A class providing graphs functionality for a 2D plot (either continuous or a set of points), from vectors of data.
This class can be used directly, the user does not need to derive any new class. Simply pass the data as two vectors with the same length containing the X and Y coordinates to the method SetData.
To generate a graph with a set of points, call
or
to render the sequence of coordinates as a continuous line.
(Added: Jose Luis Blanco, AGO-2007)
Definition at line 1289 of file mathplot.h.
#include <mrpt/otherlibs/mathplot/mathplot.h>
Public Member Functions | |
mpFXYVector (wxString name=wxEmptyString, int flags=mpALIGN_NE) | |
void | SetData (const std::vector< double > &xs, const std::vector< double > &ys) |
Changes the internal data: the set of points to draw. More... | |
void | SetData (const std::vector< float > &xs, const std::vector< float > &ys) |
Changes the internal data: the set of points to draw. More... | |
void | Clear () |
Clears all the data, leaving the layer empty. More... | |
size_t | GetDataLength () const |
Returns the number of data points currently hold in X & Y. More... | |
void | AppendDataPoint (float x, float y) |
Append a new data point (x,y) More... | |
double | GetMinX () |
Returns the actual minimum X data (loaded in SetData). More... | |
double | GetMinY () |
Returns the actual minimum Y data (loaded in SetData). More... | |
double | GetMaxX () |
Returns the actual maximum X data (loaded in SetData). More... | |
double | GetMaxY () |
Returns the actual maximum Y data (loaded in SetData). More... | |
virtual void | Plot (wxDC &dc, mpWindow &w) |
Layer plot handler. More... | |
virtual bool | HasBBox () |
Check whether this layer has a bounding box. More... | |
virtual bool | IsInfo () |
Check whether the layer is an info box. More... | |
wxString | GetName () const |
Get layer name. More... | |
const wxFont & | GetFont () const |
Get font set for this layer. More... | |
const wxPen & | GetPen () const |
Get pen set for this layer. More... | |
void | SetContinuity (bool continuity) |
Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points). More... | |
bool | GetContinuity () const |
Gets the 'continuity' property of the layer. More... | |
void | ShowName (bool show) |
Shows or hides the text label with the name of the layer (default is visible). More... | |
void | SetName (wxString name) |
Set layer name. More... | |
void | SetFont (wxFont &font) |
Set layer font. More... | |
void | SetPen (wxPen pen) |
Set layer pen. More... | |
void | SetDrawOutsideMargins (bool drawModeOutside) |
Set Draw mode: inside or outside margins. More... | |
bool | GetDrawOutsideMargins () |
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... | |
mpLayerType | GetLayerType () |
Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc, this method returns the right value. More... | |
bool | IsVisible () |
Checks whether the layer is visible or not. More... | |
void | SetVisible (bool show) |
Sets layer visibility. More... | |
const wxBrush & | GetBrush () const |
Get brush set for this layer. More... | |
void | SetBrush (wxBrush brush) |
Set layer brush. More... | |
Protected Member Functions | |
void | Rewind () |
Rewind value enumeration with mpFXY::GetNextXY. More... | |
bool | GetNextXY (double &x, double &y) |
Get locus value for next N. More... | |
void | UpdateViewBoundary (wxCoord xnew, wxCoord ynew) |
Update label positioning data. More... | |
Protected Attributes | |
std::vector< double > | m_xs |
The internal copy of the set of data to draw. More... | |
std::vector< double > | m_ys |
size_t | m_index |
The internal counter for the "GetNextXY" interface. More... | |
double | m_minX |
Loaded at SetData. More... | |
double | m_maxX |
double | m_minY |
double | m_maxY |
int | m_flags |
Holds label alignment. More... | |
wxCoord | maxDrawX |
wxCoord | minDrawX |
wxCoord | maxDrawY |
wxCoord | minDrawY |
wxFont | m_font |
Layer's font. More... | |
wxPen | m_pen |
Layer's pen. More... | |
wxBrush | m_brush |
Layer's brush. More... | |
wxString | m_name |
Layer's name. More... | |
bool | m_continuous |
Specify if the layer will be plotted as a continuous line or a set of points. More... | |
bool | m_showName |
States whether the name of the layer must be shown (default is true). More... | |
bool | m_drawOutsideMargins |
select if the layer should draw only inside margins or over all DC More... | |
mpLayerType | m_type |
Define layer type, which is assigned by constructor. More... | |
bool | m_visible |
Toggles layer visibility. More... | |
mpFXYVector::mpFXYVector | ( | wxString | name = wxEmptyString , |
int | flags = mpALIGN_NE |
||
) |
name | Label |
flags | Label alignment, pass one of mpALIGN_NE, mpALIGN_NW, mpALIGN_SW, mpALIGN_SE. |
void mpFXYVector::AppendDataPoint | ( | float | x, |
float | y | ||
) |
Append a new data point (x,y)
void mpFXYVector::Clear | ( | ) |
Clears all the data, leaving the layer empty.
|
inlineinherited |
|
inherited |
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.
side | side length in pixels |
|
inlineinherited |
Gets the 'continuity' property of the layer.
Definition at line 274 of file mathplot.h.
|
inline |
Returns the number of data points currently hold in X & Y.
Definition at line 1317 of file mathplot.h.
|
inlineinherited |
Get Draw mode: inside or outside margins.
Definition at line 301 of file mathplot.h.
|
inlineinherited |
|
inlineinherited |
Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc, this method returns the right value.
Definition at line 310 of file mathplot.h.
|
inlinevirtual |
Returns the actual maximum X data (loaded in SetData).
Reimplemented from mpLayer.
Definition at line 1363 of file mathplot.h.
|
inlinevirtual |
Returns the actual maximum Y data (loaded in SetData).
Reimplemented from mpLayer.
Definition at line 1367 of file mathplot.h.
|
inlinevirtual |
Returns the actual minimum X data (loaded in SetData).
Reimplemented from mpLayer.
Definition at line 1355 of file mathplot.h.
|
inlinevirtual |
Returns the actual minimum Y data (loaded in SetData).
Reimplemented from mpLayer.
Definition at line 1359 of file mathplot.h.
|
inlineinherited |
|
protectedvirtual |
Get locus value for next N.
Overridden in this implementation.
x | Returns X value |
y | Returns Y value |
Implements mpFXY.
|
inlineinherited |
|
inlinevirtualinherited |
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.
TRUE | Has bounding box |
FALSE | Has not bounding box |
Reimplemented in mpBitmapLayer, mpMovableObject, mpText, mpScaleY, mpScaleX, and mpInfoLayer.
Definition at line 178 of file mathplot.h.
|
inlinevirtualinherited |
Check whether the layer is an info box.
The default implementation returns FALSE. It is overrided to TRUE for mpInfoLayer class and its derivative. It is necessary to define mouse actions behaviour over info boxes.
Reimplemented in mpInfoLayer.
Definition at line 186 of file mathplot.h.
|
inlineinherited |
Checks whether the layer is visible or not.
Definition at line 314 of file mathplot.h.
|
virtualinherited |
Layer plot handler.
This implementation will plot the locus in the visible area and put a label according to the alignment specified.
Implements mpLayer.
|
protectedvirtual |
Rewind value enumeration with mpFXY::GetNextXY.
Overridden in this implementation.
Implements mpFXY.
|
inlineinherited |
Set layer brush.
brush | brush, will be copied to internal class member |
Definition at line 326 of file mathplot.h.
|
inlineinherited |
Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points).
Definition at line 269 of file mathplot.h.
void mpFXYVector::SetData | ( | const std::vector< double > & | xs, |
const std::vector< double > & | ys | ||
) |
void mpFXYVector::SetData | ( | const std::vector< float > & | xs, |
const std::vector< float > & | ys | ||
) |
|
inlineinherited |
Set Draw mode: inside or outside margins.
Default is outside, which allows the layer to draw up to the mpWindow border.
drawModeOutside | The draw mode to be set |
Definition at line 297 of file mathplot.h.
|
inlineinherited |
Set layer font.
font | Font, will be copied to internal class member |
Definition at line 288 of file mathplot.h.
|
inlineinherited |
Set layer name.
name | Name, will be copied to internal class member |
Definition at line 283 of file mathplot.h.
|
inlineinherited |
Set layer pen.
pen | Pen, will be copied to internal class member |
Definition at line 293 of file mathplot.h.
|
inlineinherited |
|
inlineinherited |
Shows or hides the text label with the name of the layer (default is visible).
Definition at line 278 of file mathplot.h.
|
protectedinherited |
Update label positioning data.
xnew | New x coordinate |
ynew | New y coordinate |
|
protectedinherited |
Layer's brush.
Definition at line 331 of file mathplot.h.
|
protectedinherited |
Specify if the layer will be plotted as a continuous line or a set of points.
Definition at line 333 of file mathplot.h.
|
protectedinherited |
select if the layer should draw only inside margins or over all DC
Definition at line 335 of file mathplot.h.
|
protected |
Holds label alignment.
Definition at line 1370 of file mathplot.h.
|
protectedinherited |
Layer's font.
Definition at line 326 of file mathplot.h.
|
protected |
The internal counter for the "GetNextXY" interface.
Definition at line 1334 of file mathplot.h.
|
protected |
Definition at line 1338 of file mathplot.h.
|
protected |
Definition at line 1338 of file mathplot.h.
|
protected |
Loaded at SetData.
Definition at line 1338 of file mathplot.h.
|
protected |
Definition at line 1338 of file mathplot.h.
|
protectedinherited |
Layer's name.
Definition at line 332 of file mathplot.h.
|
protectedinherited |
Layer's pen.
Definition at line 330 of file mathplot.h.
|
protectedinherited |
States whether the name of the layer must be shown (default is true).
Definition at line 334 of file mathplot.h.
|
protectedinherited |
Define layer type, which is assigned by constructor.
Definition at line 336 of file mathplot.h.
|
protectedinherited |
Toggles layer visibility.
Definition at line 337 of file mathplot.h.
|
protected |
The internal copy of the set of data to draw.
Definition at line 1330 of file mathplot.h.
|
protected |
Definition at line 1330 of file mathplot.h.
|
protectedinherited |
Definition at line 635 of file mathplot.h.
|
protectedinherited |
Definition at line 635 of file mathplot.h.
|
protectedinherited |
Definition at line 635 of file mathplot.h.
|
protectedinherited |
Definition at line 635 of file mathplot.h.
Page generated by Doxygen 1.8.15 for MRPT 1.4.0 SVN: at Sat Aug 3 20:09:00 UTC 2019 |