]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/include/wxEmptyPanelWidget_2.cxx
DFCH
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / include / wxEmptyPanelWidget_2.cxx
1
2 #include "vtkObjectFactory.h"
3
4 #include "vtkActor.h"
5 #include "vtkCylinderSource.h"
6 #include "vtkPolyDataMapper.h"
7 #include "vtkRenderer.h"
8 #include "vtkRenderWindow.h"
9 #include "vtkRenderWindowInteractor.h"
10 #include "vtkProperty.h"
11 #include "vtkCamera.h"
12 #include "vtkPoints.h"
13 #include "vtkCellArray.h"
14 #include "vtkPolyData.h"
15 #include "vtkPolyDataMapper.h"
16 #include "vtkPolyDataWriter.h"
17 #include "vtkPolyDataReader.h"
18 #include "vtkImageReader.h"
19 #include "vtkImageViewer.h"
20 #include "vtkImageViewer2.h"
21 #include "vtkImageToStructuredPoints.h"
22 #include <vtkImageThreshold.h> 
23
24 #include "vtkExtractVOI.h"
25 #include "vtkImageClip.h"
26 #include "vtkImageResample.h"
27 #include "vtkImageThreshold.h"
28 #include "vtkImageCast.h"
29 #include "vtkImageSeedConnectivity.h"
30 #include "vtkImageData.h"
31 #include "vtkMarchingCubes.h"
32 #include "vtkImageReslice.h"
33 #include "vtkTransform.h"
34 #include "vtkSphereSource.h"
35 #include "vtkDoubleArray.h"
36 #include "vtkPointData.h"
37 #include "vtkCommand.h"
38 #include "vtkCallbackCommand.h"
39 #include "vtkImageResample.h"
40 #include "vtkMath.h"
41 #include "vtkStripper.h"
42
43 #include "wxEmptyPanelWidget_2.h"
44
45 #include <wx/splitter.h>
46
47
48
49 //-------------------------------------------------------------------
50 //-------------------------------------------------------------------
51 //-------------------------------------------------------------------
52 vtkStandardNewMacro(TreeExtraction_MH_JFC);
53 //-------------------------------------------------------------------
54
55 TreeExtraction_MH_JFC::TreeExtraction_MH_JFC(){
56         _branchLevel            = 2;
57         _imagedataResult        = NULL;
58         _cleanLevel                     = 400;
59 }
60 //-------------------------------------------------------------------
61 TreeExtraction_MH_JFC::~TreeExtraction_MH_JFC(){
62         Reset();
63 }
64 //-------------------------------------------------------------------
65 void TreeExtraction_MH_JFC::Reset(){
66         if (_imagedataResult!=NULL){
67                 _imagedataResult->Delete();
68         }
69 }
70 //-------------------------------------------------------------------
71 void TreeExtraction_MH_JFC::SetInput(marExperiment *input){
72         _marExperiment = input;
73 }
74
75 //-------------------------------------------------------------------
76 void TreeExtraction_MH_JFC::BruleVolume(vtkImageData *imagedata, int x,int y,int z,int r , int value)
77 {
78         int ext[6];
79         int i, j, k, ii,jj,kk;  
80         imagedata->GetExtent(ext);
81         unsigned short *ptr;
82         int x1=x-r;
83         int x2=x+r;
84         int y1=y-r;
85         int y2=y+r;
86         int z1=z-r;
87         int z2=z+r;
88         double tmpsqrt;
89         for(i=x1;i<=x2;i++){
90                 for(j=y1;j<=y2;j++){
91                         for(k=z1;k<=z2;k++){
92                                 ptr=(unsigned short *)  imagedata->GetScalarPointer(i,j,k);
93                                 ii=i-x;
94                                 jj=j-y;
95                                 kk=k-z;
96                                 tmpsqrt=ii*ii + jj*jj + kk*kk;
97                                 if ((ptr!=NULL) && ( sqrt(tmpsqrt)<=r))
98                                 {
99                                         if (value==0){
100                                                 *ptr=value;
101                                         } else {
102                                                 if (*ptr==0)  {
103                                                         *ptr=value;
104                                                 }
105                                         }
106                                 } 
107                         } // for z
108                 }  // for y
109         } // fox x
110 }
111
112 //-------------------------------------------------------------------
113 void TreeExtraction_MH_JFC::BruleVolume(vtkImageData *imagedata,vtkPolyData *inputAxisRadio, int value)
114 {
115         int x,y,z,r;
116         double point[3],radio;
117         double fractpart, intpart;
118         int i,maxPoints=inputAxisRadio->GetPoints()->GetNumberOfPoints();
119         vtkDoubleArray *allRadios = (vtkDoubleArray*)(inputAxisRadio->GetPointData()->GetScalars("radio"));
120         for (i=0; i<maxPoints; i++){    
121                 inputAxisRadio->GetPoints()->GetPoint(i,point);
122                 radio=allRadios->GetValue(i);
123                 x = (int)(point[0]);
124                 y = (int)(point[1]);    
125                 z = (int)(point[2]);
126                 fractpart = modf (radio , &intpart);
127                 if (fractpart>=0.5){
128                  intpart++;
129                 }
130                 r = (int)( intpart );
131                 BruleVolume(imagedata,x,y,z,r,value);
132         }
133 }
134
135
136 //-------------------------------------------------------------------
137
138 void TreeExtraction_MH_JFC::FindVit( marExperiment *newExperiment , int actualAxis , double *pointBif , double *vit )
139 {
140         double dist,min=-1;
141         double point[3];
142         double dx,dy,dz;
143         int jPoint,maxPoints;
144         int iAxis,maxAxis;
145
146         maxAxis=newExperiment->getNumberOfAxes();
147         for (iAxis=0;iAxis<maxAxis;iAxis++){
148                 if (iAxis!=actualAxis){
149                         newExperiment->setAxis(iAxis);
150                         marAxis *maraxis = newExperiment->getAxis( );
151                         if (maraxis!=NULL) {
152                                 vtkPolyData  *axisVtk   = maraxis->GetAxisData();
153                                 maxPoints=axisVtk->GetPoints()->GetNumberOfPoints();
154                                 for (jPoint=0; jPoint<maxPoints; jPoint++){     
155                                         axisVtk->GetPoints()->GetPoint(jPoint,point);
156                                         dx = pointBif[0]-point[0];
157                                         dy = pointBif[1]-point[1];
158                                         dz = pointBif[2]-point[2];
159                                         dist = sqrt( dx*dx + dy*dy + dz*dz );
160                                         if ((min==-1) || (dist<min)) {
161                                                 min=dist;
162                                                 vit[0] = dx;
163                                                 vit[1] = dy;
164                                                 vit[2] = dz;
165                                         } //if 
166                                 } // for
167                         } // if maraxis!=NULL
168                 } // i!=actualAxis
169         } //for
170 }
171
172 //-------------------------------------------------------------------
173 void TreeExtraction_MH_JFC::Execute(int count, int sens, double *vit, int cleanLevel)
174 {
175         //------------Arbre Extraction --------------
176         // Call Maracas axis extraction
177         count--;
178 /*
179 time_t start,end;
180 double dif;
181 time (&start);
182 */
183                 int idActualAxis_Before = _marExperiment->getNumberOfAxes();
184                 _marExperiment->extractVascularTree( sens , vit, cleanLevel );
185 /*
186 time (&end);
187 dif = difftime (end,start);
188 FILE *ff;
189 ff=fopen("c:/temp/MaracasTIME.txt","a+");
190 fprintf(ff,"\n TreeExtraction_MH_JFC::Execute %d \n",count);
191 fprintf(ff,"evt %.2lf \n",dif);
192 fclose(ff);
193 */
194                 int idActualAxis = _marExperiment->getNumberOfAxes();
195                 // Bifurcation Detection JFC
196                 marAxis *maraxis = _marExperiment->getAxis( );
197                 if ((maraxis!=NULL) && (idActualAxis_Before!=idActualAxis)) {
198                         vtkImageData *imagedata                 = _marExperiment->getDynData( )->getVolume( )->castVtk();
199                         vtkPolyData  *inputAxisRadio    = maraxis->GetAxisData();
200
201                         if (count>0){
202 /*
203 time (&start);
204 */
205                                 _prgov = carotidaBifurcacion::New();
206                                 _prgov->SetMaxPropRadio(5);
207                                 _prgov->SetHumbral(0.45);
208                                 _prgov->SetMaxPropMasa(10);
209                                 _prgov->SetMinPropMasa(0.01);
210                                 _prgov->SetInput( inputAxisRadio );
211                                 _prgov->SetInput2( imagedata );
212                                 _prgov->Update();
213 /*
214 time (&end);
215 dif = difftime (end,start);
216 ff=fopen("c:/temp/MaracasTIME.txt","a+");
217 fprintf(ff,"\tcB  %.2lf \n",dif);
218 fclose(ff);
219 */
220                         }
221
222                         // Brule Volume
223                         BruleVolume(imagedata            , inputAxisRadio , 0                    );
224                         BruleVolume(_imagedataResult , inputAxisRadio , idActualAxis );
225                         inputAxisRadio->Delete();
226
227
228                         if (count>0){
229                                 // LOOP for branch extraction
230                                 vtkPolyData *bifurcations =  _prgov->GetOutput();
231                                 int i,maxPoints = bifurcations->GetPoints()->GetNumberOfPoints();
232                                 int x,y,z;
233                                 double point[3], vit[3];
234                                 for (i=0; i<maxPoints; i++){
235                                         bifurcations->GetPoints()->GetPoint(i,point);
236                                         x = (int)(point[0]);
237                                         y = (int)(point[1]);
238                                         z = (int)(point[2]);
239                                         FindVit( _marExperiment , idActualAxis , point , vit );
240                                         _marExperiment->setStartPoint( x , y , z );
241                                         //Branch extraction;
242                                         Execute(count, 0 , vit , (int)_cleanLevel );
243                                 }
244                                 bifurcations->Delete();
245 //                              _prgov->Delete();
246 //                              _prgov = NULL;
247                         } // of count>0
248
249                 } // maraxi=NULL
250 }
251
252 //-------------------------------------------------------------------
253 void TreeExtraction_MH_JFC::InitImagaDataResult(){
254         Reset();
255         vtkImageData *imagedata = _marExperiment->getDynData( )->getVolume( )->castVtk();
256         imagedata->Update();
257         _imagedataResult = vtkImageData::New();
258         int dim[3];
259         imagedata->GetDimensions(dim);
260         _imagedataResult->SetScalarType(imagedata->GetScalarType());
261
262         _imagedataResult->SetDimensions(dim[0],dim[1],dim[2]); 
263         _imagedataResult->SetExtent( 0 , dim[0]-1 , 0 , dim[1]-1 , 0 , dim[2]-1 ); 
264         _imagedataResult->SetWholeExtent(0 , dim[0]-1 , 0 , dim[1]-1 , 0 , dim[2]-1 );
265         _imagedataResult->SetSpacing( imagedata->GetSpacing()  ); 
266         _imagedataResult->SetOrigin( 0,0,0  ); 
267         _imagedataResult->Update();
268         _imagedataResult->UpdateData();
269         unsigned short *ptr;
270         int i,j,k;
271         for ( i=0 ; i<dim[0] ; i++ ){
272                 for ( j=0 ; j<dim[1] ; j++ ){
273                         for ( k=0 ; k<dim[2] ; k++ ){
274                                 ptr = (unsigned short *)        _imagedataResult->GetScalarPointer(i,j,k);
275                                 *ptr = 0;
276                         }
277                 }
278         }
279 }
280 //-------------------------------------------------------------------
281 void TreeExtraction_MH_JFC::Update(){
282 /*
283 FILE *ff;
284 ff=fopen("c:/temp/MaracasTIME.txt","w");
285 fclose(ff);
286 */
287         InitImagaDataResult();
288         Execute(_branchLevel);
289 }
290 //-------------------------------------------------------------------
291 marExperiment* TreeExtraction_MH_JFC::GetInput(){
292         return _marExperiment;
293 }
294 //-------------------------------------------------------------------
295 vtkImageData* TreeExtraction_MH_JFC::GetVolume(){
296         return _imagedataResult;
297 }
298 //-------------------------------------------------------------------
299 void TreeExtraction_MH_JFC::SetBranchLevel(int branchLevel){
300         _branchLevel = branchLevel;
301 }
302 //-------------------------------------------------------------------
303 void TreeExtraction_MH_JFC::SetCleanTreeLevel( int cleanLevel ){
304         _cleanLevel = (double)cleanLevel;
305 }
306
307 //-------------------------------------------------------------------
308 //-------------------------------------------------------------------
309 //-------------------------------------------------------------------
310 wxEmptyPanelWidget_2::wxEmptyPanelWidget_2(wxWindow *parent, marInterface* mar)
311 : wxPanel( parent, -1) 
312 {
313
314         _sensibility_JF         = 0.5;
315
316         _mar                                                            = mar;
317         wxBoxSizer                      *sizer                  = new wxBoxSizer(wxVERTICAL  );
318     wxSplitterWindow    *pnlSplitter    = new wxSplitterWindow( this , -1);
319         wxPanel                         *viewPanel              = CreateViewPanel(pnlSplitter);
320         wxPanel                         *controlPanel   = CreateControlPanel(pnlSplitter);
321
322         sizer           -> Add( pnlSplitter ,1,wxGROW  ,0);
323         pnlSplitter     -> SetMinimumPaneSize( 150 );
324     pnlSplitter -> SplitVertically( viewPanel, controlPanel, 600 );
325         this            -> SetSizer(sizer);
326
327         // Original Volume
328         _mCubes                         = NULL;
329         _surfMapper                     = NULL;
330         _surfActor                      = NULL;
331
332         // Result 1: Volume + Axis
333         _1_prgov                        = NULL;
334         _1_mapfinal                     = NULL;
335         _1_stripfinal           = NULL;
336         _1_isoMapperMC6         = NULL;
337         _1_isoActorMC6          = NULL;
338         _1_isoMC6                       = NULL;
339
340         // Result 2: Volume + Axis
341         _2_prgov                        = NULL;
342         _2_mapfinal                     = NULL;
343         _2_stripfinal           = NULL;
344         _2_isoMapperMC6         = NULL;
345         _2_isoActorMC6          = NULL;
346         _2_isoMC6                       = NULL;
347
348         //
349         _isoMapperMC1           = NULL;
350         _isoActorMC1            = NULL;
351         _isoMC1                         = NULL;
352         _imageThresholdMC1      = NULL;
353
354         //
355         _treeExtraction         = NULL; 
356
357 }
358 //-------------------------------------------------------------------
359 wxEmptyPanelWidget_2::~wxEmptyPanelWidget_2(){
360         // Erase Original Volule
361         if (_mCubes                     ) { _mCubes                     -> Delete(); }
362         if (_surfMapper         ) {     _surfMapper             -> Delete(); }
363         if (_surfActor          ) {     _surfActor              -> Delete(); }
364
365         // Erase result: Volume + Axis
366         ResetTree1_JF();
367         ResetTree2_JF();
368         ResetTree_MH_JFC();
369 }
370 //-------------------------------------------------------------------
371 wxPanel* wxEmptyPanelWidget_2::CreateViewPanel(wxWindow *parent)
372 {
373         wxPanel *panel          =       new wxPanel(parent,-1);
374     wxBoxSizer *sizer   =       new wxBoxSizer(wxVERTICAL);
375         _maracasSurfaceWidget = new wxSurfaceWidget(panel);
376         sizer->Add(_maracasSurfaceWidget        , 1, wxEXPAND, 0);
377         panel->SetSizer(sizer);
378         panel->SetAutoLayout(true);
379         panel->SetSize(400,400);
380         panel->Layout();
381         return panel;
382 }
383 //-------------------------------------------------------------------
384 wxPanel* wxEmptyPanelWidget_2::CreateControlPanel(wxWindow *parent)
385 {
386         wxPanel *panel          = new wxPanel(parent,-1);
387         _opacity_OrigVol        = new wxSlider( panel, -1, 30, 0, 100 , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
388         _isoValue                       = new wxSlider( panel, -1, 0 , 0, 3000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
389         _opacity_Res1VolJF      = new wxSlider( panel, -1, 25, 0, 100 , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
390         _opacity_Res2VolJF      = new wxSlider( panel, -1, 25, 0, 100 , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
391         _sl_sensibility_JF      = new wxSlider( panel, -1, 0 , 0, 100 , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
392         _branchLevel            = new wxSlider( panel, -1, 2 , 1, 10  , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
393         _opacity_ResVolMHJF     = new wxSlider( panel, -1, 25, 0, 100 , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
394         _isoValue_MH_JFC        = new wxSlider( panel, -1, 0 , 0, 100 , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
395         _cleanTree_MH_JFC       = new wxSlider( panel, -1, 400 , 0, 1000 , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
396
397         int tmp_sensibility= (int)(_sensibility_JF*100.0);
398         _sl_sensibility_JF->SetValue( tmp_sensibility );
399
400
401         _opacity_OrigVol        ->SetSize(250,20);   // Original Volume
402         _isoValue                       ->SetSize(250,20);
403         _opacity_Res1VolJF      ->SetSize(250,20);  // Result 1 Volume JF
404         _opacity_Res2VolJF      ->SetSize(250,20);  // Result 2 Volume JF
405         _branchLevel            ->SetSize(250,20);
406         _opacity_ResVolMHJF     ->SetSize(250,20);  // Result Volume MH+JFC
407
408         //Extract Tree 1 JF
409         wxButton *btnExtractTree1_JF    = new wxButton(panel,-1,_T("Extract Tree 1 JF"));
410         wxButton *btnEraseTree1_JF              = new wxButton(panel,-1,_T("Erase Tree 1 JF"));
411
412         //Extract Tree 2 JF
413         wxButton *btnExtractTree2_JF    = new wxButton(panel,-1,_T("Extract Tree 2 JF"));
414         wxButton *btnEraseTree2_JF              = new wxButton(panel,-1,_T("Erase Tree 2 JF"));
415
416         //Extract Tree MH + JF
417         wxButton *btnExtractTree_MH_JFC = new wxButton(panel,-1,_T("Extract Tree MH + JFC"));
418         wxButton *btnEraseTree_MH_JFC   = new wxButton(panel,-1,_T("Erase Tree MH + JFC"));
419
420
421     wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
422         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
423         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
424         sizer->Add(new wxStaticText(panel,-1,_T("Isovalue - Original Volume")));        
425         sizer->Add(_isoValue);
426         sizer->Add(new wxStaticText(panel,-1,_T("Opacity - Original Volume")));
427         sizer->Add(_opacity_OrigVol);
428
429         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
430         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
431         sizer->Add(new wxStaticText(panel,-1,_T("  - - -  Juan Francisco Module 1 - - - ")));
432         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
433         sizer->Add(btnExtractTree1_JF);
434         sizer->Add(btnEraseTree1_JF);
435         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
436         sizer->Add(new wxStaticText(panel,-1,_T("Opacity - Result Volume")));
437         sizer->Add(_opacity_Res1VolJF);
438
439         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
440         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
441         sizer->Add(new wxStaticText(panel,-1,_T("  - - -  Juan Francisco Module 2 - - - ")));
442         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
443         sizer->Add(new wxStaticText(panel,-1,_T(" % Sensibility")));
444         sizer->Add(_sl_sensibility_JF);
445         sizer->Add(btnExtractTree2_JF);
446         sizer->Add(btnEraseTree2_JF);
447         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
448         sizer->Add(new wxStaticText(panel,-1,_T("Opacity - Result Volume")));
449         sizer->Add(_opacity_Res2VolJF);
450
451
452         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
453         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
454         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
455         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
456         sizer->Add(new wxStaticText(panel,-1,_T("  - - -  MH + JFC  - - - ")));
457         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
458         sizer->Add(btnExtractTree_MH_JFC);
459         sizer->Add(btnEraseTree_MH_JFC);
460         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
461         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
462         sizer->Add(new wxStaticText(panel,-1,_T("Branch Level MH+JFC")));
463         sizer->Add(_branchLevel);
464         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
465         sizer->Add(new wxStaticText(panel,-1,_T("Opacity - Result Volume MH+JFC")));
466         sizer->Add(_opacity_ResVolMHJF);
467         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
468         sizer->Add(new wxStaticText(panel,-1,_T("IsoValue - Result Volume MH+JFC")));
469         sizer->Add(_isoValue_MH_JFC);
470         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
471         sizer->Add(new wxStaticText(panel,-1,_T("signal level (Clean Tree)")));
472         sizer->Add(_cleanTree_MH_JFC);
473
474         panel->SetSizer(sizer);
475         panel->SetAutoLayout(true);
476         panel->SetSize(400,400);
477         panel->Layout();
478         Connect(_opacity_OrigVol->GetId()               , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnOpacity_OrigVol              ); 
479         Connect(_isoValue->GetId()                              , wxEVT_SCROLL_THUMBRELEASE             , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnIsoValue                             ); 
480         Connect(_opacity_Res1VolJF->GetId()             , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnOpacity_Res1VolJF    ); 
481         Connect(_opacity_Res2VolJF->GetId()             , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnOpacity_Res2VolJF    ); 
482         Connect(_sl_sensibility_JF->GetId()             , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnSensibility                  ); 
483
484         Connect(btnExtractTree1_JF->GetId()             , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnBtnExtractTree1_JF   ); 
485         Connect(btnEraseTree1_JF->GetId()               , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnBtnEraseTree1_JF     ); 
486         Connect(btnExtractTree2_JF->GetId()             , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnBtnExtractTree2_JF   ); 
487         Connect(btnEraseTree2_JF->GetId()               , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnBtnEraseTree2_JF     ); 
488
489         Connect(btnExtractTree_MH_JFC->GetId()  , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnBtnExtractTree_MH_JFC);      
490         Connect(btnEraseTree_MH_JFC->GetId()    , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnBtnEraseTree_MH_JFC  );      
491         Connect(_branchLevel->GetId()                   , wxEVT_SCROLL_THUMBRELEASE             , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnBranchLevel                  ); 
492         Connect(_opacity_ResVolMHJF->GetId()    , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnOpacity_ResVolMHJF   ); 
493         Connect(_isoValue_MH_JFC->GetId()               , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnIsoValue_MH_JFC              ); 
494         Connect(_cleanTree_MH_JFC->GetId()              , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxEmptyPanelWidget_2::OnCleanTree_MH_JFC             ); 
495
496         return panel;
497 }
498 //------------------------------------------------------------------------
499 void wxEmptyPanelWidget_2::Refresh()
500 {
501         _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->Render();
502 }
503 //------------------------------------------------------------------------
504 void wxEmptyPanelWidget_2::ConfigureVTK()
505 {
506     wxBusyCursor wait;
507 //      _imageviewer3D->Configure();
508         vtkImageData    *imagedata              = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
509         double                  opacity_OrigVol = ((double)(_opacity_OrigVol->GetValue()))/100;
510         double                  isoValue; 
511
512         // Visualisation - original volume
513     double range[2];
514     imagedata->GetScalarRange( range );
515         isoValue=range[1] / 8;
516
517     _mCubes = vtkMarchingCubes::New( );
518     _mCubes->SetInput( imagedata );
519     _mCubes->SetValue( 0, isoValue );
520
521     vtkStripper *stripper = vtkStripper::New();
522     stripper->SetInput( _mCubes->GetOutput( ) );
523
524     _surfMapper = vtkPolyDataMapper::New( );
525         _surfMapper->SetInput( stripper->GetOutput() );
526     _surfMapper->ScalarVisibilityOff( );
527     stripper->Delete();
528
529     _surfActor = vtkActor::New( );
530     _surfActor->SetMapper( _surfMapper );
531     _surfActor->PickableOff( );
532     _surfActor->GetProperty( )->SetColor( 0, 0, 0.8 );
533     _surfActor->GetProperty( )->SetOpacity( opacity_OrigVol );
534
535         // Update Controls
536         _isoValue->SetRange( (int)(range[0]), (int)(range[1]) );
537         _isoValue->SetValue( (int)isoValue );
538         
539         // Interface Update
540         vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
541         ren->AddActor(_surfActor);
542
543         //-Maracas-
544         _maracasSurfaceWidget->ShowMARACASData( _mar );
545 }
546
547
548 //------------------------------------------------------------------------
549 void wxEmptyPanelWidget_2::ResetTree1_JF()
550 {
551         // Remove 
552         vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
553     if (_1_isoActorMC6){
554                 ren->RemoveActor(_1_isoActorMC6);
555         }
556     if (_1_stripfinal){
557                 ren->RemoveActor(_1_stripfinal);
558         }
559
560         // Delete 
561         if (_1_prgov            ) {     _1_prgov                -> Delete(); }
562         if (_1_mapfinal         ) {     _1_mapfinal             -> Delete(); }
563         if (_1_stripfinal       ) {     _1_stripfinal   -> Delete(); }
564         if (_1_isoMapperMC6     ) {     _1_isoMapperMC6 -> Delete(); }
565         if (_1_isoActorMC6      ) {     _1_isoActorMC6  -> Delete(); }
566         if (_1_isoMC6           ) {     _1_isoMC6               -> Delete(); }
567
568         // Init
569         _1_prgov                = NULL;
570         _1_mapfinal             = NULL;
571         _1_stripfinal   = NULL;
572         _1_isoMapperMC6 = NULL;
573         _1_isoActorMC6  = NULL;
574         _1_isoMC6               = NULL;
575 }
576
577 //------------------------------------------------------------------------
578 void wxEmptyPanelWidget_2::ResetTree2_JF()
579 {
580         // Remove 
581         vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
582     if (_2_isoActorMC6){
583                 ren->RemoveActor(_2_isoActorMC6);
584         }
585     if (_2_stripfinal){
586                 ren->RemoveActor(_2_stripfinal);
587         }
588
589         // Delete 
590         if (_2_prgov            ) {     _2_prgov                -> Delete(); }
591         if (_2_mapfinal         ) {     _2_mapfinal             -> Delete(); }
592         if (_2_stripfinal       ) {     _2_stripfinal   -> Delete(); }
593         if (_2_isoMapperMC6     ) {     _2_isoMapperMC6 -> Delete(); }
594         if (_2_isoActorMC6      ) {     _2_isoActorMC6  -> Delete(); }
595         if (_2_isoMC6           ) {     _2_isoMC6               -> Delete(); }
596
597         // Init
598         _2_prgov                = NULL;
599         _2_mapfinal             = NULL;
600         _2_stripfinal   = NULL;
601         _2_isoMapperMC6 = NULL;
602         _2_isoActorMC6  = NULL;
603         _2_isoMC6               = NULL;
604 }
605
606
607
608 //------------------------------------------------------------------------
609 void wxEmptyPanelWidget_2::ExtractTree1_JF(int x, int y, int z)
610 {
611         double opacity_Res1VolJF = ((double)_opacity_Res1VolJF->GetValue())/100;
612         vtkImageData *imagedata = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
613
614         double  puntoactualprov[3];
615         double  espprin[3];
616         int             extprin[6];                             
617
618         puntoactualprov[0]=x;
619         puntoactualprov[1]=y;
620         puntoactualprov[2]=z;
621         
622         imagedata->GetSpacing(espprin);
623         imagedata->GetExtent(extprin);
624
625         puntoactualprov[0]=puntoactualprov[0]*espprin[0];
626         puntoactualprov[1]=puntoactualprov[1]*espprin[1];
627         puntoactualprov[2]=puntoactualprov[2]*espprin[2];
628         
629         // Juan Francisco Carrillo Filter 
630         _1_prgov= axisExtractor::New();
631         _1_prgov->SetHumbral(0.45);
632         _1_prgov->SetInput(imagedata);
633         _1_prgov->SetPoint(puntoactualprov);
634         _1_prgov->Update();
635
636         // Visualisation - result vascular tree
637         _1_mapfinal = vtkPolyDataMapper::New();
638         _1_mapfinal->SetInput(_1_prgov->GetOutput());
639
640         _1_stripfinal = vtkActor::New();
641         _1_stripfinal->SetMapper(_1_mapfinal);
642         _1_stripfinal->GetProperty()->SetColor(1, 1, 1);
643         _1_stripfinal->GetProperty()->SetLineWidth(2);
644         _1_stripfinal->GetProperty()->BackfaceCullingOff();
645
646         // Visualisation - result volume
647         vtkImageData *imageOut = _1_prgov->GetVolumen();
648         imageOut->Update();
649
650     _1_isoMC6 = vtkMarchingCubes::New();
651     _1_isoMC6->SetInput(imageOut);
652     _1_isoMC6->SetValue(0, 1);
653         _1_isoMC6->Update();
654
655         _1_isoMapperMC6 = vtkPolyDataMapper::New();
656     _1_isoMapperMC6->SetInput(_1_isoMC6->GetOutput());
657     _1_isoMapperMC6->ScalarVisibilityOff();
658     _1_isoMapperMC6->ImmediateModeRenderingOn();
659
660         _1_isoActorMC6 = vtkActor::New();
661     _1_isoActorMC6->SetMapper(_1_isoMapperMC6);
662     _1_isoActorMC6->GetProperty()->SetColor( 0, 1, 0);
663     _1_isoActorMC6->GetProperty()->SetOpacity( opacity_Res1VolJF );
664  
665    
666         // Interface Update
667         vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
668         ren->AddActor(_1_isoActorMC6);
669         ren->AddActor(_1_stripfinal);
670 }
671
672
673 //------------------------------------------------------------------------
674 void wxEmptyPanelWidget_2::ExtractTree2_JF(int x, int y, int z)
675 {
676         double opacity_Res2VolJF = ((double)_opacity_Res2VolJF->GetValue())/100;
677         vtkImageData *imagedata = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
678
679         double  puntoactualprov[3];
680         double  espprin[3];
681         int             extprin[6];                             
682
683         puntoactualprov[0]=x;
684         puntoactualprov[1]=y;
685         puntoactualprov[2]=z;
686         
687         imagedata->GetSpacing(espprin);
688         imagedata->GetExtent(extprin);
689
690         puntoactualprov[0]=puntoactualprov[0]*espprin[0];
691         puntoactualprov[1]=puntoactualprov[1]*espprin[1];
692         puntoactualprov[2]=puntoactualprov[2]*espprin[2];
693         
694         _2_prgov= axisExtractor02::New();
695         _2_prgov->SetParam(1);
696         _2_prgov->SetParam2(1);
697         _2_prgov->SetParam3(_sensibility_JF);
698         _2_prgov->SetMaxant(20);
699         _2_prgov->SetMinant(5);
700         _2_prgov->SetInput(imagedata);
701         _2_prgov->SetPoint(puntoactualprov);
702         _2_prgov->Update();
703
704         // Visualisation - result vascular tree
705         _2_mapfinal = vtkPolyDataMapper::New();
706         _2_mapfinal->SetInput(_2_prgov->GetOutput());
707
708         _2_stripfinal = vtkActor::New();
709         _2_stripfinal->SetMapper(_2_mapfinal);
710         _2_stripfinal->GetProperty()->SetColor(0.3, 0.3, 0.3);
711         _2_stripfinal->GetProperty()->SetLineWidth(2);
712         _2_stripfinal->GetProperty()->BackfaceCullingOff();
713
714         // Visualisation - result volume
715         vtkImageData *imageOut = _2_prgov->GetVolumen();
716         imageOut->Update();
717
718     _2_isoMC6 = vtkMarchingCubes::New();
719     _2_isoMC6->SetInput(imageOut);
720     _2_isoMC6->SetValue(0, 1);
721         _2_isoMC6->Update();
722
723         _2_isoMapperMC6 = vtkPolyDataMapper::New();
724     _2_isoMapperMC6->SetInput(_2_isoMC6->GetOutput());
725     _2_isoMapperMC6->ScalarVisibilityOff();
726     _2_isoMapperMC6->ImmediateModeRenderingOn();
727
728         _2_isoActorMC6 = vtkActor::New();
729     _2_isoActorMC6->SetMapper(_2_isoMapperMC6);
730     _2_isoActorMC6->GetProperty()->SetColor( 1, 1, 0);
731     _2_isoActorMC6->GetProperty()->SetOpacity( opacity_Res2VolJF );
732     
733         // Interface Update
734         vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
735         ren->AddActor(_2_isoActorMC6);
736         ren->AddActor(_2_stripfinal);
737 }
738
739 //------------------------------------------------------------------------
740 void wxEmptyPanelWidget_2::OnOpacity_OrigVol(wxScrollEvent& event)
741 {
742         double value = ((double)_opacity_OrigVol->GetValue())/100;
743     _surfActor->GetProperty( )->SetOpacity( value );
744         Refresh();
745 }
746 //------------------------------------------------------------------------
747 void wxEmptyPanelWidget_2::OnOpacity_Res1VolJF(wxScrollEvent& event)
748 {
749         if (_1_isoActorMC6!=NULL){
750                 double value = ((double)_opacity_Res1VolJF->GetValue())/100;
751                 _1_isoActorMC6->GetProperty( )->SetOpacity( value );
752                 Refresh();
753         }
754 }
755 //------------------------------------------------------------------------
756 void wxEmptyPanelWidget_2::OnOpacity_Res2VolJF(wxScrollEvent& event)
757 {
758         if (_2_isoActorMC6!=NULL){
759                 double value = ((double)_opacity_Res2VolJF->GetValue())/100;
760                 _2_isoActorMC6->GetProperty( )->SetOpacity( value );
761                 Refresh();
762         }
763 }
764
765 //------------------------------------------------------------------------
766 void wxEmptyPanelWidget_2::OnIsoValue(wxScrollEvent& event)
767 {
768     wxBusyCursor wait;
769         _mCubes->SetValue(0, _isoValue->GetValue());
770         Refresh();
771 }
772 //------------------------------------------------------------------------
773 void wxEmptyPanelWidget_2::OnBtnExtractTree1_JF(wxCommandEvent& event)
774 {
775         if (_1_prgov==NULL){
776                 wxBusyCursor wait;
777                 vtk3DSurfaceWidget *world3D = _maracasSurfaceWidget->GetVtk3DSurfaceWidget();
778                 if( world3D->GetInitialSphere() ){
779                         double point[3];
780                         world3D->GetSphereCenter( point );
781                         ExtractTree1_JF((int)point[0],(int)point[1],(int)point[2]);
782                 }
783                 Refresh();
784         }
785 }
786 //------------------------------------------------------------------------
787 void wxEmptyPanelWidget_2::OnBtnExtractTree2_JF(wxCommandEvent& event)
788 {
789         if (_2_prgov==NULL){
790                 wxBusyCursor wait;
791                 vtk3DSurfaceWidget *world3D = _maracasSurfaceWidget->GetVtk3DSurfaceWidget();
792                 if( world3D->GetInitialSphere() ){
793                         double point[3];
794                         world3D->GetSphereCenter( point );
795                         ExtractTree2_JF((int)point[0],(int)point[1],(int)point[2]);
796                 }
797                 Refresh();
798         }
799 }
800 //------------------------------------------------------------------------
801 void wxEmptyPanelWidget_2::OnBtnEraseTree1_JF(wxCommandEvent& event)
802 {
803         ResetTree1_JF();
804         Refresh();
805 }
806 //------------------------------------------------------------------------
807 void wxEmptyPanelWidget_2::OnBtnEraseTree2_JF(wxCommandEvent& event)
808 {
809         ResetTree2_JF();
810         Refresh();
811 }
812
813 //------------------------------------------------------------------------
814 void wxEmptyPanelWidget_2::PaintVascularTree_MH_JFC(marExperiment * newExperiment)
815 {
816         vtkActor                        *branchActor;
817         vtkPolyData                     *axisVtk;
818         vtkPolyDataMapper       *branchMapper;
819         vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
820
821         int i,maxAxis=newExperiment->getNumberOfAxes();
822         for (i=0;i<maxAxis;i++){
823                 newExperiment->setAxis(i);
824                 marAxis *maraxis =newExperiment->getAxis( );
825                 if (maraxis!=NULL) {
826                         axisVtk = maraxis->Draw();
827                         branchMapper = vtkPolyDataMapper::New( );
828                         branchMapper->SetInput( axisVtk );
829                         branchMapper->Update();
830                         branchActor = vtkActor::New( );
831                         branchActor->SetMapper( branchMapper );
832                         branchActor->GetProperty()->SetColor( 1, 1, 1 );
833                         if (i== 0) { branchActor->GetProperty()->SetColor( 0  , 0       , 0.3 ); }
834                         if (i== 1) { branchActor->GetProperty()->SetColor( 0  , 0.3     , 0.3 ); }
835                         if (i== 2) { branchActor->GetProperty()->SetColor( 0.3, 0.3     , 0.3 ); }
836                         if (i== 3) { branchActor->GetProperty()->SetColor( 0.0, 0.0     , 0.6 ); }
837                         if (i== 4) { branchActor->GetProperty()->SetColor( 0.0, 0.6     , 0.6 ); }
838                         if (i== 5) { branchActor->GetProperty()->SetColor( 0.6, 0.6     , 0.6 ); }
839                         if (i== 7) { branchActor->GetProperty()->SetColor( 0.0, 0.0     , 0.9 ); }
840                         if (i== 8) { branchActor->GetProperty()->SetColor( 0.0, 0.9     , 0.9 ); }
841                         if (i== 9) { branchActor->GetProperty()->SetColor( 0.9, 0.9     , 0.9 ); }
842                         if (i==10) { branchActor->GetProperty()->SetColor( 0.9, 0.0     , 0.0 ); }
843                         if (i==11) { branchActor->GetProperty()->SetColor( 0.6, 0.0     , 0.0 ); }
844                         if (i==12) { branchActor->GetProperty()->SetColor( 0.3, 0.0     , 0.0 ); }
845                         if (i==13) { branchActor->GetProperty()->SetColor( 0.6, 0.6     , 0.0 ); }
846                         if (i==14) { branchActor->GetProperty()->SetColor( 0.3, 0.3     , 0.0 ); }
847                         if (i==15) { branchActor->GetProperty()->SetColor( 0.9, 0.9     , 0.0 ); }
848                         branchActor->GetProperty()->SetLineWidth( 2.0 );
849                         ren->AddActor( branchActor );
850
851                         _lstAxisVtk.push_back( axisVtk );
852                         _lstBranchActor.push_back( branchActor );
853                         _lstBranchMapper.push_back( branchMapper );
854                 }
855         }
856 }
857
858
859 //------------------------------------------------------------------------
860 void wxEmptyPanelWidget_2::PaintVascularVolume_MH_JFC(vtkImageData * image)
861 {
862
863         // Visualisation - result volume
864         image->Update();
865
866         _imageThresholdMC1=vtkImageThreshold::New();
867         _imageThresholdMC1->SetInput(image);
868         _imageThresholdMC1->ThresholdBetween(0,100);
869         _imageThresholdMC1->SetOutValue  (  0   ); 
870         _imageThresholdMC1->Update();
871
872     _isoMC1 = vtkMarchingCubes::New();
873     _isoMC1->SetInput(_imageThresholdMC1->GetOutput()   );
874     _isoMC1->SetValue(0, 1);
875         _isoMC1->Update();
876
877         _isoMapperMC1 = vtkPolyDataMapper::New();
878     _isoMapperMC1->SetInput(_isoMC1->GetOutput());
879     _isoMapperMC1->ScalarVisibilityOff();
880     _isoMapperMC1->ImmediateModeRenderingOn();
881         _isoMapperMC1->Update();
882
883         _isoActorMC1 = vtkActor::New();
884     _isoActorMC1->SetMapper(_isoMapperMC1);
885     _isoActorMC1->GetProperty()->SetColor( 1, 0, 0);
886     _isoActorMC1->GetProperty()->SetOpacity( 0.4 );
887
888         // Interface Update
889         vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
890         ren->AddActor(_isoActorMC1);
891 }
892
893 //------------------------------------------------------------------------
894 void wxEmptyPanelWidget_2::WriteSignals(marExperiment *newExperiment){
895         int  i       = 0;
896         int  j       = 0;
897         bool ok      = true;
898         int  value   = 0;
899         int  maxAxis = newExperiment->getNumberOfAxes();
900
901         FILE *ff;
902         ff=fopen("c:/Temp/MaracasTEMP.TXT", "w");
903
904         while (ok==true){
905                 ok=false;
906                 for (i=0;i<maxAxis;i++){
907                         newExperiment->setAxis(i);
908                         marAxis *maraxis =newExperiment->getAxis( );
909                         if (maraxis!=NULL) {
910                                 if ( j < maraxis->getNumberOfControlPoints()  ){
911                                         ok=true;
912                                         value= (int)(maraxis->getSignal((uint32_t)j) );
913                                         fprintf(ff,"%d\t", value );
914                                 } else {
915                                         fprintf(ff,"\t");
916                                 }
917                         }
918                 }
919                 fprintf(ff,"\n" );
920                 j++;
921         }
922         fclose(ff);
923 }
924
925
926 //------------------------------------------------------------------------
927 void wxEmptyPanelWidget_2::OnBtnExtractTree_MH_JFC(wxCommandEvent& event)
928 {
929   if ((_lstBranchActor.size()==0) 
930           && 
931           (_maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetInitialSphere() ) )
932   {
933    wxBusyCursor wait;
934
935         // Copie Volume
936         int voiA[6];
937         int voiB[6];
938         _mar->_experiment->getVOI(voiA);
939         voiB[0]=0;
940         voiB[1]=voiA[1]-voiA[0];
941         voiB[2]=0;
942         voiB[3]=voiA[3]-voiA[2];
943         voiB[4]=0;
944         voiB[5]=voiA[5]-voiA[4];
945         marExperiment *newExperiment = new marExperiment( _mar->_experiment->getParameters() );
946         newExperiment->setVOI( voiB );
947         newExperiment->initExperiment( _mar->_experiment->getDynData( )->getVolume() );
948         
949         double  point[3];
950         int             extent[ 6 ];
951     _mar->_experiment->getDynData( )->getVolume( )->castVtk()->GetExtent( extent );
952     _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetSphereCenter( point );
953         int x = (int)point[0] - extent[0];
954         int y = (int)point[1] - extent[2];
955         int z = (int)point[2] - extent[4];
956         newExperiment->setStartPoint( x, y, z);
957
958         // Vascular tree extraction
959         _treeExtraction = TreeExtraction_MH_JFC::New();
960         _treeExtraction->SetInput(newExperiment);
961         _treeExtraction->SetCleanTreeLevel( _cleanTree_MH_JFC->GetValue() );
962         _treeExtraction->SetBranchLevel( _branchLevel->GetValue() );
963         _treeExtraction->Update();
964
965         //Paint Vascular Tree
966         PaintVascularTree_MH_JFC(newExperiment);
967         //Paint Vascular Volume
968         PaintVascularVolume_MH_JFC( _treeExtraction->GetVolume() );
969         Refresh( );
970
971         WriteSignals(newExperiment);
972
973         // Clening memory
974         delete newExperiment;
975   }
976 }
977 //------------------------------------------------------------------------
978 void wxEmptyPanelWidget_2::OnBtnEraseTree_MH_JFC(wxCommandEvent& event)
979 {
980         ResetTree_MH_JFC();
981         Refresh();
982 }
983
984 //------------------------------------------------------------------------
985 void wxEmptyPanelWidget_2::ResetTree_MH_JFC()
986 {       
987         // Remove
988         vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
989         int i,size;
990         size=_lstAxisVtk.size();
991         size=_lstBranchMapper.size();
992         size=_lstBranchActor.size();
993         for (i=0;i<size;i++){
994                 if (_lstBranchActor[i]!=NULL){
995                         ren->RemoveActor( _lstBranchActor[i] );
996                 }
997         }
998         for (i=0;i<size;i++){
999         // Delete
1000                 if (_lstAxisVtk[i]              != NULL ) {     _lstAxisVtk[i]          -> Delete();    }
1001 //              if (_lstBranchMapper[i] != NULL ) {     _lstBranchMapper[i] -> Delete();        }
1002                 if (_lstBranchActor[i]  != NULL ) {     _lstBranchActor[i]      -> Delete();    }
1003         // Init
1004                 _lstAxisVtk[i]          = NULL;
1005                 _lstBranchActor[i]      = NULL;
1006                 _lstBranchMapper[i]     = NULL;
1007         }
1008         _lstAxisVtk.clear();
1009         _lstBranchActor.clear();
1010         _lstBranchMapper.clear();
1011
1012         // Remove 
1013     if (_isoActorMC1){
1014                 ren->RemoveActor(_isoActorMC1);
1015         }
1016
1017         // Delete 
1018         if (_isoMapperMC1               ) {     _isoMapperMC1           -> Delete(); }
1019         if (_isoActorMC1                ) {     _isoActorMC1            -> Delete(); }
1020         if (_isoMC1                             ) {     _isoMC1                         -> Delete(); }
1021         if (_imageThresholdMC1  ) {     _imageThresholdMC1      -> Delete(); }
1022
1023
1024         // Init
1025         _isoMapperMC1           = NULL;
1026         _isoActorMC1            = NULL;
1027         _isoMC1                         = NULL;
1028         _imageThresholdMC1      = NULL;
1029
1030         //
1031 //      if (_treeExtraction     ) {     _treeExtraction -> Delete(); }     // EED
1032 //      _treeExtraction=NULL; 
1033
1034 }
1035
1036 //------------------------------------------------------------------------
1037 void wxEmptyPanelWidget_2::OnOpacity_ResVolMHJF(wxScrollEvent& event)
1038 {
1039         if (_isoActorMC1!=NULL){
1040                 double value = ((double)_opacity_ResVolMHJF->GetValue())/100;
1041                 _isoActorMC1->GetProperty( )->SetOpacity( value );
1042         }
1043         Refresh();
1044 }
1045 //------------------------------------------------------------------------
1046 void wxEmptyPanelWidget_2::OnBranchLevel(wxScrollEvent& event)
1047 {
1048         //
1049 }
1050 //------------------------------------------------------------------------
1051 void wxEmptyPanelWidget_2::OnIsoValue_MH_JFC(wxScrollEvent& event)
1052 {
1053         if (_imageThresholdMC1!=NULL){
1054                 wxBusyCursor wait;
1055                 double threshold = _isoValue_MH_JFC->GetValue();
1056                 if (threshold!=0){
1057                         _imageThresholdMC1->ThresholdBetween(threshold, threshold );
1058                 } else {
1059                         _imageThresholdMC1->ThresholdBetween(0, 1000 );
1060                 }
1061                 Refresh();
1062         }
1063 }
1064 //------------------------------------------------------------------------
1065 void wxEmptyPanelWidget_2::OnCleanTree_MH_JFC(wxScrollEvent& event)
1066 {
1067 //
1068 }
1069 //------------------------------------------------------------------------
1070 void wxEmptyPanelWidget_2::OnSensibility(wxScrollEvent& event)
1071 {
1072         _sensibility_JF = (double)(_sl_sensibility_JF->GetValue())/100;
1073 }
1074