KiCad PCB EDA Suite
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, Maciej Suminski, Tomasz Wlostowski
7 // Created: 21/07/2003
8 // Last edit: 05/08/2016
9 // Copyright: (c) David Schalig, Davide Rondini
10 // Licence: wxWindows licence
12 
13 #ifndef _MP_MATHPLOT_H_
14 #define _MP_MATHPLOT_H_
15 
54 // this definition uses windows dll to export function.
55 // WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
56 // mathplot_EXPORTS will be defined by cmake
57 #ifdef mathplot_EXPORTS
58 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
59 #define WXDLLIMPEXP_DATA_MATHPLOT( type ) WXEXPORT type
60 #else // not making DLL
61 #define WXDLLIMPEXP_MATHPLOT
62 #define WXDLLIMPEXP_DATA_MATHPLOT( type ) type
63 #endif
64 
65 #include <vector>
66 
67 // #include <wx/wx.h>
68 #include <wx/defs.h>
69 #include <wx/menu.h>
70 #include <wx/scrolwin.h>
71 #include <wx/event.h>
72 #include <wx/dynarray.h>
73 #include <wx/pen.h>
74 #include <wx/dcmemory.h>
75 #include <wx/string.h>
76 #include <wx/print.h>
77 #include <wx/image.h>
78 
79 
80 #include <deque>
81 
82 // For memory leak debug
83 #ifdef _WINDOWS
84 #ifdef _DEBUG
85 #include <crtdbg.h>
86 #define DEBUG_NEW new (_NORMAL_BLOCK, __FILE__, __LINE__)
87 #else
88 #define DEBUG_NEW new
89 #endif // _DEBUG
90 #endif // _WINDOWS
91 
92 // Separation for axes when set close to border
93 #define X_BORDER_SEPARATION 40
94 #define Y_BORDER_SEPARATION 60
95 
96 // -----------------------------------------------------------------------------
97 // classes
98 // -----------------------------------------------------------------------------
99 
110 
112 enum
113 {
114  mpID_FIT = 2000, // !< Fit view to match bounding box of all layers
115  mpID_ZOOM_IN, // !< Zoom into view at clickposition / window center
116  mpID_ZOOM_OUT, // !< Zoom out
117  mpID_CENTER, // !< Center view on click position
118  mpID_LOCKASPECT, // !< Lock x/y scaling aspect
119 };
120 
121 // -----------------------------------------------------------------------------
122 // mpLayer
123 // -----------------------------------------------------------------------------
124 
125 typedef enum __mp_Layer_Type
126 {
127  mpLAYER_UNDEF, // !< Layer type undefined
128  mpLAYER_AXIS, // !< Axis type layer
129  mpLAYER_PLOT, // !< Plot type layer
130  mpLAYER_INFO, // !< Info box type layer
131  mpLAYER_BITMAP // !< Bitmap type layer
132 } mpLayerType;
133 
144 class mpScaleBase;
145 
146 class WXDLLIMPEXP_MATHPLOT mpLayer : public wxObject
147 {
148 public:
149  mpLayer();
150 
151  virtual ~mpLayer() {};
152 
160  virtual bool HasBBox() { return TRUE; }
161 
169  virtual bool IsInfo() { return false; };
170 
174  virtual double GetMinX() { return -1.0; }
175 
179  virtual double GetMaxX() { return 1.0; }
180 
184  virtual double GetMinY() { return -1.0; }
185 
189  virtual double GetMaxY() { return 1.0; }
190 
232  virtual void Plot( wxDC& dc, mpWindow& w ) = 0;
233 
237  const wxString& GetName() const { return m_name; }
238 
242  const wxFont& GetFont() const { return m_font; }
243 
247  const wxPen& GetPen() const { return m_pen; }
248 
252  void SetContinuity( bool continuity ) { m_continuous = continuity; }
253 
257  bool GetContinuity() const { return m_continuous; }
258 
261  void ShowName( bool show ) { m_showName = show; };
262 
266  void SetName( wxString name ) { m_name = name; }
267 
271  void SetFont( wxFont& font ) { m_font = font; }
272 
276  void SetPen( wxPen pen ) { m_pen = pen; }
277 
280  void SetDrawOutsideMargins( bool drawModeOutside ) { m_drawOutsideMargins = drawModeOutside; };
281 
284  bool GetDrawOutsideMargins() { return m_drawOutsideMargins; };
285 
289  wxBitmap GetColourSquare( int side = 16 );
290 
293  mpLayerType GetLayerType() { return m_type; };
294 
297  bool IsVisible() { return m_visible; };
298 
301  void SetVisible( bool show ) { m_visible = show; };
302 
305  const wxBrush& GetBrush() const { return m_brush; };
306 
309  void SetBrush( wxBrush brush ) { m_brush = brush; };
310 
311 protected:
312 
313  wxFont m_font; // !< Layer's font
314  wxPen m_pen; // !< Layer's pen
315  wxBrush m_brush; // !< Layer's brush
316  wxString m_name; // !< Layer's name
317  bool m_continuous; // !< Specify if the layer will be plotted as a continuous line or a set of points.
318  bool m_showName; // !< States whether the name of the layer must be shown (default is true).
319  bool m_drawOutsideMargins; // !< select if the layer should draw only inside margins or over all DC
320  mpLayerType m_type; // !< Define layer type, which is assigned by constructor
321  bool m_visible; // !< Toggles layer visibility
322  DECLARE_DYNAMIC_CLASS( mpLayer )
323 };
324 
325 
326 // -----------------------------------------------------------------------------
327 // mpInfoLayer
328 // -----------------------------------------------------------------------------
329 
335 {
336 public:
338  mpInfoLayer();
339 
343  mpInfoLayer( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
344 
346  virtual ~mpInfoLayer();
347 
352  virtual void UpdateInfo( mpWindow& w, wxEvent& event );
353 
356  virtual bool HasBBox() override { return false; }
357 
362  virtual void Plot( wxDC& dc, mpWindow& w ) override;
363 
367  virtual bool IsInfo() override { return true; }
368 
372  virtual bool Inside( wxPoint& point );
373 
376  virtual void Move( wxPoint delta );
377 
379  virtual void UpdateReference();
380 
383  wxPoint GetPosition();
384 
387  wxSize GetSize();
388 
391  const wxRect& GetRectangle() { return m_dim; };
392 
393 protected:
394  wxRect m_dim; // !< The bounding rectangle of the box. It may be resized dynamically by the Plot method.
395  wxPoint m_reference; // !< Holds the reference point for movements
396  wxBrush m_brush; // !< The brush to be used for the background
397  int m_winX, m_winY; // !< Holds the mpWindow size. Used to rescale position when window is resized.
398 
399  DECLARE_DYNAMIC_CLASS( mpInfoLayer )
400 };
401 
406 {
407 public:
409  mpInfoCoords();
413  mpInfoCoords( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
414 
416  ~mpInfoCoords();
417 
421  virtual void UpdateInfo( mpWindow& w, wxEvent& event ) override;
422 
427  virtual void Plot( wxDC& dc, mpWindow& w ) override;
428 
429 protected:
430  wxString m_content; // !< string holding the coordinates to be drawn.
431 };
432 
437 {
438 public:
440  mpInfoLegend();
441 
446  mpInfoLegend( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
447 
449  ~mpInfoLegend();
450 
454  virtual void UpdateInfo( mpWindow& w, wxEvent& event ) override;
455 
460  virtual void Plot( wxDC& dc, mpWindow& w ) override;
461 
462 protected:
463 };
464 
465 
466 // -----------------------------------------------------------------------------
467 // mpLayer implementations - functions
468 // -----------------------------------------------------------------------------
469 
474 #define mpALIGNMASK 0x03
475 
476 #define mpALIGN_RIGHT 0x00
477 
478 #define mpALIGN_CENTER 0x01
479 
480 #define mpALIGN_LEFT 0x02
481 
482 #define mpALIGN_TOP mpALIGN_RIGHT
483 
484 #define mpALIGN_BOTTOM mpALIGN_LEFT
485 
486 #define mpALIGN_BORDER_BOTTOM 0x04
487 
488 #define mpALIGN_BORDER_TOP 0x05
489 
490 #define mpX_NORMAL 0x00
491 
492 #define mpX_TIME 0x01
493 
494 #define mpX_HOURS 0x02
495 
496 #define mpX_DATE 0x03
497 
498 #define mpX_DATETIME 0x04
499 
500 #define mpALIGN_BORDER_LEFT mpALIGN_BORDER_BOTTOM
501 
502 #define mpALIGN_BORDER_RIGHT mpALIGN_BORDER_TOP
503 
504 #define mpALIGN_NE 0x00
505 
506 #define mpALIGN_NW 0x01
507 
508 #define mpALIGN_SW 0x02
509 
510 #define mpALIGN_SE 0x03
511 
523 {
524 public:
528  mpFX( const wxString& name = wxEmptyString, int flags = mpALIGN_RIGHT );
529 
535  virtual double GetY( double x ) = 0;
536 
541  virtual void Plot( wxDC& dc, mpWindow& w ) override;
542 
543 protected:
544  int m_flags; // !< Holds label alignment
545 
546  DECLARE_DYNAMIC_CLASS( mpFX )
547 };
548 
555 {
556 public:
560  mpFY( const wxString& name = wxEmptyString, int flags = mpALIGN_TOP );
561 
567  virtual double GetX( double y ) = 0;
568 
573  virtual void Plot( wxDC& dc, mpWindow& w ) override;
574 
575 protected:
576  int m_flags; // !< Holds label alignment
577 
578  DECLARE_DYNAMIC_CLASS( mpFY )
579 };
580 
589 {
590 public:
594  mpFXY( const wxString& name = wxEmptyString, int flags = mpALIGN_NE );
595 
599  virtual void Rewind() = 0;
600 
606  virtual bool GetNextXY( double& x, double& y ) = 0;
607 
608  virtual size_t GetCount() = 0;
609 
614  virtual void Plot( wxDC& dc, mpWindow& w ) override;
615 
616  virtual void SetScale( mpScaleBase* scaleX, mpScaleBase* scaleY );
617 
618  void UpdateScales();
619 
620  double s2x( double plotCoordX ) const;
621  double s2y( double plotCoordY ) const;
622 
623  double x2s( double x ) const;
624  double y2s( double y ) const;
625 
626 protected:
627  int m_flags; // !< Holds label alignment
628 
629  // Data to calculate label positioning
630  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
631  // int drawnPoints;
632  mpScaleBase* m_scaleX, * m_scaleY;
633 
638  void UpdateViewBoundary( wxCoord xnew, wxCoord ynew );
639 
640  DECLARE_DYNAMIC_CLASS( mpFXY )
641 };
642 
650 {
651 public:
655  mpProfile( const wxString& name = wxEmptyString, int flags = mpALIGN_TOP );
656 
662  virtual double GetY( double x ) = 0;
663 
668  virtual void Plot( wxDC& dc, mpWindow& w ) override;
669 
670 protected:
671  int m_flags; // !< Holds label alignment
672 
673  DECLARE_DYNAMIC_CLASS( mpProfile )
674 };
675 
678 // -----------------------------------------------------------------------------
679 // mpLayer implementations - furniture (scales, ...)
680 // -----------------------------------------------------------------------------
681 
693 {
694 public:
695  mpScaleBase();
696  virtual ~mpScaleBase() {};
697 
698  virtual bool IsHorizontal() = 0;
699 
700  bool HasBBox() override { return FALSE; }
701 
706  void SetAlign( int align ) { m_flags = align; };
707 
708  void SetNameAlign( int align ) { m_nameFlags = align; }
709 
713  void SetTicks( bool enable ) { m_ticks = enable; };
714 
718  bool GetTicks() { return m_ticks; };
719 
720 
721  // virtual double X2p( mpWindow &w, double x ) = 0;
722  // virtual double P2x( mpWindow &w, double x ) = 0;
723 
724  void SetDataRange( double minV, double maxV )
725  {
726  m_rangeSet = true;
727  m_minV = minV;
728  m_maxV = maxV;
729  }
730 
731  void GetDataRange( double& minV, double& maxV )
732  {
733  minV = m_minV;
734  maxV = m_maxV;
735  }
736 
737  void ExtendDataRange( double minV, double maxV )
738  {
739  if( !m_rangeSet )
740  {
741  m_minV = minV;
742  m_maxV = maxV;
743  m_rangeSet = true;
744  }
745  else
746  {
747  m_minV = std::min( minV, m_minV );
748  m_maxV = std::max( maxV, m_maxV );
749  }
750 
751  if( m_minV == m_maxV )
752  {
753  m_minV = m_minV - 1.0;
754  m_maxV = m_maxV + 1.0;
755  }
756  }
757 
759  {
760  m_rangeSet = 0;
761  }
762 
763  double AbsMaxValue() const
764  {
765  return std::max( std::abs( m_maxV ), std::abs( m_minV ) );
766  }
767 
768  double AbsVisibleMaxValue() const
769  {
770  return m_absVisibleMaxV;
771  }
772 
773  virtual double TransformToPlot( double x ) { return 0.0; };
774  virtual double TransformFromPlot( double xplot ) { return 0.0; };
775 
776  struct TickLabel
777  {
778  TickLabel( double pos_ = 0.0, const wxString& label_ = wxT("") ) :
779  pos( pos_ ), label( label_ ), pixelPos( 0 ), visible( true )
780  {}
781 
782  double pos;
783  wxString label;
784  int pixelPos;
785  bool visible;
786  };
787 
788  std::vector<TickLabel>& TickLabels() { return m_tickLabels; };
789 
790 protected:
791 
792  void updateTickLabels( wxDC& dc, mpWindow& w );
793  void computeLabelExtents( wxDC& dc, mpWindow& w );
794 
795  // virtual int getLabelDecimalDigits(int maxDigits);
796  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) {};
797  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) {};
798 
799  int tickCount() const
800  {
801  return m_tickValues.size();
802  }
803 
804  virtual int labelCount() const
805  {
806  return m_tickLabels.size();
807  }
808 
809  virtual const wxString formatLabel( double value, int nDigits ) { return wxT( "" ); }
810  virtual void formatLabels() {};
811 
812  virtual double getTickPos( int n )
813  {
814  return m_tickValues[n];
815  }
816 
817  virtual double getLabelPos( int n )
818  {
819  return m_tickLabels[n].pos;
820  }
821 
822  virtual const wxString getLabel( int n )
823  {
824  return m_tickLabels[n].label;
825  }
826 
827  std::vector<double> m_tickValues;
828  std::vector<TickLabel> m_tickLabels;
829 
830  double m_offset, m_scale;
832  int m_flags; // !< Flag for axis alignment
834  bool m_ticks; // !< Flag to toggle between ticks or grid
835  double m_minV, m_maxV;
839 };
840 
842 {
843 public:
850  mpScaleXBase( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER,
851  bool ticks = true, unsigned int type = mpX_NORMAL );
852  virtual ~mpScaleXBase() {};
853 
854  virtual bool IsHorizontal() override { return true; }
857  virtual void Plot( wxDC& dc, mpWindow& w ) override;
858 
859  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) override;
860 
861  // unsigned int m_labelType; //!< Select labels mode: mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds
862  // wxString m_labelFormat; //!< Format string used to print labels
863 
864  DECLARE_DYNAMIC_CLASS( mpScaleXBase )
865 };
866 
867 
869 {
870 public:
876  mpScaleX( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER,
877  bool ticks = true, unsigned int type = mpX_NORMAL );
878 
881  // virtual void Plot(wxDC & dc, mpWindow & w);
882 
883  // virtual double X2p( mpWindow &w, double x );
884  // virtual double P2x( mpWindow &w, double x );
885  virtual double TransformToPlot( double x ) override;
886  virtual double TransformFromPlot( double xplot ) override;
887 
888 protected:
889  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override;
890 
891 
892  DECLARE_DYNAMIC_CLASS( mpScaleX )
893 };
894 
895 
897 {
898 public:
905  mpScaleXLog( const wxString& name = wxT("log(X)"), int flags = mpALIGN_CENTER,
906  bool ticks = true, unsigned int type = mpX_NORMAL );
907 
908  virtual double TransformToPlot( double x ) override;
909  virtual double TransformFromPlot( double xplot ) override;
910 
914  // virtual double X2p( mpWindow &w, double x );
915  // virtual double P2x( mpWindow &w, double x );
916 
917 protected:
918  void recalculateTicks( wxDC& dc, mpWindow& w ) override;
919 
920  // int tickCount() const;
921  // int labelCount() const;
922  // const wxString getLabel( int n );
923  // double getTickPos( int n );
924  // double getLabelPos( int n );
925 
926  void computeLabelExtents( wxDC& dc, mpWindow& w );
927 
928 
929  DECLARE_DYNAMIC_CLASS( mpScaleXLog )
930 };
931 
932 
941 {
942 public:
947  mpScaleY( const wxString& name = wxT("Y"), int flags = mpALIGN_CENTER, bool ticks = true );
948 
949  virtual bool IsHorizontal() override { return false; }
950 
954  virtual void Plot( wxDC& dc, mpWindow& w ) override;
955 
960  virtual bool HasBBox() override { return FALSE; }
961 
964  void SetAlign( int align ) { m_flags = align; };
965 
968  void SetTicks( bool ticks ) { m_ticks = ticks; };
969 
972  bool GetTicks() { return m_ticks; };
973 
974  virtual double TransformToPlot( double x ) override;
975  virtual double TransformFromPlot( double xplot ) override;
976 
977 
978  void SetMasterScale( mpScaleY* masterScale )
979  {
980  m_masterScale = masterScale;
981  }
982 
983 protected:
984  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) override;
985  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override;
986 
987  // virtual int tickCount() const;
988  // virtual int labelCount() const;
989  // virtual const wxString getLabel( int n );
990  // virtual double getTickPos( int n );
991  // virtual double getLabelPos( int n );
992  void computeLabelExtents( wxDC& dc, mpWindow& w );
993  void computeSlaveTicks( mpWindow& w );
994 
996 
997  // double m_minV, m_maxV;
998 
999  int m_flags; // !< Flag for axis alignment
1000  bool m_ticks; // !< Flag to toggle between ticks or grid
1001  // wxString m_labelFormat; //!< Format string used to print labels
1002 
1003  DECLARE_DYNAMIC_CLASS( mpScaleY )
1004 };
1005 
1006 // -----------------------------------------------------------------------------
1007 // mpWindow
1008 // -----------------------------------------------------------------------------
1009 
1014 #define mpMOUSEMODE_DRAG 0
1015 
1016 #define mpMOUSEMODE_ZOOMBOX 1
1017 
1020 // WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, wxLayerList );
1021 typedef std::deque<mpLayer*> wxLayerList;
1022 
1045 class WXDLLIMPEXP_MATHPLOT mpWindow : public wxWindow
1046 {
1047 public:
1049  mpWindow( wxWindow* parent, wxWindowID id,
1050  const wxPoint& pos = wxDefaultPosition,
1051  const wxSize& size = wxDefaultSize,
1052  long flags = 0 );
1053  ~mpWindow();
1054 
1058  wxMenu* GetPopupMenu() { return &m_popmenu; }
1059 
1067  bool AddLayer( mpLayer* layer, bool refreshDisplay = true );
1068 
1077  bool DelLayer( mpLayer* layer, bool alsoDeleteObject = false, bool refreshDisplay = true );
1078 
1083  void DelAllLayers( bool alsoDeleteObject, bool refreshDisplay = true );
1084 
1085 
1091  mpLayer* GetLayer( int position );
1092 
1097  mpLayer* GetLayerByName( const wxString& name );
1098 
1103  double GetXscl() { return m_scaleX; }
1104  double GetScaleX( void ) const { return m_scaleX; }; // Schaling's method: maybe another method esists with the same name
1105 
1110  double GetYscl() const { return m_scaleY; }
1111  double GetScaleY( void ) const { return m_scaleY; } // Schaling's method: maybe another method exists with the same name
1112 
1117  double GetXpos() const { return m_posX; }
1118  double GetPosX( void ) const { return m_posX; }
1119 
1124  double GetYpos() const { return m_posY; }
1125  double GetPosY( void ) const { return m_posY; }
1126 
1133  int GetScrX( void ) const { return m_scrX; }
1134  int GetXScreen( void ) const { return m_scrX; }
1135 
1142  int GetScrY( void ) const { return m_scrY; }
1143  int GetYScreen( void ) const { return m_scrY; }
1144 
1148  void SetScaleX( double scaleX );
1149 
1153  void SetScaleY( double scaleY )
1154  {
1155  if( scaleY!=0 )
1156  m_scaleY = scaleY;
1157 
1158  UpdateAll();
1159  }
1160 
1164  void SetPosX( double posX ) { m_posX = posX; UpdateAll(); }
1165 
1169  void SetPosY( double posY ) { m_posY = posY; UpdateAll(); }
1170 
1175  void SetPos( double posX, double posY ) { m_posX = posX; m_posY = posY; UpdateAll(); }
1176 
1182  void SetScr( int scrX, int scrY ) { m_scrX = scrX; m_scrY = scrY; }
1183 
1186  // double p2x(wxCoord pixelCoordX, bool drawOutside = true ); // { return m_posX + pixelCoordX/m_scaleX; }
1187  inline double p2x( wxCoord pixelCoordX ) { return m_posX + pixelCoordX / m_scaleX; }
1188 
1191  // double p2y(wxCoord pixelCoordY, bool drawOutside = true ); //{ return m_posY - pixelCoordY/m_scaleY; }
1192  inline double p2y( wxCoord pixelCoordY ) { return m_posY - pixelCoordY / m_scaleY; }
1193 
1196  // wxCoord x2p(double x, bool drawOutside = true); // { return (wxCoord) ( (x-m_posX) * m_scaleX); }
1197  inline wxCoord x2p( double x ) { return (wxCoord) ( (x - m_posX) * m_scaleX ); }
1198 
1201  // wxCoord y2p(double y, bool drawOutside = true); // { return (wxCoord) ( (m_posY-y) * m_scaleY); }
1202  inline wxCoord y2p( double y ) { return (wxCoord) ( (m_posY - y) * m_scaleY ); }
1203 
1204 
1207  void EnableDoubleBuffer( bool enabled ) { m_enableDoubleBuffer = enabled; }
1208 
1211  void EnableMousePanZoom( bool enabled ) { m_enableMouseNavigation = enabled; }
1212 
1215  void EnableMouseWheelPan( bool enabled ) { m_enableMouseWheelPan = enabled; }
1216 
1222  void LockAspect( bool enable = TRUE );
1223 
1228  inline bool IsAspectLocked() { return m_lockaspect; }
1229 
1234  void Fit() override;
1235 
1242  void Fit( double xMin, double xMax, double yMin, double yMax,
1243  wxCoord* printSizeX = NULL, wxCoord* printSizeY = NULL );
1244 
1249  void ZoomIn( const wxPoint& centerPoint = wxDefaultPosition );
1250  void ZoomIn( const wxPoint& centerPoint, double zoomFactor );
1251 
1256  void ZoomOut( const wxPoint& centerPoint = wxDefaultPosition );
1257  void ZoomOut( const wxPoint& centerPoint, double zoomFactor );
1258 
1260  void ZoomInX();
1261 
1263  void ZoomOutX();
1264 
1266  void ZoomInY();
1267 
1269  void ZoomOutY();
1270 
1273  void ZoomRect( wxPoint p0, wxPoint p1 );
1274 
1276  void UpdateAll();
1277 
1278  // Added methods by Davide Rondini
1279 
1284  unsigned int CountLayers();
1285 
1288  unsigned int CountAllLayers() { return m_layers.size(); };
1289 
1290 #if 0
1291 
1294  void PrintGraph(mpPrintout *print);
1295 #endif
1296 
1301  double GetDesiredXmin() { return m_desiredXmin; }
1302 
1307  double GetDesiredXmax() { return m_desiredXmax; }
1308 
1313  double GetDesiredYmin() { return m_desiredYmin; }
1314 
1319  double GetDesiredYmax() { return m_desiredYmax; }
1320 
1324  void GetBoundingBox( double* bbox );
1325 
1328  void SetMPScrollbars( bool status );
1329 
1332  bool GetMPScrollbars() { return m_enableScrollBars; };
1333 
1339  bool SaveScreenshot( const wxString& filename, wxBitmapType type = wxBITMAP_TYPE_BMP,
1340  wxSize imageSize = wxDefaultSize, bool fit = false );
1341 
1346  static double zoomIncrementalFactor;
1347 
1354  void SetMargins( int top, int right, int bottom, int left );
1355 
1357  void SetMarginTop( int top ) { m_marginTop = top; };
1359  void SetMarginRight( int right ) { m_marginRight = right; };
1361  void SetMarginBottom( int bottom ) { m_marginBottom = bottom; };
1363  void SetMarginLeft( int left ) { m_marginLeft = left; };
1364 
1366  int GetMarginTop() { return m_marginTop; };
1368  int GetMarginRight() { return m_marginRight; };
1370  int GetMarginBottom() { return m_marginBottom; };
1372  int GetMarginLeft() { return m_marginLeft; };
1373 
1374 #if 0
1375 
1378  // void EnableCoordTooltip(bool value = true);
1379 
1383  // bool GetCoordTooltip() { return m_coordTooltip; };
1384 #endif
1385 
1389  mpInfoLayer* IsInsideInfoLayer( wxPoint& point );
1390 
1394  void SetLayerVisible( const wxString& name, bool viewable );
1395 
1399  bool IsLayerVisible( const wxString& name );
1400 
1404  void SetLayerVisible( const unsigned int position, bool viewable );
1405 
1409  bool IsLayerVisible( const unsigned int position );
1410 
1415  void SetColourTheme( const wxColour& bgColour,
1416  const wxColour& drawColour,
1417  const wxColour& axesColour );
1418 
1421  const wxColour& GetAxesColour() { return m_axColour; };
1422 
1424  void LimitView( bool aEnable )
1425  {
1426  m_enableLimitedView = aEnable;
1427  }
1428 
1429 protected:
1430  void OnPaint( wxPaintEvent& event ); // !< Paint handler, will plot all attached layers
1431  void OnSize( wxSizeEvent& event ); // !< Size handler, will update scroll bar sizes
1432 
1433  // void OnScroll2 (wxScrollWinEvent &event); //!< Scroll handler, will move canvas
1434  void OnShowPopupMenu( wxMouseEvent& event ); // !< Mouse handler, will show context menu
1435  void OnMouseMiddleDown( wxMouseEvent& event ); // !< Mouse handler, for detecting when the user
1436 
1437  // !< drags with the middle button or just "clicks" for the menu
1438  void OnCenter( wxCommandEvent& event ); // !< Context menu handler
1439  void OnFit( wxCommandEvent& event ); // !< Context menu handler
1440  void OnZoomIn( wxCommandEvent& event ); // !< Context menu handler
1441  void OnZoomOut( wxCommandEvent& event ); // !< Context menu handler
1442  void OnLockAspect( wxCommandEvent& event ); // !< Context menu handler
1443  void OnMouseWheel( wxMouseEvent& event ); // !< Mouse handler for the wheel
1444  void OnMagnify( wxMouseEvent& event ); // !< Pinch zoom handler
1445  void OnMouseMove( wxMouseEvent& event ); // !< Mouse handler for mouse motion (for pan)
1446  void OnMouseLeftDown( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1447  void OnMouseLeftRelease( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1448  void OnScrollThumbTrack( wxScrollWinEvent& event ); // !< Scroll thumb on scroll bar moving
1449  void OnScrollPageUp( wxScrollWinEvent& event ); // !< Scroll page up
1450  void OnScrollPageDown( wxScrollWinEvent& event ); // !< Scroll page down
1451  void OnScrollLineUp( wxScrollWinEvent& event ); // !< Scroll line up
1452  void OnScrollLineDown( wxScrollWinEvent& event ); // !< Scroll line down
1453  void OnScrollTop( wxScrollWinEvent& event ); // !< Scroll to top
1454  void OnScrollBottom( wxScrollWinEvent& event ); // !< Scroll to bottom
1455 
1456  void DoScrollCalc( const int position, const int orientation );
1457 
1458  void DoZoomInXCalc( const int staticXpixel );
1459  void DoZoomInYCalc( const int staticYpixel );
1460  void DoZoomOutXCalc( const int staticXpixel );
1461  void DoZoomOutYCalc( const int staticYpixel );
1462 
1463  bool CheckXLimits( double& desiredMax, double& desiredMin ) const
1464  {
1465  return !( m_enableLimitedView
1466  && (desiredMax > m_maxX - m_marginRight / m_scaleX
1467  || desiredMin < m_minX - m_marginLeft / m_scaleX) );
1468  }
1469 
1470  bool CheckYLimits( double& desiredMax, double& desiredMin ) const
1471  {
1472  return !( m_enableLimitedView
1473  && (desiredMax > m_maxY + m_marginBottom / m_scaleY
1474  || desiredMin < m_minY + m_marginTop / m_scaleY) );
1475  }
1476 
1477  void AdjustLimitedView();
1478 
1482  virtual bool UpdateBBox();
1483 
1487  virtual bool SetXView( double pos, double desiredMax, double desiredMin );
1488 
1492  virtual bool SetYView( double pos, double desiredMax, double desiredMin );
1493 
1494  // wxList m_layers; //!< List of attached plot layers
1495  wxLayerList m_layers; // !< List of attached plot layers
1496  wxMenu m_popmenu; // !< Canvas' context menu
1497  bool m_lockaspect; // !< Scale aspect is locked or not
1498  // bool m_coordTooltip; //!< Selects whether to show coordinate tooltip
1499  wxColour m_bgColour; // !< Background Colour
1500  wxColour m_fgColour; // !< Foreground Colour
1501  wxColour m_axColour; // !< Axes Colour
1502 
1503  double m_minX; // !< Global layer bounding box, left border incl.
1504  double m_maxX; // !< Global layer bounding box, right border incl.
1505  double m_minY; // !< Global layer bounding box, bottom border incl.
1506  double m_maxY; // !< Global layer bounding box, top border incl.
1507  double m_scaleX; // !< Current view's X scale
1508  double m_scaleY; // !< Current view's Y scale
1509  double m_posX; // !< Current view's X position
1510  double m_posY; // !< Current view's Y position
1511  int m_scrX; // !< Current view's X dimension
1512  int m_scrY; // !< Current view's Y dimension
1513  int m_clickedX; // !< Last mouse click X position, for centering and zooming the view
1514  int m_clickedY; // !< Last mouse click Y position, for centering and zooming the view
1515 
1519  double m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax;
1520 
1521  int m_marginTop, m_marginRight, m_marginBottom, m_marginLeft;
1522 
1523  int m_last_lx, m_last_ly; // !< For double buffering
1524  wxMemoryDC m_buff_dc; // !< For double buffering
1525  wxBitmap* m_buff_bmp; // !< For double buffering
1526  bool m_enableDoubleBuffer; // !< For double buffering
1527  bool m_enableMouseNavigation; // !< For pan/zoom with the mouse.
1528  bool m_enableMouseWheelPan; // !< Trackpad pan/zoom
1530  wxPoint m_mouseMClick; // !< For the middle button "drag" feature
1531  wxPoint m_mouseLClick; // !< Starting coords for rectangular zoom selection
1534  mpInfoLayer* m_movingInfoLayer; // !< For moving info layers over the window area
1536  wxRect m_zoomRect;
1537  DECLARE_DYNAMIC_CLASS( mpWindow )
1538  DECLARE_EVENT_TABLE()
1539 };
1540 
1541 // -----------------------------------------------------------------------------
1542 // mpFXYVector - provided by Jose Luis Blanco
1543 // -----------------------------------------------------------------------------
1544 
1565 {
1566 public:
1570  mpFXYVector( const wxString& name = wxEmptyString, int flags = mpALIGN_NE );
1571 
1572  virtual ~mpFXYVector() {}
1573 
1578  virtual void SetData( const std::vector<double>& xs, const std::vector<double>& ys );
1579 
1583  void Clear();
1584 
1585 protected:
1588  std::vector<double> m_xs, m_ys;
1589 
1592  size_t m_index;
1593 
1596  double m_minX, m_maxX, m_minY, m_maxY;
1597 
1601  void Rewind() override;
1602 
1608  bool GetNextXY( double& x, double& y ) override;
1609 
1610  size_t GetCount() override;
1611 
1612 public:
1615  double GetMinX() override { return m_minX; }
1616 
1619  double GetMinY() override { return m_minY; }
1620 
1623  double GetMaxX() override { return m_maxX; }
1624 
1627  double GetMaxY() override { return m_maxY; }
1628 
1629 protected:
1630 
1631  DECLARE_DYNAMIC_CLASS( mpFXYVector )
1632 };
1633 
1634 
1635 #if 0
1636 
1637 class WXDLLIMPEXP_MATHPLOT mpFSemiLogXVector : public mpFXYVector
1638 {
1639 public:
1643  mpFSemiLogXVector( wxString name = wxEmptyString, int flags = mpALIGN_NE );
1644 
1645  virtual ~mpFSemiLogXVector() {}
1646 
1652  DECLARE_DYNAMIC_CLASS( mpFSemiLogXVector )
1653 };
1654 #endif
1655 
1656 // -----------------------------------------------------------------------------
1657 // mpText - provided by Val Greene
1658 // -----------------------------------------------------------------------------
1659 
1667 {
1668 public:
1672  mpText( const wxString& name = wxT("Title"), int offsetx = 5, int offsety = 50 );
1673 
1676  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1677 
1679  virtual bool HasBBox() override { return FALSE; }
1680 
1681 protected:
1682  int m_offsetx; // !< Holds offset for X in percentage
1683  int m_offsety; // !< Holds offset for Y in percentage
1684 
1685  DECLARE_DYNAMIC_CLASS( mpText )
1686 };
1687 
1688 
1689 // -----------------------------------------------------------------------------
1690 // mpPrintout - provided by Davide Rondini
1691 // -----------------------------------------------------------------------------
1692 
1697 class WXDLLIMPEXP_MATHPLOT mpPrintout : public wxPrintout
1698 {
1699 public:
1700  mpPrintout( mpWindow* drawWindow, const wxChar* title = _T("wxMathPlot print output") );
1701  virtual ~mpPrintout() {};
1702 
1703  void SetDrawState( bool drawState ) { drawn = drawState; };
1704  bool OnPrintPage( int page ) override;
1705  bool HasPage( int page ) override;
1706 
1707 private:
1708  bool drawn;
1710 };
1711 
1712 
1713 // -----------------------------------------------------------------------------
1714 // mpMovableObject - provided by Jose Luis Blanco
1715 // -----------------------------------------------------------------------------
1723 {
1724 public:
1728  m_reference_x( 0 ),
1729  m_reference_y( 0 ),
1730  m_reference_phi( 0 ),
1731  m_shape_xs( 0 ),
1732  m_shape_ys( 0 )
1733  {
1734  m_type = mpLAYER_PLOT;
1735  }
1736 
1737  virtual ~mpMovableObject() {};
1738 
1741  void GetCoordinateBase( double& x, double& y, double& phi ) const
1742  {
1743  x = m_reference_x;
1744  y = m_reference_y;
1745  phi = m_reference_phi;
1746  }
1747 
1750  void SetCoordinateBase( double x, double y, double phi = 0 )
1751  {
1752  m_reference_x = x;
1753  m_reference_y = y;
1754  m_reference_phi = phi;
1755  m_flags = mpALIGN_NE;
1756  ShapeUpdated();
1757  }
1758 
1759  virtual bool HasBBox() override { return m_trans_shape_xs.size()!=0; }
1760 
1763  virtual double GetMinX() override { return m_bbox_min_x; }
1764 
1767  virtual double GetMaxX() override { return m_bbox_max_x; }
1768 
1771  virtual double GetMinY() override { return m_bbox_min_y; }
1772 
1775  virtual double GetMaxY() override { return m_bbox_max_y; }
1776 
1777  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1778 
1782  void SetAlign( int align ) { m_flags = align; };
1783 
1784 protected:
1785  int m_flags; // !< Holds label alignment
1786 
1789  double m_reference_x, m_reference_y, m_reference_phi;
1790 
1794  void TranslatePoint( double x, double y, double& out_x, double& out_y );
1795 
1799  std::vector<double> m_shape_xs, m_shape_ys;
1800 
1804  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
1805 
1809  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
1810 
1815  void ShapeUpdated();
1816 };
1817 
1818 // -----------------------------------------------------------------------------
1819 // mpCovarianceEllipse - provided by Jose Luis Blanco
1820 // -----------------------------------------------------------------------------
1833 {
1834 public:
1839  mpCovarianceEllipse( double cov_00 = 1,
1840  double cov_11 = 1,
1841  double cov_01 = 0,
1842  double quantiles = 2,
1843  int segments = 32,
1844  const wxString& layerName = wxT("") ) :
1845  m_cov_00( cov_00 ),
1846  m_cov_11( cov_11 ),
1847  m_cov_01( cov_01 ),
1848  m_quantiles( quantiles ),
1849  m_segments( segments )
1850  {
1851  m_continuous = true;
1852  m_name = layerName;
1853  RecalculateShape();
1854  m_type = mpLAYER_PLOT;
1855  }
1856 
1858 
1859  double GetQuantiles() const { return m_quantiles; }
1860 
1863  void SetQuantiles( double q )
1864  {
1865  m_quantiles = q;
1866  RecalculateShape();
1867  }
1868 
1869  void SetSegments( int segments ) { m_segments = segments; }
1870  int GetSegments() const { return m_segments; }
1871 
1874  void GetCovarianceMatrix( double& cov_00, double& cov_01, double& cov_11 ) const
1875  {
1876  cov_00 = m_cov_00;
1877  cov_01 = m_cov_01;
1878  cov_11 = m_cov_11;
1879  }
1880 
1883  void SetCovarianceMatrix( double cov_00, double cov_01, double cov_11 )
1884  {
1885  m_cov_00 = cov_00;
1886  m_cov_01 = cov_01;
1887  m_cov_11 = cov_11;
1888  RecalculateShape();
1889  }
1890 
1891 protected:
1894  double m_cov_00, m_cov_11, m_cov_01;
1895  double m_quantiles;
1896 
1900 
1903  void RecalculateShape();
1904 };
1905 
1906 // -----------------------------------------------------------------------------
1907 // mpPolygon - provided by Jose Luis Blanco
1908 // -----------------------------------------------------------------------------
1914 {
1915 public:
1918  mpPolygon( const wxString& layerName = wxT("") )
1919  {
1920  m_continuous = true;
1921  m_name = layerName;
1922  }
1923 
1924  virtual ~mpPolygon() {}
1925 
1931  void setPoints( const std::vector<double>& points_xs,
1932  const std::vector<double>& points_ys,
1933  bool closedShape = true );
1934 };
1935 
1936 // -----------------------------------------------------------------------------
1937 // mpMovableObject - provided by Jose Luis Blanco
1938 // -----------------------------------------------------------------------------
1946 {
1947 public:
1951  {
1952  m_min_x = m_max_x =
1953  m_min_y = m_max_y = 0;
1954  m_validImg = false;
1955  m_type = mpLAYER_BITMAP;
1956  }
1957 
1958  virtual ~mpBitmapLayer() {};
1959 
1962  void GetBitmapCopy( wxImage& outBmp ) const;
1963 
1971  void SetBitmap( const wxImage& inBmp, double x, double y, double lx, double ly );
1972 
1973  virtual bool HasBBox() override { return true; }
1974 
1977  virtual double GetMinX() override { return m_min_x; }
1978 
1981  virtual double GetMaxX() override { return m_max_x; }
1982 
1985  virtual double GetMinY() override { return m_min_y; }
1986 
1989  virtual double GetMaxY() override { return m_max_y; }
1990 
1991  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1992 
1996  void SetAlign( int align ) { m_flags = align; };
1997 
1998 protected:
1999  int m_flags; // !< Holds label alignment
2000 
2003  wxImage m_bitmap;
2004  wxBitmap m_scaledBitmap;
2005  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
2006 
2008 
2011  double m_min_x, m_max_x, m_min_y, m_max_y;
2012 };
2013 
2016 #endif // _MP_MATHPLOT_H_
int m_offsetx
Definition: mathplot.h:1682
bool GetMPScrollbars()
Get scrollbars status.
Definition: mathplot.h:1332
virtual double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:1977
mpLayerType GetLayerType()
Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc,...
Definition: mathplot.h:293
void ShowName(bool show)
Shows or hides the text label with the name of the layer (default is visible).
Definition: mathplot.h:261
class WXDLLIMPEXP_MATHPLOT mpWindow
Definition: mathplot.h:107
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:1058
virtual void recalculateTicks(wxDC &dc, mpWindow &w)
Definition: mathplot.h:797
wxMemoryDC m_buff_dc
Definition: mathplot.h:1524
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:1361
virtual ~mpScaleXBase()
Definition: mathplot.h:852
virtual double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1771
virtual bool IsInfo()
Check whether the layer is an info box.
Definition: mathplot.h:169
bool drawn
Definition: mathplot.h:1708
bool m_continuous
Definition: mathplot.h:317
bool m_enableScrollBars
Definition: mathplot.h:1532
virtual ~mpFXYVector()
Definition: mathplot.h:1572
mpWindow * plotWindow
Definition: mathplot.h:1709
wxBitmap m_scaledBitmap
Definition: mathplot.h:2004
void GetDataRange(double &minV, double &maxV)
Definition: mathplot.h:731
bool m_zooming
Definition: mathplot.h:1535
wxString m_content
Definition: mathplot.h:430
void SetNameAlign(int align)
Definition: mathplot.h:708
virtual ~mpMovableObject()
Definition: mathplot.h:1737
__mp_Layer_Type
Definition: mathplot.h:125
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:237
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:1363
void EnableMouseWheelPan(bool enabled)
Enable/disable trackpad friendly panning (2-axis scroll wheel)
Definition: mathplot.h:1215
double GetPosY(void) const
Definition: mathplot.h:1125
wxBrush m_brush
Definition: mathplot.h:315
int m_clickedX
Definition: mathplot.h:1513
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:1883
bool IsAspectLocked()
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:1228
class WXDLLIMPEXP_MATHPLOT mpFXYVector
Definition: mathplot.h:104
mpWindow()
Definition: mathplot.h:1048
double GetScaleX(void) const
Definition: mathplot.h:1104
TickLabel(double pos_=0.0, const wxString &label_=wxT(""))
Definition: mathplot.h:778
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1187
bool m_ticks
Definition: mathplot.h:834
virtual ~mpLayer()
Definition: mathplot.h:151
std::vector< double > m_trans_shape_ys
Definition: mathplot.h:1804
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:1945
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:242
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:522
double m_scaleY
Definition: mathplot.h:1508
std::vector< TickLabel > & TickLabels()
Definition: mathplot.h:788
int GetXScreen(void) const
Definition: mathplot.h:1134
bool m_enableMouseNavigation
Definition: mathplot.h:1527
double GetScaleY(void) const
Definition: mathplot.h:1111
int m_maxLabelHeight
Definition: mathplot.h:837
int GetMarginBottom()
Definition: mathplot.h:1370
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:1899
int m_flags
Definition: mathplot.h:832
double m_min_y
Definition: mathplot.h:2011
void SetName(wxString name)
Set layer name.
Definition: mathplot.h:266
void SetDataRange(double minV, double maxV)
Definition: mathplot.h:724
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:828
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:649
double m_posX
Definition: mathplot.h:1509
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:978
const wxColour & GetAxesColour()
Get axes draw colour.
Definition: mathplot.h:1421
double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1615
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above).
Definition: mathplot.h:1863
bool m_enableMouseWheelPan
Definition: mathplot.h:1528
int m_maxLabelWidth
Definition: mathplot.h:838
wxColour m_axColour
Definition: mathplot.h:1501
virtual ~mpBitmapLayer()
Definition: mathplot.h:1958
wxPoint m_mouseMClick
Definition: mathplot.h:1530
double m_minY
Definition: mathplot.h:1505
int m_flags
Definition: mathplot.h:576
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:476
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1192
void SetContinuity(bool continuity)
Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points...
Definition: mathplot.h:252
A class providing graphs functionality for a 2D plot (either continuous or a set of points),...
Definition: mathplot.h:1564
virtual void Plot(wxDC &dc, mpWindow &w) override
Plot method.
Definition: mathplot.cpp:155
virtual double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:1981
virtual size_t GetCount()=0
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1782
wxPoint m_scroll
Definition: mathplot.h:1533
double AbsVisibleMaxValue() const
Definition: mathplot.h:768
virtual ~mpPolygon()
Definition: mathplot.h:1924
void SetScaleY(double scaleY)
Set current view's Y scale and refresh display.
Definition: mathplot.h:1153
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:960
std::vector< double > m_ys
Definition: mathplot.h:1588
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1592
int tickCount() const
Definition: mathplot.h:799
double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1623
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:1357
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:276
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:305
double GetPosX(void) const
Definition: mathplot.h:1118
double m_scaleX
Definition: mathplot.h:1507
wxLayerList m_layers
Definition: mathplot.h:1495
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
Definition: mathplot.h:1207
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:1913
double GetQuantiles() const
Definition: mathplot.h:1859
double GetXscl()
Get current view's X scale.
Definition: mathplot.h:1103
std::deque< mpLayer * > wxLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:1021
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,...
Definition: mathplot.h:588
bool m_visible
Definition: mathplot.h:321
void ExtendDataRange(double minV, double maxV)
Definition: mathplot.h:737
mpScaleBase * m_scaleY
Definition: mathplot.h:632
bool GetTicks()
Get Y axis ticks or grid.
Definition: mathplot.h:972
mpCovarianceEllipse(double cov_00=1, double cov_11=1, double cov_01=0, double quantiles=2, int segments=32, const wxString &layerName=wxT(""))
Default constructor.
Definition: mathplot.h:1839
virtual ~mpScaleBase()
Definition: mathplot.h:696
int GetSegments() const
Definition: mathplot.h:1870
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:1874
virtual ~mpCovarianceEllipse()
Definition: mathplot.h:1857
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:405
double GetDesiredXmax()
Returns the right-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:1307
wxPoint m_mouseLClick
Definition: mathplot.h:1531
virtual ~mpPrintout()
Definition: mathplot.h:1701
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1202
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1759
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:179
#define mpX_NORMAL
Set label for X axis in normal mode.
Definition: mathplot.h:490
void SetPosX(double posX)
Set current view's X position and refresh display.
Definition: mathplot.h:1164
void ResetDataRange()
Definition: mathplot.h:758
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:1741
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:1950
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:1359
int m_winY
Definition: mathplot.h:397
double m_minY
Definition: mathplot.h:1596
void computeLabelExtents(wxDC &dc, mpWindow &w)
Definition: mathplot.cpp:935
void SetPosY(double posY)
Set current view's Y position and refresh display.
Definition: mathplot.h:1169
#define WXDLLIMPEXP_MATHPLOT
wxMathPlot is a framework for mathematical graph plotting in wxWindows.
Definition: mathplot.h:61
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:1722
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:692
double GetYscl() const
Get current view's Y scale.
Definition: mathplot.h:1110
#define NULL
void SetFont(wxFont &font)
Set layer font.
Definition: mathplot.h:271
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301
double m_absVisibleMaxV
Definition: mathplot.h:831
int GetMarginTop()
Definition: mathplot.h:1366
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:297
virtual double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:1775
virtual void UpdateInfo(mpWindow &w, wxEvent &event)
Updates the content of the info box.
Definition: mathplot.cpp:130
void SetBrush(wxBrush brush)
Set layer brush.
Definition: mathplot.h:309
wxBrush m_brush
Definition: mathplot.h:396
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:334
wxRect m_zoomRect
Definition: mathplot.h:1536
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1133
bool m_lockaspect
Definition: mathplot.h:1497
double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1627
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:700
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:940
wxCoord minDrawY
Definition: mathplot.h:630
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:189
double m_reference_y
Definition: mathplot.h:1789
int m_flags
Definition: mathplot.h:999
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:106
class WXDLLIMPEXP_MATHPLOT mpLayer
Definition: mathplot.h:100
virtual double getLabelPos(int n)
Definition: mathplot.h:817
#define mpALIGN_TOP
Aligns label to the top.
Definition: mathplot.h:482
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1470
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:1697
bool m_ticks
Definition: mathplot.h:1000
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:713
bool m_rangeSet
Definition: mathplot.h:836
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1534
#define mpALIGN_NE
Aligns label to north-east.
Definition: mathplot.h:504
int m_flags
Definition: mathplot.h:627
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1996
double GetXpos() const
Get current view's X position.
Definition: mathplot.h:1117
void EnableMousePanZoom(bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:1211
wxColour m_fgColour
Definition: mathplot.h:1500
double m_minV
Definition: mathplot.h:835
int m_last_ly
Definition: mathplot.h:1523
bool GetTicks()
Get X axis ticks or grid.
Definition: mathplot.h:718
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:1288
virtual bool HasBBox() override
mpInfoLayer has not bounding box.
Definition: mathplot.h:356
virtual void getVisibleDataRange(mpWindow &w, double &minV, double &maxV)
Definition: mathplot.h:796
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:280
bool GetContinuity() const
Gets the 'continuity' property of the layer.
Definition: mathplot.h:257
virtual bool HasBBox() override
mpText should not be used for scaling decisions.
Definition: mathplot.h:1679
bool m_drawOutsideMargins
Definition: mathplot.h:319
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1973
int GetMarginRight()
Definition: mathplot.h:1368
wxPoint m_reference
Definition: mathplot.h:395
int GetMarginLeft()
Definition: mathplot.h:1372
void SetAlign(int align)
Set Y axis alignment.
Definition: mathplot.h:964
bool m_validImg
Definition: mathplot.h:2007
virtual const wxString getLabel(int n)
Definition: mathplot.h:822
double m_posY
Definition: mathplot.h:1510
bool GetDrawOutsideMargins()
Get Draw mode: inside or outside margins.
Definition: mathplot.h:284
int m_marginTop
Definition: mathplot.h:1521
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:174
virtual bool GetNextXY(double &x, double &y)=0
Get locus value for next N.
double m_scale
Definition: mathplot.h:830
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:184
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:2003
int m_flags
Definition: mathplot.h:544
void SetAlign(int align)
Set X axis alignment.
Definition: mathplot.h:706
bool m_showName
Definition: mathplot.h:318
virtual double TransformToPlot(double x)
Definition: mathplot.h:773
double m_minX
Definition: mathplot.h:1503
double m_desiredYmin
Definition: mathplot.h:1519
enum __mp_Layer_Type mpLayerType
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1197
class WXDLLIMPEXP_MATHPLOT mpFXY
Definition: mathplot.h:103
virtual void formatLabels()
Definition: mathplot.h:810
const char * name
Definition: DXF_plotter.cpp:60
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:1832
class WXDLLIMPEXP_MATHPLOT mpPrintout
Definition: mathplot.h:109
double GetDesiredYmin()
Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not ex...
Definition: mathplot.h:1313
void SetDrawState(bool drawState)
Definition: mathplot.h:1703
wxCoord m_scaledBitmap_offset_y
Definition: mathplot.h:2005
wxPen m_pen
Definition: mathplot.h:314
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:1750
virtual bool IsInfo() override
Specifies that this is an Info box layer.
Definition: mathplot.h:367
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
Definition: mathplot.h:1182
mpMovableObject()
Default constructor (sets location and rotation to (0,0,0))
Definition: mathplot.h:1727
class WXDLLIMPEXP_MATHPLOT mpFX
Definition: mathplot.h:101
virtual bool IsHorizontal() override
Definition: mathplot.h:949
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
Definition: mathplot.h:1175
virtual void Plot(wxDC &dc, mpWindow &w)=0
Plot given view of layer to the given device context.
std::vector< double > m_shape_ys
Definition: mathplot.h:1799
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1424
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:160
int m_clickedY
Definition: mathplot.h:1514
Plot layer implementing a text string.
Definition: mathplot.h:1666
int m_flags
Definition: mathplot.h:671
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:1045
virtual double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1985
virtual void Rewind()=0
Rewind value enumeration with mpFXY::GetNextXY.
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:968
double GetDesiredXmin()
Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:1301
mpLayerType m_type
Definition: mathplot.h:320
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
virtual const wxString formatLabel(double value, int nDigits)
Definition: mathplot.h:809
virtual bool IsHorizontal() override
Definition: mathplot.h:854
#define mpALIGN_CENTER
Aligns label to the center.
Definition: mathplot.h:478
double GetMinY() override
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1619
wxString m_name
Definition: mathplot.h:316
mpPolygon(const wxString &layerName=wxT(""))
Default constructor.
Definition: mathplot.h:1918
int m_scrY
Definition: mathplot.h:1512
virtual double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:1763
bool m_enableLimitedView
Definition: mathplot.h:1529
wxMenu m_popmenu
Definition: mathplot.h:1496
double m_maxX
Definition: mathplot.h:1504
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1463
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:436
wxColour m_bgColour
Definition: mathplot.h:1499
int m_nameFlags
Definition: mathplot.h:833
virtual int labelCount() const
Definition: mathplot.h:804
bool m_enableDoubleBuffer
Definition: mathplot.h:1526
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1346
double AbsMaxValue() const
Definition: mathplot.h:763
mpScaleY * m_masterScale
Definition: mathplot.h:995
std::vector< double > m_tickValues
Definition: mathplot.h:827
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:247
int m_scrX
Definition: mathplot.h:1511
class WXDLLIMPEXP_MATHPLOT mpScaleX
Definition: mathplot.h:105
class WXDLLIMPEXP_MATHPLOT mpFY
Definition: mathplot.h:102
class WXDLLIMPEXP_MATHPLOT mpText
Definition: mathplot.h:108
virtual double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:1767
wxBitmap * m_buff_bmp
Definition: mathplot.h:1525
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:554
void SetSegments(int segments)
Definition: mathplot.h:1869
double GetDesiredYmax()
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
Definition: mathplot.h:1319
virtual double getTickPos(int n)
Definition: mathplot.h:812
int GetYScreen(void) const
Definition: mathplot.h:1143
double GetYpos() const
Get current view's Y position.
Definition: mathplot.h:1124
double m_maxY
Definition: mathplot.h:1506
virtual double TransformFromPlot(double xplot)
Definition: mathplot.h:774
int m_offsety
Definition: mathplot.h:1683
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1142
double m_bbox_min_y
Definition: mathplot.h:1809
virtual double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:1989