Tulip  5.6.3
Large graphs analysis and drawing
tlp::Camera Class Reference

#include <Camera.h>

+ Inheritance diagram for tlp::Camera:
+ Collaboration diagram for tlp::Camera:

Public Member Functions

 Camera (const Camera &)=default
 
 Camera (GlScene *scene, bool d3)
 
 Camera (GlScene *scene, Coord center=Coord(0, 0, 0), Coord eyes=Coord(0, 0, 10), Coord up=Coord(0, -1, 0), double zoomFactor=0.5, double sceneRadius=10)
 
 ~Camera () override
 
BoundingBox getBoundingBox () const
 
const Coord & getCenter () const
 
const Coord & getEyes () const
 
GlScenegetScene () const
 
double getSceneRadius () const
 
const Coord & getUp () const
 
const Vector< int, 4 > & getViewport () const
 
virtual void getXML (std::string &outString)
 
double getZoomFactor () const
 
bool is3D () const
 
void loadCameraParametersWith (const Camera &camera)
 
void move (float speed)
 
Cameraoperator= (const Camera &camera)
 
void rotate (float angle, float x, float y, float z)
 
Coord screenTo3DWorld (const Coord &point) const
 
void setCenter (const Coord &center)
 
void setEyes (const Coord &eyes)
 
void setScene (GlScene *scene)
 
void setUp (const Coord &up)
 
virtual void setWithXML (const std::string &inString, unsigned int &currentPosition)
 
void setZoomFactor (double zoomFactor)
 
void strafeLeftRight (float speed)
 
void strafeUpDown (float speed)
 
Coord viewportTo3DWorld (const Coord &point) const
 
Coord worldTo2DScreen (const Coord &obj) const
 
Coord worldTo2DViewport (const Coord &obj) const
 
- Public Member Functions inherited from tlp::Observable
void addListener (Observable &listener) const
 
void addListener (Observable *const listener) const
 
void addObserver (Observable &observer) const
 
void addObserver (Observable *const observer) const
 
unsigned int countListeners () const
 
unsigned int countObservers () const
 
unsigned int getReceived () const
 
unsigned int getSent () const
 
void removeListener (Observable &listener) const
 
void removeListener (Observable *const listener) const
 
void removeObserver (Observable &observer) const
 
void removeObserver (Observable *const observer) const
 

Additional Inherited Members

- Static Public Member Functions inherited from tlp::Observable
static void disableEventNotification ()
 
static void enableEventNotification ()
 
static tlp::node getNode (const tlp::Observable *obs)
 
static ObservablegetObject (tlp::node n)
 
static const tlp::VectorGraph & getObservableGraph ()
 
static unsigned int getScheduled (tlp::node n)
 
static void holdObservers ()
 
static bool isAlive (tlp::node n)
 
static unsigned int observersHoldCounter ()
 
static void unholdObservers ()
 
- Protected Member Functions inherited from tlp::Observable
 Observable (const Observable &)
 
bool hasOnlookers () const
 
void observableDeleted ()
 
Observableoperator= (const Observable &)
 
void sendEvent (const Event &message)
 
virtual void treatEvent (const Event &message)
 
virtual void treatEvents (const std::vector< Event > &events)
 

Detailed Description

Tulip OpenGL camera object.

This camera can be a 2D or 3D camera After setup you can do some basic operation :

  • Move, rotate, strafeLeftRight and strafeUpDown to modify point of view
  • You can directly modify camera parameters with setSceneRadius, setZoomFactor, setEyes, setCenter and setUp
  • You can transform viewport coordinates to 3D world coordinates with viewportTo3DWorld() function and 3D world coordinates to viewport coordinates with worldTo2DViewport() function A camera is a main component of GlLayer and GlScene
    See also
    GlLayer
    GlScene

Definition at line 47 of file Camera.h.

Constructor & Destructor Documentation

◆ Camera() [1/2]

tlp::Camera::Camera ( GlScene scene,
Coord  center = Coord(0, 0, 0),
Coord  eyes = Coord(0, 0, 10),
Coord  up = Coord(0, -1, 0),
double  zoomFactor = 0.5,
double  sceneRadius = 10 
)

Constructor.

Parameters
sceneA layer is attached to a scene so we have to specify it in the constructor
center3D coordinates of point visualized by the camera
eye3D position of the camera
upnormalized up 3D coordinates of the camera
zoomFactorlevel of zoom of the camera
sceneRadiusscene radius of the camera

◆ Camera() [2/2]

tlp::Camera::Camera ( GlScene scene,
bool  d3 
)

