static std::string group()
{static std::string MY_GROUP = "Features"; return MY_GROUP;}
+ /// Returns the group identifier of this result
+ virtual std::string groupName() { return group(); }
+
/// Request for initialization of data model of the feature: adding all attributes
virtual void initAttributes() = 0;
virtual boost::shared_ptr<ModelAPI_Document> document()
{return myDoc;}
+ /// Returns the group identifier of this object
+ virtual std::string groupName() = 0;
+
protected:
/// Sets the data manager of an object (document does)
virtual void setData(boost::shared_ptr<ModelAPI_Data> theData)
//virtual boost::shared_ptr<ModelAPI_Feature> owner() = 0;
/// Returns the group identifier of this result
- virtual std::string groupName() = 0;
+ //virtual std::string groupName() = 0;
};
//! Pointer on feature object
};
//! Pointer on feature object
-typedef boost::shared_ptr<ModelAPI_ResultPart> ResultPart;
+typedef boost::shared_ptr<ModelAPI_ResultPart> ResultPartPtr;
#endif
{
const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
- std::set<FeaturePtr > aFeatures = aUpdMsg->features();
- std::set<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+ std::set<ObjectPtr > aFeatures = aUpdMsg->features();
+ std::set<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
for (; anIt != aLast; anIt++) {
- FeaturePtr aFeature = *anIt;
- if (myModule->workshop()->displayer()->isVisible(aFeature) ||
- aType == EVENT_OBJECT_CREATED) {
- myModule->visualizePreview(aFeature, true, false);
- //if (aType == EVENT_OBJECT_CREATED)
- myModule->activateFeature(aFeature, true);
+ ObjectPtr aObject = *anIt;
+ ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+ if (aResult) {
+ if (myModule->workshop()->displayer()->isVisible(aResult) ||
+ aType == EVENT_OBJECT_CREATED) {
+ myModule->visualizePreview(aResult, true, false);
+ //if (aType == EVENT_OBJECT_CREATED)
+ myModule->activateFeature(aResult, true);
+ }
}
}
myModule->workshop()->displayer()->updateViewer();
}
if (aType == EVENT_OBJECT_DELETED)
{
- const ModelAPI_FeatureDeletedMessage* aDelMsg =
- dynamic_cast<const ModelAPI_FeatureDeletedMessage*>(theMessage);
+ const ModelAPI_ObjectDeletedMessage* aDelMsg =
+ dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
boost::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
std::set<std::string> aGroups = aDelMsg->groups();
FeaturePtr aFeature;
if (!theSelected.empty()) {
ModuleBase_ViewerPrs aPrs = theSelected.front();
- aFeature = aPrs.feature();
+ aFeature = aPrs.result();
}
else
aFeature = feature(); // for the widget distance only
if ((myPreSelection.size() > 0) && myActiveWidget) {
const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
ModuleBase_WidgetValueFeature aValue;
- aValue.setFeature(aPrs.feature());
+ aValue.setFeature(aPrs.result());
if (myActiveWidget->setValue(&aValue)) {
myPreSelection.remove(aPrs);
emit activateNextWidget(myActiveWidget);
const std::list<ModuleBase_ViewerPrs>& theSelected,
const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
- FeaturePtr aFeature;
+ ResultPtr aFeature;
if (!theHighlighted.empty())
- aFeature = theHighlighted.front().feature();
+ aFeature = theHighlighted.front().result();
if (!aFeature && !theSelected.empty()) // changed for a constrain
- aFeature = theSelected.front().feature();
+ aFeature = theSelected.front().result();
if (!aFeature || aFeature != feature())
{
if(aHasShift && !theHighlighted.empty()) {
QFeatureList aSelected;
aSelected.push_back(feature());
- aSelected.push_back(theHighlighted.front().feature());
+ aSelected.push_back(theHighlighted.front().result());
emit setSelection(aSelected);
}
else if (aFeature) {
ModuleBase_ViewerPrs aPrs;
for (; anIt != aLast; anIt++) {
aPrs = *anIt;
- if (!aPrs.feature())
+ if (!aPrs.result())
continue;
boost::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPrs.feature());
+ boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPrs.result());
if (!aSketchFeature)
continue;
double aDelta = aSketchFeature->distanceToPoint(
boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, anY)));
if (aMinDelta < 0 || aMinDelta > aDelta) {
aMinDelta = aDelta;
- aDeltaFeature = aPrs.feature();
+ aDeltaFeature = aPrs.result();
}
}
return aDeltaFeature;
//! Returns Feature object by the given Model index.
//! Returns 0 if the given index is not index of a feature
- virtual ObjectPtr feature(const QModelIndex& theIndex) const = 0;
+ virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
//! Returns QModelIndex which corresponds to the given feature
//! If the feature is not found then index is not valid
- virtual QModelIndex featureIndex(const ObjectPtr& theFeature) const = 0;
+ virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0;
//! Returns parent index of the given feature
- virtual QModelIndex findParent(const ObjectPtr& theFeature) const = 0;
+ virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
//! Returns index corresponded to the group
virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
//! Return a Part object
- virtual ObjectPtr part() const = 0;
+ virtual ResultPartPtr part() const = 0;
protected:
//! Id of the current part object in the document
#include <ModelAPI_Document.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
+#include <ModelAPI_ResultPart.h>
#include <Model_Events.h>
#include <ModelAPI_Object.h>
// Created object event *******************
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
- const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
- std::set<FeaturePtr> aFeatures = aUpdMsg->features();
+ const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+ std::set<ObjectPtr> aFeatures = aUpdMsg->features();
- std::set<FeaturePtr>::const_iterator aIt;
+ std::set<ObjectPtr>::const_iterator aIt;
for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
- FeaturePtr aFeature = (*aIt);
+ ObjectPtr aFeature = (*aIt);
DocumentPtr aDoc = aFeature->document();
if (aDoc == aRootDoc) { // If root objects
- if (aFeature->getGroup().compare(PARTS_GROUP) == 0) { // Update only Parts group
+ if (aFeature->groupName().compare(ModelAPI_ResultPart::group()) == 0) { // Update only Parts group
// Add a new part
int aStart = myPartModels.size();
XGUI_PartDataModel* aModel = new XGUI_PartDataModel(this);
}
// Deleted object event ***********************
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
- const Model_FeatureDeletedMessage* aUpdMsg = dynamic_cast<const Model_FeatureDeletedMessage*>(theMessage);
+ const Model_ObjectDeletedMessage* aUpdMsg = dynamic_cast<const Model_ObjectDeletedMessage*>(theMessage);
DocumentPtr aDoc = aUpdMsg->document();
std::set<std::string> aGroups = aUpdMsg->groups();
for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) {
std::string aGroup = (*aIt);
if (aDoc == aRootDoc) { // If root objects
- if (aGroup.compare(PARTS_GROUP) == 0) { // Updsate only Parts group
+ if (aGroup.compare(ModelAPI_ResultPart::group()) == 0) { // Updsate only Parts group
int aStart = myPartModels.size() - 1;
removeSubModel(aStart);
removeRow(aStart, partFolderNode());
}
// Deleted object event ***********************
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
- //const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
- //FeaturePtr aFeature = aUpdMsg->feature();
+ //const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+ //ObjectPtr aFeature = aUpdMsg->feature();
//DocumentPtr aDoc = aFeature->document();
// TODO: Identify the necessary index by the modified feature
beginResetModel();
clearModelIndexes();
- int aNbParts = aRootDoc->size(PARTS_GROUP);
+ int aNbParts = aRootDoc->size(ModelAPI_ResultPart::group());
if (myPartModels.size() != aNbParts) { // resize internal models
while (myPartModels.size() > aNbParts) {
delete myPartModels.last();
{
int aOffset = historyOffset();
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- FeaturePtr aFeature = aRootDoc->feature(FEATURES_GROUP, theIndex.row() - aOffset);
+ ObjectPtr aFeature = aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset);
if (!aFeature)
return QVariant();
switch (theRole) {
case Qt::DisplayRole:
if (aFeature)
- return aFeature->data()->getName().c_str();
+ return aFeature->data()->name().c_str();
else
return QVariant();
case Qt::DecorationRole:
// Size of external models
int aVal = historyOffset();
// Plus history size
- aVal += aRootDoc->size(FEATURES_GROUP);
+ aVal += aRootDoc->size(ModelAPI_Feature::group());
return aVal;
}
if (theParent.internalId() == PartsFolder) {
myIndexes.clear();
}
-FeaturePtr XGUI_DocumentDataModel::feature(const QModelIndex& theIndex) const
+ObjectPtr XGUI_DocumentDataModel::object(const QModelIndex& theIndex) const
{
if (theIndex.internalId() == PartsFolder)
- return FeaturePtr();
+ return ObjectPtr();
if (theIndex.internalId() == HistoryNode) {
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
int aOffset = historyOffset();
- return aRootDoc->feature(FEATURES_GROUP, theIndex.row() - aOffset);
+ return aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset);
}
QModelIndex* aIndex = toSourceModelIndex(theIndex);
if (!isSubModel(aIndex->model()))
- return FeaturePtr();
+ return ObjectPtr();
const XGUI_FeaturesModel* aModel = dynamic_cast<const XGUI_FeaturesModel*>(aIndex->model());
return aModel->feature(*aIndex);
return false;
}
-FeaturePtr XGUI_DocumentDataModel::activePart() const
+ObjectPtr XGUI_DocumentDataModel::activePart() const
{
if (myActivePart)
return myActivePart->part();
- return FeaturePtr();
+ return ObjectPtr();
}
void XGUI_DocumentDataModel::deactivatePart()
Qt::ItemFlags XGUI_DocumentDataModel::flags(const QModelIndex& theIndex) const
{
Qt::ItemFlags aFlags = QAbstractItemModel::flags(theIndex);
- if (feature(theIndex)) {
+ if (object(theIndex)) {
aFlags |= Qt::ItemIsEditable;
}
return aFlags;
}
-QModelIndex XGUI_DocumentDataModel::partIndex(const FeaturePtr& theFeature) const
+QModelIndex XGUI_DocumentDataModel::partIndex(const ObjectPtr& theObject) const
{
- FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature);
-
int aRow = -1;
XGUI_PartModel* aModel = 0;
foreach (XGUI_PartModel* aPartModel, myPartModels) {
aRow++;
- if (aPartModel->part() == aFeature) {
+ if (aPartModel->part() == theObject) {
aModel = aPartModel;
break;
}
return QModelIndex();
}
-QModelIndex XGUI_DocumentDataModel::featureIndex(const FeaturePtr theFeature) const
+QModelIndex XGUI_DocumentDataModel::featureIndex(const ObjectPtr theObject) const
{
// Check that this feature belongs to root document
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- DocumentPtr aDoc = theFeature->document();
+ DocumentPtr aDoc = theObject->document();
if (aDoc == aRootDoc) {
// This feature belongs to histrory or top model
- if (theFeature->isInHistory()) {
+ if (theObject->isInHistory()) {
int aId;
- for (aId = 0; aId < aRootDoc->size(FEATURES_GROUP); aId++) {
- if (theFeature == aRootDoc->feature(FEATURES_GROUP, aId))
+ for (aId = 0; aId < aRootDoc->size(ModelAPI_Feature::group()); aId++) {
+ if (theObject == aRootDoc->object(ModelAPI_Feature::group(), aId))
break;
}
return index(aId + historyOffset(), 0, QModelIndex());
} else {
- QModelIndex aIndex = myModel->featureIndex(theFeature);
+ QModelIndex aIndex = myModel->featureIndex(theObject);
return aIndex.isValid()?
createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)) :
QModelIndex();
}
}
if (aPartModel) {
- QModelIndex aIndex = aPartModel->featureIndex(theFeature);
+ QModelIndex aIndex = aPartModel->featureIndex(theObject);
return aIndex.isValid()?
createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)) :
QModelIndex();
//! Returns Feature object by the given Model index.
//! Returns 0 if the given index is not index of a feature
- FeaturePtr feature(const QModelIndex& theIndex) const;
+ ObjectPtr object(const QModelIndex& theIndex) const;
- QModelIndex featureIndex(const FeaturePtr theFeature) const;
+ QModelIndex featureIndex(const ObjectPtr theFeature) const;
//! Returns QModelIndex which corresponds to the given feature if this is a part
//! If the feature is not found then index is not valid
- QModelIndex partIndex(const FeaturePtr& theFeature) const;
+ QModelIndex partIndex(const ObjectPtr& theFeature) const;
//! Activates a part data model if the index is a Part node index.
//! Returns true if active part changed.
bool activatedIndex(const QModelIndex& theIndex);
//! Retrurns Feature which corresponds to active part
- FeaturePtr activePart() const;
+ ObjectPtr activePart() const;
//! Retrurns QModelIndex of active part
QModelIndex activePartIndex() const { return myActivePartIndex; }
#include <ModelAPI_Object.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultParameters.h>
#include <QIcon>
#include <QBrush>
case ParamObject:
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- ObjectPtr aFeature = aRootDoc->object(PARAMETERS_GROUP, theIndex.row());
- if (aFeature)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->data()->name().c_str();
+ ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
+ if (aObject)
+ return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
}
case ConstructFolder:
return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
case ConstructObject:
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- ObjectPtr aFeature = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
- if (aFeature)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->data()->name().c_str();
+ ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+ if (aObject)
+ return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
}
}
break;
case ConstructObject:
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- ObjectPtr aFeature = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
- if (aFeature)
- return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+ ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+ if (aObject)
+ return QIcon(XGUI_Workshop::featureIcon(aObject->getKind()));
}
}
break;
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
if (theParent.internalId() == ParamsFolder)
- return aRootDoc->size(PARAMETERS_GROUP);
+ return aRootDoc->size(ModelAPI_ResultParameters::group());
if (theParent.internalId() == ConstructFolder)
- return aRootDoc->size(CONSTRUCTIONS_GROUP);
+ return aRootDoc->size(ModelAPI_ResultConstruction::group());
return 0;
}
return rowCount(theParent) > 0;
}
-ObjectPtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const
+ObjectPtr XGUI_TopDataModel::object(const QModelIndex& theIndex) const
{
switch (theIndex.internalId()) {
case ParamsFolder:
case ParamObject:
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- return aRootDoc->feature(PARAMETERS_GROUP, theIndex.row());
+ return aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
}
case ConstructObject:
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- return aRootDoc->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ return aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
}
}
return ObjectPtr();
}
-QModelIndex XGUI_TopDataModel::findParent(const ObjectPtr& theFeature) const
+QModelIndex XGUI_TopDataModel::findParent(const ObjectPtr& theObject) const
{
- return findGroup(theFeature->getGroup().c_str());
+ return findGroup(theObject->groupName().c_str());
}
QModelIndex XGUI_TopDataModel::findGroup(const std::string& theGroup) const
{
- if (theGroup.compare(PARAMETERS_GROUP) == 0)
+ if (theGroup.compare(ModelAPI_ResultParameters::group()) == 0)
return createIndex(0, 0, (qint32) ParamsFolder);
- if (theGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+ if (theGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
return createIndex(1, 0, (qint32) ConstructFolder);
return QModelIndex();
}
-QModelIndex XGUI_TopDataModel::featureIndex(const ObjectPtr& theFeature) const
+QModelIndex XGUI_TopDataModel::objectIndex(const ObjectPtr& theObject) const
{
QModelIndex aIndex;
- if (theFeature) {
+ if (theObject) {
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- std::string aGroup = theFeature->getGroup();
+ std::string aGroup = theObject->groupName();
int aNb = aRootDoc->size(aGroup);
int aRow = -1;
for (int i = 0; i < aNb; i++) {
- if (aRootDoc->feature(aGroup, i) == theFeature) {
+ if (aRootDoc->object(aGroup, i) == theObject) {
aRow = i;
break;
}
}
if (aRow != -1) {
- if (aGroup.compare(PARAMETERS_GROUP) == 0)
+ if (aGroup.compare(ModelAPI_ResultParameters::group()) == 0)
return createIndex(aRow, 0, (qint32) ParamObject);
- if (aGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+ if (aGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
return createIndex(aRow, 0, (qint32) ConstructObject);
}
}
case MyRoot:
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- ObjectPtr aFeature = aRootDoc->feature(PARTS_GROUP, myId);
- if (aFeature)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+ ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
+ if (aObject)
+ return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->getName().c_str();
}
case ParamsFolder:
return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
case ParamObject:
{
- ObjectPtr aFeature = featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
- if (aFeature)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+ ObjectPtr aObject = partDocument()->object(ModelAPI_ResultParameters::group(), theIndex.row());
+ if (aObject)
+ return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
}
case ConstructObject:
{
- ObjectPtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
- if (aFeature)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+ ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+ if (aObject)
+ return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
}
case HistoryObject:
{
- ObjectPtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
- if (aFeature)
- return aFeature->data()->getName().c_str();
+ ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3);
+ if (aObject)
+ return aObject->data()->name().c_str();
}
}
break;
return QIcon(":pictures/constr_folder.png");
case ConstructObject:
{
- ObjectPtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
- if (aFeature)
- return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+ ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+ if (aObject)
+ return QIcon(XGUI_Workshop::featureIcon(aObject->getKind()));
}
case HistoryObject:
{
- ObjectPtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
- if (aFeature)
- return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+ ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3);
+ if (aObject)
+ return QIcon(XGUI_Workshop::featureIcon(aObject->getKind()));
}
}
break;
{
if (!parent.isValid()) {
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- if (aRootDoc->feature(PARTS_GROUP, myId))
+ if (aRootDoc->object(ModelAPI_ResultPart::group(), myId))
return 1;
else
return 0;
}
switch (parent.internalId()) {
case MyRoot:
- return 3 + featureDocument()->size(FEATURES_GROUP);
+ return 3 + partDocument()->size(ModelAPI_Feature::group());
case ParamsFolder:
- return featureDocument()->size(PARAMETERS_GROUP);
+ return partDocument()->size(ModelAPI_ResultParameters::group());
case ConstructFolder:
- return featureDocument()->size(CONSTRUCTIONS_GROUP);
+ return partDocument()->size(ModelAPI_ResultConstruction::group());
case BodiesFolder:
return 0;
}
}
-DocumentPtr XGUI_PartDataModel::featureDocument() const
+DocumentPtr XGUI_PartDataModel::partDocument() const
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- ObjectPtr aFeature = aRootDoc->feature(PARTS_GROUP, myId, true);
- return aFeature->data()->docRef("PartDocument")->value();
+ ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
+ return aObject->data()->docRef("PartDocument")->value();
}
-ObjectPtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const
+ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const
{
switch (theIndex.internalId()) {
case MyRoot:
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- return aRootDoc->feature(PARTS_GROUP, myId);
+ return aRootDoc->object(ModelAPI_ResultPart::group(), myId);
}
case ParamsFolder:
case ConstructFolder:
case BodiesFolder:
return ObjectPtr();
case ParamObject:
- return featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
+ return partDocument()->object(ModelAPI_ResultParameters::group(), theIndex.row());
case ConstructObject:
- return featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ return partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
//case BodiesObject:
- // return featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ // return partDocument()->feature(ModelAPI_ResultConstruction::group(), theIndex.row());
case HistoryObject:
- return featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
+ return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3);
}
return ObjectPtr();
}
bool XGUI_PartDataModel::hasDocument(const DocumentPtr& theDoc) const
{
- return (featureDocument() == theDoc);
+ return (partDocument() == theDoc);
}
-QModelIndex XGUI_PartDataModel::findParent(const ObjectPtr& theFeature) const
+QModelIndex XGUI_PartDataModel::findParent(const ObjectPtr& theObject) const
{
- return findGroup(theFeature->getGroup().c_str());
+ return findGroup(theObject->groupName().c_str());
}
QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
{
- if (theGroup.compare(PARAMETERS_GROUP) == 0)
+ if (theGroup.compare(ModelAPI_ResultParameters::group()) == 0)
return createIndex(0, 0, (qint32) ParamsFolder);
- if (theGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+ if (theGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
return createIndex(1, 0, (qint32) ConstructFolder);
return QModelIndex();
}
return aRootDoc->object(ModelAPI_ResultPart::group(), myId);
}
-QModelIndex XGUI_PartDataModel::featureIndex(const ObjectPtr& theObject) const
+QModelIndex XGUI_PartDataModel::objectIndex(const ObjectPtr& theObject) const
{
QModelIndex aIndex;
if (theObject) {
}
if (aRow != -1) {
return createIndex(aRow + 3, 0, (qint32) HistoryObject);
-/* if (aGroup.compare(PARAMETERS_GROUP) == 0)
+/* if (aGroup.compare(ModelAPI_ResultParameters::group()) == 0)
return createIndex(aRow, 0, (qint32) ParamObject);
- if (aGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+ if (aGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
return createIndex(aRow, 0, (qint32) ConstructObject);*/
}
}
virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
- //! Returns Feature object by the given Model index.
- //! Returns 0 if the given index is not index of a feature
- virtual ObjectPtr feature(const QModelIndex& theIndex) const;
+ //! Returns object by the given Model index.
+ //! Returns 0 if the given index is not index of a object
+ virtual ObjectPtr object(const QModelIndex& theIndex) const;
- //! Returns QModelIndex which corresponds to the given feature
- //! If the feature is not found then index is not valid
- virtual QModelIndex featureIndex(const ObjectPtr& theFeature) const;
+ //! Returns QModelIndex which corresponds to the given object
+ //! If the object is not found then index is not valid
+ virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
- //! Returns parent index of the given feature
- virtual QModelIndex findParent(const ObjectPtr& theFeature) const;
+ //! Returns parent index of the given object
+ virtual QModelIndex findParent(const ObjectPtr& theObject) const;
//! Returns index corresponded to the group
virtual QModelIndex findGroup(const std::string& theGroup) const;
virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
- //! Returns Feature object by the given Model index.
- //! Returns 0 if the given index is not index of a feature
- virtual ObjectPtr feature(const QModelIndex& theIndex) const;
+ //! Returns object by the given Model index.
+ //! Returns 0 if the given index is not index of a object
+ virtual ObjectPtr object(const QModelIndex& theIndex) const;
- //! Returns QModelIndex which corresponds to the given feature
- //! If the feature is not found then index is not valid
- virtual QModelIndex featureIndex(const ObjectPtr& theFeature) const;
+ //! Returns QModelIndex which corresponds to the given object
+ //! If the object is not found then index is not valid
+ virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
//! Returns true if the given document is a sub-document of this tree
virtual bool hasDocument(const DocumentPtr& theDoc) const;
- //! Returns parent index of the given feature
- virtual QModelIndex findParent(const ObjectPtr& theFeature) const;
+ //! Returns parent index of the given object
+ virtual QModelIndex findParent(const ObjectPtr& theObject) const;
//! Returns index corresponded to the group
virtual QModelIndex findGroup(const std::string& theGroup) const;
private:
//! Returns document of the current part
- DocumentPtr featureDocument() const;
+ DocumentPtr partDocument() const;
//! Types of QModelIndexes
enum DataIds {