VTK  9.3.20240418
vtkOpenVROverlay.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
13 #ifndef vtkOpenVROverlay_h
14 #define vtkOpenVROverlay_h
15 
16 #include "vtkNew.h" // for ivars
17 #include "vtkObject.h"
18 #include "vtkRenderingOpenVRModule.h" // For export macro
19 #include "vtkWeakPointer.h" // for ivars
20 #include <map> // ivars
21 #include <openvr.h> // for ivars
22 #include <vector> // ivars
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class vtkJPEGReader;
28 class vtkTextureObject;
30 class vtkOpenVRCamera;
31 class vtkXMLDataElement;
32 
33 class VTKRENDERINGOPENVR_EXPORT vtkOpenVROverlay : public vtkObject
34 {
35 public:
36  static vtkOpenVROverlay* New();
37  vtkTypeMacro(vtkOpenVROverlay, vtkObject);
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
43  virtual void Render();
44 
48  virtual void Create(vtkOpenVRRenderWindow* rw);
49 
53  vr::VROverlayHandle_t GetOverlayHandle() { return this->OverlayHandle; }
54 
58  vtkTextureObject* GetOverlayTexture() { return this->OverlayTexture.Get(); }
59 
61 
64  virtual void MouseMoved(int x, int y);
65  virtual void MouseButtonPress(int x, int y);
66  virtual void MouseButtonRelease(int x, int y);
68 
69  vtkOpenVROverlaySpot* GetLastSpot() { return this->LastSpot; }
70 
71  std::vector<vtkOpenVROverlaySpot>& GetSpots() { return this->Spots; }
72 
73  /***
74  * update the texture because this spot has changed
75  */
76  virtual void UpdateSpot(vtkOpenVROverlaySpot* spot);
77 
79 
82  void SetSessionName(const std::string& name) { this->SessionName = name; }
83  std::string GetSessionName() { return this->SessionName; }
85 
87 
91  {
92  this->DashboardImageFileName = name;
93  }
94  VTK_FILEPATH std::string GetDashboardImageFileName() { return this->DashboardImageFileName; }
96 
98  virtual void SetSavedCameraPose(int i, vtkOpenVRCameraPose*);
99  virtual void WriteCameraPoses(ostream& os);
100  virtual void WriteCameraPoses();
101  virtual void ReadCameraPoses();
102  virtual void ReadCameraPoses(istream& is);
103  virtual void ReadCameraPoses(vtkXMLDataElement* xml);
104  virtual void SaveCameraPose(int num);
105  virtual void LoadCameraPose(int num);
106  virtual void LoadNextCameraPose();
107  virtual std::map<int, vtkOpenVRCameraPose>& GetSavedCameraPoses()
108  {
109  return this->SavedCameraPoses;
110  }
111 
112  // not used for dashboard overlays
113  void Show();
114  void Hide();
115 
116 protected:
118  ~vtkOpenVROverlay() override;
119 
120  virtual void SetupSpots() {}
121 
122  vr::IVRSystem* VRSystem;
123 
124  // for the overlay
125  vr::VROverlayHandle_t OverlayHandle;
126  vr::VROverlayHandle_t OverlayThumbnailHandle;
128 
130 
131  // std::vector<vtkOpenVRActiveSpot> ActiveSpots;
132  unsigned char* OriginalTextureData;
133  unsigned char* CurrentTextureData;
134 
135  std::vector<vtkOpenVROverlaySpot> Spots;
137 
140  std::map<int, vtkOpenVRCameraPose> SavedCameraPoses;
141 
144 
147 
148 private:
149  vtkOpenVROverlay(const vtkOpenVROverlay&) = delete;
150  void operator=(const vtkOpenVROverlay&) = delete;
151 };
152 
153 VTK_ABI_NAMESPACE_END
154 #endif
a simple class to control print indentation
Definition: vtkIndent.h:108
read JPEG files
abstract base class for most VTK objects
Definition: vtkObject.h:162
OpenVR camera.
OpenVR overlay.
vtkTextureObject * GetOverlayTexture()
Get handle to the overlay texture.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::map< int, vtkOpenVRCameraPose > SavedCameraPoses
vr::VROverlayHandle_t OverlayThumbnailHandle
vr::IVRSystem * VRSystem
std::string GetSessionName()
Set/Get a prefix for saving camera poses.
unsigned char * CurrentTextureData
virtual void ReadCameraPoses()
virtual std::map< int, vtkOpenVRCameraPose > & GetSavedCameraPoses()
virtual void LoadCameraPose(int num)
virtual void UpdateSpot(vtkOpenVROverlaySpot *spot)
vtkOpenVROverlaySpot * GetLastSpot()
std::string DashboardImageFileName
virtual void LoadNextCameraPose()
virtual void SetupSpots()
unsigned char * OriginalTextureData
void SetDashboardImageFileName(VTK_FILEPATH const std::string &name)
Set/Get a file for the dashboard image.
vtkNew< vtkTextureObject > OverlayTexture
vtkOpenVROverlaySpot * LastSpot
virtual void SaveCameraPose(int num)
vtkOpenVRCameraPose * GetSavedCameraPose(int i)
virtual void MouseButtonRelease(int x, int y)
methods to support events on the overlay
std::vector< vtkOpenVROverlaySpot > & GetSpots()
virtual void WriteCameraPoses()
virtual void SetDashboardImageData(vtkJPEGReader *rdr)
virtual void Create(vtkOpenVRRenderWindow *rw)
Create the overlay.
static vtkOpenVROverlay * New()
vr::VROverlayHandle_t OverlayHandle
virtual void ReadCameraPoses(istream &is)
virtual void WriteCameraPoses(ostream &os)
void SetSessionName(const std::string &name)
Set/Get a prefix for saving camera poses.
virtual void SetSavedCameraPose(int i, vtkOpenVRCameraPose *)
vtkWeakPointer< vtkOpenVRRenderWindow > Window
~vtkOpenVROverlay() override
VTK_FILEPATH std::string GetDashboardImageFileName()
Set/Get a file for the dashboard image.
virtual void ReadCameraPoses(vtkXMLDataElement *xml)
vr::VROverlayHandle_t GetOverlayHandle()
Get handle to the overlay.
virtual void Render()
Render the overlay.
virtual void MouseMoved(int x, int y)
methods to support events on the overlay
std::string SessionName
std::vector< vtkOpenVROverlaySpot > Spots
virtual void MouseButtonPress(int x, int y)
methods to support events on the overlay
OpenVR rendering window.
abstracts an OpenGL texture object.
Represents an XML element and those nested inside.
@ name
Definition: vtkX3D.h:219
@ string
Definition: vtkX3D.h:490
#define VTK_FILEPATH