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