Displayer method to remove deleted features from the displayer map.
onUndo() - perform abortOperation if the document method isOperation() returns true.
std::string aGroup = aDelMsg->group();
if (aDelMsg->group().compare("Sketch") == 0) { // Update only Sketch group
+ //myModule->workshop()->displayer()->EraseDeletedFeatures();
myModule->updateCurrentPreview(aGroup);
}
}
SketchPlugin_Line::SketchPlugin_Line()
: SketchPlugin_Feature()
{
- setSketch(0);
}
void SketchPlugin_Line::initAttributes()
ic->UpdateCurrentViewer();
}
+void XGUI_Displayer::EraseDeletedFeatures(const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+
+ FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
+ aFLast = myFeature2AISObjectMap.end();
+ std::list<boost::shared_ptr<ModelAPI_Feature>> aRemoved;
+ for (; aFIt != aFLast; aFIt++)
+ {
+ boost::shared_ptr<ModelAPI_Feature> aFeature = (*aFIt).first;
+ if (!aFeature) {
+ Handle(AIS_InteractiveObject) anAIS = (*aFIt).second;
+ if (!anAIS.IsNull()) {
+ aContext->Erase(anAIS, false);
+ aRemoved.push_back(aFeature);
+ }
+ }
+ }
+ std::list<boost::shared_ptr<ModelAPI_Feature>>::const_iterator anIt = aRemoved.begin(),
+ aLast = aRemoved.end();
+ for (; anIt != aLast; anIt++) {
+ myFeature2AISObjectMap.erase(myFeature2AISObjectMap.find(*anIt));
+ }
+
+ if (isUpdateViewer)
+ aContext->UpdateCurrentViewer();
+}
+
void XGUI_Displayer::CloseLocalContexts(const bool isUpdateViewer)
{
closeAllContexts(true);
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
void EraseAll(const bool isUpdateViewer = true);
+ /// Erase AIS interactive objects, which has an empty feature in the internal map
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void EraseDeletedFeatures(const bool isUpdateViewer = true);
+
/// Deactivates selection of sub-shapes
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
void CloseLocalContexts(const bool isUpdateViewer = true);
objectBrowser()->setCurrentIndex(QModelIndex());
boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
- //if (!operationMgr()->abortOperation())
- // return;
- operationMgr()->abortOperation();
+ if (aDoc->isOperation())
+ operationMgr()->abortOperation();
aDoc->undo();
updateCommandStatus();
}