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