From: sbh Date: Tue, 9 Dec 2014 11:27:11 +0000 (+0300) Subject: Processing of 'selection_filter' xml nodes added. X-Git-Tag: before_slalome_7.5.1~30 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ebf7d0a77d8be18ee27cb5964621b652dfa59f26;p=modules%2Fshaper.git Processing of 'selection_filter' xml nodes added. --- diff --git a/src/Config/CMakeLists.txt b/src/Config/CMakeLists.txt index ab42ba193..b274350bb 100644 --- a/src/Config/CMakeLists.txt +++ b/src/Config/CMakeLists.txt @@ -18,6 +18,7 @@ SET(PROJECT_HEADERS Config_Prop.h Config_PropManager.h Config_AttributeMessage.h + Config_SelectionFilterMessage.h ) SET(PROJECT_SOURCES @@ -33,6 +34,7 @@ SET(PROJECT_SOURCES Config_Prop.cpp Config_PropManager.cpp Config_AttributeMessage.cpp + Config_SelectionFilterMessage.cpp ) SET(XML_RESOURCES diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index a8c6df0a5..cdfa693e3 100644 --- a/src/Config/Config_Common.cpp +++ b/src/Config/Config_Common.cpp @@ -56,7 +56,7 @@ bool isWidgetNode(xmlNodePtr theNode) return false; //it should not be a "source" or a "validator" node - return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NULL); + return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL); } bool hasChild(xmlNodePtr theNode) diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index bf780f330..374efeb6a 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -65,8 +65,8 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) std::string anAttributeID = getProperty(theNode, _ID); if (!anAttributeID.empty()) { aMessage->setAttributeId(anAttributeID); - aMessage->setObligatory(getBooleanAttribute(theNode, ATTRIBUTE_OBLIGATORY, true)); - aMessage->setConcealment(getBooleanAttribute(theNode, ATTRIBUTE_CONCEALMENT, false)); + aMessage->setObligatory(getBooleanAttribute(theNode, ATTR_OBLIGATORY, true)); + aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false)); Events_Loop::loop()->send(aMessage); } } @@ -83,27 +83,27 @@ bool Config_FeatureReader::processChildren(xmlNodePtr theNode) return result; } -void Config_FeatureReader::fillFeature(xmlNodePtr theNode, +void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode, const std::shared_ptr& outFeatureMessage) { - outFeatureMessage->setId(getProperty(theNode, _ID)); + outFeatureMessage->setId(getProperty(theFeatureNode, _ID)); outFeatureMessage->setPluginLibrary(myLibraryName); - outFeatureMessage->setNestedFeatures(getProperty(theNode, FEATURE_NESTED)); + outFeatureMessage->setNestedFeatures(getProperty(theFeatureNode, FEATURE_NESTED)); - bool isInternal = getBooleanAttribute(theNode, ATTRIBUTE_INTERNAL, false); + bool isInternal = getBooleanAttribute(theFeatureNode, ATTR_INTERNAL, false); outFeatureMessage->setInternal(isInternal); if (isInternal) { //Internal feature has no visual representation. return; } - outFeatureMessage->setText(getProperty(theNode, FEATURE_TEXT)); - outFeatureMessage->setTooltip(getProperty(theNode, FEATURE_TOOLTIP)); - outFeatureMessage->setIcon(getProperty(theNode, FEATURE_ICON)); - outFeatureMessage->setKeysequence(getProperty(theNode, FEATURE_KEYSEQUENCE)); + outFeatureMessage->setText(getProperty(theFeatureNode, FEATURE_TEXT)); + outFeatureMessage->setTooltip(getProperty(theFeatureNode, FEATURE_TOOLTIP)); + outFeatureMessage->setIcon(getProperty(theFeatureNode, FEATURE_ICON)); + outFeatureMessage->setKeysequence(getProperty(theFeatureNode, FEATURE_KEYSEQUENCE)); outFeatureMessage->setGroupId(restoreAttribute(NODE_GROUP, _ID)); outFeatureMessage->setWorkbenchId(restoreAttribute(NODE_WORKBENCH, _ID)); // Get document kind of a feature, if empty set workbench's kind (might be empty too) - std::string aDocKind = getProperty(theNode, WORKBENCH_DOC); + std::string aDocKind = getProperty(theFeatureNode, FEATURE_DOC); if(aDocKind.empty()) { aDocKind = restoreAttribute(NODE_WORKBENCH, WORKBENCH_DOC); } diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 159f97c17..511cfea0d 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -16,8 +16,9 @@ const static char* NODE_GROUP = "group"; const static char* NODE_FEATURE = "feature"; const static char* NODE_SOURCE = "source"; const static char* NODE_VALIDATOR = "validator"; +const static char* NODE_SELFILTER = "selection_filter"; -//Widgets +// Widgets const static char* WDG_INFO = "label"; const static char* WDG_DOUBLEVALUE = "doublevalue"; const static char* WDG_BOOLVALUE = "boolvalue"; @@ -25,52 +26,47 @@ const static char* WDG_STRINGVALUE = "stringvalue"; const static char* WDG_MULTISELECTOR = "multi_selector"; const static char* WDG_SHAPE_SELECTOR = "shape_selector"; const static char* WDG_CHOICE = "choice"; -//Specific widgets -//const static char* WDG_POINT2D_DISTANCE = "point2ddistance"; -//const static char* WDG_FEATURE_SELECTOR = "feature_selector"; -//const static char* WDG_FEATURE_OR_ATTRIBUTE_SELECTOR = "feature_or_attribute_selector"; const static char* WDG_DOUBLEVALUE_EDITOR = "doublevalue_editor"; const static char* WDG_FILE_SELECTOR= "file_selector"; - -//Widget containers +// Containers const static char* WDG_GROUP = "groupbox"; const static char* WDG_CHECK_GROUP = "check_groupbox"; const static char* WDG_TOOLBOX = "toolbox"; const static char* WDG_TOOLBOX_BOX = "box"; const static char* WDG_SWITCH = "switch"; const static char* WDG_SWITCH_CASE = "case"; - -const static char* WORKBENCH_DOC = "document"; -//Common Widget's or Feature's Properties +// Common properties (xml attributes of nodes) const static char* _ID = "id"; +// NODE_WORKBENCH properties +const static char* WORKBENCH_DOC = "document"; +// NODE_SOURCE properties +const static char* SOURCE_FILE = "path"; +// NODE_FEATURE properties const static char* FEATURE_TOOLTIP = "tooltip"; const static char* FEATURE_ICON = "icon"; const static char* FEATURE_TEXT = "title"; const static char* FEATURE_KEYSEQUENCE = "keysequence"; const static char* FEATURE_NESTED = "nested"; - -const static char* ATTRIBUTE_INTERNAL = "internal"; -const static char* ATTRIBUTE_OBLIGATORY = "obligatory"; -const static char* ATTRIBUTE_CONCEALMENT = "concealment"; -// TODO: Rename -//const static char* PREVIOUS_FEATURE_PARAM = "previous_feature_param"; -const static char* ANY_WDG_TOOLTIP = FEATURE_TOOLTIP; -const static char* ANY_WDG_ICON = FEATURE_ICON; -const static char* ANY_WDG_LABEL = "label"; -const static char* ANY_WDG_DEFAULT = "default"; - -const static char* SOURCE_FILE = "path"; +const static char* FEATURE_DOC = WORKBENCH_DOC; +// NODE_VALIDATOR properties const static char* VALIDATOR_PARAMETERS = "parameters"; - -// doublevalue properties: +// Widget (attribute) properties +const static char* ATTR_TOOLTIP = FEATURE_TOOLTIP; +const static char* ATTR_ICON = FEATURE_ICON; +const static char* ATTR_LABEL = "label"; +const static char* ATTR_DEFAULT = "default"; +const static char* ATTR_INTERNAL = "internal"; +const static char* ATTR_OBLIGATORY = "obligatory"; +const static char* ATTR_CONCEALMENT = "concealment"; +// WDG_INFO properties const static char* INFO_WDG_TEXT = FEATURE_TEXT; const static char* INFO_WDG_TOOLTIP = FEATURE_TOOLTIP; +// WDG_DOUBLEVALUE properties: const static char* DOUBLE_WDG_MIN = "min"; const static char* DOUBLE_WDG_MAX = "max"; const static char* DOUBLE_WDG_STEP = "step"; const static char* DOUBLE_WDG_DEFAULT_COMPUTED = "computed"; - -//toolbox/switch properties +// WDG_TOOLBOX/WDG_SWITCH properties const static char* CONTAINER_PAGE_NAME = "title"; /* diff --git a/src/Config/Config_SelectionFilterMessage.cpp b/src/Config/Config_SelectionFilterMessage.cpp new file mode 100644 index 000000000..05a82a096 --- /dev/null +++ b/src/Config/Config_SelectionFilterMessage.cpp @@ -0,0 +1,52 @@ +/* + * Config_SelectionFilterMessage.cpp + * + * Created on: 08 Jul 2014 + * Author: sbh + */ + +#include + +Config_SelectionFilterMessage::Config_SelectionFilterMessage(const Events_ID theId, + const void* theParent) + : Events_Message(theId, theParent) +{ + mySelectionFilterId = ""; + myFeatureId = ""; + myAttributeId = ""; +} + +Config_SelectionFilterMessage::~Config_SelectionFilterMessage() +{ +} + +const std::string& Config_SelectionFilterMessage::selectionFilterId() const +{ + return mySelectionFilterId; +} + +const std::string& Config_SelectionFilterMessage::featureId() const +{ + return myFeatureId; +} + +void Config_SelectionFilterMessage::setSelectionFilterId(const std::string& theId) +{ + mySelectionFilterId = theId; +} + +const std::string& Config_SelectionFilterMessage::attributeId() const +{ + return myAttributeId; +} + +void Config_SelectionFilterMessage::setFeatureId(const std::string& theId) +{ + myFeatureId = theId; +} + +void Config_SelectionFilterMessage::setAttributeId(const std::string& theId) +{ + myAttributeId = theId; +} + diff --git a/src/Config/Config_SelectionFilterMessage.h b/src/Config/Config_SelectionFilterMessage.h new file mode 100644 index 000000000..92b1aa244 --- /dev/null +++ b/src/Config/Config_SelectionFilterMessage.h @@ -0,0 +1,39 @@ +/* + * Config_SelectionFilterMessage.h + * + * Created on: 08 Jul 2014 + * Author: sbh + */ + +#ifndef CONFIG_SELECTIONFILTERMESSAGE_H_ +#define CONFIG_SELECTIONFILTERMESSAGE_H_ + +#include +#include + +#include +#include + +/// Event ID that Selection Filter is loaded (comes with Config_SelectionFilterMessage) +static const char * EVENT_SELFILTER_LOADED = "SelectionFilterLoaded"; + +class Config_SelectionFilterMessage : public Events_Message +{ + std::string mySelectionFilterId; + std::string myFeatureId; + std::string myAttributeId; + + public: + CONFIG_EXPORT Config_SelectionFilterMessage(const Events_ID theId, const void* theParent = 0); + CONFIG_EXPORT virtual ~Config_SelectionFilterMessage(); + + CONFIG_EXPORT const std::string& selectionFilterId() const; + CONFIG_EXPORT const std::string& featureId() const; + CONFIG_EXPORT const std::string& attributeId() 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); +}; + +#endif /* CONFIG_SELECTIONFILTERMESSAGE_H_ */ diff --git a/src/Config/Config_ValidatorMessage.cpp b/src/Config/Config_ValidatorMessage.cpp index 61ee376c0..5f0e5d021 100644 --- a/src/Config/Config_ValidatorMessage.cpp +++ b/src/Config/Config_ValidatorMessage.cpp @@ -1,7 +1,7 @@ /* * Config_ValidatorMessage.cpp * - * Created on: 08 Jul 2014 ã. + * Created on: 08 Jul 2014 �. * Author: sbh */ @@ -19,11 +19,6 @@ Config_ValidatorMessage::~Config_ValidatorMessage() { } -//static const const char* Config_ValidatorMessage::UID() const -//{ -// return "ValidatorMessage"; -//} - const std::string& Config_ValidatorMessage::validatorId() const { return myValidatorId; diff --git a/src/Config/Config_ValidatorMessage.h b/src/Config/Config_ValidatorMessage.h index 16ec27922..ada7a7e13 100644 --- a/src/Config/Config_ValidatorMessage.h +++ b/src/Config/Config_ValidatorMessage.h @@ -1,7 +1,7 @@ /* * Config_ValidatorMessage.h * - * Created on: 08 Jul 2014 ã. + * Created on: 08 Jul 2014 �. * Author: sbh */ @@ -14,7 +14,7 @@ #include #include -/// Event ID that feature is loaded (comes with Config_FeatureMessage) +/// Event ID that Validator is loaded (comes with Config_ValidatorMessage) static const char * EVENT_VALIDATOR_LOADED = "ValidatorLoaded"; class Config_ValidatorMessage : public Events_Message diff --git a/src/Config/Config_WidgetAPI.cpp b/src/Config/Config_WidgetAPI.cpp index 085648e97..bf079781b 100644 --- a/src/Config/Config_WidgetAPI.cpp +++ b/src/Config/Config_WidgetAPI.cpp @@ -99,15 +99,15 @@ std::string Config_WidgetAPI::widgetId() const std::string Config_WidgetAPI::widgetIcon() const { - return getProperty(ANY_WDG_ICON); + return getProperty(ATTR_ICON); } std::string Config_WidgetAPI::widgetLabel() const { - return getProperty(ANY_WDG_LABEL); + return getProperty(ATTR_LABEL); } std::string Config_WidgetAPI::widgetTooltip() const { - return getProperty(ANY_WDG_TOOLTIP); + return getProperty(ATTR_TOOLTIP); } diff --git a/src/Config/Config_WidgetReader.cpp b/src/Config/Config_WidgetReader.cpp index e4125b3e6..3cc97fdd7 100644 --- a/src/Config/Config_WidgetReader.cpp +++ b/src/Config/Config_WidgetReader.cpp @@ -54,7 +54,9 @@ void Config_WidgetReader::processNode(xmlNodePtr theNode) bool Config_WidgetReader::processChildren(xmlNodePtr theNode) { //Read all nodes recursively, source and validator nodes have no children - return !isNode(theNode, NODE_VALIDATOR, NODE_SOURCE, NULL); + return !isNode(theNode, NODE_VALIDATOR, + NODE_SELFILTER, + NODE_SOURCE, NULL); } void Config_WidgetReader::resolveSourceNodes(xmlNodePtr theNode) diff --git a/src/Config/Config_XMLReader.cpp b/src/Config/Config_XMLReader.cpp index 818180e11..0f32adeec 100644 --- a/src/Config/Config_XMLReader.cpp +++ b/src/Config/Config_XMLReader.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -88,6 +89,8 @@ void Config_XMLReader::processNode(xmlNodePtr theNode) #endif } else if (isNode(theNode, NODE_VALIDATOR, NULL)) { processValidator(theNode); + } else if (isNode(theNode, NODE_SELFILTER, NULL)) { + processSelectionFilter(theNode); } } @@ -184,3 +187,21 @@ void Config_XMLReader::processValidator(xmlNodePtr theNode) } aEvLoop->send(aMessage); } + +void Config_XMLReader::processSelectionFilter(xmlNodePtr theNode) +{ + Events_ID aFilterEvent = Events_Loop::eventByName(EVENT_SELFILTER_LOADED); + Events_Loop* aEvLoop = Events_Loop::loop(); + std::shared_ptr aMessage = + std::make_shared(aFilterEvent, this); + std::string aSelectionFilterId = getProperty(theNode, _ID); + aMessage->setSelectionFilterId(aSelectionFilterId); + xmlNodePtr aFeatureOrWdgNode = theNode->parent; + if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) { + aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID)); + } else { + aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID)); + aMessage->setFeatureId(myCurrentFeature); + } + aEvLoop->send(aMessage); +} diff --git a/src/Config/Config_XMLReader.h b/src/Config/Config_XMLReader.h index 9ca7ca8e5..b41790c59 100644 --- a/src/Config/Config_XMLReader.h +++ b/src/Config/Config_XMLReader.h @@ -49,6 +49,7 @@ class Config_XMLReader xmlNodePtr node(void* theNode); std::string getNodeName(xmlNodePtr theNode); void processValidator(xmlNodePtr theNode); + void processSelectionFilter(xmlNodePtr theNode); protected: std::string myCurrentFeature; diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp index 4e0ceee4c..2d2f45673 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp @@ -24,7 +24,7 @@ ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent, { QString aText = QString::fromStdString(theData->widgetLabel()); QString aToolTip = QString::fromStdString(theData->widgetTooltip()); - bool isChecked = theData->getBooleanAttribute(ANY_WDG_DEFAULT, false); + bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false); myCheckBox = new QCheckBox(aText, theParent); myCheckBox->setToolTip(aToolTip); diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 7400d7f7d..aae0a35a0 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -77,7 +77,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, mySpinBox->setSingleStep(aStepVal); } - aProp = theData->getProperty(ANY_WDG_DEFAULT); + aProp = theData->getProperty(ATTR_DEFAULT); double aDefVal = QString::fromStdString(aProp).toDouble(&isOk); if (isOk) { mySpinBox->setValue(aDefVal); diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index d000e87e0..616558f83 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -73,7 +73,7 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent) //Create a widget (doublevalue, groupbox, toolbox, etc. QWidget* aWidget = createWidgetByType(aWdgType, theParent); if (aWidget) { - if (!myWidgetApi->getBooleanAttribute(ATTRIBUTE_INTERNAL, false)) { + if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) { aWidgetLay->addWidget(aWidget); } else { aWidget->setVisible(false); diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index d83e41b6b..208b6d0eb 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -76,6 +76,7 @@ +