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