Constructor : used to create a 2D camera.

◆ ~Camera()

tlp::Camera::~Camera ( )
override

Destructor.

Member Function Documentation

◆ getBoundingBox()

BoundingBox tlp::Camera::getBoundingBox ( ) const

Return the camera bounding box.

This bounding box is the part of the scene visualized by this camera.

◆ getCenter()

const Coord& tlp::Camera::getCenter ( ) const
inline

Return the center.

3D coordinates of point visualized by the camera

Definition at line 179 of file Camera.h.

◆ getEyes()

const Coord& tlp::Camera::getEyes ( ) const
inline

Return the eyes.

3D position of the camera

Definition at line 164 of file Camera.h.

◆ getScene()

GlScene* tlp::Camera::getScene ( ) const
inline

Return the camera's scene.

Definition at line 83 of file Camera.h.

◆ getSceneRadius()

double tlp::Camera::getSceneRadius ( ) const
inline

Return the scene radius.

Definition at line 134 of file Camera.h.

◆ getUp()

const Coord& tlp::Camera::getUp ( ) const
inline

Return the up vector.

normalized up 3D coordinates of the camera

Definition at line 194 of file Camera.h.

◆ getViewport()

const Vector<int, 4>& tlp::Camera::getViewport ( ) const

Return the viewport of the attached scene.

◆ getXML()

virtual void tlp::Camera::getXML ( std::string &  outString)
virtual

Function to export data in outString (in XML format)

◆ getZoomFactor()

double tlp::Camera::getZoomFactor ( ) const
inline

Return the zoom factor.

level of zoom of the camera

Definition at line 149 of file Camera.h.

◆ is3D()

bool tlp::Camera::is3D ( ) const
inline

Return if the camera is a 3D one.

Definition at line 122 of file Camera.h.

◆ loadCameraParametersWith()

void tlp::Camera::loadCameraParametersWith ( const Camera camera)
inline

Load this camera parameters (eye, center, zoom factor) with an other camera parameters.

Definition at line 90 of file Camera.h.

◆ move()

void tlp::Camera::move ( float  speed)

This function moves the camera forward or backward depending on the speed.

◆ rotate()

void tlp::Camera::rotate ( float  angle,
float  x,
float  y,
float  z 
)

This function rotates the camera's eyes around the center depending on the values passed in.

◆ screenTo3DWorld()

Coord tlp::Camera::screenTo3DWorld ( const Coord &  point) const
inline

Return the 3D world coordinate for the given viewport point.

Warning
This function set up the projection and modelview matrix

Definition at line 208 of file Camera.h.

◆ setCenter()

void tlp::Camera::setCenter ( const Coord &  center)

Set the center.

3D coordinates of point visualized by the camera

◆ setEyes()

void tlp::Camera::setEyes ( const Coord &  eyes)

Set the eye.

3D position of the camera

◆ setScene()

void tlp::Camera::setScene ( GlScene scene)

Set the camera's scene The viewport is store in the scene, so we must attach camera to a scene.

◆ setUp()

void tlp::Camera::setUp ( const Coord &  up)

Set the up vector.

normalized up 3D coordinates of the camera

◆ setWithXML()

virtual void tlp::Camera::setWithXML ( const std::string &  inString,
unsigned int &  currentPosition 
)
virtual

Function to set data with inString (in XML format)

◆ setZoomFactor()

void tlp::Camera::setZoomFactor ( double  zoomFactor)

Set the zoom factor.

level of zoom of the camera

◆ strafeLeftRight()

void tlp::Camera::strafeLeftRight ( float  speed)

This function strafes the camera left and right depending on the speed (-/+)

◆ strafeUpDown()

void tlp::Camera::strafeUpDown ( float  speed)

This function strafes the camera up and down depending on the speed (-/+)

◆ viewportTo3DWorld()

Coord tlp::Camera::viewportTo3DWorld ( const Coord &  point) const

Return the 3D world coordinate for the given viewport point.

Warning
This function set up the projection and modelview matrix
+ Here is the caller graph for this function:

◆ worldTo2DScreen()

Coord tlp::Camera::worldTo2DScreen ( const Coord &  obj) const
inline

Return the viewport position for the given 3D coordinate.

Warning
This function set up the projection and modelview matrix

Definition at line 222 of file Camera.h.

◆ worldTo2DViewport()

Coord tlp::Camera::worldTo2DViewport ( const Coord &  obj) const

Return the viewport position for the given 3D coordinate.

Warning
This function set up the projection and modelview matrix
+ Here is the caller graph for this function: