]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkText2D.cxx
75967a29bf3c61c972dac289ede0e79257bf0d51
[bbtk.git] / packages / vtk / src / bbvtkText2D.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 "bbvtkText2D.h"
5 #include "bbvtkPackage.h"
6
7 #include "vtkTextProperty.h"
8
9 namespace bbvtk
10 {
11
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,Text2D)
13 BBTK_BLACK_BOX_IMPLEMENTATION(Text2D,bbtk::AtomicBlackBox);
14 //===== 
15 // 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)
16 //===== 
17 void Text2D::Process()
18 {
19
20 // THE MAIN PROCESSING METHOD BODY
21 //   Here we simply set the input 'In' value to the output 'Out'
22 //   And print out the output value
23 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
24 //    void bbSet{Input|Output}NAME(const TYPE&)
25 //    const TYPE& bbGet{Input|Output}NAME() const 
26 //    Where :
27 //    * NAME is the name of the input/output
28 //      (the one provided in the attribute 'name' of the tag 'input')
29 //    * TYPE is the C++ type of the input/output
30 //      (the one provided in the attribute 'type' of the tag 'input')
31
32 //    bbSetOutputOut( bbGetInputIn() );
33 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
34   
35
36  if (_textActor==NULL)
37  { 
38    _textActor = vtkTextActor::New();
39    _textActor->GetPositionCoordinate()->SetCoordinateSystemToWorld();
40
41    if (bbGetInputRenderer()!=NULL)
42    {
43       bbGetInputRenderer()->AddActor2D(_textActor);
44    }
45  }
46
47  _textActor->SetInput(bbGetInputIn().c_str());
48
49 // textActor->SetTextScaleModeToProp();
50 // textActor->SetDisplayPosition(90, 50);
51 // textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
52
53  double px=0;
54  double py=0;
55  double spx=1;
56  double spy=1;
57  if (bbGetInputPoint().size()>=2)
58  {
59     px=bbGetInputPoint()[0];
60     py=bbGetInputPoint()[1];
61         
62     if (bbGetInputSpacing().size()>=2)
63     {
64         spx=bbGetInputSpacing()[0];
65         spy=bbGetInputSpacing()[1];
66     }    
67
68  }
69  _textActor->SetPosition( px*spx , py*spy );
70 // textActor->GetPosition2Coordinate()->SetValue(0.6, 0.1);
71
72  vtkTextProperty *tprop = _textActor->GetTextProperty();
73  tprop->SetFontSize(10);
74  tprop->SetFontFamilyToArial();
75  tprop->SetJustificationToCentered();
76 // tprop->BoldOn();
77 // tprop->ItalicOn();
78 // tprop->ShadowOn();
79  tprop->SetColor(0, 0, 1);
80  tprop->SetOpacity( bbGetInputOpacity() );
81   
82 }
83 //===== 
84 // 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)
85 //===== 
86 void Text2D::bbUserSetDefaultValues()
87 {
88
89 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
90 //    Here we initialize the input 'In' to 0
91
92  _textActor=NULL;
93  bbSetInputIn("VOID");  
94  bbSetInputOpacity(1);  
95  bbSetInputRenderer(NULL); 
96  std::vector<double> spc;
97  spc.push_back(1); 
98  spc.push_back(1); 
99  spc.push_back(1); 
100  bbSetInputSpacing(spc);  
101
102
103 }
104 //===== 
105 // 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)
106 //===== 
107 void Text2D::bbUserInitializeProcessing()
108 {
109
110 //  THE INITIALIZATION METHOD BODY :
111 //    Here does nothing 
112 //    but this is where you should allocate the internal/output pointers 
113 //    if any 
114
115   
116 }
117 //===== 
118 // 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)
119 //===== 
120 void Text2D::bbUserFinalizeProcessing()
121 {
122
123 //  THE FINALIZATION METHOD BODY :
124 //    Here does nothing 
125 //    but this is where you should desallocate the internal/output pointers 
126 //    if any
127   
128 }
129 }
130 // EO namespace bbvtk
131
132