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