]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp
no message
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualViewBaseContour.cpp
1 #include "manualViewBaseContour.h"
2
3
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6 // ----------------------------------------------------------------------------
7
8 manualViewBaseContour::manualViewBaseContour()
9 {
10         _show_text                      = true;
11         _textActor                      = NULL;
12         _manContModel           = NULL;
13         _wxvtkbaseview          = NULL;
14         _selected                       = false;
15         _posibleSelected        = false;
16         _viewControlPoints      = false;
17         _pts                            = NULL;
18         _pd                                     = NULL;
19         _contourVtkActor        = NULL;
20         _bboxMapper                     = NULL;
21         _range                          = 1;
22         _sizePointsContour      = 100;
23         _spc[0]                         = 1;
24         _spc[1]                         = 1;
25         _spc[2]                         = 1;
26
27         _coulorEdit_r           = 1;
28         _coulorEdit_g           = 1;
29         _coulorEdit_b           = 0;
30
31         _coulorNormal_r         = 1;
32         _coulorNormal_g         = 0;
33         _coulorNormal_b         = 1;
34
35         _coulorSelection_r      = 0;
36         _coulorSelection_g      = 1;
37         _coulorSelection_b      = 0;
38
39         _widthline                      = 1;
40
41 }
42 // ----------------------------------------------------------------------------
43 manualViewBaseContour::~manualViewBaseContour()
44 {
45         int i,size=_lstViewPoints.size();
46         for (i=0;i<size; i++){
47                 delete _lstViewPoints[i];
48         }
49         _lstViewPoints.clear();
50 }
51 // ----------------------------------------------------------------------------
52
53
54 int manualViewBaseContour::GetType() // virtual
55 {
56 // Information...
57 //int manualViewBaseContour::GetType()          0;
58 //int manualViewContour::GetType()                      1;
59 //int manualViewRoi::GetType()                          2;
60 //int manualViewCircle::GetType()                       3;
61 //int manualViewStar::GetType()                         4;
62 //int manualViewLine::GetType()                         6;
63
64
65         return 0;
66 }
67 // ----------------------------------------------------------------------------
68
69 void manualViewBaseContour::Save(FILE *pFile)
70 {
71         fprintf(pFile,"TypeView %d\n", GetType() );
72 }
73
74 // ----------------------------------------------------------------------------
75 void manualViewBaseContour::Open(FILE *pFile)
76 {
77 }
78
79 // ----------------------------------------------------------------------------
80 void manualViewBaseContour :: AddCompleteContourActor(  bool ifControlPoints )
81 {
82         _viewControlPoints = ifControlPoints;
83          /*vtkRenderer * theRenderer = */  _wxvtkbaseview->GetRenderer();  // JPRx ??
84          //Adding the spline
85          AddSplineActor();
86
87          AddTextActor();
88          //Adding each control point
89          if( ifControlPoints )
90                 AddControlPoints();
91          RefreshContour();
92          Refresh();
93 }
94 // ---------------------------------------------------------------------------
95
96 void manualViewBaseContour :: RemoveCompleteContourActor()
97 {
98         /*vtkRenderer * theRenderer =*/  _wxvtkbaseview->GetRenderer(); // JPRx ??
99          //Removing the spline
100         RemoveSplineActor();
101         RemoveTextActor();
102
103         //Removing each point
104         RemoveControlPoints();
105         RefreshContour();
106         Refresh();
107 }
108 // ---------------------------------------------------------------------------
109 manualViewBaseContour *  manualViewBaseContour :: Clone( )//virtual
110 {
111         manualViewBaseContour * clone = new manualViewBaseContour();
112         CopyAttributesTo(clone);
113         return clone;
114
115 }
116
117 // ---------------------------------------------------------------------------
118
119 void manualViewBaseContour::CopyAttributesTo( manualViewBaseContour * cloneObject)
120 {
121         // Fathers object
122         //XXXX::CopyAttributesTo(cloneObject);
123
124         cloneObject-> SetWxVtkBaseView( this->_wxvtkbaseview );
125         cloneObject-> SetSelected( this->GetSelected() );
126         cloneObject-> SetPosibleSelected( this->GetPosibleSelected() );
127         cloneObject-> SetIfViewControlPoints( this->GetIfViewControlPoints() );
128         cloneObject-> SetRange( this->GetRange() );
129         cloneObject-> SetZ( this->GetZ() );
130         cloneObject-> SetSpacing( _spc );
131         cloneObject-> SetColorNormalContour( _coulorNormal_r, _coulorNormal_g, _coulorNormal_b );
132         cloneObject-> SetColorEditContour( _coulorEdit_r, _coulorEdit_g, _coulorEdit_b );
133         cloneObject-> SetColorSelectContour( _coulorSelection_r, _coulorSelection_g, _coulorSelection_b );
134
135         int i, size = _lstViewPoints.size();
136         for ( i=0; i<size; i++ )
137         {
138                 cloneObject->AddPoint(  );
139         }
140 }
141
142 // ----------------------------------------------------------------------------
143 void manualViewBaseContour :: AddSplineActor()
144 {
145         vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
146         if (_contourVtkActor!=NULL)
147                 theRenderer->AddActor( _contourVtkActor  );
148 }
149 // ----------------------------------------------------------------------------
150 void manualViewBaseContour :: RemoveSplineActor() // virtual
151 {
152         vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
153         if (_contourVtkActor!=NULL)
154                 theRenderer->RemoveActor( _contourVtkActor );
155 }
156 // ----------------------------------------------------------------------------
157 void manualViewBaseContour :: RemoveControlPoints()
158 {
159         if (_wxvtkbaseview!=NULL){
160                 vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
161                 int i,size=_lstViewPoints.size();
162                 for (i=0;i<size; i++)
163                 {
164                         vtkActor * pointActor = _lstViewPoints[i]->GetVtkActor();
165                         theRenderer->RemoveActor( pointActor );
166                 } // for
167         } // if
168         SetIfViewControlPoints( false );
169 }
170 // ----------------------------------------------------------------------------
171 void manualViewBaseContour::AddControlPoints()
172 {
173         vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
174         SetIfViewControlPoints( true );
175          if( _viewControlPoints )
176          {
177                 int i,size=_lstViewPoints.size();
178                 for (i=0;i<size; i++)
179                 {
180                         vtkActor * pointActor = _lstViewPoints[i]->GetVtkActor();
181                         theRenderer->AddActor( pointActor );
182                 }
183          }
184 }
185 // ----------------------------------------------------------------------------
186 void manualViewBaseContour::AddTextActor()
187 {
188         _wxvtkbaseview->GetRenderer()->AddActor2D( _textActor );
189 }
190 // ----------------------------------------------------------------------------
191 void manualViewBaseContour::RemoveTextActor()
192 {
193         _wxvtkbaseview->GetRenderer()->RemoveActor2D( _textActor );
194 }
195 // ----------------------------------------------------------------------------
196 void manualViewBaseContour::DeleteVtkObjects()
197 {
198         if ( _contourVtkActor   != NULL )       { _contourVtkActor  -> Delete(); }
199         if ( _bboxMapper                != NULL )       { _bboxMapper           -> Delete(); }
200         if ( _pts                               != NULL )       { _pts                          -> Delete(); }
201         if ( _pd                                != NULL )       { _pd                           -> Delete(); }
202         _contourVtkActor        = NULL;
203         _bboxMapper                     = NULL;
204         _pts                            = NULL;
205         _pd                                     = NULL;
206 }
207
208
209 // ----------------------------------------------------------------------------
210 void manualViewBaseContour::SetWidthLine(double width)
211 {
212         _widthline = width;
213         this->UpdateColorActor();
214
215         // for the control points
216         int id, size = _lstViewPoints.size();
217         for( id=0; id<size; id++)
218         {
219                 this->_lstViewPoints[id]->SetWidthLine(_widthline);
220         }
221
222 }
223
224 // ----------------------------------------------------------------------------
225 double manualViewBaseContour::GetWidthLine()
226 {
227         return _widthline;
228 }
229
230 // ----------------------------------------------------------------------------
231 void manualViewBaseContour::ConstructVTKObjects()
232 {
233 //JSTG 29-02-08 -----------------------------------------------
234         //int i , nps = _sizePointsContour;
235         int i;
236         int nps = _manContModel->GetNumberOfPointsSpline();
237 //-------------------------------------------------------------
238         DeleteVtkObjects();
239         _pts = vtkPoints::New();
240         _pts->SetNumberOfPoints(nps);
241
242         for (i=0 ; i<nps ; i++){
243                 _pts->SetPoint(i,       0       , 0     , 0 );
244         }
245         // This is for the boundaring inicialisation
246
247 //EED 29Mars2009        
248         _pts->SetPoint(0,       0       , 0     , -1000 );
249         _pts->SetPoint(1,       0       , 0     ,  1000 );
250 //      _pts->SetPoint(0,       -1000   , -1000 , -1000 );
251 //      _pts->SetPoint(1,       1000    , 1000  , 1000  );
252
253
254         vtkCellArray *lines = vtkCellArray::New();
255         lines->InsertNextCell( nps /* +1 */ );
256         for ( i=0 ; i<nps+1 ; i++ ){
257                 lines->InsertCellPoint(i % nps );
258         }
259
260         _pd = vtkPolyData::New();
261         _pd->SetPoints( _pts );
262         _pd->SetLines( lines );
263         lines->Delete();  //do not delete lines ??
264
265         _contourVtkActor        =       vtkActor::New();
266     _bboxMapper                 =       vtkPolyDataMapper::New();
267     _bboxMapper->ScalarVisibilityOff( );
268
269         _bboxMapper->SetInput(_pd);
270         _bboxMapper->ImmediateModeRenderingOn();
271         _contourVtkActor->SetMapper(_bboxMapper);
272         _contourVtkActor->GetProperty()->BackfaceCullingOff();
273
274         UpdateColorActor();
275
276         _pd->ComputeBounds();
277
278         //      Text
279         _textActor = vtkTextActor::New();
280 //      _textActor->SetDisplayPosition(200, 200);
281         _textActor->SetInput("00");
282         // Set coordinates to match the old vtkScaledTextActor default value
283 //      _textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
284 //      _textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 );
285         _textActor->GetPositionCoordinate()->SetCoordinateSystemToWorld ();
286 //      _textActor->GetPositionCoordinate()->SetValue( 0.8 , 0.8 );
287
288         vtkTextProperty *tprop = _textActor->GetTextProperty();
289         tprop->SetFontSize(14);
290         tprop->SetFontFamilyToArial();
291         tprop->SetColor(0, 0, 1);
292 }
293 // ----------------------------------------------------------------------------
294 void manualViewBaseContour::CreateNewContour()
295 {
296         ConstructVTKObjects();
297         /*
298         _wxvtkbaseview->GetRenderer()->AddActor( _contourVtkActor );
299         _wxvtkbaseview->GetRenderer()->AddActor2D(_textActor);*/
300         AddCompleteContourActor();
301 }
302 // ----------------------------------------------------------------------------
303 void manualViewBaseContour::UpdateViewPoint(int id) // virtual
304 {
305         manualPoint             *mp             = _manContModel->GetManualPoint(id);
306
307 //EEDx6
308                         double XX=mp->GetX(),YY=mp->GetY(),ZZ=mp->GetZ();
309 //                      wxVtk2DBaseView *wxvtk2Dbasevie = (wxVtk2DBaseView*)this->GetWxVtkBaseView();
310 //                      wxvtk2Dbasevie->TransformCoordinate_spacing_ModelToView(XX,YY,ZZ);
311
312         _lstViewPoints[id]->SetPositionXY( XX , YY ,_range, ZZ );
313 }
314
315 // ----------------------------------------------------------------------------
316 void manualViewBaseContour::UpdateViewPoints()
317 {
318         int id, size = _lstViewPoints.size();
319         for( id=0; id<size; id++)
320         {
321                 UpdateViewPoint( id );
322         }
323 }
324
325 // ----------------------------------------------------------------------------
326 void manualViewBaseContour::AddPoint()
327 {
328         manualViewPoint *mvp    = new manualViewPoint( this->GetWxVtkBaseView() );
329         AddPoint( mvp );
330 }
331 // ----------------------------------------------------------------------------
332 void manualViewBaseContour::AddPoint( manualViewPoint * manualViewPoint )
333 {
334         _lstViewPoints.push_back( manualViewPoint );
335
336         // EED 3 oct 2006
337         manualViewPoint->SetSpacing(_spc);
338
339         vtkActor *actor = manualViewPoint->CreateVtkPointActor();
340         _wxvtkbaseview->GetRenderer()->AddActor( actor );       
341 }
342
343 // ----------------------------------------------------------------------------
344 void manualViewBaseContour::InsertPoint(int id)
345 {
346         manualViewPoint         *mvp    = new manualViewPoint( this->GetWxVtkBaseView() );
347
348 // EED 3 oct 2006
349         mvp->SetSpacing(_spc);
350
351         std::vector<manualViewPoint*>::iterator itNum = _lstViewPoints.begin() + id;
352         _lstViewPoints.insert(itNum,mvp);
353         _wxvtkbaseview->GetRenderer()->AddActor( mvp->CreateVtkPointActor() );
354 }
355 // ----------------------------------------------------------------------------
356 void manualViewBaseContour::DeleteContour()
357 {
358         RemoveCompleteContourActor();
359         /*if (_contourVtkActor!=NULL){
360                 _wxvtkbaseview->GetRenderer()->RemoveActor( _contourVtkActor );
361         }*/
362         DeleteVtkObjects();
363         int i,size=_lstViewPoints.size();
364         for (i=0;i<size;i++){
365                 manualViewBaseContour::DeletePoint(0);
366         }
367         Refresh();
368 }
369 // ----------------------------------------------------------------------------
370 void manualViewBaseContour::DeletePoint(int id) // virtual
371 {
372         int size=_lstViewPoints.size();
373         if ( (id>=0) && (id<size) ){
374                 manualViewPoint         *mvp    =_lstViewPoints[id];
375 //EED ups1
376 //              _handlePicker->DeletePickList(mvp->GetVtkActor());
377                 _wxvtkbaseview->GetRenderer()->RemoveActor( mvp->GetVtkActor() );
378                 std::vector<manualViewPoint*>::iterator itNum = _lstViewPoints.begin() + id;
379                 _lstViewPoints.erase(itNum);
380                 delete mvp;
381                 Refresh();
382         }
383 }
384 // ----------------------------------------------------------------------------
385 void manualViewBaseContour::DeletePoint(int x, int y, int z)
386 {
387         int id=GetIdPoint(x,y,z);
388         if (id!=-1){
389                 DeletePoint(id);
390         }
391 }
392 // ----------------------------------------------------------------------------
393 void manualViewBaseContour::SetSelected(bool selected)
394 {
395         _selected=selected;
396 }
397 // ----------------------------------------------------------------------------
398 void manualViewBaseContour::SetPosibleSelected(bool posibleSelected)
399 {
400         _posibleSelected=posibleSelected;
401 }
402 // ----------------------------------------------------------------------------
403 bool manualViewBaseContour::GetEditable()
404 {
405         return *_editable;
406 }
407 // ----------------------------------------------------------------------------
408 void manualViewBaseContour::SetEditable( bool * condition )
409 {
410         _editable = condition;
411 }
412 // ----------------------------------------------------------------------------
413 bool manualViewBaseContour::GetSelected()
414 {
415         return _selected;
416 }
417 // ----------------------------------------------------------------------------
418 bool manualViewBaseContour::GetPosibleSelected()
419 {
420         return _posibleSelected;
421 }
422 // ----------------------------------------------------------------------------
423 void manualViewBaseContour::DeleteSelectedPoints()
424 {
425         int i,size=_lstViewPoints.size();
426         for (i=size-1;i>=0;i--){
427                 if (_lstViewPoints[i]->GetSelected()==true){
428                         DeletePoint(i);
429                 }
430         }
431         Refresh();
432 }
433 // ----------------------------------------------------------------------------
434 void manualViewBaseContour::SelectPoint(int i, bool select)
435 {
436         _lstViewPoints[i]->SetSelected(select);
437 }
438 // ----------------------------------------------------------------------------
439 void manualViewBaseContour::SelectLstPoints()
440 {
441         // ToDo
442 }
443 // ----------------------------------------------------------------------------
444 void manualViewBaseContour::SelectAllPoints(bool select)
445 {
446         int i,size=_lstViewPoints.size();
447         for (i=0;i<size;i++){
448                 SelectPoint(i,select);
449         }
450 }
451 //-----------------------------------------------------------------------------
452 void manualViewBaseContour:: SetIfViewControlPoints(bool ifShow)
453 {
454         _viewControlPoints = ifShow;
455 }
456 // ----------------------------------------------------------------------------
457 bool manualViewBaseContour:: GetIfViewControlPoints()
458 {
459         return _viewControlPoints;
460 }
461
462 // ----------------------------------------------------------------------------
463 void manualViewBaseContour::SetPointPosibleSelected(int id,bool select)
464 {
465         _lstViewPoints[id]->SetPosibleSelected(select);
466 }
467 // ----------------------------------------------------------------------------
468 void manualViewBaseContour::SetPointSelected(int id,bool select)
469 {
470         _lstViewPoints[id]->SetSelected(select);
471 }
472 // ----------------------------------------------------------------------------
473 void manualViewBaseContour::SelectAllPossibleSelected(bool select)
474 {
475         int i,size=_lstViewPoints.size();
476         for (i=0;i<size;i++){
477                 SetPointPosibleSelected(i,select);
478         }
479 }
480 // ----------------------------------------------------------------------------
481 int manualViewBaseContour::SelectPosiblePoint(int x, int y, int z)  // virtual
482 {
483         SelectAllPossibleSelected(false);
484
485     int id = GetIdPoint(x,y,z);
486         if (id!=-1)
487         {
488                 SetPointPosibleSelected(id,true);
489         }
490         return id;
491 }
492 // ----------------------------------------------------------------------------
493 bool manualViewBaseContour::SelectPosibleContour(int x, int y, int z)
494 {
495         bool result=false;
496         SetPosibleSelected(result);
497     int id = GetIdPoint(x,y,z);
498                 
499         if( !GetEditable() && !_selected && id!= -1)
500         {
501                 result=true;
502                 SetPosibleSelected(result);
503         }
504         else
505         {
506                 if ( (GetEditable()==true) && (id==-1 ) && (this->_lstViewPoints.size()>=2) )
507                 {
508                         if (ifTouchContour(x,y,z)==true)
509                         {
510                                 result=true;
511                                 SetPosibleSelected(result);
512                         }
513                 }
514
515                 if (GetEditable()==false)
516                 {
517                         if (ifTouchContour(x,y,z)==true)
518                         {
519                                 result=true;
520                                 SetPosibleSelected(result);
521                         }
522                 }
523
524
525         }
526         return result;
527 }
528 // ----------------------------------------------------------------------------
529 bool manualViewBaseContour::ifTouchContour(int x,int y, int z) // virtual
530 {
531         return false;
532 }
533 // ----------------------------------------------------------------------------
534 void manualViewBaseContour::UnSelectPoint(int i){
535         _lstViewPoints[i]->SetSelected(false);
536         Refresh();
537 }
538 // ----------------------------------------------------------------------------
539 void manualViewBaseContour::UnSelectLstPoints(){
540         // ToDo
541 }
542 // ----------------------------------------------------------------------------
543 void manualViewBaseContour::UnSelectAllPoints(){
544         int i,size=_lstViewPoints.size();
545         for (i=0;i<size;i++){
546                 UnSelectPoint(i);
547         }
548         Refresh();
549 }
550 // ----------------------------------------------------------------------------
551 void manualViewBaseContour::SetModel(manualContourModel *manContModel){
552         _manContModel=manContModel;
553 }
554 // ----------------------------------------------------------------------------
555 void manualViewBaseContour::SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview){
556         _wxvtkbaseview = wxvtkbaseview;
557 }
558 // ----------------------------------------------------------------------------
559 void manualViewBaseContour::RefreshContour()  // Virtual
560 {
561 }
562 // ----------------------------------------------------------------------------
563 double* manualViewBaseContour::GetVectorPointsXManualContour(){
564         double pp[3];
565         int i,size = _sizePointsContour;
566         double *vx = (double*)malloc(sizeof(double)*size);
567         for (i=0;i<size;i++){
568                 _pts->GetPoint(i,pp);
569                 vx[i]=pp[0];
570         }
571         return vx;
572 }
573 // ----------------------------------------------------------------------------
574 double* manualViewBaseContour::GetVectorPointsYManualContour()
575 {
576         double pp[3];
577         int i,size = _sizePointsContour;
578         double *vy = (double*)malloc(sizeof(double)*size);
579         for (i=0;i<size;i++){
580                 _pts->GetPoint(i,pp);
581                 vy[i]=pp[1];
582         }
583         return vy;
584 }
585 // ----------------------------------------------------------------------------
586 double* manualViewBaseContour::GetVectorPointsZManualContour()
587 {
588         double pp[3];
589         int i,size = _sizePointsContour;
590         double *vz = (double*)malloc(sizeof(double)*size);
591         for (i=0;i<size;i++){
592                 _pts->GetPoint(i,pp);
593                 vz[i]=pp[2];
594         }
595         return vz;
596 }
597 // ----------------------------------------------------------------------------
598 void manualViewBaseContour::Refresh() // virtual
599 {
600         if (_contourVtkActor!=NULL){
601                 RefreshContour();
602         }
603         int i,size=_lstViewPoints.size();
604         for (i=0;i<size;i++){
605                 UpdateViewPoint(i);
606                 _lstViewPoints[i]->UpdateColorActor();
607         }
608         UpdateColorActor();
609
610         if (_show_text==true)
611         {
612                 RefreshText();
613         }
614
615         vtkRenderWindowInteractor *vri = _wxvtkbaseview->GetWxVTKRenderWindowInteractor ();
616         if (vri==NULL)
617         {
618                 _wxvtkbaseview->GetRenWin()->Render();
619                 printf("EED %p How to optimize manualViewBaseContour::Refresh() \n",this);
620         }
621
622 }
623 // ----------------------------------------------------------------------------
624 void manualViewBaseContour::RefreshText()  // virtual
625 {
626         if( _textActor!=NULL)
627                 _textActor -> SetInput("00");
628 }
629 // ----------------------------------------------------------------------------
630 void manualViewBaseContour::SetColorNormalContour(double r, double g, double b)
631 {
632         _coulorNormal_r = r;
633         _coulorNormal_g = g;
634         _coulorNormal_b = b;
635 }
636 // ----------------------------------------------------------------------------
637 void manualViewBaseContour::GetColorNormalContour(double &r, double &g, double &b)
638 {
639         r = _coulorNormal_r;
640         g = _coulorNormal_g;
641         b = _coulorNormal_b;
642 }
643 // ----------------------------------------------------------------------------
644 void manualViewBaseContour::SetColorEditContour(double r, double g, double b)
645 {
646         _coulorEdit_r = r;
647         _coulorEdit_g = g;
648         _coulorEdit_b = b;
649 }
650 // ----------------------------------------------------------------------------
651 void manualViewBaseContour::GetColorEditContour(double &r, double &g, double &b)
652 {
653         r = _coulorEdit_r;
654         g = _coulorEdit_g;
655         b = _coulorEdit_b;
656 }
657 // ----------------------------------------------------------------------------
658 void manualViewBaseContour::SetColorSelectContour(double r, double g, double b)
659 {
660         _coulorSelection_r = r;
661         _coulorSelection_g = g;
662         _coulorSelection_b = b;
663 }
664 // ----------------------------------------------------------------------------
665 void manualViewBaseContour::GetColorSelectContour(double &r, double &g, double &b)
666 {
667         r = _coulorSelection_r;
668         g = _coulorSelection_g;
669         b = _coulorSelection_b;
670 }
671 // ----------------------------------------------------------------------------
672 void manualViewBaseContour::UpdateColorActor()
673 {
674         if (_contourVtkActor!=NULL)
675         {
676                 _contourVtkActor->GetProperty()->SetLineWidth( _widthline );
677                 _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorNormal_r , _coulorNormal_g , _coulorNormal_b );
678                 if (_posibleSelected || (_posibleSelected && GetEditable() ) )
679                 {
680                         _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorEdit_r , _coulorEdit_g , _coulorEdit_b );
681                 }
682                 if( _selected )
683                 {
684                         _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorSelection_r , _coulorSelection_g , _coulorSelection_b );
685                 }
686         }
687 }
688 // ----------------------------------------------------------------------------
689 int     manualViewBaseContour::GetIdPoint(int x, int y, int z) // virtual
690 {
691         int ii = -1;
692         if (_manContModel!=NULL){
693                 double xx = x;
694                 double yy = y;
695                 double zz = z;
696                 TransfromCoordViewWorld(xx,yy,zz);
697                 ii=_manContModel->GetIdPoint(xx,yy,zz,_range,-1);
698         }
699         return ii;
700 }
701
702 // ----------------------------------------------------------------------------
703
704
705 int manualViewBaseContour::GetNumberOfPoints()
706 {
707         return _lstViewPoints.size();
708 }
709
710 // ----------------------------------------------------------------------------
711
712 //JSTG 25-02-08 ---------------------------------------------------------------
713 /*int manualViewBaseContour::GetNumberOfPointsSpline()
714 {
715         return _sizePointsContour;
716 }*/
717 //----------------------------------------------------------------------------
718
719 //JSTG 25-02-08 ---------------------------------------------------------------
720 /*void manualViewBaseContour::SetNumberOfPointsSpline(int size)
721 {
722         _sizePointsContour = size;
723 }*/
724 //----------------------------------------------------------------------------
725 // virtual
726 void manualViewBaseContour::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type)  // Virtual
727 {
728         _wxvtkbaseview->TransFromCoordScreenToWorld(X, Y, Z,false, type);
729
730
731 //EED 27 sep 2007
732 //   //EEDx6
733 //      wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*)_wxvtkbaseview;
734 //      wxvtk2Dbaseview->TransformCoordinate_spacing_ModelToView(X,Y,Z);
735
736 }
737 // ----------------------------------------------------------------------------
738 void manualViewBaseContour::SetRange(double range)
739 {
740         _range=range;
741 }
742 // ----------------------------------------------------------------------------
743 double  manualViewBaseContour::GetRange()
744 {
745         return _range;
746 }
747 // ----------------------------------------------------------------------------
748 void manualViewBaseContour::SetZ(int z)
749 {
750 //      _Z=z;
751 }
752 // ----------------------------------------------------------------------------
753 int     manualViewBaseContour::GetZ()
754 {
755 //      return _Z;
756         return 0;
757 }
758 // ----------------------------------------------------------------------------
759 void manualViewBaseContour::InitMove(int x, int y, int z) // virtual
760 {
761
762 }
763 // ----------------------------------------------------------------------------
764 void manualViewBaseContour::MoveContour(int x, int y, int z) // virtual
765 {
766 }
767 // ----------------------------------------------------------------------------
768 void manualViewBaseContour::MoveContour(int horizontalUnits, int verticalUnits )// virtual
769 {
770
771 }
772 // ----------------------------------------------------------------------------
773 void manualViewBaseContour::GetMinMax( double &minX,double &minY, double &minZ, double &maxX, double &maxY, double &maxZ )// virtual
774 {
775         double  pp[3];
776         manualPoint *mp;
777         int i;
778         int size=_manContModel->GetSizeLstPoints();
779         minX=99999;
780         minY=99999;
781         maxX=-99999;
782         maxY=-99999;
783         bool ifFindZ = minZ!=-1.0 && maxZ!=-1.0;
784         if ( ifFindZ )
785         {
786                 minZ=99999;
787                 maxZ=-99999;
788         }
789         for( i = 0; i < size; i++ )
790         {
791                 mp=_manContModel->GetManualPoint(i);
792                 pp[0]=mp->GetX();
793                 pp[1]=mp->GetY();
794                 if ( ifFindZ )
795                         pp[2]=mp->GetZ();
796
797                 // min X
798                 if (pp[0]<minX)
799                 {
800                         minX=pp[0];
801                 }
802                 //min Y
803                 if (pp[1]<minY)
804                 {
805                         minY=pp[1];
806                 }
807                 //max X
808                 if (pp[0]>maxX)
809                 {
810                         maxX=pp[0];
811                 }
812                 // max Y
813                 if (pp[1]>maxY)
814                 {
815                         maxY=pp[1];
816                 }
817                 if ( ifFindZ )
818                 {
819                         // min Z
820                         if (pp[2]<minZ)
821                         {
822                                 minZ=pp[2];
823                         }
824                         // max Z
825                         if (pp[2]>maxZ)
826                         {
827                                 maxZ=pp[2];
828                         }
829                 }
830         }
831         if ( size<1 )
832         {
833                 minX = 0;
834                 maxX = 0;
835
836                 minY = 0;
837                 maxY = 0;
838
839                 minZ = 0;
840                 maxZ = 0;
841         }
842 }
843 // ----------------------------------------------------------------------------
844 void manualViewBaseContour::ClearContour()
845 {
846         if (_contourVtkActor!=NULL){
847                 _wxvtkbaseview->GetRenderer()->RemoveActor( _contourVtkActor );
848         }
849         DeleteVtkObjects();
850         int i,size=_lstViewPoints.size();
851         for (i=0;i<size;i++){
852                 ClearPoint(0);
853         }
854         Refresh();
855 }
856 // ----------------------------------------------------------------------------
857 void manualViewBaseContour::ClearPoint(int id)
858 {
859         DeletePoint(id);
860 }
861 // ----------------------------------------------------------------------------
862 void manualViewBaseContour::SetVisible(bool ok)
863 {
864         double opacity;
865         if (ok==true)
866         {
867                 opacity=1;
868         } else {
869                 opacity=0.5;
870         }
871         vtkActor *actor;
872         int i,size=_lstViewPoints.size();
873         for (i=0;i<size;i++){
874                 actor = _lstViewPoints[i]->GetVtkActor();
875                 actor->GetProperty()->SetOpacity( opacity );
876         }
877         _contourVtkActor->GetProperty()->SetOpacity( opacity );
878         _textActor->GetProperty()->SetOpacity( opacity );
879         _textActor->SetInput("00");
880
881 }
882 // ----------------------------------------------------------------------------
883 void manualViewBaseContour::SetShowText(bool ok)
884 {
885         _show_text = ok;
886         if (_show_text==false)
887         {
888                 _textActor->SetInput("00");
889         }
890 }
891 // ----------------------------------------------------------------------------
892 wxVtkBaseView *manualViewBaseContour::GetWxVtkBaseView()
893 {
894         return this->_wxvtkbaseview;
895 }
896 // ----------------------------------------------------------------------------
897 void manualViewBaseContour::GetSpacing(double spc[3])
898 {
899         spc[0] = _spc[0];
900         spc[1] = _spc[1];
901         spc[2] = _spc[2];
902 }
903 // ----------------------------------------------------------------------------
904 void manualViewBaseContour::SetSpacing(double spc[3])
905 {
906         _spc[0] = spc[0];
907         _spc[1] = spc[1];
908         _spc[2] = spc[2];
909 }