Tulip  4.6.0
Better Visualization Through Research
tlp::GlScene Class Reference

#include <GlScene.h>

+ Inheritance diagram for tlp::GlScene:
+ Collaboration diagram for tlp::GlScene:

List of all members.

Public Member Functions

 GlScene (GlLODCalculator *calculator=NULL)
void addExistingLayer (GlLayer *layer)
bool addExistingLayerAfter (GlLayer *layer, const std::string &afterLayerWithName)
bool addExistingLayerBefore (GlLayer *layer, const std::string &beforeLayerWithName)
void ajustSceneToSize (int width, int height)
void centerScene ()
void clearLayersList ()
void computeAjustSceneToSize (int width, int height, Coord *center, Coord *eye, float *sceneRadius, float *xWhiteFactor, float *yWhiteFactor, BoundingBox *sceneBoundingBox=NULL, float *zoomFactor=NULL)
GlLayercreateLayer (const std::string &name)
GlLayercreateLayerAfter (const std::string &layerName, const std::string &afterLayerWithName)
GlLayercreateLayerBefore (const std::string &layerName, const std::string &beforeLayerWithName)
void draw ()
Color getBackgroundColor () const
BoundingBox getBoundingBox ()
GlLODCalculator * getCalculator ()
bool getClearBufferAtDraw () const
GlGraphCompositegetGlGraphComposite ()
CameragetGraphCamera ()
GlLayergetGraphLayer ()
unsigned char * getImage ()
GlLayergetLayer (const std::string &name)
const std::vector< std::pair
< std::string, GlLayer * > > & 
getLayersList ()
Vector< int, 4 > getViewport () const
void getXML (std::string &out)
void getXMLOnlyForCameras (std::string &out)
void initGlParameters ()
bool isViewOrtho ()
void outputEPS (unsigned int size, const std::string &filename)
void outputSVG (unsigned int size, const std::string &filename)
void removeLayer (const std::string &name, bool deleteLayer=true)
void removeLayer (GlLayer *layer, bool deleteLayer=true)
void rotateScene (const int x, const int y, const int z)
bool selectEntities (RenderingEntitiesFlag type, int x, int y, int h, int w, GlLayer *layer, std::vector< SelectedEntity > &selectedEntities)
void setBackgroundColor (const Color &color)
void setCalculator (GlLODCalculator *calculator)
void setClearBufferAtDraw (bool clear)
void setGraphCamera (Camera *camera)
void setViewOrtho (bool viewOrtho)
void setViewport (Vector< int, 4 > &newViewport)
void setViewport (int x, int y, int width, int height)
void setWithXML (std::string &in, Graph *graph)
void translateCamera (const int x, const int y, const int z)
void zoom (float factor, const Coord &dest)
void zoom (int step)
void zoomFactor (float factor)
void zoomXY (int step, const int x, const int y)

Detailed Description

Tulip scene class.

The GlScene class is the core of the tulip rendering system This class is used to render entities and graph in OpenGL

If you want to render entities and graph, you have to use GlLayer system. You just have to create GlLayer and add GlEntity in. If you create more than one GlLayer, layers are rendered one after one, so the first GlLayer added is rendered in first.

See also:
GlLayer
GlSimpleEntity

After adding layers you can do a centerScene() and a draw()

 GlLayer *mainLayer=new GlLayer("Main");
 GlGraphComposite *graphComposite=new GlGraphComposite(graph);
 mainLayer->addGlEntity(graphComposite,"graph");
 GlLayer *otherLayer=new GlLayer("Other");
 GlCircle *circle=new GlCircle();
 otherLayer->addGlEntity(circle,"circle");
 glScene.addLayer(mainLayer);
 glScene.addLayer(otherLayer);
 glScene.centerScene();
 glScene.draw();

If you want to create a widget with a visualisation is better to use GlMainWidget class (this class use a GlScene inside)

Definition at line 153 of file GlScene.h.


Constructor & Destructor Documentation

tlp::GlScene::GlScene ( GlLODCalculator *  calculator = NULL)

Constructor Default scene is empty.

Parameters:
calculatorBy default GlScene use a GlCPULODCalculator to compute LOD but you can change this default lod calculator, to do that : put your calculator in constructor parameters Available calculators are : GlCPULODCalculator and GlQuadTreeLODCalculator

Member Function Documentation

Add an existing layer in the scene Now the scene have the ownership of this GlLayer so you don't have to delete this GlLayer.

