1 #include "interfMainPanel.h"
4 interfMainPanel* interfMainPanel::interfmainpanel=NULL;
5 wxFrame* interfMainPanel::_newframe=NULL;
7 interfMainPanel::interfMainPanel(wxWindow * parent, int sizex, int sizey, wxEvtHandler * evtHandler, std::string datadir)
8 : wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN)
11 PANEL = "New Contour";
15 PANEL4 = "Contour Tools";
16 PANEL5 = "Segmentation";
18 PANEL6 = "Image Tools";
21 segmentPanelITK = NULL;
27 informationPanel = NULL;
29 thresholdPanel = NULL;
30 colorImageLayerPanel = NULL;
34 //CMRU 17-08-09 ------------------------------------------------------------------
35 infoPanelCalibration = NULL;
37 //--------------------------------------------------------------------------------
38 splitterwindow = new wxSplitterWindow(this,-1, wxDefaultPosition, wxSize(sizex, sizey), wxSP_3DSASH, wxString(_T("")));
40 splitterwindow->SetMinimumPaneSize( 10 );
43 wxPanel* toolpanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
45 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(6,2,1,1);
46 toolpanel->SetSizer(flexsizer, true);
47 toolpanel->SetAutoLayout( true );
49 wxButton* b = getButton(toolpanel);
50 b->SetClientData(&PANEL);
51 wxButton* b1 = getButton(toolpanel);
52 b1->SetClientData(&PANEL1);
53 wxButton* b2 = getButton(toolpanel);
54 b2->SetClientData(&PANEL2);
55 wxButton* b3 = getButton(toolpanel);
56 b3->SetClientData(&PANEL3);
57 wxButton* b4 = getButton(toolpanel);
58 b4->SetClientData(&PANEL4);
59 wxButton* b5 = getButton(toolpanel);
60 b5->SetClientData(&PANEL5);
62 wxButton* b6 = getButton(toolpanel);
63 b6->SetClientData(&PANEL6);
66 wxPanel* mentex = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
67 wxPanel* mentex1 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
68 wxPanel* mentex2 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
69 wxPanel* mentex3 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
70 wxPanel* mentex4 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
71 wxPanel* mentex5 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
73 wxPanel* mentex6 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
75 menubar = new interfNewContourMenu (mentex, sizex, sizey, evtHandler, datadir);
76 menubar1 = new interfIOMenu (mentex1, sizex, sizey, evtHandler, datadir);
77 menubar2 = new interfEditMenu (mentex2, sizex, sizey, evtHandler, datadir);
78 menubar3 = new interfDeleteMenu (mentex3, sizex, sizey, evtHandler, datadir);
79 menubar4 = new interfToolsMenu (mentex4, sizex ,sizey, evtHandler, datadir);
80 menubar5 = new interfSegmentationMenu(mentex5, sizex, sizey, evtHandler, datadir);
81 menubar6 = new interfImageToolsMenu(mentex6, sizex, sizey, evtHandler, datadir);
83 statictext = getText(mentex, PANEL);
84 statictext1 = getText(mentex1, PANEL1);
85 statictext2 = getText(mentex2, PANEL2);
86 statictext3 = getText(mentex3, PANEL3);
87 statictext4 = getText(mentex4, PANEL4);
88 statictext5 = getText(mentex5, PANEL5);
89 statictext6 = getText(mentex6, PANEL6);
91 flexsizer->Add(b, wxFIXED_MINSIZE);
92 flexsizer->Add(setMenuTextSizer(mentex, menubar,statictext), wxFIXED_MINSIZE);
94 flexsizer->Add(b1, wxFIXED_MINSIZE);
95 flexsizer->Add(setMenuTextSizer(mentex1, menubar1,statictext1), wxFIXED_MINSIZE);
97 flexsizer->Add(b2, wxFIXED_MINSIZE);
98 flexsizer->Add(setMenuTextSizer(mentex2, menubar2,statictext2), wxFIXED_MINSIZE);
100 flexsizer->Add(b3, wxFIXED_MINSIZE);
101 flexsizer->Add(setMenuTextSizer(mentex3, menubar3,statictext3), wxFIXED_MINSIZE);
103 flexsizer->Add(b4, wxFIXED_MINSIZE);
104 flexsizer->Add(setMenuTextSizer(mentex4, menubar4,statictext4), wxFIXED_MINSIZE);
106 flexsizer->Add(b5, wxFIXED_MINSIZE);
107 flexsizer->Add(setMenuTextSizer(mentex5, menubar5,statictext5), wxFIXED_MINSIZE);
108 flexsizer->Add(b6, wxFIXED_MINSIZE);
109 flexsizer->Add(setMenuTextSizer(mentex6, menubar6,statictext6), wxFIXED_MINSIZE);
114 infoPanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_DOUBLE, wxString(_T("")));
115 wxFlexGridSizer* infosizer = new wxFlexGridSizer(1,1,2,2);
116 infoPanel->SetSizer(infosizer, true);
117 infoPanel->SetAutoLayout( true );
119 splitterwindow->Initialize(toolpanel);
120 splitterwindow->SetSashGravity(1);
121 splitterwindow->SetSashPosition(500);
122 splitterwindow->SetSashSize(5);
123 splitterwindow->SplitHorizontally(toolpanel, infoPanel);
125 Connect(b->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
126 Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
127 Connect(b2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
128 Connect(b3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
129 Connect(b4->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
130 Connect(b5->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
131 Connect(b6->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
136 interfMainPanel::~interfMainPanel(void)
141 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler)
143 _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);
145 if(interfmainpanel == NULL){
146 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler, datadir);
148 _newframe->Show(TRUE);
149 return interfmainpanel;
152 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler)
155 _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 );
157 if(interfmainpanel == NULL){
158 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler);
160 _newframe->Show(TRUE);
161 return interfmainpanel;
164 bool interfMainPanel::Show(bool show)
166 return _newframe->Show(show);
169 interfMainPanel* interfMainPanel::getInstance()
171 return interfmainpanel;
174 void interfMainPanel :: resetInstance()
176 //delete interfmainpanel;
178 interfmainpanel = NULL;
181 wxPanel* interfMainPanel::initializeToolsPanel(wxWindow* parent, int sizex, int sizey, wxEvtHandler * evtHandler)
183 wxPanel* panel = new wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN, wxString(_T("Spread")));
185 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2) ;
186 panel->SetSizer(flexsizer, true);
187 panel->SetAutoLayout( true );
189 interfToolsMenu* menu = new interfToolsMenu(panel, sizex, sizey, evtHandler);
190 toolspread = new interfToolsSpreadPanel(panel, sizex, 300, evtHandler);
192 flexsizer->Add(menu, wxFIXED_MINSIZE);
193 flexsizer->Add(toolspread, wxFIXED_MINSIZE);
201 ** Adds a new checkbox to the scrolledwindow using the checkboxsizer
202 ** @Params id of contour
205 void interfMainPanel::addContourCheckBox(std::string id)
207 toolspread->addContourCheckBox(id);
211 ** Removes a checkbox from the list of checkboxes in the flexsizer (checkboxsizer)
212 ** @Params id of contour
215 void interfMainPanel::removeContourCheckBox(std::string id)
217 toolspread->removeContourCheckBox(id);
220 void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event )
222 //((interfToolsMenu*)menubar4)->hideAxis();
223 wxButton* b = (wxButton*)event.GetEventObject();
226 std::string dstring = *((std::string*) b->GetClientData());
229 if(dstring.compare(PANEL)==0){
232 }else if(dstring.compare(PANEL1)==0 ){
235 }else if(dstring.compare(PANEL2)==0){
238 }else if(dstring.compare(PANEL3)==0){
241 }else if(dstring.compare(PANEL4)==0){
244 }else if(dstring.compare(PANEL5)==0){
247 }else if(dstring.compare(PANEL6)==0){
252 if(wxStrcmp(b->GetLabel(),_T("+"))==0 ){
255 b->SetLabel(_T("-"));
259 b->SetLabel(_T("+"));
262 sizechange *= dmenu->GetSize().GetHeight();
263 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+sizechange);
269 wxStaticText* interfMainPanel::getText(wxWindow* parent, std::string nom)
271 return new wxStaticText(parent, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition,
272 wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
275 wxButton* interfMainPanel::getButton(wxWindow* parent)
277 wxButton* b = new wxButton(parent, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT,
278 wxDefaultValidator, wxString(_T("-")));
282 wxPanel* interfMainPanel::setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text)
285 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2);
286 parent->SetSizer(flexsizer, true);
287 parent->SetAutoLayout( true );
289 flexsizer->Add(text, wxFLEX_GROWMODE_ALL);
290 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();
304 if(currentWindow != NULL){
305 currentWindow->Hide();
306 sizer->Remove(currentWindow);
309 currentWindow = panel;
310 currentWindow->Show(true);
312 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
313 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
316 infoPanel->Refresh();
322 ** Hide the panel in the lower box
324 void interfMainPanel::hidePanel( )
326 wxContourMainFrame::getInstance()->showAxis(false);
327 wxSizer* sizer = infoPanel->GetSizer();
329 if(currentWindow != NULL){
330 currentWindow->Hide();
331 sizer->Remove(currentWindow);
333 wxPanel * emptyPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
334 sizer->Add(emptyPanel);
335 currentWindow = emptyPanel;
336 currentWindow->Show(true);
338 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
339 splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
342 infoPanel->Refresh();
348 ** Gets the Information panel
350 wxPanel* interfMainPanel::getInfoPanel()
355 void interfMainPanel::onCreateContourSpline( )
357 wxContourMainFrame::getInstance()->showAxis(false);
358 wxContourMainFrame::getInstance()->onCreateContourSpline();
361 void interfMainPanel::onCreateContourRectangle( )
363 wxContourMainFrame::getInstance()->showAxis(false);
364 wxContourMainFrame::getInstance()->onCreateContourRectangle();
366 void interfMainPanel::onCreateContourCircle( )
368 wxContourMainFrame::getInstance()->showAxis(false);
369 wxContourMainFrame::getInstance()->onCreateContourCircle();
372 void interfMainPanel::onCreateContourLine( )
374 wxContourMainFrame::getInstance()->showAxis(false);
375 wxContourMainFrame::getInstance()->onCreateContourLine();
378 // RaC 09-09 ---------------------
379 void interfMainPanel::onCreateContourPoints( )
381 wxContourMainFrame::getInstance()->showAxis(false);
382 wxContourMainFrame::getInstance()->onCreateContourPoints();
384 // RaC 09-09 ---------------------
386 // RaC 10-09 ---------------------
387 void interfMainPanel::onCreateContourPolygon( )
389 wxContourMainFrame::getInstance()->showAxis(false);
390 wxContourMainFrame::getInstance()->onCreateContourPolygon();
392 // RaC 10-09 ---------------------
394 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull)
396 wxContourMainFrame::getInstance()->showAxis(false);
397 wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
400 void interfMainPanel::onDeleteContour()
402 wxContourMainFrame::getInstance()->showAxis(false);
403 wxContourMainFrame::getInstance()->onDeleteContour();
406 void interfMainPanel::onDeleteContoursActSlice()
408 wxContourMainFrame::getInstance()->showAxis(false);
409 wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
412 void interfMainPanel::onDeleteAllContours()
414 wxContourMainFrame::getInstance()->showAxis(false);
415 wxContourMainFrame::getInstance()->onDeleteAllContours();
418 void interfMainPanel::onCopy()
420 wxContourMainFrame::getInstance()->onCopy();
423 void interfMainPanel::onPaste()
425 wxContourMainFrame::getInstance()->onPaste();
428 void interfMainPanel::onUndo()
430 wxContourMainFrame::getInstance()->onUndo();
433 void interfMainPanel::onRedo()
435 wxContourMainFrame::getInstance()->onRedo();
438 void interfMainPanel::onLoad()
440 wxContourMainFrame::getInstance()->onLoad();
443 void interfMainPanel::onSave()
445 wxContourMainFrame::getInstance()->onSave();
448 void interfMainPanel::onImport(){
449 wxContourMainFrame::getInstance()->onImport();
452 void interfMainPanel::onTest(){
455 testPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition,
456 wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
457 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
458 testPanel->SetSizer(flexsizer, true);
459 testPanel->SetAutoLayout( true );
460 panelTest = new interfTestPanel(testPanel);
462 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1,
463 wxString(_T(" Test Panel ")),
464 wxDefaultPosition, wxDefaultSize,
465 wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
467 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
468 flexsizer->Add(panelTest, wxEXPAND);
470 showPanel(testPanel);
474 void interfMainPanel::RefreshInterface()
476 wxContourMainFrame::getInstance()->RefreshInterface();
479 vtkImageData* interfMainPanel::getImageData()
481 return wxContourMainFrame::getInstance()->getImageData();
484 void interfMainPanel::getImageRange(double range[2] )
486 vtkImageData * img = getImageData();
487 img->GetScalarRange(range);
490 void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method)
492 wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
495 void interfMainPanel::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
497 wxContourMainFrame::getInstance()->onSegmentationOneSliceITK(distance, sigma, alfa, beta, propagation, iterations, inflation);
500 int interfMainPanel::GetImageDataSizeZ()
502 return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
505 void interfMainPanel::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method)
507 wxContourMainFrame::getInstance()->onSegmentationAllSlice(minZ, maxZ,isovalue,sampling,method);
510 void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString)
512 ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
514 void interfMainPanel::onSegmentationPressed()
516 if(segmentPanel == NULL){
517 segmentPanel = new wxPanel(getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
518 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
519 segmentPanel->SetSizer(flexsizer, true);
520 segmentPanel->SetAutoLayout(true);
521 segmentPanel->SetEventHandler(this);
523 //wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
524 segmentationPanel = new interfSegmentationPanelVTK(segmentPanel);
527 wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T(" Automatic Segmentation ")), wxDefaultPosition,
528 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
530 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
531 flexsizer->Add(segmentationPanel, wxEXPAND);
532 segmentPanel->Layout();
534 showPanel(segmentPanel);
535 wxContourMainFrame::getInstance()->showAxis(true);
539 void interfMainPanel::onSegmentationPressedITK()
541 if(segmentPanelITK == NULL){
542 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
545 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
546 segmentPanelITK->SetSizer(flexsizer, true);
547 segmentPanelITK->SetAutoLayout( true );
548 //segmentPanelITK->SetEventHandler(this->contourevent);
550 //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
551 wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
553 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition,
554 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
556 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
557 flexsizer->Add(panel, wxEXPAND);
558 segmentPanelITK->Layout();
560 showPanel(segmentPanelITK);
561 wxContourMainFrame::getInstance()->showAxis(true);
565 void interfMainPanel::onRigidPressed()
567 wxContourMainFrame::getInstance()->onRigidPressed();
570 void interfMainPanel::onWidthOfContour(double width)
572 wxContourMainFrame::getInstance()->onWidthOfContour(width);
575 int interfMainPanel::getColorWindow()
577 return wxContourMainFrame::getInstance()->getColorWindow();
579 int interfMainPanel::getWindowLevel()
581 return wxContourMainFrame::getInstance()->getWindowLevel();
583 void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
585 wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
588 void interfMainPanel::onInterpolation(bool interpolate)
590 wxContourMainFrame::getInstance()->onInterpolation(interpolate);
594 void interfMainPanel::onConfigurationPressed()
596 if(configPanel == NULL){
597 configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
598 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
599 configPanel->SetSizer(flexsizer, true);
600 configPanel->SetAutoLayout( true );
601 //configPanel->SetEventHandler(this->contourevent);
602 wxPanel* panel = new interfConfigurationPanel(configPanel);
603 wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T(" Interface Configuration ")), wxDefaultPosition,
604 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
605 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
606 flexsizer->Add(panel, wxEXPAND);
607 configPanel->Layout();
609 showPanel(configPanel);
612 void interfMainPanel::onSpreadPressed()
614 if(spreadPanel==NULL){
616 spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
617 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
618 spreadPanel->SetSizer(flexsizer, true);
619 spreadPanel->SetAutoLayout( true );
620 //spreadPanel->SetEventHandler(this->contourevent);
622 //wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
623 panelSpread = new interfSpreadPanel(spreadPanel);
626 wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T(" Automatic Spread ")), wxDefaultPosition,
627 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
629 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
630 flexsizer->Add(panelSpread, wxEXPAND);
631 spreadPanel->Layout();
633 showPanel(spreadPanel);
637 void interfMainPanel::resetAppend()
639 wxContourMainFrame::getInstance()->resetAppend();
642 void interfMainPanel::onSpreadAdd()
644 wxContourMainFrame::getInstance()->onSpreadAdd();
647 void interfMainPanel::appendStringSpread(std::string val)
649 panelSpread->appendStringSpread(val);
652 void interfMainPanel::onSpreadGo(int type)
654 wxContourMainFrame::getInstance()->onSpreadGo(type);
657 void interfMainPanel::setStringSpread(std::string stringtemp)
659 panelSpread->setStringSpread(stringtemp);
662 void interfMainPanel::onInformationPressed()
667 infoWin = new wxFrame (this, -1,_T(" Statistics "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
668 infoWin->SetSize( wxSize(825,650) );
670 wxSize sizepanel(825,675);
671 informationPanel = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
673 wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
674 sizerPanel -> Add( informationPanel, 1, wxEXPAND ,0);
676 infoWin->SetSizer( sizerPanel );
677 infoWin->SetAutoLayout( true );
682 if (infoWin->IsShown()==true)
684 infoWin->Show(false);
686 //contourevent->FillGridWithContoursInformation();
691 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
694 panelAux = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
696 //------------------------------------------------------------------------------------------------------------
698 // mask view control panel
699 if(infoPanelMask == NULL){
700 infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
701 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
702 infoPanelMask->SetSizer(flexsizer, true);
703 infoPanelMask->SetAutoLayout( true );
704 //configPanel->SetEventHandler(this->contourevent);
705 wxPanel *panel = wxContourMainFrame::getInstance()->getMaskImageViewPanel( infoPanelMask );
706 wxStaticText* stattext = new wxStaticText(infoPanelMask, -1, wxString(_T(" Mask segmentation ")), wxDefaultPosition,
707 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
709 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
711 flexsizer->Add(panel, wxEXPAND);
712 infoPanelMask->Layout();
716 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
718 if(infoPanelCalibration == NULL)
720 infoPanelCalibration = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER , wxString(_T("")));
721 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
722 infoPanelCalibration->SetSizer(flexsizer, true);
723 infoPanelCalibration->SetAutoLayout( true );
725 wxPanel *panel = new interfCalibrationPanel(infoPanelCalibration);
726 wxStaticText* stattext = new wxStaticText(infoPanelCalibration, -1, wxString(_T(" Calibration ")), wxDefaultPosition,
727 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
729 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
731 flexsizer->Add(panel, wxEXPAND);
732 infoPanelCalibration->Layout();
735 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
736 panelAux->SetSizer(sizer, true);
737 panelAux->SetAutoLayout( true );
738 sizer->Add(infoPanelMask);
739 sizer->Add(infoPanelCalibration);
743 //------------------------------------------------------------------
745 wxContourMainFrame::getInstance()->changeInstant();
748 void interfMainPanel::getInstantVector(std::vector<int>& tempVector)
750 wxContourMainFrame::getInstance()->getInstantVector(tempVector);
753 std::vector<std::string> interfMainPanel::getOutlinesName(int slide)
755 return wxContourMainFrame::getInstance()->getOutlinesName(slide);
758 void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ,int grayRangeMin,int grayRangeMax){
759 wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ,grayRangeMin,grayRangeMax);
762 void interfMainPanel::setStringInfoPanel(wxString tmpString)
764 if(informationPanel!=NULL){
765 ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
769 void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString)
771 ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
774 int interfMainPanel::getNumberColsInformationPanel()
776 return ((interfInformationPanel*)informationPanel)->getNumberCols();
779 void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics)
781 ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
784 void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString)
786 ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
789 void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString)
791 ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
795 void interfMainPanel::SetScalarRange(int grayRangeMin,int grayRangeMax)
797 wxContourMainFrame::getInstance()->SetScalarRange(grayRangeMin, grayRangeMax);
800 void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename,
801 int typeContourGroup, int selection, int minZ, int maxZ ,bool XYZValues, bool contourImage, bool statistics)
803 wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename,
804 typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
807 wxString interfMainPanel::getCellValue(int j,int i){
808 return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
811 void interfMainPanel::onSnakePressed()
814 wxContourMainFrame::getInstance()->showAxis(axisshown);
815 wxContourMainFrame::getInstance()->onSnakePressed();
818 void interfMainPanel::onMirrorPressed(){
819 if(mirrorPanel==NULL)
822 mirrorPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
823 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
824 mirrorPanel->SetSizer(flexsizer, true);
825 mirrorPanel->SetAutoLayout( true );
826 panelMirror = new interfMirrorPanel(mirrorPanel);
828 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1, wxString(_T(" Mirroring Tool ")), wxDefaultPosition,
829 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
831 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
832 flexsizer->Add(panelMirror, wxEXPAND);
833 mirrorPanel->Layout();
836 wxContourMainFrame::getInstance()->referenceLine();
844 wxContourMainFrame::getInstance()->refLineShow();
849 showPanel(mirrorPanel);
852 void interfMainPanel::onMirror()
854 wxContourMainFrame::getInstance()->onMirror();
857 void interfMainPanel::onMirrorAxisShow()
861 wxContourMainFrame::getInstance()->refLineShow();
866 void interfMainPanel::onMirrorAxisHide()
870 wxContourMainFrame::getInstance()->refLineHide();
875 void interfMainPanel::onMirrorChangeWidth(int width)
877 wxContourMainFrame::getInstance()->refLineChangeWidth(width);
881 void interfMainPanel::onColorLayerImagePressed()
883 // Color Image Layer view control panel
884 if(colorImageLayerPanel == NULL){
885 colorImageLayerPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
886 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
887 colorImageLayerPanel->SetSizer(flexsizer, true);
888 colorImageLayerPanel->SetAutoLayout( true );
889 //configPanel->SetEventHandler(this->contourevent);
890 wxPanel *panel = wxContourMainFrame::getInstance()->getThresholdImageViewPanel( colorImageLayerPanel );
891 wxStaticText* stattext = new wxStaticText(colorImageLayerPanel, -1, wxString(_T(" Color Image Layer ")), wxDefaultPosition,
892 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
893 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
894 flexsizer->Add(panel, wxEXPAND);
895 colorImageLayerPanel->Layout();
897 showPanel(colorImageLayerPanel);
898 wxContourMainFrame::getInstance()->changeInstant();
902 void interfMainPanel::onThresholdPressed()
904 // Threshold view control panel
905 if(thresholdPanel == NULL){
906 thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
907 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);
908 thresholdPanel->SetSizer(flexsizer, true);
909 thresholdPanel->SetAutoLayout( true );
910 //configPanel->SetEventHandler(this->contourevent);
911 wxPanel *panel = wxContourMainFrame::getInstance()->getColorLayerImageViewPanel( thresholdPanel );
912 wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T(" Threshold segmentation ")), wxDefaultPosition,
913 wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
914 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
915 flexsizer->Add(panel, wxEXPAND);
916 thresholdPanel->Layout();
918 showPanel(thresholdPanel);
919 wxContourMainFrame::getInstance()->changeInstant();
923 void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
925 wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
929 void interfMainPanel::SetContourGroup(int contourGroup)
931 wxContourMainFrame::getInstance()->SetContourGroup( contourGroup);
934 //CMRU 17-08-09 ---------------------------------------------
935 void interfMainPanel::onPrintLabel ()
938 manualBaseModel* manualModel = wxContourMainFrame::getInstance()->getContour();
940 if(manualModel==NULL)
942 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a Contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
947 wxTextEntryDialog* dialog = new wxTextEntryDialog(this,_T("Enter a tag name: ")) ;
949 if (dialog->ShowModal() == wxID_OK)
951 label = dialog->GetValue();
955 wxContourMainFrame::getInstance()->onPrintLabel(label,manualModel);
956 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The tag name was updated"), wxT("Information"), wxOK | wxICON_INFORMATION);
961 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a valid tag"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
967 void interfMainPanel::onCalibration(wxString size, int unit)
970 double contourSize = 0.0;
971 double realSizeDouble = 0.0;
973 type = wxContourMainFrame::getInstance()->getType();
974 contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels();
976 std::cout<<"Cata->TamaƱo del contorno en pixeles:"<<contourSize<<endl;
980 if (size.ToDouble(&realSizeDouble))
984 realSizeDouble = realSizeDouble * 10;
988 realSizeDouble = realSizeDouble * 25.4;
990 std::cout<< "Valor del usuario" << realSizeDouble<< endl ;
991 onePixelSize (realSizeDouble,contourSize);
995 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a numeric value"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1001 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a line contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
1005 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The calibration was made"), wxT("Information"), wxOK | wxICON_INFORMATION);
1007 std::cout<< "Cata-> Se ha realizado la calibracion" << endl ;
1010 double interfMainPanel::onePixelSize (double realSize,double sizePixel)
1012 _pixelValue = realSize/sizePixel;
1013 std::cout<< "Valor del un pixel = " << _pixelValue<< endl ;
1014 wxContourMainFrame::getInstance()->onePixelSize (_pixelValue);
1015 return _pixelValue ;
1018 double interfMainPanel::GetPixelValue()
1022 //------------------------------------------------------------------------------------------------------------