mathplot.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #ifndef _MP_MATHPLOT_H_
00012 #define _MP_MATHPLOT_H_
00013 #define ZOOM_FACTOR 1.5
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #include "marTypes.h"
00054 #include "wx/defs.h"
00055 #include <wx/wx.h>
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 class mpLayer;
00069 class mpFX;
00070 class mpFY;
00071 class mpFXY;
00072 class mpScaleX;
00073 class mpScaleY;
00074 class mpWindow;
00075
00077 enum
00078 {
00079 mpID_FIT = 2000,
00080 mpID_ZOOM_IN,
00081 mpID_ZOOM_OUT,
00082 mpID_CENTER,
00083 mpID_LOCKASPECT,
00084 mpID_LINE_GUIDES,
00085 };
00086
00087
00088
00089
00090
00098 class creaMaracasVisu_EXPORT mpLayer : public wxObject
00099 {
00100 public:
00101 mpLayer();
00102
00110 virtual bool HasBBox() { return TRUE; }
00111
00115 virtual double GetMinX() { return -1.0; }
00116
00120 virtual double GetMaxX() { return 1.0; }
00121
00125 virtual double GetMinY() { return -1.0; }
00126
00130 virtual double GetMaxY() { return 1.0; }
00131
00165 virtual void Plot(wxDC & dc, mpWindow & w) = 0;
00166
00170 wxString GetName() const { return m_name; }
00171
00175 const wxFont& GetFont() const { return m_font; }
00176
00180 const wxPen& GetPen() const { return m_pen; }
00181
00185 void SetName(wxString name) { m_name = name; }
00186
00190 void SetFont(wxFont& font) { m_font = font; }
00191
00195 void SetPen(wxPen& pen) { m_pen = pen; }
00196
00201 int GetYTranslated(double sizey, double y){
00202 return -y+sizey;
00203 }
00204
00205 protected:
00206 wxFont m_font;
00207 wxPen m_pen;
00208 wxString m_name;
00209
00210 DECLARE_CLASS(mpLayer)
00211 };
00212
00213
00214
00215
00216
00221 #define mpALIGNMASK 0x03
00222
00223 #define mpALIGN_RIGHT 0x00
00224
00225 #define mpALIGN_CENTER 0x01
00226
00227 #define mpALIGN_LEFT 0x02
00228
00229 #define mpALIGN_TOP mpALIGN_RIGHT
00230
00231 #define mpALIGN_BOTTOM mpALIGN_LEFT
00232
00233 #define mpALIGN_NE 0x00
00234
00235 #define mpALIGN_NW 0x01
00236
00237 #define mpALIGN_SW 0x02
00238
00239 #define mpALIGN_SE 0x03
00240
00251 class mpFX : public mpLayer
00252 {
00253 public:
00257 mpFX(wxString name = wxEmptyString, int flags = mpALIGN_RIGHT);
00258
00264 virtual double GetY( double x ) = 0;
00265
00270 virtual void Plot(wxDC & dc, mpWindow & w);
00271
00272 protected:
00273 int m_flags;
00274
00275 DECLARE_CLASS(mpFX)
00276 };
00277
00283 class mpFY : public mpLayer
00284 {
00285 public:
00289 mpFY(wxString name = wxEmptyString, int flags = mpALIGN_TOP);
00290
00296 virtual double GetX( double y ) = 0;
00297
00302 virtual void Plot(wxDC & dc, mpWindow & w);
00303
00304 protected:
00305 int m_flags;
00306
00307 DECLARE_CLASS(mpFY)
00308 };
00309
00316 class mpFXY : public mpLayer
00317 {
00318 public:
00322 mpFXY(wxString name = wxEmptyString, int flags = mpALIGN_NE);
00323
00327 virtual void Rewind() = 0;
00328
00334 virtual bool GetNextXY(double & x, double & y) = 0;
00335
00340 virtual void Plot(wxDC & dc, mpWindow & w);
00341
00342 protected:
00343 int m_flags;
00344
00345 DECLARE_CLASS(mpFXY)
00346 };
00347
00350
00351
00352
00353
00362 class mpScaleX : public mpLayer
00363 {
00364 public:
00366 mpScaleX(wxString name = wxT("X"));
00367
00371 virtual void Plot(wxDC & dc, mpWindow & w);
00372
00377 virtual bool HasBBox() { return FALSE; }
00378
00379 DECLARE_CLASS(mpScaleX)
00380 };
00381
00387 class mpScaleY : public mpLayer
00388 {
00389 public:
00391 mpScaleY(wxString name = wxT("Y"));
00392
00396 virtual void Plot(wxDC & dc, mpWindow & w, int orgy);
00397
00402 virtual bool HasBBox() { return FALSE; }
00403
00404 protected:
00405
00406 DECLARE_CLASS(mpScaleY)
00407 };
00408
00409
00410
00411
00412
00417 #define mpMOUSEMODE_DRAG 0
00418
00419 #define mpMOUSEMODE_ZOOMBOX 1
00420
00433 class creaMaracasVisu_EXPORT mpWindow : public wxScrolledWindow
00434 {
00435 public:
00436 mpWindow() {}
00437 mpWindow( wxWindow *parent, wxWindowID id,
00438 const wxPoint &pos = wxDefaultPosition,
00439 const wxSize &size = wxDefaultSize,
00440 int flags = 0);
00441 ~mpWindow();
00442
00446 wxMenu* GetPopupMenu() { return &m_popmenu; }
00447
00448
00449
00450
00451
00452
00453
00454 void setType(int t)
00455 {
00456 type=t;
00457 }
00458
00459
00460
00461 int getType()
00462 {
00463 return type;
00464 }
00465
00466
00471 void setMaxScrX(int maxX)
00472 {
00473 maxScrX=maxX;
00474 }
00479 void setMaxScrY(int maxY)
00480 {
00481 maxScrY=maxY;
00482 }
00483
00484
00488 double getMaxScrX()
00489 {
00490 return maxScrX;
00491 }
00495 double getMaxScrY()
00496 {
00497 return maxScrY;
00498 }
00499
00500
00501
00502 float getZoomFactor()
00503 {
00504 return zoomFactor;
00505 }
00510 void setMinScrX(int minX)
00511 {
00512 minScrX=minX;
00513 }
00518 void setMinScrY(int minY)
00519 {
00520 minScrY=minY;
00521 }
00522
00523
00527 double getMinScrX()
00528 {
00529 return minScrX;
00530 }
00534 double getMinScrY()
00535 {
00536 return minScrY;
00537 }
00538
00543 int getClickedX()
00544 {
00545 return m_clickedX;
00546 }
00547
00552 int getClickedY()
00553 {
00554 return m_clickedY;
00555 }
00556
00561 int getOffsetPixelsX()
00562 {
00563 return offsetPixelX;
00564 }
00565
00570 int getOffsetPixelsY()
00571 {
00572 return offsetPixelY;
00573 }
00577 void setOffsetPixelX(int offX)
00578 {
00579 offsetPixelX=offX;
00580 }
00584 void setOffsetPixelY(int offY)
00585 {
00586 offsetPixelY=offY;
00587 }
00588
00592 int getOffsetX()
00593 {
00594 return offsetX;
00595 }
00596
00600 int getOffsetY()
00601 {
00602 return offsetY;
00603 }
00607 void setOffsetX(int offX)
00608 {
00609 offsetX=offX;
00610 }
00614 void setOffsetY(int offY)
00615 {
00616 offsetY=offY;
00617 }
00618
00619
00620
00621
00622
00623 void setRealGuideX(int newX_realGuide)
00624 {
00625 real_guideLine_X = newX_realGuide;
00626 if(real_guideLine_X!=-1)
00627 UpdateAll();
00628 }
00629
00630
00631
00632
00633
00634 int getRealGuideX()
00635 {
00636 return real_guideLine_X;
00637 }
00638
00639
00640
00641
00642
00643 void setRealGuideY(int newY_realGuide)
00644 {
00645 real_guideLine_Y = newY_realGuide;
00646 if(real_guideLine_Y!=-1)
00647 UpdateAll();
00648 }
00649
00650
00651
00652
00653
00654 int getRealGuideY()
00655 {
00656 return real_guideLine_Y;
00657 }
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673 bool drawGuideLines();
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00693 bool AddLayer( mpLayer* layer);
00694
00698 void DelLayer( mpLayer* layer);
00699
00704 double GetScaleX(void) const { return m_scaleX; }
00705
00710 double GetScaleY(void) const { return m_scaleY; }
00711
00716 double GetPosX(void) const { return m_posX; }
00717
00722 double GetPosY(void) const { return m_posY; }
00723
00730 int GetScrX(void) const { return m_scrX; }
00731
00738 int GetScrY(void) const { return m_scrY; }
00739
00740
00744 void SetScaleX(double scaleX) { if (scaleX!=0) m_scaleX=scaleX; }
00745
00749 void SetScaleY(double scaleY) { if (scaleY!=0) m_scaleY=scaleY; }
00750
00754 void SetPosX(double posX) { m_posX=posX; UpdateAll(); }
00755
00759 void SetPosY(double posY) { m_posY=posY; UpdateAll(); }
00760
00765 void SetPos( double posX, double posY) { m_posX=posX; m_posY=posY; UpdateAll(); }
00766
00772 void LockAspect(bool enable = TRUE);
00773
00778 inline bool IsAspectLocked() { return m_lockaspect; }
00779
00784 void Fit();
00785
00787 void ZoomIn();
00788
00790 void ZoomOut();
00791
00793 void UpdateAll();
00794
00798 int GetYTranslated(wxSize size, double y){
00799 return size.GetHeight()-y;
00800 }
00801
00802 protected:
00803
00804 void Refresh(bool eraseBackground = true, const wxRect* rect = NULL);
00805 void OnPaint (wxPaintEvent &event);
00806 void OnSize (wxSizeEvent &event);
00807 void OnScroll2 (wxScrollWinEvent &event);
00808 void OnShowPopupMenu (wxMouseEvent &event);
00809 void OnCenter (wxCommandEvent &event);
00810 void OnFit (wxCommandEvent &event);
00811 void OnZoomIn (wxCommandEvent &event);
00812 void OnZoomOut (wxCommandEvent &event);
00813 void OnLockAspect (wxCommandEvent &event);
00814
00815
00816 bool UpdateBBox();
00817
00818 wxList m_layers;
00819 wxMenu m_popmenu;
00820 bool m_lockaspect;
00821
00822 double m_minX;
00823 double m_maxX;
00824 double m_minY;
00825 double m_maxY;
00826 double m_scaleX;
00827 double m_scaleY;
00828 double m_posX;
00829 double m_posY;
00830 int m_scrX;
00831 int m_scrY;
00832 int m_clickedX;
00833 int m_clickedY;
00834
00835
00836
00837
00841 int maxScrX;
00842
00846 int maxScrY;
00850 int minScrX;
00851
00855 int minScrY;
00856
00857
00858
00859
00860 float zoomFactor;
00861
00862
00867 int offsetPixelX;
00868 int offsetPixelY;
00869
00870
00871
00872 int offsetX;
00873 int offsetY;
00874
00875
00876
00877
00878 int real_guideLine_X;
00879
00880
00881
00882 int real_guideLine_Y;
00883
00884
00885
00886
00887 bool drawGuides;
00888
00889
00890
00891
00892
00893 int type;
00894
00895 private:
00896
00897 wxBitmap *_bitmap_functions;
00898
00899
00900 DECLARE_CLASS(mpWindow)
00901 DECLARE_EVENT_TABLE()
00902 };
00903
00904 #endif // _MP_MATHPLOT_H_