]> 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         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                 printf("EED %p How to optimize manualViewBaseContour::Refresh() \n",this);
619         }
620
621 }
622 // ----------------------------------------------------------------------------
623 void manualViewBaseContour::RefreshText()  // virtual
624 {
625         if( _textActor!=NULL)
626                 _textActor -> SetInput("00");
627 }
628 // ----------------------------------------------------------------------------
629 void manualViewBaseContour::SetColorNormalContour(double r, double g, double b)
630 {
631         _coulorNormal_r = r;
632         _coulorNormal_g = g;
633         _coulorNormal_b = b;
634 }
635 // ----------------------------------------------------------------------------
636 void manualViewBaseContour::GetColorNormalContour(double &r, double &g, double &b)
637 {
638         r = _coulorNormal_r;
639         g = _coulorNormal_g;
640         b = _coulorNormal_b;
641 }
642 // ----------------------------------------------------------------------------
643 void manualViewBaseContour::SetColorEditContour(double r, double g, double b)
644 {
645         _coulorEdit_r = r;
646         _coulorEdit_g = g;
647         _coulorEdit_b = b;
648 }
649 // ----------------------------------------------------------------------------
650 void manualViewBaseContour::GetColorEditContour(double &r, double &g, double &b)
651 {
652         r = _coulorEdit_r;
653         g = _coulorEdit_g;
654         b = _coulorEdit_b;
655 }
656 // ----------------------------------------------------------------------------
657 void manualViewBaseContour::SetColorSelectContour(double r, double g, double b)
658 {
659         _coulorSelection_r = r;
660         _coulorSelection_g = g;
661         _coulorSelection_b = b;
662 }
663 // ----------------------------------------------------------------------------
664 void manualViewBaseContour::GetColorSelectContour(double &r, double &g, double &b)
665 {
666         r = _coulorSelection_r;
667         g = _coulorSelection_g;
668         b = _coulorSelection_b;
669 }
670 // ----------------------------------------------------------------------------
671 void manualViewBaseContour::UpdateColorActor()
672 {
673         if (_contourVtkActor!=NULL)
674         {
675                 _contourVtkActor->GetProperty()->SetLineWidth( _widthline );
676                 _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorNormal_r , _coulorNormal_g , _coulorNormal_b );
677                 if (_posibleSelected || (_posibleSelected && GetEditable() ) )
678                 {
679                         _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorEdit_r , _coulorEdit_g , _coulorEdit_b );
680                 }
681                 if( _selected )
682                 {
683                         _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorSelection_r , _coulorSelection_g , _coulorSelection_b );
684                 }
685         }
686 }
687 // ----------------------------------------------------------------------------
688 int     manualViewBaseContour::GetIdPoint(int x, int y, int z) // virtual
689 {
690         int ii = -1;
691         if (_manContModel!=NULL){
692                 double xx = x;
693                 double yy = y;
694                 double zz = z;
695                 TransfromCoordViewWorld(xx,yy,zz);
696                 ii=_manContModel->GetIdPoint(xx,yy,zz,_range,-1);
697         }
698         return ii;
699 }
700
701 // ----------------------------------------------------------------------------
702
703
704 int manualViewBaseContour::GetNumberOfPoints()
705 {
706         return _lstViewPoints.size();
707 }
708
709 // ----------------------------------------------------------------------------
710
711 //JSTG 25-02-08 ---------------------------------------------------------------
712 /*int manualViewBaseContour::GetNumberOfPointsSpline()
713 {
714         return _sizePointsContour;
715 }*/
716 //----------------------------------------------------------------------------
717
718 //JSTG 25-02-08 ---------------------------------------------------------------
719 /*void manualViewBaseContour::SetNumberOfPointsSpline(int size)
720 {
721         _sizePointsContour = size;
722 }*/
723 //----------------------------------------------------------------------------
724 // virtual
725 void manualViewBaseContour::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type)  // Virtual
726 {
727         _wxvtkbaseview->TransFromCoordScreenToWorld(X, Y, Z,false, type);
728
729
730 //EED 27 sep 2007
731 //   //EEDx6
732 //      wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*)_wxvtkbaseview;
733 //      wxvtk2Dbaseview->TransformCoordinate_spacing_ModelToView(X,Y,Z);
734
735 }
736 // ----------------------------------------------------------------------------
737 void manualViewBaseContour::SetRange(double range)
738 {
739         _range=range;
740 }
741 // ----------------------------------------------------------------------------
742 double  manualViewBaseContour::GetRange()
743 {
744         return _range;
745 }
746 // ----------------------------------------------------------------------------
747 void manualViewBaseContour::SetZ(int z)
748 {
749 //      _Z=z;
750 }
751 // ----------------------------------------------------------------------------
752 int     manualViewBaseContour::GetZ()
753 {
754 //      return _Z;
755         return 0;
756 }
757 // ----------------------------------------------------------------------------
758 void manualViewBaseContour::InitMove(int x, int y, int z) // virtual
759 {
760
761 }
762 // ----------------------------------------------------------------------------
763 void manualViewBaseContour::MoveContour(int x, int y, int z) // virtual
764 {
765 }
766 // ----------------------------------------------------------------------------
767 void manualViewBaseContour::MoveContour(int horizontalUnits, int verticalUnits )// virtual
768 {
769
770 }
771 // ----------------------------------------------------------------------------
772 void manualViewBaseContour::GetMinMax( double &minX,double &minY, double &minZ, double &maxX, double &maxY, double &maxZ )// virtual
773 {
774         double  pp[3];
775         manualPoint *mp;
776         int i;
777         int size=_manContModel->GetSizeLstPoints();
778         minX=99999;
779         minY=99999;
780         maxX=-99999;
781         maxY=-99999;
782         bool ifFindZ = minZ!=-1.0 && maxZ!=-1.0;
783         if ( ifFindZ )
784         {
785                 minZ=99999;
786                 maxZ=-99999;
787         }
788         for( i = 0; i < size; i++ )
789         {
790                 mp=_manContModel->GetManualPoint(i);
791                 pp[0]=mp->GetX();
792                 pp[1]=mp->GetY();
793                 if ( ifFindZ )
794                         pp[2]=mp->GetZ();
795
796                 // min X
797                 if (pp[0]<minX)
798                 {
799                         minX=pp[0];
800                 }
801                 //min Y
802                 if (pp[1]<minY)
803                 {
804                         minY=pp[1];
805                 }
806                 //max X
807                 if (pp[0]>maxX)
808                 {
809                         maxX=pp[0];
810                 }
811                 // max Y
812                 if (pp[1]>maxY)
813                 {
814                         maxY=pp[1];
815                 }
816                 if ( ifFindZ )
817                 {
818                         // min Z
819                         if (pp[2]<minZ)
820                         {
821                                 minZ=pp[2];
822                         }
823                         // max Z
824                         if (pp[2]>maxZ)
825                         {
826                                 maxZ=pp[2];
827                         }
828                 }
829         }
830         if ( size<1 )
831         {
832                 minX = 0;
833                 maxX = 0;
834
835                 minY = 0;
836                 maxY = 0;
837
838                 minZ = 0;
839                 maxZ = 0;
840         }
841 }
842 // ----------------------------------------------------------------------------
843 void manualViewBaseContour::ClearContour()
844 {
845         if (_contourVtkActor!=NULL){
846                 _wxvtkbaseview->GetRenderer()->RemoveActor( _contourVtkActor );
847         }
848         DeleteVtkObjects();
849         int i,size=_lstViewPoints.size();
850         for (i=0;i<size;i++){
851                 ClearPoint(0);
852         }
853         Refresh();
854 }
855 // ----------------------------------------------------------------------------
856 void manualViewBaseContour::ClearPoint(int id)
857 {
858         DeletePoint(id);
859 }
860 // ----------------------------------------------------------------------------
861 void manualViewBaseContour::SetVisible(bool ok)
862 {
863         double opacity;
864         if (ok==true)
865         {
866                 opacity=1;
867         } else {
868                 opacity=0.5;
869         }
870         vtkActor *actor;
871         int i,size=_lstViewPoints.size();
872         for (i=0;i<size;i++){
873                 actor = _lstViewPoints[i]->GetVtkActor();
874                 actor->GetProperty()->SetOpacity( opacity );
875         }
876         _contourVtkActor->GetProperty()->SetOpacity( opacity );
877         _textActor->GetProperty()->SetOpacity( opacity );
878         _textActor->SetInput("00");
879
880 }
881 // ----------------------------------------------------------------------------
882 void manualViewBaseContour::SetShowText(bool ok)
883 {
884         _show_text = ok;
885         if (_show_text==false)
886         {
887                 _textActor->SetInput("00");
888         }
889 }
890 // ----------------------------------------------------------------------------
891 wxVtkBaseView *manualViewBaseContour::GetWxVtkBaseView()
892 {
893         return this->_wxvtkbaseview;
894 }
895 // ----------------------------------------------------------------------------
896 void manualViewBaseContour::GetSpacing(double spc[3])
897 {
898         spc[0] = _spc[0];
899         spc[1] = _spc[1];
900         spc[2] = _spc[2];
901 }
902 // ----------------------------------------------------------------------------
903 void manualViewBaseContour::SetSpacing(double spc[3])
904 {
905         _spc[0] = spc[0];
906         _spc[1] = spc[1];
907         _spc[2] = spc[2];
908 }