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: 10/12/2025
10 // Copyright: (c) David Schalig, Davide Rondini
11 // Licence: wxWindows licence
13 
14 #ifndef MATHPLOT_H_INCLUDED
15 #define MATHPLOT_H_INCLUDED
16 
17 #define MATHPLOT_MANY_YAXIS
18 
19 
58 //this definition uses windows dll to export function.
59 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
60 //mathplot_EXPORTS will be defined by cmake
61 #ifdef mathplot_EXPORTS
62 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
63 #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
64 #else // not making DLL
65 #define WXDLLIMPEXP_MATHPLOT
66 #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
67 #endif
68 
69 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
70 #pragma interface "mathplot.h"
71 #endif
72 
73 #include <vector>
74 #include <map>
75 #include <unordered_map>
76 #include <optional>
77 
78 // #include <wx/wx.h>
79 #include <wx/defs.h>
80 #include <wx/menu.h>
81 #include <wx/scrolwin.h>
82 #include <wx/event.h>
83 #include <wx/dynarray.h>
84 #include <wx/pen.h>
85 #include <wx/dcmemory.h>
86 #include <wx/string.h>
87 #include <wx/print.h>
88 #include <wx/image.h>
89 #include <wx/intl.h>
90 
91 #include <cmath>
92 #include <deque>
93 #include <algorithm>
94 
95 // No, this is supposed to be a build parameter: #define ENABLE_MP_CONFIG
96 #ifdef ENABLE_MP_CONFIG
97  #include "MathPlotConfig.h"
98 #endif // ENABLE_MP_CONFIG
99 
104 // No, this is supposed to be a build parameter: #define ENABLE_MP_NAMESPACE
105 #ifdef ENABLE_MP_NAMESPACE
106  namespace MathPlot {
107 #endif // ENABLE_MP_NAMESPACE
108 
109 #ifdef ENABLE_MP_DEBUG
110 // For memory leak debug
111 #ifdef _WINDOWS
112 #ifdef _DEBUG
113 #include <crtdbg.h>
114 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
115 #else
116 #define DEBUG_NEW new
117 #endif // _DEBUG
118 #endif // _WINDOWS
119 #endif // ENABLE_MP_DEBUG
120 
121 // Separation for axes when set close to border
122 #define X_BORDER_SEPARATION 40
123 #define Y_BORDER_SEPARATION 60
124 
126 #define mpX_LOCALTIME 0x10
127 
128 #define mpX_UTCTIME 0x20
129 #define mpX_RAWTIME mpX_UTCTIME
130 
131 // An epsilon for float comparison to 0
132 #define EPSILON 1e-8
133 #define ISNOTNULL(x) (fabs(x) > EPSILON)
134 
135 // A small extra margin for the plot boundary
136 #define EXTRA_MARGIN 8
137 
138 #define ZOOM_AROUND_CENTER -1
139 
140 //-----------------------------------------------------------------------------
141 // classes
142 //-----------------------------------------------------------------------------
143 
144 class WXDLLIMPEXP_MATHPLOT mpLayer;
145 class WXDLLIMPEXP_MATHPLOT mpFunction;
146 class WXDLLIMPEXP_MATHPLOT mpLine;
147 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine;
148 class WXDLLIMPEXP_MATHPLOT mpVerticalLine;
149 class WXDLLIMPEXP_MATHPLOT mpFX;
150 class WXDLLIMPEXP_MATHPLOT mpFY;
151 class WXDLLIMPEXP_MATHPLOT mpFXY;
152 class WXDLLIMPEXP_MATHPLOT mpFXYVector;
153 class WXDLLIMPEXP_MATHPLOT mpProfile;
154 class WXDLLIMPEXP_MATHPLOT mpChart;
155 class WXDLLIMPEXP_MATHPLOT mpBarChart;
156 class WXDLLIMPEXP_MATHPLOT mpScale;
157 class WXDLLIMPEXP_MATHPLOT mpScaleX;
158 class WXDLLIMPEXP_MATHPLOT mpScaleY;
159 class WXDLLIMPEXP_MATHPLOT mpInfoLayer;
160 class WXDLLIMPEXP_MATHPLOT mpInfoCoords;
161 class WXDLLIMPEXP_MATHPLOT mpInfoLegend;
162 class WXDLLIMPEXP_MATHPLOT mpWindow;
163 class WXDLLIMPEXP_MATHPLOT mpText;
164 class WXDLLIMPEXP_MATHPLOT mpTitle;
165 class WXDLLIMPEXP_MATHPLOT mpPrintout;
166 class WXDLLIMPEXP_MATHPLOT mpMovableObject;
167 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse;
168 class WXDLLIMPEXP_MATHPLOT mpPolygon;
169 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer;
170 
171 #ifdef ENABLE_MP_CONFIG
173 #endif // ENABLE_MP_CONFIG
174 
176 typedef union
177 {
178  struct
179  {
180  wxCoord startPx;
181  wxCoord endPx;
182  wxCoord startPy;
183  wxCoord endPy;
184  };
185  struct
186  {
187  wxCoord left;
188  wxCoord top;
189  wxCoord right;
190  wxCoord bottom;
191  };
192  struct
193  {
194  wxCoord x1;
195  wxCoord y1;
196  wxCoord x2;
197  wxCoord y2;
198  };
199  wxCoord tab[4];
200 } mpRect;
201 
207 struct mpRange
208 {
209  double min = 0.0f;
210  double max = 0.0f;
211 
214  {
215  min = 0.0f;
216  max = 0.0f;
217  }
218 
220  mpRange(double value1, double value2)
221  {
222  if (value1 < value2)
223  {
224  min = value1;
225  max = value2;
226  }
227  else
228  {
229  min = value2;
230  max = value1;
231  }
232  }
233 
235  void Set(double _min, double _max)
236  {
237  min = _min;
238  max = _max;
239  }
240 
242  void Assign(double value1, double value2)
243  {
244  if (value1 < value2)
245  {
246  min = value1;
247  max = value2;
248  }
249  else
250  {
251  min = value2;
252  max = value1;
253  }
254  }
255 
257  bool IsSet()
258  {
259  return ((min != 0.0f) || (max != 0.0f));
260  }
261 
266  void Update(double value)
267  {
268  if (value < min)
269  min = value;
270  else
271  if (value > max)
272  max = value;
273  }
274 
278  void Update(double _min, double _max)
279  {
280  if (_min < min)
281  min = _min;
282  if (_max > max)
283  max = _max;
284  }
285 
288  void Update(mpRange range)
289  {
290  if (range.min < min)
291  min = range.min;
292  if (range.max > max)
293  max = range.max;
294  }
295 
297  void Check(void)
298  {
299  if (min == max)
300  {
301  if (max > 0)
302  min = 0;
303  else
304  max = 0;
305  }
306  }
307 
309  double Length(void) const
310  {
311  return max - min;
312  }
313 
315  double GetCenter(void) const
316  {
317  return (min + max) / 2;
318  }
319 
321  double GetMaxAbs(void) const
322  {
323  return std::max(fabs(min), fabs(max));
324  }
325 
327  void ToLog(void)
328  {
329  min = (min > 0) ? log10(min) : 0;
330  max = (max > 0) ? log10(max) : 0;
331  }
332 
334  bool PointIsInside(double point) const
335  {
336  return ((point >= min) && (point <= max));
337  }
338 
339 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
340  bool operator==(const mpRange&) const = default;
341 #else
342  bool operator==(const mpRange &other) const
343  {
344  return (min == other.min) && (max == other.max);
345  }
346  bool operator!=(const mpRange& other) const
347  {
348  return !(*this == other);
349  }
350 #endif
351 };
352 
358 struct [[deprecated("No more used, X and Y are now separated")]] mpFloatRect
359 {
360  mpRange x;
361  std::vector<mpRange> y;
362 
369  mpFloatRect(mpWindow& w);
370 
372  mpFloatRect() = delete;
373 
375  bool PointIsInside(double px, double py, size_t yAxisID = 0) const {
376  if (yAxisID < y.size())
377  {
378  if( (px < x.min || px > x.max) ||
379  (py < y[yAxisID].min || py > y[yAxisID].max))
380  {
381  return false;
382  }
383  }
384  else
385  {
386  return false;
387  }
388 
389  return true;
390  }
392  void UpdateBoundingBoxToInclude(double px, double py, size_t yAxisID = 0) {
393  assert(yAxisID < y.size());
394  if (yAxisID < y.size())
395  {
396  if (px < x.min ) x.min = px;
397  else if (px > x.max ) x.max = px;
398  if (py < y[yAxisID].min ) y[yAxisID].min = py;
399  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
400  }
401  }
403  void InitializeBoundingBox(double px, double py, size_t yAxisID = 0) {
404  assert(yAxisID < y.size());
405  if (yAxisID < y.size())
406  {
407  x.min = x.max = px;
408  y[yAxisID].min = y[yAxisID].max = py;
409  }
410  }
412  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
414 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
415  bool operator==(const mpFloatRect&) const = default;
416 #else
417  // We compare with an epsilon precision
418  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
419  bool operator==(const mpFloatRect& rect) const
420  {
421  auto Same = [](double a, double b) {
422  return std::fabs(a - b) < EPSILON;
423  };
424 
425  // Compare scalar members
426  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
427  {
428  return false;
429  }
430 
431  // Compare vector sizes
432  if (y.size() != rect.y.size())
433  {
434  return false;
435  }
436 
437  // Compare each Y boundary
438  for (size_t i = 0; i < y.size(); ++i)
439  {
440  if (!Same(y[i].min, rect.y[i].min) ||
441  !Same(y[i].max, rect.y[i].max) )
442  {
443  return false;
444  }
445  }
446 
447  return true;
448  }
449 #endif
450 };
451 
458 {
459  mpRange x;
460  mpRange y;
461 
462  mpFloatRectSimple(mpRange _x, mpRange _y) : x(_x), y(_y) { };
463 
465  bool PointIsInside(double px, double py) const {
466  return x.PointIsInside(px) && y.PointIsInside(py);
467  }
468 
469  /* Update bounding box (X and Y axis) to include this point.
470  * Expand the range to include the point.
471  * @param px: point on x-axis
472  * @param py: point on y-axis
473  */
474  void UpdateBoundingBoxToInclude(double px, double py)
475  {
476  x.Update(px);
477  y.Update(py);
478  }
479 
480  /* Initialize bounding box with an initial point
481  * @param px: point on x-axis
482  * @param py: point on y-axis
483  */
484  void InitializeBoundingBox(double px, double py)
485  {
486  x.Set(px, px);
487  y.Set(py, py);
488  }
489 };
490 
494 enum
495 {
496  mpID_FIT = 2000,
504 #ifdef ENABLE_MP_CONFIG
505  mpID_CONFIG,
506 #endif // ENABLE_MP_CONFIG
510 };
511 
513 typedef enum __mp_Location_Type
514 {
515  mpMarginLeftCenter,
516  mpMarginTopLeft,
517  mpMarginTopCenter,
518  mpMarginTopRight,
519  mpMarginRightCenter,
520  mpMarginBottomLeft,
521  mpMarginBottomCenter,
522  mpMarginBottomRight,
523  mpMarginNone,
524  mpCursor // only for mpInfoCoords
525 } mpLocation;
526 
528 typedef enum __XAxis_Align_Type
529 {
530  mpALIGN_BORDER_BOTTOM = 10,
531  mpALIGN_BOTTOM,
532  mpALIGN_CENTERX,
533  mpALIGN_TOP,
534  mpALIGN_BORDER_TOP
535 } mpXAxis_Align;
536 
538 typedef enum __YAxis_Align_Type
539 {
540  mpALIGN_BORDER_LEFT = 20,
541  mpALIGN_LEFT,
542  mpALIGN_CENTERY,
543  mpALIGN_RIGHT,
544  mpALIGN_BORDER_RIGHT
545 } mpYAxis_Align;
546 
549 {
550  mpALIGN_NW = 5,
551  mpALIGN_NE,
552  mpALIGN_SE,
553  mpALIGN_SW
554 } mpPlot_Align;
555 
557 typedef enum __mp_Style_Type
558 {
562 } mpLegendStyle;
563 
566 {
570 
571 typedef enum __Symbol_Type
572 {
573  mpsNone,
574  mpsCircle,
575  mpsSquare,
576  mpsUpTriangle,
577  mpsDownTriangle,
578  mpsCross,
579  mpsPlus
580 } mpSymbol;
581 
582 //-----------------------------------------------------------------------------
583 // mpLayer sub_type values
584 //-----------------------------------------------------------------------------
585 
587 typedef enum __Info_Type
588 {
589  mpiNone, // never used
590  mpiInfo,
591  mpiCoords,
592  mpiLegend
593 } mpInfoType;
594 
596 typedef enum __Text_Type
597 {
598  mptNone, // never used
599  mptText,
600  mptTitle
601 } mpTextType;
602 
603 typedef enum __Function_Type
604 {
605  mpfNone,
606  mpfFX,
607  mpfFY,
608  mpfFXY,
609  mpfFXYVector,
610  mpfMovable,
611  mpfLine,
612  mpfAllType
613 } mpFunctionType;
614 
615 typedef enum __Scale_Type
616 {
617  mpsScaleNone,
618  mpsScaleX,
619  mpsScaleY,
620  mpsAllType
621 } mpScaleType;
622 
623 typedef enum __Chart_Type
624 {
625  mpcChartNone,
626  mpcBarChart,
627  mpcPieChart,
628  mpcAllType
629 } mpChartType;
630 
631 enum mpMouseButtonAction
632 {
633  mpMouseBoxZoom,
634  mpMouseDragZoom,
635 };
636 
638 {
658 };
659 
660 //-----------------------------------------------------------------------------
661 // mpLayer
662 //-----------------------------------------------------------------------------
663 
664 typedef enum __mp_Layer_Type
665 {
674 } mpLayerType;
675 
681 typedef enum __mp_Layer_ZOrder
682 {
691 } mpLayerZOrder;
692 
699 typedef enum __mp_Delete_Action
700 {
701  mpNoDelete,
702  mpYesDelete,
703  mpForceDelete
705 
716 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
717 {
718  public:
719  mpLayer(mpLayerType layerType);
720 
721  virtual ~mpLayer()
722  {
723  ;
724  }
725 
729  {
730  m_win = &w;
731  }
732 
740  virtual bool HasBBox()
741  {
742  return true;
743  }
744 
749  mpLayerType GetLayerType() const
750  {
751  return m_type;
752  }
753 
757  int GetLayerSubType() const
758  {
759  return m_subtype;
760  }
761 
767  virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
768  {
769  *subtype = m_subtype;
770  return (m_type == typeOfInterest);
771  }
772 
776  virtual double GetMinX()
777  {
778  return -1.0;
779  }
780 
784  virtual double GetMaxX()
785  {
786  return 1.0;
787  }
788 
792  virtual double GetMinY()
793  {
794  return -1.0;
795  }
796 
800  virtual double GetMaxY()
801  {
802  return 1.0;
803  }
804 
846  void Plot(wxDC &dc, mpWindow &w);
847 
851  void SetName(const wxString &name)
852  {
853  m_name = name;
854  }
855 
859  const wxString& GetName() const
860  {
861  return m_name;
862  }
863 
867  void SetFont(const wxFont &font)
868  {
869  m_font = font;
870  }
871 
875  const wxFont& GetFont() const
876  {
877  return m_font;
878  }
879 
883  void SetFontColour(const wxColour &colour)
884  {
885  m_fontcolour = colour;
886  }
887 
891  const wxColour& GetFontColour() const
892  {
893  return m_fontcolour;
894  }
895 
899  void SetPen(const wxPen &pen)
900  {
901  m_pen = pen;
902  }
903 
907  const wxPen& GetPen() const
908  {
909  return m_pen;
910  }
911 
914  void SetBrush(const wxBrush &brush)
915  {
916  if (brush == wxNullBrush)
917  m_brush = *wxTRANSPARENT_BRUSH;
918  else
919  m_brush = brush;
920  }
921 
924  const wxBrush& GetBrush() const
925  {
926  return m_brush;
927  }
928 
931  void SetShowName(bool show)
932  {
933  m_showName = show;
934  }
935 
938  inline bool GetShowName() const
939  {
940  return m_showName;
941  }
942 
945  void SetDrawOutsideMargins(bool drawModeOutside)
946  {
947  m_drawOutsideMargins = drawModeOutside;
948  }
949 
953  {
954  return m_drawOutsideMargins;
955  }
956 
961  wxBitmap GetColourSquare(int side = 16);
962 
965  inline bool IsVisible() const
966  {
967  return m_visible;
968  }
969 
972  virtual void SetVisible(bool show)
973  {
974  m_visible = show;
975  }
976 
979  inline bool IsTractable() const
980  {
981  return m_tractable;
982  }
983 
986  virtual void SetTractable(bool track)
987  {
988  m_tractable = track;
989  }
990 
993  void SetAlign(int align)
994  {
995  m_flags = align;
996  }
997 
1000  int GetAlign() const
1001  {
1002  return m_flags;
1003  }
1004 
1007  void SetCanDelete(bool canDelete)
1008  {
1009  m_CanDelete = canDelete;
1010  }
1011 
1014  bool GetCanDelete(void) const
1015  {
1016  return m_CanDelete;
1017  }
1018 
1021  mpLayerZOrder GetZIndex(void) const
1022  {
1023  return m_ZIndex;
1024  }
1025 
1026  protected:
1027  const mpLayerType m_type;
1030  wxFont m_font;
1031  wxColour m_fontcolour;
1032  wxPen m_pen;
1033  wxBrush m_brush;
1034  wxString m_name;
1035  bool m_showName;
1037  bool m_visible;
1039  int m_flags;
1042  mpLayerZOrder m_ZIndex;
1043 
1046  void UpdateContext(wxDC &dc) const;
1047 
1052  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1053 
1058  virtual bool DoBeforePlot()
1059  {
1060  return true;
1061  }
1062 
1069  void CheckLog(double *x, double *y, int yAxisID);
1070 
1071  private:
1072  bool m_busy;
1073  mpLayer() = delete; // default ctor not implemented/permitted
1074 
1075  wxDECLARE_DYNAMIC_CLASS(mpLayer);
1076 };
1077 
1078 //-----------------------------------------------------------------------------
1079 // mpInfoLayer
1080 //-----------------------------------------------------------------------------
1081 
1087 class WXDLLIMPEXP_MATHPLOT mpInfoLayer: public mpLayer
1088 {
1089  public:
1091  mpInfoLayer();
1092 
1097  mpInfoLayer(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1098 
1100  virtual ~mpInfoLayer();
1101 
1104  virtual void SetVisible(bool show);
1105 
1110  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1111 
1114  virtual bool HasBBox()
1115  {
1116  return false;
1117  }
1118 
1122  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1123 
1127  virtual bool Inside(const wxPoint &point);
1128 
1131  virtual void Move(wxPoint delta);
1132 
1134  virtual void UpdateReference();
1135 
1138  wxPoint GetPosition() const
1139  {
1140  return m_dim.GetPosition();
1141  }
1142 
1145  wxSize GetSize() const
1146  {
1147  return m_dim.GetSize();
1148  }
1149 
1152  const wxRect& GetRectangle() const
1153  {
1154  return m_dim;
1155  }
1156 
1159  void SetLocation(mpLocation location)
1160  {
1161  m_location = location;
1162  }
1163 
1166  mpLocation GetLocation() const
1167  {
1168  return m_location;
1169  }
1170 
1171  protected:
1172  wxRect m_dim;
1173  wxRect m_oldDim;
1174  wxBitmap* m_info_bmp;
1175  wxPoint m_reference;
1176  int m_winX, m_winY;
1177  mpLocation m_location;
1178 
1183  virtual void DoPlot(wxDC &dc, mpWindow &w);
1184 
1187  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1188 
1189  wxDECLARE_DYNAMIC_CLASS(mpInfoLayer);
1190 };
1191 
1196 class WXDLLIMPEXP_MATHPLOT mpInfoCoords: public mpInfoLayer
1197 {
1198  public:
1200  mpInfoCoords();
1201 
1203  mpInfoCoords(mpLocation location);
1204 
1209  mpInfoCoords(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1210 
1213  {
1214  ;
1215  }
1216 
1220  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1221 
1222  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1223 
1226  void SetLabelMode(mpLabelType mode, unsigned int time_conv = mpX_RAWTIME)
1227  {
1228  m_labelType = mode;
1229  m_timeConv = time_conv;
1230  }
1231 
1234  void SetSeriesCoord(bool show)
1235  {
1236  m_series_coord = show;
1237  }
1238 
1241  bool IsSeriesCoord() const
1242  {
1243  return m_series_coord;
1244  }
1245 
1251  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1252 
1255  void SetPenSeries(const wxPen &pen)
1256  {
1257  m_penSeries = pen;
1258  }
1259 
1260  protected:
1261  wxString m_content;
1262  mpLabelType m_labelType;
1263  unsigned int m_timeConv;
1264  wxCoord m_mouseX;
1265  wxCoord m_mouseY;
1266  bool m_series_coord;
1267  wxPen m_penSeries;
1268 
1273  virtual void DoPlot(wxDC &dc, mpWindow &w);
1274 
1275  wxDECLARE_DYNAMIC_CLASS(mpInfoCoords);
1276 };
1277 
1282 class WXDLLIMPEXP_MATHPLOT mpInfoLegend: public mpInfoLayer
1283 {
1284  public:
1286  mpInfoLegend();
1287 
1293  mpInfoLegend(wxRect rect, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginNone);
1294 
1297 
1300  void SetItemMode(mpLegendStyle mode)
1301  {
1302  m_item_mode = mode;
1303  m_needs_update = true;
1304  }
1305 
1306  mpLegendStyle GetItemMode() const
1307  {
1308  return m_item_mode;
1309  }
1310 
1313  void SetItemDirection(mpLegendDirection mode)
1314  {
1315  m_item_direction = mode;
1316  m_needs_update = true;
1317  }
1318 
1319  mpLegendDirection GetItemDirection() const
1320  {
1321  return m_item_direction;
1322  }
1323 
1324  void SetNeedUpdate()
1325  {
1326  m_needs_update = true;
1327  }
1328 
1330  int GetPointed(mpWindow &w, wxPoint eventPoint);
1331 
1332  protected:
1333  mpLegendStyle m_item_mode;
1334  mpLegendDirection m_item_direction;
1335 
1340  virtual void DoPlot(wxDC &dc, mpWindow &w);
1341 
1342  private:
1344  struct LegendDetail
1345  {
1346  unsigned int layerIdx;
1347  wxCoord legendEnd;
1348  };
1350  std::vector<LegendDetail> m_LegendDetailList;
1351  bool m_needs_update;
1352 
1362  void UpdateBitmap(wxDC &dc, mpWindow &w);
1363 
1364  wxDECLARE_DYNAMIC_CLASS(mpInfoLegend);
1365 };
1366 
1367 //-----------------------------------------------------------------------------
1368 // mpLayer implementations - functions
1369 //-----------------------------------------------------------------------------
1370 
1378 class WXDLLIMPEXP_MATHPLOT mpFunction: public mpLayer
1379 {
1380  public:
1383  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1384 
1388  void SetContinuity(bool continuity)
1389  {
1390  m_continuous = continuity;
1391  }
1392 
1396  bool GetContinuity() const
1397  {
1398  return m_continuous;
1399  }
1400 
1403  void SetStep(unsigned int step)
1404  {
1405  m_step = step;
1406  }
1407 
1410  unsigned int GetStep() const
1411  {
1412  return m_step;
1413  }
1414 
1417  void SetSymbol(mpSymbol symbol)
1418  {
1419  m_symbol = symbol;
1420  }
1421 
1424  mpSymbol GetSymbol() const
1425  {
1426  return m_symbol;
1427  }
1428 
1431  void SetSymbolSize(int size)
1432  {
1433  m_symbolSize = size;
1434  m_symbolSize2 = size / 2;
1435  }
1436 
1439  int GetSymbolSize() const
1440  {
1441  return m_symbolSize;
1442  }
1443 
1447  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1448 
1452  int GetYAxisID() const
1453  {
1454  return m_yAxisID;
1455  }
1456 
1460  void SetYAxisID(unsigned int yAxisID)
1461  {
1462  m_yAxisID = yAxisID;
1463  }
1464 
1465  protected:
1467  mpSymbol m_symbol;
1470  unsigned int m_step;
1472 
1473  wxDECLARE_DYNAMIC_CLASS(mpFunction);
1474 };
1475 
1478 class WXDLLIMPEXP_MATHPLOT mpLine: public mpFunction
1479 {
1480  public:
1481  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1482 
1483  // We don't want to include line (horizontal or vertical) in BBox computation
1484  virtual bool HasBBox() override
1485  {
1486  return false;
1487  }
1488 
1492  double GetValue() const
1493  {
1494  return m_value;
1495  }
1496 
1500  void SetValue(const double value)
1501  {
1502  m_value = value;
1503  }
1504 
1507  bool IsHorizontal(void) const
1508  {
1509  return m_IsHorizontal;
1510  }
1511 
1512  protected:
1513  double m_value;
1514  bool m_IsHorizontal;
1515 
1516  wxDECLARE_DYNAMIC_CLASS(mpLine);
1517 };
1518 
1521 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine: public mpLine
1522 {
1523  public:
1524  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1525 
1529  void SetYValue(const double yvalue)
1530  {
1531  SetValue(yvalue);
1532  }
1533 
1534  protected:
1535 
1536  virtual void DoPlot(wxDC &dc, mpWindow &w);
1537 
1538  wxDECLARE_DYNAMIC_CLASS(mpHorizontalLine);
1539 };
1540 
1543 class WXDLLIMPEXP_MATHPLOT mpVerticalLine: public mpLine
1544 {
1545  public:
1546  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1547 
1551  void SetXValue(const double xvalue)
1552  {
1553  SetValue(xvalue);
1554  }
1555 
1556  protected:
1557 
1558  virtual void DoPlot(wxDC &dc, mpWindow &w);
1559 
1564  virtual bool DoBeforePlot()
1565  {
1566  return true;
1567  }
1568 
1569  wxDECLARE_DYNAMIC_CLASS(mpVerticalLine);
1570 };
1571 
1578 class WXDLLIMPEXP_MATHPLOT mpFX: public mpFunction
1579 {
1580  public:
1584  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
1585 
1591  virtual double GetY(double x) = 0;
1592 
1597  double DoGetY(double x);
1598 
1603  void DefineDoGetY(void);
1604 
1605  protected:
1606 
1607  // Pointer function to the appropriate DoGetY function
1608  double (mpFX::*pDoGetY)(double x);
1609 
1614  virtual void DoPlot(wxDC &dc, mpWindow &w);
1615 
1619  double NormalDoGetY(double x);
1620  double LogDoGetY(double x);
1621 
1622  wxDECLARE_DYNAMIC_CLASS(mpFX);
1623 };
1624 
1631 class WXDLLIMPEXP_MATHPLOT mpFY: public mpFunction
1632 {
1633  public:
1637  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
1638 
1644  virtual double GetX(double y) = 0;
1645 
1650  double DoGetX(double y);
1651 
1656  void DefineDoGetX(void);
1657 
1658  protected:
1659 
1660  // Pointer function to the appropriate DoGetX function
1661  double (mpFY::*pDoGetX)(double y);
1662 
1667  virtual void DoPlot(wxDC &dc, mpWindow &w);
1668 
1672  double NormalDoGetX(double y);
1673  double LogDoGetX(double y);
1674 
1675  wxDECLARE_DYNAMIC_CLASS(mpFY);
1676 };
1677 
1687 class WXDLLIMPEXP_MATHPLOT mpFXY: public mpFunction
1688 {
1689  public:
1693  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, unsigned int yAxisID = 0);
1694 
1698  virtual void Rewind() = 0;
1699 
1703  virtual void Clear()
1704  {
1705  ;
1706  }
1707 
1711  virtual int GetSize()
1712  {
1713  return 0;
1714  }
1715 
1722  virtual bool GetNextXY(double *x, double *y) = 0;
1723 
1727  bool DoGetNextXY(double *x, double *y);
1728 
1732  void SetViewMode(bool asBar);
1733 
1737  int GetBarWidth(void) const
1738  {
1739  return m_BarWidth;
1740  }
1741 
1745  bool ViewAsBar(void) const
1746  {
1747  return m_ViewAsBar;
1748  }
1749 
1750  protected:
1751 
1752  // Data to calculate label positioning
1753  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
1754 
1755  // Min delta between 2 x coordinate (used for view as bar)
1756  double m_deltaX, m_deltaY;
1757 
1758  // The width of a bar
1759  int m_BarWidth;
1760 
1761  // Plot data as bar graph
1762  bool m_ViewAsBar = false;
1763 
1768  virtual void DoPlot(wxDC &dc, mpWindow &w);
1769 
1774  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
1775 
1776  wxDECLARE_DYNAMIC_CLASS(mpFXY);
1777 };
1778 
1779 //-----------------------------------------------------------------------------
1780 // mpFXYVector - provided by Jose Luis Blanco
1781 //-----------------------------------------------------------------------------
1782 
1802 class WXDLLIMPEXP_MATHPLOT mpFXYVector: public mpFXY
1803 {
1804  public:
1808  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, unsigned int yAxisID = 0);
1809 
1812  virtual ~mpFXYVector()
1813  {
1814  Clear();
1815  }
1816 
1821  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
1822 
1826  void Clear();
1827 
1832  virtual int GetSize()
1833  {
1834  return m_xs.size();
1835  }
1836 
1844  bool AddData(const double x, const double y, bool updatePlot);
1845 
1851  void SetReserve(int reserve)
1852  {
1853  m_reserveXY = reserve;
1854  m_xs.reserve(m_reserveXY);
1855  m_ys.reserve(m_reserveXY);
1856  }
1857 
1860  int GetReserve() const
1861  {
1862  return m_reserveXY;
1863  }
1864 
1865  protected:
1868  std::vector<double> m_xs, m_ys;
1869 
1873 
1876  size_t m_index;
1877 
1880  double m_minX, m_maxX, m_minY, m_maxY, m_lastX, m_lastY;
1881 
1885  inline void Rewind()
1886  {
1887  m_index = 0;
1888  }
1889 
1895  virtual bool GetNextXY(double *x, double *y);
1896 
1899  void DrawAddedPoint(double x, double y);
1900 
1903  virtual double GetMinX()
1904  {
1905  if(m_ViewAsBar)
1906  {
1907  // Make extra space for outer bars
1908  return m_minX - (m_deltaX / 2);
1909  }
1910  else
1911  {
1912  return m_minX;
1913  }
1914  }
1915 
1918  virtual double GetMinY()
1919  {
1920  return m_minY;
1921  }
1922 
1925  virtual double GetMaxX()
1926  {
1927  if(m_ViewAsBar)
1928  {
1929  // Make extra space for outer bars
1930  return m_maxX + (m_deltaX / 2);
1931  }
1932  else
1933  {
1934  return m_maxX;
1935  }
1936  }
1937 
1940  virtual double GetMaxY()
1941  {
1942  return m_maxY;
1943  }
1944 
1945  private:
1948  void First_Point(double x, double y);
1949 
1952  void Check_Limit(double val, double *min, double *max, double *last, double *delta);
1953 
1954  wxDECLARE_DYNAMIC_CLASS(mpFXYVector);
1955 };
1956 
1965 class WXDLLIMPEXP_MATHPLOT mpProfile: public mpFunction
1966 {
1967  public:
1971  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
1972 
1978  virtual double GetY(double x) = 0;
1979 
1980  protected:
1981 
1986  virtual void DoPlot(wxDC &dc, mpWindow &w);
1987 
1988  wxDECLARE_DYNAMIC_CLASS(mpProfile);
1989 };
1990 
1991 //-----------------------------------------------------------------------------
1992 // mpChart
1993 //-----------------------------------------------------------------------------
1996 class WXDLLIMPEXP_MATHPLOT mpChart: public mpFunction
1997 {
1998  public:
2000  mpChart(const wxString &name = wxEmptyString);
2001 
2004  {
2005  Clear();
2006  }
2007 
2010  void SetChartValues(const std::vector<double> &data);
2011 
2014  void SetChartLabels(const std::vector<std::string> &labelArray);
2015 
2020  void AddData(const double &data, const std::string &label);
2021 
2025  virtual void Clear();
2026 
2027  virtual bool HasBBox()
2028  {
2029  return (values.size() > 0);
2030  }
2031 
2032  protected:
2033  std::vector<double> values;
2034  std::vector<std::string> labels;
2035 
2036  double m_max_value;
2037  double m_total_value;
2038 
2039  wxDECLARE_DYNAMIC_CLASS(mpChart);
2040 };
2041 
2042 //-----------------------------------------------------------------------------
2043 // mpBarChart - provided by Jose Davide Rondini
2044 //-----------------------------------------------------------------------------
2045 /* Defines for bar charts label positioning. */
2046 #define mpBAR_NONE 0
2047 #define mpBAR_AXIS_H 1
2048 #define mpBAR_AXIS_V 2
2049 #define mpBAR_INSIDE 3
2050 #define mpBAR_TOP 4
2051 
2052 
2054 class WXDLLIMPEXP_MATHPLOT mpBarChart: public mpChart
2055 {
2056  public:
2058  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2059 
2062  {
2063  Clear();
2064  }
2065 
2066  void SetBarColour(const wxColour &colour);
2067 
2068  void SetColumnWidth(const double colWidth)
2069  {
2070  m_width = colWidth;
2071  }
2072 
2074  void SetBarLabelPosition(int position);
2075 
2079  virtual double GetMinX();
2080 
2084  virtual double GetMaxX();
2085 
2089  virtual double GetMinY();
2090 
2094  virtual double GetMaxY();
2095 
2096  protected:
2097 
2098  double m_width;
2099  wxColour m_barColour;
2100  int m_labelPos;
2101  double m_labelAngle;
2102 
2107  virtual void DoPlot(wxDC &dc, mpWindow &w);
2108 
2109  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2110 };
2111 
2115 class WXDLLIMPEXP_MATHPLOT mpPieChart: public mpChart
2116 {
2117  public:
2119  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2120 
2123  {
2124  Clear();
2125  colours.clear();
2126  }
2127 
2131  void SetCenter(const wxPoint center)
2132  {
2133  m_center = center;
2134  }
2135 
2138  wxPoint GetCenter(void) const
2139  {
2140  return m_center;
2141  }
2142 
2146  void SetPieColours(const std::vector<wxColour> &colourArray);
2147 
2151  virtual double GetMinX()
2152  {
2153  return m_center.x - m_radius;
2154  }
2155 
2159  virtual double GetMaxX()
2160  {
2161  return m_center.x + m_radius;
2162  }
2163 
2167  virtual double GetMinY()
2168  {
2169  return m_center.y - m_radius;
2170  }
2171 
2175  virtual double GetMaxY()
2176  {
2177  return m_center.y + m_radius;
2178  }
2179 
2180  protected:
2181 
2182  double m_radius;
2183  wxPoint m_center;
2184  std::vector<wxColour> colours;
2185 
2190  virtual void DoPlot(wxDC &dc, mpWindow &w);
2191 
2192  const wxColour& GetColour(unsigned int id);
2193 
2194  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2195 };
2196 
2199 //-----------------------------------------------------------------------------
2200 // mpLayer implementations - furniture (scales, ...)
2201 //-----------------------------------------------------------------------------
2208 class WXDLLIMPEXP_MATHPLOT mpScale: public mpLayer
2209 {
2210  public:
2215  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, std::optional<unsigned int> axisID = std::nullopt);
2216 
2220  virtual bool HasBBox()
2221  {
2222  return false;
2223  }
2224 
2228  int GetAxisID(void)
2229  {
2230  return m_axisID;
2231  }
2232 
2237  void SetAxisID(unsigned int yAxisID)
2238  {
2239  m_axisID = yAxisID;
2240  }
2241 
2244  void ShowTicks(bool ticks)
2245  {
2246  m_ticks = ticks;
2247  }
2248 
2251  bool GetShowTicks() const
2252  {
2253  return m_ticks;
2254  }
2255 
2258  void ShowGrids(bool grids)
2259  {
2260  m_grids = grids;
2261  }
2262 
2265  bool GetShowGrids() const
2266  {
2267  return m_grids;
2268  }
2269 
2272  void SetLabelFormat(const wxString &format)
2273  {
2274  m_labelFormat = format;
2275  m_labelType = mpLabel_USER;
2276  }
2277 
2281  {
2282  return m_labelType;
2283  }
2284 
2287  void SetLabelMode(mpLabelType mode, unsigned int time_conv = mpX_RAWTIME)
2288  {
2289  m_labelType = mode;
2290  m_timeConv = time_conv;
2291  }
2292 
2295  const wxString& GetLabelFormat() const
2296  {
2297  return m_labelFormat;
2298  }
2299 
2303  void SetGridPen(const wxPen &pen)
2304  {
2305  m_gridpen = pen;
2306  }
2307 
2311  const wxPen& GetGridPen() const
2312  {
2313  return m_gridpen;
2314  }
2315 
2319  void SetAuto(bool automaticScalingIsEnabled)
2320  {
2321  m_auto = automaticScalingIsEnabled;
2322  }
2323 
2327  bool GetAuto() const
2328  {
2329  return m_auto;
2330  }
2331 
2332  void SetMinScale(double min)
2333  {
2334  m_min = min;
2335  }
2336 
2337  double GetMinScale() const
2338  {
2339  return m_min;
2340  }
2341 
2342  void SetMaxScale(double max)
2343  {
2344  m_max = max;
2345  }
2346 
2347  double GetMaxScale() const
2348  {
2349  return m_max;
2350  }
2351 
2352  void SetScale(double min, double max)
2353  {
2354  m_min = min;
2355  m_max = max;
2356  }
2357 
2358  void GetScale(double *min, double *max) const
2359  {
2360  *min = m_min;
2361  *max = m_max;
2362  }
2363 
2364  void SetScale(mpRange range)
2365  {
2366  m_min = range.min;
2367  m_max = range.max;
2368  }
2369 
2374  {
2375  return mpRange(m_min, m_max);
2376  }
2377 
2381  virtual bool IsLogAxis()
2382  {
2383  return m_isLog;
2384  }
2385 
2386  virtual void SetLogAxis(bool log)
2387  {
2388  m_isLog = log;
2389  }
2390 
2391  protected:
2392  static const wxCoord kTickSize = 4;
2393  static const wxCoord kAxisExtraSpace = 6;
2394 
2395  int m_axisID;
2396  wxPen m_gridpen;
2397  bool m_ticks;
2398  bool m_grids;
2399  bool m_auto;
2400  double m_min, m_max;
2402  unsigned int m_timeConv;
2403  wxString m_labelFormat;
2404  bool m_isLog;
2405 
2406  virtual int GetOrigin(mpWindow &w) = 0;
2407 
2414  double GetStep(double scale, int minLabelSpacing);
2415  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
2416 
2421  wxString FormatLogValue(double n);
2422 
2427  bool UseScientific(double maxAxisValue);
2428 
2434  int GetSignificantDigits(double step, double maxAxisValue);
2435 
2440  int GetDecimalDigits(double step);
2441 
2442  wxDECLARE_DYNAMIC_CLASS(mpScale);
2443 };
2444 
2445 
2451 class WXDLLIMPEXP_MATHPLOT mpScaleX: public mpScale
2452 {
2453  public:
2459  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, mpLabelType type = mpLabel_AUTO) :
2460  mpScale(name, flags, grids, type)
2461  {
2462  m_subtype = mpsScaleX;
2463  }
2464 
2465  bool IsTopAxis()
2466  {
2467  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
2468  }
2469 
2470  bool IsBottomAxis()
2471  {
2472  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
2473  }
2474 
2475  protected:
2476 
2479  virtual void DoPlot(wxDC &dc, mpWindow &w);
2480 
2486  int GetLabelWidth(double value, wxDC &dc, wxString fmt);
2487 
2488  virtual int GetOrigin(mpWindow &w);
2489  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2490  wxString FormatValue(const wxString &fmt, double n);
2491 
2492  wxDECLARE_DYNAMIC_CLASS(mpScaleX);
2493 };
2494 
2501 class WXDLLIMPEXP_MATHPLOT mpScaleY: public mpScale
2502 {
2503  public:
2508  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, std::optional<unsigned int> yAxisID = std::nullopt, mpLabelType labelType = mpLabel_AUTO) :
2509  mpScale(name, flags, grids, labelType, yAxisID)
2510  {
2511  m_subtype = mpsScaleY;
2512  m_axisWidth = Y_BORDER_SEPARATION;
2513  m_xPos = 0;
2514  }
2515 
2518  void UpdateAxisWidth(mpWindow &w);
2519 
2520  int GetAxisWidth()
2521  {
2522  return m_axisWidth;
2523  }
2524 
2525  bool IsLeftAxis()
2526  {
2527  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
2528  }
2529 
2530  bool IsRightAxis()
2531  {
2532  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
2533  }
2534 
2535  bool IsInside(wxCoord xPixel)
2536  {
2537  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
2538  {
2539  return true;
2540  }
2541  return false;
2542  }
2543 
2544  protected:
2545  int m_axisWidth;
2546  int m_xPos;
2547 
2550  virtual void DoPlot(wxDC &dc, mpWindow &w);
2551 
2552  virtual int GetOrigin(mpWindow &w);
2553  wxString GetLabelFormat(mpWindow &w, double step);
2554  int GetLabelWidth(double value, wxDC &dc, wxString fmt);
2555  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2556 
2557  wxDECLARE_DYNAMIC_CLASS(mpScaleY);
2558 };
2559 
2560 //-----------------------------------------------------------------------------
2561 // mpWindow
2562 //-----------------------------------------------------------------------------
2563 
2568 #define mpMOUSEMODE_DRAG 0
2569 
2570 #define mpMOUSEMODE_ZOOMBOX 1
2571 
2574 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
2575 typedef std::deque<mpLayer*> mpLayerList;
2576 
2587 {
2588  mpScale* axis = nullptr;
2589  double scale = 1.0;
2590  double pos = 0;
2594 
2595  // Note: we don't use the default operator since we don't want to compare axis pointers
2596  bool operator==(const mpAxisData& other) const
2597  {
2598  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
2599  (bound == other.bound) && (desired == other.desired);
2600  }
2601 };
2602 
2604 typedef std::unordered_map<int, mpAxisData> mpAxisList;
2605 
2612 typedef enum {
2613  uXAxis = 1,
2614  uYAxis = 2,
2615  uXYAxis = 3
2616 } mpAxisUpdate;
2617 
2624 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
2625 
2632 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
2633 
2639 {
2640  public:
2641  mpMagnet()
2642  {
2643  m_IsDrawn = false;
2644  m_rightClick = false;
2645  m_IsWasDrawn = false;
2646  }
2647  ~mpMagnet()
2648  {
2649  ;
2650  }
2651  void UpdateBox(wxCoord left, wxCoord top, wxCoord width, wxCoord height)
2652  {
2653  m_domain = wxRect(left, top, width, height);
2654  m_plot_size = wxRect(left, top, width + left, height + top);
2655  }
2656  void UpdateBox(const wxRect &size)
2657  {
2658  m_domain = size;
2659  m_plot_size = wxRect(size.GetLeft(), size.GetTop(),
2660  size.GetWidth() + size.GetLeft(), size.GetHeight() + size.GetTop());
2661  }
2662  void Plot(wxClientDC &dc, const wxPoint &mousePos);
2663  void ClearPlot(wxClientDC &dc);
2664  void UpdatePlot(wxClientDC &dc, const wxPoint &mousePos);
2665  void SaveDrawState(void)
2666  {
2667  m_IsWasDrawn = m_IsDrawn;
2668  // In any cases, set to false because we erase and repaint all the plot
2669  m_IsDrawn = false;
2670  }
2671 
2672  void SetRightClick(void)
2673  {
2674  m_rightClick = true;
2675  }
2676 
2677  private:
2678  wxRect m_domain;
2679  wxRect m_plot_size;
2680  wxPoint m_mousePosition;
2681  bool m_IsDrawn;
2682  bool m_IsWasDrawn;
2683  bool m_rightClick;
2684  void DrawCross(wxClientDC &dc) const;
2685 };
2686 
2708 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
2709 {
2710  public:
2711  mpWindow()
2712  {
2713  InitParameters();
2714  }
2715 
2716  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
2717  long flags = 0);
2718 
2719  ~mpWindow();
2720 
2724  wxMenu* GetPopupMenu()
2725  {
2726  return &m_popmenu;
2727  }
2728 
2737  bool AddLayer(mpLayer *layer, bool refreshDisplay = true, bool refreshConfig = true);
2738 
2751  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
2752 
2758  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
2759 
2766  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
2767 
2774  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
2775 
2781  mpLayer* GetLayer(int position);
2782 
2787  int GetLayerPosition(mpLayer* layer);
2788 
2795  mpLayer* GetLayersType(int position, mpLayerType type);
2796 
2802  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
2803 
2806  mpLayer* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
2807 
2812  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
2813 
2817  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
2818 
2823  mpLayer* GetLayerByName(const wxString &name);
2824 
2829  mpLayer* GetLayerByClassName(const wxString &name);
2830 
2834  void RefreshLegend(void);
2835 
2840  bool IsYAxisUsed(int yAxisID);
2841 
2845  mpScaleX* GetLayerXAxis();
2846 
2850  mpScaleY* GetLayerYAxis(int yAxisID);
2851 
2855  void SetScaleX(const double scaleX)
2856  {
2857  if (ISNOTNULL(scaleX))
2858  {
2859  m_AxisDataX.scale = scaleX;
2860  UpdateDesiredBoundingBox(uXAxis);
2861  }
2862  UpdateAll();
2863  }
2864 
2869  double GetScaleX(void) const
2870  {
2871  return m_AxisDataX.scale;
2872  }
2873 
2878  void SetScaleY(const double scaleY, int yAxisID)
2879  {
2880  assert(m_AxisDataYList.count(yAxisID) != 0);
2881  if (ISNOTNULL(scaleY))
2882  {
2883  m_AxisDataYList[yAxisID].scale = scaleY;
2884  UpdateDesiredBoundingBox(uYAxis);
2885  }
2886  UpdateAll();
2887  }
2888 
2894  double GetScaleY(int yAxisID)
2895  {
2896  assert(m_AxisDataYList.count(yAxisID) != 0);
2897  return m_AxisDataYList[yAxisID].scale;
2898  } // Schaling's method: maybe another method exists with the same name
2899 
2900  [[deprecated("Incomplete, use UpdateBBox instead")]]
2903  void SetBound();
2904 
2906  mpRange GetBoundX(void) const
2907  {
2908  return m_AxisDataX.bound;
2909  }
2910 
2913  {
2914  return m_AxisDataX.desired;
2915  }
2916 
2920  mpRange GetBoundY(int yAxisID)
2921  {
2922  assert(m_AxisDataYList.count(yAxisID) != 0);
2923  return m_AxisDataYList[yAxisID].bound;
2924  }
2925 
2930  {
2931  assert(m_AxisDataYList.count(yAxisID) != 0);
2932  return m_AxisDataYList[yAxisID].desired;
2933  }
2934 
2939  std::unordered_map<int, mpRange> GetAllBoundY()
2940  {
2941  std::unordered_map<int, mpRange> yRange;
2942  for (auto& [yID, yData] : m_AxisDataYList)
2943  {
2944  yRange[yID] = yData.bound;
2945  }
2946  return yRange;
2947  }
2948 
2953  std::unordered_map<int, mpRange> GetAllDesiredY()
2954  {
2955  std::unordered_map<int, mpRange> yRange;
2956  for (auto& [yID, yData] : m_AxisDataYList)
2957  {
2958  yRange[yID] = yData.desired;
2959  }
2960  return yRange;
2961  }
2962 
2966  void SetPosX(const double posX)
2967  {
2968  m_AxisDataX.pos = posX;
2969  UpdateDesiredBoundingBox(uXAxis);
2970  UpdateAll();
2971  }
2972 
2977  double GetPosX(void) const
2978  {
2979  return m_AxisDataX.pos;
2980  }
2981 
2986  void SetPosY(std::unordered_map<int, double>& posYList)
2987  {
2988  for (auto& [yID, yData] : m_AxisDataYList)
2989  {
2990  yData.pos = posYList[yID];
2991  }
2992  UpdateDesiredBoundingBox(uYAxis);
2993  UpdateAll();
2994  }
2995 
3001  double GetPosY(int yAxisID)
3002  {
3003  assert(m_AxisDataYList.count(yAxisID) != 0);
3004  return m_AxisDataYList[yAxisID].pos;
3005  }
3006 
3010  int GetNOfYAxis(void) const
3011  {
3012  return (int)m_AxisDataYList.size();
3013  }
3014 
3018  mpAxisList GetAxisDataYList(void) const
3019  {
3020  return m_AxisDataYList;
3021  }
3022 
3026  std::map<int, mpAxisData> GetSortedAxisDataYList(void) const
3027  {
3028  return std::map<int, mpAxisData>(m_AxisDataYList.begin(), m_AxisDataYList.end());
3029  }
3030 
3036  void SetScreen(const int scrX, const int scrY)
3037  {
3038  m_scrX = scrX;
3039  m_scrY = scrY;
3040  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3041  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3042 
3043  m_plotBoundaries.endPx = m_scrX;
3044  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3045  m_plotBoundaries.endPy = m_scrY;
3046  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3047 
3048  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3049  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3050 
3051  m_magnet.UpdateBox(m_PlotArea);
3052  }
3053 
3060  int GetScreenX(void) const
3061  {
3062  return m_scrX;
3063  }
3064 
3071  int GetScreenY(void) const
3072  {
3073  return m_scrY;
3074  }
3075 
3081  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3082  {
3083  m_AxisDataX.pos = posX;
3084  SetPosY(posYList);
3085  }
3086 
3090  inline double p2x(const wxCoord pixelCoordX) const
3091  {
3092  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3093  }
3094 
3098  inline double p2y(const wxCoord pixelCoordY, int yAxisID = 0)
3099  {
3100  assert(m_AxisDataYList.count(yAxisID) != 0);
3101  if (m_AxisDataYList.count(yAxisID) == 0)
3102  return 0.0;
3103  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3104  }
3105 
3109  inline wxCoord x2p(const double x) const
3110  {
3111  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3112  }
3113 
3117  inline wxCoord y2p(const double y, int yAxisID = 0)
3118  {
3119  assert(m_AxisDataYList.count(yAxisID) != 0);
3120  if (m_AxisDataYList.count(yAxisID) == 0)
3121  return 0;
3122  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3123  }
3124 
3127  void EnableDoubleBuffer(const bool enabled)
3128  {
3129  m_enableDoubleBuffer = enabled;
3130  }
3131 
3134  void EnableMousePanZoom(const bool enabled)
3135  {
3136  m_enableMouseNavigation = enabled;
3137  }
3138 
3144  void LockAspect(bool enable = true);
3145 
3150  inline bool IsAspectLocked() const
3151  {
3152  return m_lockaspect;
3153  }
3154 
3159  inline bool IsRepainting() const
3160  {
3161  return m_repainting;
3162  }
3163 
3168  void Fit();
3169 
3176  void Fit(const mpRange &rangeX, std::unordered_map<int, mpRange> rangeY, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3177 
3181  void FitX(void);
3182 
3187  void FitY(int yAxisID);
3188 
3193  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
3194 
3199  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
3200 
3202  void ZoomInX();
3203 
3205  void ZoomOutX();
3206 
3209  void ZoomInY(std::optional<int> yAxisID = std::nullopt);
3210 
3213  void ZoomOutY(std::optional<int> yAxisID = std::nullopt);
3214 
3216  void ZoomRect(wxPoint p0, wxPoint p1);
3217 
3219  void UpdateAll();
3220 
3221  // Added methods by Davide Rondini
3222 
3226  unsigned int CountLayers();
3227 
3230  unsigned int CountAllLayers()
3231  {
3232  return (unsigned int)m_layers.size();
3233  }
3234 
3238  unsigned int CountLayersType(mpLayerType type);
3239  unsigned int CountLayersFXYPlot();
3240 
3243  //void PrintGraph(mpPrintout *print);
3244 
3252  {
3253  // Change on X axis
3254  if (update & uXAxis)
3255  {
3256  m_AxisDataX.desired.Set(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale),
3257  m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3258  }
3259 
3260  // Change on Y axis
3261  if (update & uYAxis)
3262  {
3263  for (auto& [yID, yData] : m_AxisDataYList)
3264  {
3265  yData.desired.Set(yData.pos - ((m_margin.top + m_plotHeight) / yData.scale),
3266  yData.pos - (m_margin.top / yData.scale));
3267  }
3268  }
3269  }
3270 
3276  mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID = 0)
3277  {
3278  assert(m_AxisDataYList.count(yAxisID) != 0);
3279  if (desired)
3280  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
3281  else
3282  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
3283  }
3284 
3288  double GetDesiredXmin() const
3289  {
3290  return m_AxisDataX.desired.min;
3291  }
3292 
3297  double GetDesiredXmax() const
3298  {
3299  return m_AxisDataX.desired.max;
3300  }
3301 
3307  double GetDesiredYmin(int yAxisID)
3308  {
3309  assert(m_AxisDataYList.count(yAxisID) != 0);
3310  return m_AxisDataYList[yAxisID].desired.min;
3311  }
3312 
3318  double GetDesiredYmax(int yAxisID)
3319  {
3320  assert(m_AxisDataYList.count(yAxisID) != 0);
3321  return m_AxisDataYList[yAxisID].desired.max;
3322  }
3323 
3325  bool GetBoundingBox(mpRange *boundX, mpRange *boundY, int yAxisID)
3326  {
3327  if (m_AxisDataYList.count(yAxisID) == 0)
3328  return false;
3329  *boundX = m_AxisDataX.bound;
3330  *boundY = m_AxisDataYList[yAxisID].bound;
3331  return true;
3332  }
3333 
3334  // Is this point inside the bounding box
3335  bool PointIsInsideBound(double px, double py, int yAxisID)
3336  {
3337  if (m_AxisDataYList.count(yAxisID) == 0)
3338  return false;
3339 
3340  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
3341  }
3342 
3343  /* Update bounding box (X and Y axis) to include this point.
3344  * Expand the range to include the point.
3345  * @param px: point on x-axis
3346  * @param py: point on y-axis
3347  * @param yAxisID: the y-axis ID
3348  */
3349  void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
3350  {
3351  if (m_AxisDataYList.count(yAxisID) == 0)
3352  return ;
3353 
3354  m_AxisDataX.bound.Update(px);
3355  m_AxisDataYList[yAxisID].bound.Update(py);
3356  }
3357 
3358  /* Initialize bounding box with an initial point
3359  * @param px: point on x-axis
3360  * @param py: point on y-axis
3361  * @param yAxisID: the y-axis ID
3362  */
3363  void InitializeBoundingBox(double px, double py, int yAxisID)
3364  {
3365  if (m_AxisDataYList.count(yAxisID) == 0)
3366  return ;
3367 
3368  m_AxisDataX.bound.Set(px, px);
3369  m_AxisDataYList[yAxisID].bound.Set(py, py);
3370  }
3371 
3374  void SetMPScrollbars(bool status);
3375 
3378  bool GetMPScrollbars() const
3379  {
3380  return m_enableScrollBars;
3381  }
3382 
3388  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
3389 
3393  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3394 
3398  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3399 
3404  bool LoadFile(const wxString &filename);
3405 
3409 
3416  void SetMargins(int top, int right, int bottom, int left);
3417 
3420  {
3421  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3422  }
3423 
3425  void SetMarginTop(int top)
3426  {
3427  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3428  }
3429 
3433  int GetMarginTop(bool minusExtra = false) const
3434  {
3435  if (minusExtra)
3436  return m_margin.top - m_extraMargin;
3437  else
3438  return m_margin.top;
3439  }
3440 
3442  void SetMarginRight(int right)
3443  {
3444  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
3445  }
3446 
3450  int GetMarginRight(bool minusExtra = false) const
3451  {
3452  if (minusExtra)
3453  return m_margin.right - m_extraMargin;
3454  else
3455  return m_margin.right;
3456  }
3457 
3460  {
3461  return m_marginOuter.right;
3462  }
3463 
3465  void SetMarginBottom(int bottom)
3466  {
3467  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
3468  }
3469 
3473  int GetMarginBottom(bool minusExtra = false) const
3474  {
3475  if (minusExtra)
3476  return m_margin.bottom - m_extraMargin;
3477  else
3478  return m_margin.bottom;
3479  }
3480 
3482  void SetMarginLeft(int left)
3483  {
3484  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
3485  }
3486 
3490  int GetMarginLeft(bool minusExtra = false) const
3491  {
3492  if (minusExtra)
3493  return m_margin.left - m_extraMargin;
3494  else
3495  return m_margin.left;
3496  }
3497 
3499  void SetExtraMargin(int extra)
3500  {
3501  m_extraMargin = extra;
3502  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3503  }
3504 
3506  int GetExtraMargin() const
3507  {
3508  return m_extraMargin;
3509  }
3510 
3513  {
3514  return m_marginOuter.left;
3515  }
3516 
3518  int GetPlotWidth() const
3519  {
3520  return m_plotWidth;
3521  }
3522 
3524  int GetPlotHeight() const
3525  {
3526  return m_plotHeight;
3527  }
3528 
3533  mpRect GetPlotBoundaries(bool with_margin) const
3534  {
3535  mpRect bond;
3536  if (with_margin)
3537  bond = m_plotBoundariesMargin;
3538  else
3539  bond = m_plotBoundaries;
3540  bond.startPx -= m_extraMargin;
3541  bond.endPx += m_extraMargin;
3542  bond.startPy -= m_extraMargin;
3543  bond.endPy += m_extraMargin;
3544  return bond;
3545  }
3546 
3550  int GetLeftYAxesWidth(std::optional<int> yAxisID = std::nullopt);
3551 
3555  int GetRightYAxesWidth(std::optional<int> yAxisID = std::nullopt);
3556 
3558  void SetDrawBox(bool drawbox)
3559  {
3560  m_drawBox = drawbox;
3561  }
3562 
3564  bool GetDrawBox() const
3565  {
3566  return m_drawBox;
3567  }
3568 
3572  std::optional<int> IsInsideYAxis(const wxPoint &point);
3573 
3577  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
3578 
3582  void SetLayerVisible(const wxString &name, bool viewable);
3583 
3587  bool IsLayerVisible(const wxString &name);
3588 
3592  bool IsLayerVisible(const unsigned int position);
3593 
3597  void SetLayerVisible(const unsigned int position, bool viewable);
3598 
3603  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
3604 
3607  const wxColour& GetAxesColour() const
3608  {
3609  return m_axColour;
3610  }
3611 
3612  const wxColour& GetbgColour() const
3613  {
3614  return m_bgColour;
3615  }
3616 
3617  void SetbgColour(const wxColour &colour)
3618  {
3619  m_bgColour = colour;
3620  }
3621 
3626  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
3627  {
3628  m_OnDeleteLayer = event;
3629  }
3630 
3633  {
3634  m_OnDeleteLayer = NULL;
3635  }
3636 
3641  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
3642  {
3643  m_OnUserMouseAction = userMouseEventHandler;
3644  }
3645 
3648  {
3649  m_OnUserMouseAction = NULL;
3650  }
3651 
3657  bool IsLogXaxis()
3658  {
3659  if (m_AxisDataX.axis)
3660  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
3661  else
3662  return false;
3663  }
3664 
3668  bool IsLogYaxis(int yAxisID)
3669  {
3670  assert(m_AxisDataYList.count(yAxisID) != 0);
3671  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
3672  if (yAxis)
3673  return yAxis->IsLogAxis();
3674  else
3675  return false;
3676  }
3677 
3678  void SetLogXaxis(bool log)
3679  {
3680  if (m_AxisDataX.axis)
3681  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
3682  }
3683 
3687  void SetLogYaxis(int yAxisID, bool log)
3688  {
3689  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
3690  if (yAxis)
3691  yAxis->SetLogAxis(log);
3692  }
3693 
3699  bool GetMagnetize() const
3700  {
3701  return m_magnetize;
3702  }
3703 
3704  void SetMagnetize(bool mag)
3705  {
3706  m_magnetize = mag;
3707  }
3708 
3713  void SetMouseLeftDownAction(mpMouseButtonAction action)
3714  {
3715  m_mouseLeftDownAction = action;
3716  }
3717 
3722  mpMouseButtonAction GetMouseLeftDownAction()
3723  {
3724  return m_mouseLeftDownAction;
3725  }
3726 
3727 #ifdef ENABLE_MP_CONFIG
3728  void RefreshConfigWindow();
3733  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
3734 #endif // ENABLE_MP_CONFIG
3735 
3736  protected:
3737  virtual void OnPaint(wxPaintEvent &event);
3738  virtual void OnSize(wxSizeEvent &event);
3739  virtual void OnShowPopupMenu(wxMouseEvent &event);
3740  virtual void OnCenter(wxCommandEvent &event);
3741  virtual void OnFit(wxCommandEvent &event);
3742  virtual void OnToggleGrids(wxCommandEvent &event);
3743  virtual void OnToggleCoords(wxCommandEvent &event);
3744  virtual void OnScreenShot(wxCommandEvent &event);
3745  virtual void OnFullScreen(wxCommandEvent &event);
3746 #ifdef ENABLE_MP_CONFIG
3747  virtual void OnConfiguration(wxCommandEvent &event);
3748 #endif // ENABLE_MP_CONFIG
3749  virtual void OnLoadFile(wxCommandEvent &event);
3750  virtual void OnZoomIn(wxCommandEvent &event);
3751  virtual void OnZoomOut(wxCommandEvent &event);
3752  virtual void OnLockAspect(wxCommandEvent &event);
3753  virtual void OnMouseHelp(wxCommandEvent &event);
3754  virtual void OnMouseLeftDown(wxMouseEvent &event);
3755  virtual void OnMouseRightDown(wxMouseEvent &event);
3756  virtual void OnMouseMove(wxMouseEvent &event);
3757  virtual void OnMouseLeftRelease(wxMouseEvent &event);
3758  virtual void OnMouseWheel(wxMouseEvent &event);
3759  virtual void OnMouseLeave(wxMouseEvent &event);
3760  bool CheckUserMouseAction(wxMouseEvent &event);
3761  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
3762  virtual void OnScrollPageUp(wxScrollWinEvent &event);
3763  virtual void OnScrollPageDown(wxScrollWinEvent &event);
3764  virtual void OnScrollLineUp(wxScrollWinEvent &event);
3765  virtual void OnScrollLineDown(wxScrollWinEvent &event);
3766  virtual void OnScrollTop(wxScrollWinEvent &event);
3767  virtual void OnScrollBottom(wxScrollWinEvent &event);
3768 
3769  void DoScrollCalc(const int position, const int orientation);
3770 
3775  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = ZOOM_AROUND_CENTER);
3776 
3783  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = ZOOM_AROUND_CENTER, std::optional<int> = std::nullopt);
3784 
3789  void SetScaleXAndCenter(double scaleX);
3790 
3796  void SetScaleYAndCenter(double scaleY, int yAxisID);
3797 
3798  void Zoom(bool zoomIn, const wxPoint &centerPoint);
3799 
3802  virtual bool UpdateBBox();
3803 
3804  void InitParameters();
3805 
3806  wxTopLevelWindow* m_parent;
3807  bool m_fullscreen;
3808 
3809  mpLayerList m_layers;
3811  mpAxisList m_AxisDataYList;
3812 
3813  wxMenu m_popmenu;
3815  wxColour m_bgColour;
3816  wxColour m_fgColour;
3817  wxColour m_axColour;
3818  bool m_drawBox;
3819 
3820  int m_scrX;
3821  int m_scrY;
3824 
3828  wxCoord m_plotWidth;
3829  wxCoord m_plotHeight;
3830 
3833  wxRect m_PlotArea;
3834 
3835  bool m_repainting;
3836  int m_last_lx, m_last_ly;
3837  wxBitmap* m_buff_bmp;
3840  mpMouseButtonAction m_mouseLeftDownAction;
3841  bool m_mouseMovedAfterRightClick;
3842  wxPoint m_mouseRClick;
3843  wxPoint m_mouseLClick;
3844  double m_mouseScaleX;
3845  std::unordered_map<int, double> m_mouseScaleYList;
3846  std::optional<int> m_mouseYAxisID;
3847  bool m_enableScrollBars;
3848  int m_scrollX, m_scrollY;
3852  bool m_InInfoLegend;
3853 
3854  wxBitmap* m_zoom_bmp;
3855  wxRect m_zoom_dim;
3856  wxRect m_zoom_oldDim;
3857 
3860 
3861  wxBitmap* m_Screenshot_bmp;
3862 
3863 #ifdef ENABLE_MP_CONFIG
3864  MathPlotConfigDialog* m_configWindow = NULL;
3865 #endif // ENABLE_MP_CONFIG
3866 
3867  mpOnDeleteLayer m_OnDeleteLayer = NULL;
3868  mpOnUserMouseAction m_OnUserMouseAction = NULL;
3869 
3873  virtual void DesiredBoundsHaveChanged() {};
3874 
3875  private:
3876  void FillI18NString();
3877 
3879  void CheckAndReportDesiredBoundsChanges();
3880 
3881 
3886  unsigned int GetNewAxisDataID(void)
3887  {
3888  int newID = 0;
3889  for (auto& [yID, yData] : m_AxisDataYList)
3890  {
3891  if(yData.axis)
3892  {
3893  // This ID is used by an axis. Make sure the new ID is larger
3894  newID = std::max(newID, yID + 1);
3895  }
3896  }
3897  return newID;
3898  }
3899 
3900  wxDECLARE_DYNAMIC_CLASS(mpWindow);
3901  wxDECLARE_EVENT_TABLE();
3902 
3903  // To have direct access to m_Screenshot_dc
3904  friend mpPrintout;
3905 };
3906 
3907 //-----------------------------------------------------------------------------
3908 // mpText - provided by Val Greene
3909 //-----------------------------------------------------------------------------
3910 
3918 class WXDLLIMPEXP_MATHPLOT mpText: public mpLayer
3919 {
3920  public:
3923  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
3924  {
3925  m_subtype = mptText;
3926  SetName(name);
3927  m_offsetx = 5;
3928  m_offsety = 50;
3929  m_location = mpMarginNone;
3930  m_ZIndex = mpZIndex_TEXT;
3931  }
3932 
3936  mpText(const wxString &name, int offsetx, int offsety);
3937 
3941  mpText(const wxString &name, mpLocation marginLocation);
3942 
3945  virtual bool HasBBox()
3946  {
3947  return false;
3948  }
3949 
3952  void SetLocation(mpLocation location)
3953  {
3954  m_location = location;
3955  }
3956 
3959  mpLocation GetLocation() const
3960  {
3961  return m_location;
3962  }
3963 
3966  void SetOffset(int offX, int offY)
3967  {
3968  m_offsetx = offX;
3969  m_offsety = offY;
3970  }
3971 
3973  void GetOffset(int *offX, int *offY) const
3974  {
3975  *offX = m_offsetx;
3976  *offY = m_offsety;
3977  }
3978 
3979  protected:
3982  mpLocation m_location;
3983 
3986  virtual void DoPlot(wxDC &dc, mpWindow &w);
3987 
3988  wxDECLARE_DYNAMIC_CLASS(mpText);
3989 };
3990 
3994 class WXDLLIMPEXP_MATHPLOT mpTitle: public mpText
3995 {
3996  public:
3999  mpTitle();
4000 
4003  mpTitle(const wxString &name) :
4004  mpText(name, mpMarginTopCenter)
4005  {
4006  m_subtype = mptTitle;
4007  SetPen(*wxWHITE_PEN);
4008  SetBrush(*wxWHITE_BRUSH);
4009  }
4010 
4011  protected:
4012 
4013  wxDECLARE_DYNAMIC_CLASS(mpTitle);
4014 };
4015 
4016 //-----------------------------------------------------------------------------
4017 // mpPrintout - provided by Davide Rondini
4018 //-----------------------------------------------------------------------------
4019 
4024 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4025 {
4026  public:
4027  mpPrintout()
4028  {
4029  plotWindow = NULL;
4030  drawn = false;
4031  stretch_factor = 2;
4032  }
4033 
4034  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4035  virtual ~mpPrintout()
4036  {
4037  ;
4038  }
4039 
4040  void SetDrawState(bool drawState)
4041  {
4042  drawn = drawState;
4043  }
4044 
4045  bool OnPrintPage(int page);
4046  bool HasPage(int page);
4047 
4050  void SetFactor(int factor)
4051  {
4052  stretch_factor = factor;
4053  }
4054 
4055  private:
4056  bool drawn;
4057  mpWindow* plotWindow;
4058  int stretch_factor; // To reduce the size of plot
4059 
4060  protected:
4061 
4062  wxDECLARE_DYNAMIC_CLASS(mpPrintout);
4063 };
4064 
4065 //-----------------------------------------------------------------------------
4066 // mpMovableObject - provided by Jose Luis Blanco
4067 //-----------------------------------------------------------------------------
4075 class WXDLLIMPEXP_MATHPLOT mpMovableObject: public mpFunction
4076 {
4077  public:
4081  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
4082  {
4083  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
4084  m_subtype = mpfMovable;
4085  m_bbox_min_x = m_bbox_max_x = 0;
4086  m_bbox_min_y = m_bbox_max_y = 0;
4087  }
4088 
4089  virtual ~mpMovableObject() {}
4090 
4093  void GetCoordinateBase(double &x, double &y, double &phi) const
4094  {
4095  x = m_reference_x;
4096  y = m_reference_y;
4097  phi = m_reference_phi;
4098  }
4099 
4102  void SetCoordinateBase(double x, double y, double phi = 0)
4103  {
4104  m_reference_x = x;
4105  m_reference_y = y;
4106  m_reference_phi = phi;
4107  m_flags = mpALIGN_NE;
4108  ShapeUpdated();
4109  }
4110 
4111  virtual bool HasBBox()
4112  {
4113  return m_trans_shape_xs.size() != 0;
4114  }
4115 
4118  virtual double GetMinX()
4119  {
4120  return m_bbox_min_x;
4121  }
4122 
4125  virtual double GetMaxX()
4126  {
4127  return m_bbox_max_x;
4128  }
4129 
4132  virtual double GetMinY()
4133  {
4134  return m_bbox_min_y;
4135  }
4136 
4139  virtual double GetMaxY()
4140  {
4141  return m_bbox_max_y;
4142  }
4143 
4144  protected:
4145 
4148  double m_reference_x, m_reference_y, m_reference_phi;
4149 
4150  virtual void DoPlot(wxDC &dc, mpWindow &w);
4151 
4154  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
4155 
4158  std::vector<double> m_shape_xs, m_shape_ys;
4159 
4163  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
4164 
4168  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
4169 
4173  void ShapeUpdated();
4174 
4175  wxDECLARE_DYNAMIC_CLASS(mpMovableObject);
4176 };
4177 
4178 //-----------------------------------------------------------------------------
4179 // mpCovarianceEllipse - provided by Jose Luis Blanco
4180 //-----------------------------------------------------------------------------
4192 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse: public mpMovableObject
4193 {
4194  public:
4198  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
4199  const wxString &layerName = _T("")) : mpMovableObject(),
4200  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
4201  {
4202  m_continuous = true;
4203  m_name = layerName;
4204  RecalculateShape();
4205  }
4206 
4207  virtual ~mpCovarianceEllipse()
4208  {
4209  ;
4210  }
4211 
4212  double GetQuantiles() const
4213  {
4214  return m_quantiles;
4215  }
4216 
4219  void SetQuantiles(double q)
4220  {
4221  m_quantiles = q;
4222  RecalculateShape();
4223  }
4224 
4225  void SetSegments(int segments)
4226  {
4227  m_segments = segments;
4228  }
4229 
4230  int GetSegments() const
4231  {
4232  return m_segments;
4233  }
4234 
4237  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
4238  {
4239  cov_00 = m_cov_00;
4240  cov_01 = m_cov_01;
4241  cov_11 = m_cov_11;
4242  }
4243 
4246  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
4247  {
4248  m_cov_00 = cov_00;
4249  m_cov_01 = cov_01;
4250  m_cov_11 = cov_11;
4251  RecalculateShape();
4252  }
4253 
4254  protected:
4257  double m_cov_00, m_cov_11, m_cov_01;
4258  double m_quantiles;
4259 
4263 
4266  void RecalculateShape();
4267 
4268  wxDECLARE_DYNAMIC_CLASS(mpCovarianceEllipse);
4269 };
4270 
4271 //-----------------------------------------------------------------------------
4272 // mpPolygon - provided by Jose Luis Blanco
4273 //-----------------------------------------------------------------------------
4278 class WXDLLIMPEXP_MATHPLOT mpPolygon: public mpMovableObject
4279 {
4280  public:
4283  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
4284  {
4285  m_continuous = true;
4286  m_name = layerName;
4287  }
4288 
4289  virtual ~mpPolygon()
4290  {
4291  ;
4292  }
4293 
4299  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
4300 
4301  protected:
4302 
4303  wxDECLARE_DYNAMIC_CLASS(mpPolygon);
4304 };
4305 
4306 //-----------------------------------------------------------------------------
4307 // mpBitmapLayer - provided by Jose Luis Blanco
4308 //-----------------------------------------------------------------------------
4313 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer: public mpLayer
4314 {
4315  public:
4319  {
4320  m_min_x = m_max_x = 0;
4321  m_min_y = m_max_y = 0;
4322  m_validImg = false;
4323  m_bitmapChanged = false;
4324  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
4325  }
4326 
4327  virtual ~mpBitmapLayer()
4328  {
4329  ;
4330  }
4331 
4334  void GetBitmapCopy(wxImage &outBmp) const;
4335 
4343  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
4344 
4347  virtual double GetMinX()
4348  {
4349  return m_min_x;
4350  }
4351 
4354  virtual double GetMaxX()
4355  {
4356  return m_max_x;
4357  }
4358 
4361  virtual double GetMinY()
4362  {
4363  return m_min_y;
4364  }
4365 
4368  virtual double GetMaxY()
4369  {
4370  return m_max_y;
4371  }
4372 
4373  protected:
4374 
4377  wxImage m_bitmap;
4378  wxBitmap m_scaledBitmap;
4379  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
4380  bool m_validImg;
4381  bool m_bitmapChanged;
4382 
4385  double m_min_x, m_max_x, m_min_y, m_max_y;
4386 
4387  virtual void DoPlot(wxDC &dc, mpWindow &w);
4388 
4389  wxDECLARE_DYNAMIC_CLASS(mpBitmapLayer);
4390 };
4391 
4392 // utility class
4393 
4394 // Enumeration of classic colour
4395 typedef enum __mp_Colour
4396 {
4397  mpBlue,
4398  mpRed,
4399  mpGreen,
4400  mpPurple,
4401  mpYellow,
4402  mpFuchsia,
4403  mpLime,
4404  mpAqua,
4405  mpOlive
4406 } mpColour;
4407 
4412 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
4413 {
4414  public:
4415  wxIndexColour(unsigned int id)
4416  {
4417  switch (id)
4418  {
4419  case 0:
4420  this->Set(0, 0, 255);
4421  break; // Blue
4422  case 1:
4423  this->Set(255, 0, 0);
4424  break; // Red
4425  case 2:
4426  this->Set(0, 128, 0);
4427  break; // Green
4428  case 3:
4429  this->Set(128, 0, 128);
4430  break; // Purple
4431  case 4:
4432  this->Set(255, 255, 0);
4433  break; // Yellow
4434  case 5:
4435  this->Set(255, 0, 255);
4436  break; // Fuchsia
4437  case 6:
4438  this->Set(0, 255, 0);
4439  break; // Lime
4440  case 7:
4441  this->Set(0, 255, 255);
4442  break; // Aqua/Cyan
4443  case 8:
4444  this->Set(128, 128, 0);
4445  break; // Olive
4446  default:
4447  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
4448  (ChannelType)((rand() * 255) / RAND_MAX));
4449  }
4450  }
4451 };
4452 
4455 // ---------------------------------------------------------------------
4456 #ifdef ENABLE_MP_NAMESPACE
4457  }// namespace MathPlot
4458  // No, iff build enables namespace, its up to app to use it appropriately: using namespace MathPlot;
4459 #endif // ENABLE_MP_NAMESPACE
4460 
4461 #endif // MATHPLOT_H_INCLUDED
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:3981
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2295
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer Use like this : your_plot->SetOnDeleteLayer([this](void *S...
Definition: mathplot.h:2624
bool IsHorizontal(void) const
Get if is horizontal line.
Definition: mathplot.h:1507
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:513
int GetAxisID(void)
Return the ID of the Axis.
Definition: mathplot.h:2228
void SetValue(const double value)
Set x or y.
Definition: mathplot.h:1500
mpInfoLegend * m_InfoLegend
pointer to the optional info legend layer
Definition: mathplot.h:3851
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:560
double m_min_x
The shape of the bitmap:
Definition: mathplot.h:4385
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:3826
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:2404
void Set(double _min, double _max)
Set min, max function.
Definition: mathplot.h:235
void EnableDoubleBuffer(const bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled).
Definition: mathplot.h:3127
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:914
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:3668
Bitmap type layer.
Definition: mathplot.h:683
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1035
Plot type layer.
Definition: mathplot.h:668
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:3060
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4368
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:1226
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:3632
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1551
void SetYAxisID(unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1460
std::unordered_map< int, mpRange > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:2953
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:4278
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:2855
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:792
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:176
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:1802
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:3822
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:559
__mp_Layer_Type
Definition: mathplot.h:664
Show/Hide grids.
Definition: mathplot.h:501
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:4313
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:2395
bool m_magnetize
For mouse magnetization.
Definition: mathplot.h:3858
mpLabelType
Definition: mathplot.h:637
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2167
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:3842
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:2151
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:4283
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2265
std::unordered_map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:2604
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:3117
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:666
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:699
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1034
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1027
mpRange bound
Range min and max.
Definition: mathplot.h:2591
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1484
Lock x/y scaling aspect.
Definition: mathplot.h:500
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:1300
Info box type layer.
Definition: mathplot.h:688
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:3980
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set axis label view mode.
Definition: mathplot.h:2287
Abstract class providing a line.
Definition: mathplot.h:1478
Abstract class providing an vertical line.
Definition: mathplot.h:1543
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2251
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2131
mpRange lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:2593
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:2708
double GetMaxAbs(void) const
Returns max absolute value of the range.
Definition: mathplot.h:321
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:2396
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3010
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:3098
void SetExtraMargin(int extra)
Set the extra margin.
Definition: mathplot.h:3499
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1174
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:4102
double Length(void) const
Length of the range.
Definition: mathplot.h:309
Chart type layer (bar chart)
Definition: mathplot.h:673
double GetPosY(int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3001
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:891
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3150
int m_winY
Holds the mpWindow size. Used to rescale position when window is resized.
Definition: mathplot.h:1176
std::optional< int > m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:3846
~mpBarChart()
Destructor.
Definition: mathplot.h:2061
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:3090
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1042
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:3843
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:3873
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:899
int m_flags
Holds label alignment. Default : mpALIGN_NE.
Definition: mathplot.h:1039
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:3945
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:776
wxPoint GetPosition() const
Returns the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1138
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1255
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:945
~mpPieChart()
Destructor.
Definition: mathplot.h:2122
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1468
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:3518
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1029
Just the end of ZOrder.
Definition: mathplot.h:690
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4132
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:681
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:3442
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:3408
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1388
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:3512
void SetMouseLeftDownAction(mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:3713
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:3813
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:3844
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1631
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:1687
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:3817
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:1037
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:3831
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:4093
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:2632
void ToLog(void)
Convert to log range.
Definition: mathplot.h:327
mpRange GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:2912
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:1282
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:2451
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1038
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:3952
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2027
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3134
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:3818
Plot (function) type layer.
Definition: mathplot.h:686
void UpdateDesiredBoundingBox(mpAxisUpdate update)
Draws the mpWindow on a page for printing.
Definition: mathplot.h:3251
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2311
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1041
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1424
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:728
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1030
bool GetCanDelete(void) const
Get CanDelete for plot.
Definition: mathplot.h:1014
Axis type layer.
Definition: mathplot.h:684
Implementing MathPlotConfigDialogBuilder.
Definition: MathPlotConfig.h:75
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:2175
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:2399
Axis type layer.
Definition: mathplot.h:667
void SetCanDelete(bool canDelete)
Set CanDelete for plot.
Definition: mathplot.h:1007
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4347
bool GetMagnetize() const
Magnetize the position of the mouse in the plot ie draw a vertical and horizontal line...
Definition: mathplot.h:3699
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:3849
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:2401
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:1212
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:2258
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:3607
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:924
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:2575
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1940
mpRange GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:2906
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:3923
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:4377
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:3641
each visible plot is described on its own line, one above the other
Definition: mathplot.h:567
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:2966
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1021
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:640
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:3524
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:1241
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:587
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1876
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4354
Show/Hide info coord.
Definition: mathplot.h:502
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:938
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:4246
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4024
int m_last_ly
For double buffering.
Definition: mathplot.h:3836
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:358
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:3859
wxSize GetSize() const
Returns the size of the box (in pixels)
Definition: mathplot.h:1145
Chart type layer.
Definition: mathplot.h:687
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:2398
Set label for axis in scientific notation.
Definition: mathplot.h:644
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:297
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1172
Copy a screen shot to the clipboard.
Definition: mathplot.h:503
Fit view to match bounding box of all layers.
Definition: mathplot.h:496
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:3959
bool PointIsInside(double px, double py) const
Is point inside this bounding box?
Definition: mathplot.h:465
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:509
wxBitmap * m_buff_bmp
For double buffering.
Definition: mathplot.h:3837
Center view on click position.
Definition: mathplot.h:499
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1470
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:1812
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:528
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:4075
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:596
mpRange desired
Desired range min and max.
Definition: mathplot.h:2592
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:3811
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:1711
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:4158
virtual bool IsLogAxis()
Logarithmic axis.
Definition: mathplot.h:2381
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1431
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:2459
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:4412
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1471
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1396
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:3827
Layer for bar chart.
Definition: mathplot.h:2054
mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:3276
double m_max
Min and max axis values when autosize is false.
Definition: mathplot.h:2400
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1032
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:1261
abstract Layer for chart (bar and pie).
Definition: mathplot.h:1996
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:561
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:457
bool GetBoundingBox(mpRange *boundX, mpRange *boundY, int yAxisID)
Return the bounding box coordinates for the Y axis of ID yAxisID.
Definition: mathplot.h:3325
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:907
const wxRect & GetRectangle() const
Returns the current rectangle coordinates.
Definition: mathplot.h:1152
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:4168
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:3288
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:642
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:548
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1467
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:3307
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:3465
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:1832
int m_symbolSize2
Size of the symbol div 2.
Definition: mathplot.h:1469
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4361
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2327
void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2272
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1903
int GetMarginRight(bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:3450
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1529
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:1851
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:1860
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:3318
Text box type layer.
Definition: mathplot.h:670
mpMouseButtonAction GetMouseLeftDownAction()
Returns the type of action for the left mouse button.
Definition: mathplot.h:3722
double pos
Position.
Definition: mathplot.h:2590
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:3419
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:538
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:3833
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1087
Load a file.
Definition: mathplot.h:507
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:740
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:3973
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:3828
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:1114
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:749
Line (horizontal or vertical) type layer.
Definition: mathplot.h:685
wxBitmap * m_zoom_bmp
For zoom selection.
Definition: mathplot.h:3854
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1196
std::unordered_map< int, mpRange > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:2939
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:3378
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:3821
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:3109
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1403
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:3810
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1296
wxRect m_oldDim
Keep the old values of m_dim.
Definition: mathplot.h:1173
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:651
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:3815
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:3657
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3036
int GetBarWidth(void) const
return the width of the bar
Definition: mathplot.h:1737
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:3626
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1234
void SetAxisID(unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2237
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1925
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:3558
bool m_enableDoubleBuffer
For double buffering. Default enabled.
Definition: mathplot.h:3838
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1378
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1578
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2138
mpTitle(const wxString &name)
Definition: mathplot.h:4003
Plot layer implementing a simple title.
Definition: mathplot.h:3994
Set no label for axis (useful for bar)
Definition: mathplot.h:657
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:2501
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:4111
bool ViewAsBar(void) const
return true if XY series is plotted with bar
Definition: mathplot.h:1745
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1177
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:972
double GetCenter(void) const
Center of the range.
Definition: mathplot.h:315
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:3533
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:2977
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1000
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1036
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:4163
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:3506
void Assign(double value1, double value2)
Assign values to min and max.
Definition: mathplot.h:242
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2319
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:1703
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:1466
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:3647
std::vector< double > m_xs
The internal copy of the set of data to draw.
Definition: mathplot.h:1868
mpRange GetBoundY(int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:2920
~mpChart()
Destructor.
Definition: mathplot.h:2003
Abstract class providing an horizontal line.
Definition: mathplot.h:1521
Zoom into view at clickposition / window center.
Definition: mathplot.h:497
int GetMarginLeft(bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:3490
mpRange(double value1, double value2)
Create range with the 2 values.
Definition: mathplot.h:220
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:3814
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:4262
double scale
Scale.
Definition: mathplot.h:2589
void Rewind()
Rewind value enumeration with mpFXY::GetNextXY.
Definition: mathplot.h:1885
Zoom out.
Definition: mathplot.h:498
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2208
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:867
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:2638
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:2508
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition: mathplot.h:288
int m_reserveXY
Memory reserved for m_xs and m_ys.
Definition: mathplot.h:1872
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:565
mpRange GetDesiredBoundY(int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:2929
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:278
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:4192
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2280
int GetMarginTop(bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:3433
double m_minX
Loaded at SetData.
Definition: mathplot.h:1880
mpInfoCoords * m_InfoCoords
pointer to the optional info coords layer
Definition: mathplot.h:3850
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:3297
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:649
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:2586
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:557
Layer for pie chart.
Definition: mathplot.h:2115
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:883
Set label user defined.
Definition: mathplot.h:655
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:4198
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:875
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:3839
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1031
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:2986
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:647
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:653
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:4237
mpRange GetScale() const
Return m_min and m_max scale as a mpRange.
Definition: mathplot.h:2373
Bitmap type layer.
Definition: mathplot.h:671
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1159
bool IsVisible() const
Checks whether the layer is visible or not.
Definition: mathplot.h:965
mpRange()
Default constructor.
Definition: mathplot.h:213
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:2244
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:757
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:986
bool IsSet()
Check if this mpRange has been assigned any values.
Definition: mathplot.h:257
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1439
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2402
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:4080
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:669
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:3081
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3071
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3018
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:1564
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:800
Plot layer implementing a text string.
Definition: mathplot.h:3918
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:767
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:3829
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4139
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:3564
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:952
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1033
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:3459
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:784
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1175
int GetMarginBottom(bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:3473
Shows information about the mouse commands.
Definition: mathplot.h:508
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:3687
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:3425
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:2869
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:3816
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:3861
legend components follow each other horizontally on a single line
Definition: mathplot.h:568
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1313
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:4219
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1452
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:3823
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:207
void Update(double value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:266
bool PointIsInside(double point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:334
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:4148
double GetScaleY(int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:2894
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:2159
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1410
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4118
Plot layer, abstract base class.
Definition: mathplot.h:716
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1040
double GetValue() const
Set x or y.
Definition: mathplot.h:1492
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:3966
void SetFactor(int factor)
Definition: mathplot.h:4050
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:851
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1028
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:2403
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:3820
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:3845
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:931
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:859
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1058
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:4257
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:3482
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:3809
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:2397
std::map< int, mpAxisData > GetSortedAxisDataYList(void) const
Get a sorted version of the Y-axis data map.
Definition: mathplot.h:3026
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:3825
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1965
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1166
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:3840
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:3832
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:979
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2220
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4125
bool IsRepainting() const
Checks if we are repainting.
Definition: mathplot.h:3159
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:3230
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2303
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1417
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:4318
void SetScaleY(const double scaleY, int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:2878
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:2612
Text box type layer.
Definition: mathplot.h:689
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:2724
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:993
Line (horizontal or vertical) type layer.
Definition: mathplot.h:672
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1918