예제 #1
0
    private void _UpdateContoursInfo()
    {
        // Contours can change while the tool is not active (e.g. by changing a data layer's filter)
        // Check if tool is still active (could have been deactivated while creating analysis)
        if (isActive && allowInfoUpdate)
        {
            if (showContoursToggle.isOn && (contoursLayer.grids.Count > 0 || lockedContours != null))
            {
                contoursLayer.FetchGridValues();
                var sqm = ContourUtils.GetContoursSquareMeters(contoursLayer.Grid);

                // Show the stats FIRST to ensure proper UI colors
                infoPanel.ShowStats(true);
                infoPanel.UpdateEntry("CC", sqm);

                // Avoid doing multiple updates per frame (in case it's called outside of coroutine)
                nextUpdateFrame = Time.frameCount + 10;
            }
            else if (grids.Count > 0)
            {
                // Show the stats FIRST to ensure proper UI colors
                infoPanel.ShowStats(true);
                infoPanel.ClearEntry("CC");
            }
            else
            {
                // Show the stats LAST to ensure proper UI colors
                infoPanel.ClearEntry("CC");
                infoPanel.ShowStats(false);
            }
        }
    }
예제 #2
0
    private void UpdateSelectedContour(bool updateInfo)
    {
        var grid = contoursLayer.Grid;

        if (grid.values != null && grid.IsInside(contourSelectionCoords.Longitude, contourSelectionCoords.Latitude))
        {
            int index = (int)grid.GetValue(contourSelectionCoords.Longitude, contourSelectionCoords.Latitude);
            if (index > 0)
            {
                contoursLayer.SetSelectedContour(index);

                if (isActive && updateInfo)
                {
                    var sqm = ContourUtils.GetContoursSquareMeters(grid, true, index);
                    InfoPanel.UpdateEntry("SC", sqm);

                    contoursLayer.CalculateSelectedContourValues();
                    var inspectorTool = ComponentManager.Instance.Get <InspectorTool>();
                    if (inspectorTool.InspectOutput)
                    {
                        inspectorTool.InspectOutput.AreaOutput.UpdateContourInspectorOutput(dataLayers);
                    }
                }
                return;
            }
        }

        DeselectContour();
    }
예제 #3
0
    private void CreateSnapshot(int i, GridData gridData = null)
    {
        var id            = i + 1;
        var snapshotLabel = Translator.Get("Snapshot") + "\n" + id;
        var snapshotName  = Regex.Replace(snapshotLabel, @"\n|\r", "");

        emptySnapshots[i].gameObject.SetActive(false);
        emptySnapshots[i].SetAsLastSibling();

        // Create Snapshot
        var snapshot = new Snapshot
        {
            id   = "S" + i,
            name = snapshotName
        };

        snapshot.uiTransform      = Instantiate(snapshotPrefab, SnapshotList, false);
        snapshot.uiTransform.name = snapshotName;
        snapshot.uiTransform.SetSiblingIndex(i);

        // Setup toggle button
        var toggleButton = snapshot.uiTransform.GetComponentInChildren <Toggle>();

        toggleButton.onValueChanged.AddListener((isOn) => OnSnapshotToggleChanged(snapshot, isOn));

        // Setup delete button
        var deleteButton = snapshot.uiTransform.GetComponentInChildren <Button>();

        deleteButton.gameObject.SetActive(false);
        deleteButton.onClick.AddListener(() => OnRemoveSnapshot(snapshot));

        // Setup label
        snapshot.uiTransform.GetComponentInChildren <Text>().text = id.ToString();

        // Setup intput text
        var input = snapshot.uiTransform.GetComponentInChildren <InputField>();

        input.text = snapshotLabel;
        input.onEndEdit.AddListener((value) => OnEndEdit(value, input, snapshot));

        // Create snapshot's map layer
        snapshot.mapLayer = toolLayers.CreateMapLayer(snapshotLayerPrefab, "ContoursSnapshot", gridData);

        // Set Snapshot color
        SetColorsToSnapshot(snapshot.mapLayer, toggleButton, deleteButton);

        // Update output
        if (gridData != null)
        {
            var sqm = ContourUtils.GetContoursSquareMeters(gridData);
            infoPanel.UpdateEntry(snapshot.id, sqm);
        }

        snapshots[i] = snapshot;
        usedSnapshots++;

        runningSnapshotCounter++;
    }
