]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxPanelCuttingImageData.cxx
e3b24b20c8effcaa9fd864cb007fe964f317ca58
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxPanelCuttingImageData.cxx
1
2 #include "wxPanelCuttingImageData.h"
3
4 //-------------------------------------------------------------------
5
6 #include <vtkProperty.h>
7 #include <vtkTextProperty.h>
8 #include <vtkProperty2D.h>
9 //-------------------------------------------------------------------
10 //-------------------------------------------------------------------
11
12 wxPanelCuttingImageData::wxPanelCuttingImageData (wxWindow *parent)
13 : wxPanel( parent, -1)
14 {
15         _imageData=NULL;
16         _histogrammeVector=NULL;
17         _wxvtk3Dbaseview=NULL;
18         _wxvtkbaseView=NULL;
19         CreateInterface();
20         CreateModel();
21         Create3DViewObjects();
22 }
23
24 //-------------------------------------------------------------------
25 wxPanelCuttingImageData::~wxPanelCuttingImageData()
26 {
27
28
29         delete _modelCube;      
30         delete _modelSphere;    
31         delete _modelCylinder;  
32         _vtkcube                -> Delete();    
33         _vtksphere              -> Delete();    
34         _vtkcylinder    -> Delete();    
35         _cubeMapper             -> Delete();    
36         _sphereMapper   -> Delete();    
37         _cylinderMapper -> Delete();    
38         _cubeActor              -> Delete();    
39         _sphereActor    -> Delete();    
40         _cylinderActor  -> Delete();    
41 //      _xyplot->RemoveAllInputs();     
42         _xyplot                 -> Delete();    
43         _histogrammeVector->Delete();   
44         _renplotter->Delete();
45         
46         if(_wxvtkbaseView!=NULL){
47                 delete _wxvtkbaseView;
48         }
49         //delete _vtkclipping3Ddataviewer;
50         
51
52         //fclose(file);
53
54 }
55
56 //-------------------------------------------------------------------
57 void wxPanelCuttingImageData::RemoveActors()
58 {
59         _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
60 }
61
62
63 //-------------------------------------------------------------------
64 void wxPanelCuttingImageData::SetWxVtk3DBaseView( wxVtk3DBaseView * wxvtk3Dbaseview )
65 {
66         _wxvtk3Dbaseview=wxvtk3Dbaseview;
67 }
68
69 //-------------------------------------------------------------------
70
71 void wxPanelCuttingImageData::SetVtkClipping3DDataViewer( vtkClipping3DDataViewer *vtkclipping3Ddataviewer )
72 {
73         this->_vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
74 }
75
76 //-------------------------------------------------------------------
77 void wxPanelCuttingImageData::Create3DViewObjects()
78 {
79         // Sphere
80         _vtksphere              = vtkSphereSource::New();
81         _vtksphere->SetThetaResolution (20);
82         _vtksphere->SetPhiResolution (20);
83         _sphereMapper   = vtkPolyDataMapper::New();
84         _sphereMapper->SetInput( _vtksphere->GetOutput() );
85         _sphereActor    = vtkActor::New();
86         _sphereActor->SetMapper(_sphereMapper);
87         _sphereActor->SetOrigin(0, 0, 0);
88         _sphereActor->SetPosition(0, 0, 0);
89         _sphereActor->GetProperty()->SetColor(1, 0, 0);
90         _sphereActor->SetUserTransform( _modelSphere->GetVtkTransform() );      
91
92         // cube
93         _vtkcube                = vtkCubeSource::New();
94         _vtkcube->SetXLength (1);
95         _vtkcube->SetYLength (1);
96         _vtkcube->SetZLength (1);
97         _cubeMapper             = vtkPolyDataMapper::New();
98         _cubeMapper->SetInput( _vtkcube->GetOutput() );
99         _cubeActor              = vtkActor::New();
100         _cubeActor->SetMapper(_cubeMapper);
101         _cubeActor->SetOrigin(0, 0, 0);
102         _cubeActor->SetPosition(0, 0, 0);
103         _cubeActor->GetProperty()->SetColor(1, 0, 0);
104         _cubeActor->SetUserTransform( _modelCube->GetVtkTransform() );          
105
106         // cylinder
107         _vtkcylinder    = vtkCylinderSource::New();
108         _vtkcylinder->SetResolution(20);
109         _cylinderMapper = vtkPolyDataMapper::New();
110         _cylinderMapper->SetInput( _vtkcylinder->GetOutput() );
111         _cylinderActor  = vtkActor::New();
112         _cylinderActor->SetMapper(_cylinderMapper);
113         _cylinderActor->SetOrigin(0, 0, 0);
114         _cylinderActor->SetPosition(0, 0, 0);
115         _cylinderActor->GetProperty()->SetColor(1, 0, 0);
116         _cylinderActor->SetUserTransform( _modelCylinder->GetVtkTransform() );          
117
118
119 }
120
121 //-------------------------------------------------------------------
122 void wxPanelCuttingImageData::CreateModel()
123 {
124         _modelCube              = new figureCuttingCubeModel();
125         _modelSphere    = new figureCuttingSphereModel();
126         _modelCylinder  = new figureCuttingCylinderModel();
127
128 //      _modelCube->SetVtkTransform( _modelCube->GetVtkTransform()                      );
129 //      _modelSphere->SetVtkTransform( _modelSphere->GetVtkTransform()          );
130 //      _modelCylinder->SetVtkTransform( _modelCylinder->GetVtkTransform()      );
131 }
132
133 //-------------------------------------------------------------------
134
135 void wxPanelCuttingImageData::InitHistogramme()
136 {
137         double rangeA[2];
138         if (_imageData==NULL)
139         {
140                 rangeA[1]=1;
141         } else {
142                 _imageData->GetScalarRange(rangeA);
143         }
144         _xyplot->RemoveAllInputs();
145 /*
146         if ( _histogrammeVector!=NULL )
147         {
148                 _histogrammeVector -> Delete();
149         }
150 */
151         _histogrammeVector =  vtkImageData::New();
152     _histogrammeVector -> SetDimensions ( (int)(rangeA[1]),1,1 );
153     _histogrammeVector -> SetScalarTypeToUnsignedShort();
154     _histogrammeVector -> AllocateScalars();    
155     _histogrammeVector -> Update(); 
156         
157         unsigned short *p_vol = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
158         int i,size = (int) (rangeA[1]);
159         for (i=0; i < size; i++)
160         {
161                 *p_vol=0;
162                 p_vol++;
163         }
164         _xyplot->SetXRange(0, rangeA[1]);
165         _xyplot->SetYRange(0, 10);
166         _xyplot->AddInput( _histogrammeVector );
167 }
168
169 //-------------------------------------------------------------------
170 wxWindow *wxPanelCuttingImageData::CreatePlotHistogrammeInterface()
171 {
172         _xyplot = vtkXYPlotActor::New();
173         InitHistogramme();
174         _xyplot->GetPositionCoordinate()->SetValue(0.00, 0.00, 0);
175         _xyplot->GetPosition2Coordinate()->SetValue(1.0, 1.00, 0); //relative to Position
176         _xyplot->SetXValuesToArcLength();
177         _xyplot->SetNumberOfXLabels(6);
178
179         _xyplot->SetTitle("Histogramme");
180         _xyplot->SetXTitle("Gray level");
181         _xyplot->SetYTitle("Occurrences ");
182         _xyplot->GetProperty()->SetColor(1, 0, 0);
183         _xyplot->GetProperty()->SetPointSize(2);
184         vtkTextProperty *tprop = _xyplot->GetTitleTextProperty();
185         tprop->SetColor( 1,0,1 );
186         tprop->BoldOff ();
187         _xyplot->SetAxisTitleTextProperty(tprop);
188         _xyplot->SetAxisLabelTextProperty(tprop);
189         _xyplot->PlotPointsOn();
190         _xyplot->GetProperty()->SetPointSize(3);
191
192         _wxvtkbaseView = new wxVtkBaseView(this);
193         _wxvtkbaseView->Configure();
194
195         _renplotter = vtkRenderer::New();
196         vtkRenderWindow *renWin = _wxvtkbaseView->GetRenWin();
197         renWin->AddRenderer( _renplotter );
198         _renplotter->AddActor2D( _xyplot );
199
200         return _wxvtkbaseView->GetWxVTKRenderWindowInteractor();
201 }
202
203 //-------------------------------------------------------------------
204
205 void wxPanelCuttingImageData::CreateInterface()
206 {
207         SetSize(300,500);
208         wxBoxSizer      *topsizer               = new wxBoxSizer(wxVERTICAL);   // Principal sizer
209
210         wxBoxSizer              *sizerH0        = new wxBoxSizer(wxHORIZONTAL   );  // type of segmentation figure
211         wxBoxSizer          *sizerH2    = new wxBoxSizer(wxHORIZONTAL   );      // scale
212         wxBoxSizer              *sizerH3        = new wxBoxSizer(wxHORIZONTAL   );      // rotation
213         wxBoxSizer              *sizerH4        = new wxBoxSizer(wxHORIZONTAL   );  // intern extern
214         wxBoxSizer              *sizerH5        = new wxBoxSizer(wxHORIZONTAL   );  // Isovalue
215         wxBoxSizer              *sizerH6        = new wxBoxSizer(wxHORIZONTAL   );  // Buttons
216         wxFlexGridSizer *sizerH7        = new wxFlexGridSizer(2                 );  // Volumic information 
217
218         
219         _typeFig        = new wxChoice(this,-1);
220         _opacityFig     = new wxSlider(this,-1,100,0,100, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
221
222         _scaleX         = new wxSlider(this,-1,6,0,500  , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
223         _scaleY         = new wxSlider(this,-1,20,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
224         _scaleZ         = new wxSlider(this,-1,7,0,500  , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
225
226         _rotationX      = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
227         _rotationY      = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
228         _rotationZ      = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
229
230         _volIntern              = new wxRadioButton(this,-1, _T("Volume intern " ));
231         _volExtern              = new wxRadioButton(this,-1, _T("Volume extern " ));
232
233         _histogrammeAccumulated = new wxCheckBox(this,-1,_T("Histogramme accumulated"));
234
235         _isoValue                               = new wxSlider(this,-1, 200, 0,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
236         _valueBeforeIsoValue    = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
237         _valueAfterIsoValue             = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
238
239         wxButton *btnExtract    = new wxButton(this, -1,_T("Extract"));
240
241         _infoToVo       = new wxStaticText(this,-1,_T("########################"));
242         _infoSuVoA      = new wxStaticText(this,-1,_T("############"));
243         _infoSuVo       = new wxStaticText(this,-1,_T("############"));
244         _infoPixLe      = new wxStaticText(this,-1,_T("############"));
245         _infoPixHi      = new wxStaticText(this,-1,_T("############"));
246
247
248         
249
250         _typeFig->Append(_T("Cylindre"));
251         _typeFig->Append(_T("Cube"));
252         _typeFig->Append(_T("Sphere"));
253         _typeFig->SetSelection(0);
254         _volIntern->SetValue(true);
255
256         Connect(_typeFig->GetId()                               , wxEVT_COMMAND_CHOICE_SELECTED         , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTypeFig ); 
257
258         Connect(_opacityFig->GetId()                    , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnOpacityFig ); 
259         Connect(_rotationX->GetId()                             , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
260         Connect(_rotationY->GetId()                             , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
261         Connect(_rotationZ->GetId()                             , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
262         Connect(_scaleX->GetId()                                , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
263         Connect(_scaleY->GetId()                                , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
264         Connect(_scaleZ->GetId()                                , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
265         Connect(btnExtract->GetId()                             , wxEVT_COMMAND_BUTTON_CLICKED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnExtract   ); 
266          
267
268 //      wxStaticText *text=new wxStaticText(this,-1, " ");
269
270         sizerH0 -> Add( new wxStaticText(this,-1, _T("Fig. Type:   "),wxDefaultPosition, wxSize(50,20)) ,1,wxALL  ,0);
271         sizerH0 -> Add( _typeFig                ,1,wxALL  ,0);
272         sizerH0 -> Add( _opacityFig             ,1,wxALL|wxEXPAND  ,0);
273
274         sizerH2 -> Add( new wxStaticText(this,-1,_T("Scale :   "))              ,1,wxALL  ,0);
275         sizerH2 -> Add( _scaleX         ,1,wxALL | wxEXPAND ,0 );
276         sizerH2 -> Add( _scaleY         ,1,wxALL | wxEXPAND ,0 );
277         sizerH2 -> Add( _scaleZ         ,1,wxALL | wxEXPAND ,0 );
278
279         sizerH3 -> Add( new wxStaticText(this,-1,_T("Rotation :   "))   ,1,wxALL  ,0);
280         sizerH3 -> Add( _rotationX      ,1,wxALL | wxEXPAND ,0 );
281         sizerH3 -> Add( _rotationY      ,1,wxALL | wxEXPAND ,0 );
282         sizerH3 -> Add( _rotationZ      ,1,wxALL | wxEXPAND ,0 );
283
284
285         sizerH4 -> Add( new wxStaticText(this,-1,_T("Intern / Extern :   "))    ,1,wxALL  ,0);
286         sizerH4 -> Add( _volIntern                                              ,1,wxALL  ,0);
287         sizerH4 -> Add( new wxStaticText(this,-1, _T(" "))      ,1,wxALL  ,0);
288         sizerH4 -> Add( _volExtern                                              ,1,wxALL  ,0);
289
290         sizerH5 -> Add( new wxStaticText(this,-1,_T("Isovalue   "))     ,1,wxALL  ,0);
291         sizerH5 -> Add( _isoValue                                               ,1,wxALL | wxEXPAND ,0 );
292         sizerH5 -> Add( _valueBeforeIsoValue                    ,1,wxALL | wxEXPAND ,0 );
293         sizerH5 -> Add( _valueAfterIsoValue                             ,1,wxALL | wxEXPAND ,0 );
294
295         sizerH6 -> Add( new wxStaticText(this,-1, _T(" "))              ,1,wxALL  ,0);
296         sizerH6 -> Add( btnExtract      ,1,wxALL  ,0);
297
298         sizerH7 -> Add( new wxStaticText(this,-1,_T("Total Volume: "), wxDefaultPosition, wxSize(200,12))                       , 1 , wxALL  ,0);
299         sizerH7 -> Add( _infoToVo                                                                               , 1 , wxALL  ,0);
300         sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume:   "), wxDefaultPosition, wxSize(200,12) )               , 1 , wxALL  ,0);
301         sizerH7 -> Add( _infoSuVo                                                                               , 1 , wxALL  ,0);
302         sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume (ana.): "), wxDefaultPosition, wxSize(200,12))   , 1 , wxALL  ,0);
303         sizerH7 -> Add( _infoSuVoA                                                                              , 1 , wxALL  ,0);
304         sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix < isovalue:   ") , wxDefaultPosition, wxSize(200,12))  , 1 , wxALL  ,0);
305         sizerH7 -> Add( _infoPixLe                                                                              , 1 , wxALL  ,0);
306         sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix > isovalue: "), wxDefaultPosition, wxSize(200,12))     , 1 , wxALL  ,0);
307         sizerH7 -> Add( _infoPixHi                                                                              , 1 , wxALL  ,0);
308 //      sizerH7 -> SetMinSize(300, 120);
309
310         // Figure type
311         topsizer -> Add( sizerH0 ,1,wxALL|wxEXPAND  ,0);
312
313         // Scale
314         topsizer -> Add( sizerH2 ,1,wxALL|wxEXPAND  ,0);
315
316         // Rotation
317         topsizer -> Add( sizerH3 ,1,wxALL|wxEXPAND  ,0);
318
319         // Intern / Extern
320         topsizer -> Add( sizerH4 ,1,wxALL  ,0);
321
322
323         // Isovalue limite
324         topsizer -> Add( sizerH5 ,1,wxALL |wxEXPAND ,0);
325
326         // btn Extraction
327         topsizer -> Add( sizerH6        , 1 , wxALL  ,0);
328
329         // Histograme
330         topsizer -> Add( _histogrammeAccumulated ,1,  wxALL  ,0);
331
332         // Volumic information
333         topsizer -> Add( sizerH7                                , 1 , wxALL|wxEXPAND   ,0);
334
335
336
337 //    wxBoxSizer *sizerHor = new wxBoxSizer(wxHORIZONTAL);
338     wxBoxSizer *sizerHor = new wxBoxSizer(wxVERTICAL);
339         sizerHor -> Add( topsizer                               , 1 , wxALL | wxEXPAND  ,0);
340
341
342         wxWindow *panelPlotHistogramme = CreatePlotHistogrammeInterface();
343         sizerHor -> Add( panelPlotHistogramme   , 1 , wxGROW  ,0);
344
345
346         this->SetAutoLayout(true);
347         this->SetSizer( sizerHor );      
348         this->Layout(); 
349 //EEDxx2.4
350 //      this->FitInside();
351 }
352
353 //-------------------------------------------------------------------
354
355 void wxPanelCuttingImageData::OnExtract(wxCommandEvent& event)
356 {
357         wxBusyCursor wait;
358
359         bool                    inside;
360         bool                    volInt, volExt;
361         int                             xx,yy,zz;
362         unsigned short  *pOrg;
363         unsigned short  *p_histogramme;
364         int                             dim[3];
365         double                  spc[3];
366         long int                contAfter = 0;
367         long int                contBefor = 0;
368
369         double min=999999999;
370         double max=-999999999;
371
372         volExt=_volExtern->GetValue();
373         volInt=_volIntern->GetValue();
374         int isoValue                = _isoValue->GetValue();
375         int valueBeforeIsoValue = _valueBeforeIsoValue->GetValue(); 
376         int valueAfterIsoValue  = _valueAfterIsoValue ->GetValue(); 
377
378         InitHistogramme();
379         p_histogramme = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
380
381         _imageData->GetDimensions(dim);    
382         _imageData->GetSpacing(spc);    
383         _actualCuttingModel->CalculeInversMatrix();
384
385         for (xx=0;xx<dim[0]; xx++)
386         {
387                 for (yy=0;yy<dim[1]; yy++)
388                 {
389                         for (zz=0;zz<dim[2];zz++)
390                         {
391                                 inside=_actualCuttingModel->IfPointInside(xx,yy,zz);
392                                 if (  ((inside==true)&&(volInt==true)) || ((!inside==true)&&(volExt==true)) )
393                                 {
394                                         pOrg=(unsigned short*)_imageData->GetScalarPointer (xx,yy,zz); 
395
396                                         if ((*pOrg)<isoValue)
397                                         {
398                                                 contBefor++;
399                                                 if (valueBeforeIsoValue!=-1)
400                                                 {
401                                                         *pOrg=valueBeforeIsoValue;
402                                                 }
403                                         } else {
404                                                 contAfter++;
405                                                 if (valueAfterIsoValue!=-1)
406                                                 {
407                                                         *pOrg=valueAfterIsoValue;
408                                                 } // if
409                                         } // if isovalue
410
411                                         p_histogramme[*pOrg]++;
412                                         if (*pOrg<min) min=*pOrg; 
413                                         if (*pOrg>max) max=*pOrg; 
414                                 } // if inside
415                         } // for zz
416                 } // for yy
417         } // for xx
418
419
420         // Information
421         wxString infoToVo;
422         wxString infoSuVo;
423         wxString infoSuVoA;
424         wxString infoPixLe;
425         wxString infoPixHi;
426
427         double volumeUnit = spc[0]*spc[1]*spc[2];
428         long int totalSubVolume = contBefor + contAfter;
429         double contBeforPorc    = 100*(double)contBefor/(double)totalSubVolume;
430         double contAfterPorc    = 100*(double)contAfter/(double)totalSubVolume;
431         infoToVo.Printf(_T("%dx%dx%d = %d"),dim[0],dim[1],dim[2], dim[0]*dim[1]*dim[2] );
432         infoSuVo.Printf(_T("%ld") , totalSubVolume);
433         infoSuVoA.Printf(_T("%.2f"), _actualCuttingModel->GetTheoricVolume() );
434         infoPixLe.Printf(_T("%ld pix.   (%.2f %s)  -  %.2f mm^3"),contBefor, contBeforPorc ,_T("%"),contBefor*volumeUnit);
435         infoPixHi.Printf(_T("%ld pix.   (%.2f %s)  -  %.2f mm^3"),contAfter, contAfterPorc ,_T("%"),contAfter*volumeUnit);
436
437         _infoToVo->SetLabel(infoToVo);
438         _infoSuVo->SetLabel(infoSuVo);
439         _infoSuVoA->SetLabel(infoSuVoA);
440         _infoPixLe->SetLabel(infoPixLe);
441         _infoPixHi->SetLabel(infoPixHi);
442
443         // Histogram
444         if ( _histogrammeAccumulated->GetValue()==true )
445         {
446                 int dimHist[3];
447                 _histogrammeVector -> GetDimensions ( dimHist );
448
449                 int i,size=dimHist[0];
450                 for (i=1; i<=size; i++)
451                 {
452                         p_histogramme[i] = p_histogramme[i] + p_histogramme[i-1];
453                 }
454         }
455         double range[2];
456         _histogrammeVector->Update();
457         _histogrammeVector->GetScalarRange(range);
458         _xyplot->SetYRange( 0   , range[1]      );
459         _xyplot->SetXRange( min , max           );
460
461         _vtkclipping3Ddataviewer->RefreshSurface();
462         _wxvtkbaseView->Refresh();
463
464 //      _wxvtkbaseView->RefreshView();
465         wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
466         _wxvtkbaseView->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
467 }
468
469
470 //-------------------------------------------------------------------
471 void wxPanelCuttingImageData::OnTypeFig(wxCommandEvent& event)
472 {
473         _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
474
475         if (_typeFig->GetSelection()==0){
476                 _actualCuttingModel=_modelCylinder;
477                 _actualActor=_cylinderActor;
478         }
479         if (_typeFig->GetSelection()==1){
480                 _actualCuttingModel=_modelCube;
481                 _actualActor=_cubeActor;
482         }
483         if (_typeFig->GetSelection()==2){
484                 _actualCuttingModel=_modelSphere;
485                 _actualActor=_sphereActor;
486         }
487         _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
488         RefreshOpacity();
489         RefreshView();
490 }
491
492 //-------------------------------------------------------------------
493 void wxPanelCuttingImageData::RefreshOpacity()
494 {
495         double op= _opacityFig->GetValue()/100.0;
496         _actualActor->GetProperty()->SetOpacity( op );
497 }
498
499 //-------------------------------------------------------------------
500 void wxPanelCuttingImageData::OnOpacityFig(wxScrollEvent& event)
501 {
502         RefreshOpacity();
503         Refresh();
504 }
505 //-------------------------------------------------------------------
506 void wxPanelCuttingImageData::RefreshView()
507 {
508         SetParamsOfTransformation( );
509         Refresh();
510 }
511 //-------------------------------------------------------------------
512 void wxPanelCuttingImageData::Refresh()
513 {
514         _wxvtk3Dbaseview->Refresh();
515 }
516
517 //-------------------------------------------------------------------
518 void wxPanelCuttingImageData::SetParamsOfTransformation( )
519 {
520         double spc[3];
521         vtkImageData *vtkimagedata = _vtkmprbasedata->GetImageData();
522         vtkimagedata->GetSpacing(spc);
523         int px = (int) (_vtkmprbasedata->GetX() );
524         int py = (int) (_vtkmprbasedata->GetY() );
525         int pz = (int) (_vtkmprbasedata->GetZ() );
526         int sx = (int) (_scaleX->GetValue() * spc[0] );
527         int sy = (int) (_scaleY->GetValue() * spc[1] );
528         int sz = (int) (_scaleZ->GetValue() * spc[2] );
529         _actualCuttingModel     -> SetScale             ( sx    , sy    , sz );
530         _actualCuttingModel     -> SetPosition  ( px    , py , pz       );
531         _actualCuttingModel     -> SetRotation  ( _rotationX->GetValue()        , _rotationY->GetValue() , _rotationZ->GetValue()       );
532         _actualCuttingModel     -> SetSpacing   ( spc[0]        , spc[1]    , spc[2] );
533         _actualCuttingModel     -> CalculeMatrix();
534 }
535
536 //-------------------------------------------------------------------
537
538 void wxPanelCuttingImageData::OnTransform(wxScrollEvent& event)
539 {
540         RefreshView();
541 }
542
543 //-------------------------------------------------------------------
544 void wxPanelCuttingImageData::SetVtkMPRBaseData( vtkMPRBaseData *vtkmprbasedata )
545 {
546         _vtkmprbasedata = vtkmprbasedata;
547         _imageData              = _vtkmprbasedata->GetImageData();
548 }
549
550 //-------------------------------------------------------------------
551
552 void wxPanelCuttingImageData::Configure()
553 {
554         _actualCuttingModel=_modelCylinder;
555         _actualActor=_cylinderActor;
556         _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
557         SetParamsOfTransformation();
558         RefreshView();
559 }
560