wxFreeChart
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Axis Class Referenceabstract

Base class for all axes. More...

#include <axis.h>

Inheritance diagram for Axis:
Inheritance graph
[legend]
Collaboration diagram for Axis:
Collaboration graph
[legend]

Public Member Functions

 Axis (AXIS_LOCATION location)
 Constructs new axis. More...
 
AXIS_LOCATION GetLocation ()
 Returns axis location. More...
 
bool IsVertical ()
 Checks whether axis is vertical. More...
 
bool IsHorizontal ()
 Checks whether axis is horizontal. More...
 
void SetMargins (wxCoord marginMin, wxCoord marginMax)
 Sets minimal/maximal margins for axis. More...
 
void SetMajorGridlinePen (const wxPen &pen)
 Sets the pen to be used for drawing major gridlines. More...
 
void SetMinorGridlinePen (const wxPen &pen)
 Sets the pen to be used for drawing minor gridlines. More...
 
const wxPen & GetMajorGridlinePen ()
 Gets the pen that is currently used to draw major gridlines on this axis. More...
 
const wxPen & GetMinorGridlinePen ()
 Gets the pen that is currently used to draw minor gridlines on this axis. More...
 
size_t GetDatasetCount ()
 Returns dataset counts, linked with this axis. More...
 
DatasetGetDataset (size_t index)
 Returns dataset, linked with this axis at specified index. More...
 
void SetZoomPanMode ()
 
void SetWindowWidth (double winWidth)
 Sets window width. More...
 
double GetWindowWidth ()
 Returns window width. More...
 
void SetWindowPosition (double winPos)
 Sets window position. More...
 
double GetWindowPosition ()
 Returns window position. More...
 
void SetUseWindow (bool useWin)
 Sets whether to use window. More...
 
void SetWindow (double winPos, double winWidth)
 Sets window params (position and width). More...
 
bool IntersectsWindow (double v0, double v1)
 Checks whether line in data space intersects window. More...
 
void GetWindowBounds (double &winMin, double &winMax)
 Returns window bounds. More...
 
void AddDataset (Dataset *dataset)
 internal. More...
 
virtual void GetDataBounds (double &minValue, double &maxValue) const =0
 Returns data bounds. More...
 
virtual wxCoord GetExtent (wxDC &dc)=0
 Used to determine minimal size needed to draw axis contents, minimal width for vertical axes, minimal height for horizontal. More...
 
virtual bool IsVisible (double value)
 Checks whether data value is visible. More...
 
virtual double BoundValue (double value)
 Returns nearest boundary value. More...
 
virtual wxCoord ToGraphics (wxDC &dc, int minCoord, int gRange, double value)
 Transforms coordinate from data space to graphics space. More...
 
virtual double ToData (wxDC &dc, int minCoord, int gRange, wxCoord g)
 Transforms coordinate from graphics space to data space. More...
 
virtual bool UpdateBounds ()=0
 Performs axis bounds update after dataset/s change.
 
virtual void Draw (wxDC &dc, wxRect rc)=0
 Performs axis drawing. More...
 
virtual void DrawGridLines (wxDC &dc, wxRect rcData)=0
 Draws grid lines for axis. More...
 

Protected Member Functions

virtual bool AcceptDataset (Dataset *dataset)=0
 Checks whether dataset can be accepted by this axis. More...
 

Protected Attributes

DatasetArray m_datasets
 
wxPen m_majorGridlinePen
 
wxPen m_minorGridlinePen
 
wxCoord m_marginMin
 
wxCoord m_marginMax
 
double m_winPos
 
double m_winWidth
 
bool m_useWin
 

Friends

class Plot
 
class AxisShare
 

Detailed Description

Base class for all axes.

Axis has following attributes:

  1. Location - where axis arranged on plot, can be: AXIS_LEFT, AXIS_RIGHT, AXIS_TOP, AXIS_BOTTOM.
  2. Margins - distance from plot edges to axis labels.
  3. Window - visible subset of data. Window has width and position. Width means how much data points is visible at once, position is first data item visible.

