View.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_GRAPHICS_VIEW_H
#define SURGSIM_GRAPHICS_VIEW_H
#include "SurgSim/Framework/Component.h"
#include "SurgSim/Math/Vector.h"
#include <memory>
#include <array>
namespace SurgSim
{
namespace Graphics
{
class Camera;
class View : public SurgSim::Framework::Component
{
public:
explicit View(const std::string& name);
enum StereoMode
{
STEREO_MODE_NONE = -1,
STEREO_MODE_QUAD_BUFFER,
STEREO_MODE_ANAGLYPHIC,
STEREO_MODE_HORIZONTAL_SPLIT,
STEREO_MODE_VERTICAL_SPLIT,
STEREO_MODE_LEFT_EYE,
STEREO_MODE_RIGHT_EYE,
STEREO_MODE_HORIZONTAL_INTERLACE,
STEREO_MODE_VERTICAL_INTERLACE,
STEREO_MODE_CHECKERBOARD,
STEREO_MODE_COUNT
};
enum DisplayType
{
DISPLAY_TYPE_MONITOR,
DISPLAY_TYPE_HMD,
DISPLAY_TYPE_COUNT
};
virtual void setPosition(const std::array<int, 2>& position) = 0;
virtual std::array<int, 2> getPosition() const = 0;
virtual void setDimensions(const std::array<int, 2>& dimensions) = 0;
virtual std::array<int, 2> getDimensions() const = 0;
virtual void setDimensionsDouble(const std::array<double, 2>& dimensions) = 0;
virtual std::array<double, 2> getDimensionsDouble() const = 0;
virtual void setWindowBorderEnabled(bool enabled) = 0;
virtual bool isWindowBorderEnabled() const = 0;
virtual void setCamera(std::shared_ptr<SurgSim::Framework::Component> camera);
std::shared_ptr<Camera> getCamera() const;
virtual void update(double dt) = 0;
virtual bool isStereo() const;
virtual void setStereoMode(int val);
int getStereoMode() const;
void setDisplayType(int type);
int getDisplayType() const;
void setFullScreen(bool val);
bool isFullScreen() const;
void setTargetScreen(int val);
int getTargetScreen() const;
void setEyeSeparation(double val);
double getEyeSeparation() const;
void setScreenDistance(double val);
double getScreenDistance() const;
void setScreenWidth(double val);
double getScreenWidth() const;
void setScreenHeight(double val);
double getScreenHeight() const;
private:
bool doInitialize() override;
virtual int doSetTargetScreen(int val) = 0;
std::shared_ptr<Camera> m_camera;
int m_stereoMode;
int m_displayType;
int m_targetScreen;
bool m_isFullscreen;
double m_eyeSeparation;
double m_screenDistance;
double m_screenWidth;
double m_screenHeight;
};
}; // namespace Graphics
}; // namespace SurgSim
#endif // SURGSIM_GRAPHICS_VIEW_H
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
SurgSim::Graphics::View
Base graphics view class, which defines the basic interface for all graphics views.
Definition: View.h:39
SurgSim::Graphics::View::View
View(const std::string &name)
Constructor.
Definition: View.cpp:31
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
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::setDimensions
virtual void setDimensions(const std::array< int, 2 > &dimensions)=0
Set the dimensions of this view.
SurgSim::Graphics::View::STEREO_MODE_VERTICAL_SPLIT
Definition: View.h:52
SurgSim::Graphics::View::DisplayType
DisplayType
Definition: View.h:61
SurgSim::Graphics::View::STEREO_MODE_QUAD_BUFFER
Definition: View.h:49
SurgSim::Graphics::View::m_displayType
int m_displayType
The requested display type.
Definition: View.h:200
SurgSim::Graphics::View::DISPLAY_TYPE_HMD
Definition: View.h:64
SurgSim::Graphics::View::getPosition
virtual std::array< int, 2 > getPosition() const =0
Get the position of this view.
SurgSim::Graphics::View::DISPLAY_TYPE_MONITOR
Definition: View.h:63
SurgSim::Graphics::View::STEREO_MODE_VERTICAL_INTERLACE
Definition: View.h:56
Component.h
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::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::update
virtual void update(double dt)=0
Updates the view.
SurgSim::Graphics::View::setDimensionsDouble
virtual void setDimensionsDouble(const std::array< double, 2 > &dimensions)=0
Set the dimensions of this view in doubles.
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::getScreenWidth
double getScreenWidth() const
Definition: View.cpp:155
SurgSim::Graphics::View::m_screenHeight
double m_screenHeight
Height of screen in m.
Definition: View.h:206
SurgSim::Graphics::View::getDisplayType
int getDisplayType() const
Definition: View.cpp:106
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
SurgSim::Graphics::View::setWindowBorderEnabled
virtual void setWindowBorderEnabled(bool enabled)=0
Sets whether the view window has a border.
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::setPosition
virtual void setPosition(const std::array< int, 2 > &position)=0
Set the position of this view.
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::StereoMode
StereoMode
Definition: View.h:46
SurgSim::Graphics::View::isStereo
virtual bool isStereo() const
Definition: View.cpp:81
SurgSim::Graphics::View::m_stereoMode
int m_stereoMode
The stereo mode, that is being used.
Definition: View.h:199
SurgSim::Graphics::View::getEyeSeparation
double getEyeSeparation() const
Definition: View.cpp:150
SurgSim::Graphics::View::m_isFullscreen
bool m_isFullscreen
Whether to go fullscreen.
Definition: View.h:202
SurgSim::Graphics::View::STEREO_MODE_RIGHT_EYE
Definition: View.h:54
SurgSim::Graphics::View::getTargetScreen
int getTargetScreen() const
Definition: View.cpp:128
SurgSim::Graphics::View::STEREO_MODE_LEFT_EYE
Definition: View.h:53
SurgSim::Graphics::View::m_targetScreen
int m_targetScreen
Index of the screen to be used.
Definition: View.h:201
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::getStereoMode
int getStereoMode() const
Definition: View.cpp:94
SurgSim::Graphics::View::STEREO_MODE_CHECKERBOARD
Definition: View.h:57
SurgSim::Graphics::View::STEREO_MODE_ANAGLYPHIC
Definition: View.h:50
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
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Graphics::View::m_screenWidth
double m_screenWidth
Width of screen in m.
Definition: View.h:205
SurgSim::Graphics::View::getDimensions
virtual std::array< int, 2 > getDimensions() const =0
Get the dimensions of this view.
SurgSim::Graphics::View::setDisplayType
void setDisplayType(int type)
Set the kind of display.
Definition: View.cpp:99
SurgSim::Graphics::View::STEREO_MODE_HORIZONTAL_SPLIT
Definition: View.h:51
SurgSim::Graphics::View::getScreenHeight
double getScreenHeight() const
Definition: View.cpp:166
SurgSim::Graphics::View::STEREO_MODE_HORIZONTAL_INTERLACE
Definition: View.h:55
SurgSim::Graphics::View::m_screenDistance
double m_screenDistance
Distance from user to screen in m.
Definition: View.h:204
SurgSim::Graphics::View::doInitialize
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: View.cpp:75
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_NONE
Definition: View.h:48
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::m_eyeSeparation
double m_eyeSeparation
Distance between eypoints in m.
Definition: View.h:203
SurgSim::Graphics::View::DISPLAY_TYPE_COUNT
Definition: View.h:65
SurgSim::Graphics::View::isWindowBorderEnabled
virtual bool isWindowBorderEnabled() const =0
Returns whether the view window has a border.
SurgSim::Graphics::View::doSetTargetScreen
virtual int doSetTargetScreen(int val)=0
SurgSim::Graphics::View::isFullScreen
bool isFullScreen() const
Definition: View.cpp:117
SurgSim::Graphics::View::STEREO_MODE_COUNT
Definition: View.h:58