]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp
*** empty log 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         if( !GetEditable() && !_selected && id!= -1)
499         {
500                 result=true;
501                 SetPosibleSelected(result);
502         }
503         else
504         {
505                 if ( (GetEditable()==true) && (id==-1 ) && (this->_lstViewPoints.size()>=2) )
506                 {
507                         if (ifTouchContour(x,y,z)==true)
508                         {
509                                 result=true;
510                                 SetPosibleSelected(result);
511                         }
512                 }
513
514                 if (GetEditable()==false)
515                 {
516                         if (ifTouchContour(x,y,z)==true)
517                         {
518                                 result=true;
519                                 SetPosibleSelected(result);
520                         }
521                 }
522
523
524         }
525         return result;
526 }
527 // ----------------------------------------------------------------------------
528 bool manualViewBaseContour::ifTouchContour(int x,int y, int z) // virtual
529 {
530         return false;
531 }
532 // ----------------------------------------------------------------------------
533 void manualViewBaseContour::UnSelectPoint(int i){
534         _lstViewPoints[i]->SetSelected(false);
535         Refresh();
536 }
537 // ----------------------------------------------------------------------------
538 void manualViewBaseContour::UnSelectLstPoints(){
539         // ToDo
540 }
541 // ----------------------------------------------------------------------------
542 void manualViewBaseContour::UnSelectAllPoints(){
543         int i,size=_lstViewPoints.size();
544         for (i=0;i<size;i++){
545                 UnSelectPoint(i);
546         }
547         Refresh();
548 }
549 // ----------------------------------------------------------------------------
550 void manualViewBaseContour::SetModel(manualContourModel *manContModel){
551         _manContModel=manContModel;
552 }
553 // ----------------------------------------------------------------------------
554 void manualViewBaseContour::SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview){
555         _wxvtkbaseview = wxvtkbaseview;
556 }
557 // ----------------------------------------------------------------------------
558 void manualViewBaseContour::RefreshContour()  // Virtual
559 {
560 }
561 // ----------------------------------------------------------------------------
562 double* manualViewBaseContour::GetVectorPointsXManualContour(){
563         double pp[3];
564         int i,size = _sizePointsContour;
565         double *vx = (double*)malloc(sizeof(double)*size);
566         for (i=0;i<size;i++){
567                 _pts->GetPoint(i,pp);
568                 vx[i]=pp[0];
569         }
570         return vx;
571 }
572 // ----------------------------------------------------------------------------
573 double* manualViewBaseContour::GetVectorPointsYManualContour()
574 {
575         double pp[3];
576         int i,size = _sizePointsContour;
577         double *vy = (double*)malloc(sizeof(double)*size);
578         for (i=0;i<size;i++){
579                 _pts->GetPoint(i,pp);
580                 vy[i]=pp[1];
581         }
582         return vy;
583 }
584 // ----------------------------------------------------------------------------
585 double* manualViewBaseContour::GetVectorPointsZManualContour()
586 {
587         double pp[3];
588         int i,size = _sizePointsContour;
589         double *vz = (double*)malloc(sizeof(double)*size);
590         for (i=0;i<size;i++){
591                 _pts->GetPoint(i,pp);
592                 vz[i]=pp[2];
593         }
594         return vz;
595 }
596 // ----------------------------------------------------------------------------
597 void manualViewBaseContour::Refresh() // virtual
598 {
599         if (_contourVtkActor!=NULL){
600                 RefreshContour();
601         }
602         int i,size=_lstViewPoints.size();
603         for (i=0;i<size;i++){
604                 UpdateViewPoint(i);
605                 _lstViewPoints[i]->UpdateColorActor();
606         }
607         UpdateColorActor();
608
609         if (_show_text==true)
610         {
611                 RefreshText();
612         }
613
614         vtkRenderWindowInteractor *vri = _wxvtkbaseview->GetWxVTKRenderWindowInteractor ();
615         if (vri==NULL)
616         {
617                 _wxvtkbaseview->GetRenWin()->Render();
618         }
619
620 }
621 // ----------------------------------------------------------------------------
622 void manualViewBaseContour::RefreshText()  // virtual
623 {
624         if( _textActor!=NULL)
625                 _textActor -> SetInput("00");
626 }
627 // ----------------------------------------------------------------------------
628 void manualViewBaseContour::SetColorNormalContour(double r, double g, double b)
629 {
630         _coulorNormal_r = r;
631         _coulorNormal_g = g;
632         _coulorNormal_b = b;
633 }
634 // ----------------------------------------------------------------------------
635 void manualViewBaseContour::GetColorNormalContour(double &r, double &g, double &b)
636 {
637         r = _coulorNormal_r;
638         g = _coulorNormal_g;
639         b = _coulorNormal_b;
640 }
641 // ----------------------------------------------------------------------------
642 void manualViewBaseContour::SetColorEditContour(double r, double g, double b)
643 {
644         _coulorEdit_r = r;
645         _coulorEdit_g = g;
646         _coulorEdit_b = b;
647 }
648 // ----------------------------------------------------------------------------
649 void manualViewBaseContour::GetColorEditContour(double &r, double &g, double &b)
650 {
651         r = _coulorEdit_r;
652         g = _coulorEdit_g;
653         b = _coulorEdit_b;
654 }
655 // ----------------------------------------------------------------------------
656 void manualViewBaseContour::SetColorSelectContour(double r, double g, double b)
657 {
658         _coulorSelection_r = r;
659         _coulorSelection_g = g;
660         _coulorSelection_b = b;
661 }
662 // ----------------------------------------------------------------------------
663 void manualViewBaseContour::GetColorSelectContour(double &r, double &g, double &b)
664 {
665         r = _coulorSelection_r;
666         g = _coulorSelection_g;
667         b = _coulorSelection_b;
668 }
669 // ----------------------------------------------------------------------------
670 void manualViewBaseContour::UpdateColorActor()
671 {
672         if (_contourVtkActor!=NULL)
673         {
674                 _contourVtkActor->GetProperty()->SetLineWidth( _widthline );
675                 _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorNormal_r , _coulorNormal_g , _coulorNormal_b );
676                 if (_posibleSelected || (_posibleSelected && GetEditable() ) )
677                 {
678                         _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorEdit_r , _coulorEdit_g , _coulorEdit_b );
679                 }
680                 if( _selected )
681                 {
682                         _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorSelection_r , _coulorSelection_g , _coulorSelection_b );
683                 }
684         }
685 }
686 // ----------------------------------------------------------------------------
687 int     manualViewBaseContour::GetIdPoint(int x, int y, int z) // virtual
688 {
689         int ii = -1;
690         if (_manContModel!=NULL){
691                 double xx = x;
692                 double yy = y;
693                 double zz = z;
694                 TransfromeCoordViewWorld(xx,yy,zz);
695                 ii=_manContModel->GetIdPoint(xx,yy,zz,_range,-1);
696         }
697         return ii;
698 }
699
700 // ----------------------------------------------------------------------------
701
702
703 int manualViewBaseContour::GetNumberOfPoints()
704 {
705         return _lstViewPoints.size();
706 }
707
708 // ----------------------------------------------------------------------------
709
710 //JSTG 25-02-08 ---------------------------------------------------------------
711 /*int manualViewBaseContour::GetNumberOfPointsSpline()
712 {
713         return _sizePointsContour;
714 }*/
715 //----------------------------------------------------------------------------
716
717 //JSTG 25-02-08 ---------------------------------------------------------------
718 /*void manualViewBaseContour::SetNumberOfPointsSpline(int size)
719 {
720         _sizePointsContour = size;
721 }*/
722 //----------------------------------------------------------------------------
723 // virtual
724 void manualViewBaseContour::TransfromeCoordViewWorld(double &X, double &Y, double &Z, int type)  // Virtual
725 {
726         _wxvtkbaseview->TransfromeCoordScreenToWorld(X, Y, Z, type);
727
728
729 //EED 27 sep 2007
730 //   //EEDx6
731 //      wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*)_wxvtkbaseview;
732 //      wxvtk2Dbaseview->TransformCoordinate_spacing_ModelToView(X,Y,Z);
733
734 }
735 // ----------------------------------------------------------------------------
736 void manualViewBaseContour::SetRange(int range)
737 {
738         _range=range;
739 }
740 // ----------------------------------------------------------------------------
741 int     manualViewBaseContour::GetRange()
742 {
743         return _range;
744 }
745 // ----------------------------------------------------------------------------
746 void manualViewBaseContour::SetZ(int z)
747 {
748 //      _Z=z;
749 }
750 // ----------------------------------------------------------------------------
751 int     manualViewBaseContour::GetZ()
752 {
753 //      return _Z;
754         return 0;
755 }
756 // ----------------------------------------------------------------------------
757 void manualViewBaseContour::InitMove(int x, int y, int z) // virtual
758 {
759
760 }
761 // ----------------------------------------------------------------------------
762 void manualViewBaseContour::MoveContour(int x, int y, int z) // virtual
763 {
764 }
765 // ----------------------------------------------------------------------------
766 void manualViewBaseContour::MoveContour(int horizontalUnits, int verticalUnits )// virtual
767 {
768
769 }
770 // ----------------------------------------------------------------------------
771 void manualViewBaseContour::GetMinMax( double &minX,double &minY, double &minZ, double &maxX, double &maxY, double &maxZ )// virtual
772 {
773         double  pp[3];
774         manualPoint *mp;
775         int i;
776         int size=_manContModel->GetSizeLstPoints();
777         minX=99999;
778         minY=99999;
779         maxX=-99999;
780         maxY=-99999;
781         bool ifFindZ = minZ!=-1.0 && maxZ!=-1.0;
782         if ( ifFindZ )
783         {
784                 minZ=99999;
785                 maxZ=-99999;
786         }
787         for( i = 0; i < size; i++ )
788         {
789                 mp=_manContModel->GetManualPoint(i);
790                 pp[0]=mp->GetX();
791                 pp[1]=mp->GetY();
792                 if ( ifFindZ )
793                         pp[2]=mp->GetZ();
794
795                 // min X
796                 if (pp[0]<minX)
797                 {
798                         minX=pp[0];
799                 }
800                 //min Y
801                 if (pp[1]<minY)
802                 {
803                         minY=pp[1];
804                 }
805                 //max X
806                 if (pp[0]>maxX)
807                 {
808                         maxX=pp[0];
809                 }
810                 // max Y
811                 if (pp[1]>maxY)
812                 {
813                         maxY=pp[1];
814                 }
815                 if ( ifFindZ )
816                 {
817                         // min Z
818                         if (pp[2]<minZ)
819                         {
820                                 minZ=pp[2];
821                         }
822                         // max Z
823                         if (pp[2]>maxZ)
824                         {
825                                 maxZ=pp[2];
826                         }
827                 }
828         }
829         if ( size<1 )
830         {
831                 minX = 0;
832                 maxX = 0;
833
834                 minY = 0;
835                 maxY = 0;
836
837                 minZ = 0;
838                 maxZ = 0;
839         }
840 }
841 // ----------------------------------------------------------------------------
842 void manualViewBaseContour::ClearContour()
843 {
844         if (_contourVtkActor!=NULL){
845                 _wxvtkbaseview->GetRenderer()->RemoveActor( _contourVtkActor );
846         }
847         DeleteVtkObjects();
848         int i,size=_lstViewPoints.size();
849         for (i=0;i<size;i++){
850                 ClearPoint(0);
851         }
852         Refresh();
853 }
854 // ----------------------------------------------------------------------------
855 void manualViewBaseContour::ClearPoint(int id)
856 {
857         DeletePoint(id);
858 }
859 // ----------------------------------------------------------------------------
860 void manualViewBaseContour::SetVisible(bool ok)
861 {
862         double opacity;
863         if (ok==true)
864         {
865                 opacity=1;
866         } else {
867                 opacity=0.5;
868         }
869         vtkActor *actor;
870         int i,size=_lstViewPoints.size();
871         for (i=0;i<size;i++){
872                 actor = _lstViewPoints[i]->GetVtkActor();
873                 actor->GetProperty()->SetOpacity( opacity );
874         }
875         _contourVtkActor->GetProperty()->SetOpacity( opacity );
876         _textActor->GetProperty()->SetOpacity( opacity );
877         _textActor->SetInput("00");
878
879 }
880 // ----------------------------------------------------------------------------
881 void manualViewBaseContour::SetShowText(bool ok)
882 {
883         _show_text = ok;
884         if (_show_text==false)
885         {
886                 _textActor->SetInput("00");
887         }
888 }
889 // ----------------------------------------------------------------------------
890 wxVtkBaseView *manualViewBaseContour::GetWxVtkBaseView()
891 {
892         return this->_wxvtkbaseview;
893 }
894 // ----------------------------------------------------------------------------
895 void manualViewBaseContour::GetSpacing(double spc[3])
896 {
897         spc[0] = _spc[0];
898         spc[1] = _spc[1];
899         spc[2] = _spc[2];
900 }
901 // ----------------------------------------------------------------------------
902 void manualViewBaseContour::SetSpacing(double spc[3])
903 {
904         _spc[0] = spc[0];
905         _spc[1] = spc[1];
906         _spc[2] = spc[2];
907 }