]> Creatis software - bbtk.git/blobdiff - packages/vtk/src/bbvtkText2D.cxx
Text2D vtk
[bbtk.git] / packages / vtk / src / bbvtkText2D.cxx
index a36e4d34cc5f1eccb34d255f7e48add279cdf990..75967a29bf3c61c972dac289ede0e79257bf0d51 100644 (file)
@@ -4,7 +4,6 @@
 #include "bbvtkText2D.h"
 #include "bbvtkPackage.h"
 
-#include "vtkTextActor.h"
 #include "vtkTextProperty.h"
 
 namespace bbvtk
@@ -33,24 +32,52 @@ void Text2D::Process()
 //    bbSetOutputOut( bbGetInputIn() );
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
   
- vtkTextActor *textActor = vtkTextActor::New();
- textActor->SetTextScaleModeToProp();
- textActor->SetDisplayPosition(90, 50);
- textActor->SetInput(bbGetInputIn().c_str());
 
- textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
- textActor->GetPosition2Coordinate()->SetValue(0.6, 0.1);
+ if (_textActor==NULL)
+ { 
+   _textActor = vtkTextActor::New();
+   _textActor->GetPositionCoordinate()->SetCoordinateSystemToWorld();
 
- vtkTextProperty *tprop = textActor->GetTextProperty();
- tprop->SetFontSize(18);
+   if (bbGetInputRenderer()!=NULL)
+   {
+      bbGetInputRenderer()->AddActor2D(_textActor);
+   }
+ }
+
+ _textActor->SetInput(bbGetInputIn().c_str());
+
+// textActor->SetTextScaleModeToProp();
+// textActor->SetDisplayPosition(90, 50);
+// textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
+
+ double px=0;
+ double py=0;
+ double spx=1;
+ double spy=1;
+ if (bbGetInputPoint().size()>=2)
+ {
+    px=bbGetInputPoint()[0];
+    py=bbGetInputPoint()[1];
+       
+    if (bbGetInputSpacing().size()>=2)
+    {
+       spx=bbGetInputSpacing()[0];
+       spy=bbGetInputSpacing()[1];
+    }    
+
+ }
+ _textActor->SetPosition( px*spx , py*spy );
+// textActor->GetPosition2Coordinate()->SetValue(0.6, 0.1);
+
+ vtkTextProperty *tprop = _textActor->GetTextProperty();
+ tprop->SetFontSize(10);
  tprop->SetFontFamilyToArial();
  tprop->SetJustificationToCentered();
 // tprop->BoldOn();
 // tprop->ItalicOn();
 // tprop->ShadowOn();
  tprop->SetColor(0, 0, 1);
-
- bbGetInputRenderer()->AddActor2D(textActor);
+ tprop->SetOpacity( bbGetInputOpacity() );
   
 }
 //===== 
@@ -61,7 +88,18 @@ void Text2D::bbUserSetDefaultValues()
 
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
+
+ _textActor=NULL;
  bbSetInputIn("VOID");  
+ bbSetInputOpacity(1);  
+ bbSetInputRenderer(NULL); 
+ std::vector<double> spc;
+ spc.push_back(1); 
+ spc.push_back(1); 
+ spc.push_back(1); 
+ bbSetInputSpacing(spc);  
+
+
 }
 //===== 
 // 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)