}
}
}
+
+void Model_Document::eraseAllFeatures()
+{
+ if (myObjs)
+ myObjs->eraseAllFeatures();
+}
/// Returns true if theLater is in history of features creation later than theCurrent
MODEL_EXPORT virtual bool isLater(FeaturePtr theLater, FeaturePtr theCurrent) const;
+ /// Just removes all features without touching the document data (to be able undo)
+ MODEL_EXPORT virtual void eraseAllFeatures();
+
+
protected:
//! Returns (creates if needed) the general label
TDF_Label generalLabel() const;
}
}
+void Model_Objects::eraseAllFeatures()
+{
+ ModelAPI_EventCreator::get()->sendDeleted(myDoc, ModelAPI_Feature::group());
+ myFeatures.Clear(); // just remove features without modification of DS
+ updateHistory(ModelAPI_Feature::group());
+}
+
void Model_Objects::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis)
{
TDF_Label aFeaturesLab = featuresLabel();
aFeature = myFeatures.Find(aFeatureLabel);
aKeptFeatures.insert(aFeature);
if (anUpdatedMap.Contains(aFeatureLabel)) {
- if (!theOpen) { // on abort/undo/redo reinitialize attributes is something is changed
+ if (!theOpen) { // on abort/undo/redo reinitialize attributes if something is changed
std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs =
aFeature->data()->attributes("");
std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
theProcessed.insert(theFeature);
// for composites update subs recursively (sketch elements results are needed for the sketch)
CompositeFeaturePtr aComp = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
- if (aComp.get()) {
+ if (aComp.get() && aComp->getKind() != "Part") { // don't go inside of parts sub-features
// update subs of composites first
int aSubNum = aComp->numberOfSubs();
for(int a = 0; a < aSubNum; a++) {
void synchronizeBackRefsForObject(
const std::set<std::shared_ptr<ModelAPI_Attribute>>& theNewRefs, ObjectPtr theObject);
+ /// Just removes all features without touching the document data (to be able undo)
+ virtual void eraseAllFeatures();
+
private:
TDF_Label myMain; ///< main label of the data storage
/// Appends the values to theStates list.
MODELAPI_EXPORT virtual void restoreNodesState(std::list<bool>& theStates) const = 0;
+ /// Just removes all features without touching the document data (to be able undo)
+ MODELAPI_EXPORT virtual void eraseAllFeatures() = 0;
+
protected:
//! Only for SWIG wrapping it is here
MODELAPI_EXPORT ModelAPI_Document();
void PartSetPlugin_Part::removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature)
{
}
+
+void PartSetPlugin_Part::erase() {
+ ResultPartPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultPart>(firstResult());
+ if (aResult.get()) {
+ DocumentPtr aDoc = aResult->partDoc();
+ aDoc->eraseAllFeatures();
+ }
+ ModelAPI_Feature::erase();
+}
/// Use plugin manager for features creation
PartSetPlugin_Part();
+
+ /// Just removes all features of the part without touching the document data (to be able undo)
+ PARTSETPLUGIN_EXPORT virtual void erase();
};
#endif