MathPlot
mathplot.h
Go to the documentation of this file.
1 // Name: mathplot.cpp
3 // Purpose: Framework for plotting in wxWindows
4 // Original Author: David Schalig
5 // Maintainer: Davide Rondini
6 // Contributors: Jose Luis Blanco, Val Greene, Lionel Reynaud, Dave Nadler, MortenMacFly
7 // 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 
72 // #include <wx/wx.h>
73 #include <wx/defs.h>
74 #include <wx/menu.h>
75 #include <wx/scrolwin.h>
76 #include <wx/event.h>
77 #include <wx/dynarray.h>
78 #include <wx/pen.h>
79 #include <wx/dcmemory.h>
80 #include <wx/string.h>
81 #include <wx/print.h>
82 #include <wx/image.h>
83 #include <wx/intl.h>
84 
85 #include <cmath>
86 #include <deque>
87 
88 // No, this is supposed to be a build parameter: #define ENABLE_MP_CONFIG
89 #ifdef ENABLE_MP_CONFIG
90  #include "MathPlotConfig.h"
91 #endif // ENABLE_MP_CONFIG
92 
97 // No, this is supposed to be a build parameter: #define ENABLE_MP_NAMESPACE
98 #ifdef ENABLE_MP_NAMESPACE
99  namespace MathPlot {
100 #endif // ENABLE_MP_NAMESPACE
101 
102 #ifdef ENABLE_MP_DEBUG
103 // For memory leak debug
104 #ifdef _WINDOWS
105 #ifdef _DEBUG
106 #include <crtdbg.h>
107 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
108 #else
109 #define DEBUG_NEW new
110 #endif // _DEBUG
111 #endif // _WINDOWS
112 #endif // ENABLE_MP_DEBUG
113 
114 // Separation for axes when set close to border
115 #define X_BORDER_SEPARATION 40
116 #define Y_BORDER_SEPARATION 60
117 
119 #define mpX_LOCALTIME 0x10
120 
121 #define mpX_UTCTIME 0x20
122 #define mpX_RAWTIME mpX_UTCTIME
123 
124 // An epsilon for float comparison to 0
125 #define EPSILON 1e-8
126 #define ISNOTNULL(x) (fabs(x) > EPSILON)
127 
128 // A small extra margin for the plot boundary
129 #define EXTRA_MARGIN 8
130 
131 //-----------------------------------------------------------------------------
132 // classes
133 //-----------------------------------------------------------------------------
134 
135 class WXDLLIMPEXP_MATHPLOT mpLayer;
136 class WXDLLIMPEXP_MATHPLOT mpFunction;
137 class WXDLLIMPEXP_MATHPLOT mpLine;
138 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine;
139 class WXDLLIMPEXP_MATHPLOT mpVerticalLine;
140 class WXDLLIMPEXP_MATHPLOT mpFX;
141 class WXDLLIMPEXP_MATHPLOT mpFY;
142 class WXDLLIMPEXP_MATHPLOT mpFXY;
143 class WXDLLIMPEXP_MATHPLOT mpFXYVector;
144 class WXDLLIMPEXP_MATHPLOT mpProfile;
145 class WXDLLIMPEXP_MATHPLOT mpChart;
146 class WXDLLIMPEXP_MATHPLOT mpBarChart;
147 class WXDLLIMPEXP_MATHPLOT mpScale;
148 class WXDLLIMPEXP_MATHPLOT mpScaleX;
149 class WXDLLIMPEXP_MATHPLOT mpScaleY;
150 class WXDLLIMPEXP_MATHPLOT mpInfoLayer;
151 class WXDLLIMPEXP_MATHPLOT mpInfoCoords;
152 class WXDLLIMPEXP_MATHPLOT mpInfoLegend;
153 class WXDLLIMPEXP_MATHPLOT mpWindow;
154 class WXDLLIMPEXP_MATHPLOT mpText;
155 class WXDLLIMPEXP_MATHPLOT mpTitle;
156 class WXDLLIMPEXP_MATHPLOT mpPrintout;
157 class WXDLLIMPEXP_MATHPLOT mpMovableObject;
158 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse;
159 class WXDLLIMPEXP_MATHPLOT mpPolygon;
160 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer;
161 
162 #ifdef ENABLE_MP_CONFIG
164 #endif // ENABLE_MP_CONFIG
165 
167 typedef union
168 {
169  struct
170  {
171  wxCoord startPx;
172  wxCoord endPx;
173  wxCoord startPy;
174  wxCoord endPy;
175  };
176  struct
177  {
178  wxCoord left;
179  wxCoord top;
180  wxCoord right;
181  wxCoord bottom;
182  };
183  struct
184  {
185  wxCoord x1;
186  wxCoord y1;
187  wxCoord x2;
188  wxCoord y2;
189  };
190  wxCoord tab[4];
191 } mpRect;
192 
200 {
201  double Xmin;
202  double Xmax;
203  double Ymin;
204  double Ymax;
205  double Y2min;
206  double Y2max;
207  mpFloatRect() : Xmin(0.0), Xmax(0.0), Ymin(0.0), Ymax(0.0), Y2min(0.0), Y2max(0.0) {}
209  bool PointIsInside(double x, double y) const {
210  if( (x < Xmin || x > Xmax) ||
211  (y < Ymin || y > Ymax) ) return false;
212  return true;
213  }
215  void UpdateBoundingBoxToInclude(double x, double y, double y2=0) {
216  if (x < Xmin ) Xmin = x;
217  else if (x > Xmax ) Xmax = x;
218  if (y < Ymin ) Ymin = y;
219  else if (y > Ymax ) Ymax = y;
220  if (y2 < Y2min) Y2min = y2;
221  else if (y2 > Y2max) Y2max = y2;
222  }
224  void InitializeBoundingBox(double x, double y, double y2=0) {
225  Xmin = Xmax = x;
226  Ymin = Ymax = y;
227  Y2min = Y2max = y2;
228  }
230  bool IsNotSet() const { const mpFloatRect def; return *this==def; }
232  #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
233  bool operator==(const mpFloatRect&) const = default;
234  #else
235  // We compare with an epsilon precision
236  // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
237  bool operator ==(const mpFloatRect &rect) const
238  {
239  auto Same = [this,rect] (double a, double b) { return fabs(a - b) < EPSILON; };
240  return Same(Xmin, rect.Xmin) && Same(Xmax, rect.Xmax) &&
241  Same(Ymin, rect.Ymin) && Same(Ymax, rect.Ymax) &&
242  Same(Y2min, rect.Y2min) && Same(Y2max, rect.Y2max) ;
243  }
244  #endif
245 };
246 
250 enum
251 {
252  mpID_FIT = 2000,
260 #ifdef ENABLE_MP_CONFIG
261  mpID_CONFIG,
262 #endif // ENABLE_MP_CONFIG
266 };
267 
269 typedef enum __mp_Location_Type
270 {
271  mpMarginLeftCenter,
272  mpMarginTopLeft,
273  mpMarginTopCenter,
274  mpMarginTopRight,
275  mpMarginRightCenter,
276  mpMarginBottomLeft,
277  mpMarginBottomCenter,
278  mpMarginBottomRight,
279  mpMarginNone,
280  mpCursor // only for mpInfoCoords
281 } mpLocation;
282 
284 typedef enum __XAxis_Align_Type
285 {
286  mpALIGN_BORDER_BOTTOM = 10,
287  mpALIGN_BOTTOM,
288  mpALIGN_CENTERX,
289  mpALIGN_TOP,
290  mpALIGN_BORDER_TOP
291 } mpXAxis_Align;
292 
294 typedef enum __YAxis_Align_Type
295 {
296  mpALIGN_BORDER_LEFT = 20,
297  mpALIGN_LEFT,
298  mpALIGN_CENTERY,
299  mpALIGN_RIGHT,
300  mpALIGN_BORDER_RIGHT
301 } mpYAxis_Align;
302 
305 {
306  mpALIGN_NW = 5,
307  mpALIGN_NE,
308  mpALIGN_SE,
309  mpALIGN_SW
310 } mpPlot_Align;
311 
313 typedef enum __mp_Style_Type
314 {
318 } mpLegendStyle;
319 
322 {
326 
327 typedef enum __Symbol_Type
328 {
329  mpsNone,
330  mpsCircle,
331  mpsSquare,
332  mpsUpTriangle,
333  mpsDownTriangle,
334  mpsCross,
335  mpsPlus
336 } mpSymbol;
337 
338 //-----------------------------------------------------------------------------
339 // mpLayer sub_type values
340 //-----------------------------------------------------------------------------
341 
343 typedef enum __Info_Type
344 {
345  mpiNone, // never used
346  mpiInfo,
347  mpiCoords,
348  mpiLegend
349 } mpInfoType;
350 
352 typedef enum __Text_Type
353 {
354  mptNone, // never used
355  mptText,
356  mptTitle
357 } mpTextType;
358 
359 typedef enum __Function_Type
360 {
361  mpfNone,
362  mpfFX,
363  mpfFY,
364  mpfFXY,
365  mpfFXYVector,
366  mpfMovable,
367  mpfLine,
368  mpfAllType
369 } mpFunctionType;
370 
371 typedef enum __Scale_Type
372 {
373  mpsScaleNone,
374  mpsScaleX,
375  mpsScaleY,
376  mpsAllType
377 } mpScaleType;
378 
379 typedef enum __Chart_Type
380 {
381  mpcChartNone,
382  mpcBarChart,
383  mpcPieChart,
384  mpcAllType
385 } mpChartType;
386 
387 //-----------------------------------------------------------------------------
388 // mpLayer
389 //-----------------------------------------------------------------------------
390 
391 typedef enum __mp_Layer_Type
392 {
401 } mpLayerType;
402 
408 typedef enum __mp_Layer_ZOrder
409 {
418 } mpLayerZOrder;
419 
430 class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
431 {
432  public:
433  mpLayer(mpLayerType layerType);
434 
435  virtual ~mpLayer()
436  {
437  ;
438  }
439 
443  {
444  m_win = &w;
445  }
446 
454  virtual bool HasBBox()
455  {
456  return true;
457  }
458 
463  virtual void GetBBox(mpFloatRect *m_bound);
464 
469  mpLayerType GetLayerType() const
470  {
471  return m_type;
472  }
473 
477  int GetLayerSubType() const
478  {
479  return m_subtype;
480  }
481 
488  virtual bool IsLayerType(mpLayerType type, int *sub_type)
489  {
490  *sub_type = m_subtype;
491  return (m_type == type);
492  }
493 
497  virtual double GetMinX()
498  {
499  return -1.0;
500  }
501 
505  virtual double GetMaxX()
506  {
507  return 1.0;
508  }
509 
513  virtual double GetMinY()
514  {
515  return -1.0;
516  }
517 
521  virtual double GetMaxY()
522  {
523  return 1.0;
524  }
525 
567  void Plot(wxDC &dc, mpWindow &w);
568 
572  void SetName(const wxString &name)
573  {
574  m_name = name;
575  }
576 
580  const wxString& GetName() const
581  {
582  return m_name;
583  }
584 
588  void SetFont(const wxFont &font)
589  {
590  m_font = font;
591  }
592 
596  const wxFont& GetFont() const
597  {
598  return m_font;
599  }
600 
604  void SetFontColour(const wxColour &colour)
605  {
606  m_fontcolour = colour;
607  }
608 
612  const wxColour& GetFontColour() const
613  {
614  return m_fontcolour;
615  }
616 
620  void SetPen(const wxPen &pen)
621  {
622  m_pen = pen;
623  }
624 
628  const wxPen& GetPen() const
629  {
630  return m_pen;
631  }
632 
635  void SetBrush(const wxBrush &brush)
636  {
637  if (brush == wxNullBrush)
638  m_brush = *wxTRANSPARENT_BRUSH;
639  else
640  m_brush = brush;
641  }
642 
645  const wxBrush& GetBrush() const
646  {
647  return m_brush;
648  }
649 
652  void SetShowName(bool show)
653  {
654  m_showName = show;
655  }
656 
659  inline bool GetShowName() const
660  {
661  return m_showName;
662  }
663 
666  void SetDrawOutsideMargins(bool drawModeOutside)
667  {
668  m_drawOutsideMargins = drawModeOutside;
669  }
670 
674  {
675  return m_drawOutsideMargins;
676  }
677 
682  wxBitmap GetColourSquare(int side = 16);
683 
686  inline bool IsVisible() const
687  {
688  return m_visible;
689  }
690 
693  virtual void SetVisible(bool show)
694  {
695  m_visible = show;
696  }
697 
700  inline bool IsTractable() const
701  {
702  return m_tractable;
703  }
704 
707  virtual void SetTractable(bool track)
708  {
709  m_tractable = track;
710  }
711 
714  void SetAlign(int align)
715  {
716  m_flags = align;
717  }
718 
721  int GetAlign() const
722  {
723  return m_flags;
724  }
725 
728  void SetCanDelete(bool canDelete)
729  {
730  m_CanDelete = canDelete;
731  }
732 
735  bool GetCanDelete(void) const
736  {
737  return m_CanDelete;
738  }
739 
742  mpLayerZOrder GetZIndex(void) const
743  {
744  return m_ZIndex;
745  }
746 
747  protected:
748  const mpLayerType m_type;
750  int m_subtype;
751  wxFont m_font;
752  wxColour m_fontcolour;
753  wxPen m_pen;
754  wxBrush m_brush;
755  wxString m_name;
756  bool m_showName;
758  bool m_visible;
759  bool m_tractable;
760  int m_flags;
762  bool m_CanDelete;
763  mpLayerZOrder m_ZIndex;
764 
767  void UpdateContext(wxDC &dc) const;
768 
773  virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
774 
778  virtual void DoBeforePlot()
779  {
780  ;
781  }
782 
786  void CheckLog(double *x, double *y);
787 
788  private:
789  bool m_busy;
790  mpLayer() = delete; // default ctor not implemented/permitted
791 
792  wxDECLARE_DYNAMIC_CLASS(mpLayer);
793 };
794 
795 //-----------------------------------------------------------------------------
796 // mpInfoLayer
797 //-----------------------------------------------------------------------------
798 
804 class WXDLLIMPEXP_MATHPLOT mpInfoLayer: public mpLayer
805 {
806  public:
808  mpInfoLayer();
809 
814  mpInfoLayer(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
815 
817  virtual ~mpInfoLayer();
818 
821  virtual void SetVisible(bool show);
822 
827  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
828 
831  virtual bool HasBBox()
832  {
833  return false;
834  }
835 
839  virtual void ErasePlot(wxDC &dc, mpWindow &w);
840 
844  virtual bool Inside(const wxPoint &point);
845 
848  virtual void Move(wxPoint delta);
849 
851  virtual void UpdateReference();
852 
855  wxPoint GetPosition() const
856  {
857  return m_dim.GetPosition();
858  }
859 
862  wxSize GetSize() const
863  {
864  return m_dim.GetSize();
865  }
866 
869  const wxRect& GetRectangle() const
870  {
871  return m_dim;
872  }
873 
876  void SetLocation(mpLocation location)
877  {
878  m_location = location;
879  }
880 
883  mpLocation GetLocation() const
884  {
885  return m_location;
886  }
887 
888  protected:
889  wxRect m_dim;
890  wxRect m_oldDim;
891  wxBitmap* m_info_bmp;
892  wxPoint m_reference;
893  int m_winX, m_winY;
894  mpLocation m_location;
895 
900  virtual void DoPlot(wxDC &dc, mpWindow &w);
901 
904  void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
905 
906  wxDECLARE_DYNAMIC_CLASS(mpInfoLayer);
907 };
908 
913 class WXDLLIMPEXP_MATHPLOT mpInfoCoords: public mpInfoLayer
914 {
915  public:
917  mpInfoCoords();
918 
920  mpInfoCoords(mpLocation location);
921 
926  mpInfoCoords(wxRect rect, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginNone);
927 
930  {
931  ;
932  }
933 
937  virtual void UpdateInfo(mpWindow &w, wxEvent &event);
938 
939  virtual void ErasePlot(wxDC &dc, mpWindow &w);
940 
943  void SetLabelMode(unsigned int mode, unsigned int time_conv = mpX_RAWTIME)
944  {
945  m_labelType = mode;
946  m_timeConv = time_conv;
947  }
948 
951  void SetSeriesCoord(bool show)
952  {
953  m_series_coord = show;
954  }
955 
958  bool IsSeriesCoord() const
959  {
960  return m_series_coord;
961  }
962 
966  virtual wxString GetInfoCoordsText(double xVal, double yVal, double y2Val, bool isY2Axis = false);
967 
970  void SetPenSeries(const wxPen &pen)
971  {
972  m_penSeries = pen;
973  }
974 
975  protected:
976  wxString m_content;
977  unsigned int m_labelType;
978  unsigned int m_timeConv;
979  wxCoord m_mouseX;
980  wxCoord m_mouseY;
981  bool m_series_coord;
982  wxPen m_penSeries;
983 
988  virtual void DoPlot(wxDC &dc, mpWindow &w);
989 
990  wxDECLARE_DYNAMIC_CLASS(mpInfoCoords);
991 };
992 
997 class WXDLLIMPEXP_MATHPLOT mpInfoLegend: public mpInfoLayer
998 {
999  public:
1001  mpInfoLegend();
1002 
1008  mpInfoLegend(wxRect rect, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginNone);
1009 
1012 
1015  void SetItemMode(mpLegendStyle mode)
1016  {
1017  m_item_mode = mode;
1018  m_needs_update = true;
1019  }
1020 
1021  mpLegendStyle GetItemMode() const
1022  {
1023  return m_item_mode;
1024  }
1025 
1028  void SetItemDirection(mpLegendDirection mode)
1029  {
1030  m_item_direction = mode;
1031  m_needs_update = true;
1032  }
1033 
1034  mpLegendDirection GetItemDirection() const
1035  {
1036  return m_item_direction;
1037  }
1038 
1039  void SetNeedUpdate()
1040  {
1041  m_needs_update = true;
1042  }
1043 
1045  int GetPointed(mpWindow &w, wxPoint eventPoint);
1046 
1047  protected:
1048  mpLegendStyle m_item_mode;
1049  mpLegendDirection m_item_direction;
1050 
1055  virtual void DoPlot(wxDC &dc, mpWindow &w);
1056 
1057  private:
1059  struct LegendDetail
1060  {
1061  unsigned int layerIdx;
1062  wxCoord legendEnd;
1063  };
1065  std::vector<LegendDetail> m_LegendDetailList;
1066  bool m_needs_update;
1067 
1077  void UpdateBitmap(wxDC &dc, mpWindow &w);
1078 
1079  wxDECLARE_DYNAMIC_CLASS(mpInfoLegend);
1080 };
1081 
1082 //-----------------------------------------------------------------------------
1083 // mpLayer implementations - functions
1084 //-----------------------------------------------------------------------------
1085 
1093 class WXDLLIMPEXP_MATHPLOT mpFunction: public mpLayer
1094 {
1095  public:
1098  mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, bool useY2Axis = false);
1099 
1103  void SetContinuity(bool continuity)
1104  {
1105  m_continuous = continuity;
1106  }
1107 
1111  bool GetContinuity() const
1112  {
1113  return m_continuous;
1114  }
1115 
1118  void SetStep(unsigned int step)
1119  {
1120  m_step = step;
1121  }
1122 
1125  unsigned int GetStep() const
1126  {
1127  return m_step;
1128  }
1129 
1132  void SetSymbol(mpSymbol symbol)
1133  {
1134  m_symbol = symbol;
1135  }
1136 
1139  mpSymbol GetSymbol() const
1140  {
1141  return m_symbol;
1142  }
1143 
1146  void SetSymbolSize(int size)
1147  {
1148  m_symbolSize = size;
1149  m_symbolSize2 = size / 2;
1150  }
1151 
1154  int GetSymbolSize() const
1155  {
1156  return m_symbolSize;
1157  }
1158 
1162  virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1163 
1167  void SetY2Axis(bool _useY2)
1168  {
1169  m_UseY2Axis = _useY2;
1170  }
1171 
1175  bool GetY2Axis() const
1176  {
1177  return m_UseY2Axis;
1178  }
1179 
1180  protected:
1182  mpSymbol m_symbol;
1185  unsigned int m_step;
1187 
1188  wxDECLARE_DYNAMIC_CLASS(mpFunction);
1189 };
1190 
1193 class WXDLLIMPEXP_MATHPLOT mpLine: public mpFunction
1194 {
1195  public:
1196  mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1197 
1198  // We don't want to include line (horizontal or vertical) in BBox computation
1199  virtual bool HasBBox() override
1200  {
1201  return false;
1202  }
1203 
1207  double GetValue() const
1208  {
1209  return m_value;
1210  }
1211 
1215  void SetValue(const double value)
1216  {
1217  m_value = value;
1218  }
1219 
1222  bool IsHorizontal(void) const
1223  {
1224  return m_IsHorizontal;
1225  }
1226 
1227  protected:
1228  double m_value;
1229  bool m_IsHorizontal;
1230 
1231  wxDECLARE_DYNAMIC_CLASS(mpLine);
1232 };
1233 
1236 class WXDLLIMPEXP_MATHPLOT mpHorizontalLine: public mpLine
1237 {
1238  public:
1239  mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, bool useY2Axis = false);
1240 
1244  void SetYValue(const double yvalue)
1245  {
1246  SetValue(yvalue);
1247  }
1248 
1249  protected:
1250 
1251  virtual void DoPlot(wxDC &dc, mpWindow &w);
1252 
1253  wxDECLARE_DYNAMIC_CLASS(mpHorizontalLine);
1254 };
1255 
1258 class WXDLLIMPEXP_MATHPLOT mpVerticalLine: public mpLine
1259 {
1260  public:
1261  mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1262 
1266  void SetXValue(const double xvalue)
1267  {
1268  SetValue(xvalue);
1269  }
1270 
1271  protected:
1272 
1273  virtual void DoPlot(wxDC &dc, mpWindow &w);
1274 
1275  wxDECLARE_DYNAMIC_CLASS(mpVerticalLine);
1276 };
1277 
1284 class WXDLLIMPEXP_MATHPLOT mpFX: public mpFunction
1285 {
1286  public:
1290  mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, bool useY2Axis = false);
1291 
1297  virtual double GetY(double x) = 0;
1298 
1302  double DoGetY(double x);
1303 
1304  protected:
1305 
1310  virtual void DoPlot(wxDC &dc, mpWindow &w);
1311 
1312  wxDECLARE_DYNAMIC_CLASS(mpFX);
1313 };
1314 
1321 class WXDLLIMPEXP_MATHPLOT mpFY: public mpFunction
1322 {
1323  public:
1327  mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, bool useY2Axis = false);
1328 
1334  virtual double GetX(double y) = 0;
1335 
1339  double DoGetX(double y);
1340 
1341  protected:
1342 
1347  virtual void DoPlot(wxDC &dc, mpWindow &w);
1348 
1349  wxDECLARE_DYNAMIC_CLASS(mpFY);
1350 };
1351 
1361 class WXDLLIMPEXP_MATHPLOT mpFXY: public mpFunction
1362 {
1363  public:
1367  mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, bool useY2Axis = false);
1368 
1372  virtual void Rewind() = 0;
1373 
1377  virtual void Clear()
1378  {
1379  ;
1380  }
1381 
1385  virtual int GetSize()
1386  {
1387  return 0;
1388  }
1389 
1396  virtual bool GetNextXY(double *x, double *y) = 0;
1397 
1401  bool DoGetNextXY(double *x, double *y);
1402 
1406  void SetViewMode(bool asBar);
1407 
1411  int GetBarWidth(void) const
1412  {
1413  return m_BarWidth;
1414  }
1415 
1419  bool ViewAsBar(void) const
1420  {
1421  return m_ViewAsBar;
1422  }
1423 
1424  protected:
1425 
1426  // Data to calculate label positioning
1427  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
1428 
1429  // Min delta between 2 x coordinate (used for view as bar)
1430  double m_deltaX, m_deltaY;
1431 
1432  // The width of a bar
1433  int m_BarWidth;
1434 
1435  // Plot data as bar graph
1436  bool m_ViewAsBar = false;
1437 
1438  // Can the series be deleted?
1439  bool m_CanDelete = true;
1440 
1445  virtual void DoPlot(wxDC &dc, mpWindow &w);
1446 
1451  void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
1452 
1453  wxDECLARE_DYNAMIC_CLASS(mpFXY);
1454 };
1455 
1456 //-----------------------------------------------------------------------------
1457 // mpFXYVector - provided by Jose Luis Blanco
1458 //-----------------------------------------------------------------------------
1459 
1479 class WXDLLIMPEXP_MATHPLOT mpFXYVector: public mpFXY
1480 {
1481  public:
1485  mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_NE, bool viewAsBar = false, bool useY2Axis = false);
1486 
1489  virtual ~mpFXYVector()
1490  {
1491  Clear();
1492  }
1493 
1498  void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
1499 
1503  void Clear();
1504 
1509  virtual int GetSize()
1510  {
1511  return m_xs.size();
1512  }
1513 
1521  bool AddData(const double x, const double y, bool updatePlot);
1522 
1528  void SetReserve(int reserve)
1529  {
1530  m_reserveXY = reserve;
1531  m_xs.reserve(m_reserveXY);
1532  m_ys.reserve(m_reserveXY);
1533  }
1534 
1537  int GetReserve() const
1538  {
1539  return m_reserveXY;
1540  }
1541 
1542  protected:
1545  std::vector<double> m_xs, m_ys;
1546 
1550 
1553  size_t m_index;
1554 
1557  double m_minX, m_maxX, m_minY, m_maxY, m_lastX, m_lastY;
1558 
1562  inline void Rewind()
1563  {
1564  m_index = 0;
1565  }
1566 
1572  virtual bool GetNextXY(double *x, double *y);
1573 
1576  void DrawAddedPoint(double x, double y);
1577 
1580  virtual double GetMinX()
1581  {
1582  return m_minX;
1583  }
1584 
1587  virtual double GetMinY()
1588  {
1589  return m_minY;
1590  }
1591 
1594  virtual double GetMaxX()
1595  {
1596  return m_maxX;
1597  }
1598 
1601  virtual double GetMaxY()
1602  {
1603  return m_maxY;
1604  }
1605 
1606  private:
1609  void First_Point(double x, double y);
1610 
1613  void Check_Limit(double val, double *min, double *max, double *last, double *delta);
1614 
1615  wxDECLARE_DYNAMIC_CLASS(mpFXYVector);
1616 };
1617 
1626 class WXDLLIMPEXP_MATHPLOT mpProfile: public mpFunction
1627 {
1628  public:
1632  mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
1633 
1639  virtual double GetY(double x) = 0;
1640 
1641  protected:
1642 
1647  virtual void DoPlot(wxDC &dc, mpWindow &w);
1648 
1649  wxDECLARE_DYNAMIC_CLASS(mpProfile);
1650 };
1651 
1652 //-----------------------------------------------------------------------------
1653 // mpChart
1654 //-----------------------------------------------------------------------------
1657 class WXDLLIMPEXP_MATHPLOT mpChart: public mpFunction
1658 {
1659  public:
1661  mpChart(const wxString &name = wxEmptyString);
1662 
1665  {
1666  Clear();
1667  }
1668 
1671  void SetChartValues(const std::vector<double> &data);
1672 
1675  void SetChartLabels(const std::vector<std::string> &labelArray);
1676 
1681  void AddData(const double &data, const std::string &label);
1682 
1686  virtual void Clear();
1687 
1688  virtual bool HasBBox()
1689  {
1690  return (values.size() > 0);
1691  }
1692 
1693  protected:
1694  std::vector<double> values;
1695  std::vector<std::string> labels;
1696 
1697  double m_max_value;
1698  double m_total_value;
1699 
1700  wxDECLARE_DYNAMIC_CLASS(mpChart);
1701 };
1702 
1703 //-----------------------------------------------------------------------------
1704 // mpBarChart - provided by Jose Davide Rondini
1705 //-----------------------------------------------------------------------------
1706 /* Defines for bar charts label positioning. */
1707 #define mpBAR_NONE 0
1708 #define mpBAR_AXIS_H 1
1709 #define mpBAR_AXIS_V 2
1710 #define mpBAR_INSIDE 3
1711 #define mpBAR_TOP 4
1712 
1713 
1715 class WXDLLIMPEXP_MATHPLOT mpBarChart: public mpChart
1716 {
1717  public:
1719  mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
1720 
1723  {
1724  Clear();
1725  }
1726 
1727  void SetBarColour(const wxColour &colour);
1728 
1729  void SetColumnWidth(const double colWidth)
1730  {
1731  m_width = colWidth;
1732  }
1733 
1735  void SetBarLabelPosition(int position);
1736 
1740  virtual double GetMinX();
1741 
1745  virtual double GetMaxX();
1746 
1750  virtual double GetMinY();
1751 
1755  virtual double GetMaxY();
1756 
1757  protected:
1758 
1759  double m_width;
1760  wxColour m_barColour;
1761  int m_labelPos;
1762  double m_labelAngle;
1763 
1768  virtual void DoPlot(wxDC &dc, mpWindow &w);
1769 
1770  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
1771 };
1772 
1777 class WXDLLIMPEXP_MATHPLOT mpPieChart: public mpChart
1778 {
1779  public:
1781  mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
1782 
1785  {
1786  Clear();
1787  colours.clear();
1788  }
1789 
1793  void SetPieColours(const std::vector<wxColour> &colourArray);
1794 
1798  virtual double GetMinX()
1799  {
1800  return -m_radius;
1801  }
1802 
1806  virtual double GetMaxX()
1807  {
1808  return m_radius;
1809  }
1810 
1814  virtual double GetMinY()
1815  {
1816  return -m_radius;
1817  }
1818 
1822  virtual double GetMaxY()
1823  {
1824  return m_radius;
1825  }
1826 
1827  protected:
1828 
1829  double m_radius;
1830  std::vector<wxColour> colours;
1831 
1836  virtual void DoPlot(wxDC &dc, mpWindow &w);
1837 
1838  const wxColour& GetColour(unsigned int id);
1839 
1840  wxDECLARE_DYNAMIC_CLASS(mpBarChart);
1841 };
1842 
1845 //-----------------------------------------------------------------------------
1846 // mpLayer implementations - furniture (scales, ...)
1847 //-----------------------------------------------------------------------------
1854 class WXDLLIMPEXP_MATHPLOT mpScale: public mpLayer
1855 {
1856  public:
1861  mpScale(const wxString &name, int flags, bool grids);
1862 
1866  virtual bool HasBBox()
1867  {
1868  return false;
1869  }
1870 
1873  void ShowTicks(bool ticks)
1874  {
1875  m_ticks = ticks;
1876  }
1877 
1880  bool GetShowTicks() const
1881  {
1882  return m_ticks;
1883  }
1884 
1887  void ShowGrids(bool grids)
1888  {
1889  m_grids = grids;
1890  }
1891 
1894  bool GetShowGrids() const
1895  {
1896  return m_grids;
1897  }
1898 
1901  virtual void SetLabelFormat(const wxString &format)
1902  {
1903  m_labelFormat = format;
1904  }
1905 
1908  const wxString& GetLabelFormat() const
1909  {
1910  return m_labelFormat;
1911  }
1912 
1916  void SetGridPen(const wxPen &pen)
1917  {
1918  m_gridpen = pen;
1919  }
1920 
1924  const wxPen& GetGridPen() const
1925  {
1926  return m_gridpen;
1927  }
1928 
1932  void SetAuto(bool automaticScalingIsEnabled)
1933  {
1934  m_auto = automaticScalingIsEnabled;
1935  }
1936 
1940  bool GetAuto() const
1941  {
1942  return m_auto;
1943  }
1944 
1945  void SetMinScale(double min)
1946  {
1947  m_min = min;
1948  }
1949 
1950  double GetMinScale() const
1951  {
1952  return m_min;
1953  }
1954 
1955  void SetMaxScale(double max)
1956  {
1957  m_max = max;
1958  }
1959 
1960  double GetMaxScale() const
1961  {
1962  return m_max;
1963  }
1964 
1965  virtual bool IsLogAxis() = 0;
1966  virtual void SetLogAxis(bool log) = 0;
1967 
1968  protected:
1969  wxPen m_gridpen;
1970  bool m_ticks;
1971  bool m_grids;
1972  bool m_auto;
1973  double m_min, m_max;
1974  wxString m_labelFormat;
1975 
1976  virtual int GetOrigin(mpWindow &w) = 0;
1977  double GetStep(double scale);
1978  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
1979 
1980  wxString FormatLogValue(double n);
1981 
1982  wxDECLARE_DYNAMIC_CLASS(mpScale);
1983 };
1984 
1986 #define mpX_NORMAL 0x00
1987 
1989 #define mpX_TIME 0x01
1990 
1991 #define mpX_HOURS 0x02
1992 
1993 #define mpX_DATE 0x03
1994 
1995 #define mpX_DATETIME 0x04
1996 
1997 #define mpX_USER 0x05
1998 
1999 #define mpX_NONE 0x06
2000 
2006 class WXDLLIMPEXP_MATHPLOT mpScaleX: public mpScale
2007 {
2008  public:
2014  mpScaleX(const wxString &name = _T("X"), int flags = mpALIGN_CENTERX, bool grids = false, unsigned int type = mpX_NORMAL) :
2015  mpScale(name, flags, grids)
2016  {
2017  m_subtype = mpsScaleX;
2018  m_labelType = type;
2019  m_timeConv = mpX_RAWTIME;
2020  }
2021 
2022  virtual void SetLabelFormat(const wxString &format)
2023  {
2024  mpScale::SetLabelFormat(format);
2025  m_labelType = mpX_USER;
2026  }
2027 
2030  unsigned int GetLabelMode() const
2031  {
2032  return m_labelType;
2033  }
2034 
2037  void SetLabelMode(unsigned int mode, unsigned int time_conv = mpX_RAWTIME)
2038  {
2039  m_labelType = mode;
2040  m_timeConv = time_conv;
2041  }
2042 
2046  virtual bool IsLogAxis();
2047  virtual void SetLogAxis(bool log);
2048 
2049  protected:
2050  unsigned int m_labelType;
2051  unsigned int m_timeConv;
2052 
2055  virtual void DoPlot(wxDC &dc, mpWindow &w);
2056 
2057  virtual int GetOrigin(mpWindow &w);
2058  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2059  wxString FormatValue(const wxString &fmt, double n);
2060 
2061  wxDECLARE_DYNAMIC_CLASS(mpScaleX);
2062 };
2063 
2070 class WXDLLIMPEXP_MATHPLOT mpScaleY: public mpScale
2071 {
2072  public:
2078  mpScaleY(const wxString &name = _T("Y"), int flags = mpALIGN_CENTERY, bool grids = false, bool Y2Axis = false) :
2079  mpScale(name, flags, grids)
2080  {
2081  m_subtype = mpsScaleY;
2082  m_isY2Axis = Y2Axis;
2083  }
2084 
2088  virtual bool IsLogAxis();
2089  virtual void SetLogAxis(bool log);
2090 
2091  virtual bool IsY2Axis()
2092  {
2093  return m_isY2Axis;
2094  }
2095  virtual void SetY2Axis(bool y2Axis);
2096 
2097  protected:
2098  bool m_isY2Axis;
2099 
2102  virtual void DoPlot(wxDC &dc, mpWindow &w);
2103 
2104  virtual int GetOrigin(mpWindow &w);
2105  virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize);
2106 
2107  wxDECLARE_DYNAMIC_CLASS(mpScaleY);
2108 };
2109 
2110 //-----------------------------------------------------------------------------
2111 // mpWindow
2112 //-----------------------------------------------------------------------------
2113 
2118 #define mpMOUSEMODE_DRAG 0
2119 
2120 #define mpMOUSEMODE_ZOOMBOX 1
2121 
2124 //WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
2125 typedef std::deque<mpLayer*> mpLayerList;
2126 
2133 typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
2134 
2141 typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
2142 
2147 {
2148  public:
2149  mpMagnet()
2150  {
2151  m_IsDrawn = false;
2152  m_rightClick = false;
2153  m_IsWasDrawn = false;
2154  }
2155  ~mpMagnet()
2156  {
2157  ;
2158  }
2159  void UpdateBox(wxCoord left, wxCoord top, wxCoord width, wxCoord height)
2160  {
2161  m_domain = wxRect(left, top, width, height);
2162  m_plot_size = wxRect(left, top, width + left, height + top);
2163  }
2164  void UpdateBox(const wxRect &size)
2165  {
2166  m_domain = size;
2167  m_plot_size = wxRect(size.GetLeft(), size.GetTop(),
2168  size.GetWidth() + size.GetLeft(), size.GetHeight() + size.GetTop());
2169  }
2170  void Plot(wxClientDC &dc, const wxPoint &mousePos);
2171  void ClearPlot(wxClientDC &dc);
2172  void UpdatePlot(wxClientDC &dc, const wxPoint &mousePos);
2173  void SaveDrawState(void)
2174  {
2175  m_IsWasDrawn = m_IsDrawn;
2176  // In any cases, set to false because we erase and repaint all the plot
2177  m_IsDrawn = false;
2178  }
2179 
2180  void SetRightClick(void)
2181  {
2182  m_rightClick = true;
2183  }
2184 
2185  private:
2186  wxRect m_domain;
2187  wxRect m_plot_size;
2188  wxPoint m_mousePosition;
2189  bool m_IsDrawn;
2190  bool m_IsWasDrawn;
2191  bool m_rightClick;
2192  void DrawCross(wxClientDC &dc) const;
2193 };
2194 
2216 class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
2217 {
2218  public:
2219  mpWindow()
2220  {
2221  InitParameters();
2222  }
2223 
2224  mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
2225  long flags = 0);
2226 
2227  ~mpWindow();
2228 
2232  wxMenu* GetPopupMenu()
2233  {
2234  return &m_popmenu;
2235  }
2236 
2244  bool AddLayer(mpLayer *layer, bool refreshDisplay = true);
2245 
2255  bool DelLayer(mpLayer *layer, bool alsoDeleteObject, bool refreshDisplay = true);
2256 
2261  void DelAllLayers(bool alsoDeleteObject, bool refreshDisplay = true);
2262 
2268  void DelAllPlot(bool alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true);
2269 
2275  mpLayer* GetLayer(int position);
2276 
2283  mpLayer* GetLayersType(int position, mpLayerType type);
2284 
2290  mpLayer* GetLayerPlot(int position, mpFunctionType func = mpfAllType);
2291 
2294  mpLayer* GetLayerAxis(int position, mpScaleType scale = mpsAllType);
2295 
2300  mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
2301 
2305  mpLayer* GetClosestPlot(wxCoord ix, wxCoord iy, double *xnear, double *ynear, bool *isY2Axis);
2306 
2311  mpLayer* GetLayerByName(const wxString &name);
2312 
2317  mpLayer* GetLayerByClassName(const wxString &name);
2318 
2322  void RefreshLegend(void);
2323 
2327  mpScaleX* GetLayerXAxis();
2328 
2332  mpScaleY* GetLayerYAxis();
2333 
2337  mpScaleY* GetLayerY2Axis();
2338 
2342  void SetScaleX(const double scaleX)
2343  {
2344  if (ISNOTNULL(scaleX))
2345  m_scaleX = scaleX;
2346  UpdateAll();
2347  }
2348 
2353  double GetScaleX(void) const
2354  {
2355  return m_scaleX;
2356  }
2357 
2361  void SetScaleY(const double scaleY)
2362  {
2363  if (ISNOTNULL(scaleY))
2364  m_scaleY = scaleY;
2365  UpdateAll();
2366  }
2367 
2372  double GetScaleY(bool Y2 = false) const
2373  {
2374  if (Y2)
2375  return m_scaleY2;
2376  else
2377  return m_scaleY;
2378  } // Schaling's method: maybe another method exists with the same name
2379 
2380  [[deprecated("Incomplete, use UpdateBBox instead")]]
2383  void SetBound();
2384 
2387  {
2388  return m_bound;
2389  }
2390 
2394  void SetPosX(const double posX)
2395  {
2396  m_posX = posX;
2397  UpdateAll();
2398  }
2399 
2404  double GetPosX(void) const
2405  {
2406  return m_posX;
2407  }
2408 
2412  void SetPosY(const double posY, const double posY2)
2413  {
2414  m_posY = posY;
2415  m_posY2 = posY2;
2416  UpdateAll();
2417  }
2418 
2423  double GetPosY(bool Y2 = false) const
2424  {
2425  if (Y2)
2426  return m_posY2;
2427  else
2428  return m_posY;
2429  }
2430 
2436  void SetScreen(const int scrX, const int scrY)
2437  {
2438  m_scrX = scrX;
2439  m_scrY = scrY;
2440  m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
2441  m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
2442 
2443  m_plotBoundaries.endPx = m_scrX;
2444  m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
2445  m_plotBoundaries.endPy = m_scrY;
2446  m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
2447 
2448  m_PlotArea = wxRect(m_margin.left - EXTRA_MARGIN, m_margin.top - EXTRA_MARGIN,
2449  m_plotWidth + 2*EXTRA_MARGIN, m_plotHeight + 2*EXTRA_MARGIN);
2450 
2451  m_magnet.UpdateBox(m_PlotArea);
2452  }
2453 
2460  int GetScreenX(void) const
2461  {
2462  return m_scrX;
2463  }
2464 
2471  int GetScreenY(void) const
2472  {
2473  return m_scrY;
2474  }
2475 
2480  void SetPos(const double posX, const double posY, const double posY2)
2481  {
2482  m_posX = posX;
2483  m_posY = posY;
2484  m_posY2 = posY2;
2485  UpdateAll();
2486  }
2487 
2491  inline double p2x(const wxCoord pixelCoordX) const
2492  {
2493  return m_posX + pixelCoordX / m_scaleX;
2494  }
2495 
2499  inline double p2y(const wxCoord pixelCoordY, bool Y2 = false) const
2500  {
2501  if (Y2)
2502  return m_posY2 - pixelCoordY / m_scaleY2;
2503  else
2504  return m_posY - pixelCoordY / m_scaleY;
2505  }
2506 
2510  inline wxCoord x2p(const double x) const
2511  {
2512  return (wxCoord)((x - m_posX) * m_scaleX);
2513  }
2514 
2518  inline wxCoord y2p(const double y, bool Y2 = false) const
2519  {
2520  if (Y2)
2521  return (wxCoord)((m_posY2 - y) * m_scaleY2);
2522  else
2523  return (wxCoord)((m_posY - y) * m_scaleY);
2524  }
2525 
2528  void EnableDoubleBuffer(const bool enabled)
2529  {
2530  m_enableDoubleBuffer = enabled;
2531  }
2532 
2535  void EnableMousePanZoom(const bool enabled)
2536  {
2537  m_enableMouseNavigation = enabled;
2538  }
2539 
2545  void LockAspect(bool enable = true);
2546 
2551  inline bool IsAspectLocked() const
2552  {
2553  return m_lockaspect;
2554  }
2555 
2560  inline bool IsRepainting() const
2561  {
2562  return m_repainting;
2563  }
2564 
2569  void Fit();
2570 
2577  void Fit(const mpFloatRect &rect, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
2578 
2583  void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
2584 
2589  void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
2590 
2592  void ZoomInX();
2593 
2595  void ZoomOutX();
2596 
2598  void ZoomInY();
2599 
2601  void ZoomOutY();
2602 
2604  void ZoomRect(wxPoint p0, wxPoint p1);
2605 
2607  void UpdateAll();
2608 
2609  // Added methods by Davide Rondini
2610 
2614  unsigned int CountLayers();
2615 
2618  unsigned int CountAllLayers()
2619  {
2620  return (unsigned int)m_layers.size();
2621  }
2622 
2626  unsigned int CountLayersType(mpLayerType type);
2627  unsigned int CountLayersFXYPlot();
2628 
2631  //void PrintGraph(mpPrintout *print);
2632 
2635  mpFloatRect GetDesiredBoundingBox() const { return m_desired; }
2636 
2640  double GetDesiredXmin() const
2641  {
2642  return m_desired.Xmin;
2643  }
2644 
2649  double GetDesiredXmax() const
2650  {
2651  return m_desired.Xmax;
2652  }
2653 
2658  double GetDesiredYmin() const
2659  {
2660  return m_desired.Ymin;
2661  }
2662 
2667  double GetDesiredYmax() const
2668  {
2669  return m_desired.Ymax;
2670  }
2671 
2674  void GetBoundingBox(double *bbox) const;
2675  mpFloatRect *GetBoundingBox(void)
2676  {
2677  return &m_bound;
2678  }
2679 
2682  void SetMPScrollbars(bool status);
2683 
2686  bool GetMPScrollbars() const
2687  {
2688  return m_enableScrollBars;
2689  }
2690 
2696  bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
2697 
2701  wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
2702 
2706  void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
2707 
2712  bool LoadFile(const wxString &filename);
2713 
2717 
2724  void SetMargins(int top, int right, int bottom, int left);
2725 
2727  void SetMarginTop(int top)
2728  {
2729  SetMargins(top, m_margin.right, m_margin.bottom, m_margin.left);
2730  }
2731 
2733  int GetMarginTop() const
2734  {
2735  return m_margin.top;
2736  }
2737 
2739  void SetMarginRight(int right)
2740  {
2741  SetMargins(m_margin.top, right, m_margin.bottom, m_margin.left);
2742  }
2743 
2745  int GetMarginRight() const
2746  {
2747  return m_margin.right;
2748  }
2749 
2751  void SetMarginBottom(int bottom)
2752  {
2753  SetMargins(m_margin.top, m_margin.right, bottom, m_margin.left);
2754  }
2755 
2757  int GetMarginBottom() const
2758  {
2759  return m_margin.bottom;
2760  }
2761 
2763  void SetMarginLeft(int left)
2764  {
2765  SetMargins(m_margin.top, m_margin.right, m_margin.bottom, left);
2766  }
2767 
2769  int GetMarginLeft() const
2770  {
2771  return m_margin.left;
2772  }
2773 
2775  int GetPlotWidth() const
2776  {
2777  return m_plotWidth;
2778  }
2779 
2781  int GetPlotHeight() const
2782  {
2783  return m_plotHeight;
2784  }
2785 
2787  mpRect GetPlotBoundaries(bool with_margin) const
2788  {
2789  mpRect bond;
2790  if (with_margin)
2791  bond = m_plotBoundariesMargin;
2792  else
2793  bond = m_plotBoundaries;
2794  bond.startPx -= EXTRA_MARGIN;
2795  bond.endPx += EXTRA_MARGIN;
2796  bond.startPy -= EXTRA_MARGIN;
2797  bond.endPy += EXTRA_MARGIN;
2798  return bond;
2799  }
2800 
2802  void SetDrawBox(bool drawbox)
2803  {
2804  m_drawBox = drawbox;
2805  }
2806 
2808  bool GetDrawBox() const
2809  {
2810  return m_drawBox;
2811  }
2812 
2816  mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
2817 
2821  void SetLayerVisible(const wxString &name, bool viewable);
2822 
2826  bool IsLayerVisible(const wxString &name);
2827 
2831  bool IsLayerVisible(const unsigned int position);
2832 
2836  void SetLayerVisible(const unsigned int position, bool viewable);
2837 
2842  void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
2843 
2846  const wxColour& GetAxesColour() const
2847  {
2848  return m_axColour;
2849  }
2850 
2851  const wxColour& GetbgColour() const
2852  {
2853  return m_bgColour;
2854  }
2855 
2856  void SetbgColour(const wxColour &colour)
2857  {
2858  m_bgColour = colour;
2859  }
2860 
2865  void SetOnDeleteLayer(const mpOnDeleteLayer &event)
2866  {
2867  m_OnDeleteLayer = event;
2868  }
2869 
2872  {
2873  m_OnDeleteLayer = NULL;
2874  }
2875 
2880  void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
2881  {
2882  m_OnUserMouseAction = userMouseEventHandler;
2883  }
2884 
2887  {
2888  m_OnUserMouseAction = NULL;
2889  }
2890 
2896  bool IsLogXaxis() const
2897  {
2898  return m_LogXaxis;
2899  }
2900 
2901  bool IsLogYaxis() const
2902  {
2903  return m_LogYaxis;
2904  }
2905 
2906  void SetLogXaxis(bool log)
2907  {
2908  m_LogXaxis = log;
2909  }
2910 
2911  void SetLogYaxis(bool log)
2912  {
2913  m_LogYaxis = log;
2914  }
2915 
2916  bool GetMagnetize() const
2917  {
2918  return m_magnetize;
2919  }
2920 
2921  void SetMagnetize(bool mag)
2922  {
2923  m_magnetize = mag;
2924  }
2925 
2926 #ifdef ENABLE_MP_CONFIG
2927  void RefreshConfigWindow();
2932  MathPlotConfigDialog* GetConfigWindow(bool Create = false);
2933 #endif // ENABLE_MP_CONFIG
2934 
2935  void Update_CountY2Axis(bool Y2Axis);
2936 
2937  bool Y2AxisExist(void) const
2938  {
2939  return m_countY2Axis > 0;
2940  }
2941 
2942  protected:
2943  virtual void OnPaint(wxPaintEvent &event);
2944  virtual void OnSize(wxSizeEvent &event);
2945  virtual void OnShowPopupMenu(wxMouseEvent &event);
2946  virtual void OnCenter(wxCommandEvent &event);
2947  virtual void OnFit(wxCommandEvent &event);
2948  virtual void OnToggleGrids(wxCommandEvent &event);
2949  virtual void OnToggleCoords(wxCommandEvent &event);
2950  virtual void OnScreenShot(wxCommandEvent &event);
2951  virtual void OnFullScreen(wxCommandEvent &event);
2952 #ifdef ENABLE_MP_CONFIG
2953  virtual void OnConfiguration(wxCommandEvent &event);
2954 #endif // ENABLE_MP_CONFIG
2955  virtual void OnLoadFile(wxCommandEvent &event);
2956  virtual void OnZoomIn(wxCommandEvent &event);
2957  virtual void OnZoomOut(wxCommandEvent &event);
2958  virtual void OnLockAspect(wxCommandEvent &event);
2959  virtual void OnMouseHelp(wxCommandEvent &event);
2960  virtual void OnMouseLeftDown(wxMouseEvent &event);
2961  virtual void OnMouseRightDown(wxMouseEvent &event);
2962  virtual void OnMouseMove(wxMouseEvent &event);
2963  virtual void OnMouseLeftRelease(wxMouseEvent &event);
2964  virtual void OnMouseWheel(wxMouseEvent &event);
2965  virtual void OnMouseLeave(wxMouseEvent &event);
2966  bool CheckUserMouseAction(wxMouseEvent &event);
2967  virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
2968  virtual void OnScrollPageUp(wxScrollWinEvent &event);
2969  virtual void OnScrollPageDown(wxScrollWinEvent &event);
2970  virtual void OnScrollLineUp(wxScrollWinEvent &event);
2971  virtual void OnScrollLineDown(wxScrollWinEvent &event);
2972  virtual void OnScrollTop(wxScrollWinEvent &event);
2973  virtual void OnScrollBottom(wxScrollWinEvent &event);
2974 
2975  void DoScrollCalc(const int position, const int orientation);
2976 
2977  void DoZoomInXCalc(const int staticXpixel);
2978  void DoZoomInYCalc(const int staticYpixel);
2979  void DoZoomOutXCalc(const int staticXpixel);
2980  void DoZoomOutYCalc(const int staticYpixel);
2981 
2982  void Zoom(bool zoomIn, const wxPoint &centerPoint);
2983 
2986  virtual bool UpdateBBox();
2987 
2988  void InitParameters();
2989 
2990  wxTopLevelWindow* m_parent;
2991  bool m_fullscreen;
2992 
2993  mpLayerList m_layers;
2997 
2998  wxMenu m_popmenu;
3000  wxColour m_bgColour;
3001  wxColour m_fgColour;
3002  wxColour m_axColour;
3003  bool m_drawBox;
3004 
3006  double m_scaleX;
3007  double m_scaleY;
3008  double m_scaleY2;
3009  double m_posX;
3010  double m_posY;
3011  double m_posY2;
3012  int m_scrX;
3013  int m_scrY;
3016 
3021 
3023  wxCoord m_plotWidth;
3024  wxCoord m_plotHeight;
3025 
3028  wxRect m_PlotArea;
3029 
3030  bool m_repainting;
3031  int m_last_lx, m_last_ly;
3032  wxBitmap* m_buff_bmp;
3035  bool m_mouseMovedAfterRightClick;
3036  wxPoint m_mouseRClick;
3037  wxPoint m_mouseLClick;
3038  bool m_enableScrollBars;
3039  int m_scrollX, m_scrollY;
3043  bool m_InInfoLegend;
3044 
3045  wxBitmap* m_zoom_bmp;
3046  wxRect m_zoom_dim;
3047  wxRect m_zoom_oldDim;
3048 
3051 
3052  bool m_LogXaxis = false;
3053  bool m_LogYaxis = false;
3054 
3055  wxBitmap* m_Screenshot_bmp;
3056 
3057 #ifdef ENABLE_MP_CONFIG
3058  MathPlotConfigDialog* m_configWindow = NULL;
3059 #endif // ENABLE_MP_CONFIG
3060 
3061  mpOnDeleteLayer m_OnDeleteLayer = NULL;
3062  mpOnUserMouseAction m_OnUserMouseAction = NULL;
3063 
3067  virtual void DesiredBoundsHaveChanged() {};
3068 
3069  private:
3070  int m_countY2Axis = 0;
3071  void FillI18NString();
3072 
3074  void CheckAndReportDesiredBoundsChanges();
3075  bool m_initialDesiredBoundsRecorded = false;
3076  mpFloatRect m_lastDesiredReportedBounds;
3077 
3078  wxDECLARE_DYNAMIC_CLASS(mpWindow);
3079  wxDECLARE_EVENT_TABLE();
3080 
3081  // To have direct access to m_Screenshot_dc
3082  friend mpPrintout;
3083 };
3084 
3085 //-----------------------------------------------------------------------------
3086 // mpText - provided by Val Greene
3087 //-----------------------------------------------------------------------------
3088 
3096 class WXDLLIMPEXP_MATHPLOT mpText: public mpLayer
3097 {
3098  public:
3101  mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
3102  {
3103  m_subtype = mptText;
3104  SetName(name);
3105  m_offsetx = 5;
3106  m_offsety = 50;
3107  m_location = mpMarginNone;
3108  m_ZIndex = mpZIndex_TEXT;
3109  }
3110 
3114  mpText(const wxString &name, int offsetx, int offsety);
3115 
3119  mpText(const wxString &name, mpLocation marginLocation);
3120 
3123  virtual bool HasBBox()
3124  {
3125  return false;
3126  }
3127 
3130  void SetLocation(mpLocation location)
3131  {
3132  m_location = location;
3133  }
3134 
3137  mpLocation GetLocation() const
3138  {
3139  return m_location;
3140  }
3141 
3144  void SetOffset(int offX, int offY)
3145  {
3146  m_offsetx = offX;
3147  m_offsety = offY;
3148  }
3149 
3152  void GetOffset(int *offX, int *offY) const
3153  {
3154  *offX = m_offsetx;
3155  *offY = m_offsety;
3156  }
3157 
3158  protected:
3161  mpLocation m_location;
3162 
3165  virtual void DoPlot(wxDC &dc, mpWindow &w);
3166 
3167  wxDECLARE_DYNAMIC_CLASS(mpText);
3168 };
3169 
3173 class WXDLLIMPEXP_MATHPLOT mpTitle: public mpText
3174 {
3175  public:
3178  mpTitle();
3179 
3182  mpTitle(const wxString &name) :
3183  mpText(name, mpMarginTopCenter)
3184  {
3185  m_subtype = mptTitle;
3186  SetPen(*wxWHITE_PEN);
3187  SetBrush(*wxWHITE_BRUSH);
3188  }
3189 
3190  protected:
3191 
3192  wxDECLARE_DYNAMIC_CLASS(mpTitle);
3193 };
3194 
3195 //-----------------------------------------------------------------------------
3196 // mpPrintout - provided by Davide Rondini
3197 //-----------------------------------------------------------------------------
3198 
3203 class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
3204 {
3205  public:
3206  mpPrintout()
3207  {
3208  plotWindow = NULL;
3209  drawn = false;
3210  stretch_factor = 2;
3211  }
3212 
3213  mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
3214  virtual ~mpPrintout()
3215  {
3216  ;
3217  }
3218 
3219  void SetDrawState(bool drawState)
3220  {
3221  drawn = drawState;
3222  }
3223 
3224  bool OnPrintPage(int page);
3225  bool HasPage(int page);
3226 
3229  void SetFactor(int factor)
3230  {
3231  stretch_factor = factor;
3232  }
3233 
3234  private:
3235  bool drawn;
3236  mpWindow* plotWindow;
3237  int stretch_factor; // To reduce the size of plot
3238 
3239  protected:
3240 
3241  wxDECLARE_DYNAMIC_CLASS(mpPrintout);
3242 };
3243 
3244 //-----------------------------------------------------------------------------
3245 // mpMovableObject - provided by Jose Luis Blanco
3246 //-----------------------------------------------------------------------------
3254 class WXDLLIMPEXP_MATHPLOT mpMovableObject: public mpFunction
3255 {
3256  public:
3260  m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
3261  {
3262  assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
3263  m_subtype = mpfMovable;
3264  m_bbox_min_x = m_bbox_max_x = 0;
3265  m_bbox_min_y = m_bbox_max_y = 0;
3266  }
3267 
3268  virtual ~mpMovableObject() {}
3269 
3272  void GetCoordinateBase(double &x, double &y, double &phi) const
3273  {
3274  x = m_reference_x;
3275  y = m_reference_y;
3276  phi = m_reference_phi;
3277  }
3278 
3281  void SetCoordinateBase(double x, double y, double phi = 0)
3282  {
3283  m_reference_x = x;
3284  m_reference_y = y;
3285  m_reference_phi = phi;
3286  m_flags = mpALIGN_NE;
3287  ShapeUpdated();
3288  }
3289 
3290  virtual bool HasBBox()
3291  {
3292  return m_trans_shape_xs.size() != 0;
3293  }
3294 
3297  virtual double GetMinX()
3298  {
3299  return m_bbox_min_x;
3300  }
3301 
3304  virtual double GetMaxX()
3305  {
3306  return m_bbox_max_x;
3307  }
3308 
3311  virtual double GetMinY()
3312  {
3313  return m_bbox_min_y;
3314  }
3315 
3318  virtual double GetMaxY()
3319  {
3320  return m_bbox_max_y;
3321  }
3322 
3323  protected:
3324 
3327  double m_reference_x, m_reference_y, m_reference_phi;
3328 
3329  virtual void DoPlot(wxDC &dc, mpWindow &w);
3330 
3333  void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
3334 
3337  std::vector<double> m_shape_xs, m_shape_ys;
3338 
3342  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
3343 
3347  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
3348 
3352  void ShapeUpdated();
3353 
3354  wxDECLARE_DYNAMIC_CLASS(mpMovableObject);
3355 };
3356 
3357 //-----------------------------------------------------------------------------
3358 // mpCovarianceEllipse - provided by Jose Luis Blanco
3359 //-----------------------------------------------------------------------------
3371 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse: public mpMovableObject
3372 {
3373  public:
3377  mpCovarianceEllipse(double cov_00 = 1, double cov_11 = 1, double cov_01 = 0, double quantiles = 2, int segments = 32,
3378  const wxString &layerName = _T("")) : mpMovableObject(),
3379  m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
3380  {
3381  m_continuous = true;
3382  m_name = layerName;
3383  RecalculateShape();
3384  }
3385 
3386  virtual ~mpCovarianceEllipse()
3387  {
3388  ;
3389  }
3390 
3391  double GetQuantiles() const
3392  {
3393  return m_quantiles;
3394  }
3395 
3398  void SetQuantiles(double q)
3399  {
3400  m_quantiles = q;
3401  RecalculateShape();
3402  }
3403 
3404  void SetSegments(int segments)
3405  {
3406  m_segments = segments;
3407  }
3408 
3409  int GetSegments() const
3410  {
3411  return m_segments;
3412  }
3413 
3416  void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
3417  {
3418  cov_00 = m_cov_00;
3419  cov_01 = m_cov_01;
3420  cov_11 = m_cov_11;
3421  }
3422 
3425  void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
3426  {
3427  m_cov_00 = cov_00;
3428  m_cov_01 = cov_01;
3429  m_cov_11 = cov_11;
3430  RecalculateShape();
3431  }
3432 
3433  protected:
3436  double m_cov_00, m_cov_11, m_cov_01;
3437  double m_quantiles;
3438 
3442 
3445  void RecalculateShape();
3446 
3447  wxDECLARE_DYNAMIC_CLASS(mpCovarianceEllipse);
3448 };
3449 
3450 //-----------------------------------------------------------------------------
3451 // mpPolygon - provided by Jose Luis Blanco
3452 //-----------------------------------------------------------------------------
3457 class WXDLLIMPEXP_MATHPLOT mpPolygon: public mpMovableObject
3458 {
3459  public:
3462  mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
3463  {
3464  m_continuous = true;
3465  m_name = layerName;
3466  }
3467 
3468  virtual ~mpPolygon()
3469  {
3470  ;
3471  }
3472 
3478  void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
3479 
3480  protected:
3481 
3482  wxDECLARE_DYNAMIC_CLASS(mpPolygon);
3483 };
3484 
3485 //-----------------------------------------------------------------------------
3486 // mpBitmapLayer - provided by Jose Luis Blanco
3487 //-----------------------------------------------------------------------------
3492 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer: public mpLayer
3493 {
3494  public:
3498  {
3499  m_min_x = m_max_x = 0;
3500  m_min_y = m_max_y = 0;
3501  m_validImg = false;
3502  m_bitmapChanged = false;
3503  m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
3504  }
3505 
3506  virtual ~mpBitmapLayer()
3507  {
3508  ;
3509  }
3510 
3513  void GetBitmapCopy(wxImage &outBmp) const;
3514 
3522  void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
3523 
3526  virtual double GetMinX()
3527  {
3528  return m_min_x;
3529  }
3530 
3533  virtual double GetMaxX()
3534  {
3535  return m_max_x;
3536  }
3537 
3540  virtual double GetMinY()
3541  {
3542  return m_min_y;
3543  }
3544 
3547  virtual double GetMaxY()
3548  {
3549  return m_max_y;
3550  }
3551 
3552  protected:
3553 
3556  wxImage m_bitmap;
3557  wxBitmap m_scaledBitmap;
3558  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
3559  bool m_validImg;
3560  bool m_bitmapChanged;
3561 
3564  double m_min_x, m_max_x, m_min_y, m_max_y;
3565 
3566  virtual void DoPlot(wxDC &dc, mpWindow &w);
3567 
3568  wxDECLARE_DYNAMIC_CLASS(mpBitmapLayer);
3569 };
3570 
3571 // utility class
3572 
3573 // Enumeration of classic colour
3574 typedef enum __mp_Colour
3575 {
3576  mpBlue,
3577  mpRed,
3578  mpGreen,
3579  mpPurple,
3580  mpYellow,
3581  mpFuchsia,
3582  mpLime,
3583  mpAqua,
3584  mpOlive
3585 } mpColour;
3586 
3591 class WXDLLIMPEXP_MATHPLOT wxIndexColour: public wxColour
3592 {
3593  public:
3594  wxIndexColour(unsigned int id)
3595  {
3596  switch (id)
3597  {
3598  case 0:
3599  this->Set(0, 0, 255);
3600  break; // Blue
3601  case 1:
3602  this->Set(255, 0, 0);
3603  break; // Red
3604  case 2:
3605  this->Set(0, 128, 0);
3606  break; // Green
3607  case 3:
3608  this->Set(128, 0, 128);
3609  break; // Purple
3610  case 4:
3611  this->Set(255, 255, 0);
3612  break; // Yellow
3613  case 5:
3614  this->Set(255, 0, 255);
3615  break; // Fuchsia
3616  case 6:
3617  this->Set(0, 255, 0);
3618  break; // Lime
3619  case 7:
3620  this->Set(0, 255, 255);
3621  break; // Aqua/Cyan
3622  case 8:
3623  this->Set(128, 128, 0);
3624  break; // Olive
3625  default:
3626  this->Set((ChannelType)((rand() * 255) / RAND_MAX), (ChannelType)((rand() * 255) / RAND_MAX),
3627  (ChannelType)((rand() * 255) / RAND_MAX));
3628  }
3629  }
3630 };
3631 
3634 // ---------------------------------------------------------------------
3635 #ifdef ENABLE_MP_NAMESPACE
3636  }// namespace MathPlot
3637  // No, iff build enables namespace, its up to app to use it appropriately: using namespace MathPlot;
3638 #endif // ENABLE_MP_NAMESPACE
3639 
3640 #endif // MATHPLOT_H_INCLUDED
int m_offsety
Holds offset for Y in percentage.
Definition: mathplot.h:3160
const wxString & GetLabelFormat() const
Get axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:1908
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:2133
bool IsHorizontal(void) const
Get if is horizontal line.
Definition: mathplot.h:1222
__mp_Location_Type
Location for the Info layer.
Definition: mathplot.h:269
void SetScaleY(const double scaleY)
Set current view&#39;s Y scale and refresh display.
Definition: mathplot.h:2361
double GetDesiredYmin() const
Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not ex...
Definition: mathplot.h:2658
double m_posY
Current view&#39;s Y position.
Definition: mathplot.h:3010
void SetValue(const double value)
Set x or y.
Definition: mathplot.h:1215
mpInfoLegend * m_InfoLegend
pointer to the optional info legend layer
Definition: mathplot.h:3042
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:316
double m_min_x
The shape of the bitmap:
Definition: mathplot.h:3564
void EnableDoubleBuffer(const bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled).
Definition: mathplot.h:2528
mpFloatRect m_bound
Global layer bounding box in user coordinates. Does NOT include borders.
Definition: mathplot.h:3005
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition: mathplot.h:635
Bitmap type layer.
Definition: mathplot.h:410
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition: mathplot.h:756
double GetScaleY(bool Y2=false) const
Get current view&#39;s Y scale.
Definition: mathplot.h:2372
Plot type layer.
Definition: mathplot.h:395
int GetScreenX(void) const
Get current view&#39;s X dimension in device context units.
Definition: mathplot.h:2460
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:3547
void UnSetOnDeleteLayer()
Remove the &#39;delete layer event&#39; callback.
Definition: mathplot.h:2871
void SetXValue(const double xvalue)
Set x.
Definition: mathplot.h:1266
double GetPosY(bool Y2=false) const
Get current view&#39;s Y position.
Definition: mathplot.h:2423
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:3457
void SetScaleX(const double scaleX)
Set current view&#39;s X scale and refresh display.
Definition: mathplot.h:2342
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:513
A rectangle structure in several (integer) flavors.
Definition: mathplot.h:167
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:1479
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition: mathplot.h:3014
Show legend items with line with the same pen of referred mpLayer.
Definition: mathplot.h:315
__mp_Layer_Type
Definition: mathplot.h:391
bool PointIsInside(double x, double y) const
Is point inside this bounding box (ignoring Y2)?
Definition: mathplot.h:209
Show/Hide grids.
Definition: mathplot.h:257
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition: mathplot.h:3492
bool m_magnetize
For mouse magnetization.
Definition: mathplot.h:3049
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1814
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition: mathplot.h:3036
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:1798
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition: mathplot.h:3462
bool GetShowGrids() const
Get axis grids.
Definition: mathplot.h:1894
void InitializeBoundingBox(double x, double y, double y2=0)
Initialize bounding box with an initial point.
Definition: mathplot.h:224
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:393
enum __mp_Direction_Type mpLegendDirection
Direction for the Legend layer.
wxString m_name
Layer&#39;s name.
Definition: mathplot.h:755
virtual bool IsLayerType(mpLayerType type, int *sub_type)
Specifies that if the layer is of type "type".
Definition: mathplot.h:488
const mpLayerType m_type
Layer type mpLAYER_*.
Definition: mathplot.h:748
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1199
Lock x/y scaling aspect.
Definition: mathplot.h:256
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:1015
Info box type layer.
Definition: mathplot.h:415
int m_offsetx
Holds offset for X in percentage.
Definition: mathplot.h:3159
Abstract class providing a line.
Definition: mathplot.h:1193
Abstract class providing an vertical line.
Definition: mathplot.h:1258
bool GetShowTicks() const
Get axis ticks.
Definition: mathplot.h:1880
mpFloatRect m_desired
These are updated in Fit() only (also Zoom) May be different from the real borders (layer coordinates...
Definition: mathplot.h:3020
void SetPos(const double posX, const double posY, const double posY2)
Set current view&#39;s X and Y position and refresh display.
Definition: mathplot.h:2480
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:2216
enum __Info_Type mpInfoType
sub_type values for mpLAYER_INFO
double m_scaleY
Current view&#39;s Y scale.
Definition: mathplot.h:3007
wxPen m_gridpen
Grid&#39;s pen. Default Colour = LIGHT_GREY, width = 1, style = wxPENSTYLE_DOT.
Definition: mathplot.h:1969
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition: mathplot.h:891
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:3281
Chart type layer (bar chart)
Definition: mathplot.h:400
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition: mathplot.h:612
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:2551
int m_winY
Holds the mpWindow size. Used to rescale position when window is resized.
Definition: mathplot.h:893
~mpBarChart()
Destructor.
Definition: mathplot.h:1722
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:2491
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition: mathplot.h:763
double p2y(const wxCoord pixelCoordY, bool Y2=false) const
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:2499
void SetLabelMode(unsigned int mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:2037
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition: mathplot.h:3037
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition: mathplot.h:3067
void SetPen(const wxPen &pen)
Set layer pen.
Definition: mathplot.h:620
int m_flags
Holds label alignment. Default : mpALIGN_NE.
Definition: mathplot.h:760
virtual bool HasBBox()
Text Layer has not bounding box.
Definition: mathplot.h:3123
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:497
wxPoint GetPosition() const
Returns the position of the upper left corner of the box (in pixels)
Definition: mathplot.h:855
void SetPenSeries(const wxPen &pen)
Pen series for tractable.
Definition: mathplot.h:970
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:666
unsigned int GetLabelMode() const
Get X axis label view mode.
Definition: mathplot.h:2030
~mpPieChart()
Destructor.
Definition: mathplot.h:1784
int m_symbolSize
Size of the symbol. Default 6.
Definition: mathplot.h:1183
int GetPlotWidth() const
Get the width of the plot.
Definition: mathplot.h:2775
int m_subtype
Layer sub type, set in constructors.
Definition: mathplot.h:750
Just the end of ZOrder.
Definition: mathplot.h:417
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:3311
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer...
Definition: mathplot.h:408
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:2739
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:2716
void SetContinuity(bool continuity)
Set the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1103
wxMenu m_popmenu
Canvas&#39; context menu.
Definition: mathplot.h:2998
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1321
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:1361
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
wxColour m_axColour
Axes Colour.
Definition: mathplot.h:3002
bool m_visible
Toggles layer visibility. Default : true.
Definition: mathplot.h:758
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition: mathplot.h:3026
double m_scaleY2
Current view&#39;s Y2 scale.
Definition: mathplot.h:3008
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:3272
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:2141
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:997
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:2006
bool m_tractable
Is the layer tractable.
Definition: mathplot.h:759
void SetLocation(mpLocation location)
Set the location of the box.
Definition: mathplot.h:3130
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:1688
virtual void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:2022
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:2535
bool m_drawBox
Draw box of the plot bound. Default true.
Definition: mathplot.h:3003
Plot (function) type layer.
Definition: mathplot.h:413
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition: mathplot.h:1924
int GetMarginRight() const
Get the right margin.
Definition: mathplot.h:2745
bool m_CanDelete
Is the layer can be deleted.
Definition: mathplot.h:762
mpSymbol GetSymbol() const
Get symbol.
Definition: mathplot.h:1139
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition: mathplot.h:442
wxFont m_font
Layer&#39;s font.
Definition: mathplot.h:751
bool GetCanDelete(void) const
Get CanDelete for plot.
Definition: mathplot.h:735
Axis type layer.
Definition: mathplot.h:411
Definition: MathPlotConfig.h:44
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:1822
bool m_auto
Flag to autosize grids. Default true.
Definition: mathplot.h:1972
Axis type layer.
Definition: mathplot.h:394
void SetCanDelete(bool canDelete)
Set CanDelete for plot.
Definition: mathplot.h:728
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:3526
mpFloatRect Get_Bound(void) const
Get bounding box encompassing all visible plots on this mpWindow.
Definition: mathplot.h:2386
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition: mathplot.h:3040
void SetPosY(const double posY, const double posY2)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:2412
~mpInfoCoords()
Default destructor.
Definition: mathplot.h:929
void ShowGrids(bool grids)
Set axis grids.
Definition: mathplot.h:1887
mpScaleY(const wxString &name=_T("Y"), int flags=mpALIGN_CENTERY, bool grids=false, bool Y2Axis=false)
Full constructor.
Definition: mathplot.h:2078
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition: mathplot.h:2846
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:645
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:2125
virtual double GetMaxY()
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1601
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition: mathplot.h:3101
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:3556
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing...
Definition: mathplot.h:2880
each visible plot is described on its own line, one above the other
Definition: mathplot.h:323
void SetPosX(const double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:2394
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition: mathplot.h:742
int GetPlotHeight() const
Get the height of the plot.
Definition: mathplot.h:2781
bool IsSeriesCoord() const
Return if we show the series coordinates.
Definition: mathplot.h:958
__Info_Type
sub_type values for mpLAYER_INFO
Definition: mathplot.h:343
#define mpX_NORMAL
Set label for X axis in normal mode.
Definition: mathplot.h:1986
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1553
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:3533
Show/Hide info coord.
Definition: mathplot.h:258
bool GetShowName() const
Get Name visibility.
Definition: mathplot.h:659
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:3425
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:3203
int m_last_ly
For double buffering.
Definition: mathplot.h:3031
mpMagnet m_magnet
For mouse magnetization.
Definition: mathplot.h:3050
wxSize GetSize() const
Returns the size of the box (in pixels)
Definition: mathplot.h:862
Chart type layer.
Definition: mathplot.h:414
bool m_grids
Flag to show grids. Default false.
Definition: mathplot.h:1971
enum __mp_Location_Type mpLocation
Location for the Info layer.
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method)...
Definition: mathplot.h:889
Copy a screen shot to the clipboard.
Definition: mathplot.h:259
Fit view to match bounding box of all layers.
Definition: mathplot.h:252
mpLocation GetLocation() const
Returns the location of the box.
Definition: mathplot.h:3137
Toggle fullscreen only if parent is a frame windows.
Definition: mathplot.h:265
wxBitmap * m_buff_bmp
For double buffering.
Definition: mathplot.h:3032
Center view on click position.
Definition: mathplot.h:255
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition: mathplot.h:1185
virtual ~mpFXYVector()
destrutor
Definition: mathplot.h:1489
__XAxis_Align_Type
Alignment for X axis.
Definition: mathplot.h:284
mpFloatRect GetDesiredBoundingBox() const
Draws the mpWindow on a page for printing.
Definition: mathplot.h:2635
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:3254
double m_scaleX
Current view&#39;s X scale.
Definition: mathplot.h:3006
__Text_Type
sub_type values for mpLAYER_TEXT
Definition: mathplot.h:352
double m_posY2
Current view&#39;s Y2 position.
Definition: mathplot.h:3011
virtual int GetSize()
Return the number of points in the series.
Definition: mathplot.h:1385
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:3337
void SetSymbolSize(int size)
Set symbol size.
Definition: mathplot.h:1146
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition: mathplot.h:3591
unsigned int m_labelType
Select labels mode: mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds.
Definition: mathplot.h:2050
bool GetContinuity() const
Gets the &#39;continuity&#39; property of the layer.
Definition: mathplot.h:1111
A structure for computation of bounds in real units (not in screen pixel) X refer to X axis Y refer t...
Definition: mathplot.h:199
Layer for bar chart.
Definition: mathplot.h:1715
#define mpX_USER
Set label user defined.
Definition: mathplot.h:1997
double m_max
Min and max axis values when autosize is false.
Definition: mathplot.h:1973
wxPen m_pen
Layer&#39;s pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition: mathplot.h:753
wxString m_content
string holding the coordinates to be drawn.
Definition: mathplot.h:976
abstract Layer for chart (bar and pie).
Definition: mathplot.h:1657
bool GetY2Axis() const
Is second Y axis selected for this layer?
Definition: mathplot.h:1175
Show legend items with symbol used with the referred mpLayer.
Definition: mathplot.h:317
bool m_UseY2Axis
Use Y2 axis. This second axis must exist.
Definition: mathplot.h:1186
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:628
const wxRect & GetRectangle() const
Returns the current rectangle coordinates.
Definition: mathplot.h:869
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:3347
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:2640
virtual void DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ...
Definition: mathplot.h:778
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition: mathplot.h:304
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition: mathplot.h:1182
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:2751
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:1509
int m_symbolSize2
Size of the symbol div 2.
Definition: mathplot.h:1184
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:3540
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition: mathplot.h:1940
virtual double GetMinX()
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1580
mpScaleY * m_Y2Axis
Pointer to the optional Y2 axis layer of this mpWindow.
Definition: mathplot.h:2996
mpScaleY * m_YAxis
Pointer to the optional Y axis layer of this mpWindow.
Definition: mathplot.h:2995
void SetYValue(const double yvalue)
Set y.
Definition: mathplot.h:1244
void SetY2Axis(bool _useY2)
Set use of second Y axis.
Definition: mathplot.h:1167
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:1528
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition: mathplot.h:1537
Text box type layer.
Definition: mathplot.h:397
__YAxis_Align_Type
Alignment for Y axis.
Definition: mathplot.h:294
int GetMarginTop() const
Get the top margin.
Definition: mathplot.h:2733
wxRect m_PlotArea
The full size of the plot with EXTRA_MARGIN.
Definition: mathplot.h:3028
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:804
Load a file.
Definition: mathplot.h:263
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:454
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition: mathplot.h:3152
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition: mathplot.h:3023
virtual bool HasBBox()
mpInfoLayer has not bounding box.
Definition: mathplot.h:831
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc...
Definition: mathplot.h:469
Line (horizontal or vertical) type layer.
Definition: mathplot.h:412
wxBitmap * m_zoom_bmp
For zoom selection.
Definition: mathplot.h:3045
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:913
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:2686
int m_scrY
Current view&#39;s Y dimension.
Definition: mathplot.h:3013
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:2510
void SetStep(unsigned int step)
Set step for plot.
Definition: mathplot.h:1118
~mpInfoLegend()
Default destructor.
Definition: mathplot.h:1011
wxRect m_oldDim
Keep the old values of m_dim.
Definition: mathplot.h:890
wxColour m_bgColour
Background Colour.
Definition: mathplot.h:3000
void SetScreen(const int scrX, const int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:2436
int GetBarWidth(void) const
return the width of the bar
Definition: mathplot.h:1411
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer...
Definition: mathplot.h:2865
void SetSeriesCoord(bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition: mathplot.h:951
virtual double GetMaxX()
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1594
void SetDrawBox(bool drawbox)
Set the draw of the box around the plot.
Definition: mathplot.h:2802
bool m_enableDoubleBuffer
For double buffering. Default enabled.
Definition: mathplot.h:3033
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1093
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:1284
mpTitle(const wxString &name)
Definition: mathplot.h:3182
void SetLabelMode(unsigned int mode, unsigned int time_conv=0x20)
Set X axis label view mode.
Definition: mathplot.h:943
Plot layer implementing a simple title.
Definition: mathplot.h:3173
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:2070
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:3290
bool ViewAsBar(void) const
return true if XY series is plotted with bar
Definition: mathplot.h:1419
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition: mathplot.h:894
virtual void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:693
mpRect GetPlotBoundaries(bool with_margin) const
Get the boundaries of the plot.
Definition: mathplot.h:2787
double GetPosX(void) const
Get current view&#39;s X position.
Definition: mathplot.h:2404
int GetAlign() const
Get X/Y alignment.
Definition: mathplot.h:721
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition: mathplot.h:757
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:3342
virtual void SetLabelFormat(const wxString &format)
Set axis Label format (used for mpX_NORMAL draw mode).
Definition: mathplot.h:1901
void SetAuto(bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition: mathplot.h:1932
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition: mathplot.h:1377
double GetDesiredYmax() const
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
Definition: mathplot.h:2667
enum __XAxis_Align_Type mpXAxis_Align
Alignment for X axis.
bool IsLogXaxis() const
Log axis control.
Definition: mathplot.h:2896
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false...
Definition: mathplot.h:1181
void UnSetOnUserMouseAction()
Remove the &#39;user mouse action event&#39; callback.
Definition: mathplot.h:2886
std::vector< double > m_xs
The internal copy of the set of data to draw.
Definition: mathplot.h:1545
mpScaleX(const wxString &name=_T("X"), int flags=mpALIGN_CENTERX, bool grids=false, unsigned int type=0x00)
Full constructor.
Definition: mathplot.h:2014
~mpChart()
Destructor.
Definition: mathplot.h:1664
Abstract class providing an horizontal line.
Definition: mathplot.h:1236
Zoom into view at clickposition / window center.
Definition: mathplot.h:253
bool m_lockaspect
Scale aspect is locked or not.
Definition: mathplot.h:2999
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:3441
void Rewind()
Rewind value enumeration with mpFXY::GetNextXY.
Definition: mathplot.h:1562
Zoom out.
Definition: mathplot.h:254
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:1854
void SetFont(const wxFont &font)
Set layer font.
Definition: mathplot.h:588
Class for drawing mouse magnetization.
Definition: mathplot.h:2146
int m_reserveXY
Memory reserved for m_xs and m_ys.
Definition: mathplot.h:1549
__mp_Direction_Type
Direction for the Legend layer.
Definition: mathplot.h:321
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:3371
double m_minX
Loaded at SetData.
Definition: mathplot.h:1557
mpInfoCoords * m_InfoCoords
pointer to the optional info coords layer
Definition: mathplot.h:3041
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:2649
__mp_Style_Type
Style for the Legend layer.
Definition: mathplot.h:313
Layer for pie chart.
Definition: mathplot.h:1777
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition: mathplot.h:604
bool IsNotSet() const
Is mpFloatRect set ?
Definition: mathplot.h:230
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:3377
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:596
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition: mathplot.h:3034
int GetMarginLeft() const
Get the left margin.
Definition: mathplot.h:2769
wxColour m_fontcolour
Layer&#39;s font foreground colour.
Definition: mathplot.h:752
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:3416
Bitmap type layer.
Definition: mathplot.h:398
void SetLocation(mpLocation location)
Set the location of the mpInfoLayer box.
Definition: mathplot.h:876
bool IsVisible() const
Checks whether the layer is visible or not.
Definition: mathplot.h:686
void ShowTicks(bool ticks)
Set axis ticks.
Definition: mathplot.h:1873
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition: mathplot.h:477
virtual void SetTractable(bool track)
Sets layer tractability.
Definition: mathplot.h:707
int GetMarginBottom() const
Get the bottom margin.
Definition: mathplot.h:2757
int GetSymbolSize() const
Get symbol size.
Definition: mathplot.h:1154
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition: mathplot.h:3259
Info box type layer.
Definition: mathplot.h:396
int GetScreenY(void) const
Get current view&#39;s Y dimension in device context units.
Definition: mathplot.h:2471
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:521
Plot layer implementing a text string.
Definition: mathplot.h:3096
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition: mathplot.h:3024
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:3318
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition: mathplot.h:2808
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition: mathplot.h:673
wxBrush m_brush
Layer&#39;s brush. Default wxTRANSPARENT_BRUSH.
Definition: mathplot.h:754
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:505
wxPoint m_reference
Holds the reference point for movements.
Definition: mathplot.h:892
Shows information about the mouse commands.
Definition: mathplot.h:264
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:2727
double GetScaleX(void) const
Get current view&#39;s X scale.
Definition: mathplot.h:2353
wxColour m_fgColour
Foreground Colour.
Definition: mathplot.h:3001
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition: mathplot.h:3055
legend components follow each other horizontally on a single line
Definition: mathplot.h:324
void SetItemDirection(mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition: mathplot.h:1028
mpScaleX * m_XAxis
Pointer to the optional X axis layer of this mpWindow.
Definition: mathplot.h:2994
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:3398
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition: mathplot.h:3015
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:3327
wxCoord y2p(const double y, bool Y2=false) const
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:2518
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:1806
unsigned int GetStep() const
Get step for plot.
Definition: mathplot.h:1125
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:3297
Plot layer, abstract base class.
Definition: mathplot.h:430
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition: mathplot.h:761
double GetValue() const
Set x or y.
Definition: mathplot.h:1207
void SetOffset(int offX, int offY)
Set offset.
Definition: mathplot.h:3144
void SetFactor(int factor)
Definition: mathplot.h:3229
void SetName(const wxString &name)
Set layer name.
Definition: mathplot.h:572
mpWindow * m_win
The wxWindow handle.
Definition: mathplot.h:749
void UpdateBoundingBoxToInclude(double x, double y, double y2=0)
Update bounding box to include this point.
Definition: mathplot.h:215
wxString m_labelFormat
Format string used to print labels.
Definition: mathplot.h:1974
double m_posX
Current view&#39;s X position.
Definition: mathplot.h:3009
int m_scrX
Current view&#39;s X dimension in DC units, including all scales, margins.
Definition: mathplot.h:3012
void SetShowName(bool show)
Set Name visibility.
Definition: mathplot.h:652
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:580
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:3436
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:2763
mpLayerList m_layers
List of attached plot layers.
Definition: mathplot.h:2993
bool m_ticks
Flag to show ticks. Default true.
Definition: mathplot.h:1970
mpRect m_margin
Margin around the plot. Default 50.
Definition: mathplot.h:3022
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:1626
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition: mathplot.h:883
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition: mathplot.h:3027
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition: mathplot.h:700
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:1866
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:3304
bool IsRepainting() const
Checks if we are repainting.
Definition: mathplot.h:2560
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:2618
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition: mathplot.h:1916
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition: mathplot.h:2051
void SetSymbol(mpSymbol symbol)
Set symbol.
Definition: mathplot.h:1132
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:3497
Text box type layer.
Definition: mathplot.h:416
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:2232
void SetAlign(int align)
Set X/Y alignment.
Definition: mathplot.h:714
Line (horizontal or vertical) type layer.
Definition: mathplot.h:399
virtual double GetMinY()
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1587