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: 10/12/2025
10 // Copyright: (c) David Schalig, Davide Rondini
11 // Licence: wxWindows licence
13 
14 #ifndef MATHPLOT_H_INCLUDED
15 #define MATHPLOT_H_INCLUDED
16 
17 #define MATHPLOT_MANY_YAXIS
18 
19 
58 //this definition uses windows dll to export function.
59 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
60 //mathplot_EXPORTS will be defined by cmake
61 #ifdef mathplot_EXPORTS
62 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
63 #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
64 #else // not making DLL
65 #define WXDLLIMPEXP_MATHPLOT
66 #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
67 #endif
68 
69 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
70 #pragma interface "mathplot.h"
71 #endif
72 
73 #include <vector>
74 #include <map>
75 #include <optional>
76 
77 // #include <wx/wx.h>
78 #include <wx/defs.h>
79 #include <wx/menu.h>
80 #include <wx/scrolwin.h>
81 #include <wx/event.h>
82 #include <wx/dynarray.h>
83 #include <wx/pen.h>
84 #include <wx/dcmemory.h>
85 #include <wx/string.h>
86 #include <wx/print.h>
87 #include <wx/image.h>
88 #include <wx/intl.h>
89 
90 #include <cmath>
91 #include <deque>
92 #include <algorithm>
93 
94 // No, this is supposed to be a build parameter: #define ENABLE_MP_CONFIG
95 #ifdef ENABLE_MP_CONFIG
96  #include "MathPlotConfig.h"
97 #endif // ENABLE_MP_CONFIG
98 
103 // No, this is supposed to be a build parameter: #define ENABLE_MP_NAMESPACE
104 #ifdef ENABLE_MP_NAMESPACE
105  namespace MathPlot {
106 #endif // ENABLE_MP_NAMESPACE
107 
108 #ifdef ENABLE_MP_DEBUG
109 // For memory leak debug
110 #ifdef _WINDOWS
111 #ifdef _DEBUG
112 #include <crtdbg.h>
113 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
114 #else
115 #define DEBUG_NEW new
116 #endif // _DEBUG
117 #endif // _WINDOWS
118 #endif // ENABLE_MP_DEBUG
119 
120 // Separation for axes when set close to border
121 #define X_BORDER_SEPARATION 40
122 #define Y_BORDER_SEPARATION 60
123 
125 #define mpX_LOCALTIME 0x10
126 
127 #define mpX_UTCTIME 0x20
128 #define mpX_RAWTIME mpX_UTCTIME
129 
130 // An epsilon for float comparison to 0
131 #define EPSILON 1e-8
132 #define ISNOTNULL(x) (fabs(x) > EPSILON)
133 
134 // A small extra margin for the plot boundary
135 #define EXTRA_MARGIN 8
136 
137 #define ZOOM_AROUND_CENTER -1
138 
139 //-----------------------------------------------------------------------------
140 // classes
141 //-----------------------------------------------------------------------------
142 
143 class WXDLLIMPEXP_MATHPLOT mpLayer;
144 class WXDLLIMPEXP_MATHPLOT mpFunction;
145 class WXDLLIMPEXP_MATHPLOT mpLine;
146 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine;
147 class WXDLLIMPEXP_MATHPLOT mpVerticalLine;
148 class WXDLLIMPEXP_MATHPLOT mpFX;
149 class WXDLLIMPEXP_MATHPLOT mpFY;
150 class WXDLLIMPEXP_MATHPLOT mpFXY;
151 class WXDLLIMPEXP_MATHPLOT mpFXYVector;
152 class WXDLLIMPEXP_MATHPLOT mpProfile;
153 class WXDLLIMPEXP_MATHPLOT mpChart;
154 class WXDLLIMPEXP_MATHPLOT mpBarChart;
155 class WXDLLIMPEXP_MATHPLOT mpScale;
156 class WXDLLIMPEXP_MATHPLOT mpScaleX;
157 class WXDLLIMPEXP_MATHPLOT mpScaleY;
158 class WXDLLIMPEXP_MATHPLOT mpInfoLayer;
159 class WXDLLIMPEXP_MATHPLOT mpInfoCoords;
160 class WXDLLIMPEXP_MATHPLOT mpInfoLegend;
161 class WXDLLIMPEXP_MATHPLOT mpWindow;
162 class WXDLLIMPEXP_MATHPLOT mpText;
163 class WXDLLIMPEXP_MATHPLOT mpTitle;
164 class WXDLLIMPEXP_MATHPLOT mpPrintout;
165 class WXDLLIMPEXP_MATHPLOT mpMovableObject;
166 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse;
167 class WXDLLIMPEXP_MATHPLOT mpPolygon;
168 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer;
169 
170 #ifdef ENABLE_MP_CONFIG
172 #endif // ENABLE_MP_CONFIG
173 
175 typedef union
176 {
177  struct
178  {
179  wxCoord startPx;
180  wxCoord endPx;
181  wxCoord startPy;
182  wxCoord endPy;
183  };
184  struct
185  {
186  wxCoord left;
187  wxCoord top;
188  wxCoord right;
189  wxCoord bottom;
190  };
191  struct
192  {
193  wxCoord x1;
194  wxCoord y1;
195  wxCoord x2;
196  wxCoord y2;
197  };
198  wxCoord tab[4];
199 } mpRect;
200 
206 struct mpRange
207 {
208  double min = 0.0f;
209  double max = 0.0f;
210 
211  // Default constructor
212  mpRange()
213  {
214  min = 0.0f;
215  max = 0.0f;
216  }
217 
218  // Create range with the 2 values
219  mpRange(double value1, double value2)
220  {
221  if (value1 < value2)
222  {
223  min = value1;
224  max = value2;
225  }
226  else
227  {
228  min = value2;
229  max = value1;
230  }
231  }
232 
233  // Set min, max function
234  void Set(double _min, double _max)
235  {
236  min = _min;
237  max = _max;
238  }
239 
240  // Assign values to min and max
241  void Assign(double value1, double value2)
242  {
243  if (value1 < value2)
244  {
245  min = value1;
246  max = value2;
247  }
248  else
249  {
250  min = value2;
251  max = value1;
252  }
253  }
254 
255  /* Update range according new value:
256  * Expand the range to include the value.
257  * If value < min then min = value and if value > max then max = value
258  */
259  void Update(double value)
260  {
261  if (value < min)
262  min = value;
263  else
264  if (value > max)
265  max = value;
266  }
267 
268  /* Update range with new min and max values if this expand the range
269  * If _min < min then min = _min and if _max > max then max = _max
270  */
271  void Update(double _min, double _max)
272  {
273  if (_min < min)
274  min = _min;
275  if (_max > max)
276  max = _max;
277  }
278 
279  /* Update range with new range values if this expand the range
280  */
281  void Update(mpRange range)
282  {
283  if (range.min < min)
284  min = range.min;
285  if (range.max > max)
286  max = range.max;
287  }
288 
289  // Check to always have a range. If min = max then introduce the 0 to make a range.
290  void Check(void)
291  {
292  if (min == max)
293  {
294  if (max > 0)
295  min = 0;
296  else
297  max = 0;
298  }
299  }
300 
301  // Length of the range
302  double Length(void) const
303  {
304  return max - min;
305  }
306 
307  // Center of the range
308  double GetCenter(void) const
309  {
310  return (min + max) / 2;
311  }
312 
313  // Convert to log range
314  void ToLog(void)
315  {
316  min = (min > 0) ? log10(min) : 0;
317  max = (max > 0) ? log10(max) : 0;
318  }
319 
320  // Return true if the point is inside the range (min and max included)
321  bool PointIsInside(double point) const
322  {
323  return ((point >= min) && (point <= max));
324  }
325 
326 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
327  bool operator==(const mpRange&) const = default;
328 #else
329  bool operator==(const mpRange &other) const
330  {
331  return (min == other.min) && (max == other.max);
332  }
333 #endif
334 };
335 
341 struct [[deprecated("No more used, X and Y are now separated")]] mpFloatRect
342 {
343  mpRange x;
344  std::vector<mpRange> y;
345 
352  mpFloatRect(mpWindow& w);
353 
355  mpFloatRect() = delete;
356 
358  bool PointIsInside(double px, double py, size_t yAxisID = 0) const {
359  if (yAxisID < y.size())
360  {
361  if( (px < x.min || px > x.max) ||
362  (py < y[yAxisID].min || py > y[yAxisID].max))
363  {
364  return false;
365  }
366  }
367  else
368  {
369  return false;
370  }
371 
372  return true;
373  }
375  void UpdateBoundingBoxToInclude(double px, double py, size_t yAxisID = 0) {
376  assert(yAxisID < y.size());
377  if (yAxisID < y.size())
378  {
379  if (px < x.min ) x.min = px;
380  else if (px > x.max ) x.max = px;
381  if (py < y[yAxisID].min ) y[yAxisID].min = py;
382  else if (py > y[yAxisID].max ) y[yAxisID].max = py;
383  }
384  }
386  void InitializeBoundingBox(double px, double py, size_t yAxisID = 0) {
387  assert(yAxisID < y.size());
388  if (yAxisID < y.size())
389  {
390  x.min = x.max = px;
391  y[yAxisID].min = y[yAxisID].max = py;
392  }
393  }
395  bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
397 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
398  bool operator==(const mpFloatRect&) const = default;
399 #else
400  // We compare with an epsilon precision
401  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
402  bool operator==(const mpFloatRect& rect) const
403  {
404  auto Same = [](double a, double b) {
405  return std::fabs(a - b) < EPSILON;
406  };
407 
408  // Compare scalar members
409  if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
410  {
411  return false;
412  }
413 
414  // Compare vector sizes
415  if (y.size() != rect.y.size())
416  {
417  return false;
418  }
419 
420  // Compare each Y boundary
421  for (size_t i = 0; i < y.size(); ++i)
422  {
423  if (!Same(y[i].min, rect.y[i].min) ||
424  !Same(y[i].max, rect.y[i].max) )
425  {
426  return false;
427  }
428  }
429 
430  return true;
431  }
432 #endif
433 };
434 
441 {
442  mpRange x;
443  mpRange y;
444 
445  mpFloatRectSimple(mpRange _x, mpRange _y) : x(_x), y(_y) { };
446 
448  bool PointIsInside(double px, double py) const {
449  return x.PointIsInside(px) && y.PointIsInside(py);
450  }
451 
452  /* Update bounding box (X and Y axis) to include this point.
453  * Expand the range to include the point.
454  * @param px: point on x-axis
455  * @param py: point on y-axis
456  */
457  void UpdateBoundingBoxToInclude(double px, double py)
458  {
459  x.Update(px);
460  y.Update(py);
461  }
462 
463  /* Initialize bounding box with an initial point
464  * @param px: point on x-axis
465  * @param py: point on y-axis
466  */
467  void InitializeBoundingBox(double px, double py)
468  {
469  x.Set(px, px);
470  y.Set(py, py);
471  }
472 };
473 
477 enum
478 {
479  mpID_FIT = 2000,
487 #ifdef ENABLE_MP_CONFIG
488  mpID_CONFIG,
489 #endif // ENABLE_MP_CONFIG
493 };
494 
496 typedef enum __mp_Location_Type
497 {
498  mpMarginLeftCenter,
499  mpMarginTopLeft,
500  mpMarginTopCenter,
501  mpMarginTopRight,
502  mpMarginRightCenter,
503  mpMarginBottomLeft,
504  mpMarginBottomCenter,
505  mpMarginBottomRight,
506  mpMarginNone,
507  mpCursor // only for mpInfoCoords
508 } mpLocation;
509 
511 typedef enum __XAxis_Align_Type
512 {
513  mpALIGN_BORDER_BOTTOM = 10,
514  mpALIGN_BOTTOM,
515  mpALIGN_CENTERX,
516  mpALIGN_TOP,
517  mpALIGN_BORDER_TOP
518 } mpXAxis_Align;
519 
521 typedef enum __YAxis_Align_Type
522 {
523  mpALIGN_BORDER_LEFT = 20,
524  mpALIGN_LEFT,
525  mpALIGN_CENTERY,
526  mpALIGN_RIGHT,
527  mpALIGN_BORDER_RIGHT
528 } mpYAxis_Align;
529 
532 {
533  mpALIGN_NW = 5,
534  mpALIGN_NE,
535  mpALIGN_SE,
536  mpALIGN_SW
537 } mpPlot_Align;
538 
540 typedef enum __mp_Style_Type
541 {
545 } mpLegendStyle;
546 
549 {
553 
554 typedef enum __Symbol_Type
555 {
556  mpsNone,
557  mpsCircle,
558  mpsSquare,
559  mpsUpTriangle,
560  mpsDownTriangle,
561  mpsCross,
562  mpsPlus
563 } mpSymbol;
564 
565 //-----------------------------------------------------------------------------
566 // mpLayer sub_type values
567 //-----------------------------------------------------------------------------
568 
570 typedef enum __Info_Type
571 {
572  mpiNone, // never used
573  mpiInfo,
574  mpiCoords,
575  mpiLegend
576 } mpInfoType;
577 
579 typedef enum __Text_Type
580 {
581  mptNone, // never used
582  mptText,
583  mptTitle
584 } mpTextType;
585 
586 typedef enum __Function_Type
587 {
588  mpfNone,
589  mpfFX,
590  mpfFY,
591  mpfFXY,
592  mpfFXYVector,
593  mpfMovable,
594  mpfLine,
595  mpfAllType
596 } mpFunctionType;
597 
598 typedef enum __Scale_Type
599 {
600  mpsScaleNone,
601  mpsScaleX,
602  mpsScaleY,
603  mpsAllType
604 } mpScaleType;
605 
606 typedef enum __Chart_Type
607 {
608  mpcChartNone,
609  mpcBarChart,
610  mpcPieChart,
611  mpcAllType
612 } mpChartType;
613 
614 enum mpMouseButtonAction
615 {
616  mpMouseBoxZoom,
617  mpMouseDragZoom,
618 };
619 
620 //-----------------------------------------------------------------------------
621 // mpLayer
622 //-----------------------------------------------------------------------------
623 
624 typedef enum __mp_Layer_Type
625 {
634 } mpLayerType;
635 
641 typedef enum __mp_Layer_ZOrder
642 {
651 } mpLayerZOrder;
652 
659 typedef enum __mp_Delete_Action
660 {
661  mpNoDelete,
662  mpYesDelete,
663  mpForceDelete
665 
676 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
677 {
678  public:
679  mpLayer(mpLayerType layerType);
680 
681  virtual ~mpLayer()
682  {
683  ;
684  }
685 
689  {
690  m_win = &w;
691  }
692 
700  virtual bool HasBBox()
701  {
702  return true;
703  }
704 
709  mpLayerType GetLayerType() const
710  {
711  return m_type;
712  }
713 
717  int GetLayerSubType() const
718  {
719  return m_subtype;
720  }
721 
727  virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
728  {
729  *subtype = m_subtype;
730  return (m_type == typeOfInterest);
731  }
732 
736  virtual double GetMinX()
737  {
738  return -1.0;
739  }
740 
744  virtual double GetMaxX()
745  {
746  return 1.0;
747  }
748 
752  virtual double GetMinY()
753  {
754  return -1.0;
755  }
756 
760  virtual double GetMaxY()
761  {
762  return 1.0;
763  }
764 
806  void Plot(wxDC &dc, mpWindow &w);
807 
811  void SetName(const wxString &name)
812  {
813  m_name = name;
814  }
815 
819  const wxString& GetName() const
820  {
821  return m_name;
822  }
823 
827  void SetFont(const wxFont &font)
828  {
829  m_font = font;
830  }
831 
835  const wxFont& GetFont() const
836  {
837  return m_font;
838  }
839 
843  void SetFontColour(const wxColour &colour)
844  {
845  m_fontcolour = colour;
846  }
847 
851  const wxColour& GetFontColour() const
852  {
853  return m_fontcolour;
854  }
855 
859  void SetPen(const wxPen &pen)
860  {
861  m_pen = pen;
862  }
863 
867  const wxPen& GetPen() const
868  {
869  return m_pen;
870  }
871 
874  void SetBrush(const wxBrush &brush)
875  {
876  if (brush == wxNullBrush)
877  m_brush = *wxTRANSPARENT_BRUSH;
878  else
879  m_brush = brush;
880  }
881 
884  const wxBrush& GetBrush() const
885  {
886  return m_brush;
887  }
888 
891  void SetShowName(bool show)
892  {
893  m_showName = show;
894  }
895 
898  inline bool GetShowName() const
899  {
900  return m_showName;
901  }
902 
905  void SetDrawOutsideMargins(bool drawModeOutside)
906  {
907  m_drawOutsideMargins = drawModeOutside;
908  }
909 
913  {
914  return m_drawOutsideMargins;
915  }
916 
921  wxBitmap GetColourSquare(int side = 16);
922 
925  inline bool IsVisible() const
926  {
927  return m_visible;
928  }
929 
932  virtual void SetVisible(bool show)
933  {
934  m_visible = show;
935  }
936 
939  inline bool IsTractable() const
940  {
941  return m_tractable;
942  }
943 
946  virtual void SetTractable(bool track)
947  {
948  m_tractable = track;
949  }
950 
953  void SetAlign(int align)
954  {
955  m_flags = align;
956  }
957 
960  int GetAlign() const
961  {
962  return m_flags;
963  }
964 
967  void SetCanDelete(bool canDelete)
968  {
969  m_CanDelete = canDelete;
970  }
971 
974  bool GetCanDelete(void) const
975  {
976  return m_CanDelete;
977  }
978 
981  mpLayerZOrder GetZIndex(void) const
982  {
983  return m_ZIndex;
984  }
985 
986  protected:
987  const mpLayerType m_type;
989  int m_subtype;
990  wxFont m_font;
991  wxColour m_fontcolour;
992  wxPen m_pen;
993  wxBrush m_brush;
994  wxString m_name;
995  bool m_showName;
997  bool m_visible;
998  bool m_tractable;
999  int m_flags;
1002  mpLayerZOrder m_ZIndex;
1003 
1006  void UpdateContext(wxDC &dc) const;
1007 
1012  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1013 
1018  virtual bool DoBeforePlot()
1019  {
1020  return true;
1021  }
1022 
1029  void CheckLog(double *x, double *y, int yAxisID);
1030 
1031  private:
1032  bool m_busy;
1033  mpLayer() = delete; // default ctor not implemented/permitted
1034 
1035  wxDECLARE_DYNAMIC_CLASS(mpLayer);
1036 };
1037 
1038 //-----------------------------------------------------------------------------
1039 // mpInfoLayer
1040 //-----------------------------------------------------------------------------
1041 
1047 class WXDLLIMPEXP_MATHPLOT mpInfoLayer: public mpLayer
1048 {
1049  public:
1051  mpInfoLayer();
1052 
1057  mpInfoLayer(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1058 
1060  virtual ~mpInfoLayer();
1061 
1064  virtual void SetVisible(bool show);
1065 
1070  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1071 
1074  virtual bool HasBBox()
1075  {
1076  return false;
1077  }
1078 
1082  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1083 
1087  virtual bool Inside(const wxPoint &point);
1088 
1091  virtual void Move(wxPoint delta);
1092 
1094  virtual void UpdateReference();
1095 
1098  wxPoint GetPosition() const
1099  {
1100  return m_dim.GetPosition();
1101  }
1102 
1105  wxSize GetSize() const
1106  {
1107  return m_dim.GetSize();
1108  }
1109 
1112  const wxRect& GetRectangle() const
1113  {
1114  return m_dim;
1115  }
1116 
1119  void SetLocation(mpLocation location)
1120  {
1121  m_location = location;
1122  }
1123 
1126  mpLocation GetLocation() const
1127  {
1128  return m_location;
1129  }
1130 
1131  protected:
1132  wxRect m_dim;
1133  wxRect m_oldDim;
1134  wxBitmap* m_info_bmp;
1135  wxPoint m_reference;
1136  int m_winX, m_winY;
1137  mpLocation m_location;
1138 
1143  virtual void DoPlot(wxDC &dc, mpWindow &w);
1144 
1147  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1148 
1149  wxDECLARE_DYNAMIC_CLASS(mpInfoLayer);
1150 };
1151 
1156 class WXDLLIMPEXP_MATHPLOT mpInfoCoords: public mpInfoLayer
1157 {
1158  public:
1160  mpInfoCoords();
1161 
1163  mpInfoCoords(mpLocation location);
1164 
1169  mpInfoCoords(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1170 
1173  {
1174  ;
1175  }
1176 
1180  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1181 
1182  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1183 
1186  void SetLabelMode(unsigned int mode, unsigned int time_conv = mpX_RAWTIME)
1187  {
1188  m_labelType = mode;
1189  m_timeConv = time_conv;
1190  }
1191 
1194  void SetSeriesCoord(bool show)
1195  {
1196  m_series_coord = show;
1197  }
1198 
1201  bool IsSeriesCoord() const
1202  {
1203  return m_series_coord;
1204  }
1205 
1211  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::vector<double> yValList);
1212 
1215  void SetPenSeries(const wxPen &pen)
1216  {
1217  m_penSeries = pen;
1218  }
1219 
1220  protected:
1221  wxString m_content;
1222  unsigned int m_labelType;
1223  unsigned int m_timeConv;
1224  wxCoord m_mouseX;
1225  wxCoord m_mouseY;
1226  bool m_series_coord;
1227  wxPen m_penSeries;
1228 
1233  virtual void DoPlot(wxDC &dc, mpWindow &w);
1234 
1235  wxDECLARE_DYNAMIC_CLASS(mpInfoCoords);
1236 };
1237 
1242 class WXDLLIMPEXP_MATHPLOT mpInfoLegend: public mpInfoLayer
1243 {
1244  public:
1246  mpInfoLegend();
1247 
1253  mpInfoLegend(wxRect rect, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginNone);
1254 
1257 
1260  void SetItemMode(mpLegendStyle mode)
1261  {
1262  m_item_mode = mode;
1263  m_needs_update = true;
1264  }
1265 
1266  mpLegendStyle GetItemMode() const
1267  {
1268  return m_item_mode;
1269  }
1270 
1273  void SetItemDirection(mpLegendDirection mode)
1274  {
1275  m_item_direction = mode;
1276  m_needs_update = true;
1277  }
1278 
1279  mpLegendDirection GetItemDirection() const
1280  {
1281  return m_item_direction;
1282  }
1283 
1284  void SetNeedUpdate()
1285  {
1286  m_needs_update = true;
1287  }
1288 
1290  int GetPointed(mpWindow &w, wxPoint eventPoint);
1291 
1292  protected:
1293  mpLegendStyle m_item_mode;
1294  mpLegendDirection m_item_direction;
1295 
1300  virtual void DoPlot(wxDC &dc, mpWindow &w);
1301 
1302  private:
1304  struct LegendDetail
1305  {
1306  unsigned int layerIdx;
1307  wxCoord legendEnd;
1308  };
1310  std::vector<LegendDetail> m_LegendDetailList;
1311  bool m_needs_update;
1312 
1322  void UpdateBitmap(wxDC &dc, mpWindow &w);
1323 
1324  wxDECLARE_DYNAMIC_CLASS(mpInfoLegend);
1325 };
1326 
1327 //-----------------------------------------------------------------------------
1328 // mpLayer implementations - functions
1329 //-----------------------------------------------------------------------------
1330 
1338 class WXDLLIMPEXP_MATHPLOT mpFunction: public mpLayer
1339 {
1340  public:
1343  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1344 
1348  void SetContinuity(bool continuity)
1349  {
1350  m_continuous = continuity;
1351  }
1352 
1356  bool GetContinuity() const
1357  {
1358  return m_continuous;
1359  }
1360 
1363  void SetStep(unsigned int step)
1364  {
1365  m_step = step;
1366  }
1367 
1370  unsigned int GetStep() const
1371  {
1372  return m_step;
1373  }
1374 
1377  void SetSymbol(mpSymbol symbol)
1378  {
1379  m_symbol = symbol;
1380  }
1381 
1384  mpSymbol GetSymbol() const
1385  {
1386  return m_symbol;
1387  }
1388 
1391  void SetSymbolSize(int size)
1392  {
1393  m_symbolSize = size;
1394  m_symbolSize2 = size / 2;
1395  }
1396 
1399  int GetSymbolSize() const
1400  {
1401  return m_symbolSize;
1402  }
1403 
1407  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1408 
1412  int GetYAxisID() const
1413  {
1414  return m_yAxisID;
1415  }
1416 
1420  void SetYAxisID(unsigned int yAxisID)
1421  {
1422  m_yAxisID = yAxisID;
1423  }
1424 
1425  protected:
1427  mpSymbol m_symbol;
1430  unsigned int m_step;
1432 
1433  wxDECLARE_DYNAMIC_CLASS(mpFunction);
1434 };
1435 
1438 class WXDLLIMPEXP_MATHPLOT mpLine: public mpFunction
1439 {
1440  public:
1441  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1442 
1443  // We don't want to include line (horizontal or vertical) in BBox computation
1444  virtual bool HasBBox() override
1445  {
1446  return false;
1447  }
1448 
1452  double GetValue() const
1453  {
1454  return m_value;
1455  }
1456 
1460  void SetValue(const double value)
1461  {
1462  m_value = value;
1463  }
1464 
1467  bool IsHorizontal(void) const
1468  {
1469  return m_IsHorizontal;
1470  }
1471 
1472  protected:
1473  double m_value;
1474  bool m_IsHorizontal;
1475 
1476  wxDECLARE_DYNAMIC_CLASS(mpLine);
1477 };
1478 
1481 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine: public mpLine
1482 {
1483  public:
1484  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1485 
1489  void SetYValue(const double yvalue)
1490  {
1491  SetValue(yvalue);
1492  }
1493 
1494  protected:
1495 
1496  virtual void DoPlot(wxDC &dc, mpWindow &w);
1497 
1498  wxDECLARE_DYNAMIC_CLASS(mpHorizontalLine);
1499 };
1500 
1503 class WXDLLIMPEXP_MATHPLOT mpVerticalLine: public mpLine
1504 {
1505  public:
1506  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1507 
1511  void SetXValue(const double xvalue)
1512  {
1513  SetValue(xvalue);
1514  }
1515 
1516  protected:
1517 
1518  virtual void DoPlot(wxDC &dc, mpWindow &w);
1519 
1524  virtual bool DoBeforePlot()
1525  {
1526  return true;
1527  }
1528 
1529  wxDECLARE_DYNAMIC_CLASS(mpVerticalLine);
1530 };
1531 
1538 class WXDLLIMPEXP_MATHPLOT mpFX: public mpFunction
1539 {
1540  public:
1544  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
1545 
1551  virtual double GetY(double x) = 0;
1552 
1557  double DoGetY(double x);
1558 
1563  void DefineDoGetY(void);
1564 
1565  protected:
1566 
1567  // Pointer function to the appropriate DoGetY function
1568  double (mpFX::*pDoGetY)(double x);
1569 
1574  virtual void DoPlot(wxDC &dc, mpWindow &w);
1575 
1579  double NormalDoGetY(double x);
1580  double LogDoGetY(double x);
1581 
1582  wxDECLARE_DYNAMIC_CLASS(mpFX);
1583 };
1584 
1591 class WXDLLIMPEXP_MATHPLOT mpFY: public mpFunction
1592 {
1593  public:
1597  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
1598 
1604  virtual double GetX(double y) = 0;
1605 
1610  double DoGetX(double y);
1611 
1616  void DefineDoGetX(void);
1617 
1618  protected:
1619 
1620  // Pointer function to the appropriate DoGetX function
1621  double (mpFY::*pDoGetX)(double y);
1622 
1627  virtual void DoPlot(wxDC &dc, mpWindow &w);
1628 
1632  double NormalDoGetX(double y);
1633  double LogDoGetX(double y);
1634 
1635  wxDECLARE_DYNAMIC_CLASS(mpFY);
1636 };
1637 
1647 class WXDLLIMPEXP_MATHPLOT mpFXY: public mpFunction
1648 {
1649  public:
1653  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, unsigned int yAxisID = 0);
1654 
1658  virtual void Rewind() = 0;
1659 
1663  virtual void Clear()
1664  {
1665  ;
1666  }
1667 
1671  virtual int GetSize()
1672  {
1673  return 0;
1674  }
1675 
1682  virtual bool GetNextXY(double *x, double *y) = 0;
1683 
1687  bool DoGetNextXY(double *x, double *y);
1688 
1692  void SetViewMode(bool asBar);
1693 
1697  int GetBarWidth(void) const
1698  {
1699  return m_BarWidth;
1700  }
1701 
1705  bool ViewAsBar(void) const
1706  {
1707  return m_ViewAsBar;
1708  }
1709 
1710  protected:
1711 
1712  // Data to calculate label positioning
1713  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
1714 
1715  // Min delta between 2 x coordinate (used for view as bar)
1716  double m_deltaX, m_deltaY;
1717 
1718  // The width of a bar
1719  int m_BarWidth;
1720 
1721  // Plot data as bar graph
1722  bool m_ViewAsBar = false;
1723 
1728  virtual void DoPlot(wxDC &dc, mpWindow &w);
1729 
1734  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
1735 
1736  wxDECLARE_DYNAMIC_CLASS(mpFXY);
1737 };
1738 
1739 //-----------------------------------------------------------------------------
1740 // mpFXYVector - provided by Jose Luis Blanco
1741 //-----------------------------------------------------------------------------
1742 
1762 class WXDLLIMPEXP_MATHPLOT mpFXYVector: public mpFXY
1763 {
1764  public:
1768  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, unsigned int yAxisID = 0);
1769 
1772  virtual ~mpFXYVector()
1773  {
1774  Clear();
1775  }
1776 
1781  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
1782 
1786  void Clear();
1787 
1792  virtual int GetSize()
1793  {
1794  return m_xs.size();
1795  }
1796 
1804  bool AddData(const double x, const double y, bool updatePlot);
1805 
1811  void SetReserve(int reserve)
1812  {
1813  m_reserveXY = reserve;
1814  m_xs.reserve(m_reserveXY);
1815  m_ys.reserve(m_reserveXY);
1816  }
1817 
1820  int GetReserve() const
1821  {
1822  return m_reserveXY;
1823  }
1824 
1825  protected:
1828  std::vector<double> m_xs, m_ys;
1829 
1833 
1836  size_t m_index;
1837 
1840  double m_minX, m_maxX, m_minY, m_maxY, m_lastX, m_lastY;
1841 
1845  inline void Rewind()
1846  {
1847  m_index = 0;
1848  }
1849 
1855  virtual bool GetNextXY(double *x, double *y);
1856 
1859  void DrawAddedPoint(double x, double y);
1860 
1863  virtual double GetMinX()
1864  {
1865  if(m_ViewAsBar)
1866  {
1867  // Make extra space for outer bars
1868  return m_minX - (m_deltaX / 2);
1869  }
1870  else
1871  {
1872  return m_minX;
1873  }
1874  }
1875 
1878  virtual double GetMinY()
1879  {
1880  return m_minY;
1881  }
1882 
1885  virtual double GetMaxX()
1886  {
1887  if(m_ViewAsBar)
1888  {
1889  // Make extra space for outer bars
1890  return m_maxX + (m_deltaX / 2);
1891  }
1892  else
1893  {
1894  return m_maxX;
1895  }
1896  }
1897 
1900  virtual double GetMaxY()
1901  {
1902  return m_maxY;
1903  }
1904 
1905  private:
1908  void First_Point(double x, double y);
1909 
1912  void Check_Limit(double val, double *min, double *max, double *last, double *delta);
1913 
1914  wxDECLARE_DYNAMIC_CLASS(mpFXYVector);
1915 };
1916 
1925 class WXDLLIMPEXP_MATHPLOT mpProfile: public mpFunction
1926 {
1927  public:
1931  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
1932 
1938  virtual double GetY(double x) = 0;
1939 
1940  protected:
1941 
1946  virtual void DoPlot(wxDC &dc, mpWindow &w);
1947 
1948  wxDECLARE_DYNAMIC_CLASS(mpProfile);
1949 };
1950 
1951 //-----------------------------------------------------------------------------
1952 // mpChart
1953 //-----------------------------------------------------------------------------
1956 class WXDLLIMPEXP_MATHPLOT mpChart: public mpFunction
1957 {
1958  public:
1960  mpChart(const wxString &name = wxEmptyString);
1961 
1964  {
1965  Clear();
1966  }
1967 
1970  void SetChartValues(const std::vector<double> &data);
1971 
1974  void SetChartLabels(const std::vector<std::string> &labelArray);
1975 
1980  void AddData(const double &data, const std::string &label);
1981 
1985  virtual void Clear();
1986 
1987  virtual bool HasBBox()
1988  {
1989  return (values.size() > 0);
1990  }
1991 
1992  protected:
1993  std::vector<double> values;
1994  std::vector<std::string> labels;
1995 
1996  double m_max_value;
1997  double m_total_value;
1998 
1999  wxDECLARE_DYNAMIC_CLASS(mpChart);
2000 };
2001 
2002 //-----------------------------------------------------------------------------
2003 // mpBarChart - provided by Jose Davide Rondini
2004 //-----------------------------------------------------------------------------
2005 /* Defines for bar charts label positioning. */
2006 #define mpBAR_NONE 0
2007 #define mpBAR_AXIS_H 1
2008 #define mpBAR_AXIS_V 2
2009 #define mpBAR_INSIDE 3
2010 #define mpBAR_TOP 4
2011 
2012 
2014 class WXDLLIMPEXP_MATHPLOT mpBarChart: public mpChart
2015 {
2016  public:
2018  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2019 
2022  {
2023  Clear();
2024  }
2025 
2026  void SetBarColour(const wxColour &colour);
2027 
2028  void SetColumnWidth(const double colWidth)
2029  {
2030  m_width = colWidth;
2031  }
2032 
2034  void SetBarLabelPosition(int position);
2035 
2039  virtual double GetMinX();
2040 
2044  virtual double GetMaxX();
2045 
2049  virtual double GetMinY();
2050 
2054  virtual double GetMaxY();
2055 
2056  protected:
2057 
2058  double m_width;
2059  wxColour m_barColour;
2060  int m_labelPos;
2061  double m_labelAngle;
2062 
2067  virtual void DoPlot(wxDC &dc, mpWindow &w);
2068 
2069  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2070 };
2071 
2075 class WXDLLIMPEXP_MATHPLOT mpPieChart: public mpChart
2076 {
2077  public:
2079  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2080 
2083  {
2084  Clear();
2085  colours.clear();
2086  }
2087 
2091  void SetCenter(const wxPoint center)
2092  {
2093  m_center = center;
2094  }
2095 
2098  wxPoint GetCenter(void) const
2099  {
2100  return m_center;
2101  }
2102 
2106  void SetPieColours(const std::vector<wxColour> &colourArray);
2107 
2111  virtual double GetMinX()
2112  {
2113  return m_center.x - m_radius;
2114  }
2115 
2119  virtual double GetMaxX()
2120  {
2121  return m_center.x + m_radius;
2122  }
2123 
2127  virtual double GetMinY()
2128  {
2129  return m_center.y - m_radius;
2130  }
2131 
2135  virtual double GetMaxY()
2136  {
2137  return m_center.y + m_radius;
2138  }
2139 
2140  protected:
2141 
2142  double m_radius;
2143  wxPoint m_center;
2144  std::vector<wxColour> colours;
2145 
2150  virtual void DoPlot(wxDC &dc, mpWindow &w);
2151 
2152  const wxColour& GetColour(unsigned int id);
2153 
2154  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2155 };
2156 
2159 //-----------------------------------------------------------------------------
2160 // mpLayer implementations - furniture (scales, ...)
2161 //-----------------------------------------------------------------------------
2168 class WXDLLIMPEXP_MATHPLOT mpScale: public mpLayer
2169 {
2170  public:
2175  mpScale(const wxString &name, int flags, bool grids, std::optional<unsigned int> axisID = std::nullopt);
2176 
2180  virtual bool HasBBox()
2181  {
2182  return false;
2183  }
2184 
2188  int GetAxisID(void)
2189  {
2190  return m_axisID;
2191  }
2192 
2197  void SetAxisID(unsigned int yAxisID)
2198  {
2199  m_axisID = yAxisID;
2200  }
2201 
2204  void ShowTicks(bool ticks)
2205  {
2206  m_ticks = ticks;
2207  }
2208 
2211  bool GetShowTicks() const
2212  {
2213  return m_ticks;
2214  }
2215 
2218  void ShowGrids(bool grids)
2219  {
2220  m_grids = grids;
2221  }
2222 
2225  bool GetShowGrids() const
2226  {
2227  return m_grids;
2228  }
2229 
2232  virtual void SetLabelFormat(const wxString &format)
2233  {
2234  m_labelFormat = format;
2235  }
2236 
2239  const wxString& GetLabelFormat() const
2240  {
2241  return m_labelFormat;
2242  }
2243 
2247  void SetGridPen(const wxPen &pen)
2248  {
2249  m_gridpen = pen;
2250  }
2251 
2255  const wxPen& GetGridPen() const
2256  {
2257  return m_gridpen;
2258  }
2259 
2263  void SetAuto(bool automaticScalingIsEnabled)
2264  {
2265  m_auto = automaticScalingIsEnabled;
2266  }
2267 
2271  bool GetAuto() const
2272  {
2273  return m_auto;
2274  }
2275 
2276  void SetMinScale(double min)
2277  {
2278  m_min = min;
2279  }
2280 
2281  double GetMinScale() const
2282  {
2283  return m_min;
2284  }
2285 
2286  void SetMaxScale(double max)
2287  {
2288  m_max = max;
2289  }
2290 
2291  double GetMaxScale() const
2292  {
2293  return m_max;
2294  }
2295 
2296  void SetScale(double min, double max)
2297  {
2298  m_min = min;
2299  m_max = max;
2300  }
2301 
2302  void GetScale(double *min, double *max) const
2303  {
2304  *min = m_min;
2305  *max = m_max;
2306  }
2307 
2308  void SetScale(mpRange range)
2309  {
2310  m_min = range.min;
2311  m_max = range.max;
2312  }
2313 
2318  {
2319  return mpRange(m_min, m_max);
2320  }
2321 
2325  virtual bool IsLogAxis()
2326  {
2327  return m_isLog;
2328  }
2329 
2330  virtual void SetLogAxis(bool log)
2331  {
2332  m_isLog = log;
2333  }
2334 
2335  protected:
2336  static const wxCoord kTickSize = 4;
2337  static const wxCoord kAxisExtraSpace = 6;
2338 
2339  int m_axisID;
2340  wxPen m_gridpen;
2341  bool m_ticks;
2342  bool m_grids;
2343  bool m_auto;
2344  double m_min, m_max;
2345  wxString m_labelFormat;
2346  bool m_isLog;
2347 
2348  virtual int GetOrigin(mpWindow &w) = 0;
2349 
2356  double GetStep(double scale, int minLabelSpacing);
2357  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
2358 
2359  wxString FormatLogValue(double n);
2360 
2361  wxDECLARE_DYNAMIC_CLASS(mpScale);
2362 };
2363 
2365 #define mpX_NORMAL 0x00
2366 
2368 #define mpX_TIME 0x01
2369 
2370 #define mpX_HOURS 0x02
2371 
2372 #define mpX_DATE 0x03
2373 
2374 #define mpX_DATETIME 0x04
2375 
2376 #define mpX_USER 0x05
2377 
2378 #define mpX_NONE 0x06
2379 
2385 class WXDLLIMPEXP_MATHPLOT mpScaleX: public mpScale
2386 {
2387  public:
2393  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, unsigned int type = mpX_NORMAL) :
2394  mpScale(name, flags, grids)
2395  {
2396  m_subtype = mpsScaleX;
2397  m_labelType = type;
2398  m_timeConv = mpX_RAWTIME;
2399  }
2400 
2401  virtual void SetLabelFormat(const wxString &format)
2402  {
2403  mpScale::SetLabelFormat(format);
2404  m_labelType = mpX_USER;
2405  }
2406 
2409  unsigned int GetLabelMode() const
2410  {
2411  return m_labelType;
2412  }
2413 
2416  void SetLabelMode(unsigned int mode, unsigned int time_conv = mpX_RAWTIME)
2417  {
2418  m_labelType = mode;
2419  m_timeConv = time_conv;
2420  }
2421 
2422  bool IsTopAxis()
2423  {
2424  return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
2425  }
2426 
2427  bool IsBottomAxis()
2428  {
2429  return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
2430  }
2431 
2432  protected:
2433  unsigned int m_labelType;
2434  unsigned int m_timeConv;
2435 
2438  virtual void DoPlot(wxDC &dc, mpWindow &w);
2439 
2445  int GetLabelWidth(double value, wxDC &dc, wxString fmt);
2446 
2447  virtual int GetOrigin(mpWindow &w);
2448  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2449  wxString FormatValue(const wxString &fmt, double n);
2450 
2451  wxDECLARE_DYNAMIC_CLASS(mpScaleX);
2452 };
2453 
2460 class WXDLLIMPEXP_MATHPLOT mpScaleY: public mpScale
2461 {
2462  public:
2467  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, std::optional<unsigned int> yAxisID = std::nullopt) :
2468  mpScale(name, flags, grids, yAxisID)
2469  {
2470  m_subtype = mpsScaleY;
2471  m_axisWidth = Y_BORDER_SEPARATION;
2472  m_xPos = 0;
2473  }
2474 
2477  void UpdateAxisWidth(mpWindow &w);
2478 
2479  int GetAxisWidth()
2480  {
2481  return m_axisWidth;
2482  }
2483 
2484  bool IsLeftAxis()
2485  {
2486  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
2487  }
2488 
2489  bool IsRightAxis()
2490  {
2491  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
2492  }
2493 
2494  bool IsInside(wxCoord xPixel)
2495  {
2496  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
2497  {
2498  return true;
2499  }
2500  return false;
2501  }
2502 
2503  protected:
2504  int m_axisWidth;
2505  int m_xPos;
2506 
2509  virtual void DoPlot(wxDC &dc, mpWindow &w);
2510 
2511  virtual int GetOrigin(mpWindow &w);
2512  wxString GetLabelFormat(mpWindow &w);
2513  int GetLabelWidth(double value, wxDC &dc, wxString fmt);
2514  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2515 
2516  wxDECLARE_DYNAMIC_CLASS(mpScaleY);
2517 };
2518 
2519 //-----------------------------------------------------------------------------
2520 // mpWindow
2521 //-----------------------------------------------------------------------------
2522 
2527 #define mpMOUSEMODE_DRAG 0
2528 
2529 #define mpMOUSEMODE_ZOOMBOX 1
2530 
2533 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
2534 typedef std::deque<mpLayer*> mpLayerList;
2535 
2546 {
2547  mpScale* axis = nullptr;
2548  double scale = 1.0;
2549  double pos = 0;
2552 
2553  // Note: we don't use the default operator since we don't want to compare axis pointers
2554  bool operator==(const mpAxisData& other) const
2555  {
2556  return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
2557  (bound == other.bound) && (desired == other.desired);
2558  }
2559 };
2560 
2562 typedef std::map<int, mpAxisData> mpAxisList;
2563 
2570 typedef enum {
2571  uXAxis = 1,
2572  uYAxis = 2,
2573  uXYAxis = 3
2574 } mpAxisUpdate;
2575 
2582 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
2583 
2590 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
2591 
2597 {
2598  public:
2599  mpMagnet()
2600  {
2601  m_IsDrawn = false;
2602  m_rightClick = false;
2603  m_IsWasDrawn = false;
2604  }
2605  ~mpMagnet()
2606  {
2607  ;
2608  }
2609  void UpdateBox(wxCoord left, wxCoord top, wxCoord width, wxCoord height)
2610  {
2611  m_domain = wxRect(left, top, width, height);
2612  m_plot_size = wxRect(left, top, width + left, height + top);
2613  }
2614  void UpdateBox(const wxRect &size)
2615  {
2616  m_domain = size;
2617  m_plot_size = wxRect(size.GetLeft(), size.GetTop(),
2618  size.GetWidth() + size.GetLeft(), size.GetHeight() + size.GetTop());
2619  }
2620  void Plot(wxClientDC &dc, const wxPoint &mousePos);
2621  void ClearPlot(wxClientDC &dc);
2622  void UpdatePlot(wxClientDC &dc, const wxPoint &mousePos);
2623  void SaveDrawState(void)
2624  {
2625  m_IsWasDrawn = m_IsDrawn;
2626  // In any cases, set to false because we erase and repaint all the plot
2627  m_IsDrawn = false;
2628  }
2629 
2630  void SetRightClick(void)
2631  {
2632  m_rightClick = true;
2633  }
2634 
2635  private:
2636  wxRect m_domain;
2637  wxRect m_plot_size;
2638  wxPoint m_mousePosition;
2639  bool m_IsDrawn;
2640  bool m_IsWasDrawn;
2641  bool m_rightClick;
2642  void DrawCross(wxClientDC &dc) const;
2643 };
2644 
2666 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
2667 {
2668  public:
2669  mpWindow()
2670  {
2671  InitParameters();
2672  }
2673 
2674  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
2675  long flags = 0);
2676 
2677  ~mpWindow();
2678 
2682  wxMenu* GetPopupMenu()
2683  {
2684  return &m_popmenu;
2685  }
2686 
2695  bool AddLayer(mpLayer *layer, bool refreshDisplay = true, bool refreshConfig = true);
2696 
2709  bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
2710 
2716  void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
2717 
2724  void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
2725 
2732  void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
2733 
2739  mpLayer* GetLayer(int position);
2740 
2745  int GetLayerPosition(mpLayer* layer);
2746 
2753  mpLayer* GetLayersType(int position, mpLayerType type);
2754 
2760  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
2761 
2764  mpLayer* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
2765 
2770  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
2771 
2775  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
2776 
2781  mpLayer* GetLayerByName(const wxString &name);
2782 
2787  mpLayer* GetLayerByClassName(const wxString &name);
2788 
2792  void RefreshLegend(void);
2793 
2798  bool IsYAxisUsed(int yAxisID);
2799 
2803  mpScaleX* GetLayerXAxis();
2804 
2808  mpScaleY* GetLayerYAxis(int yAxisID);
2809 
2813  void SetScaleX(const double scaleX)
2814  {
2815  if (ISNOTNULL(scaleX))
2816  {
2817  m_AxisDataX.scale = scaleX;
2818  UpdateDesiredBoundingBox(uXAxis);
2819  }
2820  UpdateAll();
2821  }
2822 
2827  double GetScaleX(void) const
2828  {
2829  return m_AxisDataX.scale;
2830  }
2831 
2836  void SetScaleY(const double scaleY, int yAxisID)
2837  {
2838  assert(m_AxisDataYList.count(yAxisID) != 0);
2839  if (ISNOTNULL(scaleY))
2840  {
2841  m_AxisDataYList[yAxisID].scale = scaleY;
2842  UpdateDesiredBoundingBox(uYAxis);
2843  }
2844  UpdateAll();
2845  }
2846 
2852  double GetScaleY(int yAxisID)
2853  {
2854  assert(m_AxisDataYList.count(yAxisID) != 0);
2855  return m_AxisDataYList[yAxisID].scale;
2856  } // Schaling's method: maybe another method exists with the same name
2857 
2858  [[deprecated("Incomplete, use UpdateBBox instead")]]
2861  void SetBound();
2862 
2864  mpRange Get_BoundX(void) const
2865  {
2866  return m_AxisDataX.bound;
2867  }
2868 
2872  mpRange Get_BoundY(int yAxisID)
2873  {
2874  assert(m_AxisDataYList.count(yAxisID) != 0);
2875  return m_AxisDataYList[yAxisID].bound;
2876  }
2877 
2881  void SetPosX(const double posX)
2882  {
2883  m_AxisDataX.pos = posX;
2884  UpdateDesiredBoundingBox(uXAxis);
2885  UpdateAll();
2886  }
2887 
2892  double GetPosX(void) const
2893  {
2894  return m_AxisDataX.pos;
2895  }
2896 
2901  void SetPosY(const std::vector<double>& posYList)
2902  {
2903  int i = 0;
2904  for (auto& axisDataY : m_AxisDataYList)
2905  {
2906  axisDataY.second.pos = posYList[i];
2907  i++;
2908  }
2909  UpdateDesiredBoundingBox(uYAxis);
2910  UpdateAll();
2911  }
2912 
2918  double GetPosY(int yAxisID)
2919  {
2920  assert(m_AxisDataYList.count(yAxisID) != 0);
2921  return m_AxisDataYList[yAxisID].pos;
2922  }
2923 
2927  int GetNOfYAxis(void) const
2928  {
2929  return (int)m_AxisDataYList.size();
2930  }
2931 
2932  mpAxisList GetAxisDataYList(void) const
2933  {
2934  return m_AxisDataYList;
2935  }
2936 
2942  void SetScreen(const int scrX, const int scrY)
2943  {
2944  m_scrX = scrX;
2945  m_scrY = scrY;
2946  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
2947  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
2948 
2949  m_plotBoundaries.endPx = m_scrX;
2950  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
2951  m_plotBoundaries.endPy = m_scrY;
2952  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
2953 
2954  m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
2955  m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
2956 
2957  m_magnet.UpdateBox(m_PlotArea);
2958  }
2959 
2966  int GetScreenX(void) const
2967  {
2968  return m_scrX;
2969  }
2970 
2977  int GetScreenY(void) const
2978  {
2979  return m_scrY;
2980  }
2981 
2987  void SetPos(const double posX, const std::vector<double>& posYList)
2988  {
2989  m_AxisDataX.pos = posX;
2990  SetPosY(posYList);
2991  }
2992 
2996  inline double p2x(const wxCoord pixelCoordX) const
2997  {
2998  return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
2999  }
3000 
3004  inline double p2y(const wxCoord pixelCoordY, int yAxisID = 0)
3005  {
3006  assert(m_AxisDataYList.count(yAxisID) != 0);
3007  if (m_AxisDataYList.count(yAxisID) == 0)
3008  return 0.0;
3009  return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3010  }
3011 
3015  inline wxCoord x2p(const double x) const
3016  {
3017  return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3018  }
3019 
3023  inline wxCoord y2p(const double y, int yAxisID = 0)
3024  {
3025  assert(m_AxisDataYList.count(yAxisID) != 0);
3026  if (m_AxisDataYList.count(yAxisID) == 0)
3027  return 0;
3028  return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3029  }
3030 
3033  void EnableDoubleBuffer(const bool enabled)
3034  {
3035  m_enableDoubleBuffer = enabled;
3036  }
3037 
3040  void EnableMousePanZoom(const bool enabled)
3041  {
3042  m_enableMouseNavigation = enabled;
3043  }
3044 
3050  void LockAspect(bool enable = true);
3051 
3056  inline bool IsAspectLocked() const
3057  {
3058  return m_lockaspect;
3059  }
3060 
3065  inline bool IsRepainting() const
3066  {
3067  return m_repainting;
3068  }
3069 
3074  void Fit();
3075 
3082  void Fit(const mpRange &rangeX, const std::vector<mpRange> &rangeY, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
3083 
3087  void FitX(void);
3088 
3093  void FitY(int yAxisID);
3094 
3099  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
3100 
3105  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
3106 
3108  void ZoomInX();
3109 
3111  void ZoomOutX();
3112 
3115  void ZoomInY(std::optional<int> yAxisID = std::nullopt);
3116 
3119  void ZoomOutY(std::optional<int> yAxisID = std::nullopt);
3120 
3122  void ZoomRect(wxPoint p0, wxPoint p1);
3123 
3125  void UpdateAll();
3126 
3127  // Added methods by Davide Rondini
3128 
3132  unsigned int CountLayers();
3133 
3136  unsigned int CountAllLayers()
3137  {
3138  return (unsigned int)m_layers.size();
3139  }
3140 
3144  unsigned int CountLayersType(mpLayerType type);
3145  unsigned int CountLayersFXYPlot();
3146 
3149  //void PrintGraph(mpPrintout *print);
3150 
3158  {
3159  mpRange lastRange;
3160  // Change on X axis
3161  if ((update & uXAxis) == uXAxis)
3162  {
3163  if (!m_desiredChanged)
3164  lastRange = m_AxisDataX.desired;
3165  m_AxisDataX.desired.Assign(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale),
3166  m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3167  m_desiredChanged = !(lastRange == m_AxisDataX.desired);
3168  }
3169 
3170  // Change on Y axis
3171  if ((update & uYAxis) == uYAxis)
3172  {
3173  for (auto& axisDataY : m_AxisDataYList)
3174  {
3175  mpAxisData *yAxis = &axisDataY.second;
3176  if (!m_desiredChanged)
3177  lastRange = yAxis->desired;
3178  yAxis->desired.Assign(yAxis->pos - (m_margin.top / yAxis->scale),
3179  yAxis->pos - ((m_margin.top + m_plotHeight) / yAxis->scale));
3180  if (!m_desiredChanged)
3181  m_desiredChanged = !(lastRange == yAxis->desired);
3182  }
3183  }
3184  }
3185 
3191  mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID = 0)
3192  {
3193  assert(m_AxisDataYList.count(yAxisID) != 0);
3194  if (desired)
3195  return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
3196  else
3197  return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
3198  }
3199 
3203  double GetDesiredXmin() const
3204  {
3205  return m_AxisDataX.desired.min;
3206  }
3207 
3212  double GetDesiredXmax() const
3213  {
3214  return m_AxisDataX.desired.max;
3215  }
3216 
3222  double GetDesiredYmin(int yAxisID)
3223  {
3224  assert(m_AxisDataYList.count(yAxisID) != 0);
3225  return m_AxisDataYList[yAxisID].desired.min;
3226  }
3227 
3233  double GetDesiredYmax(int yAxisID)
3234  {
3235  assert(m_AxisDataYList.count(yAxisID) != 0);
3236  return m_AxisDataYList[yAxisID].desired.max;
3237  }
3238 
3240  bool GetBoundingBox(mpRange *boundX, mpRange *boundY, int yAxisID)
3241  {
3242  if (m_AxisDataYList.count(yAxisID) == 0)
3243  return false;
3244  *boundX = m_AxisDataX.bound;
3245  *boundY = m_AxisDataYList[yAxisID].bound;
3246  return true;
3247  }
3248 
3249  // Is this point inside the bounding box
3250  bool PointIsInsideBound(double px, double py, int yAxisID)
3251  {
3252  if (m_AxisDataYList.count(yAxisID) == 0)
3253  return false;
3254 
3255  return m_AxisDataX.bound.PointIsInside(px) && Get_BoundY(yAxisID).PointIsInside(py);
3256  }
3257 
3258  /* Update bounding box (X and Y axis) to include this point.
3259  * Expand the range to include the point.
3260  * @param px: point on x-axis
3261  * @param py: point on y-axis
3262  * @param yAxisID: the y-axis ID
3263  */
3264  void UpdateBoundingBoxToInclude(double px, double py, int yAxisID)
3265  {
3266  if (m_AxisDataYList.count(yAxisID) == 0)
3267  return ;
3268 
3269  m_AxisDataX.bound.Update(px);
3270  m_AxisDataYList[yAxisID].bound.Update(py);
3271  }
3272 
3273  /* Initialize bounding box with an initial point
3274  * @param px: point on x-axis
3275  * @param py: point on y-axis
3276  * @param yAxisID: the y-axis ID
3277  */
3278  void InitializeBoundingBox(double px, double py, int yAxisID)
3279  {
3280  if (m_AxisDataYList.count(yAxisID) == 0)
3281  return ;
3282 
3283  m_AxisDataX.bound.Set(px, px);
3284  m_AxisDataYList[yAxisID].bound.Set(py, py);
3285  }
3286 
3289  void SetMPScrollbars(bool status);
3290 
3293  bool GetMPScrollbars() const
3294  {
3295  return m_enableScrollBars;
3296  }
3297 
3303  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
3304 
3308  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3309 
3313  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3314 
3319  bool LoadFile(const wxString &filename);
3320 
3324 
3331  void SetMargins(int top, int right, int bottom, int left);
3332 
3335  {
3336  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3337  }
3338 
3340  void SetMarginTop(int top)
3341  {
3342  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3343  }
3344 
3348  int GetMarginTop(bool minusExtra = false) const
3349  {
3350  if (minusExtra)
3351  return m_margin.top - m_extraMargin;
3352  else
3353  return m_margin.top;
3354  }
3355 
3357  void SetMarginRight(int right)
3358  {
3359  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
3360  }
3361 
3365  int GetMarginRight(bool minusExtra = false) const
3366  {
3367  if (minusExtra)
3368  return m_margin.right - m_extraMargin;
3369  else
3370  return m_margin.right;
3371  }
3372 
3375  {
3376  return m_marginOuter.right;
3377  }
3378 
3380  void SetMarginBottom(int bottom)
3381  {
3382  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
3383  }
3384 
3388  int GetMarginBottom(bool minusExtra = false) const
3389  {
3390  if (minusExtra)
3391  return m_margin.bottom - m_extraMargin;
3392  else
3393  return m_margin.bottom;
3394  }
3395 
3397  void SetMarginLeft(int left)
3398  {
3399  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
3400  }
3401 
3405  int GetMarginLeft(bool minusExtra = false) const
3406  {
3407  if (minusExtra)
3408  return m_margin.left - m_extraMargin;
3409  else
3410  return m_margin.left;
3411  }
3412 
3414  void SetExtraMargin(int extra)
3415  {
3416  m_extraMargin = extra;
3417  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3418  }
3419 
3421  int GetExtraMargin() const
3422  {
3423  return m_extraMargin;
3424  }
3425 
3428  {
3429  return m_marginOuter.left;
3430  }
3431 
3433  int GetPlotWidth() const
3434  {
3435  return m_plotWidth;
3436  }
3437 
3439  int GetPlotHeight() const
3440  {
3441  return m_plotHeight;
3442  }
3443 
3448  mpRect GetPlotBoundaries(bool with_margin) const
3449  {
3450  mpRect bond;
3451  if (with_margin)
3452  bond = m_plotBoundariesMargin;
3453  else
3454  bond = m_plotBoundaries;
3455  bond.startPx -= m_extraMargin;
3456  bond.endPx += m_extraMargin;
3457  bond.startPy -= m_extraMargin;
3458  bond.endPy += m_extraMargin;
3459  return bond;
3460  }
3461 
3465  int GetLeftYAxesWidth(std::optional<int> yAxisID = std::nullopt);
3466 
3470  int GetRightYAxesWidth(std::optional<int> yAxisID = std::nullopt);
3471 
3473  void SetDrawBox(bool drawbox)
3474  {
3475  m_drawBox = drawbox;
3476  }
3477 
3479  bool GetDrawBox() const
3480  {
3481  return m_drawBox;
3482  }
3483 
3487  std::optional<int> IsInsideYAxis(const wxPoint &point);
3488 
3492  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
3493 
3497  void SetLayerVisible(const wxString &name, bool viewable);
3498 
3502  bool IsLayerVisible(const wxString &name);
3503 
3507  bool IsLayerVisible(const unsigned int position);
3508 
3512  void SetLayerVisible(const unsigned int position, bool viewable);
3513 
3518  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
3519 
3522  const wxColour& GetAxesColour() const
3523  {
3524  return m_axColour;
3525  }
3526 
3527  const wxColour& GetbgColour() const
3528  {
3529  return m_bgColour;
3530  }
3531 
3532  void SetbgColour(const wxColour &colour)
3533  {
3534  m_bgColour = colour;
3535  }
3536 
3541  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
3542  {
3543  m_OnDeleteLayer = event;
3544  }
3545 
3548  {
3549  m_OnDeleteLayer = NULL;
3550  }
3551 
3556  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
3557  {
3558  m_OnUserMouseAction = userMouseEventHandler;
3559  }
3560 
3563  {
3564  m_OnUserMouseAction = NULL;
3565  }
3566 
3572  bool IsLogXaxis()
3573  {
3574  if (m_AxisDataX.axis)
3575  return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
3576  else
3577  return false;
3578  }
3579 
3583  bool IsLogYaxis(int yAxisID)
3584  {
3585  assert(m_AxisDataYList.count(yAxisID) != 0);
3586  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
3587  if (yAxis)
3588  return yAxis->IsLogAxis();
3589  else
3590  return false;
3591  }
3592 
3593  void SetLogXaxis(bool log)
3594  {
3595  if (m_AxisDataX.axis)
3596  ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
3597  }
3598 
3602  void SetLogYaxis(int yAxisID, bool log)
3603  {
3604  mpScaleY* yAxis = GetLayerYAxis(yAxisID);
3605  if (yAxis)
3606  yAxis->SetLogAxis(log);
3607  }
3608 
3614  bool GetMagnetize() const
3615  {
3616  return m_magnetize;
3617  }
3618 
3619  void SetMagnetize(bool mag)
3620  {
3621  m_magnetize = mag;
3622  }
3623 
3628  void SetMouseLeftDownAction(mpMouseButtonAction action)
3629  {
3630  m_mouseLeftDownAction = action;
3631  }
3632 
3637  mpMouseButtonAction GetMouseLeftDownAction()
3638  {
3639  return m_mouseLeftDownAction;
3640  }
3641 
3642 #ifdef ENABLE_MP_CONFIG
3643  void RefreshConfigWindow();
3648  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
3649 #endif // ENABLE_MP_CONFIG
3650 
3651  protected:
3652  virtual void OnPaint(wxPaintEvent &event);
3653  virtual void OnSize(wxSizeEvent &event);
3654  virtual void OnShowPopupMenu(wxMouseEvent &event);
3655  virtual void OnCenter(wxCommandEvent &event);
3656  virtual void OnFit(wxCommandEvent &event);
3657  virtual void OnToggleGrids(wxCommandEvent &event);
3658  virtual void OnToggleCoords(wxCommandEvent &event);
3659  virtual void OnScreenShot(wxCommandEvent &event);
3660  virtual void OnFullScreen(wxCommandEvent &event);
3661 #ifdef ENABLE_MP_CONFIG
3662  virtual void OnConfiguration(wxCommandEvent &event);
3663 #endif // ENABLE_MP_CONFIG
3664  virtual void OnLoadFile(wxCommandEvent &event);
3665  virtual void OnZoomIn(wxCommandEvent &event);
3666  virtual void OnZoomOut(wxCommandEvent &event);
3667  virtual void OnLockAspect(wxCommandEvent &event);
3668  virtual void OnMouseHelp(wxCommandEvent &event);
3669  virtual void OnMouseLeftDown(wxMouseEvent &event);
3670  virtual void OnMouseRightDown(wxMouseEvent &event);
3671  virtual void OnMouseMove(wxMouseEvent &event);
3672  virtual void OnMouseLeftRelease(wxMouseEvent &event);
3673  virtual void OnMouseWheel(wxMouseEvent &event);
3674  virtual void OnMouseLeave(wxMouseEvent &event);
3675  bool CheckUserMouseAction(wxMouseEvent &event);
3676  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
3677  virtual void OnScrollPageUp(wxScrollWinEvent &event);
3678  virtual void OnScrollPageDown(wxScrollWinEvent &event);
3679  virtual void OnScrollLineUp(wxScrollWinEvent &event);
3680  virtual void OnScrollLineDown(wxScrollWinEvent &event);
3681  virtual void OnScrollTop(wxScrollWinEvent &event);
3682  virtual void OnScrollBottom(wxScrollWinEvent &event);
3683 
3684  void DoScrollCalc(const int position, const int orientation);
3685 
3690  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = ZOOM_AROUND_CENTER);
3691 
3698  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = ZOOM_AROUND_CENTER, std::optional<int> = std::nullopt);
3699 
3704  void SetScaleXAndCenter(double scaleX);
3705 
3711  void SetScaleYAndCenter(double scaleY, int yAxisID);
3712 
3713  void Zoom(bool zoomIn, const wxPoint &centerPoint);
3714 
3717  virtual bool UpdateBBox();
3718 
3719  void InitParameters();
3720 
3721  wxTopLevelWindow* m_parent;
3722  bool m_fullscreen;
3723 
3724  mpLayerList m_layers;
3726  mpAxisList m_AxisDataYList;
3727  bool m_desiredChanged = false;
3728 
3729  wxMenu m_popmenu;
3731  wxColour m_bgColour;
3732  wxColour m_fgColour;
3733  wxColour m_axColour;
3734  bool m_drawBox;
3735 
3736  int m_scrX;
3737  int m_scrY;
3740 
3744  wxCoord m_plotWidth;
3745  wxCoord m_plotHeight;
3746 
3749  wxRect m_PlotArea;
3750 
3751  bool m_repainting;
3752  int m_last_lx, m_last_ly;
3753  wxBitmap* m_buff_bmp;
3756  mpMouseButtonAction m_mouseLeftDownAction;
3757  bool m_mouseMovedAfterRightClick;
3758  wxPoint m_mouseRClick;
3759  wxPoint m_mouseLClick;
3760  double m_mouseScaleX;
3761  std::vector<double> m_mouseScaleYList;
3762  std::optional<int> m_mouseYAxisID;
3763  bool m_enableScrollBars;
3764  int m_scrollX, m_scrollY;
3768  bool m_InInfoLegend;
3769 
3770  wxBitmap* m_zoom_bmp;
3771  wxRect m_zoom_dim;
3772  wxRect m_zoom_oldDim;
3773 
3776 
3777  wxBitmap* m_Screenshot_bmp;
3778 
3779 #ifdef ENABLE_MP_CONFIG
3780  MathPlotConfigDialog* m_configWindow = NULL;
3781 #endif // ENABLE_MP_CONFIG
3782 
3783  mpOnDeleteLayer m_OnDeleteLayer = NULL;
3784  mpOnUserMouseAction m_OnUserMouseAction = NULL;
3785 
3789  virtual void DesiredBoundsHaveChanged() {};
3790 
3791  private:
3792  void FillI18NString();
3793  unsigned int GetNewAxisDataID(void)
3794  {
3795  while (m_AxisDataYList.count(m_LastAxisDataID) != 0)
3796  {
3797  m_LastAxisDataID++;
3798  }
3799  return m_LastAxisDataID;
3800  }
3801 
3802  unsigned int m_LastAxisDataID = 0; // Last known ID to assign to each new y-axis
3803 
3804  wxDECLARE_DYNAMIC_CLASS(mpWindow);
3805  wxDECLARE_EVENT_TABLE();
3806 
3807  // To have direct access to m_Screenshot_dc
3808  friend mpPrintout;
3809 };
3810 
3811 //-----------------------------------------------------------------------------
3812 // mpText - provided by Val Greene
3813 //-----------------------------------------------------------------------------
3814 
3822 class WXDLLIMPEXP_MATHPLOT mpText: public mpLayer
3823 {
3824  public:
3827  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
3828  {
3829  m_subtype = mptText;
3830  SetName(name);
3831  m_offsetx = 5;
3832  m_offsety = 50;
3833  m_location = mpMarginNone;
3834  m_ZIndex = mpZIndex_TEXT;
3835  }
3836 
3840  mpText(const wxString &name, int offsetx, int offsety);
3841 
3845  mpText(const wxString &name, mpLocation marginLocation);
3846 
3849  virtual bool HasBBox()
3850  {
3851  return false;
3852  }
3853 
3856  void SetLocation(mpLocation location)
3857  {
3858  m_location = location;
3859  }
3860 
3863  mpLocation GetLocation() const
3864  {
3865  return m_location;
3866  }
3867 
3870  void SetOffset(int offX, int offY)
3871  {
3872  m_offsetx = offX;
3873  m_offsety = offY;
3874  }
3875 
3877  void GetOffset(int *offX, int *offY) const
3878  {
3879  *offX = m_offsetx;
3880  *offY = m_offsety;
3881  }
3882 
3883  protected:
3886  mpLocation m_location;
3887 
3890  virtual void DoPlot(wxDC &dc, mpWindow &w);
3891 
3892  wxDECLARE_DYNAMIC_CLASS(mpText);
3893 };
3894 
3898 class WXDLLIMPEXP_MATHPLOT mpTitle: public mpText
3899 {
3900  public:
3903  mpTitle();
3904 
3907  mpTitle(const wxString &name) :
3908  mpText(name, mpMarginTopCenter)
3909  {
3910  m_subtype = mptTitle;
3911  SetPen(*wxWHITE_PEN);
3912  SetBrush(*wxWHITE_BRUSH);
3913  }
3914 
3915  protected:
3916 
3917  wxDECLARE_DYNAMIC_CLASS(mpTitle);
3918 };
3919 
3920 //-----------------------------------------------------------------------------
3921 // mpPrintout - provided by Davide Rondini
3922 //-----------------------------------------------------------------------------
3923 
3928 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
3929 {
3930  public:
3931  mpPrintout()
3932  {
3933  plotWindow = NULL;
3934  drawn = false;
3935  stretch_factor = 2;
3936  }
3937 
3938  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
3939  virtual ~mpPrintout()
3940  {
3941  ;
3942  }
3943 
3944  void SetDrawState(bool drawState)
3945  {
3946  drawn = drawState;
3947  }
3948 
3949  bool OnPrintPage(int page);
3950  bool HasPage(int page);
3951 
3954  void SetFactor(int factor)
3955  {
3956  stretch_factor = factor;
3957  }
3958 
3959  private:
3960  bool drawn;
3961  mpWindow* plotWindow;
3962  int stretch_factor; // To reduce the size of plot
3963 
3964  protected:
3965 
3966  wxDECLARE_DYNAMIC_CLASS(mpPrintout);
3967 };
3968 
3969 //-----------------------------------------------------------------------------
3970 // mpMovableObject - provided by Jose Luis Blanco
3971 //-----------------------------------------------------------------------------
3979 class WXDLLIMPEXP_MATHPLOT mpMovableObject: public mpFunction
3980 {
3981  public:
3985  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
3986  {
3987  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
3988  m_subtype = mpfMovable;
3989  m_bbox_min_x = m_bbox_max_x = 0;
3990  m_bbox_min_y = m_bbox_max_y = 0;
3991  }
3992 
3993  virtual ~mpMovableObject() {}
3994 
3997  void GetCoordinateBase(double &x, double &y, double &phi) const
3998  {
3999  x = m_reference_x;
4000  y = m_reference_y;
4001  phi = m_reference_phi;
4002  }
4003 
4006  void SetCoordinateBase(double x, double y, double phi = 0)
4007  {
4008  m_reference_x = x;
4009  m_reference_y = y;
4010  m_reference_phi = phi;
4011  m_flags = mpALIGN_NE;
4012  ShapeUpdated();
4013  }
4014 
4015  virtual bool HasBBox()
4016  {
4017  return m_trans_shape_xs.size() != 0;
4018  }
4019 
4022  virtual double GetMinX()
4023  {
4024  return m_bbox_min_x;
4025  }
4026 
4029  virtual double GetMaxX()
4030  {
4031  return m_bbox_max_x;
4032  }
4033 
4036  virtual double GetMinY()
4037  {
4038  return m_bbox_min_y;
4039  }
4040 
4043  virtual double GetMaxY()
4044  {
4045  return m_bbox_max_y;
4046  }
4047 
4048  protected:
4049 
4052  double m_reference_x, m_reference_y, m_reference_phi;
4053 
4054  virtual void DoPlot(wxDC &dc, mpWindow &w);
4055 
4058  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
4059 
4062  std::vector<double> m_shape_xs, m_shape_ys;
4063 
4067  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
4068 
4072  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
4073 
4077  void ShapeUpdated();
4078 
4079  wxDECLARE_DYNAMIC_CLASS(mpMovableObject);
4080 };
4081 
4082 //-----------------------------------------------------------------------------
4083 // mpCovarianceEllipse - provided by Jose Luis Blanco
4084 //-----------------------------------------------------------------------------
4096 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse: public mpMovableObject
4097 {
4098  public:
4102  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
4103  const wxString &layerName = _T("")) : mpMovableObject(),
4104  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
4105  {
4106  m_continuous = true;
4107  m_name = layerName;
4108  RecalculateShape();
4109  }
4110 
4111  virtual ~mpCovarianceEllipse()
4112  {
4113  ;
4114  }
4115 
4116  double GetQuantiles() const
4117  {
4118  return m_quantiles;
4119  }
4120 
4123  void SetQuantiles(double q)
4124  {
4125  m_quantiles = q;
4126  RecalculateShape();
4127  }
4128 
4129  void SetSegments(int segments)
4130  {
4131  m_segments = segments;
4132  }
4133 
4134  int GetSegments() const
4135  {
4136  return m_segments;
4137  }
4138 
4141  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
4142  {
4143  cov_00 = m_cov_00;
4144  cov_01 = m_cov_01;
4145  cov_11 = m_cov_11;
4146  }
4147 
4150  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
4151  {
4152  m_cov_00 = cov_00;
4153  m_cov_01 = cov_01;
4154  m_cov_11 = cov_11;
4155  RecalculateShape();
4156  }
4157 
4158  protected:
4161  double m_cov_00, m_cov_11, m_cov_01;
4162  double m_quantiles;
4163 
4167 
4170  void RecalculateShape();
4171 
4172  wxDECLARE_DYNAMIC_CLASS(mpCovarianceEllipse);
4173 };
4174 
4175 //-----------------------------------------------------------------------------
4176 // mpPolygon - provided by Jose Luis Blanco
4177 //-----------------------------------------------------------------------------
4182 class WXDLLIMPEXP_MATHPLOT mpPolygon: public mpMovableObject
4183 {
4184  public:
4187  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
4188  {
4189  m_continuous = true;
4190  m_name = layerName;
4191  }
4192 
4193  virtual ~mpPolygon()
4194  {
4195  ;
4196  }
4197 
4203  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
4204 
4205  protected:
4206 
4207  wxDECLARE_DYNAMIC_CLASS(mpPolygon);
4208 };
4209 
4210 //-----------------------------------------------------------------------------
4211 // mpBitmapLayer - provided by Jose Luis Blanco
4212 //-----------------------------------------------------------------------------
4217 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer: public mpLayer
4218 {
4219  public:
4223  {
4224  m_min_x = m_max_x = 0;
4225  m_min_y = m_max_y = 0;
4226  m_validImg = false;
4227  m_bitmapChanged = false;
4228  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
4229  }
4230 
4231  virtual ~mpBitmapLayer()
4232  {
4233  ;
4234  }
4235 
4238  void GetBitmapCopy(wxImage &outBmp) const;
4239 
4247  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
4248 
4251  virtual double GetMinX()
4252  {
4253  return m_min_x;
4254  }
4255 
4258  virtual double GetMaxX()
4259  {
4260  return m_max_x;
4261  }
4262 
4265  virtual double GetMinY()
4266  {
4267  return m_min_y;
4268  }
4269 
4272  virtual double GetMaxY()
4273  {
4274  return m_max_y;
4275  }
4276 
4277  protected:
4278 
4281  wxImage m_bitmap;
4282  wxBitmap m_scaledBitmap;
4283  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
4284  bool m_validImg;
4285  bool m_bitmapChanged;
4286 
4289  double m_min_x, m_max_x, m_min_y, m_max_y;
4290 
4291  virtual void DoPlot(wxDC &dc, mpWindow &w);
4292 
4293  wxDECLARE_DYNAMIC_CLASS(mpBitmapLayer);
4294 };
4295 
4296 // utility class
4297 
4298 // Enumeration of classic colour
4299 typedef enum __mp_Colour
4300 {
4301  mpBlue,
4302  mpRed,
4303  mpGreen,
4304  mpPurple,
4305  mpYellow,
4306  mpFuchsia,
4307  mpLime,
4308  mpAqua,
4309  mpOlive
4310 } mpColour;
4311 
4316 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
4317 {
4318  public:
4319  wxIndexColour(unsigned int id)
4320  {
4321  switch (id)
4322  {
4323  case 0:
4324  this->Set(0, 0, 255);
4325  break; // Blue
4326  case 1:
4327  this->Set(255, 0, 0);
4328  break; // Red
4329  case 2:
4330  this->Set(0, 128, 0);
4331  break; // Green
4332  case 3:
4333  this->Set(128, 0, 128);
4334  break; // Purple
4335  case 4:
4336  this->Set(255, 255, 0);
4337  break; // Yellow
4338  case 5:
4339  this->Set(255, 0, 255);
4340  break; // Fuchsia
4341  case 6:
4342  this->Set(0, 255, 0);
4343  break; // Lime
4344  case 7:
4345  this->Set(0, 255, 255);
4346  break; // Aqua/Cyan
4347  case 8:
4348  this->Set(128, 128, 0);
4349  break; // Olive
4350  default:
4351  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
4352  (ChannelType)((rand() * 255) / RAND_MAX));
4353  }
4354  }
4355 };
4356 
4359 // ---------------------------------------------------------------------
4360 #ifdef ENABLE_MP_NAMESPACE
4361  }// namespace MathPlot
4362  // No, iff build enables namespace, its up to app to use it appropriately: using namespace MathPlot;
4363 #endif // ENABLE_MP_NAMESPACE
4364 
4365 #endif // MATHPLOT_H_INCLUDED
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:3885
const wxString & GetLabelFormat() const
Get axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:2239
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer Use like this : your_plot->SetOnDeleteLayer([this](void *S...
Definition: mathplot.h:2582
bool IsHorizontal(void) const
Get if is horizontal line.
Definition: mathplot.h:1467
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:496
int GetAxisID(void)
Return the ID of the Axis.
Definition: mathplot.h:2188
void SetValue(const double value)
Set x or y.
Definition: mathplot.h:1460
mpInfoLegend * m_InfoLegend
pointer to the optional info legend layer
Definition: mathplot.h:3767
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:543
double m_min_x
The shape of the bitmap:
Definition: mathplot.h:4289
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:3742
bool m_isLog
Is the axis a log axis ?
Definition: mathplot.h:2346
void EnableDoubleBuffer(const bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled).
Definition: mathplot.h:3033
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:874
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:3583
Bitmap type layer.
Definition: mathplot.h:643
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:995
Plot type layer.
Definition: mathplot.h:628
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:2966
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4272
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:3547
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1511
void SetYAxisID(unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition: mathplot.h:1420
std::map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition: mathplot.h:2562
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:4182
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:2813
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:752
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:175
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:1762
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:3738
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:542
__mp_Layer_Type
Definition: mathplot.h:624
Show/Hide grids.
Definition: mathplot.h:484
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:4217
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition: mathplot.h:2339
bool m_magnetize
For mouse magnetization.
Definition: mathplot.h:3774
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2127
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:3758
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:2111
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:4187
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:2225
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:3023
enum __Plot_Align_Name_Type mpPlot_Align
Plot alignment (which corner should plot be placed)
Layer type undefined; SHOULD NOT BE USED.
Definition: mathplot.h:626
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:659
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:994
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:987
mpRange bound
Range min and max.
Definition: mathplot.h:2550
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1444
Lock x/y scaling aspect.
Definition: mathplot.h:483
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:1260
Info box type layer.
Definition: mathplot.h:648
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:3884
Abstract class providing a line.
Definition: mathplot.h:1438
Abstract class providing an vertical line.
Definition: mathplot.h:1503
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:2211
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition: mathplot.h:2091
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:2666
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:2340
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:2927
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:3004
void SetExtraMargin(int extra)
Set the extra margin.
Definition: mathplot.h:3414
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:1134
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:4006
Chart type layer (bar chart)
Definition: mathplot.h:633
double GetPosY(int yAxisID)
Get current view&#39;s Y position.
Definition: mathplot.h:2918
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:851
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:3056
int m_winY
Holds the mpWindow size. Used to rescale position when window is resized.
Definition: mathplot.h:1136
std::optional< int > m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:3762
~mpBarChart()
Destructor.
Definition: mathplot.h:2021
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:2996
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:1002
void SetLabelMode(unsigned int mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:2416
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:3759
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:3789
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:859
int m_flags
Holds label alignment. Default : mpALIGN_NE.
Definition: mathplot.h:999
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:3849
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:736
wxPoint GetPosition() const
Returns the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:1098
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1215
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:905
unsigned int GetLabelMode() const
Get X axis label view mode.
Definition: mathplot.h:2409
~mpPieChart()
Destructor.
Definition: mathplot.h:2082
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1428
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:3433
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:989
Just the end of ZOrder.
Definition: mathplot.h:650
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4036
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:641
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:3357
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:3323
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1348
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:3427
void SetMouseLeftDownAction(mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:3628
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:3729
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition: mathplot.h:3760
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1591
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:1647
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:3733
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:997
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:3747
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:3997
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:2590
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:1242
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:2385
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:998
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:3856
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:1987
virtual void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:2401
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:3040
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:3734
Plot (function) type layer.
Definition: mathplot.h:646
void UpdateDesiredBoundingBox(mpAxisUpdate update)
Draws the mpWindow on a page for printing.
Definition: mathplot.h:3157
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:2255
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:1001
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1384
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:688
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:990
bool GetCanDelete(void) const
Get CanDelete for plot.
Definition: mathplot.h:974
Axis type layer.
Definition: mathplot.h:644
Definition: MathPlotConfig.h:75
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:2135
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:2343
Axis type layer.
Definition: mathplot.h:627
void SetCanDelete(bool canDelete)
Set CanDelete for plot.
Definition: mathplot.h:967
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4251
bool GetMagnetize() const
Magnetize the position of the mouse in the plot ie draw a vertical and horizontal line...
Definition: mathplot.h:3614
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:3765
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:1172
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:2218
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:3522
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:884
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:2534
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1900
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:3827
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:4281
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:3556
each visible plot is described on its own line, one above the other
Definition: mathplot.h:550
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:2881
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:981
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:3439
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:1201
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:570
#define mpX_NORMAL
Set label for X axis in normal mode.
Definition: mathplot.h:2365
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1836
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4258
Show/Hide info coord.
Definition: mathplot.h:485
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:898
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:4150
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:3928
int m_last_ly
For double buffering.
Definition: mathplot.h:3752
struct deprecated("No more used, X and Y are now separated")]] mpFloatRect
A structure for computation of bounds in real units (not in screen pixel) X refer to X axis Y refer t...
Definition: mathplot.h:341
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:3775
wxSize GetSize() const
Returns the size of the box (in pixels)
Definition: mathplot.h:1105
Chart type layer.
Definition: mathplot.h:647
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:2342
enum __mp_Location_Type mpLocation
Location for the Info layer.
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:1132
Copy a screen shot to the clipboard.
Definition: mathplot.h:486
Fit view to match bounding box of all layers.
Definition: mathplot.h:479
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:3863
mpRange Get_BoundY(int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition: mathplot.h:2872
bool PointIsInside(double px, double py) const
Is point inside this bounding box?
Definition: mathplot.h:448
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:492
wxBitmap * m_buff_bmp
For double buffering.
Definition: mathplot.h:3753
Center view on click position.
Definition: mathplot.h:482
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1430
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:1772
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:511
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:3979
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:579
mpRange desired
Desired range min and max.
Definition: mathplot.h:2551
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition: mathplot.h:3726
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:1671
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:4062
virtual bool IsLogAxis()
Logarithmic axis.
Definition: mathplot.h:2325
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1391
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:4316
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition: mathplot.h:1431
unsigned int m_labelType
Select labels mode: mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds.
Definition: mathplot.h:2433
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1356
int m_extraMargin
Extra margin around the plot. Default 8.
Definition: mathplot.h:3743
Layer for bar chart.
Definition: mathplot.h:2014
#define mpX_USER
Set label user defined.
Definition: mathplot.h:2376
mpFloatRectSimple GetBoundingBox(bool desired, unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition: mathplot.h:3191
double m_max
Min and max axis values when autosize is false.
Definition: mathplot.h:2344
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:992
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:1221
abstract Layer for chart (bar and pie).
Definition: mathplot.h:1956
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:544
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition: mathplot.h:440
bool GetBoundingBox(mpRange *boundX, mpRange *boundY, int yAxisID)
Return the bounding box coordinates for the Y axis of ID yAxisID.
Definition: mathplot.h:3240
void SetPosY(const std::vector< double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:2901
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:867
const wxRect & GetRectangle() const
Returns the current rectangle coordinates.
Definition: mathplot.h:1112
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:4072
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:3203
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:531
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1427
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:3222
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:3380
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:1792
int m_symbolSize2
Size of the symbol div 2.
Definition: mathplot.h:1429
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:4265
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:2271
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1863
int GetMarginRight(bool minusExtra=false) const
Get the right margin.
Definition: mathplot.h:3365
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1489
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:1811
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:1820
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:3233
Text box type layer.
Definition: mathplot.h:630
mpMouseButtonAction GetMouseLeftDownAction()
Returns the type of action for the left mouse button.
Definition: mathplot.h:3637
double pos
Position.
Definition: mathplot.h:2549
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:3334
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:521
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition: mathplot.h:3749
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:1047
Load a file.
Definition: mathplot.h:490
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:700
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:3877
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:3744
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:1074
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:709
Line (horizontal or vertical) type layer.
Definition: mathplot.h:645
wxBitmap * m_zoom_bmp
For zoom selection.
Definition: mathplot.h:3770
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1156
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:3293
mpRange Get_BoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:2864
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:3737
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:3015
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1363
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition: mathplot.h:3725
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1256
wxRect m_oldDim
Keep the old values of m_dim.
Definition: mathplot.h:1133
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:3731
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:3572
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:2942
int GetBarWidth(void) const
return the width of the bar
Definition: mathplot.h:1697
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:3541
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1194
void SetAxisID(unsigned int yAxisID)
Set an ID to the axis.
Definition: mathplot.h:2197
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1885
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:3473
bool m_enableDoubleBuffer
For double buffering. Default enabled.
Definition: mathplot.h:3754
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1338
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1538
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition: mathplot.h:2098
mpTitle(const wxString &name)
Definition: mathplot.h:3907
void SetLabelMode(unsigned int mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:1186
Plot layer implementing a simple title.
Definition: mathplot.h:3898
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:2460
enum __mp_Layer_ZOrder mpLayerZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:4015
bool ViewAsBar(void) const
return true if XY series is plotted with bar
Definition: mathplot.h:1705
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:1137
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:932
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:3448
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:2892
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:960
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:996
std::vector< double > m_trans_shape_xs
The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh)...
Definition: mathplot.h:4067
int GetExtraMargin() const
Get the extra margin.
Definition: mathplot.h:3421
virtual void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:2232
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:2263
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:1663
enum __XAxis_Align_Type mpXAxis_Align
Alignment for X axis.
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1426
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:3562
std::vector< double > m_xs
The internal copy of the set of data to draw.
Definition: mathplot.h:1828
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, unsigned int type=0x00)
Full constructor.
Definition: mathplot.h:2393
~mpChart()
Destructor.
Definition: mathplot.h:1963
Abstract class providing an horizontal line.
Definition: mathplot.h:1481
std::vector< double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition: mathplot.h:3761
Zoom into view at clickposition / window center.
Definition: mathplot.h:480
int GetMarginLeft(bool minusExtra=false) const
Get the left margin.
Definition: mathplot.h:3405
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:3730
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:4166
double scale
Scale.
Definition: mathplot.h:2548
void Rewind()
Rewind value enumeration with mpFXY::GetNextXY.
Definition: mathplot.h:1845
void SetPos(const double posX, const std::vector< double > &posYList)
Set current view&#39;s X and Y position and refresh display.
Definition: mathplot.h:2987
Zoom out.
Definition: mathplot.h:481
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2168
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:827
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position...
Definition: mathplot.h:2596
int m_reserveXY
Memory reserved for m_xs and m_ys.
Definition: mathplot.h:1832
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:548
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:4096
int GetMarginTop(bool minusExtra=false) const
Get the top margin.
Definition: mathplot.h:3348
double m_minX
Loaded at SetData.
Definition: mathplot.h:1840
mpInfoCoords * m_InfoCoords
pointer to the optional info coords layer
Definition: mathplot.h:3766
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:3212
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition: mathplot.h:2545
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:540
Layer for pie chart.
Definition: mathplot.h:2075
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:843
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:4102
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:835
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:3755
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:991
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:4141
mpRange GetScale() const
Return m_min and m_max scale as a mpRange.
Definition: mathplot.h:2317
Bitmap type layer.
Definition: mathplot.h:631
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:1119
bool IsVisible() const
Checks whether the layer is visible or not.
Definition: mathplot.h:925
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:2204
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:717
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:946
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1399
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:3984
enum __mp_Delete_Action mpDeleteAction
Action to do with the object associated to the layer when we delete it.
Info box type layer.
Definition: mathplot.h:629
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:2977
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:1524
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:760
Plot layer implementing a text string.
Definition: mathplot.h:3822
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:727
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:3745
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:4043
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:3479
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:912
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:993
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:3374
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:744
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:1135
int GetMarginBottom(bool minusExtra=false) const
Get the bottom margin.
Definition: mathplot.h:3388
Shows information about the mouse commands.
Definition: mathplot.h:491
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:3602
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:3340
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:2827
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:3732
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:3777
legend components follow each other horizontally on a single line
Definition: mathplot.h:551
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1273
enum __Text_Type mpTextType
sub_type values for mpLAYER_TEXT
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above)...
Definition: mathplot.h:4123
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1412
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:3739
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:206
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:4052
double GetScaleY(int yAxisID)
Get current view&#39;s Y scale.
Definition: mathplot.h:2852
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:2119
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1370
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:4022
Plot layer, abstract base class.
Definition: mathplot.h:676
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:1000
double GetValue() const
Set x or y.
Definition: mathplot.h:1452
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:3870
void SetFactor(int factor)
Definition: mathplot.h:3954
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:811
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:988
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:2345
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:3736
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:891
mpScaleY(const wxString &name=_T("Y"), int flags=mpALIGN_CENTERY, bool grids=false, std::optional< unsigned int > yAxisID=std::nullopt)
Full constructor.
Definition: mathplot.h:2467
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:819
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:1018
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:4161
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:3397
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:3724
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:2341
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:3741
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1925
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:1126
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition: mathplot.h:3756
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:3748
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:939
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2180
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:4029
bool IsRepainting() const
Checks if we are repainting.
Definition: mathplot.h:3065
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:3136
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:2247
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2434
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1377
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:4222
void SetScaleY(const double scaleY, int yAxisID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:2836
mpAxisUpdate
Define the axis we want to update.
Definition: mathplot.h:2570
Text box type layer.
Definition: mathplot.h:649
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:2682
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:953
Line (horizontal or vertical) type layer.
Definition: mathplot.h:632
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1878