X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FThresholdImageView%2FColorLayerImageViewPanel.cxx;h=e6b81ed42d980f173bfb7f15aaaf9c7daf8cd4ba;hb=0780b53e8b105636030b2c9fcbbc423d8ed48c30;hp=af7317cc5877fadcfdfe33a2bbf51de04b092ad7;hpb=b73d56cf9e0aeee77ac87df7b5e401fc0ba87504;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 af7317c..e6b81ed 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx @@ -56,15 +56,22 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType( int &typeOfTransformation, bool &dlgWxOK) { - wxDialog* dial = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(500,550),wxRESIZE_BORDER); - wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL); + wxDialog* dial = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(500,525),wxRESIZE_BORDER); + wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK); 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(250,90), 3 , lstOptOperation, 3, wxRA_SPECIFY_COLS); +// lstOptOperation[0]=_T("By Dimension"); +// lstOptOperation[1]=_T("By Spacing"); +// lstOptOperation[2]=_T("By Pixel"); + + lstOptOperation[0]=_T("Adapt spacing of the Layer Image"); + lstOptOperation[1]=_T("Keep the spacing of the Layer Image"); + lstOptOperation[2]=_T("Use the same spacing of the Base Image"); + + + + wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of spacing transformation"), wxDefaultPosition, wxSize(250,160), 3 , lstOptOperation, 1, wxRA_SPECIFY_COLS); wxString str; wxString strBaseSpc(str); @@ -72,12 +79,11 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType( wxString strBaseDim; wxString strLayerDim; - strBaseSpc.Printf(wxT("Base spacing: %f %f %f"), baseSpc[0],baseSpc[1],baseSpc[2] ); - strLayerSpc.Printf(wxT("Layer spacing: %f %f %f"), layerSpc[0],layerSpc[1],layerSpc[2] ); - strBaseDim.Printf(wxT("Base dimension: %d %d %d"), baseDim[0],baseDim[1],baseDim[2] ); - strLayerDim.Printf(wxT("Layer dimension: %d %d %d"), layerDim[0],layerDim[1],layerDim[2] ); + strBaseSpc.Printf(wxT("Base spacing: %f %f %f") , baseSpc[0],baseSpc[1],baseSpc[2] ); + strLayerSpc.Printf(wxT("Layer spacing: %f %f %f") , layerSpc[0],layerSpc[1],layerSpc[2] ); + strBaseDim.Printf(wxT("Base dimension: %d %d %d") , baseDim[0],baseDim[1],baseDim[2] ); + strLayerDim.Printf(wxT("Layer dimension: %d %d %d") , layerDim[0],layerDim[1],layerDim[2] ); - dialSizer->Add( new wxStaticText(dial,-1,message ) , 0, wxGROW ); dialSizer->Add( new wxStaticText(dial,-1,_T(" ") ) , 0, wxGROW ); dialSizer->Add( new wxStaticText(dial,-1, strBaseSpc ) , 0, wxGROW ); dialSizer->Add( new wxStaticText(dial,-1, strLayerSpc ) , 0, wxGROW ); @@ -97,9 +103,12 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType( typeOfTransformation = -1; dlgWxOK = false; +printf("EED wxDlgTransformByDimensionBySpacingByPixel::GetTransformType AAA\n"); + if (dial->GetReturnCode() == wxID_OK) { typeOfTransformation = radioOpts->GetSelection() + 1; +printf("EED wxDlgTransformByDimensionBySpacingByPixel::GetTransformType BBB %d\n",typeOfTransformation); dlgWxOK = true; } } @@ -124,12 +133,12 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in _spcBase[0] = _spcBase[1] = _spcBase[2] = 0; _dimBase[0] = _dimBase[1] = _dimBase[2] = 0; - _cb_ShowHide = NULL; - _sl_SliceImageX = NULL; - _sl_SliceImageY = NULL; - _sl_SliceImageZ = NULL; - _histogram = NULL; - _histogramMinMaxLevel = NULL; + _cb_ShowHide = NULL; + _sl_SliceImageX = NULL; + _sl_SliceImageY = NULL; + _sl_SliceImageZ = NULL; + _histogram = NULL; + _histogramMinMaxLevel = NULL; wxFlexGridSizer * sizer = NULL; _colorLayerImageViewManager = new ColorLayerImageViewManager(); @@ -243,77 +252,80 @@ ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewMana } -//---------------------------------------------------------------------------- -// 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; -} - -//---------------------------------------------------------------------------- -// This is the Original spacing of the background image -void ColorLayerImageViewPanel::SetOriginalSpacing(double spc[3]) -{ - _spcOrg[0] = spc[0]; - _spcOrg[1] = spc[1]; - _spcOrg[2] = spc[2]; -} - -//---------------------------------------------------------------------------- -// This is the size in pixels of the background image -void ColorLayerImageViewPanel::SetBaseDimension(int dim[3]) -{ - _dimBase[0] = dim[0]; - _dimBase[1] = dim[1]; - _dimBase[2] = dim[2]; -} - //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::SetImage(vtkImageData *img) { if (img!=NULL) { + if (_histogramMinMaxLevel!=NULL) { _histogramMinMaxLevel->Configure( img ); } _colorLayerImageViewManager->SetImage( img ); - double spc[3]; - img->GetSpacing(spc); + double spcOriginalLayer[3]; + int dimensionOriginalLayer[3]; + + double spcBase[3]; + int dimensionBase[3]; + + double newSpc[3]; + GetColorLayerImageViewManager()->GetSpcOriginalLayer(0,spcOriginalLayer); + GetColorLayerImageViewManager()->GetDimensionOriginalLayer(0,dimensionOriginalLayer); + + GetColorLayerImageViewManager()->GetSpcBase(0,spcBase); + GetColorLayerImageViewManager()->GetDimensionBase(0,dimensionBase); + +/* 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]; - + dim[0] = ext[1]-ext[0]+1; + dim[1] = ext[3]-ext[2]+1; + dim[2] = ext[5]-ext[4]+1; +*/ if (_sl_SliceImageX!=NULL) { - _sl_SliceImageX->SetRange( 0 , dim[0] ); - _sl_SliceImageY->SetRange( 0 , dim[1] ); - _sl_SliceImageZ->SetRange( 0 , dim[2] ); + _sl_SliceImageX->SetRange( 0 , dimensionOriginalLayer[0] ); + _sl_SliceImageY->SetRange( 0 , dimensionOriginalLayer[1] ); + _sl_SliceImageZ->SetRange( 0 , dimensionOriginalLayer[2] ); } -//printf("EED ColorLayerImageViewPanel::SetImage UUPPSS----------------------\n" ); -//printf("EED ColorLayerImageViewPanel::SetImage UUPPSS----------------------\n" ); -//printf("EED ColorLayerImageViewPanel::SetImage UUPPSS----------------------\n" ); -//printf("EED ColorLayerImageViewPanel::SetImage UUPPSS----------------------\n" ); -//printf(" Here I have to analyse the spacing and size image to calculate new spacingvv\n" ); -//printf(" I need the caracteristics of the base image\n" ); -// GetColorLayerImageViewManager()->GetwxVtkBaseView(0); +/* +printf("EED ColorLayerImageViewPanel::SetImage UUPPSS----------------------\n" ); +printf("EED ColorLayerImageViewPanel::SetImage UUPPSS----------------------\n" ); +printf("EED ColorLayerImageViewPanel::SetImage UUPPSS----------------------\n" ); +printf("EED ColorLayerImageViewPanel::SetImage UUPPSS----------------------\n" ); +printf(" Here I have to analyse the spacing and size image to calculate new spacingvv\n" ); +printf(" I need the caracteristics of the base image\n" ); - - 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]) + wxVtkBaseView *wxvtkbaseview = GetColorLayerImageViewManager()->GetwxVtkBaseView(0); + if (wxvtkbaseview!=NULL) + { + vtkImageData *imagebase = wxvtkbaseview->GetVtkBaseData()->GetImageData(); + if (imagebase!=NULL) + { + imagebase->GetSpacing(_spcBase); + int ext[6]; + imagebase->GetWholeExtent(ext); + _dimBase[0]=ext[1]-ext[0]+1; + _dimBase[1]=ext[3]-ext[2]+1; + _dimBase[2]=ext[5]-ext[4]+1; + } // if imagebase + } // if wxvtkbaseview + +*/ + + + if ( (spcOriginalLayer[0]!=spcBase[0]) || + (spcOriginalLayer[1]!=spcBase[1]) || + (spcOriginalLayer[2]!=spcBase[2]) || + (dimensionOriginalLayer[0]!=dimensionBase[0]) || + (dimensionOriginalLayer[1]!=dimensionBase[1]) || + (dimensionOriginalLayer[2]!=dimensionBase[2]) ) { // CM @@ -322,9 +334,9 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) if (_fitting_mode == -1) { bool transformOkDlg; - wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? "); + wxString msg = _T("The image resolution of both images are not compatible. How do you want to tranform it? "); wxDlgTransformByDimensionBySpacingByPixel dlg; - dlg.GetTransformType(this,_spcBase,spc,_dimBase,dim,msg,typeOfTransformation,transformOkDlg); + dlg.GetTransformType(this , spcBase , spcOriginalLayer , dimensionBase ,dimensionOriginalLayer ,msg,typeOfTransformation,transformOkDlg); // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value. if (transformOkDlg == false) { @@ -335,29 +347,40 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) } // _fitting_mode -1 //EO CM - if (typeOfTransformation==1) // make dimensions equals + if (typeOfTransformation==1) // Adapt spacing { - 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; +printf("EED ColorLayerImageViewPanel::SetImag 1 \n"); + newSpc[0] = spcBase[0] * dimensionBase[0] / dimensionOriginalLayer[0]; + newSpc[1] = spcBase[1] * dimensionBase[1] / dimensionOriginalLayer[1]; + newSpc[2] = spcBase[2] * dimensionBase[2] / dimensionOriginalLayer[2]; +printf("EED ColorLayerImageViewPanel::SetImag 1 newSpc=%f %f %f \n", newSpc[0],newSpc[1],newSpc[2] ); } - if (typeOfTransformation==2) // make spacing equals + if (typeOfTransformation==2) // keep spacing of the Layer Image { - spc[0] = ( _spcBase[0]/spc[0] ) * _spcOrg[0]; - spc[1] = ( _spcBase[1]/spc[1] ) * _spcOrg[1]; - spc[2] = ( _spcBase[2]/spc[2] ) * _spcOrg[2]; +printf("EED ColorLayerImageViewPanel::SetImag 2 \n"); + newSpc[0] = spcOriginalLayer[0]; + newSpc[1] = spcOriginalLayer[1]; + newSpc[2] = spcOriginalLayer[2]; } - if (typeOfTransformation==3) // make spacing = 1 + if (typeOfTransformation==3) // Use the spacing of the Base Image { - spc[0] = 1; - spc[1] = 1; - spc[2] = 1; +printf("EED ColorLayerImageViewPanel::SetImag 3 \n"); + newSpc[0] = spcBase[0]; + newSpc[1] = spcBase[1]; + newSpc[2] = spcBase[2]; +// spc[0] = 1; +// spc[1] = 1; +// spc[2] = 1; } - img->SetSpacing(spc); + + GetColorLayerImageViewManager()->SetNewSpacingLayer(newSpc); + +// img->SetSpacing(newSpc); +// img->Update(); +// img->Modified(); } // spc !_spcBase dim!__dimBase } // _firsttime_mode