Salome HOME
Issue #2811: Update content of Object node on creation moment
[modules/shaper.git] / src / Selector / Selector_Algo.cpp
index c64e012d502de91b3852003f7d73efc221a7cadb..9a387d1f0cd4533b63e6fbae4c3eb515912695df 100644 (file)
@@ -40,6 +40,8 @@
 #include <TDataStd_ReferenceArray.hxx>
 #include <TDataStd_ExtStringList.hxx>
 #include <TDataStd_Integer.hxx>
+#include <TDataStd_UAttribute.hxx>
+
 
 /// type of the selection, integer keeps the Selector_Type value
 static const Standard_GUID kSEL_TYPE("db174d59-c2e3-4a90-955e-55544df090d6");
@@ -120,8 +122,9 @@ Selector_Algo* Selector_Algo::select(const TopoDS_Shape theContext, const TopoDS
       if (aContainer->select(theContext, theValue))
         return aContainer;
       delete aContainer;
-      return false;
+      return NULL;
     }
+
     Selector_Intersect* anIntersect = new Selector_Intersect;
     SET_ALGO_FLAGS(anIntersect);
     bool aGoodIntersector = anIntersect->select(theContext, theValue);
@@ -131,7 +134,7 @@ Selector_Algo* Selector_Algo::select(const TopoDS_Shape theContext, const TopoDS
     }
     if (!theUseNeighbors) {
       delete anIntersect;
-      return false;
+      return NULL;
     }
     // searching by neighbors
     Selector_FilterByNeighbors* aNBs = new Selector_FilterByNeighbors;
@@ -200,7 +203,7 @@ Selector_Algo* Selector_Algo::select(const TopoDS_Shape theContext, const TopoDS
     }
     if (!theUseNeighbors) {
       delete aModify;
-      return false;
+      return NULL;
     }
     // searching by neighbors
     Selector_FilterByNeighbors* aNBs = new Selector_FilterByNeighbors;
@@ -324,10 +327,10 @@ TopoDS_Shape Selector_Algo::value()
   return TopoDS_Shape(); // empty, error shape
 }
 
-Selector_Algo* Selector_Algo::restoreByLab(TDF_Label theLab)
+Selector_Algo* Selector_Algo::restoreByLab(TDF_Label theLab, TDF_Label theBaseDocLab)
 {
   Handle(TDataStd_Integer) aTypeAttr;
-  if (!myLab.FindAttribute(kSEL_TYPE, aTypeAttr))
+  if (!theLab.FindAttribute(kSEL_TYPE, aTypeAttr))
     return NULL;
   Selector_Type aType = Selector_Type(aTypeAttr->Get());
   Selector_Algo* aResult = NULL;
@@ -360,12 +363,9 @@ Selector_Algo* Selector_Algo::restoreByLab(TDF_Label theLab)
   }
   }
   if (aResult) {
-    bool aGeomNaming = myLab.IsAttribute(kGEOMETRICAL_NAMING);
     aResult->myLab = theLab;
-    aResult->myBaseDocumentLab = myBaseDocumentLab;
-    aResult->myGeometricalNaming = aGeomNaming;
-    aResult->myUseNeighbors = myUseNeighbors;
-    aResult->myUseIntersections = myUseIntersections;
+    aResult->myBaseDocumentLab = theBaseDocLab;
+    aResult->myGeometricalNaming = theLab.IsAttribute(kGEOMETRICAL_NAMING);
     if (!aResult->restore()) {
       delete aResult;
       aResult = NULL;
@@ -396,7 +396,8 @@ Selector_Algo* Selector_Algo::restoreByName(TDF_Label theLab, TDF_Label theBaseD
     }
   } else if (theName[0] == '(') { // filter by neighbors
     aResult = new Selector_FilterByNeighbors;
-  } if (theName.find(pureWeakNameID()) == 0) { // weak naming identifier
+  } else if (theName.find(pureWeakNameID()) == 0) { // weak naming identifier
+    aResult = new Selector_WeakName;
   } else if (theName.find('&') != std::string::npos) { // modification
     aResult = new Selector_Modify;
   } else { // primitive
@@ -416,5 +417,8 @@ Selector_Algo* Selector_Algo::restoreByName(TDF_Label theLab, TDF_Label theBaseD
 
 void Selector_Algo::storeType(const Selector_Type theType)
 {
+  myLab.ForgetAllAttributes(true);
   TDataStd_Integer::Set(myLab, kSEL_TYPE, (int)(theType));
+  if (myGeometricalNaming)
+    TDataStd_UAttribute::Set(myLab, kGEOMETRICAL_NAMING);
 }