<br><br><div><span class="gmail_quote">On 4/17/06, <b class="gmail_sendername">Marc Cotran</b> <<a href="mailto:marc@cotran.ca">marc@cotran.ca</a>> 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> static LeftClickCallback *New()<br> { return new LeftClickCallback ; }
<br><br> virtual void Execute(<br> vtkObject *caller,<br> unsigned long /* eventId */,<br> void * /*callData*/)<br> {<br> // left click was pressed, do what we want to do here<br> // in your case, you probably want to find out which actor
<br> // was clicked (if any) and then set the actor's color (somehow)<br> }<br>};<br><br>// Then use the callback by attaching a new instance to the interactor style<br>LeftClickCallback *callback = LeftClickCallback ::New();
<br>myInteractorStyle->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->GetInteractor()->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>