]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkActor.cxx
#3523 Add to BoxWidget box Transform option
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkActor.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbcreaVtkActor.h"
5 #include "bbcreaVtkPackage.h"
6 #include "vtkProperty.h"
7
8 namespace bbcreaVtk
9 {
10
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,Actor)
12 BBTK_BLACK_BOX_IMPLEMENTATION(Actor,bbtk::AtomicBlackBox);
13 //===== 
14 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
15 //===== 
16 void Actor::Process()
17 {
18 // THE MAIN PROCESSING METHOD BODY
19 //   Here we simply set the input 'In' value to the output 'Out'
20 //   And print out the output value
21 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
22 //    void bbSet{Input|Output}NAME(const TYPE&)
23 //    const TYPE& bbGet{Input|Output}NAME() const 
24 //    Where :
25 //    * NAME is the name of the input/output
26 //      (the one provided in the attribute 'name' of the tag 'input')
27 //    * TYPE is the C++ type of the input/output
28 //      (the one provided in the attribute 'type' of the tag 'input')
29 //    bbSetOutputOut( bbGetInputIn() );
30 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
31         if (bbGetInputIn()!=NULL)
32         {
33                 vtkProp3D* vtkprop3D    = bbGetInputIn();
34                 std::string className   = vtkprop3D->GetClassName();
35                 std::string wantedClass = "vtkOpenGLActor";
36                 if(className == wantedClass)
37                 {
38                         vtkActor *vtkactor=((vtkActor*)vtkprop3D);
39                         vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
40                         vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
41                         double r = bbGetInputColor()[0];
42                         double g = bbGetInputColor()[1];
43                         double b = bbGetInputColor()[2];
44                         vtkactor->GetProperty()->SetColor( r,g,b );
45                 }
46                  if ( bbGetInputTransform()!=NULL )
47                  {
48                     vtkprop3D->SetUserTransform( bbGetInputTransform() );
49                  }
50         // bbSetOutputOut( vtkactor );
51         // Interface Update
52                 if ((bbGetInputRenderer()!=NULL) && ( backActive!=bbGetInputActive() ))
53                 {
54                         if (bbGetInputActive()==true )
55                         {
56                                 bbGetInputRenderer()->AddActor( vtkprop3D );
57                         }  else {
58                                 bbGetInputRenderer()->RemoveActor( vtkprop3D );
59                         }  //if Active
60                         backActive=bbGetInputActive();
61                 } // if Renderer
62         }// bbGetInputIn
63 }
64
65 //===== 
66 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
67 //===== 
68 void Actor::bbUserSetDefaultValues()
69 {
70 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
71 //    Here we initialize the input 'In' to 0
72         std::vector<double> color;
73         color.push_back(1);
74         color.push_back(0);
75         color.push_back(0);
76         bbSetInputActive( false );
77         backActive=bbGetInputActive();
78         bbSetInputIn( NULL );
79         bbSetInputOpacity( 1 );
80         bbSetInputLineWidth( 0.5 );
81         bbSetInputRenderer( NULL );
82         bbSetInputColor( color );
83         bbSetInputTransform( NULL );
84 }
85
86 //===== 
87 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
88 //===== 
89 void Actor::bbUserInitializeProcessing()
90 {
91 //  THE INITIALIZATION METHOD BODY :
92 //    Here does nothing 
93 //    but this is where you should allocate the internal/output pointers 
94 //    if any
95 }
96
97 //===== 
98 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
99 //===== 
100 void Actor::bbUserFinalizeProcessing()
101 {
102 //  THE FINALIZATION METHOD BODY :
103 //    Here does nothing 
104 //    but this is where you should desallocate the internal/output pointers 
105 //    if any
106 }
107
108 } // EO namespace bbcreaVtk
109
110