Exemple #1
0
 private void OnShowGrid(GridMapLayer mapLayer, bool show)
 {
     if (gridLayerController.mapLayers.Count >= 2 && areaPSUIRef.correlationWarning != null)
     {
         areaPSUIRef.correlationWarning.gameObject.SetActive(false);
     }
 }
Exemple #2
0
 private void OnShowGrid(GridMapLayer mapLayer, bool show)
 {
     if (show && !visibilityToggle.isOn)
     {
         mapLayer.Show(false);
     }
 }
Exemple #3
0
    //
    // Event Methods
    //

    private void OnShowGridMapLayer(GridMapLayer mapLayer, bool show)
    {
        if (show)
        {
            mapLayer.SetTransect(slider.value);
            mapLayer.ShowTransect(true);
        }
    }
Exemple #4
0
 private void OnShowGrid(GridMapLayer mapLayer, bool show)
 {
     // Hide map layers that are loaded after hiding all layers
     if (show && hideLayers)
     {
         mapLayer.Show(false);
     }
 }
Exemple #5
0
 public void Add(GridMapLayer layer, GridData grid, string name, Color color)
 {
     layer.Init(map, grid);
     layer.name = name;
     layer.SetColor(color);
     layer.transform.SetParent(transform, false);
     mapLayers.Add(layer);
 }
    //
    // Private Methods
    //

    private void SetColorsToSnapshot(GridMapLayer mapLayer, Toggle toggle, Button deleteButton, Color color)
    {
        toggle.image.color = color;
        toggle.GetComponent <ToggleTint>().colorOff = color;
        deleteButton.image.color = color;

        // set color for mapLayer
        mapLayer.SetColor(color);
    }
Exemple #7
0
    private void CreateGridMapLayer(GridData grid)
    {
        // Add map layer
        GridMapLayer mapLayer = gridLayers.Add(grid);

        visibleGrids.Add(mapLayer);

        mapLayer.EnableFilters(showFilteredDataOnly);
    }
Exemple #8
0
 private void DeleteMapLayer(ref GridMapLayer mapLayer)
 {
     if (mapLayer != null)
     {
         toolLayers.Remove(mapLayer);
         Destroy(mapLayer.gameObject);
         mapLayer = null;
     }
 }
Exemple #9
0
    private void OnShowGrid(GridMapLayer mapLayer, bool show)
    {
        if (show)
        {
            var gridLayerController = map.GetLayerController <GridLayerController>();
            gridLayerController.OnShowGrid -= OnShowGrid;

            FinishTurnOn(gridLayerController);
        }
    }
Exemple #10
0
    private void OnPatchVisibilityChange(DataLayer dataLayer, Patch patch, bool visible)
    {
        if (dataLayer.Name == networkLayerName)
        {
            if (visible)
            {
                SetNetworkPatch(patch as GraphPatch);
            }
            else if (patch == networkPatch)
            {
                SetNetworkPatch(null);
            }
        }
        else if (dataLayer.Name == reachabilityLayerName)
        {
            if (visible)
            {
                reachabilityPatch = patch as GridPatch;
                GridMapLayer mapLayer = reachabilityPatch.GetMapLayer() as GridMapLayer;
                if (mapLayer != null)
                {
                    mapLayer.SetStripes(stripeCount, true);
                }

                if (reachabilityPatch.grid.IsCategorized)
                {
                    ShowError(CategorizedReachabilityError);
                    ResetTool(true);
                    return;
                }
                else if (placeStart != null)
                {
                    placeStart.ReachabilityPatch = reachabilityPatch;
                }
            }
            else if (patch == reachabilityPatch)
            {
                reachabilityPatch = null;
            }
        }

        if (networkPatch == null)
        {
            ShowError(NetworkNotAvailableHereError);
            movedAwayError = true;
        }
        else if (movedAwayError)
        {
            movedAwayError = false;
            HideErrorMessage();
        }
    }
