20 #ifndef Tulip_GLMAINWIDGET_H
21 #define Tulip_GLMAINWIDGET_H
23 #include <QOpenGLWidget>
25 #include <tulip/tulipconf.h>
26 #include <tulip/GlScene.h>
27 #include <tulip/Graph.h>
29 class QOpenGLFramebufferObject;
34 class GlCompositeHierarchyManager;
79 Q_DECLARE_FLAGS(RenderingOptions, RenderingOption)
114 std::vector<SelectedEntity> &selectedNodes,
115 std::vector<SelectedEntity> &selectedEdges,
tlp::GlLayer *layer =
nullptr,
116 bool pickNodes =
true,
bool pickEdges =
true);
127 tlp::GlLayer *layer =
nullptr,
bool pickNodes =
true,
bool pickEdges =
true);
131 qreal devicePixelRatio()
const {
132 return wdpr->devicePixelRatio();
141 return l * devicePixelRatio();
150 return l * devicePixelRatio();
159 qreal dpr = devicePixelRatio();
160 return Coord(point.x() * dpr, point.y() * dpr);
169 return l / devicePixelRatio();
178 qreal dpr = devicePixelRatio();
179 return Coord(point.x() / dpr, point.y() / dpr);
188 int &textureRealHeight);
196 void createPicture(
const std::string &pictureName,
int width,
int height,
bool center =
true);
206 QImage::Format format = QImage::Format_RGB32);
219 std::vector<SelectedEntity> &pickedEntities,
tlp::GlLayer *layer =
nullptr);
228 bool pickGlEntities(
const int x,
const int y, std::vector<SelectedEntity> &pickedEntities,
268 void render(RenderingOptions options = RenderingOptions(RenderScene | SwapBuffers),
269 bool checkVisibility =
true);
283 void createFramebuffers(
int width,
int height);
284 void deleteFramebuffers();
287 QRegion _visibleArea;
292 QOpenGLFramebufferObject *glFrameBuf, *glFrameBuf2;
293 static bool inRendering;
294 bool keepPointOfViewOnSubgraphChanging;
295 std::string sceneTextureId;
301 void draw(
bool graphChanged =
true);
311 void closeEvent(QCloseEvent *e)
override;
323 void centerScene(
bool graphChanged =
false,
float zoomFactor = 1.0);
325 void emitGraphChanged();
328 void paintEvent(QPaintEvent *)
override;
345 void glResized(
int w,
int h);
A GlLayer is like an 2D drawing software layer system.
This widget provide a simple system to visualize data/graph with OpenGL 3D engine.
QImage createPicture(int width, int height, bool center=true, QImage::Format format=QImage::Format_RGB32)
void 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 pu...
void computeInteractors()
void setKeepScenePointOfViewOnSubgraphChanging(bool)
Specify if the scene point of view must be kept when changing between graphs belonging to the same hi...
double screenToViewport(double l) const
convert a screen measure into a viewport measure
void draw(bool graphChanged=true)
Coord viewportToScreen(const Coord &point) const
convert a viewport point into a screen point
void viewDrawn(GlMainWidget *glWidget, bool graphChanged)
void createPicture(const std::string &pictureName, int width, int height, bool center=true)
Take a snapshot of the Widget and put it in a picture.
Coord screenToViewport(const Coord &point) const
convert a screen point into a viewport point
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)
Select nodes and edges in a region of the screen.
void resizeGL(int w, int h) override
static void getTextureRealSize(int width, int height, int &textureRealWidth, int &textureRealHeight)
Compute texture size in power of two with given height and width For example if you set width to 94 a...
bool keepScenePointOfViewOnSubgraphChanging() const
Returns if the scene point of view must be kept when changing between graphs belonging to the same hi...
int screenToViewport(int l) const
convert a screen measure into a viewport measure
void centerScene(bool graphChanged=false, float zoomFactor=1.0)
Convenience function that calls center function on the current scene, applies a zoom (if needed) and ...
RenderingOption
Configure the rendering process ( see render function)
void viewRedrawn(GlMainWidget *glWidget)
double viewportToScreen(double l) const
convert a viewport measure into a screen measure
bool 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 i...
void closing(GlMainWidget *, QCloseEvent *)
bool 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...
bool 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 ins...
View plugins provide a way to dynamically add to a Tulip plateform various ways to visualize a graph.
Structure to store selected entities.