Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering.Views/3.3/OrienteeringProblemView.cs @ 11325

Last change on this file since 11325 was 11325, checked in by pfleck, 10 years ago

#2208

  • Fixed OrienteeringSolution visualization when start or endpoint are out of range
  • Changed some parameters in OP to FixedValueParameter
  • Added start/terminal index check in OP
File size: 4.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2014 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
22using System;
23using HeuristicLab.MainForm;
24using HeuristicLab.Optimization.Views;
25
26namespace HeuristicLab.Problems.Orienteering.Views {
27
28  [View("Orienteering Problem View")]
29  [Content(typeof(OrienteeringProblem), true)]
30  public partial class OrienteeringProblemView : ProblemView {
31    public new OrienteeringProblem Content {
32      get { return (OrienteeringProblem)base.Content; }
33      set { base.Content = value; }
34    }
35
36    public OrienteeringProblemView() {
37      InitializeComponent();
38    }
39
40    protected override void DeregisterContentEvents() {
41      Content.CoordinatesParameter.ValueChanged -= new EventHandler(CoordinatesParameter_ValueChanged);
42      Content.StartingPointParameter.ValueChanged -= new EventHandler(StartingPointParameter_ValueChanged);
43      Content.TerminalPointParameter.ValueChanged -= new EventHandler(TerminalPointParameter_ValueChanged);
44      Content.ScoresParameter.ValueChanged -= new EventHandler(ScoresParameter_ValueChanged);
45      Content.BestKnownQualityParameter.ValueChanged -= new EventHandler(BestKnownQualityParameter_ValueChanged);
46      Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged);
47      base.DeregisterContentEvents();
48    }
49    protected override void RegisterContentEvents() {
50      base.RegisterContentEvents();
51      Content.CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged);
52      Content.StartingPointParameter.ValueChanged += new EventHandler(StartingPointParameter_ValueChanged);
53      Content.TerminalPointParameter.ValueChanged += new EventHandler(TerminalPointParameter_ValueChanged);
54      Content.ScoresParameter.ValueChanged += new EventHandler(ScoresParameter_ValueChanged);
55      Content.BestKnownQualityParameter.ValueChanged += new EventHandler(BestKnownQualityParameter_ValueChanged);
56      Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
57    }
58
59    protected override void OnContentChanged() {
60      base.OnContentChanged();
61      if (Content == null) {
62        orienteeringSolutionView.Content = null;
63      } else {
64        orienteeringSolutionView.Content = new OrienteeringSolution(
65          Content.BestKnownSolution, Content.Coordinates, Content.StartingPointParameter.Value, Content.TerminalPointParameter.Value, Content.Scores, Content.BestKnownQuality, penalty: null);
66      }
67    }
68
69    protected override void SetEnabledStateOfControls() {
70      base.SetEnabledStateOfControls();
71      orienteeringSolutionView.Enabled = Content != null;
72    }
73
74    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
75      orienteeringSolutionView.Content.Coordinates = Content.Coordinates;
76    }
77    private void StartingPointParameter_ValueChanged(object sender, EventArgs e) {
78      orienteeringSolutionView.Content.StartingPoint.Value = Content.StartingPoint;
79    }
80    private void TerminalPointParameter_ValueChanged(object sender, EventArgs e) {
81      orienteeringSolutionView.Content.TerminalPoint.Value = Content.TerminalPoint;
82    }
83    private void ScoresParameter_ValueChanged(object sender, EventArgs e) {
84      orienteeringSolutionView.Content.Scores = Content.Scores;
85    }
86    private void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) {
87      orienteeringSolutionView.Content.Quality = Content.BestKnownQuality;
88    }
89    private void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) {
90      orienteeringSolutionView.Content.IntegerVector = Content.BestKnownSolution;
91    }
92  }
93}
Note: See TracBrowser for help on using the repository browser.