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 
56 //this definition uses windows dll to export function.
57 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
58 //mathplot_EXPORTS will be defined by cmake
59 #ifdef mathplot_EXPORTS
60 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
61 #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
62 #else // not making DLL
63 #define WXDLLIMPEXP_MATHPLOT
64 #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
65 #endif
66 
67 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
68 #pragma interface "mathplot.h"
69 #endif
70 
71 #include <vector>
72 #include <map>
73 #include <unordered_map>
74 #include <optional>
75 
76 // #include <wx/wx.h>
77 #include <wx/defs.h>
78 #include <wx/menu.h>
79 #include <wx/scrolwin.h>
80 #include <wx/event.h>
81 #include <wx/dynarray.h>
82 #include <wx/pen.h>
83 #include <wx/dcmemory.h>
84 #include <wx/string.h>
85 #include <wx/print.h>
86 #include <wx/image.h>
87 #include <wx/intl.h>
88 
89 #include <cmath>
90 #include <deque>
91 #include <algorithm>
92 
98 #if defined(MP_USER_INCLUDE)
99 #define header MP_USER_INCLUDE.h
100 #define xstr(x) #x
101 #define str(x) xstr(x)
102 #include str(header)
103 #undef header
104 #endif
105 
106 // No, this is supposed to be a build parameter: #define ENABLE_MP_CONFIG
107 #ifdef ENABLE_MP_CONFIG
108  #include "MathPlotConfig.h"
109 #endif // ENABLE_MP_CONFIG
110 
115 // No, this is supposed to be a build parameter: #define ENABLE_MP_NAMESPACE
116 #ifdef ENABLE_MP_NAMESPACE
117  namespace MathPlot {
118 #endif // ENABLE_MP_NAMESPACE
119 
120 #ifdef ENABLE_MP_DEBUG
121 // For memory leak debug
122 #ifdef _WINDOWS
123 #ifdef _DEBUG
124 #include <crtdbg.h>
125 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
126 #else
127 #define DEBUG_NEW new
128 #endif // _DEBUG
129 #endif // _WINDOWS
130 #endif // ENABLE_MP_DEBUG
131 
132 // Separation for axes when set close to border
133 #define X_BORDER_SEPARATION 40
134 #define Y_BORDER_SEPARATION 60
135 
137 #define mpX_LOCALTIME 0x10
138 
139 #define mpX_UTCTIME 0x20
140 #define mpX_RAWTIME mpX_UTCTIME
141 
142 // An epsilon for float comparison to 0
143 #define EPSILON 1e-8
144 #define ISNOTNULL(x) (fabs(x) > EPSILON)
145 
146 // A small extra margin for the plot boundary
147 #define EXTRA_MARGIN 8
148 
149 #define ZOOM_AROUND_CENTER -1
150 
151 //-----------------------------------------------------------------------------
152 // classes
153 //-----------------------------------------------------------------------------
154 
155 class WXDLLIMPEXP_MATHPLOT mpLayer;
156 class WXDLLIMPEXP_MATHPLOT mpFunction;
157 class WXDLLIMPEXP_MATHPLOT mpLine;
158 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine;
159 class WXDLLIMPEXP_MATHPLOT mpVerticalLine;
160 class WXDLLIMPEXP_MATHPLOT mpFX;
161 class WXDLLIMPEXP_MATHPLOT mpFY;
162 class WXDLLIMPEXP_MATHPLOT mpFXY;
163 class WXDLLIMPEXP_MATHPLOT mpFXYVector;
164 class WXDLLIMPEXP_MATHPLOT mpProfile;
165 class WXDLLIMPEXP_MATHPLOT mpChart;
166 class WXDLLIMPEXP_MATHPLOT mpBarChart;
167 class WXDLLIMPEXP_MATHPLOT mpScale;
168 class WXDLLIMPEXP_MATHPLOT mpScaleX;
169 class WXDLLIMPEXP_MATHPLOT mpScaleY;
170 class WXDLLIMPEXP_MATHPLOT mpInfoLayer;
171 class WXDLLIMPEXP_MATHPLOT mpInfoCoords;
172 class WXDLLIMPEXP_MATHPLOT mpInfoLegend;
173 class WXDLLIMPEXP_MATHPLOT mpWindow;
174 class WXDLLIMPEXP_MATHPLOT mpText;
175 class WXDLLIMPEXP_MATHPLOT mpTitle;
176 class WXDLLIMPEXP_MATHPLOT mpPrintout;
177 class WXDLLIMPEXP_MATHPLOT mpMovableObject;
178 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse;
179 class WXDLLIMPEXP_MATHPLOT mpPolygon;
180 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer;
181 
182 #ifdef ENABLE_MP_CONFIG
184 #endif // ENABLE_MP_CONFIG
185 
187 typedef union
188 {
189  struct
190  {
191  wxCoord startPx;
192  wxCoord endPx;
193  wxCoord startPy;
194  wxCoord endPy;
195  };
196  struct
197  {
198  wxCoord left;
199  wxCoord top;
200  wxCoord right;
201  wxCoord bottom;
202  };
203  struct
204  {
205  wxCoord x1;
206  wxCoord y1;
207  wxCoord x2;
208  wxCoord y2;
209  };
210  wxCoord tab[4];
211 } mpRect;
212 
218 struct mpRange
219 {
220  double min = 0.0f;
221  double max = 0.0f;
222 
225  {
226  min = 0.0f;
227  max = 0.0f;
228  }
229 
231  mpRange(double value1, double value2)
232  {
233  if (value1 < value2)
234  {
235  min = value1;
236  max = value2;
237  }
238  else
239  {
240  min = value2;
241  max = value1;
242  }
243  }
244 
246  void Set(double _min, double _max)
247  {
248  min = _min;
249  max = _max;
250  }
251 
253  void Assign(double value1, double value2)
254  {
255  if (value1 < value2)
256  {
257  min = value1;
258  max = value2;
259  }
260  else
261  {
262  min = value2;
263  max = value1;
264  }
265  }
266 
268  bool IsSet()
269  {
270  return ((min != 0.0f) || (max != 0.0f));
271  }
272 
277  void Update(double value)
278  {
279  if (value < min)
280  min = value;
281  else
282  if (value > max)
283  max = value;
284  }
285 
289  void Update(double _min, double _max)
290  {
291  if (_min < min)
292  min = _min;
293  if (_max > max)
294  max = _max;
295  }
296 
299  void Update(mpRange range)
300  {
301  if (range.min < min)
302  min = range.min;
303  if (range.max > max)
304  max = range.max;
305  }
306 
308  void Check(void)
309  {
310  if (min == max)
311  {
312  if (max > 0)
313  min = 0;
314  else
315  max = 0;
316  }
317  }
318 
320  double Length(void) const
321  {
322  return max - min;
323  }
324 
326  double GetCenter(void) const
327  {
328  return (min + max) / 2;
329  }
330 
332  double GetMaxAbs(void) const
333  {
334  return std::max(fabs(min), fabs(max));
335  }
336 
338  void ToLog(void)
339  {
340  min = (min > 0) ? log10(min) : 0;
341  max = (max > 0) ? log10(max) : 0;
342  }
343 
345  bool PointIsInside(double point) const
346  {
347  return ((point >= min) && (point <= max));
348  }
349 
350 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
351  bool operator==(const mpRange&) const = default;
352 #else
353  bool operator==(const mpRange &other) const
354  {
355  return (min == other.min) && (max == other.max);
356  }
357  bool operator!=(const mpRange& other) const
358  {
359  return !(*this == other);
360  }
361 #endif
362 };
363 
369 struct [[deprecated("No more used, X and Y are now separated")]] mpFloatRect
370 {
371  mpRange x;
372  std::vector<mpRange> y;
373 
380  mpFloatRect(mpWindow& w);
381 
383  mpFloatRect() = delete;
384 
386  bool PointIsInside(double px, double py, size_t yAxisID = 0) const {
387  if (yAxisID < y.size())
388  {
389  if( (px < x.min || px > x.max) ||
390  (py < y[yAxisID].min || py > y[yAxisID].max))
391  {
392  return false;
393  }
394  }
395  else
396  {
397  return false;
398  }
399 
400  return true;
401  }
403  void UpdateBoundingBoxToInclude(double px, double py, size_t yAxisID = 0) {
404  assert(yAxisID < y.size());
405  if (yAxisID < y.size())
406  {
407  if (px < x.min ) x.min = px;
408  else if (px > x.max ) x.max = px;
409  if (py < y[yAxisID].min ) y[yAxisID].min = py;
410  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
411  }
412  }
414  void InitializeBoundingBox(double px, double py, size_t yAxisID = 0) {
415  assert(yAxisID < y.size());
416  if (yAxisID < y.size())
417  {
418  x.min = x.max = px;
419  y[yAxisID].min = y[yAxisID].max = py;
420  }
421  }
423  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
425 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
426  bool operator==(const mpFloatRect&) const = default;
427 #else
428  // We compare with an epsilon precision
429  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
430  bool operator==(const mpFloatRect& rect) const
431  {
432  auto Same = [](double a, double b) {
433  return std::fabs(a - b) < EPSILON;
434  };
435 
436  // Compare scalar members
437  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
438  {
439  return false;
440  }
441 
442  // Compare vector sizes
443  if (y.size() != rect.y.size())
444  {
445  return false;
446  }
447 
448  // Compare each Y boundary
449  for (size_t i = 0; i < y.size(); ++i)
450  {
451  if (!Same(y[i].min, rect.y[i].min) ||
452  !Same(y[i].max, rect.y[i].max) )
453  {
454  return false;
455  }
456  }
457 
458  return true;
459  }
460 #endif
461 };
462 
469 {
470  mpRange x;
471  mpRange y;
472 
473  mpFloatRectSimple(mpRange _x, mpRange _y) : x(_x), y(_y) { };
474 
476  bool PointIsInside(double px, double py) const {
477  return x.PointIsInside(px) && y.PointIsInside(py);
478  }
479 
480  /* Update bounding box (X and Y axis) to include this point.
481  * Expand the range to include the point.
482  * @param px: point on x-axis
483  * @param py: point on y-axis
484  */
485  void UpdateBoundingBoxToInclude(double px, double py)
486  {
487  x.Update(px);
488  y.Update(py);
489  }
490 
491  /* Initialize bounding box with an initial point
492  * @param px: point on x-axis
493  * @param py: point on y-axis
494  */
495  void InitializeBoundingBox(double px, double py)
496  {
497  x.Set(px, px);
498  y.Set(py, py);
499  }
500 };
501 
505 enum
506 {
507  mpID_FIT = 2000,
515 #ifdef ENABLE_MP_CONFIG
516  mpID_CONFIG,
517 #endif // ENABLE_MP_CONFIG
521 };
522 
524 typedef enum __mp_Location_Type
525 {
526  mpMarginLeftCenter,
527  mpMarginTopLeft,
528  mpMarginTopCenter,
529  mpMarginTopRight,
530  mpMarginRightCenter,
531  mpMarginBottomLeft,
532  mpMarginBottomCenter,
533  mpMarginBottomRight,
534  mpMarginNone,
535  mpCursor // only for mpInfoCoords
536 } mpLocation;
537 
539 typedef enum __XAxis_Align_Type
540 {
541  mpALIGN_BORDER_BOTTOM = 10,
542  mpALIGN_BOTTOM,
543  mpALIGN_CENTERX,
544  mpALIGN_TOP,
545  mpALIGN_BORDER_TOP
546 } mpXAxis_Align;
547 
549 typedef enum __YAxis_Align_Type
550 {
551  mpALIGN_BORDER_LEFT = 20,
552  mpALIGN_LEFT,
553  mpALIGN_CENTERY,
554  mpALIGN_RIGHT,
555  mpALIGN_BORDER_RIGHT
556 } mpYAxis_Align;
557 
560 {
561  mpALIGN_NW = 5,
562  mpALIGN_NE,
563  mpALIGN_SE,
564  mpALIGN_SW
565 } mpPlot_Align;
566 
568 typedef enum __mp_Style_Type
569 {
573 } mpLegendStyle;
574 
577 {
581 
582 typedef enum __Symbol_Type
583 {
584  mpsNone,
585  mpsCircle,
586  mpsSquare,
587  mpsUpTriangle,
588  mpsDownTriangle,
589  mpsCross,
590  mpsPlus
591 } mpSymbol;
592 
593 //-----------------------------------------------------------------------------
594 // mpLayer sub_type values
595 //-----------------------------------------------------------------------------
596 
598 typedef enum __Info_Type
599 {
600  mpiNone, // never used
601  mpiInfo,
602  mpiCoords,
603  mpiLegend
604 } mpInfoType;
605 
607 typedef enum __Text_Type
608 {
609  mptNone, // never used
610  mptText,
611  mptTitle
612 } mpTextType;
613 
614 typedef enum __Function_Type
615 {
616  mpfNone,
617  mpfFX,
618  mpfFY,
619  mpfFXY,
620  mpfFXYVector,
621  mpfMovable,
622  mpfLine,
623  mpfAllType
624 } mpFunctionType;
625 
626 typedef enum __Scale_Type
627 {
628  mpsScaleNone,
629  mpsScaleX,
630  mpsScaleY,
631  mpsAllType
632 } mpScaleType;
633 
634 typedef enum __Chart_Type
635 {
636  mpcChartNone,
637  mpcBarChart,
638  mpcPieChart,
639  mpcAllType
640 } mpChartType;
641 
642 enum mpMouseButtonAction
643 {
644  mpMouseBoxZoom,
645  mpMouseDragZoom,
646 };
647 
649 {
669 };
670 
671 //-----------------------------------------------------------------------------
672 // mpLayer
673 //-----------------------------------------------------------------------------
674 
675 typedef enum __mp_Layer_Type
676 {
685 } mpLayerType;
686 
692 typedef enum __mp_Layer_ZOrder
693 {
702 } mpLayerZOrder;
703 
710 typedef enum __mp_Delete_Action
711 {
712  mpNoDelete,
713  mpYesDelete,
714  mpForceDelete
716 
727 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
728 {
729  public:
730  mpLayer(mpLayerType layerType);
731 
732  virtual ~mpLayer()
733  {
734  ;
735  }
736 
740  {
741  m_win = &w;
742  }
743 
751  virtual bool HasBBox()
752  {
753  return true;
754  }
755 
760  mpLayerType GetLayerType() const
761  {
762  return m_type;
763  }
764 
768  int GetLayerSubType() const
769  {
770  return m_subtype;
771  }
772 
778  virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
779  {
780  *subtype = m_subtype;
781  return (m_type == typeOfInterest);
782  }
783 
787  virtual double GetMinX()
788  {
789  return -1.0;
790  }
791 
795  virtual double GetMaxX()
796  {
797  return 1.0;
798  }
799 
803  virtual double GetMinY()
804  {
805  return -1.0;
806  }
807 
811  virtual double GetMaxY()
812  {
813  return 1.0;
814  }
815 
857  void Plot(wxDC &dc, mpWindow &w);
858 
862  void SetName(const wxString &name)
863  {
864  m_name = name;
865  }
866 
870  const wxString& GetName() const
871  {
872  return m_name;
873  }
874 
878  void SetFont(const wxFont &font)
879  {
880  m_font = font;
881  }
882 
886  const wxFont& GetFont() const
887  {
888  return m_font;
889  }
890 
894  void SetFontColour(const wxColour &colour)
895  {
896  m_fontcolour = colour;
897  }
898 
902  const wxColour& GetFontColour() const
903  {
904  return m_fontcolour;
905  }
906 
910  void SetPen(const wxPen &pen)
911  {
912  m_pen = pen;
913  }
914 
918  const wxPen& GetPen() const
919  {
920  return m_pen;
921  }
922 
925  void SetBrush(const wxBrush &brush)
926  {
927  if (brush == wxNullBrush)
928  m_brush = *wxTRANSPARENT_BRUSH;
929  else
930  m_brush = brush;
931  }
932 
935  const wxBrush& GetBrush() const
936  {
937  return m_brush;
938  }
939 
942  void SetShowName(bool show)
943  {
944  m_showName = show;
945  }
946 
949  inline bool GetShowName() const
950  {
951  return m_showName;
952  }
953 
956  void SetDrawOutsideMargins(bool drawModeOutside)
957  {
958  m_drawOutsideMargins = drawModeOutside;
959  }
960 
964  {
965  return m_drawOutsideMargins;
966  }
967 
972  wxBitmap GetColourSquare(int side = 16);
973 
976  inline bool IsVisible() const
977  {
978  return m_visible;
979  }
980 
983  virtual void SetVisible(bool show)
984  {
985  m_visible = show;
986  }
987 
990  inline bool IsTractable() const
991  {
992  return m_tractable;
993  }
994 
997  virtual void SetTractable(bool track)
998  {
999  m_tractable = track;
1000  }
1001 
1004  void SetAlign(int align)
1005  {
1006  m_flags = align;
1007  }
1008 
1011  int GetAlign() const
1012  {
1013  return m_flags;
1014  }
1015 
1018  void SetCanDelete(bool canDelete)
1019  {
1020  m_CanDelete = canDelete;
1021  }
1022 
1025  bool GetCanDelete(void) const
1026  {
1027  return m_CanDelete;
1028  }
1029 
1032  mpLayerZOrder GetZIndex(void) const
1033  {
1034  return m_ZIndex;
1035  }
1036 
1037  protected:
1038  const mpLayerType m_type;
1041  wxFont m_font;
1042  wxColour m_fontcolour;
1043  wxPen m_pen;
1044  wxBrush m_brush;
1045  wxString m_name;
1046  bool m_showName;
1048  bool m_visible;
1050  int m_flags;
1053  mpLayerZOrder m_ZIndex;
1054 
1057  void UpdateContext(wxDC &dc) const;
1058 
1063  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1064 
1069  virtual bool DoBeforePlot()
1070  {
1071  return true;
1072  }
1073 
1080  void CheckLog(double *x, double *y, int yAxisID);
1081 
1082  private:
1083  bool m_busy;
1084  mpLayer() = delete; // default ctor not implemented/permitted
1085 
1086  wxDECLARE_DYNAMIC_CLASS(mpLayer);
1087 };
1088 
1089 //-----------------------------------------------------------------------------
1090 // mpInfoLayer
1091 //-----------------------------------------------------------------------------
1092 
1098 class WXDLLIMPEXP_MATHPLOT mpInfoLayer: public mpLayer
1099 {
1100  public:
1102  mpInfoLayer();
1103 
1108  mpInfoLayer(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1109 
1111  virtual ~mpInfoLayer();
1112 
1115  virtual void SetVisible(bool show);
1116 
1121  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1122 
1125  virtual bool HasBBox()
1126  {
1127  return false;
1128  }
1129 
1133  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1134 
1138  virtual bool Inside(const wxPoint &point);
1139 
1142  virtual void Move(wxPoint delta);
1143 
1145  virtual void UpdateReference();
1146 
1149  wxPoint GetPosition() const
1150  {
1151  return m_dim.GetPosition();
1152  }
1153 
1156  wxSize GetSize() const
1157  {
1158  return m_dim.GetSize();
1159  }
1160 
1163  const wxRect& GetRectangle() const
1164  {
1165  return m_dim;
1166  }
1167 
1170  void SetLocation(mpLocation location)
1171  {
1172  m_location = location;
1173  }
1174 
1177  mpLocation GetLocation() const
1178  {
1179  return m_location;
1180  }
1181 
1182  protected:
1183  wxRect m_dim;
1184  wxRect m_oldDim;
1185  wxBitmap* m_info_bmp;
1186  wxPoint m_reference;
1187  int m_winX, m_winY;
1188  mpLocation m_location;
1189 
1194  virtual void DoPlot(wxDC &dc, mpWindow &w);
1195 
1198  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1199 
1200  wxDECLARE_DYNAMIC_CLASS(mpInfoLayer);
1201 };
1202 
1207 class WXDLLIMPEXP_MATHPLOT mpInfoCoords: public mpInfoLayer
1208 {
1209  public:
1211  mpInfoCoords();
1212 
1214  mpInfoCoords(mpLocation location);
1215 
1220  mpInfoCoords(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1221 
1224  {
1225  ;
1226  }
1227 
1231  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1232 
1233  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1234 
1237  void SetLabelMode(mpLabelType mode, unsigned int time_conv = mpX_RAWTIME)
1238  {
1239  m_labelType = mode;
1240  m_timeConv = time_conv;
1241  }
1242 
1245  void SetSeriesCoord(bool show)
1246  {
1247  m_series_coord = show;
1248  }
1249 
1252  bool IsSeriesCoord() const
1253  {
1254  return m_series_coord;
1255  }
1256 
1262  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1263 
1266  void SetPenSeries(const wxPen &pen)
1267  {
1268  m_penSeries = pen;
1269  }
1270 
1271  protected:
1272  wxString m_content;
1273  mpLabelType m_labelType;
1274  unsigned int m_timeConv;
1275  wxCoord m_mouseX;
1276  wxCoord m_mouseY;
1277  bool m_series_coord;
1278  wxPen m_penSeries;
1279 
1284  virtual void DoPlot(wxDC &dc, mpWindow &w);
1285 
1286  wxDECLARE_DYNAMIC_CLASS(mpInfoCoords);
1287 };
1288 
1293 class WXDLLIMPEXP_MATHPLOT mpInfoLegend: public mpInfoLayer
1294 {
1295  public:
1297  mpInfoLegend();
1298 
1304  mpInfoLegend(wxRect rect, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginNone);
1305 
1308 
1311  void SetItemMode(mpLegendStyle mode)
1312  {
1313  m_item_mode = mode;
1314  m_needs_update = true;
1315  }
1316 
1317  mpLegendStyle GetItemMode() const
1318  {
1319  return m_item_mode;
1320  }
1321 
1324  void SetItemDirection(mpLegendDirection mode)
1325  {
1326  m_item_direction = mode;
1327  m_needs_update = true;
1328  }
1329 
1330  mpLegendDirection GetItemDirection() const
1331  {
1332  return m_item_direction;
1333  }
1334 
1335  void SetNeedUpdate()
1336  {
1337  m_needs_update = true;
1338  }
1339 
1341  int GetPointed(mpWindow &w, wxPoint eventPoint);
1342 
1343  protected:
1344  mpLegendStyle m_item_mode;
1345  mpLegendDirection m_item_direction;
1346 
1351  virtual void DoPlot(wxDC &dc, mpWindow &w);
1352 
1353  private:
1355  struct LegendDetail
1356  {
1357  unsigned int layerIdx;
1358  wxCoord legendEnd;
1359  };
1361  std::vector<LegendDetail> m_LegendDetailList;
1362  bool m_needs_update;
1363 
1373  void UpdateBitmap(wxDC &dc, mpWindow &w);
1374 
1375  wxDECLARE_DYNAMIC_CLASS(mpInfoLegend);
1376 };
1377 
1378 //-----------------------------------------------------------------------------
1379 // mpLayer implementations - functions
1380 //-----------------------------------------------------------------------------
1381 
1389 class WXDLLIMPEXP_MATHPLOT mpFunction: public mpLayer
1390 {
1391  public:
1394  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1395 
1399  void SetContinuity(bool continuity)
1400  {
1401  m_continuous = continuity;
1402  }
1403 
1407  bool GetContinuity() const
1408  {
1409  return m_continuous;
1410  }
1411 
1414  void SetStep(unsigned int step)
1415  {
1416  m_step = step;
1417  }
1418 
1421  unsigned int GetStep() const
1422  {
1423  return m_step;
1424  }
1425 
1428  void SetSymbol(mpSymbol symbol)
1429  {
1430  m_symbol = symbol;
1431  }
1432 
1435  mpSymbol GetSymbol() const
1436  {
1437  return m_symbol;
1438  }
1439 
1442  void SetSymbolSize(int size)
1443  {
1444  m_symbolSize = size;
1445  m_symbolSize2 = size / 2;
1446  }
1447 
1450  int GetSymbolSize() const
1451  {
1452  return m_symbolSize;
1453  }
1454 
1458  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1459 
1463  int GetYAxisID() const
1464  {
1465  return m_yAxisID;
1466  }
1467 
1471  void SetYAxisID(unsigned int yAxisID)
1472  {
1473  m_yAxisID = yAxisID;
1474  }
1475 
1476  protected:
1478  mpSymbol m_symbol;
1481  unsigned int m_step;
1483 
1484  wxDECLARE_DYNAMIC_CLASS(mpFunction);
1485 };
1486 
1489 class WXDLLIMPEXP_MATHPLOT mpLine: public mpFunction
1490 {
1491  public:
1492  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1493 
1494  // We don't want to include line (horizontal or vertical) in BBox computation
1495  virtual bool HasBBox() override
1496  {
1497  return false;
1498  }
1499 
1503  double GetValue() const
1504  {
1505  return m_value;
1506  }
1507 
1511  void SetValue(const double value)
1512  {
1513  m_value = value;
1514  }
1515 
1518  bool IsHorizontal(void) const
1519  {
1520  return m_IsHorizontal;
1521  }
1522 
1523  protected:
1524  double m_value;
1525  bool m_IsHorizontal;
1526 
1527  wxDECLARE_DYNAMIC_CLASS(mpLine);
1528 };
1529 
1532 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine: public mpLine
1533 {
1534  public:
1535  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1536 
1540  void SetYValue(const double yvalue)
1541  {
1542  SetValue(yvalue);
1543  }
1544 
1545  protected:
1546 
1547  virtual void DoPlot(wxDC &dc, mpWindow &w);
1548 
1549  wxDECLARE_DYNAMIC_CLASS(mpHorizontalLine);
1550 };
1551 
1554 class WXDLLIMPEXP_MATHPLOT mpVerticalLine: public mpLine
1555 {
1556  public:
1557  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1558 
1562  void SetXValue(const double xvalue)
1563  {
1564  SetValue(xvalue);
1565  }
1566 
1567  protected:
1568 
1569  virtual void DoPlot(wxDC &dc, mpWindow &w);
1570 
1575  virtual bool DoBeforePlot()
1576  {
1577  return true;
1578  }
1579 
1580  wxDECLARE_DYNAMIC_CLASS(mpVerticalLine);
1581 };
1582 
1589 class WXDLLIMPEXP_MATHPLOT mpFX: public mpFunction
1590 {
1591  public:
1595  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
1596 
1602  virtual double GetY(double x) = 0;
1603 
1608  double DoGetY(double x);
1609 
1614  void DefineDoGetY(void);
1615 
1616  protected:
1617 
1618  // Pointer function to the appropriate DoGetY function
1619  double (mpFX::*pDoGetY)(double x);
1620 
1625  virtual void DoPlot(wxDC &dc, mpWindow &w);
1626 
1630  double NormalDoGetY(double x);
1631  double LogDoGetY(double x);
1632 
1633  wxDECLARE_DYNAMIC_CLASS(mpFX);
1634 };
1635 
1642 class WXDLLIMPEXP_MATHPLOT mpFY: public mpFunction
1643 {
1644  public:
1648  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
1649 
1655  virtual double GetX(double y) = 0;
1656 
1661  double DoGetX(double y);
1662 
1667  void DefineDoGetX(void);
1668 
1669  protected:
1670 
1671  // Pointer function to the appropriate DoGetX function
1672  double (mpFY::*pDoGetX)(double y);
1673 
1678  virtual void DoPlot(wxDC &dc, mpWindow &w);
1679 
1683  double NormalDoGetX(double y);
1684  double LogDoGetX(double y);
1685 
1686  wxDECLARE_DYNAMIC_CLASS(mpFY);
1687 };
1688 
1698 class WXDLLIMPEXP_MATHPLOT mpFXY: public mpFunction
1699 {
1700  public:
1704  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, unsigned int yAxisID = 0);
1705 
1709  virtual void Rewind() = 0;
1710 
1714  virtual void Clear()
1715  {
1716  ;
1717  }
1718 
1722  virtual int GetSize()
1723  {
1724  return 0;
1725  }
1726 
1733  virtual bool GetNextXY(double *x, double *y) = 0;
1734 
1738  bool DoGetNextXY(double *x, double *y);
1739 
1743  void SetViewMode(bool asBar);
1744 
1748  int GetBarWidth(void) const
1749  {
1750  return m_BarWidth;
1751  }
1752 
1756  bool ViewAsBar(void) const
1757  {
1758  return m_ViewAsBar;
1759  }
1760 
1761  protected:
1762 
1763  // Data to calculate label positioning
1764  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
1765 
1766  // Min delta between 2 x coordinate (used for view as bar)
1767  double m_deltaX, m_deltaY;
1768 
1769  // The width of a bar
1770  int m_BarWidth;
1771 
1772  // Plot data as bar graph
1773  bool m_ViewAsBar = false;
1774 
1779  virtual void DoPlot(wxDC &dc, mpWindow &w);
1780 
1785  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
1786 
1787  wxDECLARE_DYNAMIC_CLASS(mpFXY);
1788 };
1789 
1790 //-----------------------------------------------------------------------------
1791 // mpFXYVector - provided by Jose Luis Blanco
1792 //-----------------------------------------------------------------------------
1793 
1813 class WXDLLIMPEXP_MATHPLOT mpFXYVector: public mpFXY
1814 {
1815  public:
1819  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, unsigned int yAxisID = 0);
1820 
1823  virtual ~mpFXYVector()
1824  {
1825  Clear();
1826  }
1827 
1832  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
1833 
1837  void Clear();
1838 
1843  virtual int GetSize()
1844  {
1845  return m_xs.size();
1846  }
1847 
1855  bool AddData(const double x, const double y, bool updatePlot);
1856 
1862  void SetReserve(int reserve)
1863  {
1864  m_reserveXY = reserve;
1865  m_xs.reserve(m_reserveXY);
1866  m_ys.reserve(m_reserveXY);
1867  }
1868 
1871  int GetReserve() const
1872  {
1873  return m_reserveXY;
1874  }
1875 
1876  protected:
1879  std::vector<double> m_xs, m_ys;
1880 
1884 
1887  size_t m_index;
1888 
1891  double m_minX, m_maxX, m_minY, m_maxY, m_lastX, m_lastY;
1892 
1896  inline void Rewind()
1897  {
1898  m_index = 0;
1899  }
1900 
1906  virtual bool GetNextXY(double *x, double *y);
1907 
1910  void DrawAddedPoint(double x, double y);
1911 
1914  virtual double GetMinX()
1915  {
1916  if(m_ViewAsBar)
1917  {
1918  // Make extra space for outer bars
1919  return m_minX - (m_deltaX / 2);
1920  }
1921  else
1922  {
1923  return m_minX;
1924  }
1925  }
1926 
1929  virtual double GetMinY()
1930  {
1931  return m_minY;
1932  }
1933 
1936  virtual double GetMaxX()
1937  {
1938  if(m_ViewAsBar)
1939  {
1940  // Make extra space for outer bars
1941  return m_maxX + (m_deltaX / 2);
1942  }
1943  else
1944  {
1945  return m_maxX;
1946  }
1947  }
1948 
1951  virtual double GetMaxY()
1952  {
1953  return m_maxY;
1954  }
1955 
1956  private:
1959  void First_Point(double x, double y);
1960 
1963  void Check_Limit(double val, double *min, double *max, double *last, double *delta);
1964 
1965  wxDECLARE_DYNAMIC_CLASS(mpFXYVector);
1966 };
1967 
1976 class WXDLLIMPEXP_MATHPLOT mpProfile: public mpFunction
1977 {
1978  public:
1982  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
1983 
1989  virtual double GetY(double x) = 0;
1990 
1991  protected:
1992 
1997  virtual void DoPlot(wxDC &dc, mpWindow &w);
1998 
1999  wxDECLARE_DYNAMIC_CLASS(mpProfile);
2000 };
2001 
2002 //-----------------------------------------------------------------------------
2003 // mpChart
2004 //-----------------------------------------------------------------------------
2007 class WXDLLIMPEXP_MATHPLOT mpChart: public mpFunction
2008 {
2009  public:
2011  mpChart(const wxString &name = wxEmptyString);
2012 
2015  {
2016  Clear();
2017  }
2018 
2021  void SetChartValues(const std::vector<double> &data);
2022 
2025  void SetChartLabels(const std::vector<std::string> &labelArray);
2026 
2031  void AddData(const double &data, const std::string &label);
2032 
2036  virtual void Clear();
2037 
2038  virtual bool HasBBox()
2039  {
2040  return (values.size() > 0);
2041  }
2042 
2043  protected:
2044  std::vector<double> values;
2045  std::vector<std::string> labels;
2046 
2047  double m_max_value;
2048  double m_total_value;
2049 
2050  wxDECLARE_DYNAMIC_CLASS(mpChart);
2051 };
2052 
2053 //-----------------------------------------------------------------------------
2054 // mpBarChart - provided by Jose Davide Rondini
2055 //-----------------------------------------------------------------------------
2056 /* Defines for bar charts label positioning. */
2057 #define mpBAR_NONE 0
2058 #define mpBAR_AXIS_H 1
2059 #define mpBAR_AXIS_V 2
2060 #define mpBAR_INSIDE 3
2061 #define mpBAR_TOP 4
2062 
2063 
2065 class WXDLLIMPEXP_MATHPLOT mpBarChart: public mpChart
2066 {
2067  public:
2069  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2070 
2073  {
2074  Clear();
2075  }
2076 
2077  void SetBarColour(const wxColour &colour);
2078 
2079  void SetColumnWidth(const double colWidth)
2080  {
2081  m_width = colWidth;
2082  }
2083 
2085  void SetBarLabelPosition(int position);
2086 
2090  virtual double GetMinX();
2091 
2095  virtual double GetMaxX();
2096 
2100  virtual double GetMinY();
2101 
2105  virtual double GetMaxY();
2106 
2107  protected:
2108 
2109  double m_width;
2110  wxColour m_barColour;
2111  int m_labelPos;
2112  double m_labelAngle;
2113 
2118  virtual void DoPlot(wxDC &dc, mpWindow &w);
2119 
2120  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2121 };
2122 
2126 class WXDLLIMPEXP_MATHPLOT mpPieChart: public mpChart
2127 {
2128  public:
2130  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2131 
2134  {
2135  Clear();
2136  colours.clear();
2137  }
2138 
2142  void SetCenter(const wxPoint center)
2143  {
2144  m_center = center;
2145  }
2146 
2149  wxPoint GetCenter(void) const
2150  {
2151  return m_center;
2152  }
2153 
2157  void SetPieColours(const std::vector<wxColour> &colourArray);
2158 
2162  virtual double GetMinX()
2163  {
2164  return m_center.x - m_radius;
2165  }
2166 
2170  virtual double GetMaxX()
2171  {
2172  return m_center.x + m_radius;
2173  }
2174 
2178  virtual double GetMinY()
2179  {
2180  return m_center.y - m_radius;
2181  }
2182 
2186  virtual double GetMaxY()
2187  {
2188  return m_center.y + m_radius;
2189  }
2190 
2191  protected:
2192 
2193  double m_radius;
2194  wxPoint m_center;
2195  std::vector<wxColour> colours;
2196 
2201  virtual void DoPlot(wxDC &dc, mpWindow &w);
2202 
2203  const wxColour& GetColour(unsigned int id);
2204 
2205  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2206 };
2207 
2210 //-----------------------------------------------------------------------------
2211 // mpLayer implementations - furniture (scales, ...)
2212 //-----------------------------------------------------------------------------
2219 class WXDLLIMPEXP_MATHPLOT mpScale: public mpLayer
2220 {
2221  public:
2226  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, std::optional<unsigned int> axisID = std::nullopt);
2227 
2231  virtual bool HasBBox()
2232  {
2233  return false;
2234  }
2235 
2239  int GetAxisID(void)
2240  {
2241  return m_axisID;
2242  }
2243 
2248  void SetAxisID(unsigned int yAxisID)
2249  {
2250  m_axisID = yAxisID;
2251  }
2252 
2255  void ShowTicks(bool ticks)
2256  {
2257  m_ticks = ticks;
2258  }
2259 
2262  bool GetShowTicks() const
2263  {
2264  return m_ticks;
2265  }
2266 
2269  void ShowGrids(bool grids)
2270  {
2271  m_grids = grids;
2272  }
2273 
2276  bool GetShowGrids() const
2277  {
2278  return m_grids;
2279  }
2280 
2285  void SetLabelFormat(const wxString &format, bool updateLabelMode = false)
2286  {
2287  m_labelFormat = format;
2288  if (updateLabelMode)
2289  m_labelType = mpLabel_USER;
2290  }
2291 
2295  {
2296  return m_labelType;
2297  }
2298 
2301  void SetLabelMode(mpLabelType mode, unsigned int time_conv = mpX_RAWTIME)
2302  {
2303  m_labelType = mode;
2304  m_timeConv = time_conv;
2305  }
2306 
2309  const wxString& GetLabelFormat() const
2310  {
2311  return m_labelFormat;
2312  }
2313 
2317  void SetGridPen(const wxPen &pen)
2318  {
2319  m_gridpen = pen;
2320  }
2321 
2325  const wxPen& GetGridPen() const
2326  {
2327  return m_gridpen;
2328  }
2329 
2333  void SetAuto(bool automaticScalingIsEnabled)
2334  {
2335  m_auto = automaticScalingIsEnabled;
2336  }
2337 
2341  bool GetAuto() const
2342  {
2343  return m_auto;
2344  }
2345 
2346  void SetMinScale(double min)
2347  {
2348  m_min = min;
2349  }
2350 
2351  double GetMinScale() const
2352  {
2353  return m_min;
2354  }
2355 
2356  void SetMaxScale(double max)
2357  {
2358  m_max = max;
2359  }
2360 
2361  double GetMaxScale() const
2362  {
2363  return m_max;
2364  }
2365 
2366  void SetScale(double min, double max)
2367  {
2368  m_min = min;
2369  m_max = max;
2370  }
2371 
2372  void GetScale(double *min, double *max) const
2373  {
2374  *min = m_min;
2375  *max = m_max;
2376  }
2377 
2378  void SetScale(mpRange range)
2379  {
2380  m_min = range.min;
2381  m_max = range.max;
2382  }
2383 
2388  {
2389  return mpRange(m_min, m_max);
2390  }
2391 
2395  virtual bool IsLogAxis()
2396  {
2397  return m_isLog;
2398  }
2399 
2400  virtual void SetLogAxis(bool log)
2401  {
2402  m_isLog = log;
2403  }
2404 
2405  protected:
2406  static const wxCoord kTickSize = 4;
2407  static const wxCoord kAxisExtraSpace = 6;
2408 
2409  int m_axisID;
2410  wxPen m_gridpen;
2411  bool m_ticks;
2412  bool m_grids;
2413  bool m_auto;
2414  double m_min, m_max;
2416  unsigned int m_timeConv;
2417  wxString m_labelFormat;
2418  bool m_isLog;
2419 
2420  virtual int GetOrigin(mpWindow &w) = 0;
2421 
2428  double GetStep(double scale, int minLabelSpacing);
2429  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
2430 
2437  wxString FormatLabelValue(double value, double maxAxisValue, double step);
2438 
2443  wxString FormatLogValue(double n);
2444 
2452  int GetLabelWidth(double value, wxDC &dc, double maxAxisValue, double step);
2453 
2458  bool UseScientific(double maxAxisValue);
2459 
2465  int GetSignificantDigits(double step, double maxAxisValue);
2466 
2471  int GetDecimalDigits(double step);
2472 
2473  wxDECLARE_DYNAMIC_CLASS(mpScale);
2474 };
2475 
2476 
2482 class WXDLLIMPEXP_MATHPLOT mpScaleX: public mpScale
2483 {
2484  public:
2490  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, mpLabelType type = mpLabel_AUTO) :
2491  mpScale(name, flags, grids, type)
2492  {
2493  m_subtype = mpsScaleX;
2494  }
2495 
2496  bool IsTopAxis()
2497  {
2498  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
2499  }
2500 
2501  bool IsBottomAxis()
2502  {
2503  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
2504  }
2505 
2506  protected:
2507 
2510  virtual void DoPlot(wxDC &dc, mpWindow &w);
2511 
2512  virtual int GetOrigin(mpWindow &w);
2513  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2514 
2515  wxDECLARE_DYNAMIC_CLASS(mpScaleX);
2516 };
2517 
2524 class WXDLLIMPEXP_MATHPLOT mpScaleY: public mpScale
2525 {
2526  public:
2531  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, std::optional<unsigned int> yAxisID = std::nullopt, mpLabelType labelType = mpLabel_AUTO) :
2532  mpScale(name, flags, grids, labelType, yAxisID)
2533  {
2534  m_subtype = mpsScaleY;
2535  m_axisWidth = Y_BORDER_SEPARATION;
2536  m_xPos = 0;
2537  }
2538 
2541  void UpdateAxisWidth(mpWindow &w);
2542 
2543  int GetAxisWidth()
2544  {
2545  return m_axisWidth;
2546  }
2547 
2548  bool IsLeftAxis()
2549  {
2550  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
2551  }
2552 
2553  bool IsRightAxis()
2554  {
2555  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
2556  }
2557 
2558  bool IsInside(wxCoord xPixel)
2559  {
2560  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
2561  {
2562  return true;
2563  }
2564  return false;
2565  }
2566 
2567  protected:
2568  int m_axisWidth;
2569  int m_xPos;
2570 
2573  virtual void DoPlot(wxDC &dc, mpWindow &w);
2574 
2575  virtual int GetOrigin(mpWindow &w);
2576  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2577 
2578  wxDECLARE_DYNAMIC_CLASS(mpScaleY);
2579 };
2580 
2581 //-----------------------------------------------------------------------------
2582 // mpWindow
2583 //-----------------------------------------------------------------------------
2584 
2589 #define mpMOUSEMODE_DRAG 0
2590 
2591 #define mpMOUSEMODE_ZOOMBOX 1
2592 
2595 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
2596 typedef std::deque<mpLayer*> mpLayerList;
2597 
2608 {
2609  mpScale* axis = nullptr;
2610  double scale = 1.0;
2611  double pos = 0;
2615 
2616  // Note: we don't use the default operator since we don't want to compare axis pointers
2617  bool operator==(const mpAxisData& other) const
2618  {
2619  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
2620  (bound == other.bound) && (desired == other.desired);
2621  }
2622 };
2623 
2625 typedef std::unordered_map<int, mpAxisData> mpAxisList;
2626 
2633 typedef enum {
2634  uXAxis = 1,
2635  uYAxis = 2,
2636  uXYAxis = 3
2637 } mpAxisUpdate;
2638 
2648 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
2649 
2656 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
2657 
2663 {
2664  public:
2665  mpMagnet()
2666  {
2667  m_IsDrawn = false;
2668  m_rightClick = false;
2669  m_IsWasDrawn = false;
2670  }
2671  ~mpMagnet()
2672  {
2673  ;
2674  }
2675  void UpdateBox(wxCoord left, wxCoord top, wxCoord width, wxCoord height)
2676  {
2677  m_domain = wxRect(left, top, width, height);
2678  m_plot_size = wxRect(left, top, width + left, height + top);
2679  }
2680  void UpdateBox(const wxRect &size)
2681  {
2682  m_domain = size;
2683  m_plot_size = wxRect(size.GetLeft(), size.GetTop(),
2684  size.GetWidth() + size.GetLeft(), size.GetHeight() + size.GetTop());
2685  }
2686  void Plot(wxClientDC &dc, const wxPoint &mousePos);
2687  void ClearPlot(wxClientDC &dc);
2688  void UpdatePlot(wxClientDC &dc, const wxPoint &mousePos);
2689  void SaveDrawState(void)
2690  {
2691  m_IsWasDrawn = m_IsDrawn;
2692  // In any cases, set to false because we erase and repaint all the plot
2693  m_IsDrawn = false;
2694  }
2695 
2696  void SetRightClick(void)
2697  {
2698  m_rightClick = true;
2699  }
2700 
2701  private:
2702  wxRect m_domain;
2703  wxRect m_plot_size;
2704  wxPoint m_mousePosition;
2705  bool m_IsDrawn;
2706  bool m_IsWasDrawn;
2707  bool m_rightClick;
2708  void DrawCross(wxClientDC &dc) const;
2709 };
2710 
2732 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
2733 {
2734  public:
2735  mpWindow()
2736  {
2737  InitParameters();
2738  }
2739 
2740  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
2741  long flags = 0);
2742 
2743  ~mpWindow();
2744 
2748  wxMenu* GetPopupMenu()
2749  {
2750  return &m_popmenu;
2751  }
2752 
2761  bool AddLayer(mpLayer *layer, bool refreshDisplay = true, bool refreshConfig = true);
2762 
2775  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
2776 
2782  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
2783 
2790  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
2791 
2798  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
2799 
2805  mpLayer* GetLayer(int position);
2806 
2811  int GetLayerPosition(mpLayer* layer);
2812 
2819  mpLayer* GetLayersType(int position, mpLayerType type);
2820 
2826  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
2827 
2830  mpLayer* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
2831 
2836  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
2837 
2841  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
2842 
2847  mpLayer* GetLayerByName(const wxString &name);
2848 
2853  mpLayer* GetLayerByClassName(const wxString &name);
2854 
2858  void RefreshLegend(void);
2859 
2864  bool IsYAxisUsed(int yAxisID);
2865 
2869  mpScaleX* GetLayerXAxis();
2870 
2874  mpScaleY* GetLayerYAxis(int yAxisID);
2875 
2879  void SetScaleX(const double scaleX)
2880  {
2881  if (ISNOTNULL(scaleX))
2882  {
2883  m_AxisDataX.scale = scaleX;
2884  UpdateDesiredBoundingBox(uXAxis);
2885  }
2886  UpdateAll();
2887  }
2888 
2893  double GetScaleX(void) const
2894  {
2895  return m_AxisDataX.scale;
2896  }
2897 
2902  void SetScaleY(const double scaleY, int yAxisID)
2903  {
2904  assert(m_AxisDataYList.count(yAxisID) != 0);
2905  if (ISNOTNULL(scaleY))
2906  {
2907  m_AxisDataYList[yAxisID].scale = scaleY;
2908  UpdateDesiredBoundingBox(uYAxis);
2909  }
2910  UpdateAll();
2911  }
2912 
2918  double GetScaleY(int yAxisID)
2919  {
2920  assert(m_AxisDataYList.count(yAxisID) != 0);
2921  return m_AxisDataYList[yAxisID].scale;
2922  } // Schaling's method: maybe another method exists with the same name
2923 
2924  [[deprecated("Incomplete, use UpdateBBox instead")]]
2927  void SetBound();
2928 
2930  mpRange GetBoundX(void) const
2931  {
2932  return m_AxisDataX.bound;
2933  }
2934 
2937  {
2938  return m_AxisDataX.desired;
2939  }
2940 
2944  mpRange GetBoundY(int yAxisID)
2945  {
2946  assert(m_AxisDataYList.count(yAxisID) != 0);
2947  return m_AxisDataYList[yAxisID].bound;
2948  }
2949 
2954  {
2955  assert(m_AxisDataYList.count(yAxisID) != 0);
2956  return m_AxisDataYList[yAxisID].desired;
2957  }
2958 
2963  std::unordered_map<int, mpRange> GetAllBoundY()
2964  {
2965  std::unordered_map<int, mpRange> yRange;
2966  for (auto& [yID, yData] : m_AxisDataYList)
2967  {
2968  yRange[yID] = yData.bound;
2969  }
2970  return yRange;
2971  }
2972 
2977  std::unordered_map<int, mpRange> GetAllDesiredY()
2978  {
2979  std::unordered_map<int, mpRange> yRange;
2980  for (auto& [yID, yData] : m_AxisDataYList)
2981  {
2982  yRange[yID] = yData.desired;
2983  }
2984  return yRange;
2985  }
2986 
2990  void SetPosX(const double posX)
2991  {
2992  m_AxisDataX.pos = posX;
2993  UpdateDesiredBoundingBox(uXAxis);
2994  UpdateAll();
2995  }
2996 
3001  double GetPosX(void) const
3002  {
3003  return m_AxisDataX.pos;
3004  }
3005 
3010  void SetPosY(std::unordered_map<int, double>& posYList)
3011  {
3012  for (auto& [yID, yData] : m_AxisDataYList)
3013  {
3014  yData.pos = posYList[yID];
3015  }
3016  UpdateDesiredBoundingBox(uYAxis);
3017  UpdateAll();
3018  }
3019 
3025  double GetPosY(int yAxisID)
3026  {
3027  assert(m_AxisDataYList.count(yAxisID) != 0);
3028  return m_AxisDataYList[yAxisID].pos;
3029  }
3030 
3034  int GetNOfYAxis(void) const
3035  {
3036  return (int)m_AxisDataYList.size();
3037  }
3038 
3042  mpAxisList GetAxisDataYList(void) const
3043  {
3044  return m_AxisDataYList;
3045  }
3046 
3050  std::map<int, mpAxisData> GetSortedAxisDataYList(void) const
3051  {
3052  return std::map<int, mpAxisData>(m_AxisDataYList.begin(), m_AxisDataYList.end());
3053  }
3054 
3060  void SetScreen(const int scrX, const int scrY)
3061  {
3062  m_scrX = scrX;
3063  m_scrY = scrY;
3064  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3065  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3066 
3067  m_plotBoundaries.endPx = m_scrX;
3068  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3069  m_plotBoundaries.endPy = m_scrY;
3070  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3071 
3072  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3073  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3074 
3075  m_magnet.UpdateBox(m_PlotArea);
3076  }
3077 
3084  int GetScreenX(void) const
3085  {
3086  return m_scrX;
3087  }
3088 
3095  int GetScreenY(void) const
3096  {
3097  return m_scrY;
3098  }
3099 
3105  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3106  {
3107  m_AxisDataX.pos = posX;
3108  SetPosY(posYList);
3109  }
3110 
3114  inline double p2x(const wxCoord pixelCoordX) const
3115  {
3116  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3117  }
3118 
3122  inline double p2y(const wxCoord pixelCoordY, int yAxisID = 0)
3123  {
3124  assert(m_AxisDataYList.count(yAxisID) != 0);
3125  if (m_AxisDataYList.count(yAxisID) == 0)
3126  return 0.0;
3127  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3128  }
3129 
3133  inline wxCoord x2p(const double x) const
3134  {
3135  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3136  }
3137 
3141  inline wxCoord y2p(const double y, int yAxisID = 0)
3142  {
3143  assert(m_AxisDataYList.count(yAxisID) != 0);
3144  if (m_AxisDataYList.count(yAxisID) == 0)
3145  return 0;
3146  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3147  }
3148 
3151  void EnableDoubleBuffer(const bool enabled)
3152  {
3153  m_enableDoubleBuffer = enabled;
3154  }
3155 
3158  void EnableMousePanZoom(const bool enabled)
3159  {
3160  m_enableMouseNavigation = enabled;
3161  }
3162 
3168  void LockAspect(bool enable = true);
3169 
3174  inline bool IsAspectLocked() const
3175  {
3176  return m_lockaspect;
3177  }
3178 
3183  inline bool IsRepainting() const
3184  {
3185  return m_repainting;
3186  }
3187 
3192  void Fit();
3193 
3200  void Fit(const mpRange &rangeX, std::unordered_map<int, mpRange> rangeY, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3201 
3205  void FitX(void);
3206 
3211  void FitY(int yAxisID);
3212 
3217  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
3218 
3223  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
3224 
3226  void ZoomInX();
3227 
3229  void ZoomOutX();
3230 
3233  void ZoomInY(std::optional<int> yAxisID = std::nullopt);
3234 
3237  void ZoomOutY(std::optional<int> yAxisID = std::nullopt);
3238 
3240  void ZoomRect(wxPoint p0, wxPoint p1);
3241 
3243  void UpdateAll();
3244 
3245  // Added methods by Davide Rondini
3246 
3250  unsigned int CountLayers();
3251 
3254  unsigned int CountAllLayers()
3255  {
3256  return (unsigned int)m_layers.size();
3257  }
3258 
3262  unsigned int CountLayersType(mpLayerType type);
3263  unsigned int CountLayersFXYPlot();
3264 
3267  //void PrintGraph(mpPrintout *print);
3268 
3276  {
3277  // Change on X axis
3278  if (update & uXAxis)
3279  {
3280  m_AxisDataX.desired.Set(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale),
3281  m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3282  }
3283 
3284  // Change on Y axis
3285  if (update & uYAxis)
3286  {
3287  for (auto& [yID, yData] : m_AxisDataYList)
3288  {
3289  yData.desired.Set(yData.pos - ((m_margin.top + m_plotHeight) / yData.scale),
3290  yData.pos - (m_margin.top / yData.scale));
3291  }
3292  }
3293  }
3294 
3300  mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID = 0)
3301  {
3302  assert(m_AxisDataYList.count(yAxisID) != 0);
3303  if (desired)
3304  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
3305  else
3306  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
3307  }
3308 
3312  double GetDesiredXmin() const
3313  {
3314  return m_AxisDataX.desired.min;
3315  }
3316 
3321  double GetDesiredXmax() const
3322  {
3323  return m_AxisDataX.desired.max;
3324  }
3325 
3331  double GetDesiredYmin(int yAxisID)
3332  {
3333  assert(m_AxisDataYList.count(yAxisID) != 0);
3334  return m_AxisDataYList[yAxisID].desired.min;
3335  }
3336 
3342  double GetDesiredYmax(int yAxisID)
3343  {
3344  assert(m_AxisDataYList.count(yAxisID) != 0);
3345  return m_AxisDataYList[yAxisID].desired.max;
3346  }
3347 
3349  bool GetBoundingBox(mpRange *boundX, mpRange *boundY, int yAxisID)
3350  {
3351  if (m_AxisDataYList.count(yAxisID) == 0)
3352  return false;
3353  *boundX = m_AxisDataX.bound;
3354  *boundY = m_AxisDataYList[yAxisID].bound;
3355  return true;
3356  }
3357 
3358  // Is this point inside the bounding box
3359  bool PointIsInsideBound(double px, double py, int yAxisID)
3360  {
3361  if (m_AxisDataYList.count(yAxisID) == 0)
3362  return false;
3363 
3364  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
3365  }
3366 
3367  /* Update bounding box (X and Y axis) to include this point.
3368  * Expand the range to include the point.
3369  * @param px: point on x-axis
3370  * @param py: point on y-axis
3371  * @param yAxisID: the y-axis ID
3372  */
3373  void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
3374  {
3375  if (m_AxisDataYList.count(yAxisID) == 0)
3376  return ;
3377 
3378  m_AxisDataX.bound.Update(px);
3379  m_AxisDataYList[yAxisID].bound.Update(py);
3380  }
3381 
3382  /* Initialize bounding box with an initial point
3383  * @param px: point on x-axis
3384  * @param py: point on y-axis
3385  * @param yAxisID: the y-axis ID
3386  */
3387  void InitializeBoundingBox(double px, double py, int yAxisID)
3388  {
3389  if (m_AxisDataYList.count(yAxisID) == 0)
3390  return ;
3391 
3392  m_AxisDataX.bound.Set(px, px);
3393  m_AxisDataYList[yAxisID].bound.Set(py, py);
3394  }
3395 
3398  void SetMPScrollbars(bool status);
3399 
3402  bool GetMPScrollbars() const
3403  {
3404  return m_enableScrollBars;
3405  }
3406 
3412  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
3413 
3417  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3418 
3422  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3423 
3427  void SetWildcard(const wxString &wildcard)
3428  {
3429  m_wildcard = wildcard;
3430  }
3431 
3435  const wxString& GetWildcard(void) const
3436  {
3437  return m_wildcard;
3438  }
3439 
3447  bool LoadFile(const wxString &filename = wxEmptyString);
3448 
3452 
3459  void SetMargins(int top, int right, int bottom, int left);
3460 
3463  {
3464  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3465  }
3466 
3468  void SetMarginTop(int top)
3469  {
3470  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3471  }
3472 
3476  int GetMarginTop(bool minusExtra = false) const
3477  {
3478  if (minusExtra)
3479  return m_margin.top - m_extraMargin;
3480  else
3481  return m_margin.top;
3482  }
3483 
3485  void SetMarginRight(int right)
3486  {
3487  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
3488  }
3489 
3493  int GetMarginRight(bool minusExtra = false) const
3494  {
3495  if (minusExtra)
3496  return m_margin.right - m_extraMargin;
3497  else
3498  return m_margin.right;
3499  }
3500 
3503  {
3504  return m_marginOuter.right;
3505  }
3506 
3508  void SetMarginBottom(int bottom)
3509  {
3510  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
3511  }
3512 
3516  int GetMarginBottom(bool minusExtra = false) const
3517  {
3518  if (minusExtra)
3519  return m_margin.bottom - m_extraMargin;
3520  else
3521  return m_margin.bottom;
3522  }
3523 
3525  void SetMarginLeft(int left)
3526  {
3527  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
3528  }
3529 
3533  int GetMarginLeft(bool minusExtra = false) const
3534  {
3535  if (minusExtra)
3536  return m_margin.left - m_extraMargin;
3537  else
3538  return m_margin.left;
3539  }
3540 
3542  void SetExtraMargin(int extra)
3543  {
3544  m_extraMargin = extra;
3545  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3546  }
3547 
3549  int GetExtraMargin() const
3550  {
3551  return m_extraMargin;
3552  }
3553 
3556  {
3557  return m_marginOuter.left;
3558  }
3559 
3561  int GetPlotWidth() const
3562  {
3563  return m_plotWidth;
3564  }
3565 
3567  int GetPlotHeight() const
3568  {
3569  return m_plotHeight;
3570  }
3571 
3576  mpRect GetPlotBoundaries(bool with_margin) const
3577  {
3578  mpRect bond;
3579  if (with_margin)
3580  bond = m_plotBoundariesMargin;
3581  else
3582  bond = m_plotBoundaries;
3583  bond.startPx -= m_extraMargin;
3584  bond.endPx += m_extraMargin;
3585  bond.startPy -= m_extraMargin;
3586  bond.endPy += m_extraMargin;
3587  return bond;
3588  }
3589 
3593  int GetLeftYAxesWidth(std::optional<int> yAxisID = std::nullopt);
3594 
3598  int GetRightYAxesWidth(std::optional<int> yAxisID = std::nullopt);
3599 
3601  void SetDrawBox(bool drawbox)
3602  {
3603  m_drawBox = drawbox;
3604  }
3605 
3607  bool GetDrawBox() const
3608  {
3609  return m_drawBox;
3610  }
3611 
3615  std::optional<int> IsInsideYAxis(const wxPoint &point);
3616 
3620  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
3621 
3625  void SetLayerVisible(const wxString &name, bool viewable);
3626 
3630  bool IsLayerVisible(const wxString &name);
3631 
3635  bool IsLayerVisible(const unsigned int position);
3636 
3640  void SetLayerVisible(const unsigned int position, bool viewable);
3641 
3646  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
3647 
3650  const wxColour& GetAxesColour() const
3651  {
3652  return m_axColour;
3653  }
3654 
3655  const wxColour& GetbgColour() const
3656  {
3657  return m_bgColour;
3658  }
3659 
3660  void SetbgColour(const wxColour &colour)
3661  {
3662  m_bgColour = colour;
3663  }
3664 
3670  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
3671  {
3672  m_OnDeleteLayer = event;
3673  }
3674 
3677  {
3678  m_OnDeleteLayer = NULL;
3679  }
3680 
3685  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
3686  {
3687  m_OnUserMouseAction = userMouseEventHandler;
3688  }
3689 
3692  {
3693  m_OnUserMouseAction = NULL;
3694  }
3695 
3701  bool IsLogXaxis()
3702  {
3703  if (m_AxisDataX.axis)
3704  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
3705  else
3706  return false;
3707  }
3708 
3712  bool IsLogYaxis(int yAxisID)
3713  {
3714  assert(m_AxisDataYList.count(yAxisID) != 0);
3715  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
3716  if (yAxis)
3717  return yAxis->IsLogAxis();
3718  else
3719  return false;
3720  }
3721 
3722  void SetLogXaxis(bool log)
3723  {
3724  if (m_AxisDataX.axis)
3725  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
3726  }
3727 
3731  void SetLogYaxis(int yAxisID, bool log)
3732  {
3733  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
3734  if (yAxis)
3735  yAxis->SetLogAxis(log);
3736  }
3737 
3743  bool GetMagnetize() const
3744  {
3745  return m_magnetize;
3746  }
3747 
3748  void SetMagnetize(bool mag)
3749  {
3750  m_magnetize = mag;
3751  }
3752 
3757  void SetMouseLeftDownAction(mpMouseButtonAction action)
3758  {
3759  m_mouseLeftDownAction = action;
3760  }
3761 
3766  mpMouseButtonAction GetMouseLeftDownAction()
3767  {
3768  return m_mouseLeftDownAction;
3769  }
3770 
3771 #ifdef ENABLE_MP_CONFIG
3772  void RefreshConfigWindow();
3777  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
3778 #endif // ENABLE_MP_CONFIG
3779 
3780  protected:
3781  virtual void BindEvents(void);
3782  virtual void OnPaint(wxPaintEvent &event);
3783  virtual void OnSize(wxSizeEvent &event);
3784  virtual void OnShowPopupMenu(wxMouseEvent &event);
3785  virtual void OnCenter(wxCommandEvent &event);
3786  virtual void OnFit(wxCommandEvent &event);
3787  virtual void OnToggleGrids(wxCommandEvent &event);
3788  virtual void OnToggleCoords(wxCommandEvent &event);
3789  virtual void OnScreenShot(wxCommandEvent &event);
3790  virtual void OnFullScreen(wxCommandEvent &event);
3791 #ifdef ENABLE_MP_CONFIG
3792  virtual void OnConfiguration(wxCommandEvent &event);
3793 #endif // ENABLE_MP_CONFIG
3794  virtual void OnLoadFile(wxCommandEvent &event);
3795  virtual void OnZoomIn(wxCommandEvent &event);
3796  virtual void OnZoomOut(wxCommandEvent &event);
3797  virtual void OnLockAspect(wxCommandEvent &event);
3798  virtual void OnMouseHelp(wxCommandEvent &event);
3799  virtual void OnMouseLeftDown(wxMouseEvent &event);
3800  virtual void OnMouseRightDown(wxMouseEvent &event);
3801  virtual void OnMouseMove(wxMouseEvent &event);
3802  virtual void OnMouseLeftRelease(wxMouseEvent &event);
3803  virtual void OnMouseWheel(wxMouseEvent &event);
3804  virtual void OnMouseLeave(wxMouseEvent &event);
3805  bool CheckUserMouseAction(wxMouseEvent &event);
3806  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
3807  virtual void OnScrollPageUp(wxScrollWinEvent &event);
3808  virtual void OnScrollPageDown(wxScrollWinEvent &event);
3809  virtual void OnScrollLineUp(wxScrollWinEvent &event);
3810  virtual void OnScrollLineDown(wxScrollWinEvent &event);
3811  virtual void OnScrollTop(wxScrollWinEvent &event);
3812  virtual void OnScrollBottom(wxScrollWinEvent &event);
3813 
3814  void DoScrollCalc(const int position, const int orientation);
3815 
3820  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = ZOOM_AROUND_CENTER);
3821 
3828  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = ZOOM_AROUND_CENTER, std::optional<int> = std::nullopt);
3829 
3834  void SetScaleXAndCenter(double scaleX);
3835 
3841  void SetScaleYAndCenter(double scaleY, int yAxisID);
3842 
3843  void Zoom(bool zoomIn, const wxPoint &centerPoint);
3844 
3847  virtual bool UpdateBBox();
3848 
3849  void InitParameters();
3850 
3851  wxTopLevelWindow* m_parent;
3852  bool m_fullscreen;
3853 
3854  mpLayerList m_layers;
3856  mpAxisList m_AxisDataYList;
3857 
3858  wxMenu m_popmenu;
3860  wxColour m_bgColour;
3861  wxColour m_fgColour;
3862  wxColour m_axColour;
3863  bool m_drawBox;
3864 
3865  int m_scrX;
3866  int m_scrY;
3869 
3873  wxCoord m_plotWidth;
3874  wxCoord m_plotHeight;
3875 
3878  wxRect m_PlotArea;
3879 
3880  bool m_repainting;
3881  int m_last_lx, m_last_ly;
3882  wxBitmap* m_buff_bmp;
3885  mpMouseButtonAction m_mouseLeftDownAction;
3886  bool m_mouseMovedAfterRightClick;
3887  wxPoint m_mouseRClick;
3888  wxPoint m_mouseLClick;
3889  double m_mouseScaleX;
3890  std::unordered_map<int, double> m_mouseScaleYList;
3891  std::optional<int> m_mouseYAxisID;
3892  bool m_enableScrollBars;
3893  int m_scrollX, m_scrollY;
3897  bool m_InInfoLegend;
3898 
3899  wxBitmap* m_zoom_bmp;
3900  wxRect m_zoom_dim;
3901  wxRect m_zoom_oldDim;
3902 
3905 
3906  wxBitmap* m_Screenshot_bmp;
3907 
3908  wxString m_wildcard;
3909 
3910 #ifdef ENABLE_MP_CONFIG
3911  MathPlotConfigDialog* m_configWindow = NULL;
3912 #endif // ENABLE_MP_CONFIG
3913 
3914  mpOnDeleteLayer m_OnDeleteLayer = NULL;
3915  mpOnUserMouseAction m_OnUserMouseAction = NULL;
3916 
3920  virtual void DesiredBoundsHaveChanged() {};
3921 
3922  private:
3924  void CheckAndReportDesiredBoundsChanges();
3925 
3930  unsigned int GetNewAxisDataID(void)
3931  {
3932  int newID = 0;
3933  for (auto& [yID, yData] : m_AxisDataYList)
3934  {
3935  if(yData.axis)
3936  {
3937  // This ID is used by an axis. Make sure the new ID is larger
3938  newID = std::max(newID, yID + 1);
3939  }
3940  }
3941  return newID;
3942  }
3943 
3944  wxDECLARE_DYNAMIC_CLASS(mpWindow);
3945 
3946  // To have direct access to m_Screenshot_dc
3947  friend mpPrintout;
3948 };
3949 
3950 //-----------------------------------------------------------------------------
3951 // mpText - provided by Val Greene
3952 //-----------------------------------------------------------------------------
3953 
3961 class WXDLLIMPEXP_MATHPLOT mpText: public mpLayer
3962 {
3963  public:
3966  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
3967  {
3968  m_subtype = mptText;
3969  SetName(name);
3970  m_offsetx = 5;
3971  m_offsety = 50;
3972  m_location = mpMarginNone;
3973  m_ZIndex = mpZIndex_TEXT;
3974  }
3975 
3979  mpText(const wxString &name, int offsetx, int offsety);
3980 
3984  mpText(const wxString &name, mpLocation marginLocation);
3985 
3988  virtual bool HasBBox()
3989  {
3990  return false;
3991  }
3992 
3995  void SetLocation(mpLocation location)
3996  {
3997  m_location = location;
3998  }
3999 
4002  mpLocation GetLocation() const
4003  {
4004  return m_location;
4005  }
4006 
4009  void SetOffset(int offX, int offY)
4010  {
4011  m_offsetx = offX;
4012  m_offsety = offY;
4013  }
4014 
4016  void GetOffset(int *offX, int *offY) const
4017  {
4018  *offX = m_offsetx;
4019  *offY = m_offsety;
4020  }
4021 
4022  protected:
4025  mpLocation m_location;
4026 
4029  virtual void DoPlot(wxDC &dc, mpWindow &w);
4030 
4031  wxDECLARE_DYNAMIC_CLASS(mpText);
4032 };
4033 
4037 class WXDLLIMPEXP_MATHPLOT mpTitle: public mpText
4038 {
4039  public:
4042  mpTitle();
4043 
4046  mpTitle(const wxString &name) :
4047  mpText(name, mpMarginTopCenter)
4048  {
4049  m_subtype = mptTitle;
4050  SetPen(*wxWHITE_PEN);
4051  SetBrush(*wxWHITE_BRUSH);
4052  }
4053 
4054  protected:
4055 
4056  wxDECLARE_DYNAMIC_CLASS(mpTitle);
4057 };
4058 
4059 //-----------------------------------------------------------------------------
4060 // mpPrintout - provided by Davide Rondini
4061 //-----------------------------------------------------------------------------
4062 
4067 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4068 {
4069  public:
4070  mpPrintout()
4071  {
4072  plotWindow = NULL;
4073  drawn = false;
4074  stretch_factor = 2;
4075  }
4076 
4077  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4078  virtual ~mpPrintout()
4079  {
4080  ;
4081  }
4082 
4083  void SetDrawState(bool drawState)
4084  {
4085  drawn = drawState;
4086  }
4087 
4088  bool OnPrintPage(int page);
4089  bool HasPage(int page);
4090 
4093  void SetFactor(int factor)
4094  {
4095  stretch_factor = factor;
4096  }
4097 
4098  private:
4099  bool drawn;
4100  mpWindow* plotWindow;
4101  int stretch_factor; // To reduce the size of plot
4102 
4103  protected:
4104 
4105  wxDECLARE_DYNAMIC_CLASS(mpPrintout);
4106 };
4107 
4108 //-----------------------------------------------------------------------------
4109 // mpMovableObject - provided by Jose Luis Blanco
4110 //-----------------------------------------------------------------------------
4118 class WXDLLIMPEXP_MATHPLOT mpMovableObject: public mpFunction
4119 {
4120  public:
4124  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
4125  {
4126  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
4127  m_subtype = mpfMovable;
4128  m_bbox_min_x = m_bbox_max_x = 0;
4129  m_bbox_min_y = m_bbox_max_y = 0;
4130  }
4131 
4132  virtual ~mpMovableObject() {}
4133 
4136  void GetCoordinateBase(double &x, double &y, double &phi) const
4137  {
4138  x = m_reference_x;
4139  y = m_reference_y;
4140  phi = m_reference_phi;
4141  }
4142 
4145  void SetCoordinateBase(double x, double y, double phi = 0)
4146  {
4147  m_reference_x = x;
4148  m_reference_y = y;
4149  m_reference_phi = phi;
4150  m_flags = mpALIGN_NE;
4151  ShapeUpdated();
4152  }
4153 
4154  virtual bool HasBBox()
4155  {
4156  return m_trans_shape_xs.size() != 0;
4157  }
4158 
4161  virtual double GetMinX()
4162  {
4163  return m_bbox_min_x;
4164  }
4165 
4168  virtual double GetMaxX()
4169  {
4170  return m_bbox_max_x;
4171  }
4172 
4175  virtual double GetMinY()
4176  {
4177  return m_bbox_min_y;
4178  }
4179 
4182  virtual double GetMaxY()
4183  {
4184  return m_bbox_max_y;
4185  }
4186 
4187  protected:
4188 
4191  double m_reference_x, m_reference_y, m_reference_phi;
4192 
4193  virtual void DoPlot(wxDC &dc, mpWindow &w);
4194 
4197  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
4198 
4201  std::vector<double> m_shape_xs, m_shape_ys;
4202 
4206  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
4207 
4211  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
4212 
4216  void ShapeUpdated();
4217 
4218  wxDECLARE_DYNAMIC_CLASS(mpMovableObject);
4219 };
4220 
4221 //-----------------------------------------------------------------------------
4222 // mpCovarianceEllipse - provided by Jose Luis Blanco
4223 //-----------------------------------------------------------------------------
4235 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse: public mpMovableObject
4236 {
4237  public:
4241  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
4242  const wxString &layerName = _T("")) : mpMovableObject(),
4243  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
4244  {
4245  m_continuous = true;
4246  m_name = layerName;
4247  RecalculateShape();
4248  }
4249 
4250  virtual ~mpCovarianceEllipse()
4251  {
4252  ;
4253  }
4254 
4255  double GetQuantiles() const
4256  {
4257  return m_quantiles;
4258  }
4259 
4262  void SetQuantiles(double q)
4263  {
4264  m_quantiles = q;
4265  RecalculateShape();
4266  }
4267 
4268  void SetSegments(int segments)
4269  {
4270  m_segments = segments;
4271  }
4272 
4273  int GetSegments() const
4274  {
4275  return m_segments;
4276  }
4277 
4280  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
4281  {
4282  cov_00 = m_cov_00;
4283  cov_01 = m_cov_01;
4284  cov_11 = m_cov_11;
4285  }
4286 
4289  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
4290  {
4291  m_cov_00 = cov_00;
4292  m_cov_01 = cov_01;
4293  m_cov_11 = cov_11;
4294  RecalculateShape();
4295  }
4296 
4297  protected:
4300  double m_cov_00, m_cov_11, m_cov_01;
4301  double m_quantiles;
4302 
4306 
4309  void RecalculateShape();
4310 
4311  wxDECLARE_DYNAMIC_CLASS(mpCovarianceEllipse);
4312 };
4313 
4314 //-----------------------------------------------------------------------------
4315 // mpPolygon - provided by Jose Luis Blanco
4316 //-----------------------------------------------------------------------------
4321 class WXDLLIMPEXP_MATHPLOT mpPolygon: public mpMovableObject
4322 {
4323  public:
4326  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
4327  {
4328  m_continuous = true;
4329  m_name = layerName;
4330  }
4331 
4332  virtual ~mpPolygon()
4333  {
4334  ;
4335  }
4336 
4342  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
4343 
4344  protected:
4345 
4346  wxDECLARE_DYNAMIC_CLASS(mpPolygon);
4347 };
4348 
4349 //-----------------------------------------------------------------------------
4350 // mpBitmapLayer - provided by Jose Luis Blanco
4351 //-----------------------------------------------------------------------------
4356 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer: public mpLayer
4357 {
4358  public:
4362  {
4363  m_min_x = m_max_x = 0;
4364  m_min_y = m_max_y = 0;
4365  m_validImg = false;
4366  m_bitmapChanged = false;
4367  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
4368  }
4369 
4370  virtual ~mpBitmapLayer()
4371  {
4372  ;
4373  }
4374 
4377  void GetBitmapCopy(wxImage &outBmp) const;
4378 
4386  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
4387 
4390  virtual double GetMinX()
4391  {
4392  return m_min_x;
4393  }
4394 
4397  virtual double GetMaxX()
4398  {
4399  return m_max_x;
4400  }
4401 
4404  virtual double GetMinY()
4405  {
4406  return m_min_y;
4407  }
4408 
4411  virtual double GetMaxY()
4412  {
4413  return m_max_y;
4414  }
4415 
4416  protected:
4417 
4420  wxImage m_bitmap;
4421  wxBitmap m_scaledBitmap;
4422  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
4423  bool m_validImg;
4424  bool m_bitmapChanged;
4425 
4428  double m_min_x, m_max_x, m_min_y, m_max_y;
4429 
4430  virtual void DoPlot(wxDC &dc, mpWindow &w);
4431 
4432  wxDECLARE_DYNAMIC_CLASS(mpBitmapLayer);
4433 };
4434 
4435 // utility class
4436 
4437 // Enumeration of classic colour
4438 typedef enum __mp_Colour
4439 {
4440  mpBlue,
4441  mpRed,
4442  mpGreen,
4443  mpPurple,
4444  mpYellow,
4445  mpFuchsia,
4446  mpLime,
4447  mpAqua,
4448  mpOlive
4449 } mpColour;
4450 
4455 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
4456 {
4457  public:
4458  wxIndexColour(unsigned int id)
4459  {
4460  switch (id)
4461  {
4462  case 0:
4463  this->Set(0, 0, 255);
4464  break; // Blue
4465  case 1:
4466  this->Set(255, 0, 0);
4467  break; // Red
4468  case 2:
4469  this->Set(0, 128, 0);
4470  break; // Green
4471  case 3:
4472  this->Set(128, 0, 128);
4473  break; // Purple
4474  case 4:
4475  this->Set(255, 255, 0);
4476  break; // Yellow
4477  case 5:
4478  this->Set(255, 0, 255);
4479  break; // Fuchsia
4480  case 6:
4481  this->Set(0, 255, 0);
4482  break; // Lime
4483  case 7:
4484  this->Set(0, 255, 255);
4485  break; // Aqua/Cyan
4486  case 8:
4487  this->Set(128, 128, 0);
4488  break; // Olive
4489  default:
4490  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
4491  (ChannelType)((rand() * 255) / RAND_MAX));
4492  }
4493  }
4494 };
4495 
4498 // ---------------------------------------------------------------------
4499 #ifdef ENABLE_MP_NAMESPACE
4500  }// namespace MathPlot
4501  // No, iff build enables namespace, its up to app to use it appropriately: using namespace MathPlot;
4502 #endif // ENABLE_MP_NAMESPACE
4503 
4504 #endif // MATHPLOT_H_INCLUDED
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:4024
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2309
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer Sender the mpWindow classname the class name of the obje...
Definition: mathplot.h:2648
bool IsHorizontal(void) const
Get if is horizontal line.
Definition: mathplot.h:1518
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:524
int GetAxisID(void)
Return the ID of the Axis.
Definition: mathplot.h:2239
void SetValue(const double value)
Set x or y.
Definition: mathplot.h:1511
mpInfoLegend * m_InfoLegend
pointer to the optional info legend layer
Definition: mathplot.h:3896
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:571
double m_min_x
The shape of the bitmap:
Definition: mathplot.h:4428
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:3871
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:2418
void Set(double _min, double _max)
Set min, max function.
Definition: mathplot.h:246
void EnableDoubleBuffer(const bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled).
Definition: mathplot.h:3151
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:925
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:3712
Bitmap type layer.
Definition: mathplot.h:694
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1046
Plot type layer.
Definition: mathplot.h:679
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:3084
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4411
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:1237
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:3676
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1562
void SetYAxisID(unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1471
std::unordered_map< int, mpRange > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:2977
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:4321
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:2879
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:803
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:187
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:1813
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:3867
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:570
__mp_Layer_Type
Definition: mathplot.h:675
Show/Hide grids.
Definition: mathplot.h:512
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:4356
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:2409
bool m_magnetize
For mouse magnetization.
Definition: mathplot.h:3903
mpLabelType
Definition: mathplot.h:648
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2178
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:3887
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:2162
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:4326
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2276
std::unordered_map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:2625
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:3141
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:677
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:710
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1045
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1038
mpRange bound
Range min and max.
Definition: mathplot.h:2612
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1495
Lock x/y scaling aspect.
Definition: mathplot.h:511
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:1311
wxString m_wildcard
For loadfile() function when we use wxFileDialog.
Definition: mathplot.h:3908
Info box type layer.
Definition: mathplot.h:699
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:4023
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set axis label view mode.
Definition: mathplot.h:2301
Abstract class providing a line.
Definition: mathplot.h:1489
Abstract class providing an vertical line.
Definition: mathplot.h:1554
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2262
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2142
mpRange lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:2614
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:2732
double GetMaxAbs(void) const
Returns max absolute value of the range.
Definition: mathplot.h:332
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:2410
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3034
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:3122
void SetExtraMargin(int extra)
Set the extra margin.
Definition: mathplot.h:3542
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1185
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:4145
double Length(void) const
Length of the range.
Definition: mathplot.h:320
Chart type layer (bar chart)
Definition: mathplot.h:684
double GetPosY(int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3025
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:902
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3174
int m_winY
Holds the mpWindow size. Used to rescale position when window is resized.
Definition: mathplot.h:1187
std::optional< int > m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:3891
~mpBarChart()
Destructor.
Definition: mathplot.h:2072
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:3114
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1053
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:3888
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:3920
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:910
int m_flags
Holds label alignment. Default : mpALIGN_NE.
Definition: mathplot.h:1050
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:3988
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:787
wxPoint GetPosition() const
Returns the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1149
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1266
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:956
~mpPieChart()
Destructor.
Definition: mathplot.h:2133
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1479
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:3561
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1040
Just the end of ZOrder.
Definition: mathplot.h:701
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4175
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:692
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:3485
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:3451
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1399
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:3555
void SetMouseLeftDownAction(mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:3757
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:3858
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:3889
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1642
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:1698
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:3862
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:1048
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:3876
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:4136
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:2656
void ToLog(void)
Convert to log range.
Definition: mathplot.h:338
mpRange GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:2936
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:1293
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:2482
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1049
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:3995
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2038
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3158
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:3863
Plot (function) type layer.
Definition: mathplot.h:697
void UpdateDesiredBoundingBox(mpAxisUpdate update)
Draws the mpWindow on a page for printing.
Definition: mathplot.h:3275
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2325
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1052
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1435
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:739
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1041
bool GetCanDelete(void) const
Get CanDelete for plot.
Definition: mathplot.h:1025
Axis type layer.
Definition: mathplot.h:695
Implementing MathPlotConfigDialogBuilder.
Definition: MathPlotConfig.h:75
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:2186
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:2413
Axis type layer.
Definition: mathplot.h:678
void SetCanDelete(bool canDelete)
Set CanDelete for plot.
Definition: mathplot.h:1018
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4390
bool GetMagnetize() const
Magnetize the position of the mouse in the plot ie draw a vertical and horizontal line...
Definition: mathplot.h:3743
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:3894
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:2415
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:1223
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:2269
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:3650
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:935
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:2596
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1951
mpRange GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:2930
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:3966
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:4420
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:3685
each visible plot is described on its own line, one above the other
Definition: mathplot.h:578
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:2990
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1032
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:651
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:3567
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:1252
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:598
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1887
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4397
Show/Hide info coord.
Definition: mathplot.h:513
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:949
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:4289
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4067
int m_last_ly
For double buffering.
Definition: mathplot.h:3881
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:369
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:3904
wxSize GetSize() const
Returns the size of the box (in pixels)
Definition: mathplot.h:1156
Chart type layer.
Definition: mathplot.h:698
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:2412
Set label for axis in scientific notation.
Definition: mathplot.h:655
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:308
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1183
Copy a screen shot to the clipboard.
Definition: mathplot.h:514
Fit view to match bounding box of all layers.
Definition: mathplot.h:507
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:4002
bool PointIsInside(double px, double py) const
Is point inside this bounding box?
Definition: mathplot.h:476
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:520
wxBitmap * m_buff_bmp
For double buffering.
Definition: mathplot.h:3882
Center view on click position.
Definition: mathplot.h:510
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1481
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:1823
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:539
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:4118
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:607
mpRange desired
Desired range min and max.
Definition: mathplot.h:2613
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:3856
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:1722
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:4201
virtual bool IsLogAxis()
Logarithmic axis.
Definition: mathplot.h:2395
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1442
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:2490
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:4455
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1482
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1407
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:3872
Layer for bar chart.
Definition: mathplot.h:2065
mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:3300
double m_max
Min and max axis values when autosize is false.
Definition: mathplot.h:2414
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1043
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:1272
abstract Layer for chart (bar and pie).
Definition: mathplot.h:2007
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:572
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:468
bool GetBoundingBox(mpRange *boundX, mpRange *boundY, int yAxisID)
Return the bounding box coordinates for the Y axis of ID yAxisID.
Definition: mathplot.h:3349
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:918
void SetLabelFormat(const wxString &format, bool updateLabelMode=false)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2285
const wxRect & GetRectangle() const
Returns the current rectangle coordinates.
Definition: mathplot.h:1163
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:4211
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:3312
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:653
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:559
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1478
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:3331
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:3508
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:1843
int m_symbolSize2
Size of the symbol div 2.
Definition: mathplot.h:1480
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4404
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2341
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1914
int GetMarginRight(bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:3493
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1540
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:1862
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:1871
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:3342
Text box type layer.
Definition: mathplot.h:681
mpMouseButtonAction GetMouseLeftDownAction()
Returns the type of action for the left mouse button.
Definition: mathplot.h:3766
double pos
Position.
Definition: mathplot.h:2611
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:3462
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:549
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:3878
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1098
Load a file.
Definition: mathplot.h:518
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:751
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:4016
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:3873
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:1125
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:760
Line (horizontal or vertical) type layer.
Definition: mathplot.h:696
wxBitmap * m_zoom_bmp
For zoom selection.
Definition: mathplot.h:3899
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1207
std::unordered_map< int, mpRange > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:2963
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:3402
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:3866
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:3133
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1414
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:3855
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1307
wxRect m_oldDim
Keep the old values of m_dim.
Definition: mathplot.h:1184
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:662
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:3860
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:3701
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3060
int GetBarWidth(void) const
return the width of the bar
Definition: mathplot.h:1748
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:3670
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1245
void SetAxisID(unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2248
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1936
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:3601
bool m_enableDoubleBuffer
For double buffering. Default enabled.
Definition: mathplot.h:3883
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1389
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1589
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2149
mpTitle(const wxString &name)
Definition: mathplot.h:4046
Plot layer implementing a simple title.
Definition: mathplot.h:4037
Set no label for axis (useful for bar)
Definition: mathplot.h:668
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:2524
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:4154
bool ViewAsBar(void) const
return true if XY series is plotted with bar
Definition: mathplot.h:1756
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1188
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:983
double GetCenter(void) const
Center of the range.
Definition: mathplot.h:326
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:3576
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:3001
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1011
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1047
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:4206
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:3549
void Assign(double value1, double value2)
Assign values to min and max.
Definition: mathplot.h:253
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2333
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:1714
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:1477
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:3691
std::vector< double > m_xs
The internal copy of the set of data to draw.
Definition: mathplot.h:1879
mpRange GetBoundY(int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:2944
~mpChart()
Destructor.
Definition: mathplot.h:2014
Abstract class providing an horizontal line.
Definition: mathplot.h:1532
Zoom into view at clickposition / window center.
Definition: mathplot.h:508
int GetMarginLeft(bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:3533
mpRange(double value1, double value2)
Create range with the 2 values.
Definition: mathplot.h:231
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:3859
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:4305
double scale
Scale.
Definition: mathplot.h:2610
void Rewind()
Rewind value enumeration with mpFXY::GetNextXY.
Definition: mathplot.h:1896
Zoom out.
Definition: mathplot.h:509
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2219
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:878
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:2662
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:2531
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition: mathplot.h:299
int m_reserveXY
Memory reserved for m_xs and m_ys.
Definition: mathplot.h:1883
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:576
mpRange GetDesiredBoundY(int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:2953
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:289
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:4235
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2294
int GetMarginTop(bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:3476
double m_minX
Loaded at SetData.
Definition: mathplot.h:1891
mpInfoCoords * m_InfoCoords
pointer to the optional info coords layer
Definition: mathplot.h:3895
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:3321
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:660
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:2607
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:568
Layer for pie chart.
Definition: mathplot.h:2126
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:894
Set label user defined.
Definition: mathplot.h:666
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:4241
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:886
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:3884
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1042
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:3010
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:658
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:664
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:4280
mpRange GetScale() const
Return m_min and m_max scale as a mpRange.
Definition: mathplot.h:2387
Bitmap type layer.
Definition: mathplot.h:682
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1170
bool IsVisible() const
Checks whether the layer is visible or not.
Definition: mathplot.h:976
mpRange()
Default constructor.
Definition: mathplot.h:224
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:2255
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:768
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:997
bool IsSet()
Check if this mpRange has been assigned any values.
Definition: mathplot.h:268
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1450
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2416
const wxString & GetWildcard(void) const
Get wildcard.
Definition: mathplot.h:3435
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:4123
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:680
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:3105
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3095
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3042
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:1575
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:811
Plot layer implementing a text string.
Definition: mathplot.h:3961
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:778
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:3874
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4182
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:3607
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:963
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1044
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:3502
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:795
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1186
int GetMarginBottom(bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:3516
Shows information about the mouse commands.
Definition: mathplot.h:519
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:3731
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:3468
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:2893
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:3861
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:3906
legend components follow each other horizontally on a single line
Definition: mathplot.h:579
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1324
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:4262
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1463
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:3868
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:218
void Update(double value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:277
bool PointIsInside(double point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:345
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:4191
double GetScaleY(int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:2918
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:2170
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1421
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4161
Plot layer, abstract base class.
Definition: mathplot.h:727
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1051
double GetValue() const
Set x or y.
Definition: mathplot.h:1503
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:4009
void SetFactor(int factor)
Definition: mathplot.h:4093
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:862
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1039
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:2417
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:3865
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:3890
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:942
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:870
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1069
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:4300
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:3525
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:3854
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:2411
std::map< int, mpAxisData > GetSortedAxisDataYList(void) const
Get a sorted version of the Y-axis data map.
Definition: mathplot.h:3050
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:3870
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1976
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1177
void SetWildcard(const wxString &wildcard)
Set wildcard for LoadFile() function when we use wxFileDialog.
Definition: mathplot.h:3427
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:3885
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:3877
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:990
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2231
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4168
bool IsRepainting() const
Checks if we are repainting.
Definition: mathplot.h:3183
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:3254
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2317
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1428
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:4361
void SetScaleY(const double scaleY, int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:2902
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:2633
Text box type layer.
Definition: mathplot.h:700
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:2748
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:1004
Line (horizontal or vertical) type layer.
Definition: mathplot.h:683
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1929