]> SALOME platform Git repositories - modules/shaper.git/blob - src/Config/Config_FeatureReader.cpp
Salome HOME
Container widgets processing for the PropertyPanel added
[modules/shaper.git] / src / Config / Config_FeatureReader.cpp
1 /*
2  * Config_FeatureReader.cpp
3  *
4  *  Created on: Mar 20, 2014
5  *      Author: sbh
6  */
7
8 #include <Config_Keywords.h>
9 #include <Config_Common.h>
10 #include <Config_FeatureMessage.h>
11 #include <Config_FeatureReader.h>
12 #include <Event_Message.h>
13 #include <Event_Loop.h>
14
15 #include <libxml/parser.h>
16 #include <libxml/tree.h>
17 #include <libxml/xmlstring.h>
18
19 #include <string>
20
21 #ifdef _DEBUG
22 #include <iostream>
23 #endif
24
25
26 Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
27                                            const std::string& theLibraryName,
28                                            const char* theEventGenerated)
29     : Config_XMLReader(theXmlFile),
30       myLibraryName(theLibraryName),
31       myEventGenerated(theEventGenerated ? theEventGenerated : "FeatureEvent")
32 {
33 }
34
35 Config_FeatureReader::~Config_FeatureReader()
36 {
37 }
38
39 void Config_FeatureReader::processNode(xmlNodePtr theNode)
40 {
41   Event_ID aMenuItemEvent = Event_Loop::eventByName(myEventGenerated);
42   if (isNode(theNode, NODE_FEATURE, NULL)) {
43     Event_Loop* aEvLoop = Event_Loop::loop();
44     Config_FeatureMessage aMessage(aMenuItemEvent, this);
45     fillFeature(theNode, aMessage);
46     aEvLoop->send(aMessage);
47   }
48   //The m_last* variables always defined before fillFeature() call. XML is a tree.
49   if (isNode(theNode, NODE_GROUP, NULL)) {
50     myLastGroup = getProperty(theNode, _ID);
51   }
52   if (isNode(theNode, NODE_WORKBENCH, NULL)) {
53     myLastWorkbench = getProperty(theNode, _ID);
54   }
55 }
56
57 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
58 {
59   return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
60 }
61
62 void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFtMessage)
63 {
64   outFtMessage.setId(getProperty(theRoot, _ID));
65   outFtMessage.setText(getProperty(theRoot, FEATURE_TEXT));
66   outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
67   outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
68   outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
69   outFtMessage.setGroupId(myLastGroup);
70   outFtMessage.setWorkbenchId(myLastWorkbench);
71   outFtMessage.setPluginLibrary(myLibraryName);
72 }