[vtkusers] vtkDistanceWidget and vtkCanvas

Sebastien Jourdain sebastien.jourdain at kitware.com
Wed Jan 18 11:39:00 EST 2012


Hi Marco,

looking at your test it seems that you managed to make your application work.
If I found the time, I'll look into the GC issue that you are reporting.

Thanks,

Seb

On Wed, Jan 18, 2012 at 11:36 AM, Sebastien Jourdain
<sebastien.jourdain at kitware.com> wrote:
> Hi Marco,
>
> keep the list in the loop so other could benefit from our discussion.
>
> Moreover, I'm sure you are still missing what I'm saying, but as I
> haven't done such thing in a while I can not tell you exactly how to
> do it, unless I do it myself.
>
> Seb
>
> On Wed, Jan 18, 2012 at 11:30 AM, Marco Sambin <m.sambin at gmail.com> wrote:
>> Hi Seb,
>>
>> thank you for your message.
>>
>> Actually, it looks like there is no PlaceWidget() call in vtkDistanceWidget.
>> I think the job of adding the appropriate actor(s) to the renderer is
>> carried out by the .On() call on the widget (corresponding to
>> .SetEnabled(1)). Am I correct?
>>
>> In any case, I am quite convinced I have found a (strange) issue in
>> VTK (I am using a nightly build dated 2011.12.15, Win 64-bit): don't
>> ask me why, but the vtkDistanceWidget seems not to work in vtkCanvas
>> when VTK's Java auto garbage collector is enabled.
>>
>> I attach a reproducible test case demonstrating the issue.
>> Maybe it could help you (VTK team) in fixing a possible bug.
>>
>> Best regards,
>>
>> Marco Sambin
>>
>>
>> 2012/1/18 Sebastien Jourdain <sebastien.jourdain at kitware.com>:
>>> 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