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