TDF_Label anEmptyLab;
FeaturePtr anEmptyFeature;
FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(theID);
+ boost::shared_ptr<Model_Document> aDocToAdd =
+ boost::dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd());
if (aFeature) {
TDF_Label aFeatureLab;
if (!aFeature->isAction()) {// do not add action to the data model
- TDF_Label aFeaturesLab = groupLabel(ModelAPI_Feature::group());
+ TDF_Label aFeaturesLab = aDocToAdd->groupLabel(ModelAPI_Feature::group());
aFeatureLab = aFeaturesLab.NewChild();
- initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS);
+ aDocToAdd->initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS);
// keep the feature ID to restore document later correctly
TDataStd_Comment::Set(aFeatureLab, aFeature->getKind().c_str());
- setUniqueName(aFeature);
- myObjs[ModelAPI_Feature::group()].push_back(aFeature);
+ aDocToAdd->setUniqueName(aFeature);
+ aDocToAdd->myObjs[ModelAPI_Feature::group()].push_back(aFeature);
// store feature in the history of features array
if (aFeature->isInHistory()) {
AddToRefArray(aFeaturesLab, aFeatureLab);
boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
aRes->setData(boost::shared_ptr<ModelAPI_Data>()); // deleted flag
ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
+ ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), aRes->groupName());
}
}
if (anObj->isInHistory()) {
ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName);
}
- ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName);
// results of this feature must be redisplayed (hided)
static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = boost::dynamic_pointer_cast<ModelAPI_Feature>(anObj)->results();
boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
aRes->setData(boost::shared_ptr<ModelAPI_Data>()); // deleted flag
ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
+ ModelAPI_EventCreator::get()->sendDeleted(aThis, aRes->groupName());
}
} else if (aDSTag < aFeatureTag) { // a new feature is inserted
// create a feature
if (aFeature) {
if (myModule->workshop()->displayer()->isVisible(aFeature->firstResult()) ||
aType == EVENT_OBJECT_CREATED) {
- myModule->visualizePreview(aFeature->firstResult(), true, false);
+ myModule->visualizePreview(aFeature, true, false);
//if (aType == EVENT_OBJECT_CREATED)
myModule->activateFeature(aFeature, true);
}
std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
aLast = aList.end();
for (; anIt != aLast; anIt++)
- visualizePreview((*anIt)->firstResult(), false, false);
+ visualizePreview((*anIt), false, false);
aDisplayer->updateViewer();
}
}
Events_Loop::loop()->send(aMessage);
}
-void PartSet_Module::visualizePreview(ResultPtr theFeature, bool isDisplay,
+void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
const bool isUpdateViewer)
{
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
if (!aPreviewOp)
return;
+ ResultPtr aResult = theFeature->firstResult();
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
if (isDisplay) {
boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
- if (aSPFeature)
- {
+ if (aSPFeature) {
boost::shared_ptr<GeomAPI_AISObject> anAIS =
- aSPFeature->getAISObject(aDisplayer->getAISObject(theFeature));
- aDisplayer->redisplay(theFeature, anAIS, false);
+ aSPFeature->getAISObject(aDisplayer->getAISObject(aResult));
+ aDisplayer->redisplay(aResult, anAIS, false);
}
}
else
- aDisplayer->erase(theFeature, false);
+ aDisplayer->erase(aResult, false);
if (isUpdateViewer)
aDisplayer->updateViewer();
boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
if (!aSPFeature)
continue;
- visualizePreview((*anIt)->firstResult(), true, false);
+ visualizePreview((*anIt), true, false);
aDisplayer->activateInLocalContext((*anIt)->firstResult(), aModes, false);
}
aDisplayer->updateViewer();
/// \param theFeature the feature instance to be displayed
/// \param isDisplay the state whether the presentation should be displayed or erased
/// \param isUpdateViewer the flag whether the viewer should be updated
- void visualizePreview(ResultPtr theResult, bool isDisplay,
+ void visualizePreview(FeaturePtr theFeature, bool isDisplay,
const bool isUpdateViewer = true);
/// Activates the feature in the displayer
}
-bool XGUI_Displayer::redisplay(ResultPtr theFeature,
+bool XGUI_Displayer::redisplay(ResultPtr theResult,
boost::shared_ptr<GeomAPI_AISObject> theAIS,
const bool isUpdateViewer)
{
//aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL);
}
// display or redisplay presentation
- boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theFeature];
- if (isVisible(theFeature) && anObj && !anObj->empty()) {
+ boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theResult];
+ if (isVisible(theResult) && anObj && !anObj->empty()) {
aContext->RecomputeSelectionOnly(anAIS);
}
else {
- myResult2AISObjectMap[theFeature] = theAIS;
+ myResult2AISObjectMap[theResult] = theAIS;
aContext->Display(anAIS, false);
isCreated = true;
}
}
if (aPartModel) {
QModelIndex aIndex = aPartModel->findParent(aObject);
- int aStart = aPartModel->rowCount(aIndex) - 1;
+ int aStart = aPartModel->rowCount(aIndex); // check this index
aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
insertRow(aStart, aIndex);
}
for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) {
std::string aGroup = (*aIt);
if (aDoc == aRootDoc) { // If root objects
- if (aGroup.compare(ModelAPI_ResultPart::group()) == 0) { // Updsate only Parts group
+ if (aGroup == ModelAPI_ResultPart::group()) { // Update only Parts group
int aStart = myPartModels.size() - 1;
removeSubModel(aStart);
removeRow(aStart, partFolderNode());
return aVal;
}
if (theParent.internalId() == PartsFolder) {
+ int aSize = myPartModels.size();
return myPartModels.size();
}
if (theParent.internalId() == HistoryNode) {
QList<ObjectPtr> aObjects = mySelector->selection()->selectedObjects();
if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) {
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObjects.first());
- if (aPart)
- activatePart(aPart);
+ activatePart(aPart);
} else if (theId == "DEACTIVATE_PART_CMD")
activatePart(ResultPartPtr());
else if (theId == "DELETE_CMD")