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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef SPECCTRA_H_
22#define SPECCTRA_H_
23
24
25// see http://www.boost.org/libs/ptr_container/doc/ptr_sequence_adapter.html
26#include <boost/ptr_container/ptr_vector.hpp>
27
28// see http://www.boost.org/libs/ptr_container/doc/ptr_set.html
29#include <boost/ptr_container/ptr_set.hpp>
30
31#include <specctra_import_export/specctra_lexer.h>
32
33#include <map>
34#include <memory>
35
36#include <core/typeinfo.h>
38#include <layer_ids.h>
39
40// all outside the DSN namespace:
41class BOARD;
42class COMMIT;
43class PAD;
44class PCB_TRACK;
45class PCB_ARC;
46class PCB_VIA;
47class NETCLASS;
48class FOOTPRINT;
49class SHAPE_POLY_SET;
50
51typedef DSN::T DSN_T;
52
53
76namespace DSN {
77
78
79class SPECCTRA_DB;
80
81
87void ExportBoardToSpecctraFile( BOARD* aBoard, const wxString& aFullFilename );
88
89
96const char* GetTokenText( T aTok );
97
98
104struct POINT
105{
106 double x;
107 double y;
108
109 POINT() { x=0.0; y=0.0; }
110
111 POINT( double aX, double aY ) :
112 x(aX), y(aY)
113 {
114 }
115
116 bool operator==( const POINT& other ) const
117 {
118 return x==other.x && y==other.y;
119 }
120
121 bool operator!=( const POINT& other ) const
122 {
123 return !( *this == other );
124 }
125
126 POINT& operator+=( const POINT& other )
127 {
128 x += other.x;
129 y += other.y;
130 return *this;
131 }
132
133 POINT& operator=( const POINT& other )
134 {
135 x = other.x;
136 y = other.y;
137 return *this;
138 }
139
147 {
148 if( x == -0.0 )
149 x = 0.0;
150
151 if( y == -0.0 )
152 y = 0.0;
153 }
154
162 void Format( OUTPUTFORMATTER* out, int nestLevel ) const
163 {
164 out->Print( nestLevel, " %.6g %.6g", x, y );
165 }
166};
167
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 );
267 sf.StripUseless();
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
391 std::vector<std::string> constants;
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;
455 point0.FixNegativeZero();
456
457 point1 = aPoint1;
458 point1.FixNegativeZero();
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( const std::string& rule : m_rules )
518 out->Print( nestLevel+1, "%s\n", rule.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
530 std::vector<std::string> m_rules;
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( const std::string& layer : m_layer_ids )
554 {
555 const char* quote = out->GetQuoteChar( layer.c_str() );
556 out->Print( 0, " %s%s%s", quote, layer.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
570 std::vector<std::string> m_layer_ids;
572};
573
574
579class PATH : public ELEM
580{
581public:
582
583 PATH( ELEM* aParent, DSN_T aType = T_path ) :
584 ELEM( aType, aParent )
585 {
586 aperture_width = 0.0;
587 aperture_type = T_round;
588 }
589
590 void AppendPoint( const POINT& aPoint )
591 {
592 points.push_back( aPoint );
593 }
594
595 std::vector<POINT>& GetPoints() {return points; }
596
597 void SetLayerId( const std::string& aLayerId )
598 {
599 layer_id = aLayerId;
600 }
601
602 void SetAperture( double aWidth )
603 {
604 aperture_width = aWidth;
605 }
606
607 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
608 {
609 const char* newline = nestLevel ? "\n" : "";
610
611 const char* quote = out->GetQuoteChar( layer_id.c_str() );
612
613 const int RIGHTMARGIN = 70;
614 int perLine = out->Print( nestLevel, "(%s %s%s%s %.6g",
615 Name(),
616 quote, layer_id.c_str(), quote,
618
619 int wrapNest = std::max( nestLevel+1, 6 );
620
621 for( const POINT& pt : points )
622 {
623 if( perLine > RIGHTMARGIN )
624 {
625 out->Print( 0, "\n" );
626 perLine = out->Print( wrapNest, "%s", "" );
627 }
628 else
629 {
630 perLine += out->Print( 0, " " );
631 }
632
633 perLine += out->Print( 0, "%.6g %.6g", pt.x, pt.y );
634 }
635
636 if( aperture_type == T_square )
637 {
638 out->Print( 0, "(aperture_type square)" );
639 }
640
641 out->Print( 0, ")%s", newline );
642 }
643
644private:
645 friend class SPECCTRA_DB;
646
647 std::string layer_id;
649
650 std::vector<POINT> points;
652};
653
654typedef boost::ptr_vector<PATH> PATHS;
655
656
657class BOUNDARY : public ELEM
658{
659public:
660
661 BOUNDARY( ELEM* aParent, DSN_T aType = T_boundary ) :
662 ELEM( aType, aParent )
663 {
664 rectangle = nullptr;
665 }
666
668 {
669 delete rectangle;
670 }
671
675 void GetCorners( std::vector<double>& aBuffer )
676 {
677 if( rectangle )
678 {
679 aBuffer.push_back( rectangle->GetOrigin().x );
680 aBuffer.push_back( rectangle->GetOrigin().y );
681
682 aBuffer.push_back( rectangle->GetOrigin().x );
683 aBuffer.push_back( rectangle->GetEnd().y );
684
685 aBuffer.push_back( rectangle->GetEnd().x );
686 aBuffer.push_back( rectangle->GetEnd().y );
687
688 aBuffer.push_back( rectangle->GetEnd().x );
689 aBuffer.push_back( rectangle->GetOrigin().y );
690 }
691 else
692 {
693 for( PATH& path : paths )
694 {
695 for( const POINT& pt : path.GetPoints() )
696 {
697 aBuffer.push_back( pt.x );
698 aBuffer.push_back( pt.y );
699 }
700 }
701 }
702 }
703
704
705 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
706 {
707 out->Print( nestLevel, "(%s\n", Name() );
708
709 if( rectangle )
710 rectangle->Format( out, nestLevel+1 );
711 else
712 {
713 for( PATH& path : paths )
714 path.Format( out, nestLevel+1 );
715 }
716
717 out->Print( nestLevel, ")\n" );
718 }
719
720private:
721 friend class SPECCTRA_DB;
722
723 // only one or the other of these two is used, not both
726};
727
728
729class CIRCLE : public ELEM
730{
731public:
732 CIRCLE( ELEM* aParent ) :
733 ELEM( T_circle, aParent )
734 {
735 diameter = 0.0;
736 }
737
738 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
739 {
740 const char* newline = nestLevel ? "\n" : "";
741
742 const char* quote = out->GetQuoteChar( layer_id.c_str() );
743 out->Print( nestLevel, "(%s %s%s%s %.6g", Name(), quote, layer_id.c_str(), quote, diameter );
744
745 if( vertex.x!=0.0 || vertex.y!=0.0 )
746 out->Print( 0, " %.6g %.6g)%s", vertex.x, vertex.y, newline );
747 else
748 out->Print( 0, ")%s", newline );
749 }
750
751 void SetLayerId( const std::string& aLayerId )
752 {
753 layer_id = aLayerId;
754 }
755
756 void SetDiameter( double aDiameter )
757 {
758 diameter = aDiameter;
759 }
760
761 void SetVertex( const POINT& aVertex )
762 {
763 vertex = aVertex;
764 }
765
766private:
767 friend class SPECCTRA_DB;
768
769 std::string layer_id;
770
771 double diameter;
772 POINT vertex; // POINT's constructor sets to (0,0)
773};
774
775
776class QARC : public ELEM
777{
778public:
779 QARC( ELEM* aParent ) :
780 ELEM( T_qarc, aParent )
781 {
782 aperture_width = 0.0;
783 }
784
785 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
786 {
787 const char* newline = nestLevel ? "\n" : "";
788
789 const char* quote = out->GetQuoteChar( layer_id.c_str() );
790 out->Print( nestLevel, "(%s %s%s%s %.6g", Name(), quote, layer_id.c_str(), quote,
792
793 for( const POINT& pt : vertex )
794 out->Print( 0, " %.6g %.6g", pt.x, pt.y );
795
796 out->Print( 0, ")%s", newline );
797 }
798
799 void SetLayerId( std::string& aLayerId )
800 {
801 layer_id = aLayerId;
802 }
803
804 void SetStart( const POINT& aStart )
805 {
806 vertex[0] = aStart;
807
808 // no -0.0 on the printouts!
809 vertex[0].FixNegativeZero();
810 }
811
812 void SetEnd( const POINT& aEnd )
813 {
814 vertex[1] = aEnd;
815
816 // no -0.0 on the printouts!
817 vertex[1].FixNegativeZero();
818 }
819
820 void SetCenter( const POINT& aCenter )
821 {
822 vertex[2] = aCenter;
823
824 // no -0.0 on the printouts!
825 vertex[2].FixNegativeZero();
826 }
827
828private:
829 friend class SPECCTRA_DB;
830
831 std::string layer_id;
834};
835
836
837class WINDOW : public ELEM
838{
839public:
840
841 WINDOW( ELEM* aParent, DSN_T aType = T_window ) :
842 ELEM( aType, aParent )
843 {
844 shape = nullptr;
845 }
846
848 {
849 delete shape;
850 }
851
852 void SetShape( ELEM* aShape )
853 {
854 delete shape;
855 shape = aShape;
856
857 if( aShape )
858 {
859 wxASSERT( aShape->Type()==T_rect
860 || aShape->Type()==T_circle
861 || aShape->Type()==T_qarc
862 || aShape->Type()==T_path
863 || aShape->Type()==T_polygon);
864
865 aShape->SetParent( this );
866 }
867 }
868
869 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
870 {
871 out->Print( nestLevel, "(%s ", Name() );
872
873 if( shape )
874 shape->Format( out, 0 );
875
876 out->Print( 0, ")\n" );
877 }
878
879protected:
880 /* <shape_descriptor >::=
881 [<rectangle_descriptor> |
882 <circle_descriptor> |
883 <polygon_descriptor> |
884 <path_descriptor> |
885 <qarc_descriptor> ]
886 */
888
889private:
890 friend class SPECCTRA_DB;
891};
892
893
897class KEEPOUT : public ELEM
898{
899public:
900
905 KEEPOUT( ELEM* aParent, DSN_T aType ) :
906 ELEM( aType, aParent )
907 {
908 m_rules = nullptr;
909 m_place_rules = nullptr;
910 m_shape = nullptr;
911
913 }
914
916 {
917 delete m_rules;
918 delete m_place_rules;
919 delete m_shape;
920 }
921
922 void SetShape( ELEM* aShape )
923 {
924 delete m_shape;
925 m_shape = aShape;
926
927 if( aShape )
928 {
929 wxASSERT( aShape->Type()==T_rect
930 || aShape->Type()==T_circle
931 || aShape->Type()==T_qarc
932 || aShape->Type()==T_path
933 || aShape->Type()==T_polygon);
934
935 aShape->SetParent( this );
936 }
937 }
938
939 void AddWindow( WINDOW* aWindow )
940 {
941 aWindow->SetParent( this );
942 m_windows.push_back( aWindow );
943 }
944
945 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
946 {
947 const char* newline = "\n";
948
949 out->Print( nestLevel, "(%s", Name() );
950
951 if( m_name.size() )
952 {
953 const char* quote = out->GetQuoteChar( m_name.c_str() );
954 out->Print( 0, " %s%s%s", quote, m_name.c_str(), quote );
955 }
956 // Could be not needed:
957#if 1
958 else
959 {
960 out->Print( 0, " \"\"" ); // the zone with no name or net_code == 0
961 }
962#endif
963
964 if( m_sequence_number != -1 )
965 out->Print( 0, " (sequence_number %d)", m_sequence_number );
966
967 if( m_shape )
968 {
969 out->Print( 0, " " );
970 m_shape->Format( out, 0 );
971 }
972
973 if( m_rules )
974 {
975 out->Print( 0, "%s", newline );
976 newline = "";
977 m_rules->Format( out, nestLevel+1 );
978 }
979
980 if( m_place_rules )
981 {
982 out->Print( 0, "%s", newline );
983 newline = "";
984 m_place_rules->Format( out, nestLevel+1 );
985 }
986
987 if( m_windows.size() )
988 {
989 out->Print( 0, "%s", newline );
990 newline = "";
991
992 for( WINDOW& window : m_windows )
993 window.Format( out, nestLevel+1 );
994
995 out->Print( nestLevel, ")\n" );
996 }
997 else
998 {
999 out->Print( 0, ")\n" );
1000 }
1001 }
1002
1003protected:
1004 std::string m_name;
1008
1009 boost::ptr_vector<WINDOW> m_windows;
1010
1011 /* <shape_descriptor >::=
1012 [<rectangle_descriptor> |
1013 <circle_descriptor> |
1014 <polygon_descriptor> |
1015 <path_descriptor> |
1016 <qarc_descriptor> ]
1017 */
1019
1020private:
1021 friend class SPECCTRA_DB;
1022};
1023
1024
1028class VIA : public ELEM
1029{
1030public:
1031
1032 VIA( ELEM* aParent ) :
1033 ELEM( T_via, aParent )
1034 {
1035 }
1036
1037 void AppendVia( const char* aViaName )
1038 {
1039 m_padstacks.push_back( aViaName );
1040 }
1041
1042 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1043 {
1044 const int RIGHTMARGIN = 80;
1045 int perLine = out->Print( nestLevel, "(%s", Name() );
1046
1047 for( const std::string& padstack : m_padstacks )
1048 {
1049 if( perLine > RIGHTMARGIN )
1050 {
1051 out->Print( 0, "\n" );
1052 perLine = out->Print( nestLevel+1, "%s", "");
1053 }
1054
1055 const char* quote = out->GetQuoteChar( padstack.c_str() );
1056 perLine += out->Print( 0, " %s%s%s", quote, padstack.c_str(), quote );
1057 }
1058
1059 if( m_spares.size() )
1060 {
1061 out->Print( 0, "\n" );
1062
1063 perLine = out->Print( nestLevel+1, "(spare" );
1064
1065 for( const std::string& spare : m_spares )
1066 {
1067 if( perLine > RIGHTMARGIN )
1068 {
1069 out->Print( 0, "\n" );
1070 perLine = out->Print( nestLevel+2, "%s", "");
1071 }
1072
1073 const char* quote = out->GetQuoteChar( spare.c_str() );
1074 perLine += out->Print( 0, " %s%s%s", quote, spare.c_str(), quote );
1075 }
1076
1077 out->Print( 0, ")" );
1078 }
1079
1080 out->Print( 0, ")\n" );
1081 }
1082
1083private:
1084 friend class SPECCTRA_DB;
1085
1086 std::vector<std::string> m_padstacks;
1087 std::vector<std::string> m_spares;
1088};
1089
1090
1091class CLASSES : public ELEM
1092{
1093public:
1094 CLASSES( ELEM* aParent ) :
1095 ELEM( T_classes, aParent )
1096 {
1097 }
1098
1099 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1100 {
1101 for( const std::string& class_id : class_ids )
1102 {
1103 const char* quote = out->GetQuoteChar( class_id.c_str() );
1104 out->Print( nestLevel, "%s%s%s\n", quote, class_id.c_str(), quote );
1105 }
1106 }
1107
1108private:
1109 friend class SPECCTRA_DB;
1110
1111 std::vector<std::string> class_ids;
1112};
1113
1114
1116{
1117public:
1118
1123 CLASS_CLASS( ELEM* aParent, DSN_T aType ) :
1124 ELEM_HOLDER( aType, aParent )
1125 {
1126 classes = nullptr;
1127 }
1128
1130 {
1131 delete classes;
1132 }
1133
1134 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1135 {
1136 if( classes )
1137 classes->Format( out, nestLevel );
1138
1139 // format the kids
1140 ELEM_HOLDER::FormatContents( out, nestLevel );
1141 }
1142
1143private:
1144 friend class SPECCTRA_DB;
1145
1147
1148 // rule | layer_rule are put into the kids container.
1149};
1150
1151
1152class CONTROL : public ELEM_HOLDER
1153{
1154public:
1155 CONTROL( ELEM* aParent ) :
1156 ELEM_HOLDER( T_control, aParent )
1157 {
1158 via_at_smd = false;
1159 via_at_smd_grid_on = false;
1160 }
1161
1163 {
1164 }
1165
1166 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1167 {
1168 out->Print( nestLevel, "(%s\n", Name() );
1169
1170 out->Print( nestLevel+1, "(via_at_smd %s", via_at_smd ? "on" : "off" );
1171
1172 if( via_at_smd_grid_on )
1173 out->Print( 0, " grid %s", via_at_smd_grid_on ? "on" : "off" );
1174
1175 out->Print( 0, ")\n" );
1176
1177 for( int i = 0; i < Length(); ++i )
1178 At(i)->Format( out, nestLevel+1 );
1179
1180 out->Print( nestLevel, ")\n" );
1181 }
1182
1183private:
1184 friend class SPECCTRA_DB;
1185
1188};
1189
1190
1191class LAYER : public ELEM
1192{
1193public:
1194 LAYER( ELEM* aParent ) :
1195 ELEM( T_layer, aParent )
1196 {
1197 layer_type = T_signal;
1198 direction = -1;
1199 cost = -1;
1200 cost_type = -1;
1201
1202 rules = nullptr;
1203 }
1204
1206 {
1207 delete rules;
1208 }
1209
1210 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1211 {
1212 const char* quote = out->GetQuoteChar( name.c_str() );
1213
1214 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, name.c_str(), quote );
1215
1216 out->Print( nestLevel+1, "(type %s)\n", GetTokenText( layer_type ) );
1217
1218 if( properties.size() )
1219 {
1220 out->Print( nestLevel+1, "(property\n" );
1221
1222 for( PROPERTY& property : properties )
1223 property.Format( out, nestLevel+2 );
1224
1225 out->Print( nestLevel+1, ")\n" );
1226 }
1227
1228 if( direction != -1 )
1229 out->Print( nestLevel+1, "(direction %s)\n", GetTokenText( (DSN_T)direction ) );
1230
1231 if( rules )
1232 rules->Format( out, nestLevel+1 );
1233
1234 if( cost != -1 )
1235 {
1236 if( cost < 0 )
1237 // positive integer, stored as negative.
1238 out->Print( nestLevel+1, "(cost %d", -cost );
1239 else
1240 out->Print( nestLevel+1, "(cost %s", GetTokenText( (DSN_T)cost ) );
1241
1242 if( cost_type != -1 )
1243 out->Print( 0, " (type %s)", GetTokenText( (DSN_T)cost_type ) );
1244
1245 out->Print( 0, ")\n" );
1246 }
1247
1248 if( use_net.size() )
1249 {
1250 out->Print( nestLevel+1, "(use_net" );
1251
1252 for( const std::string& net : use_net )
1253 {
1254 quote = out->GetQuoteChar( net.c_str() );
1255 out->Print( 0, " %s%s%s", quote, net.c_str(), quote );
1256 }
1257
1258 out->Print( 0, ")\n" );
1259 }
1260
1261 out->Print( nestLevel, ")\n" );
1262 }
1263
1264private:
1265 friend class SPECCTRA_DB;
1266
1267 std::string name;
1270
1272 int cost;
1275 std::vector<std::string> use_net;
1276
1278};
1279
1280
1282{
1283public:
1285 ELEM( T_layer_pair, aParent )
1286 {
1287 layer_weight = 0.0;
1288 }
1289
1290 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1291 {
1292 const char* quote0 = out->GetQuoteChar( layer_id0.c_str() );
1293 const char* quote1 = out->GetQuoteChar( layer_id1.c_str() );
1294
1295 out->Print( nestLevel, "(%s %s%s%s %s%s%s %.6g)\n",
1296 Name(),
1297 quote0, layer_id0.c_str(), quote0,
1298 quote1, layer_id1.c_str(), quote1,
1299 layer_weight );
1300 }
1301
1302private:
1303 friend class SPECCTRA_DB;
1304
1305 std::string layer_id0;
1306 std::string layer_id1;
1307
1309};
1310
1311typedef boost::ptr_vector<SPECCTRA_LAYER_PAIR> SPECCTRA_LAYER_PAIRS;
1312
1313
1315{
1316 friend class SPECCTRA_DB;
1317
1319
1320public:
1321
1323 ELEM( T_layer_noise_weight, aParent )
1324 {
1325 }
1326
1327 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1328 {
1329 out->Print( nestLevel, "(%s\n", Name() );
1330
1331 for( SPECCTRA_LAYER_PAIR& pair : layer_pairs )
1332 pair.Format( out, nestLevel+1 );
1333
1334 out->Print( nestLevel, ")\n" );
1335 }
1336};
1337
1338
1342class COPPER_PLANE : public KEEPOUT
1343{
1344public:
1345 COPPER_PLANE( ELEM* aParent ) :
1346 KEEPOUT( aParent, T_plane )
1347 {}
1348
1349private:
1350 friend class SPECCTRA_DB;
1351};
1352
1353typedef boost::ptr_vector<COPPER_PLANE> COPPER_PLANES;
1354
1355
1361class TOKPROP : public ELEM
1362{
1363public:
1364 TOKPROP( ELEM* aParent, DSN_T aType ) :
1365 ELEM( aType, aParent )
1366 {
1367 // Do not leave uninitialized members
1368 value = T_NONE;
1369 }
1370
1371 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1372 {
1373 out->Print( nestLevel, "(%s %s)\n", Name(), GetTokenText( value ) );
1374 }
1375
1376private:
1377 friend class SPECCTRA_DB;
1378
1380};
1381
1382
1388class STRINGPROP : public ELEM
1389{
1390public:
1391 STRINGPROP( ELEM* aParent, DSN_T aType ) :
1392 ELEM( aType, aParent )
1393 {
1394 }
1395
1396 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1397 {
1398 const char* quote = out->GetQuoteChar( value.c_str() );
1399
1400 out->Print( nestLevel, "(%s %s%s%s)\n",
1401 Name(),
1402 quote, value.c_str(), quote );
1403 }
1404
1405private:
1406 friend class SPECCTRA_DB;
1407
1408 std::string value;
1409};
1410
1411
1412class REGION : public ELEM_HOLDER
1413{
1414public:
1415 REGION( ELEM* aParent ) :
1416 ELEM_HOLDER( T_region, aParent )
1417 {
1418 m_rectangle = nullptr;
1419 m_polygon = nullptr;
1420 m_rules = nullptr;
1421 }
1422
1424 {
1425 delete m_rectangle;
1426 delete m_polygon;
1427 delete m_rules;
1428 }
1429
1430 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1431 {
1432 if( m_region_id.size() )
1433 {
1434 const char* quote = out->GetQuoteChar( m_region_id.c_str() );
1435 out->Print( nestLevel, "%s%s%s\n", quote, m_region_id.c_str(), quote );
1436 }
1437
1438 if( m_rectangle )
1439 m_rectangle->Format( out, nestLevel );
1440
1441 if( m_polygon )
1442 m_polygon->Format( out, nestLevel );
1443
1444 ELEM_HOLDER::FormatContents( out, nestLevel );
1445
1446 if( m_rules )
1447 m_rules->Format( out, nestLevel );
1448 }
1449
1450private:
1451 friend class SPECCTRA_DB;
1452
1453 std::string m_region_id;
1454
1455 //-----<mutually exclusive>--------------------------------------
1458 //-----</mutually exclusive>-------------------------------------
1459
1460 /* region_net | region_class | region_class_class are all mutually
1461 exclusive and are put into the kids container.
1462 */
1463
1465};
1466
1467
1468class GRID : public ELEM
1469{
1470public:
1471 GRID( ELEM* aParent ) :
1472 ELEM( T_grid, aParent )
1473 {
1474 m_grid_type = T_via;
1475 m_direction = T_NONE;
1476 m_dimension = 0.0;
1477 m_offset = 0.0;
1478 m_image_type = T_NONE;
1479 }
1480
1481 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1482 {
1483 out->Print( nestLevel, "(%s %s %.6g", Name(), GetTokenText( m_grid_type ), m_dimension );
1484
1485 if( m_grid_type == T_place )
1486 {
1487 if( m_image_type == T_smd || m_image_type == T_pin )
1488 out->Print( 0, " (image_type %s)", GetTokenText( m_image_type ) );
1489 }
1490 else
1491 {
1492 if( m_direction == T_x || m_direction == T_y )
1493 out->Print( 0, " (direction %s)", GetTokenText( m_direction ) );
1494 }
1495
1496 if( m_offset != 0.0 )
1497 out->Print( 0, " (offset %.6g)", m_offset );
1498
1499 out->Print( 0, ")\n");
1500 }
1501
1502private:
1503 friend class SPECCTRA_DB;
1504
1508 double m_offset;
1510};
1511
1512
1513class STRUCTURE_OUT : public ELEM
1514{
1515public:
1516 STRUCTURE_OUT( ELEM* aParent ) :
1517 ELEM( T_structure_out, aParent )
1518 {
1519 m_rules = nullptr;
1520 }
1521
1523 {
1524 delete m_rules;
1525 }
1526
1527 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1528 {
1529 for( LAYER& layer : m_layers )
1530 layer.Format( out, nestLevel );
1531
1532 if( m_rules )
1533 m_rules->Format( out, nestLevel );
1534 }
1535
1536private:
1537 friend class SPECCTRA_DB;
1538
1539 boost::ptr_vector<LAYER> m_layers;
1541};
1542
1543
1545{
1546public:
1547 STRUCTURE( ELEM* aParent ) :
1548 ELEM_HOLDER( T_structure, aParent )
1549 {
1550 m_unit = nullptr;
1551 m_layer_noise_weight = nullptr;
1552 m_boundary = nullptr;
1553 m_place_boundary = nullptr;
1554 m_via = nullptr;
1555 m_control = nullptr;
1556 m_rules = nullptr;
1557 m_place_rules = nullptr;
1558 }
1559
1561 {
1562 delete m_unit;
1563 delete m_layer_noise_weight;
1564 delete m_boundary;
1565 delete m_place_boundary;
1566 delete m_via;
1567 delete m_control;
1568 delete m_rules;
1569 delete m_place_rules;
1570 }
1571
1572 void SetBOUNDARY( BOUNDARY *aBoundary )
1573 {
1574 delete m_boundary;
1575 m_boundary = aBoundary;
1576
1577 if( m_boundary )
1578 m_boundary->SetParent( this );
1579 }
1580
1581 void SetPlaceBOUNDARY( BOUNDARY *aBoundary )
1582 {
1583 delete m_place_boundary;
1584 m_place_boundary = aBoundary;
1585
1586 if( m_place_boundary )
1587 m_place_boundary->SetParent( this );
1588 }
1589
1590 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1591 {
1592 if( m_unit )
1593 m_unit->Format( out, nestLevel );
1594
1595 for( LAYER& layer : m_layers)
1596 layer.Format( out, nestLevel );
1597
1599 m_layer_noise_weight->Format( out, nestLevel );
1600
1601 if( m_boundary )
1602 m_boundary->Format( out, nestLevel );
1603
1604 if( m_place_boundary )
1605 m_place_boundary->Format( out, nestLevel );
1606
1607 for( COPPER_PLANE& plane : m_planes )
1608 plane.Format( out, nestLevel );
1609
1610 for( REGION& region : m_regions )
1611 region.Format( out, nestLevel );
1612
1613 for( KEEPOUT& keepout : m_keepouts )
1614 keepout.Format( out, nestLevel );
1615
1616 if( m_via )
1617 m_via->Format( out, nestLevel );
1618
1619 if( m_control )
1620 m_control->Format( out, nestLevel );
1621
1622 for( int i=0; i<Length(); ++i )
1623 {
1624 At(i)->Format( out, nestLevel );
1625 }
1626
1627 if( m_rules )
1628 m_rules->Format( out, nestLevel );
1629
1630 if( m_place_rules )
1631 m_place_rules->Format( out, nestLevel );
1632
1633 for( GRID& grid : m_grids )
1634 grid.Format( out, nestLevel );
1635 }
1636
1637 UNIT_RES* GetUnits() const override
1638 {
1639 if( m_unit )
1640 return m_unit;
1641
1642 return ELEM::GetUnits();
1643 }
1644
1645private:
1646 friend class SPECCTRA_DB;
1647
1649
1650 boost::ptr_vector<LAYER> m_layers;
1651
1653
1659
1660 boost::ptr_vector<KEEPOUT> m_keepouts;
1661 boost::ptr_vector<COPPER_PLANE> m_planes;
1662 boost::ptr_vector<REGION> m_regions;
1663
1665
1666 boost::ptr_vector<GRID> m_grids;
1667};
1668
1669
1673class PLACE : public ELEM
1674{
1675public:
1676 PLACE( ELEM* aParent ) :
1677 ELEM( T_place, aParent )
1678 {
1679 m_side = T_front;
1680
1681 m_rotation = 0.0;
1682
1683 m_hasVertex = false;
1684
1685 m_mirror = T_NONE;
1686 m_status = T_NONE;
1687
1688 m_place_rules = nullptr;
1689
1690 m_lock_type = T_NONE;
1691 m_rules = nullptr;
1692 m_region = nullptr;
1693 }
1694
1696 {
1697 delete m_place_rules;
1698 delete m_rules;
1699 delete m_region;
1700 }
1701
1702 void SetVertex( const POINT& aVertex )
1703 {
1704 m_vertex = aVertex;
1705 m_vertex.FixNegativeZero();
1706 m_hasVertex = true;
1707 }
1708
1709 void SetRotation( double aRotation )
1710 {
1711 m_rotation = aRotation;
1712 }
1713
1714 void Format( OUTPUTFORMATTER* out, int nestLevel ) override;
1715
1716private:
1717 friend class SPECCTRA_DB;
1718
1719 std::string m_component_id;
1720
1722
1724
1727
1730
1731 std::string m_logical_part;
1732
1734
1736
1738
1739 //-----<mutually exclusive>--------------
1742 //-----</mutually exclusive>-------------
1743
1744 std::string m_part_number;
1745};
1746
1747
1751class COMPONENT : public ELEM
1752{
1753public:
1754 COMPONENT( ELEM* aParent ) :
1755 ELEM( T_component, aParent )
1756 {
1757 }
1758
1759 const std::string& GetImageId() const { return m_image_id; }
1760 void SetImageId( const std::string& aImageId )
1761 {
1762 m_image_id = aImageId;
1763 }
1764
1765
1769// static int Compare( IMAGE* lhs, IMAGE* rhs );
1770
1771 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1772 {
1773 const char* quote = out->GetQuoteChar( m_image_id.c_str() );
1774 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, m_image_id.c_str(), quote );
1775
1776 FormatContents( out, nestLevel+1 );
1777
1778 out->Print( nestLevel, ")\n" );
1779 }
1780
1781 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1782 {
1783 for( PLACE& place : m_places )
1784 place.Format( out, nestLevel );
1785 }
1786
1787private:
1788 friend class SPECCTRA_DB;
1789
1790// std::string m_hash; ///< a hash string used by Compare(), not Format()ed/exported.
1791
1792 std::string m_image_id;
1793 boost::ptr_vector<PLACE> m_places;
1794};
1795
1796
1797class PLACEMENT : public ELEM
1798{
1799public:
1800 PLACEMENT( ELEM* aParent ) :
1801 ELEM( T_placement, aParent )
1802 {
1803 m_unit = nullptr;
1804 m_flip_style = DSN_T( T_NONE );
1805 }
1806
1808 {
1809 delete m_unit;
1810 }
1811
1820 COMPONENT* LookupCOMPONENT( const std::string& imageName )
1821 {
1822 for( COMPONENT& component : m_components )
1823 {
1824 if( component.GetImageId().compare( imageName ) == 0 )
1825 return &component;
1826 }
1827
1828 COMPONENT* added = new COMPONENT(this);
1829 m_components.push_back( added );
1830 added->SetImageId( imageName );
1831 return added;
1832 }
1833
1834 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1835 {
1836 if( m_unit )
1837 m_unit->Format( out, nestLevel );
1838
1839 if( m_flip_style != DSN_T( T_NONE ) )
1840 {
1841 out->Print( nestLevel, "(place_control (flip_style %s))\n", GetTokenText( m_flip_style ) );
1842 }
1843
1844 for(auto & m_component : m_components )
1845 m_component.Format( out, nestLevel );
1846 }
1847
1848 UNIT_RES* GetUnits() const override
1849 {
1850 if( m_unit )
1851 return m_unit;
1852
1853 return ELEM::GetUnits();
1854 }
1855
1856private:
1857 friend class SPECCTRA_DB;
1858
1861 boost::ptr_vector<COMPONENT> m_components;
1862};
1863
1864
1872class SHAPE : public WINDOW
1873{
1874public:
1878 SHAPE( ELEM* aParent, DSN_T aType = T_shape ) :
1879 WINDOW( aParent, aType )
1880 {
1881 m_connect = T_on;
1882 }
1883
1884 void SetConnect( DSN_T aConnect )
1885 {
1886 m_connect = aConnect;
1887 }
1888
1889 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1890 {
1891 out->Print( nestLevel, "(%s ", Name() );
1892
1893 if( shape )
1894 shape->Format( out, 0 );
1895
1896 if( m_connect == T_off )
1897 out->Print( 0, "(connect %s)", GetTokenText( m_connect ) );
1898
1899 if( m_windows.size() )
1900 {
1901 out->Print( 0, "\n" );
1902
1903 for( WINDOW& window : m_windows )
1904 window.Format( out, nestLevel+1 );
1905
1906 out->Print( nestLevel, ")\n" );
1907 }
1908 else
1909 {
1910 out->Print( 0, ")\n" );
1911 }
1912 }
1913
1914private:
1915 friend class SPECCTRA_DB;
1916
1918
1919 /* <shape_descriptor >::=
1920 [<rectangle_descriptor> |
1921 <circle_descriptor> |
1922 <polygon_descriptor> |
1923 <path_descriptor> |
1924 <qarc_descriptor> ]
1925 ELEM* shape; // inherited from WINDOW
1926 */
1927
1928 boost::ptr_vector<WINDOW> m_windows;
1929};
1930
1931
1932class PIN : public ELEM
1933{
1934public:
1935 PIN( ELEM* aParent ) :
1936 ELEM( T_pin, aParent )
1937 {
1938 m_rotation = 0.0;
1939 m_isRotated = false;
1940 m_kiNetCode = 0;
1941 }
1942
1943 void SetRotation( double aRotation )
1944 {
1945 m_rotation = aRotation;
1946 m_isRotated = (aRotation != 0.0);
1947 }
1948
1949 void SetVertex( const POINT& aPoint )
1950 {
1951 m_vertex = aPoint;
1952 m_vertex.FixNegativeZero();
1953 }
1954
1955 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1956 {
1957 const char* quote = out->GetQuoteChar( m_padstack_id.c_str() );
1958 if( m_isRotated )
1959 out->Print( nestLevel, "(pin %s%s%s (rotate %.6g)", quote, m_padstack_id.c_str(), quote, m_rotation );
1960 else
1961 out->Print( nestLevel, "(pin %s%s%s", quote, m_padstack_id.c_str(), quote );
1962
1963 quote = out->GetQuoteChar( m_pin_id.c_str() );
1964 out->Print( 0, " %s%s%s %.6g %.6g)\n", quote, m_pin_id.c_str(), quote, m_vertex.x, m_vertex.y );
1965 }
1966
1967private:
1968 friend class SPECCTRA_DB;
1969
1970 std::string m_padstack_id;
1973 std::string m_pin_id;
1975
1977};
1978
1979
1980class LIBRARY;
1981
1982class IMAGE : public ELEM_HOLDER
1983{
1984public:
1985 IMAGE( ELEM* aParent ) :
1986 ELEM_HOLDER( T_image, aParent )
1987 {
1988 m_side = T_both;
1989 m_unit = nullptr;
1990 m_rules = nullptr;
1991 m_place_rules = nullptr;
1992 m_duplicated = 0;
1993 }
1994
1996 {
1997 delete m_unit;
1998 delete m_rules;
1999 delete m_place_rules;
2000 }
2001
2005 static int Compare( IMAGE* lhs, IMAGE* rhs );
2006
2007 std::string GetImageId()
2008 {
2009 if( m_duplicated )
2010 {
2011 return m_image_id + "::" + std::to_string( m_duplicated );
2012 }
2013
2014 return m_image_id;
2015 }
2016
2017 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2018 {
2019 std::string imageId = GetImageId();
2020
2021 const char* quote = out->GetQuoteChar( imageId.c_str() );
2022
2023 out->Print( nestLevel, "(%s %s%s%s", Name(), quote, imageId.c_str(), quote );
2024
2025 FormatContents( out, nestLevel+1 );
2026
2027 out->Print( nestLevel, ")\n" );
2028 }
2029
2030 // this is here for makeHash()
2031 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2032 {
2033 if( m_side != T_both )
2034 out->Print( 0, " (side %s)", GetTokenText( m_side ) );
2035
2036 out->Print( 0, "\n");
2037
2038 if( m_unit )
2039 m_unit->Format( out, nestLevel );
2040
2041 // format the kids, which in this class are the shapes
2042 ELEM_HOLDER::FormatContents( out, nestLevel );
2043
2044 for( PIN& pin : m_pins )
2045 pin.Format( out, nestLevel );
2046
2047 if( m_rules )
2048 m_rules->Format( out, nestLevel );
2049
2050 if( m_place_rules )
2051 m_place_rules->Format( out, nestLevel );
2052
2053 for( KEEPOUT& keepout : m_keepouts )
2054 keepout.Format( out, nestLevel );
2055 }
2056
2057 UNIT_RES* GetUnits() const override
2058 {
2059 if( m_unit )
2060 return m_unit;
2061
2062 return ELEM::GetUnits();
2063 }
2064
2065private:
2066 friend class SPECCTRA_DB;
2067 friend class LIBRARY;
2068
2069 std::string m_hash;
2070
2071 std::string m_image_id;
2074
2075 /* The grammar spec says only one outline is supported, but I am seeing
2076 *.dsn examples with multiple outlines. So the outlines will go into
2077 the kids list.
2078 */
2079
2080 boost::ptr_vector<PIN> m_pins;
2081
2084
2085 boost::ptr_vector<KEEPOUT> m_keepouts;
2086
2088};
2089
2090
2094class PADSTACK : public ELEM_HOLDER
2095{
2096public:
2103 ELEM_HOLDER( T_padstack, nullptr )
2104 {
2105 m_unit = nullptr;
2106 m_rotate = T_on;
2107 m_absolute = T_off;
2108 m_rules = nullptr;
2109 m_attach = T_off;
2110 }
2111
2113 {
2114 delete m_unit;
2115 delete m_rules;
2116 }
2117
2118 const std::string& GetPadstackId()
2119 {
2120 return m_padstack_id;
2121 }
2122
2126 static int Compare( PADSTACK* lhs, PADSTACK* rhs );
2127
2128 void SetPadstackId( const char* aPadstackId )
2129 {
2130 m_padstack_id = aPadstackId;
2131 }
2132
2133 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2134 {
2135 const char* quote = out->GetQuoteChar( m_padstack_id.c_str() );
2136
2137 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, m_padstack_id.c_str(), quote );
2138
2139 FormatContents( out, nestLevel+1 );
2140
2141 out->Print( nestLevel, ")\n" );
2142 }
2143
2144 // this factored out for use by Compare()
2145 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2146 {
2147 if( m_unit )
2148 m_unit->Format( out, nestLevel );
2149
2150 // format the kids, which in this class are the shapes
2151 ELEM_HOLDER::FormatContents( out, nestLevel );
2152
2153 out->Print( nestLevel, "%s", "" );
2154
2155 // spec for <attach_descriptor> says default is on, so
2156 // print the off condition to override this.
2157 if( m_attach == T_off )
2158 {
2159 out->Print( 0, "(attach off)" );
2160 }
2161 else if( m_attach == T_on )
2162 {
2163 const char* quote = out->GetQuoteChar( m_via_id.c_str() );
2164
2165 out->Print( 0, "(attach on (use_via %s%s%s))", quote, m_via_id.c_str(), quote );
2166 }
2167
2168 if( m_rotate == T_off ) // print the non-default
2169 out->Print( 0, "(rotate %s)", GetTokenText( m_rotate ) );
2170
2171 if( m_absolute == T_on ) // print the non-default
2172 out->Print( 0, "(absolute %s)", GetTokenText( m_absolute ) );
2173
2174 out->Print( 0, "\n" );
2175
2176 if( m_rules )
2177 m_rules->Format( out, nestLevel );
2178 }
2179
2180
2181 UNIT_RES* GetUnits() const override
2182 {
2183 if( m_unit )
2184 return m_unit;
2185
2186 return ELEM::GetUnits();
2187 }
2188
2189private:
2190 friend class SPECCTRA_DB;
2191
2192 std::string m_hash;
2193
2194 std::string m_padstack_id;
2196
2197 /* The shapes are stored in the kids list */
2198
2202 std::string m_via_id;
2203
2205};
2206
2207
2211inline bool operator<( const PADSTACK& lhs, const PADSTACK& rhs )
2212{
2213 return PADSTACK::Compare( (PADSTACK*) &lhs, (PADSTACK*) &rhs ) < 0;
2214}
2215
2216
2223class LIBRARY : public ELEM
2224{
2225public:
2226 LIBRARY( ELEM* aParent, DSN_T aType = T_library ) :
2227 ELEM( aType, aParent )
2228 {
2229 m_unit = nullptr;
2230// via_start_index = -1; // 0 or greater means there is at least one via
2231 }
2232
2234 {
2235 delete m_unit;
2236 }
2237
2238 void AddPadstack( PADSTACK* aPadstack )
2239 {
2240 aPadstack->SetParent( this );
2241 m_padstacks.push_back( aPadstack );
2242 }
2243
2244/*
2245 void SetViaStartIndex( int aIndex )
2246 {
2247 via_start_index = aIndex;
2248 }
2249 int GetViaStartIndex()
2250 {
2251 return via_start_index;
2252 }
2253*/
2254
2260 int FindIMAGE( IMAGE* aImage )
2261 {
2262 unsigned i;
2263
2264 for( i = 0; i < m_images.size(); ++i )
2265 {
2266 if( IMAGE::Compare( aImage, &m_images[i] ) == 0 )
2267 return (int) i;
2268 }
2269
2270 // There is no match to the IMAGE contents, but now generate a unique
2271 // name for it.
2272 int dups = 1;
2273
2274 for( const IMAGE& image : m_images )
2275 {
2276 if( image.m_image_id == aImage->m_image_id )
2277 aImage->m_duplicated = dups++;
2278 }
2279
2280 return -1;
2281 }
2282
2283
2287 void AppendIMAGE( IMAGE* aImage )
2288 {
2289 aImage->SetParent( this );
2290 m_images.push_back( aImage );
2291 }
2292
2300 {
2301 int ndx = FindIMAGE( aImage );
2302
2303 if( ndx == -1 )
2304 {
2305 AppendIMAGE( aImage );
2306 return aImage;
2307 }
2308
2309 return &m_images[ndx];
2310 }
2311
2317 int FindVia( PADSTACK* aVia )
2318 {
2319 for( unsigned i = 0; i < m_vias.size(); ++i )
2320 {
2321 if( PADSTACK::Compare( aVia, &m_vias[i] ) == 0 )
2322 return int( i );
2323 }
2324
2325 return -1;
2326 }
2327
2331 void AppendVia( PADSTACK* aVia )
2332 {
2333 aVia->SetParent( this );
2334 m_vias.push_back( aVia );
2335 }
2336
2337
2341 void AppendPADSTACK( PADSTACK* aPadstack )
2342 {
2343 aPadstack->SetParent( this );
2344 m_padstacks.push_back( aPadstack );
2345 }
2346
2354 {
2355 int ndx = FindVia( aVia );
2356
2357 if( ndx == -1 )
2358 {
2359 AppendVia( aVia );
2360 return aVia;
2361 }
2362
2363 return &m_vias[ndx];
2364 }
2365
2371 PADSTACK* FindPADSTACK( const std::string& aPadstackId )
2372 {
2373 for( PADSTACK& padstack : m_padstacks )
2374 {
2375 if( padstack.GetPadstackId().compare( aPadstackId ) == 0 )
2376 return &padstack;
2377 }
2378
2379 return nullptr;
2380 }
2381
2382 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2383 {
2384 if( m_unit )
2385 m_unit->Format( out, nestLevel );
2386
2387 for( IMAGE& image : m_images )
2388 image.Format( out, nestLevel );
2389
2390 for( PADSTACK& padstack : m_padstacks )
2391 padstack.Format( out, nestLevel );
2392
2393 for( PADSTACK& via : m_vias )
2394 via.Format( out, nestLevel );
2395 }
2396
2397 UNIT_RES* GetUnits() const override
2398 {
2399 if( m_unit )
2400 return m_unit;
2401
2402 return ELEM::GetUnits();
2403 }
2404
2405private:
2406 friend class SPECCTRA_DB;
2407
2409 boost::ptr_vector<IMAGE> m_images;
2410
2411 boost::ptr_vector<PADSTACK> m_padstacks;
2412 boost::ptr_vector<PADSTACK> m_vias;
2413};
2414
2415
2419struct PIN_REF : public ELEM
2420{
2421 PIN_REF( ELEM* aParent ) :
2422 ELEM( T_pin, aParent )
2423 {
2424 }
2425
2426
2432 int FormatIt( OUTPUTFORMATTER* out, int nestLevel )
2433 {
2434 // only print the newline if there is a nest level, and make
2435 // the quotes unconditional on this one.
2436 const char* newline = nestLevel ? "\n" : "";
2437
2438 const char* cquote = out->GetQuoteChar( component_id.c_str() );
2439 const char* pquote = out->GetQuoteChar( pin_id.c_str() );
2440
2441 return out->Print( nestLevel, "%s%s%s-%s%s%s%s", cquote, component_id.c_str(), cquote,
2442 pquote, pin_id.c_str(), pquote, newline );
2443 }
2444
2445 std::string component_id;
2446 std::string pin_id;
2447};
2448
2449
2450class FROMTO : public ELEM
2451{
2452public:
2453 FROMTO( ELEM* aParent ) :
2454 ELEM( T_fromto, aParent )
2455 {
2456 m_rules = nullptr;
2457 m_fromto_type = DSN_T( T_NONE );
2458 }
2459
2461 {
2462 delete m_rules;
2463 }
2464
2465 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2466 {
2467 // no quoting on these two, the lexer preserved the quotes on input
2468 out->Print( nestLevel, "(%s %s %s ", Name(), m_fromText.c_str(), m_toText.c_str() );
2469
2470 if( m_fromto_type != DSN_T( T_NONE ) )
2471 out->Print( 0, "(type %s)", GetTokenText( m_fromto_type ) );
2472
2473 if( m_net_id.size() )
2474 {
2475 const char* quote = out->GetQuoteChar( m_net_id.c_str() );
2476 out->Print( 0, "(net %s%s%s)", quote, m_net_id.c_str(), quote );
2477 }
2478
2479 bool singleLine = true;
2480
2481 if( m_rules || m_layer_rules.size() )
2482 {
2483 out->Print( 0, "\n" );
2484 singleLine = false;
2485 }
2486
2487 if( m_rules )
2488 m_rules->Format( out, nestLevel+1 );
2489
2490 /*
2491 if( circuit.size() )
2492 out->Print( nestLevel, "%s\n", circuit.c_str() );
2493 */
2494
2495 for( LAYER_RULE& layer_rule : m_layer_rules )
2496 layer_rule.Format( out, nestLevel+1 );
2497
2498 out->Print( singleLine ? 0 : nestLevel, ")" );
2499
2500 if( nestLevel || !singleLine )
2501 out->Print( 0, "\n" );
2502 }
2503
2504private:
2505 friend class SPECCTRA_DB;
2506
2507 std::string m_fromText;
2508 std::string m_toText;
2509
2511 std::string m_net_id;
2513// std::string m_circuit;
2514 boost::ptr_vector<LAYER_RULE> m_layer_rules;
2515};
2516
2517
2521class COMP_ORDER : public ELEM
2522{
2523public:
2524 COMP_ORDER( ELEM* aParent ) :
2525 ELEM( T_comp_order, aParent )
2526 {
2527 }
2528
2529 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2530 {
2531 out->Print( nestLevel, "(%s", Name() );
2532
2533 for( const std::string& placement_id : m_placement_ids )
2534 {
2535 const char* quote = out->GetQuoteChar( placement_id.c_str() );
2536 out->Print( 0, " %s%s%s", quote, placement_id.c_str(), quote );
2537 }
2538
2539 out->Print( 0, ")" );
2540
2541 if( nestLevel )
2542 out->Print( 0, "\n" );
2543 }
2544
2545private:
2546 friend class SPECCTRA_DB;
2547
2548 std::vector<std::string> m_placement_ids;
2549};
2550
2551typedef boost::ptr_vector<COMP_ORDER> COMP_ORDERS;
2552
2556class NET : public ELEM
2557{
2558public:
2559 NET( ELEM* aParent ) :
2560 ELEM( T_net, aParent )
2561 {
2562 m_unassigned = false;
2563 m_net_number = T_NONE;
2564 m_pins_type = T_pins;
2565
2566 m_type = T_NONE;
2567 m_supply = T_NONE;
2568
2569 m_rules = nullptr;
2570 m_comp_order = nullptr;
2571 }
2572
2574 {
2575 delete m_rules;
2576 delete m_comp_order;
2577 }
2578
2579 int FindPIN_REF( const std::string& aComponent )
2580 {
2581 for( unsigned i = 0; i < m_pins.size(); ++i )
2582 {
2583 if( aComponent == m_pins[i].component_id )
2584 return int(i);
2585 }
2586
2587 return -1;
2588 }
2589
2590 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2591 {
2592 const char* quote = out->GetQuoteChar( m_net_id.c_str() );
2593 const char* space = " ";
2594
2595 out->Print( nestLevel, "(%s %s%s%s", Name(), quote, m_net_id.c_str(), quote );
2596
2597 if( m_unassigned )
2598 {
2599 out->Print( 0, "%s(unassigned)", space );
2600 space = ""; // only needed one space
2601 }
2602
2603 if( m_net_number != T_NONE )
2604 {
2605 out->Print( 0, "%s(net_number %d)", space, m_net_number );
2606 // space = "";
2607 }
2608
2609 out->Print( 0, "\n" );
2610
2611 if( m_pins.size() )
2612 {
2613 const int RIGHTMARGIN = 80;
2614 int perLine = out->Print( nestLevel+1, "(%s", GetTokenText( m_pins_type ) );
2615
2616 for( PIN_REF& pin : m_pins )
2617 {
2618 if( perLine > RIGHTMARGIN )
2619 {
2620 out->Print( 0, "\n");
2621 perLine = out->Print( nestLevel+2, "%s", "" );
2622 }
2623 else
2624 {
2625 perLine += out->Print( 0, " " );
2626 }
2627
2628 perLine += pin.FormatIt( out, 0 );
2629 }
2630
2631 out->Print( 0, ")\n" );
2632 }
2633
2634 if( m_comp_order )
2635 m_comp_order->Format( out, nestLevel+1 );
2636
2637 if( m_type != T_NONE )
2638 out->Print( nestLevel+1, "(type %s)\n", GetTokenText( m_type ) );
2639
2640 if( m_rules )
2641 m_rules->Format( out, nestLevel+1 );
2642
2643 for( LAYER_RULE& layer_rule : m_layer_rules )
2644 layer_rule.Format( out, nestLevel+1 );
2645
2646 for( FROMTO& from_to : m_fromtos )
2647 from_to.Format( out, nestLevel+1 );
2648
2649 out->Print( nestLevel, ")\n" );
2650 }
2651
2652private:
2653 friend class SPECCTRA_DB;
2654
2655 std::string m_net_id;
2658
2660 std::vector<PIN_REF> m_pins;
2661
2662 std::vector<PIN_REF> m_expose;
2663 std::vector<PIN_REF> m_noexpose;
2664 std::vector<PIN_REF> m_source;
2665 std::vector<PIN_REF> m_load;
2666 std::vector<PIN_REF> m_terminator;
2667
2671
2672 boost::ptr_vector<LAYER_RULE> m_layer_rules;
2673 boost::ptr_vector<FROMTO> m_fromtos;
2675};
2676
2677
2678class TOPOLOGY : public ELEM
2679{
2680public:
2681 TOPOLOGY( ELEM* aParent ) :
2682 ELEM( T_topology, aParent )
2683 {
2684 }
2685
2686 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2687 {
2688 for( FROMTO& from_to : m_fromtos )
2689 from_to.Format( out, nestLevel );
2690
2691 for( COMP_ORDER& comp_order : m_comp_orders )
2692 comp_order.Format( out, nestLevel );
2693 }
2694
2695private:
2696 friend class SPECCTRA_DB;
2697
2698 boost::ptr_vector<FROMTO> m_fromtos;
2699 boost::ptr_vector<COMP_ORDER> m_comp_orders;
2700};
2701
2702
2706class CLASS : public ELEM
2707{
2708public:
2709 CLASS( ELEM* aParent ) :
2710 ELEM( T_class, aParent )
2711 {
2712 m_rules = nullptr;
2713 m_topology = nullptr;
2714 }
2715
2717 {
2718 delete m_rules;
2719 delete m_topology;
2720 }
2721
2722 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2723 {
2724 const char* quote = out->GetQuoteChar( m_class_id.c_str() );
2725
2726 int perLine = out->Print( nestLevel, "(%s %s%s%s", Name(), quote, m_class_id.c_str(), quote );
2727
2728 const int RIGHTMARGIN = 72;
2729
2730 for( const std::string& net_id : m_net_ids )
2731 {
2732 const char* space = " ";
2733
2734 if( perLine > RIGHTMARGIN )
2735 {
2736 out->Print( 0, "\n" );
2737 perLine = out->Print( nestLevel+1, "%s", "" );
2738 space = ""; // no space at first net_id of the line
2739 }
2740
2741 // Allegro PCB Router (Specctra) doesn't like empty net names
2742 if( net_id.empty() )
2743 continue;
2744
2745 quote = out->GetQuoteChar( net_id.c_str() );
2746 perLine += out->Print( 0, "%s%s%s%s", space, quote, net_id.c_str(), quote );
2747 }
2748
2749 bool newLine = false;
2750
2751 if( m_circuit.size() || m_rules || m_layer_rules.size() || m_topology )
2752 {
2753 out->Print( 0, "\n" );
2754 newLine = true;
2755 }
2756
2757 if( m_circuit.size() )
2758 {
2759 out->Print( nestLevel+1, "(circuit\n" );
2760
2761 for( const std::string& circuit : m_circuit )
2762 out->Print( nestLevel + 2, "%s\n", circuit.c_str() );
2763
2764 out->Print( nestLevel+1, ")\n" );
2765 }
2766
2767 if( m_rules )
2768 m_rules->Format( out, nestLevel+1 );
2769
2770 for( LAYER_RULE& layer_rule : m_layer_rules )
2771 layer_rule.Format( out, nestLevel + 1 );
2772
2773 if( m_topology )
2774 m_topology->Format( out, nestLevel+1 );
2775
2776 out->Print( newLine ? nestLevel : 0, ")\n" );
2777 }
2778
2779private:
2780 friend class SPECCTRA_DB;
2781
2782 std::string m_class_id;
2783 std::vector<std::string> m_net_ids;
2784
2786 std::vector<std::string> m_circuit;
2787
2789 boost::ptr_vector<LAYER_RULE> m_layer_rules;
2791};
2792
2793typedef boost::ptr_vector<CLASS> CLASSLIST;
2794
2795
2796class NETWORK : public ELEM
2797{
2798public:
2799 NETWORK( ELEM* aParent ) :
2800 ELEM( T_network, aParent )
2801 {
2802 }
2803
2804 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2805 {
2806 for( NET& net : m_nets )
2807 net.Format( out, nestLevel );
2808
2809 for( CLASS& c : m_classes )
2810 c.Format( out, nestLevel );
2811 }
2812
2813private:
2814 friend class SPECCTRA_DB;
2815
2816 boost::ptr_vector<NET> m_nets;
2817 boost::ptr_vector<CLASS> m_classes;
2818};
2819
2820
2821class CONNECT : public ELEM
2822{
2823 // @todo not completed.
2824
2825public:
2826 CONNECT( ELEM* aParent ) :
2827 ELEM( T_connect, aParent ) {}
2828};
2829
2830
2834class WIRE : public ELEM
2835{
2836public:
2837 WIRE( ELEM* aParent ) :
2838 ELEM( T_wire, aParent )
2839 {
2840 m_shape = nullptr;
2841 m_connect = nullptr;
2842
2843 m_turret = -1;
2844 m_wire_type = T_NONE;
2845 m_attr = T_NONE;
2846 m_supply = false;
2847 }
2848
2850 {
2851 delete m_shape;
2852 delete m_connect;
2853 }
2854
2855 void SetShape( ELEM* aShape )
2856 {
2857 delete m_shape;
2858 m_shape = aShape;
2859
2860 if( aShape )
2861 {
2862 wxASSERT(aShape->Type()==T_rect || aShape->Type()==T_circle
2863 || aShape->Type()==T_qarc || aShape->Type()==T_path
2864 || aShape->Type()==T_polygon);
2865
2866 aShape->SetParent( this );
2867 }
2868 }
2869
2870 void AddWindow( WINDOW* aWindow )
2871 {
2872 aWindow->SetParent( this );
2873 m_windows.push_back( aWindow );
2874 }
2875
2876 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2877 {
2878 out->Print( nestLevel, "(%s ", Name() );
2879
2880 if( m_shape )
2881 m_shape->Format( out, 0 );
2882
2883 if( m_net_id.size() )
2884 {
2885 const char* quote = out->GetQuoteChar( m_net_id.c_str() );
2886 out->Print( 0, "(net %s%s%s)", quote, m_net_id.c_str(), quote );
2887 }
2888
2889 if( m_turret >= 0 )
2890 out->Print( 0, "(turrent %d)", m_turret );
2891
2892 if( m_wire_type != T_NONE )
2893 out->Print( 0, "(type %s)", GetTokenText( m_wire_type ) );
2894
2895 if( m_attr != T_NONE )
2896 out->Print( 0, "(attr %s)", GetTokenText( m_attr ) );
2897
2898 if( m_shield.size() )
2899 {
2900 const char* quote = out->GetQuoteChar( m_shield.c_str() );
2901 out->Print( 0, "(shield %s%s%s)", quote, m_shield.c_str(), quote );
2902 }
2903
2904 if( m_windows.size() )
2905 {
2906 out->Print( 0, "\n" );
2907
2908 for( WINDOW& window : m_windows )
2909 window.Format( out, nestLevel + 1 );
2910
2911 out->Print( nestLevel, "" );
2912 }
2913
2914 if( m_connect )
2915 m_connect->Format( out, 0 );
2916
2917 if( m_supply )
2918 out->Print( 0, "(supply)" );
2919
2920 out->Print( 0, ")\n" );
2921 }
2922
2923private:
2924 friend class SPECCTRA_DB;
2925
2926 /* <shape_descriptor >::=
2927 [<rectangle_descriptor> |
2928 <circle_descriptor> |
2929 <polygon_descriptor> |
2930 <path_descriptor> |
2931 <qarc_descriptor> ]
2932 */
2934
2935 std::string m_net_id;
2939 std::string m_shield;
2940 boost::ptr_vector<WINDOW> m_windows;
2943};
2944
2945
2949class WIRE_VIA : public ELEM
2950{
2951public:
2952 WIRE_VIA( ELEM* aParent ) :
2953 ELEM( T_via, aParent )
2954 {
2955 m_via_number = -1;
2956 m_via_type = T_NONE;
2957 m_attr = T_NONE;
2958 m_supply = false;
2959 }
2960
2961 const std::string& GetPadstackId()
2962 {
2963 return m_padstack_id;
2964 }
2965
2966 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2967 {
2968 const char* quote = out->GetQuoteChar( m_padstack_id.c_str() );
2969
2970 const int RIGHTMARGIN = 80;
2971 int perLine = out->Print( nestLevel, "(%s %s%s%s", Name(), quote, m_padstack_id.c_str(), quote );
2972
2973 for( POINT& pt : m_vertexes )
2974 {
2975 if( perLine > RIGHTMARGIN )
2976 {
2977 out->Print( 0, "\n" );
2978 perLine = out->Print( nestLevel+1, "%s", "" );
2979 }
2980 else
2981 {
2982 perLine += out->Print( 0, " " );
2983 }
2984
2985 perLine += out->Print( 0, "%.6g %.6g", pt.x, pt.y );
2986 }
2987
2988 if( m_net_id.size() || m_via_number!=-1 || m_via_type!=T_NONE || m_attr!=T_NONE || m_supply)
2989 out->Print( 0, " " );
2990
2991 if( m_net_id.size() )
2992 {
2993 if( perLine > RIGHTMARGIN )
2994 {
2995 out->Print( 0, "\n" );
2996 perLine = out->Print( nestLevel+1, "%s", "" );
2997 }
2998
2999 quote = out->GetQuoteChar( m_net_id.c_str() );
3000 perLine += out->Print( 0, "(net %s%s%s)", quote, m_net_id.c_str(), quote );
3001 }
3002
3003 if( m_via_number != -1 )
3004 {
3005 if( perLine > RIGHTMARGIN )
3006 {
3007 out->Print( 0, "\n" );
3008 perLine = out->Print( nestLevel+1, "%s", "" );
3009 }
3010
3011 perLine += out->Print( 0, "(via_number %d)", m_via_number );
3012 }
3013
3014 if( m_via_type != T_NONE )
3015 {
3016 if( perLine > RIGHTMARGIN )
3017 {
3018 out->Print( 0, "\n" );
3019 perLine = out->Print( nestLevel+1, "%s", "" );
3020 }
3021
3022 perLine += out->Print( 0, "(type %s)", GetTokenText( m_via_type ) );
3023 }
3024
3025 if( m_attr != T_NONE )
3026 {
3027 if( perLine > RIGHTMARGIN )
3028 {
3029 out->Print( 0, "\n" );
3030 perLine = out->Print( nestLevel+1, "%s", "" );
3031 }
3032
3033 if( m_attr == T_virtual_pin )
3034 {
3035 quote = out->GetQuoteChar( m_virtual_pin_name.c_str() );
3036 perLine += out->Print( 0, "(attr virtual_pin %s%s%s)", quote, m_virtual_pin_name.c_str(), quote );
3037 }
3038 else
3039 {
3040 perLine += out->Print( 0, "(attr %s)", GetTokenText( m_attr ) );
3041 }
3042 }
3043
3044 if( m_supply )
3045 {
3046 if( perLine > RIGHTMARGIN )
3047 {
3048 out->Print( 0, "\n" );
3049 perLine = out->Print( nestLevel+1, "%s", "" );
3050 }
3051
3052 perLine += out->Print( 0, "(supply)" );
3053 }
3054
3055 if( m_contact_layers.size() )
3056 {
3057 out->Print( 0, "\n" );
3058 out->Print( nestLevel+1, "(contact\n" );
3059
3060 for( const std::string& contact_layer : m_contact_layers )
3061 {
3062 quote = out->GetQuoteChar( contact_layer.c_str() );
3063 out->Print( nestLevel+2, "%s%s%s\n", quote, contact_layer.c_str(), quote );
3064 }
3065
3066 out->Print( nestLevel+1, "))\n" );
3067 }
3068 else
3069 {
3070 out->Print( 0, ")\n" );
3071 }
3072 }
3073
3074private:
3075 friend class SPECCTRA_DB;
3076
3077 std::string m_padstack_id;
3078 std::vector<POINT> m_vertexes;
3079 std::string m_net_id;
3084 std::vector<std::string> m_contact_layers;
3086};
3087
3088
3092class WIRING : public ELEM
3093{
3094public:
3095 WIRING( ELEM* aParent ) :
3096 ELEM( T_wiring, aParent )
3097 {
3098 unit = nullptr;
3099 }
3100
3102 {
3103 delete unit;
3104 }
3105
3106 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3107 {
3108 if( unit )
3109 unit->Format( out, nestLevel );
3110
3111 for( WIRE& wire : wires )
3112 wire.Format( out, nestLevel );
3113
3114 for( WIRE_VIA& wire_via : wire_vias )
3115 wire_via.Format( out, nestLevel );
3116 }
3117
3118 UNIT_RES* GetUnits() const override
3119 {
3120 if( unit )
3121 return unit;
3122
3123 return ELEM::GetUnits();
3124 }
3125
3126private:
3127 friend class SPECCTRA_DB;
3128
3130 boost::ptr_vector<WIRE> wires;
3131 boost::ptr_vector<WIRE_VIA> wire_vias;
3132};
3133
3134
3135class PCB : public ELEM
3136{
3137public:
3138 PCB( ELEM* aParent = nullptr ) :
3139 ELEM( T_pcb, aParent )
3140 {
3141 m_parser = nullptr;
3142 m_resolution = nullptr;
3143 m_unit = nullptr;
3144 m_structure = nullptr;
3145 m_placement = nullptr;
3146 m_library = nullptr;
3147 m_network = nullptr;
3148 m_wiring = nullptr;
3149 }
3150
3152 {
3153 delete m_parser;
3154 delete m_resolution;
3155 delete m_unit;
3156 delete m_structure;
3157 delete m_placement;
3158 delete m_library;
3159 delete m_network;
3160 delete m_wiring;
3161 }
3162
3163 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3164 {
3165 const char* quote = out->GetQuoteChar( m_pcbname.c_str() );
3166
3167 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, m_pcbname.c_str(), quote );
3168
3169 if( m_parser )
3170 m_parser->Format( out, nestLevel+1 );
3171
3172 if( m_resolution )
3173 m_resolution->Format( out, nestLevel+1 );
3174
3175 if( m_unit )
3176 m_unit->Format( out, nestLevel+1 );
3177
3178 if( m_structure )
3179 m_structure->Format( out, nestLevel+1 );
3180
3181 if( m_placement )
3182 m_placement->Format( out, nestLevel+1 );
3183
3184 if( m_library )
3185 m_library->Format( out, nestLevel+1 );
3186
3187 if( m_network )
3188 m_network->Format( out, nestLevel+1 );
3189
3190 if( m_wiring )
3191 m_wiring->Format( out, nestLevel+1 );
3192
3193 out->Print( nestLevel, ")\n" );
3194 }
3195
3196 UNIT_RES* GetUnits() const override
3197 {
3198 if( m_unit )
3199 return m_unit;
3200
3201 if( m_resolution )
3202 return m_resolution->GetUnits();
3203
3204 return ELEM::GetUnits();
3205 }
3206
3207private:
3208 friend class SPECCTRA_DB;
3209
3210 std::string m_pcbname;
3219};
3220
3221
3222class ANCESTOR : public ELEM
3223{
3224public:
3225 ANCESTOR( ELEM* aParent ) :
3226 ELEM( T_ancestor, aParent )
3227 {
3228 time_stamp = time(nullptr);
3229 }
3230
3231 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3232 {
3233 char temp[80];
3234 struct tm* tmp;
3235
3236 tmp = localtime( &time_stamp );
3237 strftime( temp, sizeof(temp), "%b %d %H : %M : %S %Y", tmp );
3238
3239 // format the time first to temp
3240 // filename may be empty, so quote it just in case.
3241 out->Print( nestLevel, "(%s \"%s\" (created_time %s)\n", Name(), filename.c_str(), temp );
3242
3243 if( comment.size() )
3244 {
3245 const char* quote = out->GetQuoteChar( comment.c_str() );
3246 out->Print( nestLevel+1, "(comment %s%s%s)\n", quote, comment.c_str(), quote );
3247 }
3248
3249 out->Print( nestLevel, ")\n" );
3250 }
3251
3252private:
3253 friend class SPECCTRA_DB;
3254
3255 std::string filename;
3256 std::string comment;
3258};
3259
3260typedef boost::ptr_vector<ANCESTOR> ANCESTORS;
3261
3262
3263class HISTORY : public ELEM
3264{
3265public:
3266 HISTORY( ELEM* aParent ) :
3267 ELEM( T_history, aParent )
3268 {
3269 time_stamp = time(nullptr);
3270 }
3271
3272 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3273 {
3274 for( ANCESTOR& ancestor : ancestors )
3275 ancestor.Format( out, nestLevel );
3276
3277 char temp[80];
3278 struct tm* tmp;
3279
3280 tmp = localtime( &time_stamp );
3281 strftime( temp, sizeof( temp ), "%b %d %H : %M : %S %Y", tmp );
3282
3283 // format the time first to temp
3284 out->Print( nestLevel, "(self (created_time %s)\n", temp );
3285
3286 for( const std::string& comment : comments )
3287 {
3288 const char* quote = out->GetQuoteChar( comment.c_str() );
3289 out->Print( nestLevel+1, "(comment %s%s%s)\n", quote, comment.c_str(), quote );
3290 }
3291
3292 out->Print( nestLevel, ")\n" );
3293 }
3294
3295private:
3296 friend class SPECCTRA_DB;
3297
3300 std::vector<std::string> comments;
3301};
3302
3303
3307class SUPPLY_PIN : public ELEM
3308{
3309public:
3310 SUPPLY_PIN( ELEM* aParent ) :
3311 ELEM( T_supply_pin, aParent )
3312 {
3313 }
3314
3315 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3316 {
3317 bool singleLine = pin_refs.size() <= 1;
3318 out->Print( nestLevel, "(%s", Name() );
3319
3320 if( singleLine )
3321 {
3322 out->Print( 0, "%s", " " );
3323 pin_refs.begin()->Format( out, 0 );
3324 }
3325 else
3326 {
3327 for( PIN_REF& pin_ref : pin_refs )
3328 pin_ref.FormatIt( out, nestLevel + 1 );
3329 }
3330
3331 if( net_id.size() )
3332 {
3333 const char* newline = singleLine ? "" : "\n";
3334
3335 const char* quote = out->GetQuoteChar( net_id.c_str() );
3336 out->Print( singleLine ? 0 : nestLevel+1, " (net %s%s%s)%s",
3337 quote, net_id.c_str(), quote, newline );
3338 }
3339
3340 out->Print( singleLine ? 0 : nestLevel, ")\n");
3341 }
3342
3343private:
3344 friend class SPECCTRA_DB;
3345
3346 std::vector<PIN_REF> pin_refs;
3347 std::string net_id;
3348};
3349
3350
3354class NET_OUT : public ELEM
3355{
3356public:
3357 NET_OUT( ELEM* aParent ) :
3358 ELEM( T_net_out, aParent )
3359 {
3360 rules = nullptr;
3361 net_number = -1;
3362 m_unassigned = false;
3363 }
3364
3366 {
3367 delete rules;
3368 }
3369
3370 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3371 {
3372 const char* quote = out->GetQuoteChar( net_id.c_str() );
3373
3374 // cannot use Type() here, it is T_net_out and we need "(net "
3375 out->Print( nestLevel, "(net %s%s%s\n", quote, net_id.c_str(), quote );
3376
3377 if( m_unassigned )
3378 out->Print( nestLevel + 1, "(unassigned)\n" );
3379
3380 if( net_number>= 0 )
3381 out->Print( nestLevel+1, "(net_number %d)\n", net_number );
3382
3383 if( rules )
3384 rules->Format( out, nestLevel+1 );
3385
3386 for( WIRE& wire : wires )
3387 wire.Format( out, nestLevel + 1 );
3388
3389 for( WIRE_VIA& wire_via : wire_vias )
3390 wire_via.Format( out, nestLevel + 1 );
3391
3392 for( SUPPLY_PIN& supply_pin : supply_pins )
3393 supply_pin.Format( out, nestLevel + 1 );
3394
3395 out->Print( nestLevel, ")\n" );
3396 }
3397
3398private:
3399 friend class SPECCTRA_DB;
3400
3401 std::string net_id;
3405 boost::ptr_vector<WIRE> wires;
3406 boost::ptr_vector<WIRE_VIA> wire_vias;
3407 boost::ptr_vector<SUPPLY_PIN> supply_pins;
3408};
3409
3410
3411class ROUTE : public ELEM
3412{
3413public:
3414 ROUTE( ELEM* aParent ) :
3415 ELEM( T_route, aParent )
3416 {
3417 resolution = nullptr;
3418 parser = nullptr;
3419 structure_out = nullptr;
3420 library = nullptr;
3421 }
3422
3424 {
3425 delete resolution;
3426 delete parser;
3427 delete structure_out;
3428 delete library;
3429// delete test_points;
3430 }
3431
3432 UNIT_RES* GetUnits() const override
3433 {
3434 if( resolution )
3435 return resolution;
3436
3437 return ELEM::GetUnits();
3438 }
3439
3440 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3441 {
3442 if( resolution )
3443 resolution->Format( out, nestLevel );
3444
3445 if( parser )
3446 parser->Format( out, nestLevel );
3447
3448 if( structure_out )
3449 structure_out->Format( out, nestLevel );
3450
3451 if( library )
3452 library->Format( out, nestLevel );
3453
3454 if( net_outs.size() )
3455 {
3456 out->Print( nestLevel, "(network_out\n" );
3457
3458 for( NET_OUT& net_out : net_outs )
3459 net_out.Format( out, nestLevel + 1 );
3460
3461 out->Print( nestLevel, ")\n" );
3462 }
3463
3464// if( test_poinst )
3465// test_points->Format( out, nestLevel );
3466 }
3467
3468private:
3469 friend class SPECCTRA_DB;
3470
3475 boost::ptr_vector<NET_OUT> net_outs;
3476// TEST_POINTS* test_points;
3477};
3478
3479
3485{
3486 PIN_PAIR( ELEM* aParent = nullptr ) :
3487 was( aParent ),
3488 is( aParent )
3489 {
3490 }
3491
3494};
3495
3496
3500class WAS_IS : public ELEM
3501{
3502public:
3503 WAS_IS( ELEM* aParent ) :
3504 ELEM( T_was_is, aParent )
3505 {
3506 }
3507
3508 void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3509 {
3510 for( PIN_PAIR& pin_pair : pin_pairs )
3511 {
3512 out->Print( nestLevel, "(pins " );
3513 pin_pair.was.Format( out, 0 );
3514 out->Print( 0, " " );
3515 pin_pair.is.Format( out, 0 );
3516 out->Print( 0, ")\n" );
3517 }
3518 }
3519
3520private:
3521 friend class SPECCTRA_DB;
3522
3523 std::vector<PIN_PAIR> pin_pairs;
3524};
3525
3526
3530class SESSION : public ELEM
3531{
3532public:
3533 SESSION( ELEM* aParent = nullptr ) :
3534 ELEM( T_session, aParent )
3535 {
3536 history = nullptr;
3537 structure = nullptr;
3538 placement = nullptr;
3539 was_is = nullptr;
3540 route = nullptr;
3541 }
3542
3544 {
3545 delete history;
3546 delete structure;
3547 delete placement;
3548 delete was_is;
3549 delete route;
3550 }
3551
3552 void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3553 {
3554 const char* quote = out->GetQuoteChar( session_id.c_str() );
3555 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, session_id.c_str(), quote );
3556
3557 out->Print( nestLevel+1, "(base_design \"%s\")\n", base_design.c_str() );
3558
3559 if( history )
3560 history->Format( out, nestLevel+1 );
3561
3562 if( structure )
3563 structure->Format( out, nestLevel+1 );
3564
3565 if( placement )
3566 placement->Format( out, nestLevel+1 );
3567
3568 if( was_is )
3569 was_is->Format( out, nestLevel+1 );
3570
3571 if( route )
3572 route->Format( out, nestLevel+1 );
3573
3574 out->Print( nestLevel, ")\n" );
3575 }
3576
3577private:
3578 friend class SPECCTRA_DB;
3579
3580 std::string session_id;
3581 std::string base_design;
3582
3588
3589/* not supported:
3590 FLOOR_PLAN* floor_plan;
3591 NET_PIN_CHANGES* net_pin_changes;
3592 SWAP_HISTORY* swap_history;
3593*/
3594};
3595
3596typedef boost::ptr_set<PADSTACK> PADSTACKSET;
3597
3598
3602class SPECCTRA_DB : public SPECCTRA_LEXER
3603{
3604public:
3605
3607 SPECCTRA_LEXER( 0 ) // LINE_READER* == nullptr, no DSNLEXER::PushReader()
3608 {
3609 // The LINE_READER will be pushed from an automatic instantiation,
3610 // we don't own it:
3611 wxASSERT( !iOwnReaders );
3612
3613 m_pcb = nullptr;
3614 m_session = nullptr;
3615 m_quote_char += '"';
3616 m_footprintsAreFlipped = false;
3617
3618 SetSpecctraMode( true );
3619
3620 // Avoid not initialized members:
3621 m_routeResolution = nullptr;
3622 m_sessionBoard = nullptr;
3623 m_top_via_layer = 0;
3624 m_bot_via_layer = 0;
3625 }
3626
3628 {
3629 delete m_pcb;
3630 delete m_session;
3631
3632 deleteNETs();
3633 }
3634
3638 static PCB* MakePCB();
3639
3643 void SetPCB( PCB* aPcb )
3644 {
3645 delete m_pcb;
3646 m_pcb = aPcb;
3647 }
3648
3649 PCB* GetPCB() { return m_pcb; }
3650
3654 void SetSESSION( SESSION* aSession )
3655 {
3656 delete m_session;
3657 m_session = aSession;
3658 }
3659
3661
3671 void LoadPCB( const wxString& aFilename );
3672
3683 void LoadSESSION( const wxString& aFilename );
3684
3693 void ExportPCB( const wxString& aFilename, bool aNameChange=false );
3694
3705 void FromBOARD( BOARD* aBoard );
3706
3717 void FromSESSION( BOARD* aBoard, COMMIT& aCommit );
3718
3724 void ExportSESSION( const wxString& aFilename );
3725
3733 bool BuiltBoardOutlines( BOARD* aBoard );
3734
3738 void FlipFOOTPRINTs( BOARD* aBoard );
3739
3743 void RevertFOOTPRINTs( BOARD* aBoard );
3744
3745private:
3752 void buildLayerMaps( BOARD* aBoard );
3753
3760 int findLayerName( const std::string& aLayerName ) const;
3761
3778 void readCOMPnPIN( std::string* component_id, std::string* pid_id );
3779
3791 void readTIME( time_t* time_stamp );
3792
3793 void doPCB( PCB* growth );
3794 void doPARSER( PARSER* growth );
3795 void doRESOLUTION( UNIT_RES* growth );
3796 void doUNIT( UNIT_RES* growth );
3797 void doSTRUCTURE( STRUCTURE* growth );
3798 void doSTRUCTURE_OUT( STRUCTURE_OUT* growth );
3801 void doBOUNDARY( BOUNDARY* growth );
3802 void doRECTANGLE( RECTANGLE* growth );
3803 void doPATH( PATH* growth );
3804 void doSTRINGPROP( STRINGPROP* growth );
3805 void doTOKPROP( TOKPROP* growth );
3806 void doVIA( VIA* growth );
3807 void doCONTROL( CONTROL* growth );
3808 void doLAYER( LAYER* growth );
3809 void doRULE( RULE* growth );
3810 void doKEEPOUT( KEEPOUT* growth );
3811 void doCIRCLE( CIRCLE* growth );
3812 void doQARC( QARC* growth );
3813 void doWINDOW( WINDOW* growth );
3814 void doCONNECT( CONNECT* growth );
3815 void doREGION( REGION* growth );
3816 void doCLASS_CLASS( CLASS_CLASS* growth );
3817 void doLAYER_RULE( LAYER_RULE* growth );
3818 void doCLASSES( CLASSES* growth );
3819 void doGRID( GRID* growth );
3820 void doPLACE( PLACE* growth );
3821 void doCOMPONENT( COMPONENT* growth );
3822 void doPLACEMENT( PLACEMENT* growth );
3823 void doPROPERTIES( PROPERTIES* growth );
3824 void doPADSTACK( PADSTACK* growth );
3825 void doSHAPE( SHAPE* growth );
3826 void doIMAGE( IMAGE* growth );
3827 void doLIBRARY( LIBRARY* growth );
3828 void doPIN( PIN* growth );
3829 void doNET( NET* growth );
3830 void doNETWORK( NETWORK* growth );
3831 void doCLASS( CLASS* growth );
3832 void doTOPOLOGY( TOPOLOGY* growth );
3833 void doFROMTO( FROMTO* growth );
3834 void doCOMP_ORDER( COMP_ORDER* growth );
3835 void doWIRE( WIRE* growth );
3836 void doWIRE_VIA( WIRE_VIA* growth );
3837 void doWIRING( WIRING* growth );
3838 void doSESSION( SESSION* growth );
3839 void doANCESTOR( ANCESTOR* growth );
3840 void doHISTORY( HISTORY* growth );
3841 void doROUTE( ROUTE* growth );
3842 void doWAS_IS( WAS_IS* growth );
3843 void doNET_OUT( NET_OUT* growth );
3844 void doSUPPLY_PIN( SUPPLY_PIN* growth );
3845
3846 //-----<FromBOARD>-------------------------------------------------------
3847
3855 void fillBOUNDARY( BOARD* aBoard, BOUNDARY* aBoundary );
3856
3865 IMAGE* makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint );
3866
3877 PADSTACK* makePADSTACK( BOARD* aBoard, PAD* aPad );
3878
3888 PADSTACK* makeVia( int aCopperDiameter, int aDrillDiameter, int aTopLayer, int aBotLayer );
3889
3896 PADSTACK* makeVia( const ::PCB_VIA* aVia );
3897
3902 {
3903 for( NET* net : m_nets )
3904 delete net;
3905
3906 m_nets.clear();
3907 }
3908
3912 void exportNETCLASS( const NETCLASS* aNetClass, const BOARD* aBoard );
3913
3914 //-----</FromBOARD>------------------------------------------------------
3915
3916 //-----<FromSESSION>-----------------------------------------------------
3917
3921 PCB_TRACK* makeTRACK( WIRE* wire, PATH* aPath, int aPointIndex, int aNetcode );
3922
3926 PCB_ARC* makeARC( WIRE* wire, QARC* aQarc, int aNetcode );
3927
3932 PCB_VIA* makeVIA( WIRE_VIA*aVia, PADSTACK* aPadstack, const POINT& aPoint, int aNetCode,
3933 int aViaDrillDefault );
3934
3935 //-----</FromSESSION>----------------------------------------------------
3936
3938 static const KEYWORD keywords[];
3939
3941 SHAPE_POLY_SET m_brd_outlines; // the board outlines for DSN export
3943 wxString m_filename;
3944 std::string m_quote_char;
3945
3947
3949
3950 std::vector<std::string> m_layerIds;
3951
3952 std::map<PCB_LAYER_ID, int> m_kicadLayer2pcb;
3953 std::map<int, PCB_LAYER_ID> m_pcbLayer2kicad;
3954
3957
3960
3961 static const KICAD_T scanPADs[];
3962
3963 boost::ptr_set<PADSTACK> m_padstackset;
3964
3966 std::vector<NET*> m_nets;
3967
3971};
3972
3982
3983bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName, COMMIT& aCommit );
3984
3985} // namespace DSN
3986
3987#endif // SPECCTRA_H_
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:373
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition commit.h:68
time_t time_stamp
Definition specctra.h:3257
ANCESTOR(ELEM *aParent)
Definition specctra.h:3225
std::string filename
Definition specctra.h:3255
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:3231
std::string comment
Definition specctra.h:3256
friend class SPECCTRA_DB
Definition specctra.h:3253
BOUNDARY(ELEM *aParent, DSN_T aType=T_boundary)
Definition specctra.h:661
void GetCorners(std::vector< double > &aBuffer)
GetCorners fills aBuffer with a list of coordinates (x,y) of corners.
Definition specctra.h:675
RECTANGLE * rectangle
Definition specctra.h:725
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:705
friend class SPECCTRA_DB
Definition specctra.h:721
void SetLayerId(const std::string &aLayerId)
Definition specctra.h:751
std::string layer_id
Definition specctra.h:769
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:738
double diameter
Definition specctra.h:771
CIRCLE(ELEM *aParent)
Definition specctra.h:732
void SetVertex(const POINT &aVertex)
Definition specctra.h:761
POINT vertex
Definition specctra.h:772
void SetDiameter(double aDiameter)
Definition specctra.h:756
friend class SPECCTRA_DB
Definition specctra.h:767
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:1099
CLASSES(ELEM *aParent)
Definition specctra.h:1094
std::vector< std::string > class_ids
Definition specctra.h:1111
friend class SPECCTRA_DB
Definition specctra.h:1109
CLASS_CLASS(ELEM *aParent, DSN_T aType)
Definition specctra.h:1123
CLASSES * classes
Definition specctra.h:1146
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:1134
friend class SPECCTRA_DB
Definition specctra.h:1144
The <class_descriptor> in the specctra spec.
Definition specctra.h:2707
TOPOLOGY * m_topology
Definition specctra.h:2790
CLASS(ELEM *aParent)
Definition specctra.h:2709
std::vector< std::string > m_circuit
circuit descriptor list
Definition specctra.h:2786
boost::ptr_vector< LAYER_RULE > m_layer_rules
Definition specctra.h:2789
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:2722
std::string m_class_id
Definition specctra.h:2782
RULE * m_rules
Definition specctra.h:2788
std::vector< std::string > m_net_ids
Definition specctra.h:2783
friend class SPECCTRA_DB
Definition specctra.h:2780
Implement a <component_descriptor> in the specctra dsn spec.
Definition specctra.h:1752
std::string m_image_id
Definition specctra.h:1792
boost::ptr_vector< PLACE > m_places
Definition specctra.h:1793
const std::string & GetImageId() const
Definition specctra.h:1759
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:1781
void SetImageId(const std::string &aImageId)
Definition specctra.h:1760
COMPONENT(ELEM *aParent)
Definition specctra.h:1754
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Compare two objects of this type and returns <0, 0, or >0.
Definition specctra.h:1771
friend class SPECCTRA_DB
Definition specctra.h:1788
The <component_order_descriptor>.
Definition specctra.h:2522
COMP_ORDER(ELEM *aParent)
Definition specctra.h:2524
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:2529
std::vector< std::string > m_placement_ids
Definition specctra.h:2548
friend class SPECCTRA_DB
Definition specctra.h:2546
CONNECT(ELEM *aParent)
Definition specctra.h:2826
bool via_at_smd_grid_on
Definition specctra.h:1187
bool via_at_smd
Definition specctra.h:1186
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:1166
CONTROL(ELEM *aParent)
Definition specctra.h:1155
friend class SPECCTRA_DB
Definition specctra.h:1184
A <plane_descriptor> in the specctra dsn spec.
Definition specctra.h:1343
COPPER_PLANE(ELEM *aParent)
Definition specctra.h:1345
friend class SPECCTRA_DB
Definition specctra.h:1350
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.
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.
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
friend class SPECCTRA_DB
Definition specctra.h:356
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
virtual void Format(OUTPUTFORMATTER *out, int nestLevel)
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
ELEM(DSN_T aType, ELEM *aParent=nullptr)
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.
virtual ~ELEM()
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
friend class SPECCTRA_DB
Definition specctra.h:279
static STRING_FORMATTER sf
Definition specctra.h:273
FROMTO(ELEM *aParent)
Definition specctra.h:2453
std::string m_fromText
Definition specctra.h:2507
std::string m_net_id
Definition specctra.h:2511
std::string m_toText
Definition specctra.h:2508
DSN_T m_fromto_type
Definition specctra.h:2510
boost::ptr_vector< LAYER_RULE > m_layer_rules
Definition specctra.h:2514
RULE * m_rules
Definition specctra.h:2512
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:2465
friend class SPECCTRA_DB
Definition specctra.h:2505
DSN_T m_grid_type
T_via | T_wire | T_via_keepout | T_place | T_snap.
Definition specctra.h:1505
GRID(ELEM *aParent)
Definition specctra.h:1471
double m_offset
Definition specctra.h:1508
DSN_T m_direction
T_x | T_y | -1 for both.
Definition specctra.h:1507
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:1481
double m_dimension
Definition specctra.h:1506
DSN_T m_image_type
Definition specctra.h:1509
friend class SPECCTRA_DB
Definition specctra.h:1503
ANCESTORS ancestors
Definition specctra.h:3298
time_t time_stamp
Definition specctra.h:3299
std::vector< std::string > comments
Definition specctra.h:3300
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:3272
HISTORY(ELEM *aParent)
Definition specctra.h:3266
friend class SPECCTRA_DB
Definition specctra.h:3296
DSN_T m_side
Definition specctra.h:2072
std::string m_hash
a hash string used by Compare(), not Format()ed/exported.
Definition specctra.h:2069
friend class LIBRARY
Definition specctra.h:2067
std::string GetImageId()
Definition specctra.h:2007
static int Compare(IMAGE *lhs, IMAGE *rhs)
Compare two objects of this type and returns <0, 0, or >0.
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition specctra.h:2057
IMAGE(ELEM *aParent)
Definition specctra.h:1985
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:2031
RULE * m_rules
Definition specctra.h:2082
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:2017
boost::ptr_vector< KEEPOUT > m_keepouts
Definition specctra.h:2085
UNIT_RES * m_unit
Definition specctra.h:2073
std::string m_image_id
Definition specctra.h:2071
int m_duplicated
no. times this image_id is duplicated
Definition specctra.h:2087
boost::ptr_vector< PIN > m_pins
Definition specctra.h:2080
RULE * m_place_rules
Definition specctra.h:2083
friend class SPECCTRA_DB
Definition specctra.h:2066
Used for <keepout_descriptor> and <plane_descriptor>.
Definition specctra.h:898
void AddWindow(WINDOW *aWindow)
Definition specctra.h:939
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:905
RULE * m_place_rules
Definition specctra.h:1007
boost::ptr_vector< WINDOW > m_windows
Definition specctra.h:1009
void SetShape(ELEM *aShape)
Definition specctra.h:922
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:945
std::string m_name
Definition specctra.h:1004
ELEM * m_shape
Definition specctra.h:1018
RULE * m_rules
Definition specctra.h:1006
int m_sequence_number
Definition specctra.h:1005
friend class SPECCTRA_DB
Definition specctra.h:1021
LAYER_NOISE_WEIGHT(ELEM *aParent)
Definition specctra.h:1322
SPECCTRA_LAYER_PAIRS layer_pairs
Definition specctra.h:1318
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:1327
friend class SPECCTRA_DB
Definition specctra.h:1316
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
std::vector< std::string > m_layer_ids
Definition specctra.h:570
friend class SPECCTRA_DB
Definition specctra.h:568
PROPERTIES properties
Definition specctra.h:1277
DSN_T layer_type
one of: T_signal, T_power, T_mixed, T_jumper
Definition specctra.h:1268
LAYER(ELEM *aParent)
Definition specctra.h:1194
std::vector< std::string > use_net
Definition specctra.h:1275
RULE * rules
Definition specctra.h:1274
int cost_type
T_length | T_way.
Definition specctra.h:1273
int direction
[forbidden | high | medium | low | free | <positive_integer> | -1]
Definition specctra.h:1269
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:1210
std::string name
Definition specctra.h:1267
friend class SPECCTRA_DB
Definition specctra.h:1265
A <library_descriptor> in the specctra dsn specification.
Definition specctra.h:2224
boost::ptr_vector< PADSTACK > m_padstacks
all except vias, which are in 'vias'
Definition specctra.h:2411
PADSTACK * LookupVia(PADSTACK *aVia)
Add the via only if one exactly like it does not already exist in the padstack container.
Definition specctra.h:2353
PADSTACK * FindPADSTACK(const std::string &aPadstackId)
Search the padstack container by name.
Definition specctra.h:2371
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:2382
void AppendVia(PADSTACK *aVia)
Add aVia to the internal via container.
Definition specctra.h:2331
int FindIMAGE(IMAGE *aImage)
Search this LIBRARY for an image which matches the argument.
Definition specctra.h:2260
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition specctra.h:2397
UNIT_RES * m_unit
Definition specctra.h:2408
boost::ptr_vector< IMAGE > m_images
Definition specctra.h:2409
IMAGE * LookupIMAGE(IMAGE *aImage)
Add the image only if one exactly like it does not already exist in the image container.
Definition specctra.h:2299
void AppendPADSTACK(PADSTACK *aPadstack)
Add the padstack to the padstack container.
Definition specctra.h:2341
boost::ptr_vector< PADSTACK > m_vias
Definition specctra.h:2412
LIBRARY(ELEM *aParent, DSN_T aType=T_library)
Definition specctra.h:2226
void AddPadstack(PADSTACK *aPadstack)
Definition specctra.h:2238
void AppendIMAGE(IMAGE *aImage)
Add the image to the image list.
Definition specctra.h:2287
int FindVia(PADSTACK *aVia)
Search this LIBRARY for a via which matches the argument.
Definition specctra.h:2317
friend class SPECCTRA_DB
Definition specctra.h:2406
boost::ptr_vector< NET > m_nets
Definition specctra.h:2816
boost::ptr_vector< CLASS > m_classes
Definition specctra.h:2817
NETWORK(ELEM *aParent)
Definition specctra.h:2799
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:2804
friend class SPECCTRA_DB
Definition specctra.h:2814
A <net_out_descriptor> of the specctra dsn spec.
Definition specctra.h:3355
bool m_unassigned
Definition specctra.h:3403
boost::ptr_vector< WIRE > wires
Definition specctra.h:3405
NET_OUT(ELEM *aParent)
Definition specctra.h:3357
boost::ptr_vector< WIRE_VIA > wire_vias
Definition specctra.h:3406
std::string net_id
Definition specctra.h:3401
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:3370
boost::ptr_vector< SUPPLY_PIN > supply_pins
Definition specctra.h:3407
RULE * rules
Definition specctra.h:3404
friend class SPECCTRA_DB
Definition specctra.h:3399
A <net_descriptor> in the DSN spec.
Definition specctra.h:2557
std::vector< PIN_REF > m_load
Definition specctra.h:2665
boost::ptr_vector< FROMTO > m_fromtos
Definition specctra.h:2673
std::vector< PIN_REF > m_pins
Definition specctra.h:2660
RULE * m_rules
Definition specctra.h:2670
std::vector< PIN_REF > m_noexpose
Definition specctra.h:2663
std::vector< PIN_REF > m_source
Definition specctra.h:2664
std::string m_net_id
Definition specctra.h:2655
std::vector< PIN_REF > m_expose
Definition specctra.h:2662
int FindPIN_REF(const std::string &aComponent)
Definition specctra.h:2579
int m_net_number
Definition specctra.h:2657
std::vector< PIN_REF > m_terminator
Definition specctra.h:2666
DSN_T m_type
T_fix | T_normal.
Definition specctra.h:2668
DSN_T m_supply
T_power | T_ground.
Definition specctra.h:2669
boost::ptr_vector< LAYER_RULE > m_layer_rules
Definition specctra.h:2672
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:2590
NET(ELEM *aParent)
Definition specctra.h:2559
bool m_unassigned
Definition specctra.h:2656
COMP_ORDER * m_comp_order
Definition specctra.h:2674
DSN_T m_pins_type
T_pins | T_order, type of field 'pins' below.
Definition specctra.h:2659
friend class SPECCTRA_DB
Definition specctra.h:2653
Hold either a via or a pad definition.
Definition specctra.h:2095
std::string m_via_id
Definition specctra.h:2202
const std::string & GetPadstackId()
Definition specctra.h:2118
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:2145
std::string m_hash
a hash string used by Compare(), not Format()ed/exported.
Definition specctra.h:2192
DSN_T m_absolute
Definition specctra.h:2200
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:2133
PADSTACK()
Cannot take ELEM* aParent because PADSTACKSET confuses this with a copy constructor and causes havoc.
Definition specctra.h:2102
std::string m_padstack_id
Definition specctra.h:2194
void SetPadstackId(const char *aPadstackId)
Definition specctra.h:2128
RULE * m_rules
Definition specctra.h:2204
static int Compare(PADSTACK *lhs, PADSTACK *rhs)
Compare two objects of this type and returns <0, 0, or >0.
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition specctra.h:2181
UNIT_RES * m_unit
Definition specctra.h:2195
friend class SPECCTRA_DB
Definition specctra.h:2190
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.
std::vector< std::string > constants
This holds pairs of strings, one pair for each constant definition.
Definition specctra.h:391
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
bool via_rotate_first
Definition specctra.h:387
char string_quote
Definition specctra.h:380
PARSER(ELEM *aParent)
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
friend class SPECCTRA_DB
Definition specctra.h:378
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
Definition specctra.h:580
DSN_T aperture_type
Definition specctra.h:651
std::vector< POINT > & GetPoints()
Definition specctra.h:595
std::vector< POINT > points
Definition specctra.h:650
double aperture_width
Definition specctra.h:648
PATH(ELEM *aParent, DSN_T aType=T_path)
Definition specctra.h:583
void SetLayerId(const std::string &aLayerId)
Definition specctra.h:597
void SetAperture(double aWidth)
Definition specctra.h:602
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:607
void AppendPoint(const POINT &aPoint)
Definition specctra.h:590
std::string layer_id
Definition specctra.h:647
friend class SPECCTRA_DB
Definition specctra.h:645
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:3163
UNIT_RES * m_unit
Definition specctra.h:3213
UNIT_RES * m_resolution
Definition specctra.h:3212
PCB(ELEM *aParent=nullptr)
Definition specctra.h:3138
std::string m_pcbname
Definition specctra.h:3210
NETWORK * m_network
Definition specctra.h:3217
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition specctra.h:3196
PLACEMENT * m_placement
Definition specctra.h:3215
STRUCTURE * m_structure
Definition specctra.h:3214
PARSER * m_parser
Definition specctra.h:3211
WIRING * m_wiring
Definition specctra.h:3218
LIBRARY * m_library
Definition specctra.h:3216
friend class SPECCTRA_DB
Definition specctra.h:3208
PIN(ELEM *aParent)
Definition specctra.h:1935
void SetVertex(const POINT &aPoint)
Definition specctra.h:1949
POINT m_vertex
Definition specctra.h:1974
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:1955
int m_kiNetCode
KiCad netcode.
Definition specctra.h:1976
void SetRotation(double aRotation)
Definition specctra.h:1943
double m_rotation
Definition specctra.h:1971
std::string m_pin_id
Definition specctra.h:1973
std::string m_padstack_id
Definition specctra.h:1970
friend class SPECCTRA_DB
Definition specctra.h:1968
bool m_isRotated
Definition specctra.h:1972
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:1834
DSN_T m_flip_style
Definition specctra.h:1860
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition specctra.h:1848
UNIT_RES * m_unit
Definition specctra.h:1859
COMPONENT * LookupCOMPONENT(const std::string &imageName)
Look up a COMPONENT by name.
Definition specctra.h:1820
PLACEMENT(ELEM *aParent)
Definition specctra.h:1800
boost::ptr_vector< COMPONENT > m_components
Definition specctra.h:1861
friend class SPECCTRA_DB
Definition specctra.h:1857
Implement a <placement_reference> in the specctra dsn spec.
Definition specctra.h:1674
void SetVertex(const POINT &aVertex)
Definition specctra.h:1702
DSN_T m_status
Definition specctra.h:1729
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
bool m_hasVertex
Definition specctra.h:1725
POINT m_vertex
Definition specctra.h:1726
DSN_T m_mirror
Definition specctra.h:1728
void SetRotation(double aRotation)
Definition specctra.h:1709
RULE * m_rules
Definition specctra.h:1740
DSN_T m_lock_type
Definition specctra.h:1737
DSN_T m_side
Definition specctra.h:1721
double m_rotation
Definition specctra.h:1723
std::string m_logical_part
Definition specctra.h:1731
std::string m_part_number
Definition specctra.h:1744
REGION * m_region
Definition specctra.h:1741
std::string m_component_id
reference designator
Definition specctra.h:1719
PLACE(ELEM *aParent)
Definition specctra.h:1676
RULE * m_place_rules
Definition specctra.h:1733
PROPERTIES m_properties
Definition specctra.h:1735
friend class SPECCTRA_DB
Definition specctra.h:1717
std::string layer_id
Definition specctra.h:831
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:785
void SetStart(const POINT &aStart)
Definition specctra.h:804
QARC(ELEM *aParent)
Definition specctra.h:779
void SetLayerId(std::string &aLayerId)
Definition specctra.h:799
void SetCenter(const POINT &aCenter)
Definition specctra.h:820
void SetEnd(const POINT &aEnd)
Definition specctra.h:812
double aperture_width
Definition specctra.h:832
POINT vertex[3]
Definition specctra.h:833
friend class SPECCTRA_DB
Definition specctra.h:829
POINT GetOrigin()
Definition specctra.h:461
std::string layer_id
Definition specctra.h:481
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
friend class SPECCTRA_DB
Definition specctra.h:479
RULE * m_rules
Definition specctra.h:1464
RECTANGLE * m_rectangle
Definition specctra.h:1456
REGION(ELEM *aParent)
Definition specctra.h:1415
PATH * m_polygon
Definition specctra.h:1457
std::string m_region_id
Definition specctra.h:1453
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:1430
friend class SPECCTRA_DB
Definition specctra.h:1451
STRUCTURE_OUT * structure_out
Definition specctra.h:3473
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition specctra.h:3432
ROUTE(ELEM *aParent)
Definition specctra.h:3414
UNIT_RES * resolution
Definition specctra.h:3471
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:3440
LIBRARY * library
Definition specctra.h:3474
boost::ptr_vector< NET_OUT > net_outs
Definition specctra.h:3475
PARSER * parser
Definition specctra.h:3472
friend class SPECCTRA_DB
Definition specctra.h:3469
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
std::vector< std::string > m_rules
rules are saved in std::string form.
Definition specctra.h:530
friend class SPECCTRA_DB
Definition specctra.h:528
A <session_file_descriptor> in the specctra dsn spec.
Definition specctra.h:3531
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:3552
SESSION(ELEM *aParent=nullptr)
Definition specctra.h:3533
std::string session_id
Definition specctra.h:3580
PLACEMENT * placement
Definition specctra.h:3585
HISTORY * history
Definition specctra.h:3583
STRUCTURE * structure
Definition specctra.h:3584
std::string base_design
Definition specctra.h:3581
ROUTE * route
Definition specctra.h:3587
WAS_IS * was_is
Definition specctra.h:3586
friend class SPECCTRA_DB
Definition specctra.h:3578
A "(shape ..)" element in the specctra dsn spec.
Definition specctra.h:1873
SHAPE(ELEM *aParent, DSN_T aType=T_shape)
Takes a DSN_T aType of T_outline.
Definition specctra.h:1878
void SetConnect(DSN_T aConnect)
Definition specctra.h:1884
boost::ptr_vector< WINDOW > m_windows
Definition specctra.h:1928
DSN_T m_connect
Definition specctra.h:1917
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:1889
friend class SPECCTRA_DB
Definition specctra.h:1915
wxString m_filename
Definition specctra.h:3943
PADSTACK * makeVia(const ::PCB_VIA *aVia)
Make any kind of PADSTACK using the given KiCad VIA.
void doUNIT(UNIT_RES *growth)
Definition specctra.cpp:584
void doPCB(PCB *growth)
Definition specctra.cpp:285
int m_top_via_layer
specctra cu layers, 0 based index:
Definition specctra.h:3969
void doCOMPONENT(COMPONENT *growth)
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)
void doPLACEMENT(PLACEMENT *growth)
void doNET_OUT(NET_OUT *growth)
void buildLayerMaps(BOARD *aBoard)
Create a few data translation structures for layer name and number mapping between the DSN::PCB struc...
Definition specctra.cpp:73
PCB_TRACK * makeTRACK(WIRE *wire, PATH *aPath, int aPointIndex, int aNetcode)
Create a TRACK form the PATH and BOARD info.
void doCLASS(CLASS *growth)
void SetSESSION(SESSION *aSession)
Delete any existing SESSION and replaces it with the given one.
Definition specctra.h:3654
void doSTRUCTURE_OUT(STRUCTURE_OUT *growth)
Definition specctra.cpp:787
std::map< int, PCB_LAYER_ID > m_pcbLayer2kicad
maps PCB layer number to BOARD layer numbers
Definition specctra.h:3953
void doCIRCLE(CIRCLE *growth)
void doANCESTOR(ANCESTOR *growth)
void doLAYER_NOISE_WEIGHT(LAYER_NOISE_WEIGHT *growth)
Definition specctra.cpp:622
SESSION * GetSESSION()
Definition specctra.h:3660
void ExportPCB(const wxString &aFilename, bool aNameChange=false)
Write the internal PCB instance out as a SPECTRA DSN format file.
void doCLASS_CLASS(CLASS_CLASS *growth)
void doSESSION(SESSION *growth)
void doWINDOW(WINDOW *growth)
Definition specctra.cpp:970
UNIT_RES * m_routeResolution
used during FromSESSION() only, memory for it is not owned here.
Definition specctra.h:3956
SHAPE_POLY_SET m_brd_outlines
Definition specctra.h:3941
void doSHAPE(SHAPE *growth)
BOARD * m_sessionBoard
a copy to avoid passing as an argument, memory for it is not owned here.
Definition specctra.h:3959
void FlipFOOTPRINTs(BOARD *aBoard)
Flip the footprints which are on the back side of the board to the front.
void doQARC(QARC *growth)
void doRESOLUTION(UNIT_RES *growth)
Definition specctra.cpp:555
void LoadPCB(const wxString &aFilename)
A recursive descent parser for a SPECCTRA DSN "design" file.
Definition specctra.cpp:246
void FromSESSION(BOARD *aBoard, COMMIT &aCommit)
Add the entire SESSION info to a BOARD but does not write it out.
void doSTRINGPROP(STRINGPROP *growth)
void doBOUNDARY(BOUNDARY *growth)
void doSPECCTRA_LAYER_PAIR(SPECCTRA_LAYER_PAIR *growth)
Definition specctra.cpp:605
virtual ~SPECCTRA_DB()
Definition specctra.h:3627
bool m_footprintsAreFlipped
Definition specctra.h:3946
SESSION * m_session
Definition specctra.h:3942
void doRECTANGLE(RECTANGLE *growth)
void deleteNETs()
Delete all the NETs that may be in here.
Definition specctra.h:3901
void doREGION(REGION *growth)
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.
void doWIRE(WIRE *growth)
static const KICAD_T scanPADs[]
Definition specctra.h:3961
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:3643
void doTOKPROP(TOKPROP *growth)
std::vector< std::string > m_layerIds
indexed by PCB layer number
Definition specctra.h:3950
void doIMAGE(IMAGE *growth)
void doCONNECT(CONNECT *growth)
Definition specctra.cpp:935
void doCOMP_ORDER(COMP_ORDER *growth)
static PCB * MakePCB()
Make a PCB with all the default ELEMs and parts on the heap.
void doTOPOLOGY(TOPOLOGY *growth)
void doKEEPOUT(KEEPOUT *growth)
Definition specctra.cpp:832
void doRULE(RULE *growth)
void doPATH(PATH *growth)
void doPIN(PIN *growth)
void doSUPPLY_PIN(SUPPLY_PIN *growth)
void doLAYER(LAYER *growth)
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:265
void doLIBRARY(LIBRARY *growth)
void exportNETCLASS(const NETCLASS *aNetClass, const BOARD *aBoard)
Export aNetClass to the DSN file.
PADSTACK * makeVia(int aCopperDiameter, int aDrillDiameter, int aTopLayer, int aBotLayer)
Make a round through hole PADSTACK using the given KiCad diameter in deci-mils.
boost::ptr_set< PADSTACK > m_padstackset
Definition specctra.h:3963
STRING_FORMATTER m_sf
Definition specctra.h:3948
std::map< PCB_LAYER_ID, int > m_kicadLayer2pcb
maps BOARD layer number to PCB layer numbers
Definition specctra.h:3952
std::vector< NET * > m_nets
we don't want ownership here permanently, so we don't use boost::ptr_vector
Definition specctra.h:3966
void doVIA(VIA *growth)
void doFROMTO(FROMTO *growth)
void doPLACE(PLACE *growth)
void doGRID(GRID *growth)
void doLAYER_RULE(LAYER_RULE *growth)
void doWIRE_VIA(WIRE_VIA *growth)
void doCLASSES(CLASSES *growth)
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:108
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:3944
void doPARSER(PARSER *growth)
Definition specctra.cpp:400
void doNETWORK(NETWORK *growth)
void doNET(NET *growth)
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:642
int findLayerName(const std::string &aLayerName) const
Return the PCB layer index for a given layer name, within the specctra sessionfile.
Definition specctra.cpp:96
void doROUTE(ROUTE *growth)
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:150
void doPADSTACK(PADSTACK *growth)
void doWIRING(WIRING *growth)
static const KEYWORD keywords[]
specctra DSN keywords
Definition specctra.h:3938
void doHISTORY(HISTORY *growth)
void doCONTROL(CONTROL *growth)
void doPROPERTIES(PROPERTIES *growth)
SPECCTRA_LAYER_PAIR(ELEM *aParent)
Definition specctra.h:1284
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:1290
friend class SPECCTRA_DB
Definition specctra.h:1303
A container for a single property whose value is a string.
Definition specctra.h:1389
std::string value
Definition specctra.h:1408
STRINGPROP(ELEM *aParent, DSN_T aType)
Definition specctra.h:1391
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:1396
friend class SPECCTRA_DB
Definition specctra.h:1406
STRUCTURE_OUT(ELEM *aParent)
Definition specctra.h:1516
boost::ptr_vector< LAYER > m_layers
Definition specctra.h:1539
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:1527
friend class SPECCTRA_DB
Definition specctra.h:1537
boost::ptr_vector< REGION > m_regions
Definition specctra.h:1662
RULE * m_place_rules
Definition specctra.h:1664
UNIT_RES * m_unit
Definition specctra.h:1648
boost::ptr_vector< GRID > m_grids
Definition specctra.h:1666
boost::ptr_vector< KEEPOUT > m_keepouts
Definition specctra.h:1660
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition specctra.h:1637
BOUNDARY * m_boundary
Definition specctra.h:1654
LAYER_NOISE_WEIGHT * m_layer_noise_weight
Definition specctra.h:1652
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:1590
void SetBOUNDARY(BOUNDARY *aBoundary)
Definition specctra.h:1572
BOUNDARY * m_place_boundary
Definition specctra.h:1655
STRUCTURE(ELEM *aParent)
Definition specctra.h:1547
boost::ptr_vector< COPPER_PLANE > m_planes
Definition specctra.h:1661
void SetPlaceBOUNDARY(BOUNDARY *aBoundary)
Definition specctra.h:1581
CONTROL * m_control
Definition specctra.h:1657
boost::ptr_vector< LAYER > m_layers
Definition specctra.h:1650
friend class SPECCTRA_DB
Definition specctra.h:1646
A <supply_pin_descriptor> in the specctra dsn spec.
Definition specctra.h:3308
std::string net_id
Definition specctra.h:3347
std::vector< PIN_REF > pin_refs
Definition specctra.h:3346
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:3315
friend class SPECCTRA_DB
Definition specctra.h:3344
SUPPLY_PIN(ELEM *aParent)
Definition specctra.h:3310
A container for a single property whose value is another DSN_T token.
Definition specctra.h:1362
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:1371
TOKPROP(ELEM *aParent, DSN_T aType)
Definition specctra.h:1364
friend class SPECCTRA_DB
Definition specctra.h:1377
boost::ptr_vector< COMP_ORDER > m_comp_orders
Definition specctra.h:2699
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:2686
boost::ptr_vector< FROMTO > m_fromtos
Definition specctra.h:2698
TOPOLOGY(ELEM *aParent)
Definition specctra.h:2681
friend class SPECCTRA_DB
Definition specctra.h:2696
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 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
friend class SPECCTRA_DB
Definition specctra.h:431
A <via_descriptor> in the specctra dsn spec.
Definition specctra.h:1029
std::vector< std::string > m_spares
Definition specctra.h:1087
VIA(ELEM *aParent)
Definition specctra.h:1032
std::vector< std::string > m_padstacks
Definition specctra.h:1086
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:1042
void AppendVia(const char *aViaName)
Definition specctra.h:1037
friend class SPECCTRA_DB
Definition specctra.h:1084
A <was_is_descriptor> in the specctra dsn spec.
Definition specctra.h:3501
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:3508
WAS_IS(ELEM *aParent)
Definition specctra.h:3503
std::vector< PIN_PAIR > pin_pairs
Definition specctra.h:3523
friend class SPECCTRA_DB
Definition specctra.h:3521
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:869
WINDOW(ELEM *aParent, DSN_T aType=T_window)
Definition specctra.h:841
void SetShape(ELEM *aShape)
Definition specctra.h:852
ELEM * shape
Definition specctra.h:887
friend class SPECCTRA_DB
Definition specctra.h:890
A <wire_via_descriptor> in the specctra dsn spec.
Definition specctra.h:2950
std::string m_net_id
Definition specctra.h:3079
std::string m_padstack_id
Definition specctra.h:3077
DSN_T m_via_type
Definition specctra.h:3081
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:2966
WIRE_VIA(ELEM *aParent)
Definition specctra.h:2952
std::string m_virtual_pin_name
Definition specctra.h:3083
std::vector< std::string > m_contact_layers
Definition specctra.h:3084
const std::string & GetPadstackId()
Definition specctra.h:2961
std::vector< POINT > m_vertexes
Definition specctra.h:3078
friend class SPECCTRA_DB
Definition specctra.h:3075
A <wire_shape_descriptor> in the specctra dsn spec.
Definition specctra.h:2835
CONNECT * m_connect
Definition specctra.h:2941
void AddWindow(WINDOW *aWindow)
Definition specctra.h:2870
DSN_T m_wire_type
Definition specctra.h:2937
ELEM * m_shape
Definition specctra.h:2933
WIRE(ELEM *aParent)
Definition specctra.h:2837
bool m_supply
Definition specctra.h:2942
boost::ptr_vector< WINDOW > m_windows
Definition specctra.h:2940
void SetShape(ELEM *aShape)
Definition specctra.h:2855
int m_turret
Definition specctra.h:2936
std::string m_net_id
Definition specctra.h:2935
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:2876
std::string m_shield
Definition specctra.h:2939
DSN_T m_attr
Definition specctra.h:2938
friend class SPECCTRA_DB
Definition specctra.h:2924
A <wiring_descriptor> in the specctra dsn spec.
Definition specctra.h:3093
UNIT_RES * unit
Definition specctra.h:3129
WIRING(ELEM *aParent)
Definition specctra.h:3095
boost::ptr_vector< WIRE > wires
Definition specctra.h:3130
boost::ptr_vector< WIRE_VIA > wire_vias
Definition specctra.h:3131
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:3106
UNIT_RES * GetUnits() const override
Return the units for this section.
Definition specctra.h:3118
friend class SPECCTRA_DB
Definition specctra.h:3127
A collection of nets and the parameters used to route or test these nets.
Definition netclass.h:38
An interface used to output 8 bit text in a convenient way.
Definition richio.h:291
int PRINTF_FUNC_N Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition richio.cpp:418
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:340
Definition pad.h:61
Represent a set of closed polygons.
Implement an OUTPUTFORMATTER to a memory buffer.
Definition richio.h:418
This source file implements export and import capabilities to the specctra dsn file format.
Definition specctra.cpp:60
boost::ptr_vector< PATH > PATHS
Definition specctra.h:654
boost::ptr_vector< CLASS > CLASSLIST
Definition specctra.h:2793
boost::ptr_vector< COMP_ORDER > COMP_ORDERS
Definition specctra.h:2551
bool operator<(const PADSTACK &lhs, const PADSTACK &rhs)
Used by the PADSTACKSET boost::ptr_set below.
Definition specctra.h:2211
const char * GetTokenText(T aTok)
The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
Definition specctra.cpp:67
std::vector< PROPERTY > PROPERTIES
Definition specctra.h:192
void ExportBoardToSpecctraFile(BOARD *aBoard, const wxString &aFullFilename)
Helper method to export board to DSN file.
bool ImportSpecctraSession(BOARD *aBoard, const wxString &fullFileName, COMMIT &aCommit)
Helper method to import SES file to a board.
boost::ptr_vector< ANCESTOR > ANCESTORS
Definition specctra.h:3260
boost::ptr_vector< COPPER_PLANE > COPPER_PLANES
Definition specctra.h:1353
boost::ptr_vector< SPECCTRA_LAYER_PAIR > SPECCTRA_LAYER_PAIRS
Definition specctra.h:1311
boost::ptr_set< PADSTACK > PADSTACKSET
Definition specctra.h:3596
DSN::T DSN_T
Definition specctra.h:51
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:3485
PIN_PAIR(ELEM *aParent=nullptr)
Definition specctra.h:3486
PIN_REF was
Definition specctra.h:3492
A <pin_reference> definition in the specctra dsn spec.
Definition specctra.h:2420
std::string pin_id
Definition specctra.h:2446
PIN_REF(ELEM *aParent)
Definition specctra.h:2421
int FormatIt(OUTPUTFORMATTER *out, int nestLevel)
Like Format() but is not virtual.
Definition specctra.h:2432
std::string component_id
Definition specctra.h:2445
A point in the SPECCTRA DSN coordinate system.
Definition specctra.h:105
POINT & operator=(const POINT &other)
Definition specctra.h:133
void FixNegativeZero()
Change negative zero to positive zero in the IEEE floating point storage format.
Definition specctra.h:146
double y
Definition specctra.h:107
bool operator!=(const POINT &other) const
Definition specctra.h:121
double x
Definition specctra.h:106
bool operator==(const POINT &other) const
Definition specctra.h:116
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:162
POINT(double aX, double aY)
Definition specctra.h:111
POINT & operator+=(const POINT &other)
Definition specctra.h:126
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:36
std::string path
KIBIS_PIN * pin
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:71