Go to the documentation of this file.
21 #ifndef _MP_MATHPLOT_H_
22 #define _MP_MATHPLOT_H_
27 #pragma warning(disable:4251)
77 #define WXDLLIMPEXP_MATHPLOT GUI_IMPEXP
80 #if defined(__GNUG__) && !defined(__clang__)
81 #pragma interface "mathplot.h"
89 #include <wx/scrolwin.h>
91 #include <wx/dynarray.h>
93 #include <wx/dcmemory.h>
94 #include <wx/string.h>
105 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
107 #define DEBUG_NEW new
112 #define X_BORDER_SEPARATION 40
113 #define Y_BORDER_SEPARATION 60
249 virtual void Plot(wxDC & dc,
mpWindow & w) = 0;
259 const wxFont&
GetFont()
const {
return m_font; }
264 const wxPen&
GetPen()
const {
return m_pen; }
283 void SetName(wxString name) { m_name = name; }
306 wxBitmap GetColourSquare(
int side = 16);
322 const wxBrush&
GetBrush()
const {
return m_brush; };
359 mpInfoLayer(wxRect rect,
const wxBrush* brush = wxTRANSPARENT_BRUSH);
368 virtual void UpdateInfo(
mpWindow& w, wxEvent& event);
388 virtual bool Inside(wxPoint& point);
392 virtual void Move(wxPoint delta);
395 virtual void UpdateReference();
399 wxPoint GetPosition();
407 const wxRect& GetRectangle() {
return m_dim; };
429 mpInfoCoords(wxRect rect,
const wxBrush* brush = wxTRANSPARENT_BRUSH);
462 mpInfoLegend(wxRect rect,
const wxBrush* brush = wxTRANSPARENT_BRUSH);
491 #define mpALIGNMASK 0x03
493 #define mpALIGN_RIGHT 0x00
495 #define mpALIGN_CENTER 0x01
497 #define mpALIGN_LEFT 0x02
499 #define mpALIGN_TOP mpALIGN_RIGHT
501 #define mpALIGN_BOTTOM mpALIGN_LEFT
503 #define mpALIGN_BORDER_BOTTOM 0x04
505 #define mpALIGN_BORDER_TOP 0x05
507 #define mpX_NORMAL 0x00
509 #define mpX_TIME 0x01
511 #define mpX_HOURS 0x02
513 #define mpX_DATE 0x03
515 #define mpX_DATETIME 0x04
517 #define mpALIGN_BORDER_LEFT mpALIGN_BORDER_BOTTOM
519 #define mpALIGN_BORDER_RIGHT mpALIGN_BORDER_TOP
521 #define mpALIGN_NE 0x00
523 #define mpALIGN_NW 0x01
525 #define mpALIGN_SW 0x02
527 #define mpALIGN_SE 0x03
552 virtual double GetY(
double x ) = 0;
563 DECLARE_DYNAMIC_CLASS(
mpFX)
584 virtual double GetX(
double y ) = 0;
595 DECLARE_DYNAMIC_CLASS(
mpFY)
615 virtual void Rewind() = 0;
622 virtual bool GetNextXY(
double & x,
double & y) = 0;
642 void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
644 DECLARE_DYNAMIC_CLASS(
mpFXY)
666 virtual double GetY(
double x ) = 0;
810 #define mpMOUSEMODE_DRAG 0
812 #define mpMOUSEMODE_ZOOMBOX 1
845 mpWindow( wxWindow *parent, wxWindowID
id,
846 const wxPoint &pos = wxDefaultPosition,
847 const wxSize &
size = wxDefaultSize,
863 bool AddLayer(
mpLayer* layer,
bool refreshDisplay =
true);
873 bool DelLayer(
mpLayer* layer,
bool alsoDeleteObject =
false,
bool refreshDisplay =
true);
879 void DelAllLayers(
bool alsoDeleteObject,
bool refreshDisplay =
true);
887 mpLayer* GetLayer(
int position);
893 mpLayer* GetLayerByName(
const wxString &name);
944 void SetScaleX(
double scaleX);
949 void SetScaleY(
double scaleY) {
if (scaleY!=0) m_scaleY=scaleY; UpdateAll(); }
954 void SetPosX(
double posX) { m_posX=posX; UpdateAll(); }
959 void SetPosY(
double posY) { m_posY=posY; UpdateAll(); }
965 void SetPos(
double posX,
double posY) { m_posX=posX; m_posY=posY; UpdateAll(); }
972 void SetScr(
int scrX,
int scrY) { m_scrX=scrX; m_scrY=scrY; }
977 inline double p2x(wxCoord pixelCoordX ) {
return m_posX + pixelCoordX/m_scaleX; }
982 inline double p2y(wxCoord pixelCoordY ) {
return m_posY - pixelCoordY/m_scaleY; }
987 inline wxCoord
x2p(
double x) {
return (wxCoord) ( (x-m_posX) * m_scaleX); }
992 inline wxCoord
y2p(
double y) {
return (wxCoord) ( (m_posY-y) * m_scaleY); }
1008 void LockAspect(
bool enable = TRUE);
1028 void Fit(
double xMin,
double xMax,
double yMin,
double yMax,wxCoord *printSizeX=NULL,wxCoord *printSizeY=NULL);
1033 void ZoomIn(
const wxPoint& centerPoint = wxDefaultPosition );
1038 void ZoomOut(
const wxPoint& centerPoint = wxDefaultPosition );
1050 void ZoomRect(wxPoint p0, wxPoint p1);
1060 unsigned int CountLayers();
1099 void GetBoundingBox(
double* bbox);
1103 void SetMPScrollbars(
bool status);
1114 bool SaveScreenshot(
const wxString& filename,
int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize,
bool fit =
false);
1125 void SetMargins(
int top,
int right,
int bottom,
int left);
1158 void SetLayerVisible(
const wxString &name,
bool viewable);
1163 bool IsLayerVisible(
const wxString &name );
1168 void SetLayerVisible(
const unsigned int position,
bool viewable);
1173 bool IsLayerVisible(
const unsigned int position );
1179 void SetColourTheme(
const wxColour& bgColour,
const wxColour& drawColour,
const wxColour& axesColour);
1188 virtual bool UpdateBBox();
1191 void OnPaint (wxPaintEvent &event);
1192 void OnSize (wxSizeEvent &event);
1194 void OnShowPopupMenu (wxMouseEvent &event);
1195 void OnMouseRightDown(wxMouseEvent &event);
1196 void OnCenter (wxCommandEvent &event);
1197 void OnFit (wxCommandEvent &event);
1198 void OnZoomIn (wxCommandEvent &event);
1199 void OnZoomOut (wxCommandEvent &event);
1200 void OnLockAspect (wxCommandEvent &event);
1201 void OnMouseHelp (wxCommandEvent &event);
1202 void OnPrintMenu (wxCommandEvent &event);
1203 void OnMouseWheel (wxMouseEvent &event);
1204 void OnMouseMove (wxMouseEvent &event);
1205 void OnMouseLeftDown (wxMouseEvent &event);
1206 void OnMouseLeftRelease (wxMouseEvent &event);
1207 void OnScrollThumbTrack (wxScrollWinEvent &event);
1208 void OnScrollPageUp (wxScrollWinEvent &event);
1209 void OnScrollPageDown (wxScrollWinEvent &event);
1210 void OnScrollLineUp (wxScrollWinEvent &event);
1211 void OnScrollLineDown (wxScrollWinEvent &event);
1212 void OnScrollTop (wxScrollWinEvent &event);
1213 void OnScrollBottom (wxScrollWinEvent &event);
1215 void DoScrollCalc (
const int position,
const int orientation);
1217 void DoZoomInXCalc (
const int staticXpixel);
1218 void DoZoomInYCalc (
const int staticYpixel);
1219 void DoZoomOutXCalc (
const int staticXpixel);
1220 void DoZoomOutYCalc (
const int staticYpixel);
1263 DECLARE_EVENT_TABLE()
1301 void SetData(
const std::vector<double> &xs,
const std::vector<double> &ys);
1307 void SetData(
const std::vector<float> &xs,
const std::vector<float> &ys);
1325 void AppendDataPoint(
float x,
float y);
1391 mpText(wxString name = wxT(
"Title"),
int offsetx = 5,
int offsety = 50);
1404 DECLARE_DYNAMIC_CLASS(
mpText)
1419 mpPrintout(
mpWindow* drawWindow,
const wxChar *title = _T(
"wxMathPlot print output"));
1423 bool OnPrintPage(
int page);
1424 bool HasPage(
int page);
1464 phi = m_reference_phi;
1473 m_reference_phi = phi;
1478 virtual bool HasBBox() {
return m_trans_shape_xs.size()!=0; }
1512 void TranslatePoint(
double x,
double y,
double &out_x,
double &out_y );
1531 void ShapeUpdated();
1559 double quantiles = 2,
1561 const wxString & layerName = wxT(
"") ) :
1565 m_quantiles(quantiles),
1566 m_segments(segments)
1568 m_continuous =
true;
1620 void RecalculateShape();
1637 m_continuous =
true;
1649 const std::vector<double>& points_xs,
1650 const std::vector<double>& points_ys,
1651 bool closedShape=
true );
1659 const std::vector<float>& points_xs,
1660 const std::vector<float>& points_ys,
1661 bool closedShape=
true );
1684 m_min_y = m_max_y = 0;
1693 void GetBitmapCopy( wxImage &outBmp )
const;
1702 void SetBitmap(
const wxImage &inBmp,
double x,
double y,
double lx,
double ly );
1753 #if defined(_MSC_VER)
1754 #pragma warning(pop)
1758 #endif // _MP_MATHPLOT_H_
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
void EnableMousePanZoom(bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
double GetDesiredYmin()
Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not ex...
virtual double GetMinX()
Get inclusive left border of bounding box.
#define mpALIGN_CENTER
Aligns label to the center.
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
std::vector< double > m_trans_shape_ys
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
int GetScrX(void) const
Get current view's X dimension in device context units.
virtual bool HasBBox()
mpInfoLayer has not bounding box.
std::vector< double > m_ys
double GetDesiredXmin()
Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
size_t GetDataLength() const
Returns the number of data points currently hold in X & Y.
void SetPosY(double posY)
Set current view's Y position and refresh display.
int m_flags
Holds label alignment.
void SetLabelFormat(const wxString &format)
Set X axis Label format (used for mpX_NORMAL draw mode).
wxBitmap * m_buff_bmp
For double buffering.
#define mpALIGN_TOP
Aligns label to the top.
const wxFont & GetFont() const
Get font set for this layer.
Plot layer, abstract base class.
double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
int m_scrY
Current view's Y dimension.
virtual void UpdateInfo(mpWindow &w, wxEvent &event)
Updates the content of the info box.
bool GetDrawOutsideMargins()
Get Draw mode: inside or outside margins.
Printout class used by mpWindow to draw in the objects to be printed.
virtual bool HasBBox()
Check whether this layer has a bounding box.
Abstract base class providing plot and labeling functionality for functions F:X->Y.
double GetXpos() const
Get current view's X position.
void SetMarginLeft(int left)
Set the left margin.
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
void SetMarginBottom(int bottom)
Set the bottom margin.
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
int m_flags
Holds label alignment.
double m_posX
Current view's X position.
const wxString & SetLabelFormat()
Get X axis Label format (used for mpX_NORMAL draw mode).
virtual bool IsInfo()
Specifies that this is an Info box layer.
unsigned int GetLabelMode()
Get X axis label view mode.
virtual void Plot(wxDC &dc, mpWindow &w)=0
Plot given view of layer to the given device context.
size_t size(const MATRIXLIKE &m, int dim)
double GetYscl() const
Get current view's Y scale.
double m_maxY
Global layer bounding box, top border incl.
class WXDLLIMPEXP_MATHPLOT mpFX
double m_scaleY
Current view's Y scale.
const wxColour & GetAxesColour()
Get axes draw colour.
double GetXscl()
Get current view's X scale.
bool GetContinuity() const
Gets the 'continuity' property of the layer.
wxString m_labelFormat
Format string used to print labels.
void SetAlign(int align)
Set label axis alignment.
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
void SetPen(wxPen pen)
Set layer pen.
class WXDLLIMPEXP_MATHPLOT mpFXY
virtual ~mpMovableObject()
double GetQuantiles() const
wxColour m_axColour
Axes Colour.
int GetYScreen(void) const
const wxPen & GetPen() const
Get pen set for this layer.
wxString m_content
string holding the coordinates to be drawn.
void ShowPrintDialog()
Draws the mpWindow on a page for printing.
wxLayerList m_layers
List of attached plot layers.
long m_mouseRClick_Y
For the right button "drag" feature.
#define mpX_NORMAL
Set label for X axis in normal mode.
wxString GetName() const
Get layer name.
void SetLabelMode(unsigned int mode)
Set X axis label view mode.
#define mpALIGN_NE
Aligns label to north-east.
wxImage m_bitmap
The internal copy of the Bitmap:
void SetLabelFormat(const wxString &format)
Set Y axis Label format.
void SetAlign(int align)
Set label axis alignment.
Plot layer implementing a x-scale ruler.
size_t CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
bool m_ticks
Flag to toggle between ticks or grid.
class WXDLLIMPEXP_MATHPLOT mpLayer
class WXDLLIMPEXP_MATHPLOT mpText
void SetDrawState(bool drawState)
wxColour m_fgColour
Foreground Colour.
mpLayerType m_type
Define layer type, which is assigned by constructor.
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
int m_offsety
Holds offset for Y in percentage.
void SetContinuity(bool continuity)
Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points...
int m_winY
Holds the mpWindow size. Used to rescale position when window is resized.
class WXDLLIMPEXP_MATHPLOT mpFXYVector
virtual double GetMinY()
Get inclusive bottom border of bounding box.
bool GetTicks()
Get X axis ticks or grid.
bool m_enableDoubleBuffer
For double buffering.
virtual bool HasBBox()
Check whether this layer has a bounding box.
virtual bool HasBBox()
mpText should not be used for scaling decisions.
const wxBrush & GetBrush() const
Get brush set for this layer.
double GetPosY(void) const
void SetSegments(int segments)
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
virtual double GetMaxY()
Get inclusive top border of bounding box.
double GetMinX()
Returns the actual minimum X data (loaded in SetData).
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
int m_flags
Holds label alignment.
bool m_visible
Toggles layer visibility.
int GetMarginLeft()
Get the left margin.
double GetScaleY(void) const
wxBrush m_brush
Layer's brush.
void SetTicks(bool ticks)
Set Y axis ticks or grid.
#define mpALIGN_RIGHT
Aligns label to the right.
Implements an overlay box which shows the mouse coordinates in plot units. When an mpInfoCoords layer...
virtual bool GetNextXY(double &x, double &y)=0
Get locus value for next N.
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
double GetDesiredXmax()
Returns the right-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
bool m_showName
States whether the name of the layer must be shown (default is true).
class WXDLLIMPEXP_MATHPLOT mpScaleX
bool IsVisible()
Checks whether the layer is visible or not.
int GetMarginTop()
Get the top margin.
bool m_drawOutsideMargins
select if the layer should draw only inside margins or over all DC
double GetDesiredYmax()
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
int m_offsetx
Holds offset for X in percentage.
double GetScaleX(void) const
Zoom into view at clickposition / window center.
virtual double GetMaxY()
Get inclusive top border of bounding box.
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
void SetBrush(wxBrush brush)
Set layer brush.
class WXDLLIMPEXP_MATHPLOT mpPrintout
void SetAlign(int align)
Set Y axis alignment.
A 2D ellipse, described by a 2x2 covariance matrix.
bool GetMPScrollbars()
Get scrollbars status.
class WXDLLIMPEXP_MATHPLOT mpFY
double m_scaleX
Current view's X scale.
class WXDLLIMPEXP_MATHPLOT mpScaleY
wxColour m_bgColour
Background Colour.
mpMovableObject()
Default constructor (sets location and rotation to (0,0,0))
mpLayerType GetLayerType()
Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc,...
virtual double GetMinY()
Get inclusive bottom border of bounding box.
mpCovarianceEllipse(double cov_00=1, double cov_11=1, double cov_01=0, double quantiles=2, int segments=32, const wxString &layerName=wxT(""))
Default constructor.
Fit view to match bounding box of all layers.
virtual double GetMinY()
Get inclusive bottom border of bounding box.
A class providing graphs functionality for a 2D plot (either continuous or a set of points),...
virtual double GetMaxY()
Get inclusive top border of bounding box.
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
void SetTicks(bool ticks)
Set X axis ticks or grid.
wxMenu m_popmenu
Canvas' context menu.
double GetYpos() const
Get current view's Y position.
void SetName(wxString name)
Set layer name.
double GetPosX(void) const
int GetMarginBottom()
Get the bottom margin.
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points.
Plot layer implementing a text string.
mpBitmapLayer()
Default constructor.
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,...
bool m_ticks
Flag to toggle between ticks or grid.
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Plot layer implementing a y-scale ruler.
virtual ~mpCovarianceEllipse()
int m_mouseLClick_Y
Starting coords for rectangular zoom selection.
bool m_lockaspect
Scale aspect is locked or not.
void ShowName(bool show)
Shows or hides the text label with the name of the layer (default is visible).
std::vector< double > m_shape_ys
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
virtual void Plot(wxDC &dc, mpWindow &w)
Plot method.
bool m_enableMouseNavigation
For pan/zoom with the mouse.
void SetPosX(double posX)
Set current view's X position and refresh display.
std::deque< mpLayer * > wxLayerList
Define the type for the list of layers inside mpWindow.
virtual bool HasBBox()
Check whether this layer has a bounding box.
wxBrush m_brush
The brush to be used for the background.
virtual bool HasBBox()
Check whether this layer has a bounding box.
Abstract base class providing plot and labeling functionality for functions F:Y->X.
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above).
An arbitrary polygon, descendant of mpMovableObject.
mpPolygon(const wxString &layerName=wxT(""))
Default constructor.
void SetFont(wxFont &font)
Set layer font.
void SetScaleY(double scaleY)
Set current view's Y scale and refresh display.
int GetScrY(void) const
Get current view's Y dimension in device context units.
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
bool m_mouseMovedAfterRightClick
int m_last_ly
For double buffering.
int GetXScreen(void) const
double m_minY
Global layer bounding box, bottom border incl.
wxMemoryDC m_buff_dc
For double buffering.
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
void SetMarginTop(int top)
Set the top margin.
Canvas for plotting mpLayer implementations.
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
const wxString & SetLabelFormat()
Get Y axis Label format.
virtual double GetMinX()
Get inclusive left border of bounding box.
virtual void Rewind()=0
Rewind value enumeration with mpFXY::GetNextXY.
size_t m_index
The internal counter for the "GetNextXY" interface.
double m_minX
Global layer bounding box, left border incl.
void SetMarginRight(int right)
Set the right margin.
int m_clickedX
Last mouse click X position, for centering and zooming the view.
void SetAlign(int align)
Set X axis alignment.
virtual bool HasBBox()
Check whether this layer has a bounding box.
#define WXDLLIMPEXP_MATHPLOT
virtual double GetMinX()
Get inclusive left border of bounding box.
bool IsAspectLocked()
Checks whether the X/Y scale aspect is locked.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
virtual double GetMaxX()
Get inclusive right border of bounding box.
virtual double GetMaxX()
Get inclusive right border of bounding box.
int m_flags
Holds label alignment.
int m_scrX
Current view's X dimension.
class WXDLLIMPEXP_MATHPLOT mpWindow
virtual bool IsInfo()
Check whether the layer is an info box.
int m_flags
Holds label alignment.
wxPoint m_reference
Holds the reference point for movements.
enum __mp_Layer_Type mpLayerType
unsigned int m_labelType
Select labels mode: mpX_NORMAL for normal labels, mpX_TIME for time axis in hours,...
Abstract base class providing plot and labeling functionality for functions F:Y->X.
virtual double GetMaxX()
Get inclusive right border of bounding box.
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
double m_posY
Current view's Y position.
wxCoord m_scaledBitmap_offset_y
bool GetTicks()
Get Y axis ticks or grid.
Shows information about the mouse commands.
Center view on click position.
int GetMarginRight()
Get the right margin.
void SetVisible(bool show)
Sets layer visibility.
int m_segments
The number of line segments that build up the ellipse.
wxString m_labelFormat
Format string used to print labels.
double m_maxX
Global layer bounding box, right border incl.
wxString m_name
Layer's name.
Page generated by Doxygen 1.8.16 for MRPT 1.4.0 SVN: at Mon Oct 14 23:08:25 UTC 2019 | | |