Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1240


Ignore:
Timestamp:
03/02/09 22:03:41 (16 years ago)
Author:
mstoeger
Message:

Transformations on shapes are possible outside of the Draw method. (#424)

Location:
trunk/sources
Files:
1 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization.Test/LegendForm.cs

    r1233 r1240  
    77    public LegendForm() {
    88      InitializeComponent();
    9       canvasUI.MainCanvas.WorldShape = new WorldShape(new RectangleD(0, 0, 800, 600), new RectangleD(0, 0, 800, 600));
    109
    1110      CreateLegendShape();
     
    1312
    1413    private void CreateLegendShape() {
    15       WorldShape mainShape = canvasUI.MainCanvas.WorldShape;
    1614      LegendShape ls = new LegendShape();
    1715      ls.AddLegendItem(new LegendItem("test", Color.Black, 5));
    1816      ls.AddLegendItem(new LegendItem("test2", Color.Red, 5));
    1917
    20       mainShape.AddShape(ls);
     18      canvasUI.Canvas.AddShape(ls);
    2119    }
    2220  }
  • trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs

    r1049 r1240  
    112112      f.ShowDialog();
    113113    }
     114
     115    [Test]
     116    public void TestMainForm() {
     117      MainForm f = new MainForm();
     118      f.ShowDialog();
     119    }
    114120  }
    115121}
  • trunk/sources/HeuristicLab.Visualization.Test/MainForm.cs

    r1045 r1240  
    1 using System.Drawing;
     1using System;
     2using System.Drawing;
    23using System.Windows.Forms;
    34
    45namespace HeuristicLab.Visualization.Test {
    56  public partial class MainForm : Form {
     7    private readonly Canvas canvas;
     8
    69    public MainForm() {
    710      InitializeComponent();
    811
    9       canvasUI.MainCanvas.WorldShape = new WorldShape(new RectangleD(0, 0, 800, 600), new RectangleD(0, 0, 800, 600));
     12      canvas = canvasUI.Canvas;
    1013
    1114      CreateLeftWorldShape();
     
    1821
    1922    private void CreateSimpleRectangleShape() {
    20       WorldShape mainWorld = canvasUI.MainCanvas.WorldShape;
    2123      // simple rectangle shape
    2224      RectangleShape rect7 = new RectangleShape(5, 5, 50, 50, Color.Black);
    23       mainWorld.AddShape(rect7);
     25      canvas.AddShape(rect7);
    2426    }
    2527
    2628    private void CreateRightWorldShape() {
    27       WorldShape mainWorld = canvasUI.MainCanvas.WorldShape;
    2829      // right world shape
    29       WorldShape rightWorld = new WorldShape(new RectangleD(-1, -1, 1, 1), new RectangleD(600, 10, 780, 600));
     30      WorldShape rightWorld = new WorldShape();
     31      rightWorld.ClippingArea = new RectangleD(-1, -1, 1, 1);
     32      rightWorld.BoundingBox = new RectangleD(600, 10, 780, 600);
    3033
    3134      double x1 = -3;
     
    3942      }
    4043
    41       mainWorld.AddShape(rightWorld);
     44      canvas.AddShape(rightWorld);
    4245    }
    4346
    4447    private void CreateMiddleCompositeShape() {
    45       WorldShape mainWorld = canvasUI.MainCanvas.WorldShape;
    4648      // middle composite shape
    4749      CompositeShape middleComp = new CompositeShape();
     
    5355      middleComp.AddShape(rect6);
    5456
    55       mainWorld.AddShape(middleComp);
     57      canvas.AddShape(middleComp);
    5658    }
    5759
    5860    private void CreateLeftWorldShape() {
    59       WorldShape mainWorld = canvasUI.MainCanvas.WorldShape;
    6061      // left world shape
    61       WorldShape leftWorld = new WorldShape(new RectangleD(0, 0, 1000, 1000), new RectangleD(10, 10, 380, 590));
     62      WorldShape leftWorld = new WorldShape();
     63      leftWorld.ClippingArea = new RectangleD(0, 0, 1000, 1000);
     64      leftWorld.BoundingBox = new RectangleD(10, 10, 380, 590);
    6265
    6366      RectangleShape fillRect = new RectangleShape(0, 0, 1000, 1000, Color.LightBlue);
     
    7982      leftWorld.AddShape(comp1);
    8083
    81       mainWorld.AddShape(leftWorld);
     84      canvas.AddShape(leftWorld);
    8285    }
    8386
    84     private void legendButton_Click(object sender, System.EventArgs e) {
     87    private void legendButton_Click(object sender, EventArgs e) {
    8588      LegendForm form = new LegendForm();
    8689      form.Show();
  • trunk/sources/HeuristicLab.Visualization/Canvas.cs

    r1038 r1240  
     1using System;
    12using System.Diagnostics;
    23using System.Drawing;
     
    45
    56namespace HeuristicLab.Visualization {
    6   public class Canvas : ICanvas {
    7     private WorldShape world;
     7  public class Canvas : IShape {
     8    private readonly WorldShape worldShape;
    89
    9     public WorldShape WorldShape {
    10       get { return world; }
    11       set { world = value; }
     10    private Rectangle viewport;
     11
     12    public Canvas() {
     13      worldShape = new WorldShape();
     14      worldShape.Parent = this;
    1215    }
    1316
     17    public void AddShape(IShape shape) {
     18      worldShape.AddShape(shape);
     19    }
    1420
    15     public void Draw(Graphics graphics, Rectangle viewport) {
     21    public void RemoveShape(IShape shape) {
     22      worldShape.RemoveShape(shape);
     23    }
     24
     25    public void ClearShapes() {
     26      worldShape.ClearShapes();
     27    }
     28
     29    public Rectangle Viewport {
     30      get { return viewport; }
     31      set {
     32        viewport = value;
     33        worldShape.ClippingArea = new RectangleD(0, 0, viewport.Width, viewport.Height);
     34        worldShape.BoundingBox = worldShape.ClippingArea;
     35      }
     36    }
     37
     38    public RectangleD ClippingArea {
     39      get { return worldShape.ClippingArea; }
     40    }
     41
     42    public RectangleD BoundingBox {
     43      get { throw new InvalidOperationException(); }
     44    }
     45
     46    public IShape Parent {
     47      get { throw new InvalidOperationException(); }
     48      set { throw new InvalidOperationException(); }
     49    }
     50
     51    public void Draw(Graphics graphics) {
    1652      Stopwatch sw = new Stopwatch();
    1753      sw.Start();
    1854
    19       GraphicsState gstate = graphics.Save();
     55      graphics.SmoothingMode = SmoothingMode.AntiAlias;
     56      graphics.FillRectangle(Brushes.White, Viewport);
    2057
    21       graphics.SetClip(viewport);
     58      worldShape.Draw(graphics);
    2259
    23       world.Draw(graphics, viewport, world.BoundingBox);
    24 
    25       graphics.Restore(gstate);
     60      graphics.DrawRectangle(Pens.Black, 0, 0, Viewport.Width - 1, Viewport.Height - 1);
    2661
    2762      sw.Stop();
  • trunk/sources/HeuristicLab.Visualization/CanvasUI.cs

    r1045 r1240  
    22using System.Diagnostics;
    33using System.Drawing;
    4 using System.Drawing.Drawing2D;
    54using System.Windows.Forms;
    65
    76namespace HeuristicLab.Visualization {
    87  public partial class CanvasUI : Control {
    9     private readonly Canvas mainCanvas = new Canvas();
     8    private readonly Canvas canvas = new Canvas();
    109    private IMouseEventListener mouseEventListener;
    1110
     
    1615    }
    1716
    18     public Canvas MainCanvas {
    19       get { return mainCanvas; }
     17    public Canvas Canvas {
     18      get { return canvas; }
    2019    }
    2120
     
    2928        Graphics g = pe.Graphics;
    3029
    31         g.SmoothingMode = SmoothingMode.AntiAlias;
    32 
    33         g.FillRectangle(Brushes.White, ClientRectangle);
    34 
    35         mainCanvas.Draw(g, ClientRectangle);
    36 
    37         g.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1);
     30        canvas.Viewport = ClientRectangle;
     31        canvas.Draw(g);
    3832
    3933        base.OnPaint(pe);
     
    4539    protected override void OnResize(EventArgs e) {
    4640      Invalidate();
     41
     42      canvas.Viewport = ClientRectangle;
    4743
    4844      base.OnResize(e);
  • trunk/sources/HeuristicLab.Visualization/CompositeShape.cs

    r1234 r1240  
    55namespace HeuristicLab.Visualization {
    66  public class CompositeShape : IShape {
     7    private IShape parent;
     8
    79    protected readonly List<IShape> shapes = new List<IShape>();
    810    protected RectangleD boundingBox = RectangleD.Empty;
    911
    10     public virtual void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
     12    public virtual void Draw(Graphics graphics) {
    1113      foreach (IShape shape in shapes) {
    12         shape.Draw(graphics, parentViewport, parentClippingArea);
     14        shape.Draw(graphics);
    1315      }
    1416    }
     
    2426    }
    2527
     28    public RectangleD ClippingArea {
     29      get { return Parent.ClippingArea; }
     30    }
     31
     32    public Rectangle Viewport {
     33      get { return Parent.Viewport; }
     34    }
     35
     36    public IShape Parent {
     37      get { return parent; }
     38      set { parent = value; }
     39    }
     40
    2641    public void ClearShapes() {
    2742      shapes.Clear();
     
    3045
    3146    public void AddShape(IShape shape) {
     47      shape.Parent = this;
     48
    3249      if (shapes.Count == 0) {
    3350        boundingBox = shape.BoundingBox;
  • trunk/sources/HeuristicLab.Visualization/Grid.cs

    r1234 r1240  
    33namespace HeuristicLab.Visualization {
    44  public class Grid : WorldShape {
    5     public override void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    6       shapes.Clear();
     5    public override void Draw(Graphics graphics) {
     6      ClearShapes();
    77
    88      foreach (double y in AxisTicks.GetTicks(YAxis.PixelsPerInterval,
    9                                               parentViewport.Height,
     9                                              Parent.Viewport.Height,
    1010                                              ClippingArea.Height,
    1111                                              ClippingArea.Y1)) {
     
    1414                                       Color.LightBlue, 1,
    1515                                       DrawingStyle.Dashed);
    16         shapes.Add(line);
     16        AddShape(line);
    1717      }
    1818
    1919      foreach (double x in AxisTicks.GetTicks(XAxis.PixelsPerInterval,
    20                                               parentViewport.Width,
     20                                              Parent.Viewport.Width,
    2121                                              ClippingArea.Width,
    2222                                              ClippingArea.X1)) {
     
    2525                                       Color.LightBlue, 1,
    2626                                       DrawingStyle.Dashed);
    27         shapes.Add(line);
     27        AddShape(line);
    2828      }
    2929
     
    3838                                          DrawingStyle.Dashed);
    3939
    40       shapes.Add(lineZeroX);
    41       shapes.Add(lineZeroY);
     40      AddShape(lineZeroX);
     41      AddShape(lineZeroY);
    4242
    43       base.Draw(graphics, parentViewport, parentClippingArea);
     43      base.Draw(graphics);
    4444    }
    4545  }
  • trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj

    r1233 r1240  
    102102    <Compile Include="DrawingStyle.cs" />
    103103    <Compile Include="HeuristicLabVisualizationPlugin.cs" />
    104     <Compile Include="ICanvas.cs" />
    105104    <Compile Include="IChartDataModel.cs" />
    106105    <Compile Include="IChartDataRowsModel.cs" />
  • trunk/sources/HeuristicLab.Visualization/HorizontalLineShape.cs

    r1234 r1240  
    1717      minLineShape = new LineShape(0, yMin, 1, yMin, color, thickness, style);
    1818      maxLineShape = new LineShape(0, yMax, 1, yMax, color, thickness, style);
    19       shapes.Add(minLineShape);
    20       shapes.Add(maxLineShape);
     19      AddShape(minLineShape);
     20      AddShape(maxLineShape);
    2121    }
    2222
    23     public override void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
     23    public override void Draw(Graphics graphics) {
    2424      minLineShape.X1 = ClippingArea.X1;
    2525      minLineShape.X2 = ClippingArea.X2;
    2626      maxLineShape.X1 = ClippingArea.X1;
    2727      maxLineShape.X2 = ClippingArea.X2;
    28       base.Draw(graphics, parentViewport, parentClippingArea);
     28      base.Draw(graphics);
    2929    }
    3030
  • trunk/sources/HeuristicLab.Visualization/IShape.cs

    r1234 r1240  
    2525    /// </summary>
    2626    /// <param name="graphics">The Graphics object used to draw the shape</param>
    27     /// <param name="parentViewport">The parent's view port</param>
    28     /// <param name="parentClippingArea">The parent's clipping area</param>
    29     void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea);
     27    void Draw(Graphics graphics);
    3028
    3129    /// <summary>
     
    3331    /// </summary>
    3432    RectangleD BoundingBox { get; }
     33
     34    RectangleD ClippingArea { get; }
     35    Rectangle Viewport { get; }
     36
     37    IShape Parent { get; set; }
    3538  }
    3639}
  • trunk/sources/HeuristicLab.Visualization/Legend/LegendShape.cs

    r1233 r1240  
    1111
    1212    public void CreateLegend() {
    13       shapes.Clear();
     13      ClearShapes();
    1414      double y = ClippingArea.Y2;
    1515      foreach (LegendItem item in legendItems) {
  • trunk/sources/HeuristicLab.Visualization/LineChart.Designer.cs

    r1187 r1240  
    3232        {
    3333          this.components = new System.ComponentModel.Container();
    34           this.canvas = new HeuristicLab.Visualization.CanvasUI();
     34          this.canvasUI = new HeuristicLab.Visualization.CanvasUI();
    3535          this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
    3636          this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     
    3838          this.SuspendLayout();
    3939          //
    40           // canvas
     40          // canvasUI
    4141          //
    42           this.canvas.Dock = System.Windows.Forms.DockStyle.Fill;
    43           this.canvas.Location = new System.Drawing.Point(0, 0);
    44           this.canvas.MouseEventListener = null;
    45           this.canvas.Name = "canvas";
    46           this.canvas.Size = new System.Drawing.Size(552, 390);
    47           this.canvas.TabIndex = 0;
    48           this.canvas.Text = "canvas";
    49           this.canvas.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseWheel);
    50           this.canvas.ContextMenuStripChanged += new System.EventHandler(this.optionsToolStripMenuItem_Click);
    51           this.canvas.MouseDown += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseDown);
    52           this.canvas.KeyDown += new System.Windows.Forms.KeyEventHandler(this.canvasUI1_KeyDown);
     42          this.canvasUI.Dock = System.Windows.Forms.DockStyle.Fill;
     43          this.canvasUI.Location = new System.Drawing.Point(0, 0);
     44          this.canvasUI.MouseEventListener = null;
     45          this.canvasUI.Name = "canvasUI";
     46          this.canvasUI.Size = new System.Drawing.Size(551, 373);
     47          this.canvasUI.TabIndex = 0;
     48          this.canvasUI.Text = "canvas";
     49          this.canvasUI.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseWheel);
     50          this.canvasUI.MouseMove += new System.Windows.Forms.MouseEventHandler(this.canvas_MouseMove);
     51          this.canvasUI.ContextMenuStripChanged += new System.EventHandler(this.optionsToolStripMenuItem_Click);
     52          this.canvasUI.MouseDown += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseDown);
     53          this.canvasUI.KeyDown += new System.Windows.Forms.KeyEventHandler(this.canvasUI1_KeyDown);
    5354          //
    5455          // contextMenuStrip1
     
    5758            this.optionsToolStripMenuItem});
    5859          this.contextMenuStrip1.Name = "contextMenuStrip1";
    59           this.contextMenuStrip1.Size = new System.Drawing.Size(112, 26);
    60 
     60          this.contextMenuStrip1.Size = new System.Drawing.Size(123, 26);
    6161          //
    6262          // optionsToolStripMenuItem
    6363          //
    6464          this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
    65           this.optionsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
     65          this.optionsToolStripMenuItem.Size = new System.Drawing.Size(122, 22);
    6666          this.optionsToolStripMenuItem.Text = "Options";
    6767          this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click);
     
    7171          this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    7272          this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    73           this.Controls.Add(this.canvas);
     73          this.Controls.Add(this.canvasUI);
    7474          this.Name = "LineChart";
    75           this.Size = new System.Drawing.Size(552, 390);
     75          this.Size = new System.Drawing.Size(551, 373);
    7676          this.contextMenuStrip1.ResumeLayout(false);
    7777          this.ResumeLayout(false);
     
    8181        #endregion
    8282
    83         private CanvasUI canvas;
     83        private CanvasUI canvasUI;
    8484        private ContextMenuStrip contextMenuStrip1;
    8585        private ToolStripMenuItem optionsToolStripMenuItem;
  • trunk/sources/HeuristicLab.Visualization/LineChart.cs

    r1237 r1240  
    1212
    1313    private readonly IChartDataRowsModel model;
     14    private readonly Canvas canvas;
     15
    1416    private int maxDataRowCount;
    1517    private Boolean zoomFullView;
     
    2022    private IShape minLineShape;
    2123
    22     private readonly WorldShape root;
    2324    private readonly TextShape titleShape;
    2425    private readonly LinesShape linesShape;
     
    2829    private readonly YAxis yAxis;
    2930    private readonly Grid grid;
     31
     32    private readonly WorldShape berni;
     33    private readonly RectangleShape mousePointer;
    3034
    3135    /// <summary>
     
    4549      }
    4650
    47       //TODO: correct Rectangle to fit
    48 
    49       root = new WorldShape();
     51      minMaxLineEnabled = true;
     52
     53      canvas = canvasUI.Canvas;
    5054
    5155      grid = new Grid();
    52       minMaxLineEnabled = true;
    53       root.AddShape(grid);
     56      canvas.AddShape(grid);
    5457
    5558      linesShape = new LinesShape();
    56       root.AddShape(linesShape);
     59      canvas.AddShape(linesShape);
    5760
    5861      xAxis = new XAxis();
    59       root.AddShape(xAxis);
     62      canvas.AddShape(xAxis);
    6063
    6164      yAxis = new YAxis();
    62       root.AddShape(yAxis);
     65      canvas.AddShape(yAxis);
    6366
    6467      titleShape = new TextShape(0, 0, model.Title, 15);
    65       root.AddShape(titleShape);
     68      canvas.AddShape(titleShape);
    6669
    6770      minMaxLineShape = new MinMaxLineShape(this.minDataValue, this.maxDataValue, Color.Yellow, 4, DrawingStyle.Solid);
    68       root.AddShape(minMaxLineShape);
     71      canvas.AddShape(minMaxLineShape);
    6972
    7073      legendShape = new LegendShape();
    71       root.AddShape(legendShape);
    72 
    73       canvas.MainCanvas.WorldShape = root;
    74       canvas.Resize += delegate { UpdateLayout(); };
    75      
    76       UpdateLayout();
     74      canvas.AddShape(legendShape);
     75
     76      berni = new WorldShape();
     77      canvas.AddShape(berni);
     78
     79      mousePointer = new RectangleShape(10, 10, 20, 20, Color.Black);
     80      berni.AddShape(mousePointer);
     81
    7782      maxDataRowCount = 0;
    7883      this.model = model;
    7984      Item = model;
    8085
     86      UpdateLayout();
     87      canvasUI.Resize += delegate { UpdateLayout(); };
    8188
    8289      //The whole data rows are shown per default
     
    8895    /// </summary>
    8996    private void UpdateLayout() {
    90       root.ClippingArea = new RectangleD(0, 0, canvas.Width, canvas.Height);
    91 
    9297      titleShape.X = 10;
    93       titleShape.Y = canvas.Height - 10;
     98      titleShape.Y = canvasUI.Height - 10;
    9499
    95100      const int yAxisWidth = 100;
     
    98103      linesShape.BoundingBox = new RectangleD(yAxisWidth,
    99104                                              xAxisHeight,
    100                                               canvas.Width,
    101                                               canvas.Height);
     105                                              canvasUI.Width,
     106                                              canvasUI.Height);
     107
     108      berni.BoundingBox = linesShape.BoundingBox;
     109      berni.ClippingArea = new RectangleD(0, 0, berni.BoundingBox.Width, berni.BoundingBox.Height);
    102110
    103111      grid.BoundingBox = linesShape.BoundingBox;
     
    115123                                         linesShape.BoundingBox.Y1);
    116124
    117       legendShape.BoundingBox = new RectangleD(10, 10, 110, canvas.Height - 50);
     125      legendShape.BoundingBox = new RectangleD(10, 10, 110, canvasUI.Height - 50);
    118126      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width,
    119127                                                legendShape.BoundingBox.Height);
     
    124132      ZoomToFullView();
    125133
    126       canvas.Invalidate();
     134      canvasUI.Invalidate();
    127135    }
    128136
     
    162170      InitLineShapes(row);
    163171    }
     172
     173    private void OnDataRowRemoved(IDataRow row) {
     174      row.ValueChanged -= OnRowValueChanged;
     175      row.ValuesChanged -= OnRowValuesChanged;
     176      row.DataRowChanged -= OnDataRowChanged;
     177    }
     178
     179    #endregion
    164180
    165181    private void ZoomToFullView() {
     
    221237      ZoomToFullView();
    222238
    223       canvas.Invalidate();
    224     }
    225 
    226     private void OnDataRowRemoved(IDataRow row) {
    227       row.ValueChanged -= OnRowValueChanged;
    228       row.ValuesChanged -= OnRowValuesChanged;
    229       row.DataRowChanged -= OnDataRowChanged;
     239      canvasUI.Invalidate();
    230240    }
    231241
     
    267277      ZoomToFullView();
    268278
    269       canvas.Invalidate();
    270     }
    271 
    272 
     279      canvasUI.Invalidate();
     280    }
     281
     282    // TODO remove (see ticket #501)
    273283    public IList<IDataRow> GetRows() {
    274284      return model.Rows;
     
    286296      titleShape.Text = model.Title;
    287297
    288       Invalidate();
    289     }
    290 
    291     #endregion
     298      canvasUI.Invalidate();
     299    }
     300
     301    public void OnDataRowChanged(IDataRow row) {
     302      foreach (LineShape ls in rowToLineShapes[row]) {
     303        ls.LSColor = row.Color;
     304        ls.LSThickness = row.Thickness;
     305        ls.LSDrawingStyle = row.Style;
     306      }
     307      canvasUI.Invalidate();
     308    }
    292309
    293310    #region Begin-/EndUpdate
     
    307324
    308325      if (beginUpdateCount == 0) {
    309         canvas.Invalidate();
     326        canvasUI.Invalidate();
    310327      }
    311328    }
     
    325342
    326343        SetNewClippingArea(clippingArea);
    327         canvas.Invalidate();
     344        canvasUI.Invalidate();
    328345      }
    329346    }
     
    346363    }
    347364
     365    private void canvas_MouseMove(object sender, MouseEventArgs e) {
     366      double x = Transform.ToWorldX(e.X, berni.Viewport, berni.ClippingArea);
     367      double y = Transform.ToWorldY(e.Y, berni.Viewport, berni.ClippingArea);
     368
     369      mousePointer.Rectangle = new RectangleD(x-1, y-1, x+1, y+1);
     370      canvasUI.Invalidate();
     371    }
     372
    348373    private void canvasUI1_MouseWheel(object sender, MouseEventArgs e) {
    349374      if (ModifierKeys == Keys.Control) {
     
    353378
    354379        SetLineClippingArea(clippingArea);
    355         canvas.Invalidate();
     380        canvasUI.Invalidate();
    356381      }
    357382    }
     
    362387      zoomListener.OnMouseUp += OnZoom_MouseUp;
    363388
    364       canvas.MouseEventListener = zoomListener;
     389      canvasUI.MouseEventListener = zoomListener;
    365390
    366391      rectangleShape = new RectangleShape(e.X, e.Y, e.X, e.Y, Color.Blue);
     
    371396
    372397    private void OnZoom_MouseUp(object sender, MouseEventArgs e) {
    373       canvas.MouseEventListener = null;
     398      canvasUI.MouseEventListener = null;
    374399
    375400      RectangleD clippingArea = rectangleShape.Rectangle;
     
    382407      zoomFullView = false; //user wants to zoom => no full view
    383408
    384       canvas.Invalidate();
     409      canvasUI.Invalidate();
    385410    }
    386411
    387412    private void DrawRectangle(Rectangle rectangle) {
    388       rectangleShape.Rectangle = Transform.ToWorld(rectangle, canvas.ClientRectangle, linesShape.ClippingArea);
    389       canvas.Invalidate();
     413      rectangleShape.Rectangle = Transform.ToWorld(rectangle, canvasUI.ClientRectangle, linesShape.ClippingArea);
     414      canvasUI.Invalidate();
    390415    }
    391416
    392417    private void CreatePanListener(MouseEventArgs e) {
    393       PanListener panListener = new PanListener(canvas.ClientRectangle, linesShape.ClippingArea, e.Location);
     418      PanListener panListener = new PanListener(canvasUI.ClientRectangle, linesShape.ClippingArea, e.Location);
    394419
    395420      panListener.SetNewClippingArea += SetNewClippingArea;
    396421      panListener.OnMouseUp += delegate {
    397422                                 historyStack.Push(linesShape.ClippingArea);
    398                                  canvas.MouseEventListener = null;
     423                                 canvasUI.MouseEventListener = null;
    399424                               };
    400425
    401       canvas.MouseEventListener = panListener;
     426      canvasUI.MouseEventListener = panListener;
    402427    }
    403428
     
    406431
    407432      zoomFullView = false;
    408       canvas.Invalidate();
     433      canvasUI.Invalidate();
    409434    }
    410435
     
    415440      optionsdlg.ShowDialog(this);
    416441    }
    417 
    418     public void OnDataRowChanged(IDataRow row) {
    419       foreach (LineShape ls in rowToLineShapes[row]) {
    420         ls.LSColor = row.Color;
    421         ls.LSThickness = row.Thickness;
    422         ls.LSDrawingStyle = row.Style;
    423       }
    424       canvas.Invalidate();
    425     }
    426442  }
    427443}
  • trunk/sources/HeuristicLab.Visualization/LineShape.cs

    r1234 r1240  
    44namespace HeuristicLab.Visualization {
    55  public class LineShape : IShape {
     6    private IShape parent;
    67    private RectangleD boundingBox;
    78
     
    3334    }
    3435
     36    public RectangleD ClippingArea {
     37      get { return Parent.ClippingArea; }
     38    }
     39
     40    public Rectangle Viewport {
     41      get { return Parent.Viewport; }
     42    }
     43
     44    public IShape Parent {
     45      get { return parent; }
     46      set { parent = value; }
     47    }
     48
    3549    public double Y1 {
    3650      get { return boundingBox.Y1; }
     
    5771    /// </summary>
    5872    /// <param name="graphics">graphics handle to draw to</param>
    59     /// <param name="parentViewport">rectangle in value-coordinates to display</param>
    60     /// <param name="parentClippingArea">rectangle in screen-coordinates to draw</param>
    61     public void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    62       Rectangle screenRect = Transform.ToScreen(boundingBox, parentViewport, parentClippingArea);
     73    public void Draw(Graphics graphics) {
     74      Rectangle screenRect = Transform.ToScreen(boundingBox, Parent.Viewport, Parent.ClippingArea);
    6375
    6476      graphics.DrawLine(GetPen(), screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top);
  • trunk/sources/HeuristicLab.Visualization/RectangleShape.cs

    r1234 r1240  
    33namespace HeuristicLab.Visualization {
    44  public class RectangleShape : IShape {
     5    private IShape parent;
    56    private RectangleD rectangle;
    67
     
    2021    }
    2122
     23    public RectangleD ClippingArea {
     24      get { return Parent.ClippingArea; }
     25    }
     26
     27    public Rectangle Viewport {
     28      get { return Parent.Viewport; }
     29    }
     30
     31    public IShape Parent {
     32      get { return parent; }
     33      set { parent = value; }
     34    }
     35
    2236    public RectangleD Rectangle {
    2337      get { return rectangle; }
     
    2539    }
    2640
    27     public void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    28       Rectangle screenRect = Transform.ToScreen(rectangle, parentViewport, parentClippingArea);
     41    public void Draw(Graphics graphics) {
     42      Rectangle screenRect = Transform.ToScreen(rectangle, Parent.Viewport, Parent.ClippingArea);
    2943
    3044      graphics.DrawRectangle(GetPen(), screenRect);
  • trunk/sources/HeuristicLab.Visualization/TextShape.cs

    r1234 r1240  
    1212
    1313  public class TextShape : IShape {
     14    private IShape parent;
    1415    private Font font;
    1516    private Brush brush;
     
    6869    #region IShape Members
    6970
    70     public void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    71       int screenX = Transform.ToScreenX(x, parentViewport, parentClippingArea);
    72       int screenY = Transform.ToScreenY(y, parentViewport, parentClippingArea);
     71    public void Draw(Graphics graphics) {
     72      int screenX = Transform.ToScreenX(x, Parent.Viewport, Parent.ClippingArea);
     73      int screenY = Transform.ToScreenY(y, Parent.Viewport, Parent.ClippingArea);
    7374
    7475      SizeF size = graphics.MeasureString(text, font);
     
    107108    }
    108109
     110    public RectangleD ClippingArea {
     111      get { return Parent.ClippingArea; }
     112    }
     113
     114    public Rectangle Viewport {
     115      get { return Parent.Viewport; }
     116    }
     117
     118    public IShape Parent {
     119      get { return parent; }
     120      set { parent = value; }
     121    }
     122
    109123    #endregion
    110124  }
  • trunk/sources/HeuristicLab.Visualization/WorldShape.cs

    r1234 r1240  
    1111    private RectangleD clippingArea; // own clipping area
    1212    private RectangleD boundingBox;
     13    private IShape parent;
    1314
    14     protected readonly List<IShape> shapes = new List<IShape>();
     15    private readonly List<IShape> shapes = new List<IShape>();
    1516
    16     public WorldShape()
    17       : this(new RectangleD(0, 0, 1, 1), new RectangleD(0, 0, 1, 1)) {}
    18 
    19     /// <param name="clippingArea">The new clipping area of this world shape</param>
    20     /// <param name="boundingBox">The location and the size of this world shape in the parent's coordinate system</param>
    21     public WorldShape(RectangleD clippingArea, RectangleD boundingBox) {
    22       this.clippingArea = clippingArea;
    23       this.boundingBox = boundingBox;
     17    public WorldShape() {
     18      this.clippingArea = new RectangleD(0, 0, 1, 1);
     19      this.boundingBox = new RectangleD(0, 0, 1, 1);
    2420    }
    2521
    26     public virtual void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
     22    public virtual void Draw(Graphics graphics) {
    2723      GraphicsState gstate = graphics.Save();
    2824
    29       // calculate our drawing area on the screen using our location and
    30       // size in the parent (boundingBox), the parent's viewport and the
    31       // parent's clipping area
    32       Rectangle viewport = Transform.ToScreen(boundingBox, parentViewport, parentClippingArea);
    33 
    34       graphics.SetClip(viewport);
     25      graphics.SetClip(Viewport);
    3526
    3627      foreach (IShape shape in shapes) {
    3728        // draw child shapes using our own clipping area
    38         shape.Draw(graphics, viewport, clippingArea);
     29        shape.Draw(graphics);
    3930      }
    4031
     
    5647    }
    5748
     49    public Rectangle Viewport {
     50      get {
     51        // calculate our drawing area on the screen using our location and
     52        // size in the parent (boundingBox), the parent's viewport and the
     53        // parent's clipping area
     54        Rectangle viewport = Transform.ToScreen(boundingBox, Parent.Viewport, Parent.ClippingArea);
     55        return viewport;
     56      }
     57    }
     58
     59    public IShape Parent {
     60      get { return parent; }
     61      set { parent = value; }
     62    }
     63
     64    public void ClearShapes() {
     65      shapes.Clear();
     66    }
     67
    5868    public void AddShape(IShape shape) {
     69      shape.Parent = this;
    5970      shapes.Add(shape);
    6071    }
  • trunk/sources/HeuristicLab.Visualization/XAxis.cs

    r1234 r1240  
    1313    }
    1414
    15     public override void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    16       shapes.Clear();
     15    public override void Draw(Graphics graphics) {
     16      ClearShapes();
    1717
    18       foreach (double x in AxisTicks.GetTicks(PixelsPerInterval, parentViewport.Width,
     18      foreach (double x in AxisTicks.GetTicks(PixelsPerInterval, Parent.Viewport.Width,
    1919                                              ClippingArea.Width,
    2020                                              ClippingArea.X1)) {
     
    2323        label.AnchorPositionX = AnchorPositionX.Middle;
    2424        label.AnchorPositionY = AnchorPositionY.Top;
    25         shapes.Add(label);
     25        AddShape(label);
    2626      }
    2727
    28       base.Draw(graphics, parentViewport, parentClippingArea);
     28      base.Draw(graphics);
    2929    }
    3030  }
  • trunk/sources/HeuristicLab.Visualization/YAxis.cs

    r1234 r1240  
    1313    }
    1414
    15     public override void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    16       shapes.Clear();
     15    public override void Draw(Graphics graphics) {
     16      ClearShapes();
    1717
    18       foreach (double y in AxisTicks.GetTicks(PixelsPerInterval, parentViewport.Height,
     18      foreach (double y in AxisTicks.GetTicks(PixelsPerInterval, Parent.Viewport.Height,
    1919                                              ClippingArea.Height,
    2020                                              ClippingArea.Y1)) {
     
    2323        label.AnchorPositionX = AnchorPositionX.Right;
    2424        label.AnchorPositionY = AnchorPositionY.Middle;
    25         shapes.Add(label);
     25        AddShape(label);
    2626      }
    2727
    28       base.Draw(graphics, parentViewport, parentClippingArea);
     28      base.Draw(graphics);
    2929    }
    3030  }
Note: See TracChangeset for help on using the changeset viewer.