[vtkusers] vtkDistanceWidget and vtkCanvas

Sebastien Jourdain sebastien.jourdain at kitware.com
Wed Jan 18 08:17:02 EST 2012


Hi Marco,

I reply directly in your comment.

On Wed, Jan 18, 2012 at 5:06 AM, Marco Sambin <m.sambin at gmail.com> wrote:
> Hi Seb,
>
> first of all, thanks for your reply.
>
> What do you mean by "add your widget actor into the renderer"?
> It is my understanding that calling "SetInteractor(iren)" on the
> vtkDistanceWidget should be enough to see it working on screen. Am I
> correct, or I am missing some calls?

Yes, you are missing something, the interactor is needed so the widget
could interpret the user interaction (mouse), but this not change the
content of your 3d scene... Therefore, you still need to add
"something" to your renderer and even size your widget in the scene.
(PlaceWidget)

For more informations, you can look at that :
http://www.vtk.org/Wiki/VTK/Examples/Cxx#Widgets
and http://www.vtk.org/Wiki/VTK/Examples/Java

Hope this could help,

Seb

>
> Regarding the camera, well, I actually make a call to
> GetRenderer().ResetCamera() on my vtkCanvas, but since the
> vtkDistanceWidget is interaction-driven, shouldn't it appear in any
> case in the position where I am pressing my mouse (hence, within the
> viewing range of the camera)?
> In any case, calling ResetCamera() before or after I pressed my mouse
> buttons does not show anything.
>
> Do you have further suggestions?
>
> Thanks again for your time.
>
> Regards,
>
> Marco
>
>
> 2012/1/17 Sebastien Jourdain <sebastien.jourdain at kitware.com>:
>> Just quickly... Did you add your widget actor into the renderer ?
>> Did you reset the camera to be sure it is looking in the right direction ?
>>
>> Seb
>>
>> On Tue, Jan 17, 2012 at 1:10 PM, Marco Sambin <m.sambin at gmail.com> wrote:
>>> Hi all.
>>> I am trying to use a vtkDistanceWidget in my vtkCanvas-derived class.
>>>
>>> In the constructor of my vtkCanvas-derived class, I have the following code:
>>>
>>> [...]
>>>    // Initialize the measurements widget
>>>    vtkDistanceWidget distWidget = new vtkDistanceWidget();
>>>    distWidget.SetInteractor(iren);
>>>    vtkPointHandleRepresentation2D handle = new
>>> vtkPointHandleRepresentation2D();
>>>    handle.GetProperty().SetColor(1, 0, 0);
>>>    vtkDistanceRepresentation2D rep = new vtkDistanceRepresentation2D();
>>>    rep.SetHandleRepresentation(handle);
>>>    rep.GetAxis().SetNumberOfMinorTicks(4);
>>>    rep.GetAxis().SetTickLength(9);
>>>    rep.GetAxis().SetTitlePosition(0.2);
>>>    distWidget.SetRepresentation(rep);
>>>    distWidget.On();
>>> [...]
>>>
>>> For now, my vtkCanvas is empty, and there is no other relevant code in
>>> the constructor.
>>>
>>> I cannot get the vtkDistanceWidget to work. Nothing appears on screen
>>> when I left-press on my vtkCanvas.
>>>
>>> Am I missing something fundamental in order to have the
>>> vtkDistanceWidget to work?
>>>
>>> Thanks in advance for any hint.
>>>
>>> Best regards,
>>>
>>> Marco
>>> _______________________________________________
>>> 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
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list