From: mpv Date: Fri, 26 Dec 2014 08:59:29 +0000 (+0300) Subject: Make interfaces of methods are in more object oriented way X-Git-Tag: V_0.7.0_rc1~42^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dfbaae968c07258f014f62094bd75941b5f2d3ff;p=modules%2Fshaper.git Make interfaces of methods are in more object oriented way --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index c1d510ad2..f610b3dbe 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -76,7 +76,7 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext, else if (theContext->groupName() == ModelAPI_ResultConstruction::group()) selectConstruction(theContext, theSubShape); - std::string aSelName = buildSubShapeName(theSubShape, theContext); + std::string aSelName = namingName(); if(!aSelName.empty()) TDataStd_Name::Set(selectionLabel(), aSelName.c_str()); //set name @@ -501,14 +501,18 @@ bool isTrivial (const TopTools_ListOfShape& theAncestors, TopTools_IndexedMapOfS if(aNumber > 1) return false; return true; } -std::string Model_AttributeSelection::buildSubShapeName(std::shared_ptr theSubShape, - const ResultPtr& theContext) +std::string Model_AttributeSelection::namingName()//std::shared_ptr theSubShape, + // const ResultPtr& theContext) { + std::shared_ptr aSubSh = value(); + ResultPtr aCont = context(); std::string aName; - if(theSubShape->isNull() || theContext->shape()->isNull()) return aName; - TopoDS_Shape aSubShape = theSubShape->impl(); - TopoDS_Shape aContext = theContext->shape()->impl(); - std::shared_ptr aDoc = std::dynamic_pointer_cast(theContext->document()); + if(!aSubSh.get() || aSubSh->isNull() || !aCont.get() || aCont->shape()->isNull()) + return aName; + TopoDS_Shape aSubShape = aSubSh->impl(); + TopoDS_Shape aContext = aCont->shape()->impl(); + std::shared_ptr aDoc = + std::dynamic_pointer_cast(aCont->document()); // check if the subShape is already in DF aName = GetShapeName(aDoc, aSubShape, selectionLabel()); diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 8cfd02f30..74c77344d 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -39,9 +39,8 @@ public: /// \returns false if update is failed MODEL_EXPORT virtual bool update(); - /// builds name of the SubShape - MODEL_EXPORT virtual std::string buildSubShapeName(std::shared_ptr theSubShape, - const ResultPtr& theContext); + /// Returns a textual string of the selection + MODEL_EXPORT virtual std::string namingName(); protected: /// Objects are created for features automatically diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index b34a24d1c..b56241025 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -44,9 +44,9 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute return type(); } - /// Builds name of the SubShape - virtual std::string buildSubShapeName(std::shared_ptr theSubShape, - const ResultPtr& theContext) = 0; + /// Returns a textual string of the selection + virtual std::string namingName() = 0; + /// Selects sub-shape by Name //virtual selectSubShape(const std::string& theSubShapeName, const std::string& theContextShapeName)