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: 27/03/2026
10 // Copyright: (c) David Schalig, Davide Rondini
11 // Licence: wxWindows licence
13 
14 #ifndef MATHPLOT_H_INCLUDED
15 #define MATHPLOT_H_INCLUDED
16 
56 //this definition uses windows dll to export function.
57 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
58 //mathplot_EXPORTS will be defined by cmake
59 #ifdef mathplot_EXPORTS
60 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
62 #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
64 #else // not making DLL
65 #define WXDLLIMPEXP_MATHPLOT
67 #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
69 #endif
70 
71 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
72 #pragma interface "mathplot.h"
73 #endif
74 
75 #include <cassert> // For assert debug message. Disable if NDEBUG is defined
76 #include <vector>
77 #include <map>
78 #include <unordered_map>
79 
80 // Multiple define to compile with C++14 because
81 // Optional is only for C++ >= 17
82 // Structured binding is a C++17 feature
83 #if (defined(__cplusplus) && (__cplusplus > 201402L)) // C++17 or newer
84 // Use optional
85 #include <optional>
86 typedef std::optional<unsigned int> mpOptional_uint;
87 typedef std::optional<int> mpOptional_int;
88 #define MP_OPTNULL_INT std::nullopt
89 #define MP_OPTTEST(opt) (opt)
90 #define MP_OPTGET(opt) (*opt)
91 // Use structured binding
92 #define MP_LOOP_ITER auto& [m_yID, m_yData]
93 
94 #else
95 // To replace optional int
96 typedef unsigned int mpOptional_uint;
97 typedef int mpOptional_int;
98 #define MP_OPTNULL_INT -1
99 #define MP_OPTTEST(opt) ((opt) != -1)
100 #define MP_OPTGET(opt) (opt)
101 // To replace structured binding
102 #define MP_LOOP_ITER auto& elem
103 #define m_yID elem.first
104 #define m_yData elem.second
105 #endif
106 
107 // #include <wx/wx.h>
108 #include <wx/defs.h>
109 #include <wx/menu.h>
110 #include <wx/scrolwin.h>
111 #include <wx/event.h>
112 #include <wx/dynarray.h>
113 #include <wx/pen.h>
114 #include <wx/dcmemory.h>
115 #include <wx/string.h>
116 #include <wx/print.h>
117 #include <wx/image.h>
118 #include <wx/intl.h>
119 
120 #include <cmath>
121 #include <deque>
122 #include <algorithm>
123 
129 #if defined(MP_USER_INCLUDE)
130 #define header MP_USER_INCLUDE.h
131 #define xstr(x) #x
132 #define str(x) xstr(x)
133 #include str(header)
134 #undef header
135 #endif
136 
137 // No, this is supposed to be a build parameter: #define ENABLE_MP_CONFIG
138 #ifdef ENABLE_MP_CONFIG
139  #include "MathPlotConfig.h"
140 #endif // ENABLE_MP_CONFIG
141 
146 // No, this is supposed to be a build parameter: #define ENABLE_MP_NAMESPACE
147 #ifdef ENABLE_MP_NAMESPACE
148  namespace MathPlot {
149 #endif // ENABLE_MP_NAMESPACE
150 
151 #ifdef ENABLE_MP_DEBUG
152 // For memory leak debug
153 #ifdef _WINDOWS
154 #ifdef _DEBUG
155 #include <crtdbg.h>
156 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
157 #else
158 #define DEBUG_NEW new
159 #endif // _DEBUG
160 #endif // _WINDOWS
161 #endif // ENABLE_MP_DEBUG
162 
163 // Separation for axes when set close to border
164 #define X_BORDER_SEPARATION 40
165 #define Y_BORDER_SEPARATION 60
166 
168 #define mpX_LOCALTIME 0x10
169 
170 #define mpX_UTCTIME 0x20
171 #define mpX_RAWTIME mpX_UTCTIME
173 
175 #define EPSILON 1e-8
176 #define ISNOTNULL(x) (fabs(x) > EPSILON)
178 
180 #define EXTRA_MARGIN 8
181 
183 #define ZOOM_AROUND_CENTER -1
184 
185 //-----------------------------------------------------------------------------
186 // classes
187 //-----------------------------------------------------------------------------
188 
215 
216 #ifdef ENABLE_MP_CONFIG
218 #endif // ENABLE_MP_CONFIG
219 
221 typedef union
222 {
223  struct
224  {
225  wxCoord startPx;
226  wxCoord endPx;
227  wxCoord startPy;
228  wxCoord endPy;
229  };
230  struct
231  {
232  wxCoord left;
233  wxCoord top;
234  wxCoord right;
235  wxCoord bottom;
236  };
237  struct
238  {
239  wxCoord x1;
240  wxCoord y1;
241  wxCoord x2;
242  wxCoord y2;
243  };
244  wxCoord tab[4];
245 } mpRect;
246 
252 template<typename T>
253 struct mpRange
254 {
255  T min = 0;
256  T max = 0;
257 
260  {
261  min = 0;
262  max = 0;
263  }
264 
266  mpRange(T value1, T value2)
267  {
268  if (value1 < value2)
269  {
270  min = value1;
271  max = value2;
272  }
273  else
274  {
275  min = value2;
276  max = value1;
277  }
278  }
279 
281  void Set(T _value)
282  {
283  min = _value;
284  max = _value;
285  }
286 
288  void Set(T _min, T _max)
289  {
290  min = _min;
291  max = _max;
292  }
293 
295  void SetMin(T _min)
296  {
297  min = _min;
298  if (max < min)
299  max = min;
300  }
301 
303  void SetMax(T _max)
304  {
305  max = _max;
306  if (min > max)
307  min = max;
308  }
309 
311  void Assign(T value1, T value2)
312  {
313  if (value1 < value2)
314  {
315  min = value1;
316  max = value2;
317  }
318  else
319  {
320  min = value2;
321  max = value1;
322  }
323  }
324 
326  bool IsSet()
327  {
328  return ((min != 0) || (max != 0));
329  }
330 
335  void Update(T value)
336  {
337  if (value < min)
338  min = value;
339  else
340  if (value > max)
341  max = value;
342  }
343 
347  void Update(T _min, T _max)
348  {
349  if (_min < min)
350  min = _min;
351  if (_max > max)
352  max = _max;
353  }
354 
357  void Update(mpRange range)
358  {
359  if (range.min < min)
360  min = range.min;
361  if (range.max > max)
362  max = range.max;
363  }
364 
366  void Check(void)
367  {
368  if (min == max)
369  {
370  if (max > 0)
371  min = 0;
372  else
373  max = 0;
374  }
375  }
376 
378  T Length(void) const
379  {
380  return max - min;
381  }
382 
384  T GetCenter(void) const
385  {
386  return (min + max) / 2;
387  }
388 
390  T GetMaxAbs(void) const
391  {
392  return std::max(fabs(min), fabs(max));
393  }
394 
396  void ToLog(void)
397  {
398  min = (min > 0) ? log10(min) : 0;
399  max = (max > 0) ? log10(max) : 0;
400  }
401 
403  bool PointIsInside(T point) const
404  {
405  return ((point >= min) && (point <= max));
406  }
407 
408 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
409  bool operator==(const mpRange&) const = default;
410 #else
411  bool operator==(const mpRange &other) const
412  {
413  return (min == other.min) && (max == other.max);
414  }
415  bool operator!=(const mpRange& other) const
416  {
417  return !(*this == other);
418  }
419 #endif
420 };
421 
427 struct [[deprecated("No more used, X and Y are now separated")]] mpFloatRect
428 {
429  mpRange<double> x;
430  std::vector<mpRange<double>> y;
431 
438  mpFloatRect(mpWindow& w);
439 
441  mpFloatRect() = delete;
442 
449  bool PointIsInside(double px, double py, size_t yAxisID = 0) const {
450  if (yAxisID < y.size())
451  {
452  if( (px < x.min || px > x.max) ||
453  (py < y[yAxisID].min || py > y[yAxisID].max))
454  {
455  return false;
456  }
457  }
458  else
459  {
460  return false;
461  }
462 
463  return true;
464  }
465 
472  void UpdateBoundingBoxToInclude(double px, double py, size_t yAxisID = 0) {
473  assert(yAxisID < y.size());
474  if (yAxisID < y.size())
475  {
476  if (px < x.min ) x.min = px;
477  else if (px > x.max ) x.max = px;
478  if (py < y[yAxisID].min ) y[yAxisID].min = py;
479  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
480  }
481  }
482 
489  void InitializeBoundingBox(double px, double py, size_t yAxisID = 0) {
490  assert(yAxisID < y.size());
491  if (yAxisID < y.size())
492  {
493  x.min = x.max = px;
494  y[yAxisID].min = y[yAxisID].max = py;
495  }
496  }
498  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
500 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
501  bool operator==(const mpFloatRect&) const = default;
502 #else
503  // We compare with an epsilon precision
504  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
505  bool operator==(const mpFloatRect& rect) const
506  {
507  auto Same = [](double a, double b) {
508  return std::fabs(a - b) < EPSILON;
509  };
510 
511  // Compare scalar members
512  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
513  {
514  return false;
515  }
516 
517  // Compare vector sizes
518  if (y.size() != rect.y.size())
519  {
520  return false;
521  }
522 
523  // Compare each Y boundary
524  for (size_t i = 0; i < y.size(); ++i)
525  {
526  if (!Same(y[i].min, rect.y[i].min) ||
527  !Same(y[i].max, rect.y[i].max) )
528  {
529  return false;
530  }
531  }
532 
533  return true;
534  }
535 #endif
536 };
537 
544 {
547 
554 
560  bool PointIsInside(double px, double py) const {
561  return x.PointIsInside(px) && y.PointIsInside(py);
562  }
563 
569  void UpdateBoundingBoxToInclude(double px, double py)
570  {
571  x.Update(px);
572  y.Update(py);
573  }
574 
579  void InitializeBoundingBox(double px, double py)
580  {
581  x.Set(px, px);
582  y.Set(py, py);
583  }
584 };
585 
589 enum
590 {
591  mpID_FIT = 2000,
599 #ifdef ENABLE_MP_CONFIG
600  mpID_CONFIG,
601 #endif // ENABLE_MP_CONFIG
605 };
606 
608 typedef enum __mp_Location_Type
609 {
620 } mpLocation;
621 
623 typedef enum __XAxis_Align_Type
624 {
630 } mpXAxis_Align;
631 
633 typedef enum __YAxis_Align_Type
634 {
640 } mpYAxis_Align;
641 
644 {
649 } mpPlot_Align;
650 
652 typedef enum __mp_Style_Type
653 {
657 } mpLegendStyle;
658 
661 {
665 
667 typedef enum __Symbol_Type
668 {
676 } mpSymbol;
677 
678 //-----------------------------------------------------------------------------
679 // mpLayer sub_type values
680 //-----------------------------------------------------------------------------
681 
683 typedef enum __Info_Type
684 {
689 } mpInfoType;
690 
692 typedef enum __Text_Type
693 {
697 } mpTextType;
698 
700 typedef enum __Function_Type
701 {
711 
713 typedef enum __Scale_Type
714 {
719 } mpScaleType;
720 
722 typedef enum __Chart_Type
723 {
728 } mpChartType;
729 
732 {
735 };
736 
739 {
759 };
760 
761 //-----------------------------------------------------------------------------
762 // mpLayer
763 //-----------------------------------------------------------------------------
764 
766 typedef enum __mp_Layer_Type
767 {
776 } mpLayerType;
777 
783 typedef enum __mp_Layer_ZOrder
784 {
793 } mpLayerZOrder;
794 
801 typedef enum __mp_Delete_Action
802 {
807 
818 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
819 {
820  public:
825  mpLayer(mpLayerType layerType);
826 
827  virtual ~mpLayer()
828  {
829  ;
830  }
831 
835  {
836  m_win = &w;
837  }
838 
846  virtual bool HasBBox()
847  {
848  return true;
849  }
850 
855  mpLayerType GetLayerType() const
856  {
857  return m_type;
858  }
859 
863  int GetLayerSubType() const
864  {
865  return m_subtype;
866  }
867 
873  virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
874  {
875  *subtype = m_subtype;
876  return (m_type == typeOfInterest);
877  }
878 
882  virtual double GetMinX()
883  {
884  return -1.0;
885  }
886 
890  virtual double GetMaxX()
891  {
892  return 1.0;
893  }
894 
898  virtual double GetMinY()
899  {
900  return -1.0;
901  }
902 
906  virtual double GetMaxY()
907  {
908  return 1.0;
909  }
910 
952  void Plot(wxDC &dc, mpWindow &w);
953 
957  void SetName(const wxString &name)
958  {
959  m_name = name;
960  }
961 
965  const wxString& GetName() const
966  {
967  return m_name;
968  }
969 
973  void SetFont(const wxFont &font)
974  {
975  m_font = font;
976  }
977 
981  const wxFont& GetFont() const
982  {
983  return m_font;
984  }
985 
989  void SetFontColour(const wxColour &colour)
990  {
991  m_fontcolour = colour;
992  }
993 
997  const wxColour& GetFontColour() const
998  {
999  return m_fontcolour;
1000  }
1001 
1005  void SetPen(const wxPen &pen)
1006  {
1007  m_pen = pen;
1008  }
1009 
1013  const wxPen& GetPen() const
1014  {
1015  return m_pen;
1016  }
1017 
1020  void SetBrush(const wxBrush &brush)
1021  {
1022  if (brush == wxNullBrush)
1023  m_brush = *wxTRANSPARENT_BRUSH;
1024  else
1025  m_brush = brush;
1026  }
1027 
1030  const wxBrush& GetBrush() const
1031  {
1032  return m_brush;
1033  }
1034 
1037  void SetShowName(bool show)
1038  {
1039  m_showName = show;
1040  }
1041 
1044  inline bool GetShowName() const
1045  {
1046  return m_showName;
1047  }
1048 
1051  void SetDrawOutsideMargins(bool drawModeOutside)
1052  {
1053  m_drawOutsideMargins = drawModeOutside;
1054  }
1055 
1059  {
1060  return m_drawOutsideMargins;
1061  }
1062 
1067  wxBitmap GetColourSquare(int side = 16);
1068 
1071  inline bool IsVisible() const
1072  {
1073  return m_visible;
1074  }
1075 
1078  virtual void SetVisible(bool show)
1079  {
1080  m_visible = show;
1081  }
1082 
1085  inline bool IsTractable() const
1086  {
1087  return m_tractable;
1088  }
1089 
1092  virtual void SetTractable(bool track)
1093  {
1094  m_tractable = track;
1095  }
1096 
1099  void SetAlign(int align)
1100  {
1101  m_flags = align;
1102  }
1103 
1106  int GetAlign() const
1107  {
1108  return m_flags;
1109  }
1110 
1113  void SetCanDelete(bool canDelete)
1114  {
1115  m_CanDelete = canDelete;
1116  }
1117 
1120  bool GetCanDelete(void) const
1121  {
1122  return m_CanDelete;
1123  }
1124 
1127  mpLayerZOrder GetZIndex(void) const
1128  {
1129  return m_ZIndex;
1130  }
1131 
1132  protected:
1133  const mpLayerType m_type;
1136  wxFont m_font;
1137  wxColour m_fontcolour;
1138  wxPen m_pen;
1139  wxBrush m_brush;
1140  wxString m_name;
1141  bool m_showName;
1143  bool m_visible;
1145  int m_flags;
1148  mpLayerZOrder m_ZIndex;
1149 
1152  void UpdateContext(wxDC &dc) const;
1153 
1158  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1159 
1164  virtual bool DoBeforePlot()
1165  {
1166  return true;
1167  }
1168 
1175  void CheckLog(double *x, double *y, int yAxisID);
1176 
1177  private:
1178  bool m_busy;
1179  mpLayer() = delete; // default ctor not implemented/permitted
1180 
1181  wxDECLARE_DYNAMIC_CLASS(mpLayer);
1182 };
1183 
1184 //-----------------------------------------------------------------------------
1185 // mpInfoLayer
1186 //-----------------------------------------------------------------------------
1187 
1194 {
1195  public:
1197  mpInfoLayer();
1198 
1203  mpInfoLayer(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1204 
1206  virtual ~mpInfoLayer();
1207 
1210  virtual void SetVisible(bool show);
1211 
1216  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1217 
1220  virtual bool HasBBox()
1221  {
1222  return false;
1223  }
1224 
1228  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1229 
1233  virtual bool Inside(const wxPoint &point);
1234 
1237  virtual void Move(wxPoint delta);
1238 
1240  virtual void UpdateReference();
1241 
1244  wxPoint GetPosition() const
1245  {
1246  return m_dim.GetPosition();
1247  }
1248 
1251  wxSize GetSize() const
1252  {
1253  return m_dim.GetSize();
1254  }
1255 
1258  const wxRect& GetRectangle() const
1259  {
1260  return m_dim;
1261  }
1262 
1265  void SetLocation(mpLocation location)
1266  {
1267  m_location = location;
1268  }
1269 
1272  mpLocation GetLocation() const
1273  {
1274  return m_location;
1275  }
1276 
1277  protected:
1278  wxRect m_dim;
1279  wxRect m_oldDim;
1280  wxBitmap* m_info_bmp;
1281  wxPoint m_reference;
1282  int m_winX, m_winY;
1283  mpLocation m_location;
1284 
1289  virtual void DoPlot(wxDC &dc, mpWindow &w);
1290 
1293  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1294 
1295  wxDECLARE_DYNAMIC_CLASS(mpInfoLayer);
1296 };
1297 
1303 {
1304  public:
1306  mpInfoCoords();
1307 
1309  mpInfoCoords(mpLocation location);
1310 
1315  mpInfoCoords(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1316 
1319  {
1320  ;
1321  }
1322 
1326  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1327 
1328  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1329 
1333  void SetLabelMode(mpLabelType mode, unsigned int time_conv = mpX_RAWTIME)
1334  {
1335  m_labelType = mode;
1336  m_timeConv = time_conv;
1337  }
1338 
1341  void SetSeriesCoord(bool show)
1342  {
1343  m_series_coord = show;
1344  }
1345 
1348  bool IsSeriesCoord() const
1349  {
1350  return m_series_coord;
1351  }
1352 
1358  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1359 
1362  void SetPenSeries(const wxPen &pen)
1363  {
1364  m_penSeries = pen;
1365  }
1366 
1367  protected:
1368  wxString m_content;
1369  mpLabelType m_labelType;
1370  unsigned int m_timeConv;
1371  wxCoord m_mouseX;
1372  wxCoord m_mouseY;
1373  bool m_series_coord;
1374  wxPen m_penSeries;
1375 
1380  virtual void DoPlot(wxDC &dc, mpWindow &w);
1381 
1382  wxDECLARE_DYNAMIC_CLASS(mpInfoCoords);
1383 };
1384 
1390 {
1391  public:
1393  mpInfoLegend();
1394 
1400  mpInfoLegend(wxRect rect, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginNone);
1401 
1404 
1407  void SetItemMode(mpLegendStyle mode)
1408  {
1409  m_item_mode = mode;
1410  m_needs_update = true;
1411  }
1412 
1413  mpLegendStyle GetItemMode() const
1414  {
1415  return m_item_mode;
1416  }
1417 
1420  void SetItemDirection(mpLegendDirection mode)
1421  {
1422  m_item_direction = mode;
1423  m_needs_update = true;
1424  }
1425 
1426  mpLegendDirection GetItemDirection() const
1427  {
1428  return m_item_direction;
1429  }
1430 
1431  void SetNeedUpdate()
1432  {
1433  m_needs_update = true;
1434  }
1435 
1437  int GetPointed(mpWindow &w, wxPoint eventPoint);
1438 
1439  protected:
1440  mpLegendStyle m_item_mode;
1441  mpLegendDirection m_item_direction;
1442 
1447  virtual void DoPlot(wxDC &dc, mpWindow &w);
1448 
1449  private:
1451  struct LegendDetail
1452  {
1453  unsigned int layerIdx;
1454  wxCoord legendEnd;
1455  };
1457  std::vector<LegendDetail> m_LegendDetailList;
1458  bool m_needs_update;
1459 
1469  void UpdateBitmap(wxDC &dc, mpWindow &w);
1470 
1471  wxDECLARE_DYNAMIC_CLASS(mpInfoLegend);
1472 };
1473 
1474 //-----------------------------------------------------------------------------
1475 // mpLayer implementations - functions
1476 //-----------------------------------------------------------------------------
1477 
1486 {
1487  public:
1493  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1494 
1498  void SetContinuity(bool continuity)
1499  {
1500  m_continuous = continuity;
1501  }
1502 
1506  bool GetContinuity() const
1507  {
1508  return m_continuous;
1509  }
1510 
1513  void SetStep(unsigned int step)
1514  {
1515  m_step = step;
1516  }
1517 
1520  unsigned int GetStep() const
1521  {
1522  return m_step;
1523  }
1524 
1527  void SetSymbol(mpSymbol symbol)
1528  {
1529  m_symbol = symbol;
1530  }
1531 
1534  mpSymbol GetSymbol() const
1535  {
1536  return m_symbol;
1537  }
1538 
1541  void SetSymbolSize(int size)
1542  {
1543  m_symbolSize = size;
1544  m_symbolSize2 = size / 2;
1545  }
1546 
1549  int GetSymbolSize() const
1550  {
1551  return m_symbolSize;
1552  }
1553 
1557  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1558 
1562  int GetYAxisID() const
1563  {
1564  return m_yAxisID;
1565  }
1566 
1570  void SetYAxisID(unsigned int yAxisID)
1571  {
1572  m_yAxisID = yAxisID;
1573  }
1574 
1578  void SetLegendVisibility(bool visibility)
1579  {
1580  m_LegendVisibility = visibility;
1581  }
1582 
1586  bool GetLegendVisibility() const
1587  {
1588  return m_LegendVisibility;
1589  }
1590 
1591  protected:
1593  mpSymbol m_symbol;
1596  unsigned int m_step;
1599 
1600  wxDECLARE_DYNAMIC_CLASS(mpFunction);
1601 };
1602 
1606 {
1607  public:
1614  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1615 
1616  // We don't want to include line (horizontal or vertical) in BBox computation
1617  virtual bool HasBBox() override
1618  {
1619  return false;
1620  }
1621 
1625  double GetValue() const
1626  {
1627  return m_value;
1628  }
1629 
1633  void SetValue(const double value)
1634  {
1635  m_value = value;
1636  }
1637 
1641  bool IsHorizontal(void) const
1642  {
1643  return m_IsHorizontal;
1644  }
1645 
1646  protected:
1647  double m_value;
1649 
1650  wxDECLARE_DYNAMIC_CLASS(mpLine);
1651 };
1652 
1656 {
1657  public:
1664  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1665 
1669  void SetYValue(const double yvalue)
1670  {
1671  SetValue(yvalue);
1672  }
1673 
1674  protected:
1675 
1676  virtual void DoPlot(wxDC &dc, mpWindow &w);
1677 
1678  wxDECLARE_DYNAMIC_CLASS(mpHorizontalLine);
1679 };
1680 
1684 {
1685  public:
1691  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1692 
1696  void SetXValue(const double xvalue)
1697  {
1698  SetValue(xvalue);
1699  }
1700 
1701  protected:
1702 
1703  virtual void DoPlot(wxDC &dc, mpWindow &w);
1704 
1709  virtual bool DoBeforePlot()
1710  {
1711  return true;
1712  }
1713 
1714  wxDECLARE_DYNAMIC_CLASS(mpVerticalLine);
1715 };
1716 
1724 {
1725  public:
1730  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
1731 
1737  virtual double GetY(double x) = 0;
1738 
1745  double DoGetY(double x);
1746 
1751  void DefineDoGetY(void);
1752 
1753  protected:
1754 
1755  // Pointer function to the appropriate DoGetY function
1756  double (mpFX::*pDoGetY)(double x);
1757 
1762  virtual void DoPlot(wxDC &dc, mpWindow &w);
1763 
1768  double NormalDoGetY(double x);
1769 
1774  double LogDoGetY(double x);
1775 
1776  wxDECLARE_DYNAMIC_CLASS(mpFX);
1777 };
1778 
1786 {
1787  public:
1792  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
1793 
1799  virtual double GetX(double y) = 0;
1800 
1807  double DoGetX(double y);
1808 
1813  void DefineDoGetX(void);
1814 
1815  protected:
1816 
1817  // Pointer function to the appropriate DoGetX function
1818  double (mpFY::*pDoGetX)(double y);
1819 
1824  virtual void DoPlot(wxDC &dc, mpWindow &w);
1825 
1830  double NormalDoGetX(double y);
1831 
1836  double LogDoGetX(double y);
1837 
1838  wxDECLARE_DYNAMIC_CLASS(mpFY);
1839 };
1840 
1851 {
1852  public:
1858  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
1859 
1863  virtual void Rewind() = 0;
1864 
1868  virtual void Clear()
1869  {
1870  ;
1871  }
1872 
1876  virtual int GetSize()
1877  {
1878  return 0;
1879  }
1880 
1887  virtual bool GetNextXY(double *x, double *y) = 0;
1888 
1895  bool DoGetNextXY(double *x, double *y);
1896 
1901  void SetViewMode(bool asBar);
1902 
1907  int GetBarWidth(void) const
1908  {
1909  return m_BarWidth;
1910  }
1911 
1916  bool ViewAsBar(void) const
1917  {
1918  return m_ViewAsBar;
1919  }
1920 
1921  protected:
1922 
1923  // Data to calculate label positioning
1926 
1927  // Min delta between 2 x coordinate (used for view as bar)
1928  double m_deltaX;
1929  double m_deltaY;
1930 
1931  // The width of a bar
1932  int m_BarWidth;
1933 
1934  // Plot data as bar graph
1935  bool m_ViewAsBar = false;
1936 
1943  virtual void DoPlot(wxDC &dc, mpWindow &w);
1944 
1949  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
1950 
1951  wxDECLARE_DYNAMIC_CLASS(mpFXY);
1952 };
1953 
1954 //-----------------------------------------------------------------------------
1955 // mpFXYVector - provided by Jose Luis Blanco
1956 //-----------------------------------------------------------------------------
1957 
1978 {
1979  public:
1985  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
1986 
1989  virtual ~mpFXYVector()
1990  {
1991  Clear();
1992  }
1993 
1998  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
1999 
2003  void Clear();
2004 
2009  virtual int GetSize()
2010  {
2011  return m_xs.size();
2012  }
2013 
2021  bool AddData(const double x, const double y, bool updatePlot);
2022 
2029  void SetReserve(int reserve)
2030  {
2031  m_reserveXY = reserve;
2032  m_xs.reserve(m_reserveXY);
2033  m_ys.reserve(m_reserveXY);
2034  }
2035 
2039  int GetReserve() const
2040  {
2041  return m_reserveXY;
2042  }
2043 
2044  protected:
2047  std::vector<double> m_xs;
2048  std::vector<double> m_ys;
2049 
2053 
2056  size_t m_index;
2057 
2059  double m_lastX;
2061  double m_lastY;
2062 
2066  inline void Rewind()
2067  {
2068  m_index = 0;
2069  }
2070 
2077  virtual bool GetNextXY(double *x, double *y);
2078 
2083  void DrawAddedPoint(double x, double y);
2084 
2087  virtual double GetMinX()
2088  {
2089  if (m_ViewAsBar)
2090  {
2091  // Make extra space for outer bars
2092  return m_rangeX.min - (m_deltaX / 2);
2093  }
2094  else
2095  {
2096  return m_rangeX.min;
2097  }
2098  }
2099 
2102  virtual double GetMinY()
2103  {
2104  return m_rangeY.min;
2105  }
2106 
2109  virtual double GetMaxX()
2110  {
2111  if(m_ViewAsBar)
2112  {
2113  // Make extra space for outer bars
2114  return m_rangeX.max + (m_deltaX / 2);
2115  }
2116  else
2117  {
2118  return m_rangeX.max;
2119  }
2120  }
2121 
2124  virtual double GetMaxY()
2125  {
2126  return m_rangeY.max;
2127  }
2128 
2129  private:
2132  void First_Point(double x, double y);
2133 
2136  void Check_Limit(double val, mpRange<double> *range, double *last, double *delta);
2137 
2138  wxDECLARE_DYNAMIC_CLASS(mpFXYVector);
2139 };
2140 
2150 {
2151  public:
2155  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
2156 
2162  virtual double GetY(double x) = 0;
2163 
2164  protected:
2165 
2170  virtual void DoPlot(wxDC &dc, mpWindow &w);
2171 
2172  wxDECLARE_DYNAMIC_CLASS(mpProfile);
2173 };
2174 
2179 class mpFXGeneric: public mpFX
2180 {
2181  public:
2186  mpFXGeneric(const wxString &name = wxT("Generic FX function"), int flags = mpALIGN_LEFT, unsigned int yAxisID = 0) :
2187  mpFX(name, flags, yAxisID)
2188  {
2189  wxPen FXpen(*wxBLUE, 1, wxPENSTYLE_SOLID);
2190  SetDrawOutsideMargins(false);
2191  SetContinuity(true);
2192  SetPen(FXpen);
2193  SetStep(8); // Draw one point over eight
2194  }
2195 
2200  virtual double GetY(double x)
2201  {
2202  double y;
2203  try
2204  {
2205  y = ComputeY(x);
2206  }
2207  catch (...)
2208  {
2209  y = 0;
2210  }
2211  m_rangeY.Update(y);
2212  return y;
2213  }
2214 
2219  virtual double GetMinY()
2220  {
2221  return m_rangeY.min;
2222  }
2223 
2228  virtual double GetMaxY()
2229  {
2230  return m_rangeY.max;
2231  }
2232 
2233  protected:
2235 
2241  virtual double ComputeY(double x) = 0;
2242 };
2243 
2249 {
2250  public:
2256  mpGaussian(double mu, double sigma) :
2257  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2258  {
2259  m_mu = mu;
2260  m_sigma = sigma;
2261  m_variance = sigma * sigma;
2262  m_const = 1.0 / sqrt(2.0 * M_PI * m_variance);
2263  }
2264 
2265  protected:
2266  double m_mu;
2267  double m_sigma;
2268  double m_variance;
2269  double m_const;
2270 
2271  virtual double ComputeY(double x)
2272  {
2273  return m_const * exp(-(x - m_mu) * (x - m_mu) / (2.0 * m_variance));
2274  }
2275 };
2276 
2281 class mpNormal: public mpFXGeneric
2282 {
2283  public:
2289  mpNormal(double mu, double sigma) :
2290  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2291  {
2292  m_mu = mu;
2293  m_sigma = sigma;
2294  m_variance = sigma * sigma;
2295  m_const = 1.0 / (m_variance * sqrt(2.0 * M_PI));
2296  }
2297 
2298  protected:
2299  double m_mu;
2300  double m_sigma;
2301  double m_variance;
2302  double m_const;
2303 
2304  virtual double ComputeY(double x)
2305  {
2306  if (x < 0)
2307  return 0.0;
2308  else
2309  {
2310  double tmp = log(x) - m_mu;
2311  return m_const * exp(-tmp * tmp / (2.0 * m_variance)) / x;
2312  }
2313  }
2314 };
2315 
2316 //-----------------------------------------------------------------------------
2317 // mpChart
2318 //-----------------------------------------------------------------------------
2322 {
2323  public:
2325  mpChart(const wxString &name = wxEmptyString);
2326 
2329  {
2330  Clear();
2331  }
2332 
2335  void SetChartValues(const std::vector<double> &data);
2336 
2339  void SetChartLabels(const std::vector<std::string> &labelArray);
2340 
2345  void AddData(const double &data, const std::string &label);
2346 
2350  virtual void Clear();
2351 
2352  virtual bool HasBBox()
2353  {
2354  return (values.size() > 0);
2355  }
2356 
2357  protected:
2358  std::vector<double> values;
2359  std::vector<std::string> labels;
2360 
2361  double m_max_value;
2362  double m_total_value;
2363 
2364  wxDECLARE_DYNAMIC_CLASS(mpChart);
2365 };
2366 
2367 //-----------------------------------------------------------------------------
2368 // mpBarChart - provided by Jose Davide Rondini
2369 //-----------------------------------------------------------------------------
2370 /* Defines for bar charts label positioning. */
2371 #define mpBAR_NONE 0
2372 #define mpBAR_AXIS_H 1
2373 #define mpBAR_AXIS_V 2
2374 #define mpBAR_INSIDE 3
2375 #define mpBAR_TOP 4
2376 
2377 
2380 {
2381  public:
2383  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2384 
2387  {
2388  Clear();
2389  }
2390 
2391  void SetBarColour(const wxColour &colour);
2392 
2393  void SetColumnWidth(const double colWidth)
2394  {
2395  m_width = colWidth;
2396  }
2397 
2399  void SetBarLabelPosition(int position);
2400 
2404  virtual double GetMinX();
2405 
2409  virtual double GetMaxX();
2410 
2414  virtual double GetMinY();
2415 
2419  virtual double GetMaxY();
2420 
2421  protected:
2422 
2423  double m_width;
2424  wxColour m_barColour;
2425  int m_labelPos;
2426  double m_labelAngle;
2427 
2432  virtual void DoPlot(wxDC &dc, mpWindow &w);
2433 
2434  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2435 };
2436 
2441 {
2442  public:
2446  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2447 
2450  {
2451  Clear();
2452  colours.clear();
2453  }
2454 
2458  void SetCenter(const wxPoint center)
2459  {
2460  m_center = center;
2461  }
2462 
2466  wxPoint GetCenter(void) const
2467  {
2468  return m_center;
2469  }
2470 
2474  void SetPieColours(const std::vector<wxColour> &colourArray);
2475 
2479  virtual double GetMinX()
2480  {
2481  return m_center.x - m_radius;
2482  }
2483 
2487  virtual double GetMaxX()
2488  {
2489  return m_center.x + m_radius;
2490  }
2491 
2495  virtual double GetMinY()
2496  {
2497  return m_center.y - m_radius;
2498  }
2499 
2503  virtual double GetMaxY()
2504  {
2505  return m_center.y + m_radius;
2506  }
2507 
2508  protected:
2509 
2510  double m_radius;
2511  wxPoint m_center;
2512  std::vector<wxColour> colours;
2513 
2518  virtual void DoPlot(wxDC &dc, mpWindow &w);
2519 
2520  const wxColour& GetColour(unsigned int id);
2521 
2522  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2523 };
2524 
2527 //-----------------------------------------------------------------------------
2528 // mpLayer implementations - furniture (scales, ...)
2529 //-----------------------------------------------------------------------------
2537 {
2538  public:
2546  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, mpOptional_uint axisID = MP_OPTNULL_INT);
2547 
2551  virtual bool HasBBox()
2552  {
2553  return false;
2554  }
2555 
2559  int GetAxisID(void)
2560  {
2561  return m_axisID;
2562  }
2563 
2568  void SetAxisID(unsigned int yAxisID)
2569  {
2570  m_axisID = yAxisID;
2571  }
2572 
2575  void ShowTicks(bool ticks)
2576  {
2577  m_ticks = ticks;
2578  }
2579 
2582  bool GetShowTicks() const
2583  {
2584  return m_ticks;
2585  }
2586 
2589  void ShowGrids(bool grids)
2590  {
2591  m_grids = grids;
2592  }
2593 
2596  bool GetShowGrids() const
2597  {
2598  return m_grids;
2599  }
2600 
2605  void SetLabelFormat(const wxString &format, bool updateLabelMode = false)
2606  {
2607  m_labelFormat = format;
2608  if (updateLabelMode)
2609  m_labelType = mpLabel_USER;
2610  }
2611 
2615  {
2616  return m_labelType;
2617  }
2618 
2622  void SetLabelMode(mpLabelType mode, unsigned int time_conv = mpX_RAWTIME)
2623  {
2624  m_labelType = mode;
2625  m_timeConv = time_conv;
2626  }
2627 
2630  const wxString& GetLabelFormat() const
2631  {
2632  return m_labelFormat;
2633  }
2634 
2638  void SetGridPen(const wxPen &pen)
2639  {
2640  m_gridpen = pen;
2641  }
2642 
2646  const wxPen& GetGridPen() const
2647  {
2648  return m_gridpen;
2649  }
2650 
2654  void SetAuto(bool automaticScalingIsEnabled)
2655  {
2656  m_auto = automaticScalingIsEnabled;
2657  }
2658 
2662  bool GetAuto() const
2663  {
2664  return m_auto;
2665  }
2666 
2670  void SetMinScale(double min)
2671  {
2672  m_axisRange.SetMin(min);
2673  }
2674 
2678  double GetMinScale() const
2679  {
2680  return m_axisRange.min;
2681  }
2682 
2686  void SetMaxScale(double max)
2687  {
2688  m_axisRange.SetMax(max);
2689  }
2690 
2694  double GetMaxScale() const
2695  {
2696  return m_axisRange.max;
2697  }
2698 
2703  void SetScale(double min, double max)
2704  {
2705  m_axisRange.Set(min, max);
2706  }
2707 
2712  void GetScale(double *min, double *max) const
2713  {
2714  *min = m_axisRange.min;
2715  *max = m_axisRange.max;
2716  }
2717 
2722  {
2723  m_axisRange = range;
2724  }
2725 
2730  {
2731  return mpRange<double>(m_axisRange);
2732  }
2733 
2737  virtual bool IsLogAxis()
2738  {
2739  return m_isLog;
2740  }
2741 
2745  virtual void SetLogAxis(bool log)
2746  {
2747  m_isLog = log;
2748  }
2749 
2750  protected:
2751  static const wxCoord kTickSize = 4;
2752  static const wxCoord kAxisExtraSpace = 6;
2753 
2754  int m_axisID;
2755  wxPen m_gridpen;
2756  bool m_ticks;
2757  bool m_grids;
2758  bool m_auto;
2761  unsigned int m_timeConv;
2762  wxString m_labelFormat;
2763  bool m_isLog;
2764 
2767  virtual int GetOrigin(mpWindow &w) = 0;
2768 
2775  double GetStep(double scale, int minLabelSpacing);
2776 
2784  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
2785 
2792  wxString FormatLabelValue(double value, double maxAxisValue, double step);
2793 
2798  wxString FormatLogValue(double n);
2799 
2807  int GetLabelWidth(double value, wxDC &dc, double maxAxisValue, double step);
2808 
2813  bool UseScientific(double maxAxisValue);
2814 
2820  int GetSignificantDigits(double step, double maxAxisValue);
2821 
2826  int GetDecimalDigits(double step);
2827 
2828  wxDECLARE_DYNAMIC_CLASS(mpScale);
2829 };
2830 
2831 
2838 {
2839  public:
2845  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, mpLabelType type = mpLabel_AUTO) :
2846  mpScale(name, flags, grids, type)
2847  {
2848  m_subtype = mpsScaleX;
2849  }
2850 
2851  bool IsTopAxis()
2852  {
2853  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
2854  }
2855 
2856  bool IsBottomAxis()
2857  {
2858  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
2859  }
2860 
2861  protected:
2862 
2865  virtual void DoPlot(wxDC &dc, mpWindow &w);
2866 
2867  virtual int GetOrigin(mpWindow &w);
2868  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2869 
2870  wxDECLARE_DYNAMIC_CLASS(mpScaleX);
2871 };
2872 
2880 {
2881  public:
2889  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, mpOptional_uint yAxisID = MP_OPTNULL_INT, mpLabelType labelType = mpLabel_AUTO) :
2890  mpScale(name, flags, grids, labelType, yAxisID)
2891  {
2892  m_subtype = mpsScaleY;
2893  m_axisWidth = Y_BORDER_SEPARATION;
2894  m_xPos = 0;
2895  }
2896 
2899  void UpdateAxisWidth(mpWindow &w);
2900 
2901  int GetAxisWidth()
2902  {
2903  return m_axisWidth;
2904  }
2905 
2906  bool IsLeftAxis()
2907  {
2908  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
2909  }
2910 
2911  bool IsRightAxis()
2912  {
2913  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
2914  }
2915 
2916  bool IsInside(wxCoord xPixel)
2917  {
2918  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
2919  {
2920  return true;
2921  }
2922  return false;
2923  }
2924 
2925  protected:
2926  int m_axisWidth;
2927  int m_xPos;
2928 
2931  virtual void DoPlot(wxDC &dc, mpWindow &w);
2932 
2933  virtual int GetOrigin(mpWindow &w);
2934  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2935 
2936  wxDECLARE_DYNAMIC_CLASS(mpScaleY);
2937 };
2938 
2939 //-----------------------------------------------------------------------------
2940 // mpWindow
2941 //-----------------------------------------------------------------------------
2942 
2947 #define mpMOUSEMODE_DRAG 0
2948 
2949 #define mpMOUSEMODE_ZOOMBOX 1
2950 
2953 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
2954 typedef std::deque<mpLayer*> mpLayerList;
2955 
2966 {
2967  mpScale* axis = nullptr;
2968  double scale = 1.0;
2969  double pos = 0;
2973 
2974  // Note: we don't use the default operator since we don't want to compare axis pointers
2975  bool operator==(const mpAxisData& other) const
2976  {
2977  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
2978  (bound == other.bound) && (desired == other.desired);
2979  }
2980 };
2981 
2983 typedef std::unordered_map<int, mpAxisData> mpAxisList;
2984 
2991 typedef enum {
2992  uXAxis = 1,
2993  uYAxis = 2,
2994  uXYAxis = 3
2995 } mpAxisUpdate;
2996 
3006 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
3007 
3014 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
3015 
3021 {
3022  public:
3023  mpMagnet()
3024  {
3025  m_IsDrawn = false;
3026  m_rightClick = false;
3027  m_IsWasDrawn = false;
3028  }
3029  ~mpMagnet()
3030  {
3031  ;
3032  }
3033  void UpdateBox(wxCoord left, wxCoord top, wxCoord width, wxCoord height)
3034  {
3035  m_domain = wxRect(left, top, width, height);
3036  m_plot_size = wxRect(left, top, width + left, height + top);
3037  }
3038  void UpdateBox(const wxRect &size)
3039  {
3040  m_domain = size;
3041  m_plot_size = wxRect(size.GetLeft(), size.GetTop(),
3042  size.GetWidth() + size.GetLeft(), size.GetHeight() + size.GetTop());
3043  }
3044  void Plot(wxClientDC &dc, const wxPoint &mousePos);
3045  void ClearPlot(wxClientDC &dc);
3046  void UpdatePlot(wxClientDC &dc, const wxPoint &mousePos);
3047  void SaveDrawState(void)
3048  {
3049  m_IsWasDrawn = m_IsDrawn;
3050  // In any cases, set to false because we erase and repaint all the plot
3051  m_IsDrawn = false;
3052  }
3053 
3054  void SetRightClick(void)
3055  {
3056  m_rightClick = true;
3057  }
3058 
3059  private:
3060  wxRect m_domain;
3061  wxRect m_plot_size;
3062  wxPoint m_mousePosition;
3063  bool m_IsDrawn;
3064  bool m_IsWasDrawn;
3065  bool m_rightClick;
3066  void DrawCross(wxClientDC &dc) const;
3067 };
3068 
3090 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
3091 {
3092  public:
3093  mpWindow()
3094  {
3095  InitParameters();
3096  }
3097 
3098  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
3099  long flags = 0);
3100 
3101  ~mpWindow();
3102 
3106  wxMenu* GetPopupMenu()
3107  {
3108  return &m_popmenu;
3109  }
3110 
3119  bool AddLayer(mpLayer *layer, bool refreshDisplay = true, bool refreshConfig = true);
3120 
3133  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
3134 
3140  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
3141 
3148  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
3149 
3156  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
3157 
3163  mpLayer* GetLayer(int position);
3164 
3169  int GetLayerPosition(mpLayer* layer);
3170 
3177  mpLayer* GetLayersType(int position, mpLayerType type);
3178 
3185  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
3186 
3192  mpScale* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
3193 
3202  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
3203 
3212  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
3213 
3218  mpLayer* GetLayerByName(const wxString &name);
3219 
3224  mpLayer* GetLayerByClassName(const wxString &name);
3225 
3229  void RefreshLegend(void);
3230 
3235  bool IsYAxisUsed(int yAxisID);
3236 
3240  mpScaleX* GetLayerXAxis();
3241 
3245  mpScaleY* GetLayerYAxis(int yAxisID);
3246 
3250  void SetScaleX(const double scaleX)
3251  {
3252  if (ISNOTNULL(scaleX))
3253  {
3254  m_AxisDataX.scale = scaleX;
3255  UpdateDesiredBoundingBox(uXAxis);
3256  }
3257  UpdateAll();
3258  }
3259 
3264  double GetScaleX(void) const
3265  {
3266  return m_AxisDataX.scale;
3267  }
3268 
3273  void SetScaleY(const double scaleY, int yAxisID)
3274  {
3275  assert(m_AxisDataYList.count(yAxisID) != 0);
3276  if (ISNOTNULL(scaleY))
3277  {
3278  m_AxisDataYList[yAxisID].scale = scaleY;
3279  UpdateDesiredBoundingBox(uYAxis);
3280  }
3281  UpdateAll();
3282  }
3283 
3289  double GetScaleY(int yAxisID)
3290  {
3291  assert(m_AxisDataYList.count(yAxisID) != 0);
3292  return m_AxisDataYList[yAxisID].scale;
3293  } // Schaling's method: maybe another method exists with the same name
3294 
3295  [[deprecated("Incomplete, use UpdateBBox instead")]]
3298  void SetBound();
3299 
3302  {
3303  return m_AxisDataX.bound;
3304  }
3305 
3308  {
3309  return m_AxisDataX.desired;
3310  }
3311 
3316  {
3317  assert(m_AxisDataYList.count(yAxisID) != 0);
3318  return m_AxisDataYList[yAxisID].bound;
3319  }
3320 
3325  {
3326  assert(m_AxisDataYList.count(yAxisID) != 0);
3327  return m_AxisDataYList[yAxisID].desired;
3328  }
3329 
3334  std::unordered_map<int, mpRange<double>> GetAllBoundY()
3335  {
3336  std::unordered_map<int, mpRange<double>> yRange;
3337  for (const MP_LOOP_ITER : m_AxisDataYList)
3338  {
3339  yRange[m_yID] = m_yData.bound;
3340  }
3341  return yRange;
3342  }
3343 
3348  std::unordered_map<int, mpRange<double>> GetAllDesiredY()
3349  {
3350  std::unordered_map<int, mpRange<double>> yRange;
3351  for (const MP_LOOP_ITER : m_AxisDataYList)
3352  {
3353  yRange[m_yID] = m_yData.desired;
3354  }
3355  return yRange;
3356  }
3357 
3361  void SetPosX(const double posX)
3362  {
3363  m_AxisDataX.pos = posX;
3364  UpdateDesiredBoundingBox(uXAxis);
3365  UpdateAll();
3366  }
3367 
3372  double GetPosX(void) const
3373  {
3374  return m_AxisDataX.pos;
3375  }
3376 
3381  void SetPosY(std::unordered_map<int, double>& posYList)
3382  {
3383  for (MP_LOOP_ITER : m_AxisDataYList)
3384  {
3385  m_yData.pos = posYList[m_yID];
3386  }
3387  UpdateDesiredBoundingBox(uYAxis);
3388  UpdateAll();
3389  }
3390 
3396  double GetPosY(int yAxisID)
3397  {
3398  assert(m_AxisDataYList.count(yAxisID) != 0);
3399  return m_AxisDataYList[yAxisID].pos;
3400  }
3401 
3405  int GetNOfYAxis(void) const
3406  {
3407  return (int)m_AxisDataYList.size();
3408  }
3409 
3413  mpAxisList GetAxisDataYList(void) const
3414  {
3415  return m_AxisDataYList;
3416  }
3417 
3421  std::map<int, mpAxisData> GetSortedAxisDataYList(void) const
3422  {
3423  return std::map<int, mpAxisData>(m_AxisDataYList.begin(), m_AxisDataYList.end());
3424  }
3425 
3431  void SetScreen(const int scrX, const int scrY)
3432  {
3433  m_scrX = scrX;
3434  m_scrY = scrY;
3435  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3436  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3437 
3438  m_plotBoundaries.endPx = m_scrX;
3439  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3440  m_plotBoundaries.endPy = m_scrY;
3441  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3442 
3443  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3444  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3445 
3446  m_magnet.UpdateBox(m_PlotArea);
3447  }
3448 
3455  int GetScreenX(void) const
3456  {
3457  return m_scrX;
3458  }
3459 
3466  int GetScreenY(void) const
3467  {
3468  return m_scrY;
3469  }
3470 
3476  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3477  {
3478  m_AxisDataX.pos = posX;
3479  SetPosY(posYList);
3480  }
3481 
3485  inline double p2x(const wxCoord pixelCoordX) const
3486  {
3487  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3488  }
3489 
3493  inline double p2y(const wxCoord pixelCoordY, int yAxisID = 0)
3494  {
3495  assert(m_AxisDataYList.count(yAxisID) != 0);
3496  if (m_AxisDataYList.count(yAxisID) == 0)
3497  return 0.0;
3498  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3499  }
3500 
3504  inline wxCoord x2p(const double x) const
3505  {
3506  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3507  }
3508 
3512  inline wxCoord y2p(const double y, int yAxisID = 0)
3513  {
3514  assert(m_AxisDataYList.count(yAxisID) != 0);
3515  if (m_AxisDataYList.count(yAxisID) == 0)
3516  return 0;
3517  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3518  }
3519 
3522  void EnableDoubleBuffer(const bool enabled)
3523  {
3524  m_enableDoubleBuffer = enabled;
3525  }
3526 
3529  void EnableMousePanZoom(const bool enabled)
3530  {
3531  m_enableMouseNavigation = enabled;
3532  }
3533 
3539  void LockAspect(bool enable = true);
3540 
3545  inline bool IsAspectLocked() const
3546  {
3547  return m_lockaspect;
3548  }
3549 
3554  inline bool IsRepainting() const
3555  {
3556  return m_repainting;
3557  }
3558 
3563  void Fit();
3564 
3571  void Fit(const mpRange<double> &rangeX, std::unordered_map<int, mpRange<double>> rangeY, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3572 
3576  void FitX(void);
3577 
3582  void FitY(int yAxisID);
3583 
3588  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
3589 
3594  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
3595 
3597  void ZoomInX();
3598 
3600  void ZoomOutX();
3601 
3604  void ZoomInY(mpOptional_int yAxisID = MP_OPTNULL_INT);
3605 
3608  void ZoomOutY(mpOptional_int yAxisID = MP_OPTNULL_INT);
3609 
3614  void ZoomRect(wxPoint p0, wxPoint p1);
3615 
3617  void UpdateAll();
3618 
3619  // Added methods by Davide Rondini
3620 
3624  unsigned int CountLayers();
3625 
3628  unsigned int CountAllLayers()
3629  {
3630  return (unsigned int)m_layers.size();
3631  }
3632 
3636  unsigned int CountLayersType(mpLayerType type);
3637 
3641  unsigned int CountLayersFXYPlot();
3642 
3651  {
3652  // Change on X axis
3653  if (update & uXAxis)
3654  {
3655  m_AxisDataX.desired.Set(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale),
3656  m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3657  }
3658 
3659  // Change on Y axis
3660  if (update & uYAxis)
3661  {
3662  for (MP_LOOP_ITER : m_AxisDataYList)
3663  {
3664  m_yData.desired.Set(m_yData.pos - ((m_margin.top + m_plotHeight) / m_yData.scale),
3665  m_yData.pos - (m_margin.top / m_yData.scale));
3666  }
3667  }
3668  }
3669 
3675  mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID = 0)
3676  {
3677  assert(m_AxisDataYList.count(yAxisID) != 0);
3678  if (desired)
3679  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
3680  else
3681  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
3682  }
3683 
3687  double GetDesiredXmin() const
3688  {
3689  return m_AxisDataX.desired.min;
3690  }
3691 
3696  double GetDesiredXmax() const
3697  {
3698  return m_AxisDataX.desired.max;
3699  }
3700 
3706  double GetDesiredYmin(int yAxisID)
3707  {
3708  assert(m_AxisDataYList.count(yAxisID) != 0);
3709  return m_AxisDataYList[yAxisID].desired.min;
3710  }
3711 
3717  double GetDesiredYmax(int yAxisID)
3718  {
3719  assert(m_AxisDataYList.count(yAxisID) != 0);
3720  return m_AxisDataYList[yAxisID].desired.max;
3721  }
3722 
3724  bool GetBoundingBox(mpRange<double> *boundX, mpRange<double> *boundY, int yAxisID)
3725  {
3726  if (m_AxisDataYList.count(yAxisID) == 0)
3727  return false;
3728  *boundX = m_AxisDataX.bound;
3729  *boundY = m_AxisDataYList[yAxisID].bound;
3730  return true;
3731  }
3732 
3733  // Is this point inside the bounding box
3734  bool PointIsInsideBound(double px, double py, int yAxisID)
3735  {
3736  if (m_AxisDataYList.count(yAxisID) == 0)
3737  return false;
3738 
3739  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
3740  }
3741 
3742  /* Update bounding box (X and Y axis) to include this point.
3743  * Expand the range to include the point.
3744  * @param px: point on x-axis
3745  * @param py: point on y-axis
3746  * @param yAxisID: the y-axis ID
3747  */
3748  void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
3749  {
3750  if (m_AxisDataYList.count(yAxisID) == 0)
3751  return ;
3752 
3753  m_AxisDataX.bound.Update(px);
3754  m_AxisDataYList[yAxisID].bound.Update(py);
3755  }
3756 
3757  /* Initialize bounding box with an initial point
3758  * @param px: point on x-axis
3759  * @param py: point on y-axis
3760  * @param yAxisID: the y-axis ID
3761  */
3762  void InitializeBoundingBox(double px, double py, int yAxisID)
3763  {
3764  if (m_AxisDataYList.count(yAxisID) == 0)
3765  return ;
3766 
3767  m_AxisDataX.bound.Set(px, px);
3768  m_AxisDataYList[yAxisID].bound.Set(py, py);
3769  }
3770 
3773  void SetMPScrollbars(bool status);
3774 
3777  bool GetMPScrollbars() const
3778  {
3779  return m_enableScrollBars;
3780  }
3781 
3787  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
3788 
3792  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3793 
3797  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3798 
3802  void SetWildcard(const wxString &wildcard)
3803  {
3804  m_wildcard = wildcard;
3805  }
3806 
3810  const wxString& GetWildcard(void) const
3811  {
3812  return m_wildcard;
3813  }
3814 
3822  bool LoadFile(const wxString &filename = wxEmptyString);
3823 
3828  void SetDefaultDir(const wxString &dirname)
3829  {
3830  m_DefaultDir = dirname;
3831  }
3832 
3836 
3843  void SetMargins(int top, int right, int bottom, int left);
3844 
3847  {
3848  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3849  }
3850 
3852  void SetMarginTop(int top)
3853  {
3854  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3855  }
3856 
3860  int GetMarginTop(bool minusExtra = false) const
3861  {
3862  if (minusExtra)
3863  return m_margin.top - m_extraMargin;
3864  else
3865  return m_margin.top;
3866  }
3867 
3869  void SetMarginRight(int right)
3870  {
3871  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
3872  }
3873 
3877  int GetMarginRight(bool minusExtra = false) const
3878  {
3879  if (minusExtra)
3880  return m_margin.right - m_extraMargin;
3881  else
3882  return m_margin.right;
3883  }
3884 
3887  {
3888  return m_marginOuter.right;
3889  }
3890 
3892  void SetMarginBottom(int bottom)
3893  {
3894  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
3895  }
3896 
3900  int GetMarginBottom(bool minusExtra = false) const
3901  {
3902  if (minusExtra)
3903  return m_margin.bottom - m_extraMargin;
3904  else
3905  return m_margin.bottom;
3906  }
3907 
3909  void SetMarginLeft(int left)
3910  {
3911  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
3912  }
3913 
3917  int GetMarginLeft(bool minusExtra = false) const
3918  {
3919  if (minusExtra)
3920  return m_margin.left - m_extraMargin;
3921  else
3922  return m_margin.left;
3923  }
3924 
3926  void SetExtraMargin(int extra)
3927  {
3928  m_extraMargin = extra;
3929  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3930  }
3931 
3933  int GetExtraMargin() const
3934  {
3935  return m_extraMargin;
3936  }
3937 
3940  {
3941  return m_marginOuter.left;
3942  }
3943 
3945  int GetPlotWidth() const
3946  {
3947  return m_plotWidth;
3948  }
3949 
3951  int GetPlotHeight() const
3952  {
3953  return m_plotHeight;
3954  }
3955 
3960  mpRect GetPlotBoundaries(bool with_margin) const
3961  {
3962  mpRect bond;
3963  if (with_margin)
3964  bond = m_plotBoundariesMargin;
3965  else
3966  bond = m_plotBoundaries;
3967  bond.startPx -= m_extraMargin;
3968  bond.endPx += m_extraMargin;
3969  bond.startPy -= m_extraMargin;
3970  bond.endPy += m_extraMargin;
3971  return bond;
3972  }
3973 
3977  int GetLeftYAxesWidth(mpOptional_int yAxisID = MP_OPTNULL_INT);
3978 
3982  int GetRightYAxesWidth(mpOptional_int yAxisID = MP_OPTNULL_INT);
3983 
3985  void SetDrawBox(bool drawbox)
3986  {
3987  m_drawBox = drawbox;
3988  }
3989 
3991  bool GetDrawBox() const
3992  {
3993  return m_drawBox;
3994  }
3995 
3999  mpOptional_int IsInsideYAxis(const wxPoint &point);
4000 
4004  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
4005 
4009  void SetLayerVisible(const wxString &name, bool viewable);
4010 
4014  bool IsLayerVisible(const wxString &name);
4015 
4019  bool IsLayerVisible(const unsigned int position);
4020 
4024  void SetLayerVisible(const unsigned int position, bool viewable);
4025 
4030  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
4031 
4034  const wxColour& GetAxesColour() const
4035  {
4036  return m_axColour;
4037  }
4038 
4039  const wxColour& GetbgColour() const
4040  {
4041  return m_bgColour;
4042  }
4043 
4044  void SetbgColour(const wxColour &colour)
4045  {
4046  m_bgColour = colour;
4047  }
4048 
4054  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
4055  {
4056  m_OnDeleteLayer = event;
4057  }
4058 
4061  {
4062  m_OnDeleteLayer = NULL;
4063  }
4064 
4069  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
4070  {
4071  m_OnUserMouseAction = userMouseEventHandler;
4072  }
4073 
4076  {
4077  m_OnUserMouseAction = NULL;
4078  }
4079 
4085  bool IsLogXaxis()
4086  {
4087  if (m_AxisDataX.axis)
4088  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
4089  else
4090  return false;
4091  }
4092 
4096  bool IsLogYaxis(int yAxisID)
4097  {
4098  assert(m_AxisDataYList.count(yAxisID) != 0);
4099  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4100  if (yAxis)
4101  return yAxis->IsLogAxis();
4102  else
4103  return false;
4104  }
4105 
4106  void SetLogXaxis(bool log)
4107  {
4108  if (m_AxisDataX.axis)
4109  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
4110  }
4111 
4115  void SetLogYaxis(int yAxisID, bool log)
4116  {
4117  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4118  if (yAxis)
4119  yAxis->SetLogAxis(log);
4120  }
4121 
4127  bool GetMagnetize() const
4128  {
4129  return m_magnetize;
4130  }
4131 
4132  void SetMagnetize(bool mag)
4133  {
4134  m_magnetize = mag;
4135  }
4136 
4142  {
4143  m_mouseLeftDownAction = action;
4144  }
4145 
4151  {
4152  return m_mouseLeftDownAction;
4153  }
4154 
4155 #ifdef ENABLE_MP_CONFIG
4156  void RefreshConfigWindow();
4161  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
4162  void DeleteConfigWindow(void);
4163 #endif // ENABLE_MP_CONFIG
4164 
4165  protected:
4166  virtual void BindEvents(void);
4167  virtual void OnPaint(wxPaintEvent &event);
4168  virtual void OnSize(wxSizeEvent &event);
4169  virtual void OnShowPopupMenu(wxMouseEvent &event);
4170  virtual void OnCenter(wxCommandEvent &event);
4171  virtual void OnFit(wxCommandEvent &event);
4172  virtual void OnToggleGrids(wxCommandEvent &event);
4173  virtual void OnToggleCoords(wxCommandEvent &event);
4174  virtual void OnScreenShot(wxCommandEvent &event);
4175  virtual void OnFullScreen(wxCommandEvent &event);
4176 #ifdef ENABLE_MP_CONFIG
4177  virtual void OnConfiguration(wxCommandEvent &event);
4178 #endif // ENABLE_MP_CONFIG
4179  virtual void OnLoadFile(wxCommandEvent &event);
4180  virtual void OnZoomIn(wxCommandEvent &event);
4181  virtual void OnZoomOut(wxCommandEvent &event);
4182  virtual void OnLockAspect(wxCommandEvent &event);
4183  virtual void OnMouseHelp(wxCommandEvent &event);
4184  virtual void OnMouseLeftDown(wxMouseEvent &event);
4185  virtual void OnMouseRightDown(wxMouseEvent &event);
4186  virtual void OnMouseMove(wxMouseEvent &event);
4187  virtual void OnMouseLeftRelease(wxMouseEvent &event);
4188  virtual void OnMouseWheel(wxMouseEvent &event);
4189  virtual void OnMouseLeave(wxMouseEvent &event);
4190  bool CheckUserMouseAction(wxMouseEvent &event);
4191  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
4192  virtual void OnScrollPageUp(wxScrollWinEvent &event);
4193  virtual void OnScrollPageDown(wxScrollWinEvent &event);
4194  virtual void OnScrollLineUp(wxScrollWinEvent &event);
4195  virtual void OnScrollLineDown(wxScrollWinEvent &event);
4196  virtual void OnScrollTop(wxScrollWinEvent &event);
4197  virtual void OnScrollBottom(wxScrollWinEvent &event);
4198 
4199  void DoScrollCalc(const int position, const int orientation);
4200 
4205  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = ZOOM_AROUND_CENTER);
4206 
4213  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = ZOOM_AROUND_CENTER, mpOptional_int yAxisID = MP_OPTNULL_INT);
4214 
4219  void SetScaleXAndCenter(double scaleX);
4220 
4226  void SetScaleYAndCenter(double scaleY, int yAxisID);
4227 
4232  void Zoom(bool zoomIn, const wxPoint &centerPoint);
4233 
4236  virtual bool UpdateBBox();
4237 
4241  void InitParameters();
4242 
4243  wxTopLevelWindow* m_parent;
4245 
4246  mpLayerList m_layers;
4248  mpAxisList m_AxisDataYList;
4249 
4250  wxMenu m_popmenu;
4252  wxColour m_bgColour;
4253  wxColour m_fgColour;
4254  wxColour m_axColour;
4255  bool m_drawBox;
4256 
4257  int m_scrX;
4258  int m_scrY;
4261 
4265  wxCoord m_plotWidth;
4266  wxCoord m_plotHeight;
4267 
4270  wxRect m_PlotArea;
4271 
4273  int m_last_lx, m_last_ly;
4274  wxBitmap* m_buff_bmp;
4279  wxPoint m_mouseRClick;
4280  wxPoint m_mouseLClick;
4281  double m_mouseScaleX;
4282  std::unordered_map<int, double> m_mouseScaleYList;
4283  mpOptional_int m_mouseYAxisID;
4289 
4290  wxBitmap* m_zoom_bmp;
4291  wxRect m_zoom_Dim;
4292 
4295 
4296  wxBitmap* m_Screenshot_bmp;
4297 
4298  wxString m_wildcard;
4299  wxString m_DefaultDir;
4300 
4301 #ifdef ENABLE_MP_CONFIG
4302  MathPlotConfigDialog* m_configWindow = NULL;
4303 #endif // ENABLE_MP_CONFIG
4304 
4305  mpOnDeleteLayer m_OnDeleteLayer = NULL;
4306  mpOnUserMouseAction m_OnUserMouseAction = NULL;
4307 
4311  virtual void DesiredBoundsHaveChanged() {};
4312 
4313  private:
4315  void CheckAndReportDesiredBoundsChanges();
4316 
4321  unsigned int GetNewAxisDataID(void)
4322  {
4323  int newID = 0;
4324  for (const MP_LOOP_ITER : m_AxisDataYList)
4325  {
4326  if(m_yData.axis)
4327  {
4328  // This ID is used by an axis. Make sure the new ID is larger
4329  newID = std::max(newID, m_yID + 1);
4330  }
4331  }
4332  return newID;
4333  }
4334 
4335  wxDECLARE_DYNAMIC_CLASS(mpWindow);
4336 
4337  // To have direct access to m_Screenshot_dc
4338  friend mpPrintout;
4339 };
4340 
4341 //-----------------------------------------------------------------------------
4342 // mpText - provided by Val Greene
4343 //-----------------------------------------------------------------------------
4344 
4353 {
4354  public:
4357  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
4358  {
4359  m_subtype = mptText;
4360  SetName(name);
4361  m_offsetx = 5;
4362  m_offsety = 50;
4363  m_location = mpMarginNone;
4364  m_ZIndex = mpZIndex_TEXT;
4365  }
4366 
4370  mpText(const wxString &name, int offsetx, int offsety);
4371 
4375  mpText(const wxString &name, mpLocation marginLocation);
4376 
4379  virtual bool HasBBox()
4380  {
4381  return false;
4382  }
4383 
4386  void SetLocation(mpLocation location)
4387  {
4388  m_location = location;
4389  }
4390 
4393  mpLocation GetLocation() const
4394  {
4395  return m_location;
4396  }
4397 
4400  void SetOffset(int offX, int offY)
4401  {
4402  m_offsetx = offX;
4403  m_offsety = offY;
4404  }
4405 
4407  void GetOffset(int *offX, int *offY) const
4408  {
4409  *offX = m_offsetx;
4410  *offY = m_offsety;
4411  }
4412 
4413  protected:
4416  mpLocation m_location;
4417 
4420  virtual void DoPlot(wxDC &dc, mpWindow &w);
4421 
4422  wxDECLARE_DYNAMIC_CLASS(mpText);
4423 };
4424 
4429 {
4430  public:
4433  mpTitle();
4434 
4437  mpTitle(const wxString &name) :
4438  mpText(name, mpMarginTopCenter)
4439  {
4440  m_subtype = mptTitle;
4441  SetPen(*wxWHITE_PEN);
4442  SetBrush(*wxWHITE_BRUSH);
4443  }
4444 
4445  protected:
4446 
4447  wxDECLARE_DYNAMIC_CLASS(mpTitle);
4448 };
4449 
4450 //-----------------------------------------------------------------------------
4451 // mpPrintout - provided by Davide Rondini
4452 //-----------------------------------------------------------------------------
4453 
4458 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4459 {
4460  public:
4461  mpPrintout()
4462  {
4463  plotWindow = NULL;
4464  drawn = false;
4465  stretch_factor = 2;
4466  }
4467 
4468  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4469  virtual ~mpPrintout()
4470  {
4471  ;
4472  }
4473 
4474  void SetDrawState(bool drawState)
4475  {
4476  drawn = drawState;
4477  }
4478 
4479  bool OnPrintPage(int page);
4480  bool HasPage(int page);
4481 
4484  void SetFactor(int factor)
4485  {
4486  stretch_factor = factor;
4487  }
4488 
4489  private:
4490  bool drawn;
4491  mpWindow* plotWindow;
4492  int stretch_factor; // To reduce the size of plot
4493 
4494  protected:
4495 
4496  wxDECLARE_DYNAMIC_CLASS(mpPrintout);
4497 };
4498 
4499 //-----------------------------------------------------------------------------
4500 // mpMovableObject - provided by Jose Luis Blanco
4501 //-----------------------------------------------------------------------------
4510 {
4511  public:
4515  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
4516  {
4517  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
4518  m_subtype = mpfMovable;
4519  }
4520 
4521  virtual ~mpMovableObject() {}
4522 
4525  void GetCoordinateBase(double &x, double &y, double &phi) const
4526  {
4527  x = m_reference_x;
4528  y = m_reference_y;
4529  phi = m_reference_phi;
4530  }
4531 
4534  void SetCoordinateBase(double x, double y, double phi = 0)
4535  {
4536  m_reference_x = x;
4537  m_reference_y = y;
4538  m_reference_phi = phi;
4539  m_flags = mpALIGN_SW;
4540  ShapeUpdated();
4541  }
4542 
4543  virtual bool HasBBox()
4544  {
4545  return m_trans_shape_xs.size() != 0;
4546  }
4547 
4550  virtual double GetMinX()
4551  {
4552  return m_bbox_x.min;
4553  }
4554 
4557  virtual double GetMaxX()
4558  {
4559  return m_bbox_x.max;
4560  }
4561 
4564  virtual double GetMinY()
4565  {
4566  return m_bbox_y.min;
4567  }
4568 
4571  virtual double GetMaxY()
4572  {
4573  return m_bbox_y.max;
4574  }
4575 
4576  protected:
4577 
4580  double m_reference_x, m_reference_y, m_reference_phi;
4581 
4582  virtual void DoPlot(wxDC &dc, mpWindow &w);
4583 
4586  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
4587 
4590  std::vector<double> m_shape_xs, m_shape_ys;
4591 
4595  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
4596 
4602 
4606  void ShapeUpdated();
4607 
4608  wxDECLARE_DYNAMIC_CLASS(mpMovableObject);
4609 };
4610 
4611 //-----------------------------------------------------------------------------
4612 // mpCovarianceEllipse - provided by Jose Luis Blanco
4613 //-----------------------------------------------------------------------------
4626 {
4627  public:
4631  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
4632  const wxString &layerName = _T("")) : mpMovableObject(),
4633  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
4634  {
4635  m_continuous = true;
4636  m_name = layerName;
4637  RecalculateShape();
4638  }
4639 
4640  virtual ~mpCovarianceEllipse()
4641  {
4642  ;
4643  }
4644 
4645  double GetQuantiles() const
4646  {
4647  return m_quantiles;
4648  }
4649 
4652  void SetQuantiles(double q)
4653  {
4654  m_quantiles = q;
4655  RecalculateShape();
4656  }
4657 
4658  void SetSegments(int segments)
4659  {
4660  m_segments = segments;
4661  }
4662 
4663  int GetSegments() const
4664  {
4665  return m_segments;
4666  }
4667 
4670  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
4671  {
4672  cov_00 = m_cov_00;
4673  cov_01 = m_cov_01;
4674  cov_11 = m_cov_11;
4675  }
4676 
4679  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
4680  {
4681  m_cov_00 = cov_00;
4682  m_cov_01 = cov_01;
4683  m_cov_11 = cov_11;
4684  RecalculateShape();
4685  }
4686 
4687  protected:
4690  double m_cov_00, m_cov_11, m_cov_01;
4691  double m_quantiles;
4692 
4696 
4699  void RecalculateShape();
4700 
4701  wxDECLARE_DYNAMIC_CLASS(mpCovarianceEllipse);
4702 };
4703 
4704 //-----------------------------------------------------------------------------
4705 // mpPolygon - provided by Jose Luis Blanco
4706 //-----------------------------------------------------------------------------
4712 {
4713  public:
4716  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
4717  {
4718  m_continuous = true;
4719  m_name = layerName;
4720  }
4721 
4722  virtual ~mpPolygon()
4723  {
4724  ;
4725  }
4726 
4732  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
4733 
4734  protected:
4735 
4736  wxDECLARE_DYNAMIC_CLASS(mpPolygon);
4737 };
4738 
4739 //-----------------------------------------------------------------------------
4740 // mpBitmapLayer - provided by Jose Luis Blanco
4741 //-----------------------------------------------------------------------------
4747 {
4748  public:
4752  {
4753  m_validImg = false;
4754  m_bitmapChanged = false;
4755  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
4756  }
4757 
4758  virtual ~mpBitmapLayer()
4759  {
4760  ;
4761  }
4762 
4765  void GetBitmapCopy(wxImage &outBmp) const;
4766 
4774  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
4775 
4778  virtual double GetMinX()
4779  {
4780  return m_bitmapX.min;
4781  }
4782 
4785  virtual double GetMaxX()
4786  {
4787  return m_bitmapX.max;
4788  }
4789 
4792  virtual double GetMinY()
4793  {
4794  return m_bitmapY.min;
4795  }
4796 
4799  virtual double GetMaxY()
4800  {
4801  return m_bitmapY.max;
4802  }
4803 
4804  protected:
4805 
4808  wxImage m_bitmap;
4809  wxBitmap m_scaledBitmap;
4810  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
4811  bool m_validImg;
4812  bool m_bitmapChanged;
4813 
4816  mpRange<double> m_bitmapX; // Range of the bitmap on x direction
4817  mpRange<double> m_bitmapY; // Range of the bitmap on y direction
4818 
4819  virtual void DoPlot(wxDC &dc, mpWindow &w);
4820 
4821  wxDECLARE_DYNAMIC_CLASS(mpBitmapLayer);
4822 };
4823 
4824 // utility class
4825 
4827 typedef enum __mp_Colour
4828 {
4829  mpBlue,
4830  mpRed,
4831  mpGreen,
4832  mpPurple,
4833  mpYellow,
4834  mpFuchsia,
4835  mpLime,
4836  mpAqua,
4837  mpOlive
4838 } mpColour;
4839 
4844 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
4845 {
4846  public:
4851  wxIndexColour(unsigned int id)
4852  {
4853  switch (id)
4854  {
4855  case 0:
4856  this->Set(0, 0, 255);
4857  break; // Blue
4858  case 1:
4859  this->Set(255, 0, 0);
4860  break; // Red
4861  case 2:
4862  this->Set(0, 128, 0);
4863  break; // Green
4864  case 3:
4865  this->Set(128, 0, 128);
4866  break; // Purple
4867  case 4:
4868  this->Set(255, 255, 0);
4869  break; // Yellow
4870  case 5:
4871  this->Set(255, 0, 255);
4872  break; // Fuchsia
4873  case 6:
4874  this->Set(0, 255, 0);
4875  break; // Lime
4876  case 7:
4877  this->Set(0, 255, 255);
4878  break; // Aqua/Cyan
4879  case 8:
4880  this->Set(128, 128, 0);
4881  break; // Olive
4882  default:
4883  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
4884  (ChannelType)((rand() * 255) / RAND_MAX));
4885  }
4886  }
4887 };
4888 
4891 // ---------------------------------------------------------------------
4892 #ifdef ENABLE_MP_NAMESPACE
4893  }// namespace MathPlot
4894  // No, iff build enables namespace, its up to app to use it appropriately: using namespace MathPlot;
4895 #endif // ENABLE_MP_NAMESPACE
4896 
4897 #endif // MATHPLOT_H_INCLUDED
sub type for mpFXYVector function
Definition: mathplot.h:706
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:4415
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2630
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer.
Definition: mathplot.h:3006
bool IsHorizontal(void) const
Is it a horizontal line?
Definition: mathplot.h:1641
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:608
int GetAxisID(void)
Return the ID of the Axis.
Definition: mathplot.h:2559
mpRange< double > m_rangeY
Y range.
Definition: mathplot.h:2234
sub type for mpText layer
Definition: mathplot.h:695
Align the plot label towards the southeast.
Definition: mathplot.h:647
void SetValue(const double value)
Set x or y value.
Definition: mathplot.h:1633
mpInfoLegend * m_InfoLegend
Pointer to the optional info legend layer.
Definition: mathplot.h:4287
Draw a circle.
Definition: mathplot.h:670
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:655
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:4263
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:2763
void EnableDoubleBuffer(const bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled).
Definition: mathplot.h:3522
wxIndexColour(unsigned int id)
Constructor.
Definition: mathplot.h:4851
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:1020
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:4096
std::vector< std::string > labels
Labels of the Values.
Definition: mathplot.h:2359
enum __mp_Colour mpColour
Enumeration of classic colour.
Bitmap type layer.
Definition: mathplot.h:785
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1141
__Scale_Type
sub_type values for mpLAYER_AXIS
Definition: mathplot.h:713
Plot type layer.
Definition: mathplot.h:770
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:3455
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4799
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:1333
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:4060
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1696
void SetYAxisID(unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1570
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:4711
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:3250
mpFloatRectSimple(mpRange< double > _x, mpRange< double > _y)
Construct a simple rectangular box.
Definition: mathplot.h:553
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:898
__Symbol_Type
Displaying a symbol instead of a point in the plot function.
Definition: mathplot.h:667
double m_deltaY
Min delta between 2 consecutive coordinate on y direction.
Definition: mathplot.h:1929
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:221
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:1977
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:4259
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:654
__mp_Layer_Type
< Major type of an mpLayer (detail is in subtype)
Definition: mathplot.h:766
Show/Hide grids.
Definition: mathplot.h:596
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:4746
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:2754
bool m_magnetize
For mouse magnetization.
Definition: mathplot.h:4293
mpLabelType
enum for label for grid
Definition: mathplot.h:738
void Update(T value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:335
bool m_mouseMovedAfterRightClick
If the mouse does not move after a right click, then the context menu is displayed.
Definition: mathplot.h:4278
Classic Normal distribution f(x) = exp(-(ln(x)-μ)²/2σ²)/(xσ.sqrt(2π))
Definition: mathplot.h:2281
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2495
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:4279
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:2479
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:4716
double m_lastX
Last x-coordinate point added.
Definition: mathplot.h:2059
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2596
std::unordered_map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:2983
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:3512
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:4816
Layer type undefined; SHOULD NOT BE USED.
Definition: mathplot.h:768
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:801
sub type not defined (should be never used)
Definition: mathplot.h:715
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1140
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1133
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1617
Lock x/y scaling aspect.
Definition: mathplot.h:595
virtual double GetMinY()
Get min Y of the function.
Definition: mathplot.h:2219
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:1407
wxString m_wildcard
For loadfile() function when we use wxFileDialog.
Definition: mathplot.h:4298
Align the info in margin center-bottom.
Definition: mathplot.h:616
Info box type layer.
Definition: mathplot.h:790
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:4414
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set axis label view mode.
Definition: mathplot.h:2622
Abstract class providing a line.
Definition: mathplot.h:1605
mpRange< double > m_rangeX
Range min and max on x axis.
Definition: mathplot.h:2058
Abstract class providing an vertical line.
Definition: mathplot.h:1683
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2582
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2458
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:3090
mpRange< int > m_drawY
Range min and max on y axis.
Definition: mathplot.h:1925
wxString m_DefaultDir
The default directory for wxFileDialog.
Definition: mathplot.h:4299
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:2755
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3405
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:3493
std::vector< double > m_ys
internal copy of the set of data on y direction
Definition: mathplot.h:2048
void SetExtraMargin(int extra)
Set the extra margin.
Definition: mathplot.h:3926
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:2889
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1280
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:4534
Chart type layer (bar chart)
Definition: mathplot.h:775
mpRange< double > x
range over x direction
Definition: mathplot.h:545
double GetPosY(int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3396
virtual void SetLogAxis(bool log)
Set Logarithmic mode.
Definition: mathplot.h:2745
sub type for mpLine function
Definition: mathplot.h:708
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:997
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3545
int m_winY
Holds the mpWindow size. Used to rescale position when window is resized.
Definition: mathplot.h:1282
~mpBarChart()
Destructor.
Definition: mathplot.h:2386
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:3485
T GetMaxAbs(void) const
Returns max absolute value of the range.
Definition: mathplot.h:390
Draw a cross X.
Definition: mathplot.h:674
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition: mathplot.h:357
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1148
Draw a triangle up oriented.
Definition: mathplot.h:672
void SetLegendVisibility(bool visibility)
Set the visibility of the name of the function in the legend despite the visibility of the function i...
Definition: mathplot.h:1578
wxTopLevelWindow * m_parent
Pointer to the top-level window containing the plot (used for fullscreen)
Definition: mathplot.h:4243
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:4280
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:4311
T min
The min value of the range.
Definition: mathplot.h:255
bool m_InInfoLegend
Boolean value indicating that the mouse is moving over the legend area.
Definition: mathplot.h:4288
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:1005
No alignment.
Definition: mathplot.h:618
int m_flags
Holds label alignment. Default : mpALIGN_SW for series and mpALIGN_CENTER for scale.
Definition: mathplot.h:1145
mpRange< double > m_bbox_x
The precomputed bounding box:
Definition: mathplot.h:4600
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:4379
Mouse action drag the plot.
Definition: mathplot.h:734
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:882
mpNormal(double mu, double sigma)
Classic Normal distribution.
Definition: mathplot.h:2289
wxPoint GetPosition() const
Returns the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1244
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1362
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:1051
~mpPieChart()
Destructor.
Definition: mathplot.h:2449
mpRange()
Default constructor.
Definition: mathplot.h:259
T max
The max value of the range.
Definition: mathplot.h:256
sub type not defined (should be never used)
Definition: mathplot.h:724
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1594
void SetDefaultDir(const wxString &dirname)
Set the default directory for wxFileDialog.
Definition: mathplot.h:3828
enum __Function_Type mpFunctionType
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
sub type not defined (should be never used)
Definition: mathplot.h:702
void Check(void)
Check to always have a range. If min = max then introduce the 0 to make a range.
Definition: mathplot.h:366
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:3945
sub type not defined (should be never used)
Definition: mathplot.h:694
double m_lastY
Last y-coordinate point added.
Definition: mathplot.h:2061
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1135
T GetCenter(void) const
Center of the range.
Definition: mathplot.h:384
Just the end of ZOrder.
Definition: mathplot.h:792
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4564
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:783
void Set(T _value)
Initialize min and max.
Definition: mathplot.h:281
mpRange< double > m_axisRange
Range axis values when autosize is false.
Definition: mathplot.h:2759
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:3869
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:3835
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1498
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:3939
Draw a plus +.
Definition: mathplot.h:675
void SetMouseLeftDownAction(mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:4141
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:4250
Keep the object, just remove the layer from the layer list.
Definition: mathplot.h:803
double m_mu
Mean value.
Definition: mathplot.h:2266
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:4281
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1785
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:1850
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:4254
Delete the object regardless of the CanDelete value and remove it from the layer list.
Definition: mathplot.h:805
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:1143
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:4268
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:4525
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:3014
Align the plot label towards the southwest.
Definition: mathplot.h:648
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:1389
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:2837
Align the y-axis towards left border.
Definition: mathplot.h:635
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1144
#define ISNOTNULL(x)
Nullity test according small epsilon.
Definition: mathplot.h:177
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:4386
Align the x-axis towards bottom border.
Definition: mathplot.h:625
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2352
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3529
void Assign(T value1, T value2)
Assign values to min and max.
Definition: mathplot.h:311
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:4255
Plot (function) type layer.
Definition: mathplot.h:788
void UpdateDesiredBoundingBox(mpAxisUpdate update)
Update m_desired bounds.
Definition: mathplot.h:3650
void UpdateBoundingBoxToInclude(double px, double py)
Update bounding box (X and Y axis) to include this point.
Definition: mathplot.h:569
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2646
bool m_IsHorizontal
Is the line horizontal? Default false.
Definition: mathplot.h:1648
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1147
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1534
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:834
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1136
bool GetCanDelete(void) const
Retreive what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1120
Axis type layer.
Definition: mathplot.h:786
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:2503
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:2758
Draw a triangle down oriented.
Definition: mathplot.h:673
Axis type layer.
Definition: mathplot.h:769
void SetCanDelete(bool canDelete)
Define what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1113
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4778
bool GetMagnetize() const
Magnetize the position of the mouse in the plot ie draw a vertical and horizontal line...
Definition: mathplot.h:4127
double m_value
The x or y coordinates of the line.
Definition: mathplot.h:1647
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:4285
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:2760
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:1318
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:2589
Align the info in margin center-right.
Definition: mathplot.h:614
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:4034
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:1030
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:2954
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:2124
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:4357
mpRange< double > lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:2972
double m_const
Const factor.
Definition: mathplot.h:2269
std::unordered_map< int, mpRange< double > > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:3334
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:4808
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:4069
bool GetLegendVisibility() const
Get the visibility of the legend.
Definition: mathplot.h:1586
each visible plot is described on its own line, one above the other
Definition: mathplot.h:662
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:3361
Align the x-axis towards top plot.
Definition: mathplot.h:628
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1127
mpRange< double > bound
Range min and max.
Definition: mathplot.h:2970
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:741
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:3951
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:1348
#define EPSILON
An epsilon for float comparison to 0.
Definition: mathplot.h:175
Align the y-axis towards right border.
Definition: mathplot.h:639
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:683
std::unordered_map< int, mpRange< double > > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:3348
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:2056
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4785
Show/Hide info coord.
Definition: mathplot.h:597
Align the x-axis towards top border.
Definition: mathplot.h:629
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:1044
Mouse action draw a box to zoom inside.
Definition: mathplot.h:733
mpFXGeneric(const wxString &name=wxT("Generic FX function"), int flags=mpALIGN_LEFT, unsigned int yAxisID=0)
Definition: mathplot.h:2186
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:4679
__Function_Type
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
Definition: mathplot.h:700
Classic Gaussian distribution f(x) = exp(-(x-μ)²/2σ²)/sqrt(2πσ²)
Definition: mathplot.h:2248
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition: mathplot.h:66
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4458
Align the y-axis towards left plot.
Definition: mathplot.h:636
int m_last_ly
For double buffering.
Definition: mathplot.h:4273
struct deprecated("No more used, 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:427
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:4294
wxSize GetSize() const
Returns the size of the box (in pixels)
Definition: mathplot.h:1251
Chart type layer.
Definition: mathplot.h:789
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:2757
Set label for axis in scientific notation.
Definition: mathplot.h:745
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:347
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1278
Copy a screen shot to the clipboard.
Definition: mathplot.h:598
Create a generic FX function Override the ComputeY() function with your function. ...
Definition: mathplot.h:2179
Fit view to match bounding box of all layers.
Definition: mathplot.h:591
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:4393
bool PointIsInside(double px, double py) const
Is point inside this bounding box?
Definition: mathplot.h:560
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:604
wxBitmap * m_buff_bmp
For double buffering.
Definition: mathplot.h:4274
Center view on click position.
Definition: mathplot.h:594
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1596
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:1989
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:623
sub type for all layers who are function.
Definition: mathplot.h:709
Draw a square.
Definition: mathplot.h:671
mpRange< double > GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:3301
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:4509
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2301
Align the x-axis center plot.
Definition: mathplot.h:627
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:692
double m_deltaX
Min delta between 2 consecutive coordinate on x direction.
Definition: mathplot.h:1928
__mp_Colour
Enumeration of classic colour.
Definition: mathplot.h:4827
bool m_LegendVisibility
If true, the name is visible in the legend despite the visibility of the function. Default true.
Definition: mathplot.h:1598
mpRange< double > GetDesiredBoundY(int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3324
Align the plot label towards the northwest.
Definition: mathplot.h:645
double m_total_value
Total of the values vector.
Definition: mathplot.h:2362
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:4248
void SetMinScale(double min)
Set the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2670
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:1876
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:4590
virtual bool IsLogAxis()
Get if we are in Logarithmic mode.
Definition: mathplot.h:2737
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1541
mpRange< double > desired
Desired range min and max.
Definition: mathplot.h:2971
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:2845
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:4844
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1597
mpRange(T value1, T value2)
Create range with the 2 values.
Definition: mathplot.h:266
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1506
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:4264
No symbol is drawing.
Definition: mathplot.h:669
Layer for bar chart.
Definition: mathplot.h:2379
mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:3675
__Chart_Type
sub_type values for mpLAYER_CHART
Definition: mathplot.h:722
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1138
virtual double ComputeY(double x)
The main computation of the FX function.
Definition: mathplot.h:2304
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2268
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:1368
abstract Layer for chart (bar and pie).
Definition: mathplot.h:2321
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:656
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:543
sub type for all layers who are chart.
Definition: mathplot.h:727
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:1013
Align the info in margin center-left.
Definition: mathplot.h:610
void SetLabelFormat(const wxString &format, bool updateLabelMode=false)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2605
const wxRect & GetRectangle() const
Returns the current rectangle coordinates.
Definition: mathplot.h:1258
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:3687
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:743
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:643
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1593
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:3706
void ToLog(void)
Convert to log range.
Definition: mathplot.h:396
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:3892
mpRange< double > m_rangeY
Range min and max on y axis.
Definition: mathplot.h:2060
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:2009
int m_symbolSize2
Size of the symbol div 2.
Definition: mathplot.h:1595
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4792
sub type for mpInfoLegend layer
Definition: mathplot.h:688
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2662
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:2087
int GetMarginRight(bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:3877
mpRange< int > m_drawX
Range min and max on x axis.
Definition: mathplot.h:1924
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1669
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:2029
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:2039
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:3717
Text box type layer.
Definition: mathplot.h:772
mpMouseButtonAction GetMouseLeftDownAction()
Returns the type of action for the left mouse button.
Definition: mathplot.h:4150
double pos
Position.
Definition: mathplot.h:2969
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:3846
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:633
sub type for mpBarChart
Definition: mathplot.h:725
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:4270
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1193
Load a file.
Definition: mathplot.h:602
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:846
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:4407
bool m_fullscreen
Boolean value indicating that we are in fullscreen mode (default false)
Definition: mathplot.h:4244
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:4265
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:1220
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:855
Line (horizontal or vertical) type layer.
Definition: mathplot.h:787
wxBitmap * m_zoom_bmp
For zoom selection.
Definition: mathplot.h:4290
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1302
double m_mu
Mean value.
Definition: mathplot.h:2299
mpRange< double > y
range over y direction
Definition: mathplot.h:546
mpLocation m_location
The location of the text.
Definition: mathplot.h:4416
Delete the object if CanDelete is true and remove it from the layer list.
Definition: mathplot.h:804
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:3777
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:4258
sub type for mpTitle layer
Definition: mathplot.h:696
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:3504
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1513
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:4247
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1403
wxRect m_oldDim
Keep the old values of m_dim.
Definition: mathplot.h:1279
double GetMaxScale() const
Get the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2694
Align the info in margin center-top.
Definition: mathplot.h:612
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:752
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:4252
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:4085
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3431
int GetBarWidth(void) const
Get the width of the bar when we plot in bar mode.
Definition: mathplot.h:1907
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:4054
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1341
void SetAxisID(unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2568
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:2109
void SetMin(T _min)
Set min function, correct max.
Definition: mathplot.h:295
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:3985
bool m_enableDoubleBuffer
For double buffering. Default enabled.
Definition: mathplot.h:4275
double m_max_value
Max value of the values vector.
Definition: mathplot.h:2361
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1485
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1723
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2466
mpTitle(const wxString &name)
Definition: mathplot.h:4437
Plot layer implementing a simple title.
Definition: mathplot.h:4428
Set no label for axis (useful for bar)
Definition: mathplot.h:758
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:2879
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:731
sub type for mpPieChart
Definition: mathplot.h:726
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:4543
bool ViewAsBar(void) const
Get if we are in bar mode.
Definition: mathplot.h:1916
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1283
mpRange< double > GetBoundY(int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3315
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:1078
mpGaussian(double mu, double sigma)
Classic Gaussian distribution.
Definition: mathplot.h:2256
Align the plot label towards the northeast.
Definition: mathplot.h:646
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:3960
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:3372
only for mpInfoCoords
Definition: mathplot.h:619
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1106
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1142
std::vector< double > m_trans_shape_xs
The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh)...
Definition: mathplot.h:4595
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:3933
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2654
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:1868
virtual double ComputeY(double x)
The main computation of the FX function.
Definition: mathplot.h:2271
sub type for mpFXY function
Definition: mathplot.h:705
enum __XAxis_Align_Type mpXAxis_Align
Alignment for X axis.
#define ZOOM_AROUND_CENTER
Default value for zoom around a point (default -1 is no zoom)
Definition: mathplot.h:183
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1592
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:4075
enum __Chart_Type mpChartType
sub_type values for mpLAYER_CHART
std::vector< double > m_xs
The internal copy of the set of data to draw.
Definition: mathplot.h:2047
void SetScale(mpRange< double > range)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2721
mpRange< double > GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:3307
~mpChart()
Destructor.
Definition: mathplot.h:2328
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:3724
virtual double GetY(double x)
Get function value for argument.
Definition: mathplot.h:2200
Abstract class providing an horizontal line.
Definition: mathplot.h:1655
Zoom into view at clickposition / window center.
Definition: mathplot.h:592
int GetMarginLeft(bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:3917
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:4251
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:4695
bool m_enableScrollBars
Enable scrollbar in plot window (default false)
Definition: mathplot.h:4284
double scale
Scale.
Definition: mathplot.h:2968
Align the info in margin top-left.
Definition: mathplot.h:611
void Rewind()
Rewind value enumeration with mpFXY::GetNextXY.
Definition: mathplot.h:2066
bool IsSet()
Check if this mpRange has been assigned any values.
Definition: mathplot.h:326
Zoom out.
Definition: mathplot.h:593
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2536
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:973
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:3020
double GetMinScale() const
Get the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2678
int m_reserveXY
Memory reserved for m_xs and m_ys.
Definition: mathplot.h:2052
bool PointIsInside(T point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:403
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:660
sub type for mpInfoLayer layer
Definition: mathplot.h:686
Align the x-axis towards bottom plot.
Definition: mathplot.h:626
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:4625
virtual double GetMaxY()
Get max Y of the function.
Definition: mathplot.h:2228
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2614
int GetMarginTop(bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:3860
mpInfoCoords * m_InfoCoords
Pointer to the optional info coords layer.
Definition: mathplot.h:4286
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:3696
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:750
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:2965
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:652
Layer for pie chart.
Definition: mathplot.h:2440
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:989
Align the y-axis towards right plot.
Definition: mathplot.h:638
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:2712
T Length(void) const
Length of the range.
Definition: mathplot.h:378
sub type for mpScaleX
Definition: mathplot.h:716
sub type for mpInfoCoords layer
Definition: mathplot.h:687
Set label user defined.
Definition: mathplot.h:756
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:4631
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:981
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:4276
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1137
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:3381
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:748
sub type not defined (should be never used)
Definition: mathplot.h:685
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:754
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:4670
void SetMax(T _max)
Set max function, correct min.
Definition: mathplot.h:303
Bitmap type layer.
Definition: mathplot.h:773
wxRect m_zoom_Dim
Rectangular area selected for zoom.
Definition: mathplot.h:4291
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1265
bool IsVisible() const
Checks whether the layer is visible or not.
Definition: mathplot.h:1071
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:2575
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:863
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:1092
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1549
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2761
Align the info in margin bottom-left.
Definition: mathplot.h:615
const wxString & GetWildcard(void) const
Get wildcard.
Definition: mathplot.h:3810
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:4514
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:704
Info box type layer.
Definition: mathplot.h:771
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:3476
mpOptional_int m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:4283
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3466
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3413
Align the y-axis center plot.
Definition: mathplot.h:637
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:1709
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:906
Plot layer implementing a text string.
Definition: mathplot.h:4352
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:873
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:4266
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4571
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:3991
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:1058
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1139
double m_sigma
Sigma value.
Definition: mathplot.h:2267
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:3886
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:890
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1281
int GetMarginBottom(bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:3900
Shows information about the mouse commands.
Definition: mathplot.h:603
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:4115
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:3852
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:3264
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:4253
mpRange< double > m_bbox_y
Range of bounding box on y direction.
Definition: mathplot.h:4601
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:4296
legend components follow each other horizontally on a single line
Definition: mathplot.h:663
Align the info in margin top-right.
Definition: mathplot.h:613
void InitializeBoundingBox(double px, double py)
Initialize bounding box with an initial point.
Definition: mathplot.h:579
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1420
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 above)...
Definition: mathplot.h:4652
double m_const
Const factor.
Definition: mathplot.h:2302
bool m_repainting
Boolean value indicating that we are in repaint step.
Definition: mathplot.h:4272
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1562
sub type for all layers who are scale.
Definition: mathplot.h:718
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:4260
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:253
void Set(T _min, T _max)
Set min, max function.
Definition: mathplot.h:288
Align the info in margin bottom-right.
Definition: mathplot.h:617
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:4580
double GetScaleY(int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:3289
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:2487
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1520
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4550
sub type for mpMovableObject function
Definition: mathplot.h:707
Plot layer, abstract base class.
Definition: mathplot.h:818
std::vector< double > values
Values of the chart.
Definition: mathplot.h:2358
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1146
mpRange< double > GetScale() const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2729
double GetValue() const
Get the x or y coordinates of the line.
Definition: mathplot.h:1625
enum __Scale_Type mpScaleType
sub_type values for mpLAYER_AXIS
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:4400
void SetFactor(int factor)
Definition: mathplot.h:4484
sub type for mpFX function
Definition: mathplot.h:703
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:957
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1134
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:2762
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:4257
double m_sigma
Sigma value.
Definition: mathplot.h:2300
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:4282
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:1037
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:965
void SetScale(double min, double max)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2703
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1164
#define mpX_RAWTIME
Shortcut for mpX_UTCTIME.
Definition: mathplot.h:172
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:4690
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:3909
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:4246
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:2756
std::map< int, mpAxisData > GetSortedAxisDataYList(void) const
Get a sorted version of the Y-axis data map.
Definition: mathplot.h:3421
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:4262
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2149
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1272
void SetWildcard(const wxString &wildcard)
Set wildcard for LoadFile() function when we use wxFileDialog.
Definition: mathplot.h:3802
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:4277
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:4269
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:1085
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2551
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4557
bool IsRepainting() const
Checks if we are repainting.
Definition: mathplot.h:3554
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:3628
void SetMaxScale(double max)
Set the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2686
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2638
sub type for mpScaleY
Definition: mathplot.h:717
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1527
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:4751
void SetScaleY(const double scaleY, int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:3273
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:2991
Text box type layer.
Definition: mathplot.h:791
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:3106
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:1099
Line (horizontal or vertical) type layer.
Definition: mathplot.h:774
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:2102