Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/WorldShape.cs @ 1182

Last change on this file since 1182 was 1182, checked in by mstoeger, 15 years ago

Implemented X/Y-Axes and a Grid. (#433)

File size: 1.4 KB
Line 
1using System.Collections.Generic;
2using System.Drawing;
3using System.Drawing.Drawing2D;
4
5namespace HeuristicLab.Visualization {
6  public class WorldShape : IShape {
7    private RectangleD clippingArea;
8    private RectangleD boundingBox;
9
10    protected readonly List<IShape> shapes = new List<IShape>();
11
12    public WorldShape()
13      : this(new RectangleD(0, 0, 1, 1), new RectangleD(0, 0, 1, 1)) {}
14
15    public WorldShape(RectangleD clippingArea, RectangleD boundingBox) {
16      this.clippingArea = clippingArea;
17      this.boundingBox = boundingBox;
18    }
19
20    public virtual void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
21      GraphicsState gstate = graphics.Save();
22
23      Rectangle innerViewport = Transform.ToScreen(boundingBox, viewport, clippingArea);
24
25      graphics.SetClip(innerViewport);
26
27      foreach (IShape shape in shapes) {
28        shape.Draw(graphics, innerViewport, this.clippingArea);
29      }
30
31      graphics.Restore(gstate);
32    }
33
34    public RectangleD BoundingBox {
35      get { return boundingBox; }
36      set { boundingBox = value; }
37    }
38
39    public RectangleD ClippingArea {
40      get { return clippingArea; }
41      set { clippingArea = value; }
42    }
43
44    public void AddShape(IShape shape) {
45      shapes.Add(shape);
46    }
47
48    public bool RemoveShape(IShape shape) {
49      return shapes.Remove(shape);
50    }
51  }
52}
Note: See TracBrowser for help on using the repository browser.