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=d725af03e25b41e03b212c26068be2c04dacd270;hp=0d6884263cc68598205d6c8d8b58779c20721216;hpb=54bb3fba5f59ca71cb82d87043e21354dd85e7aa;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 0d68842..8b80071 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx @@ -10,6 +10,10 @@ #include "OpenImageDialog.h" +//--------------------------------------------------------- +//--------------------------------------------------------- +//--------------------------------------------------------- + wxDlgTransformByDimensionBySpacingByPixel::wxDlgTransformByDimensionBySpacingByPixel() { } @@ -51,8 +55,10 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren } } -//--------------------------------------------------------- +//--------------------------------------------------------- +//--------------------------------------------------------- +//--------------------------------------------------------- /** @@ -172,6 +178,72 @@ 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) { @@ -181,62 +253,7 @@ void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event) 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 - - if (_colorLayerImageView!=NULL) - { - _colorLayerImageView->onThreshold(); - _colorLayerImageView->Refresh(); - } + SetImage( diag.getImageData() ); } //----------------------------------------------------------------------------