1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #ifndef PartSet_DataTreeModel_H
4 #define PartSet_DataTreeModel_H
8 #include <ModelAPI_Document.h>
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_ResultPart.h>
11 #include <ModelAPI_Session.h>
13 #include <QAbstractItemModel>
16 /**\class PartSet_FeaturesModel
18 * \brief Abstaract class of model object which operates with features data.
20 class PARTSET_EXPORT PartSet_FeaturesModel : public QAbstractItemModel
24 /// \param theParent a parent object
25 PartSet_FeaturesModel(QObject* theParent)
26 : QAbstractItemModel(theParent),
27 myItemsColor(Qt::black)
31 //! Returns Feature object by the given Model index.
32 //! Returns 0 if the given index is not index of a feature
33 /// \param theIndex a model index
34 virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
36 //! Returns QModelIndex which corresponds to the given feature
37 //! If the feature is not found then index is not valid
38 virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0;
40 //! Returns parent index of the given feature
41 virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
43 //! Returns index corresponded to the group
44 //! \param theGroup a group name
45 virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
47 //! Set color of items
48 void setItemsColor(const QColor& theColor)
50 myItemsColor = theColor;
53 //! Returns color of items
54 QColor itemsColor() const
64 /**\class PartSet_PartModel
66 * \brief Abstaract class of model object which operates with parts data.
68 class PartSet_PartModel : public PartSet_FeaturesModel
72 /// \param theParent a parent object
73 PartSet_PartModel(QObject* theParent)
74 : PartSet_FeaturesModel(theParent)
79 myPart = FeaturePtr();
83 /// \param theId a new id
84 void setPart(FeaturePtr thePart)
89 /// Returns Id of the part
90 FeaturePtr part() const { return myPart; }
92 //! Returns true if the given document is a sub-document of this tree
93 //! \param theDoc a document to check
94 virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
96 /// Returns position of the part in history
99 DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
100 return aRootDoc->index(myPart);
104 //! Id of the current part object in the document