Salome HOME
Issue #326 Distance constraint on 2 preselected segments problem
[modules/shaper.git] / src / XGUI / XGUI_PartDataModel.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 #ifndef XGUI_PartDataModel_H
4 #define XGUI_PartDataModel_H
5
6 #include "XGUI.h"
7 #include "XGUI_DataTreeModel.h"
8
9 /**\class XGUI_TopDataModel
10  * \ingroup GUI
11  * \brief This is a data model for Object Browser (QTreeView).
12  * It represents only upper part of data tree (non-parts tree items)
13  */
14 class XGUI_EXPORT XGUI_TopDataModel : public XGUI_FeaturesModel
15 {
16 Q_OBJECT
17  public:
18   XGUI_TopDataModel(QObject* theParent);
19   virtual ~XGUI_TopDataModel();
20
21   // Reimpl from QAbstractItemModel
22   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
23   virtual QVariant headerData(int section, Qt::Orientation orientation,
24                               int role = Qt::DisplayRole) const;
25
26   virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
27   virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
28
29   virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
30                                 QModelIndex()) const;
31
32   virtual QModelIndex parent(const QModelIndex& theIndex) const;
33
34   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
35
36   //! Returns object by the given Model index.
37   //! Returns 0 if the given index is not index of a object
38   virtual ObjectPtr object(const QModelIndex& theIndex) const;
39
40   //! Returns QModelIndex which corresponds to the given object
41   //! If the object is not found then index is not valid
42   virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
43
44   //! Returns parent index of the given object
45   virtual QModelIndex findParent(const ObjectPtr& theObject) const;
46
47   //! Returns index corresponded to the group
48   virtual QModelIndex findGroup(const std::string& theGroup) const;
49
50  private:
51   //! Types of QModelIndexes
52   enum DataIds
53   {
54     ParamsFolder,
55     ParamObject,
56     ConstructFolder,
57     ConstructObject
58     //GroupsFolder,
59     //GroupObject
60   };
61
62 };
63
64 /**\class XGUI_PartDataModel
65  * \ingroup GUI
66  * \brief This is a data model for Object Browser (QTreeView).
67  * It represents data tree only of a one part
68  */
69 class XGUI_PartDataModel : public XGUI_PartModel
70 {
71 Q_OBJECT
72  public:
73   XGUI_PartDataModel(QObject* theParent);
74   virtual ~XGUI_PartDataModel();
75
76   // Reimpl from QAbstractItemModel
77   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
78   virtual QVariant headerData(int section, Qt::Orientation orientation,
79                               int role = Qt::DisplayRole) const;
80
81   virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
82   virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
83
84   virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
85                                 QModelIndex()) const;
86
87   virtual QModelIndex parent(const QModelIndex& theIndex) const;
88
89   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
90
91   //! Returns object by the given Model index.
92   //! Returns 0 if the given index is not index of a object
93   virtual ObjectPtr object(const QModelIndex& theIndex) const;
94
95   //! Returns QModelIndex which corresponds to the given object
96   //! If the object is not found then index is not valid
97   virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
98
99   //! Returns true if the given document is a sub-document of this tree
100   virtual bool hasDocument(const DocumentPtr& theDoc) const;
101
102   //! Returns parent index of the given object
103   virtual QModelIndex findParent(const ObjectPtr& theObject) const;
104
105   //! Returns index corresponded to the group
106   virtual QModelIndex findGroup(const std::string& theGroup) const;
107
108   //! Return a Part object
109   virtual ResultPartPtr part() const;
110
111  private:
112
113   //! Returns document of the current part
114   DocumentPtr partDocument() const;
115
116   int getRowsNumber() const;
117
118   //! Types of QModelIndexes
119   enum DataIds
120   {
121     MyRoot,
122     ParamsFolder,
123     ParamObject,
124     ConstructFolder,
125     ConstructObject,
126     BodiesFolder,
127     BodiesObject,
128     GroupsFolder,
129     GroupObject,
130     HistoryObject
131   };
132
133 };
134
135 #endif