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
00197 protected:
00198 wxFont m_font;
00199 wxPen m_pen;
00200 wxString m_name;
00201
00202 DECLARE_CLASS(mpLayer)
00203 };
00204
00205
00206
00207
00208
00213 #define mpALIGNMASK 0x03
00214
00215 #define mpALIGN_RIGHT 0x00
00216
00217 #define mpALIGN_CENTER 0x01
00218
00219 #define mpALIGN_LEFT 0x02
00220
00221 #define mpALIGN_TOP mpALIGN_RIGHT
00222
00223 #define mpALIGN_BOTTOM mpALIGN_LEFT
00224
00225 #define mpALIGN_NE 0x00
00226
00227 #define mpALIGN_NW 0x01
00228
00229 #define mpALIGN_SW 0x02
00230
00231 #define mpALIGN_SE 0x03
00232
00243 class mpFX : public mpLayer
00244 {
00245 public:
00249 mpFX(wxString name = wxEmptyString, int flags = mpALIGN_RIGHT);
00250
00256 virtual double GetY( double x ) = 0;
00257
00262 virtual void Plot(wxDC & dc, mpWindow & w);
00263
00264 protected:
00265 int m_flags;
00266
00267 DECLARE_CLASS(mpFX)
00268 };
00269
00275 class mpFY : public mpLayer
00276 {
00277 public:
00281 mpFY(wxString name = wxEmptyString, int flags = mpALIGN_TOP);
00282
00288 virtual double GetX( double y ) = 0;
00289
00294 virtual void Plot(wxDC & dc, mpWindow & w);
00295
00296 protected:
00297 int m_flags;
00298
00299 DECLARE_CLASS(mpFY)
00300 };
00301
00308 class mpFXY : public mpLayer
00309 {
00310 public:
00314 mpFXY(wxString name = wxEmptyString, int flags = mpALIGN_NE);
00315
00319 virtual void Rewind() = 0;
00320
00326 virtual bool GetNextXY(double & x, double & y) = 0;
00327
00332 virtual void Plot(wxDC & dc, mpWindow & w);
00333
00334 protected:
00335 int m_flags;
00336
00337 DECLARE_CLASS(mpFXY)
00338 };
00339
00342
00343
00344
00345
00354 class mpScaleX : public mpLayer
00355 {
00356 public:
00358 mpScaleX(wxString name = wxT("X"));
00359
00363 virtual void Plot(wxDC & dc, mpWindow & w);
00364
00369 virtual bool HasBBox() { return FALSE; }
00370
00371 DECLARE_CLASS(mpScaleX)
00372 };
00373
00379 class mpScaleY : public mpLayer
00380 {
00381 public:
00383 mpScaleY(wxString name = wxT("Y"));
00384
00388 virtual void Plot(wxDC & dc, mpWindow & w);
00389
00394 virtual bool HasBBox() { return FALSE; }
00395
00396 protected:
00397
00398 DECLARE_CLASS(mpScaleY)
00399 };
00400
00401
00402
00403
00404
00409 #define mpMOUSEMODE_DRAG 0
00410
00411 #define mpMOUSEMODE_ZOOMBOX 1
00412
00425 class creaMaracasVisu_EXPORT mpWindow : public wxScrolledWindow
00426 {
00427 public:
00428 mpWindow() {}
00429 mpWindow( wxWindow *parent, wxWindowID id,
00430 const wxPoint &pos = wxDefaultPosition,
00431 const wxSize &size = wxDefaultSize,
00432 int flags = 0);
00433 ~mpWindow();
00434
00438 wxMenu* GetPopupMenu() { return &m_popmenu; }
00439
00440
00441
00442
00443
00444
00445
00446 void setType(int t)
00447 {
00448 type=t;
00449 }
00450
00451
00452
00453 int getType()
00454 {
00455 return type;
00456 }
00457
00458
00463 void setMaxScrX(int maxX)
00464 {
00465 maxScrX=maxX;
00466 }
00471 void setMaxScrY(int maxY)
00472 {
00473 maxScrY=maxY;
00474 }
00475
00476
00480 double getMaxScrX()
00481 {
00482 return maxScrX;
00483 }
00487 double getMaxScrY()
00488 {
00489 return maxScrY;
00490 }
00491
00492
00493
00494 float getZoomFactor()
00495 {
00496 return zoomFactor;
00497 }
00502 void setMinScrX(int minX)
00503 {
00504 minScrX=minX;
00505 }
00510 void setMinScrY(int minY)
00511 {
00512 minScrY=minY;
00513 }
00514
00515
00519 double getMinScrX()
00520 {
00521 return minScrX;
00522 }
00526 double getMinScrY()
00527 {
00528 return minScrY;
00529 }
00530
00535 int getClickedX()
00536 {
00537 return m_clickedX;
00538 }
00539
00544 int getClickedY()
00545 {
00546 return m_clickedY;
00547 }
00548
00553 int getOffsetPixelsX()
00554 {
00555 return offsetPixelX;
00556 }
00557
00562 int getOffsetPixelsY()
00563 {
00564 return offsetPixelY;
00565 }
00569 void setOffsetPixelX(int offX)
00570 {
00571 offsetPixelX=offX;
00572 }
00576 void setOffsetPixelY(int offY)
00577 {
00578 offsetPixelY=offY;
00579 }
00580
00584 int getOffsetX()
00585 {
00586 return offsetX;
00587 }
00588
00592 int getOffsetY()
00593 {
00594 return offsetY;
00595 }
00599 void setOffsetX(int offX)
00600 {
00601 offsetX=offX;
00602 }
00606 void setOffsetY(int offY)
00607 {
00608 offsetY=offY;
00609 }
00610
00611
00612
00613
00614
00615 void setRealGuideX(int newX_realGuide)
00616 {
00617 real_guideLine_X = newX_realGuide;
00618 if(real_guideLine_X!=-1)
00619 UpdateAll();
00620 }
00621
00622
00623
00624
00625
00626 int getRealGuideX()
00627 {
00628 return real_guideLine_X;
00629 }
00630
00631
00632
00633
00634
00635 void setRealGuideY(int newY_realGuide)
00636 {
00637 real_guideLine_Y = newY_realGuide;
00638 if(real_guideLine_Y!=-1)
00639 UpdateAll();
00640 }
00641
00642
00643
00644
00645
00646 int getRealGuideY()
00647 {
00648 return real_guideLine_Y;
00649 }
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665 bool drawGuideLines();
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00685 bool AddLayer( mpLayer* layer);
00686
00690 void DelLayer( mpLayer* layer);
00691
00696 double GetScaleX(void) const { return m_scaleX; }
00697
00702 double GetScaleY(void) const { return m_scaleY; }
00703
00708 double GetPosX(void) const { return m_posX; }
00709
00714 double GetPosY(void) const { return m_posY; }
00715
00722 int GetScrX(void) const { return m_scrX; }
00723
00730 int GetScrY(void) const { return m_scrY; }
00731
00732
00736 void SetScaleX(double scaleX) { if (scaleX!=0) m_scaleX=scaleX; }
00737
00741 void SetScaleY(double scaleY) { if (scaleY!=0) m_scaleY=scaleY; }
00742
00746 void SetPosX(double posX) { m_posX=posX; UpdateAll(); }
00747
00751 void SetPosY(double posY) { m_posY=posY; UpdateAll(); }
00752
00757 void SetPos( double posX, double posY) { m_posX=posX; m_posY=posY; UpdateAll(); }
00758
00764 void LockAspect(bool enable = TRUE);
00765
00770 inline bool IsAspectLocked() { return m_lockaspect; }
00771
00776 void Fit();
00777
00779 void ZoomIn();
00780
00782 void ZoomOut();
00783
00785 void UpdateAll();
00786
00787 protected:
00788
00789 void Refresh(bool eraseBackground = true, const wxRect* rect = NULL);
00790 void OnPaint (wxPaintEvent &event);
00791 void OnSize (wxSizeEvent &event);
00792 void OnScroll2 (wxScrollWinEvent &event);
00793 void OnShowPopupMenu (wxMouseEvent &event);
00794 void OnCenter (wxCommandEvent &event);
00795 void OnFit (wxCommandEvent &event);
00796 void OnZoomIn (wxCommandEvent &event);
00797 void OnZoomOut (wxCommandEvent &event);
00798 void OnLockAspect (wxCommandEvent &event);
00799
00800
00801 bool UpdateBBox();
00802
00803 wxList m_layers;
00804 wxMenu m_popmenu;
00805 bool m_lockaspect;
00806
00807 double m_minX;
00808 double m_maxX;
00809 double m_minY;
00810 double m_maxY;
00811 double m_scaleX;
00812 double m_scaleY;
00813 double m_posX;
00814 double m_posY;
00815 int m_scrX;
00816 int m_scrY;
00817 int m_clickedX;
00818 int m_clickedY;
00819
00820
00821
00822
00826 int maxScrX;
00827
00831 int maxScrY;
00835 int minScrX;
00836
00840 int minScrY;
00841
00842
00843
00844
00845 float zoomFactor;
00846
00847
00852 int offsetPixelX;
00853 int offsetPixelY;
00854
00855
00856
00857 int offsetX;
00858 int offsetY;
00859
00860
00861
00862
00863 int real_guideLine_X;
00864
00865
00866
00867 int real_guideLine_Y;
00868
00869
00870
00871
00872 bool drawGuides;
00873
00874
00875
00876
00877
00878 int type;
00879
00880 private:
00881
00882 wxBitmap *_bitmap_functions;
00883
00884
00885 DECLARE_CLASS(mpWindow)
00886 DECLARE_EVENT_TABLE()
00887 };
00888
00889 #endif // _MP_MATHPLOT_H_