MathPlot
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mpScaleY Class Reference

Plot layer implementing a y-scale ruler. More...

#include <mathplot.h>

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

Public Member Functions

 mpScaleY (const wxString &name=_T("Y"), int flags=mpALIGN_CENTERY, bool grids=false, mpOptional_uint yAxisID=-1, mpLabelType labelType=mpLabel_AUTO)
 Full constructor. More...
 
void UpdateAxisWidth (mpWindow &w)
 Recalculate the axis width based on the label and name text sizes. More...
 
int GetAxisWidth ()
 
bool IsLeftAxis ()
 
bool IsRightAxis ()
 
bool IsInside (wxCoord xPixel)
 
- Public Member Functions inherited from mpScale
 mpScale (const wxString &name, int flags, bool grids, mpLabelType labelType=mpLabel_AUTO, mpOptional_uint axisID=-1)
 Full constructor. More...
 
virtual bool HasBBox ()
 Check whether this layer has a bounding box. More...
 
int GetAxisID (void)
 Return the ID of the Axis. More...
 
void SetAxisID (unsigned int yAxisID)
 Set an ID to the axis. More...
 
void ShowTicks (bool ticks)
 Set axis ticks. More...
 
bool GetShowTicks () const
 Get axis ticks. More...
 
void ShowGrids (bool grids)
 Set axis grids. More...
 
bool GetShowGrids () const
 Get axis grids. More...
 
void SetLabelFormat (const wxString &format, bool updateLabelMode=false)
 Set axis Label format (used for mpLabel_AUTO draw mode). More...
 
mpLabelType GetLabelMode () const
 Get axis label view mode. More...
 
void SetLabelMode (mpLabelType mode, unsigned int time_conv=0x20)
 Set axis label view mode. More...
 
const wxString & GetLabelFormat () const
 Get axis Label format (used for mpLabel_AUTO draw mode). More...
 
void SetGridPen (const wxPen &pen)
 Set grid pen. More...
 
const wxPen & GetGridPen () const
 Get pen set for this axis. More...
 
void SetAuto (bool automaticScalingIsEnabled)
 Enable/Disable automatic scaling for this axis. More...
 
bool GetAuto () const
 Is automatic scaling enabled for this axis? More...
 
void SetMinScale (double min)
 Set the minimum of the scale range when we are in automatic mode. More...
 
double GetMinScale () const
 Get the minimum of the scale range when we are in automatic mode. More...
 
void SetMaxScale (double max)
 Set the maximum of the scale range when we are in automatic mode. More...
 
double GetMaxScale () const
 Get the maximum of the scale range when we are in automatic mode. More...
 
void SetScale (double min, double max)
 Set the minimum and maximum of the scale range when we are in automatic mode. More...
 
void GetScale (double *min, double *max) const
 Get the minimum and maximum of the scale range when we are in automatic mode. More...
 
void SetScale (mpRange< double > range)
 Set the minimum and maximum of the scale range when we are in automatic mode. More...
 
mpRange< double > GetScale () const
 Get the minimum and maximum of the scale range when we are in automatic mode. More...
 
virtual bool IsLogAxis ()
 Get if we are in Logarithmic mode. More...
 
virtual void SetLogAxis (bool log)
 Set Logarithmic mode. More...
 
- Public Member Functions inherited from mpLayer
 mpLayer (mpLayerType layerType)
 The base class of all layer objects. More...
 
void SetWindow (mpWindow &w)
 Set the wxWindow handle.
 
mpLayerType GetLayerType () const
 Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc, this method returns the right value. More...
 
int GetLayerSubType () const
 Get layer subtype: each layer type can have several flavors. More...
 
virtual bool IsLayerType (mpLayerType typeOfInterest, int *subtype)
 Set the layer's subtype in caller variable, and return true if the layer is of type "typeOfInterest". More...
 
virtual double GetMinX ()
 Get inclusive left border of bounding box. More...
 
virtual double GetMaxX ()
 Get inclusive right border of bounding box. More...
 
virtual double GetMinY ()
 Get inclusive bottom border of bounding box. More...
 
