00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00012 
00013 #ifndef _MP_MATHPLOT_H_
00014 #define _MP_MATHPLOT_H_
00015 
00050 
00051 
00052 
00053 #ifdef mathplot_EXPORTS 
00054  #define WXDLLIMPEXP_MATHPLOT WXEXPORT 
00055  #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type 
00056 #else // not making DLL 
00057  #define WXDLLIMPEXP_MATHPLOT 
00058  #define WXDLLIMPEXP_DATA_MATHPLOT(type) type 
00059 #endif
00060 
00061 #if defined(__GNUG__) && !defined(__APPLE__)
00062 #pragma interface "mathplot.h"
00063 #endif
00064 
00065 #include <vector>
00066 
00067 
00068 #include <wx/defs.h>
00069 #include <wx/menu.h>
00070 #include <wx/scrolwin.h>
00071 #include <wx/event.h>
00072 #include <wx/dynarray.h>
00073 #include <wx/pen.h>
00074 #include <wx/dcmemory.h>
00075 #include <wx/string.h>
00076 #include <wx/print.h>
00077 #include <wx/image.h>
00078 
00079 
00080 #include <deque>
00081 
00082 
00083 #ifdef _WINDOWS
00084 #ifdef _DEBUG
00085 #include <crtdbg.h>
00086 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
00087 #else
00088 #define DEBUG_NEW new
00089 #endif // _DEBUG
00090 #endif // _WINDOWS
00091 
00092 
00093 #define X_BORDER_SEPARATION 40
00094 #define Y_BORDER_SEPARATION 60
00095 
00096 
00097 
00098 
00099 
00100 class WXDLLIMPEXP_MATHPLOT mpLayer;
00101 class WXDLLIMPEXP_MATHPLOT mpFX;
00102 class WXDLLIMPEXP_MATHPLOT mpFY;
00103 class WXDLLIMPEXP_MATHPLOT mpFXY;
00104 class WXDLLIMPEXP_MATHPLOT mpFXYVector;
00105 class WXDLLIMPEXP_MATHPLOT mpScaleX;
00106 class WXDLLIMPEXP_MATHPLOT mpScaleY;
00107 class WXDLLIMPEXP_MATHPLOT mpWindow;
00108 class WXDLLIMPEXP_MATHPLOT mpText;
00109 class WXDLLIMPEXP_MATHPLOT mpPrintout;
00110 
00112 enum
00113 {
00114     mpID_FIT = 2000,    
00115     mpID_ZOOM_IN,       
00116     mpID_ZOOM_OUT,      
00117     mpID_CENTER,        
00118     mpID_LOCKASPECT,    
00119     mpID_HELP_MOUSE     
00120 };
00121 
00122 
00123 
00124 
00125 
00126 typedef enum __mp_Layer_Type {
00127     mpLAYER_UNDEF,  
00128     mpLAYER_AXIS,  
00129     mpLAYER_PLOT,  
00130     mpLAYER_INFO,   
00131     mpLAYER_BITMAP 
00132 } mpLayerType;
00133 
00144 class WXDLLIMPEXP_MATHPLOT mpLayer : public wxObject
00145 {
00146 public:
00147     mpLayer();
00148 
00149     virtual ~mpLayer() {};
00150 
00158     virtual bool   HasBBox() { return TRUE; }
00159 
00166     virtual bool IsInfo() { return false; };
00167 
00171     virtual double GetMinX() { return -1.0; }
00172 
00176     virtual double GetMaxX() { return  1.0; }
00177 
00181     virtual double GetMinY() { return -1.0; }
00182 
00186     virtual double GetMaxY() { return  1.0; }
00187 
00229     virtual void   Plot(wxDC & dc, mpWindow & w) = 0;
00230 
00234     wxString       GetName() const { return m_name; }
00235 
00239     const wxFont&  GetFont() const { return m_font; }
00240 
00244     const wxPen&   GetPen()  const { return m_pen;  }
00245 
00249     void SetContinuity(bool continuity) {m_continuous = continuity;}
00250 
00254     bool GetContinuity() const {return m_continuous;}
00255 
00258     void ShowName(bool show) { m_showName = show; };
00259 
00263     void SetName(wxString name) { m_name = name; }
00264 
00268     void SetFont(wxFont& font)  { m_font = font; }
00269 
00273     void SetPen(wxPen pen)     { m_pen  = pen;  }
00274 
00277     void SetDrawOutsideMargins(bool drawModeOutside) { m_drawOutsideMargins = drawModeOutside; };
00278 
00281     bool GetDrawOutsideMargins() { return m_drawOutsideMargins; };
00282 
00286     wxBitmap GetColourSquare(int side = 16);
00287 
00290     mpLayerType GetLayerType() { return m_type; };
00291     
00294     bool IsVisible() {return m_visible; };
00295 
00298     void SetVisible(bool show) { m_visible = show; };
00299     
00302     const wxBrush&   GetBrush() const { return m_brush; };
00303     
00306     void SetBrush(wxBrush brush) { m_brush = brush; };
00307 
00308 protected:
00309     wxFont   m_font;    
00310     wxPen    m_pen;     
00311     wxBrush  m_brush;       
00312     wxString m_name;    
00313     bool     m_continuous; 
00314     bool     m_showName;  
00315     bool     m_drawOutsideMargins; 
00316     mpLayerType m_type; 
00317     bool    m_visible;  
00318     DECLARE_DYNAMIC_CLASS(mpLayer)
00319 };
00320 
00321 
00322 
00323 
00324 
00325 
00330 class WXDLLIMPEXP_MATHPLOT mpInfoLayer : public mpLayer
00331 {
00332 public:
00334     mpInfoLayer();
00335 
00339     mpInfoLayer(wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH);
00340 
00342     virtual ~mpInfoLayer();
00343 
00348     virtual void UpdateInfo(mpWindow& w, wxEvent& event);
00349 
00352     virtual bool HasBBox() { return false; };
00353 
00358     virtual void   Plot(wxDC & dc, mpWindow & w);
00359 
00363     virtual bool IsInfo() { return true; };
00364 
00368     virtual bool Inside(wxPoint& point);
00369 
00372     virtual void Move(wxPoint delta);
00373 
00375     virtual void UpdateReference();
00376 
00379     wxPoint GetPosition();
00380 
00383     wxSize GetSize();
00384     
00387     const wxRect& GetRectangle() { return m_dim; };
00388 
00389 protected:
00390     wxRect m_dim;           
00391     wxPoint m_reference;    
00392     wxBrush m_brush;        
00393     int m_winX, m_winY;     
00394     
00395     DECLARE_DYNAMIC_CLASS(mpInfoLayer)
00396 };
00397 
00401 class WXDLLIMPEXP_MATHPLOT mpInfoCoords : public mpInfoLayer
00402 {
00403 public:
00405     mpInfoCoords();
00409     mpInfoCoords(wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH);
00410 
00412     ~mpInfoCoords();
00413 
00417     virtual void UpdateInfo(mpWindow& w, wxEvent& event);
00418 
00423     virtual void   Plot(wxDC & dc, mpWindow & w);
00424 
00425 protected:
00426     wxString m_content; 
00427 };
00428 
00432 class WXDLLIMPEXP_MATHPLOT mpInfoLegend : public mpInfoLayer
00433 {
00434 public:
00436     mpInfoLegend();
00437 
00442     mpInfoLegend(wxRect rect, const wxBrush* brush = wxTRANSPARENT_BRUSH);
00443 
00445     ~mpInfoLegend();
00446 
00450     virtual void UpdateInfo(mpWindow& w, wxEvent& event);
00451 
00456     virtual void   Plot(wxDC & dc, mpWindow & w);
00457 
00458 protected:
00459     
00460 };
00461 
00462 
00463 
00464 
00465 
00466 
00471 #define mpALIGNMASK    0x03
00472 
00473 #define mpALIGN_RIGHT  0x00
00474 
00475 #define mpALIGN_CENTER 0x01
00476 
00477 #define mpALIGN_LEFT   0x02
00478 
00479 #define mpALIGN_TOP    mpALIGN_RIGHT
00480 
00481 #define mpALIGN_BOTTOM mpALIGN_LEFT
00482 
00483 #define mpALIGN_BORDER_BOTTOM  0x04
00484 
00485 #define mpALIGN_BORDER_TOP  0x05
00486 
00487 #define mpX_NORMAL  0x00
00488 
00489 #define mpX_TIME  0x01
00490 
00491 #define mpX_HOURS 0x02
00492 
00493 #define mpX_DATE 0x03
00494 
00495 #define mpX_DATETIME 0x04
00496 
00497 #define mpALIGN_BORDER_LEFT mpALIGN_BORDER_BOTTOM
00498 
00499 #define mpALIGN_BORDER_RIGHT mpALIGN_BORDER_TOP
00500 
00501 #define mpALIGN_NE     0x00
00502 
00503 #define mpALIGN_NW     0x01
00504 
00505 #define mpALIGN_SW     0x02
00506 
00507 #define mpALIGN_SE     0x03
00508 
00519 class WXDLLIMPEXP_MATHPLOT mpFX : public mpLayer
00520 {
00521 public:
00525     mpFX(wxString name = wxEmptyString, int flags = mpALIGN_RIGHT);
00526 
00532     virtual double GetY( double x ) = 0;
00533 
00538     virtual void Plot(wxDC & dc, mpWindow & w);
00539 
00540 protected:
00541     int m_flags; 
00542 
00543     DECLARE_DYNAMIC_CLASS(mpFX)
00544 };
00545 
00551 class WXDLLIMPEXP_MATHPLOT mpFY : public mpLayer
00552 {
00553 public:
00557     mpFY(wxString name = wxEmptyString, int flags = mpALIGN_TOP);
00558 
00564     virtual double GetX( double y ) = 0;
00565 
00570     virtual void Plot(wxDC & dc, mpWindow & w);
00571 
00572 protected:
00573     int m_flags; 
00574 
00575     DECLARE_DYNAMIC_CLASS(mpFY)
00576 };
00577 
00584 class WXDLLIMPEXP_MATHPLOT mpFXY : public mpLayer
00585 {
00586 public:
00590     mpFXY(wxString name = wxEmptyString, int flags = mpALIGN_NE);
00591 
00595     virtual void Rewind() = 0;
00596 
00602     virtual bool GetNextXY(double & x, double & y) = 0;
00603 
00608     virtual void Plot(wxDC & dc, mpWindow & w);
00609 
00610 
00611 protected:
00612     int m_flags; 
00613 
00614     
00615     wxCoord maxDrawX, minDrawX, maxDrawY, minDrawY;
00616     
00617 
00622     void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
00623 
00624     DECLARE_DYNAMIC_CLASS(mpFXY)
00625 };
00626 
00633 class WXDLLIMPEXP_MATHPLOT mpProfile : public mpLayer
00634 {
00635 public:
00639     mpProfile(wxString name = wxEmptyString, int flags = mpALIGN_TOP);
00640 
00646     virtual double GetY( double x ) = 0;
00647 
00652     virtual void Plot(wxDC & dc, mpWindow & w);
00653 
00654 protected:
00655     int m_flags; 
00656 
00657     DECLARE_DYNAMIC_CLASS(mpProfile)
00658 };
00659 
00662 
00663 
00664 
00665 
00674 class WXDLLIMPEXP_MATHPLOT mpScaleX : public mpLayer
00675 {
00676 public:
00682     mpScaleX(wxString name = wxT("X"), int flags = mpALIGN_CENTER, bool ticks = true, unsigned int type = mpX_NORMAL);
00683 
00686     virtual void Plot(wxDC & dc, mpWindow & w);
00687 
00691     virtual bool HasBBox() { return FALSE; }
00692 
00695     void SetAlign(int align) { m_flags = align; };
00696 
00699     void SetTicks(bool ticks) { m_ticks = ticks; };
00700 
00703     bool GetTicks() { return m_ticks; };
00704 
00707     unsigned int GetLabelMode() { return m_labelType; };
00708 
00711     void SetLabelMode(unsigned int mode) { m_labelType = mode; };
00712     
00715     void SetLabelFormat(const wxString& format) { m_labelFormat = format; };
00716 
00719     const wxString& SetLabelFormat() { return m_labelFormat; };
00720     
00721 protected:
00722     int m_flags; 
00723     bool m_ticks; 
00724     unsigned int m_labelType; 
00725     wxString m_labelFormat; 
00726 
00727     DECLARE_DYNAMIC_CLASS(mpScaleX)
00728 };
00729 
00735 class WXDLLIMPEXP_MATHPLOT mpScaleY : public mpLayer
00736 {
00737 public:
00741     mpScaleY(wxString name = wxT("Y"), int flags = mpALIGN_CENTER, bool ticks = true);
00742 
00746     virtual void Plot(wxDC & dc, mpWindow & w);
00747 
00752     virtual bool HasBBox() { return FALSE; }
00753 
00756     void SetAlign(int align) { m_flags = align; };
00757 
00760     void SetTicks(bool ticks) { m_ticks = ticks; };
00761 
00764     bool GetTicks() { return m_ticks; };
00765     
00768     void SetLabelFormat(const wxString& format) { m_labelFormat = format; };
00769     
00772     const wxString& SetLabelFormat() { return m_labelFormat; };
00773 
00774 protected:
00775     int m_flags; 
00776     bool m_ticks; 
00777     wxString m_labelFormat; 
00778 
00779     DECLARE_DYNAMIC_CLASS(mpScaleY)
00780 };
00781 
00782 
00783 
00784 
00785 
00790 #define mpMOUSEMODE_DRAG    0
00791 
00792 #define mpMOUSEMODE_ZOOMBOX 1
00793 
00796 
00797 typedef std::deque<mpLayer*> wxLayerList;
00798 
00821 class WXDLLIMPEXP_MATHPLOT mpWindow : public wxWindow
00822 {
00823 public:
00824     mpWindow() {}
00825     mpWindow( wxWindow *parent, wxWindowID id,
00826                      const wxPoint &pos = wxDefaultPosition,
00827                      const wxSize &size = wxDefaultSize,
00828                      long flags = 0);
00829     ~mpWindow();
00830 
00834     wxMenu* GetPopupMenu() { return &m_popmenu; }
00835 
00843     bool AddLayer( mpLayer* layer, bool refreshDisplay = true);
00844 
00853     bool DelLayer( mpLayer* layer, bool alsoDeleteObject = false, bool refreshDisplay = true);
00854 
00859     void DelAllLayers( bool alsoDeleteObject, bool refreshDisplay = true);
00860     
00861     
00867     mpLayer* GetLayer(int position);
00868 
00873     mpLayer* GetLayerByName( const wxString &name);
00874 
00879     double GetXscl() { return m_scaleX; }
00880     double GetScaleX(void) const{ return m_scaleX; }; 
00881 
00886     double GetYscl() const { return m_scaleY; }
00887     double GetScaleY(void) const { return m_scaleY; } 
00888 
00893     double GetXpos() const { return m_posX; }
00894     double GetPosX(void) const { return m_posX; }
00895 
00900     double GetYpos() const { return m_posY; }
00901     double GetPosY(void) const { return m_posY; }
00902 
00909     int GetScrX(void) const { return m_scrX; }
00910     int GetXScreen(void) const { return m_scrX; }
00911 
00918     int GetScrY(void) const { return m_scrY; }
00919     int GetYScreen(void) const { return m_scrY; }
00920 
00924     void SetScaleX(double scaleX);
00925 
00929     void SetScaleY(double scaleY) { if (scaleY!=0) m_scaleY=scaleY; UpdateAll(); }
00930 
00934     void SetPosX(double posX) { m_posX=posX; UpdateAll(); }
00935 
00939     void SetPosY(double posY) { m_posY=posY; UpdateAll(); }
00940 
00945     void SetPos( double posX, double posY) { m_posX=posX; m_posY=posY; UpdateAll(); }
00946 
00952     void SetScr( int scrX, int scrY) { m_scrX=scrX; m_scrY=scrY; }
00953     
00956 
00957     inline double p2x(wxCoord pixelCoordX ) { return m_posX + pixelCoordX/m_scaleX; }
00958 
00961 
00962     inline double p2y(wxCoord pixelCoordY ) { return m_posY - pixelCoordY/m_scaleY; }
00963 
00966 
00967     inline wxCoord x2p(double x) { return (wxCoord) ( (x-m_posX) * m_scaleX); }
00968 
00971 
00972     inline wxCoord y2p(double y) { return (wxCoord) ( (m_posY-y) * m_scaleY); }
00973 
00974 
00977     void EnableDoubleBuffer( bool enabled ) { m_enableDoubleBuffer = enabled; }
00978 
00981     void EnableMousePanZoom( bool enabled ) { m_enableMouseNavigation = enabled; }
00982 
00988     void LockAspect(bool enable = TRUE);
00989 
00994     inline bool IsAspectLocked() { return m_lockaspect; }
00995 
01000     void Fit();
01001 
01008     void Fit(double xMin, double xMax, double yMin, double yMax,wxCoord *printSizeX=NULL,wxCoord *printSizeY=NULL);
01009 
01013     void ZoomIn( const wxPoint& centerPoint = wxDefaultPosition );
01014 
01018     void ZoomOut( const wxPoint& centerPoint = wxDefaultPosition );
01019 
01021     void ZoomInX();
01023     void ZoomOutX();
01025     void ZoomInY();
01027     void ZoomOutY();
01028 
01030     void ZoomRect(wxPoint p0, wxPoint p1);
01031 
01033     void UpdateAll();
01034 
01035     
01036 
01040     unsigned int CountLayers();
01041     
01044     unsigned int CountAllLayers() { return m_layers.size(); };
01045 
01048     
01049 
01050 
01054     double GetDesiredXmin() {return m_desiredXmin; }
01055 
01059     double GetDesiredXmax() {return m_desiredXmax; }
01060 
01064     double GetDesiredYmin() {return m_desiredYmin; }
01065 
01069     double GetDesiredYmax() {return m_desiredYmax; }
01070 
01073     void GetBoundingBox(double* bbox);
01074     
01077     void SetMPScrollbars(bool status);
01078 
01081     bool GetMPScrollbars() {return m_enableScrollBars; };
01082 
01088     bool SaveScreenshot(const wxString& filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
01089 
01092     static double zoomIncrementalFactor;
01093 
01099     void SetMargins(int top, int right, int bottom, int left);
01100 
01102     void SetMarginTop(int top) { m_marginTop = top; };
01104     void SetMarginRight(int right) { m_marginRight = right; };
01106     void SetMarginBottom(int bottom) { m_marginBottom = bottom; };
01108     void SetMarginLeft(int left) { m_marginLeft = left; };
01109 
01111     int GetMarginTop() { return m_marginTop; };
01113     int GetMarginRight() { return m_marginRight; };
01115     int GetMarginBottom() { return m_marginBottom; };
01117     int GetMarginLeft() { return m_marginLeft; };
01118 
01120     
01122     
01123 
01127     mpInfoLayer* IsInsideInfoLayer(wxPoint& point);
01128     
01132     void SetLayerVisible(const wxString &name, bool viewable);
01133     
01137     bool IsLayerVisible(const wxString &name );
01138     
01142     void SetLayerVisible(const unsigned int position, bool viewable);
01143     
01147     bool IsLayerVisible(const unsigned int position );
01148 
01153     void SetColourTheme(const wxColour& bgColour, const wxColour& drawColour, const wxColour& axesColour);
01154     
01157     const wxColour& GetAxesColour() { return m_axColour; };
01158 
01159 protected:
01160     void OnPaint         (wxPaintEvent     &event); 
01161     void OnSize          (wxSizeEvent      &event); 
01162     
01163     void OnShowPopupMenu (wxMouseEvent     &event); 
01164     void OnMouseRightDown(wxMouseEvent     &event); 
01165     void OnCenter        (wxCommandEvent   &event); 
01166     void OnFit           (wxCommandEvent   &event); 
01167     void OnZoomIn        (wxCommandEvent   &event); 
01168     void OnZoomOut       (wxCommandEvent   &event); 
01169     void OnLockAspect    (wxCommandEvent   &event); 
01170     void OnMouseHelp     (wxCommandEvent   &event); 
01171     void OnMouseWheel    (wxMouseEvent     &event); 
01172     void OnMouseMove     (wxMouseEvent     &event); 
01173     void OnMouseLeftDown (wxMouseEvent     &event); 
01174     void OnMouseLeftRelease (wxMouseEvent  &event); 
01175     void OnScrollThumbTrack (wxScrollWinEvent &event); 
01176     void OnScrollPageUp     (wxScrollWinEvent &event); 
01177     void OnScrollPageDown   (wxScrollWinEvent &event); 
01178     void OnScrollLineUp     (wxScrollWinEvent &event); 
01179     void OnScrollLineDown   (wxScrollWinEvent &event); 
01180     void OnScrollTop        (wxScrollWinEvent &event); 
01181     void OnScrollBottom     (wxScrollWinEvent &event); 
01182 
01183     void DoScrollCalc    (const int position, const int orientation);
01184 
01185     void DoZoomInXCalc   (const int         staticXpixel);
01186     void DoZoomInYCalc   (const int         staticYpixel);
01187     void DoZoomOutXCalc  (const int         staticXpixel);
01188     void DoZoomOutYCalc  (const int         staticYpixel);
01189 
01193     virtual bool UpdateBBox();
01194 
01195     
01196     wxLayerList m_layers; 
01197     wxMenu m_popmenu;   
01198     bool   m_lockaspect;
01199     
01200     wxColour m_bgColour;    
01201     wxColour m_fgColour;    
01202     wxColour m_axColour;    
01203 
01204     double m_minX;      
01205     double m_maxX;      
01206     double m_minY;      
01207     double m_maxY;      
01208     double m_scaleX;    
01209     double m_scaleY;    
01210     double m_posX;      
01211     double m_posY;      
01212     int    m_scrX;      
01213     int    m_scrY;      
01214     int    m_clickedX;  
01215     int    m_clickedY;  
01216 
01219     double m_desiredXmin,m_desiredXmax,m_desiredYmin,m_desiredYmax;
01220 
01221     int m_marginTop, m_marginRight, m_marginBottom, m_marginLeft;
01222 
01223     int         m_last_lx,m_last_ly;   
01224     wxMemoryDC  m_buff_dc;             
01225     wxBitmap    *m_buff_bmp;            
01226     bool        m_enableDoubleBuffer;  
01227     bool        m_enableMouseNavigation;  
01228     bool        m_mouseMovedAfterRightClick;
01229     long        m_mouseRClick_X,m_mouseRClick_Y; 
01230     int         m_mouseLClick_X, m_mouseLClick_Y; 
01231     bool        m_enableScrollBars;
01232     int         m_scrollX, m_scrollY;
01233     mpInfoLayer* m_movingInfoLayer;      
01234 
01235     DECLARE_DYNAMIC_CLASS(mpWindow)
01236     DECLARE_EVENT_TABLE()
01237 };
01238 
01239 
01240 
01241 
01242 
01262 class WXDLLIMPEXP_MATHPLOT mpFXYVector : public mpFXY
01263 {
01264 public:
01268     mpFXYVector(wxString name = wxEmptyString, int flags = mpALIGN_NE);
01269 
01274     void SetData( const std::vector<double> &xs,const std::vector<double> &ys);
01275 
01279     void Clear();
01280 
01281 protected:
01284     std::vector<double>  m_xs,m_ys;
01285 
01288     size_t              m_index;
01289 
01292     double              m_minX,m_maxX,m_minY,m_maxY;
01293 
01297     void Rewind();
01298 
01304     bool GetNextXY(double & x, double & y);
01305 
01308     double GetMinX() { return m_minX; }
01309 
01312     double GetMinY() { return m_minY; }
01313 
01316     double GetMaxX() { return m_maxX; }
01317 
01320     double GetMaxY() { return m_maxY; }
01321 
01322     int     m_flags; 
01323 
01324     DECLARE_DYNAMIC_CLASS(mpFXYVector)
01325 };
01326 
01327 
01328 
01329 
01330 
01337 class WXDLLIMPEXP_MATHPLOT mpText : public mpLayer
01338 {
01339 public:
01343     mpText(wxString name = wxT("Title"), int offsetx = 5, int offsety = 50);
01344 
01347     virtual void Plot(wxDC & dc, mpWindow & w);
01348 
01350     virtual bool HasBBox() { return FALSE; }
01351 
01352 protected:
01353     int m_offsetx; 
01354     int m_offsety; 
01355 
01356     DECLARE_DYNAMIC_CLASS(mpText)
01357 };
01358 
01359 
01360 
01361 
01362 
01363 
01368 class WXDLLIMPEXP_MATHPLOT mpPrintout : public wxPrintout
01369 {
01370 public:
01371     mpPrintout(mpWindow* drawWindow, const wxChar *title = _T("wxMathPlot print output"));
01372     virtual ~mpPrintout() {};
01373 
01374     void SetDrawState(bool drawState) {drawn = drawState;};
01375     bool OnPrintPage(int page);
01376     bool HasPage(int page);
01377 
01378 private:
01379     bool drawn;
01380     mpWindow *plotWindow;
01381 };
01382 
01383 
01384 
01385 
01386 
01393 class WXDLLIMPEXP_MATHPLOT mpMovableObject : public mpLayer
01394 {
01395 public:
01398     mpMovableObject( ) :
01399         m_reference_x(0),
01400         m_reference_y(0),
01401         m_reference_phi(0),
01402         m_shape_xs(0),
01403         m_shape_ys(0)
01404     {
01405         m_type = mpLAYER_PLOT;
01406     }
01407 
01408     virtual ~mpMovableObject() {};
01409 
01412     void GetCoordinateBase( double &x, double &y, double &phi ) const
01413     {
01414         x = m_reference_x;
01415         y = m_reference_y;
01416         phi = m_reference_phi;
01417     }
01418 
01421     void SetCoordinateBase( double x, double y, double phi = 0 )
01422     {
01423         m_reference_x = x;
01424         m_reference_y = y;
01425         m_reference_phi = phi;
01426         m_flags  = mpALIGN_NE;
01427         ShapeUpdated();
01428     }
01429 
01430     virtual bool HasBBox() { return m_trans_shape_xs.size()!=0; }
01431 
01434     virtual double GetMinX() { return m_bbox_min_x; }
01435 
01438     virtual double GetMaxX() { return  m_bbox_max_x; }
01439 
01442     virtual double GetMinY() { return m_bbox_min_y; }
01443 
01446     virtual double GetMaxY() { return m_bbox_max_y; }
01447 
01448     virtual void   Plot(wxDC & dc, mpWindow & w);
01449 
01453     void SetAlign(int align) { m_flags = align; };
01454 
01455 protected:
01456     int m_flags; 
01457 
01460     double m_reference_x,m_reference_y,m_reference_phi;
01461 
01464     void TranslatePoint( double x,double y, double &out_x, double &out_y );
01465 
01468     std::vector<double>  m_shape_xs,m_shape_ys;
01469 
01473     std::vector<double>  m_trans_shape_xs,m_trans_shape_ys;
01474 
01478     double  m_bbox_min_x,m_bbox_max_x,m_bbox_min_y,m_bbox_max_y;
01479 
01483     void ShapeUpdated();
01484 
01485 };
01486 
01487 
01488 
01489 
01501 class WXDLLIMPEXP_MATHPLOT mpCovarianceEllipse : public mpMovableObject
01502 {
01503 public:
01507     mpCovarianceEllipse(
01508         double cov_00 = 1,
01509         double cov_11 = 1,
01510         double cov_01 = 0,
01511         double quantiles = 2,
01512         int    segments = 32,
01513         const wxString & layerName = wxT("") ) :
01514             m_cov_00(cov_00),
01515             m_cov_11(cov_11),
01516             m_cov_01(cov_01),
01517             m_quantiles(quantiles),
01518             m_segments(segments)
01519     {
01520         m_continuous = true;
01521         m_name = layerName;
01522         RecalculateShape();
01523         m_type = mpLAYER_PLOT;
01524     }
01525 
01526     virtual ~mpCovarianceEllipse() {}
01527 
01528     double GetQuantiles() const { return m_quantiles; }
01529 
01532     void SetQuantiles(double q)
01533     {
01534         m_quantiles=q;
01535         RecalculateShape();
01536     }
01537 
01538     void SetSegments( int segments ) { m_segments = segments; }
01539     int GetSegments( ) const { return m_segments; }
01540 
01543     void GetCovarianceMatrix( double &cov_00,double &cov_01,double &cov_11 ) const
01544     {
01545         cov_00 = m_cov_00;
01546         cov_01 = m_cov_01;
01547         cov_11 = m_cov_11;
01548     }
01549 
01552     void SetCovarianceMatrix( double cov_00,double cov_01,double cov_11 )
01553     {
01554         m_cov_00 = cov_00;
01555         m_cov_01 = cov_01;
01556         m_cov_11 = cov_11;
01557         RecalculateShape();
01558     }
01559 
01560 protected:
01563     double m_cov_00,m_cov_11,m_cov_01;
01564     double m_quantiles;
01565 
01568     int m_segments;
01569 
01572     void RecalculateShape();
01573 };
01574 
01575 
01576 
01577 
01582 class WXDLLIMPEXP_MATHPLOT mpPolygon : public mpMovableObject
01583 {
01584 public:
01587     mpPolygon( const wxString & layerName = wxT("") )
01588     {
01589         m_continuous = true;
01590         m_name = layerName;
01591     }
01592 
01593     virtual ~mpPolygon() {}
01594 
01600     void setPoints(
01601         const std::vector<double>&  points_xs,
01602         const std::vector<double>&  points_ys,
01603         bool                   closedShape=true );
01604 
01605 
01606 
01607 };
01608 
01609 
01610 
01611 
01618 class WXDLLIMPEXP_MATHPLOT mpBitmapLayer : public mpLayer
01619 {
01620 public:
01623     mpBitmapLayer( )
01624     {
01625         m_min_x = m_max_x =
01626         m_min_y = m_max_y = 0;
01627         m_validImg = false;
01628         m_type = mpLAYER_BITMAP;
01629     }
01630 
01631     virtual ~mpBitmapLayer() {};
01632 
01635     void GetBitmapCopy( wxImage &outBmp ) const;
01636 
01644     void SetBitmap( const wxImage &inBmp, double x, double y, double lx, double ly );
01645 
01646     virtual bool HasBBox() { return true; }
01647 
01650     virtual double GetMinX() { return m_min_x; }
01651 
01654     virtual double GetMaxX() { return  m_max_x; }
01655 
01658     virtual double GetMinY() { return m_min_y; }
01659 
01662     virtual double GetMaxY() { return m_max_y; }
01663 
01664     virtual void   Plot(wxDC & dc, mpWindow & w);
01665 
01669     void SetAlign(int align) { m_flags = align; };
01670 
01671 protected:
01672     int m_flags; 
01673 
01676     wxImage      m_bitmap;
01677     wxBitmap     m_scaledBitmap;
01678     wxCoord      m_scaledBitmap_offset_x,m_scaledBitmap_offset_y;
01679 
01680 
01681     bool            m_validImg;
01682 
01683 
01686     double  m_min_x,m_max_x,m_min_y,m_max_y;
01687 
01688 
01689 };
01690 
01691 
01692 
01695 #endif // _MP_MATHPLOT_H_