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)
257  {
258  return wxRect(startPx, startPy, endPx - startPx, endPy - startPy);
259  }
260 };
261 static_assert(sizeof(mpRect) == 4 * sizeof(wxCoord));
262 
268 template<typename T>
269 struct mpRange
270 {
271  T min = 0;
272  T max = 0;
273 
276  {
277  min = 0;
278  max = 0;
279  }
280 
282  mpRange(T value1, T value2)
283  {
284  if (value1 < value2)
285  {
286  min = value1;
287  max = value2;
288  }
289  else
290  {
291  min = value2;
292  max = value1;
293  }
294  }
295 
297  void Set(T _value)
298  {
299  min = _value;
300  max = _value;
301  }
302 
304  void Set(T _min, T _max)
305  {
306  min = _min;
307  max = _max;
308  }
309 
311  void SetMin(T _min)
312  {
313  min = _min;
314  if (max < min)
315  max = min;
316  }
317 
319  void SetMax(T _max)
320  {
321  max = _max;
322  if (min > max)
323  min = max;
324  }
325 
327  void Assign(T value1, T value2)
328  {
329  if (value1 < value2)
330  {
331  min = value1;
332  max = value2;
333  }
334  else
335  {
336  min = value2;
337  max = value1;
338  }
339  }
340 
342  bool IsSet()
343  {
344  return ((min != 0) || (max != 0));
345  }
346 
351  void Update(T value)
352  {
353  if (value < min)
354  min = value;
355  else
356  if (value > max)
357  max = value;
358  }
359 
363  void Update(T _min, T _max)
364  {
365  if (_min < min)
366  min = _min;
367  if (_max > max)
368  max = _max;
369  }
370 
373  void Update(mpRange range)
374  {
375  if (range.min < min)
376  min = range.min;
377  if (range.max > max)
378  max = range.max;
379  }
380 
382  void Check(void)
383  {
384  if (min == max)
385  {
386  if (max > 0)
387  min = 0;
388  else
389  max = 0;
390  }
391  }
392 
394  T Length(void) const
395  {
396  return max - min;
397  }
398 
400  T GetCenter(void) const
401  {
402  return (min + max) / 2;
403  }
404 
406  T GetMaxAbs(void) const
407  {
408  return std::max(fabs(min), fabs(max));
409  }
410 
412  void ToLog(void)
413  {
414  min = (min > 0) ? log10(min) : 0;
415  max = (max > 0) ? log10(max) : 0;
416  }
417 
419  bool PointIsInside(T point) const
420  {
421  return ((point >= min) && (point <= max));
422  }
423 
424  #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
425  bool operator==(const mpRange&) const = default;
426  #else
427  bool operator==(const mpRange &other) const
429  {
430  return (min == other.min) && (max == other.max);
431  }
433  bool operator!=(const mpRange& other) const
434  {
435  return !(*this == other);
436  }
437  #endif
438 };
439 
445 struct [[deprecated("Deprecated! No longer used as X and Y are now separated")]] mpFloatRect
446 {
447  mpRange<double> x;
448  std::vector<mpRange<double>> y;
449 
456  mpFloatRect(mpWindow& w);
457 
459  mpFloatRect() = delete;
460 
467  bool PointIsInside(double px, double py, size_t yAxisID = 0) const {
468  if (yAxisID < y.size())
469  {
470  if( (px < x.min || px > x.max) ||
471  (py < y[yAxisID].min || py > y[yAxisID].max))
472  {
473  return false;
474  }
475  }
476  else
477  {
478  return false;
479  }
480 
481  return true;
482  }
483 
490  void UpdateBoundingBoxToInclude(double px, double py, size_t yAxisID = 0) {
491  assert(yAxisID < y.size());
492  if (yAxisID < y.size())
493  {
494  if (px < x.min ) x.min = px;
495  else if (px > x.max ) x.max = px;
496  if (py < y[yAxisID].min ) y[yAxisID].min = py;
497  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
498  }
499  }
500 
507  void InitializeBoundingBox(double px, double py, size_t yAxisID = 0) {
508  assert(yAxisID < y.size());
509  if (yAxisID < y.size())
510  {
511  x.min = x.max = px;
512  y[yAxisID].min = y[yAxisID].max = py;
513  }
514  }
516  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
518 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
519  bool operator==(const mpFloatRect&) const = default;
520 #else
521  // We compare with an epsilon precision
522  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
523  bool operator==(const mpFloatRect& rect) const
524  {
525  auto Same = [](double a, double b) {
526  return std::fabs(a - b) < MP_EPSILON;
527  };
528 
529  // Compare scalar members
530  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
531  {
532  return false;
533  }
534 
535  // Compare vector sizes
536  if (y.size() != rect.y.size())
537  {
538  return false;
539  }
540 
541  // Compare each Y boundary
542  for (size_t i = 0; i < y.size(); ++i)
543  {
544  if (!Same(y[i].min, rect.y[i].min) ||
545  !Same(y[i].max, rect.y[i].max) )
546  {
547  return false;
548  }
549  }
550 
551  return true;
552  }
553 #endif
554 };
555 
562 {
565 
572 
578  bool PointIsInside(double px, double py) const {
579  return x.PointIsInside(px) && y.PointIsInside(py);
580  }
581 
587  void UpdateBoundingBoxToInclude(double px, double py)
588  {
589  x.Update(px);
590  y.Update(py);
591  }
592 
597  void InitializeBoundingBox(double px, double py)
598  {
599  x.Set(px, px);
600  y.Set(py, py);
601  }
602 };
603 
607 enum
608 {
609  mpID_FIT = 2000,
617 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
618  mpID_CONFIG,
619 #endif // MP_ENABLE_CONFIG
623 };
624 
626 typedef enum __mp_Location_Type
627 {
638 } mpLocation;
639 
641 typedef enum __XAxis_Align_Type
642 {
648 } mpXAxis_Align;
649 
651 typedef enum __YAxis_Align_Type
652 {
658 } mpYAxis_Align;
659 
662 {
667 } mpPlot_Align;
668 
670 typedef enum __mp_Style_Type
671 {
675 } mpLegendStyle;
676 
679 {
683 
685 typedef enum __Symbol_Type
686 {
694 } mpSymbol;
695 
696 //-----------------------------------------------------------------------------
697 // mpLayer sub_type values
698 //-----------------------------------------------------------------------------
699 
701 typedef enum __Info_Type
702 {
707 } mpInfoType;
708 
710 typedef enum __Text_Type
711 {
715 } mpTextType;
716 
718 typedef enum __Function_Type
719 {
729 
731 typedef enum __Scale_Type
732 {
737 } mpScaleType;
738 
740 typedef enum __Chart_Type
741 {
746 } mpChartType;
747 
750 {
753 };
754 
757 {
777 };
778 
779 //-----------------------------------------------------------------------------
780 // mpLayer
781 //-----------------------------------------------------------------------------
782 
784 typedef enum __mp_Layer_Type
785 {
794 } mpLayerType;
795 
801 typedef enum __mp_Layer_ZOrder
802 {
811 } mpLayerZOrder;
812 
819 typedef enum __mp_Delete_Action
820 {
825 
836 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
837 {
838  public:
843  mpLayer(mpLayerType layerType);
844 
845  virtual ~mpLayer()
846  {
847  ;
848  }
849 
853  {
854  m_win = &w;
855  }
856 
864  virtual bool HasBBox()
865  {
866  return true;
867  }
868 
872  mpLayerType GetLayerType() const
873  {
874  return m_type;
875  }
876 
880  int GetLayerSubType() const
881  {
882  return m_subtype;
883  }
884 
890  virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
891  {
892  *subtype = m_subtype;
893  return (m_type == typeOfInterest);
894  }
895 
899  virtual double GetMinX()
900  {
901  return -1.0;
902  }
903 
907  virtual double GetMaxX()
908  {
909  return 1.0;
910  }
911 
915  virtual double GetMinY()
916  {
917  return -1.0;
918  }
919 
923  virtual double GetMaxY()
924  {
925  return 1.0;
926  }
927 
969  void Plot(wxDC &dc, mpWindow &w);
970 
974  void SetName(const wxString &name)
975  {
976  m_name = name;
977  }
978 
982  const wxString& GetName() const
983  {
984  return m_name;
985  }
986 
990  void SetFont(const wxFont &font)
991  {
992  m_font = font;
993  }
994 
998  const wxFont& GetFont() const
999  {
1000  return m_font;
1001  }
1002 
1006  void SetFontColour(const wxColour &colour)
1007  {
1008  m_fontcolour = colour;
1009  }
1010 
1014  const wxColour& GetFontColour() const
1015  {
1016  return m_fontcolour;
1017  }
1018 
1022  void SetPen(const wxPen &pen)
1023  {
1024  m_pen = pen;
1025  }
1026 
1030  const wxPen& GetPen() const
1031  {
1032  return m_pen;
1033  }
1034 
1037  void SetBrush(const wxBrush &brush)
1038  {
1039  if (brush == wxNullBrush)
1040  m_brush = *wxTRANSPARENT_BRUSH;
1041  else
1042  m_brush = brush;
1043  }
1044 
1048  void SetBrush(const wxColour &colour, enum wxBrushStyle style = wxBRUSHSTYLE_SOLID)
1049  {
1050  m_brush.SetColour(colour);
1051  m_brush.SetStyle(style);
1052  }
1053 
1056  const wxBrush& GetBrush() const
1057  {
1058  return m_brush;
1059  }
1060 
1063  void SetShowName(bool show)
1064  {
1065  m_showName = show;
1066  }
1067 
1070  bool GetShowName() const
1071  {
1072  return m_showName;
1073  }
1074 
1077  void SetDrawOutsideMargins(bool drawModeOutside)
1078  {
1079  m_drawOutsideMargins = drawModeOutside;
1080  }
1081 
1085  {
1086  return m_drawOutsideMargins;
1087  }
1088 
1093  wxBitmap GetColourSquare(int side = 16);
1094 
1097  bool IsVisible() const
1098  {
1099  return m_visible;
1100  }
1101 
1104  virtual void SetVisible(bool show)
1105  {
1106  m_visible = show;
1107  }
1108 
1111  bool IsTractable() const
1112  {
1113  return m_tractable;
1114  }
1115 
1118  virtual void SetTractable(bool track)
1119  {
1120  m_tractable = track;
1121  }
1122 
1125  void SetAlign(int align)
1126  {
1127  m_flags = align;
1128  }
1129 
1132  int GetAlign() const
1133  {
1134  return m_flags;
1135  }
1136 
1139  void SetCanDelete(bool canDelete)
1140  {
1141  m_CanDelete = canDelete;
1142  }
1143 
1146  bool GetCanDelete(void) const
1147  {
1148  return m_CanDelete;
1149  }
1150 
1153  mpLayerZOrder GetZIndex(void) const
1154  {
1155  return m_ZIndex;
1156  }
1157 
1158  protected:
1159  const mpLayerType m_type;
1162  wxFont m_font;
1163  wxColour m_fontcolour;
1164  wxPen m_pen;
1165  wxBrush m_brush;
1166  wxString m_name;
1167  bool m_showName;
1169  bool m_visible;
1171  int m_flags;
1174  mpLayerZOrder m_ZIndex;
1175 
1178  void UpdateContext(wxDC &dc) const;
1179 
1184  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1185 
1190  virtual bool DoBeforePlot()
1191  {
1192  return true;
1193  }
1194 
1201  void CheckLog(double *x, double *y, int yAxisID);
1202 
1203  private:
1204  bool m_busy;
1205  mpLayer() = delete; // default ctor not implemented/permitted
1206 
1208 };
1209 
1210 //-----------------------------------------------------------------------------
1211 // mpInfoLayer
1212 //-----------------------------------------------------------------------------
1213 
1220 {
1221  public:
1223  mpInfoLayer();
1224 
1229  mpInfoLayer(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1230 
1232  virtual ~mpInfoLayer();
1233 
1236  virtual void SetVisible(bool show);
1237 
1242  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1243 
1246  virtual bool HasBBox()
1247  {
1248  return false;
1249  }
1250 
1253  [[deprecated("Use Show() instead")]]
1254  virtual void ErasePlot(wxDC&, mpWindow&) {};
1255 
1259  virtual bool Inside(const wxPoint &point);
1260 
1264  virtual void Move(wxPoint delta, mpWindow &w);
1265 
1267  virtual void UpdateReference();
1268 
1271  wxPoint GetPosition() const
1272  {
1273  return m_dim.GetPosition();
1274  }
1275 
1278  void SetInitialPosition(wxPoint pos)
1279  {
1280  m_relX = pos.x / 100.0;
1281  m_relY = pos.y / 100.0;
1282  }
1283 
1286  wxSize GetSize() const
1287  {
1288  return m_dim.GetSize();
1289  }
1290 
1293  const wxRect& GetRectangle() const
1294  {
1295  return m_dim;
1296  }
1297 
1300  void SetLocation(mpLocation location)
1301  {
1302  m_location = location;
1303  }
1304 
1307  mpLocation GetLocation() const
1308  {
1309  return m_location;
1310  }
1311 
1312  protected:
1313  wxRect m_dim;
1314  wxBitmap* m_info_bmp;
1315  wxPoint m_reference;
1316  double m_relX;
1317  double m_relY;
1318  mpLocation m_location;
1319 
1324  virtual void DoPlot(wxDC &dc, mpWindow &w);
1325 
1328  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1329 
1330  private:
1331 
1333 };
1334 
1340 {
1341  public:
1343  mpInfoCoords();
1344 
1346  mpInfoCoords(mpLocation location);
1347 
1352  mpInfoCoords(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1353 
1356  {
1357  ;
1358  }
1359 
1363  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1364 
1367  [[deprecated("Use Show() instead")]]
1368  virtual void ErasePlot(wxDC&, mpWindow&) {};
1369 
1372  void Show(bool show)
1373  {
1374  m_show = show;
1375  }
1376 
1379  bool IsShown()
1380  {
1381  return m_show;
1382  }
1383 
1388  bool ShouldBeShown(wxRect plotArea, wxPoint mousePos)
1389  {
1390  return IsVisible() && (GetDrawOutsideMargins() || plotArea.Contains(mousePos));
1391  }
1392 
1396  void SetLabelMode(mpLabelType mode, unsigned int time_conv = MP_X_RAWTIME)
1397  {
1398  m_labelType = mode;
1399  m_timeConv = time_conv;
1400  }
1401 
1404  void SetSeriesCoord(bool show)
1405  {
1406  m_series_coord = show;
1407  }
1408 
1411  bool IsSeriesCoord() const
1412  {
1413  return m_series_coord;
1414  }
1415 
1421  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1422 
1425  void SetPenSeries(const wxPen &pen)
1426  {
1427  m_penSeries = pen;
1428  }
1429 
1433  void DrawContent(wxDC &dc, mpWindow &w);
1434 
1435  protected:
1436  bool m_show;
1437  wxString m_content;
1439  unsigned int m_timeConv;
1440  wxCoord m_mouseX;
1441  wxCoord m_mouseY;
1443  wxPen m_penSeries;
1444 
1449  virtual void DoPlot(wxDC &dc, mpWindow &w);
1450 
1451  private:
1452  std::unordered_map<int, double> m_yValList;
1453 
1455 };
1456 
1462 {
1463  public:
1465  mpInfoLegend();
1466 
1472  mpInfoLegend(wxPoint pos, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginUser);
1473 
1476 
1479  void SetItemMode(mpLegendStyle mode)
1480  {
1481  m_item_mode = mode;
1482  m_needs_update = true;
1483  }
1484 
1486  mpLegendStyle GetItemMode() const
1487  {
1488  return m_item_mode;
1489  }
1490 
1493  void SetItemDirection(mpLegendDirection mode)
1494  {
1495  m_item_direction = mode;
1496  m_needs_update = true;
1497  }
1498 
1500  mpLegendDirection GetItemDirection() const
1501  {
1502  return m_item_direction;
1503  }
1504 
1507  {
1508  m_needs_update = true;
1509  }
1510 
1513  void ShowDraggedSeries(bool active)
1514  {
1515  m_showDraggedSeries = active;
1516  }
1517 
1521  {
1522  return m_showDraggedSeries;
1523  }
1524 
1527  void EnableSeriesValues(bool enable)
1528  {
1529  m_enableSeriesValues = enable;
1530  m_maxSeriesValueWidth = 0;
1531  }
1532 
1536  {
1537  return m_enableSeriesValues;
1538  }
1539 
1543  bool SeriesValuesShouldBeShown(wxRect plotArea, wxPoint mousePos)
1544  {
1545  return m_enableSeriesValues && plotArea.Contains(mousePos);
1546  }
1547 
1550  void ShowSeriesValues(bool show)
1551  {
1552  m_showSeriesValues = show;
1553  }
1554 
1558  {
1559  return m_showSeriesValues && IsVisible();
1560  }
1561 
1567  int GetLegendHitRegion(wxPoint mousePos);
1568 
1575  void DrawDraggedSeries(wxDC& dc, mpWindow &w);
1576 
1580  void DrawContent(wxDC &dc, mpWindow &w);
1581 
1584  void RestoreAxisHighlighting(mpWindow &w);
1585 
1587  enum HitCode : int
1588  {
1589  HitNone = -1,
1590  HitHeader = -2
1591  };
1592 
1593  mpFunction* m_selectedSeries = nullptr;
1594  mpOptional_int m_lastHoveredAxisID = std::nullopt;
1595 
1596  protected:
1597  mpLegendStyle m_item_mode;
1598  mpLegendDirection m_item_direction;
1600  wxString m_headerString = wxString::FromUTF8("≡");
1601 
1606  virtual void DoPlot(wxDC &dc, mpWindow &w);
1607 
1608  private:
1610  struct LegendDetail
1611  {
1612  unsigned int layerIdx;
1613  wxCoord legendEnd;
1614  };
1616  std::vector<LegendDetail> m_LegendDetailList;
1617  wxCoord m_headerEnd;
1618  bool m_needs_update;
1619  int m_maxSeriesValueWidth;
1620  bool m_enableSeriesValues;
1621  bool m_showSeriesValues;
1622 
1633  void UpdateBitmap(wxDC &dc, mpWindow &w);
1634 
1643  int GetMaxLabelWidth(wxDC &dc, mpWindow &w);
1644 
1665  int DrawSeriesValue(wxDC& dc, mpWindow& w, mpFunction& function, int posX, int posY, int labelHeight, int labelWidth, int maxLabelWidth);
1666 
1667  private:
1669 };
1670 
1671 //-----------------------------------------------------------------------------
1672 // mpLayer implementations - functions
1673 //-----------------------------------------------------------------------------
1674 
1675 
1683 {
1684  public:
1690  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1691 
1695  void SetContinuity(bool continuity)
1696  {
1697  m_continuous = continuity;
1698  }
1699 
1703  bool GetContinuity() const
1704  {
1705  return m_continuous;
1706  }
1707 
1710  void SetStep(unsigned int step)
1711  {
1712  m_step = step;
1713  }
1714 
1717  unsigned int GetStep() const
1718  {
1719  return m_step;
1720  }
1721 
1724  void SetSymbol(mpSymbol symbol)
1725  {
1726  m_symbol = symbol;
1727  }
1728 
1731  mpSymbol GetSymbol() const
1732  {
1733  return m_symbol;
1734  }
1735 
1738  void SetSymbolSize(int size)
1739  {
1740  m_symbolSize = size;
1741  }
1742 
1745  int GetSymbolSize() const
1746  {
1747  return m_symbolSize;
1748  }
1749 
1753  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1754 
1758  std::optional<double> GetSeriesValue(double xValue);
1759 
1763  int GetYAxisID() const
1764  {
1765  return m_yAxisID;
1766  }
1767 
1772  void SetYAxisID(unsigned int yAxisID)
1773  {
1774  m_yAxisID = yAxisID;
1775  }
1776 
1780  void SetLegendIsAlwaysVisible(bool alwaysVisible)
1781  {
1782  m_LegendIsAlwaysVisible = alwaysVisible;
1783  }
1784 
1789  {
1790  return m_LegendIsAlwaysVisible;
1791  }
1792 
1796  void SetAutoStep(bool enable)
1797  {
1798  m_autoStep = enable;
1799  }
1800 
1803  bool GetAutoStep() const
1804  {
1805  return m_autoStep;
1806  }
1807 
1811  void SetMaxNOfPoints(size_t nOfPoints)
1812  {
1813  m_maxNOfPoints = nOfPoints;
1814  }
1815 
1818  size_t GetMaxNOfPoints() const
1819  {
1820  return m_maxNOfPoints;
1821  }
1822 
1823  protected:
1825  mpSymbol m_symbol;
1827  unsigned int m_step;
1830  bool m_autoStep;
1832 
1833  private:
1835 };
1836 
1840 {
1841  public:
1848  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1849 
1850  // We don't want to include line (horizontal or vertical) in BBox computation
1851  virtual bool HasBBox() override
1852  {
1853  return false;
1854  }
1855 
1859  double GetValue() const
1860  {
1861  return m_value;
1862  }
1863 
1867  void SetValue(const double value)
1868  {
1869  m_value = value;
1870  }
1871 
1875  bool IsHorizontal(void) const
1876  {
1877  return m_IsHorizontal;
1878  }
1879 
1880  protected:
1881  double m_value;
1883 
1884  private:
1886 };
1887 
1891 {
1892  public:
1899  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1900 
1904  void SetYValue(const double yvalue)
1905  {
1906  SetValue(yvalue);
1907  }
1908 
1909  protected:
1910 
1911  virtual void DoPlot(wxDC &dc, mpWindow &w);
1912 
1913  private:
1915 };
1916 
1920 {
1921  public:
1927  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1928 
1932  void SetXValue(const double xvalue)
1933  {
1934  SetValue(xvalue);
1935  }
1936 
1937  protected:
1938 
1939  virtual void DoPlot(wxDC &dc, mpWindow &w);
1940 
1945  virtual bool DoBeforePlot()
1946  {
1947  return true;
1948  }
1949 
1950  private:
1952 };
1953 
1961 {
1962  public:
1967  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
1968 
1974  virtual double GetY(double x) = 0;
1975 
1982  double DoGetY(double x);
1983 
1988  void DefineDoGetY(void);
1989 
1990  protected:
1991 
1992  double (mpFX::*pDoGetY)(double x);
1993 
1998  virtual void DoPlot(wxDC &dc, mpWindow &w);
1999 
2004  double NormalDoGetY(double x);
2005 
2010  double LogDoGetY(double x);
2011 
2012  private:
2014 };
2015 
2023 {
2024  public:
2029  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
2030 
2036  virtual double GetX(double y) = 0;
2037 
2044  double DoGetX(double y);
2045 
2050  void DefineDoGetX(void);
2051 
2052  protected:
2053 
2054  double (mpFY::*pDoGetX)(double y);
2055 
2060  virtual void DoPlot(wxDC &dc, mpWindow &w);
2061 
2066  double NormalDoGetX(double y);
2067 
2072  double LogDoGetX(double y);
2073 
2074  private:
2076 };
2077 
2088 {
2089  public:
2095  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2096 
2100  virtual void Rewind() = 0;
2101 
2105  virtual void Clear()
2106  {
2107  ;
2108  }
2109 
2113  virtual size_t GetSize()
2114  {
2115  return 0;
2116  }
2117 
2124  virtual bool GetNextXY(double *x, double *y) = 0;
2125 
2132  bool DoGetNextXY(double *x, double *y);
2133 
2138  void SetViewMode(bool asBar);
2139 
2144  int GetBarWidth(void) const
2145  {
2146  return m_BarWidth;
2147  }
2148 
2153  bool ViewAsBar(void) const
2154  {
2155  return m_ViewAsBar;
2156  }
2157 
2158  protected:
2159 
2160  // Data to calculate label positioning
2163 
2164  // Min delta between 2 x coordinate (used for view as bar)
2165  double m_deltaX;
2166  double m_deltaY;
2167 
2169 
2170  bool m_ViewAsBar = false;
2171 
2178  virtual void DoPlot(wxDC &dc, mpWindow &w);
2179 
2184  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
2185 
2186  private:
2188 };
2189 
2190 //-----------------------------------------------------------------------------
2191 // mpFXYVector - provided by Jose Luis Blanco
2192 //-----------------------------------------------------------------------------
2193 
2214 {
2215  public:
2221  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2222 
2225  virtual ~mpFXYVector()
2226  {
2227  Clear();
2228  }
2229 
2234  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
2235 
2239  void Clear() override;
2240 
2245  virtual size_t GetSize() override
2246  {
2247  return m_xs.size();
2248  }
2249 
2257  bool AddData(const double x, const double y, bool updatePlot);
2258 
2265  void SetReserve(int reserve)
2266  {
2267  m_reserveXY = reserve;
2268  m_xs.reserve(m_reserveXY);
2269  m_ys.reserve(m_reserveXY);
2270  }
2271 
2275  int GetReserve() const
2276  {
2277  return m_reserveXY;
2278  }
2279 
2280  protected:
2281  std::vector<double> m_xs;
2282  std::vector<double> m_ys;
2285  size_t m_index;
2286  size_t m_endIndex;
2288  double m_lastX;
2290  double m_lastY;
2291 
2296  virtual void Rewind() override;
2297 
2304  virtual bool GetNextXY(double *x, double *y) override;
2305 
2310  void DrawAddedPoint(double x, double y);
2311 
2314  virtual double GetMinX()override
2315  {
2316  if (m_ViewAsBar)
2317  {
2318  // Make extra space for outer bars
2319  return m_rangeX.min - (m_deltaX / 2);
2320  }
2321  else
2322  {
2323  return m_rangeX.min;
2324  }
2325  }
2326 
2329  virtual double GetMinY() override
2330  {
2331  return m_rangeY.min;
2332  }
2333 
2336  virtual double GetMaxX() override
2337  {
2338  if(m_ViewAsBar)
2339  {
2340  // Make extra space for outer bars
2341  return m_rangeX.max + (m_deltaX / 2);
2342  }
2343  else
2344  {
2345  return m_rangeX.max;
2346  }
2347  }
2348 
2351  virtual double GetMaxY() override
2352  {
2353  return m_rangeY.max;
2354  }
2355 
2356  private:
2359  void First_Point(double x, double y);
2360 
2363  void Check_Limit(double val, mpRange<double> *range, double *last, double *delta);
2364 
2366 };
2367 
2377 {
2378  public:
2382  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
2383 
2389  virtual double GetY(double x) = 0;
2390 
2391  protected:
2392 
2397  virtual void DoPlot(wxDC &dc, mpWindow &w);
2398 
2399  private:
2401 };
2402 
2407 class mpFXGeneric: public mpFX
2408 {
2409  public:
2414  mpFXGeneric(const wxString &name = wxT("Generic FX function"), int flags = mpALIGN_LEFT, unsigned int yAxisID = 0) :
2415  mpFX(name, flags, yAxisID)
2416  {
2417  wxPen FXpen(*wxBLUE, 1, wxPENSTYLE_SOLID);
2418  SetDrawOutsideMargins(false);
2419  SetContinuity(true);
2420  SetPen(FXpen);
2421  SetStep(8); // Draw one point over eight
2422  }
2423 
2428  virtual double GetY(double x)
2429  {
2430  double y;
2431  try
2432  {
2433  y = ComputeY(x);
2434  }
2435  catch (...)
2436  {
2437  y = 0;
2438  }
2439  m_rangeY.Update(y);
2440  return y;
2441  }
2442 
2447  virtual double GetMinY()
2448  {
2449  return m_rangeY.min;
2450  }
2451 
2456  virtual double GetMaxY()
2457  {
2458  return m_rangeY.max;
2459  }
2460 
2461  protected:
2463 
2469  virtual double ComputeY(double x) = 0;
2470 
2471  private:
2473 };
2474 
2480 {
2481  public:
2487  mpGaussian(double mu, double sigma) :
2488  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2489  {
2490  m_mu = mu;
2491  m_sigma = sigma;
2492  m_variance = sigma * sigma;
2493  m_const = 1.0 / sqrt(2.0 * M_PI * m_variance);
2494  }
2495 
2496  protected:
2497  double m_mu;
2498  double m_sigma;
2499  double m_variance;
2500  double m_const;
2501 
2502  virtual double ComputeY(double x)
2503  {
2504  return m_const * exp(-(x - m_mu) * (x - m_mu) / (2.0 * m_variance));
2505  }
2506 
2507  private:
2509 };
2510 
2515 class mpNormal: public mpFXGeneric
2516 {
2517  public:
2523  mpNormal(double mu, double sigma) :
2524  mpFXGeneric(wxT("Normal"), mpALIGN_LEFT)
2525  {
2526  m_mu = mu;
2527  m_sigma = sigma;
2528  m_variance = sigma * sigma;
2529  m_const = 1.0 / (m_variance * sqrt(2.0 * M_PI));
2530  }
2531 
2532  protected:
2533  double m_mu;
2534  double m_sigma;
2535  double m_variance;
2536  double m_const;
2537 
2538  virtual double ComputeY(double x)
2539  {
2540  if (x < 0)
2541  return 0.0;
2542  else
2543  {
2544  double tmp = log(x) - m_mu;
2545  return m_const * exp(-tmp * tmp / (2.0 * m_variance)) / x;
2546  }
2547  }
2548 
2549  private:
2551 };
2552 
2553 //-----------------------------------------------------------------------------
2554 // mpChart
2555 //-----------------------------------------------------------------------------
2559 {
2560  public:
2562  mpChart(const wxString &name = wxEmptyString);
2563 
2566  {
2567  Clear();
2568  }
2569 
2572  void SetChartValues(const std::vector<double> &data);
2573 
2576  void SetChartLabels(const std::vector<std::string> &labelArray);
2577 
2582  void AddData(const double &data, const std::string &label);
2583 
2587  virtual void Clear();
2588 
2589  virtual bool HasBBox()
2590  {
2591  return (values.size() > 0);
2592  }
2593 
2594  protected:
2595  std::vector<double> values;
2596  std::vector<std::string> labels;
2597 
2598  double m_max_value;
2599  double m_total_value;
2600 
2601  private:
2603 };
2604 
2605 //-----------------------------------------------------------------------------
2606 // mpBarChart - provided by Jose Davide Rondini
2607 //-----------------------------------------------------------------------------
2608 /* Defines for bar charts label positioning. */
2609 #define mpBAR_NONE 0
2610 #define mpBAR_AXIS_H 1
2611 #define mpBAR_AXIS_V 2
2612 #define mpBAR_INSIDE 3
2613 #define mpBAR_TOP 4
2614 
2615 
2618 {
2619  public:
2621  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2622 
2625  {
2626  Clear();
2627  }
2628 
2630  void SetBarColour(const wxColour &colour);
2631 
2633  void SetColumnWidth(const double colWidth)
2634  {
2635  m_width = colWidth;
2636  }
2637 
2639  void SetBarLabelPosition(int position);
2640 
2644  virtual double GetMinX();
2645 
2649  virtual double GetMaxX();
2650 
2654  virtual double GetMinY();
2655 
2659  virtual double GetMaxY();
2660 
2661  protected:
2662 
2663  double m_width;
2664  wxColour m_barColour;
2666  double m_labelAngle;
2667 
2672  virtual void DoPlot(wxDC &dc, mpWindow &w);
2673 
2674  private:
2676 };
2677 
2682 {
2683  public:
2687  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2688 
2691  {
2692  Clear();
2693  colours.clear();
2694  }
2695 
2699  void SetCenter(const wxPoint center)
2700  {
2701  m_center = center;
2702  }
2703 
2707  wxPoint GetCenter(void) const
2708  {
2709  return m_center;
2710  }
2711 
2715  void SetPieColours(const std::vector<wxColour> &colourArray);
2716 
2720  virtual double GetMinX()
2721  {
2722  return m_center.x - m_radius;
2723  }
2724 
2728  virtual double GetMaxX()
2729  {
2730  return m_center.x + m_radius;
2731  }
2732 
2736  virtual double GetMinY()
2737  {
2738  return m_center.y - m_radius;
2739  }
2740 
2744  virtual double GetMaxY()
2745  {
2746  return m_center.y + m_radius;
2747  }
2748 
2749  protected:
2750 
2751  double m_radius;
2752  wxPoint m_center;
2753  std::vector<wxColour> colours;
2754 
2759  virtual void DoPlot(wxDC &dc, mpWindow &w);
2760 
2762  const wxColour& GetColour(unsigned int id);
2763 
2764  private:
2766 };
2767 
2770 //-----------------------------------------------------------------------------
2771 // mpLayer implementations - furniture (scales, ...)
2772 //-----------------------------------------------------------------------------
2781 {
2782  public:
2790  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, mpOptional_uint axisID = std::nullopt);
2791 
2795  virtual bool HasBBox()
2796  {
2797  return false;
2798  }
2799 
2803  int GetAxisID(void)
2804  {
2805  return m_axisID;
2806  }
2807 
2812  void SetAxisID(unsigned int yAxisID)
2813  {
2814  m_axisID = yAxisID;
2815  }
2816 
2819  void ShowTicks(bool ticks)
2820  {
2821  m_ticks = ticks;
2822  }
2823 
2826  bool GetShowTicks() const
2827  {
2828  return m_ticks;
2829  }
2830 
2833  void ShowGrids(bool grids)
2834  {
2835  m_grids = grids;
2836  }
2837 
2840  bool GetShowGrids() const
2841  {
2842  return m_grids;
2843  }
2844 
2849  void SetLabelFormat(const wxString &format, bool updateLabelMode = false)
2850  {
2851  m_labelFormat = format;
2852  if (updateLabelMode)
2853  m_labelType = mpLabel_USER;
2854  }
2855 
2859  {
2860  return m_labelType;
2861  }
2862 
2866  void SetLabelMode(mpLabelType mode, unsigned int time_conv = MP_X_RAWTIME)
2867  {
2868  m_labelType = mode;
2869  m_timeConv = time_conv;
2870  }
2871 
2874  const wxString& GetLabelFormat() const
2875  {
2876  return m_labelFormat;
2877  }
2878 
2882  void SetGridPen(const wxPen &pen)
2883  {
2884  m_gridpen = pen;
2885  }
2886 
2890  const wxPen& GetGridPen() const
2891  {
2892  return m_gridpen;
2893  }
2894 
2898  void SetAuto(bool automaticScalingIsEnabled)
2899  {
2900  m_auto = automaticScalingIsEnabled;
2901  }
2902 
2906  bool GetAuto() const
2907  {
2908  return m_auto;
2909  }
2910 
2914  void SetMinScale(double min)
2915  {
2916  m_axisRange.SetMin(min);
2917  }
2918 
2922  double GetMinScale() const
2923  {
2924  return m_axisRange.min;
2925  }
2926 
2930  void SetMaxScale(double max)
2931  {
2932  m_axisRange.SetMax(max);
2933  }
2934 
2938  double GetMaxScale() const
2939  {
2940  return m_axisRange.max;
2941  }
2942 
2947  void SetScale(double min, double max)
2948  {
2949  m_axisRange.Set(min, max);
2950  }
2951 
2956  void GetScale(double *min, double *max) const
2957  {
2958  *min = m_axisRange.min;
2959  *max = m_axisRange.max;
2960  }
2961 
2966  {
2967  m_axisRange = range;
2968  }
2969 
2974  {
2975  return mpRange<double>(m_axisRange);
2976  }
2977 
2981  void SetHovering(bool hover)
2982  {
2983  m_hover = hover;
2984  }
2985 
2989  virtual bool IsLogAxis()
2990  {
2991  return m_isLog;
2992  }
2993 
2997  virtual void SetLogAxis(bool log)
2998  {
2999  m_isLog = log;
3000  }
3001 
3005  void SetCoordIsAlwaysVisible(bool alwaysVisible)
3006  {
3007  m_CoordIsAlwaysVisible = alwaysVisible;
3008  }
3009 
3014  {
3015  return m_CoordIsAlwaysVisible;
3016  }
3017 
3018  protected:
3019  static const wxCoord kTickSize = 4;
3020  static const wxCoord kAxisExtraSpace = 6;
3021 
3022  int m_axisID;
3023  wxPen m_gridpen;
3024  bool m_ticks;
3025  bool m_grids;
3026  bool m_auto;
3029  unsigned int m_timeConv;
3030  wxString m_labelFormat;
3031  bool m_isLog;
3032  bool m_hover = false;
3034 
3037  virtual int GetOrigin(mpWindow &w) = 0;
3038 
3045  double GetStep(double scale, int minLabelSpacing);
3046 
3054  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
3055 
3061  wxString FormatLabelValue(double value);
3062 
3067  wxString FormatLogValue(double n);
3068 
3075  int GetLabelWidth(double value, wxDC &dc);
3076 
3081  bool UseScientific(double maxAxisValue);
3082 
3088  int GetSignificantDigits(double step, double maxAxisValue);
3089 
3094  int GetDecimalDigits(double step);
3095 
3099  struct {
3100  double step;
3101  double maxAxisValue;
3102  bool UseScientific;
3103  int SignificantDigits;
3104  int DecimalDigits;
3105  double EpsilonScale;
3106  } m_ScaleConstraints;
3107 
3111  void ComputeScaleConstraints(double step, double maxAxisValue);
3112 
3113  private:
3115 };
3116 
3117 
3124 {
3125  public:
3131  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, mpLabelType type = mpLabel_AUTO) :
3132  mpScale(name, flags, grids, type)
3133  {
3134  m_subtype = mpsScaleX;
3135  }
3136 
3138  bool IsTopAxis()
3139  {
3140  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
3141  }
3142 
3145  {
3146  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
3147  }
3148 
3149  protected:
3154  static int m_orgy;
3155 
3158  virtual void DoPlot(wxDC &dc, mpWindow &w);
3159 
3160  virtual int GetOrigin(mpWindow &w);
3161  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
3162 
3163  private:
3165 
3169  friend mpScaleY;
3170 };
3171 
3179 {
3180  public:
3188  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, mpOptional_uint yAxisID = std::nullopt, mpLabelType labelType = mpLabel_AUTO) :
3189  mpScale(name, flags, grids, labelType, yAxisID)
3190  {
3191  m_subtype = mpsScaleY;
3192  m_axisWidth = MP_Y_BORDER_SEPARATION;
3193  m_xPos = 0;
3194  }
3195 
3198  void UpdateAxisWidth(mpWindow &w);
3199 
3202  {
3203  return m_axisWidth;
3204  }
3205 
3207  bool IsLeftAxis()
3208  {
3209  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
3210  }
3211 
3214  {
3215  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
3216  }
3217 
3219  bool IsInside(wxCoord xPixel)
3220  {
3221  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
3222  {
3223  return true;
3224  }
3225  return false;
3226  }
3227 
3228  protected:
3230  int m_xPos;
3231 
3234  virtual void DoPlot(wxDC &dc, mpWindow &w);
3235 
3236  virtual int GetOrigin(mpWindow &w);
3237  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
3238 
3239  private:
3241 };
3242 
3243 //-----------------------------------------------------------------------------
3244 // mpWindow
3245 //-----------------------------------------------------------------------------
3246 
3252 #define mpMOUSEMODE_DRAG 0
3253 
3254 #define mpMOUSEMODE_ZOOMBOX 1
3255 
3258 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
3259 typedef std::deque<mpLayer*> mpLayerList;
3260 
3271 {
3272  mpScale* axis = nullptr;
3273  double scale = 1.0;
3274  double pos = 0;
3278 
3279  // Note: we don't use the default operator since we don't want to compare axis pointers
3281  bool operator==(const mpAxisData& other) const
3282  {
3283  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
3284  (bound == other.bound) && (desired == other.desired);
3285  }
3286 };
3287 
3289 typedef std::map<int, mpAxisData> mpAxisList;
3290 
3297 typedef enum {
3298  uXAxis = 1,
3299  uYAxis = 2,
3300  uXYAxis = 3
3301 } mpAxisUpdate;
3302 
3312 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
3313 
3320 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
3321 
3327 {
3328  public:
3329  mpMagnet()
3330  {
3331  m_enable = false;
3332  m_show = false;
3333  }
3334  ~mpMagnet()
3335  {
3336  ;
3337  }
3338 
3340  void UpdateBox(const wxRect &plotArea)
3341  {
3342  m_domain = plotArea;
3343  }
3344 
3346  void Enable(bool enable)
3347  {
3348  m_enable = enable;
3349  }
3350 
3352  bool IsEnabled() const
3353  {
3354  return m_enable;
3355  }
3356 
3358  void DrawCross(wxDC &dc, mpWindow &w);
3359 
3361  bool ShouldBeShown(wxPoint mousePos)
3362  {
3363  return m_enable && m_domain.Contains(mousePos);
3364  }
3365 
3367  void Show(bool show)
3368  {
3369  m_show = show;
3370  }
3371 
3373  bool IsShown()
3374  {
3375  return m_show;
3376  }
3377 
3378  private:
3379  bool m_enable;
3380  bool m_show;
3381  wxRect m_domain;
3382 };
3383 
3405 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
3406 {
3407  public:
3408  mpWindow()
3409  {
3410  InitParameters();
3411  }
3412 
3420  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
3421  long flags = 0);
3422 
3423  ~mpWindow();
3424 
3428  wxMenu* GetPopupMenu()
3429  {
3430  return &m_popmenu;
3431  }
3432 
3441  bool AddLayer(mpLayer *layer, bool refreshDisplay = true, bool refreshConfig = true);
3442 
3455  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
3456 
3462  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
3463 
3470  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
3471 
3478  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
3479 
3485  mpLayer* GetLayer(int position);
3486 
3491  int GetLayerPosition(mpLayer* layer);
3492 
3499  mpLayer* GetLayersType(int position, mpLayerType type);
3500 
3507  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
3508 
3514  mpScale* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
3515 
3524  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
3525 
3534  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
3535 
3540  mpLayer* GetLayerByName(const wxString &name);
3541 
3546  mpLayer* GetLayerByClassName(const wxString &name);
3547 
3551  void RefreshLegend(void);
3552 
3557  bool IsYAxisUsed(int yAxisID);
3558 
3564  bool IsYAxisUsedByFunction(int yAxisID, int *position);
3565 
3569  mpScaleX* GetLayerXAxis();
3570 
3574  mpScaleY* GetLayerYAxis(int yAxisID);
3575 
3579  void SetScaleX(const double scaleX)
3580  {
3581  if (MP_ISNOTNULL(scaleX))
3582  {
3583  m_AxisDataX.scale = scaleX;
3584  UpdateDesiredBoundingBox(uXAxis);
3585  }
3586  UpdateAll();
3587  }
3588 
3593  double GetScaleX(void) const
3594  {
3595  return m_AxisDataX.scale;
3596  }
3597 
3602  void SetScaleY(const double scaleY, int yAxisID)
3603  {
3604  assert(m_AxisDataYList.count(yAxisID) != 0);
3605  if (MP_ISNOTNULL(scaleY))
3606  {
3607  m_AxisDataYList[yAxisID].scale = scaleY;
3608  UpdateDesiredBoundingBox(uYAxis);
3609  }
3610  UpdateAll();
3611  }
3612 
3618  double GetScaleY(int yAxisID)
3619  {
3620  assert(m_AxisDataYList.count(yAxisID) != 0);
3621  return m_AxisDataYList[yAxisID].scale;
3622  } // Schaling's method: maybe another method exists with the same name
3623 
3624  [[deprecated("Incomplete, use UpdateBBox instead")]]
3627  void SetBound();
3628 
3631  {
3632  return m_AxisDataX.bound;
3633  }
3634 
3637  {
3638  return m_AxisDataX.desired;
3639  }
3640 
3645  {
3646  assert(m_AxisDataYList.count(yAxisID) != 0);
3647  return m_AxisDataYList[yAxisID].bound;
3648  }
3649 
3654  {
3655  assert(m_AxisDataYList.count(yAxisID) != 0);
3656  return m_AxisDataYList[yAxisID].desired;
3657  }
3658 
3663  std::unordered_map<int, mpRange<double>> GetAllBoundY()
3664  {
3665  std::unordered_map<int, mpRange<double>> yRange;
3666  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
3667  {
3668  yRange[m_yID] = m_yData.bound;
3669  }
3670  return yRange;
3671  }
3672 
3677  std::unordered_map<int, mpRange<double>> GetAllDesiredY()
3678  {
3679  std::unordered_map<int, mpRange<double>> yRange;
3680  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
3681  {
3682  yRange[m_yID] = m_yData.desired;
3683  }
3684  return yRange;
3685  }
3686 
3690  void SetPosX(const double posX)
3691  {
3692  m_AxisDataX.pos = posX;
3693  UpdateDesiredBoundingBox(uXAxis);
3694  UpdateAll();
3695  }
3696 
3701  double GetPosX(void) const
3702  {
3703  return m_AxisDataX.pos;
3704  }
3705 
3710  void SetPosY(std::unordered_map<int, double>& posYList)
3711  {
3712  for (auto& [m_yID, m_yData] : m_AxisDataYList)
3713  {
3714  m_yData.pos = posYList[m_yID];
3715  }
3716  UpdateDesiredBoundingBox(uYAxis);
3717  UpdateAll();
3718  }
3719 
3725  double GetPosY(int yAxisID)
3726  {
3727  assert(m_AxisDataYList.count(yAxisID) != 0);
3728  return m_AxisDataYList[yAxisID].pos;
3729  }
3730 
3734  int GetNOfYAxis(void) const
3735  {
3736  return (int)m_AxisDataYList.size();
3737  }
3738 
3742  mpAxisList GetAxisDataYList(void) const
3743  {
3744  return m_AxisDataYList;
3745  }
3746 
3752  void SetScreen(const int scrX, const int scrY)
3753  {
3754  m_scrX = scrX;
3755  m_scrY = scrY;
3756  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3757  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3758 
3759  m_plotBoundaries.endPx = m_scrX;
3760  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3761  m_plotBoundaries.endPy = m_scrY;
3762  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3763 
3764  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3765  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3766 
3767  m_magnet.UpdateBox(m_PlotArea);
3768  }
3769 
3776  int GetScreenX(void) const
3777  {
3778  return m_scrX;
3779  }
3780 
3787  int GetScreenY(void) const
3788  {
3789  return m_scrY;
3790  }
3791 
3797  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3798  {
3799  m_AxisDataX.pos = posX;
3800  SetPosY(posYList);
3801  }
3802 
3806  double p2x(const wxCoord pixelCoordX) const
3807  {
3808  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3809  }
3810 
3814  double p2y(const wxCoord pixelCoordY, int yAxisID = 0)
3815  {
3816  assert(m_AxisDataYList.count(yAxisID) != 0);
3817  if (m_AxisDataYList.count(yAxisID) == 0)
3818  return 0.0;
3819  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3820  }
3821 
3825  wxCoord x2p(const double x) const
3826  {
3827  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3828  }
3829 
3833  wxCoord y2p(const double y, int yAxisID = 0)
3834  {
3835  assert(m_AxisDataYList.count(yAxisID) != 0);
3836  if (m_AxisDataYList.count(yAxisID) == 0)
3837  return 0;
3838  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3839  }
3840 
3842  [[deprecated("Deprecated - use EnableBufferedPaintDC??")]]
3843  void EnableDoubleBuffer(const bool enabled)
3844  {
3845  EnableBufferedPaintDC(enabled);
3846  }
3847 
3851  void EnableBufferedPaintDC(const bool enabled)
3852  {
3853  m_enableBufferedPaintDC = enabled;
3854  }
3855 
3858  void EnableMousePanZoom(const bool enabled)
3859  {
3860  m_enableMouseNavigation = enabled;
3861  }
3862 
3868  void LockAspect(bool enable = true);
3869 
3874  bool IsAspectLocked() const
3875  {
3876  return m_lockaspect;
3877  }
3878 
3883  void Fit();
3884 
3891  void Fit(const mpRange<double> &rangeX, std::unordered_map<int, mpRange<double>> rangeY, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3892 
3896  void FitX(void);
3897 
3902  void FitY(int yAxisID);
3903 
3908  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
3909 
3914  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
3915 
3917  void ZoomInX();
3918 
3920  void ZoomOutX();
3921 
3924  void ZoomInY(mpOptional_int yAxisID = std::nullopt);
3925 
3928  void ZoomOutY(mpOptional_int yAxisID = std::nullopt);
3929 
3934  void ZoomRect(wxPoint p0, wxPoint p1);
3935 
3937  void UpdateAll();
3938 
3939  // Added methods by Davide Rondini
3940 
3944  unsigned int CountLayers();
3945 
3948  unsigned int CountAllLayers()
3949  {
3950  return (unsigned int)m_layers.size();
3951  }
3952 
3956  unsigned int CountLayersType(mpLayerType type);
3957 
3961  unsigned int CountLayersFXYPlot();
3962 
3970  {
3971  // Change on X axis
3972  if (update & uXAxis)
3973  {
3974  m_AxisDataX.desired.Set(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale),
3975  m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3976  }
3977 
3978  // Change on Y axis
3979  if (update & uYAxis)
3980  {
3981  for (auto& [m_yID, m_yData] : m_AxisDataYList)
3982  {
3983  m_yData.desired.Set(m_yData.pos - ((m_margin.top + m_plotHeight) / m_yData.scale),
3984  m_yData.pos - (m_margin.top / m_yData.scale));
3985  }
3986  }
3987  }
3988 
3994  mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID = 0)
3995  {
3996  assert(m_AxisDataYList.count(yAxisID) != 0);
3997  if (desired)
3998  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
3999  else
4000  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
4001  }
4002 
4006  double GetDesiredXmin() const
4007  {
4008  return m_AxisDataX.desired.min;
4009  }
4010 
4015  double GetDesiredXmax() const
4016  {
4017  return m_AxisDataX.desired.max;
4018  }
4019 
4025  double GetDesiredYmin(int yAxisID)
4026  {
4027  assert(m_AxisDataYList.count(yAxisID) != 0);
4028  return m_AxisDataYList[yAxisID].desired.min;
4029  }
4030 
4036  double GetDesiredYmax(int yAxisID)
4037  {
4038  assert(m_AxisDataYList.count(yAxisID) != 0);
4039  return m_AxisDataYList[yAxisID].desired.max;
4040  }
4041 
4047  bool GetBoundingBox(mpRange<double> *boundX, mpRange<double> *boundY, int yAxisID)
4048  {
4049  if (m_AxisDataYList.count(yAxisID) == 0)
4050  return false;
4051  *boundX = m_AxisDataX.bound;
4052  *boundY = m_AxisDataYList[yAxisID].bound;
4053  return true;
4054  }
4055 
4061  bool PointIsInsideBound(double px, double py, int yAxisID)
4062  {
4063  if (m_AxisDataYList.count(yAxisID) == 0)
4064  return false;
4065 
4066  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
4067  }
4068 
4074  void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
4075  {
4076  if (m_AxisDataYList.count(yAxisID) == 0)
4077  return ;
4078 
4079  m_AxisDataX.bound.Update(px);
4080  m_AxisDataYList[yAxisID].bound.Update(py);
4081  }
4082 
4083  /* Initialize bounding box with an initial point
4084  * @param px point on x-axis
4085  * @param py point on y-axis
4086  * @param yAxisID the y-axis ID
4087  */
4089  void InitializeBoundingBox(double px, double py, int yAxisID)
4090  {
4091  if (m_AxisDataYList.count(yAxisID) == 0)
4092  return ;
4093 
4094  m_AxisDataX.bound.Set(px, px);
4095  m_AxisDataYList[yAxisID].bound.Set(py, py);
4096  }
4097 
4100  void SetMPScrollbars(bool status);
4101 
4104  bool GetMPScrollbars() const
4105  {
4106  return m_enableScrollBars;
4107  }
4108 
4114  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
4115 
4119  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4120 
4124  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4125 
4129  void SetWildcard(const wxString &wildcard)
4130  {
4131  m_wildcard = wildcard;
4132  }
4133 
4137  const wxString& GetWildcard(void) const
4138  {
4139  return m_wildcard;
4140  }
4141 
4149  bool LoadFile(const wxString &filename = wxEmptyString);
4150 
4155  void SetDefaultDir(const wxString &dirname)
4156  {
4157  m_DefaultDir = dirname;
4158  }
4159 
4163 
4168 
4175  {
4176  m_DefaultLegendIsAlwaysVisible = visible;
4177  }
4178 
4183 
4184 
4189  void SetAutoFit(bool autoFit)
4190  {
4191  m_autoFit = autoFit;
4192  }
4193 
4200  void SetMargins(int top, int right, int bottom, int left);
4201 
4204  {
4205  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4206  }
4207 
4209  void SetMarginTop(int top)
4210  {
4211  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4212  }
4213 
4217  int GetMarginTop(bool minusExtra = false) const
4218  {
4219  if (minusExtra)
4220  return m_margin.top - m_extraMargin;
4221  else
4222  return m_margin.top;
4223  }
4224 
4226  void SetMarginRight(int right)
4227  {
4228  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
4229  }
4230 
4234  int GetMarginRight(bool minusExtra = false) const
4235  {
4236  if (minusExtra)
4237  return m_margin.right - m_extraMargin;
4238  else
4239  return m_margin.right;
4240  }
4241 
4244  {
4245  return m_marginOuter.right;
4246  }
4247 
4249  void SetMarginBottom(int bottom)
4250  {
4251  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
4252  }
4253 
4257  int GetMarginBottom(bool minusExtra = false) const
4258  {
4259  if (minusExtra)
4260  return m_margin.bottom - m_extraMargin;
4261  else
4262  return m_margin.bottom;
4263  }
4264 
4266  void SetMarginLeft(int left)
4267  {
4268  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
4269  }
4270 
4274  int GetMarginLeft(bool minusExtra = false) const
4275  {
4276  if (minusExtra)
4277  return m_margin.left - m_extraMargin;
4278  else
4279  return m_margin.left;
4280  }
4281 
4283  void SetExtraMargin(int extra)
4284  {
4285  m_extraMargin = extra;
4286  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4287  }
4288 
4290  int GetExtraMargin() const
4291  {
4292  return m_extraMargin;
4293  }
4294 
4297  {
4298  return m_marginOuter.left;
4299  }
4300 
4302  int GetPlotWidth() const
4303  {
4304  return m_plotWidth;
4305  }
4306 
4308  int GetPlotHeight() const
4309  {
4310  return m_plotHeight;
4311  }
4312 
4317  mpRect GetPlotBoundaries(bool with_margin) const
4318  {
4319  mpRect bond;
4320  if (with_margin)
4321  bond = m_plotBoundariesMargin;
4322  else
4323  bond = m_plotBoundaries;
4324  bond.startPx -= m_extraMargin;
4325  bond.endPx += m_extraMargin;
4326  bond.startPy -= m_extraMargin;
4327  bond.endPy += m_extraMargin;
4328  return bond;
4329  }
4330 
4334  int GetLeftYAxesWidth(mpOptional_int yAxisID = std::nullopt);
4335 
4339  int GetRightYAxesWidth(mpOptional_int yAxisID = std::nullopt);
4340 
4342  void SetDrawBox(bool drawbox)
4343  {
4344  m_drawBox = drawbox;
4345  }
4346 
4348  bool GetDrawBox() const
4349  {
4350  return m_drawBox;
4351  }
4352 
4356  mpOptional_int IsInsideYAxis(const wxPoint &point);
4357 
4361  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
4362 
4366  void SetLayerVisible(const wxString &name, bool viewable);
4367 
4371  bool IsLayerVisible(const wxString &name);
4372 
4376  bool IsLayerVisible(const unsigned int position);
4377 
4381  void SetLayerVisible(const unsigned int position, bool viewable);
4382 
4387  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
4388 
4391  const wxColour& GetAxesColour() const
4392  {
4393  return m_axColour;
4394  }
4395 
4397  const wxColour& GetbgColour() const
4398  {
4399  return m_bgColour;
4400  }
4401 
4403  void SetbgColour(const wxColour &colour)
4404  {
4405  m_bgColour = colour;
4406  }
4407 
4413  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
4414  {
4415  m_OnDeleteLayer = event;
4416  }
4417 
4420  {
4421  m_OnDeleteLayer = NULL;
4422  }
4423 
4428  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
4429  {
4430  m_OnUserMouseAction = userMouseEventHandler;
4431  }
4432 
4435  {
4436  m_OnUserMouseAction = NULL;
4437  }
4438 
4444  bool IsLogXaxis()
4445  {
4446  if (m_AxisDataX.axis)
4447  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
4448  else
4449  return false;
4450  }
4451 
4456  bool IsLogYaxis(int yAxisID)
4457  {
4458  assert(m_AxisDataYList.count(yAxisID) != 0);
4459  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4460  if (yAxis)
4461  return yAxis->IsLogAxis();
4462  else
4463  return false;
4464  }
4465 
4470  void SetLogXaxis(bool log)
4471  {
4472  if (m_AxisDataX.axis)
4473  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
4474  }
4475 
4481  void SetLogYaxis(int yAxisID, bool log)
4482  {
4483  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4484  if (yAxis)
4485  yAxis->SetLogAxis(log);
4486  }
4487 
4492  bool GetMagnetize() const
4493  {
4494  return m_magnet.IsEnabled();
4495  }
4496 
4498  void SetMagnetize(bool mag)
4499  {
4500  m_magnet.Enable(mag);
4501  }
4502 
4508  {
4509  m_mouseLeftDownAction = action;
4510  }
4511 
4517  {
4518  return m_mouseLeftDownAction;
4519  }
4520 
4526  {
4527  return m_mousePos;
4528  }
4529 
4535  {
4536  return m_movingInfoLayer;
4537  }
4538 
4539 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4540 
4544  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
4545 #endif // MP_ENABLE_CONFIG
4546 
4553  void RefreshConfigWindow(mpLayerType layerType, int param = 0, bool show = false);
4554 
4558  void OpenConfigWindow();
4559 
4563  void DeleteConfigWindow(void);
4564 
4569  void Paint(wxDC& dc);
4570 
4575  void RenderOverlays(wxDC& dc);
4576 
4582  wxMemoryDC *GetMemoryDC(void)
4583  {
4584  m_buff_dc.SelectObject(m_buff_bmp);
4585  return &m_buff_dc;
4586  }
4587 
4588  protected:
4589  virtual void BindEvents(void);
4590  virtual void OnPaint(wxPaintEvent &event);
4591  virtual void OnSize(wxSizeEvent &event);
4592  virtual void OnShowPopupMenu(wxMouseEvent &event);
4593  virtual void OnCenter(wxCommandEvent &event);
4594  virtual void OnFit(wxCommandEvent &event);
4595  virtual void OnToggleGrids(wxCommandEvent &event);
4596  virtual void OnToggleCoords(wxCommandEvent &event);
4597  virtual void OnScreenShot(wxCommandEvent &event);
4598  virtual void OnFullScreen(wxCommandEvent &event);
4599 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4600  virtual void OnConfiguration(wxCommandEvent &event);
4601 #endif // MP_ENABLE_CONFIG
4602  virtual void OnLoadFile(wxCommandEvent &event);
4603  virtual void OnZoomIn(wxCommandEvent &event);
4604  virtual void OnZoomOut(wxCommandEvent &event);
4605  virtual void OnLockAspect(wxCommandEvent &event);
4606  virtual void OnMouseHelp(wxCommandEvent &event);
4607  virtual void OnMouseLeftDown(wxMouseEvent &event);
4608  virtual void OnMouseRightDown(wxMouseEvent &event);
4609  virtual void OnMouseMove(wxMouseEvent &event);
4610  virtual void OnMouseLeftRelease(wxMouseEvent &event);
4611  virtual void OnMouseWheel(wxMouseEvent &event);
4612  virtual void OnMouseLeave(wxMouseEvent &event);
4613  bool CheckUserMouseAction(wxMouseEvent &event);
4614  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
4615  virtual void OnScrollPageUp(wxScrollWinEvent &event);
4616  virtual void OnScrollPageDown(wxScrollWinEvent &event);
4617  virtual void OnScrollLineUp(wxScrollWinEvent &event);
4618  virtual void OnScrollLineDown(wxScrollWinEvent &event);
4619  virtual void OnScrollTop(wxScrollWinEvent &event);
4620  virtual void OnScrollBottom(wxScrollWinEvent &event);
4621 
4623  void DoScrollCalc(const int position, const int orientation);
4624 
4629  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = MP_ZOOM_AROUND_CENTER);
4630 
4637  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = MP_ZOOM_AROUND_CENTER, mpOptional_int yAxisID = std::nullopt);
4638 
4643  void SetScaleXAndCenter(double scaleX);
4644 
4650  void SetScaleYAndCenter(double scaleY, int yAxisID);
4651 
4656  void Zoom(bool zoomIn, const wxPoint &centerPoint);
4657 
4660  virtual bool UpdateBBox();
4661 
4665  void DrawBoxZoom(wxDC& dc);
4666 
4670  void InitParameters();
4671 
4672  wxTopLevelWindow* m_parent;
4674 
4675  mpLayerList m_layers;
4677  mpAxisList m_AxisDataYList;
4678 
4679  wxMenu m_popmenu;
4681  wxColour m_bgColour;
4682  wxColour m_fgColour;
4683  wxColour m_axColour;
4684  bool m_drawBox;
4685 
4686  int m_scrX;
4687  int m_scrY;
4690 
4694  wxCoord m_plotWidth;
4695  wxCoord m_plotHeight;
4696 
4699  wxRect m_PlotArea;
4700 
4703  wxBitmap m_buff_bmp;
4704  wxMemoryDC m_buff_dc;
4710  wxPoint m_mousePos;
4711  wxPoint m_mouseRClick;
4712  wxPoint m_mouseLClick;
4713  double m_mouseScaleX;
4714  std::unordered_map<int, double> m_mouseScaleYList;
4717  bool m_autoFit;
4721 
4723 
4725 
4726  wxBitmap* m_Screenshot_bmp;
4727 
4728  wxString m_wildcard;
4729  wxString m_DefaultDir;
4730 
4731 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4732  MathPlotConfigDialog* m_configWindow = NULL;
4733 #endif // MP_ENABLE_CONFIG
4734  bool m_openConfigWindowPending = false;
4736 
4737  mpOnDeleteLayer m_OnDeleteLayer = NULL;
4738  mpOnUserMouseAction m_OnUserMouseAction = NULL;
4739 
4743  virtual void DesiredBoundsHaveChanged() {};
4744 
4745  private:
4747  void CheckAndReportDesiredBoundsChanges();
4748 
4753  unsigned int GetNewAxisDataID(void)
4754  {
4755  int newID = 0;
4756  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
4757  {
4758  if(m_yData.axis)
4759  {
4760  // This ID is used by an axis. Make sure the new ID is larger
4761  newID = std::max(newID, m_yID + 1);
4762  }
4763  }
4764  return newID;
4765  }
4766 
4768 
4769  // To have direct access to m_Screenshot_dc
4770  friend mpPrintout;
4771 };
4772 
4773 //-----------------------------------------------------------------------------
4774 // mpText - provided by Val Greene
4775 //-----------------------------------------------------------------------------
4776 
4785 {
4786  public:
4789  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
4790  {
4791  m_subtype = mptText;
4792  SetName(name);
4793  m_offsetx = 5;
4794  m_offsety = 50;
4795  m_location = mpMarginUser;
4796  m_ZIndex = mpZIndex_TEXT;
4797  }
4798 
4802  mpText(const wxString &name, int offsetx, int offsety);
4803 
4807  mpText(const wxString &name, mpLocation marginLocation);
4808 
4811  virtual bool HasBBox()
4812  {
4813  return false;
4814  }
4815 
4818  void SetLocation(mpLocation location)
4819  {
4820  m_location = location;
4821  }
4822 
4825  mpLocation GetLocation() const
4826  {
4827  return m_location;
4828  }
4829 
4832  void SetOffset(int offX, int offY)
4833  {
4834  m_offsetx = offX;
4835  m_offsety = offY;
4836  }
4837 
4839  void GetOffset(int *offX, int *offY) const
4840  {
4841  *offX = m_offsetx;
4842  *offY = m_offsety;
4843  }
4844 
4845  protected:
4848  mpLocation m_location;
4849 
4852  virtual void DoPlot(wxDC &dc, mpWindow &w);
4853 
4854  private:
4856 };
4857 
4862 {
4863  public:
4866  mpTitle();
4867 
4870  mpTitle(const wxString &name) :
4871  mpText(name, mpMarginTopCenter)
4872  {
4873  m_subtype = mptTitle;
4874  SetPen(*wxWHITE_PEN);
4875  SetBrush(*wxWHITE_BRUSH);
4876  }
4877 
4878  private:
4880 };
4881 
4882 //-----------------------------------------------------------------------------
4883 // mpPrintout - provided by Davide Rondini
4884 //-----------------------------------------------------------------------------
4885 
4890 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4891 {
4892  public:
4893  mpPrintout()
4894  {
4895  plotWindow = NULL;
4896  drawn = false;
4897  stretch_factor = 2;
4898  }
4899 
4905  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4906  virtual ~mpPrintout()
4907  {
4908  ;
4909  }
4910 
4914  void SetDrawState(bool drawState)
4915  {
4916  drawn = drawState;
4917  }
4918 
4920  bool OnPrintPage(int page);
4922  bool HasPage(int page);
4923 
4926  void SetFactor(int factor)
4927  {
4928  stretch_factor = factor;
4929  }
4930 
4931  private:
4932  bool drawn;
4933  mpWindow* plotWindow;
4934  int stretch_factor; // To reduce the size of plot
4935 
4937 };
4938 
4939 //-----------------------------------------------------------------------------
4940 // mpMovableObject - provided by Jose Luis Blanco
4941 //-----------------------------------------------------------------------------
4950 {
4951  public:
4955  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
4956  {
4957  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
4958  m_subtype = mpfMovable;
4959  }
4960 
4961  virtual ~mpMovableObject() {}
4962 
4965  void GetCoordinateBase(double &x, double &y, double &phi) const
4966  {
4967  x = m_reference_x;
4968  y = m_reference_y;
4969  phi = m_reference_phi;
4970  }
4971 
4974  void SetCoordinateBase(double x, double y, double phi = 0)
4975  {
4976  m_reference_x = x;
4977  m_reference_y = y;
4978  m_reference_phi = phi;
4979  m_flags = mpALIGN_SW;
4980  ShapeUpdated();
4981  }
4982 
4983  virtual bool HasBBox()
4984  {
4985  return m_trans_shape_xs.size() != 0;
4986  }
4987 
4990  virtual double GetMinX()
4991  {
4992  return m_bbox_x.min;
4993  }
4994 
4997  virtual double GetMaxX()
4998  {
4999  return m_bbox_x.max;
5000  }
5001 
5004  virtual double GetMinY()
5005  {
5006  return m_bbox_y.min;
5007  }
5008 
5011  virtual double GetMaxY()
5012  {
5013  return m_bbox_y.max;
5014  }
5015 
5016  protected:
5017 
5020  double m_reference_x;
5021  double m_reference_y;
5023 
5024  virtual void DoPlot(wxDC &dc, mpWindow &w);
5025 
5028  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
5029 
5030  // the object points, in local coordinates (to be transformed by the current transformation).
5031  std::vector<double> m_shape_xs;
5032  std::vector<double> m_shape_ys;
5033 
5034  // The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh).
5035  std::vector<double> m_trans_shape_xs;
5036  std::vector<double> m_trans_shape_ys;
5037 
5043 
5047  void ShapeUpdated();
5048 
5049  private:
5051 };
5052 
5053 //-----------------------------------------------------------------------------
5054 // mpCovarianceEllipse - provided by Jose Luis Blanco
5055 //-----------------------------------------------------------------------------
5068 {
5069  public:
5073  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
5074  const wxString &layerName = _T("")) : mpMovableObject(),
5075  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
5076  {
5077  m_continuous = true;
5078  m_name = layerName;
5079  RecalculateShape();
5080  }
5081 
5082  virtual ~mpCovarianceEllipse()
5083  {
5084  ;
5085  }
5086 
5089  double GetQuantiles() const
5090  {
5091  return m_quantiles;
5092  }
5093 
5096  void SetQuantiles(double q)
5097  {
5098  m_quantiles = q;
5099  RecalculateShape();
5100  }
5101 
5103  void SetSegments(int segments)
5104  {
5105  m_segments = segments;
5106  }
5107 
5109  int GetSegments() const
5110  {
5111  return m_segments;
5112  }
5113 
5116  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
5117  {
5118  cov_00 = m_cov_00;
5119  cov_01 = m_cov_01;
5120  cov_11 = m_cov_11;
5121  }
5122 
5125  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
5126  {
5127  m_cov_00 = cov_00;
5128  m_cov_01 = cov_01;
5129  m_cov_11 = cov_11;
5130  RecalculateShape();
5131  }
5132 
5133  protected:
5136  double m_cov_00;
5137  double m_cov_11;
5138  double m_cov_01;
5139  double m_quantiles;
5140 
5144 
5147  void RecalculateShape();
5148 
5149  private:
5151 };
5152 
5153 //-----------------------------------------------------------------------------
5154 // mpPolygon - provided by Jose Luis Blanco
5155 //-----------------------------------------------------------------------------
5161 {
5162  public:
5165  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
5166  {
5167  m_continuous = true;
5168  m_name = layerName;
5169  }
5170 
5171  virtual ~mpPolygon()
5172  {
5173  ;
5174  }
5175 
5181  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
5182 
5183  private:
5185 };
5186 
5187 //-----------------------------------------------------------------------------
5188 // mpBitmapLayer - provided by Jose Luis Blanco
5189 //-----------------------------------------------------------------------------
5195 {
5196  public:
5200  {
5201  m_validImg = false;
5202  m_bitmapChanged = false;
5203  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
5204  }
5205 
5206  virtual ~mpBitmapLayer()
5207  {
5208  ;
5209  }
5210 
5213  void GetBitmapCopy(wxImage &outBmp) const;
5214 
5222  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
5223 
5226  virtual double GetMinX()
5227  {
5228  return m_bitmapX.min;
5229  }
5230 
5233  virtual double GetMaxX()
5234  {
5235  return m_bitmapX.max;
5236  }
5237 
5240  virtual double GetMinY()
5241  {
5242  return m_bitmapY.min;
5243  }
5244 
5247  virtual double GetMaxY()
5248  {
5249  return m_bitmapY.max;
5250  }
5251 
5252  protected:
5253 
5256  wxImage m_bitmap;
5257  wxBitmap m_scaledBitmap;
5260  bool m_validImg;
5262 
5267 
5268  virtual void DoPlot(wxDC &dc, mpWindow &w);
5269 
5270  private:
5272 };
5273 
5274 // utility class
5275 
5277 typedef enum __mp_Colour
5278 {
5279  mpBlue,
5280  mpRed,
5281  mpGreen,
5282  mpPurple,
5283  mpYellow,
5284  mpFuchsia,
5285  mpLime,
5286  mpAqua,
5287  mpOlive
5288 } mpColour;
5289 
5294 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
5295 {
5296  public:
5301  wxIndexColour(unsigned int id)
5302  {
5303 #ifdef _WIN32
5304  auto GetRandomColor = []() {
5305  return (rand() * 255) / RAND_MAX;
5306  };
5307 #else
5308  auto GetRandomColor = []() {
5309  return (random() * 255) / RAND_MAX;
5310  };
5311 #endif
5312  switch (id)
5313  {
5314  case 0:
5315  this->Set(0, 0, 255);
5316  break; // Blue
5317  case 1:
5318  this->Set(255, 0, 0);
5319  break; // Red
5320  case 2:
5321  this->Set(0, 128, 0);
5322  break; // Green
5323  case 3:
5324  this->Set(128, 0, 128);
5325  break; // Purple
5326  case 4:
5327  this->Set(255, 255, 0);
5328  break; // Yellow
5329  case 5:
5330  this->Set(255, 0, 255);
5331  break; // Fuchsia
5332  case 6:
5333  this->Set(0, 255, 0);
5334  break; // Lime
5335  case 7:
5336  this->Set(0, 255, 255);
5337  break; // Aqua/Cyan
5338  case 8:
5339  this->Set(128, 128, 0);
5340  break; // Olive
5341  default:
5342  this->Set((ChannelType) (GetRandomColor()), (ChannelType) (GetRandomColor()), (ChannelType) (GetRandomColor()));
5343  }
5344  }
5345 };
5346 
5349 // ---------------------------------------------------------------------
5350 #if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
5351  }// namespace MathPlot
5352 #endif // MP_ENABLE_NAMESPACE
5353 
5354 #endif // MATHPLOT_H_INCLUDED
T Length(void) const
Length of the range.
Definition: mathplot.h:394
sub type for mpFXYVector function
Definition: mathplot.h:724
mpRange< double > lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:3277
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:4846
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5240
bool GetLegendIsAlwaysVisible() const
Get the visibility of the legend.
Definition: mathplot.h:1788
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer.
Definition: mathplot.h:3312
void SetLabelMode(mpLabelType mode, unsigned int time_conv=MP_X_RAWTIME)
Set X axis label view mode.
Definition: mathplot.h:1396
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:626
sub type for mpText layer
Definition: mathplot.h:713
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:4104
Align the plot label towards the southeast.
Definition: mathplot.h:665
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:852
Draw a circle.
Definition: mathplot.h:688
enum __YAxis_Align_Type mpYAxis_Align
Alignment for Y axis.
void ShowDraggedSeries(bool active)
Set if dragged series shall be shown or hidden.
Definition: mathplot.h:1513
Show legend items with small square with the same color of referred mpLayer.
Definition: mathplot.h:673
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:226
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:3428
mpRange< double > GetBoundY(int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3644
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:4714
wxMemoryDC m_buff_dc
DC for double buffering.
Definition: mathplot.h:4704
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:4413
void SetLegendIsAlwaysVisible(bool alwaysVisible)
Set the visibility of the name of the function in the legend despite the visibility of the function i...
Definition: mathplot.h:1780
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:4249
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2795
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3752
mpNormal(double mu, double sigma)
Classic Normal distribution.
Definition: mathplot.h:2523
bool GetMagnetize() const
Is mouse magnetization enabled? Useful to read the position on the axes.
Definition: mathplot.h:4492
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1404
enum __mp_Colour mpColour
Enumeration of classic colour.
Bitmap type layer.
Definition: mathplot.h:803
bool IsDraggedSeriesShown() const
Get shown status of dragged series.
Definition: mathplot.h:1520
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:4818
void SetHovering(bool hover)
Set if axis shall be highlighted when a series is dragged over it.
Definition: mathplot.h:2981
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1174
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:4699
__Scale_Type
sub_type values for mpLAYER_AXIS
Definition: mathplot.h:731
T GetMaxAbs(void) const
Max absolute value of the range.
Definition: mathplot.h:406
Plot type layer.
Definition: mathplot.h:788
void SetMinScale(double min)
Set the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2914
abstract Layer for chart (bar and pie).
Definition: mathplot.h:2558
mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:3994
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1173
bool m_enableScrollBars
Enable scrollbar in plot window (default false)
Definition: mathplot.h:4716
double m_lastX
Last x-coordinate point added.
Definition: mathplot.h:2288
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1163
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:2225
User defined position. Can be change by mouse drag.
Definition: mathplot.h:636
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1170
wxBitmap m_scaledBitmap
Cached scaled bitmap used for drawing.
Definition: mathplot.h:5257
std::map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:3289
virtual double ComputeY(double x)
The main computation of the FX function.
Definition: mathplot.h:2538
mpMouseButtonAction GetMouseLeftDownAction()
Returns the type of action for the left mouse button.
Definition: mathplot.h:4516
#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:1437
__Symbol_Type
Displaying a symbol instead of a point in the plot function.
Definition: mathplot.h:685
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:672
void SetScale(mpRange< double > range)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2965
__mp_Layer_Type
Major type of an mpLayer (detail is in subtype)
Definition: mathplot.h:784
std::unordered_map< int, mpRange< double > > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:3677
Show/Hide grids.
Definition: mathplot.h:614
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:982
bool m_autoStep
Calculates m_step automatically based on how many points you want to draw.
Definition: mathplot.h:1830
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:4266
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5004
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:3031
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1165
mpLabelType
enum for label for grid
Definition: mathplot.h:756
std::vector< std::string > labels
Labels of the Values.
Definition: mathplot.h:2596
mpLegendStyle GetItemMode() const
Get the current legend item drawing mode.
Definition: mathplot.h:1486
const wxRect & GetRectangle() const
Get the current rectangle coordinates.
Definition: mathplot.h:1293
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1425
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:4688
mpRange< double > GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:3630
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:3710
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:5125
double m_const
Const factor.
Definition: mathplot.h:2536
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:786
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:819
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:3022
sub type not defined (should be never used)
Definition: mathplot.h:733
double m_lastY
Last y-coordinate point added.
Definition: mathplot.h:2290
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:3131
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:3593
bool m_CoordIsAlwaysVisible
If true, the mouse coordinates is visible in the info coordinates despite the visibility of the axis...
Definition: mathplot.h:3033
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:363
bool ShouldBeShown(wxRect plotArea, wxPoint mousePos)
Check conditions if info coords shall be shown or not.
Definition: mathplot.h:1388
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:4296
mpRange< double > GetScale() const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2973
Lock x/y scaling aspect.
Definition: mathplot.h:613
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:4691
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2535
void SetNeedUpdate()
Mark the legend bitmap as needing regeneration.
Definition: mathplot.h:1506
void ToLog(void)
Convert to log range.
Definition: mathplot.h:412
int m_reserveXY
Memory reserved for m_xs and m_ys. Default 1000.
Definition: mathplot.h:2284
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:1022
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:634
std::vector< double > m_trans_shape_ys
Transformed shape vertices in Y coordinates.
Definition: mathplot.h:5036
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:4428
wxBitmap m_buff_bmp
Bmp for double buffering.
Definition: mathplot.h:4703
Info box type layer.
Definition: mathplot.h:808
bool m_boxZoomActive
Indicate if box zoom is active.
Definition: mathplot.h:4722
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:5194
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:998
void SetFactor(int factor)
Definition: mathplot.h:4926
virtual void SetLogAxis(bool log)
Set Logarithmic mode.
Definition: mathplot.h:2997
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1738
wxString m_DefaultDir
The default directory for wxFileDialog.
Definition: mathplot.h:4729
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1960
wxPoint GetMousePosition()
Returns current mouse position in window.
Definition: mathplot.h:4525
#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:433
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1932
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:2819
mpRange< double > m_bbox_y
Range of bounding box on y direction.
Definition: mathplot.h:5042
enum __Info_Type mpInfoType
sub_type values for mpLAYER_INFO
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:4707
void Show(bool show)
Set if magnet shall be shown or hidden.
Definition: mathplot.h:3367
const wxColour & GetbgColour() const
Get the plot background colour.
Definition: mathplot.h:4397
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:5143
Chart type layer (bar chart)
Definition: mathplot.h:793
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:4308
void SetAxisID(unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2812
bool PointIsInsideBound(double px, double py, int yAxisID)
Is the given point inside the current bounding box for the selected Y axis?
Definition: mathplot.h:4061
sub type for mpLine function
Definition: mathplot.h:726
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1745
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1190
void SetDefaultDir(const wxString &dirname)
Set the default directory for wxFileDialog.
Definition: mathplot.h:4155
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2589
Draw a cross X.
Definition: mathplot.h:692
double m_max_value
Max value of the values vector.
Definition: mathplot.h:2598
Draw a triangle up oriented.
Definition: mathplot.h:690
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1763
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2376
mpRange< double > GetDesiredBoundY(int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3653
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:4243
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:3806
wxSize GetSize() const
Get the size of the box (in pixels)
Definition: mathplot.h:1286
wxPoint m_mousePos
Current mouse position in window.
Definition: mathplot.h:4710
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3858
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:4693
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see GetQuantiles a...
Definition: mathplot.h:5096
bool IsInside(wxCoord xPixel)
Return true if the given X pixel lies within this Y-axis drawing area.
Definition: mathplot.h:3219
int GetMarginTop(bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:4217
Mouse action drag the plot.
Definition: mathplot.h:752
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:1118
virtual double GetMinY() override
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:2329
void SetFont(const wxFont &font)
Set layer font.
Definition: mathplot.h:990
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1826
double GetValue() const
Get the x or y coordinates of the line.
Definition: mathplot.h:1859
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:4683
~mpPieChart()
Destructor.
Definition: mathplot.h:2690
double m_relY
Box Y position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1317
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:4675
void Show(bool show)
Set if info coords shall be shown or hidden.
Definition: mathplot.h:1372
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:1246
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:5020
mpRange()
Default constructor.
Definition: mathplot.h:275
double m_sigma
Sigma value.
Definition: mathplot.h:2534
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:3690
void EnableSeriesValues(bool enable)
Enables to show series values in the legend.
Definition: mathplot.h:1527
bool IsLogXaxis()
Is this an X axis to be displayed with log scale? It is really an axis property but as we need to con...
Definition: mathplot.h:4444
sub type not defined (should be never used)
Definition: mathplot.h:742
int m_flags
Holds label alignment. Default : mpALIGN_SW for series and mpALIGN_CENTER for scale.
Definition: mathplot.h:1171
std::vector< wxColour > colours
Per-slice colours used when drawing the chart.
Definition: mathplot.h:2753
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:4582
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:2162
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1318
wxRect GetRect(void)
Create standard wxWidgets rectangle defined by this object&#39;s start and end points.
Definition: mathplot.h:256
sub type not defined (should be never used)
Definition: mathplot.h:720
void SetLabelFormat(const wxString &format, bool updateLabelMode=false)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2849
double GetDesiredYmax(int yAxisID)
Return the top layer-border coordinate that the user wants the mpWindow to show (it may be not exactl...
Definition: mathplot.h:4036
sub type not defined (should be never used)
Definition: mathplot.h:712
mpRange< double > m_bitmapX
The shape of the bitmap:
Definition: mathplot.h:5265
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:4825
Just the end of ZOrder.
Definition: mathplot.h:810
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:801
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:2833
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:2213
mpRange< double > x
range over x direction
Definition: mathplot.h:563
Layer for pie chart.
Definition: mathplot.h:2681
std::vector< double > m_xs
internal copy of the set of data on x direction
Definition: mathplot.h:2281
void SetDefaultLegendIsAlwaysVisible(bool visible)
Set if legend is always visible even if series is not plotted.
Definition: mathplot.h:4174
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:1014
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:2275
void Update(T value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:351
bool IsShown()
Get shown status.
Definition: mathplot.h:3373
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:4677
Draw a plus +.
Definition: mathplot.h:693
virtual double GetY(double x)
Get function value for argument.
Definition: mathplot.h:2428
void Set(T _min, T _max)
Set min, max function.
Definition: mathplot.h:304
mpCovarianceEllipse(double cov_00=1, double cov_11=1, double cov_01=0, double quantiles=2, int segments=32, const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5073
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2858
void UpdateBoundingBoxToInclude(double px, double py)
Update bounding box (X and Y axis) to include this point.
Definition: mathplot.h:587
Keep the object, just remove the layer from the layer list.
Definition: mathplot.h:821
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:3123
bool IsLeftAxis()
Return true if this Y axis is aligned to the left side.
Definition: mathplot.h:3207
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
T GetCenter(void) const
Center of the range.
Definition: mathplot.h:400
std::vector< double > m_ys
internal copy of the set of data on y direction
Definition: mathplot.h:2282
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:880
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2840
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:2285
Delete the object regardless of the CanDelete value and remove it from the layer list.
Definition: mathplot.h:823
void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
Ensure the bounding box includes the given point for the selected Y axis.
Definition: mathplot.h:4074
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:3320
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:4290
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:4708
Align the plot label towards the southwest.
Definition: mathplot.h:666
Align the y-axis towards left border.
Definition: mathplot.h:653
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:4209
virtual double GetMaxY()
Get max Y of the function.
Definition: mathplot.h:2456
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:1056
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:3701
void EnableBufferedPaintDC(const bool enabled)
Enable/disable the auto buffering of PaintDC.
Definition: mathplot.h:3851
Align the x-axis towards bottom border.
Definition: mathplot.h:643
wxCoord y2p(const double y, int yAxisID=0)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:3833
void SetLabelMode(mpLabelType mode, unsigned int time_conv=MP_X_RAWTIME)
Set axis label view mode.
Definition: mathplot.h:2866
Plot (function) type layer.
Definition: mathplot.h:806
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:4724
bool ViewAsBar(void) const
Get if we are in bar mode.
Definition: mathplot.h:2153
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1172
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:1006
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1132
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1731
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:3028
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:4302
Create a generic FX function Override the ComputeY() function with your function. ...
Definition: mathplot.h:2407
size_t m_maxNOfPoints
Maximum number of points to draw to screen.
Definition: mathplot.h:1831
double m_deltaY
Min delta between 2 consecutive coordinate on y direction.
Definition: mathplot.h:2166
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2826
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:5247
Axis type layer.
Definition: mathplot.h:804
double GetScaleY(int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:3618
double GetMaxScale() const
Get the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2938
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:5160
Draw a triangle down oriented.
Definition: mathplot.h:691
~mpChart()
Destructor.
Definition: mathplot.h:2565
Axis type layer.
Definition: mathplot.h:787
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:3825
double GetQuantiles() const
Get the confidence-interval multiplier used for the ellipse.
Definition: mathplot.h:5089
double m_const
Const factor.
Definition: mathplot.h:2500
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:1355
bool IsRightAxis()
Return true if this Y axis is aligned to the right side.
Definition: mathplot.h:3213
bool GetCanDelete(void) const
Retreive what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1146
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:2087
#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:1169
bool IsSet()
Check if this mpRange has been assigned any values.
Definition: mathplot.h:342
Align the info in margin center-right.
Definition: mathplot.h:632
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1159
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:4182
int GetBarWidth(void) const
Get the width of the bar when we plot in bar mode.
Definition: mathplot.h:2144
wxColour m_barColour
Fill colour used for the bars.
Definition: mathplot.h:2664
double GetMinScale() const
Get the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2922
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:4697
bool IsHorizontal(void) const
Is it a horizontal line?
Definition: mathplot.h:1875
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:3259
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:1111
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:4694
int GetSegments() const
Get the number of line segments used to approximate the ellipse. */.
Definition: mathplot.h:5109
virtual size_t GetSize()
Return the number of points in the series.
Definition: mathplot.h:2113
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:5116
mpRange< double > desired
Desired range min and max.
Definition: mathplot.h:3276
wxCoord m_scaledBitmap_offset_x
Cached X pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5258
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:4342
void Check(void)
Check to always have a range. If min = max then introduce the 0 to make a range.
Definition: mathplot.h:382
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:4162
bool IsEnabled() const
Check if magnet is enabled.
Definition: mathplot.h:3352
bool m_LegendIsAlwaysVisible
If true, the name is visible in the legend despite the visibility of the function. Default false.
Definition: mathplot.h:1829
bool IsShown()
Get shown status.
Definition: mathplot.h:1379
each visible plot is described on its own line, one above the other
Definition: mathplot.h:680
double m_cov_01
Covariance matrix element (0,1), equal to element (1,0).
Definition: mathplot.h:5138
void SetbgColour(const wxColour &colour)
Set the plot background colour.
Definition: mathplot.h:4403
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1339
bool m_fullscreen
Boolean value indicating that we are in fullscreen mode (default false)
Definition: mathplot.h:4673
mpRange(T value1, T value2)
Create range with the 2 values.
Definition: mathplot.h:282
Align the x-axis towards top plot.
Definition: mathplot.h:646
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:4712
virtual double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:2314
double m_mu
Mean value.
Definition: mathplot.h:2497
mpFloatRectSimple(mpRange< double > _x, mpRange< double > _y)
Construct a simple rectangular box.
Definition: mathplot.h:571
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:2720
void SetYAxisID(unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1772
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:759
virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
Set the layer&#39;s subtype in caller variable, and return true if the layer is of type "typeOfInterest"...
Definition: mathplot.h:890
Align the y-axis towards right border.
Definition: mathplot.h:657
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:701
mpLegendStyle m_item_mode
Visual style used for each legend entry.
Definition: mathplot.h:1597
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2898
void InitializeBoundingBox(double px, double py, int yAxisID)
Initialize the bounding box from a first point for the selected Y axis.
Definition: mathplot.h:4089
bool IsTopAxis()
Return true when this X axis is aligned at the top edge or top border.
Definition: mathplot.h:3138
void ShowSeriesValues(bool show)
Set if the series values shall be drawn to the plot.
Definition: mathplot.h:1550
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:907
mpLegendDirection GetItemDirection() const
Get the current legend item layout direction.
Definition: mathplot.h:1500
void InitializeBoundingBox(double px, double py)
Initialize bounding box with an initial point.
Definition: mathplot.h:597
int GetMarginBottom(bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:4257
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:4965
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:5199
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:4226
Show/Hide info coord.
Definition: mathplot.h:615
Align the x-axis towards top border.
Definition: mathplot.h:647
bool m_IsHorizontal
Is the line horizontal? Default false.
Definition: mathplot.h:1882
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5165
Mouse action draw a box to zoom inside.
Definition: mathplot.h:751
__Function_Type
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
Definition: mathplot.h:718
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition: mathplot.h:90
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1904
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:4949
Align the y-axis towards left plot.
Definition: mathplot.h:654
bool IsLogYaxis(int yAxisID)
Get the log property (true or false) Y layer (Y axis) with a specific Y ID or false if not found...
Definition: mathplot.h:4456
Chart type layer.
Definition: mathplot.h:807
Set label for axis in scientific notation.
Definition: mathplot.h:763
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4990
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2882
enum __mp_Location_Type mpLocation
Location for the Info layer.
std::optional< int > mpOptional_int
Shortcut to optional integer type..
Definition: mathplot.h:108
int m_labelPos
Bar-label placement mode.
Definition: mathplot.h:2665
Copy a screen shot to the clipboard.
Definition: mathplot.h:616
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:3326
Fit view to match bounding box of all layers.
Definition: mathplot.h:609
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:622
Center view on click position.
Definition: mathplot.h:612
virtual 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:2245
Plot layer implementing a simple title.
Definition: mathplot.h:4861
double m_total_value
Total of the values vector.
Definition: mathplot.h:2599
mpFXGeneric(const wxString &name=wxT("Generic FX function"), int flags=mpALIGN_LEFT, unsigned int yAxisID=0)
Definition: mathplot.h:2414
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:641
double pos
Position.
Definition: mathplot.h:3274
mpLabelType m_labelType
Label formatting mode used for the X coordinate display.
Definition: mathplot.h:1438
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:5011
sub type for all layers who are function.
Definition: mathplot.h:727
Draw a square.
Definition: mathplot.h:689
wxIndexColour(unsigned int id)
Constructor.
Definition: mathplot.h:5301
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:1070
void SetCanDelete(bool canDelete)
Set what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1139
Align the x-axis center plot.
Definition: mathplot.h:645
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:710
mpInfoLayer * GetMovingInfoLayer()
Returns moving info layer.
Definition: mathplot.h:4534
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:4711
double GetDesiredXmax() const
Return the right-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:4015
double m_labelAngle
Rotation angle used for bar labels, in degrees.
Definition: mathplot.h:2666
__mp_Colour
Enumeration of classic colour.
Definition: mathplot.h:5277
double m_width
Width of each bar/column in plot units.
Definition: mathplot.h:2663
mpRange< double > GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:3636
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1219
Align the plot label towards the northwest.
Definition: mathplot.h:663
int m_infoLegendSelectedSeries
Only used with config window: the selected series in info legend.
Definition: mathplot.h:4735
double GetPosY(int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3725
bool m_show
Indicates if magnet shall be shown in plot.
Definition: mathplot.h:1436
void SetMaxScale(double max)
Set the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2930
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4997
mpRange< int > m_drawX
Range min and max on x axis.
Definition: mathplot.h:2161
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:2956
void SetMin(T _min)
Set min function, correct max.
Definition: mathplot.h:311
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:4680
bool IsSeriesValuesShown()
Indicates if series values shall be shown.
Definition: mathplot.h:1557
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:3178
bool IsVisible() const
Is this layer visible?
Definition: mathplot.h:1097
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:561
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:4348
No symbol is drawing.
Definition: mathplot.h:687
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:923
double m_reference_y
Current object Y position in plot coordinates.
Definition: mathplot.h:5021
Layer for bar chart.
Definition: mathplot.h:2617
__Chart_Type
sub_type values for mpLAYER_CHART
Definition: mathplot.h:740
void SetAutoFit(bool autoFit)
Set if plot shall be auto fitted when hiding or showing axis and series via mouse.
Definition: mathplot.h:4189
static bool m_DefaultLegendIsAlwaysVisible
This value sets the default behaviour when a series is not visible for the legend display...
Definition: mathplot.h:4167
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:674
sub type for all layers who are chart.
Definition: mathplot.h:745
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4890
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:3025
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:4832
Align the info in margin center-left.
Definition: mathplot.h:628
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:761
double m_mu
Mean value.
Definition: mathplot.h:2533
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:661
mpRange< double > y
range over y direction
Definition: mathplot.h:564
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:4698
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:4391
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1682
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:1125
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:269
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:4718
sub type for mpInfoLegend layer
Definition: mathplot.h:706
void UpdateDesiredBoundingBox(mpAxisUpdate update)
Update m_desired bounds.
Definition: mathplot.h:3969
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1307
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2890
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:1104
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1162
wxPen m_penSeries
Pen used to draw the series marker when series-coordinate mode is active.
Definition: mathplot.h:1443
wxPoint m_center
Center of the pie chart in device coordinates.
Definition: mathplot.h:2752
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3787
mpOptional_int m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:4715
#define MP_EPSILON
An epsilon for float comparison to 0.
Definition: mathplot.h:174
bool ShouldBeShown(wxPoint mousePos)
Check conditions if magnet shall be shown.
Definition: mathplot.h:3361
bool PointIsInside(double px, double py) const
Is point inside this bounding box?
Definition: mathplot.h:578
double m_radius
Radius of the pie chart in pixels.
Definition: mathplot.h:2751
bool m_mouseMovedAfterRightClick
If the mouse does not move after a right click, then the context menu is displayed.
Definition: mathplot.h:4709
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:4682
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3874
int m_last_ly
Last logical Y origin, used for double buffering.
Definition: mathplot.h:4702
std::unordered_map< int, mpRange< double > > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:3663
Text box type layer.
Definition: mathplot.h:790
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:5233
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:651
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:1063
sub type for mpBarChart
Definition: mathplot.h:743
Abstract class providing a line.
Definition: mathplot.h:1839
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:1037
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:3579
Load a file.
Definition: mathplot.h:620
enum __Symbol_Type mpSymbol
Displaying a symbol instead of a point in the plot function.
void SetMaxNOfPoints(size_t nOfPoints)
Set how many points that is allowed to be drawn at a time.
Definition: mathplot.h:1811
bool GetAutoStep() const
Get if auto stop is enabled.
Definition: mathplot.h:1803
mpRange< double > m_axisRange
Range axis values when autosize is false.
Definition: mathplot.h:3027
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1851
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:3948
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1724
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:974
Line (horizontal or vertical) type layer.
Definition: mathplot.h:805
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3734
Dialog box for configuring the plot&#39;s layer objects In this dialog, you can configure: ...
Definition: MathPlotConfig.h:155
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:1077
T max
The max value of the range.
Definition: mathplot.h:272
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1313
Delete the object if CanDelete is true and remove it from the layer list.
Definition: mathplot.h:822
void SetBrush(const wxColour &colour, enum wxBrushStyle style=wxBRUSHSTYLE_SOLID)
Set layer brush.
Definition: mathplot.h:1048
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:4203
double scale
Scale.
Definition: mathplot.h:3273
sub type for mpTitle layer
Definition: mathplot.h:714
mpRange< double > m_bbox_x
The precomputed bounding box:
Definition: mathplot.h:5041
int GetMarginLeft(bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:4274
Align the info in margin center-top.
Definition: mathplot.h:630
void SetExtraMargin(int extra)
Set the extra margin.
Definition: mathplot.h:4283
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:770
bool m_autoFit
Automatically fit plot when hiding / showing axis and series.
Definition: mathplot.h:4717
wxPoint GetPosition() const
Get the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1271
bool m_series_coord
True to show the nearest plotted series value instead of raw mouse Y coordinates. ...
Definition: mathplot.h:1442
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1168
void SetWildcard(const wxString &wildcard)
Set wildcard for LoadFile() function when we use wxFileDialog.
Definition: mathplot.h:4129
mpScaleY(const wxString &name=_T("Y"), int flags=mpALIGN_CENTERY, bool grids=false, mpOptional_uint yAxisID=std::nullopt, mpLabelType labelType=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:3188
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1315
Set no label for axis (useful for bar)
Definition: mathplot.h:776
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:749
int GetAxisID(void)
Return the ID of the Axis.
Definition: mathplot.h:2803
sub type for mpPieChart
Definition: mathplot.h:744
bool m_validImg
True when the source image is valid and ready to draw.
Definition: mathplot.h:5260
double GetDesiredXmin() const
Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:4006
void Assign(T value1, T value2)
Assign values to min and max.
Definition: mathplot.h:327
Align the plot label towards the northeast.
Definition: mathplot.h:664
double m_deltaX
Min delta between 2 consecutive coordinate on x direction.
Definition: mathplot.h:2165
only for mpInfoCoords
Definition: mathplot.h:637
double m_value
The x or y coordinates of the line.
Definition: mathplot.h:1881
bool m_enableBufferedPaintDC
For auto DC double buffering.
Definition: mathplot.h:4706
HitCode
Return codes for GetLegendHitRegion() if no series was hit.
Definition: mathplot.h:1587
Abstract class providing an vertical line.
Definition: mathplot.h:1919
bool m_showDraggedSeries
Indicate if series that has been gripped with mouse shall be drawn.
Definition: mathplot.h:1599
sub type for mpFXY function
Definition: mathplot.h:723
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:899
void SetLogXaxis(bool log)
Enable or disable logarithmic scaling on the X axis.
Definition: mathplot.h:4470
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:3281
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:3776
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:2728
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:4983
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1368
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:915
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:5256
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:4726
Zoom into view at clickposition / window center.
Definition: mathplot.h:610
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:4695
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:4676
std::vector< double > values
Values of the chart.
Definition: mathplot.h:2595
Align the info in margin top-left.
Definition: mathplot.h:629
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:4317
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1167
double m_quantiles
Confidence-interval multiplier used when drawing the ellipse.
Definition: mathplot.h:5139
Zoom out.
Definition: mathplot.h:611
enum __mp_Layer_Type mpLayerType
Major type of an mpLayer (detail is in subtype)
wxCoord m_mouseY
Last mouse Y position in window pixel coordinates.
Definition: mathplot.h:1441
void SetCoordIsAlwaysVisible(bool alwaysVisible)
Set the visibility of the mouse coordinates in the info coordinates despite the visibility of the axi...
Definition: mathplot.h:3005
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1717
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:4811
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2499
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1824
double m_relX
Box X position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1316
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:678
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:5067
sub type for mpInfoLayer layer
Definition: mathplot.h:704
int GetMarginRight(bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:4234
void SetDrawState(bool drawState)
Set whether the plot has already been drawn on the current printout.
Definition: mathplot.h:4914
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:4434
Align the x-axis towards bottom plot.
Definition: mathplot.h:644
wxCoord m_scaledBitmap_offset_y
Cached Y pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5259
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1164
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:768
wxPen m_gridpen
Grid&#39;s pen. Default Colour = LIGHT_GREY, width = 1, style = wxPENSTYLE_DOT.
Definition: mathplot.h:3023
void SetItemMode(mpLegendStyle mode)
Set item mode (the element on the left of text representing the plot line may be line, square, or line with symbol).
Definition: mathplot.h:1479
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:670
bool IsSeriesValuesEnabled() const
Check if series values is enabled in legend.
Definition: mathplot.h:1535
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:4974
bool GetCoordIsAlwaysVisible() const
Get the visibility of the mouse coordinates in the info coordinates.
Definition: mathplot.h:3013
Align the y-axis towards right plot.
Definition: mathplot.h:656
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1314
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:3029
wxTopLevelWindow * m_parent
Pointer to the top-level window containing the plot (used for fullscreen)
Definition: mathplot.h:4672
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:4954
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2707
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:4713
sub type for mpScaleX
Definition: mathplot.h:734
sub type for mpInfoCoords layer
Definition: mathplot.h:705
bool GetBoundingBox(mpRange< double > *boundX, mpRange< double > *boundY, int yAxisID)
Return the bounding box coordinates for the Y axis of ID yAxisID.
Definition: mathplot.h:4047
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:445
void SetScaleY(const double scaleY, int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:3602
Set label user defined.
Definition: mathplot.h:774
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1475
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:3024
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2736
std::vector< double > m_shape_ys
Shape vertices in object-local Y coordinates.
Definition: mathplot.h:5032
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1703
std::vector< double > m_trans_shape_xs
Transformed shape vertices in X coordinates.
Definition: mathplot.h:5035
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1153
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:864
virtual double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:2336
int m_xPos
Leftmost X pixel occupied by this axis (starting point).
Definition: mathplot.h:3230
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:4689
double p2y(const wxCoord pixelCoordY, int yAxisID=0)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:3814
Plot layer implementing a text string.
Definition: mathplot.h:4784
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:766
sub type not defined (should be never used)
Definition: mathplot.h:703
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:772
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:4789
void SetLogYaxis(int yAxisID, bool log)
Set the log property (true or false) for a Y layer (Y axis) given by is ID.
Definition: mathplot.h:4481
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:3405
Bitmap type layer.
Definition: mathplot.h:791
wxCoord m_mouseX
Last mouse X position in window pixel coordinates.
Definition: mathplot.h:1440
bool m_bitmapChanged
True when the cached scaled bitmap must be regenerated.
Definition: mathplot.h:5261
void SetScale(double min, double max)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2947
void SetMax(T _max)
Set max function, correct min.
Definition: mathplot.h:319
~mpBarChart()
Destructor.
Definition: mathplot.h:2624
Classic Normal distribution f(x) = exp(-(ln(x)-μ)²/2σ²)/(xσ.sqrt(2π))
Definition: mathplot.h:2515
int GetAxisWidth()
Get the reserved width of the Y axis in pixels.
Definition: mathplot.h:3201
void Set(T _value)
Initialize min and max.
Definition: mathplot.h:297
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1828
int m_last_lx
Last logical X origin, used for double buffering.
Definition: mathplot.h:4701
Align the info in margin bottom-left.
Definition: mathplot.h:633
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:722
Info box type layer.
Definition: mathplot.h:789
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1493
Align the y-axis center plot.
Definition: mathplot.h:655
mpRange< double > m_rangeX
Range min and max on x axis.
Definition: mathplot.h:2287
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1300
double m_cov_11
Covariance matrix element (1,1).
Definition: mathplot.h:5137
mpGaussian(double mu, double sigma)
Classic Gaussian distribution.
Definition: mathplot.h:2487
virtual bool DoBeforePlot()
This is the only case where we don&#39;t need and Y axis So no need to test m_yAxisID.
Definition: mathplot.h:1945
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:4839
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2699
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1827
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1166
bool m_cacheDirty
Indicate that the cached buffer m_buff_bmp need to be re-created.
Definition: mathplot.h:4705
Shows information about the mouse commands.
Definition: mathplot.h:621
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:4687
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3742
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:1084
virtual double ComputeY(double x)
The main computation of the FX function.
Definition: mathplot.h:2502
void SetMagnetize(bool mag)
Enable or disable mouse-position magnet lines (cross-hairs) in the plot area.
Definition: mathplot.h:4498
legend components follow each other horizontally on a single line
Definition: mathplot.h:681
void SetMouseLeftDownAction(mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:4507
Align the info in margin top-right.
Definition: mathplot.h:631
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:3154
wxString m_wildcard
For loadfile() function when we use wxFileDialog.
Definition: mathplot.h:4728
mpTitle(const wxString &name)
Definition: mathplot.h:4870
int m_axisWidth
Reserved width for this Y axis including labels, in pixels.
Definition: mathplot.h:3229
enum __Text_Type mpTextType
sub_type values for mpLAYER_TEXT
double m_reference_phi
Current object rotation angle in radians.
Definition: mathplot.h:5022
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:4679
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:2744
sub type for all layers who are scale.
Definition: mathplot.h:736
unsigned int m_timeConv
Time conversion mode used when formatting date/time X values.
Definition: mathplot.h:1439
Abstract class providing an horizontal line.
Definition: mathplot.h:1890
mpInfoCoords * m_InfoCoords
Pointer to the optional info coords layer.
Definition: mathplot.h:4719
mpInfoLegend * m_InfoLegend
Pointer to the optional info legend layer.
Definition: mathplot.h:4720
bool SeriesValuesShouldBeShown(wxRect plotArea, wxPoint mousePos)
Check if series values should be shown in plot, depending on where mouse is.
Definition: mathplot.h:1543
mpLocation m_location
The location of the text.
Definition: mathplot.h:4848
Implement the legend to be added to the plot This layer allows you to add a legend to describe the pl...
Definition: mathplot.h:1461
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:3270
double m_sigma
Sigma value.
Definition: mathplot.h:2498
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:1411
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:4681
Align the info in margin bottom-right.
Definition: mathplot.h:635
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2780
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1254
bool PointIsInside(T point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:419
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1161
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1710
Classic Gaussian distribution f(x) = exp(-(x-μ)²/2σ²)/sqrt(2πσ²)
Definition: mathplot.h:2479
void Enable(bool enable)
Enables the magnet.
Definition: mathplot.h:3346
Plot layer, abstract base class.
Definition: mathplot.h:836
void SetColumnWidth(const double colWidth)
Set the bar width in plot units.
Definition: mathplot.h:2633
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:3797
void SetAutoStep(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:1796
sub type for mpMovableObject function
Definition: mathplot.h:725
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:5136
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1695
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:1030
mpRange< double > m_rangeY
Y range.
Definition: mathplot.h:2462
void EnableDoubleBuffer(const bool enabled)
Deprecated: Enable/disable the double-buffering of the window, eliminating the flicker (default=enabl...
Definition: mathplot.h:3843
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:4686
void UpdateBox(const wxRect &plotArea)
Update the drawable magnet area from a wxRect.
Definition: mathplot.h:3340
#define MP_ISNOTNULL(x)
Nullity test. Old solution is to test according small epsilon: (fabs(x) > MP_EPSILON) ...
Definition: mathplot.h:176
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:4743
mpRange< double > m_rangeY
Range min and max on y axis.
Definition: mathplot.h:2289
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:3030
sub type for mpFX function
Definition: mathplot.h:721
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2874
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:2105
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:3026
T min
The min value of the range.
Definition: mathplot.h:271
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:4684
virtual double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:2351
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2022
void SetInitialPosition(wxPoint pos)
Set the position in percent of the upper left corner of the box.
Definition: mathplot.h:1278
void SetSegments(int segments)
Set the number of line segments used to approximate the ellipse.
Definition: mathplot.h:5103
double GetDesiredYmin(int yAxisID)
Return the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:4025
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:4692
std::vector< double > m_shape_xs
Shape vertices in object-local X coordinates.
Definition: mathplot.h:5031
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:5294
virtual bool IsLogAxis()
Get if we are in Logarithmic mode.
Definition: mathplot.h:2989
mpLegendDirection m_item_direction
Layout direction used when arranging legend entries.
Definition: mathplot.h:1598
mpRange< double > bound
Range min and max.
Definition: mathplot.h:3275
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1160
#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:2283
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:872
virtual double GetMinY()
Get min Y of the function.
Definition: mathplot.h:2447
sub type for mpScaleY
Definition: mathplot.h:735
int m_BarWidth
Bar width in pixels when the XY series is drawn in bar mode.
Definition: mathplot.h:2168
mpRange< double > m_bitmapY
Range of the bitmap on y direction.
Definition: mathplot.h:5266
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:4847
size_t GetMaxNOfPoints() const
Get maximum number of points to plot.
Definition: mathplot.h:1818
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1825
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:3297
Text box type layer.
Definition: mathplot.h:809
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:4419
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:5226
void SetValue(const double value)
Set x or y value.
Definition: mathplot.h:1867
bool IsBottomAxis()
Return true when this X axis is aligned at the bottom edge or bottom border.
Definition: mathplot.h:3144
const wxString & GetWildcard(void) const
Get wildcard.
Definition: mathplot.h:4137
Line (horizontal or vertical) type layer.
Definition: mathplot.h:792
void SetReserve(int reserve)
Set memory reserved for m_xs and m_ys Note : this does not modify the size of m_xs and m_ys...
Definition: mathplot.h:2265
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2906
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition: mathplot.h:373
size_t m_endIndex
The end index indicating the last point inside plot area.
Definition: mathplot.h:2286