]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / pGraphicalFunction.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26
27 //----------------------------------------------------------------------------
28 // Class definition include
29 //----------------------------------------------------------------------------
30 #include "pGraphicalFunction.h"
31 #include "math.h"
32 #include <iostream>
33 #include <fstream>
34 #include <string>
35 #include <vector>
36
37 // ----------------------------------------------------------------------------
38 // WX headers inclusion.
39 // For compilers that support precompilation, includes <wx/wx.h>.
40 // ----------------------------------------------------------------------------
41
42 #ifndef WX_PRECOMP
43 #include <wx/wx.h>
44 #endif
45
46 //----------------------------------------------------------------------------
47 // Class implementation
48 //----------------------------------------------------------------------------
49
50 IMPLEMENT_CLASS(pGraphicalFunction, pPlotterLayer)
51
52 pGraphicalFunction:: pGraphicalFunction(wxString name, int flags)
53 {
54         SetName(name);
55         showPointsF = false;
56         validPointRange = 5;
57         logicFunction = new pLogicalFunction ();
58         fromWindow=false;
59         factorZoom=1;
60         drawing=false;
61         editable=true;
62         ifActual=false;
63         zoomIn=false;
64         setOffsetX(0);
65         setOffsetY(0);
66         initialDrawingPoint=NULL;
67         finalDrawingPoint=NULL;
68         //type=1 means that is going to be a piecewise function
69         _type=1;
70         xKSpline=NULL;
71         yKSpline=NULL;
72         offsetPixelX=0;
73         offsetPixelY=0;
74         xTraslation=0;
75         mType=DEFAULT;
76         
77 }
78
79 /**
80 * Is the destructor!!!
81 */
82 pGraphicalFunction :: ~ pGraphicalFunction ()
83 {
84         
85 }
86
87 //set if the function has to draw the points
88 void pGraphicalFunction::SetShowPoints(bool showPoints)
89 {
90         showPointsF = showPoints;
91 }
92 //get the paramater showPointsF
93 bool pGraphicalFunction::getShowPoints()
94 {
95         return showPointsF;
96 }
97 /*
98  * Set Up startPoint, endPoint, maxY,maxX points        
99 */
100 void pGraphicalFunction::setUp()
101 {
102         logicFunction->setUp();
103         setMaxX(logicFunction->getMaxX());
104         setMinX(logicFunction->getMinX());
105         setMaxY(logicFunction->getMaxY());
106         setMinY(logicFunction->getMinY());
107         setStartX(logicFunction->getStartX());
108         setEndX(logicFunction->getEndX());
109         setStartY(logicFunction->getStartY());
110         setEndY(logicFunction->getEndY());
111         
112 }
113
114 /*
115 * 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  
116 * x1-validPointRange<x<x1+validPointRange y1-validPointRange<y<y1+validPointRange
117 */
118 int pGraphicalFunction::validPointOnFunction(wxPoint realPoint)
119 {
120         return (logicFunction -> validPointOnFunction (realPoint));
121 }
122 /*
123 * returns the index in the list of the point 
124 */
125 int pGraphicalFunction::getIndexOf(wxPoint realpoint)
126 {
127         return logicFunction -> getIndexOf( realpoint );        
128 }
129
130 /*
131 * This metohd returns the node of the point that is the movingPointIndex position in the list of points.
132 * @param: int movingPointIndex, Is the index value of the searched node. 
133 * @return: Return a pointer to the node corresponding to the index value by parameter.
134 */
135 wxNode* pGraphicalFunction::GetPointAt( int movingPointIndex )
136 {
137         return logicFunction -> GetPointAt ( movingPointIndex );        
138 }
139 /*
140  * Set the scales of the function in x and y
141  * 
142  */
143 void pGraphicalFunction::setScales()
144 {
145         //int dx= logicFunction->getMaxX()-logicFunction->getMinX();
146         //int dy= logicFunction->getMaxY()-logicFunction->getMinY();
147         int dx= maxShowedX-minShowedX;
148         int dy= maxShowedY-minShowedY;
149         
150         
151         if(dx!=0 && dy!=0)
152         {
153                 double scaleX=(((float)(screenX-100))/dx)*factorZoom;
154                 double scaleY=(((float)(screenY-50))/dy)*factorZoom;
155                 setScaleX(scaleX);
156                 setScaleY(scaleY);
157                 logicFunction->setScaleX(scaleX);
158                 logicFunction->setScaleY(scaleY);
159
160         }
161 }
162 /*
163 * Includes a point between two existing points of this function. The new point (x,y) was not defined when the function was created.
164 * @return Returns true is the point was succcesfully added to the funcion.
165 */
166 bool pGraphicalFunction:: AddNewPoint(int x,int y)
167 {
168         bool added= logicFunction -> AddNewPoint ( x, y );
169         if(!fromWindow)
170          setUp();
171         else
172         {
173                 logicFunction->setEndPoints();
174                 logicFunction->setStartPoints();
175         }
176         return added;
177 }
178
179 /*
180 * This tries to Add a point to the function if possible it returns true.
181 * @pre: The list of existing points is ordered.
182 * @param: int aX, The x value of the point.
183 * @param: int aY, The y value of the point.
184 * @param: return Returns TRUE if the point was succesfuly included in the realPoints list.
185 */
186 bool pGraphicalFunction::AddPoint(int aX, int aY,bool order) 
187 {       
188         bool added=false;
189         if (logicFunction!=NULL){
190                 added=logicFunction -> AddPoint( aX, aY,order );
191                 if(!fromWindow)
192                         setUp();
193                 else
194                 {
195                         logicFunction->setEndPoints();
196                         logicFunction->setStartPoints();
197                 } // if fromWindow
198         } // if logicFunction
199         return added;
200 }
201
202 /**
203 * deletes the point given by the  user  from the collection of logical points of the function
204 * is not used
205 */
206
207 bool pGraphicalFunction::DeletePoint(int aX, int aY) 
208 {
209         bool added= logicFunction -> DeletePoint( aX, aY );     
210         if(!fromWindow)
211          setUp();
212         else
213         {
214                 logicFunction->setEndPoints();
215                 logicFunction->setStartPoints();
216         }
217         return added;
218 }
219
220 /**
221 * deletes a point of the functio given its index
222 */
223 bool pGraphicalFunction::deletePointAt(int index)
224 {
225         bool added=logicFunction -> deletePointAt( index );
226         if(!fromWindow)
227          setUp();
228         else
229         {
230                 logicFunction->setEndPoints();
231                 logicFunction->setStartPoints();
232         }
233         return added;
234 }
235
236 /**
237 * Change de coordinates of the given index point to the newCoords, if it is possible and return the result of the invoked action. 
238 * @retun Return TRUE if it was possible to do the change. A valid change is when the new x value of the point is still between the previous and next point, when condition.
239 */
240 bool pGraphicalFunction::changePoint(wxPoint newCoords, int movingIndexPoint) 
241 {
242         bool added= (logicFunction -> changePoint( newCoords, movingIndexPoint ));
243         if(!fromWindow)
244          setUp();
245         else
246         {
247                 logicFunction->setEndPoints();
248                 logicFunction->setStartPoints();
249         }
250         return added;
251 }
252 /**
253 * Evaluates if the given point belongs to the function.
254 */
255 /*
256 bool pGraphicalFunction::hasPoint(wxPoint aPoint) 
257 {
258         return logicFunction -> hasPoint( aPoint );     
259 }
260 */
261
262 /**
263 * Returns the real x values of the control points of the function. It dont includes the points calculated by interpolation.
264 */
265 double* pGraphicalFunction::getX_RealValues() 
266 {
267         return (logicFunction -> getX_RealValues( ));   
268 }
269
270 /**
271 * Returns the real y values of the control points of the function. It dont includes the points calculated by interpolation.
272 */
273 double * pGraphicalFunction::getY_RealValues() 
274 {  
275
276         return (logicFunction -> getY_RealValues());    
277 }
278
279 //----------------------------------
280 // Asking if it has a point (x,y)
281 //----------------------------------
282
283 /*
284 * returns true if the point is along the function
285 * false otherway
286 */
287 bool pGraphicalFunction:: isInFunction(int x, int y)
288 {
289         wxNode* before;
290         wxNode* next;
291         pFunctionPoint* point= new pFunctionPoint(x,y);
292         bool inLine;
293         before=getBefore(point);
294
295         if(before && before->GetNext())
296         {
297                 next = before->GetNext();
298                 //next = (before->GetNext())->GetNext();
299                 inLine= isInLine((pFunctionPoint*)before->GetData(),(pFunctionPoint*)next->GetData(),point);
300         }
301         else 
302                 inLine=false;
303         return inLine;
304 }
305 /*
306 * give us the point that is in the function and is exactly before
307 * the point we are giving
308 */
309 wxNode* pGraphicalFunction:: getBefore(pFunctionPoint* point)
310 {
311         int minDiference=10000000;
312         wxNode* node=logicFunction->GetPointAt(0);
313         wxNode* before=NULL;
314
315         while(node)
316         {
317                 pFunctionPoint* before1=(pFunctionPoint*)node->GetData();
318                 int beforeX=before1->getRealX();
319                 int pointX=point->getRealX();
320                 if(beforeX<pointX)
321                 {
322                   int minDiference1=pointX-beforeX;
323                   if(minDiference1<minDiference)
324                   {
325                           minDiference=minDiference1;
326                           before=node;
327                   }
328                 }
329                 node=node->GetNext();
330         }
331         return before;
332 }
333 /*
334 * Returns true if the point is in the line
335 */
336 bool pGraphicalFunction::isInLine(pFunctionPoint* before,pFunctionPoint* next, pFunctionPoint* point)
337 {
338         int x1,x2,x,y1,y2,y;
339         
340         x1=(float)before->getRealX();
341         x2=(float)next->getRealX();
342         y1=(float)before->getRealY();
343         y2=(float)next->getRealY();
344         x=(float)point->getRealX();
345         y=(float)point->getRealY();
346
347         
348         float d1= (float)sqrt(pow(float(x1-x),2)+ pow(float(y1-y),2));
349         float d2= (float)sqrt(pow(float(x2-x),2)+ pow(float(y2-y),2));
350         float d=(float)sqrt(pow(float(x2-x1),2)+ pow(float(y2-y1),2));
351         if(d1+d2<=(d*1.1) && d1<=d && d2<=d)
352                 return true;
353         return false;
354 }
355 /**
356 * give us the value of y in the line define by the arguments
357 */
358 double pGraphicalFunction::interpolateY(double m, int x1,int y1,int x)
359 {
360         return m*(x-x1)+y1;
361 }
362
363 //----------------------------
364 //NEW METHODS
365 //----------------------------
366
367 //----------------------------
368 // Spline Methods
369 //----------------------------
370
371
372         /*
373         * clear the spline vectors
374         */
375         void pGraphicalFunction:: clearSplineVectors()
376         {
377                 xSpline.clear();
378                 ySpline.clear();
379         }
380
381         /*
382         Initiliaze xSpline and ySpline vectors
383         */
384         void pGraphicalFunction:: initializeSplines()
385         {
386                 if(xKSpline==NULL)
387                         xKSpline = vtkKochanekSpline::New();
388                 if(yKSpline==NULL)
389                         yKSpline= vtkKochanekSpline::New();
390                 addSplinesPoints();
391
392         }
393
394         /*
395         Add the (x,y) points of the function to the 
396         spline
397         */
398         void pGraphicalFunction::addSplinesPoints()
399         {
400                 xKSpline->RemoveAllPoints();
401                 yKSpline->RemoveAllPoints();
402                 wxNode *node= logicFunction->GetPointAt(0);
403                 pFunctionPoint* p;
404                 int i=0;
405                 while(node)
406                 {
407                         p=(pFunctionPoint*)node->GetData();
408                         xKSpline->AddPoint(i,p->getRealX());
409                         yKSpline->AddPoint(i,p->getRealY());
410                         i++;
411                         node=node->GetNext();
412                 }
413         }
414         /*
415          This Method adds the point calculated by
416          the splines to the vectors
417         */
418         void pGraphicalFunction:: initializeSplineVectors()
419         {
420                 double x=0,y=0,t,delta;
421                 int i,np,nps;
422                 //realPoints.DeleteC  
423
424                 np = logicFunction->getSizePoints();
425                 nps = 200;
426                 delta=( double ) ( np ) / ( double ) ( nps );
427                 for( i = 0; i < nps; i++ )
428                 {
429                   t = delta * (double)i;
430                   GetSplinePoint(t,x,y);
431                   xSpline.push_back(x);
432                   ySpline.push_back(y);
433                 }
434         }
435         /*
436          get the spline point for t, in xKSpline and yKSpline
437         */
438         void pGraphicalFunction::GetSplinePoint(double t, double &x, double &y)
439         {
440                 if (logicFunction->getSizePoints()==0)
441                 {
442                         x = 0;
443                         y = 0;
444                 }
445                 if (logicFunction->getSizePoints()>=2)
446                 {
447                         x = xKSpline->Evaluate(t);
448                         y = yKSpline->Evaluate(t);
449                 }
450         }
451
452 //------------------------------
453 // Zoom Methods
454 //------------------------------
455
456 /**
457 This method set the initial point and the final point of drawing
458 according with the width of the square around the point clicked
459 @param clickedX
460 @param clickedY
461 @param width: width of the square
462 Note: all the parameters are pixels
463 Pre: screenX, screenY, zoom are set! with the actual data.
464 DEPRECATED!
465 */
466 void pGraphicalFunction::zooming(int clickedX,int clickedY,int width)
467 {
468         int xS,yS,x1,x2,y1,y2;
469         setScales();
470         xS=clickedX/_scaleX+_offsetX;
471         yS=clickedY/_scaleY+_offsetY;
472         //square
473         x1=(clickedX-width)/_scaleX+_offsetX;
474         x2=(clickedX+width)/_scaleX+_offsetX;
475         y1=(clickedY-width)/_scaleY+_offsetY;
476         y2=(clickedY+width)/_scaleY+_offsetY;
477
478         int numberPoints=getSizePoints();
479         pFunctionPoint* point;
480         wxNode* p;
481         bool inSquare=false,first=false;
482         
483         //if the user made a zoom
484         if(zoomIn)
485         {
486                 int i;
487                 for(i=0; i<numberPoints;i++)
488                 {
489                         p=logicFunction->GetPointAt(i);
490                         point=(pFunctionPoint*)p->GetData();
491                         int rx=point->getRealX();
492                         int ry=point->getRealY();
493                         inSquare= rx>=x1 && rx<=x2; //&& ry>=y1 && ry<=y2;
494                         if(inSquare)
495                         {
496                                 if(!first)
497                                 {
498                                         initialDrawingPoint=point;
499                                         _offsetX=rx;
500                                         _offsetY=ry;
501                                         first=true;
502                                 }
503                                 finalDrawingPoint=point;
504                         }
505                 }
506         }       
507         else
508         {
509                 //We extend the range of vision in x and y,20 and 10 respectively
510                 if((_offsetX-20)>=0)
511                 {
512                         _offsetX=_offsetX-20;
513                 }
514                 else
515                         _offsetX=0;
516                 if((_offsetY-10)>=0)
517                 {
518                         _offsetY=_offsetY-10;
519                 }
520                 else
521                         _offsetY=0;
522         }
523 }
524
525         /*
526         This method sets the offsets according with the point 
527         clicked on the window
528         @param offx: x-value of the point clicked
529         @param offx: y-value of the point clicked
530         Note: all the parameters are pixels
531         Pre: screenX, screenY are set! with the actual data.
532         Pos: Sets the value of minXshowed,minYshowed 
533         */
534         void pGraphicalFunction::setOffsets(int offx,int offy)
535         {
536                 int xS,yS;
537
538                 setScales();
539                 
540                 xS=(offx-offsetPixelX)/_scaleX+_offsetX + minShowedX;
541                 yS=(offy-offsetPixelY)/_scaleY+_offsetY+ minShowedY;
542                 
543                 setOffsetX(xS);
544                 setOffsetY(yS);
545                         
546                 //setMinShowedX(xS);
547                 //setMinShowedY(yS);
548
549                 setOffsetPixelX(offx);
550                 setOffsetPixelY(offy);
551                 //setMinShowed();
552         }
553         /*
554         *  This method sets the minShowedX 
555         *  and the minShowedY, accordig to the offset in
556         *  x-axis and y-axis respectively
557         *  pre: _offsetX>=0,_offsetY>=0
558         *               screenX and screenY are set with the actual size of the window
559         *               scaleX and scaleY are set to the actual size of the window
560         * DEPRECATED!
561         */
562         void pGraphicalFunction::setMinShowed()
563         {
564                 bool firstX=false,firstY=false;
565                 
566                 wxNode* node=logicFunction->GetPointAt(0);
567                 pFunctionPoint* p;
568
569                 //float middleWX=(((float)(screenX-100))/2)/scaleX; // JPRx
570                 //float middleWY=(((float)(screenY-50))/2)/scaleY; // JPRx
571                 
572                 //node=node->GetNext(); 
573                 while(node)
574                 {
575                         p=(pFunctionPoint*)node->GetData();
576                         int px=p->getRealX();
577                         int py=p->getRealY();
578                         int x=(px-_offsetX);//+middleWX;
579                         int y=(py-_offsetY);//+middleWY;
580                         if(!firstX && x>=0)
581                         {
582                                 firstX=true;
583                                 setMinShowedX(px);
584                         }
585                         if(!firstY && y>=0)
586                         {
587                                 firstY=true;
588                                 setMinShowedY(py);
589                         }       
590                         node=node->GetNext();
591                 }
592         }
593
594 //-----------------------
595 // Persistence
596 //-----------------------
597
598 /*
599  Save the points of the function
600 */
601 void pGraphicalFunction::save(wxString fileName)
602 {
603         
604         logicFunction->save(fileName);
605
606 }
607 /*
608  Load the points of a function 
609 */
610 void pGraphicalFunction::load(wxString fileName)
611 {
612         logicFunction->load(fileName);
613         logicFunction->setUp();
614         setMaxShowedX(logicFunction->getMaxX());
615         setMinShowedX(logicFunction->getMinX());
616         setMaxShowedY(logicFunction->getMaxY());
617         setMinShowedY(logicFunction->getMinY());
618 }
619         
620 //--------------------------
621 //GETTERS AND SETTERS
622 //---------------------------
623 /**
624 * actual
625 */
626 void pGraphicalFunction::setActual(bool act)
627 {
628   ifActual=act;
629 }
630 bool pGraphicalFunction:: getActual()
631 {
632         return ifActual;
633 }
634 /**
635 * SCALE WAY
636 * DEFECT_SCALE 1
637 * MAX_SCALE 2
638 * USER_SCALE 3
639 */
640 void pGraphicalFunction::setScaleWay(int typeS)
641 {
642   scaleWay=typeS;
643 }
644
645 int pGraphicalFunction:: getScaleWay()
646 {
647  return scaleWay;
648 }
649
650
651 /*
652 * SCREEN
653 */
654 void pGraphicalFunction::setScreenX(int scrX)
655 {
656   this->screenX=scrX;
657 }
658 int pGraphicalFunction::getScreenX()
659 {
660   return this->screenX;
661 }
662 void pGraphicalFunction::setScreenY(int scrY)
663 {
664   this->screenY=scrY;
665 }
666 int pGraphicalFunction::getScreenY()
667 {
668   return this->screenY;
669 }
670
671
672 /*
673 * STARTS
674 */
675 void pGraphicalFunction::setStartX(double aStartX) {
676         
677         logicFunction->setStartX(aStartX);
678         this->_startX =logicFunction->getStartX();
679 }
680
681 double pGraphicalFunction::getStartX() 
682 {
683         return logicFunction->getStartX();
684 }
685
686 void pGraphicalFunction::setStartY(double aStartY) 
687 {
688         logicFunction->setStartY(aStartY);
689         this->_startY = aStartY;
690 }
691
692 double pGraphicalFunction::getStartY() {
693         return logicFunction->getStartY();
694 }
695 /*
696 * ENDs
697 */
698 void pGraphicalFunction::setEndX(double aEndX) 
699 {
700         logicFunction->setEndX(aEndX);
701         this->_endX = aEndX;
702 }
703
704 double pGraphicalFunction::getEndX() {
705         return logicFunction->getEndX();
706 }
707
708 void pGraphicalFunction::setEndY(double aEndY) {
709         logicFunction->setEndY(aEndY);
710         this->_endY = aEndY;
711 }
712
713 double pGraphicalFunction::getEndY() {
714         return logicFunction->getEndY();
715 }
716 /*
717  * SCALES
718  */
719 void pGraphicalFunction::setScaleX(double aScaleX) 
720 {
721         logicFunction->setScaleX(aScaleX);
722         this->_scaleX = aScaleX;
723 }
724
725 double pGraphicalFunction::getScaleX() 
726 {
727         return this->_scaleX;
728 }
729
730 void pGraphicalFunction::setScaleY(double aScaleY) 
731 {
732         logicFunction->setScaleY(aScaleY);
733         this->_scaleY = aScaleY;
734 }
735
736 double pGraphicalFunction::getScaleY() {
737         return this->_scaleY;
738 }
739 /*
740  * Mins
741  */
742 void pGraphicalFunction::setMinX(double aMinX) 
743 {
744         logicFunction->setMinX(aMinX);
745         this->_minX = aMinX;
746 }
747
748 double pGraphicalFunction::getMinX() 
749 {
750         return logicFunction->getMinX();
751 }
752
753 void pGraphicalFunction::setMinY(double aMinY) 
754 {
755         logicFunction->setMinY(aMinY);
756         this->_minY = aMinY;
757 }
758
759 double pGraphicalFunction::getMinY() {
760         return logicFunction->getMinY();
761 }
762 /*
763  * MAXS
764  */
765 void pGraphicalFunction::setMaxX(double aMaxX) 
766 {
767         logicFunction->setMaxX(aMaxX);
768         this->_maxX = aMaxX;
769 }
770
771 double pGraphicalFunction::getMaxX() 
772 {
773         return logicFunction->getMaxX();
774 }
775
776 void pGraphicalFunction::setMaxY(double aMaxY) 
777 {
778         logicFunction->setMaxY(aMaxY);
779         this->_maxY = aMaxY;
780 }
781
782 double pGraphicalFunction::getMaxY() {
783         return logicFunction->getMaxY();
784 }
785
786 /*
787  * OFFSETS
788  */
789 void pGraphicalFunction::setOffsetX(double aOffsetX) 
790 {
791         logicFunction->setOffsetX(aOffsetX);
792         this->_offsetX = aOffsetX;
793 }
794
795 double pGraphicalFunction:: getOffsetX() 
796 {
797         
798         return this->_offsetX;
799 }
800
801 void pGraphicalFunction:: setOffsetY(double aOffsetY) 
802 {
803         logicFunction->setOffsetY(aOffsetY);
804         this->_offsetY = aOffsetY;
805 }
806
807 double pGraphicalFunction:: getOffsetY() {
808         return this->_offsetY;
809 }
810
811 /*
812  * TYPE
813  */
814 void pGraphicalFunction:: setType(int aType) 
815 {
816         logicFunction->setType(aType);
817         this->_type = aType;
818 }
819
820 int pGraphicalFunction :: getType() {
821         return this->_type;
822 }
823
824 /*
825  * validPoint
826  */
827 int pGraphicalFunction :: getValidPointRange()
828 {
829         return validPointRange;
830 }
831
832 void pGraphicalFunction :: setValidPointRange(int theRange)
833 {
834         logicFunction->setValidPointRange(theRange);
835         validPointRange = theRange;
836 }
837 /*
838 * Returns the number of points that the function
839 * has
840 */
841 int pGraphicalFunction :: getSizePoints()
842 {
843         return logicFunction->getSizePoints();
844 }
845
846 /*
847 * Sets the color points of the function by teh given parameter
848 * @param colorVector Is the color points vector to set
849 */
850 void pGraphicalFunction :: setColorPoints(std::vector<pColorPoint *> &colorVector)
851 {
852         f_colorPoints.clear();
853         int i = 0;      
854         while(i<(int)(colorVector.size()))
855         {
856                 f_colorPoints.push_back(colorVector[i]);                
857                 i++;
858         }
859 }
860
861 /*
862 * Gets the color points of the function in the given parameter
863 * @param colorVector Is the color points list to get the points
864 */
865 void pGraphicalFunction :: getColorPoints(std::vector<pColorPoint *> &colorVector)
866 {
867         int i = 0;      
868         while(i<(int)(f_colorPoints.size()))
869         {
870                 pColorPoint * originaslPoint = f_colorPoints[i];
871                 pColorPoint * copyPoint = new pColorPoint(originaslPoint->getRealX(), originaslPoint->getColor(), originaslPoint->isTemporalColor());
872                 colorVector.push_back(copyPoint);               
873                 i++;
874         }
875 }
876
877