if (isNode(theNode, NODE_WORKBENCH, NULL)) {
myLastWorkbench = getProperty(theNode, _ID);
}
+ //Process SOURCE nodes.
+ Config_XMLReader::processNode(theNode);
}
bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
const static char* NODE_WORKBENCH = "workbench";
const static char* NODE_GROUP = "group";
const static char* NODE_FEATURE = "feature";
+const static char* NODE_SOURCE = "source";
+
//Widgets
const static char* WDG_DOUBLEVALUE = "doublevalue";
//Widget containers
const static char* WDG_SWITCH = "switch";
const static char* WDG_SWITCH_CASE = "case";
-
const static char* _ID = "id";
//const static char* WORKBENCH_ID = "id";
//const static char* GROUP_ID = "id";
const static char* FEATURE_TOOLTIP = "tooltip";
const static char* FEATURE_ICON = "icon";
const static char* FEATURE_KEYSEQUENCE = "keysequence";
+const static char* SOURCE_FILE = "path";
+
// doublevalue properties:
const static char* DOUBLE_WDG_MIN = "min";
return myDescriptionCache[theFeatureName];
}
+
void Config_WidgetReader::processNode(xmlNodePtr theNode)
{
if (isNode(theNode, NODE_FEATURE, NULL)) {
- std::string result = "";
std::string aNodeName = getProperty(theNode, _ID);
- if (hasChild(theNode)) {
- xmlBufferPtr buffer = xmlBufferCreate();
- int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
- result = std::string((char*) buffer->content);
- }
- myWidgetCache[aNodeName] = result;
+ myWidgetCache[aNodeName] = dumpNode(theNode);;
myDescriptionCache[aNodeName] = getProperty(theNode, FEATURE_TEXT);
}
+ //Process SOURCE nodes.
+ Config_XMLReader::processNode(theNode);
}
bool Config_WidgetReader::processChildren(xmlNodePtr theNode)
{
return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
}
+
+std::string Config_WidgetReader::dumpNode(xmlNodePtr theNode)
+{
+ std::string result = "";
+ if (!hasChild(theNode)) {
+ return result;
+ }
+ xmlNodePtr aChildrenNode = xmlFirstElementChild(theNode);
+ xmlBufferPtr buffer = xmlBufferCreate();
+ if (isNode(aChildrenNode, NODE_SOURCE, NULL)) {
+ Config_XMLReader aSourceReader =
+ Config_XMLReader(getProperty(aChildrenNode, SOURCE_FILE));
+ xmlNodePtr aSourceRoot = aSourceReader.findRoot();
+ int size = xmlNodeDump(buffer, aSourceRoot->doc, aSourceRoot, 0, 1);
+ } else {
+ int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
+ }
+ result = std::string((char*) (buffer->content));
+ return result;
+}
protected:
void processNode(xmlNodePtr theNode);
bool processChildren(xmlNodePtr theNode);
+ std::string dumpNode(xmlNodePtr theNode);
private:
std::map<std::string, std::string> myWidgetCache;
*/
#include <Config_XMLReader.h>
+#include <Config_Keywords.h>
+#include <Config_Common.h>
#include <Event_Loop.h>
#include <libxml/parser.h>
* The default implementation does nothing. (In debug mode prints
* some info)
*/
-void Config_XMLReader::processNode(xmlNodePtr aNode)
+void Config_XMLReader::processNode(xmlNodePtr theNode)
{
-#ifdef _DEBUG
- std::cout << "Config_XMLReader::processNode: "
- << aNode->name << " content: "
- << aNode->content << std::endl;
-#endif
+ if (isNode(theNode, NODE_SOURCE, NULL)) {
+ std::string aSourceFile = getProperty(theNode, SOURCE_FILE);
+ Config_XMLReader aSourceReader = Config_XMLReader(aSourceFile);
+ readRecursively(aSourceReader.findRoot());
+ #ifdef _DEBUG
+ std::cout << "Config_XMLReader::sourced node: " << aSourceFile << std::endl;
+ #endif
+ }
}
/*
#endif
return NULL;
}
-
xmlNodePtr aRoot = xmlDocGetRootElement(myXmlDoc);
#ifdef _DEBUG
if(aRoot == NULL) {
CONFIG_EXPORT void readAll();
+public:
+ CONFIG_EXPORT xmlNodePtr findRoot();
+
protected:
virtual void processNode(xmlNodePtr aNode);
virtual bool processChildren(xmlNodePtr aNode);
- xmlNodePtr findRoot();
void readRecursively(xmlNodePtr theParent);
xmlNodePtr node(void* theNode);
SET(XML_RESOURCES
plugin-Construction.xml
+ point_widget.xml
)
INSTALL(TARGETS ConstructionPlugin DESTINATION plugins)
<workbench id="Construction">
<group id="Basic">
<feature id="Point" text="Point" tooltip="Create a new point" icon=":icons/point.png">
- <doublevalue id="x" label="X:" max="50" step="1.0" default="0" icon=":pictures/x_point.png" tooltip="Set X"/>
- <doublevalue id="y" label="Y:" min="x" default="1" icon=":pictures/y_point.png" tooltip="Set Y"/>
- <doublevalue id="z" label="Z:" min="-20" step="0.1" default="2" icon=":pictures/z_point.png" tooltip="Set Z"/>
+ <source path="point_widget.xml"/>
</feature>
<feature id="Axis" text="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence=""/>
<feature id="Plane" text="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence=""/>
--- /dev/null
+<source>
+ <doublevalue id="x" label="X:" max="50" step="1.0" default="0" icon=":pictures/x_point.png" tooltip="Set X"/>
+ <doublevalue id="y" label="Y:" min="x" default="1" icon=":pictures/y_point.png" tooltip="Set Y"/>
+ <doublevalue id="z" label="Z:" min="-20" step="0.1" default="2" icon=":pictures/z_point.png" tooltip="Set Z"/>
+</source>