2 #ifndef XGUI_DataTreeModel_H
3 #define XGUI_DataTreeModel_H
6 #include "XGUI_Constants.h"
8 #include <ModelAPI_Document.h>
9 #include <QAbstractItemModel>
12 /**\class XGUI_FeaturesModel
14 * \brief Abstaract class of model object which operates with features data.
16 class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel
19 XGUI_FeaturesModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
20 QAbstractItemModel(theParent), myDocument(theDocument), myItemsColor(Qt::black) {}
22 //! Returns Feature object by the given Model index.
23 //! Returns 0 if the given index is not index of a feature
24 virtual FeaturePtr feature(const QModelIndex& theIndex) const = 0;
26 //! Returns parent index of the given feature
27 virtual QModelIndex findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const = 0;
29 //! Returns index corresponded to the group
30 virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
32 void setItemsColor(const QColor& theColor) { myItemsColor = theColor; }
34 QColor itemsColor() const { return myItemsColor; }
37 boost::shared_ptr<ModelAPI_Document> myDocument;
42 /**\class XGUI_PartModel
44 * \brief Abstaract class of model object which operates with parts data.
46 class XGUI_PartModel : public XGUI_FeaturesModel
49 XGUI_PartModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
50 XGUI_FeaturesModel(theDocument, theParent) {}
52 void setPartId(int theId) { myId = theId; }
54 //! Returns true if the given document is a sub-document of this tree
55 virtual bool hasDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) const = 0;
57 //! Return a Part object
58 virtual FeaturePtr part() const = 0;
61 //! Id of the current part object in the document