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 printf("EED interfMainPanel::interfMainPanel Start\n");
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 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
72 #if wxMAJOR_VERSION <= 2
73 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(6,2,1,1);
75 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(6);
77 toolpanel->SetSizer(flexsizer, true);
78 toolpanel->SetAutoLayout( true );
80 wxButton* b = getButton(toolpanel);
81 b->SetClientData(&PANEL);
82 wxButton* b1 = getButton(toolpanel);
83 b1->SetClientData(&PANEL1);
84 wxButton* b2 = getButton(toolpanel);
85 b2->SetClientData(&PANEL2);
86 wxButton* b3 = getButton(toolpanel);
87 b3->SetClientData(&PANEL3);
88 wxButton* b4 = getButton(toolpanel);
89 b4->SetClientData(&PANEL4);
90 wxButton* b5 = getButton(toolpanel);
91 b5->SetClientData(&PANEL5);
93 wxButton* b6 = getButton(toolpanel);
94 b6->SetClientData(&PANEL6);
96 wxPanel* mentex = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
97 wxPanel* mentex1 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
98 wxPanel* mentex2 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
99 wxPanel* mentex3 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
100 wxPanel* mentex4 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
101 wxPanel* mentex5 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
103 wxPanel* mentex6 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
105 menubar = new interfNewContourMenu (mentex, sizex, sizey, evtHandler, datadir);
106 menubar1 = new interfIOMenu (mentex1, sizex, sizey, evtHandler, datadir);
107 menubar2 = new interfEditMenu (mentex2, sizex, sizey, evtHandler, datadir);
108 menubar3 = new interfDeleteMenu (mentex3, sizex, sizey, evtHandler, datadir);
109 menubar4 = new interfToolsMenu (mentex4, sizex ,sizey, evtHandler, datadir);
110 menubar5 = new interfSegmentationMenu(mentex5, sizex, sizey, evtHandler, datadir);
111 menubar6 = new interfImageToolsMenu(mentex6, sizex, sizey, evtHandler, datadir);
113 statictext = getText(mentex, PANEL);
114 statictext1 = getText(mentex1, PANEL1);
115 statictext2 = getText(mentex2, PANEL2);
116 statictext3 = getText(mentex3, PANEL3);
117 statictext4 = getText(mentex4, PANEL4);
118 statictext5 = getText(mentex5, PANEL5);
119 statictext6 = getText(mentex6, PANEL6);
121 flexsizer->Add(b, wxFIXED_MINSIZE);
122 flexsizer->Add(setMenuTextSizer(mentex, menubar,statictext), wxFIXED_MINSIZE);
124 flexsizer->Add(b1, wxFIXED_MINSIZE);
125 flexsizer->Add(setMenuTextSizer(mentex1, menubar1,statictext1), wxFIXED_MINSIZE);
127 flexsizer->Add(b2, wxFIXED_MINSIZE);
128 flexsizer->Add(setMenuTextSizer(mentex2, menubar2,statictext2), wxFIXED_MINSIZE);
130 flexsizer->Add(b3, wxFIXED_MINSIZE);
131 flexsizer->Add(setMenuTextSizer(mentex3, menubar3,statictext3), wxFIXED_MINSIZE);
133 flexsizer->Add(b4, wxFIXED_MINSIZE);
134 flexsizer->Add(setMenuTextSizer(mentex4, menubar4,statictext4), wxFIXED_MINSIZE);
136 flexsizer->Add(b5, wxFIXED_MINSIZE);
137 flexsizer->Add(setMenuTextSizer(mentex5, menubar5,statictext5), wxFIXED_MINSIZE);
138 flexsizer->Add(b6, wxFIXED_MINSIZE);
139 flexsizer->Add(setMenuTextSizer(mentex6, menubar6,statictext6), wxFIXED_MINSIZE);
144 infoPanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
145 wxFlexGridSizer* infosizer = new wxFlexGridSizer(1,1,2,2);
146 infoPanel->SetSizer(infosizer, true);
147 infoPanel->SetAutoLayout( true );
149 splitterwindow->Initialize(toolpanel);
150 splitterwindow->SetSashGravity(1);
151 //EED splitterwindow->SetSashPosition(600);
152 splitterwindow->SetSashSize(5);
153 splitterwindow->SplitHorizontally(toolpanel, infoPanel,8*73);
155 Connect(b->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
156 Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
157 Connect(b2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
158 Connect(b3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
159 Connect(b4->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
160 Connect(b5->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
161 Connect(b6->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
164 printf("EED interfMainPanel::interfMainPanel End\n");
167 interfMainPanel::~interfMainPanel(void)
172 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler)
174 _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);
176 if(interfmainpanel == NULL){
177 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler, datadir);
179 _newframe->Show(TRUE);
180 return interfmainpanel;
183 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler)
186 _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 );
188 if(interfmainpanel == NULL){
189 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler);
191 _newframe->Show(TRUE);
192 return interfmainpanel;
195 bool interfMainPanel::Show(bool show)
197 return _newframe->Show(show);
200 interfMainPanel* interfMainPanel::getInstance()
202 return interfmainpanel;
205 void interfMainPanel :: resetInstance()
207 //delete interfmainpanel;
209 interfmainpanel = NULL;
212 wxPanel* interfMainPanel::initializeToolsPanel(wxWindow* parent, int sizex, int sizey, wxEvtHandler * evtHandler)
214 wxPanel* panel = new wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN, wxString(_T("Spread")));
216 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2) ;
217 panel->SetSizer(flexsizer, true);
218 panel->SetAutoLayout( true );
220 interfToolsMenu* menu = new interfToolsMenu(panel, sizex, sizey, evtHandler);
221 toolspread = new interfToolsSpreadPanel(panel, sizex, 300, evtHandler);
223 flexsizer->Add(menu, wxFIXED_MINSIZE);
224 flexsizer->Add(toolspread, wxFIXED_MINSIZE);
232 ** Adds a new checkbox to the scrolledwindow using the checkboxsizer
233 ** @Params id of contour
236 void interfMainPanel::addContourCheckBox(std::string id)
238 toolspread->addContourCheckBox(id);
242 ** Removes a checkbox from the list of checkboxes in the flexsizer (checkboxsizer)
243 ** @Params id of contour
246 void interfMainPanel::removeContourCheckBox(std::string id)
248 toolspread->removeContourCheckBox(id);
251 void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event )
253 //((interfToolsMenu*)menubar4)->hideAxis();
254 wxButton* b = (wxButton*)event.GetEventObject();
257 std::string dstring = *((std::string*) b->GetClientData());
260 if(dstring.compare(PANEL)==0){
263 }else if(dstring.compare(PANEL1)==0 ){
266 }else if(dstring.compare(PANEL2)==0){
269 }else if(dstring.compare(PANEL3)==0){
272 }else if(dstring.compare(PANEL4)==0){
275 }else if(dstring.compare(PANEL5)==0){
278 }else if(dstring.compare(PANEL6)==0){
283 if(wxStrcmp(b->GetLabel(),_T("+"))==0 ){
286 b->SetLabel(_T("-"));
290 b->SetLabel(_T("+"));
293 sizechange *= (dmenu->GetSize().GetHeight()-10);
294 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+sizechange);
300 wxStaticText* interfMainPanel::getText(wxWindow* parent, std::string nom)
302 return new wxStaticText(parent, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition,
303 wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
306 wxButton* interfMainPanel::getButton(wxWindow* parent)
308 wxButton* b = new wxButton(parent, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
309 wxDefaultValidator, wxString(_T("-")));
313 wxPanel* interfMainPanel::setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text)
316 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2);
317 parent->SetSizer(flexsizer, true);
318 parent->SetAutoLayout( true );
320 flexsizer->Add(text, wxFLEX_GROWMODE_ALL);
321 flexsizer->Add(panel, wxFLEX_GROWMODE_ALL);
324 return (wxPanel*)parent;
328 ** Shows the panel in the
330 void interfMainPanel::showPanel(wxWindow* panel)
332 wxContourMainFrame::getInstance()->showAxis(false);
333 wxSizer* sizer = infoPanel->GetSizer();
335 if(currentWindow != NULL){
336 currentWindow->Hide();
337 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated
338 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
339 #if wxMAJOR_VERSION <= 2
340 sizer->Remove(currentWindow);
342 sizer->Detach(currentWindow);
347 currentWindow = panel;
348 currentWindow->Show(true);
350 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
351 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
354 infoPanel->Refresh();
360 ** Hide the panel in the lower box
362 void interfMainPanel::hidePanel( )
364 wxContourMainFrame::getInstance()->showAxis(false);
365 wxSizer* sizer = infoPanel->GetSizer();
367 if(currentWindow != NULL){
368 currentWindow->Hide();
369 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated
370 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
371 #if wxMAJOR_VERSION <= 2
372 sizer->Remove(currentWindow);
374 sizer->Detach(currentWindow);
378 wxPanel * emptyPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
379 sizer->Add(emptyPanel);
380 currentWindow = emptyPanel;
381 currentWindow->Show(true);
383 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
384 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
387 infoPanel->Refresh();
393 ** Gets the Information panel
395 wxPanel* interfMainPanel::getInfoPanel()
400 void interfMainPanel::onCreateContourSpline( )
402 wxContourMainFrame::getInstance()->showAxis(false);
403 wxContourMainFrame::getInstance()->onCreateContourSpline();
406 void interfMainPanel::onCreateContourRectangle( )
408 wxContourMainFrame::getInstance()->showAxis(false);
409 wxContourMainFrame::getInstance()->onCreateContourRectangle();
411 void interfMainPanel::onCreateContourCircle( )
413 wxContourMainFrame::getInstance()->showAxis(false);
414 wxContourMainFrame::getInstance()->onCreateContourCircle();
417 void interfMainPanel::onCreateContourLine( )
419 wxContourMainFrame::getInstance()->showAxis(false);
420 wxContourMainFrame::getInstance()->onCreateContourLine();
423 // RaC 09-09 ---------------------
424 void interfMainPanel::onCreateContourPoints( )
426 wxContourMainFrame::getInstance()->showAxis(false);
427 wxContourMainFrame::getInstance()->onCreateContourPoints();
429 // RaC 09-09 ---------------------
431 // RaC 10-09 ---------------------
432 void interfMainPanel::onCreateContourPolygon( )
434 wxContourMainFrame::getInstance()->showAxis(false);
435 wxContourMainFrame::getInstance()->onCreateContourPolygon();
437 // RaC 10-09 ---------------------
439 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull)
441 wxContourMainFrame::getInstance()->showAxis(false);
442 wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
445 void interfMainPanel::onDeleteContour()
447 wxContourMainFrame::getInstance()->showAxis(false);
448 wxContourMainFrame::getInstance()->onDeleteContour();
451 void interfMainPanel::onDeleteContoursActSlice()
453 wxContourMainFrame::getInstance()->showAxis(false);
454 wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
457 void interfMainPanel::onDeleteAllContours()
459 wxContourMainFrame::getInstance()->showAxis(false);
460 wxContourMainFrame::getInstance()->onDeleteAllContours();
463 void interfMainPanel::onCopy()
465 wxContourMainFrame::getInstance()->onCopy();
468 void interfMainPanel::onPaste()
470 wxContourMainFrame::getInstance()->onPaste();
473 void interfMainPanel::onUndo()
475 wxContourMainFrame::getInstance()->onUndo();
478 void interfMainPanel::onRedo()
480 wxContourMainFrame::getInstance()->onRedo();
483 void interfMainPanel::onLoad()
485 wxContourMainFrame::getInstance()->onLoad();
488 void interfMainPanel::onSave()
490 wxContourMainFrame::getInstance()->onSave();
493 void interfMainPanel::onImport()
495 wxContourMainFrame::getInstance()->onImport();
498 void interfMainPanel::onTest()
500 printf("EED interfMainPanel::onTest \n");
503 testPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
504 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
505 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
506 testPanel->SetSizer(flexsizer, true);
507 testPanel->SetAutoLayout( true );
508 panelTest = new interfTestPanel(testPanel);
509 wxStaticText* stattext = new wxStaticText(testPanel, -1,
510 wxString(_T(" Test Panel ")),
511 wxDefaultPosition, wxDefaultSize,
512 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
513 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
514 flexsizer->Add(panelTest, wxEXPAND);
517 showPanel(testPanel);
520 void interfMainPanel::RefreshInterface()
522 wxContourMainFrame::getInstance()->RefreshInterface();
525 vtkImageData* interfMainPanel::getImageData()
527 return wxContourMainFrame::getInstance()->getImageData();
530 void interfMainPanel::getImageRange(double range[2] )
532 vtkImageData * img = getImageData();
533 img->GetScalarRange(range);
536 void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method)
538 wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
541 void interfMainPanel::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
543 wxContourMainFrame::getInstance()->onSegmentationOneSliceITK(distance, sigma, alfa, beta, propagation, iterations, inflation);
546 int interfMainPanel::GetImageDataSizeZ()
548 return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
551 void interfMainPanel::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method)
553 wxContourMainFrame::getInstance()->onSegmentationAllSlice(minZ, maxZ,isovalue,sampling,method);
556 void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString)
558 ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
560 void interfMainPanel::onSegmentationPressed()
562 if(segmentPanel == NULL){
563 segmentPanel = new wxPanel(getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
564 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
565 segmentPanel->SetSizer(flexsizer, true);
566 segmentPanel->SetAutoLayout(true);
567 segmentPanel->SetEventHandler(this);
569 //wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
570 segmentationPanel = new interfSegmentationPanelVTK(segmentPanel);
573 wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T(" Automatic Segmentation ")), wxDefaultPosition,
574 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
576 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
577 flexsizer->Add(segmentationPanel, wxEXPAND);
578 segmentPanel->Layout();
580 showPanel(segmentPanel);
581 wxContourMainFrame::getInstance()->showAxis(true);
585 void interfMainPanel::onSegmentationPressedITK()
587 if(segmentPanelITK == NULL){
588 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
591 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
592 segmentPanelITK->SetSizer(flexsizer, true);
593 segmentPanelITK->SetAutoLayout( true );
594 //segmentPanelITK->SetEventHandler(this->contourevent);
596 //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
597 wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
599 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
600 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
602 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
603 flexsizer->Add(panel, wxEXPAND);
604 segmentPanelITK->Layout();
606 showPanel(segmentPanelITK);
607 wxContourMainFrame::getInstance()->showAxis(true);
611 void interfMainPanel::onRigidPressed()
613 wxContourMainFrame::getInstance()->onRigidPressed();
616 void interfMainPanel::onWidthOfContour(double width)
618 wxContourMainFrame::getInstance()->onWidthOfContour(width);
621 int interfMainPanel::getColorWindow()
623 return wxContourMainFrame::getInstance()->getColorWindow();
625 int interfMainPanel::getWindowLevel()
627 return wxContourMainFrame::getInstance()->getWindowLevel();
629 void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
631 wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
634 void interfMainPanel::onInterpolation(bool interpolate)
636 wxContourMainFrame::getInstance()->onInterpolation(interpolate);
640 void interfMainPanel::onConfigurationPressed()
642 if(configPanel == NULL){
643 configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
644 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
645 configPanel->SetSizer(flexsizer, true);
646 configPanel->SetAutoLayout( true );
647 //configPanel->SetEventHandler(this->contourevent);
648 wxPanel* panel = new interfConfigurationPanel(configPanel);
649 wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T(" Interface Configuration ")), wxDefaultPosition,
650 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
651 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
652 flexsizer->Add(panel, wxEXPAND);
653 configPanel->Layout();
655 showPanel(configPanel);
658 void interfMainPanel::onSpreadPressed()
660 if(spreadPanel==NULL){
662 spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
663 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
664 spreadPanel->SetSizer(flexsizer, true);
665 spreadPanel->SetAutoLayout( true );
666 //spreadPanel->SetEventHandler(this->contourevent);
668 //wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
669 panelSpread = new interfSpreadPanel(spreadPanel);
672 wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T(" Automatic Spread ")), wxDefaultPosition,
673 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
675 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
676 flexsizer->Add(panelSpread, wxEXPAND);
677 spreadPanel->Layout();
679 showPanel(spreadPanel);
683 void interfMainPanel::resetAppend()
685 wxContourMainFrame::getInstance()->resetAppend();
688 void interfMainPanel::onSpreadAdd()
690 wxContourMainFrame::getInstance()->onSpreadAdd();
693 void interfMainPanel::onSpreadAddAll()
695 wxContourMainFrame::getInstance()->onSpreadAddAll();
699 void interfMainPanel::appendStringSpread(std::string val)
701 panelSpread->appendStringSpread(val);
704 void interfMainPanel::onSpreadGo(int type)
706 wxContourMainFrame::getInstance()->onSpreadGo(type);
709 void interfMainPanel::setStringSpread(std::string stringtemp)
711 panelSpread->setStringSpread(stringtemp);
714 void interfMainPanel::onInformationPressed()
719 infoWin = new wxFrame (this, -1,_T(" Statistics "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
720 infoWin->SetSize( wxSize(825,650) );
722 wxSize sizepanel(825,675);
723 informationPanel = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
725 wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
726 sizerPanel -> Add( informationPanel, 1, wxEXPAND ,0);
728 infoWin->SetSizer( sizerPanel );
729 infoWin->SetAutoLayout( true );
734 if (infoWin->IsShown()==true)
736 infoWin->Show(false);
738 //contourevent->FillGridWithContoursInformation();
743 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
746 panelAux = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
748 //------------------------------------------------------------------------------------------------------------
750 // mask view control panel
751 if(infoPanelMask == NULL){
752 infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
753 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
754 infoPanelMask->SetSizer(flexsizer, true);
755 infoPanelMask->SetAutoLayout( true );
756 //configPanel->SetEventHandler(this->contourevent);
757 wxPanel *panel = wxContourMainFrame::getInstance()->getMaskImageViewPanel( infoPanelMask );
758 wxStaticText* stattext = new wxStaticText(infoPanelMask, -1, wxString(_T(" Mask segmentation ")), wxDefaultPosition,
759 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
761 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
763 flexsizer->Add(panel, wxEXPAND);
764 infoPanelMask->Layout();
768 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
770 if(infoPanelCalibration == NULL)
772 infoPanelCalibration = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER , wxString(_T("")));
773 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
774 infoPanelCalibration->SetSizer(flexsizer, true);
775 infoPanelCalibration->SetAutoLayout( true );
777 wxPanel *panel = new interfCalibrationPanel(infoPanelCalibration);
778 wxStaticText* stattext = new wxStaticText(infoPanelCalibration, -1, wxString(_T(" Calibration ")), wxDefaultPosition,
779 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
781 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
783 flexsizer->Add(panel, wxEXPAND);
784 infoPanelCalibration->Layout();
787 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
788 panelAux->SetSizer(sizer, true);
789 panelAux->SetAutoLayout( true );
790 sizer->Add(infoPanelMask);
791 sizer->Add(infoPanelCalibration);
795 //------------------------------------------------------------------
797 wxContourMainFrame::getInstance()->changeInstant();
800 void interfMainPanel::getInstantVector(std::vector<int>& tempVector)
802 wxContourMainFrame::getInstance()->getInstantVector(tempVector);
805 std::vector<std::string> interfMainPanel::getOutlinesName(int slide)
807 return wxContourMainFrame::getInstance()->getOutlinesName(slide);
810 void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ,int grayRangeMin,int grayRangeMax){
811 wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ,grayRangeMin,grayRangeMax);
814 void interfMainPanel::setStringInfoPanel(wxString tmpString)
816 if(informationPanel!=NULL){
817 ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
821 void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString)
823 ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
826 int interfMainPanel::getNumberColsInformationPanel()
828 return ((interfInformationPanel*)informationPanel)->getNumberCols();
831 void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics)
833 ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
836 void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString)
838 ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
841 void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString)
843 ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
847 void interfMainPanel::SetScalarRange(int grayRangeMin,int grayRangeMax)
849 wxContourMainFrame::getInstance()->SetScalarRange(grayRangeMin, grayRangeMax);
852 void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename,
853 int typeContourGroup, int selection, int minZ, int maxZ ,bool XYZValues, bool contourImage, bool statistics)
855 wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename,
856 typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
859 wxString interfMainPanel::getCellValue(int j,int i){
860 return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
863 void interfMainPanel::onSnakePressed()
866 wxContourMainFrame::getInstance()->showAxis(axisshown);
867 wxContourMainFrame::getInstance()->onSnakePressed();
870 void interfMainPanel::onMirrorPressed(){
871 if(mirrorPanel==NULL)
874 mirrorPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
875 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
876 mirrorPanel->SetSizer(flexsizer, true);
877 mirrorPanel->SetAutoLayout( true );
878 panelMirror = new interfMirrorPanel(mirrorPanel);
880 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1, wxString(_T(" Mirroring Tool ")), wxDefaultPosition,
881 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
883 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
884 flexsizer->Add(panelMirror, wxEXPAND);
885 mirrorPanel->Layout();
888 wxContourMainFrame::getInstance()->referenceLine();
896 wxContourMainFrame::getInstance()->refLineShow();
901 showPanel(mirrorPanel);
904 void interfMainPanel::onMirror()
906 wxContourMainFrame::getInstance()->onMirror();
909 void interfMainPanel::onMirrorAxisShow()
913 wxContourMainFrame::getInstance()->refLineShow();
918 void interfMainPanel::onMirrorAxisHide()
922 wxContourMainFrame::getInstance()->refLineHide();
927 void interfMainPanel::onMirrorChangeWidth(int width)
929 wxContourMainFrame::getInstance()->refLineChangeWidth(width);
933 void interfMainPanel::onColorLayerImagePressed()
935 // Color Image Layer view control panel
936 if(colorImageLayerPanel == NULL){
937 colorImageLayerPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
938 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
939 colorImageLayerPanel->SetSizer(flexsizer, true);
940 colorImageLayerPanel->SetAutoLayout( true );
941 //configPanel->SetEventHandler(this->contourevent);
942 wxPanel *panel = wxContourMainFrame::getInstance()->getColorLayerImageViewPanel( colorImageLayerPanel );
943 wxStaticText* stattext = new wxStaticText(colorImageLayerPanel, -1, wxString(_T(" Color Image Layer ")), wxDefaultPosition,
944 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
945 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
946 flexsizer->Add(panel, wxEXPAND);
947 colorImageLayerPanel->Layout();
949 showPanel(colorImageLayerPanel);
950 wxContourMainFrame::getInstance()->changeInstant();
954 void interfMainPanel::onThresholdPressed()
956 // Threshold view control panel
957 if(thresholdPanel == NULL){
958 thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
959 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
960 thresholdPanel->SetSizer(flexsizer, true);
961 thresholdPanel->SetAutoLayout( true );
962 //configPanel->SetEventHandler(this->contourevent);
963 wxPanel *panel = wxContourMainFrame::getInstance()->getThresholdImageViewPanel( thresholdPanel );
964 wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T(" Threshold segmentation ")), wxDefaultPosition,
965 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
966 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
967 flexsizer->Add(panel, wxEXPAND);
968 thresholdPanel->Layout();
970 showPanel(thresholdPanel);
971 wxContourMainFrame::getInstance()->changeInstant();
975 void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
977 wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
981 void interfMainPanel::SetContourGroup(int contourGroup)
983 wxContourMainFrame::getInstance()->SetContourGroup( contourGroup);
987 void interfMainPanel::onFlipContours()
989 printf("EED interfMainPanel::onFlipContours() \n");
992 flipPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
993 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
994 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
995 flipPanel->SetSizer(flexsizer, true);
996 flipPanel->SetAutoLayout( true );
997 panelFlip = new interfFlipPanel(flipPanel);
998 wxStaticText* stattext = new wxStaticText(flipPanel, -1,
999 wxString(_T(" Flip Contours ")),
1000 wxDefaultPosition, wxDefaultSize,
1001 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
1002 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
1003 flexsizer->Add(panelFlip, wxEXPAND);
1004 flipPanel->Layout();
1006 showPanel(flipPanel);
1010 void interfMainPanel::FlipContours(int typeContourFlip, int flipDirection)
1012 printf("EED interfMainPanel::FlipContours( %d , %d ) \n",typeContourFlip, flipDirection );
1013 wxContourMainFrame::getInstance()->FlipContours( typeContourFlip , flipDirection );
1018 //CMRU 17-08-09 ---------------------------------------------
1019 void interfMainPanel::onPrintLabel ()
1022 manualBaseModel* manualModel = wxContourMainFrame::getInstance()->getContour();
1024 if(manualModel==NULL)
1026 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a Contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1031 wxTextEntryDialog* dialog = new wxTextEntryDialog(this,_T("Enter a tag name: ")) ;
1033 if (dialog->ShowModal() == wxID_OK)
1035 label = dialog->GetValue();
1039 wxContourMainFrame::getInstance()->onPrintLabel(label,manualModel);
1040 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The tag name was updated"), wxT("Information"), wxOK | wxICON_INFORMATION);
1045 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a valid tag"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1051 void interfMainPanel::onCalibration(wxString size, int unit)
1054 double contourSize = 0.0;
1055 double realSizeDouble = 0.0;
1057 type = wxContourMainFrame::getInstance()->getType();
1058 contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels();
1060 std::cout<<"Cata->Tama�o del contorno en pixeles:"<<contourSize<<endl;
1064 if (size.ToDouble(&realSizeDouble))
1068 realSizeDouble = realSizeDouble * 10;
1072 realSizeDouble = realSizeDouble * 25.4;
1074 std::cout<< "Valor del usuario" << realSizeDouble<< endl ;
1075 onePixelSize (realSizeDouble,contourSize);
1079 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a numeric value"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1085 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a line contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1089 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The calibration was made"), wxT("Information"), wxOK | wxICON_INFORMATION);
1091 std::cout<< "Cata-> Se ha realizado la calibracion" << endl ;
1094 double interfMainPanel::onePixelSize (double realSize,double sizePixel)
1096 _pixelValue = realSize/sizePixel;
1097 std::cout<< "Valor del un pixel = " << _pixelValue<< endl ;
1098 wxContourMainFrame::getInstance()->onePixelSize (_pixelValue);
1099 return _pixelValue ;
1102 double interfMainPanel::GetPixelValue()
1106 //------------------------------------------------------------------------------------------------------------