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("")));
65 splitterwindow->SetMinimumPaneSize( 10 );
68 wxPanel* toolpanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
70 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
71 #if wxMAJOR_VERSION <= 2
72 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(6,2,1,1);
74 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(6);
76 toolpanel->SetSizer(flexsizer, true);
77 toolpanel->SetAutoLayout( true );
79 wxButton* b = getButton(toolpanel);
80 b->SetClientData(&PANEL);
81 wxButton* b1 = getButton(toolpanel);
82 b1->SetClientData(&PANEL1);
83 wxButton* b2 = getButton(toolpanel);
84 b2->SetClientData(&PANEL2);
85 wxButton* b3 = getButton(toolpanel);
86 b3->SetClientData(&PANEL3);
87 wxButton* b4 = getButton(toolpanel);
88 b4->SetClientData(&PANEL4);
89 wxButton* b5 = getButton(toolpanel);
90 b5->SetClientData(&PANEL5);
92 wxButton* b6 = getButton(toolpanel);
93 b6->SetClientData(&PANEL6);
95 wxPanel* mentex = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
96 wxPanel* mentex1 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
97 wxPanel* mentex2 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
98 wxPanel* mentex3 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
99 wxPanel* mentex4 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
100 wxPanel* mentex5 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
102 wxPanel* mentex6 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
104 menubar = new interfNewContourMenu (mentex, sizex, sizey, evtHandler, datadir);
105 menubar1 = new interfIOMenu (mentex1, sizex, sizey, evtHandler, datadir);
106 menubar2 = new interfEditMenu (mentex2, sizex, sizey, evtHandler, datadir);
107 menubar3 = new interfDeleteMenu (mentex3, sizex, sizey, evtHandler, datadir);
108 menubar4 = new interfToolsMenu (mentex4, sizex ,sizey, evtHandler, datadir);
109 menubar5 = new interfSegmentationMenu(mentex5, sizex, sizey, evtHandler, datadir);
110 menubar6 = new interfImageToolsMenu(mentex6, sizex, sizey, evtHandler, datadir);
112 statictext = getText(mentex, PANEL);
113 statictext1 = getText(mentex1, PANEL1);
114 statictext2 = getText(mentex2, PANEL2);
115 statictext3 = getText(mentex3, PANEL3);
116 statictext4 = getText(mentex4, PANEL4);
117 statictext5 = getText(mentex5, PANEL5);
118 statictext6 = getText(mentex6, PANEL6);
120 flexsizer->Add(b, wxFIXED_MINSIZE);
121 flexsizer->Add(setMenuTextSizer(mentex, menubar,statictext), wxFIXED_MINSIZE);
123 flexsizer->Add(b1, wxFIXED_MINSIZE);
124 flexsizer->Add(setMenuTextSizer(mentex1, menubar1,statictext1), wxFIXED_MINSIZE);
126 flexsizer->Add(b2, wxFIXED_MINSIZE);
127 flexsizer->Add(setMenuTextSizer(mentex2, menubar2,statictext2), wxFIXED_MINSIZE);
129 flexsizer->Add(b3, wxFIXED_MINSIZE);
130 flexsizer->Add(setMenuTextSizer(mentex3, menubar3,statictext3), wxFIXED_MINSIZE);
132 flexsizer->Add(b4, wxFIXED_MINSIZE);
133 flexsizer->Add(setMenuTextSizer(mentex4, menubar4,statictext4), wxFIXED_MINSIZE);
135 flexsizer->Add(b5, wxFIXED_MINSIZE);
136 flexsizer->Add(setMenuTextSizer(mentex5, menubar5,statictext5), wxFIXED_MINSIZE);
137 flexsizer->Add(b6, wxFIXED_MINSIZE);
138 flexsizer->Add(setMenuTextSizer(mentex6, menubar6,statictext6), wxFIXED_MINSIZE);
143 infoPanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
144 wxFlexGridSizer* infosizer = new wxFlexGridSizer(1,1,2,2);
145 infoPanel->SetSizer(infosizer, true);
146 infoPanel->SetAutoLayout( true );
148 splitterwindow->Initialize(toolpanel);
149 splitterwindow->SetSashGravity(1);
150 //EED splitterwindow->SetSashPosition(600);
151 splitterwindow->SetSashSize(5);
152 splitterwindow->SplitHorizontally(toolpanel, infoPanel,8*73);
154 Connect(b->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
155 Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
156 Connect(b2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
157 Connect(b3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
158 Connect(b4->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
159 Connect(b5->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
160 Connect(b6->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
165 interfMainPanel::~interfMainPanel(void)
170 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler)
172 _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);
174 if(interfmainpanel == NULL){
175 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler, datadir);
177 _newframe->Show(TRUE);
178 return interfmainpanel;
181 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler)
184 _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 );
186 if(interfmainpanel == NULL){
187 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler);
189 _newframe->Show(TRUE);
190 return interfmainpanel;
193 bool interfMainPanel::Show(bool show)
195 return _newframe->Show(show);
198 interfMainPanel* interfMainPanel::getInstance()
200 return interfmainpanel;
203 void interfMainPanel :: resetInstance()
205 //delete interfmainpanel;
207 interfmainpanel = NULL;
210 wxPanel* interfMainPanel::initializeToolsPanel(wxWindow* parent, int sizex, int sizey, wxEvtHandler * evtHandler)
212 wxPanel* panel = new wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN, wxString(_T("Spread")));
214 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2) ;
215 panel->SetSizer(flexsizer, true);
216 panel->SetAutoLayout( true );
218 interfToolsMenu* menu = new interfToolsMenu(panel, sizex, sizey, evtHandler);
219 toolspread = new interfToolsSpreadPanel(panel, sizex, 300, evtHandler);
221 flexsizer->Add(menu, wxFIXED_MINSIZE);
222 flexsizer->Add(toolspread, wxFIXED_MINSIZE);
230 ** Adds a new checkbox to the scrolledwindow using the checkboxsizer
231 ** @Params id of contour
234 void interfMainPanel::addContourCheckBox(std::string id)
236 toolspread->addContourCheckBox(id);
240 ** Removes a checkbox from the list of checkboxes in the flexsizer (checkboxsizer)
241 ** @Params id of contour
244 void interfMainPanel::removeContourCheckBox(std::string id)
246 toolspread->removeContourCheckBox(id);
249 void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event )
251 //((interfToolsMenu*)menubar4)->hideAxis();
252 wxButton* b = (wxButton*)event.GetEventObject();
255 std::string dstring = *((std::string*) b->GetClientData());
258 if(dstring.compare(PANEL)==0){
261 }else if(dstring.compare(PANEL1)==0 ){
264 }else if(dstring.compare(PANEL2)==0){
267 }else if(dstring.compare(PANEL3)==0){
270 }else if(dstring.compare(PANEL4)==0){
273 }else if(dstring.compare(PANEL5)==0){
276 }else if(dstring.compare(PANEL6)==0){
281 if(wxStrcmp(b->GetLabel(),_T("+"))==0 ){
284 b->SetLabel(_T("-"));
288 b->SetLabel(_T("+"));
291 sizechange *= (dmenu->GetSize().GetHeight()-10);
292 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+sizechange);
298 wxStaticText* interfMainPanel::getText(wxWindow* parent, std::string nom)
300 return new wxStaticText(parent, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition,
301 wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
304 wxButton* interfMainPanel::getButton(wxWindow* parent)
306 wxButton* b = new wxButton(parent, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
307 wxDefaultValidator, wxString(_T("-")));
311 wxPanel* interfMainPanel::setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text)
314 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2);
315 parent->SetSizer(flexsizer, true);
316 parent->SetAutoLayout( true );
318 flexsizer->Add(text, wxFLEX_GROWMODE_ALL);
319 flexsizer->Add(panel, wxFLEX_GROWMODE_ALL);
322 return (wxPanel*)parent;
326 ** Shows the panel in the
328 void interfMainPanel::showPanel(wxWindow* panel)
330 wxContourMainFrame::getInstance()->showAxis(false);
331 wxSizer* sizer = infoPanel->GetSizer();
333 if(currentWindow != NULL){
334 currentWindow->Hide();
335 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated
336 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
337 #if wxMAJOR_VERSION <= 2
338 sizer->Remove(currentWindow);
340 sizer->Detach(currentWindow);
345 currentWindow = panel;
346 currentWindow->Show(true);
348 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
349 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
352 infoPanel->Refresh();
358 ** Hide the panel in the lower box
360 void interfMainPanel::hidePanel( )
362 wxContourMainFrame::getInstance()->showAxis(false);
363 wxSizer* sizer = infoPanel->GetSizer();
365 if(currentWindow != NULL){
366 currentWindow->Hide();
367 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated
368 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
369 #if wxMAJOR_VERSION <= 2
370 sizer->Remove(currentWindow);
372 sizer->Detach(currentWindow);
376 wxPanel * emptyPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
377 sizer->Add(emptyPanel);
378 currentWindow = emptyPanel;
379 currentWindow->Show(true);
381 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
382 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
385 infoPanel->Refresh();
391 ** Gets the Information panel
393 wxPanel* interfMainPanel::getInfoPanel()
398 void interfMainPanel::onCreateContourSpline( )
400 wxContourMainFrame::getInstance()->showAxis(false);
401 wxContourMainFrame::getInstance()->onCreateContourSpline();
404 void interfMainPanel::onCreateContourRectangle( )
406 wxContourMainFrame::getInstance()->showAxis(false);
407 wxContourMainFrame::getInstance()->onCreateContourRectangle();
409 void interfMainPanel::onCreateContourCircle( )
411 wxContourMainFrame::getInstance()->showAxis(false);
412 wxContourMainFrame::getInstance()->onCreateContourCircle();
415 void interfMainPanel::onCreateContourLine( )
417 wxContourMainFrame::getInstance()->showAxis(false);
418 wxContourMainFrame::getInstance()->onCreateContourLine();
421 // RaC 09-09 ---------------------
422 void interfMainPanel::onCreateContourPoints( )
424 wxContourMainFrame::getInstance()->showAxis(false);
425 wxContourMainFrame::getInstance()->onCreateContourPoints();
427 // RaC 09-09 ---------------------
429 // RaC 10-09 ---------------------
430 void interfMainPanel::onCreateContourPolygon( )
432 wxContourMainFrame::getInstance()->showAxis(false);
433 wxContourMainFrame::getInstance()->onCreateContourPolygon();
435 // RaC 10-09 ---------------------
437 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull)
439 wxContourMainFrame::getInstance()->showAxis(false);
440 wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
443 void interfMainPanel::onDeleteContour()
445 wxContourMainFrame::getInstance()->showAxis(false);
446 wxContourMainFrame::getInstance()->onDeleteContour();
449 void interfMainPanel::onDeleteContoursActSlice()
451 wxContourMainFrame::getInstance()->showAxis(false);
452 wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
455 void interfMainPanel::onDeleteAllContours()
457 wxContourMainFrame::getInstance()->showAxis(false);
458 wxContourMainFrame::getInstance()->onDeleteAllContours();
461 void interfMainPanel::onCopy()
463 wxContourMainFrame::getInstance()->onCopy();
466 void interfMainPanel::onPaste()
468 wxContourMainFrame::getInstance()->onPaste();
471 void interfMainPanel::onUndo()
473 wxContourMainFrame::getInstance()->onUndo();
476 void interfMainPanel::onRedo()
478 wxContourMainFrame::getInstance()->onRedo();
481 void interfMainPanel::onLoad()
483 wxContourMainFrame::getInstance()->onLoad();
486 void interfMainPanel::onSave()
488 wxContourMainFrame::getInstance()->onSave();
491 void interfMainPanel::onImport()
493 wxContourMainFrame::getInstance()->onImport();
496 void interfMainPanel::onTest()
498 printf("EED interfMainPanel::onTest \n");
501 testPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
502 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
503 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
504 testPanel->SetSizer(flexsizer, true);
505 testPanel->SetAutoLayout( true );
506 panelTest = new interfTestPanel(testPanel);
507 wxStaticText* stattext = new wxStaticText(testPanel, -1,
508 wxString(_T(" Test Panel ")),
509 wxDefaultPosition, wxDefaultSize,
510 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
511 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
512 flexsizer->Add(panelTest, wxEXPAND);
515 showPanel(testPanel);
518 void interfMainPanel::RefreshInterface()
520 wxContourMainFrame::getInstance()->RefreshInterface();
523 vtkImageData* interfMainPanel::getImageData()
525 return wxContourMainFrame::getInstance()->getImageData();
528 void interfMainPanel::getImageRange(double range[2] )
530 vtkImageData * img = getImageData();
531 img->GetScalarRange(range);
534 void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method)
536 wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
539 void interfMainPanel::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
541 wxContourMainFrame::getInstance()->onSegmentationOneSliceITK(distance, sigma, alfa, beta, propagation, iterations, inflation);
544 int interfMainPanel::GetImageDataSizeZ()
546 return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
549 void interfMainPanel::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method)
551 wxContourMainFrame::getInstance()->onSegmentationAllSlice(minZ, maxZ,isovalue,sampling,method);
554 void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString)
556 ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
558 void interfMainPanel::onSegmentationPressed()
560 if(segmentPanel == NULL){
561 segmentPanel = new wxPanel(getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
562 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
563 segmentPanel->SetSizer(flexsizer, true);
564 segmentPanel->SetAutoLayout(true);
565 segmentPanel->SetEventHandler(this);
567 //wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
568 segmentationPanel = new interfSegmentationPanelVTK(segmentPanel);
571 wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T(" Automatic Segmentation ")), wxDefaultPosition,
572 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
574 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
575 flexsizer->Add(segmentationPanel, wxEXPAND);
576 segmentPanel->Layout();
578 showPanel(segmentPanel);
579 wxContourMainFrame::getInstance()->showAxis(true);
583 void interfMainPanel::onSegmentationPressedITK()
585 if(segmentPanelITK == NULL){
586 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
589 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
590 segmentPanelITK->SetSizer(flexsizer, true);
591 segmentPanelITK->SetAutoLayout( true );
592 //segmentPanelITK->SetEventHandler(this->contourevent);
594 //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
595 wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
597 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
598 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
600 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
601 flexsizer->Add(panel, wxEXPAND);
602 segmentPanelITK->Layout();
604 showPanel(segmentPanelITK);
605 wxContourMainFrame::getInstance()->showAxis(true);
609 void interfMainPanel::onRigidPressed()
611 wxContourMainFrame::getInstance()->onRigidPressed();
614 void interfMainPanel::onWidthOfContour(double width)
616 wxContourMainFrame::getInstance()->onWidthOfContour(width);
619 int interfMainPanel::getColorWindow()
621 return wxContourMainFrame::getInstance()->getColorWindow();
623 int interfMainPanel::getWindowLevel()
625 return wxContourMainFrame::getInstance()->getWindowLevel();
627 void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
629 wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
632 void interfMainPanel::onInterpolation(bool interpolate)
634 wxContourMainFrame::getInstance()->onInterpolation(interpolate);
638 void interfMainPanel::onConfigurationPressed()
640 if(configPanel == NULL){
641 configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
642 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
643 configPanel->SetSizer(flexsizer, true);
644 configPanel->SetAutoLayout( true );
645 //configPanel->SetEventHandler(this->contourevent);
646 wxPanel* panel = new interfConfigurationPanel(configPanel);
647 wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T(" Interface Configuration ")), wxDefaultPosition,
648 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
649 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
650 flexsizer->Add(panel, wxEXPAND);
651 configPanel->Layout();
653 showPanel(configPanel);
656 void interfMainPanel::onSpreadPressed()
658 if(spreadPanel==NULL){
660 spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
661 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
662 spreadPanel->SetSizer(flexsizer, true);
663 spreadPanel->SetAutoLayout( true );
664 //spreadPanel->SetEventHandler(this->contourevent);
666 //wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
667 panelSpread = new interfSpreadPanel(spreadPanel);
670 wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T(" Automatic Spread ")), wxDefaultPosition,
671 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
673 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
674 flexsizer->Add(panelSpread, wxEXPAND);
675 spreadPanel->Layout();
677 showPanel(spreadPanel);
681 void interfMainPanel::resetAppend()
683 wxContourMainFrame::getInstance()->resetAppend();
686 void interfMainPanel::onSpreadAdd()
688 wxContourMainFrame::getInstance()->onSpreadAdd();
691 void interfMainPanel::onSpreadAddAll()
693 wxContourMainFrame::getInstance()->onSpreadAddAll();
697 void interfMainPanel::appendStringSpread(std::string val)
699 panelSpread->appendStringSpread(val);
702 void interfMainPanel::onSpreadGo(int type)
704 wxContourMainFrame::getInstance()->onSpreadGo(type);
707 void interfMainPanel::setStringSpread(std::string stringtemp)
709 panelSpread->setStringSpread(stringtemp);
712 void interfMainPanel::onInformationPressed()
717 infoWin = new wxFrame (this, -1,_T(" Statistics "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
718 infoWin->SetSize( wxSize(825,650) );
720 wxSize sizepanel(825,675);
721 informationPanel = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
723 wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
724 sizerPanel -> Add( informationPanel, 1, wxEXPAND ,0);
726 infoWin->SetSizer( sizerPanel );
727 infoWin->SetAutoLayout( true );
732 if (infoWin->IsShown()==true)
734 infoWin->Show(false);
736 //contourevent->FillGridWithContoursInformation();
741 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
744 panelAux = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
746 //------------------------------------------------------------------------------------------------------------
748 // mask view control panel
749 if(infoPanelMask == NULL){
750 infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
751 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
752 infoPanelMask->SetSizer(flexsizer, true);
753 infoPanelMask->SetAutoLayout( true );
754 //configPanel->SetEventHandler(this->contourevent);
755 wxPanel *panel = wxContourMainFrame::getInstance()->getMaskImageViewPanel( infoPanelMask );
756 wxStaticText* stattext = new wxStaticText(infoPanelMask, -1, wxString(_T(" Mask segmentation ")), wxDefaultPosition,
757 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
759 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
761 flexsizer->Add(panel, wxEXPAND);
762 infoPanelMask->Layout();
766 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
768 if(infoPanelCalibration == NULL)
770 infoPanelCalibration = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER , wxString(_T("")));
771 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
772 infoPanelCalibration->SetSizer(flexsizer, true);
773 infoPanelCalibration->SetAutoLayout( true );
775 wxPanel *panel = new interfCalibrationPanel(infoPanelCalibration);
776 wxStaticText* stattext = new wxStaticText(infoPanelCalibration, -1, wxString(_T(" Calibration ")), wxDefaultPosition,
777 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
779 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
781 flexsizer->Add(panel, wxEXPAND);
782 infoPanelCalibration->Layout();
785 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
786 panelAux->SetSizer(sizer, true);
787 panelAux->SetAutoLayout( true );
788 sizer->Add(infoPanelMask);
789 sizer->Add(infoPanelCalibration);
793 //------------------------------------------------------------------
795 wxContourMainFrame::getInstance()->changeInstant();
798 void interfMainPanel::getInstantVector(std::vector<int>& tempVector)
800 wxContourMainFrame::getInstance()->getInstantVector(tempVector);
803 std::vector<std::string> interfMainPanel::getOutlinesName(int slide)
805 return wxContourMainFrame::getInstance()->getOutlinesName(slide);
808 void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ,int grayRangeMin,int grayRangeMax){
809 wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ,grayRangeMin,grayRangeMax);
812 void interfMainPanel::setStringInfoPanel(wxString tmpString)
814 if(informationPanel!=NULL){
815 ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
819 void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString)
821 ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
824 int interfMainPanel::getNumberColsInformationPanel()
826 return ((interfInformationPanel*)informationPanel)->getNumberCols();
829 void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics)
831 ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
834 void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString)
836 ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
839 void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString)
841 ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
845 void interfMainPanel::SetScalarRange(int grayRangeMin,int grayRangeMax)
847 wxContourMainFrame::getInstance()->SetScalarRange(grayRangeMin, grayRangeMax);
850 void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename,
851 int typeContourGroup, int selection, int minZ, int maxZ ,bool XYZValues, bool contourImage, bool statistics)
853 wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename,
854 typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
857 wxString interfMainPanel::getCellValue(int j,int i){
858 return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
861 void interfMainPanel::onSnakePressed()
864 wxContourMainFrame::getInstance()->showAxis(axisshown);
865 wxContourMainFrame::getInstance()->onSnakePressed();
868 void interfMainPanel::onMirrorPressed(){
869 if(mirrorPanel==NULL)
872 mirrorPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
873 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
874 mirrorPanel->SetSizer(flexsizer, true);
875 mirrorPanel->SetAutoLayout( true );
876 panelMirror = new interfMirrorPanel(mirrorPanel);
878 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1, wxString(_T(" Mirroring Tool ")), wxDefaultPosition,
879 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
881 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
882 flexsizer->Add(panelMirror, wxEXPAND);
883 mirrorPanel->Layout();
886 wxContourMainFrame::getInstance()->referenceLine();
894 wxContourMainFrame::getInstance()->refLineShow();
899 showPanel(mirrorPanel);
902 void interfMainPanel::onMirror()
904 wxContourMainFrame::getInstance()->onMirror();
907 void interfMainPanel::onMirrorAxisShow()
911 wxContourMainFrame::getInstance()->refLineShow();
916 void interfMainPanel::onMirrorAxisHide()
920 wxContourMainFrame::getInstance()->refLineHide();
925 void interfMainPanel::onMirrorChangeWidth(int width)
927 wxContourMainFrame::getInstance()->refLineChangeWidth(width);
931 void interfMainPanel::onColorLayerImagePressed()
933 // Color Image Layer view control panel
934 if(colorImageLayerPanel == NULL){
935 colorImageLayerPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
936 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
937 colorImageLayerPanel->SetSizer(flexsizer, true);
938 colorImageLayerPanel->SetAutoLayout( true );
939 //configPanel->SetEventHandler(this->contourevent);
940 wxPanel *panel = wxContourMainFrame::getInstance()->getColorLayerImageViewPanel( colorImageLayerPanel );
941 wxStaticText* stattext = new wxStaticText(colorImageLayerPanel, -1, wxString(_T(" Color Image Layer ")), wxDefaultPosition,
942 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
943 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
944 flexsizer->Add(panel, wxEXPAND);
945 colorImageLayerPanel->Layout();
947 showPanel(colorImageLayerPanel);
948 wxContourMainFrame::getInstance()->changeInstant();
952 void interfMainPanel::onThresholdPressed()
954 // Threshold view control panel
955 if(thresholdPanel == NULL){
956 thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
957 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
958 thresholdPanel->SetSizer(flexsizer, true);
959 thresholdPanel->SetAutoLayout( true );
960 //configPanel->SetEventHandler(this->contourevent);
961 wxPanel *panel = wxContourMainFrame::getInstance()->getThresholdImageViewPanel( thresholdPanel );
962 wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T(" Threshold segmentation ")), wxDefaultPosition,
963 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
964 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
965 flexsizer->Add(panel, wxEXPAND);
966 thresholdPanel->Layout();
968 showPanel(thresholdPanel);
969 wxContourMainFrame::getInstance()->changeInstant();
973 void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
975 wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
979 void interfMainPanel::SetContourGroup(int contourGroup)
981 wxContourMainFrame::getInstance()->SetContourGroup( contourGroup);
985 void interfMainPanel::onFlipContours()
987 printf("EED interfMainPanel::onFlipContours() \n");
990 flipPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
991 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
992 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
993 flipPanel->SetSizer(flexsizer, true);
994 flipPanel->SetAutoLayout( true );
995 panelFlip = new interfFlipPanel(flipPanel);
996 wxStaticText* stattext = new wxStaticText(flipPanel, -1,
997 wxString(_T(" Flip Contours ")),
998 wxDefaultPosition, wxDefaultSize,
999 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
1000 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
1001 flexsizer->Add(panelFlip, wxEXPAND);
1002 flipPanel->Layout();
1004 showPanel(flipPanel);
1008 void interfMainPanel::FlipContours(int typeContourFlip, int flipDirection)
1010 printf("EED interfMainPanel::FlipContours( %d , %d ) \n",typeContourFlip, flipDirection );
1011 wxContourMainFrame::getInstance()->FlipContours( typeContourFlip , flipDirection );
1016 //CMRU 17-08-09 ---------------------------------------------
1017 void interfMainPanel::onPrintLabel ()
1020 manualBaseModel* manualModel = wxContourMainFrame::getInstance()->getContour();
1022 if(manualModel==NULL)
1024 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a Contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1029 wxTextEntryDialog* dialog = new wxTextEntryDialog(this,_T("Enter a tag name: ")) ;
1031 if (dialog->ShowModal() == wxID_OK)
1033 label = dialog->GetValue();
1037 wxContourMainFrame::getInstance()->onPrintLabel(label,manualModel);
1038 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The tag name was updated"), wxT("Information"), wxOK | wxICON_INFORMATION);
1043 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a valid tag"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1049 void interfMainPanel::onCalibration(wxString size, int unit)
1052 double contourSize = 0.0;
1053 double realSizeDouble = 0.0;
1055 type = wxContourMainFrame::getInstance()->getType();
1056 contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels();
1058 std::cout<<"Cata->Tama�o del contorno en pixeles:"<<contourSize<<endl;
1062 if (size.ToDouble(&realSizeDouble))
1066 realSizeDouble = realSizeDouble * 10;
1070 realSizeDouble = realSizeDouble * 25.4;
1072 std::cout<< "Valor del usuario" << realSizeDouble<< endl ;
1073 onePixelSize (realSizeDouble,contourSize);
1077 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a numeric value"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1083 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a line contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1087 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The calibration was made"), wxT("Information"), wxOK | wxICON_INFORMATION);
1089 std::cout<< "Cata-> Se ha realizado la calibracion" << endl ;
1092 double interfMainPanel::onePixelSize (double realSize,double sizePixel)
1094 _pixelValue = realSize/sizePixel;
1095 std::cout<< "Valor del un pixel = " << _pixelValue<< endl ;
1096 wxContourMainFrame::getInstance()->onePixelSize (_pixelValue);
1097 return _pixelValue ;
1100 double interfMainPanel::GetPixelValue()
1104 //------------------------------------------------------------------------------------------------------------