KiCad PCB EDA Suite
mathplot.h
Go to the documentation of this file.
1 // Name: mathplot.cpp
3 // Purpose: Framework for plotting in wxWindows
4 // Original Author: David Schalig
5 // Maintainer: Davide Rondini
6 // Contributors: Jose Luis Blanco, Val Greene, Maciej Suminski, Tomasz Wlostowski
7 // Created: 21/07/2003
8 // Last edit: 05/08/2016
9 // Copyright: (c) David Schalig, Davide Rondini
10 // Licence: wxWindows licence
12 
13 #ifndef _MP_MATHPLOT_H_
14 #define _MP_MATHPLOT_H_
15 
54 // this definition uses windows dll to export function.
55 // WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
56 // mathplot_EXPORTS will be defined by cmake
57 #ifdef mathplot_EXPORTS
58 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
59 #define WXDLLIMPEXP_DATA_MATHPLOT( type ) WXEXPORT type
60 #else // not making DLL
61 #define WXDLLIMPEXP_MATHPLOT
62 #define WXDLLIMPEXP_DATA_MATHPLOT( type ) type
63 #endif
64 
65 #include <vector>
66 
67 // #include <wx/wx.h>
68 #include <wx/defs.h>
69 #include <wx/menu.h>
70 #include <wx/scrolwin.h>
71 #include <wx/event.h>
72 #include <wx/dynarray.h>
73 #include <wx/pen.h>
74 #include <wx/dcmemory.h>
75 #include <wx/string.h>
76 #include <wx/print.h>
77 #include <wx/image.h>
78 
79 
80 #include <deque>
81 
82 // For memory leak debug
83 #ifdef _WINDOWS
84 #ifdef _DEBUG
85 #include <crtdbg.h>
86 #define DEBUG_NEW new (_NORMAL_BLOCK, __FILE__, __LINE__)
87 #else
88 #define DEBUG_NEW new
89 #endif // _DEBUG
90 #endif // _WINDOWS
91 
92 // Separation for axes when set close to border
93 #define X_BORDER_SEPARATION 40
94 #define Y_BORDER_SEPARATION 60
95 
96 // -----------------------------------------------------------------------------
97 // classes
98 // -----------------------------------------------------------------------------
99 
110 
112 enum
113 {
114  mpID_FIT = 2000, // !< Fit view to match bounding box of all layers
115  mpID_ZOOM_IN, // !< Zoom into view at clickposition / window center
116  mpID_ZOOM_OUT, // !< Zoom out
117  mpID_CENTER, // !< Center view on click position
118  mpID_LOCKASPECT, // !< Lock x/y scaling aspect
119 };
120 
121 // -----------------------------------------------------------------------------
122 // mpLayer
123 // -----------------------------------------------------------------------------
124 
125 typedef enum __mp_Layer_Type
126 {
127  mpLAYER_UNDEF, // !< Layer type undefined
128  mpLAYER_AXIS, // !< Axis type layer
129  mpLAYER_PLOT, // !< Plot type layer
130  mpLAYER_INFO, // !< Info box type layer
131  mpLAYER_BITMAP // !< Bitmap type layer
132 } mpLayerType;
133 
144 class mpScaleBase;
145 
146 class WXDLLIMPEXP_MATHPLOT mpLayer : public wxObject
147 {
148 public:
149  mpLayer();
150 
151  virtual ~mpLayer() {};
152 
160  virtual bool HasBBox() { return TRUE; }
161 
169  virtual bool IsInfo() { return false; };
170 
174  virtual double GetMinX() { return -1.0; }
175 
179  virtual double GetMaxX() { return 1.0; }
180 
184  virtual double GetMinY() { return -1.0; }
185 
189  virtual double GetMaxY() { return 1.0; }
190 
232  virtual void Plot( wxDC& dc, mpWindow& w ) = 0;
233 
237  const wxString& GetName() const { return m_name; }
238 
242  const wxFont& GetFont() const { return m_font; }
243 
247  const wxPen& GetPen() const { return m_pen; }
248 
252  void SetContinuity( bool continuity ) { m_continuous = continuity; }
253 
257  bool GetContinuity() const { return m_continuous; }
258 
261  void ShowName( bool show ) { m_showName = show; };
262 
266  void SetName( wxString name ) { m_name = name; }
267 
271  void SetFont( wxFont& font ) { m_font = font; }
272 
276  void SetPen( wxPen pen ) { m_pen = pen; }
277 
280  void SetDrawOutsideMargins( bool drawModeOutside ) { m_drawOutsideMargins = drawModeOutside; };
281 
284  bool GetDrawOutsideMargins() { return m_drawOutsideMargins; };
285 
289  wxBitmap GetColourSquare( int side = 16 );
290 
293  mpLayerType GetLayerType() { return m_type; };
294 
297  bool IsVisible() { return m_visible; };
298 
301  void SetVisible( bool show ) { m_visible = show; };
302 
305  const wxBrush& GetBrush() const { return m_brush; };
306 
309  void SetBrush( wxBrush brush ) { m_brush = brush; };
310 
311 protected:
312 
313  wxFont m_font; // !< Layer's font
314  wxPen m_pen; // !< Layer's pen
315  wxBrush m_brush; // !< Layer's brush
316  wxString m_name; // !< Layer's name
317  bool m_continuous; // !< Specify if the layer will be plotted as a continuous line or a set of points.
318  bool m_showName; // !< States whether the name of the layer must be shown (default is true).
319  bool m_drawOutsideMargins; // !< select if the layer should draw only inside margins or over all DC
320  mpLayerType m_type; // !< Define layer type, which is assigned by constructor
321  bool m_visible; // !< Toggles layer visibility
322  DECLARE_DYNAMIC_CLASS( mpLayer )
323 };
324 
325 
326 // -----------------------------------------------------------------------------
327 // mpInfoLayer
328 // -----------------------------------------------------------------------------
329 
335 {
336 public:
338  mpInfoLayer();
339 
343  mpInfoLayer( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
344 
346  virtual ~mpInfoLayer();
347 
352  virtual void UpdateInfo( mpWindow& w, wxEvent& event );
353 
356  virtual bool HasBBox() override { return false; }
357 
362  virtual void Plot( wxDC& dc, mpWindow& w ) override;
363 
367  virtual bool IsInfo() override { return true; }
368 
372  virtual bool Inside( wxPoint& point );
373 
376  virtual void Move( wxPoint delta );
377 
379  virtual void UpdateReference();
380 
383  wxPoint GetPosition();
384 
387  wxSize GetSize();
388 
391  const wxRect& GetRectangle() { return m_dim; };
392 
393 protected:
394  wxRect m_dim; // !< The bounding rectangle of the box. It may be resized dynamically by the Plot method.
395  wxPoint m_reference; // !< Holds the reference point for movements
396  wxBrush m_brush; // !< The brush to be used for the background
397  int m_winX, m_winY; // !< Holds the mpWindow size. Used to rescale position when window is resized.
398 
399  DECLARE_DYNAMIC_CLASS( mpInfoLayer )
400 };
401 
406 {
407 public:
409  mpInfoCoords();
413  mpInfoCoords( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
414 
416  ~mpInfoCoords();
417 
421  virtual void UpdateInfo( mpWindow& w, wxEvent& event ) override;
422 
427  virtual void Plot( wxDC& dc, mpWindow& w ) override;
428 
429 protected:
430  wxString m_content; // !< string holding the coordinates to be drawn.
431 };
432 
437 {
438 public:
440  mpInfoLegend();
441 
446  mpInfoLegend( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
447 
449  ~mpInfoLegend();
450 
454  virtual void UpdateInfo( mpWindow& w, wxEvent& event ) override;
455 
460  virtual void Plot( wxDC& dc, mpWindow& w ) override;
461 
462 protected:
463 };
464 
465 
466 // -----------------------------------------------------------------------------
467 // mpLayer implementations - functions
468 // -----------------------------------------------------------------------------
469 
474 #define mpALIGNMASK 0x03
475 
476 #define mpALIGN_RIGHT 0x00
477 
478 #define mpALIGN_CENTER 0x01
479 
480 #define mpALIGN_LEFT 0x02
481 
482 #define mpALIGN_TOP mpALIGN_RIGHT
483 
484 #define mpALIGN_BOTTOM mpALIGN_LEFT
485 
486 #define mpALIGN_BORDER_BOTTOM 0x04
487 
488 #define mpALIGN_BORDER_TOP 0x05
489 
490 #define mpX_NORMAL 0x00
491 
492 #define mpX_TIME 0x01
493 
494 #define mpX_HOURS 0x02
495 
496 #define mpX_DATE 0x03
497 
498 #define mpX_DATETIME 0x04
499 
500 #define mpALIGN_BORDER_LEFT mpALIGN_BORDER_BOTTOM
501 
502 #define mpALIGN_BORDER_RIGHT mpALIGN_BORDER_TOP
503 
504 #define mpALIGN_NE 0x00
505 
506 #define mpALIGN_NW 0x01
507 
508 #define mpALIGN_SW 0x02
509 
510 #define mpALIGN_SE 0x03
511 
523 {
524 public:
528  mpFX( wxString name = wxEmptyString, int flags = mpALIGN_RIGHT );
529 
535  virtual double GetY( double x ) = 0;
536 
541  virtual void Plot( wxDC& dc, mpWindow& w ) override;
542 
543 protected:
544  int m_flags; // !< Holds label alignment
545 
546  DECLARE_DYNAMIC_CLASS( mpFX )
547 };
548 
555 {
556 public:
560  mpFY( wxString name = wxEmptyString, int flags = mpALIGN_TOP );
561 
567  virtual double GetX( double y ) = 0;
568 
573  virtual void Plot( wxDC& dc, mpWindow& w ) override;
574 
575 protected:
576  int m_flags; // !< Holds label alignment
577 
578  DECLARE_DYNAMIC_CLASS( mpFY )
579 };
580 
589 {
590 public:
594  mpFXY( wxString name = wxEmptyString, int flags = mpALIGN_NE );
595 
599  virtual void Rewind() = 0;
600 
606  virtual bool GetNextXY( double& x, double& y ) = 0;
607 
612  virtual void Plot( wxDC& dc, mpWindow& w ) override;
613 
614  virtual void SetScale( mpScaleBase* scaleX, mpScaleBase* scaleY );
615 
616  void UpdateScales();
617 
618  double s2x( double plotCoordX ) const;
619  double s2y( double plotCoordY ) const;
620 
621  double x2s( double x ) const;
622  double y2s( double y ) const;
623 
624 protected:
625  int m_flags; // !< Holds label alignment
626 
627  // Data to calculate label positioning
628  wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
629  // int drawnPoints;
630  mpScaleBase* m_scaleX, * m_scaleY;
631 
636  void UpdateViewBoundary( wxCoord xnew, wxCoord ynew );
637 
638  DECLARE_DYNAMIC_CLASS( mpFXY )
639 };
640 
648 {
649 public:
653  mpProfile( wxString name = wxEmptyString, int flags = mpALIGN_TOP );
654 
660  virtual double GetY( double x ) = 0;
661 
666  virtual void Plot( wxDC& dc, mpWindow& w ) override;
667 
668 protected:
669  int m_flags; // !< Holds label alignment
670 
671  DECLARE_DYNAMIC_CLASS( mpProfile )
672 };
673 
676 // -----------------------------------------------------------------------------
677 // mpLayer implementations - furniture (scales, ...)
678 // -----------------------------------------------------------------------------
679 
691 {
692 public:
693  mpScaleBase();
694  virtual ~mpScaleBase() {};
695 
696  virtual bool IsHorizontal() = 0;
697 
698  bool HasBBox() override { return FALSE; }
699 
702  void SetAlign( int align ) { m_flags = align; };
703 
704  void SetNameAlign( int align ) { m_nameFlags = align; }
705 
708  void SetTicks( bool enable ) { m_ticks = enable; };
709 
712  bool GetTicks() { return m_ticks; };
713 
714 
715  // virtual double X2p( mpWindow &w, double x ) = 0;
716  // virtual double P2x( mpWindow &w, double x ) = 0;
717 
718  void SetDataRange( double minV, double maxV )
719  {
720  m_rangeSet = true;
721  m_minV = minV;
722  m_maxV = maxV;
723  }
724 
725  void GetDataRange( double& minV, double& maxV )
726  {
727  minV = m_minV;
728  maxV = m_maxV;
729  }
730 
731  void ExtendDataRange( double minV, double maxV )
732  {
733  if( !m_rangeSet )
734  {
735  m_minV = minV;
736  m_maxV = maxV;
737  m_rangeSet = true;
738  }
739  else
740  {
741  m_minV = std::min( minV, m_minV );
742  m_maxV = std::max( maxV, m_maxV );
743  }
744 
745  if( m_minV == m_maxV )
746  {
747  m_minV = -1.0;
748  m_maxV = 1.0;
749  }
750  }
751 
753  {
754  m_rangeSet = 0;
755  }
756 
757  double AbsMaxValue() const
758  {
759  return std::max( std::abs( m_maxV ), std::abs( m_minV ) );
760  }
761 
762  double AbsVisibleMaxValue() const
763  {
764  return m_absVisibleMaxV;
765  }
766 
767  virtual double TransformToPlot( double x ) { return 0.0; };
768  virtual double TransformFromPlot( double xplot ) { return 0.0; };
769 
770  struct TickLabel
771  {
772  TickLabel( double pos_ = 0.0, const wxString& label_ = wxT("") ) :
773  pos( pos_ ), label( label_ ), pixelPos( 0 ), visible( true )
774  {}
775 
776  double pos;
777  wxString label;
778  int pixelPos;
779  bool visible;
780  };
781 
782  std::vector<TickLabel>& TickLabels() { return m_tickLabels; };
783 
784 protected:
785 
786  void updateTickLabels( wxDC& dc, mpWindow& w );
787  void computeLabelExtents( wxDC& dc, mpWindow& w );
788 
789  // virtual int getLabelDecimalDigits(int maxDigits);
790  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) {};
791  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) {};
792 
793  int tickCount() const
794  {
795  return m_tickValues.size();
796  }
797 
798  virtual int labelCount() const
799  {
800  return m_tickLabels.size();
801  }
802 
803  virtual const wxString formatLabel( double value, int nDigits ) { return wxT( "" ); }
804  virtual void formatLabels() {};
805 
806  virtual double getTickPos( int n )
807  {
808  return m_tickValues[n];
809  }
810 
811  virtual double getLabelPos( int n )
812  {
813  return m_tickLabels[n].pos;
814  }
815 
816  virtual const wxString getLabel( int n )
817  {
818  return m_tickLabels[n].label;
819  }
820 
821  std::vector<double> m_tickValues;
822  std::vector<TickLabel> m_tickLabels;
823 
824  double m_offset, m_scale;
826  int m_flags; // !< Flag for axis alignment
828  bool m_ticks; // !< Flag to toggle between ticks or grid
829  double m_minV, m_maxV;
833 };
834 
836 {
837 public:
844  mpScaleXBase( wxString name = wxT("X"), int flags = mpALIGN_CENTER,
845  bool ticks = true, unsigned int type = mpX_NORMAL );
846  virtual ~mpScaleXBase() {};
847 
848  virtual bool IsHorizontal() override { return true; }
851  virtual void Plot( wxDC& dc, mpWindow& w ) override;
852 
853  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) override;
854 
855  // unsigned int m_labelType; //!< Select labels mode: mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds
856  // wxString m_labelFormat; //!< Format string used to print labels
857 
858  DECLARE_DYNAMIC_CLASS( mpScaleXBase )
859 };
860 
861 
863 {
864 public:
870  mpScaleX( wxString name = wxT("X"), int flags = mpALIGN_CENTER,
871  bool ticks = true, unsigned int type = mpX_NORMAL );
872 
875  // virtual void Plot(wxDC & dc, mpWindow & w);
876 
877  // virtual double X2p( mpWindow &w, double x );
878  // virtual double P2x( mpWindow &w, double x );
879  virtual double TransformToPlot( double x ) override;
880  virtual double TransformFromPlot( double xplot ) override;
881 
882 protected:
883  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override;
884 
885 
886  DECLARE_DYNAMIC_CLASS( mpScaleX )
887 };
888 
889 
891 {
892 public:
899  mpScaleXLog( wxString name = wxT("log(X)"), int flags = mpALIGN_CENTER,
900  bool ticks = true, unsigned int type = mpX_NORMAL );
901 
902  virtual double TransformToPlot( double x ) override;
903  virtual double TransformFromPlot( double xplot ) override;
904 
908  // virtual double X2p( mpWindow &w, double x );
909  // virtual double P2x( mpWindow &w, double x );
910 
911 protected:
912  void recalculateTicks( wxDC& dc, mpWindow& w ) override;
913 
914  // int tickCount() const;
915  // int labelCount() const;
916  // const wxString getLabel( int n );
917  // double getTickPos( int n );
918  // double getLabelPos( int n );
919 
920  void computeLabelExtents( wxDC& dc, mpWindow& w );
921 
922 
923  DECLARE_DYNAMIC_CLASS( mpScaleXLog )
924 };
925 
926 
935 {
936 public:
941  mpScaleY( wxString name = wxT("Y"), int flags = mpALIGN_CENTER, bool ticks = true );
942 
943  virtual bool IsHorizontal() override { return false; }
944 
948  virtual void Plot( wxDC& dc, mpWindow& w ) override;
949 
954  virtual bool HasBBox() override { return FALSE; }
955 
958  void SetAlign( int align ) { m_flags = align; };
959 
962  void SetTicks( bool ticks ) { m_ticks = ticks; };
963 
966  bool GetTicks() { return m_ticks; };
967 
968  virtual double TransformToPlot( double x ) override;
969  virtual double TransformFromPlot( double xplot ) override;
970 
971 
972  void SetMasterScale( mpScaleY* masterScale )
973  {
974  m_masterScale = masterScale;
975  }
976 
977 protected:
978  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) override;
979  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override;
980 
981  // virtual int tickCount() const;
982  // virtual int labelCount() const;
983  // virtual const wxString getLabel( int n );
984  // virtual double getTickPos( int n );
985  // virtual double getLabelPos( int n );
986  void computeLabelExtents( wxDC& dc, mpWindow& w );
987  void computeSlaveTicks( mpWindow& w );
988 
990 
991  // double m_minV, m_maxV;
992 
993  int m_flags; // !< Flag for axis alignment
994  bool m_ticks; // !< Flag to toggle between ticks or grid
995  // wxString m_labelFormat; //!< Format string used to print labels
996 
997  DECLARE_DYNAMIC_CLASS( mpScaleY )
998 };
999 
1000 // -----------------------------------------------------------------------------
1001 // mpWindow
1002 // -----------------------------------------------------------------------------
1003 
1008 #define mpMOUSEMODE_DRAG 0
1009 
1010 #define mpMOUSEMODE_ZOOMBOX 1
1011 
1014 // WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, wxLayerList );
1015 typedef std::deque<mpLayer*> wxLayerList;
1016 
1039 class WXDLLIMPEXP_MATHPLOT mpWindow : public wxWindow
1040 {
1041 public:
1043  mpWindow( wxWindow* parent, wxWindowID id,
1044  const wxPoint& pos = wxDefaultPosition,
1045  const wxSize& size = wxDefaultSize,
1046  long flags = 0 );
1047  ~mpWindow();
1048 
1052  wxMenu* GetPopupMenu() { return &m_popmenu; }
1053 
1061  bool AddLayer( mpLayer* layer, bool refreshDisplay = true );
1062 
1071  bool DelLayer( mpLayer* layer, bool alsoDeleteObject = false, bool refreshDisplay = true );
1072 
1077  void DelAllLayers( bool alsoDeleteObject, bool refreshDisplay = true );
1078 
1079 
1085  mpLayer* GetLayer( int position );
1086 
1091  mpLayer* GetLayerByName( const wxString& name );
1092 
1097  double GetXscl() { return m_scaleX; }
1098  double GetScaleX( void ) const { return m_scaleX; }; // Schaling's method: maybe another method esists with the same name
1099 
1104  double GetYscl() const { return m_scaleY; }
1105  double GetScaleY( void ) const { return m_scaleY; } // Schaling's method: maybe another method exists with the same name
1106 
1111  double GetXpos() const { return m_posX; }
1112  double GetPosX( void ) const { return m_posX; }
1113 
1118  double GetYpos() const { return m_posY; }
1119  double GetPosY( void ) const { return m_posY; }
1120 
1127  int GetScrX( void ) const { return m_scrX; }
1128  int GetXScreen( void ) const { return m_scrX; }
1129 
1136  int GetScrY( void ) const { return m_scrY; }
1137  int GetYScreen( void ) const { return m_scrY; }
1138 
1142  void SetScaleX( double scaleX );
1143 
1147  void SetScaleY( double scaleY )
1148  {
1149  if( scaleY!=0 )
1150  m_scaleY = scaleY;
1151 
1152  UpdateAll();
1153  }
1154 
1158  void SetPosX( double posX ) { m_posX = posX; UpdateAll(); }
1159 
1163  void SetPosY( double posY ) { m_posY = posY; UpdateAll(); }
1164 
1169  void SetPos( double posX, double posY ) { m_posX = posX; m_posY = posY; UpdateAll(); }
1170 
1176  void SetScr( int scrX, int scrY ) { m_scrX = scrX; m_scrY = scrY; }
1177 
1180  // double p2x(wxCoord pixelCoordX, bool drawOutside = true ); // { return m_posX + pixelCoordX/m_scaleX; }
1181  inline double p2x( wxCoord pixelCoordX ) { return m_posX + pixelCoordX / m_scaleX; }
1182 
1185  // double p2y(wxCoord pixelCoordY, bool drawOutside = true ); //{ return m_posY - pixelCoordY/m_scaleY; }
1186  inline double p2y( wxCoord pixelCoordY ) { return m_posY - pixelCoordY / m_scaleY; }
1187 
1190  // wxCoord x2p(double x, bool drawOutside = true); // { return (wxCoord) ( (x-m_posX) * m_scaleX); }
1191  inline wxCoord x2p( double x ) { return (wxCoord) ( (x - m_posX) * m_scaleX ); }
1192 
1195  // wxCoord y2p(double y, bool drawOutside = true); // { return (wxCoord) ( (m_posY-y) * m_scaleY); }
1196  inline wxCoord y2p( double y ) { return (wxCoord) ( (m_posY - y) * m_scaleY ); }
1197 
1198 
1201  void EnableDoubleBuffer( bool enabled ) { m_enableDoubleBuffer = enabled; }
1202 
1205  void EnableMousePanZoom( bool enabled ) { m_enableMouseNavigation = enabled; }
1206 
1212  void LockAspect( bool enable = TRUE );
1213 
1218  inline bool IsAspectLocked() { return m_lockaspect; }
1219 
1224  void Fit() override;
1225 
1232  void Fit( double xMin, double xMax, double yMin, double yMax,
1233  wxCoord* printSizeX = NULL, wxCoord* printSizeY = NULL );
1234 
1238  void ZoomIn( const wxPoint& centerPoint = wxDefaultPosition );
1239 
1243  void ZoomOut( const wxPoint& centerPoint = wxDefaultPosition );
1244 
1246  void ZoomInX();
1247 
1249  void ZoomOutX();
1250 
1252  void ZoomInY();
1253 
1255  void ZoomOutY();
1256 
1258  void ZoomRect( wxPoint p0, wxPoint p1 );
1259 
1261  void UpdateAll();
1262 
1263  // Added methods by Davide Rondini
1264 
1268  unsigned int CountLayers();
1269 
1272  unsigned int CountAllLayers() { return m_layers.size(); };
1273 
1276  // void PrintGraph(mpPrintout *print);
1277 
1278 
1282  double GetDesiredXmin() { return m_desiredXmin; }
1283 
1287  double GetDesiredXmax() { return m_desiredXmax; }
1288 
1292  double GetDesiredYmin() { return m_desiredYmin; }
1293 
1297  double GetDesiredYmax() { return m_desiredYmax; }
1298 
1301  void GetBoundingBox( double* bbox );
1302 
1305  void SetMPScrollbars( bool status );
1306 
1309  bool GetMPScrollbars() { return m_enableScrollBars; };
1310 
1316  bool SaveScreenshot( const wxString& filename, wxBitmapType type = wxBITMAP_TYPE_BMP,
1317  wxSize imageSize = wxDefaultSize, bool fit = false );
1318 
1321  static double zoomIncrementalFactor;
1322 
1328  void SetMargins( int top, int right, int bottom, int left );
1329 
1331  void SetMarginTop( int top ) { m_marginTop = top; };
1333  void SetMarginRight( int right ) { m_marginRight = right; };
1335  void SetMarginBottom( int bottom ) { m_marginBottom = bottom; };
1337  void SetMarginLeft( int left ) { m_marginLeft = left; };
1338 
1340  int GetMarginTop() { return m_marginTop; };
1342  int GetMarginRight() { return m_marginRight; };
1344  int GetMarginBottom() { return m_marginBottom; };
1346  int GetMarginLeft() { return m_marginLeft; };
1347 
1349  // void EnableCoordTooltip(bool value = true);
1351  // bool GetCoordTooltip() { return m_coordTooltip; };
1352 
1356  mpInfoLayer* IsInsideInfoLayer( wxPoint& point );
1357 
1361  void SetLayerVisible( const wxString& name, bool viewable );
1362 
1366  bool IsLayerVisible( const wxString& name );
1367 
1371  void SetLayerVisible( const unsigned int position, bool viewable );
1372 
1376  bool IsLayerVisible( const unsigned int position );
1377 
1382  void SetColourTheme( const wxColour& bgColour,
1383  const wxColour& drawColour,
1384  const wxColour& axesColour );
1385 
1388  const wxColour& GetAxesColour() { return m_axColour; };
1389 
1391  void LimitView( bool aEnable )
1392  {
1393  m_enableLimitedView = aEnable;
1394  }
1395 
1396 protected:
1397  void OnPaint( wxPaintEvent& event ); // !< Paint handler, will plot all attached layers
1398  void OnSize( wxSizeEvent& event ); // !< Size handler, will update scroll bar sizes
1399 
1400  // void OnScroll2 (wxScrollWinEvent &event); //!< Scroll handler, will move canvas
1401  void OnShowPopupMenu( wxMouseEvent& event ); // !< Mouse handler, will show context menu
1402  void OnMouseMiddleDown( wxMouseEvent& event ); // !< Mouse handler, for detecting when the user
1403 
1404  // !< drags with the middle button or just "clicks" for the menu
1405  void OnCenter( wxCommandEvent& event ); // !< Context menu handler
1406  void OnFit( wxCommandEvent& event ); // !< Context menu handler
1407  void OnZoomIn( wxCommandEvent& event ); // !< Context menu handler
1408  void OnZoomOut( wxCommandEvent& event ); // !< Context menu handler
1409  void OnLockAspect( wxCommandEvent& event ); // !< Context menu handler
1410  void OnMouseWheel( wxMouseEvent& event ); // !< Mouse handler for the wheel
1411  void OnMouseMove( wxMouseEvent& event ); // !< Mouse handler for mouse motion (for pan)
1412  void OnMouseLeftDown( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1413  void OnMouseLeftRelease( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1414  void OnScrollThumbTrack( wxScrollWinEvent& event ); // !< Scroll thumb on scroll bar moving
1415  void OnScrollPageUp( wxScrollWinEvent& event ); // !< Scroll page up
1416  void OnScrollPageDown( wxScrollWinEvent& event ); // !< Scroll page down
1417  void OnScrollLineUp( wxScrollWinEvent& event ); // !< Scroll line up
1418  void OnScrollLineDown( wxScrollWinEvent& event ); // !< Scroll line down
1419  void OnScrollTop( wxScrollWinEvent& event ); // !< Scroll to top
1420  void OnScrollBottom( wxScrollWinEvent& event ); // !< Scroll to bottom
1421 
1422  void DoScrollCalc( const int position, const int orientation );
1423 
1424  void DoZoomInXCalc( const int staticXpixel );
1425  void DoZoomInYCalc( const int staticYpixel );
1426  void DoZoomOutXCalc( const int staticXpixel );
1427  void DoZoomOutYCalc( const int staticYpixel );
1428 
1429  bool CheckXLimits( double& desiredMax, double& desiredMin ) const
1430  {
1431  return !( m_enableLimitedView
1432  && (desiredMax > m_maxX - m_marginRight / m_scaleX
1433  || desiredMin < m_minX - m_marginLeft / m_scaleX) );
1434  }
1435 
1436  bool CheckYLimits( double& desiredMax, double& desiredMin ) const
1437  {
1438  return !( m_enableLimitedView
1439  && (desiredMax > m_maxY + m_marginBottom / m_scaleY
1440  || desiredMin < m_minY + m_marginTop / m_scaleY) );
1441  }
1442 
1443  void AdjustLimitedView();
1444 
1448  virtual bool UpdateBBox();
1449 
1453  virtual bool SetXView( double pos, double desiredMax, double desiredMin );
1454 
1458  virtual bool SetYView( double pos, double desiredMax, double desiredMin );
1459 
1460  // wxList m_layers; //!< List of attached plot layers
1461  wxLayerList m_layers; // !< List of attached plot layers
1462  wxMenu m_popmenu; // !< Canvas' context menu
1463  bool m_lockaspect; // !< Scale aspect is locked or not
1464  // bool m_coordTooltip; //!< Selects whether to show coordinate tooltip
1465  wxColour m_bgColour; // !< Background Colour
1466  wxColour m_fgColour; // !< Foreground Colour
1467  wxColour m_axColour; // !< Axes Colour
1468 
1469  double m_minX; // !< Global layer bounding box, left border incl.
1470  double m_maxX; // !< Global layer bounding box, right border incl.
1471  double m_minY; // !< Global layer bounding box, bottom border incl.
1472  double m_maxY; // !< Global layer bounding box, top border incl.
1473  double m_scaleX; // !< Current view's X scale
1474  double m_scaleY; // !< Current view's Y scale
1475  double m_posX; // !< Current view's X position
1476  double m_posY; // !< Current view's Y position
1477  int m_scrX; // !< Current view's X dimension
1478  int m_scrY; // !< Current view's Y dimension
1479  int m_clickedX; // !< Last mouse click X position, for centering and zooming the view
1480  int m_clickedY; // !< Last mouse click Y position, for centering and zooming the view
1481 
1484  double m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax;
1485 
1486  int m_marginTop, m_marginRight, m_marginBottom, m_marginLeft;
1487 
1488  int m_last_lx, m_last_ly; // !< For double buffering
1489  wxMemoryDC m_buff_dc; // !< For double buffering
1490  wxBitmap* m_buff_bmp; // !< For double buffering
1491  bool m_enableDoubleBuffer; // !< For double buffering
1492  bool m_enableMouseNavigation; // !< For pan/zoom with the mouse.
1494  wxPoint m_mouseMClick; // !< For the middle button "drag" feature
1495  wxPoint m_mouseLClick; // !< Starting coords for rectangular zoom selection
1498  mpInfoLayer* m_movingInfoLayer; // !< For moving info layers over the window area
1500  wxRect m_zoomRect;
1501  DECLARE_DYNAMIC_CLASS( mpWindow )
1502  DECLARE_EVENT_TABLE()
1503 };
1504 
1505 // -----------------------------------------------------------------------------
1506 // mpFXYVector - provided by Jose Luis Blanco
1507 // -----------------------------------------------------------------------------
1508 
1529 {
1530 public:
1534  mpFXYVector( wxString name = wxEmptyString, int flags = mpALIGN_NE );
1535 
1536  virtual ~mpFXYVector() {}
1537 
1542  virtual void SetData( const std::vector<double>& xs, const std::vector<double>& ys );
1543 
1547  void Clear();
1548 
1549 protected:
1552  std::vector<double> m_xs, m_ys;
1553 
1556  size_t m_index;
1557 
1560  double m_minX, m_maxX, m_minY, m_maxY;
1561 
1565  void Rewind() override;
1566 
1572  bool GetNextXY( double& x, double& y ) override;
1573 
1574 public:
1577  double GetMinX() override { return m_minX; }
1578 
1581  double GetMinY() override { return m_minY; }
1582 
1585  double GetMaxX() override { return m_maxX; }
1586 
1589  double GetMaxY() override { return m_maxY; }
1590 
1591 protected:
1592 
1593  DECLARE_DYNAMIC_CLASS( mpFXYVector )
1594 };
1595 
1596 
1597 #if 0
1598 
1599 class WXDLLIMPEXP_MATHPLOT mpFSemiLogXVector : public mpFXYVector
1600 {
1601 public:
1605  mpFSemiLogXVector( wxString name = wxEmptyString, int flags = mpALIGN_NE );
1606 
1607  virtual ~mpFSemiLogXVector() {}
1608 
1614  DECLARE_DYNAMIC_CLASS( mpFSemiLogXVector )
1615 };
1616 #endif
1617 
1618 // -----------------------------------------------------------------------------
1619 // mpText - provided by Val Greene
1620 // -----------------------------------------------------------------------------
1621 
1629 {
1630 public:
1634  mpText( wxString name = wxT("Title"), int offsetx = 5, int offsety = 50 );
1635 
1638  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1639 
1641  virtual bool HasBBox() override { return FALSE; }
1642 
1643 protected:
1644  int m_offsetx; // !< Holds offset for X in percentage
1645  int m_offsety; // !< Holds offset for Y in percentage
1646 
1647  DECLARE_DYNAMIC_CLASS( mpText )
1648 };
1649 
1650 
1651 // -----------------------------------------------------------------------------
1652 // mpPrintout - provided by Davide Rondini
1653 // -----------------------------------------------------------------------------
1654 
1659 class WXDLLIMPEXP_MATHPLOT mpPrintout : public wxPrintout
1660 {
1661 public:
1662  mpPrintout( mpWindow* drawWindow, const wxChar* title = _T("wxMathPlot print output") );
1663  virtual ~mpPrintout() {};
1664 
1665  void SetDrawState( bool drawState ) { drawn = drawState; };
1666  bool OnPrintPage( int page ) override;
1667  bool HasPage( int page ) override;
1668 
1669 private:
1670  bool drawn;
1672 };
1673 
1674 
1675 // -----------------------------------------------------------------------------
1676 // mpMovableObject - provided by Jose Luis Blanco
1677 // -----------------------------------------------------------------------------
1685 {
1686 public:
1690  m_reference_x( 0 ),
1691  m_reference_y( 0 ),
1692  m_reference_phi( 0 ),
1693  m_shape_xs( 0 ),
1694  m_shape_ys( 0 )
1695  {
1696  m_type = mpLAYER_PLOT;
1697  }
1698 
1699  virtual ~mpMovableObject() {};
1700 
1703  void GetCoordinateBase( double& x, double& y, double& phi ) const
1704  {
1705  x = m_reference_x;
1706  y = m_reference_y;
1707  phi = m_reference_phi;
1708  }
1709 
1712  void SetCoordinateBase( double x, double y, double phi = 0 )
1713  {
1714  m_reference_x = x;
1715  m_reference_y = y;
1716  m_reference_phi = phi;
1717  m_flags = mpALIGN_NE;
1718  ShapeUpdated();
1719  }
1720 
1721  virtual bool HasBBox() override { return m_trans_shape_xs.size()!=0; }
1722 
1725  virtual double GetMinX() override { return m_bbox_min_x; }
1726 
1729  virtual double GetMaxX() override { return m_bbox_max_x; }
1730 
1733  virtual double GetMinY() override { return m_bbox_min_y; }
1734 
1737  virtual double GetMaxY() override { return m_bbox_max_y; }
1738 
1739  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1740 
1744  void SetAlign( int align ) { m_flags = align; };
1745 
1746 protected:
1747  int m_flags; // !< Holds label alignment
1748 
1751  double m_reference_x, m_reference_y, m_reference_phi;
1752 
1756  void TranslatePoint( double x, double y, double& out_x, double& out_y );
1757 
1761  std::vector<double> m_shape_xs, m_shape_ys;
1762 
1766  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
1767 
1771  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
1772 
1777  void ShapeUpdated();
1778 };
1779 
1780 // -----------------------------------------------------------------------------
1781 // mpCovarianceEllipse - provided by Jose Luis Blanco
1782 // -----------------------------------------------------------------------------
1795 {
1796 public:
1800  mpCovarianceEllipse( double cov_00 = 1,
1801  double cov_11 = 1,
1802  double cov_01 = 0,
1803  double quantiles = 2,
1804  int segments = 32,
1805  const wxString& layerName = wxT("") ) :
1806  m_cov_00( cov_00 ),
1807  m_cov_11( cov_11 ),
1808  m_cov_01( cov_01 ),
1809  m_quantiles( quantiles ),
1810  m_segments( segments )
1811  {
1812  m_continuous = true;
1813  m_name = layerName;
1814  RecalculateShape();
1815  m_type = mpLAYER_PLOT;
1816  }
1817 
1819 
1820  double GetQuantiles() const { return m_quantiles; }
1821 
1824  void SetQuantiles( double q )
1825  {
1826  m_quantiles = q;
1827  RecalculateShape();
1828  }
1829 
1830  void SetSegments( int segments ) { m_segments = segments; }
1831  int GetSegments() const { return m_segments; }
1832 
1835  void GetCovarianceMatrix( double& cov_00, double& cov_01, double& cov_11 ) const
1836  {
1837  cov_00 = m_cov_00;
1838  cov_01 = m_cov_01;
1839  cov_11 = m_cov_11;
1840  }
1841 
1844  void SetCovarianceMatrix( double cov_00, double cov_01, double cov_11 )
1845  {
1846  m_cov_00 = cov_00;
1847  m_cov_01 = cov_01;
1848  m_cov_11 = cov_11;
1849  RecalculateShape();
1850  }
1851 
1852 protected:
1855  double m_cov_00, m_cov_11, m_cov_01;
1856  double m_quantiles;
1857 
1861 
1864  void RecalculateShape();
1865 };
1866 
1867 // -----------------------------------------------------------------------------
1868 // mpPolygon - provided by Jose Luis Blanco
1869 // -----------------------------------------------------------------------------
1875 {
1876 public:
1879  mpPolygon( const wxString& layerName = wxT("") )
1880  {
1881  m_continuous = true;
1882  m_name = layerName;
1883  }
1884 
1885  virtual ~mpPolygon() {}
1886 
1892  void setPoints( const std::vector<double>& points_xs,
1893  const std::vector<double>& points_ys,
1894  bool closedShape = true );
1895 };
1896 
1897 // -----------------------------------------------------------------------------
1898 // mpMovableObject - provided by Jose Luis Blanco
1899 // -----------------------------------------------------------------------------
1907 {
1908 public:
1912  {
1913  m_min_x = m_max_x =
1914  m_min_y = m_max_y = 0;
1915  m_validImg = false;
1916  m_type = mpLAYER_BITMAP;
1917  }
1918 
1919  virtual ~mpBitmapLayer() {};
1920 
1923  void GetBitmapCopy( wxImage& outBmp ) const;
1924 
1932  void SetBitmap( const wxImage& inBmp, double x, double y, double lx, double ly );
1933 
1934  virtual bool HasBBox() override { return true; }
1935 
1938  virtual double GetMinX() override { return m_min_x; }
1939 
1942  virtual double GetMaxX() override { return m_max_x; }
1943 
1946  virtual double GetMinY() override { return m_min_y; }
1947 
1950  virtual double GetMaxY() override { return m_max_y; }
1951 
1952  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1953 
1957  void SetAlign( int align ) { m_flags = align; };
1958 
1959 protected:
1960  int m_flags; // !< Holds label alignment
1961 
1964  wxImage m_bitmap;
1965  wxBitmap m_scaledBitmap;
1966  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
1967 
1969 
1972  double m_min_x, m_max_x, m_min_y, m_max_y;
1973 };
1974 
1977 #endif // _MP_MATHPLOT_H_
int m_offsetx
Definition: mathplot.h:1644
bool GetMPScrollbars()
Get scrollbars status.
Definition: mathplot.h:1309
virtual double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:1938
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:305
mpLayerType GetLayerType()
Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc, this method returns the right value.
Definition: mathplot.h:293
void ShowName(bool show)
Shows or hides the text label with the name of the layer (default is visible).
Definition: mathplot.h:261
class WXDLLIMPEXP_MATHPLOT mpWindow
Definition: mathplot.h:107
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:1052
virtual void recalculateTicks(wxDC &dc, mpWindow &w)
Definition: mathplot.h:791
wxMemoryDC m_buff_dc
Definition: mathplot.h:1489
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:1335
virtual ~mpScaleXBase()
Definition: mathplot.h:846
virtual double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1733
virtual bool IsInfo()
Check whether the layer is an info box.
Definition: mathplot.h:169
bool drawn
Definition: mathplot.h:1670
bool m_continuous
Definition: mathplot.h:317
bool m_enableScrollBars
Definition: mathplot.h:1496
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:237
virtual ~mpFXYVector()
Definition: mathplot.h:1536
mpWindow * plotWindow
Definition: mathplot.h:1671
wxBitmap m_scaledBitmap
Definition: mathplot.h:1965
void GetDataRange(double &minV, double &maxV)
Definition: mathplot.h:725
bool m_zooming
Definition: mathplot.h:1499
wxString m_content
Definition: mathplot.h:430
void SetNameAlign(int align)
Definition: mathplot.h:704
virtual ~mpMovableObject()
Definition: mathplot.h:1699
__mp_Layer_Type
Definition: mathplot.h:125
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:1337
wxBrush m_brush
Definition: mathplot.h:315
int m_clickedX
Definition: mathplot.h:1479
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:1844
bool IsAspectLocked()
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:1218
class WXDLLIMPEXP_MATHPLOT mpFXYVector
Definition: mathplot.h:104
mpWindow()
Definition: mathplot.h:1042
TickLabel(double pos_=0.0, const wxString &label_=wxT(""))
Definition: mathplot.h:772
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1181
bool m_ticks
Definition: mathplot.h:828
int tickCount() const
Definition: mathplot.h:793
virtual ~mpLayer()
Definition: mathplot.h:151
std::vector< double > m_trans_shape_ys
Definition: mathplot.h:1766
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:1906
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:522
int GetYScreen(void) const
Definition: mathplot.h:1137
double m_scaleY
Definition: mathplot.h:1474
std::vector< TickLabel > & TickLabels()
Definition: mathplot.h:782
bool m_enableMouseNavigation
Definition: mathplot.h:1492
int m_maxLabelHeight
Definition: mathplot.h:831
int GetMarginBottom()
Get the bottom margin.
Definition: mathplot.h:1344
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:1860
int m_flags
Definition: mathplot.h:826
double m_min_y
Definition: mathplot.h:1972
void SetName(wxString name)
Set layer name.
Definition: mathplot.h:266
void SetDataRange(double minV, double maxV)
Definition: mathplot.h:718
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:822
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:647
double m_posX
Definition: mathplot.h:1475
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:972
const wxColour & GetAxesColour()
Get axes draw colour.
Definition: mathplot.h:1388
double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1577
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above)...
Definition: mathplot.h:1824
int m_maxLabelWidth
Definition: mathplot.h:832
wxColour m_axColour
Definition: mathplot.h:1467
virtual ~mpBitmapLayer()
Definition: mathplot.h:1919
wxPoint m_mouseMClick
Definition: mathplot.h:1494
double m_minY
Definition: mathplot.h:1471
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1136
int m_flags
Definition: mathplot.h:576
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:476
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1186
void SetContinuity(bool continuity)
Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points...
Definition: mathplot.h:252
A class providing graphs functionality for a 2D plot (either continuous or a set of points)...
Definition: mathplot.h:1528
virtual void Plot(wxDC &dc, mpWindow &w) override
Plot method.
Definition: mathplot.cpp:154
virtual double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:1942
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1744
wxPoint m_scroll
Definition: mathplot.h:1497
virtual ~mpPolygon()
Definition: mathplot.h:1885
void SetScaleY(double scaleY)
Set current view's Y scale and refresh display.
Definition: mathplot.h:1147
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:954
std::vector< double > m_ys
Definition: mathplot.h:1552
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1556
double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1585
#define abs(a)
Definition: auxiliary.h:84
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:1331
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:276
double GetYpos() const
Get current view's Y position.
Definition: mathplot.h:1118
double m_scaleX
Definition: mathplot.h:1473
static const int delta[8][2]
Definition: solve.cpp:112
wxLayerList m_layers
Definition: mathplot.h:1461
double GetPosY(void) const
Definition: mathplot.h:1119
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
Definition: mathplot.h:1201
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:1874
double GetXscl()
Get current view's X scale.
Definition: mathplot.h:1097
std::deque< mpLayer * > wxLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:1015
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
Definition: mathplot.h:588
bool m_visible
Definition: mathplot.h:321
void ExtendDataRange(double minV, double maxV)
Definition: mathplot.h:731
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1429
mpScaleBase * m_scaleY
Definition: mathplot.h:630
bool GetTicks()
Get Y axis ticks or grid.
Definition: mathplot.h:966
bool GetContinuity() const
Gets the 'continuity' property of the layer.
Definition: mathplot.h:257
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:1800
virtual ~mpScaleBase()
Definition: mathplot.h:694
double GetXpos() const
Get current view's X position.
Definition: mathplot.h:1111
virtual ~mpCovarianceEllipse()
Definition: mathplot.h:1818
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:405
double GetDesiredXmax()
Returns the right-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
Definition: mathplot.h:1287
wxPoint m_mouseLClick
Definition: mathplot.h:1495
virtual ~mpPrintout()
Definition: mathplot.h:1663
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1196
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1721
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:179
#define mpX_NORMAL
Set label for X axis in normal mode.
Definition: mathplot.h:490
void SetPosX(double posX)
Set current view's X position and refresh display.
Definition: mathplot.h:1158
void ResetDataRange()
Definition: mathplot.h:752
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:1911
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:1333
int m_winY
Definition: mathplot.h:397
double m_minY
Definition: mathplot.h:1560
void computeLabelExtents(wxDC &dc, mpWindow &w)
Definition: mathplot.cpp:960
void SetPosY(double posY)
Set current view's Y position and refresh display.
Definition: mathplot.h:1163
#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:1684
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:690
void SetFont(wxFont &font)
Set layer font.
Definition: mathplot.h:271
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301
double m_absVisibleMaxV
Definition: mathplot.h:825
int GetMarginTop()
Get the top margin.
Definition: mathplot.h:1340
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:297
virtual double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:1737
virtual int labelCount() const
Definition: mathplot.h:798
virtual void UpdateInfo(mpWindow &w, wxEvent &event)
Updates the content of the info box.
Definition: mathplot.cpp:129
double GetQuantiles() const
Definition: mathplot.h:1820
void SetBrush(wxBrush brush)
Set layer brush.
Definition: mathplot.h:309
wxBrush m_brush
Definition: mathplot.h:396
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:334
wxRect m_zoomRect
Definition: mathplot.h:1500
double GetPosX(void) const
Definition: mathplot.h:1112
bool m_lockaspect
Definition: mathplot.h:1463
double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1589
bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:698
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:934
wxCoord minDrawY
Definition: mathplot.h:628
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:189
double m_reference_y
Definition: mathplot.h:1751
int m_flags
Definition: mathplot.h:993
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:106
class WXDLLIMPEXP_MATHPLOT mpLayer
Definition: mathplot.h:100
virtual double getLabelPos(int n)
Definition: mathplot.h:811
#define mpALIGN_TOP
Aligns label to the top.
Definition: mathplot.h:482
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:1659
bool m_ticks
Definition: mathplot.h:994
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:708
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:242
bool m_rangeSet
Definition: mathplot.h:830
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1498
#define mpALIGN_NE
Aligns label to north-east.
Definition: mathplot.h:504
int m_flags
Definition: mathplot.h:625
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1127
double GetScaleY(void) const
Definition: mathplot.h:1105
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1957
void EnableMousePanZoom(bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:1205
wxColour m_fgColour
Definition: mathplot.h:1466
double m_minV
Definition: mathplot.h:829
int m_last_ly
Definition: mathplot.h:1488
double AbsMaxValue() const
Definition: mathplot.h:757
bool GetTicks()
Get X axis ticks or grid.
Definition: mathplot.h:712
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:1835
double GetScaleX(void) const
Definition: mathplot.h:1098
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:1272
virtual bool HasBBox() override
mpInfoLayer has not bounding box.
Definition: mathplot.h:356
virtual void getVisibleDataRange(mpWindow &w, double &minV, double &maxV)
Definition: mathplot.h:790
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:280
int GetSegments() const
Definition: mathplot.h:1831
virtual bool HasBBox() override
mpText should not be used for scaling decisions.
Definition: mathplot.h:1641
bool m_drawOutsideMargins
Definition: mathplot.h:319
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1934
int GetMarginRight()
Get the right margin.
Definition: mathplot.h:1342
wxPoint m_reference
Definition: mathplot.h:395
int GetMarginLeft()
Get the left margin.
Definition: mathplot.h:1346
void SetAlign(int align)
Set Y axis alignment.
Definition: mathplot.h:958
bool m_validImg
Definition: mathplot.h:1968
virtual const wxString getLabel(int n)
Definition: mathplot.h:816
double m_posY
Definition: mathplot.h:1476
bool GetDrawOutsideMargins()
Get Draw mode: inside or outside margins.
Definition: mathplot.h:284
int m_marginTop
Definition: mathplot.h:1486
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:174
double m_scale
Definition: mathplot.h:824
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:184
wxImage m_bitmap
The internal copy of the Bitmap:
Definition: mathplot.h:1964
int m_flags
Definition: mathplot.h:544
void SetAlign(int align)
Set X axis alignment.
Definition: mathplot.h:702
bool m_showName
Definition: mathplot.h:318
virtual double TransformToPlot(double x)
Definition: mathplot.h:767
double m_minX
Definition: mathplot.h:1469
double m_desiredYmin
Definition: mathplot.h:1484
enum __mp_Layer_Type mpLayerType
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1191
class WXDLLIMPEXP_MATHPLOT mpFXY
Definition: mathplot.h:103
virtual void formatLabels()
Definition: mathplot.h:804
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:1794
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:1703
class WXDLLIMPEXP_MATHPLOT mpPrintout
Definition: mathplot.h:109
#define max(a, b)
Definition: auxiliary.h:86
double GetDesiredYmin()
Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not ex...
Definition: mathplot.h:1292
void SetDrawState(bool drawState)
Definition: mathplot.h:1665
double AbsVisibleMaxValue() const
Definition: mathplot.h:762
wxCoord m_scaledBitmap_offset_y
Definition: mathplot.h:1966
wxPen m_pen
Definition: mathplot.h:314
void SetCoordinateBase(double x, double y, double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition: mathplot.h:1712
virtual bool IsInfo() override
Specifies that this is an Info box layer.
Definition: mathplot.h:367
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
Definition: mathplot.h:1176
mpMovableObject()
Default constructor (sets location and rotation to (0,0,0))
Definition: mathplot.h:1689
class WXDLLIMPEXP_MATHPLOT mpFX
Definition: mathplot.h:101
virtual bool IsHorizontal() override
Definition: mathplot.h:943
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
Definition: mathplot.h:1169
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:1761
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:247
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1391
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:160
int m_clickedY
Definition: mathplot.h:1480
Plot layer implementing a text string.
Definition: mathplot.h:1628
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1436
int m_flags
Definition: mathplot.h:669
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:1039
virtual double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1946
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:962
double GetDesiredXmin()
Draws the mpWindow on a page for printing.
Definition: mathplot.h:1282
mpLayerType m_type
Definition: mathplot.h:320
const char * name
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
virtual const wxString formatLabel(double value, int nDigits)
Definition: mathplot.h:803
virtual bool IsHorizontal() override
Definition: mathplot.h:848
#define mpALIGN_CENTER
Aligns label to the center.
Definition: mathplot.h:478
double GetMinY() override
Returns the actual minimum Y data (loaded in SetData).
Definition: mathplot.h:1581
wxString m_name
Definition: mathplot.h:316
mpPolygon(const wxString &layerName=wxT(""))
Default constructor.
Definition: mathplot.h:1879
int m_scrY
Definition: mathplot.h:1478
virtual double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:1725
bool m_enableLimitedView
Definition: mathplot.h:1493
wxMenu m_popmenu
Definition: mathplot.h:1462
int GetXScreen(void) const
Definition: mathplot.h:1128
double m_maxX
Definition: mathplot.h:1470
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:436
wxColour m_bgColour
Definition: mathplot.h:1465
double GetYscl() const
Get current view's Y scale.
Definition: mathplot.h:1104
int m_nameFlags
Definition: mathplot.h:827
bool m_enableDoubleBuffer
Definition: mathplot.h:1491
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:1321
mpScaleY * m_masterScale
Definition: mathplot.h:989
std::vector< double > m_tickValues
Definition: mathplot.h:821
int m_scrX
Definition: mathplot.h:1477
class WXDLLIMPEXP_MATHPLOT mpScaleX
Definition: mathplot.h:105
class WXDLLIMPEXP_MATHPLOT mpFY
Definition: mathplot.h:102
class WXDLLIMPEXP_MATHPLOT mpText
Definition: mathplot.h:108
virtual double GetMaxX() override
Get inclusive right border of bounding box.
Definition: mathplot.h:1729
wxBitmap * m_buff_bmp
Definition: mathplot.h:1490
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:554
void SetSegments(int segments)
Definition: mathplot.h:1830
double GetDesiredYmax()
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
Definition: mathplot.h:1297
virtual double getTickPos(int n)
Definition: mathplot.h:806
double m_maxY
Definition: mathplot.h:1472
virtual double TransformFromPlot(double xplot)
Definition: mathplot.h:768
#define min(a, b)
Definition: auxiliary.h:85
int m_offsety
Definition: mathplot.h:1645
double m_bbox_min_y
Definition: mathplot.h:1771
virtual double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:1950