pPlotterWindow.h

Go to the documentation of this file.
00001 
00002 #ifndef __pPlotterWindow_h__
00003 #define __pPlotterWindow_h__
00004 
00005 // ----------------------------------------------------------------------------
00006 // WX headers inclusion.
00007 // For compilers that support precompilation, includes <wx/wx.h>.
00008 // ----------------------------------------------------------------------------
00009 
00010 #include <wx/wxprec.h>
00011 #ifdef __BORLANDC__
00012 #pragma hdrstop
00013 #endif
00014 #ifndef WX_PRECOMP
00015 #include <wx/wx.h>
00016 #endif
00017 
00018 //----------------------------------------------------------------------------
00019 // Includes
00020 //----------------------------------------------------------------------------
00021 
00022 
00023 #include "pPlotterLayer.h"
00024 #include "pGraphicalFunction.h"
00025 #include "mathplot.h"
00026 #include "marTypes.h"
00027 
00028 
00029 
00031 enum
00032 {
00033         pwID_ADDPOINT = 2010,    
00034         pwID_DELPOINT,       
00035         pwID_SHOWPOINTS,  
00036         pwID_STARTDRAWING, 
00037         pwID_DELFUNCTION, 
00038         pwID_STOPDRAWING,
00039         pwID_ADDNEWPOINT,
00040         pwID_NOSHOWPOINTS, 
00041         pwID_MYZOOMIN,
00042         pwID_MYZOOMOUT,
00043         pwID_SPLINE,
00044         pwID_LINE,
00045         pwID_SAVE,
00046         pwID_LOAD, 
00047         pwID_CHANGECOLOR, 
00048         pwID_TRASLATEACTUALFUNCTION, 
00049         pwID_LEFTUP
00050 
00051 };
00052 
00053 #define MAX_FUNCTIONS 7
00054 
00058 #define DEFAULT_SCALE 1
00059 
00062 #define MAX_SCALE 2
00063 
00066 #define USER_SCALE 3
00067 
00068 /*
00069  Types of Plotter
00070 */
00071 /*
00072  Lets to the user to plot any number of the
00073  functions
00074 */
00075 #define DEFAULT_PLOTTER 1
00076 /*
00077  Dont let draw on the plotter, but lets to edit
00078  the functions that are editables in the plotter
00079 */
00080 #define HISTOGRAM_PLOTTER 2
00081 
00084 //#define ZOOM_FACTOR 2
00085 //----------------------------------------------------------------------------
00086 // Class definition
00087 //----------------------------------------------------------------------------
00088 
00089 class creaMaracasVisu_EXPORT pPlotterWindow: public mpWindow
00090 {
00091 public:
00095         pPlotterWindow( wxWindow *parent, wxWindowID id,
00096                 const wxPoint &pos = wxDefaultPosition,
00097                 const wxSize &size = wxDefaultSize,
00098                 int flags = 0);
00099         ~pPlotterWindow();
00100         
00101         //----------------------------
00102         //Handling Options Menu
00103         //----------------------------
00104         /*
00105         if any parameter is true, is going to be remove from the popUp menu
00106         */
00107         void setPopUpMenu(bool startD,bool stopD,bool smooth,bool line, bool zoomIn,
00108                                           bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP,
00109                                           bool delPoint,bool load,bool save);
00110 
00111 
00112         //-------------------------------
00113         //Traslating the actual function
00114         //-------------------------------
00115         /*
00116                 Manipulating clicks on the plotter
00117         */
00118         void onLeftUp(wxMouseEvent& event);
00119         
00120         /*
00121          Move the actual function  when the user
00122          is moving the mouse
00123         */
00124         void onMoveFunction(wxCommandEvent& aEvent);
00125 
00126 
00130         void onChangeColor(wxCommandEvent& aEvent);
00131 
00132 
00136         void onLoad(wxCommandEvent& aEvent);
00137 
00141         void onSave(wxCommandEvent& aEvent);
00142 
00143 
00148         void onLine(wxCommandEvent& aEvent);
00149 
00150 
00154         void onSplinePoints(wxCommandEvent& aEvent);
00155         
00156         
00160         void onMyZoomOut(wxCommandEvent& aEvent);
00161 
00165         void onMyZoomIn(wxCommandEvent& aEvent);
00166 
00171         wxPoint getRealPoint(wxPoint pixelPoint);         
00172 
00176         void onNoShowPoints(wxCommandEvent& aEvent);
00177 
00181         void onStopDrawing(wxCommandEvent& aEvent);
00182 
00188         void onAddNewPoint(wxCommandEvent& aEvent);
00189 
00193         void onStartDrawing(wxCommandEvent& aEvent);
00194 
00198         void onMouseMove(wxMouseEvent& event);
00199 
00205         void onChangeActual(wxMouseEvent& event);
00206 
00210         void onAddPoint(wxMouseEvent& aEvent);
00211 
00215         void onDeletePoint(wxCommandEvent& aEvent);
00216 
00220         void onShowPoints(wxCommandEvent& aEvent);
00221 
00226         void changeFuntionType(int aTheType, bool aForAll);
00227 
00232         int addFunction(pGraphicalFunction * function);
00233 
00238         bool DeletePointFunction(pGraphicalFunction* function,wxPoint point);
00239 
00243         bool deleteFunction(pGraphicalFunction * f);
00248         void  setActualFunction(pGraphicalFunction* newActual);
00252         pGraphicalFunction* getActualFunction();
00253 
00257         void InitFunctionForVectors( pGraphicalFunction *ff );
00258         pGraphicalFunction * getFunctionForVectors( double* vectorX, int sizeX,double * vectorY, int sizeY );
00259         pGraphicalFunction * getFunctionForVectors( std::vector<double> *vectorX, std::vector<double> *vectorY );
00260 
00261         /*
00262          Set the scales according to the size of the window
00263          and the maximum given by the user
00264         */
00265 
00266         void setActualScales();
00267         
00268         
00269 
00270         //erase
00271 
00272         void setmLog(wxTextCtrl *m_log1)
00273         {
00274                 m_log=m_log1;
00275         }
00276 
00277         /*
00278         * Actualizes the view range of the plotter and the actual function
00279         * @param newMinX Is the min-value to be shown in the x-scale
00280         * @param newMaxX Is the max-value to be shown in the x-scale
00281         */
00282         void actualizeViewRange(int newMinX, int newMaxX);
00283 
00284                 /*
00285         * Sets the condition for drawing or not the guide lines
00286         * @param ifDrawing The new condition to assing 
00287         */
00288         void setLineGuidesCondition(bool ifDrawing)
00289         {               
00290                 drawGuides = ifDrawing;         
00291         }
00292 
00293         
00294         /*
00295         * Gets the condition for drawing or not the guide lines
00296         * @retval drawGuides The assigned condition
00297         */
00298         bool drawGuideLines()
00299         {
00300                 return drawGuides;
00301         }       
00302         /*
00303         * Guide lines menu handler method that reacts to the mpID_LINE_GUIDES cimmand event
00304         * event The corresponding event to handle
00305         */
00306         void OnGuideLines (wxCommandEvent   &event); 
00307 
00308         /*
00309          writes in  t information
00310         */
00311         void writeInText(wxString &t)
00312         {
00313                 t=text;
00314         }
00315         
00316         /*
00317          Get a function in the plotter given the index
00318         */
00319         pGraphicalFunction* getFunction(int index);
00320         
00321         /*
00322           move the functions that the user wants to move
00323           and that were setted in functionsToMove
00324           @param porcentageMinX:the porcentage that the minShowed
00325           of the funcntions have to be move
00326           @param porcentageMaxX:the porcentage that the maxShowed
00327           of the funcntions have to be move
00328 
00329         */
00330         void moveFunctions(float porcentageMinX,float porcentageMaxX);
00335         int addFunctionToMove(pGraphicalFunction * function);
00336 
00337         
00338 private:
00339 
00343         pGraphicalFunction* actual;
00347         wxList functions;
00348 
00352         bool drawing;
00357         int movingPointIndex;
00358 
00365         int scaleWay;
00366 
00367         
00368         /*
00369                 Use to Show Information
00370         */
00371 
00372         wxTextCtrl      *m_log;
00373         wxString                text;
00374 
00375         /*
00376           Functions to be move at the same time
00377         */
00378         wxList functionsToMove;
00379         /*
00380          the user is moving the function
00381         */
00382         bool movingFunction;
00383         /*
00384         */
00385         int initialMovingCLick;
00386 
00387         /*
00388                 saving the initial function
00389         */
00390         std::vector<double> backUpActualVector;
00391         /*
00392         wants to move the points of the function
00393         */
00394         bool movingPoints;
00395 
00396         DECLARE_CLASS (pPlotterWindow)
00397         //----------------------------------------------------------------------------
00398         // wxWidget macro use declaration for handdling events
00399         //----------------------------------------------------------------------------
00400         DECLARE_EVENT_TABLE()
00401 };
00402 
00403 #endif
00404 
00405 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1