- Timestamp:
- 03/19/10 04:56:06 (15 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TSP/3.3/PathTSPTour.cs
r3104 r3107 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; … … 28 29 namespace HeuristicLab.Problems.TSP { 29 30 /// <summary> 30 /// Represents a tour of a Traveling Salesman Problem which can be visualized in the GUI.31 /// Represents a tour of a Traveling Salesman Problem given in path representation which can be visualized in the GUI. 31 32 /// </summary> 32 [Item(" TSPTour", "Represents a tour of a Traveling Salesman Problemwhich can be visualized in the GUI.")]33 [Item("PathTSPTour", "Represents a tour of a Traveling Salesman Problem given in path representation which can be visualized in the GUI.")] 33 34 [StorableClass] 34 public sealed class TSPTour : Item {35 public sealed class PathTSPTour : Item { 35 36 private DoubleMatrix coordinates; 36 37 [Storable] … … 40 41 if (value == null) throw new ArgumentNullException(); 41 42 if (coordinates != value) { 43 if (coordinates != null) DeregisterCoordinatesEvents(); 42 44 coordinates = value; 45 if (coordinates != null) RegisterCoordinatesEvents(); 43 46 OnCoordinatesChanged(); 44 47 } … … 52 55 if (value == null) throw new ArgumentNullException(); 53 56 if (permutation != value) { 57 if (permutation != null) DeregisterPermutationEvents(); 54 58 permutation = value; 59 if (permutation != null) RegisterCoordinatesEvents(); 55 60 OnPermutationChanged(); 56 61 } … … 58 63 } 59 64 60 private TSPTour() : base() { }61 public TSPTour(DoubleMatrix coordinates, Permutation permutation)65 private PathTSPTour() : base() { } 66 public PathTSPTour(DoubleMatrix coordinates, Permutation permutation) 62 67 : base() { 63 if ((coordinates == null) || (permutation == null)) throw new ArgumentNullException(); 64 this.coordinates = coordinates; 65 this.permutation = permutation; 68 Coordinates = coordinates; 69 Permutation = permutation; 66 70 } 67 71 68 72 public override IDeepCloneable Clone(Cloner cloner) { 69 TSPTour clone = new TSPTour((DoubleMatrix)cloner.Clone(coordinates), (Permutation)cloner.Clone(permutation));73 PathTSPTour clone = new PathTSPTour(); 70 74 cloner.RegisterClonedObject(this, clone); 75 clone.Coordinates = (DoubleMatrix)cloner.Clone(coordinates); 76 clone.Permutation = (Permutation)cloner.Clone(permutation); 71 77 return clone; 72 78 } 73 79 80 #region Events 74 81 public event EventHandler CoordinatesChanged; 75 82 private void OnCoordinatesChanged() { … … 82 89 PermutationChanged(this, EventArgs.Empty); 83 90 } 91 92 private void RegisterCoordinatesEvents() { 93 Coordinates.ItemChanged += new EventHandler<EventArgs<int, int>>(Coordinates_ItemChanged); 94 Coordinates.Reset += new EventHandler(Coordinates_Reset); 95 } 96 private void DeregisterCoordinatesEvents() { 97 Coordinates.ItemChanged -= new EventHandler<EventArgs<int, int>>(Coordinates_ItemChanged); 98 Coordinates.Reset -= new EventHandler(Coordinates_Reset); 99 } 100 private void RegisterPermutationEvents() { 101 Permutation.ItemChanged += new EventHandler<EventArgs<int>>(Permutation_ItemChanged); 102 Permutation.Reset += new EventHandler(Permutation_Reset); 103 } 104 private void DeregisterPermutationEvents() { 105 Permutation.ItemChanged -= new EventHandler<EventArgs<int>>(Permutation_ItemChanged); 106 Permutation.Reset -= new EventHandler(Permutation_Reset); 107 } 108 109 private void Coordinates_ItemChanged(object sender, EventArgs<int, int> e) { 110 OnCoordinatesChanged(); 111 } 112 private void Coordinates_Reset(object sender, EventArgs e) { 113 OnCoordinatesChanged(); 114 } 115 private void Permutation_ItemChanged(object sender, EventArgs<int> e) { 116 OnPermutationChanged(); 117 } 118 private void Permutation_Reset(object sender, EventArgs e) { 119 OnPermutationChanged(); 120 } 121 #endregion 84 122 } 85 123 }
Note: See TracChangeset
for help on using the changeset viewer.