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);
161 void initGlParameters();
191 void computeAdjustSceneToSize(
int width,
int height, Coord *center, Coord *eye,
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);
211 void adjustSceneToSize(
int width,
int height);
213 _DEPRECATED
inline void ajustSceneToSize(
int width,
int height) {
214 adjustSceneToSize(width, height);
221 void zoomXY(
int step,
const int x,
const int y);
227 void zoomFactor(
float factor);
233 void zoom(
float factor,
const Coord &dest);
240 zoomFactor(powf(1.1f, step));
246 void translateCamera(
const int x,
const int y,
const int z);
254 void rotateCamera(
const int x,
const int y,
const int z);
257 _DEPRECATED
inline void rotateScene(
const int x,
const int y,
const int z) {
258 rotateCamera(x, y, z);
271 bool selectEntities(RenderingEntitiesFlag type,
int x,
int y,
int h,
int w, GlLayer *layer,
272 std::vector<SelectedEntity> &selectedEntities);
277 unsigned char *getImage();
284 viewport = newViewport;
295 viewport[3] = height;
310 backgroundColor = color;
317 return backgroundColor;
324 this->viewOrtho = viewOrtho;
340 GlLayer *createLayer(
const std::string &name);
349 GlLayer *createLayerBefore(
const std::string &layerName,
const std::string &beforeLayerWithName);
358 GlLayer *createLayerAfter(
const std::string &layerName,
const std::string &afterLayerWithName);
365 void addExistingLayer(
GlLayer *layer);
373 bool addExistingLayerBefore(
GlLayer *layer,
const std::string &beforeLayerWithName);
381 bool addExistingLayerAfter(
GlLayer *layer,
const std::string &afterLayerWithName);
387 GlLayer *getLayer(
const std::string &name);
395 void removeLayer(
const std::string &name,
bool deleteLayer =
true);
403 void removeLayer(
GlLayer *layer,
bool deleteLayer =
true);
417 for (
auto &it : layersList)
426 void getXML(std::string &out);
431 void getXMLOnlyForCameras(std::string &out);
436 void setWithXML(std::string &in,
Graph *graph);
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);
586 #endif // Tulip_GLSCENE_H