예제 #4
0
    private void UpdateSelectedContour(bool updateInfo)
    {
        var grid = contoursLayer.Grid;

        if (grid.values != null && grid.IsInside(contourSelectionCoords.Longitude, contourSelectionCoords.Latitude))
        {
            int index = (int)grid.GetValue(contourSelectionCoords.Longitude, contourSelectionCoords.Latitude);
            if (index > 0)
            {
                contoursLayer.SetSelectedContour(index);

                if (isActive && updateInfo)
                {
                    var sqm = ContourUtils.GetContoursSquareMeters(grid, true, index);
                    infoPanel.UpdateEntry("SC", sqm);
                }
                return;
            }
        }

        DeselectContour();
    }
예제 #5
0
    private void CreateSnapshot(int i, GridData gridData = null)
    {
        var id            = i + 1;
        var snapshotLabel = Translator.Get("Snapshot") + "\n" + id;
        var snapshotName  = Regex.Replace(snapshotLabel, @"\n|\r", "");

        // Create Snapshot
        var snapshot = new Snapshot
        {
            id   = "S" + i,
            name = snapshotName
        };

        snapshot.uiTransform      = Instantiate(snapshotPrefab, SnapshotList, false);
        snapshot.uiTransform.name = snapshotName;
        snapshot.uiTransform.SetSiblingIndex(i);

        // Setup toggle button
        var toggleButton = snapshot.uiTransform.GetComponentInChildren <Toggle>();

        toggleButton.onValueChanged.AddListener((isOn) => OnSnapshotToggleChanged(snapshot, isOn));

        // Setup delete button
        var deleteButton = snapshot.uiTransform.GetComponentInChildren <Button>();

        deleteButton.gameObject.SetActive(false);
        deleteButton.onClick.AddListener(() => OnRemoveSnapshot(snapshot));

        // Setup label
        snapshot.uiTransform.GetComponentInChildren <Text>().text = id.ToString();

        // Setup intput text
        var input = snapshot.uiTransform.GetComponentInChildren <InputField>();

        input.text = snapshotLabel;
        input.onEndEdit.AddListener((value) => OnEndEdit(value, input, snapshot));

        // Create snapshot's map layer
        snapshot.mapLayer = toolLayers.CreateGridMapLayer(snapshotLayerPrefab, $"ContoursSnapshot_{snapshot.id}", gridData);

        // Set Snapshot color
        SetColorsToSnapshot(snapshot.mapLayer, toggleButton, deleteButton);

        // Update output and legend panel
        string titleLabel    = $"{LocalizationManager.Instance.Get("Snapshot")} {i + 1}";
        Color  snapshotColor = toggleButton.image.color;
        string snapshotID    = snapshot.id;

        InfoPanel.AddEntry(snapshotID, titleLabel, true);
        LegendPanl.AddSnapshotItem(snapshotID, snapshotColor, titleLabel);

        if (gridData != null)
        {
            var sqm = ContourUtils.GetContoursSquareMeters(gridData);
            InfoPanel.UpdateEntry(snapshotID, sqm);
        }
        InfoPanel.SetSnapshotProperties(snapshotID, i + 1, toggleButton.image.color);

        snapshots[i] = snapshot;
        editColourPanel.AddSnapshotColour(i, toggleButton.image.color);
        usedSnapshots++;
        editToggle.gameObject.SetActive(usedSnapshots >= 1);

        runningSnapshotCounter++;

        InfoPanel.UpdateRelativeToSnapshotDropdown();

        GuiUtils.RebuildLayout(SnapshotList);
    }