Tulip  5.6.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 adjustSceneToSize (int width, int height)
 
void ajustSceneToSize (int width, int height)
 
void centerScene ()
 
void clearLayersList ()
 
void computeAdjustSceneToSize (int width, int height, Coord *center, Coord *eye, float *sceneRadius, float *xWhiteFactor, float *yWhiteFactor, BoundingBox *sceneBoundingBox=nullptr, float *zoomFactor=nullptr)
 
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 ()
 
const Vector< int, 4 > & getViewport () const
 
void getXML (std::string &out)
 
void getXMLOnlyForCameras (std::string &out)
 
void initGlParameters ()
 
bool isViewOrtho ()
 
void removeLayer (const std::string &name, bool deleteLayer=true)
 
void removeLayer (GlLayer *layer, bool deleteLayer=true)
 
void rotateCamera (const int x, const int y, const int z)
 
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 (int x, int y, int width, int height)
 
void setViewport (Vector< int, 4 > &newViewport)
 
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 &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 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 144 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.

◆ adjustSceneToSize()

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

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

◆ computeAdjustSceneToSize()

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

Compute information for adjustSceneToSize

Parameters
widthrequest width
heightrequest height
centerthe result center will be stored in (if center != nullptr)
eyethe result eye will be stored in (if eye != nullptr)
sceneRadiusthe result sceneRadius will be stored in (if sceneRadius != nullptr)
xWhiteFactorthe white part on x borders (left and right), the computed empty space size will be stored in (if xWhiteFactor != nullptr)
yWhiteFactorthe white part on y borders (top and bottom), the computed empty space size will be stored in (if yWhiteFactor != nullptr)
sceneBoundingBoxthe computed sceneBoundingBox will be stored in (if sceneBoundingBox != nullptr)
zoomFactorthe computed zoomFactor will be stored in (if zoomFactor != 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 316 of file GlScene.h.

◆ getBoundingBox()

BoundingBox tlp::GlScene::getBoundingBox ( )

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

Warning
This bounding box is computed in rendering, so if you add an entity in a layer the bounding box includes this entity if a draw is called

◆ getCalculator()

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

Return lod calculator used to render this scene.

Definition at line 441 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 502 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 516 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 530 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 463 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 478 of file GlScene.h.

+ Here is the caller graph for this function:

◆ getGraphLayer()

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

Return the layer containing the current GlGraphComposite.

Definition at line 470 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 408 of file GlScene.h.

◆ getViewport()

const 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 302 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 330 of file GlScene.h.

◆ removeLayer() [1/2]

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

Remove the layer with name This GlLayer is automatically deleted 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 automatically deleted If you want to keep this GlLayer you can put false to deleteLayer parameters but after that you have the ownership of the GlLayer.

◆ rotateCamera()

void tlp::GlScene::rotateCamera ( 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
+ Here is the caller graph for this function:

◆ 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 309 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 448 of file GlScene.h.

◆ setClearBufferAtDraw()

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

Set if OpenGL buffer will be cleared at draw.

Definition at line 495 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 509 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 523 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 487 of file GlScene.h.

◆ setViewOrtho()

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

Set if scene is render in orthogonal mode.

Definition at line 323 of file GlScene.h.

◆ setViewport() [1/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 291 of file GlScene.h.

◆ setViewport() [2/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 283 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)

+ Here is the caller graph for this function:

◆ zoom() [1/2]

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

Zoom to given world coordinate.

Warning
factor parameter isn't be used
+ Here is the caller graph for this function:

◆ zoom() [2/2]

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

Zoom by step.

Parameters
stepof zoom

Definition at line 239 of file GlScene.h.

◆ zoomFactor()

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

Zoom by factor.

Parameters
factorof zoom
+ Here is the caller graph for this function:

◆ 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
+ Here is the caller graph for this function: