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