From: dbv Date: Mon, 15 Aug 2016 13:48:30 +0000 (+0300) Subject: Issue #1648: Dump Python in the High Level Parameterized Geometry API X-Git-Tag: V_2.5.0~137^2~52 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5dc7890a0bf10ed40177900107ae4a1981da425d;p=modules%2Fshaper.git Issue #1648: Dump Python in the High Level Parameterized Geometry API Dump for FeaturesAPI_Revolution --- diff --git a/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp b/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp index d3808bb26..e2f317182 100644 --- a/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp @@ -179,7 +179,7 @@ void FeaturesAPI_Extrusion::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aBase = feature(); const std::string& aDocName = theDumper.name(aBase->document()); - AttributeReferencePtr anAttrSketch = aBase->reference(FeaturesPlugin_CompositeSketch::SKETCH_ID()); + AttributeReferencePtr anAttrSketch = aBase->reference(FeaturesPlugin_Extrusion::SKETCH_ID()); AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Extrusion::BASE_OBJECTS_ID()); AttributeSelectionPtr anAttrDirection = aBase->selection(FeaturesPlugin_Extrusion::DIRECTION_OBJECT_ID()); diff --git a/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp b/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp index bc37de7c1..d384af987 100644 --- a/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp +++ b/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp @@ -100,7 +100,7 @@ void FeaturesAPI_ExtrusionBoolean::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aBase = feature(); const std::string& aDocName = theDumper.name(aBase->document()); - AttributeReferencePtr anAttrSketch = aBase->reference(FeaturesPlugin_CompositeSketch::SKETCH_ID()); + AttributeReferencePtr anAttrSketch = aBase->reference(FeaturesPlugin_Extrusion::SKETCH_ID()); AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Extrusion::BASE_OBJECTS_ID()); AttributeSelectionPtr anAttrDirection = aBase->selection(FeaturesPlugin_Extrusion::DIRECTION_OBJECT_ID()); diff --git a/src/FeaturesAPI/FeaturesAPI_Revolution.cpp b/src/FeaturesAPI/FeaturesAPI_Revolution.cpp index d54b660fb..6c09db9f2 100644 --- a/src/FeaturesAPI/FeaturesAPI_Revolution.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Revolution.cpp @@ -8,6 +8,7 @@ #include #include +#include #include //================================================================================================== @@ -69,12 +70,24 @@ FeaturesAPI_Revolution::~FeaturesAPI_Revolution() } +//================================================================================================== +void FeaturesAPI_Revolution::setNestedSketch(const ModelHighAPI_Reference& theSketch) +{ + mysketch->setValue(theSketch.feature()); + mybaseObjects->clear(); + mybaseObjects->append(theSketch.feature()->firstResult(), GeomShapePtr()); + + execIfBaseNotEmpty(); +} + //================================================================================================== void FeaturesAPI_Revolution::setBase(const std::list& theBaseObjects) { + mysketch->setValue(ObjectPtr()); + mybaseObjects->clear(); fillAttribute(theBaseObjects, mybaseObjects); - execute(); + execIfBaseNotEmpty(); } //================================================================================================== @@ -82,7 +95,7 @@ void FeaturesAPI_Revolution::setAxis(const ModelHighAPI_Selection& theAxis) { fillAttribute(theAxis, myaxis); - execute(); + execIfBaseNotEmpty(); } //================================================================================================== @@ -93,7 +106,7 @@ void FeaturesAPI_Revolution::setAngles(const ModelHighAPI_Double& theToAngle, fillAttribute(theToAngle, mytoAngle); fillAttribute(theFromAngle, myfromAngle); - execute(); + execIfBaseNotEmpty(); } //================================================================================================== @@ -103,7 +116,7 @@ void FeaturesAPI_Revolution::setAngle(const ModelHighAPI_Double& theAngle) fillAttribute(theAngle, mytoAngle); fillAttribute(ModelHighAPI_Double(), myfromAngle); - execute(); + execIfBaseNotEmpty(); } //================================================================================================== @@ -118,7 +131,7 @@ void FeaturesAPI_Revolution::setPlanesAndOffsets(const ModelHighAPI_Selection& t fillAttribute(theFromObject, myfromObject); fillAttribute(theFromOffset, myfromOffset); - execute(); + execIfBaseNotEmpty(); } //================================================================================================== @@ -127,10 +140,13 @@ void FeaturesAPI_Revolution::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aBase = feature(); const std::string& aDocName = theDumper.name(aBase->document()); - AttributeSelectionListPtr anObjects = aBase->selectionList(FeaturesPlugin_Revolution::BASE_OBJECTS_ID()); - AttributeSelectionPtr anAxis = aBase->selection(FeaturesPlugin_Revolution::AXIS_OBJECT_ID()); + AttributeReferencePtr anAttrSketch = aBase->reference(FeaturesPlugin_Revolution::SKETCH_ID()); + AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Revolution::BASE_OBJECTS_ID()); + AttributeSelectionPtr anAttrAxis = aBase->selection(FeaturesPlugin_Revolution::AXIS_OBJECT_ID()); - theDumper << aBase << " = model.addRevolution(" << aDocName << ", " << anObjects << ", " << anAxis; + theDumper << aBase << " = model.addRevolution(" << aDocName << ", "; + anAttrSketch->isInitialized() ? theDumper << "[]" : theDumper << anAttrObjects; + theDumper << ", " << anAttrAxis; std::string aCreationMethod = aBase->string(FeaturesPlugin_Revolution::CREATION_METHOD())->value(); @@ -149,6 +165,18 @@ void FeaturesAPI_Revolution::dump(ModelHighAPI_Dumper& theDumper) const } theDumper << ")" << std::endl; + + if(anAttrSketch->isInitialized()) { + theDumper << aBase << ".setNestedSketch(" << anAttrSketch << ")" << std::endl; + } +} + +//================================================================================================== +void FeaturesAPI_Revolution::execIfBaseNotEmpty() +{ + if(mybaseObjects->size() > 0) { + execute(); + } } //================================================================================================== diff --git a/src/FeaturesAPI/FeaturesAPI_Revolution.h b/src/FeaturesAPI/FeaturesAPI_Revolution.h index 5b296ba6c..e011ee403 100644 --- a/src/FeaturesAPI/FeaturesAPI_Revolution.h +++ b/src/FeaturesAPI/FeaturesAPI_Revolution.h @@ -15,6 +15,7 @@ #include class ModelHighAPI_Double; +class ModelHighAPI_Reference; class ModelHighAPI_Selection; /// \class FeaturesAPI_Revolution @@ -57,6 +58,7 @@ public: virtual ~FeaturesAPI_Revolution(); INTERFACE_10(FeaturesPlugin_Revolution::ID(), + sketch, FeaturesPlugin_Revolution::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */, baseObjects, FeaturesPlugin_Revolution::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */, axis, FeaturesPlugin_Revolution::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection, /** Axis */, creationMethod, FeaturesPlugin_Revolution::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, @@ -65,8 +67,11 @@ public: toObject, FeaturesPlugin_Revolution::TO_OBJECT_ID(), ModelAPI_AttributeSelection, /** To object */, toOffset, FeaturesPlugin_Revolution::TO_OFFSET_ID(), ModelAPI_AttributeDouble, /** To offset */, fromObject, FeaturesPlugin_Revolution::FROM_OBJECT_ID(), ModelAPI_AttributeSelection, /** From object */, - fromOffset, FeaturesPlugin_Revolution::FROM_OFFSET_ID(), ModelAPI_AttributeDouble, /** From offset */, - sketchLauncher, FeaturesPlugin_Revolution::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */) + fromOffset, FeaturesPlugin_Revolution::FROM_OFFSET_ID(), ModelAPI_AttributeDouble, /** From offset */) + + /// Modify base attribute of the feature. + FEATURESAPI_EXPORT + void setNestedSketch(const ModelHighAPI_Reference& theSketch); /// Modify base attribute of the feature. FEATURESAPI_EXPORT @@ -94,6 +99,9 @@ public: /// Dump wrapped feature FEATURESAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const; + +private: + void execIfBaseNotEmpty(); }; /// Pointer on Revolution object.