Exemple #11
0
    private void SetColorsToSnapshot(GridMapLayer mapLayer, Toggle toggle, Button deleteButton)
    {
        float snapshotHue = (runningSnapshotCounter * 0.2f) % 1f;

        Color color = Color.HSVToRGB(snapshotHue, 0.3f, 1f);

        toggle.image.color = color;
        toggle.GetComponent <ToggleTint>().colorOff = color;
        deleteButton.image.color = color;

        // set color for mapLayer
        mapLayer.SetColor(Color.HSVToRGB(snapshotHue, 1f, 1f));
    }
    /*- private void OnLocatorChange(float locator)
     * {
     *  this.locator = locator;
     *
     *  foreach (var chart in layerCharts.Values)
     *  {
     *      chart.SetLocator(locator);
     *  }
     *          foreach (var chart in customCharts.Values)
     *          {
     *                  chart.SetLocator(locator);
     *          }
     *  }-*/

    private void OnShowGrid(GridMapLayer mapLayer, bool show)
    {
        if (show)
        {
            if (lineInfo != null)
            {
                Add(mapLayer.Grid, mapLayer.Grid.patch.DataLayer.Color, layerCharts, chartsContainer);
                UpdateGridData(mapLayer.Grid);
            }
        }
        else
        {
            Remove(mapLayer.Grid, layerCharts);
        }
    }
Exemple #13
0
    private void OnShowGrid(GridMapLayer mapLayer, bool show)
    {
        // Hide message if there is one upon show grid
        if (messenger != null && messenger.messageText.text != "")
        {
            gridLayerController.OnShowGrid -= OnShowGrid;

            HideMessage();
            messenger.messageText.text = "";
            FinishTurnOn();
        }

        if (inspectorType == InspectorType.Line)
        {
            lineInspectorPanel.LineShowGridAndUpdateOutput(mapLayer, show);
        }
    }
Exemple #14
0
    private void OnShowGrid(GridMapLayer mapLayer, bool show)
    {
        var grid = mapLayer.Grid;

        if (show)
        {
            // Add to contours layer
            if (contoursLayer.IsVisible())
            {
                contoursLayer.Add(grid);
                contoursLayer.Refresh();
            }
            else
            {
                grids.Add(grid);
            }

            grid.OnFilterChange += OnGridFilterChange;
        }
        else
        {
            grid.OnFilterChange -= OnGridFilterChange;

            // Remove from contours layer
            if (contoursLayer.IsVisible())
            {
                contoursLayer.Remove(grid);
                contoursLayer.Refresh();
            }
            else
            {
                grids.Remove(grid);
            }
            grid.patch.dataLayer.SetToolOpacity(1);
        }

        if (contoursLayer.grids.Count > 0)
        {
            contoursLayer.FetchGridValues();
        }

        contoursOutput.UpdateGroup("All Contours");
        dataLayers.AutoReduceToolOpacity();
    }
Exemple #15
0
    private void OnShowGrid(GridMapLayer mapLayer, bool show)
    {
        var grid = mapLayer.Grid;

        if (show)
        {
            // Add to contours layer
            if (contoursLayer.IsVisible())
            {
                // Temporarily disable updating info. Will be updated at the end of the method
                allowInfoUpdate = false;
                contoursLayer.Add(grid);
                contoursLayer.Refresh();
                allowInfoUpdate = true;
            }
            else
            {
                grids.Add(grid);
            }
        }
        else
        {
            // Remove from contours layer
            if (contoursLayer.IsVisible())
            {
                // Temporarily disable updating info. Will be updated at the end of the method
                allowInfoUpdate = false;
                contoursLayer.Remove(grid);
                contoursLayer.Refresh();
                allowInfoUpdate = true;
            }
            else
            {
                grids.Remove(grid);
            }
            grid.patch.DataLayer.SetToolOpacity(1);
        }

        UpdateContoursInfo();

        UpdateLayersOpacity();
    }
    private void OnShowGrid(GridMapLayer mapLayer, bool show)
    {
        var otherGrid = mapLayer.Grid;

        if (show)
        {
            // Add to budget layer
            if (budgetLayer.IsVisible())
            {
                Add(otherGrid);
                budgetLayer.UpdateData();
            }
            else
            {
                grids.Add(otherGrid);
            }

            if (highlightLayer.Grid.values == null)
            {
                UpdateHighlightGrid();
            }
        }
        else
        {
            filterToggle.onValueChanged.RemoveAllListeners();

            // Remove from budget layer
            if (budgetLayer.IsVisible())
            {
                Remove(otherGrid);
                budgetLayer.UpdateData();
            }
            else
            {
                grids.Remove(otherGrid);
            }
        }

        UpdateOutput();
        dataLayers.AutoReduceToolOpacity();
    }
