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(450,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER);
150 _newframe->SetMinSize( wxSize(200,200) );
151 if(interfmainpanel == NULL)
153 interfmainpanel = new interfMainPanel(_newframe, 450, 900, evtHandler, datadir);
155 _newframe->Show(TRUE);
156 return interfmainpanel;
159 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler)
161 _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);
162 _newframe->SetMinSize( wxSize(200,200) );
163 if(interfmainpanel == NULL)
165 interfmainpanel = new interfMainPanel(_newframe, 450, 900, evtHandler);
167 _newframe->Show(TRUE);
168 return interfmainpanel;
171 bool interfMainPanel::Show(bool show)
173 return _newframe->Show(show);
176 interfMainPanel* interfMainPanel::getInstance()
178 return interfmainpanel;
181 void interfMainPanel :: resetInstance()
183 //delete interfmainpanel;
185 interfmainpanel = NULL;
188 wxPanel* interfMainPanel::initializeToolsPanel(wxWindow* parent, int sizex, int sizey, wxEvtHandler * evtHandler)
190 wxPanel* panel = new wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN, wxString(_T("Spread")));
191 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2) ;
192 panel->SetSizer(flexsizer, true);
193 panel->SetAutoLayout( true );
194 interfToolsMenu *menu = new interfToolsMenu(panel, sizex, sizey, evtHandler);
195 toolspread = new interfToolsSpreadPanel(panel, sizex, 300, evtHandler);
196 flexsizer->Add(menu, wxFIXED_MINSIZE);
197 flexsizer->Add(toolspread, wxFIXED_MINSIZE);
203 ** Adds a new checkbox to the scrolledwindow using the checkboxsizer
204 ** @Params id of contour
207 void interfMainPanel::addContourCheckBox(std::string id)
209 toolspread->addContourCheckBox(id);
213 ** Removes a checkbox from the list of checkboxes in the flexsizer (checkboxsizer)
214 ** @Params id of contour
217 void interfMainPanel::removeContourCheckBox(std::string id)
219 toolspread->removeContourCheckBox(id);
222 void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event )
224 //((interfToolsMenu*)menubar4)->hideAxis();
225 wxButton* b = (wxButton*)event.GetEventObject();
228 std::string dstring = *((std::string*) b->GetClientData());
231 if(dstring.compare(PANEL)==0){
234 }else if(dstring.compare(PANEL1)==0 ){
237 }else if(dstring.compare(PANEL2)==0){
240 }else if(dstring.compare(PANEL3)==0){
243 }else if(dstring.compare(PANEL4)==0){
246 }else if(dstring.compare(PANEL5)==0){
249 }else if(dstring.compare(PANEL6)==0){
254 if(wxStrcmp(b->GetLabel(),_T("+"))==0 ){
257 b->SetLabel(_T("-"));
261 b->SetLabel(_T("+"));
264 sizechange *= (dmenu->GetSize().GetHeight()-10);
265 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+sizechange);
271 wxStaticText* interfMainPanel::getText(wxWindow* parent, std::string nom)
273 return new wxStaticText(parent, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition,
274 wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
277 wxButton* interfMainPanel::getButton(wxWindow* parent)
279 wxButton* b = new wxButton(parent, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
280 wxDefaultValidator, wxString(_T("-")));
284 wxPanel* interfMainPanel::setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text)
286 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2);
287 parent->SetSizer(flexsizer, true);
288 parent->SetAutoLayout( true );
289 flexsizer->Add(text, wxFLEX_GROWMODE_ALL);
290 flexsizer->Add(panel, wxFLEX_GROWMODE_ALL);
292 return (wxPanel*)parent;
296 ** Shows the panel in the
298 void interfMainPanel::showPanel(wxWindow* panel)
300 wxContourMainFrame::getInstance()->showAxis(false);
301 wxSizer* sizer = infoPanel->GetSizer();
302 if(currentWindow != NULL)
304 currentWindow->Hide();
305 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated
306 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
307 #if wxMAJOR_VERSION <= 2
308 sizer->Remove(currentWindow);
310 sizer->Detach(currentWindow);
312 } // if currentWindow
314 currentWindow = panel;
315 currentWindow->Show(true);
316 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
317 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
319 infoPanel->Refresh();
325 ** Hide the panel in the lower box
327 void interfMainPanel::hidePanel( )
329 wxContourMainFrame::getInstance()->showAxis(false);
330 wxSizer* sizer = infoPanel->GetSizer();
331 if(currentWindow != NULL)
333 currentWindow->Hide();
334 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated
335 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
336 #if wxMAJOR_VERSION <= 2
337 sizer->Remove(currentWindow);
339 sizer->Detach(currentWindow);
343 wxPanel * emptyPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
344 sizer->Add(emptyPanel);
345 currentWindow = emptyPanel;
346 currentWindow->Show(true);
347 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
348 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
350 infoPanel->Refresh();
356 ** Gets the Information panel
358 wxPanel* interfMainPanel::getInfoPanel()
363 void interfMainPanel::onCreateContourSpline( )
365 wxContourMainFrame::getInstance()->showAxis(false);
366 wxContourMainFrame::getInstance()->onCreateContourSpline();
369 void interfMainPanel::onCreateContourRectangle( )
371 wxContourMainFrame::getInstance()->showAxis(false);
372 wxContourMainFrame::getInstance()->onCreateContourRectangle();
374 void interfMainPanel::onCreateContourCircle( )
376 wxContourMainFrame::getInstance()->showAxis(false);
377 wxContourMainFrame::getInstance()->onCreateContourCircle();
380 void interfMainPanel::onCreateContourLine( )
382 wxContourMainFrame::getInstance()->showAxis(false);
383 wxContourMainFrame::getInstance()->onCreateContourLine();
386 // RaC 09-09 ---------------------
387 void interfMainPanel::onCreateContourPoints( )
389 wxContourMainFrame::getInstance()->showAxis(false);
390 wxContourMainFrame::getInstance()->onCreateContourPoints();
392 // RaC 09-09 ---------------------
394 // RaC 10-09 ---------------------
395 void interfMainPanel::onCreateContourPolygon( )
397 wxContourMainFrame::getInstance()->showAxis(false);
398 wxContourMainFrame::getInstance()->onCreateContourPolygon();
400 // RaC 10-09 ---------------------
402 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull)
404 wxContourMainFrame::getInstance()->showAxis(false);
405 wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
408 void interfMainPanel::onDeleteContour()
410 wxContourMainFrame::getInstance()->showAxis(false);
411 wxContourMainFrame::getInstance()->onDeleteContour();
414 void interfMainPanel::onDeleteContoursActSlice()
416 wxContourMainFrame::getInstance()->showAxis(false);
417 wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
420 void interfMainPanel::onDeleteAllContours()
422 wxContourMainFrame::getInstance()->showAxis(false);
423 wxContourMainFrame::getInstance()->onDeleteAllContours();
426 void interfMainPanel::onCopy()
428 wxContourMainFrame::getInstance()->onCopy();
431 void interfMainPanel::onPaste()
433 wxContourMainFrame::getInstance()->onPaste();
436 void interfMainPanel::onUndo()
438 wxContourMainFrame::getInstance()->onUndo();
441 void interfMainPanel::onRedo()
443 wxContourMainFrame::getInstance()->onRedo();
446 void interfMainPanel::onLoad()
448 wxContourMainFrame::getInstance()->onLoad();
451 void interfMainPanel::onSave()
453 wxContourMainFrame::getInstance()->onSave();
456 void interfMainPanel::onImport()
458 wxContourMainFrame::getInstance()->onImport();
461 void interfMainPanel::onTest()
463 printf("EED interfMainPanel::onTest \n");
466 testPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
467 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
468 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
469 testPanel->SetSizer(flexsizer, true);
470 testPanel->SetAutoLayout( true );
471 panelTest = new interfTestPanel(testPanel);
472 wxStaticText* stattext = new wxStaticText(testPanel, -1,
473 wxString(_T(" Test Panel ")),
474 wxDefaultPosition, wxDefaultSize,
475 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
476 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
477 flexsizer->Add(panelTest, wxEXPAND);
480 showPanel(testPanel);
483 void interfMainPanel::RefreshInterface()
485 wxContourMainFrame::getInstance()->RefreshInterface();
488 vtkImageData* interfMainPanel::getImageData()
490 return wxContourMainFrame::getInstance()->getImageData();
493 void interfMainPanel::getImageRange(double range[2] )
495 vtkImageData * img = getImageData();
496 img->GetScalarRange(range);
499 void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method)
501 wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
504 void interfMainPanel::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
506 wxContourMainFrame::getInstance()->onSegmentationOneSliceITK(distance, sigma, alfa, beta, propagation, iterations, inflation);
509 int interfMainPanel::GetImageDataSizeZ()
511 return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
514 void interfMainPanel::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method)
516 wxContourMainFrame::getInstance()->onSegmentationAllSlice(minZ, maxZ,isovalue,sampling,method);
519 void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString)
521 ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
524 void interfMainPanel::onSegmentationPressed()
526 if(segmentPanel == NULL)
528 segmentPanel = new wxPanel(getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
529 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
530 segmentPanel->SetSizer(flexsizer, true);
531 segmentPanel->SetAutoLayout(true);
532 segmentPanel->SetEventHandler(this);
533 //wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
534 segmentationPanel = new interfSegmentationPanelVTK(segmentPanel);
535 wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T(" Automatic Segmentation ")), wxDefaultPosition,
536 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
538 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
539 flexsizer->Add(segmentationPanel, wxEXPAND);
540 segmentPanel->Layout();
542 showPanel(segmentPanel);
543 wxContourMainFrame::getInstance()->showAxis(true);
547 void interfMainPanel::onSegmentationPressedITK()
549 if(segmentPanelITK == NULL)
551 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
552 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
553 segmentPanelITK->SetSizer(flexsizer, true);
554 segmentPanelITK->SetAutoLayout( true );
555 //segmentPanelITK->SetEventHandler(this->contourevent);
557 //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
558 wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
560 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
561 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
563 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
564 flexsizer->Add(panel, wxEXPAND);
565 segmentPanelITK->Layout();
566 }// if segmentPanelITK
567 showPanel(segmentPanelITK);
568 wxContourMainFrame::getInstance()->showAxis(true);
572 void interfMainPanel::onRigidPressed()
574 wxContourMainFrame::getInstance()->onRigidPressed();
577 void interfMainPanel::onWidthOfContour(double width)
579 wxContourMainFrame::getInstance()->onWidthOfContour(width);
582 int interfMainPanel::getColorWindow()
584 return wxContourMainFrame::getInstance()->getColorWindow();
586 int interfMainPanel::getWindowLevel()
588 return wxContourMainFrame::getInstance()->getWindowLevel();
590 void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
592 wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
595 void interfMainPanel::onInterpolation(bool interpolate)
597 wxContourMainFrame::getInstance()->onInterpolation(interpolate);
600 void interfMainPanel::onBeforAfterContour(bool before, bool after)
602 wxContourMainFrame::getInstance()->onBeforeAfterContour(before,after);
605 void interfMainPanel::onJumpSlice(int step, int shift)
607 wxContourMainFrame::getInstance()->onJumpSlice(step,shift);
610 void interfMainPanel::onShowTextContour(bool show)
612 wxContourMainFrame::getInstance()->onShowTextContour(show);
616 void interfMainPanel::onConfigurationPressed()
618 if(configPanel == NULL)
620 configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
621 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
622 configPanel->SetSizer(flexsizer, true);
623 configPanel->SetAutoLayout( true );
624 //configPanel->SetEventHandler(this->contourevent);
625 wxPanel* panel = new interfConfigurationPanel(configPanel);
626 wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T(" Interface Configuration ")), wxDefaultPosition,
627 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
628 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
629 flexsizer->Add(panel, wxEXPAND);
630 configPanel->Layout();
632 showPanel(configPanel);
635 void interfMainPanel::onSpreadPressed()
637 if(spreadPanel==NULL)
639 spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
640 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
641 spreadPanel->SetSizer(flexsizer, true);
642 spreadPanel->SetAutoLayout( true );
643 //spreadPanel->SetEventHandler(this->contourevent);
644 //wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
645 panelSpread = new interfSpreadPanel(spreadPanel);
646 wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T(" Automatic Spread ")), wxDefaultPosition,
647 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
648 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
649 flexsizer->Add(panelSpread, wxEXPAND);
650 spreadPanel->Layout();
652 showPanel(spreadPanel);
656 void interfMainPanel::resetAppend()
658 wxContourMainFrame::getInstance()->resetAppend();
661 void interfMainPanel::onSpreadAdd()
663 wxContourMainFrame::getInstance()->onSpreadAdd();
666 void interfMainPanel::onSpreadAddAll()
668 wxContourMainFrame::getInstance()->onSpreadAddAll();
672 void interfMainPanel::appendStringSpread(std::string val)
674 panelSpread->appendStringSpread(val);
677 void interfMainPanel::onSpreadGo(int type)
679 wxContourMainFrame::getInstance()->onSpreadGo(type);
682 void interfMainPanel::setStringSpread(std::string stringtemp)
684 panelSpread->setStringSpread(stringtemp);
687 void interfMainPanel::onInformationPressed()
692 infoWin = new wxFrame (this, -1,_T(" Statistics "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
693 infoWin->SetSize( wxSize(825,650) );
695 wxSize sizepanel(825,675);
696 informationPanel = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
698 wxFlexGridSizer * sizerPanel = new wxFlexGridSizer(1);
700 sizerPanel -> Add( informationPanel, 1, wxEXPAND ,0);
702 infoWin->SetSizer( sizerPanel );
703 infoWin->SetAutoLayout( true );
707 if (infoWin->IsShown()==true)
709 infoWin->Show(false);
711 //contourevent->FillGridWithContoursInformation();
716 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
719 panelAux = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
721 //------------------------------------------------------------------------------------------------------------
722 // mask view control panel
723 if(infoPanelMask == NULL){
724 infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
725 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
726 infoPanelMask->SetSizer(flexsizer, true);
727 infoPanelMask->SetAutoLayout( true );
728 //configPanel->SetEventHandler(this->contourevent);
729 wxPanel *panel = wxContourMainFrame::getInstance()->getMaskImageViewPanel( infoPanelMask );
730 wxStaticText* stattext = new wxStaticText(infoPanelMask, -1, wxString(_T(" Mask segmentation ")), wxDefaultPosition,
731 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
732 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
733 flexsizer->Add(panel, wxEXPAND);
734 infoPanelMask->Layout();
737 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
739 if(infoPanelCalibration == NULL)
741 infoPanelCalibration = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER , wxString(_T("")));
742 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
743 infoPanelCalibration->SetSizer(flexsizer, true);
744 infoPanelCalibration->SetAutoLayout( true );
745 wxPanel *panel = new interfCalibrationPanel(infoPanelCalibration);
746 wxStaticText* stattext = new wxStaticText(infoPanelCalibration, -1, wxString(_T(" Calibration ")), wxDefaultPosition,
747 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
748 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
749 flexsizer->Add(panel, wxEXPAND);
750 infoPanelCalibration->Layout();
753 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
754 #if wxMAJOR_VERSION <= 2
755 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
757 wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
759 sizer->Add(infoPanelMask);
760 sizer->Add(infoPanelCalibration);
761 panelAux->SetSizer(sizer, true);
762 panelAux->SetAutoLayout( true );
765 //------------------------------------------------------------------
766 wxContourMainFrame::getInstance()->changeInstant();
770 void interfMainPanel::getInstantVector(std::vector<int>& tempVector)
772 wxContourMainFrame::getInstance()->getInstantVector(tempVector);
775 std::vector<std::string> interfMainPanel::getOutlinesName(int slide)
777 return wxContourMainFrame::getInstance()->getOutlinesName(slide);
780 void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ,int grayRangeMin,int grayRangeMax){
781 wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ,grayRangeMin,grayRangeMax);
784 void interfMainPanel::setStringInfoPanel(wxString tmpString)
786 if(informationPanel!=NULL){
787 ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
791 void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString)
793 ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
796 int interfMainPanel::getNumberColsInformationPanel()
798 return ((interfInformationPanel*)informationPanel)->getNumberCols();
801 void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics)
803 ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
806 void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString)
808 ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
811 void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString)
813 ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
817 void interfMainPanel::SetScalarRange(int grayRangeMin,int grayRangeMax)
819 wxContourMainFrame::getInstance()->SetScalarRange(grayRangeMin, grayRangeMax);
822 void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename,
823 int typeContourGroup, int selection, int minZ, int maxZ ,bool XYZValues, bool contourImage, bool statistics)
825 wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename,
826 typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
829 wxString interfMainPanel::getCellValue(int j,int i){
830 return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
833 void interfMainPanel::onSnakePressed()
836 wxContourMainFrame::getInstance()->showAxis(axisshown);
837 wxContourMainFrame::getInstance()->onSnakePressed();
840 void interfMainPanel::onMirrorPressed(){
841 if(mirrorPanel==NULL)
844 mirrorPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
845 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
846 mirrorPanel->SetSizer(flexsizer, true);
847 mirrorPanel->SetAutoLayout( true );
848 panelMirror = new interfMirrorPanel(mirrorPanel);
849 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1, wxString(_T(" Mirroring Tool ")), wxDefaultPosition,
850 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
852 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
853 flexsizer->Add(panelMirror, wxEXPAND);
854 mirrorPanel->Layout();
856 wxContourMainFrame::getInstance()->referenceLine();
860 wxContourMainFrame::getInstance()->refLineShow();
865 showPanel(mirrorPanel);
868 void interfMainPanel::onMirror()
870 wxContourMainFrame::getInstance()->onMirror();
873 void interfMainPanel::onMirrorAxisShow()
877 wxContourMainFrame::getInstance()->refLineShow();
882 void interfMainPanel::onMirrorAxisHide()
886 wxContourMainFrame::getInstance()->refLineHide();
891 void interfMainPanel::onMirrorChangeWidth(int width)
893 wxContourMainFrame::getInstance()->refLineChangeWidth(width);
897 void interfMainPanel::onColorLayerImagePressed()
899 // Color Image Layer view control panel
900 if(colorImageLayerPanel == NULL){
901 colorImageLayerPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
902 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
903 colorImageLayerPanel->SetSizer(flexsizer, true);
904 colorImageLayerPanel->SetAutoLayout( true );
905 //configPanel->SetEventHandler(this->contourevent);
906 wxPanel *panel = wxContourMainFrame::getInstance()->getColorLayerImageViewPanel( colorImageLayerPanel );
907 wxStaticText* stattext = new wxStaticText(colorImageLayerPanel, -1, wxString(_T(" Color Image Layer ")), wxDefaultPosition,
908 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
909 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
910 flexsizer->Add(panel, wxEXPAND);
911 colorImageLayerPanel->Layout();
913 showPanel(colorImageLayerPanel);
914 wxContourMainFrame::getInstance()->changeInstant();
918 void interfMainPanel::onThresholdPressed()
920 // Threshold view control panel
921 if(thresholdPanel == NULL){
922 thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
923 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
924 thresholdPanel->SetSizer(flexsizer, true);
925 thresholdPanel->SetAutoLayout( true );
926 //configPanel->SetEventHandler(this->contourevent);
927 wxPanel *panel = wxContourMainFrame::getInstance()->getThresholdImageViewPanel( thresholdPanel );
928 wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T(" Threshold segmentation ")), wxDefaultPosition,
929 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
930 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
931 flexsizer->Add(panel, wxEXPAND);
932 thresholdPanel->Layout();
934 showPanel(thresholdPanel);
935 wxContourMainFrame::getInstance()->changeInstant();
939 void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
941 wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
945 void interfMainPanel::SetContourGroup(int contourGroup)
947 wxContourMainFrame::getInstance()->SetContourGroup( contourGroup);
951 void interfMainPanel::onFlipContours()
953 printf("EED interfMainPanel::onFlipContours() \n");
956 flipPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
957 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
958 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
959 flipPanel->SetSizer(flexsizer, true);
960 flipPanel->SetAutoLayout( true );
961 panelFlip = new interfFlipPanel(flipPanel);
962 wxStaticText* stattext = new wxStaticText(flipPanel, -1,
963 wxString(_T(" Flip Contours ")),
964 wxDefaultPosition, wxDefaultSize,
965 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
966 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
967 flexsizer->Add(panelFlip, wxEXPAND);
970 showPanel(flipPanel);
974 void interfMainPanel::FlipContours(int typeContourFlip, int flipDirection)
976 printf("EED interfMainPanel::FlipContours( %d , %d ) \n",typeContourFlip, flipDirection );
977 wxContourMainFrame::getInstance()->FlipContours( typeContourFlip , flipDirection );
982 //CMRU 17-08-09 ---------------------------------------------
983 void interfMainPanel::onPrintLabel ()
986 manualBaseModel* manualModel = wxContourMainFrame::getInstance()->getContour();
988 if(manualModel==NULL)
990 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a Contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
995 wxTextEntryDialog* dialog = new wxTextEntryDialog(this,_T("Enter a tag name: ")) ;
997 if (dialog->ShowModal() == wxID_OK)
999 label = dialog->GetValue();
1003 wxContourMainFrame::getInstance()->onPrintLabel(label,manualModel);
1004 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The tag name was updated"), wxT("Information"), wxOK | wxICON_INFORMATION);
1009 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a valid tag"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1015 void interfMainPanel::onCalibration(wxString size, int unit)
1018 double contourSize = 0.0;
1019 double realSizeDouble = 0.0;
1021 type = wxContourMainFrame::getInstance()->getType();
1022 contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels();
1024 std::cout<<"Cata->Tama�o del contorno en pixeles:"<<contourSize<<endl;
1028 if (size.ToDouble(&realSizeDouble))
1032 realSizeDouble = realSizeDouble * 10;
1036 realSizeDouble = realSizeDouble * 25.4;
1038 std::cout<< "Valor del usuario" << realSizeDouble<< endl ;
1039 onePixelSize (realSizeDouble,contourSize);
1043 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a numeric value"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1049 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a line contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1053 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The calibration was made"), wxT("Information"), wxOK | wxICON_INFORMATION);
1055 std::cout<< "Cata-> Se ha realizado la calibracion" << endl ;
1058 double interfMainPanel::onePixelSize (double realSize,double sizePixel)
1060 _pixelValue = realSize/sizePixel;
1061 std::cout<< "Valor del un pixel = " << _pixelValue<< endl ;
1062 wxContourMainFrame::getInstance()->onePixelSize (_pixelValue);
1063 return _pixelValue ;
1066 double interfMainPanel::GetPixelValue()
1070 //------------------------------------------------------------------------------------------------------------