Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
SurgSim::Graphics::View Class Referenceabstract

Base graphics view class, which defines the basic interface for all graphics views. More...

#include <SurgSim/Graphics/View.h>

Inheritance diagram for SurgSim::Graphics::View:
SurgSim::Framework::Component SurgSim::Framework::Accessible SurgSim::Framework::FactoryBase1< Component, std::string > SurgSim::Graphics::OsgView SurgSim::Devices::OculusView

Public Types

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 }
 
- Public Types inherited from SurgSim::Framework::Accessible
typedef std::function< boost::any(void)> GetterType
 
typedef std::function< void(boost::any)> SetterType
 
typedef std::function< YAML::Node(void)> EncoderType
 
typedef std::function< void(const YAML::Node *)> DecoderType
 
- Public Types inherited from SurgSim::Framework::FactoryBase1< Component, std::string >
typedef ObjectFactory1< Component, std::stringFactoryType
 

Public Member Functions

 View (const std::string &name)
 Constructor. More...
 
virtual void setPosition (const std::array< int, 2 > &position)=0
 Set the position of this view. More...
 
virtual std::array< int, 2 > getPosition () const =0
 Get the position of this view. More...
 
virtual void setDimensions (const std::array< int, 2 > &dimensions)=0
 Set the dimensions of this view. More...
 
virtual std::array< int, 2 > getDimensions () const =0
 Get the dimensions of this view. More...
 
virtual void setDimensionsDouble (const std::array< double, 2 > &dimensions)=0
 Set the dimensions of this view in doubles. More...
 
virtual std::array< double, 2 > getDimensionsDouble () const =0
 Get the dimensions of this view in doubles. More...
 
virtual void setWindowBorderEnabled (bool enabled)=0
 Sets whether the view window has a border. More...
 
virtual bool isWindowBorderEnabled () const =0
 Returns whether the view window has a border. More...
 
virtual void setCamera (std::shared_ptr< SurgSim::Framework::Component > camera)
 Sets the camera which provides the viewpoint in the scene. More...
 
std::shared_ptr< CameragetCamera () const
 Gets the camera which provides the viewpoint in the scene. More...
 
virtual void update (double dt)=0
 Updates the view. More...
 
virtual bool isStereo () const
 
virtual void setStereoMode (int val)
 Set the mode that this view should use for stereo display, see StereMode for all the modes. More...
 
int getStereoMode () const
 
void setDisplayType (int type)
 Set the kind of display. More...
 
int getDisplayType () const
 
void setFullScreen (bool val)
 Request the display to use the whole screen. More...
 
bool isFullScreen () const
 
void setTargetScreen (int val)
 Request a certain screen to be used for this view. More...
 
int getTargetScreen () const
 
void setEyeSeparation (double val)
 Set the distance between the users eyes, this is necessary to calculate the correct projection matrices for stereo rendering. More...
 
double getEyeSeparation () const
 
void setScreenDistance (double val)
 Set the distance of the user from the screen, this is necessary to calculate the correct projection matrices for stereo rendering. More...
 
double getScreenDistance () const
 
void setScreenWidth (double val)
 Set the width of the screen, this is necessary to calculate the correct projection matrices for stereo rendering. More...
 
double getScreenWidth () const
 
void setScreenHeight (double val)
 Set the height of the screen, this is necessary to calculate the correct projection matrices for stereo rendering. More...
 
double getScreenHeight () const
 
- Public Member Functions inherited from SurgSim::Framework::Component
 Component (const std::string &name)
 Constructor. More...
 
virtual ~Component ()
 Destructor. More...
 
std::string getName () const
 Gets component name. More...
 
std::string getFullName () const
 Gets a string containing the name of the Component and (if it has one) its SceneElement. More...
 
void setName (const std::string &name)
 Sets the name of component. More...
 
boost::uuids::uuid getUuid () const
 Gets the id of the component. More...
 
bool isInitialized () const
 
bool initialize (const std::weak_ptr< Runtime > &runtime)
 Initialize this component, this needs to be called before wakeUp() can be called. More...
 
bool isAwake () const
 
bool wakeUp ()
 Wakeup this component, this will be called when the component is inserted into the ComponentManager that is responsible for handling this component. More...
 
void retire ()
 Retire this component, this will be called when the component is removed from the ComponentManager that is responsible for handling this component. More...
 
void setScene (std::weak_ptr< Scene > scene)
 Sets the scene. More...
 
std::shared_ptr< ScenegetScene ()
 Gets the scene. More...
 
