Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/02/09 22:03:41 (15 years ago)
Author:
mstoeger
Message:

Transformations on shapes are possible outside of the Draw method. (#424)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/WorldShape.cs

    r1234 r1240  
    1111    private RectangleD clippingArea; // own clipping area
    1212    private RectangleD boundingBox;
     13    private IShape parent;
    1314
    14     protected readonly List<IShape> shapes = new List<IShape>();
     15    private readonly List<IShape> shapes = new List<IShape>();
    1516
    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);
    2420    }
    2521
    26     public virtual void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
     22    public virtual void Draw(Graphics graphics) {
    2723      GraphicsState gstate = graphics.Save();
    2824
    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);
    3526
    3627      foreach (IShape shape in shapes) {
    3728        // draw child shapes using our own clipping area
    38         shape.Draw(graphics, viewport, clippingArea);
     29        shape.Draw(graphics);
    3930      }
    4031
     
    5647    }
    5748
     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
    5868    public void AddShape(IShape shape) {
     69      shape.Parent = this;
    5970      shapes.Add(shape);
    6071    }
Note: See TracChangeset for help on using the changeset viewer.