]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
d2cbf44baad53e81bf2512ed2d9bdc8b011b9228
[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         }else{
616                 int z = _instantPanel->getConceptDataOf("Axe Depth")->getActualValue();
617                 _theViewPanel->setImageSlice(z);
618         }
619 }
620 void wxContourMainFrame::updateInstantAxes(){
621 }
622
623 void wxContourMainFrame::onChangeDeep(int val){
624         _instantPanel->setConceptValue( "Axe Depth", (int)val );        
625         changeInstant();
626 }
627
628
629 void wxContourMainFrame::onCopy(){
630         std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
631
632         std::vector<int> tempVector;
633         _instantPanel->getInstant( tempVector );
634     _performingOperation->reset();
635         _performingOperation->setStartCommand( COPY );
636         _performingOperation->setStartOperationInstantVector( tempVector );
637         _performingOperation->setKeyNamesOperationElems( currentSelection );
638 }
639 void wxContourMainFrame::onPaste(){
640
641
642         char theStartCommand = _performingOperation->getStartCommand();
643         if (  theStartCommand == COPY )
644         {
645                 //JCP 20-10-08 Undo redo implementation
646                 saveState();
647                 //JCP 20-10-08 Undo redo implementation
648                 std::vector<int> tempVector;
649                 _instantPanel->getInstant( tempVector );
650                 _performingOperation->setEndOperationInstantVector ( tempVector );
651                 std::vector<std::string> elems = _performingOperation->getKeyNamesOperationElems();
652                 int i,size = elems.size();                      
653                 for( i=0; i<size; i++ )
654                 {                               
655                         createCopyContourOf( elems[i], tempVector, i>0 );
656                 }               
657         }
658 }
659 void wxContourMainFrame::onUndo(){
660         std::string filename;
661         if(kernelManager->onUndoSaveFile(filename)){
662                 saveFileWithContours(filename);
663         }
664         if(kernelManager->onUndo(filename)){
665                 loadState(filename);
666         }
667 }
668 void wxContourMainFrame::onRedo(){
669         std::string filename;
670         if(kernelManager->onRedo(filename)){
671                 loadState(filename);
672         }
673         
674 }
675 void wxContourMainFrame :: createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append ){
676         std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData );
677         manualContourModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel();
678         _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
679 }
680
681 void wxContourMainFrame ::loadState(std::string filename){
682         char tmp[255];
683         FILE *pFile=fopen(filename.c_str(),"r+");
684
685         fscanf(pFile,"%s",tmp); // --CreaContour--
686
687         fscanf(pFile,"%s",tmp); // Version
688         fscanf(pFile,"%s",tmp); // 1.0.1
689         std::string version(tmp);
690
691         deleteAllContours();
692
693         openContours(pFile,false);
694         if (version!="1.0.0"){
695                 openContours(pFile,true);
696         }
697
698         fclose(pFile);
699         
700         //_theViewPanel->getSceneManager()->removeSceneContours();
701         //changeInstant();
702
703 }
704
705 void wxContourMainFrame::onLoad(){
706         char tmp[255];
707         wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN );
708         if (dialog.ShowModal() == wxID_OK)
709         {
710                 std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
711                 FILE *pFile=fopen(fileNameContourROI.c_str(),"r+");
712
713                 fscanf(pFile,"%s",tmp); // --CreaContour--
714
715                 fscanf(pFile,"%s",tmp); // Version
716                 fscanf(pFile,"%s",tmp); // 1.0.1
717                 std::string version(tmp);
718
719                 openContours(pFile,false);
720                 if (version!="1.0.0"){
721                         openContours(pFile,true);
722                 }
723 //                        _theViewPanel->getSceneManager()->openFileWithContours(ff);
724
725                 fclose(pFile);
726         }
727         _theViewPanel->getSceneManager()->removeSceneContours();
728         changeInstant();
729 }
730 void wxContourMainFrame::onSave(){
731         wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE );
732         if (dialog.ShowModal() == wxID_OK)
733         {
734                 std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
735                 saveFileWithContours( fileNameContourROI );
736         }
737 }
738 void wxContourMainFrame::saveFileWithContours( std::string filename ){
739
740         FILE *pFile=fopen(filename.c_str(),"w+");
741         std::vector< std::string > lstNameThings;
742         int i,sizeLstNameThings; 
743
744         fprintf(pFile,"--CreaContour--\n");
745         fprintf(pFile,"Version %s\n", "1.0.1" );
746
747         // Normal Contours
748         lstNameThings           = kernelManager->GetLstNameThings();
749         sizeLstNameThings       = lstNameThings.size(); 
750         fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
751         for (i=0 ; i<sizeLstNameThings ; i++) 
752         {
753                 kernelManager->SaveThingName( pFile, lstNameThings[i] );
754                 _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
755         }// for i
756
757         //-- Contours Statics 
758         lstNameThings           = kernelManager->GetLstNameThingsStatic();
759         sizeLstNameThings       = lstNameThings.size(); 
760         fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings );
761         for (i=0 ; i<sizeLstNameThings ; i++) 
762         {
763                 kernelManager->SaveThingName( pFile, lstNameThings[i] );
764                 _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
765         }// for i
766         fclose(pFile);
767 }
768
769 void wxContourMainFrame::openContours( FILE *pFile, bool staticContour ){
770         char tmp[255];
771         fscanf(pFile,"%s",tmp); // NumberOfContours 
772         fscanf(pFile,"%s",tmp); // ##
773         int numberOfContours = atoi(tmp);  
774
775         std::vector<int> instantVector;
776         int typeContourModel;
777         manualContourModel *manModelContour;
778         int typeView;
779
780         int i;
781         for (i=0;i<numberOfContours;i++)
782         {
783                 instantVector.clear();
784                 fscanf(pFile,"%s",tmp); // Instant
785
786                 fscanf(pFile,"%s",tmp); // 1
787                 instantVector.push_back( atoi(tmp) );
788                 fscanf(pFile,"%s",tmp); // 2
789                 instantVector.push_back( atoi(tmp) );
790                 fscanf(pFile,"%s",tmp); // 3
791                 instantVector.push_back( atoi(tmp) );
792                 fscanf(pFile,"%s",tmp); // 4
793                 instantVector.push_back( atoi(tmp) );
794                 fscanf(pFile,"%s",tmp); // 5
795                 instantVector.push_back( atoi(tmp) );
796                 fscanf(pFile,"%s",tmp); // 6
797                 instantVector.push_back( atoi(tmp) );
798
799
800                 fscanf(pFile,"%s",tmp); // TypeContourModel
801                 fscanf(pFile,"%s",tmp); // ##
802                 typeContourModel = atoi(tmp);
803
804                 manModelContour =  kernelManager->factoryManualContourModel(typeContourModel);
805                 manModelContour->Open(pFile);
806
807                 fscanf(pFile,"%s",tmp); // TypeView
808                 fscanf(pFile,"%s",tmp); // ##
809                 typeView = atoi(tmp);  
810
811
812 //                      if (typeView==1) 
813 //                      {
814 //                      }
815
816
817                 std::string theName;
818                 theName = kernelManager->createOutline( manModelContour, instantVector );
819                 bool addedModel = theName.compare("") != 0;
820                 if( addedModel )
821                 {
822                         double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
823                         _theViewPanel->getSpacing(spc);                                 
824                         //Adding the manualContourControler to interface objects structure
825                         //Adding the manualViewContour to interface objects structure           
826                         //_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.
827                         _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
828                 }       
829
830                 if (staticContour==true)
831                 {
832                         Instant instant(&instantVector);
833                         kernelManager->changeContourOfManager( theName , &instant );
834                 }
835
836         }// for  numberOfContours
837
838 }
839
840 void wxContourMainFrame::RefreshInterface(){
841         changeInstant();
842         _theViewPanel->RefreshInterface();
843         //wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
844         //wxvtk2dbaseview->Refresh();
845 }
846
847 vtkImageData* wxContourMainFrame::getImageData(){
848         return _theViewPanel->getImageData();
849 }
850
851 void wxContourMainFrame::onSegmentationOneSlice(int isovalue,int sampling,int method){
852         
853         //JCP 20-10-08 Undo redo implementation
854         saveState();
855         //JCP 20-10-08 Undo redo implementation
856         
857         wxBusyCursor wait;
858         int                                     x                                       = _theViewPanel->GetX();
859         int                                     y                                       = _theViewPanel->GetY();
860         int                                     z                                       = _theViewPanel->GetZ();
861         SegmentationOneSlice( x,y,z,isovalue, sampling, method );
862         RefreshInterface();
863 }
864
865 void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method )
866 {               
867         int typeofcontour = 1;
868         //--Extracting Contour
869         //vtkImageData  *imagedata      = _theViewPanel->getSceneManager()->GetImageData();
870         vtkImageData    *imagedata      = getImageData();
871 //              double                  *range          = imagedata->GetScalarRange();  
872 //              double                  thr                     = 1;
873
874         vtkImageReslice *imageReslice = vtkImageReslice::New();
875 //EED
876 //              double spc[3];
877 //              imagedata->GetSpacing(spc);
878 //              x = x*spc[0];
879 //              y = y*spc[1];
880 //              z = z*spc[3];
881
882         imageReslice->SetInput( imagedata );
883         imageReslice->SetInformationInput(imagedata);
884         imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
885         imageReslice->SetResliceAxesOrigin(0,0,z);
886         imageReslice->SetOutputDimensionality(2);
887         imageReslice->SetInterpolationModeToLinear();
888
889         imagedata = imageReslice->GetOutput();
890         imagedata->Update();
891         imagedata->UpdateInformation();
892
893         vtkContourFilter* cntVTK = vtkContourFilter::New( );
894         cntVTK->SetInput( imagedata );
895
896         cntVTK->SetNumberOfContours( 1 );
897         //cntVTK->SetValue( 0, vmin );
898 //              cntVTK->SetValue( 0, (range[1]*thr/100) );
899         cntVTK->SetValue( 1, isovalue );
900 //      cntVTK->SetValue( 1, vmax );
901         cntVTK->Update( );
902         cntVTK->UpdateInformation();
903                 
904         vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
905         cpd->SetInput( cntVTK->GetOutput( ) );
906         cpd->ConvertLinesToPointsOff( );
907         cpd->Update( );
908         cpd->UpdateInformation();
909
910         vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
911         conn->SetExtractionModeToClosestPointRegion( );
912         //conn->SetMaxRecursionDepth( 3000 );
913                 
914         conn->SetInput( cpd->GetOutput( ) );
915                 
916         conn->SetClosestPoint( x, y, 0 );
917         conn->Update( );
918         conn->UpdateInformation();
919                 
920         vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( );
921         cpd2->SetInput( conn->GetOutput( ) );
922         cpd2->Update();
923         cpd2->UpdateInformation();
924
925         vtkStripper* vtkstripper = vtkStripper::New( );
926         vtkstripper->SetInput( cpd2->GetOutput() );
927         vtkstripper->Update();
928         vtkstripper->UpdateInformation();
929
930
931         vtkPolyData* polyDataResult =  vtkstripper->GetOutput();
932
933         polyDataResult->Update( );
934         polyDataResult->UpdateInformation();
935
936 /* EED
937 ofstream myfile;
938 myfile.open ("c:/temp/example.txt");
939 myfile << "\n";
940 polyDataResult->Print(myfile);
941 myfile << "-------------------------------------\n";
942 polyDataResult->GetLines()->Print(myfile);
943 myfile.close();
944 */
945
946         cntVTK          -> Delete();
947         cpd2            -> Delete();
948         cpd                     -> Delete();
949         conn            -> Delete();
950
951
952 //--Calculating control points
953
954         std::vector<double> vecX;
955         std::vector<double> vecY;
956         std::vector<double> vecZ;
957
958         std::vector<double> vecCtrlPointX;
959         std::vector<double> vecCtrlPointY;
960         std::vector<double> vecCtrlPointZ;
961
962
963         double *p;
964         int ii,size=polyDataResult->GetNumberOfPoints();
965         int id;
966         for (ii=1;ii<=size;ii++)
967         {
968                 id      = polyDataResult->GetLines()->GetData()->GetValue(ii);
969                 p       = polyDataResult->GetPoint(id);
970                 double x=p[0];
971                 double y=p[1];
972                 vecX.push_back( p[0] );
973                 vecY.push_back( p[1] );
974                 vecZ.push_back( -900 );
975 //                      vecZ.push_back( p[2] );
976         }
977
978
979         ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
980         extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
981
982 //PROOFS
983         /*if (methodRadiobox->GetSelection()==0){
984                 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
985         }
986         if (methodRadiobox->GetSelection()==1){
987                 extractcontrolpoints2d->GetControlPoints(  &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
988         }
989         if (methodRadiobox->GetSelection()==2){
990                 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
991                 extractcontrolpoints2d->GetSamplingControlPoints(  &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
992         }*/
993
994         if (method==0){
995                 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
996         }
997         else if (method==1){
998                 extractcontrolpoints2d->GetControlPoints(  &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
999         }
1000         else if (method==2){
1001                 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
1002                 extractcontrolpoints2d->GetSamplingControlPoints(  &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1003         }
1004
1005         //--Adding contour to the system
1006
1007         std::vector<int> actualInstantVector;
1008         _instantPanel->getInstant( actualInstantVector );
1009         actualInstantVector[1]=z;
1010
1011         int j,sizeCtrPt = vecCtrlPointX.size();
1012         manualContourModel *manModelContour =  kernelManager->factoryManualContourModel( typeofcontour );
1013         manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 );
1014         if (sizeCtrPt>=3){
1015                 for (j=0 ; j<sizeCtrPt ; j++)
1016                 {
1017                         manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j]  );
1018                 } // for
1019                 std::string theName;
1020                 //theName = _modelManager->createOutline( manModelContour, actualInstantVector );
1021                 theName = kernelManager->createOutline( manModelContour, actualInstantVector );
1022                 bool addedModel = theName.compare("") != 0;
1023                 if( addedModel )
1024                 {
1025                         double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1026                         _theViewPanel->getSpacing(spc);                                 
1027                         //Adding the manualContourControler to interface objects structure
1028                         //Adding the manualViewContour to interface objects structure           
1029                         //_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.
1030                         _theViewPanel->configureViewControlTo(theName, manModelContour, spc, typeofcontour);
1031                         //_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ;
1032                 }       // if addedModel
1033         } // if sizeCtrPt
1034 }
1035
1036 int wxContourMainFrame::GetImageDataSizeZ(){
1037         return _theViewPanel->GetImageDataSizeZ();
1038 }
1039
1040 void wxContourMainFrame::GetImageDataRange(double *range){
1041         _theViewPanel->GetImageDataRange(range);
1042 }
1043
1044 void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method){
1045         //JCP 20-10-08 Undo redo implementation
1046         saveState();
1047         //JCP 20-10-08 Undo redo implementation
1048         
1049         wxBusyCursor wait;
1050         int                                     x                                       = _theViewPanel->GetX();
1051         int                                     y                                       = _theViewPanel->GetY();
1052         int z;
1053         double porcent; 
1054         wxString tmpString;     
1055         double totalZ = maxZ-minZ+1;
1056         for( z=minZ ; z<=maxZ ; z++ )
1057         {
1058                 porcent = 100.0* (z-minZ)/totalZ;
1059                 tmpString.Printf(_T("  %d %c            %d/%d            %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
1060                 interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(tmpString);
1061                 //_staticTextSegmentation->SetLabel(tmpString);
1062                 SegmentationOneSlice( x,y,z,isovalue, sampling,method );
1063         }
1064         interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(_T("   "));
1065         RefreshInterface();
1066 }
1067
1068 void wxContourMainFrame::showAxis(bool show){
1069         _theViewPanel->SetVisibleAxis(show);
1070         _theViewPanel->Refresh();
1071 }
1072
1073
1074 void wxContourMainFrame::onRigidPressed(){
1075         std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
1076         int elementsSelected = currentSelection.size();
1077
1078         if ( elementsSelected >= 1 ){
1079                 //JCP 20-10-08 Undo redo implementation
1080                 saveState();
1081                 //JCP 20-10-08 Undo redo implementation
1082
1083                 std::vector<int> tempVector;
1084                 _instantPanel->getInstant( tempVector );
1085                 Instant instant(&tempVector);
1086
1087                 int i , size=currentSelection.size();
1088                 for ( i=0 ; i<size ; i++ )
1089                 {
1090                         kernelManager->changeContourOfManager(currentSelection[i], &instant);
1091                 } // i
1092         }
1093 }
1094
1095 void wxContourMainFrame::onWidthOfContour(double width){
1096
1097         _theViewPanel->removeSceneContours();
1098         _theViewPanel->SetWidthContour(width);
1099         
1100         //_theViewPanel->getSceneManager()->SetWidthContour( width );
1101
1102         RefreshInterface();
1103 }
1104 int wxContourMainFrame::getColorWindow(){
1105         return _theViewPanel->getColorWindow();
1106 }
1107 int wxContourMainFrame::getWindowLevel(){
1108         return _theViewPanel->getWindowLevel();
1109 }
1110
1111 void wxContourMainFrame::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel){
1112         _theViewPanel->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
1113
1114         
1115         RefreshInterface();
1116 }
1117
1118 void wxContourMainFrame::onInterpolation(bool interpolate){
1119         _theViewPanel->onInterpolation(interpolate);    
1120         RefreshInterface();
1121 }
1122
1123 void wxContourMainFrame::onChangeInstant(std::string name,int actual){
1124         _instantPanel->setConceptValue( name, actual );
1125 }
1126
1127 void wxContourMainFrame::resetAppend(){
1128         kernelManager->resetAppend();
1129         
1130 }
1131
1132 void wxContourMainFrame::onSpreadAdd(){
1133         std::vector<double> vecX; 
1134         std::vector<double> vecY; 
1135         std::vector<double> vecZ; 
1136         _theViewPanel->GetPointsOfActualContour(&vecX , &vecY , &vecZ );
1137         
1138         std::vector<int> tempVector;
1139         _instantPanel->getInstant( tempVector );
1140
1141         std::string val = kernelManager->onSpreadAdd(&vecX , &vecY , &vecZ, tempVector);
1142
1143         interfMainPanel::getInstance()->appendStringSpread(val);
1144         
1145 }
1146
1147 void wxContourMainFrame::onSpreadGo(int type){
1148
1149         //JCP 20-10-08 Undo redo implementation
1150         saveState();
1151         //JCP 20-10-08 Undo redo implementation
1152
1153         wxBusyCursor wait;      
1154         std::vector<double> vecCtrlPointX;
1155         std::vector<double> vecCtrlPointY;
1156         std::vector<double> vecCtrlPointZ;
1157         double  minZ,maxZ;
1158         int z;
1159
1160         std::vector<int> tempVector;
1161         _instantPanel->getInstant( tempVector );
1162 //              tempVector[1];
1163
1164         kernelManager->getMaxMinZ(&minZ,&maxZ);
1165 //JSTG_16-07-08_----------------------------------------------------------------
1166         //_contourPropagation->setInterpolationNumber(maxZ-minZ+1);
1167         kernelManager->CalculeSplinePropagation();
1168
1169         double          totalZ = maxZ-minZ+1;
1170         double          porcent;
1171         wxString        tmpString;
1172 //--------------------------------------------------------------------
1173         for ( z=(int)minZ ; z<=(int)maxZ ; z++ )
1174         {
1175                 porcent = 100.0* (z-minZ)/totalZ;
1176                 int numero = (int)(z-minZ+1)/(int)totalZ;
1177                 std::string stringtemp = "  "+kernelManager->intToString(porcent)+"%            "+kernelManager->intToString(numero)+"            "+kernelManager->intToString(z);
1178                 
1179                 interfMainPanel::getInstance()->setStringSpread(stringtemp);    
1180
1181                 int typeofcontour = 1;
1182                 std::string theName;
1183                 manualContourModel* manModelContour = kernelManager->GetPoints(z, type, &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ, theName,typeofcontour, tempVector);
1184
1185                 if( manModelContour!=NULL ){
1186                         double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1187                         this->_theViewPanel->getSpacing(spc);                                   
1188                         //Adding the manualContourControler to interface objects structure
1189                         //Adding the manualViewContour to interface objects structure           
1190                         //_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.
1191                         _theViewPanel->configureViewControlTo( theName, manModelContour,spc,typeofcontour ) ;
1192                 } // if addedModel
1193         } 
1194         if(z > maxZ){
1195                 porcent = 100.0;
1196                 int numero = (int)(z-minZ+1)/(int)totalZ;
1197                 std::string stringtemp = "  "+kernelManager->intToString(porcent)+"%            "+kernelManager->intToString(numero)+"            "+kernelManager->intToString(z);
1198                 
1199                 interfMainPanel::getInstance()->setStringSpread(stringtemp);
1200         }// for z
1201         //RefreshInterface();
1202 }
1203
1204 void wxContourMainFrame::getInstantVector(std::vector<int>& tempVector){
1205         
1206 }
1207
1208 std::vector<std::string> wxContourMainFrame::getOutlinesName(int slide){
1209         std::vector<int> tempVector;
1210         _instantPanel->getInstant(tempVector);
1211         //Asignation of slide number should be different ex by name
1212         tempVector[1]=slide;
1213         return kernelManager->getOutlinesNameAtInstant(tempVector);
1214 }
1215
1216 void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ){
1217         int maxContourGroup     =       0;
1218
1219         ContourExtractData      *contourextractdata = new ContourExtractData();
1220         
1221         contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1222
1223         std::vector<manualContourModel*> lstManConMod;
1224         std::vector<manualContourModel*> lstManConModTmp;
1225         std::vector<manualContourModel*> lstManConModExp;
1226         std::vector<double> pLstValue;
1227         std::vector<double> pLstValuePosX;
1228         std::vector<double> pLstValuePosY;
1229         std::vector<double> pLstValuePosZ;
1230
1231         int             resultSize; 
1232         int             resultGrayRangeCount;
1233         double  resultMin; 
1234         double  resultMax;
1235         double  resultAverage;
1236         double  resultStandardeviation;
1237
1238         std::vector<int> tempVector;
1239         _instantPanel->getInstant( tempVector );
1240
1241         vtkImageData *imagedata = _theViewPanel->getImageData();
1242         int sizeZ = _theViewPanel->GetImageDataSizeZ();
1243         int z;
1244         int ii,sizeLstContourThings;
1245
1246
1247         int minZ,maxZ;
1248         double totalZ;
1249         double porcent; 
1250         wxString tmpString;
1251
1252         
1253
1254         if (selection==0 ) // actual slice
1255         {
1256                 std::vector<int> tempVector;
1257                 _instantPanel->getInstant( tempVector );
1258                 int actualSlice = tempVector[1];
1259                 minZ    = actualSlice;
1260                 maxZ    = actualSlice;
1261         }
1262         else if (selection==2 ) // All slices
1263         {
1264                 minZ    = 0;
1265                 maxZ    = sizeZ-1;
1266         }
1267         else if (selection==1 ) // slice range
1268         {
1269                 minZ    = minimumZ;
1270                 maxZ    = maximumZ;
1271         }
1272         
1273
1274         totalZ  = maxZ-minZ+1;
1275         contourextractdata->SetImage( imagedata);
1276
1277 // For each slice..
1278         for ( z=minZ ; z<=maxZ ; z++ )
1279         {
1280                 
1281                 porcent = 100.0* (z-minZ)/totalZ;
1282                 tmpString.Printf(_T("  %d %c            %d/%d             %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1283
1284                 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);          
1285                 //_staticTextInformation->SetLabel(tmpString);
1286
1287                 //Extraction data from contours of each slice
1288                 contourextractdata->SetZtoBeAnalys( z);
1289
1290                 tempVector[1]=z;
1291                 Instant instant(&tempVector);
1292                 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
1293                 sizeLstContourThings = lstContourThings.size();
1294
1295                 lstManConMod.clear();
1296                 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1297                 {
1298                         ContourThing **contourthing = lstContourThings[ii];
1299                         lstManConMod.push_back( (*contourthing)->getModel() );
1300                 }
1301                 lstManConModExp =  kernelManager->ExploseEachModel( lstManConMod );
1302
1303
1304                 wxString tempString;
1305                 tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
1306                 interfMainPanel::getInstance()->setRowLabelInfoPanel(z, tempString);
1307                 //_grid->SetRowLabelValue(z, tempString );
1308 //EED004
1309                 int iContourGroup,sizeContourGroup;
1310                 if (typeContourGroup==3) // contour separete
1311                 {
1312                         sizeContourGroup=lstManConModExp.size();
1313                         if ( maxContourGroup<sizeContourGroup ) 
1314                         {
1315                                 maxContourGroup=sizeContourGroup;
1316                         }
1317                 } else {  // contour AND OR XOR
1318                         sizeContourGroup=1;
1319                         maxContourGroup=1;
1320                 }
1321
1322                 int tmpIntA;
1323
1324
1325
1326                 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1327                         lstManConModTmp.clear();
1328                         if (typeContourGroup==3) // contour separete
1329                         {
1330                                 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1331                         } else {  // contour AND OR XOR
1332                                 lstManConModTmp = lstManConModExp;
1333                         }
1334
1335                         contourextractdata->SetLstManualContourModel( lstManConModTmp );
1336
1337                         pLstValue.clear();
1338                         pLstValuePosX.clear();
1339                         pLstValuePosY.clear();
1340                         pLstValuePosZ.clear();
1341                         contourextractdata->GetValuesInsideCrown(       &pLstValue,
1342                                                                                                                 &pLstValuePosX,
1343                                                                                                                 &pLstValuePosY,
1344                                                                                                                 &pLstValuePosZ);
1345                         // Statistics of each slice.
1346                         contourextractdata->Statistics( &pLstValue,
1347                                                                                         minimumZ,
1348                                                                                         maximumZ,
1349                                                                                         &resultGrayRangeCount, 
1350                                                                                         &resultSize, 
1351                                                                                         &resultMin, 
1352                                                                                         &resultMax,
1353                                                                                         &resultAverage,
1354                                                                                         &resultStandardeviation);
1355                         
1356                         if (interfMainPanel::getInstance()->getNumberColsInformationPanel()<_numberOfVariablesStatistics*(iContourGroup+1)  )
1357                         {
1358                                 interfMainPanel::getInstance()->appendColsInformationPanel(_numberOfVariablesStatistics);
1359                         }
1360
1361                         tmpIntA=_numberOfVariablesStatistics*iContourGroup ;
1362
1363                         tempString.Printf(_T("%d"),resultSize);
1364                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA, tempString);  
1365
1366                         tempString.Printf(_T("%d"),resultGrayRangeCount);
1367                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+1, tempString);
1368                         
1369                         tempString.Printf(_T("%f"),resultMin);
1370                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+2, tempString);
1371                         
1372                         tempString.Printf(_T("%f"),resultMax);
1373                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+3, tempString);
1374                         
1375                         tempString.Printf(_T("%f"),resultAverage);
1376                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+4, tempString);
1377                         
1378                         tempString.Printf(_T("%f"),resultStandardeviation);
1379                         interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+5, tempString);
1380                         
1381
1382                 } // for iContourGroup
1383         } // for z
1384
1385         int iTitleGroup;
1386         wxString tmpTitleString;
1387         int tmpIntB;
1388         for ( iTitleGroup=0 ; iTitleGroup<maxContourGroup ; iTitleGroup++ )
1389         {
1390                 tmpIntB =_numberOfVariablesStatistics*iTitleGroup;
1391                 tmpTitleString.Printf(_T("%d-Size Data"),iTitleGroup);
1392                 interfMainPanel::getInstance()->setColLableInfoPanel(tmpIntB + 0, tmpTitleString);
1393
1394                 interfMainPanel::getInstance()->setColLableInfoPanel(tmpIntB + 0, tmpTitleString );
1395                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 1, _T("Size Range") );
1396                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 2, _T("Min") );
1397                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 3, _T("Max") );
1398                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 4, _T("Average") );
1399                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 5, _T("St.Dev.") );
1400                 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 6, _T(" ") );
1401         }
1402
1403         interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
1404         delete contourextractdata;
1405 }
1406
1407 void wxContourMainFrame::onSaveResults(std::string directory,std::string namefile, std::string filename, int typeContourGroup){
1408     SaveValuesXYZ( directory , namefile, typeContourGroup );
1409         SaveImageResult( directory , namefile, typeContourGroup);
1410
1411         
1412         FILE *pFile=fopen(filename.c_str(),"w+");
1413
1414         int sizeZ = _theViewPanel->GetImageDataSizeZ();
1415
1416         wxString tmpString;
1417         int i,j,maxX,maxY=sizeZ;
1418         maxX= interfMainPanel::getInstance()->getNumberColsInformationPanel();//this->_grid->GetNumberCols();
1419
1420         int iTitle,sizeTitle = (maxX / _numberOfVariablesStatistics);
1421         for ( iTitle=0; iTitle<sizeTitle ; iTitle++)
1422         {
1423                 fprintf(pFile,"-- \t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle,tmpString.c_str() );
1424         }
1425         fprintf(pFile,"\n" );
1426
1427
1428
1429         for ( j=0; j<maxY ; j++)
1430         {
1431                 fprintf(pFile,"%d\t" , j );
1432                 for (i=0 ; i<maxX ; i++){
1433                         tmpString = interfMainPanel::getInstance()->getCellValue(j, i);//_grid->GetCellValue( j , i );
1434                         fprintf(pFile,"%s\t" , (const char *)(tmpString.mb_str()) );
1435                 } // for i
1436                 fprintf(pFile,"\n"  );
1437         } // for j
1438
1439         fclose(pFile);
1440 }
1441
1442 void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefile,int typeContourGroup)
1443 {
1444         wxBusyCursor wait;
1445         ContourExtractData      *contourextractdata = new ContourExtractData();
1446         //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
1447         contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1448
1449         std::vector<manualContourModel*> lstManConMod;
1450         std::vector<manualContourModel*> lstManConModTmp;
1451         std::vector<manualContourModel*> lstManConModExp;
1452         std::vector<double> pLstValue;
1453         std::vector<double> pLstValuePosX;
1454         std::vector<double> pLstValuePosY;
1455         std::vector<double> pLstValuePosZ;
1456
1457         std::vector<int> tempVector;
1458         _instantPanel->getInstant( tempVector );
1459
1460         vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
1461         int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
1462         int z;
1463         int ii,sizeLstContourThings;
1464
1465
1466         int minZ,maxZ;
1467         double totalZ;
1468         double porcent; 
1469         wxString tmpString;
1470         minZ    = 0;// _mbarrange->GetStart();
1471         maxZ    = sizeZ;//_mbarrange->GetEnd();
1472         totalZ  = maxZ-minZ+1;
1473
1474         contourextractdata->SetImage( imagedata);
1475
1476 // For each slice..
1477         for ( z=0 ; z<sizeZ ; z++)
1478         {
1479
1480                 porcent = 100.0* (z-minZ)/totalZ;
1481                 
1482                 tmpString.Printf(_T("Saving Values"));
1483                 tmpString.Printf(_T("  %d %c            %d/%d             %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1484                 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
1485                 //_staticTextInformation->SetLabel(tmpString);
1486
1487
1488                 //Extraction data from contours of each slice
1489                 contourextractdata->SetZtoBeAnalys( z);
1490
1491                 tempVector[1]=z;
1492                 Instant instant(&tempVector);
1493                 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant(&instant);//this->_modelManager->getOutlinesAtInstant( &instant );
1494                 sizeLstContourThings = lstContourThings.size();
1495
1496                 lstManConMod.clear();
1497                 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1498                 {
1499                         ContourThing **contourthing = lstContourThings[ii];
1500                         lstManConMod.push_back( (*contourthing)->getModel() );
1501                 }
1502                 lstManConModExp =  kernelManager->ExploseEachModel( lstManConMod );
1503
1504
1505 //EED004
1506
1507                 int iContourGroup,sizeContourGroup;
1508                 if (typeContourGroup==3) // contour separete
1509                 {
1510                         sizeContourGroup=lstManConModExp.size();
1511                 } else {  // contour AND OR XOR
1512                         sizeContourGroup=1;
1513                 }
1514
1515                 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1516                         lstManConModTmp.clear();
1517                         if (typeContourGroup==3) // contour separete
1518                         {
1519                                 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1520                         } else {  // contour AND OR XOR
1521                                 lstManConModTmp = lstManConModExp;
1522                         }
1523
1524                         contourextractdata->SetLstManualContourModel( lstManConModTmp );
1525
1526                         pLstValue.clear();
1527                         pLstValuePosX.clear();
1528                         pLstValuePosY.clear();
1529                         pLstValuePosZ.clear();
1530                         contourextractdata->GetValuesInsideCrown(       &pLstValue,
1531                                                                                                                 &pLstValuePosX,
1532                                                                                                                 &pLstValuePosY,
1533                                                                                                                 &pLstValuePosZ);
1534
1535                         std::string temp = directory + "/" + namefile + "-slice";
1536                         temp = temp + kernelManager->intToString(z) + "-cont" + kernelManager->intToString(iContourGroup);
1537                         temp = temp + ".txt";
1538
1539                         // LG 14/01/09 : using crea
1540                         wxString filename = crea::std2wx(temp);
1541                         /*filename.Printf(_T("%s"),directory.c_str());
1542                         filename.append(_T("\\"));
1543                         filename.append(_T("%s"),namefile.c_str());
1544                         filename.append(_T("-slice"));
1545                         filename.append(_T("%d"),z);
1546                         filename.append(_T("-cont"));
1547                         filename.append(_T("%d"),iContourGroup);
1548                         filename.append(_T(".txt"));*/
1549                         //                      filename.Printf(temp.c_str());
1550
1551                         
1552
1553                         FILE *pFile=fopen((const char *)filename.mb_str(),"w+");
1554                         fprintf(pFile,"value \t x \t y \t z\n"  );
1555                         int iLstValue,sizeLstValue=pLstValue.size();
1556                         for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
1557                         {
1558                                 fprintf(pFile,"%f\t %f\t %f\t %f\n", (float)pLstValue[iLstValue] , (float)pLstValuePosX[iLstValue], (float)pLstValuePosY[iLstValue], (float)z );
1559                         }
1560                         fclose(pFile);
1561                 } // for  iContourGroup
1562         } // for z
1563         interfMainPanel::getInstance()->setStringInfoPanel(_T(""));
1564         //_staticTextInformation->SetLabel( _T("") );
1565         delete contourextractdata;
1566 }
1567
1568 void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, int typeContourGroup)
1569 {
1570         wxBusyCursor wait;
1571         ContourExtractData      *contourextractdata = new ContourExtractData( true );
1572         //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
1573         if (typeContourGroup==3)
1574         {
1575                 typeContourGroup=1;
1576         }
1577         contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1578
1579         std::vector<manualContourModel*> lstManConMod;
1580         std::vector<manualContourModel*> lstManConModTmp;
1581         std::vector<manualContourModel*> lstManConModExp;
1582
1583         std::vector<int> tempVector;
1584         _instantPanel->getInstant( tempVector );
1585
1586         vtkImageData *imagedata = _theViewPanel->getImageData();
1587         int sizeZ = _theViewPanel->GetImageDataSizeZ();
1588         int z;
1589         int ii,sizeLstContourThings;
1590
1591
1592         int minZ,maxZ;
1593         double totalZ;
1594         double porcent; 
1595
1596         wxString tmpString;
1597
1598         minZ    = 0;// _mbarrange->GetStart();
1599         maxZ    = sizeZ;//_mbarrange->GetEnd();
1600         totalZ  = maxZ-minZ+1;
1601
1602         contourextractdata->SetImage( imagedata);
1603
1604 // For each slice..
1605         for ( z=0 ; z<sizeZ ; z++)
1606         {
1607
1608                 porcent = 100.0* (z-minZ)/totalZ;
1609                 tmpString.Printf(_T("Saving Values"));
1610                 tmpString.Printf(_T("%d %c            %d/%d             %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1611                 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
1612
1613                 //Extraction data from contours of each slice
1614                 contourextractdata->SetZtoBeAnalys( z);
1615
1616                 tempVector[1]=z;
1617                 Instant instant(&tempVector);
1618                 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
1619                 sizeLstContourThings = lstContourThings.size();
1620
1621                 lstManConMod.clear();
1622                 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1623                 {
1624                         ContourThing **contourthing = lstContourThings[ii];
1625                         lstManConMod.push_back( (*contourthing)->getModel() );
1626                 }
1627                 lstManConModExp =  kernelManager->ExploseEachModel( lstManConMod );
1628
1629
1630                 int iContourGroup,sizeContourGroup;
1631                 if (typeContourGroup==3) // contour separete
1632                 {
1633                         sizeContourGroup=lstManConModExp.size();
1634                 } else {  // contour AND OR XOR
1635                         sizeContourGroup=1;
1636                 }
1637
1638                 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1639                         lstManConModTmp.clear();
1640                         if (typeContourGroup==3) // contour separete
1641                         {
1642                                 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1643                         } else {  // contour AND OR XOR
1644                                 lstManConModTmp = lstManConModExp;
1645                         }
1646
1647                         contourextractdata->SetLstManualContourModel( lstManConModTmp );
1648
1649
1650 //                              for (ii=0 ; ii<sizeLstContourThings ; ii++)
1651 //                              {
1652 //                                      ContourThing **contourthing = lstContourThings[ii];
1653 //                                      lstManConMod.push_back( (*contourthing)->getModel() );
1654 //                              }
1655 //                              contourextractdata->SetLstManualContourModel( lstManConMod );
1656
1657                         contourextractdata->CalculateImageResult(); // with actual Z
1658
1659                 } // for  iContourGroup
1660         } // for z
1661
1662         std::string temp = directory + "/" + namefile + "-Value.mhd";
1663
1664         wxString filename = crea::std2wx(temp);
1665         // LG 
1666         //      filename.Printf(_T(temp.c_str()));
1667         //filename.Printf(_T("%s\\%s-Value.mhd",directory.c_str(),namefile.c_str(),z);
1668         /*filename.Printf(_T("%s"),directory.c_str());
1669         filename.append(_T("\\"));
1670         filename.append(_T("%s"),namefile.c_str());
1671         filename.append(_T("-Value.mhd"));*/
1672
1673 // Image Value
1674         vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
1675         writerValueImage->SetInput( contourextractdata->GetVtkImageValueResult() );
1676         writerValueImage->SetFileName( (const char *)filename.mb_str() );
1677         writerValueImage->SetFileDimensionality( 3 );
1678         writerValueImage->Write( );
1679
1680 // Image Mask
1681         //              filename.Printf("%s\\%s-Mask.mhd",directory.c_str(),namefile.c_str(),z);
1682         temp = directory + "/" + namefile + "-Mask.mhd";
1683
1684         // LG 14/01/09 : using crea
1685         filename = crea::std2wx(temp);
1686         //      filename.Printf(_T(temp.c_str()));
1687
1688         /*filename.Printf(_T("%s"),directory.c_str());
1689         filename.append(_T("\\"));
1690         filename.append(_T("%s"),namefile.c_str());
1691         filename.append(_T("-Mask.mhd"));*/
1692
1693         vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( );
1694         writerMaskImage->SetInput( contourextractdata->GetVtkImageMaskResult() );
1695         writerMaskImage->SetFileName( (const char *)filename.mb_str() );
1696         writerMaskImage->SetFileDimensionality( 3 );
1697         writerMaskImage->Write( );
1698
1699         interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
1700         delete contourextractdata;
1701 }
1702
1703 void wxContourMainFrame::onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow){
1704         if( name.compare( _theViewPanel->getVerticalConceptName() ) == 0){
1705                 _theViewPanel->setActualVertical( value);
1706         }
1707         else if( name.compare( _theViewPanel->getHorizontalConceptName() ) == 0|| _instantPanel->getIfConceptCheckedAt( name, 0 ) )     {
1708                 _theViewPanel->setHorizontalConcept( name, minshow, maxshow, minshow, maxshow, value);
1709         }
1710
1711         changeInstant();
1712 }
1713
1714 void wxContourMainFrame::onSnakePressed(){
1715         std::vector<double> vecX; 
1716         std::vector<double> vecY; 
1717         std::vector<double> vecZ; 
1718         _theViewPanel->GetPointsOfActualContour( &vecX , &vecY , &vecZ );       
1719
1720         if (vecX.size()!=0){
1721                 std::vector<int> tempVector;
1722                 _instantPanel->getInstant( tempVector );
1723                 int i,size=vecZ.size();
1724                 int actualSlice = tempVector[1];
1725                 for ( i=0 ; i<size ; i++ )
1726                 {
1727                         vecZ[i] = actualSlice;
1728                 } // for
1729
1730                 wxDialog* dialog = new wxDialog(this, -1, wxString(_T("Snake")));
1731                 wxPanel* panel = new wxPanel(dialog,-1); 
1732                 wxStaticText* sttext = new wxStaticText(panel, -1, wxString(_T("Panel para snake")));
1733                 dialog->ShowModal();
1734         } // if 
1735
1736 }