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, Oskar Waldemarsson
7 // Created: 21/07/2003
8 // Last edit: 29/03/2025
9 // Copyright: (c) David Schalig, Davide Rondini
10 // Licence: wxWindows licence
12 
13 #ifndef MATHPLOT_H_INCLUDED
14 #define MATHPLOT_H_INCLUDED
15 
55 //this definition uses windows dll to export function.
56 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
57 //mathplot_EXPORTS will be defined by cmake
58 #ifdef mathplot_EXPORTS
59 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
60 #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
61 #else // not making DLL
62 #define WXDLLIMPEXP_MATHPLOT
63 #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
64 #endif
65 
66 #if defined(__GNUG__) && !defined(__APPLE__)
67 #pragma interface "mathplot.h"
68 #endif
69 
70 #include <vector>
71 #include <optional>
72 
73 // #include <wx/wx.h>
74 #include <wx/defs.h>
75 #include <wx/menu.h>
76 #include <wx/scrolwin.h>
77 #include <wx/event.h>
78 #include <wx/dynarray.h>
79 #include <wx/pen.h>
80 #include <wx/dcmemory.h>
81 #include <wx/string.h>
82 #include <wx/print.h>
83 #include <wx/image.h>
84 #include <wx/intl.h>
85 
86 #include <cmath>
87 #include <deque>
88 #include <algorithm>
89 
90 // No, this is supposed to be a build parameter: #define ENABLE_MP_CONFIG
91 #ifdef ENABLE_MP_CONFIG
92  #include "MathPlotConfig.h"
93 #endif // ENABLE_MP_CONFIG
94 
99 // No, this is supposed to be a build parameter: #define ENABLE_MP_NAMESPACE
100 #ifdef ENABLE_MP_NAMESPACE
101  namespace MathPlot {
102 #endif // ENABLE_MP_NAMESPACE
103 
104 #ifdef ENABLE_MP_DEBUG
105 // For memory leak debug
106 #ifdef _WINDOWS
107 #ifdef _DEBUG
108 #include <crtdbg.h>
109 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
110 #else
111 #define DEBUG_NEW new
112 #endif // _DEBUG
113 #endif // _WINDOWS
114 #endif // ENABLE_MP_DEBUG
115 
116 // Separation for axes when set close to border
117 #define X_BORDER_SEPARATION 40
118 #define Y_BORDER_SEPARATION 60
119 
121 #define mpX_LOCALTIME 0x10
122 
123 #define mpX_UTCTIME 0x20
124 #define mpX_RAWTIME mpX_UTCTIME
125 
126 // An epsilon for float comparison to 0
127 #define EPSILON 1e-8
128 #define ISNOTNULL(x) (fabs(x) > EPSILON)
129 
130 // A small extra margin for the plot boundary
131 #define EXTRA_MARGIN 8
132 
133 #define ZOOM_AROUND_CENTER -1
134 
135 //-----------------------------------------------------------------------------
136 // classes
137 //-----------------------------------------------------------------------------
138 
139 class WXDLLIMPEXP_MATHPLOT mpLayer;
140 class WXDLLIMPEXP_MATHPLOT mpFunction;
141 class WXDLLIMPEXP_MATHPLOT mpLine;
142 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine;
143 class WXDLLIMPEXP_MATHPLOT mpVerticalLine;
144 class WXDLLIMPEXP_MATHPLOT mpFX;
145 class WXDLLIMPEXP_MATHPLOT mpFY;
146 class WXDLLIMPEXP_MATHPLOT mpFXY;
147 class WXDLLIMPEXP_MATHPLOT mpFXYVector;
148 class WXDLLIMPEXP_MATHPLOT mpProfile;
149 class WXDLLIMPEXP_MATHPLOT mpChart;
150 class WXDLLIMPEXP_MATHPLOT mpBarChart;
151 class WXDLLIMPEXP_MATHPLOT mpScale;
152 class WXDLLIMPEXP_MATHPLOT mpScaleX;
153 class WXDLLIMPEXP_MATHPLOT mpScaleY;
154 class WXDLLIMPEXP_MATHPLOT mpInfoLayer;
155 class WXDLLIMPEXP_MATHPLOT mpInfoCoords;
156 class WXDLLIMPEXP_MATHPLOT mpInfoLegend;
157 class WXDLLIMPEXP_MATHPLOT mpWindow;
158 class WXDLLIMPEXP_MATHPLOT mpText;
159 class WXDLLIMPEXP_MATHPLOT mpTitle;
160 class WXDLLIMPEXP_MATHPLOT mpPrintout;
161 class WXDLLIMPEXP_MATHPLOT mpMovableObject;
162 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse;
163 class WXDLLIMPEXP_MATHPLOT mpPolygon;
164 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer;
165 
166 #ifdef ENABLE_MP_CONFIG
168 #endif // ENABLE_MP_CONFIG
169 
171 typedef union
172 {
173  struct
174  {
175  wxCoord startPx;
176  wxCoord endPx;
177  wxCoord startPy;
178  wxCoord endPy;
179  };
180  struct
181  {
182  wxCoord left;
183  wxCoord top;
184  wxCoord right;
185  wxCoord bottom;
186  };
187  struct
188  {
189  wxCoord x1;
190  wxCoord y1;
191  wxCoord x2;
192  wxCoord y2;
193  };
194  wxCoord tab[4];
195 } mpRect;
196 
203 {
204  inline static int ySize = 1;
205  double Xmin;
206  double Xmax;
207  std::vector<double> YminList;
208  std::vector<double> YmaxList;
209 
210  mpFloatRect() : Xmin(0.0), Xmax(0.0) {YminList.resize(ySize, 0.0); YmaxList.resize(ySize, 0.0);}
212  bool PointIsInside(double x, double y, size_t yIndex = 0) const {
213  if(yIndex < YminList.size())
214  {
215  if( (x < Xmin || x > Xmax) ||
216  (y < YminList[yIndex] || y > YmaxList[yIndex]))
217  {
218  return false;
219  }
220  }
221  else
222  {
223  return false;
224  }
225 
226  return true;
227  }
229  void UpdateBoundingBoxToInclude(double x, double y, size_t yIndex = 0) {
230  if(yIndex < YminList.size())
231  {
232  if (x < Xmin ) Xmin = x;
233  else if (x > Xmax ) Xmax = x;
234  if (y < YminList[yIndex] ) YminList[yIndex] = y;
235  else if (y > YmaxList[yIndex] ) YmaxList[yIndex] = y;
236  }
237  }
239  void InitializeBoundingBox(double x, double y, size_t yIndex = 0) {
240  if(yIndex < YminList.size())
241  {
242  Xmin = Xmax = x;
243  YminList[yIndex] = YmaxList[yIndex] = y;
244  }
245  }
247  bool IsNotSet() const { const mpFloatRect def; return *this==def; }
249 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
250  bool operator==(const mpFloatRect&) const = default;
251 #else
252  // We compare with an epsilon precision
253  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
254  bool operator==(const mpFloatRect& rect) const
255  {
256  auto Same = [](double a, double b) {
257  return std::fabs(a - b) < EPSILON;
258  };
259 
260  // Compare scalar members
261  if (!Same(Xmin, rect.Xmin) || !Same(Xmax, rect.Xmax))
262  {
263  return false;
264  }
265 
266  // Compare vector sizes
267  if (YminList.size() != rect.YminList.size() || YmaxList.size() != rect.YmaxList.size())
268  {
269  return false;
270  }
271 
272  // Compare vector contents
273  auto vectorSame = [&Same](const std::vector<double>& a, const std::vector<double>& b) {
274  return std::equal(a.begin(), a.end(), b.begin(), Same);
275  };
276 
277  return vectorSame(YminList, rect.YminList) && vectorSame(YmaxList, rect.YmaxList);
278  }
279 #endif
280 };
281 
285 enum
286 {
287  mpID_FIT = 2000,
295 #ifdef ENABLE_MP_CONFIG
296  mpID_CONFIG,
297 #endif // ENABLE_MP_CONFIG
301 };
302 
304 typedef enum __mp_Location_Type
305 {
306  mpMarginLeftCenter,
307  mpMarginTopLeft,
308  mpMarginTopCenter,
309  mpMarginTopRight,
310  mpMarginRightCenter,
311  mpMarginBottomLeft,
312  mpMarginBottomCenter,
313  mpMarginBottomRight,
314  mpMarginNone,
315  mpCursor // only for mpInfoCoords
316 } mpLocation;
317 
319 typedef enum __XAxis_Align_Type
320 {
321  mpALIGN_BORDER_BOTTOM = 10,
322  mpALIGN_BOTTOM,
323  mpALIGN_CENTERX,
324  mpALIGN_TOP,
325  mpALIGN_BORDER_TOP
326 } mpXAxis_Align;
327 
329 typedef enum __YAxis_Align_Type
330 {
331  mpALIGN_BORDER_LEFT = 20,
332  mpALIGN_LEFT,
333  mpALIGN_CENTERY,
334  mpALIGN_RIGHT,
335  mpALIGN_BORDER_RIGHT
336 } mpYAxis_Align;
337 
340 {
341  mpALIGN_NW = 5,
342  mpALIGN_NE,
343  mpALIGN_SE,
344  mpALIGN_SW
345 } mpPlot_Align;
346 
348 typedef enum __mp_Style_Type
349 {
353 } mpLegendStyle;
354 
357 {
361 
362 typedef enum __Symbol_Type
363 {
364  mpsNone,
365  mpsCircle,
366  mpsSquare,
367  mpsUpTriangle,
368  mpsDownTriangle,
369  mpsCross,
370  mpsPlus
371 } mpSymbol;
372 
373 //-----------------------------------------------------------------------------
374 // mpLayer sub_type values
375 //-----------------------------------------------------------------------------
376 
378 typedef enum __Info_Type
379 {
380  mpiNone, // never used
381  mpiInfo,
382  mpiCoords,
383  mpiLegend
384 } mpInfoType;
385 
387 typedef enum __Text_Type
388 {
389  mptNone, // never used
390  mptText,
391  mptTitle
392 } mpTextType;
393 
394 typedef enum __Function_Type
395 {
396  mpfNone,
397  mpfFX,
398  mpfFY,
399  mpfFXY,
400  mpfFXYVector,
401  mpfMovable,
402  mpfLine,
403  mpfAllType
404 } mpFunctionType;
405 
406 typedef enum __Scale_Type
407 {
408  mpsScaleNone,
409  mpsScaleX,
410  mpsScaleY,
411  mpsAllType
412 } mpScaleType;
413 
414 typedef enum __Chart_Type
415 {
416  mpcChartNone,
417  mpcBarChart,
418  mpcPieChart,
419  mpcAllType
420 } mpChartType;
421 
422 //-----------------------------------------------------------------------------
423 // mpLayer
424 //-----------------------------------------------------------------------------
425 
426 typedef enum __mp_Layer_Type
427 {
436 } mpLayerType;
437 
443 typedef enum __mp_Layer_ZOrder
444 {
453 } mpLayerZOrder;
454 
465 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
466 {
467  public:
468  mpLayer(mpLayerType layerType);
469 
470  virtual ~mpLayer()
471  {
472  ;
473  }
474 
478  {
479  m_win = &w;
480  }
481 
489  virtual bool HasBBox()
490  {
491  return true;
492  }
493 
498  mpLayerType GetLayerType() const
499  {
500  return m_type;
501  }
502 
506  int GetLayerSubType() const
507  {
508  return m_subtype;
509  }
510 
517  virtual bool IsLayerType(mpLayerType type, int *sub_type)
518  {
519  *sub_type = m_subtype;
520  return (m_type == type);
521  }
522 
526  virtual double GetMinX()
527  {
528  return -1.0;
529  }
530 
534  virtual double GetMaxX()
535  {
536  return 1.0;
537  }
538 
542  virtual double GetMinY()
543  {
544  return -1.0;
545  }
546 
550  virtual double GetMaxY()
551  {
552  return 1.0;
553  }
554 
596  void Plot(wxDC &dc, mpWindow &w);
597 
601  void SetName(const wxString &name)
602  {
603  m_name = name;
604  }
605 
609  const wxString& GetName() const
610  {
611  return m_name;
612  }
613 
617  void SetFont(const wxFont &font)
618  {
619  m_font = font;
620  }
621 
625  const wxFont& GetFont() const
626  {
627  return m_font;
628  }
629 
633  void SetFontColour(const wxColour &colour)
634  {
635  m_fontcolour = colour;
636  }
637 
641  const wxColour& GetFontColour() const
642  {
643  return m_fontcolour;
644  }
645 
649  void SetPen(const wxPen &pen)
650  {
651  m_pen = pen;
652  }
653 
657  const wxPen& GetPen() const
658  {
659  return m_pen;
660  }
661 
664  void SetBrush(const wxBrush &brush)
665  {
666  if (brush == wxNullBrush)
667  m_brush = *wxTRANSPARENT_BRUSH;
668  else
669  m_brush = brush;
670  }
671 
674  const wxBrush& GetBrush() const
675  {
676  return m_brush;
677  }
678 
681  void SetShowName(bool show)
682  {
683  m_showName = show;
684  }
685 
688  inline bool GetShowName() const
689  {
690  return m_showName;
691  }
692 
695  void SetDrawOutsideMargins(bool drawModeOutside)
696  {
697  m_drawOutsideMargins = drawModeOutside;
698  }
699 
703  {
704  return m_drawOutsideMargins;
705  }
706 
711  wxBitmap GetColourSquare(int side = 16);
712 
715  inline bool IsVisible() const
716  {
717  return m_visible;
718  }
719 
722  virtual void SetVisible(bool show)
723  {
724  m_visible = show;
725  }
726 
729  inline bool IsTractable() const
730  {
731  return m_tractable;
732  }
733 
736  virtual void SetTractable(bool track)
737  {
738  m_tractable = track;
739  }
740 
743  void SetAlign(int align)
744  {
745  m_flags = align;
746  }
747 
750  int GetAlign() const
751  {
752  return m_flags;
753  }
754 
757  void SetCanDelete(bool canDelete)
758  {
759  m_CanDelete = canDelete;
760  }
761 
764  bool GetCanDelete(void) const
765  {
766  return m_CanDelete;
767  }
768 
771  mpLayerZOrder GetZIndex(void) const
772  {
773  return m_ZIndex;
774  }
775 
776  protected:
777  const mpLayerType m_type;
779  int m_subtype;
780  wxFont m_font;
781  wxColour m_fontcolour;
782  wxPen m_pen;
783  wxBrush m_brush;
784  wxString m_name;
785  bool m_showName;
787  bool m_visible;
788  bool m_tractable;
789  int m_flags;
791  bool m_CanDelete;
792  mpLayerZOrder m_ZIndex;
793 
796  void UpdateContext(wxDC &dc) const;
797 
802  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
803 
807  virtual void DoBeforePlot()
808  {
809  ;
810  }
811 
815  void CheckLog(double *x, double *y);
816 
817  private:
818  bool m_busy;
819  mpLayer() = delete; // default ctor not implemented/permitted
820 
821  wxDECLARE_DYNAMIC_CLASS(mpLayer);
822 };
823 
824 //-----------------------------------------------------------------------------
825 // mpInfoLayer
826 //-----------------------------------------------------------------------------
827 
833 class WXDLLIMPEXP_MATHPLOT mpInfoLayer: public mpLayer
834 {
835  public:
837  mpInfoLayer();
838 
843  mpInfoLayer(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
844 
846  virtual ~mpInfoLayer();
847 
850  virtual void SetVisible(bool show);
851 
856  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
857 
860  virtual bool HasBBox()
861  {
862  return false;
863  }
864 
868  virtual void ErasePlot(wxDC &dc, mpWindow &w);
869 
873  virtual bool Inside(const wxPoint &point);
874 
877  virtual void Move(wxPoint delta);
878 
880  virtual void UpdateReference();
881 
884  wxPoint GetPosition() const
885  {
886  return m_dim.GetPosition();
887  }
888 
891  wxSize GetSize() const
892  {
893  return m_dim.GetSize();
894  }
895 
898  const wxRect& GetRectangle() const
899  {
900  return m_dim;
901  }
902 
905  void SetLocation(mpLocation location)
906  {
907  m_location = location;
908  }
909 
912  mpLocation GetLocation() const
913  {
914  return m_location;
915  }
916 
917  protected:
918  wxRect m_dim;
919  wxRect m_oldDim;
920  wxBitmap* m_info_bmp;
921  wxPoint m_reference;
922  int m_winX, m_winY;
923  mpLocation m_location;
924 
929  virtual void DoPlot(wxDC &dc, mpWindow &w);
930 
933  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
934 
935  wxDECLARE_DYNAMIC_CLASS(mpInfoLayer);
936 };
937 
942 class WXDLLIMPEXP_MATHPLOT mpInfoCoords: public mpInfoLayer
943 {
944  public:
946  mpInfoCoords();
947 
949  mpInfoCoords(mpLocation location);
950 
955  mpInfoCoords(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
956 
959  {
960  ;
961  }
962 
966  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
967 
968  virtual void ErasePlot(wxDC &dc, mpWindow &w);
969 
972  void SetLabelMode(unsigned int mode, unsigned int time_conv = mpX_RAWTIME)
973  {
974  m_labelType = mode;
975  m_timeConv = time_conv;
976  }
977 
980  void SetSeriesCoord(bool show)
981  {
982  m_series_coord = show;
983  }
984 
987  bool IsSeriesCoord() const
988  {
989  return m_series_coord;
990  }
991 
996  virtual wxString GetInfoCoordsText(double xVal, std::vector<double> yValList);
997 
1000  void SetPenSeries(const wxPen &pen)
1001  {
1002  m_penSeries = pen;
1003  }
1004 
1005  protected:
1006  wxString m_content;
1007  unsigned int m_labelType;
1008  unsigned int m_timeConv;
1009  wxCoord m_mouseX;
1010  wxCoord m_mouseY;
1011  bool m_series_coord;
1012  wxPen m_penSeries;
1013 
1018  virtual void DoPlot(wxDC &dc, mpWindow &w);
1019 
1020  wxDECLARE_DYNAMIC_CLASS(mpInfoCoords);
1021 };
1022 
1027 class WXDLLIMPEXP_MATHPLOT mpInfoLegend: public mpInfoLayer
1028 {
1029  public:
1031  mpInfoLegend();
1032 
1038  mpInfoLegend(wxRect rect, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginNone);
1039 
1042 
1045  void SetItemMode(mpLegendStyle mode)
1046  {
1047  m_item_mode = mode;
1048  m_needs_update = true;
1049  }
1050 
1051  mpLegendStyle GetItemMode() const
1052  {
1053  return m_item_mode;
1054  }
1055 
1058  void SetItemDirection(mpLegendDirection mode)
1059  {
1060  m_item_direction = mode;
1061  m_needs_update = true;
1062  }
1063 
1064  mpLegendDirection GetItemDirection() const
1065  {
1066  return m_item_direction;
1067  }
1068 
1069  void SetNeedUpdate()
1070  {
1071  m_needs_update = true;
1072  }
1073 
1075  int GetPointed(mpWindow &w, wxPoint eventPoint);
1076 
1077  protected:
1078  mpLegendStyle m_item_mode;
1079  mpLegendDirection m_item_direction;
1080 
1085  virtual void DoPlot(wxDC &dc, mpWindow &w);
1086 
1087  private:
1089  struct LegendDetail
1090  {
1091  unsigned int layerIdx;
1092  wxCoord legendEnd;
1093  };
1095  std::vector<LegendDetail> m_LegendDetailList;
1096  bool m_needs_update;
1097 
1107  void UpdateBitmap(wxDC &dc, mpWindow &w);
1108 
1109  wxDECLARE_DYNAMIC_CLASS(mpInfoLegend);
1110 };
1111 
1112 //-----------------------------------------------------------------------------
1113 // mpLayer implementations - functions
1114 //-----------------------------------------------------------------------------
1115 
1123 class WXDLLIMPEXP_MATHPLOT mpFunction: public mpLayer
1124 {
1125  public:
1128  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, size_t yAxisIndex = 0);
1129 
1133  void SetContinuity(bool continuity)
1134  {
1135  m_continuous = continuity;
1136  }
1137 
1141  bool GetContinuity() const
1142  {
1143  return m_continuous;
1144  }
1145 
1148  void SetStep(unsigned int step)
1149  {
1150  m_step = step;
1151  }
1152 
1155  unsigned int GetStep() const
1156  {
1157  return m_step;
1158  }
1159 
1162  void SetSymbol(mpSymbol symbol)
1163  {
1164  m_symbol = symbol;
1165  }
1166 
1169  mpSymbol GetSymbol() const
1170  {
1171  return m_symbol;
1172  }
1173 
1176  void SetSymbolSize(int size)
1177  {
1178  m_symbolSize = size;
1179  m_symbolSize2 = size / 2;
1180  }
1181 
1184  int GetSymbolSize() const
1185  {
1186  return m_symbolSize;
1187  }
1188 
1192  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1193 
1194  size_t GetYAxisIndex() const
1195  {
1196  return m_yAxisIndex;
1197  }
1198 
1199  void SetYAxisIndex(size_t index)
1200  {
1201  m_yAxisIndex = index;
1202  }
1203 
1204  protected:
1206  mpSymbol m_symbol;
1209  unsigned int m_step;
1210  size_t m_yAxisIndex;
1211 
1212  wxDECLARE_DYNAMIC_CLASS(mpFunction);
1213 };
1214 
1217 class WXDLLIMPEXP_MATHPLOT mpLine: public mpFunction
1218 {
1219  public:
1220  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1221 
1222  // We don't want to include line (horizontal or vertical) in BBox computation
1223  virtual bool HasBBox() override
1224  {
1225  return false;
1226  }
1227 
1231  double GetValue() const
1232  {
1233  return m_value;
1234  }
1235 
1239  void SetValue(const double value)
1240  {
1241  m_value = value;
1242  }
1243 
1246  bool IsHorizontal(void) const
1247  {
1248  return m_IsHorizontal;
1249  }
1250 
1251  protected:
1252  double m_value;
1253  bool m_IsHorizontal;
1254 
1255  wxDECLARE_DYNAMIC_CLASS(mpLine);
1256 };
1257 
1260 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine: public mpLine
1261 {
1262  public:
1263  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, size_t yAxisIndex = 0);
1264 
1268  void SetYValue(const double yvalue)
1269  {
1270  SetValue(yvalue);
1271  }
1272 
1273  protected:
1274 
1275  virtual void DoPlot(wxDC &dc, mpWindow &w);
1276 
1277  wxDECLARE_DYNAMIC_CLASS(mpHorizontalLine);
1278 };
1279 
1282 class WXDLLIMPEXP_MATHPLOT mpVerticalLine: public mpLine
1283 {
1284  public:
1285  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1286 
1290  void SetXValue(const double xvalue)
1291  {
1292  SetValue(xvalue);
1293  }
1294 
1295  protected:
1296 
1297  virtual void DoPlot(wxDC &dc, mpWindow &w);
1298 
1299  wxDECLARE_DYNAMIC_CLASS(mpVerticalLine);
1300 };
1301 
1308 class WXDLLIMPEXP_MATHPLOT mpFX: public mpFunction
1309 {
1310  public:
1314  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, int yAxisIndex = 0);
1315 
1321  virtual double GetY(double x) = 0;
1322 
1326  double DoGetY(double x);
1327 
1328  protected:
1329 
1334  virtual void DoPlot(wxDC &dc, mpWindow &w);
1335 
1336  wxDECLARE_DYNAMIC_CLASS(mpFX);
1337 };
1338 
1345 class WXDLLIMPEXP_MATHPLOT mpFY: public mpFunction
1346 {
1347  public:
1351  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, int yAxisIndex = 0);
1352 
1358  virtual double GetX(double y) = 0;
1359 
1363  double DoGetX(double y);
1364 
1365  protected:
1366 
1371  virtual void DoPlot(wxDC &dc, mpWindow &w);
1372 
1373  wxDECLARE_DYNAMIC_CLASS(mpFY);
1374 };
1375 
1385 class WXDLLIMPEXP_MATHPLOT mpFXY: public mpFunction
1386 {
1387  public:
1391  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, int yAxisIndex = 0);
1392 
1396  virtual void Rewind() = 0;
1397 
1401  virtual void Clear()
1402  {
1403  ;
1404  }
1405 
1409  virtual int GetSize()
1410  {
1411  return 0;
1412  }
1413 
1420  virtual bool GetNextXY(double *x, double *y) = 0;
1421 
1425  bool DoGetNextXY(double *x, double *y);
1426 
1430  void SetViewMode(bool asBar);
1431 
1435  int GetBarWidth(void) const
1436  {
1437  return m_BarWidth;
1438  }
1439 
1443  bool ViewAsBar(void) const
1444  {
1445  return m_ViewAsBar;
1446  }
1447 
1448  protected:
1449 
1450  // Data to calculate label positioning
1451  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
1452 
1453  // Min delta between 2 x coordinate (used for view as bar)
1454  double m_deltaX, m_deltaY;
1455 
1456  // The width of a bar
1457  int m_BarWidth;
1458 
1459  // Plot data as bar graph
1460  bool m_ViewAsBar = false;
1461 
1462  // Can the series be deleted?
1463  bool m_CanDelete = true;
1464 
1469  virtual void DoPlot(wxDC &dc, mpWindow &w);
1470 
1475  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
1476 
1477  wxDECLARE_DYNAMIC_CLASS(mpFXY);
1478 };
1479 
1480 //-----------------------------------------------------------------------------
1481 // mpFXYVector - provided by Jose Luis Blanco
1482 //-----------------------------------------------------------------------------
1483 
1503 class WXDLLIMPEXP_MATHPLOT mpFXYVector: public mpFXY
1504 {
1505  public:
1509  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, int yAxisIndex = 0);
1510 
1513  virtual ~mpFXYVector()
1514  {
1515  Clear();
1516  }
1517 
1522  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
1523 
1527  void Clear();
1528 
1533  virtual int GetSize()
1534  {
1535  return m_xs.size();
1536  }
1537 
1545  bool AddData(const double x, const double y, bool updatePlot);
1546 
1552  void SetReserve(int reserve)
1553  {
1554  m_reserveXY = reserve;
1555  m_xs.reserve(m_reserveXY);
1556  m_ys.reserve(m_reserveXY);
1557  }
1558 
1561  int GetReserve() const
1562  {
1563  return m_reserveXY;
1564  }
1565 
1566  protected:
1569  std::vector<double> m_xs, m_ys;
1570 
1574 
1577  size_t m_index;
1578 
1581  double m_minX, m_maxX, m_minY, m_maxY, m_lastX, m_lastY;
1582 
1586  inline void Rewind()
1587  {
1588  m_index = 0;
1589  }
1590 
1596  virtual bool GetNextXY(double *x, double *y);
1597 
1600  void DrawAddedPoint(double x, double y);
1601 
1604  virtual double GetMinX()
1605  {
1606  return m_minX;
1607  }
1608 
1611  virtual double GetMinY()
1612  {
1613  return m_minY;
1614  }
1615 
1618  virtual double GetMaxX()
1619  {
1620  return m_maxX;
1621  }
1622 
1625  virtual double GetMaxY()
1626  {
1627  return m_maxY;
1628  }
1629 
1630  private:
1633  void First_Point(double x, double y);
1634 
1637  void Check_Limit(double val, double *min, double *max, double *last, double *delta);
1638 
1639  wxDECLARE_DYNAMIC_CLASS(mpFXYVector);
1640 };
1641 
1650 class WXDLLIMPEXP_MATHPLOT mpProfile: public mpFunction
1651 {
1652  public:
1656  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
1657 
1663  virtual double GetY(double x) = 0;
1664 
1665  protected:
1666 
1671  virtual void DoPlot(wxDC &dc, mpWindow &w);
1672 
1673  wxDECLARE_DYNAMIC_CLASS(mpProfile);
1674 };
1675 
1676 //-----------------------------------------------------------------------------
1677 // mpChart
1678 //-----------------------------------------------------------------------------
1681 class WXDLLIMPEXP_MATHPLOT mpChart: public mpFunction
1682 {
1683  public:
1685  mpChart(const wxString &name = wxEmptyString);
1686 
1689  {
1690  Clear();
1691  }
1692 
1695  void SetChartValues(const std::vector<double> &data);
1696 
1699  void SetChartLabels(const std::vector<std::string> &labelArray);
1700 
1705  void AddData(const double &data, const std::string &label);
1706 
1710  virtual void Clear();
1711 
1712  virtual bool HasBBox()
1713  {
1714  return (values.size() > 0);
1715  }
1716 
1717  protected:
1718  std::vector<double> values;
1719  std::vector<std::string> labels;
1720 
1721  double m_max_value;
1722  double m_total_value;
1723 
1724  wxDECLARE_DYNAMIC_CLASS(mpChart);
1725 };
1726 
1727 //-----------------------------------------------------------------------------
1728 // mpBarChart - provided by Jose Davide Rondini
1729 //-----------------------------------------------------------------------------
1730 /* Defines for bar charts label positioning. */
1731 #define mpBAR_NONE 0
1732 #define mpBAR_AXIS_H 1
1733 #define mpBAR_AXIS_V 2
1734 #define mpBAR_INSIDE 3
1735 #define mpBAR_TOP 4
1736 
1737 
1739 class WXDLLIMPEXP_MATHPLOT mpBarChart: public mpChart
1740 {
1741  public:
1743  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
1744 
1747  {
1748  Clear();
1749  }
1750 
1751  void SetBarColour(const wxColour &colour);
1752 
1753  void SetColumnWidth(const double colWidth)
1754  {
1755  m_width = colWidth;
1756  }
1757 
1759  void SetBarLabelPosition(int position);
1760 
1764  virtual double GetMinX();
1765 
1769  virtual double GetMaxX();
1770 
1774  virtual double GetMinY();
1775 
1779  virtual double GetMaxY();
1780 
1781  protected:
1782 
1783  double m_width;
1784  wxColour m_barColour;
1785  int m_labelPos;
1786  double m_labelAngle;
1787 
1792  virtual void DoPlot(wxDC &dc, mpWindow &w);
1793 
1794  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
1795 };
1796 
1801 class WXDLLIMPEXP_MATHPLOT mpPieChart: public mpChart
1802 {
1803  public:
1805  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
1806 
1809  {
1810  Clear();
1811  colours.clear();
1812  }
1813 
1817  void SetPieColours(const std::vector<wxColour> &colourArray);
1818 
1822  virtual double GetMinX()
1823  {
1824  return -m_radius;
1825  }
1826 
1830  virtual double GetMaxX()
1831  {
1832  return m_radius;
1833  }
1834 
1838  virtual double GetMinY()
1839  {
1840  return -m_radius;
1841  }
1842 
1846  virtual double GetMaxY()
1847  {
1848  return m_radius;
1849  }
1850 
1851  protected:
1852 
1853  double m_radius;
1854  std::vector<wxColour> colours;
1855 
1860  virtual void DoPlot(wxDC &dc, mpWindow &w);
1861 
1862  const wxColour& GetColour(unsigned int id);
1863 
1864  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
1865 };
1866 
1869 //-----------------------------------------------------------------------------
1870 // mpLayer implementations - furniture (scales, ...)
1871 //-----------------------------------------------------------------------------
1878 class WXDLLIMPEXP_MATHPLOT mpScale: public mpLayer
1879 {
1880  public:
1885  mpScale(const wxString &name, int flags, bool grids);
1886 
1890  virtual bool HasBBox()
1891  {
1892  return false;
1893  }
1894 
1897  void ShowTicks(bool ticks)
1898  {
1899  m_ticks = ticks;
1900  }
1901 
1904  bool GetShowTicks() const
1905  {
1906  return m_ticks;
1907  }
1908 
1911  void ShowGrids(bool grids)
1912  {
1913  m_grids = grids;
1914  }
1915 
1918  bool GetShowGrids() const
1919  {
1920  return m_grids;
1921  }
1922 
1925  virtual void SetLabelFormat(const wxString &format)
1926  {
1927  m_labelFormat = format;
1928  }
1929 
1932  const wxString& GetLabelFormat() const
1933  {
1934  return m_labelFormat;
1935  }
1936 
1940  void SetGridPen(const wxPen &pen)
1941  {
1942  m_gridpen = pen;
1943  }
1944 
1948  const wxPen& GetGridPen() const
1949  {
1950  return m_gridpen;
1951  }
1952 
1956  void SetAuto(bool automaticScalingIsEnabled)
1957  {
1958  m_auto = automaticScalingIsEnabled;
1959  }
1960 
1964  bool GetAuto() const
1965  {
1966  return m_auto;
1967  }
1968 
1969  void SetMinScale(double min)
1970  {
1971  m_min = min;
1972  }
1973 
1974  double GetMinScale() const
1975  {
1976  return m_min;
1977  }
1978 
1979  void SetMaxScale(double max)
1980  {
1981  m_max = max;
1982  }
1983 
1984  double GetMaxScale() const
1985  {
1986  return m_max;
1987  }
1988 
1989  virtual bool IsLogAxis() = 0;
1990  virtual void SetLogAxis(bool log) = 0;
1991 
1992  protected:
1993  wxPen m_gridpen;
1994  bool m_ticks;
1995  bool m_grids;
1996  bool m_auto;
1997  double m_min, m_max;
1998  wxString m_labelFormat;
1999 
2000  virtual int GetOrigin(mpWindow &w) = 0;
2001 
2008  double GetStep(double scale, int minLabelSpacing);
2009  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
2010 
2011  wxString FormatLogValue(double n);
2012 
2013  wxDECLARE_DYNAMIC_CLASS(mpScale);
2014 };
2015 
2017 #define mpX_NORMAL 0x00
2018 
2020 #define mpX_TIME 0x01
2021 
2022 #define mpX_HOURS 0x02
2023 
2024 #define mpX_DATE 0x03
2025 
2026 #define mpX_DATETIME 0x04
2027 
2028 #define mpX_USER 0x05
2029 
2030 #define mpX_NONE 0x06
2031 
2037 class WXDLLIMPEXP_MATHPLOT mpScaleX: public mpScale
2038 {
2039  public:
2045  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, unsigned int type = mpX_NORMAL) :
2046  mpScale(name, flags, grids)
2047  {
2048  m_subtype = mpsScaleX;
2049  m_labelType = type;
2050  m_timeConv = mpX_RAWTIME;
2051  }
2052 
2053  virtual void SetLabelFormat(const wxString &format)
2054  {
2055  mpScale::SetLabelFormat(format);
2056  m_labelType = mpX_USER;
2057  }
2058 
2061  unsigned int GetLabelMode() const
2062  {
2063  return m_labelType;
2064  }
2065 
2068  void SetLabelMode(unsigned int mode, unsigned int time_conv = mpX_RAWTIME)
2069  {
2070  m_labelType = mode;
2071  m_timeConv = time_conv;
2072  }
2073 
2077  virtual bool IsLogAxis();
2078  virtual void SetLogAxis(bool log);
2079 
2080  protected:
2081  unsigned int m_labelType;
2082  unsigned int m_timeConv;
2083 
2086  virtual void DoPlot(wxDC &dc, mpWindow &w);
2087 
2093  int GetLabelWidth(double value, wxDC &dc, wxString fmt);
2094 
2095  virtual int GetOrigin(mpWindow &w);
2096  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2097  wxString FormatValue(const wxString &fmt, double n);
2098 
2099  wxDECLARE_DYNAMIC_CLASS(mpScaleX);
2100 };
2101 
2108 class WXDLLIMPEXP_MATHPLOT mpScaleY: public mpScale
2109 {
2110  public:
2115  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, size_t axisIndex = 0) :
2116  mpScale(name, flags, grids)
2117  {
2118  m_subtype = mpsScaleY;
2119  m_axisWidth = Y_BORDER_SEPARATION;
2120  m_axisIndex = axisIndex;
2121  m_xPos = 0;
2122  }
2123 
2127  virtual bool IsLogAxis();
2128  virtual void SetLogAxis(bool log);
2129 
2132  void UpdateAxisWidth(mpWindow &w);
2133 
2134  size_t GetAxisIndex(void)
2135  {
2136  return m_axisIndex;
2137  }
2138 
2139  int GetAxisWidth()
2140  {
2141  return m_axisWidth;
2142  }
2143 
2144  bool IsLeftAxis()
2145  {
2146  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
2147  }
2148 
2149  bool IsRightAxis()
2150  {
2151  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
2152  }
2153 
2154  bool IsInside(wxCoord xPixel)
2155  {
2156  if( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
2157  {
2158  return true;
2159  }
2160  return false;
2161  }
2162 
2163  protected:
2164  int m_axisWidth;
2165  size_t m_axisIndex;
2166  int m_xPos;
2167 
2170  virtual void DoPlot(wxDC &dc, mpWindow &w);
2171 
2172  virtual int GetOrigin(mpWindow &w);
2173  wxString GetLabelFormat(mpWindow &w);
2174  int GetLabelWidth(double value, wxDC &dc, wxString fmt);
2175  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2176 
2177  wxDECLARE_DYNAMIC_CLASS(mpScaleY);
2178 };
2179 
2180 //-----------------------------------------------------------------------------
2181 // mpWindow
2182 //-----------------------------------------------------------------------------
2183 
2188 #define mpMOUSEMODE_DRAG 0
2189 
2190 #define mpMOUSEMODE_ZOOMBOX 1
2191 
2194 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
2195 typedef std::deque<mpLayer*> mpLayerList;
2196 
2203 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
2204 
2211 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
2212 
2217 {
2218  public:
2219  mpMagnet()
2220  {
2221  m_IsDrawn = false;
2222  m_rightClick = false;
2223  m_IsWasDrawn = false;
2224  }
2225  ~mpMagnet()
2226  {
2227  ;
2228  }
2229  void UpdateBox(wxCoord left, wxCoord top, wxCoord width, wxCoord height)
2230  {
2231  m_domain = wxRect(left, top, width, height);
2232  m_plot_size = wxRect(left, top, width + left, height + top);
2233  }
2234  void UpdateBox(const wxRect &size)
2235  {
2236  m_domain = size;
2237  m_plot_size = wxRect(size.GetLeft(), size.GetTop(),
2238  size.GetWidth() + size.GetLeft(), size.GetHeight() + size.GetTop());
2239  }
2240  void Plot(wxClientDC &dc, const wxPoint &mousePos);
2241  void ClearPlot(wxClientDC &dc);
2242  void UpdatePlot(wxClientDC &dc, const wxPoint &mousePos);
2243  void SaveDrawState(void)
2244  {
2245  m_IsWasDrawn = m_IsDrawn;
2246  // In any cases, set to false because we erase and repaint all the plot
2247  m_IsDrawn = false;
2248  }
2249 
2250  void SetRightClick(void)
2251  {
2252  m_rightClick = true;
2253  }
2254 
2255  private:
2256  wxRect m_domain;
2257  wxRect m_plot_size;
2258  wxPoint m_mousePosition;
2259  bool m_IsDrawn;
2260  bool m_IsWasDrawn;
2261  bool m_rightClick;
2262  void DrawCross(wxClientDC &dc) const;
2263 };
2264 
2286 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
2287 {
2288  public:
2289  mpWindow()
2290  {
2291  InitParameters();
2292  }
2293 
2294  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
2295  long flags = 0);
2296 
2297  ~mpWindow();
2298 
2302  wxMenu* GetPopupMenu()
2303  {
2304  return &m_popmenu;
2305  }
2306 
2314  bool AddLayer(mpLayer *layer, bool refreshDisplay = true);
2315 
2325  bool DelLayer(mpLayer *layer, bool alsoDeleteObject, bool refreshDisplay = true);
2326 
2331  void DelAllLayers(bool alsoDeleteObject, bool refreshDisplay = true);
2332 
2338  void DelAllPlot(bool alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
2339 
2345  mpLayer* GetLayer(int position);
2346 
2353  mpLayer* GetLayersType(int position, mpLayerType type);
2354 
2360  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
2361 
2364  mpLayer* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
2365 
2370  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
2371 
2375  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
2376 
2381  mpLayer* GetLayerByName(const wxString &name);
2382 
2387  mpLayer* GetLayerByClassName(const wxString &name);
2388 
2392  void RefreshLegend(void);
2393 
2397  mpScaleX* GetLayerXAxis();
2398 
2402  void SetScaleX(const double scaleX)
2403  {
2404  if (ISNOTNULL(scaleX))
2405  m_scaleX = scaleX;
2406  UpdateAll();
2407  }
2408 
2413  double GetScaleX(void) const
2414  {
2415  return m_scaleX;
2416  }
2417 
2421  void SetScaleY(const double scaleY, int yIndex)
2422  {
2423  if (ISNOTNULL(scaleY))
2424  m_yAxisDataList[yIndex].m_scaleY = scaleY;
2425  UpdateAll();
2426  }
2427 
2432  double GetScaleY(int yIndex = 0) const
2433  {
2434  return m_yAxisDataList[yIndex].m_scaleY;
2435  } // Schaling's method: maybe another method exists with the same name
2436 
2437  [[deprecated("Incomplete, use UpdateBBox instead")]]
2440  void SetBound();
2441 
2444  {
2445  return m_bound;
2446  }
2447 
2451  void SetPosX(const double posX)
2452  {
2453  m_posX = posX;
2454  UpdateAll();
2455  }
2456 
2461  double GetPosX(void) const
2462  {
2463  return m_posX;
2464  }
2465 
2469  void SetPosY(const std::vector<double>& posYList)
2470  {
2471  for(size_t i = 0; i < m_yAxisDataList.size(); i++)
2472  {
2473  m_yAxisDataList[i].m_posY = posYList[i];
2474  }
2475 
2476  UpdateAll();
2477  }
2478 
2483  double GetPosY(int yIndex = 0) const
2484  {
2485  return m_yAxisDataList[yIndex].m_posY;
2486  }
2487 
2488  int GetNOfYScales(void)
2489  {
2490  return m_yAxisDataList.size();
2491  }
2492 
2493  std::vector<mpScaleY*> GetYAxisList(void) const
2494  {
2495  return m_YAxisList;
2496  }
2497 
2503  void SetScreen(const int scrX, const int scrY)
2504  {
2505  m_scrX = scrX;
2506  m_scrY = scrY;
2507  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
2508  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
2509 
2510  m_plotBoundaries.endPx = m_scrX;
2511  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
2512  m_plotBoundaries.endPy = m_scrY;
2513  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
2514 
2515  m_PlotArea = wxRect(m_margin.left - EXTRA_MARGIN, m_margin.top - EXTRA_MARGIN,
2516  m_plotWidth + 2*EXTRA_MARGIN, m_plotHeight + 2*EXTRA_MARGIN);
2517 
2518  m_magnet.UpdateBox(m_PlotArea);
2519  }
2520 
2527  int GetScreenX(void) const
2528  {
2529  return m_scrX;
2530  }
2531 
2538  int GetScreenY(void) const
2539  {
2540  return m_scrY;
2541  }
2542 
2547  void SetPos(const double posX, const std::vector<double>& posYList)
2548  {
2549  m_posX = posX;
2550  for(size_t i = 0; i < m_yAxisDataList.size(); i++)
2551  {
2552  m_yAxisDataList[i].m_posY = posYList[i];
2553  }
2554 
2555  UpdateAll();
2556  }
2557 
2561  inline double p2x(const wxCoord pixelCoordX) const
2562  {
2563  return m_posX + (pixelCoordX / m_scaleX);
2564  }
2565 
2569  inline double p2y(const wxCoord pixelCoordY, int yIndex = 0) const
2570  {
2571  return m_yAxisDataList[yIndex].m_posY - (pixelCoordY / m_yAxisDataList[yIndex].m_scaleY);
2572  }
2573 
2577  inline wxCoord x2p(const double x) const
2578  {
2579  return (wxCoord)((x - m_posX) * m_scaleX);
2580  }
2581 
2585  inline wxCoord y2p(const double y, int yIndex = 0) const
2586  {
2587  return (wxCoord)((m_yAxisDataList[yIndex].m_posY - y) * m_yAxisDataList[yIndex].m_scaleY);
2588  }
2589 
2592  void EnableDoubleBuffer(const bool enabled)
2593  {
2594  m_enableDoubleBuffer = enabled;
2595  }
2596 
2599  void EnableMousePanZoom(const bool enabled)
2600  {
2601  m_enableMouseNavigation = enabled;
2602  }
2603 
2609  void LockAspect(bool enable = true);
2610 
2615  inline bool IsAspectLocked() const
2616  {
2617  return m_lockaspect;
2618  }
2619 
2624  inline bool IsRepainting() const
2625  {
2626  return m_repainting;
2627  }
2628 
2633  void Fit();
2634 
2641  void Fit(const mpFloatRect &rect, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
2642 
2647  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
2648 
2653  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
2654 
2656  void ZoomInX();
2657 
2659  void ZoomOutX();
2660 
2663  void ZoomInY(std::optional<size_t> yIndex = std::nullopt);
2664 
2667  void ZoomOutY(std::optional<size_t> yIndex = std::nullopt);
2668 
2670  void ZoomRect(wxPoint p0, wxPoint p1);
2671 
2673  void UpdateAll();
2674 
2675  // Added methods by Davide Rondini
2676 
2680  unsigned int CountLayers();
2681 
2684  unsigned int CountAllLayers()
2685  {
2686  return (unsigned int)m_layers.size();
2687  }
2688 
2692  unsigned int CountLayersType(mpLayerType type);
2693  unsigned int CountLayersFXYPlot();
2694 
2697  //void PrintGraph(mpPrintout *print);
2698 
2701  mpFloatRect GetDesiredBoundingBox() const { return m_desired; }
2702 
2706  double GetDesiredXmin() const
2707  {
2708  return m_desired.Xmin;
2709  }
2710 
2715  double GetDesiredXmax() const
2716  {
2717  return m_desired.Xmax;
2718  }
2719 
2724  double GetDesiredYmin(int yIndex) const
2725  {
2726  return m_desired.YminList[yIndex];
2727  }
2728 
2733  double GetDesiredYmax(int yIndex) const
2734  {
2735  return m_desired.YmaxList[yIndex];
2736  }
2737 
2740  void GetBoundingBox(double *bbox) const;
2741  mpFloatRect *GetBoundingBox(void)
2742  {
2743  return &m_bound;
2744  }
2745 
2748  void SetMPScrollbars(bool status);
2749 
2752  bool GetMPScrollbars() const
2753  {
2754  return m_enableScrollBars;
2755  }
2756 
2762  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
2763 
2767  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
2768 
2772  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
2773 
2778  bool LoadFile(const wxString &filename);
2779 
2783 
2790  void SetMargins(int top, int right, int bottom, int left);
2791 
2794  {
2795  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
2796  }
2797 
2799  void SetMarginTop(int top)
2800  {
2801  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
2802  }
2803 
2805  int GetMarginTop() const
2806  {
2807  return m_margin.top;
2808  }
2809 
2811  void SetMarginRight(int right)
2812  {
2813  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
2814  }
2815 
2817  int GetMarginRight() const
2818  {
2819  return m_margin.right;
2820  }
2821 
2824  {
2825  return m_marginOuter.right;
2826  }
2827 
2829  void SetMarginBottom(int bottom)
2830  {
2831  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
2832  }
2833 
2835  int GetMarginBottom() const
2836  {
2837  return m_margin.bottom;
2838  }
2839 
2841  void SetMarginLeft(int left)
2842  {
2843  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
2844  }
2845 
2847  int GetMarginLeft() const
2848  {
2849  return m_margin.left;
2850  }
2851 
2854  {
2855  return m_marginOuter.left;
2856  }
2857 
2859  int GetPlotWidth() const
2860  {
2861  return m_plotWidth;
2862  }
2863 
2865  int GetPlotHeight() const
2866  {
2867  return m_plotHeight;
2868  }
2869 
2871  mpRect GetPlotBoundaries(bool with_margin) const
2872  {
2873  mpRect bond;
2874  if (with_margin)
2875  bond = m_plotBoundariesMargin;
2876  else
2877  bond = m_plotBoundaries;
2878  bond.startPx -= EXTRA_MARGIN;
2879  bond.endPx += EXTRA_MARGIN;
2880  bond.startPy -= EXTRA_MARGIN;
2881  bond.endPy += EXTRA_MARGIN;
2882  return bond;
2883  }
2884 
2887  int GetLeftYAxesWidth(int yAxisIndex = -1);
2888 
2891  int GetRightYAxesWidth(int yAxisIndex = -1);
2892 
2894  void SetDrawBox(bool drawbox)
2895  {
2896  m_drawBox = drawbox;
2897  }
2898 
2900  bool GetDrawBox() const
2901  {
2902  return m_drawBox;
2903  }
2904 
2908  std::optional<size_t> IsInsideYAxis(const wxPoint &point);
2909 
2913  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
2914 
2918  void SetLayerVisible(const wxString &name, bool viewable);
2919 
2923  bool IsLayerVisible(const wxString &name);
2924 
2928  bool IsLayerVisible(const unsigned int position);
2929 
2933  void SetLayerVisible(const unsigned int position, bool viewable);
2934 
2939  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
2940 
2943  const wxColour& GetAxesColour() const
2944  {
2945  return m_axColour;
2946  }
2947 
2948  const wxColour& GetbgColour() const
2949  {
2950  return m_bgColour;
2951  }
2952 
2953  void SetbgColour(const wxColour &colour)
2954  {
2955  m_bgColour = colour;
2956  }
2957 
2962  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
2963  {
2964  m_OnDeleteLayer = event;
2965  }
2966 
2969  {
2970  m_OnDeleteLayer = NULL;
2971  }
2972 
2977  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
2978  {
2979  m_OnUserMouseAction = userMouseEventHandler;
2980  }
2981 
2984  {
2985  m_OnUserMouseAction = NULL;
2986  }
2987 
2993  bool IsLogXaxis() const
2994  {
2995  return m_LogXaxis;
2996  }
2997 
2998  bool IsLogYaxis() const
2999  {
3000  return m_LogYaxis;
3001  }
3002 
3003  void SetLogXaxis(bool log)
3004  {
3005  m_LogXaxis = log;
3006  }
3007 
3008  void SetLogYaxis(bool log)
3009  {
3010  m_LogYaxis = log;
3011  }
3012 
3013  bool GetMagnetize() const
3014  {
3015  return m_magnetize;
3016  }
3017 
3018  void SetMagnetize(bool mag)
3019  {
3020  m_magnetize = mag;
3021  }
3022 
3023 #ifdef ENABLE_MP_CONFIG
3024  void RefreshConfigWindow();
3029  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
3030 #endif // ENABLE_MP_CONFIG
3031 
3032  protected:
3033  virtual void OnPaint(wxPaintEvent &event);
3034  virtual void OnSize(wxSizeEvent &event);
3035  virtual void OnShowPopupMenu(wxMouseEvent &event);
3036  virtual void OnCenter(wxCommandEvent &event);
3037  virtual void OnFit(wxCommandEvent &event);
3038  virtual void OnToggleGrids(wxCommandEvent &event);
3039  virtual void OnToggleCoords(wxCommandEvent &event);
3040  virtual void OnScreenShot(wxCommandEvent &event);
3041  virtual void OnFullScreen(wxCommandEvent &event);
3042 #ifdef ENABLE_MP_CONFIG
3043  virtual void OnConfiguration(wxCommandEvent &event);
3044 #endif // ENABLE_MP_CONFIG
3045  virtual void OnLoadFile(wxCommandEvent &event);
3046  virtual void OnZoomIn(wxCommandEvent &event);
3047  virtual void OnZoomOut(wxCommandEvent &event);
3048  virtual void OnLockAspect(wxCommandEvent &event);
3049  virtual void OnMouseHelp(wxCommandEvent &event);
3050  virtual void OnMouseLeftDown(wxMouseEvent &event);
3051  virtual void OnMouseRightDown(wxMouseEvent &event);
3052  virtual void OnMouseMove(wxMouseEvent &event);
3053  virtual void OnMouseLeftRelease(wxMouseEvent &event);
3054  virtual void OnMouseWheel(wxMouseEvent &event);
3055  virtual void OnMouseLeave(wxMouseEvent &event);
3056  bool CheckUserMouseAction(wxMouseEvent &event);
3057  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
3058  virtual void OnScrollPageUp(wxScrollWinEvent &event);
3059  virtual void OnScrollPageDown(wxScrollWinEvent &event);
3060  virtual void OnScrollLineUp(wxScrollWinEvent &event);
3061  virtual void OnScrollLineDown(wxScrollWinEvent &event);
3062  virtual void OnScrollTop(wxScrollWinEvent &event);
3063  virtual void OnScrollBottom(wxScrollWinEvent &event);
3064 
3065  void DoScrollCalc(const int position, const int orientation);
3066 
3071  void DoZoomXCalc(bool zoomIn, int staticXpixel = ZOOM_AROUND_CENTER);
3072 
3079  void DoZoomYCalc(bool zoomIn, int staticYpixel = ZOOM_AROUND_CENTER, std::optional<size_t> = std::nullopt);
3080 
3081  void Zoom(bool zoomIn, const wxPoint &centerPoint);
3082 
3085  virtual bool UpdateBBox();
3086 
3087  void InitParameters();
3088 
3093  void UpdateNOfYAxes(size_t nOfYAxes);
3094 
3095  struct m_axisData
3096  {
3097  double m_scaleY = 1.0;
3098  double m_posY = 0;
3099  };
3100 
3101  wxTopLevelWindow* m_parent;
3102  bool m_fullscreen;
3103 
3104  mpLayerList m_layers;
3106  std::vector<mpScaleY*> m_YAxisList;
3107 
3108  wxMenu m_popmenu;
3110  wxColour m_bgColour;
3111  wxColour m_fgColour;
3112  wxColour m_axColour;
3113  bool m_drawBox;
3114 
3116 
3117  double m_scaleX;
3118  double m_posX;
3119  std::vector<m_axisData> m_yAxisDataList;
3120 
3121  int m_scrX;
3122  int m_scrY;
3125 
3130 
3133  wxCoord m_plotWidth;
3134  wxCoord m_plotHeight;
3135 
3138  wxRect m_PlotArea;
3139 
3140  bool m_repainting;
3141  int m_last_lx, m_last_ly;
3142  wxBitmap* m_buff_bmp;
3145  bool m_mouseMovedAfterRightClick;
3146  wxPoint m_mouseRClick;
3147  wxPoint m_mouseLClick;
3148  std::optional<size_t> m_mouseYAxisIndex;
3149  bool m_enableScrollBars;
3150  int m_scrollX, m_scrollY;
3154  bool m_InInfoLegend;
3155 
3156  wxBitmap* m_zoom_bmp;
3157  wxRect m_zoom_dim;
3158  wxRect m_zoom_oldDim;
3159 
3162 
3163  bool m_LogXaxis = false;
3164  bool m_LogYaxis = false;
3165 
3166  wxBitmap* m_Screenshot_bmp;
3167 
3168 #ifdef ENABLE_MP_CONFIG
3169  MathPlotConfigDialog* m_configWindow = NULL;
3170 #endif // ENABLE_MP_CONFIG
3171 
3172  mpOnDeleteLayer m_OnDeleteLayer = NULL;
3173  mpOnUserMouseAction m_OnUserMouseAction = NULL;
3174 
3178  virtual void DesiredBoundsHaveChanged() {};
3179 
3180  private:
3181  void FillI18NString();
3182 
3184  void CheckAndReportDesiredBoundsChanges();
3185  bool m_initialDesiredBoundsRecorded = false;
3186  mpFloatRect m_lastDesiredReportedBounds;
3187 
3188  wxDECLARE_DYNAMIC_CLASS(mpWindow);
3189  wxDECLARE_EVENT_TABLE();
3190 
3191  // To have direct access to m_Screenshot_dc
3192  friend mpPrintout;
3193 };
3194 
3195 //-----------------------------------------------------------------------------
3196 // mpText - provided by Val Greene
3197 //-----------------------------------------------------------------------------
3198 
3206 class WXDLLIMPEXP_MATHPLOT mpText: public mpLayer
3207 {
3208  public:
3211  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
3212  {
3213  m_subtype = mptText;
3214  SetName(name);
3215  m_offsetx = 5;
3216  m_offsety = 50;
3217  m_location = mpMarginNone;
3218  m_ZIndex = mpZIndex_TEXT;
3219  }
3220 
3224  mpText(const wxString &name, int offsetx, int offsety);
3225 
3229  mpText(const wxString &name, mpLocation marginLocation);
3230 
3233  virtual bool HasBBox()
3234  {
3235  return false;
3236  }
3237 
3240  void SetLocation(mpLocation location)
3241  {
3242  m_location = location;
3243  }
3244 
3247  mpLocation GetLocation() const
3248  {
3249  return m_location;
3250  }
3251 
3254  void SetOffset(int offX, int offY)
3255  {
3256  m_offsetx = offX;
3257  m_offsety = offY;
3258  }
3259 
3262  void GetOffset(int *offX, int *offY) const
3263  {
3264  *offX = m_offsetx;
3265  *offY = m_offsety;
3266  }
3267 
3268  protected:
3271  mpLocation m_location;
3272 
3275  virtual void DoPlot(wxDC &dc, mpWindow &w);
3276 
3277  wxDECLARE_DYNAMIC_CLASS(mpText);
3278 };
3279 
3283 class WXDLLIMPEXP_MATHPLOT mpTitle: public mpText
3284 {
3285  public:
3288  mpTitle();
3289 
3292  mpTitle(const wxString &name) :
3293  mpText(name, mpMarginTopCenter)
3294  {
3295  m_subtype = mptTitle;
3296  SetPen(*wxWHITE_PEN);
3297  SetBrush(*wxWHITE_BRUSH);
3298  }
3299 
3300  protected:
3301 
3302  wxDECLARE_DYNAMIC_CLASS(mpTitle);
3303 };
3304 
3305 //-----------------------------------------------------------------------------
3306 // mpPrintout - provided by Davide Rondini
3307 //-----------------------------------------------------------------------------
3308 
3313 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
3314 {
3315  public:
3316  mpPrintout()
3317  {
3318  plotWindow = NULL;
3319  drawn = false;
3320  stretch_factor = 2;
3321  }
3322 
3323  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
3324  virtual ~mpPrintout()
3325  {
3326  ;
3327  }
3328 
3329  void SetDrawState(bool drawState)
3330  {
3331  drawn = drawState;
3332  }
3333 
3334  bool OnPrintPage(int page);
3335  bool HasPage(int page);
3336 
3339  void SetFactor(int factor)
3340  {
3341  stretch_factor = factor;
3342  }
3343 
3344  private:
3345  bool drawn;
3346  mpWindow* plotWindow;
3347  int stretch_factor; // To reduce the size of plot
3348 
3349  protected:
3350 
3351  wxDECLARE_DYNAMIC_CLASS(mpPrintout);
3352 };
3353 
3354 //-----------------------------------------------------------------------------
3355 // mpMovableObject - provided by Jose Luis Blanco
3356 //-----------------------------------------------------------------------------
3364 class WXDLLIMPEXP_MATHPLOT mpMovableObject: public mpFunction
3365 {
3366  public:
3370  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
3371  {
3372  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
3373  m_subtype = mpfMovable;
3374  m_bbox_min_x = m_bbox_max_x = 0;
3375  m_bbox_min_y = m_bbox_max_y = 0;
3376  }
3377 
3378  virtual ~mpMovableObject() {}
3379 
3382  void GetCoordinateBase(double &x, double &y, double &phi) const
3383  {
3384  x = m_reference_x;
3385  y = m_reference_y;
3386  phi = m_reference_phi;
3387  }
3388 
3391  void SetCoordinateBase(double x, double y, double phi = 0)
3392  {
3393  m_reference_x = x;
3394  m_reference_y = y;
3395  m_reference_phi = phi;
3396  m_flags = mpALIGN_NE;
3397  ShapeUpdated();
3398  }
3399 
3400  virtual bool HasBBox()
3401  {
3402  return m_trans_shape_xs.size() != 0;
3403  }
3404 
3407  virtual double GetMinX()
3408  {
3409  return m_bbox_min_x;
3410  }
3411 
3414  virtual double GetMaxX()
3415  {
3416  return m_bbox_max_x;
3417  }
3418 
3421  virtual double GetMinY()
3422  {
3423  return m_bbox_min_y;
3424  }
3425 
3428  virtual double GetMaxY()
3429  {
3430  return m_bbox_max_y;
3431  }
3432 
3433  protected:
3434 
3437  double m_reference_x, m_reference_y, m_reference_phi;
3438 
3439  virtual void DoPlot(wxDC &dc, mpWindow &w);
3440 
3443  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
3444 
3447  std::vector<double> m_shape_xs, m_shape_ys;
3448 
3452  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
3453 
3457  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
3458 
3462  void ShapeUpdated();
3463 
3464  wxDECLARE_DYNAMIC_CLASS(mpMovableObject);
3465 };
3466 
3467 //-----------------------------------------------------------------------------
3468 // mpCovarianceEllipse - provided by Jose Luis Blanco
3469 //-----------------------------------------------------------------------------
3481 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse: public mpMovableObject
3482 {
3483  public:
3487  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
3488  const wxString &layerName = _T("")) : mpMovableObject(),
3489  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
3490  {
3491  m_continuous = true;
3492  m_name = layerName;
3493  RecalculateShape();
3494  }
3495 
3496  virtual ~mpCovarianceEllipse()
3497  {
3498  ;
3499  }
3500 
3501  double GetQuantiles() const
3502  {
3503  return m_quantiles;
3504  }
3505 
3508  void SetQuantiles(double q)
3509  {
3510  m_quantiles = q;
3511  RecalculateShape();
3512  }
3513 
3514  void SetSegments(int segments)
3515  {
3516  m_segments = segments;
3517  }
3518 
3519  int GetSegments() const
3520  {
3521  return m_segments;
3522  }
3523 
3526  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
3527  {
3528  cov_00 = m_cov_00;
3529  cov_01 = m_cov_01;
3530  cov_11 = m_cov_11;
3531  }
3532 
3535  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
3536  {
3537  m_cov_00 = cov_00;
3538  m_cov_01 = cov_01;
3539  m_cov_11 = cov_11;
3540  RecalculateShape();
3541  }
3542 
3543  protected:
3546  double m_cov_00, m_cov_11, m_cov_01;
3547  double m_quantiles;
3548 
3552 
3555  void RecalculateShape();
3556 
3557  wxDECLARE_DYNAMIC_CLASS(mpCovarianceEllipse);
3558 };
3559 
3560 //-----------------------------------------------------------------------------
3561 // mpPolygon - provided by Jose Luis Blanco
3562 //-----------------------------------------------------------------------------
3567 class WXDLLIMPEXP_MATHPLOT mpPolygon: public mpMovableObject
3568 {
3569  public:
3572  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
3573  {
3574  m_continuous = true;
3575  m_name = layerName;
3576  }
3577 
3578  virtual ~mpPolygon()
3579  {
3580  ;
3581  }
3582 
3588  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
3589 
3590  protected:
3591 
3592  wxDECLARE_DYNAMIC_CLASS(mpPolygon);
3593 };
3594 
3595 //-----------------------------------------------------------------------------
3596 // mpBitmapLayer - provided by Jose Luis Blanco
3597 //-----------------------------------------------------------------------------
3602 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer: public mpLayer
3603 {
3604  public:
3608  {
3609  m_min_x = m_max_x = 0;
3610  m_min_y = m_max_y = 0;
3611  m_validImg = false;
3612  m_bitmapChanged = false;
3613  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
3614  }
3615 
3616  virtual ~mpBitmapLayer()
3617  {
3618  ;
3619  }
3620 
3623  void GetBitmapCopy(wxImage &outBmp) const;
3624 
3632  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
3633 
3636  virtual double GetMinX()
3637  {
3638  return m_min_x;
3639  }
3640 
3643  virtual double GetMaxX()
3644  {
3645  return m_max_x;
3646  }
3647 
3650  virtual double GetMinY()
3651  {
3652  return m_min_y;
3653  }
3654 
3657  virtual double GetMaxY()
3658  {
3659  return m_max_y;
3660  }
3661 
3662  protected:
3663 
3666  wxImage m_bitmap;
3667  wxBitmap m_scaledBitmap;
3668  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
3669  bool m_validImg;
3670  bool m_bitmapChanged;
3671 
3674  double m_min_x, m_max_x, m_min_y, m_max_y;
3675 
3676  virtual void DoPlot(wxDC &dc, mpWindow &w);
3677 
3678  wxDECLARE_DYNAMIC_CLASS(mpBitmapLayer);
3679 };
3680 
3681 // utility class
3682 
3683 // Enumeration of classic colour
3684 typedef enum __mp_Colour
3685 {
3686  mpBlue,
3687  mpRed,
3688  mpGreen,
3689  mpPurple,
3690  mpYellow,
3691  mpFuchsia,
3692  mpLime,
3693  mpAqua,
3694  mpOlive
3695 } mpColour;
3696 
3701 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
3702 {
3703  public:
3704  wxIndexColour(unsigned int id)
3705  {
3706  switch (id)
3707  {
3708  case 0:
3709  this->Set(0, 0, 255);
3710  break; // Blue
3711  case 1:
3712  this->Set(255, 0, 0);
3713  break; // Red
3714  case 2:
3715  this->Set(0, 128, 0);
3716  break; // Green
3717  case 3:
3718  this->Set(128, 0, 128);
3719  break; // Purple
3720  case 4:
3721  this->Set(255, 255, 0);
3722  break; // Yellow
3723  case 5:
3724  this->Set(255, 0, 255);
3725  break; // Fuchsia
3726  case 6:
3727  this->Set(0, 255, 0);
3728  break; // Lime
3729  case 7:
3730  this->Set(0, 255, 255);
3731  break; // Aqua/Cyan
3732  case 8:
3733  this->Set(128, 128, 0);
3734  break; // Olive
3735  default:
3736  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
3737  (ChannelType)((rand() * 255) / RAND_MAX));
3738  }
3739  }
3740 };
3741 
3744 // ---------------------------------------------------------------------
3745 #ifdef ENABLE_MP_NAMESPACE
3746  }// namespace MathPlot
3747  // No, iff build enables namespace, its up to app to use it appropriately: using namespace MathPlot;
3748 #endif // ENABLE_MP_NAMESPACE
3749 
3750 #endif // MATHPLOT_H_INCLUDED
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:3270
const wxString & GetLabelFormat() const
Get axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:1932
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:2203
bool IsHorizontal(void) const
Get if is horizontal line.
Definition: mathplot.h:1246
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:304
void SetValue(const double value)
Set x or y.
Definition: mathplot.h:1239
mpInfoLegend * m_InfoLegend
pointer to the optional info legend layer
Definition: mathplot.h:3153
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:351
double m_min_x
The shape of the bitmap:
Definition: mathplot.h:3674
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition: mathplot.h:3132
void EnableDoubleBuffer(const bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled).
Definition: mathplot.h:2592
mpFloatRect m_bound
Global layer bounding box in user coordinates. Does NOT include borders.
Definition: mathplot.h:3115
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:664
Bitmap type layer.
Definition: mathplot.h:445
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:785
Plot type layer.
Definition: mathplot.h:430
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:2527
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:3657
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:2968
bool operator==(const mpFloatRect &rect) const
Equal operator.
Definition: mathplot.h:254
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1290
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:3567
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:2402
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:542
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:171
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:1503
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:3123
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:350
__mp_Layer_Type
Definition: mathplot.h:426
Show/Hide grids.
Definition: mathplot.h:292
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:3602
bool m_magnetize
For mouse magnetization.
Definition: mathplot.h:3160
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1838
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:3146
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:1822
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:3572
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:1918
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:428
enum __mp_Direction_Type mpLegendDirection
Direction for the Legend layer.
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:784
virtual bool IsLayerType(mpLayerType type, int *sub_type)
Specifies that if the layer is of type "type".
Definition: mathplot.h:517
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:777
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1223
Lock x/y scaling aspect.
Definition: mathplot.h:291
void SetItemMode(mpLegendStyle mode)
Set item mode (the element on the left of text representing the plot line may be line or square)...
Definition: mathplot.h:1045
bool PointIsInside(double x, double y, size_t yIndex=0) const
Is point inside this bounding box?
Definition: mathplot.h:212
Info box type layer.
Definition: mathplot.h:450
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:3269
Abstract class providing a line.
Definition: mathplot.h:1217
Abstract class providing an vertical line.
Definition: mathplot.h:1282
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:1904
mpFloatRect m_desired
These are updated in Fit() only (also Zoom) May be different from the real borders (layer coordinates...
Definition: mathplot.h:3129
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:2286
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:1993
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:920
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:3391
Chart type layer (bar chart)
Definition: mathplot.h:435
std::optional< size_t > m_mouseYAxisIndex
Indicate which Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:3148
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:641
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:2615
int m_winY
Holds the mpWindow size. Used to rescale position when window is resized.
Definition: mathplot.h:922
~mpBarChart()
Destructor.
Definition: mathplot.h:1746
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:2561
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:792
double GetScaleY(int yIndex=0) const
Get current view&#39;s Y scale.
Definition: mathplot.h:2432
void SetLabelMode(unsigned int mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:2068
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:3147
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:3178
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:649
int m_flags
Holds label alignment. Default : mpALIGN_NE.
Definition: mathplot.h:789
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:3233
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:526
wxPoint GetPosition() const
Returns the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:884
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1000
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:695
unsigned int GetLabelMode() const
Get X axis label view mode.
Definition: mathplot.h:2061
~mpPieChart()
Destructor.
Definition: mathplot.h:1808
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1207
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:2859
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:779
Just the end of ZOrder.
Definition: mathplot.h:452
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:3421
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:443
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:2811
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:2782
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1133
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:2853
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:3108
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1345
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:1385
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:3112
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:787
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:3136
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:3382
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:2211
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:1027
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:2037
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:788
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:3240
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:1712
virtual void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:2053
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:2599
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:3113
Plot (function) type layer.
Definition: mathplot.h:448
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:1948
int GetMarginRight() const
Get the right margin.
Definition: mathplot.h:2817
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:791
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1169
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:477
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:780
bool GetCanDelete(void) const
Get CanDelete for plot.
Definition: mathplot.h:764
Axis type layer.
Definition: mathplot.h:446
Definition: MathPlotConfig.h:44
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:1846
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:1996
Axis type layer.
Definition: mathplot.h:429
void SetCanDelete(bool canDelete)
Set CanDelete for plot.
Definition: mathplot.h:757
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:3636
mpFloatRect Get_Bound(void) const
Get bounding box encompassing all visible plots on this mpWindow.
Definition: mathplot.h:2443
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:3151
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:958
double GetDesiredYmax(int yIndex) const
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
Definition: mathplot.h:2733
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:1911
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:2943
double GetDesiredYmin(int yIndex) const
Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not ex...
Definition: mathplot.h:2724
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:674
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:2195
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1625
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:3211
Definition: mathplot.h:3095
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:3666
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:2977
each visible plot is described on its own line, one above the other
Definition: mathplot.h:358
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:2451
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:771
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:2865
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:987
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:378
#define mpX_NORMAL
Set label for X axis in normal mode.
Definition: mathplot.h:2017
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1577
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:3643
Show/Hide info coord.
Definition: mathplot.h:293
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:688
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:3535
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:3313
int m_last_ly
For double buffering.
Definition: mathplot.h:3141
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:3161
wxSize GetSize() const
Returns the size of the box (in pixels)
Definition: mathplot.h:891
Chart type layer.
Definition: mathplot.h:449
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:1995
enum __mp_Location_Type mpLocation
Location for the Info layer.
mpScaleY(const wxString &name=_T("Y"), int flags=mpALIGN_CENTERY, bool grids=false, size_t axisIndex=0)
Full constructor.
Definition: mathplot.h:2115
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:918
std::vector< m_axisData > m_yAxisDataList
Current view&#39;s Y scales and Y positions.
Definition: mathplot.h:3119
Copy a screen shot to the clipboard.
Definition: mathplot.h:294
Fit view to match bounding box of all layers.
Definition: mathplot.h:287
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:3247
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:300
wxBitmap * m_buff_bmp
For double buffering.
Definition: mathplot.h:3142
Center view on click position.
Definition: mathplot.h:290
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1209
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:1513
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:319
mpFloatRect GetDesiredBoundingBox() const
Draws the mpWindow on a page for printing.
Definition: mathplot.h:2701
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:3364
double m_scaleX
Current view&#39;s X scale.
Definition: mathplot.h:3117
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:387
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:1409
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:3447
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1176
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:3701
unsigned int m_labelType
Select labels mode: mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds.
Definition: mathplot.h:2081
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1141
A structure for computation of bounds in real units (not in screen pixel) X refer to X axis Y refer t...
Definition: mathplot.h:202
Layer for bar chart.
Definition: mathplot.h:1739
#define mpX_USER
Set label user defined.
Definition: mathplot.h:2028
double m_max
Min and max axis values when autosize is false.
Definition: mathplot.h:1997
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:782
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:1006
abstract Layer for chart (bar and pie).
Definition: mathplot.h:1681
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:352
void SetPosY(const std::vector< double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:2469
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:657
std::vector< mpScaleY * > m_YAxisList
Pointer to the optional Y axes layer of this mpWindow.
Definition: mathplot.h:3106
const wxRect & GetRectangle() const
Returns the current rectangle coordinates.
Definition: mathplot.h:898
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:3457
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:2706
virtual void DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:807
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:339
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1206
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:2829
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:1533
int m_symbolSize2
Size of the symbol div 2.
Definition: mathplot.h:1208
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:3650
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:1964
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1604
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1268
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:1552
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:1561
Text box type layer.
Definition: mathplot.h:432
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:2793
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:329
int GetMarginTop() const
Get the top margin.
Definition: mathplot.h:2805
wxRect m_PlotArea
The full size of the plot with EXTRA_MARGIN.
Definition: mathplot.h:3138
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:833
Load a file.
Definition: mathplot.h:298
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:489
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:3262
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:3133
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:860
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:498
Line (horizontal or vertical) type layer.
Definition: mathplot.h:447
wxBitmap * m_zoom_bmp
For zoom selection.
Definition: mathplot.h:3156
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:942
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:2752
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:3122
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:2577
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1148
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1041
wxRect m_oldDim
Keep the old values of m_dim.
Definition: mathplot.h:919
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:3110
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:2503
int GetBarWidth(void) const
return the width of the bar
Definition: mathplot.h:1435
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:2962
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:980
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1618
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:2894
bool m_enableDoubleBuffer
For double buffering. Default enabled.
Definition: mathplot.h:3143
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1123
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1308
double GetPosY(int yIndex=0) const
Get current view&#39;s Y position.
Definition: mathplot.h:2483
mpTitle(const wxString &name)
Definition: mathplot.h:3292
void SetLabelMode(unsigned int mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:972
Plot layer implementing a simple title.
Definition: mathplot.h:3283
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:2108
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:3400
bool ViewAsBar(void) const
return true if XY series is plotted with bar
Definition: mathplot.h:1443
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:923
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:722
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:2871
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:2461
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:750
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:786
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:3452
void SetScaleY(const double scaleY, int yIndex)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:2421
virtual void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:1925
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:1956
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:1401
enum __XAxis_Align_Type mpXAxis_Align
Alignment for X axis.
bool IsLogXaxis() const
Log axis control.
Definition: mathplot.h:2993
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1205
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:2983
std::vector< double > m_xs
The internal copy of the set of data to draw.
Definition: mathplot.h:1569
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, unsigned int type=0x00)
Full constructor.
Definition: mathplot.h:2045
~mpChart()
Destructor.
Definition: mathplot.h:1688
Abstract class providing an horizontal line.
Definition: mathplot.h:1260
Zoom into view at clickposition / window center.
Definition: mathplot.h:288
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:3109
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:3551
void Rewind()
Rewind value enumeration with mpFXY::GetNextXY.
Definition: mathplot.h:1586
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:2547
Zoom out.
Definition: mathplot.h:289
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:1878
void SetFont(const wxFont &font)
Set layer font.
Definition: mathplot.h:617
Class for drawing mouse magnetization.
Definition: mathplot.h:2216
int m_reserveXY
Memory reserved for m_xs and m_ys.
Definition: mathplot.h:1573
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:356
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:3481
double m_minX
Loaded at SetData.
Definition: mathplot.h:1581
mpInfoCoords * m_InfoCoords
pointer to the optional info coords layer
Definition: mathplot.h:3152
double GetDesiredXmax() const
Returns the right-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:2715
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:348
Layer for pie chart.
Definition: mathplot.h:1801
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:633
bool IsNotSet() const
Is mpFloatRect set ?
Definition: mathplot.h:247
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:3487
wxCoord y2p(const double y, int yIndex=0) const
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:2585
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:625
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:3144
int GetMarginLeft() const
Get the left margin.
Definition: mathplot.h:2847
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:781
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:3526
Bitmap type layer.
Definition: mathplot.h:433
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:905
void UpdateBoundingBoxToInclude(double x, double y, size_t yIndex=0)
Update bounding box to include this point.
Definition: mathplot.h:229
bool IsVisible() const
Checks whether the layer is visible or not.
Definition: mathplot.h:715
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:1897
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:506
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:736
int GetMarginBottom() const
Get the bottom margin.
Definition: mathplot.h:2835
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1184
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:3369
Info box type layer.
Definition: mathplot.h:431
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:2538
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:550
Plot layer implementing a text string.
Definition: mathplot.h:3206
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:3134
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:3428
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:2900
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:702
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:783
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:2823
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:534
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:921
Shows information about the mouse commands.
Definition: mathplot.h:299
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:2799
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:2413
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:3111
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:3166
legend components follow each other horizontally on a single line
Definition: mathplot.h:359
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1058
mpScaleX * m_XAxis
Pointer to the optional X axis layer of this mpWindow.
Definition: mathplot.h:3105
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:3508
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:3124
void InitializeBoundingBox(double x, double y, size_t yIndex=0)
Initialize bounding box with an initial point.
Definition: mathplot.h:239
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:3437
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:1830
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1155
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:3407
Plot layer, abstract base class.
Definition: mathplot.h:465
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:790
double p2y(const wxCoord pixelCoordY, int yIndex=0) const
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:2569
double GetValue() const
Set x or y.
Definition: mathplot.h:1231
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:3254
void SetFactor(int factor)
Definition: mathplot.h:3339
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:601
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:778
size_t m_yAxisIndex
The index of the Y axis, 0 is the first axis (default)
Definition: mathplot.h:1210
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:1998
double m_posX
Current view&#39;s X position.
Definition: mathplot.h:3118
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:3121
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:681
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:609
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:3546
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:2841
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:3104
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:1994
mpRect m_margin
Margin around the plot including Y-axis.
Definition: mathplot.h:3131
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1650
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:912
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:3137
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:729
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:1890
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:3414
bool IsRepainting() const
Checks if we are repainting.
Definition: mathplot.h:2624
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:2684
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:1940
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2082
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1162
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:3607
Text box type layer.
Definition: mathplot.h:451
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:2302
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:743
Line (horizontal or vertical) type layer.
Definition: mathplot.h:434
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1611