20 #ifndef Tulip_GLSCENE_H 21 #define Tulip_GLSCENE_H 23 #include <tulip/tulipconf.h> 24 #include <tulip/GlLODCalculator.h> 25 #include <tulip/GlLayer.h> 26 #include <tulip/Color.h> 27 #include <tulip/Observable.h> 33 class GlLODCalculator;
34 class GlGraphComposite;
49 enum SelectedEntityType {
53 SIMPLE_ENTITY_SELECTED = 3
56 SelectedEntity():simpleEntity(NULL),complexEntityId((
unsigned int)(-1)),entityType(UNKNOW_SELECTED),complexEntityGraph(NULL) {}
57 SelectedEntity(
GlSimpleEntity *entity):simpleEntity(entity),complexEntityId((
unsigned int)(-1)),entityType(SIMPLE_ENTITY_SELECTED),complexEntityGraph(NULL) {}
58 SelectedEntity(
Graph *graph,
unsigned int id,SelectedEntityType type):simpleEntity(NULL),complexEntityId(
id),entityType(type),complexEntityGraph(graph) {}
61 assert(simpleEntity!=NULL);
65 unsigned int getComplexEntityId()
const {
66 assert(complexEntityId!=(
unsigned int)(-1));
67 return complexEntityId;
70 Graph *getComplexEntityGraph()
const {
71 assert(complexEntityGraph!=NULL);
72 return complexEntityGraph;
75 SelectedEntityType getEntityType()
const {
88 if(entityType == NODE_SELECTED) {
89 return node(complexEntityId);
106 if(entityType == EDGE_SELECTED) {
107 return edge(complexEntityId);
117 unsigned int complexEntityId;
118 SelectedEntityType entityType;
119 Graph *complexEntityGraph;
161 GlScene(GlLODCalculator *calculator=NULL);
169 void initGlParameters();
194 void computeAjustSceneToSize(
int width,
int height, Coord *center, Coord *eye,
float *sceneRadius,
float *xWhiteFactor,
float *yWhiteFactor,
BoundingBox *sceneBoundingBox=NULL,
float *zoomFactor=NULL);
201 void ajustSceneToSize(
int width,
int height);
207 void zoomXY(
int step,
const int x,
const int y);
213 void zoom(
float factor,
const Coord& dest);
225 void zoomFactor(
float factor);
230 void translateCamera(
const int x,
const int y,
const int z);
238 void rotateScene(
const int x,
const int y,
const int z);
250 bool selectEntities(RenderingEntitiesFlag type,
int x,
int y,
int h,
int w,
GlLayer *layer,std::vector<SelectedEntity>& selectedEntities);
255 void outputSVG(
unsigned int size,
const std::string& filename);
260 void outputEPS(
unsigned int size,
const std::string& filename);
265 unsigned char * getImage();
272 viewport=newViewport;
298 backgroundColor=color;
305 return backgroundColor;
312 this->viewOrtho=viewOrtho;
328 GlLayer *createLayer(
const std::string &name);
337 GlLayer *createLayerBefore(
const std::string &layerName,
const std::string &beforeLayerWithName);
346 GlLayer *createLayerAfter(
const std::string &layerName,
const std::string &afterLayerWithName);
353 void addExistingLayer(
GlLayer *layer);
361 bool addExistingLayerBefore(
GlLayer *layer,
const std::string &beforeLayerWithName);
369 bool addExistingLayerAfter(
GlLayer *layer,
const std::string &afterLayerWithName);
375 GlLayer *getLayer(
const std::string& name);
383 void removeLayer(
const std::string& name,
bool deleteLayer=
true);
391 void removeLayer(
GlLayer *layer,
bool deleteLayer=
true);
405 for(std::vector<std::pair<std::string,GlLayer*> >::iterator it=layersList.begin(); it!=layersList.end(); ++it)
414 void getXML(std::string &out);
419 void getXMLOnlyForCameras(std::string &out);
424 void setWithXML(std::string &in,
Graph *graph);
430 return lodCalculator;
437 lodCalculator=calculator;
438 calculator->setScene(*
this);
451 return glGraphComposite;
466 assert(graphLayer!=NULL);
467 return graphLayer->getCamera();
475 assert(graphLayer!=NULL);
476 graphLayer->setCamera(camera);
483 clearBufferAtDraw = clear;
490 return clearBufferAtDraw;
497 clearDepthBufferAtDraw = clear;
504 return clearDepthBufferAtDraw;
511 clearStencilBufferAtDraw = clear;
518 return clearStencilBufferAtDraw;
523 std::vector<std::pair<std::string,GlLayer *> > layersList;
524 GlLODCalculator *lodCalculator;
525 Vector<int, 4> viewport;
526 Color backgroundColor;
532 bool clearBufferAtDraw;
536 bool clearDepthBufferAtDraw;
538 bool clearStencilBufferAtDraw;
562 void notifyModifyLayer(
const std::string &name,
GlLayer *layer);
577 #endif // Tulip_GLSCENE_H bool getClearBufferAtDraw() const
If false, color buffer will not be cleared before drawing the scene.
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 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.
bool getClearStencilBufferAtDraw() const
If false, color buffer will not be cleared before drawing the scene.
GlGraphComposite * getGlGraphComposite()
Return the current GlGraphComposite used by the scene.
node getNode() const
getNode is a convenience method to perform the check on the selected element type and return the corr...
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...
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...
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.
Color getBackgroundColor() const
Get the background color of the scene.
edge getEdge() const
getEdge is a convenience method to perform the check on the selected element type and return the corr...
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.
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.
Structure to store selected entities.
void setClearBufferAtDraw(bool clear)
Set if OpenGL buffer will be cleared at draw.
const std::vector< std::pair< std::string, GlLayer * > > & getLayersList()
Return the layer list.
A GlLayer is like an 2D drawing software layer system.
bool getClearDepthBufferAtDraw() const
If false, depth buffer will not be cleared before drawing the scene.
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...