bool tlp::GlScene::addExistingLayerAfter ( GlLayer layer,
const std::string &  afterLayerWithName 
)

Add an existing layer in the scene just after layer with given name Return false if the layer with beforeLayerWithName is not find Now the scene have the ownership of this GlLayer so you don't have to delete this GlLayer.

bool tlp::GlScene::addExistingLayerBefore ( GlLayer layer,
const std::string &  beforeLayerWithName 
)

Add an existing layer in the scene just before layer with given name Return false if the layer with beforeLayerWithName is not find Now the scene have the ownership of this GlLayer so you don't have to delete this GlLayer.

void tlp::GlScene::ajustSceneToSize ( int  width,
int  height 
)

Ajust camera to have entities near borders

Parameters:
widthrequested width
heightrequested height

Center scene After this function all entities are visible on the screen

void tlp::GlScene::clearLayersList ( ) [inline]

Clear layers list Layers will not be deleted in this function.

Definition at line 404 of file GlScene.h.

void tlp::GlScene::computeAjustSceneToSize ( int  width,
int  height,
Coord *  center,
Coord *  eye,
float *  sceneRadius,
float *  xWhiteFactor,
float *  yWhiteFactor,
BoundingBox sceneBoundingBox = NULL,
float *  zoomFactor = NULL 
)

Compute information for ajustSceneToSize

Parameters:
width: request width
height: request height
center: the result center will be stored in (if center != NULL)
eye: the result eye will be stored in (if eye != NULL)
sceneRadius: the result sceneRadius will be stored in (if sceneRadius != NULL)
xWhiteFactor: xWhiteFactor is the white part on x borders (left and right), the result xWhiteFactor will be stored in (if xWhiteFactor != NULL)
yWhiteFactor: yWhiteFactor is the white part on y borders (top and bottom), the result yWhiteFactor will be stored in (if yWhiteFactor != NULL)
sceneBoundingBox: the result sceneBoundingBox will be stored in (if sceneBoundingBox != NULL)
GlLayer* tlp::GlScene::createLayer ( const std::string &  name)

Create a layer with the given name in the scene This layer is added to the layers list Now the scene have the ownership of this GlLayer so you don't have to delete this GlLayer.

Examples:
graph_display/graph_display.cpp.
GlLayer* tlp::GlScene::createLayerAfter ( const std::string &  layerName,
const std::string &  afterLayerWithName 
)

Create a layer with the given name in the scene just after layer with given name This layer is added to the layers list Return NULL if the layer with beforeLayerWithName is not find Now the scene have the ownership of this GlLayer so you don't have to delete this GlLayer.

GlLayer* tlp::GlScene::createLayerBefore ( const std::string &  layerName,
const std::string &  beforeLayerWithName 
)

Create a layer with the given name in the scene just before layer with given name This layer is added to the layers list Return NULL if the layer with beforeLayerWithName is not find Now the scene have the ownership of this GlLayer so you don't have to delete this GlLayer.

Draw the scene This function is the most important function of GlScene. If you want to render a scene into an OpenGL widget : call this function.

Color tlp::GlScene::getBackgroundColor ( ) const [inline]

Get the background color of the scene.

Definition at line 304 of file GlScene.h.

Return the bouding box of the scene (in 3D coordinates)

Warning:
This bounding box is compute in rendering, so if you add an entity in a layer the bounding box include this entity if a draw is call
GlLODCalculator* tlp::GlScene::getCalculator ( ) [inline]

Return lod calculator used to render this scene.

Definition at line 429 of file GlScene.h.

bool tlp::GlScene::getClearBufferAtDraw ( ) const [inline]

If false, color buffer will not be cleared before drawing the scene.

Definition at line 489 of file GlScene.h.

Return the current GlGraphComposite used by the scene.

Examples:
graph_display/graph_display.cpp.

Definition at line 450 of file GlScene.h.

By default the most important layer is the layer where the graph is visualized This function return the camera of this layer.

Definition at line 465 of file GlScene.h.

Return the layer containing the current GlGraphComposite.

Definition at line 457 of file GlScene.h.

unsigned char* tlp::GlScene::getImage ( )

Return the RGB image of GlScene.

GlLayer* tlp::GlScene::getLayer ( const std::string &  name)

Return the layer with name : name Return NULL if the layer doesn't exist in the scene.

const std::vector<std::pair<std::string, GlLayer*> >& tlp::GlScene::getLayersList ( ) [inline]

Return the layer list.

Definition at line 396 of file GlScene.h.

