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