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