X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FThresholdImageView%2FColorLayerImageViewPanel.cxx;h=0d7fcfea3b23a0e9c7edcbeb55f2914b6d75bd35;hb=910aad6b5adef5024f896cc5a0daa79f1cda0661;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..0d7fcfe 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() { } @@ -21,7 +25,7 @@ wxDlgTransformByDimensionBySpacingByPixel::~wxDlgTransformByDimensionBySpacingBy void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *parent , wxString message,int &typeOfTransformation,bool &dlgWxOK) { - wxDialog* dial = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(590,190)); + wxDialog* dial = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(590,190)); wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL); wxBoxSizer *dialSizer = new wxBoxSizer(wxVERTICAL); @@ -51,8 +55,10 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren } } -//--------------------------------------------------------- +//--------------------------------------------------------- +//--------------------------------------------------------- +//--------------------------------------------------------- /** @@ -61,10 +67,12 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type) : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) { + printf("EED ColorLayerImageViewPanel::ColorLayerImageViewPanel start \n"); + _spcBase[0] = _spcBase[1] = _spcBase[2] = 0; _dimBase[0] = _dimBase[1] = _dimBase[2] = 0; - _colorLayerImageView = new ColorLayerImageView(); + _colorLayerImageView = new ColorLayerImageView(); _btn_ReadImage = new wxButton(this, wxID_ANY, _T("Read Image") ); _thresholdGo = true; _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") ); @@ -172,6 +180,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 +255,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() ); } //----------------------------------------------------------------------------