Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  * $Revision$ *
45  * $Author$ *
46  * $Date$ *
47  * *
48 \*===========================================================================*/
49 
50 
51 
52 //=============================================================================
53 //
54 // CLASS QtSceneGraphWidget
55 //
56 //=============================================================================
57 
58 
59 #ifndef ACG_QTSCENEGRAPHWIDGET_HH
60 #define ACG_QTSCENEGRAPHWIDGET_HH
61 
62 
63 //== INCLUDES =================================================================
64 
65 #include <ACG/Config/ACGDefines.hh>
66 #include <ACG/Scenegraph/BaseNode.hh>
67 #include <QDialog>
68 #include <QKeyEvent>
69 #include <QMenu>
70 #include <QTreeWidget>
71 #include <QMap>
72 
73 
74 //== FORWARDDECLARATIONS ======================================================
75 
76 
77 
78 //== NAMESPACES ===============================================================
79 
80 
81 namespace ACG {
82 namespace QtWidgets {
83 
84 
85 //== CLASS DEFINITION =========================================================
86 
87 class ACGDLLEXPORT SceneGraphWidgetGenerator {
88 
89 public:
90  // constructor
92 
93  // destructor
94  virtual ~SceneGraphWidgetGenerator() {}
95 
105  virtual QWidget* getWidget(SceneGraph::BaseNode* _node );
106 
111  virtual bool canHandle(std::string _className);
112 
117  virtual std::string handles();
118 
123  virtual QString contextMenuName();
124 
125 protected:
126 
127  QMap< SceneGraph::BaseNode* , QWidget* > widgetMap_;
128 };
129 
130 
131 
140 class ACGDLLEXPORT QtSceneGraphWidget : public QTreeWidget
141 {
142  Q_OBJECT
143 
144 public:
145 
147  QtSceneGraphWidget(QWidget* _parent = 0,
148  SceneGraph::BaseNode* _rootNode = 0);
149 
150 
152  virtual ~QtSceneGraphWidget() {}
153 
154  enum Columns { Node, Type, Status, Mode };
155 
156 
157  class Item : public QTreeWidgetItem
158  {
159  public:
160  // root constructor
161  Item(QTreeWidget* _parent,
162  SceneGraph::BaseNode* _node);
163 
164  // child constructor
165  Item(Item* _parent,
166  SceneGraph::BaseNode* _node);
167 
168  // get node
169  SceneGraph::BaseNode * node() { return node_; }
170 
171  // update text, etc.
172  void update();
173 
174  private:
175  SceneGraph::BaseNode* node_;
176  };
177 
178 
179 
180 public slots:
181 
183  void update( ACG::SceneGraph::BaseNode* _rootNode );
184 
185 
186 signals:
187 
190  void signalNodeChanged(ACG::SceneGraph::BaseNode* _node);
191 
192 
193 private slots:
194 
195  void slotItemPressed( QTreeWidgetItem * _item,
196  int _col );
197 
198  void slotItemExpandedOrCollapsed( QTreeWidgetItem * _item );
199 
200  void slotNodeChanged( ACG::SceneGraph::BaseNode * _node );
201 
202  void slotModeMenu ( QAction * _action );
203  void slotStatusMenu( QAction * _action );
204 
205  void slotEditMaterial();
206  void slotEditTexture();
207  void slotEditShader();
208  void slotEditClipPlanes();
209  void slotEditCoordinateFrame();
210 
211 
212 
213 private:
214 
216  QtSceneGraphWidget( const QtSceneGraphWidget & _rhs );
218  QtSceneGraphWidget & operator=( const QtSceneGraphWidget & _rhs );
219 
221  void update( SceneGraph::BaseNode * _node, Item * _parent );
222 
224  void keyPressEvent(QKeyEvent* _event);
226  void keyReleaseEvent(QKeyEvent* _event);
227 
228 
229 
230  SceneGraph::BaseNode * rootNode_;
231 
232  QMenu * modeMenu_;
233 
234  Item * curItem_;
235  bool shiftPressed_; // store shift for popup menu
236 
237  struct StatusActions {
238  QMenu * menu_;
239  QAction * actionActive_;
240  QAction * actionHideNode_;
241  QAction * actionHideChildren_;
242  QAction * actionHideSubtree_;
243  } statusActions_;
244 
245  public slots:
246 
247  void expandAll();
248 
249  void updateAll();
250 
251  public:
252 
257  bool addWidgetGenerator( SceneGraphWidgetGenerator* _generator );
258 
261  void setGeneratorMap( QMap< std::string , SceneGraphWidgetGenerator* > _map) { generatorMap_ = _map; };
262 
263  private:
264  QMap< std::string , SceneGraphWidgetGenerator* > generatorMap_;
265 };
266 
267 
268 
269 //== CLASS DEFINITION =========================================================
270 
271 
272 class ACGDLLEXPORT QtSceneGraphDialog : public QDialog
273 {
274  Q_OBJECT
275 
276 public:
277 
278  QtSceneGraphDialog( QWidget * _parent = 0,
279  SceneGraph::BaseNode * _rootNode = 0 );
280 
281 
282 public slots:
283 
285  void update(ACG::SceneGraph::BaseNode* _rootNode);
286 
287 
288 signals:
289 
292  void signalNodeChanged(ACG::SceneGraph::BaseNode* _node);
293 
294 
295 private slots:
296 
297  void slotNodeChanged(ACG::SceneGraph::BaseNode* _node);
298 
299 
300 public:
303  void setGeneratorMap( QMap< std::string , SceneGraphWidgetGenerator* > _map) { sgw_->setGeneratorMap(_map); };
304 
305 private:
306 
307  QtSceneGraphWidget * sgw_;
308 
309 };
310 
311 
312 //=============================================================================
313 } // namespace ACG
314 } // namespace QtWidgets
315 //=============================================================================
316 #endif // ACG_QTSCENEGRAPHWIDGET_HH defined
317 //=============================================================================
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
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!
Add status to mesh item (all items)
Definition: Attributes.hh:90