]> Creatis software - creaContours.git/blob - lib/Interface_Icons_NDimensions/interfMainPanel.cxx
3332 creaContours Feature New Normal - DialogBox confirmation for Delete All contours
[creaContours.git] / lib / Interface_Icons_NDimensions / interfMainPanel.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include <wx/msgdlg.h>
27
28 #include "interfMainPanel.h"
29
30 interfMainPanel *interfMainPanel::interfmainpanel       = NULL;
31 wxFrame                 *interfMainPanel::_newframe                     = NULL;
32
33 interfMainPanel::interfMainPanel(wxWindow * parent, int sizex, int sizey, wxEvtHandler * evtHandler, std::string datadir)
34 : wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN)
35 {
36         PANEL                                   = "New Contour";
37         PANEL1                                  = "I/O";
38         PANEL2                                  = "Edit";
39         PANEL3                                  = "Delete";
40         PANEL4                                  = "Contour Tools";
41         PANEL5                                  = "Segmentation";
42 //EED 07/07/2010
43         PANEL6                                  = "Image Tools";
44
45         segmentPanel                    = NULL;
46         segmentPanelITK                 = NULL;
47         configPanel                             = NULL;
48         spreadPanel                             = NULL;
49         infoWin                                 = NULL;
50         infoPanel                               = NULL;
51         infoPanelMask                   = NULL;
52         informationPanel                = NULL;
53         mirrorPanel                             = NULL;
54         thresholdPanel                  = NULL;
55         colorImageLayerPanel    = NULL;
56         currentWindow                   = NULL;
57         testPanel                               = NULL;
58         flipPanel                               = NULL;
59
60 //CMRU 17-08-09 ------------------------------------------------------------------
61         infoPanelCalibration = NULL;
62         panelAux = NULL;
63 //--------------------------------------------------------------------------------
64         splitterwindow = new wxSplitterWindow(this,-1, wxDefaultPosition, wxSize(sizex, sizey), wxSP_3DSASH, wxString(_T("")));
65         splitterwindow->SetMinimumPaneSize( 10 );
66         sizey = sizey/8;
67         wxPanel* toolpanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
68         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(20,2,1,1);
69         toolpanel->SetSizer(flexsizer, true);
70         toolpanel->SetAutoLayout( true );
71         wxButton* b = getButton(toolpanel);
72         b->SetClientData(&PANEL);
73         wxButton* b1 = getButton(toolpanel);
74         b1->SetClientData(&PANEL1);
75         wxButton* b2 = getButton(toolpanel);
76         b2->SetClientData(&PANEL2);
77         wxButton* b3 = getButton(toolpanel);
78         b3->SetClientData(&PANEL3);
79         wxButton* b4 = getButton(toolpanel);
80         b4->SetClientData(&PANEL4);
81         wxButton* b5 = getButton(toolpanel);
82         b5->SetClientData(&PANEL5);
83 //EED 07/07/2010
84         wxButton* b6 = getButton(toolpanel);
85         b6->SetClientData(&PANEL6);
86         wxPanel* mentex  = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
87         wxPanel* mentex1 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
88         wxPanel* mentex2 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
89         wxPanel* mentex3 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
90         wxPanel* mentex4 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
91         wxPanel* mentex5 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
92 //EED 07/07/2010
93         wxPanel* mentex6 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
94         menubar  = new interfNewContourMenu  (mentex,  sizex, sizey, evtHandler, datadir);
95         menubar1 = new interfIOMenu          (mentex1, sizex, sizey, evtHandler, datadir);
96         menubar2 = new interfEditMenu        (mentex2, sizex, sizey, evtHandler, datadir);
97         menubar3 = new interfDeleteMenu      (mentex3, sizex, sizey, evtHandler, datadir);
98         menubar4 = new interfToolsMenu       (mentex4, sizex ,sizey, evtHandler, datadir);
99         menubar5 = new interfSegmentationMenu(mentex5, sizex, sizey, evtHandler, datadir);
100         menubar6 = new interfImageToolsMenu(mentex6, sizex, sizey, evtHandler, datadir);
101         statictext  = getText(mentex,  PANEL);
102         statictext1 = getText(mentex1, PANEL1);
103         statictext2 = getText(mentex2, PANEL2);
104         statictext3 = getText(mentex3, PANEL3);
105         statictext4 = getText(mentex4, PANEL4);
106         statictext5 = getText(mentex5, PANEL5);
107         statictext6 = getText(mentex6, PANEL6);
108         flexsizer->Add(b, wxFIXED_MINSIZE);
109         flexsizer->Add(setMenuTextSizer(mentex, menubar,statictext), wxFIXED_MINSIZE);
110         flexsizer->Add(b1, wxFIXED_MINSIZE);
111         flexsizer->Add(setMenuTextSizer(mentex1, menubar1,statictext1), wxFIXED_MINSIZE);
112         flexsizer->Add(b2, wxFIXED_MINSIZE);
113         flexsizer->Add(setMenuTextSizer(mentex2, menubar2,statictext2), wxFIXED_MINSIZE);
114         flexsizer->Add(b3, wxFIXED_MINSIZE);
115         flexsizer->Add(setMenuTextSizer(mentex3, menubar3,statictext3), wxFIXED_MINSIZE);
116         flexsizer->Add(b4, wxFIXED_MINSIZE);
117         flexsizer->Add(setMenuTextSizer(mentex4, menubar4,statictext4), wxFIXED_MINSIZE);
118         flexsizer->Add(b5, wxFIXED_MINSIZE);
119         flexsizer->Add(setMenuTextSizer(mentex5, menubar5,statictext5), wxFIXED_MINSIZE);
120         flexsizer->Add(b6, wxFIXED_MINSIZE);
121         flexsizer->Add(setMenuTextSizer(mentex6, menubar6,statictext6), wxFIXED_MINSIZE);
122         toolpanel->Update();
123         toolpanel->Layout();
124         infoPanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
125         wxFlexGridSizer* infosizer = new wxFlexGridSizer(1,1,2,2);
126         infoPanel->SetSizer(infosizer, true);
127         infoPanel->SetAutoLayout( true );
128         splitterwindow->Initialize(toolpanel);
129         splitterwindow->SetSashGravity(1);
130 //EED   splitterwindow->SetSashPosition(600);
131         splitterwindow->SetSashSize(5);
132         splitterwindow->SplitHorizontally(toolpanel, infoPanel,8*73);
133         Connect(b->GetId(),  wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
134         Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
135         Connect(b2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
136         Connect(b3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
137         Connect(b4->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
138         Connect(b5->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
139         Connect(b6->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
140         this->Layout(); 
141 }
142
143 interfMainPanel::~interfMainPanel(void)
144 {
145
146 }
147
148 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler)
149 {
150         _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(450,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER);
151         _newframe->SetMinSize( wxSize(200,200) );
152         if(interfmainpanel == NULL)
153         {
154                 interfmainpanel = new interfMainPanel(_newframe, 450, 900, evtHandler, datadir);
155         }
156         _newframe->Show(TRUE);
157         return interfmainpanel;
158 }
159
160 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler)
161 {
162         _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(450,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER);
163         _newframe->SetMinSize( wxSize(200,200) );
164         if(interfmainpanel == NULL)
165         {
166                 interfmainpanel = new interfMainPanel(_newframe, 450, 900, evtHandler);
167         }
168         _newframe->Show(TRUE);
169         return interfmainpanel;
170 }
171
172 bool interfMainPanel::Show(bool show)
173 {
174         return _newframe->Show(show);
175 }
176
177 interfMainPanel* interfMainPanel::getInstance()
178 {
179         return interfmainpanel;
180 }
181
182 void interfMainPanel :: resetInstance()
183 {
184         //delete interfmainpanel;
185         delete _newframe;
186         interfmainpanel = NULL;
187 }
188
189 wxPanel* interfMainPanel::initializeToolsPanel(wxWindow* parent, int sizex, int sizey, wxEvtHandler * evtHandler)
190 {
191         wxPanel* panel = new wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN, wxString(_T("Spread")));
192         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2)       ;
193         panel->SetSizer(flexsizer, true);
194         panel->SetAutoLayout( true );
195         interfToolsMenu *menu           = new interfToolsMenu(panel, sizex, sizey, evtHandler);
196                                         toolspread      = new interfToolsSpreadPanel(panel, sizex, 300, evtHandler);
197         flexsizer->Add(menu, wxFIXED_MINSIZE);
198         flexsizer->Add(toolspread, wxFIXED_MINSIZE);
199         panel->Layout();
200         return panel;
201 }
202
203 /**
204 **      Adds a new checkbox to the scrolledwindow using the checkboxsizer
205 **      @Params id of contour
206 **
207 **/
208 void interfMainPanel::addContourCheckBox(std::string id)
209 {
210         toolspread->addContourCheckBox(id);
211 }
212
213 /**
214 **      Removes a checkbox from the list of checkboxes in the flexsizer (checkboxsizer)
215 **      @Params id of contour
216 **
217 **/
218 void interfMainPanel::removeContourCheckBox(std::string id)
219 {
220         toolspread->removeContourCheckBox(id);
221 }
222
223 void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event )
224 {
225         //((interfToolsMenu*)menubar4)->hideAxis();
226         wxButton* b = (wxButton*)event.GetEventObject();
227         wxPanel* dmenu;
228         wxStaticText* text;
229         std::string dstring = *((std::string*) b->GetClientData());
230         int sizechange=0;
231
232         if(dstring.compare(PANEL)==0){
233                 dmenu = menubar;
234                 text = statictext;
235         }else if(dstring.compare(PANEL1)==0 ){
236                 dmenu = menubar1;
237                 text = statictext1;
238         }else if(dstring.compare(PANEL2)==0){
239                 dmenu = menubar2;
240                 text = statictext2;
241         }else if(dstring.compare(PANEL3)==0){
242                 dmenu = menubar3;
243                 text = statictext3;
244         }else if(dstring.compare(PANEL4)==0){
245                 dmenu = menubar4;
246                 text = statictext4;
247         }else if(dstring.compare(PANEL5)==0){
248                 dmenu = menubar5;
249                 text = statictext5;
250         }else if(dstring.compare(PANEL6)==0){
251                 dmenu = menubar6;
252                 text = statictext6;
253         }
254
255         if(wxStrcmp(b->GetLabel(),_T("+"))==0 ){
256                 dmenu->Show(true);
257                 sizechange = 1;
258                 b->SetLabel(_T("-"));
259         }else{
260                 dmenu->Show(false);
261                 sizechange = -1;
262                 b->SetLabel(_T("+"));
263         }
264
265         sizechange *= (dmenu->GetSize().GetHeight()-10);
266         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+sizechange);
267
268         this->Layout();
269         this->Refresh();
270 }
271
272 wxStaticText* interfMainPanel::getText(wxWindow* parent, std::string nom)
273 {
274         return new wxStaticText(parent, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition,
275                                         wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
276 }
277
278 wxButton* interfMainPanel::getButton(wxWindow* parent)
279 {
280         wxButton* b = new wxButton(parent, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
281                                         wxDefaultValidator, wxString(_T("-")));
282         return b;
283 }
284
285 wxPanel* interfMainPanel::setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text)
286 {
287         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2);
288         parent->SetSizer(flexsizer, true);
289         parent->SetAutoLayout( true );
290         flexsizer->Add(text, wxFLEX_GROWMODE_ALL);
291         flexsizer->Add(panel, wxFLEX_GROWMODE_ALL);
292         parent->Layout();
293         return (wxPanel*)parent;
294 }
295
296 /**
297 **      Shows the panel in the
298 **/
299 void interfMainPanel::showPanel(wxWindow* panel)
300 {
301         wxContourMainFrame::getInstance()->showAxis(false);
302         wxSizer* sizer = infoPanel->GetSizer();
303         if(currentWindow != NULL)
304         {
305                 currentWindow->Hide();
306                 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated 
307 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
308 #if wxMAJOR_VERSION <= 2
309                 sizer->Remove(currentWindow);
310 #else
311                 sizer->Detach(currentWindow);
312 #endif
313         } // if currentWindow
314         sizer->Add(panel);
315         currentWindow = panel;
316         currentWindow->Show(true);
317         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
318         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
319         infoPanel->Layout();
320         infoPanel->Refresh();
321         this->Layout();
322         this->Refresh();
323 }
324
325 /**
326 **      Hide the panel in the lower box
327 **/
328 void interfMainPanel::hidePanel( )
329 {
330         wxContourMainFrame::getInstance()->showAxis(false);
331         wxSizer* sizer = infoPanel->GetSizer();
332         if(currentWindow != NULL)
333         {
334                 currentWindow->Hide();
335                 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated 
336 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
337 #if wxMAJOR_VERSION <= 2
338                 sizer->Remove(currentWindow);
339 #else
340                 sizer->Detach(currentWindow);
341 #endif
342
343         }
344         wxPanel * emptyPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
345         sizer->Add(emptyPanel);
346         currentWindow = emptyPanel;
347         currentWindow->Show(true);
348         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
349         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
350         infoPanel->Layout();
351         infoPanel->Refresh();
352         this->Layout();
353         this->Refresh();
354 }
355
356 /**
357 **      Gets the Information panel
358 **/
359 wxPanel* interfMainPanel::getInfoPanel()
360 {
361         return infoPanel;
362 }
363
364 void interfMainPanel::onCreateContourSpline( )
365 {
366         wxContourMainFrame::getInstance()->showAxis(false);
367         wxContourMainFrame::getInstance()->onCreateContourSpline();
368 }
369
370 void interfMainPanel::onCreateContourRectangle( )
371 {
372         wxContourMainFrame::getInstance()->showAxis(false);
373     wxContourMainFrame::getInstance()->onCreateContourRectangle();
374 }
375 void interfMainPanel::onCreateContourCircle( )
376 {
377         wxContourMainFrame::getInstance()->showAxis(false);
378     wxContourMainFrame::getInstance()->onCreateContourCircle();
379 }
380
381 void interfMainPanel::onCreateContourLine( )
382 {
383         wxContourMainFrame::getInstance()->showAxis(false);
384     wxContourMainFrame::getInstance()->onCreateContourLine();
385 }
386
387 // RaC 09-09 ---------------------
388 void interfMainPanel::onCreateContourPoints( )
389 {
390         wxContourMainFrame::getInstance()->showAxis(false);
391     wxContourMainFrame::getInstance()->onCreateContourPoints();
392 }
393 // RaC 09-09 ---------------------
394
395 // RaC 10-09 ---------------------
396 void interfMainPanel::onCreateContourPolygon( )
397 {
398         wxContourMainFrame::getInstance()->showAxis(false);
399     wxContourMainFrame::getInstance()->onCreateContourPolygon();
400 }
401 // RaC 10-09 ---------------------
402
403 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull)
404 {
405         wxContourMainFrame::getInstance()->showAxis(false);
406         wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
407 }
408
409 void interfMainPanel::onDeleteContoursActSlice()
410 {
411         wxContourMainFrame::getInstance()->showAxis(false);
412         wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
413 }
414
415 void interfMainPanel::onDeleteContour()
416 {
417         wxContourMainFrame::getInstance()->showAxis(false);
418         wxContourMainFrame::getInstance()->onDeleteContour();
419 }
420
421 void interfMainPanel::onDeleteAllContours()
422 {
423     wxMessageDialog *dial;
424         dial=new wxMessageDialog(       NULL,
425                                                                 wxT("Delete all contours of the system?"), 
426                                                                 wxT("Warnning!"), 
427                                                                 wxOK | wxCANCEL | wxICON_QUESTION   );
428         if (dial->ShowModal()==wxID_OK)
429         {
430                 wxContourMainFrame::getInstance()->showAxis(false);
431                 wxContourMainFrame::getInstance()->onDeleteAllContours();
432         } // if OK
433 }
434
435 void interfMainPanel::onCopy()
436 {
437         wxContourMainFrame::getInstance()->onCopy();
438 }
439
440 void interfMainPanel::onPaste()
441 {
442         wxContourMainFrame::getInstance()->onPaste();
443 }
444
445 void interfMainPanel::onUndo()
446 {
447         wxContourMainFrame::getInstance()->onUndo();
448 }
449
450 void interfMainPanel::onRedo()
451 {
452         wxContourMainFrame::getInstance()->onRedo();
453 }
454
455 void interfMainPanel::onLoad()
456 {
457         wxContourMainFrame::getInstance()->onLoad();
458 }
459
460 void interfMainPanel::onSave()
461 {
462         wxContourMainFrame::getInstance()->onSave();
463 }
464
465 void interfMainPanel::onImport()
466 {
467         wxContourMainFrame::getInstance()->onImport();
468 }
469
470 void interfMainPanel::onTest()
471 {
472         printf("EED interfMainPanel::onTest \n");
473         if(testPanel==NULL)
474         {
475                 testPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
476                         wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
477                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
478                 testPanel->SetSizer(flexsizer, true);
479                 testPanel->SetAutoLayout( true );
480                 panelTest = new interfTestPanel(testPanel);
481                 wxStaticText* stattext = new wxStaticText(testPanel,  -1,
482                         wxString(_T("   Test Panel   ")),
483                         wxDefaultPosition, wxDefaultSize,
484                         wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
485                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
486                 flexsizer->Add(panelTest, wxEXPAND);
487                 testPanel->Layout();
488         }
489         showPanel(testPanel);
490 }
491
492 void interfMainPanel::RefreshInterface()
493 {
494         wxContourMainFrame::getInstance()->RefreshInterface();
495 }
496
497 vtkImageData* interfMainPanel::getImageData()
498 {
499         return wxContourMainFrame::getInstance()->getImageData();
500 }
501
502 void interfMainPanel::getImageRange(double  range[2] )
503 {
504         vtkImageData * img = getImageData();
505         img->GetScalarRange(range);
506 }
507
508 void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method)
509 {
510         wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
511 }
512
513 void interfMainPanel::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
514 {
515         wxContourMainFrame::getInstance()->onSegmentationOneSliceITK(distance, sigma, alfa, beta, propagation, iterations, inflation);
516 }
517
518 int interfMainPanel::GetImageDataSizeZ()
519 {
520         return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
521 }
522
523 void interfMainPanel::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method)
524 {
525         wxContourMainFrame::getInstance()->onSegmentationAllSlice(minZ, maxZ,isovalue,sampling,method);
526 }
527
528 void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString)
529 {
530     ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
531 }
532
533 void interfMainPanel::onSegmentationPressed()
534 {
535         if(segmentPanel == NULL)
536         {
537                 segmentPanel = new wxPanel(getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
538                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
539                 segmentPanel->SetSizer(flexsizer, true);
540                 segmentPanel->SetAutoLayout(true);
541                 segmentPanel->SetEventHandler(this);
542                 //wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
543                 segmentationPanel = new interfSegmentationPanelVTK(segmentPanel);
544                 wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T("   Automatic Segmentation   ")), wxDefaultPosition,
545                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
546
547                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
548                 flexsizer->Add(segmentationPanel, wxEXPAND);
549                 segmentPanel->Layout();
550         }// if segmentPanel
551         showPanel(segmentPanel);
552         wxContourMainFrame::getInstance()->showAxis(true);
553         axisshown = true;
554 }
555
556 void interfMainPanel::onSegmentationPressedITK()
557 {
558     if(segmentPanelITK == NULL)
559         {
560                 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
561                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
562                 segmentPanelITK->SetSizer(flexsizer, true);
563                 segmentPanelITK->SetAutoLayout( true );
564                 //segmentPanelITK->SetEventHandler(this->contourevent);
565
566                 //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
567                 wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
568
569                 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T("   Automatic ITK Segmentation   ")), wxDefaultPosition,
570                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
571
572                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
573                 flexsizer->Add(panel, wxEXPAND);
574                 segmentPanelITK->Layout();
575         }// if segmentPanelITK
576         showPanel(segmentPanelITK);
577         wxContourMainFrame::getInstance()->showAxis(true);
578         axisshown = true;
579 }
580
581 void interfMainPanel::onRigidPressed()
582 {
583         wxContourMainFrame::getInstance()->onRigidPressed();
584 }
585
586 void interfMainPanel::onWidthOfContour(double width)
587 {
588         wxContourMainFrame::getInstance()->onWidthOfContour(width);
589 }
590
591 int interfMainPanel::getColorWindow()
592 {
593         return wxContourMainFrame::getInstance()->getColorWindow();
594 }
595 int interfMainPanel::getWindowLevel()
596 {
597         return wxContourMainFrame::getInstance()->getWindowLevel();
598 }
599 void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
600 {
601         wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
602 }
603
604 void interfMainPanel::onInterpolation(bool interpolate)
605 {
606         wxContourMainFrame::getInstance()->onInterpolation(interpolate);
607 }
608
609 void interfMainPanel::onBeforAfterContour(bool before, bool after)
610 {
611         wxContourMainFrame::getInstance()->onBeforeAfterContour(before,after);
612 }
613
614 void interfMainPanel::onJumpSlice(int step, int shift)
615 {
616         wxContourMainFrame::getInstance()->onJumpSlice(step,shift);
617 }
618
619 void interfMainPanel::onShowTextContour(bool show)
620 {
621         wxContourMainFrame::getInstance()->onShowTextContour(show);
622 }
623
624
625 void interfMainPanel::onConfigurationPressed()
626 {
627         if(configPanel == NULL)
628         {
629                 configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
630                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
631                 configPanel->SetSizer(flexsizer, true);
632                 configPanel->SetAutoLayout( true );
633                 //configPanel->SetEventHandler(this->contourevent);
634                 wxPanel* panel = new interfConfigurationPanel(configPanel);
635                 wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T("   Interface Configuration   ")), wxDefaultPosition,
636                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
637                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
638                 flexsizer->Add(panel, wxEXPAND);
639                 configPanel->Layout();
640         }// if configPanel
641         showPanel(configPanel);
642 }
643
644 void interfMainPanel::onSpreadPressed()
645 {
646     if(spreadPanel==NULL)
647         {
648                 spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
649                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
650                 spreadPanel->SetSizer(flexsizer, true);
651                 spreadPanel->SetAutoLayout( true );
652                 //spreadPanel->SetEventHandler(this->contourevent);
653                 //wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
654                 panelSpread = new interfSpreadPanel(spreadPanel);
655                 wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T("   Automatic Spread   ")), wxDefaultPosition,
656                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
657                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
658                 flexsizer->Add(panelSpread, wxEXPAND);
659                 spreadPanel->Layout();
660         } // spreadPanel
661         showPanel(spreadPanel);
662         //hideAxis();
663 }
664
665 void interfMainPanel::resetAppend()
666 {
667         wxContourMainFrame::getInstance()->resetAppend();
668 }
669
670 void interfMainPanel::onSpreadAdd()
671 {
672         wxContourMainFrame::getInstance()->onSpreadAdd();
673 }
674
675 void interfMainPanel::onSpreadAddAll()
676 {
677         wxContourMainFrame::getInstance()->onSpreadAddAll();
678 }
679
680
681 void interfMainPanel::appendStringSpread(std::string val)
682 {
683     panelSpread->appendStringSpread(val);
684 }
685
686 void interfMainPanel::onSpreadGo(int type)
687 {
688         wxContourMainFrame::getInstance()->onSpreadGo(type);
689 }
690
691 void interfMainPanel::setStringSpread(std::string stringtemp)
692 {
693         panelSpread->setStringSpread(stringtemp);
694 }
695
696 void interfMainPanel::onInformationPressed()
697 {
698         // Statistics frame
699         if(infoWin ==NULL)
700         {
701                 infoWin                 = new wxFrame (this, -1,_T("  Statistics  "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER  );
702                 infoWin->SetSize( wxSize(825,650) );
703
704                 wxSize sizepanel(825,675);
705                 informationPanel        = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
706
707                 wxFlexGridSizer * sizerPanel            = new wxFlexGridSizer(1);
708
709                 sizerPanel -> Add( informationPanel, 1, wxEXPAND ,0);
710
711                 infoWin->SetSizer( sizerPanel );
712                 infoWin->SetAutoLayout( true );
713                 infoWin->Layout();
714                 infoWin->Show();
715         }else {
716                 if (infoWin->IsShown()==true)
717                 {
718                         infoWin->Show(false);
719                 } else  {
720                         //contourevent->FillGridWithContoursInformation();
721                         infoWin->Show(true);
722                 }
723         }
724
725 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
726         if(panelAux == NULL)
727         {
728                 panelAux = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
729         }
730 //------------------------------------------------------------------------------------------------------------
731         // mask view control panel
732         if(infoPanelMask == NULL){
733                 infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
734                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
735                 infoPanelMask->SetSizer(flexsizer, true);
736                 infoPanelMask->SetAutoLayout( true );
737                 //configPanel->SetEventHandler(this->contourevent);
738                 wxPanel *panel = wxContourMainFrame::getInstance()->getMaskImageViewPanel( infoPanelMask );
739                 wxStaticText* stattext = new wxStaticText(infoPanelMask, -1, wxString(_T("   Mask segmentation    ")), wxDefaultPosition,
740                                                                                                   wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
741                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
742                 flexsizer->Add(panel, wxEXPAND);
743                 infoPanelMask->Layout();
744         }
745
746 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
747         //Calibration panel
748         if(infoPanelCalibration == NULL)
749         {
750                 infoPanelCalibration = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER , wxString(_T("")));
751                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
752                 infoPanelCalibration->SetSizer(flexsizer, true);
753                 infoPanelCalibration->SetAutoLayout( true );
754                 wxPanel *panel = new interfCalibrationPanel(infoPanelCalibration);
755                 wxStaticText* stattext = new wxStaticText(infoPanelCalibration, -1, wxString(_T("              Calibration               ")), wxDefaultPosition,
756                                                                                                   wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
757                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
758                 flexsizer->Add(panel, wxEXPAND);
759                 infoPanelCalibration->Layout();
760         }
761
762 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
763 #if wxMAJOR_VERSION <= 2
764         wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
765 #else
766         wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
767 #endif
768         sizer->Add(infoPanelMask);
769         sizer->Add(infoPanelCalibration);
770         panelAux->SetSizer(sizer, true);
771         panelAux->SetAutoLayout( true );
772         showPanel(panelAux);
773
774 //------------------------------------------------------------------
775         wxContourMainFrame::getInstance()->changeInstant();
776 }
777
778
779 void interfMainPanel::getInstantVector(std::vector<int>& tempVector)
780 {
781         wxContourMainFrame::getInstance()->getInstantVector(tempVector);
782 }
783
784 std::vector<std::string> interfMainPanel::getOutlinesName(int slide)
785 {
786         return wxContourMainFrame::getInstance()->getOutlinesName(slide);
787 }
788
789 void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ,int grayRangeMin,int grayRangeMax){
790         wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ,grayRangeMin,grayRangeMax);
791 }
792
793 void interfMainPanel::setStringInfoPanel(wxString tmpString)
794 {
795         if(informationPanel!=NULL){
796                 ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
797         }
798 }
799
800 void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString)
801 {
802         ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
803 }
804
805 int interfMainPanel::getNumberColsInformationPanel()
806 {
807         return ((interfInformationPanel*)informationPanel)->getNumberCols();
808 }
809
810 void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics)
811 {
812         ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
813 }
814
815 void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString)
816 {
817         ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
818 }
819
820 void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString)
821 {
822         ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
823
824 }
825
826 void interfMainPanel::SetScalarRange(int grayRangeMin,int grayRangeMax)
827 {
828         wxContourMainFrame::getInstance()->SetScalarRange(grayRangeMin, grayRangeMax);
829 }
830
831 void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename,
832                                                                         int typeContourGroup, int selection, int minZ, int maxZ ,bool XYZValues, bool contourImage, bool statistics)
833 {
834         wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename,
835                 typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
836 }
837
838 wxString interfMainPanel::getCellValue(int j,int i){
839         return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
840 }
841
842 void interfMainPanel::onSnakePressed()
843 {
844         axisshown=false;
845         wxContourMainFrame::getInstance()->showAxis(axisshown);
846         wxContourMainFrame::getInstance()->onSnakePressed();
847 }
848
849 void interfMainPanel::onMirrorPressed(){
850     if(mirrorPanel==NULL)
851         {
852
853                 mirrorPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
854                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
855                 mirrorPanel->SetSizer(flexsizer, true);
856                 mirrorPanel->SetAutoLayout( true );
857                 panelMirror = new interfMirrorPanel(mirrorPanel);
858                 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1, wxString(_T("   Mirroring Tool   ")), wxDefaultPosition,
859                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
860
861                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
862                 flexsizer->Add(panelMirror, wxEXPAND);
863                 mirrorPanel->Layout();
864                 refLineShown=true;
865                 wxContourMainFrame::getInstance()->referenceLine();
866         } else {
867                 if (!refLineShown)
868                 {
869                         wxContourMainFrame::getInstance()->refLineShow();
870                         refLineShown=true;
871                 }
872         } // if mirrorPanel
873
874         showPanel(mirrorPanel);
875 }
876
877 void interfMainPanel::onMirror()
878 {
879         wxContourMainFrame::getInstance()->onMirror();
880 }
881
882 void interfMainPanel::onMirrorAxisShow()
883 {
884         if (!refLineShown)
885         {
886                 wxContourMainFrame::getInstance()->refLineShow();
887                 refLineShown=true;
888         }
889 }
890
891 void interfMainPanel::onMirrorAxisHide()
892 {
893         if (refLineShown)
894         {
895                 wxContourMainFrame::getInstance()->refLineHide();
896                 refLineShown=false;
897         }
898 }
899
900 void interfMainPanel::onMirrorChangeWidth(int width)
901 {
902         wxContourMainFrame::getInstance()->refLineChangeWidth(width);
903 }
904
905 //EED 07/07/2010
906 void interfMainPanel::onColorLayerImagePressed()
907 {
908         // Color Image Layer  view control panel
909         if(colorImageLayerPanel == NULL){
910                 colorImageLayerPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
911                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
912                 colorImageLayerPanel->SetSizer(flexsizer, true);
913                 colorImageLayerPanel->SetAutoLayout( true );
914                 //configPanel->SetEventHandler(this->contourevent);
915                 wxPanel *panel = wxContourMainFrame::getInstance()->getColorLayerImageViewPanel( colorImageLayerPanel );
916                 wxStaticText* stattext = new wxStaticText(colorImageLayerPanel, -1, wxString(_T("   Color Image Layer     ")), wxDefaultPosition,
917                                                                                                   wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
918                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
919                 flexsizer->Add(panel, wxEXPAND);
920                 colorImageLayerPanel->Layout();
921         }
922         showPanel(colorImageLayerPanel);
923         wxContourMainFrame::getInstance()->changeInstant();
924 }
925
926 //EED01
927 void interfMainPanel::onThresholdPressed()
928 {
929         // Threshold view control panel
930         if(thresholdPanel == NULL){
931                 thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
932                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
933                 thresholdPanel->SetSizer(flexsizer, true);
934                 thresholdPanel->SetAutoLayout( true );
935                 //configPanel->SetEventHandler(this->contourevent);
936                 wxPanel *panel = wxContourMainFrame::getInstance()->getThresholdImageViewPanel( thresholdPanel );
937                 wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T("   Threshold segmentation    ")), wxDefaultPosition,
938                                                                                                   wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
939                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
940                 flexsizer->Add(panel, wxEXPAND);
941                 thresholdPanel->Layout();
942         }
943         showPanel(thresholdPanel);
944         wxContourMainFrame::getInstance()->changeInstant();
945 }
946
947
948 void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
949 {
950         wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
951 }
952
953
954 void interfMainPanel::SetContourGroup(int contourGroup)
955 {
956         wxContourMainFrame::getInstance()->SetContourGroup( contourGroup);
957 }
958
959
960 void interfMainPanel::onFlipContours()
961 {
962         printf("EED interfMainPanel::onFlipContours() \n");
963         if(flipPanel==NULL)
964         {
965                 flipPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
966                         wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
967                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
968                 flipPanel->SetSizer(flexsizer, true);
969                 flipPanel->SetAutoLayout( true );
970                 panelFlip = new interfFlipPanel(flipPanel);
971                 wxStaticText* stattext = new wxStaticText(flipPanel,  -1,
972                         wxString(_T("         Flip Contours   ")),
973                         wxDefaultPosition, wxDefaultSize,
974                         wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
975                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
976                 flexsizer->Add(panelFlip, wxEXPAND);
977                 flipPanel->Layout();
978         }
979         showPanel(flipPanel);
980 }
981
982
983 void interfMainPanel::FlipContours(int typeContourFlip, int flipDirection)
984 {
985         printf("EED interfMainPanel::FlipContours( %d , %d ) \n",typeContourFlip,  flipDirection );
986         wxContourMainFrame::getInstance()->FlipContours( typeContourFlip , flipDirection );
987 }
988
989
990
991 //CMRU 17-08-09 ---------------------------------------------
992 void interfMainPanel::onPrintLabel ()
993 {
994         wxString label;
995         manualBaseModel* manualModel = wxContourMainFrame::getInstance()->getContour();
996
997         if(manualModel==NULL)
998         {
999         wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a Contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1000                 dial->ShowModal();
1001                 return;
1002         }
1003
1004         wxTextEntryDialog* dialog = new wxTextEntryDialog(this,_T("Enter a tag name: ")) ;
1005
1006         if (dialog->ShowModal() == wxID_OK)
1007         {
1008                 label = dialog->GetValue();
1009
1010                 if(label.Len()!=0)
1011                 {
1012                         wxContourMainFrame::getInstance()->onPrintLabel(label,manualModel);
1013                         wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The tag name was updated"), wxT("Information"), wxOK | wxICON_INFORMATION);
1014                         dial->ShowModal();
1015                 }
1016                 else
1017                 {
1018                         wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a valid tag"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1019                         dial->ShowModal();
1020                 }
1021         }
1022 }
1023
1024 void interfMainPanel::onCalibration(wxString size, int unit)
1025 {
1026         int type = 0;
1027         double contourSize = 0.0;
1028         double realSizeDouble = 0.0;
1029
1030         type = wxContourMainFrame::getInstance()->getType();
1031         contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels();
1032
1033         std::cout<<"Cata->Tama�o del contorno en pixeles:"<<contourSize<<endl;
1034
1035         if ( type == 6 )
1036         {
1037                 if (size.ToDouble(&realSizeDouble))
1038                 {
1039                         if(unit==1)
1040                         {
1041                                 realSizeDouble = realSizeDouble * 10;
1042                         }
1043                         if(unit==2)
1044                         {
1045                                 realSizeDouble = realSizeDouble * 25.4;
1046                         }
1047                         std::cout<< "Valor del usuario" << realSizeDouble<< endl ;
1048                         onePixelSize (realSizeDouble,contourSize);
1049                  }
1050                  else
1051                  {
1052                         wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a numeric value"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1053                         dial->ShowModal();
1054                  }
1055         }
1056         else
1057         {
1058                 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a line contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1059                 dial->ShowModal();
1060         }
1061
1062         wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The calibration was made"), wxT("Information"), wxOK | wxICON_INFORMATION);
1063         dial->ShowModal();
1064         std::cout<< "Cata-> Se ha realizado la calibracion" << endl ;
1065 }
1066
1067 double interfMainPanel::onePixelSize (double realSize,double sizePixel)
1068 {
1069         _pixelValue = realSize/sizePixel;
1070         std::cout<< "Valor del un pixel = " << _pixelValue<< endl ;
1071         wxContourMainFrame::getInstance()->onePixelSize (_pixelValue);
1072         return _pixelValue ;
1073 }
1074
1075 double interfMainPanel::GetPixelValue()
1076 {
1077         return _pixelValue;
1078 }
1079 //------------------------------------------------------------------------------------------------------------