void setSceneElement (std::weak_ptr< SceneElement > sceneElement)
 Sets the scene element. More...
 
std::shared_ptr< SceneElementgetSceneElement ()
 Gets the scene element. More...
 
std::shared_ptr< const SceneElementgetSceneElement () const
 Gets the scene element, constant version. More...
 
std::shared_ptr< RuntimegetRuntime () const
 Get the runtime which contains this component. More...
 
virtual std::string getClassName () const
 The class name for this class, this being the base class it should return SurgSim::Framework::Component but this would make missing implemenentations of this hard to catch, therefore this calls SURGSIM_FAILURE. More...
 
std::shared_ptr< ComponentgetSharedPtr ()
 Gets a shared pointer to this component. More...
 
virtual bool doWakeUp ()=0
 Interface to be implemented by derived classes. More...
 
virtual void doRetire ()
 Interface to be implemented by derived classes Has a default implementation, does nothing. More...
 
bool isActive () const
 
virtual void setLocalActive (bool val)
 Set the component's active state. More...
 
bool isLocalActive () const
 
- Public Member Functions inherited from SurgSim::Framework::Accessible
 Accessible ()
 Default Constructor. More...
 
 ~Accessible ()
 Destructor. More...
 
template<class T >
getValue (const std::string &name) const
 Retrieves the value with the name by executing the getter if it is found and tries to convert it to the given type. More...
 
boost::any getValue (const std::string &name) const
 Retrieves the value with the name by executing the getter if it is found. More...
 
template<class T >
bool getValue (const std::string &name, T *value) const
 Retrieves the value with the name by executing the getter if it is found, and converts it to the type of the output parameter. More...
 
void setValue (const std::string &name, const boost::any &value)
 Sets a value of a property that has setter. More...
 
bool isReadable (const std::string &name) const
 Check whether a property is readable. More...
 
bool isWriteable (const std::string &name) const
 Check whether a property is writable. More...
 
void setGetter (const std::string &name, GetterType func)
 Sets a getter for a given property. More...
 
void setSetter (const std::string &name, SetterType func)
 Sets a setter for a given property. More...
 
void setAccessors (const std::string &name, GetterType getter, SetterType setter)
 Sets the accessors getter and setter in one function. More...
 
void removeAccessors (const std::string &name)
 Removes all the accessors (getter and setter) for a given property. More...
 
void forwardProperty (const std::string &name, const Accessible &target, const std::string &targetProperty)
 Adds a property with the given name that uses the targets accessors, in effect forwarding the value to the target. More...
 
void setSerializable (const std::string &name, EncoderType encoder, DecoderType decoder)
 Sets the functions used to convert data from and to a YAML::Node. More...
 
void setDecoder (const std::string &name, DecoderType decoder)
 Sets the functions used to convert data from a YAML::Node. More...
 
YAML::Node encode () const
 Encode this Accessible to a YAML::Node. More...
 
void decode (const YAML::Node &node, const std::vector< std::string > &ignoredProperties=std::vector< std::string >())
 Decode this Accessible from a YAML::Node, will throw an exception if the data type cannot be converted. More...
 
template<>
boost::any getValue (const std::string &name) const
 

Private Member Functions

bool doInitialize () override
 Interface to be implemented by derived classes. More...
 
virtual int doSetTargetScreen (int val)=0
 

Private Attributes

std::shared_ptr< Cameram_camera
 Camera whose image will be shown in this view. More...
 
int m_stereoMode
 The stereo mode, that is being used. More...
 
int m_displayType
 The requested display type. More...
 
int m_targetScreen
 Index of the screen to be used. More...
 
bool m_isFullscreen
 Whether to go fullscreen. More...
 
double m_eyeSeparation
 Distance between eypoints in m. More...
 
double m_screenDistance
 Distance from user to screen in m. More...
 
double m_screenWidth
 Width of screen in m. More...
 
double m_screenHeight
 Height of screen in m. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SurgSim::Framework::FactoryBase1< Component, std::string >
static FactoryTypegetFactory ()
 
- Protected Member Functions inherited from SurgSim::Framework::Component
virtual std::shared_ptr< PoseComponentgetPoseComponent ()
 Get the PoseComponent for this component. More...
 
virtual std::shared_ptr< const PoseComponentgetPoseComponent () const
 Get the PoseComponent for this component, constant access. More...
 

Detailed Description

Base graphics view class, which defines the basic interface for all graphics views.

A Graphics::View provides a visualization of the scene to the user.

A Graphics::Camera controls the viewpoint of this View.

Member Enumeration Documentation

