Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1234 for trunk/sources


Ignore:
Timestamp:
02/28/09 23:12:10 (15 years ago)
Author:
mstoeger
Message:

Added Xml comments for IShape, WorldShape and Transforms. (#406)

Location:
trunk/sources/HeuristicLab.Visualization
Files:
11 edited

Legend:

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

    r987 r1234  
    88    protected RectangleD boundingBox = RectangleD.Empty;
    99
    10     public virtual void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
     10    public virtual void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    1111      foreach (IShape shape in shapes) {
    12         shape.Draw(graphics, viewport, clippingArea);
     12        shape.Draw(graphics, parentViewport, parentClippingArea);
    1313      }
    1414    }
  • trunk/sources/HeuristicLab.Visualization/Grid.cs

    r1233 r1234  
    33namespace HeuristicLab.Visualization {
    44  public class Grid : WorldShape {
    5     public override void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
     5    public override void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    66      shapes.Clear();
    77
    88      foreach (double y in AxisTicks.GetTicks(YAxis.PixelsPerInterval,
    9                                               viewport.Height,
     9                                              parentViewport.Height,
    1010                                              ClippingArea.Height,
    1111                                              ClippingArea.Y1)) {
     
    1818
    1919      foreach (double x in AxisTicks.GetTicks(XAxis.PixelsPerInterval,
    20                                               viewport.Width,
     20                                              parentViewport.Width,
    2121                                              ClippingArea.Width,
    2222                                              ClippingArea.X1)) {
     
    4141      shapes.Add(lineZeroY);
    4242
    43       base.Draw(graphics, viewport, clippingArea);
     43      base.Draw(graphics, parentViewport, parentClippingArea);
    4444    }
    4545  }
  • trunk/sources/HeuristicLab.Visualization/HorizontalLineShape.cs

    r1233 r1234  
    2121    }
    2222
    23 
    24     /// <summary>
    25     /// Draws the HorizontalLineShape.
    26     /// </summary>
    27     /// <param name="graphics">graphics handle to draw to</param>
    28     /// <param name="viewport">rectangle in value-coordinates to display</param>
    29     /// <param name="clippingArea">rectangle in screen-coordinates to draw</param>
    30     public override void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
     23    public override void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    3124      minLineShape.X1 = ClippingArea.X1;
    3225      minLineShape.X2 = ClippingArea.X2;
    3326      maxLineShape.X1 = ClippingArea.X1;
    3427      maxLineShape.X2 = ClippingArea.X2;
    35       base.Draw(graphics, viewport, clippingArea);
     28      base.Draw(graphics, parentViewport, parentClippingArea);
    3629    }
    3730
  • trunk/sources/HeuristicLab.Visualization/IShape.cs

    r635 r1234  
    22
    33namespace HeuristicLab.Visualization {
     4  /// <summary>
     5  /// This is the base interface that has to be implemented by all shapes.
     6  ///
     7  /// View port
     8  ///   The view port is the available drawing area on the screen.
     9  ///   It is specified in the GDI coordinate system.
     10  ///
     11  /// Clipping area
     12  ///   The clipping area is the range of values visible on the view port.
     13  ///   Values outside this area will not be visible (they "get clipped").
     14  ///   It can either be inherited from the parent, or it can be overriden
     15  ///   to create distorted realities (see world shapes).
     16  ///   It is specified in a world coordinate system.
     17  ///
     18  /// Bounding box
     19  ///   The bounding box is the location and the size of a shape on its parent.
     20  ///   It is specified in the parent's world coordinate system.
     21  /// </summary>
    422  public interface IShape {
    5     void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea);
     23    /// <summary>
     24    /// Draws the shape
     25    /// </summary>
     26    /// <param name="graphics">The Graphics object used to draw the shape</param>
     27    /// <param name="parentViewport">The parent's view port</param>
     28    /// <param name="parentClippingArea">The parent's clipping area</param>
     29    void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea);
     30
     31    /// <summary>
     32    /// The shape's bounding box
     33    /// </summary>
    634    RectangleD BoundingBox { get; }
    735  }
  • trunk/sources/HeuristicLab.Visualization/LineShape.cs

    r1233 r1234  
    5757    /// </summary>
    5858    /// <param name="graphics">graphics handle to draw to</param>
    59     /// <param name="viewport">rectangle in value-coordinates to display</param>
    60     /// <param name="clippingArea">rectangle in screen-coordinates to draw</param>
    61     public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
    62       Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea);
     59    /// <param name="parentViewport">rectangle in value-coordinates to display</param>
     60    /// <param name="parentClippingArea">rectangle in screen-coordinates to draw</param>
     61    public void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
     62      Rectangle screenRect = Transform.ToScreen(boundingBox, parentViewport, parentClippingArea);
    6363
    6464      graphics.DrawLine(GetPen(), screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top);
  • trunk/sources/HeuristicLab.Visualization/RectangleShape.cs

    r1233 r1234  
    2525    }
    2626
    27     public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
    28       Rectangle screenRect = Transform.ToScreen(rectangle, viewport, clippingArea);
     27    public void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
     28      Rectangle screenRect = Transform.ToScreen(rectangle, parentViewport, parentClippingArea);
    2929
    3030      graphics.DrawRectangle(GetPen(), screenRect);
  • trunk/sources/HeuristicLab.Visualization/TextShape.cs

    r1182 r1234  
    6868    #region IShape Members
    6969
    70     public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
    71       int screenX = Transform.ToScreenX(x, viewport, clippingArea);
    72       int screenY = Transform.ToScreenY(y, viewport, clippingArea);
     70    public void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
     71      int screenX = Transform.ToScreenX(x, parentViewport, parentClippingArea);
     72      int screenY = Transform.ToScreenY(y, parentViewport, parentClippingArea);
    7373
    7474      SizeF size = graphics.MeasureString(text, font);
  • trunk/sources/HeuristicLab.Visualization/Transform.cs

    r931 r1234  
    22
    33namespace HeuristicLab.Visualization {
     4  /// <summary>
     5  /// GDI (or screen) coordinate system
     6  ///   The GDI coordinate system is specified in pixels. X goes from left to right
     7  ///   and Y goes from top to bottom.
     8  ///
     9  /// World coordinate system
     10  ///   A world coordinate system can be freely specified. X goes from left to
     11  ///   right and Y goes from bottom to top.
     12  ///
     13  /// The transformation between world- and screen-coordinate systems is done using
     14  /// a view port and a clipping area.
     15  /// </summary>
    416  public static class Transform {
    5 
    617    /// <summary>
    7     /// Screen to world transformations
     18    /// Transforms a rectangle in screen coordinates to world coordinates
    819    /// </summary>
    9     /// <param name="rect"></param>
    10     /// <param name="viewport"></param>
    11     /// <param name="clippingArea"></param>
    12     /// <returns></returns>
     20    /// <param name="rect">The rectangle in screen coordinates that should be transformed</param>
     21    /// <param name="viewport">The target view port</param>
     22    /// <param name="clippingArea">The target clipping area</param>
     23    /// <returns>The rectangle rect transformed to world coordinates</returns>
    1324    public static RectangleD ToWorld(Rectangle rect, Rectangle viewport, RectangleD clippingArea) {
    1425      double x1 = ToWorldX(rect.Left, viewport, clippingArea);
     
    1930    }
    2031
     32    /// <summary>
     33    /// Transforms a 2d point in screen coordinates to world coordinates
     34    /// </summary>
     35    /// <param name="point">The point in screen coordinates that should be transformed</param>
     36    /// <param name="viewport">The target view port</param>
     37    /// <param name="clippingArea">The target clipping area</param>
     38    /// <returns>The point transformed to world coordinates</returns>
    2139    public static PointD ToWorld(Point point, Rectangle viewport, RectangleD clippingArea) {
    2240      double x = ToWorldX(point.X, viewport, clippingArea);
     
    2543    }
    2644
     45    /// <summary>
     46    /// Transforms a point on the X-axis in screen coordinates to world coordinates
     47    /// </summary>
     48    /// <param name="x">The point on the X-axis in screen coordinates that should be transformed</param>
     49    /// <param name="viewport">The target view port</param>
     50    /// <param name="clippingArea">The target clipping area</param>
     51    /// <returns>The point transformed to world coordinates</returns>
    2752    public static double ToWorldX(int x, Rectangle viewport, RectangleD clippingArea) {
    2853      return clippingArea.X1 + clippingArea.Width/viewport.Width*(x - viewport.Left);
    2954    }
    3055
     56    /// <summary>
     57    /// Transforms a point on the Y-axis in screen coordinates to world coordinates
     58    /// </summary>
     59    /// <param name="y">The point on the Y-axis in screen coordinates that should be transformed</param>
     60    /// <param name="viewport">The target view port</param>
     61    /// <param name="clippingArea">The target clipping area</param>
     62    /// <returns>The point transformed to world coordinates</returns>
    3163    public static double ToWorldY(int y, Rectangle viewport, RectangleD clippingArea) {
    3264      return clippingArea.Y1 - clippingArea.Height/viewport.Height*(y - viewport.Bottom);
     
    3466
    3567    /// <summary>
    36     /// World to screen transformations
     68    /// Transforms a rectangle in world coordinates to screen coordinates
    3769    /// </summary>
    38     /// <param name="rect"></param>
    39     /// <param name="viewport"></param>
    40     /// <param name="clippingArea"></param>
    41     /// <returns></returns>
     70    /// <param name="rect">The rectangle in world coordinates that should be transformed</param>
     71    /// <param name="viewport">The target view port</param>
     72    /// <param name="clippingArea">The target clipping area</param>
     73    /// <returns>The rectangle rect transformed to screen coordinates</returns>
    4274    public static Rectangle ToScreen(RectangleD rect, Rectangle viewport, RectangleD clippingArea) {
    4375      int left = ToScreenX(rect.X1, viewport, clippingArea);
     
    4880    }
    4981
     82    /// <summary>
     83    /// Transforms a 2d point in world coordinates to screen coordinates
     84    /// </summary>
     85    /// <param name="point">The point in world coordinates that should be transformed</param>
     86    /// <param name="viewport">The target view port</param>
     87    /// <param name="clippingArea">The target clipping area</param>
     88    /// <returns>The point transformed to screen coordinates</returns>
    5089    public static Point ToScreen(PointD point, Rectangle viewport, RectangleD clippingArea) {
    5190      int x = ToScreenX(point.X, viewport, clippingArea);
     
    5493    }
    5594
     95    /// <summary>
     96    /// Transforms a point on the X-axis in world coordinates to screen coordinates
     97    /// </summary>
     98    /// <param name="x">The point on the X-axis in world coordinates that should be transformed</param>
     99    /// <param name="viewport">The target view port</param>
     100    /// <param name="clippingArea">The target clipping area</param>
     101    /// <returns>The point transformed to screen coordinates</returns>
    56102    public static int ToScreenX(double x, Rectangle viewport, RectangleD clippingArea) {
    57103      return (int)(viewport.Left + viewport.Width/clippingArea.Width*(x - clippingArea.X1));
    58104    }
    59105
     106    /// <summary>
     107    /// Transforms a point on the Y-axis in world coordinates to screen coordinates
     108    /// </summary>
     109    /// <param name="y">The point on the Y-axis in world coordinates that should be transformed</param>
     110    /// <param name="viewport">The target view port</param>
     111    /// <param name="clippingArea">The target clipping area</param>
     112    /// <returns>The point transformed to screen coordinates</returns>
    60113    public static int ToScreenY(double y, Rectangle viewport, RectangleD clippingArea) {
    61114      return (int)(viewport.Bottom - viewport.Height/clippingArea.Height*(y - clippingArea.Y1));
  • trunk/sources/HeuristicLab.Visualization/WorldShape.cs

    r1182 r1234  
    44
    55namespace HeuristicLab.Visualization {
     6  /// <summary>
     7  /// World shapes are composite shapes that have their own coordinate system
     8  /// which is independent from their parent's coordinate system.
     9  /// </summary>
    610  public class WorldShape : IShape {
    7     private RectangleD clippingArea;
     11    private RectangleD clippingArea; // own clipping area
    812    private RectangleD boundingBox;
    913
     
    1317      : this(new RectangleD(0, 0, 1, 1), new RectangleD(0, 0, 1, 1)) {}
    1418
     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>
    1521    public WorldShape(RectangleD clippingArea, RectangleD boundingBox) {
    1622      this.clippingArea = clippingArea;
     
    1824    }
    1925
    20     public virtual void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
     26    public virtual void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    2127      GraphicsState gstate = graphics.Save();
    2228
    23       Rectangle innerViewport = Transform.ToScreen(boundingBox, viewport, clippingArea);
     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);
    2433
    25       graphics.SetClip(innerViewport);
     34      graphics.SetClip(viewport);
    2635
    2736      foreach (IShape shape in shapes) {
    28         shape.Draw(graphics, innerViewport, this.clippingArea);
     37        // draw child shapes using our own clipping area
     38        shape.Draw(graphics, viewport, clippingArea);
    2939      }
    3040
     
    3747    }
    3848
     49    /// <summary>
     50    /// The world shape's own clipping area.
     51    /// This overrides the clipping area of the parent shape.
     52    /// </summary>
    3953    public RectangleD ClippingArea {
    4054      get { return clippingArea; }
  • trunk/sources/HeuristicLab.Visualization/XAxis.cs

    r1233 r1234  
    1313    }
    1414
    15     public override void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
     15    public override void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    1616      shapes.Clear();
    1717
    18       foreach (double x in AxisTicks.GetTicks(PixelsPerInterval, viewport.Width,
     18      foreach (double x in AxisTicks.GetTicks(PixelsPerInterval, parentViewport.Width,
    1919                                              ClippingArea.Width,
    2020                                              ClippingArea.X1)) {
     
    2626      }
    2727
    28       base.Draw(graphics, viewport, clippingArea);
     28      base.Draw(graphics, parentViewport, parentClippingArea);
    2929    }
    3030  }
  • trunk/sources/HeuristicLab.Visualization/YAxis.cs

    r1233 r1234  
    1313    }
    1414
    15     public override void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
     15    public override void Draw(Graphics graphics, Rectangle parentViewport, RectangleD parentClippingArea) {
    1616      shapes.Clear();
    1717
    18       foreach (double y in AxisTicks.GetTicks(PixelsPerInterval, viewport.Height,
     18      foreach (double y in AxisTicks.GetTicks(PixelsPerInterval, parentViewport.Height,
    1919                                              ClippingArea.Height,
    2020                                              ClippingArea.Y1)) {
     
    2626      }
    2727
    28       base.Draw(graphics, viewport, clippingArea);
     28      base.Draw(graphics, parentViewport, parentClippingArea);
    2929    }
    3030  }
Note: See TracChangeset for help on using the changeset viewer.