pGraphicalFunction.h
Go to the documentation of this file.00001
00002
00003 #ifndef __pGraphicalFunction_h__
00004 #define __pGraphicalFunction_h__
00005
00006
00007
00008
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
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
00050
00051
00052
00053
00054
00055 #define DEFAULT 1
00056
00057
00058
00059
00060 #define HISTOGRAM 2
00061
00062 class pGraphicalFunction;
00063
00064
00065
00066
00067
00068 class pGraphicalFunction: public pPlotterLayer
00069 {
00070 public:
00071
00072
00073 pGraphicalFunction(wxString name= wxEmptyString, int flags= mpALIGN_RIGHT);
00074
00075 ~pGraphicalFunction( );
00076
00077
00078
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
00125
00126 virtual void getFactorZoom(float & fz)
00127 {
00128 fz=factorZoom;
00129 }
00130
00131
00132
00133
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
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
00287
00288
00289
00290
00291
00292 int validPointOnFunction(wxPoint realPoint);
00293
00294
00295 int getIndexOf(wxPoint realpoint);
00296
00297
00298
00299
00300
00301
00302 wxNode* GetPointAt( int movingPointIndex);
00303
00304
00305
00306
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
00329
00333 double * getX_RealValues();
00334
00338 double* getY_RealValues();
00339
00340
00341
00342
00343 bool orderPoints();
00344
00351
00352
00356 bool deletePointAt(int index);
00357
00358
00359
00360
00361 int getSizePoints();
00362
00363
00364
00365 void setScales();
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 bool isInFunction(int x, int y);
00376
00377
00378
00379
00380 wxNode* getBefore(pFunctionPoint* point);
00381
00382
00383
00384 bool isInLine(pFunctionPoint* before,pFunctionPoint* next, pFunctionPoint* point);
00388 double interpolateY(double m, int x1,int y1,int x);
00389
00390
00391
00392 void setUp();
00393
00394
00395
00396
00397
00398
00399 void clearSplineVectors();
00400
00401
00402
00403
00404
00405 void initializeSplines();
00406
00407
00408
00409
00410
00411 void addSplinesPoints();
00412
00413
00414
00415
00416
00417 void initializeSplineVectors();
00418
00419
00420
00421
00422 void GetSplinePoint(double t, double &x, double &y);
00423
00424
00425
00426 virtual std::vector<double> getXSpline()
00427 {
00428 return xSpline;
00429 }
00430
00431
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
00459
00460
00461
00462
00463
00464 void save(wxString fileName);
00465
00466
00467
00468 void load(wxString fileName);
00469
00470
00471
00472
00473
00474
00475 void SetShowPoints(bool showPoints);
00476
00477
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
00549 bool GetDrawing()
00550 {
00551 return drawing;
00552 }
00553
00554
00555 void SetMousePoint(wxPoint p)
00556 {
00557 mousePoint = p;
00558 }
00559
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
00592
00593 bool getFromWindow()
00594 {
00595 return fromWindow;
00596 }
00597
00598
00599
00600 void setFactorZoom(float factor)
00601 {
00602 factorZoom=factor;
00603 }
00604
00605
00606
00607 void setEditable(bool edit)
00608 {
00609 editable=edit;
00610 }
00614 bool getEditable()
00615 {
00616 return editable;
00617 }
00618
00619
00620
00621
00622
00623
00624
00625
00626 bool getZoomB()
00627 {
00628 return zoomIn;
00629 }
00630
00631
00632
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
00682
00683 void setOffsets(int offx,int offy);
00684
00685
00686
00687
00688
00689
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
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
00790
00791
00792 void setColorPoints(std::vector<pColorPoint *> &colorVector);
00793
00794
00795
00796
00797
00798 void getColorPoints(std::vector<pColorPoint *> &colorVector);
00799
00800
00801
00802 void setmType(int mt)
00803 {
00804 mType=mt;
00805 }
00806
00807
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
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
00984
00985 std::vector<double> xSpline;
00986
00987 std::vector<double> ySpline;
00988
00989
00990
00991
00992 vtkKochanekSpline* xKSpline;
00993
00994 vtkKochanekSpline* yKSpline;
00995
00996
01001 int offsetPixelX;
01002 int offsetPixelY;
01003
01004
01005
01006
01007
01008
01009 int mType;
01010
01011
01012
01013
01014 int xTraslation;
01015
01016 DECLARE_CLASS (pGraphicalFunction)
01017 };
01018
01019 #endif
01020
01021