Exemple #17
0
    private void OnLockChanged(bool isOn)
    {
        CancelRemoveSnapshotMode();

        if (isOn)
        {
            contoursLayer.FetchGridValues();
            lockedContours = CreateMapLayer(snapshotLayerPrefab, "LockedContours", contoursLayer.Grid);
            lockedContours.Show(showContoursToggle.isOn);
        }
        else
        {
            DeleteMapLayer(ref lockedContours);
        }

        // Show/hide contours layer at the end!
        if (showContoursToggle.isOn)
        {
            ShowContoursLayer(!isOn);
        }
    }
Exemple #18
0
    public void AreaShowGridAndUpdateOutput(GridMapLayer mapLayer, bool show)
    {
        if (areaInspector.CurrAreaInspection >= 0)
        {
            var otherGrid    = mapLayer.Grid;
            var currAreaInfo = areaInfos[areaInspector.CurrAreaInspection];

            if (show)
            {
                // Add to area inspection map layer
                if (currAreaInfo.mapLayer.IsVisible())
                {
                    AddGridData(otherGrid);
                    currAreaInfo.mapLayer.Refresh(currAreaInfo.coords);
                }
                else
                {
                    areaInspector.AreaInspectorGrids.Add(otherGrid);
                }
            }
            else
            {
                // Remove from layer
                if (currAreaInfo.mapLayer.IsVisible())
                {
                    RemoveGridData(otherGrid);
                    currAreaInfo.mapLayer.Refresh(currAreaInfo.coords);
                }
                else
                {
                    areaInspector.AreaInspectorGrids.Remove(otherGrid);
                }
            }

            string dataLayerName = mapLayer.Grid.patch.DataLayer.Name;
            inspectorOutput.ShowInspectorOutputItemLabel(InspectorTool.InspectorType.Area, dataLayerName, show);
            UpdateOutput();
        }
    }
Exemple #19
0
    public void LineShowGridAndUpdateOutput(GridMapLayer mapLayer, bool show)
    {
        if (lineInspector.CurrLineInspection >= 0)
        {
            var otherGrid    = mapLayer.Grid;
            var currLineInfo = lineInfos[lineInspector.CurrLineInspection];

            if (show)
            {
                // Add to line inspection map layer
                if (currLineInfo.mapLayer.IsVisible())
                {
                    AddGridData(otherGrid);
                    currLineInfo.mapLayer.Refresh(currLineInfo.coords);
                }
                else
                {
                    lineInspector.LineInspectorGrids.Add(otherGrid);
                }
            }
            else
            {
                // Remove from layer
                if (currLineInfo.mapLayer.IsVisible())
                {
                    RemoveGridData(otherGrid);
                    currLineInfo.mapLayer.Refresh(currLineInfo.coords);
                }
                else
                {
                    lineInspector.LineInspectorGrids.Remove(otherGrid);
                }
            }

            string dataLayerName = mapLayer.Grid.patch.DataLayer.Name;
            inspectorOutput.ShowInspectorOutputItemLabel(dataLayerName, show);
            UpdateOutput();
        }
    }
