1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkOpenVRRenderWindowInteractor.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkOpenVRRenderWindowInteractor
* @brief Implements OpenVR specific functions required by vtkVRRenderWindowInteractor.
*/
#ifndef vtkOpenVRRenderWindowInteractor_h
#define vtkOpenVRRenderWindowInteractor_h
#include "vtkEventData.h" // for ivar
#include "vtkRenderingOpenVRModule.h" // For export macro
#include "vtkVRRenderWindowInteractor.h"
#include <functional> // for ivar
#include <map> // for ivar
#include <openvr.h> // for ivar
#include <string> // for ivar
VTK_ABI_NAMESPACE_BEGIN
class VTKRENDERINGOPENVR_EXPORT vtkOpenVRRenderWindowInteractor : public vtkVRRenderWindowInteractor
{
public:
static vtkOpenVRRenderWindowInteractor* New();
vtkTypeMacro(vtkOpenVRRenderWindowInteractor, vtkVRRenderWindowInteractor);
/**
* Initialize the event handler.
*/
void Initialize() override;
/**
* Implements the event loop.
*/
void DoOneEvent(vtkVRRenderWindow* renWin, vtkRenderer* ren) override;
///@{
/**
* Assign an event or std::function to an event path.
*/
void AddAction(std::string path, vtkCommand::EventIds, bool isAnalog);
void AddAction(std::string path, bool isAnalog, std::function<void(vtkEventData*)>);
///@}
protected:
vtkOpenVRRenderWindowInteractor();
~vtkOpenVRRenderWindowInteractor() override = default;
class ActionData
{
public:
vr::VRActionHandle_t ActionHandle;
vtkCommand::EventIds EventId;
std::function<void(vtkEventData*)> Function;
bool UseFunction = false;
bool IsAnalog = false;
};
std::map<std::string, ActionData> ActionMap;
vr::VRActionSetHandle_t ActionsetVTK = vr::k_ulInvalidActionSetHandle;
enum TrackerEnum
{
LEFT_HAND = 0,
RIGHT_HAND,
HEAD,
NUMBER_OF_TRACKERS
};
struct TrackerActions
{
vr::VRInputValueHandle_t Source = vr::k_ulInvalidInputValueHandle;
vr::TrackedDevicePose_t LastPose;
};
TrackerActions Trackers[NUMBER_OF_TRACKERS];
private:
vtkOpenVRRenderWindowInteractor(const vtkOpenVRRenderWindowInteractor&) = delete;
void operator=(const vtkOpenVRRenderWindowInteractor&) = delete;
};
VTK_ABI_NAMESPACE_END
#endif
|