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" ) ),
1494 wxFileName fn( aFileName );
1496 if( fn.GetExt().CmpNoCase( wxT(
"sch" ) ) != 0 )
1501 if( !file.Open( aFileName ) )
1504 if( file.GetLineCount() == 0 )
1507 wxString firstLine = file.GetFirstLine().Trim(
false );
1509 if( !firstLine.StartsWith( wxT(
"v " ) ) )
1512 wxStringTokenizer tok( firstLine );
1515 if( !tok.HasMoreTokens() )
1518 wxString dateStr = tok.GetNextToken();
1520 if( dateStr.length() != 8 )
1524 return dateStr.ToLong( &dateVal ) && dateVal >= 19700101;
1534 return static_cast<int>(
static_cast<int64_t
>( aMils ) *
MILS_TO_IU );
1550 wxStringTokenizer tokenizer( aLine );
1552 if( tokenizer.CountTokens() < 2 )
1555 wxString v = tokenizer.GetNextToken();
1557 if( v != wxT(
"v" ) )
1560 wxString dateStr = tokenizer.GetNextToken();
1567 if( tokenizer.HasMoreTokens() )
1583 std::vector<GEDA_ATTR> attrs;
1585 while( aLineIdx < aFile.GetLineCount() )
1587 wxString line = aFile.GetLine( aLineIdx );
1589 if( line.Trim() == wxT(
"}" ) )
1595 if( line.StartsWith( wxT(
"T " ) ) )
1598 wxStringTokenizer tok( line );
1601 long x = 0, y = 0, color = 0, size = 0, vis = 0, showNV = 0, angle = 0, align = 0;
1604 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
1605 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
1606 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
1607 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &size );
1608 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &vis );
1609 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &showNV );
1610 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &angle );
1611 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &align );
1612 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &numLines );
1616 wxString textContent;
1618 for(
long i = 0; i < numLines && aLineIdx < aFile.GetLineCount(); i++ )
1621 textContent += wxT(
"\n" );
1623 textContent += aFile.GetLine( aLineIdx );
1627 int eqPos = textContent.Find(
'=' );
1629 if( eqPos != wxNOT_FOUND )
1632 attr.
name = textContent.Left( eqPos );
1633 attr.
value = textContent.Mid( eqPos + 1 );
1636 if( attr.
value.length() >= 2
1637 && attr.
value.StartsWith( wxT(
"\"" ) )
1638 && attr.
value.EndsWith( wxT(
"\"" ) ) )
1643 attr.
x =
static_cast<int>( x );
1644 attr.
y =
static_cast<int>( y );
1645 attr.
size =
static_cast<int>( size );
1646 attr.
angle =
static_cast<int>( angle );
1647 attr.
align =
static_cast<int>( align );
1649 attr.
showNV =
static_cast<int>( showNV );
1650 attrs.push_back( attr );
1664 const wxString& aName )
const
1668 if( attr.name == aName )
1672 return wxEmptyString;
1677 const wxString& aName )
const
1681 if( attr.name == aName )
1692 if( aLineIdx < aFile.GetLineCount() && aFile.GetLine( aLineIdx ).Trim() == wxT(
"{" ) )
1708 switch( aDashStyle )
1760 libName =
m_schematic->Project().GetProjectName();
1762 if( libName.IsEmpty() )
1765 if( libName.IsEmpty() )
1766 libName = wxT(
"noname" );
1768 libName += wxT(
"-geda-import" );
1784 wxStringTokenizer tok( aLine );
1787 long x = 0, y = 0, selectable = 0, angle = 0, mirror = 0;
1789 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
1790 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
1791 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &selectable );
1792 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &angle );
1793 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &mirror );
1797 if( tok.HasMoreTokens() )
1798 basename = tok.GetNextToken();
1801 if( basename.StartsWith( wxT(
"EMBEDDED" ) ) )
1802 basename = basename.Mid( 8 );
1819 wxStringTokenizer tok( aLine );
1822 long x1 = 0, y1 = 0, x2 = 0, y2 = 0;
1824 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x1 );
1825 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y1 );
1826 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x2 );
1827 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y2 );
1829 VECTOR2I start =
toKiCad(
static_cast<int>( x1 ),
static_cast<int>( y1 ) );
1832 auto wire = std::make_unique<SCH_LINE>( start,
LAYER_WIRE );
1833 wire->SetEndPoint(
end );
1834 m_screen->Append( wire.release() );
1836 trackEndpoint(
static_cast<int>( x1 ),
static_cast<int>( y1 ) );
1837 trackEndpoint(
static_cast<int>( x2 ),
static_cast<int>( y2 ) );
1840 wxString netname =
findAttr( attrs, wxT(
"netname" ) );
1842 if( !netname.IsEmpty() )
1844 auto label = std::make_unique<SCH_LABEL>( start, netname );
1846 label->SetTextSize(
VECTOR2I( textSize, textSize ) );
1847 m_screen->Append( label.release() );
1855 wxStringTokenizer tok( aLine );
1858 long x1 = 0, y1 = 0, x2 = 0, y2 = 0, color = 0, ripperDir = 0;
1860 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x1 );
1861 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y1 );
1862 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x2 );
1863 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y2 );
1864 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
1868 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &ripperDir );
1871 VECTOR2I start =
toKiCad(
static_cast<int>( x1 ),
static_cast<int>( y1 ) );
1874 auto line = std::make_unique<SCH_LINE>( start,
LAYER_BUS );
1875 line->SetEndPoint(
end );
1876 m_screen->Append( line.release() );
1887 wxStringTokenizer tok( aLine );
1890 long x1 = 0, y1 = 0, x2 = 0, y2 = 0, color = 0, pintype = 0, whichend = 0;
1892 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x1 );
1893 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y1 );
1894 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x2 );
1895 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y2 );
1896 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
1900 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pintype );
1901 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &whichend );
1904 VECTOR2I start =
toKiCad(
static_cast<int>( x1 ),
static_cast<int>( y1 ) );
1908 auto wire = std::make_unique<SCH_LINE>( start,
LAYER_WIRE );
1909 wire->SetEndPoint(
end );
1910 m_screen->Append( wire.release() );
1912 VECTOR2I connPt = ( whichend == 0 ) ? start :
end;
1913 int connX = ( whichend == 0 ) ?
static_cast<int>( x1 ) :
static_cast<int>( x2 );
1914 int connY = ( whichend == 0 ) ?
static_cast<int>( y1 ) :
static_cast<int>( y2 );
1919 wxString pinlabel =
findAttr( attrs, wxT(
"pinlabel" ) );
1921 if( !pinlabel.IsEmpty() )
1923 auto label = std::make_unique<SCH_LABEL>( connPt, pinlabel );
1925 label->SetTextSize(
VECTOR2I( textSize, textSize ) );
1926 m_screen->Append( label.release() );
1936 auto libSym = std::make_unique<LIB_SYMBOL>(
m_pendingComp->basename );
1939 while( aLineIdx < aFile.GetLineCount() )
1941 wxString line = aFile.GetLine( aLineIdx );
1943 if( line.Trim() == wxT(
"]" ) )
1949 if( line.IsEmpty() )
1955 wxChar type = line[0];
1962 wxStringTokenizer tok( line );
1964 long px1 = 0, py1 = 0, px2 = 0, py2 = 0, pc = 0, pt = 0, pw = 0;
1966 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &px1 );
1967 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &py1 );
1968 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &px2 );
1969 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &py2 );
1970 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pc );
1971 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pt );
1972 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pw );
1975 addSymbolPin( *libSym,
static_cast<int>( px1 ),
static_cast<int>( py1 ),
1976 static_cast<int>( px2 ),
static_cast<int>( py2 ),
1977 static_cast<int>( pw ), pinAttrs );
1992 wxStringTokenizer tok( line );
1997 for(
int i = 0; i < 8 && tok.HasMoreTokens(); i++ )
2000 tok.GetNextToken().ToLong( &numLines );
2005 for(
long i = 0; i < numLines && aLineIdx < aFile.GetLineCount(); i++ )
2015 while( aLineIdx < aFile.GetLineCount() )
2017 if( aFile.GetLine( aLineIdx ).Trim() == wxT(
"}" ) )
2048 wxStringTokenizer tok( aLine );
2051 long x = 0, y = 0, color = 0, size = 0, vis = 0, showNV = 0, angle = 0, align = 0;
2054 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
2055 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
2056 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2057 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &size );
2058 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &vis );
2059 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &showNV );
2060 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &angle );
2064 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &align );
2065 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &numLines );
2069 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &align );
2079 wxString textContent;
2081 for(
long i = 0; i < numLines && aLineIdx < aFile.GetLineCount(); i++ )
2084 textContent += wxT(
"\n" );
2086 textContent += aFile.GetLine( aLineIdx );
2099 int eqPos = textContent.Find(
'=' );
2101 if( eqPos != wxNOT_FOUND )
2103 wxString
name = textContent.Left( eqPos );
2104 wxString value = textContent.Mid( eqPos + 1 );
2106 switch(
static_cast<int>( showNV ) )
2108 case 1: textContent = value;
break;
2109 case 2: textContent =
name;
break;
2110 default: textContent =
name + wxT(
"=" ) + value;
break;
2114 VECTOR2I pos =
toKiCad(
static_cast<int>( x ),
static_cast<int>( y ) );
2116 auto text = std::make_unique<SCH_TEXT>( pos, textContent );
2118 int textSize =
toKiCadDist(
static_cast<int>( size ) * 10 );
2127 int normAngle = ( (
static_cast<int>( angle ) % 360 ) + 360 ) % 360;
2128 int snapped = ( ( normAngle + 45 ) / 90 ) * 90;
2130 if( snapped == 360 )
2142 switch(
static_cast<int>( align ) / 3 )
2150 switch(
static_cast<int>( align ) % 3 )
2165 wxStringTokenizer tok( aLine );
2168 long x1 = 0, y1 = 0, x2 = 0, y2 = 0, color = 0, width = 0;
2169 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
2171 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x1 );
2172 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y1 );
2173 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x2 );
2174 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y2 );
2175 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2179 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &width );
2180 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
2181 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
2182 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
2183 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
2186 VECTOR2I start =
toKiCad(
static_cast<int>( x1 ),
static_cast<int>( y1 ) );
2189 auto line = std::make_unique<SCH_LINE>( start,
LAYER_NOTES );
2190 line->SetEndPoint(
end );
2193 m_screen->Append( line.release() );
2202 wxStringTokenizer tok( aLine );
2205 long x = 0, y = 0, w = 0, h = 0, color = 0, linewidth = 0;
2206 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
2207 long filltype = 0, fillwidth = 0, a1 = 0, p1 = 0, a2 = 0, p2 = 0;
2209 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
2210 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
2211 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &w );
2212 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &h );
2213 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2217 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
2218 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
2219 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
2220 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
2221 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
2222 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
2223 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &fillwidth );
2224 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a1 );
2225 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p1 );
2226 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a2 );
2227 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p2 );
2230 VECTOR2I topLeft =
toKiCad(
static_cast<int>( x ),
static_cast<int>( y + h ) );
2231 VECTOR2I botRight =
toKiCad(
static_cast<int>( x + w ),
static_cast<int>( y ) );
2234 rect->SetStart( topLeft );
2235 rect->SetEnd( botRight );
2243 rect->SetFilled(
true );
2244 rect->SetFillMode( fill );
2247 m_screen->Append( rect.release() );
2256 wxStringTokenizer tok( aLine );
2259 long cx = 0, cy = 0,
radius = 0, color = 0, linewidth = 0;
2260 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
2261 long filltype = 0, fillwidth = 0, a1 = 0, p1 = 0, a2 = 0, p2 = 0;
2263 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cx );
2264 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cy );
2265 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &
radius );
2266 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2270 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
2271 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
2272 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
2273 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
2274 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
2275 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
2276 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &fillwidth );
2277 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a1 );
2278 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p1 );
2279 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a2 );
2280 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p2 );
2295 circle->SetFilled(
true );
2296 circle->SetFillMode( fill );
2307 wxStringTokenizer tok( aLine );
2310 long cx = 0, cy = 0,
radius = 0, startAngle = 0, sweepAngle = 0;
2311 long color = 0, linewidth = 0, capstyle = 0, dashstyle = 0;
2312 long dashlength = 0, dashspace = 0;
2314 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cx );
2315 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cy );
2316 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &
radius );
2317 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &startAngle );
2318 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &sweepAngle );
2319 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2323 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
2324 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
2325 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
2326 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
2327 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
2333 double startRad =
DEG2RAD(
static_cast<double>( startAngle ) );
2334 double endRad =
DEG2RAD(
static_cast<double>( startAngle + sweepAngle ) );
2343 arc->SetCenter(
center );
2347 arc->SetStart( arcEnd );
2348 arc->SetEnd( arcStart );
2362 wxStringTokenizer tok( aLine );
2365 long color = 0, width = 0, capstyle = 0, dashstyle = 0;
2366 long dashlength = 0, dashspace = 0, filltype = 0, fillwidth = 0;
2367 long a1 = 0, p1 = 0, a2 = 0, p2 = 0, numlines = 0;
2369 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
2370 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &width );
2371 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
2372 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
2373 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
2374 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
2375 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
2376 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &fillwidth );
2377 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a1 );
2378 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p1 );
2379 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a2 );
2380 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p2 );
2381 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &numlines );
2386 for(
long i = 0; i < numlines && aLineIdx < aFile.GetLineCount(); i++ )
2389 pathData += wxT(
" " );
2391 pathData += aFile.GetLine( aLineIdx ).Trim();
2402 auto seg = std::make_unique<SCH_LINE>( aFrom,
LAYER_NOTES );
2403 seg->SetEndPoint( aTo );
2404 seg->SetStroke( stroke );
2408 wxStringTokenizer pathTok( pathData, wxT(
" ,\t" ) );
2412 auto relToAbs = [&](
long dx,
long dy ) ->
VECTOR2I
2418 while( pathTok.HasMoreTokens() )
2420 wxString token = pathTok.GetNextToken();
2422 if( token == wxT(
"M" ) )
2424 long px = 0, py = 0;
2426 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
2427 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
2429 currentPt =
toKiCad(
static_cast<int>( px ),
static_cast<int>( py ) );
2430 startPt = currentPt;
2433 else if( token == wxT(
"m" ) )
2435 long dx = 0, dy = 0;
2437 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dx )
2438 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dy ) )
2440 currentPt = relToAbs( dx, dy );
2441 startPt = currentPt;
2444 else if( token == wxT(
"L" ) )
2446 long px = 0, py = 0;
2448 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
2449 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
2451 VECTOR2I pt =
toKiCad(
static_cast<int>( px ),
static_cast<int>( py ) );
2452 emitSeg( currentPt, pt );
2456 else if( token == wxT(
"l" ) )
2458 long dx = 0, dy = 0;
2460 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dx )
2461 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dy ) )
2464 emitSeg( currentPt, pt );
2468 else if( token == wxT(
"C" ) )
2470 long cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, px = 0, py = 0;
2472 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx1 )
2473 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy1 )
2474 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx2 )
2475 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy2 )
2476 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
2477 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
2479 VECTOR2I cp1 =
toKiCad(
static_cast<int>( cx1 ),
static_cast<int>( cy1 ) );
2480 VECTOR2I cp2 =
toKiCad(
static_cast<int>( cx2 ),
static_cast<int>( cy2 ) );
2481 VECTOR2I endPt =
toKiCad(
static_cast<int>( px ),
static_cast<int>( py ) );
2484 bezier->SetStart( currentPt );
2485 bezier->SetBezierC1( cp1 );
2486 bezier->SetBezierC2( cp2 );
2487 bezier->SetEnd( endPt );
2488 bezier->SetStroke( stroke );
2489 bezier->RebuildBezierToSegmentsPointsList(
2491 m_screen->Append( bezier.release() );
2495 else if( token == wxT(
"c" ) )
2497 long cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, dx = 0, dy = 0;
2499 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx1 )
2500 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy1 )
2501 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx2 )
2502 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy2 )
2503 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dx )
2504 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &dy ) )
2506 VECTOR2I cp1 = relToAbs( cx1, cy1 );
2507 VECTOR2I cp2 = relToAbs( cx2, cy2 );
2508 VECTOR2I endPt = relToAbs( dx, dy );
2511 bezier->SetStart( currentPt );
2512 bezier->SetBezierC1( cp1 );
2513 bezier->SetBezierC2( cp2 );
2514 bezier->SetEnd( endPt );
2515 bezier->SetStroke( stroke );
2516 bezier->RebuildBezierToSegmentsPointsList(
2518 m_screen->Append( bezier.release() );
2522 else if( token == wxT(
"Z" ) || token == wxT(
"z" ) )
2524 if( currentPt != startPt )
2526 emitSeg( currentPt, startPt );
2527 currentPt = startPt;
2539 wxStringTokenizer tok( aLine );
2542 long x = 0, y = 0, w = 0, h = 0, angle = 0, mirror = 0, embedded = 0;
2544 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
2545 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
2546 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &w );
2547 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &h );
2548 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &angle );
2549 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &mirror );
2550 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &embedded );
2554 if( aLineIdx < aFile.GetLineCount() )
2556 filename = aFile.GetLine( aLineIdx ).Trim().Trim(
false );
2560 wxString base64Data;
2564 while( aLineIdx < aFile.GetLineCount() )
2566 wxString dataLine = aFile.GetLine( aLineIdx );
2569 if( dataLine.Trim() == wxT(
"." ) )
2572 base64Data += dataLine.Trim();
2576 auto bitmap = std::make_unique<SCH_BITMAP>();
2578 bool loaded =
false;
2580 int savedLoadFlags = wxImage::GetDefaultLoadFlags();
2581 wxImage::SetDefaultLoadFlags( savedLoadFlags & ~wxImage::Load_Verbose );
2583 if( embedded && !base64Data.IsEmpty() )
2585 wxMemoryBuffer buf = wxBase64Decode( base64Data );
2587 if( buf.GetDataLen() > 0 )
2590 else if( !filename.IsEmpty() )
2592 wxFileName imgFile( filename );
2594 if( !imgFile.IsAbsolute() &&
m_filename.IsOk() )
2595 imgFile.MakeAbsolute(
m_filename.GetPath() );
2597 if( imgFile.FileExists() )
2601 wxImage::SetDefaultLoadFlags( savedLoadFlags );
2608 int gCenterX =
static_cast<int>( x ) +
static_cast<int>( w ) / 2;
2609 int gCenterY =
static_cast<int>( y ) +
static_cast<int>( h ) / 2;
2612 int targetWidth =
toKiCadDist(
static_cast<int>( w ) );
2617 double scaleFactor =
static_cast<double>( targetWidth ) / imgSize.
x;
2621 bitmap->SetPosition(
center );
2624 bitmap->MirrorHorizontally(
center.x );
2626 for(
long a = angle; a > 0; a -= 90 )
2627 bitmap->Rotate(
center,
false );
2629 m_maxY = std::max(
m_maxY,
static_cast<int>( y + h ) );
2630 m_screen->Append( bitmap.release() );
2648 if( wxGetEnv( wxT(
"GEDADATA" ), &gedaData ) && !gedaData.IsEmpty() )
2650 wxString envSymDir = gedaData + wxFileName::GetPathSeparator() + wxT(
"sym" );
2652 if( wxDir::Exists( envSymDir ) )
2657 static const wxString defaultPaths[] = {
2658 wxT(
"/usr/share/gEDA/sym" ),
2659 wxT(
"/usr/share/geda-symbols" ),
2660 wxT(
"/usr/local/share/gEDA/sym" ),
2661 wxT(
"/usr/local/share/geda-symbols" ),
2662 wxT(
"/usr/share/lepton-eda/sym" ),
2663 wxT(
"/usr/local/share/lepton-eda/sym" ),
2666 for(
const wxString& dir : defaultPaths )
2668 if( wxDir::Exists( dir ) )
2674 wxString xdgDataDirs;
2676 if( wxGetEnv( wxT(
"XDG_DATA_DIRS" ), &xdgDataDirs ) && !xdgDataDirs.IsEmpty() )
2678 wxStringTokenizer xdgTok( xdgDataDirs, wxT(
":" ) );
2680 while( xdgTok.HasMoreTokens() )
2682 wxString dataDir = xdgTok.GetNextToken();
2684 if( dataDir.IsEmpty() )
2687 wxString leptonSymDir = dataDir + wxFileName::GetPathSeparator()
2688 + wxT(
"lepton-eda" ) + wxFileName::GetPathSeparator()
2691 if( wxDir::Exists( leptonSymDir ) )
2694 wxString gedaSymDir = dataDir + wxFileName::GetPathSeparator()
2695 + wxT(
"gEDA" ) + wxFileName::GetPathSeparator()
2698 if( wxDir::Exists( gedaSymDir ) )
2712 wxString homeDir = wxGetHomeDir();
2714 if( !homeDir.IsEmpty() )
2716 wxString userGedaDir = homeDir + wxFileName::GetPathSeparator() + wxT(
".gEDA" );
2724 wxString sep( wxFileName::GetPathSeparator() );
2726 if( wxGetEnv( wxT(
"XDG_CONFIG_HOME" ), &leptonDir ) && !leptonDir.IsEmpty() )
2727 leptonDir += sep + wxT(
"lepton-eda" );
2729 leptonDir = homeDir + sep + wxT(
".config" ) + sep + wxT(
"lepton-eda" );
2736 if( !schDir.IsEmpty() )
2745 static const wxString configNames[] = {
2746 wxT(
"lepton.conf" ),
2750 for(
const wxString& configName : configNames )
2752 wxString confPath = schDir + wxFileName::GetPathSeparator() + configName;
2754 if( !wxFileExists( confPath ) )
2757 wxTextFile confFile;
2759 if( !confFile.Open( confPath ) )
2762 bool inLibsSection =
false;
2764 for(
size_t i = 0; i < confFile.GetLineCount(); ++i )
2766 wxString line = confFile.GetLine( i );
2770 if( line.IsEmpty() || line[0] ==
'#' || line[0] ==
';' )
2773 if( line[0] ==
'[' )
2775 inLibsSection = ( line.CmpNoCase( wxT(
"[libs]" ) ) == 0 );
2779 if( !inLibsSection )
2782 if( line.StartsWith( wxT(
"component-library" ) ) )
2784 int eqPos = line.Find(
'=' );
2786 if( eqPos == wxNOT_FOUND )
2789 wxString libPath = line.Mid( eqPos + 1 ).Trim(
false ).Trim(
true );
2790 wxFileName libDir( libPath );
2792 if( !libDir.IsAbsolute() )
2794 libDir.MakeAbsolute( schDir );
2795 libPath = libDir.GetFullPath();
2798 if( wxDir::Exists( libPath ) )
2808 wxString symDir = schDir + wxFileName::GetPathSeparator() + wxT(
"sym" );
2810 if( wxDir::Exists( symDir ) )
2813 wxFileName parentDir( schDir );
2814 parentDir.RemoveLastDir();
2815 wxString parentSymDir =
2816 parentDir.GetPath() + wxFileName::GetPathSeparator() + wxT(
"sym" );
2818 if( wxDir::Exists( parentSymDir ) )
2828 wxString paths = it->second;
2829 wxStringTokenizer tok( paths, wxT(
"\n;" ) );
2831 while( tok.HasMoreTokens() )
2833 wxString dir = tok.GetNextToken().Trim().Trim(
false );
2835 if( !dir.IsEmpty() && wxDir::Exists( dir ) )
2850 if( !dir.IsOpened() )
2854 bool cont = dir.GetFirst( &filename );
2858 wxString fullPath = aDir + wxFileName::GetPathSeparator() + filename;
2860 if( wxDir::Exists( fullPath ) )
2864 else if( filename.EndsWith( wxT(
".sym" ) ) )
2867 entry.
path = fullPath;
2871 cont = dir.GetNext( &filename );
2878 if( !wxFileExists( aPath ) )
2883 if( !rcFile.Open( aPath ) )
2886 for(
size_t i = 0; i < rcFile.GetLineCount(); ++i )
2888 wxString line = rcFile.GetLine( i );
2892 if( !line.StartsWith( wxT(
"(component-library-search " ) )
2893 && !line.StartsWith( wxT(
"(component-library " ) ) )
2898 int firstQuote = line.Find(
'"' );
2900 if( firstQuote == wxNOT_FOUND )
2906 int secondQuote = line.Mid( firstQuote + 1 ).Find(
'"' );
2908 if( secondQuote != wxNOT_FOUND )
2909 secondQuote += firstQuote + 1;
2911 if( secondQuote == wxNOT_FOUND || secondQuote <= firstQuote )
2914 wxString libPath = line.Mid( firstQuote + 1, secondQuote - firstQuote - 1 );
2915 wxFileName libDir( libPath );
2917 if( !libDir.IsAbsolute() )
2919 libDir.MakeAbsolute( aBaseDir );
2920 libPath = libDir.GetFullPath();
2923 if( wxDir::Exists( libPath ) )
2930 wxString* aSymversion,
2931 wxString* aNetAttr )
2935 if( !file.Open( aPath ) )
2938 if( file.GetLineCount() == 0 )
2942 wxString firstLine = file.GetFirstLine().Trim(
false );
2944 if( !firstLine.StartsWith( wxT(
"v " ) ) )
2947 wxFileName fn( aPath );
2948 wxString symName = fn.GetName();
2949 auto libSym = std::make_unique<LIB_SYMBOL>( symName );
2950 libSym->SetShowPinNumbers(
true );
2951 libSym->SetShowPinNames(
true );
2955 while( lineIdx < file.GetLineCount() )
2957 wxString line = file.GetLine( lineIdx );
2959 if( line.IsEmpty() )
2965 wxChar type = line[0];
2972 wxStringTokenizer tok( line );
2974 long px1 = 0, py1 = 0, px2 = 0, py2 = 0, pc = 0, pt = 0, pw = 0;
2976 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &px1 );
2977 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &py1 );
2978 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &px2 );
2979 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &py2 );
2980 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pc );
2981 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pt );
2982 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &pw );
2985 addSymbolPin( *libSym,
static_cast<int>( px1 ),
static_cast<int>( py1 ),
2986 static_cast<int>( px2 ),
static_cast<int>( py2 ),
2987 static_cast<int>( pw ), pinAttrs );
3002 wxStringTokenizer tok( line );
3006 for(
int i = 0; i < 9 && tok.HasMoreTokens(); i++ )
3008 wxString fieldVal = tok.GetNextToken();
3011 fieldVal.ToLong( &numLines );
3014 for(
long i = 0; i < numLines && lineIdx < file.GetLineCount(); i++ )
3016 wxString textLine = file.GetLine( lineIdx );
3018 if( aSymversion && textLine.StartsWith( wxT(
"symversion=" ) ) )
3019 *aSymversion = textLine.Mid( 11 );
3021 if( aNetAttr && textLine.StartsWith( wxT(
"net=" ) ) )
3022 *aNetAttr = textLine.Mid( 4 );
3033 while( lineIdx < file.GetLineCount() )
3035 if( file.GetLine( lineIdx ).Trim() == wxT(
"}" ) )
3058 int aWhichEnd,
const std::vector<GEDA_ATTR>& aAttrs )
3062 int connX = 0, connY = 0, otherX = 0, otherY = 0;
3064 if( aWhichEnd == 0 )
3066 connX = aX1; connY = aY1;
3067 otherX = aX2; otherY = aY2;
3071 connX = aX2; connY = aY2;
3072 otherX = aX1; otherY = aY1;
3082 int dx = otherX - connX;
3083 int dy = otherY - connY;
3097 wxString pinnumber =
findAttr( aAttrs, wxT(
"pinnumber" ) );
3098 wxString pinlabel =
findAttr( aAttrs, wxT(
"pinlabel" ) );
3099 wxString pintypeStr =
findAttr( aAttrs, wxT(
"pintype" ) );
3101 if( pinnumber.IsEmpty() )
3102 pinnumber = wxT(
"?" );
3104 if( pinlabel.IsEmpty() )
3105 pinlabel = pinnumber;
3109 if( pintypeStr == wxT(
"in" ) )
3111 else if( pintypeStr == wxT(
"out" ) )
3113 else if( pintypeStr == wxT(
"io" ) )
3115 else if( pintypeStr == wxT(
"oc" ) )
3117 else if( pintypeStr == wxT(
"oe" ) )
3119 else if( pintypeStr == wxT(
"pas" ) )
3121 else if( pintypeStr == wxT(
"tp" ) )
3123 else if( pintypeStr == wxT(
"tri" ) )
3125 else if( pintypeStr == wxT(
"clk" ) )
3127 else if( pintypeStr == wxT(
"pwr" ) )
3131 pin->SetPosition( connPt );
3132 pin->SetLength( length );
3133 pin->SetOrientation( orient );
3134 pin->SetNumber( pinnumber );
3135 pin->SetName( pinlabel );
3136 pin->SetType( elecType );
3143 wxTextFile& aFile,
size_t& aLineIdx, wxChar aType )
3149 wxStringTokenizer tok( aLine );
3151 long x1 = 0, y1 = 0, x2 = 0, y2 = 0, color = 0, width = 0;
3152 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
3154 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x1 );
3155 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y1 );
3156 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x2 );
3157 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y2 );
3158 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
3159 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &width );
3160 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
3161 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
3162 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
3163 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
3181 wxStringTokenizer tok( aLine );
3183 long x = 0, y = 0, w = 0, h = 0, color = 0, linewidth = 0;
3184 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
3187 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &x );
3188 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &y );
3189 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &w );
3190 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &h );
3191 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
3192 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
3193 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
3194 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
3195 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
3196 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
3197 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
3206 rect->
SetEnd( botRight );
3224 wxStringTokenizer tok( aLine );
3226 long cx = 0, cy = 0, r = 0, color = 0, linewidth = 0;
3227 long capstyle = 0, dashstyle = 0, dashlength = 0, dashspace = 0;
3230 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cx );
3231 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cy );
3232 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &r );
3233 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
3234 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
3235 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
3236 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
3237 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
3238 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
3239 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
3254 circle->SetFilled(
true );
3255 circle->SetFillMode( fill );
3264 wxStringTokenizer tok( aLine );
3266 long cx = 0, cy = 0, r = 0, sa = 0, da = 0;
3267 long color = 0, linewidth = 0;
3269 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cx );
3270 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &cy );
3271 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &r );
3272 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &sa );
3273 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &da );
3274 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
3275 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &linewidth );
3281 double startRad =
DEG2RAD(
static_cast<double>( sa ) );
3282 double endRad =
DEG2RAD(
static_cast<double>( sa + da ) );
3304 wxStringTokenizer tok( aLine );
3307 long color = 0, width = 0, capstyle = 0, dashstyle = 0;
3308 long dashlength = 0, dashspace = 0, filltype = 0, fillwidth = 0;
3309 long a1 = 0, p1 = 0, a2 = 0, p2 = 0, numlines = 0;
3311 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &color );
3312 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &width );
3313 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &capstyle );
3314 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashstyle );
3315 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashlength );
3316 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &dashspace );
3317 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &filltype );
3318 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &fillwidth );
3319 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a1 );
3320 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p1 );
3321 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &a2 );
3322 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &p2 );
3323 if( tok.HasMoreTokens() ) tok.GetNextToken().ToLong( &numlines );
3327 for(
long i = 0; i < numlines && aLineIdx < aFile.GetLineCount(); i++ )
3330 pathData += wxT(
" " );
3332 pathData += aFile.GetLine( aLineIdx ).Trim();
3336 std::vector<VECTOR2I> polyPts;
3343 auto flushPoly = [&]()
3345 if( polyPts.size() < 2 )
3350 for(
const VECTOR2I& pt : polyPts )
3365 wxStringTokenizer pathTok( pathData, wxT(
" ,\t" ) );
3367 while( pathTok.HasMoreTokens() )
3369 wxString pathToken = pathTok.GetNextToken();
3372 auto symAbsPt = [
this](
long aX,
long aY ) ->
VECTOR2I
3378 auto symRelPt = [
this, ¤tPt](
long aDx,
long aDy ) ->
VECTOR2I
3384 bool isRelative = ( pathToken.IsAscii() && islower( pathToken[0u] ) );
3386 if( pathToken == wxT(
"M" ) || pathToken == wxT(
"m" ) )
3388 long px = 0, py = 0;
3390 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
3391 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
3393 currentPt = isRelative ? symRelPt( px, py ) : symAbsPt( px, py );
3394 startPt = currentPt;
3396 if( polyPts.empty() )
3397 polyPts.push_back( currentPt );
3400 else if( pathToken == wxT(
"L" ) || pathToken == wxT(
"l" ) )
3402 long px = 0, py = 0;
3404 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
3405 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
3407 currentPt = isRelative ? symRelPt( px, py ) : symAbsPt( px, py );
3408 polyPts.push_back( currentPt );
3411 else if( pathToken == wxT(
"C" ) || pathToken == wxT(
"c" ) )
3413 long cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, px = 0, py = 0;
3415 if( pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx1 )
3416 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy1 )
3417 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cx2 )
3418 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &cy2 )
3419 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &px )
3420 && pathTok.HasMoreTokens() && pathTok.GetNextToken().ToLong( &py ) )
3424 VECTOR2I cp1 = isRelative ? symRelPt( cx1, cy1 ) : symAbsPt( cx1, cy1 );
3425 VECTOR2I cp2 = isRelative ? symRelPt( cx2, cy2 ) : symAbsPt( cx2, cy2 );
3426 VECTOR2I endPt = isRelative ? symRelPt( px, py ) : symAbsPt( px, py );
3445 polyPts.push_back( currentPt );
3448 else if( pathToken == wxT(
"Z" ) || pathToken == wxT(
"z" ) )
3450 if( currentPt != startPt )
3452 polyPts.push_back( startPt );
3453 currentPt = startPt;
3476 size_t m = a.length();
3477 size_t n = b.length();
3479 std::vector<int> prev( n + 1 );
3480 std::vector<int> curr( n + 1 );
3482 for(
size_t j = 0; j <= n; ++j )
3483 prev[j] =
static_cast<int>( j );
3485 for(
size_t i = 1; i <= m; ++i )
3487 curr[0] =
static_cast<int>( i );
3489 for(
size_t j = 1; j <= n; ++j )
3491 int cost = ( a[i - 1] == b[j - 1] ) ? 0 : 1;
3492 curr[j] = std::min( { prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost } );
3495 std::swap( prev, curr );
3505 auto it = builtins.find( aBasename );
3507 if( it == builtins.end() )
3510 wxString tempPath = wxFileName::CreateTempFileName( wxT(
"geda_sym_" ) );
3512 if( tempPath.IsEmpty() )
3516 wxFile temp( tempPath, wxFile::write );
3518 if( !temp.IsOpened() || !temp.Write( it->second ) )
3520 wxRemoveFile( tempPath );
3527 wxRemoveFile( tempPath );
3531 wxString symName = aBasename;
3533 if( symName.EndsWith( wxT(
".sym" ) ) )
3534 symName = symName.Left( symName.length() - 4 );
3536 result->SetName( symName );
3538 if( !netAttr.IsEmpty() )
3555 return it->second.get();
3564 if( !cacheIt->second.symbol )
3567 &cacheIt->second.symversion,
3568 &cacheIt->second.netAttr );
3573 if( cacheIt->second.symbol && cacheIt->second.netAttr.IsEmpty() )
3576 auto builtinIt = builtins.find( aBasename );
3578 if( builtinIt != builtins.end() )
3582 const wxString& src = builtinIt->second;
3583 int pos = src.Find( wxT(
"\nnet=" ) );
3585 if( pos != wxNOT_FOUND )
3587 wxString rest = src.Mid( pos + 5 );
3588 int eol = rest.Find(
'\n' );
3590 cacheIt->second.netAttr = ( eol != wxNOT_FOUND )
3591 ? rest.Left( eol ).Trim()
3598 if( cacheIt->second.symbol )
3600 m_libSymbols[aBasename] = std::make_unique<LIB_SYMBOL>( *cacheIt->second.symbol );
3619 wxString suggestion;
3620 int bestDist = INT_MAX;
3626 if( dist < bestDist && dist <= 3 )
3638 if( dist < bestDist && dist <= 3 )
3645 wxString msg = wxString::Format(
_(
"Symbol '%s' not found in gEDA libraries." ),
3648 if( !suggestion.IsEmpty() )
3649 msg += wxString::Format(
_(
" Did you mean '%s'?" ), suggestion );
3660 wxString symName = aBasename;
3662 if( symName.EndsWith( wxT(
".sym" ) ) )
3663 symName = symName.Left( symName.length() - 4 );
3665 auto libSymbol = std::make_unique<LIB_SYMBOL>( symName );
3666 libSymbol->SetShowPinNumbers(
true );
3667 libSymbol->SetShowPinNames(
true );
3675 libSymbol->AddDrawItem( rect );
3696 bool isNoConnect =
m_pendingComp->basename.StartsWith( wxT(
"nc-" ) )
3697 && ncValue == wxT(
"NoConnection" );
3707 const std::vector<SCH_PIN*>& pins = ncSym->
GetPins();
3711 VECTOR2I pinPos = pins[0]->GetPosition();
3723 case 90: rx = -pinLocalY; ry = pinLocalX;
break;
3724 case 180: rx = -pinLocalX; ry = -pinLocalY;
break;
3725 case 270: rx = pinLocalY; ry = -pinLocalX;
break;
3744 if( !sourceAttr.IsEmpty() && sourceAttr.EndsWith( wxT(
".sch" ) ) )
3781 symSymver = cacheIt->second.symversion;
3783 if( !symSymver.IsEmpty() )
3787 compSymver.BeforeFirst(
'.' ).ToLong( &compMajor );
3788 symSymver.BeforeFirst(
'.' ).ToLong( &symMajor );
3790 if( compMajor != symMajor )
3793 wxString label = refdes.IsEmpty() ?
m_pendingComp->basename : refdes;
3796 wxString::Format(
_(
"Symbol version mismatch for '%s' (%s): "
3797 "schematic has symversion %s, "
3798 "library symbol has symversion %s." ),
3800 compSymver, symSymver ),
3809 wxString symNetAttr;
3813 symNetAttr = cacheEntry->second.netAttr;
3815 bool isPowerSym = !symNetAttr.IsEmpty();
3816 wxString powerNetName;
3817 std::unique_ptr<LIB_SYMBOL> powerCopy;
3824 wxString effectiveNet = schematicNet.IsEmpty() ? symNetAttr : schematicNet;
3826 int colonPos = effectiveNet.Find(
':' );
3828 if( colonPos != wxNOT_FOUND )
3829 powerNetName = effectiveNet.Left( colonPos );
3831 powerNetName = effectiveNet;
3835 powerCopy = std::make_unique<LIB_SYMBOL>( *libSym );
3836 libSym = powerCopy.get();
3848 pin->SetName( powerNetName );
3856 auto symbol = std::make_unique<SCH_SYMBOL>( *libSym, libId, &
m_schematic->CurrentSheet(),
3860 symbol->SetOrientation( orient );
3864 wxString pwrRef = wxString::Format( wxT(
"#PWR%04d" ), ++
m_powerCounter );
3865 symbol->SetRef( &
m_schematic->CurrentSheet(), pwrRef );
3875 if( graphicalAttr == wxT(
"1" ) )
3877 symbol->SetExcludedFromBOM(
true );
3878 symbol->SetExcludedFromBoard(
true );
3879 symbol->SetExcludedFromSim(
true );
3886 if( !isPowerSym && !refdes.IsEmpty() )
3888 symbol->SetRef( &
m_schematic->CurrentSheet(), refdes );
3903 if( !isPowerSym && !value.IsEmpty() )
3918 if( !footprint.IsEmpty() )
3919 symbol->SetFootprintFieldText( footprint );
3924 if( !documentation.IsEmpty() )
3927 dsField->
SetText( documentation );
3933 if( descAttr && !descAttr->
value.IsEmpty() )
3953 if( attr.
name == wxT(
"net" ) )
3955 int colonPos = attr.
value.Find(
':' );
3957 if( colonPos != wxNOT_FOUND )
3962 rec.
symbol = symbol.get();
3972 if( attr.
name == wxT(
"refdes" ) || attr.
name == wxT(
"value" )
3973 || attr.
name == wxT(
"footprint" ) || attr.
name == wxT(
"net" )
3974 || attr.
name == wxT(
"device" ) || attr.
name == wxT(
"symversion" )
3975 || attr.
name == wxT(
"documentation" ) || attr.
name == wxT(
"description" )
3976 || attr.
name == wxT(
"graphical" )
3977 || attr.
name == wxT(
"slot" ) || attr.
name == wxT(
"numslots" )
3978 || attr.
name == wxT(
"slotdef" ) )
3994 VECTOR2I pinPos = symbol->GetPinPhysicalPosition(
pin );
4000 symbol->SetLibSymbol(
new LIB_SYMBOL( *libSym ) );
4009 if( !slotStr.IsEmpty() && slotStr.ToLong( &slotNum ) && slotNum > 0 )
4011 wxString targetSlotDef;
4015 if( attr.
name != wxT(
"slotdef" ) )
4018 int colonPos = attr.
value.Find(
':' );
4020 if( colonPos == wxNOT_FOUND )
4025 if( attr.
value.Left( colonPos ).ToLong( &defSlot ) && defSlot == slotNum )
4027 targetSlotDef = attr.
value.Mid( colonPos + 1 );
4032 if( !targetSlotDef.IsEmpty() )
4034 wxArrayString slotPins;
4035 wxStringTokenizer slotTok( targetSlotDef, wxT(
"," ) );
4037 while( slotTok.HasMoreTokens() )
4038 slotPins.Add( slotTok.GetNextToken() );
4040 LIB_SYMBOL* privateSym = symbol->GetLibSymbolRef().get();
4044 std::map<long, SCH_PIN*> pinsBySeq;
4049 pinsBySeq[autoSeq] =
pin;
4053 for(
size_t i = 0; i < slotPins.size() && i < pinsBySeq.size(); i++ )
4055 auto seqIt = pinsBySeq.find(
static_cast<long>( i + 1 ) );
4057 if( seqIt != pinsBySeq.end() )
4058 seqIt->second->SetNumber( slotPins[i].Trim() );
4063 m_screen->Append( symbol.release() );
4074 wxFileName sourceFileName( aSourceFile );
4077 if( !sourceFileName.IsAbsolute() )
4078 sourceFileName.SetPath(
m_filename.GetPath() );
4080 wxString fullPath = sourceFileName.GetFullPath();
4082 if( !wxFileExists( fullPath ) )
4087 wxString::Format(
_(
"Hierarchical source '%s' not found, "
4088 "creating empty sheet." ),
4099 wxString::Format(
_(
"Circular hierarchy detected for '%s', skipping." ),
4112 auto sheet = std::make_unique<SCH_SHEET>(
m_rootSheet, pos, sheetSize );
4116 if( !refdes.IsEmpty() )
4123 sourceFileName.GetName() );
4127 sheet->SetFileName( aSourceFile );
4130 m_screen->Append( sheet.release() );
4132 if( wxFileExists( fullPath ) )
4170 const LIB_SYMBOL* libSym = rec.symbol->GetLibSymbolRef().get();
4178 if(
pin->GetNumber() == rec.pinnumber )
4180 VECTOR2I pinPos = rec.symbol->GetPinPhysicalPosition(
pin );
4182 auto label = std::make_unique<SCH_GLOBALLABEL>( pinPos, rec.netname );
4184 label->SetTextSize(
VECTOR2I( textSize, textSize ) );
4191 switch(
pin->GetOrientation() )
4197 default: pinDir =
VECTOR2I( 1, 0 );
break;
4200 VECTOR2I worldDir = rec.symbol->GetTransform().TransformCoordinate( pinDir );
4214 m_screen->Append( label.release() );
4225 std::vector<std::pair<VECTOR2I, VECTOR2I>> wireSegs;
4226 std::set<std::pair<int, int>> junctionPts;
4245 junctionPts.insert( { pos.first, pos.second } );
4253 if( junctionPts.count( pos ) )
4258 for(
const auto& [segStart, segEnd] : wireSegs )
4260 if( pt == segStart || pt == segEnd )
4263 bool isHorizontal = ( segStart.y == segEnd.y );
4264 bool isVertical = ( segStart.x == segEnd.x );
4266 if( !isHorizontal && !isVertical )
4271 if( isHorizontal && pt.
y == segStart.y )
4273 int minX = std::min( segStart.x, segEnd.x );
4274 int maxX = std::max( segStart.x, segEnd.x );
4275 onSeg = ( pt.
x > minX && pt.
x < maxX );
4277 else if( isVertical && pt.
x == segStart.x )
4279 int minY = std::min( segStart.y, segEnd.y );
4280 int maxY = std::max( segStart.y, segEnd.y );
4281 onSeg = ( pt.
y > minY && pt.
y < maxY );
4286 junctionPts.insert( pos );
4292 for(
const auto& [gX, gY] : junctionPts )
4295 m_screen->Append( std::make_unique<SCH_JUNCTION>( kicadPos ).release() );
4306 std::vector<std::pair<VECTOR2I, SCH_LINE*>> wireEndpoints;
4319 wireEndpoints.emplace_back( wire->
GetEndPoint(), wire );
4326 bool busIsHorizontal = ( bus.start.y == bus.end.y );
4327 bool busIsVertical = ( bus.start.x == bus.end.x );
4329 if( !busIsHorizontal && !busIsVertical )
4332 for(
const auto& [pt, wire] : wireEndpoints )
4336 if( busIsHorizontal )
4338 int minX = std::min( bus.start.x, bus.end.x );
4339 int maxX = std::max( bus.start.x, bus.end.x );
4340 onBus = ( pt.y == bus.start.y && pt.x >= minX && pt.x <= maxX );
4344 int minY = std::min( bus.start.y, bus.end.y );
4345 int maxY = std::max( bus.start.y, bus.end.y );
4346 onBus = ( pt.x == bus.start.x && pt.y >= minY && pt.y <= maxY );
4353 VECTOR2I otherEnd = ( wire->GetStartPoint() == pt ) ? wire->GetEndPoint()
4354 : wire->GetStartPoint();
4358 if( busIsHorizontal )
4360 dy = ( otherEnd.
y < pt.y ) ? -entrySize : entrySize;
4361 int sign = bus.ripperDir;
4366 int busMidX = ( bus.start.x + bus.end.x ) / 2;
4367 sign = ( pt.x <= busMidX ) ? 1 : -1;
4370 dx =
sign * entrySize;
4374 dx = ( otherEnd.
x < pt.x ) ? -entrySize : entrySize;
4375 int sign = bus.ripperDir;
4379 int busMidY = ( bus.start.y + bus.end.y ) / 2;
4380 sign = ( pt.y <= busMidY ) ? 1 : -1;
4383 dy =
sign * entrySize;
4387 auto entry = std::make_unique<SCH_BUS_WIRE_ENTRY>( pt );
4388 entry->SetSize(
VECTOR2I( dx, dy ) );
4393 if( wire->GetStartPoint() == pt )
4394 wire->SetStartPoint( entryTip );
4396 wire->SetEndPoint( entryTip );
4398 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 ) )
4557 if( file.GetLineCount() == 0 )
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 );
4712 THROW_IO_ERRORF(
_(
"File '%s' is not a valid gEDA schematic." ), aFileName );
4715 while( lineIdx < file.GetLineCount() )
4717 wxString line = file.GetLine( lineIdx );
4720 if( line.IsEmpty() )
4723 wxChar type = line[0];
4777 while( lineIdx < file.GetLineCount() )
4779 if( file.GetLine( lineIdx ).Trim() == wxT(
"}" ) )
4808 auto it = aProperties->find(
"additional_schematics" );
4810 if( it != aProperties->end() )
4812 wxString additionalFiles = wxString::FromUTF8( it->second.c_str() );
4813 wxStringTokenizer tok( additionalFiles, wxT(
";" ) );
4815 int sheetSpacing =
schIUScale.MilsToIU( 2000 );
4818 while( tok.HasMoreTokens() )
4820 wxString filePath = tok.GetNextToken();
4821 wxFileName fn( filePath );
4826 auto subSheet = std::make_unique<SCH_SHEET>(
m_rootSheet, pos, size );
4829 wxString::Format( wxT(
"Page %d" ), pageNum ) );
4831 subSheet->SetFileName( fn.GetFullName() );
4833 SCH_SHEET* subSheetPtr = subSheet.get();
4834 m_screen->Append( subSheet.release() );
4836 if( fn.FileExists() )
4848 copy.path = entry.path;
4849 copy.symversion = entry.symversion;
4850 copy.netAttr = entry.netAttr;
4859 subSheetPtr,
nullptr );
4866 wxString::Format(
_(
"Failed to load page '%s': %s" ),
4867 fn.GetFullName(), e.
What() ),
4873 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
virtual void SetEnd(const VECTOR2I &aEnd)
void SetCenter(const VECTOR2I &aCenter)
virtual void SetBezierC2(const VECTOR2I &aPt)
virtual void SetBezierC1(const VECTOR2I &aPt)
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
void SetFillMode(FILL_T aFill)
virtual void SetStart(const VECTOR2I &aStart)
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual void SetVisible(bool aVisible)
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
virtual void SetReporter(REPORTER *aReporter)
Set an optional reporter for warnings/errors.
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.
#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_ERRORF(msg,...)
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.