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