From 860fcac5c03fd7ea627e2dfacc0542d7f7dacb24 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 10 Dec 2014 15:02:28 +0300 Subject: [PATCH] It is a filters implementation to be set in the XML file. Add/remove the current filters to the shape selection widget by activate/deactivate operation. --- src/ModuleBase/ModuleBase_FilterFactory.cpp | 33 ++++--------------- src/ModuleBase/ModuleBase_FilterFactory.h | 12 +++---- .../ModuleBase_WidgetShapeSelector.cpp | 21 ++++++++++-- 3 files changed, 29 insertions(+), 37 deletions(-) diff --git a/src/ModuleBase/ModuleBase_FilterFactory.cpp b/src/ModuleBase/ModuleBase_FilterFactory.cpp index 1d45b9f3f..9ab3762cc 100644 --- a/src/ModuleBase/ModuleBase_FilterFactory.cpp +++ b/src/ModuleBase/ModuleBase_FilterFactory.cpp @@ -43,33 +43,14 @@ void ModuleBase_FilterFactory::assignFilter(const std::string& theID, */ } -void ModuleBase_FilterFactory::validators(const std::string& theFeatureID, - std::list& theResult, - std::list >& theArguments) const +const SelectMgr_ListOfFilter& ModuleBase_FilterFactory::filters(const std::string& theFeatureID, + const std::string& theAttrID/*, + std::list& theFilters/*, + std::list >& theArguments*/) const { -/* std::map::const_iterator aFeature = myFeatures.find(theFeatureID); - if (aFeature != myFeatures.cend()) { - AttrValidators::const_iterator aValIter = aFeature->second.cbegin(); - for (; aValIter != aFeature->second.cend(); aValIter++) { - std::map::const_iterator aFound = - myIDs.find(aValIter->first); - if (aFound == myIDs.end()) { - Events_Error::send(std::string("Validator ") + aValIter->first + " was not registered"); - } else { - theResult.push_back(aFound->second); - theArguments.push_back(aValIter->second); - } - } - } - addDefaultValidators(theResult);*/ -} - -void ModuleBase_FilterFactory::validators(const std::string& theFeatureID, - const std::string& theAttrID, - std::list& theValidators, - std::list >& theArguments) const -{ -/* std::map >::const_iterator aFeature = + SelectMgr_ListOfFilter aFilters; + return aFilters; + /* std::map >::const_iterator aFeature = myAttrs.find(theFeatureID); if (aFeature != myAttrs.cend()) { std::map::const_iterator anAttr = aFeature->second.find(theAttrID); diff --git a/src/ModuleBase/ModuleBase_FilterFactory.h b/src/ModuleBase/ModuleBase_FilterFactory.h index bf6986b80..d8b305a57 100644 --- a/src/ModuleBase/ModuleBase_FilterFactory.h +++ b/src/ModuleBase/ModuleBase_FilterFactory.h @@ -8,6 +8,8 @@ #include "ModuleBase.h" #include "ModuleBase_IWorkshop.h" +#include + #include #include @@ -52,15 +54,9 @@ class ModuleBase_FilterFactory : public QObject const std::string& theFeatureID, const std::string& theAttrID); - /// Provides a validator for the feature, returns NULL if no validator - MODULEBASE_EXPORT virtual void validators(const std::string& theFeatureID, - std::list& theResult, - std::list >& theArguments) const; /// Provides a validator for the attribute, returns NULL if no validator - MODULEBASE_EXPORT virtual void validators(const std::string& theFeatureID, - const std::string& theAttrID, - std::list& theValidators, - std::list >& theArguments) const; + MODULEBASE_EXPORT const SelectMgr_ListOfFilter& filters(const std::string& theFeatureID, + const std::string& theAttrID) const; /// Returns registered validator by its Id MODULEBASE_EXPORT virtual const ModuleBase_Filter* validator(const std::string& theID) const; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index cf0e748db..e31c52d4a 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include @@ -37,6 +39,7 @@ #include +#include #include #include @@ -402,6 +405,7 @@ void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate) return; myIsActive = toActivate; updateSelectionName(); + ModuleBase_IViewer* aViewer = myWorkshop->viewer(); if (myIsActive) { connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); @@ -413,20 +417,31 @@ void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate) myWorkshop->activateSubShapesSelection(aList); if (!myObjectTypes.isEmpty()) { myObjTypeFilter = new ModuleBase_ObjectTypesFilter(myWorkshop, myObjectTypes); - myWorkshop->viewer()->clearSelectionFilters(); - myWorkshop->viewer()->addSelectionFilter(myObjTypeFilter); + aViewer->clearSelectionFilters(); + aViewer->addSelectionFilter(myObjTypeFilter); } } } else { disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); if (myUseSubShapes) { if (!myObjTypeFilter.IsNull()) { - myWorkshop->viewer()->removeSelectionFilter(myObjTypeFilter); + aViewer->removeSelectionFilter(myObjTypeFilter); myObjTypeFilter.Nullify(); } myWorkshop->deactivateSubShapesSelection(); } } + + ModuleBase_FilterFactory* aFactory = myWorkshop->selectionFilters(); + const SelectMgr_ListOfFilter& aFilters = aFactory->filters(parentID(), attributeID()); + SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); + for (; aIt.More(); aIt.Next()) { + Handle(ModuleBase_Filter) aFilter = Handle(ModuleBase_Filter)::DownCast(aIt.Value()); + if (myIsActive) + aViewer->addSelectionFilter(aFilter); + else + aViewer->removeSelectionFilter(aFilter); + } } //******************************************************************** -- 2.39.2