MathPlot
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MathPlot::mpLayer Class Referenceabstract

Plot layer, abstract base class. More...

#include <mathplot.h>

Inheritance diagram for MathPlot::mpLayer:
Inheritance graph
[legend]
Collaboration diagram for MathPlot::mpLayer:
Collaboration graph
[legend]

Public Member Functions

 mpLayer (mpLayerType layerType)
 
void SetWindow (mpWindow &w)
 Set the wxWindow handle.
 
virtual bool HasBBox ()
 Check whether this layer has a bounding box. More...
 
virtual void GetBBox (mpFloatRect *m_bound)
 Return the bounding box, ie GetMinX(), GetMaxX(), GetMinY() and GetMaxY() of this mpLayer Here we don't use extra Y2 values.
 
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 type, int *sub_type)
 Specifies that if the layer is of type "type". 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)
 Set CanDelete for plot. More...
 
bool GetCanDelete (void) const
 Get CanDelete for plot. More...
 
mpLayerZOrder GetZIndex (void) const
 Get the ZIndex of the plot. More...
 

Protected Member Functions

void UpdateContext (wxDC &dc) const
 Initialize the context.
 
virtual void DoPlot (wxDC &dc, mpWindow &w)=0
 Pure virtual method to plot the layer. More...
 
virtual void DoBeforePlot ()
 If we need to do something before plot like reinitialize some parameters ...
 
void CheckLog (double *x, double *y)
 Test if we are in log axis and if true return the log of the values.
 

Protected Attributes

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_NE.
 
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

Plot layer, abstract base class.

Any number of mpLayer implementations can be attached to mpWindow. Examples for mpLayer implementations are function graphs, or scale rulers.

For convenience mpLayer defines a name, a font (wxFont), a pen (wxPen), and a continuity property (bool) as class members. The default values at constructor are the default font, a black pen, and continuity set to false (draw separate points). These may or may not be used by implementations.

Member Function Documentation

◆ DoPlot()

virtual void MathPlot::mpLayer::DoPlot ( wxDC &  dc,
mpWindow w 
)
protectedpure virtual

◆ GetAlign()

int MathPlot::mpLayer::GetAlign ( ) const
inline

Get X/Y alignment.

Returns
align alignment

◆ GetBrush()

const wxBrush& MathPlot::mpLayer::GetBrush ( ) const
inline

Get brush set for this layer.

Returns
brush.

◆ GetCanDelete()

bool MathPlot::mpLayer::GetCanDelete ( void  ) const
inline

Get CanDelete for plot.

Returns
CanDelete

◆ GetColourSquare()

wxBitmap mpLayer::GetColourSquare ( int  side = 16)

Get a small square bitmap filled with the colour of the pen used in the layer.

Useful to create legends or similar reference to the layers.

Parameters
sideside length in pixels
Returns
a wxBitmap filled with layer's colour

◆ GetDrawOutsideMargins()

bool MathPlot::mpLayer::GetDrawOutsideMargins ( ) const
inline

Get Draw mode: inside or outside margins.

Returns
The draw mode

◆ GetFont()

const wxFont& MathPlot::mpLayer::GetFont ( ) const
inline

Get font set for this layer.

Returns
Font

◆ GetFontColour()

const wxColour& MathPlot::mpLayer::GetFontColour ( ) const
inline

Get font foreground colour set for this layer.

Returns
colour

◆ GetLayerSubType()

int MathPlot::mpLayer::GetLayerSubType ( ) const
inline

Get layer subtype: each layer type can have several flavors.

Returns
An integer indicating layer subtype
See also
mpLayer::GetLayerSubType

◆ GetLayerType()

mpLayerType MathPlot::mpLayer::GetLayerType ( ) const
inline

Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc, this method returns the right value.

Returns
An integer indicating layer type
See also
mpLayer::GetLayerType

◆ GetMaxX()

virtual double MathPlot::mpLayer::GetMaxX ( )
inlinevirtual

Get inclusive right border of bounding box.

Returns
Value

Reimplemented in MathPlot::mpBitmapLayer, MathPlot::mpMovableObject, MathPlot::mpPieChart, MathPlot::mpBarChart, MathPlot::mpFXYVector, MyLissajoux, and MyCOSinverse.

◆ GetMaxY()

virtual double MathPlot::mpLayer::GetMaxY ( )
inlinevirtual

Get inclusive top border of bounding box.

Returns
Value

Reimplemented in MathPlot::mpBitmapLayer, MathPlot::mpMovableObject, MathPlot::mpPieChart, MathPlot::mpBarChart, MathPlot::mpFXYVector, MyLissajoux, MyPower, MyFunction, and MySIN.

◆ GetMinX()

virtual double MathPlot::mpLayer::GetMinX ( )
inlinevirtual

Get inclusive left border of bounding box.

Returns
Value

Reimplemented in MathPlot::mpBitmapLayer, MathPlot::mpMovableObject, MathPlot::mpPieChart, MathPlot::mpBarChart, MathPlot::mpFXYVector, MyLissajoux, and MyCOSinverse.

◆ GetMinY()

virtual double MathPlot::mpLayer::GetMinY ( )
inlinevirtual

Get inclusive bottom border of bounding box.

Returns
Value

Reimplemented in MathPlot::mpBitmapLayer, MathPlot::mpMovableObject, MathPlot::mpPieChart, MathPlot::mpBarChart, MathPlot::mpFXYVector, MyLissajoux, MyPower, MyFunction, and MySIN.

◆ GetName()

const wxString& MathPlot::mpLayer::GetName ( ) const
inline

Get layer name.

Returns
Name

