[vtkusers] Why is the text of vtkCaptionWidget displayed at the default position no matter what position value I set?

Liu_tj tjlp at netease.com
Tue Oct 25 10:39:50 EDT 2016


Hi,David,

Yes, I already call rep.SetAnchorPosition(pointer) to set the anchor position, which is also the attachment point.

Thanks

Liu Peng



在2016-10-25,"David Lonie" <david.lonie at kitware.com> 写道: -----原始邮件-----
发件人:"David Lonie" <david.lonie at kitware.com>
发送时间:2016年10月25日 星期二
收件人:"Liu_tj" <tjlp at netease.com>
抄送:"vtkusers" <vtkusers at vtk.org>
主题:Re: Re: [vtkusers] Why is the text of vtkCaptionWidget displayed at the default position no matter what position value I set?


Are you also setting the attachment point? From the vtkCaptionActor2D docs:


 * To use the caption actor, you normally specify the Position and Position2
 * coordinates (these are inherited from the vtkActor2D superclass). (Note
 * that Position2 can be set using vtkActor2D's SetWidth() and SetHeight()
 * methods.)  Position and Position2 define the size of the caption, and a
 * third point, the AttachmentPoint, defines a point that the caption is
 * associated with.

Also relevant:

 * The trickiest part about using this class is setting Position, Position2,
 * and AttachmentPoint correctly. These instance variables are
 * vtkCoordinates, and can be set up in various ways. In default usage, the
 * AttachmentPoint is defined in the world coordinate system, Position is the
 * lower-left corner of the caption and relative to AttachmentPoint (defined
 * in display coordaintes, i.e., pixels), and Position2 is relative to
 * Position and is the upper-right corner (also in display
 * coordinates).


HTH,
Dave


On Tue, Oct 25, 2016 at 10:02 AM, Liu_tj <tjlp at netease.com> wrote:
Hi, David,

I follow your tips. It doesn't work. The text is still displayed at the default position.

Thanks
Liu Peng





在2016-10-24,"David Lonie" <david.lonie at kitware.com> 写道:
收件人:"Liu_tj" <tjlp at netease.com>
抄送:"vtkusers" <vtkusers at vtk.org>
主题:Re: [vtkusers] Why is the text of vtkCaptionWidget displayed at the default position no matter what position value I set?



On Sun, Oct 23, 2016 at 11:13 AM, Liu_tj <tjlp at netease.com> wrote:

Hi, VTK guys,

When I display a vtkCaptionWidget, I want to set the position of the text. So I call the vtkActor2D:;SetPostion() and SetPosition2(), but when the widget is displayed, the text is alway at the left bottom corner, why? Below is my C# code:
[snip]
rep.GetCaptionActor2D().GetTextActor().SetPosition(textPos1[0], textPos1[1]);
rep.GetCaptionActor2D().GetTextActor().SetPosition2(textPos2[0], textPos2[1]);



Try just setting the position of the caption actor itself. When the caption actor renders, it sets the text actor's position. So,


rep.GetCaptionActor2D().SetPosition(textPos1[0], textPos1[1]);
rep.GetCaptionActor2D().SetPosition2(textPos2[0], textPos2[1]);


should get you what you want.


HTH,
Dave




 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161025/504e09c0/attachment.html>


More information about the vtkusers mailing list