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