From: Artem Zhidkov Date: Mon, 29 Jun 2020 21:09:03 +0000 (+0300) Subject: Task #3236: Generalization of extrusion X-Git-Tag: V9_6_0a1~60^2~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c6c1e41b28978b08ae57f35f02fb18e6527f6a99;p=modules%2Fshaper.git Task #3236: Generalization of extrusion Fix the validator to be able to select sketch vertices and edges for extrusion and revolution. --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp index 1a6767086..b1f78b9fd 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp @@ -50,6 +50,7 @@ void FeaturesPlugin_CompositeSketch::initCompositeSketchAttribtues(const int the // Initialize selection list. if(theInitFlags & InitBaseObjectsList) { data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId()); + myCurrentSelectionType = selectionList(BASE_OBJECTS_ID())->selectionType(); } } @@ -288,3 +289,15 @@ void storeSubShape( } } } + +//================================================================================================= +void FeaturesPlugin_CompositeSketch::attributeChanged(const std::string& theID) +{ + if (theID == BASE_OBJECTS_ID()) { + AttributeSelectionListPtr anObjects = selectionList(BASE_OBJECTS_ID()); + if (anObjects->size() == 0 || anObjects->selectionType() != myCurrentSelectionType) { + myCurrentSelectionType = anObjects->selectionType(); + removeResults(0); // clear the results + } + } +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h index 67fde35a5..ef4ce06a0 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h @@ -66,6 +66,10 @@ public: /// structures of the owner (the remove from the document will be done outside just after). FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr theFeature); + /// On change of attribute of the result update presentation of this result: + /// for the current moment there are only presentation attributes assigned to results + FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); + protected: enum InitFlags { InitSketchLauncher = 1 << 0, @@ -99,6 +103,8 @@ protected: const ListOfShape& theShapes, const std::string theName); +private: + std::string myCurrentSelectionType; //< type of selection (vertex, edge or face) }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index f47f5ba79..a47e06a67 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -440,14 +440,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute if(aConstruction->facesNum() > 0) { return true; } - } else { - // Shape on construction selected. Check that it is a face or wire. - if(aShape->shapeType() == GeomAPI_Shape::WIRE || - aShape->shapeType() == GeomAPI_Shape::FACE) { - return true; - } } - return false; } if(aContextShape.get() && !aShape->isEqual(aContextShape)) { diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index 97e02b9c3..94a9d4bc3 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -19,7 +19,7 @@ default_type = "2" use_choice="true" concealment="true"> - +