Developer Documentation
QtSceneGraphWidget.hh
1 /*===========================================================================*\
2  * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40 \*===========================================================================*/
41 
42 
43 
44 
45 
46 //=============================================================================
47 //
48 // CLASS QtSceneGraphWidget
49 //
50 //=============================================================================
51 
52 
53 #ifndef ACG_QTSCENEGRAPHWIDGET_HH
54 #define ACG_QTSCENEGRAPHWIDGET_HH
55 
56 
57 //== INCLUDES =================================================================
58 
59 #include <ACG/Config/ACGDefines.hh>
60 #include <ACG/Scenegraph/BaseNode.hh>
61 #include <QDialog>
62 #include <QKeyEvent>
63 #include <QMenu>
64 #include <QTreeWidget>
65 #include <QMap>
66 
67 
68 //== FORWARDDECLARATIONS ======================================================
69 
70 
71 
72 //== NAMESPACES ===============================================================
73 
74 
75 namespace ACG {
76 namespace QtWidgets {
77 
78 
79 //== CLASS DEFINITION =========================================================
80 
81 class ACGDLLEXPORT SceneGraphWidgetGenerator {
82 
83 public:
84  // constructor
86 
87  // destructor
88  virtual ~SceneGraphWidgetGenerator() {}
89 
99  virtual QWidget* getWidget(SceneGraph::BaseNode* _node );
100 
105  virtual bool canHandle(std::string _className);
106 
111  virtual std::string handles();
112 
117  virtual QString contextMenuName();
118 
119 protected:
120 
121  QMap< SceneGraph::BaseNode* , QWidget* > widgetMap_;
122 };
123 
124 
125 
134 class ACGDLLEXPORT QtSceneGraphWidget : public QTreeWidget
135 {
136  Q_OBJECT
137 
138 public:
139 
141  QtSceneGraphWidget(QWidget* _parent = 0,
142  SceneGraph::BaseNode* _rootNode = 0);
143 
144 
146  virtual ~QtSceneGraphWidget() {}
147 
148  enum Columns { Node, Type, Status, Mode };
149 
150 
151  class Item : public QTreeWidgetItem
152  {
153  public:
154  // root constructor
155  Item(QTreeWidget* _parent,
156  SceneGraph::BaseNode* _node);
157 
158  // child constructor
159  Item(Item* _parent,
160  SceneGraph::BaseNode* _node);
161 
162  // get node
163  SceneGraph::BaseNode * node() { return node_; }
164 
165  // update text, etc.
166  void update();
167 
168  private:
169  SceneGraph::BaseNode* node_;
170  };
171 
172 
173 
174 public slots:
175 
177  void update( ACG::SceneGraph::BaseNode* _rootNode );
178 
179 
180 signals:
181 
184  void signalNodeChanged(ACG::SceneGraph::BaseNode* _node);
185 
186 
187 private slots:
188 
189  void slotItemPressed( QTreeWidgetItem * _item,
190  int _col );
191 
192  void slotItemExpandedOrCollapsed( QTreeWidgetItem * _item );
193 
194  void slotNodeChanged( ACG::SceneGraph::BaseNode * _node );
195 
196  void slotModeMenu ( QAction * _action );
197  void slotStatusMenu( QAction * _action );
198 
199  void slotEditMaterial();
200  void slotEditTexture();
201  void slotEditShader();
202  void slotEditClipPlanes();
203  void slotEditCoordinateFrame();
204 
205 
206 
207 private:
208 
210  QtSceneGraphWidget( const QtSceneGraphWidget & _rhs );
212  QtSceneGraphWidget & operator=( const QtSceneGraphWidget & _rhs );
213 
215  void update( SceneGraph::BaseNode * _node, Item * _parent );
216 
218  void keyPressEvent(QKeyEvent* _event);
220  void keyReleaseEvent(QKeyEvent* _event);
221 
222 
223 
224  SceneGraph::BaseNode * rootNode_;
225 
226  QMenu * modeMenu_;
227 
228  Item * curItem_;
229  bool shiftPressed_; // store shift for popup menu
230 
231  struct StatusActions {
232  QMenu * menu_;
233  QAction * actionActive_;
234  QAction * actionHideNode_;
235  QAction * actionHideChildren_;
236  QAction * actionHideSubtree_;
237  } statusActions_;
238 
239  public slots:
240 
241  void expandAll();
242 
243  void updateAll();
244 
245  public:
246 
251  bool addWidgetGenerator( SceneGraphWidgetGenerator* _generator );
252 
255  void setGeneratorMap( QMap< std::string , SceneGraphWidgetGenerator* > _map) { generatorMap_ = _map; };
256 
257  private:
258  QMap< std::string , SceneGraphWidgetGenerator* > generatorMap_;
259 };
260 
261 
262 
263 //== CLASS DEFINITION =========================================================
264 
265 
266 class ACGDLLEXPORT QtSceneGraphDialog : public QDialog
267 {
268  Q_OBJECT
269 
270 public:
271 
272  QtSceneGraphDialog( QWidget * _parent = 0,
273  SceneGraph::BaseNode * _rootNode = 0 );
274 
275 
276 public slots:
277 
279  void update(ACG::SceneGraph::BaseNode* _rootNode);
280 
281 
282 signals:
283 
286  void signalNodeChanged(ACG::SceneGraph::BaseNode* _node);
287 
288 
289 private slots:
290 
291  void slotNodeChanged(ACG::SceneGraph::BaseNode* _node);
292 
293 
294 public:
297  void setGeneratorMap( QMap< std::string , SceneGraphWidgetGenerator* > _map) { sgw_->setGeneratorMap(_map); };
298 
299 private:
300 
301  QtSceneGraphWidget * sgw_;
302 
303 };
304 
305 
306 //=============================================================================
307 } // namespace ACG
308 } // namespace QtWidgets
309 //=============================================================================
310 #endif // ACG_QTSCENEGRAPHWIDGET_HH defined
311 //=============================================================================
Namespace providing different geometric functions concerning angles.
Add status to mesh item (all items)
Definition: Attributes.hh:85
void setGeneratorMap(QMap< std::string, SceneGraphWidgetGenerator * > _map)
Set a complete generator map (this will overwrite the existing one!
void setGeneratorMap(QMap< std::string, SceneGraphWidgetGenerator * > _map)
Set a complete generator map (this will overwrite the existing one!