MathPlot
mathplot.h
1 // Name: mathplot.cpp
3 // Purpose: Framework for plotting in wxWindows
4 // Original Author: David Schalig
5 // Maintainer: Davide Rondini
6 // Contributors: Jose Luis Blanco, Val Greene, Lionel Reynaud, Dave Nadler, MortenMacFly,
7 // Oskar Waldemarsson (for multi Y axis and corrections)
8 // Created: 21/07/2003
9 // Last edit: 23/11/2025
10 // Copyright: (c) David Schalig, Davide Rondini
11 // Licence: wxWindows licence
13 
14 #ifndef MATHPLOT_H_INCLUDED
15 #define MATHPLOT_H_INCLUDED
16 
17 #define MATHPLOT_MANY_YAXIS
18 
19 
58 //this definition uses windows dll to export function.
59 //WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
60 //mathplot_EXPORTS will be defined by cmake
61 #ifdef mathplot_EXPORTS
62 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
63 #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
64 #else // not making DLL
65 #define WXDLLIMPEXP_MATHPLOT
66 #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
67 #endif
68 
69 #if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
70 #pragma interface "mathplot.h"
71 #endif
72 
73 #include <vector>
74 #include <map>
75 #include <optional>
76 
77 // #include <wx/wx.h>
78 #include <wx/defs.h>
79 #include <wx/menu.h>
80 #include <wx/scrolwin.h>
81 #include <wx/event.h>
82 #include <wx/dynarray.h>
83 #include <wx/pen.h>
84 #include <wx/dcmemory.h>
85 #include <wx/string.h>
86 #include <wx/print.h>
87 #include <wx/image.h>
88 #include <wx/intl.h>
89 
90 #include <cmath>
91 #include <deque>
92 #include <algorithm>
93 
94 // No, this is supposed to be a build parameter: #define ENABLE_MP_CONFIG
95 #ifdef ENABLE_MP_CONFIG
96  #include "MathPlotConfig.h"
97 #endif // ENABLE_MP_CONFIG
98 
103 // No, this is supposed to be a build parameter: #define ENABLE_MP_NAMESPACE
104 #ifdef ENABLE_MP_NAMESPACE
105  namespace MathPlot {
106 #endif // ENABLE_MP_NAMESPACE
107 
108 #ifdef ENABLE_MP_DEBUG
109 // For memory leak debug
110 #ifdef _WINDOWS
111 #ifdef _DEBUG
112 #include <crtdbg.h>
113 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
114 #else
115 #define DEBUG_NEW new
116 #endif // _DEBUG
117 #endif // _WINDOWS
118 #endif // ENABLE_MP_DEBUG
119 
120 // Separation for axes when set close to border
121 #define X_BORDER_SEPARATION 40
122 #define Y_BORDER_SEPARATION 60
123 
125 #define mpX_LOCALTIME 0x10
126 
127 #define mpX_UTCTIME 0x20
128 #define mpX_RAWTIME mpX_UTCTIME
129 
130 // An epsilon for float comparison to 0
131 #define EPSILON 1e-8
132 #define ISNOTNULL(x) (fabs(x) > EPSILON)
133 
134 // A small extra margin for the plot boundary
135 #define EXTRA_MARGIN 8
136 
137 #define ZOOM_AROUND_CENTER -1
138 
139 //-----------------------------------------------------------------------------
140 // classes
141 //-----------------------------------------------------------------------------
142 
143 class WXDLLIMPEXP_MATHPLOT mpLayer;
144 class WXDLLIMPEXP_MATHPLOT mpFunction;
145 class WXDLLIMPEXP_MATHPLOT mpLine;
146 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine;
147 class WXDLLIMPEXP_MATHPLOT mpVerticalLine;
148 class WXDLLIMPEXP_MATHPLOT mpFX;
149 class WXDLLIMPEXP_MATHPLOT mpFY;
150 class WXDLLIMPEXP_MATHPLOT mpFXY;
151 class WXDLLIMPEXP_MATHPLOT mpFXYVector;
152 class WXDLLIMPEXP_MATHPLOT mpProfile;
153 class WXDLLIMPEXP_MATHPLOT mpChart;
154 class WXDLLIMPEXP_MATHPLOT mpBarChart;
155 class WXDLLIMPEXP_MATHPLOT mpScale;
156 class WXDLLIMPEXP_MATHPLOT mpScaleX;
157 class WXDLLIMPEXP_MATHPLOT mpScaleY;
158 class WXDLLIMPEXP_MATHPLOT mpInfoLayer;
159 class WXDLLIMPEXP_MATHPLOT mpInfoCoords;
160 class WXDLLIMPEXP_MATHPLOT mpInfoLegend;
161 class WXDLLIMPEXP_MATHPLOT mpWindow;
162 class WXDLLIMPEXP_MATHPLOT mpText;
163 class WXDLLIMPEXP_MATHPLOT mpTitle;
164 class WXDLLIMPEXP_MATHPLOT mpPrintout;
165 class WXDLLIMPEXP_MATHPLOT mpMovableObject;
166 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse;
167 class WXDLLIMPEXP_MATHPLOT mpPolygon;
168 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer;
169 
170 #ifdef ENABLE_MP_CONFIG
172 #endif // ENABLE_MP_CONFIG
173 
175 typedef union
176 {
177  struct
178  {
179  wxCoord startPx;
180  wxCoord endPx;
181  wxCoord startPy;
182  wxCoord endPy;
183  };
184  struct
185  {
186  wxCoord left;
187  wxCoord top;
188  wxCoord right;
189  wxCoord bottom;
190  };
191  struct
192  {
193  wxCoord x1;
194  wxCoord y1;
195  wxCoord x2;
196  wxCoord y2;
197  };
198  wxCoord tab[4];
199 } mpRect;
200 
206 struct mpRange
207 {
208  double min = 0.0f;
209  double max = 0.0f;
210 
211 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
212  bool operator==(const mpRange&) const = default;
213 #else
214  bool operator==(const mpRange& other) const
215  {
216  return min == other.min && max == other.max;
217  }
218 #endif
219 };
220 
226 struct mpAxisData
227 {
228  double scale = 1.0;
229  double pos = 0;
230 
231 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
232  bool operator==(const mpAxisData&) const = default;
233 #else
234  bool operator==(const mpAxisData& other) const
235  {
236  return scale == other.scale && pos == other.pos;
237  }
238 #endif
239 };
240 
246 //struct mpFloatRect
247 //{
248 // mpRange x;
249 // std::vector<mpRange> y;
250 //
251 // /**
252 // * Constructs a new mpFloatRect using it parent mpWindow to obtain
253 // * the number of Y-scales to use. This makes sure that the y-size
254 // * always matches the parant mpWindow y-size
255 // * @param w parent mpWindow from which to obtain informations
256 // */
257 // mpFloatRect(mpWindow& w);
258 //
259 // /// Only allow constructor with mpWindow supplied
260 // mpFloatRect() = delete;
261 //
262 // /// Is point inside this bounding box?
279 // /// Update bounding box to include this point
290 // /// Initialize bounding box with an initial point
299 // /// Is mpFloatRect set ?
300 // bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
301 // /// Equal operator
302 //#if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
303 // bool operator==(const mpFloatRect&) const = default;
304 //#else
305 // // We compare with an epsilon precision
306 // // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
307 // bool operator==(const mpFloatRect& rect) const
308 // {
309 // auto Same = [](double a, double b) {
310 // return std::fabs(a - b) < EPSILON;
311 // };
312 //
313 // // Compare scalar members
318 //
319 // // Compare vector sizes
320 // if (y.size() != rect.y.size())
321 // {
322 // return false;
323 // }
324 //
325 // // Compare each Y boundary
326 // for (size_t i = 0; i < y.size(); ++i)
327 // {
328 // if (!Same(y[i].min, rect.y[i].min) ||
329 // !Same(y[i].max, rect.y[i].max) )
330 // {
331 // return false;
332 // }
333 // }
334 //
335 // return true;
336 // }
337 //#endif
338 //};
339 
343 enum
344 {
345  mpID_FIT = 2000,
346  mpID_ZOOM_IN,
347  mpID_ZOOM_OUT,
348  mpID_CENTER,
349  mpID_LOCKASPECT,
350  mpID_TOGGLE_GRID,
351  mpID_TOGGLE_COORD,
352  mpID_SCREENSHOT,
353 #ifdef ENABLE_MP_CONFIG
354  mpID_CONFIG,
355 #endif // ENABLE_MP_CONFIG
356  mpID_LOAD_FILE,
357  mpID_HELP_MOUSE,
358  mpID_FULLSCREEN
359 };
360 
362 typedef enum __mp_Location_Type
363 {
364  mpMarginLeftCenter,
365  mpMarginTopLeft,
366  mpMarginTopCenter,
367  mpMarginTopRight,
368  mpMarginRightCenter,
369  mpMarginBottomLeft,
370  mpMarginBottomCenter,
371  mpMarginBottomRight,
372  mpMarginNone,
373  mpCursor // only for mpInfoCoords
374 } mpLocation;
375 
377 typedef enum __XAxis_Align_Type
378 {
379  mpALIGN_BORDER_BOTTOM = 10,
380  mpALIGN_BOTTOM,
381  mpALIGN_CENTERX,
382  mpALIGN_TOP,
383  mpALIGN_BORDER_TOP
384 } mpXAxis_Align;
385 
387 typedef enum __YAxis_Align_Type
388 {
389  mpALIGN_BORDER_LEFT = 20,
390  mpALIGN_LEFT,
391  mpALIGN_CENTERY,
392  mpALIGN_RIGHT,
393  mpALIGN_BORDER_RIGHT
394 } mpYAxis_Align;
395 
397 typedef enum __Plot_Align_Name_Type
398 {
399  mpALIGN_NW = 5,
400  mpALIGN_NE,
401  mpALIGN_SE,
402  mpALIGN_SW
403 } mpPlot_Align;
404 
406 typedef enum __mp_Style_Type
407 {
408  mpLegendLine,
409  mpLegendSquare,
410  mpLegendSymbol
411 } mpLegendStyle;
412 
414 typedef enum __mp_Direction_Type
415 {
416  mpVertical,
417  mpHorizontal
418 } mpLegendDirection;
419 
420 typedef enum __Symbol_Type
421 {
422  mpsNone,
423  mpsCircle,
424  mpsSquare,
425  mpsUpTriangle,
426  mpsDownTriangle,
427  mpsCross,
428  mpsPlus
429 } mpSymbol;
430 
431 //-----------------------------------------------------------------------------
432 // mpLayer sub_type values
433 //-----------------------------------------------------------------------------
434 
436 typedef enum __Info_Type
437 {
438  mpiNone, // never used
439  mpiInfo,
440  mpiCoords,
441  mpiLegend
442 } mpInfoType;
443 
445 typedef enum __Text_Type
446 {
447  mptNone, // never used
448  mptText,
449  mptTitle
450 } mpTextType;
451 
452 typedef enum __Function_Type
453 {
454  mpfNone,
455  mpfFX,
456  mpfFY,
457  mpfFXY,
458  mpfFXYVector,
459  mpfMovable,
460  mpfLine,
461  mpfAllType
462 } mpFunctionType;
463 
464 typedef enum __Scale_Type
465 {
466  mpsScaleNone,
467  mpsScaleX,
468  mpsScaleY,
469  mpsAllType
470 } mpScaleType;
471 
472 typedef enum __Chart_Type
473 {
474  mpcChartNone,
475  mpcBarChart,
476  mpcPieChart,
477  mpcAllType
478 } mpChartType;
479 
480 enum mpMouseButtonAction
481 {
482  mpMouseBoxZoom,
483  mpMouseDragZoom,
484 };
485 
486 //-----------------------------------------------------------------------------
487 // mpLayer
488 //-----------------------------------------------------------------------------
489 
490 typedef enum __mp_Layer_Type
491 {
492  mpLAYER_UNDEF,
493  mpLAYER_AXIS,
494  mpLAYER_PLOT,
495  mpLAYER_INFO,
496  mpLAYER_TEXT,
497  mpLAYER_BITMAP,
498  mpLAYER_LINE,
499  mpLAYER_CHART,
500 } mpLayerType;
501 
507 typedef enum __mp_Layer_ZOrder
508 {
509  mpZIndex_BACKGROUND,
510  mpZIndex_AXIS,
511  mpZIndex_LINE,
512  mpZIndex_PLOT,
513  mpZIndex_CHART,
514  mpZIndex_INFO,
515  mpZIndex_TEXT,
516  mpZIndex_END
517 } mpLayerZOrder;
518 
529 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
530 {
531  public:
532  mpLayer(mpLayerType layerType);
533 
534  virtual ~mpLayer()
535  {
536  ;
537  }
538 
542  {
543  m_win = &w;
544  }
545 
553  virtual bool HasBBox()
554  {
555  return true;
556  }
557 
562  mpLayerType GetLayerType() const
563  {
564  return m_type;
565  }
566 
570  int GetLayerSubType() const
571  {
572  return m_subtype;
573  }
574 
580  virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
581  {
582  *subtype = m_subtype;
583  return (m_type == typeOfInterest);
584  }
585 
589  virtual double GetMinX()
590  {
591  return -1.0;
592  }
593 
597  virtual double GetMaxX()
598  {
599  return 1.0;
600  }
601 
605  virtual double GetMinY()
606  {
607  return -1.0;
608  }
609 
613  virtual double GetMaxY()
614  {
615  return 1.0;
616  }
617 
659  void Plot(wxDC &dc, mpWindow &w);
660 
664  void SetName(const wxString &name)
665  {
666  m_name = name;
667  }
668 
672  const wxString& GetName() const
673  {
674  return m_name;
675  }
676 
680  void SetFont(const wxFont &font)
681  {
682  m_font = font;
683  }
684 
688  const wxFont& GetFont() const
689  {
690  return m_font;
691  }
692 
696  void SetFontColour(const wxColour &colour)
697  {
698  m_fontcolour = colour;
699  }
700 
704  const wxColour& GetFontColour() const
705  {
706  return m_fontcolour;
707  }
708 
712  void SetPen(const wxPen &pen)
713  {
714  m_pen = pen;
715  }
716 
720  const wxPen& GetPen() const
721  {
722  return m_pen;
723  }
724 
727  void SetBrush(const wxBrush &brush)
728  {
729  if (brush == wxNullBrush)
730  m_brush = *wxTRANSPARENT_BRUSH;
731  else
732  m_brush = brush;
733  }
734 
737  const wxBrush& GetBrush() const
738  {
739  return m_brush;
740  }
741 
744  void SetShowName(bool show)
745  {
746  m_showName = show;
747  }
748 
751  inline bool GetShowName() const
752  {
753  return m_showName;
754  }
755 
758  void SetDrawOutsideMargins(bool drawModeOutside)
759  {
760  m_drawOutsideMargins = drawModeOutside;
761  }
762 
766  {
767  return m_drawOutsideMargins;
768  }
769 
774  wxBitmap GetColourSquare(int side = 16);
775 
778  inline bool IsVisible() const
779  {
780  return m_visible;
781  }
782 
785  virtual void SetVisible(bool show)
786  {
787  m_visible = show;
788  }
789 
792  inline bool IsTractable() const
793  {
794  return m_tractable;
795  }
796 
799  virtual void SetTractable(bool track)
800  {
801  m_tractable = track;
802  }
803 
806  void SetAlign(int align)
807  {
808  m_flags = align;
809  }
810 
813  int GetAlign() const
814  {
815  return m_flags;
816  }
817 
820  void SetCanDelete(bool canDelete)
821  {
822  m_CanDelete = canDelete;
823  }
824 
827  bool GetCanDelete(void) const
828  {
829  return m_CanDelete;
830  }
831 
834  mpLayerZOrder GetZIndex(void) const
835  {
836  return m_ZIndex;
837  }
838 
839  protected:
840  const mpLayerType m_type;
841  mpWindow* m_win;
842  int m_subtype;
843  wxFont m_font;
844  wxColour m_fontcolour;
845  wxPen m_pen;
846  wxBrush m_brush;
847  wxString m_name;
848  bool m_showName;
849  bool m_drawOutsideMargins;
850  bool m_visible;
851  bool m_tractable;
852  int m_flags;
853  mpRect m_plotBoundaries;
854  bool m_CanDelete;
855  mpLayerZOrder m_ZIndex;
856 
859  void UpdateContext(wxDC &dc) const;
860 
865  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
866 
871  virtual bool DoBeforePlot()
872  {
873  return true;
874  }
875 
882  void CheckLog(double *x, double *y, int yID);
883 
884  private:
885  bool m_busy;
886  mpLayer() = delete; // default ctor not implemented/permitted
887 
888  wxDECLARE_DYNAMIC_CLASS(mpLayer);
889 };
890 
891 //-----------------------------------------------------------------------------
892 // mpInfoLayer
893 //-----------------------------------------------------------------------------
894 
900 class WXDLLIMPEXP_MATHPLOT mpInfoLayer: public mpLayer
901 {
902  public:
904  mpInfoLayer();
905 
910  mpInfoLayer(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
911 
913  virtual ~mpInfoLayer();
914 
917  virtual void SetVisible(bool show);
918 
923  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
924 
927  virtual bool HasBBox()
928  {
929  return false;
930  }
931 
935  virtual void ErasePlot(wxDC &dc, mpWindow &w);
936 
940  virtual bool Inside(const wxPoint &point);
941 
944  virtual void Move(wxPoint delta);
945 
947  virtual void UpdateReference();
948 
951  wxPoint GetPosition() const
952  {
953  return m_dim.GetPosition();
954  }
955 
958  wxSize GetSize() const
959  {
960  return m_dim.GetSize();
961  }
962 
965  const wxRect& GetRectangle() const
966  {
967  return m_dim;
968  }
969 
972  void SetLocation(mpLocation location)
973  {
974  m_location = location;
975  }
976 
979  mpLocation GetLocation() const
980  {
981  return m_location;
982  }
983 
984  protected:
985  wxRect m_dim;
986  wxRect m_oldDim;
987  wxBitmap* m_info_bmp;
988  wxPoint m_reference;
989  int m_winX, m_winY;
990  mpLocation m_location;
991 
996  virtual void DoPlot(wxDC &dc, mpWindow &w);
997 
1000  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1001 
1002  wxDECLARE_DYNAMIC_CLASS(mpInfoLayer);
1003 };
1004 
1009 class WXDLLIMPEXP_MATHPLOT mpInfoCoords: public mpInfoLayer
1010 {
1011  public:
1013  mpInfoCoords();
1014 
1016  mpInfoCoords(mpLocation location);
1017 
1022  mpInfoCoords(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
1023 
1026  {
1027  ;
1028  }
1029 
1033  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1034 
1035  virtual void ErasePlot(wxDC &dc, mpWindow &w);
1036 
1039  void SetLabelMode(unsigned int mode, unsigned int time_conv = mpX_RAWTIME)
1040  {
1041  m_labelType = mode;
1042  m_timeConv = time_conv;
1043  }
1044 
1047  void SetSeriesCoord(bool show)
1048  {
1049  m_series_coord = show;
1050  }
1051 
1054  bool IsSeriesCoord() const
1055  {
1056  return m_series_coord;
1057  }
1058 
1064  virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::vector<double> yValList);
1065 
1068  void SetPenSeries(const wxPen &pen)
1069  {
1070  m_penSeries = pen;
1071  }
1072 
1073  protected:
1074  wxString m_content;
1075  unsigned int m_labelType;
1076  unsigned int m_timeConv;
1077  wxCoord m_mouseX;
1078  wxCoord m_mouseY;
1079  bool m_series_coord;
1080  wxPen m_penSeries;
1081 
1086  virtual void DoPlot(wxDC &dc, mpWindow &w);
1087 
1088  wxDECLARE_DYNAMIC_CLASS(mpInfoCoords);
1089 };
1090 
1095 class WXDLLIMPEXP_MATHPLOT mpInfoLegend: public mpInfoLayer
1096 {
1097  public:
1099  mpInfoLegend();
1100 
1106  mpInfoLegend(wxRect rect, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginNone);
1107 
1110 
1113  void SetItemMode(mpLegendStyle mode)
1114  {
1115  m_item_mode = mode;
1116  m_needs_update = true;
1117  }
1118 
1119  mpLegendStyle GetItemMode() const
1120  {
1121  return m_item_mode;
1122  }
1123 
1126  void SetItemDirection(mpLegendDirection mode)
1127  {
1128  m_item_direction = mode;
1129  m_needs_update = true;
1130  }
1131 
1132  mpLegendDirection GetItemDirection() const
1133  {
1134  return m_item_direction;
1135  }
1136 
1137  void SetNeedUpdate()
1138  {
1139  m_needs_update = true;
1140  }
1141 
1143  int GetPointed(mpWindow &w, wxPoint eventPoint);
1144 
1145  protected:
1146  mpLegendStyle m_item_mode;
1147  mpLegendDirection m_item_direction;
1148 
1153  virtual void DoPlot(wxDC &dc, mpWindow &w);
1154 
1155  private:
1157  struct LegendDetail
1158  {
1159  unsigned int layerIdx;
1160  wxCoord legendEnd;
1161  };
1163  std::vector<LegendDetail> m_LegendDetailList;
1164  bool m_needs_update;
1165 
1175  void UpdateBitmap(wxDC &dc, mpWindow &w);
1176 
1177  wxDECLARE_DYNAMIC_CLASS(mpInfoLegend);
1178 };
1179 
1180 //-----------------------------------------------------------------------------
1181 // mpLayer implementations - furniture (scales, ...)
1182 //-----------------------------------------------------------------------------
1189 class WXDLLIMPEXP_MATHPLOT mpScale: public mpLayer
1190 {
1191  public:
1196  mpScale(const wxString &name, int flags, bool grids);
1197 
1201  virtual bool HasBBox()
1202  {
1203  return false;
1204  }
1205 
1208  void ShowTicks(bool ticks)
1209  {
1210  m_ticks = ticks;
1211  }
1212 
1215  bool GetShowTicks() const
1216  {
1217  return m_ticks;
1218  }
1219 
1222  void ShowGrids(bool grids)
1223  {
1224  m_grids = grids;
1225  }
1226 
1229  bool GetShowGrids() const
1230  {
1231  return m_grids;
1232  }
1233 
1236  virtual void SetLabelFormat(const wxString &format)
1237  {
1238  m_labelFormat = format;
1239  }
1240 
1243  const wxString& GetLabelFormat() const
1244  {
1245  return m_labelFormat;
1246  }
1247 
1251  void SetGridPen(const wxPen &pen)
1252  {
1253  m_gridpen = pen;
1254  }
1255 
1259  const wxPen& GetGridPen() const
1260  {
1261  return m_gridpen;
1262  }
1263 
1267  void SetAuto(bool automaticScalingIsEnabled)
1268  {
1269  m_auto = automaticScalingIsEnabled;
1270  }
1271 
1275  bool GetAuto() const
1276  {
1277  return m_auto;
1278  }
1279 
1280  void SetMinScale(double min)
1281  {
1282  m_min = min;
1283  }
1284 
1285  double GetMinScale() const
1286  {
1287  return m_min;
1288  }
1289 
1290  void SetMaxScale(double max)
1291  {
1292  m_max = max;
1293  }
1294 
1295  double GetMaxScale() const
1296  {
1297  return m_max;
1298  }
1299 
1303  virtual bool IsLogAxis()
1304  {
1305  return m_isLog;
1306  }
1307 
1308  virtual void SetLogAxis(bool log)
1309  {
1310  m_isLog = log;
1311  }
1312 
1313  protected:
1314  static const wxCoord kTickSize = 4;
1315  static const wxCoord kAxisExtraSpace = 6;
1316 
1317  wxPen m_gridpen;
1318  bool m_ticks;
1319  bool m_grids;
1320  bool m_auto;
1321  double m_min, m_max;
1322  wxString m_labelFormat;
1323  bool m_isLog;
1324 
1325  virtual int GetOrigin(mpWindow &w) = 0;
1326 
1333  double GetStep(double scale, int minLabelSpacing);
1334  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
1335 
1336  wxString FormatLogValue(double n);
1337 
1338  wxDECLARE_DYNAMIC_CLASS(mpScale);
1339 };
1340 
1342 #define mpX_NORMAL 0x00
1343 
1345 #define mpX_TIME 0x01
1346 
1347 #define mpX_HOURS 0x02
1348 
1349 #define mpX_DATE 0x03
1350 
1351 #define mpX_DATETIME 0x04
1352 
1353 #define mpX_USER 0x05
1354 
1355 #define mpX_NONE 0x06
1356 
1362 class WXDLLIMPEXP_MATHPLOT mpScaleX: public mpScale
1363 {
1364  public:
1370  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, unsigned int type = mpX_NORMAL) :
1371  mpScale(name, flags, grids)
1372  {
1373  m_subtype = mpsScaleX;
1374  m_labelType = type;
1375  m_timeConv = mpX_RAWTIME;
1376  }
1377 
1378  virtual void SetLabelFormat(const wxString &format)
1379  {
1380  mpScale::SetLabelFormat(format);
1381  m_labelType = mpX_USER;
1382  }
1383 
1386  unsigned int GetLabelMode() const
1387  {
1388  return m_labelType;
1389  }
1390 
1393  void SetLabelMode(unsigned int mode, unsigned int time_conv = mpX_RAWTIME)
1394  {
1395  m_labelType = mode;
1396  m_timeConv = time_conv;
1397  }
1398 
1399  protected:
1400  unsigned int m_labelType;
1401  unsigned int m_timeConv;
1402 
1405  virtual void DoPlot(wxDC &dc, mpWindow &w);
1406 
1412  int GetLabelWidth(double value, wxDC &dc, wxString fmt);
1413 
1414  virtual int GetOrigin(mpWindow &w);
1415  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
1416  wxString FormatValue(const wxString &fmt, double n);
1417 
1418  wxDECLARE_DYNAMIC_CLASS(mpScaleX);
1419 };
1420 
1427 class WXDLLIMPEXP_MATHPLOT mpScaleY: public mpScale
1428 {
1429  public:
1434  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false) :
1435  mpScale(name, flags, grids)
1436  {
1437  m_subtype = mpsScaleY;
1438  m_axisWidth = Y_BORDER_SEPARATION;
1439  m_axisID = m_LastYAxisID++;
1440  m_UseCount = 0;
1441  m_xPos = 0;
1442  }
1443 
1446  void UpdateAxisWidth(mpWindow &w);
1447 
1451  int GetAxisID(void)
1452  {
1453  return m_axisID;
1454  }
1455 
1460  void UpdateUseCount(bool increase)
1461  {
1462  if (increase)
1463  m_UseCount++;
1464  else
1465  m_UseCount--;
1466  }
1467 
1472  int GetUseCount(void) const
1473  {
1474  return m_UseCount;
1475  }
1476 
1477  int GetAxisWidth()
1478  {
1479  return m_axisWidth;
1480  }
1481 
1482  bool IsLeftAxis()
1483  {
1484  return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
1485  }
1486 
1487  bool IsRightAxis()
1488  {
1489  return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
1490  }
1491 
1492  bool IsInside(wxCoord xPixel)
1493  {
1494  if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
1495  {
1496  return true;
1497  }
1498  return false;
1499  }
1500 
1501  protected:
1502  static int m_LastYAxisID; // Static ID to assign unique ID to each new instance of mpScaleY
1503 
1504  int m_axisWidth;
1505  int m_axisID; // Unique ID that identify this axis
1506  int m_UseCount; // Count the number of function who use this axis. If this number is not null, you can not delete this axis.
1507  int m_xPos;
1508 
1511  virtual void DoPlot(wxDC &dc, mpWindow &w);
1512 
1513  virtual int GetOrigin(mpWindow &w);
1514  wxString GetLabelFormat(mpWindow &w);
1515  int GetLabelWidth(double value, wxDC &dc, wxString fmt);
1516  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
1517 
1518  wxDECLARE_DYNAMIC_CLASS(mpScaleY);
1519 };
1520 
1521 //-----------------------------------------------------------------------------
1522 // mpLayer implementations - functions
1523 //-----------------------------------------------------------------------------
1524 
1532 class WXDLLIMPEXP_MATHPLOT mpFunction: public mpLayer
1533 {
1534  public:
1537  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, mpScaleY *yAxisUsed = NULL);
1538 
1542  void SetContinuity(bool continuity)
1543  {
1544  m_continuous = continuity;
1545  }
1546 
1550  bool GetContinuity() const
1551  {
1552  return m_continuous;
1553  }
1554 
1557  void SetStep(unsigned int step)
1558  {
1559  m_step = step;
1560  }
1561 
1564  unsigned int GetStep() const
1565  {
1566  return m_step;
1567  }
1568 
1571  void SetSymbol(mpSymbol symbol)
1572  {
1573  m_symbol = symbol;
1574  }
1575 
1578  mpSymbol GetSymbol() const
1579  {
1580  return m_symbol;
1581  }
1582 
1585  void SetSymbolSize(int size)
1586  {
1587  m_symbolSize = size;
1588  m_symbolSize2 = size / 2;
1589  }
1590 
1593  int GetSymbolSize() const
1594  {
1595  return m_symbolSize;
1596  }
1597 
1601  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1602 
1606  int GetYAxisID() const
1607  {
1608  return m_yAxisID;
1609  }
1610 
1615  void SetYAxis(mpScaleY *yAxisUsed)
1616  {
1617  if (yAxisUsed == NULL)
1618  {
1619  if (m_yAxis != NULL)
1620  {
1621  m_yAxis->UpdateUseCount(false);
1622  }
1623  m_yAxis = NULL;
1624  m_yAxisID = -1;
1625  }
1626  else
1627  {
1628  if (m_yAxisID != yAxisUsed->GetAxisID())
1629  {
1630  if (m_yAxis)
1631  m_yAxis->UpdateUseCount(false);
1632  m_yAxisID = yAxisUsed->GetAxisID();
1633  yAxisUsed->UpdateUseCount(true);
1634  m_yAxis = yAxisUsed;
1635  }
1636  }
1637  }
1638 
1639  protected:
1640  bool m_continuous;
1641  mpSymbol m_symbol;
1642  int m_symbolSize;
1643  int m_symbolSize2;
1644  unsigned int m_step;
1646  mpScaleY *m_yAxis = NULL;
1647 
1652  virtual bool DoBeforePlot()
1653  {
1654  return (m_yAxisID != -1);
1655  }
1656 
1657  wxDECLARE_DYNAMIC_CLASS(mpFunction);
1658 };
1659 
1662 class WXDLLIMPEXP_MATHPLOT mpLine: public mpFunction
1663 {
1664  public:
1665  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1666 
1667  // We don't want to include line (horizontal or vertical) in BBox computation
1668  virtual bool HasBBox() override
1669  {
1670  return false;
1671  }
1672 
1676  double GetValue() const
1677  {
1678  return m_value;
1679  }
1680 
1684  void SetValue(const double value)
1685  {
1686  m_value = value;
1687  }
1688 
1691  bool IsHorizontal(void) const
1692  {
1693  return m_IsHorizontal;
1694  }
1695 
1696  protected:
1697  double m_value;
1698  bool m_IsHorizontal;
1699 
1700  wxDECLARE_DYNAMIC_CLASS(mpLine);
1701 };
1702 
1705 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine: public mpLine
1706 {
1707  public:
1708  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, mpScaleY *yAxisUsed = NULL);
1709 
1713  void SetYValue(const double yvalue)
1714  {
1715  SetValue(yvalue);
1716  }
1717 
1718  protected:
1719 
1720  virtual void DoPlot(wxDC &dc, mpWindow &w);
1721 
1722  wxDECLARE_DYNAMIC_CLASS(mpHorizontalLine);
1723 };
1724 
1727 class WXDLLIMPEXP_MATHPLOT mpVerticalLine: public mpLine
1728 {
1729  public:
1730  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1731 
1735  void SetXValue(const double xvalue)
1736  {
1737  SetValue(xvalue);
1738  }
1739 
1740  protected:
1741 
1742  virtual void DoPlot(wxDC &dc, mpWindow &w);
1743 
1744  wxDECLARE_DYNAMIC_CLASS(mpVerticalLine);
1745 };
1746 
1753 class WXDLLIMPEXP_MATHPLOT mpFX: public mpFunction
1754 {
1755  public:
1759  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, mpScaleY *yAxisUsed = NULL);
1760 
1766  virtual double GetY(double x) = 0;
1767 
1772  double DoGetY(double x);
1773 
1778  void DefineDoGetY(void);
1779 
1780  protected:
1781 
1782  // Pointer function to the appropriate DoGetY function
1783  double (mpFX::*pDoGetY)(double x);
1784 
1789  virtual void DoPlot(wxDC &dc, mpWindow &w);
1790 
1794  double NormalDoGetY(double x);
1795  double LogDoGetY(double x);
1796 
1797  wxDECLARE_DYNAMIC_CLASS(mpFX);
1798 };
1799 
1806 class WXDLLIMPEXP_MATHPLOT mpFY: public mpFunction
1807 {
1808  public:
1812  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, mpScaleY *yAxisUsed = NULL);
1813 
1819  virtual double GetX(double y) = 0;
1820 
1825  double DoGetX(double y);
1826 
1831  void DefineDoGetX(void);
1832 
1833  protected:
1834 
1835  // Pointer function to the appropriate DoGetX function
1836  double (mpFY::*pDoGetX)(double y);
1837 
1842  virtual void DoPlot(wxDC &dc, mpWindow &w);
1843 
1847  double NormalDoGetX(double y);
1848  double LogDoGetX(double y);
1849 
1850  wxDECLARE_DYNAMIC_CLASS(mpFY);
1851 };
1852 
1862 class WXDLLIMPEXP_MATHPLOT mpFXY: public mpFunction
1863 {
1864  public:
1868  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, mpScaleY *yAxisUsed = NULL);
1869 
1873  virtual void Rewind() = 0;
1874 
1878  virtual void Clear()
1879  {
1880  ;
1881  }
1882 
1886  virtual int GetSize()
1887  {
1888  return 0;
1889  }
1890 
1897  virtual bool GetNextXY(double *x, double *y) = 0;
1898 
1902  bool DoGetNextXY(double *x, double *y);
1903 
1907  void SetViewMode(bool asBar);
1908 
1912  int GetBarWidth(void) const
1913  {
1914  return m_BarWidth;
1915  }
1916 
1920  bool ViewAsBar(void) const
1921  {
1922  return m_ViewAsBar;
1923  }
1924 
1925  protected:
1926 
1927  // Data to calculate label positioning
1928  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
1929 
1930  // Min delta between 2 x coordinate (used for view as bar)
1931  double m_deltaX, m_deltaY;
1932 
1933  // The width of a bar
1934  int m_BarWidth;
1935 
1936  // Plot data as bar graph
1937  bool m_ViewAsBar = false;
1938 
1939  // Can the series be deleted?
1940  bool m_CanDelete = true;
1941 
1946  virtual void DoPlot(wxDC &dc, mpWindow &w);
1947 
1952  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
1953 
1954  wxDECLARE_DYNAMIC_CLASS(mpFXY);
1955 };
1956 
1957 //-----------------------------------------------------------------------------
1958 // mpFXYVector - provided by Jose Luis Blanco
1959 //-----------------------------------------------------------------------------
1960 
1980 class WXDLLIMPEXP_MATHPLOT mpFXYVector: public mpFXY
1981 {
1982  public:
1986  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, mpScaleY *yAxisUsed = NULL);
1987 
1990  virtual ~mpFXYVector()
1991  {
1992  Clear();
1993  }
1994 
1999  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
2000 
2004  void Clear();
2005 
2010  virtual int GetSize()
2011  {
2012  return m_xs.size();
2013  }
2014 
2022  bool AddData(const double x, const double y, bool updatePlot);
2023 
2029  void SetReserve(int reserve)
2030  {
2031  m_reserveXY = reserve;
2032  m_xs.reserve(m_reserveXY);
2033  m_ys.reserve(m_reserveXY);
2034  }
2035 
2038  int GetReserve() const
2039  {
2040  return m_reserveXY;
2041  }
2042 
2043  protected:
2046  std::vector<double> m_xs, m_ys;
2047 
2050  int m_reserveXY;
2051 
2054  size_t m_index;
2055 
2058  double m_minX, m_maxX, m_minY, m_maxY, m_lastX, m_lastY;
2059 
2063  inline void Rewind()
2064  {
2065  m_index = 0;
2066  }
2067 
2073  virtual bool GetNextXY(double *x, double *y);
2074 
2077  void DrawAddedPoint(double x, double y);
2078 
2081  virtual double GetMinX()
2082  {
2083  if(m_ViewAsBar)
2084  {
2085  // Make extra space for outer bars
2086  return m_minX - (m_deltaX / 2);
2087  }
2088  else
2089  {
2090  return m_minX;
2091  }
2092  }
2093 
2096  virtual double GetMinY()
2097  {
2098  return m_minY;
2099  }
2100 
2103  virtual double GetMaxX()
2104  {
2105  if(m_ViewAsBar)
2106  {
2107  // Make extra space for outer bars
2108  return m_maxX + (m_deltaX / 2);
2109  }
2110  else
2111  {
2112  return m_maxX;
2113  }
2114  }
2115 
2118  virtual double GetMaxY()
2119  {
2120  return m_maxY;
2121  }
2122 
2123  private:
2126  void First_Point(double x, double y);
2127 
2130  void Check_Limit(double val, double *min, double *max, double *last, double *delta);
2131 
2132  wxDECLARE_DYNAMIC_CLASS(mpFXYVector);
2133 };
2134 
2143 class WXDLLIMPEXP_MATHPLOT mpProfile: public mpFunction
2144 {
2145  public:
2149  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
2150 
2156  virtual double GetY(double x) = 0;
2157 
2158  protected:
2159 
2164  virtual void DoPlot(wxDC &dc, mpWindow &w);
2165 
2166  wxDECLARE_DYNAMIC_CLASS(mpProfile);
2167 };
2168 
2169 //-----------------------------------------------------------------------------
2170 // mpChart
2171 //-----------------------------------------------------------------------------
2174 class WXDLLIMPEXP_MATHPLOT mpChart: public mpFunction
2175 {
2176  public:
2178  mpChart(const wxString &name = wxEmptyString);
2179 
2182  {
2183  Clear();
2184  }
2185 
2188  void SetChartValues(const std::vector<double> &data);
2189 
2192  void SetChartLabels(const std::vector<std::string> &labelArray);
2193 
2198  void AddData(const double &data, const std::string &label);
2199 
2203  virtual void Clear();
2204 
2205  virtual bool HasBBox()
2206  {
2207  return (values.size() > 0);
2208  }
2209 
2210  protected:
2211  std::vector<double> values;
2212  std::vector<std::string> labels;
2213 
2214  double m_max_value;
2215  double m_total_value;
2216 
2217  wxDECLARE_DYNAMIC_CLASS(mpChart);
2218 };
2219 
2220 //-----------------------------------------------------------------------------
2221 // mpBarChart - provided by Jose Davide Rondini
2222 //-----------------------------------------------------------------------------
2223 /* Defines for bar charts label positioning. */
2224 #define mpBAR_NONE 0
2225 #define mpBAR_AXIS_H 1
2226 #define mpBAR_AXIS_V 2
2227 #define mpBAR_INSIDE 3
2228 #define mpBAR_TOP 4
2229 
2230 
2232 class WXDLLIMPEXP_MATHPLOT mpBarChart: public mpChart
2233 {
2234  public:
2236  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2237 
2240  {
2241  Clear();
2242  }
2243 
2244  void SetBarColour(const wxColour &colour);
2245 
2246  void SetColumnWidth(const double colWidth)
2247  {
2248  m_width = colWidth;
2249  }
2250 
2252  void SetBarLabelPosition(int position);
2253 
2257  virtual double GetMinX();
2258 
2262  virtual double GetMaxX();
2263 
2267  virtual double GetMinY();
2268 
2272  virtual double GetMaxY();
2273 
2274  protected:
2275 
2276  double m_width;
2277  wxColour m_barColour;
2278  int m_labelPos;
2279  double m_labelAngle;
2280 
2285  virtual void DoPlot(wxDC &dc, mpWindow &w);
2286 
2287  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2288 };
2289 
2294 class WXDLLIMPEXP_MATHPLOT mpPieChart: public mpChart
2295 {
2296  public:
2298  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2299 
2302  {
2303  Clear();
2304  colours.clear();
2305  }
2306 
2310  void SetPieColours(const std::vector<wxColour> &colourArray);
2311 
2315  virtual double GetMinX()
2316  {
2317  return -m_radius;
2318  }
2319 
2323  virtual double GetMaxX()
2324  {
2325  return m_radius;
2326  }
2327 
2331  virtual double GetMinY()
2332  {
2333  return -m_radius;
2334  }
2335 
2339  virtual double GetMaxY()
2340  {
2341  return m_radius;
2342  }
2343 
2344  protected:
2345 
2346  double m_radius;
2347  std::vector<wxColour> colours;
2348 
2353  virtual void DoPlot(wxDC &dc, mpWindow &w);
2354 
2355  const wxColour& GetColour(unsigned int id);
2356 
2357  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
2358 };
2359 
2362 //-----------------------------------------------------------------------------
2363 // mpWindow
2364 //-----------------------------------------------------------------------------
2365 
2370 #define mpMOUSEMODE_DRAG 0
2371 
2372 #define mpMOUSEMODE_ZOOMBOX 1
2373 
2376 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
2377 typedef std::deque<mpLayer*> mpLayerList;
2378 
2389 {
2390  mpScaleY* Axis;
2394 
2395 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
2396  bool operator==(const mpYAxisInfo&) const = default;
2397 #else
2398  bool operator==(const mpYAxisInfo& other) const
2399  {
2400  return (Axis == other.Axis) && Data == other.Data &&
2401  Bound == other.Bound && Desired == other.Desired;
2402  }
2403 #endif
2404 };
2405 
2412 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
2413 
2420 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
2421 
2425 class mpMagnet
2426 {
2427  public:
2428  mpMagnet()
2429  {
2430  m_IsDrawn = false;
2431  m_rightClick = false;
2432  m_IsWasDrawn = false;
2433  }
2434  ~mpMagnet()
2435  {
2436  ;
2437  }
2438  void UpdateBox(wxCoord left, wxCoord top, wxCoord width, wxCoord height)
2439  {
2440  m_domain = wxRect(left, top, width, height);
2441  m_plot_size = wxRect(left, top, width + left, height + top);
2442  }
2443  void UpdateBox(const wxRect &size)
2444  {
2445  m_domain = size;
2446  m_plot_size = wxRect(size.GetLeft(), size.GetTop(),
2447  size.GetWidth() + size.GetLeft(), size.GetHeight() + size.GetTop());
2448  }
2449  void Plot(wxClientDC &dc, const wxPoint &mousePos);
2450  void ClearPlot(wxClientDC &dc);
2451  void UpdatePlot(wxClientDC &dc, const wxPoint &mousePos);
2452  void SaveDrawState(void)
2453  {
2454  m_IsWasDrawn = m_IsDrawn;
2455  // In any cases, set to false because we erase and repaint all the plot
2456  m_IsDrawn = false;
2457  }
2458 
2459  void SetRightClick(void)
2460  {
2461  m_rightClick = true;
2462  }
2463 
2464  private:
2465  wxRect m_domain;
2466  wxRect m_plot_size;
2467  wxPoint m_mousePosition;
2468  bool m_IsDrawn;
2469  bool m_IsWasDrawn;
2470  bool m_rightClick;
2471  void DrawCross(wxClientDC &dc) const;
2472 };
2473 
2495 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
2496 {
2497  public:
2498  mpWindow()
2499  {
2500  InitParameters();
2501  }
2502 
2503  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
2504  long flags = 0);
2505 
2506  ~mpWindow();
2507 
2511  wxMenu* GetPopupMenu()
2512  {
2513  return &m_popmenu;
2514  }
2515 
2523  bool AddLayer(mpLayer *layer, bool refreshDisplay = true);
2524 
2534  bool DelLayer(mpLayer *layer, bool alsoDeleteObject, bool refreshDisplay = true);
2535 
2540  void DelAllLayers(bool alsoDeleteObject, bool refreshDisplay = true);
2541 
2547  void DelAllPlot(bool alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
2548 
2554  mpLayer* GetLayer(int position);
2555 
2562  mpLayer* GetLayersType(int position, mpLayerType type);
2563 
2569  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
2570 
2573  mpLayer* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
2574 
2579  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
2580 
2584  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear);
2585 
2590  mpLayer* GetLayerByName(const wxString &name);
2591 
2596  mpLayer* GetLayerByClassName(const wxString &name);
2597 
2601  void RefreshLegend(void);
2602 
2607  bool IsYAxisUsed(int yID);
2608 
2612  mpScaleX* GetLayerXAxis();
2613 
2617  mpScaleY* GetLayerYAxis(int yID);
2618 
2622  void SetScaleX(const double scaleX)
2623  {
2624  if (ISNOTNULL(scaleX))
2625  {
2626  m_scaleX = scaleX;
2627  UpdateDesiredBoundingBox();
2628  }
2629  UpdateAll();
2630  }
2631 
2636  double GetScaleX(void) const
2637  {
2638  return m_scaleX;
2639  }
2640 
2645  void SetScaleY(const double scaleY, int yID)
2646  {
2647  assert(m_YAxisList.count(yID) != 0);
2648  if (ISNOTNULL(scaleY))
2649  {
2650  m_YAxisList[yID].Data.scale = scaleY;
2651  UpdateDesiredBoundingBox();
2652  }
2653  UpdateAll();
2654  }
2655 
2661  double GetScaleY(int yID)
2662  {
2663  assert(m_YAxisList.count(yID) != 0);
2664  return m_YAxisList[yID].Data.scale;
2665  } // Schaling's method: maybe another method exists with the same name
2666 
2667  [[deprecated("Incomplete, use UpdateBBox instead")]]
2670  void SetBound();
2671 
2673  mpRange Get_BoundX(void) const
2674  {
2675  return m_boundx;
2676  }
2677 
2682  {
2683  assert(m_YAxisList.count(yID) != 0);
2684  return m_YAxisList[yID].Bound;
2685  }
2686 
2690  void SetPosX(const double posX)
2691  {
2692  m_posX = posX;
2693  UpdateDesiredBoundingBox();
2694  UpdateAll();
2695  }
2696 
2701  double GetPosX(void) const
2702  {
2703  return m_posX;
2704  }
2705 
2710  void SetPosY(const std::vector<double>& posYList)
2711  {
2712  int i = 0;
2713  for (auto& axisInfo : m_YAxisList)
2714  {
2715  axisInfo.second.Data.pos = posYList[i];
2716  i++;
2717  }
2718  UpdateDesiredBoundingBox();
2719  UpdateAll();
2720  }
2721 
2727  double GetPosY(int yID)
2728  {
2729  assert(m_YAxisList.count(yID) != 0);
2730  return m_YAxisList[yID].Data.pos;
2731  }
2732 
2736  int GetNOfYAxis(void) const
2737  {
2738  return (int)m_YAxisList.size();
2739  }
2740 
2741  std::map<int, mpYAxisInfo> GetYAxisList(void) const
2742  {
2743  return m_YAxisList;
2744  }
2745 
2751  void SetScreen(const int scrX, const int scrY)
2752  {
2753  m_scrX = scrX;
2754  m_scrY = scrY;
2755  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
2756  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
2757 
2758  m_plotBoundaries.endPx = m_scrX;
2759  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
2760  m_plotBoundaries.endPy = m_scrY;
2761  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
2762 
2763  m_PlotArea = wxRect(m_margin.left - EXTRA_MARGIN, m_margin.top - EXTRA_MARGIN,
2764  m_plotWidth + 2*EXTRA_MARGIN, m_plotHeight + 2*EXTRA_MARGIN);
2765 
2766  m_magnet.UpdateBox(m_PlotArea);
2767  }
2768 
2775  int GetScreenX(void) const
2776  {
2777  return m_scrX;
2778  }
2779 
2786  int GetScreenY(void) const
2787  {
2788  return m_scrY;
2789  }
2790 
2796  void SetPos(const double posX, const std::vector<double>& posYList)
2797  {
2798  m_posX = posX;
2799  SetPosY(posYList);
2800  }
2801 
2805  inline double p2x(const wxCoord pixelCoordX) const
2806  {
2807  return m_posX + (pixelCoordX / m_scaleX);
2808  }
2809 
2813  inline double p2y(const wxCoord pixelCoordY, int yID)
2814  {
2815  assert(m_YAxisList.count(yID) != 0);
2816  if (m_YAxisList.count(yID) == 0)
2817  return 0.0;
2818  return m_YAxisList[yID].Data.pos - (pixelCoordY / m_YAxisList[yID].Data.scale);
2819  }
2820 
2824  inline wxCoord x2p(const double x) const
2825  {
2826  return (wxCoord)((x - m_posX) * m_scaleX);
2827  }
2828 
2832  inline wxCoord y2p(const double y, int yID)
2833  {
2834  assert(m_YAxisList.count(yID) != 0);
2835  if (m_YAxisList.count(yID) == 0)
2836  return 0;
2837  return (wxCoord)((m_YAxisList[yID].Data.pos - y) * m_YAxisList[yID].Data.scale);
2838  }
2839 
2842  void EnableDoubleBuffer(const bool enabled)
2843  {
2844  m_enableDoubleBuffer = enabled;
2845  }
2846 
2849  void EnableMousePanZoom(const bool enabled)
2850  {
2851  m_enableMouseNavigation = enabled;
2852  }
2853 
2859  void LockAspect(bool enable = true);
2860 
2865  inline bool IsAspectLocked() const
2866  {
2867  return m_lockaspect;
2868  }
2869 
2874  inline bool IsRepainting() const
2875  {
2876  return m_repainting;
2877  }
2878 
2883  void Fit();
2884 
2891  void Fit(const mpRange &rangeX, const std::vector<mpRange> &rangeY, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
2892 
2896  void FitX(void);
2897 
2902  void FitY(int yID);
2903 
2908  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
2909 
2914  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
2915 
2917  void ZoomInX();
2918 
2920  void ZoomOutX();
2921 
2924  void ZoomInY(std::optional<int> yIndex = std::nullopt);
2925 
2928  void ZoomOutY(std::optional<int> yIndex = std::nullopt);
2929 
2931  void ZoomRect(wxPoint p0, wxPoint p1);
2932 
2934  void UpdateAll();
2935 
2936  // Added methods by Davide Rondini
2937 
2941  unsigned int CountLayers();
2942 
2945  unsigned int CountAllLayers()
2946  {
2947  return (unsigned int)m_layers.size();
2948  }
2949 
2953  unsigned int CountLayersType(mpLayerType type);
2954  unsigned int CountLayersFXYPlot();
2955 
2958  //void PrintGraph(mpPrintout *print);
2959 
2966  {
2967  m_desiredx.min = m_posX + (m_margin.left / m_scaleX);
2968  m_desiredx.max = m_posX + ((m_margin.left + m_plotWidth) / m_scaleX);
2969 
2970  for (auto& axisInfo : m_YAxisList)
2971  {
2972  axisInfo.second.Desired.max = axisInfo.second.Data.pos - (m_margin.top / axisInfo.second.Data.scale);
2973  axisInfo.second.Desired.min = axisInfo.second.Data.pos - ((m_margin.top + m_plotHeight) / axisInfo.second.Data.scale);
2974  }
2975 
2976  CheckAndReportDesiredBoundsChanges();
2977  }
2978 
2981 // mpFloatRect GetDesiredBoundingBox() const { /*return m_desired; */}
2982 
2986  double GetDesiredXmin() const
2987  {
2988  return m_desiredx.min;
2989  }
2990 
2995  double GetDesiredXmax() const
2996  {
2997  return m_desiredx.max;
2998  }
2999 
3005  double GetDesiredYmin(int yID)
3006  {
3007  assert(m_YAxisList.count(yID) != 0);
3008  return m_YAxisList[yID].Desired.min;
3009  }
3010 
3016  double GetDesiredYmax(int yID)
3017  {
3018  assert(m_YAxisList.count(yID) != 0);
3019  return m_YAxisList[yID].Desired.max;
3020  }
3021 
3023  bool GetBoundingBox(mpRange *boundX, mpRange *boundY, int yID)
3024  {
3025  if (m_YAxisList.count(yID) == 0)
3026  return false;
3027  *boundX = m_boundx;
3028  *boundY = m_YAxisList[yID].Bound;
3029  return true;
3030  }
3031 
3034  void SetMPScrollbars(bool status);
3035 
3038  bool GetMPScrollbars() const
3039  {
3040  return m_enableScrollBars;
3041  }
3042 
3048  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
3049 
3053  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3054 
3058  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
3059 
3064  bool LoadFile(const wxString &filename);
3065 
3068  static double m_zoomIncrementalFactor;
3069 
3076  void SetMargins(int top, int right, int bottom, int left);
3077 
3080  {
3081  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3082  }
3083 
3085  void SetMarginTop(int top)
3086  {
3087  SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
3088  }
3089 
3091  int GetMarginTop() const
3092  {
3093  return m_margin.top;
3094  }
3095 
3097  void SetMarginRight(int right)
3098  {
3099  SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
3100  }
3101 
3103  int GetMarginRight() const
3104  {
3105  return m_margin.right;
3106  }
3107 
3110  {
3111  return m_marginOuter.right;
3112  }
3113 
3115  void SetMarginBottom(int bottom)
3116  {
3117  SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
3118  }
3119 
3121  int GetMarginBottom() const
3122  {
3123  return m_margin.bottom;
3124  }
3125 
3127  void SetMarginLeft(int left)
3128  {
3129  SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
3130  }
3131 
3133  int GetMarginLeft() const
3134  {
3135  return m_margin.left;
3136  }
3137 
3140  {
3141  return m_marginOuter.left;
3142  }
3143 
3145  int GetPlotWidth() const
3146  {
3147  return m_plotWidth;
3148  }
3149 
3151  int GetPlotHeight() const
3152  {
3153  return m_plotHeight;
3154  }
3155 
3157  mpRect GetPlotBoundaries(bool with_margin) const
3158  {
3159  mpRect bond;
3160  if (with_margin)
3161  bond = m_plotBoundariesMargin;
3162  else
3163  bond = m_plotBoundaries;
3164  bond.startPx -= EXTRA_MARGIN;
3165  bond.endPx += EXTRA_MARGIN;
3166  bond.startPy -= EXTRA_MARGIN;
3167  bond.endPy += EXTRA_MARGIN;
3168  return bond;
3169  }
3170 
3174  int GetLeftYAxesWidth(std::optional<int> yID = std::nullopt);
3175 
3179  int GetRightYAxesWidth(std::optional<int> yID = std::nullopt);
3180 
3182  void SetDrawBox(bool drawbox)
3183  {
3184  m_drawBox = drawbox;
3185  }
3186 
3188  bool GetDrawBox() const
3189  {
3190  return m_drawBox;
3191  }
3192 
3196  std::optional<int> IsInsideYAxis(const wxPoint &point);
3197 
3201  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
3202 
3206  void SetLayerVisible(const wxString &name, bool viewable);
3207 
3211  bool IsLayerVisible(const wxString &name);
3212 
3216  bool IsLayerVisible(const unsigned int position);
3217 
3221  void SetLayerVisible(const unsigned int position, bool viewable);
3222 
3227  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
3228 
3231  const wxColour& GetAxesColour() const
3232  {
3233  return m_axColour;
3234  }
3235 
3236  const wxColour& GetbgColour() const
3237  {
3238  return m_bgColour;
3239  }
3240 
3241  void SetbgColour(const wxColour &colour)
3242  {
3243  m_bgColour = colour;
3244  }
3245 
3250  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
3251  {
3252  m_OnDeleteLayer = event;
3253  }
3254 
3257  {
3258  m_OnDeleteLayer = NULL;
3259  }
3260 
3265  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
3266  {
3267  m_OnUserMouseAction = userMouseEventHandler;
3268  }
3269 
3272  {
3273  m_OnUserMouseAction = NULL;
3274  }
3275 
3281  bool IsLogXaxis()
3282  {
3283  if (m_XAxis)
3284  return m_XAxis->IsLogAxis();
3285  else
3286  return false;
3287  }
3288 
3292  bool IsLogYaxis(int yID)
3293  {
3294  assert(m_YAxisList.count(yID) != 0);
3295  mpScaleY* yAxis = GetLayerYAxis(yID);
3296  if (yAxis)
3297  return yAxis->IsLogAxis();
3298  else
3299  return false;
3300  }
3301 
3302  void SetLogXaxis(bool log)
3303  {
3304  if (m_XAxis)
3305  m_XAxis->SetLogAxis(log);
3306  }
3307 
3311  void SetLogYaxis(int yID, bool log)
3312  {
3313  mpScaleY* yAxis = GetLayerYAxis(yID);
3314  if (yAxis)
3315  yAxis->SetLogAxis(log);
3316  }
3317 
3323  bool GetMagnetize() const
3324  {
3325  return m_magnetize;
3326  }
3327 
3328  void SetMagnetize(bool mag)
3329  {
3330  m_magnetize = mag;
3331  }
3332 
3337  void SetMouseLeftDownAction(mpMouseButtonAction action)
3338  {
3339  m_mouseLeftDownAction = action;
3340  }
3341 
3346  mpMouseButtonAction GetMouseLeftDownAction()
3347  {
3348  return m_mouseLeftDownAction;
3349  }
3350 
3351 #ifdef ENABLE_MP_CONFIG
3352  void RefreshConfigWindow();
3357  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
3358 #endif // ENABLE_MP_CONFIG
3359 
3360  protected:
3361  virtual void OnPaint(wxPaintEvent &event);
3362  virtual void OnSize(wxSizeEvent &event);
3363  virtual void OnShowPopupMenu(wxMouseEvent &event);
3364  virtual void OnCenter(wxCommandEvent &event);
3365  virtual void OnFit(wxCommandEvent &event);
3366  virtual void OnToggleGrids(wxCommandEvent &event);
3367  virtual void OnToggleCoords(wxCommandEvent &event);
3368  virtual void OnScreenShot(wxCommandEvent &event);
3369  virtual void OnFullScreen(wxCommandEvent &event);
3370 #ifdef ENABLE_MP_CONFIG
3371  virtual void OnConfiguration(wxCommandEvent &event);
3372 #endif // ENABLE_MP_CONFIG
3373  virtual void OnLoadFile(wxCommandEvent &event);
3374  virtual void OnZoomIn(wxCommandEvent &event);
3375  virtual void OnZoomOut(wxCommandEvent &event);
3376  virtual void OnLockAspect(wxCommandEvent &event);
3377  virtual void OnMouseHelp(wxCommandEvent &event);
3378  virtual void OnMouseLeftDown(wxMouseEvent &event);
3379  virtual void OnMouseRightDown(wxMouseEvent &event);
3380  virtual void OnMouseMove(wxMouseEvent &event);
3381  virtual void OnMouseLeftRelease(wxMouseEvent &event);
3382  virtual void OnMouseWheel(wxMouseEvent &event);
3383  virtual void OnMouseLeave(wxMouseEvent &event);
3384  bool CheckUserMouseAction(wxMouseEvent &event);
3385  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
3386  virtual void OnScrollPageUp(wxScrollWinEvent &event);
3387  virtual void OnScrollPageDown(wxScrollWinEvent &event);
3388  virtual void OnScrollLineUp(wxScrollWinEvent &event);
3389  virtual void OnScrollLineDown(wxScrollWinEvent &event);
3390  virtual void OnScrollTop(wxScrollWinEvent &event);
3391  virtual void OnScrollBottom(wxScrollWinEvent &event);
3392 
3393  void DoScrollCalc(const int position, const int orientation);
3394 
3399  void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = ZOOM_AROUND_CENTER);
3400 
3407  void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = ZOOM_AROUND_CENTER, std::optional<int> = std::nullopt);
3408 
3413  void SetScaleXAndCenter(double scaleX);
3414 
3420  void SetScaleYAndCenter(double scaleY, int yID);
3421 
3422  void Zoom(bool zoomIn, const wxPoint &centerPoint);
3423 
3426  virtual bool UpdateBBox();
3427 
3428  void InitParameters();
3429 
3430  wxTopLevelWindow* m_parent;
3431  bool m_fullscreen;
3432 
3433  mpLayerList m_layers;
3434  mpScaleX* m_XAxis;
3435  std::map<int, mpYAxisInfo> m_YAxisList;
3436 
3437  wxMenu m_popmenu;
3438  bool m_lockaspect;
3439  wxColour m_bgColour;
3440  wxColour m_fgColour;
3441  wxColour m_axColour;
3442  bool m_drawBox;
3443 
3444  double m_scaleX;
3445  double m_posX;
3446 
3447  int m_scrX;
3448  int m_scrY;
3449  int m_clickedX;
3450  int m_clickedY;
3451 
3452  mpRange m_boundx;
3453  mpRange m_desiredx;
3454 
3455  mpRect m_margin;
3456  mpRect m_marginOuter;
3457  wxCoord m_plotWidth;
3458  wxCoord m_plotHeight;
3459 
3460  mpRect m_plotBoundaries;
3461  mpRect m_plotBoundariesMargin;
3462  wxRect m_PlotArea;
3463 
3464  bool m_repainting;
3465  int m_last_lx, m_last_ly;
3466  wxBitmap* m_buff_bmp;
3467  bool m_enableDoubleBuffer;
3468  bool m_enableMouseNavigation;
3469  mpMouseButtonAction m_mouseLeftDownAction;
3470  bool m_mouseMovedAfterRightClick;
3471  wxPoint m_mouseRClick;
3472  wxPoint m_mouseLClick;
3473  double m_mouseScaleX;
3474  std::vector<double> m_mouseScaleYList;
3475  std::optional<int> m_mouseYAxisID;
3476  bool m_enableScrollBars;
3477  int m_scrollX, m_scrollY;
3478  mpInfoLayer* m_movingInfoLayer;
3479  mpInfoCoords* m_InfoCoords;
3480  mpInfoLegend* m_InfoLegend;
3481  bool m_InInfoLegend;
3482 
3483  wxBitmap* m_zoom_bmp;
3484  wxRect m_zoom_dim;
3485  wxRect m_zoom_oldDim;
3486 
3487  bool m_magnetize;
3488  mpMagnet m_magnet;
3489 
3490  wxBitmap* m_Screenshot_bmp;
3491 
3492 #ifdef ENABLE_MP_CONFIG
3493  MathPlotConfigDialog* m_configWindow = NULL;
3494 #endif // ENABLE_MP_CONFIG
3495 
3496  mpOnDeleteLayer m_OnDeleteLayer = NULL;
3497  mpOnUserMouseAction m_OnUserMouseAction = NULL;
3498 
3502  virtual void DesiredBoundsHaveChanged() {}; // called from CheckAndReportDesiredBoundsChanges()
3503 
3504  private:
3505  void FillI18NString();
3506 
3507  void CheckAndReportDesiredBoundsChanges();
3508  bool m_initialDesiredBoundsRecorded = false;
3509 // mpFloatRect m_lastDesiredReportedBounds; //!< for use in DesiredBoundsHaveChanged reporting in Fit()
3510 
3511  wxDECLARE_DYNAMIC_CLASS(mpWindow);
3512  wxDECLARE_EVENT_TABLE();
3513 
3514  // To have direct access to m_Screenshot_dc
3515  friend mpPrintout;
3516 };
3517 
3518 //-----------------------------------------------------------------------------
3519 // mpText - provided by Val Greene
3520 //-----------------------------------------------------------------------------
3521 
3529 class WXDLLIMPEXP_MATHPLOT mpText: public mpLayer
3530 {
3531  public:
3534  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
3535  {
3536  m_subtype = mptText;
3537  SetName(name);
3538  m_offsetx = 5;
3539  m_offsety = 50;
3540  m_location = mpMarginNone;
3541  m_ZIndex = mpZIndex_TEXT;
3542  }
3543 
3547  mpText(const wxString &name, int offsetx, int offsety);
3548 
3552  mpText(const wxString &name, mpLocation marginLocation);
3553 
3556  virtual bool HasBBox()
3557  {
3558  return false;
3559  }
3560 
3563  void SetLocation(mpLocation location)
3564  {
3565  m_location = location;
3566  }
3567 
3570  mpLocation GetLocation() const
3571  {
3572  return m_location;
3573  }
3574 
3577  void SetOffset(int offX, int offY)
3578  {
3579  m_offsetx = offX;
3580  m_offsety = offY;
3581  }
3582 
3584  void GetOffset(int *offX, int *offY) const
3585  {
3586  *offX = m_offsetx;
3587  *offY = m_offsety;
3588  }
3589 
3590  protected:
3591  int m_offsetx;
3592  int m_offsety;
3593  mpLocation m_location;
3594 
3597  virtual void DoPlot(wxDC &dc, mpWindow &w);
3598 
3599  wxDECLARE_DYNAMIC_CLASS(mpText);
3600 };
3601 
3605 class WXDLLIMPEXP_MATHPLOT mpTitle: public mpText
3606 {
3607  public:
3610  mpTitle();
3611 
3614  mpTitle(const wxString &name) :
3615  mpText(name, mpMarginTopCenter)
3616  {
3617  m_subtype = mptTitle;
3618  SetPen(*wxWHITE_PEN);
3619  SetBrush(*wxWHITE_BRUSH);
3620  }
3621 
3622  protected:
3623 
3624  wxDECLARE_DYNAMIC_CLASS(mpTitle);
3625 };
3626 
3627 //-----------------------------------------------------------------------------
3628 // mpPrintout - provided by Davide Rondini
3629 //-----------------------------------------------------------------------------
3630 
3635 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
3636 {
3637  public:
3638  mpPrintout()
3639  {
3640  plotWindow = NULL;
3641  drawn = false;
3642  stretch_factor = 2;
3643  }
3644 
3645  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
3646  virtual ~mpPrintout()
3647  {
3648  ;
3649  }
3650 
3651  void SetDrawState(bool drawState)
3652  {
3653  drawn = drawState;
3654  }
3655 
3656  bool OnPrintPage(int page);
3657  bool HasPage(int page);
3658 
3661  void SetFactor(int factor)
3662  {
3663  stretch_factor = factor;
3664  }
3665 
3666  private:
3667  bool drawn;
3668  mpWindow* plotWindow;
3669  int stretch_factor; // To reduce the size of plot
3670 
3671  protected:
3672 
3673  wxDECLARE_DYNAMIC_CLASS(mpPrintout);
3674 };
3675 
3676 //-----------------------------------------------------------------------------
3677 // mpMovableObject - provided by Jose Luis Blanco
3678 //-----------------------------------------------------------------------------
3686 class WXDLLIMPEXP_MATHPLOT mpMovableObject: public mpFunction
3687 {
3688  public:
3692  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
3693  {
3694  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
3695  m_subtype = mpfMovable;
3696  m_bbox_min_x = m_bbox_max_x = 0;
3697  m_bbox_min_y = m_bbox_max_y = 0;
3698  }
3699 
3700  virtual ~mpMovableObject() {}
3701 
3704  void GetCoordinateBase(double &x, double &y, double &phi) const
3705  {
3706  x = m_reference_x;
3707  y = m_reference_y;
3708  phi = m_reference_phi;
3709  }
3710 
3713  void SetCoordinateBase(double x, double y, double phi = 0)
3714  {
3715  m_reference_x = x;
3716  m_reference_y = y;
3717  m_reference_phi = phi;
3718  m_flags = mpALIGN_NE;
3719  ShapeUpdated();
3720  }
3721 
3722  virtual bool HasBBox()
3723  {
3724  return m_trans_shape_xs.size() != 0;
3725  }
3726 
3729  virtual double GetMinX()
3730  {
3731  return m_bbox_min_x;
3732  }
3733 
3736  virtual double GetMaxX()
3737  {
3738  return m_bbox_max_x;
3739  }
3740 
3743  virtual double GetMinY()
3744  {
3745  return m_bbox_min_y;
3746  }
3747 
3750  virtual double GetMaxY()
3751  {
3752  return m_bbox_max_y;
3753  }
3754 
3755  protected:
3756 
3759  double m_reference_x, m_reference_y, m_reference_phi;
3760 
3761  virtual void DoPlot(wxDC &dc, mpWindow &w);
3762 
3765  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
3766 
3769  std::vector<double> m_shape_xs, m_shape_ys;
3770 
3774  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
3775 
3779  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
3780 
3784  void ShapeUpdated();
3785 
3786  wxDECLARE_DYNAMIC_CLASS(mpMovableObject);
3787 };
3788 
3789 //-----------------------------------------------------------------------------
3790 // mpCovarianceEllipse - provided by Jose Luis Blanco
3791 //-----------------------------------------------------------------------------
3803 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse: public mpMovableObject
3804 {
3805  public:
3809  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
3810  const wxString &layerName = _T("")) : mpMovableObject(),
3811  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
3812  {
3813  m_continuous = true;
3814  m_name = layerName;
3815  RecalculateShape();
3816  }
3817 
3818  virtual ~mpCovarianceEllipse()
3819  {
3820  ;
3821  }
3822 
3823  double GetQuantiles() const
3824  {
3825  return m_quantiles;
3826  }
3827 
3830  void SetQuantiles(double q)
3831  {
3832  m_quantiles = q;
3833  RecalculateShape();
3834  }
3835 
3836  void SetSegments(int segments)
3837  {
3838  m_segments = segments;
3839  }
3840 
3841  int GetSegments() const
3842  {
3843  return m_segments;
3844  }
3845 
3848  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
3849  {
3850  cov_00 = m_cov_00;
3851  cov_01 = m_cov_01;
3852  cov_11 = m_cov_11;
3853  }
3854 
3857  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
3858  {
3859  m_cov_00 = cov_00;
3860  m_cov_01 = cov_01;
3861  m_cov_11 = cov_11;
3862  RecalculateShape();
3863  }
3864 
3865  protected:
3868  double m_cov_00, m_cov_11, m_cov_01;
3869  double m_quantiles;
3870 
3873  int m_segments;
3874 
3877  void RecalculateShape();
3878 
3879  wxDECLARE_DYNAMIC_CLASS(mpCovarianceEllipse);
3880 };
3881 
3882 //-----------------------------------------------------------------------------
3883 // mpPolygon - provided by Jose Luis Blanco
3884 //-----------------------------------------------------------------------------
3889 class WXDLLIMPEXP_MATHPLOT mpPolygon: public mpMovableObject
3890 {
3891  public:
3894  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
3895  {
3896  m_continuous = true;
3897  m_name = layerName;
3898  }
3899 
3900  virtual ~mpPolygon()
3901  {
3902  ;
3903  }
3904 
3910  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
3911 
3912  protected:
3913 
3914  wxDECLARE_DYNAMIC_CLASS(mpPolygon);
3915 };
3916 
3917 //-----------------------------------------------------------------------------
3918 // mpBitmapLayer - provided by Jose Luis Blanco
3919 //-----------------------------------------------------------------------------
3924 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer: public mpLayer
3925 {
3926  public:
3929  mpBitmapLayer() : mpLayer(mpLAYER_BITMAP)
3930  {
3931  m_min_x = m_max_x = 0;
3932  m_min_y = m_max_y = 0;
3933  m_validImg = false;
3934  m_bitmapChanged = false;
3935  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
3936  }
3937 
3938  virtual ~mpBitmapLayer()
3939  {
3940  ;
3941  }
3942 
3945  void GetBitmapCopy(wxImage &outBmp) const;
3946 
3954  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
3955 
3958  virtual double GetMinX()
3959  {
3960  return m_min_x;
3961  }
3962 
3965  virtual double GetMaxX()
3966  {
3967  return m_max_x;
3968  }
3969 
3972  virtual double GetMinY()
3973  {
3974  return m_min_y;
3975  }
3976 
3979  virtual double GetMaxY()
3980  {
3981  return m_max_y;
3982  }
3983 
3984  protected:
3985 
3988  wxImage m_bitmap;
3989  wxBitmap m_scaledBitmap;
3990  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
3991  bool m_validImg;
3992  bool m_bitmapChanged;
3993 
3996  double m_min_x, m_max_x, m_min_y, m_max_y;
3997 
3998  virtual void DoPlot(wxDC &dc, mpWindow &w);
3999 
4000  wxDECLARE_DYNAMIC_CLASS(mpBitmapLayer);
4001 };
4002 
4003 // utility class
4004 
4005 // Enumeration of classic colour
4006 typedef enum __mp_Colour
4007 {
4008  mpBlue,
4009  mpRed,
4010  mpGreen,
4011  mpPurple,
4012  mpYellow,
4013  mpFuchsia,
4014  mpLime,
4015  mpAqua,
4016  mpOlive
4017 } mpColour;
4018 
4023 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
4024 {
4025  public:
4026  wxIndexColour(unsigned int id)
4027  {
4028  switch (id)
4029  {
4030  case 0:
4031  this->Set(0, 0, 255);
4032  break; // Blue
4033  case 1:
4034  this->Set(255, 0, 0);
4035  break; // Red
4036  case 2:
4037  this->Set(0, 128, 0);
4038  break; // Green
4039  case 3:
4040  this->Set(128, 0, 128);
4041  break; // Purple
4042  case 4:
4043  this->Set(255, 255, 0);
4044  break; // Yellow
4045  case 5:
4046  this->Set(255, 0, 255);
4047  break; // Fuchsia
4048  case 6:
4049  this->Set(0, 255, 0);
4050  break; // Lime
4051  case 7:
4052  this->Set(0, 255, 255);
4053  break; // Aqua/Cyan
4054  case 8:
4055  this->Set(128, 128, 0);
4056  break; // Olive
4057  default:
4058  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
4059  (ChannelType)((rand() * 255) / RAND_MAX));
4060  }
4061  }
4062 };
4063 
4066 // ---------------------------------------------------------------------
4067 #ifdef ENABLE_MP_NAMESPACE
4068  }// namespace MathPlot
4069  // No, iff build enables namespace, its up to app to use it appropriately: using namespace MathPlot;
4070 #endif // ENABLE_MP_NAMESPACE
4071 
4072 #endif // MATHPLOT_H_INCLUDED
const wxString & GetLabelFormat() const
Get axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:1243
bool IsHorizontal(void) const
Get if is horizontal line.
Definition: mathplot.h:1691
void SetValue(const double value)
Set x or y.
Definition: mathplot.h:1684
void EnableDoubleBuffer(const bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled).
Definition: mathplot.h:2842
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:727
wxCoord y2p(const double y, int yID)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:2832
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:2775
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:3979
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:3256
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1735
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:3763
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:2622
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:605
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:174
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:1584
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:3798
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:2331
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:2315
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:3894
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:1229
void SetLogYaxis(int yID, bool log)
Set the log property (true or false) for a Y layer (Y axis) given by is ID.
Definition: mathplot.h:3311
void UpdateDesiredBoundingBox()
Draws the mpWindow on a page for printing.
Definition: mathplot.h:2965
int GetAxisID(void)
Return the ID of the Axis.
Definition: mathplot.h:1451
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1668
void SetItemMode(mpLegendStyle mode)
Set item mode (the element on the left of text representing the plot line may be line, square, or line with symbol).
Definition: mathplot.h:1113
int GetUseCount(void) const
Return then number of function who use this axis.
Definition: mathplot.h:1472
Abstract class providing a line.
Definition: mathplot.h:1266
Abstract class providing an vertical line.
Definition: mathplot.h:1331
double GetScaleY(int yID)
Get current view&#39;s Y scale.
Definition: mathplot.h:2661
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:1215
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:2384
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition: mathplot.h:2736
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:3713
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:704
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:2865
std::optional< int > m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition: mathplot.h:3475
~mpBarChart()
Destructor.
Definition: mathplot.h:2239
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:2805
void SetLabelMode(unsigned int mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:1393
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:3502
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:712
void UpdateUseCount(bool increase)
Update the number of function who use this axis.
Definition: mathplot.h:1460
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:3556
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:589
wxPoint GetPosition() const
Returns the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:951
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:1068
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:758
unsigned int GetLabelMode() const
Get X axis label view mode.
Definition: mathplot.h:1386
~mpPieChart()
Destructor.
Definition: mathplot.h:2301
std::map< int, mpYAxisInfo > m_YAxisList
List of Y axes layer of this mpWindow.
Definition: mathplot.h:3435
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:3145
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:3743
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:3097
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1542
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition: mathplot.h:3139
void SetMouseLeftDownAction(mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition: mathplot.h:3337
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1410
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:1466
virtual bool DoBeforePlot()
Here we verify that we have an Y axis associated to the plot We can not plot if we don&#39;t have an Y ax...
Definition: mathplot.h:1652
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:3704
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:1070
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:2147
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:3563
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:2205
void SetScaleY(const double scaleY, int yID)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:2645
bool GetBoundingBox(mpRange *boundX, mpRange *boundY, int yID)
Return the bounding box coordinates for the Y axis of ID yID.
Definition: mathplot.h:3023
virtual void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:1378
double p2y(const wxCoord pixelCoordY, int yID)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:2813
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:2849
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:1259
int GetMarginRight() const
Get the right margin.
Definition: mathplot.h:3103
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1578
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:541
bool GetCanDelete(void) const
Get CanDelete for plot.
Definition: mathplot.h:827
Definition: MathPlotConfig.h:44
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:2339
void SetCanDelete(bool canDelete)
Set CanDelete for plot.
Definition: mathplot.h:820
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:3958
bool GetMagnetize() const
Magnetize the position of the mouse in the plot ie draw a vertical and horizontal line...
Definition: mathplot.h:3323
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:1025
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:1222
mpScaleY * Axis
Pointer to the Y axes layer.
Definition: mathplot.h:2390
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:3231
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:737
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:2118
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:3534
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:3265
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:2690
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:834
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:3151
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:1054
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:3965
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:751
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:3857
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:3509
Represents all the informations needed for an Y axis This struct holds:
Definition: mathplot.h:2388
wxSize GetSize() const
Returns the size of the box (in pixels)
Definition: mathplot.h:958
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:3570
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:1990
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:3560
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:1886
virtual bool IsLogAxis()
Logarithmic axis.
Definition: mathplot.h:1303
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1585
double GetDesiredYmax(int yID)
Return the top layer-border coordinate that the user wants the mpWindow to show (it may be not exactl...
Definition: mathplot.h:3016
int m_yAxisID
The ID of the Y axis used by the function. Equal -1 if no axis.
Definition: mathplot.h:1645
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1550
Layer for bar chart.
Definition: mathplot.h:1836
abstract Layer for chart (bar and pie).
Definition: mathplot.h:1778
void SetPosY(const std::vector< double > &posYList)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:2710
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:720
const wxRect & GetRectangle() const
Returns the current rectangle coordinates.
Definition: mathplot.h:965
double GetDesiredXmin() const
Get the &#39;desired&#39; user-coordinate bounding box for the currently displayed view (set by Fit...
Definition: mathplot.h:2986
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:3115
double GetPosY(int yID)
Get current view&#39;s Y position.
Definition: mathplot.h:2727
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:2010
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:3972
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:1275
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:2081
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1713
void SetReserve(int reserve)
Set memory reserved for m_xs and m_ys Note : this does not modify the size of m_xs and m_ys...
Definition: mathplot.h:2029
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:2038
void SetYAxis(mpScaleY *yAxisUsed)
Set the Y axis associated to the function If the function is already associated to another axis...
Definition: mathplot.h:1615
mpMouseButtonAction GetMouseLeftDownAction()
Returns the type of action for the left mouse button.
Definition: mathplot.h:3346
void UpdateMargins()
Update margins if e.g.
Definition: mathplot.h:3079
int GetMarginTop() const
Get the top margin.
Definition: mathplot.h:3091
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:875
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:553
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:3584
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:927
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:562
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:984
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:3038
mpRange Get_BoundX(void) const
Get bounding box for X axis.
Definition: mathplot.h:2673
mpScaleY(const wxString &name=_T("Y"), int flags=mpALIGN_CENTERY, bool grids=false)
Full constructor.
Definition: mathplot.h:1434
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:2824
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1557
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1109
bool IsLogXaxis()
Is this an X axis to be displayed with log scale? It is really an axis property but as we need to con...
Definition: mathplot.h:3281
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:2751
int GetBarWidth(void) const
return the width of the bar
Definition: mathplot.h:1912
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:3250
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:1047
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:2103
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:3182
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1166
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1357
mpTitle(const wxString &name)
Definition: mathplot.h:3614
void SetLabelMode(unsigned int mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:1039
Plot layer implementing a simple title.
Definition: mathplot.h:3479
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:2212
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:3722
double GetDesiredYmin(int yID)
Return the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:3005
bool ViewAsBar(void) const
return true if XY series is plotted with bar
Definition: mathplot.h:1920
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:785
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:3157
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:2701
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:813
virtual void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:1236
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:1267
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:1878
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:3271
static int m_LastYAxisID
Reference the last ID provided to the last instance of mpScaleY.
Definition: mathplot.h:1502
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, unsigned int type=0x00)
Full constructor.
Definition: mathplot.h:1370
~mpChart()
Destructor.
Definition: mathplot.h:2181
Abstract class providing an horizontal line.
Definition: mathplot.h:1309
mpRange Bound
Range min and max of Y interval.
Definition: mathplot.h:2392
void Rewind()
Rewind value enumeration with mpFXY::GetNextXY.
Definition: mathplot.h:2063
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:2796
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:1975
void SetFont(const wxFont &font)
Set layer font.
Definition: mathplot.h:680
Class for drawing mouse magnetization.
Definition: mathplot.h:2314
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:3677
double GetDesiredXmax() const
Return the right-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:2995
Represents the scale and position for an axis This struct holds the scale defined by m_scale and the ...
Definition: mathplot.h:226
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:696
mpRange Get_BoundY(int yID)
Get bounding box for Y axis of ID yID.
Definition: mathplot.h:2681
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:3809
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:688
int GetMarginLeft() const
Get the left margin.
Definition: mathplot.h:3133
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:3848
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:972
bool IsVisible() const
Checks whether the layer is visible or not.
Definition: mathplot.h:778
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:1208
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:570
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:799
int GetMarginBottom() const
Get the bottom margin.
Definition: mathplot.h:3121
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1593
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:3691
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:2786
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:613
Plot layer implementing a text string.
Definition: mathplot.h:3403
virtual bool IsLayerType(mpLayerType typeOfInterest, int *subtype)
Set the layer&#39;s subtype in caller variable, and return true if the layer is of type "typeOfInterest"...
Definition: mathplot.h:580
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:3750
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:3188
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:765
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition: mathplot.h:3109
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:597
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:3085
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:2636
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1126
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above)...
Definition: mathplot.h:3830
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition: mathplot.h:1606
bool IsLogYaxis(int yID)
Get the log property (true or false) Y layer (Y axis) with a specific Y ID or false if not found...
Definition: mathplot.h:3292
Represents a numeric range with minimum and maximum values.
Definition: mathplot.h:205
mpRange Desired
Desired range min and max of Y interval.
Definition: mathplot.h:2393
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:2323
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1564
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:3729
Plot layer, abstract base class.
Definition: mathplot.h:508
double GetValue() const
Set x or y.
Definition: mathplot.h:1676
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:3577
void SetFactor(int factor)
Definition: mathplot.h:3661
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:664
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:744
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:672
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:871
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:3127
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1747
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:979
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:792
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:1201
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:3736
bool IsRepainting() const
Checks if we are repainting.
Definition: mathplot.h:2874
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:2945
mpAxisData Data
Y scale and position structure.
Definition: mathplot.h:2391
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:1251
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1571
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:3929
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:2511
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:806
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:2096