Salome HOME
#2027 Sketcher Trim feature - highlight should be cleared when the mouse is moved...
[modules/shaper.git] / src / Model / Model_Document.cpp
index de77a7472c3908901d0b0031a0c10bbf9610cf9a..89c596d6d2026e2df305d0709adba247570732d2 100755 (executable)
@@ -37,6 +37,8 @@
 #include <TDF_ListIteratorOfAttributeDeltaList.hxx>
 #include <TDF_ListIteratorOfLabelList.hxx>
 #include <TDF_LabelMap.hxx>
+#include <TDF_DeltaOnAddition.hxx>
+#include <TNaming_Builder.hxx>
 #include <TNaming_SameShapeIterator.hxx>
 #include <TNaming_Iterator.hxx>
 #include <TNaming_NamedShape.hxx>
@@ -76,7 +78,7 @@ Model_Document::Model_Document(const int theID, const std::string theKind)
     : myID(theID), myKind(theKind), myIsActive(false),
       myDoc(new TDocStd_Document("BinOcaf"))  // binary OCAF format
 {
-#ifdef DFBROWSER
+#ifdef TINSPECTOR
   CDF_Session::CurrentSession()->Directory()->Add(myDoc);
 #endif
   myObjs = new Model_Objects(myDoc->Main());
@@ -195,6 +197,7 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum
   if (!isError) {
     myDoc = aLoaded;
     myDoc->SetUndoLimit(UNDO_LIMIT);
+
     // to avoid the problem that feature is created in the current, not this, document
     aSession->setActiveDocument(anApp->document(myID), false);
     aSession->setCheckTransactions(false);
@@ -404,7 +407,8 @@ static bool isEqualContent(Handle(TDF_Attribute) theAttr1, Handle(TDF_Attribute)
     if (anArr1->Lower() == anArr2->Lower() && anArr1->Upper() == anArr2->Upper()) {
       for(int a = anArr1->Lower(); a <= anArr1->Upper(); a++) {
         if (a == 1 && // second is for display
-          anArr2->Label().Tag() == 1 && (anArr2->Label().Depth() == 4 || anArr2->Label().Depth() == 6))
+            anArr2->Label().Tag() == 1 && (anArr2->Label().Depth() == 4 ||
+            anArr2->Label().Depth() == 6))
           continue;
         if (anArr1->Value(a) != anArr2->Value(a))
           return false;
@@ -678,7 +682,7 @@ void Model_Document::abortOperation()
   for (; aSubIter != aSubs.end(); aSubIter++)
     subDoc(*aSubIter)->abortOperation();
   // references may be changed because they are set in attributes on the fly
-  myObjs->synchronizeFeatures(aDeltaLabels, true, false, isRoot());
+  myObjs->synchronizeFeatures(aDeltaLabels, true, false, false, isRoot());
 }
 
 bool Model_Document::isOperation() const
@@ -745,7 +749,7 @@ void Model_Document::undoInternal(const bool theWithSubs, const bool theSynchron
   }
   // after undo of all sub-documents to avoid updates on not-modified data (issue 370)
   if (theSynchronize) {
-    myObjs->synchronizeFeatures(aDeltaLabels, true, false, isRoot());
+    myObjs->synchronizeFeatures(aDeltaLabels, true, false, false, isRoot());
     // update the current features status
     setCurrentFeature(currentFeature(false), false);
   }
@@ -792,7 +796,7 @@ void Model_Document::redo()
     subDoc(*aSubIter)->redo();
 
   // after redo of all sub-documents to avoid updates on not-modified data (issue 370)
-  myObjs->synchronizeFeatures(aDeltaLabels, true, false, isRoot());
+  myObjs->synchronizeFeatures(aDeltaLabels, true, false, false, isRoot());
   // update the current features status
   setCurrentFeature(currentFeature(false), false);
 }
@@ -1237,6 +1241,20 @@ TDF_Label Model_Document::findNamingName(std::string theName)
         if (aName->Get() == aSubName)
           return aName->Label();
       }
+      // If not found child label with the exact sub-name, then try to find compound with
+      // such sub-name without suffix.
+      Standard_Integer aSuffixPos = aSubName.SearchFromEnd('_');
+      if (aSuffixPos != -1) {
+        TCollection_ExtendedString anIndexStr = aSubName.Split(aSuffixPos);
+        aSubName.Remove(aSuffixPos);
+        aNamesIter.Initialize(aFind->second, TDataStd_Name::GetID(), Standard_True);
+        for(; aNamesIter.More(); aNamesIter.Next()) {
+          Handle(TDataStd_Name) aName = Handle(TDataStd_Name)::DownCast(aNamesIter.Value());
+          if (aName->Get() == aSubName) {
+            return aName->Label();
+          }
+        }
+      }
     }
   }
   return TDF_Label(); // not found