From: nds Date: Tue, 24 Feb 2015 07:42:26 +0000 (+0300) Subject: Issue #386 Distance constraint on circle and arc preselected X-Git-Tag: V_1.1.0~174 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e8fc74b565b939f9d7ab151c00006f4999572c86;p=modules%2Fshaper.git Issue #386 Distance constraint on circle and arc preselected --- diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 81e45ef0a..7031b5c1e 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -283,6 +283,18 @@ bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue) // if (!acceptObjectShape(aObject)) // return false; + // Check whether the value is valid for the viewer selection filters + Handle(SelectMgr_EntityOwner) anOwner = theValue.owner(); + if (!anOwner.IsNull()) { + SelectMgr_ListOfFilter aFilters; + selectionFilters(aFilters); + SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); + for (; aIt.More(); aIt.Next()) { + const Handle(SelectMgr_Filter)& aFilter = aIt.Value(); + if (!aFilter->IsOk(anOwner)) + return false; + } + } if (isValid(aObject, aShape)) { setObject(aObject, aShape); return true; @@ -404,37 +416,30 @@ void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate) aList.append(shapeType(aType)); } myWorkshop->activateSubShapesSelection(aList); - if (!myObjectTypes.isEmpty()) { - myObjTypeFilter = new ModuleBase_ObjectTypesFilter(myWorkshop, myObjectTypes); - aViewer->clearSelectionFilters(); - aViewer->addSelectionFilter(myObjTypeFilter); - } } else { disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); - if (!myObjTypeFilter.IsNull()) { - aViewer->removeSelectionFilter(myObjTypeFilter); - myObjTypeFilter.Nullify(); - } myWorkshop->deactivateSubShapesSelection(); } - // apply filters loaded from the XML definition of the widget - ModuleBase_FilterFactory* aFactory = myWorkshop->selectionFilters(); + + // the initial code is moved here in order to clear filters, it is possible, that it is excessive and + // is performed outside + if (myIsActive && !myObjectTypes.isEmpty()) { + aViewer->clearSelectionFilters(); + } SelectMgr_ListOfFilter aFilters; - aFactory->filters(parentID(), attributeID(), aFilters); + selectionFilters(aFilters); SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); for (; aIt.More(); aIt.Next()) { - Handle(SelectMgr_Filter) aSelFilter = aIt.Value(); - if (aSelFilter.IsNull()) - continue; - - //Handle(ModuleBase_Filter) aFilter = Handle(ModuleBase_Filter)::DownCast(aIt.Value()); - //if (aFilter.IsNull()) - // continue; + const Handle(SelectMgr_Filter)& aSelFilter = aIt.Value(); if (myIsActive) aViewer->addSelectionFilter(aSelFilter); else aViewer->removeSelectionFilter(aSelFilter); } + // the internal filter should be removed by the widget deactivation, it is done historically + if (!myIsActive && !myObjTypeFilter.IsNull()) { + myObjTypeFilter.Nullify(); + } } //******************************************************************** diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h index aa0c75f13..f57f5664b 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -15,6 +15,7 @@ #include #include +#include #include @@ -149,6 +150,12 @@ Q_OBJECT /// Clear attribute void clearAttribute(); + /// Fills the given list with all widget filters. It can be used by activation widget for the viewer + /// or by checking the selection parameter in addition to check validity of the selection argument + /// It creates an object type filter if it has not been created yet and save it in the class field + /// \param theFilters a list of filter + void selectionFilters(SelectMgr_ListOfFilter& theFilters); + //----------- Class members ------------- protected: