Tulip
4.6.0
Better Visualization Through Research
|
#include <GlScene.h>
Public Member Functions | |
GlScene (GlLODCalculator *calculator=NULL) | |
void | addExistingLayer (GlLayer *layer) |
bool | addExistingLayerAfter (GlLayer *layer, const std::string &afterLayerWithName) |
bool | addExistingLayerBefore (GlLayer *layer, const std::string &beforeLayerWithName) |
void | ajustSceneToSize (int width, int height) |
void | centerScene () |
void | clearLayersList () |
void | computeAjustSceneToSize (int width, int height, Coord *center, Coord *eye, float *sceneRadius, float *xWhiteFactor, float *yWhiteFactor, BoundingBox *sceneBoundingBox=NULL, float *zoomFactor=NULL) |
GlLayer * | createLayer (const std::string &name) |
GlLayer * | createLayerAfter (const std::string &layerName, const std::string &afterLayerWithName) |
GlLayer * | createLayerBefore (const std::string &layerName, const std::string &beforeLayerWithName) |
void | draw () |
Color | getBackgroundColor () const |
BoundingBox | getBoundingBox () |
GlLODCalculator * | getCalculator () |
bool | getClearBufferAtDraw () const |
GlGraphComposite * | getGlGraphComposite () |
Camera & | getGraphCamera () |
GlLayer * | getGraphLayer () |
unsigned char * | getImage () |
GlLayer * | getLayer (const std::string &name) |
const std::vector< std::pair < std::string, GlLayer * > > & | getLayersList () |
Vector< int, 4 > | getViewport () const |
void | getXML (std::string &out) |
void | getXMLOnlyForCameras (std::string &out) |
void | initGlParameters () |
bool | isViewOrtho () |
void | outputEPS (unsigned int size, const std::string &filename) |
void | outputSVG (unsigned int size, const std::string &filename) |
void | removeLayer (const std::string &name, bool deleteLayer=true) |
void | removeLayer (GlLayer *layer, bool deleteLayer=true) |
void | rotateScene (const int x, const int y, const int z) |
bool | selectEntities (RenderingEntitiesFlag type, int x, int y, int h, int w, GlLayer *layer, std::vector< SelectedEntity > &selectedEntities) |
void | setBackgroundColor (const Color &color) |
void | setCalculator (GlLODCalculator *calculator) |
void | setClearBufferAtDraw (bool clear) |
void | setGraphCamera (Camera *camera) |
void | setViewOrtho (bool viewOrtho) |
void | setViewport (Vector< int, 4 > &newViewport) |
void | setViewport (int x, int y, int width, int height) |
void | setWithXML (std::string &in, Graph *graph) |
void | translateCamera (const int x, const int y, const int z) |
void | zoom (float factor, const Coord &dest) |
void | zoom (int step) |
void | zoomFactor (float factor) |
void | zoomXY (int step, const int x, const int y) |
Tulip scene class.
The GlScene class is the core of the tulip rendering system This class is used to render entities and graph in OpenGL
If you want to render entities and graph, you have to use GlLayer system. You just have to create GlLayer and add GlEntity in. If you create more than one GlLayer, layers are rendered one after one, so the first GlLayer added is rendered in first.
After adding layers you can do a centerScene() and a draw()
GlLayer *mainLayer=new GlLayer("Main"); GlGraphComposite *graphComposite=new GlGraphComposite(graph); mainLayer->addGlEntity(graphComposite,"graph"); GlLayer *otherLayer=new GlLayer("Other"); GlCircle *circle=new GlCircle(); otherLayer->addGlEntity(circle,"circle"); glScene.addLayer(mainLayer); glScene.addLayer(otherLayer); glScene.centerScene(); glScene.draw();
If you want to create a widget with a visualisation is better to use GlMainWidget class (this class use a GlScene inside)
tlp::GlScene::GlScene | ( | GlLODCalculator * | calculator = NULL | ) |
Constructor Default scene is empty.
calculator | By default GlScene use a GlCPULODCalculator to compute LOD but you can change this default lod calculator, to do that : put your calculator in constructor parameters Available calculators are : GlCPULODCalculator and GlQuadTreeLODCalculator |
void tlp::GlScene::addExistingLayer | ( | GlLayer * | layer | ) |
bool tlp::GlScene::addExistingLayerAfter | ( | GlLayer * | layer, |
const std::string & | afterLayerWithName | ||
) |
bool tlp::GlScene::addExistingLayerBefore | ( | GlLayer * | layer, |
const std::string & | beforeLayerWithName | ||
) |
void tlp::GlScene::ajustSceneToSize | ( | int | width, |
int | height | ||
) |
Ajust camera to have entities near borders
width | requested width |
height | requested height |
void tlp::GlScene::centerScene | ( | ) |
Center scene After this function all entities are visible on the screen
void tlp::GlScene::clearLayersList | ( | ) | [inline] |
void tlp::GlScene::computeAjustSceneToSize | ( | int | width, |
int | height, | ||
Coord * | center, | ||
Coord * | eye, | ||
float * | sceneRadius, | ||
float * | xWhiteFactor, | ||
float * | yWhiteFactor, | ||
BoundingBox * | sceneBoundingBox = NULL , |
||
float * | zoomFactor = NULL |
||
) |
Compute information for ajustSceneToSize
width | : request width |
height | : request height |
center | : the result center will be stored in (if center != NULL) |
eye | : the result eye will be stored in (if eye != NULL) |
sceneRadius | : the result sceneRadius will be stored in (if sceneRadius != NULL) |
xWhiteFactor | : xWhiteFactor is the white part on x borders (left and right), the result xWhiteFactor will be stored in (if xWhiteFactor != NULL) |
yWhiteFactor | : yWhiteFactor is the white part on y borders (top and bottom), the result yWhiteFactor will be stored in (if yWhiteFactor != NULL) |
sceneBoundingBox | : the result sceneBoundingBox will be stored in (if sceneBoundingBox != NULL) |
GlLayer* tlp::GlScene::createLayer | ( | const std::string & | name | ) |
Create a layer with the given name in the scene This layer is added to the layers list Now the scene have the ownership of this GlLayer so you don't have to delete this GlLayer.
GlLayer* tlp::GlScene::createLayerAfter | ( | const std::string & | layerName, |
const std::string & | afterLayerWithName | ||
) |
GlLayer* tlp::GlScene::createLayerBefore | ( | const std::string & | layerName, |
const std::string & | beforeLayerWithName | ||
) |
void tlp::GlScene::draw | ( | ) |
Draw the scene This function is the most important function of GlScene. If you want to render a scene into an OpenGL widget : call this function.
Color tlp::GlScene::getBackgroundColor | ( | ) | const [inline] |
Return the bouding box of the scene (in 3D coordinates)
GlLODCalculator* tlp::GlScene::getCalculator | ( | ) | [inline] |
bool tlp::GlScene::getClearBufferAtDraw | ( | ) | const [inline] |
GlGraphComposite* tlp::GlScene::getGlGraphComposite | ( | ) | [inline] |
Return the current GlGraphComposite used by the scene.
Camera& tlp::GlScene::getGraphCamera | ( | ) | [inline] |
GlLayer* tlp::GlScene::getGraphLayer | ( | ) | [inline] |
Return the layer containing the current GlGraphComposite.
unsigned char* tlp::GlScene::getImage | ( | ) |
Return the RGB image of GlScene.
GlLayer* tlp::GlScene::getLayer | ( | const std::string & | name | ) |
Return the layer with name : name Return NULL if the layer doesn't exist in the scene.
const std::vector<std::pair<std::string, GlLayer*> >& tlp::GlScene::getLayersList | ( | ) | [inline] |
Vector<int, 4> tlp::GlScene::getViewport | ( | ) | const [inline] |
void tlp::GlScene::getXML | ( | std::string & | out | ) |
Get XML description of the scene and children and store it in out string.
void tlp::GlScene::getXMLOnlyForCameras | ( | std::string & | out | ) |
Get XML description of cameras of the scene and store it in out string.
void tlp::GlScene::initGlParameters | ( | ) |
Init scene's OpenGL parameters. You don't have to call this function, it is call when you do a draw.
bool tlp::GlScene::isViewOrtho | ( | ) | [inline] |
void tlp::GlScene::outputEPS | ( | unsigned int | size, |
const std::string & | filename | ||
) |
Output the scene in EPS.
void tlp::GlScene::outputSVG | ( | unsigned int | size, |
const std::string & | filename | ||
) |
Output the scene in SVG.
void tlp::GlScene::removeLayer | ( | const std::string & | name, |
bool | deleteLayer = true |
||
) |
void tlp::GlScene::removeLayer | ( | GlLayer * | layer, |
bool | deleteLayer = true |
||
) |
void tlp::GlScene::rotateScene | ( | const int | x, |
const int | y, | ||
const int | z | ||
) |
Rotate camera by (x,y,z)
x | rotation over X axis in degree |
y | rotation over Y axis in degree |
z | rotation over Z axis in degree |
bool tlp::GlScene::selectEntities | ( | RenderingEntitiesFlag | type, |
int | x, | ||
int | y, | ||
int | h, | ||
int | w, | ||
GlLayer * | layer, | ||
std::vector< SelectedEntity > & | selectedEntities | ||
) |
Select entities in scene.
type | Entities type to select (SelectSimpleEntities,SelectNodes,SelectEdges) |
x | screen coordinates |
y | screen coordinates |
h | height in screen coordinates |
w | width in screen coordinates |
layer | where the selection will be performed |
selectedEntities | the result of the selection is stored on it |
void tlp::GlScene::setBackgroundColor | ( | const Color & | color | ) | [inline] |
void tlp::GlScene::setCalculator | ( | GlLODCalculator * | calculator | ) | [inline] |
void tlp::GlScene::setClearBufferAtDraw | ( | bool | clear | ) | [inline] |
void tlp::GlScene::setGraphCamera | ( | Camera * | camera | ) | [inline] |
void tlp::GlScene::setViewOrtho | ( | bool | viewOrtho | ) | [inline] |
void tlp::GlScene::setViewport | ( | Vector< int, 4 > & | newViewport | ) | [inline] |
void tlp::GlScene::setViewport | ( | int | x, |
int | y, | ||
int | width, | ||
int | height | ||
) | [inline] |
void tlp::GlScene::setWithXML | ( | std::string & | in, |
Graph * | graph | ||
) |
Set scene's data and children with a XML.
void tlp::GlScene::translateCamera | ( | const int | x, |
const int | y, | ||
const int | z | ||
) |
Translate camera by (x,y,z)
void tlp::GlScene::zoom | ( | float | factor, |
const Coord & | dest | ||
) |
Zoom to given world coordinate.
void tlp::GlScene::zoom | ( | int | step | ) |
Zoom by step.
step | of zoom |
void tlp::GlScene::zoomFactor | ( | float | factor | ) |
Zoom by factor.
factor | of zoom |
void tlp::GlScene::zoomXY | ( | int | step, |
const int | x, | ||
const int | y | ||
) |
Zoom by step to given x,y screen coordinates.
step | of zoom |