[vtkusers] vtkCaptionActor2D not filling its prop correctly

David Lonie david.lonie at kitware.com
Fri Sep 23 11:08:47 EDT 2016


"That's not a bug, it's a feature" ;)

VTK previously used a "tight" bounding box for aligning/sizing text, which
gives better results in cases like this. However, this caused issues with
animations in ParaView, since if a string changed height by gaining/losing
ascenders (e.g. "T" vs "n") or descenders (e.g. "j" vs "i"), the text would
jump around. So the change was made to have all strings always account for
ascenders/descenders to keep the baseline consistent in such cases.

Dan Lipsa very recently added the option to vtkTextProperty to use a tight
bounding box:

https://gitlab.kitware.com/vtk/vtk/merge_requests/1925

This is available in master, and should be in the upcoming 7.1 release. It
should allow you to render strings like in the "before" image.

HTH,
Dave

On Fri, Sep 23, 2016 at 7:27 AM, Tiago Nobrega <tigarmo at gmail.com> wrote:

> Hello,
>
> I apologize for not reading the guidelines properly and submitting an
> issue on Gitlab before trying the mailing list. Here's my issue:
>
> We are in the process of updating VTK from 6.3 to 7.0 and some of our
> tests are failing because text actors are being rendered differently. This
> usually happens when we update the library (minor differences are to be
> expected) but in this particular case it looks like a regression.
>
> The following code (python):
>
> ```python
> import vtk
>
> ren1 = vtk.vtkRenderer()
> renWin = vtk.vtkRenderWindow()
> renWin.AddRenderer(ren1)
> iren = vtk.vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
>
> prop_1 = vtk.vtkCaptionActor2D()
> prop_1.SetCaption('Hello')
> prop_1.SetAttachmentPoint((-0.1, 0.0, 0.0))
>
> prop_1.GetCaptionTextProperty().Modified()
>
> ren1.AddActor(prop_1)
> ren1.SetBackground(0, 0, 0)
> ren1.GetActiveCamera().SetFocalPoint(0,0,0)
> ren1.GetActiveCamera().SetPosition(1,0,0)
> ren1.GetActiveCamera().SetViewUp(0,0,1)
> ren1.ResetCamera()
> renWin.SetSize(500, 500)
>
> iren.Start()
> ```
>
> ... generates two different renderings depending on the version, as shown
> on the following image:
>
> http://imgur.com/w8VXM8z
>
> The left side is VTK 6.3, and the right one is 7.0. Both ran on a Windows
> 10 machine, but the issue was replicated on our Linux boxes too. In all
> cases we're still using the old OpenGL backend and not the new OpenGL2 one.
> The behavior in version 6.3 seems more "correct" in the sense that the text
> is more fully filling up the rectangle, with the default scaling mode being
> to scale to the prop. I've investigated the commit history for the classes
> that seem relevant - vtkCaptionActor2D, vtkTextActor, vtkTextProperty, etc
> - but nothing stood out as possible "culprits".
>
> Let me know if you need further info or clarifications. Thanks.
>
> Tiago Nobrega
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160923/bed73714/attachment.html>


More information about the vtkusers mailing list