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/defs.h>
68 #include <wx/menu.h>
69 #include <wx/scrolwin.h>
70 #include <wx/event.h>
71 #include <wx/dynarray.h>
72 #include <wx/pen.h>
73 #include <wx/dcmemory.h>
74 #include <wx/string.h>
75 #include <wx/print.h>
76 #include <wx/image.h>
77 
78 
79 #include <deque>
80 
81 #include <algorithm>
82 
83 // For memory leak debug
84 #ifdef _WINDOWS
85 #ifdef _DEBUG
86 #include <crtdbg.h>
87 #define DEBUG_NEW new (_NORMAL_BLOCK, __FILE__, __LINE__)
88 #else
89 #define DEBUG_NEW new
90 #endif // _DEBUG
91 #endif // _WINDOWS
92 
93 // Separation for axes when set close to border
94 #define X_BORDER_SEPARATION 40
95 #define Y_BORDER_SEPARATION 60
96 
97 // -----------------------------------------------------------------------------
98 // classes
99 // -----------------------------------------------------------------------------
100 
111 
113 enum
114 {
115  mpID_FIT = 2000, // !< Fit view to match bounding box of all layers
116  mpID_ZOOM_IN, // !< Zoom into view at clickposition / window center
117  mpID_ZOOM_OUT, // !< Zoom out
118  mpID_CENTER, // !< Center view on click position
119  mpID_LOCKASPECT, // !< Lock x/y scaling aspect
120 };
121 
122 // -----------------------------------------------------------------------------
123 // mpLayer
124 // -----------------------------------------------------------------------------
125 
126 typedef enum __mp_Layer_Type
127 {
128  mpLAYER_UNDEF, // !< Layer type undefined
129  mpLAYER_AXIS, // !< Axis type layer
130  mpLAYER_PLOT, // !< Plot type layer
131  mpLAYER_INFO, // !< Info box type layer
132  mpLAYER_BITMAP // !< Bitmap type layer
133 } mpLayerType;
134 
145 class mpScaleBase;
146 
147 class WXDLLIMPEXP_MATHPLOT mpLayer : public wxObject
148 {
149 public:
150  mpLayer();
151 
152  virtual ~mpLayer() {};
153 
161  virtual bool HasBBox() const { return true; }
162 
170  virtual bool IsInfo() const { return false; };
171 
175  virtual double GetMinX() const { return -1.0; }
176 
180  virtual double GetMaxX() const { return 1.0; }
181 
185  virtual double GetMinY() const { return -1.0; }
186 
190  virtual double GetMaxY() const { return 1.0; }
191 
233  virtual void Plot( wxDC& dc, mpWindow& w ) = 0;
234 
238  const wxString& GetName() const { return m_name; }
239 
243  const wxFont& GetFont() const { return m_font; }
244 
248  const wxPen& GetPen() const { return m_pen; }
249 
253  void SetContinuity( bool continuity ) { m_continuous = continuity; }
254 
258  bool GetContinuity() const { return m_continuous; }
259 
262  void ShowName( bool show ) { m_showName = show; };
263 
267  void SetName( wxString name ) { m_name = name; }
268 
272  void SetFont( wxFont& font ) { m_font = font; }
273 
277  void SetPen( wxPen pen ) { m_pen = pen; }
278 
281  void SetDrawOutsideMargins( bool drawModeOutside ) { m_drawOutsideMargins = drawModeOutside; };
282 
285  bool GetDrawOutsideMargins() { return m_drawOutsideMargins; };
286 
290  wxBitmap GetColourSquare( int side = 16 ) const;
291 
294  mpLayerType GetLayerType() const { return m_type; };
295 
298  bool IsVisible() const { return m_visible; };
299 
302  void SetVisible( bool show ) { m_visible = show; };
303 
306  const wxBrush& GetBrush() const { return m_brush; };
307 
310  void SetBrush( wxBrush brush ) { m_brush = brush; };
311 
312 protected:
313 
314  wxFont m_font; // !< Layer's font
315  wxPen m_pen; // !< Layer's pen
316  wxBrush m_brush; // !< Layer's brush
317  wxString m_name; // !< Layer's name
318  bool m_continuous; // !< Specify if the layer will be plotted as a continuous line or a set of points.
319  bool m_showName; // !< States whether the name of the layer must be shown (default is true).
320  bool m_drawOutsideMargins; // !< select if the layer should draw only inside margins or over all DC
321  mpLayerType m_type; // !< Define layer type, which is assigned by constructor
322  bool m_visible; // !< Toggles layer visibility
323  DECLARE_DYNAMIC_CLASS( mpLayer )
324 };
325 
326 
327 // -----------------------------------------------------------------------------
328 // mpInfoLayer
329 // -----------------------------------------------------------------------------
330 
336 {
337 public:
339  mpInfoLayer();
340 
344  mpInfoLayer( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
345 
347  virtual ~mpInfoLayer();
348 
353  virtual void UpdateInfo( mpWindow& w, wxEvent& event );
354 
357  virtual bool HasBBox() const override { return false; }
358 
363  virtual void Plot( wxDC& dc, mpWindow& w ) override;
364 
368  virtual bool IsInfo() const override { return true; }
369 
373  virtual bool Inside( wxPoint& point );
374 
377  virtual void Move( wxPoint delta );
378 
380  virtual void UpdateReference();
381 
384  wxPoint GetPosition() const;
385 
388  wxSize GetSize() const;
389 
392  const wxRect& GetRectangle() const { return m_dim; };
393 
394 protected:
395  wxRect m_dim; // !< The bounding rectangle of the box. It may be resized dynamically by the Plot method.
396  wxPoint m_reference; // !< Holds the reference point for movements
397  wxBrush m_brush; // !< The brush to be used for the background
398  int m_winX, m_winY; // !< Holds the mpWindow size. Used to rescale position when window is resized.
399 
400  DECLARE_DYNAMIC_CLASS( mpInfoLayer )
401 };
402 
407 {
408 public:
410  mpInfoCoords();
414  mpInfoCoords( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
415 
417  ~mpInfoCoords();
418 
422  virtual void UpdateInfo( mpWindow& w, wxEvent& event ) override;
423 
428  virtual void Plot( wxDC& dc, mpWindow& w ) override;
429 
430 protected:
431  wxString m_content; // !< string holding the coordinates to be drawn.
432 };
433 
438 {
439 public:
441  mpInfoLegend();
442 
447  mpInfoLegend( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
448 
450  ~mpInfoLegend();
451 
455  virtual void UpdateInfo( mpWindow& w, wxEvent& event ) override;
456 
461  virtual void Plot( wxDC& dc, mpWindow& w ) override;
462 
463 protected:
464 };
465 
466 
467 // -----------------------------------------------------------------------------
468 // mpLayer implementations - functions
469 // -----------------------------------------------------------------------------
470 
475 #define mpALIGNMASK 0x03
476 
477 #define mpALIGN_RIGHT 0x00
478 
479 #define mpALIGN_CENTER 0x01
480 
481 #define mpALIGN_LEFT 0x02
482 
483 #define mpALIGN_TOP mpALIGN_RIGHT
484 
485 #define mpALIGN_BOTTOM mpALIGN_LEFT
486 
487 #define mpALIGN_BORDER_BOTTOM 0x04
488 
489 #define mpALIGN_BORDER_TOP 0x05
490 
491 #define mpX_NORMAL 0x00
492 
493 #define mpX_TIME 0x01
494 
495 #define mpX_HOURS 0x02
496 
497 #define mpX_DATE 0x03
498 
499 #define mpX_DATETIME 0x04
500 
501 #define mpALIGN_BORDER_LEFT mpALIGN_BORDER_BOTTOM
502 
503 #define mpALIGN_BORDER_RIGHT mpALIGN_BORDER_TOP
504 
505 #define mpALIGN_NE 0x00
506 
507 #define mpALIGN_NW 0x01
508 
509 #define mpALIGN_SW 0x02
510 
511 #define mpALIGN_SE 0x03
512 
524 {
525 public:
529  mpFX( const wxString& name = wxEmptyString, int flags = mpALIGN_RIGHT );
530 
536  virtual double GetY( double x ) const = 0;
537 
542  virtual void Plot( wxDC& dc, mpWindow& w ) override;
543 
544 protected:
545  int m_flags; // !< Holds label alignment
546 
547  DECLARE_DYNAMIC_CLASS( mpFX )
548 };
549 
556 {
557 public:
561  mpFY( const wxString& name = wxEmptyString, int flags = mpALIGN_TOP );
562 
568  virtual double GetX( double y ) const = 0;
569 
574  virtual void Plot( wxDC& dc, mpWindow& w ) override;
575 
576 protected:
577  int m_flags; // !< Holds label alignment
578 
579  DECLARE_DYNAMIC_CLASS( mpFY )
580 };
581 
590 {
591 public:
595  mpFXY( const wxString& name = wxEmptyString, int flags = mpALIGN_NE );
596 
600  virtual void Rewind() = 0;
601 
607  virtual bool GetNextXY( double& x, double& y ) = 0;
608 
609  virtual size_t GetCount() const = 0;
610 
615  virtual void Plot( wxDC& dc, mpWindow& w ) override;
616 
617  virtual void SetScale( mpScaleBase* scaleX, mpScaleBase* scaleY );
618 
619  void UpdateScales();
620 
621  double s2x( double plotCoordX ) const;
622  double s2y( double plotCoordY ) const;
623 
624  double x2s( double x ) const;
625  double y2s( double y ) const;
626 
627 protected:
628  int m_flags; // !< Holds label alignment
629 
630  // Data to calculate label positioning
631  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
632  // int drawnPoints;
633  mpScaleBase* m_scaleX, * m_scaleY;
634 
639  void UpdateViewBoundary( wxCoord xnew, wxCoord ynew );
640 
641  DECLARE_DYNAMIC_CLASS( mpFXY )
642 };
643 
651 {
652 public:
656  mpProfile( const wxString& name = wxEmptyString, int flags = mpALIGN_TOP );
657 
663  virtual double GetY( double x ) const = 0;
664 
669  virtual void Plot( wxDC& dc, mpWindow& w ) override;
670 
671 protected:
672  int m_flags; // !< Holds label alignment
673 
674  DECLARE_DYNAMIC_CLASS( mpProfile )
675 };
676 
679 // -----------------------------------------------------------------------------
680 // mpLayer implementations - furniture (scales, ...)
681 // -----------------------------------------------------------------------------
682 
694 {
695 public:
696  mpScaleBase();
697  virtual ~mpScaleBase() {};
698 
699  virtual bool IsHorizontal() const = 0;
700 
701  bool HasBBox() const override { return false; }
702 
707  void SetAlign( int align ) { m_flags = align; };
708 
709  void SetNameAlign( int align ) { m_nameFlags = align; }
710 
714  void SetTicks( bool enable ) { m_ticks = enable; };
715 
719  bool GetTicks() const { return m_ticks; };
720 
721 
722  // virtual double X2p( mpWindow &w, double x ) = 0;
723  // virtual double P2x( mpWindow &w, double x ) = 0;
724 
725  void SetDataRange( double minV, double maxV )
726  {
727  m_rangeSet = true;
728  m_minV = minV;
729  m_maxV = maxV;
730  }
731 
732  void GetDataRange( double& minV, double& maxV ) const
733  {
734  minV = m_minV;
735  maxV = m_maxV;
736  }
737 
738  void ExtendDataRange( double minV, double maxV )
739  {
740  if( !m_rangeSet )
741  {
742  m_minV = minV;
743  m_maxV = maxV;
744  m_rangeSet = true;
745  }
746  else
747  {
748  m_minV = std::min( minV, m_minV );
749  m_maxV = std::max( maxV, m_maxV );
750  }
751 
752  if( m_minV == m_maxV )
753  {
754  m_minV = m_minV - 1.0;
755  m_maxV = m_maxV + 1.0;
756  }
757  }
758 
760  {
761  m_rangeSet = 0;
762  }
763 
764  double AbsMaxValue() const
765  {
766  return std::max( std::abs( m_maxV ), std::abs( m_minV ) );
767  }
768 
769  double AbsVisibleMaxValue() const
770  {
771  return m_absVisibleMaxV;
772  }
773 
774  virtual double TransformToPlot( double x ) const { return 0.0; };
775  virtual double TransformFromPlot( double xplot ) const { return 0.0; };
776 
777  struct TickLabel
778  {
779  TickLabel( double pos_ = 0.0, const wxString& label_ = wxT("") ) :
780  pos( pos_ ), label( label_ ), pixelPos( 0 ), visible( true )
781  {}
782 
783  double pos;
784  wxString label;
785  int pixelPos;
786  bool visible;
787  };
788 
789  std::vector<TickLabel>& TickLabels() { return m_tickLabels; };
790 
791 protected:
792 
793  void updateTickLabels( wxDC& dc, mpWindow& w );
794  void computeLabelExtents( wxDC& dc, mpWindow& w );
795 
796  // virtual int getLabelDecimalDigits(int maxDigits) const;
797  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) {};
798  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) {};
799 
800  int tickCount() const
801  {
802  return m_tickValues.size();
803  }
804 
805  virtual int labelCount() const
806  {
807  return m_tickLabels.size();
808  }
809 
810  virtual const wxString formatLabel( double value, int nDigits ) { return wxT( "" ); }
811  virtual void formatLabels() {};
812 
813  virtual double getTickPos( int n ) const
814  {
815  return m_tickValues[n];
816  }
817 
818  virtual double getLabelPos( int n ) const
819  {
820  return m_tickLabels[n].pos;
821  }
822 
823  virtual wxString getLabel( int n ) const
824  {
825  return m_tickLabels[n].label;
826  }
827 
828  std::vector<double> m_tickValues;
829  std::vector<TickLabel> m_tickLabels;
830 
831  double m_offset, m_scale;
833  int m_flags; // !< Flag for axis alignment
835  bool m_ticks; // !< Flag to toggle between ticks or grid
836  double m_minV, m_maxV;
840 };
841 
843 {
844 public:
851  mpScaleXBase( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER,
852  bool ticks = true, unsigned int type = mpX_NORMAL );
853  virtual ~mpScaleXBase() {};
854 
855  virtual bool IsHorizontal() const override { return true; }
858  virtual void Plot( wxDC& dc, mpWindow& w ) override;
859 
860  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) override;
861 
862  // unsigned int m_labelType; //!< Select labels mode: mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds
863  // wxString m_labelFormat; //!< Format string used to print labels
864 
865  DECLARE_DYNAMIC_CLASS( mpScaleXBase )
866 };
867 
868 
870 {
871 public:
877  mpScaleX( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER,
878  bool ticks = true, unsigned int type = mpX_NORMAL );
879 
882  // virtual void Plot(wxDC & dc, mpWindow & w);
883 
884  // virtual double X2p( mpWindow &w, double x );
885  // virtual double P2x( mpWindow &w, double x );
886  virtual double TransformToPlot( double x ) const override;
887  virtual double TransformFromPlot( double xplot ) const override;
888 
889 protected:
890  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override;
891 
892 
893  DECLARE_DYNAMIC_CLASS( mpScaleX )
894 };
895 
896 
898 {
899 public:
906  mpScaleXLog( const wxString& name = wxT("log(X)"), int flags = mpALIGN_CENTER,
907  bool ticks = true, unsigned int type = mpX_NORMAL );
908 
909  virtual double TransformToPlot( double x ) const override;
910  virtual double TransformFromPlot( double xplot ) const override;
911 
915  // virtual double X2p( mpWindow &w, double x );
916  // virtual double P2x( mpWindow &w, double x );
917 
918 protected:
919  void recalculateTicks( wxDC& dc, mpWindow& w ) override;
920 
921  // int tickCount() const;
922  // int labelCount() const;
923  // const wxString getLabel( int n );
924  // double getTickPos( int n );
925  // double getLabelPos( int n );
926 
927  void computeLabelExtents( wxDC& dc, mpWindow& w );
928 
929 
930  DECLARE_DYNAMIC_CLASS( mpScaleXLog )
931 };
932 
933 
942 {
943 public:
948  mpScaleY( const wxString& name = wxT( "Y" ), int flags = mpALIGN_CENTER, bool ticks = true );
949 
950  virtual bool IsHorizontal() const override { return false; }
951 
955  virtual void Plot( wxDC& dc, mpWindow& w ) override;
956 
961  virtual bool HasBBox() const override { return false; }
962 
965  void SetAlign( int align ) { m_flags = align; };
966 
969  void SetTicks( bool ticks ) { m_ticks = ticks; };
970 
973  bool GetTicks() const { return m_ticks; };
974 
975  virtual double TransformToPlot( double x ) const override;
976  virtual double TransformFromPlot( double xplot ) const override;
977 
978 
979  void SetMasterScale( mpScaleY* masterScale )
980  {
981  m_masterScale = masterScale;
982  }
983 
984 protected:
985  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) override;
986  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override;
987 
988  // virtual int tickCount() const;
989  // virtual int labelCount() const;
990  // virtual const wxString getLabel( int n );
991  // virtual double getTickPos( int n );
992  // virtual double getLabelPos( int n );
993  void computeLabelExtents( wxDC& dc, mpWindow& w );
994  void computeSlaveTicks( mpWindow& w );
995 
997 
998  // double m_minV, m_maxV;
999 
1000  int m_flags; // !< Flag for axis alignment
1001  bool m_ticks; // !< Flag to toggle between ticks or grid
1002  // wxString m_labelFormat; //!< Format string used to print labels
1003 
1004  DECLARE_DYNAMIC_CLASS( mpScaleY )
1005 };
1006 
1007 // -----------------------------------------------------------------------------
1008 // mpWindow
1009 // -----------------------------------------------------------------------------
1010 
1015 #define mpMOUSEMODE_DRAG 0
1016 
1017 #define mpMOUSEMODE_ZOOMBOX 1
1018 
1021 // WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, wxLayerList );
1022 typedef std::deque<mpLayer*> wxLayerList;
1023 
1046 class WXDLLIMPEXP_MATHPLOT mpWindow : public wxWindow
1047 {
1048 public:
1049  mpWindow();
1050  mpWindow( wxWindow* parent, wxWindowID id,
1051  const wxPoint& pos = wxDefaultPosition,
1052  const wxSize& size = wxDefaultSize,
1053  long flags = 0 );
1054  ~mpWindow();
1055 
1059  wxMenu* GetPopupMenu() { return &m_popmenu; }
1060 
1068  bool AddLayer( mpLayer* layer, bool refreshDisplay = true );
1069 
1078  bool DelLayer( mpLayer* layer, bool alsoDeleteObject = false, bool refreshDisplay = true );
1079 
1084  void DelAllLayers( bool alsoDeleteObject, bool refreshDisplay = true );
1085 
1086 
1092  mpLayer* GetLayer( int position ) const;
1093 
1098  const mpLayer* GetLayerByName( const wxString& name ) const;
1099  mpLayer* GetLayerByName( const wxString& name )
1100  {
1101  return const_cast<mpLayer*>( static_cast<const mpWindow*>( this )->GetLayerByName( name ) );
1102  }
1103 
1108  double GetXscl() const { return m_scaleX; }
1109  double GetScaleX( void ) const { return m_scaleX; }; // Schaling's method: maybe another method exists with the same name
1110 
1115  double GetYscl() const { return m_scaleY; }
1116  double GetScaleY( void ) const { return m_scaleY; } // Schaling's method: maybe another method exists with the same name
1117 
1122  double GetXpos() const { return m_posX; }
1123  double GetPosX( void ) const { return m_posX; }
1124 
1129  double GetYpos() const { return m_posY; }
1130  double GetPosY( void ) const { return m_posY; }
1131 
1138  int GetScrX( void ) const { return m_scrX; }
1139  int GetXScreen( void ) const { return m_scrX; }
1140 
1147  int GetScrY( void ) const { return m_scrY; }
1148  int GetYScreen( void ) const { return m_scrY; }
1149 
1153  void SetScaleX( double scaleX );
1154 
1158  void SetScaleY( double scaleY )
1159  {
1160  if( scaleY != 0 )
1161  m_scaleY = scaleY;
1162 
1163  UpdateAll();
1164  }
1165 
1169  void SetPosX( double posX ) { m_posX = posX; UpdateAll(); }
1170 
1174  void SetPosY( double posY ) { m_posY = posY; UpdateAll(); }
1175 
1180  void SetPos( double posX, double posY ) { m_posX = posX; m_posY = posY; UpdateAll(); }
1181 
1187  void SetScr( int scrX, int scrY ) { m_scrX = scrX; m_scrY = scrY; }
1188 
1191  // double p2x(wxCoord pixelCoordX, bool drawOutside = true ); // { return m_posX + pixelCoordX/m_scaleX; }
1192  inline double p2x( wxCoord pixelCoordX ) { return m_posX + pixelCoordX / m_scaleX; }
1193 
1196  // double p2y(wxCoord pixelCoordY, bool drawOutside = true ); //{ return m_posY - pixelCoordY/m_scaleY; }
1197  inline double p2y( wxCoord pixelCoordY ) { return m_posY - pixelCoordY / m_scaleY; }
1198 
1201  // wxCoord x2p(double x, bool drawOutside = true); // { return (wxCoord) ( (x-m_posX) * m_scaleX); }
1202  inline wxCoord x2p( double x ) { return (wxCoord) ( (x - m_posX) * m_scaleX ); }
1203 
1206  // wxCoord y2p(double y, bool drawOutside = true); // { return (wxCoord) ( (m_posY-y) * m_scaleY); }
1207  inline wxCoord y2p( double y ) { return (wxCoord) ( (m_posY - y) * m_scaleY ); }
1208 
1209 
1212  void EnableDoubleBuffer( bool enabled ) { m_enableDoubleBuffer = enabled; }
1213 
1216  void EnableMousePanZoom( bool enabled ) { m_enableMouseNavigation = enabled; }
1217 
1220  void EnableMouseWheelPan( bool enabled ) { m_enableMouseWheelPan = enabled; }
1221 
1227  void LockAspect( bool enable = true );
1228 
1233  inline bool IsAspectLocked() const { return m_lockaspect; }
1234 
1239  void Fit() override;
1240 
1247  void Fit( double xMin, double xMax, double yMin, double yMax,
1248  wxCoord* printSizeX = NULL, wxCoord* printSizeY = NULL );
1249 
1254  void ZoomIn( const wxPoint& centerPoint = wxDefaultPosition );
1255  void ZoomIn( const wxPoint& centerPoint, double zoomFactor );
1256 
1261  void ZoomOut( const wxPoint& centerPoint = wxDefaultPosition );
1262  void ZoomOut( const wxPoint& centerPoint, double zoomFactor );
1263 
1265  void ZoomInX();
1266 
1268  void ZoomOutX();
1269 
1271  void ZoomInY();
1272 
1274  void ZoomOutY();
1275 
1278  void ZoomRect( wxPoint p0, wxPoint p1 );
1279 
1281  void UpdateAll();
1282 
1283  // Added methods by Davide Rondini
1284 
1289  unsigned int CountLayers() const;
1290 
1293  unsigned int CountAllLayers() const { return m_layers.size(); };
1294 
1295 #if 0
1296 
1299  void PrintGraph(mpPrintout *print);
1300 #endif
1301 
1306  double GetDesiredXmin() const { return m_desiredXmin; }
1307 
1312  double GetDesiredXmax() const { return m_desiredXmax; }
1313 
1318  double GetDesiredYmin() const { return m_desiredYmin; }
1319 
1324  double GetDesiredYmax() const { return m_desiredYmax; }
1325 
1329  void GetBoundingBox( double* bbox ) const;
1330 
1333  void SetMPScrollbars( bool status );
1334 
1337  bool GetMPScrollbars() const { return m_enableScrollBars; };
1338 
1344  bool SaveScreenshot( const wxString& filename, wxBitmapType type = wxBITMAP_TYPE_BMP,
1345  wxSize imageSize = wxDefaultSize, bool fit = false );
1346 
1351  static double zoomIncrementalFactor;
1352 
1359  void SetMargins( int top, int right, int bottom, int left );
1360 
1362  void SetMarginTop( int top ) { m_marginTop = top; };
1364  void SetMarginRight( int right ) { m_marginRight = right; };
1366  void SetMarginBottom( int bottom ) { m_marginBottom = bottom; };
1368  void SetMarginLeft( int left ) { m_marginLeft = left; };
1369 
1371  int GetMarginTop() const { return m_marginTop; };
1373  int GetMarginRight() const { return m_marginRight; };
1375  int GetMarginBottom() const { return m_marginBottom; };
1377  int GetMarginLeft() const { return m_marginLeft; };
1378 
1379 #if 0
1380 
1383  // void EnableCoordTooltip(bool value = true);
1384 
1388  // bool GetCoordTooltip() { return m_coordTooltip; };
1389 #endif
1390 
1394  mpInfoLayer* IsInsideInfoLayer( wxPoint& point );
1395 
1399  void SetLayerVisible( const wxString& name, bool viewable );
1400 
1404  bool IsLayerVisible( const wxString& name ) const;
1405 
1409  void SetLayerVisible( const unsigned int position, bool viewable );
1410 
1414  bool IsLayerVisible( unsigned int position ) const;
1415 
1420  void SetColourTheme( const wxColour& bgColour,
1421  const wxColour& drawColour,
1422  const wxColour& axesColour );
1423 
1426  const wxColour& GetAxesColour() { return m_axColour; };
1427 
1429  void LimitView( bool aEnable )
1430  {
1431  m_enableLimitedView = aEnable;
1432  }
1433 
1434 protected:
1435  void OnPaint( wxPaintEvent& event ); // !< Paint handler, will plot all attached layers
1436  void OnSize( wxSizeEvent& event ); // !< Size handler, will update scroll bar sizes
1437 
1438  // void OnScroll2 (wxScrollWinEvent &event); //!< Scroll handler, will move canvas
1439  void OnShowPopupMenu( wxMouseEvent& event ); // !< Mouse handler, will show context menu
1440  void OnMouseMiddleDown( wxMouseEvent& event ); // !< Mouse handler, for detecting when the user
1441 
1442  // !< drags with the middle button or just "clicks" for the menu
1443  void OnCenter( wxCommandEvent& event ); // !< Context menu handler
1444  void OnFit( wxCommandEvent& event ); // !< Context menu handler
1445  void OnZoomIn( wxCommandEvent& event ); // !< Context menu handler
1446  void OnZoomOut( wxCommandEvent& event ); // !< Context menu handler
1447  void OnLockAspect( wxCommandEvent& event ); // !< Context menu handler
1448  void OnMouseWheel( wxMouseEvent& event ); // !< Mouse handler for the wheel
1449  void OnMagnify( wxMouseEvent& event ); // !< Pinch zoom handler
1450  void OnMouseMove( wxMouseEvent& event ); // !< Mouse handler for mouse motion (for pan)
1451  void OnMouseLeftDown( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1452  void OnMouseLeftRelease( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1453  void OnScrollThumbTrack( wxScrollWinEvent& event ); // !< Scroll thumb on scroll bar moving
1454  void OnScrollPageUp( wxScrollWinEvent& event ); // !< Scroll page up
1455  void OnScrollPageDown( wxScrollWinEvent& event ); // !< Scroll page down
1456  void OnScrollLineUp( wxScrollWinEvent& event ); // !< Scroll line up
1457  void OnScrollLineDown( wxScrollWinEvent& event ); // !< Scroll line down
1458  void OnScrollTop( wxScrollWinEvent& event ); // !< Scroll to top
1459  void OnScrollBottom( wxScrollWinEvent& event ); // !< Scroll to bottom
1460 
1461  void DoScrollCalc( const int position, const int orientation );
1462 
1463  void DoZoomInXCalc( const int staticXpixel );
1464  void DoZoomInYCalc( const int staticYpixel );
1465  void DoZoomOutXCalc( const int staticXpixel );
1466  void DoZoomOutYCalc( const int staticYpixel );
1467 
1468  bool CheckXLimits( double& desiredMax, double& desiredMin ) const
1469  {
1470  return !( m_enableLimitedView
1471  && (desiredMax > m_maxX - m_marginRight / m_scaleX
1472  || desiredMin < m_minX - m_marginLeft / m_scaleX) );
1473  }
1474 
1475  bool CheckYLimits( double& desiredMax, double& desiredMin ) const
1476  {
1477  return !( m_enableLimitedView
1478  && (desiredMax > m_maxY + m_marginBottom / m_scaleY
1479  || desiredMin < m_minY + m_marginTop / m_scaleY) );
1480  }
1481 
1482  void AdjustLimitedView();
1483 
1487  virtual bool UpdateBBox();
1488 
1492  virtual bool SetXView( double pos, double desiredMax, double desiredMin );
1493 
1497  virtual bool SetYView( double pos, double desiredMax, double desiredMin );
1498 
1499  // wxList m_layers; //!< List of attached plot layers
1500  wxLayerList m_layers; // !< List of attached plot layers
1501  wxMenu m_popmenu; // !< Canvas' context menu
1502  bool m_lockaspect; // !< Scale aspect is locked or not
1503  // bool m_coordTooltip; //!< Selects whether to show coordinate tooltip
1504  wxColour m_bgColour; // !< Background Colour
1505  wxColour m_fgColour; // !< Foreground Colour
1506  wxColour m_axColour; // !< Axes Colour
1507 
1508  double m_minX; // !< Global layer bounding box, left border incl.
1509  double m_maxX; // !< Global layer bounding box, right border incl.
1510  double m_minY; // !< Global layer bounding box, bottom border incl.
1511  double m_maxY; // !< Global layer bounding box, top border incl.
1512  double m_scaleX; // !< Current view's X scale
1513  double m_scaleY; // !< Current view's Y scale
1514  double m_posX; // !< Current view's X position
1515  double m_posY; // !< Current view's Y position
1516  int m_scrX; // !< Current view's X dimension
1517  int m_scrY; // !< Current view's Y dimension
1518  int m_clickedX; // !< Last mouse click X position, for centering and zooming the view
1519  int m_clickedY; // !< Last mouse click Y position, for centering and zooming the view
1520 
1524  double m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax;
1525 
1526  int m_marginTop, m_marginRight, m_marginBottom, m_marginLeft;
1527 
1528  int m_last_lx, m_last_ly; // !< For double buffering
1529  wxMemoryDC m_buff_dc; // !< For double buffering
1530  wxBitmap* m_buff_bmp; // !< For double buffering
1531  bool m_enableDoubleBuffer; // !< For double buffering
1532  bool m_enableMouseNavigation; // !< For pan/zoom with the mouse.
1533  bool m_enableMouseWheelPan; // !< Trackpad pan/zoom
1535  wxPoint m_mouseMClick; // !< For the middle button "drag" feature
1536  wxPoint m_mouseLClick; // !< Starting coords for rectangular zoom selection
1538  wxPoint m_scroll;
1539  mpInfoLayer* m_movingInfoLayer; // !< For moving info layers over the window area
1541  wxRect m_zoomRect;
1542  DECLARE_DYNAMIC_CLASS( mpWindow )
1543  DECLARE_EVENT_TABLE()
1544 };
1545 
1546 // -----------------------------------------------------------------------------
1547 // mpFXYVector - provided by Jose Luis Blanco
1548 // -----------------------------------------------------------------------------
1549 
1570 {
1571 public:
1575  mpFXYVector( const wxString& name = wxEmptyString, int flags = mpALIGN_NE );
1576 
1577  virtual ~mpFXYVector() {}
1578 
1583  virtual void SetData( const std::vector<double>& xs, const std::vector<double>& ys );
1584 
1588  void Clear();
1589 
1590 protected:
1593  std::vector<double> m_xs, m_ys;
1594 
1597  size_t m_index;
1598 
1601  double m_minX, m_maxX, m_minY, m_maxY;
1602 
1606  void Rewind() override;
1607 
1613  bool GetNextXY( double& x, double& y ) override;
1614 
1615  size_t GetCount() const override;
1616 
1617 public:
1620  double GetMinX() const override { return m_minX; }
1621 
1624  double GetMinY() const override { return m_minY; }
1625 
1628  double GetMaxX() const override { return m_maxX; }
1629 
1632  double GetMaxY() const override { return m_maxY; }
1633 
1634 protected:
1635 
1636  DECLARE_DYNAMIC_CLASS( mpFXYVector )
1637 };
1638 
1639 
1640 #if 0
1641 
1642 class WXDLLIMPEXP_MATHPLOT mpFSemiLogXVector : public mpFXYVector
1643 {
1644 public:
1648  mpFSemiLogXVector( wxString name = wxEmptyString, int flags = mpALIGN_NE );
1649 
1650  virtual ~mpFSemiLogXVector() {}
1651 
1657  DECLARE_DYNAMIC_CLASS( mpFSemiLogXVector )
1658 };
1659 #endif
1660 
1661 // -----------------------------------------------------------------------------
1662 // mpText - provided by Val Greene
1663 // -----------------------------------------------------------------------------
1664 
1672 {
1673 public:
1677  mpText( const wxString& name = wxT("Title"), int offsetx = 5, int offsety = 50 );
1678 
1681  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1682 
1684  virtual bool HasBBox() const override { return false; }
1685 
1686 protected:
1687  int m_offsetx; // !< Holds offset for X in percentage
1688  int m_offsety; // !< Holds offset for Y in percentage
1689 
1690  DECLARE_DYNAMIC_CLASS( mpText )
1691 };
1692 
1693 
1694 // -----------------------------------------------------------------------------
1695 // mpPrintout - provided by Davide Rondini
1696 // -----------------------------------------------------------------------------
1697 
1702 class WXDLLIMPEXP_MATHPLOT mpPrintout : public wxPrintout
1703 {
1704 public:
1705  mpPrintout( mpWindow* drawWindow, const wxChar* title = _T("wxMathPlot print output") );
1706  virtual ~mpPrintout() {};
1707 
1708  void SetDrawState( bool drawState ) { drawn = drawState; };
1709  bool OnPrintPage( int page ) override;
1710  bool HasPage( int page ) override;
1711 
1712 private:
1713  bool drawn;
1715 };
1716 
1717 
1718 // -----------------------------------------------------------------------------
1719 // mpMovableObject - provided by Jose Luis Blanco
1720 // -----------------------------------------------------------------------------
1728 {
1729 public:
1733  m_flags( 0 ),
1734  m_reference_x( 0 ),
1735  m_reference_y( 0 ),
1736  m_reference_phi( 0 ),
1737  m_shape_xs( 0 ),
1738  m_shape_ys( 0 ),
1739  m_bbox_min_x( 0 ),
1740  m_bbox_max_x( 0 ),
1741  m_bbox_min_y( 0 ),
1742  m_bbox_max_y( 0 )
1743  {
1744  m_type = mpLAYER_PLOT;
1745  }
1746 
1747  virtual ~mpMovableObject() {};
1748 
1751  void GetCoordinateBase( double& x, double& y, double& phi ) const
1752  {
1753  x = m_reference_x;
1754  y = m_reference_y;
1755  phi = m_reference_phi;
1756  }
1757 
1760  void SetCoordinateBase( double x, double y, double phi = 0 )
1761  {
1762  m_reference_x = x;
1763  m_reference_y = y;
1764  m_reference_phi = phi;
1765  m_flags = mpALIGN_NE;
1766  ShapeUpdated();
1767  }
1768 
1769  virtual bool HasBBox() const override { return m_trans_shape_xs.size()!=0; }
1770 
1773  virtual double GetMinX() const override { return m_bbox_min_x; }
1774 
1777  virtual double GetMaxX() const override { return m_bbox_max_x; }
1778 
1781  virtual double GetMinY() const override { return m_bbox_min_y; }
1782 
1785  virtual double GetMaxY() const override { return m_bbox_max_y; }
1786 
1787  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1788 
1792  void SetAlign( int align ) { m_flags = align; };
1793 
1794 protected:
1795  int m_flags; // !< Holds label alignment
1796 
1799  double m_reference_x, m_reference_y, m_reference_phi;
1800 
1804  void TranslatePoint( double x, double y, double& out_x, double& out_y );
1805 
1809  std::vector<double> m_shape_xs, m_shape_ys;
1810 
1814  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
1815 
1819  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
1820 
1825  void ShapeUpdated();
1826 };
1827 
1828 // -----------------------------------------------------------------------------
1829 // mpCovarianceEllipse - provided by Jose Luis Blanco
1830 // -----------------------------------------------------------------------------
1843 {
1844 public:
1849  mpCovarianceEllipse( double cov_00 = 1,
1850  double cov_11 = 1,
1851  double cov_01 = 0,
1852  double quantiles = 2,
1853  int segments = 32,
1854  const wxString& layerName = wxT("") ) :
1855  m_cov_00( cov_00 ),
1856  m_cov_11( cov_11 ),
1857  m_cov_01( cov_01 ),
1858  m_quantiles( quantiles ),
1859  m_segments( segments )
1860  {
1861  m_continuous = true;
1862  m_name = layerName;
1863  RecalculateShape();
1864  m_type = mpLAYER_PLOT;
1865  }
1866 
1868 
1869  double GetQuantiles() const { return m_quantiles; }
1870 
1873  void SetQuantiles( double q )
1874  {
1875  m_quantiles = q;
1876  RecalculateShape();
1877  }
1878 
1879  void SetSegments( int segments ) { m_segments = segments; }
1880  int GetSegments() const { return m_segments; }
1881 
1884  void GetCovarianceMatrix( double& cov_00, double& cov_01, double& cov_11 ) const
1885  {
1886  cov_00 = m_cov_00;
1887  cov_01 = m_cov_01;
1888  cov_11 = m_cov_11;
1889  }
1890 
1893  void SetCovarianceMatrix( double cov_00, double cov_01, double cov_11 )
1894  {
1895  m_cov_00 = cov_00;
1896  m_cov_01 = cov_01;
1897  m_cov_11 = cov_11;
1898  RecalculateShape();
1899  }
1900 
1901 protected:
1904  double m_cov_00, m_cov_11, m_cov_01;
1905  double m_quantiles;
1906 
1910 
1913  void RecalculateShape();
1914 };
1915 
1916 // -----------------------------------------------------------------------------
1917 // mpPolygon - provided by Jose Luis Blanco
1918 // -----------------------------------------------------------------------------
1924 {
1925 public:
1928  mpPolygon( const wxString& layerName = wxT("") )
1929  {
1930  m_continuous = true;
1931  m_name = layerName;
1932  }
1933 
1934  virtual ~mpPolygon() {}
1935 
1941  void setPoints( const std::vector<double>& points_xs,
1942  const std::vector<double>& points_ys,
1943  bool closedShape = true );
1944 };
1945 
1946 // -----------------------------------------------------------------------------
1947 // mpMovableObject - provided by Jose Luis Blanco
1948 // -----------------------------------------------------------------------------
1956 {
1957 public:
1961  {
1962  m_min_x = m_max_x =
1963  m_min_y = m_max_y = 0;
1964  m_scaledBitmap_offset_x = 0;
1965  m_scaledBitmap_offset_y = 0;
1966  m_validImg = false;
1967  m_type = mpLAYER_BITMAP;
1968  }
1969 
1970  virtual ~mpBitmapLayer() {};
1971 
1974  void GetBitmapCopy( wxImage& outBmp ) const;
1975 
1983  void SetBitmap( const wxImage& inBmp, double x, double y, double lx, double ly );
1984 
1985  virtual bool HasBBox() const override { return true; }
1986 
1989  virtual double GetMinX() const override { return m_min_x; }
1990 
1993  virtual double GetMaxX() const override { return m_max_x; }
1994 
1997  virtual double GetMinY() const override { return m_min_y; }
1998 
2001  virtual double GetMaxY() const override { return m_max_y; }
2002 
2003  virtual void Plot( wxDC& dc, mpWindow& w ) override;
2004 
2008  void SetAlign( int align ) { m_flags = align; };
2009 
2010 protected:
2011  int m_flags; // !< Holds label alignment
2012 
2015  wxImage m_bitmap;
2016  wxBitmap m_scaledBitmap;
2017  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
2018 
2020 
2023  double m_min_x, m_max_x, m_min_y, m_max_y;
2024 };
2025 
2028 #endif // _MP_MATHPLOT_H_
int m_offsetx
Definition: mathplot.h:1687
virtual bool HasBBox() const
Check whether this layer has a bounding box.
Definition: mathplot.h:161
bool GetMPScrollbars() const
Get scrollbars status.
Definition: mathplot.h:1337
void ShowName(bool show)
Shows or hides the text label with the name of the layer (default is visible).
Definition: mathplot.h:262
class WXDLLIMPEXP_MATHPLOT mpWindow
Definition: mathplot.h:108
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:1059
virtual void recalculateTicks(wxDC &dc, mpWindow &w)
Definition: mathplot.h:798
wxMemoryDC m_buff_dc
Definition: mathplot.h:1529
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:1366
int GetMarginBottom() const
Definition: mathplot.h:1375
virtual ~mpScaleXBase()
Definition: mathplot.h:853
bool drawn
Definition: mathplot.h:1713
bool m_continuous
Definition: mathplot.h:318
bool m_enableScrollBars
Definition: mathplot.h:1537
virtual double GetMaxY() const override
Get inclusive top border of bounding box.
Definition: mathplot.h:1785
virtual ~mpFXYVector()
Definition: mathplot.h:1577
mpWindow * plotWindow
Definition: mathplot.h:1714
wxBitmap m_scaledBitmap
Definition: mathplot.h:2016
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.h:1099
bool m_zooming
Definition: mathplot.h:1540
wxString m_content
Definition: mathplot.h:431
void SetNameAlign(int align)
Definition: mathplot.h:709
virtual ~mpMovableObject()
Definition: mathplot.h:1747
__mp_Layer_Type
Definition: mathplot.h:126
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:238
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:1368
void EnableMouseWheelPan(bool enabled)
Enable/disable trackpad friendly panning (2-axis scroll wheel)
Definition: mathplot.h:1220
double GetPosY(void) const
Definition: mathplot.h:1130
wxBrush m_brush
Definition: mathplot.h:316
virtual bool IsHorizontal() const override
Definition: mathplot.h:950
int m_clickedX
Definition: mathplot.h:1518
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:1893
virtual double getLabelPos(int n) const
Definition: mathplot.h:818
class WXDLLIMPEXP_MATHPLOT mpFXYVector
Definition: mathplot.h:105
void GetDataRange(double &minV, double &maxV) const
Definition: mathplot.h:732
double GetScaleX(void) const
Definition: mathplot.h:1109
TickLabel(double pos_=0.0, const wxString &label_=wxT(""))
Definition: mathplot.h:779
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1192
bool m_ticks
Definition: mathplot.h:835
double GetMinX() const override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1620
virtual ~mpLayer()
Definition: mathplot.h:152
std::vector< double > m_trans_shape_ys
Definition: mathplot.h:1814
virtual double GetMaxY() const
Get inclusive top border of bounding box.
Definition: mathplot.h:190
virtual bool HasBBox() const override
mpText should not be used for scaling decisions.
Definition: mathplot.h:1684
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:1955
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:243
virtual double TransformFromPlot(double xplot) const
Definition: mathplot.h:775
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:523
double m_scaleY
Definition: mathplot.h:1513
std::vector< TickLabel > & TickLabels()
Definition: mathplot.h:789
double GetMaxY() const override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1632
int GetXScreen(void) const
Definition: mathplot.h:1139
bool m_enableMouseNavigation
Definition: mathplot.h:1532
double GetScaleY(void) const
Definition: mathplot.h:1116
int m_maxLabelHeight
Definition: mathplot.h:838
virtual double GetMinX() const override
Get inclusive left border of bounding box.
Definition: mathplot.h:1773
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:1909
int m_flags
Definition: mathplot.h:833
double m_min_y
Definition: mathplot.h:2023
void SetName(wxString name)
Set layer name.
Definition: mathplot.h:267
virtual bool HasBBox() const override
mpInfoLayer has not bounding box.
Definition: mathplot.h:357
void SetDataRange(double minV, double maxV)
Definition: mathplot.h:725
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:829
virtual bool IsInfo() const override
Specifies that this is an Info box layer.
Definition: mathplot.h:368
virtual double GetMaxY() const override
Get inclusive top border of bounding box.
Definition: mathplot.h:2001
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:650
double m_posX
Definition: mathplot.h:1514
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:979
const wxColour & GetAxesColour()
Get axes draw colour.
Definition: mathplot.h:1426
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above).
Definition: mathplot.h:1873
unsigned int CountAllLayers() const
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:1293
bool m_enableMouseWheelPan
Definition: mathplot.h:1533
int m_maxLabelWidth
Definition: mathplot.h:839
wxColour m_axColour
Definition: mathplot.h:1506
virtual ~mpBitmapLayer()
Definition: mathplot.h:1970
wxPoint m_mouseMClick
Definition: mathplot.h:1535
double m_minY
Definition: mathplot.h:1510
int m_flags
Definition: mathplot.h:577
bool HasBBox() const override
Check whether this layer has a bounding box.
Definition: mathplot.h:701
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:477
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1197
void SetContinuity(bool continuity)
Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points...
Definition: mathplot.h:253
A class providing graphs functionality for a 2D plot (either continuous or a set of points),...
Definition: mathplot.h:1569
virtual void Plot(wxDC &dc, mpWindow &w) override
Plot method.
Definition: mathplot.cpp:146
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1792
wxPoint m_scroll
Definition: mathplot.h:1538
double AbsVisibleMaxValue() const
Definition: mathplot.h:769
virtual ~mpPolygon()
Definition: mathplot.h:1934
void SetScaleY(double scaleY)
Set current view's Y scale and refresh display.
Definition: mathplot.h:1158
std::vector< double > m_ys
Definition: mathplot.h:1593
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1597
int tickCount() const
Definition: mathplot.h:800
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:1362
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:277
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:306
double GetPosX(void) const
Definition: mathplot.h:1123
double m_scaleX
Definition: mathplot.h:1512
bool GetTicks() const
Get X axis ticks or grid.
Definition: mathplot.h:719
bool GetTicks() const
Get Y axis ticks or grid.
Definition: mathplot.h:973
wxLayerList m_layers
Definition: mathplot.h:1500
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
Definition: mathplot.h:1212
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:1923
double GetQuantiles() const
Definition: mathplot.h:1869
std::deque< mpLayer * > wxLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:1022
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,...
Definition: mathplot.h:589
bool m_visible
Definition: mathplot.h:322
virtual double GetMaxX() const
Get inclusive right border of bounding box.
Definition: mathplot.h:180
void ExtendDataRange(double minV, double maxV)
Definition: mathplot.h:738
virtual bool HasBBox() const override
Check whether this layer has a bounding box.
Definition: mathplot.h:1769
mpScaleBase * m_scaleY
Definition: mathplot.h:633
virtual double TransformToPlot(double x) const
Definition: mathplot.h:774
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:1849
virtual ~mpScaleBase()
Definition: mathplot.h:697
virtual double GetMinX() const override
Get inclusive left border of bounding box.
Definition: mathplot.h:1989
int GetSegments() const
Definition: mathplot.h:1880
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:1884
virtual ~mpCovarianceEllipse()
Definition: mathplot.h:1867
int GetMarginRight() const
Definition: mathplot.h:1373
virtual double GetMaxX() const override
Get inclusive right border of bounding box.
Definition: mathplot.h:1993
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:406
wxPoint m_mouseLClick
Definition: mathplot.h:1536
virtual ~mpPrintout()
Definition: mathplot.h:1706
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1207
#define mpX_NORMAL
Set label for X axis in normal mode.
Definition: mathplot.h:491
void SetPosX(double posX)
Set current view's X position and refresh display.
Definition: mathplot.h:1169
void ResetDataRange()
Definition: mathplot.h:759
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:1751
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:1960
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:1364
int m_winY
Definition: mathplot.h:398
double m_minY
Definition: mathplot.h:1601
void computeLabelExtents(wxDC &dc, mpWindow &w)
Definition: mathplot.cpp:917
void SetPosY(double posY)
Set current view's Y position and refresh display.
Definition: mathplot.h:1174
#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:1727
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:693
double GetYscl() const
Get current view's Y scale.
Definition: mathplot.h:1115
#define NULL
void SetFont(wxFont &font)
Set layer font.
Definition: mathplot.h:272
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:302
double m_absVisibleMaxV
Definition: mathplot.h:832
virtual void UpdateInfo(mpWindow &w, wxEvent &event)
Updates the content of the info box.
Definition: mathplot.cpp:121
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:1312
void SetBrush(wxBrush brush)
Set layer brush.
Definition: mathplot.h:310
wxBrush m_brush
Definition: mathplot.h:397
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:335
virtual double GetMinX() const
Get inclusive left border of bounding box.
Definition: mathplot.h:175
wxRect m_zoomRect
Definition: mathplot.h:1541
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1138
bool m_lockaspect
Definition: mathplot.h:1502
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:941
bool IsVisible() const
Checks whether the layer is visible or not.
Definition: mathplot.h:298
virtual double GetMinY() const
Get inclusive bottom border of bounding box.
Definition: mathplot.h:185
wxCoord minDrawY
Definition: mathplot.h:631
double m_reference_y
Definition: mathplot.h:1799
int m_flags
Definition: mathplot.h:1000
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:107
class WXDLLIMPEXP_MATHPLOT mpLayer
Definition: mathplot.h:101
#define mpALIGN_TOP
Aligns label to the top.
Definition: mathplot.h:483
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1475
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:1702
bool m_ticks
Definition: mathplot.h:1001
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:714
bool m_rangeSet
Definition: mathplot.h:837
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1539
int GetMarginTop() const
Definition: mathplot.h:1371
#define mpALIGN_NE
Aligns label to north-east.
Definition: mathplot.h:505
int m_flags
Definition: mathplot.h:628
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:2008
double GetXpos() const
Get current view's X position.
Definition: mathplot.h:1122
void EnableMousePanZoom(bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:1216
wxColour m_fgColour
Definition: mathplot.h:1505
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:1233
double m_minV
Definition: mathplot.h:836
int m_last_ly
Definition: mathplot.h:1528
virtual void getVisibleDataRange(mpWindow &w, double &minV, double &maxV)
Definition: mathplot.h:797
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:281
double GetMaxX() const override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1628
virtual double GetMinY() const override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1781
bool GetContinuity() const
Gets the 'continuity' property of the layer.
Definition: mathplot.h:258
virtual double getTickPos(int n) const
Definition: mathplot.h:813
bool m_drawOutsideMargins
Definition: mathplot.h:320
wxPoint m_reference
Definition: mathplot.h:396
double GetXscl() const
Get current view's X scale.
Definition: mathplot.h:1108
void SetAlign(int align)
Set Y axis alignment.
Definition: mathplot.h:965
bool m_validImg
Definition: mathplot.h:2019
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:1306
double m_posY
Definition: mathplot.h:1515
bool GetDrawOutsideMargins()
Get Draw mode: inside or outside margins.
Definition: mathplot.h:285
int m_marginTop
Definition: mathplot.h:1526
virtual bool GetNextXY(double &x, double &y)=0
Get locus value for next N.
double m_scale
Definition: mathplot.h:831
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:2015
int m_flags
Definition: mathplot.h:545
virtual wxString getLabel(int n) const
Definition: mathplot.h:823
void SetAlign(int align)
Set X axis alignment.
Definition: mathplot.h:707
bool m_showName
Definition: mathplot.h:319
double m_minX
Definition: mathplot.h:1508
double m_desiredYmin
Definition: mathplot.h:1524
enum __mp_Layer_Type mpLayerType
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1202
class WXDLLIMPEXP_MATHPLOT mpFXY
Definition: mathplot.h:104
virtual void formatLabels()
Definition: mathplot.h:811
const char * name
Definition: DXF_plotter.cpp:56
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:1842
class WXDLLIMPEXP_MATHPLOT mpPrintout
Definition: mathplot.h:110
void SetDrawState(bool drawState)
Definition: mathplot.h:1708
virtual size_t GetCount() const =0
wxCoord m_scaledBitmap_offset_y
Definition: mathplot.h:2017
wxPen m_pen
Definition: mathplot.h:315
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:1760
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
Definition: mathplot.h:1187
mpMovableObject()
Default constructor (sets location and rotation to (0,0,0))
Definition: mathplot.h:1732
class WXDLLIMPEXP_MATHPLOT mpFX
Definition: mathplot.h:102
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:1318
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
Definition: mathplot.h:1180
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:1809
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1429
int m_clickedY
Definition: mathplot.h:1519
Plot layer implementing a text string.
Definition: mathplot.h:1671
int m_flags
Definition: mathplot.h:672
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:1046
virtual void Rewind()=0
Rewind value enumeration with mpFXY::GetNextXY.
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:969
mpLayerType m_type
Definition: mathplot.h:321
virtual const wxString formatLabel(double value, int nDigits)
Definition: mathplot.h:810
int GetMarginLeft() const
Definition: mathplot.h:1377
#define mpALIGN_CENTER
Aligns label to the center.
Definition: mathplot.h:479
constexpr int delta
wxString m_name
Definition: mathplot.h:317
mpPolygon(const wxString &layerName=wxT(""))
Default constructor.
Definition: mathplot.h:1928
int m_scrY
Definition: mathplot.h:1517
bool m_enableLimitedView
Definition: mathplot.h:1534
wxMenu m_popmenu
Definition: mathplot.h:1501
double GetMinY() const override
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1624
virtual double GetMaxX() const override
Get inclusive right border of bounding box.
Definition: mathplot.h:1777
double m_maxX
Definition: mathplot.h:1509
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1468
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:437
wxColour m_bgColour
Definition: mathplot.h:1504
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:1324
int m_nameFlags
Definition: mathplot.h:834
virtual int labelCount() const
Definition: mathplot.h:805
bool m_enableDoubleBuffer
Definition: mathplot.h:1531
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:1351
double AbsMaxValue() const
Definition: mathplot.h:764
mpScaleY * m_masterScale
Definition: mathplot.h:996
std::vector< double > m_tickValues
Definition: mathplot.h:828
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:248
int m_scrX
Definition: mathplot.h:1516
virtual double GetMinY() const override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1997
class WXDLLIMPEXP_MATHPLOT mpScaleX
Definition: mathplot.h:106
class WXDLLIMPEXP_MATHPLOT mpFY
Definition: mathplot.h:103
virtual bool IsHorizontal() const override
Definition: mathplot.h:855
class WXDLLIMPEXP_MATHPLOT mpText
Definition: mathplot.h:109
virtual bool IsInfo() const
Check whether the layer is an info box.
Definition: mathplot.h:170
wxBitmap * m_buff_bmp
Definition: mathplot.h:1530
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:555
void SetSegments(int segments)
Definition: mathplot.h:1879
virtual bool HasBBox() const override
Check whether this layer has a bounding box.
Definition: mathplot.h:961
int GetYScreen(void) const
Definition: mathplot.h:1148
double GetYpos() const
Get current view's Y position.
Definition: mathplot.h:1129
double m_maxY
Definition: mathplot.h:1511
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc,...
Definition: mathplot.h:294
virtual bool HasBBox() const override
Check whether this layer has a bounding box.
Definition: mathplot.h:1985
int m_offsety
Definition: mathplot.h:1688
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1147
double m_bbox_min_y
Definition: mathplot.h:1819