Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / genericgui / YACSGuiLoader.cxx
1
2 #include "YACSGuiLoader.hxx"
3 #include "Proc.hxx"
4 #include "Node.hxx"
5
6 //#define _DEVDEBUG_
7 #include "YacsTrace.hxx"
8
9 using namespace std;
10 using namespace YACS::HMI;
11 using namespace YACS::ENGINE;
12
13 static presentationtype_parser presentation_parser;
14
15 YACSGuiLoader::YACSGuiLoader()
16   : YACSLoader()
17 {
18   presentation_parser.collector_ = this;
19   _defaultParsersMap.insert(make_pair("presentation", &presentation_parser));
20   _inputMap.clear();
21   _prsMap.clear();
22 }
23
24 YACSGuiLoader::~YACSGuiLoader()
25 {
26 }
27
28 YACS::ENGINE::Proc* YACSGuiLoader::load(const char *filename)
29 {
30   _inputMap.clear();
31   YACS::YACSLoader::load(filename);
32 }
33
34 std::map<YACS::ENGINE::Node*, PrsData> YACSGuiLoader::getPrsData(YACS::ENGINE::Proc* proc)
35 {
36   _prsMap.clear();
37
38   if (_defaultParsersMap.empty()) return _prsMap;
39
40   for (map<string, PrsData>::iterator it = _inputMap.begin(); it != _inputMap.end(); ++it)
41   {
42     Node* node = 0;
43     string name = (*it).first;
44
45     if (name != "__ROOT__")
46       node = proc->getChildByName(name);
47     else
48       node = proc;
49
50     _prsMap[node] = (*it).second;
51   }
52   return _prsMap;
53 }
54
55 void YACSGuiLoader::process(std::string theElement, bool theNewLink)
56 {
57   if(theElement == "presentation")
58   {
59     if ( _defaultParsersMap["presentation"] )
60     {
61       presentationtype_parser* aP = (presentationtype_parser*)_defaultParsersMap["presentation"];
62       _inputMap[aP->name_] = PrsData(aP->x_, aP->y_, aP->width_, aP->height_);
63       DEBTRACE(aP->name_ << " " << aP->x_ << " " << aP->y_ << " " <<  aP->width_ << " " << aP->height_);
64     }
65   }
66 }