Tulip
5.7.4
Large graphs analysis and drawing
|
#include <GlMainWidget.h>
Inherits QOpenGLWidget.
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) | |
void | computeInteractors () |
void | createPicture (const std::string &pictureName, int width, int height, bool center=true) |
QImage | createPicture (int width, int height, bool center=true, QImage::Format format=QImage::Format_RGB32) |
qreal | devicePixelRatio () const |
void | doneCurrent () |
void | drawInteractors () |
tlp::GlScene * | getScene () |
bool | isCurrent () |
bool | keepScenePointOfViewOnSubgraphChanging () const |
void | makeCurrent () |
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 |
Coord | screenToViewport (const Coord &point) const |
double | screenToViewport (double l) const |
int | screenToViewport (int l) const |
void | setKeepScenePointOfViewOnSubgraphChanging (bool) |
Coord | viewportToScreen (const Coord &point) const |
double | viewportToScreen (double l) const |
Static Public Member Functions | |
static void | getTextureRealSize (int width, int height, int &textureRealWidth, int &textureRealHeight) |
Protected Slots | |
void | paintEvent (QPaintEvent *) override |
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
To use this class you have to :
If you only want to visualize a graph, you can call the setGraph function
After scene construction you can perform some operation on GlMainWidget :
Definition at line 63 of file GlMainWidget.h.
Configure the rendering process ( see render function)
Definition at line 71 of file GlMainWidget.h.
tlp::GlMainWidget::GlMainWidget | ( | QWidget * | parent = nullptr , |
View * | view = nullptr |
||
) |
Constructor of GlMainWidget.
Create a GlMainWidget with the GlScene associated to it
parent | Qt Widget parent system |
view | if you want to link this GlMainWidget to a view : use this parameter |
|
slot |
Convenience function that calls center function on the current scene, applies a zoom (if needed) and draws the view. Same thing than.
|
signal |
This signal is emitted when the GlMainWidget will be deleted
void tlp::GlMainWidget::computeInteractors | ( | ) |
Compute interactors before drawing
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.
width | size |
height | size |
center | if true this function calls a centerScene() before picture output |
QImage tlp::GlMainWidget::createPicture | ( | int | width, |
int | height, | ||
bool | center = true , |
||
QImage::Format | format = QImage::Format_RGB32 |
||
) |
Take a snapshot of the Widget and return it
width | size |
height | size |
center | if true this function calls a centerScene() before picture output |
format | indicates the format of the created image |
|
slot |
Draw the GlScene and the interactors
void tlp::GlMainWidget::drawInteractors | ( | ) |
Draw interactors
|
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.
Definition at line 99 of file GlMainWidget.h.
|
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.
bool tlp::GlMainWidget::isCurrent | ( | ) |
Indicates if this is associated to the current OpenGL context
bool tlp::GlMainWidget::keepScenePointOfViewOnSubgraphChanging | ( | ) | const |
Returns if the scene point of view must be kept when changing between graphs belonging to the same hierarchy.
void tlp::GlMainWidget::makeCurrent | ( | ) |
Override default makeCurrent/doneCurrent behavior to activate deactivate adequate OpenGL context based on the QOpenGLWidget visibility
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.
x | screen coordinates |
y | screen coordinates |
width | screen size |
height | screen size |
pickedEntities | filled with entity under the selection screen rectangle |
layer | if you want to do the selection only on one GlLayer |
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.
x | screen coordinates |
y | screen coordinates |
pickedEntities | filled with entity under the selection screen rectangle |
layer | if you want to do the selection only on one GlLayer |
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)
selectedNodes | filled by the method with the nodes found in the region |
selectedEdges | filled by the method with the edges found in the region |
layer | specify the layer in which to perform the picking |
pickNodes | enable or disable the picking of nodes |
pickEdges | enable or disable the picking of edges |
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.
type | tells what has been found: NODE, EDGE |
layer | specify the layer in which to perform the picking |
pickNodes | enable or disable the picking of nodes |
pickEdges | enable or disable the picking of edges |
|
slot |
This function is given for optimisation purpose only. If the hardware allows it, it enables to redraw only the Augmented display and the interactors and not the graph it is really useful for interactors such as zoom box etc.. Warning, if you change the graph or the properties of element (Colors, size, etc...) applying that function will not display the change, in that case, use the draw function.
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.
options | Configure the rendering process, see the RenderingOption documentation for more information on each rendering option effect. |
checkVisibility | If check visibility is true : the engine check if GlMainWidget QWidget is visible. If false: the engine renders the scene in all cases |
|
override |
Resize openGL view
|
inline |
convert a screen point into a viewport point
a | point in screen coordinates |
Definition at line 158 of file GlMainWidget.h.
|
inline |
convert a screen measure into a viewport measure
a | measure in screen coordinates specified as a double |
Definition at line 149 of file GlMainWidget.h.
|
inline |
convert a screen measure into a viewport measure
a | measure in screen coordinates specified as an integer |
Definition at line 140 of file GlMainWidget.h.
void tlp::GlMainWidget::setKeepScenePointOfViewOnSubgraphChanging | ( | bool | ) |
Specify if the scene point of view must be kept when changing between graphs belonging to the same hierarchy.
|
signal |
This signal is emitted when GlMainWidget::draw() is call
|
inline |
convert a viewport point into a screen point
a | point in viewport coordinates |
Definition at line 177 of file GlMainWidget.h.
|
inline |
convert a viewport measure into a screen measure
a | measure in viewport coordinates specified as a double |
Definition at line 168 of file GlMainWidget.h.
|
signal |
This signal is emitted when GlMainWidget::redraw() is call