]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make interfaces of methods are in more object oriented way
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 26 Dec 2014 08:59:29 +0000 (11:59 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 26 Dec 2014 08:59:29 +0000 (11:59 +0300)
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelection.h
src/ModelAPI/ModelAPI_AttributeSelection.h

index c1d510ad2bb5ab51ab3a9c574ab8c31f40c4b0c0..f610b3dbefb7161ab8e292fcfac57b0dfd7e6539 100644 (file)
@@ -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<GeomAPI_Shape> theSubShape, 
-                                                           const ResultPtr& theContext)
+std::string Model_AttributeSelection::namingName()//std::shared_ptr<GeomAPI_Shape> theSubShape, 
+                                                       // const ResultPtr& theContext)
 {
+  std::shared_ptr<GeomAPI_Shape> aSubSh = value();
+  ResultPtr aCont = context();
   std::string aName;
-  if(theSubShape->isNull() || theContext->shape()->isNull()) return aName;  
-  TopoDS_Shape aSubShape = theSubShape->impl<TopoDS_Shape>();
-  TopoDS_Shape aContext  = theContext->shape()->impl<TopoDS_Shape>();
-  std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(theContext->document());
+  if(!aSubSh.get() || aSubSh->isNull() || !aCont.get() || aCont->shape()->isNull()) 
+    return aName;
+  TopoDS_Shape aSubShape = aSubSh->impl<TopoDS_Shape>();
+  TopoDS_Shape aContext  = aCont->shape()->impl<TopoDS_Shape>();
+  std::shared_ptr<Model_Document> aDoc = 
+    std::dynamic_pointer_cast<Model_Document>(aCont->document());
 
   // check if the subShape is already in DF
   aName = GetShapeName(aDoc, aSubShape, selectionLabel());
index 8cfd02f30a2404f4ed3ca0342072dda96f13bb08..74c77344d5daea843647d8d2c63ad4cf0d1f0d7c 100644 (file)
@@ -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<GeomAPI_Shape> theSubShape, 
-                                                        const ResultPtr& theContext);
+  /// Returns a textual string of the selection
+  MODEL_EXPORT virtual std::string namingName();
 
 protected:
   /// Objects are created for features automatically
index b34a24d1ca70a47a7a86bfa3feb06c831c34b23b..b562410252ee7c2f54b56e52bb9e34c6de5048bf 100644 (file)
@@ -44,9 +44,9 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute
     return type();
   }
 
-  /// Builds name of the SubShape 
-  virtual std::string buildSubShapeName(std::shared_ptr<GeomAPI_Shape> 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)