Salome HOME
Make XGUI as a shared library
[modules/shaper.git] / src / XGUI / XGUI_DataTreeModel.h
1
2 #ifndef XGUI_DataTreeModel_H
3 #define XGUI_DataTreeModel_H
4
5 #include "XGUI.h"
6 #include "XGUI_Constants.h"
7
8 #include <ModelAPI_Document.h>
9 #include <QAbstractItemModel>
10
11 /**\class XGUI_FeaturesModel
12  * \ingroup GUI
13  * \brief Abstaract class of model object which operates with features data.
14  */
15 class XGUI_EXPORT 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   //! Returns index corresponded to the group
29   virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
30
31 protected:
32   std::shared_ptr<ModelAPI_Document> myDocument;
33 };
34
35
36 /**\class XGUI_PartModel
37  * \ingroup GUI
38  * \brief Abstaract class of model object which operates with parts data.
39  */
40 class XGUI_PartModel : public XGUI_FeaturesModel
41 {
42 public:
43   XGUI_PartModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
44       XGUI_FeaturesModel(theDocument, theParent) {}
45
46   void setPartId(int theId) { myId = theId; }
47
48   //! Returns true if the given document is a sub-document of this tree
49   virtual bool hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const = 0;
50
51 protected:
52   //! Id of the current part object in the document
53   int myId;
54 };
55
56
57 #endif