From: nds Date: Wed, 24 Jun 2015 10:28:04 +0000 (+0300) Subject: Preselection for extrusion/revolution X-Git-Tag: V_1.3.0~198 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=25574ebcd4ac46424afb28038db1271742ca5c47;p=modules%2Fshaper.git Preselection for extrusion/revolution --- diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index 5e1c3fe8e..12e7181a7 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -5,8 +5,7 @@ label="Select a sketch face" icon=":icons/sketch.png" tooltip="Select a sketch face" - use_choice="false" - type_choice="Faces Compound"> + type_choice="Faces"> diff --git a/src/FeaturesPlugin/revolution_widget.xml b/src/FeaturesPlugin/revolution_widget.xml index add5d7a8b..47b5ee04e 100644 --- a/src/FeaturesPlugin/revolution_widget.xml +++ b/src/FeaturesPlugin/revolution_widget.xml @@ -5,8 +5,7 @@ label="Select a sketch face" icon=":icons/sketch.png" tooltip="Select a sketch face" - use_choice="false" - type_choice="Faces Compound"> + type_choice="Faces"> aWirePtr = std::dynamic_pointer_cast(myShape); - std::list > aFaces; - GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(), - aWirePtr->norm(), aWirePtr, aFaces); - std::list >::iterator aFIter = aFaces.begin(); - for(; aFIter != aFaces.end(); aFIter++) { - std::shared_ptr aFace(new GeomAPI_Face(*aFIter)); - if (aFace.get()) - myFaces.push_back(aFace); + if (aWirePtr.get()) { + std::list > aFaces; + GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(), + aWirePtr->norm(), aWirePtr, aFaces); + std::list >::iterator aFIter = aFaces.begin(); + for(; aFIter != aFaces.end(); aFIter++) { + std::shared_ptr aFace(new GeomAPI_Face(*aFIter)); + if (aFace.get()) + myFaces.push_back(aFace); + } } myFacesUpToDate = true; } diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 6728d2349..2deb05c7c 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -204,7 +204,6 @@ TopAbs_ShapeEnum shapeType(const QString& theType) MyShapeTypes["shell"] = TopAbs_SHELL; MyShapeTypes["solid"] = TopAbs_SOLID; MyShapeTypes["solids"] = TopAbs_SOLID; - MyShapeTypes["compound"] = TopAbs_COMPOUND; } QString aType = theType.toLower(); if (MyShapeTypes.contains(aType)) diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index f4a4b456f..2d2bbd7d3 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -9,6 +9,8 @@ #include #include +#include + ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, @@ -58,22 +60,35 @@ void ModuleBase_WidgetSelector::onSelectionChanged() } //******************************************************************** -bool ModuleBase_WidgetSelector::acceptSubShape(const TopoDS_Shape& theShape) const +bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape, + const ResultPtr& theResult) const { - bool aValid = true; - if (theShape.IsNull()) { - aValid = true; // do not check the shape type if the shape is empty - // extrusion uses a sketch object selectected in Object browser + bool aValid = false; + + GeomShapePtr aShape = theShape; + if (!aShape.get() && theResult.get()) { + if (theResult.get()) + aShape = theResult->shape(); } - else { - aValid = false; - TopAbs_ShapeEnum aShapeType = theShape.ShapeType(); - QIntList aShapeTypes = getShapeTypes(); - - QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end(); - for (; anIt != aLast; anIt++) { - if (aShapeType == *anIt) - aValid = true; + TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE; + if (aShape.get()) { + // Check that the selection corresponds to selection type + TopoDS_Shape aTopoShape = aShape->impl(); + aShapeType = aTopoShape.ShapeType(); + } + + QIntList aShapeTypes = getShapeTypes(); + QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end(); + for (; anIt != aLast; anIt++) { + if (aShapeType == *anIt) + aValid = true; + else if (*anIt == TopAbs_FACE) { + // try to process the construction shape only if there is no a selected shape in the viewer + if (!theShape.get() && theResult.get()) { + ResultConstructionPtr aCResult = + std::dynamic_pointer_cast(theResult); + aValid = aCResult.get() && aCResult->facesNum() > 0; + } } } return aValid; @@ -109,17 +124,9 @@ void ModuleBase_WidgetSelector::activateCustom() bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs) { GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs); - bool aValid = true; - if (!aShape.get()) { - ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); - if (aResult.get()) - aShape = aResult->shape(); - } - if (aShape.get()) { - // Check that the selection corresponds to selection type - TopoDS_Shape aTopoShape = aShape->impl(); - aValid = acceptSubShape(aTopoShape); - } + ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); + bool aValid = acceptSubShape(aShape, aResult); + if (aValid) { // In order to avoid selection of the same object ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index 4f3dd6e4a..dd853530e 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -94,9 +94,13 @@ protected: /// The methiod called when widget is activated virtual void activateCustom(); - /// Returns true if selected shape corresponds to requested shape types + /// Returns true if selected shape corresponds to requested shape types. + /// If the widget type of shapes contains the faces item, the result is converted + /// to construction result and the method returns true if there is at least one face + /// in the construction. /// \param theShape a shape - bool acceptSubShape(const TopoDS_Shape& theShape) const; + /// \param theResult a selected result + bool acceptSubShape(const GeomShapePtr& theShape, const ResultPtr& theResult) const; /// Return an object and geom shape by the viewer presentation /// \param thePrs a selection