Tulip  4.4.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlMainWidgetGraphicsItem.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
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 /**
25  Author: Antoine Lambert, Morgan Mathiaut and Ludwig Fiolka
26  This program is free software; you can redistribute it and/or modify
27  it under the terms of the GNU General Public License as published by
28  the Free Software Foundation; either version 2 of the License, or
29  (at your option) any later version.
30  */
31 
32 #include <QGraphicsObject>
33 
34 
35 #include <tulip/tulipconf.h>
36 
37 namespace tlp {
38 class GlMainWidget;
39 
40 class TLP_QT_SCOPE GlMainWidgetGraphicsItem : public QGraphicsObject {
41  Q_OBJECT
42 public:
43  GlMainWidgetGraphicsItem(tlp::GlMainWidget *glMainWidget, int width, int height);
44  virtual ~GlMainWidgetGraphicsItem();
45 
46  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
47 
48  QRectF boundingRect() const;
49 
50  void resize(int width, int height);
51 
52  void setRedrawNeeded(bool redrawNeeded) {
53  this->_redrawNeeded=redrawNeeded;
54  }
55 
56  tlp::GlMainWidget *getGlMainWidget() {
57  return glMainWidget;
58  }
59 
60  bool eventFilter(QObject *, QEvent *evt);
61 
62 signals:
63 
64  void widgetPainted(bool redraw);
65 
66 protected :
67  void keyPressEvent(QKeyEvent *event);
68  void keyReleaseEvent(QKeyEvent *event);
69  void wheelEvent(QGraphicsSceneWheelEvent *event);
70  void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
71  void mousePressEvent(QGraphicsSceneMouseEvent *event);
72  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
73  void hoverMoveEvent(QGraphicsSceneHoverEvent * event);
74  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
75  void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
76  void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
77  void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
78  void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
79  void dropEvent(QGraphicsSceneDragDropEvent *event);
80 
81 protected slots:
82  void glMainWidgetDraw(GlMainWidget *,bool);
83  void glMainWidgetRedraw(GlMainWidget *);
84 
85 private :
86  tlp::GlMainWidget *glMainWidget;
87  bool _redrawNeeded;
88  bool _graphChanged;
89  int width, height;
90 };
91 
92 }
93 
94 #endif // GLMAINWIDGETGRAPHICSITEM_H
95 ///@endcond