<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div><span>Thanks for the suggestion, Miro.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>I actually implemented something similar.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>However, when I pick the actor I make it transparent.</span></div><div style="color: rgb(0, 0, 0);
font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div>When I then want to get the picked actor, I have to use vtkRenderer::PickProp because that apparently also picks transparent props. However, it is really slow... Any suggestion here?<br><br>Thanks - Maarten<br> <div class="qtdSeparateBR"><br><br></div><div style="display: block;" class="yahoo_quoted"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Wednesday, August 13, 2014 4:10:03 PM, Miro Drahos <mdrahos@robodoc.com> wrote:<br> </font> </div> <br><br> <div class="y_msg_container"><div id="yiv6514053819"><div>
Hi Maarten,<br clear="none">
I would suggest creating a callback and registering it with the
interactor's *ButtonPressEvent. The callback would manage its own
picker. Something like:<br clear="none">
<br clear="none">
<tt>//================================================<br clear="none">
class PickCallback : public vtkCommand</tt><tt><br clear="none">
</tt><tt>{</tt><tt><br clear="none">
</tt><tt>public :</tt><tt><br clear="none">
</tt><tt> static PickCallback * New() { return new PickCallback; }</tt><tt><br clear="none">
</tt><tt> void SetRenderer(vtkRenderer * r) { this->ren = r; }</tt><tt><br clear="none">
</tt><tt> void Execute(vtkObject *caller, unsigned long event, void
*)</tt><tt><br clear="none">
</tt><tt> {</tt><tt><br clear="none">
</tt><tt> if (this->ren == NULL)</tt><tt><br clear="none">
</tt><tt> return;</tt><tt><br clear="none">
</tt><tt><br clear="none">
</tt><tt> if (event == vtkCommand::LeftButtonPressEvent)</tt><tt><br clear="none">
</tt><tt> {</tt><tt><br clear="none">
</tt><tt> vtkRenderWindowInteractor * rwi =
vtkRenderWindowInteractor::SafeDownCast(caller);</tt><tt><br clear="none">
</tt><tt> if (rwi)</tt><tt><br clear="none">
</tt><tt> {</tt><tt><br clear="none">
</tt><tt> this->picker->Pick(x, y, this->ren);</tt><tt><br clear="none">
</tt><tt> vtkAssemblyPath * path =
this->picker->GetPath();</tt><tt><br clear="none">
</tt><tt> if (path)</tt><tt><br clear="none">
</tt><tt> {</tt><tt><br clear="none">
</tt><tt> // Something was picked for sure.</tt><tt><br clear="none">
</tt><tt> vtkProp * pickedProp =
path->GetLastNode()->GetViewProp();</tt><tt><br clear="none">
</tt><tt><br clear="none">
</tt><tt> // do something with the prop</tt><tt><br clear="none">
</tt><tt> }</tt><tt><br clear="none">
</tt><tt> }</tt><tt><br clear="none">
</tt><tt> }</tt><tt><br clear="none">
</tt><tt> }</tt><tt><br clear="none">
</tt><tt><br clear="none">
</tt><tt>private :</tt><tt><br clear="none">
</tt><tt> PickCallback() { </tt><tt><br clear="none">
</tt><tt> this->picker =
vtkSmartPointer<vtkCellPicker>::New(); </tt><tt><br clear="none">
</tt><tt> this->ren = NULL;</tt><tt><br clear="none">
</tt><tt> }</tt><tt><br clear="none">
</tt><tt> </tt><tt><br clear="none">
</tt><tt> vtkRenderer * ren;</tt><tt><br clear="none">
</tt><tt> vtkSmartPointer<vtkCellPicker> picker;</tt><tt><br clear="none">
</tt><tt>};</tt><tt><br clear="none">
<br clear="none">
</tt><tt>//---------------------------------------------------------------------<br clear="none">
</tt><tt>// How to use the callback:</tt><tt><br clear="none">
</tt><tt>vtkSmartPointer<PickCallback> cbk =
vtkSmartPointer<PickCallback>::New();</tt><tt><br clear="none">
cbk->SetRenderer(ren);<br clear="none">
</tt><tt>interactor->AddObserver(vtkCommand::LeftButtonPressEvent,
cbk);</tt><tt><br clear="none">
</tt><tt>//================================================<br clear="none">
<br clear="none">
</tt>Hope this helps,<br clear="none">
Miro<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<div class="yiv6514053819yqt0067484578" id="yiv6514053819yqt12253"><div class="yiv6514053819moz-cite-prefix">On 08/13/2014 09:29 AM, Maarten Beek
via vtkusers wrote:<br clear="none">
</div>
<blockquote type="cite">
<div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt;">
<div class="yiv6514053819" style="">Hi all,</div>
<div class="yiv6514053819" style=""><br class="yiv6514053819" style="" clear="none">
</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;">I noticed
that getting the currently picked actor from the picker in the
interactor doesn't always work.</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;">Some
interactor styles and widgets (e.g.
vtkInteractorstyleTrackballActor) have their own picker which
is used for the picking but which is different from the one in
the interactor.</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><br class="yiv6514053819" style="" clear="none">
</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;">I wrote a
class that has awareness of the interactor.</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;">I would
like to use this->Interactor->GetPicker() to get access
to the currently picked object. However this doesn't work with
observers like vtkInteractorstyleTrackballActor. Using
this->Interactor->GetInteractorStyle()->GetPicker()
is also not an option because not all observers use their own
picker (and a GetPicker() function does not exist in
vtkInteractorstyleTrackballActor).</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><br class="yiv6514053819" style="" clear="none">
</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;">The hack I
made was to derive from vtkInteractorstyleTrackballActor and
overload the SetInteractor() function:</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><br class="yiv6514053819" style="" clear="none">
</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;">void
MyClass::SetInteractor(vtkRenderWindowInteractor* rwi)</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;">{</div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style="">
this->Superclass::SetInteractor(rwi);</span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""> if(
this->Interactor != NULL )</span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""> {</span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""> <span class="yiv6514053819" style=""> vtkCellPicker* picker =
vtkCellPicker::New;</span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""> <span class="yiv6514053819" style="">
picker->SetTolerance(0.001);</span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""> <span class="yiv6514053819" style="">
this->Interactor->SetPicker(picker);</span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""> <span class="yiv6514053819" style=""> picker->Delete();</span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""> }</span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style="">}</span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><br class="yiv6514053819" style="" clear="none">
<span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""></span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style="">This works. But I'd
like to use MyClass with different
observers w/o having to derive from
all of them...</span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><br class="yiv6514053819" style="" clear="none">
<span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""></span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style="">I've also looked at
the PickingManager class since all
observers seems to register their
pickers, but firstly it is not enabled
by default and secondly to get the
current selection I have to call
GetAssemblyPath() which performs a
pick which I don't want because this
invokes a PickEvent.. I use the event
in MyClass but only when I pick an
object, not when I want the currently
picked object. Giving
vtkPickingManager a public
SelectedPicker() function (like </span></span></span></span></span></span></span></span></span></span></span></span><br class="yiv6514053819" style="" clear="none">
<span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style="">vtkPickingManager::Internal
has) would do the trick here..</span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><br clear="none">
<span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""></span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style="">I guess my question
is:</span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style="">How would a write
code to get the currently picked
object that works with various
observers when I only have awareness
of the interactor?</span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><br clear="none">
<span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""></span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style="">Maarten<br clear="none">
</span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><br class="yiv6514053819" style="" clear="none">
<span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""></span></span></span></span></span></span></span></span></span></span></span></span></div>
<div class="yiv6514053819" style="color:rgb(0, 0, 0);font-size:16px;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;background-color:transparent;font-style:normal;"><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><span class="yiv6514053819" style=""><br class="yiv6514053819" style="" clear="none">
</span></span></span></span></span></span></span></span></span></span></span></span></div>
</div>
</blockquote></div>
<br clear="none">
</div></div><br><br></div> </div> </div> </div> </div></body></html>