MathPlot
mathplot.h
Go to the documentation of this file.
1 // Name: mathplot.cpp
3 // Purpose: Framework for plotting in wxWindows
4 // Original Author: David Schalig
5 // Maintainer: Davide Rondini
6 // Contributors: Jose Luis Blanco, Val Greene, Lionel Reynaud, Dave Nadler, MortenMacFly,
7 // Oskar Waldemarsson (for multi Y axis and corrections)
8 // Created: 21/07/2003
9 // Last edit: 18/04/2026
10 // Copyright: (c) David Schalig, Davide Rondini
11 // Licence: wxWindows licence
13 
14 #ifndef MATHPLOT_H_INCLUDED
15 #define MATHPLOT_H_INCLUDED
16 
67 //this definition uses windows dll to export function.
68 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
69 //mathplot_EXPORTS will be defined by cmake
70 #ifdef mathplot_EXPORTS
71  #define WXDLLIMPEXP_MATHPLOT WXEXPORT
73  #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
75 #else // not making DLL
76  #define WXDLLIMPEXP_MATHPLOT
78  #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
80 #endif
81 
82 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
83  #pragma interface "mathplot.h"
84 #endif
85 
86 #include <cassert> // For assert debug message. Disable if NDEBUG is defined
87 #include <vector>
88 #include <map>
89 #include <unordered_map>
90 
98 // Multiple define to compile with C++14 because
99 // Optional is only for C++ >= 17
100 // Structured binding is a C++17 feature
101 #if (defined(__cplusplus) && (__cplusplus > 201402L)) // C++17 or newer
102  // Use optional
103  #include <optional>
105  typedef std::optional<unsigned int> mpOptional_uint;
107  typedef std::optional<int> mpOptional_int;
109  #define MP_OPTNULL_INT std::nullopt
110  #define MP_OPTTEST(opt) (opt)
112  #define MP_OPTGET(opt) (*opt)
114  // Use structured binding
116  #define MP_LOOP_ITER auto& [m_yID, m_yData]
117 #else
118  // To replace optional int...
120  typedef unsigned int mpOptional_uint;
122  typedef int mpOptional_int;
124  #define MP_OPTNULL_INT -1
125  #define MP_OPTTEST(opt) ((opt) != -1)
127  #define MP_OPTGET(opt) (opt)
129  // To replace structured binding...
131  #define MP_LOOP_ITER auto& elem
132  #define m_yID elem.first
134  #define m_yData elem.second
136 #endif
137 
140 // #include <wx/wx.h>
141 #include <wx/defs.h>
142 #include <wx/menu.h>
143 #include <wx/scrolwin.h>
144 #include <wx/event.h>
145 #include <wx/dynarray.h>
146 #include <wx/pen.h>
147 #include <wx/dcmemory.h>
148 #include <wx/string.h>
149 #include <wx/print.h>
150 #include <wx/image.h>
151 #include <wx/intl.h>
152 
153 #include <cmath>
154 #include <deque>
155 #include <algorithm>
156 
157 #if defined(MP_USER_INCLUDE)
158  #define xstr(x) #x
160  #define str(x) xstr(x)
162  #define header MP_USER_INCLUDE.h
163  #include str(header)
164  #undef header
165 #endif
166 
167 #ifdef ENABLE_MP_CONFIG
168  #include "MathPlotConfig.h"
169 #endif // ENABLE_MP_CONFIG
170 
175 // No, this is supposed to be a build parameter: #define ENABLE_MP_NAMESPACE
176 #ifdef ENABLE_MP_NAMESPACE
177  namespace MathPlot {
178 #endif // ENABLE_MP_NAMESPACE
179 
180 #ifdef ENABLE_MP_DEBUG
181  // For memory leak debug
182  #ifdef _WINDOWS
183  #ifdef _DEBUG
184  #include <crtdbg.h>
185  #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
186  #else
187  #define DEBUG_NEW new
188  #endif // _DEBUG
189  #endif // _WINDOWS
190 #endif // ENABLE_MP_DEBUG
191 
193 #define MP_X_BORDER_SEPARATION 40
194 #define MP_Y_BORDER_SEPARATION 60
196 
198 #define MP_X_LOCALTIME 0x10
199 #define MP_X_UTCTIME 0x20
201 #define MP_X_RAWTIME MP_X_UTCTIME
203 
205 #define MP_EPSILON 1e-30
206 #define ISNOTNULL(x) (std::fpclassify(x) != FP_ZERO)
208 
210 #define MP_EXTRA_MARGIN 8
211 
213 #define MP_ZOOM_AROUND_CENTER -1
214 
215 //-----------------------------------------------------------------------------
216 // classes
217 //-----------------------------------------------------------------------------
218 
220 #define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class) wxDECLARE_DYNAMIC_CLASS(mp_class)
221 
251 
252 #ifdef ENABLE_MP_CONFIG
254 #endif // ENABLE_MP_CONFIG
255 
257 typedef union
258 {
259  struct
260  {
261  wxCoord startPx;
262  wxCoord endPx;
263  wxCoord startPy;
264  wxCoord endPy;
265  };
266  struct
267  {
268  wxCoord left;
269  wxCoord top;
270  wxCoord right;
271  wxCoord bottom;
272  };
273  struct
274  {
275  wxCoord x1;
276  wxCoord y1;
277  wxCoord x2;
278  wxCoord y2;
279  };
280  wxCoord tab[4];
281 
286  wxRect GetRect(void)
287  {
288  return wxRect(startPx, startPy, endPx - startPx, endPy - startPy);
289  }
290 } mpRect;
291 
297 template<typename T>
298 struct mpRange
299 {
300  T min = 0;
301  T max = 0;
302 
305  {
306  min = 0;
307  max = 0;
308  }
309 
311  mpRange(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  void Set(T _value)
327  {
328  min = _value;
329  max = _value;
330  }
331 
333  void Set(T _min, T _max)
334  {
335  min = _min;
336  max = _max;
337  }
338 
340  void SetMin(T _min)
341  {
342  min = _min;
343  if (max < min)
344  max = min;
345  }
346 
348  void SetMax(T _max)
349  {
350  max = _max;
351  if (min > max)
352  min = max;
353  }
354 
356  void Assign(T value1, T value2)
357  {
358  if (value1 < value2)
359  {
360  min = value1;
361  max = value2;
362  }
363  else
364  {
365  min = value2;
366  max = value1;
367  }
368  }
369 
371  bool IsSet()
372  {
373  return ((min != 0) || (max != 0));
374  }
375 
380  void Update(T value)
381  {
382  if (value < min)
383  min = value;
384  else
385  if (value > max)
386  max = value;
387  }
388 
392  void Update(T _min, T _max)
393  {
394  if (_min < min)
395  min = _min;
396  if (_max > max)
397  max = _max;
398  }
399 
402  void Update(mpRange range)
403  {
404  if (range.min < min)
405  min = range.min;
406  if (range.max > max)
407  max = range.max;
408  }
409 
411  void Check(void)
412  {
413  if (min == max)
414  {
415  if (max > 0)
416  min = 0;
417  else
418  max = 0;
419  }
420  }
421 
423  T Length(void) const
424  {
425  return max - min;
426  }
427 
429  T GetCenter(void) const
430  {
431  return (min + max) / 2;
432  }
433 
435  T GetMaxAbs(void) const
436  {
437  return std::max(fabs(min), fabs(max));
438  }
439 
441  void ToLog(void)
442  {
443  min = (min > 0) ? log10(min) : 0;
444  max = (max > 0) ? log10(max) : 0;
445  }
446 
448  bool PointIsInside(T point) const
449  {
450  return ((point >= min) && (point <= max));
451  }
452 
453  #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
454  bool operator==(const mpRange&) const = default;
455  #else
456  bool operator==(const mpRange &other) const
458  {
459  return (min == other.min) && (max == other.max);
460  }
462  bool operator!=(const mpRange& other) const
463  {
464  return !(*this == other);
465  }
466  #endif
467 };
468 
474 struct [[deprecated("Deprecated! No longer used as X and Y are now separated")]] mpFloatRect
475 {
476  mpRange<double> x;
477  std::vector<mpRange<double>> y;
478 
485  mpFloatRect(mpWindow& w);
486 
488  mpFloatRect() = delete;
489 
496  bool PointIsInside(double px, double py, size_t yAxisID = 0) const {
497  if (yAxisID < y.size())
498  {
499  if( (px < x.min || px > x.max) ||
500  (py < y[yAxisID].min || py > y[yAxisID].max))
501  {
502  return false;
503  }
504  }
505  else
506  {
507  return false;
508  }
509 
510  return true;
511  }
512 
519  void UpdateBoundingBoxToInclude(double px, double py, size_t yAxisID = 0) {
520  assert(yAxisID < y.size());
521  if (yAxisID < y.size())
522  {
523  if (px < x.min ) x.min = px;
524  else if (px > x.max ) x.max = px;
525  if (py < y[yAxisID].min ) y[yAxisID].min = py;
526  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
527  }
528  }
529 
536  void InitializeBoundingBox(double px, double py, size_t yAxisID = 0) {
537  assert(yAxisID < y.size());
538  if (yAxisID < y.size())
539  {
540  x.min = x.max = px;
541  y[yAxisID].min = y[yAxisID].max = py;
542  }
543  }
545  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
547 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
548  bool operator==(const mpFloatRect&) const = default;
549 #else
550  // We compare with an epsilon precision
551  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
552  bool operator==(const mpFloatRect& rect) const
553  {
554  auto Same = [](double a, double b) {
555  return std::fabs(a - b) < MP_EPSILON;
556  };
557 
558  // Compare scalar members
559  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
560  {
561  return false;
562  }
563 
564  // Compare vector sizes
565  if (y.size() != rect.y.size())
566  {
567  return false;
568  }
569 
570  // Compare each Y boundary
571  for (size_t i = 0; i < y.size(); ++i)
572  {
573  if (!Same(y[i].min, rect.y[i].min) ||
574  !Same(y[i].max, rect.y[i].max) )
575  {
576  return false;
577  }
578  }
579 
580  return true;
581  }
582 #endif
583 };
584 
591 {
594 
601 
607  bool PointIsInside(double px, double py) const {
608  return x.PointIsInside(px) && y.PointIsInside(py);
609  }
610 
616  void UpdateBoundingBoxToInclude(double px, double py)
617  {
618  x.Update(px);
619  y.Update(py);
620  }
621 
626  void InitializeBoundingBox(double px, double py)
627  {
628  x.Set(px, px);
629  y.Set(py, py);
630  }
631 };
632 
636 enum
637 {
638  mpID_FIT = 2000,
646 #ifdef ENABLE_MP_CONFIG
647  mpID_CONFIG,
648 #endif // ENABLE_MP_CONFIG
652 };
653 
655 typedef enum __mp_Location_Type
656 {
667 } mpLocation;
668 
670 typedef enum __XAxis_Align_Type
671 {
677 } mpXAxis_Align;
678 
680 typedef enum __YAxis_Align_Type
681 {
687 } mpYAxis_Align;
688 
691 {
696 } mpPlot_Align;
697 
699 typedef enum __mp_Style_Type
700 {
704 } mpLegendStyle;
705 
708 {
712 
714 typedef enum __Symbol_Type
715 {
723 } mpSymbol;
724 
725 //-----------------------------------------------------------------------------
726 // mpLayer sub_type values
727 //-----------------------------------------------------------------------------
728 
730 typedef enum __Info_Type
731 {
736 } mpInfoType;
737 
739 typedef enum __Text_Type
740 {
744 } mpTextType;
745 
747 typedef enum __Function_Type
748 {
758 
760 typedef enum __Scale_Type
761 {
766 } mpScaleType;
767 
769 typedef enum __Chart_Type
770 {
775 } mpChartType;
776 
779 {
782 };
783 
786 {
806 };
807 
808 //-----------------------------------------------------------------------------
809 // mpLayer
810 //-----------------------------------------------------------------------------
811 
813 typedef enum __mp_Layer_Type
814 {
823 } mpLayerType;
824 
830 typedef enum __mp_Layer_ZOrder
831 {
840 } mpLayerZOrder;
841 
848 typedef enum __mp_Delete_Action
849 {
854 
865 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
866 {
867  public:
872  mpLayer(mpLayerType layerType);
873 
874  virtual ~mpLayer()
875  {
876  ;
877  }
878 
882  {
883  m_win = &w;
884  }
885 
893  virtual bool HasBBox()
894  {
895  return true;
896  }
897 
901  mpLayerType GetLayerType() const
902  {
903  return m_type;
904  }
905 
909  int GetLayerSubType() const
910  {
911  return m_subtype;
912  }
913 
919  virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
920  {
921  *subtype = m_subtype;
922  return (m_type == typeOfInterest);
923  }
924 
928  virtual double GetMinX()
929  {
930  return -1.0;
931  }
932 
936  virtual double GetMaxX()
937  {
938  return 1.0;
939  }
940 
944  virtual double GetMinY()
945  {
946  return -1.0;
947  }
948 
952  virtual double GetMaxY()
953  {
954  return 1.0;
955  }
956 
998  void Plot(wxDC &dc, mpWindow &w);
999 
1003  void SetName(const wxString &name)
1004  {
1005  m_name = name;
1006  }
1007 
1011  const wxString& GetName() const
1012  {
1013  return m_name;
1014  }
1015 
1019  void SetFont(const wxFont &font)
1020  {
1021  m_font = font;
1022  }
1023 
1027  const wxFont& GetFont() const
1028  {
1029  return m_font;
1030  }
1031 
1035  void SetFontColour(const wxColour &colour)
1036  {
1037  m_fontcolour = colour;
1038  }
1039 
1043  const wxColour& GetFontColour() const
1044  {
1045  return m_fontcolour;
1046  }
1047 
1051  void SetPen(const wxPen &pen)
1052  {
1053  m_pen = pen;
1054  }
1055 
1059  const wxPen& GetPen() const
1060  {
1061  return m_pen;
1062  }
1063 
1066  void SetBrush(const wxBrush &brush)
1067  {
1068  if (brush == wxNullBrush)
1069  m_brush = *wxTRANSPARENT_BRUSH;
1070  else
1071  m_brush = brush;
1072  }
1073 
1077  void SetBrush(const wxColour &colour, enum wxBrushStyle style = wxBRUSHSTYLE_SOLID)
1078  {
1079  m_brush.SetColour(colour);
1080  m_brush.SetStyle(style);
1081  }
1082 
1085  const wxBrush& GetBrush() const
1086  {
1087  return m_brush;
1088  }
1089 
1092  void SetShowName(bool show)
1093  {
1094  m_showName = show;
1095  }
1096 
1099  inline bool GetShowName() const
1100  {
1101  return m_showName;
1102  }
1103 
1106  void SetDrawOutsideMargins(bool drawModeOutside)
1107  {
1108  m_drawOutsideMargins = drawModeOutside;
1109  }
1110 
1114  {
1115  return m_drawOutsideMargins;
1116  }
1117 
1122  wxBitmap GetColourSquare(int side = 16);
1123 
1126  inline bool IsVisible() const
1127  {
1128  return m_visible;
1129  }
1130 
1133  virtual void SetVisible(bool show)
1134  {
1135  m_visible = show;
1136  }
1137 
1140  inline bool IsTractable() const
1141  {
1142  return m_tractable;
1143  }
1144 
1147  virtual void SetTractable(bool track)
1148  {
1149  m_tractable = track;
1150  }
1151 
1154  void SetAlign(int align)
1155  {
1156  m_flags = align;
1157  }
1158 
1161  int GetAlign() const
1162  {
1163  return m_flags;
1164  }
1165 
1168  void SetCanDelete(bool canDelete)
1169  {
1170  m_CanDelete = canDelete;
1171  }
1172 
1175  bool GetCanDelete(void) const
1176  {
1177  return m_CanDelete;
1178  }
1179 
1182  mpLayerZOrder GetZIndex(void) const
1183  {
1184  return m_ZIndex;
1185  }
1186 
1187  protected:
1188  const mpLayerType m_type;
1191  wxFont m_font;
1192  wxColour m_fontcolour;
1193  wxPen m_pen;
1194  wxBrush m_brush;
1195  wxString m_name;
1196  bool m_showName;
1198  bool m_visible;
1200  int m_flags;
1203  mpLayerZOrder m_ZIndex;
1204 
1207  void UpdateContext(wxDC &dc) const;
1208 
1213  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1214 
1219  virtual bool DoBeforePlot()
1220  {
1221  return true;
1222  }
1223 
1230  void CheckLog(double *x, double *y, int yAxisID);
1231 
1232  private:
1233  bool m_busy;
1234  mpLayer() = delete; // default ctor not implemented/permitted
1235 
1237 };
1238 
1239 //-----------------------------------------------------------------------------
1240 // mpInfoLayer
1241 //-----------------------------------------------------------------------------
1242 
1249 {
1250  public:
1252  mpInfoLayer();
1253 
1258  mpInfoLayer(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1259 
1261  virtual ~mpInfoLayer();
1262 
1265  virtual void SetVisible(bool show);
1266 
1271  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1272 
1275  virtual bool HasBBox()
1276  {
1277  return false;
1278  }
1279 
1282  [[deprecated("Use Show() instead")]]
1283  virtual void ErasePlot(wxDC&, mpWindow&) {};
1284 
1288  virtual bool Inside(const wxPoint &point);
1289 
1293  virtual void Move(wxPoint delta, mpWindow &w);
1294 
1296  virtual void UpdateReference();
1297 
1300  wxPoint GetPosition() const
1301  {
1302  return m_dim.GetPosition();
1303  }
1304 
1307  void SetInitialPosition(wxPoint pos)
1308  {
1309  m_relX = pos.x / 100.0;
1310  m_relY = pos.y / 100.0;
1311  }
1312 
1315  wxSize GetSize() const
1316  {
1317  return m_dim.GetSize();
1318  }
1319 
1322  const wxRect& GetRectangle() const
1323  {
1324  return m_dim;
1325  }
1326 
1329  void SetLocation(mpLocation location)
1330  {
1331  m_location = location;
1332  }
1333 
1336  mpLocation GetLocation() const
1337  {
1338  return m_location;
1339  }
1340 
1341  protected:
1342  wxRect m_dim;
1343  wxBitmap* m_info_bmp;
1344  wxPoint m_reference;
1345  double m_relX;
1346  double m_relY;
1347  mpLocation m_location;
1348 
1353  virtual void DoPlot(wxDC &dc, mpWindow &w);
1354 
1357  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1358 
1359  private:
1360  double clamp(double v, double min, double max);
1361 
1363 };
1364 
1370 {
1371  public:
1373  mpInfoCoords();
1374 
1376  mpInfoCoords(mpLocation location);
1377 
1382  mpInfoCoords(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1383 
1386  {
1387  ;
1388  }
1389 
1393  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1394 
1397  [[deprecated("Use Show() instead")]]
1398  virtual void ErasePlot(wxDC&, mpWindow&) {};
1399 
1402  void Show(bool show)
1403  {
1404  m_show = show;
1405  }
1406 
1409  bool IsShown()
1410  {
1411  return m_show;
1412  }
1413 
1418  bool ShouldBeShown(wxRect plotArea, wxPoint mousePos)
1419  {
1420  return IsVisible() && (GetDrawOutsideMargins() || plotArea.Contains(mousePos));
1421  }
1422 
1426  void SetLabelMode(mpLabelType mode, unsigned int time_conv = MP_X_RAWTIME)
1427  {
1428  m_labelType = mode;
1429  m_timeConv = time_conv;
1430  }
1431 
1434  void SetSeriesCoord(bool show)
1435  {
1436  m_series_coord = show;
1437  }
1438 
1441  bool IsSeriesCoord() const
1442  {
1443  return m_series_coord;
1444  }
1445 
1451  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1452 
1455  void SetPenSeries(const wxPen &pen)
1456  {
1457  m_penSeries = pen;
1458  }
1459 
1463  void DrawContent(wxDC &dc, mpWindow &w);
1464 
1465  protected:
1466  bool m_show;
1467  wxString m_content;
1469  unsigned int m_timeConv;
1470  wxCoord m_mouseX;
1471  wxCoord m_mouseY;
1473  wxPen m_penSeries;
1474 
1479  virtual void DoPlot(wxDC &dc, mpWindow &w);
1480 
1481  private:
1482  std::unordered_map<int, double> m_yValList;
1483 
1485 };
1486 
1492 {
1493  public:
1495  mpInfoLegend();
1496 
1502  mpInfoLegend(wxPoint pos, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginUser);
1503 
1506 
1509  void SetItemMode(mpLegendStyle mode)
1510  {
1511  m_item_mode = mode;
1512  m_needs_update = true;
1513  }
1514 
1516  mpLegendStyle GetItemMode() const
1517  {
1518  return m_item_mode;
1519  }
1520 
1523  void SetItemDirection(mpLegendDirection mode)
1524  {
1525  m_item_direction = mode;
1526  m_needs_update = true;
1527  }
1528 
1530  mpLegendDirection GetItemDirection() const
1531  {
1532  return m_item_direction;
1533  }
1534 
1537  {
1538  m_needs_update = true;
1539  }
1540 
1543  void ShowDraggedSeries(bool active)
1544  {
1545  m_showDraggedSeries = active;
1546  }
1547 
1551  {
1552  return m_showDraggedSeries;
1553  }
1554 
1560  int GetLegendHitRegion(wxPoint mousePos);
1561 
1568  void DrawDraggedSeries(wxDC& dc, mpWindow &w);
1569 
1573  void DrawContent(wxDC &dc, mpWindow &w);
1574 
1577  void RestoreAxisHighlighting(mpWindow &w);
1578 
1580  enum HitCode : int
1581  {
1582  HitNone = -1,
1583  HitHeader = -2
1584  };
1585 
1586  mpFunction* m_selectedSeries = nullptr;
1587  mpOptional_int m_lastHoveredAxisID = MP_OPTNULL_INT;
1588 
1589  protected:
1590  mpLegendStyle m_item_mode;
1591  mpLegendDirection m_item_direction;
1593  wxString m_headerString = wxString::FromUTF8("≡");
1594 
1599  virtual void DoPlot(wxDC &dc, mpWindow &w);
1600 
1601  private:
1603  struct LegendDetail
1604  {
1605  unsigned int layerIdx;
1606  wxCoord legendEnd;
1607  };
1609  std::vector<LegendDetail> m_LegendDetailList;
1610  wxCoord m_headerEnd;
1611  bool m_needs_update;
1612 
1622  void UpdateBitmap(wxDC &dc, mpWindow &w);
1623 
1624  private:
1626 };
1627 
1628 //-----------------------------------------------------------------------------
1629 // mpLayer implementations - functions
1630 //-----------------------------------------------------------------------------
1631 
1632 
1640 {
1641  public:
1647  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1648 
1652  void SetContinuity(bool continuity)
1653  {
1654  m_continuous = continuity;
1655  }
1656 
1660  bool GetContinuity() const
1661  {
1662  return m_continuous;
1663  }
1664 
1667  void SetStep(unsigned int step)
1668  {
1669  m_step = step;
1670  }
1671 
1674  unsigned int GetStep() const
1675  {
1676  return m_step;
1677  }
1678 
1681  void SetSymbol(mpSymbol symbol)
1682  {
1683  m_symbol = symbol;
1684  }
1685 
1688  mpSymbol GetSymbol() const
1689  {
1690  return m_symbol;
1691  }
1692 
1695  void SetSymbolSize(int size)
1696  {
1697  m_symbolSize = size;
1698  m_symbolSize2 = size / 2;
1699  }
1700 
1703  int GetSymbolSize() const
1704  {
1705  return m_symbolSize;
1706  }
1707 
1711  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1712 
1716  int GetYAxisID() const
1717  {
1718  return m_yAxisID;
1719  }
1720 
1725  void SetYAxisID(unsigned int yAxisID)
1726  {
1727  m_yAxisID = yAxisID;
1728  }
1729 
1733  void SetLegendIsAlwaysVisible(bool alwaysVisible)
1734  {
1735  m_LegendIsAlwaysVisible = alwaysVisible;
1736  }
1737 
1742  {
1743  return m_LegendIsAlwaysVisible;
1744  }
1745 
1746  protected:
1748  mpSymbol m_symbol;
1751  unsigned int m_step;
1754 
1755  private:
1757 };
1758 
1762 {
1763  public:
1770  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1771 
1772  // We don't want to include line (horizontal or vertical) in BBox computation
1773  virtual bool HasBBox() override
1774  {
1775  return false;
1776  }
1777 
1781  double GetValue() const
1782  {
1783  return m_value;
1784  }
1785 
1789  void SetValue(const double value)
1790  {
1791  m_value = value;
1792  }
1793 
1797  bool IsHorizontal(void) const
1798  {
1799  return m_IsHorizontal;
1800  }
1801 
1802  protected:
1803  double m_value;
1805 
1806  private:
1808 };
1809 
1813 {
1814  public:
1821  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1822 
1826  void SetYValue(const double yvalue)
1827  {
1828  SetValue(yvalue);
1829  }
1830 
1831  protected:
1832 
1833  virtual void DoPlot(wxDC &dc, mpWindow &w);
1834 
1835  private:
1837 };
1838 
1842 {
1843  public:
1849  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1850 
1854  void SetXValue(const double xvalue)
1855  {
1856  SetValue(xvalue);
1857  }
1858 
1859  protected:
1860 
1861  virtual void DoPlot(wxDC &dc, mpWindow &w);
1862 
1867  virtual bool DoBeforePlot()
1868  {
1869  return true;
1870  }
1871 
1872  private:
1874 };
1875 
1883 {
1884  public:
1889  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
1890 
1896  virtual double GetY(double x) = 0;
1897 
1904  double DoGetY(double x);
1905 
1910  void DefineDoGetY(void);
1911 
1912  protected:
1913 
1914  double (mpFX::*pDoGetY)(double x);
1915 
1920  virtual void DoPlot(wxDC &dc, mpWindow &w);
1921 
1926  double NormalDoGetY(double x);
1927 
1932  double LogDoGetY(double x);
1933 
1934  private:
1936 };
1937 
1945 {
1946  public:
1951  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
1952 
1958  virtual double GetX(double y) = 0;
1959 
1966  double DoGetX(double y);
1967 
1972  void DefineDoGetX(void);
1973 
1974  protected:
1975 
1976  double (mpFY::*pDoGetX)(double y);
1977 
1982  virtual void DoPlot(wxDC &dc, mpWindow &w);
1983 
1988  double NormalDoGetX(double y);
1989 
1994  double LogDoGetX(double y);
1995 
1996  private:
1998 };
1999 
2010 {
2011  public:
2017  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2018 
2022  virtual void Rewind() = 0;
2023 
2027  virtual void Clear()
2028  {
2029  ;
2030  }
2031 
2035  virtual int GetSize()
2036  {
2037  return 0;
2038  }
2039 
2046  virtual bool GetNextXY(double *x, double *y) = 0;
2047 
2054  bool DoGetNextXY(double *x, double *y);
2055 
2060  void SetViewMode(bool asBar);
2061 
2066  int GetBarWidth(void) const
2067  {
2068  return m_BarWidth;
2069  }
2070 
2075  bool ViewAsBar(void) const
2076  {
2077  return m_ViewAsBar;
2078  }
2079 
2080  protected:
2081 
2082  // Data to calculate label positioning
2085 
2086  // Min delta between 2 x coordinate (used for view as bar)
2087  double m_deltaX;
2088  double m_deltaY;
2089 
2091 
2092  bool m_ViewAsBar = false;
2093 
2100  virtual void DoPlot(wxDC &dc, mpWindow &w);
2101 
2106  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
2107 
2108  private:
2110 };
2111 
2112 //-----------------------------------------------------------------------------
2113 // mpFXYVector - provided by Jose Luis Blanco
2114 //-----------------------------------------------------------------------------
2115 
2136 {
2137  public:
2143  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2144 
2147  virtual ~mpFXYVector()
2148  {
2149  Clear();
2150  }
2151 
2156  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
2157 
2161  void Clear();
2162 
2167  virtual int GetSize()
2168  {
2169  return m_xs.size();
2170  }
2171 
2179  bool AddData(const double x, const double y, bool updatePlot);
2180 
2187  void SetReserve(int reserve)
2188  {
2189  m_reserveXY = reserve;
2190  m_xs.reserve(m_reserveXY);
2191  m_ys.reserve(m_reserveXY);
2192  }
2193 
2197  int GetReserve() const
2198  {
2199  return m_reserveXY;
2200  }
2201 
2202  protected:
2205  std::vector<double> m_xs;
2206  std::vector<double> m_ys;
2207 
2211 
2214  size_t m_index;
2215 
2217  double m_lastX;
2219  double m_lastY;
2220 
2224  inline void Rewind()
2225  {
2226  m_index = 0;
2227  }
2228 
2235  virtual bool GetNextXY(double *x, double *y);
2236 
2241  void DrawAddedPoint(double x, double y);
2242 
2245  virtual double GetMinX()
2246  {
2247  if (m_ViewAsBar)
2248  {
2249  // Make extra space for outer bars
2250  return m_rangeX.min - (m_deltaX / 2);
2251  }
2252  else
2253  {
2254  return m_rangeX.min;
2255  }
2256  }
2257 
2260  virtual double GetMinY()
2261  {
2262  return m_rangeY.min;
2263  }
2264 
2267  virtual double GetMaxX()
2268  {
2269  if(m_ViewAsBar)
2270  {
2271  // Make extra space for outer bars
2272  return m_rangeX.max + (m_deltaX / 2);
2273  }
2274  else
2275  {
2276  return m_rangeX.max;
2277  }
2278  }
2279 
2282  virtual double GetMaxY()
2283  {
2284  return m_rangeY.max;
2285  }
2286 
2287  private:
2290  void First_Point(double x, double y);
2291 
2294  void Check_Limit(double val, mpRange<double> *range, double *last, double *delta);
2295 
2297 };
2298 
2308 {
2309  public:
2313  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
2314 
2320  virtual double GetY(double x) = 0;
2321 
2322  protected:
2323 
2328  virtual void DoPlot(wxDC &dc, mpWindow &w);
2329 
2330  private:
2332 };
2333 
2338 class mpFXGeneric: public mpFX
2339 {
2340  public:
2345  mpFXGeneric(const wxString &name = wxT("Generic FX function"), int flags = mpALIGN_LEFT, unsigned int yAxisID = 0) :
2346  mpFX(name, flags, yAxisID)
2347  {
2348  wxPen FXpen(*wxBLUE, 1, wxPENSTYLE_SOLID);
2349  SetDrawOutsideMargins(false);
2350  SetContinuity(true);
2351  SetPen(FXpen);
2352  SetStep(8); // Draw one point over eight
2353  }
2354 
2359  virtual double GetY(double x)
2360  {
2361  double y;
2362  try
2363  {
2364  y = ComputeY(x);
2365  }
2366  catch (...)
2367  {
2368  y = 0;
2369  }
2370  m_rangeY.Update(y);
2371  return y;
2372  }
2373 
2378  virtual double GetMinY()
2379  {
2380  return m_rangeY.min;
2381  }
2382 
2387  virtual double GetMaxY()
2388  {
2389  return m_rangeY.max;
2390  }
2391 
2392  protected:
2394 
2400  virtual double ComputeY(double x) = 0;
2401 
2402  private:
2404 };
2405 
2411 {
2412  public:
2418  mpGaussian(double mu, double sigma) :
2419  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2420  {
2421  m_mu = mu;
2422  m_sigma = sigma;
2423  m_variance = sigma * sigma;
2424  m_const = 1.0 / sqrt(2.0 * M_PI * m_variance);
2425  }
2426 
2427  protected:
2428  double m_mu;
2429  double m_sigma;
2430  double m_variance;
2431  double m_const;
2432 
2433  virtual double ComputeY(double x)
2434  {
2435  return m_const * exp(-(x - m_mu) * (x - m_mu) / (2.0 * m_variance));
2436  }
2437 
2438  private:
2440 };
2441 
2446 class mpNormal: public mpFXGeneric
2447 {
2448  public:
2454  mpNormal(double mu, double sigma) :
2455  mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2456  {
2457  m_mu = mu;
2458  m_sigma = sigma;
2459  m_variance = sigma * sigma;
2460  m_const = 1.0 / (m_variance * sqrt(2.0 * M_PI));
2461  }
2462 
2463  protected:
2464  double m_mu;
2465  double m_sigma;
2466  double m_variance;
2467  double m_const;
2468 
2469  virtual double ComputeY(double x)
2470  {
2471  if (x < 0)
2472  return 0.0;
2473  else
2474  {
2475  double tmp = log(x) - m_mu;
2476  return m_const * exp(-tmp * tmp / (2.0 * m_variance)) / x;
2477  }
2478  }
2479 
2480  private:
2482 };
2483 
2484 //-----------------------------------------------------------------------------
2485 // mpChart
2486 //-----------------------------------------------------------------------------
2490 {
2491  public:
2493  mpChart(const wxString &name = wxEmptyString);
2494 
2497  {
2498  Clear();
2499  }
2500 
2503  void SetChartValues(const std::vector<double> &data);
2504 
2507  void SetChartLabels(const std::vector<std::string> &labelArray);
2508 
2513  void AddData(const double &data, const std::string &label);
2514 
2518  virtual void Clear();
2519 
2520  virtual bool HasBBox()
2521  {
2522  return (values.size() > 0);
2523  }
2524 
2525  protected:
2526  std::vector<double> values;
2527  std::vector<std::string> labels;
2528 
2529  double m_max_value;
2530  double m_total_value;
2531 
2532  private:
2534 };
2535 
2536 //-----------------------------------------------------------------------------
2537 // mpBarChart - provided by Jose Davide Rondini
2538 //-----------------------------------------------------------------------------
2539 /* Defines for bar charts label positioning. */
2540 #define mpBAR_NONE 0
2541 #define mpBAR_AXIS_H 1
2542 #define mpBAR_AXIS_V 2
2543 #define mpBAR_INSIDE 3
2544 #define mpBAR_TOP 4
2545 
2546 
2549 {
2550  public:
2552  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2553 
2556  {
2557  Clear();
2558  }
2559 
2561  void SetBarColour(const wxColour &colour);
2562 
2564  void SetColumnWidth(const double colWidth)
2565  {
2566  m_width = colWidth;
2567  }
2568 
2570  void SetBarLabelPosition(int position);
2571 
2575  virtual double GetMinX();
2576 
2580  virtual double GetMaxX();
2581 
2585  virtual double GetMinY();
2586 
2590  virtual double GetMaxY();
2591 
2592  protected:
2593 
2594  double m_width;
2595  wxColour m_barColour;
2597  double m_labelAngle;
2598 
2603  virtual void DoPlot(wxDC &dc, mpWindow &w);
2604 
2605  private:
2607 };
2608 
2613 {
2614  public:
2618  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2619 
2622  {
2623  Clear();
2624  colours.clear();
2625  }
2626 
2630  void SetCenter(const wxPoint center)
2631  {
2632  m_center = center;
2633  }
2634 
2638  wxPoint GetCenter(void) const
2639  {
2640  return m_center;
2641  }
2642 
2646  void SetPieColours(const std::vector<wxColour> &colourArray);
2647 
2651  virtual double GetMinX()
2652  {
2653  return m_center.x - m_radius;
2654  }
2655 
2659  virtual double GetMaxX()
2660  {
2661  return m_center.x + m_radius;
2662  }
2663 
2667  virtual double GetMinY()
2668  {
2669  return m_center.y - m_radius;
2670  }
2671 
2675  virtual double GetMaxY()
2676  {
2677  return m_center.y + m_radius;
2678  }
2679 
2680  protected:
2681 
2682  double m_radius;
2683  wxPoint m_center;
2684  std::vector<wxColour> colours;
2685 
2690  virtual void DoPlot(wxDC &dc, mpWindow &w);
2691 
2693  const wxColour& GetColour(unsigned int id);
2694 
2695  private:
2697 };
2698 
2701 //-----------------------------------------------------------------------------
2702 // mpLayer implementations - furniture (scales, ...)
2703 //-----------------------------------------------------------------------------
2712 {
2713  public:
2721  mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, mpOptional_uint axisID = MP_OPTNULL_INT);
2722 
2726  virtual bool HasBBox()
2727  {
2728  return false;
2729  }
2730 
2734  int GetAxisID(void)
2735  {
2736  return m_axisID;
2737  }
2738 
2743  void SetAxisID(unsigned int yAxisID)
2744  {
2745  m_axisID = yAxisID;
2746  }
2747 
2750  void ShowTicks(bool ticks)
2751  {
2752  m_ticks = ticks;
2753  }
2754 
2757  bool GetShowTicks() const
2758  {
2759  return m_ticks;
2760  }
2761 
2764  void ShowGrids(bool grids)
2765  {
2766  m_grids = grids;
2767  }
2768 
2771  bool GetShowGrids() const
2772  {
2773  return m_grids;
2774  }
2775 
2780  void SetLabelFormat(const wxString &format, bool updateLabelMode = false)
2781  {
2782  m_labelFormat = format;
2783  if (updateLabelMode)
2784  m_labelType = mpLabel_USER;
2785  }
2786 
2790  {
2791  return m_labelType;
2792  }
2793 
2797  void SetLabelMode(mpLabelType mode, unsigned int time_conv = MP_X_RAWTIME)
2798  {
2799  m_labelType = mode;
2800  m_timeConv = time_conv;
2801  }
2802 
2805  const wxString& GetLabelFormat() const
2806  {
2807  return m_labelFormat;
2808  }
2809 
2813  void SetGridPen(const wxPen &pen)
2814  {
2815  m_gridpen = pen;
2816  }
2817 
2821  const wxPen& GetGridPen() const
2822  {
2823  return m_gridpen;
2824  }
2825 
2829  void SetAuto(bool automaticScalingIsEnabled)
2830  {
2831  m_auto = automaticScalingIsEnabled;
2832  }
2833 
2837  bool GetAuto() const
2838  {
2839  return m_auto;
2840  }
2841 
2845  void SetMinScale(double min)
2846  {
2847  m_axisRange.SetMin(min);
2848  }
2849 
2853  double GetMinScale() const
2854  {
2855  return m_axisRange.min;
2856  }
2857 
2861  void SetMaxScale(double max)
2862  {
2863  m_axisRange.SetMax(max);
2864  }
2865 
2869  double GetMaxScale() const
2870  {
2871  return m_axisRange.max;
2872  }
2873 
2878  void SetScale(double min, double max)
2879  {
2880  m_axisRange.Set(min, max);
2881  }
2882 
2887  void GetScale(double *min, double *max) const
2888  {
2889  *min = m_axisRange.min;
2890  *max = m_axisRange.max;
2891  }
2892 
2897  {
2898  m_axisRange = range;
2899  }
2900 
2905  {
2906  return mpRange<double>(m_axisRange);
2907  }
2908 
2912  void SetHovering(bool hover)
2913  {
2914  m_hover = hover;
2915  }
2916 
2920  virtual bool IsLogAxis()
2921  {
2922  return m_isLog;
2923  }
2924 
2928  virtual void SetLogAxis(bool log)
2929  {
2930  m_isLog = log;
2931  }
2932 
2936  void SetCoordIsAlwaysVisible(bool alwaysVisible)
2937  {
2938  m_CoordIsAlwaysVisible = alwaysVisible;
2939  }
2940 
2945  {
2946  return m_CoordIsAlwaysVisible;
2947  }
2948 
2949  protected:
2950  static const wxCoord kTickSize = 4;
2951  static const wxCoord kAxisExtraSpace = 6;
2952 
2953  int m_axisID;
2954  wxPen m_gridpen;
2955  bool m_ticks;
2956  bool m_grids;
2957  bool m_auto;
2960  unsigned int m_timeConv;
2961  wxString m_labelFormat;
2962  bool m_isLog;
2963  bool m_hover = false;
2965 
2968  virtual int GetOrigin(mpWindow &w) = 0;
2969 
2976  double GetStep(double scale, int minLabelSpacing);
2977 
2985  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
2986 
2992  wxString FormatLabelValue(double value);
2993 
2998  wxString FormatLogValue(double n);
2999 
3006  int GetLabelWidth(double value, wxDC &dc);
3007 
3012  bool UseScientific(double maxAxisValue);
3013 
3019  int GetSignificantDigits(double step, double maxAxisValue);
3020 
3025  int GetDecimalDigits(double step);
3026 
3030  struct {
3031  double step;
3032  double maxAxisValue;
3033  bool UseScientific;
3034  int SignificantDigits;
3035  int DecimalDigits;
3036  double EpsilonScale;
3037  } m_ScaleConstraints;
3038 
3042  void ComputeScaleConstraints(double step, double maxAxisValue);
3043 
3044  private:
3046 };
3047 
3048 
3055 {
3056  public:
3062  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, mpLabelType type = mpLabel_AUTO) :
3063  mpScale(name, flags, grids, type)
3064  {
3065  m_subtype = mpsScaleX;
3066  }
3067 
3069  bool IsTopAxis()
3070  {
3071  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
3072  }
3073 
3076  {
3077  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
3078  }
3079 
3080  protected:
3085  static int m_orgy;
3086 
3089  virtual void DoPlot(wxDC &dc, mpWindow &w);
3090 
3091  virtual int GetOrigin(mpWindow &w);
3092  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
3093 
3094  private:
3096 
3100  friend mpScaleY;
3101 };
3102 
3110 {
3111  public:
3119  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, mpOptional_uint yAxisID = MP_OPTNULL_INT, mpLabelType labelType = mpLabel_AUTO) :
3120  mpScale(name, flags, grids, labelType, yAxisID)
3121  {
3122  m_subtype = mpsScaleY;
3123  m_axisWidth = MP_Y_BORDER_SEPARATION;
3124  m_xPos = 0;
3125  }
3126 
3129  void UpdateAxisWidth(mpWindow &w);
3130 
3133  {
3134  return m_axisWidth;
3135  }
3136 
3138  bool IsLeftAxis()
3139  {
3140  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
3141  }
3142 
3145  {
3146  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
3147  }
3148 
3150  bool IsInside(wxCoord xPixel)
3151  {
3152  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
3153  {
3154  return true;
3155  }
3156  return false;
3157  }
3158 
3159  protected:
3161  int m_xPos;
3162 
3165  virtual void DoPlot(wxDC &dc, mpWindow &w);
3166 
3167  virtual int GetOrigin(mpWindow &w);
3168  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
3169 
3170  private:
3172 };
3173 
3174 //-----------------------------------------------------------------------------
3175 // mpWindow
3176 //-----------------------------------------------------------------------------
3177 
3183 #define mpMOUSEMODE_DRAG 0
3184 
3185 #define mpMOUSEMODE_ZOOMBOX 1
3186 
3189 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
3190 typedef std::deque<mpLayer*> mpLayerList;
3191 
3202 {
3203  mpScale* axis = nullptr;
3204  double scale = 1.0;
3205  double pos = 0;
3209 
3210  // Note: we don't use the default operator since we don't want to compare axis pointers
3212  bool operator==(const mpAxisData& other) const
3213  {
3214  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
3215  (bound == other.bound) && (desired == other.desired);
3216  }
3217 };
3218 
3220 typedef std::map<int, mpAxisData> mpAxisList;
3221 
3228 typedef enum {
3229  uXAxis = 1,
3230  uYAxis = 2,
3231  uXYAxis = 3
3232 } mpAxisUpdate;
3233 
3243 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
3244 
3251 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
3252 
3258 {
3259  public:
3260  mpMagnet()
3261  {
3262  m_enable = false;
3263  m_show = false;
3264  }
3265  ~mpMagnet()
3266  {
3267  ;
3268  }
3269 
3271  void UpdateBox(const wxRect &plotArea)
3272  {
3273  m_domain = plotArea;
3274  }
3275 
3277  void Enable(bool enable)
3278  {
3279  m_enable = enable;
3280  }
3281 
3283  bool IsEnabled() const
3284  {
3285  return m_enable;
3286  }
3287 
3289  void DrawCross(wxDC &dc, mpWindow &w);
3290 
3292  bool ShouldBeShown(wxPoint mousePos)
3293  {
3294  return m_enable && m_domain.Contains(mousePos);
3295  }
3296 
3298  void Show(bool show)
3299  {
3300  m_show = show;
3301  }
3302 
3304  bool IsShown()
3305  {
3306  return m_show;
3307  }
3308 
3309  private:
3310  bool m_enable;
3311  bool m_show;
3312  wxRect m_domain;
3313 };
3314 
3336 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
3337 {
3338  public:
3339  mpWindow()
3340  {
3341  InitParameters();
3342  }
3343 
3351  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
3352  long flags = 0);
3353 
3354  ~mpWindow();
3355 
3359  wxMenu* GetPopupMenu()
3360  {
3361  return &m_popmenu;
3362  }
3363 
3372  bool AddLayer(mpLayer *layer, bool refreshDisplay = true, bool refreshConfig = true);
3373 
3386  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
3387 
3393  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
3394 
3401  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
3402 
3409  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
3410 
3416  mpLayer* GetLayer(int position);
3417 
3422  int GetLayerPosition(mpLayer* layer);
3423 
3430  mpLayer* GetLayersType(int position, mpLayerType type);
3431 
3438  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
3439 
3445  mpScale* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
3446 
3455  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
3456 
3465  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
3466 
3471  mpLayer* GetLayerByName(const wxString &name);
3472 
3477  mpLayer* GetLayerByClassName(const wxString &name);
3478 
3482  void RefreshLegend(void);
3483 
3488  bool IsYAxisUsed(int yAxisID);
3489 
3495  bool IsYAxisUsedByFunction(int yAxisID, int *position);
3496 
3500  mpScaleX* GetLayerXAxis();
3501 
3505  mpScaleY* GetLayerYAxis(int yAxisID);
3506 
3510  void SetScaleX(const double scaleX)
3511  {
3512  if (ISNOTNULL(scaleX))
3513  {
3514  m_AxisDataX.scale = scaleX;
3515  UpdateDesiredBoundingBox(uXAxis);
3516  }
3517  UpdateAll();
3518  }
3519 
3524  double GetScaleX(void) const
3525  {
3526  return m_AxisDataX.scale;
3527  }
3528 
3533  void SetScaleY(const double scaleY, int yAxisID)
3534  {
3535  assert(m_AxisDataYList.count(yAxisID) != 0);
3536  if (ISNOTNULL(scaleY))
3537  {
3538  m_AxisDataYList[yAxisID].scale = scaleY;
3539  UpdateDesiredBoundingBox(uYAxis);
3540  }
3541  UpdateAll();
3542  }
3543 
3549  double GetScaleY(int yAxisID)
3550  {
3551  assert(m_AxisDataYList.count(yAxisID) != 0);
3552  return m_AxisDataYList[yAxisID].scale;
3553  } // Schaling's method: maybe another method exists with the same name
3554 
3555  [[deprecated("Incomplete, use UpdateBBox instead")]]
3558  void SetBound();
3559 
3562  {
3563  return m_AxisDataX.bound;
3564  }
3565 
3568  {
3569  return m_AxisDataX.desired;
3570  }
3571 
3576  {
3577  assert(m_AxisDataYList.count(yAxisID) != 0);
3578  return m_AxisDataYList[yAxisID].bound;
3579  }
3580 
3585  {
3586  assert(m_AxisDataYList.count(yAxisID) != 0);
3587  return m_AxisDataYList[yAxisID].desired;
3588  }
3589 
3594  std::unordered_map<int, mpRange<double>> GetAllBoundY()
3595  {
3596  std::unordered_map<int, mpRange<double>> yRange;
3597  for (const MP_LOOP_ITER : m_AxisDataYList)
3598  {
3599  yRange[m_yID] = m_yData.bound;
3600  }
3601  return yRange;
3602  }
3603 
3608  std::unordered_map<int, mpRange<double>> GetAllDesiredY()
3609  {
3610  std::unordered_map<int, mpRange<double>> yRange;
3611  for (const MP_LOOP_ITER : m_AxisDataYList)
3612  {
3613  yRange[m_yID] = m_yData.desired;
3614  }
3615  return yRange;
3616  }
3617 
3621  void SetPosX(const double posX)
3622  {
3623  m_AxisDataX.pos = posX;
3624  UpdateDesiredBoundingBox(uXAxis);
3625  UpdateAll();
3626  }
3627 
3632  double GetPosX(void) const
3633  {
3634  return m_AxisDataX.pos;
3635  }
3636 
3641  void SetPosY(std::unordered_map<int, double>& posYList)
3642  {
3643  for (MP_LOOP_ITER : m_AxisDataYList)
3644  {
3645  m_yData.pos = posYList[m_yID];
3646  }
3647  UpdateDesiredBoundingBox(uYAxis);
3648  UpdateAll();
3649  }
3650 
3656  double GetPosY(int yAxisID)
3657  {
3658  assert(m_AxisDataYList.count(yAxisID) != 0);
3659  return m_AxisDataYList[yAxisID].pos;
3660  }
3661 
3665  int GetNOfYAxis(void) const
3666  {
3667  return (int)m_AxisDataYList.size();
3668  }
3669 
3673  mpAxisList GetAxisDataYList(void) const
3674  {
3675  return m_AxisDataYList;
3676  }
3677 
3683  void SetScreen(const int scrX, const int scrY)
3684  {
3685  m_scrX = scrX;
3686  m_scrY = scrY;
3687  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3688  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3689 
3690  m_plotBoundaries.endPx = m_scrX;
3691  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3692  m_plotBoundaries.endPy = m_scrY;
3693  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3694 
3695  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3696  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3697 
3698  m_magnet.UpdateBox(m_PlotArea);
3699  }
3700 
3707  int GetScreenX(void) const
3708  {
3709  return m_scrX;
3710  }
3711 
3718  int GetScreenY(void) const
3719  {
3720  return m_scrY;
3721  }
3722 
3728  void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3729  {
3730  m_AxisDataX.pos = posX;
3731  SetPosY(posYList);
3732  }
3733 
3737  inline double p2x(const wxCoord pixelCoordX) const
3738  {
3739  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3740  }
3741 
3745  inline double p2y(const wxCoord pixelCoordY, int yAxisID = 0)
3746  {
3747  assert(m_AxisDataYList.count(yAxisID) != 0);
3748  if (m_AxisDataYList.count(yAxisID) == 0)
3749  return 0.0;
3750  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3751  }
3752 
3756  inline wxCoord x2p(const double x) const
3757  {
3758  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3759  }
3760 
3764  inline wxCoord y2p(const double y, int yAxisID = 0)
3765  {
3766  assert(m_AxisDataYList.count(yAxisID) != 0);
3767  if (m_AxisDataYList.count(yAxisID) == 0)
3768  return 0;
3769  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3770  }
3771 
3774  void EnableDoubleBuffer(const bool enabled)
3775  {
3776  m_enableDoubleBuffer = enabled;
3777  }
3778 
3781  void EnableMousePanZoom(const bool enabled)
3782  {
3783  m_enableMouseNavigation = enabled;
3784  }
3785 
3791  void LockAspect(bool enable = true);
3792 
3797  inline bool IsAspectLocked() const
3798  {
3799  return m_lockaspect;
3800  }
3801 
3806  void Fit();
3807 
3814  void Fit(const mpRange<double> &rangeX, std::unordered_map<int, mpRange<double>> rangeY, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3815 
3819  void FitX(void);
3820 
3825  void FitY(int yAxisID);
3826 
3831  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
3832 
3837  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
3838 
3840  void ZoomInX();
3841 
3843  void ZoomOutX();
3844 
3847  void ZoomInY(mpOptional_int yAxisID = MP_OPTNULL_INT);
3848 
3851  void ZoomOutY(mpOptional_int yAxisID = MP_OPTNULL_INT);
3852 
3857  void ZoomRect(wxPoint p0, wxPoint p1);
3858 
3860  void UpdateAll();
3861 
3862  // Added methods by Davide Rondini
3863 
3867  unsigned int CountLayers();
3868 
3871  unsigned int CountAllLayers()
3872  {
3873  return (unsigned int)m_layers.size();
3874  }
3875 
3879  unsigned int CountLayersType(mpLayerType type);
3880 
3884  unsigned int CountLayersFXYPlot();
3885 
3893  {
3894  // Change on X axis
3895  if (update & uXAxis)
3896  {
3897  m_AxisDataX.desired.Set(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale),
3898  m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3899  }
3900 
3901  // Change on Y axis
3902  if (update & uYAxis)
3903  {
3904  for (MP_LOOP_ITER : m_AxisDataYList)
3905  {
3906  m_yData.desired.Set(m_yData.pos - ((m_margin.top + m_plotHeight) / m_yData.scale),
3907  m_yData.pos - (m_margin.top / m_yData.scale));
3908  }
3909  }
3910  }
3911 
3917  mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID = 0)
3918  {
3919  assert(m_AxisDataYList.count(yAxisID) != 0);
3920  if (desired)
3921  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
3922  else
3923  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
3924  }
3925 
3929  double GetDesiredXmin() const
3930  {
3931  return m_AxisDataX.desired.min;
3932  }
3933 
3938  double GetDesiredXmax() const
3939  {
3940  return m_AxisDataX.desired.max;
3941  }
3942 
3948  double GetDesiredYmin(int yAxisID)
3949  {
3950  assert(m_AxisDataYList.count(yAxisID) != 0);
3951  return m_AxisDataYList[yAxisID].desired.min;
3952  }
3953 
3959  double GetDesiredYmax(int yAxisID)
3960  {
3961  assert(m_AxisDataYList.count(yAxisID) != 0);
3962  return m_AxisDataYList[yAxisID].desired.max;
3963  }
3964 
3970  bool GetBoundingBox(mpRange<double> *boundX, mpRange<double> *boundY, int yAxisID)
3971  {
3972  if (m_AxisDataYList.count(yAxisID) == 0)
3973  return false;
3974  *boundX = m_AxisDataX.bound;
3975  *boundY = m_AxisDataYList[yAxisID].bound;
3976  return true;
3977  }
3978 
3984  bool PointIsInsideBound(double px, double py, int yAxisID)
3985  {
3986  if (m_AxisDataYList.count(yAxisID) == 0)
3987  return false;
3988 
3989  return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
3990  }
3991 
3997  void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
3998  {
3999  if (m_AxisDataYList.count(yAxisID) == 0)
4000  return ;
4001 
4002  m_AxisDataX.bound.Update(px);
4003  m_AxisDataYList[yAxisID].bound.Update(py);
4004  }
4005 
4006  /* Initialize bounding box with an initial point
4007  * @param px point on x-axis
4008  * @param py point on y-axis
4009  * @param yAxisID the y-axis ID
4010  */
4012  void InitializeBoundingBox(double px, double py, int yAxisID)
4013  {
4014  if (m_AxisDataYList.count(yAxisID) == 0)
4015  return ;
4016 
4017  m_AxisDataX.bound.Set(px, px);
4018  m_AxisDataYList[yAxisID].bound.Set(py, py);
4019  }
4020 
4023  void SetMPScrollbars(bool status);
4024 
4027  bool GetMPScrollbars() const
4028  {
4029  return m_enableScrollBars;
4030  }
4031 
4037  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
4038 
4042  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4043 
4047  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4048 
4052  void SetWildcard(const wxString &wildcard)
4053  {
4054  m_wildcard = wildcard;
4055  }
4056 
4060  const wxString& GetWildcard(void) const
4061  {
4062  return m_wildcard;
4063  }
4064 
4072  bool LoadFile(const wxString &filename = wxEmptyString);
4073 
4078  void SetDefaultDir(const wxString &dirname)
4079  {
4080  m_DefaultDir = dirname;
4081  }
4082 
4086 
4091 
4098  {
4099  m_DefaultLegendIsAlwaysVisible = visible;
4100  }
4101 
4106 
4107 
4112  void SetAutoFit(bool autoFit)
4113  {
4114  m_autoFit = autoFit;
4115  }
4116 
4123  void SetMargins(int top, int right, int bottom, int left);
4124 
4127  {
4128  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4129  }
4130 
4132  void SetMarginTop(int top)
4133  {
4134  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4135  }
4136 
4140  int GetMarginTop(bool minusExtra = false) const
4141  {
4142  if (minusExtra)
4143  return m_margin.top - m_extraMargin;
4144  else
4145  return m_margin.top;
4146  }
4147 
4149  void SetMarginRight(int right)
4150  {
4151  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
4152  }
4153 
4157  int GetMarginRight(bool minusExtra = false) const
4158  {
4159  if (minusExtra)
4160  return m_margin.right - m_extraMargin;
4161  else
4162  return m_margin.right;
4163  }
4164 
4167  {
4168  return m_marginOuter.right;
4169  }
4170 
4172  void SetMarginBottom(int bottom)
4173  {
4174  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
4175  }
4176 
4180  int GetMarginBottom(bool minusExtra = false) const
4181  {
4182  if (minusExtra)
4183  return m_margin.bottom - m_extraMargin;
4184  else
4185  return m_margin.bottom;
4186  }
4187 
4189  void SetMarginLeft(int left)
4190  {
4191  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
4192  }
4193 
4197  int GetMarginLeft(bool minusExtra = false) const
4198  {
4199  if (minusExtra)
4200  return m_margin.left - m_extraMargin;
4201  else
4202  return m_margin.left;
4203  }
4204 
4206  void SetExtraMargin(int extra)
4207  {
4208  m_extraMargin = extra;
4209  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4210  }
4211 
4213  int GetExtraMargin() const
4214  {
4215  return m_extraMargin;
4216  }
4217 
4220  {
4221  return m_marginOuter.left;
4222  }
4223 
4225  int GetPlotWidth() const
4226  {
4227  return m_plotWidth;
4228  }
4229 
4231  int GetPlotHeight() const
4232  {
4233  return m_plotHeight;
4234  }
4235 
4240  mpRect GetPlotBoundaries(bool with_margin) const
4241  {
4242  mpRect bond;
4243  if (with_margin)
4244  bond = m_plotBoundariesMargin;
4245  else
4246  bond = m_plotBoundaries;
4247  bond.startPx -= m_extraMargin;
4248  bond.endPx += m_extraMargin;
4249  bond.startPy -= m_extraMargin;
4250  bond.endPy += m_extraMargin;
4251  return bond;
4252  }
4253 
4257  int GetLeftYAxesWidth(mpOptional_int yAxisID = MP_OPTNULL_INT);
4258 
4262  int GetRightYAxesWidth(mpOptional_int yAxisID = MP_OPTNULL_INT);
4263 
4265  void SetDrawBox(bool drawbox)
4266  {
4267  m_drawBox = drawbox;
4268  }
4269 
4271  bool GetDrawBox() const
4272  {
4273  return m_drawBox;
4274  }
4275 
4279  mpOptional_int IsInsideYAxis(const wxPoint &point);
4280 
4284  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
4285 
4289  void SetLayerVisible(const wxString &name, bool viewable);
4290 
4294  bool IsLayerVisible(const wxString &name);
4295 
4299  bool IsLayerVisible(const unsigned int position);
4300 
4304  void SetLayerVisible(const unsigned int position, bool viewable);
4305 
4310  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
4311 
4314  const wxColour& GetAxesColour() const
4315  {
4316  return m_axColour;
4317  }
4318 
4320  const wxColour& GetbgColour() const
4321  {
4322  return m_bgColour;
4323  }
4324 
4326  void SetbgColour(const wxColour &colour)
4327  {
4328  m_bgColour = colour;
4329  }
4330 
4336  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
4337  {
4338  m_OnDeleteLayer = event;
4339  }
4340 
4343  {
4344  m_OnDeleteLayer = NULL;
4345  }
4346 
4351  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
4352  {
4353  m_OnUserMouseAction = userMouseEventHandler;
4354  }
4355 
4358  {
4359  m_OnUserMouseAction = NULL;
4360  }
4361 
4367  bool IsLogXaxis()
4368  {
4369  if (m_AxisDataX.axis)
4370  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
4371  else
4372  return false;
4373  }
4374 
4379  bool IsLogYaxis(int yAxisID)
4380  {
4381  assert(m_AxisDataYList.count(yAxisID) != 0);
4382  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4383  if (yAxis)
4384  return yAxis->IsLogAxis();
4385  else
4386  return false;
4387  }
4388 
4393  void SetLogXaxis(bool log)
4394  {
4395  if (m_AxisDataX.axis)
4396  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
4397  }
4398 
4404  void SetLogYaxis(int yAxisID, bool log)
4405  {
4406  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4407  if (yAxis)
4408  yAxis->SetLogAxis(log);
4409  }
4410 
4415  bool GetMagnetize() const
4416  {
4417  return m_magnet.IsEnabled();
4418  }
4419 
4421  void SetMagnetize(bool mag)
4422  {
4423  m_magnet.Enable(mag);
4424  }
4425 
4431  {
4432  m_mouseLeftDownAction = action;
4433  }
4434 
4440  {
4441  return m_mouseLeftDownAction;
4442  }
4443 
4449  {
4450  return m_mousePos;
4451  }
4452 
4458  {
4459  return m_movingInfoLayer;
4460  }
4461 
4462 #ifdef ENABLE_MP_CONFIG
4463 
4467  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
4468 #endif // ENABLE_MP_CONFIG
4469 
4476  void RefreshConfigWindow(mpLayerType layerType, int param = 0, bool show = false);
4477 
4481  void OpenConfigWindow();
4482 
4486  void DeleteConfigWindow(void);
4487 
4492  void RenderOverlays(wxDC& dc);
4493 
4494  protected:
4495  virtual void BindEvents(void);
4496  virtual void OnPaint(wxPaintEvent &event);
4497  virtual void OnSize(wxSizeEvent &event);
4498  virtual void OnShowPopupMenu(wxMouseEvent &event);
4499  virtual void OnCenter(wxCommandEvent &event);
4500  virtual void OnFit(wxCommandEvent &event);
4501  virtual void OnToggleGrids(wxCommandEvent &event);
4502  virtual void OnToggleCoords(wxCommandEvent &event);
4503  virtual void OnScreenShot(wxCommandEvent &event);
4504  virtual void OnFullScreen(wxCommandEvent &event);
4505 #ifdef ENABLE_MP_CONFIG
4506  virtual void OnConfiguration(wxCommandEvent &event);
4507 #endif // ENABLE_MP_CONFIG
4508  virtual void OnLoadFile(wxCommandEvent &event);
4509  virtual void OnZoomIn(wxCommandEvent &event);
4510  virtual void OnZoomOut(wxCommandEvent &event);
4511  virtual void OnLockAspect(wxCommandEvent &event);
4512  virtual void OnMouseHelp(wxCommandEvent &event);
4513  virtual void OnMouseLeftDown(wxMouseEvent &event);
4514  virtual void OnMouseRightDown(wxMouseEvent &event);
4515  virtual void OnMouseMove(wxMouseEvent &event);
4516  virtual void OnMouseLeftRelease(wxMouseEvent &event);
4517  virtual void OnMouseWheel(wxMouseEvent &event);
4518  virtual void OnMouseLeave(wxMouseEvent &event);
4519  bool CheckUserMouseAction(wxMouseEvent &event);
4520  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
4521  virtual void OnScrollPageUp(wxScrollWinEvent &event);
4522  virtual void OnScrollPageDown(wxScrollWinEvent &event);
4523  virtual void OnScrollLineUp(wxScrollWinEvent &event);
4524  virtual void OnScrollLineDown(wxScrollWinEvent &event);
4525  virtual void OnScrollTop(wxScrollWinEvent &event);
4526  virtual void OnScrollBottom(wxScrollWinEvent &event);
4527 
4529  void DoScrollCalc(const int position, const int orientation);
4530 
4535  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = MP_ZOOM_AROUND_CENTER);
4536 
4543  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = MP_ZOOM_AROUND_CENTER, mpOptional_int yAxisID = MP_OPTNULL_INT);
4544 
4549  void SetScaleXAndCenter(double scaleX);
4550 
4556  void SetScaleYAndCenter(double scaleY, int yAxisID);
4557 
4562  void Zoom(bool zoomIn, const wxPoint &centerPoint);
4563 
4566  virtual bool UpdateBBox();
4567 
4571  void DrawBoxZoom(wxDC& dc);
4572 
4576  void InitParameters();
4577 
4578  wxTopLevelWindow* m_parent;
4580 
4581  mpLayerList m_layers;
4583  mpAxisList m_AxisDataYList;
4584 
4585  wxMenu m_popmenu;
4587  wxColour m_bgColour;
4588  wxColour m_fgColour;
4589  wxColour m_axColour;
4590  bool m_drawBox;
4591 
4592  int m_scrX;
4593  int m_scrY;
4596 
4600  wxCoord m_plotWidth;
4601  wxCoord m_plotHeight;
4602 
4605  wxRect m_PlotArea;
4606 
4609  wxBitmap* m_buff_bmp;
4615  wxPoint m_mousePos;
4616  wxPoint m_mouseRClick;
4617  wxPoint m_mouseLClick;
4618  double m_mouseScaleX;
4619  std::unordered_map<int, double> m_mouseScaleYList;
4622  bool m_autoFit;
4626 
4628 
4630 
4631  wxBitmap* m_Screenshot_bmp;
4632 
4633  wxString m_wildcard;
4634  wxString m_DefaultDir;
4635 
4636 #ifdef ENABLE_MP_CONFIG
4637  MathPlotConfigDialog* m_configWindow = NULL;
4638 #endif // ENABLE_MP_CONFIG
4639  bool m_openConfigWindowPending = false;
4641 
4642  mpOnDeleteLayer m_OnDeleteLayer = NULL;
4643  mpOnUserMouseAction m_OnUserMouseAction = NULL;
4644 
4648  virtual void DesiredBoundsHaveChanged() {};
4649 
4650  private:
4652  void CheckAndReportDesiredBoundsChanges();
4653 
4658  unsigned int GetNewAxisDataID(void)
4659  {
4660  int newID = 0;
4661  for (const MP_LOOP_ITER : m_AxisDataYList)
4662  {
4663  if(m_yData.axis)
4664  {
4665  // This ID is used by an axis. Make sure the new ID is larger
4666  newID = std::max(newID, m_yID + 1);
4667  }
4668  }
4669  return newID;
4670  }
4671 
4673 
4674  // To have direct access to m_Screenshot_dc
4675  friend mpPrintout;
4676 };
4677 
4678 //-----------------------------------------------------------------------------
4679 // mpText - provided by Val Greene
4680 //-----------------------------------------------------------------------------
4681 
4690 {
4691  public:
4694  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
4695  {
4696  m_subtype = mptText;
4697  SetName(name);
4698  m_offsetx = 5;
4699  m_offsety = 50;
4700  m_location = mpMarginUser;
4701  m_ZIndex = mpZIndex_TEXT;
4702  }
4703 
4707  mpText(const wxString &name, int offsetx, int offsety);
4708 
4712  mpText(const wxString &name, mpLocation marginLocation);
4713 
4716  virtual bool HasBBox()
4717  {
4718  return false;
4719  }
4720 
4723  void SetLocation(mpLocation location)
4724  {
4725  m_location = location;
4726  }
4727 
4730  mpLocation GetLocation() const
4731  {
4732  return m_location;
4733  }
4734 
4737  void SetOffset(int offX, int offY)
4738  {
4739  m_offsetx = offX;
4740  m_offsety = offY;
4741  }
4742 
4744  void GetOffset(int *offX, int *offY) const
4745  {
4746  *offX = m_offsetx;
4747  *offY = m_offsety;
4748  }
4749 
4750  protected:
4753  mpLocation m_location;
4754 
4757  virtual void DoPlot(wxDC &dc, mpWindow &w);
4758 
4759  private:
4761 };
4762 
4767 {
4768  public:
4771  mpTitle();
4772 
4775  mpTitle(const wxString &name) :
4776  mpText(name, mpMarginTopCenter)
4777  {
4778  m_subtype = mptTitle;
4779  SetPen(*wxWHITE_PEN);
4780  SetBrush(*wxWHITE_BRUSH);
4781  }
4782 
4783  private:
4785 };
4786 
4787 //-----------------------------------------------------------------------------
4788 // mpPrintout - provided by Davide Rondini
4789 //-----------------------------------------------------------------------------
4790 
4795 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4796 {
4797  public:
4798  mpPrintout()
4799  {
4800  plotWindow = NULL;
4801  drawn = false;
4802  stretch_factor = 2;
4803  }
4804 
4810  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4811  virtual ~mpPrintout()
4812  {
4813  ;
4814  }
4815 
4819  void SetDrawState(bool drawState)
4820  {
4821  drawn = drawState;
4822  }
4823 
4825  bool OnPrintPage(int page);
4827  bool HasPage(int page);
4828 
4831  void SetFactor(int factor)
4832  {
4833  stretch_factor = factor;
4834  }
4835 
4836  private:
4837  bool drawn;
4838  mpWindow* plotWindow;
4839  int stretch_factor; // To reduce the size of plot
4840 
4842 };
4843 
4844 //-----------------------------------------------------------------------------
4845 // mpMovableObject - provided by Jose Luis Blanco
4846 //-----------------------------------------------------------------------------
4855 {
4856  public:
4860  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
4861  {
4862  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
4863  m_subtype = mpfMovable;
4864  }
4865 
4866  virtual ~mpMovableObject() {}
4867 
4870  void GetCoordinateBase(double &x, double &y, double &phi) const
4871  {
4872  x = m_reference_x;
4873  y = m_reference_y;
4874  phi = m_reference_phi;
4875  }
4876 
4879  void SetCoordinateBase(double x, double y, double phi = 0)
4880  {
4881  m_reference_x = x;
4882  m_reference_y = y;
4883  m_reference_phi = phi;
4884  m_flags = mpALIGN_SW;
4885  ShapeUpdated();
4886  }
4887 
4888  virtual bool HasBBox()
4889  {
4890  return m_trans_shape_xs.size() != 0;
4891  }
4892 
4895  virtual double GetMinX()
4896  {
4897  return m_bbox_x.min;
4898  }
4899 
4902  virtual double GetMaxX()
4903  {
4904  return m_bbox_x.max;
4905  }
4906 
4909  virtual double GetMinY()
4910  {
4911  return m_bbox_y.min;
4912  }
4913 
4916  virtual double GetMaxY()
4917  {
4918  return m_bbox_y.max;
4919  }
4920 
4921  protected:
4922 
4925  double m_reference_x;
4926  double m_reference_y;
4928 
4929  virtual void DoPlot(wxDC &dc, mpWindow &w);
4930 
4933  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
4934 
4935  // the object points, in local coordinates (to be transformed by the current transformation).
4936  std::vector<double> m_shape_xs;
4937  std::vector<double> m_shape_ys;
4938 
4939  // The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh).
4940  std::vector<double> m_trans_shape_xs;
4941  std::vector<double> m_trans_shape_ys;
4942 
4948 
4952  void ShapeUpdated();
4953 
4954  private:
4956 };
4957 
4958 //-----------------------------------------------------------------------------
4959 // mpCovarianceEllipse - provided by Jose Luis Blanco
4960 //-----------------------------------------------------------------------------
4973 {
4974  public:
4978  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
4979  const wxString &layerName = _T("")) : mpMovableObject(),
4980  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
4981  {
4982  m_continuous = true;
4983  m_name = layerName;
4984  RecalculateShape();
4985  }
4986 
4987  virtual ~mpCovarianceEllipse()
4988  {
4989  ;
4990  }
4991 
4994  double GetQuantiles() const
4995  {
4996  return m_quantiles;
4997  }
4998 
5001  void SetQuantiles(double q)
5002  {
5003  m_quantiles = q;
5004  RecalculateShape();
5005  }
5006 
5008  void SetSegments(int segments)
5009  {
5010  m_segments = segments;
5011  }
5012 
5014  int GetSegments() const
5015  {
5016  return m_segments;
5017  }
5018 
5021  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
5022  {
5023  cov_00 = m_cov_00;
5024  cov_01 = m_cov_01;
5025  cov_11 = m_cov_11;
5026  }
5027 
5030  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
5031  {
5032  m_cov_00 = cov_00;
5033  m_cov_01 = cov_01;
5034  m_cov_11 = cov_11;
5035  RecalculateShape();
5036  }
5037 
5038  protected:
5041  double m_cov_00;
5042  double m_cov_11;
5043  double m_cov_01;
5044  double m_quantiles;
5045 
5049 
5052  void RecalculateShape();
5053 
5054  private:
5056 };
5057 
5058 //-----------------------------------------------------------------------------
5059 // mpPolygon - provided by Jose Luis Blanco
5060 //-----------------------------------------------------------------------------
5066 {
5067  public:
5070  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
5071  {
5072  m_continuous = true;
5073  m_name = layerName;
5074  }
5075 
5076  virtual ~mpPolygon()
5077  {
5078  ;
5079  }
5080 
5086  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
5087 
5088  private:
5090 };
5091 
5092 //-----------------------------------------------------------------------------
5093 // mpBitmapLayer - provided by Jose Luis Blanco
5094 //-----------------------------------------------------------------------------
5100 {
5101  public:
5105  {
5106  m_validImg = false;
5107  m_bitmapChanged = false;
5108  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
5109  }
5110 
5111  virtual ~mpBitmapLayer()
5112  {
5113  ;
5114  }
5115 
5118  void GetBitmapCopy(wxImage &outBmp) const;
5119 
5127  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
5128 
5131  virtual double GetMinX()
5132  {
5133  return m_bitmapX.min;
5134  }
5135 
5138  virtual double GetMaxX()
5139  {
5140  return m_bitmapX.max;
5141  }
5142 
5145  virtual double GetMinY()
5146  {
5147  return m_bitmapY.min;
5148  }
5149 
5152  virtual double GetMaxY()
5153  {
5154  return m_bitmapY.max;
5155  }
5156 
5157  protected:
5158 
5161  wxImage m_bitmap;
5162  wxBitmap m_scaledBitmap;
5165  bool m_validImg;
5167 
5172 
5173  virtual void DoPlot(wxDC &dc, mpWindow &w);
5174 
5175  private:
5177 };
5178 
5179 // utility class
5180 
5182 typedef enum __mp_Colour
5183 {
5184  mpBlue,
5185  mpRed,
5186  mpGreen,
5187  mpPurple,
5188  mpYellow,
5189  mpFuchsia,
5190  mpLime,
5191  mpAqua,
5192  mpOlive
5193 } mpColour;
5194 
5199 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
5200 {
5201  public:
5206  wxIndexColour(unsigned int id)
5207  {
5208  switch (id)
5209  {
5210  case 0:
5211  this->Set(0, 0, 255);
5212  break; // Blue
5213  case 1:
5214  this->Set(255, 0, 0);
5215  break; // Red
5216  case 2:
5217  this->Set(0, 128, 0);
5218  break; // Green
5219  case 3:
5220  this->Set(128, 0, 128);
5221  break; // Purple
5222  case 4:
5223  this->Set(255, 255, 0);
5224  break; // Yellow
5225  case 5:
5226  this->Set(255, 0, 255);
5227  break; // Fuchsia
5228  case 6:
5229  this->Set(0, 255, 0);
5230  break; // Lime
5231  case 7:
5232  this->Set(0, 255, 255);
5233  break; // Aqua/Cyan
5234  case 8:
5235  this->Set(128, 128, 0);
5236  break; // Olive
5237  default:
5238  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
5239  (ChannelType)((rand() * 255) / RAND_MAX));
5240  }
5241  }
5242 };
5243 
5246 // ---------------------------------------------------------------------
5247 #ifdef ENABLE_MP_NAMESPACE
5248  }// namespace MathPlot
5249  // No, iff build enables namespace, its up to app to use it appropriately: using namespace MathPlot;
5250 #endif // ENABLE_MP_NAMESPACE
5251 
5252 #endif // MATHPLOT_H_INCLUDED
sub type for mpFXYVector function
Definition: mathplot.h:753
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:4752
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2805
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer.
Definition: mathplot.h:3243
bool IsHorizontal(void) const
Is it a horizontal line?
Definition: mathplot.h:1797
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:655
int GetAxisID(void)
Return the ID of the Axis.
Definition: mathplot.h:2734
mpRange< double > m_rangeY
Y range.
Definition: mathplot.h:2393
sub type for mpText layer
Definition: mathplot.h:742
Align the plot label towards the southeast.
Definition: mathplot.h:694
void SetValue(const double value)
Set x or y value.
Definition: mathplot.h:1789
mpInfoLegend * m_InfoLegend
Pointer to the optional info legend layer.
Definition: mathplot.h:4625
Draw a circle.
Definition: mathplot.h:717
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:702
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:4598
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:2962
int m_infoLegendSelectedSeries
Only used with config window: the selected series in info legend.
Definition: mathplot.h:4640
bool m_LegendIsAlwaysVisible
If true, the name is visible in the legend despite the visibility of the function. Default false.
Definition: mathplot.h:1753
void EnableDoubleBuffer(const bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled).
Definition: mathplot.h:3774
wxIndexColour(unsigned int id)
Constructor.
Definition: mathplot.h:5206
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:1066
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:4379
std::vector< std::string > labels
Labels of the Values.
Definition: mathplot.h:2527
enum __mp_Colour mpColour
Enumeration of classic colour.
Bitmap type layer.
Definition: mathplot.h:832
static bool m_DefaultLegendIsAlwaysVisible
This value sets the default behaviour when a series is not visible for the legend display...
Definition: mathplot.h:4090
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:1196
#define MP_LOOP_ITER
Helper macro for iterating through axis maps without structured binding.
Definition: mathplot.h:131
mpLegendDirection m_item_direction
Layout direction used when arranging legend entries.
Definition: mathplot.h:1591
__Scale_Type
sub_type values for mpLAYER_AXIS
Definition: mathplot.h:760
Plot type layer.
Definition: mathplot.h:817
void Show(bool show)
Set if magnet shall be shown or hidden.
Definition: mathplot.h:3298
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:3707
wxPoint GetMousePosition()
Returns current mouse position in window.
Definition: mathplot.h:4448
void SetLegendIsAlwaysVisible(bool alwaysVisible)
Set the visibility of the name of the function in the legend despite the visibility of the function i...
Definition: mathplot.h:1733
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:5152
bool IsRightAxis()
Return true if this Y axis is aligned to the right side.
Definition: mathplot.h:3144
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:1426
User defined position. Can be change by mouse drag.
Definition: mathplot.h:665
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:4342
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1854
void SetYAxisID(unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1725
std::map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:3220
bool ShouldBeShown(wxRect plotArea, wxPoint mousePos)
Check conditions if info coords shall be shown or not.
Definition: mathplot.h:1418
mpLegendStyle GetItemMode() const
Get the current legend item drawing mode.
Definition: mathplot.h:1516
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:5065
#define MP_X_RAWTIME
Shortcut for MP_X_UTCTIME.
Definition: mathplot.h:202
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:3510
mpFloatRectSimple(mpRange< double > _x, mpRange< double > _y)
Construct a simple rectangular box.
Definition: mathplot.h:600
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:944
__Symbol_Type
Displaying a symbol instead of a point in the plot function.
Definition: mathplot.h:714
double m_deltaY
Min delta between 2 consecutive coordinate on y direction.
Definition: mathplot.h:2088
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:257
void SetCoordIsAlwaysVisible(bool alwaysVisible)
Set the visibility of the mouse coordinates in the info coordinates despite the visibility of the axi...
Definition: mathplot.h:2936
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:2135
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:4594
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:701
__mp_Layer_Type
Major type of an mpLayer (detail is in subtype)
Definition: mathplot.h:813
Show/Hide grids.
Definition: mathplot.h:643
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:5099
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:2953
void InitializeBoundingBox(double px, double py, int yAxisID)
Initialize the bounding box from a first point for the selected Y axis.
Definition: mathplot.h:4012
mpLabelType
enum for label for grid
Definition: mathplot.h:785
void Update(T value)
Update range according new value: Expand the range to include the value.
Definition: mathplot.h:380
bool m_mouseMovedAfterRightClick
If the mouse does not move after a right click, then the context menu is displayed.
Definition: mathplot.h:4614
Classic Normal distribution f(x) = exp(-(ln(x)-μ)²/2σ²)/(xσ.sqrt(2π))
Definition: mathplot.h:2446
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2667
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:4616
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:2651
wxRect GetRect(void)
Create rectangular area defined by start and end points.
Definition: mathplot.h:286
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:5070
double m_lastX
Last x-coordinate point added.
Definition: mathplot.h:2217
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2771
bool m_showDraggedSeries
Indicate if series that has been gripped with mouse shall be drawn.
Definition: mathplot.h:1592
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:3764
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:5170
Layer type undefined; SHOULD NOT BE USED.
Definition: mathplot.h:815
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:848
sub type not defined (should be never used)
Definition: mathplot.h:762
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:1195
void SetMagnetize(bool mag)
Enable or disable mouse-position magnet lines (cross-hairs) in the plot area.
Definition: mathplot.h:4421
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:1188
double m_cov_11
Covariance matrix element (1,1).
Definition: mathplot.h:5042
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1773
Lock x/y scaling aspect.
Definition: mathplot.h:642
virtual double GetMinY()
Get min Y of the function.
Definition: mathplot.h:2378
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:1509
wxString m_wildcard
For loadfile() function when we use wxFileDialog.
Definition: mathplot.h:4633
Align the info in margin center-bottom.
Definition: mathplot.h:663
int m_axisWidth
Reserved width for this Y axis including labels, in pixels.
Definition: mathplot.h:3160
Info box type layer.
Definition: mathplot.h:837
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:4751
void SetLabelMode(mpLabelType mode, unsigned int time_conv=0x20)
Set axis label view mode.
Definition: mathplot.h:2797
Abstract class providing a line.
Definition: mathplot.h:1761
mpRange< double > m_rangeX
Range min and max on x axis.
Definition: mathplot.h:2216
Abstract class providing an vertical line.
Definition: mathplot.h:1841
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2757
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2630
bool IsLeftAxis()
Return true if this Y axis is aligned to the left side.
Definition: mathplot.h:3138
double m_reference_y
Current object Y position in plot coordinates.
Definition: mathplot.h:4926
bool m_show
Indicates if magnet shall be shown in plot.
Definition: mathplot.h:1466
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:3336
#define MP_ZOOM_AROUND_CENTER
Default value for zoom around a point (default -1 is no zoom)
Definition: mathplot.h:213
mpRange< int > m_drawY
Range min and max on y axis.
Definition: mathplot.h:2084
wxString m_DefaultDir
The default directory for wxFileDialog.
Definition: mathplot.h:4634
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:2954
int m_labelPos
Bar-label placement mode.
Definition: mathplot.h:2596
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:3665
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:3745
std::vector< double > m_ys
internal copy of the set of data on y direction
Definition: mathplot.h:2206
void SetExtraMargin(int extra)
Set the extra margin.
Definition: mathplot.h:4206
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:3119
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1343
bool m_bitmapChanged
True when the cached scaled bitmap must be regenerated.
Definition: mathplot.h:5166
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:4879
Chart type layer (bar chart)
Definition: mathplot.h:822
mpRange< double > x
range over x direction
Definition: mathplot.h:592
double GetPosY(int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:3656
virtual void SetLogAxis(bool log)
Set Logarithmic mode.
Definition: mathplot.h:2928
double GetQuantiles() const
Get the confidence-interval multiplier used for the ellipse.
Definition: mathplot.h:4994
sub type for mpLine function
Definition: mathplot.h:755
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:1043
void SetAutoFit(bool autoFit)
Set if plot shall be auto fitted when hiding or showing axis and series via mouse.
Definition: mathplot.h:4112
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3797
~mpBarChart()
Destructor.
Definition: mathplot.h:2555
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:3737
T GetMaxAbs(void) const
Max absolute value of the range.
Definition: mathplot.h:435
Draw a cross X.
Definition: mathplot.h:721
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition: mathplot.h:402
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1203
double m_width
Width of each bar/column in plot units.
Definition: mathplot.h:2594
Draw a triangle up oriented.
Definition: mathplot.h:719
wxTopLevelWindow * m_parent
Pointer to the top-level window containing the plot (used for fullscreen)
Definition: mathplot.h:4578
void SetDefaultLegendIsAlwaysVisible(bool visible)
Set if legend is always visible even if series is not plotted.
Definition: mathplot.h:4097
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:4617
bool IsEnabled() const
Check if magnet is enabled.
Definition: mathplot.h:3283
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:4648
T min
The min value of the range.
Definition: mathplot.h:300
double m_relY
Box Y position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1346
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:1051
int m_flags
Holds label alignment. Default : mpALIGN_SW for series and mpALIGN_CENTER for scale.
Definition: mathplot.h:1200
mpRange< double > m_bbox_x
The precomputed bounding box:
Definition: mathplot.h:4946
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:4716
Mouse action drag the plot.
Definition: mathplot.h:781
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:928
mpNormal(double mu, double sigma)
Classic Normal distribution.
Definition: mathplot.h:2454
mpInfoLayer * GetMovingInfoLayer()
Returns moving info layer.
Definition: mathplot.h:4457
wxPoint GetPosition() const
Get the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1300
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1455
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:1106
~mpPieChart()
Destructor.
Definition: mathplot.h:2621
mpRange()
Default constructor.
Definition: mathplot.h:304
T max
The max value of the range.
Definition: mathplot.h:301
void Show(bool show)
Set if info coords shall be shown or hidden.
Definition: mathplot.h:1402
sub type not defined (should be never used)
Definition: mathplot.h:771
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1749
void SetDefaultDir(const wxString &dirname)
Set the default directory for wxFileDialog.
Definition: mathplot.h:4078
enum __Function_Type mpFunctionType
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
sub type not defined (should be never used)
Definition: mathplot.h:749
void Check(void)
Check to always have a range. If min = max then introduce the 0 to make a range.
Definition: mathplot.h:411
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:4225
sub type not defined (should be never used)
Definition: mathplot.h:741
double m_lastY
Last y-coordinate point added.
Definition: mathplot.h:2219
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:1190
T GetCenter(void) const
Center of the range.
Definition: mathplot.h:429
Just the end of ZOrder.
Definition: mathplot.h:839
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4909
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:830
void Set(T _value)
Initialize min and max.
Definition: mathplot.h:326
mpRange< double > m_axisRange
Range axis values when autosize is false.
Definition: mathplot.h:2958
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:4149
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:4085
double m_cov_01
Covariance matrix element (0,1), equal to element (1,0).
Definition: mathplot.h:5043
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1283
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1652
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:4219
Draw a plus +.
Definition: mathplot.h:722
void SetMouseLeftDownAction(mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:4430
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:4585
Keep the object, just remove the layer from the layer list.
Definition: mathplot.h:850
double m_mu
Mean value.
Definition: mathplot.h:2428
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:4618
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1944
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:2009
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:4589
wxColour m_barColour
Fill colour used for the bars.
Definition: mathplot.h:2595
Delete the object regardless of the CanDelete value and remove it from the layer list.
Definition: mathplot.h:852
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:1198
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:4603
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:4870
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:3251
Align the plot label towards the southwest.
Definition: mathplot.h:695
Implement the legend to be added to the plot This layer allows you to add a legend to describe the pl...
Definition: mathplot.h:1491
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:3054
double m_quantiles
Confidence-interval multiplier used when drawing the ellipse.
Definition: mathplot.h:5044
Align the y-axis towards left border.
Definition: mathplot.h:682
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:1199
#define ISNOTNULL(x)
Nullity test. Old solution is to test according small epsilon: (fabs(x) > MP_EPSILON) ...
Definition: mathplot.h:207
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:4723
Align the x-axis towards bottom border.
Definition: mathplot.h:672
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2520
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3781
void Assign(T value1, T value2)
Assign values to min and max.
Definition: mathplot.h:356
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:4590
Plot (function) type layer.
Definition: mathplot.h:835
void UpdateDesiredBoundingBox(mpAxisUpdate update)
Update m_desired bounds.
Definition: mathplot.h:3892
void UpdateBoundingBoxToInclude(double px, double py)
Update bounding box (X and Y axis) to include this point.
Definition: mathplot.h:616
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2821
bool m_IsHorizontal
Is the line horizontal? Default false.
Definition: mathplot.h:1804
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1202
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1688
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:881
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:1191
bool GetCoordIsAlwaysVisible() const
Get the visibility of the mouse coordinates in the info coordinates.
Definition: mathplot.h:2944
bool GetCanDelete(void) const
Retreive what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1175
Axis type layer.
Definition: mathplot.h:833
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:2675
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:2957
Draw a triangle down oriented.
Definition: mathplot.h:720
wxCoord m_mouseY
Last mouse Y position in window pixel coordinates.
Definition: mathplot.h:1471
Axis type layer.
Definition: mathplot.h:816
void SetCanDelete(bool canDelete)
Set what we do with the object associated with the layer when we delete the layer.
Definition: mathplot.h:1168
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:5131
bool GetMagnetize() const
Is mouse magnetization enabled? Useful to read the position on the axes.
Definition: mathplot.h:4415
double m_value
The x or y coordinates of the line.
Definition: mathplot.h:1803
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:4623
void Enable(bool enable)
Enables the magnet.
Definition: mathplot.h:3277
wxPen m_penSeries
Pen used to draw the series marker when series-coordinate mode is active.
Definition: mathplot.h:1473
wxPoint m_center
Center of the pie chart in device coordinates.
Definition: mathplot.h:2683
std::vector< double > m_trans_shape_ys
Transformed shape vertices in Y coordinates.
Definition: mathplot.h:4941
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours...
Definition: mathplot.h:2959
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:1385
#define MP_Y_BORDER_SEPARATION
Default minimum separation in pixels between Y axes and the plot border.
Definition: mathplot.h:195
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:2764
Align the info in margin center-right.
Definition: mathplot.h:661
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:4314
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:1085
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:3190
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:2282
void SetDrawState(bool drawState)
Set whether the plot has already been drawn on the current printout.
Definition: mathplot.h:4819
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:4694
mpRange< double > lastDesired
Last desired ranged, used for check if desired has changed.
Definition: mathplot.h:3208
double m_const
Const factor.
Definition: mathplot.h:2431
std::unordered_map< int, mpRange< double > > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition: mathplot.h:3594
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:5161
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:4351
void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
Ensure the bounding box includes the given point for the selected Y axis.
Definition: mathplot.h:3997
each visible plot is described on its own line, one above the other
Definition: mathplot.h:709
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:3621
int m_xPos
Leftmost X pixel occupied by this axis (starting point).
Definition: mathplot.h:3161
Align the x-axis towards top plot.
Definition: mathplot.h:675
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:1182
mpRange< double > bound
Range min and max.
Definition: mathplot.h:3206
Set label for axis in auto mode, automatically switch between decimal and scientific notation...
Definition: mathplot.h:788
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:4231
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:1441
Align the y-axis towards right border.
Definition: mathplot.h:686
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:730
std::unordered_map< int, mpRange< double > > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition: mathplot.h:3608
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:2214
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:5138
Show/Hide info coord.
Definition: mathplot.h:644
Align the x-axis towards top border.
Definition: mathplot.h:676
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:1099
Mouse action draw a box to zoom inside.
Definition: mathplot.h:780
mpFXGeneric(const wxString &name=wxT("Generic FX function"), int flags=mpALIGN_LEFT, unsigned int yAxisID=0)
Definition: mathplot.h:2345
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:5030
__Function_Type
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
Definition: mathplot.h:747
Classic Gaussian distribution f(x) = exp(-(x-μ)²/2σ²)/sqrt(2πσ²)
Definition: mathplot.h:2410
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition: mathplot.h:77
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:4795
Align the y-axis towards left plot.
Definition: mathplot.h:683
int m_last_ly
Last logical Y origin, used for double buffering.
Definition: mathplot.h:4608
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:4629
wxSize GetSize() const
Get the size of the box (in pixels)
Definition: mathplot.h:1315
Chart type layer.
Definition: mathplot.h:836
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:2956
Set label for axis in scientific notation.
Definition: mathplot.h:792
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:392
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1342
Copy a screen shot to the clipboard.
Definition: mathplot.h:645
Fit view to match bounding box of all layers.
Definition: mathplot.h:638
Create a generic FX function Override the ComputeY() function with your function. ...
Definition: mathplot.h:2338
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:4730
bool PointIsInside(double px, double py) const
Is point inside this bounding box?
Definition: mathplot.h:607
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:651
wxBitmap * m_buff_bmp
For double buffering.
Definition: mathplot.h:4609
mpRange< double > m_bitmapY
Range of the bitmap on y direction.
Definition: mathplot.h:5171
bool IsShown()
Get shown status.
Definition: mathplot.h:3304
bool m_cacheDirty
Indicate that the cached buffer m_buff_bmp need to be re-created.
Definition: mathplot.h:4610
Center view on click position.
Definition: mathplot.h:641
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1751
mpLegendStyle m_item_mode
Visual style used for each legend entry.
Definition: mathplot.h:1590
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:2147
bool m_autoFit
Automatically fit plot when hiding / showing axis and series.
Definition: mathplot.h:4622
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:670
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition: mathplot.h:1398
sub type for all layers who are function.
Definition: mathplot.h:756
Draw a square.
Definition: mathplot.h:718
mpRange< double > GetBoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:3561
bool operator==(const mpAxisData &other) const
Compare axis data while ignoring the axis pointer itself.
Definition: mathplot.h:3212
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:4854
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2466
Align the x-axis center plot.
Definition: mathplot.h:674
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:739
double m_radius
Radius of the pie chart in pixels.
Definition: mathplot.h:2682
double m_deltaX
Min delta between 2 consecutive coordinate on x direction.
Definition: mathplot.h:2087
__mp_Colour
Enumeration of classic colour.
Definition: mathplot.h:5182
mpRange< double > GetDesiredBoundY(int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3584
int m_BarWidth
Bar width in pixels when the XY series is drawn in bar mode.
Definition: mathplot.h:2090
Align the plot label towards the northwest.
Definition: mathplot.h:692
double m_total_value
Total of the values vector.
Definition: mathplot.h:2530
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:4583
void SetMinScale(double min)
Set the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2845
void SetbgColour(const wxColour &colour)
Set the plot background colour.
Definition: mathplot.h:4326
void SetHovering(bool hover)
Set if axis shall be highlighted when a series is dragged over it.
Definition: mathplot.h:2912
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:2035
std::vector< double > m_shape_xs
Shape vertices in object-local X coordinates.
Definition: mathplot.h:4936
virtual bool IsLogAxis()
Get if we are in Logarithmic mode.
Definition: mathplot.h:2920
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1695
mpRange< double > desired
Desired range min and max.
Definition: mathplot.h:3207
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition: mathplot.h:3062
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:5199
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1752
mpRange(T value1, T value2)
Create range with the 2 values.
Definition: mathplot.h:311
bool IsTopAxis()
Return true when this X axis is aligned at the top edge or top border.
Definition: mathplot.h:3069
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1660
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:4599
No symbol is drawing.
Definition: mathplot.h:716
Layer for bar chart.
Definition: mathplot.h:2548
mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:3917
__Chart_Type
sub_type values for mpLAYER_CHART
Definition: mathplot.h:769
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:1193
wxCoord m_scaledBitmap_offset_x
Cached X pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5163
virtual double ComputeY(double x)
The main computation of the FX function.
Definition: mathplot.h:2469
double m_variance
Sigma² is the variance.
Definition: mathplot.h:2430
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:1467
abstract Layer for chart (bar and pie).
Definition: mathplot.h:2489
void SetInitialPosition(wxPoint pos)
Set the position in percent of the upper left corner of the box.
Definition: mathplot.h:1307
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:703
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:590
sub type for all layers who are chart.
Definition: mathplot.h:774
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:1059
unsigned int mpOptional_uint
Optional unsigned integer fallback type used when std::optional is unavailable.
Definition: mathplot.h:120
Align the info in margin center-left.
Definition: mathplot.h:657
void SetLabelFormat(const wxString &format, bool updateLabelMode=false)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition: mathplot.h:2780
const wxRect & GetRectangle() const
Get the current rectangle coordinates.
Definition: mathplot.h:1322
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:3929
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition: mathplot.h:790
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:690
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1748
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:3948
void ToLog(void)
Convert to log range.
Definition: mathplot.h:441
void ShowDraggedSeries(bool active)
Set if dragged series shall be shown or hidden.
Definition: mathplot.h:1543
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:4172
mpRange< double > m_rangeY
Range min and max on y axis.
Definition: mathplot.h:2218
bool operator!=(const mpRange &other) const
Compare two ranges for inequality.
Definition: mathplot.h:462
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:2167
bool IsDraggedSeriesShown() const
Get shown status of dragged series.
Definition: mathplot.h:1550
int m_symbolSize2
Size of the symbol div 2.
Definition: mathplot.h:1750
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:5145
sub type for mpInfoLegend layer
Definition: mathplot.h:735
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2837
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:2245
void SetLogXaxis(bool log)
Enable or disable logarithmic scaling on the X axis.
Definition: mathplot.h:4393
int GetMarginRight(bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:4157
#define MP_EPSILON
An epsilon for float comparison to 0.
Definition: mathplot.h:205
mpRange< int > m_drawX
Range min and max on x axis.
Definition: mathplot.h:2083
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1826
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:2187
bool ShouldBeShown(wxPoint mousePos)
Check conditions if magnet shall be shown.
Definition: mathplot.h:3292
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:2197
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:3959
bool GetLegendIsAlwaysVisible() const
Get the visibility of the legend.
Definition: mathplot.h:1741
Text box type layer.
Definition: mathplot.h:819
mpMouseButtonAction GetMouseLeftDownAction()
Returns the type of action for the left mouse button.
Definition: mathplot.h:4439
double pos
Position.
Definition: mathplot.h:3205
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:4126
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:680
sub type for mpBarChart
Definition: mathplot.h:772
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:4605
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1248
Load a file.
Definition: mathplot.h:649
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:893
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:4744
bool m_fullscreen
Boolean value indicating that we are in fullscreen mode (default false)
Definition: mathplot.h:4579
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:4600
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:1275
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:901
Line (horizontal or vertical) type layer.
Definition: mathplot.h:834
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1369
double m_mu
Mean value.
Definition: mathplot.h:2464
mpRange< double > y
range over y direction
Definition: mathplot.h:593
mpLocation m_location
The location of the text.
Definition: mathplot.h:4753
Delete the object if CanDelete is true and remove it from the layer list.
Definition: mathplot.h:851
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:4027
mpLabelType m_labelType
Label formatting mode used for the X coordinate display.
Definition: mathplot.h:1468
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:4593
sub type for mpTitle layer
Definition: mathplot.h:743
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:3756
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1667
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:4582
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1505
double GetMaxScale() const
Get the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2869
Align the info in margin center-top.
Definition: mathplot.h:659
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition: mathplot.h:799
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:4587
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:4367
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:3683
int GetBarWidth(void) const
Get the width of the bar when we plot in bar mode.
Definition: mathplot.h:2066
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:4336
double m_labelAngle
Rotation angle used for bar labels, in degrees.
Definition: mathplot.h:2597
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1434
void SetAxisID(unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2743
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:2267
int mpOptional_int
Optional integer fallback type used when std::optional is unavailable.
Definition: mathplot.h:122
void SetMin(T _min)
Set min function, correct max.
Definition: mathplot.h:340
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:4265
bool m_enableDoubleBuffer
For double buffering. Default enabled.
Definition: mathplot.h:4611
double m_max_value
Max value of the values vector.
Definition: mathplot.h:2529
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1639
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1882
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2638
mpTitle(const wxString &name)
Definition: mathplot.h:4775
Plot layer implementing a simple title.
Definition: mathplot.h:4766
Set no label for axis (useful for bar)
Definition: mathplot.h:805
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:3109
bool m_validImg
True when the source image is valid and ready to draw.
Definition: mathplot.h:5165
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:778
#define MP_OPTNULL_INT
Null sentinel used for mpOptional_int / mpOptional_uint in the fallback implementation.
Definition: mathplot.h:124
sub type for mpPieChart
Definition: mathplot.h:773
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:4888
bool ViewAsBar(void) const
Get if we are in bar mode.
Definition: mathplot.h:2075
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1347
mpRange< double > GetBoundY(int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:3575
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:1133
mpGaussian(double mu, double sigma)
Classic Gaussian distribution.
Definition: mathplot.h:2418
Align the plot label towards the northeast.
Definition: mathplot.h:693
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:4240
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:3632
only for mpInfoCoords
Definition: mathplot.h:666
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:1161
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:1197
std::vector< double > m_trans_shape_xs
Transformed shape vertices in X coordinates.
Definition: mathplot.h:4940
mpLegendDirection GetItemDirection() const
Get the current legend item layout direction.
Definition: mathplot.h:1530
int GetAxisWidth()
Get the reserved width of the Y axis in pixels.
Definition: mathplot.h:3132
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:4213
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2829
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:2027
virtual double ComputeY(double x)
The main computation of the FX function.
Definition: mathplot.h:2433
sub type for mpFXY function
Definition: mathplot.h:752
wxCoord m_mouseX
Last mouse X position in window pixel coordinates.
Definition: mathplot.h:1470
enum __XAxis_Align_Type mpXAxis_Align
Alignment for X axis.
void UpdateBox(const wxRect &plotArea)
Update the drawable magnet area from a wxRect.
Definition: mathplot.h:3271
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1747
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:4357
enum __Chart_Type mpChartType
sub_type values for mpLAYER_CHART
bool IsBottomAxis()
Return true when this X axis is aligned at the bottom edge or bottom border.
Definition: mathplot.h:3075
std::vector< double > m_xs
The internal copy of the set of data to draw.
Definition: mathplot.h:2205
void SetScale(mpRange< double > range)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2896
mpRange< double > GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition: mathplot.h:3567
#define m_yID
Alias for the Y-axis identifier when structured binding is unavailable.
Definition: mathplot.h:133
~mpChart()
Destructor.
Definition: mathplot.h:2496
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:3970
virtual double GetY(double x)
Get function value for argument.
Definition: mathplot.h:2359
Abstract class providing an horizontal line.
Definition: mathplot.h:1812
Zoom into view at clickposition / window center.
Definition: mathplot.h:639
int GetMarginLeft(bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:4197
wxBitmap m_scaledBitmap
Cached scaled bitmap used for drawing.
Definition: mathplot.h:5162
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:4586
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:5048
int GetSegments() const
Get the number of line segments used to approximate the ellipse. */.
Definition: mathplot.h:5014
bool m_enableScrollBars
Enable scrollbar in plot window (default false)
Definition: mathplot.h:4621
double scale
Scale.
Definition: mathplot.h:3204
Align the info in margin top-left.
Definition: mathplot.h:658
void Rewind()
Rewind value enumeration with mpFXY::GetNextXY.
Definition: mathplot.h:2224
bool IsSet()
Check if this mpRange has been assigned any values.
Definition: mathplot.h:371
Zoom out.
Definition: mathplot.h:640
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2711
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:1019
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:3257
static bool m_DefaultCoordIsAlwaysVisible
This value sets the default behaviour when an axis is not visible for the mouse info coordinates disp...
Definition: mathplot.h:4105
void SetBrush(const wxColour &colour, enum wxBrushStyle style=wxBRUSHSTYLE_SOLID)
Set layer brush.
Definition: mathplot.h:1077
static int m_orgy
The y origin coordinate of the X axis We declare it static so we can access to it in mpScaleY...
Definition: mathplot.h:3085
double GetMinScale() const
Get the minimum of the scale range when we are in automatic mode.
Definition: mathplot.h:2853
double m_relX
Box X position relative window, used to rescale the info box position when the window is resized...
Definition: mathplot.h:1345
int m_reserveXY
Memory reserved for m_xs and m_ys.
Definition: mathplot.h:2210
bool PointIsInside(T point) const
Return true if the point is inside the range (min and max included)
Definition: mathplot.h:448
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:707
sub type for mpInfoLayer layer
Definition: mathplot.h:733
Align the x-axis towards bottom plot.
Definition: mathplot.h:673
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:4972
virtual double GetMaxY()
Get max Y of the function.
Definition: mathplot.h:2387
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition: mathplot.h:2789
int GetMarginTop(bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:4140
mpInfoCoords * m_InfoCoords
Pointer to the optional info coords layer.
Definition: mathplot.h:4624
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:3938
bool m_series_coord
True to show the nearest plotted series value instead of raw mouse Y coordinates. ...
Definition: mathplot.h:1472
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition: mathplot.h:797
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:3201
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:699
const wxColour & GetbgColour() const
Get the plot background colour.
Definition: mathplot.h:4320
Layer for pie chart.
Definition: mathplot.h:2612
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:1035
Align the y-axis towards right plot.
Definition: mathplot.h:685
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:2887
T Length(void) const
Length of the range.
Definition: mathplot.h:423
sub type for mpScaleX
Definition: mathplot.h:763
bool PointIsInsideBound(double px, double py, int yAxisID)
Is the given point inside the current bounding box for the selected Y axis?
Definition: mathplot.h:3984
sub type for mpInfoCoords layer
Definition: mathplot.h:734
bool m_CoordIsAlwaysVisible
If true, the mouse coordinates is visible in the info coordinates despite the visibility of the axis...
Definition: mathplot.h:2964
struct deprecated("Deprecated! No longer used as X and Y are now separated")]] mpFloatRect
A structure for computation of bounds in real units (not in screen pixel) X refer to X axis Y refer t...
Definition: mathplot.h:474
Set label user defined.
Definition: mathplot.h:803
void SetColumnWidth(const double colWidth)
Set the bar width in plot units.
Definition: mathplot.h:2564
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:4978
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:1027
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:4612
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:1192
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:3641
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition: mathplot.h:795
sub type not defined (should be never used)
Definition: mathplot.h:732
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition: mathplot.h:801
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:5021
void SetMax(T _max)
Set max function, correct min.
Definition: mathplot.h:348
Bitmap type layer.
Definition: mathplot.h:820
HitCode
Return codes for GetLegendHitRegion() if no series was hit.
Definition: mathplot.h:1580
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1329
bool IsVisible() const
Is this layer visible?
Definition: mathplot.h:1126
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:2750
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:909
bool IsShown()
Get shown status.
Definition: mathplot.h:1409
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:1147
int m_last_lx
Last logical X origin, used for double buffering.
Definition: mathplot.h:4607
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1703
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2960
Align the info in margin bottom-left.
Definition: mathplot.h:662
const wxString & GetWildcard(void) const
Get wildcard.
Definition: mathplot.h:4060
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:4859
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:751
Info box type layer.
Definition: mathplot.h:818
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:3728
mpOptional_int m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:4620
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:3718
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition: mathplot.h:3673
wxCoord m_scaledBitmap_offset_y
Cached Y pixel offset used when drawing the scaled bitmap.
Definition: mathplot.h:5164
Align the y-axis center plot.
Definition: mathplot.h:684
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:1867
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:952
Plot layer implementing a text string.
Definition: mathplot.h:4689
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:919
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:4601
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4916
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:4271
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:1113
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:1194
double m_sigma
Sigma value.
Definition: mathplot.h:2429
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:4166
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:936
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1344
int GetMarginBottom(bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:4180
Shows information about the mouse commands.
Definition: mathplot.h:650
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:4404
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:4132
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:3524
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:4588
mpRange< double > m_bbox_y
Range of bounding box on y direction.
Definition: mathplot.h:4947
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:4631
legend components follow each other horizontally on a single line
Definition: mathplot.h:710
Align the info in margin top-right.
Definition: mathplot.h:660
double m_reference_phi
Current object rotation angle in radians.
Definition: mathplot.h:4927
void InitializeBoundingBox(double px, double py)
Initialize bounding box with an initial point.
Definition: mathplot.h:626
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1523
enum __Text_Type mpTextType
sub_type values for mpLAYER_TEXT
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see GetQuantiles a...
Definition: mathplot.h:5001
double m_const
Const factor.
Definition: mathplot.h:2467
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1716
void SetSegments(int segments)
Set the number of line segments used to approximate the ellipse.
Definition: mathplot.h:5008
sub type for all layers who are scale.
Definition: mathplot.h:765
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:4595
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:298
void Set(T _min, T _max)
Set min, max function.
Definition: mathplot.h:333
Align the info in margin bottom-right.
Definition: mathplot.h:664
bool m_boxZoomActive
Indicate if box zoom is active.
Definition: mathplot.h:4627
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:4925
double GetScaleY(int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:3549
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:2659
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1674
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4895
sub type for mpMovableObject function
Definition: mathplot.h:754
Plot layer, abstract base class.
Definition: mathplot.h:865
std::vector< double > values
Values of the chart.
Definition: mathplot.h:2526
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1201
void SetNeedUpdate()
Mark the legend bitmap as needing regeneration.
Definition: mathplot.h:1536
bool IsInside(wxCoord xPixel)
Return true if the given X pixel lies within this Y-axis drawing area.
Definition: mathplot.h:3150
mpRange< double > GetScale() const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2904
std::vector< double > m_shape_ys
Shape vertices in object-local Y coordinates.
Definition: mathplot.h:4937
double GetValue() const
Get the x or y coordinates of the line.
Definition: mathplot.h:1781
enum __Scale_Type mpScaleType
sub_type values for mpLAYER_AXIS
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:4737
void SetFactor(int factor)
Definition: mathplot.h:4831
sub type for mpFX function
Definition: mathplot.h:750
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:1003
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:1189
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:2961
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:4592
double m_sigma
Sigma value.
Definition: mathplot.h:2465
wxPoint m_mousePos
Current mouse position in window.
Definition: mathplot.h:4615
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:4619
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:1092
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:1011
unsigned int m_timeConv
Time conversion mode used when formatting date/time X values.
Definition: mathplot.h:1469
void SetScale(double min, double max)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2878
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1219
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:5041
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:4189
#define m_yData
Alias for the Y-axis data when structured binding is unavailable.
Definition: mathplot.h:135
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:4581
std::vector< wxColour > colours
Per-slice colours used when drawing the chart.
Definition: mathplot.h:2684
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:2955
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:4597
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:2307
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1336
void SetWildcard(const wxString &wildcard)
Set wildcard for LoadFile() function when we use wxFileDialog.
Definition: mathplot.h:4052
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:4613
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:4604
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:1140
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2726
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4902
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:3871
void SetMaxScale(double max)
Set the maximum of the scale range when we are in automatic mode.
Definition: mathplot.h:2861
#define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class)
Definition for RTTI.
Definition: mathplot.h:220
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2813
sub type for mpScaleY
Definition: mathplot.h:764
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1681
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:5104
void SetScaleY(const double scaleY, int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:3533
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:3228
Text box type layer.
Definition: mathplot.h:838
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:3359
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:1154
Line (horizontal or vertical) type layer.
Definition: mathplot.h:821
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:2260