wxMathPlot
mathplot.h
Go to the documentation of this file.
1 // Name: mathplot.h
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: 11/07/2026
10 // Copyright: (c) David Schalig, Davide Rondini
11 // Licence: wxWindows licence
13 
14 #ifndef MATHPLOT_H_INCLUDED
15 #define MATHPLOT_H_INCLUDED
16 
81 // mathplot_EXPORTS definition uses windows dll to export function.
82 // mathplot_EXPORTS will be defined by cmake
83 #ifdef mathplot_EXPORTS
84  #define WXDLLIMPEXP_MATHPLOT WXEXPORT
86  #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
88 #else // not making DLL
89  #define WXDLLIMPEXP_MATHPLOT
91  #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
93 #endif
94 
95 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
96  #pragma interface "mathplot.h"
97 #endif
98 
99 #include <cassert> // For assert debug message (assert is disabled if NDEBUG is defined)
100 #include <vector>
101 #include <map>
102 #include <unordered_map>
103 
104 #include <optional>
106 typedef std::optional<unsigned int> mpOptional_uint;
108 typedef std::optional<int> mpOptional_int;
109 
110 // #include <wx/wx.h>
111 #include <wx/defs.h>
112 #include <wx/menu.h>
113 #include <wx/scrolwin.h>
114 #include <wx/event.h>
115 #include <wx/dynarray.h>
116 #include <wx/pen.h>
117 #include <wx/dcmemory.h>
118 #include <wx/string.h>
119 #include <wx/print.h>
120 #include <wx/image.h>
121 #include <wx/intl.h>
122 
123 #include <cmath>
124 #include <deque>
125 #include <algorithm>
126 
127 #if defined(MP_USER_INCLUDE)
128  #define xstr(x) #x
130  #define str(x) xstr(x)
132  #define header MP_USER_INCLUDE.h
133  #include str(header)
134  #undef header
135 #endif
136 
137 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
138  #include "MathPlotConfig.h"
139 #endif // MP_ENABLE_CONFIG
140 
145 #if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
146  namespace MathPlot {
147 #endif // MP_ENABLE_NAMESPACE
148 
149 #ifdef MP_ENABLE_DEBUG
150  // For memory leak debug
151  #ifdef _WIN32
152  #ifdef _DEBUG
153  #include <crtdbg.h>
154  #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
155  #else
156  #define DEBUG_NEW new
157  #endif // _DEBUG
158  #endif // _WINDOWS
159 #endif // MP_ENABLE_DEBUG
160 
162 #define MP_X_BORDER_SEPARATION 40
163 #define MP_Y_BORDER_SEPARATION 60
165 
167 #define MP_X_LOCALTIME 0x10
168 #define MP_X_UTCTIME 0x20
170 #define MP_X_RAWTIME MP_X_UTCTIME
172 
174 #define MP_EPSILON 1e-30
175 #define MP_ISNOTNULL(x) (std::fpclassify(x) != FP_ZERO)
177 
179 #define MP_EXTRA_MARGIN 8
180 
182 #define MP_ZOOM_AROUND_CENTER -1
183 
184 //-----------------------------------------------------------------------------
185 // classes
186 //-----------------------------------------------------------------------------
187 
189 #define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class) wxDECLARE_DYNAMIC_CLASS(mp_class)
190 
220 
221 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
223 #endif // MP_ENABLE_CONFIG
224 
226 struct mpRect
227 {
228  union {
229  struct
230  {
231  wxCoord startPx;
232  wxCoord startPy;
233  wxCoord endPx;
234  wxCoord endPy;
235  };
236  struct
237  {
238  wxCoord left;
239  wxCoord top;
240  wxCoord right;
241  wxCoord bottom;
242  };
243  struct
244  {
245  wxCoord x1;
246  wxCoord y1;
247  wxCoord x2;
248  wxCoord y2;
249  };
250  wxCoord tab[4];
251  };
256  wxRect GetRect(void) const
257  {
258  return wxRect(startPx, startPy, endPx - startPx, endPy - startPy);
259  }
260 };
261 static_assert(sizeof(mpRect) == 4 * sizeof(wxCoord));
262 
268 template<typename T>
269 struct mpRange
270 {
271  T min = 0;
272  T max = 0;
273 
276  {
277  min = 0;
278  max = 0;
279  }
280 
282  mpRange(T value1, T value2)
283  {
284  if (value1 < value2)
285  {
286  min = value1;
287  max = value2;
288  }
289  else
290  {
291  min = value2;
292  max = value1;
293  }
294  }
295 
297  void Set(T value_)
298  {
299  min = value_;
300  max = value_;
301  }
302 
304  void Set(T min_, T max_)
305  {
306  min = min_;
307  max = max_;
308  }
309 
311  void SetMin(T min_)
312  {
313  min = min_;
314  if (max < min)
315  max = min;
316  }
317 
319  void SetMax(T max_)
320  {
321  max = max_;
322  if (min > max)
323  min = max;
324  }
325 
327  void Assign(T value1, T value2)
328  {
329  if (value1 < value2)
330  {
331  min = value1;
332  max = value2;
333  }
334  else
335  {
336  min = value2;
337  max = value1;
338  }
339  }
340 
342  bool IsSet() const
343  {
344  return ((min != 0) || (max != 0));
345  }
346 
351  void Update(T value)
352  {
353  if (value < min)
354  min = value;
355  else if (value > max)
356  max = value;
357  }
358 
362  void Update(T min_, T max_)
363  {
364  if (min_ < min)
365  min = min_;
366  if (max_ > max)
367  max = max_;
368  }
369 
372  void Update(mpRange range)
373  {
374  if (range.min < min)
375  min = range.min;
376  if (range.max > max)
377  max = range.max;
378  }
379 
381  void Check(void)
382  {
383  if (min == max)
384  {
385  if (max > 0)
386  min = 0;
387  else
388  max = 0;
389  }
390  }
391 
393  T Length(void) const
394  {
395  return max - min;
396  }
397 
399  T GetCenter(void) const
400  {
401  return (min + max) / 2;
402  }
403 
405  T GetMaxAbs(void) const
406  {
407  return std::max(fabs(min), fabs(max));
408  }
409 
411  void ToLog(void)
412  {
413  min = (min > 0) ? log10(min) : 0;
414  max = (max > 0) ? log10(max) : 0;
415  }
416 
418  bool PointIsInside(T point) const
419  {
420  return ((point >= min) && (point <= max));
421  }
422 
423  #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
424  bool operator==(const mpRange&) const = default;
425  #else
426  bool operator==(const mpRange &other) const
428  {
429  return (min == other.min) && (max == other.max);
430  }
432  bool operator!=(const mpRange& other) const
433  {
434  return !(*this == other);
435  }
436  #endif
437 };
438 
444 struct [[deprecated("Deprecated! No longer used as X and Y are now separated")]] mpFloatRect
445 {
446  mpRange<double> x;
447  std::vector<mpRange<double>> y;
448 
455  mpFloatRect(mpWindow& w);
456 
458  mpFloatRect() = delete;
459 
466  bool PointIsInside(const double px, const double py, const size_t yAxisID = 0) const {
467  if (yAxisID < y.size())
468  {
469  if( (px < x.min || px > x.max) ||
470  (py < y[yAxisID].min || py > y[yAxisID].max))
471  {
472  return false;
473  }
474  }
475  else
476  {
477  return false;
478  }
479 
480  return true;
481  }
482 
489  void UpdateBoundingBoxToInclude(const double px, const double py, const size_t yAxisID = 0) {
490  assert(yAxisID < y.size());
491  if (yAxisID < y.size())
492  {
493  if (px < x.min ) x.min = px;
494  else if (px > x.max ) x.max = px;
495  if (py < y[yAxisID].min ) y[yAxisID].min = py;
496  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
497  }
498  }
499 
506  void InitializeBoundingBox(const double px, const double py, const size_t yAxisID = 0) {
507  assert(yAxisID < y.size());
508  if (yAxisID < y.size())
509  {
510  x.min = x.max = px;
511  y[yAxisID].min = y[yAxisID].max = py;
512  }
513  }
515  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
517 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
518  bool operator==(const mpFloatRect&) const = default;
519 #else
520  // We compare with an epsilon precision
521  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
522  bool operator==(const mpFloatRect& rect) const
523  {
524  auto Same = [](const double a, const double b) {
525  return std::fabs(a - b) < MP_EPSILON;
526  };
527 
528  // Compare scalar members
529  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
530  {
531  return false;
532  }
533 
534  // Compare vector sizes
535  if (y.size() != rect.y.size())
536  {
537  return false;
538  }
539 
540  // Compare each Y boundary
541  for (size_t i = 0; i < y.size(); ++i)
542  {
543  if (!Same(y[i].min, rect.y[i].min) ||
544  !Same(y[i].max, rect.y[i].max) )
545  {
546  return false;
547  }
548  }
549 
550  return true;
551  }
552 #endif
553 };
554 
561 {
564 
570  mpFloatRectSimple(const mpRange<double> x_, const mpRange<double> y_) : x(x_), y(y_) { };
571 
577  bool PointIsInside(const double px, const double py) const {
578  return x.PointIsInside(px) && y.PointIsInside(py);
579  }
580 
586  void UpdateBoundingBoxToInclude(const double px, const double py)
587  {
588  x.Update(px);
589  y.Update(py);
590  }
591 
596  void InitializeBoundingBox(const double px, const double py)
597  {
598  x.Set(px, px);
599  y.Set(py, py);
600  }
601 };
602 
605 struct mpPlotHit
606 {
607  wxColour colour;
608  wxRealPoint coords;
609 };
610 
614 enum
615 {
616  mpID_FIT = 2000,
624 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
625  mpID_CONFIG,
626 #endif // MP_ENABLE_CONFIG
630 };
631 
633 typedef enum __mp_Location_Type
634 {
645 } mpLocation;
646 
648 typedef enum __XAxis_Align_Type
649 {
655 } mpXAxis_Align;
656 
658 typedef enum __YAxis_Align_Type
659 {
665 } mpYAxis_Align;
666 
669 {
674 } mpPlot_Align;
675 
677 typedef enum __mp_Style_Type
678 {
682 } mpLegendStyle;
683 
686 {
690 
692 typedef enum __Symbol_Type
693 {
701 } mpSymbol;
702 
703 //-----------------------------------------------------------------------------
704 // mpLayer sub_type values
705 //-----------------------------------------------------------------------------
706 
708 typedef enum __Info_Type
709 {
714 } mpInfoType;
715 
717 typedef enum __Text_Type
718 {
722 } mpTextType;
723 
725 typedef enum __Function_Type
726 {
736 
738 typedef enum __Scale_Type
739 {
744 } mpScaleType;
745 
747 typedef enum __Chart_Type
748 {
753 } mpChartType;
754 
757 {
760 };
761 
764 {
784 };
785 
786 //-----------------------------------------------------------------------------
787 // mpLayer
788 //-----------------------------------------------------------------------------
789 
791 typedef enum __mp_Layer_Type
792 {
801 } mpLayerType;
802 
808 typedef enum __mp_Layer_ZOrder
809 {
818 } mpLayerZOrder;
819 
826 typedef enum __mp_Delete_Action
827 {
832 
843 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
844 {
845  public:
850  mpLayer(mpLayerType layerType);
851 
852  ~mpLayer() override
853  {
854  ;
855  }
856 
860  {
861  m_win = &w;
862  }
863 
871  virtual bool HasBBox()
872  {
873  return true;
874  }
875 
879  mpLayerType GetLayerType() const
880  {
881  return m_type;
882  }
883 
887  int GetLayerSubType() const
888  {
889  return m_subtype;
890  }
891 
897  virtual bool IsLayerType(const mpLayerType typeOfInterest, int *subtype)
898  {
899  *subtype = m_subtype;
900  return (m_type == typeOfInterest);
901  }
902 
906  virtual double GetMinX()
907  {
908  return -1.0;
909  }
910 
914  virtual double GetMaxX()
915  {
916  return 1.0;
917  }
918 
922  virtual double GetMinY()
923  {
924  return -1.0;
925  }
926 
930  virtual double GetMaxY()
931  {
932  return 1.0;
933  }
934 
976  void Plot(wxDC &dc, mpWindow &w);
977 
981  void SetName(const wxString &name)
982  {
983  m_name = name;
984  }
985 
989  const wxString& GetName() const
990  {
991  return m_name;
992  }
993 
997  void SetFont(const wxFont &font)
998  {
999  m_font = font;
1000  }
1001 
1005  const wxFont& GetFont() const
1006  {
1007  return m_font;
1008  }
1009 
1013  void SetFontColour(const wxColour &colour)
1014  {
1015  m_fontcolour = colour;
1016  }
1017 
1021  const wxColour& GetFontColour() const
1022  {
1023  return m_fontcolour;
1024  }
1025 
1029  void SetPen(const wxPen &pen)
1030  {
1031  m_pen = pen;
1032  }
1033 
1037  const wxPen& GetPen() const
1038  {
1039  return m_pen;
1040  }
1041 
1044  void SetBrush(const wxBrush &brush)
1045  {
1046  if (brush == wxNullBrush)
1047  m_brush = *wxTRANSPARENT_BRUSH;
1048  else
1049  m_brush = brush;
1050  }
1051 
1055  void SetBrush(const wxColour &colour, enum wxBrushStyle style = wxBRUSHSTYLE_SOLID)
1056  {
1057  m_brush.SetColour(colour);
1058  m_brush.SetStyle(style);
1059  }
1060 
1063  const wxBrush& GetBrush() const
1064  {
1065  return m_brush;
1066  }
1067 
1070  void SetShowName(const bool show)
1071  {
1072  m_showName = show;
1073  }
1074 
1077  bool GetShowName() const
1078  {
1079  return m_showName;
1080  }
1081 
1084  void SetDrawOutsideMargins(const bool drawModeOutside)
1085  {
1086  m_drawOutsideMargins = drawModeOutside;
1087  }
1088 
1092  {
1093  return m_drawOutsideMargins;
1094  }
1095 
1100  wxBitmap GetColourSquare(int side = 16);
1101 
1104  bool IsVisible() const
1105  {
1106  return m_visible;
1107  }
1108 
1111  virtual void SetVisible(const bool show)
1112  {
1113  m_visible = show;
1114  }
1115 
1118  bool IsTractable() const
1119  {
1120  return m_tractable;
1121  }
1122 
1125  virtual void SetTractable(const bool track)
1126  {
1127  m_tractable = track;
1128  }
1129 
1132  void SetAlign(const int align)
1133  {
1134  m_flags = align;
1135  }
1136 
1139  int GetAlign() const
1140  {
1141  return m_flags;
1142  }
1143 
1146  void SetCanDelete(const bool canDelete)
1147  {
1148  m_CanDelete = canDelete;
1149  }
1150 
1153  bool GetCanDelete(void) const
1154  {
1155  return m_CanDelete;
1156  }
1157 
1160  mpLayerZOrder GetZIndex(void) const
1161  {
1162  return m_ZIndex;
1163  }
1164 
1165  protected:
1166  const mpLayerType m_type;
1169  wxFont m_font;
1170  wxColour m_fontcolour;
1171  wxPen m_pen;
1172  wxBrush m_brush;
1173  wxString m_name;
1174  bool m_showName;
1176  bool m_visible;
1178  int m_flags;
1181  mpLayerZOrder m_ZIndex;
1182 
1185  void UpdateContext(wxDC &dc) const;
1186 
1191  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1192 
1197  virtual bool DoBeforePlot()
1198  {
1199  return true;
1200  }
1201 
1208  void CheckLog(double *x, double *y, int yAxisID);
1209 
1210  private:
1211  bool m_busy;
1212  mpLayer() = delete; // default ctor not implemented/permitted
1213 
1215 };
1216 
1217 //-----------------------------------------------------------------------------
1218 // mpInfoLayer
1219 //-----------------------------------------------------------------------------
1220 
1227 {
1228  public:
1230  mpInfoLayer();
1231 
1236  mpInfoLayer(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1237 
1239  ~mpInfoLayer() override;
1240 
1243  void SetVisible(bool show) override;
1244 
1249  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1250 
1253  bool HasBBox() override
1254  {
1255  return false;
1256  }
1257 
1260  [[deprecated("Use Show() instead")]]
1261  virtual void ErasePlot(wxDC&, mpWindow&) {};
1262 
1266  virtual bool Inside(const wxPoint &point);
1267 
1271  virtual void Move(wxPoint delta, mpWindow &w);
1272 
1274  virtual void UpdateReference();
1275 
1278  wxPoint GetPosition() const
1279  {
1280  return m_dim.GetPosition();
1281  }
1282 
1285  void SetInitialPosition(const wxPoint pos)
1286  {
1287  m_relX = pos.x / 100.0;
1288  m_relY = pos.y / 100.0;
1289  }
1290 
1293  wxSize GetSize() const
1294  {
1295  return m_dim.GetSize();
1296  }
1297 
1300  const wxRect& GetRectangle() const
1301  {
1302  return m_dim;
1303  }
1304 
1307  void SetLocation(const mpLocation location)
1308  {
1309  m_location = location;
1310  }
1311 
1314  mpLocation GetLocation() const
1315  {
1316  return m_location;
1317  }
1318 
1319  protected:
1320  wxRect m_dim;
1321  wxBitmap* m_info_bmp;
1322  wxPoint m_reference;
1323  double m_relX;
1324  double m_relY;
1325  mpLocation m_location;
1326 
1331  void DoPlot(wxDC &dc, mpWindow &w) override;
1332 
1335  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1336 
1337  private:
1338 
1340 };
1341 
1347 {
1348  public:
1350  mpInfoCoords();
1351 
1353  mpInfoCoords(mpLocation location);
1354 
1359  mpInfoCoords(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1360 
1362  ~mpInfoCoords() override
1363  {
1364  ;
1365  }
1366 
1369  {
1372  infoCoord_allSeries
1373  };
1374 
1378  void UpdateInfo(mpWindow &w, wxEvent &event) override;
1379 
1382  [[deprecated("Use Show() instead")]]
1383  void ErasePlot(wxDC&, mpWindow&) override {};
1384 
1387  void Show(const bool show)
1388  {
1389  m_show = show;
1390  }
1391 
1394  bool IsShown() const
1395  {
1396  return m_show;
1397  }
1398 
1403  bool ShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
1404  {
1405  return IsVisible() && (GetDrawOutsideMargins() || plotArea.Contains(mousePos));
1406  }
1407 
1411  void SetLabelMode(const mpLabelType mode, const unsigned int time_conv = MP_X_RAWTIME)
1412  {
1413  m_labelType = mode;
1414  m_timeConv = time_conv;
1415  }
1416 
1419  [[deprecated("Deprecated, use SetInfoCoordType instead")]]
1420  void SetSeriesCoord(const bool show)
1421  {
1422  m_infoCoordType = show ? infoCoord_closestSeries : infoCoord_axis;
1423  }
1424 
1429  {
1430  m_infoCoordType = type;
1431  }
1432 
1437  {
1438  return m_infoCoordType;
1439  }
1440 
1446  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1447 
1451  void DrawContent(wxDC &dc, mpWindow &w);
1452 
1453  protected:
1454  bool m_show;
1455  wxString m_content;
1457  unsigned int m_timeConv;
1458  wxCoord m_mouseX;
1459  wxCoord m_mouseY;
1461  std::vector<wxColor> m_seriesColors;
1462 
1467  void DoPlot(wxDC &dc, mpWindow &w) override;
1468 
1469  private:
1470 
1472 };
1473 
1479 {
1480  public:
1482  mpInfoLegend();
1483 
1489  mpInfoLegend(wxPoint pos, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginUser);
1490 
1492  ~mpInfoLegend() override {}
1493 
1496  void SetItemMode(const mpLegendStyle mode)
1497  {
1498  m_item_mode = mode;
1499  m_needs_update = true;
1500  }
1501 
1503  mpLegendStyle GetItemMode() const
1504  {
1505  return m_item_mode;
1506  }
1507 
1510  void SetItemDirection(const mpLegendDirection mode)
1511  {
1512  m_item_direction = mode;
1513  m_needs_update = true;
1514  }
1515 
1517  mpLegendDirection GetItemDirection() const
1518  {
1519  return m_item_direction;
1520  }
1521 
1524  {
1525  m_needs_update = true;
1526  }
1527 
1530  void ShowDraggedSeries(const bool active)
1531  {
1532  m_showDraggedSeries = active;
1533  }
1534 
1538  {
1539  return m_showDraggedSeries;
1540  }
1541 
1544  void EnableSeriesValues(const bool enable)
1545  {
1546  m_enableSeriesValues = enable;
1547  m_maxSeriesValueWidth = 0;
1548  }
1549 
1553  {
1554  return m_enableSeriesValues;
1555  }
1556 
1560  bool SeriesValuesShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
1561  {
1562  return m_enableSeriesValues && plotArea.Contains(mousePos);
1563  }
1564 
1567  void ShowSeriesValues(const bool show)
1568  {
1569  m_showSeriesValues = show;
1570  }
1571 
1574  bool IsSeriesValuesShown() const
1575  {
1576  return m_showSeriesValues && IsVisible();
1577  }
1578 
1581  void IndicateSeriesIntersection(const bool enable)
1582  {
1583  m_indicateSeriesIntersection = enable;
1584  }
1585 
1588  void SetVerticalCursorFollowMouse();
1589 
1592  void SetVerticalCursorFixed(double posX);
1593 
1596  {
1598  CursorMode_fixed
1599  };
1600 
1604  {
1605  return m_verticalCursorMode;
1606  }
1607 
1611  wxCoord GetVerticalCursorX() const;
1612 
1618  int GetLegendHitRegion(wxPoint mousePos);
1619 
1626  void DrawDraggedSeries(wxDC& dc, mpWindow &w) const;
1627 
1631  void DrawContent(wxDC &dc, mpWindow &w);
1632 
1635  static void RestoreAxisHighlighting(mpWindow &w);
1636 
1638  enum HitCode : int
1639  {
1640  HitNone = -1,
1641  HitHeader = -2
1642  };
1643 
1644  mpFunction* m_selectedSeries = nullptr;
1645  mpOptional_int m_lastHoveredAxisID = std::nullopt;
1646 
1647  protected:
1648  mpLegendStyle m_item_mode;
1649  mpLegendDirection m_item_direction;
1651  wxString m_headerString = wxString::FromUTF8("≡");
1652 
1657  void DoPlot(wxDC &dc, mpWindow &w) override;
1658 
1659  private:
1661  struct LegendDetail
1662  {
1663  unsigned int layerIdx;
1664  wxCoord legendEnd;
1665  };
1667  std::vector<LegendDetail> m_LegendDetailList;
1668  wxCoord m_headerEnd;
1669  bool m_needs_update;
1670  int m_maxSeriesValueWidth;
1671  bool m_enableSeriesValues;
1672  bool m_showSeriesValues;
1673  bool m_indicateSeriesIntersection;
1674  VerticalCursorMode m_verticalCursorMode;
1675  double m_verticalCursorPosX;
1676 
1687  void UpdateBitmap(wxDC &dc, mpWindow &w);
1688 
1697  int GetMaxLabelWidth(wxDC &dc, mpWindow &w) const;
1698 
1719  int DrawSeriesValue(wxDC& dc, mpWindow& w, mpFunction& function, int posX, int posY, int labelHeight, int labelWidth, int maxLabelWidth);
1720 
1721  private:
1723 };
1724 
1725 //-----------------------------------------------------------------------------
1726 // mpLayer implementations - functions
1727 //-----------------------------------------------------------------------------
1728 
1729 
1737 {
1738  public:
1744  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1745 
1749  void SetContinuity(const bool continuity)
1750  {
1751  m_continuous = continuity;
1752  }
1753 
1757  bool GetContinuity() const
1758  {
1759  return m_continuous;
1760  }
1761 
1764  void SetStep(const unsigned int step)
1765  {
1766  m_step = step;
1767  }
1768 
1771  unsigned int GetStep() const
1772  {
1773  return m_step;
1774  }
1775 
1778  void SetSymbol(const mpSymbol symbol)
1779  {
1780  m_symbol = symbol;
1781  }
1782 
1785  mpSymbol GetSymbol() const
1786  {
1787  return m_symbol;
1788  }
1789 
1792  void SetSymbolSize(const int size)
1793  {
1794  m_symbolSize = size;
1795  }
1796 
1799  int GetSymbolSize() const
1800  {
1801  return m_symbolSize;
1802  }
1803 
1807  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1808 
1812  std::optional<double> GetSeriesValue(double xValue);
1813 
1817  int GetYAxisID() const
1818  {
1819  return m_yAxisID;
1820  }
1821 
1826  void SetYAxisID(const unsigned int yAxisID)
1827  {
1828  m_yAxisID = yAxisID;
1829  }
1830 
1834  void SetLegendIsAlwaysVisible(const bool alwaysVisible)
1835  {
1836  m_LegendIsAlwaysVisible = alwaysVisible;
1837  }
1838 
1843  {
1844  return m_LegendIsAlwaysVisible;
1845  }
1846 
1850  void SetAutoStep(const bool enable)
1851  {
1852  m_autoStep = enable;
1853  }
1854 
1857  bool GetAutoStep() const
1858  {
1859  return m_autoStep;
1860  }
1861 
1865  void SetMaxNOfPoints(const size_t nOfPoints)
1866  {
1867  m_maxNOfPoints = nOfPoints;
1868  }
1869 
1872  size_t GetMaxNOfPoints() const
1873  {
1874  return m_maxNOfPoints;
1875  }
1876 
1877  protected:
1879  mpSymbol m_symbol;
1881  unsigned int m_step;
1884  bool m_autoStep;
1886 
1887  private:
1889 };
1890 
1894 {
1895  public:
1902  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1903 
1904  // We don't want to include line (horizontal or vertical) in BBox computation
1905  bool HasBBox() override
1906  {
1907  return false;
1908  }
1909 
1913  double GetValue() const
1914  {
1915  return m_value;
1916  }
1917 
1921  void SetValue(const double value)
1922  {
1923  m_value = value;
1924  }
1925 
1929  bool IsHorizontal(void) const
1930  {
1931  return m_IsHorizontal;
1932  }
1933 
1934  protected:
1935  double m_value;
1937 
1938  private:
1940 };
1941 
1945 {
1946  public:
1953  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1954 
1958  void SetYValue(const double yvalue)
1959  {
1960  SetValue(yvalue);
1961  }
1962 
1963  protected:
1964 
1965  void DoPlot(wxDC &dc, mpWindow &w) override;
1966 
1967  private:
1969 };
1970 
1974 {
1975  public:
1981  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1982 
1986  void SetXValue(const double xvalue)
1987  {
1988  SetValue(xvalue);
1989  }
1990 
1991  protected:
1992 
1993  void DoPlot(wxDC &dc, mpWindow &w) override;
1994 
1999  bool DoBeforePlot() override
2000  {
2001  return true;
2002  }
2003 
2004  private:
2006 };
2007 
2015 {
2016  public:
2021  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
2022 
2028  virtual double GetY(double x) = 0;
2029 
2036  double DoGetY(double x);
2037 
2042  void DefineDoGetY(void);
2043 
2044  protected:
2045 
2046  double (mpFX::*pDoGetY)(double x);
2047 
2052  void DoPlot(wxDC &dc, mpWindow &w) override;
2053 
2058  double NormalDoGetY(double x);
2059 
2064  double LogDoGetY(double x);
2065 
2066  private:
2068 };
2069 
2077 {
2078  public:
2083  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
2084 
2090  virtual double GetX(double y) = 0;
2091 
2098  double DoGetX(double y);
2099 
2104  void DefineDoGetX(void);
2105 
2106  protected:
2107 
2108  double (mpFY::*pDoGetX)(double y);
2109 
2114  void DoPlot(wxDC &dc, mpWindow &w) override;
2115 
2120  double NormalDoGetX(double y);
2121 
2126  double LogDoGetX(double y);
2127 
2128  private:
2130 };
2131 
2142 {
2143  public:
2149  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2150 
2154  virtual void Rewind() = 0;
2155 
2159  virtual void Clear()
2160  {
2161  ;
2162  }
2163 
2167  virtual size_t GetSize()
2168  {
2169  return 0;
2170  }
2171 
2178  virtual bool GetNextXY(double *x, double *y) = 0;
2179 
2186  bool DoGetNextXY(double *x, double *y);
2187 
2192  void SetViewMode(bool asBar);
2193 
2198  int GetBarWidth(void) const
2199  {
2200  return m_BarWidth;
2201  }
2202 
2207  bool ViewAsBar(void) const
2208  {
2209  return m_ViewAsBar;
2210  }
2211 
2212  protected:
2213 
2214  // Data to calculate label positioning
2217 
2218  // Min delta between 2 x coordinate (used for view as bar)
2219  double m_deltaX;
2220  double m_deltaY;
2221 
2223 
2224  bool m_ViewAsBar = false;
2225 
2232  void DoPlot(wxDC &dc, mpWindow &w) override;
2233 
2238  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
2239 
2240  private:
2242 };
2243 
2244 //-----------------------------------------------------------------------------
2245 // mpFXYVector - provided by Jose Luis Blanco
2246 //-----------------------------------------------------------------------------
2247 
2268 {
2269  public:
2275  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2276 
2279  ~mpFXYVector() override
2280  {
2281  Clear();
2282  }
2283 
2288  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
2289 
2293  void Clear() override;
2294 
2299  size_t GetSize() override
2300  {
2301  return m_xs.size();
2302  }
2303 
2305  const std::vector<double>& GetXData() const
2306  {
2307  return m_xs;
2308  }
2309 
2311  const std::vector<double>& GetYData() const
2312  {
2313  return m_ys;
2314  }
2315 
2323  bool AddData(double x, double y, bool updatePlot);
2324 
2331  void SetReserve(const int reserve)
2332  {
2333  m_reserveXY = reserve;
2334  m_xs.reserve(m_reserveXY);
2335  m_ys.reserve(m_reserveXY);
2336  }
2337 
2341  int GetReserve() const
2342  {
2343  return m_reserveXY;
2344  }
2345 
2346  protected:
2347  std::vector<double> m_xs;
2348  std::vector<double> m_ys;
2351  size_t m_index;
2352  size_t m_endIndex;
2354  double m_lastX;
2356  double m_lastY;
2357 
2362  void Rewind() override;
2363 
2370  bool GetNextXY(double *x, double *y) override;
2371 
2376  void DrawAddedPoint(double x, double y);
2377 
2380  double GetMinX()override
2381  {
2382  if (m_ViewAsBar)
2383  {
2384  // Make extra space for outer bars
2385  return m_rangeX.min - (m_deltaX / 2);
2386  }
2387  else
2388  {
2389  return m_rangeX.min;
2390  }
2391  }
2392 
2395  double GetMinY() override
2396  {
2397  return m_rangeY.min;
2398  }
2399 
2402  double GetMaxX() override
2403  {
2404  if(m_ViewAsBar)
2405  {
2406  // Make extra space for outer bars
2407  return m_rangeX.max + (m_deltaX / 2);
2408  }
2409  else
2410  {
2411  return m_rangeX.max;
2412  }
2413  }
2414 
2417  double GetMaxY() override
2418  {
2419  return m_rangeY.max;
2420  }
2421 
2422  private:
2425  void First_Point(double x, double y);
2426 
2429  static void Check_Limit(double val, mpRange<double> *range, double *last, double *delta);
2430 
2432 };
2433 
2443 {
2444  public:
2448  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
2449 
2455  virtual double GetY(double x) = 0;
2456 
2457  protected:
2458 
2463  void DoPlot(wxDC &dc, mpWindow &w) override;
2464 
2465  private:
2467 };
2468 
2473 class mpFXGeneric: public mpFX
2474 {
2475  public:
2480  mpFXGeneric(const wxString &name = wxT("Generic FX function"), const int flags = mpALIGN_LEFT, const unsigned int yAxisID = 0) :
2481  mpFX(name, flags, yAxisID)
2482  {
2483  const wxPen FXpen(*wxBLUE, 1, wxPENSTYLE_SOLID);
2484  SetDrawOutsideMargins(false);
2485  SetContinuity(true);
2486  SetPen(FXpen);
2487  SetStep(8); // Draw one point over eight
2488  }
2489 
2494  double GetY(const double x) override
2495  {
2496  double y;
2497  try
2498  {
2499  y = ComputeY(x);
2500  }
2501  catch (...)
2502  {
2503  y = 0;
2504  }
2505  m_rangeY.Update(y);
2506  return y;
2507  }
2508 
2513  double GetMinY() override
2514  {
2515  return m_rangeY.min;
2516  }
2517 
2522  double GetMaxY() override
2523  {
2524  return m_rangeY.max;
2525  }
2526 
2527  protected:
2529 
2535  virtual double ComputeY(double x) = 0;
2536 
2537  private:
2539 };
2540 
2546 {
2547  public:
2553  mpGaussian(const double mu, const double sigma) :
2554  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2555  {
2556  m_mu = mu;
2557  m_sigma = sigma;
2558  m_variance = sigma * sigma;
2559  m_const = 1.0 / sqrt(2.0 * M_PI * m_variance);
2560  }
2561 
2562  protected:
2563  double m_mu;
2564  double m_sigma;
2565  double m_variance;
2566  double m_const;
2567 
2568  double ComputeY(const double x) override
2569  {
2570  return m_const * exp(-(x - m_mu) * (x - m_mu) / (2.0 * m_variance));
2571  }
2572 
2573  private:
2575 };
2576 
2581 class mpNormal: public mpFXGeneric
2582 {
2583  public:
2589  mpNormal(const double mu, const double sigma) :
2590  mpFXGeneric(wxT("Normal"), mpALIGN_LEFT)
2591  {
2592  m_mu = mu;
2593  m_sigma = sigma;
2594  m_variance = sigma * sigma;
2595  m_const = 1.0 / (m_variance * sqrt(2.0 * M_PI));
2596  }
2597 
2598  protected:
2599  double m_mu;
2600  double m_sigma;
2601  double m_variance;
2602  double m_const;
2603 
2604  double ComputeY(const double x) override
2605  {
2606  if (x < 0)
2607  return 0.0;
2608  else
2609  {
2610  const double tmp = log(x) - m_mu;
2611  return m_const * exp(-tmp * tmp / (2.0 * m_variance)) / x;
2612  }
2613  }
2614 
2615  private:
2617 };
2618 
2619 //-----------------------------------------------------------------------------
2620 // mpChart
2621 //-----------------------------------------------------------------------------
2625 {
2626  public:
2628  mpChart(const wxString &name = wxEmptyString);
2629 
2631  ~mpChart() override
2632  {
2633  Clear();
2634  }
2635 
2638  void SetChartValues(const std::vector<double> &data);
2639 
2642  void SetChartLabels(const std::vector<std::string> &labelArray);
2643 
2648  void AddData(const double &data, const std::string &label);
2649 
2653  virtual void Clear();
2654 
2655  bool HasBBox() override
2656  {
2657  return (values.size() > 0);
2658  }
2659 
2660  protected:
2661  std::vector<double> values;
2662  std::vector<std::string> labels;
2663 
2664  double m_max_value;
2665  double m_total_value;
2666 
2667  private:
2669 };
2670 
2671 //-----------------------------------------------------------------------------
2672 // mpBarChart - provided by Jose Davide Rondini
2673 //-----------------------------------------------------------------------------
2674 /* Defines for bar charts label positioning. */
2675 #define mpBAR_NONE 0
2676 #define mpBAR_AXIS_H 1
2677 #define mpBAR_AXIS_V 2
2678 #define mpBAR_INSIDE 3
2679 #define mpBAR_TOP 4
2680 
2681 
2684 {
2685  public:
2687  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2688 
2690  ~mpBarChart() override
2691  {
2692  Clear();
2693  }
2694 
2696  void SetBarColour(const wxColour &colour);
2697 
2699  void SetColumnWidth(const double colWidth)
2700  {
2701  m_width = colWidth;
2702  }
2703 
2705  void SetBarLabelPosition(int position);
2706 
2710  double GetMinX() override;
2711 
2715  double GetMaxX() override;
2716 
2720  double GetMinY() override;
2721 
2725  double GetMaxY() override;
2726 
2727  protected:
2728 
2729  double m_width;
2730  wxColour m_barColour;
2732  double m_labelAngle;
2733 
2738  void DoPlot(wxDC &dc, mpWindow &w) override;
2739 
2740  private:
2742 };
2743 
2748 {
2749  public:
2753  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2754 
2756  ~mpPieChart() override
2757  {
2758  Clear();
2759  colours.clear();
2760  }
2761 
2765  void SetCenter(const wxPoint center)
2766  {
2767  m_center = center;
2768  }
2769 
2773  wxPoint GetCenter(void) const
2774  {
2775  return m_center;
2776  }
2777 
2781  void SetPieColours(const std::vector<wxColour> &colourArray);
2782 
2786  double GetMinX() override
2787  {
2788  return m_center.x - m_radius;
2789  }
2790 
2794  double GetMaxX() override
2795  {
2796  return m_center.x + m_radius;
2797  }
2798 
2802  double GetMinY() override
2803  {
2804  return m_center.y - m_radius;
2805  }
2806 
2810  double GetMaxY() override
2811  {
2812  return m_center.y + m_radius;
2813  }
2814 
2815  protected:
2816 
2817  double m_radius;
2818  wxPoint m_center;
2819  std::vector<wxColour> colours;
2820 
2825  void DoPlot(wxDC &dc, mpWindow &w) override;
2826 
2828  const wxColour& GetColour(unsigned int id);
2829 
2830  private:
2832 };
2833 
2836 //-----------------------------------------------------------------------------
2837 // mpLayer implementations - furniture (scales, ...)
2838 //-----------------------------------------------------------------------------
2847 {
2848  public:
2855  {
2856  double step = 0.0;
2857  double maxAxisValue = 0.0;
2858  bool UseScientific = false;
2859  int SignificantDigits = 0;
2860  int DecimalDigits = 0;
2861  double EpsilonScale = 0.0;
2862  };
2863 
2871  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, mpOptional_uint axisID = std::nullopt);
2872 
2876  bool HasBBox() override
2877  {
2878  return false;
2879  }
2880 
2884  int GetAxisID(void) const
2885  {
2886  return m_axisID;
2887  }
2888 
2893  void SetAxisID(const unsigned int yAxisID)
2894  {
2895  m_axisID = yAxisID;
2896  }
2897 
2900  void ShowTicks(const bool ticks)
2901  {
2902  m_ticks = ticks;
2903  }
2904 
2907  bool GetShowTicks() const
2908  {
2909  return m_ticks;
2910  }
2911 
2914  void ShowGrids(const bool grids)
2915  {
2916  m_grids = grids;
2917  }
2918 
2921  bool GetShowGrids() const
2922  {
2923  return m_grids;
2924  }
2925 
2930  void SetLabelFormat(const wxString &format, const bool updateLabelMode = false)
2931  {
2932  m_labelFormat = format;
2933  if (updateLabelMode)
2934  m_labelType = mpLabel_USER;
2935  }
2936 
2940  {
2941  return m_labelType;
2942  }
2943 
2947  void SetLabelMode(const mpLabelType mode, const unsigned int time_conv = MP_X_RAWTIME)
2948  {
2949  m_labelType = mode;
2950  m_timeConv = time_conv;
2951  }
2952 
2955  const wxString& GetLabelFormat() const
2956  {
2957  return m_labelFormat;
2958  }
2959 
2963  void SetGridPen(const wxPen &pen)
2964  {
2965  m_gridpen = pen;
2966  }
2967 
2971  const wxPen& GetGridPen() const
2972  {
2973  return m_gridpen;
2974  }
2975 
2979  void SetAuto(const bool automaticScalingIsEnabled)
2980  {
2981  m_auto = automaticScalingIsEnabled;
2982  }
2983 
2987  bool GetAuto() const
2988  {
2989  return m_auto;
2990  }
2991 
2995  void SetMinScale(const double min)
2996  {
2997  m_axisRange.SetMin(min);
2998  }
2999 
3003  double GetMinScale() const
3004  {
3005  return m_axisRange.min;
3006  }
3007 
3011  void SetMaxScale(const double max)
3012  {
3013  m_axisRange.SetMax(max);
3014  }
3015 
3019  double GetMaxScale() const
3020  {
3021  return m_axisRange.max;
3022  }
3023 
3028  void SetScale(const double min, const double max)
3029  {
3030  m_axisRange.Set(min, max);
3031  }
3032 
3037  void GetScale(double *min, double *max) const
3038  {
3039  *min = m_axisRange.min;
3040  *max = m_axisRange.max;
3041  }
3042 
3046  void SetScale(const mpRange<double> range)
3047  {
3048  m_axisRange = range;
3049  }
3050 
3055  {
3056  return mpRange<double>(m_axisRange);
3057  }
3058 
3062  void SetHovering(const bool hover)
3063  {
3064  m_hover = hover;
3065  }
3066 
3070  virtual bool IsLogAxis()
3071  {
3072  return m_isLog;
3073  }
3074 
3078  virtual void SetLogAxis(const bool log)
3079  {
3080  m_isLog = log;
3081  }
3082 
3086  void SetCoordIsAlwaysVisible(const bool alwaysVisible)
3087  {
3088  m_CoordIsAlwaysVisible = alwaysVisible;
3089  }
3090 
3095  {
3096  return m_CoordIsAlwaysVisible;
3097  }
3098 
3105  static mpScaleConstraints ComputeScaleConstraints(double step, double maxAxisValue);
3106 
3113  wxString FormatLabelValue(double value, const mpScaleConstraints &constraints);
3114 
3115  protected:
3116  static constexpr wxCoord kTickSize = 4;
3117  static constexpr wxCoord kYAxisExtraSpace = 6;
3118  static constexpr wxCoord kYAxisTitleSpace = 2;
3119  static constexpr wxCoord kYAxisLabelSpace = 2;
3120  static constexpr wxCoord kXAxisTitleSpace = 3;
3121 
3122  int m_axisID;
3123  wxPen m_gridpen;
3124  bool m_ticks;
3125  bool m_grids;
3126  bool m_auto;
3129  unsigned int m_timeConv;
3130  wxString m_labelFormat;
3131  bool m_isLog;
3132  bool m_hover = false;
3134 
3137  virtual int GetOrigin(mpWindow &w) = 0;
3138 
3145  static double GetStep(double scale, int minLabelSpacing);
3146 
3154  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
3155 
3160  static wxString FormatLogValue(double n);
3161 
3168  int GetLabelWidth(double value, wxDC &dc, const mpScaleConstraints &constraints);
3169 
3174  static bool UseScientific(double maxAxisValue);
3175 
3181  static int GetSignificantDigits(double step, double maxAxisValue);
3182 
3187  static int GetDecimalDigits(double step);
3188 
3189  private:
3191 };
3192 
3193 
3200 {
3201  public:
3207  mpScaleX(const wxString &name = _T("X"), const int flags = mpALIGN_CENTERX, const bool grids = false, const mpLabelType type = mpLabel_AUTO) :
3208  mpScale(name, flags, grids, type)
3209  {
3210  m_subtype = mpsScaleX;
3211  }
3212 
3214  bool IsTopAxis() const
3215  {
3216  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
3217  }
3218 
3220  bool IsBottomAxis() const
3221  {
3222  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
3223  }
3224 
3225  protected:
3230  static int m_orgy;
3231 
3234  void DoPlot(wxDC &dc, mpWindow &w) override;
3235 
3236  int GetOrigin(mpWindow &w) override;
3237  void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) override;
3238 
3239  private:
3241 
3245  friend mpScaleY;
3246 };
3247 
3255 {
3256  public:
3264  mpScaleY(const wxString &name = _T("Y"), const int flags = mpALIGN_CENTERY, const bool grids = false, const mpOptional_uint yAxisID = std::nullopt, const mpLabelType labelType = mpLabel_AUTO) :
3265  mpScale(name, flags, grids, labelType, yAxisID)
3266  {
3267  m_subtype = mpsScaleY;
3268  m_axisWidth = MP_Y_BORDER_SEPARATION;
3269  m_xPos = 0;
3270  }
3271 
3274  void UpdateAxisWidth(mpWindow &w);
3275 
3277  int GetAxisWidth() const
3278  {
3279  return m_axisWidth;
3280  }
3281 
3283  bool IsLeftAxis() const
3284  {
3285  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
3286  }
3287 
3289  bool IsRightAxis() const
3290  {
3291  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
3292  }
3293 
3295  bool IsInside(const wxCoord xPixel) const
3296  {
3297  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
3298  {
3299  return true;
3300  }
3301  return false;
3302  }
3303 
3304  protected:
3306  int m_xPos;
3307 
3310  void DoPlot(wxDC &dc, mpWindow &w) override;
3311 
3312  int GetOrigin(mpWindow &w) override;
3313  void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int maxLabelWidth) override;
3314 
3315  private:
3317 };
3318 
3319 //-----------------------------------------------------------------------------
3320 // mpWindow
3321 //-----------------------------------------------------------------------------
3322 
3328 #define mpMOUSEMODE_DRAG 0
3329 
3330 #define mpMOUSEMODE_ZOOMBOX 1
3331 
3334 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
3335 typedef std::deque<mpLayer*> mpLayerList;
3336 
3347 {
3348  mpScale* axis = nullptr;
3349  double scale = 1.0;
3350  double pos = 0;
3354 
3355  // Note: we don't use the default operator since we don't want to compare axis pointers
3357  bool operator==(const mpAxisData& other) const
3358  {
3359  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
3360  (bound == other.bound) && (desired == other.desired);
3361  }
3362 };
3363 
3365 typedef std::map<int, mpAxisData> mpAxisList;
3366 
3373 typedef enum {
3374  uXAxis = 1,
3375  uYAxis = 2,
3376  uXYAxis = 3
3377 } mpAxisUpdate;
3378 
3388 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
3389 
3396 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
3397 
3403 {
3404  public:
3405  mpMagnet()
3406  {
3407  m_enable = false;
3408  m_show = false;
3409  }
3410  ~mpMagnet()
3411  {
3412  ;
3413  }
3414 
3416  void UpdateBox(const wxRect &plotArea)
3417  {
3418  m_domain = plotArea;
3419  }
3420 
3422  void Enable(const bool enable)
3423  {
3424  m_enable = enable;
3425  }
3426 
3428  bool IsEnabled() const
3429  {
3430  return m_enable;
3431  }
3432 
3434  void DrawCross(wxDC &dc, mpWindow &w);
3435 
3437  bool ShouldBeShown(const wxPoint mousePos) const
3438  {
3439  return m_enable && m_domain.Contains(mousePos);
3440  }
3441 
3443  void Show(const bool show)
3444  {
3445  m_show = show;
3446  }
3447 
3449  bool IsShown() const
3450  {
3451  return m_show;
3452  }
3453 
3454  private:
3455  bool m_enable;
3456  bool m_show;
3457  wxRect m_domain;
3458 };
3459 
3481 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
3482 {
3483  public:
3484  mpWindow()
3485  {
3486  InitParameters();
3487  }
3488 
3496  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
3497  long flags = 0);
3498 
3499  ~mpWindow() override;
3500 
3504  wxMenu* GetPopupMenu()
3505  {
3506  return &m_popmenu;
3507  }
3508 
3517  bool AddLayer(mpLayer *layer, bool fit = true, bool refreshConfig = true);
3518 
3531  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
3532 
3538  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
3539 
3547  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true, bool refreshConfig = true);
3548 
3555  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
3556 
3562  mpLayer* GetLayer(int position);
3563 
3568  int GetLayerPosition(mpLayer* layer);
3569 
3576  mpLayer* GetLayersType(int position, mpLayerType type);
3577 
3584  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
3585 
3591  mpScale* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
3592 
3601  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
3602 
3610  std::optional<mpPlotHit> GetClosestPlot(wxCoord ix, wxCoord iy);
3611 
3616  mpLayer* GetLayerByName(const wxString &name);
3617 
3622  mpLayer* GetLayerByClassName(const wxString &name);
3623 
3627  void RefreshLegend(void);
3628 
3633  bool IsYAxisUsed(int yAxisID);
3634 
3640  bool IsYAxisUsedByFunction(int yAxisID, int *position);
3641 
3645  mpScaleX* GetLayerXAxis() const;
3646 
3650  mpScaleY* GetLayerYAxis(int yAxisID);
3651 
3655  void SetScaleX(const double scaleX)
3656  {
3657  if (MP_ISNOTNULL(scaleX))
3658  {
3659  m_AxisDataX.scale = scaleX;
3660  UpdateDesiredBoundingBox(uXAxis);
3661  }
3662  UpdateAll();
3663  }
3664 
3669  double GetScaleX(void) const
3670  {
3671  return m_AxisDataX.scale;
3672  }
3673 
3678  void SetScaleY(const double scaleY, const int yAxisID)
3679  {
3680  assert(m_AxisDataYList.count(yAxisID) != 0);
3681  if (MP_ISNOTNULL(scaleY))
3682  {
3683  m_AxisDataYList[yAxisID].scale = scaleY;
3684  UpdateDesiredBoundingBox(uYAxis);
3685  }
3686  UpdateAll();
3687  }
3688 
3694  double GetScaleY(const int yAxisID)
3695  {
3696  assert(m_AxisDataYList.count(yAxisID) != 0);
3697  return m_AxisDataYList[yAxisID].scale;
3698  } // Schaling's method: maybe another method exists with the same name
3699 
3700  [[deprecated("Incomplete, use UpdateBBox instead")]]
3703  void SetBound();
3704 
3707  {
3708  return m_AxisDataX.bound;
3709  }
3710 
3713  {
3714  return m_AxisDataX.desired;
3715  }
3716 
3720  mpRange<double> GetBoundY(const int yAxisID)
3721  {
3722  assert(m_AxisDataYList.count(yAxisID) != 0);
3723  return m_AxisDataYList[yAxisID].bound;
3724  }
3725 
3730  {
3731  assert(m_AxisDataYList.count(yAxisID) != 0);
3732  return m_AxisDataYList[yAxisID].desired;
3733  }
3734 
3739  {
3740  return mpRange<double>(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale), m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3741  }
3742 
3747  mpRange<double> GetVisibleRangeY(const unsigned int yAxisID = 0)
3748  {
3749  assert(m_AxisDataYList.count(yAxisID) != 0);
3750  mpAxisData& yData = m_AxisDataYList[yAxisID];
3751  return mpRange<double>(yData.pos - ((m_margin.top + m_plotHeight) / yData.scale), yData.pos - (m_margin.top / yData.scale));
3752  }
3753 
3758  std::unordered_map<int, mpRange<double>> GetAllBoundY()
3759  {
3760  std::unordered_map<int, mpRange<double>> yRange;
3761  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
3762  {
3763  yRange[m_yID] = m_yData.bound;
3764  }
3765  return yRange;
3766  }
3767 
3772  std::unordered_map<int, mpRange<double>> GetAllDesiredY()
3773  {
3774  std::unordered_map<int, mpRange<double>> yRange;
3775  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
3776  {
3777  yRange[m_yID] = m_yData.desired;
3778  }
3779  return yRange;
3780  }
3781 
3785  void SetPosX(const double posX)
3786  {
3787  m_AxisDataX.pos = posX;
3788  UpdateDesiredBoundingBox(uXAxis);
3789  UpdateAll();
3790  }
3791 
3796  double GetPosX(void) const
3797  {
3798  return m_AxisDataX.pos;
3799  }
3800 
3805  void SetPosY(std::unordered_map<int, double>& posYList)
3806  {
3807  for (auto& [m_yID, m_yData] : m_AxisDataYList)
3808  {
3809  m_yData.pos = posYList[m_yID];
3810  }
3811  UpdateDesiredBoundingBox(uYAxis);
3812  UpdateAll();
3813  }
3814 
3820  double GetPosY(const int yAxisID)
3821  {
3822  assert(m_AxisDataYList.count(yAxisID) != 0);
3823  return m_AxisDataYList[yAxisID].pos;
3824  }
3825 
3829  int GetNOfYAxis(void) const
3830  {
3831  return (int)m_AxisDataYList.size();
3832  }
3833 
3837  mpAxisList GetAxisDataYList(void) const
3838  {
3839  return m_AxisDataYList;
3840  }
3841 
3847  void SetScreen(const int scrX, const int scrY)
3848  {
3849  m_scrX = scrX;
3850  m_scrY = scrY;
3851  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3852  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3853 
3854  m_plotBoundaries.endPx = m_scrX;
3855  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3856  m_plotBoundaries.endPy = m_scrY;
3857  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3858 
3859  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3860  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3861 
3862  m_magnet.UpdateBox(m_PlotArea);
3863  }
3864 
3871  int GetScreenX(void) const
3872  {
3873  return m_scrX;
3874  }
3875 
3882  int GetScreenY(void) const
3883  {
3884  return m_scrY;
3885  }
3886 
3892  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3893  {
3894  m_AxisDataX.pos = posX;
3895  SetPosY(posYList);
3896  }
3897 
3901  double p2x(const wxCoord pixelCoordX) const
3902  {
3903  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3904  }
3905 
3909  double p2y(const wxCoord pixelCoordY, const int yAxisID = 0)
3910  {
3911  assert(m_AxisDataYList.count(yAxisID) != 0);
3912  if (m_AxisDataYList.count(yAxisID) == 0)
3913  return 0.0;
3914  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3915  }
3916 
3920  wxCoord x2p(const double x) const
3921  {
3922  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3923  }
3924 
3928  wxCoord y2p(const double y, const int yAxisID = 0)
3929  {
3930  assert(m_AxisDataYList.count(yAxisID) != 0);
3931  if (m_AxisDataYList.count(yAxisID) == 0)
3932  return 0;
3933  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3934  }
3935 
3937  [[deprecated("Deprecated - use EnableBufferedPaintDC??")]]
3938  void EnableDoubleBuffer(const bool enabled)
3939  {
3940  EnableBufferedPaintDC(enabled);
3941  }
3942 
3946  void EnableBufferedPaintDC(const bool enabled)
3947  {
3948  m_enableBufferedPaintDC = enabled;
3949  }
3950 
3953  void EnableMousePanZoom(const bool enabled)
3954  {
3955  m_enableMouseNavigation = enabled;
3956  }
3957 
3963  void LockAspect(bool enable = true);
3964 
3969  bool IsAspectLocked() const
3970  {
3971  return m_lockaspect;
3972  }
3973 
3978  void Fit() override;
3979 
3986  void Fit(const mpRange<double> &rangeX, std::unordered_map<int, mpRange<double>> rangeY, bool updateDesired = true, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3987 
3991  void FitX(void);
3992 
3997  void FitY(int yAxisID);
3998 
4003  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
4004 
4009  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
4010 
4012  void ZoomInX();
4013 
4015  void ZoomOutX();
4016 
4019  void ZoomInY(mpOptional_int yAxisID = std::nullopt);
4020 
4023  void ZoomOutY(mpOptional_int yAxisID = std::nullopt);
4024 
4029  void ZoomRect(wxPoint p0, wxPoint p1);
4030 
4032  void UpdateAll();
4033 
4034  // Added methods by Davide Rondini
4035 
4039  unsigned int CountLayers();
4040 
4043  unsigned int CountAllLayers() const
4044  {
4045  return (unsigned int)m_layers.size();
4046  }
4047 
4051  unsigned int CountLayersType(mpLayerType type);
4052 
4056  unsigned int CountLayersFXYPlot();
4057 
4065  {
4066  // Change on X axis
4067  if (update & uXAxis)
4068  {
4069  m_AxisDataX.desired = GetVisibleRangeX();
4070  }
4071 
4072  // Change on Y axis
4073  if (update & uYAxis)
4074  {
4075  for (auto& [yID, yData] : m_AxisDataYList)
4076  {
4077  yData.desired = GetVisibleRangeY(yID);
4078  }
4079  }
4080  }
4081 
4087  mpFloatRectSimple GetBoundingBox(const bool desired, const unsigned int yAxisID = 0)
4088  {
4089  assert(m_AxisDataYList.count(yAxisID) != 0);
4090  if (desired)
4091  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
4092  else
4093  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
4094  }
4095 
4101  bool PointIsInsideBound(const double px, const double py, const int yAxisID)
4102  {
4103  if (m_AxisDataYList.count(yAxisID) == 0)
4104  return false;
4105 
4106  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
4107  }
4108 
4114  void UpdateBoundingBoxToInclude(const double px, const double py, const int yAxisID)
4115  {
4116  if (m_AxisDataYList.count(yAxisID) == 0)
4117  return ;
4118 
4119  m_AxisDataX.bound.Update(px);
4120  m_AxisDataYList[yAxisID].bound.Update(py);
4121  }
4122 
4123  /* Initialize bounding box with an initial point
4124  * @param px point on x-axis
4125  * @param py point on y-axis
4126  * @param yAxisID the y-axis ID
4127  */
4129  void InitializeBoundingBox(const double px, const double py, const int yAxisID)
4130  {
4131  if (m_AxisDataYList.count(yAxisID) == 0)
4132  return ;
4133 
4134  m_AxisDataX.bound.Set(px, px);
4135  m_AxisDataYList[yAxisID].bound.Set(py, py);
4136  }
4137 
4140  void SetMPScrollbars(bool status);
4141 
4144  bool GetMPScrollbars() const
4145  {
4146  return m_enableScrollBars;
4147  }
4148 
4154  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
4155 
4159  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4160 
4164  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4165 
4169  void SetWildcard(const wxString &wildcard)
4170  {
4171  m_wildcard = wildcard;
4172  }
4173 
4177  const wxString& GetWildcard(void) const
4178  {
4179  return m_wildcard;
4180  }
4181 
4189  bool LoadFile(const wxString &filename = wxEmptyString);
4190 
4195  void SetDefaultDir(const wxString &dirname)
4196  {
4197  m_DefaultDir = dirname;
4198  }
4199 
4203 
4208 
4214  static void SetDefaultLegendIsAlwaysVisible(const bool visible)
4215  {
4216  m_DefaultLegendIsAlwaysVisible = visible;
4217  }
4218 
4223 
4224 
4229  void SetAutoFit(const bool autoFit)
4230  {
4231  m_autoFit = autoFit;
4232  }
4233 
4240  void SetMargins(int top, int right, int bottom, int left);
4241 
4244  {
4245  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4246  }
4247 
4249  void SetMarginTop(const int top)
4250  {
4251  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4252  }
4253 
4257  int GetMarginTop(const bool minusExtra = false) const
4258  {
4259  if (minusExtra)
4260  return m_margin.top - m_extraMargin;
4261  else
4262  return m_margin.top;
4263  }
4264 
4266  void SetMarginRight(const int right)
4267  {
4268  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
4269  }
4270 
4274  int GetMarginRight(const bool minusExtra = false) const
4275  {
4276  if (minusExtra)
4277  return m_margin.right - m_extraMargin;
4278  else
4279  return m_margin.right;
4280  }
4281 
4284  {
4285  return m_marginOuter.right;
4286  }
4287 
4289  void SetMarginBottom(const int bottom)
4290  {
4291  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
4292  }
4293 
4297  int GetMarginBottom(const bool minusExtra = false) const
4298  {
4299  if (minusExtra)
4300  return m_margin.bottom - m_extraMargin;
4301  else
4302  return m_margin.bottom;
4303  }
4304 
4306  void SetMarginLeft(const int left)
4307  {
4308  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
4309  }
4310 
4314  int GetMarginLeft(const bool minusExtra = false) const
4315  {
4316  if (minusExtra)
4317  return m_margin.left - m_extraMargin;
4318  else
4319  return m_margin.left;
4320  }
4321 
4323  void SetExtraMargin(const int extra)
4324  {
4325  m_extraMargin = extra;
4326  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4327  }
4328 
4330  int GetExtraMargin() const
4331  {
4332  return m_extraMargin;
4333  }
4334 
4337  {
4338  return m_marginOuter.left;
4339  }
4340 
4342  int GetPlotWidth() const
4343  {
4344  return m_plotWidth;
4345  }
4346 
4348  int GetPlotHeight() const
4349  {
4350  return m_plotHeight;
4351  }
4352 
4357  mpRect GetPlotBoundaries(const bool with_margin) const
4358  {
4359  mpRect bond;
4360  if (with_margin)
4361  bond = m_plotBoundariesMargin;
4362  else
4363  bond = m_plotBoundaries;
4364  bond.startPx -= m_extraMargin;
4365  bond.endPx += m_extraMargin;
4366  bond.startPy -= m_extraMargin;
4367  bond.endPy += m_extraMargin;
4368  return bond;
4369  }
4370 
4374  int GetLeftYAxesWidth(mpOptional_int yAxisID = std::nullopt);
4375 
4379  int GetRightYAxesWidth(mpOptional_int yAxisID = std::nullopt);
4380 
4382  void SetDrawBox(const bool drawbox)
4383  {
4384  m_drawBox = drawbox;
4385  }
4386 
4388  bool GetDrawBox() const
4389  {
4390  return m_drawBox;
4391  }
4392 
4396  mpOptional_int IsInsideYAxis(const wxPoint &point);
4397 
4401  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
4402 
4406  void SetLayerVisible(const wxString &name, bool viewable);
4407 
4411  bool IsLayerVisible(const wxString &name);
4412 
4416  bool IsLayerVisible(const unsigned int position);
4417 
4421  void SetLayerVisible(const unsigned int position, bool viewable);
4422 
4427  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
4428 
4431  const wxColour& GetAxesColour() const
4432  {
4433  return m_axColour;
4434  }
4435 
4437  const wxColour& GetbgColour() const
4438  {
4439  return m_bgColour;
4440  }
4441 
4443  void SetbgColour(const wxColour &colour)
4444  {
4445  m_bgColour = colour;
4446  }
4447 
4453  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
4454  {
4455  m_OnDeleteLayer = event;
4456  }
4457 
4460  {
4461  m_OnDeleteLayer = NULL;
4462  }
4463 
4468  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
4469  {
4470  m_OnUserMouseAction = userMouseEventHandler;
4471  }
4472 
4475  {
4476  m_OnUserMouseAction = NULL;
4477  }
4478 
4484  bool IsLogXaxis() const
4485  {
4486  if (m_AxisDataX.axis)
4487  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
4488  else
4489  return false;
4490  }
4491 
4496  bool IsLogYaxis(const int yAxisID)
4497  {
4498  assert(m_AxisDataYList.count(yAxisID) != 0);
4499  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4500  if (yAxis)
4501  return yAxis->IsLogAxis();
4502  else
4503  return false;
4504  }
4505 
4510  void SetLogXaxis(const bool log)
4511  {
4512  if (m_AxisDataX.axis)
4513  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
4514  }
4515 
4521  void SetLogYaxis(const int yAxisID, const bool log)
4522  {
4523  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4524  if (yAxis)
4525  yAxis->SetLogAxis(log);
4526  }
4527 
4532  bool GetMagnetize() const
4533  {
4534  return m_magnet.IsEnabled();
4535  }
4536 
4538  void SetMagnetize(const bool mag)
4539  {
4540  m_magnet.Enable(mag);
4541  }
4542 
4548  {
4549  m_mouseLeftDownAction = action;
4550  }
4551 
4557  {
4558  return m_mouseLeftDownAction;
4559  }
4560 
4565  wxPoint GetMousePosition() const
4566  {
4567  return m_mousePos;
4568  }
4569 
4575  {
4576  return m_movingInfoLayer;
4577  }
4578 
4579 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4580 
4584  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
4585 #endif // MP_ENABLE_CONFIG
4586 
4593  void RefreshConfigWindow(mpLayerType layerType, int param = 0);
4594 
4601  void OpenConfigWindow(mpLayerType layerType = mpLAYER_UNDEF, int param = 0);
4602 
4606  void DeleteConfigWindow(void);
4607 
4612  void Paint(wxDC& dc);
4613 
4618  void RenderOverlays(wxDC& dc);
4619 
4625  wxMemoryDC *GetMemoryDC(void)
4626  {
4627  m_buff_dc.SelectObject(m_buff_bmp);
4628  return &m_buff_dc;
4629  }
4630 
4631  protected:
4632  virtual void BindEvents(void);
4633  virtual void OnPaint(wxPaintEvent &event);
4634  virtual void OnSize(wxSizeEvent &event);
4635  virtual void OnShowPopupMenu(wxMouseEvent &event);
4636  virtual void OnCenter(wxCommandEvent &event);
4637  virtual void OnFit(wxCommandEvent &event);
4638  virtual void OnToggleGrids(wxCommandEvent &event);
4639  virtual void OnToggleCoords(wxCommandEvent &event);
4640  virtual void OnScreenShot(wxCommandEvent &event);
4641  virtual void OnFullScreen(wxCommandEvent &event);
4642 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4643  virtual void OnConfiguration(wxCommandEvent &event);
4644 #endif // MP_ENABLE_CONFIG
4645  virtual void OnLoadFile(wxCommandEvent &event);
4646  virtual void OnZoomIn(wxCommandEvent &event);
4647  virtual void OnZoomOut(wxCommandEvent &event);
4648  virtual void OnLockAspect(wxCommandEvent &event);
4649  virtual void OnMouseHelp(wxCommandEvent &event);
4650  virtual void OnMouseLeftDown(wxMouseEvent &event);
4651  virtual void OnMouseRightDown(wxMouseEvent &event);
4652  virtual void OnMouseMove(wxMouseEvent &event);
4653  virtual void OnMouseLeftRelease(wxMouseEvent &event);
4654  virtual void OnMouseWheel(wxMouseEvent &event);
4655  virtual void OnMouseLeave(wxMouseEvent &event);
4656  bool CheckUserMouseAction(wxMouseEvent &event);
4657  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
4658  virtual void OnScrollPageUp(wxScrollWinEvent &event);
4659  virtual void OnScrollPageDown(wxScrollWinEvent &event);
4660  virtual void OnScrollLineUp(wxScrollWinEvent &event);
4661  virtual void OnScrollLineDown(wxScrollWinEvent &event);
4662  virtual void OnScrollTop(wxScrollWinEvent &event);
4663  virtual void OnScrollBottom(wxScrollWinEvent &event);
4664 
4666  void DoScrollCalc(const int position, const int orientation);
4667 
4672  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = MP_ZOOM_AROUND_CENTER);
4673 
4680  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = MP_ZOOM_AROUND_CENTER, mpOptional_int yAxisID = std::nullopt);
4681 
4686  void SetScaleXAndCenter(double scaleX);
4687 
4693  void SetScaleYAndCenter(double scaleY, int yAxisID);
4694 
4699  void Zoom(bool zoomIn, const wxPoint &centerPoint);
4700 
4703  virtual bool UpdateBBox();
4704 
4708  void DrawBoxZoom(wxDC& dc);
4709 
4713  void InitParameters();
4714 
4715  wxTopLevelWindow* m_parent;
4717 
4718  mpLayerList m_layers;
4720  mpAxisList m_AxisDataYList;
4721 
4722  wxMenu m_popmenu;
4724  wxColour m_bgColour;
4725  wxColour m_fgColour;
4726  wxColour m_axColour;
4727  bool m_drawBox;
4728 
4729  int m_scrX;
4730  int m_scrY;
4733 
4737  wxCoord m_plotWidth;
4738  wxCoord m_plotHeight;
4739 
4742  wxRect m_PlotArea;
4743 
4746  wxBitmap m_buff_bmp;
4747  wxMemoryDC m_buff_dc;
4753  wxPoint m_mousePos;
4754  wxPoint m_mouseRClick;
4755  wxPoint m_mouseLClick;
4756  double m_mouseScaleX;
4757  std::unordered_map<int, double> m_mouseScaleYList;
4760  bool m_autoFit;
4764 
4766 
4768 
4769  wxBitmap* m_Screenshot_bmp;
4770 
4771  wxString m_wildcard;
4772  wxString m_DefaultDir;
4773 
4774 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4775  MathPlotConfigDialog* m_configWindow = NULL;
4776 #endif // MP_ENABLE_CONFIG
4777  bool m_openConfigWindowPending = false;
4779 
4780  mpOnDeleteLayer m_OnDeleteLayer = NULL;
4781  mpOnUserMouseAction m_OnUserMouseAction = NULL;
4782 
4786  virtual void DesiredBoundsHaveChanged() {};
4787 
4788  private:
4790  void CheckAndReportDesiredBoundsChanges();
4791 
4796  unsigned int GetNewAxisDataID(void)
4797  {
4798  int newID = 0;
4799  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
4800  {
4801  if(m_yData.axis)
4802  {
4803  // This ID is used by an axis. Make sure the new ID is larger
4804  newID = std::max(newID, m_yID + 1);
4805  }
4806  }
4807  return newID;
4808  }
4809 
4811 
4812  // To have direct access to m_Screenshot_dc
4813  friend mpPrintout;
4814 };
4815 
4816 //-----------------------------------------------------------------------------
4817 // mpText - provided by Val Greene
4818 //-----------------------------------------------------------------------------
4819 
4828 {
4829  public:
4832  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
4833  {
4834  m_subtype = mptText;
4835  SetName(name);
4836  m_offsetx = 5;
4837  m_offsety = 50;
4838  m_location = mpMarginUser;
4839  m_ZIndex = mpZIndex_TEXT;
4840  }
4841 
4845  mpText(const wxString &name, int offsetx, int offsety);
4846 
4850  mpText(const wxString &name, mpLocation marginLocation);
4851 
4854  bool HasBBox() override
4855  {
4856  return false;
4857  }
4858 
4861  void SetLocation(const mpLocation location)
4862  {
4863  m_location = location;
4864  }
4865 
4868  mpLocation GetLocation() const
4869  {
4870  return m_location;
4871  }
4872 
4875  void SetOffset(const int offX, const int offY)
4876  {
4877  m_offsetx = offX;
4878  m_offsety = offY;
4879  }
4880 
4882  void GetOffset(int *offX, int *offY) const
4883  {
4884  *offX = m_offsetx;
4885  *offY = m_offsety;
4886  }
4887 
4888  protected:
4891  mpLocation m_location;
4892 
4895  void DoPlot(wxDC &dc, mpWindow &w) override;
4896 
4897  private:
4899 };
4900 
4905 {
4906  public:
4909  mpTitle();
4910 
4913  mpTitle(const wxString &name) :
4914  mpText(name, mpMarginTopCenter)
4915  {
4916  m_subtype = mptTitle;
4917  SetPen(*wxWHITE_PEN);
4918  SetBrush(*wxWHITE_BRUSH);
4919  }
4920 
4921  private:
4923 };
4924 
4925 //-----------------------------------------------------------------------------
4926 // mpPrintout - provided by Davide Rondini
4927 //-----------------------------------------------------------------------------
4928 
4933 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4934 {
4935  public:
4936  mpPrintout()
4937  {
4938  plotWindow = NULL;
4939  drawn = false;
4940  stretch_factor = 2;
4941  }
4942 
4948  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4949  ~mpPrintout() override
4950  {
4951  ;
4952  }
4953 
4957  void SetDrawState(const bool drawState)
4958  {
4959  drawn = drawState;
4960  }
4961 
4963  bool OnPrintPage(int page) override;
4965  bool HasPage(int page) override;
4966 
4969  void SetFactor(const int factor)
4970  {
4971  stretch_factor = factor;
4972  }
4973 
4974  private:
4975  bool drawn;
4976  mpWindow* plotWindow;
4977  int stretch_factor; // To reduce the size of plot
4978 
4980 };
4981 
4982 //-----------------------------------------------------------------------------
4983 // mpMovableObject - provided by Jose Luis Blanco
4984 //-----------------------------------------------------------------------------
4993 {
4994  public:
4998  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
4999  {
5000  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
5001  m_subtype = mpfMovable;
5002  }
5003 
5004  ~mpMovableObject() override {}
5005 
5008  void GetCoordinateBase(double &x, double &y, double &phi) const
5009  {
5010  x = m_reference_x;
5011  y = m_reference_y;
5012  phi = m_reference_phi;
5013  }
5014 
5017  void SetCoordinateBase(const double x, const double y, const double phi = 0)
5018  {
5019  m_reference_x = x;
5020  m_reference_y = y;
5021  m_reference_phi = phi;
5022  m_flags = mpALIGN_SW;
5023  ShapeUpdated();
5024  }
5025 
5026  bool HasBBox() override
5027  {
5028  return m_trans_shape_xs.size() != 0;
5029  }
5030 
5033  double GetMinX() override
5034  {
5035  return m_bbox_x.min;
5036  }
5037 
5040  double GetMaxX() override
5041  {
5042  return m_bbox_x.max;
5043  }
5044 
5047  double GetMinY() override
5048  {
5049  return m_bbox_y.min;
5050  }
5051 
5054  double GetMaxY() override
5055  {
5056  return m_bbox_y.max;
5057  }
5058 
5059  protected:
5060 
5063  double m_reference_x;
5064  double m_reference_y;
5066 
5067  void DoPlot(wxDC &dc, mpWindow &w) override;
5068 
5071  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
5072 
5073  // the object points, in local coordinates (to be transformed by the current transformation).
5074  std::vector<double> m_shape_xs;
5075  std::vector<double> m_shape_ys;
5076 
5077  // The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh).
5078  std::vector<double> m_trans_shape_xs;
5079  std::vector<double> m_trans_shape_ys;
5080 
5086 
5090  void ShapeUpdated();
5091 
5092  private:
5094 };
5095 
5096 //-----------------------------------------------------------------------------
5097 // mpCovarianceEllipse - provided by Jose Luis Blanco
5098 //-----------------------------------------------------------------------------
5111 {
5112  public:
5116  mpCovarianceEllipse(const double cov_00 = 1, const double cov_11 = 1, const double cov_01 = 0, const double quantiles = 2, const int segments = 32,
5117  const wxString &layerName = _T("")) : mpMovableObject(),
5118  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
5119  {
5120  m_continuous = true;
5121  m_name = layerName;
5122  RecalculateShape();
5123  }
5124 
5125  ~mpCovarianceEllipse() override
5126  {
5127  ;
5128  }
5129 
5132  double GetQuantiles() const
5133  {
5134  return m_quantiles;
5135  }
5136 
5139  void SetQuantiles(const double q)
5140  {
5141  m_quantiles = q;
5142  RecalculateShape();
5143  }
5144 
5146  void SetSegments(const int segments)
5147  {
5148  m_segments = segments;
5149  }
5150 
5152  int GetSegments() const
5153  {
5154  return m_segments;
5155  }
5156 
5159  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
5160  {
5161  cov_00 = m_cov_00;
5162  cov_01 = m_cov_01;
5163  cov_11 = m_cov_11;
5164  }
5165 
5168  void SetCovarianceMatrix(const double cov_00, const double cov_01, const double cov_11)
5169  {
5170  m_cov_00 = cov_00;
5171  m_cov_01 = cov_01;
5172  m_cov_11 = cov_11;
5173  RecalculateShape();
5174  }
5175 
5176  protected:
5179  double m_cov_00;
5180  double m_cov_11;
5181  double m_cov_01;
5182  double m_quantiles;
5183 
5187 
5190  void RecalculateShape();
5191 
5192  private:
5194 };
5195 
5196 //-----------------------------------------------------------------------------
5197 // mpPolygon - provided by Jose Luis Blanco
5198 //-----------------------------------------------------------------------------
5204 {
5205  public:
5208  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
5209  {
5210  m_continuous = true;
5211  m_name = layerName;
5212  }
5213 
5214  ~mpPolygon() override
5215  {
5216  ;
5217  }
5218 
5224  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
5225 
5226  private:
5228 };
5229 
5230 //-----------------------------------------------------------------------------
5231 // mpBitmapLayer - provided by Jose Luis Blanco
5232 //-----------------------------------------------------------------------------
5238 {
5239  public:
5243  {
5244  m_validImg = false;
5245  m_bitmapChanged = false;
5246  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
5247  }
5248 
5249  ~mpBitmapLayer() override
5250  {
5251  ;
5252  }
5253 
5256  void GetBitmapCopy(wxImage &outBmp) const;
5257 
5265  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
5266 
5269  double GetMinX() override
5270  {
5271  return m_bitmapX.min;
5272  }
5273 
5276  double GetMaxX() override
5277  {
5278  return m_bitmapX.max;
5279  }
5280 
5283  double GetMinY() override
5284  {
5285  return m_bitmapY.min;
5286  }
5287 
5290  double GetMaxY() override
5291  {
5292  return m_bitmapY.max;
5293  }
5294 
5295  protected:
5296 
5299  wxImage m_bitmap;
5300  wxBitmap m_scaledBitmap;
5303  bool m_validImg;
5305 
5310 
5311  void DoPlot(wxDC &dc, mpWindow &w) override;
5312 
5313  private:
5315 };
5316 
5317 // utility class
5318 
5320 typedef enum __mp_Colour
5321 {
5322  mpBlue,
5323  mpRed,
5324  mpGreen,
5325  mpPurple,
5326  mpYellow,
5327  mpFuchsia,
5328  mpLime,
5329  mpAqua,
5330  mpOlive
5331 } mpColour;
5332 
5337 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
5338 {
5339  public:
5344  wxIndexColour(const unsigned int id)
5345  {
5346 #ifdef _WIN32
5347  auto GetRandomColor = []() {
5348  return (rand() * 255) / RAND_MAX;
5349  };
5350 #else
5351  auto GetRandomColor = []() {
5352  return (random() * 255) / RAND_MAX;
5353  };
5354 #endif
5355  switch (id)
5356  {
5357  case 0:
5358  this->Set(0, 0, 255);
5359  break; // Blue
5360  case 1:
5361  this->Set(255, 0, 0);
5362  break; // Red
5363  case 2:
5364  this->Set(0, 128, 0);
5365  break; // Green
5366  case 3:
5367  this->Set(128, 0, 128);
5368  break; // Purple
5369  case 4:
5370  this->Set(255, 255, 0);
5371  break; // Yellow
5372  case 5:
5373  this->Set(255, 0, 255);
5374  break; // Fuchsia
5375  case 6:
5376  this->Set(0, 255, 0);
5377  break; // Lime
5378  case 7:
5379  this->Set(0, 255, 255);
5380  break; // Aqua/Cyan
5381  case 8:
5382  this->Set(128, 128, 0);
5383  break; // Olive
5384  default:
5385  this->Set((ChannelType) (GetRandomColor()), (ChannelType) (GetRandomColor()), (ChannelType) (GetRandomColor()));
5386  }
5387  }
5388 };
5389 
5392 // ---------------------------------------------------------------------
5393 #if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
5394  }// namespace MathPlot
5395 #endif // MP_ENABLE_NAMESPACE
5396 
5397 #endif // MATHPLOT_H_INCLUDED
T Length(void) const
Length of the range.
Definition: mathplot.h:393
sub type for mpFXYVector function
Definition: mathplot.h:731
int GetMarginLeft(const bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:4314
mpRange< double > lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:3353
mpMouseButtonAction GetMouseLeftDownAction() const
Returns the type of action for the left mouse button.
Definition: mathplot.h:4556
int GetAxisWidth() const
Get the reserved width of the Y axis in pixels.
Definition: mathplot.h:3277
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:4889
bool GetLegendIsAlwaysVisible() const
Get the visibility of the legend.
Definition: mathplot.h:1842
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2802
mpScaleX(const wxString &name=_T("X"), const int flags=mpALIGN_CENTERX, const bool grids=false, const mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:3207
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer.
Definition: mathplot.h:3388
void SetDrawState(const bool drawState)
Set whether the plot has already been drawn on the current printout.
Definition: mathplot.h:4957
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:633
sub type for mpText layer
Definition: mathplot.h:720
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:4144
Align the plot label towards the southeast.
Definition: mathplot.h:672
mpScaleY(const wxString &name=_T("Y"), const int flags=mpALIGN_CENTERY, const bool grids=false, const mpOptional_uint yAxisID=std::nullopt, const mpLabelType labelType=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:3264
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:859
Draw a circle.
Definition: mathplot.h:695
enum __YAxis_Align_Type mpYAxis_Align
Alignment for Y axis.
void SetCoordinateBase(const double x, const double y, const double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:5017
Show legend items with small square with the same color of referred mpLayer.
Definition: mathplot.h:680
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:226
bool IsTopAxis() const
Return true when this X axis is aligned at the top edge or top border.
Definition: mathplot.h:3214
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:3504
mpRange< double > GetBoundY(const int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3720
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:4757
wxMemoryDC m_buff_dc
DC for double buffering.
Definition: mathplot.h:4747
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:4453
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3847
bool GetMagnetize() const
Is mouse magnetization enabled? Useful to read the position on the axes.
Definition: mathplot.h:4532
enum __mp_Colour mpColour
Enumeration of classic colour.
Bitmap type layer.
Definition: mathplot.h:810
bool IsDraggedSeriesShown() const
Get shown status of dragged series.
Definition: mathplot.h:1537
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1181
void SetExtraMargin(const int extra)
Set the extra margin.
Definition: mathplot.h:4323
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:4742
__Scale_Type
sub_type values for mpLAYER_AXIS
Definition: mathplot.h:738
T GetMaxAbs(void) const
Max absolute value of the range.
Definition: mathplot.h:405
Plot type layer.
Definition: mathplot.h:795
~mpInfoCoords() override
Default destructor.
Definition: mathplot.h:1362
abstract Layer for chart (bar and pie).
Definition: mathplot.h:2624
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1180
bool m_enableScrollBars
Enable scrollbar in plot window (default false)
Definition: mathplot.h:4759
double m_lastX
Last x-coordinate point added.
Definition: mathplot.h:2354
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1170
bool IsShown() const
Get shown status.
Definition: mathplot.h:1394
User defined position. Can be change by mouse drag.
Definition: mathplot.h:643
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1177
wxBitmap m_scaledBitmap
Cached scaled bitmap used for drawing.
Definition: mathplot.h:5300
std::map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:3365
mpFXGeneric(const wxString &name=wxT("Generic FX function"), const int flags=mpALIGN_LEFT, const unsigned int yAxisID=0)
Definition: mathplot.h:2480
#define MP_X_RAWTIME
Shortcut for MP_X_UTCTIME.
Definition: mathplot.h:171
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:1455
__Symbol_Type
Displaying a symbol instead of a point in the plot function.
Definition: mathplot.h:692
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:679
__mp_Layer_Type
Major type of an mpLayer (detail is in subtype)
Definition: mathplot.h:791
std::unordered_map< int, mpRange< double > > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:3772
Show/Hide grids.
Definition: mathplot.h:621
VerticalCursorMode GetVerticalCursorMode() const
Get the current vertical cursor mode.
Definition: mathplot.h:1603
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:989
bool m_autoStep
Calculates m_step automatically based on how many points you want to draw.
Definition: mathplot.h:1884
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:3131
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1172
mpLabelType
enum for label for grid
Definition: mathplot.h:763
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:5026
int GetAxisID(void) const
Return the ID of the Axis.
Definition: mathplot.h:2884
mpNormal(const double mu, const double sigma)
Classic Normal distribution.
Definition: mathplot.h:2589
mpRange< double > GetDesiredBoundY(const int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3729
void SetCoordIsAlwaysVisible(const bool alwaysVisible)
Set the visibility of the mouse coordinates in the info coordinates despite the visibility of the axi...
Definition: mathplot.h:3086
std::vector< std::string > labels
Labels of the Values.
Definition: mathplot.h:2662
mpLegendStyle GetItemMode() const
Get the current legend item drawing mode.
Definition: mathplot.h:1503
bool PointIsInsideBound(const double px, const double py, const int yAxisID)
Is the given point inside the current bounding box for the selected Y axis?
Definition: mathplot.h:4101
bool HasBBox() override
mpInfoLayer has not bounding box.
Definition: mathplot.h:1253
void SetScaleY(const double scaleY, const int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:3678
const wxRect & GetRectangle() const
Get the current rectangle coordinates.
Definition: mathplot.h:1300
static void SetDefaultLegendIsAlwaysVisible(const bool visible)
Set if legend is always visible even if series is not plotted.
Definition: mathplot.h:4214
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:4731
mpRange< double > GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:3706
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:3805
double m_const
Const factor.
Definition: mathplot.h:2602
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:793
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:826
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:3122
sub type not defined (should be never used)
Definition: mathplot.h:740
double m_lastY
Last y-coordinate point added.
Definition: mathplot.h:2356
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:3669
double ComputeY(const double x) override
The main computation of the FX function.
Definition: mathplot.h:2604
void SetScale(const mpRange< double > range)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3046
bool m_CoordIsAlwaysVisible
If true, the mouse coordinates is visible in the info coordinates despite the visibility of the axis...
Definition: mathplot.h:3133
VerticalCursorMode
Enumeration for vertical cursor mode, which determines how the vertical cursor is positioned for seri...
Definition: mathplot.h:1595
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:4336
mpRange< double > GetScale() const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3054
Lock x/y scaling aspect.
Definition: mathplot.h:620
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:4734
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2601
void SetNeedUpdate()
Mark the legend bitmap as needing regeneration.
Definition: mathplot.h:1523
void ToLog(void)
Convert to log range.
Definition: mathplot.h:411
int m_reserveXY
Memory reserved for m_xs and m_ys. Default 1000.
Definition: mathplot.h:2350
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:1029
std::optional< unsigned int > mpOptional_uint
Shortcut to optional unsigned integer type.
Definition: mathplot.h:106
Align the info in margin center-bottom.
Definition: mathplot.h:641
std::vector< double > m_trans_shape_ys
Transformed shape vertices in Y coordinates.
Definition: mathplot.h:5079
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:4468
wxBitmap m_buff_bmp
Bmp for double buffering.
Definition: mathplot.h:4746
Info box type layer.
Definition: mathplot.h:815
bool m_boxZoomActive
Indicate if box zoom is active.
Definition: mathplot.h:4765
~mpPieChart() override
Destructor.
Definition: mathplot.h:2756
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:5237
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:1005
virtual bool IsLayerType(const 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:897
void SetYAxisID(const unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1826
wxString m_DefaultDir
The default directory for wxFileDialog.
Definition: mathplot.h:4772
void SetMinScale(const double min)
Set the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2995
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:2014
std::vector< wxColor > m_seriesColors
Colors of the series in the order they were added to the mpWindow.
Definition: mathplot.h:1461
double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:5290
#define MP_ZOOM_AROUND_CENTER
Default value for zoom around a point (default -1 is no zoom)
Definition: mathplot.h:182
bool operator!=(const mpRange &other) const
Compare two ranges for inequality.
Definition: mathplot.h:432
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1986
void Enable(const bool enable)
Enables the magnet.
Definition: mathplot.h:3422
mpRange< double > m_bbox_y
Range of bounding box on y direction.
Definition: mathplot.h:5085
enum __Info_Type mpInfoType
sub_type values for mpLAYER_INFO
mpRect GetPlotBoundaries(const bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:4357
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:4750
void SetHovering(const bool hover)
Set if axis shall be highlighted when a series is dragged over it.
Definition: mathplot.h:3062
void ErasePlot(wxDC &, mpWindow &) override
Just delete the bitmap of the info.
Definition: mathplot.h:1383
const wxColour & GetbgColour() const
Get the plot background colour.
Definition: mathplot.h:4437
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:5186
Chart type layer (bar chart)
Definition: mathplot.h:800
int GetMarginBottom(const bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:4297
void SetDrawBox(const bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:4382
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:4348
sub type for mpLine function
Definition: mathplot.h:733
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1799
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1197
void SetDefaultDir(const wxString &dirname)
Set the default directory for wxFileDialog.
Definition: mathplot.h:4195
Draw a cross X.
Definition: mathplot.h:699
double m_max_value
Max value of the values vector.
Definition: mathplot.h:2664
void SetItemDirection(const mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1510
Draw a triangle up oriented.
Definition: mathplot.h:697
infoCoordType m_infoCoordType
Type of info coordinates to be displayed (axis, closest series, or all series).
Definition: mathplot.h:1460
void SetAuto(const bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2979
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1817
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2442
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:4283
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:2655
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:3901
wxSize GetSize() const
Get the size of the box (in pixels)
Definition: mathplot.h:1293
wxPoint m_mousePos
Current mouse position in window.
Definition: mathplot.h:4753
void SetMaxScale(const double max)
Set the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3011
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3953
double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:2380
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:4736
unsigned int CountAllLayers() const
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:4043
Mouse action drag the plot.
Definition: mathplot.h:759
bool IsLeftAxis() const
Return true if this Y axis is aligned to the left side.
Definition: mathplot.h:3283
void SetFont(const wxFont &font)
Set layer font.
Definition: mathplot.h:997
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1880
double GetValue() const
Get the x or y coordinates of the line.
Definition: mathplot.h:1913
void SetAutoStep(const bool enable)
Enables auto step which is used to plot a maximum nuber of points at a time to the plot no matter zoo...
Definition: mathplot.h:1850
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:4726
double m_relY
Box Y position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1324
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:4718
~mpBarChart() override
Destructor.
Definition: mathplot.h:2690
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:5063
mpRange()
Default constructor.
Definition: mathplot.h:275
double m_sigma
Sigma value.
Definition: mathplot.h:2600
void ShowDraggedSeries(const bool active)
Set if dragged series shall be shown or hidden.
Definition: mathplot.h:1530
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:3785
sub type not defined (should be never used)
Definition: mathplot.h:749
int m_flags
Holds label alignment. Default : mpALIGN_SW for series and mpALIGN_CENTER for scale.
Definition: mathplot.h:1178
std::vector< wxColour > colours
Per-slice colours used when drawing the chart.
Definition: mathplot.h:2819
mpRange< double > GetVisibleRangeY(const unsigned int yAxisID=0)
Get the visible range for Y axis of ID yAxisID, i.e.
Definition: mathplot.h:3747
wxMemoryDC * GetMemoryDC(void)
Give a direct access to the memory DC to draw in the buffered bitmap You need release the bitmap afte...
Definition: mathplot.h:4625
enum __Function_Type mpFunctionType
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
mpRange< int > m_drawY
Range min and max on y axis.
Definition: mathplot.h:2216
void SetReserve(const 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:2331
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1325
sub type not defined (should be never used)
Definition: mathplot.h:727
wxIndexColour(const unsigned int id)
Constructor.
Definition: mathplot.h:5344
double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:2794
sub type not defined (should be never used)
Definition: mathplot.h:719
mpRange< double > m_bitmapX
The shape of the bitmap:
Definition: mathplot.h:5308
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:4868
void SetSymbol(const mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1778
Just the end of ZOrder.
Definition: mathplot.h:817
int GetMarginRight(const bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:4274
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:808
void SetLabelFormat(const wxString &format, const bool updateLabelMode=false)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2930
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:2267
mpRange< double > x
range over x direction
Definition: mathplot.h:562
Layer for pie chart.
Definition: mathplot.h:2747
void SetAutoFit(const bool autoFit)
Set if plot shall be auto fitted when hiding or showing axis and series via mouse.
Definition: mathplot.h:4229
wxPoint GetMousePosition() const
Returns current mouse position in window.
Definition: mathplot.h:4565
std::vector< double > m_xs
internal copy of the set of data on x direction
Definition: mathplot.h:2347
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:1021
bool IsRightAxis() const
Return true if this Y axis is aligned to the right side.
Definition: mathplot.h:3289
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:2341
void Set(T value_)
Initialize min and max.
Definition: mathplot.h:297
const std::vector< double > & GetYData() const
Get read-only access to the internal Y data vector.
Definition: mathplot.h:2311
void Update(T value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:351
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:4720
Draw a plus +.
Definition: mathplot.h:700
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2939
Keep the object, just remove the layer from the layer list.
Definition: mathplot.h:828
double GetMaxY() override
Get max Y of the function.
Definition: mathplot.h:2522
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:2876
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:3199
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
T GetCenter(void) const
Center of the range.
Definition: mathplot.h:399
std::vector< double > m_ys
internal copy of the set of data on y direction
Definition: mathplot.h:2348
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:887
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2921
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:2351
Delete the object regardless of the CanDelete value and remove it from the layer list.
Definition: mathplot.h:830
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:3396
double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:2402
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:4330
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:4751
Align the plot label towards the southwest.
Definition: mathplot.h:673
Align the y-axis towards left border.
Definition: mathplot.h:660
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:1063
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:3796
void EnableBufferedPaintDC(const bool enabled)
Enable/disable the auto buffering of PaintDC.
Definition: mathplot.h:3946
Align the x-axis towards bottom border.
Definition: mathplot.h:650
void Show(const bool show)
Set if magnet shall be shown or hidden.
Definition: mathplot.h:3443
void SetMarginTop(const int top)
Set the top margin.
Definition: mathplot.h:4249
Plot (function) type layer.
Definition: mathplot.h:813
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:4767
bool ViewAsBar(void) const
Get if we are in bar mode.
Definition: mathplot.h:2207
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1179
wxColour colour
pen colour of the matched plot layer
Definition: mathplot.h:607
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:1013
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1139
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1785
void SetStep(const unsigned int step)
Set step for plot.
Definition: mathplot.h:1764
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:3128
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:4342
Create a generic FX function Override the ComputeY() function with your function. ...
Definition: mathplot.h:2473
void SetMaxNOfPoints(const size_t nOfPoints)
Set how many points that is allowed to be drawn at a time.
Definition: mathplot.h:1865
size_t m_maxNOfPoints
Maximum number of points to draw to screen.
Definition: mathplot.h:1885
double m_deltaY
Min delta between 2 consecutive coordinate on y direction.
Definition: mathplot.h:2220
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2907
Axis type layer.
Definition: mathplot.h:811
void SetMarginLeft(const int left)
Set the left margin.
Definition: mathplot.h:4306
void Update(T min_, T 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:362
double GetMaxScale() const
Get the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3019
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:5203
Draw a triangle down oriented.
Definition: mathplot.h:698
Axis type layer.
Definition: mathplot.h:794
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:3920
double GetQuantiles() const
Get the confidence-interval multiplier used for the ellipse.
Definition: mathplot.h:5132
double m_const
Const factor.
Definition: mathplot.h:2566
bool GetCanDelete(void) const
Retreive what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1153
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:2141
#define MP_Y_BORDER_SEPARATION
Default minimum separation in pixels between Y axes and the plot border.
Definition: mathplot.h:164
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:1176
void SetMarginBottom(const int bottom)
Set the bottom margin.
Definition: mathplot.h:4289
Align the info in margin center-right.
Definition: mathplot.h:639
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1166
static bool m_DefaultCoordIsAlwaysVisible
This value sets the default behaviour when an axis is not visible for the mouse info coordinates disp...
Definition: mathplot.h:4222
int GetBarWidth(void) const
Get the width of the bar when we plot in bar mode.
Definition: mathplot.h:2198
wxColour m_barColour
Fill colour used for the bars.
Definition: mathplot.h:2730
double GetMinScale() const
Get the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:3003
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:4740
bool IsHorizontal(void) const
Is it a horizontal line?
Definition: mathplot.h:1929
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:3335
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:1118
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:4737
void SetLogYaxis(const int yAxisID, const bool log)
Set the log property (true or false) for a Y layer (Y axis) given by is ID.
Definition: mathplot.h:4521
int GetSegments() const
Get the number of line segments used to approximate the ellipse. */.
Definition: mathplot.h:5152
virtual size_t GetSize()
Return the number of points in the series.
Definition: mathplot.h:2167
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:5159
mpRange< double > desired
Desired range min and max.
Definition: mathplot.h:3352
wxCoord m_scaledBitmap_offset_x
Cached X pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5301
void Check(void)
Check to always have a range. If min = max then introduce the 0 to make a range.
Definition: mathplot.h:381
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:4202
void SetLegendIsAlwaysVisible(const bool alwaysVisible)
Set the visibility of the name of the function in the legend despite the visibility of the function i...
Definition: mathplot.h:1834
bool IsEnabled() const
Check if magnet is enabled.
Definition: mathplot.h:3428
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5283
bool m_LegendIsAlwaysVisible
If true, the name is visible in the legend despite the visibility of the function. Default false.
Definition: mathplot.h:1883
each visible plot is described on its own line, one above the other
Definition: mathplot.h:687
double m_cov_01
Covariance matrix element (0,1), equal to element (1,0).
Definition: mathplot.h:5181
void SetbgColour(const wxColour &colour)
Set the plot background colour.
Definition: mathplot.h:4443
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1346
bool m_fullscreen
Boolean value indicating that we are in fullscreen mode (default false)
Definition: mathplot.h:4716
mpRange(T value1, T value2)
Create range with the 2 values.
Definition: mathplot.h:282
Align the x-axis towards top plot.
Definition: mathplot.h:653
mpGaussian(const double mu, const double sigma)
Classic Gaussian distribution.
Definition: mathplot.h:2553
void SetDrawOutsideMargins(const bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:1084
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:4755
double m_mu
Mean value.
Definition: mathplot.h:2563
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:766
void SetLocation(const mpLocation location)
Set the location of the box.
Definition: mathplot.h:4861
Align the y-axis towards right border.
Definition: mathplot.h:664
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:708
mpLegendStyle m_item_mode
Visual style used for each legend entry.
Definition: mathplot.h:1648
void SetLogXaxis(const bool log)
Enable or disable logarithmic scaling on the X axis.
Definition: mathplot.h:4510
bool IsLogXaxis() const
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:4484
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:914
double GetScaleY(const int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:3694
mpLegendDirection GetItemDirection() const
Get the current legend item layout direction.
Definition: mathplot.h:1517
void ShowGrids(const bool grids)
Set axis grids.
Definition: mathplot.h:2914
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:5008
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:5242
Show/Hide info coord.
Definition: mathplot.h:622
Align the x-axis towards top border.
Definition: mathplot.h:654
bool m_IsHorizontal
Is the line horizontal? Default false.
Definition: mathplot.h:1936
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5208
Mouse action draw a box to zoom inside.
Definition: mathplot.h:758
__Function_Type
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
Definition: mathplot.h:725
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition: mathplot.h:90
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1958
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:4992
bool IsShown() const
Get shown status.
Definition: mathplot.h:3449
Align the y-axis towards left plot.
Definition: mathplot.h:661
Chart type layer.
Definition: mathplot.h:814
Set label for axis in scientific notation.
Definition: mathplot.h:770
bool IsInside(const wxCoord xPixel) const
Return true if the given X pixel lies within this Y-axis drawing area.
Definition: mathplot.h:3295
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2963
void SetOffset(const int offX, const int offY)
Set offset.
Definition: mathplot.h:4875
enum __mp_Location_Type mpLocation
Location for the Info layer.
void SetInitialPosition(const wxPoint pos)
Set the position in percent of the upper left corner of the box.
Definition: mathplot.h:1285
std::optional< int > mpOptional_int
Shortcut to optional integer type..
Definition: mathplot.h:108
int m_labelPos
Bar-label placement mode.
Definition: mathplot.h:2731
Copy a screen shot to the clipboard.
Definition: mathplot.h:623
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:3402
Fit view to match bounding box of all layers.
Definition: mathplot.h:616
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:629
Center view on click position.
Definition: mathplot.h:619
void SetItemMode(const 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:1496
void ShowTicks(const bool ticks)
Set axis ticks.
Definition: mathplot.h:2900
Plot layer implementing a simple title.
Definition: mathplot.h:4904
double m_total_value
Total of the values vector.
Definition: mathplot.h:2665
bool IsSet() const
Check if this mpRange has been assigned any values.
Definition: mathplot.h:342
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:648
double pos
Position.
Definition: mathplot.h:3350
mpLabelType m_labelType
Label formatting mode used for the X coordinate display.
Definition: mathplot.h:1456
sub type for all layers who are function.
Definition: mathplot.h:734
Draw a square.
Definition: mathplot.h:696
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:1077
Align the x-axis center plot.
Definition: mathplot.h:652
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:717
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:4754
double m_labelAngle
Rotation angle used for bar labels, in degrees.
Definition: mathplot.h:2732
__mp_Colour
Enumeration of classic colour.
Definition: mathplot.h:5320
double m_width
Width of each bar/column in plot units.
Definition: mathplot.h:2729
void SetCovarianceMatrix(const double cov_00, const double cov_01, const double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:5168
mpRange< double > GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:3712
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1226
Align the plot label towards the northwest.
Definition: mathplot.h:670
int m_infoLegendSelectedSeries
Only used with config window: the selected series in info legend.
Definition: mathplot.h:4778
~mpInfoLegend() override
Default destructor.
Definition: mathplot.h:1492
bool m_show
Indicates if magnet shall be shown in plot.
Definition: mathplot.h:1454
void SetLabelMode(const mpLabelType mode, const unsigned int time_conv=MP_X_RAWTIME)
Set axis label view mode.
Definition: mathplot.h:2947
mpRange< int > m_drawX
Range min and max on x axis.
Definition: mathplot.h:2215
void GetScale(double *min, double *max) const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3037
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:4723
double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:2417
bool ShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
Check conditions if info coords shall be shown or not.
Definition: mathplot.h:1403
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:3254
bool IsVisible() const
Is this layer visible?
Definition: mathplot.h:1104
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:560
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:4388
No symbol is drawing.
Definition: mathplot.h:694
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:930
virtual void SetTractable(const bool track)
Sets layer tractability.
Definition: mathplot.h:1125
double m_reference_y
Current object Y position in plot coordinates.
Definition: mathplot.h:5064
Layer for bar chart.
Definition: mathplot.h:2683
__Chart_Type
sub_type values for mpLAYER_CHART
Definition: mathplot.h:747
void SetAxisID(const unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2893
void SetFactor(const int factor)
Definition: mathplot.h:4969
static bool m_DefaultLegendIsAlwaysVisible
This value sets the default behaviour when a series is not visible for the legend display...
Definition: mathplot.h:4207
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:681
sub type for all layers who are chart.
Definition: mathplot.h:752
void EnableSeriesValues(const bool enable)
Enables to show series values in the legend.
Definition: mathplot.h:1544
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4933
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:3125
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1905
Align the info in margin center-left.
Definition: mathplot.h:635
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:768
double m_mu
Mean value.
Definition: mathplot.h:2599
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:668
mpRange< double > y
range over y direction
Definition: mathplot.h:563
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:4741
void Set(T min_, T max_)
Set min, max function.
Definition: mathplot.h:304
double GetPosY(const int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3820
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:4431
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1736
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:269
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:4761
sub type for mpInfoLegend layer
Definition: mathplot.h:713
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1314
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2971
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1169
wxPoint m_center
Center of the pie chart in device coordinates.
Definition: mathplot.h:2818
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3882
double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:2810
mpOptional_int m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:4758
bool IsSeriesValuesShown() const
Indicates if series values shall be shown.
Definition: mathplot.h:1574
#define MP_EPSILON
An epsilon for float comparison to 0.
Definition: mathplot.h:174
double m_radius
Radius of the pie chart in pixels.
Definition: mathplot.h:2817
bool m_mouseMovedAfterRightClick
If the mouse does not move after a right click, then the context menu is displayed.
Definition: mathplot.h:4752
bool SeriesValuesShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
Check if series values should be shown in plot, depending on where mouse is.
Definition: mathplot.h:1560
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:4725
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3969
void SetLocation(const mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1307
int m_last_ly
Last logical Y origin, used for double buffering.
Definition: mathplot.h:4745
std::unordered_map< int, mpRange< double > > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:3758
Text box type layer.
Definition: mathplot.h:797
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:658
void SetAlign(const int align)
Set X/Y alignment.
Definition: mathplot.h:1132
sub type for mpBarChart
Definition: mathplot.h:750
Abstract class providing a line.
Definition: mathplot.h:1893
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:1044
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:3655
Load a file.
Definition: mathplot.h:627
enum __Symbol_Type mpSymbol
Displaying a symbol instead of a point in the plot function.
bool GetAutoStep() const
Get if auto stop is enabled.
Definition: mathplot.h:1857
mpRange< double > m_axisRange
Range axis values when autosize is false.
Definition: mathplot.h:3127
void Show(const bool show)
Set if info coords shall be shown or hidden.
Definition: mathplot.h:1387
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:981
Line (horizontal or vertical) type layer.
Definition: mathplot.h:812
void SetMouseLeftDownAction(const mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:4547
double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:5040
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3829
size_t GetSize() override
Return the number of points in the series We assume that size of m_xs equals size of m_ys...
Definition: mathplot.h:2299
Dialog box for configuring the plot&#39;s layer objects In this dialog, you can configure: ...
Definition: MathPlotConfig.h:155
bool ShouldBeShown(const wxPoint mousePos) const
Check conditions if magnet shall be shown.
Definition: mathplot.h:3437
T max
The max value of the range.
Definition: mathplot.h:272
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1320
infoCoordType
Type of info coordinates to be displayed (axis, closest series, or all series)
Definition: mathplot.h:1368
Delete the object if CanDelete is true and remove it from the layer list.
Definition: mathplot.h:829
void SetBrush(const wxColour &colour, enum wxBrushStyle style=wxBRUSHSTYLE_SOLID)
Set layer brush.
Definition: mathplot.h:1055
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:4243
double scale
Scale.
Definition: mathplot.h:3349
void SetContinuity(const bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1749
sub type for mpTitle layer
Definition: mathplot.h:721
mpRange< double > m_bbox_x
The precomputed bounding box:
Definition: mathplot.h:5084
int GetMarginTop(const bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:4257
Align the info in margin center-top.
Definition: mathplot.h:637
void SetScale(const double min, const double max)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3028
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:777
void SetSeriesCoord(const bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1420
void IndicateSeriesIntersection(const bool enable)
Set if the intersection of the series with the vertical cursor shall be indicated.
Definition: mathplot.h:1581
bool m_autoFit
Automatically fit plot when hiding / showing axis and series.
Definition: mathplot.h:4760
wxPoint GetPosition() const
Get the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1278
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1175
void UpdateDesiredBoundingBox(const mpAxisUpdate update)
Update m_desired bounds.
Definition: mathplot.h:4064
bool IsLogYaxis(const 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:4496
void SetWildcard(const wxString &wildcard)
Set wildcard for LoadFile() function when we use wxFileDialog.
Definition: mathplot.h:4169
double GetMinY() override
Get min Y of the function.
Definition: mathplot.h:2513
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1322
Set no label for axis (useful for bar)
Definition: mathplot.h:783
enum __mp_Layer_ZOrder mpLayerZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
mpMouseButtonAction
enum for left button mouse action: box zoom or drag
Definition: mathplot.h:756
void SetMagnetize(const bool mag)
Enable or disable mouse-position magnet lines (cross-hairs) in the plot area.
Definition: mathplot.h:4538
sub type for mpPieChart
Definition: mathplot.h:751
bool m_validImg
True when the source image is valid and ready to draw.
Definition: mathplot.h:5303
void Assign(T value1, T value2)
Assign values to min and max.
Definition: mathplot.h:327
Align the plot label towards the northeast.
Definition: mathplot.h:671
double m_deltaX
Min delta between 2 consecutive coordinate on x direction.
Definition: mathplot.h:2219
only for mpInfoCoords
Definition: mathplot.h:644
double m_value
The x or y coordinates of the line.
Definition: mathplot.h:1935
bool m_enableBufferedPaintDC
For auto DC double buffering.
Definition: mathplot.h:4749
void SetMax(T max_)
Set max function, correct min.
Definition: mathplot.h:319
HitCode
Return codes for GetLegendHitRegion() if no series was hit.
Definition: mathplot.h:1638
Abstract class providing an vertical line.
Definition: mathplot.h:1973
bool m_showDraggedSeries
Indicate if series that has been gripped with mouse shall be drawn.
Definition: mathplot.h:1650
sub type for mpFXY function
Definition: mathplot.h:730
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:906
enum __XAxis_Align_Type mpXAxis_Align
Alignment for X axis.
bool operator==(const mpAxisData &other) const
Compare axis data while ignoring the axis pointer itself.
Definition: mathplot.h:3357
bool IsBottomAxis() const
Return true when this X axis is aligned at the bottom edge or bottom border.
Definition: mathplot.h:3220
enum __Chart_Type mpChartType
sub_type values for mpLAYER_CHART
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:3871
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:922
mpInfoLayer * GetMovingInfoLayer() const
Returns moving info layer.
Definition: mathplot.h:4574
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:5299
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:4769
void UpdateBoundingBoxToInclude(const double px, const double py)
Update bounding box (X and Y axis) to include this point.
Definition: mathplot.h:586
infoCoordType GetInfoCoordType() const
Get the type of info coordinates to be displayed (axis, closest series, or all series) ...
Definition: mathplot.h:1436
Zoom into view at clickposition / window center.
Definition: mathplot.h:617
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:4738
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:4719
std::vector< double > values
Values of the chart.
Definition: mathplot.h:2661
mpCovarianceEllipse(const double cov_00=1, const double cov_11=1, const double cov_01=0, const double quantiles=2, const int segments=32, const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5116
Align the info in margin top-left.
Definition: mathplot.h:636
void SetQuantiles(const double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see GetQuantiles a...
Definition: mathplot.h:5139
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1174
double m_quantiles
Confidence-interval multiplier used when drawing the ellipse.
Definition: mathplot.h:5182
Zoom out.
Definition: mathplot.h:618
enum __mp_Layer_Type mpLayerType
Major type of an mpLayer (detail is in subtype)
virtual void SetLogAxis(const bool log)
Set Logarithmic mode.
Definition: mathplot.h:3078
wxCoord m_mouseY
Last mouse Y position in window pixel coordinates.
Definition: mathplot.h:1459
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1771
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2565
wxRealPoint coords
data-space (x, y) of the closest point
Definition: mathplot.h:608
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1878
double m_relX
Box X position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1323
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:685
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:5110
const std::vector< double > & GetXData() const
Get read-only access to the internal X data vector.
Definition: mathplot.h:2305
sub type for mpInfoLayer layer
Definition: mathplot.h:711
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:4474
Align the x-axis towards bottom plot.
Definition: mathplot.h:651
wxCoord m_scaledBitmap_offset_y
Cached Y pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5302
bool DoBeforePlot() override
This is the only case where we don&#39;t need and Y axis So no need to test m_yAxisID.
Definition: mathplot.h:1999
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1171
void InitializeBoundingBox(const double px, const double py, const int yAxisID)
Initialize the bounding box from a first point for the selected Y axis.
Definition: mathplot.h:4129
void SetMarginRight(const int right)
Set the right margin.
Definition: mathplot.h:4266
mpFloatRectSimple GetBoundingBox(const bool desired, const unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:4087
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:775
wxPen m_gridpen
Grid&#39;s pen. Default Colour = LIGHT_GREY, width = 1, style = wxPENSTYLE_DOT.
Definition: mathplot.h:3123
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:677
bool IsSeriesValuesEnabled() const
Check if series values is enabled in legend.
Definition: mathplot.h:1552
bool GetCoordIsAlwaysVisible() const
Get the visibility of the mouse coordinates in the info coordinates.
Definition: mathplot.h:3094
Align the y-axis towards right plot.
Definition: mathplot.h:663
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1321
void InitializeBoundingBox(const double px, const double py)
Initialize bounding box with an initial point.
Definition: mathplot.h:596
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:3129
wxTopLevelWindow * m_parent
Pointer to the top-level window containing the plot (used for fullscreen)
Definition: mathplot.h:4715
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:4997
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2773
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:4756
sub type for mpScaleX
Definition: mathplot.h:741
sub type for mpInfoCoords layer
Definition: mathplot.h:712
struct deprecated("Deprecated! No longer used as 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:444
Set label user defined.
Definition: mathplot.h:781
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:3124
std::vector< double > m_shape_ys
Shape vertices in object-local Y coordinates.
Definition: mathplot.h:5075
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1757
void SetMin(T min_)
Set min function, correct max.
Definition: mathplot.h:311
std::vector< double > m_trans_shape_xs
Transformed shape vertices in X coordinates.
Definition: mathplot.h:5078
double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:5269
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1160
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:871
int m_xPos
Leftmost X pixel occupied by this axis (starting point).
Definition: mathplot.h:3306
mpRange< double > GetVisibleRangeX()
Get the visible range for X axis, i.e.
Definition: mathplot.h:3738
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:4732
Plot layer implementing a text string.
Definition: mathplot.h:4827
wxCoord y2p(const double y, const int yAxisID=0)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:3928
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:773
sub type not defined (should be never used)
Definition: mathplot.h:710
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:779
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:4832
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:3481
double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:5054
Bitmap type layer.
Definition: mathplot.h:798
wxCoord m_mouseX
Last mouse X position in window pixel coordinates.
Definition: mathplot.h:1458
bool m_bitmapChanged
True when the cached scaled bitmap must be regenerated.
Definition: mathplot.h:5304
void SetLabelMode(const mpLabelType mode, const unsigned int time_conv=MP_X_RAWTIME)
Set X axis label view mode.
Definition: mathplot.h:1411
Classic Normal distribution f(x) = exp(-(ln(x)-μ)²/2σ²)/(xσ.sqrt(2π))
Definition: mathplot.h:2581
double GetY(const double x) override
Get function value for argument.
Definition: mathplot.h:2494
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1882
int m_last_lx
Last logical X origin, used for double buffering.
Definition: mathplot.h:4744
Align the info in margin bottom-left.
Definition: mathplot.h:640
enum __mp_Delete_Action mpDeleteAction
Action to do with the object associated to the layer when we delete it.
sub type for mpFY function
Definition: mathplot.h:729
Info box type layer.
Definition: mathplot.h:796
double GetMinY() override
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:2395
Align the y-axis center plot.
Definition: mathplot.h:662
mpRange< double > m_rangeX
Range min and max on x axis.
Definition: mathplot.h:2353
double m_cov_11
Covariance matrix element (1,1).
Definition: mathplot.h:5180
double p2y(const wxCoord pixelCoordY, const int yAxisID=0)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:3909
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:4882
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2765
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1881
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1173
bool m_cacheDirty
Indicate that the cached buffer m_buff_bmp need to be re-created.
Definition: mathplot.h:4748
Result of mpWindow::GetClosestPlot: the colour and data-space coordinates of the plot point closest t...
Definition: mathplot.h:605
Shows information about the mouse commands.
Definition: mathplot.h:628
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:4730
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3837
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:1091
legend components follow each other horizontally on a single line
Definition: mathplot.h:688
Align the info in margin top-right.
Definition: mathplot.h:638
void SetSegments(const int segments)
Set the number of line segments used to approximate the ellipse.
Definition: mathplot.h:5146
static int m_orgy
The y origin coordinate of the X axis We declare it static so we can access to it in mpScaleY...
Definition: mathplot.h:3230
~mpChart() override
Destructor.
Definition: mathplot.h:2631
wxString m_wildcard
For loadfile() function when we use wxFileDialog.
Definition: mathplot.h:4771
mpTitle(const wxString &name)
Definition: mathplot.h:4913
int m_axisWidth
Reserved width for this Y axis including labels, in pixels.
Definition: mathplot.h:3305
enum __Text_Type mpTextType
sub_type values for mpLAYER_TEXT
double m_reference_phi
Current object rotation angle in radians.
Definition: mathplot.h:5065
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:4722
virtual void SetVisible(const bool show)
Sets layer visibility.
Definition: mathplot.h:1111
void SetCanDelete(const bool canDelete)
Set what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1146
sub type for all layers who are scale.
Definition: mathplot.h:743
unsigned int m_timeConv
Time conversion mode used when formatting date/time X values.
Definition: mathplot.h:1457
Abstract class providing an horizontal line.
Definition: mathplot.h:1944
mpInfoCoords * m_InfoCoords
Pointer to the optional info coords layer.
Definition: mathplot.h:4762
mpInfoLegend * m_InfoLegend
Pointer to the optional info legend layer.
Definition: mathplot.h:4763
mpLocation m_location
The location of the text.
Definition: mathplot.h:4891
Implement the legend to be added to the plot This layer allows you to add a legend to describe the pl...
Definition: mathplot.h:1478
bool PointIsInside(const double px, const double py) const
Is point inside this bounding box?
Definition: mathplot.h:577
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:3346
double m_sigma
Sigma value.
Definition: mathplot.h:2564
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:4724
Align the info in margin bottom-right.
Definition: mathplot.h:642
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2846
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1261
void ShowSeriesValues(const bool show)
Set if the series values shall be drawn to the plot.
Definition: mathplot.h:1567
bool PointIsInside(T point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:418
void SetSymbolSize(const int size)
Set symbol size.
Definition: mathplot.h:1792
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1168
Classic Gaussian distribution f(x) = exp(-(x-μ)²/2σ²)/sqrt(2πσ²)
Definition: mathplot.h:2545
Plot layer, abstract base class.
Definition: mathplot.h:843
void SetColumnWidth(const double colWidth)
Set the bar width in plot units.
Definition: mathplot.h:2699
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:3892
sub type for mpMovableObject function
Definition: mathplot.h:732
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:5179
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:1037
Group of properties, derived from the axis step size and range, that control how scale labels are for...
Definition: mathplot.h:2854
mpRange< double > m_rangeY
Y range.
Definition: mathplot.h:2528
~mpFXYVector() override
destrutor
Definition: mathplot.h:2279
void EnableDoubleBuffer(const bool enabled)
Deprecated: Enable/disable the double-buffering of the window, eliminating the flicker (default=enabl...
Definition: mathplot.h:3938
enum __Scale_Type mpScaleType
sub_type values for mpLAYER_AXIS
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:4729
void UpdateBox(const wxRect &plotArea)
Update the drawable magnet area from a wxRect.
Definition: mathplot.h:3416
#define MP_ISNOTNULL(x)
Nullity test. Old solution is to test according small epsilon: (fabs(x) > MP_EPSILON) ...
Definition: mathplot.h:176
mpFloatRectSimple(const mpRange< double > x_, const mpRange< double > y_)
Construct a simple rectangular box.
Definition: mathplot.h:570
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:4786
mpRange< double > m_rangeY
Range min and max on y axis.
Definition: mathplot.h:2355
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5047
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:3130
sub type for mpFX function
Definition: mathplot.h:728
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2955
double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:5033
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:2159
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:3126
T min
The min value of the range.
Definition: mathplot.h:271
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:4727
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2076
void SetShowName(const bool show)
Set Name visibility.
Definition: mathplot.h:1070
wxRect GetRect(void) const
Create standard wxWidgets rectangle defined by this object&#39;s start and end points.
Definition: mathplot.h:256
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:4735
std::vector< double > m_shape_xs
Shape vertices in object-local X coordinates.
Definition: mathplot.h:5074
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:5337
void SetInfoCoordType(const infoCoordType type)
Set the type of info coordinates to be displayed (axis, closest series, or all series) ...
Definition: mathplot.h:1428
virtual bool IsLogAxis()
Get if we are in Logarithmic mode.
Definition: mathplot.h:3070
double ComputeY(const double x) override
The main computation of the FX function.
Definition: mathplot.h:2568
void UpdateBoundingBoxToInclude(const double px, const double py, const int yAxisID)
Ensure the bounding box includes the given point for the selected Y axis.
Definition: mathplot.h:4114
mpLegendDirection m_item_direction
Layout direction used when arranging legend entries.
Definition: mathplot.h:1649
double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:2786
mpRange< double > bound
Range min and max.
Definition: mathplot.h:3351
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1167
#define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class)
Definition for RTTI.
Definition: mathplot.h:189
bool m_isMonotonicX
Indicates if all all X values are monotonic, i.e increasing, which enables binary search...
Definition: mathplot.h:2349
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:879
Show the X and Y value of the closest series.
Definition: mathplot.h:1371
sub type for mpScaleY
Definition: mathplot.h:742
int m_BarWidth
Bar width in pixels when the XY series is drawn in bar mode.
Definition: mathplot.h:2222
mpRange< double > m_bitmapY
Range of the bitmap on y direction.
Definition: mathplot.h:5309
Vertical cursor is at mouse position.
Definition: mathplot.h:1597
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:4890
size_t GetMaxNOfPoints() const
Get maximum number of points to plot.
Definition: mathplot.h:1872
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1879
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:3373
Text box type layer.
Definition: mathplot.h:816
double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:5276
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:4459
void SetValue(const double value)
Set x or y value.
Definition: mathplot.h:1921
bool HasBBox() override
Text Layer has not bounding box.
Definition: mathplot.h:4854
Show axis coordinates at mouse position.
Definition: mathplot.h:1370
const wxString & GetWildcard(void) const
Get wildcard.
Definition: mathplot.h:4177
Line (horizontal or vertical) type layer.
Definition: mathplot.h:799
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2987
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition: mathplot.h:372
size_t m_endIndex
The end index indicating the last point inside plot area.
Definition: mathplot.h:2352