KiCad PCB EDA Suite
mathplot.h
Go to the documentation of this file.
1 // Name: mathplot.cpp
3 // Purpose: Framework for plotting in wxWindows
4 // Original Author: David Schalig
5 // Maintainer: Davide Rondini
6 // Contributors: Jose Luis Blanco, Val Greene, Maciej Suminski, Tomasz Wlostowski
7 // Created: 21/07/2003
8 // Last edit: 05/08/2016
9 // Copyright: (c) David Schalig, Davide Rondini
10 // Licence: wxWindows licence
12 
13 #ifndef _MP_MATHPLOT_H_
14 #define _MP_MATHPLOT_H_
15 
54 // this definition uses windows dll to export function.
55 // WXDLLIMPEXP_MATHPLOT definition definition changed to WXDLLIMPEXP_MATHPLOT
56 // mathplot_EXPORTS will be defined by cmake
57 #ifdef mathplot_EXPORTS
58 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
59 #define WXDLLIMPEXP_DATA_MATHPLOT( type ) WXEXPORT type
60 #else // not making DLL
61 #define WXDLLIMPEXP_MATHPLOT
62 #define WXDLLIMPEXP_DATA_MATHPLOT( type ) type
63 #endif
64 
65 #include <vector>
66 
67 // #include <wx/wx.h>
68 #include <wx/defs.h>
69 #include <wx/menu.h>
70 #include <wx/scrolwin.h>
71 #include <wx/event.h>
72 #include <wx/dynarray.h>
73 #include <wx/pen.h>
74 #include <wx/dcmemory.h>
75 #include <wx/string.h>
76 #include <wx/print.h>
77 #include <wx/image.h>
78 
79 
80 #include <deque>
81 
82 // For memory leak debug
83 #ifdef _WINDOWS
84 #ifdef _DEBUG
85 #include <crtdbg.h>
86 #define DEBUG_NEW new (_NORMAL_BLOCK, __FILE__, __LINE__)
87 #else
88 #define DEBUG_NEW new
89 #endif // _DEBUG
90 #endif // _WINDOWS
91 
92 // Separation for axes when set close to border
93 #define X_BORDER_SEPARATION 40
94 #define Y_BORDER_SEPARATION 60
95 
96 // -----------------------------------------------------------------------------
97 // classes
98 // -----------------------------------------------------------------------------
99 
110 
112 enum
113 {
114  mpID_FIT = 2000, // !< Fit view to match bounding box of all layers
115  mpID_ZOOM_IN, // !< Zoom into view at clickposition / window center
116  mpID_ZOOM_OUT, // !< Zoom out
117  mpID_CENTER, // !< Center view on click position
118  mpID_LOCKASPECT, // !< Lock x/y scaling aspect
119 };
120 
121 // -----------------------------------------------------------------------------
122 // mpLayer
123 // -----------------------------------------------------------------------------
124 
125 typedef enum __mp_Layer_Type
126 {
127  mpLAYER_UNDEF, // !< Layer type undefined
128  mpLAYER_AXIS, // !< Axis type layer
129  mpLAYER_PLOT, // !< Plot type layer
130  mpLAYER_INFO, // !< Info box type layer
131  mpLAYER_BITMAP // !< Bitmap type layer
132 } mpLayerType;
133 
144 class mpScaleBase;
145 
146 class WXDLLIMPEXP_MATHPLOT mpLayer : public wxObject
147 {
148 public:
149  mpLayer();
150 
151  virtual ~mpLayer() {};
152 
160  virtual bool HasBBox() { return TRUE; }
161 
169  virtual bool IsInfo() { return false; };
170 
174  virtual double GetMinX() { return -1.0; }
175 
179  virtual double GetMaxX() { return 1.0; }
180 
184  virtual double GetMinY() { return -1.0; }
185 
189  virtual double GetMaxY() { return 1.0; }
190 
232  virtual void Plot( wxDC& dc, mpWindow& w ) = 0;
233 
237  const wxString& GetName() const { return m_name; }
238 
242  const wxFont& GetFont() const { return m_font; }
243 
247  const wxPen& GetPen() const { return m_pen; }
248 
252  void SetContinuity( bool continuity ) { m_continuous = continuity; }
253 
257  bool GetContinuity() const { return m_continuous; }
258 
261  void ShowName( bool show ) { m_showName = show; };
262 
266  void SetName( wxString name ) { m_name = name; }
267 
271  void SetFont( wxFont& font ) { m_font = font; }
272 
276  void SetPen( wxPen pen ) { m_pen = pen; }
277 
280  void SetDrawOutsideMargins( bool drawModeOutside ) { m_drawOutsideMargins = drawModeOutside; };
281 
284  bool GetDrawOutsideMargins() { return m_drawOutsideMargins; };
285 
289  wxBitmap GetColourSquare( int side = 16 );
290 
293  mpLayerType GetLayerType() { return m_type; };
294 
297  bool IsVisible() { return m_visible; };
298 
301  void SetVisible( bool show ) { m_visible = show; };
302 
305  const wxBrush& GetBrush() const { return m_brush; };
306 
309  void SetBrush( wxBrush brush ) { m_brush = brush; };
310 
311 protected:
312 
313  wxFont m_font; // !< Layer's font
314  wxPen m_pen; // !< Layer's pen
315  wxBrush m_brush; // !< Layer's brush
316  wxString m_name; // !< Layer's name
317  bool m_continuous; // !< Specify if the layer will be plotted as a continuous line or a set of points.
318  bool m_showName; // !< States whether the name of the layer must be shown (default is true).
319  bool m_drawOutsideMargins; // !< select if the layer should draw only inside margins or over all DC
320  mpLayerType m_type; // !< Define layer type, which is assigned by constructor
321  bool m_visible; // !< Toggles layer visibility
322  DECLARE_DYNAMIC_CLASS( mpLayer )
323 };
324 
325 
326 // -----------------------------------------------------------------------------
327 // mpInfoLayer
328 // -----------------------------------------------------------------------------
329 
335 {
336 public:
338  mpInfoLayer();
339 
343  mpInfoLayer( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
344 
346  virtual ~mpInfoLayer();
347 
352  virtual void UpdateInfo( mpWindow& w, wxEvent& event );
353 
356  virtual bool HasBBox() override { return false; }
357 
362  virtual void Plot( wxDC& dc, mpWindow& w ) override;
363 
367  virtual bool IsInfo() override { return true; }
368 
372  virtual bool Inside( wxPoint& point );
373 
376  virtual void Move( wxPoint delta );
377 
379  virtual void UpdateReference();
380 
383  wxPoint GetPosition();
384 
387  wxSize GetSize();
388 
391  const wxRect& GetRectangle() { return m_dim; };
392 
393 protected:
394  wxRect m_dim; // !< The bounding rectangle of the box. It may be resized dynamically by the Plot method.
395  wxPoint m_reference; // !< Holds the reference point for movements
396  wxBrush m_brush; // !< The brush to be used for the background
397  int m_winX, m_winY; // !< Holds the mpWindow size. Used to rescale position when window is resized.
398 
399  DECLARE_DYNAMIC_CLASS( mpInfoLayer )
400 };
401 
406 {
407 public:
409  mpInfoCoords();
413  mpInfoCoords( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
414 
416  ~mpInfoCoords();
417 
421  virtual void UpdateInfo( mpWindow& w, wxEvent& event ) override;
422 
427  virtual void Plot( wxDC& dc, mpWindow& w ) override;
428 
429 protected:
430  wxString m_content; // !< string holding the coordinates to be drawn.
431 };
432 
437 {
438 public:
440  mpInfoLegend();
441 
446  mpInfoLegend( wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH );
447 
449  ~mpInfoLegend();
450 
454  virtual void UpdateInfo( mpWindow& w, wxEvent& event ) override;
455 
460  virtual void Plot( wxDC& dc, mpWindow& w ) override;
461 
462 protected:
463 };
464 
465 
466 // -----------------------------------------------------------------------------
467 // mpLayer implementations - functions
468 // -----------------------------------------------------------------------------
469 
474 #define mpALIGNMASK 0x03
475 
476 #define mpALIGN_RIGHT 0x00
477 
478 #define mpALIGN_CENTER 0x01
479 
480 #define mpALIGN_LEFT 0x02
481 
482 #define mpALIGN_TOP mpALIGN_RIGHT
483 
484 #define mpALIGN_BOTTOM mpALIGN_LEFT
485 
486 #define mpALIGN_BORDER_BOTTOM 0x04
487 
488 #define mpALIGN_BORDER_TOP 0x05
489 
490 #define mpX_NORMAL 0x00
491 
492 #define mpX_TIME 0x01
493 
494 #define mpX_HOURS 0x02
495 
496 #define mpX_DATE 0x03
497 
498 #define mpX_DATETIME 0x04
499 
500 #define mpALIGN_BORDER_LEFT mpALIGN_BORDER_BOTTOM
501 
502 #define mpALIGN_BORDER_RIGHT mpALIGN_BORDER_TOP
503 
504 #define mpALIGN_NE 0x00
505 
506 #define mpALIGN_NW 0x01
507 
508 #define mpALIGN_SW 0x02
509 
510 #define mpALIGN_SE 0x03
511 
523 {
524 public:
528  mpFX( const wxString& name = wxEmptyString, int flags = mpALIGN_RIGHT );
529 
535  virtual double GetY( double x ) = 0;
536 
541  virtual void Plot( wxDC& dc, mpWindow& w ) override;
542 
543 protected:
544  int m_flags; // !< Holds label alignment
545 
546  DECLARE_DYNAMIC_CLASS( mpFX )
547 };
548 
555 {
556 public:
560  mpFY( const wxString& name = wxEmptyString, int flags = mpALIGN_TOP );
561 
567  virtual double GetX( double y ) = 0;
568 
573  virtual void Plot( wxDC& dc, mpWindow& w ) override;
574 
575 protected:
576  int m_flags; // !< Holds label alignment
577 
578  DECLARE_DYNAMIC_CLASS( mpFY )
579 };
580 
589 {
590 public:
594  mpFXY( const wxString& name = wxEmptyString, int flags = mpALIGN_NE );
595 
599  virtual void Rewind() = 0;
600 
606  virtual bool GetNextXY( double& x, double& y ) = 0;
607 
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( const 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 
704  void SetAlign( int align ) { m_flags = align; };
705 
706  void SetNameAlign( int align ) { m_nameFlags = align; }
707 
711  void SetTicks( bool enable ) { m_ticks = enable; };
712 
716  bool GetTicks() { return m_ticks; };
717 
718 
719  // virtual double X2p( mpWindow &w, double x ) = 0;
720  // virtual double P2x( mpWindow &w, double x ) = 0;
721 
722  void SetDataRange( double minV, double maxV )
723  {
724  m_rangeSet = true;
725  m_minV = minV;
726  m_maxV = maxV;
727  }
728 
729  void GetDataRange( double& minV, double& maxV )
730  {
731  minV = m_minV;
732  maxV = m_maxV;
733  }
734 
735  void ExtendDataRange( double minV, double maxV )
736  {
737  if( !m_rangeSet )
738  {
739  m_minV = minV;
740  m_maxV = maxV;
741  m_rangeSet = true;
742  }
743  else
744  {
745  m_minV = std::min( minV, m_minV );
746  m_maxV = std::max( maxV, m_maxV );
747  }
748 
749  if( m_minV == m_maxV )
750  {
751  m_minV = m_minV - 1.0;
752  m_maxV = m_maxV + 1.0;
753  }
754  }
755 
757  {
758  m_rangeSet = 0;
759  }
760 
761  double AbsMaxValue() const
762  {
763  return std::max( std::abs( m_maxV ), std::abs( m_minV ) );
764  }
765 
766  double AbsVisibleMaxValue() const
767  {
768  return m_absVisibleMaxV;
769  }
770 
771  virtual double TransformToPlot( double x ) { return 0.0; };
772  virtual double TransformFromPlot( double xplot ) { return 0.0; };
773 
774  struct TickLabel
775  {
776  TickLabel( double pos_ = 0.0, const wxString& label_ = wxT("") ) :
777  pos( pos_ ), label( label_ ), pixelPos( 0 ), visible( true )
778  {}
779 
780  double pos;
781  wxString label;
782  int pixelPos;
783  bool visible;
784  };
785 
786  std::vector<TickLabel>& TickLabels() { return m_tickLabels; };
787 
788 protected:
789 
790  void updateTickLabels( wxDC& dc, mpWindow& w );
791  void computeLabelExtents( wxDC& dc, mpWindow& w );
792 
793  // virtual int getLabelDecimalDigits(int maxDigits);
794  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) {};
795  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) {};
796 
797  int tickCount() const
798  {
799  return m_tickValues.size();
800  }
801 
802  virtual int labelCount() const
803  {
804  return m_tickLabels.size();
805  }
806 
807  virtual const wxString formatLabel( double value, int nDigits ) { return wxT( "" ); }
808  virtual void formatLabels() {};
809 
810  virtual double getTickPos( int n )
811  {
812  return m_tickValues[n];
813  }
814 
815  virtual double getLabelPos( int n )
816  {
817  return m_tickLabels[n].pos;
818  }
819 
820  virtual const wxString getLabel( int n )
821  {
822  return m_tickLabels[n].label;
823  }
824 
825  std::vector<double> m_tickValues;
826  std::vector<TickLabel> m_tickLabels;
827 
828  double m_offset, m_scale;
830  int m_flags; // !< Flag for axis alignment
832  bool m_ticks; // !< Flag to toggle between ticks or grid
833  double m_minV, m_maxV;
837 };
838 
840 {
841 public:
848  mpScaleXBase( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER,
849  bool ticks = true, unsigned int type = mpX_NORMAL );
850  virtual ~mpScaleXBase() {};
851 
852  virtual bool IsHorizontal() override { return true; }
855  virtual void Plot( wxDC& dc, mpWindow& w ) override;
856 
857  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) override;
858 
859  // unsigned int m_labelType; //!< Select labels mode: mpX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds
860  // wxString m_labelFormat; //!< Format string used to print labels
861 
862  DECLARE_DYNAMIC_CLASS( mpScaleXBase )
863 };
864 
865 
867 {
868 public:
874  mpScaleX( const wxString& name = wxT("X"), int flags = mpALIGN_CENTER,
875  bool ticks = true, unsigned int type = mpX_NORMAL );
876 
879  // virtual void Plot(wxDC & dc, mpWindow & w);
880 
881  // virtual double X2p( mpWindow &w, double x );
882  // virtual double P2x( mpWindow &w, double x );
883  virtual double TransformToPlot( double x ) override;
884  virtual double TransformFromPlot( double xplot ) override;
885 
886 protected:
887  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override;
888 
889 
890  DECLARE_DYNAMIC_CLASS( mpScaleX )
891 };
892 
893 
895 {
896 public:
903  mpScaleXLog( const wxString& name = wxT("log(X)"), int flags = mpALIGN_CENTER,
904  bool ticks = true, unsigned int type = mpX_NORMAL );
905 
906  virtual double TransformToPlot( double x ) override;
907  virtual double TransformFromPlot( double xplot ) override;
908 
912  // virtual double X2p( mpWindow &w, double x );
913  // virtual double P2x( mpWindow &w, double x );
914 
915 protected:
916  void recalculateTicks( wxDC& dc, mpWindow& w ) override;
917 
918  // int tickCount() const;
919  // int labelCount() const;
920  // const wxString getLabel( int n );
921  // double getTickPos( int n );
922  // double getLabelPos( int n );
923 
924  void computeLabelExtents( wxDC& dc, mpWindow& w );
925 
926 
927  DECLARE_DYNAMIC_CLASS( mpScaleXLog )
928 };
929 
930 
939 {
940 public:
945  mpScaleY( const wxString& name = wxT("Y"), int flags = mpALIGN_CENTER, bool ticks = true );
946 
947  virtual bool IsHorizontal() override { return false; }
948 
952  virtual void Plot( wxDC& dc, mpWindow& w ) override;
953 
958  virtual bool HasBBox() override { return FALSE; }
959 
962  void SetAlign( int align ) { m_flags = align; };
963 
966  void SetTicks( bool ticks ) { m_ticks = ticks; };
967 
970  bool GetTicks() { return m_ticks; };
971 
972  virtual double TransformToPlot( double x ) override;
973  virtual double TransformFromPlot( double xplot ) override;
974 
975 
976  void SetMasterScale( mpScaleY* masterScale )
977  {
978  m_masterScale = masterScale;
979  }
980 
981 protected:
982  virtual void getVisibleDataRange( mpWindow& w, double& minV, double& maxV ) override;
983  virtual void recalculateTicks( wxDC& dc, mpWindow& w ) override;
984 
985  // virtual int tickCount() const;
986  // virtual int labelCount() const;
987  // virtual const wxString getLabel( int n );
988  // virtual double getTickPos( int n );
989  // virtual double getLabelPos( int n );
990  void computeLabelExtents( wxDC& dc, mpWindow& w );
991  void computeSlaveTicks( mpWindow& w );
992 
994 
995  // double m_minV, m_maxV;
996 
997  int m_flags; // !< Flag for axis alignment
998  bool m_ticks; // !< Flag to toggle between ticks or grid
999  // wxString m_labelFormat; //!< Format string used to print labels
1000 
1001  DECLARE_DYNAMIC_CLASS( mpScaleY )
1002 };
1003 
1004 // -----------------------------------------------------------------------------
1005 // mpWindow
1006 // -----------------------------------------------------------------------------
1007 
1012 #define mpMOUSEMODE_DRAG 0
1013 
1014 #define mpMOUSEMODE_ZOOMBOX 1
1015 
1018 // WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, wxLayerList );
1019 typedef std::deque<mpLayer*> wxLayerList;
1020 
1043 class WXDLLIMPEXP_MATHPLOT mpWindow : public wxWindow
1044 {
1045 public:
1047  mpWindow( wxWindow* parent, wxWindowID id,
1048  const wxPoint& pos = wxDefaultPosition,
1049  const wxSize& size = wxDefaultSize,
1050  long flags = 0 );
1051  ~mpWindow();
1052 
1056  wxMenu* GetPopupMenu() { return &m_popmenu; }
1057 
1065  bool AddLayer( mpLayer* layer, bool refreshDisplay = true );
1066 
1075  bool DelLayer( mpLayer* layer, bool alsoDeleteObject = false, bool refreshDisplay = true );
1076 
1081  void DelAllLayers( bool alsoDeleteObject, bool refreshDisplay = true );
1082 
1083 
1089  mpLayer* GetLayer( int position );
1090 
1095  mpLayer* GetLayerByName( const wxString& name );
1096 
1101  double GetXscl() { return m_scaleX; }
1102  double GetScaleX( void ) const { return m_scaleX; }; // Schaling's method: maybe another method esists with the same name
1103 
1108  double GetYscl() const { return m_scaleY; }
1109  double GetScaleY( void ) const { return m_scaleY; } // Schaling's method: maybe another method exists with the same name
1110 
1115  double GetXpos() const { return m_posX; }
1116  double GetPosX( void ) const { return m_posX; }
1117 
1122  double GetYpos() const { return m_posY; }
1123  double GetPosY( void ) const { return m_posY; }
1124 
1131  int GetScrX( void ) const { return m_scrX; }
1132  int GetXScreen( void ) const { return m_scrX; }
1133 
1140  int GetScrY( void ) const { return m_scrY; }
1141  int GetYScreen( void ) const { return m_scrY; }
1142 
1146  void SetScaleX( double scaleX );
1147 
1151  void SetScaleY( double scaleY )
1152  {
1153  if( scaleY!=0 )
1154  m_scaleY = scaleY;
1155 
1156  UpdateAll();
1157  }
1158 
1162  void SetPosX( double posX ) { m_posX = posX; UpdateAll(); }
1163 
1167  void SetPosY( double posY ) { m_posY = posY; UpdateAll(); }
1168 
1173  void SetPos( double posX, double posY ) { m_posX = posX; m_posY = posY; UpdateAll(); }
1174 
1180  void SetScr( int scrX, int scrY ) { m_scrX = scrX; m_scrY = scrY; }
1181 
1184  // double p2x(wxCoord pixelCoordX, bool drawOutside = true ); // { return m_posX + pixelCoordX/m_scaleX; }
1185  inline double p2x( wxCoord pixelCoordX ) { return m_posX + pixelCoordX / m_scaleX; }
1186 
1189  // double p2y(wxCoord pixelCoordY, bool drawOutside = true ); //{ return m_posY - pixelCoordY/m_scaleY; }
1190  inline double p2y( wxCoord pixelCoordY ) { return m_posY - pixelCoordY / m_scaleY; }
1191 
1194  // wxCoord x2p(double x, bool drawOutside = true); // { return (wxCoord) ( (x-m_posX) * m_scaleX); }
1195  inline wxCoord x2p( double x ) { return (wxCoord) ( (x - m_posX) * m_scaleX ); }
1196 
1199  // wxCoord y2p(double y, bool drawOutside = true); // { return (wxCoord) ( (m_posY-y) * m_scaleY); }
1200  inline wxCoord y2p( double y ) { return (wxCoord) ( (m_posY - y) * m_scaleY ); }
1201 
1202 
1205  void EnableDoubleBuffer( bool enabled ) { m_enableDoubleBuffer = enabled; }
1206 
1209  void EnableMousePanZoom( bool enabled ) { m_enableMouseNavigation = enabled; }
1210 
1216  void LockAspect( bool enable = TRUE );
1217 
1222  inline bool IsAspectLocked() { return m_lockaspect; }
1223 
1228  void Fit() override;
1229 
1236  void Fit( double xMin, double xMax, double yMin, double yMax,
1237  wxCoord* printSizeX = NULL, wxCoord* printSizeY = NULL );
1238 
1243  void ZoomIn( const wxPoint& centerPoint = wxDefaultPosition );
1244 
1249  void ZoomOut( const wxPoint& centerPoint = wxDefaultPosition );
1250 
1252  void ZoomInX();
1253 
1255  void ZoomOutX();
1256 
1258  void ZoomInY();
1259 
1261  void ZoomOutY();
1262 
1265  void ZoomRect( wxPoint p0, wxPoint p1 );
1266 
1268  void UpdateAll();
1269 
1270  // Added methods by Davide Rondini
1271 
1276  unsigned int CountLayers();
1277 
1280  unsigned int CountAllLayers() { return m_layers.size(); };
1281 
1282 #if 0
1283 
1286  void PrintGraph(mpPrintout *print);
1287 #endif
1288 
1293  double GetDesiredXmin() { return m_desiredXmin; }
1294 
1299  double GetDesiredXmax() { return m_desiredXmax; }
1300 
1305  double GetDesiredYmin() { return m_desiredYmin; }
1306 
1311  double GetDesiredYmax() { return m_desiredYmax; }
1312 
1316  void GetBoundingBox( double* bbox );
1317 
1320  void SetMPScrollbars( bool status );
1321 
1324  bool GetMPScrollbars() { return m_enableScrollBars; };
1325 
1331  bool SaveScreenshot( const wxString& filename, wxBitmapType type = wxBITMAP_TYPE_BMP,
1332  wxSize imageSize = wxDefaultSize, bool fit = false );
1333 
1338  static double zoomIncrementalFactor;
1339 
1346  void SetMargins( int top, int right, int bottom, int left );
1347 
1349  void SetMarginTop( int top ) { m_marginTop = top; };
1351  void SetMarginRight( int right ) { m_marginRight = right; };
1353  void SetMarginBottom( int bottom ) { m_marginBottom = bottom; };
1355  void SetMarginLeft( int left ) { m_marginLeft = left; };
1356 
1358  int GetMarginTop() { return m_marginTop; };
1360  int GetMarginRight() { return m_marginRight; };
1362  int GetMarginBottom() { return m_marginBottom; };
1364  int GetMarginLeft() { return m_marginLeft; };
1365 
1366 #if 0
1367 
1370  // void EnableCoordTooltip(bool value = true);
1371 
1375  // bool GetCoordTooltip() { return m_coordTooltip; };
1376 #endif
1377 
1381  mpInfoLayer* IsInsideInfoLayer( wxPoint& point );
1382 
1386  void SetLayerVisible( const wxString& name, bool viewable );
1387 
1391  bool IsLayerVisible( const wxString& name );
1392 
1396  void SetLayerVisible( const unsigned int position, bool viewable );
1397 
1401  bool IsLayerVisible( const unsigned int position );
1402 
1407  void SetColourTheme( const wxColour& bgColour,
1408  const wxColour& drawColour,
1409  const wxColour& axesColour );
1410 
1413  const wxColour& GetAxesColour() { return m_axColour; };
1414 
1416  void LimitView( bool aEnable )
1417  {
1418  m_enableLimitedView = aEnable;
1419  }
1420 
1421 protected:
1422  void OnPaint( wxPaintEvent& event ); // !< Paint handler, will plot all attached layers
1423  void OnSize( wxSizeEvent& event ); // !< Size handler, will update scroll bar sizes
1424 
1425  // void OnScroll2 (wxScrollWinEvent &event); //!< Scroll handler, will move canvas
1426  void OnShowPopupMenu( wxMouseEvent& event ); // !< Mouse handler, will show context menu
1427  void OnMouseMiddleDown( wxMouseEvent& event ); // !< Mouse handler, for detecting when the user
1428 
1429  // !< drags with the middle button or just "clicks" for the menu
1430  void OnCenter( wxCommandEvent& event ); // !< Context menu handler
1431  void OnFit( wxCommandEvent& event ); // !< Context menu handler
1432  void OnZoomIn( wxCommandEvent& event ); // !< Context menu handler
1433  void OnZoomOut( wxCommandEvent& event ); // !< Context menu handler
1434  void OnLockAspect( wxCommandEvent& event ); // !< Context menu handler
1435  void OnMouseWheel( wxMouseEvent& event ); // !< Mouse handler for the wheel
1436  void OnMouseMove( wxMouseEvent& event ); // !< Mouse handler for mouse motion (for pan)
1437  void OnMouseLeftDown( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1438  void OnMouseLeftRelease( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1439  void OnScrollThumbTrack( wxScrollWinEvent& event ); // !< Scroll thumb on scroll bar moving
1440  void OnScrollPageUp( wxScrollWinEvent& event ); // !< Scroll page up
1441  void OnScrollPageDown( wxScrollWinEvent& event ); // !< Scroll page down
1442  void OnScrollLineUp( wxScrollWinEvent& event ); // !< Scroll line up
1443  void OnScrollLineDown( wxScrollWinEvent& event ); // !< Scroll line down
1444  void OnScrollTop( wxScrollWinEvent& event ); // !< Scroll to top
1445  void OnScrollBottom( wxScrollWinEvent& event ); // !< Scroll to bottom
1446 
1447  void DoScrollCalc( const int position, const int orientation );
1448 
1449  void DoZoomInXCalc( const int staticXpixel );
1450  void DoZoomInYCalc( const int staticYpixel );
1451  void DoZoomOutXCalc( const int staticXpixel );
1452  void DoZoomOutYCalc( const int staticYpixel );
1453 
1454  bool CheckXLimits( double& desiredMax, double& desiredMin ) const
1455  {
1456  return !( m_enableLimitedView
1457  && (desiredMax > m_maxX - m_marginRight / m_scaleX
1458  || desiredMin < m_minX - m_marginLeft / m_scaleX) );
1459  }
1460 
1461  bool CheckYLimits( double& desiredMax, double& desiredMin ) const
1462  {
1463  return !( m_enableLimitedView
1464  && (desiredMax > m_maxY + m_marginBottom / m_scaleY
1465  || desiredMin < m_minY + m_marginTop / m_scaleY) );
1466  }
1467 
1468  void AdjustLimitedView();
1469 
1473  virtual bool UpdateBBox();
1474 
1478  virtual bool SetXView( double pos, double desiredMax, double desiredMin );
1479 
1483  virtual bool SetYView( double pos, double desiredMax, double desiredMin );
1484 
1485  // wxList m_layers; //!< List of attached plot layers
1486  wxLayerList m_layers; // !< List of attached plot layers
1487  wxMenu m_popmenu; // !< Canvas' context menu
1488  bool m_lockaspect; // !< Scale aspect is locked or not
1489  // bool m_coordTooltip; //!< Selects whether to show coordinate tooltip
1490  wxColour m_bgColour; // !< Background Colour
1491  wxColour m_fgColour; // !< Foreground Colour
1492  wxColour m_axColour; // !< Axes Colour
1493 
1494  double m_minX; // !< Global layer bounding box, left border incl.
1495  double m_maxX; // !< Global layer bounding box, right border incl.
1496  double m_minY; // !< Global layer bounding box, bottom border incl.
1497  double m_maxY; // !< Global layer bounding box, top border incl.
1498  double m_scaleX; // !< Current view's X scale
1499  double m_scaleY; // !< Current view's Y scale
1500  double m_posX; // !< Current view's X position
1501  double m_posY; // !< Current view's Y position
1502  int m_scrX; // !< Current view's X dimension
1503  int m_scrY; // !< Current view's Y dimension
1504  int m_clickedX; // !< Last mouse click X position, for centering and zooming the view
1505  int m_clickedY; // !< Last mouse click Y position, for centering and zooming the view
1506 
1510  double m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax;
1511 
1512  int m_marginTop, m_marginRight, m_marginBottom, m_marginLeft;
1513 
1514  int m_last_lx, m_last_ly; // !< For double buffering
1515  wxMemoryDC m_buff_dc; // !< For double buffering
1516  wxBitmap* m_buff_bmp; // !< For double buffering
1517  bool m_enableDoubleBuffer; // !< For double buffering
1518  bool m_enableMouseNavigation; // !< For pan/zoom with the mouse.
1520  wxPoint m_mouseMClick; // !< For the middle button "drag" feature
1521  wxPoint m_mouseLClick; // !< Starting coords for rectangular zoom selection
1523  wxPoint m_scroll;
1524  mpInfoLayer* m_movingInfoLayer; // !< For moving info layers over the window area
1526  wxRect m_zoomRect;
1527  DECLARE_DYNAMIC_CLASS( mpWindow )
1528  DECLARE_EVENT_TABLE()
1529 };
1530 
1531 // -----------------------------------------------------------------------------
1532 // mpFXYVector - provided by Jose Luis Blanco
1533 // -----------------------------------------------------------------------------
1534 
1555 {
1556 public:
1560  mpFXYVector( const wxString& name = wxEmptyString, int flags = mpALIGN_NE );
1561 
1562  virtual ~mpFXYVector() {}
1563 
1568  virtual void SetData( const std::vector<double>& xs, const std::vector<double>& ys );
1569 
1573  void Clear();
1574 
1575 protected:
1578  std::vector<double> m_xs, m_ys;
1579 
1582  size_t m_index;
1583 
1586  double m_minX, m_maxX, m_minY, m_maxY;
1587 
1591  void Rewind() override;
1592 
1598  bool GetNextXY( double& x, double& y ) override;
1599 
1600 public:
1603  double GetMinX() override { return m_minX; }
1604 
1607  double GetMinY() override { return m_minY; }
1608 
1611  double GetMaxX() override { return m_maxX; }
1612 
1615  double GetMaxY() override { return m_maxY; }
1616 
1617 protected:
1618 
1619  DECLARE_DYNAMIC_CLASS( mpFXYVector )
1620 };
1621 
1622 
1623 #if 0
1624 
1625 class WXDLLIMPEXP_MATHPLOT mpFSemiLogXVector : public mpFXYVector
1626 {
1627 public:
1631  mpFSemiLogXVector( wxString name = wxEmptyString, int flags = mpALIGN_NE );
1632 
1633  virtual ~mpFSemiLogXVector() {}
1634 
1640  DECLARE_DYNAMIC_CLASS( mpFSemiLogXVector )
1641 };
1642 #endif
1643 
1644 // -----------------------------------------------------------------------------
1645 // mpText - provided by Val Greene
1646 // -----------------------------------------------------------------------------
1647 
1655 {
1656 public:
1660  mpText( const wxString& name = wxT("Title"), int offsetx = 5, int offsety = 50 );
1661 
1664  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1665 
1667  virtual bool HasBBox() override { return FALSE; }
1668 
1669 protected:
1670  int m_offsetx; // !< Holds offset for X in percentage
1671  int m_offsety; // !< Holds offset for Y in percentage
1672 
1673  DECLARE_DYNAMIC_CLASS( mpText )
1674 };
1675 
1676 
1677 // -----------------------------------------------------------------------------
1678 // mpPrintout - provided by Davide Rondini
1679 // -----------------------------------------------------------------------------
1680 
1685 class WXDLLIMPEXP_MATHPLOT mpPrintout : public wxPrintout
1686 {
1687 public:
1688  mpPrintout( mpWindow* drawWindow, const wxChar* title = _T("wxMathPlot print output") );
1689  virtual ~mpPrintout() {};
1690 
1691  void SetDrawState( bool drawState ) { drawn = drawState; };
1692  bool OnPrintPage( int page ) override;
1693  bool HasPage( int page ) override;
1694 
1695 private:
1696  bool drawn;
1698 };
1699 
1700 
1701 // -----------------------------------------------------------------------------
1702 // mpMovableObject - provided by Jose Luis Blanco
1703 // -----------------------------------------------------------------------------
1711 {
1712 public:
1716  m_reference_x( 0 ),
1717  m_reference_y( 0 ),
1718  m_reference_phi( 0 ),
1719  m_shape_xs( 0 ),
1720  m_shape_ys( 0 )
1721  {
1722  m_type = mpLAYER_PLOT;
1723  }
1724 
1725  virtual ~mpMovableObject() {};
1726 
1729  void GetCoordinateBase( double& x, double& y, double& phi ) const
1730  {
1731  x = m_reference_x;
1732  y = m_reference_y;
1733  phi = m_reference_phi;
1734  }
1735 
1738  void SetCoordinateBase( double x, double y, double phi = 0 )
1739  {
1740  m_reference_x = x;
1741  m_reference_y = y;
1742  m_reference_phi = phi;
1743  m_flags = mpALIGN_NE;
1744  ShapeUpdated();
1745  }
1746 
1747  virtual bool HasBBox() override { return m_trans_shape_xs.size()!=0; }
1748 
1751  virtual double GetMinX() override { return m_bbox_min_x; }
1752 
1755  virtual double GetMaxX() override { return m_bbox_max_x; }
1756 
1759  virtual double GetMinY() override { return m_bbox_min_y; }
1760 
1763  virtual double GetMaxY() override { return m_bbox_max_y; }
1764 
1765  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1766 
1770  void SetAlign( int align ) { m_flags = align; };
1771 
1772 protected:
1773  int m_flags; // !< Holds label alignment
1774 
1777  double m_reference_x, m_reference_y, m_reference_phi;
1778 
1782  void TranslatePoint( double x, double y, double& out_x, double& out_y );
1783 
1787  std::vector<double> m_shape_xs, m_shape_ys;
1788 
1792  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
1793 
1797  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
1798 
1803  void ShapeUpdated();
1804 };
1805 
1806 // -----------------------------------------------------------------------------
1807 // mpCovarianceEllipse - provided by Jose Luis Blanco
1808 // -----------------------------------------------------------------------------
1821 {
1822 public:
1827  mpCovarianceEllipse( double cov_00 = 1,
1828  double cov_11 = 1,
1829  double cov_01 = 0,
1830  double quantiles = 2,
1831  int segments = 32,
1832  const wxString& layerName = wxT("") ) :
1833  m_cov_00( cov_00 ),
1834  m_cov_11( cov_11 ),
1835  m_cov_01( cov_01 ),
1836  m_quantiles( quantiles ),
1837  m_segments( segments )
1838  {
1839  m_continuous = true;
1840  m_name = layerName;
1841  RecalculateShape();
1842  m_type = mpLAYER_PLOT;
1843  }
1844 
1846 
1847  double GetQuantiles() const { return m_quantiles; }
1848 
1851  void SetQuantiles( double q )
1852  {
1853  m_quantiles = q;
1854  RecalculateShape();
1855  }
1856 
1857  void SetSegments( int segments ) { m_segments = segments; }
1858  int GetSegments() const { return m_segments; }
1859 
1862  void GetCovarianceMatrix( double& cov_00, double& cov_01, double& cov_11 ) const
1863  {
1864  cov_00 = m_cov_00;
1865  cov_01 = m_cov_01;
1866  cov_11 = m_cov_11;
1867  }
1868 
1871  void SetCovarianceMatrix( double cov_00, double cov_01, double cov_11 )
1872  {
1873  m_cov_00 = cov_00;
1874  m_cov_01 = cov_01;
1875  m_cov_11 = cov_11;
1876  RecalculateShape();
1877  }
1878 
1879 protected:
1882  double m_cov_00, m_cov_11, m_cov_01;
1883  double m_quantiles;
1884 
1888 
1891  void RecalculateShape();
1892 };
1893 
1894 // -----------------------------------------------------------------------------
1895 // mpPolygon - provided by Jose Luis Blanco
1896 // -----------------------------------------------------------------------------
1902 {
1903 public:
1906  mpPolygon( const wxString& layerName = wxT("") )
1907  {
1908  m_continuous = true;
1909  m_name = layerName;
1910  }
1911 
1912  virtual ~mpPolygon() {}
1913 
1919  void setPoints( const std::vector<double>& points_xs,
1920  const std::vector<double>& points_ys,
1921  bool closedShape = true );
1922 };
1923 
1924 // -----------------------------------------------------------------------------
1925 // mpMovableObject - provided by Jose Luis Blanco
1926 // -----------------------------------------------------------------------------
1934 {
1935 public:
1939  {
1940  m_min_x = m_max_x =
1941  m_min_y = m_max_y = 0;
1942  m_validImg = false;
1943  m_type = mpLAYER_BITMAP;
1944  }
1945 
1946  virtual ~mpBitmapLayer() {};
1947 
1950  void GetBitmapCopy( wxImage& outBmp ) const;
1951 
1959  void SetBitmap( const wxImage& inBmp, double x, double y, double lx, double ly );
1960 
1961  virtual bool HasBBox() override { return true; }
1962 
1965  virtual double GetMinX() override { return m_min_x; }
1966 
1969  virtual double GetMaxX() override { return m_max_x; }
1970 
1973  virtual double GetMinY() override { return m_min_y; }
1974 
1977  virtual double GetMaxY() override { return m_max_y; }
1978 
1979  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1980 
1984  void SetAlign( int align ) { m_flags = align; };
1985 
1986 protected:
1987  int m_flags; // !< Holds label alignment
1988 
1991  wxImage m_bitmap;
1992  wxBitmap m_scaledBitmap;
1993  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
1994 
1996 
1999  double m_min_x, m_max_x, m_min_y, m_max_y;
2000 };
2001 
2004 #endif // _MP_MATHPLOT_H_
int m_offsetx
Definition: mathplot.h:1670
bool GetMPScrollbars()
Get scrollbars status.
Definition: mathplot.h:1324
virtual double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:1965
mpLayerType GetLayerType()
Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc,...
Definition: mathplot.h:293
void ShowName(bool show)
Shows or hides the text label with the name of the layer (default is visible).
Definition: mathplot.h:261
class WXDLLIMPEXP_MATHPLOT mpWindow
Definition: mathplot.h:107
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition: mathplot.h:1056
virtual void recalculateTicks(wxDC &dc, mpWindow &w)
Definition: mathplot.h:795
wxMemoryDC m_buff_dc
Definition: mathplot.h:1515
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:1353
virtual ~mpScaleXBase()
Definition: mathplot.h:850
virtual double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1759
virtual bool IsInfo()
Check whether the layer is an info box.
Definition: mathplot.h:169
bool drawn
Definition: mathplot.h:1696
bool m_continuous
Definition: mathplot.h:317
bool m_enableScrollBars
Definition: mathplot.h:1522
virtual ~mpFXYVector()
Definition: mathplot.h:1562
mpWindow * plotWindow
Definition: mathplot.h:1697
wxBitmap m_scaledBitmap
Definition: mathplot.h:1992
void GetDataRange(double &minV, double &maxV)
Definition: mathplot.h:729
bool m_zooming
Definition: mathplot.h:1525
wxString m_content
Definition: mathplot.h:430
void SetNameAlign(int align)
Definition: mathplot.h:706
virtual ~mpMovableObject()
Definition: mathplot.h:1725
__mp_Layer_Type
Definition: mathplot.h:125
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:237
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:1355
double GetPosY(void) const
Definition: mathplot.h:1123
wxBrush m_brush
Definition: mathplot.h:315
int m_clickedX
Definition: mathplot.h:1504
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:1871
bool IsAspectLocked()
Checks whether the X/Y scale aspect is locked.
Definition: mathplot.h:1222
class WXDLLIMPEXP_MATHPLOT mpFXYVector
Definition: mathplot.h:104
mpWindow()
Definition: mathplot.h:1046
double GetScaleX(void) const
Definition: mathplot.h:1102
TickLabel(double pos_=0.0, const wxString &label_=wxT(""))
Definition: mathplot.h:776
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1185
bool m_ticks
Definition: mathplot.h:832
virtual ~mpLayer()
Definition: mathplot.h:151
std::vector< double > m_trans_shape_ys
Definition: mathplot.h:1792
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:1933
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:242
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:522
double m_scaleY
Definition: mathplot.h:1499
std::vector< TickLabel > & TickLabels()
Definition: mathplot.h:786
int GetXScreen(void) const
Definition: mathplot.h:1132
bool m_enableMouseNavigation
Definition: mathplot.h:1518
double GetScaleY(void) const
Definition: mathplot.h:1109
int m_maxLabelHeight
Definition: mathplot.h:835
int GetMarginBottom()
Definition: mathplot.h:1362
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:1887
int m_flags
Definition: mathplot.h:830
double m_min_y
Definition: mathplot.h:1999
void SetName(wxString name)
Set layer name.
Definition: mathplot.h:266
void SetDataRange(double minV, double maxV)
Definition: mathplot.h:722
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:826
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:647
double m_posX
Definition: mathplot.h:1500
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:976
const wxColour & GetAxesColour()
Get axes draw colour.
Definition: mathplot.h:1413
double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1603
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above).
Definition: mathplot.h:1851
int m_maxLabelWidth
Definition: mathplot.h:836
wxColour m_axColour
Definition: mathplot.h:1492
virtual ~mpBitmapLayer()
Definition: mathplot.h:1946
wxPoint m_mouseMClick
Definition: mathplot.h:1520
double m_minY
Definition: mathplot.h:1496
int m_flags
Definition: mathplot.h:576
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:476
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1190
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:1554
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:1969
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1770
wxPoint m_scroll
Definition: mathplot.h:1523
double AbsVisibleMaxValue() const
Definition: mathplot.h:766
virtual ~mpPolygon()
Definition: mathplot.h:1912
void SetScaleY(double scaleY)
Set current view's Y scale and refresh display.
Definition: mathplot.h:1151
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:958
std::vector< double > m_ys
Definition: mathplot.h:1578
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1582
int tickCount() const
Definition: mathplot.h:797
double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1611
#define abs(a)
Definition: auxiliary.h:84
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:1349
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:276
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition: mathplot.h:305
double GetPosX(void) const
Definition: mathplot.h:1116
double m_scaleX
Definition: mathplot.h:1498
wxLayerList m_layers
Definition: mathplot.h:1486
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
Definition: mathplot.h:1205
An arbitrary polygon, descendant of mpMovableObject.
Definition: mathplot.h:1901
double GetQuantiles() const
Definition: mathplot.h:1847
double GetXscl()
Get current view's X scale.
Definition: mathplot.h:1101
std::deque< mpLayer * > wxLayerList
Define the type for the list of layers inside mpWindow.
Definition: mathplot.h:1019
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,...
Definition: mathplot.h:588
bool m_visible
Definition: mathplot.h:321
void ExtendDataRange(double minV, double maxV)
Definition: mathplot.h:735
mpScaleBase * m_scaleY
Definition: mathplot.h:630
bool GetTicks()
Get Y axis ticks or grid.
Definition: mathplot.h:970
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:1827
virtual ~mpScaleBase()
Definition: mathplot.h:694
int GetSegments() const
Definition: mathplot.h:1858
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:1862
virtual ~mpCovarianceEllipse()
Definition: mathplot.h:1845
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:1299
wxPoint m_mouseLClick
Definition: mathplot.h:1521
virtual ~mpPrintout()
Definition: mathplot.h:1689
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1200
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1747
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:1162
void ResetDataRange()
Definition: mathplot.h:756
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:1729
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:1938
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:1351
int m_winY
Definition: mathplot.h:397
double m_minY
Definition: mathplot.h:1586
void computeLabelExtents(wxDC &dc, mpWindow &w)
Definition: mathplot.cpp:952
void SetPosY(double posY)
Set current view's Y position and refresh display.
Definition: mathplot.h:1167
#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:1710
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:690
double GetYscl() const
Get current view's Y scale.
Definition: mathplot.h:1108
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:829
int GetMarginTop()
Definition: mathplot.h:1358
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:1763
virtual void UpdateInfo(mpWindow &w, wxEvent &event)
Updates the content of the info box.
Definition: mathplot.cpp:130
void SetBrush(wxBrush brush)
Set layer brush.
Definition: mathplot.h:309
wxBrush m_brush
Definition: mathplot.h:396
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:334
wxRect m_zoomRect
Definition: mathplot.h:1526
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1131
bool m_lockaspect
Definition: mathplot.h:1488
double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1615
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:938
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:1777
int m_flags
Definition: mathplot.h:997
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:106
class WXDLLIMPEXP_MATHPLOT mpLayer
Definition: mathplot.h:100
virtual double getLabelPos(int n)
Definition: mathplot.h:815
#define mpALIGN_TOP
Aligns label to the top.
Definition: mathplot.h:482
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1461
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:1685
bool m_ticks
Definition: mathplot.h:998
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:711
bool m_rangeSet
Definition: mathplot.h:834
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1524
#define mpALIGN_NE
Aligns label to north-east.
Definition: mathplot.h:504
int m_flags
Definition: mathplot.h:625
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1984
double GetXpos() const
Get current view's X position.
Definition: mathplot.h:1115
void EnableMousePanZoom(bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition: mathplot.h:1209
wxColour m_fgColour
Definition: mathplot.h:1491
double m_minV
Definition: mathplot.h:833
int m_last_ly
Definition: mathplot.h:1514
bool GetTicks()
Get X axis ticks or grid.
Definition: mathplot.h:716
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:1280
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:794
void SetDrawOutsideMargins(bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition: mathplot.h:280
bool GetContinuity() const
Gets the 'continuity' property of the layer.
Definition: mathplot.h:257
virtual bool HasBBox() override
mpText should not be used for scaling decisions.
Definition: mathplot.h:1667
bool m_drawOutsideMargins
Definition: mathplot.h:319
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1961
int GetMarginRight()
Definition: mathplot.h:1360
wxPoint m_reference
Definition: mathplot.h:395
int GetMarginLeft()
Definition: mathplot.h:1364
void SetAlign(int align)
Set Y axis alignment.
Definition: mathplot.h:962
bool m_validImg
Definition: mathplot.h:1995
virtual const wxString getLabel(int n)
Definition: mathplot.h:820
double m_posY
Definition: mathplot.h:1501
bool GetDrawOutsideMargins()
Get Draw mode: inside or outside margins.
Definition: mathplot.h:284
int m_marginTop
Definition: mathplot.h:1512
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:174
virtual bool GetNextXY(double &x, double &y)=0
Get locus value for next N.
double m_scale
Definition: mathplot.h:828
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:1991
int m_flags
Definition: mathplot.h:544
void SetAlign(int align)
Set X axis alignment.
Definition: mathplot.h:704
bool m_showName
Definition: mathplot.h:318
virtual double TransformToPlot(double x)
Definition: mathplot.h:771
double m_minX
Definition: mathplot.h:1494
double m_desiredYmin
Definition: mathplot.h:1510
enum __mp_Layer_Type mpLayerType
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1195
class WXDLLIMPEXP_MATHPLOT mpFXY
Definition: mathplot.h:103
virtual void formatLabels()
Definition: mathplot.h:808
const char * name
Definition: DXF_plotter.cpp:61
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:1820
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:1305
void SetDrawState(bool drawState)
Definition: mathplot.h:1691
wxCoord m_scaledBitmap_offset_y
Definition: mathplot.h:1993
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:1738
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:1180
mpMovableObject()
Default constructor (sets location and rotation to (0,0,0))
Definition: mathplot.h:1715
class WXDLLIMPEXP_MATHPLOT mpFX
Definition: mathplot.h:101
virtual bool IsHorizontal() override
Definition: mathplot.h:947
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
Definition: mathplot.h:1173
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:1787
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1416
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:160
int m_clickedY
Definition: mathplot.h:1505
Plot layer implementing a text string.
Definition: mathplot.h:1654
int m_flags
Definition: mathplot.h:669
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:1043
virtual double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1973
virtual void Rewind()=0
Rewind value enumeration with mpFXY::GetNextXY.
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:966
double GetDesiredXmin()
Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
Definition: mathplot.h:1293
mpLayerType m_type
Definition: mathplot.h:320
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
virtual const wxString formatLabel(double value, int nDigits)
Definition: mathplot.h:807
virtual bool IsHorizontal() override
Definition: mathplot.h:852
#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:1607
wxString m_name
Definition: mathplot.h:316
mpPolygon(const wxString &layerName=wxT(""))
Default constructor.
Definition: mathplot.h:1906
int m_scrY
Definition: mathplot.h:1503
virtual double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:1751
bool m_enableLimitedView
Definition: mathplot.h:1519
wxMenu m_popmenu
Definition: mathplot.h:1487
double m_maxX
Definition: mathplot.h:1495
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1454
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:1490
int m_nameFlags
Definition: mathplot.h:831
virtual int labelCount() const
Definition: mathplot.h:802
bool m_enableDoubleBuffer
Definition: mathplot.h:1517
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:1338
double AbsMaxValue() const
Definition: mathplot.h:761
mpScaleY * m_masterScale
Definition: mathplot.h:993
std::vector< double > m_tickValues
Definition: mathplot.h:825
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:247
int m_scrX
Definition: mathplot.h:1502
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:1755
wxBitmap * m_buff_bmp
Definition: mathplot.h:1516
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:554
void SetSegments(int segments)
Definition: mathplot.h:1857
double GetDesiredYmax()
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
Definition: mathplot.h:1311
virtual double getTickPos(int n)
Definition: mathplot.h:810
int GetYScreen(void) const
Definition: mathplot.h:1141
double GetYpos() const
Get current view's Y position.
Definition: mathplot.h:1122
double m_maxY
Definition: mathplot.h:1497
virtual double TransformFromPlot(double xplot)
Definition: mathplot.h:772
#define min(a, b)
Definition: auxiliary.h:85
int m_offsety
Definition: mathplot.h:1671
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1140
double m_bbox_min_y
Definition: mathplot.h:1797
virtual double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:1977