]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Debug of the sketch faces selection in external document
authormpv <mpv@opencascade.com>
Fri, 19 Oct 2018 16:42:39 +0000 (19:42 +0300)
committermpv <mpv@opencascade.com>
Fri, 19 Oct 2018 16:42:39 +0000 (19:42 +0300)
src/Model/Model_ResultConstruction.cpp
src/Selector/Selector_Selector.cpp

index 3e33cef2e829230440ba56e4d02d6a3686776a39..eb18991841f72ff35f86bad93258b5212c9ed6f5 100644 (file)
@@ -65,8 +65,10 @@ void Model_ResultConstruction::setShape(std::shared_ptr<GeomAPI_Shape> theShape)
   if (myShape != theShape) {
     if (!isInfinite())
       storeShape(theShape);
-    static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
-    ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
+    if (!theShape.get() || !theShape->isEqual(myShape)) {
+      static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+      ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
+    }
     myShape = theShape;
   }
 }
index c514b8c1231ddce80f1db92af663a7125e9763c8..8036f9d1d7eb5e09068b12d4ef9c5ebb146b3fed 100644 (file)
@@ -446,7 +446,22 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape
       }
     }
     myType = SELTYPE_MODIFICATION;
-    return !myBases.IsEmpty();
+    if (myBases.IsEmpty()) { // selection based on the external shape, weak name by finals compound
+      TopoDS_ListOfShape aCommon;
+      myFinal = aModifList.First()->Label();
+      Handle(TNaming_NamedShape) aNS;
+      myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS);
+      for(TNaming_Iterator aFinalIter(aNS); aFinalIter.More(); aFinalIter.Next()) {
+        const TopoDS_Shape& aNewShape = aFinalIter.NewShape();
+        if (!aNewShape.IsNull())
+          aCommon.Append(aNewShape);
+      }
+      Selector_NExplode aNexp(aCommon);
+      myWeakIndex = aNexp.index(theValue);
+      if (myWeakIndex == -1)
+        return false;
+    }
+    return true;
   }
 
   // not found a good result
@@ -684,16 +699,29 @@ bool Selector_Selector::solve(const TopoDS_Shape& theContext)
     if (myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
       aResult = aNS->Get();
     }
+    break;
   }
   case SELTYPE_MODIFICATION: {
-    TopoDS_ListOfShape aFinalsCommon; // final shapes presented in all results from bases
-    findModificationResult(aFinalsCommon);
-    if (aFinalsCommon.Extent() == 1) // only in this case result is valid: found only one shape
-      aResult = aFinalsCommon.First();
-    else if (aFinalsCommon.Extent() > 1 && myWeakIndex) {
-      Selector_NExplode aNExp(aFinalsCommon);
-      aResult = aNExp.shape(myWeakIndex);
-
+    if (myBases.IsEmpty() && myWeakIndex) { // weak name by the final shapes index
+      TopoDS_ListOfShape aCommon;
+      Handle(TNaming_NamedShape) aNS;
+      myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS);
+      for(TNaming_Iterator aFinalIter(aNS); aFinalIter.More(); aFinalIter.Next()) {
+        const TopoDS_Shape& aNewShape = aFinalIter.NewShape();
+        if (!aNewShape.IsNull())
+          aCommon.Append(aNewShape);
+      }
+      Selector_NExplode aNexp(aCommon);
+      aResult = aNexp.shape(myWeakIndex);
+    } else { // standard case
+      TopoDS_ListOfShape aFinalsCommon; // final shapes presented in all results from bases
+      findModificationResult(aFinalsCommon);
+      if (aFinalsCommon.Extent() == 1) // only in this case result is valid: found only one shape
+        aResult = aFinalsCommon.First();
+      else if (aFinalsCommon.Extent() > 1 && myWeakIndex) {
+        Selector_NExplode aNExp(aFinalsCommon);
+        aResult = aNExp.shape(myWeakIndex);
+      }
     }
     break;
   }
@@ -759,19 +787,17 @@ std::string Selector_Selector::name(Selector_NameGenerator* theNameGenerator) {
     if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName))
       return "";
     aResult += theNameGenerator->contextName(myFinal) + "/" +
-      std::string(TCollection_AsciiString(aName->Get()).ToCString()) + "&";
+      std::string(TCollection_AsciiString(aName->Get()).ToCString());
     for(TDF_LabelList::iterator aBase = myBases.begin(); aBase != myBases.end(); aBase++) {
-      if (aBase != myBases.begin())
-        aResult += "&";
       if (!aBase->FindAttribute(TDataStd_Name::GetID(), aName))
         return "";
       aResult += theNameGenerator->contextName(*aBase) + "/" +
         std::string(TCollection_AsciiString(aName->Get()).ToCString());
-      if (myWeakIndex != -1) {
-        std::ostringstream aWeakStr;
-        aWeakStr<<"&"<<kWEAK_NAME_IDENTIFIER<<myWeakIndex;
-        aResult += aWeakStr.str();
-      }
+    }
+    if (myWeakIndex != -1) {
+      std::ostringstream aWeakStr;
+      aWeakStr<<"&"<<kWEAK_NAME_IDENTIFIER<<myWeakIndex;
+      aResult += aWeakStr.str();
     }
     return aResult;
   }