<div dir="auto">We should be able to do this.<br><br><div data-smartmail="gmail_signature">Andrew Maclean</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 Nov 2017 10:32, "Bill Lorensen" <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Andrew,<br>
<br>
I do want to make the examples available to at least 6.0 users. We can<br>
add c++ 11 stuff if we can exclude those examples based on VTK<br>
versions.<br>
<br>
Bill<br>
<br>
<br>
On Sat, Nov 11, 2017 at 6:07 PM, Andrew Maclean<br>
<<a href="mailto:andrew.amaclean@gmail.com">andrew.amaclean@gmail.com</a>> wrote:<br>
> I'll do an example for this.<br>
><br>
> I'm also thinking that since we are using C++11 we should be able to use<br>
> lambda expressions. I'll also do an example for that.<br>
><br>
> Regards<br>
> Andrew<br>
><br>
><br>
> On Sun, Nov 12, 2017 at 8:59 AM, Andrew Maclean <<a href="mailto:andrew.amaclean@gmail.com">andrew.amaclean@gmail.com</a>><br>
> wrote:<br>
>><br>
>> David,<br>
>><br>
>> When I try this I get:<br>
>> TypeError: DummyFunc() missing 1 required positional argument: 'data'<br>
>><br>
>> I used a slightly different approach in<br>
>> <a href="https://lorensen.github.io/VTKExamples/site/Python/VisualizationAlgorithms/StreamlinesWithLineWidget/" rel="noreferrer" target="_blank">https://lorensen.github.io/<wbr>VTKExamples/site/Python/<wbr>VisualizationAlgorithms/<wbr>StreamlinesWithLineWidget/</a><br>
>><br>
>> Regards<br>
>> Andrew<br>
>><br>
>> 2. Re:<br>
>> SetClientData in python (David Gobbi)<br>
>>><br>
>>> ---------- Forwarded message ----------<br>
>>> From: David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br>
>>> To:<br>
>>> "Serge K." <<a href="mailto:skab12@gmail.com">skab12@gmail.com</a>><br>
>>> Cc: VTK Users <<a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>><br>
>>> Bcc:<br>
>>> Date: Fri, 10 Nov 2017 11:17:26 -0700<br>
>>> Subject: Re: [vtkusers] SetClientData in python<br>
>>> Hi Serge,<br>
>>><br>
>>> The way to do this in Python is to add attributes to your callback<br>
>>> function.<br>
>>><br>
>>> def DummyFunc(obj, ev, data):<br>
>>> print(ev, data)<br>
>>><br>
>>><br>
>>> DummyFunc.CallData = whatever<br>
>>><br>
>>> interactor.AddObserver('<wbr>LeftButtonPressEvent', DummyFunc)<br>
>>><br>
>>> So the vtkCallbackCommand really isn't needed in Python (and, as you have<br>
>>> noticed, it really can't be used in Python anyway).<br>
>>><br>
>>> - David<br>
>>><br>
>>><br>
>>><br>
>>> On Fri, Nov 10, 2017 at 10:32 AM, Serge K. <<a href="mailto:skab12@gmail.com">skab12@gmail.com</a>> wrote:<br>
>>>><br>
>>>> Hi All,<br>
>>>><br>
>>>> I am playing with MouseEventObserver.py example and I would like to add<br>
>>>> a ClientData on my callback function. There are many examples in C++ like<br>
>>>> this one: <a href="https://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/ClientData" rel="noreferrer" target="_blank">https://www.vtk.org/Wiki/VTK/<wbr>Examples/Cxx/Interaction/<wbr>ClientData</a><br>
>>>><br>
>>>> However, I do not know how to do that in Python.<br>
>>>><br>
>>>> Indeed, if I create a vtkCallbackCommand , SetCallBack function does<br>
>>>> not exist.<br>
>>>><br>
>>>> Any Idea? Thanks for your answer.<br>
>>>><br>
>>>> Serge<br>
>>>><br>
>>>> ps: python36 - vtk 7.1.1<br>
>>>><br>
>>>><br>
>>>> #!/usr/bin/env python<br>
>>>> from __future__ import print_function<br>
>>>><br>
>>>> import vtk<br>
>>>><br>
>>>> source = vtk.vtkSphereSource()<br>
>>>> source.SetCenter(0, 0, 0)<br>
>>>> source.SetRadius(1)<br>
>>>> source.Update()<br>
>>>><br>
>>>> mapper = vtk.vtkPolyDataMapper()<br>
>>>> mapper.SetInputConnection(<wbr>source.GetOutputPort())<br>
>>>><br>
>>>> actor = vtk.vtkActor()<br>
>>>> actor.SetMapper(mapper)<br>
>>>><br>
>>>> renderer = vtk.vtkRenderer()<br>
>>>> renderer.SetBackground(1, 1, 1)<br>
>>>> renderer.AddActor(actor)<br>
>>>><br>
>>>> renwin = vtk.vtkRenderWindow()<br>
>>>> renwin.AddRenderer(renderer)<br>
>>>><br>
>>>> interactor = vtk.vtkRenderWindowInteractor(<wbr>)<br>
>>>> interactor.SetInteractorStyle(<wbr>vtk.<wbr>vtkInteractorStyleTrackballCam<wbr>era())<br>
>>>> interactor.SetRenderWindow(<wbr>renwin)<br>
>>>><br>
>>>> def DummyFunc(obj, ev, my_obj_2):<br>
>>>> print(obj, my_obj_2)<br>
>>>><br>
>>>> # obj_2 = vtk.whatever()<br>
>>>> # How do I pass my obj_2 ?<br>
>>>> interactor.AddObserver('<wbr>LeftButtonPressEvent', DummyFunc)<br>
>>>> interactor.Initialize()<br>
>>>> interactor.Start()<br>
>>><br>
>>><br>
>>><br>
>><br>
>> --<br>
>> ______________________________<wbr>_____________<br>
>> Andrew J. P. Maclean<br>
>><br>
>> ______________________________<wbr>_____________<br>
><br>
><br>
><br>
><br>
> --<br>
> ______________________________<wbr>_____________<br>
> Andrew J. P. Maclean<br>
><br>
> ______________________________<wbr>_____________<br>
><br>
> ______________________________<wbr>_________________<br>
> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
><br>
> Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
><br>
<br>
<br>
<br>
--<br>
Unpaid intern in BillsBasement at noware dot com<br>
</blockquote></div></div>