34 QString data =
getData(filename);
39 QScriptValue vadata = engine.evaluate(
"(" + data +
")");
43 QScriptValue entries = vadata.property(
"property");
45 QScriptValueIterator it(entries);
47 while (it.hasNext()) {
50 QScriptValue entry = it.value();
53 if (it.name().compare(
"length")) {
55 QString value =
getString(entry,
"value");
56 QString display =
getString(entry,
"display");
63 if (!display.compare(
"false"))
94 p->
Props.getFirst()->Value =
Props.getFirst()->Value;
111 bool getNewOne, QString filename)
114 QString data =
getData(filename);
116 QScriptEngine engine;
117 QScriptValue vadata = engine.evaluate(
"(" + data +
")");
123 BitmapFile =
getString(vadata,
"BitmapFile");
139 QMap<QString, Qt::BrushStyle> brushMap;
140 QMap<QString, Qt::PenStyle> penMap;
142 brushMap.insert(
"Qt::NoBrush", Qt::NoBrush);
143 brushMap.insert(
"Qt::SolidPattern", Qt::SolidPattern);
144 brushMap.insert(
"Qt::Dense1Pattern", Qt::Dense1Pattern);
145 brushMap.insert(
"Qt::Dense2Pattern", Qt::Dense2Pattern);
146 brushMap.insert(
"Qt::Dense3Pattern", Qt::Dense3Pattern);
147 brushMap.insert(
"Qt::Dense4Pattern", Qt::Dense4Pattern);
148 brushMap.insert(
"Qt::Dense5Pattern", Qt::Dense5Pattern);
149 brushMap.insert(
"Qt::Dense6Pattern", Qt::Dense6Pattern);
150 brushMap.insert(
"Qt::Dense7Pattern", Qt::Dense7Pattern);
151 brushMap.insert(
"Qt::HorPattern", Qt::HorPattern);
152 brushMap.insert(
"Qt::VerPattern", Qt::VerPattern);
153 brushMap.insert(
"Qt::CrossPattern", Qt::CrossPattern);
154 brushMap.insert(
"Qt::BDiagPattern", Qt::BDiagPattern);
155 brushMap.insert(
"Qt::FDiagPattern", Qt::FDiagPattern);
156 brushMap.insert(
"Qt::DiagCrossPattern", Qt::DiagCrossPattern);
158 penMap.insert(
"Qt::NoPen", Qt::NoPen);
159 penMap.insert(
"Qt::SolidLine", Qt::SolidLine);
160 penMap.insert(
"Qt::DashLine", Qt::DashLine);
161 penMap.insert(
"Qt::DotLine", Qt::DotLine);
162 penMap.insert(
"Qt::DashDotLine", Qt::DashDotLine);
163 penMap.insert(
"Qt::DashDotDotLine", Qt::DashDotDotLine);
164 penMap.insert(
"Qt::CustomDashLine", Qt::CustomDashLine);
167 QString data =
getData(filename);
169 QScriptEngine engine;
170 QScriptValue vadata = engine.evaluate(
"(" + data +
")");
173 QScriptValue entries = vadata.property(
"paintings");
175 QScriptValueIterator it(entries);
176 while (it.hasNext()) {
179 qreal x,
x1,
x2, y,
y1,
y2, w, h, thick, angle, arclen;
180 qreal size, cos, sin;
181 QString color, style , colorfill, stylefill, s;
183 QScriptValue entry = it.value();
186 if (!type.compare(
"line")) {
196 QPen (QColor (color), thick, penMap.value(style))));
199 if (!type.compare(
"rectangle")) {
207 colorfill =
getString(entry,
"colorfill");
208 stylefill =
getString(entry,
"stylefill");
211 QPen (QColor (color), thick, penMap.value(style)),
212 QBrush(QColor (colorfill), brushMap.value(stylefill))
216 if (!type.compare(
"ellipse")) {
224 colorfill =
getString(entry,
"colorfill");
225 stylefill =
getString(entry,
"stylefill");
228 QPen (QColor (color), thick, penMap.value(style)),
229 QBrush(QColor (colorfill), brushMap.value(stylefill))
233 if (!type.compare(
"ellipsearc")) {
244 Arcs.append (
new Arc (x, y, w, h, angle, arclen,
245 QPen (QColor (color), thick, penMap.value(style))));
248 if (!type.compare(
"portsymbol")) {
254 if (!type.compare(
"graphictext")) {
263 QColor (color), size, cos, sin));
266 if (!type.compare(
"arrow")) {
275 QPen (QColor (color), thick, penMap.value(style))));
296 QFile file(filename);
297 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
298 QMessageBox::critical(0, QObject::tr(
"Error"),
299 QObject::tr(
"Symbol file not found: %1").arg(filename));
304 QTextStream in(&file);
307 QString data = (QString) in.readAll();
321 return data.property(prop).toString().toDouble();
331 return data.property(prop).toString();
virtual Component * newOne()
Q3PtrList< struct Arc > Arcs
double getDouble(QScriptValue data, QString prop)
getDouble Helper to get a property out of a JSON script
void createSymbol(QString filename)
vacomponent::createSymbol Constructor call this to create the symbol.
Q3PtrList< Property > Props
QString getData(QString filename)
getData Reads the JSON file
static Element * info(QString &, QString &, bool getNewOne=false, QString filename="")
vacomponent::info is used to either get information or create objects.
Superclass of all schematic drawing elements.
vacomponent(QString filename)
vacomponent::vacomponent
QString getString(QScriptValue data, QString prop)
getString Helper to get a property out of a JSON script
Definition of the vacomponent class.
virtual void recreate(Schematic *)