20 #ifndef Tulip_GLSCENE_H
21 #define Tulip_GLSCENE_H
23 #include <tulip/tulipconf.h>
25 #include <tulip/Graph.h>
26 #include <tulip/GlLODCalculator.h>
27 #include <tulip/GlSceneObserver.h>
28 #include <tulip/GlLayer.h>
29 #include <tulip/GlDisplayListManager.h>
30 #include <tulip/GlTextureManager.h>
47 enum SelectedEntityType {
51 SIMPLE_ENTITY_SELECTED = 3
54 SelectedEntity():simpleEntity(NULL),complexEntityId((
unsigned int)(-1)),entityType(UNKNOW_SELECTED),complexEntityGraph(NULL) {}
55 SelectedEntity(
GlSimpleEntity *entity):simpleEntity(entity),complexEntityId((
unsigned int)(-1)),entityType(SIMPLE_ENTITY_SELECTED),complexEntityGraph(NULL) {}
56 SelectedEntity(
Graph *graph,
unsigned int id,SelectedEntityType type):simpleEntity(NULL),complexEntityId(
id),entityType(type),complexEntityGraph(graph) {}
59 assert(simpleEntity!=NULL);
63 unsigned int getComplexEntityId()
const {
64 assert(complexEntityId!=(
unsigned int)(-1));
65 return complexEntityId;
68 Graph *getComplexEntityGraph()
const {
69 assert(complexEntityGraph!=NULL);
70 return complexEntityGraph;
73 SelectedEntityType getEntityType()
const {
86 if(entityType == NODE_SELECTED) {
87 return node(complexEntityId);
104 if(entityType == EDGE_SELECTED) {
105 return edge(complexEntityId);
115 unsigned int complexEntityId;
116 SelectedEntityType entityType;
117 Graph *complexEntityGraph;
159 GlScene(GlLODCalculator *calculator=NULL);
167 void initGlParameters();
192 void computeAjustSceneToSize(
int width,
int height, Coord *center, Coord *eye,
float *sceneRadius,
float *xWhiteFactor,
float *yWhiteFactor,
BoundingBox *sceneBoundingBox=NULL,
float *zoomFactor=NULL);
199 void ajustSceneToSize(
int width,
int height);
205 void zoomXY(
int step,
const int x,
const int y);
211 void zoom(
float factor,
const Coord& dest);
222 void translateCamera(
const int x,
const int y,
const int z);
230 void rotateScene(
const int x,
const int y,
const int z);
242 bool selectEntities(RenderingEntitiesFlag type,
int x,
int y,
int h,
int w,
GlLayer *layer,std::vector<SelectedEntity>& selectedEntities);
247 void outputSVG(
unsigned int size,
const std::string& filename);
252 void outputEPS(
unsigned int size,
const std::string& filename);
257 unsigned char * getImage();
264 viewport=newViewport;
290 backgroundColor=color;
297 return backgroundColor;
304 this->viewOrtho=viewOrtho;
320 GlLayer *createLayer(
const std::string &name);
329 GlLayer *createLayerBefore(
const std::string &layerName,
const std::string &beforeLayerWithName);
338 GlLayer *createLayerAfter(
const std::string &layerName,
const std::string &afterLayerWithName);
345 void addExistingLayer(
GlLayer *layer);
353 bool addExistingLayerBefore(
GlLayer *layer,
const std::string &beforeLayerWithName);
361 bool addExistingLayerAfter(
GlLayer *layer,
const std::string &afterLayerWithName);
367 GlLayer *getLayer(
const std::string& name);
375 void removeLayer(
const std::string& name,
bool deleteLayer=
true);
383 void removeLayer(
GlLayer *layer,
bool deleteLayer=
true);
397 for(std::vector<std::pair<std::string,GlLayer*> >::iterator it=layersList.begin(); it!=layersList.end(); ++it)
406 void getXML(std::string &out);
411 void getXMLOnlyForCameras(std::string &out);
416 void setWithXML(std::string &in,
Graph *graph);
422 return lodCalculator;
429 lodCalculator=calculator;
430 calculator->setScene(*
this);
443 return glGraphComposite;
458 assert(graphLayer!=NULL);
459 return graphLayer->getCamera();
467 assert(graphLayer!=NULL);
468 graphLayer->setCamera(camera);
475 clearBufferAtDraw = clear;
482 return clearBufferAtDraw;
487 std::vector<std::pair<std::string,GlLayer *> > layersList;
488 GlLODCalculator *lodCalculator;
489 Vector<int, 4> viewport;
490 Color backgroundColor;
496 bool clearBufferAtDraw;
522 void notifyModifyLayer(
const std::string &name,
GlLayer *layer);
537 #endif // Tulip_GLSCENE_H