[vtkusers] vtkTextActor align to center of text
David Lonie
david.lonie at kitware.com
Fri Feb 10 09:38:42 EST 2017
It sounds like the billboard actor will give you what you want for sure
then.
Until you have that available, there are a couple other ways to do this:
1) vtkTextMapper with a vtkFollower. vtkTextMapper also has configurable
text properties, unlike the vector text.
2) vtkTextActor -- you can set this 2D actor's position coordinate to a 3D
world position and it should show up in the right spot. However, it is
always rendered on top of all 3D geometry, which may or may not be
desirable in your case.
I'd really avoid using vtkVectorText if at all possible (ie. unless you
*really* need the text to be rendered as polydata instead of a textured
quad). I think the vtkTextMapper/vtkFollower approach would make the most
sense here.
Cheers,
Dave
On Fri, Feb 10, 2017 at 4:18 AM, M. Jordan <mjordan at live.at> wrote:
> Thank you very much!
>
> I am using VTK 7.0 and I think vtkBillboardTextActor3D is not available
> in this version.
> I tried vtkTextActor3D but I need a text which is always facing the camera.
>
> I think it must be possible to calculate a new position point P' (bottom
> left corner) which leads to a text
> whose center is at the desired position P.
>
> I tried to use follower->getCenter() to get the center of the bounding box
> of my text. But now I don't know how to shift
> the position point (bottom left corner) in a manner that the center point
> = my desired position.
>
>
>
>
>
> ------------------------------
> *Von:* David Lonie <david.lonie at kitware.com>
> *Gesendet:* Donnerstag, 09. Februar 2017 18:35
> *An:* M. Jordan
> *Cc:* vtkusers at vtk.org
> *Betreff:* Re: [vtkusers] vtkTextActor align to center of text
>
> You'll likely have better luck using vtkTextActor3D or
> vtkBillboardTextActor3D. These have vtkTextProperties you can modify
> to set things like justification/alignment.
>
> HTH,
> Dave
>
> On Thu, Feb 9, 2017 at 6:37 AM, M. Jordan <mjordan at live.at> wrote:
> > Hi,
> >
> > I am creating a 3D text like this:
> >
> > // create text
> > vtkSmartPointer<vtkVectorText> textSource =
> > vtkSmartPointer<vtkVectorText>::New();
> > textSource->SetText("TEST");
> > textSource->Update();
> > // create a mapper for the text
> > vtkSmartPointer<vtkPolyDataMapper> txtmapper =
> > vtkSmartPointer<vtkPolyDataMapper>::New();
> > txtmapper->SetInputConnection(transformFilter->GetOutputPort());
> > // create a subclass of vtkActor: a vtkFollower that remains facing the
> > camera
> > vtkSmartPointer<vtkFollower> follower =
> > vtkSmartPointer<vtkFollower>::New();
> > follower->SetMapper(txtmapper);
> > follower->SetCamera(renderer->GetActiveCamera());
> > follower->SetPosition(10.0,20.0,30.0);
> >
> > Now the passed follower position is approximately the bottom left corner
> of
> > my text.
> >
> > How can I achieve a text which is centered about my desired position?
> > For example the text "101" should result in a 3D text with the center
> being
> > located in the middle of the "0"
> >
> > Thank you very much!
> >
> >
> >
> > _______________________________________________
> > Powered by www.kitware.com
> <http://www.kitware.com/>
> Kitware Inc. - leading edge, high-quality software
> <http://www.kitware.com/>
> www.kitware.com
> Kitware's mission is to create state-of-the-art software products and
> services in visualization and data processing using advanced quality
> software methods and ...
>
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> OPEN SOURCE - Kitware <http://www.kitware.com/opensource/opensource.html>
> www.kitware.com
> Kitware develops, maintains and supports a wide array of toolkits and
> applications that are used by tens of thousands of software developers,
> researchers and ...
>
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Search the list archives at: http://markmail.org/search/?q=vtkusers
> >
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/vtkusers
> vtkusers Info Page - Kitware
> <http://public.kitware.com/mailman/listinfo/vtkusers>
> public.kitware.com
> To see the collection of prior postings to the list, visit the vtkusers
> Archives. Using vtkusers: To post a message to all the list members, send
> ...
>
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170210/99a6b52e/attachment.html>
More information about the vtkusers
mailing list