X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FThresholdImageView%2FLayerImageBase.cxx;h=c6d8465096bfd21a7ec43484e7ed82244e2eef78;hb=5a27c495a6c3899102f76eb029b6aadcee4121c1;hp=c079604b5debfe8a5eecf4536ee736a64003267f;hpb=d8edef346f2d6c64f6ed3bea7225aeb3a8b3970c;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 c079604..c6d8465 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx @@ -1,11 +1,46 @@ /** - * \file - * \brief Class bbtk::ThresholdImageView . + * \file + * \brief Class bbtk::ThresholdImageView . */ #include "LayerImageBase.h" + +//--------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------- + +ColorLayerImageBasevtkInteractor::ColorLayerImageBasevtkInteractor(LayerImageBase* layerImageBase) +{ + _layerImageBase=layerImageBase; +} + +//--------------------------------------------------------------------------------------------- +ColorLayerImageBasevtkInteractor::~ColorLayerImageBasevtkInteractor() +{ +} + + +//--------------------------------------------------------------------------------------------- +bool ColorLayerImageBasevtkInteractor::OnMouseMove() +{ + + if (_vtkInteractorStyleBaseView->GetRefresh_waiting()==true) + { + _layerImageBase->GetvtkImageReslice()->Modified(); + } + + return true; +} + + +//--------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------- + + + LayerImageBase::LayerImageBase() { _actorPresent = false; @@ -14,6 +49,7 @@ LayerImageBase::LayerImageBase() _thresholdMapper = NULL; _thresholdActor = NULL; _image = NULL; + _baseView = NULL; _imageReslicer = vtkImageReslice::New(); } @@ -59,6 +95,9 @@ void LayerImageBase::SetImage(vtkImageData* image) void LayerImageBase::SetwxVtkBaseView(wxVtkBaseView *baseview) { _baseView = baseview; + + vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)(_baseView->GetInteractorStyleBaseView()); + isbv->AddInteractorStyleMaracas( new ColorLayerImageBasevtkInteractor(this) ); } //---------------------------------------------------------------------------- @@ -67,6 +106,15 @@ wxVtkBaseView *LayerImageBase::GetwxVtkBaseView() return _baseView; } +//---------------------------------------------------------------------------- +void LayerImageBase::Refresh() +{ + printf("EED LayerImageBase::Refresh\n"); + if (_baseView!=NULL) + { + _baseView->Refresh(); + } +} //---------------------------------------------------------------------------- @@ -77,7 +125,7 @@ vtkLookupTable* LayerImageBase::GetThresholdTable() //---------------------------------------------------------------------------- int LayerImageBase::CleanZ(int z) -{ +{ int ext[6]; _image->GetWholeExtent(ext); @@ -98,45 +146,45 @@ int LayerImageBase::CleanZ(int z) void LayerImageBase::onThreshold() { - if (_image!=NULL) + if ((_image!=NULL) && (_baseView!=NULL)) { int z=CleanZ( GetZ() ); if (!GetActorPresent()) - { + { if (_thresholdTable==NULL) { //Lookup Table _thresholdTable = vtkLookupTable::New(); } // _thresholdTable - + if (_thresholdMapper==NULL) { _thresholdMapper = vtkImageMapToColors::New( ); } - + if (_thresholdActor==NULL) { _thresholdActor = vtkImageActor::New( ); _thresholdActor->SetOpacity( 0.6 ); _thresholdActor->InterpolateOn( ); _thresholdActor->SetPosition( 0,0, 900-1 ); - } // _thresholdActor + } // _thresholdActor _baseView->GetRenderer()->AddActor( _thresholdActor ); - _actorPresent = true; + _actorPresent = true; } // !GetActorPresent() ConfigLookupTable(); // virtual method _imageReslicer->SetInput( GetImage() ); - _imageReslicer->SetInformationInput( GetImage() ); + _imageReslicer->SetInformationInput( GetImage() ); _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1); _imageReslicer->SetOutputDimensionality(2); _imageReslicer->SetInterpolationModeToLinear(); _imageReslicer->SetResliceAxesOrigin(0,0,z); vtkImageData *img = _imageReslicer->GetOutput(); - img->Update(); - img->UpdateInformation(); +// img->Update(); +// img->UpdateInformation(); _thresholdMapper->SetInput( img ); _thresholdMapper->SetLookupTable( _thresholdTable ); @@ -167,7 +215,7 @@ void LayerImageBase::onThresholdInterpolation(bool interpolate) else { _thresholdActor->InterpolateOff( ); - } + } } } @@ -188,9 +236,19 @@ void LayerImageBase::onThresholdRemove() wxVtkBaseView * baseView = _baseView; baseView->GetRenderer()->RemoveActor( _thresholdActor ); _actorPresent = false; - } + } +} + +//---------------------------------------------------------------------------- +vtkLookupTable *LayerImageBase::GetvtkLookupTable() +{ + return _thresholdTable; } +vtkImageReslice *LayerImageBase::GetvtkImageReslice() +{ + return _imageReslicer; +}