Tulip  4.9.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlMainView.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
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 QRectF;
28 
29 namespace tlp {
30 class GlOverviewGraphicsItem;
31 class SceneConfigWidget;
32 class SceneLayersConfigWidget;
33 class GlMainWidget;
34 class QuickAccessBar;
35 
36 /**
37  * @ingroup Plugins
38  *
39  * @brief An abstract view that displays a GlMainWidget as its central widget.
40  *
41  * The GlMainView subclasses ViewWidget and always uses a GlMainWidget as the central widget of the panel. It also adds the following features:
42  * @list
43  * @li An overview of the scene that can be toggled on or off.
44  * @li Some configuration widgets that modify the rendering parameters.
45  * @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)
46  * @li The possibility to make snapshots of the current scene
47  * @endlist
48  *
49  * 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.
50  *
51  * @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:
52  @code
53  void MyView::setupWidget() { // Where MyView is a subclass of tlp::GlMainView
54  GlMainView::setupWidget(); // call this first
55  // insert custom behavior here
56  }
57  @endcode
58 
59  * @see tlp::ViewWidget
60  */
61 class TLP_QT_SCOPE GlMainView: public tlp::ViewWidget {
62 
63  Q_OBJECT
64 
65  tlp::GlMainWidget* _glMainWidget;
66  tlp::GlOverviewGraphicsItem* _overviewItem;
67  bool isOverviewVisible;
68  QGraphicsProxyWidget* _quickAccessBarItem;
69 
70  QAction *_centerViewAction;
71  QAction *_forceRedrawAction;
72  QAction* _advAntiAliasingAction;
73  QAction* _snapshotAction;
74 
75 protected :
76 
77  tlp::QuickAccessBar* _quickAccessBar;
78  tlp::SceneConfigWidget* _sceneConfigurationWidget;
79  tlp::SceneLayersConfigWidget* _sceneLayersConfigurationWidget;
80 
81 public:
82 
83  enum OverviewPosition {OVERVIEW_TOP_LEFT, OVERVIEW_TOP_RIGHT, OVERVIEW_BOTTOM_LEFT, OVERVIEW_BOTTOM_RIGHT};
84 
85  GlMainView();
86  virtual ~GlMainView();
87  tlp::GlMainWidget* getGlMainWidget() const;
88  virtual QList<QWidget*> configurationWidgets() const;
89  bool overviewVisible() const;
90  QPixmap snapshot(const QSize &outputSize=QSize()) const;
91 
92  void setOverviewPosition(const OverviewPosition &position);
93  OverviewPosition overviewPosition() const;
94 
95  void setUpdateOverview(bool updateOverview);
96  bool updateOverview() const;
97 
98 public slots:
99  /**
100  * @brief Calls GlMainWidget::draw();
101  */
102  virtual void draw();
103 
104  /**
105  * @brief Calls GlMainWidget::redraw();
106  */
107  void redraw();
108 
109  /**
110  * @brief Calls GlMainWidget::redraw();
111  */
112  virtual void refresh();
113 
114  /**
115  * @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.
116  */
117  virtual void drawOverview(bool generatePixmap=true);
118 
119  /**
120  * @brief Centers the scene's camera
121  */
122  virtual void centerView(bool graphChanged = false);
123 
124  /**
125  * @brief Toggles the overview on or off
126  */
127  void setOverviewVisible(bool);
128 
129  /**
130  * @brief Toggles the orthogonal projection on or off, then draws
131  */
132  void setViewOrtho(bool);
133 
134  /**
135  * @brief Force the settings set in the configuration widgets to be re-applied.
136  */
137  void applySettings();
138 
139  /**
140  * @brief Display a dialog that takes a snapshot of the current scene.
141  */
142  void openSnapshotDialog();
143 
144  void undoCallback();
145 
146  void setAntiAliasing(bool);
147 
148  void setAdvancedAntiAliasing(bool);
149 
150 
151 protected slots:
152  virtual void glMainViewDrawn(bool graphChanged);
153  virtual void sceneRectChanged(const QRectF&);
154  void setQuickAccessBarVisible(bool);
155  void fillContextMenu(QMenu *menu,const QPointF &);
156  void delayedCenterView();
157 
158 
159 protected:
160  virtual void setupWidget();
161  bool quickAccessBarVisible() const;
162  void assignNewGlMainWidget(GlMainWidget *glMainWidget,bool deleteOldGlMainWidget=true);
163  bool eventFilter(QObject* obj, QEvent* event);
164 
165  tlp::GlOverviewGraphicsItem* overviewItem() const;
166 
167  OverviewPosition _overviewPosition;
168 
169  bool _updateOverview;
170 
171 };
172 }
173 
174 #endif /* GLMAINVIEW_H_ */
An abstract view that displays a GlMainWidget as its central widget.
Definition: GlMainView.h:61
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