summaryrefslogtreecommitdiffstats
path: root/src/CS340.Plotter/Plot.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/CS340.Plotter/Plot.cs')
-rw-r--r--src/CS340.Plotter/Plot.cs40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/CS340.Plotter/Plot.cs b/src/CS340.Plotter/Plot.cs
index 7028d29..89894e4 100644
--- a/src/CS340.Plotter/Plot.cs
+++ b/src/CS340.Plotter/Plot.cs
@@ -23,10 +23,10 @@ namespace Plotter
NextGraph.Enabled = (Plots.Count > 1);
PrevGraph.Enabled = false;
- RenderWindow(debug: true);
+ RenderWindow();
}
- void RenderWindow(bool debug = false)
+ void RenderWindow()
{
Text = $"TSP: Graph {CurrentGraph + 1}";
GraphLabel.Text = $"Graph {CurrentGraph + 1}";
@@ -40,7 +40,7 @@ namespace Plotter
TourPlot bruteForce = new(BruteForcePlot, BruteForceWeight, BruteForceTime);
- TourPlot estimation = new(EstimationPlot, EstimatedWeight, EstimatedTime);
+ TourPlot approximate = new(EstimationPlot, EstimatedWeight, EstimatedTime);
TourPlot mst = new(MSTPlot, MSTWeight, MSTTime);
Stopwatch stopWatch = new Stopwatch();
@@ -52,9 +52,9 @@ namespace Plotter
stopWatch.Reset();
stopWatch.Start();
- estimation.Tour = TSPSolver.Approximate(graphFile, coordsFile, 0); // TODO create estimation function
+ approximate.Tour = TSPSolver.Approximate(graphFile, coordsFile, 0); // TODO create estimation function
stopWatch.Stop();
- estimation.RunTime = stopWatch.Elapsed;
+ approximate.RunTime = stopWatch.Elapsed;
stopWatch.Reset();
@@ -63,7 +63,14 @@ namespace Plotter
stopWatch.Stop();
mst.RunTime = stopWatch.Elapsed;
- return new[] { bruteForce, estimation, mst };
+ return new[] { bruteForce, approximate, mst };
+ }
+
+ private void SaveSet(string folderName, int graphNum)
+ {
+ Plots[graphNum][0].Save(Path.Join(folderName, $"graph{graphNum + 1}_trueshortest.png"));
+ Plots[graphNum][1].Save(Path.Join(folderName, $"graph{graphNum + 1}_approximate.png"));
+ Plots[graphNum][2].Save(Path.Join(folderName, $"graph{graphNum + 1}_mst.png"));
}
private void Canvas_SizeChanged(object sender, EventArgs e)
@@ -86,5 +93,26 @@ namespace Plotter
NextGraph.Enabled = true;
PrevGraph.Enabled = (CurrentGraph > 0);
}
+
+ private void SaveGraph_Click(object sender, EventArgs e)
+ {
+ var folderBrowserDialog = new FolderBrowserDialog();
+
+ // Show the FolderBrowserDialog.
+ DialogResult result = folderBrowserDialog.ShowDialog();
+ if (result == DialogResult.OK)
+ SaveSet(folderBrowserDialog.SelectedPath, CurrentGraph);
+ }
+
+ private void SaveAll_Click(object sender, EventArgs e)
+ {
+ var folderBrowserDialog = new FolderBrowserDialog();
+
+ // Show the FolderBrowserDialog.
+ DialogResult result = folderBrowserDialog.ShowDialog();
+ if (result == DialogResult.OK)
+ for (int i = 0; i < Plots.Count; i++)
+ SaveSet(folderBrowserDialog.SelectedPath, i);
+ }
}
}