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 <wx/msgdlg.h>
28 #include "interfMainPanel.h"
30 interfMainPanel *interfMainPanel::interfmainpanel = NULL;
31 wxFrame *interfMainPanel::_newframe = NULL;
33 interfMainPanel::interfMainPanel(wxWindow * parent, int sizex, int sizey, wxEvtHandler * evtHandler, std::string datadir)
34 : 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("")));
65 splitterwindow->SetMinimumPaneSize( 10 );
67 wxPanel* toolpanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
68 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(20,2,1,1);
69 toolpanel->SetSizer(flexsizer, true);
70 toolpanel->SetAutoLayout( true );
71 wxButton* b = getButton(toolpanel);
72 b->SetClientData(&PANEL);
73 wxButton* b1 = getButton(toolpanel);
74 b1->SetClientData(&PANEL1);
75 wxButton* b2 = getButton(toolpanel);
76 b2->SetClientData(&PANEL2);
77 wxButton* b3 = getButton(toolpanel);
78 b3->SetClientData(&PANEL3);
79 wxButton* b4 = getButton(toolpanel);
80 b4->SetClientData(&PANEL4);
81 wxButton* b5 = getButton(toolpanel);
82 b5->SetClientData(&PANEL5);
84 wxButton* b6 = getButton(toolpanel);
85 b6->SetClientData(&PANEL6);
86 wxPanel* mentex = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
87 wxPanel* mentex1 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
88 wxPanel* mentex2 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
89 wxPanel* mentex3 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
90 wxPanel* mentex4 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
91 wxPanel* mentex5 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
93 wxPanel* mentex6 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
94 menubar = new interfNewContourMenu (mentex, sizex, sizey, evtHandler, datadir);
95 menubar1 = new interfIOMenu (mentex1, sizex, sizey, evtHandler, datadir);
96 menubar2 = new interfEditMenu (mentex2, sizex, sizey, evtHandler, datadir);
97 menubar3 = new interfDeleteMenu (mentex3, sizex, sizey, evtHandler, datadir);
98 menubar4 = new interfToolsMenu (mentex4, sizex ,sizey, evtHandler, datadir);
99 menubar5 = new interfSegmentationMenu(mentex5, sizex, sizey, evtHandler, datadir);
100 menubar6 = new interfImageToolsMenu(mentex6, sizex, sizey, evtHandler, datadir);
101 statictext = getText(mentex, PANEL);
102 statictext1 = getText(mentex1, PANEL1);
103 statictext2 = getText(mentex2, PANEL2);
104 statictext3 = getText(mentex3, PANEL3);
105 statictext4 = getText(mentex4, PANEL4);
106 statictext5 = getText(mentex5, PANEL5);
107 statictext6 = getText(mentex6, PANEL6);
108 flexsizer->Add(b, wxFIXED_MINSIZE);
109 flexsizer->Add(setMenuTextSizer(mentex, menubar,statictext), wxFIXED_MINSIZE);
110 flexsizer->Add(b1, wxFIXED_MINSIZE);
111 flexsizer->Add(setMenuTextSizer(mentex1, menubar1,statictext1), wxFIXED_MINSIZE);
112 flexsizer->Add(b2, wxFIXED_MINSIZE);
113 flexsizer->Add(setMenuTextSizer(mentex2, menubar2,statictext2), wxFIXED_MINSIZE);
114 flexsizer->Add(b3, wxFIXED_MINSIZE);
115 flexsizer->Add(setMenuTextSizer(mentex3, menubar3,statictext3), wxFIXED_MINSIZE);
116 flexsizer->Add(b4, wxFIXED_MINSIZE);
117 flexsizer->Add(setMenuTextSizer(mentex4, menubar4,statictext4), wxFIXED_MINSIZE);
118 flexsizer->Add(b5, wxFIXED_MINSIZE);
119 flexsizer->Add(setMenuTextSizer(mentex5, menubar5,statictext5), wxFIXED_MINSIZE);
120 flexsizer->Add(b6, wxFIXED_MINSIZE);
121 flexsizer->Add(setMenuTextSizer(mentex6, menubar6,statictext6), wxFIXED_MINSIZE);
124 infoPanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
125 wxFlexGridSizer* infosizer = new wxFlexGridSizer(1,1,2,2);
126 infoPanel->SetSizer(infosizer, true);
127 infoPanel->SetAutoLayout( true );
128 splitterwindow->Initialize(toolpanel);
129 splitterwindow->SetSashGravity(1);
130 //EED splitterwindow->SetSashPosition(600);
131 splitterwindow->SetSashSize(5);
132 splitterwindow->SplitHorizontally(toolpanel, infoPanel,8*73);
133 Connect(b->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
134 Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
135 Connect(b2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
136 Connect(b3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
137 Connect(b4->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
138 Connect(b5->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
139 Connect(b6->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
143 interfMainPanel::~interfMainPanel(void)
148 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler)
150 _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(450,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER);
151 _newframe->SetMinSize( wxSize(200,200) );
152 if(interfmainpanel == NULL)
154 interfmainpanel = new interfMainPanel(_newframe, 450, 900, evtHandler, datadir);
156 _newframe->Show(TRUE);
157 return interfmainpanel;
160 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler)
162 _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(450,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER);
163 _newframe->SetMinSize( wxSize(200,200) );
164 if(interfmainpanel == NULL)
166 interfmainpanel = new interfMainPanel(_newframe, 450, 900, evtHandler);
168 _newframe->Show(TRUE);
169 return interfmainpanel;
172 bool interfMainPanel::Show(bool show)
174 return _newframe->Show(show);
177 interfMainPanel* interfMainPanel::getInstance()
179 return interfmainpanel;
182 void interfMainPanel :: resetInstance()
184 //delete interfmainpanel;
186 interfmainpanel = NULL;
189 wxPanel* interfMainPanel::initializeToolsPanel(wxWindow* parent, int sizex, int sizey, wxEvtHandler * evtHandler)
191 wxPanel* panel = new wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN, wxString(_T("Spread")));
192 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2) ;
193 panel->SetSizer(flexsizer, true);
194 panel->SetAutoLayout( true );
195 interfToolsMenu *menu = new interfToolsMenu(panel, sizex, sizey, evtHandler);
196 toolspread = new interfToolsSpreadPanel(panel, sizex, 300, evtHandler);
197 flexsizer->Add(menu, wxFIXED_MINSIZE);
198 flexsizer->Add(toolspread, wxFIXED_MINSIZE);
204 ** Adds a new checkbox to the scrolledwindow using the checkboxsizer
205 ** @Params id of contour
208 void interfMainPanel::addContourCheckBox(std::string id)
210 toolspread->addContourCheckBox(id);
214 ** Removes a checkbox from the list of checkboxes in the flexsizer (checkboxsizer)
215 ** @Params id of contour
218 void interfMainPanel::removeContourCheckBox(std::string id)
220 toolspread->removeContourCheckBox(id);
223 void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event )
225 //((interfToolsMenu*)menubar4)->hideAxis();
226 wxButton* b = (wxButton*)event.GetEventObject();
229 std::string dstring = *((std::string*) b->GetClientData());
232 if(dstring.compare(PANEL)==0){
235 }else if(dstring.compare(PANEL1)==0 ){
238 }else if(dstring.compare(PANEL2)==0){
241 }else if(dstring.compare(PANEL3)==0){
244 }else if(dstring.compare(PANEL4)==0){
247 }else if(dstring.compare(PANEL5)==0){
250 }else if(dstring.compare(PANEL6)==0){
255 if(wxStrcmp(b->GetLabel(),_T("+"))==0 ){
258 b->SetLabel(_T("-"));
262 b->SetLabel(_T("+"));
265 sizechange *= (dmenu->GetSize().GetHeight()-10);
266 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+sizechange);
272 wxStaticText* interfMainPanel::getText(wxWindow* parent, std::string nom)
274 return new wxStaticText(parent, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition,
275 wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
278 wxButton* interfMainPanel::getButton(wxWindow* parent)
280 wxButton* b = new wxButton(parent, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
281 wxDefaultValidator, wxString(_T("-")));
285 wxPanel* interfMainPanel::setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text)
287 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2);
288 parent->SetSizer(flexsizer, true);
289 parent->SetAutoLayout( true );
290 flexsizer->Add(text, wxFLEX_GROWMODE_ALL);
291 flexsizer->Add(panel, wxFLEX_GROWMODE_ALL);
293 return (wxPanel*)parent;
297 ** Shows the panel in the
299 void interfMainPanel::showPanel(wxWindow* panel)
301 wxContourMainFrame::getInstance()->showAxis(false);
302 wxSizer* sizer = infoPanel->GetSizer();
303 if(currentWindow != NULL)
305 currentWindow->Hide();
306 /// \TODO fix warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated
307 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
308 #if wxMAJOR_VERSION <= 2
309 sizer->Remove(currentWindow);
311 sizer->Detach(currentWindow);
313 } // if currentWindow
315 currentWindow = panel;
316 currentWindow->Show(true);
317 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
318 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
320 infoPanel->Refresh();
326 ** Hide the panel in the lower box
328 void interfMainPanel::hidePanel( )
330 wxContourMainFrame::getInstance()->showAxis(false);
331 wxSizer* sizer = infoPanel->GetSizer();
332 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);
344 wxPanel * emptyPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
345 sizer->Add(emptyPanel);
346 currentWindow = emptyPanel;
347 currentWindow->Show(true);
348 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
349 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
351 infoPanel->Refresh();
357 ** Gets the Information panel
359 wxPanel* interfMainPanel::getInfoPanel()
364 void interfMainPanel::onCreateContourSpline( )
366 wxContourMainFrame::getInstance()->showAxis(false);
367 wxContourMainFrame::getInstance()->onCreateContourSpline();
370 void interfMainPanel::onCreateContourRectangle( )
372 wxContourMainFrame::getInstance()->showAxis(false);
373 wxContourMainFrame::getInstance()->onCreateContourRectangle();
375 void interfMainPanel::onCreateContourCircle( )
377 wxContourMainFrame::getInstance()->showAxis(false);
378 wxContourMainFrame::getInstance()->onCreateContourCircle();
381 void interfMainPanel::onCreateContourLine( )
383 wxContourMainFrame::getInstance()->showAxis(false);
384 wxContourMainFrame::getInstance()->onCreateContourLine();
387 // RaC 09-09 ---------------------
388 void interfMainPanel::onCreateContourPoints( )
390 wxContourMainFrame::getInstance()->showAxis(false);
391 wxContourMainFrame::getInstance()->onCreateContourPoints();
393 // RaC 09-09 ---------------------
395 // RaC 10-09 ---------------------
396 void interfMainPanel::onCreateContourPolygon( )
398 wxContourMainFrame::getInstance()->showAxis(false);
399 wxContourMainFrame::getInstance()->onCreateContourPolygon();
401 // RaC 10-09 ---------------------
403 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull)
405 wxContourMainFrame::getInstance()->showAxis(false);
406 wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
409 void interfMainPanel::onDeleteContoursActSlice()
411 wxContourMainFrame::getInstance()->showAxis(false);
412 wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
415 void interfMainPanel::onDeleteContour()
417 wxContourMainFrame::getInstance()->showAxis(false);
418 wxContourMainFrame::getInstance()->onDeleteContour();
421 void interfMainPanel::onDeleteAllContours()
423 wxMessageDialog *dial;
424 dial=new wxMessageDialog( NULL,
425 wxT("Delete all contours of the system?"),
427 wxOK | wxCANCEL | wxICON_QUESTION );
428 if (dial->ShowModal()==wxID_OK)
430 wxContourMainFrame::getInstance()->showAxis(false);
431 wxContourMainFrame::getInstance()->onDeleteAllContours();
435 void interfMainPanel::onCopy()
437 wxContourMainFrame::getInstance()->onCopy();
440 void interfMainPanel::onPaste()
442 wxContourMainFrame::getInstance()->onPaste();
445 void interfMainPanel::onUndo()
447 wxContourMainFrame::getInstance()->onUndo();
450 void interfMainPanel::onRedo()
452 wxContourMainFrame::getInstance()->onRedo();
455 void interfMainPanel::onLoad()
457 wxContourMainFrame::getInstance()->onLoad();
460 void interfMainPanel::onSave()
462 wxContourMainFrame::getInstance()->onSave();
465 void interfMainPanel::onImport()
467 wxContourMainFrame::getInstance()->onImport();
470 void interfMainPanel::onTest()
472 printf("EED interfMainPanel::onTest \n");
475 testPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
476 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
477 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
478 testPanel->SetSizer(flexsizer, true);
479 testPanel->SetAutoLayout( true );
480 panelTest = new interfTestPanel(testPanel);
481 wxStaticText* stattext = new wxStaticText(testPanel, -1,
482 wxString(_T(" Test Panel ")),
483 wxDefaultPosition, wxDefaultSize,
484 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
485 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
486 flexsizer->Add(panelTest, wxEXPAND);
489 showPanel(testPanel);
492 void interfMainPanel::RefreshInterface()
494 wxContourMainFrame::getInstance()->RefreshInterface();
497 vtkImageData* interfMainPanel::getImageData()
499 return wxContourMainFrame::getInstance()->getImageData();
502 void interfMainPanel::getImageRange(double range[2] )
504 vtkImageData * img = getImageData();
505 img->GetScalarRange(range);
508 void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method)
510 wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
513 void interfMainPanel::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
515 wxContourMainFrame::getInstance()->onSegmentationOneSliceITK(distance, sigma, alfa, beta, propagation, iterations, inflation);
518 int interfMainPanel::GetImageDataSizeZ()
520 return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
523 void interfMainPanel::onSegmentationAllSlices(int minZ,int maxZ,int isovalue,int sampling,int method)
525 wxContourMainFrame::getInstance()->onSegmentationAllSlices(minZ, maxZ,isovalue,sampling,method);
528 void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString)
530 ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
533 void interfMainPanel::onSegmentationPressed()
535 if(segmentPanel == NULL)
537 segmentPanel = new wxPanel(getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
538 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
539 segmentPanel->SetSizer(flexsizer, true);
540 segmentPanel->SetAutoLayout(true);
541 segmentPanel->SetEventHandler(this);
542 //wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
543 segmentationPanel = new interfSegmentationPanelVTK(segmentPanel);
544 wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T(" Automatic Segmentation ")), wxDefaultPosition,
545 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
547 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
548 flexsizer->Add(segmentationPanel, wxEXPAND);
549 segmentPanel->Layout();
551 showPanel(segmentPanel);
552 wxContourMainFrame::getInstance()->showAxis(true);
556 void interfMainPanel::onSegmentationPressedITK()
558 if(segmentPanelITK == NULL)
560 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
561 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
562 segmentPanelITK->SetSizer(flexsizer, true);
563 segmentPanelITK->SetAutoLayout( true );
564 //segmentPanelITK->SetEventHandler(this->contourevent);
566 //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
567 wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
569 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
570 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
572 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
573 flexsizer->Add(panel, wxEXPAND);
574 segmentPanelITK->Layout();
575 }// if segmentPanelITK
576 showPanel(segmentPanelITK);
577 wxContourMainFrame::getInstance()->showAxis(true);
581 void interfMainPanel::onRigidPressed()
583 wxContourMainFrame::getInstance()->onRigidPressed();
586 void interfMainPanel::onWidthOfContour(double width)
588 wxContourMainFrame::getInstance()->onWidthOfContour(width);
591 int interfMainPanel::getColorWindow()
593 return wxContourMainFrame::getInstance()->getColorWindow();
595 int interfMainPanel::getWindowLevel()
597 return wxContourMainFrame::getInstance()->getWindowLevel();
599 void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
601 wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
604 void interfMainPanel::onInterpolation(bool interpolate)
606 wxContourMainFrame::getInstance()->onInterpolation(interpolate);
609 void interfMainPanel::onBeforAfterContour(bool before, bool after)
611 wxContourMainFrame::getInstance()->onBeforeAfterContour(before,after);
614 void interfMainPanel::onJumpSlice(int step, int shift)
616 wxContourMainFrame::getInstance()->onJumpSlice(step,shift);
619 void interfMainPanel::onShowTextContour(bool show)
621 wxContourMainFrame::getInstance()->onShowTextContour(show);
625 void interfMainPanel::onConfigurationPressed()
627 if(configPanel == NULL)
629 configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
630 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
631 configPanel->SetSizer(flexsizer, true);
632 configPanel->SetAutoLayout( true );
633 //configPanel->SetEventHandler(this->contourevent);
634 wxPanel* panel = new interfConfigurationPanel(configPanel);
635 wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T(" Interface Configuration ")), wxDefaultPosition,
636 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
637 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
638 flexsizer->Add(panel, wxEXPAND);
639 configPanel->Layout();
641 showPanel(configPanel);
644 void interfMainPanel::onSpreadPressed()
646 if(spreadPanel==NULL)
648 spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
649 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
650 spreadPanel->SetSizer(flexsizer, true);
651 spreadPanel->SetAutoLayout( true );
652 //spreadPanel->SetEventHandler(this->contourevent);
653 //wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
654 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("")));
657 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
658 flexsizer->Add(panelSpread, wxEXPAND);
659 spreadPanel->Layout();
661 showPanel(spreadPanel);
665 void interfMainPanel::resetAppend()
667 wxContourMainFrame::getInstance()->resetAppend();
670 void interfMainPanel::onSpreadAdd()
672 wxContourMainFrame::getInstance()->onSpreadAdd();
675 void interfMainPanel::onSpreadAddAll()
677 wxContourMainFrame::getInstance()->onSpreadAddAll();
681 void interfMainPanel::appendStringSpread(std::string val)
683 panelSpread->appendStringSpread(val);
686 void interfMainPanel::onSpreadGo(int type)
688 wxContourMainFrame::getInstance()->onSpreadGo(type);
691 void interfMainPanel::setStringSpread(std::string stringtemp)
693 panelSpread->setStringSpread(stringtemp);
696 void interfMainPanel::onInformationPressed()
701 infoWin = new wxFrame (this, -1,_T(" Statistics "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
702 infoWin->SetSize( wxSize(825,650) );
704 wxSize sizepanel(825,675);
705 informationPanel = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
707 wxFlexGridSizer * sizerPanel = new wxFlexGridSizer(1);
709 sizerPanel -> Add( informationPanel, 1, wxEXPAND ,0);
711 infoWin->SetSizer( sizerPanel );
712 infoWin->SetAutoLayout( true );
716 if (infoWin->IsShown()==true)
718 infoWin->Show(false);
720 //contourevent->FillGridWithContoursInformation();
725 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
728 panelAux = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
730 //------------------------------------------------------------------------------------------------------------
731 // mask view control panel
732 if(infoPanelMask == NULL){
733 infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
734 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
735 infoPanelMask->SetSizer(flexsizer, true);
736 infoPanelMask->SetAutoLayout( true );
737 //configPanel->SetEventHandler(this->contourevent);
738 wxPanel *panel = wxContourMainFrame::getInstance()->getMaskImageViewPanel( infoPanelMask );
739 wxStaticText* stattext = new wxStaticText(infoPanelMask, -1, wxString(_T(" Mask segmentation ")), wxDefaultPosition,
740 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
741 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
742 flexsizer->Add(panel, wxEXPAND);
743 infoPanelMask->Layout();
746 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
748 if(infoPanelCalibration == NULL)
750 infoPanelCalibration = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER , wxString(_T("")));
751 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
752 infoPanelCalibration->SetSizer(flexsizer, true);
753 infoPanelCalibration->SetAutoLayout( true );
754 wxPanel *panel = new interfCalibrationPanel(infoPanelCalibration);
755 wxStaticText* stattext = new wxStaticText(infoPanelCalibration, -1, wxString(_T(" Calibration ")), wxDefaultPosition,
756 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
757 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
758 flexsizer->Add(panel, wxEXPAND);
759 infoPanelCalibration->Layout();
762 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
763 #if wxMAJOR_VERSION <= 2
764 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
766 wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
768 sizer->Add(infoPanelMask);
769 sizer->Add(infoPanelCalibration);
770 panelAux->SetSizer(sizer, true);
771 panelAux->SetAutoLayout( true );
774 //------------------------------------------------------------------
775 wxContourMainFrame::getInstance()->changeInstant();
779 void interfMainPanel::getInstantVector(std::vector<int>& tempVector)
781 wxContourMainFrame::getInstance()->getInstantVector(tempVector);
784 std::vector<std::string> interfMainPanel::getOutlinesName(int slide)
786 return wxContourMainFrame::getInstance()->getOutlinesName(slide);
789 void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ,int grayRangeMin,int grayRangeMax){
790 wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ,grayRangeMin,grayRangeMax);
793 void interfMainPanel::setStringInfoPanel(wxString tmpString)
795 if(informationPanel!=NULL){
796 ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
800 void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString)
802 ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
805 int interfMainPanel::getNumberColsInformationPanel()
807 return ((interfInformationPanel*)informationPanel)->getNumberCols();
810 void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics)
812 ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
815 void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString)
817 ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
820 void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString)
822 ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
826 void interfMainPanel::SetScalarRange(int grayRangeMin,int grayRangeMax)
828 wxContourMainFrame::getInstance()->SetScalarRange(grayRangeMin, grayRangeMax);
831 void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename,
832 int typeContourGroup, int selection, int minZ, int maxZ ,bool XYZValues, bool contourImage, bool statistics)
834 wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename,
835 typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
838 wxString interfMainPanel::getCellValue(int j,int i){
839 return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
842 void interfMainPanel::onSnakePressed()
845 wxContourMainFrame::getInstance()->showAxis(axisshown);
846 wxContourMainFrame::getInstance()->onSnakePressed();
849 void interfMainPanel::onMirrorPressed(){
850 if(mirrorPanel==NULL)
853 mirrorPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
854 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
855 mirrorPanel->SetSizer(flexsizer, true);
856 mirrorPanel->SetAutoLayout( true );
857 panelMirror = new interfMirrorPanel(mirrorPanel);
858 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1, wxString(_T(" Mirroring Tool ")), wxDefaultPosition,
859 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
861 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
862 flexsizer->Add(panelMirror, wxEXPAND);
863 mirrorPanel->Layout();
865 wxContourMainFrame::getInstance()->referenceLine();
869 wxContourMainFrame::getInstance()->refLineShow();
874 showPanel(mirrorPanel);
877 void interfMainPanel::onMirror()
879 wxContourMainFrame::getInstance()->onMirror();
882 void interfMainPanel::onMirrorAxisShow()
886 wxContourMainFrame::getInstance()->refLineShow();
891 void interfMainPanel::onMirrorAxisHide()
895 wxContourMainFrame::getInstance()->refLineHide();
900 void interfMainPanel::onMirrorChangeWidth(int width)
902 wxContourMainFrame::getInstance()->refLineChangeWidth(width);
906 void interfMainPanel::onColorLayerImagePressed()
908 // Color Image Layer view control panel
909 if(colorImageLayerPanel == NULL){
910 colorImageLayerPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
911 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
912 colorImageLayerPanel->SetSizer(flexsizer, true);
913 colorImageLayerPanel->SetAutoLayout( true );
914 //configPanel->SetEventHandler(this->contourevent);
915 wxPanel *panel = wxContourMainFrame::getInstance()->getColorLayerImageViewPanel( colorImageLayerPanel );
916 wxStaticText* stattext = new wxStaticText(colorImageLayerPanel, -1, wxString(_T(" Color Image Layer ")), wxDefaultPosition,
917 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
918 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
919 flexsizer->Add(panel, wxEXPAND);
920 colorImageLayerPanel->Layout();
922 showPanel(colorImageLayerPanel);
923 wxContourMainFrame::getInstance()->changeInstant();
927 void interfMainPanel::onThresholdPressed()
929 // Threshold view control panel
930 if(thresholdPanel == NULL){
931 thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
932 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
933 thresholdPanel->SetSizer(flexsizer, true);
934 thresholdPanel->SetAutoLayout( true );
935 //configPanel->SetEventHandler(this->contourevent);
936 wxPanel *panel = wxContourMainFrame::getInstance()->getThresholdImageViewPanel( thresholdPanel );
937 wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T(" Threshold segmentation ")), wxDefaultPosition,
938 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
939 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
940 flexsizer->Add(panel, wxEXPAND);
941 thresholdPanel->Layout();
943 showPanel(thresholdPanel);
944 wxContourMainFrame::getInstance()->changeInstant();
948 void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
950 wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
954 void interfMainPanel::SetContourGroup(int contourGroup)
956 wxContourMainFrame::getInstance()->SetContourGroup( contourGroup);
960 void interfMainPanel::onFlipContours()
962 printf("EED interfMainPanel::onFlipContours() \n");
965 flipPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
966 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
967 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
968 flipPanel->SetSizer(flexsizer, true);
969 flipPanel->SetAutoLayout( true );
970 panelFlip = new interfFlipPanel(flipPanel);
971 wxStaticText* stattext = new wxStaticText(flipPanel, -1,
972 wxString(_T(" Flip Contours ")),
973 wxDefaultPosition, wxDefaultSize,
974 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
975 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
976 flexsizer->Add(panelFlip, wxEXPAND);
979 showPanel(flipPanel);
983 void interfMainPanel::FlipContours(int typeContourFlip, int flipDirection)
985 printf("EED interfMainPanel::FlipContours( %d , %d ) \n",typeContourFlip, flipDirection );
986 wxContourMainFrame::getInstance()->FlipContours( typeContourFlip , flipDirection );
991 //CMRU 17-08-09 ---------------------------------------------
992 void interfMainPanel::onPrintLabel ()
995 manualBaseModel* manualModel = wxContourMainFrame::getInstance()->getContour();
997 if(manualModel==NULL)
999 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a Contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1004 wxTextEntryDialog* dialog = new wxTextEntryDialog(this,_T("Enter a tag name: ")) ;
1006 if (dialog->ShowModal() == wxID_OK)
1008 label = dialog->GetValue();
1012 wxContourMainFrame::getInstance()->onPrintLabel(label,manualModel);
1013 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The tag name was updated"), wxT("Information"), wxOK | wxICON_INFORMATION);
1018 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a valid tag"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1024 void interfMainPanel::onCalibration(wxString size, int unit)
1027 double contourSize = 0.0;
1028 double realSizeDouble = 0.0;
1030 type = wxContourMainFrame::getInstance()->getType();
1031 contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels();
1033 std::cout<<"Cata->Tama�o del contorno en pixeles:"<<contourSize<<endl;
1037 if (size.ToDouble(&realSizeDouble))
1041 realSizeDouble = realSizeDouble * 10;
1045 realSizeDouble = realSizeDouble * 25.4;
1047 std::cout<< "Valor del usuario" << realSizeDouble<< endl ;
1048 onePixelSize (realSizeDouble,contourSize);
1052 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a numeric value"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1058 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a line contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1062 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The calibration was made"), wxT("Information"), wxOK | wxICON_INFORMATION);
1064 std::cout<< "Cata-> Se ha realizado la calibracion" << endl ;
1067 double interfMainPanel::onePixelSize (double realSize,double sizePixel)
1069 _pixelValue = realSize/sizePixel;
1070 std::cout<< "Valor del un pixel = " << _pixelValue<< endl ;
1071 wxContourMainFrame::getInstance()->onePixelSize (_pixelValue);
1072 return _pixelValue ;
1075 double interfMainPanel::GetPixelValue()
1079 //------------------------------------------------------------------------------------------------------------