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);
27 //! Returns Feature object by the given Model index.
28 //! Returns 0 if the given index is not index of a feature
29 /// \param theIndex a model index
30 virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
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;
36 //! Returns parent index of the given feature
37 virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
39 //! Returns index corresponded to the group
40 //! \param theGroup a group name
41 virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
43 //! Set color of items
44 void setItemsColor(const QColor& theColor)
46 myItemsColor = theColor;
49 //! Returns color of items
50 QColor itemsColor() const
60 /**\class PartSet_PartModel
62 * \brief Abstaract class of model object which operates with parts data.
64 class PartSet_PartModel : public PartSet_FeaturesModel
68 /// \param theParent a parent object
69 PartSet_PartModel(QObject* theParent);
74 /// \param theId a new id
75 void setPart(FeaturePtr thePart)
80 /// Returns Id of the part
81 FeaturePtr part() const { return myPart; }
83 //! Returns true if the given document is a sub-document of this tree
84 //! \param theDoc a document to check
85 virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
87 /// Returns position of the part in history
90 DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
91 return aRootDoc->index(myPart);
95 //! Id of the current part object in the document