Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/01/15 23:17:56 (9 years ago)
Author:
bburlacu
Message:

#1772: Added some useful functionality to the GenealogyGraphView.

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs

    r11817 r11852  
    4040    private readonly Pen defaultPen;
    4141
     42    private Dictionary<IGenealogyGraphNode, VisualGenealogyGraphNode> nodeMap;
     43    private Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc> arcMap;
     44
    4245    public IGenealogyGraph GenealogyGraph {
    4346      get { return genealogyGraph; }
     
    6366    }
    6467
    65     private Dictionary<IGenealogyGraphNode, VisualGenealogyGraphNode> nodeMap;
    66     private Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc> arcMap;
     68    public bool UpdateEnabled {
     69      get { return Chart.UpdateEnabled; }
     70      set { Chart.UpdateEnabled = value; }
     71    }
     72
     73    public void EnforceUpdate() {
     74      Chart.EnforceUpdate();
     75    }
    6776
    6877    #region chart modes
     
    225234
    226235      // update
    227       Chart.UpdateEnabled = true;
    228       Chart.EnforceUpdate();
     236      UpdateEnabled = true;
     237      EnforceUpdate();
    229238
    230239      if (SelectedVisualNode != null)
    231         /* emit clicked event */
    232         OnGenealogyGraphNodeClicked(SelectedVisualNode, e);
     240        OnGenealogyGraphNodeClicked(SelectedVisualNode, e); // emit clicked event
    233241
    234242      base.pictureBox_MouseUp(sender, e);
     
    306314    }
    307315
     316    public void ClearArcs() {
     317      foreach (var primitive in Chart.Group.Primitives.OfType<VisualGenealogyGraphArc>()) {
     318        primitive.Pen = Pens.Transparent;
     319      }
     320    }
     321
     322    public void ClearNodes() {
     323      foreach (var primitive in Chart.Group.Primitives.OfType<VisualGenealogyGraphNode>()) {
     324        primitive.Brush = new SolidBrush(Color.Transparent);
     325        primitive.Pen = new Pen(Color.LightGray);
     326      }
     327    }
     328
    308329    public virtual void ClearPrimitives() {
    309330      foreach (var primitive in Chart.Group.Primitives) {
     
    313334          primitive.Brush = new SolidBrush(Color.Transparent);
    314335          primitive.Pen = new Pen(Color.DarkGray);
    315         }
    316       }
    317     }
    318 
    319     public void HighlightNodes(IEnumerable<IGenealogyGraphNode> nodes) {
    320       Chart.UpdateEnabled = false;
    321       ClearPrimitives();
     336          //          primitive.Pen = Pens.Transparent; // remove the node contour
     337        }
     338      }
     339    }
     340
     341    public void HighlightNodes(IEnumerable<IGenealogyGraphNode> nodes, bool clearPrimitives = true) {
     342      if (clearPrimitives)
     343        ClearPrimitives();
     344
    322345      foreach (var node in nodes) {
    323346        var graphNode = GetMappedNode(node);
    324347        graphNode.Brush = new SolidBrush(node.GetColor());
    325348      }
    326       Chart.UpdateEnabled = true;
    327       Chart.EnforceUpdate();
     349    }
     350
     351    public void HighlightNodes(IEnumerable<IGenealogyGraphNode> nodes, Color color, bool clearPrimitives = true) {
     352      if (clearPrimitives)
     353        ClearPrimitives();
     354
     355      foreach (var node in nodes.Select(GetMappedNode)) {
     356        node.Brush = new SolidBrush(color);
     357      }
    328358    }
    329359
    330360    public void HighlightAll() {
    331       Chart.UpdateEnabled = false;
    332361      foreach (var visualNode in nodeMap.Values) {
    333362        visualNode.Brush = new SolidBrush(visualNode.Data.GetColor());
     
    340369        arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor());
    341370      }
    342       Chart.UpdateEnabled = true;
    343       Chart.EnforceUpdate();
    344371    }
    345372
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.Designer.cs

    r11817 r11852  
    2626    private void InitializeComponent() {
    2727      this.splitContainer = new System.Windows.Forms.SplitContainer();
     28      this.genealogyGraphChart = new HeuristicLab.EvolutionTracking.Views.GenealogyGraphChart();
    2829      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    2930      this.groupBox = new System.Windows.Forms.GroupBox();
     
    3132      this.simpleLineages_checkBox = new System.Windows.Forms.CheckBox();
    3233      this.trace_checkBox = new System.Windows.Forms.CheckBox();
    33       this.genealogyGraphChart = new HeuristicLab.EvolutionTracking.Views.GenealogyGraphChart();
     34      this.openNew_CheckBox = new System.Windows.Forms.CheckBox();
    3435      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    3536      this.splitContainer.Panel1.SuspendLayout();
     
    5859      this.splitContainer.TabIndex = 0;
    5960      //
     61      // genealogyGraphChart
     62      //
     63      this.genealogyGraphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     64            | System.Windows.Forms.AnchorStyles.Left)
     65            | System.Windows.Forms.AnchorStyles.Right)));
     66      this.genealogyGraphChart.BackColor = System.Drawing.SystemColors.Control;
     67      this.genealogyGraphChart.GenealogyGraph = null;
     68      this.genealogyGraphChart.Location = new System.Drawing.Point(0, 0);
     69      this.genealogyGraphChart.LockGenealogy = false;
     70      this.genealogyGraphChart.Name = "genealogyGraphChart";
     71      this.genealogyGraphChart.ScaleOnResize = true;
     72      this.genealogyGraphChart.SimpleLineages = false;
     73      this.genealogyGraphChart.Size = new System.Drawing.Size(689, 738);
     74      this.genealogyGraphChart.TabIndex = 0;
     75      this.genealogyGraphChart.TraceFragments = false;
     76      this.genealogyGraphChart.UpdateEnabled = true;
     77      //
    6078      // viewHost
    6179      //
     
    7795      // groupBox
    7896      //
     97      this.groupBox.Controls.Add(this.openNew_CheckBox);
    7998      this.groupBox.Controls.Add(this.lockGraph_checkBox);
    8099      this.groupBox.Controls.Add(this.simpleLineages_checkBox);
     
    123142      this.trace_checkBox.CheckedChanged += new System.EventHandler(this.trace_checkBox_CheckedChanged);
    124143      //
    125       // genealogyGraphChart
     144      // openNew_CheckBox
    126145      //
    127       this.genealogyGraphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    128             | System.Windows.Forms.AnchorStyles.Left)
    129             | System.Windows.Forms.AnchorStyles.Right)));
    130       this.genealogyGraphChart.BackColor = System.Drawing.SystemColors.Control;
    131       this.genealogyGraphChart.GenealogyGraph = null;
    132       this.genealogyGraphChart.Location = new System.Drawing.Point(0, 0);
    133       this.genealogyGraphChart.LockGenealogy = false;
    134       this.genealogyGraphChart.Name = "genealogyGraphChart";
    135       this.genealogyGraphChart.ScaleOnResize = true;
    136       this.genealogyGraphChart.SimpleLineages = false;
    137       this.genealogyGraphChart.Size = new System.Drawing.Size(689, 738);
    138       this.genealogyGraphChart.TabIndex = 0;
    139       this.genealogyGraphChart.TraceFragments = false;
     146      this.openNew_CheckBox.AutoSize = true;
     147      this.openNew_CheckBox.Location = new System.Drawing.Point(237, 20);
     148      this.openNew_CheckBox.Name = "openNew_CheckBox";
     149      this.openNew_CheckBox.Size = new System.Drawing.Size(111, 17);
     150      this.openNew_CheckBox.TabIndex = 1;
     151      this.openNew_CheckBox.Text = "Open in new view";
     152      this.openNew_CheckBox.UseVisualStyleBackColor = true;
    140153      //
    141154      // GenealogyGraphView
     
    166179    protected System.Windows.Forms.CheckBox simpleLineages_checkBox;
    167180    protected System.Windows.Forms.CheckBox lockGraph_checkBox;
     181    protected System.Windows.Forms.CheckBox openNew_CheckBox;
    168182
    169183  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/HeuristicLab.EvolutionTracking.Views-3.4.csproj

    r11639 r11852  
    129129    <None Include="HeuristicLab.snk" />
    130130  </ItemGroup>
     131  <ItemGroup>
     132    <EmbeddedResource Include="GenealogyGraphView.resx">
     133      <DependentUpon>GenealogyGraphView.cs</DependentUpon>
     134    </EmbeddedResource>
     135  </ItemGroup>
    131136  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    132137  <PropertyGroup>
Note: See TracChangeset for help on using the changeset viewer.