##// END OF EJS Templates
Non working pad rendering.. Rotation issue.
jeandet -
r12:93ef9e74723d default
parent child
Show More
@@ -1,1183 +1,1184
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 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 752 if(node->name==QIlib::Lexique::setup_c)
753 753 {
754 754 this->p_node = node;
755 755 for(int i=0;i<node->nodes.count();i++)
756 756 {
757 757 if(node->nodes.at(i)->name==QIlib::Lexique::via_drill_c)
758 758 {
759 759 this->via_dril.setNode(node->nodes.at(i));
760 760 this->p_defaultViaDrillSize = nodeValueToDouble(node->nodes.at(i));
761 761 }
762 762 }
763 763 }
764 764 }
765 765
766 766
767 767 QIlib::QIcadPcbPlotParams::QIcadPcbPlotParams(QIlib::AbstractNode *node)
768 768 :QIcadAbstractNodeWrapper(node)
769 769 {
770 770 this->setNode(node);
771 771 }
772 772
773 773 void QIlib::QIcadPcbPlotParams::setNode(QIlib::AbstractNode *node)
774 774 {
775 775 this->p_node = node;
776 776 }
777 777
778 778
779 779 QIlib::QIcadPcbSegment::QIcadPcbSegment(QIlib::AbstractNode *node)
780 780 :QIcadAbstractPcbLine(node)
781 781 {
782 782 this->setNode(node);
783 783 }
784 784
785 785 void QIlib::QIcadPcbSegment::setNode(QIlib::AbstractNode *node)
786 786 {
787 787 if(node->name==QIlib::Lexique::segment_c)
788 788 {
789 789 this->p_node = node;
790 790 for(int i=0;i<node->nodes.count();i++)
791 791 {
792 792 if(node->nodes.at(i)->name==QIlib::Lexique::start_c)
793 793 {
794 794 this->p_startpos = nodeTo2DCoords(node->nodes.at(i));
795 795 this->start.setNode(node->nodes.at(i));
796 796 }
797 797 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
798 798 {
799 799 this->p_stoppos = nodeTo2DCoords(node->nodes.at(i));
800 800 this->end.setNode(node->nodes.at(i));
801 801 }
802 802 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
803 803 {
804 804 this->p_width = nodeValueToDouble(node->nodes.at(i));
805 805 this->width.setNode(node->nodes.at(i));
806 806 }
807 807 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
808 808 {
809 809 this->p_layers = node->nodes.at(i)->Values;
810 810 this->layer.setNode(node->nodes.at(i));
811 811 }
812 812 if(node->nodes.at(i)->name==QIlib::Lexique::net_c)
813 813 {
814 814 this->net.setNode(node->nodes.at(i));
815 815 }
816 816 }
817 817 }
818 818 }
819 819
820 820
821 821 QIlib::QIcadPcbVia::QIcadPcbVia(QIlib::AbstractNode *node, double defaultDrill)
822 822 :QIcadAbstractNodeWrapper(node),p_drill(defaultDrill)
823 823 {
824 824 this->setNode(node);
825 825 }
826 826
827 827 void QIlib::QIcadPcbVia::setNode(QIlib::AbstractNode *node)
828 828 {
829 829 if(node->name==QIlib::Lexique::via_c)
830 830 {
831 831 this->p_node = node;
832 832 for(int i=0;i<node->nodes.count();i++)
833 833 {
834 834 if(node->nodes.at(i)->name==QIlib::Lexique::at_c)
835 835 {
836 836 this->at.setNode(node->nodes.at(i));
837 837 p_pos = nodeTo2DCoords(node->nodes.at(i));
838 838 }
839 839 if(node->nodes.at(i)->name==QIlib::Lexique::size_c)
840 840 {
841 841 this->sizeNode.setNode(node->nodes.at(i));
842 842 p_size = QSizeF(nodeValueToDouble(node->nodes.at(i)),nodeValueToDouble(node->nodes.at(i)));
843 843 }
844 844 if(node->nodes.at(i)->name==QIlib::Lexique::drill_c)
845 845 {
846 846 this->drillNode.setNode(node->nodes.at(i));
847 847 p_drill = nodeValueToDouble(node->nodes.at(i));
848 848 }
849 849 if(node->nodes.at(i)->name==QIlib::Lexique::layers_c)
850 850 {
851 851 this->layersNode.setNode(node->nodes.at(i));
852 852 p_layers = node->nodes.at(i)->Values;
853 853 }
854 854 if(node->nodes.at(i)->name==QIlib::Lexique::net_c)
855 855 {
856 856 this->net.setNode(node->nodes.at(i));
857 857 }
858 858 if(node->nodes.at(i)->name==QIlib::Lexique::tstamp_c)
859 859 {
860 860 this->tstamp.setNode(node->nodes.at(i));
861 861 }
862 862 }
863 863 }
864 864 }
865 865
866 866
867 867 QIlib::QIcadPcbPad::QIcadPcbPad(QIlib::AbstractNode *node)
868 868 :QIcadAbstractNodeWrapper(node)
869 869 {
870 870 this->setNode(node);
871 871 }
872 872
873 873 void QIlib::QIcadPcbPad::setNode(QIlib::AbstractNode *node)
874 874 {
875 875 if(node->name==QIlib::Lexique::pad_c)
876 876 {
877 877 this->p_node = node;
878 878 if(p_node->Values.count()>=3)
879 879 {
880 880 if(!this->p_node->Values.at((2)).compare("rect"))
881 881 {
882 882 this->p_shape = rectangle;
883 883 }
884 884 else
885 885 if(!this->p_node->Values.at((2)).compare("circle"))
886 886 {
887 887 this->p_shape = circle;
888 888 }
889
889 this->p_padNumber = nodeValueToInt(node,0);
890 890 }
891 891 for(int i=0;i<node->nodes.count();i++)
892 892 {
893 893 if(node->nodes.at(i)->name==QIlib::Lexique::at_c)
894 894 {
895 895 this->at.setNode(node->nodes.at(i));
896 896 this->p_pos = nodeTo2DCoords(node->nodes.at(i));
897 this->p_angle = nodeValueToDouble(node->nodes.at(i),2);
897 898 }
898 899 if(node->nodes.at(i)->name==QIlib::Lexique::size_c)
899 900 {
900 901 this->sizeNode.setNode(node->nodes.at(i));
901 902 this->p_size = nodeTo2DSize(node->nodes.at(i));
902 903 }
903 904 if(node->nodes.at(i)->name==QIlib::Lexique::layers_c)
904 905 {
905 906 this->layer.setNode(node->nodes.at(i));
906 907 this->p_layers = node->nodes.at(i)->Values;
907 908 }
908 909 if(node->nodes.at(i)->name==QIlib::Lexique::net_c)
909 910 {
910 911 this->netNode.setNode(node->nodes.at(i));
911 912 }
912 913 if(node->nodes.at(i)->name==QIlib::Lexique::drill_c)
913 914 {
914 915 this->drillNode.setNode(node->nodes.at(i));
915 916 this->p_drill = nodeValueToDouble(node->nodes.at(i));
916 917 }
917 918 }
918 919 }
919 920 }
920 921
921 922
922 923 QIlib::QIcadPcbFPLine::QIcadPcbFPLine(QIlib::AbstractNode *node)
923 924 :QIcadAbstractPcbLine(node)
924 925 {
925 926 this->setNode(node);
926 927 }
927 928
928 929 void QIlib::QIcadPcbFPLine::setNode(QIlib::AbstractNode *node)
929 930 {
930 931 if(node->name==QIlib::Lexique::fp_line_c)
931 932 {
932 933 this->p_node = node;
933 934 for(int i=0;i<node->nodes.count();i++)
934 935 {
935 936 if(node->nodes.at(i)->name==QIlib::Lexique::start_c)
936 937 {
937 938 this->p_startpos = nodeTo2DCoords(node->nodes.at(i));
938 939 this->start.setNode(node->nodes.at(i));
939 940 }
940 941 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
941 942 {
942 943 this->p_stoppos = nodeTo2DCoords(node->nodes.at(i));
943 944 this->end.setNode(node->nodes.at(i));
944 945 }
945 946 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
946 947 {
947 948 this->p_layers = node->nodes.at(i)->Values;
948 949 this->layer.setNode(node->nodes.at(i));
949 950 }
950 951 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
951 952 {
952 953 this->p_width = nodeValueToDouble(node->nodes.at(i));
953 954 this->width.setNode(node->nodes.at(i));
954 955 }
955 956 }
956 957 }
957 958 }
958 959
959 960
960 961 QIlib::QIcadPcbFPCircle::QIcadPcbFPCircle(QIlib::AbstractNode *node)
961 962 :QIcadAbstractNodeWrapper(node)
962 963 {
963 964 this->setNode(node);
964 965 }
965 966
966 967 void QIlib::QIcadPcbFPCircle::setNode(QIlib::AbstractNode *node)
967 968 {
968 969 if(node->name==QIlib::Lexique::fp_circle_c)
969 970 {
970 971 this->p_node = node;
971 972 for(int i=0;i<node->nodes.count();i++)
972 973 {
973 974 if(node->nodes.at(i)->name==QIlib::Lexique::center_c)
974 975 {
975 976 this->center.setNode(node->nodes.at(i));
976 977 }
977 978 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
978 979 {
979 980 this->end.setNode(node->nodes.at(i));
980 981 }
981 982 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
982 983 {
983 984 this->layer.setNode(node->nodes.at(i));
984 985 }
985 986 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
986 987 {
987 988 this->width.setNode(node->nodes.at(i));
988 989 }
989 990 }
990 991 }
991 992 }
992 993
993 994
994 995 QIlib::QIcadPcbText::QIcadPcbText(QIlib::AbstractNode *node)
995 996 :QIcadAbstractNodeWrapper(node)
996 997 {
997 998 this->setNode(node);
998 999 }
999 1000
1000 1001 void QIlib::QIcadPcbText::setNode(QIlib::AbstractNode *node)
1001 1002 {
1002 1003 if(node->name==QIlib::Lexique::gr_text_c)
1003 1004 {
1004 1005 this->p_node = node;
1005 1006 for(int i=0;i<node->nodes.count();i++)
1006 1007 {
1007 1008 if(node->nodes.at(i)->name==QIlib::Lexique::at_c)
1008 1009 {
1009 1010 this->at.setNode(node->nodes.at(i));
1010 1011 }
1011 1012 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
1012 1013 {
1013 1014 this->layer.setNode(node->nodes.at(i));
1014 1015 }
1015 1016 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
1016 1017 {
1017 1018 this->width.setNode(node->nodes.at(i));
1018 1019 }
1019 1020 if(node->nodes.at(i)->name==QIlib::Lexique::effects_c)
1020 1021 {
1021 1022 this->effects.setNode(node->nodes.at(i));
1022 1023 }
1023 1024 }
1024 1025 }
1025 1026 }
1026 1027
1027 1028
1028 1029 QIlib::QIcadPcbCircle::QIcadPcbCircle(QIlib::AbstractNode *node)
1029 1030 :QIcadAbstractNodeWrapper(node)
1030 1031 {
1031 1032 this->setNode(node);
1032 1033 }
1033 1034
1034 1035 void QIlib::QIcadPcbCircle::setNode(QIlib::AbstractNode *node)
1035 1036 {
1036 1037 if(node->name==QIlib::Lexique::gr_circle_c)
1037 1038 {
1038 1039 this->p_node = node;
1039 1040 for(int i=0;i<node->nodes.count();i++)
1040 1041 {
1041 1042 if(node->nodes.at(i)->name==QIlib::Lexique::center_c)
1042 1043 {
1043 1044 this->center.setNode(node->nodes.at(i));
1044 1045 }
1045 1046 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
1046 1047 {
1047 1048 this->end.setNode(node->nodes.at(i));
1048 1049 }
1049 1050 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
1050 1051 {
1051 1052 this->layer.setNode(node->nodes.at(i));
1052 1053 }
1053 1054 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
1054 1055 {
1055 1056 this->width.setNode(node->nodes.at(i));
1056 1057 }
1057 1058 }
1058 1059 }
1059 1060 }
1060 1061
1061 1062
1062 1063 QIlib::QIcadPcbArc::QIcadPcbArc(QIlib::AbstractNode *node)
1063 1064 :QIcadAbstractNodeWrapper(node)
1064 1065 {
1065 1066 this->setNode(node);
1066 1067 }
1067 1068
1068 1069 void QIlib::QIcadPcbArc::setNode(QIlib::AbstractNode *node)
1069 1070 {
1070 1071 if(node->name==QIlib::Lexique::gr_arc_c)
1071 1072 {
1072 1073 this->p_node = node;
1073 1074 for(int i=0;i<node->nodes.count();i++)
1074 1075 {
1075 1076 if(node->nodes.at(i)->name==QIlib::Lexique::start_c)
1076 1077 {
1077 1078 this->start.setNode(node->nodes.at(i));
1078 1079 }
1079 1080 if(node->nodes.at(i)->name==QIlib::Lexique::end_c)
1080 1081 {
1081 1082 this->end.setNode(node->nodes.at(i));
1082 1083 }
1083 1084 if(node->nodes.at(i)->name==QIlib::Lexique::angle_c)
1084 1085 {
1085 1086 this->angle.setNode(node->nodes.at(i));
1086 1087 }
1087 1088 if(node->nodes.at(i)->name==QIlib::Lexique::layer_c)
1088 1089 {
1089 1090 this->layer.setNode(node->nodes.at(i));
1090 1091 }
1091 1092 if(node->nodes.at(i)->name==QIlib::Lexique::width_c)
1092 1093 {
1093 1094 this->width.setNode(node->nodes.at(i));
1094 1095 }
1095 1096 }
1096 1097 }
1097 1098 }
1098 1099
1099 1100
1100 1101 QIlib::QIcadPcbZone::QIcadPcbZone(QIlib::AbstractNode *node)
1101 1102 :QIcadAbstractNodeWrapper(node)
1102 1103 {
1103 1104 this->setNode(node);
1104 1105 }
1105 1106
1106 1107 void QIlib::QIcadPcbZone::setNode(QIlib::AbstractNode *node)
1107 1108 {
1108 1109 if(node->name==QIlib::Lexique::zone_c)
1109 1110 {
1110 1111 this->p_node = node;
1111 1112 }
1112 1113 }
1113 1114
1114 1115
1115 1116 const QPointF QIlib::nodeTo2DCoords(QIlib::AbstractNode *node)
1116 1117 {
1117 1118 QPointF point;
1118 1119 QStringList coords=node->Values;
1119 1120 if(coords.count()>=2)
1120 1121 {
1121 1122 point.setX(coords.at(0).toDouble());
1122 1123 point.setY(coords.at(1).toDouble());
1123 1124 }
1124 1125 return point;
1125 1126 }
1126 1127
1127 1128
1128 1129 double QIlib::nodeValueToDouble(QIlib::AbstractNode *node, int index)
1129 1130 {
1130 1131 if(node->Values.count()>index)
1131 1132 {
1132 1133 return node->Values.at(index).toDouble();
1133 1134 }
1134 1135 return 0.0;
1135 1136 }
1136 1137
1137 1138
1138 1139 int QIlib::nodeValueToInt(QIlib::AbstractNode *node, int index)
1139 1140 {
1140 1141 if(node->Values.count()>index)
1141 1142 {
1142 1143 return node->Values.at(index).toInt();
1143 1144 }
1144 1145 return 0;
1145 1146 }
1146 1147
1147 1148
1148 1149 QIlib::QIcadPcbLayer::QIcadPcbLayer(QIlib::AbstractNode *node)
1149 1150 :QIcadAbstractNodeWrapper(node)
1150 1151 {
1151 1152 this->p_index = QString(this->p_node->name).remove('(').toInt();
1152 1153 if(this->p_node->Values.count()>=1)
1153 1154 {
1154 1155 this->p_name = this->p_node->Values.at(0);
1155 1156 }
1156 1157 if(this->p_node->Values.count()>=2)
1157 1158 {
1158 1159 QString typestr=this->p_node->Values.at(1);
1159 1160 this->p_type = none;
1160 1161 if(!typestr.compare("signal"))
1161 1162 {
1162 1163 this->p_type = signal;
1163 1164 }
1164 1165 else
1165 1166 if(!typestr.compare("user"))
1166 1167 {
1167 1168 this->p_type = user;
1168 1169 }
1169 1170 }
1170 1171 }
1171 1172
1172 1173
1173 1174 const QSizeF QIlib::nodeTo2DSize(QIlib::AbstractNode *node)
1174 1175 {
1175 1176 QSizeF size;
1176 1177 QStringList sz=node->Values;
1177 1178 if(sz.count()>=2)
1178 1179 {
1179 1180 size.setWidth(sz.at(0).toDouble());
1180 1181 size.setHeight(sz.at(1).toDouble());
1181 1182 }
1182 1183 return size;
1183 1184 }
@@ -1,490 +1,494
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 144 double defaultViaDrillSize(){return p_defaultViaDrillSize;}
145 145 private:
146 146 double p_defaultViaDrillSize;
147 147 };
148 148
149 149 class QIcadPcbNetClass : public QIcadAbstractNodeWrapper
150 150 {
151 151 public:
152 152 QIcadPcbNetClass(QIlib::AbstractNode* node);
153 153 QIcadPcbNetClass(){}
154 154 QIcadAbstractNodeWrapper clearance;
155 155 QIcadAbstractNodeWrapper trace_width;
156 156 QIcadAbstractNodeWrapper via_dia;
157 157 QIcadAbstractNodeWrapper via_drill;
158 158 QIcadAbstractNodeWrapper uvia_dia;
159 159 QIcadAbstractNodeWrapper uvia_drill;
160 160 QList<QIcadAbstractNodeWrapper*> nets;
161 161 void setNode(QIlib::AbstractNode* node);
162 162 };
163 163
164 164 class QIcadPcbFpTextEffectsFont : public QIcadAbstractNodeWrapper
165 165 {
166 166 public:
167 167 QIcadPcbFpTextEffectsFont(QIlib::AbstractNode* node);
168 168 QIcadAbstractNodeWrapper size;
169 169 void setNode(QIlib::AbstractNode* node);
170 170 };
171 171
172 172 class QIcadPcbFpTextEffects : public QIcadAbstractNodeWrapper
173 173 {
174 174 public:
175 175 QIcadPcbFpTextEffects(QIlib::AbstractNode* node);
176 176 QIcadPcbFpTextEffects(){}
177 177 QIcadAbstractNodeWrapper font;
178 178 QIcadAbstractNodeWrapper thickness;
179 179 void setNode(QIlib::AbstractNode* node);
180 180 };
181 181
182 182 class QIcadPcbFPText : public QIcadAbstractNodeWrapper
183 183 {
184 184 public:
185 185 QIcadPcbFPText(QIlib::AbstractNode* node);
186 186 QIcadPcbFPText(){}
187 187 QIcadAbstractNodeWrapper at;
188 188 QIcadAbstractNodeWrapper layer;
189 189 QIcadPcbFpTextEffects effects;
190 190 void setNode(QIlib::AbstractNode* node);
191 191 };
192 192
193 193 class QIcadPcbModuleModel : public QIcadAbstractNodeWrapper
194 194 {
195 195 public:
196 196 QIcadPcbModuleModel(QIlib::AbstractNode* node);
197 197 QIcadPcbModuleModel(){}
198 198 QIcadAbstractNodeWrapper at;
199 199 QIcadAbstractNodeWrapper scale;
200 200 QIcadAbstractNodeWrapper rotate;
201 201 void setNode(QIlib::AbstractNode* node);
202 202 };
203 203
204 204 class QIcadPcbDimension : public QIcadAbstractNodeWrapper
205 205 {
206 206 public:
207 207 QIcadPcbDimension(QIlib::AbstractNode* node);
208 208 QIcadPcbDimension(){}
209 209 QIcadAbstractNodeWrapper width;
210 210 QIcadAbstractNodeWrapper layer;
211 211 QIcadAbstractNodeWrapper gr_text;
212 212 QIcadAbstractNodeWrapper feature1;
213 213 QIcadAbstractNodeWrapper feature2;
214 214 QIcadAbstractNodeWrapper crossbar;
215 215 QIcadAbstractNodeWrapper arrow1a;
216 216 QIcadAbstractNodeWrapper arrow1b;
217 217 QIcadAbstractNodeWrapper arrow2a;
218 218 QIcadAbstractNodeWrapper arrow2b;
219 219 void setNode(QIlib::AbstractNode* node);
220 220 };
221 221
222 222 class QIcadPcbPad : public QIcadAbstractNodeWrapper
223 223 {
224 224 public:
225 225 typedef enum
226 226 {
227 227 rectangle,
228 228 circle
229 229 }padShape;
230 230 QIcadPcbPad(QIlib::AbstractNode* node);
231 231 QIcadPcbPad(){}
232 232 QIcadAbstractNodeWrapper at;
233 233 QIcadAbstractNodeWrapper sizeNode;
234 234 QIcadAbstractNodeWrapper layer;
235 235 QIcadAbstractNodeWrapper netNode;
236 236 QIcadAbstractNodeWrapper drillNode;
237 237 const QStringList& layers(){return p_layers;}
238 238 const QSizeF& size(){return p_size;}
239 239 const QPointF& pos(){return p_pos;}
240 240 double drill(){return p_drill;}
241 double angle(){return p_angle;}
241 242 padShape shape(){return p_shape;}
243 int padNumber(){return p_padNumber;}
242 244 void setNode(QIlib::AbstractNode* node);
243 245 private:
246 int p_padNumber;
244 247 padShape p_shape;
245 248 double p_drill;
249 double p_angle;
246 250 QSizeF p_size;
247 251 QPointF p_pos;
248 252 QStringList p_layers;
249 253 };
250 254
251 255 class QIcadPcbFPLine : public QIcadAbstractPcbLine
252 256 {
253 257 public:
254 258 QIcadPcbFPLine(QIlib::AbstractNode* node);
255 259 QIcadPcbFPLine(){}
256 260 QIcadAbstractNodeWrapper start;
257 261 QIcadAbstractNodeWrapper end;
258 262 QIcadAbstractNodeWrapper layer;
259 263 QIcadAbstractNodeWrapper width;
260 264 void setNode(QIlib::AbstractNode* node);
261 265 };
262 266
263 267 class QIcadPcbFPCircle : public QIcadAbstractNodeWrapper
264 268 {
265 269 public:
266 270 QIcadPcbFPCircle(QIlib::AbstractNode* node);
267 271 QIcadPcbFPCircle(){}
268 272 QIcadAbstractNodeWrapper center;
269 273 QIcadAbstractNodeWrapper end;
270 274 QIcadAbstractNodeWrapper layer;
271 275 QIcadAbstractNodeWrapper width;
272 276 void setNode(QIlib::AbstractNode* node);
273 277 };
274 278
275 279 class QIcadPcbModule : public QIcadAbstractNodeWrapper
276 280 {
277 281 public:
278 282 QIcadPcbModule(QIlib::AbstractNode* node);
279 283 QIcadPcbModule(){}
280 284 const QPointF& pos();
281 285 double angle();
282 286 QIcadAbstractNodeWrapper layer;
283 287 QIcadAbstractNodeWrapper tedit;
284 288 QIcadAbstractNodeWrapper tstamp;
285 289 QIcadAbstractNodeWrapper at;
286 290 QIcadAbstractNodeWrapper descr;
287 291 QIcadAbstractNodeWrapper tags;
288 292 QIcadAbstractNodeWrapper path;
289 293 QIcadAbstractNodeWrapper attr;
290 294 QList<QIcadPcbFPText*> fp_texts;
291 295 QList<QIcadPcbFPLine*> fp_lines;
292 296 QList<QIcadPcbFPCircle*> fp_circles;
293 297 QList<QIcadPcbPad*> pads;
294 298 QIcadPcbModuleModel model;
295 299 void setNode(QIlib::AbstractNode* node);
296 300 void clrPads();
297 301 void apendPad(QIlib::AbstractNode* node);
298 302 void clrTexts();
299 303 void apendText(QIlib::AbstractNode* node);
300 304 void clrLines();
301 305 void apendLine(QIlib::AbstractNode* node);
302 306 void clrCircles();
303 307 void apendCircle(QIlib::AbstractNode* node);
304 308 private:
305 309 QPointF p_pos;
306 310 double p_angle;
307 311 };
308 312
309 313 class QIcadPcbSegment : public QIcadAbstractPcbLine
310 314 {
311 315 public:
312 316 QIcadPcbSegment(QIlib::AbstractNode* node);
313 317 QIcadPcbSegment(){}
314 318 QIcadAbstractNodeWrapper start;
315 319 QIcadAbstractNodeWrapper end;
316 320 QIcadAbstractNodeWrapper width;
317 321 QIcadAbstractNodeWrapper layer;
318 322 QIcadAbstractNodeWrapper net;
319 323 void setNode(QIlib::AbstractNode* node);
320 324 };
321 325
322 326 class QIcadPcbVia : public QIcadAbstractNodeWrapper
323 327 {
324 328 public:
325 329 QIcadPcbVia(QIlib::AbstractNode* node, double defaultDrill=0);
326 330 QIcadPcbVia(){}
327 331 QIcadAbstractNodeWrapper at;
328 332 QIcadAbstractNodeWrapper sizeNode;
329 333 QIcadAbstractNodeWrapper drillNode;
330 334 QIcadAbstractNodeWrapper layersNode;
331 335 QIcadAbstractNodeWrapper net;
332 336 QIcadAbstractNodeWrapper tstamp;
333 337 void setNode(QIlib::AbstractNode* node);
334 338 const QStringList& layers(){return p_layers;}
335 339 const QSizeF& size(){return p_size;}
336 340 const QPointF& pos(){return p_pos;}
337 341 double drill(){return p_drill;}
338 342 private:
339 343 double p_drill;
340 344 QSizeF p_size;
341 345 QPointF p_pos;
342 346 QStringList p_layers;
343 347 };
344 348
345 349 class QIcadPcbLine : public QIcadAbstractPcbLine
346 350 {
347 351 public:
348 352 QIcadPcbLine(QIlib::AbstractNode* node);
349 353 QIcadPcbLine(){}
350 354 QIcadAbstractNodeWrapper start;
351 355 QIcadAbstractNodeWrapper end;
352 356 QIcadAbstractNodeWrapper angle;
353 357 QIcadAbstractNodeWrapper layer;
354 358 QIcadAbstractNodeWrapper width;
355 359 void setNode(QIlib::AbstractNode* node);
356 360 };
357 361
358 362 class QIcadPcbZone : public QIcadAbstractNodeWrapper
359 363 {
360 364 public:
361 365 QIcadPcbZone(QIlib::AbstractNode* node);
362 366 QIcadPcbZone(){}
363 367 void setNode(QIlib::AbstractNode* node);
364 368 };
365 369
366 370 class QIcadPcbArc : public QIcadAbstractNodeWrapper
367 371 {
368 372 public:
369 373 QIcadPcbArc(QIlib::AbstractNode* node);
370 374 QIcadPcbArc(){}
371 375 QIcadAbstractNodeWrapper start;
372 376 QIcadAbstractNodeWrapper end;
373 377 QIcadAbstractNodeWrapper angle;
374 378 QIcadAbstractNodeWrapper layer;
375 379 QIcadAbstractNodeWrapper width;
376 380 void setNode(QIlib::AbstractNode* node);
377 381 };
378 382
379 383 class QIcadPcbCircle : public QIcadAbstractNodeWrapper
380 384 {
381 385 public:
382 386 QIcadPcbCircle(QIlib::AbstractNode* node);
383 387 QIcadPcbCircle(){}
384 388 QIcadAbstractNodeWrapper center;
385 389 QIcadAbstractNodeWrapper end;
386 390 QIcadAbstractNodeWrapper layer;
387 391 QIcadAbstractNodeWrapper width;
388 392 void setNode(QIlib::AbstractNode* node);
389 393 };
390 394
391 395 class QIcadPcbText : public QIcadAbstractNodeWrapper
392 396 {
393 397 public:
394 398 QIcadPcbText(QIlib::AbstractNode* node);
395 399 QIcadPcbText(){}
396 400 QIcadAbstractNodeWrapper at;
397 401 QIcadAbstractNodeWrapper layer;
398 402 QIcadAbstractNodeWrapper width;
399 403 QIcadPcbFpTextEffects effects;
400 404 void setNode(QIlib::AbstractNode* node);
401 405 };
402 406
403 407 class QIcadPcbLayers : public QIcadAbstractNodeWrapper
404 408 {
405 409 public:
406 410 QIcadPcbLayers(QIlib::AbstractNode* node);
407 411 QIcadPcbLayers(){}
408 412 QList<QIcadPcbLayer*> layers;
409 413 void setNode(QIlib::AbstractNode* node);
410 414 void clrLayers();
411 415 void apendLayer(QIlib::AbstractNode* node);
412 416 };
413 417
414 418 class QIcadPcbGeneralInfo : public QIcadAbstractNodeWrapper
415 419 {
416 420 public:
417 421 QIcadPcbGeneralInfo(QIlib::AbstractNode* node);
418 422 QIcadPcbGeneralInfo(){}
419 423 QIcadAbstractNodeWrapper links;
420 424 QIcadAbstractNodeWrapper no_connections;
421 425 QIcadAbstractNodeWrapper area;
422 426 QIcadAbstractNodeWrapper thickness;
423 427 QIcadAbstractNodeWrapper drawings;
424 428 QIcadAbstractNodeWrapper tracks;
425 429 QIcadAbstractNodeWrapper zones;
426 430 QIcadAbstractNodeWrapper modules;
427 431 QIcadAbstractNodeWrapper nets;
428 432 void setNode(QIlib::AbstractNode* node);
429 433 };
430 434
431 435 class QIcadPcbRoot : public QIcadAbstractNodeWrapper
432 436 {
433 437 public:
434 438 QIcadPcbRoot(QIlib::AbstractNode* node);
435 439 QIcadAbstractNodeWrapper version;
436 440 QIcadAbstractNodeWrapper host;
437 441 QIcadAbstractNodeWrapper page;
438 442 QIcadPcbGeneralInfo general;
439 443 QIcadPcbLayers layers;
440 444 QIcadPcbSetup setup;
441 445 QList<QIcadAbstractNodeWrapper*> nets;
442 446 QList<QIcadPcbModule*> modules;
443 447 QList<QIcadPcbDimension*> dimensions;
444 448 QList<QIcadPcbLine*> lines;
445 449 QList<QIcadPcbSegment*> segments;
446 450 QList<QIcadPcbVia*> vias;
447 451 QList<QIcadPcbArc*> arcs;
448 452 QList<QIcadPcbCircle*> circles;
449 453 QList<QIcadPcbText*> texts;
450 454 QList<QIcadPcbZone*> zones;
451 455 void setNode(QIlib::AbstractNode* node);
452 456 void clrNets();
453 457 void apendNet(QIlib::AbstractNode* node);
454 458 void clrModules();
455 459 void apendModule(QIlib::AbstractNode* node);
456 460 void clrDimensions();
457 461 void apendDimension(QIlib::AbstractNode* node);
458 462 void apendLine(QIlib::AbstractNode* node);
459 463 void clrLines();
460 464 void clrSegments();
461 465 void apendSegment(QIlib::AbstractNode* node);
462 466 void clrVias();
463 467 void apendVia(QIlib::AbstractNode* node);
464 468 void clrArcs();
465 469 void apendArc(QIlib::AbstractNode* node);
466 470 void clrCircles();
467 471 void apendCircle(QIlib::AbstractNode* node);
468 472 void clrTexts();
469 473 void apendText(QIlib::AbstractNode* node);
470 474 void clrZones();
471 475 void apendZone(QIlib::AbstractNode* node);
472 476 };
473 477
474 478 class QIcadPcb : private lispLike_Driver
475 479 {
476 480 public:
477 481 QIcadPcb();
478 482 bool parsePcb(const QString& pcb);
479 483 QString toString();
480 484 QString fileName;
481 485 QString print();
482 486
483 487 QIcadPcbRoot* pcbRoot;
484 488 private:
485 489 void updateConcreteTree();
486 490 };
487 491
488 492
489 493 }
490 494 #endif // QICADPCB_H
@@ -1,87 +1,105
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 "mainwindow.h"
23 23 #include "ui_mainwindow.h"
24 24 #include "pcbmodule.h"
25 25 #include "pcbline.h"
26 26 #include "pcbvia.h"
27 #include <QFileDialog>
27 28
28 29
29 30 MainWindow::MainWindow(QWidget *parent) :
30 31 QMainWindow(parent),
31 32 ui(new Ui::MainWindow)
32 33 {
33 34 ui->setupUi(this);
34 35 this->p_scene = new QGraphicsScene();
35 this->p_scene->setSceneRect(0, 0, 500, 200);
36
37 36 this->context = new PCBContext();
38 37 this->ui->graphicsView->setScene(this->p_scene);
39 QIlib::QIcadPcb pcbDriver;
40 // pcbDriver.parsePcb("/opt/kicadTools/test/testFiles/pcb2.kicad_pcb");
41 // pcbDriver.parsePcb("/home/jeandet/Documents/PCB/ADC_STAMP/ADC_STAMP.kicad_pcb");
42 pcbDriver.parsePcb("/usr/share/kicad/demos/video/video.kicad_pcb");
43 // pcbDriver.parsePcb("/usr/share/kicad/demos/kit-dev-coldfire-xilinx_5213/kit-dev-coldfire-xilinx_5213.kicad_pcb");
44 for(int i=0;i<pcbDriver.pcbRoot->layers.layers.count();i++)
45 {
46 this->context->addlayer(pcbDriver.pcbRoot->layers.layers.at(i)->name(),pcbDriver.pcbRoot->layers.layers.at(i)->index());
47 }
48 for(int i=0;i<pcbDriver.pcbRoot->modules.count();i++)
49 {
50 this->p_scene->addItem(new PCBModule(pcbDriver.pcbRoot->modules.at(i),this->context));
51 }
52 for(int i=0;i<pcbDriver.pcbRoot->lines.count();i++)
53 {
54 this->p_scene->addItem(new PCBLine((QIlib::QIcadAbstractPcbLine*)pcbDriver.pcbRoot->lines.at(i),this->context));
55 }
56 for(int i=0;i<pcbDriver.pcbRoot->segments.count();i++)
57 {
58 this->p_scene->addItem(new PCBLine((QIlib::QIcadAbstractPcbLine*)pcbDriver.pcbRoot->segments.at(i),this->context));
59 }
60 for(int i=0;i<pcbDriver.pcbRoot->vias.count();i++)
61 {
62 this->p_scene->addItem(new PCBVia(pcbDriver.pcbRoot->vias.at(i),this->context));
63 }
38 this->pcbDriver =NULL;
64 39 connect(this->ui->actionRedraw,SIGNAL(triggered(bool)),this,SLOT(redraw()));
40 connect(this->ui->actionOpen,SIGNAL(triggered(bool)),this,SLOT(openFile()));
65 41 }
66 42
67 43 MainWindow::~MainWindow()
68 44 {
69 45 delete ui;
70 46 }
71 47
72 48 void MainWindow::redraw()
73 49 {
74 50 this->p_scene->update();
75 51 }
76 52
53 void MainWindow::openFile()
54 {
55 QString file = QFileDialog::getOpenFileName(this,tr("Open kicad PCB file"),
56 "",
57 tr("PCB file (*.kicad_pcb)"));
58 if(QFile::exists(file))
59 loadFile(file);
60 }
61
77 62 void MainWindow::changeEvent(QEvent *e)
78 63 {
79 64 QMainWindow::changeEvent(e);
80 65 switch (e->type()) {
81 66 case QEvent::LanguageChange:
82 67 ui->retranslateUi(this);
83 68 break;
84 69 default:
85 70 break;
86 71 }
87 72 }
73
74 void MainWindow::loadFile(const QString &file)
75 {
76 this->p_scene->setSceneRect(0, 0, 500, 200);
77 if(pcbDriver!=NULL)delete pcbDriver;
78 pcbDriver = new QIlib::QIcadPcb();
79 this->context->clear();
80 this->p_scene->clear();
81 // pcbDriver.parsePcb("/opt/kicadTools/test/testFiles/pcb2.kicad_pcb");
82 // pcbDriver.parsePcb("/home/jeandet/Documents/PCB/ADC_STAMP/ADC_STAMP.kicad_pcb");
83 pcbDriver->parsePcb(file);
84 // pcbDriver.parsePcb("/usr/share/kicad/demos/kit-dev-coldfire-xilinx_5213/kit-dev-coldfire-xilinx_5213.kicad_pcb");
85 for(int i=0;i<pcbDriver->pcbRoot->layers.layers.count();i++)
86 {
87 this->context->addlayer(pcbDriver->pcbRoot->layers.layers.at(i)->name(),pcbDriver->pcbRoot->layers.layers.at(i)->index());
88 }
89 for(int i=0;i<pcbDriver->pcbRoot->modules.count();i++)
90 {
91 this->p_scene->addItem(new PCBModule(pcbDriver->pcbRoot->modules.at(i),this->context));
92 }
93 for(int i=0;i<pcbDriver->pcbRoot->lines.count();i++)
94 {
95 this->p_scene->addItem(new PCBLine((QIlib::QIcadAbstractPcbLine*)pcbDriver->pcbRoot->lines.at(i),this->context));
96 }
97 for(int i=0;i<pcbDriver->pcbRoot->segments.count();i++)
98 {
99 this->p_scene->addItem(new PCBLine((QIlib::QIcadAbstractPcbLine*)pcbDriver->pcbRoot->segments.at(i),this->context));
100 }
101 for(int i=0;i<pcbDriver->pcbRoot->vias.count();i++)
102 {
103 this->p_scene->addItem(new PCBVia(pcbDriver->pcbRoot->vias.at(i),this->context));
104 }
105 }
@@ -1,57 +1,60
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 #ifndef MAINWINDOW_H
23 23 #define MAINWINDOW_H
24 24
25 25 #include <QMainWindow>
26 26 #include <QGraphicsScene>
27 27 #include <qicadnetlist.h>
28 28 #include <qicadpcb.h>
29 29 #include <QMap>
30 30 #include <pcbcontext.h>
31 31
32 32
33 33
34 34 namespace Ui {
35 35 class MainWindow;
36 36 }
37 37
38 38 class MainWindow : public QMainWindow
39 39 {
40 40 Q_OBJECT
41 41
42 42 public:
43 43 explicit MainWindow(QWidget *parent = 0);
44 44 ~MainWindow();
45 45
46 46 public slots:
47 47 void redraw();
48 void openFile();
48 49 protected:
49 50 void changeEvent(QEvent *e);
50 51
51 52 private:
53 void loadFile(const QString& file);
52 54 Ui::MainWindow *ui;
53 55 QGraphicsScene* p_scene;
54 56 PCBContext* context;
57 QIlib::QIcadPcb* pcbDriver;
55 58 };
56 59
57 60 #endif // MAINWINDOW_H
@@ -1,73 +1,79
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 "pcbcontext.h"
23 23
24 24 Qt::GlobalColor Colours[]= {
25 25 Qt::red,
26 26 Qt::blue,
27 27 Qt::black,
28 28 Qt::green,
29 29 Qt::darkGreen,
30 30 Qt::cyan,
31 31 Qt::darkRed,
32 32 Qt::gray,
33 33 Qt::yellow,
34 34 Qt::darkBlue,
35 35 Qt::darkCyan,
36 36 Qt::magenta,
37 37 Qt::darkMagenta,
38 38 Qt::darkYellow,
39 39 Qt::darkGray,
40 40 Qt::lightGray
41 41 };
42 42
43 43 PCBContext::PCBContext(QObject *parent) : QObject(parent)
44 44 {
45 45
46 46 }
47 47
48 48 void PCBContext::addlayer(const QString &name, int number)
49 49 {
50 50 this->layers_map[name]=number;
51 51 layers_colors[number] = Colours[number%15];
52 52 }
53 53
54 54 int PCBContext::layer(const QString &name)
55 55 {
56 56 return layers_map[name];
57 57 }
58 58
59 59 const QColor &PCBContext::layerColor(const QString &name)
60 60 {
61 61 return layers_colors[layers_map[name]];
62 62 }
63 63
64 64 const QColor &PCBContext::layerColor(int number)
65 65 {
66 66 return layers_colors[number];
67 67 }
68 68
69 69 const QString PCBContext::layer(int number)
70 70 {
71 71 return layers_map.key(number);
72 72 }
73 73
74 void PCBContext::clear()
75 {
76 this->layers_colors.clear();
77 this->layers_map.clear();
78 }
79
@@ -1,48 +1,49
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 #ifndef PCBCONTEXT_H
23 23 #define PCBCONTEXT_H
24 24
25 25 #include <QObject>
26 26 #include <QWidget>
27 27 #include <QMap>
28 28
29 29 class PCBContext : public QObject
30 30 {
31 31 Q_OBJECT
32 32 public:
33 33 explicit PCBContext(QObject *parent = 0);
34 34 void addlayer(const QString& name,int number);
35 35 int layer(const QString& name);
36 36 const QColor& layerColor(const QString& name);
37 37 const QColor& layerColor(int number);
38 38 const QString layer(int number);
39 void clear();
39 40 signals:
40 41
41 42 public slots:
42 43
43 44 private:
44 45 QMap<int,QColor> layers_colors;
45 46 QMap<QString,int> layers_map;
46 47 };
47 48
48 49 #endif // PCBCONTEXT_H
@@ -1,80 +1,88
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 "pcbrectpad.h"
23 23 #include <QPen>
24 24
25 25 PCBRectPad::PCBRectPad(QIlib::QIcadPcbPad *padNode, PCBContext *context)
26 26 :QGraphicsItemGroup(),padNode(padNode),context(context)
27 27 {
28 28 this->init(QPointF(0.0,0.0));
29 29 }
30 30
31 31
32 32
33 33 PCBRectPad::PCBRectPad(QIlib::QIcadPcbPad *padNode, QPointF offset, PCBContext *context)
34 34 :QGraphicsItemGroup(),padNode(padNode),context(context)
35 35 {
36 36 this->init(offset);
37 37 }
38 38
39 39 void PCBRectPad::init( QPointF offset)
40 40 {
41 41 this->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
42 42 offset-=QPointF(this->padNode->size().width()/2,this->padNode->size().height()/2);
43 43 if(this->padNode->shape()==QIlib::QIcadPcbPad::rectangle)
44 44 {
45 QRectF rec(this->padNode->pos()+offset,this->padNode->size());
45 46 for(int i=0;i<this->padNode->layers().count();i++)
46 47 {
47 48 QGraphicsRectItem* rect = new QGraphicsRectItem();
49 rect->setTransformOriginPoint(rec.center());
48 50 QPen pen = rect->pen();
49 51 pen.setWidthF(0.01);
50 52 rect->setPen(pen);
51 53 QBrush brush = rect->brush();
52 54 brush.setStyle(Qt::SolidPattern);
53 55 brush.setColor(context->layerColor(this->padNode->layers().at(i)));
54 56 rect->setBrush(brush);
55 QRectF rec(this->padNode->pos()+offset,this->padNode->size());
56 57 rect->setRect(rec);
57 58 rect->setZValue(-context->layer(padNode->layers().at(i)));
59 rect->setRotation(padNode->angle());
58 60 this->addToGroup(rect);
59 61 }
62 QGraphicsTextItem* text=new QGraphicsTextItem(QString::number(padNode->padNumber()));
63 text->setPos(rec.center());
64 text->setScale(0.01);
65 text->setZValue(1);
66 this->addToGroup(text);
67
60 68 }
61 69 if(this->padNode->shape()==QIlib::QIcadPcbPad::circle)
62 70 {
63 71 for(int i=0;i<this->padNode->layers().count();i++)
64 72 {
65 73 QGraphicsEllipseItem* ellipse = new QGraphicsEllipseItem();
66 74 QPen pen = ellipse->pen();
67 75 pen.setWidthF(0.01);
68 76 ellipse->setPen(pen);
69 77 QBrush brush = ellipse->brush();
70 78 brush.setStyle(Qt::SolidPattern);
71 79 brush.setColor(context->layerColor(this->padNode->layers().at(i)));
72 80 ellipse->setBrush(brush);
73 81 QRectF rec(this->padNode->pos()+offset,this->padNode->size());
74 82 ellipse->setRect(rec);
75 83 ellipse->setZValue(-context->layer(padNode->layers().at(i)));
76 84 this->addToGroup(ellipse);
77 85 }
78 86 }
79 87 setOpacity(0.6);
80 88 }
@@ -1,63 +1,66
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 this->path.addEllipse(this->viaNode->pos(),this->viaNode->size().width()/2,this->viaNode->size().height()/2);
41 double thickness = (this->viaNode->size().width()-this->viaNode->drill())/2;
42 this->path.addEllipse(this->viaNode->pos(),(this->viaNode->size().width()/2)-thickness,(this->viaNode->size().height()/2)-thickness);
40 43 this->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
41 44 this->setFlags(ItemIsMovable|ItemIsSelectable|ItemIsFocusable);
42 45 offset-=QPointF(this->viaNode->size().width()/2,this->viaNode->size().height()/2);
43 46
44 47 for(int i=0;i<this->viaNode->layers().count();i++)
45 48 {
46 QGraphicsEllipseItem* ellipse = new QGraphicsEllipseItem();
47 QPen pen = ellipse->pen();
48 double thickness = (this->viaNode->size().width()-this->viaNode->drill())/2;
49 pen.setWidthF(thickness);
49 QGraphicsPathItem* pathitem = new QGraphicsPathItem();
50 QPen pen = pathitem->pen();
51 pen.setWidthF(0.01);
50 52
51 ellipse->setPen(pen);
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));
57 ellipse->setRect(rec);
58 ellipse->setZValue(-context->layer(viaNode->layers().at(i)));
59 this->addToGroup(ellipse);
53 pathitem->setPen(pen);
54 QBrush brush = pathitem->brush();
55 brush.setStyle(Qt::SolidPattern);
56 brush.setColor(context->layerColor(this->viaNode->layers().at(i)));
57 pathitem->setBrush(brush);
58 // QRectF rec(this->viaNode->pos()+offset,QSizeF(this->viaNode->size().width()-thickness,this->viaNode->size().width()-thickness));
59 // pathitem->setRect(rec);
60 pathitem->setZValue(-context->layer(viaNode->layers().at(i)));
61 pathitem->setPath(path);
62 this->addToGroup(pathitem);
60 63 }
61 64
62 65 setOpacity(0.6);
63 66 }
@@ -1,46 +1,48
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 #ifndef PCBVIA_H
23 23 #define PCBVIA_H
24 24 #include <QObject>
25 25 #include <QWidget>
26 26 #include <QGraphicsRectItem>
27 27 #include <QGraphicsItemGroup>
28 28 #include <pcbcontext.h>
29 29 #include <qicadpcb.h>
30 #include <QPainterPath>
30 31
31 32 class PCBVia: public QGraphicsItemGroup
32 33 {
33 34 public:
34 35 PCBVia(QIlib::QIcadPcbVia* viaNode,PCBContext* context);
35 36 PCBVia(QIlib::QIcadPcbVia* viaNode,QPointF offset,PCBContext* context);
36 37 private:
37 38 void init(QPointF offset);
38 39 QIlib::QIcadPcbVia* viaNode;
39 40 QString name;
40 41 QPointF pos;
41 42 QRectF size;
42 43 QList<int> layers;
43 44 PCBContext* context;
45 QPainterPath path;
44 46 };
45 47
46 48 #endif // PCBVIA_H
General Comments 0
You need to be logged in to leave comments. Login now