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

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

#include <View.h>

Inheritance diagram for SurgSim::Graphics::View:
SurgSim::Framework::Component SurgSim::Framework::Accessible SurgSim::Framework::FactoryBase1< Component, std::string > MockView SurgSim::Graphics::NotMockView 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::string > FactoryType
 

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.
 
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.
 
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.
 
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.
 
 ~Accessible ()
 Destructor.
 
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...
 
std::vector< std::string > getProperties ()
 
template<>
boost::any getValue (const std::string &name) const
 

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.

Constructor & Destructor Documentation

§ View()

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

Constructor.

Parameters
nameName of the view

Member Function Documentation

§ 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 MockView, and 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 MockView, and 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 MockView, and 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 MockView, and 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 MockView, and 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 MockView, and 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 MockView, and 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 MockView, and 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 MockView, and SurgSim::Graphics::OsgView.


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