#include <TDF_AttributeDelta.hxx>
#include <TDF_AttributeDeltaList.hxx>
#include <TDF_ListIteratorOfAttributeDeltaList.hxx>
+#include <TDF_ListIteratorOfLabelList.hxx>
#include <climits>
#ifndef WIN32
// in transaction for nesting correct working
myDoc->NewCommand();
TDataStd_Integer::Set(myDoc->Main().Father(), 0);
+ // this to avoid creation of integer attribute outside the transaction after undo
+ transactionID();
myDoc->CommitCommand();
}
// close all only if it is really asked, otherwise it can be undoed/redoed
if (theForever) {
+ // flush everything to avoid messages with bad objects
delete myObjs;
myObjs = 0;
if (myDoc->CanClose() == CDM_CCS_OK)
aDelta = theDoc->GetRedos().First();
else
aDelta = theDoc->GetUndos().Last();
- aDelta->Labels(theDelta);
+ TDF_LabelList aDeltaList;
+ aDelta->Labels(aDeltaList); // it clears list, so, use new one and then append to the result
+ for(TDF_ListIteratorOfLabelList aListIter(aDeltaList); aListIter.More(); aListIter.Next()) {
+ theDelta.Append(aListIter.Value());
+ }
// add also label of the modified attributes
const TDF_AttributeDeltaList& anAttrs = aDelta->AttributeDeltas();
for (TDF_ListIteratorOfAttributeDeltaList anAttr(anAttrs); anAttr.More(); anAttr.Next()) {
if (!myNestedNum.empty())
(*myNestedNum.rbegin())--;
// roll back the needed number of transactions
- myDoc->AbortCommand();
+ // make commit/undo to get the modification delta
+ //myDoc->AbortCommand();
+ if (myDoc->CommitCommand()) {
+ modifiedLabels(myDoc, aDeltaLabels);
+ myDoc->Undo();
+ }
for(int a = 0; a < aNumTransactions; a++) {
modifiedLabels(myDoc, aDeltaLabels);
myDoc->Undo();
subDoc(*aSubIter)->undoInternal(theWithSubs, theSynchronize);
}
}
- // after redo of all sub-documents to avoid updates on not-modified data (issue 370)
+ // after undo of all sub-documents to avoid updates on not-modified data (issue 370)
if (theSynchronize) {
myObjs->synchronizeFeatures(aDeltaLabels, true, isRoot());
// update the current features status
aDocToAdd = this;
}
if (aFeature) {
- aDocToAdd->myObjs->addFeature(aFeature, aDocToAdd->currentFeature(false));
+ // searching for feature after which must be added the next feature: this is the current feature
+ // but also all sub-features of this feature
+ FeaturePtr aCurrent = aDocToAdd->currentFeature(false);
+ bool isModified = true;
+ for(CompositeFeaturePtr aComp = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCurrent);
+ aComp.get() && isModified;
+ aComp = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCurrent)) {
+ isModified = false;
+ int aSubs = aComp->numberOfSubs(false);
+ for(int a = 0; a < aSubs; a++) {
+ FeaturePtr aSub = aComp->subFeature(a, false);
+ if (myObjs->isLater(aSub, aCurrent)) {
+ isModified = true;
+ aCurrent = aSub;
+ }
+ }
+ }
+ aDocToAdd->myObjs->addFeature(aFeature, aCurrent);
if (!aFeature->isAction()) { // do not add action to the data model
if (theMakeCurrent) // after all this feature stays in the document, so make it current
aDocToAdd->setCurrentFeature(aFeature, false);
void Model_Document::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis)
{
myObjs->moveFeature(theMoved, theAfterThis);
+ if (theAfterThis == currentFeature(true))
+ setCurrentFeature(theMoved, true);
}
void Model_Document::updateHistory(const std::shared_ptr<ModelAPI_Object> theObject)