X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FInterface_Icons_NDimensions%2FinterfSegmentationPanels.cxx;h=0fa3d18196d39987746a8a9253cfa81f4c3bb349;hb=8f2bd3952065a2028ae345188c3493f82eda2b27;hp=306370d4af8a886afb2a5c9b38ca86135413d645;hpb=771693e697633fa631dbaa4823404eb2890136e5;p=creaContours.git diff --git a/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx b/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx index 306370d..0fa3d18 100644 --- a/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx +++ b/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx @@ -5,49 +5,50 @@ interfSegmentationPanelVTK::interfSegmentationPanelVTK(wxWindow * parent) : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) { int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ(); - //int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ(); + double range[2]; - //_theViewPanel->getSceneManager()->GetImageDataRange(range); - interfMainPanel::getInstance()->GetImageDataRange(range); + interfMainPanel::getInstance()->getImageRange(range); + + int min = (int)floor (range[0]); + int max = (int)ceil (range[1]); - wxButton *segmentationOneSliceBtn = new wxButton(this,-1,_T("Current slice"), wxDefaultPosition, wxSize(200,35) ); - wxButton *segmentationAllSliceBtn = new wxButton(this,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) ); - _isovalue = new wxSlider(this, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); - _sampling = new wxSlider(this, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); + wxButton *segmentationOneSliceBtn = new wxButton(this,-1,_T("Current slice"), wxDefaultPosition, wxSize(200,35) ); + wxButton *segmentationAllSliceBtn = new wxButton(this,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) ); + _isovalue = new wxSlider(this, -1, 40 , min, max, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); + _sampling = new wxSlider(this, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); wxString lstOptions[3]; lstOptions[0]=_T("A"); lstOptions[1]=_T("B"); lstOptions[2]=_T("C"); - methodRadiobox = new wxRadioBox(this, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS); + methodRadiobox = new wxRadioBox(this, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS); methodRadiobox->SetSelection(2); - _staticTextSegmentation = new wxStaticText(this,-1,_T(" ")); + _staticTextSegmentation = new wxStaticText(this,-1,_T(" ")); - _mbarrange = new mBarRange(this,70, 65); + _mbarrange = new mBarRange(this,70, 65); _mbarrange->SetMin(0); _mbarrange->SetStart(0); - _mbarrange-> SetOrientation( true ); - _mbarrange-> setActiveStateTo(true); - _mbarrange-> setVisibleLabels( true ); - _mbarrange-> setDeviceEndMargin(10); - _mbarrange-> setRepresentedValues( 0 , sizeZ ); - _mbarrange-> setDeviceBlitStart(10,10); - _mbarrange-> setIfWithActualDrawed( false ); - _mbarrange-> SetStart( 0 ); - _mbarrange-> SetEnd( sizeZ ); - - - wxFlexGridSizer * sizer = new wxFlexGridSizer(1); - sizer -> Add( new wxStaticText(this,-1,_T("Isovalue (Gray level)")) , 1, wxGROW ); - sizer -> Add( _isovalue , 1, wxGROW ); - sizer -> Add( methodRadiobox , 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1,_T("Sampling (%)")) , 1, wxGROW ); - sizer -> Add( _sampling , 1, wxGROW ); - sizer -> Add( segmentationOneSliceBtn , 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); - sizer -> Add( _staticTextSegmentation , 1, wxGROW ); - sizer -> Add( segmentationAllSliceBtn , 1, wxGROW ); - sizer -> Add( _mbarrange , 1, wxGROW ); + _mbarrange->SetOrientation( true ); + _mbarrange->setActiveStateTo(true); + _mbarrange->setVisibleLabels( true ); + _mbarrange->setDeviceEndMargin(10); + _mbarrange->setRepresentedValues( 0 , sizeZ ); + _mbarrange->setDeviceBlitStart(10,10); + _mbarrange->setIfWithActualDrawed( false ); + _mbarrange->SetStart( 0 ); + _mbarrange->SetEnd( sizeZ ); + + wxFlexGridSizer * sizer = new wxFlexGridSizer(1); + sizer->Add( new wxStaticText(this, -1, _T("Isovalue (Gray level)")), 1, wxGROW ); + sizer->Add( _isovalue, 1, wxGROW ); + sizer->Add( methodRadiobox , 1, wxGROW ); + sizer->Add( new wxStaticText(this, -1 ,_T("Sampling (%)")), 1, wxGROW ); + sizer->Add( _sampling, 1, wxGROW ); + sizer->Add( segmentationOneSliceBtn, 1, wxGROW ); + sizer->Add( new wxStaticText(this, -1, _T(" ")), 1, wxGROW ); + sizer->Add( _staticTextSegmentation, 1, wxGROW ); + sizer->Add( segmentationAllSliceBtn, 1, wxGROW ); + sizer->Add( _mbarrange, 1, wxGROW ); this->SetSizer( sizer ); // panel->SetSize( sizePanel ); @@ -59,8 +60,8 @@ interfSegmentationPanelVTK::interfSegmentationPanelVTK(wxWindow * parent) //segmentationOneSliceBtn->SetEventHandler( this ); //segmentationAllSliceBtn->SetEventHandler( this ); //panel->SetEventHandler(this); - Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationOneSlice); - Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationAllSlice); + Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationOneSlice); + Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) &interfSegmentationPanelVTK::onSegmentationAllSlice); } @@ -76,9 +77,8 @@ interfSegmentationPanelVTK::~interfSegmentationPanelVTK() **/ void interfSegmentationPanelVTK::onSegmentationPressedITK(wxCommandEvent& event){ - if(segmentPanelITK == NULL){ - segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T(""))); - + if(segmentPanelITK == NULL) { + segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T(""))); wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1); segmentPanelITK->SetSizer(flexsizer, true); @@ -86,14 +86,13 @@ void interfSegmentationPanelVTK::onSegmentationPressedITK(wxCommandEvent& event wxPanel* panel = new wxPanel(this, -1);//contourevent->getSegmentationPanelITK(segmentPanelITK); - wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T(" Automatic ITK Segmentation ")), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T(""))); - flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE); + flexsizer->Add(stattext, wxALIGN_CENTER | wxALIGN_CENTRE); flexsizer->Add(panel, wxEXPAND); segmentPanelITK->Layout(); - } + } interfMainPanel::getInstance()->showPanel(segmentPanelITK); //contourevent->showAxis(true); //axisshown = true; @@ -101,27 +100,22 @@ void interfSegmentationPanelVTK::onSegmentationPressedITK(wxCommandEvent& event void interfSegmentationPanelVTK::onSegmentationOneSlice( wxCommandEvent& event ) { - - - int isovalue = _isovalue->GetValue(); - int sampling = _sampling->GetValue(); + int isovalue = _isovalue->GetValue(); + int sampling = _sampling->GetValue(); int method = methodRadiobox->GetSelection(); interfMainPanel::getInstance()->onSegmentationOneSlice(isovalue, sampling, method); } void interfSegmentationPanelVTK::onSegmentationAllSlice( wxCommandEvent& event ) { - int minZ=_mbarrange->GetStart(); int maxZ=_mbarrange->GetEnd(); - int isovalue = _isovalue->GetValue(); - int sampling = _sampling->GetValue(); - int method = methodRadiobox->GetSelection(); - + int isovalue = _isovalue->GetValue(); + int sampling = _sampling->GetValue(); + int method = methodRadiobox->GetSelection(); - interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method); - + interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method); } void interfSegmentationPanelVTK::setLabel(wxString tmpString){ @@ -134,39 +128,41 @@ void interfSegmentationPanelVTK::setLabel(wxString tmpString){ interfSegmentationPanelITK::interfSegmentationPanelITK(wxWindow * parent) : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) { - int sizeZ = interfMainPanel::getInstance()->GetImageDataSizeZ(); - //int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ(); double range[2]; - //_theViewPanel->getSceneManager()->GetImageDataRange(range); - interfMainPanel::getInstance()->GetImageDataRange(range); + interfMainPanel::getInstance()->getImageRange(range); + + int min = (int)floor (range[0]); + int max = (int)ceil (range[1]); //The labels - wxStaticText * distance = new wxStaticText(this, wxID_ANY, wxT("Initial Distance"), wxPoint(5, 5)); - wxStaticText * sigma = new wxStaticText(this, wxID_ANY, wxT("Sigma"),wxPoint(5, 30)); - wxStaticText * alfa = new wxStaticText(this, wxID_ANY, wxT("Sigmoid Alfa"), wxPoint(5, 55)); - wxStaticText * beta = new wxStaticText(this, wxID_ANY, wxT("Sigmoid Beta"), wxPoint(5, 80)); - wxStaticText * propagation = new wxStaticText(this, wxID_ANY, wxT("Propagation Scaling"),wxPoint(5, 105)); - wxStaticText * iterations = new wxStaticText(this, wxID_ANY, wxT("Iterations"), wxPoint(5, 130)); - wxStaticText * infStrength = new wxStaticText(this, wxID_ANY, wxT("Inflation Strength"), wxPoint(5, 155)); + //wxStaticText * distance = + new wxStaticText(this, wxID_ANY, wxT("Initial Distance"), wxPoint(5, 5)); + //wxStaticText * sigma = + new wxStaticText(this, wxID_ANY, wxT("Sigma"), wxPoint(5, 30)); + //wxStaticText * alfa = + new wxStaticText(this, wxID_ANY, wxT("Sigmoid Alfa"), wxPoint(5, 55)); + //wxStaticText * beta = + new wxStaticText(this, wxID_ANY, wxT("Sigmoid Beta"), wxPoint(5, 80)); + //wxStaticText * propagation = + new wxStaticText(this, wxID_ANY, wxT("Propagation Scaling"),wxPoint(5, 105)); + //wxStaticText * iterations = + new wxStaticText(this, wxID_ANY, wxT("Iterations"), wxPoint(5, 130)); + //wxStaticText * infStrength = + new wxStaticText(this, wxID_ANY, wxT("Inflation Strength"), wxPoint(5, 155)); //Text Controls - _distance= new wxTextCtrl(this, wxID_ANY, "5.0", wxPoint(98,5), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); - - _sigma= new wxTextCtrl(this, wxID_ANY, "1.2", wxPoint(98,30), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); - - _alfa= new wxTextCtrl(this, wxID_ANY, "-1.0", wxPoint(98,55), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); - - _beta= new wxTextCtrl(this, wxID_ANY, "5.0", wxPoint(98,80), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); - - _propagation= new wxTextCtrl(this, wxID_ANY, "6.0", wxPoint(98,105), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); - - _iterations= new wxTextCtrl(this, wxID_ANY, "800", wxPoint(98,130), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); - - _infStrength= new wxTextCtrl(this, wxID_ANY, "3.0", wxPoint(98,155), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); + _distance = new wxTextCtrl(this, wxID_ANY, wxT("5.0"), wxPoint(98,5), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); + _sigma = new wxTextCtrl(this, wxID_ANY, wxT("1.2"), wxPoint(98,30), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); + _alfa = new wxTextCtrl(this, wxID_ANY, wxT("-1.0"), wxPoint(98,55), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); + _beta = new wxTextCtrl(this, wxID_ANY, wxT("5.0"), wxPoint(98,80), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); + _propagation = new wxTextCtrl(this, wxID_ANY, wxT("6.0"), wxPoint(98,105), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); + _iterations = new wxTextCtrl(this, wxID_ANY, wxT("800"), wxPoint(98,130), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); + _infStrength = new wxTextCtrl(this, wxID_ANY, wxT("3.0"), wxPoint(98,155), wxSize(80, 20), 0, wxDefaultValidator, wxTextCtrlNameStr); //El boton - wxButton * bot= new wxButton(this, 6, wxT("One Slice"), wxPoint(98, 180), wxSize(70, 25), 0, wxDefaultValidator, "button"); + //wxButton * bot = + new wxButton(this, 6, wxT("One Slice"), wxPoint(98, 180), wxSize(70, 25), 0, wxDefaultValidator, wxT("button")); //Conexion del boton con su respectivo manejador Connect(6, wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction) &interfSegmentationPanelITK::onSegmentationOneSlice); @@ -204,5 +200,187 @@ void interfSegmentationPanelITK::onSegmentationAllSlice( wxCommandEvent& event ) interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method);*/ } + //------------------------------------------------------------------------------------------------------------ + +/** +** Begin of the mirror panel +**/ + +interfMirrorPanel::interfMirrorPanel(wxWindow* parent) +: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) +{ + _axisStatus = true; + + wxButton *axisShowBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Axis"), wxDefaultPosition, wxSize(200,35) ); + wxButton *mirrorGoBtn = new wxButton(this,wxID_ANY,_T("Mirror Contour"), wxDefaultPosition, wxSize(200,35) ); + _thickness = new wxSlider(this, -1, 4, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); + + Connect( axisShowBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onAxisShow ); + Connect( mirrorGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfMirrorPanel::onMirrorGo ); + + wxFlexGridSizer * sizer = new wxFlexGridSizer(1); + sizer -> Add( axisShowBtn, 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T("Thickness")) , 1, wxGROW ); + sizer -> Add( _thickness, 1, wxGROW ); + sizer -> Add( mirrorGoBtn, 1, wxGROW ); + + this->SetSizer( sizer ); + this->SetAutoLayout( true ); + this->Layout(); +} + +interfMirrorPanel::~interfMirrorPanel(){ +} + +void interfMirrorPanel::onAxisShow(wxCommandEvent& event) +{ + + if (!_axisStatus) + { + interfMainPanel::getInstance()->onMirrorAxisShow(); + _axisStatus=true; + } + else + { + interfMainPanel::getInstance()->onMirrorAxisHide(); + _axisStatus=false; + } +} + +void interfMirrorPanel::onMirrorGo(wxCommandEvent& event) +{ + if (_axisStatus) + { + interfMainPanel::getInstance()->onMirror(); + } +} + +void interfMirrorPanel::onChangeWidth(wxScrollEvent& event) +{ + int width = _thickness->GetValue(); + interfMainPanel::getInstance()->onMirrorChangeWidth(width); +} + + + +/** +** Begin of the threshold panel +**/ +interfThresholdPanel::interfThresholdPanel(wxWindow* parent) +: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) +{ + wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) ); + _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") ); + _interpolationCheckBox->SetValue(true); + _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); + _thresholdGo = false; + + double range[2]; + interfMainPanel::getInstance()->getImageRange(range); + + int min = (int)floor (range[0]); + int max = (int)ceil (range[1]); + + _mBarThreshold = new mBarRange(this,70,65); + _mBarThreshold->SetMin(0); + _mBarThreshold->SetStart(0); + _mBarThreshold-> SetOrientation( true ); + _mBarThreshold-> setActiveStateTo(true); + _mBarThreshold-> setVisibleLabels( true ); + _mBarThreshold-> setDeviceEndMargin(10); + _mBarThreshold-> setRepresentedValues( min , max ); + _mBarThreshold-> setDeviceBlitStart(10,10); + _mBarThreshold-> setIfWithActualDrawed( false ); + _mBarThreshold-> SetStart( min ); + _mBarThreshold-> SetEnd( max ); + + Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &interfThresholdPanel::onThresholdGo ); + Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfThresholdPanel::onThresholdInterpolation ); + + wxFlexGridSizer * sizer = new wxFlexGridSizer(1); + sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW ); + sizer -> Add( _mBarThreshold, 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW ); + sizer -> Add( _opacity, 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); + sizer -> Add( thresholdGoBtn, 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); + sizer -> Add( _interpolationCheckBox, 1, wxGROW ); + + this->SetSizer( sizer ); + this->SetAutoLayout( true ); + this->Layout(); +} + +interfThresholdPanel::~interfThresholdPanel(){ +} + + + +void interfThresholdPanel::onThresholdChange(wxCommandEvent& event) +{ + if (_thresholdGo) + { + interfMainPanel::getInstance()->onThresholdChange(); + + //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl; + } +} + +void interfThresholdPanel::onThresholdGo(wxCommandEvent& event) +{ + if (!_thresholdGo) + { + interfMainPanel::getInstance()->onThreshold(); + _thresholdGo=true; + } + else + { + interfMainPanel::getInstance()->onThresholdRemove( ); + _thresholdGo=false; + } +} + +void interfThresholdPanel::onThresholdStop() +{ + if (_thresholdGo) + { + interfMainPanel::getInstance()->onThresholdRemove( ); + _thresholdGo=false; + } +} + +void interfThresholdPanel::onThresholdInstantChange(double range[]) +{ + range[0] = _mBarThreshold->GetStart(); + range[1] = _mBarThreshold->GetEnd(); +} + +void interfThresholdPanel::onThresholdInterpolation(wxCommandEvent& event) +{ + interfMainPanel::getInstance()->onThresholdInterpolation(_interpolationCheckBox->GetValue()); +} + +void interfThresholdPanel::onChangeOpacity(wxScrollEvent& event) +{ + int opacity = _opacity->GetValue(); + interfMainPanel::getInstance()->onThresholdChangeOpacity(opacity); +} + + +BEGIN_EVENT_TABLE(interfMirrorPanel, wxPanel) + EVT_SCROLL(interfMirrorPanel :: onChangeWidth) +END_EVENT_TABLE() + +BEGIN_EVENT_TABLE(interfThresholdPanel, wxPanel) + EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, interfThresholdPanel :: onThresholdChange) + EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, interfThresholdPanel :: onThresholdChange) + EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, interfThresholdPanel :: onThresholdChange) + EVT_SCROLL(interfThresholdPanel :: onChangeOpacity) +END_EVENT_TABLE() + +