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