virtual double GetMaxY ()
 Get inclusive top border of bounding box. More...
 
void Plot (wxDC &dc, mpWindow &w)
 Plot given view of layer to the given device context. More...
 
void SetName (const wxString &name)
 Set layer name. More...
 
const wxString & GetName () const
 Get layer name. More...
 
void SetFont (const wxFont &font)
 Set layer font. More...
 
const wxFont & GetFont () const
 Get font set for this layer. More...
 
void SetFontColour (const wxColour &colour)
 Set layer font foreground colour. More...
 
const wxColour & GetFontColour () const
 Get font foreground colour set for this layer. More...
 
void SetPen (const wxPen &pen)
 Set layer pen. More...
 
const wxPen & GetPen () const
 Get pen set for this layer. More...
 
void SetBrush (const wxBrush &brush)
 Set layer brush. More...
 
const wxBrush & GetBrush () const
 Get brush set for this layer. More...
 
void SetShowName (bool show)
 Set Name visibility. More...
 
bool GetShowName () const
 Get Name visibility. More...
 
void SetDrawOutsideMargins (bool drawModeOutside)
 Set Draw mode: inside or outside margins. More...
 
bool GetDrawOutsideMargins () const
 Get Draw mode: inside or outside margins. More...
 
wxBitmap GetColourSquare (int side=16)
 Get a small square bitmap filled with the colour of the pen used in the layer. More...
 
bool IsVisible () const
 Checks whether the layer is visible or not. More...
 
virtual void SetVisible (bool show)
 Sets layer visibility. More...
 
bool IsTractable () const
 Checks whether the layer is tractable or not. More...
 
virtual void SetTractable (bool track)
 Sets layer tractability. More...
 
void SetAlign (int align)
 Set X/Y alignment. More...
 
int GetAlign () const
 Get X/Y alignment. More...
 
void SetCanDelete (bool canDelete)
 Define what we do with the object associated with the layer when we delete the layer. More...
 
bool GetCanDelete (void) const
 Retreive what we do with the object associated with the layer when we delete the layer. More...
 
mpLayerZOrder GetZIndex (void) const
 Get the ZIndex of the plot. More...
 

Protected Member Functions

virtual void DoPlot (wxDC &dc, mpWindow &w)
 Layer plot handler. More...
 
virtual int GetOrigin (mpWindow &w)
 Get the origin of axis and initialize the plot boundaries.
 
virtual void DrawScaleName (wxDC &dc, mpWindow &w, int origin, int labelSize)
 Draw the name of the scale
This function is virtual and need to be overloaded in child class. More...
 
 wxDECLARE_DYNAMIC_CLASS (mpScaleY)
 
- Protected Member Functions inherited from mpScale
double GetStep (double scale, int minLabelSpacing)
 Calculate a 'nice' label step size for the given dataset and desired pixel spacing. More...
 
wxString FormatLabelValue (double value, double maxAxisValue, double step)
 Formats a label value to a string. More...
 
wxString FormatLogValue (double n)
 Formats a value to a string used on a log axis. More...
 
int GetLabelWidth (double value, wxDC &dc, double maxAxisValue, double step)
 Get label text width for a given value. More...
 
bool UseScientific (double maxAxisValue)
 Checks if scientific notation shall be used on the labels. More...
 
int GetSignificantDigits (double step, double maxAxisValue)
 Get number of significant digits to be used in scientific notation. More...
 
int GetDecimalDigits (double step)
 Get number of decimal digits to be used in decimal notation. More...
 
 wxDECLARE_DYNAMIC_CLASS (mpScale)
 
- Protected Member Functions inherited from mpLayer
void UpdateContext (wxDC &dc) const
 Initialize the context.
 
virtual bool DoBeforePlot ()
 If we need to do something before plot like reinitialize some parameters ... More...
 
void CheckLog (double *x, double *y, int yAxisID)
 Test if we are in log axis and if true return the log of the values. More...
 

Protected Attributes

int m_axisWidth
 
int m_xPos
 
- Protected Attributes inherited from mpScale
int m_axisID
 Unique ID that identify this axis. Default -1 mean that axis is not used.
 
