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