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