Tulip  4.1.0
Better Visualization Through Research
 All Classes 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 <QtGui/QGraphicsObject>
33 #include <tulip/tulipconf.h>
34 
35 namespace tlp {
36 class GlMainWidget;
37 }
38 
39 
40 namespace tlp {
41 class TLP_QT_SCOPE GlMainWidgetGraphicsItem : public QGraphicsObject {
42  Q_OBJECT
43 public:
44  GlMainWidgetGraphicsItem(tlp::GlMainWidget *glMainWidget, int width, int height);
45  virtual ~GlMainWidgetGraphicsItem();
46 
47  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
48 
49  QRectF boundingRect() const;
50 
51  void resize(int width, int height);
52 
53  void setRedrawNeeded(bool redrawNeeded) {
54  this->_redrawNeeded=redrawNeeded;
55  }
56 
57  tlp::GlMainWidget *getGlMainWidget() {
58  return glMainWidget;
59  }
60 
61  bool eventFilter(QObject *, QEvent *evt);
62 
63 signals:
64 
65  void widgetPainted(bool redraw);
66 
67 protected :
68  void keyPressEvent(QKeyEvent *event);
69  void keyReleaseEvent(QKeyEvent *event);
70  void wheelEvent(QGraphicsSceneWheelEvent *event);
71  void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
72  void mousePressEvent(QGraphicsSceneMouseEvent *event);
73  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
74  void hoverMoveEvent(QGraphicsSceneHoverEvent * event);
75  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
76  void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
77  void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
78  void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
79  void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
80  void dropEvent(QGraphicsSceneDragDropEvent *event);
81 
82 protected slots:
83  void glMainWidgetDraw(GlMainWidget *,bool);
84  void glMainWidgetRedraw(GlMainWidget *);
85 
86 private :
87  tlp::GlMainWidget *glMainWidget;
88  bool _redrawNeeded;
89  bool _graphChanged;
90  int width, height;
91 };
92 
93 }
94 
95 #endif // GLMAINWIDGETGRAPHICSITEM_H
96 ///@endcond