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