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.1f, 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 unsigned char *getImage();
300 viewport = newViewport;
311 viewport[3] = height;
326 backgroundColor = color;
333 return backgroundColor;
340 this->viewOrtho = viewOrtho;
356 GlLayer *createLayer(
const std::string &name);
365 GlLayer *createLayerBefore(
const std::string &layerName,
const std::string &beforeLayerWithName);
374 GlLayer *createLayerAfter(
const std::string &layerName,
const std::string &afterLayerWithName);
381 void addExistingLayer(
GlLayer *layer);
389 bool addExistingLayerBefore(
GlLayer *layer,
const std::string &beforeLayerWithName);
397 bool addExistingLayerAfter(
GlLayer *layer,
const std::string &afterLayerWithName);
403 GlLayer *getLayer(
const std::string &name);
411 void removeLayer(
const std::string &name,
bool deleteLayer =
true);
419 void removeLayer(
GlLayer *layer,
bool deleteLayer =
true);
433 for (
auto &it : layersList)
442 void getXML(std::string &out);
447 void getXMLOnlyForCameras(std::string &out);
452 void setWithXML(std::string &in,
Graph *graph);
458 return lodCalculator;
465 lodCalculator = calculator;
466 calculator->setScene(*
this);
480 return glGraphComposite;
495 assert(graphLayer !=
nullptr);
496 return graphLayer->getCamera();
504 assert(graphLayer !=
nullptr);
505 graphLayer->setCamera(camera);
512 clearBufferAtDraw = clear;
519 return clearBufferAtDraw;
526 clearDepthBufferAtDraw = clear;
533 return clearDepthBufferAtDraw;
540 clearStencilBufferAtDraw = clear;
547 return clearStencilBufferAtDraw;
551 std::vector<std::pair<std::string, GlLayer *>> layersList;
552 GlLODCalculator *lodCalculator;
553 Vector<int, 4> viewport;
554 Color backgroundColor;
560 bool clearBufferAtDraw;
564 bool clearDepthBufferAtDraw;
566 bool clearStencilBufferAtDraw;
589 void notifyModifyLayer(
const std::string &name,
GlLayer *layer);
602 #endif // Tulip_GLSCENE_H