wxMathPlot
mathplot.h
Go to the documentation of this file.
1 // Name: mathplot.h
3 // Purpose: Framework for plotting in wxWindows
4 // Original Author: David Schalig
5 // Maintainer: Davide Rondini
6 // Contributors: Jose Luis Blanco, Val Greene, Lionel Reynaud, Dave Nadler, MortenMacFly,
7 // Oskar Waldemarsson (for multi Y axis and corrections)
8 // Created: 21/07/2003
9 // Last edit: 11/07/2026
10 // Copyright: (c) David Schalig, Davide Rondini
11 // Licence: wxWindows licence
13 
14 #ifndef MATHPLOT_H_INCLUDED
15 #define MATHPLOT_H_INCLUDED
16 
81 // mathplot_EXPORTS definition uses windows dll to export function.
82 // mathplot_EXPORTS will be defined by cmake
83 #ifdef mathplot_EXPORTS
84  #define WXDLLIMPEXP_MATHPLOT WXEXPORT
86  #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
88 #else // not making DLL
89  #define WXDLLIMPEXP_MATHPLOT
91  #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
93 #endif
94 
95 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
96  #pragma interface "mathplot.h"
97 #endif
98 
99 #include <cassert> // For assert debug message (assert is disabled if NDEBUG is defined)
100 #include <vector>
101 #include <map>
102 #include <unordered_map>
103 
104 #include <optional>
106 typedef std::optional<unsigned int> mpOptional_uint;
108 typedef std::optional<int> mpOptional_int;
109 
110 // #include <wx/wx.h>
111 #include <wx/defs.h>
112 #include <wx/menu.h>
113 #include <wx/scrolwin.h>
114 #include <wx/event.h>
115 #include <wx/dynarray.h>
116 #include <wx/pen.h>
117 #include <wx/dcmemory.h>
118 #include <wx/string.h>
119 #include <wx/print.h>
120 #include <wx/image.h>
121 #include <wx/intl.h>
122 
123 #include <cmath>
124 #include <deque>
125 #include <algorithm>
126 
127 #if defined(MP_USER_INCLUDE)
128  #define xstr(x) #x
130  #define str(x) xstr(x)
132  #define header MP_USER_INCLUDE.h
133  #include str(header)
134  #undef header
135 #endif
136 
137 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
138  #include "MathPlotConfig.h"
139 #endif // MP_ENABLE_CONFIG
140 
145 #if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
146  namespace MathPlot {
147 #endif // MP_ENABLE_NAMESPACE
148 
149 #ifdef MP_ENABLE_DEBUG
150  // For memory leak debug
151  #ifdef _WIN32
152  #ifdef _DEBUG
153  #include <crtdbg.h>
154  #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
155  #else
156  #define DEBUG_NEW new
157  #endif // _DEBUG
158  #endif // _WINDOWS
159 #endif // MP_ENABLE_DEBUG
160 
162 #define MP_X_BORDER_SEPARATION 40
163 #define MP_Y_BORDER_SEPARATION 60
165 
167 #define MP_X_LOCALTIME 0x10
168 #define MP_X_UTCTIME 0x20
170 #define MP_X_RAWTIME MP_X_UTCTIME
172 
174 #define MP_EPSILON 1e-30
175 #define MP_ISNOTNULL(x) (std::fpclassify(x) != FP_ZERO)
177 
179 #define MP_EXTRA_MARGIN 8
180 
182 #define MP_ZOOM_AROUND_CENTER -1
183 
184 //-----------------------------------------------------------------------------
185 // classes
186 //-----------------------------------------------------------------------------
187 
189 #define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class) wxDECLARE_DYNAMIC_CLASS(mp_class)
190 
220 
221 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
223 #endif // MP_ENABLE_CONFIG
224 
226 struct mpRect
227 {
228  union {
229  struct
230  {
231  wxCoord startPx;
232  wxCoord startPy;
233  wxCoord endPx;
234  wxCoord endPy;
235  };
236  struct
237  {
238  wxCoord left;
239  wxCoord top;
240  wxCoord right;
241  wxCoord bottom;
242  };
243  struct
244  {
245  wxCoord x1;
246  wxCoord y1;
247  wxCoord x2;
248  wxCoord y2;
249  };
250  wxCoord tab[4];
251  };
256  wxRect GetRect(void) const
257  {
258  return wxRect(startPx, startPy, endPx - startPx, endPy - startPy);
259  }
260 };
261 static_assert(sizeof(mpRect) == 4 * sizeof(wxCoord));
262 
268 template<typename T>
269 struct mpRange
270 {
271  T min = 0;
272  T max = 0;
273 
276  {
277  min = 0;
278  max = 0;
279  }
280 
282  mpRange(T value1, T value2)
283  {
284  if (value1 < value2)
285  {
286  min = value1;
287  max = value2;
288  }
289  else
290  {
291  min = value2;
292  max = value1;
293  }
294  }
295 
297  void Set(T value_)
298  {
299  min = value_;
300  max = value_;
301  }
302 
304  void Set(T min_, T max_)
305  {
306  min = min_;
307  max = max_;
308  }
309 
311  void SetMin(T min_)
312  {
313  min = min_;
314  if (max < min)
315  max = min;
316  }
317 
319  void SetMax(T max_)
320  {
321  max = max_;
322  if (min > max)
323  min = max;
324  }
325 
327  void Assign(T value1, T value2)
328  {
329  if (value1 < value2)
330  {
331  min = value1;
332  max = value2;
333  }
334  else
335  {
336  min = value2;
337  max = value1;
338  }
339  }
340 
342  bool IsSet() const
343  {
344  return ((min != 0) || (max != 0));
345  }
346 
351  void Update(T value)
352  {
353  if (value < min)
354  min = value;
355  else
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(const double px, const double py, const 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(const double px, const double py, const 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(const double px, const double py, const 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 = [](const double a, const 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 
571  mpFloatRectSimple(const mpRange<double> x_, const mpRange<double> y_) : x(x_), y(y_) { };
572 
578  bool PointIsInside(const double px, const double py) const {
579  return x.PointIsInside(px) && y.PointIsInside(py);
580  }
581 
587  void UpdateBoundingBoxToInclude(const double px, const double py)
588  {
589  x.Update(px);
590  y.Update(py);
591  }
592 
597  void InitializeBoundingBox(const double px, const double py)
598  {
599  x.Set(px, px);
600  y.Set(py, py);
601  }
602 };
603 
606 struct mpPlotHit
607 {
608  wxColour colour;
609  wxRealPoint coords;
610 };
611 
615 enum
616 {
617  mpID_FIT = 2000,
625 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
626  mpID_CONFIG,
627 #endif // MP_ENABLE_CONFIG
631 };
632 
634 typedef enum __mp_Location_Type
635 {
646 } mpLocation;
647 
649 typedef enum __XAxis_Align_Type
650 {
656 } mpXAxis_Align;
657 
659 typedef enum __YAxis_Align_Type
660 {
666 } mpYAxis_Align;
667 
670 {
675 } mpPlot_Align;
676 
678 typedef enum __mp_Style_Type
679 {
683 } mpLegendStyle;
684 
687 {
691 
693 typedef enum __Symbol_Type
694 {
702 } mpSymbol;
703 
704 //-----------------------------------------------------------------------------
705 // mpLayer sub_type values
706 //-----------------------------------------------------------------------------
707 
709 typedef enum __Info_Type
710 {
715 } mpInfoType;
716 
718 typedef enum __Text_Type
719 {
723 } mpTextType;
724 
726 typedef enum __Function_Type
727 {
737 
739 typedef enum __Scale_Type
740 {
745 } mpScaleType;
746 
748 typedef enum __Chart_Type
749 {
754 } mpChartType;
755 
758 {
761 };
762 
765 {
785 };
786 
787 //-----------------------------------------------------------------------------
788 // mpLayer
789 //-----------------------------------------------------------------------------
790 
792 typedef enum __mp_Layer_Type
793 {
802 } mpLayerType;
803 
809 typedef enum __mp_Layer_ZOrder
810 {
819 } mpLayerZOrder;
820 
827 typedef enum __mp_Delete_Action
828 {
833 
844 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
845 {
846  public:
851  mpLayer(mpLayerType layerType);
852 
853  ~mpLayer() override
854  {
855  ;
856  }
857 
861  {
862  m_win = &w;
863  }
864 
872  virtual bool HasBBox()
873  {
874  return true;
875  }
876 
880  mpLayerType GetLayerType() const
881  {
882  return m_type;
883  }
884 
888  int GetLayerSubType() const
889  {
890  return m_subtype;
891  }
892 
898  virtual bool IsLayerType(const mpLayerType typeOfInterest, int *subtype)
899  {
900  *subtype = m_subtype;
901  return (m_type == typeOfInterest);
902  }
903 
907  virtual double GetMinX()
908  {
909  return -1.0;
910  }
911 
915  virtual double GetMaxX()
916  {
917  return 1.0;
918  }
919 
923  virtual double GetMinY()
924  {
925  return -1.0;
926  }
927 
931  virtual double GetMaxY()
932  {
933  return 1.0;
934  }
935 
977  void Plot(wxDC &dc, mpWindow &w);
978 
982  void SetName(const wxString &name)
983  {
984  m_name = name;
985  }
986 
990  const wxString& GetName() const
991  {
992  return m_name;
993  }
994 
998  void SetFont(const wxFont &font)
999  {
1000  m_font = font;
1001  }
1002 
1006  const wxFont& GetFont() const
1007  {
1008  return m_font;
1009  }
1010 
1014  void SetFontColour(const wxColour &colour)
1015  {
1016  m_fontcolour = colour;
1017  }
1018 
1022  const wxColour& GetFontColour() const
1023  {
1024  return m_fontcolour;
1025  }
1026 
1030  void SetPen(const wxPen &pen)
1031  {
1032  m_pen = pen;
1033  }
1034 
1038  const wxPen& GetPen() const
1039  {
1040  return m_pen;
1041  }
1042 
1045  void SetBrush(const wxBrush &brush)
1046  {
1047  if (brush == wxNullBrush)
1048  m_brush = *wxTRANSPARENT_BRUSH;
1049  else
1050  m_brush = brush;
1051  }
1052 
1056  void SetBrush(const wxColour &colour, enum wxBrushStyle style = wxBRUSHSTYLE_SOLID)
1057  {
1058  m_brush.SetColour(colour);
1059  m_brush.SetStyle(style);
1060  }
1061 
1064  const wxBrush& GetBrush() const
1065  {
1066  return m_brush;
1067  }
1068 
1071  void SetShowName(const bool show)
1072  {
1073  m_showName = show;
1074  }
1075 
1078  bool GetShowName() const
1079  {
1080  return m_showName;
1081  }
1082 
1085  void SetDrawOutsideMargins(const bool drawModeOutside)
1086  {
1087  m_drawOutsideMargins = drawModeOutside;
1088  }
1089 
1093  {
1094  return m_drawOutsideMargins;
1095  }
1096 
1101  wxBitmap GetColourSquare(int side = 16);
1102 
1105  bool IsVisible() const
1106  {
1107  return m_visible;
1108  }
1109 
1112  virtual void SetVisible(const bool show)
1113  {
1114  m_visible = show;
1115  }
1116 
1119  bool IsTractable() const
1120  {
1121  return m_tractable;
1122  }
1123 
1126  virtual void SetTractable(const bool track)
1127  {
1128  m_tractable = track;
1129  }
1130 
1133  void SetAlign(const int align)
1134  {
1135  m_flags = align;
1136  }
1137 
1140  int GetAlign() const
1141  {
1142  return m_flags;
1143  }
1144 
1147  void SetCanDelete(const bool canDelete)
1148  {
1149  m_CanDelete = canDelete;
1150  }
1151 
1154  bool GetCanDelete(void) const
1155  {
1156  return m_CanDelete;
1157  }
1158 
1161  mpLayerZOrder GetZIndex(void) const
1162  {
1163  return m_ZIndex;
1164  }
1165 
1166  protected:
1167  const mpLayerType m_type;
1170  wxFont m_font;
1171  wxColour m_fontcolour;
1172  wxPen m_pen;
1173  wxBrush m_brush;
1174  wxString m_name;
1175  bool m_showName;
1177  bool m_visible;
1179  int m_flags;
1182  mpLayerZOrder m_ZIndex;
1183 
1186  void UpdateContext(wxDC &dc) const;
1187 
1192  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1193 
1198  virtual bool DoBeforePlot()
1199  {
1200  return true;
1201  }
1202 
1209  void CheckLog(double *x, double *y, int yAxisID);
1210 
1211  private:
1212  bool m_busy;
1213  mpLayer() = delete; // default ctor not implemented/permitted
1214 
1216 };
1217 
1218 //-----------------------------------------------------------------------------
1219 // mpInfoLayer
1220 //-----------------------------------------------------------------------------
1221 
1228 {
1229  public:
1231  mpInfoLayer();
1232 
1237  mpInfoLayer(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1238 
1240  ~mpInfoLayer() override;
1241 
1244  void SetVisible(bool show) override;
1245 
1250  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1251 
1254  bool HasBBox() override
1255  {
1256  return false;
1257  }
1258 
1261  [[deprecated("Use Show() instead")]]
1262  virtual void ErasePlot(wxDC&, mpWindow&) {};
1263 
1267  virtual bool Inside(const wxPoint &point);
1268 
1272  virtual void Move(wxPoint delta, mpWindow &w);
1273 
1275  virtual void UpdateReference();
1276 
1279  wxPoint GetPosition() const
1280  {
1281  return m_dim.GetPosition();
1282  }
1283 
1286  void SetInitialPosition(const wxPoint pos)
1287  {
1288  m_relX = pos.x / 100.0;
1289  m_relY = pos.y / 100.0;
1290  }
1291 
1294  wxSize GetSize() const
1295  {
1296  return m_dim.GetSize();
1297  }
1298 
1301  const wxRect& GetRectangle() const
1302  {
1303  return m_dim;
1304  }
1305 
1308  void SetLocation(const mpLocation location)
1309  {
1310  m_location = location;
1311  }
1312 
1315  mpLocation GetLocation() const
1316  {
1317  return m_location;
1318  }
1319 
1320  protected:
1321  wxRect m_dim;
1322  wxBitmap* m_info_bmp;
1323  wxPoint m_reference;
1324  double m_relX;
1325  double m_relY;
1326  mpLocation m_location;
1327 
1332  void DoPlot(wxDC &dc, mpWindow &w) override;
1333 
1336  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1337 
1338  private:
1339 
1341 };
1342 
1348 {
1349  public:
1351  mpInfoCoords();
1352 
1354  mpInfoCoords(mpLocation location);
1355 
1360  mpInfoCoords(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1361 
1363  ~mpInfoCoords() override
1364  {
1365  ;
1366  }
1367 
1370  {
1373  infoCoord_allSeries
1374  };
1375 
1379  void UpdateInfo(mpWindow &w, wxEvent &event) override;
1380 
1383  [[deprecated("Use Show() instead")]]
1384  void ErasePlot(wxDC&, mpWindow&) override {};
1385 
1388  void Show(const bool show)
1389  {
1390  m_show = show;
1391  }
1392 
1395  bool IsShown() const
1396  {
1397  return m_show;
1398  }
1399 
1404  bool ShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
1405  {
1406  return IsVisible() && (GetDrawOutsideMargins() || plotArea.Contains(mousePos));
1407  }
1408 
1412  void SetLabelMode(const mpLabelType mode, const unsigned int time_conv = MP_X_RAWTIME)
1413  {
1414  m_labelType = mode;
1415  m_timeConv = time_conv;
1416  }
1417 
1420  [[deprecated("Deprecated, use SetInfoCoordType instead")]]
1421  void SetSeriesCoord(const bool show)
1422  {
1423  m_infoCoordType = show ? infoCoord_closestSeries : infoCoord_axis;
1424  }
1425 
1430  {
1431  m_infoCoordType = type;
1432  }
1433 
1438  {
1439  return m_infoCoordType;
1440  }
1441 
1447  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1448 
1452  void DrawContent(wxDC &dc, mpWindow &w);
1453 
1454  protected:
1455  bool m_show;
1456  wxString m_content;
1458  unsigned int m_timeConv;
1459  wxCoord m_mouseX;
1460  wxCoord m_mouseY;
1462  std::vector<wxColor> m_seriesColors;
1463 
1468  void DoPlot(wxDC &dc, mpWindow &w) override;
1469 
1470  private:
1471 
1473 };
1474 
1480 {
1481  public:
1483  mpInfoLegend();
1484 
1490  mpInfoLegend(wxPoint pos, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginUser);
1491 
1493  ~mpInfoLegend() override {}
1494 
1497  void SetItemMode(const mpLegendStyle mode)
1498  {
1499  m_item_mode = mode;
1500  m_needs_update = true;
1501  }
1502 
1504  mpLegendStyle GetItemMode() const
1505  {
1506  return m_item_mode;
1507  }
1508 
1511  void SetItemDirection(const mpLegendDirection mode)
1512  {
1513  m_item_direction = mode;
1514  m_needs_update = true;
1515  }
1516 
1518  mpLegendDirection GetItemDirection() const
1519  {
1520  return m_item_direction;
1521  }
1522 
1525  {
1526  m_needs_update = true;
1527  }
1528 
1531  void ShowDraggedSeries(const bool active)
1532  {
1533  m_showDraggedSeries = active;
1534  }
1535 
1539  {
1540  return m_showDraggedSeries;
1541  }
1542 
1545  void EnableSeriesValues(const bool enable)
1546  {
1547  m_enableSeriesValues = enable;
1548  m_maxSeriesValueWidth = 0;
1549  }
1550 
1554  {
1555  return m_enableSeriesValues;
1556  }
1557 
1561  bool SeriesValuesShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
1562  {
1563  return m_enableSeriesValues && plotArea.Contains(mousePos);
1564  }
1565 
1568  void ShowSeriesValues(const bool show)
1569  {
1570  m_showSeriesValues = show;
1571  }
1572 
1575  bool IsSeriesValuesShown() const
1576  {
1577  return m_showSeriesValues && IsVisible();
1578  }
1579 
1582  void IndicateSeriesIntersection(const bool enable)
1583  {
1584  m_indicateSeriesIntersection = enable;
1585  }
1586 
1589  void SetVerticalCursorFollowMouse();
1590 
1593  void SetVerticalCursorFixed(double posX);
1594 
1597  {
1599  CursorMode_fixed
1600  };
1601 
1605  {
1606  return m_verticalCursorMode;
1607  }
1608 
1612  wxCoord GetVerticalCursorX() const;
1613 
1619  int GetLegendHitRegion(wxPoint mousePos);
1620 
1627  void DrawDraggedSeries(wxDC& dc, mpWindow &w) const;
1628 
1632  void DrawContent(wxDC &dc, mpWindow &w);
1633 
1636  static void RestoreAxisHighlighting(mpWindow &w);
1637 
1639  enum HitCode : int
1640  {
1641  HitNone = -1,
1642  HitHeader = -2
1643  };
1644 
1645  mpFunction* m_selectedSeries = nullptr;
1646  mpOptional_int m_lastHoveredAxisID = std::nullopt;
1647 
1648  protected:
1649  mpLegendStyle m_item_mode;
1650  mpLegendDirection m_item_direction;
1652  wxString m_headerString = wxString::FromUTF8("≡");
1653 
1658  void DoPlot(wxDC &dc, mpWindow &w) override;
1659 
1660  private:
1662  struct LegendDetail
1663  {
1664  unsigned int layerIdx;
1665  wxCoord legendEnd;
1666  };
1668  std::vector<LegendDetail> m_LegendDetailList;
1669  wxCoord m_headerEnd;
1670  bool m_needs_update;
1671  int m_maxSeriesValueWidth;
1672  bool m_enableSeriesValues;
1673  bool m_showSeriesValues;
1674  bool m_indicateSeriesIntersection;
1675  VerticalCursorMode m_verticalCursorMode;
1676  double m_verticalCursorPosX;
1677 
1688  void UpdateBitmap(wxDC &dc, mpWindow &w);
1689 
1698  int GetMaxLabelWidth(wxDC &dc, mpWindow &w) const;
1699 
1720  int DrawSeriesValue(wxDC& dc, mpWindow& w, mpFunction& function, int posX, int posY, int labelHeight, int labelWidth, int maxLabelWidth);
1721 
1722  private:
1724 };
1725 
1726 //-----------------------------------------------------------------------------
1727 // mpLayer implementations - functions
1728 //-----------------------------------------------------------------------------
1729 
1730 
1738 {
1739  public:
1745  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1746 
1750  void SetContinuity(const bool continuity)
1751  {
1752  m_continuous = continuity;
1753  }
1754 
1758  bool GetContinuity() const
1759  {
1760  return m_continuous;
1761  }
1762 
1765  void SetStep(const unsigned int step)
1766  {
1767  m_step = step;
1768  }
1769 
1772  unsigned int GetStep() const
1773  {
1774  return m_step;
1775  }
1776 
1779  void SetSymbol(const mpSymbol symbol)
1780  {
1781  m_symbol = symbol;
1782  }
1783 
1786  mpSymbol GetSymbol() const
1787  {
1788  return m_symbol;
1789  }
1790 
1793  void SetSymbolSize(const int size)
1794  {
1795  m_symbolSize = size;
1796  }
1797 
1800  int GetSymbolSize() const
1801  {
1802  return m_symbolSize;
1803  }
1804 
1808  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1809 
1813  std::optional<double> GetSeriesValue(double xValue);
1814 
1818  int GetYAxisID() const
1819  {
1820  return m_yAxisID;
1821  }
1822 
1827  void SetYAxisID(const unsigned int yAxisID)
1828  {
1829  m_yAxisID = yAxisID;
1830  }
1831 
1835  void SetLegendIsAlwaysVisible(const bool alwaysVisible)
1836  {
1837  m_LegendIsAlwaysVisible = alwaysVisible;
1838  }
1839 
1844  {
1845  return m_LegendIsAlwaysVisible;
1846  }
1847 
1851  void SetAutoStep(const bool enable)
1852  {
1853  m_autoStep = enable;
1854  }
1855 
1858  bool GetAutoStep() const
1859  {
1860  return m_autoStep;
1861  }
1862 
1866  void SetMaxNOfPoints(const size_t nOfPoints)
1867  {
1868  m_maxNOfPoints = nOfPoints;
1869  }
1870 
1873  size_t GetMaxNOfPoints() const
1874  {
1875  return m_maxNOfPoints;
1876  }
1877 
1878  protected:
1880  mpSymbol m_symbol;
1882  unsigned int m_step;
1885  bool m_autoStep;
1887 
1888  private:
1890 };
1891 
1895 {
1896  public:
1903  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1904 
1905  // We don't want to include line (horizontal or vertical) in BBox computation
1906  bool HasBBox() override
1907  {
1908  return false;
1909  }
1910 
1914  double GetValue() const
1915  {
1916  return m_value;
1917  }
1918 
1922  void SetValue(const double value)
1923  {
1924  m_value = value;
1925  }
1926 
1930  bool IsHorizontal(void) const
1931  {
1932  return m_IsHorizontal;
1933  }
1934 
1935  protected:
1936  double m_value;
1938 
1939  private:
1941 };
1942 
1946 {
1947  public:
1954  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1955 
1959  void SetYValue(const double yvalue)
1960  {
1961  SetValue(yvalue);
1962  }
1963 
1964  protected:
1965 
1966  void DoPlot(wxDC &dc, mpWindow &w) override;
1967 
1968  private:
1970 };
1971 
1975 {
1976  public:
1982  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1983 
1987  void SetXValue(const double xvalue)
1988  {
1989  SetValue(xvalue);
1990  }
1991 
1992  protected:
1993 
1994  void DoPlot(wxDC &dc, mpWindow &w) override;
1995 
2000  bool DoBeforePlot() override
2001  {
2002  return true;
2003  }
2004 
2005  private:
2007 };
2008 
2016 {
2017  public:
2022  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
2023 
2029  virtual double GetY(double x) = 0;
2030 
2037  double DoGetY(double x);
2038 
2043  void DefineDoGetY(void);
2044 
2045  protected:
2046 
2047  double (mpFX::*pDoGetY)(double x);
2048 
2053  void DoPlot(wxDC &dc, mpWindow &w) override;
2054 
2059  double NormalDoGetY(double x);
2060 
2065  double LogDoGetY(double x);
2066 
2067  private:
2069 };
2070 
2078 {
2079  public:
2084  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
2085 
2091  virtual double GetX(double y) = 0;
2092 
2099  double DoGetX(double y);
2100 
2105  void DefineDoGetX(void);
2106 
2107  protected:
2108 
2109  double (mpFY::*pDoGetX)(double y);
2110 
2115  void DoPlot(wxDC &dc, mpWindow &w) override;
2116 
2121  double NormalDoGetX(double y);
2122 
2127  double LogDoGetX(double y);
2128 
2129  private:
2131 };
2132 
2143 {
2144  public:
2150  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2151 
2155  virtual void Rewind() = 0;
2156 
2160  virtual void Clear()
2161  {
2162  ;
2163  }
2164 
2168  virtual size_t GetSize()
2169  {
2170  return 0;
2171  }
2172 
2179  virtual bool GetNextXY(double *x, double *y) = 0;
2180 
2187  bool DoGetNextXY(double *x, double *y);
2188 
2193  void SetViewMode(bool asBar);
2194 
2199  int GetBarWidth(void) const
2200  {
2201  return m_BarWidth;
2202  }
2203 
2208  bool ViewAsBar(void) const
2209  {
2210  return m_ViewAsBar;
2211  }
2212 
2213  protected:
2214 
2215  // Data to calculate label positioning
2218 
2219  // Min delta between 2 x coordinate (used for view as bar)
2220  double m_deltaX;
2221  double m_deltaY;
2222 
2224 
2225  bool m_ViewAsBar = false;
2226 
2233  void DoPlot(wxDC &dc, mpWindow &w) override;
2234 
2239  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
2240 
2241  private:
2243 };
2244 
2245 //-----------------------------------------------------------------------------
2246 // mpFXYVector - provided by Jose Luis Blanco
2247 //-----------------------------------------------------------------------------
2248 
2269 {
2270  public:
2276  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2277 
2280  ~mpFXYVector() override
2281  {
2282  Clear();
2283  }
2284 
2289  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
2290 
2294  void Clear() override;
2295 
2300  size_t GetSize() override
2301  {
2302  return m_xs.size();
2303  }
2304 
2306  const std::vector<double>& GetXData() const
2307  {
2308  return m_xs;
2309  }
2310 
2312  const std::vector<double>& GetYData() const
2313  {
2314  return m_ys;
2315  }
2316 
2324  bool AddData(double x, double y, bool updatePlot);
2325 
2332  void SetReserve(const int reserve)
2333  {
2334  m_reserveXY = reserve;
2335  m_xs.reserve(m_reserveXY);
2336  m_ys.reserve(m_reserveXY);
2337  }
2338 
2342  int GetReserve() const
2343  {
2344  return m_reserveXY;
2345  }
2346 
2347  protected:
2348  std::vector<double> m_xs;
2349  std::vector<double> m_ys;
2352  size_t m_index;
2353  size_t m_endIndex;
2355  double m_lastX;
2357  double m_lastY;
2358 
2363  void Rewind() override;
2364 
2371  bool GetNextXY(double *x, double *y) override;
2372 
2377  void DrawAddedPoint(double x, double y);
2378 
2381  double GetMinX()override
2382  {
2383  if (m_ViewAsBar)
2384  {
2385  // Make extra space for outer bars
2386  return m_rangeX.min - (m_deltaX / 2);
2387  }
2388  else
2389  {
2390  return m_rangeX.min;
2391  }
2392  }
2393 
2396  double GetMinY() override
2397  {
2398  return m_rangeY.min;
2399  }
2400 
2403  double GetMaxX() override
2404  {
2405  if(m_ViewAsBar)
2406  {
2407  // Make extra space for outer bars
2408  return m_rangeX.max + (m_deltaX / 2);
2409  }
2410  else
2411  {
2412  return m_rangeX.max;
2413  }
2414  }
2415 
2418  double GetMaxY() override
2419  {
2420  return m_rangeY.max;
2421  }
2422 
2423  private:
2426  void First_Point(double x, double y);
2427 
2430  static void Check_Limit(double val, mpRange<double> *range, double *last, double *delta);
2431 
2433 };
2434 
2444 {
2445  public:
2449  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
2450 
2456  virtual double GetY(double x) = 0;
2457 
2458  protected:
2459 
2464  void DoPlot(wxDC &dc, mpWindow &w) override;
2465 
2466  private:
2468 };
2469 
2474 class mpFXGeneric: public mpFX
2475 {
2476  public:
2481  mpFXGeneric(const wxString &name = wxT("Generic FX function"), const int flags = mpALIGN_LEFT, const unsigned int yAxisID = 0) :
2482  mpFX(name, flags, yAxisID)
2483  {
2484  const wxPen FXpen(*wxBLUE, 1, wxPENSTYLE_SOLID);
2485  SetDrawOutsideMargins(false);
2486  SetContinuity(true);
2487  SetPen(FXpen);
2488  SetStep(8); // Draw one point over eight
2489  }
2490 
2495  double GetY(const double x) override
2496  {
2497  double y;
2498  try
2499  {
2500  y = ComputeY(x);
2501  }
2502  catch (...)
2503  {
2504  y = 0;
2505  }
2506  m_rangeY.Update(y);
2507  return y;
2508  }
2509 
2514  double GetMinY() override
2515  {
2516  return m_rangeY.min;
2517  }
2518 
2523  double GetMaxY() override
2524  {
2525  return m_rangeY.max;
2526  }
2527 
2528  protected:
2530 
2536  virtual double ComputeY(double x) = 0;
2537 
2538  private:
2540 };
2541 
2547 {
2548  public:
2554  mpGaussian(const double mu, const double sigma) :
2555  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2556  {
2557  m_mu = mu;
2558  m_sigma = sigma;
2559  m_variance = sigma * sigma;
2560  m_const = 1.0 / sqrt(2.0 * M_PI * m_variance);
2561  }
2562 
2563  protected:
2564  double m_mu;
2565  double m_sigma;
2566  double m_variance;
2567  double m_const;
2568 
2569  double ComputeY(const double x) override
2570  {
2571  return m_const * exp(-(x - m_mu) * (x - m_mu) / (2.0 * m_variance));
2572  }
2573 
2574  private:
2576 };
2577 
2582 class mpNormal: public mpFXGeneric
2583 {
2584  public:
2590  mpNormal(const double mu, const double sigma) :
2591  mpFXGeneric(wxT("Normal"), mpALIGN_LEFT)
2592  {
2593  m_mu = mu;
2594  m_sigma = sigma;
2595  m_variance = sigma * sigma;
2596  m_const = 1.0 / (m_variance * sqrt(2.0 * M_PI));
2597  }
2598 
2599  protected:
2600  double m_mu;
2601  double m_sigma;
2602  double m_variance;
2603  double m_const;
2604 
2605  double ComputeY(const double x) override
2606  {
2607  if (x < 0)
2608  return 0.0;
2609  else
2610  {
2611  const double tmp = log(x) - m_mu;
2612  return m_const * exp(-tmp * tmp / (2.0 * m_variance)) / x;
2613  }
2614  }
2615 
2616  private:
2618 };
2619 
2620 //-----------------------------------------------------------------------------
2621 // mpChart
2622 //-----------------------------------------------------------------------------
2626 {
2627  public:
2629  mpChart(const wxString &name = wxEmptyString);
2630 
2632  ~mpChart() override
2633  {
2634  Clear();
2635  }
2636 
2639  void SetChartValues(const std::vector<double> &data);
2640 
2643  void SetChartLabels(const std::vector<std::string> &labelArray);
2644 
2649  void AddData(const double &data, const std::string &label);
2650 
2654  virtual void Clear();
2655 
2656  bool HasBBox() override
2657  {
2658  return (values.size() > 0);
2659  }
2660 
2661  protected:
2662  std::vector<double> values;
2663  std::vector<std::string> labels;
2664 
2665  double m_max_value;
2666  double m_total_value;
2667 
2668  private:
2670 };
2671 
2672 //-----------------------------------------------------------------------------
2673 // mpBarChart - provided by Jose Davide Rondini
2674 //-----------------------------------------------------------------------------
2675 /* Defines for bar charts label positioning. */
2676 #define mpBAR_NONE 0
2677 #define mpBAR_AXIS_H 1
2678 #define mpBAR_AXIS_V 2
2679 #define mpBAR_INSIDE 3
2680 #define mpBAR_TOP 4
2681 
2682 
2685 {
2686  public:
2688  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2689 
2691  ~mpBarChart() override
2692  {
2693  Clear();
2694  }
2695 
2697  void SetBarColour(const wxColour &colour);
2698 
2700  void SetColumnWidth(const double colWidth)
2701  {
2702  m_width = colWidth;
2703  }
2704 
2706  void SetBarLabelPosition(int position);
2707 
2711  double GetMinX() override;
2712 
2716  double GetMaxX() override;
2717 
2721  double GetMinY() override;
2722 
2726  double GetMaxY() override;
2727 
2728  protected:
2729 
2730  double m_width;
2731  wxColour m_barColour;
2733  double m_labelAngle;
2734 
2739  void DoPlot(wxDC &dc, mpWindow &w) override;
2740 
2741  private:
2743 };
2744 
2749 {
2750  public:
2754  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2755 
2757  ~mpPieChart() override
2758  {
2759  Clear();
2760  colours.clear();
2761  }
2762 
2766  void SetCenter(const wxPoint center)
2767  {
2768  m_center = center;
2769  }
2770 
2774  wxPoint GetCenter(void) const
2775  {
2776  return m_center;
2777  }
2778 
2782  void SetPieColours(const std::vector<wxColour> &colourArray);
2783 
2787  double GetMinX() override
2788  {
2789  return m_center.x - m_radius;
2790  }
2791 
2795  double GetMaxX() override
2796  {
2797  return m_center.x + m_radius;
2798  }
2799 
2803  double GetMinY() override
2804  {
2805  return m_center.y - m_radius;
2806  }
2807 
2811  double GetMaxY() override
2812  {
2813  return m_center.y + m_radius;
2814  }
2815 
2816  protected:
2817 
2818  double m_radius;
2819  wxPoint m_center;
2820  std::vector<wxColour> colours;
2821 
2826  void DoPlot(wxDC &dc, mpWindow &w) override;
2827 
2829  const wxColour& GetColour(unsigned int id);
2830 
2831  private:
2833 };
2834 
2837 //-----------------------------------------------------------------------------
2838 // mpLayer implementations - furniture (scales, ...)
2839 //-----------------------------------------------------------------------------
2848 {
2849  public:
2856  {
2857  double step = 0.0;
2858  double maxAxisValue = 0.0;
2859  bool UseScientific = false;
2860  int SignificantDigits = 0;
2861  int DecimalDigits = 0;
2862  double EpsilonScale = 0.0;
2863  };
2864 
2872  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, mpOptional_uint axisID = std::nullopt);
2873 
2877  bool HasBBox() override
2878  {
2879  return false;
2880  }
2881 
2885  int GetAxisID(void) const
2886  {
2887  return m_axisID;
2888  }
2889 
2894  void SetAxisID(const unsigned int yAxisID)
2895  {
2896  m_axisID = yAxisID;
2897  }
2898 
2901  void ShowTicks(const bool ticks)
2902  {
2903  m_ticks = ticks;
2904  }
2905 
2908  bool GetShowTicks() const
2909  {
2910  return m_ticks;
2911  }
2912 
2915  void ShowGrids(const bool grids)
2916  {
2917  m_grids = grids;
2918  }
2919 
2922  bool GetShowGrids() const
2923  {
2924  return m_grids;
2925  }
2926 
2931  void SetLabelFormat(const wxString &format, const bool updateLabelMode = false)
2932  {
2933  m_labelFormat = format;
2934  if (updateLabelMode)
2935  m_labelType = mpLabel_USER;
2936  }
2937 
2941  {
2942  return m_labelType;
2943  }
2944 
2948  void SetLabelMode(const mpLabelType mode, const unsigned int time_conv = MP_X_RAWTIME)
2949  {
2950  m_labelType = mode;
2951  m_timeConv = time_conv;
2952  }
2953 
2956  const wxString& GetLabelFormat() const
2957  {
2958  return m_labelFormat;
2959  }
2960 
2964  void SetGridPen(const wxPen &pen)
2965  {
2966  m_gridpen = pen;
2967  }
2968 
2972  const wxPen& GetGridPen() const
2973  {
2974  return m_gridpen;
2975  }
2976 
2980  void SetAuto(const bool automaticScalingIsEnabled)
2981  {
2982  m_auto = automaticScalingIsEnabled;
2983  }
2984 
2988  bool GetAuto() const
2989  {
2990  return m_auto;
2991  }
2992 
2996  void SetMinScale(const double min)
2997  {
2998  m_axisRange.SetMin(min);
2999  }
3000 
3004  double GetMinScale() const
3005  {
3006  return m_axisRange.min;
3007  }
3008 
3012  void SetMaxScale(const double max)
3013  {
3014  m_axisRange.SetMax(max);
3015  }
3016 
3020  double GetMaxScale() const
3021  {
3022  return m_axisRange.max;
3023  }
3024 
3029  void SetScale(const double min, const double max)
3030  {
3031  m_axisRange.Set(min, max);
3032  }
3033 
3038  void GetScale(double *min, double *max) const
3039  {
3040  *min = m_axisRange.min;
3041  *max = m_axisRange.max;
3042  }
3043 
3047  void SetScale(const mpRange<double> range)
3048  {
3049  m_axisRange = range;
3050  }
3051 
3056  {
3057  return mpRange<double>(m_axisRange);
3058  }
3059 
3063  void SetHovering(const bool hover)
3064  {
3065  m_hover = hover;
3066  }
3067 
3071  virtual bool IsLogAxis()
3072  {
3073  return m_isLog;
3074  }
3075 
3079  virtual void SetLogAxis(const bool log)
3080  {
3081  m_isLog = log;
3082  }
3083 
3087  void SetCoordIsAlwaysVisible(const bool alwaysVisible)
3088  {
3089  m_CoordIsAlwaysVisible = alwaysVisible;
3090  }
3091 
3096  {
3097  return m_CoordIsAlwaysVisible;
3098  }
3099 
3106  static mpScaleConstraints ComputeScaleConstraints(double step, double maxAxisValue);
3107 
3114  wxString FormatLabelValue(double value, const mpScaleConstraints &constraints);
3115 
3116  protected:
3117  static constexpr wxCoord kTickSize = 4;
3118  static constexpr wxCoord kYAxisExtraSpace = 6;
3119  static constexpr wxCoord kYAxisTitleSpace = 2;
3120  static constexpr wxCoord kYAxisLabelSpace = 2;
3121  static constexpr wxCoord kXAxisTitleSpace = 3;
3122 
3123  int m_axisID;
3124  wxPen m_gridpen;
3125  bool m_ticks;
3126  bool m_grids;
3127  bool m_auto;
3130  unsigned int m_timeConv;
3131  wxString m_labelFormat;
3132  bool m_isLog;
3133  bool m_hover = false;
3135 
3138  virtual int GetOrigin(mpWindow &w) = 0;
3139 
3146  static double GetStep(double scale, int minLabelSpacing);
3147 
3155  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
3156 
3161  static wxString FormatLogValue(double n);
3162 
3169  int GetLabelWidth(double value, wxDC &dc, const mpScaleConstraints &constraints);
3170 
3175  static bool UseScientific(double maxAxisValue);
3176 
3182  static int GetSignificantDigits(double step, double maxAxisValue);
3183 
3188  static int GetDecimalDigits(double step);
3189 
3190  private:
3192 };
3193 
3194 
3201 {
3202  public:
3208  mpScaleX(const wxString &name = _T("X"), const int flags = mpALIGN_CENTERX, const bool grids = false, const mpLabelType type = mpLabel_AUTO) :
3209  mpScale(name, flags, grids, type)
3210  {
3211  m_subtype = mpsScaleX;
3212  }
3213 
3215  bool IsTopAxis() const
3216  {
3217  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
3218  }
3219 
3221  bool IsBottomAxis() const
3222  {
3223  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
3224  }
3225 
3226  protected:
3231  static int m_orgy;
3232 
3235  void DoPlot(wxDC &dc, mpWindow &w) override;
3236 
3237  int GetOrigin(mpWindow &w) override;
3238  void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) override;
3239 
3240  private:
3242 
3246  friend mpScaleY;
3247 };
3248 
3256 {
3257  public:
3265  mpScaleY(const wxString &name = _T("Y"), const int flags = mpALIGN_CENTERY, const bool grids = false, const mpOptional_uint yAxisID = std::nullopt, const mpLabelType labelType = mpLabel_AUTO) :
3266  mpScale(name, flags, grids, labelType, yAxisID)
3267  {
3268  m_subtype = mpsScaleY;
3269  m_axisWidth = MP_Y_BORDER_SEPARATION;
3270  m_xPos = 0;
3271  }
3272 
3275  void UpdateAxisWidth(mpWindow &w);
3276 
3278  int GetAxisWidth() const
3279  {
3280  return m_axisWidth;
3281  }
3282 
3284  bool IsLeftAxis() const
3285  {
3286  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
3287  }
3288 
3290  bool IsRightAxis() const
3291  {
3292  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
3293  }
3294 
3296  bool IsInside(const wxCoord xPixel) const
3297  {
3298  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
3299  {
3300  return true;
3301  }
3302  return false;
3303  }
3304 
3305  protected:
3307  int m_xPos;
3308 
3311  void DoPlot(wxDC &dc, mpWindow &w) override;
3312 
3313  int GetOrigin(mpWindow &w) override;
3314  void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int maxLabelWidth) override;
3315 
3316  private:
3318 };
3319 
3320 //-----------------------------------------------------------------------------
3321 // mpWindow
3322 //-----------------------------------------------------------------------------
3323 
3329 #define mpMOUSEMODE_DRAG 0
3330 
3331 #define mpMOUSEMODE_ZOOMBOX 1
3332 
3335 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
3336 typedef std::deque<mpLayer*> mpLayerList;
3337 
3348 {
3349  mpScale* axis = nullptr;
3350  double scale = 1.0;
3351  double pos = 0;
3355 
3356  // Note: we don't use the default operator since we don't want to compare axis pointers
3358  bool operator==(const mpAxisData& other) const
3359  {
3360  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
3361  (bound == other.bound) && (desired == other.desired);
3362  }
3363 };
3364 
3366 typedef std::map<int, mpAxisData> mpAxisList;
3367 
3374 typedef enum {
3375  uXAxis = 1,
3376  uYAxis = 2,
3377  uXYAxis = 3
3378 } mpAxisUpdate;
3379 
3389 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
3390 
3397 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
3398 
3404 {
3405  public:
3406  mpMagnet()
3407  {
3408  m_enable = false;
3409  m_show = false;
3410  }
3411  ~mpMagnet()
3412  {
3413  ;
3414  }
3415 
3417  void UpdateBox(const wxRect &plotArea)
3418  {
3419  m_domain = plotArea;
3420  }
3421 
3423  void Enable(const bool enable)
3424  {
3425  m_enable = enable;
3426  }
3427 
3429  bool IsEnabled() const
3430  {
3431  return m_enable;
3432  }
3433 
3435  void DrawCross(wxDC &dc, mpWindow &w);
3436 
3438  bool ShouldBeShown(const wxPoint mousePos) const
3439  {
3440  return m_enable && m_domain.Contains(mousePos);
3441  }
3442 
3444  void Show(const bool show)
3445  {
3446  m_show = show;
3447  }
3448 
3450  bool IsShown() const
3451  {
3452  return m_show;
3453  }
3454 
3455  private:
3456  bool m_enable;
3457  bool m_show;
3458  wxRect m_domain;
3459 };
3460 
3482 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
3483 {
3484  public:
3485  mpWindow()
3486  {
3487  InitParameters();
3488  }
3489 
3497  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
3498  long flags = 0);
3499 
3500  ~mpWindow() override;
3501 
3505  wxMenu* GetPopupMenu()
3506  {
3507  return &m_popmenu;
3508  }
3509 
3518  bool AddLayer(mpLayer *layer, bool refreshDisplay = true, bool refreshConfig = true);
3519 
3532  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
3533 
3539  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
3540 
3548  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true, bool refreshConfig = true);
3549 
3556  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
3557 
3563  mpLayer* GetLayer(int position);
3564 
3569  int GetLayerPosition(mpLayer* layer);
3570 
3577  mpLayer* GetLayersType(int position, mpLayerType type);
3578 
3585  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
3586 
3592  mpScale* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
3593 
3602  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
3603 
3611  std::optional<mpPlotHit> GetClosestPlot(wxCoord ix, wxCoord iy);
3612 
3617  mpLayer* GetLayerByName(const wxString &name);
3618 
3623  mpLayer* GetLayerByClassName(const wxString &name);
3624 
3628  void RefreshLegend(void);
3629 
3634  bool IsYAxisUsed(int yAxisID);
3635 
3641  bool IsYAxisUsedByFunction(int yAxisID, int *position);
3642 
3646  mpScaleX* GetLayerXAxis() const;
3647 
3651  mpScaleY* GetLayerYAxis(int yAxisID);
3652 
3656  void SetScaleX(const double scaleX)
3657  {
3658  if (MP_ISNOTNULL(scaleX))
3659  {
3660  m_AxisDataX.scale = scaleX;
3661  UpdateDesiredBoundingBox(uXAxis);
3662  }
3663  UpdateAll();
3664  }
3665 
3670  double GetScaleX(void) const
3671  {
3672  return m_AxisDataX.scale;
3673  }
3674 
3679  void SetScaleY(const double scaleY, const int yAxisID)
3680  {
3681  assert(m_AxisDataYList.count(yAxisID) != 0);
3682  if (MP_ISNOTNULL(scaleY))
3683  {
3684  m_AxisDataYList[yAxisID].scale = scaleY;
3685  UpdateDesiredBoundingBox(uYAxis);
3686  }
3687  UpdateAll();
3688  }
3689 
3695  double GetScaleY(const int yAxisID)
3696  {
3697  assert(m_AxisDataYList.count(yAxisID) != 0);
3698  return m_AxisDataYList[yAxisID].scale;
3699  } // Schaling's method: maybe another method exists with the same name
3700 
3701  [[deprecated("Incomplete, use UpdateBBox instead")]]
3704  void SetBound();
3705 
3708  {
3709  return m_AxisDataX.bound;
3710  }
3711 
3714  {
3715  return m_AxisDataX.desired;
3716  }
3717 
3721  mpRange<double> GetBoundY(const int yAxisID)
3722  {
3723  assert(m_AxisDataYList.count(yAxisID) != 0);
3724  return m_AxisDataYList[yAxisID].bound;
3725  }
3726 
3731  {
3732  assert(m_AxisDataYList.count(yAxisID) != 0);
3733  return m_AxisDataYList[yAxisID].desired;
3734  }
3735 
3740  std::unordered_map<int, mpRange<double>> GetAllBoundY()
3741  {
3742  std::unordered_map<int, mpRange<double>> yRange;
3743  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
3744  {
3745  yRange[m_yID] = m_yData.bound;
3746  }
3747  return yRange;
3748  }
3749 
3754  std::unordered_map<int, mpRange<double>> GetAllDesiredY()
3755  {
3756  std::unordered_map<int, mpRange<double>> yRange;
3757  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
3758  {
3759  yRange[m_yID] = m_yData.desired;
3760  }
3761  return yRange;
3762  }
3763 
3767  void SetPosX(const double posX)
3768  {
3769  m_AxisDataX.pos = posX;
3770  UpdateDesiredBoundingBox(uXAxis);
3771  UpdateAll();
3772  }
3773 
3778  double GetPosX(void) const
3779  {
3780  return m_AxisDataX.pos;
3781  }
3782 
3787  void SetPosY(std::unordered_map<int, double>& posYList)
3788  {
3789  for (auto& [m_yID, m_yData] : m_AxisDataYList)
3790  {
3791  m_yData.pos = posYList[m_yID];
3792  }
3793  UpdateDesiredBoundingBox(uYAxis);
3794  UpdateAll();
3795  }
3796 
3802  double GetPosY(const int yAxisID)
3803  {
3804  assert(m_AxisDataYList.count(yAxisID) != 0);
3805  return m_AxisDataYList[yAxisID].pos;
3806  }
3807 
3811  int GetNOfYAxis(void) const
3812  {
3813  return (int)m_AxisDataYList.size();
3814  }
3815 
3819  mpAxisList GetAxisDataYList(void) const
3820  {
3821  return m_AxisDataYList;
3822  }
3823 
3829  void SetScreen(const int scrX, const int scrY)
3830  {
3831  m_scrX = scrX;
3832  m_scrY = scrY;
3833  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3834  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3835 
3836  m_plotBoundaries.endPx = m_scrX;
3837  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3838  m_plotBoundaries.endPy = m_scrY;
3839  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3840 
3841  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3842  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3843 
3844  m_magnet.UpdateBox(m_PlotArea);
3845  }
3846 
3853  int GetScreenX(void) const
3854  {
3855  return m_scrX;
3856  }
3857 
3864  int GetScreenY(void) const
3865  {
3866  return m_scrY;
3867  }
3868 
3874  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3875  {
3876  m_AxisDataX.pos = posX;
3877  SetPosY(posYList);
3878  }
3879 
3883  double p2x(const wxCoord pixelCoordX) const
3884  {
3885  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3886  }
3887 
3891  double p2y(const wxCoord pixelCoordY, const int yAxisID = 0)
3892  {
3893  assert(m_AxisDataYList.count(yAxisID) != 0);
3894  if (m_AxisDataYList.count(yAxisID) == 0)
3895  return 0.0;
3896  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3897  }
3898 
3902  wxCoord x2p(const double x) const
3903  {
3904  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3905  }
3906 
3910  wxCoord y2p(const double y, const int yAxisID = 0)
3911  {
3912  assert(m_AxisDataYList.count(yAxisID) != 0);
3913  if (m_AxisDataYList.count(yAxisID) == 0)
3914  return 0;
3915  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3916  }
3917 
3919  [[deprecated("Deprecated - use EnableBufferedPaintDC??")]]
3920  void EnableDoubleBuffer(const bool enabled)
3921  {
3922  EnableBufferedPaintDC(enabled);
3923  }
3924 
3928  void EnableBufferedPaintDC(const bool enabled)
3929  {
3930  m_enableBufferedPaintDC = enabled;
3931  }
3932 
3935  void EnableMousePanZoom(const bool enabled)
3936  {
3937  m_enableMouseNavigation = enabled;
3938  }
3939 
3945  void LockAspect(bool enable = true);
3946 
3951  bool IsAspectLocked() const
3952  {
3953  return m_lockaspect;
3954  }
3955 
3960  void Fit() override;
3961 
3968  void Fit(const mpRange<double> &rangeX, std::unordered_map<int, mpRange<double>> rangeY, bool updateDesired = true, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3969 
3973  void FitX(void);
3974 
3979  void FitY(int yAxisID);
3980 
3985  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
3986 
3991  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
3992 
3994  void ZoomInX();
3995 
3997  void ZoomOutX();
3998 
4001  void ZoomInY(mpOptional_int yAxisID = std::nullopt);
4002 
4005  void ZoomOutY(mpOptional_int yAxisID = std::nullopt);
4006 
4011  void ZoomRect(wxPoint p0, wxPoint p1);
4012 
4014  void UpdateAll();
4015 
4016  // Added methods by Davide Rondini
4017 
4021  unsigned int CountLayers();
4022 
4025  unsigned int CountAllLayers() const
4026  {
4027  return (unsigned int)m_layers.size();
4028  }
4029 
4033  unsigned int CountLayersType(mpLayerType type);
4034 
4038  unsigned int CountLayersFXYPlot();
4039 
4047  {
4048  // Change on X axis
4049  if (update & uXAxis)
4050  {
4051  m_AxisDataX.desired.Set(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale),
4052  m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
4053  }
4054 
4055  // Change on Y axis
4056  if (update & uYAxis)
4057  {
4058  for (auto& [yID, yData] : m_AxisDataYList)
4059  {
4060  yData.desired.Set(yData.pos - ((m_margin.top + m_plotHeight) / yData.scale),
4061  yData.pos - (m_margin.top / yData.scale));
4062  }
4063  }
4064  }
4065 
4071  mpFloatRectSimple GetBoundingBox(const bool desired, const unsigned int yAxisID = 0)
4072  {
4073  assert(m_AxisDataYList.count(yAxisID) != 0);
4074  if (desired)
4075  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
4076  else
4077  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
4078  }
4079 
4085  bool GetBoundingBox(mpRange<double> *boundX, mpRange<double> *boundY, const int yAxisID)
4086  {
4087  if (m_AxisDataYList.count(yAxisID) == 0)
4088  return false;
4089  *boundX = m_AxisDataX.bound;
4090  *boundY = m_AxisDataYList[yAxisID].bound;
4091  return true;
4092  }
4093 
4099  bool PointIsInsideBound(const double px, const double py, const int yAxisID)
4100  {
4101  if (m_AxisDataYList.count(yAxisID) == 0)
4102  return false;
4103 
4104  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
4105  }
4106 
4112  void UpdateBoundingBoxToInclude(const double px, const double py, const int yAxisID)
4113  {
4114  if (m_AxisDataYList.count(yAxisID) == 0)
4115  return ;
4116 
4117  m_AxisDataX.bound.Update(px);
4118  m_AxisDataYList[yAxisID].bound.Update(py);
4119  }
4120 
4121  /* Initialize bounding box with an initial point
4122  * @param px point on x-axis
4123  * @param py point on y-axis
4124  * @param yAxisID the y-axis ID
4125  */
4127  void InitializeBoundingBox(const double px, const double py, const int yAxisID)
4128  {
4129  if (m_AxisDataYList.count(yAxisID) == 0)
4130  return ;
4131 
4132  m_AxisDataX.bound.Set(px, px);
4133  m_AxisDataYList[yAxisID].bound.Set(py, py);
4134  }
4135 
4138  void SetMPScrollbars(bool status);
4139 
4142  bool GetMPScrollbars() const
4143  {
4144  return m_enableScrollBars;
4145  }
4146 
4152  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
4153 
4157  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4158 
4162  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4163 
4167  void SetWildcard(const wxString &wildcard)
4168  {
4169  m_wildcard = wildcard;
4170  }
4171 
4175  const wxString& GetWildcard(void) const
4176  {
4177  return m_wildcard;
4178  }
4179 
4187  bool LoadFile(const wxString &filename = wxEmptyString);
4188 
4193  void SetDefaultDir(const wxString &dirname)
4194  {
4195  m_DefaultDir = dirname;
4196  }
4197 
4201 
4206 
4212  static void SetDefaultLegendIsAlwaysVisible(const bool visible)
4213  {
4214  m_DefaultLegendIsAlwaysVisible = visible;
4215  }
4216 
4221 
4222 
4227  void SetAutoFit(const bool autoFit)
4228  {
4229  m_autoFit = autoFit;
4230  }
4231 
4238  void SetMargins(int top, int right, int bottom, int left);
4239 
4242  {
4243  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4244  }
4245 
4247  void SetMarginTop(const int top)
4248  {
4249  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4250  }
4251 
4255  int GetMarginTop(const bool minusExtra = false) const
4256  {
4257  if (minusExtra)
4258  return m_margin.top - m_extraMargin;
4259  else
4260  return m_margin.top;
4261  }
4262 
4264  void SetMarginRight(const int right)
4265  {
4266  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
4267  }
4268 
4272  int GetMarginRight(const bool minusExtra = false) const
4273  {
4274  if (minusExtra)
4275  return m_margin.right - m_extraMargin;
4276  else
4277  return m_margin.right;
4278  }
4279 
4282  {
4283  return m_marginOuter.right;
4284  }
4285 
4287  void SetMarginBottom(const int bottom)
4288  {
4289  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
4290  }
4291 
4295  int GetMarginBottom(const bool minusExtra = false) const
4296  {
4297  if (minusExtra)
4298  return m_margin.bottom - m_extraMargin;
4299  else
4300  return m_margin.bottom;
4301  }
4302 
4304  void SetMarginLeft(const int left)
4305  {
4306  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
4307  }
4308 
4312  int GetMarginLeft(const bool minusExtra = false) const
4313  {
4314  if (minusExtra)
4315  return m_margin.left - m_extraMargin;
4316  else
4317  return m_margin.left;
4318  }
4319 
4321  void SetExtraMargin(const int extra)
4322  {
4323  m_extraMargin = extra;
4324  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4325  }
4326 
4328  int GetExtraMargin() const
4329  {
4330  return m_extraMargin;
4331  }
4332 
4335  {
4336  return m_marginOuter.left;
4337  }
4338 
4340  int GetPlotWidth() const
4341  {
4342  return m_plotWidth;
4343  }
4344 
4346  int GetPlotHeight() const
4347  {
4348  return m_plotHeight;
4349  }
4350 
4355  mpRect GetPlotBoundaries(const bool with_margin) const
4356  {
4357  mpRect bond;
4358  if (with_margin)
4359  bond = m_plotBoundariesMargin;
4360  else
4361  bond = m_plotBoundaries;
4362  bond.startPx -= m_extraMargin;
4363  bond.endPx += m_extraMargin;
4364  bond.startPy -= m_extraMargin;
4365  bond.endPy += m_extraMargin;
4366  return bond;
4367  }
4368 
4372  int GetLeftYAxesWidth(mpOptional_int yAxisID = std::nullopt);
4373 
4377  int GetRightYAxesWidth(mpOptional_int yAxisID = std::nullopt);
4378 
4380  void SetDrawBox(const bool drawbox)
4381  {
4382  m_drawBox = drawbox;
4383  }
4384 
4386  bool GetDrawBox() const
4387  {
4388  return m_drawBox;
4389  }
4390 
4394  mpOptional_int IsInsideYAxis(const wxPoint &point);
4395 
4399  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
4400 
4404  void SetLayerVisible(const wxString &name, bool viewable);
4405 
4409  bool IsLayerVisible(const wxString &name);
4410 
4414  bool IsLayerVisible(const unsigned int position);
4415 
4419  void SetLayerVisible(const unsigned int position, bool viewable);
4420 
4425  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
4426 
4429  const wxColour& GetAxesColour() const
4430  {
4431  return m_axColour;
4432  }
4433 
4435  const wxColour& GetbgColour() const
4436  {
4437  return m_bgColour;
4438  }
4439 
4441  void SetbgColour(const wxColour &colour)
4442  {
4443  m_bgColour = colour;
4444  }
4445 
4451  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
4452  {
4453  m_OnDeleteLayer = event;
4454  }
4455 
4458  {
4459  m_OnDeleteLayer = NULL;
4460  }
4461 
4466  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
4467  {
4468  m_OnUserMouseAction = userMouseEventHandler;
4469  }
4470 
4473  {
4474  m_OnUserMouseAction = NULL;
4475  }
4476 
4482  bool IsLogXaxis() const
4483  {
4484  if (m_AxisDataX.axis)
4485  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
4486  else
4487  return false;
4488  }
4489 
4494  bool IsLogYaxis(const int yAxisID)
4495  {
4496  assert(m_AxisDataYList.count(yAxisID) != 0);
4497  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4498  if (yAxis)
4499  return yAxis->IsLogAxis();
4500  else
4501  return false;
4502  }
4503 
4508  void SetLogXaxis(const bool log)
4509  {
4510  if (m_AxisDataX.axis)
4511  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
4512  }
4513 
4519  void SetLogYaxis(const int yAxisID, const bool log)
4520  {
4521  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4522  if (yAxis)
4523  yAxis->SetLogAxis(log);
4524  }
4525 
4530  bool GetMagnetize() const
4531  {
4532  return m_magnet.IsEnabled();
4533  }
4534 
4536  void SetMagnetize(const bool mag)
4537  {
4538  m_magnet.Enable(mag);
4539  }
4540 
4546  {
4547  m_mouseLeftDownAction = action;
4548  }
4549 
4555  {
4556  return m_mouseLeftDownAction;
4557  }
4558 
4563  wxPoint GetMousePosition() const
4564  {
4565  return m_mousePos;
4566  }
4567 
4573  {
4574  return m_movingInfoLayer;
4575  }
4576 
4577 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4578 
4582  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
4583 #endif // MP_ENABLE_CONFIG
4584 
4591  void RefreshConfigWindow(mpLayerType layerType, int param = 0);
4592 
4599  void OpenConfigWindow(mpLayerType layerType = mpLAYER_UNDEF, int param = 0);
4600 
4604  void DeleteConfigWindow(void);
4605 
4610  void Paint(wxDC& dc);
4611 
4616  void RenderOverlays(wxDC& dc);
4617 
4623  wxMemoryDC *GetMemoryDC(void)
4624  {
4625  m_buff_dc.SelectObject(m_buff_bmp);
4626  return &m_buff_dc;
4627  }
4628 
4629  protected:
4630  virtual void BindEvents(void);
4631  virtual void OnPaint(wxPaintEvent &event);
4632  virtual void OnSize(wxSizeEvent &event);
4633  virtual void OnShowPopupMenu(wxMouseEvent &event);
4634  virtual void OnCenter(wxCommandEvent &event);
4635  virtual void OnFit(wxCommandEvent &event);
4636  virtual void OnToggleGrids(wxCommandEvent &event);
4637  virtual void OnToggleCoords(wxCommandEvent &event);
4638  virtual void OnScreenShot(wxCommandEvent &event);
4639  virtual void OnFullScreen(wxCommandEvent &event);
4640 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4641  virtual void OnConfiguration(wxCommandEvent &event);
4642 #endif // MP_ENABLE_CONFIG
4643  virtual void OnLoadFile(wxCommandEvent &event);
4644  virtual void OnZoomIn(wxCommandEvent &event);
4645  virtual void OnZoomOut(wxCommandEvent &event);
4646  virtual void OnLockAspect(wxCommandEvent &event);
4647  virtual void OnMouseHelp(wxCommandEvent &event);
4648  virtual void OnMouseLeftDown(wxMouseEvent &event);
4649  virtual void OnMouseRightDown(wxMouseEvent &event);
4650  virtual void OnMouseMove(wxMouseEvent &event);
4651  virtual void OnMouseLeftRelease(wxMouseEvent &event);
4652  virtual void OnMouseWheel(wxMouseEvent &event);
4653  virtual void OnMouseLeave(wxMouseEvent &event);
4654  bool CheckUserMouseAction(wxMouseEvent &event);
4655  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
4656  virtual void OnScrollPageUp(wxScrollWinEvent &event);
4657  virtual void OnScrollPageDown(wxScrollWinEvent &event);
4658  virtual void OnScrollLineUp(wxScrollWinEvent &event);
4659  virtual void OnScrollLineDown(wxScrollWinEvent &event);
4660  virtual void OnScrollTop(wxScrollWinEvent &event);
4661  virtual void OnScrollBottom(wxScrollWinEvent &event);
4662 
4664  void DoScrollCalc(const int position, const int orientation);
4665 
4670  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = MP_ZOOM_AROUND_CENTER);
4671 
4678  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = MP_ZOOM_AROUND_CENTER, mpOptional_int yAxisID = std::nullopt);
4679 
4684  void SetScaleXAndCenter(double scaleX);
4685 
4691  void SetScaleYAndCenter(double scaleY, int yAxisID);
4692 
4697  void Zoom(bool zoomIn, const wxPoint &centerPoint);
4698 
4701  virtual bool UpdateBBox();
4702 
4706  void DrawBoxZoom(wxDC& dc);
4707 
4711  void InitParameters();
4712 
4713  wxTopLevelWindow* m_parent;
4715 
4716  mpLayerList m_layers;
4718  mpAxisList m_AxisDataYList;
4719 
4720  wxMenu m_popmenu;
4722  wxColour m_bgColour;
4723  wxColour m_fgColour;
4724  wxColour m_axColour;
4725  bool m_drawBox;
4726 
4727  int m_scrX;
4728  int m_scrY;
4731 
4735  wxCoord m_plotWidth;
4736  wxCoord m_plotHeight;
4737 
4740  wxRect m_PlotArea;
4741 
4744  wxBitmap m_buff_bmp;
4745  wxMemoryDC m_buff_dc;
4751  wxPoint m_mousePos;
4752  wxPoint m_mouseRClick;
4753  wxPoint m_mouseLClick;
4754  double m_mouseScaleX;
4755  std::unordered_map<int, double> m_mouseScaleYList;
4758  bool m_autoFit;
4762 
4764 
4766 
4767  wxBitmap* m_Screenshot_bmp;
4768 
4769  wxString m_wildcard;
4770  wxString m_DefaultDir;
4771 
4772 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4773  MathPlotConfigDialog* m_configWindow = NULL;
4774 #endif // MP_ENABLE_CONFIG
4775  bool m_openConfigWindowPending = false;
4777 
4778  mpOnDeleteLayer m_OnDeleteLayer = NULL;
4779  mpOnUserMouseAction m_OnUserMouseAction = NULL;
4780 
4784  virtual void DesiredBoundsHaveChanged() {};
4785 
4786  private:
4788  void CheckAndReportDesiredBoundsChanges();
4789 
4794  unsigned int GetNewAxisDataID(void)
4795  {
4796  int newID = 0;
4797  for (const auto& [m_yID, m_yData] : m_AxisDataYList)
4798  {
4799  if(m_yData.axis)
4800  {
4801  // This ID is used by an axis. Make sure the new ID is larger
4802  newID = std::max(newID, m_yID + 1);
4803  }
4804  }
4805  return newID;
4806  }
4807 
4809 
4810  // To have direct access to m_Screenshot_dc
4811  friend mpPrintout;
4812 };
4813 
4814 //-----------------------------------------------------------------------------
4815 // mpText - provided by Val Greene
4816 //-----------------------------------------------------------------------------
4817 
4826 {
4827  public:
4830  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
4831  {
4832  m_subtype = mptText;
4833  SetName(name);
4834  m_offsetx = 5;
4835  m_offsety = 50;
4836  m_location = mpMarginUser;
4837  m_ZIndex = mpZIndex_TEXT;
4838  }
4839 
4843  mpText(const wxString &name, int offsetx, int offsety);
4844 
4848  mpText(const wxString &name, mpLocation marginLocation);
4849 
4852  bool HasBBox() override
4853  {
4854  return false;
4855  }
4856 
4859  void SetLocation(const mpLocation location)
4860  {
4861  m_location = location;
4862  }
4863 
4866  mpLocation GetLocation() const
4867  {
4868  return m_location;
4869  }
4870 
4873  void SetOffset(const int offX, const int offY)
4874  {
4875  m_offsetx = offX;
4876  m_offsety = offY;
4877  }
4878 
4880  void GetOffset(int *offX, int *offY) const
4881  {
4882  *offX = m_offsetx;
4883  *offY = m_offsety;
4884  }
4885 
4886  protected:
4889  mpLocation m_location;
4890 
4893  void DoPlot(wxDC &dc, mpWindow &w) override;
4894 
4895  private:
4897 };
4898 
4903 {
4904  public:
4907  mpTitle();
4908 
4911  mpTitle(const wxString &name) :
4912  mpText(name, mpMarginTopCenter)
4913  {
4914  m_subtype = mptTitle;
4915  SetPen(*wxWHITE_PEN);
4916  SetBrush(*wxWHITE_BRUSH);
4917  }
4918 
4919  private:
4921 };
4922 
4923 //-----------------------------------------------------------------------------
4924 // mpPrintout - provided by Davide Rondini
4925 //-----------------------------------------------------------------------------
4926 
4931 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4932 {
4933  public:
4934  mpPrintout()
4935  {
4936  plotWindow = NULL;
4937  drawn = false;
4938  stretch_factor = 2;
4939  }
4940 
4946  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4947  ~mpPrintout() override
4948  {
4949  ;
4950  }
4951 
4955  void SetDrawState(const bool drawState)
4956  {
4957  drawn = drawState;
4958  }
4959 
4961  bool OnPrintPage(int page) override;
4963  bool HasPage(int page) override;
4964 
4967  void SetFactor(const int factor)
4968  {
4969  stretch_factor = factor;
4970  }
4971 
4972  private:
4973  bool drawn;
4974  mpWindow* plotWindow;
4975  int stretch_factor; // To reduce the size of plot
4976 
4978 };
4979 
4980 //-----------------------------------------------------------------------------
4981 // mpMovableObject - provided by Jose Luis Blanco
4982 //-----------------------------------------------------------------------------
4991 {
4992  public:
4996  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
4997  {
4998  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
4999  m_subtype = mpfMovable;
5000  }
5001 
5002  ~mpMovableObject() override {}
5003 
5006  void GetCoordinateBase(double &x, double &y, double &phi) const
5007  {
5008  x = m_reference_x;
5009  y = m_reference_y;
5010  phi = m_reference_phi;
5011  }
5012 
5015  void SetCoordinateBase(const double x, const double y, const double phi = 0)
5016  {
5017  m_reference_x = x;
5018  m_reference_y = y;
5019  m_reference_phi = phi;
5020  m_flags = mpALIGN_SW;
5021  ShapeUpdated();
5022  }
5023 
5024  bool HasBBox() override
5025  {
5026  return m_trans_shape_xs.size() != 0;
5027  }
5028 
5031  double GetMinX() override
5032  {
5033  return m_bbox_x.min;
5034  }
5035 
5038  double GetMaxX() override
5039  {
5040  return m_bbox_x.max;
5041  }
5042 
5045  double GetMinY() override
5046  {
5047  return m_bbox_y.min;
5048  }
5049 
5052  double GetMaxY() override
5053  {
5054  return m_bbox_y.max;
5055  }
5056 
5057  protected:
5058 
5061  double m_reference_x;
5062  double m_reference_y;
5064 
5065  void DoPlot(wxDC &dc, mpWindow &w) override;
5066 
5069  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
5070 
5071  // the object points, in local coordinates (to be transformed by the current transformation).
5072  std::vector<double> m_shape_xs;
5073  std::vector<double> m_shape_ys;
5074 
5075  // The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh).
5076  std::vector<double> m_trans_shape_xs;
5077  std::vector<double> m_trans_shape_ys;
5078 
5084 
5088  void ShapeUpdated();
5089 
5090  private:
5092 };
5093 
5094 //-----------------------------------------------------------------------------
5095 // mpCovarianceEllipse - provided by Jose Luis Blanco
5096 //-----------------------------------------------------------------------------
5109 {
5110  public:
5114  mpCovarianceEllipse(const double cov_00 = 1, const double cov_11 = 1, const double cov_01 = 0, const double quantiles = 2, const int segments = 32,
5115  const wxString &layerName = _T("")) : mpMovableObject(),
5116  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
5117  {
5118  m_continuous = true;
5119  m_name = layerName;
5120  RecalculateShape();
5121  }
5122 
5123  ~mpCovarianceEllipse() override
5124  {
5125  ;
5126  }
5127 
5130  double GetQuantiles() const
5131  {
5132  return m_quantiles;
5133  }
5134 
5137  void SetQuantiles(const double q)
5138  {
5139  m_quantiles = q;
5140  RecalculateShape();
5141  }
5142 
5144  void SetSegments(const int segments)
5145  {
5146  m_segments = segments;
5147  }
5148 
5150  int GetSegments() const
5151  {
5152  return m_segments;
5153  }
5154 
5157  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
5158  {
5159  cov_00 = m_cov_00;
5160  cov_01 = m_cov_01;
5161  cov_11 = m_cov_11;
5162  }
5163 
5166  void SetCovarianceMatrix(const double cov_00, const double cov_01, const double cov_11)
5167  {
5168  m_cov_00 = cov_00;
5169  m_cov_01 = cov_01;
5170  m_cov_11 = cov_11;
5171  RecalculateShape();
5172  }
5173 
5174  protected:
5177  double m_cov_00;
5178  double m_cov_11;
5179  double m_cov_01;
5180  double m_quantiles;
5181 
5185 
5188  void RecalculateShape();
5189 
5190  private:
5192 };
5193 
5194 //-----------------------------------------------------------------------------
5195 // mpPolygon - provided by Jose Luis Blanco
5196 //-----------------------------------------------------------------------------
5202 {
5203  public:
5206  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
5207  {
5208  m_continuous = true;
5209  m_name = layerName;
5210  }
5211 
5212  ~mpPolygon() override
5213  {
5214  ;
5215  }
5216 
5222  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
5223 
5224  private:
5226 };
5227 
5228 //-----------------------------------------------------------------------------
5229 // mpBitmapLayer - provided by Jose Luis Blanco
5230 //-----------------------------------------------------------------------------
5236 {
5237  public:
5241  {
5242  m_validImg = false;
5243  m_bitmapChanged = false;
5244  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
5245  }
5246 
5247  ~mpBitmapLayer() override
5248  {
5249  ;
5250  }
5251 
5254  void GetBitmapCopy(wxImage &outBmp) const;
5255 
5263  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
5264 
5267  double GetMinX() override
5268  {
5269  return m_bitmapX.min;
5270  }
5271 
5274  double GetMaxX() override
5275  {
5276  return m_bitmapX.max;
5277  }
5278 
5281  double GetMinY() override
5282  {
5283  return m_bitmapY.min;
5284  }
5285 
5288  double GetMaxY() override
5289  {
5290  return m_bitmapY.max;
5291  }
5292 
5293  protected:
5294 
5297  wxImage m_bitmap;
5298  wxBitmap m_scaledBitmap;
5301  bool m_validImg;
5303 
5308 
5309  void DoPlot(wxDC &dc, mpWindow &w) override;
5310 
5311  private:
5313 };
5314 
5315 // utility class
5316 
5318 typedef enum __mp_Colour
5319 {
5320  mpBlue,
5321  mpRed,
5322  mpGreen,
5323  mpPurple,
5324  mpYellow,
5325  mpFuchsia,
5326  mpLime,
5327  mpAqua,
5328  mpOlive
5329 } mpColour;
5330 
5335 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
5336 {
5337  public:
5342  wxIndexColour(const unsigned int id)
5343  {
5344 #ifdef _WIN32
5345  auto GetRandomColor = []() {
5346  return (rand() * 255) / RAND_MAX;
5347  };
5348 #else
5349  auto GetRandomColor = []() {
5350  return (random() * 255) / RAND_MAX;
5351  };
5352 #endif
5353  switch (id)
5354  {
5355  case 0:
5356  this->Set(0, 0, 255);
5357  break; // Blue
5358  case 1:
5359  this->Set(255, 0, 0);
5360  break; // Red
5361  case 2:
5362  this->Set(0, 128, 0);
5363  break; // Green
5364  case 3:
5365  this->Set(128, 0, 128);
5366  break; // Purple
5367  case 4:
5368  this->Set(255, 255, 0);
5369  break; // Yellow
5370  case 5:
5371  this->Set(255, 0, 255);
5372  break; // Fuchsia
5373  case 6:
5374  this->Set(0, 255, 0);
5375  break; // Lime
5376  case 7:
5377  this->Set(0, 255, 255);
5378  break; // Aqua/Cyan
5379  case 8:
5380  this->Set(128, 128, 0);
5381  break; // Olive
5382  default:
5383  this->Set((ChannelType) (GetRandomColor()), (ChannelType) (GetRandomColor()), (ChannelType) (GetRandomColor()));
5384  }
5385  }
5386 };
5387 
5390 // ---------------------------------------------------------------------
5391 #if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
5392  }// namespace MathPlot
5393 #endif // MP_ENABLE_NAMESPACE
5394 
5395 #endif // MATHPLOT_H_INCLUDED
T Length(void) const
Length of the range.
Definition: mathplot.h:394
sub type for mpFXYVector function
Definition: mathplot.h:732
int GetMarginLeft(const bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:4312
mpRange< double > lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:3354
mpMouseButtonAction GetMouseLeftDownAction() const
Returns the type of action for the left mouse button.
Definition: mathplot.h:4554
int GetAxisWidth() const
Get the reserved width of the Y axis in pixels.
Definition: mathplot.h:3278
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:4887
bool GetLegendIsAlwaysVisible() const
Get the visibility of the legend.
Definition: mathplot.h:1843
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2803
mpScaleX(const wxString &name=_T("X"), const int flags=mpALIGN_CENTERX, const bool grids=false, const mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:3208
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer.
Definition: mathplot.h:3389
void SetDrawState(const bool drawState)
Set whether the plot has already been drawn on the current printout.
Definition: mathplot.h:4955
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:634
sub type for mpText layer
Definition: mathplot.h:721
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:4142
Align the plot label towards the southeast.
Definition: mathplot.h:673
mpScaleY(const wxString &name=_T("Y"), const int flags=mpALIGN_CENTERY, const bool grids=false, const mpOptional_uint yAxisID=std::nullopt, const mpLabelType labelType=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:3265
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:860
Draw a circle.
Definition: mathplot.h:696
enum __YAxis_Align_Type mpYAxis_Align
Alignment for Y axis.
void SetCoordinateBase(const double x, const double y, const double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:5015
Show legend items with small square with the same color of referred mpLayer.
Definition: mathplot.h:681
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:226
bool IsTopAxis() const
Return true when this X axis is aligned at the top edge or top border.
Definition: mathplot.h:3215
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:3505
mpRange< double > GetBoundY(const int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3721
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:4755
wxMemoryDC m_buff_dc
DC for double buffering.
Definition: mathplot.h:4745
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:4451
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3829
bool GetMagnetize() const
Is mouse magnetization enabled? Useful to read the position on the axes.
Definition: mathplot.h:4530
enum __mp_Colour mpColour
Enumeration of classic colour.
Bitmap type layer.
Definition: mathplot.h:811
bool IsDraggedSeriesShown() const
Get shown status of dragged series.
Definition: mathplot.h:1538
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1182
void SetExtraMargin(const int extra)
Set the extra margin.
Definition: mathplot.h:4321
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:4740
__Scale_Type
sub_type values for mpLAYER_AXIS
Definition: mathplot.h:739
T GetMaxAbs(void) const
Max absolute value of the range.
Definition: mathplot.h:406
Plot type layer.
Definition: mathplot.h:796
~mpInfoCoords() override
Default destructor.
Definition: mathplot.h:1363
abstract Layer for chart (bar and pie).
Definition: mathplot.h:2625
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1181
bool m_enableScrollBars
Enable scrollbar in plot window (default false)
Definition: mathplot.h:4757
double m_lastX
Last x-coordinate point added.
Definition: mathplot.h:2355
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1171
bool IsShown() const
Get shown status.
Definition: mathplot.h:1395
User defined position. Can be change by mouse drag.
Definition: mathplot.h:644
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1178
wxBitmap m_scaledBitmap
Cached scaled bitmap used for drawing.
Definition: mathplot.h:5298
std::map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:3366
mpFXGeneric(const wxString &name=wxT("Generic FX function"), const int flags=mpALIGN_LEFT, const unsigned int yAxisID=0)
Definition: mathplot.h:2481
#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:1456
__Symbol_Type
Displaying a symbol instead of a point in the plot function.
Definition: mathplot.h:693
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:680
__mp_Layer_Type
Major type of an mpLayer (detail is in subtype)
Definition: mathplot.h:792
std::unordered_map< int, mpRange< double > > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:3754
Show/Hide grids.
Definition: mathplot.h:622
VerticalCursorMode GetVerticalCursorMode() const
Get the current vertical cursor mode.
Definition: mathplot.h:1604
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:990
bool m_autoStep
Calculates m_step automatically based on how many points you want to draw.
Definition: mathplot.h:1885
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:3132
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1173
mpLabelType
enum for label for grid
Definition: mathplot.h:764
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:5024
int GetAxisID(void) const
Return the ID of the Axis.
Definition: mathplot.h:2885
mpNormal(const double mu, const double sigma)
Classic Normal distribution.
Definition: mathplot.h:2590
mpRange< double > GetDesiredBoundY(const int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3730
void SetCoordIsAlwaysVisible(const bool alwaysVisible)
Set the visibility of the mouse coordinates in the info coordinates despite the visibility of the axi...
Definition: mathplot.h:3087
std::vector< std::string > labels
Labels of the Values.
Definition: mathplot.h:2663
mpLegendStyle GetItemMode() const
Get the current legend item drawing mode.
Definition: mathplot.h:1504
bool PointIsInsideBound(const double px, const double py, const int yAxisID)
Is the given point inside the current bounding box for the selected Y axis?
Definition: mathplot.h:4099
bool HasBBox() override
mpInfoLayer has not bounding box.
Definition: mathplot.h:1254
void SetScaleY(const double scaleY, const int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:3679
const wxRect & GetRectangle() const
Get the current rectangle coordinates.
Definition: mathplot.h:1301
static void SetDefaultLegendIsAlwaysVisible(const bool visible)
Set if legend is always visible even if series is not plotted.
Definition: mathplot.h:4212
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:4729
mpRange< double > GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:3707
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:3787
double m_const
Const factor.
Definition: mathplot.h:2603
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:794
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:827
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:3123
sub type not defined (should be never used)
Definition: mathplot.h:741
double m_lastY
Last y-coordinate point added.
Definition: mathplot.h:2357
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:3670
double ComputeY(const double x) override
The main computation of the FX function.
Definition: mathplot.h:2605
void SetScale(const mpRange< double > range)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3047
bool m_CoordIsAlwaysVisible
If true, the mouse coordinates is visible in the info coordinates despite the visibility of the axis...
Definition: mathplot.h:3134
VerticalCursorMode
Enumeration for vertical cursor mode, which determines how the vertical cursor is positioned for seri...
Definition: mathplot.h:1596
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:4334
mpRange< double > GetScale() const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3055
Lock x/y scaling aspect.
Definition: mathplot.h:621
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:4732
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2602
void SetNeedUpdate()
Mark the legend bitmap as needing regeneration.
Definition: mathplot.h:1524
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:2351
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:1030
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:642
std::vector< double > m_trans_shape_ys
Transformed shape vertices in Y coordinates.
Definition: mathplot.h:5077
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:4466
wxBitmap m_buff_bmp
Bmp for double buffering.
Definition: mathplot.h:4744
Info box type layer.
Definition: mathplot.h:816
bool m_boxZoomActive
Indicate if box zoom is active.
Definition: mathplot.h:4763
~mpPieChart() override
Destructor.
Definition: mathplot.h:2757
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:5235
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:1006
virtual bool IsLayerType(const mpLayerType typeOfInterest, int *subtype)
Set the layer&#39;s subtype in caller variable, and return true if the layer is of type "typeOfInterest"...
Definition: mathplot.h:898
void SetYAxisID(const unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1827
wxString m_DefaultDir
The default directory for wxFileDialog.
Definition: mathplot.h:4770
void SetMinScale(const double min)
Set the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2996
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:2015
std::vector< wxColor > m_seriesColors
Colors of the series in the order they were added to the mpWindow.
Definition: mathplot.h:1462
double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:5288
#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:1987
void Enable(const bool enable)
Enables the magnet.
Definition: mathplot.h:3423
mpRange< double > m_bbox_y
Range of bounding box on y direction.
Definition: mathplot.h:5083
enum __Info_Type mpInfoType
sub_type values for mpLAYER_INFO
mpRect GetPlotBoundaries(const bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:4355
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:4748
void SetHovering(const bool hover)
Set if axis shall be highlighted when a series is dragged over it.
Definition: mathplot.h:3063
void ErasePlot(wxDC &, mpWindow &) override
Just delete the bitmap of the info.
Definition: mathplot.h:1384
const wxColour & GetbgColour() const
Get the plot background colour.
Definition: mathplot.h:4435
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:5184
Chart type layer (bar chart)
Definition: mathplot.h:801
int GetMarginBottom(const bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:4295
void SetDrawBox(const bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:4380
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:4346
sub type for mpLine function
Definition: mathplot.h:734
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1800
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1198
void SetDefaultDir(const wxString &dirname)
Set the default directory for wxFileDialog.
Definition: mathplot.h:4193
Draw a cross X.
Definition: mathplot.h:700
double m_max_value
Max value of the values vector.
Definition: mathplot.h:2665
void SetItemDirection(const mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1511
Draw a triangle up oriented.
Definition: mathplot.h:698
infoCoordType m_infoCoordType
Type of info coordinates to be displayed (axis, closest series, or all series).
Definition: mathplot.h:1461
void SetAuto(const bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2980
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1818
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2443
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:4281
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:2656
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:3883
wxSize GetSize() const
Get the size of the box (in pixels)
Definition: mathplot.h:1294
wxPoint m_mousePos
Current mouse position in window.
Definition: mathplot.h:4751
void SetMaxScale(const double max)
Set the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3012
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3935
double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:2381
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:4734
unsigned int CountAllLayers() const
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:4025
Mouse action drag the plot.
Definition: mathplot.h:760
bool IsLeftAxis() const
Return true if this Y axis is aligned to the left side.
Definition: mathplot.h:3284
void SetFont(const wxFont &font)
Set layer font.
Definition: mathplot.h:998
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1881
double GetValue() const
Get the x or y coordinates of the line.
Definition: mathplot.h:1914
void SetAutoStep(const bool enable)
Enables auto step which is used to plot a maximum nuber of points at a time to the plot no matter zoo...
Definition: mathplot.h:1851
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:4724
double m_relY
Box Y position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1325
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:4716
~mpBarChart() override
Destructor.
Definition: mathplot.h:2691
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:5061
mpRange()
Default constructor.
Definition: mathplot.h:275
double m_sigma
Sigma value.
Definition: mathplot.h:2601
void ShowDraggedSeries(const bool active)
Set if dragged series shall be shown or hidden.
Definition: mathplot.h:1531
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:3767
sub type not defined (should be never used)
Definition: mathplot.h:750
int m_flags
Holds label alignment. Default : mpALIGN_SW for series and mpALIGN_CENTER for scale.
Definition: mathplot.h:1179
std::vector< wxColour > colours
Per-slice colours used when drawing the chart.
Definition: mathplot.h:2820
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:4623
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:2217
void SetReserve(const int reserve)
Set memory reserved for m_xs and m_ys Note : this does not modify the size of m_xs and m_ys...
Definition: mathplot.h:2332
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1326
sub type not defined (should be never used)
Definition: mathplot.h:728
wxIndexColour(const unsigned int id)
Constructor.
Definition: mathplot.h:5342
double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:2795
sub type not defined (should be never used)
Definition: mathplot.h:720
mpRange< double > m_bitmapX
The shape of the bitmap:
Definition: mathplot.h:5306
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:4866
void SetSymbol(const mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1779
Just the end of ZOrder.
Definition: mathplot.h:818
int GetMarginRight(const bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:4272
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:809
void SetLabelFormat(const wxString &format, const bool updateLabelMode=false)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2931
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:2268
mpRange< double > x
range over x direction
Definition: mathplot.h:563
Layer for pie chart.
Definition: mathplot.h:2748
void SetAutoFit(const bool autoFit)
Set if plot shall be auto fitted when hiding or showing axis and series via mouse.
Definition: mathplot.h:4227
wxPoint GetMousePosition() const
Returns current mouse position in window.
Definition: mathplot.h:4563
std::vector< double > m_xs
internal copy of the set of data on x direction
Definition: mathplot.h:2348
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:1022
bool IsRightAxis() const
Return true if this Y axis is aligned to the right side.
Definition: mathplot.h:3290
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:2342
void Set(T value_)
Initialize min and max.
Definition: mathplot.h:297
const std::vector< double > & GetYData() const
Get read-only access to the internal Y data vector.
Definition: mathplot.h:2312
void Update(T value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:351
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:4718
Draw a plus +.
Definition: mathplot.h:701
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2940
Keep the object, just remove the layer from the layer list.
Definition: mathplot.h:829
double GetMaxY() override
Get max Y of the function.
Definition: mathplot.h:2523
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:2877
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:3200
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:2349
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:888
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2922
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:2352
Delete the object regardless of the CanDelete value and remove it from the layer list.
Definition: mathplot.h:831
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:3397
double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:2403
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:4328
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:4749
Align the plot label towards the southwest.
Definition: mathplot.h:674
Align the y-axis towards left border.
Definition: mathplot.h:661
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:1064
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:3778
void EnableBufferedPaintDC(const bool enabled)
Enable/disable the auto buffering of PaintDC.
Definition: mathplot.h:3928
Align the x-axis towards bottom border.
Definition: mathplot.h:651
void Show(const bool show)
Set if magnet shall be shown or hidden.
Definition: mathplot.h:3444
void SetMarginTop(const int top)
Set the top margin.
Definition: mathplot.h:4247
Plot (function) type layer.
Definition: mathplot.h:814
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:4765
bool ViewAsBar(void) const
Get if we are in bar mode.
Definition: mathplot.h:2208
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1180
wxColour colour
pen colour of the matched plot layer
Definition: mathplot.h:608
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:1014
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1140
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1786
void SetStep(const unsigned int step)
Set step for plot.
Definition: mathplot.h:1765
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:3129
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:4340
Create a generic FX function Override the ComputeY() function with your function. ...
Definition: mathplot.h:2474
void SetMaxNOfPoints(const size_t nOfPoints)
Set how many points that is allowed to be drawn at a time.
Definition: mathplot.h:1866
size_t m_maxNOfPoints
Maximum number of points to draw to screen.
Definition: mathplot.h:1886
double m_deltaY
Min delta between 2 consecutive coordinate on y direction.
Definition: mathplot.h:2221
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2908
Axis type layer.
Definition: mathplot.h:812
void SetMarginLeft(const int left)
Set the left margin.
Definition: mathplot.h:4304
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
double GetMaxScale() const
Get the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3020
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:5201
Draw a triangle down oriented.
Definition: mathplot.h:699
Axis type layer.
Definition: mathplot.h:795
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:3902
double GetQuantiles() const
Get the confidence-interval multiplier used for the ellipse.
Definition: mathplot.h:5130
double m_const
Const factor.
Definition: mathplot.h:2567
bool GetCanDelete(void) const
Retreive what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1154
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:2142
#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:1177
void SetMarginBottom(const int bottom)
Set the bottom margin.
Definition: mathplot.h:4287
Align the info in margin center-right.
Definition: mathplot.h:640
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1167
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:4220
int GetBarWidth(void) const
Get the width of the bar when we plot in bar mode.
Definition: mathplot.h:2199
wxColour m_barColour
Fill colour used for the bars.
Definition: mathplot.h:2731
double GetMinScale() const
Get the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:3004
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:4738
bool IsHorizontal(void) const
Is it a horizontal line?
Definition: mathplot.h:1930
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:3336
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:1119
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:4735
void SetLogYaxis(const int yAxisID, const bool log)
Set the log property (true or false) for a Y layer (Y axis) given by is ID.
Definition: mathplot.h:4519
int GetSegments() const
Get the number of line segments used to approximate the ellipse. */.
Definition: mathplot.h:5150
virtual size_t GetSize()
Return the number of points in the series.
Definition: mathplot.h:2168
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:5157
mpRange< double > desired
Desired range min and max.
Definition: mathplot.h:3353
wxCoord m_scaledBitmap_offset_x
Cached X pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5299
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:4200
void SetLegendIsAlwaysVisible(const bool alwaysVisible)
Set the visibility of the name of the function in the legend despite the visibility of the function i...
Definition: mathplot.h:1835
bool IsEnabled() const
Check if magnet is enabled.
Definition: mathplot.h:3429
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5281
bool m_LegendIsAlwaysVisible
If true, the name is visible in the legend despite the visibility of the function. Default false.
Definition: mathplot.h:1884
each visible plot is described on its own line, one above the other
Definition: mathplot.h:688
double m_cov_01
Covariance matrix element (0,1), equal to element (1,0).
Definition: mathplot.h:5179
void SetbgColour(const wxColour &colour)
Set the plot background colour.
Definition: mathplot.h:4441
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1347
bool m_fullscreen
Boolean value indicating that we are in fullscreen mode (default false)
Definition: mathplot.h:4714
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:654
mpGaussian(const double mu, const double sigma)
Classic Gaussian distribution.
Definition: mathplot.h:2554
void SetDrawOutsideMargins(const bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:1085
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:4753
double m_mu
Mean value.
Definition: mathplot.h:2564
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:767
void SetLocation(const mpLocation location)
Set the location of the box.
Definition: mathplot.h:4859
Align the y-axis towards right border.
Definition: mathplot.h:665
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:709
mpLegendStyle m_item_mode
Visual style used for each legend entry.
Definition: mathplot.h:1649
void SetLogXaxis(const bool log)
Enable or disable logarithmic scaling on the X axis.
Definition: mathplot.h:4508
bool IsLogXaxis() const
Is this an X axis to be displayed with log scale? It is really an axis property but as we need to con...
Definition: mathplot.h:4482
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:915
double GetScaleY(const int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:3695
mpLegendDirection GetItemDirection() const
Get the current legend item layout direction.
Definition: mathplot.h:1518
void ShowGrids(const bool grids)
Set axis grids.
Definition: mathplot.h:2915
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:5006
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:5240
Show/Hide info coord.
Definition: mathplot.h:623
Align the x-axis towards top border.
Definition: mathplot.h:655
bool m_IsHorizontal
Is the line horizontal? Default false.
Definition: mathplot.h:1937
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5206
Mouse action draw a box to zoom inside.
Definition: mathplot.h:759
__Function_Type
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
Definition: mathplot.h:726
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition: mathplot.h:90
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1959
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:4990
bool IsShown() const
Get shown status.
Definition: mathplot.h:3450
Align the y-axis towards left plot.
Definition: mathplot.h:662
Chart type layer.
Definition: mathplot.h:815
Set label for axis in scientific notation.
Definition: mathplot.h:771
bool IsInside(const wxCoord xPixel) const
Return true if the given X pixel lies within this Y-axis drawing area.
Definition: mathplot.h:3296
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2964
void SetOffset(const int offX, const int offY)
Set offset.
Definition: mathplot.h:4873
enum __mp_Location_Type mpLocation
Location for the Info layer.
void SetInitialPosition(const wxPoint pos)
Set the position in percent of the upper left corner of the box.
Definition: mathplot.h:1286
std::optional< int > mpOptional_int
Shortcut to optional integer type..
Definition: mathplot.h:108
int m_labelPos
Bar-label placement mode.
Definition: mathplot.h:2732
Copy a screen shot to the clipboard.
Definition: mathplot.h:624
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:3403
Fit view to match bounding box of all layers.
Definition: mathplot.h:617
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:630
Center view on click position.
Definition: mathplot.h:620
void SetItemMode(const mpLegendStyle mode)
Set item mode (the element on the left of text representing the plot line may be line, square, or line with symbol).
Definition: mathplot.h:1497
void ShowTicks(const bool ticks)
Set axis ticks.
Definition: mathplot.h:2901
Plot layer implementing a simple title.
Definition: mathplot.h:4902
double m_total_value
Total of the values vector.
Definition: mathplot.h:2666
bool IsSet() const
Check if this mpRange has been assigned any values.
Definition: mathplot.h:342
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:649
double pos
Position.
Definition: mathplot.h:3351
mpLabelType m_labelType
Label formatting mode used for the X coordinate display.
Definition: mathplot.h:1457
sub type for all layers who are function.
Definition: mathplot.h:735
Draw a square.
Definition: mathplot.h:697
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:1078
Align the x-axis center plot.
Definition: mathplot.h:653
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:718
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:4752
double m_labelAngle
Rotation angle used for bar labels, in degrees.
Definition: mathplot.h:2733
__mp_Colour
Enumeration of classic colour.
Definition: mathplot.h:5318
double m_width
Width of each bar/column in plot units.
Definition: mathplot.h:2730
void SetCovarianceMatrix(const double cov_00, const double cov_01, const double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:5166
mpRange< double > GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:3713
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1227
Align the plot label towards the northwest.
Definition: mathplot.h:671
int m_infoLegendSelectedSeries
Only used with config window: the selected series in info legend.
Definition: mathplot.h:4776
~mpInfoLegend() override
Default destructor.
Definition: mathplot.h:1493
bool m_show
Indicates if magnet shall be shown in plot.
Definition: mathplot.h:1455
void SetLabelMode(const mpLabelType mode, const unsigned int time_conv=MP_X_RAWTIME)
Set axis label view mode.
Definition: mathplot.h:2948
mpRange< int > m_drawX
Range min and max on x axis.
Definition: mathplot.h:2216
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:3038
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:4721
double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:2418
bool ShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
Check conditions if info coords shall be shown or not.
Definition: mathplot.h:1404
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:3255
bool IsVisible() const
Is this layer visible?
Definition: mathplot.h:1105
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:4386
No symbol is drawing.
Definition: mathplot.h:695
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:931
virtual void SetTractable(const bool track)
Sets layer tractability.
Definition: mathplot.h:1126
double m_reference_y
Current object Y position in plot coordinates.
Definition: mathplot.h:5062
Layer for bar chart.
Definition: mathplot.h:2684
__Chart_Type
sub_type values for mpLAYER_CHART
Definition: mathplot.h:748
void SetAxisID(const unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2894
void SetFactor(const int factor)
Definition: mathplot.h:4967
static bool m_DefaultLegendIsAlwaysVisible
This value sets the default behaviour when a series is not visible for the legend display...
Definition: mathplot.h:4205
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:682
sub type for all layers who are chart.
Definition: mathplot.h:753
void EnableSeriesValues(const bool enable)
Enables to show series values in the legend.
Definition: mathplot.h:1545
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4931
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:3126
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1906
Align the info in margin center-left.
Definition: mathplot.h:636
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:769
double m_mu
Mean value.
Definition: mathplot.h:2600
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:669
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:4739
void Set(T min_, T max_)
Set min, max function.
Definition: mathplot.h:304
double GetPosY(const int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3802
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:4429
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1737
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:4759
sub type for mpInfoLegend layer
Definition: mathplot.h:714
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1315
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2972
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1170
wxPoint m_center
Center of the pie chart in device coordinates.
Definition: mathplot.h:2819
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3864
double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:2811
mpOptional_int m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:4756
bool IsSeriesValuesShown() const
Indicates if series values shall be shown.
Definition: mathplot.h:1575
#define MP_EPSILON
An epsilon for float comparison to 0.
Definition: mathplot.h:174
double m_radius
Radius of the pie chart in pixels.
Definition: mathplot.h:2818
bool m_mouseMovedAfterRightClick
If the mouse does not move after a right click, then the context menu is displayed.
Definition: mathplot.h:4750
bool SeriesValuesShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
Check if series values should be shown in plot, depending on where mouse is.
Definition: mathplot.h:1561
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:4723
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3951
void SetLocation(const mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1308
int m_last_ly
Last logical Y origin, used for double buffering.
Definition: mathplot.h:4743
std::unordered_map< int, mpRange< double > > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:3740
Text box type layer.
Definition: mathplot.h:798
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:659
void SetAlign(const int align)
Set X/Y alignment.
Definition: mathplot.h:1133
sub type for mpBarChart
Definition: mathplot.h:751
Abstract class providing a line.
Definition: mathplot.h:1894
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:1045
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:3656
Load a file.
Definition: mathplot.h:628
enum __Symbol_Type mpSymbol
Displaying a symbol instead of a point in the plot function.
bool GetAutoStep() const
Get if auto stop is enabled.
Definition: mathplot.h:1858
mpRange< double > m_axisRange
Range axis values when autosize is false.
Definition: mathplot.h:3128
void Show(const bool show)
Set if info coords shall be shown or hidden.
Definition: mathplot.h:1388
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:982
Line (horizontal or vertical) type layer.
Definition: mathplot.h:813
void SetMouseLeftDownAction(const mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:4545
double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:5038
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3811
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:2300
Dialog box for configuring the plot&#39;s layer objects In this dialog, you can configure: ...
Definition: MathPlotConfig.h:155
bool ShouldBeShown(const wxPoint mousePos) const
Check conditions if magnet shall be shown.
Definition: mathplot.h:3438
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:1321
infoCoordType
Type of info coordinates to be displayed (axis, closest series, or all series)
Definition: mathplot.h:1369
Delete the object if CanDelete is true and remove it from the layer list.
Definition: mathplot.h:830
void SetBrush(const wxColour &colour, enum wxBrushStyle style=wxBRUSHSTYLE_SOLID)
Set layer brush.
Definition: mathplot.h:1056
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:4241
double scale
Scale.
Definition: mathplot.h:3350
void SetContinuity(const bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1750
sub type for mpTitle layer
Definition: mathplot.h:722
mpRange< double > m_bbox_x
The precomputed bounding box:
Definition: mathplot.h:5082
int GetMarginTop(const bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:4255
Align the info in margin center-top.
Definition: mathplot.h:638
void SetScale(const double min, const double max)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:3029
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:778
void SetSeriesCoord(const bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1421
void IndicateSeriesIntersection(const bool enable)
Set if the intersection of the series with the vertical cursor shall be indicated.
Definition: mathplot.h:1582
bool m_autoFit
Automatically fit plot when hiding / showing axis and series.
Definition: mathplot.h:4758
wxPoint GetPosition() const
Get the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1279
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1176
void UpdateDesiredBoundingBox(const mpAxisUpdate update)
Update m_desired bounds.
Definition: mathplot.h:4046
bool IsLogYaxis(const int yAxisID)
Get the log property (true or false) Y layer (Y axis) with a specific Y ID or false if not found...
Definition: mathplot.h:4494
void SetWildcard(const wxString &wildcard)
Set wildcard for LoadFile() function when we use wxFileDialog.
Definition: mathplot.h:4167
double GetMinY() override
Get min Y of the function.
Definition: mathplot.h:2514
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1323
Set no label for axis (useful for bar)
Definition: mathplot.h:784
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:757
void SetMagnetize(const bool mag)
Enable or disable mouse-position magnet lines (cross-hairs) in the plot area.
Definition: mathplot.h:4536
sub type for mpPieChart
Definition: mathplot.h:752
bool m_validImg
True when the source image is valid and ready to draw.
Definition: mathplot.h:5301
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:672
double m_deltaX
Min delta between 2 consecutive coordinate on x direction.
Definition: mathplot.h:2220
only for mpInfoCoords
Definition: mathplot.h:645
double m_value
The x or y coordinates of the line.
Definition: mathplot.h:1936
bool m_enableBufferedPaintDC
For auto DC double buffering.
Definition: mathplot.h:4747
void SetMax(T max_)
Set max function, correct min.
Definition: mathplot.h:319
HitCode
Return codes for GetLegendHitRegion() if no series was hit.
Definition: mathplot.h:1639
Abstract class providing an vertical line.
Definition: mathplot.h:1974
bool m_showDraggedSeries
Indicate if series that has been gripped with mouse shall be drawn.
Definition: mathplot.h:1651
sub type for mpFXY function
Definition: mathplot.h:731
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:907
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:3358
bool IsBottomAxis() const
Return true when this X axis is aligned at the bottom edge or bottom border.
Definition: mathplot.h:3221
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:3853
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:923
mpInfoLayer * GetMovingInfoLayer() const
Returns moving info layer.
Definition: mathplot.h:4572
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:5297
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:4767
void UpdateBoundingBoxToInclude(const double px, const double py)
Update bounding box (X and Y axis) to include this point.
Definition: mathplot.h:587
bool GetBoundingBox(mpRange< double > *boundX, mpRange< double > *boundY, const int yAxisID)
Return the bounding box coordinates for the Y axis of ID yAxisID.
Definition: mathplot.h:4085
infoCoordType GetInfoCoordType() const
Get the type of info coordinates to be displayed (axis, closest series, or all series) ...
Definition: mathplot.h:1437
Zoom into view at clickposition / window center.
Definition: mathplot.h:618
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:4736
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:4717
std::vector< double > values
Values of the chart.
Definition: mathplot.h:2662
mpCovarianceEllipse(const double cov_00=1, const double cov_11=1, const double cov_01=0, const double quantiles=2, const int segments=32, const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5114
Align the info in margin top-left.
Definition: mathplot.h:637
void SetQuantiles(const double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see GetQuantiles a...
Definition: mathplot.h:5137
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1175
double m_quantiles
Confidence-interval multiplier used when drawing the ellipse.
Definition: mathplot.h:5180
Zoom out.
Definition: mathplot.h:619
enum __mp_Layer_Type mpLayerType
Major type of an mpLayer (detail is in subtype)
virtual void SetLogAxis(const bool log)
Set Logarithmic mode.
Definition: mathplot.h:3079
wxCoord m_mouseY
Last mouse Y position in window pixel coordinates.
Definition: mathplot.h:1460
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1772
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2566
wxRealPoint coords
data-space (x, y) of the closest point
Definition: mathplot.h:609
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1879
double m_relX
Box X position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1324
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:686
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:5108
const std::vector< double > & GetXData() const
Get read-only access to the internal X data vector.
Definition: mathplot.h:2306
sub type for mpInfoLayer layer
Definition: mathplot.h:712
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:4472
Align the x-axis towards bottom plot.
Definition: mathplot.h:652
wxCoord m_scaledBitmap_offset_y
Cached Y pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5300
bool DoBeforePlot() override
This is the only case where we don&#39;t need and Y axis So no need to test m_yAxisID.
Definition: mathplot.h:2000
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1172
void InitializeBoundingBox(const double px, const double py, const int yAxisID)
Initialize the bounding box from a first point for the selected Y axis.
Definition: mathplot.h:4127
void SetMarginRight(const int right)
Set the right margin.
Definition: mathplot.h:4264
mpFloatRectSimple GetBoundingBox(const bool desired, const unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:4071
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:776
wxPen m_gridpen
Grid&#39;s pen. Default Colour = LIGHT_GREY, width = 1, style = wxPENSTYLE_DOT.
Definition: mathplot.h:3124
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:678
bool IsSeriesValuesEnabled() const
Check if series values is enabled in legend.
Definition: mathplot.h:1553
bool GetCoordIsAlwaysVisible() const
Get the visibility of the mouse coordinates in the info coordinates.
Definition: mathplot.h:3095
Align the y-axis towards right plot.
Definition: mathplot.h:664
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1322
void InitializeBoundingBox(const double px, const double py)
Initialize bounding box with an initial point.
Definition: mathplot.h:597
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:3130
wxTopLevelWindow * m_parent
Pointer to the top-level window containing the plot (used for fullscreen)
Definition: mathplot.h:4713
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:4995
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2774
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:4754
sub type for mpScaleX
Definition: mathplot.h:742
sub type for mpInfoCoords layer
Definition: mathplot.h:713
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
Set label user defined.
Definition: mathplot.h:782
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:3125
std::vector< double > m_shape_ys
Shape vertices in object-local Y coordinates.
Definition: mathplot.h:5073
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1758
void SetMin(T min_)
Set min function, correct max.
Definition: mathplot.h:311
std::vector< double > m_trans_shape_xs
Transformed shape vertices in X coordinates.
Definition: mathplot.h:5076
double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:5267
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1161
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:872
int m_xPos
Leftmost X pixel occupied by this axis (starting point).
Definition: mathplot.h:3307
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:4730
Plot layer implementing a text string.
Definition: mathplot.h:4825
wxCoord y2p(const double y, const int yAxisID=0)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:3910
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:774
sub type not defined (should be never used)
Definition: mathplot.h:711
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:780
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:4830
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:3482
double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:5052
Bitmap type layer.
Definition: mathplot.h:799
wxCoord m_mouseX
Last mouse X position in window pixel coordinates.
Definition: mathplot.h:1459
bool m_bitmapChanged
True when the cached scaled bitmap must be regenerated.
Definition: mathplot.h:5302
void SetLabelMode(const mpLabelType mode, const unsigned int time_conv=MP_X_RAWTIME)
Set X axis label view mode.
Definition: mathplot.h:1412
Classic Normal distribution f(x) = exp(-(ln(x)-μ)²/2σ²)/(xσ.sqrt(2π))
Definition: mathplot.h:2582
double GetY(const double x) override
Get function value for argument.
Definition: mathplot.h:2495
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1883
int m_last_lx
Last logical X origin, used for double buffering.
Definition: mathplot.h:4742
Align the info in margin bottom-left.
Definition: mathplot.h:641
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:730
Info box type layer.
Definition: mathplot.h:797
double GetMinY() override
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:2396
Align the y-axis center plot.
Definition: mathplot.h:663
mpRange< double > m_rangeX
Range min and max on x axis.
Definition: mathplot.h:2354
double m_cov_11
Covariance matrix element (1,1).
Definition: mathplot.h:5178
double p2y(const wxCoord pixelCoordY, const int yAxisID=0)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:3891
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:4880
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2766
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1882
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1174
bool m_cacheDirty
Indicate that the cached buffer m_buff_bmp need to be re-created.
Definition: mathplot.h:4746
Result of mpWindow::GetClosestPlot: the colour and data-space coordinates of the plot point closest t...
Definition: mathplot.h:606
Shows information about the mouse commands.
Definition: mathplot.h:629
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:4728
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3819
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:1092
legend components follow each other horizontally on a single line
Definition: mathplot.h:689
Align the info in margin top-right.
Definition: mathplot.h:639
void SetSegments(const int segments)
Set the number of line segments used to approximate the ellipse.
Definition: mathplot.h:5144
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:3231
~mpChart() override
Destructor.
Definition: mathplot.h:2632
wxString m_wildcard
For loadfile() function when we use wxFileDialog.
Definition: mathplot.h:4769
mpTitle(const wxString &name)
Definition: mathplot.h:4911
int m_axisWidth
Reserved width for this Y axis including labels, in pixels.
Definition: mathplot.h:3306
enum __Text_Type mpTextType
sub_type values for mpLAYER_TEXT
double m_reference_phi
Current object rotation angle in radians.
Definition: mathplot.h:5063
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:4720
virtual void SetVisible(const bool show)
Sets layer visibility.
Definition: mathplot.h:1112
void SetCanDelete(const bool canDelete)
Set what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1147
sub type for all layers who are scale.
Definition: mathplot.h:744
unsigned int m_timeConv
Time conversion mode used when formatting date/time X values.
Definition: mathplot.h:1458
Abstract class providing an horizontal line.
Definition: mathplot.h:1945
mpInfoCoords * m_InfoCoords
Pointer to the optional info coords layer.
Definition: mathplot.h:4760
mpInfoLegend * m_InfoLegend
Pointer to the optional info legend layer.
Definition: mathplot.h:4761
mpLocation m_location
The location of the text.
Definition: mathplot.h:4889
Implement the legend to be added to the plot This layer allows you to add a legend to describe the pl...
Definition: mathplot.h:1479
bool PointIsInside(const double px, const double py) const
Is point inside this bounding box?
Definition: mathplot.h:578
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:3347
double m_sigma
Sigma value.
Definition: mathplot.h:2565
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:4722
Align the info in margin bottom-right.
Definition: mathplot.h:643
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2847
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1262
void ShowSeriesValues(const bool show)
Set if the series values shall be drawn to the plot.
Definition: mathplot.h:1568
bool PointIsInside(T point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:419
void SetSymbolSize(const int size)
Set symbol size.
Definition: mathplot.h:1793
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1169
Classic Gaussian distribution f(x) = exp(-(x-μ)²/2σ²)/sqrt(2πσ²)
Definition: mathplot.h:2546
Plot layer, abstract base class.
Definition: mathplot.h:844
void SetColumnWidth(const double colWidth)
Set the bar width in plot units.
Definition: mathplot.h:2700
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:3874
sub type for mpMovableObject function
Definition: mathplot.h:733
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:5177
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:1038
Group of properties, derived from the axis step size and range, that control how scale labels are for...
Definition: mathplot.h:2855
mpRange< double > m_rangeY
Y range.
Definition: mathplot.h:2529
~mpFXYVector() override
destrutor
Definition: mathplot.h:2280
void EnableDoubleBuffer(const bool enabled)
Deprecated: Enable/disable the double-buffering of the window, eliminating the flicker (default=enabl...
Definition: mathplot.h:3920
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:4727
void UpdateBox(const wxRect &plotArea)
Update the drawable magnet area from a wxRect.
Definition: mathplot.h:3417
#define MP_ISNOTNULL(x)
Nullity test. Old solution is to test according small epsilon: (fabs(x) > MP_EPSILON) ...
Definition: mathplot.h:176
mpFloatRectSimple(const mpRange< double > x_, const mpRange< double > y_)
Construct a simple rectangular box.
Definition: mathplot.h:571
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:4784
mpRange< double > m_rangeY
Range min and max on y axis.
Definition: mathplot.h:2356
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5045
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:3131
sub type for mpFX function
Definition: mathplot.h:729
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2956
double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:5031
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:2160
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:3127
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:4725
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2077
void SetShowName(const bool show)
Set Name visibility.
Definition: mathplot.h:1071
wxRect GetRect(void) const
Create standard wxWidgets rectangle defined by this object&#39;s start and end points.
Definition: mathplot.h:256
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:4733
std::vector< double > m_shape_xs
Shape vertices in object-local X coordinates.
Definition: mathplot.h:5072
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:5335
void SetInfoCoordType(const infoCoordType type)
Set the type of info coordinates to be displayed (axis, closest series, or all series) ...
Definition: mathplot.h:1429
virtual bool IsLogAxis()
Get if we are in Logarithmic mode.
Definition: mathplot.h:3071
double ComputeY(const double x) override
The main computation of the FX function.
Definition: mathplot.h:2569
void UpdateBoundingBoxToInclude(const double px, const double py, const int yAxisID)
Ensure the bounding box includes the given point for the selected Y axis.
Definition: mathplot.h:4112
mpLegendDirection m_item_direction
Layout direction used when arranging legend entries.
Definition: mathplot.h:1650
double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:2787
mpRange< double > bound
Range min and max.
Definition: mathplot.h:3352
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1168
#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:2350
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:880
Show the X and Y value of the closest series.
Definition: mathplot.h:1372
sub type for mpScaleY
Definition: mathplot.h:743
int m_BarWidth
Bar width in pixels when the XY series is drawn in bar mode.
Definition: mathplot.h:2223
mpRange< double > m_bitmapY
Range of the bitmap on y direction.
Definition: mathplot.h:5307
Vertical cursor is at mouse position.
Definition: mathplot.h:1598
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:4888
size_t GetMaxNOfPoints() const
Get maximum number of points to plot.
Definition: mathplot.h:1873
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1880
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:3374
Text box type layer.
Definition: mathplot.h:817
double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:5274
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:4457
void SetValue(const double value)
Set x or y value.
Definition: mathplot.h:1922
bool HasBBox() override
Text Layer has not bounding box.
Definition: mathplot.h:4852
Show axis coordinates at mouse position.
Definition: mathplot.h:1371
const wxString & GetWildcard(void) const
Get wildcard.
Definition: mathplot.h:4175
Line (horizontal or vertical) type layer.
Definition: mathplot.h:800
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2988
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:2353