35#include <wx/filename.h>
36#include <wx/textfile.h>
37#include <wx/tokenzr.h>
93 result.reserve( aInput.length() + 8 );
97 while( i < aInput.length() )
99 if( i + 1 < aInput.length() && aInput[i] ==
'\\' && aInput[i + 1] ==
'_' )
101 size_t barEnd = aInput.find( wxT(
"\\_" ), i + 2 );
103 if( barEnd != wxString::npos )
106 result += aInput.Mid( i + 2, barEnd - ( i + 2 ) );
116 else if( i + 1 < aInput.length() && aInput[i] ==
'\\' && aInput[i + 1] ==
'\\' )
137 static const std::map<wxString, wxString> symbols = {
138 { wxT(
"resistor-1.sym" ),
139 wxT(
"v 20031231 1\n"
140 "L 600 200 500 0 3 0 0 0 -1 -1\n"
141 "L 500 0 400 200 3 0 0 0 -1 -1\n"
142 "L 400 200 300 0 3 0 0 0 -1 -1\n"
143 "L 300 0 200 200 3 0 0 0 -1 -1\n"
144 "T 300 400 5 10 0 0 0 0 1\n"
146 "L 600 200 700 0 3 0 0 0 -1 -1\n"
147 "L 700 0 750 100 3 0 0 0 -1 -1\n"
148 "P 900 100 750 100 1 0 0\n"
150 "T 800 150 5 8 0 1 0 0 1\n"
152 "T 800 150 5 8 0 0 0 0 1\n"
154 "T 800 150 5 8 0 1 0 0 1\n"
156 "T 800 150 5 8 0 1 0 0 1\n"
159 "P 0 100 152 100 1 0 0\n"
161 "T 100 150 5 8 0 1 0 0 1\n"
163 "T 100 150 5 8 0 0 0 0 1\n"
165 "T 100 150 5 8 0 1 0 0 1\n"
167 "T 100 150 5 8 0 1 0 0 1\n"
170 "L 201 200 150 100 3 0 0 0 -1 -1\n"
171 "T 200 300 8 10 1 1 0 0 1\n"
174 { wxT(
"resistor-2.sym" ),
175 wxT(
"v 20031231 1\n"
176 "B 200 0 600 200 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n"
177 "T 300 400 5 10 0 0 0 0 1\n"
179 "P 900 100 800 100 1 0 0\n"
181 "T 800 150 5 8 0 1 0 0 1\n"
183 "T 800 150 5 8 0 0 0 0 1\n"
185 "T 800 150 5 8 0 1 0 0 1\n"
187 "T 800 150 5 8 0 1 0 0 1\n"
190 "P 0 100 200 100 1 0 0\n"
192 "T 100 150 5 8 0 1 0 0 1\n"
194 "T 100 150 5 8 0 0 0 0 1\n"
196 "T 100 150 5 8 0 1 0 0 1\n"
198 "T 100 150 5 8 0 1 0 0 1\n"
201 "T 200 300 8 10 1 1 0 0 1\n"
204 { wxT(
"capacitor-1.sym" ),
205 wxT(
"v 20050820 1\n"
206 "P 0 200 200 200 1 0 0\n"
208 "T 150 250 5 8 0 1 0 6 1\n"
210 "T 150 150 5 8 0 1 0 8 1\n"
212 "T 200 200 9 8 0 1 0 0 1\n"
214 "T 200 200 5 8 0 1 0 2 1\n"
217 "P 900 200 700 200 1 0 0\n"
219 "T 750 250 5 8 0 1 0 0 1\n"
221 "T 750 150 5 8 0 1 0 2 1\n"
223 "T 700 200 9 8 0 1 0 6 1\n"
225 "T 700 200 5 8 0 1 0 8 1\n"
228 "L 400 400 400 0 3 0 0 0 -1 -1\n"
229 "L 500 400 500 0 3 0 0 0 -1 -1\n"
230 "L 700 200 500 200 3 0 0 0 -1 -1\n"
231 "L 400 200 200 200 3 0 0 0 -1 -1\n"
232 "T 200 700 5 10 0 0 0 0 1\n"
234 "T 200 500 8 10 1 1 0 0 1\n"
237 { wxT(
"capacitor-2.sym" ),
238 wxT(
"v 20050820 1\n"
239 "P 0 200 200 200 1 0 0\n"
241 "T 150 250 5 8 1 1 0 6 1\n"
243 "T 200 150 5 8 0 1 0 8 1\n"
245 "T 250 200 9 8 0 1 0 0 1\n"
247 "T 250 200 5 8 0 1 0 2 1\n"
250 "P 900 200 700 200 1 0 0\n"
252 "T 750 250 5 8 1 1 0 0 1\n"
254 "T 700 150 5 8 0 1 0 2 1\n"
256 "T 650 200 9 8 0 1 0 6 1\n"
258 "T 650 200 5 8 0 1 0 8 1\n"
261 "L 400 400 400 0 3 0 0 0 -1 -1\n"
262 "A 1200 200 700 165 30 3 0 0 0 -1 -1\n"
263 "L 700 200 500 200 3 0 0 0 -1 -1\n"
264 "L 400 200 200 200 3 0 0 0 -1 -1\n"
265 "L 289 400 289 300 3 0 0 0 -1 -1\n"
266 "L 340 349 240 349 3 0 0 0 -1 -1\n"
267 "T 200 700 5 10 0 0 0 0 1\n"
268 "device=POLARIZED_CAPACITOR\n"
269 "T 200 500 8 10 1 1 0 0 1\n"
272 { wxT(
"gnd-1.sym" ),
273 wxT(
"v 20031231 1\n"
274 "P 100 100 100 300 1 0 1\n"
276 "T 158 161 5 4 0 1 0 0 1\n"
278 "T 158 161 5 4 0 0 0 0 1\n"
280 "T 158 161 5 4 0 1 0 0 1\n"
282 "T 158 161 5 4 0 1 0 0 1\n"
285 "L 0 100 200 100 3 0 0 0 -1 -1\n"
286 "L 55 50 145 50 3 0 0 0 -1 -1\n"
287 "L 80 10 120 10 3 0 0 0 -1 -1\n"
288 "T 300 50 8 10 0 0 0 0 1\n"
291 { wxT(
"generic-power.sym" ),
292 wxT(
"v 20031231 1\n"
293 "P 200 0 200 200 1 0 0\n"
295 "T 250 50 5 6 0 1 0 0 1\n"
297 "T 250 50 5 6 0 0 0 0 1\n"
299 "T 250 50 5 6 0 1 0 0 1\n"
301 "T 250 50 5 6 0 1 0 0 1\n"
304 "L 50 200 350 200 3 0 0 0 -1 -1\n"
305 "T 200 250 8 10 1 1 0 3 1\n"
308 { wxT(
"input-1.sym" ),
309 wxT(
"v 20031231 1\n"
310 "P 600 100 800 100 1 0 1\n"
312 "T 450 50 5 6 0 1 0 0 1\n"
314 "T 450 50 5 6 0 0 0 0 1\n"
317 "L 0 200 0 0 3 0 0 0 -1 -1\n"
318 "L 0 200 500 200 3 0 0 0 -1 -1\n"
319 "L 500 200 600 100 3 0 0 0 -1 -1\n"
320 "L 600 100 500 0 3 0 0 0 -1 -1\n"
321 "L 500 0 0 0 3 0 0 0 -1 -1\n"
322 "T 0 300 5 10 0 0 0 0 1\n"
323 "device=INPUT\n" ) },
325 { wxT(
"output-1.sym" ),
326 wxT(
"v 20031231 1\n"
327 "P 0 100 200 100 1 0 0\n"
329 "T 250 50 5 6 0 1 0 0 1\n"
331 "T 250 50 5 6 0 0 0 0 1\n"
334 "L 200 200 200 0 3 0 0 0 -1 -1\n"
335 "L 200 200 700 200 3 0 0 0 -1 -1\n"
336 "L 700 200 800 100 3 0 0 0 -1 -1\n"
337 "L 800 100 700 0 3 0 0 0 -1 -1\n"
338 "L 700 0 200 0 3 0 0 0 -1 -1\n"
339 "T 100 300 5 10 0 0 0 0 1\n"
340 "device=OUTPUT\n" ) },
342 { wxT(
"nc-right-1.sym" ),
343 wxT(
"v 20060123 1\n"
344 "P 0 100 200 100 1 0 0\n"
346 "T 600 100 5 10 0 0 180 8 1\n"
348 "T 600 300 5 10 0 0 180 8 1\n"
351 "L 200 0 200 200 3 0 0 0 -1 -1\n"
352 "T 100 500 8 10 0 0 0 0 1\n"
353 "value=NoConnection\n"
354 "T 250 100 9 10 1 0 0 1 1\n"
356 "T 0 600 8 10 0 0 0 0 1\n"
357 "device=DRC_Directive\n"
358 "T 100 900 8 10 0 0 0 0 1\n"
361 { wxT(
"nc-left-1.sym" ),
362 wxT(
"v 20060123 1\n"
363 "P 400 100 200 100 1 0 1\n"
365 "T 0 100 5 10 0 0 0 0 1\n"
367 "T 0 300 5 10 0 0 0 0 1\n"
370 "L 200 0 200 200 3 0 0 0 -1 -1\n"
371 "T 100 500 8 10 0 0 0 0 1\n"
372 "value=NoConnection\n"
373 "T 50 100 9 10 1 0 0 5 1\n"
375 "T 0 600 8 10 0 0 0 0 1\n"
376 "device=DRC_Directive\n"
377 "T 100 900 8 10 0 0 0 0 1\n"
380 { wxT(
"terminal-1.sym" ),
381 wxT(
"v 20041228 1\n"
382 "T 310 750 8 10 0 0 0 0 1\n"
384 "P 560 100 900 100 1 0 1\n"
386 "T 660 150 5 10 0 0 0 0 1\n"
388 "T 510 100 5 10 0 1 0 0 1\n"
390 "T 510 300 5 10 0 1 0 0 1\n"
392 "T 800 100 5 10 0 1 0 0 1\n"
393 "pinlabel=terminal\n"
395 "V 460 100 100 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n"
396 "T 250 50 8 10 1 1 0 6 1\n"
400 { wxT(
"vcc-1.sym" ),
401 wxT(
"v 20031231 1\n"
402 "P 200 0 200 200 1 0 0\n"
404 "T 250 50 5 6 0 1 0 0 1\n"
406 "T 250 50 5 6 0 0 0 0 1\n"
408 "T 250 50 5 6 0 1 0 0 1\n"
410 "T 250 50 5 6 0 1 0 0 1\n"
413 "L 50 200 350 200 3 0 0 0 -1 -1\n"
414 "T 75 250 9 8 1 0 0 0 1\n"
416 "T 450 200 8 10 0 0 0 0 1\n"
419 { wxT(
"vdd-1.sym" ),
420 wxT(
"v 20031231 1\n"
421 "P 200 0 200 200 1 0 0\n"
423 "T 250 50 5 6 0 1 0 0 1\n"
425 "T 250 50 5 6 0 0 0 0 1\n"
427 "T 250 50 5 6 0 1 0 0 1\n"
429 "T 250 50 5 6 0 1 0 0 1\n"
432 "L 50 200 350 200 3 0 0 0 -1 -1\n"
433 "T 75 250 9 8 1 0 0 0 1\n"
435 "T 450 200 8 10 0 0 0 0 1\n"
438 { wxT(
"5V-plus-1.sym" ),
439 wxT(
"v 20031231 1\n"
440 "P 200 0 200 200 1 0 0\n"
442 "T 250 50 5 6 0 1 0 0 1\n"
444 "T 250 50 5 6 0 0 0 0 1\n"
446 "T 250 50 5 6 0 1 0 0 1\n"
448 "T 250 50 5 6 0 1 0 0 1\n"
451 "L 50 200 350 200 3 0 0 0 -1 -1\n"
452 "T 75 250 9 8 1 0 0 0 1\n"
454 "T 300 0 8 8 0 0 0 0 1\n"
457 { wxT(
"3.3V-plus-1.sym" ),
458 wxT(
"v 20031231 1\n"
459 "P 200 0 200 200 1 0 0\n"
461 "T 250 50 5 6 0 1 0 0 1\n"
463 "T 250 50 5 6 0 0 0 0 1\n"
465 "T 250 50 5 6 0 1 0 0 1\n"
467 "T 250 50 5 6 0 1 0 0 1\n"
470 "L 50 200 350 200 3 0 0 0 -1 -1\n"
471 "T 75 250 9 8 1 0 0 0 1\n"
473 "T 300 0 8 8 0 0 0 0 1\n"
476 { wxT(
"12V-plus-1.sym" ),
477 wxT(
"v 20031231 1\n"
478 "P 200 0 200 200 1 0 0\n"
480 "T 250 50 5 6 0 1 0 0 1\n"
482 "T 250 50 5 6 0 0 0 0 1\n"
484 "T 250 50 5 6 0 1 0 0 1\n"
486 "T 250 50 5 6 0 1 0 0 1\n"
489 "L 50 200 350 200 3 0 0 0 -1 -1\n"
490 "T 75 250 9 8 1 0 0 0 1\n"
492 "T 300 0 9 8 0 0 0 0 1\n"
495 { wxT(
"vcc-2.sym" ),
496 wxT(
"v 20031231 1\n"
497 "V 200 350 50 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n"
498 "P 200 300 200 0 1 0 1\n"
500 "T 300 50 5 10 0 1 0 0 1\n"
502 "T 300 50 5 10 0 0 0 0 1\n"
504 "T 300 50 5 10 0 1 0 0 1\n"
506 "T 300 50 5 10 0 1 0 0 1\n"
509 "T 0 450 9 10 1 0 0 0 1\n"
511 "T 400 300 8 8 0 0 0 0 1\n"
514 { wxT(
"vss-1.sym" ),
515 wxT(
"v 20031231 1\n"
516 "P 200 0 200 200 1 0 0\n"
518 "T 250 50 5 6 0 1 0 0 1\n"
520 "T 250 50 5 6 0 0 0 0 1\n"
522 "T 250 50 5 6 0 1 0 0 1\n"
524 "T 250 50 5 6 0 1 0 0 1\n"
527 "L 50 200 350 200 3 0 0 0 -1 -1\n"
528 "T 75 250 9 8 1 0 0 0 1\n"
530 "T 450 200 8 10 0 0 0 0 1\n"
533 { wxT(
"vee-1.sym" ),
534 wxT(
"v 20031231 1\n"
535 "P 200 0 200 200 1 0 0\n"
537 "T 250 50 5 6 0 1 0 0 1\n"
539 "T 250 50 5 6 0 0 0 0 1\n"
541 "T 250 50 5 6 0 1 0 0 1\n"
543 "T 250 50 5 6 0 1 0 0 1\n"
546 "L 50 200 350 200 3 0 0 0 -1 -1\n"
547 "T 75 250 9 8 1 0 0 0 1\n"
549 "T 450 200 8 10 0 0 0 0 1\n"
552 { wxT(
"gnd-2.sym" ),
553 wxT(
"v 20031231 1\n"
554 "P 100 100 100 300 1 0 1\n"
556 "T 158 161 5 4 0 1 0 0 1\n"
558 "T 158 161 5 4 0 0 0 0 1\n"
560 "T 300 200 3 10 1 1 0 0 1\n"
562 "T 158 161 5 4 0 1 0 0 1\n"
565 "L 0 100 200 100 3 0 0 0 -1 -1\n"
566 "L 55 50 145 50 3 0 0 0 -1 -1\n"
567 "L 80 10 120 10 3 0 0 0 -1 -1\n"
568 "T 300 50 8 10 0 0 0 0 1\n"
572 { wxT(
"diode-1.sym" ),
573 wxT(
"v 20031231 1\n"
574 "L 300 400 300 0 3 0 0 0 -1 -1\n"
575 "L 300 400 600 200 3 0 0 0 -1 -1\n"
576 "T 400 600 5 10 0 0 0 0 1\n"
578 "L 600 200 300 0 3 0 0 0 -1 -1\n"
579 "L 600 400 600 0 3 0 0 0 -1 -1\n"
580 "P 0 200 200 200 1 0 0\n"
582 "T 100 250 5 8 0 1 0 0 1\n"
584 "T 100 250 5 8 0 0 0 0 1\n"
586 "T 100 250 5 8 0 1 0 0 1\n"
588 "T 100 250 5 8 0 1 0 0 1\n"
591 "P 900 200 700 200 1 0 0\n"
593 "T 700 250 5 8 0 1 0 0 1\n"
595 "T 700 250 5 8 0 0 0 0 1\n"
597 "T 700 250 5 8 0 1 0 0 1\n"
599 "T 700 250 5 8 0 1 0 0 1\n"
602 "L 700 200 600 200 3 0 0 0 -1 -1\n"
603 "L 300 200 200 200 3 0 0 0 -1 -1\n"
604 "T 300 500 8 10 1 1 0 0 1\n"
607 { wxT(
"zener-1.sym" ),
608 wxT(
"v 20031231 1\n"
609 "L 300 400 300 0 3 0 0 0 -1 -1\n"
610 "L 600 200 300 0 3 0 0 0 -1 -1\n"
611 "L 600 200 300 400 3 0 0 0 -1 -1\n"
612 "T 400 600 5 10 0 0 0 0 1\n"
613 "device=ZENER_DIODE\n"
614 "L 600 400 600 0 3 0 0 0 -1 -1\n"
615 "P 900 200 700 200 1 0 0\n"
617 "T 700 250 5 8 0 1 0 0 1\n"
619 "T 700 250 5 8 0 0 0 0 1\n"
621 "T 700 250 5 8 0 1 0 0 1\n"
623 "T 700 250 5 8 0 1 0 0 1\n"
626 "P 200 200 0 200 1 0 1\n"
628 "T 100 250 5 8 0 1 0 0 1\n"
630 "T 100 250 5 8 0 0 0 0 1\n"
632 "T 100 250 5 8 0 1 0 0 1\n"
634 "T 100 250 5 8 0 1 0 0 1\n"
637 "L 700 200 600 200 3 0 0 0 -1 -1\n"
638 "L 300 200 200 200 3 0 0 0 -1 -1\n"
639 "L 600 400 500 400 3 0 0 0 -1 -1\n"
640 "L 600 0 700 0 3 0 0 0 -1 -1\n"
641 "T 300 500 8 10 1 1 0 0 1\n"
644 { wxT(
"schottky-1.sym" ),
645 wxT(
"v 20041228 1\n"
646 "L 300 400 300 0 3 0 0 0 -1 -1\n"
647 "L 300 400 600 200 3 0 0 0 -1 -1\n"
648 "T 322 672 8 10 0 0 0 0 1\n"
650 "L 600 200 300 0 3 0 0 0 -1 -1\n"
651 "L 600 400 600 0 3 0 0 0 -1 -1\n"
652 "P 0 200 200 200 1 0 0\n"
654 "T 205 256 5 8 0 1 0 0 1\n"
656 "T 170 286 5 8 0 0 90 0 1\n"
658 "T -10 81 5 10 0 1 0 0 1\n"
660 "T 75 288 5 10 0 1 90 0 1\n"
663 "P 900 200 700 200 1 0 0\n"
665 "T 700 250 5 8 0 1 0 0 1\n"
667 "T 730 50 5 8 0 0 0 0 1\n"
669 "T 798 265 5 10 0 1 0 0 1\n"
671 "T 931 138 5 10 0 1 0 0 1\n"
674 "L 700 200 600 200 3 0 0 0 -1 -1\n"
675 "L 300 200 200 200 3 0 0 0 -1 -1\n"
676 "A 650 400 50 0 180 3 0 0 0 -1 -1\n"
677 "A 550 0 50 180 180 3 0 0 0 -1 -1\n"
678 "T 300 500 8 10 1 1 0 0 1\n"
680 "T 567 515 8 10 0 0 0 0 1\n"
683 { wxT(
"led-1.sym" ),
684 wxT(
"v 20210407 2\n"
685 "P 0 200 200 200 1 0 0\n"
687 "T 150 250 5 8 1 1 0 6 1\n"
689 "T 150 150 5 8 0 1 0 8 1\n"
691 "T 250 200 9 8 0 1 0 0 1\n"
693 "T 250 200 5 8 0 1 0 2 1\n"
696 "P 900 200 700 200 1 0 0\n"
698 "T 750 250 5 8 1 1 0 0 1\n"
700 "T 750 150 5 8 0 1 0 2 1\n"
702 "T 650 200 9 8 0 1 0 6 1\n"
704 "T 650 200 5 8 0 1 0 8 1\n"
707 "L 400 300 500 200 3 0 0 0 -1 -1\n"
708 "L 500 200 400 100 3 0 0 0 -1 -1\n"
709 "L 400 300 400 100 3 0 0 0 -1 -1\n"
710 "L 500 300 500 100 3 0 0 0 -1 -1\n"
711 "L 500 200 700 200 3 0 0 0 -1 -1\n"
712 "L 400 200 200 200 3 0 0 0 -1 -1\n"
713 "V 450 200 200 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n"
714 "T 800 600 5 10 0 0 0 0 1\n"
716 "T 800 400 8 10 1 1 0 0 1\n"
718 "T 800 1000 5 10 0 0 0 0 1\n"
720 "T 800 800 5 10 0 0 0 0 1\n"
721 "symversion=0.2\n" ) },
724 { wxT(
"npn-1.sym" ),
725 wxT(
"v 20210407 2\n"
726 "L 200 800 200 200 3 0 0 0 -1 -1\n"
727 "T 600 500 5 10 0 0 0 0 1\n"
728 "device=NPN_TRANSISTOR\n"
729 "L 500 800 200 500 3 0 0 0 -1 -1\n"
730 "L 200 500 500 200 3 0 0 0 -1 -1\n"
731 "H 3 0 0 0 -1 -1 1 -1 -1 -1 -1 -1 5\n"
737 "P 0 500 200 500 1 0 0\n"
739 "T 100 550 5 6 1 1 0 0 1\n"
741 "T 100 550 5 6 0 0 0 0 1\n"
743 "T 100 550 5 6 0 1 0 0 1\n"
745 "T 100 550 5 6 0 1 0 0 1\n"
748 "P 500 1000 500 800 1 0 0\n"
750 "T 400 850 5 6 1 1 0 0 1\n"
752 "T 400 850 5 6 0 0 0 0 1\n"
754 "T 400 850 5 6 0 1 0 0 1\n"
756 "T 400 850 5 6 0 1 0 0 1\n"
759 "P 500 200 500 0 1 0 1\n"
761 "T 400 50 5 6 1 1 0 0 1\n"
763 "T 400 50 5 6 0 0 0 0 1\n"
765 "T 400 50 5 6 0 1 0 0 1\n"
767 "T 400 50 5 6 0 1 0 0 1\n"
770 "T 600 500 8 10 1 1 0 0 1\n"
773 { wxT(
"pnp-1.sym" ),
774 wxT(
"v 20210407 2\n"
775 "L 200 800 200 200 3 0 0 0 -1 -1\n"
776 "T 600 500 5 10 0 0 0 0 1\n"
777 "device=PNP_TRANSISTOR\n"
778 "L 500 800 200 500 3 0 0 0 -1 -1\n"
779 "L 200 500 500 200 3 0 0 0 -1 -1\n"
780 "P 0 500 200 500 1 0 0\n"
782 "T 100 550 5 6 1 1 0 0 1\n"
784 "T 100 550 5 6 0 0 0 0 1\n"
786 "T 100 550 5 6 0 1 0 0 1\n"
788 "T 100 550 5 6 0 1 0 0 1\n"
791 "P 500 1000 500 800 1 0 0\n"
793 "T 400 850 5 6 1 1 0 0 1\n"
795 "T 400 850 5 6 0 0 0 0 1\n"
797 "T 400 850 5 6 0 1 0 0 1\n"
799 "T 400 850 5 6 0 1 0 0 1\n"
802 "P 500 200 500 0 1 0 1\n"
804 "T 400 50 5 6 1 1 0 0 1\n"
806 "T 400 50 5 6 0 0 0 0 1\n"
808 "T 400 50 5 6 0 1 0 0 1\n"
810 "T 400 50 5 6 0 1 0 0 1\n"
813 "T 600 500 8 10 1 1 0 0 1\n"
815 "H 3 0 0 0 -1 -1 1 -1 -1 -1 -1 -1 5\n"
822 { wxT(
"nmos-1.sym" ),
823 wxT(
"v 20210407 2\n"
824 "L 300 600 300 200 3 0 0 0 -1 -1\n"
825 "T 700 800 5 10 0 0 0 0 1\n"
826 "device=NMOS_TRANSISTOR\n"
827 "L 200 600 200 200 3 0 0 0 -1 -1\n"
828 "L 300 600 500 600 3 0 0 0 -1 -1\n"
829 "L 300 200 500 200 3 0 0 0 -1 -1\n"
830 "L 300 400 500 400 3 0 0 0 -1 -1\n"
831 "L 300 400 400 500 3 0 0 0 -1 -1\n"
832 "L 300 400 400 300 3 0 0 0 -1 -1\n"
833 "P 0 400 200 400 1 0 0\n"
835 "T 150 450 5 8 0 1 0 6 1\n"
837 "T 150 350 5 8 0 1 0 8 1\n"
839 "T 200 400 9 8 0 1 0 0 1\n"
841 "T 200 400 5 8 0 1 0 2 1\n"
844 "P 500 600 500 800 1 0 1\n"
846 "T 550 650 5 8 0 1 0 0 1\n"
848 "T 550 650 5 8 0 1 0 2 1\n"
850 "T 500 600 9 8 0 1 0 5 1\n"
852 "T 500 400 5 8 0 1 0 5 1\n"
855 "P 500 200 500 0 1 0 1\n"
857 "T 550 50 5 8 0 1 0 0 1\n"
859 "T 550 50 5 8 0 1 0 2 1\n"
861 "T 500 200 9 8 0 1 0 3 1\n"
863 "T 500 500 5 8 0 1 0 3 1\n"
866 "T 700 600 8 10 1 1 0 0 1\n"
868 "T 700 1000 5 10 0 0 0 0 1\n"
869 "symversion=0.2\n" ) },
871 { wxT(
"pmos-1.sym" ),
872 wxT(
"v 20210407 2\n"
873 "L 300 600 300 200 3 0 0 0 -1 -1\n"
874 "T 600 200 5 10 0 0 0 0 1\n"
875 "device=PMOS_TRANSISTOR\n"
876 "L 200 600 200 200 3 0 0 0 -1 -1\n"
877 "L 300 600 500 600 3 0 0 0 -1 -1\n"
878 "L 300 200 500 200 3 0 0 0 -1 -1\n"
879 "L 300 400 500 400 3 0 0 0 -1 -1\n"
880 "L 500 400 400 300 3 0 0 0 -1 -1\n"
881 "L 500 400 400 500 3 0 0 0 -1 -1\n"
882 "P 500 600 500 800 1 0 1\n"
884 "T 300 700 5 10 0 1 0 0 1\n"
886 "T 300 700 5 10 0 0 0 0 1\n"
888 "T 300 700 5 10 0 1 0 0 1\n"
890 "T 300 700 5 10 0 1 0 0 1\n"
893 "P 500 200 500 0 1 0 1\n"
895 "T 300 0 5 10 0 1 0 0 1\n"
897 "T 300 0 5 10 0 0 0 0 1\n"
899 "T 300 0 5 10 0 1 0 0 1\n"
901 "T 300 0 5 10 0 1 0 0 1\n"
904 "P 200 400 0 400 1 0 1\n"
906 "T 0 500 5 10 0 1 0 0 1\n"
908 "T 0 500 5 10 0 0 0 0 1\n"
910 "T 0 500 5 10 0 1 0 0 1\n"
912 "T 0 500 5 10 0 1 0 0 1\n"
915 "T 700 600 8 10 1 1 0 0 1\n"
917 "T 1200 500 8 10 0 0 0 0 1\n"
918 "symversion=0.1\n" ) },
921 { wxT(
"opamp-1.sym" ),
922 wxT(
"v 20050820 1\n"
923 "L 200 800 200 0 3 0 0 0 -1 -1\n"
924 "L 200 800 800 400 3 0 0 0 -1 -1\n"
925 "T 700 800 5 10 0 0 0 0 1\n"
927 "L 800 400 200 0 3 0 0 0 -1 -1\n"
928 "L 300 650 300 550 3 0 0 0 -1 -1\n"
929 "L 250 600 350 600 3 0 0 0 -1 -1\n"
930 "L 250 200 350 200 3 0 0 0 -1 -1\n"
931 "P 0 600 200 600 1 0 0\n"
933 "T 150 650 5 8 1 1 0 6 1\n"
935 "T 150 550 5 8 0 1 0 8 1\n"
937 "T 250 600 9 8 0 1 0 0 1\n"
939 "T 250 600 5 8 0 1 0 2 1\n"
942 "P 0 200 200 200 1 0 0\n"
944 "T 150 250 5 8 1 1 0 6 1\n"
946 "T 150 150 5 8 0 1 0 8 1\n"
948 "T 250 200 9 8 0 1 0 0 1\n"
950 "T 250 200 5 8 0 1 0 2 1\n"
953 "P 800 400 1000 400 1 0 1\n"
955 "T 800 450 5 8 1 1 0 0 1\n"
957 "T 800 350 5 8 0 1 0 2 1\n"
959 "T 750 400 9 8 0 1 0 6 1\n"
961 "T 750 400 5 8 0 1 0 8 1\n"
964 "P 500 600 500 800 1 0 1\n"
966 "T 550 600 5 8 1 1 0 0 1\n"
968 "T 550 600 5 8 0 1 0 2 1\n"
970 "T 500 600 9 8 0 1 0 5 1\n"
972 "T 500 550 5 8 0 1 0 5 1\n"
975 "P 500 200 500 0 1 0 1\n"
977 "T 550 100 5 8 1 1 0 0 1\n"
979 "T 550 100 5 8 0 1 0 2 1\n"
981 "T 500 200 9 8 0 1 0 3 1\n"
983 "T 500 300 5 8 0 1 0 3 1\n"
986 "T 700 600 8 10 1 1 0 0 1\n"
988 "T 700 1000 5 10 0 0 0 0 1\n"
990 "T 700 1400 5 10 0 0 0 0 1\n"
991 "symversion=0.1\n" ) },
993 { wxT(
"inductor-1.sym" ),
994 wxT(
"v 20210407 2\n"
995 "P 900 100 750 100 1 0 0\n"
997 "T 800 150 5 8 0 1 0 0 1\n"
999 "T 800 50 5 8 0 1 0 2 1\n"
1001 "T 700 100 9 8 0 1 0 6 1\n"
1003 "T 700 100 5 8 0 1 0 8 1\n"
1006 "P 0 100 150 100 1 0 0\n"
1008 "T 100 150 5 8 0 1 0 6 1\n"
1010 "T 100 50 5 8 0 1 0 8 1\n"
1012 "T 200 100 9 8 0 1 0 0 1\n"
1014 "T 200 100 5 8 0 1 0 2 1\n"
1017 "A 237 100 75 0 180 3 0 0 0 -1 -1\n"
1018 "A 379 100 75 0 180 3 0 0 0 -1 -1\n"
1019 "A 521 100 75 0 180 3 0 0 0 -1 -1\n"
1020 "A 663 100 75 0 180 3 0 0 0 -1 -1\n"
1021 "T 200 500 5 10 0 0 0 0 1\n"
1023 "T 200 300 8 10 1 1 0 0 1\n"
1025 "T 200 700 5 10 0 0 0 0 1\n"
1026 "symversion=0.2\n" ) },
1029 { wxT(
"7400-1.sym" ),
1030 wxT(
"v 20031231 1\n"
1031 "L 300 200 300 800 3 0 0 0 -1 -1\n"
1032 "T 300 0 9 8 1 0 0 0 1\n"
1034 "L 300 800 700 800 3 0 0 0 -1 -1\n"
1035 "T 500 900 5 10 0 0 0 0 1\n"
1037 "T 500 1100 5 10 0 0 0 0 1\n"
1039 "T 500 1300 5 10 0 0 0 0 1\n"
1041 "T 500 1500 5 10 0 0 0 0 1\n"
1043 "T 500 1700 5 10 0 0 0 0 1\n"
1045 "T 500 1900 5 10 0 0 0 0 1\n"
1046 "slotdef=3:9,10,8\n"
1047 "T 500 2100 5 10 0 0 0 0 1\n"
1048 "slotdef=4:12,13,11\n"
1049 "L 300 200 700 200 3 0 0 0 -1 -1\n"
1050 "A 700 500 300 270 180 3 0 0 0 -1 -1\n"
1051 "V 1050 500 50 6 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n"
1052 "P 1100 500 1300 500 1 0 1\n"
1054 "T 1100 550 5 8 1 1 0 0 1\n"
1056 "T 1100 450 5 8 0 1 0 2 1\n"
1058 "T 950 500 9 8 0 1 0 6 1\n"
1060 "T 950 500 5 8 0 1 0 8 1\n"
1063 "P 300 300 0 300 1 0 1\n"
1065 "T 200 350 5 8 1 1 0 6 1\n"
1067 "T 200 250 5 8 0 1 0 8 1\n"
1069 "T 350 300 9 8 0 1 0 0 1\n"
1071 "T 350 300 5 8 0 1 0 2 1\n"
1074 "P 300 700 0 700 1 0 1\n"
1076 "T 200 750 5 8 1 1 0 6 1\n"
1078 "T 200 650 5 8 0 1 0 8 1\n"
1080 "T 350 700 9 8 0 1 0 0 1\n"
1082 "T 350 700 5 8 0 1 0 2 1\n"
1085 "T 300 900 8 10 1 1 0 0 1\n"
1087 "T 500 2850 5 10 0 0 0 0 1\n"
1089 "T 500 3050 5 10 0 0 0 0 1\n"
1092 { wxT(
"7404-1.sym" ),
1093 wxT(
"v 20031231 1\n"
1094 "L 300 800 800 500 3 0 0 0 -1 -1\n"
1095 "T 600 900 5 10 0 0 0 0 1\n"
1097 "T 600 1100 5 10 0 0 0 0 1\n"
1099 "T 600 1300 5 10 0 0 0 0 1\n"
1101 "T 600 1500 5 10 0 0 0 0 1\n"
1103 "T 600 1700 5 10 0 0 0 0 1\n"
1105 "T 600 1900 5 10 0 0 0 0 1\n"
1107 "T 600 2100 5 10 0 0 0 0 1\n"
1109 "T 600 2300 5 10 0 0 0 0 1\n"
1111 "T 600 2500 5 10 0 0 0 0 1\n"
1113 "L 800 500 300 200 3 0 0 0 -1 -1\n"
1114 "L 300 800 300 200 3 0 0 0 -1 -1\n"
1115 "V 850 500 50 6 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n"
1116 "P 300 500 0 500 1 0 1\n"
1118 "T 200 550 5 8 1 1 0 6 1\n"
1120 "T 200 450 5 8 0 1 0 8 1\n"
1122 "T 350 500 9 8 0 1 0 0 1\n"
1124 "T 350 500 5 8 0 1 0 2 1\n"
1127 "P 1100 500 900 500 1 0 0\n"
1129 "T 900 550 5 8 1 1 0 0 1\n"
1131 "T 900 450 5 8 0 1 0 2 1\n"
1133 "T 750 500 9 8 0 1 0 6 1\n"
1135 "T 750 500 5 8 0 1 0 8 1\n"
1138 "T 300 0 9 8 1 0 0 0 1\n"
1140 "T 300 900 8 10 1 1 0 0 1\n"
1142 "T 600 3100 5 10 0 0 0 0 1\n"
1144 "T 600 3300 5 10 0 0 0 0 1\n"
1147 { wxT(
"7408-1.sym" ),
1148 wxT(
"v 20031231 1\n"
1149 "L 300 200 300 800 3 0 0 0 -1 -1\n"
1150 "T 300 0 9 8 1 0 0 0 1\n"
1152 "L 300 800 700 800 3 0 0 0 -1 -1\n"
1153 "T 700 900 5 10 0 0 0 0 1\n"
1155 "T 700 1100 5 10 0 0 0 0 1\n"
1157 "T 700 1300 5 10 0 0 0 0 1\n"
1159 "T 700 1500 5 10 0 0 0 0 1\n"
1161 "T 700 1700 5 10 0 0 0 0 1\n"
1163 "T 700 1900 5 10 0 0 0 0 1\n"
1164 "slotdef=3:9,10,8\n"
1165 "T 700 2100 5 10 0 0 0 0 1\n"
1166 "slotdef=4:12,13,11\n"
1167 "L 300 200 700 200 3 0 0 0 -1 -1\n"
1168 "A 700 500 300 270 180 3 0 0 0 -1 -1\n"
1169 "P 1000 500 1300 500 1 0 1\n"
1171 "T 1100 550 5 8 1 1 0 0 1\n"
1173 "T 1100 450 5 8 0 1 0 2 1\n"
1175 "T 950 500 9 8 0 1 0 6 1\n"
1177 "T 950 500 5 8 0 1 0 8 1\n"
1180 "P 300 700 0 700 1 0 1\n"
1182 "T 200 750 5 8 1 1 0 6 1\n"
1184 "T 200 650 5 8 0 1 0 8 1\n"
1186 "T 350 700 9 8 0 1 0 0 1\n"
1188 "T 350 700 5 8 0 1 0 2 1\n"
1191 "P 300 300 0 300 1 0 1\n"
1193 "T 200 350 5 8 1 1 0 6 1\n"
1195 "T 200 250 5 8 0 1 0 8 1\n"
1197 "T 350 300 9 8 0 1 0 0 1\n"
1199 "T 350 300 5 8 0 1 0 2 1\n"
1202 "T 300 900 8 10 1 1 0 0 1\n"
1204 "T 700 2700 5 10 0 0 0 0 1\n"
1206 "T 700 2900 5 10 0 0 0 0 1\n"
1209 { wxT(
"7432-1.sym" ),
1210 wxT(
"v 20031231 1\n"
1211 "L 260 200 600 200 3 0 0 0 -1 -1\n"
1212 "L 260 800 600 800 3 0 0 0 -1 -1\n"
1213 "T 600 900 5 10 0 0 0 0 1\n"
1215 "T 600 1100 5 10 0 0 0 0 1\n"
1217 "T 600 1300 5 10 0 0 0 0 1\n"
1219 "T 600 1500 5 10 0 0 0 0 1\n"
1221 "T 600 1700 5 10 0 0 0 0 1\n"
1223 "T 600 1900 5 10 0 0 0 0 1\n"
1224 "slotdef=3:9,10,8\n"
1225 "T 600 2100 5 10 0 0 0 0 1\n"
1226 "slotdef=4:12,13,11\n"
1227 "T 300 0 9 8 1 0 0 0 1\n"
1229 "A 0 500 400 312 97 3 0 0 0 -1 -1\n"
1230 "P 300 700 0 700 1 0 1\n"
1232 "T 200 750 5 8 1 1 0 6 1\n"
1234 "T 200 650 5 8 0 1 0 8 1\n"
1236 "T 350 700 9 8 0 1 0 0 1\n"
1238 "T 350 700 5 8 0 1 0 2 1\n"
1241 "P 300 300 0 300 1 0 1\n"
1243 "T 200 350 5 8 1 1 0 6 1\n"
1245 "T 200 250 5 8 0 1 0 8 1\n"
1247 "T 350 300 9 8 0 1 0 0 1\n"
1249 "T 350 300 5 8 0 1 0 2 1\n"
1252 "P 1300 500 988 500 1 0 0\n"
1254 "T 1100 550 5 8 1 1 0 0 1\n"
1256 "T 1100 450 5 8 0 1 0 2 1\n"
1258 "T 950 500 9 8 0 1 0 6 1\n"
1260 "T 950 500 5 8 0 1 0 8 1\n"
1263 "A 600 600 400 270 76 3 0 0 0 -1 -1\n"
1264 "A 600 400 400 14 76 3 0 0 0 -1 -1\n"
1265 "T 300 900 8 10 1 1 0 0 1\n"
1267 "T 600 2700 5 10 0 0 0 0 1\n"
1269 "T 600 2900 5 10 0 0 0 0 1\n"
1272 { wxT(
"7486-1.sym" ),
1273 wxT(
"v 20031231 1\n"
1274 "L 260 200 600 200 3 0 0 0 -1 -1\n"
1275 "L 260 800 600 800 3 0 0 0 -1 -1\n"
1276 "T 700 900 5 10 0 0 0 0 1\n"
1278 "T 700 1100 5 10 0 0 0 0 1\n"
1280 "T 700 1300 5 10 0 0 0 0 1\n"
1282 "T 700 1500 5 10 0 0 0 0 1\n"
1284 "T 700 1700 5 10 0 0 0 0 1\n"
1286 "T 700 1900 5 10 0 0 0 0 1\n"
1287 "slotdef=3:9,10,8\n"
1288 "T 700 2100 5 10 0 0 0 0 1\n"
1289 "slotdef=4:12,13,11\n"
1290 "A 0 500 400 312 97 3 0 0 0 -1 -1\n"
1291 "A -100 500 400 312 97 3 0 0 0 -1 -1\n"
1292 "P 300 700 0 700 1 0 1\n"
1294 "T 150 750 5 8 1 1 0 6 1\n"
1296 "T 150 650 5 8 0 1 0 8 1\n"
1298 "T 350 700 9 8 0 1 0 0 1\n"
1300 "T 350 700 5 8 0 1 0 2 1\n"
1303 "P 300 300 0 300 1 0 1\n"
1305 "T 150 350 5 8 1 1 0 6 1\n"
1307 "T 150 250 5 8 0 1 0 8 1\n"
1309 "T 350 300 9 8 0 1 0 0 1\n"
1311 "T 350 300 5 8 0 1 0 2 1\n"
1314 "P 988 500 1300 500 1 0 1\n"
1316 "T 1100 550 5 8 1 1 0 0 1\n"
1318 "T 1100 450 5 8 0 1 0 2 1\n"
1320 "T 950 500 9 8 0 1 0 6 1\n"
1322 "T 950 500 5 8 0 1 0 8 1\n"
1325 "A 600 600 400 270 76 3 0 0 0 -1 -1\n"
1326 "A 600 400 400 14 76 3 0 0 0 -1 -1\n"
1327 "T 300 900 8 10 1 1 0 0 1\n"
1329 "T 300 0 9 8 1 0 0 0 1\n"
1331 "T 700 2700 5 10 0 0 0 0 1\n"
1333 "T 700 2900 5 10 0 0 0 0 1\n"
1336 { wxT(
"7402-1.sym" ),
1337 wxT(
"v 20031231 1\n"
1338 "L 260 200 600 200 3 0 0 0 -1 -1\n"
1339 "L 260 800 600 800 3 0 0 0 -1 -1\n"
1340 "T 600 900 5 10 0 0 0 0 1\n"
1342 "T 600 1100 5 10 0 0 0 0 1\n"
1344 "T 600 1300 5 10 0 0 0 0 1\n"
1346 "T 600 1500 5 10 0 0 0 0 1\n"
1348 "T 600 1700 5 10 0 0 0 0 1\n"
1350 "T 600 1900 5 10 0 0 0 0 1\n"
1351 "slotdef=3:10,8,9\n"
1352 "T 600 2100 5 10 0 0 0 0 1\n"
1353 "slotdef=4:13,11,12\n"
1354 "T 300 0 9 8 1 0 0 0 1\n"
1356 "A 0 500 400 312 97 3 0 0 0 -1 -1\n"
1357 "P 300 700 0 700 1 0 1\n"
1359 "T 200 750 5 8 1 1 0 6 1\n"
1361 "T 200 650 5 8 0 1 0 8 1\n"
1363 "T 350 700 9 8 0 1 0 0 1\n"
1365 "T 350 700 5 8 0 1 0 2 1\n"
1368 "P 300 300 0 300 1 0 1\n"
1370 "T 200 350 5 8 1 1 0 6 1\n"
1372 "T 200 250 5 8 0 1 0 8 1\n"
1374 "T 350 300 9 8 0 1 0 0 1\n"
1376 "T 350 300 5 8 0 1 0 2 1\n"
1379 "V 1038 500 50 6 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n"
1380 "P 1300 500 1088 500 1 0 0\n"
1382 "T 1100 550 5 8 1 1 0 0 1\n"
1384 "T 1100 450 5 8 0 1 0 2 1\n"
1386 "T 950 500 9 8 0 1 0 6 1\n"
1388 "T 950 500 5 8 0 1 0 8 1\n"
1391 "A 600 600 400 270 76 3 0 0 0 -1 -1\n"
1392 "A 600 400 400 14 76 3 0 0 0 -1 -1\n"
1393 "T 300 900 8 10 1 1 0 0 1\n"
1395 "T 600 2700 5 10 0 0 0 0 1\n"
1397 "T 600 2900 5 10 0 0 0 0 1\n"
1401 { wxT(
"busripper-1.sym" ),
1402 wxT(
"v 20031231 1\n"
1403 "T 0 400 5 8 0 0 0 0 1\n"
1405 "P 0 0 100 100 1 0 0\n"
1407 "T 0 500 5 8 0 0 0 0 1\n"
1409 "T 0 600 5 8 0 0 0 0 1\n"
1411 "T 0 700 5 8 0 0 0 0 1\n"
1413 "T 0 800 5 8 0 0 0 0 1\n"
1414 "pinlabel=netside\n"
1416 "T 0 300 5 8 0 0 0 0 1\n"
1418 "L 200 200 100 100 10 30 0 0 -1 -1\n" ) },
1420 { wxT(
"busripper-2.sym" ),
1421 wxT(
"v 20031231 1\n"
1422 "T 0 400 5 8 0 0 0 0 1\n"
1424 "P 0 0 0 100 1 0 0\n"
1426 "T 0 500 5 8 0 0 0 0 1\n"
1428 "T 0 600 5 8 0 0 0 0 1\n"
1430 "T 0 700 5 8 0 0 0 0 1\n"
1432 "T 0 800 5 8 0 0 0 0 1\n"
1433 "pinlabel=netside\n"
1435 "T 0 300 5 8 0 0 0 0 1\n"
1437 "L 0 100 100 200 3 0 0 0 -1 -1\n"
1438 "L 0 100 -100 200 3 0 0 0 -1 -1\n" ) },
1440 { wxT(
"title-B.sym" ),
1441 wxT(
"v 20031231 1\n"
1442 "B 0 0 17000 11000 15 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n"
1443 "T 14400 1500 5 10 0 0 0 0 1\n"
1445 "L 12900 600 12900 0 15 0 0 0 -1 -1\n"
1446 "T 9500 400 15 8 1 0 0 0 1\n"
1448 "T 13000 400 15 8 1 0 0 0 1\n"
1450 "T 13000 100 15 8 1 0 0 0 1\n"
1452 "T 9500 100 15 8 1 0 0 0 1\n"
1454 "T 11200 100 15 8 1 0 0 0 1\n"
1456 "T 9500 700 15 8 1 0 0 0 1\n"
1458 "B 9400 0 7600 1400 15 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n"
1459 "L 9400 600 17000 600 15 0 0 0 -1 -1\n" ) },
1471 SCH_IO( wxS(
"gEDA/gschem Schematic" ) ),
1495 wxFileName fn( aFileName );
1497 if( fn.GetExt().CmpNoCase( wxT(
"sch" ) ) != 0 )
1502 if( !file.Open( aFileName ) )
1505 if( file.GetLineCount() == 0 )
1508 wxString firstLine = file.GetFirstLine().Trim(
false );
1510 if( !firstLine.StartsWith( wxT(
"v " ) ) )
1513 wxStringTokenizer tok( firstLine );
1516 if( !tok.HasMoreTokens() )
1519 wxString dateStr = tok.GetNextToken();
1521 if( dateStr.length() != 8 )
1525 return dateStr.ToLong( &dateVal ) && dateVal >= 19700101;
1535 return static_cast<int>(
static_cast<int64_t
>( aMils ) *
MILS_TO_IU );
1551 wxStringTokenizer tokenizer( aLine );
1553 if( tokenizer.CountTokens() < 2 )
1556 wxString v = tokenizer.GetNextToken();
1558 if( v != wxT(
"v" ) )
1561 wxString dateStr = tokenizer.GetNextToken();
1568 if( tokenizer.HasMoreTokens() )
1584 std::vector<GEDA_ATTR> attrs;
1586 while( aLineIdx < aFile.GetLineCount() )
1588 wxString line = aFile.GetLine( aLineIdx );
1590 if( line.Trim() == wxT(
"}" ) )
1596 if( line.StartsWith( wxT(
"T " ) ) )
1599 wxStringTokenizer tok( line );
1602 long x = 0, y = 0, color = 0, size = 0, vis = 0, showNV = 0, angle = 0, align = 0;
1605 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
1606 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
1607 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
1608 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &size );
1609 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &vis );
1610 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &showNV );
1611 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &angle );
1612 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &align );
1613 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &numLines );
1617 wxString textContent;
1619 for(
long i = 0; i < numLines && aLineIdx < aFile.GetLineCount(); i++ )
1622 textContent += wxT(
"\n" );
1624 textContent += aFile.GetLine( aLineIdx );
1628 int eqPos = textContent.Find(
'=' );
1630 if( eqPos != wxNOT_FOUND )
1633 attr.
name = textContent.Left( eqPos );
1634 attr.
value = textContent.Mid( eqPos + 1 );
1637 if( attr.
value.length() >= 2
1638 && attr.
value.StartsWith( wxT(
"\"" ) )
1639 && attr.
value.EndsWith( wxT(
"\"" ) ) )
1644 attr.
x =
static_cast<int>( x );
1645 attr.
y =
static_cast<int>( y );
1646 attr.
size =
static_cast<int>( size );
1647 attr.
angle =
static_cast<int>( angle );
1648 attr.
align =
static_cast<int>( align );
1650 attr.
showNV =
static_cast<int>( showNV );
1651 attrs.push_back( attr );
1665 const wxString& aName )
const
1669 if( attr.name == aName )
1673 return wxEmptyString;
1678 const wxString& aName )
const
1682 if( attr.name == aName )
1693 if( aLineIdx < aFile.GetLineCount() && aFile.GetLine( aLineIdx ).Trim() == wxT(
"{" ) )
1709 switch( aDashStyle )
1761 libName =
m_schematic->Project().GetProjectName();
1763 if( libName.IsEmpty() )
1766 if( libName.IsEmpty() )
1767 libName = wxT(
"noname" );
1769 libName += wxT(
"-geda-import" );
1785 wxStringTokenizer tok( aLine );
1788 long x = 0, y = 0, selectable = 0, angle = 0, mirror = 0;
1790 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
1791 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
1792 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &selectable );
1793 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &angle );
1794 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &mirror );
1798 if( tok.HasMoreTokens() )
1799 basename = tok.GetNextToken();
1802 if( basename.StartsWith( wxT(
"EMBEDDED" ) ) )
1803 basename = basename.Mid( 8 );
1820 wxStringTokenizer tok( aLine );
1823 long x1 = 0, y1 = 0, x2 = 0, y2 = 0;
1825 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x1 );
1826 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y1 );
1827 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x2 );
1828 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y2 );
1830 VECTOR2I start =
toKiCad(
static_cast<int>( x1 ),
static_cast<int>( y1 ) );
1833 auto wire = std::make_unique<SCH_LINE>( start,
LAYER_WIRE );
1834 wire->SetEndPoint(
end );
1835 m_screen->Append( wire.release() );
1837 trackEndpoint(
static_cast<int>( x1 ),
static_cast<int>( y1 ) );
1838 trackEndpoint(
static_cast<int>( x2 ),
static_cast<int>( y2 ) );
1841 wxString netname =
findAttr( attrs, wxT(
"netname" ) );
1843 if( !netname.IsEmpty() )
1845 auto label = std::make_unique<SCH_LABEL>( start, netname );
1847 label->SetTextSize(
VECTOR2I( textSize, textSize ) );
1848 m_screen->Append( label.release() );
1856 wxStringTokenizer tok( aLine );
1859 long x1 = 0, y1 = 0, x2 = 0, y2 = 0, color = 0, ripperDir = 0;
1861 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x1 );
1862 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y1 );
1863 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x2 );
1864 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y2 );
1865 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
1869 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &ripperDir );
1872 VECTOR2I start =
toKiCad(
static_cast<int>( x1 ),
static_cast<int>( y1 ) );
1875 auto line = std::make_unique<SCH_LINE>( start,
LAYER_BUS );
1876 line->SetEndPoint(
end );
1877 m_screen->Append( line.release() );
1888 wxStringTokenizer tok( aLine );
1891 long x1 = 0, y1 = 0, x2 = 0, y2 = 0, color = 0, pintype = 0, whichend = 0;
1893 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x1 );
1894 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y1 );
1895 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x2 );
1896 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y2 );
1897 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
1901 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pintype );
1902 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &whichend );
1905 VECTOR2I start =
toKiCad(
static_cast<int>( x1 ),
static_cast<int>( y1 ) );
1909 auto wire = std::make_unique<SCH_LINE>( start,
LAYER_WIRE );
1910 wire->SetEndPoint(
end );
1911 m_screen->Append( wire.release() );
1913 VECTOR2I connPt = ( whichend == 0 ) ? start :
end;
1914 int connX = ( whichend == 0 ) ?
static_cast<int>( x1 ) :
static_cast<int>( x2 );
1915 int connY = ( whichend == 0 ) ?
static_cast<int>( y1 ) :
static_cast<int>( y2 );
1920 wxString pinlabel =
findAttr( attrs, wxT(
"pinlabel" ) );
1922 if( !pinlabel.IsEmpty() )
1924 auto label = std::make_unique<SCH_LABEL>( connPt, pinlabel );
1926 label->SetTextSize(
VECTOR2I( textSize, textSize ) );
1927 m_screen->Append( label.release() );
1937 auto libSym = std::make_unique<LIB_SYMBOL>(
m_pendingComp->basename );
1940 while( aLineIdx < aFile.GetLineCount() )
1942 wxString line = aFile.GetLine( aLineIdx );
1944 if( line.Trim() == wxT(
"]" ) )
1950 if( line.IsEmpty() )
1956 wxChar type = line[0];
1963 wxStringTokenizer tok( line );
1965 long px1 = 0, py1 = 0, px2 = 0, py2 = 0, pc = 0, pt = 0, pw = 0;
1967 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &px1 );
1968 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &py1 );
1969 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &px2 );
1970 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &py2 );
1971 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pc );
1972 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pt );
1973 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pw );
1976 addSymbolPin( *libSym,
static_cast<int>( px1 ),
static_cast<int>( py1 ),
1977 static_cast<int>( px2 ),
static_cast<int>( py2 ),
1978 static_cast<int>( pw ), pinAttrs );
1993 wxStringTokenizer tok( line );
1998 for(
int i = 0; i < 8 && tok.HasMoreTokens(); i++ )
2001 tok.GetNextToken().ToLong( &numLines );
2006 for(
long i = 0; i < numLines && aLineIdx < aFile.GetLineCount(); i++ )
2016 while( aLineIdx < aFile.GetLineCount() )
2018 if( aFile.GetLine( aLineIdx ).Trim() == wxT(
"}" ) )
2049 wxStringTokenizer tok( aLine );
2052 long x = 0, y = 0, color = 0, size = 0, vis = 0, showNV = 0, angle = 0, align = 0;
2055 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
2056 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
2057 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2058 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &size );
2059 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &vis );
2060 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &showNV );
2061 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &angle );
2065 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &align );
2066 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &numLines );
2070 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &align );
2080 wxString textContent;
2082 for(
long i = 0; i < numLines && aLineIdx < aFile.GetLineCount(); i++ )
2085 textContent += wxT(
"\n" );
2087 textContent += aFile.GetLine( aLineIdx );
2100 int eqPos = textContent.Find(
'=' );
2102 if( eqPos != wxNOT_FOUND )
2104 wxString
name = textContent.Left( eqPos );
2105 wxString value = textContent.Mid( eqPos + 1 );
2107 switch(
static_cast<int>( showNV ) )
2109 case 1: textContent = value;
break;
2110 case 2: textContent =
name;
break;
2111 default: textContent =
name + wxT(
"=" ) + value;
break;
2115 VECTOR2I pos =
toKiCad(
static_cast<int>( x ),
static_cast<int>( y ) );
2117 auto text = std::make_unique<SCH_TEXT>( pos, textContent );
2119 int textSize =
toKiCadDist(
static_cast<int>( size ) * 10 );
2128 int normAngle = ( (
static_cast<int>( angle ) % 360 ) + 360 ) % 360;
2129 int snapped = ( ( normAngle + 45 ) / 90 ) * 90;
2131 if( snapped == 360 )
2143 switch(
static_cast<int>( align ) / 3 )
2151 switch(
static_cast<int>( align ) % 3 )
2166 wxStringTokenizer tok( aLine );
2169 long x1 = 0, y1 = 0, x2 = 0, y2 = 0, color = 0, width = 0;
2170 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
2172 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x1 );
2173 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y1 );
2174 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x2 );
2175 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y2 );
2176 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2180 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &width );
2181 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
2182 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
2183 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
2184 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
2187 VECTOR2I start =
toKiCad(
static_cast<int>( x1 ),
static_cast<int>( y1 ) );
2190 auto line = std::make_unique<SCH_LINE>( start,
LAYER_NOTES );
2191 line->SetEndPoint(
end );
2194 m_screen->Append( line.release() );
2203 wxStringTokenizer tok( aLine );
2206 long x = 0, y = 0, w = 0, h = 0, color = 0, linewidth = 0;
2207 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
2208 long filltype = 0, fillwidth = 0, a1 = 0, p1 = 0, a2 = 0, p2 = 0;
2210 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
2211 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
2212 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &w );
2213 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &h );
2214 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2218 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
2219 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
2220 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
2221 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
2222 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
2223 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
2224 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &fillwidth );
2225 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a1 );
2226 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p1 );
2227 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a2 );
2228 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p2 );
2231 VECTOR2I topLeft =
toKiCad(
static_cast<int>( x ),
static_cast<int>( y + h ) );
2232 VECTOR2I botRight =
toKiCad(
static_cast<int>( x + w ),
static_cast<int>( y ) );
2235 rect->SetStart( topLeft );
2236 rect->SetEnd( botRight );
2244 rect->SetFilled(
true );
2245 rect->SetFillMode( fill );
2248 m_screen->Append( rect.release() );
2257 wxStringTokenizer tok( aLine );
2260 long cx = 0, cy = 0,
radius = 0, color = 0, linewidth = 0;
2261 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
2262 long filltype = 0, fillwidth = 0, a1 = 0, p1 = 0, a2 = 0, p2 = 0;
2264 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cx );
2265 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cy );
2266 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &
radius );
2267 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2271 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
2272 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
2273 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
2274 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
2275 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
2276 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
2277 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &fillwidth );
2278 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a1 );
2279 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p1 );
2280 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a2 );
2281 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p2 );
2296 circle->SetFilled(
true );
2297 circle->SetFillMode( fill );
2308 wxStringTokenizer tok( aLine );
2311 long cx = 0, cy = 0,
radius = 0, startAngle = 0, sweepAngle = 0;
2312 long color = 0, linewidth = 0, capstyle = 0, dashstyle = 0;
2313 long dashlength = 0, dashspace = 0;
2315 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cx );
2316 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cy );
2317 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &
radius );
2318 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &startAngle );
2319 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &sweepAngle );
2320 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2324 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
2325 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
2326 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
2327 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
2328 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
2334 double startRad =
DEG2RAD(
static_cast<double>( startAngle ) );
2335 double endRad =
DEG2RAD(
static_cast<double>( startAngle + sweepAngle ) );
2344 arc->SetCenter(
center );
2348 arc->SetStart( arcEnd );
2349 arc->SetEnd( arcStart );
2363 wxStringTokenizer tok( aLine );
2366 long color = 0, width = 0, capstyle = 0, dashstyle = 0;
2367 long dashlength = 0, dashspace = 0, filltype = 0, fillwidth = 0;
2368 long a1 = 0, p1 = 0, a2 = 0, p2 = 0, numlines = 0;
2370 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2371 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &width );
2372 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
2373 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
2374 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
2375 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
2376 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
2377 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &fillwidth );
2378 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a1 );
2379 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p1 );
2380 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a2 );
2381 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p2 );
2382 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &numlines );
2387 for(
long i = 0; i < numlines && aLineIdx < aFile.GetLineCount(); i++ )
2390 pathData += wxT(
" " );
2392 pathData += aFile.GetLine( aLineIdx ).Trim();
2403 auto seg = std::make_unique<SCH_LINE>( aFrom,
LAYER_NOTES );
2404 seg->SetEndPoint( aTo );
2405 seg->SetStroke( stroke );
2409 wxStringTokenizer pathTok( pathData, wxT(
" ,\t" ) );
2413 auto relToAbs = [&](
long dx,
long dy ) ->
VECTOR2I
2419 while( pathTok.HasMoreTokens() )
2421 wxString token = pathTok.GetNextToken();
2423 if( token == wxT(
"M" ) )
2425 long px = 0, py = 0;
2427 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
2428 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
2430 currentPt =
toKiCad(
static_cast<int>( px ),
static_cast<int>( py ) );
2431 startPt = currentPt;
2434 else if( token == wxT(
"m" ) )
2436 long dx = 0, dy = 0;
2438 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dx )
2439 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dy ) )
2441 currentPt = relToAbs( dx, dy );
2442 startPt = currentPt;
2445 else if( token == wxT(
"L" ) )
2447 long px = 0, py = 0;
2449 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
2450 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
2452 VECTOR2I pt =
toKiCad(
static_cast<int>( px ),
static_cast<int>( py ) );
2453 emitSeg( currentPt, pt );
2457 else if( token == wxT(
"l" ) )
2459 long dx = 0, dy = 0;
2461 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dx )
2462 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dy ) )
2465 emitSeg( currentPt, pt );
2469 else if( token == wxT(
"C" ) )
2471 long cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, px = 0, py = 0;
2473 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx1 )
2474 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy1 )
2475 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx2 )
2476 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy2 )
2477 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
2478 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
2480 VECTOR2I cp1 =
toKiCad(
static_cast<int>( cx1 ),
static_cast<int>( cy1 ) );
2481 VECTOR2I cp2 =
toKiCad(
static_cast<int>( cx2 ),
static_cast<int>( cy2 ) );
2482 VECTOR2I endPt =
toKiCad(
static_cast<int>( px ),
static_cast<int>( py ) );
2485 bezier->SetStart( currentPt );
2486 bezier->SetBezierC1( cp1 );
2487 bezier->SetBezierC2( cp2 );
2488 bezier->SetEnd( endPt );
2489 bezier->SetStroke( stroke );
2490 bezier->RebuildBezierToSegmentsPointsList(
2492 m_screen->Append( bezier.release() );
2496 else if( token == wxT(
"c" ) )
2498 long cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, dx = 0, dy = 0;
2500 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx1 )
2501 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy1 )
2502 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx2 )
2503 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy2 )
2504 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dx )
2505 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dy ) )
2507 VECTOR2I cp1 = relToAbs( cx1, cy1 );
2508 VECTOR2I cp2 = relToAbs( cx2, cy2 );
2509 VECTOR2I endPt = relToAbs( dx, dy );
2512 bezier->SetStart( currentPt );
2513 bezier->SetBezierC1( cp1 );
2514 bezier->SetBezierC2( cp2 );
2515 bezier->SetEnd( endPt );
2516 bezier->SetStroke( stroke );
2517 bezier->RebuildBezierToSegmentsPointsList(
2519 m_screen->Append( bezier.release() );
2523 else if( token == wxT(
"Z" ) || token == wxT(
"z" ) )
2525 if( currentPt != startPt )
2527 emitSeg( currentPt, startPt );
2528 currentPt = startPt;
2540 wxStringTokenizer tok( aLine );
2543 long x = 0, y = 0, w = 0, h = 0, angle = 0, mirror = 0, embedded = 0;
2545 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
2546 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
2547 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &w );
2548 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &h );
2549 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &angle );
2550 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &mirror );
2551 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &embedded );
2555 if( aLineIdx < aFile.GetLineCount() )
2557 filename = aFile.GetLine( aLineIdx ).Trim().Trim(
false );
2561 wxString base64Data;
2565 while( aLineIdx < aFile.GetLineCount() )
2567 wxString dataLine = aFile.GetLine( aLineIdx );
2570 if( dataLine.Trim() == wxT(
"." ) )
2573 base64Data += dataLine.Trim();
2577 auto bitmap = std::make_unique<SCH_BITMAP>();
2579 bool loaded =
false;
2581 int savedLoadFlags = wxImage::GetDefaultLoadFlags();
2582 wxImage::SetDefaultLoadFlags( savedLoadFlags & ~wxImage::Load_Verbose );
2584 if( embedded && !base64Data.IsEmpty() )
2586 wxMemoryBuffer buf = wxBase64Decode( base64Data );
2588 if( buf.GetDataLen() > 0 )
2591 else if( !filename.IsEmpty() )
2593 wxFileName imgFile( filename );
2595 if( !imgFile.IsAbsolute() &&
m_filename.IsOk() )
2596 imgFile.MakeAbsolute(
m_filename.GetPath() );
2598 if( imgFile.FileExists() )
2602 wxImage::SetDefaultLoadFlags( savedLoadFlags );
2609 int gCenterX =
static_cast<int>( x ) +
static_cast<int>( w ) / 2;
2610 int gCenterY =
static_cast<int>( y ) +
static_cast<int>( h ) / 2;
2613 int targetWidth =
toKiCadDist(
static_cast<int>( w ) );
2618 double scaleFactor =
static_cast<double>( targetWidth ) / imgSize.
x;
2622 bitmap->SetPosition(
center );
2625 bitmap->MirrorHorizontally(
center.x );
2627 for(
long a = angle; a > 0; a -= 90 )
2628 bitmap->Rotate(
center,
false );
2630 m_maxY = std::max(
m_maxY,
static_cast<int>( y + h ) );
2631 m_screen->Append( bitmap.release() );
2649 if( wxGetEnv( wxT(
"GEDADATA" ), &gedaData ) && !gedaData.IsEmpty() )
2651 wxString envSymDir = gedaData + wxFileName::GetPathSeparator() + wxT(
"sym" );
2653 if( wxDir::Exists( envSymDir ) )
2658 static const wxString defaultPaths[] = {
2659 wxT(
"/usr/share/gEDA/sym" ),
2660 wxT(
"/usr/share/geda-symbols" ),
2661 wxT(
"/usr/local/share/gEDA/sym" ),
2662 wxT(
"/usr/local/share/geda-symbols" ),
2663 wxT(
"/usr/share/lepton-eda/sym" ),
2664 wxT(
"/usr/local/share/lepton-eda/sym" ),
2667 for(
const wxString& dir : defaultPaths )
2669 if( wxDir::Exists( dir ) )
2675 wxString xdgDataDirs;
2677 if( wxGetEnv( wxT(
"XDG_DATA_DIRS" ), &xdgDataDirs ) && !xdgDataDirs.IsEmpty() )
2679 wxStringTokenizer xdgTok( xdgDataDirs, wxT(
":" ) );
2681 while( xdgTok.HasMoreTokens() )
2683 wxString dataDir = xdgTok.GetNextToken();
2685 if( dataDir.IsEmpty() )
2688 wxString leptonSymDir = dataDir + wxFileName::GetPathSeparator()
2689 + wxT(
"lepton-eda" ) + wxFileName::GetPathSeparator()
2692 if( wxDir::Exists( leptonSymDir ) )
2695 wxString gedaSymDir = dataDir + wxFileName::GetPathSeparator()
2696 + wxT(
"gEDA" ) + wxFileName::GetPathSeparator()
2699 if( wxDir::Exists( gedaSymDir ) )
2713 wxString homeDir = wxGetHomeDir();
2715 if( !homeDir.IsEmpty() )
2717 wxString userGedaDir = homeDir + wxFileName::GetPathSeparator() + wxT(
".gEDA" );
2725 wxString sep( wxFileName::GetPathSeparator() );
2727 if( wxGetEnv( wxT(
"XDG_CONFIG_HOME" ), &leptonDir ) && !leptonDir.IsEmpty() )
2728 leptonDir += sep + wxT(
"lepton-eda" );
2730 leptonDir = homeDir + sep + wxT(
".config" ) + sep + wxT(
"lepton-eda" );
2737 if( !schDir.IsEmpty() )
2746 static const wxString configNames[] = {
2747 wxT(
"lepton.conf" ),
2751 for(
const wxString& configName : configNames )
2753 wxString confPath = schDir + wxFileName::GetPathSeparator() + configName;
2755 if( !wxFileExists( confPath ) )
2758 wxTextFile confFile;
2760 if( !confFile.Open( confPath ) )
2763 bool inLibsSection =
false;
2765 for(
size_t i = 0; i < confFile.GetLineCount(); ++i )
2767 wxString line = confFile.GetLine( i );
2771 if( line.IsEmpty() || line[0] ==
'#' || line[0] ==
';' )
2774 if( line[0] ==
'[' )
2776 inLibsSection = ( line.CmpNoCase( wxT(
"[libs]" ) ) == 0 );
2780 if( !inLibsSection )
2783 if( line.StartsWith( wxT(
"component-library" ) ) )
2785 int eqPos = line.Find(
'=' );
2787 if( eqPos == wxNOT_FOUND )
2790 wxString libPath = line.Mid( eqPos + 1 ).Trim(
false ).Trim(
true );
2791 wxFileName libDir( libPath );
2793 if( !libDir.IsAbsolute() )
2795 libDir.MakeAbsolute( schDir );
2796 libPath = libDir.GetFullPath();
2799 if( wxDir::Exists( libPath ) )
2809 wxString symDir = schDir + wxFileName::GetPathSeparator() + wxT(
"sym" );
2811 if( wxDir::Exists( symDir ) )
2814 wxFileName parentDir( schDir );
2815 parentDir.RemoveLastDir();
2816 wxString parentSymDir =
2817 parentDir.GetPath() + wxFileName::GetPathSeparator() + wxT(
"sym" );
2819 if( wxDir::Exists( parentSymDir ) )
2829 wxString paths = it->second;
2830 wxStringTokenizer tok( paths, wxT(
"\n;" ) );
2832 while( tok.HasMoreTokens() )
2834 wxString dir = tok.GetNextToken().Trim().Trim(
false );
2836 if( !dir.IsEmpty() && wxDir::Exists( dir ) )
2851 if( !dir.IsOpened() )
2855 bool cont = dir.GetFirst( &filename );
2859 wxString fullPath = aDir + wxFileName::GetPathSeparator() + filename;
2861 if( wxDir::Exists( fullPath ) )
2865 else if( filename.EndsWith( wxT(
".sym" ) ) )
2868 entry.
path = fullPath;
2872 cont = dir.GetNext( &filename );
2879 if( !wxFileExists( aPath ) )
2884 if( !rcFile.Open( aPath ) )
2887 for(
size_t i = 0; i < rcFile.GetLineCount(); ++i )
2889 wxString line = rcFile.GetLine( i );
2893 if( !line.StartsWith( wxT(
"(component-library-search " ) )
2894 && !line.StartsWith( wxT(
"(component-library " ) ) )
2899 int firstQuote = line.Find(
'"' );
2901 if( firstQuote == wxNOT_FOUND )
2907 int secondQuote = line.Mid( firstQuote + 1 ).Find(
'"' );
2909 if( secondQuote != wxNOT_FOUND )
2910 secondQuote += firstQuote + 1;
2912 if( secondQuote == wxNOT_FOUND || secondQuote <= firstQuote )
2915 wxString libPath = line.Mid( firstQuote + 1, secondQuote - firstQuote - 1 );
2916 wxFileName libDir( libPath );
2918 if( !libDir.IsAbsolute() )
2920 libDir.MakeAbsolute( aBaseDir );
2921 libPath = libDir.GetFullPath();
2924 if( wxDir::Exists( libPath ) )
2931 wxString* aSymversion,
2932 wxString* aNetAttr )
2936 if( !file.Open( aPath ) )
2939 if( file.GetLineCount() == 0 )
2943 wxString firstLine = file.GetFirstLine().Trim(
false );
2945 if( !firstLine.StartsWith( wxT(
"v " ) ) )
2948 wxFileName fn( aPath );
2949 wxString symName = fn.GetName();
2950 auto libSym = std::make_unique<LIB_SYMBOL>( symName );
2951 libSym->SetShowPinNumbers(
true );
2952 libSym->SetShowPinNames(
true );
2956 while( lineIdx < file.GetLineCount() )
2958 wxString line = file.GetLine( lineIdx );
2960 if( line.IsEmpty() )
2966 wxChar type = line[0];
2973 wxStringTokenizer tok( line );
2975 long px1 = 0, py1 = 0, px2 = 0, py2 = 0, pc = 0, pt = 0, pw = 0;
2977 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &px1 );
2978 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &py1 );
2979 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &px2 );
2980 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &py2 );
2981 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pc );
2982 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pt );
2983 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pw );
2986 addSymbolPin( *libSym,
static_cast<int>( px1 ),
static_cast<int>( py1 ),
2987 static_cast<int>( px2 ),
static_cast<int>( py2 ),
2988 static_cast<int>( pw ), pinAttrs );
3003 wxStringTokenizer tok( line );
3007 for(
int i = 0; i < 9 && tok.HasMoreTokens(); i++ )
3009 wxString fieldVal = tok.GetNextToken();
3012 fieldVal.ToLong( &numLines );
3015 for(
long i = 0; i < numLines && lineIdx < file.GetLineCount(); i++ )
3017 wxString textLine = file.GetLine( lineIdx );
3019 if( aSymversion && textLine.StartsWith( wxT(
"symversion=" ) ) )
3020 *aSymversion = textLine.Mid( 11 );
3022 if( aNetAttr && textLine.StartsWith( wxT(
"net=" ) ) )
3023 *aNetAttr = textLine.Mid( 4 );
3034 while( lineIdx < file.GetLineCount() )
3036 if( file.GetLine( lineIdx ).Trim() == wxT(
"}" ) )
3059 int aWhichEnd,
const std::vector<GEDA_ATTR>& aAttrs )
3063 int connX = 0, connY = 0, otherX = 0, otherY = 0;
3065 if( aWhichEnd == 0 )
3067 connX = aX1; connY = aY1;
3068 otherX = aX2; otherY = aY2;
3072 connX = aX2; connY = aY2;
3073 otherX = aX1; otherY = aY1;
3083 int dx = otherX - connX;
3084 int dy = otherY - connY;
3098 wxString pinnumber =
findAttr( aAttrs, wxT(
"pinnumber" ) );
3099 wxString pinlabel =
findAttr( aAttrs, wxT(
"pinlabel" ) );
3100 wxString pintypeStr =
findAttr( aAttrs, wxT(
"pintype" ) );
3102 if( pinnumber.IsEmpty() )
3103 pinnumber = wxT(
"?" );
3105 if( pinlabel.IsEmpty() )
3106 pinlabel = pinnumber;
3110 if( pintypeStr == wxT(
"in" ) )
3112 else if( pintypeStr == wxT(
"out" ) )
3114 else if( pintypeStr == wxT(
"io" ) )
3116 else if( pintypeStr == wxT(
"oc" ) )
3118 else if( pintypeStr == wxT(
"oe" ) )
3120 else if( pintypeStr == wxT(
"pas" ) )
3122 else if( pintypeStr == wxT(
"tp" ) )
3124 else if( pintypeStr == wxT(
"tri" ) )
3126 else if( pintypeStr == wxT(
"clk" ) )
3128 else if( pintypeStr == wxT(
"pwr" ) )
3132 pin->SetPosition( connPt );
3133 pin->SetLength( length );
3134 pin->SetOrientation( orient );
3135 pin->SetNumber( pinnumber );
3136 pin->SetName( pinlabel );
3137 pin->SetType( elecType );
3144 wxTextFile& aFile,
size_t& aLineIdx, wxChar aType )
3150 wxStringTokenizer tok( aLine );
3152 long x1 = 0, y1 = 0, x2 = 0, y2 = 0, color = 0, width = 0;
3153 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
3155 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x1 );
3156 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y1 );
3157 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x2 );
3158 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y2 );
3159 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
3160 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &width );
3161 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
3162 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
3163 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
3164 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
3182 wxStringTokenizer tok( aLine );
3184 long x = 0, y = 0, w = 0, h = 0, color = 0, linewidth = 0;
3185 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
3188 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
3189 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
3190 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &w );
3191 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &h );
3192 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
3193 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
3194 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
3195 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
3196 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
3197 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
3198 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
3207 rect->
SetEnd( botRight );
3225 wxStringTokenizer tok( aLine );
3227 long cx = 0, cy = 0, r = 0, color = 0, linewidth = 0;
3228 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
3231 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cx );
3232 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cy );
3233 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &r );
3234 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
3235 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
3236 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
3237 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
3238 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
3239 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
3240 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
3255 circle->SetFilled(
true );
3256 circle->SetFillMode( fill );
3265 wxStringTokenizer tok( aLine );
3267 long cx = 0, cy = 0, r = 0, sa = 0, da = 0;
3268 long color = 0, linewidth = 0;
3270 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cx );
3271 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cy );
3272 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &r );
3273 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &sa );
3274 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &da );
3275 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
3276 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
3282 double startRad =
DEG2RAD(
static_cast<double>( sa ) );
3283 double endRad =
DEG2RAD(
static_cast<double>( sa + da ) );
3305 wxStringTokenizer tok( aLine );
3308 long color = 0, width = 0, capstyle = 0, dashstyle = 0;
3309 long dashlength = 0, dashspace = 0, filltype = 0, fillwidth = 0;
3310 long a1 = 0, p1 = 0, a2 = 0, p2 = 0, numlines = 0;
3312 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
3313 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &width );
3314 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
3315 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
3316 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
3317 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
3318 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
3319 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &fillwidth );
3320 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a1 );
3321 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p1 );
3322 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a2 );
3323 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p2 );
3324 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &numlines );
3328 for(
long i = 0; i < numlines && aLineIdx < aFile.GetLineCount(); i++ )
3331 pathData += wxT(
" " );
3333 pathData += aFile.GetLine( aLineIdx ).Trim();
3337 std::vector<VECTOR2I> polyPts;
3344 auto flushPoly = [&]()
3346 if( polyPts.size() < 2 )
3351 for(
const VECTOR2I& pt : polyPts )
3366 wxStringTokenizer pathTok( pathData, wxT(
" ,\t" ) );
3368 while( pathTok.HasMoreTokens() )
3370 wxString pathToken = pathTok.GetNextToken();
3373 auto symAbsPt = [
this](
long aX,
long aY ) ->
VECTOR2I
3379 auto symRelPt = [
this, ¤tPt](
long aDx,
long aDy ) ->
VECTOR2I
3385 bool isRelative = ( pathToken.IsAscii() && islower( pathToken[0u] ) );
3387 if( pathToken == wxT(
"M" ) || pathToken == wxT(
"m" ) )
3389 long px = 0, py = 0;
3391 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
3392 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
3394 currentPt = isRelative ? symRelPt( px, py ) : symAbsPt( px, py );
3395 startPt = currentPt;
3397 if( polyPts.empty() )
3398 polyPts.push_back( currentPt );
3401 else if( pathToken == wxT(
"L" ) || pathToken == wxT(
"l" ) )
3403 long px = 0, py = 0;
3405 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
3406 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
3408 currentPt = isRelative ? symRelPt( px, py ) : symAbsPt( px, py );
3409 polyPts.push_back( currentPt );
3412 else if( pathToken == wxT(
"C" ) || pathToken == wxT(
"c" ) )
3414 long cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, px = 0, py = 0;
3416 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx1 )
3417 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy1 )
3418 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx2 )
3419 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy2 )
3420 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
3421 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
3425 VECTOR2I cp1 = isRelative ? symRelPt( cx1, cy1 ) : symAbsPt( cx1, cy1 );
3426 VECTOR2I cp2 = isRelative ? symRelPt( cx2, cy2 ) : symAbsPt( cx2, cy2 );
3427 VECTOR2I endPt = isRelative ? symRelPt( px, py ) : symAbsPt( px, py );
3446 polyPts.push_back( currentPt );
3449 else if( pathToken == wxT(
"Z" ) || pathToken == wxT(
"z" ) )
3451 if( currentPt != startPt )
3453 polyPts.push_back( startPt );
3454 currentPt = startPt;
3477 size_t m = a.length();
3478 size_t n = b.length();
3480 std::vector<int> prev( n + 1 );
3481 std::vector<int> curr( n + 1 );
3483 for(
size_t j = 0; j <= n; ++j )
3484 prev[j] =
static_cast<int>( j );
3486 for(
size_t i = 1; i <= m; ++i )
3488 curr[0] =
static_cast<int>( i );
3490 for(
size_t j = 1; j <= n; ++j )
3492 int cost = ( a[i - 1] == b[j - 1] ) ? 0 : 1;
3493 curr[j] = std::min( { prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost } );
3496 std::swap( prev, curr );
3506 auto it = builtins.find( aBasename );
3508 if( it == builtins.end() )
3511 wxString tempPath = wxFileName::CreateTempFileName( wxT(
"geda_sym_" ) );
3513 if( tempPath.IsEmpty() )
3517 wxFile temp( tempPath, wxFile::write );
3519 if( !temp.IsOpened() || !temp.Write( it->second ) )
3521 wxRemoveFile( tempPath );
3528 wxRemoveFile( tempPath );
3532 wxString symName = aBasename;
3534 if( symName.EndsWith( wxT(
".sym" ) ) )
3535 symName = symName.Left( symName.length() - 4 );
3537 result->SetName( symName );
3539 if( !netAttr.IsEmpty() )
3556 return it->second.get();
3565 if( !cacheIt->second.symbol )
3568 &cacheIt->second.symversion,
3569 &cacheIt->second.netAttr );
3574 if( cacheIt->second.symbol && cacheIt->second.netAttr.IsEmpty() )
3577 auto builtinIt = builtins.find( aBasename );
3579 if( builtinIt != builtins.end() )
3583 const wxString& src = builtinIt->second;
3584 int pos = src.Find( wxT(
"\nnet=" ) );
3586 if( pos != wxNOT_FOUND )
3588 wxString rest = src.Mid( pos + 5 );
3589 int eol = rest.Find(
'\n' );
3591 cacheIt->second.netAttr = ( eol != wxNOT_FOUND )
3592 ? rest.Left( eol ).Trim()
3599 if( cacheIt->second.symbol )
3601 m_libSymbols[aBasename] = std::make_unique<LIB_SYMBOL>( *cacheIt->second.symbol );
3620 wxString suggestion;
3621 int bestDist = INT_MAX;
3627 if( dist < bestDist && dist <= 3 )
3639 if( dist < bestDist && dist <= 3 )
3646 wxString msg = wxString::Format(
_(
"Symbol '%s' not found in gEDA libraries." ),
3649 if( !suggestion.IsEmpty() )
3650 msg += wxString::Format(
_(
" Did you mean '%s'?" ), suggestion );
3661 wxString symName = aBasename;
3663 if( symName.EndsWith( wxT(
".sym" ) ) )
3664 symName = symName.Left( symName.length() - 4 );
3666 auto libSymbol = std::make_unique<LIB_SYMBOL>( symName );
3667 libSymbol->SetShowPinNumbers(
true );
3668 libSymbol->SetShowPinNames(
true );
3676 libSymbol->AddDrawItem( rect );
3697 bool isNoConnect =
m_pendingComp->basename.StartsWith( wxT(
"nc-" ) )
3698 && ncValue == wxT(
"NoConnection" );
3708 const std::vector<SCH_PIN*>& pins = ncSym->
GetPins();
3712 VECTOR2I pinPos = pins[0]->GetPosition();
3724 case 90: rx = -pinLocalY; ry = pinLocalX;
break;
3725 case 180: rx = -pinLocalX; ry = -pinLocalY;
break;
3726 case 270: rx = pinLocalY; ry = -pinLocalX;
break;
3745 if( !sourceAttr.IsEmpty() && sourceAttr.EndsWith( wxT(
".sch" ) ) )
3782 symSymver = cacheIt->second.symversion;
3784 if( !symSymver.IsEmpty() )
3788 compSymver.BeforeFirst(
'.' ).ToLong( &compMajor );
3789 symSymver.BeforeFirst(
'.' ).ToLong( &symMajor );
3791 if( compMajor != symMajor )
3794 wxString label = refdes.IsEmpty() ?
m_pendingComp->basename : refdes;
3797 wxString::Format(
_(
"Symbol version mismatch for '%s' (%s): "
3798 "schematic has symversion %s, "
3799 "library symbol has symversion %s." ),
3801 compSymver, symSymver ),
3810 wxString symNetAttr;
3814 symNetAttr = cacheEntry->second.netAttr;
3816 bool isPowerSym = !symNetAttr.IsEmpty();
3817 wxString powerNetName;
3818 std::unique_ptr<LIB_SYMBOL> powerCopy;
3825 wxString effectiveNet = schematicNet.IsEmpty() ? symNetAttr : schematicNet;
3827 int colonPos = effectiveNet.Find(
':' );
3829 if( colonPos != wxNOT_FOUND )
3830 powerNetName = effectiveNet.Left( colonPos );
3832 powerNetName = effectiveNet;
3836 powerCopy = std::make_unique<LIB_SYMBOL>( *libSym );
3837 libSym = powerCopy.get();
3849 pin->SetName( powerNetName );
3857 auto symbol = std::make_unique<SCH_SYMBOL>( *libSym, libId, &
m_schematic->CurrentSheet(),
3861 symbol->SetOrientation( orient );
3865 wxString pwrRef = wxString::Format( wxT(
"#PWR%04d" ), ++
m_powerCounter );
3866 symbol->SetRef( &
m_schematic->CurrentSheet(), pwrRef );
3876 if( graphicalAttr == wxT(
"1" ) )
3878 symbol->SetExcludedFromBOM(
true );
3879 symbol->SetExcludedFromBoard(
true );
3880 symbol->SetExcludedFromSim(
true );
3887 if( !isPowerSym && !refdes.IsEmpty() )
3889 symbol->SetRef( &
m_schematic->CurrentSheet(), refdes );
3904 if( !isPowerSym && !value.IsEmpty() )
3919 if( !footprint.IsEmpty() )
3920 symbol->SetFootprintFieldText( footprint );
3925 if( !documentation.IsEmpty() )
3928 dsField->
SetText( documentation );
3934 if( descAttr && !descAttr->
value.IsEmpty() )
3954 if( attr.
name == wxT(
"net" ) )
3956 int colonPos = attr.
value.Find(
':' );
3958 if( colonPos != wxNOT_FOUND )
3963 rec.
symbol = symbol.get();
3973 if( attr.
name == wxT(
"refdes" ) || attr.
name == wxT(
"value" )
3974 || attr.
name == wxT(
"footprint" ) || attr.
name == wxT(
"net" )
3975 || attr.
name == wxT(
"device" ) || attr.
name == wxT(
"symversion" )
3976 || attr.
name == wxT(
"documentation" ) || attr.
name == wxT(
"description" )
3977 || attr.
name == wxT(
"graphical" )
3978 || attr.
name == wxT(
"slot" ) || attr.
name == wxT(
"numslots" )
3979 || attr.
name == wxT(
"slotdef" ) )
3995 VECTOR2I pinPos = symbol->GetPinPhysicalPosition(
pin );
4001 symbol->SetLibSymbol(
new LIB_SYMBOL( *libSym ) );
4010 if( !slotStr.IsEmpty() && slotStr.ToLong( &slotNum ) && slotNum > 0 )
4012 wxString targetSlotDef;
4016 if( attr.
name != wxT(
"slotdef" ) )
4019 int colonPos = attr.
value.Find(
':' );
4021 if( colonPos == wxNOT_FOUND )
4026 if( attr.
value.Left( colonPos ).ToLong( &defSlot ) && defSlot == slotNum )
4028 targetSlotDef = attr.
value.Mid( colonPos + 1 );
4033 if( !targetSlotDef.IsEmpty() )
4035 wxArrayString slotPins;
4036 wxStringTokenizer slotTok( targetSlotDef, wxT(
"," ) );
4038 while( slotTok.HasMoreTokens() )
4039 slotPins.Add( slotTok.GetNextToken() );
4041 LIB_SYMBOL* privateSym = symbol->GetLibSymbolRef().get();
4045 std::map<long, SCH_PIN*> pinsBySeq;
4050 pinsBySeq[autoSeq] =
pin;
4054 for(
size_t i = 0; i < slotPins.size() && i < pinsBySeq.size(); i++ )
4056 auto seqIt = pinsBySeq.find(
static_cast<long>( i + 1 ) );
4058 if( seqIt != pinsBySeq.end() )
4059 seqIt->second->SetNumber( slotPins[i].Trim() );
4064 m_screen->Append( symbol.release() );
4075 wxFileName sourceFileName( aSourceFile );
4078 if( !sourceFileName.IsAbsolute() )
4079 sourceFileName.SetPath(
m_filename.GetPath() );
4081 wxString fullPath = sourceFileName.GetFullPath();
4083 if( !wxFileExists( fullPath ) )
4088 wxString::Format(
_(
"Hierarchical source '%s' not found, "
4089 "creating empty sheet." ),
4100 wxString::Format(
_(
"Circular hierarchy detected for '%s', skipping." ),
4113 auto sheet = std::make_unique<SCH_SHEET>(
m_rootSheet, pos, sheetSize );
4117 if( !refdes.IsEmpty() )
4124 sourceFileName.GetName() );
4128 sheet->SetFileName( aSourceFile );
4131 m_screen->Append( sheet.release() );
4133 if( wxFileExists( fullPath ) )
4171 const LIB_SYMBOL* libSym = rec.symbol->GetLibSymbolRef().get();
4179 if(
pin->GetNumber() == rec.pinnumber )
4181 VECTOR2I pinPos = rec.symbol->GetPinPhysicalPosition(
pin );
4183 auto label = std::make_unique<SCH_GLOBALLABEL>( pinPos, rec.netname );
4185 label->SetTextSize(
VECTOR2I( textSize, textSize ) );
4192 switch(
pin->GetOrientation() )
4198 default: pinDir =
VECTOR2I( 1, 0 );
break;
4201 VECTOR2I worldDir = rec.symbol->GetTransform().TransformCoordinate( pinDir );
4215 m_screen->Append( label.release() );
4226 std::vector<std::pair<VECTOR2I, VECTOR2I>> wireSegs;
4227 std::set<std::pair<int, int>> junctionPts;
4246 junctionPts.insert( { pos.first, pos.second } );
4254 if( junctionPts.count( pos ) )
4259 for(
const auto& [segStart, segEnd] : wireSegs )
4261 if( pt == segStart || pt == segEnd )
4264 bool isHorizontal = ( segStart.y == segEnd.y );
4265 bool isVertical = ( segStart.x == segEnd.x );
4267 if( !isHorizontal && !isVertical )
4272 if( isHorizontal && pt.
y == segStart.y )
4274 int minX = std::min( segStart.x, segEnd.x );
4275 int maxX = std::max( segStart.x, segEnd.x );
4276 onSeg = ( pt.
x > minX && pt.
x < maxX );
4278 else if( isVertical && pt.
x == segStart.x )
4280 int minY = std::min( segStart.y, segEnd.y );
4281 int maxY = std::max( segStart.y, segEnd.y );
4282 onSeg = ( pt.
y > minY && pt.
y < maxY );
4287 junctionPts.insert( pos );
4293 for(
const auto& [gX, gY] : junctionPts )
4296 m_screen->Append( std::make_unique<SCH_JUNCTION>( kicadPos ).release() );
4307 std::vector<std::pair<VECTOR2I, SCH_LINE*>> wireEndpoints;
4320 wireEndpoints.emplace_back( wire->
GetEndPoint(), wire );
4327 bool busIsHorizontal = ( bus.start.y == bus.end.y );
4328 bool busIsVertical = ( bus.start.x == bus.end.x );
4330 if( !busIsHorizontal && !busIsVertical )
4333 for(
const auto& [pt, wire] : wireEndpoints )
4337 if( busIsHorizontal )
4339 int minX = std::min( bus.start.x, bus.end.x );
4340 int maxX = std::max( bus.start.x, bus.end.x );
4341 onBus = ( pt.y == bus.start.y && pt.x >= minX && pt.x <= maxX );
4345 int minY = std::min( bus.start.y, bus.end.y );
4346 int maxY = std::max( bus.start.y, bus.end.y );
4347 onBus = ( pt.x == bus.start.x && pt.y >= minY && pt.y <= maxY );
4354 VECTOR2I otherEnd = ( wire->GetStartPoint() == pt ) ? wire->GetEndPoint()
4355 : wire->GetStartPoint();
4359 if( busIsHorizontal )
4361 dy = ( otherEnd.
y < pt.y ) ? -entrySize : entrySize;
4362 int sign = bus.ripperDir;
4367 int busMidX = ( bus.start.x + bus.end.x ) / 2;
4368 sign = ( pt.x <= busMidX ) ? 1 : -1;
4371 dx =
sign * entrySize;
4375 dx = ( otherEnd.
x < pt.x ) ? -entrySize : entrySize;
4376 int sign = bus.ripperDir;
4380 int busMidY = ( bus.start.y + bus.end.y ) / 2;
4381 sign = ( pt.y <= busMidY ) ? 1 : -1;
4384 dy =
sign * entrySize;
4388 auto entry = std::make_unique<SCH_BUS_WIRE_ENTRY>( pt );
4389 entry->SetSize(
VECTOR2I( dx, dy ) );
4394 if( wire->GetStartPoint() == pt )
4395 wire->SetStartPoint( entryTip );
4397 wire->SetEndPoint( entryTip );
4399 m_screen->Append( entry.release() );
4424 subEntry.
path = entry.path;
4448 wxString::Format(
_(
"Failed to load sub-schematic '%s': %s" ),
4449 deferred.sourceFile, e.
What() ),
4462 bbox.
Merge( item->GetBoundingBox() );
4473 if( pageSizeIU.
x < targetSize.
x )
4476 if( pageSizeIU.
y < targetSize.
y )
4479 m_screen->SetPageSettings( pageInfo );
4482 VECTOR2I sheetCentre( pageSizeIU.
x / 2, pageSizeIU.
y / 2 );
4485 VECTOR2I translation = sheetCentre - itemsCentre;
4486 translation.
x = translation.
x - translation.
x %
schIUScale.MilsToIU( 100 );
4487 translation.
y = translation.
y - translation.
y %
schIUScale.MilsToIU( 100 );
4489 std::vector<SCH_ITEM*> allItems;
4491 std::back_inserter( allItems ) );
4495 item->SetPosition( item->GetPosition() + translation );
4508 const std::map<std::string, UTF8>* aProperties )
4510 wxASSERT( !aFileName.IsEmpty() && aSchematic );
4531 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
4532 "Can't append to a schematic with no root!" );
4554 if( !file.Open( aFileName ) )
4555 THROW_IO_ERROR( wxString::Format(
_(
"Cannot open file '%s'." ), aFileName ) );
4557 if( file.GetLineCount() == 0 )
4558 THROW_IO_ERROR( wxString::Format(
_(
"File '%s' is empty." ), aFileName ) );
4562 for(
size_t i = 0; i < file.GetLineCount(); i++ )
4564 wxString line = file.GetLine( i );
4565 wxChar type = line.IsEmpty() ?
'\0' : line[0];
4571 while( ++i < file.GetLineCount() )
4573 if( file.GetLine( i ).Trim() == wxT(
"]" ) )
4580 if( type ==
'C' || type ==
'N' || type ==
'U' || type ==
'T' || type ==
'L'
4581 || type ==
'B' || type ==
'V' || type ==
'A' || type ==
'P' || type ==
'G' )
4583 wxStringTokenizer tok( line );
4588 if( tok.HasMoreTokens() ) tok.GetNextToken();
4590 if( tok.HasMoreTokens() )
4592 tok.GetNextToken().ToLong( &val );
4595 m_maxY =
static_cast<int>( val );
4598 if( type ==
'N' || type ==
'U' || type ==
'L' || type ==
'P' )
4600 if( tok.HasMoreTokens() ) tok.GetNextToken();
4602 if( tok.HasMoreTokens() )
4604 tok.GetNextToken().ToLong( &val );
4607 m_maxY =
static_cast<int>( val );
4613 long bw = 0, bh = 0;
4615 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &bw );
4616 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &bh );
4618 long top = val + bh;
4624 if( type ==
'V' || type ==
'A' )
4630 if( tok.HasMoreTokens() )
4631 tok.GetNextToken().ToLong( &
radius );
4633 long extent = val +
radius;
4636 m_maxY =
static_cast<int>( extent );
4646 long numTextLines = 1;
4648 for(
int j = 0; j < 6 && tok.HasMoreTokens(); j++ )
4651 if( tok.HasMoreTokens() )
4652 tok.GetNextToken().ToLong( &numTextLines );
4654 i +=
static_cast<size_t>( numTextLines );
4657 else if( type ==
'H' )
4660 wxStringTokenizer tok( line );
4664 for(
int j = 0; j < 12 && tok.HasMoreTokens(); j++ )
4667 if( tok.HasMoreTokens() )
4668 tok.GetNextToken().ToLong( &numlines );
4670 for(
long j = 0; j < numlines && ( i + 1 ) < file.GetLineCount(); j++ )
4673 wxString pathLine = file.GetLine( i );
4674 wxStringTokenizer ptok( pathLine, wxT(
" ,\t" ) );
4678 bool nextIsY =
false;
4680 while( ptok.HasMoreTokens() )
4682 wxString token = ptok.GetNextToken();
4684 if( token.length() == 1 && wxIsalpha( token[0] ) )
4692 if( token.ToLong( &pval ) )
4694 if( nextIsY && pval >
m_maxY )
4695 m_maxY =
static_cast<int>( pval );
4708 wxString firstLine = file.GetLine( lineIdx );
4713 THROW_IO_ERROR( wxString::Format(
_(
"File '%s' is not a valid gEDA schematic." ),
4718 while( lineIdx < file.GetLineCount() )
4720 wxString line = file.GetLine( lineIdx );
4723 if( line.IsEmpty() )
4726 wxChar type = line[0];
4780 while( lineIdx < file.GetLineCount() )
4782 if( file.GetLine( lineIdx ).Trim() == wxT(
"}" ) )
4811 auto it = aProperties->find(
"additional_schematics" );
4813 if( it != aProperties->end() )
4815 wxString additionalFiles = wxString::FromUTF8( it->second.c_str() );
4816 wxStringTokenizer tok( additionalFiles, wxT(
";" ) );
4818 int sheetSpacing =
schIUScale.MilsToIU( 2000 );
4821 while( tok.HasMoreTokens() )
4823 wxString filePath = tok.GetNextToken();
4824 wxFileName fn( filePath );
4829 auto subSheet = std::make_unique<SCH_SHEET>(
m_rootSheet, pos, size );
4832 wxString::Format( wxT(
"Page %d" ), pageNum ) );
4834 subSheet->SetFileName( fn.GetFullName() );
4836 SCH_SHEET* subSheetPtr = subSheet.get();
4837 m_screen->Append( subSheet.release() );
4839 if( fn.FileExists() )
4850 copy.path = entry.path;
4851 copy.symversion = entry.symversion;
4852 copy.netAttr = entry.netAttr;
4861 subSheetPtr,
nullptr );
4868 wxString::Format(
_(
"Failed to load page '%s': %s" ),
4869 fn.GetFullName(), e.
What() ),
4875 sheetY += sheetSpacing;
constexpr EDA_IU_SCALE schIUScale
constexpr double ARC_LOW_DEF_MM
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr size_type GetHeight() const
constexpr const SizeVec & GetSize() const
void SetBezierC2(const VECTOR2I &aPt)
void SetCenter(const VECTOR2I &aCenter)
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
void SetStart(const VECTOR2I &aStart)
void SetEnd(const VECTOR2I &aEnd)
void SetBezierC1(const VECTOR2I &aPt)
void SetFillMode(FILL_T aFill)
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual void SetVisible(bool aVisible)
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
A logical library item identifier and consists of various portions much like a URI.
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Define a library symbol object.
wxString GetName() const override
SCH_FIELD & GetValueField()
Return reference to the value field.
std::vector< SCH_PIN * > GetPins() const override
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetHeightMils(double aHeightInMils)
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
void SetWidthMils(double aWidthInMils)
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
bool ReadImageFile(const wxString &aFullFilename)
Read and store an image file.
void SetImageScale(double aScale)
Set the image "zoom" value.
Holds all the data relating to one schematic.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
void SetTopLevelSheets(const std::vector< SCH_SHEET * > &aSheets)
void SetPosition(const VECTOR2I &aPosition) override
void SetText(const wxString &aText) override
std::unique_ptr< PENDING_COMPONENT > m_pendingComp
Pending component awaiting symbol resolution.
void addBusEntries()
Create SCH_BUS_WIRE_ENTRY objects where net endpoints touch bus segments.
void importHierarchicalSheet(const wxString &aSourceFile)
Import a gEDA hierarchical sub-schematic as a KiCad SCH_SHEET.
int toKiCadDist(int aMils) const
Convert a gEDA distance in mils to KiCad IU.
void addSymbolGraphic(LIB_SYMBOL &aSymbol, const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx, wxChar aType)
Add a graphical item (line/box/circle/arc/path) to a LIB_SYMBOL.
void parseBus(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
void fitPageToContent()
Enlarge the page if needed and center all content on the sheet.
std::vector< GEDA_ATTR > maybeParseAttributes(wxTextFile &aFile, size_t &aLineIdx)
Check for and consume a { } attribute block at the current line position.
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
bool m_symLibraryInitialized
const GEDA_ATTR * findAttrStruct(const std::vector< GEDA_ATTR > &aAttrs, const wxString &aName) const
Find a GEDA_ATTR struct by name, returns nullptr if not found.
void parseEmbeddedComponent(wxTextFile &aFile, size_t &aLineIdx)
void addJunctions()
Place junctions where 3+ net/pin endpoints coincide.
void parseNet(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
void postProcess()
Run the full post-processing pipeline after parsing is complete:
std::map< std::pair< int, int >, int > m_netEndpoints
Net endpoint positions in raw gEDA coordinates for junction detection.
int m_powerCounter
Sequential counter for auto-generated #PWR references.
static constexpr int MILS_TO_IU
gEDA coordinates are mils with Y-up.
int m_maxY
The maximum Y coordinate seen during parsing (gEDA coords, before flip).
std::vector< DEFERRED_SHEET > m_deferredSheets
std::unique_ptr< LIB_SYMBOL > loadBuiltinSymbol(const wxString &aBasename)
Try loading a symbol from the built-in standard library embedded in the importer.
LIB_SYMBOL * getOrLoadSymbol(const wxString &aBasename)
Get or load a cached symbol by gEDA basename.
void parseText(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
void parseComponent(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
void parsePin(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
int toKiCadOrientation(int aAngle, int aMirror) const
Map gEDA angle (0/90/180/270) + mirror to KiCad symbol orientation.
void parseLine(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
void parseCircle(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
std::map< wxString, std::unique_ptr< LIB_SYMBOL > > m_libSymbols
Loaded symbols for this import session, keyed by basename.
void parsePath(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
void scanSymbolDir(const wxString &aDir, int aDepth=0)
Recursively scan a directory for .sym files and populate m_symLibrary.
std::set< wxString > m_importStack
Set of fully-resolved file paths currently in the import call stack, used to detect and prevent circu...
wxString getLibName() const
Derive the KiCad import library name from the schematic file.
void flushPendingComponent()
Instantiate the pending component: look up or load the symbol, create SCH_SYMBOL, apply transforms an...
std::unique_ptr< LIB_SYMBOL > createFallbackSymbol(const wxString &aBasename)
Create a fallback rectangular symbol when the .sym file is not found.
static const std::map< wxString, wxString > & getBuiltinSymbols()
Return the map of built-in gEDA symbol definitions (symbol name -> .sym content).
VECTOR2I toKiCad(int aGedaX, int aGedaY) const
Apply the Y-flip and scale to transform gEDA coords to KiCad.
static LINE_STYLE toLineStyle(int aDashStyle)
Map gEDA dashstyle (0-4) to KiCad LINE_STYLE.
void parseBox(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
std::vector< NET_ATTR_RECORD > m_netAttrRecords
wxString findAttr(const std::vector< GEDA_ATTR > &aAttrs, const wxString &aName) const
Find an attribute by name, returns empty string if not found.
std::vector< BUS_SEGMENT > m_busSegments
void parseArc(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
bool CanReadSchematicFile(const wxString &aFileName) const override
Checks if this SCH_IO can read the specified schematic file.
std::unique_ptr< LIB_SYMBOL > loadSymbolFile(const wxString &aPath, wxString *aSymversion=nullptr, wxString *aNetAttr=nullptr)
Load a .sym file and return a LIB_SYMBOL.
void processNetAttributes()
For each component with net= attributes, create global labels at pin positions.
void initSymbolLibrary()
Ensure the symbol library hash is built by scanning gEDA library dirs.
std::map< wxString, SYM_CACHE_ENTRY > m_symLibrary
Symbol library cache: gEDA basename -> cache entry.
long m_releaseVersion
gEDA file version fields from the "v YYYYMMDD N" header line.
void parsePicture(const wxString &aLine, wxTextFile &aFile, size_t &aLineIdx)
void parseRcFileForLibraries(const wxString &aPath, const wxString &aBaseDir)
Parse an RC file (gafrc or gschemrc) for component-library directives.
void trackEndpoint(int aGedaX, int aGedaY)
Track a point as a net or pin endpoint for junction detection.
bool parseVersionLine(const wxString &aLine)
Parse the "v YYYYMMDD N" version line and validate.
std::vector< GEDA_ATTR > parseAttributes(wxTextFile &aFile, size_t &aLineIdx)
Read a { } attribute block starting after the '{' line.
const std::map< std::string, UTF8 > * m_properties
Properties passed from the import framework (search paths, etc.)
void addSymbolPin(LIB_SYMBOL &aSymbol, int aX1, int aY1, int aX2, int aY2, int aWhichEnd, const std::vector< GEDA_ATTR > &aAttrs)
Create a pin on a LIB_SYMBOL from gEDA P line data and its attributes.
void loadDeferredSheets()
Load sub-schematics for any SCH_SHEET objects created during parsing.
static FILL_T toFillType(int aFillType)
Map gEDA filltype (0-4) to KiCad FILL_T.
SCH_IO(const wxString &aName)
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Segment description base class to describe items which have 2 end points (track, wire,...
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
const KIID & GetUuid() const
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
void SetFilled(bool aFilled) override
void SetStroke(const STROKE_PARAMS &aStroke) override
void AddPoint(const VECTOR2I &aPosition)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Simple container to manage line stroke parameters.
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
static REPORTER & GetInstance()
#define DEFAULT_SCH_ENTRY_SIZE
The default text size in mils. (can be changed in preference menu)
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_270
static constexpr EDA_ANGLE ANGLE_180
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
@ FILLED_SHAPE
Fill with object color.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
@ PT_INPUT
usual pin input: must be connected
@ PT_TRISTATE
tri state bus pin
@ PT_BIDI
input or output (like port for a microprocessor)
@ PT_OPENEMITTER
pin type open emitter
@ PT_OPENCOLLECTOR
pin type open collector
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
PIN_ORIENTATION
The symbol library pin object orientations.
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
@ PIN_RIGHT
The pin extends rightwards from the connection point.
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
static constexpr int GEDA_DEFAULT_TEXT_SIZE_MILS
static wxString convertOverbars(const wxString &aInput)
Convert gEDA overbar markup to KiCad syntax.
static constexpr int DEFAULT_SYMBOL_SIZE_MILS
static int editDistance(const wxString &a, const wxString &b)
Compute the Levenshtein edit distance between two strings.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
LINE_STYLE
Dashed line types.
Parsed bus segment in KiCad coordinates with gEDA ripper direction.
Deferred hierarchical sheet loads.
Parsed attribute from a gEDA T line inside a { } block.
int showNV
0=name+value, 1=value, 2=name
Components with net= attributes that need post-processing.
Entry in the symbol library search cache.
wxString netAttr
net= attribute (e.g. "GND:1") identifying power symbols
wxString path
Full path to .sym file.
@ USER
The field ID hasn't been set yet; field is invalid.
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
KIBIS top(path, &reporter)
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
wxString result
Test unit parsing edge cases and error handling.
double DEG2RAD(double deg)
constexpr int sign(T val)
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.