wxPen m_gridpen
 Grid's pen. Default Colour = LIGHT_GREY, width = 1, style = wxPENSTYLE_DOT.
 
bool m_ticks
 Flag to show ticks. Default true.
 
bool m_grids
 Flag to show grids. Default false.
 
bool m_auto
 Flag to autosize grids. Default true.
 
mpRange< double > m_axisRange
 Range axis values when autosize is false.
 
mpLabelType m_labelType
 Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours, minutes, seconds.
 
unsigned int m_timeConv
 Selects if time has to be converted to local time or not.
 
wxString m_labelFormat
 Format string used to print labels.
 
bool m_isLog
 Is the axis a log axis ?
 
- Protected Attributes inherited from mpLayer
const mpLayerType m_type
 Layer type mpLAYER_*.
 
mpWindowm_win
 The wxWindow handle.
 
int m_subtype
 Layer sub type, set in constructors.
 
wxFont m_font
 Layer's font.
 
wxColour m_fontcolour
 Layer's font foreground colour.
 
wxPen m_pen
 Layer's pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
 
wxBrush m_brush
 Layer's brush. Default wxTRANSPARENT_BRUSH.
 
wxString m_name
 Layer's name.
 
bool m_showName
 States whether the name of the layer must be shown. Default : false.
 
bool m_drawOutsideMargins
 Select if the layer should draw only inside margins or over all DC. Default : false.
 
bool m_visible
 Toggles layer visibility. Default : true.
 
bool m_tractable
 Is the layer tractable.
 
int m_flags
 Holds label alignment. Default : mpALIGN_SW for series and mpALIGN_CENTER for scale.
 
mpRect m_plotBoundaries
 The boundaries for plotting curve calculated by mpWindow.
 
bool m_CanDelete
 Is the layer can be deleted.
 
mpLayerZOrder m_ZIndex
 The index in Z-Order to draw the layer.
 

Additional Inherited Members

- Static Protected Attributes inherited from mpScale
static const wxCoord kTickSize = 4
 Length of tick line.
 
static const wxCoord kAxisExtraSpace = 6
 Extra space for axis to make it look good.
 

Detailed Description

Plot layer implementing a y-scale ruler.

If align is set to mpALIGN_CENTER, the ruler is fixed at X=0 in the coordinate system. If the align is set to mpALIGN_TOP or mpALIGN_BOTTOM, the axis is always drawn respectively at top or bottom of the window. A label is plotted at the top-right hand of the ruler. The scale numbering automatically adjusts to view and zoom factor.

Constructor & Destructor Documentation

◆ mpScaleY()

mpScaleY::mpScaleY ( const wxString &  name = _T("Y"),
int  flags = mpALIGN_CENTERY,
bool  grids = false,
mpOptional_uint  yAxisID = -1,
mpLabelType  labelType = mpLabel_AUTO 
)
inline

Full constructor.

Parameters
nameLabel to plot by the ruler
flagsSet the position of the scale with respect to the window.
gridsShow grid or not. Give false (default) for not drawing the grid
yAxisIDoptional yAxisID (default 0)
labelTypeoptional type of the label (default mpLabel_AUTO)
See also
mpLabelType

Member Function Documentation

◆ DoPlot()

void mpScaleY::DoPlot ( wxDC &  dc,
mpWindow w 
)
protectedvirtual

Layer plot handler.

This implementation will plot the ruler adjusted to the visible area.

Implements mpLayer.

◆ DrawScaleName()

void mpScaleY::DrawScaleName ( wxDC &  dc,
mpWindow w,
int  origin,
int  labelSize 
)
protectedvirtual

Draw the name of the scale
This function is virtual and need to be overloaded in child class.

Parameters
dcCurrent dc
wCurrent window
originthe origin of the axis
labelSizethe size of the label

Implements mpScale.

◆ UpdateAxisWidth()

void mpScaleY::UpdateAxisWidth ( mpWindow w)

Recalculate the axis width based on the label and name text sizes.

Parameters
wCurrent window used as canvas