]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Parameters for the filters are similar to the parameters of validators.
authornds <natalia.donis@opencascade.com>
Mon, 15 Dec 2014 11:01:41 +0000 (14:01 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 15 Dec 2014 11:01:41 +0000 (14:01 +0300)
src/Config/Config_Common.cpp
src/Config/Config_Common.h
src/Config/Config_Keywords.h
src/Config/Config_SelectionFilterMessage.cpp
src/Config/Config_SelectionFilterMessage.h
src/Config/Config_XMLReader.cpp
src/ModuleBase/ModuleBase_FilterFactory.cpp
src/ModuleBase/ModuleBase_FilterFactory.h
src/XGUI/XGUI_Workshop.cpp

index 46afa60902091ab99fdcaa05eab3787206f6e0db..1f6ca635630f025a1c781a674ad7e13c76b8b75d 100644 (file)
@@ -72,7 +72,7 @@ bool hasChild(xmlNodePtr theNode)
   return false;\r
 }\r
 \r
-bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,\r
+bool getParametersInfo(xmlNodePtr theNode, std::string& outValidatorId,\r
                       std::list<std::string>& outValidatorParameters)\r
 {\r
   //Validator id:\r
@@ -83,7 +83,7 @@ bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,
   outValidatorId = std::string(anIdProp);\r
 \r
   //Validator parameters:\r
-  char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_PARAMETERS);\r
+  char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST _PARAMETERS);\r
   if (aParamProp && aParamProp[0] != 0) {\r
     std::string aPropString = std::string(aParamProp);\r
     std::stringstream aPropStringStream(aPropString);\r
index a588e509850c1a20ec6f76f2dea586b08e8bbc26..05e2024fd2d049eee678883a1fd34b9d6da8c4dd 100644 (file)
@@ -58,10 +58,10 @@ CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
 CONFIG_EXPORT bool hasChild(xmlNodePtr theNode);
 
 /*
- *
+ * Returns named property for an id node as std::string and the parameters of the node.
  */
-CONFIG_EXPORT bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,
-                                    std::list<std::string>& outValidatorParameters);
+CONFIG_EXPORT bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId,
+                                     std::list<std::string>& outValidatorParameters);
 
 /*!
  \brief Convert the given parameter to the platform-specific library name.
index a5ff66d307b416b995cac0c81b183af6aebd4ad0..90f7fcb67450cce3c2302ee9572ad016d239e15e 100644 (file)
@@ -50,8 +50,9 @@ const static char* FEATURE_TEXT = "title";
 const static char* FEATURE_KEYSEQUENCE = "keysequence";
 const static char* FEATURE_NESTED = "nested";
 const static char* FEATURE_DOC = WORKBENCH_DOC;
-// NODE_VALIDATOR properties
-const static char* VALIDATOR_PARAMETERS = "parameters";
+// NODE_VALIDATOR properties, NODE_SELFILTER properties
+const static char* _PARAMETERS = "parameters";
+
 // Widget (attribute) properties
 const static char* ATTR_TOOLTIP = FEATURE_TOOLTIP;
 const static char* ATTR_ICON = FEATURE_ICON;
index 6067d4238ee1805a4f8e5fb03224981d56890c5d..cb958cd46a44d45fc90556f0a96cb74289af5a4d 100644 (file)
@@ -42,6 +42,11 @@ const std::string& Config_SelectionFilterMessage::attributeId() const
   return myAttributeId;
 }
 
+const std::list<std::string>& Config_SelectionFilterMessage::parameters() const
+{
+  return myFilterParameters;
+}
+
 void Config_SelectionFilterMessage::setFeatureId(const std::string& theId)
 {
   myFeatureId = theId;
@@ -52,3 +57,8 @@ void Config_SelectionFilterMessage::setAttributeId(const std::string& theId)
   myAttributeId = theId;
 }
 
+void Config_SelectionFilterMessage::setFilterParameters(const std::list<std::string>& parameters)
+{
+  myFilterParameters = parameters;
+}
+
index 56eb7741275785e1f9c64d8bed79479af2e3a91c..d43b41382d426986320e570d71b9024450429768 100644 (file)
@@ -24,6 +24,7 @@ class Config_SelectionFilterMessage : public Events_Message
   std::string mySelectionFilterId;
   std::string myFeatureId;
   std::string myAttributeId;
+  std::list<std::string> myFilterParameters;
 
  public:
   CONFIG_EXPORT Config_SelectionFilterMessage(const Events_ID theId, const void* theParent = 0);
@@ -32,10 +33,12 @@ class Config_SelectionFilterMessage : public Events_Message
   CONFIG_EXPORT const std::string& selectionFilterId() const;
   CONFIG_EXPORT const std::string& featureId() const;
   CONFIG_EXPORT const std::string& attributeId() const;
+  CONFIG_EXPORT const std::list<std::string>& parameters() const;
 
   CONFIG_EXPORT void setSelectionFilterId(const std::string& theId);
   CONFIG_EXPORT void setFeatureId(const std::string& theId);
   CONFIG_EXPORT void setAttributeId(const std::string& theId);
+  CONFIG_EXPORT void setFilterParameters(const std::list<std::string>& parameters);
 };
 
 #endif /* CONFIG_SELECTIONFILTERMESSAGE_H_ */
