Axis Class Reference

#include <Axis.hpp>

Collaboration diagram for Axis:

Collaboration graph
[legend]
List of all members.

Detailed Description

This class is used to draw a simple axis.

It can be configured mostly by using an AxisStyle but specific things as to this particular axis are modified in this class.

Definition at line 56 of file Axis.hpp.

Public Member Functions

 Axis (double ix, double iy, double ex, double ey, double length, double imin, double imax, const AxisStyle &style=AxisStyle())
 Constructor.
 Axis (double ix, double iy, double direction, double length, double imin, double imax, const AxisStyle &style=AxisStyle())
 Constructor.
 ~Axis ()
void setPosition (double ix, double iy)
 Set the x and y position.
void setLength (double length)
 Set the length.
void setRange (double imin, double imax)
 Set the range.
void setGap (double igap)
 Set the gap (distance in plot space between ticks).
void setAngle (double angle)
 Set the angle for the axis.
void drawToFrame (const vdraw::Frame &ff)
 Draw this zxis to this frame.
bool pointFromValue (double &x, double &y, double value)
 Finds out the x, y point given a value.
bool labelPointAbove (double &x, double &y, double &rotation, double value)
 Finds out the x, y point for a label above the axis given a value.
bool labelPointBelow (double &x, double &y, double &rotation, double value)
 Finds out the x, y point for a label below the axis given a value.

Public Attributes

AxisStyle axis_style
 Axis style.

Static Public Attributes

const double RIGHT
const double UP
const double LEFT
const double DOWN
const double N
const double E
const double S
const double W
const double NORTH
const double EAST
const double SOUTH
const double WEST

Protected Member Functions

void init (double ix, double iy, double direction, double length, double imin, double imax, const AxisStyle &style)
 Initializer (the real constructor).
void fromRatio (double &x, double &y, double ratio)
 Finds out the point for the ratio along the axis line.
void axisTick (double ratio, double dist)
 Helper to start the recursive method.
void axisTickRecursive (bool draw, int depth, double ratio, double dist, double length)
 Recursively draw the axis ticks.
void drawTick (double ratio, double length)
 Draw a tick at this ratio with this length.
void fromTic (double &x1, double &y1, double &x2, double &y2, double distratio, double length)
 Get the endpoints of a tick at ratio.
void guessTickInfo (double &startpos, double &startval, double &distpos, double &distval)
 The major axis ticks will start at the the startpos ratio with value startval and at every increment of distpos there will be the previous value + distval.
bool label (double value, int direction, const vdraw::TextStyle &style)
 Put a label at this position.
bool label (const char *str, double value, int direction, const vdraw::TextStyle &style)
 Put a label at this position.
bool label (vdraw::Text &t, double value, int direction, const vdraw::TextStyle &style)
 Put a label at this position.
bool labelPoint (double &x, double &y, double &rotation, double value, int direction)
 Get the x,y position for a label and its rotation Note that rotation needs to be corrected to be right-side up.

Protected Attributes

vdraw::Frame f
 Temporary frame pointer (so we don't have to pass it to every function).
double x
 X coordinate of this axis.
double y
 Y coordinate of this axis.
double line_length
 Length of this axis.
double line_direction
 Direction is an angle in radians (for use with sin, cos).
double sindir
 Sin(line_direction).
double cosdir
 Cos(line_direction).
double sintic
 Sin(line_direction+PI/2).
double costic
 Cos(line_direction+PI/2).
double max
 For the axis, this is the data's maximum for the axis to show.
double axesMax
 For the axis, this is the data's maximum from which to draw tics.
double min
 For the axis, this is the data's minimum for the axis to show.
double axesMin
 For the axis, this is the data's minimum from which to draw tics.
double gap
 For the axis, this is the gap between tick marks.


Constructor & Destructor Documentation

Axis double  ix,
double  iy,
double  ex,
double  ey,
double  length,
double  imin,
double  imax,
const AxisStyle style = AxisStyle()
[inline]
 

Constructor.

Parameters:
ix Start x position
iy Start y position
ex End x position
ey End y position
length Length of the axis (in frame space)
imin Minimum of the axis
imax Maximum of the axis
style Style of the axis

Definition at line 87 of file Axis.hpp.

References gpstk::atan().

Axis double  ix,
double  iy,
double  direction,
double  length,
double  imin,
double  imax,
const AxisStyle style = AxisStyle()
[inline]
 

Constructor.

Parameters:
ix Start x position
iy Start y position
direction Direction the axis moves toward
length Length of the axis (in frame space)
imin Minimum of the axis
imax Maximum of the axis
style Style of the axis

Definition at line 125 of file Axis.hpp.

~Axis  )  [inline]
 

