[vtkusers] Re: Displaying string as labels - how to? (Roger Blum)

Roger Blum roger_blum at swissonline.ch
Mon Aug 28 20:39:18 EDT 2006


Hi Rodolfo,

Thanks for your ideas. I probably have to be more precise about what I 
intend to do:

I create a couple of glyphs with the vtkGlyph3D filter. Now I would like to 
annotate each of these glyphs with 1 to 4 labels.

I could use a vtkTextActor for each of these labels. But I hope there is a 
more efficient way to do it.

The vtkLabeledDataMapper is close to what I need, but I can not pass the 
string labels (vtkStringArray) through the pipeline.

Thanks again,
Roger



<scsrsao at leeds.ac.uk> schrieb im Newsbeitrag 
news:1156763687.3604bdfcf7984 at webmail7.leeds.ac.uk...
> Hi Roger,
>
> I can think about two thinks you could do... the first one in case you 
> only
> want to set up some sort of title or description that doesn't need to be 
> moved
> when objects rotate in the render window... for this, you could something 
> like:
>
> titleMapper = vtkTextMapper::New();
>   titleMapper->SetInput("your title");
>
> titleActor = vtkTextActor::New();
>   titleActor->SetMapper(titleMapper);
>   titleActor->GetTextProperty()->SetFontSize(24);
>
> titleActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
>   titleActor->GetPositionCoordinate()->SetValue(0.4,0.93);
>
> On the other hand, if you want to make labels to move together with an 
> object
> you have associated to, then you need something more elavorated... the 
> common
> example (or at least the one I know) is to build 3d axes... the code 
> should be
> something like this:
>
> //initialize axis stuff
> xAxis = vtkArrowSource::New();
>
> xAxisMapper = vtkPolyDataMapper::New();
>   xAxisMapper->SetInput(xAxis->GetOutput());
>
> xAxisActor = vtkActor::New();
>   xAxisActor->SetMapper(xAxisMapper);
>   xAxisActor->GetProperty()->SetColor(1,0,0);
>
> xLabel = vtkCaptionActor2D::New();
>   xLabel->SetCaption("X");
>   xLabel->SetAttachmentPoint(0.8,0,0);
>   xLabel->LeaderOff();
>   xLabel->BorderOff();
>   xLabel->SetPosition(0,0);
>
> yAxis = vtkArrowSource::New();
>
> yAxisMapper = vtkPolyDataMapper::New();
>   yAxisMapper->SetInput(yAxis->GetOutput());
>
> yAxisActor = vtkActor::New();
>   yAxisActor->SetMapper(yAxisMapper);
>   yAxisActor->RotateZ(90);
>   yAxisActor->GetProperty()->SetColor(0,1,0);
>
> yLabel = vtkCaptionActor2D::New();
>   yLabel->SetCaption("Y");
>   yLabel->SetAttachmentPoint(0,0.7,0);
>   yLabel->LeaderOff();
>   yLabel->BorderOff();
>   yLabel->SetPosition(0,0);
>
> zAxis = vtkArrowSource::New();
>
> zAxisMapper = vtkPolyDataMapper::New();
>   zAxisMapper->SetInput(zAxis->GetOutput());
>
> zAxisActor = vtkActor::New();
>   zAxisActor->SetMapper(zAxisMapper);
>   zAxisActor->RotateY(-90);
>   zAxisActor->GetProperty()->SetColor(0,0,0.8);
>
> zLabel = vtkCaptionActor2D::New();
>   zLabel->SetCaption("Z");
>   zLabel->SetAttachmentPoint(0,0,1);
>   zLabel->LeaderOff();
>   zLabel->BorderOff();
>   zLabel->SetPosition(0,0);
>
>
> Axes3D = vtkPropAssembly::New();
>   Axes3D->AddPart(xAxisActor);
>   Axes3D->AddPart(xLabel);
>   Axes3D->AddPart(yAxisActor);
>   Axes3D->AddPart(yLabel);
>   Axes3D->AddPart(zAxisActor);
>   Axes3D->AddPart(zLabel);
>
> axesCam = vtkCamera::New();
>   axesCam->ParallelProjectionOn();
>
> axesRen = vtkRenderer::New();
>   axesRen->InteractiveOff();
>   axesRen->SetActiveCamera(axesCam);
>   axesRen->SetViewport(0,0.80,0.15,0.95);
>   axesRen->SetLayer(1);
>   axesRen->AddActor(Axes3D);
>   axesRen->ResetCameraClippingRange();
>
>
> Hope it helps...
> Rodolfo
>
>> ------------------------------
>>
>> Message: 4
>> Date: Sat, 26 Aug 2006 20:49:35 -1000
>> From: "Roger Blum" <roger_blum at swissonline.ch>
>> Subject: [vtkusers] Displaying string as labels - how to?
>> To: vtkusers at public.kitware.com
>> Message-ID: <ecrf9p$rao$1 at sea.gmane.org>
>>
>> Hi vtk users,
>>
>> I have a couple of points, a scalar value for each point and 1 to 4 
>> strings
>> describing each point. How can I display the strings at the point 
>> location
>> (I am using vtk 5.0.0 with Tcl)?
>>
>> I have tried to use vtkPolyData (with a vtkStringArray containing the 
>> Labels
>> in vtkPointData), but a vtkStringArray can not be added to vtkPointData.
>>
>> Is the vtkLabeledDataMapper the right thing to use for what I want to do? 
>> Is
>> there a better way to do it?
>>
>> Thanks in advance for your help,
>> Roger
>>
>>
>>
>>
>>
>>
>> ------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: 
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 






More information about the vtkusers mailing list