<br><br><div><span class="gmail_quote">On 4/17/06, <b class="gmail_sendername">Marc Cotran</b> &lt;<a href="mailto:marc@cotran.ca">marc@cotran.ca</a>&gt; wrote:</span><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
Here is some sample code that might assist you:<br><br>// First create the callback comand<br>class LeftClickCallback : public vtkCommand<br>{<br>public:<br>&nbsp;&nbsp;&nbsp;&nbsp;static LeftClickCallback *New()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ return new LeftClickCallback ; }
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;virtual void Execute(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vtkObject *caller,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unsigned long /* eventId */,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void * /*callData*/)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// left click was pressed, do what we want to do here<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// in your case, you probably want to find out which actor
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// was clicked (if any) and then set the actor's color (somehow)<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>};<br><br>// Then use the callback by attaching a new instance to the interactor style<br>LeftClickCallback *callback = LeftClickCallback ::New();
<br>myInteractorStyle-&gt;AddObserver(vtkCommand::LeftButtonPressEvent,<br>callback, 0);</blockquote><div><br>
Thanks Marc, this was most helpful!! Clicking left mouse button now runs my callback :-)<br>
<br>
I'm still struggling with finding out which actor I had just clicked, which was the original intention!<br>
<br>
Inside the LeftClickCallback::Execute <br>
<br>
vtkObject* caller<br>
<br>
is set to the vtkInteractorStyle I am observing. I then create a
vtkInteractorStyle* style = vktInteractorStyle::SafeDownCast( caller );<br>
<br>
but am still having trouble finding the Actor I had just clicked on, because<br>
<br>
style-&gt;GetInteractor()-&gt;GetPicker()<br>
<br>
is a vtkAbstractPicker and does not know anything about it's derived's<br>
<br>
vtkPicker::GetActors()<br>
<br>
hm... I've tried reinterpret_casting vtkAbstractPicker to vtkPicker but it (predictably) segfaults :-/<br>
<br>
any insights?<br>
<br>
Thank you for your patience and help! <br>
<br>
</div></div>-- <br><a href="mailto:stoptv@gmail.com">stoptv@gmail.com</a><br>
<br>