]> Creatis software - creaMaracasVisu.git/commitdiff
#3529 Remove Add ImageToActor
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 26 Jul 2023 15:51:12 +0000 (17:51 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 26 Jul 2023 15:51:12 +0000 (17:51 +0200)
bbtk/src/bbmaracasvisuImageActor.cxx
bbtk/src/bbmaracasvisuImageActor.h

index adc7846f53d7e28ff32778eca5f479e1fe7e3847..aded76a185919ec7040728946d6f4f7a5d7aa659 100644 (file)
@@ -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);
index f8e90337cdf8234ec3a75e3401ba11e41077fa25..8e98086aba560e207633a651c3b2799931db1e8a 100644 (file)
@@ -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,"");