[2805] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[14185] | 3 | * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2805] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Windows.Forms;
|
---|
[14454] | 24 | using HeuristicLab.Data;
|
---|
[2805] | 25 | using HeuristicLab.MainForm;
|
---|
[7558] | 26 | using HeuristicLab.Optimization.Views;
|
---|
[2805] | 27 |
|
---|
[3158] | 28 | namespace HeuristicLab.Problems.TravelingSalesman.Views {
|
---|
[2805] | 29 | /// <summary>
|
---|
[4513] | 30 | /// A view for a Traveling Salesman Problem instance.
|
---|
[2805] | 31 | /// </summary>
|
---|
[3159] | 32 | [View("Traveling Salesman Problem View")]
|
---|
| 33 | [Content(typeof(TravelingSalesmanProblem), true)]
|
---|
[7641] | 34 | public sealed partial class TravelingSalesmanProblemView : ProblemView {
|
---|
[3159] | 35 | public new TravelingSalesmanProblem Content {
|
---|
| 36 | get { return (TravelingSalesmanProblem)base.Content; }
|
---|
[2805] | 37 | set { base.Content = value; }
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | /// <summary>
|
---|
[4513] | 41 | /// Initializes a new instance of <see cref="TravelingSalesmanProblemView"/>.
|
---|
[2805] | 42 | /// </summary>
|
---|
[3159] | 43 | public TravelingSalesmanProblemView() {
|
---|
[2805] | 44 | InitializeComponent();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
[3153] | 47 | protected override void DeregisterContentEvents() {
|
---|
| 48 | Content.CoordinatesParameter.ValueChanged -= new EventHandler(CoordinatesParameter_ValueChanged);
|
---|
[14454] | 49 | //Content.BestKnownQualityParameter.ValueChanged -= new EventHandler(BestKnownQualityParameter_ValueChanged);
|
---|
[3153] | 50 | Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged);
|
---|
| 51 | base.DeregisterContentEvents();
|
---|
| 52 | }
|
---|
| 53 | protected override void RegisterContentEvents() {
|
---|
| 54 | base.RegisterContentEvents();
|
---|
| 55 | Content.CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged);
|
---|
[14454] | 56 | //Content.BestKnownQualityParameter.ValueChanged += new EventHandler(BestKnownQualityParameter_ValueChanged);
|
---|
[3153] | 57 | Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[2998] | 60 | protected override void OnContentChanged() {
|
---|
| 61 | base.OnContentChanged();
|
---|
| 62 | if (Content == null) {
|
---|
[3153] | 63 | pathTSPTourView.Content = null;
|
---|
[2998] | 64 | } else {
|
---|
[14454] | 65 | pathTSPTourView.Content = new PathTSPTour(Content.Coordinates, Content.BestKnownSolution, new DoubleValue(Content.BestKnownQuality));
|
---|
[2998] | 66 | }
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[3904] | 69 | protected override void SetEnabledStateOfControls() {
|
---|
| 70 | base.SetEnabledStateOfControls();
|
---|
[3454] | 71 | pathTSPTourView.Enabled = Content != null;
|
---|
[14454] | 72 | updateDistanceMatrixButton.Enabled = Content != null && !ReadOnly && !Locked;
|
---|
[3454] | 73 | }
|
---|
| 74 |
|
---|
[3153] | 75 | private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 76 | pathTSPTourView.Content.Coordinates = Content.Coordinates;
|
---|
| 77 | }
|
---|
[3712] | 78 | private void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) {
|
---|
[14454] | 79 | pathTSPTourView.Content.Quality = new DoubleValue(Content.BestKnownQuality);
|
---|
[3712] | 80 | }
|
---|
[3153] | 81 | private void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 82 | pathTSPTourView.Content.Permutation = Content.BestKnownSolution;
|
---|
| 83 | }
|
---|
[14454] | 84 |
|
---|
| 85 | private void updateDistanceMatrixButton_Click(object sender, EventArgs e) {
|
---|
| 86 | Content.UpdateDistanceMatrix();
|
---|
| 87 | }
|
---|
[2805] | 88 | }
|
---|
| 89 | }
|
---|