Definition at line 39 of file axis.h.

Constructor & Destructor Documentation

Axis::Axis ( AXIS_LOCATION  location)

Constructs new axis.

Parameters
locationaxis location (cannot be changed after axis created)

Member Function Documentation

virtual bool Axis::AcceptDataset ( Dataset dataset)
protectedpure virtual

Checks whether dataset can be accepted by this axis.

Must be implemented by derivative classes. XXX: maybe remove this method later.

Parameters
datasetdataset to be checked
Returns
true - if dataset can be accepted, false overwise

Implemented in AxisShare, NumberAxis, CompDateAxis, DateAxis, and CategoryAxis.

Referenced by NumberAxis::ForceExtraMajorInterval(), DateAxis::SetDateFormat(), and CompDateAxis::SetSpanDraw().

void Axis::AddDataset ( Dataset dataset)
inline
virtual double Axis::BoundValue ( double  value)
virtual

Returns nearest boundary value.

Parameters
valueout of bounds value, for which will be returned boundary value
Returns
nearest boundary value

Reimplemented in AxisShare, and LogarithmicNumberAxis.

virtual void Axis::Draw ( wxDC &  dc,
wxRect  rc 
)
pure virtual

Performs axis drawing.

Parameters
dcdevice context
rcrectangle where to draw

Implemented in AxisShare, LabelAxis, and CompDateAxis.

Referenced by LabelAxis::GetMinorIntervalCout().

virtual void Axis::DrawGridLines ( wxDC &  dc,
wxRect  rcData 
)
pure virtual

Draws grid lines for axis.

Parameters
dcdevice context
rcdata area rectangle of plot

Implemented in AxisShare, LabelAxis, and CompDateAxis.

Referenced by LabelAxis::GetMinorIntervalCout().

virtual void Axis::GetDataBounds ( double &  minValue,
double &  maxValue 
) const
pure virtual

Returns data bounds.

Parameters
minValueoutput minimal data value
maxValueoutput maximal data value

Implemented in AxisShare, NumberAxis, CompDateAxis, DateAxis, and CategoryAxis.

Referenced by NumberAxis::ForceExtraMajorInterval(), and DateAxis::SetDateFormat().

Dataset* Axis::GetDataset ( size_t  index)

Returns dataset, linked with this axis at specified index.

Parameters
indexdataset index
Returns
dataset at index

Referenced by AxisPlot::GetAxisDataset(), and GetMinorGridlinePen().

size_t Axis::GetDatasetCount ( )

Returns dataset counts, linked with this axis.

Returns
dataset counts, linked with this axis

Referenced by GetMinorGridlinePen().

virtual wxCoord Axis::GetExtent ( wxDC &  dc)
pure virtual

Used to determine minimal size needed to draw axis contents, minimal width for vertical axes, minimal height for horizontal.

Parameters
dcdevice context
Returns
extent

Implemented in AxisShare, LabelAxis, and CompDateAxis.

Referenced by LabelAxis::GetMinorIntervalCout().

AXIS_LOCATION Axis::GetLocation ( )
inline

Returns axis location.

Returns
axis location

Definition at line 57 of file axis.h.

const wxPen& Axis::GetMajorGridlinePen ( )
inline

Gets the pen that is currently used to draw major gridlines on this axis.

Returns
The pen currently used to draw major gridlines.

Definition at line 112 of file axis.h.

const wxPen& Axis::GetMinorGridlinePen ( )
inline

Gets the pen that is currently used to draw minor gridlines on this axis.

Returns
The pen currently used to draw minor gridlines.

Definition at line 121 of file axis.h.

References GetDataset(), and GetDatasetCount().

void Axis::GetWindowBounds ( double &  winMin,
double &  winMax 
)
inline

Returns window bounds.

If window is not used, simply returns data bounds.

Parameters
winMinout for window minimal
winMaxout for window maximal