Exemple #20
0
    private void TurnOff()
    {
        var gridLayerController = map.GetLayerController <GridLayerController>();

        gridLayerController.OnShowGrid -= OnShowGrid;

        // Tools
        int index = 0;
        var tools = toolsGroup.GetComponentsInChildren <Toggle>();

        foreach (var tool in tools)
        {
            int id = index++;
            OnToolChange(false, id);
            tool.onValueChanged.RemoveAllListeners();
        }
        toolsGroup.SetAllTogglesOff();
        if (lassoTool != null)
        {
            Destroy(lassoTool.gameObject);
            lassoTool = null;
        }
        if (brushTool != null)
        {
            Destroy(brushTool.gameObject);
            brushTool = null;
        }

        // Reset typologyGroup to have first typology toggle to be on
        foreach (var toggle in toggles)
        {
            toggle.isOn = false;
        }
        toggles[0].isOn = true;

        // hide typologies, show tools
        OnClickReturn();

        // Kill the planner
        if (planner != null)
        {
            planner.ShowAllFlags(true);
            Destroy(planner.gameObject);
            planner = null;
        }

        // Destroy the planning layer
        if (planningLayer != null)
        {
            toolLayers.Remove(planningLayer);
            Destroy(planningLayer.gameObject);
            planningLayer = null;
        }

        toogleTarget.GetComponentInChildren <Toggle>().onValueChanged.RemoveListener(OnToggleTargetChange);

        if (targetPanel != null)
        {
            Destroy(targetPanel.gameObject);
        }

        // Additional settings
        displayPlanningSummaryToggle.onValueChanged.RemoveListener(OnDisplayPlanningSummary);
        displayPlanningSummaryToggle.isOn = true;

        //siteBrowser.OnBeforeActiveSiteChange -= OnBeforeActiveSiteChange;
        //siteBrowser.OnAfterActiveSiteChange -= OnAfterActiveSiteChange;
    }
