From d1de4d9e4121e4602daf11142cbc4b03c386d98a Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Thu, 10 Mar 2016 16:07:16 +0100 Subject: [PATCH] #2855 creaMaracasVisu Bug New Normal - ColorLayer box spacing size not identified --- .../bbcreaMaracasVisuColorLayerImageView.cxx | 2 + .../bbcreaMaracasVisuColorLayerImageView.h | 5 ++ .../src/bbmaracasvisuTransferFunctionView.cxx | 34 +++--------- bbtk/src/bbmaracasvisuViewerNV.cxx | 18 ++----- .../ColorLayerImageViewManager.cxx | 10 ++++ .../ColorLayerImageViewManager.h | 9 ++-- .../ColorLayerImageViewPanel.cxx | 54 +++---------------- .../ThresholdImageView/LayerImageBase.cxx | 23 +++----- .../ThresholdImageView/LayerImageBase.h | 16 +++--- 9 files changed, 55 insertions(+), 116 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx index 90d5de2..ba35577 100644 --- a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx @@ -74,6 +74,8 @@ void ColorLayerImageView::Process() clivp->SetImage( bbGetInputIn() ); + bbSetOutputNewImage( clivp->GetColorLayerImageViewManager()->GetImageChangeInformation(0) ); + // std::string msg; diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h index 7191b72..5fbe03e 100644 --- a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h @@ -57,6 +57,7 @@ class bbcreaMaracasVisu_EXPORT ColorLayerImageView BBTK_DECLARE_INPUT(lstRangeForColorBar,std::vector); BBTK_DECLARE_INPUT(PlainOrGradientColor,bool); BBTK_DECLARE_INPUT(FittingMode,int); + BBTK_DECLARE_OUTPUT(NewImage,vtkImageData*); BBTK_PROCESS(Process); void Process(); BBTK_CREATE_WIDGET(CreateWidget); @@ -90,6 +91,10 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ColorLayerImageView,bbtk::WxBlackBox); BBTK_INPUT(ColorLayerImageView,PlainOrGradientColor,"true=Plane false=Gradient (Default false)",bool,""); BBTK_INPUT(ColorLayerImageView,FittingMode,"Choose the fitting mode between the images, the transformation can be either by Dimension (1), by Spacing (2) or by Pixel (3). If you want to make the choice through a dialog box, choose (-1). Default is by Pixel (3).",int,""); + + BBTK_OUTPUT(ColorLayerImageView,NewImage,"Image with correct Spacing",vtkImageData*,""); + + BBTK_END_DESCRIBE_BLACK_BOX(ColorLayerImageView); //===== // Don't edit this file. This file is generated from xml description.. diff --git a/bbtk/src/bbmaracasvisuTransferFunctionView.cxx b/bbtk/src/bbmaracasvisuTransferFunctionView.cxx index 7d6765e..ca7fa29 100644 --- a/bbtk/src/bbmaracasvisuTransferFunctionView.cxx +++ b/bbtk/src/bbmaracasvisuTransferFunctionView.cxx @@ -37,12 +37,13 @@ void TransferFunctionView::Process() if(bbGetInputIn()!=NULL) { - if(_currentimg != bbGetInputIn()){ +// if(_currentimg != bbGetInputIn()) +// { _currentimg = bbGetInputIn(); //mwxwidget->initializeHistogram(_currentimg); mwxwidget->setImageData(_currentimg); //mwxwidget->Refresh(); - } +// } // onColorChange(); /* @@ -75,7 +76,7 @@ void TransferFunctionView::onColorChange() unsigned int i; for(i = 0; i < greylevel.size();i++){ _tfun->AddPoint(greylevel[i], value[i]); - std::cout<<"TransferFunctionView::Process()transfer function "<RemoveAllPoints(); _ctfun->SetScaleToLinear (); @@ -99,7 +100,7 @@ void TransferFunctionView::onColorChange() nc = ((greylevelcolors[i]-min)/dif)*w + c-w/2; // _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]); _ctfun->AddRGBPoint( nc , red[i],green[i], blue[i]); - std::cout<<"EED TransferFunctionView::Process()transfer color function <<"<AddRGBPoint( greylevelcolors[i] , red[i],green[i], blue[i]); @@ -116,29 +117,13 @@ void TransferFunctionView::onColorChange() } void TransferFunctionView::onSliderChange() - { - - //EED +{ onColorChange(); - bbSignalOutputModification(); - -printf("EED TransferFunctionView::onSliderChange --------------------- \n"); - // bbSetOutputWindowLevel(mwxwidget->GetWindowLevel()); // bbSetOutputColorLevel(mwxwidget->GetColorLevel()); - } -/* -//----------------------------------------------------- -void TransferFunctionView::onActive() -{ - bbSignalOutputModification(); - - printf("EED TransferFunctionView::onActive popopopopopopopop \n"); -} -*/ //----------------------------------------------------- void TransferFunctionView::CreateWidget(wxWindow* parent) @@ -199,13 +184,6 @@ void TransferFunctionView::bbUserSetDefaultValues() _box->onSliderChange(); } -/* - void HandlerTransferFunctionView::onActive(wxCommandEvent& event) - { - _box->onActive(); - } -*/ - } // EO namespace bbcreaMaracasVisu diff --git a/bbtk/src/bbmaracasvisuViewerNV.cxx b/bbtk/src/bbmaracasvisuViewerNV.cxx index 1b17eec..a191017 100644 --- a/bbtk/src/bbmaracasvisuViewerNV.cxx +++ b/bbtk/src/bbmaracasvisuViewerNV.cxx @@ -86,17 +86,8 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ViewerNV,bbtk::WxBlackBox); void ViewerNV::Process() { vtkImageData* img = bbGetInputIn(); -/* - double spc[3]; - img->GetSpacing(spc); - printf ("EED ViewerNV::Process A %f %f %f \n", spc[0], spc[1], spc[2] ); - img->SetSpacing( 1,1,1 ); - img->Update( ); - img->GetSpacing(spc); - img->PrintSelf(std::cout,(vtkIndent)2); - img->Print(std::cout); - printf ("EED ViewerNV::Process B %f %f %f \n", spc[0], spc[1], spc[2] ); -*/ + + std::vector type = bbGetInputnTypeView(); @@ -107,11 +98,10 @@ void ViewerNV::Process() }else if (img != _currentimg){ _mwxwidget->SetImage(img); } - _mwxwidget->RefreshView(); - _currenttype = type; - _currentimg = img; + _currenttype = type; + _currentimg = img; _point.clear(); _point.push_back((int)_mwxwidget->GetX()); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx index 1306f71..bc06bfd 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx @@ -384,6 +384,16 @@ void ColorLayerImageViewManager::SetImage( vtkImageData* img ) } // for } +//---------------------------------------------------------------------------- +vtkImageData* ColorLayerImageViewManager::GetImageChangeInformation(int id) +{ + if (_colorLayerImageViewLst[id]!=NULL) + { + return _colorLayerImageViewLst[id]->GetImage( ); + } // if + return NULL; +} + //---------------------------------------------------------------------------- void ColorLayerImageViewManager::GetDimensionBase(int id,int *dim) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h index c898121..06194fe 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h @@ -68,11 +68,12 @@ class ColorLayerImageViewManager void SetSliceFixDynamic( bool fixdin ); void onThresholdChangeOpacity( int opacity ); void SetImage( vtkImageData* img ); + vtkImageData* GetImageChangeInformation(int id); - void GetDimensionBase (int id,int *dim); - void GetSpcBase (int id,double *spc); - void GetDimensionOriginalLayer (int id,int *dim); - void GetSpcOriginalLayer (int id,double *spc); + void GetDimensionBase (int id,int *dim); + void GetSpcBase (int id,double *spc); + void GetDimensionOriginalLayer (int id,int *dim); + void GetSpcOriginalLayer (int id,double *spc); void SetNewSpacingLayer(double *spc); private: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx index e6b81ed..5f08d62 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx @@ -278,15 +278,6 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) GetColorLayerImageViewManager()->GetSpcBase(0,spcBase); GetColorLayerImageViewManager()->GetDimensionBase(0,dimensionBase); -/* - int dim[3]; - int ext[6]; - img->GetWholeExtent(ext); - 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 , dimensionOriginalLayer[0] ); @@ -294,31 +285,6 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) _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" ); - - 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]) || @@ -349,16 +315,13 @@ printf(" I need the caracteristics of the base image\n" ); //EO CM if (typeOfTransformation==1) // Adapt spacing { -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) // keep spacing of the Layer Image { -printf("EED ColorLayerImageViewPanel::SetImag 2 \n"); newSpc[0] = spcOriginalLayer[0]; newSpc[1] = spcOriginalLayer[1]; newSpc[2] = spcOriginalLayer[2]; @@ -366,22 +329,19 @@ printf("EED ColorLayerImageViewPanel::SetImag 2 \n"); if (typeOfTransformation==3) // Use the spacing of the Base Image { -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; } - - GetColorLayerImageViewManager()->SetNewSpacingLayer(newSpc); + } else { + newSpc[0] = spcOriginalLayer[0]; + newSpc[1] = spcOriginalLayer[1]; + newSpc[2] = spcOriginalLayer[2]; + } // spc !_spcBase dim!__dimBase + + GetColorLayerImageViewManager()->SetNewSpacingLayer(newSpc); -// img->SetSpacing(newSpc); -// img->Update(); -// img->Modified(); - } // spc !_spcBase dim!__dimBase } // _firsttime_mode if (_active==true) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx index a86251c..8f1fc5e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx @@ -152,7 +152,14 @@ int LayerImageBase::GetZ() // virtual vtkImageData* LayerImageBase::GetImage() { // return _image; - return _imageChangeInformation->GetOutput(); + vtkImageData *result; + if (_image==NULL) + { + result = NULL; + } else { + result = _imageChangeInformation->GetOutput(); + } + return result; } //---------------------------------------------------------------------------- @@ -402,26 +409,16 @@ void LayerImageBase::onThreshold() { if ((_image!=NULL) && (_baseView!=NULL)) { -double spc[3]; -GetImage()-> GetSpacing(spc); -printf("EED LayerImageBase::onThreshold A img-spc %f %f %f\n", spc[0],spc[1],spc[2]); double x=GetX(); double y=GetY(); double z=GetZ(); -// x = x*spc[0]; -// y = y*spc[1]; -// z = z*spc[2]; - - x = x*_spcBase[0]; y = y*_spcBase[1]; z = z*_spcBase[2]; - CleanXYZ(x,y,z); - vtkCamera *camera = _baseView->GetRenderer()->GetActiveCamera(); int directionViewer=0; if (camera->GetParallelProjection()==1) @@ -430,7 +427,6 @@ printf("EED LayerImageBase::onThreshold A img-spc %f %f %f\n", spc[0],spc[1] directionViewer = wxvtk2dbasevie->GetDirection(); } // ParallelProjection - if (!GetActorPresent()) { if (_thresholdTable==NULL) @@ -516,9 +512,6 @@ printf("EED LayerImageBase::onThreshold A img-spc %f %f %f\n", spc[0],spc[1] // _scalarbarActor->SetTextPad(4); ?? -GetImage()-> GetSpacing(spc); -printf("EED LayerImageBase::onThreshold B img-spc %f %f %f\n", spc[0],spc[1],spc[2]); - } // _image } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h index b6ad1e1..0a9f0c0 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h @@ -85,13 +85,14 @@ class LayerImageBase public: LayerImageBase(); virtual ~LayerImageBase(); - void SetX(int x); - void SetY(int y); - void SetZ(int z); - void SetImage(vtkImageData* image); - void SetRangeForColorBar(std::vector &range); - void GetRangeForColorBar(double &minRange, double &maxRange); - void SetwxVtkBaseView(wxVtkBaseView *baseview); + void SetX(int x); + void SetY(int y); + void SetZ(int z); + void SetImage(vtkImageData* image); + vtkImageData* GetImage(); + void SetRangeForColorBar(std::vector &range); + void GetRangeForColorBar(double &minRange, double &maxRange); + void SetwxVtkBaseView(wxVtkBaseView *baseview); void onThreshold(); void onThresholdChange(); @@ -148,7 +149,6 @@ class LayerImageBase protected: vtkLookupTable *GetThresholdTable(); - vtkImageData *GetImage(); double _range[2]; std::vector _rangeForColorBar; }; -- 2.45.0