MathPlot
mathplot.h
Go to the documentation of this file.
1 // Name: mathplot.cpp
3 // Purpose: Framework for plotting in wxWindows
4 // Original Author: David Schalig
5 // Maintainer: Davide Rondini
6 // Contributors: Jose Luis Blanco, Val Greene, Lionel Reynaud, Dave Nadler, MortenMacFly
7 // Created: 21/07/2003
8 // Last edit: 29/03/2025
9 // Copyright: (c) David Schalig, Davide Rondini
10 // Licence: wxWindows licence
12 
13 #ifndef _MP_MATHPLOT_H_
14 #define _MP_MATHPLOT_H_
15 
55 //this definition uses windows dll to export function.
56 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
57 //mathplot_EXPORTS will be defined by cmake
58 #ifdef mathplot_EXPORTS
59 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
60 #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
61 #else // not making DLL
62 #define WXDLLIMPEXP_MATHPLOT
63 #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
64 #endif
65 
66 #if defined(__GNUG__) && !defined(__APPLE__)
67 #pragma interface "mathplot.h"
68 #endif
69 
70 #include <vector>
71 
72 // #include <wx/wx.h>
73 #include <wx/defs.h>
74 #include <wx/menu.h>
75 #include <wx/scrolwin.h>
76 #include <wx/event.h>
77 #include <wx/dynarray.h>
78 #include <wx/pen.h>
79 #include <wx/dcmemory.h>
80 #include <wx/string.h>
81 #include <wx/print.h>
82 #include <wx/image.h>
83 #include <wx/intl.h>
84 
85 #include <cmath>
86 #include <deque>
87 
88 #define ENABLE_MP_CONFIG
89 #ifdef ENABLE_MP_CONFIG
90 #include "MathPlotConfig.h"
91 #endif // ENABLE_MP_CONFIG
92 
96 #define ENABLE_MP_NAMESPACE
97 #ifdef ENABLE_MP_NAMESPACE
98 namespace MathPlot
99 {
100 #endif // ENABLE_MP_NAMESPACE
101 
102 #ifdef ENABLE_MP_DEBUG
103 // For memory leak debug
104 #ifdef _WINDOWS
105 #ifdef _DEBUG
106 #include <crtdbg.h>
107 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
108 #else
109 #define DEBUG_NEW new
110 #endif // _DEBUG
111 #endif // _WINDOWS
112 #endif // ENABLE_MP_DEBUG
113 
114 // Separation for axes when set close to border
115 #define X_BORDER_SEPARATION 40
116 #define Y_BORDER_SEPARATION 60
117 
119 #define mpX_LOCALTIME 0x10
120 
121 #define mpX_UTCTIME 0x20
122 #define mpX_RAWTIME mpX_UTCTIME
123 
124 // An epsilon for float comparison to 0
125 #define EPSILON 1e-8
126 #define ISNOTNULL(x) (fabs(x) > EPSILON)
127 
128 // A small extra margin for the plot boundary
129 #define EXTRA_MARGIN 8
130 
131 //-----------------------------------------------------------------------------
132 // classes
133 //-----------------------------------------------------------------------------
134 
135 class WXDLLIMPEXP_MATHPLOT mpLayer;
136 class WXDLLIMPEXP_MATHPLOT mpFunction;
137 class WXDLLIMPEXP_MATHPLOT mpLine;
138 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine;
139 class WXDLLIMPEXP_MATHPLOT mpVerticalLine;
140 class WXDLLIMPEXP_MATHPLOT mpFX;
141 class WXDLLIMPEXP_MATHPLOT mpFY;
142 class WXDLLIMPEXP_MATHPLOT mpFXY;
143 class WXDLLIMPEXP_MATHPLOT mpFXYVector;
144 class WXDLLIMPEXP_MATHPLOT mpProfile;
145 class WXDLLIMPEXP_MATHPLOT mpChart;
146 class WXDLLIMPEXP_MATHPLOT mpBarChart;
147 class WXDLLIMPEXP_MATHPLOT mpScale;
148 class WXDLLIMPEXP_MATHPLOT mpScaleX;
149 class WXDLLIMPEXP_MATHPLOT mpScaleY;
150 class WXDLLIMPEXP_MATHPLOT mpInfoLayer;
151 class WXDLLIMPEXP_MATHPLOT mpInfoCoords;
152 class WXDLLIMPEXP_MATHPLOT mpInfoLegend;
153 class WXDLLIMPEXP_MATHPLOT mpWindow;
154 class WXDLLIMPEXP_MATHPLOT mpText;
155 class WXDLLIMPEXP_MATHPLOT mpTitle;
156 class WXDLLIMPEXP_MATHPLOT mpPrintout;
157 class WXDLLIMPEXP_MATHPLOT mpMovableObject;
158 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse;
159 class WXDLLIMPEXP_MATHPLOT mpPolygon;
160 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer;
161 
162 #ifdef ENABLE_MP_CONFIG
164 #endif // ENABLE_MP_CONFIG
165 
167 typedef union
168 {
169  struct
170  {
171  wxCoord startPx;
172  wxCoord endPx;
173  wxCoord startPy;
174  wxCoord endPy;
175  };
176  struct
177  {
178  wxCoord left;
179  wxCoord top;
180  wxCoord right;
181  wxCoord bottom;
182  };
183  struct
184  {
185  wxCoord x1;
186  wxCoord y1;
187  wxCoord x2;
188  wxCoord y2;
189  };
190  wxCoord tab[4];
191 } mpRect;
192 
200 {
201  struct
202  {
203  double Xmin;
204  double Xmax;
205  double Ymin;
206  double Ymax;
207  double Y2min;
208  double Y2max;
209  };
210  mpFloatRect() : Xmin(0.0), Xmax(0.0), Ymin(0.0), Ymax(0.0), Y2min(0.0), Y2max(0.0) {}
212  bool PointIsInside(double x, double y) const {
213  if( (x < Xmin || x > Xmax) ||
214  (y < Ymin || y > Ymax) ) return false;
215  return true;
216  }
218  void UpdateBoundingBoxToInclude(double x, double y, double y2=0) {
219  if (x < Xmin ) Xmin = x;
220  else if (x > Xmax ) Xmax = x;
221  if (y < Ymin ) Ymin = y;
222  else if (y > Ymax ) Ymax = y;
223  if (y2 < Y2min) Y2min = y2;
224  else if (y2 > Y2max) Y2max = y2;
225  }
227  void InitializeBoundingBox(double x, double y, double y2=0) {
228  Xmin = Xmax = x;
229  Ymin = Ymax = y;
230  Y2min = Y2max = y2;
231  }
233  bool IsNotSet() const { const mpFloatRect def; return *this==def; }
235  #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
236  bool operator==(const mpFloatRect&) const = default;
237  #else
238  // We compare with an epsilon precision
239  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
240  bool operator ==(const mpFloatRect &rect) const
241  {
242  auto Same = [this,rect] (double a, double b) { return fabs(a - b) < EPSILON; };
243  return Same(Xmin, rect.Xmin) && Same(Xmax, rect.Xmax) &&
244  Same(Ymin, rect.Ymin) && Same(Ymax, rect.Ymax) &&
245  Same(Y2min, rect.Y2min) && Same(Y2max, rect.Y2max) ;
246  }
247  #endif
248 };
249 
253 enum
254 {
255  mpID_FIT = 2000,
263 #ifdef ENABLE_MP_CONFIG
265 #endif // ENABLE_MP_CONFIG
269 };
270 
272 typedef enum __mp_Location_Type
273 {
274  mpMarginLeftCenter,
275  mpMarginTopLeft,
276  mpMarginTopCenter,
277  mpMarginTopRight,
278  mpMarginRightCenter,
279  mpMarginBottomLeft,
280  mpMarginBottomCenter,
281  mpMarginBottomRight,
282  mpMarginNone,
283  mpCursor // only for mpInfoCoords
284 } mpLocation;
285 
287 typedef enum __XAxis_Align_Type
288 {
289  mpALIGN_BORDER_BOTTOM = 10,
290  mpALIGN_BOTTOM,
291  mpALIGN_CENTERX,
292  mpALIGN_TOP,
293  mpALIGN_BORDER_TOP
294 } mpXAxis_Align;
295 
297 typedef enum __YAxis_Align_Type
298 {
299  mpALIGN_BORDER_LEFT = 20,
300  mpALIGN_LEFT,
301  mpALIGN_CENTERY,
302  mpALIGN_RIGHT,
303  mpALIGN_BORDER_RIGHT
304 } mpYAxis_Align;
305 
308 {
309  mpALIGN_NW = 5,
310  mpALIGN_NE,
311  mpALIGN_SE,
312  mpALIGN_SW
313 } mpPlot_Align;
314 
316 typedef enum __mp_Style_Type
317 {
321 } mpLegendStyle;
322 
325 {
329 
330 typedef enum __Symbol_Type
331 {
332  mpsNone,
333  mpsCircle,
334  mpsSquare,
335  mpsUpTriangle,
336  mpsDownTriangle,
337  mpsCross,
338  mpsPlus
339 } mpSymbol;
340 
341 //-----------------------------------------------------------------------------
342 // mpLayer sub_type values
343 //-----------------------------------------------------------------------------
344 
346 typedef enum __Info_Type
347 {
348  mpiNone, // never used
349  mpiInfo,
350  mpiCoords,
351  mpiLegend
352 } mpInfoType;
353 
355 typedef enum __Text_Type
356 {
357  mptNone, // never used
358  mptText,
359  mptTitle
360 } mpTextType;
361 
362 typedef enum __Function_Type
363 {
364  mpfNone,
365  mpfFX,
366  mpfFY,
367  mpfFXY,
368  mpfFXYVector,
369  mpfMovable,
370  mpfLine,
371  mpfAllType
372 } mpFunctionType;
373 
374 typedef enum __Scale_Type
375 {
376  mpsScaleNone,
377  mpsScaleX,
378  mpsScaleY,
379  mpsAllType
380 } mpScaleType;
381 
382 typedef enum __Chart_Type
383 {
384  mpcChartNone,
385  mpcBarChart,
386  mpcPieChart,
387  mpcAllType
388 } mpChartType;
389 
390 //-----------------------------------------------------------------------------
391 // mpLayer
392 //-----------------------------------------------------------------------------
393 
394 typedef enum __mp_Layer_Type
395 {
404 } mpLayerType;
405 
411 typedef enum __mp_Layer_ZOrder
412 {
421 } mpLayerZOrder;
422 
433 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
434 {
435  public:
436  mpLayer(mpLayerType layerType);
437 
438  virtual ~mpLayer()
439  {
440  ;
441  }
442 
446  {
447  m_win = &w;
448  }
449 
457  virtual bool HasBBox()
458  {
459  return true;
460  }
461 
466  virtual void GetBBox(mpFloatRect *m_bound);
467 
472  mpLayerType GetLayerType() const
473  {
474  return m_type;
475  }
476 
480  int GetLayerSubType() const
481  {
482  return m_subtype;
483  }
484 
491  virtual bool IsLayerType(mpLayerType type, int *sub_type)
492  {
493  *sub_type = m_subtype;
494  return (m_type == type);
495  }
496 
500  virtual double GetMinX()
501  {
502  return -1.0;
503  }
504 
508  virtual double GetMaxX()
509  {
510  return 1.0;
511  }
512 
516  virtual double GetMinY()
517  {
518  return -1.0;
519  }
520 
524  virtual double GetMaxY()
525  {
526  return 1.0;
527  }
528 
570  void Plot(wxDC &dc, mpWindow &w);
571 
575  void SetName(const wxString &name)
576  {
577  m_name = name;
578  }
579 
583  const wxString& GetName() const
584  {
585  return m_name;
586  }
587 
591  void SetFont(const wxFont &font)
592  {
593  m_font = font;
594  }
595 
599  const wxFont& GetFont() const
600  {
601  return m_font;
602  }
603 
607  void SetFontColour(const wxColour &colour)
608  {
609  m_fontcolour = colour;
610  }
611 
615  const wxColour& GetFontColour() const
616  {
617  return m_fontcolour;
618  }
619 
623  void SetPen(const wxPen &pen)
624  {
625  m_pen = pen;
626  }
627 
631  const wxPen& GetPen() const
632  {
633  return m_pen;
634  }
635 
638  void SetBrush(const wxBrush &brush)
639  {
640  if (brush == wxNullBrush)
641  m_brush = *wxTRANSPARENT_BRUSH;
642  else
643  m_brush = brush;
644  }
645 
648  const wxBrush& GetBrush() const
649  {
650  return m_brush;
651  }
652 
655  void SetShowName(bool show)
656  {
657  m_showName = show;
658  }
659 
662  inline bool GetShowName() const
663  {
664  return m_showName;
665  }
666 
669  void SetDrawOutsideMargins(bool drawModeOutside)
670  {
671  m_drawOutsideMargins = drawModeOutside;
672  }
673 
677  {
678  return m_drawOutsideMargins;
679  }
680 
685  wxBitmap GetColourSquare(int side = 16);
686 
689  inline bool IsVisible() const
690  {
691  return m_visible;
692  }
693 
696  virtual void SetVisible(bool show)
697  {
698  m_visible = show;
699  }
700 
703  inline bool IsTractable() const
704  {
705  return m_tractable;
706  }
707 
710  virtual void SetTractable(bool track)
711  {
712  m_tractable = track;
713  }
714 
717  void SetAlign(int align)
718  {
719  m_flags = align;
720  }
721 
724  int GetAlign() const
725  {
726  return m_flags;
727  }
728 
731  void SetCanDelete(bool canDelete)
732  {
733  m_CanDelete = canDelete;
734  }
735 
738  bool GetCanDelete(void) const
739  {
740  return m_CanDelete;
741  }
742 
745  mpLayerZOrder GetZIndex(void) const
746  {
747  return m_ZIndex;
748  }
749 
750  protected:
751  const mpLayerType m_type;
753  int m_subtype;
754  wxFont m_font;
755  wxColour m_fontcolour;
756  wxPen m_pen;
757  wxBrush m_brush;
758  wxString m_name;
759  bool m_showName;
761  bool m_visible;
762  bool m_tractable;
763  int m_flags;
765  bool m_CanDelete;
766  mpLayerZOrder m_ZIndex;
767 
770  void UpdateContext(wxDC &dc) const;
771 
776  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
777 
781  virtual void DoBeforePlot()
782  {
783  ;
784  }
785 
789  void CheckLog(double *x, double *y);
790 
791  private:
792  bool m_busy;
793  mpLayer() = delete; // default ctor not implemented/permitted
794 
795  wxDECLARE_DYNAMIC_CLASS(mpLayer);
796 };
797 
798 //-----------------------------------------------------------------------------
799 // mpInfoLayer
800 //-----------------------------------------------------------------------------
801 
807 class WXDLLIMPEXP_MATHPLOT mpInfoLayer: public mpLayer
808 {
809  public:
811  mpInfoLayer();
812 
817  mpInfoLayer(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
818 
820  virtual ~mpInfoLayer();
821 
824  virtual void SetVisible(bool show);
825 
830  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
831 
834  virtual bool HasBBox()
835  {
836  return false;
837  }
838 
842  virtual void ErasePlot(wxDC &dc, mpWindow &w);
843 
847  virtual bool Inside(const wxPoint &point);
848 
851  virtual void Move(wxPoint delta);
852 
854  virtual void UpdateReference();
855 
858  wxPoint GetPosition() const
859  {
860  return m_dim.GetPosition();
861  }
862 
865  wxSize GetSize() const
866  {
867  return m_dim.GetSize();
868  }
869 
872  const wxRect& GetRectangle() const
873  {
874  return m_dim;
875  }
876 
879  void SetLocation(mpLocation location)
880  {
881  m_location = location;
882  }
883 
886  mpLocation GetLocation() const
887  {
888  return m_location;
889  }
890 
891  protected:
892  wxRect m_dim;
893  wxRect m_oldDim;
894  wxBitmap* m_info_bmp;
895  wxPoint m_reference;
896  int m_winX, m_winY;
897  mpLocation m_location;
898 
903  virtual void DoPlot(wxDC &dc, mpWindow &w);
904 
907  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
908 
909  wxDECLARE_DYNAMIC_CLASS(mpInfoLayer);
910 };
911 
916 class WXDLLIMPEXP_MATHPLOT mpInfoCoords: public mpInfoLayer
917 {
918  public:
920  mpInfoCoords();
921 
923  mpInfoCoords(mpLocation location);
924 
929  mpInfoCoords(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
930 
933  {
934  ;
935  }
936 
940  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
941 
942  virtual void ErasePlot(wxDC &dc, mpWindow &w);
943 
946  void SetLabelMode(unsigned int mode, unsigned int time_conv = mpX_RAWTIME)
947  {
948  m_labelType = mode;
949  m_timeConv = time_conv;
950  }
951 
954  void SetSeriesCoord(bool show)
955  {
956  m_series_coord = show;
957  }
958 
961  bool IsSeriesCoord() const
962  {
963  return m_series_coord;
964  }
965 
969  virtual wxString GetInfoCoordsText(double xVal, double yVal, double y2Val, bool isY2Axis = false);
970 
973  void SetPenSeries(const wxPen &pen)
974  {
975  m_penSeries = pen;
976  }
977 
978  protected:
979  wxString m_content;
980  unsigned int m_labelType;
981  unsigned int m_timeConv;
982  wxCoord m_mouseX;
983  wxCoord m_mouseY;
984  bool m_series_coord;
985  wxPen m_penSeries;
986 
991  virtual void DoPlot(wxDC &dc, mpWindow &w);
992 
993  wxDECLARE_DYNAMIC_CLASS(mpInfoCoords);
994 };
995 
1000 class WXDLLIMPEXP_MATHPLOT mpInfoLegend: public mpInfoLayer
1001 {
1002  public:
1004  mpInfoLegend();
1005 
1011  mpInfoLegend(wxRect rect, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginNone);
1012 
1015 
1018  void SetItemMode(mpLegendStyle mode)
1019  {
1020  m_item_mode = mode;
1021  m_needs_update = true;
1022  }
1023 
1024  mpLegendStyle GetItemMode() const
1025  {
1026  return m_item_mode;
1027  }
1028 
1031  void SetItemDirection(mpLegendDirection mode)
1032  {
1033  m_item_direction = mode;
1034  m_needs_update = true;
1035  }
1036 
1037  mpLegendDirection GetItemDirection() const
1038  {
1039  return m_item_direction;
1040  }
1041 
1042  void SetNeedUpdate()
1043  {
1044  m_needs_update = true;
1045  }
1046 
1048  int GetPointed(mpWindow &w, wxPoint eventPoint);
1049 
1050  protected:
1051  mpLegendStyle m_item_mode;
1052  mpLegendDirection m_item_direction;
1053 
1058  virtual void DoPlot(wxDC &dc, mpWindow &w);
1059 
1060  private:
1062  struct LegendDetail
1063  {
1064  unsigned int layerIdx;
1065  wxCoord legendEnd;
1066  };
1068  std::vector<LegendDetail> m_LegendDetailList;
1069  bool m_needs_update;
1070 
1080  void UpdateBitmap(wxDC &dc, mpWindow &w);
1081 
1082  wxDECLARE_DYNAMIC_CLASS(mpInfoLegend);
1083 };
1084 
1085 //-----------------------------------------------------------------------------
1086 // mpLayer implementations - functions
1087 //-----------------------------------------------------------------------------
1088 
1096 class WXDLLIMPEXP_MATHPLOT mpFunction: public mpLayer
1097 {
1098  public:
1101  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, bool useY2Axis = false);
1102 
1106  void SetContinuity(bool continuity)
1107  {
1108  m_continuous = continuity;
1109  }
1110 
1114  bool GetContinuity() const
1115  {
1116  return m_continuous;
1117  }
1118 
1121  void SetStep(unsigned int step)
1122  {
1123  m_step = step;
1124  }
1125 
1128  unsigned int GetStep() const
1129  {
1130  return m_step;
1131  }
1132 
1135  void SetSymbol(mpSymbol symbol)
1136  {
1137  m_symbol = symbol;
1138  }
1139 
1142  mpSymbol GetSymbol() const
1143  {
1144  return m_symbol;
1145  }
1146 
1149  void SetSymbolSize(int size)
1150  {
1151  m_symbolSize = size;
1152  m_symbolSize2 = size / 2;
1153  }
1154 
1157  int GetSymbolSize() const
1158  {
1159  return m_symbolSize;
1160  }
1161 
1165  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1166 
1170  void SetY2Axis(bool _useY2)
1171  {
1172  m_UseY2Axis = _useY2;
1173  }
1174 
1178  bool GetY2Axis() const
1179  {
1180  return m_UseY2Axis;
1181  }
1182 
1183  protected:
1185  mpSymbol m_symbol;
1188  unsigned int m_step;
1190 
1191  wxDECLARE_DYNAMIC_CLASS(mpFunction);
1192 };
1193 
1196 class WXDLLIMPEXP_MATHPLOT mpLine: public mpFunction
1197 {
1198  public:
1199  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1200 
1201  // We don't want to include line (horizontal or vertical) in BBox computation
1202  virtual bool HasBBox() override
1203  {
1204  return false;
1205  }
1206 
1210  double GetValue() const
1211  {
1212  return m_value;
1213  }
1214 
1218  void SetValue(const double value)
1219  {
1220  m_value = value;
1221  }
1222 
1225  bool IsHorizontal(void) const
1226  {
1227  return m_IsHorizontal;
1228  }
1229 
1230  protected:
1231  double m_value;
1232  bool m_IsHorizontal;
1233 
1234  wxDECLARE_DYNAMIC_CLASS(mpLine);
1235 };
1236 
1239 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine: public mpLine
1240 {
1241  public:
1242  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, bool useY2Axis = false);
1243 
1247  void SetYValue(const double yvalue)
1248  {
1249  SetValue(yvalue);
1250  }
1251 
1252  protected:
1253 
1254  virtual void DoPlot(wxDC &dc, mpWindow &w);
1255 
1256  wxDECLARE_DYNAMIC_CLASS(mpHorizontalLine);
1257 };
1258 
1261 class WXDLLIMPEXP_MATHPLOT mpVerticalLine: public mpLine
1262 {
1263  public:
1264  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1265 
1269  void SetXValue(const double xvalue)
1270  {
1271  SetValue(xvalue);
1272  }
1273 
1274  protected:
1275 
1276  virtual void DoPlot(wxDC &dc, mpWindow &w);
1277 
1278  wxDECLARE_DYNAMIC_CLASS(mpVerticalLine);
1279 };
1280 
1287 class WXDLLIMPEXP_MATHPLOT mpFX: public mpFunction
1288 {
1289  public:
1293  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, bool useY2Axis = false);
1294 
1300  virtual double GetY(double x) = 0;
1301 
1305  double DoGetY(double x);
1306 
1307  protected:
1308 
1313  virtual void DoPlot(wxDC &dc, mpWindow &w);
1314 
1315  wxDECLARE_DYNAMIC_CLASS(mpFX);
1316 };
1317 
1324 class WXDLLIMPEXP_MATHPLOT mpFY: public mpFunction
1325 {
1326  public:
1330  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, bool useY2Axis = false);
1331 
1337  virtual double GetX(double y) = 0;
1338 
1342  double DoGetX(double y);
1343 
1344  protected:
1345 
1350  virtual void DoPlot(wxDC &dc, mpWindow &w);
1351 
1352  wxDECLARE_DYNAMIC_CLASS(mpFY);
1353 };
1354 
1364 class WXDLLIMPEXP_MATHPLOT mpFXY: public mpFunction
1365 {
1366  public:
1370  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, bool useY2Axis = false);
1371 
1375  virtual void Rewind() = 0;
1376 
1380  virtual void Clear()
1381  {
1382  ;
1383  }
1384 
1388  virtual int GetSize()
1389  {
1390  return 0;
1391  }
1392 
1399  virtual bool GetNextXY(double *x, double *y) = 0;
1400 
1404  bool DoGetNextXY(double *x, double *y);
1405 
1409  void SetViewMode(bool asBar);
1410 
1414  int GetBarWidth(void) const
1415  {
1416  return m_BarWidth;
1417  }
1418 
1422  bool ViewAsBar(void) const
1423  {
1424  return m_ViewAsBar;
1425  }
1426 
1427  protected:
1428 
1429  // Data to calculate label positioning
1430  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
1431 
1432  // Min delta between 2 x coordinate (used for view as bar)
1433  double m_deltaX, m_deltaY;
1434 
1435  // The width of a bar
1436  int m_BarWidth;
1437 
1438  // Plot data as bar graph
1439  bool m_ViewAsBar = false;
1440 
1441  // Can the series be deleted?
1442  bool m_CanDelete = true;
1443 
1448  virtual void DoPlot(wxDC &dc, mpWindow &w);
1449 
1454  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
1455 
1456  wxDECLARE_DYNAMIC_CLASS(mpFXY);
1457 };
1458 
1459 //-----------------------------------------------------------------------------
1460 // mpFXYVector - provided by Jose Luis Blanco
1461 //-----------------------------------------------------------------------------
1462 
1482 class WXDLLIMPEXP_MATHPLOT mpFXYVector: public mpFXY
1483 {
1484  public:
1488  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, bool useY2Axis = false);
1489 
1492  virtual ~mpFXYVector()
1493  {
1494  Clear();
1495  }
1496 
1501  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
1502 
1506  void Clear();
1507 
1512  virtual int GetSize()
1513  {
1514  return m_xs.size();
1515  }
1516 
1524  bool AddData(const double x, const double y, bool updatePlot);
1525 
1531  void SetReserve(int reserve)
1532  {
1533  m_reserveXY = reserve;
1534  m_xs.reserve(m_reserveXY);
1535  m_ys.reserve(m_reserveXY);
1536  }
1537 
1540  int GetReserve() const
1541  {
1542  return m_reserveXY;
1543  }
1544 
1545  protected:
1548  std::vector<double> m_xs, m_ys;
1549 
1553 
1556  size_t m_index;
1557 
1560  double m_minX, m_maxX, m_minY, m_maxY, m_lastX, m_lastY;
1561 
1565  inline void Rewind()
1566  {
1567  m_index = 0;
1568  }
1569 
1575  virtual bool GetNextXY(double *x, double *y);
1576 
1579  void DrawAddedPoint(double x, double y);
1580 
1583  virtual double GetMinX()
1584  {
1585  return m_minX;
1586  }
1587 
1590  virtual double GetMinY()
1591  {
1592  return m_minY;
1593  }
1594 
1597  virtual double GetMaxX()
1598  {
1599  return m_maxX;
1600  }
1601 
1604  virtual double GetMaxY()
1605  {
1606  return m_maxY;
1607  }
1608 
1609  private:
1612  void First_Point(double x, double y);
1613 
1616  void Check_Limit(double val, double *min, double *max, double *last, double *delta);
1617 
1618  wxDECLARE_DYNAMIC_CLASS(mpFXYVector);
1619 };
1620 
1629 class WXDLLIMPEXP_MATHPLOT mpProfile: public mpFunction
1630 {
1631  public:
1635  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
1636 
1642  virtual double GetY(double x) = 0;
1643 
1644  protected:
1645 
1650  virtual void DoPlot(wxDC &dc, mpWindow &w);
1651 
1652  wxDECLARE_DYNAMIC_CLASS(mpProfile);
1653 };
1654 
1655 //-----------------------------------------------------------------------------
1656 // mpChart
1657 //-----------------------------------------------------------------------------
1660 class WXDLLIMPEXP_MATHPLOT mpChart: public mpFunction
1661 {
1662  public:
1664  mpChart(const wxString &name = wxEmptyString);
1665 
1668  {
1669  Clear();
1670  }
1671 
1674  void SetChartValues(const std::vector<double> &data);
1675 
1678  void SetChartLabels(const std::vector<std::string> &labelArray);
1679 
1684  void AddData(const double &data, const std::string &label);
1685 
1689  virtual void Clear();
1690 
1691  virtual bool HasBBox()
1692  {
1693  return (values.size() > 0);
1694  }
1695 
1696  protected:
1697  std::vector<double> values;
1698  std::vector<std::string> labels;
1699 
1700  double m_max_value;
1701  double m_total_value;
1702 
1703  wxDECLARE_DYNAMIC_CLASS(mpChart);
1704 };
1705 
1706 //-----------------------------------------------------------------------------
1707 // mpBarChart - provided by Jose Davide Rondini
1708 //-----------------------------------------------------------------------------
1709 /* Defines for bar charts label positioning. */
1710 #define mpBAR_NONE 0
1711 #define mpBAR_AXIS_H 1
1712 #define mpBAR_AXIS_V 2
1713 #define mpBAR_INSIDE 3
1714 #define mpBAR_TOP 4
1715 
1716 
1718 class WXDLLIMPEXP_MATHPLOT mpBarChart: public mpChart
1719 {
1720  public:
1722  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
1723 
1726  {
1727  Clear();
1728  }
1729 
1730  void SetBarColour(const wxColour &colour);
1731 
1732  void SetColumnWidth(const double colWidth)
1733  {
1734  m_width = colWidth;
1735  }
1736 
1738  void SetBarLabelPosition(int position);
1739 
1743  virtual double GetMinX();
1744 
1748  virtual double GetMaxX();
1749 
1753  virtual double GetMinY();
1754 
1758  virtual double GetMaxY();
1759 
1760  protected:
1761 
1762  double m_width;
1763  wxColour m_barColour;
1764  int m_labelPos;
1765  double m_labelAngle;
1766 
1771  virtual void DoPlot(wxDC &dc, mpWindow &w);
1772 
1773  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
1774 };
1775 
1780 class WXDLLIMPEXP_MATHPLOT mpPieChart: public mpChart
1781 {
1782  public:
1784  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
1785 
1788  {
1789  Clear();
1790  colours.clear();
1791  }
1792 
1796  void SetPieColours(const std::vector<wxColour> &colourArray);
1797 
1801  virtual double GetMinX()
1802  {
1803  return -m_radius;
1804  }
1805 
1809  virtual double GetMaxX()
1810  {
1811  return m_radius;
1812  }
1813 
1817  virtual double GetMinY()
1818  {
1819  return -m_radius;
1820  }
1821 
1825  virtual double GetMaxY()
1826  {
1827  return m_radius;
1828  }
1829 
1830  protected:
1831 
1832  double m_radius;
1833  std::vector<wxColour> colours;
1834 
1839  virtual void DoPlot(wxDC &dc, mpWindow &w);
1840 
1841  const wxColour& GetColour(unsigned int id);
1842 
1843  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
1844 };
1845 
1848 //-----------------------------------------------------------------------------
1849 // mpLayer implementations - furniture (scales, ...)
1850 //-----------------------------------------------------------------------------
1857 class WXDLLIMPEXP_MATHPLOT mpScale: public mpLayer
1858 {
1859  public:
1864  mpScale(const wxString &name, int flags, bool grids);
1865 
1869  virtual bool HasBBox()
1870  {
1871  return false;
1872  }
1873 
1876  void ShowTicks(bool ticks)
1877  {
1878  m_ticks = ticks;
1879  }
1880 
1883  bool GetShowTicks() const
1884  {
1885  return m_ticks;
1886  }
1887 
1890  void ShowGrids(bool grids)
1891  {
1892  m_grids = grids;
1893  }
1894 
1897  bool GetShowGrids() const
1898  {
1899  return m_grids;
1900  }
1901 
1904  virtual void SetLabelFormat(const wxString &format)
1905  {
1906  m_labelFormat = format;
1907  }
1908 
1911  const wxString& GetLabelFormat() const
1912  {
1913  return m_labelFormat;
1914  }
1915 
1919  void SetGridPen(const wxPen &pen)
1920  {
1921  m_gridpen = pen;
1922  }
1923 
1927  const wxPen& GetGridPen() const
1928  {
1929  return m_gridpen;
1930  }
1931 
1935  void SetAuto(bool automaticScalingIsEnabled)
1936  {
1937  m_auto = automaticScalingIsEnabled;
1938  }
1939 
1943  bool GetAuto() const
1944  {
1945  return m_auto;
1946  }
1947 
1948  void SetMinScale(double min)
1949  {
1950  m_min = min;
1951  }
1952 
1953  double GetMinScale() const
1954  {
1955  return m_min;
1956  }
1957 
1958  void SetMaxScale(double max)
1959  {
1960  m_max = max;
1961  }
1962 
1963  double GetMaxScale() const
1964  {
1965  return m_max;
1966  }
1967 
1968  virtual bool IsLogAxis() = 0;
1969  virtual void SetLogAxis(bool log) = 0;
1970 
1971  protected:
1972  wxPen m_gridpen;
1973  bool m_ticks;
1974  bool m_grids;
1975  bool m_auto;
1976  double m_min, m_max;
1977  wxString m_labelFormat;
1978 
1979  virtual int GetOrigin(mpWindow &w) = 0;
1980  double GetStep(double scale);
1981  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
1982 
1983  wxString FormatLogValue(double n);
1984 
1985  wxDECLARE_DYNAMIC_CLASS(mpScale);
1986 };
1987 
1989 #define mpX_NORMAL 0x00
1990 
1992 #define mpX_TIME 0x01
1993 
1994 #define mpX_HOURS 0x02
1995 
1996 #define mpX_DATE 0x03
1997 
1998 #define mpX_DATETIME 0x04
1999 
2000 #define mpX_USER 0x05
2001 
2002 #define mpX_NONE 0x06
2003 
2009 class WXDLLIMPEXP_MATHPLOT mpScaleX: public mpScale
2010 {
2011  public:
2017  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, unsigned int type = mpX_NORMAL) :
2018  mpScale(name, flags, grids)
2019  {
2020  m_subtype = mpsScaleX;
2021  m_labelType = type;
2022  m_timeConv = mpX_RAWTIME;
2023  }
2024 
2025  virtual void SetLabelFormat(const wxString &format)
2026  {
2027  mpScale::SetLabelFormat(format);
2028  m_labelType = mpX_USER;
2029  }
2030 
2033  unsigned int GetLabelMode() const
2034  {
2035  return m_labelType;
2036  }
2037 
2040  void SetLabelMode(unsigned int mode, unsigned int time_conv = mpX_RAWTIME)
2041  {
2042  m_labelType = mode;
2043  m_timeConv = time_conv;
2044  }
2045 
2049  virtual bool IsLogAxis();
2050  virtual void SetLogAxis(bool log);
2051 
2052  protected:
2053  unsigned int m_labelType;
2054  unsigned int m_timeConv;
2055 
2058  virtual void DoPlot(wxDC &dc, mpWindow &w);
2059 
2060  virtual int GetOrigin(mpWindow &w);
2061  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2062  wxString FormatValue(const wxString &fmt, double n);
2063 
2064  wxDECLARE_DYNAMIC_CLASS(mpScaleX);
2065 };
2066 
2073 class WXDLLIMPEXP_MATHPLOT mpScaleY: public mpScale
2074 {
2075  public:
2081  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, bool Y2Axis = false) :
2082  mpScale(name, flags, grids)
2083  {
2084  m_subtype = mpsScaleY;
2085  m_isY2Axis = Y2Axis;
2086  }
2087 
2091  virtual bool IsLogAxis();
2092  virtual void SetLogAxis(bool log);
2093 
2094  virtual bool IsY2Axis()
2095  {
2096  return m_isY2Axis;
2097  }
2098  virtual void SetY2Axis(bool y2Axis);
2099 
2100  protected:
2101  bool m_isY2Axis;
2102 
2105  virtual void DoPlot(wxDC &dc, mpWindow &w);
2106 
2107  virtual int GetOrigin(mpWindow &w);
2108  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2109 
2110  wxDECLARE_DYNAMIC_CLASS(mpScaleY);
2111 };
2112 
2113 //-----------------------------------------------------------------------------
2114 // mpWindow
2115 //-----------------------------------------------------------------------------
2116 
2121 #define mpMOUSEMODE_DRAG 0
2122 
2123 #define mpMOUSEMODE_ZOOMBOX 1
2124 
2127 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
2128 typedef std::deque<mpLayer*> mpLayerList;
2129 
2136 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
2137 
2144 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
2145 
2150 {
2151  public:
2152  mpMagnet()
2153  {
2154  m_IsDrawn = false;
2155  m_rightClick = false;
2156  m_IsWasDrawn = false;
2157  }
2158  ~mpMagnet()
2159  {
2160  ;
2161  }
2162  void UpdateBox(wxCoord left, wxCoord top, wxCoord width, wxCoord height)
2163  {
2164  m_domain = wxRect(left, top, width, height);
2165  m_plot_size = wxRect(left, top, width + left, height + top);
2166  }
2167  void UpdateBox(const wxRect &size)
2168  {
2169  m_domain = size;
2170  m_plot_size = wxRect(size.GetLeft(), size.GetTop(),
2171  size.GetWidth() + size.GetLeft(), size.GetHeight() + size.GetTop());
2172  }
2173  void Plot(wxClientDC &dc, const wxPoint &mousePos);
2174  void ClearPlot(wxClientDC &dc);
2175  void UpdatePlot(wxClientDC &dc, const wxPoint &mousePos);
2176  void SaveDrawState(void)
2177  {
2178  m_IsWasDrawn = m_IsDrawn;
2179  // In any cases, set to false because we erase and repaint all the plot
2180  m_IsDrawn = false;
2181  }
2182 
2183  void SetRightClick(void)
2184  {
2185  m_rightClick = true;
2186  }
2187 
2188  private:
2189  wxRect m_domain;
2190  wxRect m_plot_size;
2191  wxPoint m_mousePosition;
2192  bool m_IsDrawn;
2193  bool m_IsWasDrawn;
2194  bool m_rightClick;
2195  void DrawCross(wxClientDC &dc) const;
2196 };
2197 
2219 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
2220 {
2221  public:
2222  mpWindow()
2223  {
2224  InitParameters();
2225  }
2226 
2227  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
2228  long flags = 0);
2229 
2230  ~mpWindow();
2231 
2235  wxMenu* GetPopupMenu()
2236  {
2237  return &m_popmenu;
2238  }
2239 
2247  bool AddLayer(mpLayer *layer, bool refreshDisplay = true);
2248 
2258  bool DelLayer(mpLayer *layer, bool alsoDeleteObject, bool refreshDisplay = true);
2259 
2264  void DelAllLayers(bool alsoDeleteObject, bool refreshDisplay = true);
2265 
2271  void DelAllPlot(bool alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
2272 
2278  mpLayer* GetLayer(int position);
2279 
2286  mpLayer* GetLayersType(int position, mpLayerType type);
2287 
2293  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
2294 
2297  mpLayer* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
2298 
2303  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
2304 
2308  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear, bool *isY2Axis);
2309 
2314  mpLayer* GetLayerByName(const wxString &name);
2315 
2320  mpLayer* GetLayerByClassName(const wxString &name);
2321 
2325  void RefreshLegend(void);
2326 
2330  mpScaleX* GetLayerXAxis();
2331 
2335  mpScaleY* GetLayerYAxis();
2336 
2340  mpScaleY* GetLayerY2Axis();
2341 
2345  void SetScaleX(const double scaleX)
2346  {
2347  if (ISNOTNULL(scaleX))
2348  m_scaleX = scaleX;
2349  UpdateAll();
2350  }
2351 
2356  double GetScaleX(void) const
2357  {
2358  return m_scaleX;
2359  }
2360 
2364  void SetScaleY(const double scaleY)
2365  {
2366  if (ISNOTNULL(scaleY))
2367  m_scaleY = scaleY;
2368  UpdateAll();
2369  }
2370 
2375  double GetScaleY(bool Y2 = false) const
2376  {
2377  if (Y2)
2378  return m_scaleY2;
2379  else
2380  return m_scaleY;
2381  } // Schaling's method: maybe another method exists with the same name
2382 
2383  [[deprecated("Incomplete, use UpdateBBox instead")]]
2386  void SetBound();
2387 
2390  {
2391  return m_bound;
2392  }
2393 
2397  void SetPosX(const double posX)
2398  {
2399  m_posX = posX;
2400  UpdateAll();
2401  }
2402 
2407  double GetPosX(void) const
2408  {
2409  return m_posX;
2410  }
2411 
2415  void SetPosY(const double posY, const double posY2)
2416  {
2417  m_posY = posY;
2418  m_posY2 = posY2;
2419  UpdateAll();
2420  }
2421 
2426  double GetPosY(bool Y2 = false) const
2427  {
2428  if (Y2)
2429  return m_posY2;
2430  else
2431  return m_posY;
2432  }
2433 
2439  void SetScreen(const int scrX, const int scrY)
2440  {
2441  m_scrX = scrX;
2442  m_scrY = scrY;
2443  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
2444  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
2445 
2446  m_plotBoundaries.endPx = m_scrX;
2447  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
2448  m_plotBoundaries.endPy = m_scrY;
2449  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
2450 
2451  m_PlotArea = wxRect(m_margin.left - EXTRA_MARGIN, m_margin.top - EXTRA_MARGIN,
2452  m_plotWidth + 2*EXTRA_MARGIN, m_plotHeight + 2*EXTRA_MARGIN);
2453 
2454  m_magnet.UpdateBox(m_PlotArea);
2455  }
2456 
2463  int GetScreenX(void) const
2464  {
2465  return m_scrX;
2466  }
2467 
2474  int GetScreenY(void) const
2475  {
2476  return m_scrY;
2477  }
2478 
2483  void SetPos(const double posX, const double posY, const double posY2)
2484  {
2485  m_posX = posX;
2486  m_posY = posY;
2487  m_posY2 = posY2;
2488  UpdateAll();
2489  }
2490 
2494  inline double p2x(const wxCoord pixelCoordX) const
2495  {
2496  return m_posX + pixelCoordX / m_scaleX;
2497  }
2498 
2502  inline double p2y(const wxCoord pixelCoordY, bool Y2 = false) const
2503  {
2504  if (Y2)
2505  return m_posY2 - pixelCoordY / m_scaleY2;
2506  else
2507  return m_posY - pixelCoordY / m_scaleY;
2508  }
2509 
2513  inline wxCoord x2p(const double x) const
2514  {
2515  return (wxCoord)((x - m_posX) * m_scaleX);
2516  }
2517 
2521  inline wxCoord y2p(const double y, bool Y2 = false) const
2522  {
2523  if (Y2)
2524  return (wxCoord)((m_posY2 - y) * m_scaleY2);
2525  else
2526  return (wxCoord)((m_posY - y) * m_scaleY);
2527  }
2528 
2531  void EnableDoubleBuffer(const bool enabled)
2532  {
2533  m_enableDoubleBuffer = enabled;
2534  }
2535 
2538  void EnableMousePanZoom(const bool enabled)
2539  {
2540  m_enableMouseNavigation = enabled;
2541  }
2542 
2548  void LockAspect(bool enable = true);
2549 
2554  inline bool IsAspectLocked() const
2555  {
2556  return m_lockaspect;
2557  }
2558 
2563  inline bool IsRepainting() const
2564  {
2565  return m_repainting;
2566  }
2567 
2572  void Fit();
2573 
2580  void Fit(const mpFloatRect &rect, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
2581 
2586  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
2587 
2592  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
2593 
2595  void ZoomInX();
2596 
2598  void ZoomOutX();
2599 
2601  void ZoomInY();
2602 
2604  void ZoomOutY();
2605 
2607  void ZoomRect(wxPoint p0, wxPoint p1);
2608 
2610  void UpdateAll();
2611 
2612  // Added methods by Davide Rondini
2613 
2617  unsigned int CountLayers();
2618 
2621  unsigned int CountAllLayers()
2622  {
2623  return (unsigned int)m_layers.size();
2624  }
2625 
2629  unsigned int CountLayersType(mpLayerType type);
2630  unsigned int CountLayersFXYPlot();
2631 
2634  //void PrintGraph(mpPrintout *print);
2635 
2638  mpFloatRect GetDesiredBoundingBox() const { return m_desired; }
2639 
2643  double GetDesiredXmin() const
2644  {
2645  return m_desired.Xmin;
2646  }
2647 
2652  double GetDesiredXmax() const
2653  {
2654  return m_desired.Xmax;
2655  }
2656 
2661  double GetDesiredYmin() const
2662  {
2663  return m_desired.Ymin;
2664  }
2665 
2670  double GetDesiredYmax() const
2671  {
2672  return m_desired.Ymax;
2673  }
2674 
2677  void GetBoundingBox(double *bbox) const;
2678  mpFloatRect *GetBoundingBox(void)
2679  {
2680  return &m_bound;
2681  }
2682 
2685  void SetMPScrollbars(bool status);
2686 
2689  bool GetMPScrollbars() const
2690  {
2691  return m_enableScrollBars;
2692  }
2693 
2699  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
2700 
2704  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
2705 
2709  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
2710 
2715  bool LoadFile(const wxString &filename);
2716 
2720 
2727  void SetMargins(int top, int right, int bottom, int left);
2728 
2730  void SetMarginTop(int top)
2731  {
2732  SetMargins(top, m_margin.right, m_margin.bottom, m_margin.left);
2733  }
2734 
2736  int GetMarginTop() const
2737  {
2738  return m_margin.top;
2739  }
2740 
2742  void SetMarginRight(int right)
2743  {
2744  SetMargins(m_margin.top, right, m_margin.bottom, m_margin.left);
2745  }
2746 
2748  int GetMarginRight() const
2749  {
2750  return m_margin.right;
2751  }
2752 
2754  void SetMarginBottom(int bottom)
2755  {
2756  SetMargins(m_margin.top, m_margin.right, bottom, m_margin.left);
2757  }
2758 
2760  int GetMarginBottom() const
2761  {
2762  return m_margin.bottom;
2763  }
2764 
2766  void SetMarginLeft(int left)
2767  {
2768  SetMargins(m_margin.top, m_margin.right, m_margin.bottom, left);
2769  }
2770 
2772  int GetMarginLeft() const
2773  {
2774  return m_margin.left;
2775  }
2776 
2778  int GetPlotWidth() const
2779  {
2780  return m_plotWidth;
2781  }
2782 
2784  int GetPlotHeight() const
2785  {
2786  return m_plotHeight;
2787  }
2788 
2790  mpRect GetPlotBoundaries(bool with_margin) const
2791  {
2792  mpRect bond;
2793  if (with_margin)
2794  bond = m_plotBoundariesMargin;
2795  else
2796  bond = m_plotBoundaries;
2797  bond.startPx -= EXTRA_MARGIN;
2798  bond.endPx += EXTRA_MARGIN;
2799  bond.startPy -= EXTRA_MARGIN;
2800  bond.endPy += EXTRA_MARGIN;
2801  return bond;
2802  }
2803 
2805  void SetDrawBox(bool drawbox)
2806  {
2807  m_drawBox = drawbox;
2808  }
2809 
2811  bool GetDrawBox() const
2812  {
2813  return m_drawBox;
2814  }
2815 
2819  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
2820 
2824  void SetLayerVisible(const wxString &name, bool viewable);
2825 
2829  bool IsLayerVisible(const wxString &name);
2830 
2834  bool IsLayerVisible(const unsigned int position);
2835 
2839  void SetLayerVisible(const unsigned int position, bool viewable);
2840 
2845  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
2846 
2849  const wxColour& GetAxesColour() const
2850  {
2851  return m_axColour;
2852  }
2853 
2854  const wxColour& GetbgColour() const
2855  {
2856  return m_bgColour;
2857  }
2858 
2859  void SetbgColour(const wxColour &colour)
2860  {
2861  m_bgColour = colour;
2862  }
2863 
2868  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
2869  {
2870  m_OnDeleteLayer = event;
2871  }
2872 
2875  {
2876  m_OnDeleteLayer = NULL;
2877  }
2878 
2883  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
2884  {
2885  m_OnUserMouseAction = userMouseEventHandler;
2886  }
2887 
2890  {
2891  m_OnUserMouseAction = NULL;
2892  }
2893 
2899  bool IsLogXaxis() const
2900  {
2901  return m_LogXaxis;
2902  }
2903 
2904  bool IsLogYaxis() const
2905  {
2906  return m_LogYaxis;
2907  }
2908 
2909  void SetLogXaxis(bool log)
2910  {
2911  m_LogXaxis = log;
2912  }
2913 
2914  void SetLogYaxis(bool log)
2915  {
2916  m_LogYaxis = log;
2917  }
2918 
2919  bool GetMagnetize() const
2920  {
2921  return m_magnetize;
2922  }
2923 
2924  void SetMagnetize(bool mag)
2925  {
2926  m_magnetize = mag;
2927  }
2928 
2929 #ifdef ENABLE_MP_CONFIG
2930  void RefreshConfigWindow();
2935  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
2936 #endif // ENABLE_MP_CONFIG
2937 
2938  void Update_CountY2Axis(bool Y2Axis);
2939 
2940  bool Y2AxisExist(void) const
2941  {
2942  return m_countY2Axis > 0;
2943  }
2944 
2945  protected:
2946  virtual void OnPaint(wxPaintEvent &event);
2947  virtual void OnSize(wxSizeEvent &event);
2948  virtual void OnShowPopupMenu(wxMouseEvent &event);
2949  virtual void OnCenter(wxCommandEvent &event);
2950  virtual void OnFit(wxCommandEvent &event);
2951  virtual void OnToggleGrids(wxCommandEvent &event);
2952  virtual void OnToggleCoords(wxCommandEvent &event);
2953  virtual void OnScreenShot(wxCommandEvent &event);
2954  virtual void OnFullScreen(wxCommandEvent &event);
2955 #ifdef ENABLE_MP_CONFIG
2956  virtual void OnConfiguration(wxCommandEvent &event);
2957 #endif // ENABLE_MP_CONFIG
2958  virtual void OnLoadFile(wxCommandEvent &event);
2959  virtual void OnZoomIn(wxCommandEvent &event);
2960  virtual void OnZoomOut(wxCommandEvent &event);
2961  virtual void OnLockAspect(wxCommandEvent &event);
2962  virtual void OnMouseHelp(wxCommandEvent &event);
2963  virtual void OnMouseLeftDown(wxMouseEvent &event);
2964  virtual void OnMouseRightDown(wxMouseEvent &event);
2965  virtual void OnMouseMove(wxMouseEvent &event);
2966  virtual void OnMouseLeftRelease(wxMouseEvent &event);
2967  virtual void OnMouseWheel(wxMouseEvent &event);
2968  virtual void OnMouseLeave(wxMouseEvent &event);
2969  bool CheckUserMouseAction(wxMouseEvent &event);
2970  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
2971  virtual void OnScrollPageUp(wxScrollWinEvent &event);
2972  virtual void OnScrollPageDown(wxScrollWinEvent &event);
2973  virtual void OnScrollLineUp(wxScrollWinEvent &event);
2974  virtual void OnScrollLineDown(wxScrollWinEvent &event);
2975  virtual void OnScrollTop(wxScrollWinEvent &event);
2976  virtual void OnScrollBottom(wxScrollWinEvent &event);
2977 
2978  void DoScrollCalc(const int position, const int orientation);
2979 
2980  void DoZoomInXCalc(const int staticXpixel);
2981  void DoZoomInYCalc(const int staticYpixel);
2982  void DoZoomOutXCalc(const int staticXpixel);
2983  void DoZoomOutYCalc(const int staticYpixel);
2984 
2985  void Zoom(bool zoomIn, const wxPoint &centerPoint);
2986 
2989  virtual bool UpdateBBox();
2990 
2991  void InitParameters();
2992 
2993  wxTopLevelWindow* m_parent;
2994  bool m_fullscreen;
2995 
2996  mpLayerList m_layers;
3000 
3001  wxMenu m_popmenu;
3003  wxColour m_bgColour;
3004  wxColour m_fgColour;
3005  wxColour m_axColour;
3006  bool m_drawBox;
3007 
3009  double m_scaleX;
3010  double m_scaleY;
3011  double m_scaleY2;
3012  double m_posX;
3013  double m_posY;
3014  double m_posY2;
3015  int m_scrX;
3016  int m_scrY;
3019 
3024 
3026  wxCoord m_plotWidth;
3027  wxCoord m_plotHeight;
3028 
3031  wxRect m_PlotArea;
3032 
3033  bool m_repainting;
3034  int m_last_lx, m_last_ly;
3035  wxBitmap* m_buff_bmp;
3038  bool m_mouseMovedAfterRightClick;
3039  wxPoint m_mouseRClick;
3040  wxPoint m_mouseLClick;
3041  bool m_enableScrollBars;
3042  int m_scrollX, m_scrollY;
3046  bool m_InInfoLegend;
3047 
3048  wxBitmap* m_zoom_bmp;
3049  wxRect m_zoom_dim;
3050  wxRect m_zoom_oldDim;
3051 
3054 
3055  bool m_LogXaxis = false;
3056  bool m_LogYaxis = false;
3057 
3058  wxBitmap* m_Screenshot_bmp;
3059 
3060 #ifdef ENABLE_MP_CONFIG
3061  MathPlotConfigDialog* m_configWindow = NULL;
3062 #endif // ENABLE_MP_CONFIG
3063 
3064  mpOnDeleteLayer m_OnDeleteLayer = NULL;
3065  mpOnUserMouseAction m_OnUserMouseAction = NULL;
3066 
3070  virtual void DesiredBoundsHaveChanged() {};
3071 
3072  private:
3073  int m_countY2Axis = 0;
3074  void FillI18NString();
3075 
3077  void CheckAndReportDesiredBoundsChanges();
3078  bool m_initialDesiredBoundsRecorded = false;
3079  mpFloatRect m_lastDesiredReportedBounds;
3080 
3081  wxDECLARE_DYNAMIC_CLASS(mpWindow);
3082  wxDECLARE_EVENT_TABLE();
3083 
3084  // To have direct access to m_Screenshot_dc
3085  friend mpPrintout;
3086 };
3087 
3088 //-----------------------------------------------------------------------------
3089 // mpText - provided by Val Greene
3090 //-----------------------------------------------------------------------------
3091 
3099 class WXDLLIMPEXP_MATHPLOT mpText: public mpLayer
3100 {
3101  public:
3104  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
3105  {
3106  m_subtype = mptText;
3107  SetName(name);
3108  m_offsetx = 5;
3109  m_offsety = 50;
3110  m_location = mpMarginNone;
3111  m_ZIndex = mpZIndex_TEXT;
3112  }
3113 
3117  mpText(const wxString &name, int offsetx, int offsety);
3118 
3122  mpText(const wxString &name, mpLocation marginLocation);
3123 
3126  virtual bool HasBBox()
3127  {
3128  return false;
3129  }
3130 
3133  void SetLocation(mpLocation location)
3134  {
3135  m_location = location;
3136  }
3137 
3140  mpLocation GetLocation() const
3141  {
3142  return m_location;
3143  }
3144 
3147  void SetOffset(int offX, int offY)
3148  {
3149  m_offsetx = offX;
3150  m_offsety = offY;
3151  }
3152 
3155  void GetOffset(int *offX, int *offY) const
3156  {
3157  *offX = m_offsetx;
3158  *offY = m_offsety;
3159  }
3160 
3161  protected:
3164  mpLocation m_location;
3165 
3168  virtual void DoPlot(wxDC &dc, mpWindow &w);
3169 
3170  wxDECLARE_DYNAMIC_CLASS(mpText);
3171 };
3172 
3176 class WXDLLIMPEXP_MATHPLOT mpTitle: public mpText
3177 {
3178  public:
3181  mpTitle();
3182 
3185  mpTitle(const wxString &name) :
3186  mpText(name, mpMarginTopCenter)
3187  {
3188  m_subtype = mptTitle;
3189  SetPen(*wxWHITE_PEN);
3190  SetBrush(*wxWHITE_BRUSH);
3191  }
3192 
3193  protected:
3194 
3195  wxDECLARE_DYNAMIC_CLASS(mpTitle);
3196 };
3197 
3198 //-----------------------------------------------------------------------------
3199 // mpPrintout - provided by Davide Rondini
3200 //-----------------------------------------------------------------------------
3201 
3206 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
3207 {
3208  public:
3209  mpPrintout()
3210  {
3211  plotWindow = NULL;
3212  drawn = false;
3213  stretch_factor = 2;
3214  }
3215 
3216  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
3217  virtual ~mpPrintout()
3218  {
3219  ;
3220  }
3221 
3222  void SetDrawState(bool drawState)
3223  {
3224  drawn = drawState;
3225  }
3226 
3227  bool OnPrintPage(int page);
3228  bool HasPage(int page);
3229 
3232  void SetFactor(int factor)
3233  {
3234  stretch_factor = factor;
3235  }
3236 
3237  private:
3238  bool drawn;
3239  mpWindow* plotWindow;
3240  int stretch_factor; // To reduce the size of plot
3241 
3242  protected:
3243 
3244  wxDECLARE_DYNAMIC_CLASS(mpPrintout);
3245 };
3246 
3247 //-----------------------------------------------------------------------------
3248 // mpMovableObject - provided by Jose Luis Blanco
3249 //-----------------------------------------------------------------------------
3257 class WXDLLIMPEXP_MATHPLOT mpMovableObject: public mpFunction
3258 {
3259  public:
3263  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
3264  {
3265  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
3266  m_subtype = mpfMovable;
3267  m_bbox_min_x = m_bbox_max_x = 0;
3268  m_bbox_min_y = m_bbox_max_y = 0;
3269  }
3270 
3271  virtual ~mpMovableObject() {}
3272 
3275  void GetCoordinateBase(double &x, double &y, double &phi) const
3276  {
3277  x = m_reference_x;
3278  y = m_reference_y;
3279  phi = m_reference_phi;
3280  }
3281 
3284  void SetCoordinateBase(double x, double y, double phi = 0)
3285  {
3286  m_reference_x = x;
3287  m_reference_y = y;
3288  m_reference_phi = phi;
3289  m_flags = mpALIGN_NE;
3290  ShapeUpdated();
3291  }
3292 
3293  virtual bool HasBBox()
3294  {
3295  return m_trans_shape_xs.size() != 0;
3296  }
3297 
3300  virtual double GetMinX()
3301  {
3302  return m_bbox_min_x;
3303  }
3304 
3307  virtual double GetMaxX()
3308  {
3309  return m_bbox_max_x;
3310  }
3311 
3314  virtual double GetMinY()
3315  {
3316  return m_bbox_min_y;
3317  }
3318 
3321  virtual double GetMaxY()
3322  {
3323  return m_bbox_max_y;
3324  }
3325 
3326  protected:
3327 
3330  double m_reference_x, m_reference_y, m_reference_phi;
3331 
3332  virtual void DoPlot(wxDC &dc, mpWindow &w);
3333 
3336  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
3337 
3340  std::vector<double> m_shape_xs, m_shape_ys;
3341 
3345  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
3346 
3350  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
3351 
3355  void ShapeUpdated();
3356 
3357  wxDECLARE_DYNAMIC_CLASS(mpMovableObject);
3358 };
3359 
3360 //-----------------------------------------------------------------------------
3361 // mpCovarianceEllipse - provided by Jose Luis Blanco
3362 //-----------------------------------------------------------------------------
3374 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse: public mpMovableObject
3375 {
3376  public:
3380  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
3381  const wxString &layerName = _T("")) : mpMovableObject(),
3382  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
3383  {
3384  m_continuous = true;
3385  m_name = layerName;
3386  RecalculateShape();
3387  }
3388 
3389  virtual ~mpCovarianceEllipse()
3390  {
3391  ;
3392  }
3393 
3394  double GetQuantiles() const
3395  {
3396  return m_quantiles;
3397  }
3398 
3401  void SetQuantiles(double q)
3402  {
3403  m_quantiles = q;
3404  RecalculateShape();
3405  }
3406 
3407  void SetSegments(int segments)
3408  {
3409  m_segments = segments;
3410  }
3411 
3412  int GetSegments() const
3413  {
3414  return m_segments;
3415  }
3416 
3419  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
3420  {
3421  cov_00 = m_cov_00;
3422  cov_01 = m_cov_01;
3423  cov_11 = m_cov_11;
3424  }
3425 
3428  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
3429  {
3430  m_cov_00 = cov_00;
3431  m_cov_01 = cov_01;
3432  m_cov_11 = cov_11;
3433  RecalculateShape();
3434  }
3435 
3436  protected:
3439  double m_cov_00, m_cov_11, m_cov_01;
3440  double m_quantiles;
3441 
3445 
3448  void RecalculateShape();
3449 
3450  wxDECLARE_DYNAMIC_CLASS(mpCovarianceEllipse);
3451 };
3452 
3453 //-----------------------------------------------------------------------------
3454 // mpPolygon - provided by Jose Luis Blanco
3455 //-----------------------------------------------------------------------------
3460 class WXDLLIMPEXP_MATHPLOT mpPolygon: public mpMovableObject
3461 {
3462  public:
3465  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
3466  {
3467  m_continuous = true;
3468  m_name = layerName;
3469  }
3470 
3471  virtual ~mpPolygon()
3472  {
3473  ;
3474  }
3475 
3481  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
3482 
3483  protected:
3484 
3485  wxDECLARE_DYNAMIC_CLASS(mpPolygon);
3486 };
3487 
3488 //-----------------------------------------------------------------------------
3489 // mpBitmapLayer - provided by Jose Luis Blanco
3490 //-----------------------------------------------------------------------------
3495 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer: public mpLayer
3496 {
3497  public:
3501  {
3502  m_min_x = m_max_x = 0;
3503  m_min_y = m_max_y = 0;
3504  m_validImg = false;
3505  m_bitmapChanged = false;
3506  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
3507  }
3508 
3509  virtual ~mpBitmapLayer()
3510  {
3511  ;
3512  }
3513 
3516  void GetBitmapCopy(wxImage &outBmp) const;
3517 
3525  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
3526 
3529  virtual double GetMinX()
3530  {
3531  return m_min_x;
3532  }
3533 
3536  virtual double GetMaxX()
3537  {
3538  return m_max_x;
3539  }
3540 
3543  virtual double GetMinY()
3544  {
3545  return m_min_y;
3546  }
3547 
3550  virtual double GetMaxY()
3551  {
3552  return m_max_y;
3553  }
3554 
3555  protected:
3556 
3559  wxImage m_bitmap;
3560  wxBitmap m_scaledBitmap;
3561  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
3562  bool m_validImg;
3563  bool m_bitmapChanged;
3564 
3567  double m_min_x, m_max_x, m_min_y, m_max_y;
3568 
3569  virtual void DoPlot(wxDC &dc, mpWindow &w);
3570 
3571  wxDECLARE_DYNAMIC_CLASS(mpBitmapLayer);
3572 };
3573 
3574 // utility class
3575 
3576 // Enumeration of classic colour
3577 typedef enum __mp_Colour
3578 {
3579  mpBlue,
3580  mpRed,
3581  mpGreen,
3582  mpPurple,
3583  mpYellow,
3584  mpFuchsia,
3585  mpLime,
3586  mpAqua,
3587  mpOlive
3588 } mpColour;
3589 
3594 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
3595 {
3596  public:
3597  wxIndexColour(unsigned int id)
3598  {
3599  switch (id)
3600  {
3601  case 0:
3602  this->Set(0, 0, 255);
3603  break; // Blue
3604  case 1:
3605  this->Set(255, 0, 0);
3606  break; // Red
3607  case 2:
3608  this->Set(0, 128, 0);
3609  break; // Green
3610  case 3:
3611  this->Set(128, 0, 128);
3612  break; // Purple
3613  case 4:
3614  this->Set(255, 255, 0);
3615  break; // Yellow
3616  case 5:
3617  this->Set(255, 0, 255);
3618  break; // Fuchsia
3619  case 6:
3620  this->Set(0, 255, 0);
3621  break; // Lime
3622  case 7:
3623  this->Set(0, 255, 255);
3624  break; // Aqua/Cyan
3625  case 8:
3626  this->Set(128, 128, 0);
3627  break; // Olive
3628  default:
3629  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
3630  (ChannelType)((rand() * 255) / RAND_MAX));
3631  }
3632  }
3633 };
3634 
3637 // ---------------------------------------------------------------------
3638 #ifdef ENABLE_MP_NAMESPACE
3639 }// namespace MathPlot
3640 using namespace MathPlot;
3641 #endif // ENABLE_MP_NAMESPACE
3642 
3643 #endif // _MP_MATHPLOT_H_
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:480
virtual void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:2025
enum MathPlot::__Info_Type mpInfoType
sub_type values for mpLAYER_INFO
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:3559
mpFloatRect Get_Bound(void) const
Get bounding box encompassing all visible plots on this mpWindow.
Definition: mathplot.h:2389
double m_minX
Loaded at SetData.
Definition: mathplot.h:1560
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:3001
unsigned int GetLabelMode() const
Get X axis label view mode.
Definition: mathplot.h:2033
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:3206
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1184
Abstract class providing an vertical line.
Definition: mathplot.h:1261
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:3284
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:1977
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1629
wxCoord y2p(const double y, bool Y2=false) const
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:2521
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:3006
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:2996
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:886
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:3495
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:2463
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:3419
bool GetCanDelete(void) const
Get CanDelete for plot.
Definition: mathplot.h:738
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:3070
bool IsRepainting() const
Checks if we are repainting.
Definition: mathplot.h:2563
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:759
mpTitle(const wxString &name)
Definition: mathplot.h:3185
void SetFont(const wxFont &font)
Set layer font.
Definition: mathplot.h:591
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1135
void SetReserve(int reserve)
Set memory reserved for m_xs and m_ys Note : this does not modify the size of m_xs and m_ys...
Definition: mathplot.h:1531
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:961
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:765
bool m_magnetize
For mouse magnetization.
Definition: mathplot.h:3052
mpCovarianceEllipse(double cov_00=1, double cov_11=1, double cov_01=0, double quantiles=2, int segments=32, const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:3380
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:3133
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:2128
Plot layer, abstract base class.
Definition: mathplot.h:433
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:3005
static double m_zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:2719
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:472
double m_scaleX
Current view&#39;s X scale.
Definition: mathplot.h:3009
int GetMarginRight() const
Get the right margin.
Definition: mathplot.h:2748
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:3104
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:3529
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:3058
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:3465
Layer for pie chart.
Definition: mathplot.h:1780
~mpChart()
Destructor.
Definition: mathplot.h:1667
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1031
unsigned int m_labelType
Select labels mode: mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds.
Definition: mathplot.h:2053
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:2474
Load a file.
Definition: mathplot.h:266
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:1935
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:752
mpFloatRect m_bound
Global layer bounding box in user coordinates. Does NOT include borders.
Definition: mathplot.h:3008
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:1540
int GetMarginLeft() const
Get the left margin.
Definition: mathplot.h:2772
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1556
const wxString & GetLabelFormat() const
Get axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:1911
void SetY2Axis(bool _useY2)
Set use of second Y axis.
Definition: mathplot.h:1170
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:631
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:1825
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1247
wxRect m_PlotArea
The full size of the plot with EXTRA_MARGIN.
Definition: mathplot.h:3031
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:346
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:3350
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1202
wxRect m_oldDim
Keep the old values of m_dim.
Definition: mathplot.h:893
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:3039
double GetDesiredXmax() const
Returns the right-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:2652
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:623
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:3053
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1186
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:615
Class for drawing mouse magnetization.
Definition: mathplot.h:2149
bool operator==(const mpFloatRect &rect) const
Equal operator.
Definition: mathplot.h:240
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:2356
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:1857
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:2689
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:583
Copy a screen shot to the clipboard.
Definition: mathplot.h:262
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:2778
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:2554
int GetMarginBottom() const
Get the bottom margin.
Definition: mathplot.h:2760
wxBitmap * m_buff_bmp
For double buffering.
Definition: mathplot.h:3035
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:879
mpInfoLegend * m_InfoLegend
pointer to the optional info legend layer
Definition: mathplot.h:3045
void SetLabelMode(unsigned int mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:946
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:2730
double GetDesiredXmin() const
Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:2643
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:758
Plot layer implementing a simple title.
Definition: mathplot.h:3176
abstract Layer for chart (bar and pie).
Definition: mathplot.h:1660
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:1380
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:1876
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:954
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:757
double GetPosY(bool Y2=false) const
Get current view&#39;s Y position.
Definition: mathplot.h:2426
virtual bool IsLayerType(mpLayerType type, int *sub_type)
Specifies that if the layer is of type "type".
Definition: mathplot.h:491
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:892
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:2874
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1128
bool ViewAsBar(void) const
return true if XY series is plotted with bar
Definition: mathplot.h:1422
enum MathPlot::__XAxis_Align_Type mpXAxis_Align
Alignment for X axis.
Info box type layer.
Definition: mathplot.h:418
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:3040
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:2407
legend components follow each other horizontally on a single line
Definition: mathplot.h:327
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:2621
void SetValue(const double value)
Set x or y.
Definition: mathplot.h:1218
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:411
virtual void DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:781
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:3163
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:1890
Layer for bar chart.
Definition: mathplot.h:1718
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:1869
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1114
double m_cov_00
The elements of the matrix (only 3 since cov(0,1)=cov(1,0) in any positive definite matrix)...
Definition: mathplot.h:3439
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:1691
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:3002
Axis type layer.
Definition: mathplot.h:414
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:324
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:3321
Bitmap type layer.
Definition: mathplot.h:413
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:307
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:3444
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1142
Abstract class providing an horizontal line.
Definition: mathplot.h:1239
Bitmap type layer.
Definition: mathplot.h:401
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:3027
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:1974
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:755
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:761
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:272
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:3018
void SetFactor(int factor)
Definition: mathplot.h:3232
Show legend items with small square with the same color of referred mpLayer.
Definition: mathplot.h:319
double m_scaleY
Current view&#39;s Y scale.
Definition: mathplot.h:3010
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:167
#define mpX_NORMAL
Set label for X axis in normal mode.
Definition: mathplot.h:1989
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:1388
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:916
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:1943
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:1883
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1096
void EnableDoubleBuffer(const bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled).
Definition: mathplot.h:2531
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:648
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:287
mpInfoCoords * m_InfoCoords
pointer to the optional info coords layer
Definition: mathplot.h:3044
double m_posY2
Current view&#39;s Y2 position.
Definition: mathplot.h:3014
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:766
Axis type layer.
Definition: mathplot.h:397
A structure for computation of bounds in real units (not in screen pixel) X refer to X axis Y refer t...
Definition: mathplot.h:199
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:3594
double p2y(const wxCoord pixelCoordY, bool Y2=false) const
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:2502
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:3300
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:655
Definition: MathPlotConfig.h:46
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:762
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, unsigned int type=0x00)
Full constructor.
Definition: mathplot.h:2017
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:3026
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:764
~mpPieChart()
Destructor.
Definition: mathplot.h:1787
int m_winY
Holds the mpWindow size. Used to rescale position when window is resized.
Definition: mathplot.h:896
mpFloatRect GetDesiredBoundingBox() const
Draws the mpWindow on a page for printing.
Definition: mathplot.h:2638
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:3147
mpScaleY * m_YAxis
Pointer to the optional Y axis layer of this mpWindow.
Definition: mathplot.h:2998
int m_symbolSize2
Size of the symbol div 2.
Definition: mathplot.h:1187
Show/Hide grids.
Definition: mathplot.h:260
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1185
#define mpX_USER
Set label user defined.
Definition: mathplot.h:2000
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:575
enum MathPlot::__mp_Direction_Type mpLegendDirection
Direction for the Legend layer.
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:717
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:751
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1324
int m_reserveXY
Memory reserved for m_xs and m_ys.
Definition: mathplot.h:1552
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1121
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:2219
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:1492
Text box type layer.
Definition: mathplot.h:400
bool IsNotSet() const
Is mpFloatRect set ?
Definition: mathplot.h:233
double GetDesiredYmax() const
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
Definition: mathplot.h:2670
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:3004
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1106
mpScaleY * m_Y2Axis
Pointer to the optional Y2 axis layer of this mpWindow.
Definition: mathplot.h:2999
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:2811
mpRect m_margin
Margin around the plot. Default 50.
Definition: mathplot.h:3025
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1188
bool IsVisible() const
Checks whether the layer is visible or not.
Definition: mathplot.h:689
Lock x/y scaling aspect.
Definition: mathplot.h:259
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:932
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:320
Info box type layer.
Definition: mathplot.h:399
void SetPos(const double posX, const double posY, const double posY2)
Set current view&#39;s X and Y position and refresh display.
Definition: mathplot.h:2483
enum MathPlot::__mp_Layer_ZOrder mpLayerZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1597
Text box type layer.
Definition: mathplot.h:419
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:3015
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:834
double m_posX
Current view&#39;s X position.
Definition: mathplot.h:3012
Center view on click position.
Definition: mathplot.h:258
Show/Hide info coord.
Definition: mathplot.h:261
enum MathPlot::__Text_Type mpTextType
sub_type values for mpLAYER_TEXT
wxSize GetSize() const
Returns the size of the box (in pixels)
Definition: mathplot.h:865
double m_scaleY2
Current view&#39;s Y2 scale.
Definition: mathplot.h:3011
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:268
virtual int GetSize()
Return the number of points in the series We assume that size of m_xs equals size of m_ys...
Definition: mathplot.h:1512
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1590
void UpdateBoundingBoxToInclude(double x, double y, double y2=0)
Update bounding box to include this point.
Definition: mathplot.h:218
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:1919
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:3460
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:2790
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:1000
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1604
double m_max
Min and max axis values when autosize is false.
Definition: mathplot.h:1976
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:3029
int m_flags
Holds label alignment. Default : mpALIGN_NE.
Definition: mathplot.h:763
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:1809
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:508
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:2009
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:2742
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:754
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:3003
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1269
const wxRect & GetRectangle() const
Returns the current rectangle coordinates.
Definition: mathplot.h:872
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:607
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:2849
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:895
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:2883
Abstract class providing a line.
Definition: mathplot.h:1196
void SetItemMode(mpLegendStyle mode)
Set item mode (the element on the left of text representing the plot line may be line or square)...
Definition: mathplot.h:1018
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:753
bool PointIsInside(double x, double y) const
Is point inside this bounding box (ignoring Y2)?
Definition: mathplot.h:212
void SetPosY(const double posY, const double posY2)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:2415
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:724
bool IsHorizontal(void) const
Get if is horizontal line.
Definition: mathplot.h:1225
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:676
int m_last_ly
For double buffering.
Definition: mathplot.h:3034
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:807
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:760
bool m_UseY2Axis
Use Y2 axis. This second axis must exist.
Definition: mathplot.h:1189
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:3314
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:316
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1157
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1149
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:318
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:3340
wxPoint GetPosition() const
Returns the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:858
Shows information about the mouse commands.
Definition: mathplot.h:267
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:3374
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:710
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:2784
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1817
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:3330
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:3275
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:3043
Fit view to match bounding box of all layers.
Definition: mathplot.h:255
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:669
bool GetY2Axis() const
Is second Y axis selected for this layer?
Definition: mathplot.h:1178
Line (horizontal or vertical) type layer.
Definition: mathplot.h:415
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:2439
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:1973
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:524
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:979
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1287
bool IsLogXaxis() const
Log axis control.
Definition: mathplot.h:2899
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:445
bool m_enableDoubleBuffer
For double buffering. Default enabled.
Definition: mathplot.h:3036
void SetCanDelete(bool canDelete)
Set CanDelete for plot.
Definition: mathplot.h:731
enum MathPlot::__mp_Location_Type mpLocation
Location for the Info layer.
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:297
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:1482
void InitializeBoundingBox(double x, double y, double y2=0)
Initialize bounding box with an initial point.
Definition: mathplot.h:227
Zoom into view at clickposition / window center.
Definition: mathplot.h:256
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:973
Zoom out.
Definition: mathplot.h:257
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:1364
Plot type layer.
Definition: mathplot.h:398
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above)...
Definition: mathplot.h:3401
double GetScaleY(bool Y2=false) const
Get current view&#39;s Y scale.
Definition: mathplot.h:2375
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:2235
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:638
double GetValue() const
Set x or y.
Definition: mathplot.h:1210
mpFloatRect m_desired
These are updated in Fit() only (also Zoom) May be different from the real borders (layer coordinates...
Definition: mathplot.h:3023
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:3307
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:1975
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:897
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:2868
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1583
double p2x(const wxCoord pixelCoordX) const
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:2494
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:1927
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:2538
Layer type undefined; SHOULD NOT BE USED.
Definition: mathplot.h:396
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:2754
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:3016
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:1801
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:3428
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:2766
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:703
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:355
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:2397
void SetLabelMode(unsigned int mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:2040
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:516
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:3030
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:894
__mp_Layer_Type
Definition: mathplot.h:394
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:3162
each visible plot is described on its own line, one above the other
Definition: mathplot.h:326
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:500
Just the end of ZOrder.
Definition: mathplot.h:420
Definition: mathplot.h:98
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:2073
~mpBarChart()
Destructor.
Definition: mathplot.h:1725
std::vector< double > m_xs
The internal copy of the set of data to draw.
Definition: mathplot.h:1548
double GetDesiredYmin() const
Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not ex...
Definition: mathplot.h:2661
wxPen m_gridpen
Grid&#39;s pen. Default Colour = LIGHT_GREY, width = 1, style = wxPENSTYLE_DOT.
Definition: mathplot.h:1972
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer Use like this : your_plot->SetOnDeleteLayer([this](void *S...
Definition: mathplot.h:2136
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:2889
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:756
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:3550
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:3140
enum MathPlot::__mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxCoord x2p(const double x) const
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:2513
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2054
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:3293
void Rewind()
Rewind value enumeration with mpFXY::GetNextXY.
Definition: mathplot.h:1565
std::vector< double > m_trans_shape_xs
The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh)...
Definition: mathplot.h:3345
std::function< void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction
Define an event for when we have a mouse click Use like this : your_plot->SetOnUserMouseAction([this]...
Definition: mathplot.h:2144
Chart type layer (bar chart)
Definition: mathplot.h:403
double m_min_x
The shape of the bitmap:
Definition: mathplot.h:3567
int GetMarginTop() const
Get the top margin.
Definition: mathplot.h:2736
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:3155
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:745
mpScaleY(const wxString &name=_T("Y"), int flags=mpALIGN_CENTERY, bool grids=false, bool Y2Axis=false)
Full constructor.
Definition: mathplot.h:2081
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1014
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:457
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:1897
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:599
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:3017
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:2345
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:3543
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:3257
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:2805
enum MathPlot::__Plot_Align_Name_Type mpPlot_Align
Plot alignment (which corner should plot be placed)
Configuration.
Definition: mathplot.h:264
enum MathPlot::__YAxis_Align_Type mpYAxis_Align
Alignment for Y axis.
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:3536
Line (horizontal or vertical) type layer.
Definition: mathplot.h:402
void SetScaleY(const double scaleY)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:2364
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:3500
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:696
mpScaleX * m_XAxis
Pointer to the optional X axis layer of this mpWindow.
Definition: mathplot.h:2997
virtual void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:1904
Plot (function) type layer.
Definition: mathplot.h:416
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:662
Plot layer implementing a text string.
Definition: mathplot.h:3099
int GetBarWidth(void) const
return the width of the bar
Definition: mathplot.h:1414
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:3262
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:3126
wxBitmap * m_zoom_bmp
For zoom selection.
Definition: mathplot.h:3048
Chart type layer.
Definition: mathplot.h:417
double m_posY
Current view&#39;s Y position.
Definition: mathplot.h:3013
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:3037