<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Jul 2, 2016 at 4:12 AM, Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">However, since VTK no longer renders for every input event, I have to be careful when I use the VTK picker.  I wrote a method called UpdatePropsForPick() that I call for every input event, and it ensures that the picking works correctly regardless of whether the Render()s are actually happening.</div></div></blockquote><div><br></div></span><div>Ah, this is good advice. Would you mind sharing how it ensures this? Not necessarily in code, but just in a few words? I'm quite new to VTK and haven't done any picking yet.<br></div></div></div></div></blockquote><div><br></div><div>Here's the code.  It is only for pickers derived from vtkPicker (I use it with vtkCellPicker).  Pickers derived from vtkPicker work by interrogating the data, i.e. they don't use OpenGL for the picking.  Perhaps I should contribute this to VTK as a vtkPicker method.</div><div><br></div><div>void UpdatePropsForPick(vtkPicker *picker, vtkRenderer *renderer)</div><div>{</div><div>  // Go through all Prop3Ds that might be picked and update their data.</div><div>  // This is necessary if any data has changed since the last render.</div><div>  vtkPropCollection *props;</div><div>  if (picker->GetPickFromList()) {</div><div>    props = picker->GetPickList();</div><div>  }</div><div>  else {</div><div>    props = renderer->GetViewProps();</div><div>  }</div><div><br></div><div>  vtkProp *prop;</div><div>  vtkCollectionSimpleIterator pit;</div><div>  props->InitTraversal(pit);</div><div>  while ((prop = props->GetNextProp(pit)) != 0) {</div><div>    if (!prop->GetPickable() || !prop->GetVisibility()) {</div><div>      continue;</div><div>    }</div><div>    vtkAssemblyPath *path;</div><div>    prop->InitPathTraversal();</div><div>    while ((path = prop->GetNextPath()) != 0) {</div><div>      vtkProp *anyProp = path->GetLastNode()->GetViewProp();</div><div><br></div><div>      vtkActor *actor;</div><div>      vtkVolume *volume;</div><div>      vtkImageSlice *imageActor;</div><div><br></div><div>      if ((actor = vtkActor::SafeDownCast(anyProp)) != 0) {</div><div>        actor->GetMapper()->Update();</div><div>      }</div><div>      else if ((volume = vtkVolume::SafeDownCast(anyProp)) != 0) {</div><div>        volume->GetMapper()->Update();</div><div>      }</div><div>      else if ((imageActor = vtkImageSlice::SafeDownCast(anyProp)) != 0) {</div><div>        imageActor->GetMapper()->Update();</div><div>      }</div><div>    }</div><div>  }</div><div>} </div></div></div></div>