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)
36 PANEL = "New Contour";
40 PANEL4 = "Contour Tools";
41 PANEL5 = "Segmentation";
43 PANEL6 = "Image Tools";
46 segmentPanelITK = NULL;
52 informationPanel = NULL;
54 thresholdPanel = NULL;
55 colorImageLayerPanel = NULL;
60 //CMRU 17-08-09 ------------------------------------------------------------------
61 infoPanelCalibration = NULL;
63 //--------------------------------------------------------------------------------
64 splitterwindow = new wxSplitterWindow(this,-1, wxDefaultPosition, wxSize(sizex, sizey), wxSP_3DSASH, wxString(_T("")));
66 splitterwindow->SetMinimumPaneSize( 10 );
69 wxPanel* toolpanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
71 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(6,2,1,1);
72 toolpanel->SetSizer(flexsizer, true);
73 toolpanel->SetAutoLayout( true );
75 wxButton* b = getButton(toolpanel);
76 b->SetClientData(&PANEL);
77 wxButton* b1 = getButton(toolpanel);
78 b1->SetClientData(&PANEL1);
79 wxButton* b2 = getButton(toolpanel);
80 b2->SetClientData(&PANEL2);
81 wxButton* b3 = getButton(toolpanel);
82 b3->SetClientData(&PANEL3);
83 wxButton* b4 = getButton(toolpanel);
84 b4->SetClientData(&PANEL4);
85 wxButton* b5 = getButton(toolpanel);
86 b5->SetClientData(&PANEL5);
88 wxButton* b6 = getButton(toolpanel);
89 b6->SetClientData(&PANEL6);
92 wxPanel* mentex = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
93 wxPanel* mentex1 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
94 wxPanel* mentex2 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
95 wxPanel* mentex3 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
96 wxPanel* mentex4 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
97 wxPanel* mentex5 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
99 wxPanel* mentex6 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
101 menubar = new interfNewContourMenu (mentex, sizex, sizey, evtHandler, datadir);
102 menubar1 = new interfIOMenu (mentex1, sizex, sizey, evtHandler, datadir);
103 menubar2 = new interfEditMenu (mentex2, sizex, sizey, evtHandler, datadir);
104 menubar3 = new interfDeleteMenu (mentex3, sizex, sizey, evtHandler, datadir);
105 menubar4 = new interfToolsMenu (mentex4, sizex ,sizey, evtHandler, datadir);
106 menubar5 = new interfSegmentationMenu(mentex5, sizex, sizey, evtHandler, datadir);
107 menubar6 = new interfImageToolsMenu(mentex6, sizex, sizey, evtHandler, datadir);
109 statictext = getText(mentex, PANEL);
110 statictext1 = getText(mentex1, PANEL1);
111 statictext2 = getText(mentex2, PANEL2);
112 statictext3 = getText(mentex3, PANEL3);
113 statictext4 = getText(mentex4, PANEL4);
114 statictext5 = getText(mentex5, PANEL5);
115 statictext6 = getText(mentex6, PANEL6);
117 flexsizer->Add(b, wxFIXED_MINSIZE);
118 flexsizer->Add(setMenuTextSizer(mentex, menubar,statictext), wxFIXED_MINSIZE);
120 flexsizer->Add(b1, wxFIXED_MINSIZE);
121 flexsizer->Add(setMenuTextSizer(mentex1, menubar1,statictext1), wxFIXED_MINSIZE);
123 flexsizer->Add(b2, wxFIXED_MINSIZE);
124 flexsizer->Add(setMenuTextSizer(mentex2, menubar2,statictext2), wxFIXED_MINSIZE);
126 flexsizer->Add(b3, wxFIXED_MINSIZE);
127 flexsizer->Add(setMenuTextSizer(mentex3, menubar3,statictext3), wxFIXED_MINSIZE);
129 flexsizer->Add(b4, wxFIXED_MINSIZE);
130 flexsizer->Add(setMenuTextSizer(mentex4, menubar4,statictext4), wxFIXED_MINSIZE);
132 flexsizer->Add(b5, wxFIXED_MINSIZE);
133 flexsizer->Add(setMenuTextSizer(mentex5, menubar5,statictext5), wxFIXED_MINSIZE);
134 flexsizer->Add(b6, wxFIXED_MINSIZE);
135 flexsizer->Add(setMenuTextSizer(mentex6, menubar6,statictext6), wxFIXED_MINSIZE);
140 infoPanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
141 wxFlexGridSizer* infosizer = new wxFlexGridSizer(1,1,2,2);
142 infoPanel->SetSizer(infosizer, true);
143 infoPanel->SetAutoLayout( true );
145 splitterwindow->Initialize(toolpanel);
146 splitterwindow->SetSashGravity(1);
147 //EED splitterwindow->SetSashPosition(600);
148 splitterwindow->SetSashSize(5);
149 splitterwindow->SplitHorizontally(toolpanel, infoPanel,8*73);
151 Connect(b->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
152 Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
153 Connect(b2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
154 Connect(b3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
155 Connect(b4->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
156 Connect(b5->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
157 Connect(b6->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
162 interfMainPanel::~interfMainPanel(void)
167 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler)
169 _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);
171 if(interfmainpanel == NULL){
172 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler, datadir);
174 _newframe->Show(TRUE);
175 return interfmainpanel;
178 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler)
181 _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 );
183 if(interfmainpanel == NULL){
184 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler);
186 _newframe->Show(TRUE);
187 return interfmainpanel;
190 bool interfMainPanel::Show(bool show)
192 return _newframe->Show(show);
195 interfMainPanel* interfMainPanel::getInstance()
197 return interfmainpanel;
200 void interfMainPanel :: resetInstance()
202 //delete interfmainpanel;
204 interfmainpanel = NULL;
207 wxPanel* interfMainPanel::initializeToolsPanel(wxWindow* parent, int sizex, int sizey, wxEvtHandler * evtHandler)
209 wxPanel* panel = new wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN, wxString(_T("Spread")));
211 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2) ;
212 panel->SetSizer(flexsizer, true);
213 panel->SetAutoLayout( true );
215 interfToolsMenu* menu = new interfToolsMenu(panel, sizex, sizey, evtHandler);
216 toolspread = new interfToolsSpreadPanel(panel, sizex, 300, evtHandler);
218 flexsizer->Add(menu, wxFIXED_MINSIZE);
219 flexsizer->Add(toolspread, wxFIXED_MINSIZE);
227 ** Adds a new checkbox to the scrolledwindow using the checkboxsizer
228 ** @Params id of contour
231 void interfMainPanel::addContourCheckBox(std::string id)
233 toolspread->addContourCheckBox(id);
237 ** Removes a checkbox from the list of checkboxes in the flexsizer (checkboxsizer)
238 ** @Params id of contour
241 void interfMainPanel::removeContourCheckBox(std::string id)
243 toolspread->removeContourCheckBox(id);
246 void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event )
248 //((interfToolsMenu*)menubar4)->hideAxis();
249 wxButton* b = (wxButton*)event.GetEventObject();
252 std::string dstring = *((std::string*) b->GetClientData());
255 if(dstring.compare(PANEL)==0){
258 }else if(dstring.compare(PANEL1)==0 ){
261 }else if(dstring.compare(PANEL2)==0){
264 }else if(dstring.compare(PANEL3)==0){
267 }else if(dstring.compare(PANEL4)==0){
270 }else if(dstring.compare(PANEL5)==0){
273 }else if(dstring.compare(PANEL6)==0){
278 if(wxStrcmp(b->GetLabel(),_T("+"))==0 ){
281 b->SetLabel(_T("-"));
285 b->SetLabel(_T("+"));
288 sizechange *= (dmenu->GetSize().GetHeight()-10);
289 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+sizechange);
295 wxStaticText* interfMainPanel::getText(wxWindow* parent, std::string nom)
297 return new wxStaticText(parent, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition,
298 wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
301 wxButton* interfMainPanel::getButton(wxWindow* parent)
303 wxButton* b = new wxButton(parent, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
304 wxDefaultValidator, wxString(_T("-")));
308 wxPanel* interfMainPanel::setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text)
311 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2);
312 parent->SetSizer(flexsizer, true);
313 parent->SetAutoLayout( true );
315 flexsizer->Add(text, wxFLEX_GROWMODE_ALL);
316 flexsizer->Add(panel, wxFLEX_GROWMODE_ALL);
319 return (wxPanel*)parent;
323 ** Shows the panel in the
325 void interfMainPanel::showPanel(wxWindow* panel)
327 wxContourMainFrame::getInstance()->showAxis(false);
328 wxSizer* sizer = infoPanel->GetSizer();
330 if(currentWindow != NULL){
331 currentWindow->Hide();
332 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated
333 sizer->Remove(currentWindow);
336 currentWindow = panel;
337 currentWindow->Show(true);
339 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
340 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
343 infoPanel->Refresh();
349 ** Hide the panel in the lower box
351 void interfMainPanel::hidePanel( )
353 wxContourMainFrame::getInstance()->showAxis(false);
354 wxSizer* sizer = infoPanel->GetSizer();
356 if(currentWindow != NULL){
357 currentWindow->Hide();
358 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated
359 sizer->Remove(currentWindow);
361 wxPanel * emptyPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
362 sizer->Add(emptyPanel);
363 currentWindow = emptyPanel;
364 currentWindow->Show(true);
366 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
367 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
370 infoPanel->Refresh();
376 ** Gets the Information panel
378 wxPanel* interfMainPanel::getInfoPanel()
383 void interfMainPanel::onCreateContourSpline( )
385 wxContourMainFrame::getInstance()->showAxis(false);
386 wxContourMainFrame::getInstance()->onCreateContourSpline();
389 void interfMainPanel::onCreateContourRectangle( )
391 wxContourMainFrame::getInstance()->showAxis(false);
392 wxContourMainFrame::getInstance()->onCreateContourRectangle();
394 void interfMainPanel::onCreateContourCircle( )
396 wxContourMainFrame::getInstance()->showAxis(false);
397 wxContourMainFrame::getInstance()->onCreateContourCircle();
400 void interfMainPanel::onCreateContourLine( )
402 wxContourMainFrame::getInstance()->showAxis(false);
403 wxContourMainFrame::getInstance()->onCreateContourLine();
406 // RaC 09-09 ---------------------
407 void interfMainPanel::onCreateContourPoints( )
409 wxContourMainFrame::getInstance()->showAxis(false);
410 wxContourMainFrame::getInstance()->onCreateContourPoints();
412 // RaC 09-09 ---------------------
414 // RaC 10-09 ---------------------
415 void interfMainPanel::onCreateContourPolygon( )
417 wxContourMainFrame::getInstance()->showAxis(false);
418 wxContourMainFrame::getInstance()->onCreateContourPolygon();
420 // RaC 10-09 ---------------------
422 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull)
424 wxContourMainFrame::getInstance()->showAxis(false);
425 wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
428 void interfMainPanel::onDeleteContour()
430 wxContourMainFrame::getInstance()->showAxis(false);
431 wxContourMainFrame::getInstance()->onDeleteContour();
434 void interfMainPanel::onDeleteContoursActSlice()
436 wxContourMainFrame::getInstance()->showAxis(false);
437 wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
440 void interfMainPanel::onDeleteAllContours()
442 wxContourMainFrame::getInstance()->showAxis(false);
443 wxContourMainFrame::getInstance()->onDeleteAllContours();
446 void interfMainPanel::onCopy()
448 wxContourMainFrame::getInstance()->onCopy();
451 void interfMainPanel::onPaste()
453 wxContourMainFrame::getInstance()->onPaste();
456 void interfMainPanel::onUndo()
458 wxContourMainFrame::getInstance()->onUndo();
461 void interfMainPanel::onRedo()
463 wxContourMainFrame::getInstance()->onRedo();
466 void interfMainPanel::onLoad()
468 wxContourMainFrame::getInstance()->onLoad();
471 void interfMainPanel::onSave()
473 wxContourMainFrame::getInstance()->onSave();
476 void interfMainPanel::onImport()
478 wxContourMainFrame::getInstance()->onImport();
481 void interfMainPanel::onTest()
483 printf("EED interfMainPanel::onTest \n");
486 testPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
487 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
488 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
489 testPanel->SetSizer(flexsizer, true);
490 testPanel->SetAutoLayout( true );
491 panelTest = new interfTestPanel(testPanel);
492 wxStaticText* stattext = new wxStaticText(testPanel, -1,
493 wxString(_T(" Test Panel ")),
494 wxDefaultPosition, wxDefaultSize,
495 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
496 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
497 flexsizer->Add(panelTest, wxEXPAND);
500 showPanel(testPanel);
503 void interfMainPanel::RefreshInterface()
505 wxContourMainFrame::getInstance()->RefreshInterface();
508 vtkImageData* interfMainPanel::getImageData()
510 return wxContourMainFrame::getInstance()->getImageData();
513 void interfMainPanel::getImageRange(double range[2] )
515 vtkImageData * img = getImageData();
516 img->GetScalarRange(range);
519 void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method)
521 wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
524 void interfMainPanel::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
526 wxContourMainFrame::getInstance()->onSegmentationOneSliceITK(distance, sigma, alfa, beta, propagation, iterations, inflation);
529 int interfMainPanel::GetImageDataSizeZ()
531 return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
534 void interfMainPanel::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method)
536 wxContourMainFrame::getInstance()->onSegmentationAllSlice(minZ, maxZ,isovalue,sampling,method);
539 void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString)
541 ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
543 void interfMainPanel::onSegmentationPressed()
545 if(segmentPanel == NULL){
546 segmentPanel = new wxPanel(getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
547 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
548 segmentPanel->SetSizer(flexsizer, true);
549 segmentPanel->SetAutoLayout(true);
550 segmentPanel->SetEventHandler(this);
552 //wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
553 segmentationPanel = new interfSegmentationPanelVTK(segmentPanel);
556 wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T(" Automatic Segmentation ")), wxDefaultPosition,
557 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
559 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
560 flexsizer->Add(segmentationPanel, wxEXPAND);
561 segmentPanel->Layout();
563 showPanel(segmentPanel);
564 wxContourMainFrame::getInstance()->showAxis(true);
568 void interfMainPanel::onSegmentationPressedITK()
570 if(segmentPanelITK == NULL){
571 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
574 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
575 segmentPanelITK->SetSizer(flexsizer, true);
576 segmentPanelITK->SetAutoLayout( true );
577 //segmentPanelITK->SetEventHandler(this->contourevent);
579 //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
580 wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
582 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
583 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
585 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
586 flexsizer->Add(panel, wxEXPAND);
587 segmentPanelITK->Layout();
589 showPanel(segmentPanelITK);
590 wxContourMainFrame::getInstance()->showAxis(true);
594 void interfMainPanel::onRigidPressed()
596 wxContourMainFrame::getInstance()->onRigidPressed();
599 void interfMainPanel::onWidthOfContour(double width)
601 wxContourMainFrame::getInstance()->onWidthOfContour(width);
604 int interfMainPanel::getColorWindow()
606 return wxContourMainFrame::getInstance()->getColorWindow();
608 int interfMainPanel::getWindowLevel()
610 return wxContourMainFrame::getInstance()->getWindowLevel();
612 void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
614 wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
617 void interfMainPanel::onInterpolation(bool interpolate)
619 wxContourMainFrame::getInstance()->onInterpolation(interpolate);
623 void interfMainPanel::onConfigurationPressed()
625 if(configPanel == NULL){
626 configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
627 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
628 configPanel->SetSizer(flexsizer, true);
629 configPanel->SetAutoLayout( true );
630 //configPanel->SetEventHandler(this->contourevent);
631 wxPanel* panel = new interfConfigurationPanel(configPanel);
632 wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T(" Interface Configuration ")), wxDefaultPosition,
633 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
634 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
635 flexsizer->Add(panel, wxEXPAND);
636 configPanel->Layout();
638 showPanel(configPanel);
641 void interfMainPanel::onSpreadPressed()
643 if(spreadPanel==NULL){
645 spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
646 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
647 spreadPanel->SetSizer(flexsizer, true);
648 spreadPanel->SetAutoLayout( true );
649 //spreadPanel->SetEventHandler(this->contourevent);
651 //wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
652 panelSpread = new interfSpreadPanel(spreadPanel);
655 wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T(" Automatic Spread ")), wxDefaultPosition,
656 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
658 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
659 flexsizer->Add(panelSpread, wxEXPAND);
660 spreadPanel->Layout();
662 showPanel(spreadPanel);
666 void interfMainPanel::resetAppend()
668 wxContourMainFrame::getInstance()->resetAppend();
671 void interfMainPanel::onSpreadAdd()
673 wxContourMainFrame::getInstance()->onSpreadAdd();
676 void interfMainPanel::onSpreadAddAll()
678 wxContourMainFrame::getInstance()->onSpreadAddAll();
682 void interfMainPanel::appendStringSpread(std::string val)
684 panelSpread->appendStringSpread(val);
687 void interfMainPanel::onSpreadGo(int type)
689 wxContourMainFrame::getInstance()->onSpreadGo(type);
692 void interfMainPanel::setStringSpread(std::string stringtemp)
694 panelSpread->setStringSpread(stringtemp);
697 void interfMainPanel::onInformationPressed()
702 infoWin = new wxFrame (this, -1,_T(" Statistics "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
703 infoWin->SetSize( wxSize(825,650) );
705 wxSize sizepanel(825,675);
706 informationPanel = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
708 wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
709 sizerPanel -> Add( informationPanel, 1, wxEXPAND ,0);
711 infoWin->SetSizer( sizerPanel );
712 infoWin->SetAutoLayout( true );
717 if (infoWin->IsShown()==true)
719 infoWin->Show(false);
721 //contourevent->FillGridWithContoursInformation();
726 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
729 panelAux = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
731 //------------------------------------------------------------------------------------------------------------
733 // mask view control panel
734 if(infoPanelMask == NULL){
735 infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
736 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
737 infoPanelMask->SetSizer(flexsizer, true);
738 infoPanelMask->SetAutoLayout( true );
739 //configPanel->SetEventHandler(this->contourevent);
740 wxPanel *panel = wxContourMainFrame::getInstance()->getMaskImageViewPanel( infoPanelMask );
741 wxStaticText* stattext = new wxStaticText(infoPanelMask, -1, wxString(_T(" Mask segmentation ")), wxDefaultPosition,
742 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
744 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
746 flexsizer->Add(panel, wxEXPAND);
747 infoPanelMask->Layout();
751 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
753 if(infoPanelCalibration == NULL)
755 infoPanelCalibration = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER , wxString(_T("")));
756 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
757 infoPanelCalibration->SetSizer(flexsizer, true);
758 infoPanelCalibration->SetAutoLayout( true );
760 wxPanel *panel = new interfCalibrationPanel(infoPanelCalibration);
761 wxStaticText* stattext = new wxStaticText(infoPanelCalibration, -1, wxString(_T(" Calibration ")), wxDefaultPosition,
762 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
764 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
766 flexsizer->Add(panel, wxEXPAND);
767 infoPanelCalibration->Layout();
770 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
771 panelAux->SetSizer(sizer, true);
772 panelAux->SetAutoLayout( true );
773 sizer->Add(infoPanelMask);
774 sizer->Add(infoPanelCalibration);
778 //------------------------------------------------------------------
780 wxContourMainFrame::getInstance()->changeInstant();
783 void interfMainPanel::getInstantVector(std::vector<int>& tempVector)
785 wxContourMainFrame::getInstance()->getInstantVector(tempVector);
788 std::vector<std::string> interfMainPanel::getOutlinesName(int slide)
790 return wxContourMainFrame::getInstance()->getOutlinesName(slide);
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);
797 void interfMainPanel::setStringInfoPanel(wxString tmpString)
799 if(informationPanel!=NULL){
800 ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
804 void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString)
806 ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
809 int interfMainPanel::getNumberColsInformationPanel()
811 return ((interfInformationPanel*)informationPanel)->getNumberCols();
814 void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics)
816 ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
819 void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString)
821 ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
824 void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString)
826 ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
830 void interfMainPanel::SetScalarRange(int grayRangeMin,int grayRangeMax)
832 wxContourMainFrame::getInstance()->SetScalarRange(grayRangeMin, grayRangeMax);
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)
838 wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename,
839 typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
842 wxString interfMainPanel::getCellValue(int j,int i){
843 return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
846 void interfMainPanel::onSnakePressed()
849 wxContourMainFrame::getInstance()->showAxis(axisshown);
850 wxContourMainFrame::getInstance()->onSnakePressed();
853 void interfMainPanel::onMirrorPressed(){
854 if(mirrorPanel==NULL)
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);
863 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1, wxString(_T(" Mirroring Tool ")), wxDefaultPosition,
864 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
866 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
867 flexsizer->Add(panelMirror, wxEXPAND);
868 mirrorPanel->Layout();
871 wxContourMainFrame::getInstance()->referenceLine();
879 wxContourMainFrame::getInstance()->refLineShow();
884 showPanel(mirrorPanel);
887 void interfMainPanel::onMirror()
889 wxContourMainFrame::getInstance()->onMirror();
892 void interfMainPanel::onMirrorAxisShow()
896 wxContourMainFrame::getInstance()->refLineShow();
901 void interfMainPanel::onMirrorAxisHide()
905 wxContourMainFrame::getInstance()->refLineHide();
910 void interfMainPanel::onMirrorChangeWidth(int width)
912 wxContourMainFrame::getInstance()->refLineChangeWidth(width);
916 void interfMainPanel::onColorLayerImagePressed()
918 // Color Image Layer view control panel
919 if(colorImageLayerPanel == NULL){
920 colorImageLayerPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
921 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
922 colorImageLayerPanel->SetSizer(flexsizer, true);
923 colorImageLayerPanel->SetAutoLayout( true );
924 //configPanel->SetEventHandler(this->contourevent);
925 wxPanel *panel = wxContourMainFrame::getInstance()->getColorLayerImageViewPanel( colorImageLayerPanel );
926 wxStaticText* stattext = new wxStaticText(colorImageLayerPanel, -1, wxString(_T(" Color Image Layer ")), wxDefaultPosition,
927 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
928 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
929 flexsizer->Add(panel, wxEXPAND);
930 colorImageLayerPanel->Layout();
932 showPanel(colorImageLayerPanel);
933 wxContourMainFrame::getInstance()->changeInstant();
937 void interfMainPanel::onThresholdPressed()
939 // Threshold view control panel
940 if(thresholdPanel == NULL){
941 thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
942 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
943 thresholdPanel->SetSizer(flexsizer, true);
944 thresholdPanel->SetAutoLayout( true );
945 //configPanel->SetEventHandler(this->contourevent);
946 wxPanel *panel = wxContourMainFrame::getInstance()->getThresholdImageViewPanel( thresholdPanel );
947 wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T(" Threshold segmentation ")), wxDefaultPosition,
948 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
949 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
950 flexsizer->Add(panel, wxEXPAND);
951 thresholdPanel->Layout();
953 showPanel(thresholdPanel);
954 wxContourMainFrame::getInstance()->changeInstant();
958 void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
960 wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
964 void interfMainPanel::SetContourGroup(int contourGroup)
966 wxContourMainFrame::getInstance()->SetContourGroup( contourGroup);
970 void interfMainPanel::onFlipContours()
972 printf("EED interfMainPanel::onFlipContours() \n");
975 flipPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
976 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
977 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
978 flipPanel->SetSizer(flexsizer, true);
979 flipPanel->SetAutoLayout( true );
980 panelFlip = new interfFlipPanel(flipPanel);
981 wxStaticText* stattext = new wxStaticText(flipPanel, -1,
982 wxString(_T(" Flip Contours ")),
983 wxDefaultPosition, wxDefaultSize,
984 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
985 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
986 flexsizer->Add(panelFlip, wxEXPAND);
989 showPanel(flipPanel);
993 void interfMainPanel::FlipContours(int typeContourFlip, int flipDirection)
995 printf("EED interfMainPanel::FlipContours( %d , %d ) \n",typeContourFlip, flipDirection );
996 wxContourMainFrame::getInstance()->FlipContours( typeContourFlip , flipDirection );
1001 //CMRU 17-08-09 ---------------------------------------------
1002 void interfMainPanel::onPrintLabel ()
1005 manualBaseModel* manualModel = wxContourMainFrame::getInstance()->getContour();
1007 if(manualModel==NULL)
1009 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a Contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1014 wxTextEntryDialog* dialog = new wxTextEntryDialog(this,_T("Enter a tag name: ")) ;
1016 if (dialog->ShowModal() == wxID_OK)
1018 label = dialog->GetValue();
1022 wxContourMainFrame::getInstance()->onPrintLabel(label,manualModel);
1023 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The tag name was updated"), wxT("Information"), wxOK | wxICON_INFORMATION);
1028 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a valid tag"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1034 void interfMainPanel::onCalibration(wxString size, int unit)
1037 double contourSize = 0.0;
1038 double realSizeDouble = 0.0;
1040 type = wxContourMainFrame::getInstance()->getType();
1041 contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels();
1043 std::cout<<"Cata->Tama�o del contorno en pixeles:"<<contourSize<<endl;
1047 if (size.ToDouble(&realSizeDouble))
1051 realSizeDouble = realSizeDouble * 10;
1055 realSizeDouble = realSizeDouble * 25.4;
1057 std::cout<< "Valor del usuario" << realSizeDouble<< endl ;
1058 onePixelSize (realSizeDouble,contourSize);
1062 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a numeric value"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1068 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a line contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1072 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The calibration was made"), wxT("Information"), wxOK | wxICON_INFORMATION);
1074 std::cout<< "Cata-> Se ha realizado la calibracion" << endl ;
1077 double interfMainPanel::onePixelSize (double realSize,double sizePixel)
1079 _pixelValue = realSize/sizePixel;
1080 std::cout<< "Valor del un pixel = " << _pixelValue<< endl ;
1081 wxContourMainFrame::getInstance()->onePixelSize (_pixelValue);
1082 return _pixelValue ;
1085 double interfMainPanel::GetPixelValue()
1089 //------------------------------------------------------------------------------------------------------------