pGraphicalFunction.h

Go to the documentation of this file.
00001 
00002 
00003 #ifndef __pGraphicalFunction_h__
00004 #define __pGraphicalFunction_h__
00005 
00006 // ----------------------------------------------------------------------------
00007 // WX headers inclusion.
00008 // For compilers that support precompilation, includes <wx/wx.h>.
00009 // ----------------------------------------------------------------------------
00010 
00011 #include <wx/wxprec.h>
00012 #ifdef __BORLANDC__
00013 #pragma hdrstop
00014 #endif
00015 #ifndef WX_PRECOMP
00016 #include <wx/wx.h>
00017 #endif
00018 
00019 
00020 //----------------------------------------------------------------------------
00021 // Includes
00022 //----------------------------------------------------------------------------
00023 
00024 
00025 #include "pPlotterLayer.h"
00026 #include "pFunctionPoint.h"
00027 #include "pLogicalFunction.h"
00028 #include "pColorPoint.h"
00029 #include "vtkKochanekSpline.h"
00030 #include <vector>
00031 #include <iostream>
00032 #include <fstream>
00033 
00038 #define DEFECT_SCALE 1
00039 
00042 #define MAX_SCALE 2
00043 
00046 #define USER_SCALE 3
00047 
00048 /*
00049  Types of Plotter
00050 */
00051 /*
00052  Lets to the user to plot any number of the
00053  functions
00054 */
00055 #define DEFAULT 1
00056 /*
00057  Dont let draw on the plotter, but lets to edit
00058  the functions that are editables in the plotter
00059 */
00060 #define HISTOGRAM 2
00061 
00062 class pGraphicalFunction;
00063 //----------------------------------------------------------------------------
00064 // Class definition
00065 //----------------------------------------------------------------------------
00066 
00067 
00068 class pGraphicalFunction: public pPlotterLayer
00069 {
00070 public:
00071 
00072         //constructor 
00073         pGraphicalFunction(wxString name= wxEmptyString, int flags= mpALIGN_RIGHT);
00074 
00075         ~pGraphicalFunction( );
00076         
00077         //---------------------------
00078         //Virtual Mehods
00079         //---------------------------
00080 
00085         virtual int getXTraslation()
00086         {
00087                 return xTraslation;
00088         }
00089 
00090 
00091 
00092 
00098         virtual int getmType()
00099         {
00100                 return mType;
00101         }
00102 
00108         virtual int vGetType()
00109         {
00110                 return _type;
00111         }
00112 
00117         virtual void getOffsets(int &offsetX,int &offSetY )
00118         {
00119                 offsetX=(int)_offsetX;
00120                 offsetY=(int)_offsetY;
00121         }
00122         
00123         /*
00124         * Get the factor zoom
00125         */
00126         virtual void getFactorZoom(float & fz)
00127         {
00128                 fz=factorZoom;
00129         }
00130 
00131 
00132         /*
00133         * Get the value of fromWindow
00134         */
00135         virtual void getFromWindowV(bool &fw)
00136         {
00137                 fw=fromWindow;
00138         }
00139 
00140 
00144         virtual void getIfActual(bool &actual)
00145         {
00146                 actual=ifActual;
00147         }
00148 
00152         virtual void getMax(int & maxX, int &maxY)
00153         {
00154                 maxX=(int)getMaxX();
00155             maxY=(int)getMaxY();
00156         }
00160         virtual void getMaxShowed(int & maxX, int &maxY)
00161         {
00162                 maxX=(int)getMaxXShowed();
00163                 maxY=(int)getMaxYShowed();
00164         }
00168         virtual void getMinShowed(int & minX, int &minY)
00169         {
00170                 minX=(int)getMinXShowed();
00171                 minY=(int)getMinYShowed();
00172         }
00173 
00177         virtual void getScreens(int & scrX, int & scrY)
00178         {
00179       scrX=screenX;
00180           scrY=screenY;
00181         }
00182 
00186         virtual void setScreens(int scrX,int scrY)
00187         {
00188                 screenX=scrX;
00189                 screenY=scrY;                   
00190         }
00191         
00195         virtual void getScales(double & scaleX,double & scaleY)
00196         {
00197                 scaleX=_scaleX;
00198                 scaleY=_scaleY;
00199         }
00200         
00201         
00207         virtual void getDrawing(bool &draw)
00208         {
00209                 draw = drawing;
00210         }
00211 
00216         virtual void ifShowPoints(bool & show)
00217         {
00218                 show = showPointsF;
00219         }
00220 
00224         virtual void Rewind()
00225         {
00226                                 
00227                 node = logicFunction->GetPointAt(0);
00228                 
00229         }
00230 
00236         virtual bool GetNextXY(double & x, double & y) 
00237         {
00238                 if(node)
00239                 {
00240                         pFunctionPoint* p=(pFunctionPoint*)node->GetData();
00241                         x=p->getRealX();
00242                         y=p->getRealY();
00243                         node=node->GetNext();
00244                         return true;
00245                 }
00246                 return false;
00247         }
00252         virtual void GetPoints(wxList &points)
00253         {
00254                 logicFunction->GetPoints(points);
00255                 //points = realPoints;
00256         }  
00257 
00263         virtual void getMousePoint(int &x,int &y)
00264         {
00265                 x=mousePoint.x;
00266                 y=mousePoint.y;
00267         }
00268 
00272         virtual void getSize(int &size)
00273         {
00274                 size=getSizePoints();
00275         }
00276 
00280         virtual void getDirection(bool &dir)
00281         {               
00282                 logicFunction -> getDirection (dir);
00283         }
00284 
00285         //---------------------------
00286         // Methods
00287         //---------------------------
00288         /*
00289         * validate if the function has that point in a sensible area returning the index where the point was found or -1 if is in not part of the function: define the sensible area is  
00290         * x1-validPointRange<x<x1+validPointRange y1-validPointRange<y<y1+validPointRange
00291         */
00292         int validPointOnFunction(wxPoint realPoint);
00293 
00294         //returns the index in the list of the point  
00295         int getIndexOf(wxPoint realpoint);
00296 
00297         /*
00298         * This metohd returns the node of the point that is the movingPointIndex position in the list of points.
00299         * @param: int movingPointIndex, Is the index value of the searched node.
00300         * @return: Return a pointer to the node corresponding to the index value by parameter.
00301         */
00302         wxNode* GetPointAt( int movingPointIndex);
00303 
00304         /*
00305         * Includes a point between two existing points of the this function. The new point (x,y) was not defined when the function was created.
00306         *@ return Returns true is the point was succcesfully added to the funcion.
00307         */
00308         bool AddNewPoint(int x,int y);
00309 
00313         bool AddPoint(int aX, int aY,bool order=true);
00314 
00318         bool DeletePoint(int aX, int aY);
00319 
00323         bool changePoint(wxPoint newCoords, int movingIndexPoint);
00324 
00328         //bool hasPoint(wxPoint aAPoint);
00329 
00333         double * getX_RealValues();
00334 
00338         double* getY_RealValues();
00339         /*
00340         * This method orders the list of points taking into account that the last appended node in the list (realPoint) is the only one disordered.
00341         * @return Returns true if the last point included has a valid value for x and was ordered, according to the definition of function.
00342         */
00343         bool orderPoints();
00344 
00351         //wxNode * findPreviousNodeTo( int realX, int realY );
00352 
00356         bool deletePointAt(int index);
00357         /*
00358         * Returns the number of points that the function
00359         * has
00360         */
00361         int getSizePoints();
00362         /*
00363         * Set the scales of the function in x and y
00364         */
00365         void setScales();
00366 
00367         //----------------------------------
00368         // Asking if it has a point (x,y)
00369         //----------------------------------
00370 
00371         /*
00372         * returns true if the point is along the function
00373         * false otherway
00374         */
00375         bool isInFunction(int x, int y);
00376         /*
00377         * give us the point that is in the function and is exactly before
00378         * the point we are giving
00379         */
00380         wxNode* getBefore(pFunctionPoint* point);
00381         /*
00382         * Returns true if the point is in the line
00383         */
00384         bool isInLine(pFunctionPoint* before,pFunctionPoint* next, pFunctionPoint* point);
00388         double interpolateY(double m, int x1,int y1,int x);
00389         /*
00390          * Set Up startPoint, endPoint, maxY,maxX points        
00391         */
00392         void setUp();
00393         //----------------------------
00394         // Spline Methods
00395         //----------------------------
00396         /*
00397         * clear the spline vectors
00398         */
00399         void clearSplineVectors();
00400 
00401 
00402         /*
00403         Initiliaze xSpline and ySpline vectors
00404         */
00405         void initializeSplines();
00406         
00407         /*
00408         Add the (x,y) points of the function to the 
00409         spline
00410         */
00411         void addSplinesPoints();
00412         
00413         /*
00414          This Method adds the point calculated by
00415          the splines to the vectors
00416         */
00417         void initializeSplineVectors();
00418         
00419         /*
00420          get the spline point for t, in xKSpline and yKSpline
00421         */
00422         void GetSplinePoint(double t, double &x, double &y); 
00423         /*
00424          returns the xSpline to plotter
00425         */
00426         virtual std::vector<double> getXSpline()
00427         {
00428                 return xSpline;
00429         }
00430         /*
00431          returns the ySpline to plotter
00432         */
00433         virtual std::vector<double> getYSpline()
00434         {
00435                 return ySpline;
00436         }
00437 
00438 
00443         virtual int getOffsetPixelsXv()
00444         {
00445                 return offsetPixelX;
00446         }       
00447         
00452         virtual int getOffsetPixelsYv()
00453         {
00454                 return offsetPixelY;
00455         }
00456 
00457         //-----------------------
00458         // Persistence
00459         //-----------------------
00460 
00461         /*
00462          Save the points of the function
00463         */
00464         void save(wxString fileName);
00465         /*
00466          Load the points of a function 
00467         */
00468         void load(wxString fileName);
00469 
00470     //------------------------------
00471         // Getters and Setters
00472         //------------------------------
00473 
00474         //set if the function has to draw the points  
00475         void SetShowPoints(bool showPoints);
00476 
00477         //get the paramater showPointsF
00478         bool getShowPoints();
00479 
00480         void setScreenX(int scrX);
00481 
00482         int getScreenX();
00483 
00484         void setScreenY(int scrY);
00485 
00486         int getScreenY();
00487         
00488         void setStartX(double aStartX);
00489 
00490         double getStartX();
00491 
00492         void setStartY(double aStartY);
00493 
00494         double getStartY();
00495 
00496         void setEndX(double aEndX);
00497 
00498         double getEndX();
00499 
00500         void setEndY(double aEndY);
00501 
00502         double getEndY();
00503 
00504         void setScaleX(double aScaleX);
00505 
00506         double getScaleX();
00507 
00508         void setScaleY(double aScaleY);
00509 
00510         double getScaleY();
00511 
00512         void setMinX(double aMinX);
00513 
00514         double getMinX();
00515 
00516         void setMinY(double aMinY);
00517 
00518         double getMinY();
00519         
00520         void setMaxX(double aMaxX);
00521 
00522         double getMaxX();
00523 
00524         void setMaxY(double aMaxY);
00525 
00526         double getMaxY();
00527 
00528         void setOffsetX(double aOffsetX);
00529 
00530         double getOffsetX();
00531 
00532         void setOffsetY(double aOffsetY);
00533 
00534         double getOffsetY();
00535 
00536         void setType(int aType);
00537 
00538         int getType();
00539 
00540         int getValidPointRange();
00541 
00542         void setValidPointRange(int theRange);
00543 
00544         void SetDrawing(bool d)
00545         {
00546                 drawing = d;
00547         }
00548         //get if the function is being drawed
00549         bool GetDrawing()
00550         {
00551                 return drawing;
00552         }
00553 
00554         //set the mouse point
00555         void SetMousePoint(wxPoint p)
00556         { 
00557                 mousePoint = p;
00558         }
00559         //get the mousePoint
00560         wxPoint getMousePoint()
00561         {
00562                 return mousePoint;
00563         }
00567         void setActual(bool act);
00568 
00569         bool getActual();
00570 
00577         void setScaleWay(int typeS);
00578 
00579         int  getScaleWay();
00580         
00585         void setFromWindow(bool w)
00586         {
00587                 fromWindow=w;
00588         }
00589         
00590         /*
00591         * Get the value of fromWindow
00592         */
00593         bool getFromWindow()
00594         {
00595                 return fromWindow;
00596         }
00597         /*
00598         *  Set factor zoom
00599         */
00600         void setFactorZoom(float factor)
00601         {
00602                 factorZoom=factor;
00603         }
00604         /*
00605         * Set editable
00606         */
00607         void setEditable(bool edit)
00608         {
00609                 editable=edit;
00610         }
00614         bool getEditable()
00615         {
00616                 return editable;
00617         }
00618 
00619         //----------------------------
00620         // Zoom
00621         //----------------------------
00622 
00623         /* 
00624          * Get boolean zoom
00625          */
00626         bool getZoomB()
00627         {
00628                 return zoomIn;
00629         }
00630         /* *
00631          * Set boolean zoom
00632          * @param z: the new value
00633          */
00634         void setZoomIn(bool z)
00635         {
00636                 zoomIn=z;
00637         }
00642         void setInitialDrawPoint(pFunctionPoint* initialPoint)
00643         {
00644                 initialDrawingPoint=initialPoint;       
00645         }
00650         pFunctionPoint* getInitialDrawPoint()
00651         {
00652                 return initialDrawingPoint;     
00653         }
00658         void setFinalDrawPoint(pFunctionPoint* finalPoint)
00659         {
00660                 finalDrawingPoint=finalPoint;   
00661         }
00666         pFunctionPoint* getFinallDrawPoint()
00667         {
00668                 return finalDrawingPoint;       
00669         }
00678         void zooming(int clickedX,int clickedY,int width);
00679         
00680         /*
00681         * This method sets the offset 
00682         */
00683         void setOffsets(int offx,int offy);
00684         
00685         /*
00686         *  This method sets the minShowedX 
00687         *  and the minShowedY, accordig to the offset in
00688         *  x-axis and y-axis respectively
00689         *  pre: _offsetX>=0,_offsetY>=0
00690         */
00691         void setMinShowed();
00692 
00696         int getMinXShowed()
00697         {
00698                 return minShowedX;
00699         }
00703         int getMinYShowed()
00704         {
00705                 return minShowedY;
00706         }
00710         int getMaxXShowed()
00711         {
00712                 return maxShowedX;
00713         }
00717         int getMaxYShowed()
00718         {
00719                 return maxShowedY;
00720         }
00724         void setMinShowedX(int msx)
00725         {
00726                 minShowedX=msx;
00727         }
00731         void setMinShowedY(int msy)
00732         {
00733                 minShowedY=msy;
00734         }
00738         void setMaxShowedX(int msx)
00739         {
00740                 maxShowedX=msx;
00741         }
00745         void setMaxShowedY(int msy)
00746         {
00747                 maxShowedY=msy;
00748         }
00749 
00750         //------------------------
00751         // Offsets in pixels 
00752         //------------------------
00753         
00758         int getOffsetPixelsX()
00759         {
00760                 return offsetPixelX;
00761         }       
00762         
00767         int getOffsetPixelsY()
00768         {
00769                 return offsetPixelY;
00770         }
00774         void setOffsetPixelX(int offX)
00775         {
00776                 offsetPixelX=offX;
00777         }
00781         void setOffsetPixelY(int offY)
00782         {
00783                 offsetPixelY=offY;
00784         }       
00785 
00786         
00787 
00788         /*
00789         * Sets the color points of the function by teh given parameter
00790         * @param colorVector Is the color points vector to set
00791         */
00792         void setColorPoints(std::vector<pColorPoint *> &colorVector);
00793 
00794         /*
00795         * Gets the color points of the function in the given parameter
00796         * @param colorVector Is the color points list to get the points
00797         */
00798         void getColorPoints(std::vector<pColorPoint *> &colorVector);
00799         /*
00800          Setter the mType
00801         */
00802         void setmType(int mt)
00803         {
00804                 mType=mt;
00805         }
00806         //-----------------------
00807         //TRASLATION
00808         //-----------------------
00814         void setXTraslation(int xT)
00815         {
00816                  xTraslation=xT;
00817         }
00818         
00819 
00820 
00821 private:
00822 
00826         pLogicalFunction* logicFunction;
00830         bool showPointsF;
00831 
00835         double _startX;
00839         double _startY;
00843         double _endX;
00847         double _endY;
00851         double _scaleX;
00855         double _scaleY;
00859         double _minX;
00863         double _minY;
00867         double _maxX;
00871         double _maxY;
00875         double _offsetX;
00879         double _offsetY;
00883         int _type;
00887         wxList realPoints;
00888         /*
00889         * The list of the color points of the function associated to the color bar
00890         */
00891         std::vector<pColorPoint *> f_colorPoints;
00892 
00896         wxNode* node;
00900         int validPointRange;
00901 
00905         bool drawing; 
00906 
00911         wxPoint mousePoint;
00912 
00916         int screenX;
00917         
00921         int screenY;
00925         bool ifActual;
00926         
00934         int scaleWay;
00935 
00939     bool fromWindow;
00943         float factorZoom;
00947         bool editable;
00951         bool zoomIn;
00955         pFunctionPoint* initialDrawingPoint;
00959         pFunctionPoint* finalDrawingPoint;
00964         int minShowedX;
00969         int maxShowedX;
00974         int minShowedY;
00979         int maxShowedY;
00980         
00981         
00982         /*
00983          Vectors where the spline is stored
00984         */
00985         std::vector<double> xSpline;
00986         
00987         std::vector<double>     ySpline;
00988         
00989         /*
00990           Kochanek splines
00991         */
00992         vtkKochanekSpline* xKSpline;
00993 
00994         vtkKochanekSpline* yKSpline;
00995         
00996         
01001         int offsetPixelX;
01002         int offsetPixelY;
01003         /*
01004          type of the meaning of the function
01005          DEFAULT=1; the  function  has no meaning
01006          HISTOGRAM=2. The function represents an histogram
01007         */
01008 
01009         int mType;
01010 
01011         /*
01012          is use for lets the user move the function
01013         */
01014         int xTraslation;
01015 
01016         DECLARE_CLASS (pGraphicalFunction)
01017 };
01018 
01019 #endif
01020 
01021 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1