]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
*** empty log message ***
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourMainFrame.cxx
1 //----------------------------------------------------------------------------------------------------------------
2 // Class definition include
3 //----------------------------------------------------------------------------------------------------------------
4 #include "wxContourMainFrame.h"
5
6
7
8 //----------------------------------------------------------------------------------------------------------------
9 // Includes
10 //----------------------------------------------------------------------------------------------------------------
11
12
13 #include "NameWrapper.h"
14 #include "wx/artprov.h"
15 #include "ConceptDataWrap.h"
16
17 #include <manualContour.h>
18 //#include "ImageSourceThing.h"
19 //#include "wxContour_ActionCommandsID.h"
20 //#include "OutlineModelBuilder.h"
21 //#include "wxContourEventHandler.h"
22 #include <creaWx.h>
23
24 //----------------------------------------------------------------------------------------------------------------
25 // Class implementation
26 //----------------------------------------------------------------------------------------------------------------
27 /** @file wxContourMainFrame.cxx */
28
29         //------------------------------------------------------------------------------------------------------------
30         // Constructors & Destructors
31         //------------------------------------------------------------------------------------------------------------
32
33 wxContourMainFrame* wxContourMainFrame:: instance = NULL;
34 char wxContourMainFrame::COPY = 'C';
35                 
36         wxContourMainFrame :: wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style)
37                 //: wxPanel(parent, id, title, pos, size, style)
38                 //: wxWindow(parent, id, pos, size, style)
39                 : wxPanel(parent, id, pos, size, style)
40         {
41                 m_mgr.SetManagedWindow(this);
42                 _creatingContoursActive         = false;
43                 _theViewPanel                           = NULL;
44 //              _modelManager                           = NULL;
45                 _instantPanel                           = NULL;
46 //              _buttonsBar                                     = NULL;
47 //              _gridPanel                                      = NULL; 
48 //              _drawToolsPanel                         = NULL;
49 //              _operationsToolsPanel           = NULL;
50                 //_autoFormsPanel                               = NULL; 
51 //              _standardToolsPanel                     = NULL;
52 //              _editionToolsPanel                      = NULL;
53 //              _listViewPanel                          = NULL;
54 //              _sceneManager                           = NULL;
55                 //_actualInstant                                = NULL;
56                 _numberOfVariablesStatistics = 6+1;
57
58                 // set up default notebook style
59 //              m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
60 //              m_notebook_theme = 0;   
61                 //wxContour_ActionCommandsID a;
62
63         }
64
65 wxContourMainFrame :: wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style)             
66                 : wxPanel(parent, id, pos, size, style)
67         {
68                 m_mgr.SetManagedWindow(this);
69                 _creatingContoursActive         = false;
70                 _theViewPanel                           = NULL;
71 //              _modelManager                           = NULL;
72                 _instantPanel                           = NULL;
73 //              _buttonsBar                                     = NULL;
74 //              _gridPanel                                      = NULL; 
75 //              _drawToolsPanel                         = NULL;
76 //              _operationsToolsPanel           = NULL;
77 //              _autoFormsPanel                         = NULL; 
78 //              _standardToolsPanel                     = NULL;
79 //              _editionToolsPanel                      = NULL;
80 //              _listViewPanel                          = NULL;
81 //              _sceneManager                           = NULL;
82                 //_actualInstant                                = NULL;
83
84                 // set up default notebook style
85                 m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
86                 m_notebook_theme = 0;   
87                 //wxContour_ActionCommandsID a;
88                 _numberOfVariablesStatistics = 6+1;
89
90
91                 _performingOperation                    = new PerformingOperation();
92 //JCP 17 - 10 - 2008
93
94         inredo = 0;
95         inundo = 0;
96
97         kernelManager = new KernelManagerContour(images);
98         //kernelManager->setVectImages(images);
99         //kernelManager->initializeEnvironment();
100                         
101         //vtkImageData* selectedimage = kernelManager->getVectImages()[0];
102         
103 //-------------------------------------------------------------
104
105         /*frame = new wxContourMainFrame(_builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(),  _builder->getContourEnv(),NULL, wxID_ANY, wxT("ROI Application Sample"), wxPoint(50,50), wxSize(800, 600)); 
106         frame->Show(TRUE);*/
107
108         //Creating the evtHandler of the panels
109         //wxContourEventHandler * eventHandler = new wxContourEventHandler();
110
111         //Creating the window that will show the panels
112
113         //Getting the parent for the panels ( using aui )
114         wxAuiNotebook * notebook = this->createNotebook();
115
116         //JCP 17 - 11 - 08
117         //wxInstantChooserPanel * instantPanel                          = new wxInstantChooserPanel( notebook, "Instant Chooser", true);
118         //JCP 17 - 11 - 08
119         std::vector<std::string> conceptNameVect;
120         std::vector<int> conceptSizeVect;
121         
122
123
124         _instantPanel                           = new wxInstantChooserPanel( notebook, "Instant Chooser", true, false, "c" );
125         _theViewPanel                           = new wxContourViewPanel( kernelManager->getSourceImage(), notebook );  
126
127
128
129     kernelManager->getConceptsInformation(conceptNameVect, conceptSizeVect);
130         _instantPanel->addConcepts(conceptNameVect, conceptSizeVect);
131                 
132
133         double val = _theViewPanel->getCurrentDeep();
134         _instantPanel->setConceptValue( "Axe Depth", (int)val );
135         //JCP _instantPanel->setConceptValue("time", num de imagenes);
136         ConceptDataWrap * data = _instantPanel->getConceptDataOf( "Axe Depth" );
137         //*******************changeInstant();
138         _theViewPanel->setVerticalConcept( "Axe Depth", data->getMinValue(), data->getMaxValue(), data->getMinShowedValue(),  data->getMaxShowedValue(), data->getActualValue() );
139
140         //eventHandler->setModelManager( kernelManager->getOutlineModelManager() );
141         //eventHandler->setViewPanel( _theViewPanel );
142         //_theViewPanel->initializeScenceManager();
143         //eventHandler->setInstantChooserPanel( _instantPanel );
144         
145         //bool successConfiuration = eventHandler->configureEventsHandling();
146
147         //successConfiuration &= this->configurePanels( notebook );
148         this->configurePanels( notebook );
149
150         interfMainPanel* pannew = interfMainPanel::getInstance(parent);//, eventHandler);
151
152 //JCP 17 -10 - 2008
153
154
155         }
156
157
158         wxContourMainFrame* wxContourMainFrame :: getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style ){
159                 if(instance == NULL){
160                         instance = new wxContourMainFrame(parent, id, title, pos, size, images, style);
161                 }
162                 return instance;
163         }
164
165         std::vector<vtkImageData*> wxContourMainFrame ::getVectImages(){
166                 return kernelManager->getVectImages();
167         }
168         wxContourMainFrame* wxContourMainFrame :: getInstance(){
169                 return instance;
170                 
171         }
172
173         wxContourMainFrame :: ~wxContourMainFrame()
174         {
175                   m_mgr.UnInit();
176                   //El problema al cerrar la aplicacion puede estar asociado 
177                   //a que  wxAUINotebook esta en la aplicacion 
178                   //principal (wxContourGUIExample)tambien
179 //EED????               delete _theViewPanel;             
180 //EED????               delete _instantPanel;
181 //EED????               delete _buttonsBar;
182 //EED????               delete _actualInstant;           
183 //EED????               delete _sceneManager;
184         }
185
186
187         //------------------------------------------------------------------------------------------------------------
188         // Creational and initialization methods using WxAui
189         //------------------------------------------------------------------------------------------------------------
190         //
191         wxAuiNotebook * wxContourMainFrame :: createNotebook()
192         {
193                 wxSize client_size = GetClientSize();
194                 wxAuiNotebook* noteBook = new wxAuiNotebook(this, -1, wxPoint(client_size.x, client_size.y), wxSize(430,200), m_notebook_style);
195                 wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16));
196                 return noteBook;
197         }
198         
199
200         //------------------------------------------------------------------------------------------------------------
201         // Creational and initialization methods 
202         //------------------------------------------------------------------------------------------------------------
203         bool wxContourMainFrame :: configurePanels(wxAuiNotebook* theNoteBook)
204         {
205                 bool configured = _theViewPanel!=NULL;
206                                         
207                 configured &= _theViewPanel!=NULL;
208                 if( _theViewPanel!=NULL )
209                 {
210                         theNoteBook->AddPage( _theViewPanel, wxT("       View       ") );               
211                         m_mgr.Update();
212                 }
213
214
215                 if( configured )
216                 {
217                         theNoteBook->AddPage( _instantPanel, wxT("Instant Page") );
218                         m_mgr.Update();
219                 }
220
221                 m_mgr.AddPane(theNoteBook, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false));
222                 m_mgr.Update();
223 /*              configured &= _buttonsBar!=NULL;
224                 if( _buttonsBar!=NULL )
225                 {                       
226                         m_mgr.AddPane(_buttonsBar, wxAuiPaneInfo().
227                                         Name(wxT("TB")).Caption(wxT("Buttons Bar")).
228                                         ToolbarPane().Top().
229                                         LeftDockable(  ).RightDockable( false ).CloseButton(false));
230                         m_mgr.Update();
231                 }*/
232                 //CreateStatusBar();
233                          
234                 SetMinSize(wxSize(300,300));
235                 m_mgr.Update();
236                 return configured;
237         }
238
239         void wxContourMainFrame :: setNotebook( wxAuiNotebook * noteBook )
240         {
241
242         }
243
244         //------------------------------------------------------------------------------------------------------------
245         //  Attributes getters and setters
246         //------------------------------------------------------------------------------------------------------------
247         
248
249         
250         void wxContourMainFrame :: setInstantChooserPanel(  wxInstantChooserPanel * theInstantChooserPanel )
251         {
252                 _instantPanel = theInstantChooserPanel; 
253         }
254
255 //      void wxContourMainFrame :: setButtonsBar(  wxContour_ButtonsBar * theButtonsBar )
256 //      {
257 //              _buttonsBar = theButtonsBar;
258 //      }
259
260 //      void wxContourMainFrame :: setGrid(  wxContour_Grid * theGridPanel )
261 //      {
262 //              _gridPanel = theGridPanel;
263 //      }
264
265 //      void wxContourMainFrame :: setDrawToolsPanel(  wxContour_DrawToolsPanel * theDrawToolsPanel )
266 //      {
267 //              _drawToolsPanel = theDrawToolsPanel;
268 //      }
269
270 //      void wxContourMainFrame :: setOperationsToolsPanel(  wxContour_OperationsToolsPanel * theOperationsToolsPanel )
271 //      {       
272 //              _operationsToolsPanel = theOperationsToolsPanel;
273 //      }
274
275 //      void wxContourMainFrame :: setAutomaticFormsPanel(  wxContour_AutomaticFormsToolsPanel * theAutoFormsPanel )
276 //      {
277 //              _autoFormsPanel = theAutoFormsPanel;
278 //      }
279
280 //      void wxContourMainFrame :: setStandardToolsPanel(  wxContour_StandardToolsPanel * theStandardToolsPanel )
281 //      {
282 //              _standardToolsPanel= theStandardToolsPanel;
283 //      }
284
285 //      void wxContourMainFrame :: setEditionToolsPanel(  wxContour_EdtionToolsPanel * theEditionToolsPanel )
286 //      {
287 //              _editionToolsPanel =  theEditionToolsPanel;
288 //      }
289
290 //      void wxContourMainFrame :: setListViewPanel(  wxContour_ListViewPanel * theListViewPanel )
291 //      {
292 //              _listViewPanel = theListViewPanel;
293 //      }
294
295
296
297 void wxContourMainFrame::onCreateContourSpline( ){
298         
299         //JCP 20-10-08 Undo redo implementation
300         saveState();
301         //JCP 20-10-08 Undo redo implementation
302         createContour( 1 );
303         
304 }
305 void wxContourMainFrame::onCreateContourRectangle( ){
306     //JCP 20-10-08 Undo redo implementation
307         saveState();
308         //JCP 20-10-08 Undo redo implementation 
309         createContour( 2 );
310 }
311 void wxContourMainFrame::onCreateContourCircle( ){
312     //JCP 20-10-08 Undo redo implementation
313         saveState();
314         //JCP 20-10-08 Undo redo implementation 
315         createContour( 3 );
316 }
317 //------------------------------------------------------------------------------------------------------------
318
319 void wxContourMainFrame :: onCreateContourBullEye(wxPanel* panel )
320 {
321         //Creating the manualContourModel and including in the model
322         manualContourModel * manModelContour = factoryManualContourModel(panel );
323
324         std::vector<int> instantVector;
325         _instantPanel->getInstant( instantVector );
326         std::string theName = kernelManager->createOutline(manModelContour, instantVector);
327         
328         /*std::vector<int> instantVector;
329         _instantPanel->getInstant( instantVector );
330         std::string theName;
331         theName= _modelManager->createOutline( manModelContour, instantVector );*/
332         bool addedModel = theName.compare("") != 0;//??
333
334         if( addedModel )
335         {
336                 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
337                 _theViewPanel->getSpacing(spc);                                 
338                 //Adding the manualContourControler to interface objects structure
339                 //Adding the manualViewContour to interface objects structure           
340                 //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
341                 _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , 4) ;
342         }
343 }
344 void wxContourMainFrame :: createContour( int typeContour )
345 {
346         //Creating the manualContourModel and including in the model
347         manualContourModel * manModelContour = kernelManager->factoryManualContourModel(typeContour);
348
349
350         std::vector<int> instantVector;
351         _instantPanel->getInstant( instantVector );
352         std::string theName = kernelManager->createOutline(manModelContour, instantVector);
353         
354         /*std::vector<int> instantVector;
355         _instantPanel->getInstant( instantVector );
356         std::string theName;
357         theName= _modelManager->createOutline( manModelContour, instantVector );*/
358         bool addedModel = theName.compare("") != 0;//??
359         if( addedModel )
360         {
361                 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
362                 _theViewPanel->getSpacing(spc);                                 
363                 //Adding the manualContourControler to interface objects structure
364                 //Adding the manualViewContour to interface objects structure           
365                 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
366                 _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeContour) ;
367         }       
368
369 }
370 manualContourModel * wxContourMainFrame::factoryManualContourModel(wxPanel* panel){
371
372         manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
373         manualContourModel *manModelContour=NULL;
374         manModelContour = manModelContourBullEye;
375         if (panel!=NULL){
376                 int iCrown,sizeCrowns,iSector,sizeSectors;
377                 double radioA,radioB,ang,angDelta ;
378                 sizeCrowns = ((PanelBullEyeOptions*)panel)->GetNumberOfCrowns();
379                 for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
380                 {
381                         sizeSectors = ((PanelBullEyeOptions*)panel)->GetNumberOfSections(iCrown);
382                         radioB  = ((PanelBullEyeOptions*)panel)->GetRadioOfCrown(iCrown);
383                         if (iCrown==sizeCrowns-1)
384                         {
385                                 radioA  = 0;
386                         } else {
387                                 radioA  = ((PanelBullEyeOptions*)panel)->GetRadioOfCrown(iCrown+1);
388                         }
389                         radioA=radioA/100.0;
390                         radioB=radioB/100.0;
391                         for ( iSector=0 ; iSector<sizeSectors  ; iSector++ )
392                         {
393                                 ang             = ((PanelBullEyeOptions*)panel)->GetAngOfCrownSection(iCrown,iSector);
394                                 angDelta= ((PanelBullEyeOptions*)panel)->GetAngDeltaOfCrownSection(iCrown);                                     
395                                 manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
396                         } // for iSector
397                 } // for iCrown
398         } // if _panelBullEyeOptions
399         
400         return manModelContour;
401 }
402 void wxContourMainFrame :: saveState(){ 
403                 
404         std::string temp = kernelManager->saveState();
405         saveFileWithContours(temp);     
406 }
407
408 void wxContourMainFrame::onDeleteContour(){
409         //JCP 20-10-08 Undo redo implementation
410                 saveState();
411                 //JCP 20-10-08 Undo redo implementation
412
413                 std::vector<std::string> lstKeyNameToBeErase;
414                 lstKeyNameToBeErase             = _theViewPanel->getSceneManager()->getSelectedObjects();
415                 deleteContours( lstKeyNameToBeErase );
416 /*JCP 19 - 11 - 08
417                 int i,size=_sceneManager->getSelectedObjects().size();
418                 for(i=0;i<size;i++)
419                 {
420                         std::string keyName             = _sceneManager->getSelectedObjects()[i];
421                         int ispartofstaticlist  = this->_modelManager->IsPartOfStaticList( keyName );
422                         if ( ispartofstaticlist>=0 )
423                         {
424                                 std::vector<int> tempVector;
425                                 _instantPanel->getInstant( tempVector );
426                                 Instant instant(&tempVector);
427                                 this->_modelManager->ChangeContourOfList(keyName, &instant);
428                         }
429                 }
430
431                 std::vector<std::string> lstKeyName;
432                 std::vector<std::string> lstKeyNameActualSlice;
433                 std::vector<std::string> lstKeyNameToBeErase;
434
435                 lstKeyNameToBeErase             = _sceneManager->getSelectedObjects();
436                 lstKeyNameActualSlice   = _sceneManager->GetlstContoursNameActualSlice();
437                 int k,kSize=lstKeyNameToBeErase.size();
438                 int j,jSize=lstKeyNameActualSlice.size();
439                 bool ok;
440                 for (k=0;k<kSize; k++)
441                 {
442                         ok=false;
443                         for (j=0;j<jSize; j++)
444                         {
445                                 if (lstKeyNameToBeErase[k]==lstKeyNameActualSlice[j])
446                                 { 
447                                         ok=true;
448                                 }
449                         } // for j
450                         if (ok==true)
451                         {
452                                 lstKeyName.push_back( lstKeyNameToBeErase[k] );
453                         } // if ok
454                 } // for k
455
456                 deleteContours( lstKeyName );
457 JCP 19 - 11 - 08*/
458 }
459
460 void wxContourMainFrame :: deleteContours( std::vector<std::string>  keyNamesVector )
461 {
462         int i,size=keyNamesVector.size();
463         for (i=0;i<size;i++)
464         {
465                 deleteContour( keyNamesVector[i] );
466         }
467 }
468
469 void wxContourMainFrame :: deleteContour( std::string theKeyName ){
470         /*manualContourModel                    * cModel;
471         manualViewBaseContour           * cViewer;
472         manualContourBaseControler      * cControler;
473
474         ContourWrap_ViewControl *conwrapviewControl =  _theViewPanel->getSceneManager()->getContourWrap_ViewControlOf( theKeyName );
475         cControler      = conwrapviewControl->getControler();*/
476
477         //JCP 21 - 11 - 2008
478         bool isedit = _theViewPanel->isEditableCControler(theKeyName);
479         bool ispartofstaticlst = kernelManager->IsPartOfStaticList(theKeyName);
480
481         if (isedit  && ispartofstaticlst)
482         {
483                 _theViewPanel->removeFromScene(theKeyName);
484
485                 kernelManager->deleteCModel(theKeyName);
486                 //_theViewPanel->getSceneManager()->removeFromScene( theKeyName );                      
487                 //cViewer               = conwrapviewControl->getViewer();
488                 //_theViewPanel->getSceneManager()->removeWrap( theKeyName );
489                 //cControler* conwrapviewControl->getControler();                       
490 //EED Borrame
491 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
492 //fprintf(ff,"EED wxContourEventHandler::deleteContours() \n" );
493 //fprintf(ff,"    %s %p\n",keyNamesVector[i].c_str(),  cControler );
494 //fclose(ff);
495         //      delete cModel;
496         //      delete cViewer;
497         //      delete cControler;
498         } // if editable
499 //JCP 21 - 11 - 08
500 }
501
502 void wxContourMainFrame::onDeleteContoursActSlice(){
503         //JCP 20-10-08 Undo redo implementation
504         saveState();
505         //JCP 20-10-08 Undo redo implementation
506         deleteContours( (std::vector<std::string>)_theViewPanel->getSceneManager()->GetlstContoursNameActualSlice() );
507 }
508 void wxContourMainFrame::onDeleteAllContours(){
509         //JCP 20-10-08 Undo redo implementation
510         saveState();
511         deleteAllContours();
512 }
513 void wxContourMainFrame::deleteAllContours(){
514         //JCP 20-10-08 Undo redo implementation
515
516         wxBusyCursor wait;
517         std::vector<int> tempVector;
518         _instantPanel->getInstant( tempVector );
519
520 //JCP --08-09-2008 When using a diferent interface the _mbarrangeDeleteAll might not be initialize
521 //              the values in GetStart and GetEnd will then not be initialize also.
522 //              We use instead the values given when initializing the _deletepanel.
523
524         //int minZ = _mbarrangeDeleteAll->GetStart();
525         //int maxZ = _mbarrangeDeleteAll->GetEnd();
526         int minZ, maxZ;
527         
528         minZ = 0;
529         maxZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
530         
531 //JCP --08-09-2008
532         
533         _theViewPanel->getSceneManager()->removeSceneContours( );       
534         _theViewPanel->getSceneManager()->removeAllOutlines();
535         kernelManager->removeAllOutlines();     
536 //JCP --08-09-2008
537         /*
538         if ( (minZ==0) && (maxZ==_mbarrangeDeleteAll->GetMax() ))
539         {
540                 _theViewPanel->getSceneManager()->removeSceneContours( );
541                 _modelManager->removeAllOutlines();
542                 _theViewPanel->getSceneManager()->removeAllOutlines();
543
544         } else {
545                 for ( z=minZ ; z<=maxZ ; z++)
546                 {
547                         tempVector[1]=z;
548                         Instant instant(&tempVector);
549                         std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
550
551                         sizeLstContourThings = lstContourThings.size();
552                         for (ii=0 ; ii<sizeLstContourThings ; ii++)
553                         {
554                                 ContourThing **contourthing = lstContourThings[ii];
555                                 deleteContour( (*contourthing)->getName() );
556                         } //for ii
557                 }// for z
558         } // if 
559 JCP --08-09-2008 */
560 }
561
562 void wxContourMainFrame::setConceptValue( std::string name, int value ){
563         _instantPanel->setConceptValue(name, value);
564 }
565
566 ConceptDataWrap* wxContourMainFrame::getLastConceptData(){
567         return _instantPanel->getLastConceptData();
568 }
569 bool wxContourMainFrame::getIfConceptCheckedAt( std::string name, int pos ){
570         return _instantPanel->getIfConceptCheckedAt( name, pos );
571 }
572
573 void wxContourMainFrame::changeInstant(){
574                 std::vector<int> instantVect;
575                 _instantPanel->getInstant( instantVect );
576 //              Instant * theInstant = new Instant ( &instantVect );
577                 
578                 //Setting the actual instant
579                 //_actualInstant = theInstant;
580
581                 kernelManager->setInstant(instantVect);
582                 //_modelManager->setInstant( _actualInstant );
583                 
584                 updateInstantOutlines();
585                 updateInstantImageData();
586                 updateInstantAxes();
587
588                 
589 }
590 void wxContourMainFrame :: updateInstantOutlines(){
591         
592         _theViewPanel->removeSceneContours();
593         _theViewPanel->addNameWrapperToScene();
594
595         //for( int i=0; i<size; i++)
596         //{                     
597         //      _theViewPanel->getSceneManager()->addToScene(namesWrapping[i]->getKeyName(), true, true, true, false, false );
598         //}
599 }
600
601 int wxContourMainFrame::getNamesWrappingSize(){
602         return kernelManager->getNamesWrappingSize();
603 }
604 std::string wxContourMainFrame::getNameWrapping(int i){
605         return kernelManager->getNameWrapping(i);
606 }
607
608 void wxContourMainFrame::updateInstantImageData(){
609         std::vector<int> inst;
610         _instantPanel->getInstant(inst);
611
612         vtkImageData* img = kernelManager->getImageAtInstant(inst);
613         if(img!=NULL){
614                 _theViewPanel->changeImage(img);
615                 showAxis(false);
616         }else{
617                 int z = _instantPanel->getConceptDataOf("Axe Depth")->getActualValue();
618                 _theViewPanel->setImageSlice(z);
619         }
620 }
621 void wxContourMainFrame::updateInstantAxes(){
622 }
623
624 void wxContourMainFrame::onChangeDeep(int val){
625         _instantPanel->setConceptValue( "Axe Depth", (int)val );        
626         changeInstant();
627 }
628
629
630 void wxContourMainFrame::onCopy(){
631         std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
632
633         std::vector<int> tempVector;
634         _instantPanel->getInstant( tempVector );
635     _performingOperation->reset();
636         _performingOperation->setStartCommand( COPY );
637         _performingOperation->setStartOperationInstantVector( tempVector );
638         _performingOperation->setKeyNamesOperationElems( currentSelection );
639 }
640 void wxContourMainFrame::onPaste(){
641
642
643         char theStartCommand = _performingOperation->getStartCommand();
644         if (  theStartCommand == COPY )
645         {
646                 //JCP 20-10-08 Undo redo implementation
647                 saveState();
648                 //JCP 20-10-08 Undo redo implementation
649                 std::vector<int> tempVector;
650                 _instantPanel->getInstant( tempVector );
651                 _performingOperation->setEndOperationInstantVector ( tempVector );
652                 std::vector<std::string> elems = _performingOperation->getKeyNamesOperationElems();
653                 int i,size = elems.size();                      
654                 for( i=0; i<size; i++ )
655                 {                               
656                         createCopyContourOf( elems[i], tempVector, i>0 );
657                 }               
658         }
659 }
660 void wxContourMainFrame::onUndo(){
661         std::string filename;
662         if(kernelManager->onUndoSaveFile(filename)){
663                 saveFileWithContours(filename);
664         }
665         if(kernelManager->onUndo(filename)){
666                 loadState(filename);
667         }
668 }
669 void wxContourMainFrame::onRedo(){
670         std::string filename;
671         if(kernelManager->onRedo(filename)){
672                 loadState(filename);
673         }
674         
675 }
676 void wxContourMainFrame :: createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append ){
677         std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData );
678         manualContourModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel();
679         _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
680 }
681
682 void wxContourMainFrame ::loadState(std::string filename){
683         char tmp[255];
684         FILE *pFile=fopen(filename.c_str(),"r+");
685
686         fscanf(pFile,"%s",tmp); // --CreaContour--
687
688         fscanf(pFile,"%s",tmp); // Version
689         fscanf(pFile,"%s",tmp); // 1.0.1
690         std::string version(tmp);
691
692         deleteAllContours();
693
694         openContours(pFile,false);
695         if (version!="1.0.0"){
696                 openContours(pFile,true);
697         }
698
699         fclose(pFile);
700         
701         //_theViewPanel->getSceneManager()->removeSceneContours();
702         //changeInstant();
703
704 }
705
706 void wxContourMainFrame::onLoad(){
707         char tmp[255];
708         wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN );
709         if (dialog.ShowModal() == wxID_OK)
710         {
711                 std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
712                 FILE *pFile=fopen(fileNameContourROI.c_str(),"r+");
713
714                 fscanf(pFile,"%s",tmp); // --CreaContour--
715
716                 fscanf(pFile,"%s",tmp); // Version
717                 fscanf(pFile,"%s",tmp); // 1.0.1
718                 std::string version(tmp);
719
720                 openContours(pFile,false);
721                 if (version!="1.0.0"){
722                         openContours(pFile,true);
723                 }
724 //                        _theViewPanel->getSceneManager()->openFileWithContours(ff);
725
726                 fclose(pFile);
727         }
728         _theViewPanel->getSceneManager()->removeSceneContours();
729         changeInstant();
730 }
731 void wxContourMainFrame::onSave(){
732         wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE );
733         if (dialog.ShowModal() == wxID_OK)
734         {
735                 std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
736                 kernelManager->setCurrentFileName(fileNameContourROI);
737                 saveFileWithContours( fileNameContourROI );
738         }
739 }
740 void wxContourMainFrame::saveFileWithContours( std::string filename ){
741
742         FILE *pFile=fopen(filename.c_str(),"w+");
743         std::vector< std::string > lstNameThings;
744         int i,sizeLstNameThings; 
745
746         fprintf(pFile,"--CreaContour--\n");
747         fprintf(pFile,"Version %s\n", "1.0.1" );
748
749         // Normal Contours
750         lstNameThings           = kernelManager->GetLstNameThings();
751         sizeLstNameThings       = lstNameThings.size(); 
752         fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
753         for (i=0 ; i<sizeLstNameThings ; i++) 
754         {
755                 kernelManager->SaveThingName( pFile, lstNameThings[i] );
756                 _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
757         }// for i
758
759         //-- Contours Statics 
760         lstNameThings           = kernelManager->GetLstNameThingsStatic();
761         sizeLstNameThings       = lstNameThings.size(); 
762         fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings );
763         for (i=0 ; i<sizeLstNameThings ; i++) 
764         {
765                 kernelManager->SaveThingName( pFile, lstNameThings[i] );
766                 _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
767         }// for i
768         fclose(pFile);
769 }
770
771 void wxContourMainFrame::openContours( FILE *pFile, bool staticContour ){
772         char tmp[255];
773         fscanf(pFile,"%s",tmp); // NumberOfContours 
774         fscanf(pFile,"%s",tmp); // ##
775         int numberOfContours = atoi(tmp);  
776
777         std::vector<int> instantVector;
778         int typeContourModel;
779         manualContourModel *manModelContour;
780         int typeView;
781
782         int i;
783         for (i=0;i<numberOfContours;i++)
784         {
785                 instantVector.clear();
786                 fscanf(pFile,"%s",tmp); // Instant
787
788                 fscanf(pFile,"%s",tmp); // 1
789                 instantVector.push_back( atoi(tmp) );
790                 fscanf(pFile,"%s",tmp); // 2
791                 instantVector.push_back( atoi(tmp) );
792                 fscanf(pFile,"%s",tmp); // 3
793                 instantVector.push_back( atoi(tmp) );
794                 fscanf(pFile,"%s",tmp); // 4
795                 instantVector.push_back( atoi(tmp) );
796                 fscanf(pFile,"%s",tmp); // 5
797                 instantVector.push_back( atoi(tmp) );
798                 fscanf(pFile,"%s",tmp); // 6
799                 instantVector.push_back( atoi(tmp) );
800
801
802                 fscanf(pFile,"%s",tmp); // TypeContourModel
803                 fscanf(pFile,"%s",tmp); // ##
804                 typeContourModel = atoi(tmp);
805
806                 manModelContour =  kernelManager->factoryManualContourModel(typeContourModel);
807                 manModelContour->Open(pFile);
808
809                 fscanf(pFile,"%s",tmp); // TypeView
810                 fscanf(pFile,"%s",tmp); // ##
811                 typeView = atoi(tmp);  
812
813
814 //                      if (typeView==1) 
815 //                      {
816 //                      }
817
818
819                 std::string theName;
820                 theName = kernelManager->createOutline( manModelContour, instantVector );
821                 bool addedModel = theName.compare("") != 0;
822                 if( addedModel )
823                 {
824                         double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
825                         _theViewPanel->getSpacing(spc);                                 
826                         //Adding the manualContourControler to interface objects structure
827                         //Adding the manualViewContour to interface objects structure           
828                         //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
829                         _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
830                 }       
831
832                 if (staticContour==true)
833                 {
834                         Instant instant(&instantVector);
835                         kernelManager->changeContourOfManager( theName , &instant );
836                 }
837
838         }// for  numberOfContours
839
840 }
841
842 void wxContourMainFrame::RefreshInterface(){
843         changeInstant();
844         _theViewPanel->RefreshInterface();
845         //wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
846         //wxvtk2dbaseview->Refresh();
847 }
848
849 vtkImageData* wxContourMainFrame::getImageData(){
850         return _theViewPanel->getImageData();
851 }
852
853 void wxContourMainFrame::onSegmentationOneSlice(int isovalue,int sampling,int method){
854         
855         //JCP 20-10-08 Undo redo implementation
856         saveState();
857         //JCP 20-10-08 Undo redo implementation
858         
859         wxBusyCursor wait;
860         int                                     x                                       = _theViewPanel->GetX();
861         int                                     y                                       = _theViewPanel->GetY();
862         int                                     z                                       = _theViewPanel->GetZ();
863         SegmentationOneSlice( x,y,z,isovalue, sampling, method );
864         RefreshInterface();
865 }
866
867 void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method )
868 {               
869         int typeofcontour = 1;
870         //--Extracting Contour
871         //vtkImageData  *imagedata      = _theViewPanel->getSceneManager()->GetImageData();
872         vtkImageData    *imagedata      = getImageData();
873 //              double                  *range          = imagedata->GetScalarRange();  
874 //              double                  thr                     = 1;
875
876         vtkImageReslice *imageReslice = vtkImageReslice::New();
877 //EED
878 //              double spc[3];
879 //              imagedata->GetSpacing(spc);
880 //              x = x*spc[0];
881 //              y = y*spc[1];
882 //              z = z*spc[3];
883
884         imageReslice->SetInput( imagedata );
885         imageReslice->SetInformationInput(imagedata);
886         imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
887         imageReslice->SetResliceAxesOrigin(0,0,z);
888         imageReslice->SetOutputDimensionality(2);
889         imageReslice->SetInterpolationModeToLinear();
890
891         imagedata = imageReslice->GetOutput();
892         imagedata->Update();
893         imagedata->UpdateInformation();
894
895         vtkContourFilter* cntVTK = vtkContourFilter::New( );
896         cntVTK->SetInput( imagedata );
897
898         cntVTK->SetNumberOfContours( 1 );
899         //cntVTK->SetValue( 0, vmin );
900 //              cntVTK->SetValue( 0, (range[1]*thr/100) );
901         cntVTK->SetValue( 1, isovalue );
902 //      cntVTK->SetValue( 1, vmax );
903         cntVTK->Update( );
904         cntVTK->UpdateInformation();
905                 
906         vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
907         cpd->SetInput( cntVTK->GetOutput( ) );
908         cpd->ConvertLinesToPointsOff( );
909         cpd->Update( );
910         cpd->UpdateInformation();
911
912         vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
913         conn->SetExtractionModeToClosestPointRegion( );
914         //conn->SetMaxRecursionDepth( 3000 );
915                 
916         conn->SetInput( cpd->GetOutput( ) );
917                 
918         conn->SetClosestPoint( x, y, 0 );
919         conn->Update( );
920         conn->UpdateInformation();
921                 
922         vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( );
923         cpd2->SetInput( conn->GetOutput( ) );
924         cpd2->Update();
925         cpd2->UpdateInformation();
926
927         vtkStripper* vtkstripper = vtkStripper::New( );
928         vtkstripper->SetInput( cpd2->GetOutput() );
929         vtkstripper->Update();
930         vtkstripper->UpdateInformation();
931
932
933         vtkPolyData* polyDataResult =  vtkstripper->GetOutput();
934
935         polyDataResult->Update( );
936         polyDataResult->UpdateInformation();
937
938 /* EED
939 ofstream myfile;
940 myfile.open ("c:/temp/example.txt");
941 myfile << "\n";
942 polyDataResult->Print(myfile);
943 myfile << "-------------------------------------\n";
944 polyDataResult->GetLines()->Print(myfile);
945 myfile.close();
946 */
947
948         cntVTK          -> Delete();
949         cpd2            -> Delete();
950         cpd                     -> Delete();
951         conn            -> Delete();
952
953
954 //--Calculating control points
955
956         std::vector<double> vecX;
957         std::vector<double> vecY;
958         std::vector<double> vecZ;
959
960         std::vector<double> vecCtrlPointX;
961         std::vector<double> vecCtrlPointY;
962         std::vector<double> vecCtrlPointZ;
963
964
965         double *p;
966         int ii,size=polyDataResult->GetNumberOfPoints();
967         int id;
968         for (ii=1;ii<=size;ii++)
969         {
970                 id      = polyDataResult->GetLines()->GetData()->GetValue(ii);
971                 p       = polyDataResult->GetPoint(id);
972                 double x=p[0];
973                 double y=p[1];
974                 vecX.push_back( p[0] );
975                 vecY.push_back( p[1] );
976                 vecZ.push_back( -900 );
977 //                      vecZ.push_back( p[2] );
978         }
979
980
981         ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
982         extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
983
984 //PROOFS
985         /*if (methodRadiobox->GetSelection()==0){
986                 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
987         }
988         if (methodRadiobox->GetSelection()==1){
989                 extractcontrolpoints2d->GetControlPoints(  &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
990         }
991         if (methodRadiobox->GetSelection()==2){
992                 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
993                 extractcontrolpoints2d->GetSamplingControlPoints(  &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
994         }*/
995
996         if (method==0){
997                 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
998         }
999         else if (method==1){
1000                 extractcontrolpoints2d->GetControlPoints(  &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1001         }
1002         else if (method==2){
1003                 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
1004                 extractcontrolpoints2d->GetSamplingControlPoints(  &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1005         }
1006
1007         //--Adding contour to the system
1008
1009         std::vector<int> actualInstantVector;
1010         _instantPanel->getInstant( actualInstantVector );
1011         actualInstantVector[1]=z;
1012
1013         int j,sizeCtrPt = vecCtrlPointX.size();
1014         manualContourModel *manModelContour =  kernelManager->factoryManualContourModel( typeofcontour );
1015         manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 );
1016         if (sizeCtrPt>=3){
1017                 for (j=0 ; j<sizeCtrPt ; j++)
1018                 {
1019                         manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j]  );
1020                 } // for
1021                 std::string theName;
1022                 //theName = _modelManager->createOutline( manModelContour, actualInstantVector );
1023                 theName = kernelManager->createOutline( manModelContour, actualInstantVector );
1024                 bool addedModel = theName.compare("") != 0;
1025                 if( addedModel )
1026                 {
1027                         double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1028                         _theViewPanel->getSpacing(spc);                                 
1029                         //Adding the manualContourControler to interface objects structure
1030                         //Adding the manualViewContour to interface objects structure           
1031                         //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
1032                         _theViewPanel->configureViewControlTo(theName, manModelContour, spc, typeofcontour);
1033                         //_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ;
1034                 }       // if addedModel
1035         } // if sizeCtrPt
1036 }
1037
1038 int wxContourMainFrame::GetImageDataSizeZ(){
1039         return _theViewPanel->GetImageDataSizeZ();
1040 }
1041
1042 void wxContourMainFrame::GetImageDataRange(double *range){
1043         _theViewPanel->GetImageDataRange(range);
1044 }
1045
1046 void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method){
1047         //JCP 20-10-08 Undo redo implementation
1048         saveState();
1049         //JCP 20-10-08 Undo redo implementation
1050         
1051         wxBusyCursor wait;
1052         int                                     x                                       = _theViewPanel->GetX();
1053         int                                     y                                       = _theViewPanel->GetY();
1054         int z;
1055         double porcent; 
1056         wxString tmpString;     
1057         double totalZ = maxZ-minZ+1;
1058         for( z=minZ ; z<=maxZ ; z++ )
1059         {
1060                 porcent = 100.0* (z-minZ)/totalZ;
1061                 tmpString.Printf(_T("  %d %c            %d/%d            %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
1062                 interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(tmpString);
1063                 //_staticTextSegmentation->SetLabel(tmpString);
1064                 SegmentationOneSlice( x,y,z,isovalue, sampling,method );
1065         }
1066         interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(_T("   "));
1067         RefreshInterface();
1068 }
1069
1070 void wxContourMainFrame::showAxis(bool show){
1071         _theViewPanel->SetVisibleAxis(show);
1072         _theViewPanel->Refresh();
1073 }
1074
1075
1076 void wxContourMainFrame::onRigidPressed(){
1077         std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
1078         int elementsSelected = currentSelection.size();
1079
1080         if ( elementsSelected >= 1 ){
1081                 //JCP 20-10-08 Undo redo implementation
1082                 saveState();
1083                 //JCP 20-10-08 Undo redo implementation
1084
1085                 std::vector<int> tempVector;
1086                 _instantPanel->getInstant( tempVector );
1087                 Instant instant(&tempVector);
1088
1089                 int i , size=currentSelection.size();
1090                 for ( i=0 ; i<size ; i++ )
1091                 {
1092                         kernelManager->changeContourOfManager(currentSelection[i], &instant);
1093                 } // i
1094         }
1095 }
1096
1097 void wxContourMainFrame::onWidthOfContour(double width){
1098
1099         _theViewPanel->removeSceneContours();
1100         _theViewPanel->SetWidthContour(width);
1101         
1102         //_theViewPanel->getSceneManager()->SetWidthContour( width );
1103
1104         RefreshInterface();
1105 }
1106 int wxContourMainFrame::getColorWindow(){
1107         return _theViewPanel->getColorWindow();
1108 }
1109 int wxContourMainFrame::getWindowLevel(){
1110         return _theViewPanel->getWindowLevel();
1111 }
1112
1113 void wxContourMainFrame::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel){
1114         _theViewPanel->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
1115
1116         
1117         RefreshInterface();
1118 }
1119
1120 void wxContourMainFrame::onInterpolation(bool interpolate){
1121         _theViewPanel->onInterpolation(interpolate);    
1122         RefreshInterface();
1123 }
1124
1125 void wxContourMainFrame::onChangeInstant(std::string name,int actual){
1126         _instantPanel->setConceptValue( name, actual );
1127 }
1128
1129 void wxContourMainFrame::resetAppend(){
1130         kernelManager->resetAppend();
1131         
1132 }
1133
1134 void wxContourMainFrame::onSpreadAdd(){
1135         std::vector<double> vecX; 
1136         std::vector<double> vecY; 
1137         std::vector<double> vecZ; 
1138         _theViewPanel->GetPointsOfActualContour(&vecX , &vecY , &vecZ );
1139         
1140         std::vector<int> tempVector;
1141         _instantPanel->getInstant( tempVector );
1142
1143         std::string val = kernelManager->onSpreadAdd(&vecX , &vecY , &vecZ, tempVector);
1144
1145         interfMainPanel::getInstance()->appendStringSpread(val);
1146         
1147 }
1148
1149 void wxContourMainFrame::onSpreadGo(int type){
1150
1151         //JCP 20-10-08 Undo redo implementation
1152         saveState();
1153         //JCP 20-10-08 Undo redo implementation
1154
1155         wxBusyCursor wait;      
1156         std::vector<double> vecCtrlPointX;
1157         std::vector<double> vecCtrlPointY;
1158         std::vector<double> vecCtrlPointZ;
1159         double  minZ,maxZ;
1160         int z;
1161
1162         std::vector<int> tempVector;
1163         _instantPanel->getInstant( tempVector );
1164 //              tempVector[1];
1165
1166         kernelManager->getMaxMinZ(&minZ,&maxZ);
1167 //JSTG_16-07-08_----------------------------------------------------------------
1168         //_contourPropagation->setInterpolationNumber(maxZ-minZ+1);
1169         kernelManager->CalculeSplinePropagation();
1170
1171         double          totalZ = maxZ-minZ+1;
1172         double          porcent;
1173         wxString        tmpString;
1174 //--------------------------------------------------------------------
1175         for ( z=(int)minZ ; z<=(int)maxZ ; z++ )
1176         {
1177                 porcent = 100.0* (z-minZ)/totalZ;
1178                 int numero = (int)(z-minZ+1)/(int)totalZ;
1179                 std::string stringtemp = "  "+kernelManager->intToString(porcent)+"%            "+kernelManager->intToString(numero)+"            "+kernelManager->intToString(z);
1180                 
1181                 interfMainPanel::getInstance()->setStringSpread(stringtemp);    
1182
1183                 int typeofcontour = 1;
1184                 std::string theName;
1185                 manualContourModel* manModelContour = kernelManager->GetPoints(z, type, &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ, theName,typeofcontour, tempVector);
1186
1187                 if( manModelContour!=NULL ){
1188                         double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1189                         this->_theViewPanel->getSpacing(spc);                                   
1190                         //Adding the manualContourControler to interface objects structure
1191                         //Adding the manualViewContour to interface objects structure           
1192                         //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
1193                         _theViewPanel->configureViewControlTo( theName, manModelContour,spc,typeofcontour ) ;
1194                 } // if addedModel
1195         } 
1196         if(z > maxZ){
1197                 porcent = 100.0;
1198                 int numero = (int)(z-minZ+1)/(int)totalZ;
1199                 std::string stringtemp = "  "+kernelManager->intToString(porcent)+"%            "+kernelManager->intToString(numero)+"            "+kernelManager->intToString(z);
1200                 
1201                 interfMainPanel::getInstance()->setStringSpread(stringtemp);
1202         }// for z
1203         //RefreshInterface();
1204 }
1205
1206 void wxContourMainFrame::getInstantVector(std::vector<int>& tempVector){
1207         
1208 }
1209
1210 std::vector<std::string> wxContourMainFrame::getOutlinesName(int slide){
1211         std::vector<int> tempVector;
1212         _instantPanel->getInstant(tempVector);
1213         //Asignation of slide number should be different ex by name
1214         tempVector[1]=slide;
1215         return kernelManager->getOutlinesNameAtInstant(tempVector);
1216 }
1217
1218 void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ){
1219         int maxContourGroup     =       0;
1220
1221         ContourExtractData      *contourextractdata = new ContourExtractData();
1222         
1223         contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1224
1225         std::vector<manualContourModel*> lstManConMod;
1226         std::vector<manualContourModel*> lstManConModTmp;
1227         std::vector<manualContourModel*> lstManConModExp;
1228         std::vector<double> pLstValue;
1229         std::vector<double> pLstValuePosX;
1230         std::vector<double> pLstValuePosY;
1231         std::vector<double> pLstValuePosZ;
1232
1233         int             resultSize; 
1234         int             resultGrayRangeCount;
1235         double  resultMin; 
1236         double  resultMax;
1237         double  resultAverage;
1238         double  resultStandardeviation;
1239
1240         std::vector<int> tempVector;
1241         _instantPanel->getInstant( tempVector );
1242
1243         vtkImageData *imagedata = _theViewPanel->getImageData();
1244         int sizeZ = _theViewPanel->GetImageDataSizeZ();
1245         int z;
1246         int ii,sizeLstContourThings;
1247
1248
1249         int minZ,maxZ;
1250         double totalZ;
1251         double porcent; 
1252         wxString tmpString;
1253
1254         
1255
1256         if (selection==0 ) // actual slice
1257         {
1258                 std::vector<int> tempVector;
1259                 _instantPanel->getInstant( tempVector );
1260                 int actualSlice = tempVector[1];
1261                 minZ    = actualSlice;
1262                 maxZ    = actualSlice;
1263         }
1264         else if (selection==2 ) // All slices
1265         {
1266                 minZ    = 0;
1267                 maxZ    = sizeZ-1;
1268         }
1269         else if (selection==1 ) // slice range
1270         {
1271                 minZ    = minimumZ;
1272                 maxZ    = maximumZ;
1273         }
1274         
1275
1276         totalZ  = maxZ-minZ+1;
1277         contourextractdata->SetImage( imagedata);
1278
1279 // For each slice..
1280         for ( z=minZ ; z<=maxZ ; z++ )
1281         {
1282                 
1283                 porcent = 100.0* (z-minZ)/totalZ;
1284                 tmpString.Printf(_T("  %d %c            %d/%d             %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1285
1286                 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);          
1287                 //_staticTextInformation->SetLabel(tmpString);
1288
1289                 //Extraction data from contours of each slice
1290                 contourextractdata->SetZtoBeAnalys( z);
1291
1292                 tempVector[1]=z;
1293                 Instant instant(&tempVector);
1294                 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
1295                 sizeLstContourThings = lstContourThings.size();
1296
1297                 lstManConMod.clear();
1298                 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1299                 {
1300                         ContourThing **contourthing = lstContourThings[ii];
1301                         lstManConMod.push_back( (*contourthing)->getModel() );
1302                 }
1303                 lstManConModExp =  kernelManager->ExploseEachModel( lstManConMod );
1304
1305
1306                 wxString tempString;
1307                 tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
1308                 interfMainPanel::getInstance()->setRowLabelInfoPanel(z, tempString);
1309                 //_grid->SetRowLabelValue(z, tempString );
1310 //EED004
1311                 int iContourGroup,sizeContourGroup;
1312                 if (typeContourGroup==3) // contour separete
1313                 {
1314                         sizeContourGroup=lstManConModExp.size();
1315                         if ( maxContourGroup<sizeContourGroup ) 
1316                         {
1317                                 maxContourGroup=sizeContourGroup;
1318                         }
1319                 } else {  // contour AND OR XOR
1320                         sizeContourGroup=1;
1321                         maxContourGroup=1;
1322                 }
1323
1324                 int tmpIntA;
1325
1326
1327
1328                 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1329                         lstManConModTmp.clear();
1330                         if (typeContourGroup==3) // contour separete
1331                         {
1332                                 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1333                         } else {  // contour AND OR XOR
1334                                 lstManConModTmp = lstManConModExp;
1335                         }
1336
1337                         contourextractdata->SetLstManualContourModel( lstManConModTmp );
1338
1339                         pLstValue.clear();
1340                         pLstValuePosX.clear();
1341                         pLstValuePosY.clear();
1342                         pLstValuePosZ.clear();
1343                         contourextractdata->GetValuesInsideCrown(       &pLstValue,
1344                                                                                                                 &pLstValuePosX,
1345                                                                                                                 &pLstValuePosY,
1346                                                                                                                 &pLstValuePosZ);
1347                         // Statistics of each slice.
1348                         contourextractdata->Statistics( &pLstValue,
1349                                                                                         minimumZ,
1350                                                                                         maximumZ,
1351                                                                                         &resultGrayRangeCount, 
1352                                                                                         &resultSize, 
1353                                                                                         &resultMin, 
1354                                                                                         &resultMax,
1355                                                                                         &resultAverage,
1356                                                                                         &resultStandardeviation);
1357                         
1358                         if (interfMainPanel::getInstance()->getNumberColsInformationPanel()<_numberOfVariablesStatistics*(iContourGroup+1)  )
1359                         {
1360                                 interfMainPanel::getInstance()->appendColsInformationPanel(_numberOfVariablesStatistics);
1361                         }
1362
1363                         tmpIntA=_numberOfVariablesStatistics*iContourGroup ;
1364
1365                         tempString.Printf(_T("%d"),resultSize);
1366                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA, tempString);  
1367
1368                         tempString.Printf(_T("%d"),resultGrayRangeCount);
1369                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+1, tempString);
1370                         
1371                         tempString.Printf(_T("%f"),resultMin);
1372                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+2, tempString);
1373                         
1374                         tempString.Printf(_T("%f"),resultMax);
1375                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+3, tempString);
1376                         
1377                         tempString.Printf(_T("%f"),resultAverage);
1378                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+4, tempString);
1379                         
1380                         tempString.Printf(_T("%f"),resultStandardeviation);
1381                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+5, tempString);
1382                         
1383
1384                 } // for iContourGroup
1385         } // for z
1386
1387         int iTitleGroup;
1388         wxString tmpTitleString;
1389         int tmpIntB;
1390         for ( iTitleGroup=0 ; iTitleGroup<maxContourGroup ; iTitleGroup++ )
1391         {
1392                 tmpIntB =_numberOfVariablesStatistics*iTitleGroup;
1393                 tmpTitleString.Printf(_T("%d-Size Data"),iTitleGroup);
1394                 interfMainPanel::getInstance()->setColLableInfoPanel(tmpIntB + 0, tmpTitleString);
1395
1396                 interfMainPanel::getInstance()->setColLableInfoPanel(tmpIntB + 0, tmpTitleString );
1397                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 1, _T("Size Range") );
1398                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 2, _T("Min") );
1399                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 3, _T("Max") );
1400                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 4, _T("Average") );
1401                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 5, _T("St.Dev.") );
1402                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 6, _T(" ") );
1403         }
1404
1405         interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
1406         delete contourextractdata;
1407 }
1408
1409 void wxContourMainFrame::onSaveResults(std::string directory,std::string namefile, std::string filename, int typeContourGroup){
1410     SaveValuesXYZ( directory , namefile, typeContourGroup );
1411         SaveImageResult( directory , namefile, typeContourGroup);
1412
1413         
1414         FILE *pFile=fopen(filename.c_str(),"w+");
1415
1416         int sizeZ = _theViewPanel->GetImageDataSizeZ();
1417
1418         wxString tmpString;
1419         int i,j,maxX,maxY=sizeZ;
1420         maxX= interfMainPanel::getInstance()->getNumberColsInformationPanel();//this->_grid->GetNumberCols();
1421
1422         int iTitle,sizeTitle = (maxX / _numberOfVariablesStatistics);
1423         for ( iTitle=0; iTitle<sizeTitle ; iTitle++)
1424         {
1425                 fprintf(pFile,"-- \t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle,tmpString.c_str() );
1426         }
1427         fprintf(pFile,"\n" );
1428
1429
1430
1431         for ( j=0; j<maxY ; j++)
1432         {
1433                 fprintf(pFile,"%d\t" , j );
1434                 for (i=0 ; i<maxX ; i++){
1435                         tmpString = interfMainPanel::getInstance()->getCellValue(j, i);//_grid->GetCellValue( j , i );
1436                         fprintf(pFile,"%s\t" , (const char *)(tmpString.mb_str()) );
1437                 } // for i
1438                 fprintf(pFile,"\n"  );
1439         } // for j
1440
1441         fclose(pFile);
1442 }
1443
1444 void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefile,int typeContourGroup)
1445 {
1446         wxBusyCursor wait;
1447         ContourExtractData      *contourextractdata = new ContourExtractData();
1448         //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
1449         contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1450
1451         std::vector<manualContourModel*> lstManConMod;
1452         std::vector<manualContourModel*> lstManConModTmp;
1453         std::vector<manualContourModel*> lstManConModExp;
1454         std::vector<double> pLstValue;
1455         std::vector<double> pLstValuePosX;
1456         std::vector<double> pLstValuePosY;
1457         std::vector<double> pLstValuePosZ;
1458
1459         std::vector<int> tempVector;
1460         _instantPanel->getInstant( tempVector );
1461
1462         vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
1463         int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
1464         int z;
1465         int ii,sizeLstContourThings;
1466
1467
1468         int minZ,maxZ;
1469         double totalZ;
1470         double porcent; 
1471         wxString tmpString;
1472         minZ    = 0;// _mbarrange->GetStart();
1473         maxZ    = sizeZ;//_mbarrange->GetEnd();
1474         totalZ  = maxZ-minZ+1;
1475
1476         contourextractdata->SetImage( imagedata);
1477
1478 // For each slice..
1479         for ( z=0 ; z<sizeZ ; z++)
1480         {
1481
1482                 porcent = 100.0* (z-minZ)/totalZ;
1483                 
1484                 tmpString.Printf(_T("Saving Values"));
1485                 tmpString.Printf(_T("  %d %c            %d/%d             %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1486                 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
1487                 //_staticTextInformation->SetLabel(tmpString);
1488
1489
1490                 //Extraction data from contours of each slice
1491                 contourextractdata->SetZtoBeAnalys( z);
1492
1493                 tempVector[1]=z;
1494                 Instant instant(&tempVector);
1495                 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant(&instant);//this->_modelManager->getOutlinesAtInstant( &instant );
1496                 sizeLstContourThings = lstContourThings.size();
1497
1498                 lstManConMod.clear();
1499                 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1500                 {
1501                         ContourThing **contourthing = lstContourThings[ii];
1502                         lstManConMod.push_back( (*contourthing)->getModel() );
1503                 }
1504                 lstManConModExp =  kernelManager->ExploseEachModel( lstManConMod );
1505
1506
1507 //EED004
1508
1509                 int iContourGroup,sizeContourGroup;
1510                 if (typeContourGroup==3) // contour separete
1511                 {
1512                         sizeContourGroup=lstManConModExp.size();
1513                 } else {  // contour AND OR XOR
1514                         sizeContourGroup=1;
1515                 }
1516
1517                 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1518                         lstManConModTmp.clear();
1519                         if (typeContourGroup==3) // contour separete
1520                         {
1521                                 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1522                         } else {  // contour AND OR XOR
1523                                 lstManConModTmp = lstManConModExp;
1524                         }
1525
1526                         contourextractdata->SetLstManualContourModel( lstManConModTmp );
1527
1528                         pLstValue.clear();
1529                         pLstValuePosX.clear();
1530                         pLstValuePosY.clear();
1531                         pLstValuePosZ.clear();
1532                         contourextractdata->GetValuesInsideCrown(       &pLstValue,
1533                                                                                                                 &pLstValuePosX,
1534                                                                                                                 &pLstValuePosY,
1535                                                                                                                 &pLstValuePosZ);
1536
1537                         std::string temp = directory + "/" + namefile + "-slice";
1538                         temp = temp + kernelManager->intToString(z) + "-cont" + kernelManager->intToString(iContourGroup);
1539                         temp = temp + ".txt";
1540
1541                         // LG 14/01/09 : using crea
1542                         wxString filename = crea::std2wx(temp);
1543                         /*filename.Printf(_T("%s"),directory.c_str());
1544                         filename.append(_T("\\"));
1545                         filename.append(_T("%s"),namefile.c_str());
1546                         filename.append(_T("-slice"));
1547                         filename.append(_T("%d"),z);
1548                         filename.append(_T("-cont"));
1549                         filename.append(_T("%d"),iContourGroup);
1550                         filename.append(_T(".txt"));*/
1551                         //                      filename.Printf(temp.c_str());
1552
1553                         
1554
1555                         FILE *pFile=fopen((const char *)filename.mb_str(),"w+");
1556                         fprintf(pFile,"value \t x \t y \t z\n"  );
1557                         int iLstValue,sizeLstValue=pLstValue.size();
1558                         for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
1559                         {
1560                                 fprintf(pFile,"%f\t %f\t %f\t %f\n", (float)pLstValue[iLstValue] , (float)pLstValuePosX[iLstValue], (float)pLstValuePosY[iLstValue], (float)z );
1561                         }
1562                         fclose(pFile);
1563                 } // for  iContourGroup
1564         } // for z
1565         interfMainPanel::getInstance()->setStringInfoPanel(_T(""));
1566         //_staticTextInformation->SetLabel( _T("") );
1567         delete contourextractdata;
1568 }
1569
1570 void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, int typeContourGroup)
1571 {
1572         wxBusyCursor wait;
1573         ContourExtractData      *contourextractdata = new ContourExtractData( true );
1574         //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
1575         if (typeContourGroup==3)
1576         {
1577                 typeContourGroup=1;
1578         }
1579         contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1580
1581         std::vector<manualContourModel*> lstManConMod;
1582         std::vector<manualContourModel*> lstManConModTmp;
1583         std::vector<manualContourModel*> lstManConModExp;
1584
1585         std::vector<int> tempVector;
1586         _instantPanel->getInstant( tempVector );
1587
1588         vtkImageData *imagedata = _theViewPanel->getImageData();
1589         int sizeZ = _theViewPanel->GetImageDataSizeZ();
1590         int z;
1591         int ii,sizeLstContourThings;
1592
1593
1594         int minZ,maxZ;
1595         double totalZ;
1596         double porcent; 
1597
1598         wxString tmpString;
1599
1600         minZ    = 0;// _mbarrange->GetStart();
1601         maxZ    = sizeZ;//_mbarrange->GetEnd();
1602         totalZ  = maxZ-minZ+1;
1603
1604         contourextractdata->SetImage( imagedata);
1605
1606 // For each slice..
1607         for ( z=0 ; z<sizeZ ; z++)
1608         {
1609
1610                 porcent = 100.0* (z-minZ)/totalZ;
1611                 tmpString.Printf(_T("Saving Values"));
1612                 tmpString.Printf(_T("%d %c            %d/%d             %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1613                 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
1614
1615                 //Extraction data from contours of each slice
1616                 contourextractdata->SetZtoBeAnalys( z);
1617
1618                 tempVector[1]=z;
1619                 Instant instant(&tempVector);
1620                 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
1621                 sizeLstContourThings = lstContourThings.size();
1622
1623                 lstManConMod.clear();
1624                 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1625                 {
1626                         ContourThing **contourthing = lstContourThings[ii];
1627                         lstManConMod.push_back( (*contourthing)->getModel() );
1628                 }
1629                 lstManConModExp =  kernelManager->ExploseEachModel( lstManConMod );
1630
1631
1632                 int iContourGroup,sizeContourGroup;
1633                 if (typeContourGroup==3) // contour separete
1634                 {
1635                         sizeContourGroup=lstManConModExp.size();
1636                 } else {  // contour AND OR XOR
1637                         sizeContourGroup=1;
1638                 }
1639
1640                 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1641                         lstManConModTmp.clear();
1642                         if (typeContourGroup==3) // contour separete
1643                         {
1644                                 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1645                         } else {  // contour AND OR XOR
1646                                 lstManConModTmp = lstManConModExp;
1647                         }
1648
1649                         contourextractdata->SetLstManualContourModel( lstManConModTmp );
1650
1651
1652 //                              for (ii=0 ; ii<sizeLstContourThings ; ii++)
1653 //                              {
1654 //                                      ContourThing **contourthing = lstContourThings[ii];
1655 //                                      lstManConMod.push_back( (*contourthing)->getModel() );
1656 //                              }
1657 //                              contourextractdata->SetLstManualContourModel( lstManConMod );
1658
1659                         contourextractdata->CalculateImageResult(); // with actual Z
1660
1661                 } // for  iContourGroup
1662         } // for z
1663
1664         std::string temp = directory + "/" + namefile + "-Value.mhd";
1665
1666         wxString filename = crea::std2wx(temp);
1667         // LG 
1668         //      filename.Printf(_T(temp.c_str()));
1669         //filename.Printf(_T("%s\\%s-Value.mhd",directory.c_str(),namefile.c_str(),z);
1670         /*filename.Printf(_T("%s"),directory.c_str());
1671         filename.append(_T("\\"));
1672         filename.append(_T("%s"),namefile.c_str());
1673         filename.append(_T("-Value.mhd"));*/
1674
1675 // Image Value
1676         vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
1677         writerValueImage->SetInput( contourextractdata->GetVtkImageValueResult() );
1678         writerValueImage->SetFileName( (const char *)filename.mb_str() );
1679         writerValueImage->SetFileDimensionality( 3 );
1680         writerValueImage->Write( );
1681
1682 // Image Mask
1683         //              filename.Printf("%s\\%s-Mask.mhd",directory.c_str(),namefile.c_str(),z);
1684         temp = directory + "/" + namefile + "-Mask.mhd";
1685
1686         // LG 14/01/09 : using crea
1687         filename = crea::std2wx(temp);
1688         //      filename.Printf(_T(temp.c_str()));
1689
1690         /*filename.Printf(_T("%s"),directory.c_str());
1691         filename.append(_T("\\"));
1692         filename.append(_T("%s"),namefile.c_str());
1693         filename.append(_T("-Mask.mhd"));*/
1694
1695         vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( );
1696         writerMaskImage->SetInput( contourextractdata->GetVtkImageMaskResult() );
1697         writerMaskImage->SetFileName( (const char *)filename.mb_str() );
1698         writerMaskImage->SetFileDimensionality( 3 );
1699         writerMaskImage->Write( );
1700
1701         interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
1702         delete contourextractdata;
1703 }
1704
1705 void wxContourMainFrame::onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow){
1706         if( name.compare( _theViewPanel->getVerticalConceptName() ) == 0){
1707                 _theViewPanel->setActualVertical( value);
1708         }
1709         else if( name.compare( _theViewPanel->getHorizontalConceptName() ) == 0|| _instantPanel->getIfConceptCheckedAt( name, 0 ) )     {
1710                 _theViewPanel->setHorizontalConcept( name, minshow, maxshow, minshow, maxshow, value);
1711         }
1712
1713         changeInstant();
1714 }
1715
1716 void wxContourMainFrame::onSnakePressed(){
1717         std::vector<double> vecX; 
1718         std::vector<double> vecY; 
1719         std::vector<double> vecZ; 
1720         _theViewPanel->GetPointsOfActualContour( &vecX , &vecY , &vecZ );       
1721
1722         if (vecX.size()!=0){
1723                 std::vector<int> tempVector;
1724                 _instantPanel->getInstant( tempVector );
1725                 int i,size=vecZ.size();
1726                 int actualSlice = tempVector[1];
1727                 for ( i=0 ; i<size ; i++ )
1728                 {
1729                         vecZ[i] = actualSlice;
1730                 } // for
1731
1732                 wxDialog* dialog = new wxDialog(this, -1, wxString(_T("Snake")));
1733                 wxPanel* panel = new wxPanel(dialog,-1); 
1734                 wxStaticText* sttext = new wxStaticText(panel, -1, wxString(_T("Panel para snake")));
1735                 dialog->ShowModal();
1736         } // if 
1737
1738 }
1739
1740 void wxContourMainFrame::saveFileWithContoursAutomatique(){
1741         std::string filename = kernelManager->getCurrentFileName();
1742         if(filename.compare("")!=0){
1743                 saveFileWithContours(filename);
1744         }else{
1745                 onSave();
1746         }
1747 }