Salome HOME
Release version on WIndows
[modules/shaper.git] / src / XGUI / XGUI_DataTreeModel.h
1
2
3 #ifndef XGUI_DataTreeModel_H
4 #define XGUI_DataTreeModel_H
5
6 #include <ModelAPI_Document.h>
7 #include <QAbstractItemModel>
8
9 #include "XGUI_Constants.h"
10
11 /**\class XGUI_FeaturesModel
12  * \ingroup GUI
13  * \brief Abstaract class of model object which operates with features data.
14  */
15 class XGUI_FeaturesModel : public QAbstractItemModel
16 {
17 public:
18   XGUI_FeaturesModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
19       QAbstractItemModel(theParent), myDocument(theDocument) {}
20
21   //! Returns Feature object by the given Model index.
22   //! Returns 0 if the given index is not index of a feature
23   virtual FeaturePtr feature(const QModelIndex& theIndex) const = 0;
24
25   //! Returns parent index of the given feature
26   virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const = 0;
27
28 protected:
29   std::shared_ptr<ModelAPI_Document> myDocument;
30 };
31
32
33 /**\class XGUI_PartModel
34  * \ingroup GUI
35  * \brief Abstaract class of model object which operates with parts data.
36  */
37 class XGUI_PartModel : public XGUI_FeaturesModel
38 {
39 public:
40   XGUI_PartModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
41       XGUI_FeaturesModel(theDocument, theParent) {}
42
43   void setPartId(int theId) { myId = theId; }
44
45   //! Returns true if the given document is a sub-document of this tree
46   virtual bool hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const = 0;
47
48 protected:
49   //! Id of the current part object in the document
50   int myId;
51 };
52
53
54 #endif