Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/09/08 20:19:42 (16 years ago)
Author:
bspisic
Message:

#424
Added getter and setter by WorldShape
Implemented panning in LineChart

Location:
trunk/sources/HeuristicLab.Visualization
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/LineChart.Designer.cs

    r869 r928  
    4141          this.canvasUI1.TabIndex = 0;
    4242          this.canvasUI1.Text = "canvasUI1";
     43          this.canvasUI1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseDown);
    4344          //
    4445          // LineChart
  • trunk/sources/HeuristicLab.Visualization/LineChart.cs

    r870 r928  
    11using System;
    22using System.Collections.Generic;
     3using System.Diagnostics;
     4using System.Drawing;
     5using System.Windows.Forms;
    36using HeuristicLab.Core;
    47
     
    1922    /// <param name="model">Referenz to the model, for data</param>
    2023    public LineChart(IChartDataRowsModel model) : this() {
    21       if (model == null)
     24      if (model == null) {
    2225        throw new NullReferenceException("Model cannot be null.");
     26      }
    2327
    2428      //TODO: correct Rectangle to fit
     
    2630      canvasUI1.MainCanvas.WorldShape = new WorldShape(clientRectangle, clientRectangle);
    2731
     32      CreateMouseEventListeners();
     33
    2834      this.model = model;
    29       this.Item = (IItem)model;
     35      Item = (IItem)model;
    3036    }
    3137
     
    8591      List<LineShape> lineShapes = rowToLineShapes[row];
    8692
    87       if (index > lineShapes.Count+1)
     93      if (index > lineShapes.Count + 1) {
    8894        throw new NotImplementedException();
     95      }
    8996
    9097      // new value was added
    91       if (index > 0 && index == lineShapes.Count+1) {
     98      if (index > 0 && index == lineShapes.Count + 1) {
    9299        LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], 0, row.Color, row.Thickness);
    93100        lineShapes.Add(lineShape);
     
    97104
    98105      // not the first value
    99       if (index > 0)
    100         lineShapes[index-1].Y2 = value;
     106      if (index > 0) {
     107        lineShapes[index - 1].Y2 = value;
     108      }
    101109
    102110      // not the last value
    103       if (index > 0 && index < row.Count-1)
     111      if (index > 0 && index < row.Count - 1) {
    104112        lineShapes[index].Y1 = value;
     113      }
    105114
    106115      canvasUI1.Invalidate();
     
    114123    }
    115124
    116     private void OnModelChanged() {
    117     }
     125    private void OnModelChanged() {}
    118126
    119127    #endregion
     
    128136
    129137    public void EndUpdate() {
    130       if (beginUpdateCount == 0)
     138      if (beginUpdateCount == 0) {
    131139        throw new InvalidOperationException("Too many EndUpdates.");
     140      }
    132141
    133142      beginUpdateCount--;
    134143
    135       if (beginUpdateCount == 0)
     144      if (beginUpdateCount == 0) {
    136145        Invalidate();
     146      }
    137147    }
    138148
    139149    #endregion
     150
     151    private MouseEventListener panListener;
     152
     153    private void CreateMouseEventListeners() {
     154      panListener = new MouseEventListener();
     155      panListener.OnMouseMove += Pan_OnMouseMove;
     156      panListener.OnMouseUp += Pan_OnMouseUp;
     157    }
     158
     159
     160    private RectangleD startClippingArea;
     161
     162    private void canvasUI1_MouseDown(object sender, MouseEventArgs e) {
     163      panListener.StartPoint = e.Location;
     164      canvasUI1.MouseEventListener = panListener;
     165
     166      startClippingArea = canvasUI1.MainCanvas.WorldShape.ClippingArea;
     167    }
     168
     169    private void Pan_OnMouseUp(Point startPoint, Point actualPoint) {
     170       canvasUI1.MouseEventListener = null;
     171    }
     172
     173    private void Pan_OnMouseMove(Point startPoint, Point actualPoint) {
     174      Rectangle viewPort = canvasUI1.ClientRectangle;
     175
     176      PointD worldStartPoint = Transform.ToWorld(startPoint, viewPort, startClippingArea);
     177      PointD worldActualPoint = Transform.ToWorld(actualPoint, viewPort, startClippingArea);
     178
     179      double xDiff = worldActualPoint.X - worldStartPoint.X;
     180      double yDiff = worldActualPoint.Y - worldStartPoint.Y;
     181
     182      RectangleD newClippingArea = new RectangleD();
     183      newClippingArea.X1 = startClippingArea.X1 - xDiff;
     184      newClippingArea.X2 = startClippingArea.X2 - xDiff;
     185      newClippingArea.Y1 = startClippingArea.Y1 - yDiff;
     186      newClippingArea.Y2 = startClippingArea.Y2 - yDiff;
     187
     188      canvasUI1.MainCanvas.WorldShape.ClippingArea = newClippingArea;
     189      panListener.StartPoint = startPoint;
     190
     191      canvasUI1.Invalidate();
     192    }
    140193  }
    141194}
  • trunk/sources/HeuristicLab.Visualization/WorldShape.cs

    r862 r928  
    3636    }
    3737
     38    public RectangleD ClippingArea {
     39      get { return clippingArea; }
     40      set { clippingArea = value; }
     41    }
     42
    3843    /// <summary>
    3944    /// adds a shape to the WorldShape
Note: See TracChangeset for help on using the changeset viewer.