Salome HOME
Issue #335 : generaet the shape for selection construction elements whole results...
authormpv <mpv@opencascade.com>
Tue, 30 Dec 2014 09:24:22 +0000 (12:24 +0300)
committermpv <mpv@opencascade.com>
Tue, 30 Dec 2014 09:24:22 +0000 (12:24 +0300)
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp
src/Model/Model_AttributeSelection.cpp

index 2dc527d9d5462e97016396853b31144b6e9f754a..6f262f536531617248435a95f8b60710a3072650 100644 (file)
@@ -69,4 +69,4 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::
   std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
   aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
   return aRes;
-}
\ No newline at end of file
+}
index cb6db8e7478f9efdb9b905ef42751a12bb28aecf..bcf8a57b3d18bcb63917524d87b95d5b727ee5de 100644 (file)
@@ -80,16 +80,19 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext,
 
   // do noth use naming if selected shape is result shape itself, but not sub-shape
   TDF_Label aSelLab = selectionLabel();
-  if (theContext->shape().get() && theContext->shape()->isEqual(theSubShape)) {
-    aSelLab.ForgetAllAttributes(true);
-    TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
-  } else {
-    aSelLab.ForgetAttribute(kSIMPLE_REF_ID);
-    if (theContext->groupName() == ModelAPI_ResultBody::group())
+  aSelLab.ForgetAttribute(kSIMPLE_REF_ID);
+  if (theContext->groupName() == ModelAPI_ResultBody::group()) {
+    // do not select the whole shape for body:it is already must be in the data framework
+    if (theContext->shape().get() && theContext->shape()->isEqual(theSubShape)) {
+      aSelLab.ForgetAllAttributes(true);
+      TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
+    } else {
       selectBody(theContext, theSubShape);
-    else if (theContext->groupName() == ModelAPI_ResultConstruction::group())
-      selectConstruction(theContext, theSubShape);
+    }
+  } else if (theContext->groupName() == ModelAPI_ResultConstruction::group()) {
+    selectConstruction(theContext, theSubShape);
   }
+  myIsInitialized = true;
 
   std::string aSelName = namingName();
   if(!aSelName.empty())
@@ -101,7 +104,6 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext,
   //selectSubShape("EDGE", "Extrusion_1/TopFace|Extrusion_1/LateralFace_1");
   //selectSubShape("EDGE", "Sketch_1/Edge_6");
 #endif
-  myIsInitialized = true;
   owner()->data()->sendAttributeUpdated(this);
 }
 
@@ -348,6 +350,7 @@ bool Model_AttributeSelection::update()
         }
       }
     } else { // simple construction element: the selected is that needed
+      selectConstruction(aContext, aContext->shape());
       owner()->data()->sendAttributeUpdated(this);
       return true;
     }
@@ -398,11 +401,11 @@ static void registerSubShape(TDF_Label& theMainLabel, TopoDS_Shape theShape,
   else if (theShape.ShapeType() == TopAbs_VERTEX) aName<<"Vertex";
 
   if (theRefs.IsNull()) {
-    aName<<"_"<<theID;
+    aName<<theID;
   } else { // make a compisite name from all sub-elements indexes: "1_2_3_4"
     TColStd_MapIteratorOfPackedMapOfInteger aRef(theRefs->GetMap());
     for(; aRef.More(); aRef.Next()) {
-      aName<<"_"<<aRef.Key();
+      aName<<"-"<<aRef.Key();
     }
   }
 
@@ -418,13 +421,18 @@ void Model_AttributeSelection::selectConstruction(
   FeaturePtr aContextFeature = theContext->document()->feature(theContext);
   CompositeFeaturePtr aComposite = 
     std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aContextFeature);
+  const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
   if (!aComposite || aComposite->numberOfSubs() == 0) {
-    return; // saving of context is enough: result construction contains exactly the needed shape
+    // saving of context is enough: result construction contains exactly the needed shape
+    TNaming_Builder aBuilder(selectionLabel());
+    aBuilder.Generated(aSubShape);
+    aMyDoc->addNamingName(selectionLabel(), theContext->data()->name());
+    TDataStd_Name::Set(selectionLabel(), theContext->data()->name().c_str());
+    return;
   }
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(owner()->data());
   TDF_Label aLab = myRef.myRef->Label();
   // identify the reuslts of sub-object of the composite by edges
-  const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
   // save type of the selected shape in integer attribute
   TopAbs_ShapeEnum aShapeType = aSubShape.ShapeType();
   TDataStd_Integer::Set(aLab, (int)aShapeType);