20 #ifndef Tulip_GLSCENE_H
21 #define Tulip_GLSCENE_H
25 #include <tulip/tulipconf.h>
26 #include <tulip/BoundingBox.h>
27 #include <tulip/GlLODCalculator.h>
28 #include <tulip/GlLayer.h>
29 #include <tulip/Color.h>
30 #include <tulip/Observable.h>
36 class GlGraphComposite;
52 enum SelectedEntityType {
56 SIMPLE_ENTITY_SELECTED = 3
60 : simpleEntity(
nullptr), complexEntityId(UINT_MAX), entityType(UNKNOW_SELECTED) {}
62 : simpleEntity(entity), complexEntityId(UINT_MAX), entityType(SIMPLE_ENTITY_SELECTED) {}
64 : complexEntityGraph(graph), complexEntityId(
id), entityType(type) {
65 assert((type == NODE_SELECTED) || (type == EDGE_SELECTED));
69 assert((entityType == SIMPLE_ENTITY_SELECTED) && (simpleEntity !=
nullptr));
73 unsigned int getComplexEntityId()
const {
74 assert((entityType != SIMPLE_ENTITY_SELECTED) && (complexEntityId != UINT_MAX));
75 return complexEntityId;
78 Graph *getComplexEntityGraph()
const {
79 assert((entityType != SIMPLE_ENTITY_SELECTED) && (complexEntityGraph !=
nullptr));
80 return complexEntityGraph;
83 SelectedEntityType getEntityType()
const {
90 assert((entityType == NODE_SELECTED) || (complexEntityId == UINT_MAX));
91 return node(complexEntityId);
98 assert((entityType == EDGE_SELECTED) || (complexEntityId == UINT_MAX));
99 return edge(complexEntityId);
105 Graph *complexEntityGraph;
107 unsigned int complexEntityId;
108 SelectedEntityType entityType;
153 GlScene(GlLODCalculator *calculator =
nullptr);
192 float *sceneRadius,
float *xWhiteFactor,
float *yWhiteFactor,
194 float *zoomFactor =
nullptr);
197 _DEPRECATED
void computeAjustSceneToSize(
int width,
int height, Coord *center, Coord *eye,
198 float *sceneRadius,
float *xWhiteFactor,
201 float *zoomFactor =
nullptr) {
202 computeAdjustSceneToSize(width, height, center, eye, sceneRadius, xWhiteFactor, yWhiteFactor,
203 sceneBoundingBox, zoomFactor);
213 _DEPRECATED
inline void ajustSceneToSize(
int width,
int height) {
214 adjustSceneToSize(width, height);
221 void zoomXY(
int step,
const int x,
const int y);
233 void zoom(
float factor,
const Coord &dest);
240 zoomFactor(powf(1.1f, step));
257 _DEPRECATED
inline void rotateScene(
const int x,
const int y,
const int z) {
258 rotateCamera(x, y, z);
272 std::vector<SelectedEntity> &selectedEntities);
284 viewport = newViewport;
295 viewport[3] = height;
310 backgroundColor = color;
317 return backgroundColor;
324 this->viewOrtho = viewOrtho;
395 void removeLayer(
const std::string &name,
bool deleteLayer =
true);
417 for (
auto &it : layersList)
442 return lodCalculator;
449 lodCalculator = calculator;
450 calculator->setScene(*
this);
464 return glGraphComposite;
479 assert(graphLayer !=
nullptr);
480 return graphLayer->getCamera();
488 assert(graphLayer !=
nullptr);
489 graphLayer->setCamera(camera);
496 clearBufferAtDraw = clear;
503 return clearBufferAtDraw;
510 clearDepthBufferAtDraw = clear;
517 return clearDepthBufferAtDraw;
524 clearStencilBufferAtDraw = clear;
531 return clearStencilBufferAtDraw;
535 std::vector<std::pair<std::string, GlLayer *>> layersList;
536 GlLODCalculator *lodCalculator;
537 Vector<int, 4> viewport;
538 Color backgroundColor;
544 bool clearBufferAtDraw;
548 bool clearDepthBufferAtDraw;
550 bool clearStencilBufferAtDraw;
573 void notifyModifyLayer(
const std::string &name,
GlLayer *layer);
Tulip OpenGL camera object.
Class use to visualize graph in OpenGL Tulip engine.
A GlLayer is like an 2D drawing software layer system.
void setViewport(Vector< int, 4 > &newViewport)
Set the viewport of the scene with a vector The viewport must be in many case the size of the widget ...
void zoomFactor(float factor)
Zoom by factor.
GlGraphComposite * getGlGraphComposite()
Return the current GlGraphComposite used by the scene.
void addExistingLayer(GlLayer *layer)
Add an existing layer in the scene Now the scene have the ownership of this GlLayer so you don't have...
void getXML(std::string &out)
Get XML description of the scene and children and store it in out string.
bool selectEntities(RenderingEntitiesFlag type, int x, int y, int h, int w, GlLayer *layer, std::vector< SelectedEntity > &selectedEntities)
Select entities in scene.
void getXMLOnlyForCameras(std::string &out)
Get XML description of cameras of the scene and store it in out string.
void setCalculator(GlLODCalculator *calculator)
Set a new lod calculator used to render this scene.
const Vector< int, 4 > & getViewport() const
Get the viewport of the scene The viewport will be in many case the size of the widget containing the...
bool getClearStencilBufferAtDraw() const
If false, color buffer will not be cleared before drawing the scene.
BoundingBox getBoundingBox()
Return the bounding box of the scene (in 3D coordinates)
GlScene(GlLODCalculator *calculator=nullptr)
Constructor Default scene is empty.
Camera & getGraphCamera()
By default the most important layer is the layer where the graph is visualized This function return t...
void setViewOrtho(bool viewOrtho)
Set if scene is render in orthogonal mode.
void zoomXY(int step, const int x, const int y)
Zoom by step to given x,y screen coordinates.
void setWithXML(std::string &in, Graph *graph)
Set scene's data and children with a XML.
void setViewport(int x, int y, int width, int height)
Set the viewport of the scene with 4 int The viewport must be in many case the size of the widget con...
bool getClearDepthBufferAtDraw() const
If false, depth buffer will not be cleared before drawing the scene.
bool 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 be...
bool 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 b...
GlLayer * getLayer(const std::string &name)
Return the layer with name : name Return nullptr if the layer doesn't exist in the scene.
void setBackgroundColor(const Color &color)
Set the background color of the scene.
GlLayer * getGraphLayer()
Return the layer containing the current GlGraphComposite.
void rotateCamera(const int x, const int y, const int z)
Rotate camera by (x,y,z)
void initGlParameters()
Init scene's OpenGL parameters. You don't have to call this function, it is call when you do a draw.
void setClearStencilBufferAtDraw(bool clear)
Set if OpenGL stencil buffer will be cleared at draw.
void 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...
GlLODCalculator * getCalculator()
Return lod calculator used to render this scene.
Color getBackgroundColor() const
Get the background color of the scene.
bool isViewOrtho()
Scene is render in orthogonal mode ?
void clearLayersList()
Clear layers list Layers will not be deleted in this function.
void zoom(float factor, const Coord &dest)
Zoom to given world coordinate.
unsigned char * getImage()
Return the RGB image of GlScene.
void setClearBufferAtDraw(bool clear)
Set if OpenGL buffer will be cleared at draw.
void adjustSceneToSize(int width, int height)
void setClearDepthBufferAtDraw(bool clear)
Set if OpenGL depth buffer will be cleared at draw.
void translateCamera(const int x, const int y, const int z)
Translate camera by (x,y,z)
GlLayer * 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 ...
void setGraphCamera(Camera *camera)
By default the most important layer is the layer where the graph is visualized This function set the ...
bool getClearBufferAtDraw() const
If false, color buffer will not be cleared before drawing the scene.
void zoom(int step)
Zoom by step.
GlLayer * 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 ...
GlLayer * 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...
void removeLayer(GlLayer *layer, bool deleteLayer=true)
Remove the layer with name This GlLayer is automatically deleted If you want to keep this GlLayer you...
void draw()
Draw the scene This function is the most important function of GlScene. If you want to render a scene...
const std::vector< std::pair< std::string, GlLayer * > > & getLayersList()
Return the layer list.
void computeAdjustSceneToSize(int width, int height, Coord *center, Coord *eye, float *sceneRadius, float *xWhiteFactor, float *yWhiteFactor, BoundingBox *sceneBoundingBox=nullptr, float *zoomFactor=nullptr)
Base class for all Tulip OpenGL entities.
The Observable class is the base of Tulip's observation system.
This class represents the 3D bounding box of an object. It is mostly used to determine whether or not...
Structure to store selected entities.
The edge struct represents an edge in a Graph object.
The node struct represents a node in a Graph object.