Skip to content

Commit

Permalink
BUG: Do not report "Unrecognized device" if handling complex gesture
Browse files Browse the repository at this point in the history
Since complex gesture are not associated with a specific controller, the
associated event will be a synthesized one not associated with any particular
device.
  • Loading branch information
jcfr committed Dec 21, 2023
1 parent 22eba9f commit af3efbe
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/c++",
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
6 changes: 6 additions & 0 deletions VirtualReality/MRML/vtkVirtualRealityViewInteractor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ vtkVirtualRealityViewInteractor::~vtkVirtualRealityViewInteractor()
{
}

//------------------------------------------------------------------------------
vtkCommand::EventIds vtkVirtualRealityViewInteractor::GetCurrentGesture() const
{
return this->CurrentGesture;
}

//------------------------------------------------------------------------------
void vtkVirtualRealityViewInteractor::HandleComplexGestureEvents(vtkEventData* ed)
{
Expand Down
6 changes: 6 additions & 0 deletions VirtualReality/MRML/vtkVirtualRealityViewInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class VTK_SLICER_VIRTUALREALITY_MODULE_MRML_EXPORT vtkVirtualRealityViewInteract

virtual void SetInteractorStyle(vtkInteractorObserver*) override;

/// Return the identifier of the complex gesture being handled.
/// \sa HandleComplexGestureEvents(), RecognizeComplexGesture()
/// \sa vtkVirtualRealityViewInteractorStyle::OnStartGesture()
/// \sa vtkVirtualRealityViewInteractorStyle::OnEndGesture()
vtkCommand::EventIds GetCurrentGesture() const;

///@{
/// Define Slicer specific heuristic for handling complex gestures.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "vtkVirtualRealityViewInteractorObserver.h"

// SlicerVirtualReality includes
#include "vtkVirtualRealityViewInteractor.h"
#include "vtkVirtualRealityViewInteractorStyle.h"

// MRML includes
Expand Down Expand Up @@ -222,6 +223,9 @@ bool vtkVirtualRealityViewInteractorObserver::DelegateInteractionEventDataToDisp
vtkRenderer* currentRenderer = this->GetInteractorStyle()->GetCurrentRenderer();
ed->SetRenderer(currentRenderer);

vtkVirtualRealityViewInteractor* vrViewInteractor =
vtkVirtualRealityViewInteractor::SafeDownCast(this->GetInteractor());

std::string interactionContextName;
if (ed->GetDevice() == vtkEventDataDevice::LeftController)
{
Expand All @@ -235,8 +239,9 @@ bool vtkVirtualRealityViewInteractorObserver::DelegateInteractionEventDataToDisp
{
interactionContextName = "HeadMountedDisplay";
}
else
else if (vrViewInteractor && vrViewInteractor->GetCurrentGesture() == vtkCommand::NoEvent)
{
// Report an error message only if the interactor is not processing a complex gesture.
vtkErrorMacro("DelegateInteractionEventDataToDisplayableManagers: Unrecognized device");
}
ed->SetInteractionContextName(interactionContextName);
Expand Down

0 comments on commit af3efbe

Please sign in to comment.