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