Tulip  5.3.0
Large graphs analysis and drawing
tlp::GlScene Class Reference

#include <GlScene.h>

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

Public Member Functions

 GlScene (GlLODCalculator *calculator=nullptr)
 
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=nullptr, float *zoomFactor=nullptr)
 
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
 
bool getClearDepthBufferAtDraw () const
 
bool getClearStencilBufferAtDraw () 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 setClearDepthBufferAtDraw (bool clear)
 
void setClearStencilBufferAtDraw (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)
 
- Public Member Functions inherited from tlp::Observable
void addListener (Observable *const listener) 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 *const listener) const
 
void removeObserver (Observable *const observerver) 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 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 160 of file GlScene.h.

Constructor & Destructor Documentation

◆ GlScene()

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

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

◆ addExistingLayer()

void tlp::GlScene::addExistingLayer ( GlLayer layer)

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.

◆ addExistingLayerAfter()

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.

◆ addExistingLayerBefore()

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.

◆ ajustSceneToSize()

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

Ajust camera to have entities near borders

Parameters
widthrequested width
heightrequested height

◆ centerScene()

void tlp::GlScene::centerScene ( )

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

◆ clearLayersList()

void tlp::GlScene::clearLayersList ( )
inline

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

Definition at line 420 of file GlScene.h.

◆ computeAjustSceneToSize()

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

Compute information for ajustSceneToSize

Parameters
width: request width
height: request height
center: the result center will be stored in (if center != nullptr)
eye: the result eye will be stored in (if eye != nullptr)
sceneRadius: the result sceneRadius will be stored in (if sceneRadius != nullptr)
xWhiteFactor: xWhiteFactor is the white part on x borders (left and right), the result xWhiteFactor will be stored in (if xWhiteFactor != nullptr)
yWhiteFactor: yWhiteFactor is the white part on y borders (top and bottom), the result yWhiteFactor will be stored in (if yWhiteFactor != nullptr)
sceneBoundingBox: the result sceneBoundingBox will be stored in (if sceneBoundingBox != nullptr)

◆ createLayer()

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.

◆ createLayerAfter()

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 nullptr 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.

◆ createLayerBefore()

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 nullptr 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()

void tlp::GlScene::draw ( )

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.

◆ getBackgroundColor()

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

Get the background color of the scene.

Definition at line 320 of file GlScene.h.

◆ getBoundingBox()

BoundingBox tlp::GlScene::getBoundingBox ( )

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

◆ getCalculator()

GlLODCalculator* tlp::GlScene::getCalculator ( )
inline

Return lod calculator used to render this scene.

Definition at line 446 of file GlScene.h.

◆ getClearBufferAtDraw()

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

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

Definition at line 507 of file GlScene.h.

◆ getClearDepthBufferAtDraw()

bool tlp::GlScene::getClearDepthBufferAtDraw ( ) const
inline

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

Definition at line 521 of file GlScene.h.

◆ getClearStencilBufferAtDraw()

bool tlp::GlScene::getClearStencilBufferAtDraw ( ) const
inline

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

Definition at line 535 of file GlScene.h.

◆ getGlGraphComposite()

GlGraphComposite* tlp::GlScene::getGlGraphComposite ( )
inline

Return the current GlGraphComposite used by the scene.

Examples:
graph_display/graph_display.cpp.

Definition at line 468 of file GlScene.h.

◆ getGraphCamera()

Camera& tlp::GlScene::getGraphCamera ( )
inline

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 483 of file GlScene.h.

◆ getGraphLayer()

GlLayer* tlp::GlScene::getGraphLayer ( )
inline

Return the layer containing the current GlGraphComposite.

Definition at line 475 of file GlScene.h.

◆ getImage()

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

Return the RGB image of GlScene.

◆ getLayer()

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

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

◆ getLayersList()

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

Return the layer list.

Definition at line 412 of file GlScene.h.

◆ getViewport()

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 306 of file GlScene.h.

◆ getXML()

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

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

◆ getXMLOnlyForCameras()

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

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

◆ initGlParameters()

void tlp::GlScene::initGlParameters ( )

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

◆ isViewOrtho()

bool tlp::GlScene::isViewOrtho ( )
inline

Scene is render in orthogonal mode ?

Definition at line 334 of file GlScene.h.

◆ outputEPS()

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

Output the scene in EPS.

◆ outputSVG()

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

Output the scene in SVG.

◆ removeLayer() [1/2]

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.

◆ removeLayer() [2/2]

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.

◆ rotateScene()

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

◆ selectEntities()

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

◆ setBackgroundColor()

void tlp::GlScene::setBackgroundColor ( const Color &  color)
inline

Set the background color of the scene.

Definition at line 313 of file GlScene.h.

◆ setCalculator()

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

Set a new lod calculator used to render this scene.

Definition at line 453 of file GlScene.h.

◆ setClearBufferAtDraw()

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

Set if OpenGL buffer will be cleared at draw.

Definition at line 500 of file GlScene.h.

◆ setClearDepthBufferAtDraw()

void tlp::GlScene::setClearDepthBufferAtDraw ( bool  clear)
inline

Set if OpenGL depth buffer will be cleared at draw.

Definition at line 514 of file GlScene.h.

◆ setClearStencilBufferAtDraw()

void tlp::GlScene::setClearStencilBufferAtDraw ( bool  clear)
inline

Set if OpenGL stencil buffer will be cleared at draw.

Definition at line 528 of file GlScene.h.

◆ setGraphCamera()

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 492 of file GlScene.h.

◆ setViewOrtho()

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

Set if scene is render in orthogonal mode.

Definition at line 327 of file GlScene.h.

◆ setViewport() [1/2]

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 287 of file GlScene.h.

◆ setViewport() [2/2]

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 295 of file GlScene.h.

◆ setWithXML()

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

Set scene's data and children with a XML.

◆ translateCamera()

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

Translate camera by (x,y,z)

◆ zoom() [1/2]

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

Zoom to given world coordinate.

Warning
factor parameter isn't be used

◆ zoom() [2/2]

void tlp::GlScene::zoom ( int  step)

Zoom by step.

Parameters
stepof zoom

◆ zoomFactor()

void tlp::GlScene::zoomFactor ( float  factor)

Zoom by factor.

Parameters
factorof zoom

◆ zoomXY()

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

Zoom by step to given x,y screen coordinates.

Parameters
stepof zoom