KiCad PCB EDA Suite
eagle_plugin.cpp
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) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
5  * Copyright (C) 2012-2017 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 
26 /*
27 
28 Pcbnew PLUGIN for Eagle 6.x XML *.brd and footprint format.
29 
30 XML parsing and converting:
31 Getting line numbers and byte offsets from the source XML file is not
32 possible using currently available XML libraries within KiCad project:
33 wxXmlDocument and boost::property_tree.
34 
35 property_tree will give line numbers but no byte offsets, and only during
36 document loading. This means that if we have a problem after the document is
37 successfully loaded, there is no way to correlate back to line number and byte
38 offset of the problem. So a different approach is taken, one which relies on the
39 XML elements themselves using an XPATH type of reporting mechanism. The path to
40 the problem is reported in the error messages. This means keeping track of that
41 path as we traverse the XML document for the sole purpose of accurate error
42 reporting.
43 
44 User can load the source XML file into firefox or other xml browser and follow
45 our error message.
46 
47 Load() TODO's
48 
49 *) verify zone fill clearances are correct
50 
51 */
52 
53 #include <errno.h>
54 
55 #include <wx/string.h>
56 #include <wx/xml/xml.h>
57 
58 #include <common.h>
59 #include <macros.h>
60 #include <fctsys.h>
61 #include <trigo.h>
62 #include <macros.h>
63 #include <kicad_string.h>
64 #include <properties.h>
65 #include <wx/filename.h>
66 
67 #include <class_board.h>
68 #include <class_module.h>
69 #include <class_track.h>
70 #include <class_edge_mod.h>
71 #include <class_zone.h>
72 #include <class_pcb_text.h>
73 #include <class_dimension.h>
74 
75 #include <eagle_plugin.h>
76 
77 using namespace std;
78 
79 
80 typedef MODULE_MAP::iterator MODULE_ITER;
81 typedef MODULE_MAP::const_iterator MODULE_CITER;
82 
83 
86 static double parseEagle( const wxString& aDistance )
87 {
88  double ret = strtod( aDistance.c_str(), NULL );
89  if( aDistance.npos != aDistance.find( "mil" ) )
90  ret = IU_PER_MILS * ret;
91  else
92  ret = IU_PER_MM * ret;
93 
94  return ret;
95 }
96 
97 
98 void ERULES::parse( wxXmlNode* aRules )
99 {
100  wxXmlNode* child = aRules->GetChildren();
101 
102  while( child )
103  {
104  if( child->GetName() == "param" )
105  {
106  const wxString& name = child->GetAttribute( "name" );
107  const wxString& value = child->GetAttribute( "value" );
108 
109  if( name == "psElongationLong" )
110  psElongationLong = wxAtoi( value );
111  else if( name == "psElongationOffset" )
112  psElongationOffset = wxAtoi( value );
113  else if( name == "rvPadTop" )
114  value.ToDouble( &rvPadTop );
115  else if( name == "rlMinPadTop" )
116  rlMinPadTop = parseEagle( value );
117  else if( name == "rlMaxPadTop" )
118  rlMaxPadTop = parseEagle( value );
119  else if( name == "rvViaOuter" )
120  value.ToDouble( &rvViaOuter );
121  else if( name == "rlMinViaOuter" )
122  rlMinViaOuter = parseEagle( value );
123  else if( name == "rlMaxViaOuter" )
124  rlMaxViaOuter = parseEagle( value );
125  else if( name == "mdWireWire" )
126  mdWireWire = parseEagle( value );
127  }
128 
129  child = child->GetNext();
130  }
131 }
132 
133 
135  m_rules( new ERULES() ),
136  m_xpath( new XPATH() ),
137  m_mod_time( wxDateTime::Now() )
138 {
139  init( NULL );
140 
141  clear_cu_map();
142 }
143 
144 
146 {
147  deleteTemplates();
148  delete m_rules;
149  delete m_xpath;
150 }
151 
152 
153 const wxString EAGLE_PLUGIN::PluginName() const
154 {
155  return wxT( "Eagle" );
156 }
157 
158 
159 const wxString EAGLE_PLUGIN::GetFileExtension() const
160 {
161  return wxT( "brd" );
162 }
163 
164 
165 int inline EAGLE_PLUGIN::kicad( double d ) const
166 {
167  return KiROUND( biu_per_mm * d );
168 }
169 
170 
171 wxSize inline EAGLE_PLUGIN::kicad_fontz( double d ) const
172 {
173  // texts seem to better match eagle when scaled down by 0.95
174  int kz = kicad( d ) * 95 / 100;
175  return wxSize( kz, kz );
176 }
177 
178 
179 BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
180 {
181  LOCALE_IO toggle; // toggles on, then off, the C locale.
182  wxXmlNode* doc;
183 
184  init( aProperties );
185 
186  m_board = aAppendToMe ? aAppendToMe : new BOARD();
187 
188  // Give the filename to the board if it's new
189  if( !aAppendToMe )
190  m_board->SetFileName( aFileName );
191 
192  // delete on exception, if I own m_board, according to aAppendToMe
193  unique_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
194 
195  try
196  {
197  // Load the document
198  wxXmlDocument xmlDocument;
199  wxFileName fn = aFileName;
200 
201  if( !xmlDocument.Load( fn.GetFullPath() ) )
202  THROW_IO_ERROR( wxString::Format( _( "Unable to read file '%s'" ),
203  fn.GetFullPath() ) );
204 
205  doc = xmlDocument.GetRoot();
206 
207  m_min_trace = INT_MAX;
208  m_min_via = INT_MAX;
209  m_min_via_hole = INT_MAX;
210 
211  loadAllSections( doc );
212 
213  BOARD_DESIGN_SETTINGS& designSettings = m_board->GetDesignSettings();
214 
215  if( m_min_trace < designSettings.m_TrackMinWidth )
216  designSettings.m_TrackMinWidth = m_min_trace;
217 
218  if( m_min_via < designSettings.m_ViasMinSize )
219  designSettings.m_ViasMinSize = m_min_via;
220 
221  if( m_min_via_hole < designSettings.m_ViasMinDrill )
222  designSettings.m_ViasMinDrill = m_min_via_hole;
223 
224  if( m_rules->mdWireWire )
225  {
226  NETCLASSPTR defaultNetclass = designSettings.GetDefault();
227  int clearance = KiROUND( m_rules->mdWireWire );
228 
229  if( clearance < defaultNetclass->GetClearance() )
230  defaultNetclass->SetClearance( clearance );
231  }
232 
233  // should be empty, else missing m_xpath->pop()
234  wxASSERT( m_xpath->Contents().size() == 0 );
235  }
236  // Catch all exceptions thrown from the parser.
237  catch( const XML_PARSER_ERROR &exc )
238  {
239  string errmsg = exc.what();
240 
241  errmsg += "\n@ ";
242  errmsg += m_xpath->Contents();
243 
244  THROW_IO_ERROR( errmsg );
245  }
246 
247  // IO_ERROR exceptions are left uncaught, they pass upwards from here.
248 
249  // Ensure the copper layers count is a multiple of 2
250  // Pcbnew does not like boards with odd layers count
251  // (these boards cannot exist. they actually have a even layers count)
252  int lyrcnt = m_board->GetCopperLayerCount();
253 
254  if( (lyrcnt % 2) != 0 )
255  {
256  lyrcnt++;
257  m_board->SetCopperLayerCount( lyrcnt );
258  }
259 
260  centerBoard();
261 
262  deleter.release();
263  return m_board;
264 }
265 
266 
267 void EAGLE_PLUGIN::init( const PROPERTIES* aProperties )
268 {
269  m_hole_count = 0;
270  m_min_trace = 0;
271  m_min_via = 0;
272  m_min_via_hole = 0;
273  m_xpath->clear();
274  m_pads_to_nets.clear();
275  deleteTemplates();
276 
277  m_board = NULL;
278  m_props = aProperties;
279 
280  mm_per_biu = 1/IU_PER_MM;
281  biu_per_mm = IU_PER_MM;
282 
283  delete m_rules;
284  m_rules = new ERULES();
285 }
286 
287 
289 {
290  // All cu layers are invalid until we see them in the <layers> section while
291  // loading either a board or library. See loadLayerDefs().
292  for( unsigned i = 0; i < DIM(m_cu_map); ++i )
293  m_cu_map[i] = -1;
294 }
295 
296 
297 void EAGLE_PLUGIN::loadAllSections( wxXmlNode* aDoc )
298 {
299  wxXmlNode* drawing = MapChildren( aDoc )["drawing"];
300  NODE_MAP drawingChildren = MapChildren( drawing );
301 
302  wxXmlNode* board = drawingChildren["board"];
303  NODE_MAP boardChildren = MapChildren( board );
304 
305  m_xpath->push( "eagle.drawing" );
306 
307  {
308  m_xpath->push( "board" );
309 
310  wxXmlNode* designrules = boardChildren["designrules"];
311  loadDesignRules( designrules );
312 
313  m_xpath->pop();
314  }
315 
316  {
317  m_xpath->push( "layers" );
318 
319  wxXmlNode* layers = drawingChildren["layers"];
320  loadLayerDefs( layers );
321 
322  m_xpath->pop();
323  }
324 
325  {
326  m_xpath->push( "board" );
327 
328  wxXmlNode* plain = boardChildren["plain"];
329  loadPlain( plain );
330 
331  wxXmlNode* signals = boardChildren["signals"];
332  loadSignals( signals );
333 
334  wxXmlNode* libs = boardChildren["libraries"];
335  loadLibraries( libs );
336 
337  wxXmlNode* elems = boardChildren["elements"];
338  loadElements( elems );
339 
340  m_xpath->pop(); // "board"
341  }
342 
343  m_xpath->pop(); // "eagle.drawing"
344 }
345 
346 
347 void EAGLE_PLUGIN::loadDesignRules( wxXmlNode* aDesignRules )
348 {
349  m_xpath->push( "designrules" );
350  m_rules->parse( aDesignRules );
351  m_xpath->pop(); // "designrules"
352 }
353 
354 
355 void EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
356 {
357  typedef std::vector<ELAYER> ELAYERS;
358  typedef ELAYERS::const_iterator EITER;
359 
360  ELAYERS cu; // copper layers
361 
362  // Get the first layer and iterate
363  wxXmlNode* layerNode = aLayers->GetChildren();
364 
365  // find the subset of layers that are copper, and active
366  while( layerNode )
367  {
368  ELAYER elayer( layerNode );
369 
370  if( elayer.number >= 1 && elayer.number <= 16 && ( !elayer.active || *elayer.active ) )
371  {
372  cu.push_back( elayer );
373  }
374 
375  layerNode = layerNode->GetNext();
376  }
377 
378  // establish cu layer map:
379  int ki_layer_count = 0;
380 
381  for( EITER it = cu.begin(); it != cu.end(); ++it, ++ki_layer_count )
382  {
383  if( ki_layer_count == 0 )
384  m_cu_map[it->number] = F_Cu;
385  else if( ki_layer_count == int( cu.size()-1 ) )
386  m_cu_map[it->number] = B_Cu;
387  else
388  {
389  // some eagle boards do not have contiguous layer number sequences.
390 
391 #if 0 // pre PCB_LAYER_ID & LSET:
392  m_cu_map[it->number] = cu.size() - 1 - ki_layer_count;
393 #else
394  m_cu_map[it->number] = ki_layer_count;
395 #endif
396  }
397  }
398 
399 #if 0 && defined(DEBUG)
400  printf( "m_cu_map:\n" );
401  for( unsigned i=0; i<DIM(m_cu_map); ++i )
402  {
403  printf( "\t[%d]:%d\n", i, m_cu_map[i] );
404  }
405 #endif
406 
407  // Set the layer names and cu count iff we're loading a board.
408  if( m_board )
409  {
410  m_board->SetCopperLayerCount( cu.size() );
411 
412  for( EITER it = cu.begin(); it != cu.end(); ++it )
413  {
414  PCB_LAYER_ID layer = kicad_layer( it->number );
415 
416  // these function provide their own protection against UNDEFINED_LAYER:
417  m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) );
418  m_board->SetLayerType( layer, LT_SIGNAL );
419 
420  // could map the colors here
421  }
422  }
423 }
424 
425 
426 void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
427 {
428  m_xpath->push( "plain" );
429 
430  // Get the first graphic and iterate
431  wxXmlNode* gr = aGraphics->GetChildren();
432 
433  // (polygon | wire | text | circle | rectangle | frame | hole)*
434  while( gr )
435  {
436  wxString grName = gr->GetName();
437 
438  if( grName == "wire" )
439  {
440  m_xpath->push( "wire" );
441 
442  EWIRE w( gr );
443  PCB_LAYER_ID layer = kicad_layer( w.layer );
444 
445  wxPoint start( kicad_x( w.x1 ), kicad_y( w.y1 ) );
446  wxPoint end( kicad_x( w.x2 ), kicad_y( w.y2 ) );
447 
448  if( layer != UNDEFINED_LAYER )
449  {
450  DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
451  m_board->Add( dseg, ADD_APPEND );
452 
453  if( !w.curve )
454  {
455  dseg->SetStart( start );
456  dseg->SetEnd( end );
457  }
458  else
459  {
460  wxPoint center = kicad_arc_center( start, end, *w.curve);
461 
462  dseg->SetShape( S_ARC );
463  dseg->SetStart( center );
464  dseg->SetEnd( start );
465  dseg->SetAngle( *w.curve * -10.0 ); // KiCad rotates the other way
466  }
467 
468  dseg->SetTimeStamp( timeStamp( gr ) );
469  dseg->SetLayer( layer );
470  dseg->SetWidth( Millimeter2iu( DEFAULT_PCB_EDGE_THICKNESS ) );
471  }
472  m_xpath->pop();
473  }
474  else if( grName == "text" )
475  {
476  m_xpath->push( "text" );
477 
478  ETEXT t( gr );
479  PCB_LAYER_ID layer = kicad_layer( t.layer );
480 
481  if( layer != UNDEFINED_LAYER )
482  {
483  TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board );
484  m_board->Add( pcbtxt, ADD_APPEND );
485 
486  pcbtxt->SetLayer( layer );
487  pcbtxt->SetTimeStamp( timeStamp( gr ) );
488  pcbtxt->SetText( FROM_UTF8( t.text.c_str() ) );
489  pcbtxt->SetTextPos( wxPoint( kicad_x( t.x ), kicad_y( t.y ) ) );
490 
491  pcbtxt->SetTextSize( kicad_fontz( t.size ) );
492 
493  double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default
494 
495  pcbtxt->SetThickness( kicad( t.size * ratio / 100 ) );
496 
497  int align = t.align ? *t.align : ETEXT::BOTTOM_LEFT;
498 
499  if( t.rot )
500  {
501  int sign = t.rot->mirror ? -1 : 1;
502  pcbtxt->SetMirrored( t.rot->mirror );
503 
504  double degrees = t.rot->degrees;
505 
506  if( degrees == 90 || t.rot->spin )
507  pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 );
508  else if( degrees == 180 )
509  align = ETEXT::TOP_RIGHT;
510  else if( degrees == 270 )
511  {
512  pcbtxt->SetTextAngle( sign * 90 * 10 );
513  align = ETEXT::TOP_RIGHT;
514  }
515  else // Ok so text is not at 90,180 or 270 so do some funny stuf to get placement right
516  {
517  if( ( degrees > 0 ) && ( degrees < 90 ) )
518  pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 );
519  else if( ( degrees > 90 ) && ( degrees < 180 ) )
520  {
521  pcbtxt->SetTextAngle( sign * ( t.rot->degrees + 180 ) * 10 );
522  align = ETEXT::TOP_RIGHT;
523  }
524  else if( ( degrees > 180 ) && ( degrees < 270 ) )
525  {
526  pcbtxt->SetTextAngle( sign * ( t.rot->degrees - 180 ) * 10 );
527  align = ETEXT::TOP_RIGHT;
528  }
529  else if( ( degrees > 270 ) && ( degrees < 360 ) )
530  {
531  pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 );
532  align = ETEXT::BOTTOM_LEFT;
533  }
534  }
535  }
536 
537  switch( align )
538  {
539  case ETEXT::CENTER:
540  // this was the default in pcbtxt's constructor
541  break;
542 
543  case ETEXT::CENTER_LEFT:
545  break;
546 
547  case ETEXT::CENTER_RIGHT:
549  break;
550 
551  case ETEXT::TOP_CENTER:
553  break;
554 
555  case ETEXT::TOP_LEFT:
558  break;
559 
560  case ETEXT::TOP_RIGHT:
563  break;
564 
567  break;
568 
569  case ETEXT::BOTTOM_LEFT:
572  break;
573 
574  case ETEXT::BOTTOM_RIGHT:
577  break;
578  }
579  }
580  m_xpath->pop();
581  }
582  else if( grName == "circle" )
583  {
584  m_xpath->push( "circle" );
585 
586  ECIRCLE c( gr );
587  PCB_LAYER_ID layer = kicad_layer( c.layer );
588 
589  if( layer != UNDEFINED_LAYER ) // unsupported layer
590  {
591  DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
592  m_board->Add( dseg, ADD_APPEND );
593 
594  dseg->SetShape( S_CIRCLE );
595  dseg->SetTimeStamp( timeStamp( gr ) );
596  dseg->SetLayer( layer );
597  dseg->SetStart( wxPoint( kicad_x( c.x ), kicad_y( c.y ) ) );
598  dseg->SetEnd( wxPoint( kicad_x( c.x + c.radius ), kicad_y( c.y ) ) );
599  dseg->SetWidth( kicad( c.width ) );
600  }
601  m_xpath->pop();
602  }
603  else if( grName == "rectangle" )
604  {
605  // This seems to be a simplified rectangular [copper] zone, cannot find any
606  // net related info on it from the DTD.
607  m_xpath->push( "rectangle" );
608 
609  ERECT r( gr );
610  PCB_LAYER_ID layer = kicad_layer( r.layer );
611 
612  if( IsCopperLayer( layer ) )
613  {
614  // use a "netcode = 0" type ZONE:
615  ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
616  m_board->Add( zone, ADD_APPEND );
617 
618  zone->SetTimeStamp( timeStamp( gr ) );
619  zone->SetLayer( layer );
621 
623 
624  const int outlineIdx = -1; // this is the id of the copper zone main outline
625  zone->AppendCorner( wxPoint( kicad_x( r.x1 ), kicad_y( r.y1 ) ), outlineIdx );
626  zone->AppendCorner( wxPoint( kicad_x( r.x2 ), kicad_y( r.y1 ) ), outlineIdx );
627  zone->AppendCorner( wxPoint( kicad_x( r.x2 ), kicad_y( r.y2 ) ), outlineIdx );
628  zone->AppendCorner( wxPoint( kicad_x( r.x1 ), kicad_y( r.y2 ) ), outlineIdx );
629 
630  // this is not my fault:
631  zone->SetHatch( outline_hatch, zone->GetDefaultHatchPitch(), true );
632  }
633 
634  m_xpath->pop();
635  }
636  else if( grName == "hole" )
637  {
638  m_xpath->push( "hole" );
639  EHOLE e( gr );
640 
641  // Fabricate a MODULE with a single PAD_ATTRIB_HOLE_NOT_PLATED pad.
642  // Use m_hole_count to gen up a unique name.
643 
644  MODULE* module = new MODULE( m_board );
645  m_board->Add( module, ADD_APPEND );
646 
647  char temp[40];
648  sprintf( temp, "@HOLE%d", m_hole_count++ );
649  module->SetReference( FROM_UTF8( temp ) );
650  module->Reference().SetVisible( false );
651 
652  wxPoint pos( kicad_x( e.x ), kicad_y( e.y ) );
653 
654  module->SetPosition( pos );
655 
656  // Add a PAD_ATTRIB_HOLE_NOT_PLATED pad to this module.
657  D_PAD* pad = new D_PAD( module );
658  module->PadsList().PushBack( pad );
659 
660  pad->SetShape( PAD_SHAPE_CIRCLE );
662 
663  /* pad's position is already centered on module at relative (0, 0)
664  wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
665 
666  pad->SetPos0( padpos );
667  pad->SetPosition( padpos + module->GetPosition() );
668  */
669 
670  wxSize sz( kicad( e.drill ), kicad( e.drill ) );
671 
672  pad->SetDrillSize( sz );
673  pad->SetSize( sz );
674 
675  pad->SetLayerSet( LSET::AllCuMask() );
676  m_xpath->pop();
677  }
678  else if( grName == "frame" )
679  {
680  // picture this
681  }
682  else if( grName == "polygon" )
683  {
684  // could be on a copper layer, could be on another layer.
685  // copper layer would be done using netCode=0 type of ZONE_CONTAINER.
686  }
687  else if( grName == "dimension" )
688  {
689  EDIMENSION d( gr );
690  PCB_LAYER_ID layer = kicad_layer( d.layer );
691 
692  if( layer != UNDEFINED_LAYER )
693  {
694  DIMENSION* dimension = new DIMENSION( m_board );
695  m_board->Add( dimension, ADD_APPEND );
696 
697  dimension->SetLayer( layer );
698  // The origin and end are assumed to always be in this order from eagle
699  dimension->SetOrigin( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) );
700  dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) );
702 
704  int maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetTextSize() );
705 
706  if( width > maxThickness )
707  width = maxThickness;
708 
709  dimension->Text().SetThickness( width );
710  dimension->SetWidth( width );
711 
712  // check which axis the dimension runs in
713  // because the "height" of the dimension is perpendicular to that axis
714  // Note the check is just if two axes are close enough to each other
715  // Eagle appears to have some rounding errors
716  if( fabs( d.x1 - d.x2 ) < 0.05 )
717  dimension->SetHeight( kicad_x( d.x1 - d.x3 ) );
718  else
719  dimension->SetHeight( kicad_y( d.y3 - d.y1 ) );
720 
721  dimension->AdjustDimensionDetails();
722  }
723  }
724 
725  // Get next graphic
726  gr = gr->GetNext();
727  }
728  m_xpath->pop();
729 }
730 
731 
732 void EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLib, const string* aLibName )
733 {
734  m_xpath->push( "packages" );
735 
736  // library will have <xmlattr> node, skip that and get the single packages node
737  wxXmlNode* packages = MapChildren( aLib )["packages"];
738 
739 
740  // Create a MODULE for all the eagle packages, for use later via a copy constructor
741  // to instantiate needed MODULES in our BOARD. Save the MODULE templates in
742  // a MODULE_MAP using a single lookup key consisting of libname+pkgname.
743 
744  // Get the first package and iterate
745  wxXmlNode* package = packages->GetChildren();
746 
747  while( package )
748  {
749  m_xpath->push( "package", "name" );
750 
751  const wxString& pack_ref = package->GetAttribute( "name" );
752 
753  string pack_name( pack_ref.ToStdString() );
754 
755  ReplaceIllegalFileNameChars( &pack_name );
756 
757  m_xpath->Value( pack_name.c_str() );
758 
759  string key = aLibName ? makeKey( *aLibName, pack_name ) : pack_name;
760 
761  MODULE* m = makeModule( package, pack_name );
762 
763  // add the templating MODULE to the MODULE template factory "m_templates"
764  std::pair<MODULE_ITER, bool> r = m_templates.insert( {key, m} );
765 
766  if( !r.second
767  // && !( m_props && m_props->Value( "ignore_duplicates" ) )
768  )
769  {
770  wxString lib = aLibName ? FROM_UTF8( aLibName->c_str() ) : m_lib_path;
771  wxString pkg = FROM_UTF8( pack_name.c_str() );
772 
773  wxString emsg = wxString::Format(
774  _( "<package> name: '%s' duplicated in eagle <library>: '%s'" ),
775  GetChars( pkg ),
776  GetChars( lib )
777  );
778  THROW_IO_ERROR( emsg );
779  }
780 
781  m_xpath->pop();
782 
783  package = package->GetNext();
784  }
785 
786  m_xpath->pop(); // "packages"
787 }
788 
789 
790 void EAGLE_PLUGIN::loadLibraries( wxXmlNode* aLibs )
791 {
792  m_xpath->push( "libraries.library", "name" );
793 
794  // Get the first library and iterate
795  wxXmlNode* library = aLibs->GetChildren();
796 
797  while( library )
798  {
799  const string& lib_name = library->GetAttribute( "name" ).ToStdString();
800 
801  m_xpath->Value( lib_name.c_str() );
802 
803  loadLibrary( library, &lib_name );
804 
805  library = library->GetNext();
806  }
807 
808  m_xpath->pop();
809 }
810 
811 
812 void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
813 {
814  m_xpath->push( "elements.element", "name" );
815 
816  EATTR name;
817  EATTR value;
818  bool refanceNamePresetInPackageLayout;
819  bool valueNamePresetInPackageLayout;
820 
821  // Get the first element and iterate
822  wxXmlNode* element = aElements->GetChildren();
823 
824  while( element )
825  {
826  if( element->GetName() != "element" )
827  {
828  wxLogMessage( "expected: <element> read <%s>. Skip it", element->GetName() );
829  // Get next item
830  element = element->GetNext();
831  continue;
832  }
833 
834  EELEMENT e( element );
835 
836  // use "NULL-ness" as an indication of presence of the attribute:
837  EATTR* nameAttr = 0;
838  EATTR* valueAttr = 0;
839 
840  m_xpath->Value( e.name.c_str() );
841 
842  string pkg_key = makeKey( e.library, e.package );
843 
844  MODULE_CITER mi = m_templates.find( pkg_key );
845 
846  if( mi == m_templates.end() )
847  {
848  wxString emsg = wxString::Format( _( "No '%s' package in library '%s'" ),
849  GetChars( FROM_UTF8( e.package.c_str() ) ),
850  GetChars( FROM_UTF8( e.library.c_str() ) ) );
851  THROW_IO_ERROR( emsg );
852  }
853 
854  // copy constructor to clone the template
855  MODULE* m = new MODULE( *mi->second );
856  m_board->Add( m, ADD_APPEND );
857 
858  // update the nets within the pads of the clone
859  for( D_PAD* pad = m->PadsList(); pad; pad = pad->Next() )
860  {
861  string pn_key = makeKey( e.name, TO_UTF8( pad->GetPadName() ) );
862 
863  NET_MAP_CITER ni = m_pads_to_nets.find( pn_key );
864  if( ni != m_pads_to_nets.end() )
865  {
866  const ENET* enet = &ni->second;
867  pad->SetNetCode( enet->netcode );
868  }
869  }
870 
871  refanceNamePresetInPackageLayout = true;
872  valueNamePresetInPackageLayout = true;
873  m->SetPosition( wxPoint( kicad_x( e.x ), kicad_y( e.y ) ) );
874  // Is >NAME field set in package layout ?
875  if( m->GetReference().size() == 0 )
876  {
877  m->Reference().SetVisible( false ); // No so no show
878  refanceNamePresetInPackageLayout = false;
879  }
880  // Is >VALUE field set in package layout
881  if( m->GetValue().size() == 0 )
882  {
883  m->Value().SetVisible( false ); // No so no show
884  valueNamePresetInPackageLayout = false;
885  }
886  m->SetReference( FROM_UTF8( e.name.c_str() ) );
887  m->SetValue( FROM_UTF8( e.value.c_str() ) );
888 
889  if( !e.smashed )
890  { // Not smashed so show NAME & VALUE
891  if( valueNamePresetInPackageLayout )
892  m->Value().SetVisible( true ); // Only if place holder in package layout
893  if( refanceNamePresetInPackageLayout )
894  m->Reference().SetVisible( true ); // Only if place holder in package layout
895  }
896  else if( *e.smashed == true )
897  { // Smasted so set default to no show for NAME and VALUE
898  m->Value().SetVisible( false );
899  m->Reference().SetVisible( false );
900 
901  // initalize these to default values incase the <attribute> elements are not present.
902  m_xpath->push( "attribute", "name" );
903 
904  // VALUE and NAME can have something like our text "effects" overrides
905  // in SWEET and new schematic. Eagle calls these XML elements "attribute".
906  // There can be one for NAME and/or VALUE both. Features present in the
907  // EATTR override the ones established in the package only if they are
908  // present here (except for rot, which if not present means angle zero).
909  // So the logic is a bit different than in packageText() and in plain text.
910 
911  // Get the first attribute and iterate
912  wxXmlNode* attribute = element->GetChildren();
913 
914  while( attribute )
915  {
916  if( attribute->GetName() != "attribute" )
917  {
918  wxLogMessage( "expected: <attribute> read <%s>. Skip it", attribute->GetName() );
919  attribute = attribute->GetNext();
920  continue;
921  }
922 
923  EATTR a( attribute );
924 
925  if( a.name == "NAME" )
926  {
927  name = a;
928  nameAttr = &name;
929 
930  // do we have a display attribute ?
931  if( a.display )
932  {
933  // Yes!
934  switch( *a.display )
935  {
936  case EATTR::VALUE :
937  nameAttr->name = e.name;
938  m->SetReference( e.name );
939  if( refanceNamePresetInPackageLayout )
940  m->Reference().SetVisible( true );
941  break;
942 
943  case EATTR::NAME :
944  if( refanceNamePresetInPackageLayout )
945  {
946  m->SetReference( "NAME" );
947  m->Reference().SetVisible( true );
948  }
949  break;
950 
951  case EATTR::BOTH :
952  if( refanceNamePresetInPackageLayout )
953  m->Reference().SetVisible( true );
954  nameAttr->name = nameAttr->name + " = " + e.name;
955  m->SetReference( "NAME = " + e.name );
956  break;
957 
958  case EATTR::Off :
959  m->Reference().SetVisible( false );
960  break;
961 
962  default:
963  nameAttr->name = e.name;
964  if( refanceNamePresetInPackageLayout )
965  m->Reference().SetVisible( true );
966  }
967  }
968  else
969  // No display, so default is visable, and show value of NAME
970  m->Reference().SetVisible( true );
971  }
972  else if( a.name == "VALUE" )
973  {
974  value = a;
975  valueAttr = &value;
976 
977  if( a.display )
978  {
979  // Yes!
980  switch( *a.display )
981  {
982  case EATTR::VALUE :
983  valueAttr->value = e.value;
984  m->SetValue( e.value );
985  if( valueNamePresetInPackageLayout )
986  m->Value().SetVisible( true );
987  break;
988 
989  case EATTR::NAME :
990  if( valueNamePresetInPackageLayout )
991  m->Value().SetVisible( true );
992  m->SetValue( "VALUE" );
993  break;
994 
995  case EATTR::BOTH :
996  if( valueNamePresetInPackageLayout )
997  m->Value().SetVisible( true );
998  valueAttr->value = "VALUE = " + e.value;
999  m->SetValue( "VALUE = " + e.value );
1000  break;
1001 
1002  case EATTR::Off :
1003  m->Value().SetVisible( false );
1004  break;
1005 
1006  default:
1007  valueAttr->value = e.value;
1008  if( valueNamePresetInPackageLayout )
1009  m->Value().SetVisible( true );
1010  }
1011  }
1012  else
1013  // No display, so default is visible, and show value of NAME
1014  m->Value().SetVisible( true );
1015 
1016  }
1017 
1018  attribute = attribute->GetNext();
1019  }
1020 
1021  m_xpath->pop(); // "attribute"
1022  }
1023 
1024  orientModuleAndText( m, e, nameAttr, valueAttr );
1025 
1026  // Get next element
1027  element = element->GetNext();
1028  }
1029 
1030  m_xpath->pop(); // "elements.element"
1031 }
1032 
1033 
1035  const EATTR* nameAttr, const EATTR* valueAttr )
1036 {
1037  if( e.rot )
1038  {
1039  if( e.rot->mirror )
1040  {
1041  double orientation = e.rot->degrees + 180.0;
1042  m->SetOrientation( orientation * 10 );
1043  m->Flip( m->GetPosition() );
1044  }
1045  else
1046  m->SetOrientation( e.rot->degrees * 10 );
1047  }
1048 
1049  orientModuleText( m, e, &m->Reference(), nameAttr );
1050  orientModuleText( m, e, &m->Value(), valueAttr );
1051 }
1052 
1053 
1055  TEXTE_MODULE* txt, const EATTR* aAttr )
1056 {
1057  // Smashed part ?
1058  if( aAttr )
1059  { // Yes
1060  const EATTR& a = *aAttr;
1061 
1062  if( a.value )
1063  {
1064  txt->SetText( FROM_UTF8( a.value->c_str() ) );
1065  }
1066 
1067  if( a.x && a.y ) // boost::optional
1068  {
1069  wxPoint pos( kicad_x( *a.x ), kicad_y( *a.y ) );
1070  txt->SetTextPos( pos );
1071  }
1072 
1073  // Even though size and ratio are both optional, I am not seeing
1074  // a case where ratio is present but size is not.
1075  double ratio = 8;
1076  wxSize fontz = txt->GetTextSize();
1077 
1078  if( a.size )
1079  {
1080  fontz = kicad_fontz( *a.size );
1081  txt->SetTextSize( fontz );
1082 
1083  if( a.ratio )
1084  ratio = *a.ratio;
1085  }
1086 
1087  int lw = int( fontz.y * ratio / 100.0 );
1088  txt->SetThickness( lw );
1089 
1090  int align = ETEXT::BOTTOM_LEFT; // bottom-left is eagle default
1091 
1092  // The "rot" in a EATTR seems to be assumed to be zero if it is not
1093  // present, and this zero rotation becomes an override to the
1094  // package's text field. If they did not want zero, they specify
1095  // what they want explicitly.
1096  double degrees = a.rot ? a.rot->degrees : 0;
1097  double orient; // relative to parent
1098 
1099  int sign = 1;
1100  bool spin = false;
1101 
1102  if( a.rot )
1103  {
1104  spin = a.rot->spin;
1105  sign = a.rot->mirror ? -1 : 1;
1106  txt->SetMirrored( a.rot->mirror );
1107  }
1108 
1109  if( degrees == 90 || degrees == 0 || spin )
1110  {
1111  orient = degrees - m->GetOrientation() / 10;
1112  txt->SetTextAngle( sign * orient * 10 );
1113  }
1114  else if( degrees == 180 )
1115  {
1116  orient = 0 - m->GetOrientation() / 10;
1117  txt->SetTextAngle( sign * orient * 10 );
1118  align = ETEXT::TOP_RIGHT;
1119  }
1120  else if( degrees == 270 )
1121  {
1122  orient = 90 - m->GetOrientation() / 10;
1123  align = ETEXT::TOP_RIGHT;
1124  txt->SetTextAngle( sign * orient * 10 );
1125  }
1126  else
1127  {
1128  orient = 90 - degrees - m->GetOrientation() / 10;
1129  txt->SetTextAngle( sign * orient * 10 );
1130  }
1131 
1132  switch( align )
1133  {
1134  case ETEXT::TOP_RIGHT:
1137  break;
1138 
1139  case ETEXT::BOTTOM_LEFT:
1142  break;
1143 
1144  default:
1145  ;
1146  }
1147  }
1148  else // Part is not smash so use Lib default for NAME/VALUE // the text is per the original package, sans <attribute>
1149  {
1150  double degrees = ( txt->GetTextAngle() + m->GetOrientation() ) / 10;
1151 
1152  // @todo there are a few more cases than these to contend with:
1153  if( (!txt->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ))
1154  || ( txt->IsMirrored() && ( degrees == 360 ) ) )
1155  {
1156  // ETEXT::TOP_RIGHT:
1159  }
1160  }
1161 }
1162 
1163 
1164 MODULE* EAGLE_PLUGIN::makeModule( wxXmlNode* aPackage, const string& aPkgName ) const
1165 {
1166  std::unique_ptr<MODULE> m( new MODULE( m_board ) );
1167 
1168  m->SetFPID( LIB_ID( UTF8(aPkgName) ) );
1169 
1170  // Get the first package item and iterate
1171  wxXmlNode* packageItem = aPackage->GetChildren();
1172 
1173  while( packageItem )
1174  {
1175  const wxString& itemName = packageItem->GetName();
1176 
1177  if( itemName == "description" )
1178  m->SetDescription( FROM_UTF8( packageItem->GetNodeContent().c_str() ) );
1179 
1180  else if( itemName == "wire" )
1181  packageWire( m.get(), packageItem );
1182 
1183  else if( itemName == "pad" )
1184  packagePad( m.get(), packageItem );
1185 
1186  else if( itemName == "text" )
1187  packageText( m.get(), packageItem );
1188 
1189  else if( itemName == "rectangle" )
1190  packageRectangle( m.get(), packageItem );
1191 
1192  else if( itemName == "polygon" )
1193  packagePolygon( m.get(), packageItem );
1194 
1195  else if( itemName == "circle" )
1196  packageCircle( m.get(), packageItem );
1197 
1198  else if( itemName == "hole" )
1199  packageHole( m.get(), packageItem );
1200 
1201  else if( itemName == "smd" )
1202  packageSMD( m.get(), packageItem );
1203 
1204  packageItem = packageItem->GetNext();
1205  }
1206 
1207  return m.release();
1208 }
1209 
1210 
1211 void EAGLE_PLUGIN::packageWire( MODULE* aModule, wxXmlNode* aTree ) const
1212 {
1213  EWIRE w( aTree );
1214  PCB_LAYER_ID layer = kicad_layer( w.layer );
1215 
1216  if( IsNonCopperLayer( layer ) ) // only valid non-copper wires, skip copper package wires
1217  {
1218  wxPoint start( kicad_x( w.x1 ), kicad_y( w.y1 ) );
1219  wxPoint end( kicad_x( w.x2 ), kicad_y( w.y2 ) );
1220  int width = kicad( w.width );
1221 
1222  // FIXME: the cap attribute is ignored because kicad can't create lines
1223  // with flat ends.
1224  EDGE_MODULE* dwg;
1225  if( !w.curve )
1226  {
1227  dwg = new EDGE_MODULE( aModule, S_SEGMENT );
1228 
1229  dwg->SetStart0( start );
1230  dwg->SetEnd0( end );
1231  }
1232  else
1233  {
1234  dwg = new EDGE_MODULE( aModule, S_ARC );
1235  wxPoint center = kicad_arc_center( start, end, *w.curve);
1236 
1237  dwg->SetStart0( center );
1238  dwg->SetEnd0( start );
1239  dwg->SetAngle( *w.curve * -10.0 ); // KiCad rotates the other way
1240  }
1241 
1242  dwg->SetLayer( layer );
1243  dwg->SetWidth( width );
1244 
1245  aModule->GraphicalItemsList().PushBack( dwg );
1246  }
1247 }
1248 
1249 
1250 void EAGLE_PLUGIN::packagePad( MODULE* aModule, wxXmlNode* aTree ) const
1251 {
1252  // this is thru hole technology here, no SMDs
1253  EPAD e( aTree );
1254 
1255  D_PAD* pad = new D_PAD( aModule );
1256  aModule->PadsList().PushBack( pad );
1257 
1258  pad->SetPadName( FROM_UTF8( e.name.c_str() ) );
1259 
1260  // pad's "Position" is not relative to the module's,
1261  // whereas Pos0 is relative to the module's but is the unrotated coordinate.
1262 
1263  wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
1264 
1265  pad->SetPos0( padpos );
1266 
1267  RotatePoint( &padpos, aModule->GetOrientation() );
1268 
1269  pad->SetPosition( padpos + aModule->GetPosition() );
1270 
1271  pad->SetDrillSize( wxSize( kicad( e.drill ), kicad( e.drill ) ) );
1272 
1273  pad->SetLayerSet( LSET::AllCuMask().set( B_Mask ).set( F_Mask ) );
1274 
1275  if( e.shape )
1276  {
1277  switch( *e.shape )
1278  {
1279  case EPAD::ROUND:
1280  wxASSERT( pad->GetShape()==PAD_SHAPE_CIRCLE ); // verify set in D_PAD constructor
1281  break;
1282 
1283  case EPAD::OCTAGON:
1284  // no KiCad octagonal pad shape, use PAD_CIRCLE for now.
1285  // pad->SetShape( PAD_OCTAGON );
1286  wxASSERT( pad->GetShape()==PAD_SHAPE_CIRCLE ); // verify set in D_PAD constructor
1287  break;
1288 
1289  case EPAD::LONG:
1290  pad->SetShape( PAD_SHAPE_OVAL );
1291  break;
1292 
1293  case EPAD::SQUARE:
1294  pad->SetShape( PAD_SHAPE_RECT );
1295  break;
1296 
1297  case EPAD::OFFSET:
1298  ; // don't know what to do here.
1299  }
1300  }
1301  else
1302  {
1303  // if shape is not present, our default is circle and that matches their default "round"
1304  }
1305 
1306  if( e.diameter )
1307  {
1308  int diameter = kicad( *e.diameter );
1309  pad->SetSize( wxSize( diameter, diameter ) );
1310  }
1311  else
1312  {
1313  double drillz = pad->GetDrillSize().x;
1314  double annulus = drillz * m_rules->rvPadTop; // copper annulus, eagle "restring"
1315  annulus = Clamp( m_rules->rlMinPadTop, annulus, m_rules->rlMaxPadTop );
1316  int diameter = KiROUND( drillz + 2 * annulus );
1317  pad->SetSize( wxSize( KiROUND( diameter ), KiROUND( diameter ) ) );
1318  }
1319 
1320  if( pad->GetShape() == PAD_SHAPE_OVAL )
1321  {
1322  // The Eagle "long" pad is wider than it is tall,
1323  // m_elongation is percent elongation
1324  wxSize sz = pad->GetSize();
1325  sz.x = ( sz.x * ( 100 + m_rules->psElongationLong ) ) / 100;
1326  pad->SetSize( sz );
1327  }
1328 
1329  if( e.rot )
1330  {
1331  pad->SetOrientation( e.rot->degrees * 10 );
1332  }
1333 
1334  // @todo: handle stop and thermal
1335 }
1336 
1337 
1338 void EAGLE_PLUGIN::packageText( MODULE* aModule, wxXmlNode* aTree ) const
1339 {
1340  ETEXT t( aTree );
1341  PCB_LAYER_ID layer = kicad_layer( t.layer );
1342 
1343  if( layer == UNDEFINED_LAYER )
1344  {
1345  layer = Cmts_User;
1346  }
1347 
1348  TEXTE_MODULE* txt;
1349 
1350  if( t.text == ">NAME" || t.text == ">name" )
1351  txt = &aModule->Reference();
1352  else if( t.text == ">VALUE" || t.text == ">value" )
1353  txt = &aModule->Value();
1354  else
1355  {
1356  // FIXME: graphical text items are rotated for some reason.
1357  txt = new TEXTE_MODULE( aModule );
1358  aModule->GraphicalItemsList().PushBack( txt );
1359  }
1360 
1361  txt->SetTimeStamp( timeStamp( aTree ) );
1362  txt->SetText( FROM_UTF8( t.text.c_str() ) );
1363 
1364  wxPoint pos( kicad_x( t.x ), kicad_y( t.y ) );
1365 
1366  txt->SetTextPos( pos );
1367  txt->SetPos0( pos - aModule->GetPosition() );
1368 
1369  txt->SetLayer( layer );
1370  txt->SetTextSize( kicad_fontz( t.size ) );
1371 
1372  double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default
1373 
1374  txt->SetThickness( kicad( t.size * ratio / 100 ) );
1375 
1376  int align = t.align ? *t.align : ETEXT::BOTTOM_LEFT; // bottom-left is eagle default
1377 
1378  // An eagle package is never rotated, the DTD does not allow it.
1379  // angle -= aModule->GetOrienation();
1380 
1381  if( t.rot )
1382  {
1383  int sign = t.rot->mirror ? -1 : 1;
1384  txt->SetMirrored( t.rot->mirror );
1385 
1386  double degrees = t.rot->degrees;
1387 
1388  if( degrees == 90 || t.rot->spin )
1389  txt->SetTextAngle( sign * degrees * 10 );
1390  else if( degrees == 180 )
1391  align = ETEXT::TOP_RIGHT;
1392  else if( degrees == 270 )
1393  {
1394  align = ETEXT::TOP_RIGHT;
1395  txt->SetTextAngle( sign * 90 * 10 );
1396  }
1397  }
1398 
1399  switch( align )
1400  {
1401  case ETEXT::CENTER:
1402  // this was the default in pcbtxt's constructor
1403  break;
1404 
1405  case ETEXT::CENTER_LEFT:
1407  break;
1408 
1409  case ETEXT::CENTER_RIGHT:
1411  break;
1412 
1413  case ETEXT::TOP_CENTER:
1415  break;
1416 
1417  case ETEXT::TOP_LEFT:
1420  break;
1421 
1422  case ETEXT::TOP_RIGHT:
1425  break;
1426 
1427  case ETEXT::BOTTOM_CENTER:
1429  break;
1430 
1431  case ETEXT::BOTTOM_LEFT:
1434  break;
1435 
1436  case ETEXT::BOTTOM_RIGHT:
1439  break;
1440  }
1441 }
1442 
1443 
1444 void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const
1445 {
1446  ERECT r( aTree );
1447  PCB_LAYER_ID layer = kicad_layer( r.layer );
1448 
1449  if( IsNonCopperLayer( layer ) ) // skip copper "package.rectangle"s
1450  {
1451  EDGE_MODULE* dwg = new EDGE_MODULE( aModule, S_POLYGON );
1452  aModule->GraphicalItemsList().PushBack( dwg );
1453 
1454  dwg->SetLayer( layer );
1455  dwg->SetWidth( 0 );
1456 
1457  dwg->SetTimeStamp( timeStamp( aTree ) );
1458 
1459  std::vector<wxPoint> pts;
1460 
1461  wxPoint start( wxPoint( kicad_x( r.x1 ), kicad_y( r.y1 ) ) );
1462  wxPoint end( wxPoint( kicad_x( r.x1 ), kicad_y( r.y2 ) ) );
1463 
1464  pts.push_back( start );
1465  pts.push_back( wxPoint( kicad_x( r.x2 ), kicad_y( r.y1 ) ) );
1466  pts.push_back( wxPoint( kicad_x( r.x2 ), kicad_y( r.y2 ) ) );
1467  pts.push_back( end );
1468 
1469  dwg->SetPolyPoints( pts );
1470 
1471  dwg->SetStart0( start );
1472  dwg->SetEnd0( end );
1473  }
1474 }
1475 
1476 
1477 void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const
1478 {
1479  EPOLYGON p( aTree );
1480  PCB_LAYER_ID layer = kicad_layer( p.layer );
1481 
1482  if( IsNonCopperLayer( layer ) ) // skip copper "package.rectangle"s
1483  {
1484  EDGE_MODULE* dwg = new EDGE_MODULE( aModule, S_POLYGON );
1485  aModule->GraphicalItemsList().PushBack( dwg );
1486 
1487  dwg->SetWidth( 0 ); // it's filled, no need for boundary width
1488 
1489  /*
1490  switch( layer )
1491  {
1492  case Eco1_User: layer = F_SilkS; break;
1493  case Eco2_User: layer = B_SilkS; break;
1494 
1495  // all MODULE templates (created from eagle packages) are on front layer
1496  // until cloned.
1497  case Cmts_User: layer = F_SilkS; break;
1498  }
1499  */
1500 
1501  dwg->SetLayer( layer );
1502 
1503  dwg->SetTimeStamp( timeStamp( aTree ) );
1504 
1505  std::vector<wxPoint> pts;
1506  // TODO: I think there's no way to know a priori the number of children in wxXmlNode :()
1507  // pts.reserve( aTree.size() );
1508 
1509  // Get the first vertex and iterate
1510  wxXmlNode* vertex = aTree->GetChildren();
1511 
1512  while( vertex )
1513  {
1514  if( vertex->GetName() != "vertex" ) // skip <xmlattr> node
1515  continue;
1516 
1517  EVERTEX v( vertex );
1518 
1519  pts.push_back( wxPoint( kicad_x( v.x ), kicad_y( v.y ) ) );
1520 
1521  vertex = vertex->GetNext();
1522  }
1523 
1524  dwg->SetPolyPoints( pts );
1525 
1526  dwg->SetStart0( *pts.begin() );
1527  dwg->SetEnd0( pts.back() );
1528  }
1529 }
1530 
1531 
1532 void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
1533 {
1534  ECIRCLE e( aTree );
1535  PCB_LAYER_ID layer = kicad_layer( e.layer );
1536  EDGE_MODULE* gr = new EDGE_MODULE( aModule, S_CIRCLE );
1537 
1538  aModule->GraphicalItemsList().PushBack( gr );
1539 
1540  gr->SetWidth( kicad( e.width ) );
1541 
1542  switch( (int) layer )
1543  {
1544  case UNDEFINED_LAYER: layer = Cmts_User; break;
1545  /*
1546  case Eco1_User: layer = F_SilkS; break;
1547  case Eco2_User: layer = B_SilkS; break;
1548  */
1549  default:
1550  break;
1551  }
1552 
1553  gr->SetLayer( layer );
1554  gr->SetTimeStamp( timeStamp( aTree ) );
1555 
1556  gr->SetStart0( wxPoint( kicad_x( e.x ), kicad_y( e.y ) ) );
1557  gr->SetEnd0( wxPoint( kicad_x( e.x + e.radius ), kicad_y( e.y ) ) );
1558 }
1559 
1560 
1561 void EAGLE_PLUGIN::packageHole( MODULE* aModule, wxXmlNode* aTree ) const
1562 {
1563  EHOLE e( aTree );
1564 
1565  // we add a PAD_ATTRIB_HOLE_NOT_PLATED pad to this module.
1566  D_PAD* pad = new D_PAD( aModule );
1567  aModule->PadsList().PushBack( pad );
1568 
1569  pad->SetShape( PAD_SHAPE_CIRCLE );
1571 
1572  // Mechanical purpose only:
1573  // no offset, no net name, no pad name allowed
1574  // pad->SetOffset( wxPoint( 0, 0 ) );
1575  // pad->SetPadName( wxEmptyString );
1576 
1577  wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
1578 
1579  pad->SetPos0( padpos );
1580  pad->SetPosition( padpos + aModule->GetPosition() );
1581 
1582  wxSize sz( kicad( e.drill ), kicad( e.drill ) );
1583 
1584  pad->SetDrillSize( sz );
1585  pad->SetSize( sz );
1586 
1587  pad->SetLayerSet( LSET::AllCuMask() /* | SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT */ );
1588 }
1589 
1590 
1591 void EAGLE_PLUGIN::packageSMD( MODULE* aModule, wxXmlNode* aTree ) const
1592 {
1593  ESMD e( aTree );
1594  PCB_LAYER_ID layer = kicad_layer( e.layer );
1595 
1596  if( !IsCopperLayer( layer ) )
1597  {
1598  return;
1599  }
1600 
1601  D_PAD* pad = new D_PAD( aModule );
1602  aModule->PadsList().PushBack( pad );
1603 
1604  pad->SetPadName( FROM_UTF8( e.name.c_str() ) );
1605  pad->SetShape( PAD_SHAPE_RECT );
1606  pad->SetAttribute( PAD_ATTRIB_SMD );
1607 
1608  // pad's "Position" is not relative to the module's,
1609  // whereas Pos0 is relative to the module's but is the unrotated coordinate.
1610 
1611  wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
1612 
1613  pad->SetPos0( padpos );
1614 
1615  RotatePoint( &padpos, aModule->GetOrientation() );
1616 
1617  pad->SetPosition( padpos + aModule->GetPosition() );
1618 
1619  pad->SetSize( wxSize( kicad( e.dx ), kicad( e.dy ) ) );
1620 
1621  pad->SetLayer( layer );
1622 
1623  static const LSET front( 3, F_Cu, F_Paste, F_Mask );
1624  static const LSET back( 3, B_Cu, B_Paste, B_Mask );
1625 
1626  if( layer == F_Cu )
1627  pad->SetLayerSet( front );
1628  else if( layer == B_Cu )
1629  pad->SetLayerSet( back );
1630 
1631  // Optional according to DTD
1632  if( e.roundness ) // set set shape to PAD_SHAPE_RECT above, in case roundness is not present
1633  {
1634  if( *e.roundness >= 75 ) // roundness goes from 0-100% as integer
1635  {
1636  if( e.dy == e.dx )
1637  pad->SetShape( PAD_SHAPE_CIRCLE );
1638  else
1639  pad->SetShape( PAD_SHAPE_OVAL );
1640  }
1641  }
1642 
1643  if( e.rot )
1644  {
1645  pad->SetOrientation( e.rot->degrees * 10 );
1646  }
1647 
1648  // don't know what stop, thermals, and cream should look like now.
1649 }
1650 
1651 
1653 {
1654  for( auto& t : m_templates )
1655  delete t.second;
1656 
1657  m_templates.clear();
1658 }
1659 
1660 
1662 typedef std::vector<ZONE_CONTAINER*> ZONES;
1663 
1664 
1665 void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
1666 {
1667  ZONES zones; // per net
1668 
1669  m_xpath->push( "signals.signal", "name" );
1670 
1671  int netCode = 1;
1672 
1673  // Get the first signal and iterate
1674  wxXmlNode* net = aSignals->GetChildren();
1675 
1676  while( net )
1677  {
1678  bool sawPad = false;
1679 
1680  zones.clear();
1681 
1682  const string& nname = net->GetAttribute( "name" ).ToStdString();
1683  wxString netName = FROM_UTF8( nname.c_str() );
1684  m_board->Add( new NETINFO_ITEM( m_board, netName, netCode ) );
1685 
1686  m_xpath->Value( nname.c_str() );
1687 
1688  // Get the first net item and iterate
1689  wxXmlNode* netItem = net->GetChildren();
1690 
1691  // (contactref | polygon | wire | via)*
1692  while( netItem )
1693  {
1694  const wxString& itemName = netItem->GetName();
1695  if( itemName == "wire" )
1696  {
1697  m_xpath->push( "wire" );
1698 
1699  EWIRE w( netItem );
1700  PCB_LAYER_ID layer = kicad_layer( w.layer );
1701 
1702  if( IsCopperLayer( layer ) )
1703  {
1704  TRACK* t = new TRACK( m_board );
1705 
1706  t->SetTimeStamp( timeStamp( netItem ) );
1707 
1708  t->SetPosition( wxPoint( kicad_x( w.x1 ), kicad_y( w.y1 ) ) );
1709  t->SetEnd( wxPoint( kicad_x( w.x2 ), kicad_y( w.y2 ) ) );
1710 
1711  int width = kicad( w.width );
1712  if( width < m_min_trace )
1713  m_min_trace = width;
1714 
1715  t->SetWidth( width );
1716  t->SetLayer( layer );
1717  t->SetNetCode( netCode );
1718 
1719  m_board->m_Track.Insert( t, NULL );
1720  }
1721  else
1722  {
1723  // put non copper wires where the sun don't shine.
1724  }
1725 
1726  m_xpath->pop();
1727  }
1728 
1729  else if( itemName == "via" )
1730  {
1731  m_xpath->push( "via" );
1732  EVIA v( netItem );
1733 
1734  PCB_LAYER_ID layer_front_most = kicad_layer( v.layer_front_most );
1735  PCB_LAYER_ID layer_back_most = kicad_layer( v.layer_back_most );
1736 
1737  if( IsCopperLayer( layer_front_most ) &&
1738  IsCopperLayer( layer_back_most ) )
1739  {
1740  int kidiam;
1741  int drillz = kicad( v.drill );
1742  VIA* via = new VIA( m_board );
1743  m_board->m_Track.Insert( via, NULL );
1744 
1745  via->SetLayerPair( layer_front_most, layer_back_most );
1746 
1747  if( v.diam )
1748  {
1749  kidiam = kicad( *v.diam );
1750  via->SetWidth( kidiam );
1751  }
1752  else
1753  {
1754  double annulus = drillz * m_rules->rvViaOuter; // eagle "restring"
1755  annulus = Clamp( m_rules->rlMinViaOuter, annulus, m_rules->rlMaxViaOuter );
1756  kidiam = KiROUND( drillz + 2 * annulus );
1757  via->SetWidth( kidiam );
1758  }
1759 
1760  via->SetDrill( drillz );
1761 
1762  // make sure the via diameter respects the restring rules
1763 
1764  if( !v.diam || via->GetWidth() <= via->GetDrill() )
1765  {
1766  double annulus = Clamp( m_rules->rlMinViaOuter,
1767  (double)( via->GetWidth() / 2 - via->GetDrill() ), m_rules->rlMaxViaOuter );
1768  via->SetWidth( drillz + 2 * annulus );
1769  }
1770 
1771  if( kidiam < m_min_via )
1772  m_min_via = kidiam;
1773 
1774  if( drillz < m_min_via_hole )
1775  m_min_via_hole = drillz;
1776 
1777  if( layer_front_most == F_Cu && layer_back_most == B_Cu )
1778  via->SetViaType( VIA_THROUGH );
1779  else if( layer_front_most == F_Cu || layer_back_most == B_Cu )
1780  via->SetViaType( VIA_MICROVIA );
1781  else
1782  via->SetViaType( VIA_BLIND_BURIED );
1783 
1784  via->SetTimeStamp( timeStamp( netItem ) );
1785 
1786  wxPoint pos( kicad_x( v.x ), kicad_y( v.y ) );
1787 
1788  via->SetPosition( pos );
1789  via->SetEnd( pos );
1790 
1791  via->SetNetCode( netCode );
1792  }
1793 
1794  m_xpath->pop();
1795  }
1796 
1797  else if( itemName == "contactref" )
1798  {
1799  m_xpath->push( "contactref" );
1800  // <contactref element="RN1" pad="7"/>
1801 
1802  const string& reference = netItem->GetAttribute( "element" ).ToStdString();
1803  const string& pad = netItem->GetAttribute( "pad" ).ToStdString();
1804 
1805  string key = makeKey( reference, pad ) ;
1806 
1807  // D(printf( "adding refname:'%s' pad:'%s' netcode:%d netname:'%s'\n", reference.c_str(), pad.c_str(), netCode, nname.c_str() );)
1808 
1809  m_pads_to_nets[ key ] = ENET( netCode, nname );
1810 
1811  m_xpath->pop();
1812 
1813  sawPad = true;
1814  }
1815 
1816  else if( itemName == "polygon" )
1817  {
1818  m_xpath->push( "polygon" );
1819 
1820  EPOLYGON p( netItem );
1821  PCB_LAYER_ID layer = kicad_layer( p.layer );
1822 
1823  if( IsCopperLayer( layer ) )
1824  {
1825  // use a "netcode = 0" type ZONE:
1826  ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
1827  m_board->Add( zone, ADD_APPEND );
1828  zones.push_back( zone );
1829 
1830  zone->SetTimeStamp( timeStamp( netItem ) );
1831  zone->SetLayer( layer );
1832  zone->SetNetCode( netCode );
1833 
1834  // Get the first vertex and iterate
1835  wxXmlNode* vertex = netItem->GetChildren();
1836 
1837  while( vertex )
1838  {
1839  if( vertex->GetName() != "vertex" ) // skip <xmlattr> node
1840  continue;
1841 
1842  EVERTEX v( vertex );
1843 
1844  // Append the corner
1845  zone->AppendCorner( wxPoint( kicad_x( v.x ), kicad_y( v.y ) ), -1 );
1846 
1847  vertex = vertex->GetNext();
1848  }
1849 
1850  // If the pour is a cutout it needs to be set to a keepout
1851  if( p.pour == EPOLYGON::CUTOUT )
1852  {
1853  zone->SetIsKeepout( true );
1854  zone->SetDoNotAllowCopperPour( true );
1856  }
1857 
1858  // if spacing is set the zone should be hatched
1859  // However, use the default hatch step, p.spacing value has no meaning for Kicad
1860  // TODO: see if this parameter is related to a grid fill option.
1861  if( p.spacing )
1863 
1864  // clearances, etc.
1865  zone->SetArcSegmentCount( 32 ); // @todo: should be a constructor default?
1866  zone->SetMinThickness( kicad( p.width ) );
1867 
1868  // FIXME: KiCad zones have very rounded corners compared to eagle.
1869  // This means that isolation amounts that work well in eagle
1870  // tend to make copper intrude in soldermask free areas around pads.
1871  if( p.isolate )
1872  {
1873  zone->SetZoneClearance( kicad( *p.isolate ) );
1874  } else
1875  {
1876  zone->SetZoneClearance( 0 );
1877  }
1878 
1879  // missing == yes per DTD.
1880  bool thermals = !p.thermals || *p.thermals;
1882  if( thermals )
1883  {
1884  // FIXME: eagle calculates dimensions for thermal spokes
1885  // based on what the zone is connecting to.
1886  // (i.e. width of spoke is half of the smaller side of an smd pad)
1887  // This is a basic workaround
1888  zone->SetThermalReliefGap( kicad( p.width + 0.05 ) );
1889  zone->SetThermalReliefCopperBridge( kicad( p.width + 0.05 ) );
1890  }
1891 
1892  int rank = p.rank ? (p.max_priority - *p.rank) : p.max_priority;
1893  zone->SetPriority( rank );
1894  }
1895 
1896  m_xpath->pop(); // "polygon"
1897  }
1898 
1899  netItem = netItem->GetNext();
1900  }
1901 
1902  if( zones.size() && !sawPad )
1903  {
1904  // KiCad does not support an unconnected zone with its own non-zero netcode,
1905  // but only when assigned netcode = 0 w/o a name...
1906  for( ZONES::iterator it = zones.begin(); it != zones.end(); ++it )
1907  (*it)->SetNetCode( NETINFO_LIST::UNCONNECTED );
1908 
1909  // therefore omit this signal/net.
1910  }
1911  else
1912  netCode++;
1913 
1914  // Get next signal
1915  net = net->GetNext();
1916  }
1917 
1918  m_xpath->pop(); // "signals.signal"
1919 }
1920 
1921 
1922 PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
1923 {
1924  int kiLayer;
1925 
1926  // eagle copper layer:
1927  if( aEagleLayer >= 1 && aEagleLayer < int( DIM( m_cu_map ) ) )
1928  {
1929  kiLayer = m_cu_map[aEagleLayer];
1930  }
1931 
1932  else
1933  {
1934  // translate non-copper eagle layer to pcbnew layer
1935  switch( aEagleLayer )
1936  {
1937  // Eagle says "Dimension" layer, but it's for board perimeter
1938  case EAGLE_LAYER::DIMENSION: kiLayer = Edge_Cuts; break;
1939  case EAGLE_LAYER::TPLACE: kiLayer = F_SilkS; break;
1940  case EAGLE_LAYER::BPLACE: kiLayer = B_SilkS; break;
1941  case EAGLE_LAYER::TNAMES: kiLayer = F_SilkS; break;
1942  case EAGLE_LAYER::BNAMES: kiLayer = B_SilkS; break;
1943  case EAGLE_LAYER::TVALUES: kiLayer = F_SilkS; break;
1944  case EAGLE_LAYER::BVALUES: kiLayer = B_SilkS; break;
1945  case EAGLE_LAYER::TSTOP: kiLayer = F_Mask; break;
1946  case EAGLE_LAYER::BSTOP: kiLayer = B_Mask; break;
1947  case EAGLE_LAYER::TCREAM: kiLayer = F_Paste; break;
1948  case EAGLE_LAYER::BCREAM: kiLayer = B_Paste; break;
1949  case EAGLE_LAYER::TFINISH: kiLayer = F_Mask; break;
1950  case EAGLE_LAYER::BFINISH: kiLayer = B_Mask; break;
1951  case EAGLE_LAYER::TGLUE: kiLayer = F_Adhes; break;
1952  case EAGLE_LAYER::BGLUE: kiLayer = B_Adhes; break;
1953  case EAGLE_LAYER::DOCUMENT: kiLayer = Cmts_User; break;
1954  case EAGLE_LAYER::REFERENCELC: kiLayer = Cmts_User; break;
1955  case EAGLE_LAYER::REFERENCELS: kiLayer = Cmts_User; break;
1956 
1957  // Packages show the future chip pins on SMD parts using layer 51.
1958  // This is an area slightly smaller than the PAD/SMD copper area.
1959  // Carry those visual aids into the MODULE on the fabrication layer,
1960  // not silkscreen. This is perhaps not perfect, but there is not a lot
1961  // of other suitable paired layers
1962  case EAGLE_LAYER::TDOCU: kiLayer = F_Fab; break;
1963  case EAGLE_LAYER::BDOCU: kiLayer = B_Fab; break;
1964 
1965  // thes layers are defined as user layers. put them on ECO layers
1966  case EAGLE_LAYER::USERLAYER1: kiLayer = Eco1_User; break;
1967  case EAGLE_LAYER::USERLAYER2: kiLayer = Eco2_User; break;
1968 
1969  case EAGLE_LAYER::UNROUTED:
1970  case EAGLE_LAYER::TKEEPOUT:
1971  case EAGLE_LAYER::BKEEPOUT:
1972  case EAGLE_LAYER::TTEST:
1973  case EAGLE_LAYER::BTEST:
1974  case EAGLE_LAYER::MILLING:
1975  case EAGLE_LAYER::HOLES:
1976  default:
1977  // some layers do not map to KiCad
1978  wxLogMessage( wxString::Format( "Unsupported Eagle layer %d. Use drawings layer",
1979  aEagleLayer ) );
1980  kiLayer = Dwgs_User; break;
1981  }
1982  }
1983 
1984  return PCB_LAYER_ID( kiLayer );
1985 }
1986 
1987 
1989 {
1990  if( m_props )
1991  {
1992  UTF8 page_width;
1993  UTF8 page_height;
1994 
1995  if( m_props->Value( "page_width", &page_width ) &&
1996  m_props->Value( "page_height", &page_height ) )
1997  {
1999 
2000  int w = atoi( page_width.c_str() );
2001  int h = atoi( page_height.c_str() );
2002 
2003  int desired_x = ( w - bbbox.GetWidth() ) / 2;
2004  int desired_y = ( h - bbbox.GetHeight() ) / 2;
2005 
2006  DBG(printf( "bbox.width:%d bbox.height:%d w:%d h:%d desired_x:%d desired_y:%d\n",
2007  bbbox.GetWidth(), bbbox.GetHeight(), w, h, desired_x, desired_y );)
2008 
2009  m_board->Move( wxPoint( desired_x - bbbox.GetX(), desired_y - bbbox.GetY() ) );
2010  }
2011  }
2012 }
2013 
2014 
2015 wxDateTime EAGLE_PLUGIN::getModificationTime( const wxString& aPath )
2016 {
2017  wxFileName fn( aPath );
2018 
2019  // Do not call wxFileName::GetModificationTime() on a non-existent file, because
2020  // if it fails, wx's implementation calls the crap wxLogSysError() which
2021  // eventually infects our UI with an unwanted popup window, so don't let it fail.
2022  if( !fn.IsFileReadable() )
2023  {
2024  wxString msg = wxString::Format(
2025  _( "File '%s' is not readable." ),
2026  GetChars( aPath ) );
2027 
2028  THROW_IO_ERROR( msg );
2029  }
2030 
2031  /*
2032  // update the writable flag while we have a wxFileName, in a network this
2033  // is possibly quite dynamic anyway.
2034  m_writable = fn.IsFileWritable();
2035  */
2036 
2037  wxDateTime modTime = fn.GetModificationTime();
2038 
2039  if( !modTime.IsValid() )
2040  modTime.Now();
2041 
2042  return modTime;
2043 }
2044 
2045 
2046 void EAGLE_PLUGIN::cacheLib( const wxString& aLibPath )
2047 {
2048  try
2049  {
2050  wxDateTime modtime = getModificationTime( aLibPath );
2051 
2052  // Fixes assertions in wxWidgets debug builds for the wxDateTime object. Refresh the
2053  // cache if either of the wxDateTime objects are invalid or the last file modification
2054  // time differs from the current file modification time.
2055  bool load = !m_mod_time.IsValid() || !modtime.IsValid() ||
2056  m_mod_time != modtime;
2057 
2058  if( aLibPath != m_lib_path || load )
2059  {
2060  wxXmlNode* doc;
2061  LOCALE_IO toggle; // toggles on, then off, the C locale.
2062 
2063  deleteTemplates();
2064 
2065  // Set this before completion of loading, since we rely on it for
2066  // text of an exception. Delay setting m_mod_time until after successful load
2067  // however.
2068  m_lib_path = aLibPath;
2069 
2070  // 8 bit "filename" should be encoded according to disk filename encoding,
2071  // (maybe this is current locale, maybe not, its a filesystem issue),
2072  // and is not necessarily utf8.
2073  string filename = (const char*) aLibPath.char_str( wxConvFile );
2074 
2075  // Load the document
2076  wxXmlDocument xmlDocument;
2077  wxFileName fn( filename );
2078 
2079  if( !xmlDocument.Load( fn.GetFullPath() ) )
2080  THROW_IO_ERROR( wxString::Format( _( "Unable to read file '%s'" ),
2081  fn.GetFullPath() ) );
2082 
2083  doc = xmlDocument.GetRoot();
2084 
2085  wxXmlNode* drawing = MapChildren( doc )["drawing"];
2086  NODE_MAP drawingChildren = MapChildren( drawing );
2087 
2088  // clear the cu map and then rebuild it.
2089  clear_cu_map();
2090 
2091  m_xpath->push( "eagle.drawing.layers" );
2092  wxXmlNode* layers = drawingChildren["layers"];
2093  loadLayerDefs( layers );
2094  m_xpath->pop();
2095 
2096  m_xpath->push( "eagle.drawing.library" );
2097  wxXmlNode* library = drawingChildren["library"];
2098  loadLibrary( library, NULL );
2099  m_xpath->pop();
2100 
2101  m_mod_time = modtime;
2102  }
2103  }
2104  catch(...){}
2105  // TODO: Handle exceptions
2106  // catch( file_parser_error fpe )
2107  // {
2108  // // for xml_parser_error, what() has the line number in it,
2109  // // but no byte offset. That should be an adequate error message.
2110  // THROW_IO_ERROR( fpe.what() );
2111  // }
2112  //
2113  // // Class ptree_error is a base class for xml_parser_error & file_parser_error,
2114  // // so one catch should be OK for all errors.
2115  // catch( ptree_error pte )
2116  // {
2117  // string errmsg = pte.what();
2118  //
2119  // errmsg += " @\n";
2120  // errmsg += m_xpath->Contents();
2121  //
2122  // THROW_IO_ERROR( errmsg );
2123  // }
2124 }
2125 
2126 
2127 void EAGLE_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
2128  const PROPERTIES* aProperties )
2129 {
2130  init( aProperties );
2131 
2132  cacheLib( aLibraryPath );
2133 
2134  for( MODULE_CITER it = m_templates.begin(); it != m_templates.end(); ++it )
2135  aFootprintNames.Add( FROM_UTF8( it->first.c_str() ) );
2136 }
2137 
2138 
2139 MODULE* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
2140  const PROPERTIES* aProperties )
2141 {
2142  init( aProperties );
2143 
2144  cacheLib( aLibraryPath );
2145 
2146  string key = TO_UTF8( aFootprintName );
2147 
2148  MODULE_CITER mi = m_templates.find( key );
2149 
2150  if( mi == m_templates.end() )
2151  return NULL;
2152 
2153  // copy constructor to clone the template
2154  MODULE* ret = new MODULE( *mi->second );
2155 
2156  return ret;
2157 }
2158 
2159 
2160 void EAGLE_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const
2161 {
2162  PLUGIN::FootprintLibOptions( aListToAppendTo );
2163 
2164  /*
2165  (*aListToAppendTo)["ignore_duplicates"] = UTF8( _(
2166  "Ignore duplicately named footprints within the same Eagle library. "
2167  "Only the first similarly named footprint will be loaded."
2168  ));
2169  */
2170 }
2171 
2172 
2173 /*
2174 void EAGLE_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
2175 {
2176  // Eagle lovers apply here.
2177 }
2178 
2179 
2180 void EAGLE_PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, const PROPERTIES* aProperties )
2181 {
2182 }
2183 
2184 
2185 void EAGLE_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName )
2186 {
2187 }
2188 
2189 
2190 void EAGLE_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
2191 {
2192 }
2193 
2194 
2195 bool EAGLE_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
2196 {
2197 }
2198 
2199 
2200 bool EAGLE_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
2201 {
2202  return true;
2203 }
2204 
2205 */
void SetMirrored(bool isMirrored)
Definition: eda_text.h:178
opt_double diameter
Definition: eagle_parser.h:553
Eagle vertex.
Definition: eagle_parser.h:593
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:639
Class UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion supp...
Definition: utf8.h:73
#define DIM(x)
of elements in an array
Definition: macros.h:98
MODULE_MAP::iterator MODULE_ITER
void SetEnd0(const wxPoint &aPoint)
double width
Definition: eagle_parser.h:401
void loadAllSections(wxXmlNode *aDocument)
string package
Definition: eagle_parser.h:647
double rlMaxViaOuter
maximum copper annulus on via
Definition: eagle_plugin.h:57
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
bool mirror
Definition: eagle_parser.h:376
opt_double curve
range is -359.9..359.9
Definition: eagle_parser.h:412
std::unordered_map< string, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:46
double radius
Definition: eagle_parser.h:445
void SetTextAngle(double aAngle)
double size
Definition: eagle_parser.h:520
TEXTE_MODULE & Reference()
Definition: class_module.h:463
opt_double isolate
Definition: eagle_parser.h:622
void SetShape(STROKE_T aShape)
NETCLASSPTR GetDefault() const
Function GetDefault.
opt_int rank
Definition: eagle_parser.h:625
void clear_cu_map()
const T & Clamp(const T &lower, const T &value, const T &upper)
Function Clamp limits value within the range lower <= value <= upper.
Definition: macros.h:127
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
void centerBoard()
move the BOARD into the center of the page
BOARD * m_board
which BOARD is being worked on, no ownership here
Definition: eagle_plugin.h:145
TEXTE_PCB class definition.
string name
Definition: eagle_parser.h:645
double y
Definition: eagle_parser.h:578
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:440
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:63
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
void FootprintLibOptions(PROPERTIES *aProperties) const override
Function FootprintLibOptions appends supported PLUGIN options to aListToAppenTo along with internatio...
string name
Definition: eagle_parser.h:576
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:412
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void packageHole(MODULE *aModule, wxXmlNode *aTree) const
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:117
void clear()
Definition: eagle_parser.h:109
NODE_MAP MapChildren(wxXmlNode *currentNode)
Function MapChildren provides an easy access to the children of an XML node via their names...
ERULES * m_rules
Eagle design rules.
Definition: eagle_plugin.h:131
unsigned long timeStamp(wxXmlNode *aTree)
Make a unique time stamp.
MODULE * makeModule(wxXmlNode *aPackage, const std::string &aPkgName) const
Function makeModule creates a MODULE from an Eagle package.
double y
Definition: eagle_parser.h:635
int m_PcbTextWidth
current Pcb (not module) Text width
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
Class BOARD to handle a board.
const wxPoint & GetPosition() const override
Definition: class_module.h:155
double x
Definition: eagle_parser.h:577
void push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:104
bool Value(const char *aName, UTF8 *aFetchedValue=NULL) const
Function Value fetches a property by aName and returns true if that property was found, else false.
Definition: properties.cpp:24
Eagle element element.
Definition: eagle_parser.h:643
polygon (not yet used for tracks, but could be in microwave apps)
Class XPATH keeps track of what we are working on within a PTREE.
Definition: eagle_parser.h:99
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
Return a list of footprint names contained within the library at aLibraryPath.
static const int max_priority
Definition: eagle_parser.h:614
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:59
double rlMaxPadTop
maximum copper annulus on through hole pads
Definition: eagle_plugin.h:53
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
void SetVisible(bool aVisible)
Definition: eda_text.h:175
opt_double ratio
Definition: eagle_parser.h:523
int GetHeight() const
int number
Definition: eagle_parser.h:661
double y
Definition: eagle_parser.h:429
void SetCopperLayerCount(int aCount)
opt_erot rot
Definition: eagle_parser.h:653
opt_bool thermals
Definition: eagle_parser.h:624
double x1
Definition: eagle_parser.h:456
void packageText(MODULE *aModule, wxXmlNode *aTree) const
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Function ReplaceIllegalFileNameChars checks aName for illegal file name characters.
Definition: string.cpp:483
opt_bool smashed
Definition: eagle_parser.h:652
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:169
Classes to handle copper zones.
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=NULL) override
Function Load loads information from some input file format that this PLUGIN implementation knows abo...
const wxString & GetValue() const
Function GetValue.
Definition: class_module.h:447
usual segment : line with rounded ends
void parse(wxXmlNode *aRules)
wxPoint kicad_arc_center(const wxPoint &aStart, const wxPoint &aEnd, double aAngle)
Convert an Eagle curve end to a KiCad center for S_ARC.
void SetArcSegmentCount(int aArcSegCount)
Definition: class_zone.h:197
NET_MAP::const_iterator NET_MAP_CITER
Definition: eagle_plugin.h:38
void SetHatch(int aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetHatch sets all hatch parameters for the zone.
Definition: class_zone.cpp:926
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void SetDrillSize(const wxSize &aSize)
Definition: class_pad.h:187
double degrees
Definition: eagle_parser.h:378
opt_double size
Definition: eagle_parser.h:479
void packagePolygon(MODULE *aModule, wxXmlNode *aTree) const
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
Eagle SMD pad.
Definition: eagle_parser.h:574
wxSize kicad_fontz(double d) const
create a font size (fontz) from an eagle font size scalar
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Function SetLayerType changes the type of the layer given by aLayer.
opt_double spacing
Definition: eagle_parser.h:607
double y2
Definition: eagle_parser.h:400
const wxSize & GetDrillSize() const
Definition: class_pad.h:188
Class LIB_ID.
Definition: lib_id.h:56
int m_min_via
smallest via we find on Load(), in BIU.
Definition: eagle_plugin.h:148
double rvViaOuter
copper annulus is this percent of via hole
Definition: eagle_plugin.h:55
Class PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
#define cu(a)
Definition: auxiliary.h:88
Eagle hole element.
Definition: eagle_parser.h:632
Class XML_PARSER_ERROR implements a simple wrapper around runtime_error to isolate the errors thrown ...
Definition: eagle_parser.h:57
Eagle text element.
Definition: eagle_parser.h:515
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:166
#define abs(a)
Definition: auxiliary.h:84
double x2
Definition: eagle_parser.h:399
int GetDrill() const
Function GetDrill returns the local drill setting for this VIA.
Definition: class_track.h:454
void loadLayerDefs(wxXmlNode *aLayers)
double x
Definition: eagle_parser.h:649
void packageCircle(MODULE *aModule, wxXmlNode *aTree) const
opt_erot rot
Definition: eagle_parser.h:482
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:132
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:203
double GetTextAngle() const
Definition: eda_text.h:164
Functions relatives to tracks, vias and segments used to fill zones.
#define DEFAULT_PCB_EDGE_THICKNESS
int m_cu_map[17]
map eagle to kicad, cu layers only.
Definition: eagle_plugin.h:129
bool IsNonCopperLayer(LAYER_NUM aLayerId)
Function IsNonCopperLayer tests whether a layer is a non copper layer.
int kicad_y(double y) const
Definition: eagle_plugin.h:164
This file contains miscellaneous commonly used macros and functions.
void SetWidth(int aWidth)
Definition: class_track.h:114
double dx
Definition: eagle_parser.h:579
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
int layer_back_most
< extent
Definition: eagle_parser.h:431
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:789
void SetPriority(unsigned aPriority)
Function SetPriority.
Definition: class_zone.h:113
double y
Definition: eagle_parser.h:650
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
DIMENSION class definition.
PCB_LAYER_ID
A quick note on layer IDs:
int m_min_via_hole
smallest via diameter hole we find on Load(), in BIU.
Definition: eagle_plugin.h:149
string makeKey(const string &aFirst, const string &aSecond)
Assemble a two part key as a simple concatenation of aFirst and aSecond parts, using a separator...
string text
Definition: eagle_parser.h:517
void SetOrigin(const wxPoint &aOrigin)
Function SetOrigin Sets a new origin of the crossbar line.
Class LSET is a set of PCB_LAYER_IDs.
double y
Definition: eagle_parser.h:596
void cacheLib(const wxString &aLibraryPath)
This PLUGIN only caches one footprint library, this determines which one.
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
Definition: eagle_plugin.h:144
LAYER_NUM layer
Definition: eagle_parser.h:402
double x1
Definition: eagle_parser.h:397
int layer
Definition: eagle_parser.h:460
Eagle thru hol pad.
Definition: eagle_parser.h:547
double GetOrientation() const
Definition: class_module.h:160
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:462
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:175
wxSize m_PcbTextSize
current Pcb (not module) Text size
int m_TrackMinWidth
track min value for width ((min copper size value
void SetEnd(const wxPoint &aEnd)
Function SetEnd Sets a new end of the crossbar line.
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize As a rule, pen width should not be >1/4em, otherwise the character will b...
Definition: drawtxt.cpp:67
string name
Definition: eagle_parser.h:475
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:194
Arcs (with rounded ends)
int m_ViasMinSize
vias (not micro vias) min diameter
Eagle circle.
Definition: eagle_parser.h:441
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Function SetLayerName changes the name of the layer given by aLayer.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
opt_double diam
Definition: eagle_parser.h:433
double y1
Definition: eagle_parser.h:457
wxString m_lib_path
Definition: eagle_plugin.h:154
int m_ViasMinDrill
vias (not micro vias) min drill diameter
D_PAD * Next() const
Definition: class_pad.h:106
const wxSize & GetSize() const
Definition: class_pad.h:182
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:524
void SetSize(const wxSize &aSize)
Definition: class_pad.h:181
double x
Definition: eagle_parser.h:634
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
subset of eagle.drawing.board.designrules in the XML document
Definition: eagle_plugin.h:42
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_Layer contains the top layer, the other layer is in m_BottomLayer...
void SetReference(const wxString &aReference)
Function SetReference.
Definition: class_module.h:429
opt_string value
Definition: eagle_parser.h:476
int kicad_x(double x) const
Definition: eagle_plugin.h:165
HATCH_STYLE
Zone hatch styles.
Definition: class_zone.h:85
void SetFileName(const wxString &aFileName)
Definition: class_board.h:232
double y1
Definition: eagle_parser.h:398
void SetPosition(const wxPoint &aPos) override
void SetZoneClearance(int aZoneClearance)
Definition: class_zone.h:204
int layer
Definition: eagle_parser.h:581
static wxDateTime getModificationTime(const wxString &aPath)
get a file's or dir's modification time.
double mdWireWire
wire to wire spacing I presume.
Definition: eagle_plugin.h:58
std::vector< ZONE_CONTAINER * > ZONES
non-owning container
double x
Definition: eagle_parser.h:550
double width
Definition: eagle_parser.h:605
int m_min_trace
smallest trace we find on Load(), in BIU.
Definition: eagle_plugin.h:147
string value
Definition: eagle_parser.h:648
double dy
Definition: eagle_parser.h:580
opt_int roundness
Definition: eagle_parser.h:582
double mm_per_biu
how many mm in each BIU
Definition: eagle_plugin.h:151
int m_hole_count
generates unique module names from eagle "hole"s.
Definition: eagle_plugin.h:135
LAYER_NUM layer
Definition: eagle_parser.h:447
Eagle XML rectangle in binary.
Definition: eagle_parser.h:454
opt_erot rot
Definition: eagle_parser.h:564
void SetAttribute(PAD_ATTR_T aAttribute)
Definition: class_pad.cpp:348
opt_int align
Definition: eagle_parser.h:540
Eagle net.
Definition: eagle_parser.h:357
void SetPos0(const wxPoint &aPos)
int psElongationLong
percent over 100%.
Definition: eagle_plugin.h:44
void AdjustDimensionDetails(bool aDoNotChangeText=false)
Function AdjustDimensionDetails Calculate coordinates of segments used to draw the dimension...
void SetStart(const wxPoint &aStart)
void SetThermalReliefCopperBridge(int aThermalReliefCopperBridge)
Definition: class_zone.h:191
void loadLibraries(wxXmlNode *aLibs)
void loadPlain(wxXmlNode *aPlain)
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
opt_double x
Definition: eagle_parser.h:477
string name
Definition: eagle_parser.h:549
void orientModuleAndText(MODULE *m, const EELEMENT &e, const EATTR *nameAttr, const EATTR *valueAttr)
string Contents()
return the contents of the XPATH as a single string
Definition: eagle_parser.h:126
void Move(const wxPoint &aMoveVector) override
Function Move move this object.
void SetDoNotAllowCopperPour(bool aEnable)
Definition: class_zone.h:660
Class EATTR parses an Eagle "attribute" XML element.
Definition: eagle_parser.h:473
void packageSMD(MODULE *aModule, wxXmlNode *aTree) const
Eagle via.
Definition: eagle_parser.h:426
double width
Definition: eagle_parser.h:446
void SetLayerSet(LSET aLayerMask)
Definition: class_pad.h:234
Class NETINFO_ITEM handles the data for a net.
Definition: class_netinfo.h:69
MODULE_MAP::const_iterator MODULE_CITER
string library
Definition: eagle_parser.h:646
opt_erot rot
Definition: eagle_parser.h:524
int netcode
Definition: eagle_parser.h:359
double x2
Definition: eagle_parser.h:458
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void loadElements(wxXmlNode *aElements)
double drill
Definition: eagle_parser.h:552
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void packagePad(MODULE *aModule, wxXmlNode *aTree) const
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
double x
Definition: eagle_parser.h:443
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:419
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:193
bool IsMirrored() const
Definition: eda_text.h:179
int GetWidth() const
Definition: class_track.h:115
void SetOrientation(double newangle)
void SetPosition(const wxPoint &aPos) override
Definition: class_track.h:111
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
const char * c_str() const
Definition: utf8.h:107
MODULE_MAP m_templates
is part of a MODULE factory that operates using copy construction.
Definition: eagle_plugin.h:139
TEXTE_PCB & Text()
wxDateTime m_mod_time
Definition: eagle_plugin.h:155
void packageWire(MODULE *aModule, wxXmlNode *aTree) const
Class EDA_RECT handles the component boundary box.
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:447
void SetStart0(const wxPoint &aPoint)
double drill
< inclusive
Definition: eagle_parser.h:432
void SetValue(const wxString &aValue)
Function SetValue.
Definition: class_module.h:456
opt_double ratio
Definition: eagle_parser.h:481
int GetX() const
void SetHatchStyle(HATCH_STYLE aStyle)
Definition: class_zone.h:554
static double parseEagle(const wxString &aDistance)
Parse an eagle distance which is either mm, or mils if there is "mil" suffix.
NET_MAP m_pads_to_nets
net list
Definition: eagle_plugin.h:137
The common library.
int GetWidth() const
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:167
void SetPadName(const wxString &name)
Set the pad name (sometimes called pad number, although it can be an array ref like AA12 the pad name...
Definition: class_pad.cpp:455
const char * name
int GetY() const
void SetEnd(const wxPoint &aEnd)
Eagle wire.
Definition: eagle_parser.h:395
void SetOrientation(double aAngle)
Function SetOrientation sets the rotation angle of the pad.
Definition: class_pad.cpp:357
void SetAngle(double aAngle)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees...
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
double x
Definition: eagle_parser.h:428
double y
Definition: eagle_parser.h:519
bool AppendCorner(wxPoint aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
Definition: class_zone.cpp:852
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:137
double x
Definition: eagle_parser.h:595
opt_int shape
Definition: eagle_parser.h:563
opt_erot rot
Definition: eagle_parser.h:583
#define DBG(x)
Definition: fctsys.h:33
Eagle dimension element.
Definition: eagle_parser.h:498
double rvPadTop
top pad size as percent of drill size
Definition: eagle_plugin.h:49
DLIST< D_PAD > & PadsList()
Definition: class_module.h:134
void deleteTemplates()
Deletes the footprint templates list
void packageRectangle(MODULE *aModule, wxXmlNode *aTree) const
void SetTextAngle(double aAngle)
DLIST< TRACK > m_Track
Definition: class_board.h:246
bool spin
Definition: eagle_parser.h:377
double biu_per_mm
how many bius in a mm
Definition: eagle_plugin.h:152
Module description (excepted pads)
const wxSize & GetTextSize() const
Definition: eda_text.h:215
double drill
Definition: eagle_parser.h:636
Eagle polygon, without vertices which are parsed as needed.
Definition: eagle_parser.h:603
opt_int display
Definition: eagle_parser.h:490
void pop()
Definition: eagle_parser.h:111
void SetIsKeepout(bool aEnable)
Definition: class_zone.h:659
void loadDesignRules(wxXmlNode *aDesignRules)
void SetPadConnection(ZoneConnection aPadConnection)
Definition: class_zone.h:207
void SetWidth(int aWidth)
EDGE_MODULE class definition.
const wxString PluginName() const override
Function PluginName returns a brief hard coded name for this PLUGIN.
int layer
Definition: eagle_parser.h:521
void SetMinThickness(int aMinThickness)
Definition: class_zone.h:210
opt_double y
Definition: eagle_parser.h:478
double rlMinPadTop
minimum copper annulus on through hole pads
Definition: eagle_plugin.h:52
double rlMinViaOuter
minimum copper annulus on via
Definition: eagle_plugin.h:56
virtual void FootprintLibOptions(PROPERTIES *aListToAppendTo) const
Function FootprintLibOptions appends supported PLUGIN options to aListToAppenTo along with internatio...
Definition: plugin.cpp:122
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
Use thermal relief for pads.
Definition: zones.h:58
void SetThermalReliefGap(int aThermalReliefGap)
Definition: class_zone.h:188
MODULE * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a lib...
Class DIMENSION.
opt_bool active
Definition: eagle_parser.h:666
double x
Definition: eagle_parser.h:518
void loadSignals(wxXmlNode *aSignals)
double y
Definition: eagle_parser.h:444
double y2
Definition: eagle_parser.h:459
void Insert(T *aNewElement, T *aElementAfterMe)
Function Insert puts aNewElement just in front of aElementAfterMe in the list sequence.
Definition: dlist.h:200
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:148
const wxString GetFileExtension() const override
Function GetFileExtension returns the file extension for the PLUGIN.
pads are covered by copper
Definition: zones.h:59
void Value(const char *aValue)
modify the last path node's value
Definition: eagle_parser.h:114
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
int layer_front_most
Definition: eagle_parser.h:430
int sign(T val)
Definition: math_util.h:44
virtual void SetText(const wxString &aText)
Definition: eda_text.h:141
double y
Definition: eagle_parser.h:551
void orientModuleText(MODULE *m, const EELEMENT &e, TEXTE_MODULE *txt, const EATTR *a)
void SetWidth(int aWidth)
int kicad(double d) const
Convert an Eagle distance to a KiCad distance.
void loadLibrary(wxXmlNode *aLib, const std::string *aLibName)
Function loadLibrary loads the Eagle "library" XML element, which can occur either under a "libraries...