]> Creatis software - bbtk.git/commitdiff
Text2D vtk
authordavila <eduardo.davila@creatis.insa-lyon.fr>
Tue, 6 May 2014 15:40:00 +0000 (17:40 +0200)
committerdavila <eduardo.davila@creatis.insa-lyon.fr>
Tue, 6 May 2014 15:40:00 +0000 (17:40 +0200)
packages/vtk/bbs/appli/exampleText2D.bbg [new file with mode: 0644]
packages/vtk/bbs/appli/exampleText2D.bbs [new file with mode: 0644]
packages/vtk/src/bbvtkText2D.cxx
packages/vtk/src/bbvtkText2D.h

diff --git a/packages/vtk/bbs/appli/exampleText2D.bbg b/packages/vtk/bbs/appli/exampleText2D.bbg
new file mode 100644 (file)
index 0000000..8927761
--- /dev/null
@@ -0,0 +1,82 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBG BlackBox Diagram file
+# - /home/davila/Creatis/All-Vtk_5-10-1/creatools_source/bbtk/packages/vtk/bbs/appli/exampleText2D.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:<VOID>
+DESCRIPTION:Description ??
+AUTHOR:Author ??
+COMPLEXBOX:FALSE
+COMPLEXINPUTS:0
+BOXES:6
+BOX
+vtk:LoadHola:Box00
+ISEXEC:FALSE
+-28.489648:74.163529:-900.000000
+17.085352:64.163529:-900.000000
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box01
+ISEXEC:TRUE
+-37.232503:52.758608:-900.000000
+23.407497:42.758608:-900.000000
+FIN_BOX
+BOX
+vtk:Text2D:Box02
+ISEXEC:TRUE
+-47.181269:-18.390143:-900.000000
+-14.406269:-28.390143:-900.000000
+PORT
+In:"hola"
+FIN_BOX
+BOX
+std:ConcatStrings:Box03
+ISEXEC:FALSE
+-83.358600:22.610832:-900.000000
+-37.783600:12.610832:-900.000000
+FIN_BOX
+BOX
+vtk:ImageVtkProperties:Box04
+ISEXEC:FALSE
+37.232503:38.890631:-900.000000
+82.807503:28.890631:-900.000000
+FIN_BOX
+BOX
+std:ConcatStrings:Box05
+ISEXEC:FALSE
+26.680782:8.139900:-900.000000
+72.255782:-1.860100:-900.000000
+FIN_BOX
+CONNECTIONS:10
+CONNECTION
+Box00:Out:Box01:In
+NumberOfControlPoints:0
+CONNECTION
+Box01:Renderer4:Box02:Renderer
+NumberOfControlPoints:0
+CONNECTION
+Box01:Point:Box03:In1
+NumberOfControlPoints:0
+CONNECTION
+Box03:Out:Box02:Point
+NumberOfControlPoints:0
+CONNECTION
+Box01:BoxChange:Box03:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box01:BoxChange:Box02:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box00:Out:Box04:In
+NumberOfControlPoints:0
+CONNECTION
+Box04:Spacing:Box05:In1
+NumberOfControlPoints:0
+CONNECTION
+Box05:Out:Box02:Spacing
+NumberOfControlPoints:0
+CONNECTION
+Box01:Point:Box02:In
+NumberOfControlPoints:0
+APP_END
diff --git a/packages/vtk/bbs/appli/exampleText2D.bbs b/packages/vtk/bbs/appli/exampleText2D.bbs
new file mode 100644 (file)
index 0000000..dcc98a4
--- /dev/null
@@ -0,0 +1,57 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBS BlackBox Script
+# - /home/davila/Creatis/All-Vtk_5-10-1/creatools_source/bbtk/packages/vtk/bbs/appli/exampleText2D.bbs
+# ----------------------------------
+
+# BBTK GEditor Script
+# ----------------------
+
+include std
+include itkvtk
+include vtk
+include creaMaracasVisu
+include std
+
+author "Author ??"
+description "Description ??"
+category "<VOID>"
+
+new LoadHola Box00
+
+new ViewerNV Box01
+
+new Text2D Box02
+  set Box02.In "hola"
+
+new ConcatStrings Box03
+
+new ImageVtkProperties Box04
+
+new ConcatStrings Box05
+
+
+connect Box00.Out Box01.In
+
+connect Box01.Renderer4 Box02.Renderer
+
+connect Box01.Point Box03.In1
+
+connect Box03.Out Box02.Point
+
+connect Box01.BoxChange Box03.BoxExecute
+
+connect Box01.BoxChange Box02.BoxExecute
+
+connect Box00.Out Box04.In
+
+connect Box04.Spacing Box05.In1
+
+connect Box05.Out Box02.Spacing
+
+connect Box01.Point Box02.In
+
+
+
+# Complex input ports
+exec Box01
+exec Box02
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)
index cc5e72abf80d447caa4ac352bcbec68710dd0b78..ad9821ed9f56980df625532fa8df569cfc5a4263 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "vtkProp.h"
 #include "vtkRenderer.h"
+#include "vtkTextActor.h"
 
 namespace bbvtk
 {
@@ -24,10 +25,14 @@ class bbvtk_EXPORT Text2D
 BBTK_DECLARE_INPUT(In,std::string);
   BBTK_DECLARE_INPUT(Renderer,vtkRenderer*);
   BBTK_DECLARE_INPUT(Point,std::vector<double>);
+  BBTK_DECLARE_INPUT(Spacing,std::vector<double>);
   BBTK_DECLARE_INPUT(Opacity,double);
   BBTK_DECLARE_OUTPUT( Out , vtkProp* );
   BBTK_PROCESS(Process);
   void Process();
+
+  vtkTextActor *_textActor;
+
 //===== 
 // 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)
 //===== 
@@ -40,9 +45,10 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(Text2D,bbtk::AtomicBlackBox);
   BBTK_CATEGORY("empty");
 
   BBTK_INPUT(Text2D,In,"Input text (default = 'VOID')",std::string,"");
-  BBTK_INPUT(Text2D,Renderer,"Input text",vtkRenderer*,"");
   BBTK_INPUT(Text2D,Point,"Point [x,y,z]",std::vector<double>,"");
-  BBTK_INPUT(Text2D,Opacity,"Input text",double,"");
+  BBTK_INPUT(Text2D,Spacing,"Spacing [sx,sy,sz] default [1,1,1]",std::vector<double>,"");
+  BBTK_INPUT(Text2D,Opacity,"Pacity default 1 ",double,"");
+  BBTK_INPUT(Text2D,Renderer,"Input text",vtkRenderer*,"");
 
   BBTK_OUTPUT(Text2D,Out,"vtk Prop",vtkProp*,"");