Skip to content

Commit

Permalink
Merge branch 'main' into CC2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
miniJmo authored Dec 10, 2024
2 parents e8ff73b + c002797 commit 7d58c14
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Assets/Prefabs/UI/VisualizationSettings.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 30 additions & 3 deletions Assets/Scripts/Simulation/PatrollingSimulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ protected override void CreateStatisticsFile()
var waypointFilename = Path.Join(folderPath, $"waypoint_{point.x}_{point.y}");
new CsvDataWriter<WaypointSnapShot>(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)
Expand All @@ -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)
{
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!;

Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit 7d58c14

Please sign in to comment.