Tulip  5.3.0
Large graphs analysis and drawing
tlp::GlMainWidget Class Reference

#include <GlMainWidget.h>

Inherits QGLWidget.

Public Types

enum  RenderingOption { RenderScene = 0x1, SwapBuffers = 0x2 }
 

Public Slots

void centerScene (bool graphChanged=false, float zoomFactor=1.0)
 
void closeEvent (QCloseEvent *e) override
 
void draw (bool graphChanged=true)
 
void emitGraphChanged ()
 
void redraw ()
 

Signals

void closing (GlMainWidget *, QCloseEvent *)
 
void glResized (int w, int h)
 
void graphChanged ()
 
void viewDrawn (GlMainWidget *glWidget, bool graphChanged)
 
void viewRedrawn (GlMainWidget *glWidget)
 

Public Member Functions

 GlMainWidget (QWidget *parent=nullptr, View *view=nullptr)
 
bool advancedAntiAliasingActivated () const
 
void computeInteractors ()
 
void createPicture (const std::string &pictureName, int width, int height, bool center=true)
 
QImage createPicture (int width, int height, bool center=true)
 
QOpenGLFramebufferObject * createTexture (const std::string &textureName, int width, int height)
 
void doSelect (const int x, const int y, const int width, const int height, std::vector< tlp::node > &sNode, std::vector< tlp::edge > &sEdge, tlp::GlLayer *layer=nullptr)
 
bool doSelect (const int x, const int y, tlp::ElementType &type, tlp::node &n, tlp::edge &e, tlp::GlLayer *layer=nullptr)
 
void drawInteractors ()
 
tlp::GlScenegetScene ()
 
bool keepScenePointOfViewOnSubgraphChanging () const
 
virtual void makeCurrent ()
 
bool outputEPS (int size, int doSort, const char *filename)
 
bool outputSVG (int size, const char *filename)
 
bool pickGlEntities (const int x, const int y, const int width, const int height, std::vector< SelectedEntity > &pickedEntities, tlp::GlLayer *layer=nullptr)
 
bool pickGlEntities (const int x, const int y, std::vector< SelectedEntity > &pickedEntities, tlp::GlLayer *layer=nullptr)
 
void pickNodesEdges (const int x, const int y, const int width, const int height, std::vector< SelectedEntity > &selectedNodes, std::vector< SelectedEntity > &selectedEdges, tlp::GlLayer *layer=nullptr, bool pickNodes=true, bool pickEdges=true)
 
bool pickNodesEdges (const int x, const int y, SelectedEntity &selectedEntity, tlp::GlLayer *layer=nullptr, bool pickNodes=true, bool pickEdges=true)
 
void render (RenderingOptions options=RenderingOptions(RenderScene|SwapBuffers), bool checkVisibility=true)
 
void resizeGL (int w, int h) override
 
int screenToViewport (int l)
 
double screenToViewport (double l)
 
Coord screenToViewport (const Coord &point)
 
bool selectGlEntities (const int x, const int y, const int width, const int height, std::vector< GlSimpleEntity *> &pickedEntities, tlp::GlLayer *layer=nullptr)
 
bool selectGlEntities (const int x, const int y, std::vector< GlSimpleEntity *> &pickedEntities, tlp::GlLayer *layer=nullptr)
 
void setAdvancedAntiAliasing (bool advancedAntiAliasing)
 
void setKeepScenePointOfViewOnSubgraphChanging (bool)
 
double viewportToScreen (double l)
 
Coord viewportToScreen (const Coord &point)
 

Static Public Member Functions

static void clearFirstQGLWidget ()
 
static QGLWidget * getFirstQGLWidget ()
 
static void getTextureRealSize (int width, int height, int &textureRealWidth, int &textureRealHeight)
 

Protected Slots

void paintEvent (QPaintEvent *) override
 

Detailed Description

This widget provide a simple system to visualize data/graph with OpenGL 3D engine.

This widget is an interface between Qt Widget system and tulip OpenGL engine The central object of GlMainWidget is the GlScene member

See also
GlScene

To use this class you have to :

See also
GlLayer
GlSimpleEntity

If you only want to visualize a graph, you can call the setGraph function

