From: nds Date: Fri, 25 Mar 2016 09:13:23 +0000 (+0300) Subject: Issue #1343 Improvement of Extrusion and Revolution operations: wires selection. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e29b625bae601a7d29e9bf45594bd9e8aaf0e376;p=modules%2Fshaper.git Issue #1343 Improvement of Extrusion and Revolution operations: wires selection. --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp b/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp index 7f16df44e..00f2dc170 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp @@ -17,7 +17,7 @@ bool FeaturesPlugin_ValidatorExtrusionBase::isValid(const AttributePtr& theAttri { bool aValid = true; - GeomValidators_FeatureKind* aValidator = new GeomValidators_FeatureKind(); + /*GeomValidators_FeatureKind* aValidator = new GeomValidators_FeatureKind(); // check whether the selection is on the sketch bool aFeatureKindValid = aValidator->isValid(theAttribute, theArguments, theError); if (!aFeatureKindValid) { @@ -26,6 +26,6 @@ bool FeaturesPlugin_ValidatorExtrusionBase::isValid(const AttributePtr& theAttri std::list anArguments; anArguments.push_back("face"); aValid = aShapeType->isValid(theAttribute, anArguments, theError); - } + }*/ return aValid; } diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 9b0833a4a..1b7f8c6eb 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -682,6 +682,7 @@ static void registerSubShape(TDF_Label theMainLabel, TopoDS_Shape theShape, if (!theAdditionalName.empty()) aName< #include +//#define DEBUG_WIRE +#ifdef DEBUG_WIRE +#include +#include +#endif IMPLEMENT_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner); IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner); @@ -68,6 +73,18 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult) SetAutoHilight(aCompSolid.get() == NULL); } +bool ModuleBase_ResultPrs::isValidShapeType(const TopAbs_ShapeEnum& theBaseType, + const TopAbs_ShapeEnum& theCheckedType) +{ + bool aValid = theBaseType == theCheckedType; + if (!aValid) { + // currently this functionality is for all, as we have no separate wire selection mode + // lately it should be corrected to have the following check only for sketch presentations + aValid = theBaseType == TopAbs_FACE && theCheckedType == TopAbs_WIRE; + } + return aValid; +} + void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, @@ -102,6 +119,21 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t Events_Error::throwException("An empty AIS presentation: ModuleBase_ResultPrs"); } +#ifdef DEBUG_WIRE +void debugInfo(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + TopTools_IndexedMapOfShape aSubShapes; + TopExp::MapShapes (theShape, theType, aSubShapes); + + Standard_Boolean isComesFromDecomposition = !((aSubShapes.Extent() == 1) && (theShape == aSubShapes (1))); + int anExtent = aSubShapes.Extent(); + for (Standard_Integer aShIndex = 1; aShIndex <= aSubShapes.Extent(); ++aShIndex) + { + const TopoDS_Shape& aSubShape = aSubShapes (aShIndex); + int aValue = 0; + } +} +#endif void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) @@ -110,9 +142,15 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a // In order to avoid using custom selection modes return; - if (myIsSketchMode) { if (aMode == AIS_Shape::SelectionMode(TopAbs_FACE)) { +#ifdef DEBUG_WIRE + const TopoDS_Shape& aShape = Shape(); + debugInfo(aShape, TopAbs_VERTEX); // 24 + debugInfo(aShape, TopAbs_EDGE); // 12 + debugInfo(aShape, TopAbs_WIRE); // 0 + debugInfo(aShape, TopAbs_FACE); // 0 +#endif BRep_Builder aBuilder; TopoDS_Compound aComp; aBuilder.MakeCompound(aComp); @@ -121,7 +159,16 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) { TopoDS_Shape aFace = (*aIt)->impl(); aBuilder.Add(aComp, aFace); + // for sketch presentation in the face mode wires should be selectable also + // accoring to #1343 Improvement of Extrusion and Revolution operations + appendWiresSelection(aSelection, aFace); } +#ifdef DEBUG_WIRE + debugInfo(aComp, TopAbs_VERTEX); // 24 + debugInfo(aComp, TopAbs_EDGE); // 12 + debugInfo(aComp, TopAbs_WIRE); // 4 + debugInfo(aComp, TopAbs_FACE); // 2 +#endif Set(aComp); } else Set(myOriginalShape); @@ -171,6 +218,24 @@ bool ModuleBase_ResultPrs::hasCompSolidSelectionMode() const return false; } +void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection, + const TopoDS_Shape& theShape) +{ + static TopAbs_ShapeEnum TypOfSel + = AIS_Shape::SelectionType(AIS_Shape::SelectionMode(TopAbs_WIRE)); + // POP protection against crash in low layers + Standard_Real aDeflection = Prs3d::GetDeflection(theShape, myDrawer); + try { + StdSelect_BRepSelectionTool::Load(theSelection, + this, + theShape, + TypOfSel, + aDeflection, + myDrawer->HLRAngle(), + myDrawer->IsAutoTriangulation()); + } catch ( Standard_Failure ) { + } +} TopoDS_Shape ModuleBase_ResultPrs::getSelectionShape() const { diff --git a/src/ModuleBase/ModuleBase_ResultPrs.h b/src/ModuleBase/ModuleBase_ResultPrs.h index 056d757e1..e6f2e3e7e 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.h +++ b/src/ModuleBase/ModuleBase_ResultPrs.h @@ -53,6 +53,12 @@ public: /// \param theResult a result object Standard_EXPORT ModuleBase_ResultPrs(ResultPtr theResult); + /// Returns true if the checked type can be accepted for the base selection type + /// It returns true if they are coicide or if the base type is face and the checked type is wire + /// @return boolean result + static Standard_EXPORT bool isValidShapeType(const TopAbs_ShapeEnum& theBaseType, + const TopAbs_ShapeEnum& theCheckedType); + //! Method which draws selected owners ( for fast presentation draw ) Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, @@ -86,6 +92,11 @@ protected: const Standard_Integer aMode) ; private: + /// Appens sensitive and owners for wires of the given shape into selection + /// \param theSelection a current filled selection + /// \param theShape a shape + void appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection, + const TopoDS_Shape& theShape); /// Returns shape dependent on CompSolid selection mode /// In case CompSolid selection mode it returns parent's compsolid shape TopoDS_Shape getSelectionShape() const; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 454ed88de..e07b726b2 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -105,15 +106,17 @@ bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape, QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end(); for (; anIt != aLast; anIt++) { - if (aShapeType == *anIt) + TopAbs_ShapeEnum aCurrentShapeType = (TopAbs_ShapeEnum)*anIt; + if (aShapeType == aCurrentShapeType) aValid = true; - else if (*anIt == TopAbs_FACE) { + else if (aCurrentShapeType == 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; } + aValid = ModuleBase_ResultPrs::isValidShapeType(aCurrentShapeType, aShapeType); } } return aValid;