Definition at line 133 of file Axis.hpp.


Member Function Documentation

void axisTick double  ratio,
double  dist
[inline, protected]
 

Helper to start the recursive method.

Parameters:
ratio Ratio on axis line where tick is.
dist Distance between major ticks

Definition at line 255 of file Axis.hpp.

References AxisStyle::major_tick_length, and AxisStyle::tick_recursion_depth.

void axisTickRecursive bool  draw,
int  depth,
double  ratio,
double  dist,
double  length
[protected]
 

Recursively draw the axis ticks.

Parameters:
draw Whether or not to draw this tick
depth Depth that this tick is (used in recursion)
ratio Ratio on axis line where tick is. 0 <= ratio <= 1
dist Ratio distance between this tick and the next one with same depth
length Length of the tick

void drawTick double  ratio,
double  length
[protected]
 

Draw a tick at this ratio with this length.

Parameters:
ratio Where the tick is. 0 <= ratio <= 1
length Length of the tick

void drawToFrame const vdraw::Frame &  ff  ) 
 

Draw this zxis to this frame.

Parameters:
ff Pointer to frame to draw to

void fromRatio double &  x,
double &  y,
double  ratio
[inline, protected]
 

Finds out the point for the ratio along the axis line.

Parameters:
[out] x 
[out] y 
[in] ratio 

Definition at line 244 of file Axis.hpp.

void fromTic double &  x1,
double &  y1,
double &  x2,
double &  y2,
double  distratio,
double  length
[protected]
 

Get the endpoints of a tick at ratio.

Parameters:
[out] x1 Upper x output
[out] y1 Upper y output
[out] x2 Lower x output
[out] y2 Lower y output
[in] distratio Distance up axis line, ratio to length
[in] length Length of tick mark

void guessTickInfo double &  startpos,
double &  startval,
double &  distpos,
double &  distval
[protected]
 

The major axis ticks will start at the the startpos ratio with value startval and at every increment of distpos there will be the previous value + distval.

The *pos are RATIOS of the full width/height. The *val are values of the data. Note that positions that are less than 0 or greater than 1 are not themselves drawn on the axis, but can be important as the recursively smaller sub-ticks might be within the 0-1 range.

Parameters:
[out] startpos ratio position (can be <0) of start position
[out] startval value at the start position
[out] distpos ratio distance between positions
[out] distval value distance between each major tick

void init double  ix,
double  iy,
double  direction,
double  length,
double  imin,
double  imax,
const AxisStyle style
[protected]
 

Initializer (the real constructor).

Parameters:
ix Start x position
iy Start y position
direction Direction the axis moves toward
length Length of the axis (in frame space)
imin Minimum of the axis
imax Maximum of the axis
style Style of the axis

bool label vdraw::Text &  t,
double  value,
int  direction,
const vdraw::TextStyle &  style
[protected]
 

Put a label at this position.

Parameters:
t Text object for this label (will be modified)
value The value at which the label will go
direction Direction where the label is AxisStyle::(ABOVE|BELOW)
style TextStyle of the label

bool label const char *  str,
double  value,
int  direction,
const vdraw::TextStyle &  style
[protected]
 

Put a label at this position.

Parameters:
str The string for the label
value The value at which the label will go
direction Direction where the label is AxisStyle::(ABOVE|BELOW)
style TextStyle of the label

bool label double  value,
int  direction,
const vdraw::TextStyle &  style
[protected]
 

Put a label at this position.

Parameters:
value The value at which the label will go
direction Direction where the label is AxisStyle::(ABOVE|BELOW)
style TextStyle of the label

bool labelPoint double &  x,
double &  y,
double &  rotation,
double  value,
int  direction
[protected]
 

Get the x,y position for a label and its rotation Note that rotation needs to be corrected to be right-side up.

