X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Document.cpp;h=4d4207648740649aec6d7da1fdad57830da3701d;hb=b0196aeefbaa53754b1052fab904386707caad87;hp=22cc823d05e7e8c495e8a12198b3791ceee7900f;hpb=ce9a1d1c5d51c711390aa88bf348240337a93b74;p=modules%2Fshaper.git diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 22cc823d0..4d4207648 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -84,7 +85,8 @@ static const int TAG_GENERAL = 1; // general properties tag // general sub-labels /// where the reference to the current feature label is located (or no attribute if null feature) static const int TAG_CURRENT_FEATURE = 1; ///< reference to the current feature -static const int TAG_CURRENT_TRANSACTION = 2; ///< integer, index of the transaction +/// integer, index of the transaction + GUID for auto recomutation blocking +static const int TAG_CURRENT_TRANSACTION = 2; static const int TAG_SELECTION_FEATURE = 3; ///< integer, tag of the selection feature label static const int TAG_NODES_STATE = 4; ///< array, tag of the Object Browser nodes states ///< naming structures constructions selected from other document @@ -272,7 +274,7 @@ bool Model_Document::save( Handle(Model_Application) anApp = Model_Application::getApplication(); if (isRoot()) { #ifdef WIN32 - CreateDirectory(theDirName, NULL); + CreateDirectory((LPTSTR) theDirName, NULL); #else mkdir(theDirName, 0x1ff); #endif @@ -998,12 +1000,14 @@ void Model_Document::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis) void Model_Document::updateHistory(const std::shared_ptr theObject) { - myObjs->updateHistory(theObject); + if (myObjs) + myObjs->updateHistory(theObject); } void Model_Document::updateHistory(const std::string theGroup) { - myObjs->updateHistory(theGroup); + if (myObjs) + myObjs->updateHistory(theGroup); } const std::set Model_Document::subDocuments() const @@ -1332,7 +1336,6 @@ Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2) return TDF_LabelMapHasher::IsEqual(theLab1, theLab2); } -// searches in this document feature that contains this label FeaturePtr Model_Document::featureByLab(const TDF_Label& theLab) { TDF_Label aCurrentLab = theLab; while(aCurrentLab.Depth() > 3) @@ -1340,6 +1343,20 @@ FeaturePtr Model_Document::featureByLab(const TDF_Label& theLab) { return myObjs->feature(aCurrentLab); } +ResultPtr Model_Document::resultByLab(const TDF_Label& theLab) +{ + TDF_Label aCurrentLab = theLab; + while(aCurrentLab.Depth() > 3) { + ObjectPtr aResultObj = myObjs->object(aCurrentLab); + if (aResultObj.get()) { + return std::dynamic_pointer_cast(aResultObj); // this may be null if feature + } + aCurrentLab = aCurrentLab.Father(); + } + return ResultPtr(); // not found +} + + void Model_Document::addNamingName(const TDF_Label theLabel, std::string theName) { std::map >::iterator aFind = myNamingNames.find(theName); @@ -1478,8 +1495,13 @@ bool Model_Document::isLaterByDep(FeaturePtr theThis, FeaturePtr theOther) { if (!aRefFeat.get()) { // take feature of the result aRefFeat = feature(std::dynamic_pointer_cast(aRefObj)); } - if (aRefFeat.get() && aRefFeat == theThis) { - return false; // other references to this, so this later than other + if (aRefFeat.get()) { + if (aRefFeat == theThis) + return false; // other references to this, so other later than this + if (std::dynamic_pointer_cast(aRefFeat)) { + if (!isLaterByDep(theThis, aRefFeat)) // nested composites: recursion + return false; + } } } } @@ -1534,7 +1556,7 @@ ResultPtr Model_Document::findByName( std::string aName = theName; ResultPtr aRes = myObjs->findByName(aName); theUniqueContext = !(aRes.get() && myNamingNames.find(aName) != myNamingNames.end()); - while(!aRes.get() && aName[0] == '_') { // this may be thecontext with the history index + while(!aRes.get() && aName[0] == '_') { // this may be theContext with the history index aNumInHistory++; aName = aName.substr(1); aRes = myObjs->findByName(aName); @@ -1903,3 +1925,34 @@ void Model_Document::setExecuteFeatures(const bool theFlag) subDoc(*aSubIter)->setExecuteFeatures(theFlag); } } + +void Model_Document::appendTransactionToPrevious() +{ + Transaction anAppended = myTransactions.back(); + myTransactions.pop_back(); + if (!myTransactions.empty()) { // if it is empty, just forget the appended + myTransactions.back().myOCAFNum += anAppended.myOCAFNum; + } + // propagate the same action to sub-documents + const std::set aSubs = subDocuments(); + for (std::set::iterator aSubIter = aSubs.begin(); aSubIter != aSubs.end(); aSubIter++) { + subDoc(*aSubIter)->appendTransactionToPrevious(); + } +} + +/// GUID for keeping information about the auto-recomputation state +static const Standard_GUID kAutoRecomputationID("8493fb74-0674-4912-a100-1cf46c7cfab3"); + +void Model_Document::setAutoRecomutationState(const bool theState) +{ + if (theState) + generalLabel().FindChild(TAG_CURRENT_TRANSACTION).ForgetAttribute(kAutoRecomputationID); + else + TDataStd_UAttribute::Set( + generalLabel().FindChild(TAG_CURRENT_TRANSACTION), kAutoRecomputationID); +} + +bool Model_Document::autoRecomutationState() const +{ + return !generalLabel().FindChild(TAG_CURRENT_TRANSACTION).IsAttribute(kAutoRecomputationID); +}