X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FThresholdImageView%2FLayerImageBase.cxx;h=c295169ae16fc898a8eb0fab5bb0708ab31cde3e;hb=f9901e756bb82bd333310b47607875331616bb29;hp=d7e3e7284cfb40319a7f7f6176bcbccf876ae29a;hpb=2154a89395b7e9869b0e3dea859425d52a5aa9bd;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx index d7e3e72..c295169 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx @@ -32,7 +32,7 @@ #include "wxMPRBaseData.h" #include "wxVtk2DBaseView.h" -#include "wxVTKRenderWindowInteractor.h" +#include "creawxVTKRenderWindowInteractor.h" #include "vtkTextProperty.h" @@ -67,7 +67,7 @@ class ColorLayerObserver : public vtkCommand{ _layerimagebase->SetX( vtkmprbasedata->GetX() ); _layerimagebase->SetY( vtkmprbasedata->GetY() ); _layerimagebase->SetZ( vtkmprbasedata->GetZ() ); - _layerimagebase->onThresholdChange(); + _layerimagebase->onThresholdChange(); } // if basedata } // if wxvtkbaseview @@ -94,9 +94,10 @@ private: LayerImageBase::LayerImageBase() { _actorPresent = false; - _X = 0; - _Y = 0; - _Z = 0; + _X = -1; + _Y = -1; + _Z = -1; + _opacity = 1; _thresholdTable = NULL; _thresholdMapper = NULL; _scalarbarActor = NULL; @@ -191,7 +192,15 @@ void LayerImageBase::SetImage(vtkImageData* image) spcBase[5]=0; _image = image; + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + _image->Update(); _image->GetWholeExtent(ext); +#else + _image->GetExtent(ext); +#endif + dimensionOriginalLayer[0] = ext[1]-ext[0]+1; dimensionOriginalLayer[1] = ext[3]-ext[2]+1; dimensionOriginalLayer[2] = ext[5]-ext[4]+1; @@ -204,23 +213,40 @@ void LayerImageBase::SetImage(vtkImageData* image) vtkImageData *imagebase = GetwxVtkBaseView()->GetVtkBaseData()->GetImageData(); if (imagebase!=NULL) { + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 imagebase->GetWholeExtent(ext); +#else + imagebase->GetExtent(ext); +#endif + dimBase[0]=ext[1]-ext[0]+1; dimBase[1]=ext[3]-ext[2]+1; dimBase[2]=ext[5]-ext[4]+1; SetDimensionBase(dimBase); imagebase->GetSpacing(spcBase); SetSpcBase(spcBase); - SetX( dimBase[0]*spcBase[0]/2 ); - SetY( dimBase[1]*spcBase[1]/2 ); - SetZ( dimBase[2]*spcBase[2]/2 ); + + if ((_X<0) || (_X>dimBase[0])) { SetX( dimBase[0]/2 ); } + if ((_Y<0) || (_Y>dimBase[1])) { SetY( dimBase[1]/2 ); } + if ((_Z<0) || (_Z>dimBase[2])) { SetZ( dimBase[2]/2 ); } + + } // if imagebase } // if wxvtkbaseview - _image->Update(); _image->GetScalarRange( _range ); - _thresholdTable = vtkLookupTable::New(); +// _thresholdTable = vtkLookupTable::New(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _imageChangeInformation->SetInput(_image); +#else + _imageChangeInformation->SetInputData(_image); + _imageChangeInformation->Update(); +#endif + } //------------------------------------------------------------------------------ @@ -234,9 +260,9 @@ void LayerImageBase::SetSpcOriginalLayer(double spc[3]) //------------------------------------------------------------------------------ void LayerImageBase::SetNewSpacingLayer(double spc[3]) { - _newSpcLayer[0]=spc[0]; - _newSpcLayer[1]=spc[1]; - _newSpcLayer[2]=spc[2]; + _newSpcLayer[0] = spc[0]; + _newSpcLayer[1] = spc[1]; + _newSpcLayer[2] = spc[2]; _imageChangeInformation->SetOutputSpacing( _newSpcLayer ); } @@ -301,6 +327,12 @@ void LayerImageBase::GetDimensionBase(int *dim) } +//------------------------------------------------------------------------------ +void LayerImageBase::SetColorBarPosition(std::vector &colorbarposition) +{ + _colorBarPosition=colorbarposition; +} + //------------------------------------------------------------------------------ void LayerImageBase::SetRangeForColorBar(std::vector &range) { @@ -389,24 +421,6 @@ void LayerImageBase::CleanXYZ(double &x, double &y, double &z) z = maxSize; } -/* - - if ( x > (ext[1]-ext[0]) ) - { - z=ext[1]-ext[0]; - } - - if ( y > (ext[3]-ext[2]) ) - { - z=ext[3]-ext[2]; - } - - if ( z > (ext[5]-ext[4]) ) - { - z=ext[5]-ext[4]; - } -*/ - } //---------------------------------------------------------------------------- @@ -432,6 +446,7 @@ void LayerImageBase::onThreshold() directionViewer = wxvtk2dbasevie->GetDirection(); } // ParallelProjection + if (!GetActorPresent()) { if (_thresholdTable==NULL) @@ -449,8 +464,18 @@ void LayerImageBase::onThreshold() { _thresholdActor = vtkImageActor::New( ); _scalarbarActor = vtkScalarBarActor::New(); - _thresholdActor->SetOpacity( 0.6 ); + if (_colorBarPosition.size()==2) + { + _scalarbarActor->SetDisplayPosition(_colorBarPosition[0],_colorBarPosition[1]); + } else { + _scalarbarActor->SetDisplayPosition(0,0); + } + _scalarbarActor->SetHeight(0.4); //default 0.8 + _scalarbarActor->SetWidth(0.08); //default 0.17 + + _thresholdActor->SetOpacity( 1 ); _thresholdActor->InterpolateOn( ); + if (directionViewer==0) { _thresholdActor->SetPosition( 900-1,0,0 ); @@ -472,7 +497,14 @@ void LayerImageBase::onThreshold() } // !GetActorPresent() ConfigLookupTable(); // virtual method + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _imageReslicer->SetInput( GetImage() ); +#else + _imageReslicer->SetInputData( GetImage() ); +#endif + _imageReslicer->SetInformationInput( GetImage() ); if (directionViewer==0) @@ -498,26 +530,43 @@ void LayerImageBase::onThreshold() _imageReslicer->SetInterpolationModeToNearestNeighbor(); _imageReslicer->Modified(); - +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + // .. +#else + _imageReslicer->Update(); +#endif vtkImageData *img = _imageReslicer->GetOutput(); // img->Update(); // img->UpdateInformation(); - // _thresholdTable->Update(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _thresholdMapper->SetInput( img ); +#else + _thresholdMapper->SetInputData( img ); +#endif + _thresholdMapper->SetLookupTable( _thresholdTable ); + + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _thresholdActor->SetInput( _thresholdMapper->GetOutput() ); +#else + _thresholdMapper->Update(); + _thresholdActor->SetInputData( _thresholdMapper->GetOutput() ); +#endif + _thresholdActor->SetOpacity(_opacity); _scalarbarActor->SetLookupTable( _thresholdTable ); // _scalarbarActor->SetLookupTable( _thresholdMapper->GetLookupTable() ); _scalarbarActor->SetTitle("Value"); _scalarbarActor->SetNumberOfLabels(4); int fontsize = _scalarbarActor->GetLabelTextProperty()->GetFontSize(); _scalarbarActor->GetLabelTextProperty()->SetFontSize(fontsize/2); - // _scalarbarActor->SetTextPad(4); ?? - - } // _image } @@ -553,8 +602,10 @@ void LayerImageBase::onThresholdChangeOpacity (int opacity) { if (_actorPresent) { - _thresholdActor->SetOpacity(opacity*0.1); + _thresholdActor->SetOpacity(opacity/100.0); } +// EED 2017-12-17 + _opacity = (double)opacity/100.0; } //---------------------------------------------------------------------------- @@ -565,15 +616,8 @@ void LayerImageBase::onThresholdRemove() wxVtkBaseView * baseView = _baseView; baseView->GetRenderer()->RemoveActor( _thresholdActor ); baseView->GetRenderer()->RemoveActor( _scalarbarActor ); - _actorPresent = false; - } -} - -//---------------------------------------------------------------------------- -vtkLookupTable *LayerImageBase::GetvtkLookupTable() -{ - return _thresholdTable; + } // if _actorPresent } //---------------------------------------------------------------------------- @@ -592,7 +636,10 @@ void LayerImageBase::GetImageScalarRange() _range[1]=max; } - +vtkScalarsToColors* LayerImageBase::GetLookupTable() +{ + return _thresholdTable; +} // EOF