◆ GetPen()

const wxPen& MathPlot::mpLayer::GetPen ( ) const
inline

Get pen set for this layer.

Returns
Pen

◆ GetShowName()

bool MathPlot::mpLayer::GetShowName ( ) const
inline

Get Name visibility.

Returns
true if visible

◆ GetZIndex()

mpLayerZOrder MathPlot::mpLayer::GetZIndex ( void  ) const
inline

Get the ZIndex of the plot.

Returns
m_ZIndex

◆ HasBBox()

virtual bool MathPlot::mpLayer::HasBBox ( )
inlinevirtual

Check whether this layer has a bounding box.

The default implementation returns TRUE. Override and return FALSE if your mpLayer implementation should be ignored by the calculation of the global bounding box for all layers in a mpWindow.

Return values
TRUEHas bounding box
FALSEHas not bounding box

Reimplemented in MathPlot::mpMovableObject, MathPlot::mpText, MathPlot::mpScale, MathPlot::mpChart, MathPlot::mpLine, and MathPlot::mpInfoLayer.

◆ IsLayerType()

virtual bool MathPlot::mpLayer::IsLayerType ( mpLayerType  type,
int *  sub_type 
)
inlinevirtual

Specifies that if the layer is of type "type".

if true then get the subtype

Parameters
type
subtype
See also
mpLayer::IsLayerType

◆ IsTractable()

bool MathPlot::mpLayer::IsTractable ( ) const
inline

Checks whether the layer is tractable or not.

Returns
true if visible

◆ IsVisible()

bool MathPlot::mpLayer::IsVisible ( ) const
inline

Checks whether the layer is visible or not.

Returns
true if visible

◆ Plot()

void mpLayer::Plot ( wxDC &  dc,
mpWindow w 
)

Plot given view of layer to the given device context.

An implementation of this function has to transform layer coordinates to wxDC coordinates based on the view parameters retrievable from the mpWindow passed in w. Note that the public methods of mpWindow: x2p,y2p and p2x,p2y are already provided which transform layer coordinates to DC pixel coordinates, and user code should rely on them for portability and future changes to be applied transparently, instead of implementing the following formulas manually.

The passed device context dc has its coordinate origin set to the top-left corner of the visible area (the default). The coordinate orientation is as shown in the following picture:

(wxDC origin 0,0)
x-------------> ascending X ----------------+
|                                           |
|                                           |
V ascending Y                               |
|                                           |
|                                           |
|                                           |
+-------------------------------------------+  <-- right-bottom corner of the mpWindow visible area.

Note that Y ascends in downward direction, whereas the usual vertical orientation for mathematical plots is vice versa. Thus Y-orientation will be swapped usually, when transforming between wxDC and mpLayer coordinates. This change of coordinates is taken into account in the methods p2x, p2y, x2p, y2p.

Rules for transformation between mpLayer and wxDC coordinates

dc_X = (layer_X - mpWindow::GetPosX()) * mpWindow::GetScaleX()
dc_Y = (mpWindow::GetPosY() - layer_Y) * mpWindow::GetScaleY() // swapping Y-orientation
layer_X = (dc_X / mpWindow::GetScaleX()) + mpWindow::GetPosX() // scale guaranteed to be not 0
layer_Y = mpWindow::GetPosY() - (dc_Y / mpWindow::GetScaleY()) // swapping Y-orientation
Parameters
dcDevice context to plot to.
wView to plot. The visible area can be retrieved from this object.
See also
mpWindow::p2x, mpWindow::p2y, mpWindow::x2p, mpWindow::y2p

◆ SetAlign()

void MathPlot::mpLayer::SetAlign ( int  align)
inline

Set X/Y alignment.

Parameters
alignalignment

◆ SetBrush()

void MathPlot::mpLayer::SetBrush ( const wxBrush &  brush)
inline

Set layer brush.

Parameters
brushbrush, will be copied to internal class member

◆ SetCanDelete()

void MathPlot::mpLayer::SetCanDelete ( bool  canDelete)
inline

Set CanDelete for plot.

Parameters
CanDelete

◆ SetDrawOutsideMargins()

void MathPlot::mpLayer::SetDrawOutsideMargins ( bool  drawModeOutside)
inline

Set Draw mode: inside or outside margins.

Default is outside (TRUE), which allows the layer to draw up to the mpWindow border.

Parameters
drawModeOutsideThe draw mode to be set

◆ SetFont()

void MathPlot::mpLayer::SetFont ( const wxFont &  font)
inline

Set layer font.

Parameters
fontFont, will be copied to internal class member

◆ SetFontColour()

void MathPlot::mpLayer::SetFontColour ( const wxColour &  colour)
inline

Set layer font foreground colour.

Parameters
colour

◆ SetName()

void MathPlot::mpLayer::SetName ( const wxString &  name)
inline

Set layer name.

Parameters
nameName, will be copied to internal class member

◆ SetPen()

void MathPlot::mpLayer::SetPen ( const wxPen &  pen)
inline

Set layer pen.

Parameters
penPen, will be copied to internal class member

◆ SetShowName()

void MathPlot::mpLayer::SetShowName ( bool  show)
inline

Set Name visibility.

Parameters
showvisibility bool.

◆ SetTractable()

virtual void MathPlot::mpLayer::SetTractable ( bool  track)
inlinevirtual

Sets layer tractability.

Parameters
tracktractability bool.

◆ SetVisible()

virtual void MathPlot::mpLayer::SetVisible ( bool  show)
inlinevirtual

Sets layer visibility.

Parameters
showvisibility bool.

Reimplemented in MathPlot::mpInfoLayer.