#include <ModelAPI_ResultPart.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultParameters.h>
+#include <ModelAPI_ResultBody.h>
#include <QIcon>
#include <QBrush>
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
if (aObject)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
+ return aObject->data()->name().c_str();
}
+ break;
case ConstructFolder:
return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
case ConstructObject:
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
if (aObject)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
+ return aObject->data()->name().c_str();
+ }
+ break;
+ case BodiesFolder:
+ return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
+ case BodiesObject:
+ {
+ DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
+ ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row());
+ if (aObject)
+ return aObject->data()->name().c_str();
}
}
break;
switch (theIndex.internalId()) {
case ParamsFolder:
return QIcon(":pictures/params_folder.png");
+ case BodiesFolder:
case ConstructFolder:
return QIcon(":pictures/constr_folder.png");
case ConstructObject:
+ case BodiesObject:
return QIcon(":pictures/constr_object.png");
- //{
- // DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
- // ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
- // if (aObject)
- // return QIcon(XGUI_Workshop::featureIcon(aObject->getKind()));
- //}
}
break;
int XGUI_TopDataModel::rowCount(const QModelIndex& theParent) const
{
if (!theParent.isValid())
- return 2;
+ return 3;
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
if (theParent.internalId() == ParamsFolder)
if (theParent.internalId() == ConstructFolder)
return aRootDoc->size(ModelAPI_ResultConstruction::group());
+
+ if (theParent.internalId() == BodiesFolder)
+ return aRootDoc->size(ModelAPI_ResultBody::group());
return 0;
}
return createIndex(theRow, theColumn, (qint32) ParamsFolder);
case 1:
return createIndex(theRow, theColumn, (qint32) ConstructFolder);
+ case 2:
+ return createIndex(theRow, theColumn, (qint32) BodiesFolder);
}
} else {
if (theParent.internalId() == ParamsFolder)
if (theParent.internalId() == ConstructFolder)
return createIndex(theRow, theColumn, (qint32) ConstructObject);
+
+ if (theParent.internalId() == BodiesFolder)
+ return createIndex(theRow, theColumn, (qint32) BodiesObject);
}
return QModelIndex();
}
switch (aId) {
case ParamsFolder:
case ConstructFolder:
+ case BodiesFolder:
return QModelIndex();
case ParamObject:
return createIndex(0, 0, (qint32) ParamsFolder);
case ConstructObject:
return createIndex(1, 0, (qint32) ConstructFolder);
+ case BodiesObject:
+ return createIndex(2, 0, (qint32) BodiesFolder);
}
return QModelIndex();
}
switch (theIndex.internalId()) {
case ParamsFolder:
case ConstructFolder:
+ case BodiesFolder:
return ObjectPtr();
case ParamObject:
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
return aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
}
+ case BodiesObject:
+ {
+ DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
+ return aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row());
+ }
}
return ObjectPtr();
}
QModelIndex XGUI_TopDataModel::findGroup(const std::string& theGroup) const
{
- if (theGroup.compare(ModelAPI_ResultParameters::group()) == 0)
+ if (theGroup == ModelAPI_ResultParameters::group())
return createIndex(0, 0, (qint32) ParamsFolder);
- if (theGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
+ if (theGroup == ModelAPI_ResultConstruction::group())
return createIndex(1, 0, (qint32) ConstructFolder);
+ if (theGroup == ModelAPI_ResultBody::group())
+ return createIndex(2, 0, (qint32) BodiesFolder);
return QModelIndex();
}
}
}
if (aRow != -1) {
- if (aGroup.compare(ModelAPI_ResultParameters::group()) == 0)
+ if (aGroup == ModelAPI_ResultParameters::group())
return createIndex(aRow, 0, (qint32) ParamObject);
- if (aGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
+ if (aGroup == ModelAPI_ResultConstruction::group())
return createIndex(aRow, 0, (qint32) ConstructObject);
+ if (aGroup == ModelAPI_ResultBody::group())
+ return createIndex(aRow, 0, (qint32) BodiesObject);
}
}
return aIndex;