diff --git a/Source/ViewerVTK/imstkVTKInteractorStyleVR.cpp b/Source/ViewerVTK/imstkVTKInteractorStyleVR.cpp index 74a2d030bfee3c06ed318b88b894f317eff7ed2a..b7d0fce20c0ff662692631e24c13f007f92d96e2 100644 --- a/Source/ViewerVTK/imstkVTKInteractorStyleVR.cpp +++ b/Source/ViewerVTK/imstkVTKInteractorStyleVR.cpp @@ -26,8 +26,7 @@ #include <vtkMath.h> #include <vtkEventData.h> #include <vtkObjectFactory.h> -#include "imstkVtkOpenVRRenderWindowInteractor2.h" -//#include <vtkOpenVRRenderWindowInteractor.h> +#include "imstkVtkOpenVRRenderWindowInteractorImstk.h" vtkStandardNewMacro(vtkInteractorStyleVR); @@ -73,8 +72,8 @@ vtkInteractorStyleVR::OnButtonPress(vtkEventData* data, int buttonId) void vtkInteractorStyleVR::addMovementActions() { - vtkOpenVRRenderWindowInteractor2* iren = - vtkOpenVRRenderWindowInteractor2::SafeDownCast(GetInteractor()); + vtkOpenVRRenderWindowInteractorImstk* iren = + vtkOpenVRRenderWindowInteractorImstk::SafeDownCast(GetInteractor()); CHECK(iren->GetInitialized()) << "Cannot addMovementActions to style until " "interactor has been initialized"; iren->AddAction("/actions/vtk/in/LeftGripMovement", true, @@ -96,8 +95,8 @@ vtkInteractorStyleVR::addMovementActions() void vtkInteractorStyleVR::addButtonActions() { - vtkOpenVRRenderWindowInteractor2* iren = - vtkOpenVRRenderWindowInteractor2::SafeDownCast(GetInteractor()); + vtkOpenVRRenderWindowInteractorImstk* iren = + vtkOpenVRRenderWindowInteractorImstk::SafeDownCast(GetInteractor()); CHECK(iren->GetInitialized()) << "Cannot addButtonActions to style until " "interactor has been initialized"; diff --git a/Source/ViewerVTK/imstkVTKOpenVRViewer.cpp b/Source/ViewerVTK/imstkVTKOpenVRViewer.cpp index 89a952cd07d0d626fcdd29c73f26d650363e313c..d91f7817a8b4ca7b886a3017ebf754ec292b4f00 100644 --- a/Source/ViewerVTK/imstkVTKOpenVRViewer.cpp +++ b/Source/ViewerVTK/imstkVTKOpenVRViewer.cpp @@ -28,9 +28,8 @@ #include "imstkVTKInteractorStyleVR.h" #include "imstkVTKRenderer.h" -#include "imstkVtkOpenVRRenderWindowInteractor2.h" +#include "imstkVtkOpenVRRenderWindowInteractorImstk.h" -//#include <vtkOpenVRRenderWindowInteractor.h> #include <vtkMatrix4x4.h> #include <vtkOpenVRRenderer.h> #include <vtkOpenVRRenderWindow.h> @@ -45,7 +44,7 @@ VTKOpenVRViewer::VTKOpenVRViewer(std::string name) : AbstractVTKViewer(name) m_vtkInteractorStyle = vrInteractorStyle; // Create the interactor - auto iren = vtkSmartPointer<vtkOpenVRRenderWindowInteractor2>::New(); + auto iren = vtkSmartPointer<vtkOpenVRRenderWindowInteractorImstk>::New(); iren->SetInteractorStyle(m_vtkInteractorStyle); // Create the RenderWindow @@ -149,7 +148,7 @@ void VTKOpenVRViewer::processEvents() { // Custom call to only process input events, do not perform a render - auto iren = vtkOpenVRRenderWindowInteractor2::SafeDownCast(m_vtkRenderWindow->GetInteractor()); + auto iren = vtkOpenVRRenderWindowInteractorImstk::SafeDownCast(m_vtkRenderWindow->GetInteractor()); auto ren = std::dynamic_pointer_cast<imstk::VTKRenderer>(getActiveRenderer()); iren->DoOneEvent(vtkOpenVRRenderWindow::SafeDownCast(m_vtkRenderWindow), ren->getVtkRenderer(), false); @@ -170,7 +169,7 @@ VTKOpenVRViewer::initModule() // VR interactor doesn't support timers, here we throw timer event every update // another option would be to conform VTKs VR interactor - auto iren = vtkOpenVRRenderWindowInteractor2::SafeDownCast(m_vtkRenderWindow->GetInteractor()); + auto iren = vtkOpenVRRenderWindowInteractorImstk::SafeDownCast(m_vtkRenderWindow->GetInteractor()); //iren->Start(); // Cannot use if (iren->HasObserver(vtkCommand::StartEvent)) { diff --git a/Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractor2.cpp b/Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractorImstk.cpp similarity index 90% rename from Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractor2.cpp rename to Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractorImstk.cpp index 2753a4a1d84f76a0a08b9b6d8e61fc6aa0761f4c..25c6e50f6b7fe130a20d12601f23fd10069a7aaf 100644 --- a/Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractor2.cpp +++ b/Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractorImstk.cpp @@ -21,7 +21,7 @@ #include "vtkOpenGLState.h" #include "vtkOpenVROverlay.h" #include "vtkOpenVRRenderWindow.h" -#include "imstkVtkOpenVRRenderWindowInteractor2.h" +#include "imstkVtkOpenVRRenderWindowInteractorImstk.h" #include "vtkRendererCollection.h" #include "vtkVRRenderWindow.h" @@ -38,16 +38,16 @@ #include "vtkTransform.h" #include <vtksys/SystemTools.hxx> -vtkStandardNewMacro(vtkOpenVRRenderWindowInteractor2); +vtkStandardNewMacro(vtkOpenVRRenderWindowInteractorImstk); -void (*vtkOpenVRRenderWindowInteractor2::ClassExitMethod)(void*) = (void (*)(void*)) nullptr; -void* vtkOpenVRRenderWindowInteractor2::ClassExitMethodArg = (void*)nullptr; -void (*vtkOpenVRRenderWindowInteractor2::ClassExitMethodArgDelete)( +void (*vtkOpenVRRenderWindowInteractorImstk::ClassExitMethod)(void*) = (void (*)(void*)) nullptr; +void* vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArg = (void*)nullptr; +void (*vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArgDelete)( void*) = (void (*)(void*)) nullptr; //------------------------------------------------------------------------------ // Construct object so that light follows camera motion. -vtkOpenVRRenderWindowInteractor2::vtkOpenVRRenderWindowInteractor2() +vtkOpenVRRenderWindowInteractorImstk::vtkOpenVRRenderWindowInteractorImstk() { vtkNew<vtkOpenVRInteractorStyle> style; this->SetInteractorStyle(style); @@ -61,34 +61,34 @@ vtkOpenVRRenderWindowInteractor2::vtkOpenVRRenderWindowInteractor2() } //------------------------------------------------------------------------------ -vtkOpenVRRenderWindowInteractor2::~vtkOpenVRRenderWindowInteractor2() = default; +vtkOpenVRRenderWindowInteractorImstk::~vtkOpenVRRenderWindowInteractorImstk() = default; -void vtkOpenVRRenderWindowInteractor2::SetPhysicalScale(double scale) +void vtkOpenVRRenderWindowInteractorImstk::SetPhysicalScale(double scale) { vtkVRRenderWindow* win = vtkVRRenderWindow::SafeDownCast(this->RenderWindow); win->SetPhysicalScale(scale); } -double vtkOpenVRRenderWindowInteractor2::GetPhysicalScale() +double vtkOpenVRRenderWindowInteractorImstk::GetPhysicalScale() { vtkVRRenderWindow* win = vtkVRRenderWindow::SafeDownCast(this->RenderWindow); return win->GetPhysicalScale(); } -void vtkOpenVRRenderWindowInteractor2::SetPhysicalTranslation( +void vtkOpenVRRenderWindowInteractorImstk::SetPhysicalTranslation( vtkCamera*, double t1, double t2, double t3) { vtkVRRenderWindow* win = vtkVRRenderWindow::SafeDownCast(this->RenderWindow); win->SetPhysicalTranslation(t1, t2, t3); } -double* vtkOpenVRRenderWindowInteractor2::GetPhysicalTranslation(vtkCamera*) +double* vtkOpenVRRenderWindowInteractorImstk::GetPhysicalTranslation(vtkCamera*) { vtkVRRenderWindow* win = vtkVRRenderWindow::SafeDownCast(this->RenderWindow); return win->GetPhysicalTranslation(); } -void vtkOpenVRRenderWindowInteractor2::ConvertOpenVRPoseToMatrices( +void vtkOpenVRRenderWindowInteractorImstk::ConvertOpenVRPoseToMatrices( const vr::TrackedDevicePose_t & tdPose, vtkMatrix4x4 * poseMatrixWorld, vtkMatrix4x4 * poseMatrixPhysical /*=nullptr*/) { @@ -119,7 +119,7 @@ void vtkOpenVRRenderWindowInteractor2::ConvertOpenVRPoseToMatrices( } } -void vtkOpenVRRenderWindowInteractor2::ConvertPoseToWorldCoordinates( +void vtkOpenVRRenderWindowInteractorImstk::ConvertPoseToWorldCoordinates( const vr::TrackedDevicePose_t & tdPose, double pos[3], // Output world position double wxyz[4], // Output world orientation quaternion @@ -132,7 +132,7 @@ void vtkOpenVRRenderWindowInteractor2::ConvertPoseToWorldCoordinates( tdPose.mDeviceToAbsoluteTracking.m, pos, wxyz, ppos, wdir); } -void vtkOpenVRRenderWindowInteractor2::ConvertPoseMatrixToWorldCoordinates( +void vtkOpenVRRenderWindowInteractorImstk::ConvertPoseMatrixToWorldCoordinates( const float poseMatrix[3][4], double pos[3], // Output world position double wxyz[4], // Output world orientation quaternion @@ -243,7 +243,7 @@ bool GetDigitalActionState( } //------------------------------------------------------------------------------ -void vtkOpenVRRenderWindowInteractor2::StartEventLoop() +void vtkOpenVRRenderWindowInteractorImstk::StartEventLoop() { this->StartedMessageLoop = 1; this->Done = false; @@ -258,7 +258,7 @@ void vtkOpenVRRenderWindowInteractor2::StartEventLoop() } } -void vtkOpenVRRenderWindowInteractor2::ProcessEvents() +void vtkOpenVRRenderWindowInteractorImstk::ProcessEvents() { vtkOpenVRRenderWindow* renWin = vtkOpenVRRenderWindow::SafeDownCast(this->RenderWindow); @@ -266,7 +266,7 @@ void vtkOpenVRRenderWindowInteractor2::ProcessEvents() this->DoOneEvent(renWin, ren, true); } -void vtkOpenVRRenderWindowInteractor2::DoOneEvent(vtkOpenVRRenderWindow* renWin, vtkRenderer* ren, bool doRender) +void vtkOpenVRRenderWindowInteractorImstk::DoOneEvent(vtkOpenVRRenderWindow* renWin, vtkRenderer* ren, bool doRender) { if (!renWin || !ren) { @@ -354,7 +354,7 @@ void vtkOpenVRRenderWindowInteractor2::DoOneEvent(vtkOpenVRRenderWindow* renWin, actionSet.ulActionSet = this->ActionsetVTK; vr::VRInput()->UpdateActionState(&actionSet, sizeof(actionSet), 1); - for (int tracker = 0; tracker < vtkOpenVRRenderWindowInteractor2::NumberOfTrackers; tracker++) + for (int tracker = 0; tracker < vtkOpenVRRenderWindowInteractorImstk::NumberOfTrackers; tracker++) { vr::InputOriginInfo_t originInfo; vr::EVRInputError evriError = vr::VRInput()->GetOriginTrackedDeviceInfo( @@ -534,7 +534,7 @@ void vtkOpenVRRenderWindowInteractor2::DoOneEvent(vtkOpenVRRenderWindow* renWin, } } -void vtkOpenVRRenderWindowInteractor2::HandleGripEvents(vtkEventData * ed) +void vtkOpenVRRenderWindowInteractorImstk::HandleGripEvents(vtkEventData * ed) { vtkEventDataDevice3D* edata = ed->GetAsEventDataDevice3D(); if (!edata) @@ -592,7 +592,7 @@ void vtkOpenVRRenderWindowInteractor2::HandleGripEvents(vtkEventData * ed) } //------------------------------------------------------------------------------ -void vtkOpenVRRenderWindowInteractor2::RecognizeComplexGesture(vtkEventDataDevice3D*) +void vtkOpenVRRenderWindowInteractorImstk::RecognizeComplexGesture(vtkEventDataDevice3D*) { // Recognize gesture only if one button is pressed per controller int lhand = static_cast<int>(vtkEventDataDevice::LeftController); @@ -729,7 +729,7 @@ void vtkOpenVRRenderWindowInteractor2::RecognizeComplexGesture(vtkEventDataDevic } //------------------------------------------------------------------------------ -void vtkOpenVRRenderWindowInteractor2::AddAction( +void vtkOpenVRRenderWindowInteractorImstk::AddAction( std::string path, vtkCommand::EventIds eid, bool isAnalog) { auto& am = this->ActionMap[path]; @@ -744,7 +744,7 @@ void vtkOpenVRRenderWindowInteractor2::AddAction( } } -void vtkOpenVRRenderWindowInteractor2::AddAction( +void vtkOpenVRRenderWindowInteractorImstk::AddAction( std::string path, bool isAnalog, std::function<void(vtkEventData*)> func) { auto& am = this->ActionMap[path]; @@ -758,7 +758,7 @@ void vtkOpenVRRenderWindowInteractor2::AddAction( } //------------------------------------------------------------------------------ -void vtkOpenVRRenderWindowInteractor2::Initialize() +void vtkOpenVRRenderWindowInteractorImstk::Initialize() { // make sure we have a RenderWindow and camera if (!this->RenderWindow) @@ -810,7 +810,7 @@ void vtkOpenVRRenderWindowInteractor2::Initialize() } //------------------------------------------------------------------------------ -int vtkOpenVRRenderWindowInteractor2::InternalCreateTimer( +int vtkOpenVRRenderWindowInteractorImstk::InternalCreateTimer( int vtkNotUsed(timerId), int vtkNotUsed(timerType), unsigned long vtkNotUsed(duration)) { // todo @@ -818,7 +818,7 @@ int vtkOpenVRRenderWindowInteractor2::InternalCreateTimer( } //------------------------------------------------------------------------------ -int vtkOpenVRRenderWindowInteractor2::InternalDestroyTimer(int vtkNotUsed(platformTimerId)) +int vtkOpenVRRenderWindowInteractorImstk::InternalDestroyTimer(int vtkNotUsed(platformTimerId)) { // todo return 0; @@ -827,20 +827,20 @@ int vtkOpenVRRenderWindowInteractor2::InternalDestroyTimer(int vtkNotUsed(platfo //------------------------------------------------------------------------------ // Specify the default function to be called when an interactor needs to exit. // This callback is overridden by an instance ExitMethod that is defined. -void vtkOpenVRRenderWindowInteractor2::SetClassExitMethod(void (*f)(void*), void* arg) +void vtkOpenVRRenderWindowInteractorImstk::SetClassExitMethod(void (*f)(void*), void* arg) { - if (f != vtkOpenVRRenderWindowInteractor2::ClassExitMethod || - arg != vtkOpenVRRenderWindowInteractor2::ClassExitMethodArg) + if (f != vtkOpenVRRenderWindowInteractorImstk::ClassExitMethod || + arg != vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArg) { // delete the current arg if there is a delete method - if ((vtkOpenVRRenderWindowInteractor2::ClassExitMethodArg) && - (vtkOpenVRRenderWindowInteractor2::ClassExitMethodArgDelete)) + if ((vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArg) && + (vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArgDelete)) { - (*vtkOpenVRRenderWindowInteractor2::ClassExitMethodArgDelete)( - vtkOpenVRRenderWindowInteractor2::ClassExitMethodArg); + (*vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArgDelete)( + vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArg); } - vtkOpenVRRenderWindowInteractor2::ClassExitMethod = f; - vtkOpenVRRenderWindowInteractor2::ClassExitMethodArg = arg; + vtkOpenVRRenderWindowInteractorImstk::ClassExitMethod = f; + vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArg = arg; // no call to this->Modified() since this is a class member function } @@ -848,41 +848,41 @@ void vtkOpenVRRenderWindowInteractor2::SetClassExitMethod(void (*f)(void*), void //------------------------------------------------------------------------------ // Set the arg delete method. This is used to free user memory. -void vtkOpenVRRenderWindowInteractor2::SetClassExitMethodArgDelete(void (*f)(void*)) +void vtkOpenVRRenderWindowInteractorImstk::SetClassExitMethodArgDelete(void (*f)(void*)) { - if (f != vtkOpenVRRenderWindowInteractor2::ClassExitMethodArgDelete) + if (f != vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArgDelete) { - vtkOpenVRRenderWindowInteractor2::ClassExitMethodArgDelete = f; + vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArgDelete = f; // no call to this->Modified() since this is a class member function } } //------------------------------------------------------------------------------ -void vtkOpenVRRenderWindowInteractor2::PrintSelf(ostream & os, vtkIndent indent) +void vtkOpenVRRenderWindowInteractorImstk::PrintSelf(ostream & os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); os << indent << "StartedMessageLoop: " << this->StartedMessageLoop << endl; } //------------------------------------------------------------------------------ -void vtkOpenVRRenderWindowInteractor2::ExitCallback() +void vtkOpenVRRenderWindowInteractorImstk::ExitCallback() { if (this->HasObserver(vtkCommand::ExitEvent)) { this->InvokeEvent(vtkCommand::ExitEvent, nullptr); } - else if (vtkOpenVRRenderWindowInteractor2::ClassExitMethod) + else if (vtkOpenVRRenderWindowInteractorImstk::ClassExitMethod) { - (*vtkOpenVRRenderWindowInteractor2::ClassExitMethod)( - vtkOpenVRRenderWindowInteractor2::ClassExitMethodArg); + (*vtkOpenVRRenderWindowInteractorImstk::ClassExitMethod)( + vtkOpenVRRenderWindowInteractorImstk::ClassExitMethodArg); } this->TerminateApp(); } //------------------------------------------------------------------------------ -vtkEventDataDevice vtkOpenVRRenderWindowInteractor2::GetPointerDevice() +vtkEventDataDevice vtkOpenVRRenderWindowInteractorImstk::GetPointerDevice() { if (this->PointerIndex == 0) { @@ -896,7 +896,7 @@ vtkEventDataDevice vtkOpenVRRenderWindowInteractor2::GetPointerDevice() } //------------------------------------------------------------------------------ -void vtkOpenVRRenderWindowInteractor2::GetStartingPhysicalToWorldMatrix( +void vtkOpenVRRenderWindowInteractorImstk::GetStartingPhysicalToWorldMatrix( vtkMatrix4x4 * startingPhysicalToWorldMatrix) { if (!startingPhysicalToWorldMatrix) diff --git a/Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractor2.h b/Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractorImstk.h similarity index 90% rename from Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractor2.h rename to Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractorImstk.h index f6cb2ae805baffea4be916061dbbbfc8443ccdc4..379d87940cc00759228e523a2e465d6fc851514c 100644 --- a/Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractor2.h +++ b/Source/ViewerVTK/imstkVtkOpenVRRenderWindowInteractorImstk.h @@ -17,11 +17,13 @@ * @brief implements OpenVR specific functions * required by vtkOpenVRRenderWindowInteractor2. * - * + * Note: This class was introduced by iMSTK fixing the DoOneEvent to allow + * processing of VR events without render calls. Please remove this class + * when fixed in VTK */ -#ifndef vtkOpenVRRenderWindowInteractor2_h -#define vtkOpenVRRenderWindowInteractor2_h +#ifndef vtkOpenVRRenderWindowInteractorImstk_h +#define vtkOpenVRRenderWindowInteractorImstk_h #include "vtkEventData.h" // for ivar #include "vtkNew.h" // ivars @@ -38,15 +40,15 @@ class vtkMatrix4x4; class vtkOpenVROverlay; class vtkOpenVRRenderWindow; -class vtkOpenVRRenderWindowInteractor2 : public vtkRenderWindowInteractor3D +class vtkOpenVRRenderWindowInteractorImstk : public vtkRenderWindowInteractor3D { public: /** * Construct object so that light follows camera motion. */ - static vtkOpenVRRenderWindowInteractor2* New(); + static vtkOpenVRRenderWindowInteractorImstk* New(); - vtkTypeMacro(vtkOpenVRRenderWindowInteractor2, vtkRenderWindowInteractor3D); + vtkTypeMacro(vtkOpenVRRenderWindowInteractorImstk, vtkRenderWindowInteractor3D); void PrintSelf(ostream& os, vtkIndent indent); /** @@ -161,8 +163,8 @@ public: ///@} protected: - vtkOpenVRRenderWindowInteractor2(); - ~vtkOpenVRRenderWindowInteractor2() override; + vtkOpenVRRenderWindowInteractorImstk(); + ~vtkOpenVRRenderWindowInteractorImstk() override; ///@{ /** @@ -240,8 +242,8 @@ protected: void HandleGripEvents(vtkEventData* ed); private: - vtkOpenVRRenderWindowInteractor2(const vtkOpenVRRenderWindowInteractor2&) = delete; - void operator=(const vtkOpenVRRenderWindowInteractor2&) = delete; + vtkOpenVRRenderWindowInteractorImstk(const vtkOpenVRRenderWindowInteractorImstk&) = delete; + void operator=(const vtkOpenVRRenderWindowInteractorImstk&) = delete; }; #endif \ No newline at end of file