[12269] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 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;
|
---|
| 24 | using HeuristicLab.MainForm;
|
---|
| 25 | using HeuristicLab.Optimization.Views;
|
---|
| 26 | using HeuristicLab.Problems.PTSP;
|
---|
| 27 | using HeuristicLab.Data;
|
---|
| 28 |
|
---|
| 29 | namespace HeuristicLab.Problems.PTSP.Views {
|
---|
| 30 | /// <summary>
|
---|
| 31 | /// A view for a Traveling Salesman Problem instance.
|
---|
| 32 | /// </summary>
|
---|
| 33 | [View("Probabilistic Traveling Salesman Problem View")]
|
---|
| 34 | [Content(typeof(ProbabilisticTravelingSalesmanProblem), true)]
|
---|
| 35 | public sealed partial class ProbabilisticTravelingSalesmanProblemView : ProblemView {
|
---|
| 36 | public new ProbabilisticTravelingSalesmanProblem Content {
|
---|
| 37 | get { return (ProbabilisticTravelingSalesmanProblem)base.Content; }
|
---|
| 38 | set { base.Content = value; }
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | /// <summary>
|
---|
| 42 | /// Initializes a new instance of <see cref="ProbabilisticTravelingSalesmanView"/>.
|
---|
| 43 | /// </summary>
|
---|
| 44 | public ProbabilisticTravelingSalesmanProblemView() {
|
---|
| 45 | InitializeComponent();
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | protected override void DeregisterContentEvents() {
|
---|
| 49 | Content.CoordinatesParameter.ValueChanged -= new EventHandler(CoordinatesParameter_ValueChanged);
|
---|
| 50 | Content.ProbabilityMatrixParameter.ValueChanged -= new EventHandler(ProbabilityParameter_ValueChanged);
|
---|
| 51 | //Content.BestKnownQualityParameter.ValueChanged -= new EventHandler(BestKnownQualityParameter_ValueChanged);
|
---|
| 52 | Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged);
|
---|
| 53 | base.DeregisterContentEvents();
|
---|
| 54 | }
|
---|
| 55 | protected override void RegisterContentEvents() {
|
---|
| 56 | base.RegisterContentEvents();
|
---|
| 57 | Content.CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged);
|
---|
| 58 | Content.ProbabilityMatrixParameter.ValueChanged += new EventHandler(ProbabilityParameter_ValueChanged);
|
---|
| 59 | //Content.BestKnownQualityParameter.ValueChanged += new EventHandler(BestKnownQualityParameter_ValueChanged);
|
---|
| 60 | Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
|
---|
| 61 | }
|
---|
| 62 | protected override void OnContentChanged() {
|
---|
| 63 | base.OnContentChanged();
|
---|
| 64 | if (Content == null) {
|
---|
| 65 | pathPTSPTourView.Content = null;
|
---|
| 66 | } else {
|
---|
| 67 | pathPTSPTourView.Content = new PathPTSPTour(Content.Coordinates, Content.ProbabilityMatrix, Content.BestKnownSolution, new DoubleValue(Content.BestKnownQuality));
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | protected override void SetEnabledStateOfControls() {
|
---|
| 72 | base.SetEnabledStateOfControls();
|
---|
| 73 | pathPTSPTourView.Enabled = Content != null;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 77 | pathPTSPTourView.Content.Coordinates = Content.Coordinates;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | private void ProbabilityParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 81 | pathPTSPTourView.Content.Probabilities = Content.ProbabilityMatrix;
|
---|
| 82 | }
|
---|
| 83 | private void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 84 | pathPTSPTourView.Content.Quality = new DoubleValue(Content.BestKnownQuality);
|
---|
| 85 | }
|
---|
| 86 | private void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 87 | pathPTSPTourView.Content.Permutation = Content.BestKnownSolution;
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 | }
|
---|