Tulip  5.1.0
Large graphs analysis and drawing
GlMainView.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 
20 #ifndef Tulip_GLMAINVIEW_H
21 #define Tulip_GLMAINVIEW_H
22 
23 #include <tulip/ViewWidget.h>
24 
25 class QGraphicsProxyWidget;
26 class QAction;
27 class QPushButton;
28 class QRectF;
29 
30 namespace tlp {
31 class GlOverviewGraphicsItem;
32 class SceneConfigWidget;
33 class SceneLayersConfigWidget;
34 class GlMainWidget;
35 class QuickAccessBar;
36 
37 /**
38  * @ingroup Plugins
39  *
40  * @brief An abstract view that displays a GlMainWidget as its central widget.
41  *
42  * The GlMainView subclasses ViewWidget and always uses a GlMainWidget as the central widget of the panel. It also adds the following features:
43  * @list
44  * @li An overview of the scene that can be toggled on or off.
45  * @li Some configuration widgets that modify the rendering parameters.
46  * @li A quick access bar widget that allows the user to quickly modify some of the most used rendering parameters and graph properties (nodes color, edges display, etc)
47  * @li The possibility to make snapshots of the current scene
48  * @endlist
49  *
50  * Subclassing GlMainView means you will only want to display graphs in a single GlMainWidget. Switching the central widget can only be achieved from the ViewWidget class.
51  *
52  * @warning It is strongly unadvised to re-implement methods already implemented into tlp::View or tlp::ViewWidget. If you have to add custom behavior to those method, make sure to call the upper-class methods first:
53  @code
54  void MyView::setupWidget() { // Where MyView is a subclass of tlp::GlMainView
55  GlMainView::setupWidget(); // call this first
56  // insert custom behavior here
57  }
58  @endcode
59 
60  * @see tlp::ViewWidget
61  */
62 class TLP_QT_SCOPE GlMainView: public tlp::ViewWidget {
63 
64  Q_OBJECT
65 
66  tlp::GlMainWidget* _glMainWidget;
67  tlp::GlOverviewGraphicsItem* _overviewItem;
68 
69  QAction *_centerViewAction;
70  QAction *_forceRedrawAction;
71  QAction* _advAntiAliasingAction;
72  QAction* _snapshotAction;
73 
74  QPushButton *_showOvButton, *_showQabButton;
75 
76 protected :
77 
78  bool needQuickAccessBar;
79  QGraphicsProxyWidget* _quickAccessBarItem;
80  tlp::QuickAccessBar* _quickAccessBar;
81  tlp::SceneConfigWidget* _sceneConfigurationWidget;
82  tlp::SceneLayersConfigWidget* _sceneLayersConfigurationWidget;
83 
84 public:
85 
86  enum OverviewPosition {OVERVIEW_TOP_LEFT, OVERVIEW_TOP_RIGHT, OVERVIEW_BOTTOM_LEFT, OVERVIEW_BOTTOM_RIGHT};
87 
88  GlMainView();
89  virtual ~GlMainView();
90  tlp::GlMainWidget* getGlMainWidget() const;
91  virtual QList<QWidget*> configurationWidgets() const;
92  bool overviewVisible() const;
93  QPixmap snapshot(const QSize &outputSize=QSize()) const;
94 
95  void setOverviewPosition(const OverviewPosition &position);
96  OverviewPosition overviewPosition() const;
97 
98  void setUpdateOverview(bool updateOverview);
99  bool updateOverview() const;
100 
101  void setState(const tlp::DataSet &);
102  tlp::DataSet state() const;
103 
104 public slots:
105  /**
106  * @brief Calls GlMainWidget::draw();
107  */
108  virtual void draw();
109 
110  /**
111  * @brief Calls GlMainWidget::redraw();
112  */
113  void redraw();
114 
115  /**
116  * @brief Calls GlMainWidget::redraw();
117  */
118  virtual void refresh();
119 
120  /**
121  * @brief Force the overview to be redrawn. Since GlMainView already detects graph's modifications, this method should not be called manually to avoid extra rendering.
122  */
123  virtual void drawOverview(bool generatePixmap=true);
124 
125  /**
126  * @brief Centers the scene's camera
127  */
128  virtual void centerView(bool graphChanged = false);
129 
130  /**
131  * @brief Toggles the overview on or off
132  */
133  void setOverviewVisible(bool);
134 
135  /**
136  * @brief Toggles the orthogonal projection on or off, then draws
137  */
138  void setViewOrtho(bool);
139 
140  /**
141  * @brief Force the settings set in the configuration widgets to be re-applied.
142  */
143  void applySettings();
144 
145  /**
146  * @brief Display a dialog that takes a snapshot of the current scene.
147  */
148  void openSnapshotDialog();
149 
150  void undoCallback();
151 
152  void setAntiAliasing(bool);
153 
154  void setAdvancedAntiAliasing(bool);
155 
156 
157 protected slots:
158  virtual void glMainViewDrawn(bool graphChanged);
159  virtual void sceneRectChanged(const QRectF&);
160  void setQuickAccessBarVisible(bool);
161  void fillContextMenu(QMenu *menu,const QPointF &);
162  void delayedCenterView();
163 
164 
165 protected:
166  virtual void setupWidget();
167  bool quickAccessBarVisible() const;
168  void assignNewGlMainWidget(GlMainWidget *glMainWidget,bool deleteOldGlMainWidget=true);
169  bool eventFilter(QObject* obj, QEvent* event);
170 
171  tlp::GlOverviewGraphicsItem* overviewItem() const;
172  void updateShowOverviewButton();
173  void updateShowQuickAccessBarButton();
174  virtual QuickAccessBar* getQuickAccessBarImpl();
175 
176  OverviewPosition _overviewPosition;
177 
178  bool _updateOverview;
179 
180 };
181 }
182 
183 #endif /* GLMAINVIEW_H_ */
An abstract view that displays a GlMainWidget as its central widget.
Definition: GlMainView.h:62
A container that can store data from any type.
Definition: DataSet.h:190
ViewWidget provides convenience functions to allow the user to build a view plugin that displays a QW...
Definition: ViewWidget.h:43
This widget provide a simple system to visualize data/graph with OpenGL 3D engine.
Definition: GlMainWidget.h:67