View.h
Go to the documentation of this file.
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 
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 
47  {
59  };
60 
62  {
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 
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
SurgSim::Graphics::View::m_eyeSeparation
double m_eyeSeparation
Distance between eypoints in m.
Definition: View.h:203
SurgSim::Graphics::View::m_targetScreen
int m_targetScreen
Index of the screen to be used.
Definition: View.h:201
SurgSim::Framework::Component
Component is the main interface class to pass information to the system managers each will decide whe...
Definition: Component.h:42
SurgSim::Graphics::View::m_isFullscreen
bool m_isFullscreen
Whether to go fullscreen.
Definition: View.h:202
SurgSim::Graphics::View::doSetTargetScreen
virtual int doSetTargetScreen(int val)=0
SurgSim::Graphics::View::isWindowBorderEnabled
virtual bool isWindowBorderEnabled() const =0
Returns whether the view window has a border.
SurgSim::Graphics::View::isStereo
virtual bool isStereo() const
Definition: View.cpp:81
SurgSim::Graphics::View::DISPLAY_TYPE_HMD
@ DISPLAY_TYPE_HMD
Definition: View.h:64
SurgSim::Graphics::View::STEREO_MODE_ANAGLYPHIC
@ STEREO_MODE_ANAGLYPHIC
Definition: View.h:50
SurgSim::Graphics::View::setScreenWidth
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
Vector.h
SurgSim::Graphics::View::m_screenWidth
double m_screenWidth
Width of screen in m.
Definition: View.h:205
SurgSim::Graphics::View::m_camera
std::shared_ptr< Camera > m_camera
Camera whose image will be shown in this view.
Definition: View.h:197
SurgSim::Graphics::View::STEREO_MODE_NONE
@ STEREO_MODE_NONE
Definition: View.h:48
SurgSim::Graphics::View::STEREO_MODE_RIGHT_EYE
@ STEREO_MODE_RIGHT_EYE
Definition: View.h:54
SurgSim::Graphics::View::STEREO_MODE_HORIZONTAL_SPLIT
@ STEREO_MODE_HORIZONTAL_SPLIT
Definition: View.h:51
SurgSim::Graphics::View::setStereoMode
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
SurgSim::Graphics::View::getScreenWidth
double getScreenWidth() const
Definition: View.cpp:155
SurgSim::Graphics::View::StereoMode
StereoMode
Definition: View.h:46
SurgSim::Graphics::View::getScreenDistance
double getScreenDistance() const
Definition: View.cpp:139
SurgSim::Graphics::View::setFullScreen
void setFullScreen(bool val)
Request the display to use the whole screen.
Definition: View.cpp:111
SurgSim::Graphics::View::setDimensions
virtual void setDimensions(const std::array< int, 2 > &dimensions)=0
Set the dimensions of this view.
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::View::update
virtual void update(double dt)=0
Updates the view.
SurgSim::Graphics::View::STEREO_MODE_HORIZONTAL_INTERLACE
@ STEREO_MODE_HORIZONTAL_INTERLACE
Definition: View.h:55
SurgSim::Graphics::View::getCamera
std::shared_ptr< Camera > getCamera() const
Gets the camera which provides the viewpoint in the scene.
Definition: View.cpp:70
SurgSim::Graphics::View::STEREO_MODE_COUNT
@ STEREO_MODE_COUNT
Definition: View.h:58
SurgSim::Graphics::View::setScreenDistance
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
SurgSim::Graphics::View::getTargetScreen
int getTargetScreen() const
Definition: View.cpp:128
SurgSim::Graphics::View::DISPLAY_TYPE_MONITOR
@ DISPLAY_TYPE_MONITOR
Definition: View.h:63
SurgSim::Graphics::View::doInitialize
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: View.cpp:75
SurgSim::Graphics::View::isFullScreen
bool isFullScreen() const
Definition: View.cpp:117
SurgSim::Graphics::View::setPosition
virtual void setPosition(const std::array< int, 2 > &position)=0
Set the position of this view.
SurgSim::Graphics::View::getDisplayType
int getDisplayType() const
Definition: View.cpp:106
SurgSim::Graphics::View::setScreenHeight
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
Component.h
SurgSim::Graphics::View::STEREO_MODE_QUAD_BUFFER
@ STEREO_MODE_QUAD_BUFFER
Definition: View.h:49
SurgSim::Graphics::View::getStereoMode
int getStereoMode() const
Definition: View.cpp:94
SurgSim::Graphics::View::setDisplayType
void setDisplayType(int type)
Set the kind of display.
Definition: View.cpp:99
SurgSim::Graphics::View::m_displayType
int m_displayType
The requested display type.
Definition: View.h:200
SurgSim::Graphics::View::m_screenHeight
double m_screenHeight
Height of screen in m.
Definition: View.h:206
SurgSim::Graphics::View::getPosition
virtual std::array< int, 2 > getPosition() const =0
Get the position of this view.
SurgSim::Graphics::View::setWindowBorderEnabled
virtual void setWindowBorderEnabled(bool enabled)=0
Sets whether the view window has a border.
SurgSim::Graphics::View::STEREO_MODE_VERTICAL_INTERLACE
@ STEREO_MODE_VERTICAL_INTERLACE
Definition: View.h:56
SurgSim::Graphics::View::setTargetScreen
void setTargetScreen(int val)
Request a certain screen to be used for this view.
Definition: View.cpp:122
SurgSim::Graphics::View::DISPLAY_TYPE_COUNT
@ DISPLAY_TYPE_COUNT
Definition: View.h:65
SurgSim::Graphics::View
Base graphics view class, which defines the basic interface for all graphics views.
Definition: View.h:39
SurgSim::Graphics::View::setEyeSeparation
void setEyeSeparation(double val)
Set the distance between the users eyes, this is necessary to calculate the correct projection matric...
Definition: View.cpp:144
SurgSim::Graphics::View::DisplayType
DisplayType
Definition: View.h:61
SurgSim::Graphics::View::m_screenDistance
double m_screenDistance
Distance from user to screen in m.
Definition: View.h:204
string
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
SurgSim::Graphics::View::getDimensions
virtual std::array< int, 2 > getDimensions() const =0
Get the dimensions of this view.
SurgSim::Graphics::View::setDimensionsDouble
virtual void setDimensionsDouble(const std::array< double, 2 > &dimensions)=0
Set the dimensions of this view in doubles.
SurgSim::Graphics::View::View
View(const std::string &name)
Constructor.
Definition: View.cpp:31
SurgSim::Graphics::View::m_stereoMode
int m_stereoMode
The stereo mode, that is being used.
Definition: View.h:199
SurgSim::Graphics::View::setCamera
virtual void setCamera(std::shared_ptr< SurgSim::Framework::Component > camera)
Sets the camera which provides the viewpoint in the scene.
Definition: View.cpp:60
SurgSim::Graphics::View::STEREO_MODE_VERTICAL_SPLIT
@ STEREO_MODE_VERTICAL_SPLIT
Definition: View.h:52
SurgSim::Graphics::View::getScreenHeight
double getScreenHeight() const
Definition: View.cpp:166
SurgSim::Graphics::View::STEREO_MODE_CHECKERBOARD
@ STEREO_MODE_CHECKERBOARD
Definition: View.h:57
SurgSim::Graphics::View::getEyeSeparation
double getEyeSeparation() const
Definition: View.cpp:150
SurgSim::Graphics::View::getDimensionsDouble
virtual std::array< double, 2 > getDimensionsDouble() const =0
Get the dimensions of this view in doubles.
SurgSim::Graphics::View::STEREO_MODE_LEFT_EYE
@ STEREO_MODE_LEFT_EYE
Definition: View.h:53