wxMathPlot
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"), const int flags=mpALIGN_CENTERY, const bool grids=false, const mpOptional_uint yAxisID=std::nullopt, const 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 () const
 Get the reserved width of the Y axis in pixels.
 
bool IsLeftAxis () const
 Return true if this Y axis is aligned to the left side.
 
bool IsRightAxis () const
 Return true if this Y axis is aligned to the right side.
 
bool IsInside (const wxCoord xPixel) const
 Return true if the given X pixel lies within this Y-axis drawing area.
 
- Public Member Functions inherited from mpScale
 mpScale (const wxString &name, int flags, bool grids, mpLabelType labelType=mpLabel_AUTO, mpOptional_uint axisID=std::nullopt)
 Full constructor. More...
 
bool HasBBox () override
 Check whether this layer has a bounding box. More...
 
int GetAxisID (void) const
 Return the ID of the Axis. More...
 
void SetAxisID (const unsigned int yAxisID)
 Set an ID to the axis. More...
 
void ShowTicks (const bool ticks)
 Set axis ticks. More...
 
bool GetShowTicks () const
 Get axis ticks. More...
 
void ShowGrids (const bool grids)
 Set axis grids. More...
 
bool GetShowGrids () const
 Get axis grids. More...
 
void SetLabelFormat (const wxString &format, const 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 (const mpLabelType mode, const unsigned int time_conv=MP_X_RAWTIME)
 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 (const bool automaticScalingIsEnabled)
 Enable/Disable automatic scaling for this axis. More...
 
bool GetAuto () const
 Is automatic scaling enabled for this axis? More...
 
void SetMinScale (const 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 (const 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 (const double min, const 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 (const 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...
 
void SetHovering (const bool hover)
 Set if axis shall be highlighted when a series is dragged over it. More...
 
virtual bool IsLogAxis ()
 Get if we are in Logarithmic mode. More...
 
virtual void SetLogAxis (const bool log)
 Set Logarithmic mode. More...
 
void SetCoordIsAlwaysVisible (const bool alwaysVisible)
 Set the visibility of the mouse coordinates in the info coordinates despite the visibility of the axis. More...
 
bool GetCoordIsAlwaysVisible () const
 Get the visibility of the mouse coordinates in the info coordinates. More...
 
wxString FormatLabelValue (double value, const mpScaleConstraints &constraints)
 Formats a label value to a string Use m_ScaleConstraints, so this structure must be up to date. 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. More...
 
int GetLayerSubType () const
 Get layer subtype: each layer type can have several flavors. More...
 
virtual bool IsLayerType (const 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...
 
void SetBrush (const wxColour &colour, enum wxBrushStyle style=wxBRUSHSTYLE_SOLID)
 Set layer brush. More...
 
const wxBrush & GetBrush () const
 Get brush set for this layer. More...
 
void SetShowName (const bool show)
 Set Name visibility. More...
 
bool GetShowName () const
 Get Name visibility. More...
 
void SetDrawOutsideMargins (const 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
 Is this layer visible? More...
 
virtual void SetVisible (const bool show)
 Sets layer visibility. More...
 
bool IsTractable () const
 Checks whether the layer is tractable or not. More...
 
virtual void SetTractable (const bool track)
 Sets layer tractability. More...
 
void SetAlign (const int align)
 Set X/Y alignment. More...
 
int GetAlign () const
 Get X/Y alignment. More...
 
void SetCanDelete (const bool canDelete)
 Set 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

void DoPlot (wxDC &dc, mpWindow &w) override
 Layer plot handler. More...
 
int GetOrigin (mpWindow &w) override
 Get the origin of axis and initialize the plot boundaries.
 
void DrawScaleName (wxDC &dc, mpWindow &w, int origin, int maxLabelWidth) override
 Draw the name of the scale
This function is virtual and need to be overloaded in child class. More...
 
- Protected Member Functions inherited from mpScale
int GetLabelWidth (double value, wxDC &dc, const mpScaleConstraints &constraints)
 Get label text width for a given value. More...
 
- 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
 Reserved width for this Y axis including labels, in pixels.
 
int m_xPos
 Leftmost X pixel occupied by this axis (starting point).
 
- 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 ?
 
bool m_hover = false
 Indicate if axis is hovered by mouse while dragging a series onto it.
 
bool m_CoordIsAlwaysVisible
 If true, the mouse coordinates is visible in the info coordinates despite the visibility of the axis. Default true.
 
- Protected Attributes inherited from mpLayer
const mpLayerType m_type
 Layer type mpLAYER_*.
 
mpWindow * m_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 Public Member Functions inherited from mpScale
static mpScaleConstraints ComputeScaleConstraints (double step, double maxAxisValue)
 Compute the scale constraints for the given step size and axis range. More...
 
- Static Protected Member Functions inherited from mpScale
static double GetStep (double scale, int minLabelSpacing)
 Calculate a 'nice' label step size for the given dataset and desired pixel spacing. More...
 
static wxString FormatLogValue (double n)
 Formats a value to a string used on a log axis. More...
 
static bool UseScientific (double maxAxisValue)
 Checks if scientific notation shall be used on the labels. More...
 
static int GetSignificantDigits (double step, double maxAxisValue)
 Get number of significant digits to be used in scientific notation. More...
 
static int GetDecimalDigits (double step)
 Get number of decimal digits to be used in decimal notation. More...
 
- Static Protected Attributes inherited from mpScale
static constexpr wxCoord kTickSize = 4
 Length of tick line.
 
static constexpr wxCoord kYAxisExtraSpace = 6
 Extra space for Y-axis to make it look good.
 
static constexpr wxCoord kYAxisTitleSpace = 2
 Extra space for Y-axis title to make it look good.
 
static constexpr wxCoord kYAxisLabelSpace = 2
 Extra space for Y-axis tick labels to make it look good.
 
static constexpr wxCoord kXAxisTitleSpace = 3
 Extra space for X-axis title to make it look good.
 

Detailed Description

Plot layer implementing a y-scale ruler.

If align is set to mpALIGN_CENTERY, 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"),
const int  flags = mpALIGN_CENTERY,
const bool  grids = false,
const mpOptional_uint  yAxisID = std::nullopt,
const 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 
)
overrideprotectedvirtual

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 
)
overrideprotectedvirtual

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

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