X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Document.cpp;h=7acdecde220b777596bc253df61c14321945cff3;hb=88be48ed1ea478b9d9d6ac2d965092418ef4dae6;hp=caba9de1337b13ec201b8b6032512169212f07d7;hpb=5a82acff74697623112b76b67c0200945a3e9976;p=modules%2Fshaper.git diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index caba9de13..7acdecde2 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,14 +85,15 @@ 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 static const int TAG_EXTERNAL_CONSTRUCTIONS = 5; Model_Document::Model_Document(const int theID, const std::string theKind) - : myID(theID), myKind(theKind), myIsActive(false), + : myID(theID), myKind(theKind), myIsActive(false), myIsSetCurrentFeature(false), myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format { #ifdef TINSPECTOR @@ -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 @@ -1084,6 +1086,9 @@ std::shared_ptr Model_Document::currentFeature(const bool theV void Model_Document::setCurrentFeature( std::shared_ptr theCurrent, const bool theVisible) { + if (myIsSetCurrentFeature) + return; + myIsSetCurrentFeature = true; // blocks the flush signals to avoid each objects visualization in the viewer // they should not be shown once after all modifications are performed Events_Loop* aLoop = Events_Loop::loop(); @@ -1120,6 +1125,7 @@ void Model_Document::setCurrentFeature( std::shared_ptr aData = std::static_pointer_cast(theCurrent->data()); if (!aData.get() || !aData->isValid()) { aLoop->activateFlushes(isActive); + myIsSetCurrentFeature = false; return; } TDF_Label aFeatureLabel = aData->label().Father(); @@ -1192,6 +1198,7 @@ void Model_Document::setCurrentFeature( } } } + myIsSetCurrentFeature = false; // unblock the flush signals and up them after this aLoop->activateFlushes(isActive); } @@ -1898,3 +1905,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); +}