From: Eduardo DAVILA Date: Wed, 26 Jul 2023 15:51:12 +0000 (+0200) Subject: #3529 Remove Add ImageToActor X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b30f11b1de7cc1259130b491e36657811622270c;p=creaMaracasVisu.git #3529 Remove Add ImageToActor --- diff --git a/bbtk/src/bbmaracasvisuImageActor.cxx b/bbtk/src/bbmaracasvisuImageActor.cxx index adc7846..aded76a 100644 --- a/bbtk/src/bbmaracasvisuImageActor.cxx +++ b/bbtk/src/bbmaracasvisuImageActor.cxx @@ -40,63 +40,74 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ImageActor) BBTK_BLACK_BOX_IMPLEMENTATION(ImageActor,bbtk::AtomicBlackBox); void ImageActor::Process() { - //JCP 04/04/09 - vtkImageData *img = bbGetInputIn(); - vtkLinearTransform* transform = bbGetInputTransform(); - - if(img != NULL) - { - if (bbGetInputLookupTable()==NULL) - { -//EED 2017-01-01 Migration VTK7 + + if (bbGetInputActive()==true) + { + //JCP 04/04/09 + vtkImageData *img = bbGetInputIn(); + vtkLinearTransform* transform = bbGetInputTransform(); + + if(img != NULL) + { + if (bbGetInputLookupTable()==NULL) + { + //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 - imageactor->SetInput( img ); + imageactor->SetInput( img ); #else - imageactor->SetInputData( img ); + imageactor->SetInputData( img ); #endif - } else { - vtkImageMapToColors *color = vtkImageMapToColors::New(); - color->SetLookupTable( bbGetInputLookupTable() ); - color->PassAlphaToOutputOn(); - -//EED 2017-01-01 Migration VTK7 + } else { + vtkImageMapToColors *color = vtkImageMapToColors::New(); + color->SetLookupTable( bbGetInputLookupTable() ); + color->PassAlphaToOutputOn(); + + //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 - color->SetInput( img ); - color->Update(); - imageactor->GetMapper()->SetInput( color->GetOutput() ); + color->SetInput( img ); + color->Update(); + imageactor->GetMapper()->SetInput( color->GetOutput() ); #else - color->SetInputData( img ); - color->Update(); - imageactor->GetMapper()->SetInputData( color->GetOutput() ); + color->SetInputData( img ); + color->Update(); + imageactor->GetMapper()->SetInputData( color->GetOutput() ); #endif - - if ( bbGetInputInterpolationMode()==0) { imageactor->GetProperty()->SetInterpolationTypeToNearest(); } - if ( bbGetInputInterpolationMode()==1) { imageactor->GetProperty()->SetInterpolationTypeToLinear(); } - if ( bbGetInputInterpolationMode()==2) { imageactor->GetProperty()->SetInterpolationTypeToCubic(); } - imageactor->SetForceOpaque(true); - } - - if (transform!=NULL) - { - imageactor->SetUserTransform( transform ); - } // transform - bbSetOutputOut(imageactor); - } // img - - // Interface Update - if ((firsttime==true) && (bbGetInputRenderer()!=NULL )) - { - firsttime=false; - bbGetInputRenderer()->AddActor( imageactor ); - } - imageactor->GetProperty()->SetOpacity( bbGetInputOpacity() ); - bbSetOutputOut(imageactor); + + if ( bbGetInputInterpolationMode()==0) { imageactor->GetProperty()->SetInterpolationTypeToNearest(); } + if ( bbGetInputInterpolationMode()==1) { imageactor->GetProperty()->SetInterpolationTypeToLinear(); } + if ( bbGetInputInterpolationMode()==2) { imageactor->GetProperty()->SetInterpolationTypeToCubic(); } + imageactor->SetForceOpaque(true); + } + + if (transform!=NULL) + { + imageactor->SetUserTransform( transform ); + } // transform + bbSetOutputOut(imageactor); + } // img + + // Interface Update + if ((firsttime==true) && (bbGetInputRenderer()!=NULL )) + { + firsttime=false; + bbGetInputRenderer()->AddActor( imageactor ); + } + imageactor->GetProperty()->SetOpacity( bbGetInputOpacity() ); + bbSetOutputOut(imageactor); + }else{ + if ((firsttime==false) && (bbGetInputRenderer()!=NULL )) + { + firsttime = true; + bbGetInputRenderer()->RemoveActor( imageactor ); + } + } } void ImageActor::bbUserSetDefaultValues() { firsttime = true; imageactor = NULL; + bbSetInputActive(true); bbSetInputIn(NULL); bbSetInputOpacity(1); bbSetInputTransform(NULL); diff --git a/bbtk/src/bbmaracasvisuImageActor.h b/bbtk/src/bbmaracasvisuImageActor.h index f8e9033..8e98086 100644 --- a/bbtk/src/bbmaracasvisuImageActor.h +++ b/bbtk/src/bbmaracasvisuImageActor.h @@ -48,6 +48,7 @@ class bbcreaMaracasVisu_EXPORT ImageActor public bbtk::AtomicBlackBox { BBTK_BLACK_BOX_INTERFACE(ImageActor,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(Active, bool); BBTK_DECLARE_INPUT(In,vtkImageData*); BBTK_DECLARE_INPUT(Transform,vtkLinearTransform*); BBTK_DECLARE_INPUT(Renderer,vtkRenderer*); @@ -59,8 +60,8 @@ class bbcreaMaracasVisu_EXPORT ImageActor BBTK_PROCESS(Process); void Process(); bool firsttime; - vtkImageActor *imageactor; - vtkImageShiftScale *imageshiftscale; + vtkImageActor *imageactor; + vtkImageShiftScale *imageshiftscale; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageActor,bbtk::AtomicBlackBox); @@ -68,7 +69,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageActor,bbtk::AtomicBlackBox); BBTK_AUTHOR("InfoDev CREATIS"); BBTK_DESCRIPTION("put image in a 3D univers"); BBTK_CATEGORY(""); - BBTK_INPUT(ImageActor,In,"Image input",vtkImageData*,""); + BBTK_INPUT(ImageActor,Active,"Active",bool,""); + BBTK_INPUT(ImageActor,In,"Image input",vtkImageData*,""); BBTK_INPUT(ImageActor,Transform,"Transform",vtkLinearTransform*,""); BBTK_INPUT(ImageActor,Renderer,"Renderer",vtkRenderer*,""); BBTK_INPUT(ImageActor,Opacity,"Opacity [0-1]",double,"");