Vector<int, 4> tlp::GlScene::getViewport ( ) const [inline]

Get the viewport of the scene The viewport will be in many case the size of the widget containing the scene.

Definition at line 290 of file GlScene.h.

void tlp::GlScene::getXML ( std::string &  out)

Get XML description of the scene and children and store it in out string.

void tlp::GlScene::getXMLOnlyForCameras ( std::string &  out)

Get XML description of cameras of the scene and store it in out string.

Init scene's OpenGL parameters. You don't have to call this function, it is call when you do a draw.

bool tlp::GlScene::isViewOrtho ( ) [inline]

Scene is render in orthogonal mode ?

Definition at line 318 of file GlScene.h.

void tlp::GlScene::outputEPS ( unsigned int  size,
const std::string &  filename 
)

Output the scene in EPS.

void tlp::GlScene::outputSVG ( unsigned int  size,
const std::string &  filename 
)

Output the scene in SVG.

void tlp::GlScene::removeLayer ( const std::string &  name,
bool  deleteLayer = true 
)

Remove the layer with name This GlLayer is automaticaly delete If you want to keep this GlLayer you can put false to deleteLayer parameters but after that you have the ownership of the GlLayer.

void tlp::GlScene::removeLayer ( GlLayer layer,
bool  deleteLayer = true 
)

Remove the layer with name This GlLayer is automaticaly delete If you want to keep this GlLayer you can put false to deleteLayer parameters but after that you have the ownership of the GlLayer.

void tlp::GlScene::rotateScene ( const int  x,
const int  y,
const int  z 
)

Rotate camera by (x,y,z)

Parameters:
xrotation over X axis in degree
yrotation over Y axis in degree
zrotation over Z axis in degree
bool tlp::GlScene::selectEntities ( RenderingEntitiesFlag  type,
int  x,
int  y,
int  h,
int  w,
GlLayer layer,
std::vector< SelectedEntity > &  selectedEntities 
)

Select entities in scene.

Parameters:
typeEntities type to select (SelectSimpleEntities,SelectNodes,SelectEdges)
xscreen coordinates
yscreen coordinates
hheight in screen coordinates
wwidth in screen coordinates
layerwhere the selection will be performed
selectedEntitiesthe result of the selection is stored on it
void tlp::GlScene::setBackgroundColor ( const Color &  color) [inline]

Set the background color of the scene.

Definition at line 297 of file GlScene.h.

void tlp::GlScene::setCalculator ( GlLODCalculator *  calculator) [inline]

Set a new lod calculator used to render this scene.

Definition at line 436 of file GlScene.h.

void tlp::GlScene::setClearBufferAtDraw ( bool  clear) [inline]

Set if OpenGL buffer will be cleared at draw.

Definition at line 482 of file GlScene.h.

void tlp::GlScene::setGraphCamera ( Camera camera) [inline]

By default the most important layer is the layer where the graph is visualized This function set the camera of this layer.

Definition at line 474 of file GlScene.h.

void tlp::GlScene::setViewOrtho ( bool  viewOrtho) [inline]

Set if scene is render in orthogonal mode.

Definition at line 311 of file GlScene.h.

void tlp::GlScene::setViewport ( Vector< int, 4 > &  newViewport) [inline]

Set the viewport of the scene with a vector The viewport must be in many case the size of the widget containing the scene.

Definition at line 271 of file GlScene.h.

void tlp::GlScene::setViewport ( int  x,
int  y,
int  width,
int  height 
) [inline]

Set the viewport of the scene with 4 int The viewport must be in many case the size of the widget containing the scene.

Definition at line 279 of file GlScene.h.

void tlp::GlScene::setWithXML ( std::string &  in,
Graph graph 
)

Set scene's data and children with a XML.

void tlp::GlScene::translateCamera ( const int  x,
const int  y,
const int  z 
)

Translate camera by (x,y,z)

void tlp::GlScene::zoom ( float  factor,
const Coord &  dest 
)

Zoom to given world coordinate.

Warning:
factor parameter isn't be used
void tlp::GlScene::zoom ( int  step)

Zoom by step.

Parameters:
stepof zoom
void tlp::GlScene::zoomFactor ( float  factor)

Zoom by factor.

Parameters:
factorof zoom
void tlp::GlScene::zoomXY ( int  step,
const int  x,
const int  y 
)

Zoom by step to given x,y screen coordinates.

Parameters:
stepof zoom
 All Classes Files Functions Variables Enumerations Enumerator Properties