Skip to content

Commit

Permalink
BUG: Ensure All Events are Processed through the VR CustomProcessEven…
Browse files Browse the repository at this point in the history
…ts Callback

Following the previous commit titled "BUG: Ensure passing of vtkEventData to
displayable managers," this update guarantees the effective invocation of the
newly introduced custom delegation function, designed to handle a calldata
argument. This ensures that all processing is funneled through the
`vtkVirtualRealityViewInteractorObserver::CustomProcessEvents` callback. The
callback is responsible for handling 3D event data and passing it down appropriately.
  • Loading branch information
jcfr committed Dec 21, 2023
1 parent 4a1c0be commit 969f93b
Showing 1 changed file with 9 additions and 46 deletions.
55 changes: 9 additions & 46 deletions VirtualReality/MRML/vtkVirtualRealityViewInteractorObserver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,50 +34,18 @@
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkVirtualRealityViewInteractorObserver);

//----------------------------------------------------------------------------
class vtkVirtualRealityViewInteractorObserver::vtkInternal
{
public:
vtkInternal(vtkVirtualRealityViewInteractorObserver* external);
~vtkInternal();

public:
vtkVirtualRealityViewInteractorObserver* External{nullptr};
vtkCallbackCommand* EventCallbackCommand{nullptr};
};


//---------------------------------------------------------------------------
// vtkInternal methods

//---------------------------------------------------------------------------
vtkVirtualRealityViewInteractorObserver::vtkInternal::vtkInternal(vtkVirtualRealityViewInteractorObserver* external)
: External(external)
{
this->EventCallbackCommand = vtkCallbackCommand::New();
this->EventCallbackCommand->SetClientData(this->External);
this->EventCallbackCommand->SetCallback(vtkVirtualRealityViewInteractorObserver::CustomProcessEvents);
}

//---------------------------------------------------------------------------
vtkVirtualRealityViewInteractorObserver::vtkInternal::~vtkInternal()
{
this->EventCallbackCommand->Delete();
}

//---------------------------------------------------------------------------
// vtkVirtualRealityViewInteractorObserver methods

//----------------------------------------------------------------------------
vtkVirtualRealityViewInteractorObserver::vtkVirtualRealityViewInteractorObserver()
{
this->Internal = new vtkInternal(this);
this->EventCallbackCommand->SetCallback(vtkVirtualRealityViewInteractorObserver::CustomProcessEvents);
}

//----------------------------------------------------------------------------
vtkVirtualRealityViewInteractorObserver::~vtkVirtualRealityViewInteractorObserver()
{
delete this->Internal;
}

//----------------------------------------------------------------------------
Expand All @@ -93,11 +61,6 @@ void vtkVirtualRealityViewInteractorObserver::SetInteractor(vtkRenderWindowInter
{
return;
}
// if we already have an Interactor then stop observing it
if (this->Interactor)
{
this->Interactor->RemoveObserver(this->Internal->EventCallbackCommand);
}

this->Superclass::SetInteractor(interactor);

Expand All @@ -108,14 +71,14 @@ void vtkVirtualRealityViewInteractorObserver::SetInteractor(vtkRenderWindowInter
/// 3D event bindings
// Move3DEvent: Already observed in vtkMRMLViewInteractorStyle
// Button3DEvent: Already observed in vtkMRMLViewInteractorStyle
interactor->AddObserver(vtkCommand::Menu3DEvent, this->Internal->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::Select3DEvent, this->Internal->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::NextPose3DEvent, this->Internal->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::ViewerMovement3DEvent, this->Internal->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::Pick3DEvent, this->Internal->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::PositionProp3DEvent, this->Internal->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::Clip3DEvent, this->Internal->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::Elevation3DEvent, this->Internal->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::Menu3DEvent, this->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::Select3DEvent, this->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::NextPose3DEvent, this->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::ViewerMovement3DEvent, this->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::Pick3DEvent, this->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::PositionProp3DEvent, this->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::Clip3DEvent, this->EventCallbackCommand, priority);
interactor->AddObserver(vtkCommand::Elevation3DEvent, this->EventCallbackCommand, priority);

/// Touch gesture interaction events
// Already observed in vtkMRMLViewInteractorStyle
Expand Down

0 comments on commit 969f93b

Please sign in to comment.