Version: 9.16.0
YACSGuiLoader.hxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
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.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef _YACSGUILOADER_HXX_
21#define _YACSGUILOADER_HXX_
22
23#include <parsers.hxx>
24
25#include <map>
26#include <string>
27#include <QString>
28
29namespace YACS
30{
31 namespace ENGINE
32 {
33 class Node;
34 class Proc;
35 }
36
37 namespace HMI
38 {
39
40 struct PrsData
41 {
42 float _x, _y;
44 float _expx, _expy;
48
50 {
51 _x = _y = 0;
52 _width = _height = 1.;
53 _expx = _expy = 0;
55 _expanded = true;
56 _shownState = 0;
57 }
58
59 PrsData(float x,
60 float y,
61 float width,
62 float height,
63 float expx,
64 float expy,
65 float expWidth,
66 float expHeight,
67 bool expanded,
68 int shownState)
69 {
70 _x = x;
71 _y = y;
72 _width = width;
73 _height = height;
74 _expx = expx;
75 _expy = expy;
76 _expWidth = expWidth;
77 _expHeight = expHeight;
78 _expanded = expanded;
80 }
81 };
82
88 {
89 public:
91 virtual ~YACSGuiLoader();
92 virtual void reset();
93
94 virtual YACS::ENGINE::Proc* load (const char *filename);
95 std::map<YACS::ENGINE::Node*, PrsData> getPrsData(YACS::ENGINE::Proc* proc);
96
97 void process(std::string element, bool newLink = false);
98
99 private:
100 std::map<YACS::ENGINE::Node*, PrsData> _prsMap;
101 std::map<std::string, PrsData> _inputMap;
102 };
103
108 {
109 std::string name_;
110 float x_, y_;
112 float expx_, expy_;
116
118
120 {
121 collector_ = 0;
122 }
123
124 virtual void onStart(const XML_Char* el, const XML_Char** attr)
125 {
126 std::string element(el);
127 parser* pp=&main_parser;
129 pp->init();
130 pp->pre();
131 pp->buildAttr(attr);
132 }
133
134 virtual void buildAttr(const XML_Char** attr)
135 {
136 required("name",attr);
137 required("x",attr);
138 required("y",attr);
139 required("width",attr);
140 required("height",attr);
141 //required("expanded", attr);
142 for (int i = 0; attr[i]; i += 2)
143 {
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]);
155 }
156
157 if ( collector_ )
158 collector_->process("presentation");
159 }
160
161 virtual void pre ()
162 {
163 name_ = "";
164 x_ = y_ = 0.;
165 width_ = height_ = 1;
166 expx_ = expy_ = 0.;
167 expanded_ = true;
168 shownState_ = 0;
169 }
170
171 virtual void name(const std::string& name)
172 {
173 name_ = name;
174 }
175
176 virtual void x(const std::string& x)
177 {
178 x_ = QString(x.c_str()).toFloat();
179 }
180
181 virtual void y(const std::string& y)
182 {
183 y_ = QString(y.c_str()).toFloat();
184 }
185
186 virtual void width(const std::string& width)
187 {
188 width_ = QString(width.c_str()).toFloat();
189 }
190
191 virtual void height(const std::string& height)
192 {
193 height_ = QString(height.c_str()).toFloat();
194 }
195
196 virtual void expx(const std::string& x)
197 {
198 expx_ = QString(x.c_str()).toFloat();
199 }
200
201 virtual void expy(const std::string& y)
202 {
203 expy_ = QString(y.c_str()).toFloat();
204 }
205
206 virtual void expWidth(const std::string& x)
207 {
208 expWidth_ = QString(x.c_str()).toFloat();
209 }
210
211 virtual void expHeight(const std::string& y)
212 {
213 expHeight_ = QString(y.c_str()).toFloat();
214 }
215
216 virtual void expanded(const std::string& expanded)
217 {
218 expanded_ = QString(expanded.c_str()).toInt();
219 }
220
221 virtual void shownState(const std::string& shownState)
222 {
223 shownState_ = QString(shownState.c_str()).toInt();
224 }
225 };
226
227
228 }
229}
230
231#endif
Base class for all schema objects.
Definition: Proc.hxx:44
std::map< YACS::ENGINE::Node *, PrsData > _prsMap
void process(std::string element, bool newLink=false)
std::map< std::string, PrsData > _inputMap
std::map< YACS::ENGINE::Node *, PrsData > getPrsData(YACS::ENGINE::Proc *proc)
virtual YACS::ENGINE::Proc * load(const char *filename)
char XML_Char
Definition: parserBase.hxx:37
PrsData(float x, float y, float width, float height, float expx, float expy, float expWidth, float expHeight, bool expanded, int shownState)
virtual void name(const std::string &name)
virtual void expy(const std::string &y)
virtual void x(const std::string &x)
virtual void buildAttr(const XML_Char **attr)
virtual void y(const std::string &y)
virtual void expWidth(const std::string &x)
virtual void width(const std::string &width)
virtual void expHeight(const std::string &y)
virtual void expx(const std::string &x)
virtual void onStart(const XML_Char *el, const XML_Char **attr)
virtual void shownState(const std::string &shownState)
virtual void expanded(const std::string &expanded)
virtual void height(const std::string &height)
virtual void init()
Definition: parserBase.cxx:86
virtual void pre()
Definition: parserBase.hxx:61
virtual void SetUserDataAndPush(parser *pp)
Definition: parserBase.cxx:55
virtual void required(const std::string &name, const XML_Char **attr)
Definition: parserBase.cxx:186
virtual void buildAttr(const XML_Char **attr)
Definition: parserBase.cxx:195
static parser main_parser
Definition: parserBase.hxx:41