Exemple #21
0
    private void FinishTurnOn(GridLayerController gridLayerController)
    {
        var mapLayers = gridLayerController.mapLayers;

        // For now, just get any grid
        var referenceGridData = mapLayers[0].Grid;

        HideMessage();

        // Create the planning grid
        var grid = new GridData
        {
            countX = referenceGridData.countX,
            countY = referenceGridData.countY
        };

        grid.ChangeBounds(referenceGridData.west, referenceGridData.east, referenceGridData.north, referenceGridData.south);
        grid.InitGridValues(false);

        // Build the planning categories list
        int index = 0;
        List <IntCategory> cats = new List <IntCategory>
        {
            new IntCategory()
            {
                color = new Color(0, 0, 0, 0.2f), name = "noData", value = index++
            },
            new IntCategory()
            {
                color = Color.black, name = "empty", value = index++
            }
        };

        for (int i = 0; i < typologies.Count; ++i)
        {
            cats.Add(new IntCategory()
            {
                color = typologies[i].color,
                name  = typologies[i].name,
                value = index++
            });
        }
        grid.categories = cats.ToArray();

        // Create planning layer
        planningLayer      = Instantiate(planningLayerPrefab);
        planningLayer.name = planningLayerPrefab.name;
        planningLayer.SetCellSize(0.25f);

        // Add planning layer to tool layers
        toolLayers.Add(planningLayer, grid, "PlanningLayer", Color.white);

        var cellGroupGrid = new GridData
        {
            countX = grid.countX,
            countY = grid.countY
        };

        cellGroupGrid.ChangeBounds(grid.west, grid.east, grid.north, grid.south);
        cellGroupGrid.InitGridValues(false);

        // Create planner
        planner      = Instantiate(plannerPrefab);
        planner.name = plannerPrefab.name;
        planner.Init(typologyLibrary, planningLayer.Grid, typologies);

        // set output after initialization
        planner.SetOutput(gameObject.activeInHierarchy);

        // Select the first typology in the list (only if none selected)
        if (!typologyGroup.AnyTogglesOn() && typologies.Count > 0)
        {
            typologyGroup.transform.GetChild(0).GetComponent <TypologyToggleWithText>().toggle.isOn = true;
        }

        // Tools
        lassoTool      = Instantiate(lassoToolPrefab);
        lassoTool.name = lassoToolPrefab.name;
        lassoTool.Deactivate();
        brushTool      = Instantiate(brushToolPrefab);
        brushTool.name = brushToolPrefab.name;
        brushTool.Deactivate();

        // Setup tool callbacks
        index = 0;
        var tools = toolsGroup.GetComponentsInChildren <Toggle>();

        foreach (var tool in tools)
        {
            int id = index++;
            tool.onValueChanged.AddListener((isOn) => OnToolChange(isOn, id));
        }

        typologyGroup.gameObject.SetActive(true);

        ToggleSiteSpecificTypologies();
    }
    //
    // Event Methods
    //

    protected override void OnToggleTool(bool isOn)
    {
        if (isOn)
        {
            // Create budget layer
            budgetLayer    = toolLayers.CreateGridMapLayer(budgetLayerPrefab, "WeightedLayer");
            highlightLayer = toolLayers.CreateGridMapLayer(highlightLayerPrefab, "HighlightLayer");
            highlightLayer.Show(false);

            // Store number of childs on start
            initChildsCount = transform.childCount + 1;

            // Add slider
            foreach (var panel in dataLayers.activeLayerPanels)
            {
                UpdateSlider(panel.DataLayer, true);
            }

            // Create output panel for tool
            municipalBudgetOutput      = Instantiate(outputPrefab);
            municipalBudgetOutput.name = "MunicipalBudget_OutputPanel";
            outputPanel.SetPanel(municipalBudgetOutput.transform);
            municipalBudgetOutput.OnItemHovering += OnItemHover;

            // Add event listeners
            siteBrowser.OnBeforeActiveSiteChange += OnBeforeActiveSiteChange;
            siteBrowser.OnAfterActiveSiteChange  += OnAfterActiveSiteChange;

            // Listen to any data layers being added/removed
            dataLayers.OnLayerAvailabilityChange += OnLayerAvailabilityChange;

            // Listen to any grids being added/removed
            var gridController = map.GetLayerController <GridLayerController>();
            gridController.OnShowGrid += OnShowGrid;

            // Initialize grids list with already visible grid layers
            foreach (var layer in gridController.mapLayers)
            {
                grids.Add(layer.Grid);
            }

            ShowBudgetLayer(false);

            // Add filter toggle event
            filterToggle.onValueChanged.AddListener(OnFilterToggleChange);
            noDataToggle.onValueChanged.AddListener(OnNoDataToggleChange);
            budgetLayer.useFilters = filterToggle.isOn;

            loadDataCR = StartCoroutine(LoadData());
        }
        else
        {
            if (loadDataCR != null)
            {
                StopCoroutine(loadDataCR);
            }

            // Remove listeners
            siteBrowser.OnBeforeActiveSiteChange -= OnBeforeActiveSiteChange;
            siteBrowser.OnAfterActiveSiteChange  -= OnAfterActiveSiteChange;
            dataLayers.OnLayerAvailabilityChange -= OnLayerAvailabilityChange;
            if (map != null)
            {
                var gridController = map.GetLayerController <GridLayerController>();
                if (gridController)
                {
                    gridController.OnShowGrid -= OnShowGrid;
                }
            }

            // Remove Output panel
            outputPanel.DestroyPanel(municipalBudgetOutput.gameObject);
            municipalBudgetOutput = null;

            // Remove map layer
            DeleteAllLayers();

            // Remove sliders
            foreach (var pair in sliders)
            {
                Destroy(pair.Value.gameObject);
            }
            sliders.Clear();

            grids.Clear();

            dataLayers.ResetToolOpacity();
        }
    }