Changeset 3153
- Timestamp:
- 03/22/10 01:00:52 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/HeuristicLab.Problems.TSP.Views-3.3.csproj
r3151 r3153 152 152 <Name>HeuristicLab.Optimization-3.3</Name> 153 153 </ProjectReference> 154 <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj"> 155 <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project> 156 <Name>HeuristicLab.Parameters-3.3</Name> 157 </ProjectReference> 154 158 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 155 159 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> -
trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/HeuristicLabProblemsTSPViewsPlugin.cs.frame
r3151 r3153 38 38 [PluginDependency("HeuristicLab.Optimization", "3.3")] 39 39 [PluginDependency("HeuristicLab.Optimization.Views", "3.3")] 40 [PluginDependency("HeuristicLab.Parameters", "3.3")] 40 41 [PluginDependency("HeuristicLab.Problems.TSP", "3.3")] 41 42 public class HeuristicLabProblemsTSPViewsPlugin : PluginBase { -
trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/PathTSPTourView.cs
r3139 r3153 69 69 base.OnContentChanged(); 70 70 if (Content == null) { 71 pictureBox.Image = null; 71 72 pictureBox.Enabled = false; 72 73 } else { 73 74 pictureBox.Enabled = true; 75 GenerateImage(); 74 76 } 75 GenerateImage();76 77 } 77 78 … … 85 86 Bitmap bitmap = new Bitmap(pictureBox.Width, pictureBox.Height); 86 87 87 if ( coordinates != null) {88 if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) { 88 89 double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue; 89 90 for (int i = 0; i < coordinates.Rows; i++) { … … 99 100 100 101 Point[] points = new Point[coordinates.Rows]; 101 if (permutation == null) { 102 for (int i = 0; i < coordinates.Rows; i++) 103 points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)), 104 border + ((int)((coordinates[i, 1] - yMin) * yStep))); 105 } else { 106 for (int i = 0; i < coordinates.Rows; i++) 107 points[i] = new Point(border + ((int)((coordinates[permutation[i], 0] - xMin) * xStep)), 108 border + ((int)((coordinates[permutation[i], 1] - yMin) * yStep))); 109 } 102 for (int i = 0; i < coordinates.Rows; i++) 103 points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)), 104 border + ((int)((coordinates[i, 1] - yMin) * yStep))); 110 105 111 106 Graphics graphics = Graphics.FromImage(bitmap); 112 if (permutation != null) graphics.DrawPolygon(Pens.Black, points); 107 if ((permutation != null) && (permutation.Length == coordinates.Rows) && (permutation.Validate())) { 108 Point[] tour = new Point[permutation.Length]; 109 for (int i = 0; i < permutation.Length; i++) { 110 tour[i] = points[permutation[i]]; 111 } 112 graphics.DrawPolygon(Pens.Black, tour); 113 } 113 114 for (int i = 0; i < points.Length; i++) 114 115 graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, 6, 6); -
trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPLIBImportDialog.cs
r3151 r3153 27 27 28 28 namespace HeuristicLab.Problems.TSP.Views { 29 public partial class TSPLIBImportDialog : Form {29 public sealed partial class TSPLIBImportDialog : Form { 30 30 private string tspFileName; 31 31 public string TSPFileName { -
trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPView.Designer.cs
r3151 r3153 47 47 private void InitializeComponent() { 48 48 this.importButton = new System.Windows.Forms.Button(); 49 this.tabControl = new System.Windows.Forms.TabControl(); 50 this.parametersTabPage = new System.Windows.Forms.TabPage(); 51 this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView(); 52 this.visualizationTabPage = new System.Windows.Forms.TabPage(); 53 this.pathTSPTourView = new HeuristicLab.Problems.TSP.Views.PathTSPTourView(); 49 54 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 55 this.tabControl.SuspendLayout(); 56 this.parametersTabPage.SuspendLayout(); 57 this.visualizationTabPage.SuspendLayout(); 50 58 this.SuspendLayout(); 51 //52 // parameterCollectionView53 //54 this.parameterCollectionView.Size = new System.Drawing.Size(529, 341);55 59 // 56 60 // nameTextBox … … 76 80 this.importButton.Click += new System.EventHandler(this.importButton_Click); 77 81 // 82 // tabControl 83 // 84 this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 85 | System.Windows.Forms.AnchorStyles.Left) 86 | System.Windows.Forms.AnchorStyles.Right))); 87 this.tabControl.Controls.Add(this.parametersTabPage); 88 this.tabControl.Controls.Add(this.visualizationTabPage); 89 this.tabControl.Location = new System.Drawing.Point(0, 52); 90 this.tabControl.Name = "tabControl"; 91 this.tabControl.SelectedIndex = 0; 92 this.tabControl.Size = new System.Drawing.Size(529, 341); 93 this.tabControl.TabIndex = 4; 94 // 95 // parametersTabPage 96 // 97 this.parametersTabPage.Controls.Add(this.parameterCollectionView); 98 this.parametersTabPage.Location = new System.Drawing.Point(4, 22); 99 this.parametersTabPage.Name = "parametersTabPage"; 100 this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3); 101 this.parametersTabPage.Size = new System.Drawing.Size(521, 315); 102 this.parametersTabPage.TabIndex = 0; 103 this.parametersTabPage.Text = "Parameters"; 104 this.parametersTabPage.UseVisualStyleBackColor = true; 105 // 106 // parameterCollectionView 107 // 108 this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 109 | System.Windows.Forms.AnchorStyles.Left) 110 | System.Windows.Forms.AnchorStyles.Right))); 111 this.parameterCollectionView.Caption = "ParameterCollection"; 112 this.parameterCollectionView.Content = null; 113 this.parameterCollectionView.Location = new System.Drawing.Point(6, 6); 114 this.parameterCollectionView.Name = "parameterCollectionView"; 115 this.parameterCollectionView.Size = new System.Drawing.Size(509, 303); 116 this.parameterCollectionView.TabIndex = 0; 117 // 118 // visualizationTabPage 119 // 120 this.visualizationTabPage.Controls.Add(this.pathTSPTourView); 121 this.visualizationTabPage.Location = new System.Drawing.Point(4, 22); 122 this.visualizationTabPage.Name = "visualizationTabPage"; 123 this.visualizationTabPage.Padding = new System.Windows.Forms.Padding(3); 124 this.visualizationTabPage.Size = new System.Drawing.Size(521, 315); 125 this.visualizationTabPage.TabIndex = 1; 126 this.visualizationTabPage.Text = "Visualization"; 127 this.visualizationTabPage.UseVisualStyleBackColor = true; 128 // 129 // pathTSPTourView 130 // 131 this.pathTSPTourView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 132 | System.Windows.Forms.AnchorStyles.Left) 133 | System.Windows.Forms.AnchorStyles.Right))); 134 this.pathTSPTourView.Caption = "View"; 135 this.pathTSPTourView.Content = null; 136 this.pathTSPTourView.Location = new System.Drawing.Point(6, 6); 137 this.pathTSPTourView.Name = "pathTSPTourView"; 138 this.pathTSPTourView.Size = new System.Drawing.Size(509, 303); 139 this.pathTSPTourView.TabIndex = 0; 140 // 78 141 // TSPView 79 142 // 80 143 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 81 144 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 145 this.Controls.Add(this.tabControl); 82 146 this.Controls.Add(this.importButton); 83 147 this.Name = "TSPView"; 84 148 this.Size = new System.Drawing.Size(529, 422); 85 149 this.Controls.SetChildIndex(this.importButton, 0); 86 this.Controls.SetChildIndex(this. parameterCollectionView, 0);150 this.Controls.SetChildIndex(this.tabControl, 0); 87 151 this.Controls.SetChildIndex(this.nameLabel, 0); 88 152 this.Controls.SetChildIndex(this.descriptionLabel, 0); … … 90 154 this.Controls.SetChildIndex(this.descriptionTextBox, 0); 91 155 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 156 this.tabControl.ResumeLayout(false); 157 this.parametersTabPage.ResumeLayout(false); 158 this.visualizationTabPage.ResumeLayout(false); 92 159 this.ResumeLayout(false); 93 160 this.PerformLayout(); … … 98 165 99 166 private System.Windows.Forms.Button importButton; 167 private System.Windows.Forms.TabControl tabControl; 168 private System.Windows.Forms.TabPage parametersTabPage; 169 private System.Windows.Forms.TabPage visualizationTabPage; 170 private HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView; 171 private PathTSPTourView pathTSPTourView; 100 172 101 173 } -
trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/TSPView.cs
r3151 r3153 22 22 using System; 23 23 using System.Windows.Forms; 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Core.Views; 25 26 using HeuristicLab.MainForm; 26 using HeuristicLab.Optimization.Views;27 27 28 28 namespace HeuristicLab.Problems.TSP.Views { … … 32 32 [View("TSP View")] 33 33 [Content(typeof(TSP), true)] 34 public sealed partial class TSPView : ProblemView {34 public sealed partial class TSPView : NamedItemView { 35 35 private TSPLIBImportDialog tsplibImportDialog; 36 36 … … 55 55 } 56 56 57 protected override void DeregisterContentEvents() { 58 Content.CoordinatesParameter.ValueChanged -= new EventHandler(CoordinatesParameter_ValueChanged); 59 Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged); 60 base.DeregisterContentEvents(); 61 } 62 protected override void RegisterContentEvents() { 63 base.RegisterContentEvents(); 64 Content.CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged); 65 Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged); 66 } 67 57 68 protected override void OnContentChanged() { 58 69 base.OnContentChanged(); 59 70 if (Content == null) { 71 parameterCollectionView.Content = null; 72 parameterCollectionView.Enabled = false; 73 pathTSPTourView.Content = null; 74 pathTSPTourView.Enabled = false; 60 75 importButton.Enabled = false; 61 76 } else { 77 parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters; 78 parameterCollectionView.Enabled = true; 79 pathTSPTourView.Content = new PathTSPTour(Content.Coordinates, Content.BestKnownSolution); 80 pathTSPTourView.Enabled = true; 62 81 importButton.Enabled = true; 63 82 } … … 79 98 } 80 99 } 100 101 private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) { 102 pathTSPTourView.Content.Coordinates = Content.Coordinates; 103 } 104 private void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) { 105 pathTSPTourView.Content.Permutation = Content.BestKnownSolution; 106 } 81 107 } 82 108 } -
trunk/sources/HeuristicLab.Problems.TSP/3.3/HeuristicLab.Problems.TSP-3.3.csproj
r3151 r3153 156 156 </ItemGroup> 157 157 <ItemGroup> 158 <None Include="ch130.opt.tour" /> 158 159 <None Include="ch130.tsp" /> 159 160 <None Include="fl1400.tsp" /> -
trunk/sources/HeuristicLab.Problems.TSP/3.3/TSP.cs
r3151 r3153 23 23 using System.Collections.Generic; 24 24 using System.Drawing; 25 using System.IO; 25 26 using System.Linq; 26 27 using HeuristicLab.Common; … … 178 179 Coordinates = new DoubleMatrix(tspParser.Vertices); 179 180 BestKnownQuality = null; 180 181 BestKnownSolution = null; 181 182 if (!string.IsNullOrEmpty(optimalTourFileName)) { 182 183 TSPLIBTourParser tourParser = new TSPLIBTourParser(optimalTourFileName); 183 184 tourParser.Parse(); 185 if (tourParser.Tour.Length != Coordinates.Rows) throw new InvalidDataException("Length of optimal tour is not equal to number of cities."); 184 186 BestKnownSolution = new Permutation(tourParser.Tour); 185 187 }
Note: See TracChangeset
for help on using the changeset viewer.