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 
265  int GetWidth() const
266  {
267  return right - left;
268  }
269 
274  int GetHeight() const
275  {
276  return bottom - top;
277  }
278 
279 };
280 static_assert(sizeof(mpRect) == 4 * sizeof(wxCoord));
281 
287 template<typename T>
288 struct mpRange
289 {
290  T min = 0;
291  T max = 0;
292 
295  {
296  min = 0;
297  max = 0;
298  }
299 
301  mpRange(T value1, T value2)
302  {
303  if (value1 < value2)
304  {
305  min = value1;
306  max = value2;
307  }
308  else
309  {
310  min = value2;
311  max = value1;
312  }
313  }
314 
316  void Set(T value_)
317  {
318  min = value_;
319  max = value_;
320  }
321 
323  void Set(T min_, T max_)
324  {
325  min = min_;
326  max = max_;
327  }
328 
330  void SetMin(T min_)
331  {
332  min = min_;
333  if (max < min)
334  max = min;
335  }
336 
338  void SetMax(T max_)
339  {
340  max = max_;
341  if (min > max)
342  min = max;
343  }
344 
346  void Assign(T value1, T value2)
347  {
348  if (value1 < value2)
349  {
350  min = value1;
351  max = value2;
352  }
353  else
354  {
355  min = value2;
356  max = value1;
357  }
358  }
359 
361  bool IsSet() const
362  {
363  return ((min != 0) || (max != 0));
364  }
365 
370  void Update(T value)
371  {
372  if (value < min)
373  min = value;
374  else if (value > max)
375  max = value;
376  }
377 
381  void Update(T min_, T max_)
382  {
383  if (min_ < min)
384  min = min_;
385  if (max_ > max)
386  max = max_;
387  }
388 
391  void Update(mpRange range)
392  {
393  if (range.min < min)
394  min = range.min;
395  if (range.max > max)
396  max = range.max;
397  }
398 
400  void Check(void)
401  {
402  if (min == max)
403  {
404  if (max > 0)
405  min = 0;
406  else
407  max = 0;
408  }
409  }
410 
412  T Length(void) const
413  {
414  return max - min;
415  }
416 
418  T GetCenter(void) const
419  {
420  return (min + max) / 2;
421  }
422 
424  T GetMaxAbs(void) const
425  {
426  return std::max(fabs(min), fabs(max));
427  }
428 
430  void ToLog(void)
431  {
432  min = (min > 0) ? log10(min) : 0;
433  max = (max > 0) ? log10(max) : 0;
434  }
435 
437  bool PointIsInside(T point) const
438  {
439  return ((point >= min) && (point <= max));
440  }
441 
442  #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
443  bool operator==(const mpRange&) const = default;
444  #else
445  bool operator==(const mpRange &other) const
447  {
448  return (min == other.min) && (max == other.max);
449  }
451  bool operator!=(const mpRange& other) const
452  {
453  return !(*this == other);
454  }
455  #endif
456 };
457 
463 struct [[deprecated("Deprecated! No longer used as X and Y are now separated")]] mpFloatRect
464 {
465  mpRange<double> x;
466  std::vector<mpRange<double>> y;
467 
474  mpFloatRect(mpWindow& w);
475 
477  mpFloatRect() = delete;
478 
485  bool PointIsInside(const double px, const double py, const size_t yAxisID = 0) const {
486  if (yAxisID < y.size())
487  {
488  if( (px < x.min || px > x.max) ||
489  (py < y[yAxisID].min || py > y[yAxisID].max))
490  {
491  return false;
492  }
493  }
494  else
495  {
496  return false;
497  }
498 
499  return true;
500  }
501 
508  void UpdateBoundingBoxToInclude(const double px, const double py, const size_t yAxisID = 0) {
509  assert(yAxisID < y.size());
510  if (yAxisID < y.size())
511  {
512  if (px < x.min ) x.min = px;
513  else if (px > x.max ) x.max = px;
514  if (py < y[yAxisID].min ) y[yAxisID].min = py;
515  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
516  }
517  }
518 
525  void InitializeBoundingBox(const double px, const double py, const size_t yAxisID = 0) {
526  assert(yAxisID < y.size());
527  if (yAxisID < y.size())
528  {
529  x.min = x.max = px;
530  y[yAxisID].min = y[yAxisID].max = py;
531  }
532  }
534  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
536 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
537  bool operator==(const mpFloatRect&) const = default;
538 #else
539  // We compare with an epsilon precision
540  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
541  bool operator==(const mpFloatRect& rect) const
542  {
543  auto Same = [](const double a, const double b) {
544  return std::fabs(a - b) < MP_EPSILON;
545  };
546 
547  // Compare scalar members
548  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
549  {
550  return false;
551  }
552 
553  // Compare vector sizes
554  if (y.size() != rect.y.size())
555  {
556  return false;
557  }
558 
559  // Compare each Y boundary
560  for (size_t i = 0; i < y.size(); ++i)
561  {
562  if (!Same(y[i].min, rect.y[i].min) ||
563  !Same(y[i].max, rect.y[i].max) )
564  {
565  return false;
566  }
567  }
568 
569  return true;
570  }
571 #endif
572 };
573 
580 {
583 
589  mpFloatRectSimple(const mpRange<double> x_, const mpRange<double> y_) : x(x_), y(y_) { };
590 
596  bool PointIsInside(const double px, const double py) const {
597  return x.PointIsInside(px) && y.PointIsInside(py);
598  }
599 
605  void UpdateBoundingBoxToInclude(const double px, const double py)
606  {
607  x.Update(px);
608  y.Update(py);
609  }
610 
615  void InitializeBoundingBox(const double px, const double py)
616  {
617  x.Set(px, px);
618  y.Set(py, py);
619  }
620 };
621 
624 struct mpPlotHit
625 {
626  wxColour colour;
627  wxRealPoint coords;
628 };
629 
633 enum
634 {
635  mpID_FIT = 2000,
643 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
644  mpID_CONFIG,
645 #endif // MP_ENABLE_CONFIG
649 };
650 
652 typedef enum __mp_Location_Type
653 {
664 } mpLocation;
665 
667 typedef enum __XAxis_Align_Type
668 {
674 } mpXAxis_Align;
675 
677 typedef enum __YAxis_Align_Type
678 {
684 } mpYAxis_Align;
685 
688 {
693 } mpPlot_Align;
694 
696 typedef enum __mp_Style_Type
697 {
701 } mpLegendStyle;
702 
705 {
709 
711 typedef enum __Symbol_Type
712 {
720 } mpSymbol;
721 
722 //-----------------------------------------------------------------------------
723 // mpLayer sub_type values
724 //-----------------------------------------------------------------------------
725 
727 typedef enum __Info_Type
728 {
733 } mpInfoType;
734 
736 typedef enum __Text_Type
737 {
741 } mpTextType;
742 
744 typedef enum __Function_Type
745 {
755 
757 typedef enum __Scale_Type
758 {
763 } mpScaleType;
764 
766 typedef enum __Chart_Type
767 {
772 } mpChartType;
773 
776 {
779 };
780 
783 {
803 };
804 
805 //-----------------------------------------------------------------------------
806 // mpLayer
807 //-----------------------------------------------------------------------------
808 
810 typedef enum __mp_Layer_Type
811 {
820 } mpLayerType;
821 
827 typedef enum __mp_Layer_ZOrder
828 {
837 } mpLayerZOrder;
838 
845 typedef enum __mp_Delete_Action
846 {
851 
862 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
863 {
864  public:
869  mpLayer(mpLayerType layerType);
870 
871  ~mpLayer() override
872  {
873  ;
874  }
875 
879  {
880  m_win = &w;
881  }
882 
890  virtual bool HasBBox()
891  {
892  return true;
893  }
894 
898  mpLayerType GetLayerType() const
899  {
900  return m_type;
901  }
902 
906  int GetLayerSubType() const
907  {
908  return m_subtype;
909  }
910 
916  virtual bool IsLayerType(const mpLayerType typeOfInterest, int *subtype)
917  {
918  *subtype = m_subtype;
919  return (m_type == typeOfInterest);
920  }
921 
925  virtual double GetMinX()
926  {
927  return -1.0;
928  }
929 
933  virtual double GetMaxX()
934  {
935  return 1.0;
936  }
937 
941  virtual double GetMinY()
942  {
943  return -1.0;
944  }
945 
949  virtual double GetMaxY()
950  {
951  return 1.0;
952  }
953 
995  void Plot(wxDC &dc, mpWindow &w);
996 
1000  void SetName(const wxString &name)
1001  {
1002  m_name = name;
1003  }
1004 
1008  const wxString& GetName() const
1009  {
1010  return m_name;
1011  }
1012 
1016  void SetFont(const wxFont &font)
1017  {
1018  m_font = font;
1019  }
1020 
1024  const wxFont& GetFont() const
1025  {
1026  return m_font;
1027  }
1028 
1032  void SetFontColour(const wxColour &colour)
1033  {
1034  m_fontcolour = colour;
1035  }
1036 
1040  const wxColour& GetFontColour() const
1041  {
1042  return m_fontcolour;
1043  }
1044 
1048  void SetPen(const wxPen &pen)
1049  {
1050  m_pen = pen;
1051  }
1052 
1056  const wxPen& GetPen() const
1057  {
1058  return m_pen;
1059  }
1060 
1063  void SetBrush(const wxBrush &brush)
1064  {
1065  if (brush == wxNullBrush)
1066  m_brush = *wxTRANSPARENT_BRUSH;
1067  else
1068  m_brush = brush;
1069  }
1070 
1074  void SetBrush(const wxColour &colour, enum wxBrushStyle style = wxBRUSHSTYLE_SOLID)
1075  {
1076  m_brush.SetColour(colour);
1077  m_brush.SetStyle(style);
1078  }
1079 
1082  const wxBrush& GetBrush() const
1083  {
1084  return m_brush;
1085  }
1086 
1089  void SetShowName(const bool show)
1090  {
1091  m_showName = show;
1092  }
1093 
1096  bool GetShowName() const
1097  {
1098  return m_showName;
1099  }
1100 
1103  void SetDrawOutsideMargins(const bool drawModeOutside)
1104  {
1105  m_drawOutsideMargins = drawModeOutside;
1106  }
1107 
1111  {
1112  return m_drawOutsideMargins;
1113  }
1114 
1119  wxBitmap GetColourSquare(int side = 16);
1120 
1123  bool IsVisible() const
1124  {
1125  return m_visible;
1126  }
1127 
1130  virtual void SetVisible(const bool show)
1131  {
1132  m_visible = show;
1133  }
1134 
1137  bool IsTractable() const
1138  {
1139  return m_tractable;
1140  }
1141 
1144  virtual void SetTractable(const bool track)
1145  {
1146  m_tractable = track;
1147  }
1148 
1151  void SetAlign(const int align)
1152  {
1153  m_flags = align;
1154  }
1155 
1158  int GetAlign() const
1159  {
1160  return m_flags;
1161  }
1162 
1165  void SetCanDelete(const bool canDelete)
1166  {
1167  m_CanDelete = canDelete;
1168  }
1169 
1172  bool GetCanDelete(void) const
1173  {
1174  return m_CanDelete;
1175  }
1176 
1179  mpLayerZOrder GetZIndex(void) const
1180  {
1181  return m_ZIndex;
1182  }
1183 
1184  protected:
1185  const mpLayerType m_type;
1188  wxFont m_font;
1189  wxColour m_fontcolour;
1190  wxPen m_pen;
1191  wxBrush m_brush;
1192  wxString m_name;
1193  bool m_showName;
1195  bool m_visible;
1197  int m_flags;
1200  mpLayerZOrder m_ZIndex;
1201 
1204  void UpdateContext(wxDC &dc) const;
1205 
1210  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1211 
1216  virtual bool DoBeforePlot()
1217  {
1218  return true;
1219  }
1220 
1227  void CheckLog(double *x, double *y, int yAxisID);
1228 
1229  private:
1230  bool m_busy;
1231  mpLayer() = delete; // default ctor not implemented/permitted
1232 
1234 };
1235 
1236 //-----------------------------------------------------------------------------
1237 // mpInfoLayer
1238 //-----------------------------------------------------------------------------
1239 
1246 {
1247  public:
1249  mpInfoLayer();
1250 
1255  mpInfoLayer(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1256 
1258  ~mpInfoLayer() override;
1259 
1262  void SetVisible(bool show) override;
1263 
1268  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1269 
1272  bool HasBBox() override
1273  {
1274  return false;
1275  }
1276 
1279  [[deprecated("Use Show() instead")]]
1280  virtual void ErasePlot(wxDC&, mpWindow&) {};
1281 
1285  virtual bool Inside(const wxPoint &point);
1286 
1290  virtual void Move(wxPoint delta, mpWindow &w);
1291 
1293  virtual void UpdateReference();
1294 
1297  wxPoint GetPosition() const
1298  {
1299  return m_dim.GetPosition();
1300  }
1301 
1304  void SetInitialPosition(const wxPoint pos)
1305  {
1306  m_relX = pos.x / 100.0;
1307  m_relY = pos.y / 100.0;
1308  }
1309 
1312  wxSize GetSize() const
1313  {
1314  return m_dim.GetSize();
1315  }
1316 
1319  const wxRect& GetRectangle() const
1320  {
1321  return m_dim;
1322  }
1323 
1326  void SetLocation(const mpLocation location)
1327  {
1328  m_location = location;
1329  }
1330 
1333  mpLocation GetLocation() const
1334  {
1335  return m_location;
1336  }
1337 
1338  protected:
1339  wxRect m_dim;
1340  wxBitmap* m_info_bmp;
1341  wxPoint m_reference;
1342  double m_relX;
1343  double m_relY;
1344  mpLocation m_location;
1345 
1350  void DoPlot(wxDC &dc, mpWindow &w) override;
1351 
1354  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1355 
1356  private:
1357 
1359 };
1360 
1366 {
1367  public:
1369  mpInfoCoords();
1370 
1372  mpInfoCoords(mpLocation location);
1373 
1378  mpInfoCoords(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1379 
1381  ~mpInfoCoords() override
1382  {
1383  ;
1384  }
1385 
1388  {
1391  infoCoord_allSeries
1392  };
1393 
1397  void UpdateInfo(mpWindow &w, wxEvent &event) override;
1398 
1401  [[deprecated("Use Show() instead")]]
1402  void ErasePlot(wxDC&, mpWindow&) override {};
1403 
1406  void Show(const bool show)
1407  {
1408  m_show = show;
1409  }
1410 
1413  bool IsShown() const
1414  {
1415  return m_show;
1416  }
1417 
1422  bool ShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
1423  {
1424  return IsVisible() && (GetDrawOutsideMargins() || plotArea.Contains(mousePos));
1425  }
1426 
1430  void SetLabelMode(const mpLabelType mode, const unsigned int time_conv = MP_X_RAWTIME)
1431  {
1432  m_labelType = mode;
1433  m_timeConv = time_conv;
1434  }
1435 
1438  [[deprecated("Deprecated, use SetInfoCoordType instead")]]
1439  void SetSeriesCoord(const bool show)
1440  {
1441  m_infoCoordType = show ? infoCoord_closestSeries : infoCoord_axis;
1442  }
1443 
1448  {
1449  m_infoCoordType = type;
1450  }
1451 
1456  {
1457  return m_infoCoordType;
1458  }
1459 
1465  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1466 
1470  void DrawContent(wxDC &dc, mpWindow &w);
1471 
1472  protected:
1473  bool m_show;
1474  wxString m_content;
1476  unsigned int m_timeConv;
1477  wxCoord m_mouseX;
1478  wxCoord m_mouseY;
1480  std::vector<wxColor> m_seriesColors;
1481 
1486  void DoPlot(wxDC &dc, mpWindow &w) override;
1487 
1488  private:
1489 
1491 };
1492 
1498 {
1499  public:
1501  mpInfoLegend();
1502 
1508  mpInfoLegend(wxPoint pos, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginUser);
1509 
1511  ~mpInfoLegend() override {}
1512 
1515  void SetItemMode(const mpLegendStyle mode)
1516  {
1517  m_item_mode = mode;
1518  m_needs_update = true;
1519  }
1520 
1522  mpLegendStyle GetItemMode() const
1523  {
1524  return m_item_mode;
1525  }
1526 
1529  void SetItemDirection(const mpLegendDirection mode)
1530  {
1531  m_item_direction = mode;
1532  m_needs_update = true;
1533  }
1534 
1536  mpLegendDirection GetItemDirection() const
1537  {
1538  return m_item_direction;
1539  }
1540 
1543  {
1544  m_needs_update = true;
1545  }
1546 
1549  void ShowDraggedSeries(const bool active)
1550  {
1551  m_showDraggedSeries = active;
1552  }
1553 
1557  {
1558  return m_showDraggedSeries;
1559  }
1560 
1563  void EnableSeriesValues(const bool enable)
1564  {
1565  m_enableSeriesValues = enable;
1566  m_maxSeriesValueWidth = 0;
1567  }
1568 
1572  {
1573  return m_enableSeriesValues;
1574  }
1575 
1579  bool SeriesValuesShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
1580  {
1581  return m_enableSeriesValues && plotArea.Contains(mousePos);
1582  }
1583 
1586  void ShowSeriesValues(const bool show)
1587  {
1588  m_showSeriesValues = show;
1589  }
1590 
1593  bool IsSeriesValuesShown() const
1594  {
1595  return m_showSeriesValues && IsVisible();
1596  }
1597 
1600  void IndicateSeriesIntersection(const bool enable)
1601  {
1602  m_indicateSeriesIntersection = enable;
1603  }
1604 
1607  void SetVerticalCursorFollowMouse();
1608 
1611  void SetVerticalCursorFixed(double posX);
1612 
1615  {
1617  CursorMode_fixed
1618  };
1619 
1623  {
1624  return m_verticalCursorMode;
1625  }
1626 
1630  wxCoord GetVerticalCursorX() const;
1631 
1637  int GetLegendHitRegion(wxPoint mousePos);
1638 
1645  void DrawDraggedSeries(wxDC& dc, mpWindow &w) const;
1646 
1650  void DrawContent(wxDC &dc, mpWindow &w);
1651 
1654  static void RestoreAxisHighlighting(mpWindow &w);
1655 
1657  enum HitCode : int
1658  {
1659  HitNone = -1,
1660  HitHeader = -2
1661  };
1662 
1663  mpFunction* m_selectedSeries = nullptr;
1664  mpOptional_int m_lastHoveredAxisID = std::nullopt;
1665 
1666  protected:
1667  mpLegendStyle m_item_mode;
1668  mpLegendDirection m_item_direction;
1670  wxString m_headerString = wxString::FromUTF8("≡");
1671 
1676  void DoPlot(wxDC &dc, mpWindow &w) override;
1677 
1678  private:
1680  struct LegendDetail
1681  {
1682  unsigned int layerIdx;
1683  wxCoord legendEnd;
1684  };
1686  std::vector<LegendDetail> m_LegendDetailList;
1687  wxCoord m_headerEnd;
1688  bool m_needs_update;
1689  int m_maxSeriesValueWidth;
1690  bool m_enableSeriesValues;
1691  bool m_showSeriesValues;
1692  bool m_indicateSeriesIntersection;
1693  VerticalCursorMode m_verticalCursorMode;
1694  double m_verticalCursorPosX;
1695 
1706  void UpdateBitmap(wxDC &dc, mpWindow &w);
1707 
1716  int GetMaxLabelWidth(wxDC &dc, mpWindow &w) const;
1717 
1738  int DrawSeriesValue(wxDC& dc, mpWindow& w, mpFunction& function, int posX, int posY, int labelHeight, int labelWidth, int maxLabelWidth);
1739 
1744  void DrawVerticalCursor(wxDC &dc, mpWindow &w);
1745 
1746  private:
1748 };
1749 
1750 //-----------------------------------------------------------------------------
1751 // mpLayer implementations - functions
1752 //-----------------------------------------------------------------------------
1753 
1754 
1762 {
1763  public:
1769  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1770 
1774  void SetContinuity(const bool continuity)
1775  {
1776  m_continuous = continuity;
1777  }
1778 
1782  bool GetContinuity() const
1783  {
1784  return m_continuous;
1785  }
1786 
1789  void SetStep(const unsigned int step)
1790  {
1791  m_step = step;
1792  }
1793 
1796  unsigned int GetStep() const
1797  {
1798  return m_step;
1799  }
1800 
1803  void SetSymbol(const mpSymbol symbol)
1804  {
1805  m_symbol = symbol;
1806  }
1807 
1810  mpSymbol GetSymbol() const
1811  {
1812  return m_symbol;
1813  }
1814 
1817  void SetSymbolSize(const int size)
1818  {
1819  m_symbolSize = size;
1820  }
1821 
1824  int GetSymbolSize() const
1825  {
1826  return m_symbolSize;
1827  }
1828 
1832  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1833 
1837  std::optional<double> GetSeriesValue(double xValue);
1838 
1842  int GetYAxisID() const
1843  {
1844  return m_yAxisID;
1845  }
1846 
1851  void SetYAxisID(const unsigned int yAxisID)
1852  {
1853  m_yAxisID = yAxisID;
1854  }
1855 
1859  void SetLegendIsAlwaysVisible(const bool alwaysVisible)
1860  {
1861  m_LegendIsAlwaysVisible = alwaysVisible;
1862  }
1863 
1868  {
1869  return m_LegendIsAlwaysVisible;
1870  }
1871 
1875  void SetAutoStep(const bool enable)
1876  {
1877  m_autoStep = enable;
1878  }
1879 
1882  bool GetAutoStep() const
1883  {
1884  return m_autoStep;
1885  }
1886 
1890  void SetMaxNOfPoints(const size_t nOfPoints)
1891  {
1892  m_maxNOfPoints = nOfPoints;
1893  }
1894 
1897  size_t GetMaxNOfPoints() const
1898  {
1899  return m_maxNOfPoints;
1900  }
1901 
1902  protected:
1904  mpSymbol m_symbol;
1906  unsigned int m_step;
1909  bool m_autoStep;
1911 
1912  private:
1914 };
1915 
1919 {
1920  public:
1927  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1928 
1929  // We don't want to include line (horizontal or vertical) in BBox computation
1930  bool HasBBox() override
1931  {
1932  return false;
1933  }
1934 
1938  double GetValue() const
1939  {
1940  return m_value;
1941  }
1942 
1946  void SetValue(const double value)
1947  {
1948  m_value = value;
1949  }
1950 
1954  bool IsHorizontal(void) const
1955  {
1956  return m_IsHorizontal;
1957  }
1958 
1959  protected:
1960  double m_value;
1962 
1963  private:
1965 };
1966 
1970 {
1971  public:
1978  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1979 
1983  void SetYValue(const double yvalue)
1984  {
1985  SetValue(yvalue);
1986  }
1987 
1988  protected:
1989 
1990  void DoPlot(wxDC &dc, mpWindow &w) override;
1991 
1992  private:
1994 };
1995 
1999 {
2000  public:
2006  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
2007 
2011  void SetXValue(const double xvalue)
2012  {
2013  SetValue(xvalue);
2014  }
2015 
2016  protected:
2017 
2018  void DoPlot(wxDC &dc, mpWindow &w) override;
2019 
2024  bool DoBeforePlot() override
2025  {
2026  return true;
2027  }
2028 
2029  private:
2031 };
2032 
2040 {
2041  public:
2046  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
2047 
2053  virtual double GetY(double x) = 0;
2054 
2061  double DoGetY(double x);
2062 
2067  void DefineDoGetY(void);
2068 
2069  protected:
2070 
2071  double (mpFX::*pDoGetY)(double x);
2072 
2077  void DoPlot(wxDC &dc, mpWindow &w) override;
2078 
2083  double NormalDoGetY(double x);
2084 
2089  double LogDoGetY(double x);
2090 
2091  private:
2093 };
2094 
2102 {
2103  public:
2108  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
2109 
2115  virtual double GetX(double y) = 0;
2116 
2123  double DoGetX(double y);
2124 
2129  void DefineDoGetX(void);
2130 
2131  protected:
2132 
2133  double (mpFY::*pDoGetX)(double y);
2134 
2139  void DoPlot(wxDC &dc, mpWindow &w) override;
2140 
2145  double NormalDoGetX(double y);
2146 
2151  double LogDoGetX(double y);
2152 
2153  private:
2155 };
2156 
2167 {
2168  public:
2174  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2175 
2179  virtual void Rewind() = 0;
2180 
2184  virtual void Clear()
2185  {
2186  ;
2187  }
2188 
2192  virtual size_t GetSize()
2193  {
2194  return 0;
2195  }
2196 
2203  virtual bool GetNextXY(double *x, double *y) = 0;
2204 
2211  bool DoGetNextXY(double *x, double *y);
2212 
2217  void SetViewMode(bool asBar);
2218 
2223  int GetBarWidth(void) const
2224  {
2225  return m_BarWidth;
2226  }
2227 
2232  bool ViewAsBar(void) const
2233  {
2234  return m_ViewAsBar;
2235  }
2236 
2237  protected:
2238 
2239  // Data to calculate label positioning
2242 
2243  // Min delta between 2 x coordinate (used for view as bar)
2244  double m_deltaX;
2245  double m_deltaY;
2246 
2248 
2249  bool m_ViewAsBar = false;
2250 
2257  void DoPlot(wxDC &dc, mpWindow &w) override;
2258 
2263  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
2264 
2265  private:
2267 };
2268 
2269 //-----------------------------------------------------------------------------
2270 // mpFXYVector - provided by Jose Luis Blanco
2271 //-----------------------------------------------------------------------------
2272 
2293 {
2294  public:
2300  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2301 
2304  ~mpFXYVector() override
2305  {
2306  Clear();
2307  }
2308 
2313  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
2314 
2318  void Clear() override;
2319 
2324  size_t GetSize() override
2325  {
2326  return m_xs.size();
2327  }
2328 
2330  const std::vector<double>& GetXData() const
2331  {
2332  return m_xs;
2333  }
2334 
2336  const std::vector<double>& GetYData() const
2337  {
2338  return m_ys;
2339  }
2340 
2348  bool AddData(double x, double y, bool updatePlot);
2349 
2356  void SetReserve(const int reserve)
2357  {
2358  m_reserveXY = reserve;
2359  m_xs.reserve(m_reserveXY);
2360  m_ys.reserve(m_reserveXY);
2361  }
2362 
2366  int GetReserve() const
2367  {
2368  return m_reserveXY;
2369  }
2370 
2371  protected:
2372  std::vector<double> m_xs;
2373  std::vector<double> m_ys;
2376  size_t m_index;
2377  size_t m_endIndex;
2379  double m_lastX;
2381  double m_lastY;
2382 
2387  void Rewind() override;
2388 
2395  bool GetNextXY(double *x, double *y) override;
2396 
2401  void DrawAddedPoint(double x, double y);
2402 
2405  double GetMinX()override
2406  {
2407  if (m_ViewAsBar)
2408  {
2409  // Make extra space for outer bars
2410  return m_rangeX.min - (m_deltaX / 2);
2411  }
2412  else
2413  {
2414  return m_rangeX.min;
2415  }
2416  }
2417 
2420  double GetMinY() override
2421  {
2422  return m_rangeY.min;
2423  }
2424 
2427  double GetMaxX() override
2428  {
2429  if(m_ViewAsBar)
2430  {
2431  // Make extra space for outer bars
2432  return m_rangeX.max + (m_deltaX / 2);
2433  }
2434  else
2435  {
2436  return m_rangeX.max;
2437  }
2438  }
2439 
2442  double GetMaxY() override
2443  {
2444  return m_rangeY.max;
2445  }
2446 
2447  private:
2450  void First_Point(double x, double y);
2451 
2454  static void Check_Limit(double val, mpRange<double> *range, double *last, double *delta);
2455 
2457 };
2458 
2468 {
2469  public:
2473  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
2474 
2480  virtual double GetY(double x) = 0;
2481 
2482  protected:
2483 
2488  void DoPlot(wxDC &dc, mpWindow &w) override;
2489 
2490  private:
2492 };
2493 
2498 class mpFXGeneric: public mpFX
2499 {
2500  public:
2505  mpFXGeneric(const wxString &name = wxT("Generic FX function"), const int flags = mpALIGN_LEFT, const unsigned int yAxisID = 0) :
2506  mpFX(name, flags, yAxisID)
2507  {
2508  const wxPen FXpen(*wxBLUE, 1, wxPENSTYLE_SOLID);
2509  SetDrawOutsideMargins(false);
2510  SetContinuity(true);
2511  SetPen(FXpen);
2512  SetStep(8); // Draw one point over eight
2513  }
2514 
2519  double GetY(const double x) override
2520  {
2521  double y;
2522  try
2523  {
2524  y = ComputeY(x);
2525  }
2526  catch (...)
2527  {
2528  y = 0;
2529  }
2530  m_rangeY.Update(y);
2531  return y;
2532  }
2533 
2538  double GetMinY() override
2539  {
2540  return m_rangeY.min;
2541  }
2542 
2547  double GetMaxY() override
2548  {
2549  return m_rangeY.max;
2550  }
2551 
2552  protected:
2554 
2560  virtual double ComputeY(double x) = 0;
2561 
2562  private:
2564 };
2565 
2571 {
2572  public:
2578  mpGaussian(const double mu, const double sigma) :
2579  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2580  {
2581  m_mu = mu;
2582  m_sigma = sigma;
2583  m_variance = sigma * sigma;
2584  m_const = 1.0 / sqrt(2.0 * M_PI * m_variance);
2585  }
2586 
2587  protected:
2588  double m_mu;
2589  double m_sigma;
2590  double m_variance;
2591  double m_const;
2592 
2593  double ComputeY(const double x) override
2594  {
2595  return m_const * exp(-(x - m_mu) * (x - m_mu) / (2.0 * m_variance));
2596  }
2597 
2598  private:
2600 };
2601 
2606 class mpNormal: public mpFXGeneric
2607 {
2608  public:
2614  mpNormal(const double mu, const double sigma) :
2615  mpFXGeneric(wxT("Normal"), mpALIGN_LEFT)
2616  {
2617  m_mu = mu;
2618  m_sigma = sigma;
2619  m_variance = sigma * sigma;
2620  m_const = 1.0 / (m_variance * sqrt(2.0 * M_PI));
2621  }
2622 
2623  protected:
2624  double m_mu;
2625  double m_sigma;
2626  double m_variance;
2627  double m_const;
2628 
2629  double ComputeY(const double x) override
2630  {
2631  if (x < 0)
2632  return 0.0;
2633  else
2634  {
2635  const double tmp = log(x) - m_mu;
2636  return m_const * exp(-tmp * tmp / (2.0 * m_variance)) / x;
2637  }
2638  }
2639 
2640  private:
2642 };
2643 
2644 //-----------------------------------------------------------------------------
2645 // mpChart
2646 //-----------------------------------------------------------------------------
2650 {
2651  public:
2653  mpChart(const wxString &name = wxEmptyString);
2654 
2656  ~mpChart() override
2657  {
2658  Clear();
2659  }
2660 
2663  void SetChartValues(const std::vector<double> &data);
2664 
2667  void SetChartLabels(const std::vector<std::string> &labelArray);
2668 
2673  void AddData(const double &data, const std::string &label);
2674 
2678  virtual void Clear();
2679 
2680  bool HasBBox() override
2681  {
2682  return (values.size() > 0);
2683  }
2684 
2685  protected:
2686  std::vector<double> values;
2687  std::vector<std::string> labels;
2688 
2689  double m_max_value;
2690  double m_total_value;
2691 
2692  private:
2694 };
2695 
2696 //-----------------------------------------------------------------------------
2697 // mpBarChart - provided by Jose Davide Rondini
2698 //-----------------------------------------------------------------------------
2699 /* Defines for bar charts label positioning. */
2700 #define mpBAR_NONE 0
2701 #define mpBAR_AXIS_H 1
2702 #define mpBAR_AXIS_V 2
2703 #define mpBAR_INSIDE 3
2704 #define mpBAR_TOP 4
2705 
2706 
2709 {
2710  public:
2712  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2713 
2715  ~mpBarChart() override
2716  {
2717  Clear();
2718  }
2719 
2721  void SetBarColour(const wxColour &colour);
2722 
2724  void SetColumnWidth(const double colWidth)
2725  {
2726  m_width = colWidth;
2727  }
2728 
2730  void SetBarLabelPosition(int position);
2731 
2735  double GetMinX() override;
2736 
2740  double GetMaxX() override;
2741 
2745  double GetMinY() override;
2746 
2750  double GetMaxY() override;
2751 
2752  protected:
2753 
2754  double m_width;
2755  wxColour m_barColour;
2757  double m_labelAngle;
2758 
2763  void DoPlot(wxDC &dc, mpWindow &w) override;
2764 
2765  private:
2767 };
2768 
2773 {
2774  public:
2778  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2779 
2781  ~mpPieChart() override
2782  {
2783  Clear();
2784  colours.clear();
2785  }
2786 
2790  void SetCenter(const wxPoint center)
2791  {
2792  m_center = center;
2793  }
2794 
2798  wxPoint GetCenter(void) const
2799  {
2800  return m_center;
2801  }
2802 
2806  void SetPieColours(const std::vector<wxColour> &colourArray);
2807 
2811  double GetMinX() override
2812  {
2813  return m_center.x - m_radius;
2814  }
2815 
2819  double GetMaxX() override
2820  {
2821  return m_center.x + m_radius;
2822  }
2823 
2827  double GetMinY() override
2828  {
2829  return m_center.y - m_radius;
2830  }
2831 
2835  double GetMaxY() override
2836  {
2837  return m_center.y + m_radius;
2838  }
2839 
2840  protected:
2841 
2842  double m_radius;
2843  wxPoint m_center;
2844  std::vector<wxColour> colours;
2845 
2850  void DoPlot(wxDC &dc, mpWindow &w) override;
2851 
2853  const wxColour& GetColour(unsigned int id);
2854 
2855  private:
2857 };
2858 
2861 //-----------------------------------------------------------------------------
2862 // mpLayer implementations - furniture (scales, ...)
2863 //-----------------------------------------------------------------------------
2872 {
2873  public:
2880  {
2881  double step = 0.0;
2882  double maxAxisValue = 0.0;
2883  bool UseScientific = false;
2884  int SignificantDigits = 0;
2885  int DecimalDigits = 0;
2886  double EpsilonScale = 0.0;
2887  };
2888 
2896  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, mpOptional_uint axisID = std::nullopt);
2897 
2901  bool HasBBox() override
2902  {
2903  return false;
2904  }
2905 
2909  int GetAxisID(void) const
2910  {
2911  return m_axisID;
2912  }
2913 
2918  void SetAxisID(const unsigned int yAxisID)
2919  {
2920  m_axisID = yAxisID;
2921  }
2922 
2925  void ShowTicks(const bool ticks)
2926  {
2927  m_ticks = ticks;
2928  }
2929 
2932  bool GetShowTicks() const
2933  {
2934  return m_ticks;
2935  }
2936 
2939  void ShowGrids(const bool grids)
2940  {
2941  m_grids = grids;
2942  }
2943 
2946  bool GetShowGrids() const
2947  {
2948  return m_grids;
2949  }
2950 
2955  void SetLabelFormat(const wxString &format, const bool updateLabelMode = false)
2956  {
2957  m_labelFormat = format;
2958  if (updateLabelMode)
2959  m_labelType = mpLabel_USER;
2960  }
2961 
2965  {
2966  return m_labelType;
2967  }
2968 
2972  void SetLabelMode(const mpLabelType mode, const unsigned int time_conv = MP_X_RAWTIME)
2973  {
2974  m_labelType = mode;
2975  m_timeConv = time_conv;
2976  }
2977 
2980  const wxString& GetLabelFormat() const
2981  {
2982  return m_labelFormat;
2983  }
2984 
2988  void SetGridPen(const wxPen &pen)
2989  {
2990  m_gridpen = pen;
2991  }
2992 
2996  const wxPen& GetGridPen() const
2997  {
2998  return m_gridpen;
2999  }
3000 
3004  void SetAuto(const bool automaticScalingIsEnabled)
3005  {
3006  m_auto = automaticScalingIsEnabled;
3007  }
3008 
3012  bool GetAuto() const
3013  {
3014  return m_auto;
3015  }
3016 
3020  void SetMinScale(const double min)
3021  {
3022  m_axisRange.SetMin(min);
3023  }
3024 
3028  double GetMinScale() const
3029  {
3030  return m_axisRange.min;
3031  }
3032 
3036  void SetMaxScale(const double max)
3037  {
3038  m_axisRange.SetMax(max);
3039  }
3040 
3044  double GetMaxScale() const
3045  {
3046  return m_axisRange.max;
3047  }
3048 
3053  void SetScale(const double min, const double max)
3054  {
3055  m_axisRange.Set(min, max);
3056  }
3057 
3062  void GetScale(double *min, double *max) const
3063  {
3064  *min = m_axisRange.min;
3065  *max = m_axisRange.max;
3066  }
3067 
3071  void SetScale(const mpRange<double> range)
3072  {
3073  m_axisRange = range;
3074  }
3075 
3080  {
3081  return mpRange<double>(m_axisRange);
3082  }
3083 
3087  void SetHovering(const bool hover)
3088  {
3089  m_hover = hover;
3090  }
3091 
3095  virtual bool IsLogAxis()
3096  {
3097  return m_isLog;
3098  }
3099 
3103  virtual void SetLogAxis(const bool log)
3104  {
3105  m_isLog = log;
3106  }
3107 
3111  void SetCoordIsAlwaysVisible(const bool alwaysVisible)
3112  {
3113  m_CoordIsAlwaysVisible = alwaysVisible;
3114  }
3115 
3120  {
3121  return m_CoordIsAlwaysVisible;
3122  }
3123 
3130  static mpScaleConstraints ComputeScaleConstraints(double step, double maxAxisValue);
3131 
3138  wxString FormatLabelValue(double value, const mpScaleConstraints &constraints);
3139 
3140  protected:
3141  static constexpr wxCoord kTickSize = 4;
3142  static constexpr wxCoord kYAxisExtraSpace = 6;
3143  static constexpr wxCoord kYAxisTitleSpace = 2;
3144  static constexpr wxCoord kYAxisLabelSpace = 2;
3145  static constexpr wxCoord kXAxisTitleSpace = 3;
3146 
3147  int m_axisID;
3148  wxPen m_gridpen;
3149  bool m_ticks;
3150  bool m_grids;
3151  bool m_auto;
3154  unsigned int m_timeConv;
3155  wxString m_labelFormat;
3156  bool m_isLog;
3157  bool m_hover = false;
3159 
3162  virtual int GetOrigin(mpWindow &w) = 0;
3163 
3170  static double GetStep(double scale, int minLabelSpacing);
3171 
3179  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
3180 
3185  static wxString FormatLogValue(double n);
3186 
3193  int GetLabelWidth(double value, wxDC &dc, const mpScaleConstraints &constraints);
3194 
3199  static bool UseScientific(double maxAxisValue);
3200 
3206  static int GetSignificantDigits(double step, double maxAxisValue);
3207 
3212  static int GetDecimalDigits(double step);
3213 
3214  private:
3216 };
3217 
3218 
3225 {
3226  public:
3232  mpScaleX(const wxString &name = _T("X"), const int flags = mpALIGN_CENTERX, const bool grids = false, const mpLabelType type = mpLabel_AUTO) :
3233  mpScale(name, flags, grids, type)
3234  {
3235  m_subtype = mpsScaleX;
3236  }
3237 
3239  bool IsTopAxis() const
3240  {
3241  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
3242  }
3243 
3245  bool IsBottomAxis() const
3246  {
3247  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
3248  }
3249 
3250  protected:
3255  static int m_orgy;
3256 
3259  void DoPlot(wxDC &dc, mpWindow &w) override;
3260 
3261  int GetOrigin(mpWindow &w) override;
3262  void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) override;
3263 
3264  private:
3266 
3270  friend mpScaleY;
3271 };
3272 
3280 {
3281  public:
3289  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) :
3290  mpScale(name, flags, grids, labelType, yAxisID)
3291  {
3292  m_subtype = mpsScaleY;
3293  m_axisWidth = MP_Y_BORDER_SEPARATION;
3294  m_xPos = 0;
3295  m_autoHideAxis = false;
3296  }
3297 
3300  void UpdateAxisWidth(mpWindow &w);
3301 
3303  int GetAxisWidth() const
3304  {
3305  return m_axisWidth;
3306  }
3307 
3311  void SetAutoHideAxis(const bool autoHide)
3312  {
3313  m_autoHideAxis = autoHide;
3314  }
3315 
3317  bool GetAutoHideAxis() const
3318  {
3319  return m_autoHideAxis;
3320  }
3321 
3323  bool IsLeftAxis() const
3324  {
3325  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
3326  }
3327 
3329  bool IsRightAxis() const
3330  {
3331  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
3332  }
3333 
3335  bool IsInside(const wxCoord xPixel) const
3336  {
3337  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
3338  {
3339  return true;
3340  }
3341  return false;
3342  }
3343 
3344  protected:
3346  int m_xPos;
3348 
3351  void DoPlot(wxDC &dc, mpWindow &w) override;
3352 
3353  int GetOrigin(mpWindow &w) override;
3354  void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int maxLabelWidth) override;
3355 
3356  private:
3358 };
3359 
3360 //-----------------------------------------------------------------------------
3361 // mpWindow
3362 //-----------------------------------------------------------------------------
3363 
3369 #define mpMOUSEMODE_DRAG 0
3370 
3371 #define mpMOUSEMODE_ZOOMBOX 1
3372 
3375 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
3376 typedef std::deque<mpLayer*> mpLayerList;
3377 
3388 {
3389  mpScale* axis = nullptr;
3390  double scale = 1.0;
3391  double pos = 0;
3395 
3396  // Note: we don't use the default operator since we don't want to compare axis pointers
3398  bool operator==(const mpAxisData& other) const
3399  {
3400  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
3401  (bound == other.bound) && (desired == other.desired);
3402  }
3403 };
3404 
3406 typedef std::map<int, mpAxisData> mpAxisList;
3407 
3414 typedef enum {
3415  uXAxis = 1,
3416  uYAxis = 2,
3417  uXYAxis = 3
3418 } mpAxisUpdate;
3419 
3429 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
3430 
3437 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
3438 
3444 {
3445  public:
3446  mpMagnet()
3447  {
3448  m_enable = false;
3449  m_show = false;
3450  }
3451  ~mpMagnet()
3452  {
3453  ;
3454  }
3455 
3457  void Enable(const bool enable)
3458  {
3459  m_enable = enable;
3460  }
3461 
3463  bool IsEnabled() const
3464  {
3465  return m_enable;
3466  }
3467 
3469  void DrawCross(wxDC &dc, mpWindow &w);
3470 
3472  bool ShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
3473  {
3474  return m_enable && plotArea.Contains(mousePos);
3475  }
3476 
3478  void Show(const bool show)
3479  {
3480  m_show = show;
3481  }
3482 
3484  bool IsShown() const
3485  {
3486  return m_show;
3487  }
3488 
3489  private:
3490  bool m_enable;
3491  bool m_show;
3492 };
3493 
3515 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
3516 {
3517  public:
3518  mpWindow()
3519  {
3520  InitParameters();
3521  }
3522 
3530  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
3531  long flags = 0);
3532 
3533  ~mpWindow() override;
3534 
3538  wxMenu* GetPopupMenu()
3539  {
3540  return &m_popmenu;
3541  }
3542 
3551  bool AddLayer(mpLayer *layer, bool fit = true, bool refreshConfig = true);
3552 
3565  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
3566 
3572  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
3573 
3581  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true, bool refreshConfig = true);
3582 
3589  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
3590 
3596  mpLayer* GetLayer(int position);
3597 
3602  int GetLayerPosition(mpLayer* layer);
3603 
3610  mpLayer* GetLayersType(int position, mpLayerType type);
3611 
3618  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
3619 
3625  mpScale* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
3626 
3635  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
3636 
3644  std::optional<mpPlotHit> GetClosestPlot(wxCoord ix, wxCoord iy);
3645 
3650  mpLayer* GetLayerByName(const wxString &name);
3651 
3656  mpLayer* GetLayerByClassName(const wxString &name);
3657 
3661  void RefreshLegend(void);
3662 
3668  bool IsYAxisUsedByFunction(int yAxisID);
3669 
3675  bool ShouldDrawYAxis(const mpScaleY &yAxis);
3676 
3677 
3681  mpScaleX* GetLayerXAxis() const;
3682 
3686  mpScaleY* GetLayerYAxis(int yAxisID);
3687 
3691  void SetScaleX(const double scaleX)
3692  {
3693  if (MP_ISNOTNULL(scaleX))
3694  {
3695  m_AxisDataX.scale = scaleX;
3696  UpdateDesiredBoundingBox(uXAxis);
3697  }
3698  UpdateAll();
3699  }
3700 
3705  double GetScaleX(void) const
3706  {
3707  return m_AxisDataX.scale;
3708  }
3709 
3714  void SetScaleY(const double scaleY, const int yAxisID)
3715  {
3716  assert(m_AxisDataYList.count(yAxisID) != 0);
3717  if (MP_ISNOTNULL(scaleY))
3718  {
3719  m_AxisDataYList[yAxisID].scale = scaleY;
3720  UpdateDesiredBoundingBox(uYAxis);
3721  }
3722  UpdateAll();
3723  }
3724 
3730  double GetScaleY(const int yAxisID)
3731  {
3732  assert(m_AxisDataYList.count(yAxisID) != 0);
3733  return m_AxisDataYList[yAxisID].scale;
3734  } // Schaling's method: maybe another method exists with the same name
3735 
3736  [[deprecated("Incomplete, use UpdateBBox instead")]]
3739  void SetBound();
3740 
3743  {
3744  return m_AxisDataX.bound;
3745  }
3746 
3749  {
3750  return m_AxisDataX.desired;
3751  }
3752 
3756  mpRange<double> GetBoundY(const int yAxisID)
3757  {
3758  assert(m_AxisDataYList.count(yAxisID) != 0);
3759  return m_AxisDataYList[yAxisID].bound;
3760  }
3761 
3766  {
3767  assert(m_AxisDataYList.count(yAxisID) != 0);
3768  return m_AxisDataYList[yAxisID].desired;
3769  }
3770 
3775  {
3776  return mpRange<double>(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale), m_AxisDataX.pos + ((m_margin.left + GetPlotWidth()) / m_AxisDataX.scale));
3777  }
3778 
3783  mpRange<double> GetVisibleRangeY(const unsigned int yAxisID = 0)
3784  {
3785  assert(m_AxisDataYList.count(yAxisID) != 0);
3786  mpAxisData& yData = m_AxisDataYList[yAxisID];
3787  return mpRange<double>(yData.pos - ((m_margin.top + GetPlotHeight()) / yData.scale), yData.pos - (m_margin.top / yData.scale));
3788  }
3789 
3794  std::unordered_map<int, mpRange<double>> GetAllBoundY()
3795  {
3796  std::unordered_map<int, mpRange<double>> yRange;
3797  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
3798  {
3799  yRange[m_yID] = m_yData.bound;
3800  }
3801  return yRange;
3802  }
3803 
3808  std::unordered_map<int, mpRange<double>> GetAllDesiredY()
3809  {
3810  std::unordered_map<int, mpRange<double>> yRange;
3811  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
3812  {
3813  yRange[m_yID] = m_yData.desired;
3814  }
3815  return yRange;
3816  }
3817 
3821  void SetPosX(const double posX)
3822  {
3823  m_AxisDataX.pos = posX;
3824  UpdateDesiredBoundingBox(uXAxis);
3825  UpdateAll();
3826  }
3827 
3832  double GetPosX(void) const
3833  {
3834  return m_AxisDataX.pos;
3835  }
3836 
3841  void SetPosY(std::unordered_map<int, double>& posYList)
3842  {
3843  for (auto& [m_yID, m_yData] : m_AxisDataYList)
3844  {
3845  m_yData.pos = posYList[m_yID];
3846  }
3847  UpdateDesiredBoundingBox(uYAxis);
3848  UpdateAll();
3849  }
3850 
3856  double GetPosY(const int yAxisID)
3857  {
3858  assert(m_AxisDataYList.count(yAxisID) != 0);
3859  return m_AxisDataYList[yAxisID].pos;
3860  }
3861 
3865  int GetNOfYAxis(void) const
3866  {
3867  return (int)m_AxisDataYList.size();
3868  }
3869 
3873  mpAxisList GetAxisDataYList(void) const
3874  {
3875  return m_AxisDataYList;
3876  }
3877 
3883  void SetScreen(const int scrX, const int scrY)
3884  {
3885  m_scrX = scrX;
3886  m_scrY = scrY;
3887  UpdatePlotBoundaries();
3888  }
3889 
3896  int GetScreenX(void) const
3897  {
3898  return m_scrX;
3899  }
3900 
3907  int GetScreenY(void) const
3908  {
3909  return m_scrY;
3910  }
3911 
3917  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3918  {
3919  m_AxisDataX.pos = posX;
3920  SetPosY(posYList);
3921  }
3922 
3926  double p2x(const wxCoord pixelCoordX) const
3927  {
3928  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3929  }
3930 
3934  double p2y(const wxCoord pixelCoordY, const int yAxisID = 0)
3935  {
3936  assert(m_AxisDataYList.count(yAxisID) != 0);
3937  if (m_AxisDataYList.count(yAxisID) == 0)
3938  return 0.0;
3939  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3940  }
3941 
3945  wxCoord x2p(const double x) const
3946  {
3947  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3948  }
3949 
3953  wxCoord y2p(const double y, const int yAxisID = 0)
3954  {
3955  assert(m_AxisDataYList.count(yAxisID) != 0);
3956  if (m_AxisDataYList.count(yAxisID) == 0)
3957  return 0;
3958  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3959  }
3960 
3962  [[deprecated("Deprecated - use EnableBufferedPaintDC??")]]
3963  void EnableDoubleBuffer(const bool enabled)
3964  {
3965  EnableBufferedPaintDC(enabled);
3966  }
3967 
3971  void EnableBufferedPaintDC(const bool enabled)
3972  {
3973  m_enableBufferedPaintDC = enabled;
3974  }
3975 
3978  void EnableMousePanZoom(const bool enabled)
3979  {
3980  m_enableMouseNavigation = enabled;
3981  }
3982 
3988  void LockAspect(bool enable = true);
3989 
3994  bool IsAspectLocked() const
3995  {
3996  return m_lockaspect;
3997  }
3998 
4003  void Fit() override;
4004 
4011  void Fit(const mpRange<double> &rangeX, std::unordered_map<int, mpRange<double>> rangeY, bool updateDesired = true, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
4012 
4016  void FitX(void);
4017 
4022  void FitY(int yAxisID);
4023 
4028  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
4029 
4034  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
4035 
4037  void ZoomInX();
4038 
4040  void ZoomOutX();
4041 
4044  void ZoomInY(mpOptional_int yAxisID = std::nullopt);
4045 
4048  void ZoomOutY(mpOptional_int yAxisID = std::nullopt);
4049 
4054  void ZoomRect(wxPoint p0, wxPoint p1);
4055 
4057  void UpdateAll();
4058 
4059  // Added methods by Davide Rondini
4060 
4064  unsigned int CountLayers();
4065 
4068  unsigned int CountAllLayers() const
4069  {
4070  return (unsigned int)m_layers.size();
4071  }
4072 
4076  unsigned int CountLayersType(mpLayerType type);
4077 
4081  unsigned int CountLayersFXYPlot();
4082 
4090  {
4091  // Change on X axis
4092  if ((update & uXAxis) && (GetPlotWidth() > 0))
4093  {
4094  m_AxisDataX.desired = GetVisibleRangeX();
4095  }
4096 
4097  // Change on Y axis
4098  if ((update & uYAxis) && (GetPlotHeight() > 0))
4099  {
4100  for (auto& [yID, yData] : m_AxisDataYList)
4101  {
4102  yData.desired = GetVisibleRangeY(yID);
4103  }
4104  }
4105  }
4106 
4112  mpFloatRectSimple GetBoundingBox(const bool desired, const unsigned int yAxisID = 0)
4113  {
4114  assert(m_AxisDataYList.count(yAxisID) != 0);
4115  if (desired)
4116  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
4117  else
4118  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
4119  }
4120 
4126  bool PointIsInsideBound(const double px, const double py, const int yAxisID)
4127  {
4128  if (m_AxisDataYList.count(yAxisID) == 0)
4129  return false;
4130 
4131  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
4132  }
4133 
4139  void UpdateBoundingBoxToInclude(const double px, const double py, const int yAxisID)
4140  {
4141  if (m_AxisDataYList.count(yAxisID) == 0)
4142  return ;
4143 
4144  m_AxisDataX.bound.Update(px);
4145  m_AxisDataYList[yAxisID].bound.Update(py);
4146  }
4147 
4148  /* Initialize bounding box with an initial point
4149  * @param px point on x-axis
4150  * @param py point on y-axis
4151  * @param yAxisID the y-axis ID
4152  */
4154  void InitializeBoundingBox(const double px, const double py, const int yAxisID)
4155  {
4156  if (m_AxisDataYList.count(yAxisID) == 0)
4157  return ;
4158 
4159  m_AxisDataX.bound.Set(px, px);
4160  m_AxisDataYList[yAxisID].bound.Set(py, py);
4161  }
4162 
4165  void SetMPScrollbars(bool status);
4166 
4169  bool GetMPScrollbars() const
4170  {
4171  return m_enableScrollBars;
4172  }
4173 
4179  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
4180 
4184  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4185 
4189  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4190 
4194  void SetWildcard(const wxString &wildcard)
4195  {
4196  m_wildcard = wildcard;
4197  }
4198 
4202  const wxString& GetWildcard(void) const
4203  {
4204  return m_wildcard;
4205  }
4206 
4214  bool LoadFile(const wxString &filename = wxEmptyString);
4215 
4220  void SetDefaultDir(const wxString &dirname)
4221  {
4222  m_DefaultDir = dirname;
4223  }
4224 
4228 
4233 
4239  static void SetDefaultLegendIsAlwaysVisible(const bool visible)
4240  {
4241  m_DefaultLegendIsAlwaysVisible = visible;
4242  }
4243 
4248 
4249 
4254  void SetAutoFit(const bool autoFit)
4255  {
4256  m_autoFit = autoFit;
4257  }
4258 
4265  void SetMargins(int top, int right, int bottom, int left);
4266 
4268  void UpdateMargins();
4269 
4272  void UpdatePlotBoundaries();
4273 
4275  void SetMarginTop(const int top)
4276  {
4277  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4278  }
4279 
4283  int GetMarginTop(const bool minusExtra = false) const
4284  {
4285  if (minusExtra)
4286  return m_margin.top - m_extraMargin;
4287  else
4288  return m_margin.top;
4289  }
4290 
4292  void SetMarginRight(const int right)
4293  {
4294  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
4295  }
4296 
4300  int GetMarginRight(const bool minusExtra = false) const
4301  {
4302  if (minusExtra)
4303  return m_margin.right - m_extraMargin;
4304  else
4305  return m_margin.right;
4306  }
4307 
4310  {
4311  return m_marginOuter.right;
4312  }
4313 
4315  void SetMarginBottom(const int bottom)
4316  {
4317  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
4318  }
4319 
4323  int GetMarginBottom(const bool minusExtra = false) const
4324  {
4325  if (minusExtra)
4326  return m_margin.bottom - m_extraMargin;
4327  else
4328  return m_margin.bottom;
4329  }
4330 
4332  void SetMarginLeft(const int left)
4333  {
4334  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
4335  }
4336 
4340  int GetMarginLeft(const bool minusExtra = false) const
4341  {
4342  if (minusExtra)
4343  return m_margin.left - m_extraMargin;
4344  else
4345  return m_margin.left;
4346  }
4347 
4349  void SetExtraMargin(const int extra)
4350  {
4351  m_extraMargin = extra;
4352  UpdateMargins();
4353  }
4354 
4356  int GetExtraMargin() const
4357  {
4358  return m_extraMargin;
4359  }
4360 
4363  {
4364  return m_marginOuter.left;
4365  }
4366 
4368  int GetPlotWidth() const
4369  {
4370  return m_plotBoundariesMargin.GetWidth();
4371  }
4372 
4374  int GetPlotHeight() const
4375  {
4376  return m_plotBoundariesMargin.GetHeight();
4377  }
4378 
4383  mpRect GetPlotBoundaries(const bool with_margin) const
4384  {
4385  mpRect bond;
4386  if (with_margin)
4387  {
4388  bond = m_plotBoundariesMargin;
4389  }
4390  else
4391  {
4392  bond.startPx = 0;
4393  bond.startPy = 0;
4394  bond.endPx = m_scrX;
4395  bond.endPy = m_scrY;
4396  }
4397  bond.startPx -= m_extraMargin;
4398  bond.endPx += m_extraMargin;
4399  bond.startPy -= m_extraMargin;
4400  bond.endPy += m_extraMargin;
4401  return bond;
4402  }
4403 
4407  int GetLeftYAxesWidth(mpOptional_int yAxisID = std::nullopt);
4408 
4412  int GetRightYAxesWidth(mpOptional_int yAxisID = std::nullopt);
4413 
4415  void SetDrawBox(const bool drawbox)
4416  {
4417  m_drawBox = drawbox;
4418  }
4419 
4421  bool GetDrawBox() const
4422  {
4423  return m_drawBox;
4424  }
4425 
4429  mpOptional_int IsInsideYAxis(const wxPoint &point);
4430 
4434  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
4435 
4439  void SetLayerVisible(const wxString &name, bool viewable);
4440 
4444  bool IsLayerVisible(const wxString &name);
4445 
4449  bool IsLayerVisible(const unsigned int position);
4450 
4454  void SetLayerVisible(const unsigned int position, bool viewable);
4455 
4460  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
4461 
4464  const wxColour& GetAxesColour() const
4465  {
4466  return m_axColour;
4467  }
4468 
4470  const wxColour& GetbgColour() const
4471  {
4472  return m_bgColour;
4473  }
4474 
4476  void SetbgColour(const wxColour &colour)
4477  {
4478  m_bgColour = colour;
4479  }
4480 
4486  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
4487  {
4488  m_OnDeleteLayer = event;
4489  }
4490 
4493  {
4494  m_OnDeleteLayer = NULL;
4495  }
4496 
4501  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
4502  {
4503  m_OnUserMouseAction = userMouseEventHandler;
4504  }
4505 
4508  {
4509  m_OnUserMouseAction = NULL;
4510  }
4511 
4517  bool IsLogXaxis() const
4518  {
4519  if (m_AxisDataX.axis)
4520  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
4521  else
4522  return false;
4523  }
4524 
4529  bool IsLogYaxis(const int yAxisID)
4530  {
4531  assert(m_AxisDataYList.count(yAxisID) != 0);
4532  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4533  if (yAxis)
4534  return yAxis->IsLogAxis();
4535  else
4536  return false;
4537  }
4538 
4543  void SetLogXaxis(const bool log)
4544  {
4545  if (m_AxisDataX.axis)
4546  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
4547  }
4548 
4554  void SetLogYaxis(const int yAxisID, const bool log)
4555  {
4556  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4557  if (yAxis)
4558  yAxis->SetLogAxis(log);
4559  }
4560 
4565  bool GetMagnetize() const
4566  {
4567  return m_magnet.IsEnabled();
4568  }
4569 
4571  void SetMagnetize(const bool mag)
4572  {
4573  m_magnet.Enable(mag);
4574  }
4575 
4581  {
4582  m_mouseLeftDownAction = action;
4583  }
4584 
4590  {
4591  return m_mouseLeftDownAction;
4592  }
4593 
4598  wxPoint GetMousePosition() const
4599  {
4600  return m_mousePos;
4601  }
4602 
4608  {
4609  return m_movingInfoLayer;
4610  }
4611 
4612 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4613 
4617  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
4618 #endif // MP_ENABLE_CONFIG
4619 
4627  void RefreshConfigWindow(mpLayerType layerType = mpLAYER_UNDEF, int param = -1);
4628 
4636  void OpenConfigWindow(mpLayerType layerType = mpLAYER_UNDEF, int param = -1);
4637 
4641  void DeleteConfigWindow(void);
4642 
4647  void Paint(wxDC& dc);
4648 
4653  void RenderOverlays(wxDC& dc);
4654 
4660  wxMemoryDC *GetMemoryDC(void)
4661  {
4662  m_buff_dc.SelectObject(m_buff_bmp);
4663  return &m_buff_dc;
4664  }
4665 
4666  protected:
4667  virtual void BindEvents(void);
4668  virtual void OnPaint(wxPaintEvent &event);
4669  virtual void OnSize(wxSizeEvent &event);
4670  virtual void OnShowPopupMenu(wxMouseEvent &event);
4671  virtual void OnCenter(wxCommandEvent &event);
4672  virtual void OnFit(wxCommandEvent &event);
4673  virtual void OnToggleGrids(wxCommandEvent &event);
4674  virtual void OnToggleCoords(wxCommandEvent &event);
4675  virtual void OnScreenShot(wxCommandEvent &event);
4676  virtual void OnFullScreen(wxCommandEvent &event);
4677 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4678  virtual void OnConfiguration(wxCommandEvent &event);
4679 #endif // MP_ENABLE_CONFIG
4680  virtual void OnLoadFile(wxCommandEvent &event);
4681  virtual void OnZoomIn(wxCommandEvent &event);
4682  virtual void OnZoomOut(wxCommandEvent &event);
4683  virtual void OnLockAspect(wxCommandEvent &event);
4684  virtual void OnMouseHelp(wxCommandEvent &event);
4685  virtual void OnMouseLeftDown(wxMouseEvent &event);
4686  virtual void OnMouseLeftDoubleClick(wxMouseEvent &event);
4687  virtual void OnMouseRightDown(wxMouseEvent &event);
4688  virtual void OnMouseMove(wxMouseEvent &event);
4689  virtual void OnMouseLeftRelease(wxMouseEvent &event);
4690  virtual void OnMouseWheel(wxMouseEvent &event);
4691  virtual void OnMouseLeave(wxMouseEvent &event);
4692  bool CheckUserMouseAction(wxMouseEvent &event);
4693  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
4694  virtual void OnScrollPageUp(wxScrollWinEvent &event);
4695  virtual void OnScrollPageDown(wxScrollWinEvent &event);
4696  virtual void OnScrollLineUp(wxScrollWinEvent &event);
4697  virtual void OnScrollLineDown(wxScrollWinEvent &event);
4698  virtual void OnScrollTop(wxScrollWinEvent &event);
4699  virtual void OnScrollBottom(wxScrollWinEvent &event);
4700 
4702  void DoScrollCalc(const int position, const int orientation);
4703 
4708  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = MP_ZOOM_AROUND_CENTER);
4709 
4716  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = MP_ZOOM_AROUND_CENTER, mpOptional_int yAxisID = std::nullopt);
4717 
4722  void SetScaleXAndCenter(double scaleX);
4723 
4729  void SetScaleYAndCenter(double scaleY, int yAxisID);
4730 
4735  void Zoom(bool zoomIn, const wxPoint &centerPoint);
4736 
4739  virtual bool UpdateBBox();
4740 
4744  void DrawBoxZoom(wxDC& dc);
4745 
4749  void InitParameters();
4750 
4751  wxTopLevelWindow* m_parent;
4753 
4754  mpLayerList m_layers;
4756  mpAxisList m_AxisDataYList;
4757 
4758  wxMenu m_popmenu;
4760  wxColour m_bgColour;
4761  wxColour m_fgColour;
4762  wxColour m_axColour;
4763  bool m_drawBox;
4764 
4765  int m_scrX;
4766  int m_scrY;
4769 
4773 
4775  wxRect m_PlotArea;
4776 
4779  wxBitmap m_buff_bmp;
4780  wxMemoryDC m_buff_dc;
4786  wxPoint m_mousePos;
4787  wxPoint m_mouseRClick;
4788  wxPoint m_mouseLClick;
4789  double m_mouseScaleX;
4790  std::unordered_map<int, double> m_mouseScaleYList;
4793  bool m_autoFit;
4797 
4799 
4801 
4802  wxBitmap* m_Screenshot_bmp;
4803 
4804  wxString m_wildcard;
4805  wxString m_DefaultDir;
4806 
4807 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4808  MathPlotConfigDialog* m_configWindow = NULL;
4809 #endif // MP_ENABLE_CONFIG
4810  bool m_openConfigWindowPending = false;
4812 
4813  mpOnDeleteLayer m_OnDeleteLayer = NULL;
4814  mpOnUserMouseAction m_OnUserMouseAction = NULL;
4815 
4819  virtual void DesiredBoundsHaveChanged() {};
4820 
4821  private:
4823  void CheckAndReportDesiredBoundsChanges();
4824 
4829  unsigned int GetNewAxisDataID(void)
4830  {
4831  int newID = 0;
4832  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
4833  {
4834  if(m_yData.axis)
4835  {
4836  // This ID is used by an axis. Make sure the new ID is larger
4837  newID = std::max(newID, m_yID + 1);
4838  }
4839  }
4840  return newID;
4841  }
4842 
4844 
4845  // To have direct access to m_Screenshot_dc
4846  friend mpPrintout;
4847 };
4848 
4849 //-----------------------------------------------------------------------------
4850 // mpText - provided by Val Greene
4851 //-----------------------------------------------------------------------------
4852 
4861 {
4862  public:
4865  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
4866  {
4867  m_subtype = mptText;
4868  SetName(name);
4869  m_offsetx = 5;
4870  m_offsety = 50;
4871  m_location = mpMarginUser;
4872  m_ZIndex = mpZIndex_TEXT;
4873  }
4874 
4878  mpText(const wxString &name, int offsetx, int offsety);
4879 
4883  mpText(const wxString &name, mpLocation marginLocation);
4884 
4887  bool HasBBox() override
4888  {
4889  return false;
4890  }
4891 
4894  void SetLocation(const mpLocation location)
4895  {
4896  m_location = location;
4897  }
4898 
4901  mpLocation GetLocation() const
4902  {
4903  return m_location;
4904  }
4905 
4908  void SetOffset(const int offX, const int offY)
4909  {
4910  m_offsetx = offX;
4911  m_offsety = offY;
4912  }
4913 
4915  void GetOffset(int *offX, int *offY) const
4916  {
4917  *offX = m_offsetx;
4918  *offY = m_offsety;
4919  }
4920 
4921  protected:
4924  mpLocation m_location;
4925 
4928  void DoPlot(wxDC &dc, mpWindow &w) override;
4929 
4930  private:
4932 };
4933 
4938 {
4939  public:
4942  mpTitle();
4943 
4946  mpTitle(const wxString &name) :
4947  mpText(name, mpMarginTopCenter)
4948  {
4949  m_subtype = mptTitle;
4950  SetPen(*wxWHITE_PEN);
4951  SetBrush(*wxWHITE_BRUSH);
4952  }
4953 
4954  private:
4956 };
4957 
4958 //-----------------------------------------------------------------------------
4959 // mpPrintout - provided by Davide Rondini
4960 //-----------------------------------------------------------------------------
4961 
4966 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4967 {
4968  public:
4969  mpPrintout()
4970  {
4971  plotWindow = NULL;
4972  drawn = false;
4973  stretch_factor = 2;
4974  }
4975 
4981  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4982  ~mpPrintout() override
4983  {
4984  ;
4985  }
4986 
4990  void SetDrawState(const bool drawState)
4991  {
4992  drawn = drawState;
4993  }
4994 
4996  bool OnPrintPage(int page) override;
4998  bool HasPage(int page) override;
4999 
5002  void SetFactor(const int factor)
5003  {
5004  stretch_factor = factor;
5005  }
5006 
5007  private:
5008  bool drawn;
5009  mpWindow* plotWindow;
5010  int stretch_factor; // To reduce the size of plot
5011 
5013 };
5014 
5015 //-----------------------------------------------------------------------------
5016 // mpMovableObject - provided by Jose Luis Blanco
5017 //-----------------------------------------------------------------------------
5026 {
5027  public:
5031  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
5032  {
5033  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
5034  m_subtype = mpfMovable;
5035  }
5036 
5037  ~mpMovableObject() override {}
5038 
5041  void GetCoordinateBase(double &x, double &y, double &phi) const
5042  {
5043  x = m_reference_x;
5044  y = m_reference_y;
5045  phi = m_reference_phi;
5046  }
5047 
5050  void SetCoordinateBase(const double x, const double y, const double phi = 0)
5051  {
5052  m_reference_x = x;
5053  m_reference_y = y;
5054  m_reference_phi = phi;
5055  m_flags = mpALIGN_SW;
5056  ShapeUpdated();
5057  }
5058 
5059  bool HasBBox() override
5060  {
5061  return m_trans_shape_xs.size() != 0;
5062  }
5063 
5066  double GetMinX() override
5067  {
5068  return m_bbox_x.min;
5069  }
5070 
5073  double GetMaxX() override
5074  {
5075  return m_bbox_x.max;
5076  }
5077 
5080  double GetMinY() override
5081  {
5082  return m_bbox_y.min;
5083  }
5084 
5087  double GetMaxY() override
5088  {
5089  return m_bbox_y.max;
5090  }
5091 
5092  protected:
5093 
5096  double m_reference_x;
5097  double m_reference_y;
5099 
5100  void DoPlot(wxDC &dc, mpWindow &w) override;
5101 
5104  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
5105 
5106  // the object points, in local coordinates (to be transformed by the current transformation).
5107  std::vector<double> m_shape_xs;
5108  std::vector<double> m_shape_ys;
5109 
5110  // The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh).
5111  std::vector<double> m_trans_shape_xs;
5112  std::vector<double> m_trans_shape_ys;
5113 
5119 
5123  void ShapeUpdated();
5124 
5125  private:
5127 };
5128 
5129 //-----------------------------------------------------------------------------
5130 // mpCovarianceEllipse - provided by Jose Luis Blanco
5131 //-----------------------------------------------------------------------------
5144 {
5145  public:
5149  mpCovarianceEllipse(const double cov_00 = 1, const double cov_11 = 1, const double cov_01 = 0, const double quantiles = 2, const int segments = 32,
5150  const wxString &layerName = _T("")) : mpMovableObject(),
5151  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
5152  {
5153  m_continuous = true;
5154  m_name = layerName;
5155  RecalculateShape();
5156  }
5157 
5158  ~mpCovarianceEllipse() override
5159  {
5160  ;
5161  }
5162 
5165  double GetQuantiles() const
5166  {
5167  return m_quantiles;
5168  }
5169 
5172  void SetQuantiles(const double q)
5173  {
5174  m_quantiles = q;
5175  RecalculateShape();
5176  }
5177 
5179  void SetSegments(const int segments)
5180  {
5181  m_segments = segments;
5182  }
5183 
5185  int GetSegments() const
5186  {
5187  return m_segments;
5188  }
5189 
5192  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
5193  {
5194  cov_00 = m_cov_00;
5195  cov_01 = m_cov_01;
5196  cov_11 = m_cov_11;
5197  }
5198 
5201  void SetCovarianceMatrix(const double cov_00, const double cov_01, const double cov_11)
5202  {
5203  m_cov_00 = cov_00;
5204  m_cov_01 = cov_01;
5205  m_cov_11 = cov_11;
5206  RecalculateShape();
5207  }
5208 
5209  protected:
5212  double m_cov_00;
5213  double m_cov_11;
5214  double m_cov_01;
5215  double m_quantiles;
5216 
5220 
5223  void RecalculateShape();
5224 
5225  private:
5227 };
5228 
5229 //-----------------------------------------------------------------------------
5230 // mpPolygon - provided by Jose Luis Blanco
5231 //-----------------------------------------------------------------------------
5237 {
5238  public:
5241  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
5242  {
5243  m_continuous = true;
5244  m_name = layerName;
5245  }
5246 
5247  ~mpPolygon() override
5248  {
5249  ;
5250  }
5251 
5257  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
5258 
5259  private:
5261 };
5262 
5263 //-----------------------------------------------------------------------------
5264 // mpBitmapLayer - provided by Jose Luis Blanco
5265 //-----------------------------------------------------------------------------
5271 {
5272  public:
5276  {
5277  m_validImg = false;
5278  m_bitmapChanged = false;
5279  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
5280  }
5281 
5282  ~mpBitmapLayer() override
5283  {
5284  ;
5285  }
5286 
5289  void GetBitmapCopy(wxImage &outBmp) const;
5290 
5298  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
5299 
5302  double GetMinX() override
5303  {
5304  return m_bitmapX.min;
5305  }
5306 
5309  double GetMaxX() override
5310  {
5311  return m_bitmapX.max;
5312  }
5313 
5316  double GetMinY() override
5317  {
5318  return m_bitmapY.min;
5319  }
5320 
5323  double GetMaxY() override
5324  {
5325  return m_bitmapY.max;
5326  }
5327 
5328  protected:
5329 
5332  wxImage m_bitmap;
5333  wxBitmap m_scaledBitmap;
5336  bool m_validImg;
5338 
5343 
5344  void DoPlot(wxDC &dc, mpWindow &w) override;
5345 
5346  private:
5348 };
5349 
5350 // utility class
5351 
5353 typedef enum __mp_Colour
5354 {
5355  mpBlue,
5356  mpRed,
5357  mpGreen,
5358  mpPurple,
5359  mpYellow,
5360  mpFuchsia,
5361  mpLime,
5362  mpAqua,
5363  mpOlive
5364 } mpColour;
5365 
5370 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
5371 {
5372  public:
5377  wxIndexColour(const unsigned int id)
5378  {
5379 #ifdef _WIN32
5380  auto GetRandomColor = []() {
5381  return (rand() * 255) / RAND_MAX;
5382  };
5383 #else
5384  auto GetRandomColor = []() {
5385  return (random() * 255) / RAND_MAX;
5386  };
5387 #endif
5388  switch (id)
5389  {
5390  case 0:
5391  this->Set(0, 0, 255);
5392  break; // Blue
5393  case 1:
5394  this->Set(255, 0, 0);
5395  break; // Red
5396  case 2:
5397  this->Set(0, 128, 0);
5398  break; // Green
5399  case 3:
5400  this->Set(128, 0, 128);
5401  break; // Purple
5402  case 4:
5403  this->Set(255, 255, 0);
5404  break; // Yellow
5405  case 5:
5406  this->Set(255, 0, 255);
5407  break; // Fuchsia
5408  case 6:
5409  this->Set(0, 255, 0);
5410  break; // Lime
5411  case 7:
5412  this->Set(0, 255, 255);
5413  break; // Aqua/Cyan
5414  case 8:
5415  this->Set(128, 128, 0);
5416  break; // Olive
5417  default:
5418  this->Set((ChannelType) (GetRandomColor()), (ChannelType) (GetRandomColor()), (ChannelType) (GetRandomColor()));
5419  }
5420  }
5421 };
5422 
5425 // ---------------------------------------------------------------------
5426 #if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
5427  }// namespace MathPlot
5428 #endif // MP_ENABLE_NAMESPACE
5429 
5430 #endif // MATHPLOT_H_INCLUDED
T Length(void) const
Length of the range.
Definition: mathplot.h:412
sub type for mpFXYVector function
Definition: mathplot.h:750
int GetMarginLeft(const bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:4340
mpRange< double > lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:3394
mpMouseButtonAction GetMouseLeftDownAction() const
Returns the type of action for the left mouse button.
Definition: mathplot.h:4589
int GetAxisWidth() const
Get the reserved width of the Y axis in pixels.
Definition: mathplot.h:3303
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:4922
bool GetLegendIsAlwaysVisible() const
Get the visibility of the legend.
Definition: mathplot.h:1867
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2827
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:3232
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer.
Definition: mathplot.h:3429
void SetDrawState(const bool drawState)
Set whether the plot has already been drawn on the current printout.
Definition: mathplot.h:4990
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:652
sub type for mpText layer
Definition: mathplot.h:739
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:4169
Align the plot label towards the southeast.
Definition: mathplot.h:691
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:3289
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:878
Draw a circle.
Definition: mathplot.h:714
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:5050
Show legend items with small square with the same color of referred mpLayer.
Definition: mathplot.h:699
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:3239
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:3538
mpRange< double > GetBoundY(const int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3756
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:4790
wxMemoryDC m_buff_dc
DC for double buffering.
Definition: mathplot.h:4780
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:4486
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3883
bool GetMagnetize() const
Is mouse magnetization enabled? Useful to read the position on the axes.
Definition: mathplot.h:4565
enum __mp_Colour mpColour
Enumeration of classic colour.
Bitmap type layer.
Definition: mathplot.h:829
bool IsDraggedSeriesShown() const
Get shown status of dragged series.
Definition: mathplot.h:1556
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1200
void SetExtraMargin(const int extra)
Set the extra margin.
Definition: mathplot.h:4349
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:4775
__Scale_Type
sub_type values for mpLAYER_AXIS
Definition: mathplot.h:757
T GetMaxAbs(void) const
Max absolute value of the range.
Definition: mathplot.h:424
Plot type layer.
Definition: mathplot.h:814
~mpInfoCoords() override
Default destructor.
Definition: mathplot.h:1381
abstract Layer for chart (bar and pie).
Definition: mathplot.h:2649
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1199
bool m_enableScrollBars
Enable scrollbar in plot window (default false)
Definition: mathplot.h:4792
double m_lastX
Last x-coordinate point added.
Definition: mathplot.h:2379
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1189
bool IsShown() const
Get shown status.
Definition: mathplot.h:1413
User defined position. Can be change by mouse drag.
Definition: mathplot.h:662
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1196
wxBitmap m_scaledBitmap
Cached scaled bitmap used for drawing.
Definition: mathplot.h:5333
std::map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:3406
mpFXGeneric(const wxString &name=wxT("Generic FX function"), const int flags=mpALIGN_LEFT, const unsigned int yAxisID=0)
Definition: mathplot.h:2505
#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:1474
__Symbol_Type
Displaying a symbol instead of a point in the plot function.
Definition: mathplot.h:711
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:698
__mp_Layer_Type
Major type of an mpLayer (detail is in subtype)
Definition: mathplot.h:810
std::unordered_map< int, mpRange< double > > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:3808
Show/Hide grids.
Definition: mathplot.h:640
VerticalCursorMode GetVerticalCursorMode() const
Get the current vertical cursor mode.
Definition: mathplot.h:1622
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:1008
bool m_autoStep
Calculates m_step automatically based on how many points you want to draw.
Definition: mathplot.h:1909
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:3156
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1191
mpLabelType
enum for label for grid
Definition: mathplot.h:782
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:5059
int GetAxisID(void) const
Return the ID of the Axis.
Definition: mathplot.h:2909
mpNormal(const double mu, const double sigma)
Classic Normal distribution.
Definition: mathplot.h:2614
mpRange< double > GetDesiredBoundY(const int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3765
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:3111
std::vector< std::string > labels
Labels of the Values.
Definition: mathplot.h:2687
mpLegendStyle GetItemMode() const
Get the current legend item drawing mode.
Definition: mathplot.h:1522
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:4126
bool HasBBox() override
mpInfoLayer has not bounding box.
Definition: mathplot.h:1272
void SetScaleY(const double scaleY, const int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:3714
const wxRect & GetRectangle() const
Get the current rectangle coordinates.
Definition: mathplot.h:1319
static void SetDefaultLegendIsAlwaysVisible(const bool visible)
Set if legend is always visible even if series is not plotted.
Definition: mathplot.h:4239
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:4767
mpRange< double > GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:3742
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:3841
double m_const
Const factor.
Definition: mathplot.h:2627
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:812
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:845
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:3147
sub type not defined (should be never used)
Definition: mathplot.h:759
double m_lastY
Last y-coordinate point added.
Definition: mathplot.h:2381
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:3705
double ComputeY(const double x) override
The main computation of the FX function.
Definition: mathplot.h:2629
void SetScale(const mpRange< double > range)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3071
bool m_CoordIsAlwaysVisible
If true, the mouse coordinates is visible in the info coordinates despite the visibility of the axis...
Definition: mathplot.h:3158
VerticalCursorMode
Enumeration for vertical cursor mode, which determines how the vertical cursor is positioned for seri...
Definition: mathplot.h:1614
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:4362
mpRange< double > GetScale() const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3079
Lock x/y scaling aspect.
Definition: mathplot.h:639
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:4770
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2626
void SetNeedUpdate()
Mark the legend bitmap as needing regeneration.
Definition: mathplot.h:1542
void ToLog(void)
Convert to log range.
Definition: mathplot.h:430
int m_reserveXY
Memory reserved for m_xs and m_ys. Default 1000.
Definition: mathplot.h:2375
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:1048
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:660
std::vector< double > m_trans_shape_ys
Transformed shape vertices in Y coordinates.
Definition: mathplot.h:5112
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:4501
wxBitmap m_buff_bmp
Bmp for double buffering.
Definition: mathplot.h:4779
Info box type layer.
Definition: mathplot.h:834
bool m_boxZoomActive
Indicate if box zoom is active.
Definition: mathplot.h:4798
~mpPieChart() override
Destructor.
Definition: mathplot.h:2781
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:5270
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:1024
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:916
void SetYAxisID(const unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1851
wxString m_DefaultDir
The default directory for wxFileDialog.
Definition: mathplot.h:4805
void SetMinScale(const double min)
Set the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:3020
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:2039
std::vector< wxColor > m_seriesColors
Colors of the series in the order they were added to the mpWindow.
Definition: mathplot.h:1480
double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:5323
#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:451
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:2011
void Enable(const bool enable)
Enables the magnet.
Definition: mathplot.h:3457
mpRange< double > m_bbox_y
Range of bounding box on y direction.
Definition: mathplot.h:5118
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:4383
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:4783
void SetHovering(const bool hover)
Set if axis shall be highlighted when a series is dragged over it.
Definition: mathplot.h:3087
void ErasePlot(wxDC &, mpWindow &) override
Just delete the bitmap of the info.
Definition: mathplot.h:1402
const wxColour & GetbgColour() const
Get the plot background colour.
Definition: mathplot.h:4470
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:5219
Chart type layer (bar chart)
Definition: mathplot.h:819
int GetMarginBottom(const bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:4323
void SetDrawBox(const bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:4415
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:4374
sub type for mpLine function
Definition: mathplot.h:752
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1824
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1216
void SetDefaultDir(const wxString &dirname)
Set the default directory for wxFileDialog.
Definition: mathplot.h:4220
Draw a cross X.
Definition: mathplot.h:718
bool GetAutoHideAxis() const
Return true if this axis is automatically hidden when not used by any series.
Definition: mathplot.h:3317
double m_max_value
Max value of the values vector.
Definition: mathplot.h:2689
void SetItemDirection(const mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1529
Draw a triangle up oriented.
Definition: mathplot.h:716
infoCoordType m_infoCoordType
Type of info coordinates to be displayed (axis, closest series, or all series).
Definition: mathplot.h:1479
void SetAuto(const bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:3004
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1842
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2467
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:4309
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:2680
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:3926
wxSize GetSize() const
Get the size of the box (in pixels)
Definition: mathplot.h:1312
wxPoint m_mousePos
Current mouse position in window.
Definition: mathplot.h:4786
void SetMaxScale(const double max)
Set the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3036
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3978
double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:2405
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:4772
unsigned int CountAllLayers() const
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:4068
Mouse action drag the plot.
Definition: mathplot.h:778
bool IsLeftAxis() const
Return true if this Y axis is aligned to the left side.
Definition: mathplot.h:3323
void SetFont(const wxFont &font)
Set layer font.
Definition: mathplot.h:1016
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1905
double GetValue() const
Get the x or y coordinates of the line.
Definition: mathplot.h:1938
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:1875
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:4762
double m_relY
Box Y position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1343
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:4754
~mpBarChart() override
Destructor.
Definition: mathplot.h:2715
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:5096
mpRange()
Default constructor.
Definition: mathplot.h:294
double m_sigma
Sigma value.
Definition: mathplot.h:2625
void ShowDraggedSeries(const bool active)
Set if dragged series shall be shown or hidden.
Definition: mathplot.h:1549
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:3821
sub type not defined (should be never used)
Definition: mathplot.h:768
int m_flags
Holds label alignment. Default : mpALIGN_SW for series and mpALIGN_CENTER for scale.
Definition: mathplot.h:1197
std::vector< wxColour > colours
Per-slice colours used when drawing the chart.
Definition: mathplot.h:2844
mpRange< double > GetVisibleRangeY(const unsigned int yAxisID=0)
Get the visible range for Y axis of ID yAxisID, i.e.
Definition: mathplot.h:3783
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:4660
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:2241
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:2356
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1344
sub type not defined (should be never used)
Definition: mathplot.h:746
wxIndexColour(const unsigned int id)
Constructor.
Definition: mathplot.h:5377
double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:2819
sub type not defined (should be never used)
Definition: mathplot.h:738
mpRange< double > m_bitmapX
The shape of the bitmap:
Definition: mathplot.h:5341
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:4901
void SetSymbol(const mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1803
Just the end of ZOrder.
Definition: mathplot.h:836
int GetMarginRight(const bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:4300
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:827
void SetLabelFormat(const wxString &format, const bool updateLabelMode=false)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2955
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:2292
mpRange< double > x
range over x direction
Definition: mathplot.h:581
Layer for pie chart.
Definition: mathplot.h:2772
void SetAutoFit(const bool autoFit)
Set if plot shall be auto fitted when hiding or showing axis and series via mouse.
Definition: mathplot.h:4254
wxPoint GetMousePosition() const
Returns current mouse position in window.
Definition: mathplot.h:4598
std::vector< double > m_xs
internal copy of the set of data on x direction
Definition: mathplot.h:2372
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:1040
bool IsRightAxis() const
Return true if this Y axis is aligned to the right side.
Definition: mathplot.h:3329
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:2366
void Set(T value_)
Initialize min and max.
Definition: mathplot.h:316
const std::vector< double > & GetYData() const
Get read-only access to the internal Y data vector.
Definition: mathplot.h:2336
void Update(T value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:370
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:4756
Draw a plus +.
Definition: mathplot.h:719
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2964
Keep the object, just remove the layer from the layer list.
Definition: mathplot.h:847
double GetMaxY() override
Get max Y of the function.
Definition: mathplot.h:2547
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:2901
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:3224
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
T GetCenter(void) const
Center of the range.
Definition: mathplot.h:418
std::vector< double > m_ys
internal copy of the set of data on y direction
Definition: mathplot.h:2373
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:906
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2946
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:2376
Delete the object regardless of the CanDelete value and remove it from the layer list.
Definition: mathplot.h:849
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:3437
double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:2427
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:4356
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:4784
Align the plot label towards the southwest.
Definition: mathplot.h:692
Align the y-axis towards left border.
Definition: mathplot.h:679
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:1082
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:3832
void EnableBufferedPaintDC(const bool enabled)
Enable/disable the auto buffering of PaintDC.
Definition: mathplot.h:3971
Align the x-axis towards bottom border.
Definition: mathplot.h:669
void Show(const bool show)
Set if magnet shall be shown or hidden.
Definition: mathplot.h:3478
void SetMarginTop(const int top)
Set the top margin.
Definition: mathplot.h:4275
Plot (function) type layer.
Definition: mathplot.h:832
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:4800
bool ViewAsBar(void) const
Get if we are in bar mode.
Definition: mathplot.h:2232
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1198
wxColour colour
pen colour of the matched plot layer
Definition: mathplot.h:626
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:1032
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1158
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1810
void SetStep(const unsigned int step)
Set step for plot.
Definition: mathplot.h:1789
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:3153
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:4368
Create a generic FX function Override the ComputeY() function with your function. ...
Definition: mathplot.h:2498
void SetMaxNOfPoints(const size_t nOfPoints)
Set how many points that is allowed to be drawn at a time.
Definition: mathplot.h:1890
size_t m_maxNOfPoints
Maximum number of points to draw to screen.
Definition: mathplot.h:1910
double m_deltaY
Min delta between 2 consecutive coordinate on y direction.
Definition: mathplot.h:2245
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2932
Axis type layer.
Definition: mathplot.h:830
void SetMarginLeft(const int left)
Set the left margin.
Definition: mathplot.h:4332
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:381
double GetMaxScale() const
Get the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3044
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:5236
Draw a triangle down oriented.
Definition: mathplot.h:717
Axis type layer.
Definition: mathplot.h:813
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:3945
double GetQuantiles() const
Get the confidence-interval multiplier used for the ellipse.
Definition: mathplot.h:5165
double m_const
Const factor.
Definition: mathplot.h:2591
bool GetCanDelete(void) const
Retreive what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1172
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:2166
#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:1195
void SetMarginBottom(const int bottom)
Set the bottom margin.
Definition: mathplot.h:4315
Align the info in margin center-right.
Definition: mathplot.h:658
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1185
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:4247
int GetBarWidth(void) const
Get the width of the bar when we plot in bar mode.
Definition: mathplot.h:2223
wxColour m_barColour
Fill colour used for the bars.
Definition: mathplot.h:2755
double GetMinScale() const
Get the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:3028
bool IsHorizontal(void) const
Is it a horizontal line?
Definition: mathplot.h:1954
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:3376
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:1137
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:4554
int GetSegments() const
Get the number of line segments used to approximate the ellipse. */.
Definition: mathplot.h:5185
virtual size_t GetSize()
Return the number of points in the series.
Definition: mathplot.h:2192
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:5192
mpRange< double > desired
Desired range min and max.
Definition: mathplot.h:3393
wxCoord m_scaledBitmap_offset_x
Cached X pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5334
void Check(void)
Check to always have a range. If min = max then introduce the 0 to make a range.
Definition: mathplot.h:400
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:4227
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:1859
bool IsEnabled() const
Check if magnet is enabled.
Definition: mathplot.h:3463
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5316
bool m_LegendIsAlwaysVisible
If true, the name is visible in the legend despite the visibility of the function. Default false.
Definition: mathplot.h:1908
each visible plot is described on its own line, one above the other
Definition: mathplot.h:706
double m_cov_01
Covariance matrix element (0,1), equal to element (1,0).
Definition: mathplot.h:5214
void SetbgColour(const wxColour &colour)
Set the plot background colour.
Definition: mathplot.h:4476
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1365
bool m_fullscreen
Boolean value indicating that we are in fullscreen mode (default false)
Definition: mathplot.h:4752
mpRange(T value1, T value2)
Create range with the 2 values.
Definition: mathplot.h:301
Align the x-axis towards top plot.
Definition: mathplot.h:672
mpGaussian(const double mu, const double sigma)
Classic Gaussian distribution.
Definition: mathplot.h:2578
void SetDrawOutsideMargins(const bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:1103
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:4788
double m_mu
Mean value.
Definition: mathplot.h:2588
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:785
void SetLocation(const mpLocation location)
Set the location of the box.
Definition: mathplot.h:4894
Align the y-axis towards right border.
Definition: mathplot.h:683
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:727
mpLegendStyle m_item_mode
Visual style used for each legend entry.
Definition: mathplot.h:1667
void SetLogXaxis(const bool log)
Enable or disable logarithmic scaling on the X axis.
Definition: mathplot.h:4543
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:4517
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:933
double GetScaleY(const int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:3730
mpLegendDirection GetItemDirection() const
Get the current legend item layout direction.
Definition: mathplot.h:1536
void ShowGrids(const bool grids)
Set axis grids.
Definition: mathplot.h:2939
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:5041
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:5275
Show/Hide info coord.
Definition: mathplot.h:641
Align the x-axis towards top border.
Definition: mathplot.h:673
bool m_IsHorizontal
Is the line horizontal? Default false.
Definition: mathplot.h:1961
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5241
Mouse action draw a box to zoom inside.
Definition: mathplot.h:777
__Function_Type
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
Definition: mathplot.h:744
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition: mathplot.h:90
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1983
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:5025
bool IsShown() const
Get shown status.
Definition: mathplot.h:3484
Align the y-axis towards left plot.
Definition: mathplot.h:680
Chart type layer.
Definition: mathplot.h:833
Set label for axis in scientific notation.
Definition: mathplot.h:789
bool IsInside(const wxCoord xPixel) const
Return true if the given X pixel lies within this Y-axis drawing area.
Definition: mathplot.h:3335
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2988
void SetOffset(const int offX, const int offY)
Set offset.
Definition: mathplot.h:4908
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:1304
std::optional< int > mpOptional_int
Shortcut to optional integer type..
Definition: mathplot.h:108
int m_labelPos
Bar-label placement mode.
Definition: mathplot.h:2756
Copy a screen shot to the clipboard.
Definition: mathplot.h:642
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:3443
Fit view to match bounding box of all layers.
Definition: mathplot.h:635
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:648
Center view on click position.
Definition: mathplot.h:638
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:1515
void ShowTicks(const bool ticks)
Set axis ticks.
Definition: mathplot.h:2925
Plot layer implementing a simple title.
Definition: mathplot.h:4937
double m_total_value
Total of the values vector.
Definition: mathplot.h:2690
bool IsSet() const
Check if this mpRange has been assigned any values.
Definition: mathplot.h:361
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:667
double pos
Position.
Definition: mathplot.h:3391
mpLabelType m_labelType
Label formatting mode used for the X coordinate display.
Definition: mathplot.h:1475
sub type for all layers who are function.
Definition: mathplot.h:753
Draw a square.
Definition: mathplot.h:715
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:1096
Align the x-axis center plot.
Definition: mathplot.h:671
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:736
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:4787
double m_labelAngle
Rotation angle used for bar labels, in degrees.
Definition: mathplot.h:2757
__mp_Colour
Enumeration of classic colour.
Definition: mathplot.h:5353
double m_width
Width of each bar/column in plot units.
Definition: mathplot.h:2754
void SetCovarianceMatrix(const double cov_00, const double cov_01, const double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:5201
mpRange< double > GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:3748
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1245
Align the plot label towards the northwest.
Definition: mathplot.h:689
int m_infoLegendSelectedSeries
Only used with config window: the selected series in info legend.
Definition: mathplot.h:4811
~mpInfoLegend() override
Default destructor.
Definition: mathplot.h:1511
bool m_show
Indicates if magnet shall be shown in plot.
Definition: mathplot.h:1473
void SetLabelMode(const mpLabelType mode, const unsigned int time_conv=MP_X_RAWTIME)
Set axis label view mode.
Definition: mathplot.h:2972
mpRange< int > m_drawX
Range min and max on x axis.
Definition: mathplot.h:2240
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:3062
int GetWidth() const
Get the width of the rectangle defined by this object&#39;s left and right coordinates.
Definition: mathplot.h:265
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:4759
double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:2442
bool ShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
Check conditions if info coords shall be shown or not.
Definition: mathplot.h:1422
bool m_autoHideAxis
Hide axis automatically if no series uses it. Default: false.
Definition: mathplot.h:3347
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:3279
bool IsVisible() const
Is this layer visible?
Definition: mathplot.h:1123
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:579
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:4421
No symbol is drawing.
Definition: mathplot.h:713
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:949
int GetHeight() const
Get the height of the rectangle defined by this object&#39;s top and bottom coordinates.
Definition: mathplot.h:274
virtual void SetTractable(const bool track)
Sets layer tractability.
Definition: mathplot.h:1144
double m_reference_y
Current object Y position in plot coordinates.
Definition: mathplot.h:5097
Layer for bar chart.
Definition: mathplot.h:2708
__Chart_Type
sub_type values for mpLAYER_CHART
Definition: mathplot.h:766
void SetAxisID(const unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2918
void SetFactor(const int factor)
Definition: mathplot.h:5002
static bool m_DefaultLegendIsAlwaysVisible
This value sets the default behaviour when a series is not visible for the legend display...
Definition: mathplot.h:4232
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:700
sub type for all layers who are chart.
Definition: mathplot.h:771
void EnableSeriesValues(const bool enable)
Enables to show series values in the legend.
Definition: mathplot.h:1563
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4966
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:3150
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1930
Align the info in margin center-left.
Definition: mathplot.h:654
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:787
double m_mu
Mean value.
Definition: mathplot.h:2624
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:687
mpRange< double > y
range over y direction
Definition: mathplot.h:582
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:4774
void Set(T min_, T max_)
Set min, max function.
Definition: mathplot.h:323
double GetPosY(const int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3856
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:4464
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1761
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:288
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:4794
sub type for mpInfoLegend layer
Definition: mathplot.h:732
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1333
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2996
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1188
wxPoint m_center
Center of the pie chart in device coordinates.
Definition: mathplot.h:2843
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3907
double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:2835
mpOptional_int m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:4791
bool IsSeriesValuesShown() const
Indicates if series values shall be shown.
Definition: mathplot.h:1593
#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:2842
bool m_mouseMovedAfterRightClick
If the mouse does not move after a right click, then the context menu is displayed.
Definition: mathplot.h:4785
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:1579
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:4761
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3994
void SetLocation(const mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1326
int m_last_ly
Last logical Y origin, used for double buffering.
Definition: mathplot.h:4778
std::unordered_map< int, mpRange< double > > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:3794
Text box type layer.
Definition: mathplot.h:816
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:677
void SetAlign(const int align)
Set X/Y alignment.
Definition: mathplot.h:1151
sub type for mpBarChart
Definition: mathplot.h:769
Abstract class providing a line.
Definition: mathplot.h:1918
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:1063
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:3691
Load a file.
Definition: mathplot.h:646
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:1882
mpRange< double > m_axisRange
Range axis values when autosize is false.
Definition: mathplot.h:3152
void Show(const bool show)
Set if info coords shall be shown or hidden.
Definition: mathplot.h:1406
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:1000
Line (horizontal or vertical) type layer.
Definition: mathplot.h:831
void SetMouseLeftDownAction(const mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:4580
double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:5073
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3865
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:2324
Dialog box for configuring the plot&#39;s layer objects In this dialog, you can configure: ...
Definition: MathPlotConfig.h:155
T max
The max value of the range.
Definition: mathplot.h:291
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1339
infoCoordType
Type of info coordinates to be displayed (axis, closest series, or all series)
Definition: mathplot.h:1387
Delete the object if CanDelete is true and remove it from the layer list.
Definition: mathplot.h:848
void SetBrush(const wxColour &colour, enum wxBrushStyle style=wxBRUSHSTYLE_SOLID)
Set layer brush.
Definition: mathplot.h:1074
double scale
Scale.
Definition: mathplot.h:3390
void SetContinuity(const bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1774
sub type for mpTitle layer
Definition: mathplot.h:740
mpRange< double > m_bbox_x
The precomputed bounding box:
Definition: mathplot.h:5117
int GetMarginTop(const bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:4283
Align the info in margin center-top.
Definition: mathplot.h:656
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:3053
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:796
void SetSeriesCoord(const bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1439
void IndicateSeriesIntersection(const bool enable)
Set if the intersection of the series with the vertical cursor shall be indicated.
Definition: mathplot.h:1600
bool m_autoFit
Automatically fit plot when hiding / showing axis and series.
Definition: mathplot.h:4793
wxPoint GetPosition() const
Get the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1297
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1194
void UpdateDesiredBoundingBox(const mpAxisUpdate update)
Update m_desired bounds.
Definition: mathplot.h:4089
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:4529
void SetWildcard(const wxString &wildcard)
Set wildcard for LoadFile() function when we use wxFileDialog.
Definition: mathplot.h:4194
double GetMinY() override
Get min Y of the function.
Definition: mathplot.h:2538
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1341
Set no label for axis (useful for bar)
Definition: mathplot.h:802
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:775
void SetMagnetize(const bool mag)
Enable or disable mouse-position magnet lines (cross-hairs) in the plot area.
Definition: mathplot.h:4571
sub type for mpPieChart
Definition: mathplot.h:770
bool m_validImg
True when the source image is valid and ready to draw.
Definition: mathplot.h:5336
void Assign(T value1, T value2)
Assign values to min and max.
Definition: mathplot.h:346
Align the plot label towards the northeast.
Definition: mathplot.h:690
double m_deltaX
Min delta between 2 consecutive coordinate on x direction.
Definition: mathplot.h:2244
only for mpInfoCoords
Definition: mathplot.h:663
double m_value
The x or y coordinates of the line.
Definition: mathplot.h:1960
bool m_enableBufferedPaintDC
For auto DC double buffering.
Definition: mathplot.h:4782
void SetMax(T max_)
Set max function, correct min.
Definition: mathplot.h:338
HitCode
Return codes for GetLegendHitRegion() if no series was hit.
Definition: mathplot.h:1657
Abstract class providing an vertical line.
Definition: mathplot.h:1998
bool m_showDraggedSeries
Indicate if series that has been gripped with mouse shall be drawn.
Definition: mathplot.h:1669
sub type for mpFXY function
Definition: mathplot.h:749
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:925
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:3398
bool IsBottomAxis() const
Return true when this X axis is aligned at the bottom edge or bottom border.
Definition: mathplot.h:3245
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:3896
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:941
mpInfoLayer * GetMovingInfoLayer() const
Returns moving info layer.
Definition: mathplot.h:4607
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:5332
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:4802
void UpdateBoundingBoxToInclude(const double px, const double py)
Update bounding box (X and Y axis) to include this point.
Definition: mathplot.h:605
infoCoordType GetInfoCoordType() const
Get the type of info coordinates to be displayed (axis, closest series, or all series) ...
Definition: mathplot.h:1455
Zoom into view at clickposition / window center.
Definition: mathplot.h:636
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:4755
std::vector< double > values
Values of the chart.
Definition: mathplot.h:2686
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:5149
Align the info in margin top-left.
Definition: mathplot.h:655
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:5172
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1193
double m_quantiles
Confidence-interval multiplier used when drawing the ellipse.
Definition: mathplot.h:5215
Zoom out.
Definition: mathplot.h:637
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:3103
wxCoord m_mouseY
Last mouse Y position in window pixel coordinates.
Definition: mathplot.h:1478
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1796
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2590
wxRealPoint coords
data-space (x, y) of the closest point
Definition: mathplot.h:627
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1903
double m_relX
Box X position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1342
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:704
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:5143
const std::vector< double > & GetXData() const
Get read-only access to the internal X data vector.
Definition: mathplot.h:2330
sub type for mpInfoLayer layer
Definition: mathplot.h:730
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:4507
Align the x-axis towards bottom plot.
Definition: mathplot.h:670
wxCoord m_scaledBitmap_offset_y
Cached Y pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5335
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:2024
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1190
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:4154
void SetMarginRight(const int right)
Set the right margin.
Definition: mathplot.h:4292
mpFloatRectSimple GetBoundingBox(const bool desired, const unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:4112
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:794
bool ShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
Check conditions if magnet shall be shown.
Definition: mathplot.h:3472
wxPen m_gridpen
Grid&#39;s pen. Default Colour = LIGHT_GREY, width = 1, style = wxPENSTYLE_DOT.
Definition: mathplot.h:3148
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:696
bool IsSeriesValuesEnabled() const
Check if series values is enabled in legend.
Definition: mathplot.h:1571
bool GetCoordIsAlwaysVisible() const
Get the visibility of the mouse coordinates in the info coordinates.
Definition: mathplot.h:3119
Align the y-axis towards right plot.
Definition: mathplot.h:682
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1340
void InitializeBoundingBox(const double px, const double py)
Initialize bounding box with an initial point.
Definition: mathplot.h:615
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:3154
wxTopLevelWindow * m_parent
Pointer to the top-level window containing the plot (used for fullscreen)
Definition: mathplot.h:4751
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:5030
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2798
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:4789
sub type for mpScaleX
Definition: mathplot.h:760
sub type for mpInfoCoords layer
Definition: mathplot.h:731
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:463
Set label user defined.
Definition: mathplot.h:800
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:3149
std::vector< double > m_shape_ys
Shape vertices in object-local Y coordinates.
Definition: mathplot.h:5108
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1782
void SetMin(T min_)
Set min function, correct max.
Definition: mathplot.h:330
std::vector< double > m_trans_shape_xs
Transformed shape vertices in X coordinates.
Definition: mathplot.h:5111
double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:5302
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1179
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:890
int m_xPos
Leftmost X pixel occupied by this axis (starting point).
Definition: mathplot.h:3346
mpRange< double > GetVisibleRangeX()
Get the visible range for X axis, i.e.
Definition: mathplot.h:3774
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:4768
Plot layer implementing a text string.
Definition: mathplot.h:4860
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:3953
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:792
sub type not defined (should be never used)
Definition: mathplot.h:729
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:798
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:4865
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:3515
double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:5087
Bitmap type layer.
Definition: mathplot.h:817
wxCoord m_mouseX
Last mouse X position in window pixel coordinates.
Definition: mathplot.h:1477
bool m_bitmapChanged
True when the cached scaled bitmap must be regenerated.
Definition: mathplot.h:5337
void SetLabelMode(const mpLabelType mode, const unsigned int time_conv=MP_X_RAWTIME)
Set X axis label view mode.
Definition: mathplot.h:1430
Classic Normal distribution f(x) = exp(-(ln(x)-μ)²/2σ²)/(xσ.sqrt(2π))
Definition: mathplot.h:2606
double GetY(const double x) override
Get function value for argument.
Definition: mathplot.h:2519
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1907
int m_last_lx
Last logical X origin, used for double buffering.
Definition: mathplot.h:4777
Align the info in margin bottom-left.
Definition: mathplot.h:659
void SetAutoHideAxis(const bool autoHide)
Enable or disable automatic hiding of this axis when no series uses it.
Definition: mathplot.h:3311
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:748
Info box type layer.
Definition: mathplot.h:815
double GetMinY() override
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:2420
Align the y-axis center plot.
Definition: mathplot.h:681
mpRange< double > m_rangeX
Range min and max on x axis.
Definition: mathplot.h:2378
double m_cov_11
Covariance matrix element (1,1).
Definition: mathplot.h:5213
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:3934
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:4915
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2790
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1906
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1192
bool m_cacheDirty
Indicate that the cached buffer m_buff_bmp need to be re-created.
Definition: mathplot.h:4781
Result of mpWindow::GetClosestPlot: the colour and data-space coordinates of the plot point closest t...
Definition: mathplot.h:624
Shows information about the mouse commands.
Definition: mathplot.h:647
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:4766
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3873
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:1110
legend components follow each other horizontally on a single line
Definition: mathplot.h:707
Align the info in margin top-right.
Definition: mathplot.h:657
void SetSegments(const int segments)
Set the number of line segments used to approximate the ellipse.
Definition: mathplot.h:5179
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:3255
~mpChart() override
Destructor.
Definition: mathplot.h:2656
wxString m_wildcard
For loadfile() function when we use wxFileDialog.
Definition: mathplot.h:4804
mpTitle(const wxString &name)
Definition: mathplot.h:4946
int m_axisWidth
Reserved width for this Y axis including labels, in pixels.
Definition: mathplot.h:3345
enum __Text_Type mpTextType
sub_type values for mpLAYER_TEXT
double m_reference_phi
Current object rotation angle in radians.
Definition: mathplot.h:5098
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:4758
virtual void SetVisible(const bool show)
Sets layer visibility.
Definition: mathplot.h:1130
void SetCanDelete(const bool canDelete)
Set what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1165
sub type for all layers who are scale.
Definition: mathplot.h:762
unsigned int m_timeConv
Time conversion mode used when formatting date/time X values.
Definition: mathplot.h:1476
Abstract class providing an horizontal line.
Definition: mathplot.h:1969
mpInfoCoords * m_InfoCoords
Pointer to the optional info coords layer.
Definition: mathplot.h:4795
mpInfoLegend * m_InfoLegend
Pointer to the optional info legend layer.
Definition: mathplot.h:4796
mpLocation m_location
The location of the text.
Definition: mathplot.h:4924
Implement the legend to be added to the plot This layer allows you to add a legend to describe the pl...
Definition: mathplot.h:1497
bool PointIsInside(const double px, const double py) const
Is point inside this bounding box?
Definition: mathplot.h:596
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:3387
double m_sigma
Sigma value.
Definition: mathplot.h:2589
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:4760
Align the info in margin bottom-right.
Definition: mathplot.h:661
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2871
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1280
void ShowSeriesValues(const bool show)
Set if the series values shall be drawn to the plot.
Definition: mathplot.h:1586
bool PointIsInside(T point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:437
void SetSymbolSize(const int size)
Set symbol size.
Definition: mathplot.h:1817
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1187
Classic Gaussian distribution f(x) = exp(-(x-μ)²/2σ²)/sqrt(2πσ²)
Definition: mathplot.h:2570
Plot layer, abstract base class.
Definition: mathplot.h:862
void SetColumnWidth(const double colWidth)
Set the bar width in plot units.
Definition: mathplot.h:2724
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:3917
sub type for mpMovableObject function
Definition: mathplot.h:751
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:5212
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:1056
Group of properties, derived from the axis step size and range, that control how scale labels are for...
Definition: mathplot.h:2879
mpRange< double > m_rangeY
Y range.
Definition: mathplot.h:2553
~mpFXYVector() override
destrutor
Definition: mathplot.h:2304
void EnableDoubleBuffer(const bool enabled)
Deprecated: Enable/disable the double-buffering of the window, eliminating the flicker (default=enabl...
Definition: mathplot.h:3963
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:4765
#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:589
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:4819
mpRange< double > m_rangeY
Range min and max on y axis.
Definition: mathplot.h:2380
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5080
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:3155
sub type for mpFX function
Definition: mathplot.h:747
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2980
double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:5066
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:2184
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:3151
T min
The min value of the range.
Definition: mathplot.h:290
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:4763
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2101
void SetShowName(const bool show)
Set Name visibility.
Definition: mathplot.h:1089
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:4771
std::vector< double > m_shape_xs
Shape vertices in object-local X coordinates.
Definition: mathplot.h:5107
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:5370
void SetInfoCoordType(const infoCoordType type)
Set the type of info coordinates to be displayed (axis, closest series, or all series) ...
Definition: mathplot.h:1447
virtual bool IsLogAxis()
Get if we are in Logarithmic mode.
Definition: mathplot.h:3095
double ComputeY(const double x) override
The main computation of the FX function.
Definition: mathplot.h:2593
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:4139
mpLegendDirection m_item_direction
Layout direction used when arranging legend entries.
Definition: mathplot.h:1668
double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:2811
mpRange< double > bound
Range min and max.
Definition: mathplot.h:3392
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1186
#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:2374
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:898
Show the X and Y value of the closest series.
Definition: mathplot.h:1390
sub type for mpScaleY
Definition: mathplot.h:761
int m_BarWidth
Bar width in pixels when the XY series is drawn in bar mode.
Definition: mathplot.h:2247
mpRange< double > m_bitmapY
Range of the bitmap on y direction.
Definition: mathplot.h:5342
Vertical cursor is at mouse position.
Definition: mathplot.h:1616
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:4923
size_t GetMaxNOfPoints() const
Get maximum number of points to plot.
Definition: mathplot.h:1897
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1904
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:3414
Text box type layer.
Definition: mathplot.h:835
double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:5309
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:4492
void SetValue(const double value)
Set x or y value.
Definition: mathplot.h:1946
bool HasBBox() override
Text Layer has not bounding box.
Definition: mathplot.h:4887
Show axis coordinates at mouse position.
Definition: mathplot.h:1389
const wxString & GetWildcard(void) const
Get wildcard.
Definition: mathplot.h:4202
Line (horizontal or vertical) type layer.
Definition: mathplot.h:818
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:3012
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition: mathplot.h:391
size_t m_endIndex
The end index indicating the last point inside plot area.
Definition: mathplot.h:2377