20 #ifndef Tulip_GLSCENE_H 21 #define Tulip_GLSCENE_H 23 #include <tulip/tulipconf.h> 24 #include <tulip/BoundingBox.h> 25 #include <tulip/GlLODCalculator.h> 26 #include <tulip/GlLayer.h> 27 #include <tulip/Color.h> 28 #include <tulip/Observable.h> 34 class GlGraphComposite;
50 enum SelectedEntityType {
54 SIMPLE_ENTITY_SELECTED = 3
58 : simpleEntity(
nullptr), complexEntityId(uint(-1)), entityType(UNKNOW_SELECTED),
59 complexEntityGraph(
nullptr) {}
61 : simpleEntity(entity), complexEntityId(uint(-1)), entityType(SIMPLE_ENTITY_SELECTED),
62 complexEntityGraph(
nullptr) {}
64 : simpleEntity(
nullptr), complexEntityId(
id), entityType(type), complexEntityGraph(graph) {}
67 assert(simpleEntity !=
nullptr);
71 unsigned int getComplexEntityId()
const {
72 assert(complexEntityId != uint(-1));
73 return complexEntityId;
76 Graph *getComplexEntityGraph()
const {
77 assert(complexEntityGraph !=
nullptr);
78 return complexEntityGraph;
81 SelectedEntityType getEntityType()
const {
95 if (entityType == NODE_SELECTED) {
96 return node(complexEntityId);
113 if (entityType == EDGE_SELECTED) {
114 return edge(complexEntityId);
122 unsigned int complexEntityId;
123 SelectedEntityType entityType;
124 Graph *complexEntityGraph;
169 GlScene(GlLODCalculator *calculator =
nullptr);
177 void initGlParameters();
207 void computeAdjustSceneToSize(
int width,
int height, Coord *center, Coord *eye,
208 float *sceneRadius,
float *xWhiteFactor,
float *yWhiteFactor,
210 float *zoomFactor =
nullptr);
213 _DEPRECATED
void computeAjustSceneToSize(
int width,
int height, Coord *center, Coord *eye,
214 float *sceneRadius,
float *xWhiteFactor,
217 float *zoomFactor =
nullptr) {
218 computeAdjustSceneToSize(width, height, center, eye, sceneRadius, xWhiteFactor, yWhiteFactor,
219 sceneBoundingBox, zoomFactor);
227 void adjustSceneToSize(
int width,
int height);
229 _DEPRECATED
inline void ajustSceneToSize(
int width,
int height) {
230 adjustSceneToSize(width, height);
237 void zoomXY(
int step,
const int x,
const int y);
243 void zoomFactor(
float factor);
249 void zoom(
float factor,
const Coord &dest);
256 zoomFactor(powf(1.1, step));
262 void translateCamera(
const int x,
const int y,
const int z);
270 void rotateCamera(
const int x,
const int y,
const int z);
273 _DEPRECATED
inline void rotateScene(
const int x,
const int y,
const int z) {
274 rotateCamera(x, y, z);
287 bool selectEntities(RenderingEntitiesFlag type,
int x,
int y,
int h,
int w,
GlLayer *layer,
288 std::vector<SelectedEntity> &selectedEntities);
293 void outputSVG(
unsigned int size,
const std::string &filename);
298 void outputEPS(
unsigned int size,
const std::string &filename);
303 unsigned char *getImage();
310 viewport = newViewport;
321 viewport[3] = height;
336 backgroundColor = color;
343 return backgroundColor;
350 this->viewOrtho = viewOrtho;
366 GlLayer *createLayer(
const std::string &name);
375 GlLayer *createLayerBefore(
const std::string &layerName,
const std::string &beforeLayerWithName);
384 GlLayer *createLayerAfter(
const std::string &layerName,
const std::string &afterLayerWithName);
391 void addExistingLayer(
GlLayer *layer);
399 bool addExistingLayerBefore(
GlLayer *layer,
const std::string &beforeLayerWithName);
407 bool addExistingLayerAfter(
GlLayer *layer,
const std::string &afterLayerWithName);
413 GlLayer *getLayer(
const std::string &name);
421 void removeLayer(
const std::string &name,
bool deleteLayer =
true);
429 void removeLayer(
GlLayer *layer,
bool deleteLayer =
true);
443 for (std::vector<std::pair<std::string, GlLayer *>>::iterator it = layersList.begin();
444 it != layersList.end(); ++it)
453 void getXML(std::string &out);
458 void getXMLOnlyForCameras(std::string &out);
463 void setWithXML(std::string &in,
Graph *graph);
469 return lodCalculator;
476 lodCalculator = calculator;
477 calculator->setScene(*
this);
491 return glGraphComposite;
506 assert(graphLayer !=
nullptr);
507 return graphLayer->getCamera();
515 assert(graphLayer !=
nullptr);
516 graphLayer->setCamera(camera);
523 clearBufferAtDraw = clear;
530 return clearBufferAtDraw;
537 clearDepthBufferAtDraw = clear;
544 return clearDepthBufferAtDraw;
551 clearStencilBufferAtDraw = clear;
558 return clearStencilBufferAtDraw;
562 std::vector<std::pair<std::string, GlLayer *>> layersList;
563 GlLODCalculator *lodCalculator;
564 Vector<int, 4> viewport;
565 Color backgroundColor;
571 bool clearBufferAtDraw;
575 bool clearDepthBufferAtDraw;
577 bool clearStencilBufferAtDraw;
600 void notifyModifyLayer(
const std::string &name,
GlLayer *layer);
613 #endif // Tulip_GLSCENE_H
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 ...
edge getEdge() const
getEdge is a convenience method to perform the check on the selected element type and return the corr...
void setGraphCamera(Camera *camera)
By default the most important layer is the layer where the graph is visualized This function set the ...
void setBackgroundColor(const Color &color)
Set the background color of the scene.
Base class for all Tulip OpenGL entities.
void clearLayersList()
Clear layers list Layers will not be deleted in this function.
void setCalculator(GlLODCalculator *calculator)
Set a new lod calculator used to render this scene.
GlGraphComposite * getGlGraphComposite()
Return the current GlGraphComposite used by the scene.
bool isViewOrtho()
Scene is render in orthogonal mode ?
Camera & getGraphCamera()
By default the most important layer is the layer where the graph is visualized This function return t...
bool getClearDepthBufferAtDraw() const
If false, depth buffer will not be cleared before drawing the scene.
bool getClearBufferAtDraw() const
If false, color buffer will not be cleared before drawing the scene.
Color getBackgroundColor() const
Get the background color of the scene.
The edge struct represents an edge in a Graph object.
The node struct represents a node in a Graph object.
GlLayer * getGraphLayer()
Return the layer containing the current GlGraphComposite.
This class represents the 3D bounding box of an object. It is mostly used to determine whether or not...
Tulip OpenGL camera object.
void setClearDepthBufferAtDraw(bool clear)
Set if OpenGL depth buffer will be cleared at draw.
void setViewOrtho(bool viewOrtho)
Set if scene is render in orthogonal mode.
const std::vector< std::pair< std::string, GlLayer * > > & getLayersList()
Return the layer list.
Class use to visualize graph in OpenGL Tulip engine.
GlLODCalculator * getCalculator()
Return lod calculator used to render this scene.
void setClearStencilBufferAtDraw(bool clear)
Set if OpenGL stencil buffer will be cleared at draw.
The Observable class is the base of Tulip's observation system.
bool getClearStencilBufferAtDraw() const
If false, color buffer will not be cleared before drawing the scene.
node getNode() const
getNode is a convenience method to perform the check on the selected element type and return the corr...
Structure to store selected entities.
void setClearBufferAtDraw(bool clear)
Set if OpenGL buffer will be cleared at draw.
void zoom(int step)
Zoom by step.
A GlLayer is like an 2D drawing software layer system.
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...
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...