return setInvalidIfFalse(aSelLab, false); // unknown case
}
+/// integer that contains the tag number of external construction shape naming
+static Standard_GUID kEXTERNAL_CONSTRUCTION_TAG("f7d0726f-e848-4d22-9101-def16d0eff2c");
+
+void Model_AttributeSelection::storeExternalConstruction(
+ const ResultConstructionPtr& theConstruction, const GeomShapePtr& theSubShape)
+{
+ std::string aName = namingName();
+ if (aName.empty()) // unknown error
+ return;
+ std::shared_ptr<Model_Document> aMyDoc =
+ std::dynamic_pointer_cast<Model_Document>(owner()->document());
+ TDF_Label anExternalLab = aMyDoc->extConstructionsLabel();
+ Handle(TDataStd_Integer) anExtTag;
+ if (selectionLabel().FindAttribute(kEXTERNAL_CONSTRUCTION_TAG, anExtTag)) {
+ anExternalLab = anExternalLab.FindChild(anExtTag->Get()); // use existing label
+ } else {
+ // search label with the same name
+ TDF_ChildIDIterator aNamesIter(anExternalLab, TDataStd_Name::GetID());
+ for(; aNamesIter.More(); aNamesIter.Next()) {
+ if (aName == TCollection_AsciiString(Handle(TDataStd_Name)::DownCast(
+ aNamesIter.Value())->Get()).ToCString()) {
+ anExternalLab = aNamesIter.Value()->Label();
+ break;
+ }
+ }
+ if (aNamesIter.More()) {
+ } else {
+ anExternalLab = anExternalLab.NewChild(); // create new label
+ TDataStd_Integer::Set(selectionLabel(), kEXTERNAL_CONSTRUCTION_TAG,
+ anExternalLab.Tag()); // store this tag in the data model
+ }
+ }
+ anExternalLab.ForgetAllAttributes();
+ TopoDS_Shape aSubShape = theSubShape->impl<TopoDS_Shape>();
+ TNaming_Builder aBuilder(anExternalLab);
+ aBuilder.Generated(aSubShape);
+}
+
void Model_AttributeSelection::selectBody(
const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
{
if (aFaceIndex >= 0) {
TDataStd_Integer::Set(aSelLab, theSubShape->shapeType() == GeomAPI_Shape::FACE ?
kEXT_SKETCH_FACE : kEXT_SKETCH_WIRE, aFaceIndex); // store index of the face
+ //storeExternalConstruction(aConstr, theSubShape);
return;
}
- } else if (theSubShape->shapeType() == GeomAPI_Shape::WIRE) {
-
} else if (theSubShape->shapeType() == GeomAPI_Shape::EDGE ||// sketch result edge (full one)
theSubShape->shapeType() == GeomAPI_Shape::VERTEX) { // or start/end vertex
bool isVertex = theSubShape->shapeType() == GeomAPI_Shape::VERTEX;
if ((*aRes)->data()->name() == aCompName) {
theValue = std::dynamic_pointer_cast<Model_Data>((*aRes)->data())->shapeLab();
break;
- } else if (aCompName.find((*aRes)->data()->name()) != std::string::npos) {// sub-vertex
+ } else { // any sub-label because the sketch line may be renamed, but not sub-vertices
TDF_Label aLab = std::dynamic_pointer_cast<Model_Data>((*aRes)->data())->shapeLab();
TDF_ChildIDIterator aSubNames(aLab, TDataStd_Name::GetID());
for(; aSubNames.More(); aSubNames.Next()) {
class Model_AttributeSelectionList;
class Model_Document;
+class ModelAPI_ResultConstruction;
/**\class Model_AttributeSelection
* \ingroup DataModel
class Model_AttributeSelection : public ModelAPI_AttributeSelection,
public Selector_NameGenerator
{
- Model_AttributeReference myRef; ///< The reference functionality reusage
+ Model_AttributeReference myRef; ///< The reference functionality re-usage
/// temporarily storages to avoid keeping in the data structure if not needed
ResultPtr myTmpContext;
/// temporarily storages to avoid keeping in the data structure if not needed
std::shared_ptr<GeomAPI_Shape> myTmpSubShape;
/// temporarily storages to avoid keeping in the data structure if not needed
CenterType myTmpCenterType;
- /// Reference to the partent attribute, if any (to split selection compounds in issue 1799)
+ /// Reference to the parent attribute, if any (to split selection compounds in issue 1799)
Model_AttributeSelectionList* myParent;
std::shared_ptr<Model_Document> myRestoreDocument; // current document to restore by name
/// \param theContext object where the sub-shape was selected
/// \param theSubShape selected sub-shape (if null, the whole context is selected)
/// \param theTemporarily if it is true, do not store and name the added in the data framework
- /// (used to remove immideately, without the following updates)
+ /// (used to remove immediately, without the following updates)
/// \returns true if attribute was updated
MODEL_EXPORT virtual bool setValue(
const ObjectPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
/// Sets the feature object
MODEL_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject);
- /// Updates the underlied selection due to the changes in the referenced objects
+ /// Updates the selection due to the changes in the referenced objects
/// \returns false if update is failed
MODEL_EXPORT virtual bool update();
/// NOTE: This method is opposite to Id() method.
MODEL_EXPORT virtual void setId(int theID);
- /// Selects (i.e. creates Naming data structure) of sub-shape specifed by textual name
+ /// Selects (i.e. creates Naming data structure) of sub-shape specified by textual name
MODEL_EXPORT virtual void selectSubShape(const std::string& theType,
const std::string& theSubShapeName);
/// Returns true if attribute was initialized by some value
MODEL_EXPORT virtual bool isInitialized();
- /// Returns true if recomute of selection become impossible
+ /// Returns true if recompute of selection become impossible
MODEL_EXPORT virtual bool isInvalid();
/// Updates the arguments of selection if something was affected by creation
/// Returns theType type of the center, or NOT_CENTER if it is not.
std::shared_ptr<GeomAPI_Shape> internalValue(CenterType& theType);
-
- /// Performs the selection for the body result (TNaming Selection)
+ /// stores the naming structure of external construction (sketch element) in the data
+ /// tree of this document with name equal to selection-name in external document
+ void storeExternalConstruction(
+ const std::shared_ptr<ModelAPI_ResultConstruction>& theConstruction,
+ const std::shared_ptr<GeomAPI_Shape>& theSubShape);
/// Performs the selection for the body result (TNaming selection)
virtual void selectBody(
/// \param theContext the result - owner of the selection
/// \param theSubShape selected shape
/// \param theUpdate flag that shows that it must be just update, theShape is null
- /// \returns true if eveything is selected correctly
+ /// \returns true if everything is selected correctly
virtual bool selectPart(
const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
const bool theUpdate = false);