Tulip  5.2.0
Large graphs analysis and drawing
GlMainWidgetGraphicsItem.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef GLMAINWIDGETGRAPHICSITEM_H
22 #define GLMAINWIDGETGRAPHICSITEM_H
23 
24 #include <QGraphicsObject>
25 
26 #include <tulip/tulipconf.h>
27 
28 namespace tlp {
29 class GlMainWidget;
30 
31 class TLP_QT_SCOPE GlMainWidgetGraphicsItem : public QGraphicsObject {
32  Q_OBJECT
33 public:
34  GlMainWidgetGraphicsItem(tlp::GlMainWidget *glMainWidget, int width, int height);
35  ~GlMainWidgetGraphicsItem() override;
36 
37  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
38 
39  QRectF boundingRect() const override;
40 
41  void resize(int width, int height);
42 
43  void setRedrawNeeded(bool redrawNeeded) {
44  this->_redrawNeeded = redrawNeeded;
45  }
46 
47  tlp::GlMainWidget *getGlMainWidget() {
48  return glMainWidget;
49  }
50 
51  void setGlMainWidget(tlp::GlMainWidget *);
52 
53  bool eventFilter(QObject *, QEvent *evt) override;
54 
55 signals:
56 
57  void widgetPainted(bool redraw);
58 
59 protected:
60  void keyPressEvent(QKeyEvent *event) override;
61  void keyReleaseEvent(QKeyEvent *event) override;
62  void wheelEvent(QGraphicsSceneWheelEvent *event) override;
63  void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
64  void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
65  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
66  void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
67  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
68  void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
69  void dragEnterEvent(QGraphicsSceneDragDropEvent *event) override;
70  void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) override;
71  void dragMoveEvent(QGraphicsSceneDragDropEvent *event) override;
72  void dropEvent(QGraphicsSceneDragDropEvent *event) override;
73 
74 protected slots:
75  void glMainWidgetDraw(GlMainWidget *, bool);
76  void glMainWidgetRedraw(GlMainWidget *);
77 
78 private:
79  tlp::GlMainWidget *glMainWidget;
80  bool _redrawNeeded;
81  bool _graphChanged;
82  int width, height;
83 };
84 }
85 
86 #endif // GLMAINWIDGETGRAPHICSITEM_H
87 ///@endcond
This widget provide a simple system to visualize data/graph with OpenGL 3D engine.
Definition: GlMainWidget.h:66