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 
67 //this definition uses windows dll to export function.
68 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
69 //mathplot_EXPORTS will be defined by cmake
70 #ifdef mathplot_EXPORTS
71  #define WXDLLIMPEXP_MATHPLOT WXEXPORT
73  #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
75 #else // not making DLL
76  #define WXDLLIMPEXP_MATHPLOT
78  #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
80 #endif
81 
82 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
83  #pragma interface "mathplot.h"
84 #endif
85 
86 #include <cassert> // For assert debug message. Disable if NDEBUG is defined
87 #include <vector>
88 #include <map>
89 #include <unordered_map>
90 
98 // Multiple define to compile with C++14 because
99 // Optional is only for C++ >= 17
100 // Structured binding is a C++17 feature
101 #if (defined(__cplusplus) && (__cplusplus > 201402L)) // C++17 or newer
102  // Use optional
103  #include <optional>
105  typedef std::optional<unsigned int> mpOptional_uint;
107  typedef std::optional<int> mpOptional_int;
109  #define MP_OPTNULL_INT std::nullopt
110  #define MP_OPTTEST(opt) (opt)
112  #define MP_OPTGET(opt) (*opt)
114  // Use structured binding
116  #define MP_LOOP_ITER auto& [m_yID, m_yData]
117 #else
118  // To replace optional int...
120  typedef unsigned int mpOptional_uint;
122  typedef int mpOptional_int;
124  #define MP_OPTNULL_INT -1
125  #define MP_OPTTEST(opt) ((opt) != -1)
127  #define MP_OPTGET(opt) (opt)
129  // To replace structured binding...
131  #define MP_LOOP_ITER auto& elem
132  #define m_yID elem.first
134  #define m_yData elem.second
136 #endif
137 
140 // #include <wx/wx.h>
141 #include <wx/defs.h>
142 #include <wx/menu.h>
143 #include <wx/scrolwin.h>
144 #include <wx/event.h>
145 #include <wx/dynarray.h>
146 #include <wx/pen.h>
147 #include <wx/dcmemory.h>
148 #include <wx/string.h>
149 #include <wx/print.h>
150 #include <wx/image.h>
151 #include <wx/intl.h>
152 
153 #include <cmath>
154 #include <deque>
155 #include <algorithm>
156 
157 #if defined(MP_USER_INCLUDE)
158  #define xstr(x) #x
160  #define str(x) xstr(x)
162  #define header MP_USER_INCLUDE.h
163  #include str(header)
164  #undef header
165 #endif
166 
167 #ifdef ENABLE_MP_CONFIG
168  #include "MathPlotConfig.h"
169 #endif // ENABLE_MP_CONFIG
170 
175 // No, this is supposed to be a build parameter: #define ENABLE_MP_NAMESPACE
176 #ifdef ENABLE_MP_NAMESPACE
177  namespace MathPlot {
178 #endif // ENABLE_MP_NAMESPACE
179 
180 #ifdef ENABLE_MP_DEBUG
181  // For memory leak debug
182  #ifdef _WINDOWS
183  #ifdef _DEBUG
184  #include <crtdbg.h>
185  #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
186  #else
187  #define DEBUG_NEW new
188  #endif // _DEBUG
189  #endif // _WINDOWS
190 #endif // ENABLE_MP_DEBUG
191 
193 #define MP_X_BORDER_SEPARATION 40
194 #define MP_Y_BORDER_SEPARATION 60
196 
198 #define MP_X_LOCALTIME 0x10
199 #define MP_X_UTCTIME 0x20
201 #define MP_X_RAWTIME MP_X_UTCTIME
203 
205 #define MP_EPSILON 1e-30
206 #define ISNOTNULL(x) (std::fpclassify(x) != FP_ZERO)
208 
210 #define MP_EXTRA_MARGIN 8
211 
213 #define MP_ZOOM_AROUND_CENTER -1
214 
215 //-----------------------------------------------------------------------------
216 // classes
217 //-----------------------------------------------------------------------------
218 
220 #define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class) wxDECLARE_DYNAMIC_CLASS(mp_class)
221 
251 
252 #ifdef ENABLE_MP_CONFIG
254 #endif // ENABLE_MP_CONFIG
255 
257 struct mpRect
258 {
259  union {
260  struct
261  {
262  wxCoord startPx;
263  wxCoord startPy;
264  wxCoord endPx;
265  wxCoord endPy;
266  };
267  struct
268  {
269  wxCoord left;
270  wxCoord top;
271  wxCoord right;
272  wxCoord bottom;
273  };
274  struct
275  {
276  wxCoord x1;
277  wxCoord y1;
278  wxCoord x2;
279  wxCoord y2;
280  };
281  wxCoord tab[4];
282  };
287  wxRect GetRect(void)
288  {
289  return wxRect(startPx, startPy, endPx - startPx, endPy - startPy);
290  }
291 };
292 static_assert(sizeof(mpRect) == 4 * sizeof(wxCoord));
293 
299 template<typename T>
300 struct mpRange
301 {
302  T min = 0;
303  T max = 0;
304 
307  {
308  min = 0;
309  max = 0;
310  }
311 
313  mpRange(T value1, T value2)
314  {
315  if (value1 < value2)
316  {
317  min = value1;
318  max = value2;
319  }
320  else
321  {
322  min = value2;
323  max = value1;
324  }
325  }
326 
328  void Set(T _value)
329  {
330  min = _value;
331  max = _value;
332  }
333 
335  void Set(T _min, T _max)
336  {
337  min = _min;
338  max = _max;
339  }
340 
342  void SetMin(T _min)
343  {
344  min = _min;
345  if (max < min)
346  max = min;
347  }
348 
350  void SetMax(T _max)
351  {
352  max = _max;
353  if (min > max)
354  min = max;
355  }
356 
358  void Assign(T value1, T value2)
359  {
360  if (value1 < value2)
361  {
362  min = value1;
363  max = value2;
364  }
365  else
366  {
367  min = value2;
368  max = value1;
369  }
370  }
371 
373  bool IsSet()
374  {
375  return ((min != 0) || (max != 0));
376  }
377 
382  void Update(T value)
383  {
384  if (value < min)
385  min = value;
386  else
387  if (value > max)
388  max = value;
389  }
390 
394  void Update(T _min, T _max)
395  {
396  if (_min < min)
397  min = _min;
398  if (_max > max)
399  max = _max;
400  }
401 
404  void Update(mpRange range)
405  {
406  if (range.min < min)
407  min = range.min;
408  if (range.max > max)
409  max = range.max;
410  }
411 
413  void Check(void)
414  {
415  if (min == max)
416  {
417  if (max > 0)
418  min = 0;
419  else
420  max = 0;
421  }
422  }
423 
425  T Length(void) const
426  {
427  return max - min;
428  }
429 
431  T GetCenter(void) const
432  {
433  return (min + max) / 2;
434  }
435 
437  T GetMaxAbs(void) const
438  {
439  return std::max(fabs(min), fabs(max));
440  }
441 
443  void ToLog(void)
444  {
445  min = (min > 0) ? log10(min) : 0;
446  max = (max > 0) ? log10(max) : 0;
447  }
448 
450  bool PointIsInside(T point) const
451  {
452  return ((point >= min) && (point <= max));
453  }
454 
455  #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
456  bool operator==(const mpRange&) const = default;
457  #else
458  bool operator==(const mpRange &other) const
460  {
461  return (min == other.min) && (max == other.max);
462  }
464  bool operator!=(const mpRange& other) const
465  {
466  return !(*this == other);
467  }
468  #endif
469 };
470 
476 struct [[deprecated("Deprecated! No longer used as X and Y are now separated")]] mpFloatRect
477 {
478  mpRange<double> x;
479  std::vector<mpRange<double>> y;
480 
487  mpFloatRect(mpWindow& w);
488 
490  mpFloatRect() = delete;
491 
498  bool PointIsInside(double px, double py, size_t yAxisID = 0) const {
499  if (yAxisID < y.size())
500  {
501  if( (px < x.min || px > x.max) ||
502  (py < y[yAxisID].min || py > y[yAxisID].max))
503  {
504  return false;
505  }
506  }
507  else
508  {
509  return false;
510  }
511 
512  return true;
513  }
514 
521  void UpdateBoundingBoxToInclude(double px, double py, size_t yAxisID = 0) {
522  assert(yAxisID < y.size());
523  if (yAxisID < y.size())
524  {
525  if (px < x.min ) x.min = px;
526  else if (px > x.max ) x.max = px;
527  if (py < y[yAxisID].min ) y[yAxisID].min = py;
528  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
529  }
530  }
531 
538  void InitializeBoundingBox(double px, double py, size_t yAxisID = 0) {
539  assert(yAxisID < y.size());
540  if (yAxisID < y.size())
541  {
542  x.min = x.max = px;
543  y[yAxisID].min = y[yAxisID].max = py;
544  }
545  }
547  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
549 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
550  bool operator==(const mpFloatRect&) const = default;
551 #else
552  // We compare with an epsilon precision
553  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
554  bool operator==(const mpFloatRect& rect) const
555  {
556  auto Same = [](double a, double b) {
557  return std::fabs(a - b) < MP_EPSILON;
558  };
559 
560  // Compare scalar members
561  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
562  {
563  return false;
564  }
565 
566  // Compare vector sizes
567  if (y.size() != rect.y.size())
568  {
569  return false;
570  }
571 
572  // Compare each Y boundary
573  for (size_t i = 0; i < y.size(); ++i)
574  {
575  if (!Same(y[i].min, rect.y[i].min) ||
576  !Same(y[i].max, rect.y[i].max) )
577  {
578  return false;
579  }
580  }
581 
582  return true;
583  }
584 #endif
585 };
586 
593 {
596 
603 
609  bool PointIsInside(double px, double py) const {
610  return x.PointIsInside(px) && y.PointIsInside(py);
611  }
612 
618  void UpdateBoundingBoxToInclude(double px, double py)
619  {
620  x.Update(px);
621  y.Update(py);
622  }
623 
628  void InitializeBoundingBox(double px, double py)
629  {
630  x.Set(px, px);
631  y.Set(py, py);
632  }
633 };
634 
638 enum
639 {
640  mpID_FIT = 2000,
648 #ifdef ENABLE_MP_CONFIG
649  mpID_CONFIG,
650 #endif // ENABLE_MP_CONFIG
654 };
655 
657 typedef enum __mp_Location_Type
658 {
669 } mpLocation;
670 
672 typedef enum __XAxis_Align_Type
673 {
679 } mpXAxis_Align;
680 
682 typedef enum __YAxis_Align_Type
683 {
689 } mpYAxis_Align;
690 
693 {
698 } mpPlot_Align;
699 
701 typedef enum __mp_Style_Type
702 {
706 } mpLegendStyle;
707 
710 {
714 
716 typedef enum __Symbol_Type
717 {
725 } mpSymbol;
726 
727 //-----------------------------------------------------------------------------
728 // mpLayer sub_type values
729 //-----------------------------------------------------------------------------
730 
732 typedef enum __Info_Type
733 {
738 } mpInfoType;
739 
741 typedef enum __Text_Type
742 {
746 } mpTextType;
747 
749 typedef enum __Function_Type
750 {
760 
762 typedef enum __Scale_Type
763 {
768 } mpScaleType;
769 
771 typedef enum __Chart_Type
772 {
777 } mpChartType;
778 
781 {
784 };
785 
788 {
808 };
809 
810 //-----------------------------------------------------------------------------
811 // mpLayer
812 //-----------------------------------------------------------------------------
813 
815 typedef enum __mp_Layer_Type
816 {
825 } mpLayerType;
826 
832 typedef enum __mp_Layer_ZOrder
833 {
842 } mpLayerZOrder;
843 
850 typedef enum __mp_Delete_Action
851 {
856 
867 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
868 {
869  public:
874  mpLayer(mpLayerType layerType);
875 
876  virtual ~mpLayer()
877  {
878  ;
879  }
880 
884  {
885  m_win = &w;
886  }
887 
895  virtual bool HasBBox()
896  {
897  return true;
898  }
899 
903  mpLayerType GetLayerType() const
904  {
905  return m_type;
906  }
907 
911  int GetLayerSubType() const
912  {
913  return m_subtype;
914  }
915 
921  virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
922  {
923  *subtype = m_subtype;
924  return (m_type == typeOfInterest);
925  }
926 
930  virtual double GetMinX()
931  {
932  return -1.0;
933  }
934 
938  virtual double GetMaxX()
939  {
940  return 1.0;
941  }
942 
946  virtual double GetMinY()
947  {
948  return -1.0;
949  }
950 
954  virtual double GetMaxY()
955  {
956  return 1.0;
957  }
958 
1000  void Plot(wxDC &dc, mpWindow &w);
1001 
1005  void SetName(const wxString &name)
1006  {
1007  m_name = name;
1008  }
1009 
1013  const wxString& GetName() const
1014  {
1015  return m_name;
1016  }
1017 
1021  void SetFont(const wxFont &font)
1022  {
1023  m_font = font;
1024  }
1025 
1029  const wxFont& GetFont() const
1030  {
1031  return m_font;
1032  }
1033 
1037  void SetFontColour(const wxColour &colour)
1038  {
1039  m_fontcolour = colour;
1040  }
1041 
1045  const wxColour& GetFontColour() const
1046  {
1047  return m_fontcolour;
1048  }
1049 
1053  void SetPen(const wxPen &pen)
1054  {
1055  m_pen = pen;
1056  }
1057 
1061  const wxPen& GetPen() const
1062  {
1063  return m_pen;
1064  }
1065 
1068  void SetBrush(const wxBrush &brush)
1069  {
1070  if (brush == wxNullBrush)
1071  m_brush = *wxTRANSPARENT_BRUSH;
1072  else
1073  m_brush = brush;
1074  }
1075 
1079  void SetBrush(const wxColour &colour, enum wxBrushStyle style = wxBRUSHSTYLE_SOLID)
1080  {
1081  m_brush.SetColour(colour);
1082  m_brush.SetStyle(style);
1083  }
1084 
1087  const wxBrush& GetBrush() const
1088  {
1089  return m_brush;
1090  }
1091 
1094  void SetShowName(bool show)
1095  {
1096  m_showName = show;
1097  }
1098 
1101  inline bool GetShowName() const
1102  {
1103  return m_showName;
1104  }
1105 
1108  void SetDrawOutsideMargins(bool drawModeOutside)
1109  {
1110  m_drawOutsideMargins = drawModeOutside;
1111  }
1112 
1116  {
1117  return m_drawOutsideMargins;
1118  }
1119 
1124  wxBitmap GetColourSquare(int side = 16);
1125 
1128  inline bool IsVisible() const
1129  {
1130  return m_visible;
1131  }
1132 
1135  virtual void SetVisible(bool show)
1136  {
1137  m_visible = show;
1138  }
1139 
1142  inline bool IsTractable() const
1143  {
1144  return m_tractable;
1145  }
1146 
1149  virtual void SetTractable(bool track)
1150  {
1151  m_tractable = track;
1152  }
1153 
1156  void SetAlign(int align)
1157  {
1158  m_flags = align;
1159  }
1160 
1163  int GetAlign() const
1164  {
1165  return m_flags;
1166  }
1167 
1170  void SetCanDelete(bool canDelete)
1171  {
1172  m_CanDelete = canDelete;
1173  }
1174 
1177  bool GetCanDelete(void) const
1178  {
1179  return m_CanDelete;
1180  }
1181 
1184  mpLayerZOrder GetZIndex(void) const
1185  {
1186  return m_ZIndex;
1187  }
1188 
1189  protected:
1190  const mpLayerType m_type;
1193  wxFont m_font;
1194  wxColour m_fontcolour;
1195  wxPen m_pen;
1196  wxBrush m_brush;
1197  wxString m_name;
1198  bool m_showName;
1200  bool m_visible;
1202  int m_flags;
1205  mpLayerZOrder m_ZIndex;
1206 
1209  void UpdateContext(wxDC &dc) const;
1210 
1215  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1216 
1221  virtual bool DoBeforePlot()
1222  {
1223  return true;
1224  }
1225 
1232  void CheckLog(double *x, double *y, int yAxisID);
1233 
1234  private:
1235  bool m_busy;
1236  mpLayer() = delete; // default ctor not implemented/permitted
1237 
1239 };
1240 
1241 //-----------------------------------------------------------------------------
1242 // mpInfoLayer
1243 //-----------------------------------------------------------------------------
1244 
1251 {
1252  public:
1254  mpInfoLayer();
1255 
1260  mpInfoLayer(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1261 
1263  virtual ~mpInfoLayer();
1264 
1267  virtual void SetVisible(bool show);
1268 
1273  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1274 
1277  virtual bool HasBBox()
1278  {
1279  return false;
1280  }
1281 
1284  [[deprecated("Use Show() instead")]]
1285  virtual void ErasePlot(wxDC&, mpWindow&) {};
1286 
1290  virtual bool Inside(const wxPoint &point);
1291 
1295  virtual void Move(wxPoint delta, mpWindow &w);
1296 
1298  virtual void UpdateReference();
1299 
1302  wxPoint GetPosition() const
1303  {
1304  return m_dim.GetPosition();
1305  }
1306 
1309  void SetInitialPosition(wxPoint pos)
1310  {
1311  m_relX = pos.x / 100.0;
1312  m_relY = pos.y / 100.0;
1313  }
1314 
1317  wxSize GetSize() const
1318  {
1319  return m_dim.GetSize();
1320  }
1321 
1324  const wxRect& GetRectangle() const
1325  {
1326  return m_dim;
1327  }
1328 
1331  void SetLocation(mpLocation location)
1332  {
1333  m_location = location;
1334  }
1335 
1338  mpLocation GetLocation() const
1339  {
1340  return m_location;
1341  }
1342 
1343  protected:
1344  wxRect m_dim;
1345  wxBitmap* m_info_bmp;
1346  wxPoint m_reference;
1347  double m_relX;
1348  double m_relY;
1349  mpLocation m_location;
1350 
1355  virtual void DoPlot(wxDC &dc, mpWindow &w);
1356 
1359  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1360 
1361  private:
1362  double clamp(double v, double min, double max);
1363 
1365 };
1366 
1372 {
1373  public:
1375  mpInfoCoords();
1376 
1378  mpInfoCoords(mpLocation location);
1379 
1384  mpInfoCoords(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1385 
1388  {
1389  ;
1390  }
1391 
1395  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1396 
1399  [[deprecated("Use Show() instead")]]
1400  virtual void ErasePlot(wxDC&, mpWindow&) {};
1401 
1404  void Show(bool show)
1405  {
1406  m_show = show;
1407  }
1408 
1411  bool IsShown()
1412  {
1413  return m_show;
1414  }
1415 
1420  bool ShouldBeShown(wxRect plotArea, wxPoint mousePos)
1421  {
1422  return IsVisible() && (GetDrawOutsideMargins() || plotArea.Contains(mousePos));
1423  }
1424 
1428  void SetLabelMode(mpLabelType mode, unsigned int time_conv = MP_X_RAWTIME)
1429  {
1430  m_labelType = mode;
1431  m_timeConv = time_conv;
1432  }
1433 
1436  void SetSeriesCoord(bool show)
1437  {
1438  m_series_coord = show;
1439  }
1440 
1443  bool IsSeriesCoord() const
1444  {
1445  return m_series_coord;
1446  }
1447 
1453  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1454 
1457  void SetPenSeries(const wxPen &pen)
1458  {
1459  m_penSeries = pen;
1460  }
1461 
1465  void DrawContent(wxDC &dc, mpWindow &w);
1466 
1467  protected:
1468  bool m_show;
1469  wxString m_content;
1471  unsigned int m_timeConv;
1472  wxCoord m_mouseX;
1473  wxCoord m_mouseY;
1475  wxPen m_penSeries;
1476 
1481  virtual void DoPlot(wxDC &dc, mpWindow &w);
1482 
1483  private:
1484  std::unordered_map<int, double> m_yValList;
1485 
1487 };
1488 
1494 {
1495  public:
1497  mpInfoLegend();
1498 
1504  mpInfoLegend(wxPoint pos, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginUser);
1505 
1508 
1511  void SetItemMode(mpLegendStyle mode)
1512  {
1513  m_item_mode = mode;
1514  m_needs_update = true;
1515  }
1516 
1518  mpLegendStyle GetItemMode() const
1519  {
1520  return m_item_mode;
1521  }
1522 
1525  void SetItemDirection(mpLegendDirection mode)
1526  {
1527  m_item_direction = mode;
1528  m_needs_update = true;
1529  }
1530 
1532  mpLegendDirection GetItemDirection() const
1533  {
1534  return m_item_direction;
1535  }
1536 
1539  {
1540  m_needs_update = true;
1541  }
1542 
1545  void ShowDraggedSeries(bool active)
1546  {
1547  m_showDraggedSeries = active;
1548  }
1549 
1553  {
1554  return m_showDraggedSeries;
1555  }
1556 
1562  int GetLegendHitRegion(wxPoint mousePos);
1563 
1570  void DrawDraggedSeries(wxDC& dc, mpWindow &w);
1571 
1575  void DrawContent(wxDC &dc, mpWindow &w);
1576 
1579  void RestoreAxisHighlighting(mpWindow &w);
1580 
1582  enum HitCode : int
1583  {
1584  HitNone = -1,
1585  HitHeader = -2
1586  };
1587 
1588  mpFunction* m_selectedSeries = nullptr;
1589  mpOptional_int m_lastHoveredAxisID = MP_OPTNULL_INT;
1590 
1591  protected:
1592  mpLegendStyle m_item_mode;
1593  mpLegendDirection m_item_direction;
1595  wxString m_headerString = wxString::FromUTF8("≡");
1596 
1601  virtual void DoPlot(wxDC &dc, mpWindow &w);
1602 
1603  private:
1605  struct LegendDetail
1606  {
1607  unsigned int layerIdx;
1608  wxCoord legendEnd;
1609  };
1611  std::vector<LegendDetail> m_LegendDetailList;
1612  wxCoord m_headerEnd;
1613  bool m_needs_update;
1614 
1624  void UpdateBitmap(wxDC &dc, mpWindow &w);
1625 
1626  private:
1628 };
1629 
1630 //-----------------------------------------------------------------------------
1631 // mpLayer implementations - functions
1632 //-----------------------------------------------------------------------------
1633 
1634 
1642 {
1643  public:
1649  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1650 
1654  void SetContinuity(bool continuity)
1655  {
1656  m_continuous = continuity;
1657  }
1658 
1662  bool GetContinuity() const
1663  {
1664  return m_continuous;
1665  }
1666 
1669  void SetStep(unsigned int step)
1670  {
1671  m_step = step;
1672  }
1673 
1676  unsigned int GetStep() const
1677  {
1678  return m_step;
1679  }
1680 
1683  void SetSymbol(mpSymbol symbol)
1684  {
1685  m_symbol = symbol;
1686  }
1687 
1690  mpSymbol GetSymbol() const
1691  {
1692  return m_symbol;
1693  }
1694 
1697  void SetSymbolSize(int size)
1698  {
1699  m_symbolSize = size;
1700  m_symbolSize2 = size / 2;
1701  }
1702 
1705  int GetSymbolSize() const
1706  {
1707  return m_symbolSize;
1708  }
1709 
1713  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1714 
1718  int GetYAxisID() const
1719  {
1720  return m_yAxisID;
1721  }
1722 
1727  void SetYAxisID(unsigned int yAxisID)
1728  {
1729  m_yAxisID = yAxisID;
1730  }
1731 
1735  void SetLegendIsAlwaysVisible(bool alwaysVisible)
1736  {
1737  m_LegendIsAlwaysVisible = alwaysVisible;
1738  }
1739 
1744  {
1745  return m_LegendIsAlwaysVisible;
1746  }
1747 
1751  void SetAutoStep(bool enable)
1752  {
1753  m_autoStep = enable;
1754  }
1755 
1758  bool GetAutoStep() const
1759  {
1760  return m_autoStep;
1761  }
1762 
1766  void SetMaxNOfPoints(size_t nOfPoints)
1767  {
1768  m_maxNOfPoints = nOfPoints;
1769  }
1770 
1773  size_t GetMaxNOfPoints() const
1774  {
1775  return m_maxNOfPoints;
1776  }
1777 
1778  protected:
1780  mpSymbol m_symbol;
1783  unsigned int m_step;
1786  bool m_autoStep;
1788 
1789  private:
1791 };
1792 
1796 {
1797  public:
1804  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1805 
1806  // We don't want to include line (horizontal or vertical) in BBox computation
1807  virtual bool HasBBox() override
1808  {
1809  return false;
1810  }
1811 
1815  double GetValue() const
1816  {
1817  return m_value;
1818  }
1819 
1823  void SetValue(const double value)
1824  {
1825  m_value = value;
1826  }
1827 
1831  bool IsHorizontal(void) const
1832  {
1833  return m_IsHorizontal;
1834  }
1835 
1836  protected:
1837  double m_value;
1839 
1840  private:
1842 };
1843 
1847 {
1848  public:
1855  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1856 
1860  void SetYValue(const double yvalue)
1861  {
1862  SetValue(yvalue);
1863  }
1864 
1865  protected:
1866 
1867  virtual void DoPlot(wxDC &dc, mpWindow &w);
1868 
1869  private:
1871 };
1872 
1876 {
1877  public:
1883  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1884 
1888  void SetXValue(const double xvalue)
1889  {
1890  SetValue(xvalue);
1891  }
1892 
1893  protected:
1894 
1895  virtual void DoPlot(wxDC &dc, mpWindow &w);
1896 
1901  virtual bool DoBeforePlot()
1902  {
1903  return true;
1904  }
1905 
1906  private:
1908 };
1909 
1917 {
1918  public:
1923  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
1924 
1930  virtual double GetY(double x) = 0;
1931 
1938  double DoGetY(double x);
1939 
1944  void DefineDoGetY(void);
1945 
1946  protected:
1947 
1948  double (mpFX::*pDoGetY)(double x);
1949 
1954  virtual void DoPlot(wxDC &dc, mpWindow &w);
1955 
1960  double NormalDoGetY(double x);
1961 
1966  double LogDoGetY(double x);
1967 
1968  private:
1970 };
1971 
1979 {
1980  public:
1985  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
1986 
1992  virtual double GetX(double y) = 0;
1993 
2000  double DoGetX(double y);
2001 
2006  void DefineDoGetX(void);
2007 
2008  protected:
2009 
2010  double (mpFY::*pDoGetX)(double y);
2011 
2016  virtual void DoPlot(wxDC &dc, mpWindow &w);
2017 
2022  double NormalDoGetX(double y);
2023 
2028  double LogDoGetX(double y);
2029 
2030  private:
2032 };
2033 
2044 {
2045  public:
2051  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2052 
2056  virtual void Rewind() = 0;
2057 
2061  virtual void Clear()
2062  {
2063  ;
2064  }
2065 
2069  virtual int GetSize()
2070  {
2071  return 0;
2072  }
2073 
2080  virtual bool GetNextXY(double *x, double *y) = 0;
2081 
2088  bool DoGetNextXY(double *x, double *y);
2089 
2094  void SetViewMode(bool asBar);
2095 
2100  int GetBarWidth(void) const
2101  {
2102  return m_BarWidth;
2103  }
2104 
2109  bool ViewAsBar(void) const
2110  {
2111  return m_ViewAsBar;
2112  }
2113 
2114  protected:
2115 
2116  // Data to calculate label positioning
2119 
2120  // Min delta between 2 x coordinate (used for view as bar)
2121  double m_deltaX;
2122  double m_deltaY;
2123 
2125 
2126  bool m_ViewAsBar = false;
2127 
2134  virtual void DoPlot(wxDC &dc, mpWindow &w);
2135 
2140  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
2141 
2142  private:
2144 };
2145 
2146 //-----------------------------------------------------------------------------
2147 // mpFXYVector - provided by Jose Luis Blanco
2148 //-----------------------------------------------------------------------------
2149 
2170 {
2171  public:
2177  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2178 
2181  virtual ~mpFXYVector()
2182  {
2183  Clear();
2184  }
2185 
2190  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
2191 
2195  void Clear();
2196 
2201  virtual int GetSize()
2202  {
2203  return m_xs.size();
2204  }
2205 
2213  bool AddData(const double x, const double y, bool updatePlot);
2214 
2221  void SetReserve(int reserve)
2222  {
2223  m_reserveXY = reserve;
2224  m_xs.reserve(m_reserveXY);
2225  m_ys.reserve(m_reserveXY);
2226  }
2227 
2231  int GetReserve() const
2232  {
2233  return m_reserveXY;
2234  }
2235 
2236  protected:
2237  std::vector<double> m_xs;
2238  std::vector<double> m_ys;
2241  size_t m_index;
2242  size_t m_endIndex;
2244  double m_lastX;
2246  double m_lastY;
2247 
2252  virtual void Rewind() override;
2253 
2260  virtual bool GetNextXY(double *x, double *y);
2261 
2266  void DrawAddedPoint(double x, double y);
2267 
2270  virtual double GetMinX()
2271  {
2272  if (m_ViewAsBar)
2273  {
2274  // Make extra space for outer bars
2275  return m_rangeX.min - (m_deltaX / 2);
2276  }
2277  else
2278  {
2279  return m_rangeX.min;
2280  }
2281  }
2282 
2285  virtual double GetMinY()
2286  {
2287  return m_rangeY.min;
2288  }
2289 
2292  virtual double GetMaxX()
2293  {
2294  if(m_ViewAsBar)
2295  {
2296  // Make extra space for outer bars
2297  return m_rangeX.max + (m_deltaX / 2);
2298  }
2299  else
2300  {
2301  return m_rangeX.max;
2302  }
2303  }
2304 
2307  virtual double GetMaxY()
2308  {
2309  return m_rangeY.max;
2310  }
2311 
2312  private:
2315  void First_Point(double x, double y);
2316 
2319  void Check_Limit(double val, mpRange<double> *range, double *last, double *delta);
2320 
2322 };
2323 
2333 {
2334  public:
2338  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
2339 
2345  virtual double GetY(double x) = 0;
2346 
2347  protected:
2348 
2353  virtual void DoPlot(wxDC &dc, mpWindow &w);
2354 
2355  private:
2357 };
2358 
2363 class mpFXGeneric: public mpFX
2364 {
2365  public:
2370  mpFXGeneric(const wxString &name = wxT("Generic FX function"), int flags = mpALIGN_LEFT, unsigned int yAxisID = 0) :
2371  mpFX(name, flags, yAxisID)
2372  {
2373  wxPen FXpen(*wxBLUE, 1, wxPENSTYLE_SOLID);
2374  SetDrawOutsideMargins(false);
2375  SetContinuity(true);
2376  SetPen(FXpen);
2377  SetStep(8); // Draw one point over eight
2378  }
2379 
2384  virtual double GetY(double x)
2385  {
2386  double y;
2387  try
2388  {
2389  y = ComputeY(x);
2390  }
2391  catch (...)
2392  {
2393  y = 0;
2394  }
2395  m_rangeY.Update(y);
2396  return y;
2397  }
2398 
2403  virtual double GetMinY()
2404  {
2405  return m_rangeY.min;
2406  }
2407 
2412  virtual double GetMaxY()
2413  {
2414  return m_rangeY.max;
2415  }
2416 
2417  protected:
2419 
2425  virtual double ComputeY(double x) = 0;
2426 
2427  private:
2429 };
2430 
2436 {
2437  public:
2443  mpGaussian(double mu, double sigma) :
2444  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2445  {
2446  m_mu = mu;
2447  m_sigma = sigma;
2448  m_variance = sigma * sigma;
2449  m_const = 1.0 / sqrt(2.0 * M_PI * m_variance);
2450  }
2451 
2452  protected:
2453  double m_mu;
2454  double m_sigma;
2455  double m_variance;
2456  double m_const;
2457 
2458  virtual double ComputeY(double x)
2459  {
2460  return m_const * exp(-(x - m_mu) * (x - m_mu) / (2.0 * m_variance));
2461  }
2462 
2463  private:
2465 };
2466 
2471 class mpNormal: public mpFXGeneric
2472 {
2473  public:
2479  mpNormal(double mu, double sigma) :
2480  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2481  {
2482  m_mu = mu;
2483  m_sigma = sigma;
2484  m_variance = sigma * sigma;
2485  m_const = 1.0 / (m_variance * sqrt(2.0 * M_PI));
2486  }
2487 
2488  protected:
2489  double m_mu;
2490  double m_sigma;
2491  double m_variance;
2492  double m_const;
2493 
2494  virtual double ComputeY(double x)
2495  {
2496  if (x < 0)
2497  return 0.0;
2498  else
2499  {
2500  double tmp = log(x) - m_mu;
2501  return m_const * exp(-tmp * tmp / (2.0 * m_variance)) / x;
2502  }
2503  }
2504 
2505  private:
2507 };
2508 
2509 //-----------------------------------------------------------------------------
2510 // mpChart
2511 //-----------------------------------------------------------------------------
2515 {
2516  public:
2518  mpChart(const wxString &name = wxEmptyString);
2519 
2522  {
2523  Clear();
2524  }
2525 
2528  void SetChartValues(const std::vector<double> &data);
2529 
2532  void SetChartLabels(const std::vector<std::string> &labelArray);
2533 
2538  void AddData(const double &data, const std::string &label);
2539 
2543  virtual void Clear();
2544 
2545  virtual bool HasBBox()
2546  {
2547  return (values.size() > 0);
2548  }
2549 
2550  protected:
2551  std::vector<double> values;
2552  std::vector<std::string> labels;
2553 
2554  double m_max_value;
2555  double m_total_value;
2556 
2557  private:
2559 };
2560 
2561 //-----------------------------------------------------------------------------
2562 // mpBarChart - provided by Jose Davide Rondini
2563 //-----------------------------------------------------------------------------
2564 /* Defines for bar charts label positioning. */
2565 #define mpBAR_NONE 0
2566 #define mpBAR_AXIS_H 1
2567 #define mpBAR_AXIS_V 2
2568 #define mpBAR_INSIDE 3
2569 #define mpBAR_TOP 4
2570 
2571 
2574 {
2575  public:
2577  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2578 
2581  {
2582  Clear();
2583  }
2584 
2586  void SetBarColour(const wxColour &colour);
2587 
2589  void SetColumnWidth(const double colWidth)
2590  {
2591  m_width = colWidth;
2592  }
2593 
2595  void SetBarLabelPosition(int position);
2596 
2600  virtual double GetMinX();
2601 
2605  virtual double GetMaxX();
2606 
2610  virtual double GetMinY();
2611 
2615  virtual double GetMaxY();
2616 
2617  protected:
2618 
2619  double m_width;
2620  wxColour m_barColour;
2622  double m_labelAngle;
2623 
2628  virtual void DoPlot(wxDC &dc, mpWindow &w);
2629 
2630  private:
2632 };
2633 
2638 {
2639  public:
2643  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2644 
2647  {
2648  Clear();
2649  colours.clear();
2650  }
2651 
2655  void SetCenter(const wxPoint center)
2656  {
2657  m_center = center;
2658  }
2659 
2663  wxPoint GetCenter(void) const
2664  {
2665  return m_center;
2666  }
2667 
2671  void SetPieColours(const std::vector<wxColour> &colourArray);
2672 
2676  virtual double GetMinX()
2677  {
2678  return m_center.x - m_radius;
2679  }
2680 
2684  virtual double GetMaxX()
2685  {
2686  return m_center.x + m_radius;
2687  }
2688 
2692  virtual double GetMinY()
2693  {
2694  return m_center.y - m_radius;
2695  }
2696 
2700  virtual double GetMaxY()
2701  {
2702  return m_center.y + m_radius;
2703  }
2704 
2705  protected:
2706 
2707  double m_radius;
2708  wxPoint m_center;
2709  std::vector<wxColour> colours;
2710 
2715  virtual void DoPlot(wxDC &dc, mpWindow &w);
2716 
2718  const wxColour& GetColour(unsigned int id);
2719 
2720  private:
2722 };
2723 
2726 //-----------------------------------------------------------------------------
2727 // mpLayer implementations - furniture (scales, ...)
2728 //-----------------------------------------------------------------------------
2737 {
2738  public:
2746  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, mpOptional_uint axisID = MP_OPTNULL_INT);
2747 
2751  virtual bool HasBBox()
2752  {
2753  return false;
2754  }
2755 
2759  int GetAxisID(void)
2760  {
2761  return m_axisID;
2762  }
2763 
2768  void SetAxisID(unsigned int yAxisID)
2769  {
2770  m_axisID = yAxisID;
2771  }
2772 
2775  void ShowTicks(bool ticks)
2776  {
2777  m_ticks = ticks;
2778  }
2779 
2782  bool GetShowTicks() const
2783  {
2784  return m_ticks;
2785  }
2786 
2789  void ShowGrids(bool grids)
2790  {
2791  m_grids = grids;
2792  }
2793 
2796  bool GetShowGrids() const
2797  {
2798  return m_grids;
2799  }
2800 
2805  void SetLabelFormat(const wxString &format, bool updateLabelMode = false)
2806  {
2807  m_labelFormat = format;
2808  if (updateLabelMode)
2809  m_labelType = mpLabel_USER;
2810  }
2811 
2815  {
2816  return m_labelType;
2817  }
2818 
2822  void SetLabelMode(mpLabelType mode, unsigned int time_conv = MP_X_RAWTIME)
2823  {
2824  m_labelType = mode;
2825  m_timeConv = time_conv;
2826  }
2827 
2830  const wxString& GetLabelFormat() const
2831  {
2832  return m_labelFormat;
2833  }
2834 
2838  void SetGridPen(const wxPen &pen)
2839  {
2840  m_gridpen = pen;
2841  }
2842 
2846  const wxPen& GetGridPen() const
2847  {
2848  return m_gridpen;
2849  }
2850 
2854  void SetAuto(bool automaticScalingIsEnabled)
2855  {
2856  m_auto = automaticScalingIsEnabled;
2857  }
2858 
2862  bool GetAuto() const
2863  {
2864  return m_auto;
2865  }
2866 
2870  void SetMinScale(double min)
2871  {
2872  m_axisRange.SetMin(min);
2873  }
2874 
2878  double GetMinScale() const
2879  {
2880  return m_axisRange.min;
2881  }
2882 
2886  void SetMaxScale(double max)
2887  {
2888  m_axisRange.SetMax(max);
2889  }
2890 
2894  double GetMaxScale() const
2895  {
2896  return m_axisRange.max;
2897  }
2898 
2903  void SetScale(double min, double max)
2904  {
2905  m_axisRange.Set(min, max);
2906  }
2907 
2912  void GetScale(double *min, double *max) const
2913  {
2914  *min = m_axisRange.min;
2915  *max = m_axisRange.max;
2916  }
2917 
2922  {
2923  m_axisRange = range;
2924  }
2925 
2930  {
2931  return mpRange<double>(m_axisRange);
2932  }
2933 
2937  void SetHovering(bool hover)
2938  {
2939  m_hover = hover;
2940  }
2941 
2945  virtual bool IsLogAxis()
2946  {
2947  return m_isLog;
2948  }
2949 
2953  virtual void SetLogAxis(bool log)
2954  {
2955  m_isLog = log;
2956  }
2957 
2961  void SetCoordIsAlwaysVisible(bool alwaysVisible)
2962  {
2963  m_CoordIsAlwaysVisible = alwaysVisible;
2964  }
2965 
2970  {
2971  return m_CoordIsAlwaysVisible;
2972  }
2973 
2974  protected:
2975  static const wxCoord kTickSize = 4;
2976  static const wxCoord kAxisExtraSpace = 6;
2977 
2978  int m_axisID;
2979  wxPen m_gridpen;
2980  bool m_ticks;
2981  bool m_grids;
2982  bool m_auto;
2985  unsigned int m_timeConv;
2986  wxString m_labelFormat;
2987  bool m_isLog;
2988  bool m_hover = false;
2990 
2993  virtual int GetOrigin(mpWindow &w) = 0;
2994 
3001  double GetStep(double scale, int minLabelSpacing);
3002 
3010  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
3011 
3017  wxString FormatLabelValue(double value);
3018 
3023  wxString FormatLogValue(double n);
3024 
3031  int GetLabelWidth(double value, wxDC &dc);
3032 
3037  bool UseScientific(double maxAxisValue);
3038 
3044  int GetSignificantDigits(double step, double maxAxisValue);
3045 
3050  int GetDecimalDigits(double step);
3051 
3055  struct {
3056  double step;
3057  double maxAxisValue;
3058  bool UseScientific;
3059  int SignificantDigits;
3060  int DecimalDigits;
3061  double EpsilonScale;
3062  } m_ScaleConstraints;
3063 
3067  void ComputeScaleConstraints(double step, double maxAxisValue);
3068 
3069  private:
3071 };
3072 
3073 
3080 {
3081  public:
3087  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, mpLabelType type = mpLabel_AUTO) :
3088  mpScale(name, flags, grids, type)
3089  {
3090  m_subtype = mpsScaleX;
3091  }
3092 
3094  bool IsTopAxis()
3095  {
3096  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
3097  }
3098 
3101  {
3102  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
3103  }
3104 
3105  protected:
3110  static int m_orgy;
3111 
3114  virtual void DoPlot(wxDC &dc, mpWindow &w);
3115 
3116  virtual int GetOrigin(mpWindow &w);
3117  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
3118 
3119  private:
3121 
3125  friend mpScaleY;
3126 };
3127 
3135 {
3136  public:
3144  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, mpOptional_uint yAxisID = MP_OPTNULL_INT, mpLabelType labelType = mpLabel_AUTO) :
3145  mpScale(name, flags, grids, labelType, yAxisID)
3146  {
3147  m_subtype = mpsScaleY;
3148  m_axisWidth = MP_Y_BORDER_SEPARATION;
3149  m_xPos = 0;
3150  }
3151 
3154  void UpdateAxisWidth(mpWindow &w);
3155 
3158  {
3159  return m_axisWidth;
3160  }
3161 
3163  bool IsLeftAxis()
3164  {
3165  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
3166  }
3167 
3170  {
3171  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
3172  }
3173 
3175  bool IsInside(wxCoord xPixel)
3176  {
3177  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
3178  {
3179  return true;
3180  }
3181  return false;
3182  }
3183 
3184  protected:
3186  int m_xPos;
3187 
3190  virtual void DoPlot(wxDC &dc, mpWindow &w);
3191 
3192  virtual int GetOrigin(mpWindow &w);
3193  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
3194 
3195  private:
3197 };
3198 
3199 //-----------------------------------------------------------------------------
3200 // mpWindow
3201 //-----------------------------------------------------------------------------
3202 
3208 #define mpMOUSEMODE_DRAG 0
3209 
3210 #define mpMOUSEMODE_ZOOMBOX 1
3211 
3214 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
3215 typedef std::deque<mpLayer*> mpLayerList;
3216 
3227 {
3228  mpScale* axis = nullptr;
3229  double scale = 1.0;
3230  double pos = 0;
3234 
3235  // Note: we don't use the default operator since we don't want to compare axis pointers
3237  bool operator==(const mpAxisData& other) const
3238  {
3239  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
3240  (bound == other.bound) && (desired == other.desired);
3241  }
3242 };
3243 
3245 typedef std::map<int, mpAxisData> mpAxisList;
3246 
3253 typedef enum {
3254  uXAxis = 1,
3255  uYAxis = 2,
3256  uXYAxis = 3
3257 } mpAxisUpdate;
3258 
3268 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
3269 
3276 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
3277 
3283 {
3284  public:
3285  mpMagnet()
3286  {
3287  m_enable = false;
3288  m_show = false;
3289  }
3290  ~mpMagnet()
3291  {
3292  ;
3293  }
3294 
3296  void UpdateBox(const wxRect &plotArea)
3297  {
3298  m_domain = plotArea;
3299  }
3300 
3302  void Enable(bool enable)
3303  {
3304  m_enable = enable;
3305  }
3306 
3308  bool IsEnabled() const
3309  {
3310  return m_enable;
3311  }
3312 
3314  void DrawCross(wxDC &dc, mpWindow &w);
3315 
3317  bool ShouldBeShown(wxPoint mousePos)
3318  {
3319  return m_enable && m_domain.Contains(mousePos);
3320  }
3321 
3323  void Show(bool show)
3324  {
3325  m_show = show;
3326  }
3327 
3329  bool IsShown()
3330  {
3331  return m_show;
3332  }
3333 
3334  private:
3335  bool m_enable;
3336  bool m_show;
3337  wxRect m_domain;
3338 };
3339 
3361 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
3362 {
3363  public:
3364  mpWindow()
3365  {
3366  InitParameters();
3367  }
3368 
3376  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
3377  long flags = 0);
3378 
3379  ~mpWindow();
3380 
3384  wxMenu* GetPopupMenu()
3385  {
3386  return &m_popmenu;
3387  }
3388 
3397  bool AddLayer(mpLayer *layer, bool refreshDisplay = true, bool refreshConfig = true);
3398 
3411  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
3412 
3418  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
3419 
3426  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
3427 
3434  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
3435 
3441  mpLayer* GetLayer(int position);
3442 
3447  int GetLayerPosition(mpLayer* layer);
3448 
3455  mpLayer* GetLayersType(int position, mpLayerType type);
3456 
3463  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
3464 
3470  mpScale* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
3471 
3480  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
3481 
3490  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
3491 
3496  mpLayer* GetLayerByName(const wxString &name);
3497 
3502  mpLayer* GetLayerByClassName(const wxString &name);
3503 
3507  void RefreshLegend(void);
3508 
3513  bool IsYAxisUsed(int yAxisID);
3514 
3520  bool IsYAxisUsedByFunction(int yAxisID, int *position);
3521 
3525  mpScaleX* GetLayerXAxis();
3526 
3530  mpScaleY* GetLayerYAxis(int yAxisID);
3531 
3535  void SetScaleX(const double scaleX)
3536  {
3537  if (ISNOTNULL(scaleX))
3538  {
3539  m_AxisDataX.scale = scaleX;
3540  UpdateDesiredBoundingBox(uXAxis);
3541  }
3542  UpdateAll();
3543  }
3544 
3549  double GetScaleX(void) const
3550  {
3551  return m_AxisDataX.scale;
3552  }
3553 
3558  void SetScaleY(const double scaleY, int yAxisID)
3559  {
3560  assert(m_AxisDataYList.count(yAxisID) != 0);
3561  if (ISNOTNULL(scaleY))
3562  {
3563  m_AxisDataYList[yAxisID].scale = scaleY;
3564  UpdateDesiredBoundingBox(uYAxis);
3565  }
3566  UpdateAll();
3567  }
3568 
3574  double GetScaleY(int yAxisID)
3575  {
3576  assert(m_AxisDataYList.count(yAxisID) != 0);
3577  return m_AxisDataYList[yAxisID].scale;
3578  } // Schaling's method: maybe another method exists with the same name
3579 
3580  [[deprecated("Incomplete, use UpdateBBox instead")]]
3583  void SetBound();
3584 
3587  {
3588  return m_AxisDataX.bound;
3589  }
3590 
3593  {
3594  return m_AxisDataX.desired;
3595  }
3596 
3601  {
3602  assert(m_AxisDataYList.count(yAxisID) != 0);
3603  return m_AxisDataYList[yAxisID].bound;
3604  }
3605 
3610  {
3611  assert(m_AxisDataYList.count(yAxisID) != 0);
3612  return m_AxisDataYList[yAxisID].desired;
3613  }
3614 
3619  std::unordered_map<int, mpRange<double>> GetAllBoundY()
3620  {
3621  std::unordered_map<int, mpRange<double>> yRange;
3622  for (const MP_LOOP_ITER : m_AxisDataYList)
3623  {
3624  yRange[m_yID] = m_yData.bound;
3625  }
3626  return yRange;
3627  }
3628 
3633  std::unordered_map<int, mpRange<double>> GetAllDesiredY()
3634  {
3635  std::unordered_map<int, mpRange<double>> yRange;
3636  for (const MP_LOOP_ITER : m_AxisDataYList)
3637  {
3638  yRange[m_yID] = m_yData.desired;
3639  }
3640  return yRange;
3641  }
3642 
3646  void SetPosX(const double posX)
3647  {
3648  m_AxisDataX.pos = posX;
3649  UpdateDesiredBoundingBox(uXAxis);
3650  UpdateAll();
3651  }
3652 
3657  double GetPosX(void) const
3658  {
3659  return m_AxisDataX.pos;
3660  }
3661 
3666  void SetPosY(std::unordered_map<int, double>& posYList)
3667  {
3668  for (MP_LOOP_ITER : m_AxisDataYList)
3669  {
3670  m_yData.pos = posYList[m_yID];
3671  }
3672  UpdateDesiredBoundingBox(uYAxis);
3673  UpdateAll();
3674  }
3675 
3681  double GetPosY(int yAxisID)
3682  {
3683  assert(m_AxisDataYList.count(yAxisID) != 0);
3684  return m_AxisDataYList[yAxisID].pos;
3685  }
3686 
3690  int GetNOfYAxis(void) const
3691  {
3692  return (int)m_AxisDataYList.size();
3693  }
3694 
3698  mpAxisList GetAxisDataYList(void) const
3699  {
3700  return m_AxisDataYList;
3701  }
3702 
3708  void SetScreen(const int scrX, const int scrY)
3709  {
3710  m_scrX = scrX;
3711  m_scrY = scrY;
3712  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3713  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3714 
3715  m_plotBoundaries.endPx = m_scrX;
3716  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3717  m_plotBoundaries.endPy = m_scrY;
3718  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3719 
3720  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3721  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3722 
3723  m_magnet.UpdateBox(m_PlotArea);
3724  }
3725 
3732  int GetScreenX(void) const
3733  {
3734  return m_scrX;
3735  }
3736 
3743  int GetScreenY(void) const
3744  {
3745  return m_scrY;
3746  }
3747 
3753  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3754  {
3755  m_AxisDataX.pos = posX;
3756  SetPosY(posYList);
3757  }
3758 
3762  inline double p2x(const wxCoord pixelCoordX) const
3763  {
3764  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3765  }
3766 
3770  inline double p2y(const wxCoord pixelCoordY, int yAxisID = 0)
3771  {
3772  assert(m_AxisDataYList.count(yAxisID) != 0);
3773  if (m_AxisDataYList.count(yAxisID) == 0)
3774  return 0.0;
3775  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3776  }
3777 
3781  inline wxCoord x2p(const double x) const
3782  {
3783  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3784  }
3785 
3789  inline wxCoord y2p(const double y, int yAxisID = 0)
3790  {
3791  assert(m_AxisDataYList.count(yAxisID) != 0);
3792  if (m_AxisDataYList.count(yAxisID) == 0)
3793  return 0;
3794  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3795  }
3796 
3799  void EnableBufferedPaintDC(const bool enabled)
3800  {
3801  m_enableBufferedPaintDC = enabled;
3802  }
3803 
3806  void EnableMousePanZoom(const bool enabled)
3807  {
3808  m_enableMouseNavigation = enabled;
3809  }
3810 
3816  void LockAspect(bool enable = true);
3817 
3822  inline bool IsAspectLocked() const
3823  {
3824  return m_lockaspect;
3825  }
3826 
3831  void Fit();
3832 
3839  void Fit(const mpRange<double> &rangeX, std::unordered_map<int, mpRange<double>> rangeY, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3840 
3844  void FitX(void);
3845 
3850  void FitY(int yAxisID);
3851 
3856  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
3857 
3862  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
3863 
3865  void ZoomInX();
3866 
3868  void ZoomOutX();
3869 
3872  void ZoomInY(mpOptional_int yAxisID = MP_OPTNULL_INT);
3873 
3876  void ZoomOutY(mpOptional_int yAxisID = MP_OPTNULL_INT);
3877 
3882  void ZoomRect(wxPoint p0, wxPoint p1);
3883 
3885  void UpdateAll();
3886 
3887  // Added methods by Davide Rondini
3888 
3892  unsigned int CountLayers();
3893 
3896  unsigned int CountAllLayers()
3897  {
3898  return (unsigned int)m_layers.size();
3899  }
3900 
3904  unsigned int CountLayersType(mpLayerType type);
3905 
3909  unsigned int CountLayersFXYPlot();
3910 
3918  {
3919  // Change on X axis
3920  if (update & uXAxis)
3921  {
3922  m_AxisDataX.desired.Set(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale),
3923  m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3924  }
3925 
3926  // Change on Y axis
3927  if (update & uYAxis)
3928  {
3929  for (MP_LOOP_ITER : m_AxisDataYList)
3930  {
3931  m_yData.desired.Set(m_yData.pos - ((m_margin.top + m_plotHeight) / m_yData.scale),
3932  m_yData.pos - (m_margin.top / m_yData.scale));
3933  }
3934  }
3935  }
3936 
3942  mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID = 0)
3943  {
3944  assert(m_AxisDataYList.count(yAxisID) != 0);
3945  if (desired)
3946  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
3947  else
3948  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
3949  }
3950 
3954  double GetDesiredXmin() const
3955  {
3956  return m_AxisDataX.desired.min;
3957  }
3958 
3963  double GetDesiredXmax() const
3964  {
3965  return m_AxisDataX.desired.max;
3966  }
3967 
3973  double GetDesiredYmin(int yAxisID)
3974  {
3975  assert(m_AxisDataYList.count(yAxisID) != 0);
3976  return m_AxisDataYList[yAxisID].desired.min;
3977  }
3978 
3984  double GetDesiredYmax(int yAxisID)
3985  {
3986  assert(m_AxisDataYList.count(yAxisID) != 0);
3987  return m_AxisDataYList[yAxisID].desired.max;
3988  }
3989 
3995  bool GetBoundingBox(mpRange<double> *boundX, mpRange<double> *boundY, int yAxisID)
3996  {
3997  if (m_AxisDataYList.count(yAxisID) == 0)
3998  return false;
3999  *boundX = m_AxisDataX.bound;
4000  *boundY = m_AxisDataYList[yAxisID].bound;
4001  return true;
4002  }
4003 
4009  bool PointIsInsideBound(double px, double py, int yAxisID)
4010  {
4011  if (m_AxisDataYList.count(yAxisID) == 0)
4012  return false;
4013 
4014  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
4015  }
4016 
4022  void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
4023  {
4024  if (m_AxisDataYList.count(yAxisID) == 0)
4025  return ;
4026 
4027  m_AxisDataX.bound.Update(px);
4028  m_AxisDataYList[yAxisID].bound.Update(py);
4029  }
4030 
4031  /* Initialize bounding box with an initial point
4032  * @param px point on x-axis
4033  * @param py point on y-axis
4034  * @param yAxisID the y-axis ID
4035  */
4037  void InitializeBoundingBox(double px, double py, int yAxisID)
4038  {
4039  if (m_AxisDataYList.count(yAxisID) == 0)
4040  return ;
4041 
4042  m_AxisDataX.bound.Set(px, px);
4043  m_AxisDataYList[yAxisID].bound.Set(py, py);
4044  }
4045 
4048  void SetMPScrollbars(bool status);
4049 
4052  bool GetMPScrollbars() const
4053  {
4054  return m_enableScrollBars;
4055  }
4056 
4062  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
4063 
4067  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4068 
4072  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4073 
4077  void SetWildcard(const wxString &wildcard)
4078  {
4079  m_wildcard = wildcard;
4080  }
4081 
4085  const wxString& GetWildcard(void) const
4086  {
4087  return m_wildcard;
4088  }
4089 
4097  bool LoadFile(const wxString &filename = wxEmptyString);
4098 
4103  void SetDefaultDir(const wxString &dirname)
4104  {
4105  m_DefaultDir = dirname;
4106  }
4107 
4111 
4116 
4123  {
4124  m_DefaultLegendIsAlwaysVisible = visible;
4125  }
4126 
4131 
4132 
4137  void SetAutoFit(bool autoFit)
4138  {
4139  m_autoFit = autoFit;
4140  }
4141 
4148  void SetMargins(int top, int right, int bottom, int left);
4149 
4152  {
4153  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4154  }
4155 
4157  void SetMarginTop(int top)
4158  {
4159  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4160  }
4161 
4165  int GetMarginTop(bool minusExtra = false) const
4166  {
4167  if (minusExtra)
4168  return m_margin.top - m_extraMargin;
4169  else
4170  return m_margin.top;
4171  }
4172 
4174  void SetMarginRight(int right)
4175  {
4176  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
4177  }
4178 
4182  int GetMarginRight(bool minusExtra = false) const
4183  {
4184  if (minusExtra)
4185  return m_margin.right - m_extraMargin;
4186  else
4187  return m_margin.right;
4188  }
4189 
4192  {
4193  return m_marginOuter.right;
4194  }
4195 
4197  void SetMarginBottom(int bottom)
4198  {
4199  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
4200  }
4201 
4205  int GetMarginBottom(bool minusExtra = false) const
4206  {
4207  if (minusExtra)
4208  return m_margin.bottom - m_extraMargin;
4209  else
4210  return m_margin.bottom;
4211  }
4212 
4214  void SetMarginLeft(int left)
4215  {
4216  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
4217  }
4218 
4222  int GetMarginLeft(bool minusExtra = false) const
4223  {
4224  if (minusExtra)
4225  return m_margin.left - m_extraMargin;
4226  else
4227  return m_margin.left;
4228  }
4229 
4231  void SetExtraMargin(int extra)
4232  {
4233  m_extraMargin = extra;
4234  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4235  }
4236 
4238  int GetExtraMargin() const
4239  {
4240  return m_extraMargin;
4241  }
4242 
4245  {
4246  return m_marginOuter.left;
4247  }
4248 
4250  int GetPlotWidth() const
4251  {
4252  return m_plotWidth;
4253  }
4254 
4256  int GetPlotHeight() const
4257  {
4258  return m_plotHeight;
4259  }
4260 
4265  mpRect GetPlotBoundaries(bool with_margin) const
4266  {
4267  mpRect bond;
4268  if (with_margin)
4269  bond = m_plotBoundariesMargin;
4270  else
4271  bond = m_plotBoundaries;
4272  bond.startPx -= m_extraMargin;
4273  bond.endPx += m_extraMargin;
4274  bond.startPy -= m_extraMargin;
4275  bond.endPy += m_extraMargin;
4276  return bond;
4277  }
4278 
4282  int GetLeftYAxesWidth(mpOptional_int yAxisID = MP_OPTNULL_INT);
4283 
4287  int GetRightYAxesWidth(mpOptional_int yAxisID = MP_OPTNULL_INT);
4288 
4290  void SetDrawBox(bool drawbox)
4291  {
4292  m_drawBox = drawbox;
4293  }
4294 
4296  bool GetDrawBox() const
4297  {
4298  return m_drawBox;
4299  }
4300 
4304  mpOptional_int IsInsideYAxis(const wxPoint &point);
4305 
4309  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
4310 
4314  void SetLayerVisible(const wxString &name, bool viewable);
4315 
4319  bool IsLayerVisible(const wxString &name);
4320 
4324  bool IsLayerVisible(const unsigned int position);
4325 
4329  void SetLayerVisible(const unsigned int position, bool viewable);
4330 
4335  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
4336 
4339  const wxColour& GetAxesColour() const
4340  {
4341  return m_axColour;
4342  }
4343 
4345  const wxColour& GetbgColour() const
4346  {
4347  return m_bgColour;
4348  }
4349 
4351  void SetbgColour(const wxColour &colour)
4352  {
4353  m_bgColour = colour;
4354  }
4355 
4361  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
4362  {
4363  m_OnDeleteLayer = event;
4364  }
4365 
4368  {
4369  m_OnDeleteLayer = NULL;
4370  }
4371 
4376  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
4377  {
4378  m_OnUserMouseAction = userMouseEventHandler;
4379  }
4380 
4383  {
4384  m_OnUserMouseAction = NULL;
4385  }
4386 
4392  bool IsLogXaxis()
4393  {
4394  if (m_AxisDataX.axis)
4395  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
4396  else
4397  return false;
4398  }
4399 
4404  bool IsLogYaxis(int yAxisID)
4405  {
4406  assert(m_AxisDataYList.count(yAxisID) != 0);
4407  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4408  if (yAxis)
4409  return yAxis->IsLogAxis();
4410  else
4411  return false;
4412  }
4413 
4418  void SetLogXaxis(bool log)
4419  {
4420  if (m_AxisDataX.axis)
4421  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
4422  }
4423 
4429  void SetLogYaxis(int yAxisID, bool log)
4430  {
4431  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4432  if (yAxis)
4433  yAxis->SetLogAxis(log);
4434  }
4435 
4440  bool GetMagnetize() const
4441  {
4442  return m_magnet.IsEnabled();
4443  }
4444 
4446  void SetMagnetize(bool mag)
4447  {
4448  m_magnet.Enable(mag);
4449  }
4450 
4456  {
4457  m_mouseLeftDownAction = action;
4458  }
4459 
4465  {
4466  return m_mouseLeftDownAction;
4467  }
4468 
4474  {
4475  return m_mousePos;
4476  }
4477 
4483  {
4484  return m_movingInfoLayer;
4485  }
4486 
4487 #ifdef ENABLE_MP_CONFIG
4488 
4492  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
4493 #endif // ENABLE_MP_CONFIG
4494 
4501  void RefreshConfigWindow(mpLayerType layerType, int param = 0, bool show = false);
4502 
4506  void OpenConfigWindow();
4507 
4511  void DeleteConfigWindow(void);
4512 
4517  void Paint(wxDC& dc);
4518 
4523  void RenderOverlays(wxDC& dc);
4524 
4530  wxMemoryDC *GetMemoryDC(void)
4531  {
4532  m_buff_dc.SelectObject(m_buff_bmp);
4533  return &m_buff_dc;
4534  }
4535 
4536  protected:
4537  virtual void BindEvents(void);
4538  virtual void OnPaint(wxPaintEvent &event);
4539  virtual void OnSize(wxSizeEvent &event);
4540  virtual void OnShowPopupMenu(wxMouseEvent &event);
4541  virtual void OnCenter(wxCommandEvent &event);
4542  virtual void OnFit(wxCommandEvent &event);
4543  virtual void OnToggleGrids(wxCommandEvent &event);
4544  virtual void OnToggleCoords(wxCommandEvent &event);
4545  virtual void OnScreenShot(wxCommandEvent &event);
4546  virtual void OnFullScreen(wxCommandEvent &event);
4547 #ifdef ENABLE_MP_CONFIG
4548  virtual void OnConfiguration(wxCommandEvent &event);
4549 #endif // ENABLE_MP_CONFIG
4550  virtual void OnLoadFile(wxCommandEvent &event);
4551  virtual void OnZoomIn(wxCommandEvent &event);
4552  virtual void OnZoomOut(wxCommandEvent &event);
4553  virtual void OnLockAspect(wxCommandEvent &event);
4554  virtual void OnMouseHelp(wxCommandEvent &event);
4555  virtual void OnMouseLeftDown(wxMouseEvent &event);
4556  virtual void OnMouseRightDown(wxMouseEvent &event);
4557  virtual void OnMouseMove(wxMouseEvent &event);
4558  virtual void OnMouseLeftRelease(wxMouseEvent &event);
4559  virtual void OnMouseWheel(wxMouseEvent &event);
4560  virtual void OnMouseLeave(wxMouseEvent &event);
4561  bool CheckUserMouseAction(wxMouseEvent &event);
4562  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
4563  virtual void OnScrollPageUp(wxScrollWinEvent &event);
4564  virtual void OnScrollPageDown(wxScrollWinEvent &event);
4565  virtual void OnScrollLineUp(wxScrollWinEvent &event);
4566  virtual void OnScrollLineDown(wxScrollWinEvent &event);
4567  virtual void OnScrollTop(wxScrollWinEvent &event);
4568  virtual void OnScrollBottom(wxScrollWinEvent &event);
4569 
4571  void DoScrollCalc(const int position, const int orientation);
4572 
4577  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = MP_ZOOM_AROUND_CENTER);
4578 
4585  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = MP_ZOOM_AROUND_CENTER, mpOptional_int yAxisID = MP_OPTNULL_INT);
4586 
4591  void SetScaleXAndCenter(double scaleX);
4592 
4598  void SetScaleYAndCenter(double scaleY, int yAxisID);
4599 
4604  void Zoom(bool zoomIn, const wxPoint &centerPoint);
4605 
4608  virtual bool UpdateBBox();
4609 
4613  void DrawBoxZoom(wxDC& dc);
4614 
4618  void InitParameters();
4619 
4620  wxTopLevelWindow* m_parent;
4622 
4623  mpLayerList m_layers;
4625  mpAxisList m_AxisDataYList;
4626 
4627  wxMenu m_popmenu;
4629  wxColour m_bgColour;
4630  wxColour m_fgColour;
4631  wxColour m_axColour;
4632  bool m_drawBox;
4633 
4634  int m_scrX;
4635  int m_scrY;
4638 
4642  wxCoord m_plotWidth;
4643  wxCoord m_plotHeight;
4644 
4647  wxRect m_PlotArea;
4648 
4651  wxBitmap m_buff_bmp;
4652  wxMemoryDC m_buff_dc;
4658  wxPoint m_mousePos;
4659  wxPoint m_mouseRClick;
4660  wxPoint m_mouseLClick;
4661  double m_mouseScaleX;
4662  std::unordered_map<int, double> m_mouseScaleYList;
4665  bool m_autoFit;
4669 
4671 
4673 
4674  wxBitmap* m_Screenshot_bmp;
4675 
4676  wxString m_wildcard;
4677  wxString m_DefaultDir;
4678 
4679 #ifdef ENABLE_MP_CONFIG
4680  MathPlotConfigDialog* m_configWindow = NULL;
4681 #endif // ENABLE_MP_CONFIG
4682  bool m_openConfigWindowPending = false;
4684 
4685  mpOnDeleteLayer m_OnDeleteLayer = NULL;
4686  mpOnUserMouseAction m_OnUserMouseAction = NULL;
4687 
4691  virtual void DesiredBoundsHaveChanged() {};
4692 
4693  private:
4695  void CheckAndReportDesiredBoundsChanges();
4696 
4701  unsigned int GetNewAxisDataID(void)
4702  {
4703  int newID = 0;
4704  for (const MP_LOOP_ITER : m_AxisDataYList)
4705  {
4706  if(m_yData.axis)
4707  {
4708  // This ID is used by an axis. Make sure the new ID is larger
4709  newID = std::max(newID, m_yID + 1);
4710  }
4711  }
4712  return newID;
4713  }
4714 
4716 
4717  // To have direct access to m_Screenshot_dc
4718  friend mpPrintout;
4719 };
4720 
4721 //-----------------------------------------------------------------------------
4722 // mpText - provided by Val Greene
4723 //-----------------------------------------------------------------------------
4724 
4733 {
4734  public:
4737  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
4738  {
4739  m_subtype = mptText;
4740  SetName(name);
4741  m_offsetx = 5;
4742  m_offsety = 50;
4743  m_location = mpMarginUser;
4744  m_ZIndex = mpZIndex_TEXT;
4745  }
4746 
4750  mpText(const wxString &name, int offsetx, int offsety);
4751 
4755  mpText(const wxString &name, mpLocation marginLocation);
4756 
4759  virtual bool HasBBox()
4760  {
4761  return false;
4762  }
4763 
4766  void SetLocation(mpLocation location)
4767  {
4768  m_location = location;
4769  }
4770 
4773  mpLocation GetLocation() const
4774  {
4775  return m_location;
4776  }
4777 
4780  void SetOffset(int offX, int offY)
4781  {
4782  m_offsetx = offX;
4783  m_offsety = offY;
4784  }
4785 
4787  void GetOffset(int *offX, int *offY) const
4788  {
4789  *offX = m_offsetx;
4790  *offY = m_offsety;
4791  }
4792 
4793  protected:
4796  mpLocation m_location;
4797 
4800  virtual void DoPlot(wxDC &dc, mpWindow &w);
4801 
4802  private:
4804 };
4805 
4810 {
4811  public:
4814  mpTitle();
4815 
4818  mpTitle(const wxString &name) :
4819  mpText(name, mpMarginTopCenter)
4820  {
4821  m_subtype = mptTitle;
4822  SetPen(*wxWHITE_PEN);
4823  SetBrush(*wxWHITE_BRUSH);
4824  }
4825 
4826  private:
4828 };
4829 
4830 //-----------------------------------------------------------------------------
4831 // mpPrintout - provided by Davide Rondini
4832 //-----------------------------------------------------------------------------
4833 
4838 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4839 {
4840  public:
4841  mpPrintout()
4842  {
4843  plotWindow = NULL;
4844  drawn = false;
4845  stretch_factor = 2;
4846  }
4847 
4853  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4854  virtual ~mpPrintout()
4855  {
4856  ;
4857  }
4858 
4862  void SetDrawState(bool drawState)
4863  {
4864  drawn = drawState;
4865  }
4866 
4868  bool OnPrintPage(int page);
4870  bool HasPage(int page);
4871 
4874  void SetFactor(int factor)
4875  {
4876  stretch_factor = factor;
4877  }
4878 
4879  private:
4880  bool drawn;
4881  mpWindow* plotWindow;
4882  int stretch_factor; // To reduce the size of plot
4883 
4885 };
4886 
4887 //-----------------------------------------------------------------------------
4888 // mpMovableObject - provided by Jose Luis Blanco
4889 //-----------------------------------------------------------------------------
4898 {
4899  public:
4903  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
4904  {
4905  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
4906  m_subtype = mpfMovable;
4907  }
4908 
4909  virtual ~mpMovableObject() {}
4910 
4913  void GetCoordinateBase(double &x, double &y, double &phi) const
4914  {
4915  x = m_reference_x;
4916  y = m_reference_y;
4917  phi = m_reference_phi;
4918  }
4919 
4922  void SetCoordinateBase(double x, double y, double phi = 0)
4923  {
4924  m_reference_x = x;
4925  m_reference_y = y;
4926  m_reference_phi = phi;
4927  m_flags = mpALIGN_SW;
4928  ShapeUpdated();
4929  }
4930 
4931  virtual bool HasBBox()
4932  {
4933  return m_trans_shape_xs.size() != 0;
4934  }
4935 
4938  virtual double GetMinX()
4939  {
4940  return m_bbox_x.min;
4941  }
4942 
4945  virtual double GetMaxX()
4946  {
4947  return m_bbox_x.max;
4948  }
4949 
4952  virtual double GetMinY()
4953  {
4954  return m_bbox_y.min;
4955  }
4956 
4959  virtual double GetMaxY()
4960  {
4961  return m_bbox_y.max;
4962  }
4963 
4964  protected:
4965 
4968  double m_reference_x;
4969  double m_reference_y;
4971 
4972  virtual void DoPlot(wxDC &dc, mpWindow &w);
4973 
4976  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
4977 
4978  // the object points, in local coordinates (to be transformed by the current transformation).
4979  std::vector<double> m_shape_xs;
4980  std::vector<double> m_shape_ys;
4981 
4982  // The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh).
4983  std::vector<double> m_trans_shape_xs;
4984  std::vector<double> m_trans_shape_ys;
4985 
4991 
4995  void ShapeUpdated();
4996 
4997  private:
4999 };
5000 
5001 //-----------------------------------------------------------------------------
5002 // mpCovarianceEllipse - provided by Jose Luis Blanco
5003 //-----------------------------------------------------------------------------
5016 {
5017  public:
5021  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
5022  const wxString &layerName = _T("")) : mpMovableObject(),
5023  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
5024  {
5025  m_continuous = true;
5026  m_name = layerName;
5027  RecalculateShape();
5028  }
5029 
5030  virtual ~mpCovarianceEllipse()
5031  {
5032  ;
5033  }
5034 
5037  double GetQuantiles() const
5038  {
5039  return m_quantiles;
5040  }
5041 
5044  void SetQuantiles(double q)
5045  {
5046  m_quantiles = q;
5047  RecalculateShape();
5048  }
5049 
5051  void SetSegments(int segments)
5052  {
5053  m_segments = segments;
5054  }
5055 
5057  int GetSegments() const
5058  {
5059  return m_segments;
5060  }
5061 
5064  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
5065  {
5066  cov_00 = m_cov_00;
5067  cov_01 = m_cov_01;
5068  cov_11 = m_cov_11;
5069  }
5070 
5073  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
5074  {
5075  m_cov_00 = cov_00;
5076  m_cov_01 = cov_01;
5077  m_cov_11 = cov_11;
5078  RecalculateShape();
5079  }
5080 
5081  protected:
5084  double m_cov_00;
5085  double m_cov_11;
5086  double m_cov_01;
5087  double m_quantiles;
5088 
5092 
5095  void RecalculateShape();
5096 
5097  private:
5099 };
5100 
5101 //-----------------------------------------------------------------------------
5102 // mpPolygon - provided by Jose Luis Blanco
5103 //-----------------------------------------------------------------------------
5109 {
5110  public:
5113  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
5114  {
5115  m_continuous = true;
5116  m_name = layerName;
5117  }
5118 
5119  virtual ~mpPolygon()
5120  {
5121  ;
5122  }
5123 
5129  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
5130 
5131  private:
5133 };
5134 
5135 //-----------------------------------------------------------------------------
5136 // mpBitmapLayer - provided by Jose Luis Blanco
5137 //-----------------------------------------------------------------------------
5143 {
5144  public:
5148  {
5149  m_validImg = false;
5150  m_bitmapChanged = false;
5151  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
5152  }
5153 
5154  virtual ~mpBitmapLayer()
5155  {
5156  ;
5157  }
5158 
5161  void GetBitmapCopy(wxImage &outBmp) const;
5162 
5170  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
5171 
5174  virtual double GetMinX()
5175  {
5176  return m_bitmapX.min;
5177  }
5178 
5181  virtual double GetMaxX()
5182  {
5183  return m_bitmapX.max;
5184  }
5185 
5188  virtual double GetMinY()
5189  {
5190  return m_bitmapY.min;
5191  }
5192 
5195  virtual double GetMaxY()
5196  {
5197  return m_bitmapY.max;
5198  }
5199 
5200  protected:
5201 
5204  wxImage m_bitmap;
5205  wxBitmap m_scaledBitmap;
5208  bool m_validImg;
5210 
5215 
5216  virtual void DoPlot(wxDC &dc, mpWindow &w);
5217 
5218  private:
5220 };
5221 
5222 // utility class
5223 
5225 typedef enum __mp_Colour
5226 {
5227  mpBlue,
5228  mpRed,
5229  mpGreen,
5230  mpPurple,
5231  mpYellow,
5232  mpFuchsia,
5233  mpLime,
5234  mpAqua,
5235  mpOlive
5236 } mpColour;
5237 
5242 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
5243 {
5244  public:
5249  wxIndexColour(unsigned int id)
5250  {
5251  switch (id)
5252  {
5253  case 0:
5254  this->Set(0, 0, 255);
5255  break; // Blue
5256  case 1:
5257  this->Set(255, 0, 0);
5258  break; // Red
5259  case 2:
5260  this->Set(0, 128, 0);
5261  break; // Green
5262  case 3:
5263  this->Set(128, 0, 128);
5264  break; // Purple
5265  case 4:
5266  this->Set(255, 255, 0);
5267  break; // Yellow
5268  case 5:
5269  this->Set(255, 0, 255);
5270  break; // Fuchsia
5271  case 6:
5272  this->Set(0, 255, 0);
5273  break; // Lime
5274  case 7:
5275  this->Set(0, 255, 255);
5276  break; // Aqua/Cyan
5277  case 8:
5278  this->Set(128, 128, 0);
5279  break; // Olive
5280  default:
5281  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
5282  (ChannelType)((rand() * 255) / RAND_MAX));
5283  }
5284  }
5285 };
5286 
5289 // ---------------------------------------------------------------------
5290 #ifdef ENABLE_MP_NAMESPACE
5291  }// namespace MathPlot
5292  // No, iff build enables namespace, its up to app to use it appropriately: using namespace MathPlot;
5293 #endif // ENABLE_MP_NAMESPACE
5294 
5295 #endif // MATHPLOT_H_INCLUDED
sub type for mpFXYVector function
Definition: mathplot.h:755
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:4795
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2830
bool m_enableBufferedPaintDC
For auto DC double buffering.
Definition: mathplot.h:4654
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer.
Definition: mathplot.h:3268
bool IsHorizontal(void) const
Is it a horizontal line?
Definition: mathplot.h:1831
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:657
int GetAxisID(void)
Return the ID of the Axis.
Definition: mathplot.h:2759
mpRange< double > m_rangeY
Y range.
Definition: mathplot.h:2418
sub type for mpText layer
Definition: mathplot.h:744
Align the plot label towards the southeast.
Definition: mathplot.h:696
wxMemoryDC m_buff_dc
DC for double buffering.
Definition: mathplot.h:4652
void SetValue(const double value)
Set x or y value.
Definition: mathplot.h:1823
mpInfoLegend * m_InfoLegend
Pointer to the optional info legend layer.
Definition: mathplot.h:4668
Draw a circle.
Definition: mathplot.h:719
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:704
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:4640
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:2987
int m_infoLegendSelectedSeries
Only used with config window: the selected series in info legend.
Definition: mathplot.h:4683
bool m_LegendIsAlwaysVisible
If true, the name is visible in the legend despite the visibility of the function. Default false.
Definition: mathplot.h:1785
size_t m_endIndex
The end index indicating the last point inside plot area.
Definition: mathplot.h:2242
wxIndexColour(unsigned int id)
Constructor.
Definition: mathplot.h:5249
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:1068
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:4404
std::vector< std::string > labels
Labels of the Values.
Definition: mathplot.h:2552
enum __mp_Colour mpColour
Enumeration of classic colour.
Bitmap type layer.
Definition: mathplot.h:834
static bool m_DefaultLegendIsAlwaysVisible
This value sets the default behaviour when a series is not visible for the legend display...
Definition: mathplot.h:4115
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1198
#define MP_LOOP_ITER
Helper macro for iterating through axis maps without structured binding.
Definition: mathplot.h:131
mpLegendDirection m_item_direction
Layout direction used when arranging legend entries.
Definition: mathplot.h:1593
__Scale_Type
sub_type values for mpLAYER_AXIS
Definition: mathplot.h:762
Plot type layer.
Definition: mathplot.h:819
void Show(bool show)
Set if magnet shall be shown or hidden.
Definition: mathplot.h:3323
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:3732
wxPoint GetMousePosition()
Returns current mouse position in window.
Definition: mathplot.h:4473
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:1735
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:5195
bool IsRightAxis()
Return true if this Y axis is aligned to the right side.
Definition: mathplot.h:3169
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:1428
User defined position. Can be change by mouse drag.
Definition: mathplot.h:667
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:4367
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1888
void SetYAxisID(unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1727
std::map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:3245
bool ShouldBeShown(wxRect plotArea, wxPoint mousePos)
Check conditions if info coords shall be shown or not.
Definition: mathplot.h:1420
mpLegendStyle GetItemMode() const
Get the current legend item drawing mode.
Definition: mathplot.h:1518
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:5108
#define MP_X_RAWTIME
Shortcut for MP_X_UTCTIME.
Definition: mathplot.h:202
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:3535
mpFloatRectSimple(mpRange< double > _x, mpRange< double > _y)
Construct a simple rectangular box.
Definition: mathplot.h:602
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:946
__Symbol_Type
Displaying a symbol instead of a point in the plot function.
Definition: mathplot.h:716
double m_deltaY
Min delta between 2 consecutive coordinate on y direction.
Definition: mathplot.h:2122
void SetCoordIsAlwaysVisible(bool alwaysVisible)
Set the visibility of the mouse coordinates in the info coordinates despite the visibility of the axi...
Definition: mathplot.h:2961
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:2169
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:4636
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:703
__mp_Layer_Type
Major type of an mpLayer (detail is in subtype)
Definition: mathplot.h:815
wxBitmap m_buff_bmp
Bmp for double buffering.
Definition: mathplot.h:4651
Show/Hide grids.
Definition: mathplot.h:645
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:5142
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:2978
void InitializeBoundingBox(double px, double py, int yAxisID)
Initialize the bounding box from a first point for the selected Y axis.
Definition: mathplot.h:4037
mpLabelType
enum for label for grid
Definition: mathplot.h:787
void Update(T value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:382
bool m_mouseMovedAfterRightClick
If the mouse does not move after a right click, then the context menu is displayed.
Definition: mathplot.h:4657
Classic Normal distribution f(x) = exp(-(ln(x)-μ)²/2σ²)/(xσ.sqrt(2π))
Definition: mathplot.h:2471
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2692
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:4659
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:2676
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5113
double m_lastX
Last x-coordinate point added.
Definition: mathplot.h:2244
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2796
bool m_showDraggedSeries
Indicate if series that has been gripped with mouse shall be drawn.
Definition: mathplot.h:1594
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:3789
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:5213
Layer type undefined; SHOULD NOT BE USED.
Definition: mathplot.h:817
enum __mp_Direction_Type mpLegendDirection
Direction for the Legend layer.
__mp_Delete_Action
Action to do with the object associated to the layer when we delete it.
Definition: mathplot.h:850
sub type not defined (should be never used)
Definition: mathplot.h:764
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1197
void SetMagnetize(bool mag)
Enable or disable mouse-position magnet lines (cross-hairs) in the plot area.
Definition: mathplot.h:4446
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1190
double m_cov_11
Covariance matrix element (1,1).
Definition: mathplot.h:5085
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1807
Lock x/y scaling aspect.
Definition: mathplot.h:644
virtual double GetMinY()
Get min Y of the function.
Definition: mathplot.h:2403
void SetMaxNOfPoints(size_t nOfPoints)
Set how many points that is allowed to be drawn at a time.
Definition: mathplot.h:1766
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:1511
wxString m_wildcard
For loadfile() function when we use wxFileDialog.
Definition: mathplot.h:4676
Align the info in margin center-bottom.
Definition: mathplot.h:665
int m_axisWidth
Reserved width for this Y axis including labels, in pixels.
Definition: mathplot.h:3185
Info box type layer.
Definition: mathplot.h:839
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:4794
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set axis label view mode.
Definition: mathplot.h:2822
Abstract class providing a line.
Definition: mathplot.h:1795
mpRange< double > m_rangeX
Range min and max on x axis.
Definition: mathplot.h:2243
Abstract class providing an vertical line.
Definition: mathplot.h:1875
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2782
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2655
bool IsLeftAxis()
Return true if this Y axis is aligned to the left side.
Definition: mathplot.h:3163
double m_reference_y
Current object Y position in plot coordinates.
Definition: mathplot.h:4969
bool m_show
Indicates if magnet shall be shown in plot.
Definition: mathplot.h:1468
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:3361
#define MP_ZOOM_AROUND_CENTER
Default value for zoom around a point (default -1 is no zoom)
Definition: mathplot.h:213
mpRange< int > m_drawY
Range min and max on y axis.
Definition: mathplot.h:2118
wxString m_DefaultDir
The default directory for wxFileDialog.
Definition: mathplot.h:4677
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:2979
int m_labelPos
Bar-label placement mode.
Definition: mathplot.h:2621
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3690
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:3770
std::vector< double > m_ys
internal copy of the set of data on y direction
Definition: mathplot.h:2238
void SetExtraMargin(int extra)
Set the extra margin.
Definition: mathplot.h:4231
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:3144
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1345
bool m_bitmapChanged
True when the cached scaled bitmap must be regenerated.
Definition: mathplot.h:5209
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:4922
bool m_isMonotonicX
Indicates if all all X values are monotonic, i.e increasing, which enables binary search...
Definition: mathplot.h:2239
Chart type layer (bar chart)
Definition: mathplot.h:824
mpRange< double > x
range over x direction
Definition: mathplot.h:594
double GetPosY(int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3681
virtual void SetLogAxis(bool log)
Set Logarithmic mode.
Definition: mathplot.h:2953
double GetQuantiles() const
Get the confidence-interval multiplier used for the ellipse.
Definition: mathplot.h:5037
sub type for mpLine function
Definition: mathplot.h:757
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:1045
void SetAutoFit(bool autoFit)
Set if plot shall be auto fitted when hiding or showing axis and series via mouse.
Definition: mathplot.h:4137
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3822
~mpBarChart()
Destructor.
Definition: mathplot.h:2580
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:3762
T GetMaxAbs(void) const
Max absolute value of the range.
Definition: mathplot.h:437
Draw a cross X.
Definition: mathplot.h:723
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition: mathplot.h:404
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1205
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:257
double m_width
Width of each bar/column in plot units.
Definition: mathplot.h:2619
Draw a triangle up oriented.
Definition: mathplot.h:721
wxTopLevelWindow * m_parent
Pointer to the top-level window containing the plot (used for fullscreen)
Definition: mathplot.h:4620
void SetDefaultLegendIsAlwaysVisible(bool visible)
Set if legend is always visible even if series is not plotted.
Definition: mathplot.h:4122
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:4660
bool IsEnabled() const
Check if magnet is enabled.
Definition: mathplot.h:3308
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:4691
T min
The min value of the range.
Definition: mathplot.h:302
double m_relY
Box Y position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1348
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:1053
int m_flags
Holds label alignment. Default : mpALIGN_SW for series and mpALIGN_CENTER for scale.
Definition: mathplot.h:1202
wxRect GetRect(void)
Create rectangular area defined by start and end points.
Definition: mathplot.h:287
mpRange< double > m_bbox_x
The precomputed bounding box:
Definition: mathplot.h:4989
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:4759
Mouse action drag the plot.
Definition: mathplot.h:783
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:930
mpNormal(double mu, double sigma)
Classic Normal distribution.
Definition: mathplot.h:2479
mpInfoLayer * GetMovingInfoLayer()
Returns moving info layer.
Definition: mathplot.h:4482
wxPoint GetPosition() const
Get the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1302
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1457
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:1108
~mpPieChart()
Destructor.
Definition: mathplot.h:2646
mpRange()
Default constructor.
Definition: mathplot.h:306
T max
The max value of the range.
Definition: mathplot.h:303
void Show(bool show)
Set if info coords shall be shown or hidden.
Definition: mathplot.h:1404
sub type not defined (should be never used)
Definition: mathplot.h:773
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1781
void SetDefaultDir(const wxString &dirname)
Set the default directory for wxFileDialog.
Definition: mathplot.h:4103
enum __Function_Type mpFunctionType
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
sub type not defined (should be never used)
Definition: mathplot.h:751
void Check(void)
Check to always have a range. If min = max then introduce the 0 to make a range.
Definition: mathplot.h:413
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:4250
sub type not defined (should be never used)
Definition: mathplot.h:743
double m_lastY
Last y-coordinate point added.
Definition: mathplot.h:2246
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1192
T GetCenter(void) const
Center of the range.
Definition: mathplot.h:431
Just the end of ZOrder.
Definition: mathplot.h:841
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4952
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:832
void Set(T _value)
Initialize min and max.
Definition: mathplot.h:328
mpRange< double > m_axisRange
Range axis values when autosize is false.
Definition: mathplot.h:2983
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:4174
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:4110
double m_cov_01
Covariance matrix element (0,1), equal to element (1,0).
Definition: mathplot.h:5086
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1285
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1654
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:4244
Draw a plus +.
Definition: mathplot.h:724
void SetMouseLeftDownAction(mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:4455
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:4627
Keep the object, just remove the layer from the layer list.
Definition: mathplot.h:852
double m_mu
Mean value.
Definition: mathplot.h:2453
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:4661
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1978
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:2043
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:4631
wxColour m_barColour
Fill colour used for the bars.
Definition: mathplot.h:2620
Delete the object regardless of the CanDelete value and remove it from the layer list.
Definition: mathplot.h:854
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:1200
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:4645
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:4913
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:3276
Align the plot label towards the southwest.
Definition: mathplot.h:697
Implement the legend to be added to the plot This layer allows you to add a legend to describe the pl...
Definition: mathplot.h:1493
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:3079
double m_quantiles
Confidence-interval multiplier used when drawing the ellipse.
Definition: mathplot.h:5087
Align the y-axis towards left border.
Definition: mathplot.h:684
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1201
#define ISNOTNULL(x)
Nullity test. Old solution is to test according small epsilon: (fabs(x) > MP_EPSILON) ...
Definition: mathplot.h:207
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:4766
Align the x-axis towards bottom border.
Definition: mathplot.h:674
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2545
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3806
void Assign(T value1, T value2)
Assign values to min and max.
Definition: mathplot.h:358
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:4632
Plot (function) type layer.
Definition: mathplot.h:837
void UpdateDesiredBoundingBox(mpAxisUpdate update)
Update m_desired bounds.
Definition: mathplot.h:3917
void UpdateBoundingBoxToInclude(double px, double py)
Update bounding box (X and Y axis) to include this point.
Definition: mathplot.h:618
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2846
bool m_IsHorizontal
Is the line horizontal? Default false.
Definition: mathplot.h:1838
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1204
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1690
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:883
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1193
bool GetCoordIsAlwaysVisible() const
Get the visibility of the mouse coordinates in the info coordinates.
Definition: mathplot.h:2969
bool GetCanDelete(void) const
Retreive what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1177
Axis type layer.
Definition: mathplot.h:835
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:2700
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:2982
Draw a triangle down oriented.
Definition: mathplot.h:722
wxCoord m_mouseY
Last mouse Y position in window pixel coordinates.
Definition: mathplot.h:1473
Axis type layer.
Definition: mathplot.h:818
void SetCanDelete(bool canDelete)
Set what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1170
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:5174
bool GetMagnetize() const
Is mouse magnetization enabled? Useful to read the position on the axes.
Definition: mathplot.h:4440
double m_value
The x or y coordinates of the line.
Definition: mathplot.h:1837
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:4666
void Enable(bool enable)
Enables the magnet.
Definition: mathplot.h:3302
wxPen m_penSeries
Pen used to draw the series marker when series-coordinate mode is active.
Definition: mathplot.h:1475
wxPoint m_center
Center of the pie chart in device coordinates.
Definition: mathplot.h:2708
std::vector< double > m_trans_shape_ys
Transformed shape vertices in Y coordinates.
Definition: mathplot.h:4984
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:2984
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:1387
#define MP_Y_BORDER_SEPARATION
Default minimum separation in pixels between Y axes and the plot border.
Definition: mathplot.h:195
size_t GetMaxNOfPoints() const
Get maximum number of points to plot.
Definition: mathplot.h:1773
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:2789
Align the info in margin center-right.
Definition: mathplot.h:663
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:4339
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:1087
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:3215
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:2307
void SetDrawState(bool drawState)
Set whether the plot has already been drawn on the current printout.
Definition: mathplot.h:4862
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:4737
mpRange< double > lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:3233
double m_const
Const factor.
Definition: mathplot.h:2456
std::unordered_map< int, mpRange< double > > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:3619
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:5204
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:4376
void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
Ensure the bounding box includes the given point for the selected Y axis.
Definition: mathplot.h:4022
each visible plot is described on its own line, one above the other
Definition: mathplot.h:711
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:3646
int m_xPos
Leftmost X pixel occupied by this axis (starting point).
Definition: mathplot.h:3186
Align the x-axis towards top plot.
Definition: mathplot.h:677
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1184
mpRange< double > bound
Range min and max.
Definition: mathplot.h:3231
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:790
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:4256
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:1443
Align the y-axis towards right border.
Definition: mathplot.h:688
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:732
std::unordered_map< int, mpRange< double > > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:3633
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:2241
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:5181
Show/Hide info coord.
Definition: mathplot.h:646
Align the x-axis towards top border.
Definition: mathplot.h:678
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:1101
Mouse action draw a box to zoom inside.
Definition: mathplot.h:782
mpFXGeneric(const wxString &name=wxT("Generic FX function"), int flags=mpALIGN_LEFT, unsigned int yAxisID=0)
Definition: mathplot.h:2370
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:5073
__Function_Type
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
Definition: mathplot.h:749
Classic Gaussian distribution f(x) = exp(-(x-μ)²/2σ²)/sqrt(2πσ²)
Definition: mathplot.h:2435
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition: mathplot.h:77
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4838
Align the y-axis towards left plot.
Definition: mathplot.h:685
int m_last_ly
Last logical Y origin, used for double buffering.
Definition: mathplot.h:4650
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:4672
size_t m_maxNOfPoints
Maximum number of points to draw to screen.
Definition: mathplot.h:1787
wxSize GetSize() const
Get the size of the box (in pixels)
Definition: mathplot.h:1317
Chart type layer.
Definition: mathplot.h:838
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:2981
Set label for axis in scientific notation.
Definition: mathplot.h:794
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:394
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1344
Copy a screen shot to the clipboard.
Definition: mathplot.h:647
Fit view to match bounding box of all layers.
Definition: mathplot.h:640
Create a generic FX function Override the ComputeY() function with your function. ...
Definition: mathplot.h:2363
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:4773
bool PointIsInside(double px, double py) const
Is point inside this bounding box?
Definition: mathplot.h:609
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:653
mpRange< double > m_bitmapY
Range of the bitmap on y direction.
Definition: mathplot.h:5214
bool IsShown()
Get shown status.
Definition: mathplot.h:3329
bool m_cacheDirty
Indicate that the cached buffer m_buff_bmp need to be re-created.
Definition: mathplot.h:4653
Center view on click position.
Definition: mathplot.h:643
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1783
mpLegendStyle m_item_mode
Visual style used for each legend entry.
Definition: mathplot.h:1592
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:2181
bool m_autoFit
Automatically fit plot when hiding / showing axis and series.
Definition: mathplot.h:4665
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:672
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1400
sub type for all layers who are function.
Definition: mathplot.h:758
Draw a square.
Definition: mathplot.h:720
mpRange< double > GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:3586
bool operator==(const mpAxisData &other) const
Compare axis data while ignoring the axis pointer itself.
Definition: mathplot.h:3237
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:4897
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2491
Align the x-axis center plot.
Definition: mathplot.h:676
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:741
double m_radius
Radius of the pie chart in pixels.
Definition: mathplot.h:2707
double m_deltaX
Min delta between 2 consecutive coordinate on x direction.
Definition: mathplot.h:2121
__mp_Colour
Enumeration of classic colour.
Definition: mathplot.h:5225
mpRange< double > GetDesiredBoundY(int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3609
int m_BarWidth
Bar width in pixels when the XY series is drawn in bar mode.
Definition: mathplot.h:2124
Align the plot label towards the northwest.
Definition: mathplot.h:694
double m_total_value
Total of the values vector.
Definition: mathplot.h:2555
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:4625
void SetMinScale(double min)
Set the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2870
void SetbgColour(const wxColour &colour)
Set the plot background colour.
Definition: mathplot.h:4351
bool GetAutoStep() const
Get if auto stop is enabled.
Definition: mathplot.h:1758
void SetHovering(bool hover)
Set if axis shall be highlighted when a series is dragged over it.
Definition: mathplot.h:2937
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:2069
std::vector< double > m_shape_xs
Shape vertices in object-local X coordinates.
Definition: mathplot.h:4979
virtual bool IsLogAxis()
Get if we are in Logarithmic mode.
Definition: mathplot.h:2945
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1697
mpRange< double > desired
Desired range min and max.
Definition: mathplot.h:3232
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:3087
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:5242
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1784
mpRange(T value1, T value2)
Create range with the 2 values.
Definition: mathplot.h:313
bool IsTopAxis()
Return true when this X axis is aligned at the top edge or top border.
Definition: mathplot.h:3094
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1662
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:4641
No symbol is drawing.
Definition: mathplot.h:718
Layer for bar chart.
Definition: mathplot.h:2573
mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:3942
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:1751
__Chart_Type
sub_type values for mpLAYER_CHART
Definition: mathplot.h:771
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1195
wxCoord m_scaledBitmap_offset_x
Cached X pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5206
virtual double ComputeY(double x)
The main computation of the FX function.
Definition: mathplot.h:2494
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2455
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:1469
abstract Layer for chart (bar and pie).
Definition: mathplot.h:2514
void SetInitialPosition(wxPoint pos)
Set the position in percent of the upper left corner of the box.
Definition: mathplot.h:1309
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:705
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:592
sub type for all layers who are chart.
Definition: mathplot.h:776
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:1061
unsigned int mpOptional_uint
Optional unsigned integer fallback type used when std::optional is unavailable.
Definition: mathplot.h:120
Align the info in margin center-left.
Definition: mathplot.h:659
void SetLabelFormat(const wxString &format, bool updateLabelMode=false)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2805
const wxRect & GetRectangle() const
Get the current rectangle coordinates.
Definition: mathplot.h:1324
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:3954
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:792
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:692
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1780
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:3973
void ToLog(void)
Convert to log range.
Definition: mathplot.h:443
void ShowDraggedSeries(bool active)
Set if dragged series shall be shown or hidden.
Definition: mathplot.h:1545
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:4197
mpRange< double > m_rangeY
Range min and max on y axis.
Definition: mathplot.h:2245
bool operator!=(const mpRange &other) const
Compare two ranges for inequality.
Definition: mathplot.h:464
virtual int GetSize()
Return the number of points in the series We assume that size of m_xs equals size of m_ys...
Definition: mathplot.h:2201
bool IsDraggedSeriesShown() const
Get shown status of dragged series.
Definition: mathplot.h:1552
int m_symbolSize2
Size of the symbol div 2.
Definition: mathplot.h:1782
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5188
sub type for mpInfoLegend layer
Definition: mathplot.h:737
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2862
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:2270
void SetLogXaxis(bool log)
Enable or disable logarithmic scaling on the X axis.
Definition: mathplot.h:4418
int GetMarginRight(bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:4182
#define MP_EPSILON
An epsilon for float comparison to 0.
Definition: mathplot.h:205
mpRange< int > m_drawX
Range min and max on x axis.
Definition: mathplot.h:2117
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1860
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:2221
bool ShouldBeShown(wxPoint mousePos)
Check conditions if magnet shall be shown.
Definition: mathplot.h:3317
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:2231
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:3984
bool GetLegendIsAlwaysVisible() const
Get the visibility of the legend.
Definition: mathplot.h:1743
Text box type layer.
Definition: mathplot.h:821
mpMouseButtonAction GetMouseLeftDownAction()
Returns the type of action for the left mouse button.
Definition: mathplot.h:4464
double pos
Position.
Definition: mathplot.h:3230
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:4151
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:682
sub type for mpBarChart
Definition: mathplot.h:774
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:4647
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1250
Load a file.
Definition: mathplot.h:651
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:895
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:4787
bool m_fullscreen
Boolean value indicating that we are in fullscreen mode (default false)
Definition: mathplot.h:4621
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:4642
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:1277
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:903
Line (horizontal or vertical) type layer.
Definition: mathplot.h:836
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1371
double m_mu
Mean value.
Definition: mathplot.h:2489
mpRange< double > y
range over y direction
Definition: mathplot.h:595
mpLocation m_location
The location of the text.
Definition: mathplot.h:4796
Delete the object if CanDelete is true and remove it from the layer list.
Definition: mathplot.h:853
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:4052
mpLabelType m_labelType
Label formatting mode used for the X coordinate display.
Definition: mathplot.h:1470
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:4635
sub type for mpTitle layer
Definition: mathplot.h:745
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:3781
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1669
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:4624
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1507
double GetMaxScale() const
Get the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2894
Align the info in margin center-top.
Definition: mathplot.h:661
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:801
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:4629
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:4392
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3708
int GetBarWidth(void) const
Get the width of the bar when we plot in bar mode.
Definition: mathplot.h:2100
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:4361
double m_labelAngle
Rotation angle used for bar labels, in degrees.
Definition: mathplot.h:2622
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1436
void SetAxisID(unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2768
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:2292
int mpOptional_int
Optional integer fallback type used when std::optional is unavailable.
Definition: mathplot.h:122
void SetMin(T _min)
Set min function, correct max.
Definition: mathplot.h:342
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:4290
double m_max_value
Max value of the values vector.
Definition: mathplot.h:2554
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1641
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1916
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2663
mpTitle(const wxString &name)
Definition: mathplot.h:4818
void EnableBufferedPaintDC(const bool enabled)
Enable/disable the auto buffering of PaintDC.
Definition: mathplot.h:3799
Plot layer implementing a simple title.
Definition: mathplot.h:4809
Set no label for axis (useful for bar)
Definition: mathplot.h:807
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:3134
bool m_validImg
True when the source image is valid and ready to draw.
Definition: mathplot.h:5208
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:780
#define MP_OPTNULL_INT
Null sentinel used for mpOptional_int / mpOptional_uint in the fallback implementation.
Definition: mathplot.h:124
sub type for mpPieChart
Definition: mathplot.h:775
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:4931
bool ViewAsBar(void) const
Get if we are in bar mode.
Definition: mathplot.h:2109
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1349
mpRange< double > GetBoundY(int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3600
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:1135
mpGaussian(double mu, double sigma)
Classic Gaussian distribution.
Definition: mathplot.h:2443
Align the plot label towards the northeast.
Definition: mathplot.h:695
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:4265
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:3657
only for mpInfoCoords
Definition: mathplot.h:668
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1163
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1199
std::vector< double > m_trans_shape_xs
Transformed shape vertices in X coordinates.
Definition: mathplot.h:4983
mpLegendDirection GetItemDirection() const
Get the current legend item layout direction.
Definition: mathplot.h:1532
int GetAxisWidth()
Get the reserved width of the Y axis in pixels.
Definition: mathplot.h:3157
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:4238
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2854
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:2061
virtual double ComputeY(double x)
The main computation of the FX function.
Definition: mathplot.h:2458
sub type for mpFXY function
Definition: mathplot.h:754
wxCoord m_mouseX
Last mouse X position in window pixel coordinates.
Definition: mathplot.h:1472
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:3296
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1779
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:4382
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:3100
std::vector< double > m_xs
internal copy of the set of data on x direction
Definition: mathplot.h:2237
void SetScale(mpRange< double > range)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2921
mpRange< double > GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:3592
#define m_yID
Alias for the Y-axis identifier when structured binding is unavailable.
Definition: mathplot.h:133
~mpChart()
Destructor.
Definition: mathplot.h:2521
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:3995
virtual double GetY(double x)
Get function value for argument.
Definition: mathplot.h:2384
Abstract class providing an horizontal line.
Definition: mathplot.h:1846
Zoom into view at clickposition / window center.
Definition: mathplot.h:641
int GetMarginLeft(bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:4222
wxBitmap m_scaledBitmap
Cached scaled bitmap used for drawing.
Definition: mathplot.h:5205
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:4628
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:5091
int GetSegments() const
Get the number of line segments used to approximate the ellipse. */.
Definition: mathplot.h:5057
bool m_enableScrollBars
Enable scrollbar in plot window (default false)
Definition: mathplot.h:4664
double scale
Scale.
Definition: mathplot.h:3229
Align the info in margin top-left.
Definition: mathplot.h:660
bool IsSet()
Check if this mpRange has been assigned any values.
Definition: mathplot.h:373
Zoom out.
Definition: mathplot.h:642
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2736
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:1021
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:3282
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:4130
void SetBrush(const wxColour &colour, enum wxBrushStyle style=wxBRUSHSTYLE_SOLID)
Set layer brush.
Definition: mathplot.h:1079
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:3110
double GetMinScale() const
Get the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2878
double m_relX
Box X position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1347
int m_reserveXY
Memory reserved for m_xs and m_ys. Default 1000.
Definition: mathplot.h:2240
bool PointIsInside(T point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:450
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:709
sub type for mpInfoLayer layer
Definition: mathplot.h:735
Align the x-axis towards bottom plot.
Definition: mathplot.h:675
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:5015
virtual double GetMaxY()
Get max Y of the function.
Definition: mathplot.h:2412
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2814
int GetMarginTop(bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:4165
mpInfoCoords * m_InfoCoords
Pointer to the optional info coords layer.
Definition: mathplot.h:4667
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:3963
bool m_series_coord
True to show the nearest plotted series value instead of raw mouse Y coordinates. ...
Definition: mathplot.h:1474
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:799
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:3226
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:701
const wxColour & GetbgColour() const
Get the plot background colour.
Definition: mathplot.h:4345
Layer for pie chart.
Definition: mathplot.h:2637
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:1037
Align the y-axis towards right plot.
Definition: mathplot.h:687
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:2912
T Length(void) const
Length of the range.
Definition: mathplot.h:425
sub type for mpScaleX
Definition: mathplot.h:765
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:4009
sub type for mpInfoCoords layer
Definition: mathplot.h:736
bool m_CoordIsAlwaysVisible
If true, the mouse coordinates is visible in the info coordinates despite the visibility of the axis...
Definition: mathplot.h:2989
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:476
Set label user defined.
Definition: mathplot.h:805
void SetColumnWidth(const double colWidth)
Set the bar width in plot units.
Definition: mathplot.h:2589
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:5021
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:1029
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:4655
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1194
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:3666
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:797
sub type not defined (should be never used)
Definition: mathplot.h:734
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:803
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:5064
void SetMax(T _max)
Set max function, correct min.
Definition: mathplot.h:350
Bitmap type layer.
Definition: mathplot.h:822
HitCode
Return codes for GetLegendHitRegion() if no series was hit.
Definition: mathplot.h:1582
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1331
bool IsVisible() const
Is this layer visible?
Definition: mathplot.h:1128
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:2775
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:911
bool IsShown()
Get shown status.
Definition: mathplot.h:1411
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:1149
int m_last_lx
Last logical X origin, used for double buffering.
Definition: mathplot.h:4649
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1705
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2985
Align the info in margin bottom-left.
Definition: mathplot.h:664
const wxString & GetWildcard(void) const
Get wildcard.
Definition: mathplot.h:4085
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:4902
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:753
Info box type layer.
Definition: mathplot.h:820
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:3753
mpOptional_int m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:4663
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3743
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3698
wxCoord m_scaledBitmap_offset_y
Cached Y pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5207
Align the y-axis center plot.
Definition: mathplot.h:686
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:1901
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:954
Plot layer implementing a text string.
Definition: mathplot.h:4732
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:921
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:4643
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4959
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:4530
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:4296
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:1115
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1196
double m_sigma
Sigma value.
Definition: mathplot.h:2454
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:4191
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:938
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1346
int GetMarginBottom(bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:4205
Shows information about the mouse commands.
Definition: mathplot.h:652
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:4429
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:4157
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:3549
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:4630
mpRange< double > m_bbox_y
Range of bounding box on y direction.
Definition: mathplot.h:4990
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:4674
legend components follow each other horizontally on a single line
Definition: mathplot.h:712
Align the info in margin top-right.
Definition: mathplot.h:662
double m_reference_phi
Current object rotation angle in radians.
Definition: mathplot.h:4970
void InitializeBoundingBox(double px, double py)
Initialize bounding box with an initial point.
Definition: mathplot.h:628
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1525
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:5044
double m_const
Const factor.
Definition: mathplot.h:2492
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1718
void SetSegments(int segments)
Set the number of line segments used to approximate the ellipse.
Definition: mathplot.h:5051
sub type for all layers who are scale.
Definition: mathplot.h:767
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:4637
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:300
void Set(T _min, T _max)
Set min, max function.
Definition: mathplot.h:335
Align the info in margin bottom-right.
Definition: mathplot.h:666
bool m_boxZoomActive
Indicate if box zoom is active.
Definition: mathplot.h:4670
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:4968
double GetScaleY(int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:3574
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:2684
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1676
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4938
sub type for mpMovableObject function
Definition: mathplot.h:756
Plot layer, abstract base class.
Definition: mathplot.h:867
std::vector< double > values
Values of the chart.
Definition: mathplot.h:2551
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1203
void SetNeedUpdate()
Mark the legend bitmap as needing regeneration.
Definition: mathplot.h:1538
bool IsInside(wxCoord xPixel)
Return true if the given X pixel lies within this Y-axis drawing area.
Definition: mathplot.h:3175
mpRange< double > GetScale() const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2929
std::vector< double > m_shape_ys
Shape vertices in object-local Y coordinates.
Definition: mathplot.h:4980
bool m_autoStep
Calculates m_step automatically based on how many points you want to draw.
Definition: mathplot.h:1786
double GetValue() const
Get the x or y coordinates of the line.
Definition: mathplot.h:1815
enum __Scale_Type mpScaleType
sub_type values for mpLAYER_AXIS
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:4780
void SetFactor(int factor)
Definition: mathplot.h:4874
sub type for mpFX function
Definition: mathplot.h:752
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:1005
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1191
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:2986
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:4634
double m_sigma
Sigma value.
Definition: mathplot.h:2490
wxPoint m_mousePos
Current mouse position in window.
Definition: mathplot.h:4658
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:4662
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:1094
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:1013
unsigned int m_timeConv
Time conversion mode used when formatting date/time X values.
Definition: mathplot.h:1471
void SetScale(double min, double max)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2903
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1221
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:5084
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:4214
#define m_yData
Alias for the Y-axis data when structured binding is unavailable.
Definition: mathplot.h:135
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:4623
std::vector< wxColour > colours
Per-slice colours used when drawing the chart.
Definition: mathplot.h:2709
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:2980
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:4639
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2332
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1338
void SetWildcard(const wxString &wildcard)
Set wildcard for LoadFile() function when we use wxFileDialog.
Definition: mathplot.h:4077
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:4656
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:4646
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:1142
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2751
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4945
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:3896
void SetMaxScale(double max)
Set the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2886
#define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class)
Definition for RTTI.
Definition: mathplot.h:220
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2838
sub type for mpScaleY
Definition: mathplot.h:766
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1683
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:5147
void SetScaleY(const double scaleY, int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:3558
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:3253
Text box type layer.
Definition: mathplot.h:840
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:3384
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:1156
Line (horizontal or vertical) type layer.
Definition: mathplot.h:823
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:2285