◆ DisplayType

Enumerator
DISPLAY_TYPE_MONITOR 
DISPLAY_TYPE_HMD 
DISPLAY_TYPE_COUNT 

◆ StereoMode

Enumerator
STEREO_MODE_NONE 
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 

Constructor & Destructor Documentation

◆ View()

SurgSim::Graphics::View::View ( const std::string name)
explicit

Constructor.

Parameters
nameName of the view

Member Function Documentation

◆ doInitialize()

bool SurgSim::Graphics::View::doInitialize ( )
overrideprivatevirtual

Interface to be implemented by derived classes.

Returns
True if component is initialized successfully; otherwise, false.

Implements SurgSim::Framework::Component.

◆ doSetTargetScreen()

virtual int SurgSim::Graphics::View::doSetTargetScreen ( int  val)
privatepure virtual

Implemented in SurgSim::Graphics::OsgView.

◆ getCamera()

std::shared_ptr< Camera > SurgSim::Graphics::View::getCamera ( ) const

Gets the camera which provides the viewpoint in the scene.

Returns
camera Camera whose image will be shown in this view

◆ getDimensions()

virtual std::array<int, 2> SurgSim::Graphics::View::getDimensions ( ) const
pure virtual

Get the dimensions of this view.

Returns
Dimensions on the screen (in pixels)

Implemented in SurgSim::Graphics::OsgView.

◆ getDimensionsDouble()

virtual std::array<double, 2> SurgSim::Graphics::View::getDimensionsDouble ( ) const
pure virtual

Get the dimensions of this view in doubles.

Returns
Dimensions on the screen (in pixels)

Implemented in SurgSim::Graphics::OsgView.

◆ getDisplayType()

int SurgSim::Graphics::View::getDisplayType ( ) const
Returns
The type of display that the view is on

◆ getEyeSeparation()

double SurgSim::Graphics::View::getEyeSeparation ( ) const
Returns
The current distance between the eye points in m.

◆ getPosition()

virtual std::array<int, 2> SurgSim::Graphics::View::getPosition ( ) const
pure virtual

Get the position of this view.

Returns
Position on the screen (in pixels)

Implemented in SurgSim::Graphics::OsgView.

◆ getScreenDistance()

double SurgSim::Graphics::View::getScreenDistance ( ) const
Returns
The current distance from user to screen in m.

◆ getScreenHeight()

double SurgSim::Graphics::View::getScreenHeight ( ) const
Returns
The currently used height of the screen in m.

◆ getScreenWidth()

double SurgSim::Graphics::View::getScreenWidth ( ) const
Returns
The currently used width of the screen in m.

◆ getStereoMode()

int SurgSim::Graphics::View::getStereoMode ( ) const
Returns
What kind of stereo rendering is being used for this view.

◆ getTargetScreen()

int SurgSim::Graphics::View::getTargetScreen ( ) const
Returns
The number of the screen that this view is on.

◆ isFullScreen()

bool SurgSim::Graphics::View::isFullScreen ( ) const
Returns
true if the display is set to use the whole screen, or is currently using the whole screen.

◆ isStereo()

bool SurgSim::Graphics::View::isStereo ( ) const
virtual
Returns
true if the display is set to render a stereo view, or is currently rendering in stereo.

◆ isWindowBorderEnabled()

virtual bool SurgSim::Graphics::View::isWindowBorderEnabled ( ) const
pure virtual

Returns whether the view window has a border.

Returns
True to enable the border around the window; false for no border

Implemented in SurgSim::Graphics::OsgView.

◆ setCamera()

void SurgSim::Graphics::View::setCamera ( std::shared_ptr< SurgSim::Framework::Component camera)
virtual

Sets the camera which provides the viewpoint in the scene.

Parameters
cameraCamera whose image will be shown in this view
Returns
True if it succeeded, false if it failed

Reimplemented in SurgSim::Graphics::OsgView.

◆ setDimensions()

virtual void SurgSim::Graphics::View::setDimensions ( const std::array< int, 2 > &  dimensions)
pure virtual

Set the dimensions of this view.

Parameters
dimensionsDimensions on the screen (in pixels)

Implemented in SurgSim::Graphics::OsgView.

◆ setDimensionsDouble()

virtual void SurgSim::Graphics::View::setDimensionsDouble ( const std::array< double, 2 > &  dimensions)
pure virtual

Set the dimensions of this view in doubles.

Parameters
dimensionsDimensions on the screen (in pixels)

Implemented in SurgSim::Graphics::OsgView.

◆ setDisplayType()

