private void UpdateSitesMask() { for (int i = 0; i < dataLayer.loadedPatchesInView.Count; i++) { GridedPatch patch = dataLayer.loadedPatchesInView[i] as GridedPatch; if (patch != null) { patch.SetCategoryMask(mask); } } // Also update other patches from the same site but different record if (dataLayer.loadedPatchesInView.Count > 0) { var siteRecord = dataLayer.loadedPatchesInView[0].siteRecord; foreach (var record in siteRecord.layerSite.records) { if (record.Value == siteRecord) { continue; } foreach (var patch in record.Value.patches) { (patch as GridedPatch).SetCategoryMask(mask); } } } }
protected override void OnPatchVisibilityChange(DataLayer dataLayer, Patch patch, bool visible) { base.OnPatchVisibilityChange(dataLayer, patch, visible); bool rebuildLayout = false; if (visible) { if (AllSitesHaveSameCategories()) { if (toggles.Count == 0) { UpdateList(); rebuildLayout = true; } else { GridedPatch gridedPatch = patch as GridedPatch; gridedPatch.SetCategoryMask(mask); } } else { ClearList(); rebuildLayout = true; } (patch.Data as GridData).OnGridChange += OnGridChange; } else { if (dataLayer.HasLoadedPatchesInView() && AllSitesHaveSameCategories()) { if (toggles.Count == 0) { UpdateList(); rebuildLayout = true; } } else { ClearList(); rebuildLayout = true; } (patch.Data as GridData).OnGridChange -= OnGridChange; } if (rebuildLayout) { GuiUtils.RebuildLayout(transform); } }
private void OnCategoryHover(int index, bool hover) { index = hover ? index : -1; for (int i = 0; i < dataLayer.loadedPatchesInView.Count; i++) { GridedPatch patch = dataLayer.loadedPatchesInView[i] as GridedPatch; if (patch != null) { var mapLayer = patch.GetMapLayer() as GridMapLayer; mapLayer.HighlightCategory(index); } } }
private void _UpdateChart() { nextValidUpdateTime = Time.time + ChartUpdateInterval; ClearChartValues(); float minValue = float.MaxValue; float maxValue = float.MinValue; float minRange; float maxRange; for (int i = 0; i < dataLayer.loadedPatchesInView.Count; i++) { GridedPatch patch = dataLayer.loadedPatchesInView[i] as GridedPatch; if (patch == null) { continue; } var grid = patch.grid; if (grid.minValue != float.MaxValue) { minValue = Mathf.Min(minValue, grid.minValue); maxValue = Mathf.Max(maxValue, grid.maxValue); minRange = Mathf.InverseLerp(siteMinValue, siteMaxValue, grid.minValue); maxRange = Mathf.InverseLerp(siteMinValue, siteMaxValue, grid.maxValue); } else { minValue = 0; maxValue = 0; minRange = 0; maxRange = 0; } var dv = grid.DistributionValues; int distribSize = 0; if (dv != null) { distribSize = dv.Length; } float invSize = 1f / distribSize; float f1 = minRange * chartSize; int ci1 = (int)f1; float f2; int ci2; float countPerChartSlot = distribSize / ((maxRange - minRange) * chartSize); for (int j = 1; j <= distribSize; j++) { f2 = chartSize * Mathf.Lerp(minRange, maxRange, j * invSize); ci2 = (int)f2; if (ci1 == ci2) { chartValues[ci1] += dv[j - 1]; maxChartValue = Mathf.Max(maxChartValue, chartValues[ci1]); } else { float x = dv[j - 1] * countPerChartSlot; float p = ci1 - f1 + 1f; chartValues[ci1] += p * x; maxChartValue = Mathf.Max(maxChartValue, chartValues[ci1]); for (int ci = ci1 + 1; ci < ci2; ci++) { chartValues[ci] += x; maxChartValue = Mathf.Max(maxChartValue, chartValues[ci]); } if (ci2 < chartSize) { p = f2 - ci2; chartValues[ci2] += p * x; maxChartValue = Mathf.Max(maxChartValue, chartValues[ci2]); } } f1 = f2; ci1 = ci2; } } chart.SetMinRange(Mathf.InverseLerp(siteMinValue, siteMaxValue, minValue)); chart.SetMaxRange(Mathf.InverseLerp(siteMinValue, siteMaxValue, maxValue)); chart.SetData(chartValues, maxChartValue); }