- case Qt::DisplayRole:
- // return a name
- switch (theIndex.internalId()) {
- case MyRoot:
- {
- DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- FeaturePtr aFeature = aRootDoc->feature(PARTS_GROUP, myId);
- if (aFeature)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
- }
- case ParamsFolder:
- return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
- case ConstructFolder:
- return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
- case BodiesFolder:
- return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
- case ParamObject:
- {
- FeaturePtr aFeature = featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
- if (aFeature)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
- }
- case ConstructObject:
- {
- FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
- if (aFeature)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
- }
- case HistoryObject:
- {
- FeaturePtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
- if (aFeature)
- return aFeature->data()->getName().c_str();
- }
- }
- break;
- case Qt::DecorationRole:
- // return an Icon
- switch (theIndex.internalId()) {
- case MyRoot:
- return QIcon(":pictures/part_ico.png");
- case ParamsFolder:
- return QIcon(":pictures/params_folder.png");
- case ConstructFolder:
- case BodiesFolder:
- return QIcon(":pictures/constr_folder.png");
- case ConstructObject:
- {
- FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
- if (aFeature)
- return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+ case Qt::DisplayRole:
+ // return a name
+ switch (theIndex.internalId()) {
+ case MyRoot: {
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
+ ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
+ if (aObject)
+ return std::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
+ }
+ case ParamsFolder:
+ return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
+ case ConstructFolder:
+ return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
+ case BodiesFolder:
+ return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
+ case GroupsFolder:
+ return tr("Groups") + QString(" (%1)").arg(rowCount(theIndex));
+ case ParamObject: {
+ ObjectPtr aObject = partDocument()->object(ModelAPI_ResultParameter::group(),
+ theIndex.row());
+ if (aObject) {
+ ResultParameterPtr aParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aObject);
+ AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE());
+ QString aVal = QString::number(aValueAttribute->value());
+ QString aTitle = QString(aObject->data()->name().c_str());
+ return aTitle + " = " + aVal;
+ }
+ }
+ break;
+ case ConstructObject: {
+ ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(),
+ theIndex.row());
+ if (aObject)
+ return std::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
+ }
+ break;
+ case BodiesObject: {
+ ObjectPtr aObject = partDocument()->object(ModelAPI_ResultBody::group(), theIndex.row());
+ if (aObject)
+ return aObject->data()->name().c_str();
+ }
+ break;
+ case GroupObject: {
+ ObjectPtr aObject = partDocument()->object(ModelAPI_ResultGroup::group(), theIndex.row());
+ if (aObject)
+ return aObject->data()->name().c_str();
+ }
+ case HistoryObject: {
+ ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber());
+ if (aObject)
+ return aObject->data()->name().c_str();
+ }