From 4698cddc08cddfdd0a535d5a260f7dbaaf564be6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me?= Date: Thu, 10 Dec 2020 20:16:13 +0100 Subject: [PATCH] #20441: remove transparency in API python --- src/FeaturesAPI/FeaturesAPI_SharedFaces.cpp | 5 ----- src/FeaturesAPI/FeaturesAPI_SharedFaces.h | 7 +------ src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.cpp | 4 +++- src/FeaturesPlugin/Test/TestCheckSharedFaces.py | 2 +- src/FeaturesPlugin/doc/checkSharedFaceFeature.rst | 3 +-- src/FeaturesPlugin/doc/examples/checkSharedFaces.py | 2 +- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/FeaturesAPI/FeaturesAPI_SharedFaces.cpp b/src/FeaturesAPI/FeaturesAPI_SharedFaces.cpp index 92b09330e..b13f62313 100644 --- a/src/FeaturesAPI/FeaturesAPI_SharedFaces.cpp +++ b/src/FeaturesAPI/FeaturesAPI_SharedFaces.cpp @@ -39,13 +39,11 @@ FeaturesAPI_SharedFaces:: FeaturesAPI_SharedFaces::FeaturesAPI_SharedFaces( const std::shared_ptr& theFeature, const ModelHighAPI_Selection& theobject, - const ModelHighAPI_Integer& theTransparency, const std::string & theNameGroup) :ModelHighAPI_Interface(theFeature) { if (initialize()) { fillAttribute(theobject, myobjectselected); - fillAttribute(theTransparency, mytransparency); fillAttribute(theNameGroup, mygroupname); execute(); } @@ -66,7 +64,6 @@ void FeaturesAPI_SharedFaces::dump(ModelHighAPI_Dumper& theDumper) const anAttrObject = aBase->selection(FeaturesPlugin_GroupSharedFaces::OBJECT_ID()); theDumper << aBase << " = model.getSharedFaces(" << aDocName << ", " << anAttrObject; - theDumper << ", " << aBase->integer(FeaturesPlugin_GroupSharedFaces::TRANSPARENCY_ID()); theDumper << ", " << aBase->string(FeaturesPlugin_GroupSharedFaces::GROUP_NAME_ID()); theDumper << ")" << std::endl; } @@ -74,7 +71,6 @@ void FeaturesAPI_SharedFaces::dump(ModelHighAPI_Dumper& theDumper) const //================================================================================================= SharedFacesPtr getSharedFaces(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theobject, - const ModelHighAPI_Integer& theTransparency, const std::string & theNameGroup) { @@ -84,7 +80,6 @@ SharedFacesPtr getSharedFaces(const std::shared_ptr& thePart, aSharedFaces.reset(new FeaturesAPI_SharedFaces(aFeature, theobject, - theTransparency, theNameGroup)); return aSharedFaces; diff --git a/src/FeaturesAPI/FeaturesAPI_SharedFaces.h b/src/FeaturesAPI/FeaturesAPI_SharedFaces.h index 001a1cbc3..e5dc89cf1 100644 --- a/src/FeaturesAPI/FeaturesAPI_SharedFaces.h +++ b/src/FeaturesAPI/FeaturesAPI_SharedFaces.h @@ -46,20 +46,16 @@ public: FEATURESAPI_EXPORT explicit FeaturesAPI_SharedFaces(const std::shared_ptr& theFeature, const ModelHighAPI_Selection& theobject, - const ModelHighAPI_Integer& theTransparency, const std::string & theNameGroup); /// Destructor. FEATURESAPI_EXPORT virtual ~FeaturesAPI_SharedFaces(); - INTERFACE_3(FeaturesPlugin_GroupSharedFaces::ID(), + INTERFACE_2(FeaturesPlugin_GroupSharedFaces::ID(), objectselected, FeaturesPlugin_GroupSharedFaces::OBJECT_ID(), ModelAPI_AttributeSelection, /** object selected*/, - transparency, FeaturesPlugin_GroupSharedFaces::TRANSPARENCY_ID(), - ModelAPI_AttributeInteger, - /** transparency*/, groupname, FeaturesPlugin_GroupSharedFaces::GROUP_NAME_ID(), ModelAPI_AttributeString, /** group name*/) @@ -80,7 +76,6 @@ typedef std::shared_ptr SharedFacesPtr; FEATURESAPI_EXPORT SharedFacesPtr getSharedFaces(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theObject, - const ModelHighAPI_Integer& theTransparency, const std::string & theNameGroup); #endif // FeaturesAPI_SharedFaces_H_ diff --git a/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.cpp index 53b576e1f..0bdc7208f 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.cpp @@ -58,6 +58,8 @@ void FeaturesPlugin_GroupSharedFaces::initAttributes() data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::typeId()); data()->addAttribute(GROUP_NAME_ID(), ModelAPI_AttributeString::typeId()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TRANSPARENCY_ID()); + } @@ -99,7 +101,7 @@ void FeaturesPlugin_GroupSharedFaces::execute() } } - if (selection(OBJECT_ID())->isInitialized()) { + if (selection(OBJECT_ID())->isInitialized() && integer(TRANSPARENCY_ID())->isInitialized()) { AttributeSelectionPtr ancompSolidAttr = selection(OBJECT_ID()); ResultPtr aResult = ancompSolidAttr->context(); diff --git a/src/FeaturesPlugin/Test/TestCheckSharedFaces.py b/src/FeaturesPlugin/Test/TestCheckSharedFaces.py index 4e04c7454..c0d98ace1 100644 --- a/src/FeaturesPlugin/Test/TestCheckSharedFaces.py +++ b/src/FeaturesPlugin/Test/TestCheckSharedFaces.py @@ -52,7 +52,7 @@ if __name__ == '__main__': CompSolid_1 = model.addCompSolid(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Box_2_1")]) ### Create Shared_faces - Shared_faces_1 = model.getSharedFaces(Part_1_doc, model.selection("COMPSOLID", "CompSolid_1_1"), 50, "mygroup") + Shared_faces_1 = model.getSharedFaces(Part_1_doc, model.selection("COMPSOLID", "CompSolid_1_1"), "mygroup") model.do() # Check results diff --git a/src/FeaturesPlugin/doc/checkSharedFaceFeature.rst b/src/FeaturesPlugin/doc/checkSharedFaceFeature.rst index e7ca9fac1..e1f45530a 100644 --- a/src/FeaturesPlugin/doc/checkSharedFaceFeature.rst +++ b/src/FeaturesPlugin/doc/checkSharedFaceFeature.rst @@ -32,11 +32,10 @@ Input fields: **TUI Command**: -.. py:function:: model.getSharedFaces(Part_doc, shape, transparency, nameGroup) +.. py:function:: model.getSharedFaces(Part_doc, shape, nameGroup) :param part: The current part object. :param object: A composolid or compound in format *model.selection("Type", shape)*. - :param number: value for the transparency. :param string: name of group created. :return: Created group. diff --git a/src/FeaturesPlugin/doc/examples/checkSharedFaces.py b/src/FeaturesPlugin/doc/examples/checkSharedFaces.py index bc541d1de..198027331 100644 --- a/src/FeaturesPlugin/doc/examples/checkSharedFaces.py +++ b/src/FeaturesPlugin/doc/examples/checkSharedFaces.py @@ -15,7 +15,7 @@ Box_2 = model.addBox(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Front][Box_ CompSolid_1 = model.addCompSolid(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Box_2_1")]) ### Create Shared_faces -Shared_faces_1 = model.getSharedFaces(Part_1_doc, model.selection("COMPSOLID", "CompSolid_1_1"), 50, "mygroup") +Shared_faces_1 = model.getSharedFaces(Part_1_doc, model.selection("COMPSOLID", "CompSolid_1_1"), "mygroup") model.do() model.end() -- 2.39.2