After scene construction you can perform some operation on GlMainWidget :

Examples:
graph_display/graph_display.cpp.

Definition at line 64 of file GlMainWidget.h.

Member Enumeration Documentation

◆ RenderingOption

Configure the rendering process ( see render function)

See also
render
Enumerator
SwapBuffers 

Force to render the graph even if there is a previous buffered render. You need to call this option if the graph is updated to regenerate the buffer. If not set try to use the last buffered graph render, if there is no valid buffer this flag is forced.

Definition at line 72 of file GlMainWidget.h.

Constructor & Destructor Documentation

◆ GlMainWidget()

tlp::GlMainWidget::GlMainWidget ( QWidget *  parent = nullptr,
View view = nullptr 
)

Constructor of GlMainWidget.

Create a GlMainWidget with the GlScene associated to it

Parameters
parentQt Widget parent system
viewif you want to link this GlMainWidget to a view : use this parameter

Member Function Documentation

◆ advancedAntiAliasingActivated()

bool tlp::GlMainWidget::advancedAntiAliasingActivated ( ) const
inline

Returns the advanced anti-aliasing technique state

Definition at line 355 of file GlMainWidget.h.

◆ centerScene

void tlp::GlMainWidget::centerScene ( bool  graphChanged = false,
float  zoomFactor = 1.0 
)
slot

Convenience function that call center function on the current scene, apply a zoom (if needed) and draw the view. Same thing than.

Examples:
graph_display/graph_display.cpp.

◆ closing

void tlp::GlMainWidget::closing ( GlMainWidget ,
QCloseEvent *   
)
signal

This signal is emit when the GlMainWidget will be deleted

◆ computeInteractors()

void tlp::GlMainWidget::computeInteractors ( )

Compute interactors before drawing

◆ createPicture() [1/2]

void tlp::GlMainWidget::createPicture ( const std::string &  pictureName,
int  width,
int  height,
bool  center = true 
)

Take a snapshot of the Widget and put it in a picture.

Parameters
widthsize
heightsize
centerif true this function call a centerScene() before picture output

◆ createPicture() [2/2]

QImage tlp::GlMainWidget::createPicture ( int  width,
int  height,
bool  center = true 
)

Take a snapshot of the Widget and return it

Parameters
widthsize
heightsize
centerif true this function call a centerScene() before picture output

◆ createTexture()

QOpenGLFramebufferObject* tlp::GlMainWidget::createTexture ( const std::string &  textureName,
int  width,
int  height 
)

Take a snapshot of the Widget and put it in an OpenGl texture.

Parameters
widthpower of two number (for example 256)
heightpower of two number (for example 256) You can use this texture with Tulip texture system
See also
GlTextureManager

◆ doSelect() [1/2]

void tlp::GlMainWidget::doSelect ( const int  x,
const int  y,
const int  width,
const int  height,
std::vector< tlp::node > &  sNode,
std::vector< tlp::edge > &  sEdge,
tlp::GlLayer layer = nullptr 
)
Deprecated:
this function should not be used anymore, use pickNodesEdges()

◆ doSelect() [2/2]

bool tlp::GlMainWidget::doSelect ( const int  x,
const int  y,
tlp::ElementType type,
tlp::node n,
tlp::edge e,
tlp::GlLayer layer = nullptr 
)
Deprecated:
this function should not be used anymore, use pickNodesEdges()

◆ draw

void tlp::GlMainWidget::draw ( bool  graphChanged = true)
slot

Draw the GlScene and the interactors

Examples:
graph_display/graph_display.cpp.

◆ drawInteractors()

void tlp::GlMainWidget::drawInteractors ( )

Draw interactors

◆ getFirstQGLWidget()

static QGLWidget* tlp::GlMainWidget::getFirstQGLWidget ( )
static

This function return the first QGLWidget created This function is use to share OpenGL context

◆ getScene()

tlp::GlScene* tlp::GlMainWidget::getScene ( )
inline

Get the GlScene of this GlMainWidget You have to add yours GlLayer and GlEntity to this GlScene At the construction this GlScene is empty.

See also
GlScene
GlScene::createLayer(const std::string &name)
GlLayer::addGlEntity(GlSimpleEntity *entity,const std::string& name)
Examples:
graph_display/graph_display.cpp.

