1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _YACSGUILOADER_HXX_
21 #define _YACSGUILOADER_HXX_
23 #include <parsers.hxx>
43 float _width, _height;
45 float _expWidth, _expHeight;
52 _width = _height = 1.;
54 _expWidth = _expHeight = 0;
77 _expHeight = expHeight;
79 _shownState = shownState;
84 * Class that extends engine XML loader. It can process the presentation data
85 * not hanled by the base class.
87 class YACSGuiLoader : public YACS::YACSLoader
91 virtual ~YACSGuiLoader();
94 virtual YACS::ENGINE::Proc* load (const char *filename);
95 std::map<YACS::ENGINE::Node*, PrsData> getPrsData(YACS::ENGINE::Proc* proc);
97 void process(std::string element, bool newLink = false);
100 std::map<YACS::ENGINE::Node*, PrsData> _prsMap;
101 std::map<std::string, PrsData> _inputMap;
105 * Struct for parse <presentation .../> element from XML file.
107 struct presentationtype_parser: parser
111 float width_, height_;
113 float expWidth_, expHeight_;
117 YACSGuiLoader* collector_;
119 presentationtype_parser(): parser()
124 virtual void onStart(const XML_Char* el, const XML_Char** attr)
126 std::string element(el);
127 parser* pp=&main_parser;
128 SetUserDataAndPush(pp);
134 virtual void buildAttr(const XML_Char** attr)
136 required("name",attr);
139 required("width",attr);
140 required("height",attr);
141 //required("expanded", attr);
142 for (int i = 0; attr[i]; i += 2)
144 if(std::string(attr[i]) == "name") name(attr[i+1]);
145 if(std::string(attr[i]) == "x") x(attr[i+1]);
146 if(std::string(attr[i]) == "y") y(attr[i+1]);
147 if(std::string(attr[i]) == "width") width(attr[i+1]);
148 if(std::string(attr[i]) == "height") height(attr[i+1]);
149 if(std::string(attr[i]) == "expx") expx(attr[i+1]);
150 if(std::string(attr[i]) == "expy") expy(attr[i+1]);
151 if(std::string(attr[i]) == "expWidth") expWidth(attr[i+1]);
152 if(std::string(attr[i]) == "expHeight") expHeight(attr[i+1]);
153 if(std::string(attr[i]) == "expanded") expanded(attr[i+1]);
154 if(std::string(attr[i]) == "shownState") shownState(attr[i+1]);
158 collector_->process("presentation");
165 width_ = height_ = 1;
171 virtual void name(const std::string& name)
176 virtual void x(const std::string& x)
178 x_ = QString(x.c_str()).toFloat();
181 virtual void y(const std::string& y)
183 y_ = QString(y.c_str()).toFloat();
186 virtual void width(const std::string& width)
188 width_ = QString(width.c_str()).toFloat();
191 virtual void height(const std::string& height)
193 height_ = QString(height.c_str()).toFloat();
196 virtual void expx(const std::string& x)
198 expx_ = QString(x.c_str()).toFloat();
201 virtual void expy(const std::string& y)
203 expy_ = QString(y.c_str()).toFloat();
206 virtual void expWidth(const std::string& x)
208 expWidth_ = QString(x.c_str()).toFloat();
211 virtual void expHeight(const std::string& y)
213 expHeight_ = QString(y.c_str()).toFloat();
216 virtual void expanded(const std::string& expanded)
218 expanded_ = QString(expanded.c_str()).toInt();
221 virtual void shownState(const std::string& shownState)
223 shownState_ = QString(shownState.c_str()).toInt();