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