]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/include/vtk3DQuantSurfaceWidget.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / include / vtk3DQuantSurfaceWidget.cxx
1 /*=========================================================================
2
3   Program:   wxMaracas
4   Module:    $RCSfile: vtk3DQuantSurfaceWidget.cxx,v $
5   Language:  C++
6   Date:      $Date: 2009/05/14 13:54:57 $
7   Version:   $Revision: 1.1 $
8
9   Copyright: (c) 2002, 2003
10   License:
11   
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notice for more information.
15
16 =========================================================================*/
17 #include "vtk3DQuantSurfaceWidget.h"
18 #include <vtkPointPicker.h>
19 #include <vtkCamera.h>
20 #include <vtkWindowLevelLookupTable.h>
21 // EED
22 #include <vtkPolyLine.h> 
23 #include <vtkPlaneSource.h> 
24
25
26
27 //----------------------------------------------------------------------------
28 RectangleGuideVtk::RectangleGuideVtk(){
29   _showActor    = false;
30   _grid                 = NULL; 
31   _actor                = NULL;
32   _points               = NULL;
33   _mapper               = NULL;
34   _poly_line    = NULL;
35   _iSlice               = -1;
36 }
37 //----------------------------------------------------------------------------
38 RectangleGuideVtk::~RectangleGuideVtk(){
39   if( _grid              )      _grid->Delete();
40   if( _actor     )      _actor->Delete();
41   if( _points    )      _points->Delete();
42   if( _mapper    )      _mapper->Delete();
43   if( _poly_line )      _poly_line->Delete();
44 }
45
46 //----------------------------------------------------------------------------
47 //----------------------------------------------------------------------------
48 //----------------------------------------------------------------------------
49 //----------------------------------------------------------------------------
50 listContourVTK::listContourVTK(vtk3DQuantSurfaceWidget *quantSurfaceWidget){
51         _r=1;
52         _g=1;
53         _b=1;
54         _vtk3DQuantSurfaceWidget=quantSurfaceWidget;
55 }
56 //----------------------------------------------------------------------------
57 listContourVTK::~listContourVTK(){
58         EraseListContourActor();
59 }
60 //----------------------------------------------------------------------------
61 void listContourVTK::SetColour(int r,int g,int b){
62         _r=r;
63         _g=g;
64         _b=b;
65 }
66 //----------------------------------------------------------------------------
67 void listContourVTK::InitListContourActor(int nos){
68   EraseListContourActor();
69   int i;
70   for (i=0;i<nos;i++){
71     _lst3DContoursVtkActor.push_back( NULL );
72     _lst3DContoursVtkUnstructuredGrid.push_back( NULL );
73     _lst3DContoursVtkDataSetMapper.push_back( NULL );
74     _lst3DContoursVtkPolyLine.push_back( NULL );
75   }
76
77   // Refresh 3DWidget
78 // EED 31 mai 2007 
79 //  vtkRenderWindow* pRenderWindow = _vtk3DQuantSurfaceWidget->QuantSurfaceWidget_GetRenderWindow();
80 //  pRenderWindow->Render( );
81 }
82 //----------------------------------------------------------------------------
83 void listContourVTK::EraseListContourActor(){
84         int i;
85         for (i=0;i<_lst3DContoursVtkActor.size();i++){
86                 EraseSliceContourActor(i,false);
87          }
88         _lst3DContoursVtkActor.clear();
89         _lst3DContoursVtkUnstructuredGrid.clear();
90         _lst3DContoursVtkDataSetMapper.clear();
91         _lst3DContoursVtkPolyLine.clear();
92 }
93 //----------------------------------------------------------------------------
94 void listContourVTK::EraseSliceContourActor(int slice, bool refresh){
95         if (_lst3DContoursVtkActor[slice]!=NULL){
96                 vtkRenderer *pRenderer = _vtk3DQuantSurfaceWidget->QuantSurfaceWidget_GetRenderer();
97                 if (_lst3DContoursVtkActor[slice])                                      pRenderer->RemoveActor(_lst3DContoursVtkActor[slice]);
98                 if (_lst3DContoursVtkUnstructuredGrid[slice])           _lst3DContoursVtkUnstructuredGrid[slice]->Delete();
99                 if (_lst3DContoursVtkDataSetMapper[slice])                      _lst3DContoursVtkDataSetMapper[slice]->Delete();
100                 if (_lst3DContoursVtkPolyLine[slice])                           _lst3DContoursVtkPolyLine[slice]->Delete();
101                 if (_lst3DContoursVtkActor[slice])                                      _lst3DContoursVtkActor[slice]->Delete();
102                 _lst3DContoursVtkUnstructuredGrid[slice]=NULL;
103                 _lst3DContoursVtkDataSetMapper[slice]=NULL;
104                 _lst3DContoursVtkPolyLine[slice]=NULL;
105                 _lst3DContoursVtkActor[slice]=NULL;
106         }
107         if (refresh==true){
108                 // Refresh 3DWidget
109                 vtkRenderWindow* pRenderWindow = _vtk3DQuantSurfaceWidget->QuantSurfaceWidget_GetRenderWindow();
110                 pRenderWindow->Render( );
111         }
112 }
113 //----------------------------------------------------------------------------
114 void listContourVTK::Set3DContourActor( int slice, vtkPoints* contour3D, bool showActor){
115         // Erase old actor
116         EraseSliceContourActor(slice);
117         // generate new actor
118         int id,numberOfPoints;
119         numberOfPoints=contour3D->GetNumberOfPoints ();
120         _lst3DContoursVtkPolyLine[slice]        = vtkPolyLine::New();
121
122         ( _lst3DContoursVtkPolyLine[slice]->GetPointIds() )->SetNumberOfIds(numberOfPoints);
123         for (id=0;id<numberOfPoints;id++){
124                 ( _lst3DContoursVtkPolyLine[slice]->GetPointIds() )->SetId(id,id);
125         }
126         _lst3DContoursVtkUnstructuredGrid[slice]=vtkUnstructuredGrid::New();
127         _lst3DContoursVtkUnstructuredGrid[slice]->Allocate(1,1);
128         _lst3DContoursVtkUnstructuredGrid[slice]->InsertNextCell(   _lst3DContoursVtkPolyLine[slice]->GetCellType() , 
129                                                                                                                                 _lst3DContoursVtkPolyLine[slice]->GetPointIds() );
130         _lst3DContoursVtkUnstructuredGrid[slice]->SetPoints( contour3D );
131         _lst3DContoursVtkDataSetMapper[slice] = vtkDataSetMapper::New();
132         _lst3DContoursVtkDataSetMapper[slice]->SetInput(_lst3DContoursVtkUnstructuredGrid[slice]);
133         _lst3DContoursVtkDataSetMapper[slice]->ImmediateModeRenderingOn();
134         _lst3DContoursVtkActor[slice]=vtkActor::New();
135         _lst3DContoursVtkActor[slice]->SetMapper(_lst3DContoursVtkDataSetMapper[slice]);
136         _lst3DContoursVtkActor[slice]->GetProperty()->BackfaceCullingOn();
137         _lst3DContoursVtkActor[slice]->GetProperty()->SetDiffuseColor(_r,_g,_b);
138         _lst3DContoursVtkActor[slice]->PickableOff( );
139         // add new actor
140         vtkRenderer *pRenderer                  = _vtk3DQuantSurfaceWidget->QuantSurfaceWidget_GetRenderer();
141         vtkRenderWindow* pRenderWindow  = _vtk3DQuantSurfaceWidget->QuantSurfaceWidget_GetRenderWindow();
142
143         if (showActor==true){ 
144                 pRenderer->AddActor( _lst3DContoursVtkActor[slice] );
145         }
146         // Refresh 3DWidget
147         pRenderWindow->Render( );
148
149
150 }
151 //----------------------------------------------------------------------------
152 void listContourVTK::Show3DContourActor( ){
153         vtkRenderer *pRenderer                  = _vtk3DQuantSurfaceWidget->QuantSurfaceWidget_GetRenderer();
154         vtkRenderWindow* pRenderWindow  = _vtk3DQuantSurfaceWidget->QuantSurfaceWidget_GetRenderWindow();
155         int i;
156         for (i=0;i<_lst3DContoursVtkActor.size();i++){
157                 if (_lst3DContoursVtkActor[i]!=NULL) pRenderer->AddActor( _lst3DContoursVtkActor[i] );  
158          }
159         // Refresh 3DWidget
160         pRenderWindow->Render( );
161 }
162 //----------------------------------------------------------------------------
163 void listContourVTK::Hide3DContourActor( ){
164         vtkRenderer *pRenderer                  = _vtk3DQuantSurfaceWidget->QuantSurfaceWidget_GetRenderer();
165         vtkRenderWindow* pRenderWindow  = _vtk3DQuantSurfaceWidget->QuantSurfaceWidget_GetRenderWindow();
166         int i;
167         for (i=0;i<_lst3DContoursVtkActor.size();i++){
168                 if (_lst3DContoursVtkActor[i]!=NULL) pRenderer->RemoveActor( _lst3DContoursVtkActor[i] );       
169          }
170         // Refresh 3DWidget
171         pRenderWindow->Render( );
172 }
173
174
175 //----------------------------------------------------------------------------
176 //----------------------------------------------------------------------------
177 //----------------------------------------------------------------------------
178
179
180
181
182
183 /**
184  * Again wxVTK is an hybrid class, double click was done using wxWindows, simply
185  * because VTK doesn't provide such facility (as opposed to wheel support that is
186  * supposed to be merged in VTK trunk sooner or later:
187  *
188  * http://public.kitware.com/pipermail/vtkusers/2003-August/019548.html
189  * http://www.creatis.insa-lyon.fr/~malaterre/vtk/wheel.patch
190  */
191
192 //----------------------------------------------------------------------------
193 /*
194 BEGIN_EVENT_TABLE( vtk3DQuantSurfaceWidget, vtk3DSurfaceWidget )
195   //  EVT_LEFT_DCLICK( vtk3DQuantSurfaceWidget::OnLeftDClick )
196   // EVT_MOUSEWHEEL( vtk3DQuantSurfaceWidget::OnMouseWheel )
197 END_EVENT_TABLE( );
198 */
199 //----------------------------------------------------------------------------
200 vtk3DQuantSurfaceWidget::vtk3DQuantSurfaceWidget(
201         wxWindow* parent,
202         wxWindowID id,
203         const wxPoint& pos,
204         const wxSize& size,
205         long style,
206         const wxString& name)
207         : vtk3DSurfaceWidget( parent, id, pos, size, style, name ){
208   _3DSliceMapper                = NULL;
209   _3DSliceActor                 = NULL;
210   _bwlookup                             = NULL;
211   _collookup                    = NULL;
212   _hs_rectGuide                 = new RectangleGuideVtk();
213   _s1_rectGuide                 = new RectangleGuideVtk();
214   _s2_rectGuide                 = new RectangleGuideVtk();
215   _sA_rectGuide                 = new RectangleGuideVtk();
216   _sB_rectGuide                 = new RectangleGuideVtk();
217
218   _lstContVtk                   = new listContourVTK(this);
219   _lstContHealtyVtk             = new listContourVTK(this);
220   _lstContVtk->SetColour(1,1,0);
221   _lstContHealtyVtk->SetColour(0,0,1);
222
223 }
224
225 vtk3DQuantSurfaceWidget::~vtk3DQuantSurfaceWidget()
226 {
227   if( _3DSliceActor )   _3DSliceActor   ->Delete();
228   if( _3DSliceMapper)   _3DSliceMapper  ->Delete();
229   if( _bwlookup         )       _bwlookup               ->Delete();
230   if( _collookup        )       _collookup              ->Delete();
231
232   delete _hs_rectGuide;
233   delete _s1_rectGuide;
234   delete _s2_rectGuide;
235   delete _sA_rectGuide;
236   delete _sB_rectGuide;
237
238   delete _lstContVtk;
239   delete _lstContHealtyVtk;
240 }
241
242
243 //----------------------------------------------------------------------------
244 void vtk3DQuantSurfaceWidget::ShowMARACASDataAndAxe( marInterface* mar )
245 {
246   marAxis                       *temp;
247   vtkPolyData           *allData;
248   int nos;
249   vtkProbeFilter        *pFilter;
250
251   this->ShowMARACASData( mar );
252   this->ConfigureVTK();
253
254   _pRenderer->SetBackground( 0.35, 0.35, 0.35 );
255
256   // Axis
257   _mar->_experiment->setAxis( 0 );
258   temp          = _mar->_experiment->getAxis( );  // ??? getActualAxis ??
259   allData       = temp->Draw( );
260
261   nos           = _mar->_experiment->getNumberOfSlices( );
262   pFilter       = _mar->_experiment->get3DSlice( (int) (nos-1)/2 );
263
264   _bwlookup = vtkWindowLevelLookupTable::New( );
265   _bwlookup->SetHueRange( 0 , 1 );
266   _bwlookup->SetNumberOfColors( (int)(_range[1] - _range[0] + 1) );
267   _bwlookup->SetTableRange( _range[0] , _range[1] );
268   _bwlookup->SetSaturationRange( 0 , 0 );
269   _bwlookup->SetValueRange( 0 , 1 );
270   _bwlookup->SetAlphaRange( 1 , 1 );
271   _bwlookup->Build( );
272
273   _collookup = vtkLookupTable::New( );
274   _collookup->SetNumberOfColors( 256 );
275   _collookup->SetTableRange( 0 , 255 );
276   _collookup->Build( );
277   _collookup->SetTableValue( 0  , 1 , 0 , 0 , 1 );
278   _collookup->SetTableValue(128 , 0 , 0 , 1 , 1 );
279   _collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
280
281   _3DSliceMapper = vtkDataSetMapper::New( );
282   _3DSliceMapper->SetInput(pFilter->GetOutput( ) );
283   _3DSliceMapper->SetLookupTable( _bwlookup );
284   _3DSliceMapper->SetScalarRange( _range );
285   _3DSliceMapper->ImmediateModeRenderingOn( );
286
287   _3DSliceActor = vtkActor::New( );
288   _3DSliceActor->SetMapper( _3DSliceMapper );
289   _pRenderer->AddActor( _3DSliceActor);
290
291   _lstContVtk->InitListContourActor(nos);
292   _lstContHealtyVtk->InitListContourActor(nos);
293   
294   this->SetAxis( allData );
295 }
296
297 //----------------------------------------------------------------------------
298
299 //----------------------------------------------------------------------------
300 void vtk3DQuantSurfaceWidget::ShowMARACASDataAndAxeCT( marInterfaceCT* mar )
301 {
302   marAxis                       *temp;
303   vtkPolyData           *allData;
304   int nos;
305   vtkProbeFilter        *pFilter;
306
307   this->ShowMARACASDataCT( mar );
308   this->ConfigureVTK();
309
310   _pRenderer->SetBackground( 0.75, 0.75, 0.75 );
311
312   // Axis
313   _marCT->setAxis( 0 );
314   temp          = _marCT->getAxis( );  // ??? getActualAxis ??
315   allData       = temp->Draw( );
316
317   nos           = _marCT->getNumberOfSlices( );
318   pFilter       = _marCT->get3DSlice( (int) (nos-1)/2 );
319
320   _bwlookup = vtkWindowLevelLookupTable::New( );
321   _bwlookup->SetHueRange( 0 , 1 );
322   _bwlookup->SetNumberOfColors( (int)(_range[1] - _range[0] + 1) );
323   _bwlookup->SetTableRange( _range[0] , _range[1] );
324   _bwlookup->SetSaturationRange( 0 , 0 );
325   _bwlookup->SetValueRange( 0 , 1 );
326   _bwlookup->SetAlphaRange( 1 , 1 );
327   _bwlookup->Build( );
328
329   _collookup = vtkLookupTable::New( );
330   _collookup->SetNumberOfColors( 256 );
331   _collookup->SetTableRange( 0 , 255 );
332   _collookup->Build( );
333   _collookup->SetTableValue( 0  , 1 , 0 , 0 , 1 );
334   _collookup->SetTableValue(128 , 0 , 0 , 1 , 1 );
335   _collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
336
337   _3DSliceMapper = vtkDataSetMapper::New( );
338   _3DSliceMapper->SetInput(pFilter->GetOutput( ) );
339   _3DSliceMapper->SetLookupTable( _bwlookup );
340   _3DSliceMapper->SetScalarRange( _range );
341   _3DSliceMapper->ImmediateModeRenderingOn( );
342
343   _3DSliceActor = vtkActor::New( );
344   _3DSliceActor->SetMapper( _3DSliceMapper );
345   _pRenderer->AddActor( _3DSliceActor);
346
347   _lstContVtk->InitListContourActor(nos);
348   _lstContHealtyVtk->InitListContourActor(nos);
349   
350   this->SetAxis( allData );
351 }
352
353 //----------------------------------------------------------------------------
354
355 void vtk3DQuantSurfaceWidget::SetBWLookUp(){
356   _3DSliceMapper->SetLookupTable( _bwlookup );
357   _pRenderWindow->Render( );
358 }    
359 //----------------------------------------------------------------------------
360 void vtk3DQuantSurfaceWidget::SetColorLookUp(){
361   _3DSliceMapper->SetLookupTable( _collookup );
362   _pRenderWindow->Render( );
363 }
364 //----------------------------------------------------------------------------
365 void vtk3DQuantSurfaceWidget::SetImage( vtkProbeFilter* pFilter )
366 {
367   _3DSliceMapper->SetInput(pFilter->GetOutput( ) );
368 }
369 //----------------------------------------------------------------------------
370 void vtk3DQuantSurfaceWidget::Show3DSliceActor( )
371 {
372   _pRenderer->AddActor( _3DSliceActor );
373   _pRenderWindow->Render( );
374 }
375 //----------------------------------------------------------------------------
376 void vtk3DQuantSurfaceWidget::Hide3DSliceActor( )
377 {
378   _pRenderer->RemoveActor( _3DSliceActor );
379   _pRenderWindow->Render( );
380 }
381 //----------------------------------------------------------------------------
382 void vtk3DQuantSurfaceWidget::InitListContourActor(int type, int nos){
383         if ((type==0) || (type==-1)){ _lstContVtk->InitListContourActor(nos); }
384         if ((type==1) || (type==-1)){ _lstContHealtyVtk->InitListContourActor(nos); }
385 }
386 //----------------------------------------------------------------------------
387 void vtk3DQuantSurfaceWidget::Show3DContourActor( int type ){
388         if (type==0){ _lstContVtk->Show3DContourActor(); }
389         if (type==1){ _lstContHealtyVtk->Show3DContourActor(); }
390 }
391 //----------------------------------------------------------------------------
392 void vtk3DQuantSurfaceWidget::Hide3DContourActor( int type ){
393         if (type==0){ _lstContVtk->Hide3DContourActor(); }
394         if (type==1){ _lstContHealtyVtk->Hide3DContourActor(); }
395 }
396 //----------------------------------------------------------------------------
397 void vtk3DQuantSurfaceWidget::Set3DContourActor( int slice, vtkPoints* contour3D, bool showActor , int type){
398         if (type==0) { _lstContVtk->Set3DContourActor(slice,contour3D,showActor);       }
399         if (type==1) { _lstContHealtyVtk->Set3DContourActor(slice,contour3D,showActor); }
400 }
401 //----------------------------------------------------------------------------
402 void vtk3DQuantSurfaceWidget::Erase3DContourActor( int slice){
403         _lstContVtk->EraseSliceContourActor(slice);
404 }
405 //----------------------------------------------------------------------------
406 void vtk3DQuantSurfaceWidget::Show3DHealthySliceActor( )
407 {
408   _pRenderer->AddActor( _hs_rectGuide->_actor );
409   _pRenderWindow->Render( );
410 }
411 //----------------------------------------------------------------------------
412 void vtk3DQuantSurfaceWidget::Hide3DHealthySliceActor( )
413 {
414   _pRenderer->RemoveActor( _hs_rectGuide->_actor );
415   _pRenderWindow->Render( );
416 }
417 //----------------------------------------------------------------------------
418 void vtk3DQuantSurfaceWidget::Set3DSliceActor( RectangleGuideVtk *_rectGuide ,float scale, int k,int r,int g,int b){
419         int             sizeIma;
420         double  dimIma;
421         double  *o;  // Origen
422         double  *c;  // Center
423         double  *n;  // Normal
424
425         double  ori[3];
426         double  p1[3];
427         double  p2[3];
428
429         sizeIma = _mar->_experiment->getAxis( )->getParameters( )->getSizeIma( );
430         dimIma  = _mar->_experiment->getAxis( )->getParameters( )->getDimIma( );
431     o           = _mar->_experiment->getAxis( )->getSplinePoint(k);  
432     c           = _mar->_experiment->getAxis( )->getSplinePoint(k);  
433     n           = _mar->_experiment->getAxis( )->getNormal(k);  
434
435     vtkPlaneSource* pSource = vtkPlaneSource::New( );
436     pSource->SetOrigin( o[0]                            , o[1], o[2]                            );
437     pSource->SetPoint1( o[0]+dimIma*scale - 1.0 , o[1], o[2]                            );
438     pSource->SetPoint2( o[0]                            , o[1], o[2]+dimIma*scale - 1.0 );
439     pSource->SetResolution( sizeIma - 1 , sizeIma - 1   );
440     pSource->Update( );
441     pSource->SetCenter( c[ 0 ], c[ 1 ], c[ 2 ] );
442     pSource->SetNormal( n[ 0 ], n[ 1 ], n[ 2 ] );
443     pSource->Update( );
444         pSource->GetOrigin( ori );
445     pSource->GetPoint1( p1      );
446     pSource->GetPoint2( p2      );
447
448         if (_rectGuide->_actor)         _pRenderer->RemoveActor(_rectGuide->_actor);
449         if (_rectGuide->_grid)          _rectGuide->_grid->Delete();
450         if (_rectGuide->_actor)         _rectGuide->_actor->Delete();
451         if (_rectGuide->_points)        _rectGuide->_points->Delete();
452         if (_rectGuide->_mapper)        _rectGuide->_mapper->Delete();
453         if (_rectGuide->_poly_line)     _rectGuide->_poly_line->Delete();
454
455         _rectGuide->_poly_line = vtkPolyLine::New();
456         ( _rectGuide->_poly_line->GetPointIds() )->SetNumberOfIds(8);
457         ( _rectGuide->_poly_line->GetPointIds() )->SetId(0,0);
458         ( _rectGuide->_poly_line->GetPointIds() )->SetId(1,1);
459         ( _rectGuide->_poly_line->GetPointIds() )->SetId(2,2);
460         ( _rectGuide->_poly_line->GetPointIds() )->SetId(3,3);
461         ( _rectGuide->_poly_line->GetPointIds() )->SetId(4,4);
462         ( _rectGuide->_poly_line->GetPointIds() )->SetId(5,5);
463         ( _rectGuide->_poly_line->GetPointIds() )->SetId(6,6);
464         ( _rectGuide->_poly_line->GetPointIds() )->SetId(7,7);
465
466         _rectGuide->_points=vtkPoints::New();
467         _rectGuide->_points->InsertNextPoint( ori[0]                    , ori[1]                                        , ori[2]                        );
468         _rectGuide->_points->InsertNextPoint( p1[0]                             , p1[1]                                         , p1[2]                         );
469         _rectGuide->_points->InsertNextPoint( p2[0]+p1[0]-ori[0], p2[1]+p1[1]-ori[1]            , p2[2]+p1[2]-ori[2]);
470         _rectGuide->_points->InsertNextPoint( p2[0]                             , p2[1]                                         , p2[2]                         );
471         _rectGuide->_points->InsertNextPoint( ori[0]                    , ori[1]                                        , ori[2]                        );
472         _rectGuide->_points->InsertNextPoint( p2[0]+p1[0]-ori[0], p2[1]+p1[1]-ori[1]            , p2[2]+p1[2]-ori[2]);
473         _rectGuide->_points->InsertNextPoint( p1[0]                             , p1[1]                                         , p1[2]                         );
474         _rectGuide->_points->InsertNextPoint( p2[0]                             , p2[1]                                         , p2[2]                         );
475
476         _rectGuide->_grid=vtkUnstructuredGrid::New();
477         _rectGuide->_grid->Allocate(1,1);
478         _rectGuide->_grid->InsertNextCell( _rectGuide->_poly_line->GetCellType() , _rectGuide->_poly_line->GetPointIds() );
479         _rectGuide->_grid->SetPoints( _rectGuide->_points );
480
481         _rectGuide->_mapper = vtkDataSetMapper::New();
482         _rectGuide->_mapper->SetInput(_rectGuide->_grid);
483         _rectGuide->_mapper->ImmediateModeRenderingOn();
484
485         _rectGuide->_actor=vtkActor::New();
486         _rectGuide->_actor->SetMapper(_rectGuide->_mapper);
487         _rectGuide->_actor->GetProperty()->BackfaceCullingOn();
488         _rectGuide->_actor->GetProperty()->SetDiffuseColor(r,g,b);
489         _rectGuide->_actor->PickableOff( );
490         _rectGuide->_iSlice = k;
491 }
492 //----------------------------------------------------------------------------
493 void vtk3DQuantSurfaceWidget::Set3DHealthySliceActor(  ){
494         int k = _mar->_experiment->getAxis( )->getHealthySlice();
495         Set3DSliceActor( _hs_rectGuide , 1.0 , k ,0,0,1);
496 }
497
498 //----------------------------------------------------------------------------
499 void vtk3DQuantSurfaceWidget::Set3DRegionSliceActor( int type , int k1, int k2 ){
500         Set3DStartRegionSliceActor(type, k1);
501         Set3DEndRegionSliceActor(type, k2);
502 }
503 //----------------------------------------------------------------------------
504 void vtk3DQuantSurfaceWidget::Set3DStartRegionSliceActor( int type , int k ){
505         if (type==0){
506                 Set3DSliceActor( _s1_rectGuide , 0.3 , k ,1,0,0);
507                 _mar->_experiment->getAxis()->setStartQuant(k);
508         }
509         if (type==1){
510                 Set3DSliceActor( _sA_rectGuide , 0.3 , k ,1,1,0);
511         }
512 }
513 //----------------------------------------------------------------------------
514 void vtk3DQuantSurfaceWidget::Set3DEndRegionSliceActor( int type , int k ){
515         if (type==0){
516                 Set3DSliceActor( _s2_rectGuide , 0.3 , k ,1,0,0);
517                 _mar->_experiment->getAxis()->setFinishQuant(k);
518         }
519         if (type==1){
520                 Set3DSliceActor( _sB_rectGuide , 0.3 , k ,1,1,0);
521         }
522 }
523 //----------------------------------------------------------------------------
524 void vtk3DQuantSurfaceWidget::Show3DRegionSliceActor( int type ){
525         Show3DStartRegionSliceActor(type);
526         Show3DEndRegionSliceActor(type);
527 }
528 //----------------------------------------------------------------------------
529 void vtk3DQuantSurfaceWidget::Show3DStartRegionSliceActor( int type ){
530         if ((type==0) && (_s1_rectGuide->_iSlice!=-1)){
531                 _pRenderer->AddActor( _s1_rectGuide->_actor );
532                 _s1_rectGuide->_showActor=true;
533         }
534         if ((type==1) && (_sA_rectGuide->_iSlice!=-1)){
535                 _pRenderer->AddActor( _sA_rectGuide->_actor );
536                 _sA_rectGuide->_showActor=true;
537         }
538   _pRenderWindow->Render( );
539 }
540 //----------------------------------------------------------------------------
541 void vtk3DQuantSurfaceWidget::Show3DEndRegionSliceActor( int type ){
542         if ((type==0) && (_s2_rectGuide->_iSlice!=-1)){
543                 _pRenderer->AddActor( _s2_rectGuide->_actor );
544                 _s2_rectGuide->_showActor=true;
545         }
546         if ((type==1) && (_sB_rectGuide->_iSlice!=-1)){
547                 _pRenderer->AddActor( _sB_rectGuide->_actor );
548                 _sB_rectGuide->_showActor=true;
549         }
550   _pRenderWindow->Render( );
551 }
552 //----------------------------------------------------------------------------
553 void vtk3DQuantSurfaceWidget::Hide3DRegionSliceActor( int type ){
554         Hide3DStartRegionSliceActor(type );
555         Hide3DEndRegionSliceActor(type );
556 }
557 //----------------------------------------------------------------------------
558 void vtk3DQuantSurfaceWidget::Hide3DStartRegionSliceActor( int type ){
559         if (type==0){
560                 if (_s1_rectGuide->_showActor==true){
561                         _pRenderer->RemoveActor( _s1_rectGuide->_actor );
562                         _s1_rectGuide->_showActor=false;
563                 }
564         }
565         if (type==1){
566                 if (_sA_rectGuide->_showActor==true){
567                         _pRenderer->RemoveActor( _sA_rectGuide->_actor );
568                         _sA_rectGuide->_showActor=false;
569                 }
570         }
571         _pRenderWindow->Render( );
572 }
573 //----------------------------------------------------------------------------
574 void vtk3DQuantSurfaceWidget::Hide3DEndRegionSliceActor( int type ){
575         if (type==0){
576                 if (_s2_rectGuide->_showActor==true){
577                         _pRenderer->RemoveActor( _s2_rectGuide->_actor );
578                         _s2_rectGuide->_showActor=false;
579                 }
580         }
581         if (type==1){
582                 if (_sB_rectGuide->_showActor==true){
583                         _pRenderer->RemoveActor( _sB_rectGuide->_actor );
584                         _sB_rectGuide->_showActor=false;
585                 }
586         }
587         _pRenderWindow->Render( );
588 }
589 //----------------------------------------------------------------------------
590 void vtk3DQuantSurfaceWidget::GetSliceLimites(int type, int &sliceStart,int &sliceEnd){
591         if (type==0){
592                 sliceStart      = _s1_rectGuide->_iSlice;
593                 sliceEnd        = _s2_rectGuide->_iSlice;
594         }
595         if (type==1){
596                 sliceStart      = _sA_rectGuide->_iSlice;
597                 sliceEnd        = _sB_rectGuide->_iSlice;
598         }
599 }
600 //--------------------------------------------------------------------
601 int vtk3DQuantSurfaceWidget::GetAnalysisTypeStenosis(){
602         return _analysisTypeStenosis;
603 }
604 //--------------------------------------------------------------------
605 void vtk3DQuantSurfaceWidget::SetAnalysisTypeStenosis(int analysisTypeStenosis){
606         _analysisTypeStenosis=analysisTypeStenosis;
607 }
608
609
610