Config_Prop.h
Config_PropManager.h
Config_AttributeMessage.h
+ Config_SelectionFilterMessage.h
)
SET(PROJECT_SOURCES
Config_Prop.cpp
Config_PropManager.cpp
Config_AttributeMessage.cpp
+ Config_SelectionFilterMessage.cpp
)
SET(XML_RESOURCES
return false;\r
\r
//it should not be a "source" or a "validator" node\r
- return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NULL);\r
+ return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL);\r
}\r
\r
bool hasChild(xmlNodePtr theNode)\r
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);
}
}
return result;
}
-void Config_FeatureReader::fillFeature(xmlNodePtr theNode,
+void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode,
const std::shared_ptr<Config_FeatureMessage>& 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);
}
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";
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";
/*
--- /dev/null
+/*
+ * Config_SelectionFilterMessage.cpp
+ *
+ * Created on: 08 Jul 2014
+ * Author: sbh
+ */
+
+#include <Config_SelectionFilterMessage.h>
+
+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;
+}
+
--- /dev/null
+/*
+ * Config_SelectionFilterMessage.h
+ *
+ * Created on: 08 Jul 2014
+ * Author: sbh
+ */
+
+#ifndef CONFIG_SELECTIONFILTERMESSAGE_H_
+#define CONFIG_SELECTIONFILTERMESSAGE_H_
+
+#include <Events_Message.h>
+#include <Config_def.h>
+
+#include <list>
+#include <string>
+
+/// 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_ */
/*
* Config_ValidatorMessage.cpp
*
- * Created on: 08 Jul 2014 ã.
+ * Created on: 08 Jul 2014 �.
* Author: sbh
*/
{
}
-//static const const char* Config_ValidatorMessage::UID() const
-//{
-// return "ValidatorMessage";
-//}
-
const std::string& Config_ValidatorMessage::validatorId() const
{
return myValidatorId;
/*
* Config_ValidatorMessage.h
*
- * Created on: 08 Jul 2014 ã.
+ * Created on: 08 Jul 2014 �.
* Author: sbh
*/
#include <list>
#include <string>
-/// 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
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);
}
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)
#include <Config_Keywords.h>
#include <Config_Common.h>
#include <Config_ValidatorMessage.h>
+#include <Config_SelectionFilterMessage.h>
#include <Config_PropManager.h>
#include <Events_Loop.h>
#endif
} else if (isNode(theNode, NODE_VALIDATOR, NULL)) {
processValidator(theNode);
+ } else if (isNode(theNode, NODE_SELFILTER, NULL)) {
+ processSelectionFilter(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<Config_SelectionFilterMessage> aMessage =
+ std::make_shared<Config_SelectionFilterMessage>(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);
+}
xmlNodePtr node(void* theNode);
std::string getNodeName(xmlNodePtr theNode);
void processValidator(xmlNodePtr theNode);
+ void processSelectionFilter(xmlNodePtr theNode);
protected:
std::string myCurrentFeature;
{
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);
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);
//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);
<sketch_constraint_shape_selector id="ConstraintEntityA"
label="First line" tooltip="Select an line in the viewer"
shape_types="edge" use_subshapes="true">
+ <selection_filter id="LinearEdgeFilter"/>
</sketch_constraint_shape_selector>
<sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer"