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