X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FThresholdImageView%2FColorLayerImageViewPanel.cxx;h=8b8007143fd22d271c0368193fbb60861f1d17f0;hb=825f47d7d281a359e9fec03de88e7db58e9e49ff;hp=d574e307ba27d5d20f1375721eaeabac3ad853c6;hpb=badc6cea49d018dec82191a977fc082299a1da35;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx index d574e30..8b80071 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx @@ -1,8 +1,8 @@ - + /** - * \file - * \brief ClassThresholdImageViewPanel . + * \file + * \brief ClassThresholdImageViewPanel . */ @@ -10,6 +10,10 @@ #include "OpenImageDialog.h" +//--------------------------------------------------------- +//--------------------------------------------------------- +//--------------------------------------------------------- + wxDlgTransformByDimensionBySpacingByPixel::wxDlgTransformByDimensionBySpacingByPixel() { } @@ -24,26 +28,26 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren wxDialog* dial = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(590,190)); wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL); wxBoxSizer *dialSizer = new wxBoxSizer(wxVERTICAL); - + wxString lstOptOperation[3]; lstOptOperation[0]=_T("By Dimension"); lstOptOperation[1]=_T("By Spacing"); lstOptOperation[2]=_T("By Pixel"); - wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,45), 3 , lstOptOperation, 3, wxRA_SPECIFY_COLS); - + wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,45), 3 , lstOptOperation, 3, wxRA_SPECIFY_COLS); + dialSizer->Add( new wxStaticText(dial,-1,message) , 0, wxGROW ); - // dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?")) , 0, wxGROW ); - dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW ); + // dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?")) , 0, wxGROW ); + dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW ); dialSizer->Add(radioOpts,0,wxGROW); - dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW ); + dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW ); dialSizer->Add(buttonsSizer,0,wxGROW); dial->SetSizer(dialSizer, true); dial->Layout(); dial->ShowModal(); - + typeOfTransformation = -1; dlgWxOK = false; - + if (dial->GetReturnCode() == wxID_OK) { typeOfTransformation = radioOpts->GetSelection(); @@ -51,8 +55,10 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren } } -//--------------------------------------------------------- +//--------------------------------------------------------- +//--------------------------------------------------------- +//--------------------------------------------------------- /** @@ -77,20 +83,20 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in _sl_SliceImage->Enable(false); _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") ); - _interpolationCheckBox->SetValue(true); + _interpolationCheckBox->SetValue(true); _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); - + if (type==0) { } - + if (type==1) { } - - - Connect( _btn_ReadImage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onReadImage ); - Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow ); + + + Connect( _btn_ReadImage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onReadImage ); + Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow ); Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation ); Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity ); Connect( _cb_SliceFixDinamic->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceFixDinamic ); @@ -137,13 +143,20 @@ void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* color _colorLayerImageView = colorLayerImageView; } +//---------------------------------------------------------------------------- +ColorLayerImageView* ColorLayerImageViewPanel::GetColorLayerImageView() +{ + return _colorLayerImageView; +} + + // This is the new spacing of the background image (1,1,1) void ColorLayerImageViewPanel::SetBaseSpacing(double spc[3]) { _spcBase[0] = spc[0]; _spcBase[1] = spc[1]; _spcBase[2] = spc[2]; - + _spcBase[0] = 1; _spcBase[1] = 1; _spcBase[2] = 1; @@ -165,142 +178,174 @@ void ColorLayerImageViewPanel::SetBaseDimension(int dim[3]) _dimBase[2] = dim[2]; } +//---------------------------------------------------------------------------- +void ColorLayerImageViewPanel::SetImage(vtkImageData *img) +{ + if (img!=NULL) + { + _colorLayerImageView->SetImage( img ); + + double spc[3]; + img->GetSpacing(spc); + + int dim[3]; + int ext[6]; + img->GetWholeExtent(ext); + dim[0] = ext[1]-ext[0]; + dim[1] = ext[3]-ext[2]; + dim[2] = ext[5]-ext[4]; + _sl_SliceImage->SetRange( 0 , dim[2] ); + + if ( (spc[0]!=_spcBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2]) || + (dim[0]!=_dimBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2]) + ) + { + + bool transformOkDlg; + int typeOfTransformation; + wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? "); + wxDlgTransformByDimensionBySpacingByPixel dlg; + dlg.GetTransformType(this,msg,typeOfTransformation,transformOkDlg); + + printf("EED ColorLayerImageViewPanel::onReadImage call dialog spc size,dim...???\n"); + + if (typeOfTransformation==0) // make dimensions equals + { + printf("EED ColorLayerImageViewPanel::onReadImage ...WARNNING.... dif size image spc*dim ofnew image ...???\n"); + spc[0]=_spcBase[0]*_dimBase[0]/dim[0]; + spc[1]=_spcBase[1]*_dimBase[1]/dim[1]; + spc[2] = 1; + } + + if (typeOfTransformation==1) // make spacing equals + { + spc[0] = ( _spcBase[0]/spc[0] ) * _spcOrg[0]; + spc[1] = ( _spcBase[1]/spc[1] ) * _spcOrg[1]; + spc[2] = ( _spcBase[2]/spc[2] ) * _spcOrg[2]; + } + + if (typeOfTransformation==2) // make spacing = 1 + { + spc[0] = 1; + spc[1] = 1; + spc[2] = 1; + } + + img->SetSpacing(spc); + } // spc !_spcBase dim!__dimBase + + if (_colorLayerImageView!=NULL) + { + _colorLayerImageView->onThreshold(); + _colorLayerImageView->Refresh(); + } + + + } +} + //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event) { // EED ??? -// creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB"); -// w.ShowModal(); +// creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB"); +// w.ShowModal(); printf("EED ColorLayerImageViewPanel::onReadImage ....WARNING... Read dlg. all images creaImageIO ... ???\n"); creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog(); - _colorLayerImageView->SetImage( diag.getImageData() ); - - double spc[3]; - diag.getImageData()->GetSpacing(spc); - - int dim[3]; - int ext[6]; - diag.getImageData()->GetWholeExtent(ext); - dim[0] = ext[1]-ext[0]; - dim[1] = ext[3]-ext[2]; - dim[2] = ext[5]-ext[4]; - _sl_SliceImage->SetRange( 0 , dim[2] ); - - if ( (spc[0]!=_spcBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2]) || - (dim[0]!=_dimBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2]) - ) - { - - bool transformOkDlg; - int typeOfTransformation; - wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? "); - wxDlgTransformByDimensionBySpacingByPixel dlg; - dlg.GetTransformType(this,msg,typeOfTransformation,transformOkDlg); - -printf("EED ColorLayerImageViewPanel::onReadImage call dialog spc size,dim...???\n"); - - if (typeOfTransformation==0) // make dimensions equals - { - printf("EED ColorLayerImageViewPanel::onReadImage ...WARNNING.... dif size image spc*dim ofnew image ...???\n"); - spc[0]=_spcBase[0]*_dimBase[0]/dim[0]; - spc[1]=_spcBase[1]*_dimBase[1]/dim[1]; - spc[2] = 1; - } - - if (typeOfTransformation==1) // make spacing equals - { - spc[0] = ( _spcBase[0]/spc[0] ) * _spcOrg[0]; - spc[1] = ( _spcBase[1]/spc[1] ) * _spcOrg[1]; - spc[2] = ( _spcBase[2]/spc[2] ) * _spcOrg[2]; - } - - if (typeOfTransformation==2) // make spacing = 1 - { - spc[0] = 1; - spc[1] = 1; - spc[2] = 1; - } - - diag.getImageData()->SetSpacing(spc); - } // spc !_spcBase dim!__dimBase - - _colorLayerImageView->onThreshold(); - _colorLayerImageView->GetwxVtkBaseView()->Refresh(); + SetImage( diag.getImageData() ); } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event) { - if (_thresholdGo) + if (_colorLayerImageView!=NULL) { - _colorLayerImageView->onThresholdChange(); - _colorLayerImageView->GetwxVtkBaseView()->Refresh(); - //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl; - } + if (_thresholdGo) + { + _colorLayerImageView->onThresholdChange(); + _colorLayerImageView->Refresh(); + //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl; + } // _threshold + }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event) { - _thresholdGo = _cb_ShowHide->GetValue(); - if (_thresholdGo) + if (_colorLayerImageView!=NULL) { - _colorLayerImageView->onThreshold(); - } - else - { - _colorLayerImageView->onThresholdRemove( ); - } - _colorLayerImageView->GetwxVtkBaseView()->Refresh(); + _thresholdGo = _cb_ShowHide->GetValue(); + if (_thresholdGo) + { + _colorLayerImageView->onThreshold(); + }else{ + _colorLayerImageView->onThresholdRemove( ); + } + _colorLayerImageView->Refresh(); + }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdStop() { - if (_thresholdGo) - { - _colorLayerImageView->onThresholdRemove( ); - _thresholdGo=false; - } + if (_colorLayerImageView!=NULL) + { + if (_thresholdGo) + { + _colorLayerImageView->onThresholdRemove( ); + _thresholdGo=false; + } + }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event) { - _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue()); - _colorLayerImageView->GetwxVtkBaseView()->Refresh(); - + if (_colorLayerImageView!=NULL) + { + _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue()); + _colorLayerImageView->Refresh(); + }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event) { - bool fixdin = _cb_SliceFixDinamic->GetValue(); - _colorLayerImageView->SetSliceFixDinamic( fixdin ); - if (fixdin==false) + if (_colorLayerImageView!=NULL) { - _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() ); - } - _sl_SliceImage->Enable(!fixdin); - _colorLayerImageView->onThreshold(); - _colorLayerImageView->GetwxVtkBaseView()->Refresh(); + bool fixdin = _cb_SliceFixDinamic->GetValue(); + _colorLayerImageView->SetSliceFixDinamic( fixdin ); + if (fixdin==false) + { + _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() ); + } + _sl_SliceImage->Enable(!fixdin); + _colorLayerImageView->onThreshold(); + _colorLayerImageView->Refresh(); + }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event) { - _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() ); - _colorLayerImageView->onThreshold(); - _colorLayerImageView->GetwxVtkBaseView()->Refresh(); + if (_colorLayerImageView!=NULL) + { + _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() ); + _colorLayerImageView->onThreshold(); + _colorLayerImageView->Refresh(); + }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event) { - int opacity = _opacity->GetValue(); - _colorLayerImageView->onThresholdChangeOpacity(opacity); - _colorLayerImageView->GetwxVtkBaseView()->Refresh(); + if (_colorLayerImageView!=NULL) + { + int opacity = _opacity->GetValue(); + _colorLayerImageView->onThresholdChangeOpacity(opacity); + _colorLayerImageView->Refresh(); + }//_colorLayerImageView }