1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "bbmaracasvisuImageActor.h"
27 #include "bbcreaMaracasVisuPackage.h"
29 #include "vtkImageShiftScale.h"
30 #include <vtkLookupTable.h>
31 #include <vtkColorTransferFunction.h>
32 #include <vtkImageMapToColors.h>
33 #include <vtkImageMapper3D.h>
34 #include <vtkImageProperty.h>
36 namespace bbcreaMaracasVisu
39 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ImageActor)
40 BBTK_BLACK_BOX_IMPLEMENTATION(ImageActor,bbtk::AtomicBlackBox);
41 void ImageActor::Process()
44 vtkImageData *img = bbGetInputIn();
45 vtkLinearTransform* transform = bbGetInputTransform();
50 if (bbGetInputLookupTable()==NULL)
52 //EED 2017-01-01 Migration VTK7
53 #if VTK_MAJOR_VERSION <= 5
54 imageactor->SetInput( img );
56 imageactor->SetInputData( img );
59 vtkImageMapToColors *color = vtkImageMapToColors::New();
60 color->SetLookupTable( bbGetInputLookupTable() );
61 color->PassAlphaToOutputOn();
63 //EED 2017-01-01 Migration VTK7
64 #if VTK_MAJOR_VERSION <= 5
65 color->SetInput( img );
67 imageactor->GetMapper()->SetInput( color->GetOutput() );
69 color->SetInputData( img );
71 imageactor->GetMapper()->SetInputData( color->GetOutput() );
74 if ( bbGetInputInterpolationMode()==0) { imageactor->GetProperty()->SetInterpolationTypeToNearest(); }
75 if ( bbGetInputInterpolationMode()==1) { imageactor->GetProperty()->SetInterpolationTypeToLinear(); }
76 if ( bbGetInputInterpolationMode()==2) { imageactor->GetProperty()->SetInterpolationTypeToCubic(); }
77 imageactor->SetForceOpaque(true);
82 imageactor->SetUserTransform( transform );
84 bbSetOutputOut(imageactor);
88 if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
91 bbGetInputRenderer()->AddActor( imageactor );
93 imageactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
94 bbSetOutputOut(imageactor);
97 void ImageActor::bbUserSetDefaultValues()
102 bbSetInputOpacity(1);
103 bbSetInputTransform(NULL);
104 bbSetInputRenderer(NULL);
105 bbSetInputLookupTable(NULL);
106 bbSetInputInterpolationMode(0);
110 //-----------------------------------------------------------------
111 void ImageActor::bbUserInitializeProcessing()
113 imageactor = vtkImageActor::New();
114 imageshiftscale = vtkImageShiftScale::New();
117 //-----------------------------------------------------------------
118 void ImageActor::bbUserFinalizeProcessing()
122 //-----------------------------------------------------------------
124 // EO namespace bbcreaMaracasVisu