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