using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; namespace HeuristicLab.Visualization { public class WorldShape : IShape { private RectangleD clippingArea; private RectangleD boundingBox; private readonly List shapes = new List(); public WorldShape(RectangleD clippingArea, RectangleD boundingBox) { this.clippingArea = clippingArea; this.boundingBox = boundingBox; } public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { GraphicsState gstate = graphics.Save(); Rectangle innerViewport = Transform.ToScreen(boundingBox, viewport, clippingArea); graphics.SetClip(innerViewport); foreach (IShape shape in shapes) { shape.Draw(graphics, innerViewport, this.clippingArea); } graphics.Restore(gstate); } /// /// /// public RectangleD BoundingBox { get { return boundingBox; } } /// /// adds a shape to the WorldShape /// /// shape to add public void AddShape(IShape shape) { shapes.Add(shape); } } }