From 815d02a699ded50ddf0f82315d48825cc1123f98 Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 30 Dec 2014 12:24:22 +0300 Subject: [PATCH] Issue #335 : generaet the shape for selection construction elements whole results to let them appeared in the naming structures of the document --- src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp | 2 +- src/Model/Model_AttributeSelection.cpp | 34 +++++++++++++-------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp index 2dc527d9d..6f262f536 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp @@ -69,4 +69,4 @@ std::shared_ptr GeomAlgoAPI_FaceBuilder:: std::shared_ptr aRes(new GeomAPI_Shape); aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face())); return aRes; -} \ No newline at end of file +} diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index cb6db8e74..bcf8a57b3 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -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<<"_"<GetMap()); for(; aRef.More(); aRef.Next()) { - aName<<"_"<document()->feature(theContext); CompositeFeaturePtr aComposite = std::dynamic_pointer_cast(aContextFeature); + const TopoDS_Shape& aSubShape = theSubShape->impl(); 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 aData = std::dynamic_pointer_cast(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(); // save type of the selected shape in integer attribute TopAbs_ShapeEnum aShapeType = aSubShape.ShapeType(); TDataStd_Integer::Set(aLab, (int)aShapeType); -- 2.39.2