VTK  9.3.1
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 
97  vtkOpenVRCameraPose* GetSavedCameraPose(int i);
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 
129  virtual void SetDashboardImageData(vtkJPEGReader* rdr);
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
std::string DashboardImageFileName
void SetDashboardImageFileName(VTK_FILEPATH const std::string &name)
Set/Get a file for the dashboard image.
vtkWeakPointer< vtkOpenVRRenderWindow > Window
OpenVR camera.
abstract base class for most VTK objects
Definition: vtkObject.h:51
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.
read JPEG files
Definition: vtkJPEGReader.h:26
Represents an XML element and those nested inside.
vtkOpenVROverlaySpot * LastSpot
std::map< int, vtkOpenVRCameraPose > SavedCameraPoses
unsigned char * CurrentTextureData
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkNew< vtkTextureObject > OverlayTexture
OpenVR overlay.
vr::VROverlayHandle_t OverlayHandle
std::string SessionName
vr::IVRSystem * VRSystem
unsigned char * OriginalTextureData
vtkOpenVROverlaySpot * GetLastSpot()
VTK_FILEPATH std::string GetDashboardImageFileName()
Set/Get a file for the dashboard image.
vr::VROverlayHandle_t OverlayThumbnailHandle
std::vector< vtkOpenVROverlaySpot > & GetSpots()
abstracts an OpenGL texture object.
OpenVR rendering window.
#define VTK_FILEPATH
std::vector< vtkOpenVROverlaySpot > Spots
vr::VROverlayHandle_t GetOverlayHandle()
Get handle to the overlay.
void SetSessionName(const std::string &name)
Set/Get a prefix for saving camera poses.
virtual std::map< int, vtkOpenVRCameraPose > & GetSavedCameraPoses()
virtual void SetupSpots()
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
std::string GetSessionName()
Set/Get a prefix for saving camera poses.