MathPlot
mathplot.h
Go to the documentation of this file.
1 // Name: mathplot.cpp
3 // Purpose: Framework for plotting in wxWindows
4 // Original Author: David Schalig
5 // Maintainer: Davide Rondini
6 // Contributors: Jose Luis Blanco, Val Greene, Lionel Reynaud, Dave Nadler, MortenMacFly,
7 // Oskar Waldemarsson (for multi Y axis and corrections)
8 // Created: 21/07/2003
9 // Last edit: 18/04/2026
10 // Copyright: (c) David Schalig, Davide Rondini
11 // Licence: wxWindows licence
13 
14 #ifndef MATHPLOT_H_INCLUDED
15 #define MATHPLOT_H_INCLUDED
16 
75 //this definition uses windows dll to export function.
76 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
77 //mathplot_EXPORTS will be defined by cmake
78 #ifdef mathplot_EXPORTS
79  #define WXDLLIMPEXP_MATHPLOT WXEXPORT
81  #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
83 #else // not making DLL
84  #define WXDLLIMPEXP_MATHPLOT
86  #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
88 #endif
89 
90 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
91  #pragma interface "mathplot.h"
92 #endif
93 
94 #include <cassert> // For assert debug message. Disable if NDEBUG is defined
95 #include <vector>
96 #include <map>
97 #include <unordered_map>
98 
106 // Multiple define to compile with C++14 because
107 // Optional is only for C++ >= 17
108 // Structured binding is a C++17 feature
109 #if (defined(__cplusplus) && (__cplusplus > 201402L)) // C++17 or newer
110  // Use optional
111  #include <optional>
113  typedef std::optional<unsigned int> mpOptional_uint;
115  typedef std::optional<int> mpOptional_int;
117  #define MP_OPTNULL_INT std::nullopt
118  #define MP_OPTTEST(opt) (opt)
120  #define MP_OPTGET(opt) (*opt)
122  // Use structured binding
124  #define MP_LOOP_ITER auto& [m_yID, m_yData]
125 #else
126  // To replace optional int...
128  typedef unsigned int mpOptional_uint;
130  typedef int mpOptional_int;
132  #define MP_OPTNULL_INT -1
133  #define MP_OPTTEST(opt) ((opt) != -1)
135  #define MP_OPTGET(opt) (opt)
137  // To replace structured binding...
139  #define MP_LOOP_ITER auto& elem
140  #define m_yID elem.first
142  #define m_yData elem.second
144 #endif
145 
148 // #include <wx/wx.h>
149 #include <wx/defs.h>
150 #include <wx/menu.h>
151 #include <wx/scrolwin.h>
152 #include <wx/event.h>
153 #include <wx/dynarray.h>
154 #include <wx/pen.h>
155 #include <wx/dcmemory.h>
156 #include <wx/string.h>
157 #include <wx/print.h>
158 #include <wx/image.h>
159 #include <wx/intl.h>
160 
161 #include <cmath>
162 #include <deque>
163 #include <algorithm>
164 
165 #if defined(MP_USER_INCLUDE)
166  #define xstr(x) #x
168  #define str(x) xstr(x)
170  #define header MP_USER_INCLUDE.h
171  #include str(header)
172  #undef header
173 #endif
174 
175 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
176  #include "MathPlotConfig.h"
177 #endif // MP_ENABLE_CONFIG
178 
183 #if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
184  namespace MathPlot {
185 #endif // MP_ENABLE_NAMESPACE
186 
187 #ifdef ENABLE_MP_DEBUG
188  // For memory leak debug
189  #ifdef _WINDOWS
190  #ifdef _DEBUG
191  #include <crtdbg.h>
192  #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
193  #else
194  #define DEBUG_NEW new
195  #endif // _DEBUG
196  #endif // _WINDOWS
197 #endif // ENABLE_MP_DEBUG
198 
200 #define MP_X_BORDER_SEPARATION 40
201 #define MP_Y_BORDER_SEPARATION 60
203 
205 #define MP_X_LOCALTIME 0x10
206 #define MP_X_UTCTIME 0x20
208 #define MP_X_RAWTIME MP_X_UTCTIME
210 
212 #define MP_EPSILON 1e-30
213 #define ISNOTNULL(x) (std::fpclassify(x) != FP_ZERO)
215 
217 #define MP_EXTRA_MARGIN 8
218 
220 #define MP_ZOOM_AROUND_CENTER -1
221 
222 //-----------------------------------------------------------------------------
223 // classes
224 //-----------------------------------------------------------------------------
225 
227 #define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class) wxDECLARE_DYNAMIC_CLASS(mp_class)
228 
258 
259 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
261 #endif // MP_ENABLE_CONFIG
262 
264 struct mpRect
265 {
266  union {
267  struct
268  {
269  wxCoord startPx;
270  wxCoord startPy;
271  wxCoord endPx;
272  wxCoord endPy;
273  };
274  struct
275  {
276  wxCoord left;
277  wxCoord top;
278  wxCoord right;
279  wxCoord bottom;
280  };
281  struct
282  {
283  wxCoord x1;
284  wxCoord y1;
285  wxCoord x2;
286  wxCoord y2;
287  };
288  wxCoord tab[4];
289  };
294  wxRect GetRect(void)
295  {
296  return wxRect(startPx, startPy, endPx - startPx, endPy - startPy);
297  }
298 };
299 static_assert(sizeof(mpRect) == 4 * sizeof(wxCoord));
300 
306 template<typename T>
307 struct mpRange
308 {
309  T min = 0;
310  T max = 0;
311 
314  {
315  min = 0;
316  max = 0;
317  }
318 
320  mpRange(T value1, T value2)
321  {
322  if (value1 < value2)
323  {
324  min = value1;
325  max = value2;
326  }
327  else
328  {
329  min = value2;
330  max = value1;
331  }
332  }
333 
335  void Set(T _value)
336  {
337  min = _value;
338  max = _value;
339  }
340 
342  void Set(T _min, T _max)
343  {
344  min = _min;
345  max = _max;
346  }
347 
349  void SetMin(T _min)
350  {
351  min = _min;
352  if (max < min)
353  max = min;
354  }
355 
357  void SetMax(T _max)
358  {
359  max = _max;
360  if (min > max)
361  min = max;
362  }
363 
365  void Assign(T value1, T value2)
366  {
367  if (value1 < value2)
368  {
369  min = value1;
370  max = value2;
371  }
372  else
373  {
374  min = value2;
375  max = value1;
376  }
377  }
378 
380  bool IsSet()
381  {
382  return ((min != 0) || (max != 0));
383  }
384 
389  void Update(T value)
390  {
391  if (value < min)
392  min = value;
393  else
394  if (value > max)
395  max = value;
396  }
397 
401  void Update(T _min, T _max)
402  {
403  if (_min < min)
404  min = _min;
405  if (_max > max)
406  max = _max;
407  }
408 
411  void Update(mpRange range)
412  {
413  if (range.min < min)
414  min = range.min;
415  if (range.max > max)
416  max = range.max;
417  }
418 
420  void Check(void)
421  {
422  if (min == max)
423  {
424  if (max > 0)
425  min = 0;
426  else
427  max = 0;
428  }
429  }
430 
432  T Length(void) const
433  {
434  return max - min;
435  }
436 
438  T GetCenter(void) const
439  {
440  return (min + max) / 2;
441  }
442 
444  T GetMaxAbs(void) const
445  {
446  return std::max(fabs(min), fabs(max));
447  }
448 
450  void ToLog(void)
451  {
452  min = (min > 0) ? log10(min) : 0;
453  max = (max > 0) ? log10(max) : 0;
454  }
455 
457  bool PointIsInside(T point) const
458  {
459  return ((point >= min) && (point <= max));
460  }
461 
462  #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
463  bool operator==(const mpRange&) const = default;
464  #else
465  bool operator==(const mpRange &other) const
467  {
468  return (min == other.min) && (max == other.max);
469  }
471  bool operator!=(const mpRange& other) const
472  {
473  return !(*this == other);
474  }
475  #endif
476 };
477 
483 struct [[deprecated("Deprecated! No longer used as X and Y are now separated")]] mpFloatRect
484 {
485  mpRange<double> x;
486  std::vector<mpRange<double>> y;
487 
494  mpFloatRect(mpWindow& w);
495 
497  mpFloatRect() = delete;
498 
505  bool PointIsInside(double px, double py, size_t yAxisID = 0) const {
506  if (yAxisID < y.size())
507  {
508  if( (px < x.min || px > x.max) ||
509  (py < y[yAxisID].min || py > y[yAxisID].max))
510  {
511  return false;
512  }
513  }
514  else
515  {
516  return false;
517  }
518 
519  return true;
520  }
521 
528  void UpdateBoundingBoxToInclude(double px, double py, size_t yAxisID = 0) {
529  assert(yAxisID < y.size());
530  if (yAxisID < y.size())
531  {
532  if (px < x.min ) x.min = px;
533  else if (px > x.max ) x.max = px;
534  if (py < y[yAxisID].min ) y[yAxisID].min = py;
535  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
536  }
537  }
538 
545  void InitializeBoundingBox(double px, double py, size_t yAxisID = 0) {
546  assert(yAxisID < y.size());
547  if (yAxisID < y.size())
548  {
549  x.min = x.max = px;
550  y[yAxisID].min = y[yAxisID].max = py;
551  }
552  }
554  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
556 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
557  bool operator==(const mpFloatRect&) const = default;
558 #else
559  // We compare with an epsilon precision
560  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
561  bool operator==(const mpFloatRect& rect) const
562  {
563  auto Same = [](double a, double b) {
564  return std::fabs(a - b) < MP_EPSILON;
565  };
566 
567  // Compare scalar members
568  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
569  {
570  return false;
571  }
572 
573  // Compare vector sizes
574  if (y.size() != rect.y.size())
575  {
576  return false;
577  }
578 
579  // Compare each Y boundary
580  for (size_t i = 0; i < y.size(); ++i)
581  {
582  if (!Same(y[i].min, rect.y[i].min) ||
583  !Same(y[i].max, rect.y[i].max) )
584  {
585  return false;
586  }
587  }
588 
589  return true;
590  }
591 #endif
592 };
593 
600 {
603 
610 
616  bool PointIsInside(double px, double py) const {
617  return x.PointIsInside(px) && y.PointIsInside(py);
618  }
619 
625  void UpdateBoundingBoxToInclude(double px, double py)
626  {
627  x.Update(px);
628  y.Update(py);
629  }
630 
635  void InitializeBoundingBox(double px, double py)
636  {
637  x.Set(px, px);
638  y.Set(py, py);
639  }
640 };
641 
645 enum
646 {
647  mpID_FIT = 2000,
655 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
656  mpID_CONFIG,
657 #endif // MP_ENABLE_CONFIG
661 };
662 
664 typedef enum __mp_Location_Type
665 {
676 } mpLocation;
677 
679 typedef enum __XAxis_Align_Type
680 {
686 } mpXAxis_Align;
687 
689 typedef enum __YAxis_Align_Type
690 {
696 } mpYAxis_Align;
697 
700 {
705 } mpPlot_Align;
706 
708 typedef enum __mp_Style_Type
709 {
713 } mpLegendStyle;
714 
717 {
721 
723 typedef enum __Symbol_Type
724 {
732 } mpSymbol;
733 
734 //-----------------------------------------------------------------------------
735 // mpLayer sub_type values
736 //-----------------------------------------------------------------------------
737 
739 typedef enum __Info_Type
740 {
745 } mpInfoType;
746 
748 typedef enum __Text_Type
749 {
753 } mpTextType;
754 
756 typedef enum __Function_Type
757 {
767 
769 typedef enum __Scale_Type
770 {
775 } mpScaleType;
776 
778 typedef enum __Chart_Type
779 {
784 } mpChartType;
785 
788 {
791 };
792 
795 {
815 };
816 
817 //-----------------------------------------------------------------------------
818 // mpLayer
819 //-----------------------------------------------------------------------------
820 
822 typedef enum __mp_Layer_Type
823 {
832 } mpLayerType;
833 
839 typedef enum __mp_Layer_ZOrder
840 {
849 } mpLayerZOrder;
850 
857 typedef enum __mp_Delete_Action
858 {
863 
874 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
875 {
876  public:
881  mpLayer(mpLayerType layerType);
882 
883  virtual ~mpLayer()
884  {
885  ;
886  }
887 
891  {
892  m_win = &w;
893  }
894 
902  virtual bool HasBBox()
903  {
904  return true;
905  }
906 
910  mpLayerType GetLayerType() const
911  {
912  return m_type;
913  }
914 
918  int GetLayerSubType() const
919  {
920  return m_subtype;
921  }
922 
928  virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
929  {
930  *subtype = m_subtype;
931  return (m_type == typeOfInterest);
932  }
933 
937  virtual double GetMinX()
938  {
939  return -1.0;
940  }
941 
945  virtual double GetMaxX()
946  {
947  return 1.0;
948  }
949 
953  virtual double GetMinY()
954  {
955  return -1.0;
956  }
957 
961  virtual double GetMaxY()
962  {
963  return 1.0;
964  }
965 
1007  void Plot(wxDC &dc, mpWindow &w);
1008 
1012  void SetName(const wxString &name)
1013  {
1014  m_name = name;
1015  }
1016 
1020  const wxString& GetName() const
1021  {
1022  return m_name;
1023  }
1024 
1028  void SetFont(const wxFont &font)
1029  {
1030  m_font = font;
1031  }
1032 
1036  const wxFont& GetFont() const
1037  {
1038  return m_font;
1039  }
1040 
1044  void SetFontColour(const wxColour &colour)
1045  {
1046  m_fontcolour = colour;
1047  }
1048 
1052  const wxColour& GetFontColour() const
1053  {
1054  return m_fontcolour;
1055  }
1056 
1060  void SetPen(const wxPen &pen)
1061  {
1062  m_pen = pen;
1063  }
1064 
1068  const wxPen& GetPen() const
1069  {
1070  return m_pen;
1071  }
1072 
1075  void SetBrush(const wxBrush &brush)
1076  {
1077  if (brush == wxNullBrush)
1078  m_brush = *wxTRANSPARENT_BRUSH;
1079  else
1080  m_brush = brush;
1081  }
1082 
1086  void SetBrush(const wxColour &colour, enum wxBrushStyle style = wxBRUSHSTYLE_SOLID)
1087  {
1088  m_brush.SetColour(colour);
1089  m_brush.SetStyle(style);
1090  }
1091 
1094  const wxBrush& GetBrush() const
1095  {
1096  return m_brush;
1097  }
1098 
1101  void SetShowName(bool show)
1102  {
1103  m_showName = show;
1104  }
1105 
1108  inline bool GetShowName() const
1109  {
1110  return m_showName;
1111  }
1112 
1115  void SetDrawOutsideMargins(bool drawModeOutside)
1116  {
1117  m_drawOutsideMargins = drawModeOutside;
1118  }
1119 
1123  {
1124  return m_drawOutsideMargins;
1125  }
1126 
1131  wxBitmap GetColourSquare(int side = 16);
1132 
1135  inline bool IsVisible() const
1136  {
1137  return m_visible;
1138  }
1139 
1142  virtual void SetVisible(bool show)
1143  {
1144  m_visible = show;
1145  }
1146 
1149  inline bool IsTractable() const
1150  {
1151  return m_tractable;
1152  }
1153 
1156  virtual void SetTractable(bool track)
1157  {
1158  m_tractable = track;
1159  }
1160 
1163  void SetAlign(int align)
1164  {
1165  m_flags = align;
1166  }
1167 
1170  int GetAlign() const
1171  {
1172  return m_flags;
1173  }
1174 
1177  void SetCanDelete(bool canDelete)
1178  {
1179  m_CanDelete = canDelete;
1180  }
1181 
1184  bool GetCanDelete(void) const
1185  {
1186  return m_CanDelete;
1187  }
1188 
1191  mpLayerZOrder GetZIndex(void) const
1192  {
1193  return m_ZIndex;
1194  }
1195 
1196  protected:
1197  const mpLayerType m_type;
1200  wxFont m_font;
1201  wxColour m_fontcolour;
1202  wxPen m_pen;
1203  wxBrush m_brush;
1204  wxString m_name;
1205  bool m_showName;
1207  bool m_visible;
1209  int m_flags;
1212  mpLayerZOrder m_ZIndex;
1213 
1216  void UpdateContext(wxDC &dc) const;
1217 
1222  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1223 
1228  virtual bool DoBeforePlot()
1229  {
1230  return true;
1231  }
1232 
1239  void CheckLog(double *x, double *y, int yAxisID);
1240 
1241  private:
1242  bool m_busy;
1243  mpLayer() = delete; // default ctor not implemented/permitted
1244 
1246 };
1247 
1248 //-----------------------------------------------------------------------------
1249 // mpInfoLayer
1250 //-----------------------------------------------------------------------------
1251 
1258 {
1259  public:
1261  mpInfoLayer();
1262 
1267  mpInfoLayer(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1268 
1270  virtual ~mpInfoLayer();
1271 
1274  virtual void SetVisible(bool show);
1275 
1280  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1281 
1284  virtual bool HasBBox()
1285  {
1286  return false;
1287  }
1288 
1291  [[deprecated("Use Show() instead")]]
1292  virtual void ErasePlot(wxDC&, mpWindow&) {};
1293 
1297  virtual bool Inside(const wxPoint &point);
1298 
1302  virtual void Move(wxPoint delta, mpWindow &w);
1303 
1305  virtual void UpdateReference();
1306 
1309  wxPoint GetPosition() const
1310  {
1311  return m_dim.GetPosition();
1312  }
1313 
1316  void SetInitialPosition(wxPoint pos)
1317  {
1318  m_relX = pos.x / 100.0;
1319  m_relY = pos.y / 100.0;
1320  }
1321 
1324  wxSize GetSize() const
1325  {
1326  return m_dim.GetSize();
1327  }
1328 
1331  const wxRect& GetRectangle() const
1332  {
1333  return m_dim;
1334  }
1335 
1338  void SetLocation(mpLocation location)
1339  {
1340  m_location = location;
1341  }
1342 
1345  mpLocation GetLocation() const
1346  {
1347  return m_location;
1348  }
1349 
1350  protected:
1351  wxRect m_dim;
1352  wxBitmap* m_info_bmp;
1353  wxPoint m_reference;
1354  double m_relX;
1355  double m_relY;
1356  mpLocation m_location;
1357 
1362  virtual void DoPlot(wxDC &dc, mpWindow &w);
1363 
1366  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1367 
1368  private:
1369  double clamp(double v, double min, double max);
1370 
1372 };
1373 
1379 {
1380  public:
1382  mpInfoCoords();
1383 
1385  mpInfoCoords(mpLocation location);
1386 
1391  mpInfoCoords(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1392 
1395  {
1396  ;
1397  }
1398 
1402  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1403 
1406  [[deprecated("Use Show() instead")]]
1407  virtual void ErasePlot(wxDC&, mpWindow&) {};
1408 
1411  void Show(bool show)
1412  {
1413  m_show = show;
1414  }
1415 
1418  bool IsShown()
1419  {
1420  return m_show;
1421  }
1422 
1427  bool ShouldBeShown(wxRect plotArea, wxPoint mousePos)
1428  {
1429  return IsVisible() && (GetDrawOutsideMargins() || plotArea.Contains(mousePos));
1430  }
1431 
1435  void SetLabelMode(mpLabelType mode, unsigned int time_conv = MP_X_RAWTIME)
1436  {
1437  m_labelType = mode;
1438  m_timeConv = time_conv;
1439  }
1440 
1443  void SetSeriesCoord(bool show)
1444  {
1445  m_series_coord = show;
1446  }
1447 
1450  bool IsSeriesCoord() const
1451  {
1452  return m_series_coord;
1453  }
1454 
1460  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1461 
1464  void SetPenSeries(const wxPen &pen)
1465  {
1466  m_penSeries = pen;
1467  }
1468 
1472  void DrawContent(wxDC &dc, mpWindow &w);
1473 
1474  protected:
1475  bool m_show;
1476  wxString m_content;
1478  unsigned int m_timeConv;
1479  wxCoord m_mouseX;
1480  wxCoord m_mouseY;
1482  wxPen m_penSeries;
1483 
1488  virtual void DoPlot(wxDC &dc, mpWindow &w);
1489 
1490  private:
1491  std::unordered_map<int, double> m_yValList;
1492 
1494 };
1495 
1501 {
1502  public:
1504  mpInfoLegend();
1505 
1511  mpInfoLegend(wxPoint pos, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginUser);
1512 
1515 
1518  void SetItemMode(mpLegendStyle mode)
1519  {
1520  m_item_mode = mode;
1521  m_needs_update = true;
1522  }
1523 
1525  mpLegendStyle GetItemMode() const
1526  {
1527  return m_item_mode;
1528  }
1529 
1532  void SetItemDirection(mpLegendDirection mode)
1533  {
1534  m_item_direction = mode;
1535  m_needs_update = true;
1536  }
1537 
1539  mpLegendDirection GetItemDirection() const
1540  {
1541  return m_item_direction;
1542  }
1543 
1546  {
1547  m_needs_update = true;
1548  }
1549 
1552  void ShowDraggedSeries(bool active)
1553  {
1554  m_showDraggedSeries = active;
1555  }
1556 
1560  {
1561  return m_showDraggedSeries;
1562  }
1563 
1569  int GetLegendHitRegion(wxPoint mousePos);
1570 
1577  void DrawDraggedSeries(wxDC& dc, mpWindow &w);
1578 
1582  void DrawContent(wxDC &dc, mpWindow &w);
1583 
1586  void RestoreAxisHighlighting(mpWindow &w);
1587 
1589  enum HitCode : int
1590  {
1591  HitNone = -1,
1592  HitHeader = -2
1593  };
1594 
1595  mpFunction* m_selectedSeries = nullptr;
1596  mpOptional_int m_lastHoveredAxisID = MP_OPTNULL_INT;
1597 
1598  protected:
1599  mpLegendStyle m_item_mode;
1600  mpLegendDirection m_item_direction;
1602  wxString m_headerString = wxString::FromUTF8("≡");
1603 
1608  virtual void DoPlot(wxDC &dc, mpWindow &w);
1609 
1610  private:
1612  struct LegendDetail
1613  {
1614  unsigned int layerIdx;
1615  wxCoord legendEnd;
1616  };
1618  std::vector<LegendDetail> m_LegendDetailList;
1619  wxCoord m_headerEnd;
1620  bool m_needs_update;
1621 
1631  void UpdateBitmap(wxDC &dc, mpWindow &w);
1632 
1633  private:
1635 };
1636 
1637 //-----------------------------------------------------------------------------
1638 // mpLayer implementations - functions
1639 //-----------------------------------------------------------------------------
1640 
1641 
1649 {
1650  public:
1656  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1657 
1661  void SetContinuity(bool continuity)
1662  {
1663  m_continuous = continuity;
1664  }
1665 
1669  bool GetContinuity() const
1670  {
1671  return m_continuous;
1672  }
1673 
1676  void SetStep(unsigned int step)
1677  {
1678  m_step = step;
1679  }
1680 
1683  unsigned int GetStep() const
1684  {
1685  return m_step;
1686  }
1687 
1690  void SetSymbol(mpSymbol symbol)
1691  {
1692  m_symbol = symbol;
1693  }
1694 
1697  mpSymbol GetSymbol() const
1698  {
1699  return m_symbol;
1700  }
1701 
1704  void SetSymbolSize(int size)
1705  {
1706  m_symbolSize = size;
1707  }
1708 
1711  int GetSymbolSize() const
1712  {
1713  return m_symbolSize;
1714  }
1715 
1719  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1720 
1724  int GetYAxisID() const
1725  {
1726  return m_yAxisID;
1727  }
1728 
1733  void SetYAxisID(unsigned int yAxisID)
1734  {
1735  m_yAxisID = yAxisID;
1736  }
1737 
1741  void SetLegendIsAlwaysVisible(bool alwaysVisible)
1742  {
1743  m_LegendIsAlwaysVisible = alwaysVisible;
1744  }
1745 
1750  {
1751  return m_LegendIsAlwaysVisible;
1752  }
1753 
1757  void SetAutoStep(bool enable)
1758  {
1759  m_autoStep = enable;
1760  }
1761 
1764  bool GetAutoStep() const
1765  {
1766  return m_autoStep;
1767  }
1768 
1772  void SetMaxNOfPoints(size_t nOfPoints)
1773  {
1774  m_maxNOfPoints = nOfPoints;
1775  }
1776 
1779  size_t GetMaxNOfPoints() const
1780  {
1781  return m_maxNOfPoints;
1782  }
1783 
1784  protected:
1786  mpSymbol m_symbol;
1788  unsigned int m_step;
1791  bool m_autoStep;
1793 
1794  private:
1796 };
1797 
1801 {
1802  public:
1809  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1810 
1811  // We don't want to include line (horizontal or vertical) in BBox computation
1812  virtual bool HasBBox() override
1813  {
1814  return false;
1815  }
1816 
1820  double GetValue() const
1821  {
1822  return m_value;
1823  }
1824 
1828  void SetValue(const double value)
1829  {
1830  m_value = value;
1831  }
1832 
1836  bool IsHorizontal(void) const
1837  {
1838  return m_IsHorizontal;
1839  }
1840 
1841  protected:
1842  double m_value;
1844 
1845  private:
1847 };
1848 
1852 {
1853  public:
1860  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1861 
1865  void SetYValue(const double yvalue)
1866  {
1867  SetValue(yvalue);
1868  }
1869 
1870  protected:
1871 
1872  virtual void DoPlot(wxDC &dc, mpWindow &w);
1873 
1874  private:
1876 };
1877 
1881 {
1882  public:
1888  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1889 
1893  void SetXValue(const double xvalue)
1894  {
1895  SetValue(xvalue);
1896  }
1897 
1898  protected:
1899 
1900  virtual void DoPlot(wxDC &dc, mpWindow &w);
1901 
1906  virtual bool DoBeforePlot()
1907  {
1908  return true;
1909  }
1910 
1911  private:
1913 };
1914 
1922 {
1923  public:
1928  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
1929 
1935  virtual double GetY(double x) = 0;
1936 
1943  double DoGetY(double x);
1944 
1949  void DefineDoGetY(void);
1950 
1951  protected:
1952 
1953  double (mpFX::*pDoGetY)(double x);
1954 
1959  virtual void DoPlot(wxDC &dc, mpWindow &w);
1960 
1965  double NormalDoGetY(double x);
1966 
1971  double LogDoGetY(double x);
1972 
1973  private:
1975 };
1976 
1984 {
1985  public:
1990  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
1991 
1997  virtual double GetX(double y) = 0;
1998 
2005  double DoGetX(double y);
2006 
2011  void DefineDoGetX(void);
2012 
2013  protected:
2014 
2015  double (mpFY::*pDoGetX)(double y);
2016 
2021  virtual void DoPlot(wxDC &dc, mpWindow &w);
2022 
2027  double NormalDoGetX(double y);
2028 
2033  double LogDoGetX(double y);
2034 
2035  private:
2037 };
2038 
2049 {
2050  public:
2056  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2057 
2061  virtual void Rewind() = 0;
2062 
2066  virtual void Clear()
2067  {
2068  ;
2069  }
2070 
2074  virtual int GetSize()
2075  {
2076  return 0;
2077  }
2078 
2085  virtual bool GetNextXY(double *x, double *y) = 0;
2086 
2093  bool DoGetNextXY(double *x, double *y);
2094 
2099  void SetViewMode(bool asBar);
2100 
2105  int GetBarWidth(void) const
2106  {
2107  return m_BarWidth;
2108  }
2109 
2114  bool ViewAsBar(void) const
2115  {
2116  return m_ViewAsBar;
2117  }
2118 
2119  protected:
2120 
2121  // Data to calculate label positioning
2124 
2125  // Min delta between 2 x coordinate (used for view as bar)
2126  double m_deltaX;
2127  double m_deltaY;
2128 
2130 
2131  bool m_ViewAsBar = false;
2132 
2139  virtual void DoPlot(wxDC &dc, mpWindow &w);
2140 
2145  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
2146 
2147  private:
2149 };
2150 
2151 //-----------------------------------------------------------------------------
2152 // mpFXYVector - provided by Jose Luis Blanco
2153 //-----------------------------------------------------------------------------
2154 
2175 {
2176  public:
2182  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2183 
2186  virtual ~mpFXYVector()
2187  {
2188  Clear();
2189  }
2190 
2195  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
2196 
2200  void Clear() override;
2201 
2206  virtual int GetSize() override
2207  {
2208  return m_xs.size();
2209  }
2210 
2218  bool AddData(const double x, const double y, bool updatePlot);
2219 
2226  void SetReserve(int reserve)
2227  {
2228  m_reserveXY = reserve;
2229  m_xs.reserve(m_reserveXY);
2230  m_ys.reserve(m_reserveXY);
2231  }
2232 
2236  int GetReserve() const
2237  {
2238  return m_reserveXY;
2239  }
2240 
2241  protected:
2242  std::vector<double> m_xs;
2243  std::vector<double> m_ys;
2246  size_t m_index;
2247  size_t m_endIndex;
2249  double m_lastX;
2251  double m_lastY;
2252 
2257  virtual void Rewind() override;
2258 
2265  virtual bool GetNextXY(double *x, double *y) override;
2266 
2271  void DrawAddedPoint(double x, double y);
2272 
2275  virtual double GetMinX()override
2276  {
2277  if (m_ViewAsBar)
2278  {
2279  // Make extra space for outer bars
2280  return m_rangeX.min - (m_deltaX / 2);
2281  }
2282  else
2283  {
2284  return m_rangeX.min;
2285  }
2286  }
2287 
2290  virtual double GetMinY() override
2291  {
2292  return m_rangeY.min;
2293  }
2294 
2297  virtual double GetMaxX() override
2298  {
2299  if(m_ViewAsBar)
2300  {
2301  // Make extra space for outer bars
2302  return m_rangeX.max + (m_deltaX / 2);
2303  }
2304  else
2305  {
2306  return m_rangeX.max;
2307  }
2308  }
2309 
2312  virtual double GetMaxY() override
2313  {
2314  return m_rangeY.max;
2315  }
2316 
2317  private:
2320  void First_Point(double x, double y);
2321 
2324  void Check_Limit(double val, mpRange<double> *range, double *last, double *delta);
2325 
2327 };
2328 
2338 {
2339  public:
2343  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
2344 
2350  virtual double GetY(double x) = 0;
2351 
2352  protected:
2353 
2358  virtual void DoPlot(wxDC &dc, mpWindow &w);
2359 
2360  private:
2362 };
2363 
2368 class mpFXGeneric: public mpFX
2369 {
2370  public:
2375  mpFXGeneric(const wxString &name = wxT("Generic FX function"), int flags = mpALIGN_LEFT, unsigned int yAxisID = 0) :
2376  mpFX(name, flags, yAxisID)
2377  {
2378  wxPen FXpen(*wxBLUE, 1, wxPENSTYLE_SOLID);
2379  SetDrawOutsideMargins(false);
2380  SetContinuity(true);
2381  SetPen(FXpen);
2382  SetStep(8); // Draw one point over eight
2383  }
2384 
2389  virtual double GetY(double x)
2390  {
2391  double y;
2392  try
2393  {
2394  y = ComputeY(x);
2395  }
2396  catch (...)
2397  {
2398  y = 0;
2399  }
2400  m_rangeY.Update(y);
2401  return y;
2402  }
2403 
2408  virtual double GetMinY()
2409  {
2410  return m_rangeY.min;
2411  }
2412 
2417  virtual double GetMaxY()
2418  {
2419  return m_rangeY.max;
2420  }
2421 
2422  protected:
2424 
2430  virtual double ComputeY(double x) = 0;
2431 
2432  private:
2434 };
2435 
2441 {
2442  public:
2448  mpGaussian(double mu, double sigma) :
2449  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2450  {
2451  m_mu = mu;
2452  m_sigma = sigma;
2453  m_variance = sigma * sigma;
2454  m_const = 1.0 / sqrt(2.0 * M_PI * m_variance);
2455  }
2456 
2457  protected:
2458  double m_mu;
2459  double m_sigma;
2460  double m_variance;
2461  double m_const;
2462 
2463  virtual double ComputeY(double x)
2464  {
2465  return m_const * exp(-(x - m_mu) * (x - m_mu) / (2.0 * m_variance));
2466  }
2467 
2468  private:
2470 };
2471 
2476 class mpNormal: public mpFXGeneric
2477 {
2478  public:
2484  mpNormal(double mu, double sigma) :
2485  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2486  {
2487  m_mu = mu;
2488  m_sigma = sigma;
2489  m_variance = sigma * sigma;
2490  m_const = 1.0 / (m_variance * sqrt(2.0 * M_PI));
2491  }
2492 
2493  protected:
2494  double m_mu;
2495  double m_sigma;
2496  double m_variance;
2497  double m_const;
2498 
2499  virtual double ComputeY(double x)
2500  {
2501  if (x < 0)
2502  return 0.0;
2503  else
2504  {
2505  double tmp = log(x) - m_mu;
2506  return m_const * exp(-tmp * tmp / (2.0 * m_variance)) / x;
2507  }
2508  }
2509 
2510  private:
2512 };
2513 
2514 //-----------------------------------------------------------------------------
2515 // mpChart
2516 //-----------------------------------------------------------------------------
2520 {
2521  public:
2523  mpChart(const wxString &name = wxEmptyString);
2524 
2527  {
2528  Clear();
2529  }
2530 
2533  void SetChartValues(const std::vector<double> &data);
2534 
2537  void SetChartLabels(const std::vector<std::string> &labelArray);
2538 
2543  void AddData(const double &data, const std::string &label);
2544 
2548  virtual void Clear();
2549 
2550  virtual bool HasBBox()
2551  {
2552  return (values.size() > 0);
2553  }
2554 
2555  protected:
2556  std::vector<double> values;
2557  std::vector<std::string> labels;
2558 
2559  double m_max_value;
2560  double m_total_value;
2561 
2562  private:
2564 };
2565 
2566 //-----------------------------------------------------------------------------
2567 // mpBarChart - provided by Jose Davide Rondini
2568 //-----------------------------------------------------------------------------
2569 /* Defines for bar charts label positioning. */
2570 #define mpBAR_NONE 0
2571 #define mpBAR_AXIS_H 1
2572 #define mpBAR_AXIS_V 2
2573 #define mpBAR_INSIDE 3
2574 #define mpBAR_TOP 4
2575 
2576 
2579 {
2580  public:
2582  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2583 
2586  {
2587  Clear();
2588  }
2589 
2591  void SetBarColour(const wxColour &colour);
2592 
2594  void SetColumnWidth(const double colWidth)
2595  {
2596  m_width = colWidth;
2597  }
2598 
2600  void SetBarLabelPosition(int position);
2601 
2605  virtual double GetMinX();
2606 
2610  virtual double GetMaxX();
2611 
2615  virtual double GetMinY();
2616 
2620  virtual double GetMaxY();
2621 
2622  protected:
2623 
2624  double m_width;
2625  wxColour m_barColour;
2627  double m_labelAngle;
2628 
2633  virtual void DoPlot(wxDC &dc, mpWindow &w);
2634 
2635  private:
2637 };
2638 
2643 {
2644  public:
2648  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2649 
2652  {
2653  Clear();
2654  colours.clear();
2655  }
2656 
2660  void SetCenter(const wxPoint center)
2661  {
2662  m_center = center;
2663  }
2664 
2668  wxPoint GetCenter(void) const
2669  {
2670  return m_center;
2671  }
2672 
2676  void SetPieColours(const std::vector<wxColour> &colourArray);
2677 
2681  virtual double GetMinX()
2682  {
2683  return m_center.x - m_radius;
2684  }
2685 
2689  virtual double GetMaxX()
2690  {
2691  return m_center.x + m_radius;
2692  }
2693 
2697  virtual double GetMinY()
2698  {
2699  return m_center.y - m_radius;
2700  }
2701 
2705  virtual double GetMaxY()
2706  {
2707  return m_center.y + m_radius;
2708  }
2709 
2710  protected:
2711 
2712  double m_radius;
2713  wxPoint m_center;
2714  std::vector<wxColour> colours;
2715 
2720  virtual void DoPlot(wxDC &dc, mpWindow &w);
2721 
2723  const wxColour& GetColour(unsigned int id);
2724 
2725  private:
2727 };
2728 
2731 //-----------------------------------------------------------------------------
2732 // mpLayer implementations - furniture (scales, ...)
2733 //-----------------------------------------------------------------------------
2742 {
2743  public:
2751  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, mpOptional_uint axisID = MP_OPTNULL_INT);
2752 
2756  virtual bool HasBBox()
2757  {
2758  return false;
2759  }
2760 
2764  int GetAxisID(void)
2765  {
2766  return m_axisID;
2767  }
2768 
2773  void SetAxisID(unsigned int yAxisID)
2774  {
2775  m_axisID = yAxisID;
2776  }
2777 
2780  void ShowTicks(bool ticks)
2781  {
2782  m_ticks = ticks;
2783  }
2784 
2787  bool GetShowTicks() const
2788  {
2789  return m_ticks;
2790  }
2791 
2794  void ShowGrids(bool grids)
2795  {
2796  m_grids = grids;
2797  }
2798 
2801  bool GetShowGrids() const
2802  {
2803  return m_grids;
2804  }
2805 
2810  void SetLabelFormat(const wxString &format, bool updateLabelMode = false)
2811  {
2812  m_labelFormat = format;
2813  if (updateLabelMode)
2814  m_labelType = mpLabel_USER;
2815  }
2816 
2820  {
2821  return m_labelType;
2822  }
2823 
2827  void SetLabelMode(mpLabelType mode, unsigned int time_conv = MP_X_RAWTIME)
2828  {
2829  m_labelType = mode;
2830  m_timeConv = time_conv;
2831  }
2832 
2835  const wxString& GetLabelFormat() const
2836  {
2837  return m_labelFormat;
2838  }
2839 
2843  void SetGridPen(const wxPen &pen)
2844  {
2845  m_gridpen = pen;
2846  }
2847 
2851  const wxPen& GetGridPen() const
2852  {
2853  return m_gridpen;
2854  }
2855 
2859  void SetAuto(bool automaticScalingIsEnabled)
2860  {
2861  m_auto = automaticScalingIsEnabled;
2862  }
2863 
2867  bool GetAuto() const
2868  {
2869  return m_auto;
2870  }
2871 
2875  void SetMinScale(double min)
2876  {
2877  m_axisRange.SetMin(min);
2878  }
2879 
2883  double GetMinScale() const
2884  {
2885  return m_axisRange.min;
2886  }
2887 
2891  void SetMaxScale(double max)
2892  {
2893  m_axisRange.SetMax(max);
2894  }
2895 
2899  double GetMaxScale() const
2900  {
2901  return m_axisRange.max;
2902  }
2903 
2908  void SetScale(double min, double max)
2909  {
2910  m_axisRange.Set(min, max);
2911  }
2912 
2917  void GetScale(double *min, double *max) const
2918  {
2919  *min = m_axisRange.min;
2920  *max = m_axisRange.max;
2921  }
2922 
2927  {
2928  m_axisRange = range;
2929  }
2930 
2935  {
2936  return mpRange<double>(m_axisRange);
2937  }
2938 
2942  void SetHovering(bool hover)
2943  {
2944  m_hover = hover;
2945  }
2946 
2950  virtual bool IsLogAxis()
2951  {
2952  return m_isLog;
2953  }
2954 
2958  virtual void SetLogAxis(bool log)
2959  {
2960  m_isLog = log;
2961  }
2962 
2966  void SetCoordIsAlwaysVisible(bool alwaysVisible)
2967  {
2968  m_CoordIsAlwaysVisible = alwaysVisible;
2969  }
2970 
2975  {
2976  return m_CoordIsAlwaysVisible;
2977  }
2978 
2979  protected:
2980  static const wxCoord kTickSize = 4;
2981  static const wxCoord kAxisExtraSpace = 6;
2982 
2983  int m_axisID;
2984  wxPen m_gridpen;
2985  bool m_ticks;
2986  bool m_grids;
2987  bool m_auto;
2990  unsigned int m_timeConv;
2991  wxString m_labelFormat;
2992  bool m_isLog;
2993  bool m_hover = false;
2995 
2998  virtual int GetOrigin(mpWindow &w) = 0;
2999 
3006  double GetStep(double scale, int minLabelSpacing);
3007 
3015  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
3016 
3022  wxString FormatLabelValue(double value);
3023 
3028  wxString FormatLogValue(double n);
3029 
3036  int GetLabelWidth(double value, wxDC &dc);
3037 
3042  bool UseScientific(double maxAxisValue);
3043 
3049  int GetSignificantDigits(double step, double maxAxisValue);
3050 
3055  int GetDecimalDigits(double step);
3056 
3060  struct {
3061  double step;
3062  double maxAxisValue;
3063  bool UseScientific;
3064  int SignificantDigits;
3065  int DecimalDigits;
3066  double EpsilonScale;
3067  } m_ScaleConstraints;
3068 
3072  void ComputeScaleConstraints(double step, double maxAxisValue);
3073 
3074  private:
3076 };
3077 
3078 
3085 {
3086  public:
3092  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, mpLabelType type = mpLabel_AUTO) :
3093  mpScale(name, flags, grids, type)
3094  {
3095  m_subtype = mpsScaleX;
3096  }
3097 
3099  bool IsTopAxis()
3100  {
3101  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
3102  }
3103 
3106  {
3107  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
3108  }
3109 
3110  protected:
3115  static int m_orgy;
3116 
3119  virtual void DoPlot(wxDC &dc, mpWindow &w);
3120 
3121  virtual int GetOrigin(mpWindow &w);
3122  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
3123 
3124  private:
3126 
3130  friend mpScaleY;
3131 };
3132 
3140 {
3141  public:
3149  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, mpOptional_uint yAxisID = MP_OPTNULL_INT, mpLabelType labelType = mpLabel_AUTO) :
3150  mpScale(name, flags, grids, labelType, yAxisID)
3151  {
3152  m_subtype = mpsScaleY;
3153  m_axisWidth = MP_Y_BORDER_SEPARATION;
3154  m_xPos = 0;
3155  }
3156 
3159  void UpdateAxisWidth(mpWindow &w);
3160 
3163  {
3164  return m_axisWidth;
3165  }
3166 
3168  bool IsLeftAxis()
3169  {
3170  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
3171  }
3172 
3175  {
3176  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
3177  }
3178 
3180  bool IsInside(wxCoord xPixel)
3181  {
3182  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
3183  {
3184  return true;
3185  }
3186  return false;
3187  }
3188 
3189  protected:
3191  int m_xPos;
3192 
3195  virtual void DoPlot(wxDC &dc, mpWindow &w);
3196 
3197  virtual int GetOrigin(mpWindow &w);
3198  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
3199 
3200  private:
3202 };
3203 
3204 //-----------------------------------------------------------------------------
3205 // mpWindow
3206 //-----------------------------------------------------------------------------
3207 
3213 #define mpMOUSEMODE_DRAG 0
3214 
3215 #define mpMOUSEMODE_ZOOMBOX 1
3216 
3219 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
3220 typedef std::deque<mpLayer*> mpLayerList;
3221 
3232 {
3233  mpScale* axis = nullptr;
3234  double scale = 1.0;
3235  double pos = 0;
3239 
3240  // Note: we don't use the default operator since we don't want to compare axis pointers
3242  bool operator==(const mpAxisData& other) const
3243  {
3244  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
3245  (bound == other.bound) && (desired == other.desired);
3246  }
3247 };
3248 
3250 typedef std::map<int, mpAxisData> mpAxisList;
3251 
3258 typedef enum {
3259  uXAxis = 1,
3260  uYAxis = 2,
3261  uXYAxis = 3
3262 } mpAxisUpdate;
3263 
3273 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
3274 
3281 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
3282 
3288 {
3289  public:
3290  mpMagnet()
3291  {
3292  m_enable = false;
3293  m_show = false;
3294  }
3295  ~mpMagnet()
3296  {
3297  ;
3298  }
3299 
3301  void UpdateBox(const wxRect &plotArea)
3302  {
3303  m_domain = plotArea;
3304  }
3305 
3307  void Enable(bool enable)
3308  {
3309  m_enable = enable;
3310  }
3311 
3313  bool IsEnabled() const
3314  {
3315  return m_enable;
3316  }
3317 
3319  void DrawCross(wxDC &dc, mpWindow &w);
3320 
3322  bool ShouldBeShown(wxPoint mousePos)
3323  {
3324  return m_enable && m_domain.Contains(mousePos);
3325  }
3326 
3328  void Show(bool show)
3329  {
3330  m_show = show;
3331  }
3332 
3334  bool IsShown()
3335  {
3336  return m_show;
3337  }
3338 
3339  private:
3340  bool m_enable;
3341  bool m_show;
3342  wxRect m_domain;
3343 };
3344 
3366 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
3367 {
3368  public:
3369  mpWindow()
3370  {
3371  InitParameters();
3372  }
3373 
3381  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
3382  long flags = 0);
3383 
3384  ~mpWindow();
3385 
3389  wxMenu* GetPopupMenu()
3390  {
3391  return &m_popmenu;
3392  }
3393 
3402  bool AddLayer(mpLayer *layer, bool refreshDisplay = true, bool refreshConfig = true);
3403 
3416  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
3417 
3423  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
3424 
3431  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
3432 
3439  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
3440 
3446  mpLayer* GetLayer(int position);
3447 
3452  int GetLayerPosition(mpLayer* layer);
3453 
3460  mpLayer* GetLayersType(int position, mpLayerType type);
3461 
3468  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
3469 
3475  mpScale* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
3476 
3485  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
3486 
3495  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
3496 
3501  mpLayer* GetLayerByName(const wxString &name);
3502 
3507  mpLayer* GetLayerByClassName(const wxString &name);
3508 
3512  void RefreshLegend(void);
3513 
3518  bool IsYAxisUsed(int yAxisID);
3519 
3525  bool IsYAxisUsedByFunction(int yAxisID, int *position);
3526 
3530  mpScaleX* GetLayerXAxis();
3531 
3535  mpScaleY* GetLayerYAxis(int yAxisID);
3536 
3540  void SetScaleX(const double scaleX)
3541  {
3542  if (ISNOTNULL(scaleX))
3543  {
3544  m_AxisDataX.scale = scaleX;
3545  UpdateDesiredBoundingBox(uXAxis);
3546  }
3547  UpdateAll();
3548  }
3549 
3554  double GetScaleX(void) const
3555  {
3556  return m_AxisDataX.scale;
3557  }
3558 
3563  void SetScaleY(const double scaleY, int yAxisID)
3564  {
3565  assert(m_AxisDataYList.count(yAxisID) != 0);
3566  if (ISNOTNULL(scaleY))
3567  {
3568  m_AxisDataYList[yAxisID].scale = scaleY;
3569  UpdateDesiredBoundingBox(uYAxis);
3570  }
3571  UpdateAll();
3572  }
3573 
3579  double GetScaleY(int yAxisID)
3580  {
3581  assert(m_AxisDataYList.count(yAxisID) != 0);
3582  return m_AxisDataYList[yAxisID].scale;
3583  } // Schaling's method: maybe another method exists with the same name
3584 
3585  [[deprecated("Incomplete, use UpdateBBox instead")]]
3588  void SetBound();
3589 
3592  {
3593  return m_AxisDataX.bound;
3594  }
3595 
3598  {
3599  return m_AxisDataX.desired;
3600  }
3601 
3606  {
3607  assert(m_AxisDataYList.count(yAxisID) != 0);
3608  return m_AxisDataYList[yAxisID].bound;
3609  }
3610 
3615  {
3616  assert(m_AxisDataYList.count(yAxisID) != 0);
3617  return m_AxisDataYList[yAxisID].desired;
3618  }
3619 
3624  std::unordered_map<int, mpRange<double>> GetAllBoundY()
3625  {
3626  std::unordered_map<int, mpRange<double>> yRange;
3627  for (const MP_LOOP_ITER : m_AxisDataYList)
3628  {
3629  yRange[m_yID] = m_yData.bound;
3630  }
3631  return yRange;
3632  }
3633 
3638  std::unordered_map<int, mpRange<double>> GetAllDesiredY()
3639  {
3640  std::unordered_map<int, mpRange<double>> yRange;
3641  for (const MP_LOOP_ITER : m_AxisDataYList)
3642  {
3643  yRange[m_yID] = m_yData.desired;
3644  }
3645  return yRange;
3646  }
3647 
3651  void SetPosX(const double posX)
3652  {
3653  m_AxisDataX.pos = posX;
3654  UpdateDesiredBoundingBox(uXAxis);
3655  UpdateAll();
3656  }
3657 
3662  double GetPosX(void) const
3663  {
3664  return m_AxisDataX.pos;
3665  }
3666 
3671  void SetPosY(std::unordered_map<int, double>& posYList)
3672  {
3673  for (MP_LOOP_ITER : m_AxisDataYList)
3674  {
3675  m_yData.pos = posYList[m_yID];
3676  }
3677  UpdateDesiredBoundingBox(uYAxis);
3678  UpdateAll();
3679  }
3680 
3686  double GetPosY(int yAxisID)
3687  {
3688  assert(m_AxisDataYList.count(yAxisID) != 0);
3689  return m_AxisDataYList[yAxisID].pos;
3690  }
3691 
3695  int GetNOfYAxis(void) const
3696  {
3697  return (int)m_AxisDataYList.size();
3698  }
3699 
3703  mpAxisList GetAxisDataYList(void) const
3704  {
3705  return m_AxisDataYList;
3706  }
3707 
3713  void SetScreen(const int scrX, const int scrY)
3714  {
3715  m_scrX = scrX;
3716  m_scrY = scrY;
3717  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3718  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3719 
3720  m_plotBoundaries.endPx = m_scrX;
3721  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3722  m_plotBoundaries.endPy = m_scrY;
3723  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3724 
3725  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3726  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3727 
3728  m_magnet.UpdateBox(m_PlotArea);
3729  }
3730 
3737  int GetScreenX(void) const
3738  {
3739  return m_scrX;
3740  }
3741 
3748  int GetScreenY(void) const
3749  {
3750  return m_scrY;
3751  }
3752 
3758  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3759  {
3760  m_AxisDataX.pos = posX;
3761  SetPosY(posYList);
3762  }
3763 
3767  inline double p2x(const wxCoord pixelCoordX) const
3768  {
3769  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3770  }
3771 
3775  inline double p2y(const wxCoord pixelCoordY, int yAxisID = 0)
3776  {
3777  assert(m_AxisDataYList.count(yAxisID) != 0);
3778  if (m_AxisDataYList.count(yAxisID) == 0)
3779  return 0.0;
3780  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3781  }
3782 
3786  inline wxCoord x2p(const double x) const
3787  {
3788  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3789  }
3790 
3794  inline wxCoord y2p(const double y, int yAxisID = 0)
3795  {
3796  assert(m_AxisDataYList.count(yAxisID) != 0);
3797  if (m_AxisDataYList.count(yAxisID) == 0)
3798  return 0;
3799  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3800  }
3801 
3803  [[deprecated("Deprecated - use EnableBufferedPaintDC??")]]
3804  void EnableDoubleBuffer(const bool enabled)
3805  {
3806  EnableBufferedPaintDC(enabled);
3807  };
3808 
3811  void EnableBufferedPaintDC(const bool enabled)
3812  {
3813  m_enableBufferedPaintDC = enabled;
3814  }
3815 
3818  void EnableMousePanZoom(const bool enabled)
3819  {
3820  m_enableMouseNavigation = enabled;
3821  }
3822 
3828  void LockAspect(bool enable = true);
3829 
3834  inline bool IsAspectLocked() const
3835  {
3836  return m_lockaspect;
3837  }
3838 
3843  void Fit();
3844 
3851  void Fit(const mpRange<double> &rangeX, std::unordered_map<int, mpRange<double>> rangeY, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3852 
3856  void FitX(void);
3857 
3862  void FitY(int yAxisID);
3863 
3868  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
3869 
3874  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
3875 
3877  void ZoomInX();
3878 
3880  void ZoomOutX();
3881 
3884  void ZoomInY(mpOptional_int yAxisID = MP_OPTNULL_INT);
3885 
3888  void ZoomOutY(mpOptional_int yAxisID = MP_OPTNULL_INT);
3889 
3894  void ZoomRect(wxPoint p0, wxPoint p1);
3895 
3897  void UpdateAll();
3898 
3899  // Added methods by Davide Rondini
3900 
3904  unsigned int CountLayers();
3905 
3908  unsigned int CountAllLayers()
3909  {
3910  return (unsigned int)m_layers.size();
3911  }
3912 
3916  unsigned int CountLayersType(mpLayerType type);
3917 
3921  unsigned int CountLayersFXYPlot();
3922 
3930  {
3931  // Change on X axis
3932  if (update & uXAxis)
3933  {
3934  m_AxisDataX.desired.Set(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale),
3935  m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3936  }
3937 
3938  // Change on Y axis
3939  if (update & uYAxis)
3940  {
3941  for (MP_LOOP_ITER : m_AxisDataYList)
3942  {
3943  m_yData.desired.Set(m_yData.pos - ((m_margin.top + m_plotHeight) / m_yData.scale),
3944  m_yData.pos - (m_margin.top / m_yData.scale));
3945  }
3946  }
3947  }
3948 
3954  mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID = 0)
3955  {
3956  assert(m_AxisDataYList.count(yAxisID) != 0);
3957  if (desired)
3958  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
3959  else
3960  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
3961  }
3962 
3966  double GetDesiredXmin() const
3967  {
3968  return m_AxisDataX.desired.min;
3969  }
3970 
3975  double GetDesiredXmax() const
3976  {
3977  return m_AxisDataX.desired.max;
3978  }
3979 
3985  double GetDesiredYmin(int yAxisID)
3986  {
3987  assert(m_AxisDataYList.count(yAxisID) != 0);
3988  return m_AxisDataYList[yAxisID].desired.min;
3989  }
3990 
3996  double GetDesiredYmax(int yAxisID)
3997  {
3998  assert(m_AxisDataYList.count(yAxisID) != 0);
3999  return m_AxisDataYList[yAxisID].desired.max;
4000  }
4001 
4007  bool GetBoundingBox(mpRange<double> *boundX, mpRange<double> *boundY, int yAxisID)
4008  {
4009  if (m_AxisDataYList.count(yAxisID) == 0)
4010  return false;
4011  *boundX = m_AxisDataX.bound;
4012  *boundY = m_AxisDataYList[yAxisID].bound;
4013  return true;
4014  }
4015 
4021  bool PointIsInsideBound(double px, double py, int yAxisID)
4022  {
4023  if (m_AxisDataYList.count(yAxisID) == 0)
4024  return false;
4025 
4026  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
4027  }
4028 
4034  void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
4035  {
4036  if (m_AxisDataYList.count(yAxisID) == 0)
4037  return ;
4038 
4039  m_AxisDataX.bound.Update(px);
4040  m_AxisDataYList[yAxisID].bound.Update(py);
4041  }
4042 
4043  /* Initialize bounding box with an initial point
4044  * @param px point on x-axis
4045  * @param py point on y-axis
4046  * @param yAxisID the y-axis ID
4047  */
4049  void InitializeBoundingBox(double px, double py, int yAxisID)
4050  {
4051  if (m_AxisDataYList.count(yAxisID) == 0)
4052  return ;
4053 
4054  m_AxisDataX.bound.Set(px, px);
4055  m_AxisDataYList[yAxisID].bound.Set(py, py);
4056  }
4057 
4060  void SetMPScrollbars(bool status);
4061 
4064  bool GetMPScrollbars() const
4065  {
4066  return m_enableScrollBars;
4067  }
4068 
4074  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
4075 
4079  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4080 
4084  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4085 
4089  void SetWildcard(const wxString &wildcard)
4090  {
4091  m_wildcard = wildcard;
4092  }
4093 
4097  const wxString& GetWildcard(void) const
4098  {
4099  return m_wildcard;
4100  }
4101 
4109  bool LoadFile(const wxString &filename = wxEmptyString);
4110 
4115  void SetDefaultDir(const wxString &dirname)
4116  {
4117  m_DefaultDir = dirname;
4118  }
4119 
4123 
4128 
4135  {
4136  m_DefaultLegendIsAlwaysVisible = visible;
4137  }
4138 
4143 
4144 
4149  void SetAutoFit(bool autoFit)
4150  {
4151  m_autoFit = autoFit;
4152  }
4153 
4160  void SetMargins(int top, int right, int bottom, int left);
4161 
4164  {
4165  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4166  }
4167 
4169  void SetMarginTop(int top)
4170  {
4171  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4172  }
4173 
4177  int GetMarginTop(bool minusExtra = false) const
4178  {
4179  if (minusExtra)
4180  return m_margin.top - m_extraMargin;
4181  else
4182  return m_margin.top;
4183  }
4184 
4186  void SetMarginRight(int right)
4187  {
4188  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
4189  }
4190 
4194  int GetMarginRight(bool minusExtra = false) const
4195  {
4196  if (minusExtra)
4197  return m_margin.right - m_extraMargin;
4198  else
4199  return m_margin.right;
4200  }
4201 
4204  {
4205  return m_marginOuter.right;
4206  }
4207 
4209  void SetMarginBottom(int bottom)
4210  {
4211  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
4212  }
4213 
4217  int GetMarginBottom(bool minusExtra = false) const
4218  {
4219  if (minusExtra)
4220  return m_margin.bottom - m_extraMargin;
4221  else
4222  return m_margin.bottom;
4223  }
4224 
4226  void SetMarginLeft(int left)
4227  {
4228  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
4229  }
4230 
4234  int GetMarginLeft(bool minusExtra = false) const
4235  {
4236  if (minusExtra)
4237  return m_margin.left - m_extraMargin;
4238  else
4239  return m_margin.left;
4240  }
4241 
4243  void SetExtraMargin(int extra)
4244  {
4245  m_extraMargin = extra;
4246  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4247  }
4248 
4250  int GetExtraMargin() const
4251  {
4252  return m_extraMargin;
4253  }
4254 
4257  {
4258  return m_marginOuter.left;
4259  }
4260 
4262  int GetPlotWidth() const
4263  {
4264  return m_plotWidth;
4265  }
4266 
4268  int GetPlotHeight() const
4269  {
4270  return m_plotHeight;
4271  }
4272 
4277  mpRect GetPlotBoundaries(bool with_margin) const
4278  {
4279  mpRect bond;
4280  if (with_margin)
4281  bond = m_plotBoundariesMargin;
4282  else
4283  bond = m_plotBoundaries;
4284  bond.startPx -= m_extraMargin;
4285  bond.endPx += m_extraMargin;
4286  bond.startPy -= m_extraMargin;
4287  bond.endPy += m_extraMargin;
4288  return bond;
4289  }
4290 
4294  int GetLeftYAxesWidth(mpOptional_int yAxisID = MP_OPTNULL_INT);
4295 
4299  int GetRightYAxesWidth(mpOptional_int yAxisID = MP_OPTNULL_INT);
4300 
4302  void SetDrawBox(bool drawbox)
4303  {
4304  m_drawBox = drawbox;
4305  }
4306 
4308  bool GetDrawBox() const
4309  {
4310  return m_drawBox;
4311  }
4312 
4316  mpOptional_int IsInsideYAxis(const wxPoint &point);
4317 
4321  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
4322 
4326  void SetLayerVisible(const wxString &name, bool viewable);
4327 
4331  bool IsLayerVisible(const wxString &name);
4332 
4336  bool IsLayerVisible(const unsigned int position);
4337 
4341  void SetLayerVisible(const unsigned int position, bool viewable);
4342 
4347  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
4348 
4351  const wxColour& GetAxesColour() const
4352  {
4353  return m_axColour;
4354  }
4355 
4357  const wxColour& GetbgColour() const
4358  {
4359  return m_bgColour;
4360  }
4361 
4363  void SetbgColour(const wxColour &colour)
4364  {
4365  m_bgColour = colour;
4366  }
4367 
4373  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
4374  {
4375  m_OnDeleteLayer = event;
4376  }
4377 
4380  {
4381  m_OnDeleteLayer = NULL;
4382  }
4383 
4388  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
4389  {
4390  m_OnUserMouseAction = userMouseEventHandler;
4391  }
4392 
4395  {
4396  m_OnUserMouseAction = NULL;
4397  }
4398 
4404  bool IsLogXaxis()
4405  {
4406  if (m_AxisDataX.axis)
4407  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
4408  else
4409  return false;
4410  }
4411 
4416  bool IsLogYaxis(int yAxisID)
4417  {
4418  assert(m_AxisDataYList.count(yAxisID) != 0);
4419  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4420  if (yAxis)
4421  return yAxis->IsLogAxis();
4422  else
4423  return false;
4424  }
4425 
4430  void SetLogXaxis(bool log)
4431  {
4432  if (m_AxisDataX.axis)
4433  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
4434  }
4435 
4441  void SetLogYaxis(int yAxisID, bool log)
4442  {
4443  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4444  if (yAxis)
4445  yAxis->SetLogAxis(log);
4446  }
4447 
4452  bool GetMagnetize() const
4453  {
4454  return m_magnet.IsEnabled();
4455  }
4456 
4458  void SetMagnetize(bool mag)
4459  {
4460  m_magnet.Enable(mag);
4461  }
4462 
4468  {
4469  m_mouseLeftDownAction = action;
4470  }
4471 
4477  {
4478  return m_mouseLeftDownAction;
4479  }
4480 
4486  {
4487  return m_mousePos;
4488  }
4489 
4495  {
4496  return m_movingInfoLayer;
4497  }
4498 
4499 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4500 
4504  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
4505 #endif // MP_ENABLE_CONFIG
4506 
4513  void RefreshConfigWindow(mpLayerType layerType, int param = 0, bool show = false);
4514 
4518  void OpenConfigWindow();
4519 
4523  void DeleteConfigWindow(void);
4524 
4529  void Paint(wxDC& dc);
4530 
4535  void RenderOverlays(wxDC& dc);
4536 
4542  wxMemoryDC *GetMemoryDC(void)
4543  {
4544  m_buff_dc.SelectObject(m_buff_bmp);
4545  return &m_buff_dc;
4546  }
4547 
4548  protected:
4549  virtual void BindEvents(void);
4550  virtual void OnPaint(wxPaintEvent &event);
4551  virtual void OnSize(wxSizeEvent &event);
4552  virtual void OnShowPopupMenu(wxMouseEvent &event);
4553  virtual void OnCenter(wxCommandEvent &event);
4554  virtual void OnFit(wxCommandEvent &event);
4555  virtual void OnToggleGrids(wxCommandEvent &event);
4556  virtual void OnToggleCoords(wxCommandEvent &event);
4557  virtual void OnScreenShot(wxCommandEvent &event);
4558  virtual void OnFullScreen(wxCommandEvent &event);
4559 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4560  virtual void OnConfiguration(wxCommandEvent &event);
4561 #endif // MP_ENABLE_CONFIG
4562  virtual void OnLoadFile(wxCommandEvent &event);
4563  virtual void OnZoomIn(wxCommandEvent &event);
4564  virtual void OnZoomOut(wxCommandEvent &event);
4565  virtual void OnLockAspect(wxCommandEvent &event);
4566  virtual void OnMouseHelp(wxCommandEvent &event);
4567  virtual void OnMouseLeftDown(wxMouseEvent &event);
4568  virtual void OnMouseRightDown(wxMouseEvent &event);
4569  virtual void OnMouseMove(wxMouseEvent &event);
4570  virtual void OnMouseLeftRelease(wxMouseEvent &event);
4571  virtual void OnMouseWheel(wxMouseEvent &event);
4572  virtual void OnMouseLeave(wxMouseEvent &event);
4573  bool CheckUserMouseAction(wxMouseEvent &event);
4574  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
4575  virtual void OnScrollPageUp(wxScrollWinEvent &event);
4576  virtual void OnScrollPageDown(wxScrollWinEvent &event);
4577  virtual void OnScrollLineUp(wxScrollWinEvent &event);
4578  virtual void OnScrollLineDown(wxScrollWinEvent &event);
4579  virtual void OnScrollTop(wxScrollWinEvent &event);
4580  virtual void OnScrollBottom(wxScrollWinEvent &event);
4581 
4583  void DoScrollCalc(const int position, const int orientation);
4584 
4589  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = MP_ZOOM_AROUND_CENTER);
4590 
4597  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = MP_ZOOM_AROUND_CENTER, mpOptional_int yAxisID = MP_OPTNULL_INT);
4598 
4603  void SetScaleXAndCenter(double scaleX);
4604 
4610  void SetScaleYAndCenter(double scaleY, int yAxisID);
4611 
4616  void Zoom(bool zoomIn, const wxPoint &centerPoint);
4617 
4620  virtual bool UpdateBBox();
4621 
4625  void DrawBoxZoom(wxDC& dc);
4626 
4630  void InitParameters();
4631 
4632  wxTopLevelWindow* m_parent;
4634 
4635  mpLayerList m_layers;
4637  mpAxisList m_AxisDataYList;
4638 
4639  wxMenu m_popmenu;
4641  wxColour m_bgColour;
4642  wxColour m_fgColour;
4643  wxColour m_axColour;
4644  bool m_drawBox;
4645 
4646  int m_scrX;
4647  int m_scrY;
4650 
4654  wxCoord m_plotWidth;
4655  wxCoord m_plotHeight;
4656 
4659  wxRect m_PlotArea;
4660 
4663  wxBitmap m_buff_bmp;
4664  wxMemoryDC m_buff_dc;
4670  wxPoint m_mousePos;
4671  wxPoint m_mouseRClick;
4672  wxPoint m_mouseLClick;
4673  double m_mouseScaleX;
4674  std::unordered_map<int, double> m_mouseScaleYList;
4677  bool m_autoFit;
4681 
4683 
4685 
4686  wxBitmap* m_Screenshot_bmp;
4687 
4688  wxString m_wildcard;
4689  wxString m_DefaultDir;
4690 
4691 #if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4692  MathPlotConfigDialog* m_configWindow = NULL;
4693 #endif // MP_ENABLE_CONFIG
4694  bool m_openConfigWindowPending = false;
4696 
4697  mpOnDeleteLayer m_OnDeleteLayer = NULL;
4698  mpOnUserMouseAction m_OnUserMouseAction = NULL;
4699 
4703  virtual void DesiredBoundsHaveChanged() {};
4704 
4705  private:
4707  void CheckAndReportDesiredBoundsChanges();
4708 
4713  unsigned int GetNewAxisDataID(void)
4714  {
4715  int newID = 0;
4716  for (const MP_LOOP_ITER : m_AxisDataYList)
4717  {
4718  if(m_yData.axis)
4719  {
4720  // This ID is used by an axis. Make sure the new ID is larger
4721  newID = std::max(newID, m_yID + 1);
4722  }
4723  }
4724  return newID;
4725  }
4726 
4728 
4729  // To have direct access to m_Screenshot_dc
4730  friend mpPrintout;
4731 };
4732 
4733 //-----------------------------------------------------------------------------
4734 // mpText - provided by Val Greene
4735 //-----------------------------------------------------------------------------
4736 
4745 {
4746  public:
4749  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
4750  {
4751  m_subtype = mptText;
4752  SetName(name);
4753  m_offsetx = 5;
4754  m_offsety = 50;
4755  m_location = mpMarginUser;
4756  m_ZIndex = mpZIndex_TEXT;
4757  }
4758 
4762  mpText(const wxString &name, int offsetx, int offsety);
4763 
4767  mpText(const wxString &name, mpLocation marginLocation);
4768 
4771  virtual bool HasBBox()
4772  {
4773  return false;
4774  }
4775 
4778  void SetLocation(mpLocation location)
4779  {
4780  m_location = location;
4781  }
4782 
4785  mpLocation GetLocation() const
4786  {
4787  return m_location;
4788  }
4789 
4792  void SetOffset(int offX, int offY)
4793  {
4794  m_offsetx = offX;
4795  m_offsety = offY;
4796  }
4797 
4799  void GetOffset(int *offX, int *offY) const
4800  {
4801  *offX = m_offsetx;
4802  *offY = m_offsety;
4803  }
4804 
4805  protected:
4808  mpLocation m_location;
4809 
4812  virtual void DoPlot(wxDC &dc, mpWindow &w);
4813 
4814  private:
4816 };
4817 
4822 {
4823  public:
4826  mpTitle();
4827 
4830  mpTitle(const wxString &name) :
4831  mpText(name, mpMarginTopCenter)
4832  {
4833  m_subtype = mptTitle;
4834  SetPen(*wxWHITE_PEN);
4835  SetBrush(*wxWHITE_BRUSH);
4836  }
4837 
4838  private:
4840 };
4841 
4842 //-----------------------------------------------------------------------------
4843 // mpPrintout - provided by Davide Rondini
4844 //-----------------------------------------------------------------------------
4845 
4850 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4851 {
4852  public:
4853  mpPrintout()
4854  {
4855  plotWindow = NULL;
4856  drawn = false;
4857  stretch_factor = 2;
4858  }
4859 
4865  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4866  virtual ~mpPrintout()
4867  {
4868  ;
4869  }
4870 
4874  void SetDrawState(bool drawState)
4875  {
4876  drawn = drawState;
4877  }
4878 
4880  bool OnPrintPage(int page);
4882  bool HasPage(int page);
4883 
4886  void SetFactor(int factor)
4887  {
4888  stretch_factor = factor;
4889  }
4890 
4891  private:
4892  bool drawn;
4893  mpWindow* plotWindow;
4894  int stretch_factor; // To reduce the size of plot
4895 
4897 };
4898 
4899 //-----------------------------------------------------------------------------
4900 // mpMovableObject - provided by Jose Luis Blanco
4901 //-----------------------------------------------------------------------------
4910 {
4911  public:
4915  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
4916  {
4917  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
4918  m_subtype = mpfMovable;
4919  }
4920 
4921  virtual ~mpMovableObject() {}
4922 
4925  void GetCoordinateBase(double &x, double &y, double &phi) const
4926  {
4927  x = m_reference_x;
4928  y = m_reference_y;
4929  phi = m_reference_phi;
4930  }
4931 
4934  void SetCoordinateBase(double x, double y, double phi = 0)
4935  {
4936  m_reference_x = x;
4937  m_reference_y = y;
4938  m_reference_phi = phi;
4939  m_flags = mpALIGN_SW;
4940  ShapeUpdated();
4941  }
4942 
4943  virtual bool HasBBox()
4944  {
4945  return m_trans_shape_xs.size() != 0;
4946  }
4947 
4950  virtual double GetMinX()
4951  {
4952  return m_bbox_x.min;
4953  }
4954 
4957  virtual double GetMaxX()
4958  {
4959  return m_bbox_x.max;
4960  }
4961 
4964  virtual double GetMinY()
4965  {
4966  return m_bbox_y.min;
4967  }
4968 
4971  virtual double GetMaxY()
4972  {
4973  return m_bbox_y.max;
4974  }
4975 
4976  protected:
4977 
4980  double m_reference_x;
4981  double m_reference_y;
4983 
4984  virtual void DoPlot(wxDC &dc, mpWindow &w);
4985 
4988  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
4989 
4990  // the object points, in local coordinates (to be transformed by the current transformation).
4991  std::vector<double> m_shape_xs;
4992  std::vector<double> m_shape_ys;
4993 
4994  // The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh).
4995  std::vector<double> m_trans_shape_xs;
4996  std::vector<double> m_trans_shape_ys;
4997 
5003 
5007  void ShapeUpdated();
5008 
5009  private:
5011 };
5012 
5013 //-----------------------------------------------------------------------------
5014 // mpCovarianceEllipse - provided by Jose Luis Blanco
5015 //-----------------------------------------------------------------------------
5028 {
5029  public:
5033  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
5034  const wxString &layerName = _T("")) : mpMovableObject(),
5035  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
5036  {
5037  m_continuous = true;
5038  m_name = layerName;
5039  RecalculateShape();
5040  }
5041 
5042  virtual ~mpCovarianceEllipse()
5043  {
5044  ;
5045  }
5046 
5049  double GetQuantiles() const
5050  {
5051  return m_quantiles;
5052  }
5053 
5056  void SetQuantiles(double q)
5057  {
5058  m_quantiles = q;
5059  RecalculateShape();
5060  }
5061 
5063  void SetSegments(int segments)
5064  {
5065  m_segments = segments;
5066  }
5067 
5069  int GetSegments() const
5070  {
5071  return m_segments;
5072  }
5073 
5076  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
5077  {
5078  cov_00 = m_cov_00;
5079  cov_01 = m_cov_01;
5080  cov_11 = m_cov_11;
5081  }
5082 
5085  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
5086  {
5087  m_cov_00 = cov_00;
5088  m_cov_01 = cov_01;
5089  m_cov_11 = cov_11;
5090  RecalculateShape();
5091  }
5092 
5093  protected:
5096  double m_cov_00;
5097  double m_cov_11;
5098  double m_cov_01;
5099  double m_quantiles;
5100 
5104 
5107  void RecalculateShape();
5108 
5109  private:
5111 };
5112 
5113 //-----------------------------------------------------------------------------
5114 // mpPolygon - provided by Jose Luis Blanco
5115 //-----------------------------------------------------------------------------
5121 {
5122  public:
5125  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
5126  {
5127  m_continuous = true;
5128  m_name = layerName;
5129  }
5130 
5131  virtual ~mpPolygon()
5132  {
5133  ;
5134  }
5135 
5141  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
5142 
5143  private:
5145 };
5146 
5147 //-----------------------------------------------------------------------------
5148 // mpBitmapLayer - provided by Jose Luis Blanco
5149 //-----------------------------------------------------------------------------
5155 {
5156  public:
5160  {
5161  m_validImg = false;
5162  m_bitmapChanged = false;
5163  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
5164  }
5165 
5166  virtual ~mpBitmapLayer()
5167  {
5168  ;
5169  }
5170 
5173  void GetBitmapCopy(wxImage &outBmp) const;
5174 
5182  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
5183 
5186  virtual double GetMinX()
5187  {
5188  return m_bitmapX.min;
5189  }
5190 
5193  virtual double GetMaxX()
5194  {
5195  return m_bitmapX.max;
5196  }
5197 
5200  virtual double GetMinY()
5201  {
5202  return m_bitmapY.min;
5203  }
5204 
5207  virtual double GetMaxY()
5208  {
5209  return m_bitmapY.max;
5210  }
5211 
5212  protected:
5213 
5216  wxImage m_bitmap;
5217  wxBitmap m_scaledBitmap;
5220  bool m_validImg;
5222 
5227 
5228  virtual void DoPlot(wxDC &dc, mpWindow &w);
5229 
5230  private:
5232 };
5233 
5234 // utility class
5235 
5237 typedef enum __mp_Colour
5238 {
5239  mpBlue,
5240  mpRed,
5241  mpGreen,
5242  mpPurple,
5243  mpYellow,
5244  mpFuchsia,
5245  mpLime,
5246  mpAqua,
5247  mpOlive
5248 } mpColour;
5249 
5254 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
5255 {
5256  public:
5261  wxIndexColour(unsigned int id)
5262  {
5263  switch (id)
5264  {
5265  case 0:
5266  this->Set(0, 0, 255);
5267  break; // Blue
5268  case 1:
5269  this->Set(255, 0, 0);
5270  break; // Red
5271  case 2:
5272  this->Set(0, 128, 0);
5273  break; // Green
5274  case 3:
5275  this->Set(128, 0, 128);
5276  break; // Purple
5277  case 4:
5278  this->Set(255, 255, 0);
5279  break; // Yellow
5280  case 5:
5281  this->Set(255, 0, 255);
5282  break; // Fuchsia
5283  case 6:
5284  this->Set(0, 255, 0);
5285  break; // Lime
5286  case 7:
5287  this->Set(0, 255, 255);
5288  break; // Aqua/Cyan
5289  case 8:
5290  this->Set(128, 128, 0);
5291  break; // Olive
5292  default:
5293  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
5294  (ChannelType)((rand() * 255) / RAND_MAX));
5295  }
5296  }
5297 };
5298 
5301 // ---------------------------------------------------------------------
5302 #if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
5303  }// namespace MathPlot
5304 #endif // MP_ENABLE_NAMESPACE
5305 
5306 #endif // MATHPLOT_H_INCLUDED
sub type for mpFXYVector function
Definition: mathplot.h:762
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:4807
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2835
bool m_enableBufferedPaintDC
For auto DC double buffering.
Definition: mathplot.h:4666
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer.
Definition: mathplot.h:3273
bool IsHorizontal(void) const
Is it a horizontal line?
Definition: mathplot.h:1836
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:664
int GetAxisID(void)
Return the ID of the Axis.
Definition: mathplot.h:2764
mpRange< double > m_rangeY
Y range.
Definition: mathplot.h:2423
sub type for mpText layer
Definition: mathplot.h:751
Align the plot label towards the southeast.
Definition: mathplot.h:703
wxMemoryDC m_buff_dc
DC for double buffering.
Definition: mathplot.h:4664
void SetValue(const double value)
Set x or y value.
Definition: mathplot.h:1828
mpInfoLegend * m_InfoLegend
Pointer to the optional info legend layer.
Definition: mathplot.h:4680
Draw a circle.
Definition: mathplot.h:726
enum __YAxis_Align_Type mpYAxis_Align
Alignment for Y axis.
Show legend items with small square with the same color of referred mpLayer.
Definition: mathplot.h:711
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:4652
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:2992
int m_infoLegendSelectedSeries
Only used with config window: the selected series in info legend.
Definition: mathplot.h:4695
bool m_LegendIsAlwaysVisible
If true, the name is visible in the legend despite the visibility of the function. Default false.
Definition: mathplot.h:1790
size_t m_endIndex
The end index indicating the last point inside plot area.
Definition: mathplot.h:2247
void EnableDoubleBuffer(const bool enabled)
Deprecated: Enable/disable the double-buffering of the window, eliminating the flicker (default=enabl...
Definition: mathplot.h:3804
wxIndexColour(unsigned int id)
Constructor.
Definition: mathplot.h:5261
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:1075
bool IsLogYaxis(int yAxisID)
Get the log property (true or false) Y layer (Y axis) with a specific Y ID or false if not found...
Definition: mathplot.h:4416
std::vector< std::string > labels
Labels of the Values.
Definition: mathplot.h:2557
enum __mp_Colour mpColour
Enumeration of classic colour.
Bitmap type layer.
Definition: mathplot.h:841
static bool m_DefaultLegendIsAlwaysVisible
This value sets the default behaviour when a series is not visible for the legend display...
Definition: mathplot.h:4127
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1205
#define MP_LOOP_ITER
Helper macro for iterating through axis maps without structured binding.
Definition: mathplot.h:139
mpLegendDirection m_item_direction
Layout direction used when arranging legend entries.
Definition: mathplot.h:1600
__Scale_Type
sub_type values for mpLAYER_AXIS
Definition: mathplot.h:769
Plot type layer.
Definition: mathplot.h:826
void Show(bool show)
Set if magnet shall be shown or hidden.
Definition: mathplot.h:3328
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:3737
wxPoint GetMousePosition()
Returns current mouse position in window.
Definition: mathplot.h:4485
void SetLegendIsAlwaysVisible(bool alwaysVisible)
Set the visibility of the name of the function in the legend despite the visibility of the function i...
Definition: mathplot.h:1741
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:5207
bool IsRightAxis()
Return true if this Y axis is aligned to the right side.
Definition: mathplot.h:3174
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:1435
User defined position. Can be change by mouse drag.
Definition: mathplot.h:674
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:4379
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1893
void SetYAxisID(unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1733
std::map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:3250
bool ShouldBeShown(wxRect plotArea, wxPoint mousePos)
Check conditions if info coords shall be shown or not.
Definition: mathplot.h:1427
mpLegendStyle GetItemMode() const
Get the current legend item drawing mode.
Definition: mathplot.h:1525
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:5120
#define MP_X_RAWTIME
Shortcut for MP_X_UTCTIME.
Definition: mathplot.h:209
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:3540
mpFloatRectSimple(mpRange< double > _x, mpRange< double > _y)
Construct a simple rectangular box.
Definition: mathplot.h:609
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:953
__Symbol_Type
Displaying a symbol instead of a point in the plot function.
Definition: mathplot.h:723
double m_deltaY
Min delta between 2 consecutive coordinate on y direction.
Definition: mathplot.h:2127
void SetCoordIsAlwaysVisible(bool alwaysVisible)
Set the visibility of the mouse coordinates in the info coordinates despite the visibility of the axi...
Definition: mathplot.h:2966
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:2174
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:4648
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:710
__mp_Layer_Type
Major type of an mpLayer (detail is in subtype)
Definition: mathplot.h:822
wxBitmap m_buff_bmp
Bmp for double buffering.
Definition: mathplot.h:4663
Show/Hide grids.
Definition: mathplot.h:652
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:5154
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:2983
void InitializeBoundingBox(double px, double py, int yAxisID)
Initialize the bounding box from a first point for the selected Y axis.
Definition: mathplot.h:4049
mpLabelType
enum for label for grid
Definition: mathplot.h:794
void Update(T value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:389
bool m_mouseMovedAfterRightClick
If the mouse does not move after a right click, then the context menu is displayed.
Definition: mathplot.h:4669
Classic Normal distribution f(x) = exp(-(ln(x)-μ)²/2σ²)/(xσ.sqrt(2π))
Definition: mathplot.h:2476
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2697
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:4671
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:2681
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5125
double m_lastX
Last x-coordinate point added.
Definition: mathplot.h:2249
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2801
bool m_showDraggedSeries
Indicate if series that has been gripped with mouse shall be drawn.
Definition: mathplot.h:1601
wxCoord y2p(const double y, int yAxisID=0)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:3794
enum __Plot_Align_Name_Type mpPlot_Align
Plot alignment (which corner should plot be placed)
mpRange< double > m_bitmapX
The shape of the bitmap:
Definition: mathplot.h:5225
Layer type undefined; SHOULD NOT BE USED.
Definition: mathplot.h:824
enum __mp_Direction_Type mpLegendDirection
Direction for the Legend layer.
virtual double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:2312
__mp_Delete_Action
Action to do with the object associated to the layer when we delete it.
Definition: mathplot.h:857
sub type not defined (should be never used)
Definition: mathplot.h:771
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1204
void SetMagnetize(bool mag)
Enable or disable mouse-position magnet lines (cross-hairs) in the plot area.
Definition: mathplot.h:4458
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1197
double m_cov_11
Covariance matrix element (1,1).
Definition: mathplot.h:5097
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1812
Lock x/y scaling aspect.
Definition: mathplot.h:651
virtual double GetMinY()
Get min Y of the function.
Definition: mathplot.h:2408
void SetMaxNOfPoints(size_t nOfPoints)
Set how many points that is allowed to be drawn at a time.
Definition: mathplot.h:1772
void SetItemMode(mpLegendStyle mode)
Set item mode (the element on the left of text representing the plot line may be line, square, or line with symbol).
Definition: mathplot.h:1518
wxString m_wildcard
For loadfile() function when we use wxFileDialog.
Definition: mathplot.h:4688
Align the info in margin center-bottom.
Definition: mathplot.h:672
int m_axisWidth
Reserved width for this Y axis including labels, in pixels.
Definition: mathplot.h:3190
Info box type layer.
Definition: mathplot.h:846
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:4806
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set axis label view mode.
Definition: mathplot.h:2827
Abstract class providing a line.
Definition: mathplot.h:1800
mpRange< double > m_rangeX
Range min and max on x axis.
Definition: mathplot.h:2248
Abstract class providing an vertical line.
Definition: mathplot.h:1880
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2787
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2660
bool IsLeftAxis()
Return true if this Y axis is aligned to the left side.
Definition: mathplot.h:3168
double m_reference_y
Current object Y position in plot coordinates.
Definition: mathplot.h:4981
bool m_show
Indicates if magnet shall be shown in plot.
Definition: mathplot.h:1475
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:3366
#define MP_ZOOM_AROUND_CENTER
Default value for zoom around a point (default -1 is no zoom)
Definition: mathplot.h:220
virtual double GetMinY() override
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:2290
mpRange< int > m_drawY
Range min and max on y axis.
Definition: mathplot.h:2123
wxString m_DefaultDir
The default directory for wxFileDialog.
Definition: mathplot.h:4689
enum __Info_Type mpInfoType
sub_type values for mpLAYER_INFO
wxPen m_gridpen
Grid&#39;s pen. Default Colour = LIGHT_GREY, width = 1, style = wxPENSTYLE_DOT.
Definition: mathplot.h:2984
int m_labelPos
Bar-label placement mode.
Definition: mathplot.h:2626
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3695
double p2y(const wxCoord pixelCoordY, int yAxisID=0)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:3775
std::vector< double > m_ys
internal copy of the set of data on y direction
Definition: mathplot.h:2243
void SetExtraMargin(int extra)
Set the extra margin.
Definition: mathplot.h:4243
mpScaleY(const wxString &name=_T("Y"), int flags=mpALIGN_CENTERY, bool grids=false, mpOptional_uint yAxisID=-1, mpLabelType labelType=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:3149
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1352
bool m_bitmapChanged
True when the cached scaled bitmap must be regenerated.
Definition: mathplot.h:5221
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:4934
bool m_isMonotonicX
Indicates if all all X values are monotonic, i.e increasing, which enables binary search...
Definition: mathplot.h:2244
Chart type layer (bar chart)
Definition: mathplot.h:831
mpRange< double > x
range over x direction
Definition: mathplot.h:601
double GetPosY(int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3686
virtual void SetLogAxis(bool log)
Set Logarithmic mode.
Definition: mathplot.h:2958
double GetQuantiles() const
Get the confidence-interval multiplier used for the ellipse.
Definition: mathplot.h:5049
sub type for mpLine function
Definition: mathplot.h:764
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:1052
void SetAutoFit(bool autoFit)
Set if plot shall be auto fitted when hiding or showing axis and series via mouse.
Definition: mathplot.h:4149
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3834
~mpBarChart()
Destructor.
Definition: mathplot.h:2585
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:3767
T GetMaxAbs(void) const
Max absolute value of the range.
Definition: mathplot.h:444
Draw a cross X.
Definition: mathplot.h:730
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition: mathplot.h:411
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1212
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:264
double m_width
Width of each bar/column in plot units.
Definition: mathplot.h:2624
Draw a triangle up oriented.
Definition: mathplot.h:728
wxTopLevelWindow * m_parent
Pointer to the top-level window containing the plot (used for fullscreen)
Definition: mathplot.h:4632
void SetDefaultLegendIsAlwaysVisible(bool visible)
Set if legend is always visible even if series is not plotted.
Definition: mathplot.h:4134
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:4672
bool IsEnabled() const
Check if magnet is enabled.
Definition: mathplot.h:3313
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:4703
T min
The min value of the range.
Definition: mathplot.h:309
double m_relY
Box Y position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1355
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:1060
int m_flags
Holds label alignment. Default : mpALIGN_SW for series and mpALIGN_CENTER for scale.
Definition: mathplot.h:1209
wxRect GetRect(void)
Create rectangular area defined by start and end points.
Definition: mathplot.h:294
mpRange< double > m_bbox_x
The precomputed bounding box:
Definition: mathplot.h:5001
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:4771
Mouse action drag the plot.
Definition: mathplot.h:790
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:937
mpNormal(double mu, double sigma)
Classic Normal distribution.
Definition: mathplot.h:2484
mpInfoLayer * GetMovingInfoLayer()
Returns moving info layer.
Definition: mathplot.h:4494
wxPoint GetPosition() const
Get the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1309
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1464
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:1115
~mpPieChart()
Destructor.
Definition: mathplot.h:2651
mpRange()
Default constructor.
Definition: mathplot.h:313
T max
The max value of the range.
Definition: mathplot.h:310
void Show(bool show)
Set if info coords shall be shown or hidden.
Definition: mathplot.h:1411
sub type not defined (should be never used)
Definition: mathplot.h:780
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1787
void SetDefaultDir(const wxString &dirname)
Set the default directory for wxFileDialog.
Definition: mathplot.h:4115
enum __Function_Type mpFunctionType
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
sub type not defined (should be never used)
Definition: mathplot.h:758
void Check(void)
Check to always have a range. If min = max then introduce the 0 to make a range.
Definition: mathplot.h:420
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:4262
sub type not defined (should be never used)
Definition: mathplot.h:750
double m_lastY
Last y-coordinate point added.
Definition: mathplot.h:2251
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1199
T GetCenter(void) const
Center of the range.
Definition: mathplot.h:438
Just the end of ZOrder.
Definition: mathplot.h:848
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4964
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:839
void Set(T _value)
Initialize min and max.
Definition: mathplot.h:335
virtual double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:2297
mpRange< double > m_axisRange
Range axis values when autosize is false.
Definition: mathplot.h:2988
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:4186
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:4122
double m_cov_01
Covariance matrix element (0,1), equal to element (1,0).
Definition: mathplot.h:5098
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1292
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1661
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:4256
Draw a plus +.
Definition: mathplot.h:731
void SetMouseLeftDownAction(mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:4467
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:4639
Keep the object, just remove the layer from the layer list.
Definition: mathplot.h:859
double m_mu
Mean value.
Definition: mathplot.h:2458
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:4673
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1983
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:2048
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:4643
wxColour m_barColour
Fill colour used for the bars.
Definition: mathplot.h:2625
Delete the object regardless of the CanDelete value and remove it from the layer list.
Definition: mathplot.h:861
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:1207
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:4657
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:4925
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:3281
Align the plot label towards the southwest.
Definition: mathplot.h:704
Implement the legend to be added to the plot This layer allows you to add a legend to describe the pl...
Definition: mathplot.h:1500
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:3084
double m_quantiles
Confidence-interval multiplier used when drawing the ellipse.
Definition: mathplot.h:5099
Align the y-axis towards left border.
Definition: mathplot.h:691
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1208
#define ISNOTNULL(x)
Nullity test. Old solution is to test according small epsilon: (fabs(x) > MP_EPSILON) ...
Definition: mathplot.h:214
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:4778
Align the x-axis towards bottom border.
Definition: mathplot.h:681
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2550
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3818
void Assign(T value1, T value2)
Assign values to min and max.
Definition: mathplot.h:365
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:4644
Plot (function) type layer.
Definition: mathplot.h:844
void UpdateDesiredBoundingBox(mpAxisUpdate update)
Update m_desired bounds.
Definition: mathplot.h:3929
void UpdateBoundingBoxToInclude(double px, double py)
Update bounding box (X and Y axis) to include this point.
Definition: mathplot.h:625
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2851
bool m_IsHorizontal
Is the line horizontal? Default false.
Definition: mathplot.h:1843
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1211
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1697
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:890
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1200
bool GetCoordIsAlwaysVisible() const
Get the visibility of the mouse coordinates in the info coordinates.
Definition: mathplot.h:2974
virtual int 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:2206
bool GetCanDelete(void) const
Retreive what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1184
Axis type layer.
Definition: mathplot.h:842
Dialog box for configuring the plot&#39;s layer objects In this dialog, you can configure: ...
Definition: MathPlotConfig.h:154
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:2705
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:2987
Draw a triangle down oriented.
Definition: mathplot.h:729
wxCoord m_mouseY
Last mouse Y position in window pixel coordinates.
Definition: mathplot.h:1480
Axis type layer.
Definition: mathplot.h:825
void SetCanDelete(bool canDelete)
Set what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1177
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:5186
bool GetMagnetize() const
Is mouse magnetization enabled? Useful to read the position on the axes.
Definition: mathplot.h:4452
double m_value
The x or y coordinates of the line.
Definition: mathplot.h:1842
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:4678
void Enable(bool enable)
Enables the magnet.
Definition: mathplot.h:3307
wxPen m_penSeries
Pen used to draw the series marker when series-coordinate mode is active.
Definition: mathplot.h:1482
wxPoint m_center
Center of the pie chart in device coordinates.
Definition: mathplot.h:2713
std::vector< double > m_trans_shape_ys
Transformed shape vertices in Y coordinates.
Definition: mathplot.h:4996
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:2989
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:1394
#define MP_Y_BORDER_SEPARATION
Default minimum separation in pixels between Y axes and the plot border.
Definition: mathplot.h:202
size_t GetMaxNOfPoints() const
Get maximum number of points to plot.
Definition: mathplot.h:1779
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:2794
Align the info in margin center-right.
Definition: mathplot.h:670
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:4351
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:1094
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:3220
void SetDrawState(bool drawState)
Set whether the plot has already been drawn on the current printout.
Definition: mathplot.h:4874
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:4749
mpRange< double > lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:3238
double m_const
Const factor.
Definition: mathplot.h:2461
std::unordered_map< int, mpRange< double > > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:3624
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:5216
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:4388
void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
Ensure the bounding box includes the given point for the selected Y axis.
Definition: mathplot.h:4034
each visible plot is described on its own line, one above the other
Definition: mathplot.h:718
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:3651
int m_xPos
Leftmost X pixel occupied by this axis (starting point).
Definition: mathplot.h:3191
Align the x-axis towards top plot.
Definition: mathplot.h:684
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1191
mpRange< double > bound
Range min and max.
Definition: mathplot.h:3236
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:797
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:4268
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:1450
Align the y-axis towards right border.
Definition: mathplot.h:695
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:739
std::unordered_map< int, mpRange< double > > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:3638
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:2246
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:5193
Show/Hide info coord.
Definition: mathplot.h:653
Align the x-axis towards top border.
Definition: mathplot.h:685
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:1108
Mouse action draw a box to zoom inside.
Definition: mathplot.h:789
mpFXGeneric(const wxString &name=wxT("Generic FX function"), int flags=mpALIGN_LEFT, unsigned int yAxisID=0)
Definition: mathplot.h:2375
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:5085
__Function_Type
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
Definition: mathplot.h:756
Classic Gaussian distribution f(x) = exp(-(x-μ)²/2σ²)/sqrt(2πσ²)
Definition: mathplot.h:2440
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition: mathplot.h:85
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4850
Align the y-axis towards left plot.
Definition: mathplot.h:692
int m_last_ly
Last logical Y origin, used for double buffering.
Definition: mathplot.h:4662
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:4684
size_t m_maxNOfPoints
Maximum number of points to draw to screen.
Definition: mathplot.h:1792
wxSize GetSize() const
Get the size of the box (in pixels)
Definition: mathplot.h:1324
Chart type layer.
Definition: mathplot.h:845
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:2986
Set label for axis in scientific notation.
Definition: mathplot.h:801
enum __mp_Location_Type mpLocation
Location for the Info layer.
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:401
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1351
Copy a screen shot to the clipboard.
Definition: mathplot.h:654
Fit view to match bounding box of all layers.
Definition: mathplot.h:647
Create a generic FX function Override the ComputeY() function with your function. ...
Definition: mathplot.h:2368
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:4785
bool PointIsInside(double px, double py) const
Is point inside this bounding box?
Definition: mathplot.h:616
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:660
mpRange< double > m_bitmapY
Range of the bitmap on y direction.
Definition: mathplot.h:5226
bool IsShown()
Get shown status.
Definition: mathplot.h:3334
bool m_cacheDirty
Indicate that the cached buffer m_buff_bmp need to be re-created.
Definition: mathplot.h:4665
Center view on click position.
Definition: mathplot.h:650
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1788
mpLegendStyle m_item_mode
Visual style used for each legend entry.
Definition: mathplot.h:1599
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:2186
bool m_autoFit
Automatically fit plot when hiding / showing axis and series.
Definition: mathplot.h:4677
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:679
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1407
sub type for all layers who are function.
Definition: mathplot.h:765
Draw a square.
Definition: mathplot.h:727
mpRange< double > GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:3591
bool operator==(const mpAxisData &other) const
Compare axis data while ignoring the axis pointer itself.
Definition: mathplot.h:3242
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:4909
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2496
Align the x-axis center plot.
Definition: mathplot.h:683
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:748
double m_radius
Radius of the pie chart in pixels.
Definition: mathplot.h:2712
double m_deltaX
Min delta between 2 consecutive coordinate on x direction.
Definition: mathplot.h:2126
__mp_Colour
Enumeration of classic colour.
Definition: mathplot.h:5237
mpRange< double > GetDesiredBoundY(int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3614
int m_BarWidth
Bar width in pixels when the XY series is drawn in bar mode.
Definition: mathplot.h:2129
Align the plot label towards the northwest.
Definition: mathplot.h:701
double m_total_value
Total of the values vector.
Definition: mathplot.h:2560
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:4637
void SetMinScale(double min)
Set the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2875
void SetbgColour(const wxColour &colour)
Set the plot background colour.
Definition: mathplot.h:4363
bool GetAutoStep() const
Get if auto stop is enabled.
Definition: mathplot.h:1764
void SetHovering(bool hover)
Set if axis shall be highlighted when a series is dragged over it.
Definition: mathplot.h:2942
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:2074
std::vector< double > m_shape_xs
Shape vertices in object-local X coordinates.
Definition: mathplot.h:4991
virtual bool IsLogAxis()
Get if we are in Logarithmic mode.
Definition: mathplot.h:2950
virtual double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:2275
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1704
mpRange< double > desired
Desired range min and max.
Definition: mathplot.h:3237
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:3092
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:5254
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1789
mpRange(T value1, T value2)
Create range with the 2 values.
Definition: mathplot.h:320
bool IsTopAxis()
Return true when this X axis is aligned at the top edge or top border.
Definition: mathplot.h:3099
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1669
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:4653
No symbol is drawing.
Definition: mathplot.h:725
Layer for bar chart.
Definition: mathplot.h:2578
mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:3954
void SetAutoStep(bool enable)
Enables auto step which is used to plot a maximum nuber of points at a time to the plot no matter zoo...
Definition: mathplot.h:1757
__Chart_Type
sub_type values for mpLAYER_CHART
Definition: mathplot.h:778
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1202
wxCoord m_scaledBitmap_offset_x
Cached X pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5218
virtual double ComputeY(double x)
The main computation of the FX function.
Definition: mathplot.h:2499
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2460
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:1476
abstract Layer for chart (bar and pie).
Definition: mathplot.h:2519
void SetInitialPosition(wxPoint pos)
Set the position in percent of the upper left corner of the box.
Definition: mathplot.h:1316
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:712
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:599
sub type for all layers who are chart.
Definition: mathplot.h:783
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:1068
unsigned int mpOptional_uint
Optional unsigned integer fallback type used when std::optional is unavailable.
Definition: mathplot.h:128
Align the info in margin center-left.
Definition: mathplot.h:666
void SetLabelFormat(const wxString &format, bool updateLabelMode=false)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2810
const wxRect & GetRectangle() const
Get the current rectangle coordinates.
Definition: mathplot.h:1331
double GetDesiredXmin() const
Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:3966
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:799
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:699
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1786
double GetDesiredYmin(int yAxisID)
Return the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:3985
void ToLog(void)
Convert to log range.
Definition: mathplot.h:450
void ShowDraggedSeries(bool active)
Set if dragged series shall be shown or hidden.
Definition: mathplot.h:1552
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:4209
mpRange< double > m_rangeY
Range min and max on y axis.
Definition: mathplot.h:2250
bool operator!=(const mpRange &other) const
Compare two ranges for inequality.
Definition: mathplot.h:471
bool IsDraggedSeriesShown() const
Get shown status of dragged series.
Definition: mathplot.h:1559
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5200
sub type for mpInfoLegend layer
Definition: mathplot.h:744
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2867
void SetLogXaxis(bool log)
Enable or disable logarithmic scaling on the X axis.
Definition: mathplot.h:4430
int GetMarginRight(bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:4194
#define MP_EPSILON
An epsilon for float comparison to 0.
Definition: mathplot.h:212
mpRange< int > m_drawX
Range min and max on x axis.
Definition: mathplot.h:2122
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1865
void SetReserve(int reserve)
Set memory reserved for m_xs and m_ys Note : this does not modify the size of m_xs and m_ys...
Definition: mathplot.h:2226
bool ShouldBeShown(wxPoint mousePos)
Check conditions if magnet shall be shown.
Definition: mathplot.h:3322
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:2236
double GetDesiredYmax(int yAxisID)
Return the top layer-border coordinate that the user wants the mpWindow to show (it may be not exactl...
Definition: mathplot.h:3996
bool GetLegendIsAlwaysVisible() const
Get the visibility of the legend.
Definition: mathplot.h:1749
Text box type layer.
Definition: mathplot.h:828
mpMouseButtonAction GetMouseLeftDownAction()
Returns the type of action for the left mouse button.
Definition: mathplot.h:4476
double pos
Position.
Definition: mathplot.h:3235
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:4163
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:689
sub type for mpBarChart
Definition: mathplot.h:781
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:4659
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1257
Load a file.
Definition: mathplot.h:658
enum __Symbol_Type mpSymbol
Displaying a symbol instead of a point in the plot function.
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:902
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:4799
bool m_fullscreen
Boolean value indicating that we are in fullscreen mode (default false)
Definition: mathplot.h:4633
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:4654
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:1284
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:910
Line (horizontal or vertical) type layer.
Definition: mathplot.h:843
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1378
double m_mu
Mean value.
Definition: mathplot.h:2494
mpRange< double > y
range over y direction
Definition: mathplot.h:602
mpLocation m_location
The location of the text.
Definition: mathplot.h:4808
Delete the object if CanDelete is true and remove it from the layer list.
Definition: mathplot.h:860
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:4064
mpLabelType m_labelType
Label formatting mode used for the X coordinate display.
Definition: mathplot.h:1477
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:4647
sub type for mpTitle layer
Definition: mathplot.h:752
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:3786
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1676
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:4636
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1514
double GetMaxScale() const
Get the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2899
Align the info in margin center-top.
Definition: mathplot.h:668
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:808
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:4641
bool IsLogXaxis()
Is this an X axis to be displayed with log scale? It is really an axis property but as we need to con...
Definition: mathplot.h:4404
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3713
int GetBarWidth(void) const
Get the width of the bar when we plot in bar mode.
Definition: mathplot.h:2105
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:4373
double m_labelAngle
Rotation angle used for bar labels, in degrees.
Definition: mathplot.h:2627
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1443
void SetAxisID(unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2773
int mpOptional_int
Optional integer fallback type used when std::optional is unavailable.
Definition: mathplot.h:130
void SetMin(T _min)
Set min function, correct max.
Definition: mathplot.h:349
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:4302
double m_max_value
Max value of the values vector.
Definition: mathplot.h:2559
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1648
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1921
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2668
mpTitle(const wxString &name)
Definition: mathplot.h:4830
void EnableBufferedPaintDC(const bool enabled)
Enable/disable the auto buffering of PaintDC.
Definition: mathplot.h:3811
Plot layer implementing a simple title.
Definition: mathplot.h:4821
Set no label for axis (useful for bar)
Definition: mathplot.h:814
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:3139
bool m_validImg
True when the source image is valid and ready to draw.
Definition: mathplot.h:5220
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:787
#define MP_OPTNULL_INT
Null sentinel used for mpOptional_int / mpOptional_uint in the fallback implementation.
Definition: mathplot.h:132
sub type for mpPieChart
Definition: mathplot.h:782
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:4943
bool ViewAsBar(void) const
Get if we are in bar mode.
Definition: mathplot.h:2114
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1356
mpRange< double > GetBoundY(int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3605
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:1142
mpGaussian(double mu, double sigma)
Classic Gaussian distribution.
Definition: mathplot.h:2448
Align the plot label towards the northeast.
Definition: mathplot.h:702
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:4277
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:3662
only for mpInfoCoords
Definition: mathplot.h:675
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1170
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1206
std::vector< double > m_trans_shape_xs
Transformed shape vertices in X coordinates.
Definition: mathplot.h:4995
mpLegendDirection GetItemDirection() const
Get the current legend item layout direction.
Definition: mathplot.h:1539
int GetAxisWidth()
Get the reserved width of the Y axis in pixels.
Definition: mathplot.h:3162
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:4250
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2859
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:2066
virtual double ComputeY(double x)
The main computation of the FX function.
Definition: mathplot.h:2463
sub type for mpFXY function
Definition: mathplot.h:761
wxCoord m_mouseX
Last mouse X position in window pixel coordinates.
Definition: mathplot.h:1479
enum __XAxis_Align_Type mpXAxis_Align
Alignment for X axis.
void UpdateBox(const wxRect &plotArea)
Update the drawable magnet area from a wxRect.
Definition: mathplot.h:3301
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1785
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:4394
enum __Chart_Type mpChartType
sub_type values for mpLAYER_CHART
bool IsBottomAxis()
Return true when this X axis is aligned at the bottom edge or bottom border.
Definition: mathplot.h:3105
std::vector< double > m_xs
internal copy of the set of data on x direction
Definition: mathplot.h:2242
void SetScale(mpRange< double > range)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2926
mpRange< double > GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:3597
#define m_yID
Alias for the Y-axis identifier when structured binding is unavailable.
Definition: mathplot.h:141
~mpChart()
Destructor.
Definition: mathplot.h:2526
bool GetBoundingBox(mpRange< double > *boundX, mpRange< double > *boundY, int yAxisID)
Return the bounding box coordinates for the Y axis of ID yAxisID.
Definition: mathplot.h:4007
virtual double GetY(double x)
Get function value for argument.
Definition: mathplot.h:2389
Abstract class providing an horizontal line.
Definition: mathplot.h:1851
Zoom into view at clickposition / window center.
Definition: mathplot.h:648
int GetMarginLeft(bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:4234
wxBitmap m_scaledBitmap
Cached scaled bitmap used for drawing.
Definition: mathplot.h:5217
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:4640
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:5103
int GetSegments() const
Get the number of line segments used to approximate the ellipse. */.
Definition: mathplot.h:5069
bool m_enableScrollBars
Enable scrollbar in plot window (default false)
Definition: mathplot.h:4676
double scale
Scale.
Definition: mathplot.h:3234
Align the info in margin top-left.
Definition: mathplot.h:667
bool IsSet()
Check if this mpRange has been assigned any values.
Definition: mathplot.h:380
Zoom out.
Definition: mathplot.h:649
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2741
enum __mp_Layer_Type mpLayerType
Major type of an mpLayer (detail is in subtype)
void SetFont(const wxFont &font)
Set layer font.
Definition: mathplot.h:1028
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:3287
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:4142
void SetBrush(const wxColour &colour, enum wxBrushStyle style=wxBRUSHSTYLE_SOLID)
Set layer brush.
Definition: mathplot.h:1086
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:3115
double GetMinScale() const
Get the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2883
double m_relX
Box X position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1354
int m_reserveXY
Memory reserved for m_xs and m_ys. Default 1000.
Definition: mathplot.h:2245
bool PointIsInside(T point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:457
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:716
sub type for mpInfoLayer layer
Definition: mathplot.h:742
Align the x-axis towards bottom plot.
Definition: mathplot.h:682
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:5027
virtual double GetMaxY()
Get max Y of the function.
Definition: mathplot.h:2417
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2819
int GetMarginTop(bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:4177
mpInfoCoords * m_InfoCoords
Pointer to the optional info coords layer.
Definition: mathplot.h:4679
double GetDesiredXmax() const
Return the right-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:3975
bool m_series_coord
True to show the nearest plotted series value instead of raw mouse Y coordinates. ...
Definition: mathplot.h:1481
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:806
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:3231
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:708
const wxColour & GetbgColour() const
Get the plot background colour.
Definition: mathplot.h:4357
Layer for pie chart.
Definition: mathplot.h:2642
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:1044
Align the y-axis towards right plot.
Definition: mathplot.h:694
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:2917
T Length(void) const
Length of the range.
Definition: mathplot.h:432
sub type for mpScaleX
Definition: mathplot.h:772
bool PointIsInsideBound(double px, double py, int yAxisID)
Is the given point inside the current bounding box for the selected Y axis?
Definition: mathplot.h:4021
sub type for mpInfoCoords layer
Definition: mathplot.h:743
bool m_CoordIsAlwaysVisible
If true, the mouse coordinates is visible in the info coordinates despite the visibility of the axis...
Definition: mathplot.h:2994
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:483
Set label user defined.
Definition: mathplot.h:812
void SetColumnWidth(const double colWidth)
Set the bar width in plot units.
Definition: mathplot.h:2594
mpCovarianceEllipse(double cov_00=1, double cov_11=1, double cov_01=0, double quantiles=2, int segments=32, const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5033
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:1036
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:4667
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1201
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:3671
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:804
sub type not defined (should be never used)
Definition: mathplot.h:741
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:810
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:5076
void SetMax(T _max)
Set max function, correct min.
Definition: mathplot.h:357
Bitmap type layer.
Definition: mathplot.h:829
HitCode
Return codes for GetLegendHitRegion() if no series was hit.
Definition: mathplot.h:1589
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1338
bool IsVisible() const
Is this layer visible?
Definition: mathplot.h:1135
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:2780
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:918
bool IsShown()
Get shown status.
Definition: mathplot.h:1418
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:1156
int m_last_lx
Last logical X origin, used for double buffering.
Definition: mathplot.h:4661
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1711
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2990
Align the info in margin bottom-left.
Definition: mathplot.h:671
const wxString & GetWildcard(void) const
Get wildcard.
Definition: mathplot.h:4097
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:4914
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:760
Info box type layer.
Definition: mathplot.h:827
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:3758
mpOptional_int m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:4675
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3748
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3703
wxCoord m_scaledBitmap_offset_y
Cached Y pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5219
Align the y-axis center plot.
Definition: mathplot.h:693
virtual bool DoBeforePlot()
This is the only case where we don&#39;t need and Y axis So no need to test m_yAxisID.
Definition: mathplot.h:1906
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:961
Plot layer implementing a text string.
Definition: mathplot.h:4744
virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
Set the layer&#39;s subtype in caller variable, and return true if the layer is of type "typeOfInterest"...
Definition: mathplot.h:928
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:4655
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4971
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:4542
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:4308
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:1122
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1203
double m_sigma
Sigma value.
Definition: mathplot.h:2459
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:4203
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:945
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1353
int GetMarginBottom(bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:4217
Shows information about the mouse commands.
Definition: mathplot.h:659
void SetLogYaxis(int yAxisID, bool log)
Set the log property (true or false) for a Y layer (Y axis) given by is ID.
Definition: mathplot.h:4441
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:4169
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:3554
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:4642
mpRange< double > m_bbox_y
Range of bounding box on y direction.
Definition: mathplot.h:5002
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:4686
legend components follow each other horizontally on a single line
Definition: mathplot.h:719
Align the info in margin top-right.
Definition: mathplot.h:669
double m_reference_phi
Current object rotation angle in radians.
Definition: mathplot.h:4982
void InitializeBoundingBox(double px, double py)
Initialize bounding box with an initial point.
Definition: mathplot.h:635
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1532
enum __Text_Type mpTextType
sub_type values for mpLAYER_TEXT
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see GetQuantiles a...
Definition: mathplot.h:5056
double m_const
Const factor.
Definition: mathplot.h:2497
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1724
void SetSegments(int segments)
Set the number of line segments used to approximate the ellipse.
Definition: mathplot.h:5063
sub type for all layers who are scale.
Definition: mathplot.h:774
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:4649
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:307
void Set(T _min, T _max)
Set min, max function.
Definition: mathplot.h:342
Align the info in margin bottom-right.
Definition: mathplot.h:673
bool m_boxZoomActive
Indicate if box zoom is active.
Definition: mathplot.h:4682
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:4980
double GetScaleY(int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:3579
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:2689
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1683
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4950
sub type for mpMovableObject function
Definition: mathplot.h:763
Plot layer, abstract base class.
Definition: mathplot.h:874
std::vector< double > values
Values of the chart.
Definition: mathplot.h:2556
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1210
void SetNeedUpdate()
Mark the legend bitmap as needing regeneration.
Definition: mathplot.h:1545
bool IsInside(wxCoord xPixel)
Return true if the given X pixel lies within this Y-axis drawing area.
Definition: mathplot.h:3180
mpRange< double > GetScale() const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2934
std::vector< double > m_shape_ys
Shape vertices in object-local Y coordinates.
Definition: mathplot.h:4992
bool m_autoStep
Calculates m_step automatically based on how many points you want to draw.
Definition: mathplot.h:1791
double GetValue() const
Get the x or y coordinates of the line.
Definition: mathplot.h:1820
enum __Scale_Type mpScaleType
sub_type values for mpLAYER_AXIS
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:4792
void SetFactor(int factor)
Definition: mathplot.h:4886
sub type for mpFX function
Definition: mathplot.h:759
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:1012
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1198
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:2991
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:4646
double m_sigma
Sigma value.
Definition: mathplot.h:2495
wxPoint m_mousePos
Current mouse position in window.
Definition: mathplot.h:4670
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:4674
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:1101
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:1020
unsigned int m_timeConv
Time conversion mode used when formatting date/time X values.
Definition: mathplot.h:1478
void SetScale(double min, double max)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2908
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1228
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:5096
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:4226
#define m_yData
Alias for the Y-axis data when structured binding is unavailable.
Definition: mathplot.h:143
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:4635
std::vector< wxColour > colours
Per-slice colours used when drawing the chart.
Definition: mathplot.h:2714
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:2985
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:4651
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2337
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1345
void SetWildcard(const wxString &wildcard)
Set wildcard for LoadFile() function when we use wxFileDialog.
Definition: mathplot.h:4089
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:4668
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:4658
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:1149
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2756
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4957
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:3908
void SetMaxScale(double max)
Set the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2891
#define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class)
Definition for RTTI.
Definition: mathplot.h:227
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2843
sub type for mpScaleY
Definition: mathplot.h:773
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1690
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:5159
void SetScaleY(const double scaleY, int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:3563
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:3258
Text box type layer.
Definition: mathplot.h:847
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:3389
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:1163
Line (horizontal or vertical) type layer.
Definition: mathplot.h:830