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