Changeset 1240
- Timestamp:
- 03/02/09 22:03:41 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.Test/LegendForm.cs
r1233 r1240 7 7 public LegendForm() { 8 8 InitializeComponent(); 9 canvasUI.MainCanvas.WorldShape = new WorldShape(new RectangleD(0, 0, 800, 600), new RectangleD(0, 0, 800, 600));10 9 11 10 CreateLegendShape(); … … 13 12 14 13 private void CreateLegendShape() { 15 WorldShape mainShape = canvasUI.MainCanvas.WorldShape;16 14 LegendShape ls = new LegendShape(); 17 15 ls.AddLegendItem(new LegendItem("test", Color.Black, 5)); 18 16 ls.AddLegendItem(new LegendItem("test2", Color.Red, 5)); 19 17 20 mainShape.AddShape(ls);18 canvasUI.Canvas.AddShape(ls); 21 19 } 22 20 } -
trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs
r1049 r1240 112 112 f.ShowDialog(); 113 113 } 114 115 [Test] 116 public void TestMainForm() { 117 MainForm f = new MainForm(); 118 f.ShowDialog(); 119 } 114 120 } 115 121 } -
trunk/sources/HeuristicLab.Visualization.Test/MainForm.cs
r1045 r1240 1 using System.Drawing; 1 using System; 2 using System.Drawing; 2 3 using System.Windows.Forms; 3 4 4 5 namespace HeuristicLab.Visualization.Test { 5 6 public partial class MainForm : Form { 7 private readonly Canvas canvas; 8 6 9 public MainForm() { 7 10 InitializeComponent(); 8 11 9 canvas UI.MainCanvas.WorldShape = new WorldShape(new RectangleD(0, 0, 800, 600), new RectangleD(0, 0, 800, 600));12 canvas = canvasUI.Canvas; 10 13 11 14 CreateLeftWorldShape(); … … 18 21 19 22 private void CreateSimpleRectangleShape() { 20 WorldShape mainWorld = canvasUI.MainCanvas.WorldShape;21 23 // simple rectangle shape 22 24 RectangleShape rect7 = new RectangleShape(5, 5, 50, 50, Color.Black); 23 mainWorld.AddShape(rect7);25 canvas.AddShape(rect7); 24 26 } 25 27 26 28 private void CreateRightWorldShape() { 27 WorldShape mainWorld = canvasUI.MainCanvas.WorldShape;28 29 // 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); 30 33 31 34 double x1 = -3; … … 39 42 } 40 43 41 mainWorld.AddShape(rightWorld);44 canvas.AddShape(rightWorld); 42 45 } 43 46 44 47 private void CreateMiddleCompositeShape() { 45 WorldShape mainWorld = canvasUI.MainCanvas.WorldShape;46 48 // middle composite shape 47 49 CompositeShape middleComp = new CompositeShape(); … … 53 55 middleComp.AddShape(rect6); 54 56 55 mainWorld.AddShape(middleComp);57 canvas.AddShape(middleComp); 56 58 } 57 59 58 60 private void CreateLeftWorldShape() { 59 WorldShape mainWorld = canvasUI.MainCanvas.WorldShape;60 61 // 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); 62 65 63 66 RectangleShape fillRect = new RectangleShape(0, 0, 1000, 1000, Color.LightBlue); … … 79 82 leftWorld.AddShape(comp1); 80 83 81 mainWorld.AddShape(leftWorld);84 canvas.AddShape(leftWorld); 82 85 } 83 86 84 private void legendButton_Click(object sender, System.EventArgs e) {87 private void legendButton_Click(object sender, EventArgs e) { 85 88 LegendForm form = new LegendForm(); 86 89 form.Show(); -
trunk/sources/HeuristicLab.Visualization/Canvas.cs
r1038 r1240 1 using System; 1 2 using System.Diagnostics; 2 3 using System.Drawing; … … 4 5 5 6 namespace HeuristicLab.Visualization { 6 public class Canvas : I Canvas{7 private WorldShape world;7 public class Canvas : IShape { 8 private readonly WorldShape worldShape; 8 9 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; 12 15 } 13 16 17 public void AddShape(IShape shape) { 18 worldShape.AddShape(shape); 19 } 14 20 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) { 16 52 Stopwatch sw = new Stopwatch(); 17 53 sw.Start(); 18 54 19 GraphicsState gstate = graphics.Save(); 55 graphics.SmoothingMode = SmoothingMode.AntiAlias; 56 graphics.FillRectangle(Brushes.White, Viewport); 20 57 21 graphics.SetClip(viewport);58 worldShape.Draw(graphics); 22 59 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); 26 61 27 62 sw.Stop(); -
trunk/sources/HeuristicLab.Visualization/CanvasUI.cs
r1045 r1240 2 2 using System.Diagnostics; 3 3 using System.Drawing; 4 using System.Drawing.Drawing2D;5 4 using System.Windows.Forms; 6 5 7 6 namespace HeuristicLab.Visualization { 8 7 public partial class CanvasUI : Control { 9 private readonly Canvas mainCanvas = new Canvas();8 private readonly Canvas canvas = new Canvas(); 10 9 private IMouseEventListener mouseEventListener; 11 10 … … 16 15 } 17 16 18 public Canvas MainCanvas {19 get { return mainCanvas; }17 public Canvas Canvas { 18 get { return canvas; } 20 19 } 21 20 … … 29 28 Graphics g = pe.Graphics; 30 29 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); 38 32 39 33 base.OnPaint(pe); … … 45 39 protected override void OnResize(EventArgs e) { 46 40 Invalidate(); 41 42 canvas.Viewport = ClientRectangle; 47 43 48 44 base.OnResize(e); -
trunk/sources/HeuristicLab.Visualization/CompositeShape.cs
r1234 r1240 5 5 namespace HeuristicLab.Visualization { 6 6 public class CompositeShape : IShape { 7 private IShape parent; 8 7 9 protected readonly List<IShape> shapes = new List<IShape>(); 8 10 protected RectangleD boundingBox = RectangleD.Empty; 9 11 10 public virtual void Draw(Graphics graphics , Rectangle parentViewport, RectangleD parentClippingArea) {12 public virtual void Draw(Graphics graphics) { 11 13 foreach (IShape shape in shapes) { 12 shape.Draw(graphics , parentViewport, parentClippingArea);14 shape.Draw(graphics); 13 15 } 14 16 } … … 24 26 } 25 27 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 26 41 public void ClearShapes() { 27 42 shapes.Clear(); … … 30 45 31 46 public void AddShape(IShape shape) { 47 shape.Parent = this; 48 32 49 if (shapes.Count == 0) { 33 50 boundingBox = shape.BoundingBox; -
trunk/sources/HeuristicLab.Visualization/Grid.cs
r1234 r1240 3 3 namespace HeuristicLab.Visualization { 4 4 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(); 7 7 8 8 foreach (double y in AxisTicks.GetTicks(YAxis.PixelsPerInterval, 9 parentViewport.Height,9 Parent.Viewport.Height, 10 10 ClippingArea.Height, 11 11 ClippingArea.Y1)) { … … 14 14 Color.LightBlue, 1, 15 15 DrawingStyle.Dashed); 16 shapes.Add(line);16 AddShape(line); 17 17 } 18 18 19 19 foreach (double x in AxisTicks.GetTicks(XAxis.PixelsPerInterval, 20 parentViewport.Width,20 Parent.Viewport.Width, 21 21 ClippingArea.Width, 22 22 ClippingArea.X1)) { … … 25 25 Color.LightBlue, 1, 26 26 DrawingStyle.Dashed); 27 shapes.Add(line);27 AddShape(line); 28 28 } 29 29 … … 38 38 DrawingStyle.Dashed); 39 39 40 shapes.Add(lineZeroX);41 shapes.Add(lineZeroY);40 AddShape(lineZeroX); 41 AddShape(lineZeroY); 42 42 43 base.Draw(graphics , parentViewport, parentClippingArea);43 base.Draw(graphics); 44 44 } 45 45 } -
trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj
r1233 r1240 102 102 <Compile Include="DrawingStyle.cs" /> 103 103 <Compile Include="HeuristicLabVisualizationPlugin.cs" /> 104 <Compile Include="ICanvas.cs" />105 104 <Compile Include="IChartDataModel.cs" /> 106 105 <Compile Include="IChartDataRowsModel.cs" /> -
trunk/sources/HeuristicLab.Visualization/HorizontalLineShape.cs
r1234 r1240 17 17 minLineShape = new LineShape(0, yMin, 1, yMin, color, thickness, style); 18 18 maxLineShape = new LineShape(0, yMax, 1, yMax, color, thickness, style); 19 shapes.Add(minLineShape);20 shapes.Add(maxLineShape);19 AddShape(minLineShape); 20 AddShape(maxLineShape); 21 21 } 22 22 23 public override void Draw(Graphics graphics , Rectangle parentViewport, RectangleD parentClippingArea) {23 public override void Draw(Graphics graphics) { 24 24 minLineShape.X1 = ClippingArea.X1; 25 25 minLineShape.X2 = ClippingArea.X2; 26 26 maxLineShape.X1 = ClippingArea.X1; 27 27 maxLineShape.X2 = ClippingArea.X2; 28 base.Draw(graphics , parentViewport, parentClippingArea);28 base.Draw(graphics); 29 29 } 30 30 -
trunk/sources/HeuristicLab.Visualization/IShape.cs
r1234 r1240 25 25 /// </summary> 26 26 /// <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); 30 28 31 29 /// <summary> … … 33 31 /// </summary> 34 32 RectangleD BoundingBox { get; } 33 34 RectangleD ClippingArea { get; } 35 Rectangle Viewport { get; } 36 37 IShape Parent { get; set; } 35 38 } 36 39 } -
trunk/sources/HeuristicLab.Visualization/Legend/LegendShape.cs
r1233 r1240 11 11 12 12 public void CreateLegend() { 13 shapes.Clear();13 ClearShapes(); 14 14 double y = ClippingArea.Y2; 15 15 foreach (LegendItem item in legendItems) { -
trunk/sources/HeuristicLab.Visualization/LineChart.Designer.cs
r1187 r1240 32 32 { 33 33 this.components = new System.ComponentModel.Container(); 34 this.canvas = new HeuristicLab.Visualization.CanvasUI();34 this.canvasUI = new HeuristicLab.Visualization.CanvasUI(); 35 35 this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); 36 36 this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); … … 38 38 this.SuspendLayout(); 39 39 // 40 // canvas 40 // canvasUI 41 41 // 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); 53 54 // 54 55 // contextMenuStrip1 … … 57 58 this.optionsToolStripMenuItem}); 58 59 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); 61 61 // 62 62 // optionsToolStripMenuItem 63 63 // 64 64 this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; 65 this.optionsToolStripMenuItem.Size = new System.Drawing.Size(1 52, 22);65 this.optionsToolStripMenuItem.Size = new System.Drawing.Size(122, 22); 66 66 this.optionsToolStripMenuItem.Text = "Options"; 67 67 this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click); … … 71 71 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 72 72 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 73 this.Controls.Add(this.canvas );73 this.Controls.Add(this.canvasUI); 74 74 this.Name = "LineChart"; 75 this.Size = new System.Drawing.Size(55 2, 390);75 this.Size = new System.Drawing.Size(551, 373); 76 76 this.contextMenuStrip1.ResumeLayout(false); 77 77 this.ResumeLayout(false); … … 81 81 #endregion 82 82 83 private CanvasUI canvas ;83 private CanvasUI canvasUI; 84 84 private ContextMenuStrip contextMenuStrip1; 85 85 private ToolStripMenuItem optionsToolStripMenuItem; -
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r1237 r1240 12 12 13 13 private readonly IChartDataRowsModel model; 14 private readonly Canvas canvas; 15 14 16 private int maxDataRowCount; 15 17 private Boolean zoomFullView; … … 20 22 private IShape minLineShape; 21 23 22 private readonly WorldShape root;23 24 private readonly TextShape titleShape; 24 25 private readonly LinesShape linesShape; … … 28 29 private readonly YAxis yAxis; 29 30 private readonly Grid grid; 31 32 private readonly WorldShape berni; 33 private readonly RectangleShape mousePointer; 30 34 31 35 /// <summary> … … 45 49 } 46 50 47 //TODO: correct Rectangle to fit48 49 root = new WorldShape();51 minMaxLineEnabled = true; 52 53 canvas = canvasUI.Canvas; 50 54 51 55 grid = new Grid(); 52 minMaxLineEnabled = true; 53 root.AddShape(grid); 56 canvas.AddShape(grid); 54 57 55 58 linesShape = new LinesShape(); 56 root.AddShape(linesShape);59 canvas.AddShape(linesShape); 57 60 58 61 xAxis = new XAxis(); 59 root.AddShape(xAxis);62 canvas.AddShape(xAxis); 60 63 61 64 yAxis = new YAxis(); 62 root.AddShape(yAxis);65 canvas.AddShape(yAxis); 63 66 64 67 titleShape = new TextShape(0, 0, model.Title, 15); 65 root.AddShape(titleShape);68 canvas.AddShape(titleShape); 66 69 67 70 minMaxLineShape = new MinMaxLineShape(this.minDataValue, this.maxDataValue, Color.Yellow, 4, DrawingStyle.Solid); 68 root.AddShape(minMaxLineShape);71 canvas.AddShape(minMaxLineShape); 69 72 70 73 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 77 82 maxDataRowCount = 0; 78 83 this.model = model; 79 84 Item = model; 80 85 86 UpdateLayout(); 87 canvasUI.Resize += delegate { UpdateLayout(); }; 81 88 82 89 //The whole data rows are shown per default … … 88 95 /// </summary> 89 96 private void UpdateLayout() { 90 root.ClippingArea = new RectangleD(0, 0, canvas.Width, canvas.Height);91 92 97 titleShape.X = 10; 93 titleShape.Y = canvas .Height - 10;98 titleShape.Y = canvasUI.Height - 10; 94 99 95 100 const int yAxisWidth = 100; … … 98 103 linesShape.BoundingBox = new RectangleD(yAxisWidth, 99 104 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); 102 110 103 111 grid.BoundingBox = linesShape.BoundingBox; … … 115 123 linesShape.BoundingBox.Y1); 116 124 117 legendShape.BoundingBox = new RectangleD(10, 10, 110, canvas .Height - 50);125 legendShape.BoundingBox = new RectangleD(10, 10, 110, canvasUI.Height - 50); 118 126 legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, 119 127 legendShape.BoundingBox.Height); … … 124 132 ZoomToFullView(); 125 133 126 canvas .Invalidate();134 canvasUI.Invalidate(); 127 135 } 128 136 … … 162 170 InitLineShapes(row); 163 171 } 172 173 private void OnDataRowRemoved(IDataRow row) { 174 row.ValueChanged -= OnRowValueChanged; 175 row.ValuesChanged -= OnRowValuesChanged; 176 row.DataRowChanged -= OnDataRowChanged; 177 } 178 179 #endregion 164 180 165 181 private void ZoomToFullView() { … … 221 237 ZoomToFullView(); 222 238 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(); 230 240 } 231 241 … … 267 277 ZoomToFullView(); 268 278 269 canvas .Invalidate();270 } 271 272 279 canvasUI.Invalidate(); 280 } 281 282 // TODO remove (see ticket #501) 273 283 public IList<IDataRow> GetRows() { 274 284 return model.Rows; … … 286 296 titleShape.Text = model.Title; 287 297 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 } 292 309 293 310 #region Begin-/EndUpdate … … 307 324 308 325 if (beginUpdateCount == 0) { 309 canvas .Invalidate();326 canvasUI.Invalidate(); 310 327 } 311 328 } … … 325 342 326 343 SetNewClippingArea(clippingArea); 327 canvas .Invalidate();344 canvasUI.Invalidate(); 328 345 } 329 346 } … … 346 363 } 347 364 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 348 373 private void canvasUI1_MouseWheel(object sender, MouseEventArgs e) { 349 374 if (ModifierKeys == Keys.Control) { … … 353 378 354 379 SetLineClippingArea(clippingArea); 355 canvas .Invalidate();380 canvasUI.Invalidate(); 356 381 } 357 382 } … … 362 387 zoomListener.OnMouseUp += OnZoom_MouseUp; 363 388 364 canvas .MouseEventListener = zoomListener;389 canvasUI.MouseEventListener = zoomListener; 365 390 366 391 rectangleShape = new RectangleShape(e.X, e.Y, e.X, e.Y, Color.Blue); … … 371 396 372 397 private void OnZoom_MouseUp(object sender, MouseEventArgs e) { 373 canvas .MouseEventListener = null;398 canvasUI.MouseEventListener = null; 374 399 375 400 RectangleD clippingArea = rectangleShape.Rectangle; … … 382 407 zoomFullView = false; //user wants to zoom => no full view 383 408 384 canvas .Invalidate();409 canvasUI.Invalidate(); 385 410 } 386 411 387 412 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(); 390 415 } 391 416 392 417 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); 394 419 395 420 panListener.SetNewClippingArea += SetNewClippingArea; 396 421 panListener.OnMouseUp += delegate { 397 422 historyStack.Push(linesShape.ClippingArea); 398 canvas .MouseEventListener = null;423 canvasUI.MouseEventListener = null; 399 424 }; 400 425 401 canvas .MouseEventListener = panListener;426 canvasUI.MouseEventListener = panListener; 402 427 } 403 428 … … 406 431 407 432 zoomFullView = false; 408 canvas .Invalidate();433 canvasUI.Invalidate(); 409 434 } 410 435 … … 415 440 optionsdlg.ShowDialog(this); 416 441 } 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 }426 442 } 427 443 } -
trunk/sources/HeuristicLab.Visualization/LineShape.cs
r1234 r1240 4 4 namespace HeuristicLab.Visualization { 5 5 public class LineShape : IShape { 6 private IShape parent; 6 7 private RectangleD boundingBox; 7 8 … … 33 34 } 34 35 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 35 49 public double Y1 { 36 50 get { return boundingBox.Y1; } … … 57 71 /// </summary> 58 72 /// <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); 63 75 64 76 graphics.DrawLine(GetPen(), screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top); -
trunk/sources/HeuristicLab.Visualization/RectangleShape.cs
r1234 r1240 3 3 namespace HeuristicLab.Visualization { 4 4 public class RectangleShape : IShape { 5 private IShape parent; 5 6 private RectangleD rectangle; 6 7 … … 20 21 } 21 22 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 22 36 public RectangleD Rectangle { 23 37 get { return rectangle; } … … 25 39 } 26 40 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); 29 43 30 44 graphics.DrawRectangle(GetPen(), screenRect); -
trunk/sources/HeuristicLab.Visualization/TextShape.cs
r1234 r1240 12 12 13 13 public class TextShape : IShape { 14 private IShape parent; 14 15 private Font font; 15 16 private Brush brush; … … 68 69 #region IShape Members 69 70 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); 73 74 74 75 SizeF size = graphics.MeasureString(text, font); … … 107 108 } 108 109 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 109 123 #endregion 110 124 } -
trunk/sources/HeuristicLab.Visualization/WorldShape.cs
r1234 r1240 11 11 private RectangleD clippingArea; // own clipping area 12 12 private RectangleD boundingBox; 13 private IShape parent; 13 14 14 pr otectedreadonly List<IShape> shapes = new List<IShape>();15 private readonly List<IShape> shapes = new List<IShape>(); 15 16 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); 24 20 } 25 21 26 public virtual void Draw(Graphics graphics , Rectangle parentViewport, RectangleD parentClippingArea) {22 public virtual void Draw(Graphics graphics) { 27 23 GraphicsState gstate = graphics.Save(); 28 24 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); 35 26 36 27 foreach (IShape shape in shapes) { 37 28 // draw child shapes using our own clipping area 38 shape.Draw(graphics , viewport, clippingArea);29 shape.Draw(graphics); 39 30 } 40 31 … … 56 47 } 57 48 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 58 68 public void AddShape(IShape shape) { 69 shape.Parent = this; 59 70 shapes.Add(shape); 60 71 } -
trunk/sources/HeuristicLab.Visualization/XAxis.cs
r1234 r1240 13 13 } 14 14 15 public override void Draw(Graphics graphics , Rectangle parentViewport, RectangleD parentClippingArea) {16 shapes.Clear();15 public override void Draw(Graphics graphics) { 16 ClearShapes(); 17 17 18 foreach (double x in AxisTicks.GetTicks(PixelsPerInterval, parentViewport.Width,18 foreach (double x in AxisTicks.GetTicks(PixelsPerInterval, Parent.Viewport.Width, 19 19 ClippingArea.Width, 20 20 ClippingArea.X1)) { … … 23 23 label.AnchorPositionX = AnchorPositionX.Middle; 24 24 label.AnchorPositionY = AnchorPositionY.Top; 25 shapes.Add(label);25 AddShape(label); 26 26 } 27 27 28 base.Draw(graphics , parentViewport, parentClippingArea);28 base.Draw(graphics); 29 29 } 30 30 } -
trunk/sources/HeuristicLab.Visualization/YAxis.cs
r1234 r1240 13 13 } 14 14 15 public override void Draw(Graphics graphics , Rectangle parentViewport, RectangleD parentClippingArea) {16 shapes.Clear();15 public override void Draw(Graphics graphics) { 16 ClearShapes(); 17 17 18 foreach (double y in AxisTicks.GetTicks(PixelsPerInterval, parentViewport.Height,18 foreach (double y in AxisTicks.GetTicks(PixelsPerInterval, Parent.Viewport.Height, 19 19 ClippingArea.Height, 20 20 ClippingArea.Y1)) { … … 23 23 label.AnchorPositionX = AnchorPositionX.Right; 24 24 label.AnchorPositionY = AnchorPositionY.Middle; 25 shapes.Add(label);25 AddShape(label); 26 26 } 27 27 28 base.Draw(graphics , parentViewport, parentClippingArea);28 base.Draw(graphics); 29 29 } 30 30 }
Note: See TracChangeset
for help on using the changeset viewer.