Definition at line 100 of file GlMainWidget.h.

◆ getTextureRealSize()

static void tlp::GlMainWidget::getTextureRealSize ( int  width,
int  height,
int &  textureRealWidth,
int &  textureRealHeight 
)
static

Compute texture size in power of two with given height and width For example if you set width to 94 and height to 256, this function set textureRealWidth to 128 and textureRealHeight to 256.

◆ keepScenePointOfViewOnSubgraphChanging()

bool tlp::GlMainWidget::keepScenePointOfViewOnSubgraphChanging ( ) const

Returns if the scene point of view must be kept when changing between graphs belonging to the same hierarchy.

◆ makeCurrent()

virtual void tlp::GlMainWidget::makeCurrent ( )
virtual

Extend makeCurrent function of QGLWidget to inform TextureManager and DisplayListManager of context changement

◆ outputEPS()

bool tlp::GlMainWidget::outputEPS ( int  size,
int  doSort,
const char *  filename 
)

EPS output of the GlMainWidget.

◆ outputSVG()

bool tlp::GlMainWidget::outputSVG ( int  size,
const char *  filename 
)

SVG output of the GlMainWidget.

◆ pickGlEntities() [1/2]

bool tlp::GlMainWidget::pickGlEntities ( const int  x,
const int  y,
const int  width,
const int  height,
std::vector< SelectedEntity > &  pickedEntities,
tlp::GlLayer layer = nullptr 
)

Function to do picking on entities in a screen region It just calls selectEntities on the GlScene instance.

Parameters
xscreen coordinates
yscreen coordinates
widthscreen size
heightscreen size
pickedEntitiesfilled with entity under the selection screen rectangle
layerif you want to do the selection only on one GlLayer

◆ pickGlEntities() [2/2]

bool tlp::GlMainWidget::pickGlEntities ( const int  x,
const int  y,
std::vector< SelectedEntity > &  pickedEntities,
tlp::GlLayer layer = nullptr 
)

Function to do picking on entities. It just calls selectEntities on the GlScene instance with a small window of twelve pixels.

Parameters
xscreen coordinates
yscreen coordinates
pickedEntitiesfilled with entity under the selection screen rectangle
layerif you want to do the selection only on one GlLayer

◆ pickNodesEdges() [1/2]

void tlp::GlMainWidget::pickNodesEdges ( const int  x,
const int  y,
const int  width,
const int  height,
std::vector< SelectedEntity > &  selectedNodes,
std::vector< SelectedEntity > &  selectedEdges,
tlp::GlLayer layer = nullptr,
bool  pickNodes = true,
bool  pickEdges = true 
)

Select nodes and edges in a region of the screen.

Select all nodes and edges lying in the area of the screen of given width and height, and with its upper-left corner at (x,y)

Parameters
selectedNodesfilled by the method with the nodes found in the region
selectedEdgesfilled by the method with the edges found in the region
layerspecify the layer in which to perform the picking
pickNodesenable or disable the picking of nodes
pickEdgesenable or disable the picking of edges
Examples:
interactor_plugin/interactor_plugin.cpp.

◆ pickNodesEdges() [2/2]

bool tlp::GlMainWidget::pickNodesEdges ( const int  x,
const int  y,
SelectedEntity selectedEntity,
tlp::GlLayer layer = nullptr,
bool  pickNodes = true,
bool  pickEdges = true 
)

Select a node or edge at a screen point Try to select at point (x,y) a node in the first place then if no result try to select an edge.

Parameters
typetells what has been found: NODE, EDGE
layerspecify the layer in which to perform the picking
pickNodesenable or disable the picking of nodes
pickEdgesenable or disable the picking of edges
Returns
true if something has been found, false otherwise

◆ redraw

void tlp::GlMainWidget::redraw ( )
slot

This function is given for optimisation purpose only. If the hardware enable it, it enables to redraw only the Augmented display and the interactors and not the graph it is really usefull for interactors such as zoom box etc.. Warning, if you change the graph or the porperties of element (Colors, size, etc...) applying that fonction will not display the change, in that case, use the draw function.

◆ render()

