#include <QIcon>
#include <QBrush>
+
+FeaturePtr featureObj(const FeaturePtr& theFeature)
+{
+ ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
+ if (aObject)
+ return aObject->featureRef();
+ return theFeature;
+}
+
+
XGUI_TopDataModel::XGUI_TopDataModel(const DocumentPtr& theDocument, QObject* theParent)
: XGUI_FeaturesModel(theDocument, theParent)
{
return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
case ParamObject:
{
- FeaturePtr aFeature = myDocument->feature(PARAMETERS_GROUP, theIndex.row());
+ FeaturePtr aFeature = featureObj(myDocument->feature(PARAMETERS_GROUP, theIndex.row()));
if (aFeature)
return aFeature->data()->getName().c_str();
}
return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
case ConstructObject:
{
- FeaturePtr aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ FeaturePtr aFeature = featureObj(myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row()));
if (aFeature)
return aFeature->data()->getName().c_str();
}
return QIcon(":pictures/constr_folder.png");
case ConstructObject:
{
- FeaturePtr aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ FeaturePtr aFeature = featureObj(myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row()));
if (aFeature)
return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
}
case ConstructFolder:
return FeaturePtr();
case ParamObject:
- return myDocument->feature(PARAMETERS_GROUP, theIndex.row());
+ return featureObj(myDocument->feature(PARAMETERS_GROUP, theIndex.row()));
case ConstructObject:
- return myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ return featureObj(myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row()));
}
return FeaturePtr();
}
switch (theIndex.internalId()) {
case MyRoot:
{
- FeaturePtr aFeature = myDocument->feature(PARTS_GROUP, myId);
+ FeaturePtr aFeature = featureObj(myDocument->feature(PARTS_GROUP, myId));
if (aFeature)
return aFeature->data()->getName().c_str();
}
return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
case ParamObject:
{
- FeaturePtr aFeature = featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
+ FeaturePtr aFeature = featureObj(featureDocument()->feature(PARAMETERS_GROUP, theIndex.row()));
if (aFeature)
return aFeature->data()->getName().c_str();
}
case ConstructObject:
{
- FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ FeaturePtr aFeature = featureObj(featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row()));
if (aFeature)
return aFeature->data()->getName().c_str();
}
case HistoryObject:
{
- FeaturePtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
+ FeaturePtr aFeature = featureObj(featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3));
if (aFeature)
return aFeature->data()->getName().c_str();
}
return QIcon(":pictures/constr_folder.png");
case ConstructObject:
{
- FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ FeaturePtr aFeature = featureObj(featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row()));
if (aFeature)
return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
}
DocumentPtr XGUI_PartDataModel::featureDocument() const
{
- 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();
+ FeaturePtr aFeature = featureObj(myDocument->feature(PARTS_GROUP, myId));
return aFeature->data()->docRef("PartDocument")->value();
}
{
switch (theIndex.internalId()) {
case MyRoot:
- if (theIndex.row() < 3)
- return myDocument->feature(PARTS_GROUP, myId);
- else
+ if (theIndex.row() < 3) {
+ return featureObj(myDocument->feature(PARTS_GROUP, myId));
+ } else
return featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
case ParamsFolder:
case ConstructFolder:
return FeaturePtr();
case ParamObject:
- return featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
+ return featureObj(featureDocument()->feature(PARAMETERS_GROUP, theIndex.row()));
case ConstructObject:
- return featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ return featureObj(featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row()));
}
return FeaturePtr();
}
FeaturePtr XGUI_PartDataModel::part() const
{
- return myDocument->feature(PARTS_GROUP, myId);
+ return featureObj(myDocument->feature(PARTS_GROUP, myId));
}
\ No newline at end of file
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_Object.h>
#include <Events_Loop.h>
#include <Events_Error.h>
{
const Model_FeatureUpdatedMessage* anUpdateMsg =
dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
- boost::shared_ptr<ModelAPI_Feature> aNewFeature = anUpdateMsg->feature();
- boost::shared_ptr<ModelAPI_Feature> aCurrentFeature = myOperationMgr->currentOperation()->feature();
+ FeaturePtr aNewFeature = anUpdateMsg->feature();
+ FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
if(aNewFeature == aCurrentFeature) {
myPropertyPanel->updateContentWidget(aCurrentFeature);
}
void XGUI_Workshop::saveDocument(QString theName)
{
QApplication::restoreOverrideCursor();
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
aDoc->save(theName.toLatin1().constData());
QApplication::restoreOverrideCursor();
}
//******************************************************
void XGUI_Workshop::onExit()
{
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
if(aDoc->isModified()) {
int anAnswer = QMessageBox::question(
myMainWindow, tr("Save current file"),
void XGUI_Workshop::onOpen()
{
//save current file before close if modified
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
if(aDoc->isModified()) {
//TODO(sbh): re-launch the app?
int anAnswer = QMessageBox::question(
void XGUI_Workshop::onUndo()
{
objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
if (aDoc->isOperation())
operationMgr()->abortOperation();
aDoc->undo();
void XGUI_Workshop::onRedo()
{
objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
aDoc->redo();
updateCommandStatus();
}
QList<XGUI_Command*> aCommands = aMenuBar->features();
QList<XGUI_Command*>::const_iterator aIt;
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
if (aMgr->hasRootDocument()) {
XGUI_Command* aUndoCmd;
XGUI_Command* aRedoCmd;
else // Enable all commands
aCmd->enable();
}
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ DocumentPtr aDoc = aMgr->rootDocument();
aUndoCmd->setEnabled(aDoc->canUndo());
aRedoCmd->setEnabled(aDoc->canRedo());
} else {
//******************************************************
void XGUI_Workshop::changeCurrentDocument(FeaturePtr thePart)
{
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
if (thePart) {
boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = thePart->data()->docRef("PartDocument");
if (aDocRef)