##// END OF EJS Templates
Sync
Jeandet Alexis -
r11:10ac2f44ce26 default
parent child
Show More
@@ -1,1172 +1,1183
1 1 #include "qicadpcb.h"
2 2
3 3
4 4 QIlib::QIcadPcb::QIcadPcb()
5 5 :pcbRoot(NULL)
6 6 {
7 7
8 8 }
9 9
10 10 bool QIlib::QIcadPcb::parsePcb(const QString &pcb)
11 11 {
12 12 parse(pcb.toStdString().c_str());
13 13 updateConcreteTree();
14 14 return false;
15 15 }
16 16
17 17 QString QIlib::QIcadPcb::toString()
18 18 {
19 19
20 20 }
21 21
22 22 QString QIlib::QIcadPcb::print()
23 23 {
24 24 return rootNode.print();
25 25 }
26 26
27 27
28 28 void QIlib::QIcadPcb::updateConcreteTree()
29 29 {
30 30 if(this->rootNode.nodes.count())
31 31 {
32 32 if(this->rootNode.nodes.at(0)->name==QIlib::Lexique::kicad_pcb_c)
33 33 {
34 34 if(this->pcbRoot==NULL)
35 35 {
36 36 this->pcbRoot = new QIcadPcbRoot(this->rootNode.nodes.at(0));
37 37 }
38 38 }
39 39 }
40 40 }
41 41
42 42
43 43 QIlib::QIcadPcbRoot::QIcadPcbRoot(QIlib::AbstractNode *node)
44 44 :QIcadAbstractNodeWrapper(node)
45 45 {
46 46 this->setNode(node);
47 47 }
48 48
49 49 void QIlib::QIcadPcbRoot::setNode(QIlib::AbstractNode *node)
50 50 {
51 51 this->clrNets();
52 52 this->clrModules();
53 53 this->clrDimensions();
54 54 this->clrLines();
55 55 this->clrSegments();
56 56 this->clrVias();
57 57 this->clrArcs();
58 58 this->clrCircles();
59 59 this->clrTexts();
60 60 this->clrZones();
61 61 if(node->name==QIlib::Lexique::kicad_pcb_c)
62 62 {
63 63 this->p_node = node;
64 64 for(int i=0;i<node->nodes.count();i++)
65 65 {
66 66 if(node->nodes.at(i)->name==QIlib::Lexique::version_c)
67 67 {
68 68 this->version.setNode(node->nodes.at(i));
69 69 }
70 70 if(node->nodes.at(i)->name==QIlib::Lexique::host_c)
71 71 {
72 72 this->host.setNode(node->nodes.at(i));
73 73 }
74 74 if(node->nodes.at(i)->name==QIlib::Lexique::page_c)
75 75 {
76 76 this->page.setNode(node->nodes.at(i));
77 77 }
78 78 if(node->nodes.at(i)->name==QIlib::Lexique::general_c)
79 79 {
80 80 this->general.setNode(node->nodes.at(i));
81 81 }
82 82 if(node->nodes.at(i)->name==QIlib::Lexique::layers_c)
83 83 {
84 84 this->layers.setNode(node->nodes.at(i));
85 85 }
86 86 if(node->nodes.at(i)->name==QIlib::Lexique::setup_c)
87 87 {
88 88 this->setup.setNode(node->nodes.at(i));
89 89 }
90 90 if(node->nodes.at(i)->name==QIlib::Lexique::net_c)
91 91 {
92 92 this->apendNet(node->nodes.at(i));
93 93 }
94 94 if(node->nodes.at(i)->name==QIlib::Lexique::module_c)
95 95 {
96 96 this->apendModule(node->nodes.at(i));
97 97 }
98 98 if(node->nodes.at(i)->name==QIlib::Lexique::gr_line_c)
99 99 {
100 100 this->apendLine(node->nodes.at(i));
101 101 }
102 102 if(node->nodes.at(i)->name==QIlib::Lexique::dimension_c)
103 103 {
104 104 this->apendDimension(node->nodes.at(i));
105 105 }
106 106 if(node->nodes.at(i)->name==QIlib::Lexique::via_c)
107 107 {
108 108 this->apendVia(node->nodes.at(i));
109 109 }
110 110 if(node->nodes.at(i)->name==QIlib::Lexique::segment_c)
111 111 {
112 112 this->apendSegment(node->nodes.at(i));
113 113 }
114 114 if(node->nodes.at(i)->name==QIlib::Lexique::gr_text_c)
115 115 {
116 116 this->apendText(node->nodes.at(i));
117 117 }
118 118 if(node->nodes.at(i)->name==QIlib::Lexique::gr_arc_c)
119 119 {
120 120 this->apendArc(node->nodes.at(i));
121 121 }
122 122 if(node->nodes.at(i)->name==QIlib::Lexique::gr_circle_c)
123 123 {
124 124 this->apendCircle(node->nodes.at(i));
125 125 }
126 126 if(node->nodes.at(i)->name==QIlib::Lexique::zone_c)
127 127 {
128 128 this->apendZone(node->nodes.at(i));
129 129 }
130 130 }
131 131 }
132 132 }
133 133
134 134 void QIlib::QIcadPcbRoot::clrNets()
135 135 {
136 136 while(nets.count())
137 137 {
138 138 QIcadAbstractNodeWrapper* net;
139 139 net = nets.last();
140 140 nets.removeLast();
141 141 delete net;
142 142 }
143 143 }
144 144
145 145 void QIlib::QIcadPcbRoot::apendNet(QIlib::AbstractNode *node)
146 146 {
147 147 if(node->name==QIlib::Lexique::net_c)
148 148 {
149 149 this->nets.append(new QIcadAbstractNodeWrapper(node));
150 150 }
151 151 }
152 152
153 153 void QIlib::QIcadPcbRoot::clrModules()
154 154 {
155 155 while(modules.count())
156 156 {
157 157 QIcadPcbModule* module;
158 158 module = modules.last();
159 159 modules.removeLast();
160 160 delete module;
161 161 }
162 162 }
163 163
164 164 void QIlib::QIcadPcbRoot::apendModule(QIlib::AbstractNode *node)
165 165 {
166 166 if(node->name==QIlib::Lexique::module_c)
167 167 {
168 168 this->modules.append(new QIcadPcbModule(node));
169 169 }
170 170 }
171 171
172 172 void QIlib::QIcadPcbRoot::clrDimensions()
173 173 {
174 174 while(dimensions.count())
175 175 {
176 176 QIcadPcbDimension* dimension;
177 177 dimension = dimensions.last();
178 178 dimensions.removeLast();
179 179 delete dimension;
180 180 }
181 181 }
182 182
183 183 void QIlib::QIcadPcbRoot::apendDimension(QIlib::AbstractNode *node)
184 184 {
185 185 if(node->name==QIlib::Lexique::dimension_c)
186 186 {
187 187 this->dimensions.append(new QIcadPcbDimension(node));
188 188 }
189 189 }
190 190
191 191 void QIlib::QIcadPcbRoot::apendLine(QIlib::AbstractNode *node)
192 192 {
193 193 if(node->name==QIlib::Lexique::gr_line_c)
194 194 {
195 195 this->lines.append(new QIcadPcbLine(node));
196 196 }
197 197 }
198 198
199 199 void QIlib::QIcadPcbRoot::clrLines()
200 200 {
201 201 while(lines.count())
202 202 {
203 203 QIcadPcbLine* line;
204 204 line = lines.last();
205 205 lines.removeLast();
206 206 delete line;
207 207 }
208 208 }
209 209
210 210 void QIlib::QIcadPcbRoot::clrSegments()
211 211 {
212 212 while(segments.count())
213 213 {
214 214 QIcadPcbSegment* segment;
215 215 segment = segments.last();
216 216 segments.removeLast();
217 217 delete segment;
218 218 }
219 219 }
220 220
221 221 void QIlib::QIcadPcbRoot::apendSegment(QIlib::AbstractNode *node)
222 222 {
223 223 if(node->name==QIlib::Lexique::segment_c)
224 224 {
225 225 this->segments.append(new QIcadPcbSegment(node));
226 226 }
227 227 }
228 228
229 229 void QIlib::QIcadPcbRoot::clrVias()
230 230 {
231 231 while(vias.count())
232 232 {
233 233 QIcadPcbVia* via;
234 234 via = vias.last();
235 235 vias.removeLast();
236 236 delete via;
237 237 }
238 238 }
239 239
240 240 void QIlib::QIcadPcbRoot::apendVia(QIlib::AbstractNode *node)
241 241 {
242 242 if(node->name==QIlib::Lexique::via_c)
243 243 {
244 this->vias.append(new QIcadPcbVia(node));
244 this->vias.append(new QIcadPcbVia(node,this->setup.defaultViaDrillSize()));
245 245 }
246 246 }
247 247
248 248 void QIlib::QIcadPcbRoot::clrArcs()
249 249 {
250 250 while(arcs.count())
251 251 {
252 252 QIcadPcbArc* arc;
253 253 arc = arcs.last();
254 254 arcs.removeLast();
255 255 delete arc;
256 256 }
257 257 }
258 258
259 259 void QIlib::QIcadPcbRoot::apendArc(QIlib::AbstractNode *node)
260 260 {
261 261 if(node->name==QIlib::Lexique::gr_arc_c)
262 262 {
263 263 this->arcs.append(new QIcadPcbArc(node));
264 264 }
265 265 }
266 266
267 267 void QIlib::QIcadPcbRoot::clrCircles()
268 268 {
269 269 while(circles.count())
270 270 {
271 271 QIcadPcbCircle* circle;
272 272 circle = circles.last();
273 273 circles.removeLast();
274 274 delete circle;
275 275 }
276 276 }
277 277
278 278 void QIlib::QIcadPcbRoot::apendCircle(QIlib::AbstractNode *node)
279 279 {
280 280 if(node->name==QIlib::Lexique::gr_circle_c)
281 281 {
282 282 this->circles.append(new QIcadPcbCircle(node));
283 283 }
284 284 }
285 285
286 286 void QIlib::QIcadPcbRoot::clrTexts()
287 287 {
288 288 while(texts.count())
289 289 {
290 290 QIcadPcbText* text;
291 291 text = texts.last();
292 292 texts.removeLast();
293 293 delete text;
294 294 }
295 295 }
296 296
297 297 void QIlib::QIcadPcbRoot::apendText(QIlib::AbstractNode *node)
298 298 {
299 299 if(node->name==QIlib::Lexique::gr_text_c)
300 300 {
301 301 this->texts.append(new QIcadPcbText(node));
302 302 }
303 303 }
304 304
305 305 void QIlib::QIcadPcbRoot::clrZones()
306 306 {
307 307 while(zones.count())
308 308 {
309 309 QIcadPcbZone* zone;
310 310 zone = zones.last();
311 311 zones.removeLast();
312 312 delete zone;
313 313 }
314 314 }
315 315
316 316 void QIlib::QIcadPcbRoot::apendZone(QIlib::AbstractNode *node)
317 317 {
318 318 if(node->name==QIlib::Lexique::zone_c)
319 319 {
320 320 this->zones.append(new QIcadPcbZone(node));
321 321 }
322 322 }
323 323
324 324 QIlib::QIcadPcbGeneralInfo::QIcadPcbGeneralInfo(QIlib::AbstractNode *node)
325 325 :QIcadAbstractNodeWrapper(node)
326 326 {
327 327 this->setNode(node);
328 328 }
329 329
330 330 void QIlib::QIcadPcbGeneralInfo::setNode(QIlib::AbstractNode *node)
331 331 {
332 332 if(node->name==QIlib::Lexique::general_c)
333 333 {
334 334 this->p_node = node;
335 335 for(int i=0;i<node->nodes.count();i++)
336 336 {
337 337 if(node->nodes.at(i)->name==QIlib::Lexique::links_c)
338 338 {
339 339 this->links.setNode(node->nodes.at(i));
340 340 }
341 341 if(node->nodes.at(i)->name==QIlib::Lexique::no_connect_c)
342 342 {
343 343 this->no_connections.setNode(node->nodes.at(i));
344 344 }
345 345 if(node->nodes.at(i)->name==QIlib::Lexique::area_c)
346 346 {
347 347 this->area.setNode(node->nodes.at(i));
348 348 }
349 349 if(node->nodes.at(i)->name==QIlib::Lexique::thickness_c)
350 350 {
351 351 this->thickness.setNode(node->nodes.at(i));
352 352 }
353 353 if(node->nodes.at(i)->name==QIlib::Lexique::drawings_c)
354 354 {
355 355 this->drawings.setNode(node->nodes.at(i));
356 356 }
357 357 if(node->nodes.at(i)->name==QIlib::Lexique::tracks_c)
358 358 {
359 359 this->tracks.setNode(node->nodes.at(i));
360 360 }
361 361 if(node->nodes.at(i)->name==QIlib::Lexique::zones_c)
362 362 {
363 363 this->zones.setNode(node->nodes.at(i));
364 364 }
365 365 if(node->nodes.at(i)->name==QIlib::Lexique::modules_c)
366 366 {
367 367 this->modules.setNode(node->nodes.at(i));
368 368 }
369 369 if(node->nodes.at(i)->name==QIlib::Lexique::nets_c)
370 370 {
371 371 this->nets.setNode(node->nodes.at(i));
372 372 }
373 373 }
374 374 }
375 375 }
376 376
377 377
378 378 QIlib::QIcadPcbLayers::QIcadPcbLayers(QIlib::AbstractNode *node)
379 379 :QIcadAbstractNodeWrapper(node)
380 380 {
381 381 this->setNode(node);
382 382 }
383 383
384 384 void QIlib::QIcadPcbLayers::setNode(QIlib::AbstractNode *node)
385 385 {
386 386 this->p_node = node;
387 387 if(node->name==QIlib::Lexique::layers_c)
388 388 {
389 389 this->clrLayers();
390 390 for(int i=0;i<node->nodes.count();i++)
391 391 {
392 392 this->apendLayer(node->nodes.at(i));
393 393 }
394 394 }
395 395 }
396 396
397 397 void QIlib::QIcadPcbLayers::clrLayers()
398 398 {
399 399 while(layers.count())
400 400 {
401 401 QIcadPcbLayer* layer;
402 402 layer = layers.last();
403 403 layers.removeLast();
404 404 delete layer;
405 405 }
406 406 }
407 407
408 408 void QIlib::QIcadPcbLayers::apendLayer(QIlib::AbstractNode *node)
409 409 {
410 410 this->layers.append(new QIcadPcbLayer(node));
411 411 }
412 412
413 413
414 414 QIlib::QIcadPcbLine::QIcadPcbLine(QIlib::AbstractNode *node)
415 415 :QIcadAbstractPcbLine(node)
416 416 {
417 417 this->setNode(node);
418 418 }
419 419
420 420
421 421 void QIlib::QIcadPcbLine::setNode(QIlib::AbstractNode *node)
422 422 {
423 423 if(node->name==QIlib::Lexique::gr_line_c)
424 424 {
425 425 this->p_node = node;
426 426 for(int i=0;i<node->nodes.count();i++)
427 427 {
428 428 if(node->nodes.at(i)->name==QIlib::Lexique::start_c)
429 429 {
430 430 this->p_startpos = nodeTo2DCoords(node->nodes.at(i));
431 431 this->start.setNode(node->nodes.at(i));
432 432 }
433 433 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
434 434 {
435 435 this->p_stoppos = nodeTo2DCoords(node->nodes.at(i));
436 436 this->end.setNode(node->nodes.at(i));
437 437 }
438 438 if(node->nodes.at(i)->name==QIlib::Lexique::angle_c)
439 439 {
440 440 this->angle.setNode(node->nodes.at(i));
441 441 }
442 442 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
443 443 {
444 444 this->p_layers = node->nodes.at(i)->Values;
445 445 this->layer.setNode(node->nodes.at(i));
446 446 }
447 447 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
448 448 {
449 449 this->p_width = nodeValueToDouble(node->nodes.at(i));
450 450 this->width.setNode(node->nodes.at(i));
451 451 }
452 452 }
453 453 }
454 454 }
455 455
456 456
457 457 QIlib::QIcadPcbModule::QIcadPcbModule(QIlib::AbstractNode *node)
458 458 :QIcadAbstractNodeWrapper(node)
459 459 {
460 460 this->setNode(node);
461 461 }
462 462
463 463 const QPointF &QIlib::QIcadPcbModule::pos()
464 464 {
465 465 return p_pos;
466 466 }
467 467
468 468 double QIlib::QIcadPcbModule::angle()
469 469 {
470 470 return p_angle;
471 471 }
472 472
473 473 void QIlib::QIcadPcbModule::setNode(QIlib::AbstractNode *node)
474 474 {
475 475 this->clrPads();
476 476 if(node->name==QIlib::Lexique::module_c)
477 477 {
478 478 this->p_node = node;
479 479 for(int i=0;i<node->nodes.count();i++)
480 480 {
481 481 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
482 482 {
483 483 this->layer.setNode(node->nodes.at(i));
484 484 }
485 485 if(node->nodes.at(i)->name==QIlib::Lexique::tedit_c)
486 486 {
487 487 this->tedit.setNode(node->nodes.at(i));
488 488 }
489 489 if(node->nodes.at(i)->name==QIlib::Lexique::tstamp_c)
490 490 {
491 491 this->tstamp.setNode(node->nodes.at(i));
492 492 }
493 493 if(node->nodes.at(i)->name==QIlib::Lexique::at_c)
494 494 {
495 495 this->at.setNode(node->nodes.at(i));
496 496 QStringList coords=node->nodes.at(i)->Values;
497 497 p_pos = nodeTo2DCoords(node->nodes.at(i));
498 498 if(coords.count()==3)
499 499 {
500 500 p_angle = coords.at(2).toDouble();
501 501 }
502 502 }
503 503 if(node->nodes.at(i)->name==QIlib::Lexique::tags_c)
504 504 {
505 505 this->tags.setNode(node->nodes.at(i));
506 506 }
507 507 if(node->nodes.at(i)->name==QIlib::Lexique::path_c)
508 508 {
509 509 this->path.setNode(node->nodes.at(i));
510 510 }
511 511 if(node->nodes.at(i)->name==QIlib::Lexique::attr_c)
512 512 {
513 513 this->attr.setNode(node->nodes.at(i));
514 514 }
515 515 if(node->nodes.at(i)->name==QIlib::Lexique::pad_c)
516 516 {
517 517 this->apendPad(node->nodes.at(i));
518 518 }
519 519 if(node->nodes.at(i)->name==QIlib::Lexique::fp_line_c)
520 520 {
521 521 this->apendLine(node->nodes.at(i));
522 522 }
523 523 if(node->nodes.at(i)->name==QIlib::Lexique::fp_text_c)
524 524 {
525 525 this->apendText(node->nodes.at(i));
526 526 }
527 527 if(node->nodes.at(i)->name==QIlib::Lexique::fp_circle_c)
528 528 {
529 529 this->apendCircle(node->nodes.at(i));
530 530 }
531 531 }
532 532 }
533 533 }
534 534
535 535 void QIlib::QIcadPcbModule::clrPads()
536 536 {
537 537 while(pads.count())
538 538 {
539 539 QIcadPcbPad* pad;
540 540 pad = pads.last();
541 541 pads.removeLast();
542 542 delete pad;
543 543 }
544 544 }
545 545
546 546 void QIlib::QIcadPcbModule::apendPad(QIlib::AbstractNode *node)
547 547 {
548 548 if(node->name==QIlib::Lexique::pad_c)
549 549 {
550 550 this->pads.append(new QIcadPcbPad(node));
551 551 }
552 552 }
553 553
554 554 void QIlib::QIcadPcbModule::clrTexts()
555 555 {
556 556 while(fp_texts.count())
557 557 {
558 558 QIcadPcbFPText* text;
559 559 text = fp_texts.last();
560 560 fp_texts.removeLast();
561 561 delete text;
562 562 }
563 563 }
564 564
565 565 void QIlib::QIcadPcbModule::apendText(QIlib::AbstractNode *node)
566 566 {
567 567 if(node->name==QIlib::Lexique::fp_text_c)
568 568 {
569 569 this->fp_texts.append(new QIcadPcbFPText(node));
570 570 }
571 571 }
572 572
573 573 void QIlib::QIcadPcbModule::clrLines()
574 574 {
575 575 while(fp_lines.count())
576 576 {
577 577 QIcadPcbFPLine* line;
578 578 line = fp_lines.last();
579 579 fp_lines.removeLast();
580 580 delete line;
581 581 }
582 582 }
583 583
584 584 void QIlib::QIcadPcbModule::apendLine(QIlib::AbstractNode *node)
585 585 {
586 586 if(node->name==QIlib::Lexique::fp_line_c)
587 587 {
588 588 this->fp_lines.append(new QIcadPcbFPLine(node));
589 589 }
590 590 }
591 591
592 592 void QIlib::QIcadPcbModule::clrCircles()
593 593 {
594 594 while(fp_circles.count())
595 595 {
596 596 QIcadPcbFPCircle* circle;
597 597 circle = fp_circles.last();
598 598 fp_circles.removeLast();
599 599 delete circle;
600 600 }
601 601 }
602 602
603 603 void QIlib::QIcadPcbModule::apendCircle(QIlib::AbstractNode *node)
604 604 {
605 605 if(node->name==QIlib::Lexique::fp_circle_c)
606 606 {
607 607 this->fp_circles.append(new QIcadPcbFPCircle(node));
608 608 }
609 609 }
610 610
611 611
612 612 QIlib::QIcadPcbDimension::QIcadPcbDimension(QIlib::AbstractNode *node)
613 613 :QIcadAbstractNodeWrapper(node)
614 614 {
615 615 this->setNode(node);
616 616 }
617 617
618 618 void QIlib::QIcadPcbDimension::setNode(QIlib::AbstractNode *node)
619 619 {
620 620 if(node->name==QIlib::Lexique::dimension_c)
621 621 {
622 622 this->p_node = node;
623 623 for(int i=0;i<node->nodes.count();i++)
624 624 {
625 625 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
626 626 {
627 627 this->width.setNode(node->nodes.at(i));
628 628 }
629 629 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
630 630 {
631 631 this->layer.setNode(node->nodes.at(i));
632 632 }
633 633 if(node->nodes.at(i)->name==QIlib::Lexique::gr_text_c)
634 634 {
635 635 this->gr_text.setNode(node->nodes.at(i));
636 636 }
637 637 if(node->nodes.at(i)->name==QIlib::Lexique::feature1_c)
638 638 {
639 639 this->feature1.setNode(node->nodes.at(i));
640 640 }
641 641 if(node->nodes.at(i)->name==QIlib::Lexique::crossbar_c)
642 642 {
643 643 this->crossbar.setNode(node->nodes.at(i));
644 644 }
645 645 if(node->nodes.at(i)->name==QIlib::Lexique::arrow1a_c)
646 646 {
647 647 this->arrow1a.setNode(node->nodes.at(i));
648 648 }
649 649 if(node->nodes.at(i)->name==QIlib::Lexique::arrow1b_c)
650 650 {
651 651 this->arrow1b.setNode(node->nodes.at(i));
652 652 }
653 653 if(node->nodes.at(i)->name==QIlib::Lexique::arrow2a_c)
654 654 {
655 655 this->arrow2a.setNode(node->nodes.at(i));
656 656 }
657 657 if(node->nodes.at(i)->name==QIlib::Lexique::arrow2b_c)
658 658 {
659 659 this->arrow2b.setNode(node->nodes.at(i));
660 660 }
661 661 }
662 662 }
663 663 }
664 664
665 665
666 666 QIlib::QIcadPcbModuleModel::QIcadPcbModuleModel(QIlib::AbstractNode *node)
667 667 :QIcadAbstractNodeWrapper(node)
668 668 {
669 669 this->setNode(node);
670 670 }
671 671
672 672 void QIlib::QIcadPcbModuleModel::setNode(QIlib::AbstractNode *node)
673 673 {
674 674 this->p_node = node;
675 675 }
676 676
677 677
678 678 QIlib::QIcadPcbFPText::QIcadPcbFPText(QIlib::AbstractNode *node)
679 679 :QIcadAbstractNodeWrapper(node)
680 680 {
681 681 this->setNode(node);
682 682 }
683 683
684 684 void QIlib::QIcadPcbFPText::setNode(QIlib::AbstractNode *node)
685 685 {
686 686 if(node->name==QIlib::Lexique::pad_c)
687 687 {
688 688 this->p_node = node;
689 689 for(int i=0;i<node->nodes.count();i++)
690 690 {
691 691 if(node->nodes.at(i)->name==QIlib::Lexique::at_c)
692 692 {
693 693 this->at.setNode(node->nodes.at(i));
694 694 }
695 695 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
696 696 {
697 697 this->layer.setNode(node->nodes.at(i));
698 698 }
699 699 if(node->nodes.at(i)->name==QIlib::Lexique::effects_c)
700 700 {
701 701 this->effects.setNode(node->nodes.at(i));
702 702 }
703 703 }
704 704 }
705 705 }
706 706
707 707
708 708 QIlib::QIcadPcbFpTextEffects::QIcadPcbFpTextEffects(QIlib::AbstractNode *node)
709 709 :QIcadAbstractNodeWrapper(node)
710 710 {
711 711 this->setNode(node);
712 712 }
713 713
714 714 void QIlib::QIcadPcbFpTextEffects::setNode(QIlib::AbstractNode *node)
715 715 {
716 716 this->p_node = node;
717 717 }
718 718
719 719
720 720 QIlib::QIcadPcbFpTextEffectsFont::QIcadPcbFpTextEffectsFont(QIlib::AbstractNode *node)
721 721 :QIcadAbstractNodeWrapper(node)
722 722 {
723 723 this->setNode(node);
724 724 }
725 725
726 726 void QIlib::QIcadPcbFpTextEffectsFont::setNode(QIlib::AbstractNode *node)
727 727 {
728 728 this->p_node = node;
729 729 }
730 730
731 731
732 732 QIlib::QIcadPcbNetClass::QIcadPcbNetClass(QIlib::AbstractNode *node)
733 733 :QIcadAbstractNodeWrapper(node)
734 734 {
735 735 this->setNode(node);
736 736 }
737 737
738 738 void QIlib::QIcadPcbNetClass::setNode(QIlib::AbstractNode *node)
739 739 {
740 740 this->p_node = node;
741 741 }
742 742
743 743
744 744 QIlib::QIcadPcbSetup::QIcadPcbSetup(QIlib::AbstractNode *node)
745 745 :QIcadAbstractNodeWrapper(node)
746 746 {
747 747 this->setNode(node);
748 748 }
749 749
750 750 void QIlib::QIcadPcbSetup::setNode(QIlib::AbstractNode *node)
751 751 {
752 this->p_node = node;
752 if(node->name==QIlib::Lexique::setup_c)
753 {
754 this->p_node = node;
755 for(int i=0;i<node->nodes.count();i++)
756 {
757 if(node->nodes.at(i)->name==QIlib::Lexique::via_drill_c)
758 {
759 this->via_dril.setNode(node->nodes.at(i));
760 this->p_defaultViaDrillSize = nodeValueToDouble(node->nodes.at(i));
761 }
762 }
763 }
753 764 }
754 765
755 766
756 767 QIlib::QIcadPcbPlotParams::QIcadPcbPlotParams(QIlib::AbstractNode *node)
757 768 :QIcadAbstractNodeWrapper(node)
758 769 {
759 770 this->setNode(node);
760 771 }
761 772
762 773 void QIlib::QIcadPcbPlotParams::setNode(QIlib::AbstractNode *node)
763 774 {
764 775 this->p_node = node;
765 776 }
766 777
767 778
768 779 QIlib::QIcadPcbSegment::QIcadPcbSegment(QIlib::AbstractNode *node)
769 780 :QIcadAbstractPcbLine(node)
770 781 {
771 782 this->setNode(node);
772 783 }
773 784
774 785 void QIlib::QIcadPcbSegment::setNode(QIlib::AbstractNode *node)
775 786 {
776 787 if(node->name==QIlib::Lexique::segment_c)
777 788 {
778 789 this->p_node = node;
779 790 for(int i=0;i<node->nodes.count();i++)
780 791 {
781 792 if(node->nodes.at(i)->name==QIlib::Lexique::start_c)
782 793 {
783 794 this->p_startpos = nodeTo2DCoords(node->nodes.at(i));
784 795 this->start.setNode(node->nodes.at(i));
785 796 }
786 797 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
787 798 {
788 799 this->p_stoppos = nodeTo2DCoords(node->nodes.at(i));
789 800 this->end.setNode(node->nodes.at(i));
790 801 }
791 802 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
792 803 {
793 804 this->p_width = nodeValueToDouble(node->nodes.at(i));
794 805 this->width.setNode(node->nodes.at(i));
795 806 }
796 807 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
797 808 {
798 809 this->p_layers = node->nodes.at(i)->Values;
799 810 this->layer.setNode(node->nodes.at(i));
800 811 }
801 812 if(node->nodes.at(i)->name==QIlib::Lexique::net_c)
802 813 {
803 814 this->net.setNode(node->nodes.at(i));
804 815 }
805 816 }
806 817 }
807 818 }
808 819
809 820
810 QIlib::QIcadPcbVia::QIcadPcbVia(QIlib::AbstractNode *node)
811 :QIcadAbstractNodeWrapper(node)
821 QIlib::QIcadPcbVia::QIcadPcbVia(QIlib::AbstractNode *node, double defaultDrill)
822 :QIcadAbstractNodeWrapper(node),p_drill(defaultDrill)
812 823 {
813 824 this->setNode(node);
814 825 }
815 826
816 827 void QIlib::QIcadPcbVia::setNode(QIlib::AbstractNode *node)
817 828 {
818 829 if(node->name==QIlib::Lexique::via_c)
819 830 {
820 831 this->p_node = node;
821 832 for(int i=0;i<node->nodes.count();i++)
822 833 {
823 834 if(node->nodes.at(i)->name==QIlib::Lexique::at_c)
824 835 {
825 836 this->at.setNode(node->nodes.at(i));
826 837 p_pos = nodeTo2DCoords(node->nodes.at(i));
827 838 }
828 839 if(node->nodes.at(i)->name==QIlib::Lexique::size_c)
829 840 {
830 841 this->sizeNode.setNode(node->nodes.at(i));
831 p_size = nodeTo2DSize(node->nodes.at(i));
842 p_size = QSizeF(nodeValueToDouble(node->nodes.at(i)),nodeValueToDouble(node->nodes.at(i)));
832 843 }
833 844 if(node->nodes.at(i)->name==QIlib::Lexique::drill_c)
834 845 {
835 846 this->drillNode.setNode(node->nodes.at(i));
836 847 p_drill = nodeValueToDouble(node->nodes.at(i));
837 848 }
838 849 if(node->nodes.at(i)->name==QIlib::Lexique::layers_c)
839 850 {
840 851 this->layersNode.setNode(node->nodes.at(i));
841 852 p_layers = node->nodes.at(i)->Values;
842 853 }
843 854 if(node->nodes.at(i)->name==QIlib::Lexique::net_c)
844 855 {
845 856 this->net.setNode(node->nodes.at(i));
846 857 }
847 858 if(node->nodes.at(i)->name==QIlib::Lexique::tstamp_c)
848 859 {
849 860 this->tstamp.setNode(node->nodes.at(i));
850 861 }
851 862 }
852 863 }
853 864 }
854 865
855 866
856 867 QIlib::QIcadPcbPad::QIcadPcbPad(QIlib::AbstractNode *node)
857 868 :QIcadAbstractNodeWrapper(node)
858 869 {
859 870 this->setNode(node);
860 871 }
861 872
862 873 void QIlib::QIcadPcbPad::setNode(QIlib::AbstractNode *node)
863 874 {
864 875 if(node->name==QIlib::Lexique::pad_c)
865 876 {
866 877 this->p_node = node;
867 878 if(p_node->Values.count()>=3)
868 879 {
869 880 if(!this->p_node->Values.at((2)).compare("rect"))
870 881 {
871 882 this->p_shape = rectangle;
872 883 }
873 884 else
874 885 if(!this->p_node->Values.at((2)).compare("circle"))
875 886 {
876 887 this->p_shape = circle;
877 888 }
878 889
879 890 }
880 891 for(int i=0;i<node->nodes.count();i++)
881 892 {
882 893 if(node->nodes.at(i)->name==QIlib::Lexique::at_c)
883 894 {
884 895 this->at.setNode(node->nodes.at(i));
885 896 this->p_pos = nodeTo2DCoords(node->nodes.at(i));
886 897 }
887 898 if(node->nodes.at(i)->name==QIlib::Lexique::size_c)
888 899 {
889 900 this->sizeNode.setNode(node->nodes.at(i));
890 901 this->p_size = nodeTo2DSize(node->nodes.at(i));
891 902 }
892 903 if(node->nodes.at(i)->name==QIlib::Lexique::layers_c)
893 904 {
894 905 this->layer.setNode(node->nodes.at(i));
895 906 this->p_layers = node->nodes.at(i)->Values;
896 907 }
897 908 if(node->nodes.at(i)->name==QIlib::Lexique::net_c)
898 909 {
899 910 this->netNode.setNode(node->nodes.at(i));
900 911 }
901 912 if(node->nodes.at(i)->name==QIlib::Lexique::drill_c)
902 913 {
903 914 this->drillNode.setNode(node->nodes.at(i));
904 915 this->p_drill = nodeValueToDouble(node->nodes.at(i));
905 916 }
906 917 }
907 918 }
908 919 }
909 920
910 921
911 922 QIlib::QIcadPcbFPLine::QIcadPcbFPLine(QIlib::AbstractNode *node)
912 923 :QIcadAbstractPcbLine(node)
913 924 {
914 925 this->setNode(node);
915 926 }
916 927
917 928 void QIlib::QIcadPcbFPLine::setNode(QIlib::AbstractNode *node)
918 929 {
919 930 if(node->name==QIlib::Lexique::fp_line_c)
920 931 {
921 932 this->p_node = node;
922 933 for(int i=0;i<node->nodes.count();i++)
923 934 {
924 935 if(node->nodes.at(i)->name==QIlib::Lexique::start_c)
925 936 {
926 937 this->p_startpos = nodeTo2DCoords(node->nodes.at(i));
927 938 this->start.setNode(node->nodes.at(i));
928 939 }
929 940 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
930 941 {
931 942 this->p_stoppos = nodeTo2DCoords(node->nodes.at(i));
932 943 this->end.setNode(node->nodes.at(i));
933 944 }
934 945 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
935 946 {
936 947 this->p_layers = node->nodes.at(i)->Values;
937 948 this->layer.setNode(node->nodes.at(i));
938 949 }
939 950 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
940 951 {
941 952 this->p_width = nodeValueToDouble(node->nodes.at(i));
942 953 this->width.setNode(node->nodes.at(i));
943 954 }
944 955 }
945 956 }
946 957 }
947 958
948 959
949 960 QIlib::QIcadPcbFPCircle::QIcadPcbFPCircle(QIlib::AbstractNode *node)
950 961 :QIcadAbstractNodeWrapper(node)
951 962 {
952 963 this->setNode(node);
953 964 }
954 965
955 966 void QIlib::QIcadPcbFPCircle::setNode(QIlib::AbstractNode *node)
956 967 {
957 968 if(node->name==QIlib::Lexique::fp_circle_c)
958 969 {
959 970 this->p_node = node;
960 971 for(int i=0;i<node->nodes.count();i++)
961 972 {
962 973 if(node->nodes.at(i)->name==QIlib::Lexique::center_c)
963 974 {
964 975 this->center.setNode(node->nodes.at(i));
965 976 }
966 977 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
967 978 {
968 979 this->end.setNode(node->nodes.at(i));
969 980 }
970 981 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
971 982 {
972 983 this->layer.setNode(node->nodes.at(i));
973 984 }
974 985 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
975 986 {
976 987 this->width.setNode(node->nodes.at(i));
977 988 }
978 989 }
979 990 }
980 991 }
981 992
982 993
983 994 QIlib::QIcadPcbText::QIcadPcbText(QIlib::AbstractNode *node)
984 995 :QIcadAbstractNodeWrapper(node)
985 996 {
986 997 this->setNode(node);
987 998 }
988 999
989 1000 void QIlib::QIcadPcbText::setNode(QIlib::AbstractNode *node)
990 1001 {
991 1002 if(node->name==QIlib::Lexique::gr_text_c)
992 1003 {
993 1004 this->p_node = node;
994 1005 for(int i=0;i<node->nodes.count();i++)
995 1006 {
996 1007 if(node->nodes.at(i)->name==QIlib::Lexique::at_c)
997 1008 {
998 1009 this->at.setNode(node->nodes.at(i));
999 1010 }
1000 1011 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
1001 1012 {
1002 1013 this->layer.setNode(node->nodes.at(i));
1003 1014 }
1004 1015 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
1005 1016 {
1006 1017 this->width.setNode(node->nodes.at(i));
1007 1018 }
1008 1019 if(node->nodes.at(i)->name==QIlib::Lexique::effects_c)
1009 1020 {
1010 1021 this->effects.setNode(node->nodes.at(i));
1011 1022 }
1012 1023 }
1013 1024 }
1014 1025 }
1015 1026
1016 1027
1017 1028 QIlib::QIcadPcbCircle::QIcadPcbCircle(QIlib::AbstractNode *node)
1018 1029 :QIcadAbstractNodeWrapper(node)
1019 1030 {
1020 1031 this->setNode(node);
1021 1032 }
1022 1033
1023 1034 void QIlib::QIcadPcbCircle::setNode(QIlib::AbstractNode *node)
1024 1035 {
1025 1036 if(node->name==QIlib::Lexique::gr_circle_c)
1026 1037 {
1027 1038 this->p_node = node;
1028 1039 for(int i=0;i<node->nodes.count();i++)
1029 1040 {
1030 1041 if(node->nodes.at(i)->name==QIlib::Lexique::center_c)
1031 1042 {
1032 1043 this->center.setNode(node->nodes.at(i));
1033 1044 }
1034 1045 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
1035 1046 {
1036 1047 this->end.setNode(node->nodes.at(i));
1037 1048 }
1038 1049 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
1039 1050 {
1040 1051 this->layer.setNode(node->nodes.at(i));
1041 1052 }
1042 1053 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
1043 1054 {
1044 1055 this->width.setNode(node->nodes.at(i));
1045 1056 }
1046 1057 }
1047 1058 }
1048 1059 }
1049 1060
1050 1061
1051 1062 QIlib::QIcadPcbArc::QIcadPcbArc(QIlib::AbstractNode *node)
1052 1063 :QIcadAbstractNodeWrapper(node)
1053 1064 {
1054 1065 this->setNode(node);
1055 1066 }
1056 1067
1057 1068 void QIlib::QIcadPcbArc::setNode(QIlib::AbstractNode *node)
1058 1069 {
1059 1070 if(node->name==QIlib::Lexique::gr_arc_c)
1060 1071 {
1061 1072 this->p_node = node;
1062 1073 for(int i=0;i<node->nodes.count();i++)
1063 1074 {
1064 1075 if(node->nodes.at(i)->name==QIlib::Lexique::start_c)
1065 1076 {
1066 1077 this->start.setNode(node->nodes.at(i));
1067 1078 }
1068 1079 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
1069 1080 {
1070 1081 this->end.setNode(node->nodes.at(i));
1071 1082 }
1072 1083 if(node->nodes.at(i)->name==QIlib::Lexique::angle_c)
1073 1084 {
1074 1085 this->angle.setNode(node->nodes.at(i));
1075 1086 }
1076 1087 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
1077 1088 {
1078 1089 this->layer.setNode(node->nodes.at(i));
1079 1090 }
1080 1091 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
1081 1092 {
1082 1093 this->width.setNode(node->nodes.at(i));
1083 1094 }
1084 1095 }
1085 1096 }
1086 1097 }
1087 1098
1088 1099
1089 1100 QIlib::QIcadPcbZone::QIcadPcbZone(QIlib::AbstractNode *node)
1090 1101 :QIcadAbstractNodeWrapper(node)
1091 1102 {
1092 1103 this->setNode(node);
1093 1104 }
1094 1105
1095 1106 void QIlib::QIcadPcbZone::setNode(QIlib::AbstractNode *node)
1096 1107 {
1097 1108 if(node->name==QIlib::Lexique::zone_c)
1098 1109 {
1099 1110 this->p_node = node;
1100 1111 }
1101 1112 }
1102 1113
1103 1114
1104 1115 const QPointF QIlib::nodeTo2DCoords(QIlib::AbstractNode *node)
1105 1116 {
1106 1117 QPointF point;
1107 1118 QStringList coords=node->Values;
1108 1119 if(coords.count()>=2)
1109 1120 {
1110 1121 point.setX(coords.at(0).toDouble());
1111 1122 point.setY(coords.at(1).toDouble());
1112 1123 }
1113 1124 return point;
1114 1125 }
1115 1126
1116 1127
1117 1128 double QIlib::nodeValueToDouble(QIlib::AbstractNode *node, int index)
1118 1129 {
1119 1130 if(node->Values.count()>index)
1120 1131 {
1121 1132 return node->Values.at(index).toDouble();
1122 1133 }
1123 1134 return 0.0;
1124 1135 }
1125 1136
1126 1137
1127 1138 int QIlib::nodeValueToInt(QIlib::AbstractNode *node, int index)
1128 1139 {
1129 1140 if(node->Values.count()>index)
1130 1141 {
1131 1142 return node->Values.at(index).toInt();
1132 1143 }
1133 1144 return 0;
1134 1145 }
1135 1146
1136 1147
1137 1148 QIlib::QIcadPcbLayer::QIcadPcbLayer(QIlib::AbstractNode *node)
1138 1149 :QIcadAbstractNodeWrapper(node)
1139 1150 {
1140 1151 this->p_index = QString(this->p_node->name).remove('(').toInt();
1141 1152 if(this->p_node->Values.count()>=1)
1142 1153 {
1143 1154 this->p_name = this->p_node->Values.at(0);
1144 1155 }
1145 1156 if(this->p_node->Values.count()>=2)
1146 1157 {
1147 1158 QString typestr=this->p_node->Values.at(1);
1148 1159 this->p_type = none;
1149 1160 if(!typestr.compare("signal"))
1150 1161 {
1151 1162 this->p_type = signal;
1152 1163 }
1153 1164 else
1154 1165 if(!typestr.compare("user"))
1155 1166 {
1156 1167 this->p_type = user;
1157 1168 }
1158 1169 }
1159 1170 }
1160 1171
1161 1172
1162 1173 const QSizeF QIlib::nodeTo2DSize(QIlib::AbstractNode *node)
1163 1174 {
1164 1175 QSizeF size;
1165 1176 QStringList sz=node->Values;
1166 1177 if(sz.count()>=2)
1167 1178 {
1168 1179 size.setWidth(sz.at(0).toDouble());
1169 1180 size.setHeight(sz.at(1).toDouble());
1170 1181 }
1171 1182 return size;
1172 1183 }
@@ -1,487 +1,490
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the Kicad Tools Software
3 3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef QICADPCB_H
23 23 #define QICADPCB_H
24 24 #include <QString>
25 25 #include <QStringList>
26 26 #include <QList>
27 27 #include <QFile>
28 28 #include <parsers/lispLike_driver.h>
29 29 #include <qicadlisplikelexique.h>
30 30 #include <QPointF>
31 31 #include <QRectF>
32 32
33 33 namespace QIlib{
34 34
35 35 const QPointF nodeTo2DCoords(QIlib::AbstractNode* node);
36 36 const QSizeF nodeTo2DSize(QIlib::AbstractNode* node);
37 37 double nodeValueToDouble(QIlib::AbstractNode* node,int index=0);
38 38 int nodeValueToInt(QIlib::AbstractNode* node,int index=0);
39 39
40 40 class QIcadAbstractPcbLine : public QIcadAbstractNodeWrapper
41 41 {
42 42 public:
43 43 QIcadAbstractPcbLine(QIlib::AbstractNode* node)
44 44 :QIcadAbstractNodeWrapper(node)
45 45 {}
46 46 QIcadAbstractPcbLine(){}
47 47 virtual const QPointF& startPos(){return p_startpos;}
48 48 virtual const QPointF& stopPos(){return p_stoppos;}
49 49 virtual double width(){return p_width;}
50 50 virtual const QStringList& layers(){return p_layers;}
51 51 protected:
52 52 double p_width;
53 53 QPointF p_startpos;
54 54 QPointF p_stoppos;
55 55 QStringList p_layers;
56 56 };
57 57
58 58 class QIcadPcbLayer : public QIcadAbstractNodeWrapper
59 59 {
60 60 public:
61 61 typedef enum
62 62 {
63 63 signal,
64 64 user,
65 65 none
66 66 }layetType_t;
67 67 QIcadPcbLayer(QIlib::AbstractNode* node);
68 68 QIcadPcbLayer(){}
69 69 int index(){return p_index;}
70 70 const QString& name(){return p_name;}
71 71 layetType_t type(){return p_type;}
72 72 protected:
73 73 int p_index;
74 74 QString p_name;
75 75 layetType_t p_type;
76 76 };
77 77
78 78 class QIcadPcbPlotParams : public QIcadAbstractNodeWrapper
79 79 {
80 80 public:
81 81 QIcadPcbPlotParams(QIlib::AbstractNode* node);
82 82 QIcadPcbPlotParams(){}
83 83 QIcadAbstractNodeWrapper layerselection;
84 84 QIcadAbstractNodeWrapper usegerberextensions;
85 85 QIcadAbstractNodeWrapper excludeedgelayer;
86 86 QIcadAbstractNodeWrapper linewidth;
87 87 QIcadAbstractNodeWrapper plotframeref;
88 88 QIcadAbstractNodeWrapper viasonmask;
89 89 QIcadAbstractNodeWrapper mode;
90 90 QIcadAbstractNodeWrapper useauxorigin;
91 91 QIcadAbstractNodeWrapper hpglpennumber;
92 92 QIcadAbstractNodeWrapper hpglpenspeed;
93 93 QIcadAbstractNodeWrapper hpglpendiameter;
94 94 QIcadAbstractNodeWrapper hpglpenoverlay;
95 95 QIcadAbstractNodeWrapper psnegative;
96 96 QIcadAbstractNodeWrapper psa4output;
97 97 QIcadAbstractNodeWrapper plotreference;
98 98 QIcadAbstractNodeWrapper plotvalue;
99 99 QIcadAbstractNodeWrapper plotothertext;
100 100 QIcadAbstractNodeWrapper plotinvisibletext;
101 101 QIcadAbstractNodeWrapper padsonsilk;
102 102 QIcadAbstractNodeWrapper subtractmaskfromsilk;
103 103 QIcadAbstractNodeWrapper outputformat;
104 104 QIcadAbstractNodeWrapper mirror;
105 105 QIcadAbstractNodeWrapper drillshape;
106 106 QIcadAbstractNodeWrapper scaleselection;
107 107 QIcadAbstractNodeWrapper outputdirectory;
108 108 void setNode(QIlib::AbstractNode* node);
109 109 };
110 110
111 111 class QIcadPcbSetup : public QIcadAbstractNodeWrapper
112 112 {
113 113 public:
114 114 QIcadPcbSetup(QIlib::AbstractNode* node);
115 115 QIcadPcbSetup(){}
116 116 QIcadAbstractNodeWrapper last_trace_width;
117 117 QIcadAbstractNodeWrapper trace_clearance;
118 118 QIcadAbstractNodeWrapper zone_clearance;
119 119 QIcadAbstractNodeWrapper zone_45_only;
120 120 QIcadAbstractNodeWrapper trace_min;
121 121 QIcadAbstractNodeWrapper segment_width;
122 122 QIcadAbstractNodeWrapper edge_width;
123 123 QIcadAbstractNodeWrapper via_size;
124 124 QIcadAbstractNodeWrapper via_dril;
125 125 QIcadAbstractNodeWrapper via_min_size;
126 126 QIcadAbstractNodeWrapper via_min_drill;
127 127 QIcadAbstractNodeWrapper uvia_size;
128 128 QIcadAbstractNodeWrapper uvia_drill;
129 129 QIcadAbstractNodeWrapper uvias_allowed;
130 130 QIcadAbstractNodeWrapper uvia_min_size;
131 131 QIcadAbstractNodeWrapper uvia_min_drill;
132 132 QIcadAbstractNodeWrapper pcb_text_width;
133 133 QIcadAbstractNodeWrapper pcb_text_size;
134 134 QIcadAbstractNodeWrapper mod_edge_width;
135 135 QIcadAbstractNodeWrapper mod_text_size;
136 136 QIcadAbstractNodeWrapper mod_text_width;
137 137 QIcadAbstractNodeWrapper pad_size;
138 138 QIcadAbstractNodeWrapper pad_drill;
139 139 QIcadAbstractNodeWrapper pad_to_mask_clearance;
140 140 QIcadAbstractNodeWrapper aux_axis_origin;
141 141 QIcadAbstractNodeWrapper visible_elements;
142 142 QIcadPcbPlotParams plotParams;
143 143 void setNode(QIlib::AbstractNode* node);
144 double defaultViaDrillSize(){return p_defaultViaDrillSize;}
145 private:
146 double p_defaultViaDrillSize;
144 147 };
145 148
146 149 class QIcadPcbNetClass : public QIcadAbstractNodeWrapper
147 150 {
148 151 public:
149 152 QIcadPcbNetClass(QIlib::AbstractNode* node);
150 153 QIcadPcbNetClass(){}
151 154 QIcadAbstractNodeWrapper clearance;
152 155 QIcadAbstractNodeWrapper trace_width;
153 156 QIcadAbstractNodeWrapper via_dia;
154 157 QIcadAbstractNodeWrapper via_drill;
155 158 QIcadAbstractNodeWrapper uvia_dia;
156 159 QIcadAbstractNodeWrapper uvia_drill;
157 160 QList<QIcadAbstractNodeWrapper*> nets;
158 161 void setNode(QIlib::AbstractNode* node);
159 162 };
160 163
161 164 class QIcadPcbFpTextEffectsFont : public QIcadAbstractNodeWrapper
162 165 {
163 166 public:
164 167 QIcadPcbFpTextEffectsFont(QIlib::AbstractNode* node);
165 168 QIcadAbstractNodeWrapper size;
166 169 void setNode(QIlib::AbstractNode* node);
167 170 };
168 171
169 172 class QIcadPcbFpTextEffects : public QIcadAbstractNodeWrapper
170 173 {
171 174 public:
172 175 QIcadPcbFpTextEffects(QIlib::AbstractNode* node);
173 176 QIcadPcbFpTextEffects(){}
174 177 QIcadAbstractNodeWrapper font;
175 178 QIcadAbstractNodeWrapper thickness;
176 179 void setNode(QIlib::AbstractNode* node);
177 180 };
178 181
179 182 class QIcadPcbFPText : public QIcadAbstractNodeWrapper
180 183 {
181 184 public:
182 185 QIcadPcbFPText(QIlib::AbstractNode* node);
183 186 QIcadPcbFPText(){}
184 187 QIcadAbstractNodeWrapper at;
185 188 QIcadAbstractNodeWrapper layer;
186 189 QIcadPcbFpTextEffects effects;
187 190 void setNode(QIlib::AbstractNode* node);
188 191 };
189 192
190 193 class QIcadPcbModuleModel : public QIcadAbstractNodeWrapper
191 194 {
192 195 public:
193 196 QIcadPcbModuleModel(QIlib::AbstractNode* node);
194 197 QIcadPcbModuleModel(){}
195 198 QIcadAbstractNodeWrapper at;
196 199 QIcadAbstractNodeWrapper scale;
197 200 QIcadAbstractNodeWrapper rotate;
198 201 void setNode(QIlib::AbstractNode* node);
199 202 };
200 203
201 204 class QIcadPcbDimension : public QIcadAbstractNodeWrapper
202 205 {
203 206 public:
204 207 QIcadPcbDimension(QIlib::AbstractNode* node);
205 208 QIcadPcbDimension(){}
206 209 QIcadAbstractNodeWrapper width;
207 210 QIcadAbstractNodeWrapper layer;
208 211 QIcadAbstractNodeWrapper gr_text;
209 212 QIcadAbstractNodeWrapper feature1;
210 213 QIcadAbstractNodeWrapper feature2;
211 214 QIcadAbstractNodeWrapper crossbar;
212 215 QIcadAbstractNodeWrapper arrow1a;
213 216 QIcadAbstractNodeWrapper arrow1b;
214 217 QIcadAbstractNodeWrapper arrow2a;
215 218 QIcadAbstractNodeWrapper arrow2b;
216 219 void setNode(QIlib::AbstractNode* node);
217 220 };
218 221
219 222 class QIcadPcbPad : public QIcadAbstractNodeWrapper
220 223 {
221 224 public:
222 225 typedef enum
223 226 {
224 227 rectangle,
225 228 circle
226 229 }padShape;
227 230 QIcadPcbPad(QIlib::AbstractNode* node);
228 231 QIcadPcbPad(){}
229 232 QIcadAbstractNodeWrapper at;
230 233 QIcadAbstractNodeWrapper sizeNode;
231 234 QIcadAbstractNodeWrapper layer;
232 235 QIcadAbstractNodeWrapper netNode;
233 236 QIcadAbstractNodeWrapper drillNode;
234 237 const QStringList& layers(){return p_layers;}
235 238 const QSizeF& size(){return p_size;}
236 239 const QPointF& pos(){return p_pos;}
237 240 double drill(){return p_drill;}
238 241 padShape shape(){return p_shape;}
239 242 void setNode(QIlib::AbstractNode* node);
240 243 private:
241 244 padShape p_shape;
242 245 double p_drill;
243 246 QSizeF p_size;
244 247 QPointF p_pos;
245 248 QStringList p_layers;
246 249 };
247 250
248 251 class QIcadPcbFPLine : public QIcadAbstractPcbLine
249 252 {
250 253 public:
251 254 QIcadPcbFPLine(QIlib::AbstractNode* node);
252 255 QIcadPcbFPLine(){}
253 256 QIcadAbstractNodeWrapper start;
254 257 QIcadAbstractNodeWrapper end;
255 258 QIcadAbstractNodeWrapper layer;
256 259 QIcadAbstractNodeWrapper width;
257 260 void setNode(QIlib::AbstractNode* node);
258 261 };
259 262
260 263 class QIcadPcbFPCircle : public QIcadAbstractNodeWrapper
261 264 {
262 265 public:
263 266 QIcadPcbFPCircle(QIlib::AbstractNode* node);
264 267 QIcadPcbFPCircle(){}
265 268 QIcadAbstractNodeWrapper center;
266 269 QIcadAbstractNodeWrapper end;
267 270 QIcadAbstractNodeWrapper layer;
268 271 QIcadAbstractNodeWrapper width;
269 272 void setNode(QIlib::AbstractNode* node);
270 273 };
271 274
272 275 class QIcadPcbModule : public QIcadAbstractNodeWrapper
273 276 {
274 277 public:
275 278 QIcadPcbModule(QIlib::AbstractNode* node);
276 279 QIcadPcbModule(){}
277 280 const QPointF& pos();
278 281 double angle();
279 282 QIcadAbstractNodeWrapper layer;
280 283 QIcadAbstractNodeWrapper tedit;
281 284 QIcadAbstractNodeWrapper tstamp;
282 285 QIcadAbstractNodeWrapper at;
283 286 QIcadAbstractNodeWrapper descr;
284 287 QIcadAbstractNodeWrapper tags;
285 288 QIcadAbstractNodeWrapper path;
286 289 QIcadAbstractNodeWrapper attr;
287 290 QList<QIcadPcbFPText*> fp_texts;
288 291 QList<QIcadPcbFPLine*> fp_lines;
289 292 QList<QIcadPcbFPCircle*> fp_circles;
290 293 QList<QIcadPcbPad*> pads;
291 294 QIcadPcbModuleModel model;
292 295 void setNode(QIlib::AbstractNode* node);
293 296 void clrPads();
294 297 void apendPad(QIlib::AbstractNode* node);
295 298 void clrTexts();
296 299 void apendText(QIlib::AbstractNode* node);
297 300 void clrLines();
298 301 void apendLine(QIlib::AbstractNode* node);
299 302 void clrCircles();
300 303 void apendCircle(QIlib::AbstractNode* node);
301 304 private:
302 305 QPointF p_pos;
303 306 double p_angle;
304 307 };
305 308
306 309 class QIcadPcbSegment : public QIcadAbstractPcbLine
307 310 {
308 311 public:
309 312 QIcadPcbSegment(QIlib::AbstractNode* node);
310 313 QIcadPcbSegment(){}
311 314 QIcadAbstractNodeWrapper start;
312 315 QIcadAbstractNodeWrapper end;
313 316 QIcadAbstractNodeWrapper width;
314 317 QIcadAbstractNodeWrapper layer;
315 318 QIcadAbstractNodeWrapper net;
316 319 void setNode(QIlib::AbstractNode* node);
317 320 };
318 321
319 322 class QIcadPcbVia : public QIcadAbstractNodeWrapper
320 323 {
321 324 public:
322 QIcadPcbVia(QIlib::AbstractNode* node);
325 QIcadPcbVia(QIlib::AbstractNode* node, double defaultDrill=0);
323 326 QIcadPcbVia(){}
324 327 QIcadAbstractNodeWrapper at;
325 328 QIcadAbstractNodeWrapper sizeNode;
326 329 QIcadAbstractNodeWrapper drillNode;
327 330 QIcadAbstractNodeWrapper layersNode;
328 331 QIcadAbstractNodeWrapper net;
329 332 QIcadAbstractNodeWrapper tstamp;
330 333 void setNode(QIlib::AbstractNode* node);
331 334 const QStringList& layers(){return p_layers;}
332 335 const QSizeF& size(){return p_size;}
333 336 const QPointF& pos(){return p_pos;}
334 337 double drill(){return p_drill;}
335 338 private:
336 339 double p_drill;
337 340 QSizeF p_size;
338 341 QPointF p_pos;
339 342 QStringList p_layers;
340 343 };
341 344
342 345 class QIcadPcbLine : public QIcadAbstractPcbLine
343 346 {
344 347 public:
345 348 QIcadPcbLine(QIlib::AbstractNode* node);
346 349 QIcadPcbLine(){}
347 350 QIcadAbstractNodeWrapper start;
348 351 QIcadAbstractNodeWrapper end;
349 352 QIcadAbstractNodeWrapper angle;
350 353 QIcadAbstractNodeWrapper layer;
351 354 QIcadAbstractNodeWrapper width;
352 355 void setNode(QIlib::AbstractNode* node);
353 356 };
354 357
355 358 class QIcadPcbZone : public QIcadAbstractNodeWrapper
356 359 {
357 360 public:
358 361 QIcadPcbZone(QIlib::AbstractNode* node);
359 362 QIcadPcbZone(){}
360 363 void setNode(QIlib::AbstractNode* node);
361 364 };
362 365
363 366 class QIcadPcbArc : public QIcadAbstractNodeWrapper
364 367 {
365 368 public:
366 369 QIcadPcbArc(QIlib::AbstractNode* node);
367 370 QIcadPcbArc(){}
368 371 QIcadAbstractNodeWrapper start;
369 372 QIcadAbstractNodeWrapper end;
370 373 QIcadAbstractNodeWrapper angle;
371 374 QIcadAbstractNodeWrapper layer;
372 375 QIcadAbstractNodeWrapper width;
373 376 void setNode(QIlib::AbstractNode* node);
374 377 };
375 378
376 379 class QIcadPcbCircle : public QIcadAbstractNodeWrapper
377 380 {
378 381 public:
379 382 QIcadPcbCircle(QIlib::AbstractNode* node);
380 383 QIcadPcbCircle(){}
381 384 QIcadAbstractNodeWrapper center;
382 385 QIcadAbstractNodeWrapper end;
383 386 QIcadAbstractNodeWrapper layer;
384 387 QIcadAbstractNodeWrapper width;
385 388 void setNode(QIlib::AbstractNode* node);
386 389 };
387 390
388 391 class QIcadPcbText : public QIcadAbstractNodeWrapper
389 392 {
390 393 public:
391 394 QIcadPcbText(QIlib::AbstractNode* node);
392 395 QIcadPcbText(){}
393 396 QIcadAbstractNodeWrapper at;
394 397 QIcadAbstractNodeWrapper layer;
395 398 QIcadAbstractNodeWrapper width;
396 399 QIcadPcbFpTextEffects effects;
397 400 void setNode(QIlib::AbstractNode* node);
398 401 };
399 402
400 403 class QIcadPcbLayers : public QIcadAbstractNodeWrapper
401 404 {
402 405 public:
403 406 QIcadPcbLayers(QIlib::AbstractNode* node);
404 407 QIcadPcbLayers(){}
405 408 QList<QIcadPcbLayer*> layers;
406 409 void setNode(QIlib::AbstractNode* node);
407 410 void clrLayers();
408 411 void apendLayer(QIlib::AbstractNode* node);
409 412 };
410 413
411 414 class QIcadPcbGeneralInfo : public QIcadAbstractNodeWrapper
412 415 {
413 416 public:
414 417 QIcadPcbGeneralInfo(QIlib::AbstractNode* node);
415 418 QIcadPcbGeneralInfo(){}
416 419 QIcadAbstractNodeWrapper links;
417 420 QIcadAbstractNodeWrapper no_connections;
418 421 QIcadAbstractNodeWrapper area;
419 422 QIcadAbstractNodeWrapper thickness;
420 423 QIcadAbstractNodeWrapper drawings;
421 424 QIcadAbstractNodeWrapper tracks;
422 425 QIcadAbstractNodeWrapper zones;
423 426 QIcadAbstractNodeWrapper modules;
424 427 QIcadAbstractNodeWrapper nets;
425 428 void setNode(QIlib::AbstractNode* node);
426 429 };
427 430
428 431 class QIcadPcbRoot : public QIcadAbstractNodeWrapper
429 432 {
430 433 public:
431 434 QIcadPcbRoot(QIlib::AbstractNode* node);
432 435 QIcadAbstractNodeWrapper version;
433 436 QIcadAbstractNodeWrapper host;
434 437 QIcadAbstractNodeWrapper page;
435 438 QIcadPcbGeneralInfo general;
436 439 QIcadPcbLayers layers;
437 440 QIcadPcbSetup setup;
438 441 QList<QIcadAbstractNodeWrapper*> nets;
439 442 QList<QIcadPcbModule*> modules;
440 443 QList<QIcadPcbDimension*> dimensions;
441 444 QList<QIcadPcbLine*> lines;
442 445 QList<QIcadPcbSegment*> segments;
443 446 QList<QIcadPcbVia*> vias;
444 447 QList<QIcadPcbArc*> arcs;
445 448 QList<QIcadPcbCircle*> circles;
446 449 QList<QIcadPcbText*> texts;
447 450 QList<QIcadPcbZone*> zones;
448 451 void setNode(QIlib::AbstractNode* node);
449 452 void clrNets();
450 453 void apendNet(QIlib::AbstractNode* node);
451 454 void clrModules();
452 455 void apendModule(QIlib::AbstractNode* node);
453 456 void clrDimensions();
454 457 void apendDimension(QIlib::AbstractNode* node);
455 458 void apendLine(QIlib::AbstractNode* node);
456 459 void clrLines();
457 460 void clrSegments();
458 461 void apendSegment(QIlib::AbstractNode* node);
459 462 void clrVias();
460 463 void apendVia(QIlib::AbstractNode* node);
461 464 void clrArcs();
462 465 void apendArc(QIlib::AbstractNode* node);
463 466 void clrCircles();
464 467 void apendCircle(QIlib::AbstractNode* node);
465 468 void clrTexts();
466 469 void apendText(QIlib::AbstractNode* node);
467 470 void clrZones();
468 471 void apendZone(QIlib::AbstractNode* node);
469 472 };
470 473
471 474 class QIcadPcb : private lispLike_Driver
472 475 {
473 476 public:
474 477 QIcadPcb();
475 478 bool parsePcb(const QString& pcb);
476 479 QString toString();
477 480 QString fileName;
478 481 QString print();
479 482
480 483 QIcadPcbRoot* pcbRoot;
481 484 private:
482 485 void updateConcreteTree();
483 486 };
484 487
485 488
486 489 }
487 490 #endif // QICADPCB_H
@@ -1,61 +1,63
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the Kicad Tools Software
3 3 -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #include "pcbvia.h"
23 23 #include <QPen>
24 24
25 25
26 26 PCBVia::PCBVia(QIlib::QIcadPcbVia *viaNode, PCBContext *context)
27 27 :QGraphicsItemGroup(),viaNode(viaNode),context(context)
28 28 {
29 29 this->init(QPointF(0.0,0.0));
30 30 }
31 31
32 32 PCBVia::PCBVia(QIlib::QIcadPcbVia *viaNode, QPointF offset, PCBContext *context)
33 33 :QGraphicsItemGroup(),viaNode(viaNode),context(context)
34 34 {
35 35 this->init(offset);
36 36 }
37 37
38 38 void PCBVia::init(QPointF offset)
39 39 {
40 40 this->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
41 41 this->setFlags(ItemIsMovable|ItemIsSelectable|ItemIsFocusable);
42 42 offset-=QPointF(this->viaNode->size().width()/2,this->viaNode->size().height()/2);
43 43
44 44 for(int i=0;i<this->viaNode->layers().count();i++)
45 45 {
46 46 QGraphicsEllipseItem* ellipse = new QGraphicsEllipseItem();
47 47 QPen pen = ellipse->pen();
48 pen.setWidthF(0.01);
48 double thickness = (this->viaNode->size().width()-this->viaNode->drill())/2;
49 pen.setWidthF(thickness);
50
49 51 ellipse->setPen(pen);
50 QBrush brush = ellipse->brush();
51 brush.setStyle(Qt::SolidPattern);
52 brush.setColor(context->layerColor(this->viaNode->layers().at(i)));
53 ellipse->setBrush(brush);
54 QRectF rec(this->viaNode->pos()+offset,this->viaNode->size());
52 // QBrush brush = ellipse->brush();
53 // brush.setStyle(Qt::SolidPattern);
54 // brush.setColor(context->layerColor(this->viaNode->layers().at(i)));
55 // ellipse->setBrush(brush);
56 QRectF rec(this->viaNode->pos()+offset,QSizeF(this->viaNode->size().width()-thickness,this->viaNode->size().width()-thickness));
55 57 ellipse->setRect(rec);
56 58 ellipse->setZValue(-context->layer(viaNode->layers().at(i)));
57 59 this->addToGroup(ellipse);
58 60 }
59 61
60 62 setOpacity(0.6);
61 63 }
General Comments 0
You need to be logged in to leave comments. Login now