QtSceneGraphWidget.hh

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 6743 $                                                       *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2009-08-05 11:03:10 +0200 (Mi, 05. Aug 2009) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 //=============================================================================
00046 //
00047 //  CLASS QtSceneGraphWidget
00048 //
00049 //=============================================================================
00050 
00051 
00052 #ifndef ACG_QTSCENEGRAPHWIDGET_HH
00053 #define ACG_QTSCENEGRAPHWIDGET_HH
00054 
00055 
00056 //== INCLUDES =================================================================
00057 
00058 #include "../Config/ACGDefines.hh"
00059 #include <QDialog>
00060 #include <QKeyEvent>
00061 #include <QMenu>
00062 #include <QTreeWidget>
00063 #include <QMap>
00064 
00065 
00066 //== FORWARDDECLARATIONS ======================================================
00067 
00068 
00069 namespace ACG {
00070   namespace SceneGraph {
00071     class BaseNode;
00072   }
00073 }
00074 
00075 
00076 //== NAMESPACES ===============================================================
00077 
00078 
00079 namespace ACG {
00080 namespace QtWidgets {
00081 
00082 
00083 //== CLASS DEFINITION =========================================================
00084 
00085 
00094 class ACGDLLEXPORT QtSceneGraphWidget : public QTreeWidget
00095 {
00096   Q_OBJECT
00097 
00098 public:
00099 
00101   QtSceneGraphWidget( QWidget              * _parent = 0,
00102                       SceneGraph::BaseNode * _rootNode = 0 );
00103 
00104 
00106   ~QtSceneGraphWidget() {}
00107 
00108 
00109   enum Columns { Node, Type, Status, Mode };
00110 
00111 
00112   class Item : public QTreeWidgetItem
00113   {
00114   public:
00115     // root constructor
00116     Item( QTreeWidget          * _parent,
00117           SceneGraph::BaseNode * _node );
00118 
00119     // child constructor
00120     Item( Item                 * _parent,
00121           SceneGraph::BaseNode * _node );
00122 
00123     // get node
00124     SceneGraph::BaseNode * node() { return node_; }
00125 
00126     // update text, etc.
00127     void update();
00128 
00129   private:
00130     SceneGraph::BaseNode*  node_;
00131   };
00132 
00133 
00134 
00135 public slots:
00136 
00138   void update( ACG::SceneGraph::BaseNode* _rootNode );
00139 
00140 
00141 signals:
00142 
00145   void signalNodeChanged(ACG::SceneGraph::BaseNode* _node);
00146 
00147 
00148 private slots:
00149 
00150   void slotItemPressed( QTreeWidgetItem * _item,
00151                         int            _col );
00152 
00153   void slotItemExpandedOrCollapsed( QTreeWidgetItem * _item );
00154 
00155   void slotNodeChanged( ACG::SceneGraph::BaseNode * _node );
00156 
00157   void slotModeMenu  ( QAction * _action );
00158   void slotStatusMenu( QAction * _action );
00159 
00160   void slotEditMaterial();
00161   void slotEditShader();
00162   void slotEditClipPlanes();
00163   void slotEditCoordinateFrame();
00164 
00165 
00166 
00167 private:
00168 
00170   QtSceneGraphWidget( const QtSceneGraphWidget & _rhs );
00172   QtSceneGraphWidget & operator=( const QtSceneGraphWidget & _rhs );
00173 
00175   void update( SceneGraph::BaseNode * _node, Item * _parent );
00176 
00178   void keyPressEvent(QKeyEvent* _event);
00180   void keyReleaseEvent(QKeyEvent* _event);
00181 
00182 
00183 
00184   SceneGraph::BaseNode * rootNode_;
00185 
00186   QMenu *                modeMenu_;
00187 
00188   Item  *                curItem_;
00189   bool                   shiftPressed_; // store shift for popup menu
00190 
00191   struct StatusActions {
00192     QMenu   * menu_;
00193     QAction * actionActive_;
00194     QAction * actionHideNode_;
00195     QAction * actionHideChildren_;
00196     QAction * actionHideSubtree_;
00197   } statusActions_;
00198 };
00199 
00200 
00201 
00202 //== CLASS DEFINITION =========================================================
00203 
00204 
00205 class ACGDLLEXPORT QtSceneGraphDialog : public QDialog
00206 {
00207   Q_OBJECT
00208 
00209 public:
00210 
00211   QtSceneGraphDialog( QWidget              * _parent = 0,
00212                       SceneGraph::BaseNode * _rootNode = 0 );
00213 
00214 
00215 public slots:
00216 
00218   void update(ACG::SceneGraph::BaseNode* _rootNode);
00219 
00220 
00221 signals:
00222 
00225   void signalNodeChanged(ACG::SceneGraph::BaseNode* _node);
00226 
00227 
00228 private slots:
00229 
00230   void slotNodeChanged(ACG::SceneGraph::BaseNode* _node);
00231 
00232 
00233 private:
00234 
00235   QtSceneGraphWidget * sgw_;
00236 
00237 };
00238 
00239 
00240 //=============================================================================
00241 } // namespace ACG
00242 } // namespace QtWidgets
00243 //=============================================================================
00244 #endif // ACG_QTSCENEGRAPHWIDGET_HH defined
00245 //=============================================================================

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .