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