From: nds Date: Mon, 15 Dec 2014 11:01:41 +0000 (+0300) Subject: Parameters for the filters are similar to the parameters of validators. X-Git-Tag: before_slalome_7.5.1~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9ade3feafa3ee13af4f9eaf8ffa2b96f7973709b;p=modules%2Fshaper.git Parameters for the filters are similar to the parameters of validators. --- diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index 46afa6090..1f6ca6356 100644 --- a/src/Config/Config_Common.cpp +++ b/src/Config/Config_Common.cpp @@ -72,7 +72,7 @@ bool hasChild(xmlNodePtr theNode) return false; } -bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId, +bool getParametersInfo(xmlNodePtr theNode, std::string& outValidatorId, std::list& outValidatorParameters) { //Validator id: @@ -83,7 +83,7 @@ bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId, outValidatorId = std::string(anIdProp); //Validator parameters: - char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_PARAMETERS); + char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST _PARAMETERS); if (aParamProp && aParamProp[0] != 0) { std::string aPropString = std::string(aParamProp); std::stringstream aPropStringStream(aPropString); diff --git a/src/Config/Config_Common.h b/src/Config/Config_Common.h index a588e5098..05e2024fd 100644 --- a/src/Config/Config_Common.h +++ b/src/Config/Config_Common.h @@ -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& outValidatorParameters); +CONFIG_EXPORT bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId, + std::list& outValidatorParameters); /*! \brief Convert the given parameter to the platform-specific library name. diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index a5ff66d30..90f7fcb67 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -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; diff --git a/src/Config/Config_SelectionFilterMessage.cpp b/src/Config/Config_SelectionFilterMessage.cpp index 6067d4238..cb958cd46 100644 --- a/src/Config/Config_SelectionFilterMessage.cpp +++ b/src/Config/Config_SelectionFilterMessage.cpp @@ -42,6 +42,11 @@ const std::string& Config_SelectionFilterMessage::attributeId() const return myAttributeId; } +const std::list& 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& parameters) +{ + myFilterParameters = parameters; +} + diff --git a/src/Config/Config_SelectionFilterMessage.h b/src/Config/Config_SelectionFilterMessage.h index 56eb77412..d43b41382 100644 --- a/src/Config/Config_SelectionFilterMessage.h +++ b/src/Config/Config_SelectionFilterMessage.h @@ -24,6 +24,7 @@ class Config_SelectionFilterMessage : public Events_Message std::string mySelectionFilterId; std::string myFeatureId; std::string myAttributeId; + std::list 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& 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& parameters); }; #endif /* CONFIG_SELECTIONFILTERMESSAGE_H_ */ diff --git a/src/Config/Config_XMLReader.cpp b/src/Config/Config_XMLReader.cpp index 061264cc8..856e663be 100644 --- a/src/Config/Config_XMLReader.cpp +++ b/src/Config/Config_XMLReader.cpp @@ -176,10 +176,10 @@ void Config_XMLReader::processValidator(xmlNodePtr theNode) std::shared_ptr aMessage(new Config_ValidatorMessage(aValidatoEvent, this)); std::string aValidatorId; - std::list aValidatorParameters; - getValidatorInfo(theNode, aValidatorId, aValidatorParameters); + std::list 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 aMessage = std::make_shared(aFilterEvent, this); - std::string aSelectionFilterId = getProperty(theNode, _ID); + std::string aSelectionFilterId; + std::list 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)); diff --git a/src/ModuleBase/ModuleBase_FilterFactory.cpp b/src/ModuleBase/ModuleBase_FilterFactory.cpp index 891d74370..c1fb82fc2 100644 --- a/src/ModuleBase/ModuleBase_FilterFactory.cpp +++ b/src/ModuleBase/ModuleBase_FilterFactory.cpp @@ -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& theArguments) { // create feature-structures if not exist std::map >::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(); + aFeature->second[theAttrID][theID] = theArguments; } void ModuleBase_FilterFactory::filters(const std::string& theFeatureID, diff --git a/src/ModuleBase/ModuleBase_FilterFactory.h b/src/ModuleBase/ModuleBase_FilterFactory.h index d0d627639..a0759f25c 100644 --- a/src/ModuleBase/ModuleBase_FilterFactory.h +++ b/src/ModuleBase/ModuleBase_FilterFactory.h @@ -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& theArguments); /// Provides a filter for the attribute, returns NULL if no filter MODULEBASE_EXPORT void filters(const std::string& theFeatureID, diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 42308e373..79491af82 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -432,10 +432,9 @@ void XGUI_Workshop::processEvent(const std::shared_ptr& theMessa std::dynamic_pointer_cast(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()); } } }