void SurgSim::Graphics::View::setDisplayType ( int  type)

Set the kind of display.

Exceptions
SurgSim::Framework::AssertionFailureif used after initialize has been called
Parameters
typeThe type of display

◆ setEyeSeparation()

void SurgSim::Graphics::View::setEyeSeparation ( double  val)

Set the distance between the users eyes, this is necessary to calculate the correct projection matrices for stereo rendering.

Exceptions
SurgSim::Framework::AssertionFailureif used after initialize has been called.
Note
this is only used when rendering stereo.
Parameters
valThe distance between the eyes in m.

◆ setFullScreen()

void SurgSim::Graphics::View::setFullScreen ( bool  val)

Request the display to use the whole screen.

Exceptions
SurgSim::Framework::AssertionFailureif used after initialize has been called.
Parameters
valIf true the display will use up the whole screen, ignoring the dimension and location settings

◆ setPosition()

virtual void SurgSim::Graphics::View::setPosition ( const std::array< int, 2 > &  position)
pure virtual

Set the position of this view.

Parameters
positionPosition on the screen (in pixels)
Returns
True if it succeeded, false if it failed

Implemented in SurgSim::Graphics::OsgView.

◆ setScreenDistance()

void SurgSim::Graphics::View::setScreenDistance ( double  val)

Set the distance of the user from the screen, this is necessary to calculate the correct projection matrices for stereo rendering.

Exceptions
SurgSim::Framework::AssertionFailureif used after initialize has been called.
Note
this is only used when rendering stereo.
Parameters
valThe distance from the user to the screen in m.

◆ setScreenHeight()

void SurgSim::Graphics::View::setScreenHeight ( double  val)

Set the height of the screen, this is necessary to calculate the correct projection matrices for stereo rendering.

Exceptions
SurgSim::Framework::AssertionFailureif used after initialize has been called.
Note
this is only used when rendering stereo.
Parameters
valThe height of the screen used, in m.

◆ setScreenWidth()

void SurgSim::Graphics::View::setScreenWidth ( double  val)

Set the width of the screen, this is necessary to calculate the correct projection matrices for stereo rendering.

Exceptions
SurgSim::Framework::AssertionFailureif used after initialize has been called.
Note
this is only used when rendering stereo.
Parameters
valThe width of the screen used, in m.

◆ setStereoMode()

void SurgSim::Graphics::View::setStereoMode ( int  val)
virtual

Set the mode that this view should use for stereo display, see StereMode for all the modes.

Exceptions
SurgSim::Framework::AssertionFailureif used after initialize has been called.
Parameters
valThe actual mode.

◆ setTargetScreen()

void SurgSim::Graphics::View::setTargetScreen ( int  val)

Request a certain screen to be used for this view.

Exceptions
SurgSim::Framework::AssertionFailureif used after initialize has been called.
Parameters
valThe number of the screen (base 0) that should be used for this view.

◆ setWindowBorderEnabled()

virtual void SurgSim::Graphics::View::setWindowBorderEnabled ( bool  enabled)
pure virtual

Sets whether the view window has a border.

Parameters
enabledTrue to enable the border around the window; false for no border

Implemented in SurgSim::Graphics::OsgView.

◆ update()

virtual void SurgSim::Graphics::View::update ( double  dt)
pure virtual

Updates the view.

Parameters
dtThe time in seconds of the preceding timestep.

Implemented in SurgSim::Graphics::OsgView.

Member Data Documentation

◆ m_camera

std::shared_ptr<Camera> SurgSim::Graphics::View::m_camera
private

Camera whose image will be shown in this view.

◆ m_displayType

int SurgSim::Graphics::View::m_displayType
private

The requested display type.

◆ m_eyeSeparation

double SurgSim::Graphics::View::m_eyeSeparation
private

Distance between eypoints in m.

◆ m_isFullscreen

bool SurgSim::Graphics::View::m_isFullscreen
private

Whether to go fullscreen.

◆ m_screenDistance

double SurgSim::Graphics::View::m_screenDistance
private

Distance from user to screen in m.

◆ m_screenHeight

double SurgSim::Graphics::View::m_screenHeight
private

Height of screen in m.

◆ m_screenWidth

double SurgSim::Graphics::View::m_screenWidth
private

Width of screen in m.

◆ m_stereoMode

int SurgSim::Graphics::View::m_stereoMode
private

The stereo mode, that is being used.

◆ m_targetScreen

int SurgSim::Graphics::View::m_targetScreen
private

Index of the screen to be used.


The documentation for this class was generated from the following files: