| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Library General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 |
* GNU Library General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Library General Public * |
| 17 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 18 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 19 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
#ifndef GUI_SCENEINSPECTOR_H |
| 24 |
#define GUI_SCENEINSPECTOR_H |
| 25 |
|
| 26 |
#include <QDialog> |
| 27 |
#include <QHash> |
| 28 |
#include <QStandardItemModel> |
| 29 |
|
| 30 |
class SoNode; |
| 31 |
|
| 32 |
namespace Gui |
| 33 |
{ |
| 34 |
class Document; |
| 35 |
namespace Dialog |
| 36 |
{ |
| 37 |
|
| 38 |
class Ui_SceneInspector; |
| 39 |
|
| 40 |
/// Stores data representing scenegraph nodes. |
| 41 |
class SceneModel: public QStandardItemModel |
| 42 |
{ |
| 43 |
Q_OBJECT |
| 44 |
|
| 45 |
public: |
| 46 |
SceneModel(QObject* parent); |
| 47 |
~SceneModel() override; |
| 48 |
|
| 49 |
/// Tree structure: column count is 1. |
| 50 |
int columnCount(const QModelIndex& parent = QModelIndex()) const override; |
| 51 |
/** returns empty QVariant, unless orientation == Qt::Horizontal, |
| 52 |
* role == Qt::DisplayRole and section == 0 where it returns |
| 53 |
* "Inventor Tree" |
| 54 |
*/ |
| 55 |
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; |
| 56 |
/// header data not used: returns false |
| 57 |
bool setHeaderData( |
| 58 |
int section, |
| 59 |
Qt::Orientation orientation, |
| 60 |
const QVariant& value, |
| 61 |
int role = Qt::EditRole |
| 62 |
) override; |
| 63 |
/// insert the first node in tree |
| 64 |
void setNode(SoNode* node); |
| 65 |
/// set names per node |
| 66 |
void setNodeNames(const QHash<SoNode*, QString>& names); |
| 67 |
/// returns standard parent's flags |
| 68 |
Qt::ItemFlags flags(const QModelIndex& index) const override; |
| 69 |
|
| 70 |
private: |
| 71 |
void setNode(QModelIndex, SoNode*); |
| 72 |
QHash<SoNode*, QString> nodeNames; |
| 73 |
}; |
| 74 |
|
| 75 |
/// Dialog window to display scenegraph model as a tree |
| 76 |
class DlgInspector: public QDialog |
| 77 |
{ |
| 78 |
Q_OBJECT |
| 79 |
|
| 80 |
public: |
| 81 |
DlgInspector(QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags()); |
| 82 |
~DlgInspector() override; |
| 83 |
|
| 84 |
void setDocument(Gui::Document* doc); |
| 85 |
|
| 86 |
private: |
| 87 |
void onRefreshButtonClicked(); |
| 88 |
|
| 89 |
protected: |
| 90 |
void changeEvent(QEvent* e) override; |
| 91 |
void setNode(SoNode* node); |
| 92 |
void setNodeNames(Gui::Document*); |
| 93 |
|
| 94 |
private: |
| 95 |
Ui_SceneInspector* ui; |
| 96 |
}; |
| 97 |
|
| 98 |
} // namespace Dialog |
| 99 |
} // namespace Gui |
| 100 |
|
| 101 |
#endif // GUI_SCENEINSPECTOR_H |