wxMathPlot
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mpInfoCoords Class Reference

Implements an overlay box which shows the mouse coordinates in plot units. More...

#include <mathplot.h>

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

Public Types

enum  infoCoordType { infoCoord_axis, infoCoord_closestSeries, infoCoord_allSeries }
 Type of info coordinates to be displayed (axis, closest series, or all series) More...
 

Public Member Functions

 mpInfoCoords ()
 Default constructor.
 
 mpInfoCoords (mpLocation location)
 Limited constructor.
 
 mpInfoCoords (wxPoint pos, const wxBrush &brush= *wxTRANSPARENT_BRUSH, mpLocation location=mpMarginUser)
 Complete constructor, setting initial rectangle and background brush. More...
 
 ~mpInfoCoords () override
 Default destructor.
 
void UpdateInfo (mpWindow &w, wxEvent &event) override
 Update the content of the info box. More...
 
void ErasePlot (wxDC &, mpWindow &) override
 Just delete the bitmap of the info. More...
 
void Show (const bool show)
 Set if info coords shall be shown or hidden. More...
 
bool IsShown () const
 Get shown status. More...
 
bool ShouldBeShown (const wxRect plotArea, const wxPoint mousePos) const
 Check conditions if info coords shall be shown or not. More...
 
void SetLabelMode (const mpLabelType mode, const unsigned int time_conv=MP_X_RAWTIME)
 Set X axis label view mode. More...
 
void SetSeriesCoord (const bool show)
 Set the series coordinates of the mouse position (if tractable set)
 
void SetInfoCoordType (const infoCoordType type)
 Set the type of info coordinates to be displayed (axis, closest series, or all series) More...
 
infoCoordType GetInfoCoordType () const
 Get the type of info coordinates to be displayed (axis, closest series, or all series) More...
 
virtual wxString GetInfoCoordsText (mpWindow &w, double xVal, std::unordered_map< int, double > yValList)
 Get string describing mouse position. More...
 
void DrawContent (wxDC &dc, mpWindow &w)
 Draw the content of info coords to plot. More...
 
- Public Member Functions inherited from mpInfoLayer
 mpInfoLayer ()
 Default constructor. More...
 
 mpInfoLayer (wxPoint pos, const wxBrush &brush= *wxTRANSPARENT_BRUSH, mpLocation location=mpMarginUser)
 Complete constructor. More...
 
 ~mpInfoLayer () override
 Destructor.
 
void SetVisible (bool show) override
 Sets layer visibility. More...
 
bool HasBBox () override
 mpInfoLayer has not bounding box. More...
 
virtual bool Inside (const wxPoint &point)
 Is given point inside the info box rectangle? More...
 
virtual void Move (wxPoint delta, mpWindow &w)
 Move the layer rectangle by given pixel deltas. More...
 
virtual void UpdateReference ()
 Update the rectangle reference point. More...
 
wxPoint GetPosition () const
 Get the position of the upper left corner of the box (in pixels) More...
 
void SetInitialPosition (const wxPoint pos)
 Set the position in percent of the upper left corner of the box. More...
 
wxSize GetSize () const
 Get the size of the box (in pixels) More...
 
const wxRect & GetRectangle () const
 Get the current rectangle coordinates. More...
 
void SetLocation (const mpLocation location)
 Set the location of the mpInfoLayer box.
 
mpLocation GetLocation () const
 Return the location of the mpInfoLayer box. 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...
 
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
 Plot method. More...
 
- Protected Member Functions inherited from mpInfoLayer
void SetInfoRectangle (mpWindow &w, int width=0, int height=0)
 Compute the dimensions and position of the mpInfoLayer rectangle.
 
- 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

bool m_show
 Indicates if magnet shall be shown in plot.
 
wxString m_content
 string holding the coordinates to be drawn.
 
mpLabelType m_labelType
 Label formatting mode used for the X coordinate display.
 
unsigned int m_timeConv
 Time conversion mode used when formatting date/time X values.
 
wxCoord m_mouseX
 Last mouse X position in window pixel coordinates.
 
wxCoord m_mouseY
 Last mouse Y position in window pixel coordinates.
 
infoCoordType m_infoCoordType
 Type of info coordinates to be displayed (axis, closest series, or all series).
 
std::vector< wxColor > m_seriesColors
 Colors of the series in the order they were added to the mpWindow.
 
- Protected Attributes inherited from mpInfoLayer
wxRect m_dim
 The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method).
 
wxBitmap * m_info_bmp
 The bitmap that contain the info.
 
wxPoint m_reference
 Holds the reference point for movements.
 
double m_relX
 Box X position relative window, used to rescale the info box position when the window is resized.
 
double m_relY
 Box Y position relative window, used to rescale the info box position when the window is resized.
 
mpLocation m_location
 Location of the box in the margin. Default mpMarginNone = use coordinates.
 
- 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.
 

Detailed Description

Implements an overlay box which shows the mouse coordinates in plot units.

When mouse is moved over the mpWindow with an active mpInfoCoords layer, the mouse coordinates (in mpWindow units, not pixels) are continuously reported inside the layer box.

Member Enumeration Documentation

◆ infoCoordType

Type of info coordinates to be displayed (axis, closest series, or all series)

Enumerator
infoCoord_axis 

Show axis coordinates at mouse position.

infoCoord_closestSeries 

Show the X and Y value of the closest series.

infoCoord_allSeries 

Show the Y-values of all series that intersect with a vertical line drawn at the mouse position.

Constructor & Destructor Documentation

◆ mpInfoCoords()

mpInfoCoords::mpInfoCoords ( wxPoint  pos,
const wxBrush &  brush = *wxTRANSPARENT_BRUSH,
mpLocation  location = mpMarginUser 
)

Complete constructor, setting initial rectangle and background brush.

Parameters
posThe initial position in percent of the rectangle.
brushThe wxBrush to be used for box background: default is transparent
locationto place in the margin or free

Member Function Documentation

◆ DoPlot()

void mpInfoCoords::DoPlot ( wxDC &  dc,
mpWindow &  w 
)
overrideprotectedvirtual

Plot method.

Parameters
dcthe device content where to plot
wthe window to plot
See also
mpLayer::Plot

Reimplemented from mpInfoLayer.

◆ DrawContent()

void mpInfoCoords::DrawContent ( wxDC &  dc,
mpWindow &  w 
)

Draw the content of info coords to plot.

Parameters
dcthe device context where to plot
wthe window to plot

◆ ErasePlot()

void mpInfoCoords::ErasePlot ( wxDC &  ,
mpWindow &   
)
inlineoverridevirtual

Just delete the bitmap of the info.

Not used since background bitmap is no longer needed Just keep to not break compatability with overridden functions

Reimplemented from mpInfoLayer.

◆ GetInfoCoordsText()

wxString mpInfoCoords::GetInfoCoordsText ( mpWindow &  w,
double  xVal,
std::unordered_map< int, double >  yValList 
)
virtual

Get string describing mouse position.

Override in your derived class to customize mpInfoCoords display.

Parameters
wparent mpWindow from which to obtain information
xValthe X mouse position
yValListValues of Y. If m_series_coord is used, only one value of the closest serie is supplied, otherwise mouse position for each Y-axis is supplied

◆ GetInfoCoordType()

infoCoordType mpInfoCoords::GetInfoCoordType ( ) const
inline

Get the type of info coordinates to be displayed (axis, closest series, or all series)

Returns
The type of info coordinates to be displayed (axis, closest series, or all series)

◆ IsShown()

bool mpInfoCoords::IsShown ( ) const
inline

Get shown status.

Returns
Indicate if shall be shown

◆ SetInfoCoordType()

void mpInfoCoords::SetInfoCoordType ( const infoCoordType  type)
inline

Set the type of info coordinates to be displayed (axis, closest series, or all series)

Parameters
typeThe type of info coordinates to be displayed (axis, closest series, or all series)

◆ SetLabelMode()

void mpInfoCoords::SetLabelMode ( const mpLabelType  mode,
const unsigned int  time_conv = MP_X_RAWTIME 
)
inline

Set X axis label view mode.

Parameters
modempLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours, minutes, seconds.
time_convset time format Local or UTC

◆ ShouldBeShown()

bool mpInfoCoords::ShouldBeShown ( const wxRect  plotArea,
const wxPoint  mousePos 
) const
inline

Check conditions if info coords shall be shown or not.

Parameters
plotAreaArea where info coors is allowed to be rendered
mousePosPosition of mouse in plot window
Returns
Indicate if shall be shown

◆ Show()

void mpInfoCoords::Show ( const bool  show)
inline

Set if info coords shall be shown or hidden.

Parameters
showSet if shall be shown

◆ UpdateInfo()

void mpInfoCoords::UpdateInfo ( mpWindow &  w,
wxEvent &  event 
)
overridevirtual

Update the content of the info box.

Used to update coordinates.

Parameters
wparent mpWindow from which to obtain information
eventThe event which called the update.

Reimplemented from mpInfoLayer.


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