#include "XGUI_Constants.h"
#include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
+
#include <QAbstractItemModel>
#include <QColor>
class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel
{
public:
- XGUI_FeaturesModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
+ XGUI_FeaturesModel(const DocumentPtr& theDocument, QObject* theParent):
QAbstractItemModel(theParent), myDocument(theDocument), myItemsColor(Qt::black) {}
//! Returns Feature object by the given Model index.
virtual FeaturePtr feature(const QModelIndex& theIndex) const = 0;
//! Returns parent index of the given feature
- virtual QModelIndex findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const = 0;
+ virtual QModelIndex findParent(const FeaturePtr& theFeature) const = 0;
//! Returns index corresponded to the group
virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
class XGUI_PartModel : public XGUI_FeaturesModel
{
public:
- XGUI_PartModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
+ XGUI_PartModel(const DocumentPtr& theDocument, QObject* theParent):
XGUI_FeaturesModel(theDocument, theParent) {}
void setPartId(int theId) { myId = theId; }
//! Returns true if the given document is a sub-document of this tree
- virtual bool hasDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) const = 0;
+ virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
//! Return a Part object
virtual FeaturePtr part() const = 0;
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_Object.h>
#include <QIcon>
#include <QBrush>
-XGUI_TopDataModel::XGUI_TopDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
+XGUI_TopDataModel::XGUI_TopDataModel(const DocumentPtr& theDocument, QObject* theParent)
: XGUI_FeaturesModel(theDocument, theParent)
{
}
return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
case ParamObject:
{
- boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARAMETERS_GROUP, theIndex.row());
+ FeaturePtr aFeature = myDocument->feature(PARAMETERS_GROUP, theIndex.row());
if (aFeature)
return aFeature->data()->getName().c_str();
}
return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
case ConstructObject:
{
- boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ FeaturePtr aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
if (aFeature)
return aFeature->data()->getName().c_str();
}
}
-QModelIndex XGUI_TopDataModel::findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const
+QModelIndex XGUI_TopDataModel::findParent(const FeaturePtr& theFeature) const
{
QString aGroup(theFeature->getGroup().c_str());
//******************************************************************
//******************************************************************
//******************************************************************
-XGUI_PartDataModel::XGUI_PartDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
+XGUI_PartDataModel::XGUI_PartDataModel(const DocumentPtr& theDocument, QObject* theParent)
: XGUI_PartModel(theDocument, theParent)
{
}
switch (theIndex.internalId()) {
case MyRoot:
{
- boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
+ FeaturePtr aFeature = myDocument->feature(PARTS_GROUP, myId);
if (aFeature)
return aFeature->data()->getName().c_str();
}
return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
case ParamObject:
{
- boost::shared_ptr<ModelAPI_Feature> aFeature =
- featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
+ FeaturePtr aFeature = featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
if (aFeature)
return aFeature->data()->getName().c_str();
}
case ConstructObject:
{
- boost::shared_ptr<ModelAPI_Feature> aFeature =
- featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
if (aFeature)
return aFeature->data()->getName().c_str();
}
case HistoryObject:
{
- boost::shared_ptr<ModelAPI_Feature> aFeature =
- featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
+ FeaturePtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
if (aFeature)
return aFeature->data()->getName().c_str();
}
}
case HistoryObject:
{
- boost::shared_ptr<ModelAPI_Feature> aFeature =
- featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
+ FeaturePtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
if (aFeature)
return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
}
}
-boost::shared_ptr<ModelAPI_Document> XGUI_PartDataModel::featureDocument() const
+DocumentPtr XGUI_PartDataModel::featureDocument() const
{
- boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
+ FeaturePtr aFeature = myDocument->feature(PARTS_GROUP, myId);
+ ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
+ if (aObject)
+ return aObject->featureRef()->data()->docRef("PartDocument")->value();
return aFeature->data()->docRef("PartDocument")->value();
}
-
+
FeaturePtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const
{
switch (theIndex.internalId()) {
return FeaturePtr();
}
-bool XGUI_PartDataModel::hasDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) const
+bool XGUI_PartDataModel::hasDocument(const DocumentPtr& theDoc) const
{
return (featureDocument() == theDoc);
}
-QModelIndex XGUI_PartDataModel::findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const
+QModelIndex XGUI_PartDataModel::findParent(const FeaturePtr& theFeature) const
{
QString aGroup(theFeature->getGroup().c_str());
{
Q_OBJECT
public:
- XGUI_TopDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
+ XGUI_TopDataModel(const DocumentPtr& theDocument, QObject* theParent);
virtual ~XGUI_TopDataModel();
// Reimpl from QAbstractItemModel
virtual FeaturePtr feature(const QModelIndex& theIndex) const;
//! Returns parent index of the given feature
- virtual QModelIndex findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const;
+ virtual QModelIndex findParent(const FeaturePtr& theFeature) const;
//! Returns index corresponded to the group
virtual QModelIndex findGroup(const std::string& theGroup) const;
{
Q_OBJECT
public:
- XGUI_PartDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
+ XGUI_PartDataModel(const DocumentPtr& theDocument, QObject* theParent);
virtual ~XGUI_PartDataModel();
// Reimpl from QAbstractItemModel
virtual FeaturePtr feature(const QModelIndex& theIndex) const;
//! Returns true if the given document is a sub-document of this tree
- virtual bool hasDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) const;
+ virtual bool hasDocument(const DocumentPtr& theDoc) const;
//! Returns parent index of the given feature
- virtual QModelIndex findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const;
+ virtual QModelIndex findParent(const FeaturePtr& theFeature) const;
//! Returns index corresponded to the group
virtual QModelIndex findGroup(const std::string& theGroup) const;
virtual FeaturePtr part() const;
private:
- boost::shared_ptr<ModelAPI_Document> featureDocument() const;
+ DocumentPtr featureDocument() const;
//! Types of QModelIndexes
enum DataIds {