]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
It is a filters implementation to be set in the XML file.
authornds <natalia.donis@opencascade.com>
Wed, 10 Dec 2014 12:02:28 +0000 (15:02 +0300)
committernds <natalia.donis@opencascade.com>
Wed, 10 Dec 2014 12:02:28 +0000 (15:02 +0300)
Add/remove the current filters to the shape selection widget by activate/deactivate operation.

src/ModuleBase/ModuleBase_FilterFactory.cpp
src/ModuleBase/ModuleBase_FilterFactory.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp

index 1d45b9f3ff62cd431dade5080813302bc55861c3..9ab3762cc52d165dc0c2943a5a2d15100d42e18e 100644 (file)
@@ -43,33 +43,14 @@ void ModuleBase_FilterFactory::assignFilter(const std::string& theID,
   */
 }
 
-void ModuleBase_FilterFactory::validators(const std::string& theFeatureID,
-  std::list<ModuleBase_Filter*>& theResult,
-  std::list<std::list<std::string> >& theArguments) const
+const SelectMgr_ListOfFilter& ModuleBase_FilterFactory::filters(const std::string& theFeatureID,
+  const std::string& theAttrID/*,
+  std::list<ModuleBase_Filter*>& theFilters/*,
+  std::list<std::list<std::string> >& theArguments*/) const
 {
-/*  std::map<std::string, AttrValidators>::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<std::string, ModuleBase_Filter*>::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<ModuleBase_Filter*>& theValidators,
-  std::list<std::list<std::string> >& theArguments) const
-{
-/*  std::map<std::string, std::map<std::string, AttrValidators> >::const_iterator aFeature = 
+  SelectMgr_ListOfFilter aFilters;
+  return aFilters;
+  /*  std::map<std::string, std::map<std::string, AttrValidators> >::const_iterator aFeature = 
     myAttrs.find(theFeatureID);
   if (aFeature != myAttrs.cend()) {
     std::map<std::string, AttrValidators>::const_iterator anAttr = aFeature->second.find(theAttrID);
index bf6986b80fe0e137b7644e95afd5c61410ac9d94..d8b305a577a295d65610b25673bff3c8fed07270 100644 (file)
@@ -8,6 +8,8 @@
 #include "ModuleBase.h"
 #include "ModuleBase_IWorkshop.h"
 
+#include <SelectMgr_ListOfFilter.hxx>
+
 #include <map>
 #include <set>
 
@@ -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<ModuleBase_Filter*>& theResult,
-                                       std::list<std::list<std::string> >& 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<ModuleBase_Filter*>& theValidators,
-                                       std::list<std::list<std::string> >& 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;
index cf0e748dba6bb608b1320b4861fbc87338b58e93..e31c52d4a185add173fc44496d42f0a22ea844a9 100644 (file)
@@ -8,6 +8,8 @@
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_Tools.h>
+#include <ModuleBase_FilterFactory.h>
+#include <ModuleBase_Filter.h>
 
 #include <Config_WidgetAPI.h>
 #include <Events_Loop.h>
@@ -37,6 +39,7 @@
 
 #include <GeomAPI_Shape.h>
 
+#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopExp_Explorer.hxx>
 
@@ -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);
+  }
 }
 
 //********************************************************************