Definition at line 225 of file axis.h.

References AxisShare::GetDataBounds().

double Axis::GetWindowPosition ( )
inline

Returns window position.

Returns
window position

Definition at line 182 of file axis.h.

double Axis::GetWindowWidth ( )
inline

Returns window width.

Returns
window width

Definition at line 164 of file axis.h.

bool Axis::IntersectsWindow ( double  v0,
double  v1 
)

Checks whether line in data space intersects window.

Parameters
v0line begin in data space
v0line end in data space
Returns
true if line intersects window

Referenced by SetWindow().

bool Axis::IsHorizontal ( )
inline

Checks whether axis is horizontal.

Returns
true if axis is horizontal, false - overwise

Definition at line 75 of file axis.h.

References IsVertical(), and SetMargins().

bool Axis::IsVertical ( )
inline

Checks whether axis is vertical.

Returns
true if axis is vertical, false - overwise

Definition at line 66 of file axis.h.

Referenced by IsHorizontal().

virtual bool Axis::IsVisible ( double  value)
virtual

Checks whether data value is visible.

Parameters
valuevalue in data space
Returns
true if data value is visible

Reimplemented in AxisShare, and LogarithmicNumberAxis.

void Axis::SetMajorGridlinePen ( const wxPen &  pen)
inline

Sets the pen to be used for drawing major gridlines.

A major gridline is a gridline that is associated with a major axis label.

Parameters
majorGridlinePenThe pen to be used to draw major gridlines on this axis.

Definition at line 93 of file axis.h.

void Axis::SetMargins ( wxCoord  marginMin,
wxCoord  marginMax 
)

Sets minimal/maximal margins for axis.

Eg bottom/top for vertical axes, left/right for horizontal.

Parameters
marginMinnew minimal margin
marginMaxnew maximal margin

Referenced by IsHorizontal().

void Axis::SetMinorGridlinePen ( const wxPen &  pen)
inline

Sets the pen to be used for drawing minor gridlines.

A minor gridline is a gridline that is associated with a minor axis label, i.e. any label that is not a major axis label.

Parameters
minorGridlinePenThe pen to be used to draw minor gridlines on this axis.

Definition at line 103 of file axis.h.

void Axis::SetUseWindow ( bool  useWin)
inline

Sets whether to use window.

Parameters
useWintrue to use window

Definition at line 191 of file axis.h.

void Axis::SetWindow ( double  winPos,
double  winWidth 
)
inline

Sets window params (position and width).

Window params are in data space.

Parameters
winPosnew window position
winWidthnew window width

Definition at line 203 of file axis.h.

References IntersectsWindow().

Referenced by SetWindowPosition(), and SetWindowWidth().

void Axis::SetWindowPosition ( double  winPos)
inline

Sets window position.

Window position is in data space.

Parameters
winPosnew window position

Definition at line 173 of file axis.h.

References SetWindow().

void Axis::SetWindowWidth ( double  winWidth)
inline

Sets window width.

Window width is in data space.

Parameters
winWidthnew window width

Definition at line 155 of file axis.h.

References SetWindow().

virtual double Axis::ToData ( wxDC &  dc,
int  minCoord,
int  gRange,
wxCoord  g 
)
virtual

Transforms coordinate from graphics space to data space.

Parameters
dcdevice context
minCoordminimal graphics space coordinate
gRangegraphics space range
valuevalue in data space
Returns
coordinate in data space

Reimplemented in AxisShare, LogarithmicNumberAxis, and CompDateAxis.

virtual wxCoord Axis::ToGraphics ( wxDC &  dc,
int  minCoord,
int  gRange,
double  value 
)
virtual

Transforms coordinate from data space to graphics space.

Parameters
dcdevice context
minCoordminimal graphics space coordinate
gRangegraphics space range
valuevalue in data space
Returns
value in graphics space

Reimplemented in AxisShare, CompDateAxis, and LogarithmicNumberAxis.


The documentation for this class was generated from the following file: