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 setWindowBorderEnabled(bool enabled) = 0;
88 
91  virtual bool isWindowBorderEnabled() const = 0;
92 
96  virtual void setCamera(std::shared_ptr<SurgSim::Framework::Component> camera);
97 
100  std::shared_ptr<Camera> getCamera() const;
101 
104  virtual void update(double dt) = 0;
105 
107  virtual bool isStereo() const;
108 
112  virtual void setStereoMode(int val);
113 
115  int getStereoMode() const;
116 
120  void setDisplayType(int type);
121 
123  int getDisplayType() const;
124 
128  void setFullScreen(bool val);
129 
131  bool isFullScreen() const;
132 
136  void setTargetScreen(int val);
137 
139  int getTargetScreen() const;
140 
146  void setEyeSeparation(double val);
147 
149  double getEyeSeparation() const;
150 
156  void setScreenDistance(double val);
157 
159  double getScreenDistance() const;
160 
166  void setScreenWidth(double val);
167 
169  double getScreenWidth() const;
170 
171 
177  void setScreenHeight(double val);
178 
180  double getScreenHeight() const;
181 
182 private:
183 
184  virtual bool doInitialize() override;
185 
187  std::shared_ptr<Camera> m_camera;
188 
195  double m_screenWidth;
196  double m_screenHeight;
197 
198 };
199 
200 }; // namespace Graphics
201 
202 }; // namespace SurgSim
203 
204 #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:165
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:30
Definition: DriveElementFromInputBehavior.cpp:27
std::shared_ptr< Camera > m_camera
Camera whose image will be shown in this view.
Definition: View.h:187
virtual void setDimensions(const std::array< int, 2 > &dimensions)=0
Set the dimensions of this view.
DisplayType
Definition: View.h:61
virtual bool isStereo() const
Definition: View.cpp:75
int m_displayType
The requested display type.
Definition: View.h:190
double getScreenWidth() const
Definition: View.cpp:149
virtual std::array< int, 2 > getPosition() const =0
Get the position of this view.
int getTargetScreen() const
Definition: View.cpp:122
void setEyeSeparation(double val)
Set the distance between the users eyes, this is necessary to calculate the correct projection matric...
Definition: View.cpp:138
virtual void update(double dt)=0
Updates the view.
Component is the main interface class to pass information to the system managers each will decide whe...
Definition: Component.h:43
double m_screenHeight
Height of screen in m.
Definition: View.h:196
void setScreenWidth(double val)
Set the width of the screen, this is necessary to calculate the correct projection matrices for stere...
Definition: View.cpp:155
virtual void setWindowBorderEnabled(bool enabled)=0
Sets whether the view window has a border.
int getDisplayType() const
Definition: View.cpp:100
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:127
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:57
string(TOUPPER ${DEVICE}DEVICE_UPPER_CASE) option(BUILD_DEVICE_ $
Definition: CMakeLists.txt:35
StereoMode
Definition: View.h:46
int m_stereoMode
The stereo mode, that is being used.
Definition: View.h:189
double getScreenHeight() const
Definition: View.cpp:160
int getStereoMode() const
Definition: View.cpp:88
bool m_isFullscreen
Whether to go fullscreen.
Definition: View.h:192
double getEyeSeparation() const
Definition: View.cpp:144
int m_targetScreen
Index of the screen to be used.
Definition: View.h:191
void setTargetScreen(int val)
Request a certain screen to be used for this view.
Definition: View.cpp:116
double getScreenDistance() const
Definition: View.cpp:133
std::shared_ptr< Camera > getCamera() const
Gets the camera which provides the viewpoint in the scene.
Definition: View.cpp:64
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:81
Definitions of small fixed-size vector types.
double m_screenWidth
Width of screen in m.
Definition: View.h:195
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:93
double m_screenDistance
Distance from user to screen in m.
Definition: View.h:194
virtual bool doInitialize() override
Interface to be implemented by derived classes.
Definition: View.cpp:69
void setFullScreen(bool val)
Request the display to use the whole screen.
Definition: View.cpp:105
double m_eyeSeparation
Distance between eypoints in m.
Definition: View.h:193
bool isFullScreen() const
Definition: View.cpp:111
virtual bool isWindowBorderEnabled() const =0
Returns whether the view window has a border.