Rev | Line | |
---|
[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 |
|
---|
| 10 | private readonly List<IShape> shapes = new List<IShape>();
|
---|
| 11 |
|
---|
| 12 | public WorldShape(RectangleD clippingArea, RectangleD boundingBox) {
|
---|
| 13 | this.clippingArea = clippingArea;
|
---|
| 14 | this.boundingBox = boundingBox;
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
|
---|
| 18 | GraphicsState gstate = graphics.Save();
|
---|
| 19 |
|
---|
| 20 | Rectangle innerViewport = Transform.ToScreen(boundingBox, viewport, clippingArea);
|
---|
| 21 |
|
---|
| 22 | graphics.SetClip(innerViewport);
|
---|
| 23 |
|
---|
| 24 | foreach (IShape shape in shapes) {
|
---|
| 25 | shape.Draw(graphics, innerViewport, this.clippingArea);
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | graphics.Restore(gstate);
|
---|
| 29 | }
|
---|
| 30 |
|
---|
[862] | 31 | /// <summary>
|
---|
| 32 | ///
|
---|
| 33 | /// </summary>
|
---|
[635] | 34 | public RectangleD BoundingBox {
|
---|
| 35 | get { return boundingBox; }
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[862] | 38 | /// <summary>
|
---|
| 39 | /// adds a shape to the WorldShape
|
---|
| 40 | /// </summary>
|
---|
| 41 | /// <param name="shape">shape to add</param>
|
---|
[635] | 42 | public void AddShape(IShape shape) {
|
---|
| 43 | shapes.Add(shape);
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.