Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[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 <ModelAPI_Feature.h>
10 #include <ModelAPI_ResultPart.h>
11
12 #include <QAbstractItemModel>
13 #include <QColor>
14
15 /**\class XGUI_FeaturesModel
16  * \ingroup GUI
17  * \brief Abstaract class of model object which operates with features data.
18  */
19 class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel
20 {
21 public:
22   XGUI_FeaturesModel(QObject* theParent):
23       QAbstractItemModel(theParent), myItemsColor(Qt::black) {}
24
25   //! Returns Feature object by the given Model index.
26   //! Returns 0 if the given index is not index of a feature
27   virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
28
29   //! Returns QModelIndex which corresponds to the given feature
30   //! If the feature is not found then index is not valid
31   virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0;
32
33   //! Returns parent index of the given feature
34   virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
35
36   //! Returns index corresponded to the group
37   virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
38
39   void setItemsColor(const QColor& theColor) { myItemsColor = theColor; }
40
41   QColor itemsColor() const { return myItemsColor; }
42
43 protected:
44   QColor myItemsColor;
45 };
46
47
48 /**\class XGUI_PartModel
49  * \ingroup GUI
50  * \brief Abstaract class of model object which operates with parts data.
51  */
52 class XGUI_PartModel : public XGUI_FeaturesModel
53 {
54 public:
55   XGUI_PartModel(QObject* theParent):
56       XGUI_FeaturesModel(theParent) {}
57
58   void setPartId(int theId) { myId = theId; }
59
60   //! Returns true if the given document is a sub-document of this tree
61   virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
62
63   //! Return a Part object
64   virtual ResultPartPtr part() const = 0;
65
66 protected:
67   //! Id of the current part object in the document
68   int myId;
69 };
70
71
72 #endif