1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #include "interfMainPanel.h"
29 interfMainPanel *interfMainPanel::interfmainpanel = NULL;
30 wxFrame *interfMainPanel::_newframe = NULL;
32 interfMainPanel::interfMainPanel(wxWindow * parent, int sizex, int sizey, wxEvtHandler * evtHandler, std::string datadir)
33 : wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN)
35 PANEL = "New Contour";
39 PANEL4 = "Contour Tools";
40 PANEL5 = "Segmentation";
42 PANEL6 = "Image Tools";
45 segmentPanelITK = NULL;
51 informationPanel = NULL;
53 thresholdPanel = NULL;
54 colorImageLayerPanel = NULL;
59 //CMRU 17-08-09 ------------------------------------------------------------------
60 infoPanelCalibration = NULL;
62 //--------------------------------------------------------------------------------
63 splitterwindow = new wxSplitterWindow(this,-1, wxDefaultPosition, wxSize(sizex, sizey), wxSP_3DSASH, wxString(_T("")));
64 splitterwindow->SetMinimumPaneSize( 10 );
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);
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("")));
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);
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);
142 interfMainPanel::~interfMainPanel(void)
147 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler)
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)
152 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler, datadir);
154 _newframe->Show(TRUE);
155 return interfmainpanel;
158 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler)
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)
163 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler);
165 _newframe->Show(TRUE);
166 return interfmainpanel;
169 bool interfMainPanel::Show(bool show)
171 return _newframe->Show(show);
174 interfMainPanel* interfMainPanel::getInstance()
176 return interfmainpanel;
179 void interfMainPanel :: resetInstance()
181 //delete interfmainpanel;
183 interfmainpanel = NULL;
186 wxPanel* interfMainPanel::initializeToolsPanel(wxWindow* parent, int sizex, int sizey, wxEvtHandler * evtHandler)
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);
201 ** Adds a new checkbox to the scrolledwindow using the checkboxsizer
202 ** @Params id of contour
205 void interfMainPanel::addContourCheckBox(std::string id)
207 toolspread->addContourCheckBox(id);
211 ** Removes a checkbox from the list of checkboxes in the flexsizer (checkboxsizer)
212 ** @Params id of contour
215 void interfMainPanel::removeContourCheckBox(std::string id)
217 toolspread->removeContourCheckBox(id);
220 void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event )
222 //((interfToolsMenu*)menubar4)->hideAxis();
223 wxButton* b = (wxButton*)event.GetEventObject();
226 std::string dstring = *((std::string*) b->GetClientData());
229 if(dstring.compare(PANEL)==0){
232 }else if(dstring.compare(PANEL1)==0 ){
235 }else if(dstring.compare(PANEL2)==0){
238 }else if(dstring.compare(PANEL3)==0){
241 }else if(dstring.compare(PANEL4)==0){
244 }else if(dstring.compare(PANEL5)==0){
247 }else if(dstring.compare(PANEL6)==0){
252 if(wxStrcmp(b->GetLabel(),_T("+"))==0 ){
255 b->SetLabel(_T("-"));
259 b->SetLabel(_T("+"));
262 sizechange *= (dmenu->GetSize().GetHeight()-10);
263 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+sizechange);
269 wxStaticText* interfMainPanel::getText(wxWindow* parent, std::string nom)
271 return new wxStaticText(parent, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition,
272 wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
275 wxButton* interfMainPanel::getButton(wxWindow* parent)
277 wxButton* b = new wxButton(parent, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
278 wxDefaultValidator, wxString(_T("-")));
282 wxPanel* interfMainPanel::setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text)
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);
290 return (wxPanel*)parent;
294 ** Shows the panel in the
296 void interfMainPanel::showPanel(wxWindow* panel)
298 wxContourMainFrame::getInstance()->showAxis(false);
299 wxSizer* sizer = infoPanel->GetSizer();
300 if(currentWindow != NULL)
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);
308 sizer->Detach(currentWindow);
310 } // if currentWindow
312 currentWindow = panel;
313 currentWindow->Show(true);
314 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
315 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
317 infoPanel->Refresh();
323 ** Hide the panel in the lower box
325 void interfMainPanel::hidePanel( )
327 wxContourMainFrame::getInstance()->showAxis(false);
328 wxSizer* sizer = infoPanel->GetSizer();
329 if(currentWindow != NULL)
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);
337 sizer->Detach(currentWindow);
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);
348 infoPanel->Refresh();
354 ** Gets the Information panel
356 wxPanel* interfMainPanel::getInfoPanel()
361 void interfMainPanel::onCreateContourSpline( )
363 wxContourMainFrame::getInstance()->showAxis(false);
364 wxContourMainFrame::getInstance()->onCreateContourSpline();
367 void interfMainPanel::onCreateContourRectangle( )
369 wxContourMainFrame::getInstance()->showAxis(false);
370 wxContourMainFrame::getInstance()->onCreateContourRectangle();
372 void interfMainPanel::onCreateContourCircle( )
374 wxContourMainFrame::getInstance()->showAxis(false);
375 wxContourMainFrame::getInstance()->onCreateContourCircle();
378 void interfMainPanel::onCreateContourLine( )
380 wxContourMainFrame::getInstance()->showAxis(false);
381 wxContourMainFrame::getInstance()->onCreateContourLine();
384 // RaC 09-09 ---------------------
385 void interfMainPanel::onCreateContourPoints( )
387 wxContourMainFrame::getInstance()->showAxis(false);
388 wxContourMainFrame::getInstance()->onCreateContourPoints();
390 // RaC 09-09 ---------------------
392 // RaC 10-09 ---------------------
393 void interfMainPanel::onCreateContourPolygon( )
395 wxContourMainFrame::getInstance()->showAxis(false);
396 wxContourMainFrame::getInstance()->onCreateContourPolygon();
398 // RaC 10-09 ---------------------
400 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull)
402 wxContourMainFrame::getInstance()->showAxis(false);
403 wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
406 void interfMainPanel::onDeleteContour()
408 wxContourMainFrame::getInstance()->showAxis(false);
409 wxContourMainFrame::getInstance()->onDeleteContour();
412 void interfMainPanel::onDeleteContoursActSlice()
414 wxContourMainFrame::getInstance()->showAxis(false);
415 wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
418 void interfMainPanel::onDeleteAllContours()
420 wxContourMainFrame::getInstance()->showAxis(false);
421 wxContourMainFrame::getInstance()->onDeleteAllContours();
424 void interfMainPanel::onCopy()
426 wxContourMainFrame::getInstance()->onCopy();
429 void interfMainPanel::onPaste()
431 wxContourMainFrame::getInstance()->onPaste();
434 void interfMainPanel::onUndo()
436 wxContourMainFrame::getInstance()->onUndo();
439 void interfMainPanel::onRedo()
441 wxContourMainFrame::getInstance()->onRedo();
444 void interfMainPanel::onLoad()
446 wxContourMainFrame::getInstance()->onLoad();
449 void interfMainPanel::onSave()
451 wxContourMainFrame::getInstance()->onSave();
454 void interfMainPanel::onImport()
456 wxContourMainFrame::getInstance()->onImport();
459 void interfMainPanel::onTest()
461 printf("EED interfMainPanel::onTest \n");
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);
478 showPanel(testPanel);
481 void interfMainPanel::RefreshInterface()
483 wxContourMainFrame::getInstance()->RefreshInterface();
486 vtkImageData* interfMainPanel::getImageData()
488 return wxContourMainFrame::getInstance()->getImageData();
491 void interfMainPanel::getImageRange(double range[2] )
493 vtkImageData * img = getImageData();
494 img->GetScalarRange(range);
497 void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method)
499 wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
502 void interfMainPanel::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
504 wxContourMainFrame::getInstance()->onSegmentationOneSliceITK(distance, sigma, alfa, beta, propagation, iterations, inflation);
507 int interfMainPanel::GetImageDataSizeZ()
509 return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
512 void interfMainPanel::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method)
514 wxContourMainFrame::getInstance()->onSegmentationAllSlice(minZ, maxZ,isovalue,sampling,method);
517 void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString)
519 ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
522 void interfMainPanel::onSegmentationPressed()
524 if(segmentPanel == NULL)
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("")));
536 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
537 flexsizer->Add(segmentationPanel, wxEXPAND);
538 segmentPanel->Layout();
540 showPanel(segmentPanel);
541 wxContourMainFrame::getInstance()->showAxis(true);
545 void interfMainPanel::onSegmentationPressedITK()
547 if(segmentPanelITK == NULL)
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);
555 //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
556 wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
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("")));
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);
570 void interfMainPanel::onRigidPressed()
572 wxContourMainFrame::getInstance()->onRigidPressed();
575 void interfMainPanel::onWidthOfContour(double width)
577 wxContourMainFrame::getInstance()->onWidthOfContour(width);
580 int interfMainPanel::getColorWindow()
582 return wxContourMainFrame::getInstance()->getColorWindow();
584 int interfMainPanel::getWindowLevel()
586 return wxContourMainFrame::getInstance()->getWindowLevel();
588 void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
590 wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
593 void interfMainPanel::onInterpolation(bool interpolate)
595 wxContourMainFrame::getInstance()->onInterpolation(interpolate);
599 void interfMainPanel::onConfigurationPressed()
601 if(configPanel == NULL)
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();
615 showPanel(configPanel);
618 void interfMainPanel::onSpreadPressed()
620 if(spreadPanel==NULL)
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();
635 showPanel(spreadPanel);
639 void interfMainPanel::resetAppend()
641 wxContourMainFrame::getInstance()->resetAppend();
644 void interfMainPanel::onSpreadAdd()
646 wxContourMainFrame::getInstance()->onSpreadAdd();
649 void interfMainPanel::onSpreadAddAll()
651 wxContourMainFrame::getInstance()->onSpreadAddAll();
655 void interfMainPanel::appendStringSpread(std::string val)
657 panelSpread->appendStringSpread(val);
660 void interfMainPanel::onSpreadGo(int type)
662 wxContourMainFrame::getInstance()->onSpreadGo(type);
665 void interfMainPanel::setStringSpread(std::string stringtemp)
667 panelSpread->setStringSpread(stringtemp);
670 void interfMainPanel::onInformationPressed()
675 printf("EED interfMainPanel::onInformationPressed 0.1\n");
676 infoWin = new wxFrame (this, -1,_T(" Statistics "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
677 printf("EED interfMainPanel::onInformationPressed 0.2\n");
678 infoWin->SetSize( wxSize(825,650) );
680 wxSize sizepanel(825,675);
681 printf("EED interfMainPanel::onInformationPressed 0.3\n");
682 informationPanel = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
683 printf("EED interfMainPanel::onInformationPressed 0.3a\n");
685 // Borrame wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
686 wxFlexGridSizer * sizerPanel = new wxFlexGridSizer(1);
688 sizerPanel -> Add( informationPanel, 1, wxEXPAND ,0);
689 printf("EED interfMainPanel::onInformationPressed 0.4\n");
691 infoWin->SetSizer( sizerPanel );
692 infoWin->SetAutoLayout( true );
694 printf("EED interfMainPanel::onInformationPressed 0.43\n");
697 printf("EED interfMainPanel::onInformationPressed 0.5\n");
699 if (infoWin->IsShown()==true)
701 printf("EED interfMainPanel::onInformationPressed 0.6\n");
702 infoWin->Show(false);
704 //contourevent->FillGridWithContoursInformation();
705 printf("EED interfMainPanel::onInformationPressed 0.7\n");
710 printf("EED interfMainPanel::onInformationPressed 1\n");
712 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
715 panelAux = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
717 //------------------------------------------------------------------------------------------------------------
718 printf("EED interfMainPanel::onInformationPressed 2\n");
720 // mask view control panel
721 if(infoPanelMask == NULL){
722 infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
723 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
724 infoPanelMask->SetSizer(flexsizer, true);
725 infoPanelMask->SetAutoLayout( true );
726 //configPanel->SetEventHandler(this->contourevent);
727 wxPanel *panel = wxContourMainFrame::getInstance()->getMaskImageViewPanel( infoPanelMask );
728 wxStaticText* stattext = new wxStaticText(infoPanelMask, -1, wxString(_T(" Mask segmentation ")), wxDefaultPosition,
729 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
731 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
733 flexsizer->Add(panel, wxEXPAND);
734 infoPanelMask->Layout();
738 printf("EED interfMainPanel::onInformationPressed 3\n");
739 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
741 if(infoPanelCalibration == NULL)
743 infoPanelCalibration = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER , wxString(_T("")));
744 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
745 infoPanelCalibration->SetSizer(flexsizer, true);
746 infoPanelCalibration->SetAutoLayout( true );
747 wxPanel *panel = new interfCalibrationPanel(infoPanelCalibration);
748 wxStaticText* stattext = new wxStaticText(infoPanelCalibration, -1, wxString(_T(" Calibration ")), wxDefaultPosition,
749 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
751 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
753 flexsizer->Add(panel, wxEXPAND);
754 infoPanelCalibration->Layout();
756 printf("EED interfMainPanel::onInformationPressed 4\n");
758 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
759 #if wxMAJOR_VERSION <= 2
760 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
762 wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
764 sizer->Add(infoPanelMask);
765 printf("EED interfMainPanel::onInformationPressed 4.1\n");
766 sizer->Add(infoPanelCalibration);
767 printf("EED interfMainPanel::onInformationPressed 4.2\n");
768 panelAux->SetSizer(sizer, true);
769 printf("EED interfMainPanel::onInformationPressed 4.3\n");
770 panelAux->SetAutoLayout( true );
771 printf("EED interfMainPanel::onInformationPressed 4.4\n");
773 printf("EED interfMainPanel::onInformationPressed 4.5\n");
775 //------------------------------------------------------------------
776 printf("EED interfMainPanel::onInformationPressed OOJJOOOOOOOOOO......\n");
777 wxContourMainFrame::getInstance()->changeInstant();
778 printf("EED interfMainPanel::onInformationPressed End\n");
782 void interfMainPanel::getInstantVector(std::vector<int>& tempVector)
784 wxContourMainFrame::getInstance()->getInstantVector(tempVector);
787 std::vector<std::string> interfMainPanel::getOutlinesName(int slide)
789 return wxContourMainFrame::getInstance()->getOutlinesName(slide);
792 void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ,int grayRangeMin,int grayRangeMax){
793 wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ,grayRangeMin,grayRangeMax);
796 void interfMainPanel::setStringInfoPanel(wxString tmpString)
798 if(informationPanel!=NULL){
799 ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
803 void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString)
805 ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
808 int interfMainPanel::getNumberColsInformationPanel()
810 return ((interfInformationPanel*)informationPanel)->getNumberCols();
813 void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics)
815 ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
818 void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString)
820 ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
823 void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString)
825 ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
829 void interfMainPanel::SetScalarRange(int grayRangeMin,int grayRangeMax)
831 wxContourMainFrame::getInstance()->SetScalarRange(grayRangeMin, grayRangeMax);
834 void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename,
835 int typeContourGroup, int selection, int minZ, int maxZ ,bool XYZValues, bool contourImage, bool statistics)
837 wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename,
838 typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
841 wxString interfMainPanel::getCellValue(int j,int i){
842 return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
845 void interfMainPanel::onSnakePressed()
848 wxContourMainFrame::getInstance()->showAxis(axisshown);
849 wxContourMainFrame::getInstance()->onSnakePressed();
852 void interfMainPanel::onMirrorPressed(){
853 if(mirrorPanel==NULL)
856 mirrorPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
857 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
858 mirrorPanel->SetSizer(flexsizer, true);
859 mirrorPanel->SetAutoLayout( true );
860 panelMirror = new interfMirrorPanel(mirrorPanel);
861 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1, wxString(_T(" Mirroring Tool ")), wxDefaultPosition,
862 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
864 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
865 flexsizer->Add(panelMirror, wxEXPAND);
866 mirrorPanel->Layout();
868 wxContourMainFrame::getInstance()->referenceLine();
872 wxContourMainFrame::getInstance()->refLineShow();
877 showPanel(mirrorPanel);
880 void interfMainPanel::onMirror()
882 wxContourMainFrame::getInstance()->onMirror();
885 void interfMainPanel::onMirrorAxisShow()
889 wxContourMainFrame::getInstance()->refLineShow();
894 void interfMainPanel::onMirrorAxisHide()
898 wxContourMainFrame::getInstance()->refLineHide();
903 void interfMainPanel::onMirrorChangeWidth(int width)
905 wxContourMainFrame::getInstance()->refLineChangeWidth(width);
909 void interfMainPanel::onColorLayerImagePressed()
911 // Color Image Layer view control panel
912 if(colorImageLayerPanel == NULL){
913 colorImageLayerPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
914 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
915 colorImageLayerPanel->SetSizer(flexsizer, true);
916 colorImageLayerPanel->SetAutoLayout( true );
917 //configPanel->SetEventHandler(this->contourevent);
918 wxPanel *panel = wxContourMainFrame::getInstance()->getColorLayerImageViewPanel( colorImageLayerPanel );
919 wxStaticText* stattext = new wxStaticText(colorImageLayerPanel, -1, wxString(_T(" Color Image Layer ")), wxDefaultPosition,
920 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
921 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
922 flexsizer->Add(panel, wxEXPAND);
923 colorImageLayerPanel->Layout();
925 showPanel(colorImageLayerPanel);
926 wxContourMainFrame::getInstance()->changeInstant();
930 void interfMainPanel::onThresholdPressed()
932 // Threshold view control panel
933 if(thresholdPanel == NULL){
934 thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
935 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
936 thresholdPanel->SetSizer(flexsizer, true);
937 thresholdPanel->SetAutoLayout( true );
938 //configPanel->SetEventHandler(this->contourevent);
939 wxPanel *panel = wxContourMainFrame::getInstance()->getThresholdImageViewPanel( thresholdPanel );
940 wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T(" Threshold segmentation ")), wxDefaultPosition,
941 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
942 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
943 flexsizer->Add(panel, wxEXPAND);
944 thresholdPanel->Layout();
946 showPanel(thresholdPanel);
947 wxContourMainFrame::getInstance()->changeInstant();
951 void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
953 wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
957 void interfMainPanel::SetContourGroup(int contourGroup)
959 wxContourMainFrame::getInstance()->SetContourGroup( contourGroup);
963 void interfMainPanel::onFlipContours()
965 printf("EED interfMainPanel::onFlipContours() \n");
968 flipPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
969 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
970 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
971 flipPanel->SetSizer(flexsizer, true);
972 flipPanel->SetAutoLayout( true );
973 panelFlip = new interfFlipPanel(flipPanel);
974 wxStaticText* stattext = new wxStaticText(flipPanel, -1,
975 wxString(_T(" Flip Contours ")),
976 wxDefaultPosition, wxDefaultSize,
977 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
978 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
979 flexsizer->Add(panelFlip, wxEXPAND);
982 showPanel(flipPanel);
986 void interfMainPanel::FlipContours(int typeContourFlip, int flipDirection)
988 printf("EED interfMainPanel::FlipContours( %d , %d ) \n",typeContourFlip, flipDirection );
989 wxContourMainFrame::getInstance()->FlipContours( typeContourFlip , flipDirection );
994 //CMRU 17-08-09 ---------------------------------------------
995 void interfMainPanel::onPrintLabel ()
998 manualBaseModel* manualModel = wxContourMainFrame::getInstance()->getContour();
1000 if(manualModel==NULL)
1002 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a Contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1007 wxTextEntryDialog* dialog = new wxTextEntryDialog(this,_T("Enter a tag name: ")) ;
1009 if (dialog->ShowModal() == wxID_OK)
1011 label = dialog->GetValue();
1015 wxContourMainFrame::getInstance()->onPrintLabel(label,manualModel);
1016 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The tag name was updated"), wxT("Information"), wxOK | wxICON_INFORMATION);
1021 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a valid tag"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1027 void interfMainPanel::onCalibration(wxString size, int unit)
1030 double contourSize = 0.0;
1031 double realSizeDouble = 0.0;
1033 type = wxContourMainFrame::getInstance()->getType();
1034 contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels();
1036 std::cout<<"Cata->Tama�o del contorno en pixeles:"<<contourSize<<endl;
1040 if (size.ToDouble(&realSizeDouble))
1044 realSizeDouble = realSizeDouble * 10;
1048 realSizeDouble = realSizeDouble * 25.4;
1050 std::cout<< "Valor del usuario" << realSizeDouble<< endl ;
1051 onePixelSize (realSizeDouble,contourSize);
1055 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a numeric value"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1061 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a line contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1065 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The calibration was made"), wxT("Information"), wxOK | wxICON_INFORMATION);
1067 std::cout<< "Cata-> Se ha realizado la calibracion" << endl ;
1070 double interfMainPanel::onePixelSize (double realSize,double sizePixel)
1072 _pixelValue = realSize/sizePixel;
1073 std::cout<< "Valor del un pixel = " << _pixelValue<< endl ;
1074 wxContourMainFrame::getInstance()->onePixelSize (_pixelValue);
1075 return _pixelValue ;
1078 double interfMainPanel::GetPixelValue()
1082 //------------------------------------------------------------------------------------------------------------