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