/// \param theObject a model object\r
virtual bool canActivateSelection(const ObjectPtr& theObject) const;\r
\r
+ /// Returns true if the given selection mode can be activated for the given presentgation\r
+ /// \param theIO an object presentation\r
+ /// \param theMode selection mode\r
+ virtual bool canActivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const { return true; }\r
+\r
+ /// Returns true if the given selection mode must be deactivated for the given presentgation in any case\r
+ /// \param theIO an object presentation\r
+ /// \param theMode selection mode\r
+ virtual bool needDeactivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const { return false; }\r
+\r
/// Reacts to the delete action in module\r
/// \returns true if the action is processed\r
virtual bool deleteObjects() { return false; };\r
//! 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
/// \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
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<ModuleBase_WidgetSelector*>(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;
+}
/// \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,
{
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);
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)));
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;
}