From: vsv Date: Wed, 25 May 2016 15:01:23 +0000 (+0300) Subject: Issue #1412: Activate selection mode FACES for sketcher only in operations with selector X-Git-Tag: V_2.3.1~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=79b3cdc4791257ddc2d41dd891e41509459a02af;p=modules%2Fshaper.git Issue #1412: Activate selection mode FACES for sketcher only in operations with selector --- diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index f9b5868b7..f65b1d313 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -183,6 +183,16 @@ 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; }; diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index f20a298c4..cb826704b 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -64,6 +64,10 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg //! Clear all validated cash in the widget void clearValidatedCash(); + /// Returns true if the workshop validator filter has been already activated + /// \return boolean value + bool isFilterActivated() const; + protected: /// Checks whether all active viewer filters validate the presentation /// \param thePrs a selected presentation in the view @@ -132,10 +136,6 @@ private: /// \return true if all validators return that the attribute is valid bool isValidAttribute(const AttributePtr& theAttribute) const; - /// Returns true if the workshop validator filter has been already activated - /// \return boolean value - bool isFilterActivated() const; - protected: /// Gets the validity state of the presentation in an internal map. Returns true if the valid state of value is stored /// \param theValue a viewer presentation diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 2c127173d..3235693f3 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1322,3 +1322,35 @@ 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(); + ModuleBase_ModelWidget* aModelWgt = aPropPanel->activeWidget(); + ModuleBase_WidgetSelector* aWgtSelector = dynamic_cast(aModelWgt); + if (aWgtSelector) { + return aWgtSelector->isFilterActivated(); + } else + return true; + } 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 bca62aaa9..0c03bede4 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -307,6 +307,16 @@ 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/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index bc1bb7526..4c41e5243 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -885,7 +885,12 @@ void XGUI_Displayer::activateAIS(const Handle(AIS_InteractiveObject)& theIO, { Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); if (!aContext.IsNull()) { - aContext->Activate(theIO, theMode, false); + if (myWorkshop->module()) { + int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode); + if (myWorkshop->module()->canActivateSelectionMode(theIO, aMode)) + aContext->Activate(theIO, theMode, false); + } else + aContext->Activate(theIO, theMode, false); #ifdef DEBUG_ACTIVATE_AIS ObjectPtr anObject = getObject(theIO); @@ -903,9 +908,9 @@ void XGUI_Displayer::deactivateAIS(const Handle(AIS_InteractiveObject)& theIO, c if (!aContext.IsNull()) { if (theMode == -1) aContext->Deactivate(theIO); - else + else aContext->Deactivate(theIO, theMode); - + #ifdef DEBUG_DEACTIVATE_AIS ObjectPtr anObject = getObject(theIO); anInfo.append(ModuleBase_Tools::objectInfo((*anIt))); @@ -1154,7 +1159,8 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO, bool isDeactivated = false; for (; itr.More(); itr.Next() ) { Standard_Integer aMode = itr.Value(); - if (!theModes.contains(aMode)) { + int aShapeMode = (aMode > 8)? aMode : AIS_Shape::SelectionType(aMode); + if (!theModes.contains(aMode) || (myWorkshop->module()->needDeactivateSelectionMode(theIO, aShapeMode))) { deactivateAIS(theIO, aMode); isDeactivated = true; }