Skip to content

Commit

Permalink
BUG: Ensure passing of vtkEventData to displayable managers
Browse files Browse the repository at this point in the history
This commit follows up to "BUG: Fix integration with updated Slicer event
delegation and VTK OpenVR API". It ensures that existing event data objects
are consistently passed down to the `Delegate` functions and associated
displayable managers.
  • Loading branch information
jcfr committed Dec 21, 2023
1 parent d9671b2 commit 4a1c0be
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
24 changes: 23 additions & 1 deletion VirtualReality/MRML/vtkVirtualRealityViewInteractorObserver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void vtkVirtualRealityViewInteractorObserver::CustomProcessEvents(vtkObject* obj
vtkVirtualRealityViewInteractorObserver* self
= reinterpret_cast<vtkVirtualRealityViewInteractorObserver *>(clientdata);

if (!self->DelegateInteractionEventToDisplayableManagers(event) || self->GetInteractorStyle()->GetState() != VTKIS_NONE)
if (!self->DelegateInteractionEventToDisplayableManagers(event, calldata))
{
// Displayable managers did not process it
vtkVirtualRealityViewInteractorObserver::ProcessEvents(object, event, clientdata, calldata);
Expand Down Expand Up @@ -196,6 +196,28 @@ void vtkVirtualRealityViewInteractorObserver::ProcessEvents(
// Generic events binding
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
bool vtkVirtualRealityViewInteractorObserver::DelegateInteractionEventToDisplayableManagers(unsigned long event, void* calldata)
{
vtkSmartPointer<vtkEventData> ed;
if (vtkCommand::EventHasData(event))
{
ed = vtkSmartPointer(static_cast<vtkEventData*>(calldata));
}
else
{
ed = vtkSmartPointer<vtkMRMLInteractionEventData>::New();
ed->SetType(event);
}

bool delegated = this->DelegateInteractionEventToDisplayableManagers(ed);
if (delegated)
{
this->EventCallbackCommand->SetAbortFlag(1);
}
return delegated;
}

//----------------------------------------------------------------------------
bool vtkVirtualRealityViewInteractorObserver::DelegateInteractionEventToDisplayableManagers(vtkEventData* inputEventData)
{
Expand Down
13 changes: 11 additions & 2 deletions VirtualReality/MRML/vtkVirtualRealityViewInteractorObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,20 @@ class VTK_SLICER_VIRTUALREALITY_MODULE_MRML_EXPORT vtkVirtualRealityViewInteract
vtkTypeMacro(vtkVirtualRealityViewInteractorObserver,vtkMRMLViewInteractorStyle);
void PrintSelf(ostream& os, vtkIndent indent) override;

using vtkMRMLViewInteractorStyle::DelegateInteractionEventToDisplayableManagers;

/// Give a chance to displayable managers to process the event.
/// Based on the return of vtkCommand::EventHasData(event), it either casts the
/// calldata to a vtkEventData or just creates a one of type vtkMRMLInteractionEventData.
/// In both case, it calls DelegateInteractionEventDataToDisplayableManagers
/// passing a vtkEventData object.
/// Return true if the event is processed.
virtual bool DelegateInteractionEventToDisplayableManagers(unsigned long event, void* calldata);

/// Give a chance to displayable managers to process the event.
/// It just creates vtkMRMLInteractionEventData and calls
/// It creates vtkMRMLInteractionEventData and calls
/// DelegateInteractionEventDataToDisplayableManagers.
/// Return true if the event is processed.
using vtkMRMLViewInteractorStyle::DelegateInteractionEventToDisplayableManagers;
bool DelegateInteractionEventToDisplayableManagers(vtkEventData* inputEventData) override;

/// Give a chance to displayable managers to process the event.
Expand Down

0 comments on commit 4a1c0be

Please sign in to comment.