opensurgsim
View.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_GRAPHICS_VIEW_H
17 #define SURGSIM_GRAPHICS_VIEW_H
18 
19 #include "SurgSim/Framework/Component.h"
20 
21 #include "SurgSim/Math/Vector.h"
22 
23 #include <memory>
24 #include <array>
25 
26 namespace SurgSim
27 {
28 
29 namespace Graphics
30 {
31 
32 class Camera;
33 
40 {
41 public:
44  explicit View(const std::string& name);
45 
46  enum StereoMode
47  {
48  STEREO_MODE_NONE = -1,
49  STEREO_MODE_QUAD_BUFFER,
50  STEREO_MODE_ANAGLYPHIC,
51  STEREO_MODE_HORIZONTAL_SPLIT,
52  STEREO_MODE_VERTICAL_SPLIT,
53  STEREO_MODE_LEFT_EYE,
54  STEREO_MODE_RIGHT_EYE,
55  STEREO_MODE_HORIZONTAL_INTERLACE,
56  STEREO_MODE_VERTICAL_INTERLACE,
57  STEREO_MODE_CHECKERBOARD,
58  STEREO_MODE_COUNT
59  };
60 
61  enum DisplayType
62  {
63  DISPLAY_TYPE_MONITOR,
64  DISPLAY_TYPE_HMD,
65  DISPLAY_TYPE_COUNT
66  };
67 
71  virtual void setPosition(const std::array<int, 2>& position) = 0;
72 
75  virtual std::array<int, 2> getPosition() const = 0;
76 
79  virtual void setDimensions(const std::array<int, 2>& dimensions) = 0;
80 
83  virtual std::array<int, 2> getDimensions() const = 0;
84 
87  virtual void setDimensionsDouble(const std::array<double, 2>& dimensions) = 0;
88 
91  virtual std::array<double, 2> getDimensionsDouble() const = 0;
92 
95  virtual void setWindowBorderEnabled(bool enabled) = 0;
96 
99  virtual bool isWindowBorderEnabled() const = 0;
100 
104  virtual void setCamera(std::shared_ptr<SurgSim::Framework::Component> camera);
105 
108  std::shared_ptr<Camera> getCamera() const;
109 
112  virtual void update(double dt) = 0;
113 
115  virtual bool isStereo() const;
116 
120  virtual void setStereoMode(int val);
121 
123  int getStereoMode() const;
124 
128  void setDisplayType(int type);
129 
131  int getDisplayType() const;
132 
136  void setFullScreen(bool val);
137 
139  bool isFullScreen() const;
140 
144  void setTargetScreen(int val);
145 
147  int getTargetScreen() const;
148 
154  void setEyeSeparation(double val);
155 
157  double getEyeSeparation() const;
158 
164  void setScreenDistance(double val);
165 
167  double getScreenDistance() const;
168 
174  void setScreenWidth(double val);
175 
177  double getScreenWidth() const;
178 
179 
185  void setScreenHeight(double val);
186 
188  double getScreenHeight() const;
189 
190 private:
191 
192  bool doInitialize() override;
193 
194  virtual int doSetTargetScreen(int val) = 0;
195 
197  std::shared_ptr<Camera> m_camera;
198 
199  int m_stereoMode;
200  int m_displayType;
201  int m_targetScreen;
202  bool m_isFullscreen;
203  double m_eyeSeparation;
204  double m_screenDistance;
205  double m_screenWidth;
206  double m_screenHeight;
207 
208 };
209 
210 }; // namespace Graphics
211 
212 }; // namespace SurgSim
213 
214 #endif // SURGSIM_GRAPHICS_VIEW_H
void setScreenHeight(double val)
Set the height of the screen, this is necessary to calculate the correct projection matrices for ster...
Definition: View.cpp:171
Base graphics view class, which defines the basic interface for all graphics views.
Definition: View.h:39
View(const std::string &name)
Constructor.
Definition: View.cpp:31
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
virtual void setDimensions(const std::array< int, 2 > &dimensions)=0
Set the dimensions of this view.
virtual std::array< int, 2 > getPosition() const =0
Get the position of this view.
std::shared_ptr< Camera > getCamera() const
Gets the camera which provides the viewpoint in the scene.
Definition: View.cpp:70
void setEyeSeparation(double val)
Set the distance between the users eyes, this is necessary to calculate the correct projection matric...
Definition: View.cpp:144
virtual void update(double dt)=0
Updates the view.
virtual void setDimensionsDouble(const std::array< double, 2 > &dimensions)=0
Set the dimensions of this view in doubles.
Component is the main interface class to pass information to the system managers each will decide whe...
Definition: Component.h:42
double getScreenWidth() const
Definition: View.cpp:155
int getDisplayType() const
Definition: View.cpp:106
void setScreenWidth(double val)
Set the width of the screen, this is necessary to calculate the correct projection matrices for stere...
Definition: View.cpp:160
virtual void setWindowBorderEnabled(bool enabled)=0
Sets whether the view window has a border.
void setScreenDistance(double val)
Set the distance of the user from the screen, this is necessary to calculate the correct projection m...
Definition: View.cpp:133
virtual void setPosition(const std::array< int, 2 > &position)=0
Set the position of this view.
virtual void setCamera(std::shared_ptr< SurgSim::Framework::Component > camera)
Sets the camera which provides the viewpoint in the scene.
Definition: View.cpp:60
virtual bool isStereo() const
Definition: View.cpp:81
double getEyeSeparation() const
Definition: View.cpp:150
int getTargetScreen() const
Definition: View.cpp:128
void setTargetScreen(int val)
Request a certain screen to be used for this view.
Definition: View.cpp:122
int getStereoMode() const
Definition: View.cpp:94
virtual void setStereoMode(int val)
Set the mode that this view should use for stereo display, see StereMode for all the modes...
Definition: View.cpp:87
Definitions of small fixed-size vector types.
virtual std::array< int, 2 > getDimensions() const =0
Get the dimensions of this view.
void setDisplayType(int type)
Set the kind of display.
Definition: View.cpp:99
double getScreenHeight() const
Definition: View.cpp:166
virtual std::array< double, 2 > getDimensionsDouble() const =0
Get the dimensions of this view in doubles.
double getScreenDistance() const
Definition: View.cpp:139
void setFullScreen(bool val)
Request the display to use the whole screen.
Definition: View.cpp:111
virtual bool isWindowBorderEnabled() const =0
Returns whether the view window has a border.
bool isFullScreen() const
Definition: View.cpp:117