OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
scene_win_model.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GUI_SCENE_WIN_SCENE_WIN_MODEL_HH
20 #define OST_GUI_SCENE_WIN_SCENE_WIN_MODEL_HH
21 
22 /*
23  Author: Stefan Scheuber, Marco Biasini, Ansgar Philippsen
24  */
25 
26 
27 #include <ost/mol/view_type_fw.hh>
29 
30 #include <ost/gfx/gfx_node_fw.hh>
32 
33 #include <ost/gui/module_config.hh>
36 
37 #include <QStringList>
38 #include <QMimeData>
39 #include <QMap>
40 #include <QAbstractItemModel>
41 namespace ost { namespace gui {
42 
43 
44 
45 
47 class DLLEXPORT_OST_GUI SceneWinModel : public QAbstractItemModel,
48  public gfx::SceneObserver {
49  Q_OBJECT
50 public:
51  SceneWinModel(QObject* parent=NULL);
52  ~SceneWinModel();
53 
54  gfx::NodePtrList GetGfxNodes(QModelIndexList indexes);
55  mol::QueryViewWrapperList GetQueryViewsList(QModelIndexList indexes);
56  gfx::EntityP GetEntityOfViews(QModelIndexList indexes);
57 
58  virtual void Update();
59 
60  SceneNode* GetItem(const QModelIndex &index) const;
61 
62  SceneNode* FindGfxNode(gfx::GfxNodeP node);
63 
64 
65  bool AddNode(SceneNode* parent, SceneNode* child);
66  bool RemoveNode(SceneNode* node);
67 
68  void AttachRenderModeObserver(RenderModesNode* node);
69  void DetachRenderModeObserver(RenderModesNode* node);
70 
71  QModelIndex GetIndexOf(SceneNode* node, int column=0);
72 
73  // abstract item model interface
74  QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const;
75 
76  QModelIndex parent(const QModelIndex& index) const;
77 
78  int rowCount(const QModelIndex& parent=QModelIndex()) const;
79 
80  int columnCount(const QModelIndex& parent=QModelIndex()) const;
81 
82  QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const;
83 
84  QVariant headerData(int section, Qt::Orientation orientation,
85  int role=Qt::DisplayRole) const;
86 
87  virtual Qt::ItemFlags flags(const QModelIndex& index=QModelIndex()) const;
88 
89  virtual bool setData(const QModelIndex& index=QModelIndex(),
90  const QVariant& value=QVariant(),
91  int role=Qt::DisplayRole);
92 
93  virtual QStringList mimeTypes() const;
94  Qt::DropActions supportedDragActions() const;
95  virtual QMimeData* mimeData(const QModelIndexList& indexes) const;
96 
97  // scene observer interface
98  virtual void NodeAdded(const gfx::GfxNodeP& node);
99  virtual void NodeRemoved(const gfx::GfxNodeP& node);
100  virtual void SelectionChanged(const gfx::GfxObjP& obj, const mol::EntityView& sel);
101  virtual void RenderModeChanged(const gfx::GfxNodeP& node);
102 
103 private:
104  QModelIndex GetIndex(SceneNode* node, QModelIndex index,int column);
105 
106  SceneNode* root_node_;
107  SceneNode* scene_node_;
108 
109  QMap<gfx::GfxNode*, RenderModesNode*> render_observers_;
110  QMap<gfx::GfxNode*, SceneNode*> node_map_;
111 };
112 
113 }}
114 
115 #endif
boost::shared_ptr< GfxObj > GfxObjP
boost::shared_ptr< Entity > EntityP
Definition: entity_fw.hh:27
Interface for observing graphical objects.
#define DLLEXPORT_OST_GUI
data model for scene win
definition of EntityView
Definition: entity_view.hh:86
std::vector< GfxNodeP > NodePtrList
Definition: gfx_node_fw.hh:34
boost::shared_ptr< GfxNode > GfxNodeP
Definition: gfx_node_fw.hh:31
std::vector< QueryViewWrapper > QueryViewWrapperList
Definition: view_type_fw.hh:51