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 #include <algorithm>
83 
84 // For memory leak debug
85 #ifdef _WINDOWS
86 #ifdef _DEBUG
87 #include <crtdbg.h>
88 #define DEBUG_NEW new (_NORMAL_BLOCK, __FILE__, __LINE__)
89 #else
90 #define DEBUG_NEW new
91 #endif // _DEBUG
92 #endif // _WINDOWS
93 
94 // Separation for axes when set close to border
95 #define X_BORDER_SEPARATION 40
96 #define Y_BORDER_SEPARATION 60
97 
98 // -----------------------------------------------------------------------------
99 // classes
100 // -----------------------------------------------------------------------------
101 
112 
114 enum
115 {
116  mpID_FIT = 2000, // !< Fit view to match bounding box of all layers
117  mpID_ZOOM_IN, // !< Zoom into view at clickposition / window center
118  mpID_ZOOM_OUT, // !< Zoom out
119  mpID_CENTER, // !< Center view on click position
120  mpID_LOCKASPECT, // !< Lock x/y scaling aspect
121 };
122 
123 // -----------------------------------------------------------------------------
124 // mpLayer
125 // -----------------------------------------------------------------------------
126 
127 typedef enum __mp_Layer_Type
128 {
129  mpLAYER_UNDEF, // !< Layer type undefined
130  mpLAYER_AXIS, // !< Axis type layer
131  mpLAYER_PLOT, // !< Plot type layer
132  mpLAYER_INFO, // !< Info box type layer
133  mpLAYER_BITMAP // !< Bitmap type layer
134 } mpLayerType;
135 
146 class mpScaleBase;
147 
148 class WXDLLIMPEXP_MATHPLOT mpLayer : public wxObject
149 {
150 public:
151  mpLayer();
152 
153  virtual ~mpLayer() {};
154 
162  virtual bool HasBBox() { return TRUE; }
163 
171  virtual bool IsInfo() { return false; };
172 
176  virtual double GetMinX() { return -1.0; }
177 
181  virtual double GetMaxX() { return 1.0; }
182 
186  virtual double GetMinY() { return -1.0; }
187 
191  virtual double GetMaxY() { return 1.0; }
192 
234  virtual void Plot( wxDC& dc, mpWindow& w ) = 0;
235 
239  const wxString& GetName() const { return m_name; }
240 
244  const wxFont& GetFont() const { return m_font; }
245 
249  const wxPen& GetPen() const { return m_pen; }
250 
254  void SetContinuity( bool continuity ) { m_continuous = continuity; }
255 
259  bool GetContinuity() const { return m_continuous; }
260 
263  void ShowName( bool show ) { m_showName = show; };
264 
268  void SetName( wxString name ) { m_name = name; }
269 
273  void SetFont( wxFont& font ) { m_font = font; }
274 
278  void SetPen( wxPen pen ) { m_pen = pen; }
279 
282  void SetDrawOutsideMargins( bool drawModeOutside ) { m_drawOutsideMargins = drawModeOutside; };
283 
286  bool GetDrawOutsideMargins() { return m_drawOutsideMargins; };
287 
291  wxBitmap GetColourSquare( int side = 16 );
292 
295  mpLayerType GetLayerType() { return m_type; };
296 
299  bool IsVisible() { return m_visible; };
300 
303  void SetVisible( bool show ) { m_visible = show; };
304 
307  const wxBrush& GetBrush() const { return m_brush; };
308 
311  void SetBrush( wxBrush brush ) { m_brush = brush; };
312 
313 protected:
314 
315  wxFont m_font; // !< Layer's font
316  wxPen m_pen; // !< Layer's pen
317  wxBrush m_brush; // !< Layer's brush
318  wxString m_name; // !< Layer's name
319  bool m_continuous; // !< Specify if the layer will be plotted as a continuous line or a set of points.
320  bool m_showName; // !< States whether the name of the layer must be shown (default is true).
321  bool m_drawOutsideMargins; // !< select if the layer should draw only inside margins or over all DC
322  mpLayerType m_type; // !< Define layer type, which is assigned by constructor
323  bool m_visible; // !< Toggles layer visibility
324  DECLARE_DYNAMIC_CLASS( mpLayer )
325 };
326 
327 
328 // -----------------------------------------------------------------------------
329 // mpInfoLayer
330 // -----------------------------------------------------------------------------
331 
337 {
338 public:
340  mpInfoLayer();
341 
345  mpInfoLayer( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
346 
348  virtual ~mpInfoLayer();
349 
354  virtual void UpdateInfo( mpWindow& w, wxEvent& event );
355 
358  virtual bool HasBBox() override { return false; }
359 
364  virtual void Plot( wxDC& dc, mpWindow& w ) override;
365 
369  virtual bool IsInfo() override { return true; }
370 
374  virtual bool Inside( wxPoint& point );
375 
378  virtual void Move( wxPoint delta );
379 
381  virtual void UpdateReference();
382 
385  wxPoint GetPosition();
386 
389  wxSize GetSize();
390 
393  const wxRect& GetRectangle() { return m_dim; };
394 
395 protected:
396  wxRect m_dim; // !< The bounding rectangle of the box. It may be resized dynamically by the Plot method.
397  wxPoint m_reference; // !< Holds the reference point for movements
398  wxBrush m_brush; // !< The brush to be used for the background
399  int m_winX, m_winY; // !< Holds the mpWindow size. Used to rescale position when window is resized.
400 
401  DECLARE_DYNAMIC_CLASS( mpInfoLayer )
402 };
403 
408 {
409 public:
411  mpInfoCoords();
415  mpInfoCoords( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
416 
418  ~mpInfoCoords();
419 
423  virtual void UpdateInfo( mpWindow& w, wxEvent& event ) override;
424 
429  virtual void Plot( wxDC& dc, mpWindow& w ) override;
430 
431 protected:
432  wxString m_content; // !< string holding the coordinates to be drawn.
433 };
434 
439 {
440 public:
442  mpInfoLegend();
443 
448  mpInfoLegend( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
449 
451  ~mpInfoLegend();
452 
456  virtual void UpdateInfo( mpWindow& w, wxEvent& event ) override;
457 
462  virtual void Plot( wxDC& dc, mpWindow& w ) override;
463 
464 protected:
465 };
466 
467 
468 // -----------------------------------------------------------------------------
469 // mpLayer implementations - functions
470 // -----------------------------------------------------------------------------
471 
476 #define mpALIGNMASK 0x03
477 
478 #define mpALIGN_RIGHT 0x00
479 
480 #define mpALIGN_CENTER 0x01
481 
482 #define mpALIGN_LEFT 0x02
483 
484 #define mpALIGN_TOP mpALIGN_RIGHT
485 
486 #define mpALIGN_BOTTOM mpALIGN_LEFT
487 
488 #define mpALIGN_BORDER_BOTTOM 0x04
489 
490 #define mpALIGN_BORDER_TOP 0x05
491 
492 #define mpX_NORMAL 0x00
493 
494 #define mpX_TIME 0x01
495 
496 #define mpX_HOURS 0x02
497 
498 #define mpX_DATE 0x03
499 
500 #define mpX_DATETIME 0x04
501 
502 #define mpALIGN_BORDER_LEFT mpALIGN_BORDER_BOTTOM
503 
504 #define mpALIGN_BORDER_RIGHT mpALIGN_BORDER_TOP
505 
506 #define mpALIGN_NE 0x00
507 
508 #define mpALIGN_NW 0x01
509 
510 #define mpALIGN_SW 0x02
511 
512 #define mpALIGN_SE 0x03
513 
525 {
526 public:
530  mpFX( const wxString& name = wxEmptyString, int flags = mpALIGN_RIGHT );
531 
537  virtual double GetY( double x ) = 0;
538 
543  virtual void Plot( wxDC& dc, mpWindow& w ) override;
544 
545 protected:
546  int m_flags; // !< Holds label alignment
547 
548  DECLARE_DYNAMIC_CLASS( mpFX )
549 };
550 
557 {
558 public:
562  mpFY( const wxString& name = wxEmptyString, int flags = mpALIGN_TOP );
563 
569  virtual double GetX( double y ) = 0;
570 
575  virtual void Plot( wxDC& dc, mpWindow& w ) override;
576 
577 protected:
578  int m_flags; // !< Holds label alignment
579 
580  DECLARE_DYNAMIC_CLASS( mpFY )
581 };
582 
591 {
592 public:
596  mpFXY( const wxString& name = wxEmptyString, int flags = mpALIGN_NE );
597 
601  virtual void Rewind() = 0;
602 
608  virtual bool GetNextXY( double& x, double& y ) = 0;
609 
610  virtual size_t GetCount() = 0;
611 
616  virtual void Plot( wxDC& dc, mpWindow& w ) override;
617 
618  virtual void SetScale( mpScaleBase* scaleX, mpScaleBase* scaleY );
619 
620  void UpdateScales();
621 
622  double s2x( double plotCoordX ) const;
623  double s2y( double plotCoordY ) const;
624 
625  double x2s( double x ) const;
626  double y2s( double y ) const;
627 
628 protected:
629  int m_flags; // !< Holds label alignment
630 
631  // Data to calculate label positioning
632  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
633  // int drawnPoints;
634  mpScaleBase* m_scaleX, * m_scaleY;
635 
640  void UpdateViewBoundary( wxCoord xnew, wxCoord ynew );
641 
642  DECLARE_DYNAMIC_CLASS( mpFXY )
643 };
644 
652 {
653 public:
657  mpProfile( const wxString& name = wxEmptyString, int flags = mpALIGN_TOP );
658 
664  virtual double GetY( double x ) = 0;
665 
670  virtual void Plot( wxDC& dc, mpWindow& w ) override;
671 
672 protected:
673  int m_flags; // !< Holds label alignment
674 
675  DECLARE_DYNAMIC_CLASS( mpProfile )
676 };
677 
680 // -----------------------------------------------------------------------------
681 // mpLayer implementations - furniture (scales, ...)
682 // -----------------------------------------------------------------------------
683 
695 {
696 public:
697  mpScaleBase();
698  virtual ~mpScaleBase() {};
699 
700  virtual bool IsHorizontal() = 0;
701 
702  bool HasBBox() override { return FALSE; }
703 
708  void SetAlign( int align ) { m_flags = align; };
709 
710  void SetNameAlign( int align ) { m_nameFlags = align; }
711 
715  void SetTicks( bool enable ) { m_ticks = enable; };
716 
720  bool GetTicks() { return m_ticks; };
721 
722 
723  // virtual double X2p( mpWindow &w, double x ) = 0;
724  // virtual double P2x( mpWindow &w, double x ) = 0;
725 
726  void SetDataRange( double minV, double maxV )
727  {
728  m_rangeSet = true;
729  m_minV = minV;
730  m_maxV = maxV;
731  }
732 
733  void GetDataRange( double& minV, double& maxV )
734  {
735  minV = m_minV;
736  maxV = m_maxV;
737  }
738 
739  void ExtendDataRange( double minV, double maxV )
740  {
741  if( !m_rangeSet )
742  {
743  m_minV = minV;
744  m_maxV = maxV;
745  m_rangeSet = true;
746  }
747  else
748  {
749  m_minV = std::min( minV, m_minV );
750  m_maxV = std::max( maxV, m_maxV );
751  }
752 
753  if( m_minV == m_maxV )
754  {
755  m_minV = m_minV - 1.0;
756  m_maxV = m_maxV + 1.0;
757  }
758  }
759 
761  {
762  m_rangeSet = 0;
763  }
764 
765  double AbsMaxValue() const
766  {
767  return std::max( std::abs( m_maxV ), std::abs( m_minV ) );
768  }
769 
770  double AbsVisibleMaxValue() const
771  {
772  return m_absVisibleMaxV;
773  }
774 
775  virtual double TransformToPlot( double x ) { return 0.0; };
776  virtual double TransformFromPlot( double xplot ) { return 0.0; };
777 
778  struct TickLabel
779  {
780  TickLabel( double pos_ = 0.0, const wxString& label_ = wxT("") ) :
781  pos( pos_ ), label( label_ ), pixelPos( 0 ), visible( true )
782  {}
783 
784  double pos;
785  wxString label;
786  int pixelPos;
787  bool visible;
788  };
789 
790  std::vector<TickLabel>& TickLabels() { return m_tickLabels; };
791 
792 protected:
793 
794  void updateTickLabels( wxDC& dc, mpWindow& w );
795  void computeLabelExtents( wxDC& dc, mpWindow& w );
796 
797  // virtual int getLabelDecimalDigits(int maxDigits);
798  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) {};
799  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) {};
800 
801  int tickCount() const
802  {
803  return m_tickValues.size();
804  }
805 
806  virtual int labelCount() const
807  {
808  return m_tickLabels.size();
809  }
810 
811  virtual const wxString formatLabel( double value, int nDigits ) { return wxT( "" ); }
812  virtual void formatLabels() {};
813 
814  virtual double getTickPos( int n )
815  {
816  return m_tickValues[n];
817  }
818 
819  virtual double getLabelPos( int n )
820  {
821  return m_tickLabels[n].pos;
822  }
823 
824  virtual const wxString getLabel( int n )
825  {
826  return m_tickLabels[n].label;
827  }
828 
829  std::vector<double> m_tickValues;
830  std::vector<TickLabel> m_tickLabels;
831 
832  double m_offset, m_scale;
834  int m_flags; // !< Flag for axis alignment
836  bool m_ticks; // !< Flag to toggle between ticks or grid
837  double m_minV, m_maxV;
841 };
842 
844 {
845 public:
852  mpScaleXBase( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER,
853  bool ticks = true, unsigned int type = mpX_NORMAL );
854  virtual ~mpScaleXBase() {};
855 
856  virtual bool IsHorizontal() override { return true; }
859  virtual void Plot( wxDC& dc, mpWindow& w ) override;
860 
861  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) override;
862 
863  // unsigned int m_labelType; //!< Select labels mode: mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds
864  // wxString m_labelFormat; //!< Format string used to print labels
865 
866  DECLARE_DYNAMIC_CLASS( mpScaleXBase )
867 };
868 
869 
871 {
872 public:
878  mpScaleX( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER,
879  bool ticks = true, unsigned int type = mpX_NORMAL );
880 
883  // virtual void Plot(wxDC & dc, mpWindow & w);
884 
885  // virtual double X2p( mpWindow &w, double x );
886  // virtual double P2x( mpWindow &w, double x );
887  virtual double TransformToPlot( double x ) override;
888  virtual double TransformFromPlot( double xplot ) override;
889 
890 protected:
891  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override;
892 
893 
894  DECLARE_DYNAMIC_CLASS( mpScaleX )
895 };
896 
897 
899 {
900 public:
907  mpScaleXLog( const wxString& name = wxT("log(X)"), int flags = mpALIGN_CENTER,
908  bool ticks = true, unsigned int type = mpX_NORMAL );
909 
910  virtual double TransformToPlot( double x ) override;
911  virtual double TransformFromPlot( double xplot ) override;
912 
916  // virtual double X2p( mpWindow &w, double x );
917  // virtual double P2x( mpWindow &w, double x );
918 
919 protected:
920  void recalculateTicks( wxDC& dc, mpWindow& w ) override;
921 
922  // int tickCount() const;
923  // int labelCount() const;
924  // const wxString getLabel( int n );
925  // double getTickPos( int n );
926  // double getLabelPos( int n );
927 
928  void computeLabelExtents( wxDC& dc, mpWindow& w );
929 
930 
931  DECLARE_DYNAMIC_CLASS( mpScaleXLog )
932 };
933 
934 
943 {
944 public:
949  mpScaleY( const wxString& name = wxT("Y"), int flags = mpALIGN_CENTER, bool ticks = true );
950 
951  virtual bool IsHorizontal() override { return false; }
952 
956  virtual void Plot( wxDC& dc, mpWindow& w ) override;
957 
962  virtual bool HasBBox() override { return FALSE; }
963 
966  void SetAlign( int align ) { m_flags = align; };
967 
970  void SetTicks( bool ticks ) { m_ticks = ticks; };
971 
974  bool GetTicks() { return m_ticks; };
975 
976  virtual double TransformToPlot( double x ) override;
977  virtual double TransformFromPlot( double xplot ) override;
978 
979 
980  void SetMasterScale( mpScaleY* masterScale )
981  {
982  m_masterScale = masterScale;
983  }
984 
985 protected:
986  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) override;
987  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override;
988 
989  // virtual int tickCount() const;
990  // virtual int labelCount() const;
991  // virtual const wxString getLabel( int n );
992  // virtual double getTickPos( int n );
993  // virtual double getLabelPos( int n );
994  void computeLabelExtents( wxDC& dc, mpWindow& w );
995  void computeSlaveTicks( mpWindow& w );
996 
998 
999  // double m_minV, m_maxV;
1000 
1001  int m_flags; // !< Flag for axis alignment
1002  bool m_ticks; // !< Flag to toggle between ticks or grid
1003  // wxString m_labelFormat; //!< Format string used to print labels
1004 
1005  DECLARE_DYNAMIC_CLASS( mpScaleY )
1006 };
1007 
1008 // -----------------------------------------------------------------------------
1009 // mpWindow
1010 // -----------------------------------------------------------------------------
1011 
1016 #define mpMOUSEMODE_DRAG 0
1017 
1018 #define mpMOUSEMODE_ZOOMBOX 1
1019 
1022 // WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, wxLayerList );
1023 typedef std::deque<mpLayer*> wxLayerList;
1024 
1047 class WXDLLIMPEXP_MATHPLOT mpWindow : public wxWindow
1048 {
1049 public:
1051  mpWindow( wxWindow* parent, wxWindowID id,
1052  const wxPoint& pos = wxDefaultPosition,
1053  const wxSize& size = wxDefaultSize,
1054  long flags = 0 );
1055  ~mpWindow();
1056 
1060  wxMenu* GetPopupMenu() { return &m_popmenu; }
1061 
1069  bool AddLayer( mpLayer* layer, bool refreshDisplay = true );
1070 
1079  bool DelLayer( mpLayer* layer, bool alsoDeleteObject = false, bool refreshDisplay = true );
1080 
1085  void DelAllLayers( bool alsoDeleteObject, bool refreshDisplay = true );
1086 
1087 
1093  mpLayer* GetLayer( int position );
1094 
1099  mpLayer* GetLayerByName( const wxString& name );
1100 
1105  double GetXscl() { return m_scaleX; }
1106  double GetScaleX( void ) const { return m_scaleX; }; // Schaling's method: maybe another method esists with the same name
1107 
1112  double GetYscl() const { return m_scaleY; }
1113  double GetScaleY( void ) const { return m_scaleY; } // Schaling's method: maybe another method exists with the same name
1114 
1119  double GetXpos() const { return m_posX; }
1120  double GetPosX( void ) const { return m_posX; }
1121 
1126  double GetYpos() const { return m_posY; }
1127  double GetPosY( void ) const { return m_posY; }
1128 
1135  int GetScrX( void ) const { return m_scrX; }
1136  int GetXScreen( void ) const { return m_scrX; }
1137 
1144  int GetScrY( void ) const { return m_scrY; }
1145  int GetYScreen( void ) const { return m_scrY; }
1146 
1150  void SetScaleX( double scaleX );
1151 
1155  void SetScaleY( double scaleY )
1156  {
1157  if( scaleY!=0 )
1158  m_scaleY = scaleY;
1159 
1160  UpdateAll();
1161  }
1162 
1166  void SetPosX( double posX ) { m_posX = posX; UpdateAll(); }
1167 
1171  void SetPosY( double posY ) { m_posY = posY; UpdateAll(); }
1172 
1177  void SetPos( double posX, double posY ) { m_posX = posX; m_posY = posY; UpdateAll(); }
1178 
1184  void SetScr( int scrX, int scrY ) { m_scrX = scrX; m_scrY = scrY; }
1185 
1188  // double p2x(wxCoord pixelCoordX, bool drawOutside = true ); // { return m_posX + pixelCoordX/m_scaleX; }
1189  inline double p2x( wxCoord pixelCoordX ) { return m_posX + pixelCoordX / m_scaleX; }
1190 
1193  // double p2y(wxCoord pixelCoordY, bool drawOutside = true ); //{ return m_posY - pixelCoordY/m_scaleY; }
1194  inline double p2y( wxCoord pixelCoordY ) { return m_posY - pixelCoordY / m_scaleY; }
1195 
1198  // wxCoord x2p(double x, bool drawOutside = true); // { return (wxCoord) ( (x-m_posX) * m_scaleX); }
1199  inline wxCoord x2p( double x ) { return (wxCoord) ( (x - m_posX) * m_scaleX ); }
1200 
1203  // wxCoord y2p(double y, bool drawOutside = true); // { return (wxCoord) ( (m_posY-y) * m_scaleY); }
1204  inline wxCoord y2p( double y ) { return (wxCoord) ( (m_posY - y) * m_scaleY ); }
1205 
1206 
1209  void EnableDoubleBuffer( bool enabled ) { m_enableDoubleBuffer = enabled; }
1210 
1213  void EnableMousePanZoom( bool enabled ) { m_enableMouseNavigation = enabled; }
1214 
1217  void EnableMouseWheelPan( bool enabled ) { m_enableMouseWheelPan = enabled; }
1218 
1224  void LockAspect( bool enable = TRUE );
1225 
1230  inline bool IsAspectLocked() { return m_lockaspect; }
1231 
1236  void Fit() override;
1237 
1244  void Fit( double xMin, double xMax, double yMin, double yMax,
1245  wxCoord* printSizeX = NULL, wxCoord* printSizeY = NULL );
1246 
1251  void ZoomIn( const wxPoint& centerPoint = wxDefaultPosition );
1252  void ZoomIn( const wxPoint& centerPoint, double zoomFactor );
1253 
1258  void ZoomOut( const wxPoint& centerPoint = wxDefaultPosition );
1259  void ZoomOut( const wxPoint& centerPoint, double zoomFactor );
1260 
1262  void ZoomInX();
1263 
1265  void ZoomOutX();
1266 
1268  void ZoomInY();
1269 
1271  void ZoomOutY();
1272 
1275  void ZoomRect( wxPoint p0, wxPoint p1 );
1276 
1278  void UpdateAll();
1279 
1280  // Added methods by Davide Rondini
1281 
1286  unsigned int CountLayers();
1287 
1290  unsigned int CountAllLayers() { return m_layers.size(); };
1291 
1292 #if 0
1293 
1296  void PrintGraph(mpPrintout *print);
1297 #endif
1298 
1303  double GetDesiredXmin() { return m_desiredXmin; }
1304 
1309  double GetDesiredXmax() { return m_desiredXmax; }
1310 
1315  double GetDesiredYmin() { return m_desiredYmin; }
1316 
1321  double GetDesiredYmax() { return m_desiredYmax; }
1322 
1326  void GetBoundingBox( double* bbox );
1327 
1330  void SetMPScrollbars( bool status );
1331 
1334  bool GetMPScrollbars() { return m_enableScrollBars; };
1335 
1341  bool SaveScreenshot( const wxString& filename, wxBitmapType type = wxBITMAP_TYPE_BMP,
1342  wxSize imageSize = wxDefaultSize, bool fit = false );
1343 
1348  static double zoomIncrementalFactor;
1349 
1356  void SetMargins( int top, int right, int bottom, int left );
1357 
1359  void SetMarginTop( int top ) { m_marginTop = top; };
1361  void SetMarginRight( int right ) { m_marginRight = right; };
1363  void SetMarginBottom( int bottom ) { m_marginBottom = bottom; };
1365  void SetMarginLeft( int left ) { m_marginLeft = left; };
1366 
1368  int GetMarginTop() { return m_marginTop; };
1370  int GetMarginRight() { return m_marginRight; };
1372  int GetMarginBottom() { return m_marginBottom; };
1374  int GetMarginLeft() { return m_marginLeft; };
1375 
1376 #if 0
1377 
1380  // void EnableCoordTooltip(bool value = true);
1381 
1385  // bool GetCoordTooltip() { return m_coordTooltip; };
1386 #endif
1387 
1391  mpInfoLayer* IsInsideInfoLayer( wxPoint& point );
1392 
1396  void SetLayerVisible( const wxString& name, bool viewable );
1397 
1401  bool IsLayerVisible( const wxString& name );
1402 
1406  void SetLayerVisible( const unsigned int position, bool viewable );
1407 
1411  bool IsLayerVisible( const unsigned int position );
1412 
1417  void SetColourTheme( const wxColour& bgColour,
1418  const wxColour& drawColour,
1419  const wxColour& axesColour );
1420 
1423  const wxColour& GetAxesColour() { return m_axColour; };
1424 
1426  void LimitView( bool aEnable )
1427  {
1428  m_enableLimitedView = aEnable;
1429  }
1430 
1431 protected:
1432  void OnPaint( wxPaintEvent& event ); // !< Paint handler, will plot all attached layers
1433  void OnSize( wxSizeEvent& event ); // !< Size handler, will update scroll bar sizes
1434 
1435  // void OnScroll2 (wxScrollWinEvent &event); //!< Scroll handler, will move canvas
1436  void OnShowPopupMenu( wxMouseEvent& event ); // !< Mouse handler, will show context menu
1437  void OnMouseMiddleDown( wxMouseEvent& event ); // !< Mouse handler, for detecting when the user
1438 
1439  // !< drags with the middle button or just "clicks" for the menu
1440  void OnCenter( wxCommandEvent& event ); // !< Context menu handler
1441  void OnFit( wxCommandEvent& event ); // !< Context menu handler
1442  void OnZoomIn( wxCommandEvent& event ); // !< Context menu handler
1443  void OnZoomOut( wxCommandEvent& event ); // !< Context menu handler
1444  void OnLockAspect( wxCommandEvent& event ); // !< Context menu handler
1445  void OnMouseWheel( wxMouseEvent& event ); // !< Mouse handler for the wheel
1446  void OnMagnify( wxMouseEvent& event ); // !< Pinch zoom handler
1447  void OnMouseMove( wxMouseEvent& event ); // !< Mouse handler for mouse motion (for pan)
1448  void OnMouseLeftDown( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1449  void OnMouseLeftRelease( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1450  void OnScrollThumbTrack( wxScrollWinEvent& event ); // !< Scroll thumb on scroll bar moving
1451  void OnScrollPageUp( wxScrollWinEvent& event ); // !< Scroll page up
1452  void OnScrollPageDown( wxScrollWinEvent& event ); // !< Scroll page down
1453  void OnScrollLineUp( wxScrollWinEvent& event ); // !< Scroll line up
1454  void OnScrollLineDown( wxScrollWinEvent& event ); // !< Scroll line down
1455  void OnScrollTop( wxScrollWinEvent& event ); // !< Scroll to top
1456  void OnScrollBottom( wxScrollWinEvent& event ); // !< Scroll to bottom
1457 
1458  void DoScrollCalc( const int position, const int orientation );
1459 
1460  void DoZoomInXCalc( const int staticXpixel );
1461  void DoZoomInYCalc( const int staticYpixel );
1462  void DoZoomOutXCalc( const int staticXpixel );
1463  void DoZoomOutYCalc( const int staticYpixel );
1464 
1465  bool CheckXLimits( double& desiredMax, double& desiredMin ) const
1466  {
1467  return !( m_enableLimitedView
1468  && (desiredMax > m_maxX - m_marginRight / m_scaleX
1469  || desiredMin < m_minX - m_marginLeft / m_scaleX) );
1470  }
1471 
1472  bool CheckYLimits( double& desiredMax, double& desiredMin ) const
1473  {
1474  return !( m_enableLimitedView
1475  && (desiredMax > m_maxY + m_marginBottom / m_scaleY
1476  || desiredMin < m_minY + m_marginTop / m_scaleY) );
1477  }
1478 
1479  void AdjustLimitedView();
1480 
1484  virtual bool UpdateBBox();
1485 
1489  virtual bool SetXView( double pos, double desiredMax, double desiredMin );
1490 
1494  virtual bool SetYView( double pos, double desiredMax, double desiredMin );
1495 
1496  // wxList m_layers; //!< List of attached plot layers
1497  wxLayerList m_layers; // !< List of attached plot layers
1498  wxMenu m_popmenu; // !< Canvas' context menu
1499  bool m_lockaspect; // !< Scale aspect is locked or not
1500  // bool m_coordTooltip; //!< Selects whether to show coordinate tooltip
1501  wxColour m_bgColour; // !< Background Colour
1502  wxColour m_fgColour; // !< Foreground Colour
1503  wxColour m_axColour; // !< Axes Colour
1504 
1505  double m_minX; // !< Global layer bounding box, left border incl.
1506  double m_maxX; // !< Global layer bounding box, right border incl.
1507  double m_minY; // !< Global layer bounding box, bottom border incl.
1508  double m_maxY; // !< Global layer bounding box, top border incl.
1509  double m_scaleX; // !< Current view's X scale
1510  double m_scaleY; // !< Current view's Y scale
1511  double m_posX; // !< Current view's X position
1512  double m_posY; // !< Current view's Y position
1513  int m_scrX; // !< Current view's X dimension
1514  int m_scrY; // !< Current view's Y dimension
1515  int m_clickedX; // !< Last mouse click X position, for centering and zooming the view
1516  int m_clickedY; // !< Last mouse click Y position, for centering and zooming the view
1517 
1521  double m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax;
1522 
1523  int m_marginTop, m_marginRight, m_marginBottom, m_marginLeft;
1524 
1525  int m_last_lx, m_last_ly; // !< For double buffering
1526  wxMemoryDC m_buff_dc; // !< For double buffering
1527  wxBitmap* m_buff_bmp; // !< For double buffering
1528  bool m_enableDoubleBuffer; // !< For double buffering
1529  bool m_enableMouseNavigation; // !< For pan/zoom with the mouse.
1530  bool m_enableMouseWheelPan; // !< Trackpad pan/zoom
1532  wxPoint m_mouseMClick; // !< For the middle button "drag" feature
1533  wxPoint m_mouseLClick; // !< Starting coords for rectangular zoom selection
1536  mpInfoLayer* m_movingInfoLayer; // !< For moving info layers over the window area
1538  wxRect m_zoomRect;
1539  DECLARE_DYNAMIC_CLASS( mpWindow )
1540  DECLARE_EVENT_TABLE()
1541 };
1542 
1543 // -----------------------------------------------------------------------------
1544 // mpFXYVector - provided by Jose Luis Blanco
1545 // -----------------------------------------------------------------------------
1546 
1567 {
1568 public:
1572  mpFXYVector( const wxString& name = wxEmptyString, int flags = mpALIGN_NE );
1573 
1574  virtual ~mpFXYVector() {}
1575 
1580  virtual void SetData( const std::vector<double>& xs, const std::vector<double>& ys );
1581 
1585  void Clear();
1586 
1587 protected:
1590  std::vector<double> m_xs, m_ys;
1591 
1594  size_t m_index;
1595 
1598  double m_minX, m_maxX, m_minY, m_maxY;
1599 
1603  void Rewind() override;
1604 
1610  bool GetNextXY( double& x, double& y ) override;
1611 
1612  size_t GetCount() override;
1613 
1614 public:
1617  double GetMinX() override { return m_minX; }
1618 
1621  double GetMinY() override { return m_minY; }
1622 
1625  double GetMaxX() override { return m_maxX; }
1626 
1629  double GetMaxY() override { return m_maxY; }
1630 
1631 protected:
1632 
1633  DECLARE_DYNAMIC_CLASS( mpFXYVector )
1634 };
1635 
1636 
1637 #if 0
1638 
1639 class WXDLLIMPEXP_MATHPLOT mpFSemiLogXVector : public mpFXYVector
1640 {
1641 public:
1645  mpFSemiLogXVector( wxString name = wxEmptyString, int flags = mpALIGN_NE );
1646 
1647  virtual ~mpFSemiLogXVector() {}
1648 
1654  DECLARE_DYNAMIC_CLASS( mpFSemiLogXVector )
1655 };
1656 #endif
1657 
1658 // -----------------------------------------------------------------------------
1659 // mpText - provided by Val Greene
1660 // -----------------------------------------------------------------------------
1661 
1669 {
1670 public:
1674  mpText( const wxString& name = wxT("Title"), int offsetx = 5, int offsety = 50 );
1675 
1678  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1679 
1681  virtual bool HasBBox() override { return FALSE; }
1682 
1683 protected:
1684  int m_offsetx; // !< Holds offset for X in percentage
1685  int m_offsety; // !< Holds offset for Y in percentage
1686 
1687  DECLARE_DYNAMIC_CLASS( mpText )
1688 };
1689 
1690 
1691 // -----------------------------------------------------------------------------
1692 // mpPrintout - provided by Davide Rondini
1693 // -----------------------------------------------------------------------------
1694 
1699 class WXDLLIMPEXP_MATHPLOT mpPrintout : public wxPrintout
1700 {
1701 public:
1702  mpPrintout( mpWindow* drawWindow, const wxChar* title = _T("wxMathPlot print output") );
1703  virtual ~mpPrintout() {};
1704 
1705  void SetDrawState( bool drawState ) { drawn = drawState; };
1706  bool OnPrintPage( int page ) override;
1707  bool HasPage( int page ) override;
1708 
1709 private:
1710  bool drawn;
1712 };
1713 
1714 
1715 // -----------------------------------------------------------------------------
1716 // mpMovableObject - provided by Jose Luis Blanco
1717 // -----------------------------------------------------------------------------
1725 {
1726 public:
1730  m_reference_x( 0 ),
1731  m_reference_y( 0 ),
1732  m_reference_phi( 0 ),
1733  m_shape_xs( 0 ),
1734  m_shape_ys( 0 )
1735  {
1736  m_type = mpLAYER_PLOT;
1737  }
1738 
1739  virtual ~mpMovableObject() {};
1740 
1743  void GetCoordinateBase( double& x, double& y, double& phi ) const
1744  {
1745  x = m_reference_x;
1746  y = m_reference_y;
1747  phi = m_reference_phi;
1748  }
1749 
1752  void SetCoordinateBase( double x, double y, double phi = 0 )
1753  {
1754  m_reference_x = x;
1755  m_reference_y = y;
1756  m_reference_phi = phi;
1757  m_flags = mpALIGN_NE;
1758  ShapeUpdated();
1759  }
1760 
1761  virtual bool HasBBox() override { return m_trans_shape_xs.size()!=0; }
1762 
1765  virtual double GetMinX() override { return m_bbox_min_x; }
1766 
1769  virtual double GetMaxX() override { return m_bbox_max_x; }
1770 
1773  virtual double GetMinY() override { return m_bbox_min_y; }
1774 
1777  virtual double GetMaxY() override { return m_bbox_max_y; }
1778 
1779  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1780 
1784  void SetAlign( int align ) { m_flags = align; };
1785 
1786 protected:
1787  int m_flags; // !< Holds label alignment
1788 
1791  double m_reference_x, m_reference_y, m_reference_phi;
1792 
1796  void TranslatePoint( double x, double y, double& out_x, double& out_y );
1797 
1801  std::vector<double> m_shape_xs, m_shape_ys;
1802 
1806  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
1807 
1811  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
1812 
1817  void ShapeUpdated();
1818 };
1819 
1820 // -----------------------------------------------------------------------------
1821 // mpCovarianceEllipse - provided by Jose Luis Blanco
1822 // -----------------------------------------------------------------------------
1835 {
1836 public:
1841  mpCovarianceEllipse( double cov_00 = 1,
1842  double cov_11 = 1,
1843  double cov_01 = 0,
1844  double quantiles = 2,
1845  int segments = 32,
1846  const wxString& layerName = wxT("") ) :
1847  m_cov_00( cov_00 ),
1848  m_cov_11( cov_11 ),
1849  m_cov_01( cov_01 ),
1850  m_quantiles( quantiles ),
1851  m_segments( segments )
1852  {
1853  m_continuous = true;
1854  m_name = layerName;
1855  RecalculateShape();
1856  m_type = mpLAYER_PLOT;
1857  }
1858 
1860 
1861  double GetQuantiles() const { return m_quantiles; }
1862 
1865  void SetQuantiles( double q )
1866  {
1867  m_quantiles = q;
1868  RecalculateShape();
1869  }
1870 
1871  void SetSegments( int segments ) { m_segments = segments; }
1872  int GetSegments() const { return m_segments; }
1873 
1876  void GetCovarianceMatrix( double& cov_00, double& cov_01, double& cov_11 ) const
1877  {
1878  cov_00 = m_cov_00;
1879  cov_01 = m_cov_01;
1880  cov_11 = m_cov_11;
1881  }
1882 
1885  void SetCovarianceMatrix( double cov_00, double cov_01, double cov_11 )
1886  {
1887  m_cov_00 = cov_00;
1888  m_cov_01 = cov_01;
1889  m_cov_11 = cov_11;
1890  RecalculateShape();
1891  }
1892 
1893 protected:
1896  double m_cov_00, m_cov_11, m_cov_01;
1897  double m_quantiles;
1898 
1902 
1905  void RecalculateShape();
1906 };
1907 
1908 // -----------------------------------------------------------------------------
1909 // mpPolygon - provided by Jose Luis Blanco
1910 // -----------------------------------------------------------------------------
1916 {
1917 public:
1920  mpPolygon( const wxString& layerName = wxT("") )
1921  {
1922  m_continuous = true;
1923  m_name = layerName;
1924  }
1925 
1926  virtual ~mpPolygon() {}
1927 
1933  void setPoints( const std::vector<double>& points_xs,
1934  const std::vector<double>& points_ys,
1935  bool closedShape = true );
1936 };
1937 
1938 // -----------------------------------------------------------------------------
1939 // mpMovableObject - provided by Jose Luis Blanco
1940 // -----------------------------------------------------------------------------
1948 {
1949 public:
1953  {
1954  m_min_x = m_max_x =
1955  m_min_y = m_max_y = 0;
1956  m_validImg = false;
1957  m_type = mpLAYER_BITMAP;
1958  }
1959 
1960  virtual ~mpBitmapLayer() {};
1961 
1964  void GetBitmapCopy( wxImage& outBmp ) const;
1965 
1973  void SetBitmap( const wxImage& inBmp, double x, double y, double lx, double ly );
1974 
1975  virtual bool HasBBox() override { return true; }
1976 
1979  virtual double GetMinX() override { return m_min_x; }
1980 
1983  virtual double GetMaxX() override { return m_max_x; }
1984 
1987  virtual double GetMinY() override { return m_min_y; }
1988 
1991  virtual double GetMaxY() override { return m_max_y; }
1992 
1993  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1994 
1998  void SetAlign( int align ) { m_flags = align; };
1999 
2000 protected:
2001  int m_flags; // !< Holds label alignment
2002 
2005  wxImage m_bitmap;
2006  wxBitmap m_scaledBitmap;
2007  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
2008 
2010 
2013  double m_min_x, m_max_x, m_min_y, m_max_y;
2014 };
2015 
2018 #endif // _MP_MATHPLOT_H_
int m_offsetx
Definition: mathplot.h:1684
bool GetMPScrollbars()
Get scrollbars status.
Definition: mathplot.h:1334
virtual double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:1979
mpLayerType GetLayerType()
Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc,...
Definition: mathplot.h:295
void ShowName(bool show)
Shows or hides the text label with the name of the layer (default is visible).
Definition: mathplot.h:263
class WXDLLIMPEXP_MATHPLOT mpWindow
Definition: mathplot.h:109
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:1060
virtual void recalculateTicks(wxDC &dc, mpWindow &w)
Definition: mathplot.h:799
wxMemoryDC m_buff_dc
Definition: mathplot.h:1526
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:1363
virtual ~mpScaleXBase()
Definition: mathplot.h:854
virtual double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1773
virtual bool IsInfo()
Check whether the layer is an info box.
Definition: mathplot.h:171
bool drawn
Definition: mathplot.h:1710
bool m_continuous
Definition: mathplot.h:319
bool m_enableScrollBars
Definition: mathplot.h:1534
virtual ~mpFXYVector()
Definition: mathplot.h:1574
mpWindow * plotWindow
Definition: mathplot.h:1711
wxBitmap m_scaledBitmap
Definition: mathplot.h:2006
void GetDataRange(double &minV, double &maxV)
Definition: mathplot.h:733
bool m_zooming
Definition: mathplot.h:1537
wxString m_content
Definition: mathplot.h:432
void SetNameAlign(int align)
Definition: mathplot.h:710
virtual ~mpMovableObject()
Definition: mathplot.h:1739
__mp_Layer_Type
Definition: mathplot.h:127
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:239
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:1365
void EnableMouseWheelPan(bool enabled)
Enable/disable trackpad friendly panning (2-axis scroll wheel)
Definition: mathplot.h:1217
double GetPosY(void) const
Definition: mathplot.h:1127
wxBrush m_brush
Definition: mathplot.h:317
int m_clickedX
Definition: mathplot.h:1515
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:1885
bool IsAspectLocked()
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:1230
class WXDLLIMPEXP_MATHPLOT mpFXYVector
Definition: mathplot.h:106
mpWindow()
Definition: mathplot.h:1050
double GetScaleX(void) const
Definition: mathplot.h:1106
TickLabel(double pos_=0.0, const wxString &label_=wxT(""))
Definition: mathplot.h:780
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1189
bool m_ticks
Definition: mathplot.h:836
virtual ~mpLayer()
Definition: mathplot.h:153
std::vector< double > m_trans_shape_ys
Definition: mathplot.h:1806
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:1947
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:244
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:524
double m_scaleY
Definition: mathplot.h:1510
std::vector< TickLabel > & TickLabels()
Definition: mathplot.h:790
int GetXScreen(void) const
Definition: mathplot.h:1136
bool m_enableMouseNavigation
Definition: mathplot.h:1529
double GetScaleY(void) const
Definition: mathplot.h:1113
int m_maxLabelHeight
Definition: mathplot.h:839
int GetMarginBottom()
Definition: mathplot.h:1372
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:1901
int m_flags
Definition: mathplot.h:834
double m_min_y
Definition: mathplot.h:2013
void SetName(wxString name)
Set layer name.
Definition: mathplot.h:268
void SetDataRange(double minV, double maxV)
Definition: mathplot.h:726
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:830
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:651
double m_posX
Definition: mathplot.h:1511
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:980
const wxColour & GetAxesColour()
Get axes draw colour.
Definition: mathplot.h:1423
double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1617
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above).
Definition: mathplot.h:1865
bool m_enableMouseWheelPan
Definition: mathplot.h:1530
int m_maxLabelWidth
Definition: mathplot.h:840
wxColour m_axColour
Definition: mathplot.h:1503
virtual ~mpBitmapLayer()
Definition: mathplot.h:1960
wxPoint m_mouseMClick
Definition: mathplot.h:1532
double m_minY
Definition: mathplot.h:1507
int m_flags
Definition: mathplot.h:578
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:478
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1194
void SetContinuity(bool continuity)
Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points...
Definition: mathplot.h:254
A class providing graphs functionality for a 2D plot (either continuous or a set of points),...
Definition: mathplot.h:1566
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:1983
virtual size_t GetCount()=0
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1784
wxPoint m_scroll
Definition: mathplot.h:1535
double AbsVisibleMaxValue() const
Definition: mathplot.h:770
virtual ~mpPolygon()
Definition: mathplot.h:1926
void SetScaleY(double scaleY)
Set current view's Y scale and refresh display.
Definition: mathplot.h:1155
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:962
std::vector< double > m_ys
Definition: mathplot.h:1590
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1594
int tickCount() const
Definition: mathplot.h:801
double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1625
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:1359
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:278
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:307
double GetPosX(void) const
Definition: mathplot.h:1120
double m_scaleX
Definition: mathplot.h:1509
wxLayerList m_layers
Definition: mathplot.h:1497
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
Definition: mathplot.h:1209
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:1915
double GetQuantiles() const
Definition: mathplot.h:1861
double GetXscl()
Get current view's X scale.
Definition: mathplot.h:1105
std::deque< mpLayer * > wxLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:1023
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,...
Definition: mathplot.h:590
bool m_visible
Definition: mathplot.h:323
void ExtendDataRange(double minV, double maxV)
Definition: mathplot.h:739
mpScaleBase * m_scaleY
Definition: mathplot.h:634
bool GetTicks()
Get Y axis ticks or grid.
Definition: mathplot.h:974
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:1841
virtual ~mpScaleBase()
Definition: mathplot.h:698
int GetSegments() const
Definition: mathplot.h:1872
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:1876
virtual ~mpCovarianceEllipse()
Definition: mathplot.h:1859
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:407
double GetDesiredXmax()
Returns the right-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:1309
wxPoint m_mouseLClick
Definition: mathplot.h:1533
virtual ~mpPrintout()
Definition: mathplot.h:1703
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1204
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1761
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:181
#define mpX_NORMAL
Set label for X axis in normal mode.
Definition: mathplot.h:492
void SetPosX(double posX)
Set current view's X position and refresh display.
Definition: mathplot.h:1166
void ResetDataRange()
Definition: mathplot.h:760
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:1743
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:1952
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:1361
int m_winY
Definition: mathplot.h:399
double m_minY
Definition: mathplot.h:1598
void computeLabelExtents(wxDC &dc, mpWindow &w)
Definition: mathplot.cpp:968
void SetPosY(double posY)
Set current view's Y position and refresh display.
Definition: mathplot.h:1171
#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:1724
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:694
double GetYscl() const
Get current view's Y scale.
Definition: mathplot.h:1112
#define NULL
void SetFont(wxFont &font)
Set layer font.
Definition: mathplot.h:273
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:303
double m_absVisibleMaxV
Definition: mathplot.h:833
int GetMarginTop()
Definition: mathplot.h:1368
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:299
virtual double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:1777
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:311
wxBrush m_brush
Definition: mathplot.h:398
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:336
wxRect m_zoomRect
Definition: mathplot.h:1538
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1135
bool m_lockaspect
Definition: mathplot.h:1499
double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1629
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:702
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:942
wxCoord minDrawY
Definition: mathplot.h:632
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:191
double m_reference_y
Definition: mathplot.h:1791
int m_flags
Definition: mathplot.h:1001
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:108
class WXDLLIMPEXP_MATHPLOT mpLayer
Definition: mathplot.h:102
virtual double getLabelPos(int n)
Definition: mathplot.h:819
#define mpALIGN_TOP
Aligns label to the top.
Definition: mathplot.h:484
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1472
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:1699
bool m_ticks
Definition: mathplot.h:1002
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:715
bool m_rangeSet
Definition: mathplot.h:838
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1536
#define mpALIGN_NE
Aligns label to north-east.
Definition: mathplot.h:506
int m_flags
Definition: mathplot.h:629
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1998
double GetXpos() const
Get current view's X position.
Definition: mathplot.h:1119
void EnableMousePanZoom(bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:1213
wxColour m_fgColour
Definition: mathplot.h:1502
double m_minV
Definition: mathplot.h:837
int m_last_ly
Definition: mathplot.h:1525
bool GetTicks()
Get X axis ticks or grid.
Definition: mathplot.h:720
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:1290
virtual bool HasBBox() override
mpInfoLayer has not bounding box.
Definition: mathplot.h:358
virtual void getVisibleDataRange(mpWindow &w, double &minV, double &maxV)
Definition: mathplot.h:798
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:282
bool GetContinuity() const
Gets the 'continuity' property of the layer.
Definition: mathplot.h:259
virtual bool HasBBox() override
mpText should not be used for scaling decisions.
Definition: mathplot.h:1681
bool m_drawOutsideMargins
Definition: mathplot.h:321
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1975
int GetMarginRight()
Definition: mathplot.h:1370
wxPoint m_reference
Definition: mathplot.h:397
int GetMarginLeft()
Definition: mathplot.h:1374
void SetAlign(int align)
Set Y axis alignment.
Definition: mathplot.h:966
bool m_validImg
Definition: mathplot.h:2009
virtual const wxString getLabel(int n)
Definition: mathplot.h:824
double m_posY
Definition: mathplot.h:1512
bool GetDrawOutsideMargins()
Get Draw mode: inside or outside margins.
Definition: mathplot.h:286
int m_marginTop
Definition: mathplot.h:1523
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:176
virtual bool GetNextXY(double &x, double &y)=0
Get locus value for next N.
double m_scale
Definition: mathplot.h:832
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:186
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:2005
int m_flags
Definition: mathplot.h:546
void SetAlign(int align)
Set X axis alignment.
Definition: mathplot.h:708
bool m_showName
Definition: mathplot.h:320
virtual double TransformToPlot(double x)
Definition: mathplot.h:775
double m_minX
Definition: mathplot.h:1505
double m_desiredYmin
Definition: mathplot.h:1521
enum __mp_Layer_Type mpLayerType
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1199
class WXDLLIMPEXP_MATHPLOT mpFXY
Definition: mathplot.h:105
virtual void formatLabels()
Definition: mathplot.h:812
const char * name
Definition: DXF_plotter.cpp:60
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:1834
class WXDLLIMPEXP_MATHPLOT mpPrintout
Definition: mathplot.h:111
double GetDesiredYmin()
Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not ex...
Definition: mathplot.h:1315
void SetDrawState(bool drawState)
Definition: mathplot.h:1705
wxCoord m_scaledBitmap_offset_y
Definition: mathplot.h:2007
wxPen m_pen
Definition: mathplot.h:316
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:1752
virtual bool IsInfo() override
Specifies that this is an Info box layer.
Definition: mathplot.h:369
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
Definition: mathplot.h:1184
mpMovableObject()
Default constructor (sets location and rotation to (0,0,0))
Definition: mathplot.h:1729
class WXDLLIMPEXP_MATHPLOT mpFX
Definition: mathplot.h:103
virtual bool IsHorizontal() override
Definition: mathplot.h:951
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
Definition: mathplot.h:1177
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:1801
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1426
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:162
int m_clickedY
Definition: mathplot.h:1516
Plot layer implementing a text string.
Definition: mathplot.h:1668
int m_flags
Definition: mathplot.h:673
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:1047
virtual double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1987
virtual void Rewind()=0
Rewind value enumeration with mpFXY::GetNextXY.
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:970
double GetDesiredXmin()
Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:1303
mpLayerType m_type
Definition: mathplot.h:322
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
virtual const wxString formatLabel(double value, int nDigits)
Definition: mathplot.h:811
virtual bool IsHorizontal() override
Definition: mathplot.h:856
#define mpALIGN_CENTER
Aligns label to the center.
Definition: mathplot.h:480
double GetMinY() override
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1621
wxString m_name
Definition: mathplot.h:318
mpPolygon(const wxString &layerName=wxT(""))
Default constructor.
Definition: mathplot.h:1920
int m_scrY
Definition: mathplot.h:1514
virtual double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:1765
bool m_enableLimitedView
Definition: mathplot.h:1531
wxMenu m_popmenu
Definition: mathplot.h:1498
double m_maxX
Definition: mathplot.h:1506
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1465
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:438
wxColour m_bgColour
Definition: mathplot.h:1501
int m_nameFlags
Definition: mathplot.h:835
virtual int labelCount() const
Definition: mathplot.h:806
bool m_enableDoubleBuffer
Definition: mathplot.h:1528
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:1348
double AbsMaxValue() const
Definition: mathplot.h:765
mpScaleY * m_masterScale
Definition: mathplot.h:997
std::vector< double > m_tickValues
Definition: mathplot.h:829
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:249
int m_scrX
Definition: mathplot.h:1513
class WXDLLIMPEXP_MATHPLOT mpScaleX
Definition: mathplot.h:107
class WXDLLIMPEXP_MATHPLOT mpFY
Definition: mathplot.h:104
class WXDLLIMPEXP_MATHPLOT mpText
Definition: mathplot.h:110
virtual double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:1769
wxBitmap * m_buff_bmp
Definition: mathplot.h:1527
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:556
void SetSegments(int segments)
Definition: mathplot.h:1871
double GetDesiredYmax()
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
Definition: mathplot.h:1321
virtual double getTickPos(int n)
Definition: mathplot.h:814
int GetYScreen(void) const
Definition: mathplot.h:1145
double GetYpos() const
Get current view's Y position.
Definition: mathplot.h:1126
double m_maxY
Definition: mathplot.h:1508
virtual double TransformFromPlot(double xplot)
Definition: mathplot.h:776
int m_offsety
Definition: mathplot.h:1685
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1144
double m_bbox_min_y
Definition: mathplot.h:1811
virtual double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:1991