From 36358763f1b843f3d5cfc49b9bd56a9a9b0b7771 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 27 May 2016 11:00:25 +0300 Subject: [PATCH] Issue #1412: Activate selection mode FACES for sketcher only in operations with selector: correction for wrong case in Extrusion operation. New custom selection modes(Face, Wire) are implemented in Sketch presentation which is switched on by module when corresponded standard modes are mentioned in XML. It is switched on/off when the Property panel widget control is activated. --- src/ModuleBase/ModuleBase_IModule.h | 14 +++----- src/PartSet/PartSet_Module.cpp | 43 +++++-------------------- src/PartSet/PartSet_Module.h | 14 +++----- src/PartSet/PartSet_ResultSketchPrs.cpp | 16 ++++++--- src/PartSet/PartSet_ResultSketchPrs.h | 2 +- src/SketcherPrs/SketcherPrs_Tools.h | 10 ++++-- src/XGUI/XGUI_Displayer.cpp | 5 ++- src/XGUI/XGUI_ModuleConnector.cpp | 5 ++- 8 files changed, 43 insertions(+), 66 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index f65b1d313..f12b751f3 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -183,16 +183,6 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \param theObject a model object virtual bool canActivateSelection(const ObjectPtr& theObject) const; - /// Returns true if the given selection mode can be activated for the given presentgation - /// \param theIO an object presentation - /// \param theMode selection mode - virtual bool canActivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const { return true; } - - /// Returns true if the given selection mode must be deactivated for the given presentgation in any case - /// \param theIO an object presentation - /// \param theMode selection mode - virtual bool needDeactivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const { return false; } - /// Reacts to the delete action in module /// \returns true if the action is processed virtual bool deleteObjects() { return false; }; @@ -207,6 +197,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \param theModes a list of modes virtual void activeSelectionModes(QIntList& theModes) {} + /// Appends specific selection modes for the module to the list of types + /// \param theTypes a selection modes to be extended + virtual void customSubShapesSelectionModes(QIntList& theTypes) {} + /// Activate custom presentation for the object. Default realization is empty. /// \param theFeature a feature instance /// \param theFlag a flag of level of customization, which means that only part of sub-elements diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index b8b46fb90..29948541d 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -526,6 +526,14 @@ void PartSet_Module::activeSelectionModes(QIntList& theModes) PartSet_SketcherMgr::sketchSelectionModes(theModes); } +void PartSet_Module::customSubShapesSelectionModes(QIntList& theTypes) +{ + if (theTypes.contains(TopAbs_FACE)) + theTypes.append(SketcherPrs_Tools::Sel_Sketch_Face); + if (theTypes.contains(TopAbs_WIRE)) + theTypes.append(SketcherPrs_Tools::Sel_Sketch_Wire); +} + bool PartSet_Module::isMouseOverWindow() { return mySketchMgr->isMouseOverWindow(); @@ -1322,38 +1330,3 @@ void PartSet_Module::setDefaultConstraintShown() myHasConstraintShown[PartSet_Tools::Dimensional] = true; myHasConstraintShown[PartSet_Tools::Expressions] = false; } - -//****************************************************** -bool PartSet_Module::canActivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const -{ - /*if (theMode == TopAbs_FACE) { - Handle(PartSet_ResultSketchPrs) aSketchPrs = Handle(PartSet_ResultSketchPrs)::DownCast(theIO); - if (!aSketchPrs.IsNull()) { - ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); - if (anOperation) { - ModuleBase_IPropertyPanel* aPropPanel = anOperation->propertyPanel(); - if (aPropPanel) { - ModuleBase_ModelWidget* aModelWgt = aPropPanel->activeWidget(); - ModuleBase_WidgetSelector* aWgtSelector = dynamic_cast(aModelWgt); - if (aWgtSelector) { - return aWgtSelector->isFilterActivated(); - } else - return true; - } else - return false; - } else - return false; - } - }*/ - return true; -} - -//****************************************************** -bool PartSet_Module::needDeactivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const -{ - if (theMode == TopAbs_FACE) { - // Handle(PartSet_ResultSketchPrs) aSketchPrs = Handle(PartSet_ResultSketchPrs)::DownCast(theIO); - // return !aSketchPrs.IsNull(); - } - return false; -} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 0c03bede4..237fd817b 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -189,6 +189,10 @@ public: /// \param theModes a list of modes virtual void activeSelectionModes(QIntList& theModes); + /// Appends specific selection modes for the module to the list of types + /// \param theTypes a selection modes to be extended + virtual void customSubShapesSelectionModes(QIntList& theTypes); + /// Returns whether the mouse enter the viewer's window /// \return true if items are added and there is no necessity to provide standard menu bool isMouseOverWindow(); @@ -307,16 +311,6 @@ public: /// \return theAttribute virtual AttributePtr findAttribute(const ObjectPtr& theObject, const GeomShapePtr& theGeomShape); - /// Returns true if the given selection mode can be activated for the given presentgation - /// \param theIO an object presentation - /// \param theMode selection mode - virtual bool canActivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const; - - /// Returns true if the given selection mode must be deactivated for the given presentgation in any case - /// \param theIO an object presentation - /// \param theMode selection mode - virtual bool needDeactivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const; - public slots: /// Redefines the parent method in order to customize the next case: /// If the sketch nested operation is active and the presentation is not visualized in the viewer, diff --git a/src/PartSet/PartSet_ResultSketchPrs.cpp b/src/PartSet/PartSet_ResultSketchPrs.cpp index 384741ced..a07cfd490 100755 --- a/src/PartSet/PartSet_ResultSketchPrs.cpp +++ b/src/PartSet/PartSet_ResultSketchPrs.cpp @@ -18,6 +18,8 @@ #include +#include + #include #include @@ -120,15 +122,21 @@ void debugInfo(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) #endif void PartSet_ResultSketchPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer aMode) + const Standard_Integer theMode) { - if (aMode > 8) + int aMode = theMode; + + if (aMode > 8 && + aMode != SketcherPrs_Tools::Sel_Sketch_Face && + aMode != SketcherPrs_Tools::Sel_Sketch_Wire) // In order to avoid using custom selection modes return; bool aShapeIsChanged = false; - if (aMode == AIS_Shape::SelectionMode(TopAbs_FACE) || - aMode == AIS_Shape::SelectionMode(TopAbs_WIRE)) { + if (aMode == SketcherPrs_Tools::Sel_Sketch_Face || + aMode == SketcherPrs_Tools::Sel_Sketch_Wire) { + aMode = (aMode == SketcherPrs_Tools::Sel_Sketch_Face) ? AIS_Shape::SelectionMode(TopAbs_FACE) + : AIS_Shape::SelectionMode(TopAbs_WIRE); #ifdef DEBUG_WIRE const TopoDS_Shape& aShape = Shape(); debugInfo(aShape, TopAbs_VERTEX); // 24 diff --git a/src/PartSet/PartSet_ResultSketchPrs.h b/src/PartSet/PartSet_ResultSketchPrs.h index ddf21d1ec..f303adec9 100755 --- a/src/PartSet/PartSet_ResultSketchPrs.h +++ b/src/PartSet/PartSet_ResultSketchPrs.h @@ -37,7 +37,7 @@ protected: /// Redefinition of virtual function Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer aMode) ; + const Standard_Integer theMode) ; private: /// Appens sensitive and owners for wires of the given shape into selection diff --git a/src/SketcherPrs/SketcherPrs_Tools.h b/src/SketcherPrs/SketcherPrs_Tools.h index a17dc4937..cfc15dbfc 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.h +++ b/src/SketcherPrs/SketcherPrs_Tools.h @@ -72,8 +72,14 @@ namespace SketcherPrs_Tools { /// Selection mode for line of dimension Sel_Dimension_Line, - /// Selection mode foe text of dimension - Sel_Dimension_Text + /// Selection mode for text of dimension + Sel_Dimension_Text, + + /// Selectiom mode for faces selection on sketch + Sel_Sketch_Face, + + /// Selectiom mode for wires selection on sketch + Sel_Sketch_Wire }; /// Type of angle diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 4c41e5243..2b3b043e4 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -887,8 +887,7 @@ void XGUI_Displayer::activateAIS(const Handle(AIS_InteractiveObject)& theIO, if (!aContext.IsNull()) { if (myWorkshop->module()) { int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode); - if (myWorkshop->module()->canActivateSelectionMode(theIO, aMode)) - aContext->Activate(theIO, theMode, false); + aContext->Activate(theIO, theMode, false); } else aContext->Activate(theIO, theMode, false); @@ -1160,7 +1159,7 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO, for (; itr.More(); itr.Next() ) { Standard_Integer aMode = itr.Value(); int aShapeMode = (aMode > 8)? aMode : AIS_Shape::SelectionType(aMode); - if (!theModes.contains(aMode) || (myWorkshop->module()->needDeactivateSelectionMode(theIO, aShapeMode))) { + if (!theModes.contains(aMode)) { deactivateAIS(theIO, aMode); isDeactivated = true; } diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index 8fd52e598..4163952e3 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -79,8 +79,11 @@ QObjectPtrList XGUI_ModuleConnector::activeObjects(const QObjectPtrList& theObjL void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes) { + QIntList aTypes = theTypes; + XGUI_Displayer* aDisp = myWorkshop->displayer(); - aDisp->activateObjects(theTypes, activeObjects(aDisp->displayedObjects())); + myWorkshop->module()->customSubShapesSelectionModes(aTypes); + aDisp->activateObjects(aTypes, activeObjects(aDisp->displayedObjects())); } void XGUI_ModuleConnector::deactivateSubShapesSelection() -- 2.39.2