KiCad PCB EDA Suite
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 <dick@softplc.com>
5  * Copyright (C) 2007-2015 KiCad Developers, see change_log.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 #include <pcbnew.h>
37 
38 #include <memory>
39 
40 // all outside the DSN namespace:
41 class BOARD;
42 class TRACK;
43 class VIA;
44 class NETCLASS;
45 class FOOTPRINT;
47 
48 typedef DSN::T DSN_T;
49 
50 
73 namespace DSN {
74 
75 
76 class SPECCTRA_DB;
77 
78 
85 const char* GetTokenText( T aTok );
86 
87 
93 struct POINT
94 {
95  double x;
96  double y;
97 
98  POINT() { x=0.0; y=0.0; }
99 
100  POINT( double aX, double aY ) :
101  x(aX), y(aY)
102  {
103  }
104 
105  bool operator==( const POINT& other ) const
106  {
107  return x==other.x && y==other.y;
108  }
109 
110  bool operator!=( const POINT& other ) const
111  {
112  return !( *this == other );
113  }
114 
115  POINT& operator+=( const POINT& other )
116  {
117  x += other.x;
118  y += other.y;
119  return *this;
120  }
121 
122  POINT& operator=( const POINT& other )
123  {
124  x = other.x;
125  y = other.y;
126  return *this;
127  }
128 
136  {
137  if( x == -0.0 )
138  x = 0.0;
139  if( y == -0.0 )
140  y = 0.0;
141  }
142 
151  void Format( OUTPUTFORMATTER* out, int nestLevel ) const
152  {
153  out->Print( nestLevel, " %.6g %.6g", x, y );
154  }
155 };
156 
157 typedef std::vector<std::string> STRINGS;
158 typedef std::vector<POINT> POINTS;
159 
160 struct PROPERTY
161 {
162  std::string name;
163  std::string value;
164 
173  void Format( OUTPUTFORMATTER* out, int nestLevel ) const
174  {
175  const char* quoteName = out->GetQuoteChar( name.c_str() );
176  const char* quoteValue = out->GetQuoteChar( value.c_str() );
177 
178  out->Print( nestLevel, "(%s%s%s %s%s%s)\n",
179  quoteName, name.c_str(), quoteName,
180  quoteValue, value.c_str(), quoteValue );
181  }
182 };
183 typedef std::vector<PROPERTY> PROPERTIES;
184 
185 
186 class UNIT_RES;
187 
193 class ELEM
194 {
195  friend class SPECCTRA_DB;
196 
197 protected:
200 
201 
211  std::string makeHash()
212  {
213  sf.Clear();
214  FormatContents( &sf, 0 );
215  sf.StripUseless();
216 
217  return sf.GetString();
218  }
219 
220  // avoid creating this for every compare, make static.
222 
223 
224 public:
225 
226  ELEM( DSN_T aType, ELEM* aParent = 0 );
227 
228  virtual ~ELEM();
229 
230  DSN_T Type() const { return type; }
231 
232  const char* Name() const;
233 
234 
241  virtual UNIT_RES* GetUnits() const;
242 
251  virtual void Format( OUTPUTFORMATTER* out, int nestLevel );
252 
253 
263  virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel )
264  {
265  // overridden in ELEM_HOLDER
266  }
267 
268  void SetParent( ELEM* aParent )
269  {
270  parent = aParent;
271  }
272 };
273 
274 
280 class ELEM_HOLDER : public ELEM
281 {
282  friend class SPECCTRA_DB;
283 
284  typedef boost::ptr_vector<ELEM> ELEM_ARRAY;
285 
287 
288 public:
289 
290  ELEM_HOLDER( DSN_T aType, ELEM* aParent = 0 ) :
291  ELEM( aType, aParent )
292  {
293  }
294 
295  virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override;
296 
297 
298  //-----< list operations >--------------------------------------------
299 
307  int FindElem( DSN_T aType, int instanceNum = 0 );
308 
309 
315  int Length() const
316  {
317  return kids.size();
318  }
319 
320  void Append( ELEM* aElem )
321  {
322  kids.push_back( aElem );
323  }
324 
325  ELEM* Replace( int aIndex, ELEM* aElem )
326  {
327  ELEM_ARRAY::auto_type ret = kids.replace( aIndex, aElem );
328  return ret.release();
329  }
330 
331  ELEM* Remove( int aIndex )
332  {
333  ELEM_ARRAY::auto_type ret = kids.release( kids.begin()+aIndex );
334  return ret.release();
335  }
336 
337  void Insert( int aIndex, ELEM* aElem )
338  {
339  kids.insert( kids.begin()+aIndex, aElem );
340  }
341 
342  ELEM* At( int aIndex ) const
343  {
344  // we have varying sized objects and are using polymorphism, so we
345  // must return a pointer not a reference.
346  return (ELEM*) &kids[aIndex];
347  }
348 
349  ELEM* operator[]( int aIndex ) const
350  {
351  return At( aIndex );
352  }
353 
354  void Delete( int aIndex )
355  {
356  kids.erase( kids.begin()+aIndex );
357  }
358 };
359 
360 
366 class PARSER : public ELEM
367 {
368  friend class SPECCTRA_DB;
369 
379 
382 
383  std::string host_cad;
384  std::string host_version;
385 
386 
387 public:
388 
389  PARSER( ELEM* aParent );
390 
391  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override;
392 };
393 
394 
400 class UNIT_RES : public ELEM
401 {
402  friend class SPECCTRA_DB;
403 
405  int value;
406 
407 public:
408 
414 
415  UNIT_RES( ELEM* aParent, DSN_T aType ) :
416  ELEM( aType, aParent )
417  {
418  units = T_inch;
419  value = 2540000;
420  }
421 
422  DSN_T GetEngUnits() const { return units; }
423  int GetValue() const { return value; }
424 
425  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
426  {
427  if( type == T_unit )
428  out->Print( nestLevel, "(%s %s)\n", Name(), GetTokenText( units ) );
429  else // T_resolution
430  out->Print( nestLevel, "(%s %s %d)\n", Name(), GetTokenText( units ), value );
431  }
432 };
433 
434 
435 class RECTANGLE : public ELEM
436 {
437  friend class SPECCTRA_DB;
438 
439  std::string layer_id;
440 
443 
444 public:
445 
446  RECTANGLE( ELEM* aParent ) :
447  ELEM( T_rect, aParent )
448  {
449  }
450 
451  void SetLayerId( const char* aLayerId )
452  {
453  layer_id = aLayerId;
454  }
455 
456  void SetCorners( const POINT& aPoint0, const POINT& aPoint1 )
457  {
458  point0 = aPoint0;
460 
461  point1 = aPoint1;
463  }
464 
465  POINT GetOrigin() { return point0; }
466  POINT GetEnd() { return point1; }
467 
468  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
469  {
470  const char* newline = nestLevel ? "\n" : "";
471 
472  const char* quote = out->GetQuoteChar( layer_id.c_str() );
473 
474  out->Print( nestLevel, "(%s %s%s%s %.6g %.6g %.6g %.6g)%s",
475  Name(),
476  quote, layer_id.c_str(), quote,
477  point0.x, point0.y,
478  point1.x, point1.y,
479  newline );
480  }
481 };
482 
483 
488 class RULE : public ELEM
489 {
490  friend class SPECCTRA_DB;
491 
493 
494 public:
495 
496  RULE( ELEM* aParent, DSN_T aType ) :
497  ELEM( aType, aParent )
498  {
499  }
500 
501  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
502  {
503  out->Print( nestLevel, "(%s", Name() );
504 
505  bool singleLine;
506 
507  if( rules.size() == 1 )
508  {
509  singleLine = true;
510  out->Print( 0, " %s)", rules.begin()->c_str() );
511  }
512 
513  else
514  {
515  out->Print( 0, "\n" );
516  singleLine = false;
517 
518  for( STRINGS::const_iterator i = rules.begin(); i != rules.end(); ++i )
519  out->Print( nestLevel+1, "%s\n", i->c_str() );
520 
521  out->Print( nestLevel, ")" );
522  }
523 
524  if( nestLevel || !singleLine )
525  out->Print( 0, "\n" );
526  }
527 };
528 
529 
530 class LAYER_RULE : public ELEM
531 {
532  friend class SPECCTRA_DB;
533 
536 
537 public:
538 
539  LAYER_RULE( ELEM* aParent ) :
540  ELEM( T_layer_rule, aParent )
541  {
542  rule = 0;
543  }
544 
546  {
547  delete rule;
548  }
549 
550  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
551  {
552  out->Print( nestLevel, "(%s", Name() );
553 
554  for( STRINGS::const_iterator i=layer_ids.begin(); i != layer_ids.end(); ++i )
555  {
556  const char* quote = out->GetQuoteChar( i->c_str() );
557  out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
558  }
559 
560  out->Print( 0 , "\n" );
561 
562  if( rule )
563  rule->Format( out, nestLevel+1 );
564 
565  out->Print( nestLevel, ")\n" );
566  }
567 };
568 
569 
570 typedef boost::ptr_vector<LAYER_RULE> LAYER_RULES;
571 
572 
578 class PATH : public ELEM
579 {
580  friend class SPECCTRA_DB;
581 
582  std::string layer_id;
584 
587 
588 public:
589 
590  PATH( ELEM* aParent, DSN_T aType = T_path ) :
591  ELEM( aType, aParent )
592  {
593  aperture_width = 0.0;
594  aperture_type = T_round;
595  }
596 
597  void AppendPoint( const POINT& aPoint )
598  {
599  points.push_back( aPoint );
600  }
601 
602  POINTS& GetPoints() {return points; }
603 
604  void SetLayerId( const char* aLayerId )
605  {
606  layer_id = aLayerId;
607  }
608 
609  void SetAperture( double aWidth )
610  {
611  aperture_width = aWidth;
612  }
613 
614  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
615  {
616  const char* newline = nestLevel ? "\n" : "";
617 
618  const char* quote = out->GetQuoteChar( layer_id.c_str() );
619 
620  const int RIGHTMARGIN = 70;
621  int perLine = out->Print( nestLevel, "(%s %s%s%s %.6g",
622  Name(),
623  quote, layer_id.c_str(), quote,
624  aperture_width );
625 
626  int wrapNest = std::max( nestLevel+1, 6 );
627 
628  for( unsigned i = 0; i < points.size(); ++i )
629  {
630  if( perLine > RIGHTMARGIN )
631  {
632  out->Print( 0, "\n" );
633  perLine = out->Print( wrapNest, "%s", "" );
634  }
635  else
636  {
637  perLine += out->Print( 0, " " );
638  }
639 
640  perLine += out->Print( 0, "%.6g %.6g", points[i].x, points[i].y );
641  }
642 
643  if( aperture_type == T_square )
644  {
645  out->Print( 0, "(aperture_type square)" );
646  }
647 
648  out->Print( 0, ")%s", newline );
649  }
650 };
651 typedef boost::ptr_vector<PATH> PATHS;
652 
653 
654 class BOUNDARY : public ELEM
655 {
656  friend class SPECCTRA_DB;
657 
658  // only one or the other of these two is used, not both
661 
662 
663 public:
664 
665  BOUNDARY( ELEM* aParent, DSN_T aType = T_boundary ) :
666  ELEM( aType, aParent )
667  {
668  rectangle = 0;
669  }
670 
672  {
673  delete rectangle;
674  }
675 
679  void GetCorners( std::vector<double>& aBuffer )
680  {
681  if( rectangle )
682  {
683  aBuffer.push_back( rectangle->GetOrigin().x );
684  aBuffer.push_back( rectangle->GetOrigin().y );
685 
686  aBuffer.push_back( rectangle->GetOrigin().x );
687  aBuffer.push_back( rectangle->GetEnd().y );
688 
689  aBuffer.push_back( rectangle->GetEnd().x );
690  aBuffer.push_back( rectangle->GetEnd().y );
691 
692  aBuffer.push_back( rectangle->GetEnd().x );
693  aBuffer.push_back( rectangle->GetOrigin().y );
694  }
695  else
696  {
697  for( PATHS::iterator i=paths.begin(); i!=paths.end(); ++i )
698  {
699  POINTS& plist = i->GetPoints();
700 
701  for( unsigned jj = 0; jj < plist.size(); jj++ )
702  {
703  aBuffer.push_back( plist[jj].x );
704  aBuffer.push_back( plist[jj].y );
705  }
706  }
707  }
708  }
709 
710 
711  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
712  {
713  out->Print( nestLevel, "(%s\n", Name() );
714 
715  if( rectangle )
716  rectangle->Format( out, nestLevel+1 );
717  else
718  {
719  for( PATHS::iterator i = paths.begin(); i != paths.end(); ++i )
720  i->Format( out, nestLevel+1 );
721  }
722 
723  out->Print( nestLevel, ")\n" );
724  }
725 };
726 
727 
728 class CIRCLE : public ELEM
729 {
730  friend class SPECCTRA_DB;
731 
732  std::string layer_id;
733 
734  double diameter;
735  POINT vertex; // POINT's constructor sets to (0,0)
736 
737 public:
738  CIRCLE( ELEM* aParent ) :
739  ELEM( T_circle, aParent )
740  {
741  diameter = 0.0;
742  }
743 
744  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
745  {
746  const char* newline = nestLevel ? "\n" : "";
747 
748  const char* quote = out->GetQuoteChar( layer_id.c_str() );
749  out->Print( nestLevel, "(%s %s%s%s %.6g", Name(),
750  quote, layer_id.c_str(), quote,
751  diameter );
752 
753  if( vertex.x!=0.0 || vertex.y!=0.0 )
754  out->Print( 0, " %.6g %.6g)%s", vertex.x, vertex.y, newline );
755  else
756  out->Print( 0, ")%s", newline );
757  }
758 
759  void SetLayerId( const char* aLayerId )
760  {
761  layer_id = aLayerId;
762  }
763 
764  void SetDiameter( double aDiameter )
765  {
766  diameter = aDiameter;
767  }
768 
769  void SetVertex( const POINT& aVertex )
770  {
771  vertex = aVertex;
772  }
773 };
774 
775 
776 class QARC : public ELEM
777 {
778  friend class SPECCTRA_DB;
779 
780  std::string layer_id;
783 
784 public:
785  QARC( ELEM* aParent ) :
786  ELEM( T_qarc, aParent )
787  {
788  aperture_width = 0.0;
789  }
790 
791  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
792  {
793  const char* newline = nestLevel ? "\n" : "";
794 
795  const char* quote = out->GetQuoteChar( layer_id.c_str() );
796  out->Print( nestLevel, "(%s %s%s%s %.6g", Name() ,
797  quote, layer_id.c_str(), quote,
799 
800  for( int i=0; i<3; ++i )
801  out->Print( 0, " %.6g %.6g", vertex[i].x, vertex[i].y );
802 
803  out->Print( 0, ")%s", newline );
804  }
805 
806  void SetLayerId( const char* aLayerId )
807  {
808  layer_id = aLayerId;
809  }
810 
811  void SetStart( const POINT& aStart )
812  {
813  vertex[0] = aStart;
814  // no -0.0 on the printouts!
815  vertex[0].FixNegativeZero();
816  }
817 
818  void SetEnd( const POINT& aEnd )
819  {
820  vertex[1] = aEnd;
821  // no -0.0 on the printouts!
822  vertex[1].FixNegativeZero();
823  }
824 
825  void SetCenter( const POINT& aCenter )
826  {
827  vertex[2] = aCenter;
828  // no -0.0 on the printouts!
829  vertex[2].FixNegativeZero();
830  }
831 };
832 
833 
834 class WINDOW : public ELEM
835 {
836  friend class SPECCTRA_DB;
837 
838 protected:
839  /* <shape_descriptor >::=
840  [<rectangle_descriptor> |
841  <circle_descriptor> |
842  <polygon_descriptor> |
843  <path_descriptor> |
844  <qarc_descriptor> ]
845  */
847 
848 public:
849 
850  WINDOW( ELEM* aParent, DSN_T aType = T_window ) :
851  ELEM( aType, aParent )
852  {
853  shape = 0;
854  }
855 
857  {
858  delete shape;
859  }
860 
861  void SetShape( ELEM* aShape )
862  {
863  delete shape;
864  shape = aShape;
865 
866  if( aShape )
867  {
868  wxASSERT( aShape->Type()==T_rect
869  || aShape->Type()==T_circle
870  || aShape->Type()==T_qarc
871  || aShape->Type()==T_path
872  || aShape->Type()==T_polygon);
873 
874  aShape->SetParent( this );
875  }
876  }
877 
878  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
879  {
880  out->Print( nestLevel, "(%s ", Name() );
881 
882  if( shape )
883  shape->Format( out, 0 );
884 
885  out->Print( 0, ")\n" );
886  }
887 };
888 typedef boost::ptr_vector<WINDOW> WINDOWS;
889 
890 
895 class KEEPOUT : public ELEM
896 {
897  friend class SPECCTRA_DB;
898 
899 protected:
900  std::string name;
904 
906 
907  /* <shape_descriptor >::=
908  [<rectangle_descriptor> |
909  <circle_descriptor> |
910  <polygon_descriptor> |
911  <path_descriptor> |
912  <qarc_descriptor> ]
913  */
915 
916 public:
917 
923  KEEPOUT( ELEM* aParent, DSN_T aType ) :
924  ELEM( aType, aParent )
925  {
926  rules = 0;
927  place_rules = 0;
928  shape = 0;
929 
930  sequence_number = -1;
931  }
932 
934  {
935  delete rules;
936  delete place_rules;
937  delete shape;
938  }
939 
940  void SetShape( ELEM* aShape )
941  {
942  delete shape;
943  shape = aShape;
944 
945  if( aShape )
946  {
947  wxASSERT( aShape->Type()==T_rect
948  || aShape->Type()==T_circle
949  || aShape->Type()==T_qarc
950  || aShape->Type()==T_path
951  || aShape->Type()==T_polygon);
952 
953  aShape->SetParent( this );
954  }
955  }
956 
957  void AddWindow( WINDOW* aWindow )
958  {
959  aWindow->SetParent( this );
960  windows.push_back( aWindow );
961  }
962 
963  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
964  {
965  const char* newline = "\n";
966 
967  out->Print( nestLevel, "(%s", Name() );
968 
969  if( name.size() )
970  {
971  const char* quote = out->GetQuoteChar( name.c_str() );
972  out->Print( 0, " %s%s%s", quote, name.c_str(), quote );
973  }
974  // Could be not needed:
975 #if 1
976  else
977  out->Print( 0, " \"\"" ); // the zone with no name or net_code == 0
978 #endif
979 
980  if( sequence_number != -1 )
981  out->Print( 0, " (sequence_number %d)", sequence_number );
982 
983  if( shape )
984  {
985  out->Print( 0, " " );
986  shape->Format( out, 0 );
987  }
988 
989  if( rules )
990  {
991  out->Print( 0, "%s", newline );
992  newline = "";
993  rules->Format( out, nestLevel+1 );
994  }
995 
996  if( place_rules )
997  {
998  out->Print( 0, "%s", newline );
999  newline = "";
1000  place_rules->Format( out, nestLevel+1 );
1001  }
1002 
1003  if( windows.size() )
1004  {
1005  out->Print( 0, "%s", newline );
1006  newline = "";
1007 
1008  for( WINDOWS::iterator i = windows.begin(); i != windows.end(); ++i )
1009  i->Format( out, nestLevel+1 );
1010 
1011  out->Print( nestLevel, ")\n" );
1012  }
1013  else
1014  out->Print( 0, ")\n" );
1015  }
1016 };
1017 typedef boost::ptr_vector<KEEPOUT> KEEPOUTS;
1018 
1019 
1024 class VIA : public ELEM
1025 {
1026  friend class SPECCTRA_DB;
1027 
1030 
1031 public:
1032 
1033  VIA( ELEM* aParent ) :
1034  ELEM( T_via, aParent )
1035  {
1036  }
1037 
1038  void AppendVia( const char* aViaName )
1039  {
1040  padstacks.push_back( aViaName );
1041  }
1042 
1043  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1044  {
1045  const int RIGHTMARGIN = 80;
1046  int perLine = out->Print( nestLevel, "(%s", Name() );
1047 
1048  for( STRINGS::iterator i = padstacks.begin(); i != padstacks.end(); ++i )
1049  {
1050  if( perLine > RIGHTMARGIN )
1051  {
1052  out->Print( 0, "\n" );
1053  perLine = out->Print( nestLevel+1, "%s", "");
1054  }
1055 
1056  const char* quote = out->GetQuoteChar( i->c_str() );
1057  perLine += out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
1058  }
1059 
1060  if( spares.size() )
1061  {
1062  out->Print( 0, "\n" );
1063 
1064  perLine = out->Print( nestLevel+1, "(spare" );
1065 
1066  for( STRINGS::iterator i = spares.begin(); i != spares.end(); ++i )
1067  {
1068  if( perLine > RIGHTMARGIN )
1069  {
1070  out->Print( 0, "\n" );
1071  perLine = out->Print( nestLevel+2, "%s", "");
1072  }
1073 
1074  const char* quote = out->GetQuoteChar( i->c_str() );
1075  perLine += out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
1076  }
1077 
1078  out->Print( 0, ")" );
1079  }
1080 
1081  out->Print( 0, ")\n" );
1082  }
1083 };
1084 
1085 
1086 class CLASSES : public ELEM
1087 {
1088  friend class SPECCTRA_DB;
1089 
1091 
1092 public:
1093  CLASSES( ELEM* aParent ) :
1094  ELEM( T_classes, aParent )
1095  {
1096  }
1097 
1098  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1099  {
1100  for( STRINGS::iterator i = class_ids.begin(); i != class_ids.end(); ++i )
1101  {
1102  const char* quote = out->GetQuoteChar( i->c_str() );
1103  out->Print( nestLevel, "%s%s%s\n", quote, i->c_str(), quote );
1104  }
1105  }
1106 };
1107 
1108 
1109 class CLASS_CLASS : public ELEM_HOLDER
1110 {
1111  friend class SPECCTRA_DB;
1112 
1114 
1115  /* rule | layer_rule are put into the kids container.
1116  */
1117 
1118 
1119 public:
1120 
1126  CLASS_CLASS( ELEM* aParent, DSN_T aType ) :
1127  ELEM_HOLDER( aType, aParent )
1128  {
1129  classes = 0;
1130  }
1131 
1133  {
1134  delete classes;
1135  }
1136 
1137  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1138  {
1139  if( classes )
1140  classes->Format( out, nestLevel );
1141 
1142  // format the kids
1143  ELEM_HOLDER::FormatContents( out, nestLevel );
1144  }
1145 };
1146 
1147 
1148 class CONTROL : public ELEM_HOLDER
1149 {
1150  friend class SPECCTRA_DB;
1151 
1154 
1155 public:
1156  CONTROL( ELEM* aParent ) :
1157  ELEM_HOLDER( T_control, aParent )
1158  {
1159  via_at_smd = false;
1160  via_at_smd_grid_on = false;
1161  }
1162 
1164  {
1165  }
1166 
1167  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1168  {
1169  out->Print( nestLevel, "(%s\n", Name() );
1170 
1171  out->Print( nestLevel+1, "(via_at_smd %s", via_at_smd ? "on" : "off" );
1172 
1173  if( via_at_smd_grid_on )
1174  out->Print( 0, " grid %s", via_at_smd_grid_on ? "on" : "off" );
1175 
1176  out->Print( 0, ")\n" );
1177 
1178  for( int i = 0; i < Length(); ++i )
1179  At(i)->Format( out, nestLevel+1 );
1180 
1181  out->Print( nestLevel, ")\n" );
1182  }
1183 };
1184 
1185 
1186 class LAYER : public ELEM
1187 {
1188  friend class SPECCTRA_DB;
1189 
1190  std::string name;
1193  int cost;
1197 
1199 
1200 public:
1201 
1202  LAYER( ELEM* aParent ) :
1203  ELEM( T_layer, aParent )
1204  {
1205  layer_type = T_signal;
1206  direction = -1;
1207  cost = -1;
1208  cost_type = -1;
1209 
1210  rules = 0;
1211  }
1212 
1214  {
1215  delete rules;
1216  }
1217 
1218  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1219  {
1220  const char* quote = out->GetQuoteChar( name.c_str() );
1221 
1222  out->Print( nestLevel, "(%s %s%s%s\n",
1223  Name(),
1224  quote, name.c_str(), quote );
1225 
1226  out->Print( nestLevel+1, "(type %s)\n", GetTokenText( layer_type ) );
1227 
1228  if( properties.size() )
1229  {
1230  out->Print( nestLevel+1, "(property\n" );
1231 
1232  for( PROPERTIES::iterator i = properties.begin(); i != properties.end(); ++i )
1233  {
1234  i->Format( out, nestLevel+2 );
1235  }
1236  out->Print( nestLevel+1, ")\n" );
1237  }
1238 
1239  if( direction != -1 )
1240  out->Print( nestLevel+1, "(direction %s)\n", GetTokenText( (DSN_T)direction ) );
1241 
1242  if( rules )
1243  rules->Format( out, nestLevel+1 );
1244 
1245  if( cost != -1 )
1246  {
1247  if( cost < 0 )
1248  out->Print( nestLevel+1, "(cost %d", -cost ); // positive integer, stored as negative
1249  else
1250  out->Print( nestLevel+1, "(cost %s", GetTokenText( (DSN_T)cost ) );
1251 
1252  if( cost_type != -1 )
1253  out->Print( 0, " (type %s)", GetTokenText( (DSN_T)cost_type ) );
1254 
1255  out->Print( 0, ")\n" );
1256  }
1257 
1258  if( use_net.size() )
1259  {
1260  out->Print( nestLevel+1, "(use_net" );
1261 
1262  for( STRINGS::const_iterator i = use_net.begin(); i != use_net.end(); ++i )
1263  {
1264  quote = out->GetQuoteChar( i->c_str() );
1265  out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
1266  }
1267 
1268  out->Print( 0, ")\n" );
1269  }
1270 
1271  out->Print( nestLevel, ")\n" );
1272  }
1273 };
1274 
1275 typedef boost::ptr_vector<LAYER> LAYERS;
1276 
1277 
1279 {
1280  friend class SPECCTRA_DB;
1281 
1282  std::string layer_id0;
1283  std::string layer_id1;
1284 
1286 
1287 public:
1289  ELEM( T_layer_pair, aParent )
1290  {
1291  layer_weight = 0.0;
1292  }
1293 
1294  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1295  {
1296  const char* quote0 = out->GetQuoteChar( layer_id0.c_str() );
1297  const char* quote1 = out->GetQuoteChar( layer_id1.c_str() );
1298 
1299  out->Print( nestLevel, "(%s %s%s%s %s%s%s %.6g)\n",
1300  Name(),
1301  quote0, layer_id0.c_str(), quote0,
1302  quote1, layer_id1.c_str(), quote1,
1303  layer_weight );
1304  }
1305 };
1306 typedef boost::ptr_vector<SPECCTRA_LAYER_PAIR> SPECCTRA_LAYER_PAIRS;
1307 
1308 
1309 class LAYER_NOISE_WEIGHT : public ELEM
1310 {
1311  friend class SPECCTRA_DB;
1312 
1314 
1315 public:
1316 
1317  LAYER_NOISE_WEIGHT( ELEM* aParent ) :
1318  ELEM( T_layer_noise_weight, aParent )
1319  {
1320  }
1321 
1322  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1323  {
1324  out->Print( nestLevel, "(%s\n", Name() );
1325 
1326  for( SPECCTRA_LAYER_PAIRS::iterator i = layer_pairs.begin(); i != layer_pairs.end(); ++i )
1327  i->Format( out, nestLevel+1 );
1328 
1329  out->Print( nestLevel, ")\n" );
1330  }
1331 };
1332 
1333 
1338 class COPPER_PLANE : public KEEPOUT
1339 {
1340  friend class SPECCTRA_DB;
1341 
1342 public:
1343  COPPER_PLANE( ELEM* aParent ) :
1344  KEEPOUT( aParent, T_plane )
1345  {}
1346 };
1347 typedef boost::ptr_vector<COPPER_PLANE> COPPER_PLANES;
1348 
1349 
1355 class TOKPROP : public ELEM
1356 {
1357  friend class SPECCTRA_DB;
1358 
1360 
1361 public:
1362 
1363  TOKPROP( ELEM* aParent, DSN_T aType ) :
1364  ELEM( aType, aParent )
1365  {
1366  // Do not leave uninitialized members
1367  value = T_NONE;
1368  }
1369 
1370  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1371  {
1372  out->Print( nestLevel, "(%s %s)\n",
1373  Name(),
1374  GetTokenText( value ) );
1375  }
1376 };
1377 
1378 
1384 class STRINGPROP : public ELEM
1385 {
1386  friend class SPECCTRA_DB;
1387 
1388  std::string value;
1389 
1390 public:
1391 
1392  STRINGPROP( ELEM* aParent, DSN_T aType ) :
1393  ELEM( aType, aParent )
1394  {
1395  }
1396 
1397  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1398  {
1399  const char* quote = out->GetQuoteChar( value.c_str() );
1400 
1401  out->Print( nestLevel, "(%s %s%s%s)\n",
1402  Name(),
1403  quote, value.c_str(), quote );
1404  }
1405 };
1406 
1407 
1408 class REGION : public ELEM_HOLDER
1409 {
1410  friend class SPECCTRA_DB;
1411 
1412  std::string region_id;
1413 
1414  //-----<mutually exclusive>--------------------------------------
1417  //-----</mutually exclusive>-------------------------------------
1418 
1419  /* region_net | region_class | region_class_class are all mutually
1420  exclusive and are put into the kids container.
1421  */
1422 
1424 
1425 public:
1426  REGION( ELEM* aParent ) :
1427  ELEM_HOLDER( T_region, aParent )
1428  {
1429  rectangle = 0;
1430  polygon = 0;
1431  rules = 0;
1432  }
1433 
1435  {
1436  delete rectangle;
1437  delete polygon;
1438  delete rules;
1439  }
1440 
1441  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1442  {
1443  if( region_id.size() )
1444  {
1445  const char* quote = out->GetQuoteChar( region_id.c_str() );
1446  out->Print( nestLevel, "%s%s%s\n", quote, region_id.c_str(), quote );
1447  }
1448 
1449  if( rectangle )
1450  rectangle->Format( out, nestLevel );
1451 
1452  if( polygon )
1453  polygon->Format( out, nestLevel );
1454 
1455  ELEM_HOLDER::FormatContents( out, nestLevel );
1456 
1457  if( rules )
1458  rules->Format( out, nestLevel );
1459  }
1460 };
1461 
1462 
1463 class GRID : public ELEM
1464 {
1465  friend class SPECCTRA_DB;
1466 
1468  double dimension;
1470  double offset;
1472 
1473 public:
1474 
1475  GRID( ELEM* aParent ) :
1476  ELEM( T_grid, aParent )
1477  {
1478  grid_type = T_via;
1479  direction = T_NONE;
1480  dimension = 0.0;
1481  offset = 0.0;
1482  image_type = T_NONE;
1483  }
1484 
1485  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1486  {
1487  out->Print( nestLevel, "(%s %s %.6g",
1488  Name(),
1490 
1491  if( grid_type == T_place )
1492  {
1493  if( image_type==T_smd || image_type==T_pin )
1494  out->Print( 0, " (image_type %s)", GetTokenText( image_type ) );
1495  }
1496  else
1497  {
1498  if( direction==T_x || direction==T_y )
1499  out->Print( 0, " (direction %s)", GetTokenText( direction ) );
1500  }
1501 
1502  if( offset != 0.0 )
1503  out->Print( 0, " (offset %.6g)", offset );
1504 
1505  out->Print( 0, ")\n");
1506  }
1507 };
1508 
1509 
1510 class STRUCTURE_OUT : public ELEM
1511 {
1512  friend class SPECCTRA_DB;
1513 
1516 
1517 public:
1518  STRUCTURE_OUT( ELEM* aParent ) :
1519  ELEM( T_structure_out, aParent )
1520  {
1521  rules = 0;
1522  }
1523 
1525  {
1526  delete rules;
1527  }
1528 
1529  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1530  {
1531  for( LAYERS::iterator i = layers.begin(); i != layers.end(); ++i )
1532  i->Format( out, nestLevel );
1533 
1534  if( rules )
1535  rules->Format( out, nestLevel );
1536  }
1537 };
1538 
1539 
1540 class STRUCTURE : public ELEM_HOLDER
1541 {
1542  friend class SPECCTRA_DB;
1543 
1545 
1547 
1549 
1555 
1557 
1559 
1560  typedef boost::ptr_vector<REGION> REGIONS;
1562 
1564 
1565  typedef boost::ptr_vector<GRID> GRIDS;
1567 
1568 public:
1569 
1570  STRUCTURE( ELEM* aParent ) :
1571  ELEM_HOLDER( T_structure, aParent )
1572  {
1573  unit = 0;
1574  layer_noise_weight = 0;
1575  boundary = 0;
1576  place_boundary = 0;
1577  via = 0;
1578  control = 0;
1579  rules = 0;
1580  place_rules = 0;
1581  }
1582 
1584  {
1585  delete unit;
1586  delete layer_noise_weight;
1587  delete boundary;
1588  delete place_boundary;
1589  delete via;
1590  delete control;
1591  delete rules;
1592  delete place_rules;
1593  }
1594 
1595  void SetBOUNDARY( BOUNDARY *aBoundary )
1596  {
1597  delete boundary;
1598  boundary = aBoundary;
1599  if( boundary )
1600  {
1601  boundary->SetParent( this );
1602  }
1603  }
1604 
1605  void SetPlaceBOUNDARY( BOUNDARY *aBoundary )
1606  {
1607  delete place_boundary;
1608  place_boundary = aBoundary;
1609  if( place_boundary )
1610  place_boundary->SetParent( this );
1611  }
1612 
1613  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1614  {
1615  if( unit )
1616  unit->Format( out, nestLevel );
1617 
1618  for( LAYERS::iterator i=layers.begin(); i!=layers.end(); ++i )
1619  i->Format( out, nestLevel );
1620 
1621  if( layer_noise_weight )
1622  layer_noise_weight->Format( out, nestLevel );
1623 
1624  if( boundary )
1625  boundary->Format( out, nestLevel );
1626 
1627  if( place_boundary )
1628  place_boundary->Format( out, nestLevel );
1629 
1630  for( COPPER_PLANES::iterator i=planes.begin(); i!=planes.end(); ++i )
1631  i->Format( out, nestLevel );
1632 
1633  for( REGIONS::iterator i=regions.begin(); i!=regions.end(); ++i )
1634  i->Format( out, nestLevel );
1635 
1636  for( KEEPOUTS::iterator i=keepouts.begin(); i!=keepouts.end(); ++i )
1637  i->Format( out, nestLevel );
1638 
1639  if( via )
1640  via->Format( out, nestLevel );
1641 
1642  if( control )
1643  control->Format( out, nestLevel );
1644 
1645  for( int i=0; i<Length(); ++i )
1646  {
1647  At(i)->Format( out, nestLevel );
1648  }
1649 
1650  if( rules )
1651  rules->Format( out, nestLevel );
1652 
1653  if( place_rules )
1654  place_rules->Format( out, nestLevel );
1655 
1656  for( GRIDS::iterator i=grids.begin(); i!=grids.end(); ++i )
1657  i->Format( out, nestLevel );
1658  }
1659 
1660  UNIT_RES* GetUnits() const override
1661  {
1662  if( unit )
1663  return unit;
1664 
1665  return ELEM::GetUnits();
1666  }
1667 };
1668 
1669 
1674 class PLACE : public ELEM
1675 {
1676  friend class SPECCTRA_DB;
1677 
1678  std::string component_id;
1679 
1681 
1682  double rotation;
1683 
1686 
1689 
1690  std::string logical_part;
1691 
1693 
1695 
1697 
1698  //-----<mutually exclusive>--------------
1701  //-----</mutually exclusive>-------------
1702 
1703  std::string part_number;
1704 
1705 public:
1706 
1707  PLACE( ELEM* aParent ) :
1708  ELEM( T_place, aParent )
1709  {
1710  side = T_front;
1711 
1712  rotation = 0.0;
1713 
1714  hasVertex = false;
1715 
1716  mirror = T_NONE;
1717  status = T_NONE;
1718 
1719  place_rules = 0;
1720 
1721  lock_type = T_NONE;
1722  rules = 0;
1723  region = 0;
1724  }
1725 
1727  {
1728  delete place_rules;
1729  delete rules;
1730  delete region;
1731  }
1732 
1733  void SetVertex( const POINT& aVertex )
1734  {
1735  vertex = aVertex;
1737  hasVertex = true;
1738  }
1739 
1740  void SetRotation( double aRotation )
1741  {
1742  rotation = aRotation;
1743  }
1744 
1745  void Format( OUTPUTFORMATTER* out, int nestLevel ) override;
1746 };
1747 typedef boost::ptr_vector<PLACE> PLACES;
1748 
1749 
1754 class COMPONENT : public ELEM
1755 {
1756  friend class SPECCTRA_DB;
1757 
1758 // std::string hash; ///< a hash string used by Compare(), not Format()ed/exported.
1759 
1760  std::string image_id;
1762 
1763 public:
1764  COMPONENT( ELEM* aParent ) :
1765  ELEM( T_component, aParent )
1766  {
1767  }
1768 
1769  const std::string& GetImageId() const { return image_id; }
1770  void SetImageId( const std::string& aImageId )
1771  {
1772  image_id = aImageId;
1773  }
1774 
1775 
1780 // static int Compare( IMAGE* lhs, IMAGE* rhs );
1781 
1782  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1783  {
1784  const char* quote = out->GetQuoteChar( image_id.c_str() );
1785  out->Print( nestLevel, "(%s %s%s%s\n", Name(),
1786  quote, image_id.c_str(), quote );
1787 
1788  FormatContents( out, nestLevel+1 );
1789 
1790  out->Print( nestLevel, ")\n" );
1791  }
1792 
1793  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1794  {
1795  for( PLACES::iterator i=places.begin(); i!=places.end(); ++i )
1796  i->Format( out, nestLevel );
1797  }
1798 };
1799 typedef boost::ptr_vector<COMPONENT> COMPONENTS;
1800 
1801 
1802 class PLACEMENT : public ELEM
1803 {
1804  friend class SPECCTRA_DB;
1805 
1807 
1809 
1811 
1812 public:
1813  PLACEMENT( ELEM* aParent ) :
1814  ELEM( T_placement, aParent )
1815  {
1816  unit = 0;
1817  flip_style = DSN_T( T_NONE );
1818  }
1819 
1821  {
1822  delete unit;
1823  }
1824 
1832  COMPONENT* LookupCOMPONENT( const std::string& imageName )
1833  {
1834  for( unsigned i=0; i<components.size(); ++i )
1835  {
1836  if( 0 == components[i].GetImageId().compare( imageName ) )
1837  return &components[i];
1838  }
1839 
1840  COMPONENT* added = new COMPONENT(this);
1841  components.push_back( added );
1842  added->SetImageId( imageName );
1843  return added;
1844  }
1845 
1846  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
1847  {
1848  if( unit )
1849  unit->Format( out, nestLevel );
1850 
1851  if( flip_style != DSN_T( T_NONE ) )
1852  {
1853  out->Print( nestLevel, "(place_control (flip_style %s))\n",
1854  GetTokenText( flip_style ) );
1855  }
1856 
1857  for( COMPONENTS::iterator i=components.begin(); i!=components.end(); ++i )
1858  i->Format( out, nestLevel );
1859  }
1860 
1861  UNIT_RES* GetUnits() const override
1862  {
1863  if( unit )
1864  return unit;
1865 
1866  return ELEM::GetUnits();
1867  }
1868 };
1869 
1870 
1878 class SHAPE : public WINDOW
1879 {
1880  friend class SPECCTRA_DB;
1881 
1883 
1884  /* <shape_descriptor >::=
1885  [<rectangle_descriptor> |
1886  <circle_descriptor> |
1887  <polygon_descriptor> |
1888  <path_descriptor> |
1889  <qarc_descriptor> ]
1890  ELEM* shape; // inherited from WINDOW
1891  */
1892 
1894 
1895 public:
1896 
1901  SHAPE( ELEM* aParent, DSN_T aType = T_shape ) :
1902  WINDOW( aParent, aType )
1903  {
1904  connect = T_on;
1905  }
1906 
1907  void SetConnect( DSN_T aConnect )
1908  {
1909  connect = aConnect;
1910  }
1911 
1912  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1913  {
1914  out->Print( nestLevel, "(%s ", Name() );
1915 
1916  if( shape )
1917  shape->Format( out, 0 );
1918 
1919  if( connect == T_off )
1920  out->Print( 0, "(connect %s)", GetTokenText( connect ) );
1921 
1922  if( windows.size() )
1923  {
1924  out->Print( 0, "\n" );
1925 
1926  for( WINDOWS::iterator i=windows.begin(); i!=windows.end(); ++i )
1927  i->Format( out, nestLevel+1 );
1928 
1929  out->Print( nestLevel, ")\n" );
1930  }
1931  else
1932  out->Print( 0, ")\n" );
1933  }
1934 };
1935 
1936 
1937 class PIN : public ELEM
1938 {
1939  friend class SPECCTRA_DB;
1940 
1941  std::string padstack_id;
1942  double rotation;
1944  std::string pin_id;
1946 
1948 
1949 
1950 public:
1951  PIN( ELEM* aParent ) :
1952  ELEM( T_pin, aParent )
1953  {
1954  rotation = 0.0;
1955  isRotated = false;
1956  kiNetCode = 0;
1957  }
1958 
1959  void SetRotation( double aRotation )
1960  {
1961  rotation = aRotation;
1962  isRotated = (aRotation != 0.0);
1963  }
1964 
1965  void SetVertex( const POINT& aPoint )
1966  {
1967  vertex = aPoint;
1969  }
1970 
1971  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
1972  {
1973  const char* quote = out->GetQuoteChar( padstack_id.c_str() );
1974  if( isRotated )
1975  out->Print( nestLevel, "(pin %s%s%s (rotate %.6g)",
1976  quote, padstack_id.c_str(), quote,
1977  rotation
1978  );
1979  else
1980  out->Print( nestLevel, "(pin %s%s%s", quote, padstack_id.c_str(), quote );
1981 
1982  quote = out->GetQuoteChar( pin_id.c_str() );
1983  out->Print( 0, " %s%s%s %.6g %.6g)\n", quote, pin_id.c_str(), quote,
1984  vertex.x, vertex.y );
1985  }
1986 };
1987 typedef boost::ptr_vector<PIN> PINS;
1988 
1989 
1990 class LIBRARY;
1991 class IMAGE : public ELEM_HOLDER
1992 {
1993  friend class SPECCTRA_DB;
1994  friend class LIBRARY;
1995 
1996  std::string hash;
1997 
1998  std::string image_id;
2001 
2002  /* The grammar spec says only one outline is supported, but I am seeing
2003  *.dsn examples with multiple outlines. So the outlines will go into
2004  the kids list.
2005  */
2006 
2008 
2011 
2013 
2015 
2016 public:
2017 
2018  IMAGE( ELEM* aParent ) :
2019  ELEM_HOLDER( T_image, aParent )
2020  {
2021  side = T_both;
2022  unit = 0;
2023  rules = 0;
2024  place_rules = 0;
2025  duplicated = 0;
2026  }
2028  {
2029  delete unit;
2030  delete rules;
2031  delete place_rules;
2032  }
2033 
2038  static int Compare( IMAGE* lhs, IMAGE* rhs );
2039 
2040  std::string GetImageId()
2041  {
2042  if( duplicated )
2043  {
2044  char buf[32];
2045 
2046  std::string ret = image_id;
2047  ret += "::";
2048  sprintf( buf, "%d", duplicated );
2049  ret += buf;
2050  return ret;
2051  }
2052 
2053  return image_id;
2054  }
2055 
2056  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2057  {
2058  std::string imageId = GetImageId();
2059 
2060  const char* quote = out->GetQuoteChar( imageId.c_str() );
2061 
2062  out->Print( nestLevel, "(%s %s%s%s",
2063  Name(),
2064  quote, imageId.c_str(), quote );
2065 
2066  FormatContents( out, nestLevel+1 );
2067 
2068  out->Print( nestLevel, ")\n" );
2069  }
2070 
2071  // this is here for makeHash()
2072  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2073  {
2074  if( side != T_both )
2075  out->Print( 0, " (side %s)", GetTokenText( side ) );
2076 
2077  out->Print( 0, "\n");
2078 
2079  if( unit )
2080  unit->Format( out, nestLevel );
2081 
2082  // format the kids, which in this class are the shapes
2083  ELEM_HOLDER::FormatContents( out, nestLevel );
2084 
2085  for( PINS::iterator i=pins.begin(); i!=pins.end(); ++i )
2086  i->Format( out, nestLevel );
2087 
2088  if( rules )
2089  rules->Format( out, nestLevel );
2090 
2091  if( place_rules )
2092  place_rules->Format( out, nestLevel );
2093 
2094  for( KEEPOUTS::iterator i=keepouts.begin(); i!=keepouts.end(); ++i )
2095  i->Format( out, nestLevel );
2096  }
2097 
2098 
2099  UNIT_RES* GetUnits() const override
2100  {
2101  if( unit )
2102  return unit;
2103 
2104  return ELEM::GetUnits();
2105  }
2106 };
2107 typedef boost::ptr_vector<IMAGE> IMAGES;
2108 
2109 
2114 class PADSTACK : public ELEM_HOLDER
2115 {
2116  friend class SPECCTRA_DB;
2117 
2118  std::string hash;
2119 
2120  std::string padstack_id;
2122 
2123  /* The shapes are stored in the kids list */
2124 
2128  std::string via_id;
2129 
2131 
2132 public:
2133 
2141  ELEM_HOLDER( T_padstack, NULL )
2142  {
2143  unit = 0;
2144  rotate = T_on;
2145  absolute = T_off;
2146  rules = 0;
2147  attach = T_off;
2148  }
2150  {
2151  delete unit;
2152  delete rules;
2153  }
2154 
2155  const std::string& GetPadstackId()
2156  {
2157  return padstack_id;
2158  }
2159 
2164  static int Compare( PADSTACK* lhs, PADSTACK* rhs );
2165 
2166 
2167  void SetPadstackId( const char* aPadstackId )
2168  {
2169  padstack_id = aPadstackId;
2170  }
2171 
2172  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2173  {
2174  const char* quote = out->GetQuoteChar( padstack_id.c_str() );
2175 
2176  out->Print( nestLevel, "(%s %s%s%s\n",
2177  Name(),
2178  quote, padstack_id.c_str(), quote );
2179 
2180  FormatContents( out, nestLevel+1 );
2181 
2182  out->Print( nestLevel, ")\n" );
2183  }
2184 
2185 
2186  // this factored out for use by Compare()
2187  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2188  {
2189  if( unit )
2190  unit->Format( out, nestLevel );
2191 
2192  // format the kids, which in this class are the shapes
2193  ELEM_HOLDER::FormatContents( out, nestLevel );
2194 
2195  out->Print( nestLevel, "%s", "" );
2196 
2197  // spec for <attach_descriptor> says default is on, so
2198  // print the off condition to override this.
2199  if( attach == T_off )
2200  {
2201  out->Print( 0, "(attach off)" );
2202  }
2203  else if( attach == T_on )
2204  {
2205  const char* quote = out->GetQuoteChar( via_id.c_str() );
2206 
2207  out->Print( 0, "(attach on (use_via %s%s%s))",
2208  quote, via_id.c_str(), quote );
2209  }
2210 
2211  if( rotate == T_off ) // print the non-default
2212  out->Print( 0, "(rotate %s)", GetTokenText( rotate ) );
2213 
2214  if( absolute == T_on ) // print the non-default
2215  out->Print( 0, "(absolute %s)", GetTokenText( absolute ) );
2216 
2217  out->Print( 0, "\n" );
2218 
2219  if( rules )
2220  rules->Format( out, nestLevel );
2221  }
2222 
2223 
2224  UNIT_RES* GetUnits() const override
2225  {
2226  if( unit )
2227  return unit;
2228 
2229  return ELEM::GetUnits();
2230  }
2231 };
2232 typedef boost::ptr_vector<PADSTACK> PADSTACKS;
2233 
2234 
2239 inline bool operator<( const PADSTACK& lhs, const PADSTACK& rhs )
2240 {
2241  return PADSTACK::Compare( (PADSTACK*) &lhs, (PADSTACK*) &rhs ) < 0;
2242 }
2243 
2244 
2251 class LIBRARY : public ELEM
2252 {
2253  friend class SPECCTRA_DB;
2254 
2257 
2260 
2261 public:
2262 
2263  LIBRARY( ELEM* aParent, DSN_T aType = T_library ) :
2264  ELEM( aType, aParent )
2265  {
2266  unit = 0;
2267 // via_start_index = -1; // 0 or greater means there is at least one via
2268  }
2270  {
2271  delete unit;
2272  }
2273 
2274  void AddPadstack( PADSTACK* aPadstack )
2275  {
2276  aPadstack->SetParent( this );
2277  padstacks.push_back( aPadstack );
2278  }
2279 
2280 /*
2281  void SetViaStartIndex( int aIndex )
2282  {
2283  via_start_index = aIndex;
2284  }
2285  int GetViaStartIndex()
2286  {
2287  return via_start_index;
2288  }
2289 */
2290 
2291 
2297  int FindIMAGE( IMAGE* aImage )
2298  {
2299  unsigned i;
2300  for( i=0; i<images.size(); ++i )
2301  {
2302  if( 0 == IMAGE::Compare( aImage, &images[i] ) )
2303  return (int) i;
2304  }
2305 
2306  // There is no match to the IMAGE contents, but now generate a unique
2307  // name for it.
2308  int dups = 1;
2309  for( i=0; i<images.size(); ++i )
2310  {
2311  if( 0 == aImage->image_id.compare( images[i].image_id ) )
2312  aImage->duplicated = dups++;
2313  }
2314 
2315  return -1;
2316  }
2317 
2318 
2323  void AppendIMAGE( IMAGE* aImage )
2324  {
2325  aImage->SetParent( this );
2326  images.push_back( aImage );
2327  }
2328 
2338  {
2339  int ndx = FindIMAGE( aImage );
2340  if( ndx == -1 )
2341  {
2342  AppendIMAGE( aImage );
2343  return aImage;
2344  }
2345  return &images[ndx];
2346  }
2347 
2353  int FindVia( PADSTACK* aVia )
2354  {
2355  for( unsigned i = 0; i < vias.size(); ++i )
2356  {
2357  if( 0 == PADSTACK::Compare( aVia, &vias[i] ) )
2358  return int( i );
2359  }
2360  return -1;
2361  }
2362 
2367  void AppendVia( PADSTACK* aVia )
2368  {
2369  aVia->SetParent( this );
2370  vias.push_back( aVia );
2371  }
2372 
2373 
2378  void AppendPADSTACK( PADSTACK* aPadstack )
2379  {
2380  aPadstack->SetParent( this );
2381  padstacks.push_back( aPadstack );
2382  }
2383 
2393  {
2394  int ndx = FindVia( aVia );
2395  if( ndx == -1 )
2396  {
2397  AppendVia( aVia );
2398  return aVia;
2399  }
2400  return &vias[ndx];
2401  }
2402 
2408  PADSTACK* FindPADSTACK( const std::string& aPadstackId )
2409  {
2410  for( unsigned i=0; i<padstacks.size(); ++i )
2411  {
2412  PADSTACK* ps = &padstacks[i];
2413 
2414  if( ps->GetPadstackId().compare( aPadstackId ) == 0 )
2415  return ps;
2416  }
2417  return NULL;
2418  }
2419 
2420  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2421  {
2422  if( unit )
2423  unit->Format( out, nestLevel );
2424 
2425  for( IMAGES::iterator i = images.begin(); i != images.end(); ++i )
2426  i->Format( out, nestLevel );
2427 
2428  for( PADSTACKS::iterator i = padstacks.begin(); i != padstacks.end(); ++i )
2429  i->Format( out, nestLevel );
2430 
2431  for( PADSTACKS::iterator i = vias.begin(); i != vias.end(); ++i )
2432  i->Format( out, nestLevel );
2433  }
2434 
2435  UNIT_RES* GetUnits() const override
2436  {
2437  if( unit )
2438  return unit;
2439 
2440  return ELEM::GetUnits();
2441  }
2442 };
2443 
2444 
2449 struct PIN_REF : public ELEM
2450 {
2451  std::string component_id;
2452  std::string pin_id;
2453 
2454  PIN_REF( ELEM* aParent ) :
2455  ELEM( T_pin, aParent )
2456  {
2457  }
2458 
2459 
2465  int FormatIt( OUTPUTFORMATTER* out, int nestLevel )
2466  {
2467  // only print the newline if there is a nest level, and make
2468  // the quotes unconditional on this one.
2469  const char* newline = nestLevel ? "\n" : "";
2470 
2471  const char* cquote = out->GetQuoteChar( component_id.c_str() );
2472  const char* pquote = out->GetQuoteChar( pin_id.c_str() );
2473 
2474  return out->Print( nestLevel, "%s%s%s-%s%s%s%s",
2475  cquote, component_id.c_str(), cquote,
2476  pquote, pin_id.c_str(), pquote,
2477  newline );
2478  }
2479 };
2480 typedef std::vector<PIN_REF> PIN_REFS;
2481 
2482 
2483 class FROMTO : public ELEM
2484 {
2485  friend class SPECCTRA_DB;
2486 
2487  std::string fromText;
2488  std::string toText;
2489 
2491  std::string net_id;
2493 // std::string circuit;
2495 
2496 
2497 public:
2498  FROMTO( ELEM* aParent ) :
2499  ELEM( T_fromto, aParent )
2500  {
2501  rules = 0;
2502  fromto_type = DSN_T( T_NONE );
2503  }
2505  {
2506  delete rules;
2507  }
2508 
2509  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2510  {
2511  // no quoting on these two, the lexer preserved the quotes on input
2512  out->Print( nestLevel, "(%s %s %s ",
2513  Name(), fromText.c_str(), toText.c_str() );
2514 
2515  if( fromto_type != DSN_T( T_NONE ) )
2516  out->Print( 0, "(type %s)", GetTokenText( fromto_type ) );
2517 
2518  if( net_id.size() )
2519  {
2520  const char* quote = out->GetQuoteChar( net_id.c_str() );
2521  out->Print( 0, "(net %s%s%s)", quote, net_id.c_str(), quote );
2522  }
2523 
2524  bool singleLine = true;
2525 
2526  if( rules || layer_rules.size() )
2527  {
2528  out->Print( 0, "\n" );
2529  singleLine = false;
2530  }
2531 
2532  if( rules )
2533  rules->Format( out, nestLevel+1 );
2534 
2535  /*
2536  if( circuit.size() )
2537  out->Print( nestLevel, "%s\n", circuit.c_str() );
2538  */
2539 
2540  for( LAYER_RULES::iterator i = layer_rules.begin(); i != layer_rules.end(); ++i )
2541  i->Format( out, nestLevel+1 );
2542 
2543  out->Print( singleLine ? 0 : nestLevel, ")" );
2544 
2545  if( nestLevel || !singleLine )
2546  out->Print( 0, "\n" );
2547  }
2548 };
2549 typedef boost::ptr_vector<FROMTO> FROMTOS;
2550 
2551 
2556 class COMP_ORDER : public ELEM
2557 {
2558  friend class SPECCTRA_DB;
2559 
2561 
2562 public:
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 = placement_ids.begin(); i != 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 };
2584 typedef boost::ptr_vector<COMP_ORDER> COMP_ORDERS;
2585 
2591 class NET : public ELEM
2592 {
2593  friend class SPECCTRA_DB;
2594 
2595  std::string net_id;
2598 
2601 
2607 
2609 
2611 
2613 
2615 
2617 
2619 
2620 public:
2621 
2622  NET( ELEM* aParent ) :
2623  ELEM( T_net, aParent )
2624  {
2625  unassigned = false;
2626  net_number = T_NONE;
2627  pins_type = T_pins;
2628 
2629  type = T_NONE;
2630  supply = T_NONE;
2631 
2632  rules = 0;
2633  comp_order = 0;
2634  }
2635 
2637  {
2638  delete rules;
2639  delete comp_order;
2640  }
2641 
2642  int FindPIN_REF( const std::string& aComponent )
2643  {
2644  for( unsigned i = 0; i < pins.size(); ++i )
2645  {
2646  if( aComponent.compare( pins[i].component_id ) == 0 )
2647  return int(i);
2648  }
2649  return -1;
2650  }
2651 
2652  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2653  {
2654  const char* quote = out->GetQuoteChar( net_id.c_str() );
2655  const char* space = " ";
2656 
2657  out->Print( nestLevel, "(%s %s%s%s",
2658  Name(),
2659  quote, net_id.c_str(), quote );
2660 
2661  if( unassigned )
2662  {
2663  out->Print( 0, "%s(unassigned)", space );
2664  space = ""; // only needed one space
2665  }
2666 
2667  if( net_number != T_NONE )
2668  {
2669  out->Print( 0, "%s(net_number %d)", space, net_number );
2670  // space = "";
2671  }
2672 
2673  out->Print( 0, "\n" );
2674 
2675  if( pins.size() )
2676  {
2677  const int RIGHTMARGIN = 80;
2678  int perLine = out->Print( nestLevel+1, "(%s", GetTokenText( pins_type ) );
2679 
2680  for( PIN_REFS::iterator i=pins.begin(); i!=pins.end(); ++i )
2681  {
2682  if( perLine > RIGHTMARGIN )
2683  {
2684  out->Print( 0, "\n");
2685  perLine = out->Print( nestLevel+2, "%s", "" );
2686  }
2687  else
2688  {
2689  perLine += out->Print( 0, " " );
2690  }
2691 
2692  perLine += i->FormatIt( out, 0 );
2693  }
2694  out->Print( 0, ")\n" );
2695  }
2696 
2697  if( comp_order )
2698  comp_order->Format( out, nestLevel+1 );
2699 
2700  if( type != T_NONE )
2701  out->Print( nestLevel+1, "(type %s)\n", GetTokenText( type ) );
2702 
2703  if( rules )
2704  rules->Format( out, nestLevel+1 );
2705 
2706  for( LAYER_RULES::iterator i = layer_rules.begin(); i != layer_rules.end(); ++i )
2707  i->Format( out, nestLevel+1 );
2708 
2709  for( FROMTOS::iterator i = fromtos.begin(); i != fromtos.end(); ++i )
2710  i->Format( out, nestLevel+1 );
2711 
2712  out->Print( nestLevel, ")\n" );
2713  }
2714 };
2715 typedef boost::ptr_vector<NET> NETS;
2716 
2717 
2718 class TOPOLOGY : public ELEM
2719 {
2720  friend class SPECCTRA_DB;
2721 
2723 
2725 
2726 public:
2727  TOPOLOGY( ELEM* aParent ) :
2728  ELEM( T_topology, aParent )
2729  {
2730  }
2731 
2732  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2733  {
2734  for( FROMTOS::iterator i=fromtos.begin(); i!=fromtos.end(); ++i )
2735  i->Format( out, nestLevel );
2736 
2737  for( COMP_ORDERS::iterator i=comp_orders.begin(); i!=comp_orders.end(); ++i )
2738  i->Format( out, nestLevel );
2739  }
2740 };
2741 
2742 
2747 class CLASS : public ELEM
2748 {
2749  friend class SPECCTRA_DB;
2750 
2751  std::string class_id;
2752 
2754 
2757 
2759 
2761 
2763 
2764 public:
2765 
2766  CLASS( ELEM* aParent ) :
2767  ELEM( T_class, aParent )
2768  {
2769  rules = 0;
2770  topology = 0;
2771  }
2773  {
2774  delete rules;
2775  delete topology;
2776  }
2777 
2778 
2779  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2780  {
2781  const char* quote = out->GetQuoteChar( class_id.c_str() );
2782 
2783  int perLine = out->Print( nestLevel, "(%s %s%s%s",
2784  Name(),
2785  quote, class_id.c_str(), quote );
2786 
2787  const int RIGHTMARGIN = 72;
2788 
2789  for( STRINGS::iterator i=net_ids.begin(); i!=net_ids.end(); ++i )
2790  {
2791  const char* space = " ";
2792  if( perLine > RIGHTMARGIN )
2793  {
2794  out->Print( 0, "\n" );
2795  perLine = out->Print( nestLevel+1, "%s", "" );
2796  space = ""; // no space at first net_id of the line
2797  }
2798 
2799  quote = out->GetQuoteChar( i->c_str() );
2800  perLine += out->Print( 0, "%s%s%s%s", space, quote, i->c_str(), quote );
2801  }
2802 
2803  bool newLine = false;
2804  if( circuit.size() || rules || layer_rules.size() || topology )
2805  {
2806  out->Print( 0, "\n" );
2807  newLine = true;
2808  }
2809 
2810  if( circuit.size() )
2811  {
2812  out->Print( nestLevel+1, "(circuit\n" );
2813  for( STRINGS::iterator i=circuit.begin(); i!=circuit.end(); ++i )
2814  out->Print( nestLevel+2, "%s\n", i->c_str() );
2815  out->Print( nestLevel+1, ")\n" );
2816  }
2817 
2818  if( rules )
2819  rules->Format( out, nestLevel+1 );
2820 
2821  for( LAYER_RULES::iterator i=layer_rules.begin(); i!=layer_rules.end(); ++i )
2822  i->Format( out, nestLevel+1 );
2823 
2824  if( topology )
2825  topology->Format( out, nestLevel+1 );
2826 
2827  out->Print( newLine ? nestLevel : 0, ")\n" );
2828  }
2829 };
2830 typedef boost::ptr_vector<CLASS> CLASSLIST;
2831 
2832 
2833 class NETWORK : public ELEM
2834 {
2835  friend class SPECCTRA_DB;
2836 
2839 
2840 
2841 public:
2842 
2843  NETWORK( ELEM* aParent ) :
2844  ELEM( T_network, aParent )
2845  {
2846  }
2847 
2848  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
2849  {
2850  for( NETS::iterator i=nets.begin(); i!=nets.end(); ++i )
2851  i->Format( out, nestLevel );
2852 
2853  for( CLASSLIST::iterator i=classes.begin(); i!=classes.end(); ++i )
2854  i->Format( out, nestLevel );
2855  }
2856 };
2857 
2858 
2859 class CONNECT : public ELEM
2860 {
2861  // @todo not completed.
2862 
2863 public:
2864  CONNECT( ELEM* aParent ) :
2865  ELEM( T_connect, aParent ) {}
2866 };
2867 
2868 
2873 class WIRE : public ELEM
2874 {
2875  friend class SPECCTRA_DB;
2876 
2877  /* <shape_descriptor >::=
2878  [<rectangle_descriptor> |
2879  <circle_descriptor> |
2880  <polygon_descriptor> |
2881  <path_descriptor> |
2882  <qarc_descriptor> ]
2883  */
2885 
2886  std::string net_id;
2887  int turret;
2890  std::string shield;
2893  bool supply;
2894 
2895 public:
2896  WIRE( ELEM* aParent ) :
2897  ELEM( T_wire, aParent )
2898  {
2899  shape = 0;
2900  connect = 0;
2901 
2902  turret = -1;
2903  wire_type = T_NONE;
2904  attr = T_NONE;
2905  supply = false;
2906  }
2907 
2909  {
2910  delete shape;
2911  delete connect;
2912  }
2913 
2914  void SetShape( ELEM* aShape )
2915  {
2916  delete shape;
2917  shape = aShape;
2918 
2919  if( aShape )
2920  {
2921  wxASSERT(aShape->Type()==T_rect || aShape->Type()==T_circle
2922  || aShape->Type()==T_qarc || aShape->Type()==T_path
2923  || aShape->Type()==T_polygon);
2924 
2925  aShape->SetParent( this );
2926  }
2927  }
2928 
2929  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
2930  {
2931  out->Print( nestLevel, "(%s ", Name() );
2932 
2933  if( shape )
2934  shape->Format( out, 0 );
2935 
2936  if( net_id.size() )
2937  {
2938  const char* quote = out->GetQuoteChar( net_id.c_str() );
2939  out->Print( 0, "(net %s%s%s)",
2940  quote, net_id.c_str(), quote );
2941  }
2942 
2943  if( turret >= 0 )
2944  out->Print( 0, "(turrent %d)", turret );
2945 
2946  if( wire_type != T_NONE )
2947  out->Print( 0, "(type %s)", GetTokenText( wire_type ) );
2948 
2949  if( attr != T_NONE )
2950  out->Print( 0, "(attr %s)", GetTokenText( attr ) );
2951 
2952  if( shield.size() )
2953  {
2954  const char* quote = out->GetQuoteChar( shield.c_str() );
2955  out->Print( 0, "(shield %s%s%s)",
2956  quote, shield.c_str(), quote );
2957  }
2958 
2959  if( windows.size() )
2960  {
2961  out->Print( 0, "\n" );
2962 
2963  for( WINDOWS::iterator i=windows.begin(); i!=windows.end(); ++i )
2964  i->Format( out, nestLevel+1 );
2965  }
2966 
2967  if( connect )
2968  connect->Format( out, 0 );
2969 
2970  if( supply )
2971  out->Print( 0, "(supply)" );
2972 
2973  out->Print( 0, ")\n" );
2974  }
2975 };
2976 typedef boost::ptr_vector<WIRE> WIRES;
2977 
2978 
2983 class WIRE_VIA : public ELEM
2984 {
2985  friend class SPECCTRA_DB;
2986 
2987  std::string padstack_id;
2989  std::string net_id;
2993  std::string virtual_pin_name;
2995  bool supply;
2996 
2997 
2998 public:
2999  WIRE_VIA( ELEM* aParent ) :
3000  ELEM( T_via, aParent )
3001  {
3002  via_number = -1;
3003  via_type = T_NONE;
3004  attr = T_NONE;
3005  supply = false;
3006  }
3007 
3008  const std::string& GetPadstackId()
3009  {
3010  return padstack_id;
3011  }
3012 
3013  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3014  {
3015  const char* quote = out->GetQuoteChar( padstack_id.c_str() );
3016 
3017  const int RIGHTMARGIN = 80;
3018  int perLine = out->Print( nestLevel, "(%s %s%s%s",
3019  Name(),
3020  quote, padstack_id.c_str(), quote );
3021 
3022  for( POINTS::iterator i=vertexes.begin(); i!=vertexes.end(); ++i )
3023  {
3024  if( perLine > RIGHTMARGIN )
3025  {
3026  out->Print( 0, "\n" );
3027  perLine = out->Print( nestLevel+1, "%s", "" );
3028  }
3029  else
3030  perLine += out->Print( 0, " " );
3031 
3032  perLine += out->Print( 0, "%.6g %.6g", i->x, i->y );
3033  }
3034 
3035  if( net_id.size() || via_number!=-1 || via_type!=T_NONE || attr!=T_NONE || supply)
3036  out->Print( 0, " " );
3037 
3038  if( net_id.size() )
3039  {
3040  if( perLine > RIGHTMARGIN )
3041  {
3042  out->Print( 0, "\n" );
3043  perLine = out->Print( nestLevel+1, "%s", "" );
3044  }
3045  quote = out->GetQuoteChar( net_id.c_str() );
3046  perLine += out->Print( 0, "(net %s%s%s)", quote, net_id.c_str(), quote );
3047  }
3048 
3049  if( via_number != -1 )
3050  {
3051  if( perLine > RIGHTMARGIN )
3052  {
3053  out->Print( 0, "\n" );
3054  perLine = out->Print( nestLevel+1, "%s", "" );
3055  }
3056  perLine += out->Print( 0, "(via_number %d)", via_number );
3057  }
3058 
3059  if( via_type != T_NONE )
3060  {
3061  if( perLine > RIGHTMARGIN )
3062  {
3063  out->Print( 0, "\n" );
3064  perLine = out->Print( nestLevel+1, "%s", "" );
3065  }
3066  perLine += out->Print( 0, "(type %s)", GetTokenText( via_type ) );
3067  }
3068 
3069  if( attr != T_NONE )
3070  {
3071  if( perLine > RIGHTMARGIN )
3072  {
3073  out->Print( 0, "\n" );
3074  perLine = out->Print( nestLevel+1, "%s", "" );
3075  }
3076  if( attr == T_virtual_pin )
3077  {
3078  quote = out->GetQuoteChar( virtual_pin_name.c_str() );
3079  perLine += out->Print( 0, "(attr virtual_pin %s%s%s)",
3080  quote, virtual_pin_name.c_str(), quote );
3081  }
3082  else
3083  perLine += out->Print( 0, "(attr %s)", GetTokenText( attr ) );
3084  }
3085 
3086  if( supply )
3087  {
3088  if( perLine > RIGHTMARGIN )
3089  {
3090  out->Print( 0, "\n" );
3091  perLine = out->Print( nestLevel+1, "%s", "" );
3092  }
3093  perLine += out->Print( 0, "(supply)" );
3094  }
3095 
3096  if( contact_layers.size() )
3097  {
3098  out->Print( 0, "\n" );
3099  out->Print( nestLevel+1, "(contact\n" );
3100 
3101  for( STRINGS::iterator i=contact_layers.begin(); i!=contact_layers.end(); ++i )
3102  {
3103  quote = out->GetQuoteChar( i->c_str() );
3104  out->Print( nestLevel+2, "%s%s%s\n", quote, i->c_str(), quote );
3105  }
3106  out->Print( nestLevel+1, "))\n" );
3107  }
3108  else
3109  out->Print( 0, ")\n" );
3110  }
3111 };
3112 typedef boost::ptr_vector<WIRE_VIA> WIRE_VIAS;
3113 
3114 
3119 class WIRING : public ELEM
3120 {
3121  friend class SPECCTRA_DB;
3122 
3126 
3127 public:
3128 
3129  WIRING( ELEM* aParent ) :
3130  ELEM( T_wiring, aParent )
3131  {
3132  unit = 0;
3133  }
3135  {
3136  delete unit;
3137  }
3138 
3139  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3140  {
3141  if( unit )
3142  unit->Format( out, nestLevel );
3143 
3144  for( WIRES::iterator i=wires.begin(); i!=wires.end(); ++i )
3145  i->Format( out, nestLevel );
3146 
3147  for( WIRE_VIAS::iterator i=wire_vias.begin(); i!=wire_vias.end(); ++i )
3148  i->Format( out, nestLevel );
3149  }
3150 
3151  UNIT_RES* GetUnits() const override
3152  {
3153  if( unit )
3154  return unit;
3155 
3156  return ELEM::GetUnits();
3157  }
3158 };
3159 
3160 
3161 class PCB : public ELEM
3162 {
3163  friend class SPECCTRA_DB;
3164 
3165  std::string pcbname;
3174 
3175 public:
3176 
3177  PCB( ELEM* aParent = 0 ) :
3178  ELEM( T_pcb, aParent )
3179  {
3180  parser = 0;
3181  resolution = 0;
3182  unit = 0;
3183  structure = 0;
3184  placement = 0;
3185  library = 0;
3186  network = 0;
3187  wiring = 0;
3188  }
3189 
3191  {
3192  delete parser;
3193  delete resolution;
3194  delete unit;
3195  delete structure;
3196  delete placement;
3197  delete library;
3198  delete network;
3199  delete wiring;
3200  }
3201 
3202  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3203  {
3204  const char* quote = out->GetQuoteChar( pcbname.c_str() );
3205 
3206  out->Print( nestLevel, "(%s %s%s%s\n", Name(),
3207  quote, pcbname.c_str(), quote );
3208 
3209  if( parser )
3210  parser->Format( out, nestLevel+1 );
3211 
3212  if( resolution )
3213  resolution->Format( out, nestLevel+1 );
3214 
3215  if( unit )
3216  unit->Format( out, nestLevel+1 );
3217 
3218  if( structure )
3219  structure->Format( out, nestLevel+1 );
3220 
3221  if( placement )
3222  placement->Format( out, nestLevel+1 );
3223 
3224  if( library )
3225  library->Format( out, nestLevel+1 );
3226 
3227  if( network )
3228  network->Format( out, nestLevel+1 );
3229 
3230  if( wiring )
3231  wiring->Format( out, nestLevel+1 );
3232 
3233  out->Print( nestLevel, ")\n" );
3234  }
3235 
3236  UNIT_RES* GetUnits() const override
3237  {
3238  if( unit )
3239  return unit;
3240 
3241  if( resolution )
3242  return resolution->GetUnits();
3243 
3244  return ELEM::GetUnits();
3245  }
3246 };
3247 
3248 
3249 class ANCESTOR : public ELEM
3250 {
3251  friend class SPECCTRA_DB;
3252 
3253  std::string filename;
3254  std::string comment;
3255  time_t time_stamp;
3256 
3257 
3258 public:
3259  ANCESTOR( ELEM* aParent ) :
3260  ELEM( T_ancestor, aParent )
3261  {
3262  time_stamp = time(NULL);
3263  }
3264 
3265  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3266  {
3267  char temp[80];
3268  struct tm* tmp;
3269 
3270  tmp = localtime( &time_stamp );
3271  strftime( temp, sizeof(temp), "%b %d %H : %M : %S %Y", tmp );
3272 
3273  // format the time first to temp
3274  // filename may be empty, so quote it just in case.
3275  out->Print( nestLevel, "(%s \"%s\" (created_time %s)\n",
3276  Name(),
3277  filename.c_str(),
3278  temp );
3279 
3280  if( comment.size() )
3281  {
3282  const char* quote = out->GetQuoteChar( comment.c_str() );
3283  out->Print( nestLevel+1, "(comment %s%s%s)\n",
3284  quote, comment.c_str(), quote );
3285  }
3286 
3287  out->Print( nestLevel, ")\n" );
3288  }
3289 };
3290 typedef boost::ptr_vector<ANCESTOR> ANCESTORS;
3291 
3292 
3293 class HISTORY : public ELEM
3294 {
3295  friend class SPECCTRA_DB;
3296 
3298  time_t time_stamp;
3300 
3301 public:
3302 
3303  HISTORY( ELEM* aParent ) :
3304  ELEM( T_history, aParent )
3305  {
3306  time_stamp = time(NULL);
3307  }
3308 
3309  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3310  {
3311  for( ANCESTORS::iterator i=ancestors.begin(); i!=ancestors.end(); ++i )
3312  i->Format( out, nestLevel );
3313 
3314  char temp[80];
3315  struct tm* tmp;
3316 
3317  tmp = localtime( &time_stamp );
3318  strftime( temp, sizeof(temp), "%b %d %H : %M : %S %Y", tmp );
3319 
3320  // format the time first to temp
3321  out->Print( nestLevel, "(self (created_time %s)\n", temp );
3322 
3323  for( STRINGS::iterator i=comments.begin(); i!=comments.end(); ++i )
3324  {
3325  const char* quote = out->GetQuoteChar( i->c_str() );
3326  out->Print( nestLevel+1, "(comment %s%s%s)\n",
3327  quote, i->c_str(), quote );
3328  }
3329 
3330  out->Print( nestLevel, ")\n" );
3331  }
3332 };
3333 
3334 
3339 class SUPPLY_PIN : public ELEM
3340 {
3341  friend class SPECCTRA_DB;
3342 
3344  std::string net_id;
3345 
3346 public:
3347  SUPPLY_PIN( ELEM* aParent ) :
3348  ELEM( T_supply_pin, aParent )
3349  {
3350  }
3351 
3352  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3353  {
3354  bool singleLine = pin_refs.size() <= 1;
3355  out->Print( nestLevel, "(%s", Name() );
3356 
3357  if( singleLine )
3358  {
3359  out->Print( 0, "%s", " " );
3360  pin_refs.begin()->Format( out, 0 );
3361  }
3362  else
3363  {
3364  for( PIN_REFS::iterator i=pin_refs.begin(); i!=pin_refs.end(); ++i )
3365  i->FormatIt( out, nestLevel+1 );
3366  }
3367 
3368  if( net_id.size() )
3369  {
3370  const char* newline = singleLine ? "" : "\n";
3371 
3372  const char* quote = out->GetQuoteChar( net_id.c_str() );
3373  out->Print( singleLine ? 0 : nestLevel+1,
3374  " (net %s%s%s)%s", quote, net_id.c_str(), quote, newline );
3375  }
3376 
3377  out->Print( singleLine ? 0 : nestLevel, ")\n");
3378  }
3379 };
3380 typedef boost::ptr_vector<SUPPLY_PIN> SUPPLY_PINS;
3381 
3382 
3387 class NET_OUT : public ELEM
3388 {
3389  friend class SPECCTRA_DB;
3390 
3391  std::string net_id;
3397 
3398 
3399 public:
3400  NET_OUT( ELEM* aParent ) :
3401  ELEM( T_net_out, aParent )
3402  {
3403  rules = 0;
3404  net_number = -1;
3405  }
3407  {
3408  delete rules;
3409  }
3410 
3411  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3412  {
3413  const char* quote = out->GetQuoteChar( net_id.c_str() );
3414 
3415  // cannot use Type() here, it is T_net_out and we need "(net "
3416  out->Print( nestLevel, "(net %s%s%s\n",
3417  quote, net_id.c_str(), quote );
3418 
3419  if( net_number>= 0 )
3420  out->Print( nestLevel+1, "(net_number %d)\n", net_number );
3421 
3422  if( rules )
3423  rules->Format( out, nestLevel+1 );
3424 
3425  for( WIRES::iterator i=wires.begin(); i!=wires.end(); ++i )
3426  i->Format( out, nestLevel+1 );
3427 
3428  for( WIRE_VIAS::iterator i=wire_vias.begin(); i!=wire_vias.end(); ++i )
3429  i->Format( out, nestLevel+1 );
3430 
3431  for( SUPPLY_PINS::iterator i=supply_pins.begin(); i!=supply_pins.end(); ++i )
3432  i->Format( out, nestLevel+1 );
3433 
3434  out->Print( nestLevel, ")\n" );
3435  }
3436 };
3437 typedef boost::ptr_vector<NET_OUT> NET_OUTS;
3438 
3439 
3440 class ROUTE : public ELEM
3441 {
3442  friend class SPECCTRA_DB;
3443 
3449 // TEST_POINTS* test_points;
3450 
3451 public:
3452 
3453  ROUTE( ELEM* aParent ) :
3454  ELEM( T_route, aParent )
3455  {
3456  resolution = 0;
3457  parser = 0;
3458  structure_out = 0;
3459  library = 0;
3460  }
3462  {
3463  delete resolution;
3464  delete parser;
3465  delete structure_out;
3466  delete library;
3467 // delete test_points;
3468  }
3469 
3470  UNIT_RES* GetUnits() const override
3471  {
3472  if( resolution )
3473  return resolution;
3474 
3475  return ELEM::GetUnits();
3476  }
3477 
3478  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3479  {
3480  if( resolution )
3481  resolution->Format( out, nestLevel );
3482 
3483  if( parser )
3484  parser->Format( out, nestLevel );
3485 
3486  if( structure_out )
3487  structure_out->Format( out, nestLevel );
3488 
3489  if( library )
3490  library->Format( out, nestLevel );
3491 
3492  if( net_outs.size() )
3493  {
3494  out->Print( nestLevel, "(network_out\n" );
3495  for( NET_OUTS::iterator i=net_outs.begin(); i!=net_outs.end(); ++i )
3496  i->Format( out, nestLevel+1 );
3497  out->Print( nestLevel, ")\n" );
3498  }
3499 
3500 // if( test_poinst )
3501 // test_points->Format( out, nestLevel );
3502  }
3503 };
3504 
3505 
3511 struct PIN_PAIR
3512 {
3513  PIN_PAIR( ELEM* aParent = 0 ) :
3514  was( aParent ),
3515  is( aParent )
3516  {
3517  }
3518 
3521 };
3522 typedef std::vector<PIN_PAIR> PIN_PAIRS;
3523 
3524 
3529 class WAS_IS : public ELEM
3530 {
3531  friend class SPECCTRA_DB;
3532 
3534 
3535 public:
3536  WAS_IS( ELEM* aParent ) :
3537  ELEM( T_was_is, aParent )
3538  {
3539  }
3540 
3541  void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
3542  {
3543  for( PIN_PAIRS::iterator i=pin_pairs.begin(); i!=pin_pairs.end(); ++i )
3544  {
3545  out->Print( nestLevel, "(pins " );
3546  i->was.Format( out, 0 );
3547  out->Print( 0, " " );
3548  i->is.Format( out, 0 );
3549  out->Print( 0, ")\n" );
3550  }
3551  }
3552 };
3553 
3554 
3559 class SESSION : public ELEM
3560 {
3561  friend class SPECCTRA_DB;
3562 
3563  std::string session_id;
3564  std::string base_design;
3565 
3571 
3572 /* not supported:
3573  FLOOR_PLAN* floor_plan;
3574  NET_PIN_CHANGES* net_pin_changes;
3575  SWAP_HISTORY* swap_history;
3576 */
3577 
3578 public:
3579 
3580  SESSION( ELEM* aParent = 0 ) :
3581  ELEM( T_session, aParent )
3582  {
3583  history = 0;
3584  structure = 0;
3585  placement = 0;
3586  was_is = 0;
3587  route = 0;
3588  }
3590  {
3591  delete history;
3592  delete structure;
3593  delete placement;
3594  delete was_is;
3595  delete route;
3596  }
3597 
3598  void Format( OUTPUTFORMATTER* out, int nestLevel ) override
3599  {
3600  const char* quote = out->GetQuoteChar( session_id.c_str() );
3601  out->Print( nestLevel, "(%s %s%s%s\n", Name(),
3602  quote, session_id.c_str(), quote );
3603 
3604  out->Print( nestLevel+1, "(base_design \"%s\")\n", base_design.c_str() );
3605 
3606  if( history )
3607  history->Format( out, nestLevel+1 );
3608 
3609  if( structure )
3610  structure->Format( out, nestLevel+1 );
3611 
3612  if( placement )
3613  placement->Format( out, nestLevel+1 );
3614 
3615  if( was_is )
3616  was_is->Format( out, nestLevel+1 );
3617 
3618  if( route )
3619  route->Format( out, nestLevel+1 );
3620 
3621  out->Print( nestLevel, ")\n" );
3622  }
3623 };
3624 
3625 typedef boost::ptr_set<PADSTACK> PADSTACKSET;
3626 
3627 
3632 class SPECCTRA_DB : public SPECCTRA_LEXER
3633 {
3635  static const KEYWORD keywords[];
3636 
3639  wxString m_filename;
3640  std::string m_quote_char;
3641 
3643 
3645 
3647 
3648  std::vector<int> m_kicadLayer2pcb;
3649  std::vector<PCB_LAYER_ID> m_pcbLayer2kicad;
3650 
3653 
3656 
3657  static const KICAD_T scanPADs[];
3658 
3660 
3662  std::vector<NET*> m_nets;
3663 
3667 
3674  void buildLayerMaps( BOARD* aBoard );
3675 
3684  int findLayerName( const std::string& aLayerName ) const;
3685 
3702  void readCOMPnPIN( std::string* component_id, std::string* pid_id );
3703 
3718  void readTIME( time_t* time_stamp );
3719 
3720  void doPCB( PCB* growth );
3721  void doPARSER( PARSER* growth );
3722  void doRESOLUTION( UNIT_RES* growth );
3723  void doUNIT( UNIT_RES* growth );
3724  void doSTRUCTURE( STRUCTURE* growth );
3725  void doSTRUCTURE_OUT( STRUCTURE_OUT* growth );
3726  void doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth );
3728  void doBOUNDARY( BOUNDARY* growth );
3729  void doRECTANGLE( RECTANGLE* growth );
3730  void doPATH( PATH* growth );
3731  void doSTRINGPROP( STRINGPROP* growth );
3732  void doTOKPROP( TOKPROP* growth );
3733  void doVIA( VIA* growth );
3734  void doCONTROL( CONTROL* growth );
3735  void doLAYER( LAYER* growth );
3736  void doRULE( RULE* growth );
3737  void doKEEPOUT( KEEPOUT* growth );
3738  void doCIRCLE( CIRCLE* growth );
3739  void doQARC( QARC* growth );
3740  void doWINDOW( WINDOW* growth );
3741  void doCONNECT( CONNECT* growth );
3742  void doREGION( REGION* growth );
3743  void doCLASS_CLASS( CLASS_CLASS* growth );
3744  void doLAYER_RULE( LAYER_RULE* growth );
3745  void doCLASSES( CLASSES* growth );
3746  void doGRID( GRID* growth );
3747  void doPLACE( PLACE* growth );
3748  void doCOMPONENT( COMPONENT* growth );
3749  void doPLACEMENT( PLACEMENT* growth );
3750  void doPROPERTIES( PROPERTIES* growth );
3751  void doPADSTACK( PADSTACK* growth );
3752  void doSHAPE( SHAPE* growth );
3753  void doIMAGE( IMAGE* growth );
3754  void doLIBRARY( LIBRARY* growth );
3755  void doPIN( PIN* growth );
3756  void doNET( NET* growth );
3757  void doNETWORK( NETWORK* growth );
3758  void doCLASS( CLASS* growth );
3759  void doTOPOLOGY( TOPOLOGY* growth );
3760  void doFROMTO( FROMTO* growth );
3761  void doCOMP_ORDER( COMP_ORDER* growth );
3762  void doWIRE( WIRE* growth );
3763  void doWIRE_VIA( WIRE_VIA* growth );
3764  void doWIRING( WIRING* growth );
3765  void doSESSION( SESSION* growth );
3766  void doANCESTOR( ANCESTOR* growth );
3767  void doHISTORY( HISTORY* growth );
3768  void doROUTE( ROUTE* growth );
3769  void doWAS_IS( WAS_IS* growth );
3770  void doNET_OUT( NET_OUT* growth );
3771  void doSUPPLY_PIN( SUPPLY_PIN* growth );
3772 
3773  //-----<FromBOARD>-------------------------------------------------------
3774 
3782  void fillBOUNDARY( BOARD* aBoard, BOUNDARY* aBoundary );
3783 
3792  IMAGE* makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint );
3793 
3802  PADSTACK* makePADSTACK( BOARD* aBoard, PAD* aPad );
3803 
3814  PADSTACK* makeVia( int aCopperDiameter, int aDrillDiameter,
3815  int aTopLayer, int aBotLayer );
3816 
3824  PADSTACK* makeVia( const ::VIA* aVia );
3825 
3830  void deleteNETs()
3831  {
3832  for( unsigned n=0; n < m_nets.size(); ++n )
3833  delete m_nets[n];
3834 
3835  m_nets.clear();
3836  }
3837 
3842  void exportNETCLASS( const std::shared_ptr<NETCLASS>& aNetClass, BOARD* aBoard );
3843 
3844  //-----</FromBOARD>------------------------------------------------------
3845 
3846  //-----<FromSESSION>-----------------------------------------------------
3847 
3852  TRACK* makeTRACK( PATH* aPath, int aPointIndex, int aNetcode );
3853 
3859  ::VIA* makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNetCode, int aViaDrillDefault );
3860 
3861  //-----</FromSESSION>----------------------------------------------------
3862 
3863 public:
3864 
3866  SPECCTRA_LEXER( 0 ) // LINE_READER* == NULL, no DSNLEXER::PushReader()
3867  {
3868  // The LINE_READER will be pushed from an automatic instantiation,
3869  // we don't own it:
3870  wxASSERT( !iOwnReaders );
3871 
3872  m_pcb = 0;
3873  m_session = 0;
3874  m_quote_char += '"';
3875  m_footprintsAreFlipped = false;
3876 
3877  SetSpecctraMode( true );
3878 
3879  // Avoid not initialized members:
3881  m_sessionBoard = NULL;
3882  m_top_via_layer = 0;
3883  m_bot_via_layer = 0;
3884  }
3885 
3886  virtual ~SPECCTRA_DB()
3887  {
3888  delete m_pcb;
3889  delete m_session;
3890 
3891  deleteNETs();
3892  }
3893 
3898  static PCB* MakePCB();
3899 
3904  void SetPCB( PCB* aPcb )
3905  {
3906  delete m_pcb;
3907  m_pcb = aPcb;
3908  }
3909  PCB* GetPCB() { return m_pcb; }
3910 
3915  void SetSESSION( SESSION* aSession )
3916  {
3917  delete m_session;
3918  m_session = aSession;
3919  }
3921 
3931  void LoadPCB( const wxString& aFilename );
3932 
3943  void LoadSESSION( const wxString& aFilename );
3944 
3954  void ExportPCB( const wxString& aFilename, bool aNameChange=false );
3955 
3965  void FromBOARD( BOARD* aBoard );
3966 
3975  void FromSESSION( BOARD* aBoard );
3976 
3983  void ExportSESSION( const wxString& aFilename );
3984 
3989  void FlipFOOTPRINTs( BOARD* aBoard );
3990 
3995  void RevertFOOTPRINTs( BOARD* aBoard );
3996 };
3997 
3998 
3999 } // namespace DSN
4000 
4001 #endif // SPECCTRA_H_
4002 
4003 //EOF
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:3541
DSN_T units
Definition: specctra.h:404
void LoadSESSION(const wxString &aFilename)
Function LoadSESSION is a recursive descent parser for a SPECCTRA DSN "session" file.
Definition: specctra.cpp:262
PCB(ELEM *aParent=0)
Definition: specctra.h:3177
IMAGE(ELEM *aParent)
Definition: specctra.h:2018
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:3411
VIA corresponds to the <via_descriptor> in the specctra dsn spec.
Definition: specctra.h:1024
boost::ptr_vector< SUPPLY_PIN > SUPPLY_PINS
Definition: specctra.h:3380
boost::ptr_vector< COMP_ORDER > COMP_ORDERS
Definition: specctra.h:2584
void FixNegativeZero()
Function FixNegativeZero will change negative zero to positive zero in the IEEE floating point storag...
Definition: specctra.h:135
void doLAYER_NOISE_WEIGHT(LAYER_NOISE_WEIGHT *growth)
Definition: specctra.cpp:590
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:3265
TRACK * makeTRACK(PATH *aPath, int aPointIndex, int aNetcode)
Function makeTRACK creates a TRACK form the PATH and BOARD info.
boost::ptr_vector< PADSTACK > PADSTACKS
Definition: specctra.h:2232
PIN_REF corresponds to the <pin_reference> definition in the specctra dsn spec.
Definition: specctra.h:2449
LIBRARY(ELEM *aParent, DSN_T aType=T_library)
Definition: specctra.h:2263
bool space_in_quoted_tokens
Definition: specctra.h:371
DSN_T side
Definition: specctra.h:1999
static int Compare(IMAGE *lhs, IMAGE *rhs)
Function Compare compares two objects of this type and returns <0, 0, or >0.
Definition: specctra.cpp:3588
Definition: track.h:343
POINT vertex[3]
Definition: specctra.h:782
std::string layer_id
Definition: specctra.h:439
void SetAperture(double aWidth)
Definition: specctra.h:609
std::string pin_id
Definition: specctra.h:1944
void buildLayerMaps(BOARD *aBoard)
Function buildLayerMaps creates a few data translation structures for layer name and number mapping b...
Definition: specctra.cpp:74
void SetLayerId(const char *aLayerId)
Definition: specctra.h:806
void doKEEPOUT(KEEPOUT *growth)
Definition: specctra.cpp:787
DSN_T fromto_type
Definition: specctra.h:2490
BOARD * m_sessionBoard
a copy to avoid passing as an argument, memory for it is not owned here.
Definition: specctra.h:3655
void SetImageId(const std::string &aImageId)
Definition: specctra.h:1770
DSN_T lock_type
Definition: specctra.h:1696
double aperture_width
Definition: specctra.h:781
std::string shield
Definition: specctra.h:2890
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:711
DSN::T DSN_T
Definition: specctra.h:46
UNIT_RES * GetUnits() const override
Function GetUnits returns the units for this section.
Definition: specctra.h:2435
CLASSES(ELEM *aParent)
Definition: specctra.h:1093
NET(ELEM *aParent)
Definition: specctra.h:2622
boost::ptr_vector< NET > NETS
Definition: specctra.h:2715
RULE * rules
Definition: specctra.h:2130
PIN(ELEM *aParent)
Definition: specctra.h:1951
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:2732
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:151
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3494
boost::ptr_vector< CLASS > CLASSLIST
Definition: specctra.h:2830
LAYER(ELEM *aParent)
Definition: specctra.h:1202
virtual ~SPECCTRA_DB()
Definition: specctra.h:3886
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:2848
void SetPlaceBOUNDARY(BOUNDARY *aBoundary)
Definition: specctra.h:1605
void exportNETCLASS(const std::shared_ptr< NETCLASS > &aNetClass, BOARD *aBoard)
Function exportNETCLASS exports aNetClass to the DSN file.
STRINGS placement_ids
Definition: specctra.h:2560
DSN_T attr
Definition: specctra.h:2889
NET corresponds to a <net_descriptor> in the DSN spec.
Definition: specctra.h:2591
SHAPE(ELEM *aParent, DSN_T aType=T_shape)
Constructor SHAPE alternatively takes a DSN_T aType of T_outline.
Definition: specctra.h:1901
This source file implements export and import capabilities to the specctra dsn file format.
Definition: specctra.cpp:62
COPPER_PLANES planes
Definition: specctra.h:1558
std::vector< PROPERTY > PROPERTIES
Definition: specctra.h:183
SESSION * GetSESSION()
Definition: specctra.h:3920
PIN_PAIRS pin_pairs
Definition: specctra.h:3533
CIRCLE(ELEM *aParent)
Definition: specctra.h:738
CLASSES * classes
Definition: specctra.h:1113
void doCLASS_CLASS(CLASS_CLASS *growth)
Definition: specctra.cpp:1582
STRINGS circuit
circuit descriptor list
Definition: specctra.h:2756
STRINGS comments
Definition: specctra.h:3299
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:2652
int FindPIN_REF(const std::string &aComponent)
Definition: specctra.h:2642
void doGRID(GRID *growth)
Definition: specctra.cpp:1650
void SetStart(const POINT &aStart)
Definition: specctra.h:811
double y
Definition: specctra.h:96
std::string net_id
Definition: specctra.h:2595
bool via_rotate_first
Definition: specctra.h:377
DSN_T direction
T_x | T_y | -1 for both.
Definition: specctra.h:1469
UNIT_RES * unit
Definition: specctra.h:3123
FROMTOS fromtos
Definition: specctra.h:2616
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:3013
boost::ptr_vector< PIN > PINS
Definition: specctra.h:1987
boost::ptr_vector< LAYER > LAYERS
Definition: specctra.h:1275
void doWIRE(WIRE *growth)
Definition: specctra.cpp:2760
STRINGS padstacks
Definition: specctra.h:1028
KEEPOUTS keepouts
Definition: specctra.h:2012
POINTS & GetPoints()
Definition: specctra.h:602
std::string component_id
Definition: specctra.h:2451
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:1370
void doCONTROL(CONTROL *growth)
Definition: specctra.cpp:1189
boost::ptr_vector< WIRE_VIA > WIRE_VIAS
Definition: specctra.h:3112
PIN_REFS pin_refs
Definition: specctra.h:3343
CONTROL(ELEM *aParent)
Definition: specctra.h:1156
RULE * rules
Definition: specctra.h:1554
void doROUTE(ROUTE *growth)
Definition: specctra.cpp:3255
bool m_footprintsAreFlipped
Definition: specctra.h:3642
boost::ptr_vector< COPPER_PLANE > COPPER_PLANES
Definition: specctra.h:1347
STRINGS class_ids
Definition: specctra.h:1090
Struct PIN_PAIR is used within the WAS_IS class below to hold a pair of PIN_REFs and corresponds to t...
Definition: specctra.h:3511
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:3598
boost::ptr_vector< PATH > PATHS
Definition: specctra.h:651
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:173
PINS pins
Definition: specctra.h:2007
SESSION corresponds to the <session_file_descriptor> in the specctra dsn spec.
Definition: specctra.h:3559
void doTOKPROP(TOKPROP *growth)
Definition: specctra.cpp:1147
NET_OUTS net_outs
Definition: specctra.h:3448
void doLAYER(LAYER *growth)
Definition: specctra.cpp:1259
static const KEYWORD keywords[]
specctra DSN keywords
Definition: specctra.h:3635
double offset
Definition: specctra.h:1470
ELEM * shape
Definition: specctra.h:914
int duplicated
no. times this image_id is duplicated
Definition: specctra.h:2014
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:2072
void doSPECCTRA_LAYER_PAIR(SPECCTRA_LAYER_PAIR *growth)
Definition: specctra.cpp:574
RULE * rules
Definition: specctra.h:2492
std::string base_design
Definition: specctra.h:3564
static int Compare(PADSTACK *lhs, PADSTACK *rhs)
Function Compare compares two objects of this type and returns <0, 0, or >0.
Definition: specctra.cpp:3566
const char * Name() const
Definition: specctra.cpp:3505
int FindVia(PADSTACK *aVia)
Function FindVia searches this LIBRARY for a via which matches the argument.
Definition: specctra.h:2353
PLACE(ELEM *aParent)
Definition: specctra.h:1707
void doPROPERTIES(PROPERTIES *growth)
Definition: specctra.cpp:1236
std::string part_number
Definition: specctra.h:1703
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:2420
std::string net_id
Definition: specctra.h:3344
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:501
PADSTACKS vias
Definition: specctra.h:2259
void doSTRUCTURE_OUT(STRUCTURE_OUT *growth)
Definition: specctra.cpp:744
std::string name
Definition: specctra.h:162
POINT & operator+=(const POINT &other)
Definition: specctra.h:115
RULE * rules
Definition: specctra.h:2612
bool routes_include_testpoint
Definition: specctra.h:374
void doNET(NET *growth)
Definition: specctra.cpp:2323
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:1294
std::string logical_part
Definition: specctra.h:1690
RULE * rules
Definition: specctra.h:902
IMAGE * LookupIMAGE(IMAGE *aImage)
Function LookupIMAGE will add the image only if one exactly like it does not already exist in the ima...
Definition: specctra.h:2337
int FindIMAGE(IMAGE *aImage)
Function FindIMAGE searches this LIBRARY for an image which matches the argument.
Definition: specctra.h:2297
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:1485
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel)
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:263
PIN_REF(ELEM *aParent)
Definition: specctra.h:2454
void SetLayerId(const char *aLayerId)
Definition: specctra.h:604
void SetLayerId(const char *aLayerId)
Definition: specctra.h:759
UNIT_RES * unit
Definition: specctra.h:1544
void doPLACE(PLACE *growth)
Definition: specctra.cpp:1740
void doVIA(VIA *growth)
Definition: specctra.cpp:1160
POINTS vertexes
Definition: specctra.h:2988
UNIT_RES is a holder for either a T_unit or T_resolution object which are usually mutually exclusive ...
Definition: specctra.h:400
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:2568
void Delete(int aIndex)
Definition: specctra.h:354
int kiNetCode
KiCad netcode.
Definition: specctra.h:1947
DSN_T type
T_fix | T_normal.
Definition: specctra.h:2608
NET_OUT(ELEM *aParent)
Definition: specctra.h:3400
void SetConnect(DSN_T aConnect)
Definition: specctra.h:1907
void fillBOUNDARY(BOARD *aBoard, BOUNDARY *aBoundary)
Function fillBOUNDARY makes the board perimeter for the DSN file by filling the BOUNDARY element in t...
UNIT_RES * unit
Definition: specctra.h:2121
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:550
UNIT_RES * resolution
Definition: specctra.h:3167
RECTANGLE(ELEM *aParent)
Definition: specctra.h:446
STRINGS m_layerIds
indexed by PCB layer number
Definition: specctra.h:3646
IMAGE * makeIMAGE(BOARD *aBoard, FOOTPRINT *aFootprint)
Function makeIMAGE allocates an IMAGE on the heap and creates all the PINs according to the PADs in t...
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:306
UNIT_RES * unit
Definition: specctra.h:2255
WIRE_VIA(ELEM *aParent)
Definition: specctra.h:2999
void doRESOLUTION(UNIT_RES *growth)
Definition: specctra.cpp:526
void doWIRING(WIRING *growth)
Definition: specctra.cpp:2987
void AppendPoint(const POINT &aPoint)
Definition: specctra.h:597
CLASS corresponds to the <class_descriptor> in the specctra spec.
Definition: specctra.h:2747
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:1218
boost::ptr_vector< ELEM > ELEM_ARRAY
Definition: specctra.h:284
void doREGION(REGION *growth)
Definition: specctra.cpp:1513
SESSION(ELEM *aParent=0)
Definition: specctra.h:3580
PLACES places
Definition: specctra.h:1761
double x
Definition: specctra.h:95
int direction
Definition: specctra.h:1192
boost::ptr_vector< NET_OUT > NET_OUTS
Definition: specctra.h:3437
STRUCTURE * structure
Definition: specctra.h:3567
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:3478
std::string via_id
Definition: specctra.h:2128
ELEM * parent
Definition: specctra.h:199
void SetPCB(PCB *aPcb)
Function SetPCB deletes any existing PCB and replaces it with the given one.
Definition: specctra.h:3904
PADSTACK()
Constructor PADSTACK() cannot take ELEM* aParent because PADSTACKSET confuses this with a copy constr...
Definition: specctra.h:2140
void SetRotation(double aRotation)
Definition: specctra.h:1959
UNIT_RES * GetUnits() const override
Function GetUnits returns the units for this section.
Definition: specctra.h:2099
STRUCTURE * structure
Definition: specctra.h:3169
virtual ~ELEM()
Definition: specctra.cpp:3501
ELEM * Replace(int aIndex, ELEM *aElem)
Definition: specctra.h:325
void doCOMPONENT(COMPONENT *growth)
Definition: specctra.cpp:1855
PIN_REFS noexpose
Definition: specctra.h:2603
DSN_T GetEngUnits() const
Definition: specctra.h:422
UNIT_RES(ELEM *aParent, DSN_T aType)
Definition: specctra.h:415
ELEM * operator[](int aIndex) const
Definition: specctra.h:349
COMP_ORDER * comp_order
Definition: specctra.h:2618
RULE * rules
Definition: specctra.h:1423
A name/value tuple with unique names and optional values.
Definition: properties.h:33
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:1441
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:2172
WIRING * wiring
Definition: specctra.h:3173
void SetLayerId(const char *aLayerId)
Definition: specctra.h:451
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:1846
PIN_REF was
Definition: specctra.h:3519
WAS_IS corresponds to the <was_is_descriptor> in the specctra dsn spec.
Definition: specctra.h:3529
static PCB * MakePCB()
Function MakePCB makes a PCB with all the default ELEMs and parts on the heap.
Definition: specctra.cpp:3467
std::string net_id
Definition: specctra.h:2989
int FormatIt(OUTPUTFORMATTER *out, int nestLevel)
Function FormatIt is like Format() but is not virual and returns the number of characters that were o...
Definition: specctra.h:2465
DSN_T grid_type
T_via | T_wire | T_via_keepout | T_place | T_snap.
Definition: specctra.h:1467
std::string class_id
Definition: specctra.h:2751
void doIMAGE(IMAGE *growth)
Definition: specctra.cpp:2126
void SetVertex(const POINT &aPoint)
Definition: specctra.h:1965
int cost_type
T_length | T_way.
Definition: specctra.h:1194
IMAGES images
Definition: specctra.h:2256
STRUCTURE_OUT * structure_out
Definition: specctra.h:3446
DSN_T image_type
Definition: specctra.h:1471
std::string layer_id
Definition: specctra.h:582
PIN_REF is
Definition: specctra.h:3520
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:2779
int GetValue() const
Definition: specctra.h:423
BOUNDARY * place_boundary
Definition: specctra.h:1551
std::string value
Definition: specctra.h:163
bool supply
Definition: specctra.h:2893
time_t time_stamp
Definition: specctra.h:3298
boost::ptr_vector< LAYER_RULE > LAYER_RULES
Definition: specctra.h:570
DSN_T via_type
Definition: specctra.h:2991
DSN_T status
Definition: specctra.h:1688
CONNECT(ELEM *aParent)
Definition: specctra.h:2864
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
RULE corresponds to the <rule_descriptor> in the specctra dsn spec.
Definition: specctra.h:488
void SetVertex(const POINT &aVertex)
Definition: specctra.h:1733
UNIT_RES * GetUnits() const override
Function GetUnits returns the units for this section.
Definition: specctra.h:3236
RECTANGLE * rectangle
Definition: specctra.h:1415
std::string makeHash()
Function makeHash returns a string which uniquely represents this ELEM amoung other ELEMs of the same...
Definition: specctra.h:211
CONTROL * control
Definition: specctra.h:1553
LAYER_NOISE_WEIGHT(ELEM *aParent)
Definition: specctra.h:1317
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:3309
void doLIBRARY(LIBRARY *growth)
Definition: specctra.cpp:2269
void SetShape(ELEM *aShape)
Definition: specctra.h:861
ROUTE(ELEM *aParent)
Definition: specctra.h:3453
void doANCESTOR(ANCESTOR *growth)
Definition: specctra.cpp:3043
STRINGS layer_ids
Definition: specctra.h:534
STRING_FORMATTER m_sf
Definition: specctra.h:3644
static const KICAD_T scanPADs[]
Definition: specctra.h:3657
POINT vertex
Definition: specctra.h:1685
void doWINDOW(WINDOW *growth)
Definition: specctra.cpp:913
void SetSESSION(SESSION *aSession)
Function SetSESSION deletes any existing SESSION and replaces it with the given one.
Definition: specctra.h:3915
int findLayerName(const std::string &aLayerName) const
Function findLayerName returns the PCB layer index for a given layer name, within the specctra sessio...
Definition: specctra.cpp:124
void doRULE(RULE *growth)
Definition: specctra.cpp:1381
PATH supports both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
Definition: specctra.h:578
bool unassigned
Definition: specctra.h:2596
int turret
Definition: specctra.h:2887
WAS_IS(ELEM *aParent)
Definition: specctra.h:3536
COMP_ORDER corresponds to the <component_order_descriptor>.
Definition: specctra.h:2556
boost::ptr_vector< WINDOW > WINDOWS
Definition: specctra.h:888
FROMTOS fromtos
Definition: specctra.h:2722
std::vector< NET * > m_nets
we don't want ownership here permanently, so we don't use boost::ptr_vector
Definition: specctra.h:3662
const std::string & GetPadstackId()
Definition: specctra.h:2155
double rotation
Definition: specctra.h:1682
bool hasVertex
Definition: specctra.h:1684
ELEM * shape
Definition: specctra.h:2884
DSN_T layer_type
one of: T_signal, T_power, T_mixed, T_jumper
Definition: specctra.h:1191
UNIT_RES * GetUnits() const override
Function GetUnits returns the units for this section.
Definition: specctra.h:3470
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.cpp:3639
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:425
PCB * GetPCB()
Definition: specctra.h:3909
void doCOMP_ORDER(COMP_ORDER *growth)
Definition: specctra.cpp:2656
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:2509
void SetShape(ELEM *aShape)
Definition: specctra.h:940
std::string comment
Definition: specctra.h:3254
ANCESTORS ancestors
Definition: specctra.h:3297
WIRES wires
Definition: specctra.h:3124
RULE * place_rules
Definition: specctra.h:1563
bool isRotated
Definition: specctra.h:1943
POINT point0
one of two opposite corners
Definition: specctra.h:441
UNIT_RES * GetUnits() const override
Function GetUnits returns the units for this section.
Definition: specctra.h:1861
std::vector< int > m_kicadLayer2pcb
maps BOARD layer number to PCB layer numbers
Definition: specctra.h:3648
LAYER_RULES layer_rules
Definition: specctra.h:2494
PADSTACK * FindPADSTACK(const std::string &aPadstackId)
Function FindPADSTACK searches the padstack container by name.
Definition: specctra.h:2408
SUPPLY_PIN(ELEM *aParent)
Definition: specctra.h:3347
STRUCTURE_OUT(ELEM *aParent)
Definition: specctra.h:1518
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:1098
std::string image_id
Definition: specctra.h:1998
int net_number
Definition: specctra.h:2597
std::string name
Definition: specctra.h:1190
WIRES wires
Definition: specctra.h:3394
bool operator==(const POINT &other) const
Definition: specctra.h:105
PIN_REFS terminator
Definition: specctra.h:2606
std::string net_id
Definition: specctra.h:2491
Normal via.
Definition: router_tool.cpp:67
#define NULL
STRINGPROP(ELEM *aParent, DSN_T aType)
Definition: specctra.h:1392
TOKPROP is a container for a single property whose value is another DSN_T token.
Definition: specctra.h:1355
void AddWindow(WINDOW *aWindow)
Definition: specctra.h:957
std::string session_id
Definition: specctra.h:3563
PARSER(ELEM *aParent)
Definition: specctra.cpp:3619
void AppendIMAGE(IMAGE *aImage)
Function AppendIMAGE adds the image to the image list.
Definition: specctra.h:2323
boost::ptr_vector< REGION > REGIONS
Definition: specctra.h:1560
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:3202
std::string host_version
Definition: specctra.h:384
RULE * place_rules
Definition: specctra.h:2010
void doCLASS(CLASS *growth)
Definition: specctra.cpp:2501
DSN_T rotate
Definition: specctra.h:2125
boost::ptr_vector< COMPONENT > COMPONENTS
Definition: specctra.h:1799
COPPER_PLANE corresponds to a <plane_descriptor> in the specctra dsn spec.
Definition: specctra.h:1338
void deleteNETs()
Function deleteNETs deletes all the NETs that may be in here.
Definition: specctra.h:3830
DSN_T attach
Definition: specctra.h:2127
bool routes_include_image_conductor
Definition: specctra.h:376
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:1322
std::string padstack_id
Definition: specctra.h:2987
Represent a set of closed polygons.
void doPADSTACK(PADSTACK *growth)
Definition: specctra.cpp:1940
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:468
RULE * rules
Definition: specctra.h:3393
DSN_T side
Definition: specctra.h:1680
void doPATH(PATH *growth)
Definition: specctra.cpp:1014
GRID(ELEM *aParent)
Definition: specctra.h:1475
void RevertFOOTPRINTs(BOARD *aBoard)
Function RevertFOOTPRINTs flips the footprints which were on the back side of the board back to the b...
PLACE implements the <placement_reference> in the specctra dsn spec.
Definition: specctra.h:1674
void doSUPPLY_PIN(SUPPLY_PIN *growth)
Definition: specctra.cpp:3406
LAYER_NOISE_WEIGHT * layer_noise_weight
Definition: specctra.h:1548
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:46
SPECCTRA_LAYER_PAIR(ELEM *aParent)
Definition: specctra.h:1288
void doRECTANGLE(RECTANGLE *growth)
Definition: specctra.cpp:1062
bool via_at_smd
Definition: specctra.h:1152
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:1613
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:3139
void doHISTORY(HISTORY *growth)
Definition: specctra.cpp:3081
PROPERTIES properties
Definition: specctra.h:1694
PARSER * parser
Definition: specctra.h:3445
DSN_T connect
Definition: specctra.h:1882
PIN_REFS expose
Definition: specctra.h:2602
LIBRARY * library
Definition: specctra.h:3447
std::string hash
a hash string used by Compare(), not Format()ed/exported.
Definition: specctra.h:2118
void readTIME(time_t *time_stamp)
Function readTIME reads a <time_stamp> which consists of 8 lexer tokens: "month date hour : minute : ...
Definition: specctra.cpp:177
std::vector< PIN_PAIR > PIN_PAIRS
Definition: specctra.h:3522
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:286
RULE * place_rules
Definition: specctra.h:1692
PATH * polygon
Definition: specctra.h:1416
std::string filename
Definition: specctra.h:3253
SUPPLY_PINS supply_pins
Definition: specctra.h:3396
std::string region_id
Definition: specctra.h:1412
bool operator<(const PADSTACK &lhs, const PADSTACK &rhs)
Function operator< is used by the PADSTACKSET boost::ptr_set below.
Definition: specctra.h:2239
std::string image_id
Definition: specctra.h:1760
WIRING(ELEM *aParent)
Definition: specctra.h:3129
void AddPadstack(PADSTACK *aPadstack)
Definition: specctra.h:2274
::VIA * makeVIA(PADSTACK *aPadstack, const POINT &aPoint, int aNetCode, int aViaDrillDefault)
Function makeVIA instantiates a KiCad VIA on the heap and initializes it with internal values consist...
KEEPOUT(ELEM *aParent, DSN_T aType)
Constructor KEEPOUT requires a DSN_T because this class is used for T_place_keepout,...
Definition: specctra.h:923
WIRE(ELEM *aParent)
Definition: specctra.h:2896
boost::ptr_set< PADSTACK > PADSTACKSET
Definition: specctra.h:3625
const std::string & GetImageId() const
Definition: specctra.h:1769
TOKPROP(ELEM *aParent, DSN_T aType)
Definition: specctra.h:1363
boost::ptr_vector< GRID > GRIDS
Definition: specctra.h:1565
COMPONENT(ELEM *aParent)
Definition: specctra.h:1764
std::string component_id
reference designator
Definition: specctra.h:1678
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:744
PADSTACK holds either a via or a pad definition.
Definition: specctra.h:2114
void Append(ELEM *aElem)
Definition: specctra.h:320
wxString m_filename
Definition: specctra.h:3639
PLACEMENT(ELEM *aParent)
Definition: specctra.h:1813
boost::ptr_vector< KEEPOUT > KEEPOUTS
Definition: specctra.h:1017
WIRE_VIAS wire_vias
Definition: specctra.h:3125
int m_top_via_layer
specctra cu layers, 0 based index:
Definition: specctra.h:3665
const std::string & GetString()
Definition: richio.h:435
std::vector< std::string > STRINGS
Definition: specctra.h:157
RULE(ELEM *aParent, DSN_T aType)
Definition: specctra.h:496
FROMTO(ELEM *aParent)
Definition: specctra.h:2498
SPECCTRA_DB holds a DSN data tree, usually coming from a DSN file.
Definition: specctra.h:3632
void AppendPADSTACK(PADSTACK *aPadstack)
Function AppendPADSTACK adds the padstack to the padstack container.
Definition: specctra.h:2378
std::string fromText
Definition: specctra.h:2487
CLASS(ELEM *aParent)
Definition: specctra.h:2766
PIN_REFS load
Definition: specctra.h:2605
WIRE_VIAS wire_vias
Definition: specctra.h:3395
POINT vertex
Definition: specctra.h:735
CLASSLIST classes
Definition: specctra.h:2838
REGIONS regions
Definition: specctra.h:1561
void doPCB(PCB *growth)
Definition: specctra.cpp:282
WINDOWS windows
Definition: specctra.h:2891
RECTANGLE * rectangle
Definition: specctra.h:660
RULE * rules
Definition: specctra.h:1699
TOPOLOGY(ELEM *aParent)
Definition: specctra.h:2727
void doSTRUCTURE(STRUCTURE *growth)
Definition: specctra.cpp:610
void doCLASSES(CLASSES *growth)
Definition: specctra.cpp:1627
POINT GetEnd()
Definition: specctra.h:466
double dimension
Definition: specctra.h:1468
COMPONENT * LookupCOMPONENT(const std::string &imageName)
Function LookupCOMPONENT looks up a COMPONENT by name.
Definition: specctra.h:1832
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:1529
std::string layer_id
Definition: specctra.h:732
std::string padstack_id
Definition: specctra.h:1941
std::string layer_id
Definition: specctra.h:780
UNIT_RES * resolution
Definition: specctra.h:3444
void doWIRE_VIA(WIRE_VIA *growth)
Definition: specctra.cpp:2883
PARSER * parser
Definition: specctra.h:3166
virtual void Format(OUTPUTFORMATTER *out, int nestLevel)
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.cpp:3519
DSN_T type
Definition: specctra.h:198
void doCIRCLE(CIRCLE *growth)
Definition: specctra.cpp:1087
PADSTACK * makePADSTACK(BOARD *aBoard, PAD *aPad)
Function makePADSTACK creates a PADSTACK which matches the given pad.
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:331
DSN_T supply
T_power | T_ground.
Definition: specctra.h:2610
void SetRotation(double aRotation)
Definition: specctra.h:1740
LIBRARY * library
Definition: specctra.h:3171
DSN_T flip_style
Definition: specctra.h:1808
std::string GetImageId()
Definition: specctra.h:2040
QARC(ELEM *aParent)
Definition: specctra.h:785
ANCESTOR(ELEM *aParent)
Definition: specctra.h:3259
UNIT_RES * m_routeResolution
used during FromSESSION() only, memory for it is not owned here.
Definition: specctra.h:3652
SHAPE corresponds to the "(shape ..)" element in the specctra dsn spec.
Definition: specctra.h:1878
boost::ptr_vector< FROMTO > FROMTOS
Definition: specctra.h:2549
PLACEMENT * placement
Definition: specctra.h:3568
LAYER_RULES layer_rules
Definition: specctra.h:2614
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:1043
void doSTRINGPROP(STRINGPROP *growth)
Definition: specctra.cpp:1139
const std::string & GetPadstackId()
Definition: specctra.h:3008
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:1912
void doPIN(PIN *growth)
Definition: specctra.cpp:2222
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:1971
STRINGS spares
Definition: specctra.h:1029
time_t time_stamp
Definition: specctra.h:3255
UNIT_RES * GetUnits() const override
Function GetUnits returns the units for this section.
Definition: specctra.h:2224
std::vector< POINT > POINTS
Definition: specctra.h:158
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:791
COMP_ORDERS comp_orders
Definition: specctra.h:2724
void LoadPCB(const wxString &aFilename)
Function LoadPCB is a recursive descent parser for a SPECCTRA DSN "design" file.
Definition: specctra.cpp:243
boost::ptr_vector< IMAGE > IMAGES
Definition: specctra.h:2107
RULE * rules
Definition: specctra.h:1195
COMP_ORDER(ELEM *aParent)
Definition: specctra.h:2563
bool case_sensitive
Definition: specctra.h:372
void doTOPOLOGY(TOPOLOGY *growth)
Definition: specctra.cpp:2463
PADSTACK * LookupVia(PADSTACK *aVia)
Function LookupVia will add the via only if one exactly like it does not already exist in the padstac...
Definition: specctra.h:2392
UNIT_RES * GetUnits() const override
Function GetUnits returns the units for this section.
Definition: specctra.h:1660
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Compare compares two objects of this type and returns <0, 0, or >0.
Definition: specctra.h:1782
COMPONENT implements the <component_descriptor> in the specctra dsn spec.
Definition: specctra.h:1754
LIBRARY corresponds to the <library_descriptor> in the specctra dsn specification.
Definition: specctra.h:2251
STRINGS constants
This holds pairs of strings, one pair for each constant definition.
Definition: specctra.h:381
std::vector< PCB_LAYER_ID > m_pcbLayer2kicad
maps PCB layer number to BOARD layer numbers
Definition: specctra.h:3649
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:614
char string_quote
Definition: specctra.h:370
Struct POINT is a holder for a point in the SPECCTRA DSN coordinate system.
Definition: specctra.h:93
std::string host_cad
Definition: specctra.h:383
POINT point1
Definition: specctra.h:442
void FromBOARD(BOARD *aBoard)
Function FromBOARD adds the entire BOARD to the PCB but does not write it out.
UNIT_RES * unit
Definition: specctra.h:1806
REGION(ELEM *aParent)
Definition: specctra.h:1426
boost::ptr_vector< SPECCTRA_LAYER_PAIR > SPECCTRA_LAYER_PAIRS
Definition: specctra.h:1306
WINDOW(ELEM *aParent, DSN_T aType=T_window)
Definition: specctra.h:850
double rotation
Definition: specctra.h:1942
void Insert(int aIndex, ELEM *aElem)
Definition: specctra.h:337
WIRE corresponds to <wire_shape_descriptor> in the specctra dsn spec.
Definition: specctra.h:2873
std::vector< PIN_REF > PIN_REFS
Definition: specctra.h:2480
PATHS paths
Definition: specctra.h:659
Helper class to centralize the paths used throughout kicad.
Definition: paths.h:29
void SetCorners(const POINT &aPoint0, const POINT &aPoint1)
Definition: specctra.h:456
STRINGS contact_layers
Definition: specctra.h:2994
void ExportPCB(const wxString &aFilename, bool aNameChange=false)
Function ExportPCB writes the internal PCB instance out as a SPECTRA DSN format file.
Definition: specctra.cpp:3442
int net_number
Definition: specctra.h:3392
DSN_T value
Definition: specctra.h:1359
void AppendVia(PADSTACK *aVia)
Function AppendVia adds aVia to the internal via container.
Definition: specctra.h:2367
boost::ptr_vector< PLACE > PLACES
Definition: specctra.h:1747
DSN_T aperture_type
Definition: specctra.h:586
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
int sequence_number
Definition: specctra.h:901
DSN_T Type() const
Definition: specctra.h:230
POINTS points
Definition: specctra.h:585
POINT & operator=(const POINT &other)
Definition: specctra.h:122
POINT(double aX, double aY)
Definition: specctra.h:100
int FindElem(DSN_T aType, int instanceNum=0)
Function FindElem finds a particular instance number of a given type of ELEM.
Definition: specctra.cpp:3536
static UNIT_RES Default
A static instance which holds the default units of T_inch and 2540000.
Definition: specctra.h:413
bool via_at_smd_grid_on
Definition: specctra.h:1153
PLACEMENT * placement
Definition: specctra.h:3170
void doSHAPE(SHAPE *growth)
Definition: specctra.cpp:2040
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:1793
STRINGPROP is a container for a single property whose value is a string.
Definition: specctra.h:1384
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:2187
PIN_PAIR(ELEM *aParent=0)
Definition: specctra.h:3513
LAYER_RULES layer_rules
Definition: specctra.h:2760
void readCOMPnPIN(std::string *component_id, std::string *pid_id)
Function readCOMPnPIN reads a <pin_reference> and splits it into the two parts which are on either si...
Definition: specctra.cpp:134
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:3352
RULE * rules
Definition: specctra.h:2758
boost::ptr_vector< ANCESTOR > ANCESTORS
Definition: specctra.h:3290
UNIT_RES * unit
Definition: specctra.h:2000
void doLAYER_RULE(LAYER_RULE *growth)
Definition: specctra.cpp:1715
bool routes_include_guides
Definition: specctra.h:375
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.cpp:3529
SESSION * m_session
Definition: specctra.h:3638
void SetEnd(const POINT &aEnd)
Definition: specctra.h:818
void SetShape(ELEM *aShape)
Definition: specctra.h:2914
RULE * rules
Definition: specctra.h:2009
double aperture_width
Definition: specctra.h:583
REGION * region
Definition: specctra.h:1700
BOUNDARY * boundary
Definition: specctra.h:1550
DSN_T mirror
Definition: specctra.h:1687
void SetBOUNDARY(BOUNDARY *aBoundary)
Definition: specctra.h:1595
std::string padstack_id
Definition: specctra.h:2120
void AppendVia(const char *aViaName)
Definition: specctra.h:1038
const char * GetTokenText(T aTok)
Function GetTokenText is in the DSN namespace and returns the C string representing a SPECCTRA_DB::ke...
Definition: specctra.cpp:69
ROUTE * route
Definition: specctra.h:3570
void GetCorners(std::vector< double > &aBuffer)
GetCorners fills aBuffer with a list of coordinates (x,y) of corners.
Definition: specctra.h:679
NET_OUT corresponds to the <net_out_descriptor> of the specctra dsn spec.
Definition: specctra.h:3387
UNIT_RES * unit
Definition: specctra.h:3168
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3510
STRINGS use_net
Definition: specctra.h:1196
ELEM * shape
Definition: specctra.h:846
void doPLACEMENT(PLACEMENT *growth)
Definition: specctra.cpp:1885
int cost
[forbidden | high | medium | low | free | <positive_integer> | -1]
Definition: specctra.h:1193
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.cpp:3677
boost::ptr_vector< WIRE > WIRES
Definition: specctra.h:2976
LAYERS layers
Definition: specctra.h:1546
POINT GetOrigin()
Definition: specctra.h:465
STRUCTURE(ELEM *aParent)
Definition: specctra.h:1570
PATH(ELEM *aParent, DSN_T aType=T_path)
Definition: specctra.h:590
PIN_REFS pins
Definition: specctra.h:2600
void StripUseless()
Removes whitespace, '(', and ')' from the string.
Definition: richio.cpp:494
ELEM * At(int aIndex) const
Definition: specctra.h:342
WIRE_VIA corresponds to <wire_via_descriptor> in the specctra dsn spec.
Definition: specctra.h:2983
void FromSESSION(BOARD *aBoard)
Function FromSESSION adds the entire SESSION info to a BOARD but does not write it out.
void doNETWORK(NETWORK *growth)
Definition: specctra.cpp:2611
std::string value
Definition: specctra.h:1388
TOPOLOGY * topology
Definition: specctra.h:2762
void doNET_OUT(NET_OUT *growth)
Definition: specctra.cpp:3338
PIN_REFS source
Definition: specctra.h:2604
ELEM is a base class for any DSN element class.
Definition: specctra.h:193
UNIT_RES * GetUnits() const override
Function GetUnits returns the units for this section.
Definition: specctra.h:3151
void SetVertex(const POINT &aVertex)
Definition: specctra.h:769
std::string virtual_pin_name
Definition: specctra.h:2993
std::string pin_id
Definition: specctra.h:2452
HISTORY(ELEM *aParent)
Definition: specctra.h:3303
WINDOWS windows
Definition: specctra.h:905
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:2929
CLASS_CLASS(ELEM *aParent, DSN_T aType)
Constructor CLASS_CLASS.
Definition: specctra.h:1126
DSN_T wire_type
Definition: specctra.h:2888
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:408
WINDOWS windows
Definition: specctra.h:1893
CONNECT * connect
Definition: specctra.h:2892
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:878
bool wires_include_testpoint
Definition: specctra.h:373
LAYER_RULE(ELEM *aParent)
Definition: specctra.h:539
Definition: pad.h:60
ELEM_HOLDER is a holder for any DSN class.
Definition: specctra.h:280
void doCONNECT(CONNECT *growth)
Definition: specctra.cpp:878
PROPERTIES properties
Definition: specctra.h:1198
STRINGS net_ids
Definition: specctra.h:2753
NETWORK(ELEM *aParent)
Definition: specctra.h:2843
SUPPLY_PIN corresponds to the <supply_pin_descriptor> in the specctra dsn spec.
Definition: specctra.h:3339
void ExportSESSION(const wxString &aFilename)
Function ExportSESSION writes the internal SESSION instance out as a SPECTRA DSN format file.
Definition: specctra.cpp:3456
std::string hash
a hash string used by Compare(), not Format()ed/exported.
Definition: specctra.h:1996
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:1397
DSN_T absolute
Definition: specctra.h:2126
std::string pcbname
Definition: specctra.h:3165
PADSTACKSET m_padstackset
Definition: specctra.h:3659
KEEPOUT is used for <keepout_descriptor> and <plane_descriptor>.
Definition: specctra.h:895
void doQARC(QARC *growth)
Definition: specctra.cpp:1115
std::string name
Definition: specctra.h:900
NETWORK * network
Definition: specctra.h:3172
void doSESSION(SESSION *growth)
Definition: specctra.cpp:3137
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:963
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:411
HISTORY * history
Definition: specctra.h:3566
Hold a keyword string and its unique integer token.
Definition: dsnlexer.h:39
void doPARSER(PARSER *growth)
Definition: specctra.cpp:387
int Length() const
Function Length returns the number of ELEMs in this ELEM.
Definition: specctra.h:315
RULE * place_rules
Definition: specctra.h:903
WAS_IS * was_is
Definition: specctra.h:3569
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:1167
PADSTACKS padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2258
void SetPadstackId(const char *aPadstackId)
Definition: specctra.h:2167
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:2056
std::string toText
Definition: specctra.h:2488
BOUNDARY(ELEM *aParent, DSN_T aType=T_boundary)
Definition: specctra.h:665
ELEM * Remove(int aIndex)
Definition: specctra.h:331
void SetParent(ELEM *aParent)
Definition: specctra.h:268
void SetDiameter(double aDiameter)
Definition: specctra.h:764
PARSER is simply a configuration record per the SPECCTRA DSN file spec.
Definition: specctra.h:366
COPPER_PLANE(ELEM *aParent)
Definition: specctra.h:1343
void doFROMTO(FROMTO *growth)
Definition: specctra.cpp:2674
void SetCenter(const POINT &aCenter)
Definition: specctra.h:825
WIRING corresponds to <wiring_descriptor> in the specctra dsn spec.
Definition: specctra.h:3119
COMPONENTS components
Definition: specctra.h:1810
void doUNIT(UNIT_RES *growth)
Definition: specctra.cpp:553
std::string net_id
Definition: specctra.h:3391
Definition: track.h:83
ELEM_HOLDER(DSN_T aType, ELEM *aParent=0)
Definition: specctra.h:290
std::string net_id
Definition: specctra.h:2886
POINT vertex
Definition: specctra.h:1945
VIA(ELEM *aParent)
Definition: specctra.h:1033
static STRING_FORMATTER sf
Definition: specctra.h:221
PADSTACK * makeVia(int aCopperDiameter, int aDrillDiameter, int aTopLayer, int aBotLayer)
Function makeVia makes a round through hole PADSTACK using the given KiCad diameter in deci-mils.
std::string m_quote_char
Definition: specctra.h:3640
void doWAS_IS(WAS_IS *growth)
Definition: specctra.cpp:3214
SPECCTRA_LAYER_PAIRS layer_pairs
Definition: specctra.h:1313
void Clear()
Clear the buffer and empties the internal string.
Definition: richio.h:425
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:1137
void doBOUNDARY(BOUNDARY *growth)
Definition: specctra.cpp:967
void FlipFOOTPRINTs(BOARD *aBoard)
Function FlipFOOTPRINTs flips the footprints which are on the back side of the board to the front.
double diameter
Definition: specctra.h:734
bool operator!=(const POINT &other) const
Definition: specctra.h:110
STRINGS rules
rules are saved in std::string form.
Definition: specctra.h:492
bool generated_by_freeroute
Definition: specctra.h:378
DSN_T pins_type
T_pins | T_order, type of field 'pins' below.
Definition: specctra.h:2599
KEEPOUTS keepouts
Definition: specctra.h:1556