Salome HOME
Issue #1648: Dump Python in the High Level Parameterized Geometry API
authordbv <dbv@opencascade.com>
Thu, 11 Aug 2016 14:34:40 +0000 (17:34 +0300)
committerdbv <dbv@opencascade.com>
Mon, 15 Aug 2016 11:03:10 +0000 (14:03 +0300)
Dump for FeaturesAPI_Group

src/FeaturesAPI/FeaturesAPI_Group.cpp
src/FeaturesAPI/FeaturesAPI_Group.h
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/FeaturesPlugin_Translation.cpp
src/ModelHighAPI/ModelHighAPI_Selection.cpp
src/ModelHighAPI/ModelHighAPI_Selection.h
src/ModelHighAPI/ModelHighAPI_Tools.cpp

index 274fe8e40e9e1d3cdcae2f3fb9f1000edd848d89..d12e73f45f47d5f6d98069585b168aa35e65faf4 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "FeaturesAPI_Group.h"
 
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Integer.h>
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
@@ -41,6 +42,17 @@ void FeaturesAPI_Group::setGroupList(const std::list<ModelHighAPI_Selection>& th
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_Group::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  AttributeSelectionListPtr anAttrList = aBase->selectionList(FeaturesPlugin_Group::LIST_ID());
+
+  theDumper << aBase << " = model.addGroup(" << aDocName << ", " << anAttrList << ")" << std::endl;
+}
+
 //==================================================================================================
 GroupPtr addGroup(const std::shared_ptr<ModelAPI_Document>& thePart,
                   const std::list<ModelHighAPI_Selection>& theGroupList)
index 68239201bb5ee7089f01dc92cc1cf181cb6cb0a9..fece502f25f7320428279fd654780e709dcb9cc0 100644 (file)
@@ -14,6 +14,7 @@
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
 
+class ModelHighAPI_Dumper;
 class ModelHighAPI_Selection;
 
 /// \class FeaturesAPI_Group
@@ -41,6 +42,10 @@ public:
   /// Set main objects.
   FEATURESAPI_EXPORT
   void setGroupList(const std::list<ModelHighAPI_Selection>& theGroupList);
+
+  /// Dump wrapped feature
+  FEATURESAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
 };
 
 /// Pointer on Group object.
index 69915b1b38674876b643180cd03e19801d224e8b..075bd5f7b0498a51cb4d09cdc3ee42cf6252cb86 100644 (file)
@@ -39,13 +39,9 @@ void FeaturesPlugin_Boolean::initAttributes()
   AttributeSelectionListPtr aSelection = 
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
     FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
-  // extrusion works with faces always
-  aSelection->setSelectionType("SOLID");
 
   aSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
     FeaturesPlugin_Boolean::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
-  // extrusion works with faces always
-  aSelection->setSelectionType("SOLID");
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_LIST_ID());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID());
index 43b25be205b2270e3e0eec2bb0c5ce5d840f75c8..496abeb0a42122e4f4b061d26e31fcc28d6907a5 100644 (file)
@@ -34,8 +34,6 @@ void FeaturesPlugin_Placement::initAttributes()
   AttributeSelectionListPtr aSelection = 
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
     OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
-  // extrusion works with faces always
-  aSelection->setSelectionType("SOLID");
 
   data()->addAttribute(START_SHAPE_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(END_SHAPE_ID(), ModelAPI_AttributeSelection::typeId());
index 3d3076ab5d085516c6cce484a267717f3b2c636f..91ab7c7b09b2335bdd68758f099b1549bcda1f3e 100755 (executable)
@@ -25,8 +25,6 @@ void FeaturesPlugin_Rotation::initAttributes()
   AttributeSelectionListPtr aSelection = 
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
     FeaturesPlugin_Rotation::OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
-  // revolution works with faces always
-  aSelection->setSelectionType("SOLID");
 
   data()->addAttribute(FeaturesPlugin_Rotation::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(FeaturesPlugin_Rotation::ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
index c3931387cf2de04422574dc778d6052237958fc7..e335277846986784435cb6a3cde322cc9736273e 100644 (file)
@@ -27,8 +27,6 @@ void FeaturesPlugin_Translation::initAttributes()
   AttributeSelectionListPtr aSelection = 
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
     FeaturesPlugin_Translation::OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
-  // revolution works with faces always
-  aSelection->setSelectionType("SOLID");
 
   data()->addAttribute(FeaturesPlugin_Translation::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(FeaturesPlugin_Translation::DISTANCE_ID(), ModelAPI_AttributeDouble::typeId());
index c2540b8f51a30d29cf1512265e661e9f292addfd..0c4e764f595be68f106cd06e1c1ed8961133a62d 100644 (file)
@@ -77,3 +77,14 @@ TypeSubShapeNamePair ModelHighAPI_Selection::typeSubShapeNamePair() const
 {
   return myTypeSubShapeNamePair;
 }
+
+//==================================================================================================
+std::string ModelHighAPI_Selection::shapeType() const
+{
+  switch(myVariantType) {
+    case VT_ResultSubShapePair: return myResultSubShapePair.second->shapeTypeStr();
+    case VT_TypeSubShapeNamePair: return myTypeSubShapeNamePair.first;
+  }
+
+  return "SHAPE";
+}
index e559228b6fe206cf4410abdc43b678f95b31bafa..2e1507ff139ea8da3f44b367de3f1641728d3e3e 100644 (file)
@@ -72,6 +72,10 @@ public:
   MODELHIGHAPI_EXPORT
   virtual TypeSubShapeNamePair typeSubShapeNamePair() const;
 
+  /// \return shape type.
+  MODELHIGHAPI_EXPORT
+  virtual std::string shapeType() const;
+
 private:
   VariantType myVariantType;
   ResultSubShapePair myResultSubShapePair;
index 7931f0dcae2a8e34eb8a91c1987348a9a8b1f98f..8923fd6e13bf01788622a586a564361eccb44709 100644 (file)
@@ -173,6 +173,13 @@ void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
                    const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute)
 {
   theAttribute->clear();
+
+  if(!theValue.empty()) {
+    std::string aSelectionType;
+    const ModelHighAPI_Selection& aSelection = theValue.front();
+    theAttribute->setSelectionType(aSelection.shapeType());
+  }
+
   for (auto it = theValue.begin(); it != theValue.end(); ++it)
     it->appendToList(theAttribute);
 }