Salome HOME
Processing of 'selection_filter' xml nodes added.
authorsbh <sergey.belash@opencascade.com>
Tue, 9 Dec 2014 11:27:11 +0000 (14:27 +0300)
committersbh <sergey.belash@opencascade.com>
Tue, 9 Dec 2014 11:27:11 +0000 (14:27 +0300)
16 files changed:
src/Config/CMakeLists.txt
src/Config/Config_Common.cpp
src/Config/Config_FeatureReader.cpp
src/Config/Config_Keywords.h
src/Config/Config_SelectionFilterMessage.cpp [new file with mode: 0644]
src/Config/Config_SelectionFilterMessage.h [new file with mode: 0644]
src/Config/Config_ValidatorMessage.cpp
src/Config/Config_ValidatorMessage.h
src/Config/Config_WidgetAPI.cpp
src/Config/Config_WidgetReader.cpp
src/Config/Config_XMLReader.cpp
src/Config/Config_XMLReader.h
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/SketchPlugin/plugin-Sketch.xml

index ab42ba19335b0d30ff217564b89743d9e5d35e1f..b274350bbd4e82f5e8b7bb298d8906ccfdff9fa1 100644 (file)
@@ -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
index a8c6df0a55ceafc3d9983aaa00f667cd963d68fb..cdfa693e3bfe32d92547a36437999e81d53a82e8 100644 (file)
@@ -56,7 +56,7 @@ bool isWidgetNode(xmlNodePtr theNode)
     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
index bf780f3301c0442b94aa05988f351dd8e44dbad3..374efeb6a9830b5bef2a8eed304722ab98b4496f 100644 (file)
@@ -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<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);
   }
index 159f97c1738303aaf76f266f65f1e084cf069d44..511cfea0d02e980acd38608936be5ae06cfba1c2 100644 (file)
@@ -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 (file)
index 0000000..05a82a0
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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;
+}
+
diff --git a/src/Config/Config_SelectionFilterMessage.h b/src/Config/Config_SelectionFilterMessage.h
new file mode 100644 (file)
index 0000000..92b1aa2
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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_ */
index 61ee376c00d87c6b7f9ba2a1bffa3676137b1ccf..5f0e5d02146bad91b488365d15ede070e4c31408 100644 (file)
@@ -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;
index 16ec279222b136d3d9c06fbe46ee7132e36b0c51..ada7a7e13a206631526d5205cf842ae477a37ead 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Config_ValidatorMessage.h
  *
- *  Created on: 08 Jul 2014 ã.
+ *  Created on: 08 Jul 2014 .
  *      Author: sbh
  */
 
@@ -14,7 +14,7 @@
 #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
index 085648e9708b5f6d6f1d96bd5bbd6146aba02608..bf079781bff7391ba8aca04a3b38d8f0ea083d9d 100644 (file)
@@ -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);
 }
index e4125b3e688049f15812d0e01188d0c4cb74def5..3cc97fdd7c2465f946273e9ce1ed2e6983a153f4 100644 (file)
@@ -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)
index 818180e1129bc0705176edb88dd9ed98bdf17b4c..0f32adeecf5c69998fd011668d3fb181478b68ef 100644 (file)
@@ -9,6 +9,7 @@
 #include <Config_Keywords.h>
 #include <Config_Common.h>
 #include <Config_ValidatorMessage.h>
+#include <Config_SelectionFilterMessage.h>
 #include <Config_PropManager.h>
 
 #include <Events_Loop.h>
@@ -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<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);
+}
index 9ca7ca8e59f2d81e344d2eeaaf6eb228008cdca8..b41790c59b50e5912b523b3c0950a009d9079fb5 100644 (file)
@@ -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;
index 4e0ceee4c1dfb7e405798432d9882c7b3b5ebcd3..2d2f45673d7bbe58f6f0465e66d32b6676e40198 100644 (file)
@@ -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);
index 7400d7f7d48db95bc329456d6a75aa6c7a567282..aae0a35a05d53c420160ebbf97a7dd26e2392401 100644 (file)
@@ -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);
index d000e87e090771aaf7e268dfe68deaa435f2d78d..616558f838cda5159727fe98818ef39b89938046 100644 (file)
@@ -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);
index d83e41b6b8ba90720f37de56b0d0231e1ebd1399..208b6d0eb2fdacce51f0ec351415a8681b241882 100644 (file)
@@ -76,6 +76,7 @@
                <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"