KiCad PCB EDA Suite
Loading...
Searching...
No Matches
specctra.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef SPECCTRA_H_
26#define SPECCTRA_H_
27
28
29// see http://www.boost.org/libs/ptr_container/doc/ptr_sequence_adapter.html
30#include <boost/ptr_container/ptr_vector.hpp>
31
32// see http://www.boost.org/libs/ptr_container/doc/ptr_set.html
33#include <boost/ptr_container/ptr_set.hpp>
34
35#include <specctra_import_export/specctra_lexer.h>
36
37#include <memory>
39
40// all outside the DSN namespace:
41class BOARD;
42class PCB_TRACK;
43class PCB_ARC;
44class PCB_VIA;
45class NETCLASS;
46class FOOTPRINT;
47class SHAPE_POLY_SET;
48
49typedef DSN::T DSN_T;
50
51
74namespace DSN {
75
76
77class SPECCTRA_DB;
78
79
85void ExportBoardToSpecctraFile( BOARD* aBoard, const wxString& aFullFilename );
86
87
94const char* GetTokenText( T aTok );
95
96
102struct POINT
103{
104 double x;
105 double y;
106
107 POINT() { x=0.0; y=0.0; }
108
109 POINT( double aX, double aY ) :
110 x(aX), y(aY)
111 {
112 }
113
114 bool operator==( const POINT& other ) const
115 {
116 return x==other.x && y==other.y;
117 }
118
119 bool operator!=( const POINT& other ) const
120 {
121 return !( *this == other );
122 }
123
124 POINT& operator+=( const POINT& other )
125 {
126 x += other.x;
127 y += other.y;
128 return *this;
129 }
130
131 POINT& operator=( const POINT& other )
132 {
133 x = other.x;
134 y = other.y;
135 return *this;
136 }
137
145 {
146 if( x == -0.0 )
147 x = 0.0;
148
149 if( y == -0.0 )
150 y = 0.0;
151 }
152
160 void Format( OUTPUTFORMATTER* out, int nestLevel ) const
161 {
162 out->Print( nestLevel, " %.6g %.6g", x, y );
163 }
164};
165
166typedef std::vector<std::string> STRINGS;
167typedef std::vector<POINT> POINTS;
168
170{
171 std::string name;
172 std::string value;
173
181 void Format( OUTPUTFORMATTER* out, int nestLevel ) const
182 {
183 const char* quoteName = out->GetQuoteChar( name.c_str() );
184 const char* quoteValue = out->GetQuoteChar( value.c_str() );
185
186 out->Print( nestLevel, "(%s%s%s %s%s%s)\n",
187 quoteName, name.c_str(), quoteName,
188 quoteValue, value.c_str(), quoteValue );
189 }
190};
191
192typedef std::vector<PROPERTY> PROPERTIES;
193
194
195class UNIT_RES;
196
202class ELEM
203{
204public:
205
206 ELEM( DSN_T aType, ELEM* aParent = nullptr );
207
208 virtual ~ELEM();
209
210 DSN_T Type() const { return type; }
211
212 const char* Name() const;
213
214
222 virtual UNIT_RES* GetUnits() const;
223
231 virtual void Format( OUTPUTFORMATTER* out, int nestLevel );
232
242 virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel )
243 {
244 // overridden in ELEM_HOLDER
245 }
246
247 void SetParent( ELEM* aParent )
248 {
249 parent = aParent;
250 }
251
252protected:
253
263 std::string makeHash()
264 {
265 sf.Clear();
266 FormatContents( &sf, 0 );
268
269 return sf.GetString();
270 }
271
272 // avoid creating this for every compare, make static.
274
277
278private:
279 friend class SPECCTRA_DB;
280};
281
282
288class ELEM_HOLDER : public ELEM
289{
290public:
291
292 ELEM_HOLDER( DSN_T aType, ELEM* aParent = nullptr ) :
293 ELEM( aType, aParent )
294 {
295 }
296
297 virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override;
298
299
300 //-----< list operations >--------------------------------------------
301
309 int FindElem( DSN_T aType, int instanceNum = 0 );
310
311
317 int Length() const
318 {
319 return kids.size();
320 }
321
322 void Append( ELEM* aElem )
323 {
324 kids.push_back( aElem );
325 }
326
327 ELEM* Replace( int aIndex, ELEM* aElem )
328 {
329 ELEM_ARRAY::auto_type ret = kids.replace( aIndex, aElem );
330 return ret.release();
331 }
332
333 ELEM* Remove( int aIndex )
334 {
335 ELEM_ARRAY::auto_type ret = kids.release( kids.begin() + aIndex );
336 return ret.release();
337 }
338
339 void Insert( int aIndex, ELEM* aElem ) { kids.insert( kids.begin() + aIndex, aElem ); }
340
341 ELEM* At( int aIndex ) const
342 {
343 // we have varying sized objects and are using polymorphism, so we
344 // must return a pointer not a reference.
345 return (ELEM*) &kids[aIndex];
346 }
347
348 ELEM* operator[]( int aIndex ) const
349 {
350 return At( aIndex );
351 }
352
353 void Delete( int aIndex ) { kids.erase( kids.begin() + aIndex ); }
354
355private:
356 friend class SPECCTRA_DB;
357
358 typedef boost::ptr_vector<ELEM> ELEM_ARRAY;
359
361};
362
363
369class PARSER : public ELEM
370{
371public:
372
373 PARSER( ELEM* aParent );
374
375 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override;
376
377private:
378 friend class SPECCTRA_DB;
379
389
392
393 std::string host_cad;
394 std::string host_version;
395};
396
397
402class UNIT_RES : public ELEM
403{
404public:
405
411
412 UNIT_RES( ELEM* aParent, DSN_T aType ) :
413 ELEM( aType, aParent )
414 {
415 units = T_inch;
416 value = 2540000;
417 }
418
419 DSN_T GetEngUnits() const { return units; }
420 int GetValue() const { return value; }
421
422 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
423 {
424 if( type == T_unit )
425 out->Print( nestLevel, "(%s %s)\n", Name(), GetTokenText( units ) );
426 else // T_resolution
427 out->Print( nestLevel, "(%s %s %d)\n", Name(), GetTokenText( units ), value );
428 }
429
430private:
431 friend class SPECCTRA_DB;
432
434 int value;
435};
436
437
438class RECTANGLE : public ELEM
439{
440public:
441
442 RECTANGLE( ELEM* aParent ) :
443 ELEM( T_rect, aParent )
444 {
445 }
446
447 void SetLayerId( std::string& aLayerId )
448 {
449 layer_id = aLayerId;
450 }
451
452 void SetCorners( const POINT& aPoint0, const POINT& aPoint1 )
453 {
454 point0 = aPoint0;
456
457 point1 = aPoint1;
459 }
460
461 POINT GetOrigin() { return point0; }
462 POINT GetEnd() { return point1; }
463
464 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
465 {
466 const char* newline = nestLevel ? "\n" : "";
467
468 const char* quote = out->GetQuoteChar( layer_id.c_str() );
469
470 out->Print( nestLevel, "(%s %s%s%s %.6g %.6g %.6g %.6g)%s",
471 Name(),
472 quote, layer_id.c_str(), quote,
473 point0.x, point0.y,
474 point1.x, point1.y,
475 newline );
476 }
477
478private:
479 friend class SPECCTRA_DB;
480
481 std::string layer_id;
482
485};
486
487
491class RULE : public ELEM
492{
493public:
494
495 RULE( ELEM* aParent, DSN_T aType ) :
496 ELEM( aType, aParent )
497 {
498 }
499
500 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
501 {
502 out->Print( nestLevel, "(%s", Name() );
503
504 bool singleLine;
505
506 if( m_rules.size() == 1 )
507 {
508 singleLine = true;
509 out->Print( 0, " %s)", m_rules.begin()->c_str() );
510 }
511
512 else
513 {
514 out->Print( 0, "\n" );
515 singleLine = false;
516
517 for( STRINGS::const_iterator i = m_rules.begin(); i != m_rules.end(); ++i )
518 out->Print( nestLevel+1, "%s\n", i->c_str() );
519
520 out->Print( nestLevel, ")" );
521 }
522
523 if( nestLevel || !singleLine )
524 out->Print( 0, "\n" );
525 }
526
527private:
528 friend class SPECCTRA_DB;
529
531};
532
533
534class LAYER_RULE : public ELEM
535{
536public:
537
538 LAYER_RULE( ELEM* aParent ) :
539 ELEM( T_layer_rule, aParent )
540 {
541 m_rule = nullptr;
542 }
543
545 {
546 delete m_rule;
547 }
548
549 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
550 {
551 out->Print( nestLevel, "(%s", Name() );
552
553 for( STRINGS::const_iterator i = m_layer_ids.begin(); i != m_layer_ids.end(); ++i )
554 {
555 const char* quote = out->GetQuoteChar( i->c_str() );
556 out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
557 }
558
559 out->Print( 0 , "\n" );
560
561 if( m_rule )
562 m_rule->Format( out, nestLevel+1 );
563
564 out->Print( nestLevel, ")\n" );
565 }
566
567private:
568 friend class SPECCTRA_DB;
569
572};
573
574
575typedef boost::ptr_vector<LAYER_RULE> LAYER_RULES;
576
577
582class PATH : public ELEM
583{
584public:
585
586 PATH( ELEM* aParent, DSN_T aType = T_path ) :
587 ELEM( aType, aParent )
588 {
589 aperture_width = 0.0;
590 aperture_type = T_round;
591 }
592
593 void AppendPoint( const POINT& aPoint )
594 {
595 points.push_back( aPoint );
596 }
597
598 POINTS& GetPoints() {return points; }
599
600 void SetLayerId( const std::string& aLayerId )
601 {
602 layer_id = aLayerId;
603 }
604
605 void SetAperture( double aWidth )
606 {
607 aperture_width = aWidth;
608 }
609
610 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
611 {
612 const char* newline = nestLevel ? "\n" : "";
613
614 const char* quote = out->GetQuoteChar( layer_id.c_str() );
615
616 const int RIGHTMARGIN = 70;
617 int perLine = out->Print( nestLevel, "(%s %s%s%s %.6g",
618 Name(),
619 quote, layer_id.c_str(), quote,
621
622 int wrapNest = std::max( nestLevel+1, 6 );
623
624 for( unsigned i = 0; i < points.size(); ++i )
625 {
626 if( perLine > RIGHTMARGIN )
627 {
628 out->Print( 0, "\n" );
629 perLine = out->Print( wrapNest, "%s", "" );
630 }
631 else
632 {
633 perLine += out->Print( 0, " " );
634 }
635
636 perLine += out->Print( 0, "%.6g %.6g", points[i].x, points[i].y );
637 }
638
639 if( aperture_type == T_square )
640 {
641 out->Print( 0, "(aperture_type square)" );
642 }
643
644 out->Print( 0, ")%s", newline );
645 }
646
647private:
648 friend class SPECCTRA_DB;
649
650 std::string layer_id;
652
655};
656
657typedef boost::ptr_vector<PATH> PATHS;
658
659
660class BOUNDARY : public ELEM
661{
662public:
663
664 BOUNDARY( ELEM* aParent, DSN_T aType = T_boundary ) :
665 ELEM( aType, aParent )
666 {
667 rectangle = nullptr;
668 }
669
671 {
672 delete rectangle;
673 }
674
678 void GetCorners( std::vector<double>& aBuffer )
679 {
680 if( rectangle )
681 {
682 aBuffer.push_back( rectangle->GetOrigin().x );
683 aBuffer.push_back( rectangle->GetOrigin().y );
684
685 aBuffer.push_back( rectangle->GetOrigin().x );
686 aBuffer.push_back( rectangle->GetEnd().y );
687
688 aBuffer.push_back( rectangle->GetEnd().x );
689 aBuffer.push_back( rectangle->GetEnd().y );
690
691 aBuffer.push_back( rectangle->GetEnd().x );
692 aBuffer.push_back( rectangle->GetOrigin().y );
693 }
694 else
695 {
696 for( PATHS::iterator i=paths.begin(); i!=paths.end(); ++i )
697 {
698 POINTS& plist = i->GetPoints();
699
700 for( unsigned jj = 0; jj < plist.size(); jj++ )
701 {
702 aBuffer.push_back( plist[jj].x );
703 aBuffer.push_back( plist[jj].y );
704 }
705 }
706 }
707 }
708
709
710 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
711 {
712 out->Print( nestLevel, "(%s\n", Name() );
713
714 if( rectangle )
715 rectangle->Format( out, nestLevel+1 );
716 else
717 {
718 for( PATHS::iterator i = paths.begin(); i != paths.end(); ++i )
719 i->Format( out, nestLevel+1 );
720 }
721
722 out->Print( nestLevel, ")\n" );
723 }
724
725private:
726 friend class SPECCTRA_DB;
727
728 // only one or the other of these two is used, not both
731};
732
733
734class CIRCLE : public ELEM
735{
736public:
737 CIRCLE( ELEM* aParent ) :
738 ELEM( T_circle, aParent )
739 {
740 diameter = 0.0;
741 }
742
743 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
744 {
745 const char* newline = nestLevel ? "\n" : "";
746
747 const char* quote = out->GetQuoteChar( layer_id.c_str() );
748 out->Print( nestLevel, "(%s %s%s%s %.6g", Name(), quote, layer_id.c_str(), quote,
749 diameter );
750
751 if( vertex.x!=0.0 || vertex.y!=0.0 )
752 out->Print( 0, " %.6g %.6g)%s", vertex.x, vertex.y, newline );
753 else
754 out->Print( 0, ")%s", newline );
755 }
756
757 void SetLayerId( const std::string& aLayerId )
758 {
759 layer_id = aLayerId;
760 }
761
762 void SetDiameter( double aDiameter )
763 {
764 diameter = aDiameter;
765 }
766
767 void SetVertex( const POINT& aVertex )
768 {
769 vertex = aVertex;
770 }
771
772private:
773 friend class SPECCTRA_DB;
774
775 std::string layer_id;
776
777 double diameter;
778 POINT vertex; // POINT's constructor sets to (0,0)
779};
780
781
782class QARC : public ELEM
783{
784public:
785 QARC( ELEM* aParent ) :
786 ELEM( T_qarc, aParent )
787 {
788 aperture_width = 0.0;
789 }
790
791 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
792 {
793 const char* newline = nestLevel ? "\n" : "";
794
795 const char* quote = out->GetQuoteChar( layer_id.c_str() );
796 out->Print( nestLevel, "(%s %s%s%s %.6g", Name(), quote, layer_id.c_str(), quote,
798
799 for( int i=0; i<3; ++i )
800 out->Print( 0, " %.6g %.6g", vertex[i].x, vertex[i].y );
801
802 out->Print( 0, ")%s", newline );
803 }
804
805 void SetLayerId( std::string& aLayerId )
806 {
807 layer_id = aLayerId;
808 }
809
810 void SetStart( const POINT& aStart )
811 {
812 vertex[0] = aStart;
813
814 // no -0.0 on the printouts!
816 }
817
818 void SetEnd( const POINT& aEnd )
819 {
820 vertex[1] = aEnd;
821
822 // no -0.0 on the printouts!
824 }
825
826 void SetCenter( const POINT& aCenter )
827 {
828 vertex[2] = aCenter;
829
830 // no -0.0 on the printouts!
832 }
833
834private:
835 friend class SPECCTRA_DB;
836
837 std::string layer_id;
840};
841
842
843class WINDOW : public ELEM
844{
845public:
846
847 WINDOW( ELEM* aParent, DSN_T aType = T_window ) :
848 ELEM( aType, aParent )
849 {
850 shape = nullptr;
851 }
852
854 {
855 delete shape;
856 }
857
858 void SetShape( ELEM* aShape )
859 {
860 delete shape;
861 shape = aShape;
862
863 if( aShape )
864 {
865 wxASSERT( aShape->Type()==T_rect
866 || aShape->Type()==T_circle
867 || aShape->Type()==T_qarc
868 || aShape->Type()==T_path
869 || aShape->Type()==T_polygon);
870
871 aShape->SetParent( this );
872 }
873 }
874
875 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
876 {
877 out->Print( nestLevel, "(%s ", Name() );
878
879 if( shape )
880 shape->Format( out, 0 );
881
882 out->Print( 0, ")\n" );
883 }
884
885protected:
886 /* <shape_descriptor >::=
887 [<rectangle_descriptor> |
888 <circle_descriptor> |
889 <polygon_descriptor> |
890 <path_descriptor> |
891 <qarc_descriptor> ]
892 */
894
895private:
896 friend class SPECCTRA_DB;
897};
898
899typedef boost::ptr_vector<WINDOW> WINDOWS;
900
901
905class KEEPOUT : public ELEM
906{
907public:
908
913 KEEPOUT( ELEM* aParent, DSN_T aType ) :
914 ELEM( aType, aParent )
915 {
916 m_rules = nullptr;
917 m_place_rules = nullptr;
918 m_shape = nullptr;
919
921 }
922
924 {
925 delete m_rules;
926 delete m_place_rules;
927 delete m_shape;
928 }
929
930 void SetShape( ELEM* aShape )
931 {
932 delete m_shape;
933 m_shape = aShape;
934
935 if( aShape )
936 {
937 wxASSERT( aShape->Type()==T_rect
938 || aShape->Type()==T_circle
939 || aShape->Type()==T_qarc
940 || aShape->Type()==T_path
941 || aShape->Type()==T_polygon);
942
943 aShape->SetParent( this );
944 }
945 }
946
947 void AddWindow( WINDOW* aWindow )
948 {
949 aWindow->SetParent( this );
950 m_windows.push_back( aWindow );
951 }
952
953 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
954 {
955 const char* newline = "\n";
956
957 out->Print( nestLevel, "(%s", Name() );
958
959 if( m_name.size() )
960 {
961 const char* quote = out->GetQuoteChar( m_name.c_str() );
962 out->Print( 0, " %s%s%s", quote, m_name.c_str(), quote );
963 }
964 // Could be not needed:
965#if 1
966 else
967 {
968 out->Print( 0, " \"\"" ); // the zone with no name or net_code == 0
969 }
970#endif
971
972 if( m_sequence_number != -1 )
973 out->Print( 0, " (sequence_number %d)", m_sequence_number );
974
975 if( m_shape )
976 {
977 out->Print( 0, " " );
978 m_shape->Format( out, 0 );
979 }
980
981 if( m_rules )
982 {
983 out->Print( 0, "%s", newline );
984 newline = "";
985 m_rules->Format( out, nestLevel+1 );
986 }
987
988 if( m_place_rules )
989 {
990 out->Print( 0, "%s", newline );
991 newline = "";
992 m_place_rules->Format( out, nestLevel+1 );
993 }
994
995 if( m_windows.size() )
996 {
997 out->Print( 0, "%s", newline );
998 newline = "";
999
1000 for( WINDOWS::iterator i = m_windows.begin(); i != m_windows.end(); ++i )
1001 i->Format( out, nestLevel+1 );
1002
1003 out->Print( nestLevel, ")\n" );
1004 }
1005 else
1006 {
1007 out->Print( 0, ")\n" );
1008 }
1009 }
1010
1011protected:
1012 std::string m_name;
1016
1018
1019 /* <shape_descriptor >::=
1020 [<rectangle_descriptor> |
1021 <circle_descriptor> |
1022 <polygon_descriptor> |
1023 <path_descriptor> |
1024 <qarc_descriptor> ]
1025 */
1027
1028private:
1029 friend class SPECCTRA_DB;
1030};
1031
1032typedef boost::ptr_vector<KEEPOUT> KEEPOUTS;
1033
1034
1038class VIA : public ELEM
1039{
1040public:
1041
1042 VIA( ELEM* aParent ) :
1043 ELEM( T_via, aParent )
1044 {
1045 }
1046
1047 void AppendVia( const char* aViaName )
1048 {
1049 m_padstacks.push_back( aViaName );
1050 }
1051
1052 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1053 {
1054 const int RIGHTMARGIN = 80;
1055 int perLine = out->Print( nestLevel, "(%s", Name() );
1056
1057 for( STRINGS::iterator i = m_padstacks.begin(); i != m_padstacks.end(); ++i )
1058 {
1059 if( perLine > RIGHTMARGIN )
1060 {
1061 out->Print( 0, "\n" );
1062 perLine = out->Print( nestLevel+1, "%s", "");
1063 }
1064
1065 const char* quote = out->GetQuoteChar( i->c_str() );
1066 perLine += out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
1067 }
1068
1069 if( m_spares.size() )
1070 {
1071 out->Print( 0, "\n" );
1072
1073 perLine = out->Print( nestLevel+1, "(spare" );
1074
1075 for( STRINGS::iterator i = m_spares.begin(); i != m_spares.end(); ++i )
1076 {
1077 if( perLine > RIGHTMARGIN )
1078 {
1079 out->Print( 0, "\n" );
1080 perLine = out->Print( nestLevel+2, "%s", "");
1081 }
1082
1083 const char* quote = out->GetQuoteChar( i->c_str() );
1084 perLine += out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
1085 }
1086
1087 out->Print( 0, ")" );
1088 }
1089
1090 out->Print( 0, ")\n" );
1091 }
1092
1093private:
1094 friend class SPECCTRA_DB;
1095
1098};
1099
1100
1101class CLASSES : public ELEM
1102{
1103public:
1104 CLASSES( ELEM* aParent ) :
1105 ELEM( T_classes, aParent )
1106 {
1107 }
1108
1109 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1110 {
1111 for( STRINGS::iterator i = class_ids.begin(); i != class_ids.end(); ++i )
1112 {
1113 const char* quote = out->GetQuoteChar( i->c_str() );
1114 out->Print( nestLevel, "%s%s%s\n", quote, i->c_str(), quote );
1115 }
1116 }
1117
1118private:
1119 friend class SPECCTRA_DB;
1120
1122};
1123
1124
1126{
1127public:
1128
1133 CLASS_CLASS( ELEM* aParent, DSN_T aType ) :
1134 ELEM_HOLDER( aType, aParent )
1135 {
1136 classes = nullptr;
1137 }
1138
1140 {
1141 delete classes;
1142 }
1143
1144 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1145 {
1146 if( classes )
1147 classes->Format( out, nestLevel );
1148
1149 // format the kids
1150 ELEM_HOLDER::FormatContents( out, nestLevel );
1151 }
1152
1153private:
1154 friend class SPECCTRA_DB;
1155
1157
1158 // rule | layer_rule are put into the kids container.
1159};
1160
1161
1162class CONTROL : public ELEM_HOLDER
1163{
1164public:
1165 CONTROL( ELEM* aParent ) :
1166 ELEM_HOLDER( T_control, aParent )
1167 {
1168 via_at_smd = false;
1169 via_at_smd_grid_on = false;
1170 }
1171
1173 {
1174 }
1175
1176 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1177 {
1178 out->Print( nestLevel, "(%s\n", Name() );
1179
1180 out->Print( nestLevel+1, "(via_at_smd %s", via_at_smd ? "on" : "off" );
1181
1182 if( via_at_smd_grid_on )
1183 out->Print( 0, " grid %s", via_at_smd_grid_on ? "on" : "off" );
1184
1185 out->Print( 0, ")\n" );
1186
1187 for( int i = 0; i < Length(); ++i )
1188 At(i)->Format( out, nestLevel+1 );
1189
1190 out->Print( nestLevel, ")\n" );
1191 }
1192
1193private:
1194 friend class SPECCTRA_DB;
1195
1198};
1199
1200
1201class LAYER : public ELEM
1202{
1203public:
1204 LAYER( ELEM* aParent ) :
1205 ELEM( T_layer, aParent )
1206 {
1207 layer_type = T_signal;
1208 direction = -1;
1209 cost = -1;
1210 cost_type = -1;
1211
1212 rules = nullptr;
1213 }
1214
1216 {
1217 delete rules;
1218 }
1219
1220 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1221 {
1222 const char* quote = out->GetQuoteChar( name.c_str() );
1223
1224 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, name.c_str(), quote );
1225
1226 out->Print( nestLevel+1, "(type %s)\n", GetTokenText( layer_type ) );
1227
1228 if( properties.size() )
1229 {
1230 out->Print( nestLevel+1, "(property\n" );
1231
1232 for( PROPERTIES::iterator i = properties.begin(); i != properties.end(); ++i )
1233 {
1234 i->Format( out, nestLevel+2 );
1235 }
1236 out->Print( nestLevel+1, ")\n" );
1237 }
1238
1239 if( direction != -1 )
1240 out->Print( nestLevel+1, "(direction %s)\n", GetTokenText( (DSN_T)direction ) );
1241
1242 if( rules )
1243 rules->Format( out, nestLevel+1 );
1244
1245 if( cost != -1 )
1246 {
1247 if( cost < 0 )
1248 // positive integer, stored as negative.
1249 out->Print( nestLevel+1, "(cost %d", -cost );
1250 else
1251 out->Print( nestLevel+1, "(cost %s", GetTokenText( (DSN_T)cost ) );
1252
1253 if( cost_type != -1 )
1254 out->Print( 0, " (type %s)", GetTokenText( (DSN_T)cost_type ) );
1255
1256 out->Print( 0, ")\n" );
1257 }
1258
1259 if( use_net.size() )
1260 {
1261 out->Print( nestLevel+1, "(use_net" );
1262
1263 for( STRINGS::const_iterator i = use_net.begin(); i != use_net.end(); ++i )
1264 {
1265 quote = out->GetQuoteChar( i->c_str() );
1266 out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
1267 }
1268
1269 out->Print( 0, ")\n" );
1270 }
1271
1272 out->Print( nestLevel, ")\n" );
1273 }
1274
1275private:
1276 friend class SPECCTRA_DB;
1277
1278 std::string name;
1281
1283 int cost;
1287
1289};
1290
1291typedef boost::ptr_vector<LAYER> LAYERS;
1292
1293
1295{
1296public:
1298 ELEM( T_layer_pair, aParent )
1299 {
1300 layer_weight = 0.0;
1301 }
1302
1303 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1304 {
1305 const char* quote0 = out->GetQuoteChar( layer_id0.c_str() );
1306 const char* quote1 = out->GetQuoteChar( layer_id1.c_str() );
1307
1308 out->Print( nestLevel, "(%s %s%s%s %s%s%s %.6g)\n", Name(), quote0, layer_id0.c_str(),
1309 quote0, quote1, layer_id1.c_str(), quote1, layer_weight );
1310 }
1311
1312private:
1313 friend class SPECCTRA_DB;
1314
1315 std::string layer_id0;
1316 std::string layer_id1;
1317
1319};
1320
1321typedef boost::ptr_vector<SPECCTRA_LAYER_PAIR> SPECCTRA_LAYER_PAIRS;
1322
1323
1325{
1326 friend class SPECCTRA_DB;
1327
1329
1330public:
1331
1333 ELEM( T_layer_noise_weight, aParent )
1334 {
1335 }
1336
1337 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1338 {
1339 out->Print( nestLevel, "(%s\n", Name() );
1340
1341 for( SPECCTRA_LAYER_PAIRS::iterator i = layer_pairs.begin(); i != layer_pairs.end(); ++i )
1342 i->Format( out, nestLevel+1 );
1343
1344 out->Print( nestLevel, ")\n" );
1345 }
1346};
1347
1348
1352class COPPER_PLANE : public KEEPOUT
1353{
1354public:
1355 COPPER_PLANE( ELEM* aParent ) :
1356 KEEPOUT( aParent, T_plane )
1357 {}
1358
1359private:
1360 friend class SPECCTRA_DB;
1361};
1362
1363typedef boost::ptr_vector<COPPER_PLANE> COPPER_PLANES;
1364
1365
1371class TOKPROP : public ELEM
1372{
1373public:
1374 TOKPROP( ELEM* aParent, DSN_T aType ) :
1375 ELEM( aType, aParent )
1376 {
1377 // Do not leave uninitialized members
1378 value = T_NONE;
1379 }
1380
1381 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1382 {
1383 out->Print( nestLevel, "(%s %s)\n", Name(), GetTokenText( value ) );
1384 }
1385
1386private:
1387 friend class SPECCTRA_DB;
1388
1390};
1391
1392
1398class STRINGPROP : public ELEM
1399{
1400public:
1401 STRINGPROP( ELEM* aParent, DSN_T aType ) :
1402 ELEM( aType, aParent )
1403 {
1404 }
1405
1406 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1407 {
1408 const char* quote = out->GetQuoteChar( value.c_str() );
1409
1410 out->Print( nestLevel, "(%s %s%s%s)\n",
1411 Name(),
1412 quote, value.c_str(), quote );
1413 }
1414
1415private:
1416 friend class SPECCTRA_DB;
1417
1418 std::string value;
1419};
1420
1421
1422class REGION : public ELEM_HOLDER
1423{
1424public:
1425 REGION( ELEM* aParent ) :
1426 ELEM_HOLDER( T_region, aParent )
1427 {
1428 m_rectangle = nullptr;
1429 m_polygon = nullptr;
1430 m_rules = nullptr;
1431 }
1432
1434 {
1435 delete m_rectangle;
1436 delete m_polygon;
1437 delete m_rules;
1438 }
1439
1440 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1441 {
1442 if( m_region_id.size() )
1443 {
1444 const char* quote = out->GetQuoteChar( m_region_id.c_str() );
1445 out->Print( nestLevel, "%s%s%s\n", quote, m_region_id.c_str(), quote );
1446 }
1447
1448 if( m_rectangle )
1449 m_rectangle->Format( out, nestLevel );
1450
1451 if( m_polygon )
1452 m_polygon->Format( out, nestLevel );
1453
1454 ELEM_HOLDER::FormatContents( out, nestLevel );
1455
1456 if( m_rules )
1457 m_rules->Format( out, nestLevel );
1458 }
1459
1460private:
1461 friend class SPECCTRA_DB;
1462
1463 std::string m_region_id;
1464
1465 //-----<mutually exclusive>--------------------------------------
1468 //-----</mutually exclusive>-------------------------------------
1469
1470 /* region_net | region_class | region_class_class are all mutually
1471 exclusive and are put into the kids container.
1472 */
1473
1475};
1476
1477
1478class GRID : public ELEM
1479{
1480public:
1481 GRID( ELEM* aParent ) :
1482 ELEM( T_grid, aParent )
1483 {
1484 m_grid_type = T_via;
1485 m_direction = T_NONE;
1486 m_dimension = 0.0;
1487 m_offset = 0.0;
1488 m_image_type = T_NONE;
1489 }
1490
1491 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1492 {
1493 out->Print( nestLevel, "(%s %s %.6g", Name(), GetTokenText( m_grid_type ), m_dimension );
1494
1495 if( m_grid_type == T_place )
1496 {
1497 if( m_image_type == T_smd || m_image_type == T_pin )
1498 out->Print( 0, " (image_type %s)", GetTokenText( m_image_type ) );
1499 }
1500 else
1501 {
1502 if( m_direction == T_x || m_direction == T_y )
1503 out->Print( 0, " (direction %s)", GetTokenText( m_direction ) );
1504 }
1505
1506 if( m_offset != 0.0 )
1507 out->Print( 0, " (offset %.6g)", m_offset );
1508
1509 out->Print( 0, ")\n");
1510 }
1511
1512private:
1513 friend class SPECCTRA_DB;
1514
1518 double m_offset;
1520};
1521
1522
1523class STRUCTURE_OUT : public ELEM
1524{
1525public:
1526 STRUCTURE_OUT( ELEM* aParent ) :
1527 ELEM( T_structure_out, aParent )
1528 {
1529 m_rules = nullptr;
1530 }
1531
1533 {
1534 delete m_rules;
1535 }
1536
1537 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1538 {
1539 for( LAYERS::iterator i = m_layers.begin(); i != m_layers.end(); ++i )
1540 i->Format( out, nestLevel );
1541
1542 if( m_rules )
1543 m_rules->Format( out, nestLevel );
1544 }
1545
1546private:
1547 friend class SPECCTRA_DB;
1548
1551};
1552
1553
1555{
1556public:
1557 STRUCTURE( ELEM* aParent ) :
1558 ELEM_HOLDER( T_structure, aParent )
1559 {
1560 m_unit = nullptr;
1561 m_layer_noise_weight = nullptr;
1562 m_boundary = nullptr;
1563 m_place_boundary = nullptr;
1564 m_via = nullptr;
1565 m_control = nullptr;
1566 m_rules = nullptr;
1567 m_place_rules = nullptr;
1568 }
1569
1571 {
1572 delete m_unit;
1573 delete m_layer_noise_weight;
1574 delete m_boundary;
1575 delete m_place_boundary;
1576 delete m_via;
1577 delete m_control;
1578 delete m_rules;
1579 delete m_place_rules;
1580 }
1581
1582 void SetBOUNDARY( BOUNDARY *aBoundary )
1583 {
1584 delete m_boundary;
1585 m_boundary = aBoundary;
1586
1587 if( m_boundary )
1588 m_boundary->SetParent( this );
1589 }
1590
1591 void SetPlaceBOUNDARY( BOUNDARY *aBoundary )
1592 {
1593 delete m_place_boundary;
1594 m_place_boundary = aBoundary;
1595
1596 if( m_place_boundary )
1597 m_place_boundary->SetParent( this );
1598 }
1599
1600 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1601 {
1602 if( m_unit )
1603 m_unit->Format( out, nestLevel );
1604
1605 for( LAYERS::iterator i=m_layers.begin(); i!=m_layers.end(); ++i )
1606 i->Format( out, nestLevel );
1607
1609 m_layer_noise_weight->Format( out, nestLevel );
1610
1611 if( m_boundary )
1612 m_boundary->Format( out, nestLevel );
1613
1614 if( m_place_boundary )
1615 m_place_boundary->Format( out, nestLevel );
1616
1617 for( COPPER_PLANES::iterator i=m_planes.begin(); i!=m_planes.end(); ++i )
1618 i->Format( out, nestLevel );
1619
1620 for( REGIONS::iterator i=m_regions.begin(); i!=m_regions.end(); ++i )
1621 i->Format( out, nestLevel );
1622
1623 for( KEEPOUTS::iterator i=m_keepouts.begin(); i!=m_keepouts.end(); ++i )
1624 i->Format( out, nestLevel );
1625
1626 if( m_via )
1627 m_via->Format( out, nestLevel );
1628
1629 if( m_control )
1630 m_control->Format( out, nestLevel );
1631
1632 for( int i=0; i<Length(); ++i )
1633 {
1634 At(i)->Format( out, nestLevel );
1635 }
1636
1637 if( m_rules )
1638 m_rules->Format( out, nestLevel );
1639
1640 if( m_place_rules )
1641 m_place_rules->Format( out, nestLevel );
1642
1643 for( GRIDS::iterator i=m_grids.begin(); i!=m_grids.end(); ++i )
1644 i->Format( out, nestLevel );
1645 }
1646
1647 UNIT_RES* GetUnits() const override
1648 {
1649 if( m_unit )
1650 return m_unit;
1651
1652 return ELEM::GetUnits();
1653 }
1654
1655private:
1656 friend class SPECCTRA_DB;
1657
1659
1661
1663
1669
1671
1673
1674 typedef boost::ptr_vector<REGION> REGIONS;
1676
1678
1679 typedef boost::ptr_vector<GRID> GRIDS;
1681};
1682
1683
1687class PLACE : public ELEM
1688{
1689public:
1690 PLACE( ELEM* aParent ) :
1691 ELEM( T_place, aParent )
1692 {
1693 m_side = T_front;
1694
1695 m_rotation = 0.0;
1696
1697 m_hasVertex = false;
1698
1699 m_mirror = T_NONE;
1700 m_status = T_NONE;
1701
1702 m_place_rules = nullptr;
1703
1704 m_lock_type = T_NONE;
1705 m_rules = nullptr;
1706 m_region = nullptr;
1707 }
1708
1710 {
1711 delete m_place_rules;
1712 delete m_rules;
1713 delete m_region;
1714 }
1715
1716 void SetVertex( const POINT& aVertex )
1717 {
1718 m_vertex = aVertex;
1720 m_hasVertex = true;
1721 }
1722
1723 void SetRotation( double aRotation )
1724 {
1725 m_rotation = aRotation;
1726 }
1727
1728 void Format( OUTPUTFORMATTER* out, int nestLevel ) override;
1729
1730private:
1731 friend class SPECCTRA_DB;
1732
1733 std::string m_component_id;
1734
1736
1738
1741
1744
1745 std::string m_logical_part;
1746
1748
1750
1752
1753 //-----<mutually exclusive>--------------
1756 //-----</mutually exclusive>-------------
1757
1758 std::string m_part_number;
1759};
1760
1761typedef boost::ptr_vector<PLACE> PLACES;
1762
1763
1767class COMPONENT : public ELEM
1768{
1769public:
1770 COMPONENT( ELEM* aParent ) :
1771 ELEM( T_component, aParent )
1772 {
1773 }
1774
1775 const std::string& GetImageId() const { return m_image_id; }
1776 void SetImageId( const std::string& aImageId )
1777 {
1778 m_image_id = aImageId;
1779 }
1780
1781
1785// static int Compare( IMAGE* lhs, IMAGE* rhs );
1786
1787 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1788 {
1789 const char* quote = out->GetQuoteChar( m_image_id.c_str() );
1790 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, m_image_id.c_str(), quote );
1791
1792 FormatContents( out, nestLevel+1 );
1793
1794 out->Print( nestLevel, ")\n" );
1795 }
1796
1797 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1798 {
1799 for( PLACES::iterator i=m_places.begin(); i!=m_places.end(); ++i )
1800 i->Format( out, nestLevel );
1801 }
1802
1803private:
1804 friend class SPECCTRA_DB;
1805
1806// std::string m_hash; ///< a hash string used by Compare(), not Format()ed/exported.
1807
1808 std::string m_image_id;
1810};
1811
1812typedef boost::ptr_vector<COMPONENT> COMPONENTS;
1813
1814
1815class PLACEMENT : public ELEM
1816{
1817public:
1818 PLACEMENT( ELEM* aParent ) :
1819 ELEM( T_placement, aParent )
1820 {
1821 m_unit = nullptr;
1822 m_flip_style = DSN_T( T_NONE );
1823 }
1824
1826 {
1827 delete m_unit;
1828 }
1829
1838 COMPONENT* LookupCOMPONENT( const std::string& imageName )
1839 {
1840 for( unsigned i = 0; i < m_components.size(); ++i )
1841 {
1842 if( 0 == m_components[i].GetImageId().compare( imageName ) )
1843 return &m_components[i];
1844 }
1845
1846 COMPONENT* added = new COMPONENT(this);
1847 m_components.push_back( added );
1848 added->SetImageId( imageName );
1849 return added;
1850 }
1851
1852 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1853 {
1854 if( m_unit )
1855 m_unit->Format( out, nestLevel );
1856
1857 if( m_flip_style != DSN_T( T_NONE ) )
1858 {
1859 out->Print( nestLevel, "(place_control (flip_style %s))\n",
1861 }
1862
1863 for( COMPONENTS::iterator i = m_components.begin(); i != m_components.end(); ++i )
1864 i->Format( out, nestLevel );
1865 }
1866
1867 UNIT_RES* GetUnits() const override
1868 {
1869 if( m_unit )
1870 return m_unit;
1871
1872 return ELEM::GetUnits();
1873 }
1874
1875private:
1876 friend class SPECCTRA_DB;
1877
1879
1881
1883};
1884
1885
1893class SHAPE : public WINDOW
1894{
1895public:
1899 SHAPE( ELEM* aParent, DSN_T aType = T_shape ) :
1900 WINDOW( aParent, aType )
1901 {
1902 m_connect = T_on;
1903 }
1904
1905 void SetConnect( DSN_T aConnect )
1906 {
1907 m_connect = aConnect;
1908 }
1909
1910 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1911 {
1912 out->Print( nestLevel, "(%s ", Name() );
1913
1914 if( shape )
1915 shape->Format( out, 0 );
1916
1917 if( m_connect == T_off )
1918 out->Print( 0, "(connect %s)", GetTokenText( m_connect ) );
1919
1920 if( m_windows.size() )
1921 {
1922 out->Print( 0, "\n" );
1923
1924 for( WINDOWS::iterator i=m_windows.begin(); i!=m_windows.end(); ++i )
1925 i->Format( out, nestLevel+1 );
1926
1927 out->Print( nestLevel, ")\n" );
1928 }
1929 else
1930 {
1931 out->Print( 0, ")\n" );
1932 }
1933 }
1934
1935private:
1936 friend class SPECCTRA_DB;
1937
1939
1940 /* <shape_descriptor >::=
1941 [<rectangle_descriptor> |
1942 <circle_descriptor> |
1943 <polygon_descriptor> |
1944 <path_descriptor> |
1945 <qarc_descriptor> ]
1946 ELEM* shape; // inherited from WINDOW
1947 */
1948
1950};
1951
1952
1953class PIN : public ELEM
1954{
1955public:
1956 PIN( ELEM* aParent ) :
1957 ELEM( T_pin, aParent )
1958 {
1959 m_rotation = 0.0;
1960 m_isRotated = false;
1961 m_kiNetCode = 0;
1962 }
1963
1964 void SetRotation( double aRotation )
1965 {
1966 m_rotation = aRotation;
1967 m_isRotated = (aRotation != 0.0);
1968 }
1969
1970 void SetVertex( const POINT& aPoint )
1971 {
1972 m_vertex = aPoint;
1974 }
1975
1976 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1977 {
1978 const char* quote = out->GetQuoteChar( m_padstack_id.c_str() );
1979 if( m_isRotated )
1980 out->Print( nestLevel, "(pin %s%s%s (rotate %.6g)", quote, m_padstack_id.c_str(), quote,
1981 m_rotation );
1982 else
1983 out->Print( nestLevel, "(pin %s%s%s", quote, m_padstack_id.c_str(), quote );
1984
1985 quote = out->GetQuoteChar( m_pin_id.c_str() );
1986 out->Print( 0, " %s%s%s %.6g %.6g)\n", quote, m_pin_id.c_str(), quote, m_vertex.x, m_vertex.y );
1987 }
1988
1989private:
1990 friend class SPECCTRA_DB;
1991
1992 std::string m_padstack_id;
1995 std::string m_pin_id;
1997
1999};
2000
2001typedef boost::ptr_vector<PIN> PINS;
2002
2003
2004class LIBRARY;
2005
2006class IMAGE : public ELEM_HOLDER
2007{
2008public:
2009 IMAGE( ELEM* aParent ) :
2010 ELEM_HOLDER( T_image, aParent )
2011 {
2012 m_side = T_both;
2013 m_unit = nullptr;
2014 m_rules = nullptr;
2015 m_place_rules = nullptr;
2016 m_duplicated = 0;
2017 }
2018
2020 {
2021 delete m_unit;
2022 delete m_rules;
2023 delete m_place_rules;
2024 }
2025
2029 static int Compare( IMAGE* lhs, IMAGE* rhs );
2030
2031 std::string GetImageId()
2032 {
2033 if( m_duplicated )
2034 {
2035 return m_image_id + "::" + std::to_string( m_duplicated );
2036 }
2037
2038 return m_image_id;
2039 }
2040
2041 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2042 {
2043 std::string imageId = GetImageId();
2044
2045 const char* quote = out->GetQuoteChar( imageId.c_str() );
2046
2047 out->Print( nestLevel, "(%s %s%s%s", Name(), quote, imageId.c_str(), quote );
2048
2049 FormatContents( out, nestLevel+1 );
2050
2051 out->Print( nestLevel, ")\n" );
2052 }
2053
2054 // this is here for makeHash()
2055 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2056 {
2057 if( m_side != T_both )
2058 out->Print( 0, " (side %s)", GetTokenText( m_side ) );
2059
2060 out->Print( 0, "\n");
2061
2062 if( m_unit )
2063 m_unit->Format( out, nestLevel );
2064
2065 // format the kids, which in this class are the shapes
2066 ELEM_HOLDER::FormatContents( out, nestLevel );
2067
2068 for( PINS::iterator i=m_pins.begin(); i!=m_pins.end(); ++i )
2069 i->Format( out, nestLevel );
2070
2071 if( m_rules )
2072 m_rules->Format( out, nestLevel );
2073
2074 if( m_place_rules )
2075 m_place_rules->Format( out, nestLevel );
2076
2077 for( KEEPOUTS::iterator i=m_keepouts.begin(); i!=m_keepouts.end(); ++i )
2078 i->Format( out, nestLevel );
2079 }
2080
2081 UNIT_RES* GetUnits() const override
2082 {
2083 if( m_unit )
2084 return m_unit;
2085
2086 return ELEM::GetUnits();
2087 }
2088
2089private:
2090 friend class SPECCTRA_DB;
2091 friend class LIBRARY;
2092
2093 std::string m_hash;
2094
2095 std::string m_image_id;
2098
2099 /* The grammar spec says only one outline is supported, but I am seeing
2100 *.dsn examples with multiple outlines. So the outlines will go into
2101 the kids list.
2102 */
2103
2105
2108
2110
2112};
2113
2114typedef boost::ptr_vector<IMAGE> IMAGES;
2115
2116
2120class PADSTACK : public ELEM_HOLDER
2121{
2122public:
2129 ELEM_HOLDER( T_padstack, nullptr )
2130 {
2131 m_unit = nullptr;
2132 m_rotate = T_on;
2133 m_absolute = T_off;
2134 m_rules = nullptr;
2135 m_attach = T_off;
2136 }
2137
2139 {
2140 delete m_unit;
2141 delete m_rules;
2142 }
2143
2144 const std::string& GetPadstackId()
2145 {
2146 return m_padstack_id;
2147 }
2148
2152 static int Compare( PADSTACK* lhs, PADSTACK* rhs );
2153
2154 void SetPadstackId( const char* aPadstackId )
2155 {
2156 m_padstack_id = aPadstackId;
2157 }
2158
2159 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2160 {
2161 const char* quote = out->GetQuoteChar( m_padstack_id.c_str() );
2162
2163 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, m_padstack_id.c_str(), quote );
2164
2165 FormatContents( out, nestLevel+1 );
2166
2167 out->Print( nestLevel, ")\n" );
2168 }
2169
2170 // this factored out for use by Compare()
2171 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2172 {
2173 if( m_unit )
2174 m_unit->Format( out, nestLevel );
2175
2176 // format the kids, which in this class are the shapes
2177 ELEM_HOLDER::FormatContents( out, nestLevel );
2178
2179 out->Print( nestLevel, "%s", "" );
2180
2181 // spec for <attach_descriptor> says default is on, so
2182 // print the off condition to override this.
2183 if( m_attach == T_off )
2184 {
2185 out->Print( 0, "(attach off)" );
2186 }
2187 else if( m_attach == T_on )
2188 {
2189 const char* quote = out->GetQuoteChar( m_via_id.c_str() );
2190
2191 out->Print( 0, "(attach on (use_via %s%s%s))", quote, m_via_id.c_str(), quote );
2192 }
2193
2194 if( m_rotate == T_off ) // print the non-default
2195 out->Print( 0, "(rotate %s)", GetTokenText( m_rotate ) );
2196
2197 if( m_absolute == T_on ) // print the non-default
2198 out->Print( 0, "(absolute %s)", GetTokenText( m_absolute ) );
2199
2200 out->Print( 0, "\n" );
2201
2202 if( m_rules )
2203 m_rules->Format( out, nestLevel );
2204 }
2205
2206
2207 UNIT_RES* GetUnits() const override
2208 {
2209 if( m_unit )
2210 return m_unit;
2211
2212 return ELEM::GetUnits();
2213 }
2214
2215private:
2216 friend class SPECCTRA_DB;
2217
2218 std::string m_hash;
2219
2220 std::string m_padstack_id;
2222
2223 /* The shapes are stored in the kids list */
2224
2228 std::string m_via_id;
2229
2231};
2232
2233typedef boost::ptr_vector<PADSTACK> PADSTACKS;
2234
2235
2239inline bool operator<( const PADSTACK& lhs, const PADSTACK& rhs )
2240{
2241 return PADSTACK::Compare( (PADSTACK*) &lhs, (PADSTACK*) &rhs ) < 0;
2242}
2243
2244
2251class LIBRARY : public ELEM
2252{
2253public:
2254 LIBRARY( ELEM* aParent, DSN_T aType = T_library ) :
2255 ELEM( aType, aParent )
2256 {
2257 m_unit = nullptr;
2258// via_start_index = -1; // 0 or greater means there is at least one via
2259 }
2260
2262 {
2263 delete m_unit;
2264 }
2265
2266 void AddPadstack( PADSTACK* aPadstack )
2267 {
2268 aPadstack->SetParent( this );
2269 m_padstacks.push_back( aPadstack );
2270 }
2271
2272/*
2273 void SetViaStartIndex( int aIndex )
2274 {
2275 via_start_index = aIndex;
2276 }
2277 int GetViaStartIndex()
2278 {
2279 return via_start_index;
2280 }
2281*/
2282
2288 int FindIMAGE( IMAGE* aImage )
2289 {
2290 unsigned i;
2291
2292 for( i=0; i<m_images.size(); ++i )
2293 {
2294 if( 0 == IMAGE::Compare( aImage, &m_images[i] ) )
2295 return (int) i;
2296 }
2297
2298 // There is no match to the IMAGE contents, but now generate a unique
2299 // name for it.
2300 int dups = 1;
2301
2302 for( i=0; i<m_images.size(); ++i )
2303 {
2304 if( 0 == aImage->m_image_id.compare( m_images[i].m_image_id ) )
2305 aImage->m_duplicated = dups++;
2306 }
2307
2308 return -1;
2309 }
2310
2311
2315 void AppendIMAGE( IMAGE* aImage )
2316 {
2317 aImage->SetParent( this );
2318 m_images.push_back( aImage );
2319 }
2320
2328 {
2329 int ndx = FindIMAGE( aImage );
2330
2331 if( ndx == -1 )
2332 {
2333 AppendIMAGE( aImage );
2334 return aImage;
2335 }
2336
2337 return &m_images[ndx];
2338 }
2339
2345 int FindVia( PADSTACK* aVia )
2346 {
2347 for( unsigned i = 0; i < m_vias.size(); ++i )
2348 {
2349 if( 0 == PADSTACK::Compare( aVia, &m_vias[i] ) )
2350 return int( i );
2351 }
2352
2353 return -1;
2354 }
2355
2359 void AppendVia( PADSTACK* aVia )
2360 {
2361 aVia->SetParent( this );
2362 m_vias.push_back( aVia );
2363 }
2364
2365
2369 void AppendPADSTACK( PADSTACK* aPadstack )
2370 {
2371 aPadstack->SetParent( this );
2372 m_padstacks.push_back( aPadstack );
2373 }
2374
2382 {
2383 int ndx = FindVia( aVia );
2384
2385 if( ndx == -1 )
2386 {
2387 AppendVia( aVia );
2388 return aVia;
2389 }
2390
2391 return &m_vias[ndx];
2392 }
2393
2399 PADSTACK* FindPADSTACK( const std::string& aPadstackId )
2400 {
2401 for( unsigned i = 0; i < m_padstacks.size(); ++i )
2402 {
2403 PADSTACK* ps = &m_padstacks[i];
2404
2405 if( ps->GetPadstackId().compare( aPadstackId ) == 0 )
2406 return ps;
2407 }
2408
2409 return nullptr;
2410 }
2411
2412 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2413 {
2414 if( m_unit )
2415 m_unit->Format( out, nestLevel );
2416
2417 for( IMAGES::iterator i = m_images.begin(); i != m_images.end(); ++i )
2418 i->Format( out, nestLevel );
2419
2420 for( PADSTACKS::iterator i = m_padstacks.begin(); i != m_padstacks.end(); ++i )
2421 i->Format( out, nestLevel );
2422
2423 for( PADSTACKS::iterator i = m_vias.begin(); i != m_vias.end(); ++i )
2424 i->Format( out, nestLevel );
2425 }
2426
2427 UNIT_RES* GetUnits() const override
2428 {
2429 if( m_unit )
2430 return m_unit;
2431
2432 return ELEM::GetUnits();
2433 }
2434
2435private:
2436 friend class SPECCTRA_DB;
2437
2440
2443};
2444
2445
2449struct PIN_REF : public ELEM
2450{
2451 PIN_REF( ELEM* aParent ) :
2452 ELEM( T_pin, aParent )
2453 {
2454 }
2455
2456
2462 int FormatIt( OUTPUTFORMATTER* out, int nestLevel )
2463 {
2464 // only print the newline if there is a nest level, and make
2465 // the quotes unconditional on this one.
2466 const char* newline = nestLevel ? "\n" : "";
2467
2468 const char* cquote = out->GetQuoteChar( component_id.c_str() );
2469 const char* pquote = out->GetQuoteChar( pin_id.c_str() );
2470
2471 return out->Print( nestLevel, "%s%s%s-%s%s%s%s", cquote, component_id.c_str(), cquote,
2472 pquote, pin_id.c_str(), pquote, newline );
2473 }
2474
2475 std::string component_id;
2476 std::string pin_id;
2477};
2478
2479typedef std::vector<PIN_REF> PIN_REFS;
2480
2481
2482class FROMTO : public ELEM
2483{
2484public:
2485 FROMTO( ELEM* aParent ) :
2486 ELEM( T_fromto, aParent )
2487 {
2488 m_rules = nullptr;
2489 m_fromto_type = DSN_T( T_NONE );
2490 }
2492 {
2493 delete m_rules;
2494 }
2495
2496 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2497 {
2498 // no quoting on these two, the lexer preserved the quotes on input
2499 out->Print( nestLevel, "(%s %s %s ",
2500 Name(), m_fromText.c_str(), m_toText.c_str() );
2501
2502 if( m_fromto_type != DSN_T( T_NONE ) )
2503 out->Print( 0, "(type %s)", GetTokenText( m_fromto_type ) );
2504
2505 if( m_net_id.size() )
2506 {
2507 const char* quote = out->GetQuoteChar( m_net_id.c_str() );
2508 out->Print( 0, "(net %s%s%s)", quote, m_net_id.c_str(), quote );
2509 }
2510
2511 bool singleLine = true;
2512
2513 if( m_rules || m_layer_rules.size() )
2514 {
2515 out->Print( 0, "\n" );
2516 singleLine = false;
2517 }
2518
2519 if( m_rules )
2520 m_rules->Format( out, nestLevel+1 );
2521
2522 /*
2523 if( circuit.size() )
2524 out->Print( nestLevel, "%s\n", circuit.c_str() );
2525 */
2526
2527 for( LAYER_RULES::iterator i = m_layer_rules.begin(); i != m_layer_rules.end(); ++i )
2528 i->Format( out, nestLevel+1 );
2529
2530 out->Print( singleLine ? 0 : nestLevel, ")" );
2531
2532 if( nestLevel || !singleLine )
2533 out->Print( 0, "\n" );
2534 }
2535
2536private:
2537 friend class SPECCTRA_DB;
2538
2539 std::string m_fromText;
2540 std::string m_toText;
2541
2543 std::string m_net_id;
2545// std::string m_circuit;
2547};
2548
2549typedef boost::ptr_vector<FROMTO> FROMTOS;
2550
2551
2555class COMP_ORDER : public ELEM
2556{
2557public:
2558 COMP_ORDER( ELEM* aParent ) :
2559 ELEM( T_comp_order, aParent )
2560 {
2561 }
2562
2563 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2564 {
2565 out->Print( nestLevel, "(%s", Name() );
2566
2567 for( STRINGS::iterator i = m_placement_ids.begin(); i != m_placement_ids.end(); ++i )
2568 {
2569 const char* quote = out->GetQuoteChar( i->c_str() );
2570 out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
2571 }
2572
2573 out->Print( 0, ")" );
2574
2575 if( nestLevel )
2576 out->Print( 0, "\n" );
2577 }
2578
2579private:
2580 friend class SPECCTRA_DB;
2581
2583};
2584
2585typedef boost::ptr_vector<COMP_ORDER> COMP_ORDERS;
2586
2590class NET : public ELEM
2591{
2592public:
2593 NET( ELEM* aParent ) :
2594 ELEM( T_net, aParent )
2595 {
2596 m_unassigned = false;
2597 m_net_number = T_NONE;
2598 m_pins_type = T_pins;
2599
2600 m_type = T_NONE;
2601 m_supply = T_NONE;
2602
2603 m_rules = nullptr;
2604 m_comp_order = nullptr;
2605 }
2606
2608 {
2609 delete m_rules;
2610 delete m_comp_order;
2611 }
2612
2613 int FindPIN_REF( const std::string& aComponent )
2614 {
2615 for( unsigned i = 0; i < m_pins.size(); ++i )
2616 {
2617 if( aComponent.compare( m_pins[i].component_id ) == 0 )
2618 return int(i);
2619 }
2620
2621 return -1;
2622 }
2623
2624 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2625 {
2626 const char* quote = out->GetQuoteChar( m_net_id.c_str() );
2627 const char* space = " ";
2628
2629 out->Print( nestLevel, "(%s %s%s%s", Name(), quote, m_net_id.c_str(), quote );
2630
2631 if( m_unassigned )
2632 {
2633 out->Print( 0, "%s(unassigned)", space );
2634 space = ""; // only needed one space
2635 }
2636
2637 if( m_net_number != T_NONE )
2638 {
2639 out->Print( 0, "%s(net_number %d)", space, m_net_number );
2640 // space = "";
2641 }
2642
2643 out->Print( 0, "\n" );
2644
2645 if( m_pins.size() )
2646 {
2647 const int RIGHTMARGIN = 80;
2648 int perLine = out->Print( nestLevel+1, "(%s", GetTokenText( m_pins_type ) );
2649
2650 for( PIN_REFS::iterator i = m_pins.begin(); i != m_pins.end(); ++i )
2651 {
2652 if( perLine > RIGHTMARGIN )
2653 {
2654 out->Print( 0, "\n");
2655 perLine = out->Print( nestLevel+2, "%s", "" );
2656 }
2657 else
2658 {
2659 perLine += out->Print( 0, " " );
2660 }
2661
2662 perLine += i->FormatIt( out, 0 );
2663 }
2664
2665 out->Print( 0, ")\n" );
2666 }
2667
2668 if( m_comp_order )
2669 m_comp_order->Format( out, nestLevel+1 );
2670
2671 if( m_type != T_NONE )
2672 out->Print( nestLevel+1, "(type %s)\n", GetTokenText( m_type ) );
2673
2674 if( m_rules )
2675 m_rules->Format( out, nestLevel+1 );
2676
2677 for( LAYER_RULES::iterator i = m_layer_rules.begin(); i != m_layer_rules.end(); ++i )
2678 i->Format( out, nestLevel+1 );
2679
2680 for( FROMTOS::iterator i = m_fromtos.begin(); i != m_fromtos.end(); ++i )
2681 i->Format( out, nestLevel+1 );
2682
2683 out->Print( nestLevel, ")\n" );
2684 }
2685
2686private:
2687 friend class SPECCTRA_DB;
2688
2689 std::string m_net_id;
2692
2695
2701
2703
2705
2707
2709
2711
2713};
2714
2715typedef boost::ptr_vector<NET> NETS;
2716
2717
2718class TOPOLOGY : public ELEM
2719{
2720public:
2721 TOPOLOGY( ELEM* aParent ) :
2722 ELEM( T_topology, aParent )
2723 {
2724 }
2725
2726 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2727 {
2728 for( FROMTOS::iterator i = m_fromtos.begin(); i != m_fromtos.end(); ++i )
2729 i->Format( out, nestLevel );
2730
2731 for( COMP_ORDERS::iterator i = m_comp_orders.begin(); i != m_comp_orders.end(); ++i )
2732 i->Format( out, nestLevel );
2733 }
2734
2735private:
2736 friend class SPECCTRA_DB;
2737
2739
2741};
2742
2743
2747class CLASS : public ELEM
2748{
2749public:
2750 CLASS( ELEM* aParent ) :
2751 ELEM( T_class, aParent )
2752 {
2753 m_rules = nullptr;
2754 m_topology = nullptr;
2755 }
2756
2758 {
2759 delete m_rules;
2760 delete m_topology;
2761 }
2762
2763 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2764 {
2765 const char* quote = out->GetQuoteChar( m_class_id.c_str() );
2766
2767 int perLine = out->Print( nestLevel, "(%s %s%s%s", Name(), quote, m_class_id.c_str(), quote );
2768
2769 const int RIGHTMARGIN = 72;
2770
2771 for( STRINGS::iterator i=m_net_ids.begin(); i!=m_net_ids.end(); ++i )
2772 {
2773 const char* space = " ";
2774
2775 if( perLine > RIGHTMARGIN )
2776 {
2777 out->Print( 0, "\n" );
2778 perLine = out->Print( nestLevel+1, "%s", "" );
2779 space = ""; // no space at first net_id of the line
2780 }
2781
2782 // Allegro PCB Router (Specctra) doesn't like empty net names
2783 if( i->empty() )
2784 continue;
2785
2786 quote = out->GetQuoteChar( i->c_str() );
2787 perLine += out->Print( 0, "%s%s%s%s", space, quote, i->c_str(), quote );
2788 }
2789
2790 bool newLine = false;
2791
2792 if( m_circuit.size() || m_rules || m_layer_rules.size() || m_topology )
2793 {
2794 out->Print( 0, "\n" );
2795 newLine = true;
2796 }
2797
2798 if( m_circuit.size() )
2799 {
2800 out->Print( nestLevel+1, "(circuit\n" );
2801
2802 for( STRINGS::iterator i = m_circuit.begin(); i != m_circuit.end(); ++i )
2803 out->Print( nestLevel + 2, "%s\n", i->c_str() );
2804
2805 out->Print( nestLevel+1, ")\n" );
2806 }
2807
2808 if( m_rules )
2809 m_rules->Format( out, nestLevel+1 );
2810
2811 for( LAYER_RULES::iterator i = m_layer_rules.begin(); i != m_layer_rules.end(); ++i )
2812 i->Format( out, nestLevel + 1 );
2813
2814 if( m_topology )
2815 m_topology->Format( out, nestLevel+1 );
2816
2817 out->Print( newLine ? nestLevel : 0, ")\n" );
2818 }
2819
2820private:
2821 friend class SPECCTRA_DB;
2822
2823 std::string m_class_id;
2824
2826
2829
2831
2833
2835};
2836
2837typedef boost::ptr_vector<CLASS> CLASSLIST;
2838
2839
2840class NETWORK : public ELEM
2841{
2842public:
2843 NETWORK( ELEM* aParent ) :
2844 ELEM( T_network, aParent )
2845 {
2846 }
2847
2848 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2849 {
2850 for( NETS::iterator i = m_nets.begin(); i != m_nets.end(); ++i )
2851 i->Format( out, nestLevel );
2852
2853 for( CLASSLIST::iterator i = m_classes.begin(); i != m_classes.end(); ++i )
2854 i->Format( out, nestLevel );
2855 }
2856
2857private:
2858 friend class SPECCTRA_DB;
2859
2862};
2863
2864
2865class CONNECT : public ELEM
2866{
2867 // @todo not completed.
2868
2869public:
2870 CONNECT( ELEM* aParent ) :
2871 ELEM( T_connect, aParent ) {}
2872};
2873
2874
2878class WIRE : public ELEM
2879{
2880public:
2881 WIRE( ELEM* aParent ) :
2882 ELEM( T_wire, aParent )
2883 {
2884 m_shape = nullptr;
2885 m_connect = nullptr;
2886
2887 m_turret = -1;
2888 m_wire_type = T_NONE;
2889 m_attr = T_NONE;
2890 m_supply = false;
2891 }
2892
2894 {
2895 delete m_shape;
2896 delete m_connect;
2897 }
2898
2899 void SetShape( ELEM* aShape )
2900 {
2901 delete m_shape;
2902 m_shape = aShape;
2903
2904 if( aShape )
2905 {
2906 wxASSERT(aShape->Type()==T_rect || aShape->Type()==T_circle
2907 || aShape->Type()==T_qarc || aShape->Type()==T_path
2908 || aShape->Type()==T_polygon);
2909
2910 aShape->SetParent( this );
2911 }
2912 }
2913
2914 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2915 {
2916 out->Print( nestLevel, "(%s ", Name() );
2917
2918 if( m_shape )
2919 m_shape->Format( out, 0 );
2920
2921 if( m_net_id.size() )
2922 {
2923 const char* quote = out->GetQuoteChar( m_net_id.c_str() );
2924 out->Print( 0, "(net %s%s%s)", quote, m_net_id.c_str(), quote );
2925 }
2926
2927 if( m_turret >= 0 )
2928 out->Print( 0, "(turrent %d)", m_turret );
2929
2930 if( m_wire_type != T_NONE )
2931 out->Print( 0, "(type %s)", GetTokenText( m_wire_type ) );
2932
2933 if( m_attr != T_NONE )
2934 out->Print( 0, "(attr %s)", GetTokenText( m_attr ) );
2935
2936 if( m_shield.size() )
2937 {
2938 const char* quote = out->GetQuoteChar( m_shield.c_str() );
2939 out->Print( 0, "(shield %s%s%s)", quote, m_shield.c_str(), quote );
2940 }
2941
2942 if( m_windows.size() )
2943 {
2944 out->Print( 0, "\n" );
2945
2946 for( WINDOWS::iterator i = m_windows.begin(); i != m_windows.end(); ++i )
2947 i->Format( out, nestLevel + 1 );
2948 }
2949
2950 if( m_connect )
2951 m_connect->Format( out, 0 );
2952
2953 if( m_supply )
2954 out->Print( 0, "(supply)" );
2955
2956 out->Print( 0, ")\n" );
2957 }
2958
2959private:
2960 friend class SPECCTRA_DB;
2961
2962 /* <shape_descriptor >::=
2963 [<rectangle_descriptor> |
2964 <circle_descriptor> |
2965 <polygon_descriptor> |
2966 <path_descriptor> |
2967 <qarc_descriptor> ]
2968 */
2970
2971 std::string m_net_id;
2975 std::string m_shield;
2979};
2980
2981typedef boost::ptr_vector<WIRE> WIRES;
2982
2983
2987class WIRE_VIA : public ELEM
2988{
2989public:
2990 WIRE_VIA( ELEM* aParent ) :
2991 ELEM( T_via, aParent )
2992 {
2993 m_via_number = -1;
2994 m_via_type = T_NONE;
2995 m_attr = T_NONE;
2996 m_supply = false;
2997 }
2998
2999 const std::string& GetPadstackId()
3000 {
3001 return m_padstack_id;
3002 }
3003
3004 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3005 {
3006 const char* quote = out->GetQuoteChar( m_padstack_id.c_str() );
3007
3008 const int RIGHTMARGIN = 80;
3009 int perLine = out->Print( nestLevel, "(%s %s%s%s", Name(), quote, m_padstack_id.c_str(),
3010 quote );
3011
3012 for( POINTS::iterator i = m_vertexes.begin(); i != m_vertexes.end(); ++i )
3013 {
3014 if( perLine > RIGHTMARGIN )
3015 {
3016 out->Print( 0, "\n" );
3017 perLine = out->Print( nestLevel+1, "%s", "" );
3018 }
3019 else
3020 {
3021 perLine += out->Print( 0, " " );
3022 }
3023
3024 perLine += out->Print( 0, "%.6g %.6g", i->x, i->y );
3025 }
3026
3027 if( m_net_id.size() || m_via_number!=-1 || m_via_type!=T_NONE || m_attr!=T_NONE || m_supply)
3028 out->Print( 0, " " );
3029
3030 if( m_net_id.size() )
3031 {
3032 if( perLine > RIGHTMARGIN )
3033 {
3034 out->Print( 0, "\n" );
3035 perLine = out->Print( nestLevel+1, "%s", "" );
3036 }
3037
3038 quote = out->GetQuoteChar( m_net_id.c_str() );
3039 perLine += out->Print( 0, "(net %s%s%s)", quote, m_net_id.c_str(), quote );
3040 }
3041
3042 if( m_via_number != -1 )
3043 {
3044 if( perLine > RIGHTMARGIN )
3045 {
3046 out->Print( 0, "\n" );
3047 perLine = out->Print( nestLevel+1, "%s", "" );
3048 }
3049
3050 perLine += out->Print( 0, "(via_number %d)", m_via_number );
3051 }
3052
3053 if( m_via_type != T_NONE )
3054 {
3055 if( perLine > RIGHTMARGIN )
3056 {
3057 out->Print( 0, "\n" );
3058 perLine = out->Print( nestLevel+1, "%s", "" );
3059 }
3060
3061 perLine += out->Print( 0, "(type %s)", GetTokenText( m_via_type ) );
3062 }
3063
3064 if( m_attr != T_NONE )
3065 {
3066 if( perLine > RIGHTMARGIN )
3067 {
3068 out->Print( 0, "\n" );
3069 perLine = out->Print( nestLevel+1, "%s", "" );
3070 }
3071
3072 if( m_attr == T_virtual_pin )
3073 {
3074 quote = out->GetQuoteChar( m_virtual_pin_name.c_str() );
3075 perLine += out->Print( 0, "(attr virtual_pin %s%s%s)", quote,
3076 m_virtual_pin_name.c_str(), quote );
3077 }
3078 else
3079 {
3080 perLine += out->Print( 0, "(attr %s)", GetTokenText( m_attr ) );
3081 }
3082 }
3083
3084 if( m_supply )
3085 {
3086 if( perLine > RIGHTMARGIN )
3087 {
3088 out->Print( 0, "\n" );
3089 perLine = out->Print( nestLevel+1, "%s", "" );
3090 }
3091
3092 perLine += out->Print( 0, "(supply)" );
3093 }
3094
3095 if( m_contact_layers.size() )
3096 {
3097 out->Print( 0, "\n" );
3098 out->Print( nestLevel+1, "(contact\n" );
3099
3100 for( STRINGS::iterator i = m_contact_layers.begin(); i != m_contact_layers.end(); ++i )
3101 {
3102 quote = out->GetQuoteChar( i->c_str() );
3103 out->Print( nestLevel+2, "%s%s%s\n", quote, i->c_str(), quote );
3104 }
3105
3106 out->Print( nestLevel+1, "))\n" );
3107 }
3108 else
3109 {
3110 out->Print( 0, ")\n" );
3111 }
3112 }
3113
3114private:
3115 friend class SPECCTRA_DB;
3116
3117 std::string m_padstack_id;
3119 std::string m_net_id;
3126};
3127
3128typedef boost::ptr_vector<WIRE_VIA> WIRE_VIAS;
3129
3130
3134class WIRING : public ELEM
3135{
3136public:
3137 WIRING( ELEM* aParent ) :
3138 ELEM( T_wiring, aParent )
3139 {
3140 unit = nullptr;
3141 }
3142
3144 {
3145 delete unit;
3146 }
3147
3148 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3149 {
3150 if( unit )
3151 unit->Format( out, nestLevel );
3152
3153 for( WIRES::iterator i = wires.begin(); i != wires.end(); ++i )
3154 i->Format( out, nestLevel );
3155
3156 for( WIRE_VIAS::iterator i = wire_vias.begin(); i != wire_vias.end(); ++i )
3157 i->Format( out, nestLevel );
3158 }
3159
3160 UNIT_RES* GetUnits() const override
3161 {
3162 if( unit )
3163 return unit;
3164
3165 return ELEM::GetUnits();
3166 }
3167
3168private:
3169 friend class SPECCTRA_DB;
3170
3174};
3175
3176
3177class PCB : public ELEM
3178{
3179public:
3180 PCB( ELEM* aParent = nullptr ) :
3181 ELEM( T_pcb, aParent )
3182 {
3183 m_parser = nullptr;
3184 m_resolution = nullptr;
3185 m_unit = nullptr;
3186 m_structure = nullptr;
3187 m_placement = nullptr;
3188 m_library = nullptr;
3189 m_network = nullptr;
3190 m_wiring = nullptr;
3191 }
3192
3194 {
3195 delete m_parser;
3196 delete m_resolution;
3197 delete m_unit;
3198 delete m_structure;
3199 delete m_placement;
3200 delete m_library;
3201 delete m_network;
3202 delete m_wiring;
3203 }
3204
3205 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3206 {
3207 const char* quote = out->GetQuoteChar( m_pcbname.c_str() );
3208
3209 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, m_pcbname.c_str(), quote );
3210
3211 if( m_parser )
3212 m_parser->Format( out, nestLevel+1 );
3213
3214 if( m_resolution )
3215 m_resolution->Format( out, nestLevel+1 );
3216
3217 if( m_unit )
3218 m_unit->Format( out, nestLevel+1 );
3219
3220 if( m_structure )
3221 m_structure->Format( out, nestLevel+1 );
3222
3223 if( m_placement )
3224 m_placement->Format( out, nestLevel+1 );
3225
3226 if( m_library )
3227 m_library->Format( out, nestLevel+1 );
3228
3229 if( m_network )
3230 m_network->Format( out, nestLevel+1 );
3231
3232 if( m_wiring )
3233 m_wiring->Format( out, nestLevel+1 );
3234
3235 out->Print( nestLevel, ")\n" );
3236 }
3237
3238 UNIT_RES* GetUnits() const override
3239 {
3240 if( m_unit )
3241 return m_unit;
3242
3243 if( m_resolution )
3244 return m_resolution->GetUnits();
3245
3246 return ELEM::GetUnits();
3247 }
3248
3249private:
3250 friend class SPECCTRA_DB;
3251
3252 std::string m_pcbname;
3261};
3262
3263
3264class ANCESTOR : public ELEM
3265{
3266public:
3267 ANCESTOR( ELEM* aParent ) :
3268 ELEM( T_ancestor, aParent )
3269 {
3270 time_stamp = time(nullptr);
3271 }
3272
3273 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3274 {
3275 char temp[80];
3276 struct tm* tmp;
3277
3278 tmp = localtime( &time_stamp );
3279 strftime( temp, sizeof(temp), "%b %d %H : %M : %S %Y", tmp );
3280
3281 // format the time first to temp
3282 // filename may be empty, so quote it just in case.
3283 out->Print( nestLevel, "(%s \"%s\" (created_time %s)\n", Name(), filename.c_str(), temp );
3284
3285 if( comment.size() )
3286 {
3287 const char* quote = out->GetQuoteChar( comment.c_str() );
3288 out->Print( nestLevel+1, "(comment %s%s%s)\n", quote, comment.c_str(), quote );
3289 }
3290
3291 out->Print( nestLevel, ")\n" );
3292 }
3293
3294private:
3295 friend class SPECCTRA_DB;
3296
3297 std::string filename;
3298 std::string comment;
3300};
3301
3302typedef boost::ptr_vector<ANCESTOR> ANCESTORS;
3303
3304
3305class HISTORY : public ELEM
3306{
3307public:
3308 HISTORY( ELEM* aParent ) :
3309 ELEM( T_history, aParent )
3310 {
3311 time_stamp = time(nullptr);
3312 }
3313
3314 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3315 {
3316 for( ANCESTORS::iterator i=ancestors.begin(); i!=ancestors.end(); ++i )
3317 i->Format( out, nestLevel );
3318
3319 char temp[80];
3320 struct tm* tmp;
3321
3322 tmp = localtime( &time_stamp );
3323 strftime( temp, sizeof( temp ), "%b %d %H : %M : %S %Y", tmp );
3324
3325 // format the time first to temp
3326 out->Print( nestLevel, "(self (created_time %s)\n", temp );
3327
3328 for( STRINGS::iterator i=comments.begin(); i!=comments.end(); ++i )
3329 {
3330 const char* quote = out->GetQuoteChar( i->c_str() );
3331 out->Print( nestLevel+1, "(comment %s%s%s)\n", quote, i->c_str(), quote );
3332 }
3333
3334 out->Print( nestLevel, ")\n" );
3335 }
3336
3337private:
3338 friend class SPECCTRA_DB;
3339
3343};
3344
3345
3349class SUPPLY_PIN : public ELEM
3350{
3351public:
3352 SUPPLY_PIN( ELEM* aParent ) :
3353 ELEM( T_supply_pin, aParent )
3354 {
3355 }
3356
3357 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3358 {
3359 bool singleLine = pin_refs.size() <= 1;
3360 out->Print( nestLevel, "(%s", Name() );
3361
3362 if( singleLine )
3363 {
3364 out->Print( 0, "%s", " " );
3365 pin_refs.begin()->Format( out, 0 );
3366 }
3367 else
3368 {
3369 for( PIN_REFS::iterator i = pin_refs.begin(); i != pin_refs.end(); ++i )
3370 i->FormatIt( out, nestLevel + 1 );
3371 }
3372
3373 if( net_id.size() )
3374 {
3375 const char* newline = singleLine ? "" : "\n";
3376
3377 const char* quote = out->GetQuoteChar( net_id.c_str() );
3378 out->Print( singleLine ? 0 : nestLevel+1, " (net %s%s%s)%s",
3379 quote, net_id.c_str(), quote, newline );
3380 }
3381
3382 out->Print( singleLine ? 0 : nestLevel, ")\n");
3383 }
3384
3385private:
3386 friend class SPECCTRA_DB;
3387
3389 std::string net_id;
3390};
3391
3392typedef boost::ptr_vector<SUPPLY_PIN> SUPPLY_PINS;
3393
3394
3398class NET_OUT : public ELEM
3399{
3400public:
3401 NET_OUT( ELEM* aParent ) :
3402 ELEM( T_net_out, aParent )
3403 {
3404 rules = nullptr;
3405 net_number = -1;
3406 }
3407
3409 {
3410 delete rules;
3411 }
3412
3413 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3414 {
3415 const char* quote = out->GetQuoteChar( net_id.c_str() );
3416
3417 // cannot use Type() here, it is T_net_out and we need "(net "
3418 out->Print( nestLevel, "(net %s%s%s\n", quote, net_id.c_str(), quote );
3419
3420 if( net_number>= 0 )
3421 out->Print( nestLevel+1, "(net_number %d)\n", net_number );
3422
3423 if( rules )
3424 rules->Format( out, nestLevel+1 );
3425
3426 for( WIRES::iterator i = wires.begin(); i != wires.end(); ++i )
3427 i->Format( out, nestLevel + 1 );
3428
3429 for( WIRE_VIAS::iterator i = wire_vias.begin(); i != wire_vias.end(); ++i )
3430 i->Format( out, nestLevel + 1 );
3431
3432 for( SUPPLY_PINS::iterator i = supply_pins.begin(); i != supply_pins.end(); ++i )
3433 i->Format( out, nestLevel + 1 );
3434
3435 out->Print( nestLevel, ")\n" );
3436 }
3437
3438private:
3439 friend class SPECCTRA_DB;
3440
3441 std::string net_id;
3447};
3448
3449typedef boost::ptr_vector<NET_OUT> NET_OUTS;
3450
3451
3452class ROUTE : public ELEM
3453{
3454public:
3455 ROUTE( ELEM* aParent ) :
3456 ELEM( T_route, aParent )
3457 {
3458 resolution = nullptr;
3459 parser = nullptr;
3460 structure_out = nullptr;
3461 library = nullptr;
3462 }
3463
3465 {
3466 delete resolution;
3467 delete parser;
3468 delete structure_out;
3469 delete library;
3470// delete test_points;
3471 }
3472
3473 UNIT_RES* GetUnits() const override
3474 {
3475 if( resolution )
3476 return resolution;
3477
3478 return ELEM::GetUnits();
3479 }
3480
3481 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3482 {
3483 if( resolution )
3484 resolution->Format( out, nestLevel );
3485
3486 if( parser )
3487 parser->Format( out, nestLevel );
3488
3489 if( structure_out )
3490 structure_out->Format( out, nestLevel );
3491
3492 if( library )
3493 library->Format( out, nestLevel );
3494
3495 if( net_outs.size() )
3496 {
3497 out->Print( nestLevel, "(network_out\n" );
3498
3499 for( NET_OUTS::iterator i = net_outs.begin(); i != net_outs.end(); ++i )
3500 i->Format( out, nestLevel + 1 );
3501
3502 out->Print( nestLevel, ")\n" );
3503 }
3504
3505// if( test_poinst )
3506// test_points->Format( out, nestLevel );
3507 }
3508
3509private:
3510 friend class SPECCTRA_DB;
3511
3517// TEST_POINTS* test_points;
3518};
3519
3520
3526{
3527 PIN_PAIR( ELEM* aParent = nullptr ) :
3528 was( aParent ),
3529 is( aParent )
3530 {
3531 }
3532
3535};
3536
3537typedef std::vector<PIN_PAIR> PIN_PAIRS;
3538
3539
3543class WAS_IS : public ELEM
3544{
3545public:
3546 WAS_IS( ELEM* aParent ) :
3547 ELEM( T_was_is, aParent )
3548 {
3549 }
3550
3551 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3552 {
3553 for( PIN_PAIRS::iterator i = pin_pairs.begin(); i != pin_pairs.end(); ++i )
3554 {
3555 out->Print( nestLevel, "(pins " );
3556 i->was.Format( out, 0 );
3557 out->Print( 0, " " );
3558 i->is.Format( out, 0 );
3559 out->Print( 0, ")\n" );
3560 }
3561 }
3562
3563private:
3564 friend class SPECCTRA_DB;
3565
3567};
3568
3569
3573class SESSION : public ELEM
3574{
3575public:
3576 SESSION( ELEM* aParent = nullptr ) :
3577 ELEM( T_session, aParent )
3578 {
3579 history = nullptr;
3580 structure = nullptr;
3581 placement = nullptr;
3582 was_is = nullptr;
3583 route = nullptr;
3584 }
3585
3587 {
3588 delete history;
3589 delete structure;
3590 delete placement;
3591 delete was_is;
3592 delete route;
3593 }
3594
3595 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3596 {
3597 const char* quote = out->GetQuoteChar( session_id.c_str() );
3598 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, session_id.c_str(), quote );
3599
3600 out->Print( nestLevel+1, "(base_design \"%s\")\n", base_design.c_str() );
3601
3602 if( history )
3603 history->Format( out, nestLevel+1 );
3604
3605 if( structure )
3606 structure->Format( out, nestLevel+1 );
3607
3608 if( placement )
3609 placement->Format( out, nestLevel+1 );
3610
3611 if( was_is )
3612 was_is->Format( out, nestLevel+1 );
3613
3614 if( route )
3615 route->Format( out, nestLevel+1 );
3616
3617 out->Print( nestLevel, ")\n" );
3618 }
3619
3620private:
3621 friend class SPECCTRA_DB;
3622
3623 std::string session_id;
3624 std::string base_design;
3625
3631
3632/* not supported:
3633 FLOOR_PLAN* floor_plan;
3634 NET_PIN_CHANGES* net_pin_changes;
3635 SWAP_HISTORY* swap_history;
3636*/
3637};
3638
3639typedef boost::ptr_set<PADSTACK> PADSTACKSET;
3640
3641
3645class SPECCTRA_DB : public SPECCTRA_LEXER
3646{
3647public:
3648
3650 SPECCTRA_LEXER( 0 ) // LINE_READER* == nullptr, no DSNLEXER::PushReader()
3651 {
3652 // The LINE_READER will be pushed from an automatic instantiation,
3653 // we don't own it:
3654 wxASSERT( !iOwnReaders );
3655
3656 m_pcb = nullptr;
3657 m_session = nullptr;
3658 m_quote_char += '"';
3659 m_footprintsAreFlipped = false;
3660
3661 SetSpecctraMode( true );
3662
3663 // Avoid not initialized members:
3664 m_routeResolution = nullptr;
3665 m_sessionBoard = nullptr;
3666 m_top_via_layer = 0;
3667 m_bot_via_layer = 0;
3668 }
3669
3671 {
3672 delete m_pcb;
3673 delete m_session;
3674
3675 deleteNETs();
3676 }
3677
3681 static PCB* MakePCB();
3682
3686 void SetPCB( PCB* aPcb )
3687 {
3688 delete m_pcb;
3689 m_pcb = aPcb;
3690 }
3691
3692 PCB* GetPCB() { return m_pcb; }
3693
3697 void SetSESSION( SESSION* aSession )
3698 {
3699 delete m_session;
3700 m_session = aSession;
3701 }
3702
3704
3714 void LoadPCB( const wxString& aFilename );
3715
3726 void LoadSESSION( const wxString& aFilename );
3727
3736 void ExportPCB( const wxString& aFilename, bool aNameChange=false );
3737
3748 void FromBOARD( BOARD* aBoard );
3749
3758 void FromSESSION( BOARD* aBoard );
3759
3765 void ExportSESSION( const wxString& aFilename );
3766
3774 bool BuiltBoardOutlines( BOARD* aBoard );
3775
3779 void FlipFOOTPRINTs( BOARD* aBoard );
3780
3784 void RevertFOOTPRINTs( BOARD* aBoard );
3785
3786private:
3793 void buildLayerMaps( BOARD* aBoard );
3794
3801 int findLayerName( const std::string& aLayerName ) const;
3802
3819 void readCOMPnPIN( std::string* component_id, std::string* pid_id );
3820
3832 void readTIME( time_t* time_stamp );
3833
3834 void doPCB( PCB* growth );
3835 void doPARSER( PARSER* growth );
3836 void doRESOLUTION( UNIT_RES* growth );
3837 void doUNIT( UNIT_RES* growth );
3838 void doSTRUCTURE( STRUCTURE* growth );
3839 void doSTRUCTURE_OUT( STRUCTURE_OUT* growth );
3842 void doBOUNDARY( BOUNDARY* growth );
3843 void doRECTANGLE( RECTANGLE* growth );
3844 void doPATH( PATH* growth );
3845 void doSTRINGPROP( STRINGPROP* growth );
3846 void doTOKPROP( TOKPROP* growth );
3847 void doVIA( VIA* growth );
3848 void doCONTROL( CONTROL* growth );
3849 void doLAYER( LAYER* growth );
3850 void doRULE( RULE* growth );
3851 void doKEEPOUT( KEEPOUT* growth );
3852 void doCIRCLE( CIRCLE* growth );
3853 void doQARC( QARC* growth );
3854 void doWINDOW( WINDOW* growth );
3855 void doCONNECT( CONNECT* growth );
3856 void doREGION( REGION* growth );
3857 void doCLASS_CLASS( CLASS_CLASS* growth );
3858 void doLAYER_RULE( LAYER_RULE* growth );
3859 void doCLASSES( CLASSES* growth );
3860 void doGRID( GRID* growth );
3861 void doPLACE( PLACE* growth );
3862 void doCOMPONENT( COMPONENT* growth );
3863 void doPLACEMENT( PLACEMENT* growth );
3864 void doPROPERTIES( PROPERTIES* growth );
3865 void doPADSTACK( PADSTACK* growth );
3866 void doSHAPE( SHAPE* growth );
3867 void doIMAGE( IMAGE* growth );
3868 void doLIBRARY( LIBRARY* growth );
3869 void doPIN( PIN* growth );
3870 void doNET( NET* growth );
3871 void doNETWORK( NETWORK* growth );
3872 void doCLASS( CLASS* growth );
3873 void doTOPOLOGY( TOPOLOGY* growth );
3874 void doFROMTO( FROMTO* growth );
3875 void doCOMP_ORDER( COMP_ORDER* growth );
3876 void doWIRE( WIRE* growth );
3877 void doWIRE_VIA( WIRE_VIA* growth );
3878 void doWIRING( WIRING* growth );
3879 void doSESSION( SESSION* growth );
3880 void doANCESTOR( ANCESTOR* growth );
3881 void doHISTORY( HISTORY* growth );
3882 void doROUTE( ROUTE* growth );
3883 void doWAS_IS( WAS_IS* growth );
3884 void doNET_OUT( NET_OUT* growth );
3885 void doSUPPLY_PIN( SUPPLY_PIN* growth );
3886
3887 //-----<FromBOARD>-------------------------------------------------------
3888
3896 void fillBOUNDARY( BOARD* aBoard, BOUNDARY* aBoundary );
3897
3906 IMAGE* makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint );
3907
3918 PADSTACK* makePADSTACK( BOARD* aBoard, PAD* aPad );
3919
3929 PADSTACK* makeVia( int aCopperDiameter, int aDrillDiameter,
3930 int aTopLayer, int aBotLayer );
3931
3938 PADSTACK* makeVia( const ::PCB_VIA* aVia );
3939
3944 {
3945 for( unsigned n = 0; n < m_nets.size(); ++n )
3946 delete m_nets[n];
3947
3948 m_nets.clear();
3949 }
3950
3954 void exportNETCLASS( const std::shared_ptr<NETCLASS>& aNetClass, BOARD* aBoard );
3955
3956 //-----</FromBOARD>------------------------------------------------------
3957
3958 //-----<FromSESSION>-----------------------------------------------------
3959
3963 PCB_TRACK* makeTRACK( WIRE* wire, PATH* aPath, int aPointIndex, int aNetcode );
3964
3968 PCB_ARC* makeARC( WIRE* wire, QARC* aQarc, int aNetcode );
3969
3974 PCB_VIA* makeVIA( WIRE_VIA*aVia, PADSTACK* aPadstack, const POINT& aPoint, int aNetCode,
3975 int aViaDrillDefault );
3976
3977 //-----</FromSESSION>----------------------------------------------------
3978
3980 static const KEYWORD keywords[];
3981
3983 SHAPE_POLY_SET m_brd_outlines; // the board outlines for DSN export
3985 wxString m_filename;
3986 std::string m_quote_char;
3987
3989
3991
3993
3994 std::map<PCB_LAYER_ID, int> m_kicadLayer2pcb;
3995 std::map<int, PCB_LAYER_ID> m_pcbLayer2kicad;
3996
3999
4002
4003 static const KICAD_T scanPADs[];
4004
4006
4008 std::vector<NET*> m_nets;
4009
4013};
4014
4022bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName );
4023
4024} // namespace DSN
4025
4026#endif // SPECCTRA_H_
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:295
time_t time_stamp
Definition: specctra.h:3299
ANCESTOR(ELEM *aParent)
Definition: specctra.h:3267
std::string filename
Definition: specctra.h:3297
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3273
std::string comment
Definition: specctra.h:3298
PATHS paths
Definition: specctra.h:729
BOUNDARY(ELEM *aParent, DSN_T aType=T_boundary)
Definition: specctra.h:664
void GetCorners(std::vector< double > &aBuffer)
GetCorners fills aBuffer with a list of coordinates (x,y) of corners.
Definition: specctra.h:678
RECTANGLE * rectangle
Definition: specctra.h:730
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:710
void SetLayerId(const std::string &aLayerId)
Definition: specctra.h:757
std::string layer_id
Definition: specctra.h:775
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:743
double diameter
Definition: specctra.h:777
CIRCLE(ELEM *aParent)
Definition: specctra.h:737
void SetVertex(const POINT &aVertex)
Definition: specctra.h:767
POINT vertex
Definition: specctra.h:778
void SetDiameter(double aDiameter)
Definition: specctra.h:762
STRINGS class_ids
Definition: specctra.h:1121
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1109
CLASSES(ELEM *aParent)
Definition: specctra.h:1104
CLASS_CLASS(ELEM *aParent, DSN_T aType)
Definition: specctra.h:1133
CLASSES * classes
Definition: specctra.h:1156
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1144
The <class_descriptor> in the specctra spec.
Definition: specctra.h:2748
TOPOLOGY * m_topology
Definition: specctra.h:2834
CLASS(ELEM *aParent)
Definition: specctra.h:2750
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2763
std::string m_class_id
Definition: specctra.h:2823
RULE * m_rules
Definition: specctra.h:2830
STRINGS m_net_ids
Definition: specctra.h:2825
STRINGS m_circuit
circuit descriptor list
Definition: specctra.h:2828
LAYER_RULES m_layer_rules
Definition: specctra.h:2832
Implement a <component_descriptor> in the specctra dsn spec.
Definition: specctra.h:1768
std::string m_image_id
Definition: specctra.h:1808
const std::string & GetImageId() const
Definition: specctra.h:1775
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1797
void SetImageId(const std::string &aImageId)
Definition: specctra.h:1776
COMPONENT(ELEM *aParent)
Definition: specctra.h:1770
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Compare two objects of this type and returns <0, 0, or >0.
Definition: specctra.h:1787
PLACES m_places
Definition: specctra.h:1809
The <component_order_descriptor>.
Definition: specctra.h:2556
COMP_ORDER(ELEM *aParent)
Definition: specctra.h:2558
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2563
STRINGS m_placement_ids
Definition: specctra.h:2582
CONNECT(ELEM *aParent)
Definition: specctra.h:2870
bool via_at_smd_grid_on
Definition: specctra.h:1197
bool via_at_smd
Definition: specctra.h:1196
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1176
CONTROL(ELEM *aParent)
Definition: specctra.h:1165
A <plane_descriptor> in the specctra dsn spec.
Definition: specctra.h:1353
COPPER_PLANE(ELEM *aParent)
Definition: specctra.h:1355
A holder for any DSN class.
Definition: specctra.h:289
void Append(ELEM *aElem)
Definition: specctra.h:322
int FindElem(DSN_T aType, int instanceNum=0)
Find a particular instance number of a given type of ELEM.
Definition: specctra.cpp:3798
ELEM_HOLDER(DSN_T aType, ELEM *aParent=nullptr)
Definition: specctra.h:292
ELEM * operator[](int aIndex) const
Definition: specctra.h:348
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.cpp:3791
ELEM * Replace(int aIndex, ELEM *aElem)
Definition: specctra.h:327
void Insert(int aIndex, ELEM *aElem)
Definition: specctra.h:339
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:360
ELEM * Remove(int aIndex)
Definition: specctra.h:333
void Delete(int aIndex)
Definition: specctra.h:353
ELEM * At(int aIndex) const
Definition: specctra.h:341
boost::ptr_vector< ELEM > ELEM_ARRAY
Definition: specctra.h:358
int Length() const
Return the number of ELEMs in this holder.
Definition: specctra.h:317
A base class for any DSN element class.
Definition: specctra.h:203
ELEM * parent
Definition: specctra.h:276
std::string makeHash()
Return a string which uniquely represents this ELEM among other ELEMs of the same derived class as "t...
Definition: specctra.h:263
const char * Name() const
Definition: specctra.cpp:3767
virtual void Format(OUTPUTFORMATTER *out, int nestLevel)
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.cpp:3781
void SetParent(ELEM *aParent)
Definition: specctra.h:247
DSN_T type
Definition: specctra.h:275
virtual UNIT_RES * GetUnits() const
Return the units for this section.
Definition: specctra.cpp:3772
virtual ~ELEM()
Definition: specctra.cpp:3763
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel)
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:242
DSN_T Type() const
Definition: specctra.h:210
static STRING_FORMATTER sf
Definition: specctra.h:273
LAYER_RULES m_layer_rules
Definition: specctra.h:2546
FROMTO(ELEM *aParent)
Definition: specctra.h:2485
std::string m_fromText
Definition: specctra.h:2539
std::string m_net_id
Definition: specctra.h:2543
std::string m_toText
Definition: specctra.h:2540
DSN_T m_fromto_type
Definition: specctra.h:2542
RULE * m_rules
Definition: specctra.h:2544
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2496
DSN_T m_grid_type
T_via | T_wire | T_via_keepout | T_place | T_snap.
Definition: specctra.h:1515
GRID(ELEM *aParent)
Definition: specctra.h:1481
double m_offset
Definition: specctra.h:1518
DSN_T m_direction
T_x | T_y | -1 for both.
Definition: specctra.h:1517
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1491
double m_dimension
Definition: specctra.h:1516
DSN_T m_image_type
Definition: specctra.h:1519
STRINGS comments
Definition: specctra.h:3342
ANCESTORS ancestors
Definition: specctra.h:3340
time_t time_stamp
Definition: specctra.h:3341
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3314
HISTORY(ELEM *aParent)
Definition: specctra.h:3308
DSN_T m_side
Definition: specctra.h:2096
std::string m_hash
a hash string used by Compare(), not Format()ed/exported.
Definition: specctra.h:2093
KEEPOUTS m_keepouts
Definition: specctra.h:2109
std::string GetImageId()
Definition: specctra.h:2031
static int Compare(IMAGE *lhs, IMAGE *rhs)
Compare two objects of this type and returns <0, 0, or >0.
Definition: specctra.cpp:3845
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition: specctra.h:2081
IMAGE(ELEM *aParent)
Definition: specctra.h:2009
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2055
RULE * m_rules
Definition: specctra.h:2106
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2041
UNIT_RES * m_unit
Definition: specctra.h:2097
std::string m_image_id
Definition: specctra.h:2095
PINS m_pins
Definition: specctra.h:2104
int m_duplicated
no. times this image_id is duplicated
Definition: specctra.h:2111
RULE * m_place_rules
Definition: specctra.h:2107
Used for <keepout_descriptor> and <plane_descriptor>.
Definition: specctra.h:906
void AddWindow(WINDOW *aWindow)
Definition: specctra.h:947
KEEPOUT(ELEM *aParent, DSN_T aType)
Require a DSN_T because this class is used for T_place_keepout, T_via_keepout, T_wire_keepout,...
Definition: specctra.h:913
RULE * m_place_rules
Definition: specctra.h:1015
void SetShape(ELEM *aShape)
Definition: specctra.h:930
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:953
std::string m_name
Definition: specctra.h:1012
WINDOWS m_windows
Definition: specctra.h:1017
ELEM * m_shape
Definition: specctra.h:1026
RULE * m_rules
Definition: specctra.h:1014
int m_sequence_number
Definition: specctra.h:1013
LAYER_NOISE_WEIGHT(ELEM *aParent)
Definition: specctra.h:1332
SPECCTRA_LAYER_PAIRS layer_pairs
Definition: specctra.h:1328
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1337
STRINGS m_layer_ids
Definition: specctra.h:570
LAYER_RULE(ELEM *aParent)
Definition: specctra.h:538
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:549
RULE * m_rule
Definition: specctra.h:571
STRINGS use_net
Definition: specctra.h:1286
PROPERTIES properties
Definition: specctra.h:1288
DSN_T layer_type
one of: T_signal, T_power, T_mixed, T_jumper
Definition: specctra.h:1279
LAYER(ELEM *aParent)
Definition: specctra.h:1204
RULE * rules
Definition: specctra.h:1285
int cost_type
T_length | T_way.
Definition: specctra.h:1284
int direction
[forbidden | high | medium | low | free | <positive_integer> | -1]
Definition: specctra.h:1280
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1220
std::string name
Definition: specctra.h:1278
A <library_descriptor> in the specctra dsn specification.
Definition: specctra.h:2252
PADSTACK * LookupVia(PADSTACK *aVia)
Add the via only if one exactly like it does not already exist in the padstack container.
Definition: specctra.h:2381
PADSTACK * FindPADSTACK(const std::string &aPadstackId)
Search the padstack container by name.
Definition: specctra.h:2399
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2412
void AppendVia(PADSTACK *aVia)
Add aVia to the internal via container.
Definition: specctra.h:2359
IMAGES m_images
Definition: specctra.h:2439
int FindIMAGE(IMAGE *aImage)
Search this LIBRARY for an image which matches the argument.
Definition: specctra.h:2288
PADSTACKS m_padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2441
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition: specctra.h:2427
UNIT_RES * m_unit
Definition: specctra.h:2438
IMAGE * LookupIMAGE(IMAGE *aImage)
Add the image only if one exactly like it does not already exist in the image container.
Definition: specctra.h:2327
void AppendPADSTACK(PADSTACK *aPadstack)
Add the padstack to the padstack container.
Definition: specctra.h:2369
LIBRARY(ELEM *aParent, DSN_T aType=T_library)
Definition: specctra.h:2254
PADSTACKS m_vias
Definition: specctra.h:2442
void AddPadstack(PADSTACK *aPadstack)
Definition: specctra.h:2266
void AppendIMAGE(IMAGE *aImage)
Add the image to the image list.
Definition: specctra.h:2315
int FindVia(PADSTACK *aVia)
Search this LIBRARY for a via which matches the argument.
Definition: specctra.h:2345
NETWORK(ELEM *aParent)
Definition: specctra.h:2843
CLASSLIST m_classes
Definition: specctra.h:2861
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2848
A <net_out_descriptor> of the specctra dsn spec.
Definition: specctra.h:3399
int net_number
Definition: specctra.h:3442
NET_OUT(ELEM *aParent)
Definition: specctra.h:3401
SUPPLY_PINS supply_pins
Definition: specctra.h:3446
std::string net_id
Definition: specctra.h:3441
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3413
RULE * rules
Definition: specctra.h:3443
WIRE_VIAS wire_vias
Definition: specctra.h:3445
WIRES wires
Definition: specctra.h:3444
A <net_descriptor> in the DSN spec.
Definition: specctra.h:2591
FROMTOS m_fromtos
Definition: specctra.h:2710
PIN_REFS m_source
Definition: specctra.h:2698
PIN_REFS m_expose
Definition: specctra.h:2696
PIN_REFS m_load
Definition: specctra.h:2699
RULE * m_rules
Definition: specctra.h:2706
PIN_REFS m_noexpose
Definition: specctra.h:2697
std::string m_net_id
Definition: specctra.h:2689
int FindPIN_REF(const std::string &aComponent)
Definition: specctra.h:2613
int m_net_number
Definition: specctra.h:2691
LAYER_RULES m_layer_rules
Definition: specctra.h:2708
DSN_T m_type
T_fix | T_normal.
Definition: specctra.h:2702
PIN_REFS m_pins
Definition: specctra.h:2694
DSN_T m_supply
T_power | T_ground.
Definition: specctra.h:2704
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2624
NET(ELEM *aParent)
Definition: specctra.h:2593
bool m_unassigned
Definition: specctra.h:2690
COMP_ORDER * m_comp_order
Definition: specctra.h:2712
PIN_REFS m_terminator
Definition: specctra.h:2700
DSN_T m_pins_type
T_pins | T_order, type of field 'pins' below.
Definition: specctra.h:2693
Hold either a via or a pad definition.
Definition: specctra.h:2121
std::string m_via_id
Definition: specctra.h:2228
const std::string & GetPadstackId()
Definition: specctra.h:2144
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2171
std::string m_hash
a hash string used by Compare(), not Format()ed/exported.
Definition: specctra.h:2218
DSN_T m_attach
Definition: specctra.h:2227
DSN_T m_absolute
Definition: specctra.h:2226
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2159
PADSTACK()
Cannot take ELEM* aParent because PADSTACKSET confuses this with a copy constructor and causes havoc.
Definition: specctra.h:2128
std::string m_padstack_id
Definition: specctra.h:2220
void SetPadstackId(const char *aPadstackId)
Definition: specctra.h:2154
RULE * m_rules
Definition: specctra.h:2230
DSN_T m_rotate
Definition: specctra.h:2225
static int Compare(PADSTACK *lhs, PADSTACK *rhs)
Compare two objects of this type and returns <0, 0, or >0.
Definition: specctra.cpp:3824
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition: specctra.h:2207
UNIT_RES * m_unit
Definition: specctra.h:2221
A configuration record per the SPECCTRA DSN file spec.
Definition: specctra.h:370
std::string host_version
Definition: specctra.h:394
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.cpp:3893
bool routes_include_image_conductor
Definition: specctra.h:386
std::string host_cad
Definition: specctra.h:393
bool routes_include_guides
Definition: specctra.h:385
bool case_sensitive
Definition: specctra.h:382
bool wires_include_testpoint
Definition: specctra.h:383
STRINGS constants
This holds pairs of strings, one pair for each constant definition.
Definition: specctra.h:391
bool via_rotate_first
Definition: specctra.h:387
char string_quote
Definition: specctra.h:380
bool routes_include_testpoint
Definition: specctra.h:384
bool generated_by_freeroute
Definition: specctra.h:388
bool space_in_quoted_tokens
Definition: specctra.h:381
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
Definition: specctra.h:583
DSN_T aperture_type
Definition: specctra.h:654
POINTS points
Definition: specctra.h:653
POINTS & GetPoints()
Definition: specctra.h:598
double aperture_width
Definition: specctra.h:651
PATH(ELEM *aParent, DSN_T aType=T_path)
Definition: specctra.h:586
void SetLayerId(const std::string &aLayerId)
Definition: specctra.h:600
void SetAperture(double aWidth)
Definition: specctra.h:605
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:610
void AppendPoint(const POINT &aPoint)
Definition: specctra.h:593
std::string layer_id
Definition: specctra.h:650
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3205
UNIT_RES * m_unit
Definition: specctra.h:3255
UNIT_RES * m_resolution
Definition: specctra.h:3254
PCB(ELEM *aParent=nullptr)
Definition: specctra.h:3180
std::string m_pcbname
Definition: specctra.h:3252
NETWORK * m_network
Definition: specctra.h:3259
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition: specctra.h:3238
PLACEMENT * m_placement
Definition: specctra.h:3257
STRUCTURE * m_structure
Definition: specctra.h:3256
PARSER * m_parser
Definition: specctra.h:3253
WIRING * m_wiring
Definition: specctra.h:3260
LIBRARY * m_library
Definition: specctra.h:3258
PIN(ELEM *aParent)
Definition: specctra.h:1956
void SetVertex(const POINT &aPoint)
Definition: specctra.h:1970
POINT m_vertex
Definition: specctra.h:1996
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1976
int m_kiNetCode
KiCad netcode.
Definition: specctra.h:1998
void SetRotation(double aRotation)
Definition: specctra.h:1964
double m_rotation
Definition: specctra.h:1993
std::string m_pin_id
Definition: specctra.h:1995
std::string m_padstack_id
Definition: specctra.h:1992
bool m_isRotated
Definition: specctra.h:1994
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1852
DSN_T m_flip_style
Definition: specctra.h:1880
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition: specctra.h:1867
UNIT_RES * m_unit
Definition: specctra.h:1878
COMPONENT * LookupCOMPONENT(const std::string &imageName)
Look up a COMPONENT by name.
Definition: specctra.h:1838
PLACEMENT(ELEM *aParent)
Definition: specctra.h:1818
COMPONENTS m_components
Definition: specctra.h:1882
Implement a <placement_reference> in the specctra dsn spec.
Definition: specctra.h:1688
void SetVertex(const POINT &aVertex)
Definition: specctra.h:1716
DSN_T m_status
Definition: specctra.h:1743
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.cpp:3930
bool m_hasVertex
Definition: specctra.h:1739
POINT m_vertex
Definition: specctra.h:1740
DSN_T m_mirror
Definition: specctra.h:1742
void SetRotation(double aRotation)
Definition: specctra.h:1723
RULE * m_rules
Definition: specctra.h:1754
DSN_T m_lock_type
Definition: specctra.h:1751
DSN_T m_side
Definition: specctra.h:1735
double m_rotation
Definition: specctra.h:1737
std::string m_logical_part
Definition: specctra.h:1745
std::string m_part_number
Definition: specctra.h:1758
REGION * m_region
Definition: specctra.h:1755
std::string m_component_id
reference designator
Definition: specctra.h:1733
PLACE(ELEM *aParent)
Definition: specctra.h:1690
RULE * m_place_rules
Definition: specctra.h:1747
PROPERTIES m_properties
Definition: specctra.h:1749
std::string layer_id
Definition: specctra.h:837
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:791
void SetStart(const POINT &aStart)
Definition: specctra.h:810
QARC(ELEM *aParent)
Definition: specctra.h:785
void SetLayerId(std::string &aLayerId)
Definition: specctra.h:805
void SetCenter(const POINT &aCenter)
Definition: specctra.h:826
void SetEnd(const POINT &aEnd)
Definition: specctra.h:818
double aperture_width
Definition: specctra.h:838
POINT vertex[3]
Definition: specctra.h:839
POINT GetOrigin()
Definition: specctra.h:461
std::string layer_id
Definition: specctra.h:481
POINT point1
Definition: specctra.h:484
RECTANGLE(ELEM *aParent)
Definition: specctra.h:442
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:464
void SetLayerId(std::string &aLayerId)
Definition: specctra.h:447
void SetCorners(const POINT &aPoint0, const POINT &aPoint1)
Definition: specctra.h:452
POINT point0
one of two opposite corners
Definition: specctra.h:483
POINT GetEnd()
Definition: specctra.h:462
RULE * m_rules
Definition: specctra.h:1474
RECTANGLE * m_rectangle
Definition: specctra.h:1466
REGION(ELEM *aParent)
Definition: specctra.h:1425
PATH * m_polygon
Definition: specctra.h:1467
std::string m_region_id
Definition: specctra.h:1463
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1440
STRUCTURE_OUT * structure_out
Definition: specctra.h:3514
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition: specctra.h:3473
NET_OUTS net_outs
Definition: specctra.h:3516
ROUTE(ELEM *aParent)
Definition: specctra.h:3455
UNIT_RES * resolution
Definition: specctra.h:3512
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3481
LIBRARY * library
Definition: specctra.h:3515
PARSER * parser
Definition: specctra.h:3513
A <rule_descriptor> in the specctra dsn spec.
Definition: specctra.h:492
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:500
RULE(ELEM *aParent, DSN_T aType)
Definition: specctra.h:495
STRINGS m_rules
rules are saved in std::string form.
Definition: specctra.h:530
A <session_file_descriptor> in the specctra dsn spec.
Definition: specctra.h:3574
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3595
SESSION(ELEM *aParent=nullptr)
Definition: specctra.h:3576
std::string session_id
Definition: specctra.h:3623
PLACEMENT * placement
Definition: specctra.h:3628
HISTORY * history
Definition: specctra.h:3626
STRUCTURE * structure
Definition: specctra.h:3627
std::string base_design
Definition: specctra.h:3624
ROUTE * route
Definition: specctra.h:3630
WAS_IS * was_is
Definition: specctra.h:3629
A "(shape ..)" element in the specctra dsn spec.
Definition: specctra.h:1894
SHAPE(ELEM *aParent, DSN_T aType=T_shape)
Takes a DSN_T aType of T_outline.
Definition: specctra.h:1899
void SetConnect(DSN_T aConnect)
Definition: specctra.h:1905
DSN_T m_connect
Definition: specctra.h:1938
WINDOWS m_windows
Definition: specctra.h:1949
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1910
A DSN data tree, usually coming from a DSN file.
Definition: specctra.h:3646
wxString m_filename
Definition: specctra.h:3985
PADSTACK * makeVia(const ::PCB_VIA *aVia)
Make any kind of PADSTACK using the given KiCad VIA.
void doUNIT(UNIT_RES *growth)
Definition: specctra.cpp:587
void doPCB(PCB *growth)
Definition: specctra.cpp:288
int m_top_via_layer
specctra cu layers, 0 based index:
Definition: specctra.h:4011
void doCOMPONENT(COMPONENT *growth)
Definition: specctra.cpp:2003
IMAGE * makeIMAGE(BOARD *aBoard, FOOTPRINT *aFootprint)
Allocates an I::MAGE on the heap and creates all the PINs according to the PADs in the FOOTPRINT.
void doWAS_IS(WAS_IS *growth)
Definition: specctra.cpp:3453
void doPLACEMENT(PLACEMENT *growth)
Definition: specctra.cpp:2035
void doNET_OUT(NET_OUT *growth)
Definition: specctra.cpp:3594
void buildLayerMaps(BOARD *aBoard)
Create a few data translation structures for layer name and number mapping between the DSN::PCB struc...
Definition: specctra.cpp:76
PCB_TRACK * makeTRACK(WIRE *wire, PATH *aPath, int aPointIndex, int aNetcode)
Create a TRACK form the #PATH and BOARD info.
void doCLASS(CLASS *growth)
Definition: specctra.cpp:2689
void SetSESSION(SESSION *aSession)
Delete any existing SESSION and replaces it with the given one.
Definition: specctra.h:3697
void doSTRUCTURE_OUT(STRUCTURE_OUT *growth)
Definition: specctra.cpp:790
std::map< int, PCB_LAYER_ID > m_pcbLayer2kicad
maps PCB layer number to BOARD layer numbers
Definition: specctra.h:3995
void doCIRCLE(CIRCLE *growth)
Definition: specctra.cpp:1158
void doANCESTOR(ANCESTOR *growth)
Definition: specctra.cpp:3265
void doLAYER_NOISE_WEIGHT(LAYER_NOISE_WEIGHT *growth)
Definition: specctra.cpp:625
SESSION * GetSESSION()
Definition: specctra.h:3703
void ExportPCB(const wxString &aFilename, bool aNameChange=false)
Write the internal PCB instance out as a SPECTRA DSN format file.
Definition: specctra.cpp:3704
void doCLASS_CLASS(CLASS_CLASS *growth)
Definition: specctra.cpp:1694
void doSESSION(SESSION *growth)
Definition: specctra.cpp:3363
void doWINDOW(WINDOW *growth)
Definition: specctra.cpp:969
UNIT_RES * m_routeResolution
used during FromSESSION() only, memory for it is not owned here.
Definition: specctra.h:3998
SHAPE_POLY_SET m_brd_outlines
Definition: specctra.h:3983
void doSHAPE(SHAPE *growth)
Definition: specctra.cpp:2205
BOARD * m_sessionBoard
a copy to avoid passing as an argument, memory for it is not owned here.
Definition: specctra.h:4001
void FlipFOOTPRINTs(BOARD *aBoard)
Flip the footprints which are on the back side of the board to the front.
void doQARC(QARC *growth)
Definition: specctra.cpp:1189
void doRESOLUTION(UNIT_RES *growth)
Definition: specctra.cpp:558
PCB * GetPCB()
Definition: specctra.h:3692
void LoadPCB(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "design" file.
Definition: specctra.cpp:249
void doSTRINGPROP(STRINGPROP *growth)
Definition: specctra.cpp:1216
STRINGS m_layerIds
indexed by PCB layer number
Definition: specctra.h:3992
void doBOUNDARY(BOUNDARY *growth)
Definition: specctra.cpp:1028
void doSPECCTRA_LAYER_PAIR(SPECCTRA_LAYER_PAIR *growth)
Definition: specctra.cpp:608
virtual ~SPECCTRA_DB()
Definition: specctra.h:3670
bool m_footprintsAreFlipped
Definition: specctra.h:3988
SESSION * m_session
Definition: specctra.h:3984
void doRECTANGLE(RECTANGLE *growth)
Definition: specctra.cpp:1129
void deleteNETs()
Delete all the NETs that may be in here.
Definition: specctra.h:3943
void doREGION(REGION *growth)
Definition: specctra.cpp:1619
void fillBOUNDARY(BOARD *aBoard, BOUNDARY *aBoundary)
Make the board perimeter for the DSN file by filling the BOUNDARY element in the specctra element tre...
void ExportSESSION(const wxString &aFilename)
Write the internal #SESSION instance out as a #SPECTRA DSN format file.
Definition: specctra.cpp:3718
void doWIRE(WIRE *growth)
Definition: specctra.cpp:2957
static const KICAD_T scanPADs[]
Definition: specctra.h:4003
PADSTACK * makePADSTACK(BOARD *aBoard, PAD *aPad)
Create a PADSTACK which matches the given pad.
void SetPCB(PCB *aPcb)
Delete any existing PCB and replaces it with the given one.
Definition: specctra.h:3686
void doTOKPROP(TOKPROP *growth)
Definition: specctra.cpp:1224
void doIMAGE(IMAGE *growth)
Definition: specctra.cpp:2293
void doCONNECT(CONNECT *growth)
Definition: specctra.cpp:934
void doCOMP_ORDER(COMP_ORDER *growth)
Definition: specctra.cpp:2848
static PCB * MakePCB()
Make a PCB with all the default ELEMs and parts on the heap.
Definition: specctra.cpp:3729
void doTOPOLOGY(TOPOLOGY *growth)
Definition: specctra.cpp:2650
void doKEEPOUT(KEEPOUT *growth)
Definition: specctra.cpp:835
void doRULE(RULE *growth)
Definition: specctra.cpp:1481
void doPATH(PATH *growth)
Definition: specctra.cpp:1078
void doPIN(PIN *growth)
Definition: specctra.cpp:2395
void doSUPPLY_PIN(SUPPLY_PIN *growth)
Definition: specctra.cpp:3666
void doLAYER(LAYER *growth)
Definition: specctra.cpp:1341
bool BuiltBoardOutlines(BOARD *aBoard)
Build the board outlines and store it in m_brd_outlines.
void LoadSESSION(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "session" file.
Definition: specctra.cpp:268
void doLIBRARY(LIBRARY *growth)
Definition: specctra.cpp:2446
PADSTACK * makeVia(int aCopperDiameter, int aDrillDiameter, int aTopLayer, int aBotLayer)
Make a round through hole PADSTACK using the given KiCad diameter in deci-mils.
STRING_FORMATTER m_sf
Definition: specctra.h:3990
std::map< PCB_LAYER_ID, int > m_kicadLayer2pcb
maps BOARD layer number to PCB layer numbers
Definition: specctra.h:3994
std::vector< NET * > m_nets
we don't want ownership here permanently, so we don't use boost::ptr_vector
Definition: specctra.h:4008
void doVIA(VIA *growth)
Definition: specctra.cpp:1237
void doFROMTO(FROMTO *growth)
Definition: specctra.cpp:2864
void doPLACE(PLACE *growth)
Definition: specctra.cpp:1868
PADSTACKSET m_padstackset
Definition: specctra.h:4005
void doGRID(GRID *growth)
Definition: specctra.cpp:1766
void doLAYER_RULE(LAYER_RULE *growth)
Definition: specctra.cpp:1843
void FromSESSION(BOARD *aBoard)
Add the entire #SESSION info to a BOARD but does not write it out.
void exportNETCLASS(const std::shared_ptr< NETCLASS > &aNetClass, BOARD *aBoard)
Export aNetClass to the DSN file.
void doWIRE_VIA(WIRE_VIA *growth)
Definition: specctra.cpp:3091
void doCLASSES(CLASSES *growth)
Definition: specctra.cpp:1742
void readCOMPnPIN(std::string *component_id, std::string *pid_id)
Read a <pin_reference> and splits it into the two parts which are on either side of the hyphen.
Definition: specctra.cpp:111
PCB_VIA * makeVIA(WIRE_VIA *aVia, PADSTACK *aPadstack, const POINT &aPoint, int aNetCode, int aViaDrillDefault)
Instantiate a KiCad VIA on the heap and initializes it with internal values consistent with the given...
PCB_ARC * makeARC(WIRE *wire, QARC *aQarc, int aNetcode)
Create an ARC form the #PATH and BOARD info.
void FromBOARD(BOARD *aBoard)
Add the entire BOARD to the PCB but does not write it out.
std::string m_quote_char
Definition: specctra.h:3986
void doPARSER(PARSER *growth)
Definition: specctra.cpp:403
void doNETWORK(NETWORK *growth)
Definition: specctra.cpp:2802
void doNET(NET *growth)
Definition: specctra.cpp:2502
void RevertFOOTPRINTs(BOARD *aBoard)
Flip the footprints which were on the back side of the board back to the back.
void doSTRUCTURE(STRUCTURE *growth)
Definition: specctra.cpp:645
int findLayerName(const std::string &aLayerName) const
Return the PCB layer index for a given layer name, within the specctra sessionfile.
Definition: specctra.cpp:99
void doROUTE(ROUTE *growth)
Definition: specctra.cpp:3494
void readTIME(time_t *time_stamp)
Read a <time_stamp> which consists of 8 lexer tokens: "month date hour : minute : second year".
Definition: specctra.cpp:153
void doPADSTACK(PADSTACK *growth)
Definition: specctra.cpp:2093
void doWIRING(WIRING *growth)
Definition: specctra.cpp:3206
static const KEYWORD keywords[]
specctra DSN keywords
Definition: specctra.h:3980
void doHISTORY(HISTORY *growth)
Definition: specctra.cpp:3304
void doCONTROL(CONTROL *growth)
Definition: specctra.cpp:1268
void doPROPERTIES(PROPERTIES *growth)
Definition: specctra.cpp:1318
SPECCTRA_LAYER_PAIR(ELEM *aParent)
Definition: specctra.h:1297
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1303
A container for a single property whose value is a string.
Definition: specctra.h:1399
std::string value
Definition: specctra.h:1418
STRINGPROP(ELEM *aParent, DSN_T aType)
Definition: specctra.h:1401
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1406
STRUCTURE_OUT(ELEM *aParent)
Definition: specctra.h:1526
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1537
RULE * m_place_rules
Definition: specctra.h:1677
UNIT_RES * m_unit
Definition: specctra.h:1658
KEEPOUTS m_keepouts
Definition: specctra.h:1670
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition: specctra.h:1647
boost::ptr_vector< GRID > GRIDS
Definition: specctra.h:1679
BOUNDARY * m_boundary
Definition: specctra.h:1664
LAYER_NOISE_WEIGHT * m_layer_noise_weight
Definition: specctra.h:1662
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1600
void SetBOUNDARY(BOUNDARY *aBoundary)
Definition: specctra.h:1582
COPPER_PLANES m_planes
Definition: specctra.h:1672
REGIONS m_regions
Definition: specctra.h:1675
BOUNDARY * m_place_boundary
Definition: specctra.h:1665
LAYERS m_layers
Definition: specctra.h:1660
STRUCTURE(ELEM *aParent)
Definition: specctra.h:1557
void SetPlaceBOUNDARY(BOUNDARY *aBoundary)
Definition: specctra.h:1591
CONTROL * m_control
Definition: specctra.h:1667
boost::ptr_vector< REGION > REGIONS
Definition: specctra.h:1674
RULE * m_rules
Definition: specctra.h:1668
A <supply_pin_descriptor> in the specctra dsn spec.
Definition: specctra.h:3350
std::string net_id
Definition: specctra.h:3389
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3357
PIN_REFS pin_refs
Definition: specctra.h:3388
SUPPLY_PIN(ELEM *aParent)
Definition: specctra.h:3352
A container for a single property whose value is another DSN_T token.
Definition: specctra.h:1372
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1381
TOKPROP(ELEM *aParent, DSN_T aType)
Definition: specctra.h:1374
DSN_T value
Definition: specctra.h:1389
FROMTOS m_fromtos
Definition: specctra.h:2738
COMP_ORDERS m_comp_orders
Definition: specctra.h:2740
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2726
TOPOLOGY(ELEM *aParent)
Definition: specctra.h:2721
A holder for either a T_unit or T_resolution object which are usually mutually exclusive in the dsn g...
Definition: specctra.h:403
UNIT_RES(ELEM *aParent, DSN_T aType)
Definition: specctra.h:412
static UNIT_RES Default
A static instance which holds the default units of T_inch and 2540000.
Definition: specctra.h:410
DSN_T units
Definition: specctra.h:433
DSN_T GetEngUnits() const
Definition: specctra.h:419
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:422
int GetValue() const
Definition: specctra.h:420
A <via_descriptor> in the specctra dsn spec.
Definition: specctra.h:1039
STRINGS m_spares
Definition: specctra.h:1097
STRINGS m_padstacks
Definition: specctra.h:1096
VIA(ELEM *aParent)
Definition: specctra.h:1042
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:1052
void AppendVia(const char *aViaName)
Definition: specctra.h:1047
A <was_is_descriptor> in the specctra dsn spec.
Definition: specctra.h:3544
PIN_PAIRS pin_pairs
Definition: specctra.h:3566
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3551
WAS_IS(ELEM *aParent)
Definition: specctra.h:3546
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:875
WINDOW(ELEM *aParent, DSN_T aType=T_window)
Definition: specctra.h:847
void SetShape(ELEM *aShape)
Definition: specctra.h:858
ELEM * shape
Definition: specctra.h:893
A <wire_via_descriptor> in the specctra dsn spec.
Definition: specctra.h:2988
std::string m_net_id
Definition: specctra.h:3119
std::string m_padstack_id
Definition: specctra.h:3117
int m_via_number
Definition: specctra.h:3120
DSN_T m_via_type
Definition: specctra.h:3121
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3004
WIRE_VIA(ELEM *aParent)
Definition: specctra.h:2990
std::string m_virtual_pin_name
Definition: specctra.h:3123
const std::string & GetPadstackId()
Definition: specctra.h:2999
STRINGS m_contact_layers
Definition: specctra.h:3124
DSN_T m_attr
Definition: specctra.h:3122
POINTS m_vertexes
Definition: specctra.h:3118
A <wire_shape_descriptor> in the specctra dsn spec.
Definition: specctra.h:2879
CONNECT * m_connect
Definition: specctra.h:2977
DSN_T m_wire_type
Definition: specctra.h:2973
ELEM * m_shape
Definition: specctra.h:2969
WIRE(ELEM *aParent)
Definition: specctra.h:2881
bool m_supply
Definition: specctra.h:2978
WINDOWS m_windows
Definition: specctra.h:2976
void SetShape(ELEM *aShape)
Definition: specctra.h:2899
int m_turret
Definition: specctra.h:2972
std::string m_net_id
Definition: specctra.h:2971
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2914
std::string m_shield
Definition: specctra.h:2975
DSN_T m_attr
Definition: specctra.h:2974
A <wiring_descriptor> in the specctra dsn spec.
Definition: specctra.h:3135
UNIT_RES * unit
Definition: specctra.h:3171
WIRING(ELEM *aParent)
Definition: specctra.h:3137
WIRES wires
Definition: specctra.h:3172
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:3148
WIRE_VIAS wire_vias
Definition: specctra.h:3173
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition: specctra.h:3160
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:45
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
int PRINTF_FUNC_N Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:460
static const char * GetQuoteChar(const char *wrapee, const char *quote_char)
Perform quote character need determination according to the Specctra DSN specification.
Definition: richio.cpp:382
Definition: pad.h:54
Helper class to centralize the paths used throughout kicad.
Definition: paths.h:37
Represent a set of closed polygons.
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:449
void StripUseless()
Removes whitespace, '(', and ')' from the string.
Definition: richio.cpp:564
const std::string & GetString()
Definition: richio.h:472
void Clear()
Clear the buffer and empties the internal string.
Definition: richio.h:462
This source file implements export and import capabilities to the specctra dsn file format.
Definition: specctra.cpp:63
boost::ptr_vector< KEEPOUT > KEEPOUTS
Definition: specctra.h:1032
std::vector< std::string > STRINGS
Definition: specctra.h:166
boost::ptr_vector< NET_OUT > NET_OUTS
Definition: specctra.h:3449
boost::ptr_vector< PATH > PATHS
Definition: specctra.h:657
boost::ptr_vector< WINDOW > WINDOWS
Definition: specctra.h:899
boost::ptr_vector< CLASS > CLASSLIST
Definition: specctra.h:2837
std::vector< PIN_REF > PIN_REFS
Definition: specctra.h:2479
boost::ptr_vector< PIN > PINS
Definition: specctra.h:2001
boost::ptr_vector< COMP_ORDER > COMP_ORDERS
Definition: specctra.h:2585
std::vector< PIN_PAIR > PIN_PAIRS
Definition: specctra.h:3537
bool operator<(const PADSTACK &lhs, const PADSTACK &rhs)
Used by the PADSTACKSET boost::ptr_set below.
Definition: specctra.h:2239
const char * GetTokenText(T aTok)
The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
Definition: specctra.cpp:70
boost::ptr_vector< WIRE > WIRES
Definition: specctra.h:2981
boost::ptr_vector< SUPPLY_PIN > SUPPLY_PINS
Definition: specctra.h:3392
std::vector< PROPERTY > PROPERTIES
Definition: specctra.h:192
boost::ptr_vector< PADSTACK > PADSTACKS
Definition: specctra.h:2233
std::vector< POINT > POINTS
Definition: specctra.h:167
void ExportBoardToSpecctraFile(BOARD *aBoard, const wxString &aFullFilename)
Helper method to export board to DSN file.
boost::ptr_vector< PLACE > PLACES
Definition: specctra.h:1761
boost::ptr_vector< IMAGE > IMAGES
Definition: specctra.h:2114
boost::ptr_vector< LAYER > LAYERS
Definition: specctra.h:1291
boost::ptr_vector< FROMTO > FROMTOS
Definition: specctra.h:2549
boost::ptr_vector< ANCESTOR > ANCESTORS
Definition: specctra.h:3302
boost::ptr_vector< WIRE_VIA > WIRE_VIAS
Definition: specctra.h:3128
boost::ptr_vector< COPPER_PLANE > COPPER_PLANES
Definition: specctra.h:1363
boost::ptr_vector< SPECCTRA_LAYER_PAIR > SPECCTRA_LAYER_PAIRS
Definition: specctra.h:1321
boost::ptr_vector< COMPONENT > COMPONENTS
Definition: specctra.h:1812
bool ImportSpecctraSession(BOARD *aBoard, const wxString &fullFileName)
Helper method to import SES file to a board.
boost::ptr_vector< NET > NETS
Definition: specctra.h:2715
boost::ptr_vector< LAYER_RULE > LAYER_RULES
Definition: specctra.h:575
boost::ptr_set< PADSTACK > PADSTACKSET
Definition: specctra.h:3639
DSN::T DSN_T
Definition: specctra.h:49
Used within the WAS_IS class below to hold a pair of PIN_REFs and corresponds to the (pins was is) co...
Definition: specctra.h:3526
PIN_REF is
Definition: specctra.h:3534
PIN_PAIR(ELEM *aParent=nullptr)
Definition: specctra.h:3527
PIN_REF was
Definition: specctra.h:3533
A <pin_reference> definition in the specctra dsn spec.
Definition: specctra.h:2450
std::string pin_id
Definition: specctra.h:2476
PIN_REF(ELEM *aParent)
Definition: specctra.h:2451
int FormatIt(OUTPUTFORMATTER *out, int nestLevel)
Like Format() but is not virtual.
Definition: specctra.h:2462
std::string component_id
Definition: specctra.h:2475
A point in the SPECCTRA DSN coordinate system.
Definition: specctra.h:103
POINT & operator=(const POINT &other)
Definition: specctra.h:131
void FixNegativeZero()
Change negative zero to positive zero in the IEEE floating point storage format.
Definition: specctra.h:144
double y
Definition: specctra.h:105
bool operator!=(const POINT &other) const
Definition: specctra.h:119
double x
Definition: specctra.h:104
bool operator==(const POINT &other) const
Definition: specctra.h:114
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:160
POINT(double aX, double aY)
Definition: specctra.h:109
POINT & operator+=(const POINT &other)
Definition: specctra.h:124
std::string value
Definition: specctra.h:172
std::string name
Definition: specctra.h:171
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:181
Hold a keyword string and its unique integer token.
Definition: dsnlexer.h:41
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78