13 #ifndef _MP_MATHPLOT_H_
14 #define _MP_MATHPLOT_H_
19 #pragma warning(disable:4251)
69 #define WXDLLIMPEXP_MATHPLOT GUI_IMPEXP
72 #if defined(__GNUG__) && !defined(__APPLE__)
73 #pragma interface "mathplot.h"
81 #include <wx/scrolwin.h>
83 #include <wx/dynarray.h>
85 #include <wx/dcmemory.h>
86 #include <wx/string.h>
97 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
104 #define X_BORDER_SEPARATION 40
105 #define Y_BORDER_SEPARATION 60
241 virtual void Plot(wxDC & dc,
mpWindow & w) = 0;
251 const wxFont&
GetFont()
const {
return m_font; }
256 const wxPen&
GetPen()
const {
return m_pen; }
275 void SetName(wxString name) { m_name = name; }
298 wxBitmap GetColourSquare(
int side = 16);
314 const wxBrush&
GetBrush()
const {
return m_brush; };
351 mpInfoLayer(wxRect rect,
const wxBrush* brush = wxTRANSPARENT_BRUSH);
360 virtual void UpdateInfo(
mpWindow& w, wxEvent& event);
380 virtual bool Inside(wxPoint& point);
384 virtual void Move(wxPoint delta);
387 virtual void UpdateReference();
391 wxPoint GetPosition();
399 const wxRect& GetRectangle() {
return m_dim; };
421 mpInfoCoords(wxRect rect,
const wxBrush* brush = wxTRANSPARENT_BRUSH);
454 mpInfoLegend(wxRect rect,
const wxBrush* brush = wxTRANSPARENT_BRUSH);
483 #define mpALIGNMASK 0x03
485 #define mpALIGN_RIGHT 0x00
487 #define mpALIGN_CENTER 0x01
489 #define mpALIGN_LEFT 0x02
491 #define mpALIGN_TOP mpALIGN_RIGHT
493 #define mpALIGN_BOTTOM mpALIGN_LEFT
495 #define mpALIGN_BORDER_BOTTOM 0x04
497 #define mpALIGN_BORDER_TOP 0x05
499 #define mpX_NORMAL 0x00
501 #define mpX_TIME 0x01
503 #define mpX_HOURS 0x02
505 #define mpX_DATE 0x03
507 #define mpX_DATETIME 0x04
509 #define mpALIGN_BORDER_LEFT mpALIGN_BORDER_BOTTOM
511 #define mpALIGN_BORDER_RIGHT mpALIGN_BORDER_TOP
513 #define mpALIGN_NE 0x00
515 #define mpALIGN_NW 0x01
517 #define mpALIGN_SW 0x02
519 #define mpALIGN_SE 0x03
544 virtual double GetY(
double x ) = 0;
555 DECLARE_DYNAMIC_CLASS(
mpFX)
576 virtual double GetX(
double y ) = 0;
587 DECLARE_DYNAMIC_CLASS(
mpFY)
607 virtual void Rewind() = 0;
614 virtual bool GetNextXY(
double & x,
double & y) = 0;
634 void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
636 DECLARE_DYNAMIC_CLASS(
mpFXY)
658 virtual double GetY(
double x ) = 0;
802 #define mpMOUSEMODE_DRAG 0
804 #define mpMOUSEMODE_ZOOMBOX 1
837 mpWindow( wxWindow *parent, wxWindowID
id,
838 const wxPoint &pos = wxDefaultPosition,
839 const wxSize &
size = wxDefaultSize,
855 bool AddLayer(
mpLayer* layer,
bool refreshDisplay =
true);
865 bool DelLayer(
mpLayer* layer,
bool alsoDeleteObject =
false,
bool refreshDisplay =
true);
871 void DelAllLayers(
bool alsoDeleteObject,
bool refreshDisplay =
true);
879 mpLayer* GetLayer(
int position);
885 mpLayer* GetLayerByName(
const wxString &name);
936 void SetScaleX(
double scaleX);
941 void SetScaleY(
double scaleY) {
if (scaleY!=0) m_scaleY=scaleY; UpdateAll(); }
946 void SetPosX(
double posX) { m_posX=posX; UpdateAll(); }
951 void SetPosY(
double posY) { m_posY=posY; UpdateAll(); }
957 void SetPos(
double posX,
double posY) { m_posX=posX; m_posY=posY; UpdateAll(); }
964 void SetScr(
int scrX,
int scrY) { m_scrX=scrX; m_scrY=scrY; }
969 inline double p2x(wxCoord pixelCoordX ) {
return m_posX + pixelCoordX/m_scaleX; }
974 inline double p2y(wxCoord pixelCoordY ) {
return m_posY - pixelCoordY/m_scaleY; }
979 inline wxCoord
x2p(
double x) {
return (wxCoord) ( (x-m_posX) * m_scaleX); }
984 inline wxCoord
y2p(
double y) {
return (wxCoord) ( (m_posY-y) * m_scaleY); }
1000 void LockAspect(
bool enable = TRUE);
1020 void Fit(
double xMin,
double xMax,
double yMin,
double yMax,wxCoord *printSizeX=NULL,wxCoord *printSizeY=NULL);
1025 void ZoomIn(
const wxPoint& centerPoint = wxDefaultPosition );
1030 void ZoomOut(
const wxPoint& centerPoint = wxDefaultPosition );
1042 void ZoomRect(wxPoint p0, wxPoint p1);
1052 unsigned int CountLayers();
1062 void ShowPrintDialog()
1091 void GetBoundingBox(
double* bbox);
1095 void SetMPScrollbars(
bool status);
1106 bool SaveScreenshot(
const wxString& filename,
int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize,
bool fit =
false);
1117 void SetMargins(
int top,
int right,
int bottom,
int left);
1150 void SetLayerVisible(
const wxString &name,
bool viewable);
1155 bool IsLayerVisible(
const wxString &name );
1160 void SetLayerVisible(
const unsigned int position,
bool viewable);
1165 bool IsLayerVisible(
const unsigned int position );
1171 void SetColourTheme(
const wxColour& bgColour,
const wxColour& drawColour,
const wxColour& axesColour);
1178 void OnPaint (wxPaintEvent &event);
1179 void OnSize (wxSizeEvent &event);
1181 void OnShowPopupMenu (wxMouseEvent &event);
1182 void OnMouseRightDown(wxMouseEvent &event);
1183 void OnCenter (wxCommandEvent &event);
1184 void OnFit (wxCommandEvent &event);
1185 void OnZoomIn (wxCommandEvent &event);
1186 void OnZoomOut (wxCommandEvent &event);
1187 void OnLockAspect (wxCommandEvent &event);
1188 void OnMouseHelp (wxCommandEvent &event);
1189 void OnPrintMenu (wxCommandEvent &event);
1190 void OnMouseWheel (wxMouseEvent &event);
1191 void OnMouseMove (wxMouseEvent &event);
1192 void OnMouseLeftDown (wxMouseEvent &event);
1193 void OnMouseLeftRelease (wxMouseEvent &event);
1194 void OnScrollThumbTrack (wxScrollWinEvent &event);
1195 void OnScrollPageUp (wxScrollWinEvent &event);
1196 void OnScrollPageDown (wxScrollWinEvent &event);
1197 void OnScrollLineUp (wxScrollWinEvent &event);
1198 void OnScrollLineDown (wxScrollWinEvent &event);
1199 void OnScrollTop (wxScrollWinEvent &event);
1200 void OnScrollBottom (wxScrollWinEvent &event);
1202 void DoScrollCalc (
const int position,
const int orientation);
1204 void DoZoomInXCalc (
const int staticXpixel);
1205 void DoZoomInYCalc (
const int staticYpixel);
1206 void DoZoomOutXCalc (
const int staticXpixel);
1207 void DoZoomOutYCalc (
const int staticYpixel);
1212 virtual bool UpdateBBox();
1255 DECLARE_EVENT_TABLE()
1293 void SetData(
const std::vector<double> &xs,
const std::vector<double> &ys);
1299 void SetData(
const std::vector<float> &xs,
const std::vector<float> &ys);
1309 size_t GetDataLength()
const
1317 void AppendDataPoint(
float x,
float y);
1342 bool GetNextXY(
double & x,
double & y);
1383 mpText(wxString name = wxT(
"Title"),
int offsetx = 5,
int offsety = 50);
1387 virtual void Plot(wxDC & dc,
mpWindow & w);
1396 DECLARE_DYNAMIC_CLASS(
mpText)
1411 mpPrintout(
mpWindow* drawWindow,
const wxChar *title = _T(
"wxMathPlot print output"));
1415 bool OnPrintPage(
int page);
1416 bool HasPage(
int page);
1452 void GetCoordinateBase(
double &x,
double &y,
double &phi )
const
1456 phi = m_reference_phi;
1461 void SetCoordinateBase(
double x,
double y,
double phi = 0 )
1465 m_reference_phi = phi;
1470 virtual bool HasBBox() {
return m_trans_shape_xs.size()!=0; }
1488 virtual void Plot(wxDC & dc,
mpWindow & w);
1504 void TranslatePoint(
double x,
double y,
double &out_x,
double &out_y );
1523 void ShapeUpdated();
1551 double quantiles = 2,
1553 const wxString & layerName = wxT(
"") ) :
1557 m_quantiles(quantiles),
1558 m_segments(segments)
1560 m_continuous =
true;
1572 void SetQuantiles(
double q)
1583 void GetCovarianceMatrix(
double &cov_00,
double &cov_01,
double &cov_11 )
const
1592 void SetCovarianceMatrix(
double cov_00,
double cov_01,
double cov_11 )
1612 void RecalculateShape();
1629 m_continuous =
true;
1641 const std::vector<double>& points_xs,
1642 const std::vector<double>& points_ys,
1643 bool closedShape=
true );
1651 const std::vector<float>& points_xs,
1652 const std::vector<float>& points_ys,
1653 bool closedShape=
true );
1676 m_min_y = m_max_y = 0;
1685 void GetBitmapCopy( wxImage &outBmp )
const;
1694 void SetBitmap(
const wxImage &inBmp,
double x,
double y,
double lx,
double ly );
1714 virtual void Plot(wxDC & dc,
mpWindow & w);
1745 #if defined(_MSC_VER)
1746 #pragma warning(pop)
1750 #endif // _MP_MATHPLOT_H_