20 #ifndef Tulip_GLMAINWIDGET_H 21 #define Tulip_GLMAINWIDGET_H 24 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 28 #include <tulip/tulipconf.h> 29 #include <tulip/GlScene.h> 30 #include <tulip/Graph.h> 32 class QGLFramebufferObject;
37 class GlCompositeHierarchyManager;
116 void pickNodesEdges(
const int x,
const int y,
const int width,
const int height,
117 std::vector<SelectedEntity> &selectedNodes,
118 std::vector<SelectedEntity> &selectedEdges,
tlp::GlLayer *layer =
nullptr,
119 bool pickNodes =
true,
bool pickEdges =
true);
129 bool pickNodesEdges(
const int x,
const int y,
SelectedEntity &selectedEntity,
130 tlp::GlLayer *layer =
nullptr,
bool pickNodes =
true,
bool pickEdges =
true);
135 _DEPRECATED
void doSelect(
const int x,
const int y,
const int width,
const int height,
136 std::vector<tlp::node> &sNode, std::vector<tlp::edge> &sEdge,
151 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 152 return l * windowHandle()->devicePixelRatio();
164 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 165 return l * windowHandle()->devicePixelRatio();
177 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 178 qreal dpr = windowHandle()->devicePixelRatio();
179 return Coord(point.x() * dpr, point.y() * dpr);
191 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 192 return l / windowHandle()->devicePixelRatio();
204 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 205 qreal dpr = windowHandle()->devicePixelRatio();
206 return Coord(point.x() / dpr, point.y() / dpr);
215 bool outputEPS(
int size,
int doSort,
const char *filename);
219 bool outputSVG(
int size,
const char *filename);
226 static void getTextureRealSize(
int width,
int height,
int &textureRealWidth,
227 int &textureRealHeight);
236 QGLFramebufferObject *createTexture(
const std::string &textureName,
int width,
int height);
243 void createPicture(
const std::string &pictureName,
int width,
int height,
bool center =
true);
251 QImage createPicture(
int width,
int height,
bool center =
true);
263 bool pickGlEntities(
const int x,
const int y,
const int width,
const int height,
264 std::vector<SelectedEntity> &pickedEntities,
tlp::GlLayer *layer =
nullptr);
273 bool pickGlEntities(
const int x,
const int y, std::vector<SelectedEntity> &pickedEntities,
279 _DEPRECATED
bool selectGlEntities(
const int x,
const int y,
const int width,
const int height,
280 std::vector<GlSimpleEntity *> &pickedEntities,
282 std::vector<SelectedEntity> entities;
283 pickGlEntities(x, y, width, height, entities, layer);
284 bool foundEntity =
false;
286 for (std::vector<SelectedEntity>::iterator it = entities.begin(); it != entities.end(); ++it) {
287 if ((*it).getEntityType() == SelectedEntity::SIMPLE_ENTITY_SELECTED) {
288 pickedEntities.push_back((*it).getSimpleEntity());
300 std::vector<GlSimpleEntity *> &pickedEntities,
302 std::vector<SelectedEntity> entities;
303 pickGlEntities(x, y, entities, layer);
304 bool foundEntity =
false;
306 for (std::vector<SelectedEntity>::iterator it = entities.begin(); it != entities.end(); ++it) {
307 if ((*it).getEntityType() == SelectedEntity::SIMPLE_ENTITY_SELECTED) {
308 pickedEntities.push_back((*it).getSimpleEntity());
320 virtual QImage grabFrameBuffer(
bool withAlpha =
false);
326 virtual void makeCurrent();
331 void resizeGL(
int w,
int h)
override;
336 void computeInteractors();
341 void drawInteractors();
353 void render(RenderingOptions options = RenderingOptions(RenderScene | SwapBuffers),
354 bool checkVisibility =
true);
360 void setKeepScenePointOfViewOnSubgraphChanging(
bool);
365 bool keepScenePointOfViewOnSubgraphChanging()
const;
377 this->advancedAntiAliasing = advancedAntiAliasing;
384 return advancedAntiAliasing;
388 void setupOpenGlContext();
389 void createRenderingStore(
int width,
int height);
390 void deleteRenderingStore();
393 QRegion _visibleArea;
397 unsigned char *renderingStore;
398 bool frameBufferStored;
399 bool useFramebufferObject;
400 QGLFramebufferObject *glFrameBuf, *glFrameBuf2;
401 static bool inRendering;
402 bool keepPointOfViewOnSubgraphChanging;
403 bool advancedAntiAliasing;
409 void draw(
bool graphChanged =
true);
419 void closeEvent(QCloseEvent *e)
override;
431 void centerScene(
bool graphChanged =
false,
float zoomFactor = 1.0);
433 void emitGraphChanged();
436 void paintEvent(QPaintEvent *)
override;
451 void viewDrawn(
GlMainWidget *glWidget,
bool graphChanged);
453 void glResized(
int w,
int h);
462 static QGLWidget *getFirstQGLWidget();
464 static void clearFirstQGLWidget();
467 static QGLWidget *firstQGLWidget;
tlp::GlScene * getScene()
Get the GlScene of this GlMainWidget You have to add yours GlLayer and GlEntity to this GlScene At th...
double viewportToScreen(double l)
convert a viewport measure into a screen measure
bool selectGlEntities(const int x, const int y, const int width, const int height, std::vector< GlSimpleEntity *> &pickedEntities, tlp::GlLayer *layer=nullptr)
void setAdvancedAntiAliasing(bool advancedAntiAliasing)
Specify if an advanced technique for better scene anti-aliasing has to be activated.
The edge struct represents an edge in a Graph object.
The node struct represents a node in a Graph object.
bool advancedAntiAliasingActivated() const
double screenToViewport(double l)
convert a screen measure into a viewport measure
bool selectGlEntities(const int x, const int y, std::vector< GlSimpleEntity *> &pickedEntities, tlp::GlLayer *layer=nullptr)
View plugins provide a way to dynamically add to a Tulip plateform various ways to visualize a graph...
int screenToViewport(int l)
convert a screen measure into a viewport measure
Structure to store selected entities.
RenderingOption
Configure the rendering process ( see render function)
A GlLayer is like an 2D drawing software layer system.
Coord viewportToScreen(const Coord &point)
convert a viewport point into a screen point
Coord screenToViewport(const Coord &point)
convert a screen point into a viewport point
This widget provide a simple system to visualize data/graph with OpenGL 3D engine.