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 
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 = -1.0;
752  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( 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( 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( 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( 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 
1242  void ZoomIn( const wxPoint& centerPoint = wxDefaultPosition );
1243 
1247  void ZoomOut( const wxPoint& centerPoint = wxDefaultPosition );
1248 
1250  void ZoomInX();
1251 
1253  void ZoomOutX();
1254 
1256  void ZoomInY();
1257 
1259  void ZoomOutY();
1260 
1262  void ZoomRect( wxPoint p0, wxPoint p1 );
1263 
1265  void UpdateAll();
1266 
1267  // Added methods by Davide Rondini
1268 
1272  unsigned int CountLayers();
1273 
1276  unsigned int CountAllLayers() { return m_layers.size(); };
1277 
1278 #if 0
1279 
1282  void PrintGraph(mpPrintout *print);
1283 #endif
1284 
1288  double GetDesiredXmin() { return m_desiredXmin; }
1289 
1293  double GetDesiredXmax() { return m_desiredXmax; }
1294 
1298  double GetDesiredYmin() { return m_desiredYmin; }
1299 
1303  double GetDesiredYmax() { return m_desiredYmax; }
1304 
1307  void GetBoundingBox( double* bbox );
1308 
1311  void SetMPScrollbars( bool status );
1312 
1315  bool GetMPScrollbars() { return m_enableScrollBars; };
1316 
1322  bool SaveScreenshot( const wxString& filename, wxBitmapType type = wxBITMAP_TYPE_BMP,
1323  wxSize imageSize = wxDefaultSize, bool fit = false );
1324 
1327  static double zoomIncrementalFactor;
1328 
1334  void SetMargins( int top, int right, int bottom, int left );
1335 
1337  void SetMarginTop( int top ) { m_marginTop = top; };
1339  void SetMarginRight( int right ) { m_marginRight = right; };
1341  void SetMarginBottom( int bottom ) { m_marginBottom = bottom; };
1343  void SetMarginLeft( int left ) { m_marginLeft = left; };
1344 
1346  int GetMarginTop() { return m_marginTop; };
1348  int GetMarginRight() { return m_marginRight; };
1350  int GetMarginBottom() { return m_marginBottom; };
1352  int GetMarginLeft() { return m_marginLeft; };
1353 
1354 #if 0
1355 
1358  // void EnableCoordTooltip(bool value = true);
1359 
1363  // bool GetCoordTooltip() { return m_coordTooltip; };
1364 #endif
1365 
1369  mpInfoLayer* IsInsideInfoLayer( wxPoint& point );
1370 
1374  void SetLayerVisible( const wxString& name, bool viewable );
1375 
1379  bool IsLayerVisible( const wxString& name );
1380 
1384  void SetLayerVisible( const unsigned int position, bool viewable );
1385 
1389  bool IsLayerVisible( const unsigned int position );
1390 
1395  void SetColourTheme( const wxColour& bgColour,
1396  const wxColour& drawColour,
1397  const wxColour& axesColour );
1398 
1401  const wxColour& GetAxesColour() { return m_axColour; };
1402 
1404  void LimitView( bool aEnable )
1405  {
1406  m_enableLimitedView = aEnable;
1407  }
1408 
1409 protected:
1410  void OnPaint( wxPaintEvent& event ); // !< Paint handler, will plot all attached layers
1411  void OnSize( wxSizeEvent& event ); // !< Size handler, will update scroll bar sizes
1412 
1413  // void OnScroll2 (wxScrollWinEvent &event); //!< Scroll handler, will move canvas
1414  void OnShowPopupMenu( wxMouseEvent& event ); // !< Mouse handler, will show context menu
1415  void OnMouseMiddleDown( wxMouseEvent& event ); // !< Mouse handler, for detecting when the user
1416 
1417  // !< drags with the middle button or just "clicks" for the menu
1418  void OnCenter( wxCommandEvent& event ); // !< Context menu handler
1419  void OnFit( wxCommandEvent& event ); // !< Context menu handler
1420  void OnZoomIn( wxCommandEvent& event ); // !< Context menu handler
1421  void OnZoomOut( wxCommandEvent& event ); // !< Context menu handler
1422  void OnLockAspect( wxCommandEvent& event ); // !< Context menu handler
1423  void OnMouseWheel( wxMouseEvent& event ); // !< Mouse handler for the wheel
1424  void OnMouseMove( wxMouseEvent& event ); // !< Mouse handler for mouse motion (for pan)
1425  void OnMouseLeftDown( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1426  void OnMouseLeftRelease( wxMouseEvent& event ); // !< Mouse left click (for rect zoom)
1427  void OnScrollThumbTrack( wxScrollWinEvent& event ); // !< Scroll thumb on scroll bar moving
1428  void OnScrollPageUp( wxScrollWinEvent& event ); // !< Scroll page up
1429  void OnScrollPageDown( wxScrollWinEvent& event ); // !< Scroll page down
1430  void OnScrollLineUp( wxScrollWinEvent& event ); // !< Scroll line up
1431  void OnScrollLineDown( wxScrollWinEvent& event ); // !< Scroll line down
1432  void OnScrollTop( wxScrollWinEvent& event ); // !< Scroll to top
1433  void OnScrollBottom( wxScrollWinEvent& event ); // !< Scroll to bottom
1434 
1435  void DoScrollCalc( const int position, const int orientation );
1436 
1437  void DoZoomInXCalc( const int staticXpixel );
1438  void DoZoomInYCalc( const int staticYpixel );
1439  void DoZoomOutXCalc( const int staticXpixel );
1440  void DoZoomOutYCalc( const int staticYpixel );
1441 
1442  bool CheckXLimits( double& desiredMax, double& desiredMin ) const
1443  {
1444  return !( m_enableLimitedView
1445  && (desiredMax > m_maxX - m_marginRight / m_scaleX
1446  || desiredMin < m_minX - m_marginLeft / m_scaleX) );
1447  }
1448 
1449  bool CheckYLimits( double& desiredMax, double& desiredMin ) const
1450  {
1451  return !( m_enableLimitedView
1452  && (desiredMax > m_maxY + m_marginBottom / m_scaleY
1453  || desiredMin < m_minY + m_marginTop / m_scaleY) );
1454  }
1455 
1456  void AdjustLimitedView();
1457 
1461  virtual bool UpdateBBox();
1462 
1466  virtual bool SetXView( double pos, double desiredMax, double desiredMin );
1467 
1471  virtual bool SetYView( double pos, double desiredMax, double desiredMin );
1472 
1473  // wxList m_layers; //!< List of attached plot layers
1474  wxLayerList m_layers; // !< List of attached plot layers
1475  wxMenu m_popmenu; // !< Canvas' context menu
1476  bool m_lockaspect; // !< Scale aspect is locked or not
1477  // bool m_coordTooltip; //!< Selects whether to show coordinate tooltip
1478  wxColour m_bgColour; // !< Background Colour
1479  wxColour m_fgColour; // !< Foreground Colour
1480  wxColour m_axColour; // !< Axes Colour
1481 
1482  double m_minX; // !< Global layer bounding box, left border incl.
1483  double m_maxX; // !< Global layer bounding box, right border incl.
1484  double m_minY; // !< Global layer bounding box, bottom border incl.
1485  double m_maxY; // !< Global layer bounding box, top border incl.
1486  double m_scaleX; // !< Current view's X scale
1487  double m_scaleY; // !< Current view's Y scale
1488  double m_posX; // !< Current view's X position
1489  double m_posY; // !< Current view's Y position
1490  int m_scrX; // !< Current view's X dimension
1491  int m_scrY; // !< Current view's Y dimension
1492  int m_clickedX; // !< Last mouse click X position, for centering and zooming the view
1493  int m_clickedY; // !< Last mouse click Y position, for centering and zooming the view
1494 
1497  double m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax;
1498 
1499  int m_marginTop, m_marginRight, m_marginBottom, m_marginLeft;
1500 
1501  int m_last_lx, m_last_ly; // !< For double buffering
1502  wxMemoryDC m_buff_dc; // !< For double buffering
1503  wxBitmap* m_buff_bmp; // !< For double buffering
1504  bool m_enableDoubleBuffer; // !< For double buffering
1505  bool m_enableMouseNavigation; // !< For pan/zoom with the mouse.
1507  wxPoint m_mouseMClick; // !< For the middle button "drag" feature
1508  wxPoint m_mouseLClick; // !< Starting coords for rectangular zoom selection
1511  mpInfoLayer* m_movingInfoLayer; // !< For moving info layers over the window area
1513  wxRect m_zoomRect;
1514  DECLARE_DYNAMIC_CLASS( mpWindow )
1515  DECLARE_EVENT_TABLE()
1516 };
1517 
1518 // -----------------------------------------------------------------------------
1519 // mpFXYVector - provided by Jose Luis Blanco
1520 // -----------------------------------------------------------------------------
1521 
1542 {
1543 public:
1547  mpFXYVector( wxString name = wxEmptyString, int flags = mpALIGN_NE );
1548 
1549  virtual ~mpFXYVector() {}
1550 
1555  virtual void SetData( const std::vector<double>& xs, const std::vector<double>& ys );
1556 
1560  void Clear();
1561 
1562 protected:
1565  std::vector<double> m_xs, m_ys;
1566 
1569  size_t m_index;
1570 
1573  double m_minX, m_maxX, m_minY, m_maxY;
1574 
1578  void Rewind() override;
1579 
1585  bool GetNextXY( double& x, double& y ) override;
1586 
1587 public:
1590  double GetMinX() override { return m_minX; }
1591 
1594  double GetMinY() override { return m_minY; }
1595 
1598  double GetMaxX() override { return m_maxX; }
1599 
1602  double GetMaxY() override { return m_maxY; }
1603 
1604 protected:
1605 
1606  DECLARE_DYNAMIC_CLASS( mpFXYVector )
1607 };
1608 
1609 
1610 #if 0
1611 
1612 class WXDLLIMPEXP_MATHPLOT mpFSemiLogXVector : public mpFXYVector
1613 {
1614 public:
1618  mpFSemiLogXVector( wxString name = wxEmptyString, int flags = mpALIGN_NE );
1619 
1620  virtual ~mpFSemiLogXVector() {}
1621 
1627  DECLARE_DYNAMIC_CLASS( mpFSemiLogXVector )
1628 };
1629 #endif
1630 
1631 // -----------------------------------------------------------------------------
1632 // mpText - provided by Val Greene
1633 // -----------------------------------------------------------------------------
1634 
1642 {
1643 public:
1647  mpText( wxString name = wxT("Title"), int offsetx = 5, int offsety = 50 );
1648 
1651  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1652 
1654  virtual bool HasBBox() override { return FALSE; }
1655 
1656 protected:
1657  int m_offsetx; // !< Holds offset for X in percentage
1658  int m_offsety; // !< Holds offset for Y in percentage
1659 
1660  DECLARE_DYNAMIC_CLASS( mpText )
1661 };
1662 
1663 
1664 // -----------------------------------------------------------------------------
1665 // mpPrintout - provided by Davide Rondini
1666 // -----------------------------------------------------------------------------
1667 
1672 class WXDLLIMPEXP_MATHPLOT mpPrintout : public wxPrintout
1673 {
1674 public:
1675  mpPrintout( mpWindow* drawWindow, const wxChar* title = _T("wxMathPlot print output") );
1676  virtual ~mpPrintout() {};
1677 
1678  void SetDrawState( bool drawState ) { drawn = drawState; };
1679  bool OnPrintPage( int page ) override;
1680  bool HasPage( int page ) override;
1681 
1682 private:
1683  bool drawn;
1685 };
1686 
1687 
1688 // -----------------------------------------------------------------------------
1689 // mpMovableObject - provided by Jose Luis Blanco
1690 // -----------------------------------------------------------------------------
1698 {
1699 public:
1703  m_reference_x( 0 ),
1704  m_reference_y( 0 ),
1705  m_reference_phi( 0 ),
1706  m_shape_xs( 0 ),
1707  m_shape_ys( 0 )
1708  {
1709  m_type = mpLAYER_PLOT;
1710  }
1711 
1712  virtual ~mpMovableObject() {};
1713 
1716  void GetCoordinateBase( double& x, double& y, double& phi ) const
1717  {
1718  x = m_reference_x;
1719  y = m_reference_y;
1720  phi = m_reference_phi;
1721  }
1722 
1725  void SetCoordinateBase( double x, double y, double phi = 0 )
1726  {
1727  m_reference_x = x;
1728  m_reference_y = y;
1729  m_reference_phi = phi;
1730  m_flags = mpALIGN_NE;
1731  ShapeUpdated();
1732  }
1733 
1734  virtual bool HasBBox() override { return m_trans_shape_xs.size()!=0; }
1735 
1738  virtual double GetMinX() override { return m_bbox_min_x; }
1739 
1742  virtual double GetMaxX() override { return m_bbox_max_x; }
1743 
1746  virtual double GetMinY() override { return m_bbox_min_y; }
1747 
1750  virtual double GetMaxY() override { return m_bbox_max_y; }
1751 
1752  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1753 
1757  void SetAlign( int align ) { m_flags = align; };
1758 
1759 protected:
1760  int m_flags; // !< Holds label alignment
1761 
1764  double m_reference_x, m_reference_y, m_reference_phi;
1765 
1769  void TranslatePoint( double x, double y, double& out_x, double& out_y );
1770 
1774  std::vector<double> m_shape_xs, m_shape_ys;
1775 
1779  std::vector<double> m_trans_shape_xs, m_trans_shape_ys;
1780 
1784  double m_bbox_min_x, m_bbox_max_x, m_bbox_min_y, m_bbox_max_y;
1785 
1790  void ShapeUpdated();
1791 };
1792 
1793 // -----------------------------------------------------------------------------
1794 // mpCovarianceEllipse - provided by Jose Luis Blanco
1795 // -----------------------------------------------------------------------------
1808 {
1809 public:
1813  mpCovarianceEllipse( double cov_00 = 1,
1814  double cov_11 = 1,
1815  double cov_01 = 0,
1816  double quantiles = 2,
1817  int segments = 32,
1818  const wxString& layerName = wxT("") ) :
1819  m_cov_00( cov_00 ),
1820  m_cov_11( cov_11 ),
1821  m_cov_01( cov_01 ),
1822  m_quantiles( quantiles ),
1823  m_segments( segments )
1824  {
1825  m_continuous = true;
1826  m_name = layerName;
1827  RecalculateShape();
1828  m_type = mpLAYER_PLOT;
1829  }
1830 
1832 
1833  double GetQuantiles() const { return m_quantiles; }
1834 
1837  void SetQuantiles( double q )
1838  {
1839  m_quantiles = q;
1840  RecalculateShape();
1841  }
1842 
1843  void SetSegments( int segments ) { m_segments = segments; }
1844  int GetSegments() const { return m_segments; }
1845 
1848  void GetCovarianceMatrix( double& cov_00, double& cov_01, double& cov_11 ) const
1849  {
1850  cov_00 = m_cov_00;
1851  cov_01 = m_cov_01;
1852  cov_11 = m_cov_11;
1853  }
1854 
1857  void SetCovarianceMatrix( double cov_00, double cov_01, double cov_11 )
1858  {
1859  m_cov_00 = cov_00;
1860  m_cov_01 = cov_01;
1861  m_cov_11 = cov_11;
1862  RecalculateShape();
1863  }
1864 
1865 protected:
1868  double m_cov_00, m_cov_11, m_cov_01;
1869  double m_quantiles;
1870 
1874 
1877  void RecalculateShape();
1878 };
1879 
1880 // -----------------------------------------------------------------------------
1881 // mpPolygon - provided by Jose Luis Blanco
1882 // -----------------------------------------------------------------------------
1888 {
1889 public:
1892  mpPolygon( const wxString& layerName = wxT("") )
1893  {
1894  m_continuous = true;
1895  m_name = layerName;
1896  }
1897 
1898  virtual ~mpPolygon() {}
1899 
1905  void setPoints( const std::vector<double>& points_xs,
1906  const std::vector<double>& points_ys,
1907  bool closedShape = true );
1908 };
1909 
1910 // -----------------------------------------------------------------------------
1911 // mpMovableObject - provided by Jose Luis Blanco
1912 // -----------------------------------------------------------------------------
1920 {
1921 public:
1925  {
1926  m_min_x = m_max_x =
1927  m_min_y = m_max_y = 0;
1928  m_validImg = false;
1929  m_type = mpLAYER_BITMAP;
1930  }
1931 
1932  virtual ~mpBitmapLayer() {};
1933 
1936  void GetBitmapCopy( wxImage& outBmp ) const;
1937 
1945  void SetBitmap( const wxImage& inBmp, double x, double y, double lx, double ly );
1946 
1947  virtual bool HasBBox() override { return true; }
1948 
1951  virtual double GetMinX() override { return m_min_x; }
1952 
1955  virtual double GetMaxX() override { return m_max_x; }
1956 
1959  virtual double GetMinY() override { return m_min_y; }
1960 
1963  virtual double GetMaxY() override { return m_max_y; }
1964 
1965  virtual void Plot( wxDC& dc, mpWindow& w ) override;
1966 
1970  void SetAlign( int align ) { m_flags = align; };
1971 
1972 protected:
1973  int m_flags; // !< Holds label alignment
1974 
1977  wxImage m_bitmap;
1978  wxBitmap m_scaledBitmap;
1979  wxCoord m_scaledBitmap_offset_x, m_scaledBitmap_offset_y;
1980 
1982 
1985  double m_min_x, m_max_x, m_min_y, m_max_y;
1986 };
1987 
1990 #endif // _MP_MATHPLOT_H_
int m_offsetx
Definition: mathplot.h:1657
bool GetMPScrollbars()
Get scrollbars status.
Definition: mathplot.h:1315
virtual double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:1951
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:1056
virtual void recalculateTicks(wxDC &dc, mpWindow &w)
Definition: mathplot.h:795
wxMemoryDC m_buff_dc
Definition: mathplot.h:1502
void SetMarginBottom(int bottom)
Set the bottom margin.
Definition: mathplot.h:1341
virtual ~mpScaleXBase()
Definition: mathplot.h:850
virtual double GetMinY() override
Get inclusive bottom border of bounding box.
Definition: mathplot.h:1746
virtual bool IsInfo()
Check whether the layer is an info box.
Definition: mathplot.h:169
bool drawn
Definition: mathplot.h:1683
bool m_continuous
Definition: mathplot.h:317
bool m_enableScrollBars
Definition: mathplot.h:1509
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:237
virtual ~mpFXYVector()
Definition: mathplot.h:1549
mpWindow * plotWindow
Definition: mathplot.h:1684
wxBitmap m_scaledBitmap
Definition: mathplot.h:1978
void GetDataRange(double &minV, double &maxV)
Definition: mathplot.h:729
bool m_zooming
Definition: mathplot.h:1512
wxString m_content
Definition: mathplot.h:430
void SetNameAlign(int align)
Definition: mathplot.h:706
virtual ~mpMovableObject()
Definition: mathplot.h:1712
__mp_Layer_Type
Definition: mathplot.h:125
void SetMarginLeft(int left)
Set the left margin.
Definition: mathplot.h:1343
wxBrush m_brush
Definition: mathplot.h:315
int m_clickedX
Definition: mathplot.h:1492
void SetCovarianceMatrix(double cov_00, double cov_01, double cov_11)
Changes the covariance matrix:
Definition: mathplot.h:1857
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
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, using current mpWindow position and scale.
Definition: mathplot.h:1185
bool m_ticks
Definition: mathplot.h:832
int tickCount() const
Definition: mathplot.h:797
virtual ~mpLayer()
Definition: mathplot.h:151
std::vector< double > m_trans_shape_ys
Definition: mathplot.h:1779
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition: mathplot.h:1919
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition: mathplot.h:522
int GetYScreen(void) const
Definition: mathplot.h:1141
double m_scaleY
Definition: mathplot.h:1487
std::vector< TickLabel > & TickLabels()
Definition: mathplot.h:786
bool m_enableMouseNavigation
Definition: mathplot.h:1505
int m_maxLabelHeight
Definition: mathplot.h:835
int GetMarginBottom()
Definition: mathplot.h:1350
int m_segments
The number of line segments that build up the ellipse.
Definition: mathplot.h:1873
int m_flags
Definition: mathplot.h:830
double m_min_y
Definition: mathplot.h:1985
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:1488
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:976
const wxColour & GetAxesColour()
Get axes draw colour.
Definition: mathplot.h:1401
double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition: mathplot.h:1590
void SetQuantiles(double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see above)...
Definition: mathplot.h:1837
int m_maxLabelWidth
Definition: mathplot.h:836
wxColour m_axColour
Definition: mathplot.h:1480
virtual ~mpBitmapLayer()
Definition: mathplot.h:1932
wxPoint m_mouseMClick
Definition: mathplot.h:1507
double m_minY
Definition: mathplot.h:1484
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1140
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: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:1541
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:1955
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1757
wxPoint m_scroll
Definition: mathplot.h:1510
virtual ~mpPolygon()
Definition: mathplot.h:1898
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:1565
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition: mathplot.h:1569
double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition: mathplot.h:1598
#define abs(a)
Definition: auxiliary.h:84
void SetMarginTop(int top)
Set the top margin.
Definition: mathplot.h:1337
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:276
double GetYpos() const
Get current view's Y position.
Definition: mathplot.h:1122
double m_scaleX
Definition: mathplot.h:1486
static const int delta[8][2]
Definition: solve.cpp:112
wxLayerList m_layers
Definition: mathplot.h:1474
double GetPosY(void) const
Definition: mathplot.h:1123
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:1887
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,Y.
Definition: mathplot.h:588
bool m_visible
Definition: mathplot.h:321
void ExtendDataRange(double minV, double maxV)
Definition: mathplot.h:735
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1442
mpScaleBase * m_scaleY
Definition: mathplot.h:630
bool GetTicks()
Get Y axis ticks or grid.
Definition: mathplot.h:970
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:1813
virtual ~mpScaleBase()
Definition: mathplot.h:694
double GetXpos() const
Get current view's X position.
Definition: mathplot.h:1115
virtual ~mpCovarianceEllipse()
Definition: mathplot.h:1831
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:1293
wxPoint m_mouseLClick
Definition: mathplot.h:1508
virtual ~mpPrintout()
Definition: mathplot.h:1676
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1200
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1734
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
mpBitmapLayer()
Default constructor.
Definition: mathplot.h:1924
void SetMarginRight(int right)
Set the right margin.
Definition: mathplot.h:1339
int m_winY
Definition: mathplot.h:397
double m_minY
Definition: mathplot.h:1573
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: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:1697
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:829
int GetMarginTop()
Definition: mathplot.h:1346
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:1750
virtual int labelCount() const
Definition: mathplot.h:802
virtual void UpdateInfo(mpWindow &w, wxEvent &event)
Updates the content of the info box.
Definition: mathplot.cpp:129
double GetQuantiles() const
Definition: mathplot.h:1833
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:1513
double GetPosX(void) const
Definition: mathplot.h:1116
bool m_lockaspect
Definition: mathplot.h:1476
double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition: mathplot.h:1602
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:1764
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
Printout class used by mpWindow to draw in the objects to be printed.
Definition: mathplot.h:1672
bool m_ticks
Definition: mathplot.h:998
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:711
const wxFont & GetFont() const
Get font set for this layer.
Definition: mathplot.h:242
bool m_rangeSet
Definition: mathplot.h:834
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1511
#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:1131
double GetScaleY(void) const
Definition: mathplot.h:1109
void SetAlign(int align)
Set label axis alignment.
Definition: mathplot.h:1970
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:1479
double m_minV
Definition: mathplot.h:833
int m_last_ly
Definition: mathplot.h:1501
double AbsMaxValue() const
Definition: mathplot.h:761
bool GetTicks()
Get X axis ticks or grid.
Definition: mathplot.h:716
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition: mathplot.h:1848
double GetScaleX(void) const
Definition: mathplot.h:1102
unsigned int CountAllLayers()
Counts the number of plot layers, whether or not they have a bounding box.
Definition: mathplot.h:1276
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
int GetSegments() const
Definition: mathplot.h:1844
virtual bool HasBBox() override
mpText should not be used for scaling decisions.
Definition: mathplot.h:1654
bool m_drawOutsideMargins
Definition: mathplot.h:319
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1947
int GetMarginRight()
Definition: mathplot.h:1348
wxPoint m_reference
Definition: mathplot.h:395
int GetMarginLeft()
Definition: mathplot.h:1352
void SetAlign(int align)
Set Y axis alignment.
Definition: mathplot.h:962
bool m_validImg
Definition: mathplot.h:1981
virtual const wxString getLabel(int n)
Definition: mathplot.h:820
double m_posY
Definition: mathplot.h:1489
bool GetDrawOutsideMargins()
Get Draw mode: inside or outside margins.
Definition: mathplot.h:284
int m_marginTop
Definition: mathplot.h:1499
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:174
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:1977
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:1482
double m_desiredYmin
Definition: mathplot.h:1497
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:1195
class WXDLLIMPEXP_MATHPLOT mpFXY
Definition: mathplot.h:103
virtual void formatLabels()
Definition: mathplot.h:808
A 2D ellipse, described by a 2x2 covariance matrix.
Definition: mathplot.h:1807
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition: mathplot.h:1716
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:1298
void SetDrawState(bool drawState)
Definition: mathplot.h:1678
double AbsVisibleMaxValue() const
Definition: mathplot.h:766
wxCoord m_scaledBitmap_offset_y
Definition: mathplot.h:1979
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:1725
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:1702
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:1774
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:1404
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:160
int m_clickedY
Definition: mathplot.h:1493
Plot layer implementing a text string.
Definition: mathplot.h:1641
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1449
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:1959
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:1288
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: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:1594
wxString m_name
Definition: mathplot.h:316
mpPolygon(const wxString &layerName=wxT(""))
Default constructor.
Definition: mathplot.h:1892
int m_scrY
Definition: mathplot.h:1491
virtual double GetMinX() override
Get inclusive left border of bounding box.
Definition: mathplot.h:1738
bool m_enableLimitedView
Definition: mathplot.h:1506
wxMenu m_popmenu
Definition: mathplot.h:1475
int GetXScreen(void) const
Definition: mathplot.h:1132
double m_maxX
Definition: mathplot.h:1483
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:1478
double GetYscl() const
Get current view's Y scale.
Definition: mathplot.h:1108
int m_nameFlags
Definition: mathplot.h:831
bool m_enableDoubleBuffer
Definition: mathplot.h:1504
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:1327
mpScaleY * m_masterScale
Definition: mathplot.h:993
std::vector< double > m_tickValues
Definition: mathplot.h:825
int m_scrX
Definition: mathplot.h:1490
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:1742
wxBitmap * m_buff_bmp
Definition: mathplot.h:1503
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition: mathplot.h:554
void SetSegments(int segments)
Definition: mathplot.h:1843
double GetDesiredYmax()
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
Definition: mathplot.h:1303
virtual double getTickPos(int n)
Definition: mathplot.h:810
double m_maxY
Definition: mathplot.h:1485
virtual double TransformFromPlot(double xplot)
Definition: mathplot.h:772
#define min(a, b)
Definition: auxiliary.h:85
int m_offsety
Definition: mathplot.h:1658
double m_bbox_min_y
Definition: mathplot.h:1784
virtual double GetMaxY() override
Get inclusive top border of bounding box.
Definition: mathplot.h:1963