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