C# Class NPlot.PhysicalAxis

This class adds physical positioning information [PhysicalMin, PhysicalMax] and related functionality on top of a specific Axis class. It's an interesting question where to put this information. It belongs with every specific axis type, but on the other hand, users of the library as it is normally used should not see it because positioning of axes is handled internally by PlotSurface2D. Therefore it doesn't make sense to put it in the Axis class unless it is internal. But if this were done it would restrict use of this information outside the library always, which is not what is wanted. The main disadvantage with the method chosen is that there is a lot of passing of the positional information between physical axis and the underlying logical axis type. C# doesn't have templates. If it did, I might derive PhysicalAxis from the templated Axis type (LinearAxis etc). Instead, have used a has-a relationship with an Axis superclass.
Mostrar archivo Open project: GridProtectionAlliance/openHistorian Class Usage Examples

Public Methods

Method Description
Draw ( Graphics g, Rectangle &boundingBox ) : void

Draws the axis on the given graphics surface.

GetBoundingBox ( ) : Rectangle

Returns the smallest rectangle that completely contains all parts of the axis [including ticks and label].

PhysicalAxis ( Axis a, Point physicalMin, Point physicalMax ) : System

Construct

PhysicalToWorld ( Point p, bool clip ) : double

Given a physical point on the graphics surface, returns the world value of it's projection onto the axis [i.e. closest point on the axis]. The function is implemented for axes of arbitrary orientation.

SetWorldLimitsFromPhysical ( Point min, Point max ) : void

This sets new world limits for the axis from two physical points selected within the plot area.

WorldToPhysical ( double coord, bool clip ) : PointF

Given a world coordinate value, returns the physical position of the coordinate along the axis.

Method Details

Draw() public method

Draws the axis on the given graphics surface.
public Draw ( Graphics g, Rectangle &boundingBox ) : void
g System.Drawing.Graphics The graphics surface on which to draw.
boundingBox System.Drawing.Rectangle out: the axis bounding box - the smallest rectangle that /// completely contains all parts of the axis [including ticks and label].
return void

GetBoundingBox() public method

Returns the smallest rectangle that completely contains all parts of the axis [including ticks and label].
public GetBoundingBox ( ) : Rectangle
return System.Drawing.Rectangle

PhysicalAxis() public method

Construct
public PhysicalAxis ( Axis a, Point physicalMin, Point physicalMax ) : System
a Axis The axis this is a physical representation of.
physicalMin Point the physical position of the world minimum axis value.
physicalMax Point the physical position of the world maximum axis value.
return System

PhysicalToWorld() public method

Given a physical point on the graphics surface, returns the world value of it's projection onto the axis [i.e. closest point on the axis]. The function is implemented for axes of arbitrary orientation.
public PhysicalToWorld ( Point p, bool clip ) : double
p Point Physical point to find corresponding world value of.
clip bool if true, returns a world position outside WorldMin / WorldMax /// range if this is closer to the axis line. If false, such values will /// be clipped to be either WorldMin or WorldMax as appropriate.
return double

SetWorldLimitsFromPhysical() public method

This sets new world limits for the axis from two physical points selected within the plot area.
public SetWorldLimitsFromPhysical ( Point min, Point max ) : void
min Point The upper left point of the selection.
max Point The lower right point of the selection.
return void

WorldToPhysical() public method

Given a world coordinate value, returns the physical position of the coordinate along the axis.
public WorldToPhysical ( double coord, bool clip ) : PointF
coord double the world coordinate
clip bool if true, the physical position returned will be clipped to the physical max / min position as appropriate if the world value is outside the limits of the axis.
return PointF