Changeset 10650 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs
- Timestamp:
- 03/24/14 16:59:22 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs
r10302 r10650 1 using System; 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Drawing; … … 26 47 } 27 48 49 public IGenealogyGraphNode SelectedGraphNode { get; private set; } 50 28 51 private void Clear() { 29 52 if (nodeMap == null) … … 41 64 private Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc> arcMap; 42 65 66 #region chart modes 43 67 public bool SimpleLineages { get; set; } 44 68 public bool LockGenealogy { get; set; } 69 public bool TraceFragments { get; set; } 70 #endregion 71 45 72 private Visualization.Rectangle TargetRectangle { get; set; } 73 private bool DrawInProgress { get; set; } // do not try to update the chart while the drawing is not finished 74 private VisualGenealogyGraphNode SelectedVisualNode { get; set; } 46 75 47 76 private VisualGenealogyGraphNode GetMappedNode(IGenealogyGraphNode node) { … … 62 91 return arc; 63 92 } 64 private bool DrawInProgress { get; set; } // do not try to update the chart while the drawing is not finished 65 private VisualGenealogyGraphNode SelectedVisualNode { get; set; } 66 67 public event MouseEventHandler GenealogyGraphNodeClicked; 68 private void OnGenealogyGraphNodeClicked(object sender, MouseEventArgs e) { 69 var clicked = GenealogyGraphNodeClicked; 70 if (clicked != null) clicked(sender, e); 71 } 93 72 94 public GenealogyGraphChart() 73 95 : base() { 74 96 InitializeComponent(); 75 97 } 98 76 99 protected virtual void DrawGraph(double xIncrement, double yIncrement, double diameter) { 77 100 Chart.UpdateEnabled = false; … … 127 150 DrawInProgress = false; 128 151 } 152 153 public event MouseEventHandler GenealogyGraphNodeClicked; 154 private void OnGenealogyGraphNodeClicked(object sender, MouseEventArgs e) { 155 var clicked = GenealogyGraphNodeClicked; 156 if (clicked != null) clicked(sender, e); 157 } 158 159 #region event handlers 129 160 protected override void pictureBox_MouseMove(object sender, MouseEventArgs e) { 130 161 if (!DrawInProgress) { … … 160 191 SelectedVisualNode = visualNodes[0] as VisualGenealogyGraphNode; 161 192 if (SelectedVisualNode == null) return; 193 SelectedGraphNode = SelectedVisualNode.Data; 162 194 163 195 if (!LockGenealogy) { … … 188 220 base.pictureBox_MouseUp(sender, e); 189 221 } 222 #endregion 223 190 224 private void DrawLineage(VisualGenealogyGraphNode node, Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector, Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector) { 191 225 if (node.Brush != null) return; … … 205 239 } 206 240 } 241 207 242 void MarkSelectedNode() { 208 243 var center = SelectedVisualNode.Center; … … 219 254 } 220 255 } 256 221 257 private static VisualGenealogyGraphArc AddArc(IChart chart, VisualGenealogyGraphNode source, VisualGenealogyGraphNode target, Pen pen, Brush brush = null) { 222 258 var arc = new VisualGenealogyGraphArc(chart, source, target, pen) { Brush = brush }; … … 227 263 return arc; 228 264 } 265 229 266 public virtual void ClearPrimitives() { 230 267 foreach (var primitive in Chart.Group.Primitives) { … … 236 273 } 237 274 } 275 238 276 public void HighlightNodes(IEnumerable<IGenealogyGraphNode> nodes) { 239 277 Chart.UpdateEnabled = false; 240 278 ClearPrimitives(); 241 279 foreach (var node in nodes) { 242 GetMappedNode(node).Brush = new SolidBrush(node.GetColor()); 280 var graphNode = GetMappedNode(node); 281 graphNode.Brush = new SolidBrush(node.GetColor()); 243 282 } 244 283 Chart.UpdateEnabled = true; 245 284 Chart.EnforceUpdate(); 246 285 } 286 247 287 public void HighlightAll() { 248 288 Chart.UpdateEnabled = false; … … 261 301 } 262 302 } 303 263 304 internal static class Util { 264 305 public static Color GetColor(this IGenealogyGraphNode node) {
Note: See TracChangeset
for help on using the changeset viewer.