index 061264cc8174670a17a0987a4299073086981053..856e663becd7511c6a01bd1fa9a6a4685a6ff5c0 100644 (file)
@@ -176,10 +176,10 @@ void Config_XMLReader::processValidator(xmlNodePtr theNode)
   std::shared_ptr<Config_ValidatorMessage> 
     aMessage(new Config_ValidatorMessage(aValidatoEvent, this));
   std::string aValidatorId;
-  std::list<std::string> aValidatorParameters;
-  getValidatorInfo(theNode, aValidatorId, aValidatorParameters);
+  std::list<std::string> aParameters;
+  getParametersInfo(theNode, aValidatorId, aParameters);
   aMessage->setValidatorId(aValidatorId);
-  aMessage->setValidatorParameters(aValidatorParameters);
+  aMessage->setValidatorParameters(aParameters);
   xmlNodePtr aFeatureOrWdgNode = theNode->parent;
   if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
     aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
@@ -196,8 +196,12 @@ void Config_XMLReader::processSelectionFilter(xmlNodePtr theNode)
   Events_Loop* aEvLoop = Events_Loop::loop();
   std::shared_ptr<Config_SelectionFilterMessage> aMessage =
       std::make_shared<Config_SelectionFilterMessage>(aFilterEvent, this);
-  std::string aSelectionFilterId = getProperty(theNode, _ID);
+  std::string aSelectionFilterId;
+  std::list<std::string> aParameters;
+  getParametersInfo(theNode, aSelectionFilterId, aParameters);
   aMessage->setSelectionFilterId(aSelectionFilterId);
+  aMessage->setFilterParameters(aParameters);
+
   xmlNodePtr aFeatureOrWdgNode = theNode->parent;
   if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
     aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
index 891d74370621fb944a2ff2789ec631cdf0927a95..c1fb82fc2d04c846e7dace999e65f1cd46214ecd 100644 (file)
@@ -27,7 +27,8 @@ void ModuleBase_FilterFactory::registerFilter(const std::string& theID,
 
 void ModuleBase_FilterFactory::assignFilter(const std::string& theID,
                                             const std::string& theFeatureID,
-                                            const std::string& theAttrID)
+                                            const std::string& theAttrID,
+                                            const std::list<std::string>& theArguments)
 {
   // create feature-structures if not exist
   std::map<std::string, std::map<std::string, AttrFilters> >::iterator aFeature = myAttrs.find(
@@ -41,7 +42,7 @@ void ModuleBase_FilterFactory::assignFilter(const std::string& theID,
   if (anAttr == aFeature->second.end()) {
     aFeature->second[theAttrID] = AttrFilters();
   }
-  aFeature->second[theAttrID][theID] = std::list<std::string>();
+  aFeature->second[theAttrID][theID] = theArguments;
 }
 
 void ModuleBase_FilterFactory::filters(const std::string& theFeatureID,
index d0d627639f21574dace29e7b7ae7230a47ad69f4..a0759f25c517ca89d930811f5a5f7705331f7a7f 100644 (file)
@@ -44,7 +44,8 @@ class ModuleBase_FilterFactory : public QObject
   /// Assigns filter to the attribute of the feature
   MODULEBASE_EXPORT virtual void assignFilter(const std::string& theID,
                                               const std::string& theFeatureID,
-                                              const std::string& theAttrID);
+                                              const std::string& theAttrID,
+                                              const std::list<std::string>& theArguments);
 
   /// Provides a filter for the attribute, returns NULL if no filter
   MODULEBASE_EXPORT void filters(const std::string& theFeatureID,
index 42308e3732e66e7dc0661326725e316e2aec8ce3..79491af8274f91b4b1088898f3aecbdb7e77e1fc 100644 (file)
@@ -432,10 +432,9 @@ void XGUI_Workshop::processEvent(const std::shared_ptr<Events_Message>& theMessa
       std::dynamic_pointer_cast<Config_SelectionFilterMessage>(theMessage);
     if (aMsg) {
       ModuleBase_FilterFactory* aFactory = moduleConnector()->selectionFilters();
-      if (aMsg->attributeId().empty()) {  // feature validator
-        //aFactory->assignFilter(aMsg->selectionFilterId(), aMsg->featureId());
-      } else {  // attribute validator
-        aFactory->assignFilter(aMsg->selectionFilterId(), aMsg->featureId(), aMsg->attributeId());
+      if (!aMsg->attributeId().empty()) {
+        aFactory->assignFilter(aMsg->selectionFilterId(), aMsg->featureId(), aMsg->attributeId(),
+                               aMsg->parameters());
       }
     }
   }