diff --git a/Assets/Prefabs/UI/VisualizationSettings.prefab b/Assets/Prefabs/UI/VisualizationSettings.prefab index dd6c5e81..4dff0390 100644 --- a/Assets/Prefabs/UI/VisualizationSettings.prefab +++ b/Assets/Prefabs/UI/VisualizationSettings.prefab @@ -1091,7 +1091,7 @@ GameObject: - component: {fileID: 6565508993320586232} - component: {fileID: 5786503876836124102} m_Layer: 5 - m_Name: ToggleIdleGraph + m_Name: ToggleIdleGraphButton m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/Assets/Scripts/Simulation/PatrollingSimulation.cs b/Assets/Scripts/Simulation/PatrollingSimulation.cs index f680bef2..ff41c75b 100644 --- a/Assets/Scripts/Simulation/PatrollingSimulation.cs +++ b/Assets/Scripts/Simulation/PatrollingSimulation.cs @@ -79,7 +79,9 @@ protected override void CreateStatisticsFile() var waypointFilename = Path.Join(folderPath, $"waypoint_{point.x}_{point.y}"); new CsvDataWriter(snapShots, waypointFilename).CreateCsvFileNoPrepare(); } - SaveChart(folderPath); + // Todo: Save Graph + // The Saving doesnt work due to the simulation finishing before enough frames have passed to allow the graph to update and save. + // SaveChart(folderPath); } private void SaveChart(string folderPath) @@ -90,7 +92,6 @@ private void SaveChart(string folderPath) } Debug.Log("Saving chart..."); - var path = Path.Join(folderPath, "chart.png"); if (!Tracker.Chart.gameObject.activeSelf) { @@ -104,7 +105,33 @@ private void SaveChart(string folderPath) Tracker.Chart.SetAllDirty(); Tracker.Chart.RefreshAllComponent(); Tracker.Chart.RefreshChart(); - Tracker.Chart.SaveAsImage("png", path); + + var path = Path.Join(folderPath, "chart-all-idleness.png"); + SaveSeries(path, true, true, true, false); + + path = Path.Join(folderPath, "worst-idleness.png"); + SaveSeries(path, true, false, false, false); + + path = Path.Join(folderPath, "average-idleness.png"); + SaveSeries(path, false, true, false, false); + + path = Path.Join(folderPath, "current-idleness.png"); + SaveSeries(path, false, false, true, false); + + path = Path.Join(folderPath, "total-distance-idleness.png"); + SaveSeries(path, false, false, false, true); + + void SaveSeries(string path, bool saveWorstIdleness, bool saveAverageIdleness, bool saveCurrentIdleness, bool saveTotalDistance) + { + var copiedChart = Instantiate(PatrollingTracker.Chart); + copiedChart.series[0].show = saveWorstIdleness; + copiedChart.series[1].show = saveAverageIdleness; + copiedChart.series[2].show = saveCurrentIdleness; + copiedChart.series[3].show = saveTotalDistance; + copiedChart.RefreshGraph(); + + copiedChart.SaveAsImage("png", path); + } } public void SetSelectedVertex(VertexVisualizer? newSelectedVertex) diff --git a/Assets/Scripts/UI/SimulationInfoUIControllers/PatrollingInfoUIController.cs b/Assets/Scripts/UI/SimulationInfoUIControllers/PatrollingInfoUIController.cs index 6b3bba43..f074d5f3 100644 --- a/Assets/Scripts/UI/SimulationInfoUIControllers/PatrollingInfoUIController.cs +++ b/Assets/Scripts/UI/SimulationInfoUIControllers/PatrollingInfoUIController.cs @@ -18,7 +18,6 @@ public sealed class PatrollingInfoUIController : SimulationInfoUIControllerBase< { private static readonly float MaxRobotHighlightingSize = 25.0f; public BaseChart Chart = null!; - public GameObject GraphControlPanel; public Image ProgressBarMask = null!; public TextMeshProUGUI ProgressText = null!; @@ -221,7 +220,7 @@ private void SetAverageGraphIdleness(float idleness) private void ToggleGraph() { Chart.gameObject.SetActive(!Chart.gameObject.activeSelf); - GraphControlPanel.SetActive(!GraphControlPanel.activeSelf); + ToogleIdleGraphButton.image.color = Chart.gameObject.activeSelf ? new Color(150 / 255f, 200 / 255f, 150 / 255f) : Color.white; } } } \ No newline at end of file