bool labelPointAbove double &  x,
double &  y,
double &  rotation,
double  value
[inline]
 

Finds out the x, y point for a label above the axis given a value.

Parameters:
[out] x 
[out] y 
[out] rotation 
[in] value 
Returns:

Definition at line 182 of file Axis.hpp.

bool labelPointBelow double &  x,
double &  y,
double &  rotation,
double  value
[inline]
 

Finds out the x, y point for a label below the axis given a value.

Parameters:
[out] x 
[out] y 
[out] rotation 
[in] value 
Returns:

Definition at line 195 of file Axis.hpp.

bool pointFromValue double &  x,
double &  y,
double  value
 

Finds out the x, y point given a value.

Parameters:
[out] x 
[out] y 
[in] value 
Returns:

void setAngle double  angle  ) 
 

Set the angle for the axis.

void setGap double  igap  )  [inline]
 

Set the gap (distance in plot space between ticks).

Definition at line 150 of file Axis.hpp.

void setLength double  length  )  [inline]
 

Set the length.

Definition at line 144 of file Axis.hpp.

void setPosition double  ix,
double  iy
[inline]
 

Set the x and y position.

Definition at line 141 of file Axis.hpp.

void setRange double  imin,
double  imax
[inline]
 

Set the range.

Definition at line 147 of file Axis.hpp.


Member Data Documentation

double axesMax [protected]
 

For the axis, this is the data's maximum from which to draw tics.

This is not necessarily within the bounds if the plot is tight.

Definition at line 376 of file Axis.hpp.

double axesMin [protected]
 

For the axis, this is the data's minimum from which to draw tics.

This is not necessarily within the bounds if the plot is tight.

Definition at line 383 of file Axis.hpp.

AxisStyle axis_style
 

Axis style.

Definition at line 201 of file Axis.hpp.

double cosdir [protected]
 

Cos(line_direction).

Definition at line 363 of file Axis.hpp.

double costic [protected]
 

Cos(line_direction+PI/2).

Definition at line 367 of file Axis.hpp.

const double DOWN [static]
 

Definition at line 62 of file Axis.hpp.

const double E [static]
 

Definition at line 64 of file Axis.hpp.

const double EAST [static]
 

Definition at line 68 of file Axis.hpp.

vdraw::Frame f [protected]
 

Temporary frame pointer (so we don't have to pass it to every function).

Definition at line 347 of file Axis.hpp.

double gap [protected]
 

For the axis, this is the gap between tick marks.

This is 0 if this is to be determined by the Axis.

Definition at line 388 of file Axis.hpp.

const double LEFT [static]
 

Definition at line 61 of file Axis.hpp.

double line_direction [protected]
 

Direction is an angle in radians (for use with sin, cos).

Definition at line 359 of file Axis.hpp.

double line_length [protected]
 

Length of this axis.

Definition at line 356 of file Axis.hpp.

double max [protected]
 

For the axis, this is the data's maximum for the axis to show.

Definition at line 373 of file Axis.hpp.

double min [protected]
 

For the axis, this is the data's minimum for the axis to show.

Definition at line 380 of file Axis.hpp.

const double N [static]
 

Definition at line 63 of file Axis.hpp.

const double NORTH [static]
 

Definition at line 67 of file Axis.hpp.

const double RIGHT [static]
 

Definition at line 59 of file Axis.hpp.

const double S [static]
 

Definition at line 65 of file Axis.hpp.

double sindir [protected]
 

Sin(line_direction).

Definition at line 361 of file Axis.hpp.

double sintic [protected]
 

Sin(line_direction+PI/2).

Definition at line 365 of file Axis.hpp.

const double SOUTH [static]
 

Definition at line 69 of file Axis.hpp.

const double UP [static]
 

Definition at line 60 of file Axis.hpp.

const double W [static]
 

Definition at line 66 of file Axis.hpp.

const double WEST [static]
 

Definition at line 70 of file Axis.hpp.

double x [protected]
 

X coordinate of this axis.

Definition at line 350 of file Axis.hpp.

double y [protected]
 

Y coordinate of this axis.

Definition at line 353 of file Axis.hpp.


The documentation for this class was generated from the following file:
Generated on Wed Feb 8 03:31:44 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1