[vtkusers] Dealing with QTBUG-40889
Elvis Stansvik
elvis.stansvik at orexplore.com
Sat Jul 2 08:24:02 EDT 2016
2016-07-02 14:03 GMT+02:00 David Gobbi <david.gobbi at gmail.com>:
> On Sat, Jul 2, 2016 at 4:12 AM, Elvis Stansvik <
> elvis.stansvik at orexplore.com> wrote:
>
>>
>>> 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.
>>>
>>
>> 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.
>>
>
> 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.
>
Thanks a lot for this snippet. I'll get back to it should I need to do any
picking (I expect I will).
Elvis
> void UpdatePropsForPick(vtkPicker *picker, vtkRenderer *renderer)
> {
> // Go through all Prop3Ds that might be picked and update their data.
> // This is necessary if any data has changed since the last render.
> vtkPropCollection *props;
> if (picker->GetPickFromList()) {
> props = picker->GetPickList();
> }
> else {
> props = renderer->GetViewProps();
> }
>
> vtkProp *prop;
> vtkCollectionSimpleIterator pit;
> props->InitTraversal(pit);
> while ((prop = props->GetNextProp(pit)) != 0) {
> if (!prop->GetPickable() || !prop->GetVisibility()) {
> continue;
> }
> vtkAssemblyPath *path;
> prop->InitPathTraversal();
> while ((path = prop->GetNextPath()) != 0) {
> vtkProp *anyProp = path->GetLastNode()->GetViewProp();
>
> vtkActor *actor;
> vtkVolume *volume;
> vtkImageSlice *imageActor;
>
> if ((actor = vtkActor::SafeDownCast(anyProp)) != 0) {
> actor->GetMapper()->Update();
> }
> else if ((volume = vtkVolume::SafeDownCast(anyProp)) != 0) {
> volume->GetMapper()->Update();
> }
> else if ((imageActor = vtkImageSlice::SafeDownCast(anyProp)) != 0) {
> imageActor->GetMapper()->Update();
> }
> }
> }
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160702/951ed769/attachment.html>
More information about the vtkusers
mailing list