summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.vscode/settings.json2
-rw-r--r--src/CS340.Plotter/Plot.Designer.cs88
-rw-r--r--src/CS340.Plotter/Plot.cs45
-rw-r--r--src/CS340.Plotter/Program.cs2
4 files changed, 99 insertions, 38 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 7a73a41..6661e88 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,2 +1,4 @@
{
+ "terminal.integrated.shell.windows": "cmd",
+ "terminal.integrated.shellArgs.windows": []
} \ No newline at end of file
diff --git a/src/CS340.Plotter/Plot.Designer.cs b/src/CS340.Plotter/Plot.Designer.cs
index 4bab6c8..e509bdc 100644
--- a/src/CS340.Plotter/Plot.Designer.cs
+++ b/src/CS340.Plotter/Plot.Designer.cs
@@ -1,7 +1,7 @@

namespace Plotter
{
- partial class Plot
+ partial class PlotWindow
{
/// <summary>
/// Required designer variable.
@@ -51,6 +51,9 @@ namespace Plotter
this.BruteForceLabel = new System.Windows.Forms.Label();
this.EstimatedLabel = new System.Windows.Forms.Label();
this.MSTLabel = new System.Windows.Forms.Label();
+ this.NextGraph = new System.Windows.Forms.Button();
+ this.PrevGraph = new System.Windows.Forms.Button();
+ this.GraphLabel = new System.Windows.Forms.Label();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
@@ -77,7 +80,7 @@ namespace Plotter
this.BruteForcePlot.Dock = System.Windows.Forms.DockStyle.Fill;
this.BruteForcePlot.Location = new System.Drawing.Point(3, 3);
this.BruteForcePlot.Name = "BruteForcePlot";
- this.BruteForcePlot.Size = new System.Drawing.Size(248, 241);
+ this.BruteForcePlot.Size = new System.Drawing.Size(248, 213);
this.BruteForcePlot.TabIndex = 0;
this.BruteForcePlot.TabStop = false;
//
@@ -86,7 +89,7 @@ namespace Plotter
this.EstimationPlot.Dock = System.Windows.Forms.DockStyle.Fill;
this.EstimationPlot.Location = new System.Drawing.Point(257, 3);
this.EstimationPlot.Name = "EstimationPlot";
- this.EstimationPlot.Size = new System.Drawing.Size(248, 241);
+ this.EstimationPlot.Size = new System.Drawing.Size(248, 213);
this.EstimationPlot.TabIndex = 1;
this.EstimationPlot.TabStop = false;
//
@@ -95,7 +98,7 @@ namespace Plotter
this.MSTPlot.Dock = System.Windows.Forms.DockStyle.Fill;
this.MSTPlot.Location = new System.Drawing.Point(511, 3);
this.MSTPlot.Name = "MSTPlot";
- this.MSTPlot.Size = new System.Drawing.Size(250, 241);
+ this.MSTPlot.Size = new System.Drawing.Size(250, 213);
this.MSTPlot.TabIndex = 2;
this.MSTPlot.TabStop = false;
//
@@ -115,15 +118,19 @@ namespace Plotter
this.LayoutPanel.Controls.Add(this.EstimatedLabel, 1, 1);
this.LayoutPanel.Controls.Add(this.MSTPlot, 2, 0);
this.LayoutPanel.Controls.Add(this.MSTLabel, 2, 1);
+ this.LayoutPanel.Controls.Add(this.NextGraph, 2, 4);
+ this.LayoutPanel.Controls.Add(this.PrevGraph, 0, 4);
+ this.LayoutPanel.Controls.Add(this.GraphLabel, 1, 4);
this.LayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.LayoutPanel.Location = new System.Drawing.Point(0, 0);
this.LayoutPanel.Name = "LayoutPanel";
- this.LayoutPanel.RowCount = 4;
+ this.LayoutPanel.RowCount = 5;
this.LayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.LayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.LayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.LayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
- this.LayoutPanel.Size = new System.Drawing.Size(764, 311);
+ this.LayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.LayoutPanel.Size = new System.Drawing.Size(764, 312);
this.LayoutPanel.TabIndex = 4;
//
// tableLayoutPanel1
@@ -137,7 +144,7 @@ namespace Plotter
this.tableLayoutPanel1.Controls.Add(this.BruteForceWeightLabel, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.BruteForceTimeLabel, 0, 1);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 274);
+ this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 246);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
@@ -192,7 +199,7 @@ namespace Plotter
this.BruteForceTimeLabel.Size = new System.Drawing.Size(67, 17);
this.BruteForceTimeLabel.TabIndex = 9;
this.BruteForceTimeLabel.Text = "Runtime:";
- this.BruteForceTimeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.BruteForceTimeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// tableLayoutPanel5
//
@@ -205,7 +212,7 @@ namespace Plotter
this.tableLayoutPanel5.Controls.Add(this.EstimatedWeightLabel, 0, 0);
this.tableLayoutPanel5.Controls.Add(this.EstimatedTimeLabel, 0, 1);
this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
- this.tableLayoutPanel5.Location = new System.Drawing.Point(257, 274);
+ this.tableLayoutPanel5.Location = new System.Drawing.Point(257, 246);
this.tableLayoutPanel5.Name = "tableLayoutPanel5";
this.tableLayoutPanel5.RowCount = 2;
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
@@ -259,7 +266,7 @@ namespace Plotter
this.EstimatedTimeLabel.Size = new System.Drawing.Size(67, 17);
this.EstimatedTimeLabel.TabIndex = 9;
this.EstimatedTimeLabel.Text = "Runtime:";
- this.EstimatedTimeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.EstimatedTimeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// tableLayoutPanel6
//
@@ -272,7 +279,7 @@ namespace Plotter
this.tableLayoutPanel6.Controls.Add(this.MSTWeightLabel, 0, 0);
this.tableLayoutPanel6.Controls.Add(this.MSTTimeLabel, 0, 1);
this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill;
- this.tableLayoutPanel6.Location = new System.Drawing.Point(511, 274);
+ this.tableLayoutPanel6.Location = new System.Drawing.Point(511, 246);
this.tableLayoutPanel6.Name = "tableLayoutPanel6";
this.tableLayoutPanel6.RowCount = 2;
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
@@ -326,43 +333,77 @@ namespace Plotter
this.MSTTimeLabel.Size = new System.Drawing.Size(67, 17);
this.MSTTimeLabel.TabIndex = 9;
this.MSTTimeLabel.Text = "Runtime:";
- this.MSTTimeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.MSTTimeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// BruteForceLabel
//
this.BruteForceLabel.AutoSize = true;
this.BruteForceLabel.Dock = System.Windows.Forms.DockStyle.Top;
this.BruteForceLabel.Font = new System.Drawing.Font("Arial", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- this.BruteForceLabel.Location = new System.Drawing.Point(3, 247);
+ this.BruteForceLabel.Location = new System.Drawing.Point(3, 219);
this.BruteForceLabel.Name = "BruteForceLabel";
this.BruteForceLabel.Size = new System.Drawing.Size(248, 24);
this.BruteForceLabel.TabIndex = 3;
this.BruteForceLabel.Text = "Brute Force";
- this.BruteForceLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
+ this.BruteForceLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// EstimatedLabel
//
this.EstimatedLabel.AutoSize = true;
this.EstimatedLabel.Dock = System.Windows.Forms.DockStyle.Top;
this.EstimatedLabel.Font = new System.Drawing.Font("Arial", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- this.EstimatedLabel.Location = new System.Drawing.Point(257, 247);
+ this.EstimatedLabel.Location = new System.Drawing.Point(257, 219);
this.EstimatedLabel.Name = "EstimatedLabel";
this.EstimatedLabel.Size = new System.Drawing.Size(248, 24);
this.EstimatedLabel.TabIndex = 4;
this.EstimatedLabel.Text = "Estimated";
- this.EstimatedLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
+ this.EstimatedLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// MSTLabel
//
this.MSTLabel.AutoSize = true;
this.MSTLabel.Dock = System.Windows.Forms.DockStyle.Top;
this.MSTLabel.Font = new System.Drawing.Font("Arial", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- this.MSTLabel.Location = new System.Drawing.Point(511, 247);
+ this.MSTLabel.Location = new System.Drawing.Point(511, 219);
this.MSTLabel.Name = "MSTLabel";
this.MSTLabel.Size = new System.Drawing.Size(250, 24);
this.MSTLabel.TabIndex = 5;
this.MSTLabel.Text = "MST";
- this.MSTLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
+ this.MSTLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // NextGraph
+ //
+ this.NextGraph.Dock = System.Windows.Forms.DockStyle.Right;
+ this.NextGraph.Location = new System.Drawing.Point(686, 286);
+ this.NextGraph.Name = "NextGraph";
+ this.NextGraph.Size = new System.Drawing.Size(75, 23);
+ this.NextGraph.TabIndex = 15;
+ this.NextGraph.Text = "Next Graph";
+ this.NextGraph.UseVisualStyleBackColor = true;
+ this.NextGraph.Click += new System.EventHandler(this.NextGraph_Click);
+ //
+ // PrevGraph
+ //
+ this.PrevGraph.Dock = System.Windows.Forms.DockStyle.Left;
+ this.PrevGraph.Location = new System.Drawing.Point(3, 286);
+ this.PrevGraph.Name = "PrevGraph";
+ this.PrevGraph.Size = new System.Drawing.Size(75, 23);
+ this.PrevGraph.TabIndex = 16;
+ this.PrevGraph.Text = "Previous Graph";
+ this.PrevGraph.UseVisualStyleBackColor = true;
+ this.PrevGraph.Click += new System.EventHandler(this.PrevGraph_Click);
+ //
+ // GraphLabel
+ //
+ this.GraphLabel.AutoSize = true;
+ this.GraphLabel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.GraphLabel.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.GraphLabel.Location = new System.Drawing.Point(257, 283);
+ this.GraphLabel.Name = "GraphLabel";
+ this.GraphLabel.Size = new System.Drawing.Size(248, 29);
+ this.GraphLabel.TabIndex = 17;
+ this.GraphLabel.Text = "Graph 1";
+ this.GraphLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// tableLayoutPanel2
//
@@ -481,15 +522,15 @@ namespace Plotter
this.label9.Text = "123.342";
this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
- // Plot
+ // PlotWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(764, 311);
+ this.ClientSize = new System.Drawing.Size(764, 312);
this.Controls.Add(this.LayoutPanel);
this.MinimumSize = new System.Drawing.Size(780, 350);
- this.Name = "Plot";
- this.Text = "Plot";
+ this.Name = "PlotWindow";
+ this.Text = "TSP: Graph 1";
this.SizeChanged += new System.EventHandler(this.Canvas_SizeChanged);
((System.ComponentModel.ISupportInitialize)(this.BruteForcePlot)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.EstimationPlot)).EndInit();
@@ -546,6 +587,9 @@ namespace Plotter
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
+ private System.Windows.Forms.Button NextGraph;
+ private System.Windows.Forms.Button PrevGraph;
+ private System.Windows.Forms.Label GraphLabel;
}
}
diff --git a/src/CS340.Plotter/Plot.cs b/src/CS340.Plotter/Plot.cs
index 611e06f..636d955 100644
--- a/src/CS340.Plotter/Plot.cs
+++ b/src/CS340.Plotter/Plot.cs
@@ -7,35 +7,34 @@ using TSP;
namespace Plotter
{
- public partial class Plot : Form
+ public partial class PlotWindow : Form
{
// List<TourPlot[]> Plots;
List<TourPlot[]> Plots = new();
+ int CurrentGraph { get; set; } = 0;
- public Plot()
+ public PlotWindow()
{
InitializeComponent();
foreach (string graphFile in Directory.GetFiles("graphs/", "*.txt"))
- GetTours(graphFile);
+ Plots.Add(GetTourSet(graphFile));
+
+ NextGraph.Enabled = (Plots.Count > 1);
+ PrevGraph.Enabled = false;
RenderWindow(debug: true);
}
void RenderWindow(bool debug = false)
{
- foreach (var plot in Plots)
- {
- if (debug)
- plot[0].WriteDebug();
-
- plot[0].Render();
- plot[1].Render();
- plot[2].Render();
- }
+ Text = $"TSP: Graph {CurrentGraph + 1}";
+ GraphLabel.Text = $"Graph {CurrentGraph + 1}";
+ foreach (var plot in Plots[CurrentGraph])
+ plot.Render();
}
- void GetTours(string graphFile)
+ TourPlot[] GetTourSet(string graphFile)
{
string coordsFile = graphFile.Replace(".txt", ".csv");
@@ -57,19 +56,35 @@ namespace Plotter
stopWatch.Stop();
estimation.RunTime = stopWatch.Elapsed;
-
+
stopWatch.Reset();
stopWatch.Start();
mst.Tour = Solve.MST(graphFile, coordsFile, 0);
stopWatch.Stop();
mst.RunTime = stopWatch.Elapsed;
- Plots.Add(new[] { bruteForce, estimation, mst });
+ return new[] { bruteForce, estimation, mst };
}
private void Canvas_SizeChanged(object sender, EventArgs e)
{
RenderWindow();
}
+
+ private void NextGraph_Click(object sender, EventArgs e)
+ {
+ CurrentGraph++;
+ RenderWindow();
+ PrevGraph.Enabled = true;
+ NextGraph.Enabled = (CurrentGraph < Plots.Count - 1);
+ }
+
+ private void PrevGraph_Click(object sender, EventArgs e)
+ {
+ CurrentGraph--;
+ RenderWindow();
+ NextGraph.Enabled = true;
+ PrevGraph.Enabled = (CurrentGraph > 0);
+ }
}
}
diff --git a/src/CS340.Plotter/Program.cs b/src/CS340.Plotter/Program.cs
index cfffac2..d9175fe 100644
--- a/src/CS340.Plotter/Program.cs
+++ b/src/CS340.Plotter/Program.cs
@@ -24,7 +24,7 @@ namespace Plotter
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Plot());
+ Application.Run(new PlotWindow());
}
}
}