void tlp::GlMainWidget::render ( RenderingOptions  options = RenderingOptions(RenderScene|SwapBuffers),
bool  checkVisibility = true 
)

This function performs all the rendering process of the graph. Use this function only for advanced purpose, if you want to perform simple rendering use the draw or redraw functions instead.

Parameters
optionsConfigure the rendering process, see the RenderingOption documentation for more information on each rendering option effect.
See also
RenderingOption
Parameters
checkVisibilityIf check visibility is set as true : the engine check if GlMainWidget QWidget is visible. If set at false : the engine render the scene in all cases

◆ resizeGL()

void tlp::GlMainWidget::resizeGL ( int  w,
int  h 
)
override

Resize openGL view

◆ screenToViewport() [1/3]

int tlp::GlMainWidget::screenToViewport ( int  l)
inline

convert a screen measure into a viewport measure

Parameters
ameasure in screen coordinates specified as an integer
Returns
the converted measure in viewport coordinates as an integer

Definition at line 148 of file GlMainWidget.h.

◆ screenToViewport() [2/3]

double tlp::GlMainWidget::screenToViewport ( double  l)
inline

convert a screen measure into a viewport measure

Parameters
ameasure in screen coordinates specified as a double
Returns
the converted measure in viewport coordinates as a double

Definition at line 157 of file GlMainWidget.h.

◆ screenToViewport() [3/3]

Coord tlp::GlMainWidget::screenToViewport ( const Coord &  point)
inline

convert a screen point into a viewport point

Parameters
apoint in screen coordinates
Returns
the converted point in viewport coordinates

Definition at line 166 of file GlMainWidget.h.

◆ selectGlEntities() [1/2]

bool tlp::GlMainWidget::selectGlEntities ( const int  x,
const int  y,
const int  width,
const int  height,
std::vector< GlSimpleEntity *> &  pickedEntities,
tlp::GlLayer layer = nullptr 
)
inline
Deprecated:
this function should not be used anymore, please use pickGlEntities() instead.

Definition at line 257 of file GlMainWidget.h.

◆ selectGlEntities() [2/2]

bool tlp::GlMainWidget::selectGlEntities ( const int  x,
const int  y,
std::vector< GlSimpleEntity *> &  pickedEntities,
tlp::GlLayer layer = nullptr 
)
inline
Deprecated:
this function should not be used anymore, please use pickGlEntities() instead.

Definition at line 277 of file GlMainWidget.h.

◆ setAdvancedAntiAliasing()

void tlp::GlMainWidget::setAdvancedAntiAliasing ( bool  advancedAntiAliasing)
inline

Specify if an advanced technique for better scene anti-aliasing has to be activated.

That option allows to obtain a better scene antialiasing through the use of offscreen rendering and sampling. The result rendering will look better while the performance will be slightly altered. That option is desactivated by default. Use it with caution as it could cause crashes with some buggy OpenGL drivers.

Definition at line 348 of file GlMainWidget.h.

◆ setKeepScenePointOfViewOnSubgraphChanging()

void tlp::GlMainWidget::setKeepScenePointOfViewOnSubgraphChanging ( bool  )

Specify if the scene point of view must be kept when changing between graphs belonging to the same hierarchy.

◆ viewDrawn

void tlp::GlMainWidget::viewDrawn ( GlMainWidget glWidget,
bool  graphChanged 
)
signal

This signal is emit when GlMainWidget::draw() is call

◆ viewportToScreen() [1/2]

double tlp::GlMainWidget::viewportToScreen ( double  l)
inline

convert a viewport measure into a screen measure

Parameters
ameasure in viewport coordinates specified as a double
Returns
the converted measure in screen coordinates as a double

Definition at line 176 of file GlMainWidget.h.

◆ viewportToScreen() [2/2]

Coord tlp::GlMainWidget::viewportToScreen ( const Coord &  point)
inline

convert a viewport point into a screen point

Parameters
apoint in viewport coordinates
Returns
the converted point in screen coordinates

Definition at line 185 of file GlMainWidget.h.

◆ viewRedrawn

void tlp::GlMainWidget::viewRedrawn ( GlMainWidget glWidget)
signal

This signal is emit when GlMainWidget::redraw() is call