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