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 // Oskar Waldemarsson (for multi Y axis and corrections)
8 // Created: 21/07/2003
9 // Last edit: 07/02/2026
10 // Copyright: (c) David Schalig, Davide Rondini
11 // Licence: wxWindows licence
13 
14 #ifndef MATHPLOT_H_INCLUDED
15 #define MATHPLOT_H_INCLUDED
16 
17 #define MATHPLOT_MANY_YAXIS
18 
19 
58 //this definition uses windows dll to export function.
59 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
60 //mathplot_EXPORTS will be defined by cmake
61 #ifdef mathplot_EXPORTS
62 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
63 #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
64 #else // not making DLL
65 #define WXDLLIMPEXP_MATHPLOT
66 #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
67 #endif
68 
69 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
70 #pragma interface "mathplot.h"
71 #endif
72 
73 #include <vector>
74 #include <map>
75 #include <unordered_map>
76 #include <optional>
77 
78 // #include <wx/wx.h>
79 #include <wx/defs.h>
80 #include <wx/menu.h>
81 #include <wx/scrolwin.h>
82 #include <wx/event.h>
83 #include <wx/dynarray.h>
84 #include <wx/pen.h>
85 #include <wx/dcmemory.h>
86 #include <wx/string.h>
87 #include <wx/print.h>
88 #include <wx/image.h>
89 #include <wx/intl.h>
90 
91 #include <cmath>
92 #include <deque>
93 #include <algorithm>
94 
100 #if defined(MP_USER_INCLUDE)
101 #define header MP_USER_INCLUDE.h
102 #define xstr(x) #x
103 #define str(x) xstr(x)
104 #include str(header)
105 #endif
106 
107 // No, this is supposed to be a build parameter: #define ENABLE_MP_CONFIG
108 #ifdef ENABLE_MP_CONFIG
109  #include "MathPlotConfig.h"
110 #endif // ENABLE_MP_CONFIG
111 
116 // No, this is supposed to be a build parameter: #define ENABLE_MP_NAMESPACE
117 #ifdef ENABLE_MP_NAMESPACE
118  namespace MathPlot {
119 #endif // ENABLE_MP_NAMESPACE
120 
121 #ifdef ENABLE_MP_DEBUG
122 // For memory leak debug
123 #ifdef _WINDOWS
124 #ifdef _DEBUG
125 #include <crtdbg.h>
126 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
127 #else
128 #define DEBUG_NEW new
129 #endif // _DEBUG
130 #endif // _WINDOWS
131 #endif // ENABLE_MP_DEBUG
132 
133 // Separation for axes when set close to border
134 #define X_BORDER_SEPARATION 40
135 #define Y_BORDER_SEPARATION 60
136 
138 #define mpX_LOCALTIME 0x10
139 
140 #define mpX_UTCTIME 0x20
141 #define mpX_RAWTIME mpX_UTCTIME
142 
143 // An epsilon for float comparison to 0
144 #define EPSILON 1e-8
145 #define ISNOTNULL(x) (fabs(x) > EPSILON)
146 
147 // A small extra margin for the plot boundary
148 #define EXTRA_MARGIN 8
149 
150 #define ZOOM_AROUND_CENTER -1
151 
152 //-----------------------------------------------------------------------------
153 // classes
154 //-----------------------------------------------------------------------------
155 
156 class WXDLLIMPEXP_MATHPLOT mpLayer;
157 class WXDLLIMPEXP_MATHPLOT mpFunction;
158 class WXDLLIMPEXP_MATHPLOT mpLine;
159 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine;
160 class WXDLLIMPEXP_MATHPLOT mpVerticalLine;
161 class WXDLLIMPEXP_MATHPLOT mpFX;
162 class WXDLLIMPEXP_MATHPLOT mpFY;
163 class WXDLLIMPEXP_MATHPLOT mpFXY;
164 class WXDLLIMPEXP_MATHPLOT mpFXYVector;
165 class WXDLLIMPEXP_MATHPLOT mpProfile;
166 class WXDLLIMPEXP_MATHPLOT mpChart;
167 class WXDLLIMPEXP_MATHPLOT mpBarChart;
168 class WXDLLIMPEXP_MATHPLOT mpScale;
169 class WXDLLIMPEXP_MATHPLOT mpScaleX;
170 class WXDLLIMPEXP_MATHPLOT mpScaleY;
171 class WXDLLIMPEXP_MATHPLOT mpInfoLayer;
172 class WXDLLIMPEXP_MATHPLOT mpInfoCoords;
173 class WXDLLIMPEXP_MATHPLOT mpInfoLegend;
174 class WXDLLIMPEXP_MATHPLOT mpWindow;
175 class WXDLLIMPEXP_MATHPLOT mpText;
176 class WXDLLIMPEXP_MATHPLOT mpTitle;
177 class WXDLLIMPEXP_MATHPLOT mpPrintout;
178 class WXDLLIMPEXP_MATHPLOT mpMovableObject;
179 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse;
180 class WXDLLIMPEXP_MATHPLOT mpPolygon;
181 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer;
182 
183 #ifdef ENABLE_MP_CONFIG
185 #endif // ENABLE_MP_CONFIG
186 
188 typedef union
189 {
190  struct
191  {
192  wxCoord startPx;
193  wxCoord endPx;
194  wxCoord startPy;
195  wxCoord endPy;
196  };
197  struct
198  {
199  wxCoord left;
200  wxCoord top;
201  wxCoord right;
202  wxCoord bottom;
203  };
204  struct
205  {
206  wxCoord x1;
207  wxCoord y1;
208  wxCoord x2;
209  wxCoord y2;
210  };
211  wxCoord tab[4];
212 } mpRect;
213 
219 struct mpRange
220 {
221  double min = 0.0f;
222  double max = 0.0f;
223 
226  {
227  min = 0.0f;
228  max = 0.0f;
229  }
230 
232  mpRange(double value1, double value2)
233  {
234  if (value1 < value2)
235  {
236  min = value1;
237  max = value2;
238  }
239  else
240  {
241  min = value2;
242  max = value1;
243  }
244  }
245 
247  void Set(double _min, double _max)
248  {
249  min = _min;
250  max = _max;
251  }
252 
254  void Assign(double value1, double value2)
255  {
256  if (value1 < value2)
257  {
258  min = value1;
259  max = value2;
260  }
261  else
262  {
263  min = value2;
264  max = value1;
265  }
266  }
267 
269  bool IsSet()
270  {
271  return ((min != 0.0f) || (max != 0.0f));
272  }
273 
278  void Update(double value)
279  {
280  if (value < min)
281  min = value;
282  else
283  if (value > max)
284  max = value;
285  }
286 
290  void Update(double _min, double _max)
291  {
292  if (_min < min)
293  min = _min;
294  if (_max > max)
295  max = _max;
296  }
297 
300  void Update(mpRange range)
301  {
302  if (range.min < min)
303  min = range.min;
304  if (range.max > max)
305  max = range.max;
306  }
307 
309  void Check(void)
310  {
311  if (min == max)
312  {
313  if (max > 0)
314  min = 0;
315  else
316  max = 0;
317  }
318  }
319 
321  double Length(void) const
322  {
323  return max - min;
324  }
325 
327  double GetCenter(void) const
328  {
329  return (min + max) / 2;
330  }
331 
333  double GetMaxAbs(void) const
334  {
335  return std::max(fabs(min), fabs(max));
336  }
337 
339  void ToLog(void)
340  {
341  min = (min > 0) ? log10(min) : 0;
342  max = (max > 0) ? log10(max) : 0;
343  }
344 
346  bool PointIsInside(double point) const
347  {
348  return ((point >= min) && (point <= max));
349  }
350 
351 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
352  bool operator==(const mpRange&) const = default;
353 #else
354  bool operator==(const mpRange &other) const
355  {
356  return (min == other.min) && (max == other.max);
357  }
358  bool operator!=(const mpRange& other) const
359  {
360  return !(*this == other);
361  }
362 #endif
363 };
364 
370 struct [[deprecated("No more used, X and Y are now separated")]] mpFloatRect
371 {
372  mpRange x;
373  std::vector<mpRange> y;
374 
381  mpFloatRect(mpWindow& w);
382 
384  mpFloatRect() = delete;
385 
387  bool PointIsInside(double px, double py, size_t yAxisID = 0) const {
388  if (yAxisID < y.size())
389  {
390  if( (px < x.min || px > x.max) ||
391  (py < y[yAxisID].min || py > y[yAxisID].max))
392  {
393  return false;
394  }
395  }
396  else
397  {
398  return false;
399  }
400 
401  return true;
402  }
404  void UpdateBoundingBoxToInclude(double px, double py, size_t yAxisID = 0) {
405  assert(yAxisID < y.size());
406  if (yAxisID < y.size())
407  {
408  if (px < x.min ) x.min = px;
409  else if (px > x.max ) x.max = px;
410  if (py < y[yAxisID].min ) y[yAxisID].min = py;
411  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
412  }
413  }
415  void InitializeBoundingBox(double px, double py, size_t yAxisID = 0) {
416  assert(yAxisID < y.size());
417  if (yAxisID < y.size())
418  {
419  x.min = x.max = px;
420  y[yAxisID].min = y[yAxisID].max = py;
421  }
422  }
424  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
426 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
427  bool operator==(const mpFloatRect&) const = default;
428 #else
429  // We compare with an epsilon precision
430  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
431  bool operator==(const mpFloatRect& rect) const
432  {
433  auto Same = [](double a, double b) {
434  return std::fabs(a - b) < EPSILON;
435  };
436 
437  // Compare scalar members
438  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
439  {
440  return false;
441  }
442 
443  // Compare vector sizes
444  if (y.size() != rect.y.size())
445  {
446  return false;
447  }
448 
449  // Compare each Y boundary
450  for (size_t i = 0; i < y.size(); ++i)
451  {
452  if (!Same(y[i].min, rect.y[i].min) ||
453  !Same(y[i].max, rect.y[i].max) )
454  {
455  return false;
456  }
457  }
458 
459  return true;
460  }
461 #endif
462 };
463 
470 {
471  mpRange x;
472  mpRange y;
473 
474  mpFloatRectSimple(mpRange _x, mpRange _y) : x(_x), y(_y) { };
475 
477  bool PointIsInside(double px, double py) const {
478  return x.PointIsInside(px) && y.PointIsInside(py);
479  }
480 
481  /* Update bounding box (X and Y axis) to include this point.
482  * Expand the range to include the point.
483  * @param px: point on x-axis
484  * @param py: point on y-axis
485  */
486  void UpdateBoundingBoxToInclude(double px, double py)
487  {
488  x.Update(px);
489  y.Update(py);
490  }
491 
492  /* Initialize bounding box with an initial point
493  * @param px: point on x-axis
494  * @param py: point on y-axis
495  */
496  void InitializeBoundingBox(double px, double py)
497  {
498  x.Set(px, px);
499  y.Set(py, py);
500  }
501 };
502 
506 enum
507 {
508  mpID_FIT = 2000,
516 #ifdef ENABLE_MP_CONFIG
517  mpID_CONFIG,
518 #endif // ENABLE_MP_CONFIG
522 };
523 
525 typedef enum __mp_Location_Type
526 {
527  mpMarginLeftCenter,
528  mpMarginTopLeft,
529  mpMarginTopCenter,
530  mpMarginTopRight,
531  mpMarginRightCenter,
532  mpMarginBottomLeft,
533  mpMarginBottomCenter,
534  mpMarginBottomRight,
535  mpMarginNone,
536  mpCursor // only for mpInfoCoords
537 } mpLocation;
538 
540 typedef enum __XAxis_Align_Type
541 {
542  mpALIGN_BORDER_BOTTOM = 10,
543  mpALIGN_BOTTOM,
544  mpALIGN_CENTERX,
545  mpALIGN_TOP,
546  mpALIGN_BORDER_TOP
547 } mpXAxis_Align;
548 
550 typedef enum __YAxis_Align_Type
551 {
552  mpALIGN_BORDER_LEFT = 20,
553  mpALIGN_LEFT,
554  mpALIGN_CENTERY,
555  mpALIGN_RIGHT,
556  mpALIGN_BORDER_RIGHT
557 } mpYAxis_Align;
558 
561 {
562  mpALIGN_NW = 5,
563  mpALIGN_NE,
564  mpALIGN_SE,
565  mpALIGN_SW
566 } mpPlot_Align;
567 
569 typedef enum __mp_Style_Type
570 {
574 } mpLegendStyle;
575 
578 {
582 
583 typedef enum __Symbol_Type
584 {
585  mpsNone,
586  mpsCircle,
587  mpsSquare,
588  mpsUpTriangle,
589  mpsDownTriangle,
590  mpsCross,
591  mpsPlus
592 } mpSymbol;
593 
594 //-----------------------------------------------------------------------------
595 // mpLayer sub_type values
596 //-----------------------------------------------------------------------------
597 
599 typedef enum __Info_Type
600 {
601  mpiNone, // never used
602  mpiInfo,
603  mpiCoords,
604  mpiLegend
605 } mpInfoType;
606 
608 typedef enum __Text_Type
609 {
610  mptNone, // never used
611  mptText,
612  mptTitle
613 } mpTextType;
614 
615 typedef enum __Function_Type
616 {
617  mpfNone,
618  mpfFX,
619  mpfFY,
620  mpfFXY,
621  mpfFXYVector,
622  mpfMovable,
623  mpfLine,
624  mpfAllType
625 } mpFunctionType;
626 
627 typedef enum __Scale_Type
628 {
629  mpsScaleNone,
630  mpsScaleX,
631  mpsScaleY,
632  mpsAllType
633 } mpScaleType;
634 
635 typedef enum __Chart_Type
636 {
637  mpcChartNone,
638  mpcBarChart,
639  mpcPieChart,
640  mpcAllType
641 } mpChartType;
642 
643 enum mpMouseButtonAction
644 {
645  mpMouseBoxZoom,
646  mpMouseDragZoom,
647 };
648 
650 {
670 };
671 
672 //-----------------------------------------------------------------------------
673 // mpLayer
674 //-----------------------------------------------------------------------------
675 
676 typedef enum __mp_Layer_Type
677 {
686 } mpLayerType;
687 
693 typedef enum __mp_Layer_ZOrder
694 {
703 } mpLayerZOrder;
704 
711 typedef enum __mp_Delete_Action
712 {
713  mpNoDelete,
714  mpYesDelete,
715  mpForceDelete
717 
728 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
729 {
730  public:
731  mpLayer(mpLayerType layerType);
732 
733  virtual ~mpLayer()
734  {
735  ;
736  }
737 
741  {
742  m_win = &w;
743  }
744 
752  virtual bool HasBBox()
753  {
754  return true;
755  }
756 
761  mpLayerType GetLayerType() const
762  {
763  return m_type;
764  }
765 
769  int GetLayerSubType() const
770  {
771  return m_subtype;
772  }
773 
779  virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
780  {
781  *subtype = m_subtype;
782  return (m_type == typeOfInterest);
783  }
784 
788  virtual double GetMinX()
789  {
790  return -1.0;
791  }
792 
796  virtual double GetMaxX()
797  {
798  return 1.0;
799  }
800 
804  virtual double GetMinY()
805  {
806  return -1.0;
807  }
808 
812  virtual double GetMaxY()
813  {
814  return 1.0;
815  }
816 
858  void Plot(wxDC &dc, mpWindow &w);
859 
863  void SetName(const wxString &name)
864  {
865  m_name = name;
866  }
867 
871  const wxString& GetName() const
872  {
873  return m_name;
874  }
875 
879  void SetFont(const wxFont &font)
880  {
881  m_font = font;
882  }
883 
887  const wxFont& GetFont() const
888  {
889  return m_font;
890  }
891 
895  void SetFontColour(const wxColour &colour)
896  {
897  m_fontcolour = colour;
898  }
899 
903  const wxColour& GetFontColour() const
904  {
905  return m_fontcolour;
906  }
907 
911  void SetPen(const wxPen &pen)
912  {
913  m_pen = pen;
914  }
915 
919  const wxPen& GetPen() const
920  {
921  return m_pen;
922  }
923 
926  void SetBrush(const wxBrush &brush)
927  {
928  if (brush == wxNullBrush)
929  m_brush = *wxTRANSPARENT_BRUSH;
930  else
931  m_brush = brush;
932  }
933 
936  const wxBrush& GetBrush() const
937  {
938  return m_brush;
939  }
940 
943  void SetShowName(bool show)
944  {
945  m_showName = show;
946  }
947 
950  inline bool GetShowName() const
951  {
952  return m_showName;
953  }
954 
957  void SetDrawOutsideMargins(bool drawModeOutside)
958  {
959  m_drawOutsideMargins = drawModeOutside;
960  }
961 
965  {
966  return m_drawOutsideMargins;
967  }
968 
973  wxBitmap GetColourSquare(int side = 16);
974 
977  inline bool IsVisible() const
978  {
979  return m_visible;
980  }
981 
984  virtual void SetVisible(bool show)
985  {
986  m_visible = show;
987  }
988 
991  inline bool IsTractable() const
992  {
993  return m_tractable;
994  }
995 
998  virtual void SetTractable(bool track)
999  {
1000  m_tractable = track;
1001  }
1002 
1005  void SetAlign(int align)
1006  {
1007  m_flags = align;
1008  }
1009 
1012  int GetAlign() const
1013  {
1014  return m_flags;
1015  }
1016 
1019  void SetCanDelete(bool canDelete)
1020  {
1021  m_CanDelete = canDelete;
1022  }
1023 
1026  bool GetCanDelete(void) const
1027  {
1028  return m_CanDelete;
1029  }
1030 
1033  mpLayerZOrder GetZIndex(void) const
1034  {
1035  return m_ZIndex;
1036  }
1037 
1038  protected:
1039  const mpLayerType m_type;
1042  wxFont m_font;
1043  wxColour m_fontcolour;
1044  wxPen m_pen;
1045  wxBrush m_brush;
1046  wxString m_name;
1047  bool m_showName;
1049  bool m_visible;
1051  int m_flags;
1054  mpLayerZOrder m_ZIndex;
1055 
1058  void UpdateContext(wxDC &dc) const;
1059 
1064  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1065 
1070  virtual bool DoBeforePlot()
1071  {
1072  return true;
1073  }
1074 
1081  void CheckLog(double *x, double *y, int yAxisID);
1082 
1083  private:
1084  bool m_busy;
1085  mpLayer() = delete; // default ctor not implemented/permitted
1086 
1087  wxDECLARE_DYNAMIC_CLASS(mpLayer);
1088 };
1089 
1090 //-----------------------------------------------------------------------------
1091 // mpInfoLayer
1092 //-----------------------------------------------------------------------------
1093 
1099 class WXDLLIMPEXP_MATHPLOT mpInfoLayer: public mpLayer
1100 {
1101  public:
1103  mpInfoLayer();
1104 
1109  mpInfoLayer(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1110 
1112  virtual ~mpInfoLayer();
1113 
1116  virtual void SetVisible(bool show);
1117 
1122  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1123 
1126  virtual bool HasBBox()
1127  {
1128  return false;
1129  }
1130 
1134  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1135 
1139  virtual bool Inside(const wxPoint &point);
1140 
1143  virtual void Move(wxPoint delta);
1144 
1146  virtual void UpdateReference();
1147 
1150  wxPoint GetPosition() const
1151  {
1152  return m_dim.GetPosition();
1153  }
1154 
1157  wxSize GetSize() const
1158  {
1159  return m_dim.GetSize();
1160  }
1161 
1164  const wxRect& GetRectangle() const
1165  {
1166  return m_dim;
1167  }
1168 
1171  void SetLocation(mpLocation location)
1172  {
1173  m_location = location;
1174  }
1175 
1178  mpLocation GetLocation() const
1179  {
1180  return m_location;
1181  }
1182 
1183  protected:
1184  wxRect m_dim;
1185  wxRect m_oldDim;
1186  wxBitmap* m_info_bmp;
1187  wxPoint m_reference;
1188  int m_winX, m_winY;
1189  mpLocation m_location;
1190 
1195  virtual void DoPlot(wxDC &dc, mpWindow &w);
1196 
1199  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1200 
1201  wxDECLARE_DYNAMIC_CLASS(mpInfoLayer);
1202 };
1203 
1208 class WXDLLIMPEXP_MATHPLOT mpInfoCoords: public mpInfoLayer
1209 {
1210  public:
1212  mpInfoCoords();
1213 
1215  mpInfoCoords(mpLocation location);
1216 
1221  mpInfoCoords(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1222 
1225  {
1226  ;
1227  }
1228 
1232  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1233 
1234  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1235 
1238  void SetLabelMode(mpLabelType mode, unsigned int time_conv = mpX_RAWTIME)
1239  {
1240  m_labelType = mode;
1241  m_timeConv = time_conv;
1242  }
1243 
1246  void SetSeriesCoord(bool show)
1247  {
1248  m_series_coord = show;
1249  }
1250 
1253  bool IsSeriesCoord() const
1254  {
1255  return m_series_coord;
1256  }
1257 
1263  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1264 
1267  void SetPenSeries(const wxPen &pen)
1268  {
1269  m_penSeries = pen;
1270  }
1271 
1272  protected:
1273  wxString m_content;
1274  mpLabelType m_labelType;
1275  unsigned int m_timeConv;
1276  wxCoord m_mouseX;
1277  wxCoord m_mouseY;
1278  bool m_series_coord;
1279  wxPen m_penSeries;
1280 
1285  virtual void DoPlot(wxDC &dc, mpWindow &w);
1286 
1287  wxDECLARE_DYNAMIC_CLASS(mpInfoCoords);
1288 };
1289 
1294 class WXDLLIMPEXP_MATHPLOT mpInfoLegend: public mpInfoLayer
1295 {
1296  public:
1298  mpInfoLegend();
1299 
1305  mpInfoLegend(wxRect rect, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginNone);
1306 
1309 
1312  void SetItemMode(mpLegendStyle mode)
1313  {
1314  m_item_mode = mode;
1315  m_needs_update = true;
1316  }
1317 
1318  mpLegendStyle GetItemMode() const
1319  {
1320  return m_item_mode;
1321  }
1322 
1325  void SetItemDirection(mpLegendDirection mode)
1326  {
1327  m_item_direction = mode;
1328  m_needs_update = true;
1329  }
1330 
1331  mpLegendDirection GetItemDirection() const
1332  {
1333  return m_item_direction;
1334  }
1335 
1336  void SetNeedUpdate()
1337  {
1338  m_needs_update = true;
1339  }
1340 
1342  int GetPointed(mpWindow &w, wxPoint eventPoint);
1343 
1344  protected:
1345  mpLegendStyle m_item_mode;
1346  mpLegendDirection m_item_direction;
1347 
1352  virtual void DoPlot(wxDC &dc, mpWindow &w);
1353 
1354  private:
1356  struct LegendDetail
1357  {
1358  unsigned int layerIdx;
1359  wxCoord legendEnd;
1360  };
1362  std::vector<LegendDetail> m_LegendDetailList;
1363  bool m_needs_update;
1364 
1374  void UpdateBitmap(wxDC &dc, mpWindow &w);
1375 
1376  wxDECLARE_DYNAMIC_CLASS(mpInfoLegend);
1377 };
1378 
1379 //-----------------------------------------------------------------------------
1380 // mpLayer implementations - functions
1381 //-----------------------------------------------------------------------------
1382 
1390 class WXDLLIMPEXP_MATHPLOT mpFunction: public mpLayer
1391 {
1392  public:
1395  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1396 
1400  void SetContinuity(bool continuity)
1401  {
1402  m_continuous = continuity;
1403  }
1404 
1408  bool GetContinuity() const
1409  {
1410  return m_continuous;
1411  }
1412 
1415  void SetStep(unsigned int step)
1416  {
1417  m_step = step;
1418  }
1419 
1422  unsigned int GetStep() const
1423  {
1424  return m_step;
1425  }
1426 
1429  void SetSymbol(mpSymbol symbol)
1430  {
1431  m_symbol = symbol;
1432  }
1433 
1436  mpSymbol GetSymbol() const
1437  {
1438  return m_symbol;
1439  }
1440 
1443  void SetSymbolSize(int size)
1444  {
1445  m_symbolSize = size;
1446  m_symbolSize2 = size / 2;
1447  }
1448 
1451  int GetSymbolSize() const
1452  {
1453  return m_symbolSize;
1454  }
1455 
1459  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1460 
1464  int GetYAxisID() const
1465  {
1466  return m_yAxisID;
1467  }
1468 
1472  void SetYAxisID(unsigned int yAxisID)
1473  {
1474  m_yAxisID = yAxisID;
1475  }
1476 
1477  protected:
1479  mpSymbol m_symbol;
1482  unsigned int m_step;
1484 
1485  wxDECLARE_DYNAMIC_CLASS(mpFunction);
1486 };
1487 
1490 class WXDLLIMPEXP_MATHPLOT mpLine: public mpFunction
1491 {
1492  public:
1493  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1494 
1495  // We don't want to include line (horizontal or vertical) in BBox computation
1496  virtual bool HasBBox() override
1497  {
1498  return false;
1499  }
1500 
1504  double GetValue() const
1505  {
1506  return m_value;
1507  }
1508 
1512  void SetValue(const double value)
1513  {
1514  m_value = value;
1515  }
1516 
1519  bool IsHorizontal(void) const
1520  {
1521  return m_IsHorizontal;
1522  }
1523 
1524  protected:
1525  double m_value;
1526  bool m_IsHorizontal;
1527 
1528  wxDECLARE_DYNAMIC_CLASS(mpLine);
1529 };
1530 
1533 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine: public mpLine
1534 {
1535  public:
1536  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1537 
1541  void SetYValue(const double yvalue)
1542  {
1543  SetValue(yvalue);
1544  }
1545 
1546  protected:
1547 
1548  virtual void DoPlot(wxDC &dc, mpWindow &w);
1549 
1550  wxDECLARE_DYNAMIC_CLASS(mpHorizontalLine);
1551 };
1552 
1555 class WXDLLIMPEXP_MATHPLOT mpVerticalLine: public mpLine
1556 {
1557  public:
1558  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1559 
1563  void SetXValue(const double xvalue)
1564  {
1565  SetValue(xvalue);
1566  }
1567 
1568  protected:
1569 
1570  virtual void DoPlot(wxDC &dc, mpWindow &w);
1571 
1576  virtual bool DoBeforePlot()
1577  {
1578  return true;
1579  }
1580 
1581  wxDECLARE_DYNAMIC_CLASS(mpVerticalLine);
1582 };
1583 
1590 class WXDLLIMPEXP_MATHPLOT mpFX: public mpFunction
1591 {
1592  public:
1596  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
1597 
1603  virtual double GetY(double x) = 0;
1604 
1609  double DoGetY(double x);
1610 
1615  void DefineDoGetY(void);
1616 
1617  protected:
1618 
1619  // Pointer function to the appropriate DoGetY function
1620  double (mpFX::*pDoGetY)(double x);
1621 
1626  virtual void DoPlot(wxDC &dc, mpWindow &w);
1627 
1631  double NormalDoGetY(double x);
1632  double LogDoGetY(double x);
1633 
1634  wxDECLARE_DYNAMIC_CLASS(mpFX);
1635 };
1636 
1643 class WXDLLIMPEXP_MATHPLOT mpFY: public mpFunction
1644 {
1645  public:
1649  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
1650 
1656  virtual double GetX(double y) = 0;
1657 
1662  double DoGetX(double y);
1663 
1668  void DefineDoGetX(void);
1669 
1670  protected:
1671 
1672  // Pointer function to the appropriate DoGetX function
1673  double (mpFY::*pDoGetX)(double y);
1674 
1679  virtual void DoPlot(wxDC &dc, mpWindow &w);
1680 
1684  double NormalDoGetX(double y);
1685  double LogDoGetX(double y);
1686 
1687  wxDECLARE_DYNAMIC_CLASS(mpFY);
1688 };
1689 
1699 class WXDLLIMPEXP_MATHPLOT mpFXY: public mpFunction
1700 {
1701  public:
1705  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, unsigned int yAxisID = 0);
1706 
1710  virtual void Rewind() = 0;
1711 
1715  virtual void Clear()
1716  {
1717  ;
1718  }
1719 
1723  virtual int GetSize()
1724  {
1725  return 0;
1726  }
1727 
1734  virtual bool GetNextXY(double *x, double *y) = 0;
1735 
1739  bool DoGetNextXY(double *x, double *y);
1740 
1744  void SetViewMode(bool asBar);
1745 
1749  int GetBarWidth(void) const
1750  {
1751  return m_BarWidth;
1752  }
1753 
1757  bool ViewAsBar(void) const
1758  {
1759  return m_ViewAsBar;
1760  }
1761 
1762  protected:
1763 
1764  // Data to calculate label positioning
1765  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
1766 
1767  // Min delta between 2 x coordinate (used for view as bar)
1768  double m_deltaX, m_deltaY;
1769 
1770  // The width of a bar
1771  int m_BarWidth;
1772 
1773  // Plot data as bar graph
1774  bool m_ViewAsBar = false;
1775 
1780  virtual void DoPlot(wxDC &dc, mpWindow &w);
1781 
1786  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
1787 
1788  wxDECLARE_DYNAMIC_CLASS(mpFXY);
1789 };
1790 
1791 //-----------------------------------------------------------------------------
1792 // mpFXYVector - provided by Jose Luis Blanco
1793 //-----------------------------------------------------------------------------
1794 
1814 class WXDLLIMPEXP_MATHPLOT mpFXYVector: public mpFXY
1815 {
1816  public:
1820  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, unsigned int yAxisID = 0);
1821 
1824  virtual ~mpFXYVector()
1825  {
1826  Clear();
1827  }
1828 
1833  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
1834 
1838  void Clear();
1839 
1844  virtual int GetSize()
1845  {
1846  return m_xs.size();
1847  }
1848 
1856  bool AddData(const double x, const double y, bool updatePlot);
1857 
1863  void SetReserve(int reserve)
1864  {
1865  m_reserveXY = reserve;
1866  m_xs.reserve(m_reserveXY);
1867  m_ys.reserve(m_reserveXY);
1868  }
1869 
1872  int GetReserve() const
1873  {
1874  return m_reserveXY;
1875  }
1876 
1877  protected:
1880  std::vector<double> m_xs, m_ys;
1881 
1885 
1888  size_t m_index;
1889 
1892  double m_minX, m_maxX, m_minY, m_maxY, m_lastX, m_lastY;
1893 
1897  inline void Rewind()
1898  {
1899  m_index = 0;
1900  }
1901 
1907  virtual bool GetNextXY(double *x, double *y);
1908 
1911  void DrawAddedPoint(double x, double y);
1912 
1915  virtual double GetMinX()
1916  {
1917  if(m_ViewAsBar)
1918  {
1919  // Make extra space for outer bars
1920  return m_minX - (m_deltaX / 2);
1921  }
1922  else
1923  {
1924  return m_minX;
1925  }
1926  }
1927 
1930  virtual double GetMinY()
1931  {
1932  return m_minY;
1933  }
1934 
1937  virtual double GetMaxX()
1938  {
1939  if(m_ViewAsBar)
1940  {
1941  // Make extra space for outer bars
1942  return m_maxX + (m_deltaX / 2);
1943  }
1944  else
1945  {
1946  return m_maxX;
1947  }
1948  }
1949 
1952  virtual double GetMaxY()
1953  {
1954  return m_maxY;
1955  }
1956 
1957  private:
1960  void First_Point(double x, double y);
1961 
1964  void Check_Limit(double val, double *min, double *max, double *last, double *delta);
1965 
1966  wxDECLARE_DYNAMIC_CLASS(mpFXYVector);
1967 };
1968 
1977 class WXDLLIMPEXP_MATHPLOT mpProfile: public mpFunction
1978 {
1979  public:
1983  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
1984 
1990  virtual double GetY(double x) = 0;
1991 
1992  protected:
1993 
1998  virtual void DoPlot(wxDC &dc, mpWindow &w);
1999 
2000  wxDECLARE_DYNAMIC_CLASS(mpProfile);
2001 };
2002 
2003 //-----------------------------------------------------------------------------
2004 // mpChart
2005 //-----------------------------------------------------------------------------
2008 class WXDLLIMPEXP_MATHPLOT mpChart: public mpFunction
2009 {
2010  public:
2012  mpChart(const wxString &name = wxEmptyString);
2013 
2016  {
2017  Clear();
2018  }
2019 
2022  void SetChartValues(const std::vector<double> &data);
2023 
2026  void SetChartLabels(const std::vector<std::string> &labelArray);
2027 
2032  void AddData(const double &data, const std::string &label);
2033 
2037  virtual void Clear();
2038 
2039  virtual bool HasBBox()
2040  {
2041  return (values.size() > 0);
2042  }
2043 
2044  protected:
2045  std::vector<double> values;
2046  std::vector<std::string> labels;
2047 
2048  double m_max_value;
2049  double m_total_value;
2050 
2051  wxDECLARE_DYNAMIC_CLASS(mpChart);
2052 };
2053 
2054 //-----------------------------------------------------------------------------
2055 // mpBarChart - provided by Jose Davide Rondini
2056 //-----------------------------------------------------------------------------
2057 /* Defines for bar charts label positioning. */
2058 #define mpBAR_NONE 0
2059 #define mpBAR_AXIS_H 1
2060 #define mpBAR_AXIS_V 2
2061 #define mpBAR_INSIDE 3
2062 #define mpBAR_TOP 4
2063 
2064 
2066 class WXDLLIMPEXP_MATHPLOT mpBarChart: public mpChart
2067 {
2068  public:
2070  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2071 
2074  {
2075  Clear();
2076  }
2077 
2078  void SetBarColour(const wxColour &colour);
2079 
2080  void SetColumnWidth(const double colWidth)
2081  {
2082  m_width = colWidth;
2083  }
2084 
2086  void SetBarLabelPosition(int position);
2087 
2091  virtual double GetMinX();
2092 
2096  virtual double GetMaxX();
2097 
2101  virtual double GetMinY();
2102 
2106  virtual double GetMaxY();
2107 
2108  protected:
2109 
2110  double m_width;
2111  wxColour m_barColour;
2112  int m_labelPos;
2113  double m_labelAngle;
2114 
2119  virtual void DoPlot(wxDC &dc, mpWindow &w);
2120 
2121  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2122 };
2123 
2127 class WXDLLIMPEXP_MATHPLOT mpPieChart: public mpChart
2128 {
2129  public:
2131  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2132 
2135  {
2136  Clear();
2137  colours.clear();
2138  }
2139 
2143  void SetCenter(const wxPoint center)
2144  {
2145  m_center = center;
2146  }
2147 
2150  wxPoint GetCenter(void) const
2151  {
2152  return m_center;
2153  }
2154 
2158  void SetPieColours(const std::vector<wxColour> &colourArray);
2159 
2163  virtual double GetMinX()
2164  {
2165  return m_center.x - m_radius;
2166  }
2167 
2171  virtual double GetMaxX()
2172  {
2173  return m_center.x + m_radius;
2174  }
2175 
2179  virtual double GetMinY()
2180  {
2181  return m_center.y - m_radius;
2182  }
2183 
2187  virtual double GetMaxY()
2188  {
2189  return m_center.y + m_radius;
2190  }
2191 
2192  protected:
2193 
2194  double m_radius;
2195  wxPoint m_center;
2196  std::vector<wxColour> colours;
2197 
2202  virtual void DoPlot(wxDC &dc, mpWindow &w);
2203 
2204  const wxColour& GetColour(unsigned int id);
2205 
2206  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2207 };
2208 
2211 //-----------------------------------------------------------------------------
2212 // mpLayer implementations - furniture (scales, ...)
2213 //-----------------------------------------------------------------------------
2220 class WXDLLIMPEXP_MATHPLOT mpScale: public mpLayer
2221 {
2222  public:
2227  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, std::optional<unsigned int> axisID = std::nullopt);
2228 
2232  virtual bool HasBBox()
2233  {
2234  return false;
2235  }
2236 
2240  int GetAxisID(void)
2241  {
2242  return m_axisID;
2243  }
2244 
2249  void SetAxisID(unsigned int yAxisID)
2250  {
2251  m_axisID = yAxisID;
2252  }
2253 
2256  void ShowTicks(bool ticks)
2257  {
2258  m_ticks = ticks;
2259  }
2260 
2263  bool GetShowTicks() const
2264  {
2265  return m_ticks;
2266  }
2267 
2270  void ShowGrids(bool grids)
2271  {
2272  m_grids = grids;
2273  }
2274 
2277  bool GetShowGrids() const
2278  {
2279  return m_grids;
2280  }
2281 
2284  void SetLabelFormat(const wxString &format)
2285  {
2286  m_labelFormat = format;
2287  m_labelType = mpLabel_USER;
2288  }
2289 
2293  {
2294  return m_labelType;
2295  }
2296 
2299  void SetLabelMode(mpLabelType mode, unsigned int time_conv = mpX_RAWTIME)
2300  {
2301  m_labelType = mode;
2302  m_timeConv = time_conv;
2303  }
2304 
2307  const wxString& GetLabelFormat() const
2308  {
2309  return m_labelFormat;
2310  }
2311 
2315  void SetGridPen(const wxPen &pen)
2316  {
2317  m_gridpen = pen;
2318  }
2319 
2323  const wxPen& GetGridPen() const
2324  {
2325  return m_gridpen;
2326  }
2327 
2331  void SetAuto(bool automaticScalingIsEnabled)
2332  {
2333  m_auto = automaticScalingIsEnabled;
2334  }
2335 
2339  bool GetAuto() const
2340  {
2341  return m_auto;
2342  }
2343 
2344  void SetMinScale(double min)
2345  {
2346  m_min = min;
2347  }
2348 
2349  double GetMinScale() const
2350  {
2351  return m_min;
2352  }
2353 
2354  void SetMaxScale(double max)
2355  {
2356  m_max = max;
2357  }
2358 
2359  double GetMaxScale() const
2360  {
2361  return m_max;
2362  }
2363 
2364  void SetScale(double min, double max)
2365  {
2366  m_min = min;
2367  m_max = max;
2368  }
2369 
2370  void GetScale(double *min, double *max) const
2371  {
2372  *min = m_min;
2373  *max = m_max;
2374  }
2375 
2376  void SetScale(mpRange range)
2377  {
2378  m_min = range.min;
2379  m_max = range.max;
2380  }
2381 
2386  {
2387  return mpRange(m_min, m_max);
2388  }
2389 
2393  virtual bool IsLogAxis()
2394  {
2395  return m_isLog;
2396  }
2397 
2398  virtual void SetLogAxis(bool log)
2399  {
2400  m_isLog = log;
2401  }
2402 
2403  protected:
2404  static const wxCoord kTickSize = 4;
2405  static const wxCoord kAxisExtraSpace = 6;
2406 
2407  int m_axisID;
2408  wxPen m_gridpen;
2409  bool m_ticks;
2410  bool m_grids;
2411  bool m_auto;
2412  double m_min, m_max;
2414  unsigned int m_timeConv;
2415  wxString m_labelFormat;
2416  bool m_isLog;
2417 
2418  virtual int GetOrigin(mpWindow &w) = 0;
2419 
2426  double GetStep(double scale, int minLabelSpacing);
2427  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
2428 
2435  wxString FormatLabelValue(double value, double maxAxisValue, double step);
2436 
2441  wxString FormatLogValue(double n);
2442 
2450  int GetLabelWidth(double value, wxDC &dc, double maxAxisValue, double step);
2451 
2456  bool UseScientific(double maxAxisValue);
2457 
2463  int GetSignificantDigits(double step, double maxAxisValue);
2464 
2469  int GetDecimalDigits(double step);
2470 
2471  wxDECLARE_DYNAMIC_CLASS(mpScale);
2472 };
2473 
2474 
2480 class WXDLLIMPEXP_MATHPLOT mpScaleX: public mpScale
2481 {
2482  public:
2488  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, mpLabelType type = mpLabel_AUTO) :
2489  mpScale(name, flags, grids, type)
2490  {
2491  m_subtype = mpsScaleX;
2492  }
2493 
2494  bool IsTopAxis()
2495  {
2496  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
2497  }
2498 
2499  bool IsBottomAxis()
2500  {
2501  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
2502  }
2503 
2504  protected:
2505 
2508  virtual void DoPlot(wxDC &dc, mpWindow &w);
2509 
2510  virtual int GetOrigin(mpWindow &w);
2511  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2512 
2513  wxDECLARE_DYNAMIC_CLASS(mpScaleX);
2514 };
2515 
2522 class WXDLLIMPEXP_MATHPLOT mpScaleY: public mpScale
2523 {
2524  public:
2529  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, std::optional<unsigned int> yAxisID = std::nullopt, mpLabelType labelType = mpLabel_AUTO) :
2530  mpScale(name, flags, grids, labelType, yAxisID)
2531  {
2532  m_subtype = mpsScaleY;
2533  m_axisWidth = Y_BORDER_SEPARATION;
2534  m_xPos = 0;
2535  }
2536 
2539  void UpdateAxisWidth(mpWindow &w);
2540 
2541  int GetAxisWidth()
2542  {
2543  return m_axisWidth;
2544  }
2545 
2546  bool IsLeftAxis()
2547  {
2548  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
2549  }
2550 
2551  bool IsRightAxis()
2552  {
2553  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
2554  }
2555 
2556  bool IsInside(wxCoord xPixel)
2557  {
2558  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
2559  {
2560  return true;
2561  }
2562  return false;
2563  }
2564 
2565  protected:
2566  int m_axisWidth;
2567  int m_xPos;
2568 
2571  virtual void DoPlot(wxDC &dc, mpWindow &w);
2572 
2573  virtual int GetOrigin(mpWindow &w);
2574  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2575 
2576  wxDECLARE_DYNAMIC_CLASS(mpScaleY);
2577 };
2578 
2579 //-----------------------------------------------------------------------------
2580 // mpWindow
2581 //-----------------------------------------------------------------------------
2582 
2587 #define mpMOUSEMODE_DRAG 0
2588 
2589 #define mpMOUSEMODE_ZOOMBOX 1
2590 
2593 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
2594 typedef std::deque<mpLayer*> mpLayerList;
2595 
2606 {
2607  mpScale* axis = nullptr;
2608  double scale = 1.0;
2609  double pos = 0;
2613 
2614  // Note: we don't use the default operator since we don't want to compare axis pointers
2615  bool operator==(const mpAxisData& other) const
2616  {
2617  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
2618  (bound == other.bound) && (desired == other.desired);
2619  }
2620 };
2621 
2623 typedef std::unordered_map<int, mpAxisData> mpAxisList;
2624 
2631 typedef enum {
2632  uXAxis = 1,
2633  uYAxis = 2,
2634  uXYAxis = 3
2635 } mpAxisUpdate;
2636 
2643 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
2644 
2651 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
2652 
2658 {
2659  public:
2660  mpMagnet()
2661  {
2662  m_IsDrawn = false;
2663  m_rightClick = false;
2664  m_IsWasDrawn = false;
2665  }
2666  ~mpMagnet()
2667  {
2668  ;
2669  }
2670  void UpdateBox(wxCoord left, wxCoord top, wxCoord width, wxCoord height)
2671  {
2672  m_domain = wxRect(left, top, width, height);
2673  m_plot_size = wxRect(left, top, width + left, height + top);
2674  }
2675  void UpdateBox(const wxRect &size)
2676  {
2677  m_domain = size;
2678  m_plot_size = wxRect(size.GetLeft(), size.GetTop(),
2679  size.GetWidth() + size.GetLeft(), size.GetHeight() + size.GetTop());
2680  }
2681  void Plot(wxClientDC &dc, const wxPoint &mousePos);
2682  void ClearPlot(wxClientDC &dc);
2683  void UpdatePlot(wxClientDC &dc, const wxPoint &mousePos);
2684  void SaveDrawState(void)
2685  {
2686  m_IsWasDrawn = m_IsDrawn;
2687  // In any cases, set to false because we erase and repaint all the plot
2688  m_IsDrawn = false;
2689  }
2690 
2691  void SetRightClick(void)
2692  {
2693  m_rightClick = true;
2694  }
2695 
2696  private:
2697  wxRect m_domain;
2698  wxRect m_plot_size;
2699  wxPoint m_mousePosition;
2700  bool m_IsDrawn;
2701  bool m_IsWasDrawn;
2702  bool m_rightClick;
2703  void DrawCross(wxClientDC &dc) const;
2704 };
2705 
2727 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
2728 {
2729  public:
2730  mpWindow()
2731  {
2732  InitParameters();
2733  }
2734 
2735  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
2736  long flags = 0);
2737 
2738  ~mpWindow();
2739 
2743  wxMenu* GetPopupMenu()
2744  {
2745  return &m_popmenu;
2746  }
2747 
2756  bool AddLayer(mpLayer *layer, bool refreshDisplay = true, bool refreshConfig = true);
2757 
2770  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
2771 
2777  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
2778 
2785  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
2786 
2793  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
2794 
2800  mpLayer* GetLayer(int position);
2801 
2806  int GetLayerPosition(mpLayer* layer);
2807 
2814  mpLayer* GetLayersType(int position, mpLayerType type);
2815 
2821  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
2822 
2825  mpLayer* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
2826 
2831  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
2832 
2836  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
2837 
2842  mpLayer* GetLayerByName(const wxString &name);
2843 
2848  mpLayer* GetLayerByClassName(const wxString &name);
2849 
2853  void RefreshLegend(void);
2854 
2859  bool IsYAxisUsed(int yAxisID);
2860 
2864  mpScaleX* GetLayerXAxis();
2865 
2869  mpScaleY* GetLayerYAxis(int yAxisID);
2870 
2874  void SetScaleX(const double scaleX)
2875  {
2876  if (ISNOTNULL(scaleX))
2877  {
2878  m_AxisDataX.scale = scaleX;
2879  UpdateDesiredBoundingBox(uXAxis);
2880  }
2881  UpdateAll();
2882  }
2883 
2888  double GetScaleX(void) const
2889  {
2890  return m_AxisDataX.scale;
2891  }
2892 
2897  void SetScaleY(const double scaleY, int yAxisID)
2898  {
2899  assert(m_AxisDataYList.count(yAxisID) != 0);
2900  if (ISNOTNULL(scaleY))
2901  {
2902  m_AxisDataYList[yAxisID].scale = scaleY;
2903  UpdateDesiredBoundingBox(uYAxis);
2904  }
2905  UpdateAll();
2906  }
2907 
2913  double GetScaleY(int yAxisID)
2914  {
2915  assert(m_AxisDataYList.count(yAxisID) != 0);
2916  return m_AxisDataYList[yAxisID].scale;
2917  } // Schaling's method: maybe another method exists with the same name
2918 
2919  [[deprecated("Incomplete, use UpdateBBox instead")]]
2922  void SetBound();
2923 
2925  mpRange GetBoundX(void) const
2926  {
2927  return m_AxisDataX.bound;
2928  }
2929 
2932  {
2933  return m_AxisDataX.desired;
2934  }
2935 
2939  mpRange GetBoundY(int yAxisID)
2940  {
2941  assert(m_AxisDataYList.count(yAxisID) != 0);
2942  return m_AxisDataYList[yAxisID].bound;
2943  }
2944 
2949  {
2950  assert(m_AxisDataYList.count(yAxisID) != 0);
2951  return m_AxisDataYList[yAxisID].desired;
2952  }
2953 
2958  std::unordered_map<int, mpRange> GetAllBoundY()
2959  {
2960  std::unordered_map<int, mpRange> yRange;
2961  for (auto& [yID, yData] : m_AxisDataYList)
2962  {
2963  yRange[yID] = yData.bound;
2964  }
2965  return yRange;
2966  }
2967 
2972  std::unordered_map<int, mpRange> GetAllDesiredY()
2973  {
2974  std::unordered_map<int, mpRange> yRange;
2975  for (auto& [yID, yData] : m_AxisDataYList)
2976  {
2977  yRange[yID] = yData.desired;
2978  }
2979  return yRange;
2980  }
2981 
2985  void SetPosX(const double posX)
2986  {
2987  m_AxisDataX.pos = posX;
2988  UpdateDesiredBoundingBox(uXAxis);
2989  UpdateAll();
2990  }
2991 
2996  double GetPosX(void) const
2997  {
2998  return m_AxisDataX.pos;
2999  }
3000 
3005  void SetPosY(std::unordered_map<int, double>& posYList)
3006  {
3007  for (auto& [yID, yData] : m_AxisDataYList)
3008  {
3009  yData.pos = posYList[yID];
3010  }
3011  UpdateDesiredBoundingBox(uYAxis);
3012  UpdateAll();
3013  }
3014 
3020  double GetPosY(int yAxisID)
3021  {
3022  assert(m_AxisDataYList.count(yAxisID) != 0);
3023  return m_AxisDataYList[yAxisID].pos;
3024  }
3025 
3029  int GetNOfYAxis(void) const
3030  {
3031  return (int)m_AxisDataYList.size();
3032  }
3033 
3037  mpAxisList GetAxisDataYList(void) const
3038  {
3039  return m_AxisDataYList;
3040  }
3041 
3045  std::map<int, mpAxisData> GetSortedAxisDataYList(void) const
3046  {
3047  return std::map<int, mpAxisData>(m_AxisDataYList.begin(), m_AxisDataYList.end());
3048  }
3049 
3055  void SetScreen(const int scrX, const int scrY)
3056  {
3057  m_scrX = scrX;
3058  m_scrY = scrY;
3059  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3060  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3061 
3062  m_plotBoundaries.endPx = m_scrX;
3063  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3064  m_plotBoundaries.endPy = m_scrY;
3065  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3066 
3067  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3068  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3069 
3070  m_magnet.UpdateBox(m_PlotArea);
3071  }
3072 
3079  int GetScreenX(void) const
3080  {
3081  return m_scrX;
3082  }
3083 
3090  int GetScreenY(void) const
3091  {
3092  return m_scrY;
3093  }
3094 
3100  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3101  {
3102  m_AxisDataX.pos = posX;
3103  SetPosY(posYList);
3104  }
3105 
3109  inline double p2x(const wxCoord pixelCoordX) const
3110  {
3111  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3112  }
3113 
3117  inline double p2y(const wxCoord pixelCoordY, int yAxisID = 0)
3118  {
3119  assert(m_AxisDataYList.count(yAxisID) != 0);
3120  if (m_AxisDataYList.count(yAxisID) == 0)
3121  return 0.0;
3122  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3123  }
3124 
3128  inline wxCoord x2p(const double x) const
3129  {
3130  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3131  }
3132 
3136  inline wxCoord y2p(const double y, int yAxisID = 0)
3137  {
3138  assert(m_AxisDataYList.count(yAxisID) != 0);
3139  if (m_AxisDataYList.count(yAxisID) == 0)
3140  return 0;
3141  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3142  }
3143 
3146  void EnableDoubleBuffer(const bool enabled)
3147  {
3148  m_enableDoubleBuffer = enabled;
3149  }
3150 
3153  void EnableMousePanZoom(const bool enabled)
3154  {
3155  m_enableMouseNavigation = enabled;
3156  }
3157 
3163  void LockAspect(bool enable = true);
3164 
3169  inline bool IsAspectLocked() const
3170  {
3171  return m_lockaspect;
3172  }
3173 
3178  inline bool IsRepainting() const
3179  {
3180  return m_repainting;
3181  }
3182 
3187  void Fit();
3188 
3195  void Fit(const mpRange &rangeX, std::unordered_map<int, mpRange> rangeY, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3196 
3200  void FitX(void);
3201 
3206  void FitY(int yAxisID);
3207 
3212  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
3213 
3218  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
3219 
3221  void ZoomInX();
3222 
3224  void ZoomOutX();
3225 
3228  void ZoomInY(std::optional<int> yAxisID = std::nullopt);
3229 
3232  void ZoomOutY(std::optional<int> yAxisID = std::nullopt);
3233 
3235  void ZoomRect(wxPoint p0, wxPoint p1);
3236 
3238  void UpdateAll();
3239 
3240  // Added methods by Davide Rondini
3241 
3245  unsigned int CountLayers();
3246 
3249  unsigned int CountAllLayers()
3250  {
3251  return (unsigned int)m_layers.size();
3252  }
3253 
3257  unsigned int CountLayersType(mpLayerType type);
3258  unsigned int CountLayersFXYPlot();
3259 
3262  //void PrintGraph(mpPrintout *print);
3263 
3271  {
3272  // Change on X axis
3273  if (update & uXAxis)
3274  {
3275  m_AxisDataX.desired.Set(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale),
3276  m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3277  }
3278 
3279  // Change on Y axis
3280  if (update & uYAxis)
3281  {
3282  for (auto& [yID, yData] : m_AxisDataYList)
3283  {
3284  yData.desired.Set(yData.pos - ((m_margin.top + m_plotHeight) / yData.scale),
3285  yData.pos - (m_margin.top / yData.scale));
3286  }
3287  }
3288  }
3289 
3295  mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID = 0)
3296  {
3297  assert(m_AxisDataYList.count(yAxisID) != 0);
3298  if (desired)
3299  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
3300  else
3301  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
3302  }
3303 
3307  double GetDesiredXmin() const
3308  {
3309  return m_AxisDataX.desired.min;
3310  }
3311 
3316  double GetDesiredXmax() const
3317  {
3318  return m_AxisDataX.desired.max;
3319  }
3320 
3326  double GetDesiredYmin(int yAxisID)
3327  {
3328  assert(m_AxisDataYList.count(yAxisID) != 0);
3329  return m_AxisDataYList[yAxisID].desired.min;
3330  }
3331 
3337  double GetDesiredYmax(int yAxisID)
3338  {
3339  assert(m_AxisDataYList.count(yAxisID) != 0);
3340  return m_AxisDataYList[yAxisID].desired.max;
3341  }
3342 
3344  bool GetBoundingBox(mpRange *boundX, mpRange *boundY, int yAxisID)
3345  {
3346  if (m_AxisDataYList.count(yAxisID) == 0)
3347  return false;
3348  *boundX = m_AxisDataX.bound;
3349  *boundY = m_AxisDataYList[yAxisID].bound;
3350  return true;
3351  }
3352 
3353  // Is this point inside the bounding box
3354  bool PointIsInsideBound(double px, double py, int yAxisID)
3355  {
3356  if (m_AxisDataYList.count(yAxisID) == 0)
3357  return false;
3358 
3359  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
3360  }
3361 
3362  /* Update bounding box (X and Y axis) to include this point.
3363  * Expand the range to include the point.
3364  * @param px: point on x-axis
3365  * @param py: point on y-axis
3366  * @param yAxisID: the y-axis ID
3367  */
3368  void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
3369  {
3370  if (m_AxisDataYList.count(yAxisID) == 0)
3371  return ;
3372 
3373  m_AxisDataX.bound.Update(px);
3374  m_AxisDataYList[yAxisID].bound.Update(py);
3375  }
3376 
3377  /* Initialize bounding box with an initial point
3378  * @param px: point on x-axis
3379  * @param py: point on y-axis
3380  * @param yAxisID: the y-axis ID
3381  */
3382  void InitializeBoundingBox(double px, double py, int yAxisID)
3383  {
3384  if (m_AxisDataYList.count(yAxisID) == 0)
3385  return ;
3386 
3387  m_AxisDataX.bound.Set(px, px);
3388  m_AxisDataYList[yAxisID].bound.Set(py, py);
3389  }
3390 
3393  void SetMPScrollbars(bool status);
3394 
3397  bool GetMPScrollbars() const
3398  {
3399  return m_enableScrollBars;
3400  }
3401 
3407  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
3408 
3412  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3413 
3417  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3418 
3423  bool LoadFile(const wxString &filename);
3424 
3428 
3435  void SetMargins(int top, int right, int bottom, int left);
3436 
3439  {
3440  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3441  }
3442 
3444  void SetMarginTop(int top)
3445  {
3446  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3447  }
3448 
3452  int GetMarginTop(bool minusExtra = false) const
3453  {
3454  if (minusExtra)
3455  return m_margin.top - m_extraMargin;
3456  else
3457  return m_margin.top;
3458  }
3459 
3461  void SetMarginRight(int right)
3462  {
3463  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
3464  }
3465 
3469  int GetMarginRight(bool minusExtra = false) const
3470  {
3471  if (minusExtra)
3472  return m_margin.right - m_extraMargin;
3473  else
3474  return m_margin.right;
3475  }
3476 
3479  {
3480  return m_marginOuter.right;
3481  }
3482 
3484  void SetMarginBottom(int bottom)
3485  {
3486  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
3487  }
3488 
3492  int GetMarginBottom(bool minusExtra = false) const
3493  {
3494  if (minusExtra)
3495  return m_margin.bottom - m_extraMargin;
3496  else
3497  return m_margin.bottom;
3498  }
3499 
3501  void SetMarginLeft(int left)
3502  {
3503  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
3504  }
3505 
3509  int GetMarginLeft(bool minusExtra = false) const
3510  {
3511  if (minusExtra)
3512  return m_margin.left - m_extraMargin;
3513  else
3514  return m_margin.left;
3515  }
3516 
3518  void SetExtraMargin(int extra)
3519  {
3520  m_extraMargin = extra;
3521  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3522  }
3523 
3525  int GetExtraMargin() const
3526  {
3527  return m_extraMargin;
3528  }
3529 
3532  {
3533  return m_marginOuter.left;
3534  }
3535 
3537  int GetPlotWidth() const
3538  {
3539  return m_plotWidth;
3540  }
3541 
3543  int GetPlotHeight() const
3544  {
3545  return m_plotHeight;
3546  }
3547 
3552  mpRect GetPlotBoundaries(bool with_margin) const
3553  {
3554  mpRect bond;
3555  if (with_margin)
3556  bond = m_plotBoundariesMargin;
3557  else
3558  bond = m_plotBoundaries;
3559  bond.startPx -= m_extraMargin;
3560  bond.endPx += m_extraMargin;
3561  bond.startPy -= m_extraMargin;
3562  bond.endPy += m_extraMargin;
3563  return bond;
3564  }
3565 
3569  int GetLeftYAxesWidth(std::optional<int> yAxisID = std::nullopt);
3570 
3574  int GetRightYAxesWidth(std::optional<int> yAxisID = std::nullopt);
3575 
3577  void SetDrawBox(bool drawbox)
3578  {
3579  m_drawBox = drawbox;
3580  }
3581 
3583  bool GetDrawBox() const
3584  {
3585  return m_drawBox;
3586  }
3587 
3591  std::optional<int> IsInsideYAxis(const wxPoint &point);
3592 
3596  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
3597 
3601  void SetLayerVisible(const wxString &name, bool viewable);
3602 
3606  bool IsLayerVisible(const wxString &name);
3607 
3611  bool IsLayerVisible(const unsigned int position);
3612 
3616  void SetLayerVisible(const unsigned int position, bool viewable);
3617 
3622  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
3623 
3626  const wxColour& GetAxesColour() const
3627  {
3628  return m_axColour;
3629  }
3630 
3631  const wxColour& GetbgColour() const
3632  {
3633  return m_bgColour;
3634  }
3635 
3636  void SetbgColour(const wxColour &colour)
3637  {
3638  m_bgColour = colour;
3639  }
3640 
3645  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
3646  {
3647  m_OnDeleteLayer = event;
3648  }
3649 
3652  {
3653  m_OnDeleteLayer = NULL;
3654  }
3655 
3660  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
3661  {
3662  m_OnUserMouseAction = userMouseEventHandler;
3663  }
3664 
3667  {
3668  m_OnUserMouseAction = NULL;
3669  }
3670 
3676  bool IsLogXaxis()
3677  {
3678  if (m_AxisDataX.axis)
3679  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
3680  else
3681  return false;
3682  }
3683 
3687  bool IsLogYaxis(int yAxisID)
3688  {
3689  assert(m_AxisDataYList.count(yAxisID) != 0);
3690  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
3691  if (yAxis)
3692  return yAxis->IsLogAxis();
3693  else
3694  return false;
3695  }
3696 
3697  void SetLogXaxis(bool log)
3698  {
3699  if (m_AxisDataX.axis)
3700  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
3701  }
3702 
3706  void SetLogYaxis(int yAxisID, bool log)
3707  {
3708  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
3709  if (yAxis)
3710  yAxis->SetLogAxis(log);
3711  }
3712 
3718  bool GetMagnetize() const
3719  {
3720  return m_magnetize;
3721  }
3722 
3723  void SetMagnetize(bool mag)
3724  {
3725  m_magnetize = mag;
3726  }
3727 
3732  void SetMouseLeftDownAction(mpMouseButtonAction action)
3733  {
3734  m_mouseLeftDownAction = action;
3735  }
3736 
3741  mpMouseButtonAction GetMouseLeftDownAction()
3742  {
3743  return m_mouseLeftDownAction;
3744  }
3745 
3746 #ifdef ENABLE_MP_CONFIG
3747  void RefreshConfigWindow();
3752  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
3753 #endif // ENABLE_MP_CONFIG
3754 
3755  protected:
3756  virtual void BindEvents(void);
3757  virtual void OnPaint(wxPaintEvent &event);
3758  virtual void OnSize(wxSizeEvent &event);
3759  virtual void OnShowPopupMenu(wxMouseEvent &event);
3760  virtual void OnCenter(wxCommandEvent &event);
3761  virtual void OnFit(wxCommandEvent &event);
3762  virtual void OnToggleGrids(wxCommandEvent &event);
3763  virtual void OnToggleCoords(wxCommandEvent &event);
3764  virtual void OnScreenShot(wxCommandEvent &event);
3765  virtual void OnFullScreen(wxCommandEvent &event);
3766 #ifdef ENABLE_MP_CONFIG
3767  virtual void OnConfiguration(wxCommandEvent &event);
3768 #endif // ENABLE_MP_CONFIG
3769  virtual void OnLoadFile(wxCommandEvent &event);
3770  virtual void OnZoomIn(wxCommandEvent &event);
3771  virtual void OnZoomOut(wxCommandEvent &event);
3772  virtual void OnLockAspect(wxCommandEvent &event);
3773  virtual void OnMouseHelp(wxCommandEvent &event);
3774  virtual void OnMouseLeftDown(wxMouseEvent &event);
3775  virtual void OnMouseRightDown(wxMouseEvent &event);
3776  virtual void OnMouseMove(wxMouseEvent &event);
3777  virtual void OnMouseLeftRelease(wxMouseEvent &event);
3778  virtual void OnMouseWheel(wxMouseEvent &event);
3779  virtual void OnMouseLeave(wxMouseEvent &event);
3780  bool CheckUserMouseAction(wxMouseEvent &event);
3781  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
3782  virtual void OnScrollPageUp(wxScrollWinEvent &event);
3783  virtual void OnScrollPageDown(wxScrollWinEvent &event);
3784  virtual void OnScrollLineUp(wxScrollWinEvent &event);
3785  virtual void OnScrollLineDown(wxScrollWinEvent &event);
3786  virtual void OnScrollTop(wxScrollWinEvent &event);
3787  virtual void OnScrollBottom(wxScrollWinEvent &event);
3788 
3789  void DoScrollCalc(const int position, const int orientation);
3790 
3795  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = ZOOM_AROUND_CENTER);
3796 
3803  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = ZOOM_AROUND_CENTER, std::optional<int> = std::nullopt);
3804 
3809  void SetScaleXAndCenter(double scaleX);
3810 
3816  void SetScaleYAndCenter(double scaleY, int yAxisID);
3817 
3818  void Zoom(bool zoomIn, const wxPoint &centerPoint);
3819 
3822  virtual bool UpdateBBox();
3823 
3824  void InitParameters();
3825 
3826  wxTopLevelWindow* m_parent;
3827  bool m_fullscreen;
3828 
3829  mpLayerList m_layers;
3831  mpAxisList m_AxisDataYList;
3832 
3833  wxMenu m_popmenu;
3835  wxColour m_bgColour;
3836  wxColour m_fgColour;
3837  wxColour m_axColour;
3838  bool m_drawBox;
3839 
3840  int m_scrX;
3841  int m_scrY;
3844 
3848  wxCoord m_plotWidth;
3849  wxCoord m_plotHeight;
3850 
3853  wxRect m_PlotArea;
3854 
3855  bool m_repainting;
3856  int m_last_lx, m_last_ly;
3857  wxBitmap* m_buff_bmp;
3860  mpMouseButtonAction m_mouseLeftDownAction;
3861  bool m_mouseMovedAfterRightClick;
3862  wxPoint m_mouseRClick;
3863  wxPoint m_mouseLClick;
3864  double m_mouseScaleX;
3865  std::unordered_map<int, double> m_mouseScaleYList;
3866  std::optional<int> m_mouseYAxisID;
3867  bool m_enableScrollBars;
3868  int m_scrollX, m_scrollY;
3872  bool m_InInfoLegend;
3873 
3874  wxBitmap* m_zoom_bmp;
3875  wxRect m_zoom_dim;
3876  wxRect m_zoom_oldDim;
3877 
3880 
3881  wxBitmap* m_Screenshot_bmp;
3882 
3883 #ifdef ENABLE_MP_CONFIG
3884  MathPlotConfigDialog* m_configWindow = NULL;
3885 #endif // ENABLE_MP_CONFIG
3886 
3887  mpOnDeleteLayer m_OnDeleteLayer = NULL;
3888  mpOnUserMouseAction m_OnUserMouseAction = NULL;
3889 
3893  virtual void DesiredBoundsHaveChanged() {};
3894 
3895  private:
3897  void CheckAndReportDesiredBoundsChanges();
3898 
3903  unsigned int GetNewAxisDataID(void)
3904  {
3905  int newID = 0;
3906  for (auto& [yID, yData] : m_AxisDataYList)
3907  {
3908  if(yData.axis)
3909  {
3910  // This ID is used by an axis. Make sure the new ID is larger
3911  newID = std::max(newID, yID + 1);
3912  }
3913  }
3914  return newID;
3915  }
3916 
3917  wxDECLARE_DYNAMIC_CLASS(mpWindow);
3918 
3919  // To have direct access to m_Screenshot_dc
3920  friend mpPrintout;
3921 };
3922 
3923 //-----------------------------------------------------------------------------
3924 // mpText - provided by Val Greene
3925 //-----------------------------------------------------------------------------
3926 
3934 class WXDLLIMPEXP_MATHPLOT mpText: public mpLayer
3935 {
3936  public:
3939  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
3940  {
3941  m_subtype = mptText;
3942  SetName(name);
3943  m_offsetx = 5;
3944  m_offsety = 50;
3945  m_location = mpMarginNone;
3946  m_ZIndex = mpZIndex_TEXT;
3947  }
3948 
3952  mpText(const wxString &name, int offsetx, int offsety);
3953 
3957  mpText(const wxString &name, mpLocation marginLocation);
3958 
3961  virtual bool HasBBox()
3962  {
3963  return false;
3964  }
3965 
3968  void SetLocation(mpLocation location)
3969  {
3970  m_location = location;
3971  }
3972 
3975  mpLocation GetLocation() const
3976  {
3977  return m_location;
3978  }
3979 
3982  void SetOffset(int offX, int offY)
3983  {
3984  m_offsetx = offX;
3985  m_offsety = offY;
3986  }
3987 
3989  void GetOffset(int *offX, int *offY) const
3990  {
3991  *offX = m_offsetx;
3992  *offY = m_offsety;
3993  }
3994 
3995  protected:
3998  mpLocation m_location;
3999 
4002  virtual void DoPlot(wxDC &dc, mpWindow &w);
4003 
4004  wxDECLARE_DYNAMIC_CLASS(mpText);
4005 };
4006 
4010 class WXDLLIMPEXP_MATHPLOT mpTitle: public mpText
4011 {
4012  public:
4015  mpTitle();
4016 
4019  mpTitle(const wxString &name) :
4020  mpText(name, mpMarginTopCenter)
4021  {
4022  m_subtype = mptTitle;
4023  SetPen(*wxWHITE_PEN);
4024  SetBrush(*wxWHITE_BRUSH);
4025  }
4026 
4027  protected:
4028 
4029  wxDECLARE_DYNAMIC_CLASS(mpTitle);
4030 };
4031 
4032 //-----------------------------------------------------------------------------
4033 // mpPrintout - provided by Davide Rondini
4034 //-----------------------------------------------------------------------------
4035 
4040 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4041 {
4042  public:
4043  mpPrintout()
4044  {
4045  plotWindow = NULL;
4046  drawn = false;
4047  stretch_factor = 2;
4048  }
4049 
4050  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4051  virtual ~mpPrintout()
4052  {
4053  ;
4054  }
4055 
4056  void SetDrawState(bool drawState)
4057  {
4058  drawn = drawState;
4059  }
4060 
4061  bool OnPrintPage(int page);
4062  bool HasPage(int page);
4063 
4066  void SetFactor(int factor)
4067  {
4068  stretch_factor = factor;
4069  }
4070 
4071  private:
4072  bool drawn;
4073  mpWindow* plotWindow;
4074  int stretch_factor; // To reduce the size of plot
4075 
4076  protected:
4077 
4078  wxDECLARE_DYNAMIC_CLASS(mpPrintout);
4079 };
4080 
4081 //-----------------------------------------------------------------------------
4082 // mpMovableObject - provided by Jose Luis Blanco
4083 //-----------------------------------------------------------------------------
4091 class WXDLLIMPEXP_MATHPLOT mpMovableObject: public mpFunction
4092 {
4093  public:
4097  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
4098  {
4099  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
4100  m_subtype = mpfMovable;
4101  m_bbox_min_x = m_bbox_max_x = 0;
4102  m_bbox_min_y = m_bbox_max_y = 0;
4103  }
4104 
4105  virtual ~mpMovableObject() {}
4106 
4109  void GetCoordinateBase(double &x, double &y, double &phi) const
4110  {
4111  x = m_reference_x;
4112  y = m_reference_y;
4113  phi = m_reference_phi;
4114  }
4115 
4118  void SetCoordinateBase(double x, double y, double phi = 0)
4119  {
4120  m_reference_x = x;
4121  m_reference_y = y;
4122  m_reference_phi = phi;
4123  m_flags = mpALIGN_NE;
4124  ShapeUpdated();
4125  }
4126 
4127  virtual bool HasBBox()
4128  {
4129  return m_trans_shape_xs.size() != 0;
4130  }
4131 
4134  virtual double GetMinX()
4135  {
4136  return m_bbox_min_x;
4137  }
4138 
4141  virtual double GetMaxX()
4142  {
4143  return m_bbox_max_x;
4144  }
4145 
4148  virtual double GetMinY()
4149  {
4150  return m_bbox_min_y;
4151  }
4152 
4155  virtual double GetMaxY()
4156  {
4157  return m_bbox_max_y;
4158  }
4159 
4160  protected:
4161 
4164  double m_reference_x, m_reference_y, m_reference_phi;
4165 
4166  virtual void DoPlot(wxDC &dc, mpWindow &w);
4167 
4170  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
4171 
4174  std::vector<double> m_shape_xs, m_shape_ys;
4175 
4179  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
4180 
4184  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
4185 
4189  void ShapeUpdated();
4190 
4191  wxDECLARE_DYNAMIC_CLASS(mpMovableObject);
4192 };
4193 
4194 //-----------------------------------------------------------------------------
4195 // mpCovarianceEllipse - provided by Jose Luis Blanco
4196 //-----------------------------------------------------------------------------
4208 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse: public mpMovableObject
4209 {
4210  public:
4214  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
4215  const wxString &layerName = _T("")) : mpMovableObject(),
4216  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
4217  {
4218  m_continuous = true;
4219  m_name = layerName;
4220  RecalculateShape();
4221  }
4222 
4223  virtual ~mpCovarianceEllipse()
4224  {
4225  ;
4226  }
4227 
4228  double GetQuantiles() const
4229  {
4230  return m_quantiles;
4231  }
4232 
4235  void SetQuantiles(double q)
4236  {
4237  m_quantiles = q;
4238  RecalculateShape();
4239  }
4240 
4241  void SetSegments(int segments)
4242  {
4243  m_segments = segments;
4244  }
4245 
4246  int GetSegments() const
4247  {
4248  return m_segments;
4249  }
4250 
4253  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
4254  {
4255  cov_00 = m_cov_00;
4256  cov_01 = m_cov_01;
4257  cov_11 = m_cov_11;
4258  }
4259 
4262  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
4263  {
4264  m_cov_00 = cov_00;
4265  m_cov_01 = cov_01;
4266  m_cov_11 = cov_11;
4267  RecalculateShape();
4268  }
4269 
4270  protected:
4273  double m_cov_00, m_cov_11, m_cov_01;
4274  double m_quantiles;
4275 
4279 
4282  void RecalculateShape();
4283 
4284  wxDECLARE_DYNAMIC_CLASS(mpCovarianceEllipse);
4285 };
4286 
4287 //-----------------------------------------------------------------------------
4288 // mpPolygon - provided by Jose Luis Blanco
4289 //-----------------------------------------------------------------------------
4294 class WXDLLIMPEXP_MATHPLOT mpPolygon: public mpMovableObject
4295 {
4296  public:
4299  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
4300  {
4301  m_continuous = true;
4302  m_name = layerName;
4303  }
4304 
4305  virtual ~mpPolygon()
4306  {
4307  ;
4308  }
4309 
4315  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
4316 
4317  protected:
4318 
4319  wxDECLARE_DYNAMIC_CLASS(mpPolygon);
4320 };
4321 
4322 //-----------------------------------------------------------------------------
4323 // mpBitmapLayer - provided by Jose Luis Blanco
4324 //-----------------------------------------------------------------------------
4329 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer: public mpLayer
4330 {
4331  public:
4335  {
4336  m_min_x = m_max_x = 0;
4337  m_min_y = m_max_y = 0;
4338  m_validImg = false;
4339  m_bitmapChanged = false;
4340  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
4341  }
4342 
4343  virtual ~mpBitmapLayer()
4344  {
4345  ;
4346  }
4347 
4350  void GetBitmapCopy(wxImage &outBmp) const;
4351 
4359  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
4360 
4363  virtual double GetMinX()
4364  {
4365  return m_min_x;
4366  }
4367 
4370  virtual double GetMaxX()
4371  {
4372  return m_max_x;
4373  }
4374 
4377  virtual double GetMinY()
4378  {
4379  return m_min_y;
4380  }
4381 
4384  virtual double GetMaxY()
4385  {
4386  return m_max_y;
4387  }
4388 
4389  protected:
4390 
4393  wxImage m_bitmap;
4394  wxBitmap m_scaledBitmap;
4395  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
4396  bool m_validImg;
4397  bool m_bitmapChanged;
4398 
4401  double m_min_x, m_max_x, m_min_y, m_max_y;
4402 
4403  virtual void DoPlot(wxDC &dc, mpWindow &w);
4404 
4405  wxDECLARE_DYNAMIC_CLASS(mpBitmapLayer);
4406 };
4407 
4408 // utility class
4409 
4410 // Enumeration of classic colour
4411 typedef enum __mp_Colour
4412 {
4413  mpBlue,
4414  mpRed,
4415  mpGreen,
4416  mpPurple,
4417  mpYellow,
4418  mpFuchsia,
4419  mpLime,
4420  mpAqua,
4421  mpOlive
4422 } mpColour;
4423 
4428 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
4429 {
4430  public:
4431  wxIndexColour(unsigned int id)
4432  {
4433  switch (id)
4434  {
4435  case 0:
4436  this->Set(0, 0, 255);
4437  break; // Blue
4438  case 1:
4439  this->Set(255, 0, 0);
4440  break; // Red
4441  case 2:
4442  this->Set(0, 128, 0);
4443  break; // Green
4444  case 3:
4445  this->Set(128, 0, 128);
4446  break; // Purple
4447  case 4:
4448  this->Set(255, 255, 0);
4449  break; // Yellow
4450  case 5:
4451  this->Set(255, 0, 255);
4452  break; // Fuchsia
4453  case 6:
4454  this->Set(0, 255, 0);
4455  break; // Lime
4456  case 7:
4457  this->Set(0, 255, 255);
4458  break; // Aqua/Cyan
4459  case 8:
4460  this->Set(128, 128, 0);
4461  break; // Olive
4462  default:
4463  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
4464  (ChannelType)((rand() * 255) / RAND_MAX));
4465  }
4466  }
4467 };
4468 
4471 // ---------------------------------------------------------------------
4472 #ifdef ENABLE_MP_NAMESPACE
4473  }// namespace MathPlot
4474  // No, iff build enables namespace, its up to app to use it appropriately: using namespace MathPlot;
4475 #endif // ENABLE_MP_NAMESPACE
4476 
4477 #endif // MATHPLOT_H_INCLUDED
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:3997
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2307
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:2643
bool IsHorizontal(void) const
Get if is horizontal line.
Definition: mathplot.h:1519
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:525
int GetAxisID(void)
Return the ID of the Axis.
Definition: mathplot.h:2240
void SetValue(const double value)
Set x or y.
Definition: mathplot.h:1512
mpInfoLegend * m_InfoLegend
pointer to the optional info legend layer
Definition: mathplot.h:3871
enum __YAxis_Align_Type mpYAxis_Align
Alignment for Y axis.
Show legend items with small square with the same color of referred mpLayer.
Definition: mathplot.h:572
double m_min_x
The shape of the bitmap:
Definition: mathplot.h:4401
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:3846
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:2416
void Set(double _min, double _max)
Set min, max function.
Definition: mathplot.h:247
void EnableDoubleBuffer(const bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled).
Definition: mathplot.h:3146
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:926
bool IsLogYaxis(int yAxisID)
Get the log property (true or false) Y layer (Y axis) with a specific Y ID or false if not found...
Definition: mathplot.h:3687
Bitmap type layer.
Definition: mathplot.h:695
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1047
Plot type layer.
Definition: mathplot.h:680
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:3079
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4384
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:1238
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:3651
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1563
void SetYAxisID(unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1472
std::unordered_map< int, mpRange > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:2972
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:4294
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:2874
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:804
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:188
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:1814
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:3842
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:571
__mp_Layer_Type
Definition: mathplot.h:676
Show/Hide grids.
Definition: mathplot.h:513
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:4329
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:2407
bool m_magnetize
For mouse magnetization.
Definition: mathplot.h:3878
mpLabelType
Definition: mathplot.h:649
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2179
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:3862
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:2163
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:4299
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2277
std::unordered_map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:2623
wxCoord y2p(const double y, int yAxisID=0)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:3136
enum __Plot_Align_Name_Type mpPlot_Align
Plot alignment (which corner should plot be placed)
Layer type undefined; SHOULD NOT BE USED.
Definition: mathplot.h:678
enum __mp_Direction_Type mpLegendDirection
Direction for the Legend layer.
__mp_Delete_Action
Action to do with the object associated to the layer when we delete it.
Definition: mathplot.h:711
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1046
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1039
mpRange bound
Range min and max.
Definition: mathplot.h:2610
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1496
Lock x/y scaling aspect.
Definition: mathplot.h:512
void SetItemMode(mpLegendStyle mode)
Set item mode (the element on the left of text representing the plot line may be line, square, or line with symbol).
Definition: mathplot.h:1312
Info box type layer.
Definition: mathplot.h:700
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:3996
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set axis label view mode.
Definition: mathplot.h:2299
Abstract class providing a line.
Definition: mathplot.h:1490
Abstract class providing an vertical line.
Definition: mathplot.h:1555
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2263
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2143
mpRange lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:2612
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:2727
double GetMaxAbs(void) const
Returns max absolute value of the range.
Definition: mathplot.h:333
enum __Info_Type mpInfoType
sub_type values for mpLAYER_INFO
wxPen m_gridpen
Grid&#39;s pen. Default Colour = LIGHT_GREY, width = 1, style = wxPENSTYLE_DOT.
Definition: mathplot.h:2408
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3029
double p2y(const wxCoord pixelCoordY, int yAxisID=0)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:3117
void SetExtraMargin(int extra)
Set the extra margin.
Definition: mathplot.h:3518
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1186
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:4118
double Length(void) const
Length of the range.
Definition: mathplot.h:321
Chart type layer (bar chart)
Definition: mathplot.h:685
double GetPosY(int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3020
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:903
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3169
int m_winY
Holds the mpWindow size. Used to rescale position when window is resized.
Definition: mathplot.h:1188
std::optional< int > m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:3866
~mpBarChart()
Destructor.
Definition: mathplot.h:2073
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:3109
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1054
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:3863
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:3893
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:911
int m_flags
Holds label alignment. Default : mpALIGN_NE.
Definition: mathplot.h:1051
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:3961
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:788
wxPoint GetPosition() const
Returns the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1150
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1267
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:957
~mpPieChart()
Destructor.
Definition: mathplot.h:2134
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1480
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:3537
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1041
Just the end of ZOrder.
Definition: mathplot.h:702
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4148
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:693
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:3461
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:3427
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1400
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:3531
void SetMouseLeftDownAction(mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:3732
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:3833
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:3864
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1643
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:1699
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:3837
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:1049
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:3851
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:4109
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:2651
void ToLog(void)
Convert to log range.
Definition: mathplot.h:339
mpRange GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:2931
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:1294
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:2480
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1050
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:3968
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2039
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3153
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:3838
Plot (function) type layer.
Definition: mathplot.h:698
void UpdateDesiredBoundingBox(mpAxisUpdate update)
Draws the mpWindow on a page for printing.
Definition: mathplot.h:3270
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2323
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1053
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1436
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:740
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1042
bool GetCanDelete(void) const
Get CanDelete for plot.
Definition: mathplot.h:1026
Axis type layer.
Definition: mathplot.h:696
Implementing MathPlotConfigDialogBuilder.
Definition: MathPlotConfig.h:75
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:2187
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:2411
Axis type layer.
Definition: mathplot.h:679
void SetCanDelete(bool canDelete)
Set CanDelete for plot.
Definition: mathplot.h:1019
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4363
bool GetMagnetize() const
Magnetize the position of the mouse in the plot ie draw a vertical and horizontal line...
Definition: mathplot.h:3718
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:3869
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:2413
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:1224
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:2270
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:3626
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:936
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:2594
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1952
mpRange GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:2925
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:3939
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:4393
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:3660
each visible plot is described on its own line, one above the other
Definition: mathplot.h:579
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:2985
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1033
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:652
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:3543
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:1253
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:599
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1888
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4370
Show/Hide info coord.
Definition: mathplot.h:514
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:950
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:4262
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4040
int m_last_ly
For double buffering.
Definition: mathplot.h:3856
struct deprecated("No more used, X and Y are now separated")]] mpFloatRect
A structure for computation of bounds in real units (not in screen pixel) X refer to X axis Y refer t...
Definition: mathplot.h:370
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:3879
wxSize GetSize() const
Returns the size of the box (in pixels)
Definition: mathplot.h:1157
Chart type layer.
Definition: mathplot.h:699
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:2410
Set label for axis in scientific notation.
Definition: mathplot.h:656
enum __mp_Location_Type mpLocation
Location for the Info layer.
void Check(void)
Check to always have a range. If min = max then introduce the 0 to make a range.
Definition: mathplot.h:309
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1184
Copy a screen shot to the clipboard.
Definition: mathplot.h:515
Fit view to match bounding box of all layers.
Definition: mathplot.h:508
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:3975
bool PointIsInside(double px, double py) const
Is point inside this bounding box?
Definition: mathplot.h:477
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:521
wxBitmap * m_buff_bmp
For double buffering.
Definition: mathplot.h:3857
Center view on click position.
Definition: mathplot.h:511
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1482
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:1824
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:540
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:4091
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:608
mpRange desired
Desired range min and max.
Definition: mathplot.h:2611
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:3831
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:1723
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:4174
virtual bool IsLogAxis()
Logarithmic axis.
Definition: mathplot.h:2393
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1443
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:2488
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:4428
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1483
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1408
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:3847
Layer for bar chart.
Definition: mathplot.h:2066
mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:3295
double m_max
Min and max axis values when autosize is false.
Definition: mathplot.h:2412
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1044
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:1273
abstract Layer for chart (bar and pie).
Definition: mathplot.h:2008
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:573
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:469
bool GetBoundingBox(mpRange *boundX, mpRange *boundY, int yAxisID)
Return the bounding box coordinates for the Y axis of ID yAxisID.
Definition: mathplot.h:3344
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:919
const wxRect & GetRectangle() const
Returns the current rectangle coordinates.
Definition: mathplot.h:1164
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:4184
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:3307
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:654
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:560
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1479
double GetDesiredYmin(int yAxisID)
Return the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:3326
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:3484
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:1844
int m_symbolSize2
Size of the symbol div 2.
Definition: mathplot.h:1481
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4377
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2339
void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2284
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1915
int GetMarginRight(bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:3469
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1541
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:1863
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:1872
double GetDesiredYmax(int yAxisID)
Return the top layer-border coordinate that the user wants the mpWindow to show (it may be not exactl...
Definition: mathplot.h:3337
Text box type layer.
Definition: mathplot.h:682
mpMouseButtonAction GetMouseLeftDownAction()
Returns the type of action for the left mouse button.
Definition: mathplot.h:3741
double pos
Position.
Definition: mathplot.h:2609
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:3438
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:550
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:3853
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1099
Load a file.
Definition: mathplot.h:519
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:752
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:3989
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:3848
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:1126
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:761
Line (horizontal or vertical) type layer.
Definition: mathplot.h:697
wxBitmap * m_zoom_bmp
For zoom selection.
Definition: mathplot.h:3874
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1208
std::unordered_map< int, mpRange > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:2958
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:3397
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:3841
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:3128
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1415
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:3830
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1308
wxRect m_oldDim
Keep the old values of m_dim.
Definition: mathplot.h:1185
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:663
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:3835
bool IsLogXaxis()
Is this an X axis to be displayed with log scale? It is really an axis property but as we need to con...
Definition: mathplot.h:3676
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3055
int GetBarWidth(void) const
return the width of the bar
Definition: mathplot.h:1749
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:3645
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1246
void SetAxisID(unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2249
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1937
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:3577
bool m_enableDoubleBuffer
For double buffering. Default enabled.
Definition: mathplot.h:3858
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1390
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1590
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2150
mpTitle(const wxString &name)
Definition: mathplot.h:4019
Plot layer implementing a simple title.
Definition: mathplot.h:4010
Set no label for axis (useful for bar)
Definition: mathplot.h:669
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:2522
enum __mp_Layer_ZOrder mpLayerZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:4127
bool ViewAsBar(void) const
return true if XY series is plotted with bar
Definition: mathplot.h:1757
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1189
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:984
double GetCenter(void) const
Center of the range.
Definition: mathplot.h:327
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:3552
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:2996
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1012
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1048
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:4179
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:3525
void Assign(double value1, double value2)
Assign values to min and max.
Definition: mathplot.h:254
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2331
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:1715
enum __XAxis_Align_Type mpXAxis_Align
Alignment for X axis.
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1478
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:3666
std::vector< double > m_xs
The internal copy of the set of data to draw.
Definition: mathplot.h:1880
mpRange GetBoundY(int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:2939
~mpChart()
Destructor.
Definition: mathplot.h:2015
Abstract class providing an horizontal line.
Definition: mathplot.h:1533
Zoom into view at clickposition / window center.
Definition: mathplot.h:509
int GetMarginLeft(bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:3509
mpRange(double value1, double value2)
Create range with the 2 values.
Definition: mathplot.h:232
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:3834
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:4278
double scale
Scale.
Definition: mathplot.h:2608
void Rewind()
Rewind value enumeration with mpFXY::GetNextXY.
Definition: mathplot.h:1897
Zoom out.
Definition: mathplot.h:510
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2220
enum __mp_Layer_Type mpLayerType
Major type of an mpLayer (detail is in subtype)
void SetFont(const wxFont &font)
Set layer font.
Definition: mathplot.h:879
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:2657
mpScaleY(const wxString &name=_T("Y"), int flags=mpALIGN_CENTERY, bool grids=false, std::optional< unsigned int > yAxisID=std::nullopt, mpLabelType labelType=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:2529
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition: mathplot.h:300
int m_reserveXY
Memory reserved for m_xs and m_ys.
Definition: mathplot.h:1884
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:577
mpRange GetDesiredBoundY(int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:2948
void Update(double _min, double _max)
Update range with new min and max values if this expand the range If _min < min then min = _min and i...
Definition: mathplot.h:290
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:4208
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2292
int GetMarginTop(bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:3452
double m_minX
Loaded at SetData.
Definition: mathplot.h:1892
mpInfoCoords * m_InfoCoords
pointer to the optional info coords layer
Definition: mathplot.h:3870
double GetDesiredXmax() const
Return the right-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:3316
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:661
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:2605
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:569
Layer for pie chart.
Definition: mathplot.h:2127
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:895
Set label user defined.
Definition: mathplot.h:667
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:4214
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:887
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:3859
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1043
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:3005
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:659
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:665
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:4253
mpRange GetScale() const
Return m_min and m_max scale as a mpRange.
Definition: mathplot.h:2385
Bitmap type layer.
Definition: mathplot.h:683
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1171
bool IsVisible() const
Checks whether the layer is visible or not.
Definition: mathplot.h:977
mpRange()
Default constructor.
Definition: mathplot.h:225
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:2256
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:769
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:998
bool IsSet()
Check if this mpRange has been assigned any values.
Definition: mathplot.h:269
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1451
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2414
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:4096
enum __mp_Delete_Action mpDeleteAction
Action to do with the object associated to the layer when we delete it.
Info box type layer.
Definition: mathplot.h:681
void SetPos(const double posX, std::unordered_map< int, double > &posYList)
Set current view&#39;s X and Y position and refresh display.
Definition: mathplot.h:3100
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3090
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3037
virtual bool DoBeforePlot()
This is the only case where we don&#39;t need and Y axis So no need to test m_yAxisID.
Definition: mathplot.h:1576
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:812
Plot layer implementing a text string.
Definition: mathplot.h:3934
virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
Set the layer&#39;s subtype in caller variable, and return true if the layer is of type "typeOfInterest"...
Definition: mathplot.h:779
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:3849
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4155
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:3583
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:964
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1045
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:3478
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:796
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1187
int GetMarginBottom(bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:3492
Shows information about the mouse commands.
Definition: mathplot.h:520
void SetLogYaxis(int yAxisID, bool log)
Set the log property (true or false) for a Y layer (Y axis) given by is ID.
Definition: mathplot.h:3706
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:3444
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:2888
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:3836
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:3881
legend components follow each other horizontally on a single line
Definition: mathplot.h:580
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1325
enum __Text_Type mpTextType
sub_type values for mpLAYER_TEXT
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above)...
Definition: mathplot.h:4235
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1464
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:3843
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:219
void Update(double value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:278
bool PointIsInside(double point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:346
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:4164
double GetScaleY(int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:2913
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:2171
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1422
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4134
Plot layer, abstract base class.
Definition: mathplot.h:728
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1052
double GetValue() const
Set x or y.
Definition: mathplot.h:1504
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:3982
void SetFactor(int factor)
Definition: mathplot.h:4066
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:863
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1040
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:2415
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:3840
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:3865
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:943
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:871
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1070
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:4273
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:3501
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:3829
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:2409
std::map< int, mpAxisData > GetSortedAxisDataYList(void) const
Get a sorted version of the Y-axis data map.
Definition: mathplot.h:3045
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:3845
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1977
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1178
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:3860
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:3852
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:991
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2232
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4141
bool IsRepainting() const
Checks if we are repainting.
Definition: mathplot.h:3178
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:3249
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2315
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1429
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:4334
void SetScaleY(const double scaleY, int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:2897
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:2631
Text box type layer.
Definition: mathplot.h:701
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:2743
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:1005
Line (horizontal or vertical) type layer.
Definition: mathplot.h:684
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1930