Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Charting/3.3/ModelingBubbleChart.cs @ 2301

Last change on this file since 2301 was 2295, checked in by mkommend, 15 years ago

adapted CEDMA.BubbleChart to meet needs of new ModelAnalyzer (ticket #723)

File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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 System.Collections.Generic;
24using System.Text;
25using System.Drawing;
26using System.Linq;
27using HeuristicLab.Charting;
28using System.Windows.Forms;
29using HeuristicLab.PluginInfrastructure;
30using HeuristicLab.Core;
31using System.Diagnostics;
32using HeuristicLab.SparseMatrix;
33
34
35namespace HeuristicLab.CEDMA.Charting {
36  public class ModelingBubbleChart :BubbleChart {
37    public ModelingBubbleChart(VisualMatrix matrix, PointD lowerLeft, PointD upperRight)
38      : base(matrix,lowerLeft, upperRight) {
39
40      matrix.Changed += new EventHandler(matrix_Changed);
41    }
42
43    public ModelingBubbleChart(VisualMatrix matrix, double x1, double y1, double x2, double y2)
44      : this(matrix, new PointD(x1, y1), new PointD(x2, y2)) {
45    }
46
47    public void matrix_Changed(object sender, EventArgs e) {
48      Refresh();
49    }
50
51    public override void MouseDoubleClick(Point point, MouseButtons button) {
52      if (button == MouseButtons.Left) {
53        VisualMatrixRow row = GetMatrixRow(point);
54        if (row != null) {
55          var model = (IItem)PersistenceManager.RestoreFromGZip((byte[])row.Get("PersistedData"));
56          if (model != null)
57            PluginManager.ControlManager.ShowControl(model.CreateView());
58        }
59      } else {
60        base.MouseDoubleClick(point, button);
61      }
62    }
63
64    public override void MouseDrag(Point start, Point end, MouseButtons button) {
65      if (button == MouseButtons.Left && Mode == ChartMode.Select) {
66        PointD a = TransformPixelToWorld(start);
67        PointD b = TransformPixelToWorld(end);
68        double minX = Math.Min(a.X, b.X);
69        double minY = Math.Min(a.Y, b.Y);
70        double maxX = Math.Max(a.X, b.X);
71        double maxY = Math.Max(a.Y, b.Y);
72        HeuristicLab.Charting.Rectangle rect = new HeuristicLab.Charting.Rectangle(this, minX, minY, maxX, maxY);
73
74        List<IPrimitive> primitives = new List<IPrimitive>();
75        primitives.AddRange(points.Primitives);
76
77        foreach (FixedSizeCircle p in primitives) {
78          if (rect.ContainsPoint(p.Point)) {
79            VisualMatrixRow r;
80            primitiveToMatrixRowDictionary.TryGetValue(p, out r);
81            if (r != null) r.ToggleSelected();
82          }
83        }
84        if (primitives.Count() > 0) matrix.FireChanged();
85      } else {
86        base.MouseDrag(start, end, button);
87      }
88    }
89
90    public override void MouseClick(Point point, MouseButtons button) {
91      if (button == MouseButtons.Left) {
92        VisualMatrixRow r = GetMatrixRow(point);
93        if (r != null) {
94          r.ToggleSelected();
95          matrix.FireChanged();
96        }
97      } else {
98        base.MouseClick(point, button);
99      }
100    }
101  }
102}
Note: See TracBrowser for help on using the repository browser.