KiCad PCB EDA Suite
EAGLE_PLUGIN Class Reference

Class EAGLE_PLUGIN works with Eagle 6.x XML board files and footprints to implement the Pcbnew PLUGIN API, or a portion of it. More...

#include <eagle_plugin.h>

Inheritance diagram for EAGLE_PLUGIN:
PLUGIN

Public Types

typedef int BIU
 

Public Member Functions

const wxString PluginName () const override
 Function PluginName returns a brief hard coded name for this PLUGIN. More...
 
BOARDLoad (const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=NULL) override
 Function Load loads information from some input file format that this PLUGIN implementation knows about, into either a new BOARD or an existing one. More...
 
const wxString GetFileExtension () const override
 Function GetFileExtension returns the file extension for the PLUGIN. More...
 
void FootprintEnumerate (wxArrayString &aFootprintNames, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
 Return a list of footprint names contained within the library at aLibraryPath. More...
 
MODULEFootprintLoad (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
 Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about. More...
 
bool IsFootprintLibWritable (const wxString &aLibraryPath) override
 Function IsFootprintLibWritable returns true iff the library at aLibraryPath is writable. More...
 
void FootprintLibOptions (PROPERTIES *aProperties) const override
 Function FootprintLibOptions appends supported PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 
 EAGLE_PLUGIN ()
 
 ~EAGLE_PLUGIN ()
 
virtual void Save (const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=NULL)
 Function Save will write aBoard to a storage file in a format that this PLUGIN implementation knows about, or it can be used to write a portion of aBoard to a special kind of export file. More...
 
virtual wxDateTime GetLibModificationTime (const wxString &aLibraryPath) const
 Return the footprint lib last-mod-time, if available. More...
 
virtual void PrefetchLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function PrefetchLib If possible, prefetches the specified library (e.g. More...
 
virtual void FootprintSave (const wxString &aLibraryPath, const MODULE *aFootprint, const PROPERTIES *aProperties=NULL)
 Function FootprintSave will write aModule to an existing library located at aLibraryPath. More...
 
virtual void FootprintDelete (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL)
 Function FootprintDelete deletes aFootprintName from the library at aLibraryPath. More...
 
virtual void FootprintLibCreate (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function FootprintLibCreate creates a new empty footprint library at aLibraryPath empty. More...
 
virtual bool FootprintLibDelete (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function FootprintLibDelete deletes an existing footprint library and returns true, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason. More...
 

Private Types

typedef std::vector< ELAYERELAYERS
 
typedef ELAYERS::const_iterator EITER
 

Private Member Functions

void init (const PROPERTIES *aProperties)
 initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed. More...
 
void clear_cu_map ()
 
int kicad_y (const ECOORD &y) const
 Convert an Eagle distance to a KiCad distance. More...
 
int kicad_x (const ECOORD &x) const
 
wxSize kicad_fontz (const ECOORD &d) const
 create a font size (fontz) from an eagle font size scalar More...
 
PCB_LAYER_ID kicad_layer (int aLayer) const
 Convert an Eagle layer to a KiCad layer. More...
 
const wxString & eagle_layer_name (int aLayer) const
 Get Eagle layer name by its number. More...
 
void cacheLib (const wxString &aLibraryPath)
 This PLUGIN only caches one footprint library, this determines which one. More...
 
void loadAllSections (wxXmlNode *aDocument)
 
void loadDesignRules (wxXmlNode *aDesignRules)
 
void loadLayerDefs (wxXmlNode *aLayers)
 
void loadPlain (wxXmlNode *aPlain)
 
void loadSignals (wxXmlNode *aSignals)
 
void loadLibrary (wxXmlNode *aLib, const wxString *aLibName)
 Function loadLibrary loads the Eagle "library" XML element, which can occur either under a "libraries" element (if a *.brd file) or under a "drawing" element if a *.lbr file. More...
 
void loadLibraries (wxXmlNode *aLibs)
 
void loadElements (wxXmlNode *aElements)
 
void orientModuleAndText (MODULE *m, const EELEMENT &e, const EATTR *nameAttr, const EATTR *valueAttr)
 
void orientModuleText (MODULE *m, const EELEMENT &e, TEXTE_MODULE *txt, const EATTR *a)
 
void centerBoard ()
 move the BOARD into the center of the page More...
 
wxString fmtDEG (double aAngle) const
 Function fmtDEG formats an angle in a way particular to a board file format. More...
 
MODULEmakeModule (wxXmlNode *aPackage, const wxString &aPkgName) const
 Function makeModule creates a MODULE from an Eagle package. More...
 
void packageWire (MODULE *aModule, wxXmlNode *aTree) const
 
void packagePad (MODULE *aModule, wxXmlNode *aTree) const
 
void packageText (MODULE *aModule, wxXmlNode *aTree) const
 
void packageRectangle (MODULE *aModule, wxXmlNode *aTree) const
 
void packagePolygon (MODULE *aModule, wxXmlNode *aTree) const
 
void packageCircle (MODULE *aModule, wxXmlNode *aTree) const
 
void packageHole (MODULE *aModule, wxXmlNode *aTree) const
 
void packageSMD (MODULE *aModule, wxXmlNode *aTree) const
 
void deleteTemplates ()
 

Deletes the footprint templates list

More...
 

Static Private Member Functions

static wxDateTime getModificationTime (const wxString &aPath)
 get a file's or dir's modification time. More...
 

Private Attributes

int m_cu_map [17]
 map eagle to kicad, cu layers only. More...
 
std::map< int, ELAYERm_eagleLayers
 Eagle layers data stored by the layer number. More...
 
ERULESm_rules
 Eagle design rules. More...
 
XPATHm_xpath
 keeps track of what we are working on within XML document during a Load(). More...
 
int m_hole_count
 generates unique module names from eagle "hole"s. More...
 
NET_MAP m_pads_to_nets
 net list More...
 
MODULE_MAP m_templates
 is part of a MODULE factory that operates using copy construction. More...
 
const PROPERTIESm_props
 passed via Save() or Load(), no ownership, may be NULL. More...
 
BOARDm_board
 which BOARD is being worked on, no ownership here More...
 
int m_min_trace
 smallest trace we find on Load(), in BIU. More...
 
int m_min_via
 smallest via we find on Load(), in BIU. More...
 
int m_min_via_hole
 smallest via diameter hole we find on Load(), in BIU. More...
 
wxString m_lib_path
 
wxDateTime m_mod_time
 

Detailed Description

Class EAGLE_PLUGIN works with Eagle 6.x XML board files and footprints to implement the Pcbnew PLUGIN API, or a portion of it.

Definition at line 83 of file eagle_plugin.h.

Member Typedef Documentation

typedef int EAGLE_PLUGIN::BIU

Definition at line 122 of file eagle_plugin.h.

typedef ELAYERS::const_iterator EAGLE_PLUGIN::EITER
private

Definition at line 129 of file eagle_plugin.h.

typedef std::vector<ELAYER> EAGLE_PLUGIN::ELAYERS
private

Definition at line 128 of file eagle_plugin.h.

Constructor & Destructor Documentation

EAGLE_PLUGIN::EAGLE_PLUGIN ( )

Definition at line 142 of file eagle_plugin.cpp.

References clear_cu_map(), and init().

142  :
143  m_rules( new ERULES() ),
144  m_xpath( new XPATH() ),
145  m_mod_time( wxDateTime::Now() )
146 {
147  init( NULL );
148  clear_cu_map();
149 }
void clear_cu_map()
ERULES * m_rules
Eagle design rules.
Definition: eagle_plugin.h:134
Class XPATH keeps track of what we are working on within a PTREE.
Definition: eagle_parser.h:112
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
subset of eagle.drawing.board.designrules in the XML document
Definition: eagle_plugin.h:42
wxDateTime m_mod_time
Definition: eagle_plugin.h:155
EAGLE_PLUGIN::~EAGLE_PLUGIN ( )

Definition at line 152 of file eagle_plugin.cpp.

References deleteTemplates(), m_rules, and m_xpath.

153 {
154  deleteTemplates();
155  delete m_rules;
156  delete m_xpath;
157 }
ERULES * m_rules
Eagle design rules.
Definition: eagle_plugin.h:134
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
void deleteTemplates()
Deletes the footprint templates list

Member Function Documentation

void EAGLE_PLUGIN::cacheLib ( const wxString &  aLibraryPath)
private

This PLUGIN only caches one footprint library, this determines which one.

Definition at line 2093 of file eagle_plugin.cpp.

References clear_cu_map(), deleteTemplates(), Format(), getModificationTime(), loadLayerDefs(), loadLibrary(), m_lib_path, m_mod_time, m_xpath, MapChildren(), XPATH::pop(), XPATH::push(), and THROW_IO_ERROR.

Referenced by FootprintEnumerate(), and FootprintLoad().

2094 {
2095  try
2096  {
2097  wxDateTime modtime = getModificationTime( aLibPath );
2098 
2099  // Fixes assertions in wxWidgets debug builds for the wxDateTime object. Refresh the
2100  // cache if either of the wxDateTime objects are invalid or the last file modification
2101  // time differs from the current file modification time.
2102  bool load = !m_mod_time.IsValid() || !modtime.IsValid() ||
2103  m_mod_time != modtime;
2104 
2105  if( aLibPath != m_lib_path || load )
2106  {
2107  wxXmlNode* doc;
2108  LOCALE_IO toggle; // toggles on, then off, the C locale.
2109 
2110  deleteTemplates();
2111 
2112  // Set this before completion of loading, since we rely on it for
2113  // text of an exception. Delay setting m_mod_time until after successful load
2114  // however.
2115  m_lib_path = aLibPath;
2116 
2117  // 8 bit "filename" should be encoded according to disk filename encoding,
2118  // (maybe this is current locale, maybe not, its a filesystem issue),
2119  // and is not necessarily utf8.
2120  string filename = (const char*) aLibPath.char_str( wxConvFile );
2121 
2122  // Load the document
2123  wxXmlDocument xmlDocument;
2124  wxFileName fn( filename );
2125 
2126  if( !xmlDocument.Load( fn.GetFullPath() ) )
2127  THROW_IO_ERROR( wxString::Format( _( "Unable to read file \"%s\"" ),
2128  fn.GetFullPath() ) );
2129 
2130  doc = xmlDocument.GetRoot();
2131 
2132  wxXmlNode* drawing = MapChildren( doc )["drawing"];
2133  NODE_MAP drawingChildren = MapChildren( drawing );
2134 
2135  // clear the cu map and then rebuild it.
2136  clear_cu_map();
2137 
2138  m_xpath->push( "eagle.drawing.layers" );
2139  wxXmlNode* layers = drawingChildren["layers"];
2140  loadLayerDefs( layers );
2141  m_xpath->pop();
2142 
2143  m_xpath->push( "eagle.drawing.library" );
2144  wxXmlNode* library = drawingChildren["library"];
2145  loadLibrary( library, NULL );
2146  m_xpath->pop();
2147 
2148  m_mod_time = modtime;
2149  }
2150  }
2151  catch(...){}
2152  // TODO: Handle exceptions
2153  // catch( file_parser_error fpe )
2154  // {
2155  // // for xml_parser_error, what() has the line number in it,
2156  // // but no byte offset. That should be an adequate error message.
2157  // THROW_IO_ERROR( fpe.what() );
2158  // }
2159  //
2160  // // Class ptree_error is a base class for xml_parser_error & file_parser_error,
2161  // // so one catch should be OK for all errors.
2162  // catch( ptree_error pte )
2163  // {
2164  // string errmsg = pte.what();
2165  //
2166  // errmsg += " @\n";
2167  // errmsg += m_xpath->Contents();
2168  //
2169  // THROW_IO_ERROR( errmsg );
2170  // }
2171 }
void clear_cu_map()
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
void push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:117
void loadLayerDefs(wxXmlNode *aLayers)
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Function MapChildren provides an easy access to the children of an XML node via their names...
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
wxString m_lib_path
Definition: eagle_plugin.h:154
static wxDateTime getModificationTime(const wxString &aPath)
get a file&#39;s or dir&#39;s modification time.
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
wxDateTime m_mod_time
Definition: eagle_plugin.h:155
void loadLibrary(wxXmlNode *aLib, const wxString *aLibName)
Function loadLibrary loads the Eagle "library" XML element, which can occur either under a "libraries...
void deleteTemplates()
Deletes the footprint templates list
void pop()
Definition: eagle_parser.h:124
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:48
void EAGLE_PLUGIN::centerBoard ( )
private

move the BOARD into the center of the page

Definition at line 2035 of file eagle_plugin.cpp.

References UTF8::c_str(), DBG, BOARD::GetBoardEdgesBoundingBox(), EDA_RECT::GetHeight(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), EDA_RECT::GetY(), m_board, m_props, BOARD::Move(), and PROPERTIES::Value().

Referenced by Load().

2036 {
2037  if( m_props )
2038  {
2039  UTF8 page_width;
2040  UTF8 page_height;
2041 
2042  if( m_props->Value( "page_width", &page_width ) &&
2043  m_props->Value( "page_height", &page_height ) )
2044  {
2046 
2047  int w = atoi( page_width.c_str() );
2048  int h = atoi( page_height.c_str() );
2049 
2050  int desired_x = ( w - bbbox.GetWidth() ) / 2;
2051  int desired_y = ( h - bbbox.GetHeight() ) / 2;
2052 
2053  DBG(printf( "bbox.width:%d bbox.height:%d w:%d h:%d desired_x:%d desired_y:%d\n",
2054  bbbox.GetWidth(), bbbox.GetHeight(), w, h, desired_x, desired_y );)
2055 
2056  m_board->Move( wxPoint( desired_x - bbbox.GetX(), desired_y - bbbox.GetY() ) );
2057  }
2058  }
2059 }
Class UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion supp...
Definition: utf8.h:73
BOARD * m_board
which BOARD is being worked on, no ownership here
Definition: eagle_plugin.h:148
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
int GetHeight() const
Definition: eda_rect.h:118
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:797
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
Definition: eagle_plugin.h:147
void Move(const wxPoint &aMoveVector) override
Function Move move this object.
const char * c_str() const
Definition: utf8.h:107
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
int GetX() const
Definition: eda_rect.h:109
int GetWidth() const
Definition: eda_rect.h:117
int GetY() const
Definition: eda_rect.h:110
#define DBG(x)
Definition: fctsys.h:33
void EAGLE_PLUGIN::clear_cu_map ( )
private

Definition at line 286 of file eagle_plugin.cpp.

References DIM, and m_cu_map.

Referenced by cacheLib(), and EAGLE_PLUGIN().

287 {
288  // All cu layers are invalid until we see them in the <layers> section while
289  // loading either a board or library. See loadLayerDefs().
290  for( unsigned i = 0; i < DIM(m_cu_map); ++i )
291  m_cu_map[i] = -1;
292 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
int m_cu_map[17]
map eagle to kicad, cu layers only.
Definition: eagle_plugin.h:131
void EAGLE_PLUGIN::deleteTemplates ( )
private

Deletes the footprint templates list

Definition at line 1690 of file eagle_plugin.cpp.

References m_templates.

Referenced by cacheLib(), and ~EAGLE_PLUGIN().

1691 {
1692  for( auto& t : m_templates )
1693  delete t.second;
1694 
1695  m_templates.clear();
1696 }
MODULE_MAP m_templates
is part of a MODULE factory that operates using copy construction.
Definition: eagle_plugin.h:142
const wxString & EAGLE_PLUGIN::eagle_layer_name ( int  aLayer) const
private

Get Eagle layer name by its number.

Definition at line 2027 of file eagle_plugin.cpp.

References m_eagleLayers.

Referenced by kicad_layer().

2028 {
2029  static const wxString unknown( "unknown" );
2030  auto it = m_eagleLayers.find( aLayer );
2031  return it == m_eagleLayers.end() ? unknown : it->second.name;
2032 }
std::map< int, ELAYER > m_eagleLayers
Eagle layers data stored by the layer number.
Definition: eagle_plugin.h:132
wxString EAGLE_PLUGIN::fmtDEG ( double  aAngle) const
private

Function fmtDEG formats an angle in a way particular to a board file format.

This function is the opposite or complement of degParse(). One has to know what the other is doing.

void PLUGIN::FootprintDelete ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function FootprintDelete deletes aFootprintName from the library at aLibraryPath.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aFootprintNameis the name of a footprint to delete from the specified library.
aPropertiesis an associative array that can be used to tell the library delete function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem finding the footprint or the library, or deleting it.

Reimplemented in GITHUB_PLUGIN, PCB_IO, and GPCB_PLUGIN.

Definition at line 92 of file plugin.cpp.

References not_implemented().

Referenced by FP_LIB_TABLE::FootprintDelete().

93 {
94  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
95  not_implemented( this, __FUNCTION__ );
96 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
void EAGLE_PLUGIN::FootprintEnumerate ( wxArrayString &  aFootprintNames,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Return a list of footprint names contained within the library at aLibraryPath.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aPropertiesis an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
aFootprintNamesis the array of available footprint names inside a library.
Exceptions
IO_ERRORif the library cannot be found, or footprint cannot be loaded.

Reimplemented from PLUGIN.

Definition at line 2174 of file eagle_plugin.cpp.

References cacheLib(), FROM_UTF8(), init(), and m_templates.

2176 {
2177  init( aProperties );
2178 
2179  cacheLib( aLibraryPath );
2180 
2181  for( MODULE_CITER it = m_templates.begin(); it != m_templates.end(); ++it )
2182  aFootprintNames.Add( FROM_UTF8( it->first.c_str() ) );
2183 }
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 init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void cacheLib(const wxString &aLibraryPath)
This PLUGIN only caches one footprint library, this determines which one.
MODULE_MAP::const_iterator MODULE_CITER
MODULE_MAP m_templates
is part of a MODULE factory that operates using copy construction.
Definition: eagle_plugin.h:142
void PLUGIN::FootprintLibCreate ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function FootprintLibCreate creates a new empty footprint library at aLibraryPath empty.

It is an error to attempt to create an existing library or to attempt to create on a "read only" location.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aPropertiesis an associative array that can be used to tell the library create function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem finding the library, or creating it.

Reimplemented in GITHUB_PLUGIN, and PCB_IO.

Definition at line 99 of file plugin.cpp.

References not_implemented().

Referenced by PCB_BASE_EDIT_FRAME::CreateNewLibrary(), and FP_LIB_TABLE::FootprintLibCreate().

100 {
101  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
102  not_implemented( this, __FUNCTION__ );
103 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
bool PLUGIN::FootprintLibDelete ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function FootprintLibDelete deletes an existing footprint library and returns true, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason.

Parameters
aLibraryPathis a locator for the "library", usually a directory or file which will contain footprints.
aPropertiesis an associative array that can be used to tell the library delete implementation function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
bool - true if library deleted, false if library did not exist.
Exceptions
IO_ERRORif there is a problem deleting an existing library.

Reimplemented in GITHUB_PLUGIN, PCB_IO, LEGACY_PLUGIN, and GPCB_PLUGIN.

Definition at line 106 of file plugin.cpp.

References not_implemented().

Referenced by PCB_BASE_EDIT_FRAME::CreateNewLibrary(), and FP_LIB_TABLE::FootprintLibDelete().

107 {
108  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
109  not_implemented( this, __FUNCTION__ );
110  return false;
111 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
void EAGLE_PLUGIN::FootprintLibOptions ( PROPERTIES aListToAppendTo) const
overridevirtual

Function FootprintLibOptions appends supported PLUGIN options to aListToAppenTo along with internationalized descriptions.

Options are typically appended so that a derived PLUGIN can call its base class function by the same name first, thus inheriting options declared there. (Some base class options could pertain to all Footprint*() functions in all derived PLUGINs.) Note that since aListToAppendTo is a PROPERTIES object, all options will be unique and last guy wins.

Parameters
aListToAppendToholds a tuple of
option
This eventually is what shows up into the fp-lib-table "options" field, possibly combined with others.
internationalized description
The internationalized description is displayed in DIALOG_FP_PLUGIN_OPTIONS. It may be multi-line and be quite explanatory of the option.

In the future perhaps aListToAppendTo evolves to something capable of also holding a wxValidator for the cells in said dialog: http://forums.wxwidgets.org/viewtopic.php?t=23277&p=104180. This would require a 3 column list, and introducing wx GUI knowledge to PLUGIN, which has been avoided to date.

Reimplemented from PLUGIN.

Definition at line 2203 of file eagle_plugin.cpp.

References PLUGIN::FootprintLibOptions().

2204 {
2205  PLUGIN::FootprintLibOptions( aListToAppendTo );
2206 
2207  /*
2208  (*aListToAppendTo)["ignore_duplicates"] = UTF8( _(
2209  "Ignore duplicately named footprints within the same Eagle library. "
2210  "Only the first similarly named footprint will be loaded."
2211  ));
2212  */
2213 }
virtual void FootprintLibOptions(PROPERTIES *aListToAppendTo) const
Function FootprintLibOptions appends supported PLUGIN options to aListToAppenTo along with internatio...
Definition: plugin.cpp:122
MODULE * EAGLE_PLUGIN::FootprintLoad ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aFootprintNameis the name of the footprint to load.
aPropertiesis an associative array that can be used to tell the loader implementation to do something special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
MODULE* - if found caller owns it, else NULL if not found.
Exceptions
IO_ERRORif the library cannot be found or read. No exception is thrown in the case where aFootprintName cannot be found.

Reimplemented from PLUGIN.

Definition at line 2186 of file eagle_plugin.cpp.

References cacheLib(), init(), and m_templates.

2188 {
2189  init( aProperties );
2190  cacheLib( aLibraryPath );
2191  MODULE_CITER mi = m_templates.find( aFootprintName );
2192 
2193  if( mi == m_templates.end() )
2194  return NULL;
2195 
2196  // copy constructor to clone the template
2197  MODULE* ret = new MODULE( *mi->second );
2198 
2199  return ret;
2200 }
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void cacheLib(const wxString &aLibraryPath)
This PLUGIN only caches one footprint library, this determines which one.
MODULE_MAP::const_iterator MODULE_CITER
MODULE_MAP m_templates
is part of a MODULE factory that operates using copy construction.
Definition: eagle_plugin.h:142
void PLUGIN::FootprintSave ( const wxString &  aLibraryPath,
const MODULE aFootprint,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function FootprintSave will write aModule to an existing library located at aLibraryPath.

If a footprint by the same name already exists, it is replaced.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aFootprintis what to store in the library. The caller continues to own the footprint after this call.
aPropertiesis an associative array that can be used to tell the saver how to save the footprint, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem saving.

Reimplemented in GITHUB_PLUGIN, and PCB_IO.

Definition at line 85 of file plugin.cpp.

References not_implemented().

Referenced by PCB_EDIT_FRAME::ArchiveModulesOnBoard(), WIZARD_FPLIB_TABLE::checkFiles(), FP_LIB_TABLE::FootprintSave(), FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs(), and FOOTPRINT_EDIT_FRAME::SaveCurrentModule().

86 {
87  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
88  not_implemented( this, __FUNCTION__ );
89 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
const wxString EAGLE_PLUGIN::GetFileExtension ( ) const
overridevirtual

Function GetFileExtension returns the file extension for the PLUGIN.

Implements PLUGIN.

Definition at line 166 of file eagle_plugin.cpp.

167 {
168  return wxT( "brd" );
169 }
virtual wxDateTime PLUGIN::GetLibModificationTime ( const wxString &  aLibraryPath) const
inlinevirtualinherited

Return the footprint lib last-mod-time, if available.

Reimplemented in PCB_IO.

Definition at line 359 of file io_mgr.h.

Referenced by FP_LIB_TABLE::GenLastModifiedChecksum(), and LP_CACHE::SaveEndOfFile().

360  {
361  // Default implementation.
362  return wxDateTime::Now(); // If we don't know then we must assume the worst.
363  }
wxDateTime EAGLE_PLUGIN::getModificationTime ( const wxString &  aPath)
staticprivate

get a file's or dir's modification time.

Definition at line 2062 of file eagle_plugin.cpp.

References Format(), GetChars(), and THROW_IO_ERROR.

Referenced by cacheLib().

2063 {
2064  wxFileName fn( aPath );
2065 
2066  // Do not call wxFileName::GetModificationTime() on a non-existent file, because
2067  // if it fails, wx's implementation calls the crap wxLogSysError() which
2068  // eventually infects our UI with an unwanted popup window, so don't let it fail.
2069  if( !fn.IsFileReadable() )
2070  {
2071  wxString msg = wxString::Format(
2072  _( "File \"%s\" is not readable." ),
2073  GetChars( aPath ) );
2074 
2075  THROW_IO_ERROR( msg );
2076  }
2077 
2078  /*
2079  // update the writable flag while we have a wxFileName, in a network this
2080  // is possibly quite dynamic anyway.
2081  m_writable = fn.IsFileWritable();
2082  */
2083 
2084  wxDateTime modTime = fn.GetModificationTime();
2085 
2086  if( !modTime.IsValid() )
2087  modTime.Now();
2088 
2089  return modTime;
2090 }
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 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
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
void EAGLE_PLUGIN::init ( const PROPERTIES aProperties)
private

initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.

Definition at line 268 of file eagle_plugin.cpp.

References XPATH::clear(), m_board, m_hole_count, m_min_trace, m_min_via, m_min_via_hole, m_pads_to_nets, m_props, m_rules, and m_xpath.

Referenced by EAGLE_PLUGIN(), FootprintEnumerate(), FootprintLoad(), and Load().

269 {
270  m_hole_count = 0;
271  m_min_trace = 0;
272  m_min_via = 0;
273  m_min_via_hole = 0;
274  m_xpath->clear();
275  m_pads_to_nets.clear();
276 
277  m_board = NULL;
278  m_props = aProperties;
279 
280 
281  delete m_rules;
282  m_rules = new ERULES();
283 }
BOARD * m_board
which BOARD is being worked on, no ownership here
Definition: eagle_plugin.h:148
void clear()
Definition: eagle_parser.h:122
ERULES * m_rules
Eagle design rules.
Definition: eagle_plugin.h:134
int m_min_via
smallest via we find on Load(), in BIU.
Definition: eagle_plugin.h:151
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
int m_min_via_hole
smallest via diameter hole we find on Load(), in BIU.
Definition: eagle_plugin.h:152
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
Definition: eagle_plugin.h:147
subset of eagle.drawing.board.designrules in the XML document
Definition: eagle_plugin.h:42
int m_min_trace
smallest trace we find on Load(), in BIU.
Definition: eagle_plugin.h:150
int m_hole_count
generates unique module names from eagle "hole"s.
Definition: eagle_plugin.h:138
NET_MAP m_pads_to_nets
net list
Definition: eagle_plugin.h:140
bool EAGLE_PLUGIN::IsFootprintLibWritable ( const wxString &  aLibraryPath)
inlineoverridevirtual

Function IsFootprintLibWritable returns true iff the library at aLibraryPath is writable.

(Often system libraries are read only because of where they are installed.)

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
Exceptions
IO_ERRORif no library at aLibraryPath exists.

Reimplemented from PLUGIN.

Definition at line 101 of file eagle_plugin.h.

102  {
103  return false; // until someone writes others like FootprintSave(), etc.
104  }
wxSize EAGLE_PLUGIN::kicad_fontz ( const ECOORD d) const
inlineprivate

create a font size (fontz) from an eagle font size scalar

Definition at line 172 of file eagle_plugin.cpp.

References ECOORD::ToPcbUnits().

Referenced by loadPlain(), orientModuleText(), and packageText().

173 {
174  // texts seem to better match eagle when scaled down by 0.95
175  int kz = d.ToPcbUnits() * 95 / 100;
176  return wxSize( kz, kz );
177 }
int ToPcbUnits() const
Definition: eagle_parser.h:428
PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer ( int  aLayer) const
private

Convert an Eagle layer to a KiCad layer.

Definition at line 1959 of file eagle_plugin.cpp.

References B_Adhes, B_Fab, B_Mask, B_Paste, B_SilkS, EAGLE_LAYER::BCREAM, EAGLE_LAYER::BDOCU, EAGLE_LAYER::BFINISH, EAGLE_LAYER::BGLUE, EAGLE_LAYER::BKEEPOUT, EAGLE_LAYER::BNAMES, EAGLE_LAYER::BPLACE, EAGLE_LAYER::BSTOP, EAGLE_LAYER::BTEST, EAGLE_LAYER::BVALUES, Cmts_User, DIM, EAGLE_LAYER::DIMENSION, EAGLE_LAYER::DOCUMENT, Dwgs_User, eagle_layer_name(), Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_Fab, F_Mask, F_Paste, F_SilkS, Format(), EAGLE_LAYER::HOLES, m_cu_map, EAGLE_LAYER::MILLING, EAGLE_LAYER::REFERENCELC, EAGLE_LAYER::REFERENCELS, EAGLE_LAYER::TCREAM, EAGLE_LAYER::TDOCU, EAGLE_LAYER::TFINISH, EAGLE_LAYER::TGLUE, EAGLE_LAYER::TKEEPOUT, EAGLE_LAYER::TNAMES, EAGLE_LAYER::TPLACE, EAGLE_LAYER::TSTOP, EAGLE_LAYER::TTEST, EAGLE_LAYER::TVALUES, EAGLE_LAYER::UNROUTED, EAGLE_LAYER::USERLAYER1, and EAGLE_LAYER::USERLAYER2.

Referenced by loadLayerDefs(), loadPlain(), loadSignals(), packageCircle(), packagePolygon(), packageRectangle(), packageSMD(), packageText(), and packageWire().

1960 {
1961  int kiLayer;
1962 
1963  // eagle copper layer:
1964  if( aEagleLayer >= 1 && aEagleLayer < int( DIM( m_cu_map ) ) )
1965  {
1966  kiLayer = m_cu_map[aEagleLayer];
1967  }
1968 
1969  else
1970  {
1971  // translate non-copper eagle layer to pcbnew layer
1972  switch( aEagleLayer )
1973  {
1974  // Eagle says "Dimension" layer, but it's for board perimeter
1975  case EAGLE_LAYER::DIMENSION: kiLayer = Edge_Cuts; break;
1976  case EAGLE_LAYER::TPLACE: kiLayer = F_SilkS; break;
1977  case EAGLE_LAYER::BPLACE: kiLayer = B_SilkS; break;
1978  case EAGLE_LAYER::TNAMES: kiLayer = F_SilkS; break;
1979  case EAGLE_LAYER::BNAMES: kiLayer = B_SilkS; break;
1980  case EAGLE_LAYER::TVALUES: kiLayer = F_SilkS; break;
1981  case EAGLE_LAYER::BVALUES: kiLayer = B_SilkS; break;
1982  case EAGLE_LAYER::TSTOP: kiLayer = F_Mask; break;
1983  case EAGLE_LAYER::BSTOP: kiLayer = B_Mask; break;
1984  case EAGLE_LAYER::TCREAM: kiLayer = F_Paste; break;
1985  case EAGLE_LAYER::BCREAM: kiLayer = B_Paste; break;
1986  case EAGLE_LAYER::TFINISH: kiLayer = F_Mask; break;
1987  case EAGLE_LAYER::BFINISH: kiLayer = B_Mask; break;
1988  case EAGLE_LAYER::TGLUE: kiLayer = F_Adhes; break;
1989  case EAGLE_LAYER::BGLUE: kiLayer = B_Adhes; break;
1990  case EAGLE_LAYER::DOCUMENT: kiLayer = Cmts_User; break;
1991  case EAGLE_LAYER::REFERENCELC: kiLayer = Cmts_User; break;
1992  case EAGLE_LAYER::REFERENCELS: kiLayer = Cmts_User; break;
1993 
1994  // Packages show the future chip pins on SMD parts using layer 51.
1995  // This is an area slightly smaller than the PAD/SMD copper area.
1996  // Carry those visual aids into the MODULE on the fabrication layer,
1997  // not silkscreen. This is perhaps not perfect, but there is not a lot
1998  // of other suitable paired layers
1999  case EAGLE_LAYER::TDOCU: kiLayer = F_Fab; break;
2000  case EAGLE_LAYER::BDOCU: kiLayer = B_Fab; break;
2001 
2002  // thes layers are defined as user layers. put them on ECO layers
2003  case EAGLE_LAYER::USERLAYER1: kiLayer = Eco1_User; break;
2004  case EAGLE_LAYER::USERLAYER2: kiLayer = Eco2_User; break;
2005 
2006  case EAGLE_LAYER::UNROUTED:
2007  case EAGLE_LAYER::TKEEPOUT:
2008  case EAGLE_LAYER::BKEEPOUT:
2009  case EAGLE_LAYER::TTEST:
2010  case EAGLE_LAYER::BTEST:
2011  case EAGLE_LAYER::MILLING:
2012  case EAGLE_LAYER::HOLES:
2013  default:
2014  // some layers do not map to KiCad
2015  wxLogMessage( wxString::Format( "Unsupported Eagle layer '%s' (%d), converted to Dwgs.User layer",
2016  eagle_layer_name( aEagleLayer ), aEagleLayer ) );
2017 
2018  kiLayer = Dwgs_User;
2019  break;
2020  }
2021  }
2022 
2023  return PCB_LAYER_ID( kiLayer );
2024 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
int m_cu_map[17]
map eagle to kicad, cu layers only.
Definition: eagle_plugin.h:131
const wxString & eagle_layer_name(int aLayer) const
Get Eagle layer name by its number.
PCB_LAYER_ID
A quick note on layer IDs:
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
int EAGLE_PLUGIN::kicad_x ( const ECOORD x) const
inlineprivate
int EAGLE_PLUGIN::kicad_y ( const ECOORD y) const
inlineprivate

Convert an Eagle distance to a KiCad distance.

Definition at line 163 of file eagle_plugin.h.

References ECOORD::ToPcbUnits().

Referenced by loadElements(), loadPlain(), loadSignals(), orientModuleText(), packageCircle(), packageHole(), packagePad(), packagePolygon(), packageRectangle(), packageSMD(), packageText(), and packageWire().

163 { return -y.ToPcbUnits(); }
int ToPcbUnits() const
Definition: eagle_parser.h:428
BOARD * EAGLE_PLUGIN::Load ( const wxString &  aFileName,
BOARD aAppendToMe,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function Load loads information from some input file format that this PLUGIN implementation knows about, into either a new BOARD or an existing one.

This may be used to load an entire new BOARD, or to augment an existing one if aAppendToMe is not NULL.

Parameters
aFileNameis the name of the file to use as input and may be foreign in nature or native in nature.
aAppendToMeis an existing BOARD to append to, but if NULL then this means "do not append, rather load anew".
aPropertiesis an associative array that can be used to tell the loader how to load the file, because it can take any number of additional named arguments that the plugin is known to support. These are tuning parameters for the import or load. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
BOARD* - the successfully loaded board, or the same one as aAppendToMe if aAppendToMe was not NULL, and caller owns it.
Exceptions
IO_ERRORif there is a problem loading, and its contents should say what went wrong, using line number and character offsets of the input file if possible.

Reimplemented from PLUGIN.

Definition at line 180 of file eagle_plugin.cpp.

References centerBoard(), XPATH::Contents(), Format(), BOARD_DESIGN_SETTINGS::GetDefault(), init(), KiROUND(), loadAllSections(), m_board, m_min_trace, m_min_via, m_min_via_hole, m_rules, BOARD_DESIGN_SETTINGS::m_TrackMinWidth, BOARD_DESIGN_SETTINGS::m_ViasMinDrill, BOARD_DESIGN_SETTINGS::m_ViasMinSize, m_xpath, ERULES::mdWireWire, BOARD::SetFileName(), and THROW_IO_ERROR.

181 {
182  LOCALE_IO toggle; // toggles on, then off, the C locale.
183  wxXmlNode* doc;
184 
185  init( aProperties );
186 
187  m_board = aAppendToMe ? aAppendToMe : new BOARD();
188 
189  // Give the filename to the board if it's new
190  if( !aAppendToMe )
191  m_board->SetFileName( aFileName );
192 
193  // delete on exception, if I own m_board, according to aAppendToMe
194  unique_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
195 
196  try
197  {
198  // Load the document
199  wxXmlDocument xmlDocument;
200  wxFileName fn = aFileName;
201 
202  if( !xmlDocument.Load( fn.GetFullPath() ) )
203  THROW_IO_ERROR( wxString::Format( _( "Unable to read file \"%s\"" ),
204  fn.GetFullPath() ) );
205 
206  doc = xmlDocument.GetRoot();
207 
208  m_min_trace = INT_MAX;
209  m_min_via = INT_MAX;
210  m_min_via_hole = INT_MAX;
211 
212  loadAllSections( doc );
213 
214  BOARD_DESIGN_SETTINGS& designSettings = m_board->GetDesignSettings();
215 
216  if( m_min_trace < designSettings.m_TrackMinWidth )
217  designSettings.m_TrackMinWidth = m_min_trace;
218 
219  if( m_min_via < designSettings.m_ViasMinSize )
220  designSettings.m_ViasMinSize = m_min_via;
221 
222  if( m_min_via_hole < designSettings.m_ViasMinDrill )
223  designSettings.m_ViasMinDrill = m_min_via_hole;
224 
225  if( m_rules->mdWireWire )
226  {
227  NETCLASSPTR defaultNetclass = designSettings.GetDefault();
228  int clearance = KiROUND( m_rules->mdWireWire );
229 
230  if( clearance < defaultNetclass->GetClearance() )
231  defaultNetclass->SetClearance( clearance );
232  }
233 
234  // should be empty, else missing m_xpath->pop()
235  wxASSERT( m_xpath->Contents().size() == 0 );
236  }
237  // Catch all exceptions thrown from the parser.
238  catch( const XML_PARSER_ERROR &exc )
239  {
240  wxString errmsg = exc.what();
241 
242  errmsg += "\n@ ";
243  errmsg += m_xpath->Contents();
244 
245  THROW_IO_ERROR( errmsg );
246  }
247 
248  // IO_ERROR exceptions are left uncaught, they pass upwards from here.
249 
250  // Ensure the copper layers count is a multiple of 2
251  // Pcbnew does not like boards with odd layers count
252  // (these boards cannot exist. they actually have a even layers count)
253  int lyrcnt = m_board->GetCopperLayerCount();
254 
255  if( (lyrcnt % 2) != 0 )
256  {
257  lyrcnt++;
258  m_board->SetCopperLayerCount( lyrcnt );
259  }
260 
261  centerBoard();
262 
263  deleter.release();
264  return m_board;
265 }
wxString Contents()
return the contents of the XPATH as a single string
Definition: eagle_parser.h:139
void loadAllSections(wxXmlNode *aDocument)
NETCLASSPTR GetDefault() const
Function GetDefault.
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:148
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
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
ERULES * m_rules
Eagle design rules.
Definition: eagle_plugin.h:134
int GetCopperLayerCount() const
Function GetCopperLayerCount.
void SetCopperLayerCount(int aCount)
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
int m_min_via
smallest via we find on Load(), in BIU.
Definition: eagle_plugin.h:151
Class XML_PARSER_ERROR implements a simple wrapper around runtime_error to isolate the errors thrown ...
Definition: eagle_parser.h:70
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
int m_min_via_hole
smallest via diameter hole we find on Load(), in BIU.
Definition: eagle_plugin.h:152
int m_TrackMinWidth
track min value for width ((min copper size value
int m_ViasMinSize
vias (not micro vias) min diameter
int m_ViasMinDrill
vias (not micro vias) min drill diameter
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
void SetFileName(const wxString &aFileName)
Definition: class_board.h:232
double mdWireWire
wire to wire spacing I presume.
Definition: eagle_plugin.h:58
int m_min_trace
smallest trace we find on Load(), in BIU.
Definition: eagle_plugin.h:150
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
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
void EAGLE_PLUGIN::loadAllSections ( wxXmlNode *  aDocument)
private

Definition at line 295 of file eagle_plugin.cpp.

References loadDesignRules(), loadElements(), loadLayerDefs(), loadLibraries(), loadPlain(), loadSignals(), m_xpath, MapChildren(), XPATH::pop(), and XPATH::push().

Referenced by Load().

296 {
297  wxXmlNode* drawing = MapChildren( aDoc )["drawing"];
298  NODE_MAP drawingChildren = MapChildren( drawing );
299 
300  wxXmlNode* board = drawingChildren["board"];
301  NODE_MAP boardChildren = MapChildren( board );
302 
303  m_xpath->push( "eagle.drawing" );
304 
305  {
306  m_xpath->push( "board" );
307 
308  wxXmlNode* designrules = boardChildren["designrules"];
309  loadDesignRules( designrules );
310 
311  m_xpath->pop();
312  }
313 
314  {
315  m_xpath->push( "layers" );
316 
317  wxXmlNode* layers = drawingChildren["layers"];
318  loadLayerDefs( layers );
319 
320  m_xpath->pop();
321  }
322 
323  {
324  m_xpath->push( "board" );
325 
326  wxXmlNode* plain = boardChildren["plain"];
327  loadPlain( plain );
328 
329  wxXmlNode* signals = boardChildren["signals"];
330  loadSignals( signals );
331 
332  wxXmlNode* libs = boardChildren["libraries"];
333  loadLibraries( libs );
334 
335  wxXmlNode* elems = boardChildren["elements"];
336  loadElements( elems );
337 
338  m_xpath->pop(); // "board"
339  }
340 
341  m_xpath->pop(); // "eagle.drawing"
342 }
void push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:117
void loadLayerDefs(wxXmlNode *aLayers)
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Function MapChildren provides an easy access to the children of an XML node via their names...
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
void loadLibraries(wxXmlNode *aLibs)
void loadPlain(wxXmlNode *aPlain)
void loadElements(wxXmlNode *aElements)
void pop()
Definition: eagle_parser.h:124
void loadDesignRules(wxXmlNode *aDesignRules)
void loadSignals(wxXmlNode *aSignals)
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:48
void EAGLE_PLUGIN::loadDesignRules ( wxXmlNode *  aDesignRules)
private

Definition at line 345 of file eagle_plugin.cpp.

References m_rules, m_xpath, ERULES::parse(), XPATH::pop(), and XPATH::push().

Referenced by loadAllSections().

346 {
347  m_xpath->push( "designrules" );
348  m_rules->parse( aDesignRules );
349  m_xpath->pop(); // "designrules"
350 }
ERULES * m_rules
Eagle design rules.
Definition: eagle_plugin.h:134
void push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:117
void parse(wxXmlNode *aRules)
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
void pop()
Definition: eagle_parser.h:124
void EAGLE_PLUGIN::loadElements ( wxXmlNode *  aElements)
private

Definition at line 824 of file eagle_plugin.cpp.

References BOARD::Add(), ADD_APPEND, EATTR::BOTH, EATTR::display, Format(), FROM_UTF8(), GetChars(), MODULE::GetReference(), MODULE::GetValue(), kicad_x(), kicad_y(), EELEMENT::library, m_board, m_pads_to_nets, m_templates, m_xpath, makeKey(), name, EATTR::name, EATTR::NAME, EELEMENT::name, ENET::netcode, D_PAD::Next(), EATTR::Off, orientModuleAndText(), EELEMENT::package, MODULE::PadsList(), XPATH::pop(), XPATH::push(), MODULE::Reference(), MODULE::SetPosition(), MODULE::SetReference(), MODULE::SetValue(), EDA_TEXT::SetVisible(), EELEMENT::smashed, THROW_IO_ERROR, XPATH::Value(), MODULE::Value(), EATTR::value, EATTR::VALUE, EELEMENT::value, EELEMENT::x, and EELEMENT::y.

Referenced by loadAllSections().

825 {
826  m_xpath->push( "elements.element", "name" );
827 
828  EATTR name;
829  EATTR value;
830  bool refanceNamePresetInPackageLayout;
831  bool valueNamePresetInPackageLayout;
832 
833  // Get the first element and iterate
834  wxXmlNode* element = aElements->GetChildren();
835 
836  while( element )
837  {
838  if( element->GetName() != "element" )
839  {
840  wxLogMessage( "expected: <element> read <%s>. Skip it", element->GetName() );
841  // Get next item
842  element = element->GetNext();
843  continue;
844  }
845 
846  EELEMENT e( element );
847 
848  // use "NULL-ness" as an indication of presence of the attribute:
849  EATTR* nameAttr = 0;
850  EATTR* valueAttr = 0;
851 
852  m_xpath->Value( e.name.c_str() );
853 
854  wxString pkg_key = makeKey( e.library, e.package );
855 
856  MODULE_CITER mi = m_templates.find( pkg_key );
857 
858  if( mi == m_templates.end() )
859  {
860  wxString emsg = wxString::Format( _( "No \"%s\" package in library \"%s\"" ),
861  GetChars( FROM_UTF8( e.package.c_str() ) ),
862  GetChars( FROM_UTF8( e.library.c_str() ) ) );
863  THROW_IO_ERROR( emsg );
864  }
865 
866  // copy constructor to clone the template
867  MODULE* m = new MODULE( *mi->second );
868  m_board->Add( m, ADD_APPEND );
869 
870  // update the nets within the pads of the clone
871  for( D_PAD* pad = m->PadsList(); pad; pad = pad->Next() )
872  {
873  wxString pn_key = makeKey( e.name, pad->GetName() );
874 
875  NET_MAP_CITER ni = m_pads_to_nets.find( pn_key );
876  if( ni != m_pads_to_nets.end() )
877  {
878  const ENET* enet = &ni->second;
879  pad->SetNetCode( enet->netcode );
880  }
881  }
882 
883  refanceNamePresetInPackageLayout = true;
884  valueNamePresetInPackageLayout = true;
885  m->SetPosition( wxPoint( kicad_x( e.x ), kicad_y( e.y ) ) );
886 
887  // Is >NAME field set in package layout ?
888  if( m->GetReference().size() == 0 )
889  {
890  m->Reference().SetVisible( false ); // No so no show
891  refanceNamePresetInPackageLayout = false;
892  }
893 
894  // Is >VALUE field set in package layout
895  if( m->GetValue().size() == 0 )
896  {
897  m->Value().SetVisible( false ); // No so no show
898  valueNamePresetInPackageLayout = false;
899  }
900 
901  m->SetReference( FROM_UTF8( e.name.c_str() ) );
902  m->SetValue( FROM_UTF8( e.value.c_str() ) );
903 
904  if( !e.smashed )
905  { // Not smashed so show NAME & VALUE
906  if( valueNamePresetInPackageLayout )
907  m->Value().SetVisible( true ); // Only if place holder in package layout
908 
909  if( refanceNamePresetInPackageLayout )
910  m->Reference().SetVisible( true ); // Only if place holder in package layout
911  }
912  else if( *e.smashed == true )
913  { // Smasted so set default to no show for NAME and VALUE
914  m->Value().SetVisible( false );
915  m->Reference().SetVisible( false );
916 
917  // initalize these to default values incase the <attribute> elements are not present.
918  m_xpath->push( "attribute", "name" );
919 
920  // VALUE and NAME can have something like our text "effects" overrides
921  // in SWEET and new schematic. Eagle calls these XML elements "attribute".
922  // There can be one for NAME and/or VALUE both. Features present in the
923  // EATTR override the ones established in the package only if they are
924  // present here (except for rot, which if not present means angle zero).
925  // So the logic is a bit different than in packageText() and in plain text.
926 
927  // Get the first attribute and iterate
928  wxXmlNode* attribute = element->GetChildren();
929 
930  while( attribute )
931  {
932  if( attribute->GetName() != "attribute" )
933  {
934  wxLogMessage( "expected: <attribute> read <%s>. Skip it", attribute->GetName() );
935  attribute = attribute->GetNext();
936  continue;
937  }
938 
939  EATTR a( attribute );
940 
941  if( a.name == "NAME" )
942  {
943  name = a;
944  nameAttr = &name;
945 
946  // do we have a display attribute ?
947  if( a.display )
948  {
949  // Yes!
950  switch( *a.display )
951  {
952  case EATTR::VALUE :
953  nameAttr->name = e.name;
954  m->SetReference( e.name );
955  if( refanceNamePresetInPackageLayout )
956  m->Reference().SetVisible( true );
957  break;
958 
959  case EATTR::NAME :
960  if( refanceNamePresetInPackageLayout )
961  {
962  m->SetReference( "NAME" );
963  m->Reference().SetVisible( true );
964  }
965  break;
966 
967  case EATTR::BOTH :
968  if( refanceNamePresetInPackageLayout )
969  m->Reference().SetVisible( true );
970  nameAttr->name = nameAttr->name + " = " + e.name;
971  m->SetReference( "NAME = " + e.name );
972  break;
973 
974  case EATTR::Off :
975  m->Reference().SetVisible( false );
976  break;
977 
978  default:
979  nameAttr->name = e.name;
980  if( refanceNamePresetInPackageLayout )
981  m->Reference().SetVisible( true );
982  }
983  }
984  else
985  // No display, so default is visable, and show value of NAME
986  m->Reference().SetVisible( true );
987  }
988  else if( a.name == "VALUE" )
989  {
990  value = a;
991  valueAttr = &value;
992 
993  if( a.display )
994  {
995  // Yes!
996  switch( *a.display )
997  {
998  case EATTR::VALUE :
999  valueAttr->value = opt_wxString( e.value );
1000  m->SetValue( e.value );
1001  if( valueNamePresetInPackageLayout )
1002  m->Value().SetVisible( true );
1003  break;
1004 
1005  case EATTR::NAME :
1006  if( valueNamePresetInPackageLayout )
1007  m->Value().SetVisible( true );
1008  m->SetValue( "VALUE" );
1009  break;
1010 
1011  case EATTR::BOTH :
1012  if( valueNamePresetInPackageLayout )
1013  m->Value().SetVisible( true );
1014  valueAttr->value = opt_wxString( "VALUE = " + e.value );
1015  m->SetValue( "VALUE = " + e.value );
1016  break;
1017 
1018  case EATTR::Off :
1019  m->Value().SetVisible( false );
1020  break;
1021 
1022  default:
1023  valueAttr->value = opt_wxString( e.value );
1024  if( valueNamePresetInPackageLayout )
1025  m->Value().SetVisible( true );
1026  }
1027  }
1028  else
1029  // No display, so default is visible, and show value of NAME
1030  m->Value().SetVisible( true );
1031 
1032  }
1033 
1034  attribute = attribute->GetNext();
1035  }
1036 
1037  m_xpath->pop(); // "attribute"
1038  }
1039 
1040  orientModuleAndText( m, e, nameAttr, valueAttr );
1041 
1042  // Get next element
1043  element = element->GetNext();
1044  }
1045 
1046  m_xpath->pop(); // "elements.element"
1047 }
TEXTE_MODULE & Reference()
Definition: class_module.h:483
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
BOARD * m_board
which BOARD is being worked on, no ownership here
Definition: eagle_plugin.h:148
void push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:117
Eagle element element.
Definition: eagle_parser.h:792
void SetVisible(bool aVisible)
Definition: eda_text.h:173
const wxString & GetValue() const
Function GetValue.
Definition: class_module.h:467
NET_MAP::const_iterator NET_MAP_CITER
Definition: eagle_plugin.h:38
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
OPTIONAL_XML_ATTRIBUTE< wxString > opt_wxString
Definition: eagle_parser.h:378
wxString name
Definition: eagle_parser.h:602
static wxString makeKey(const wxString &aFirst, const wxString &aSecond)
Assemble a two part key as a simple concatenation of aFirst and aSecond parts, using a separator...
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:482
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
D_PAD * Next() const
Definition: class_pad.h:160
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
void SetReference(const wxString &aReference)
Function SetReference.
Definition: class_module.h:449
void SetPosition(const wxPoint &aPos) override
opt_wxString value
Definition: eagle_parser.h:603
Eagle net.
Definition: eagle_parser.h:459
void orientModuleAndText(MODULE *m, const EELEMENT &e, const EATTR *nameAttr, const EATTR *valueAttr)
Class EATTR parses an Eagle "attribute" XML element.
Definition: eagle_parser.h:600
MODULE_MAP::const_iterator MODULE_CITER
int netcode
Definition: eagle_parser.h:461
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
const char * name
Definition: DXF_plotter.cpp:61
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
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:439
MODULE_MAP m_templates
is part of a MODULE factory that operates using copy construction.
Definition: eagle_plugin.h:142
void SetValue(const wxString &aValue)
Function SetValue.
Definition: class_module.h:476
NET_MAP m_pads_to_nets
net list
Definition: eagle_plugin.h:140
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
void pop()
Definition: eagle_parser.h:124
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
void Value(const char *aValue)
modify the last path node&#39;s value
Definition: eagle_parser.h:127
void EAGLE_PLUGIN::loadLayerDefs ( wxXmlNode *  aLayers)
private

Definition at line 353 of file eagle_plugin.cpp.

References ELAYER::active, B_Cu, cu, DIM, F_Cu, FROM_UTF8(), kicad_layer(), LT_SIGNAL, m_board, m_cu_map, m_eagleLayers, ELAYER::number, BOARD::SetCopperLayerCount(), BOARD::SetLayerName(), and BOARD::SetLayerType().

Referenced by cacheLib(), and loadAllSections().

354 {
355  ELAYERS cu; // copper layers
356 
357  // Get the first layer and iterate
358  wxXmlNode* layerNode = aLayers->GetChildren();
359 
360  m_eagleLayers.clear();
361 
362  while( layerNode )
363  {
364  ELAYER elayer( layerNode );
365  m_eagleLayers.insert( std::make_pair( elayer.number, elayer ) );
366 
367  // find the subset of layers that are copper and active
368  if( elayer.number >= 1 && elayer.number <= 16 && ( !elayer.active || *elayer.active ) )
369  {
370  cu.push_back( elayer );
371  }
372 
373  layerNode = layerNode->GetNext();
374  }
375 
376  // establish cu layer map:
377  int ki_layer_count = 0;
378 
379  for( EITER it = cu.begin(); it != cu.end(); ++it, ++ki_layer_count )
380  {
381  if( ki_layer_count == 0 )
382  m_cu_map[it->number] = F_Cu;
383  else if( ki_layer_count == int( cu.size()-1 ) )
384  m_cu_map[it->number] = B_Cu;
385  else
386  {
387  // some eagle boards do not have contiguous layer number sequences.
388 
389 #if 0 // pre PCB_LAYER_ID & LSET:
390  m_cu_map[it->number] = cu.size() - 1 - ki_layer_count;
391 #else
392  m_cu_map[it->number] = ki_layer_count;
393 #endif
394  }
395  }
396 
397 #if 0 && defined(DEBUG)
398  printf( "m_cu_map:\n" );
399  for( unsigned i=0; i<DIM(m_cu_map); ++i )
400  {
401  printf( "\t[%d]:%d\n", i, m_cu_map[i] );
402  }
403 #endif
404 
405  // Set the layer names and cu count iff we're loading a board.
406  if( m_board )
407  {
408  m_board->SetCopperLayerCount( cu.size() );
409 
410  for( EITER it = cu.begin(); it != cu.end(); ++it )
411  {
412  PCB_LAYER_ID layer = kicad_layer( it->number );
413 
414  // these function provide their own protection against UNDEFINED_LAYER:
415  m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) );
416  m_board->SetLayerType( layer, LT_SIGNAL );
417 
418  // could map the colors here
419  }
420  }
421 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
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
BOARD * m_board
which BOARD is being worked on, no ownership here
Definition: eagle_plugin.h:148
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
void SetCopperLayerCount(int aCount)
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Function SetLayerType changes the type of the layer given by aLayer.
#define cu(a)
Definition: auxiliary.h:88
int m_cu_map[17]
map eagle to kicad, cu layers only.
Definition: eagle_plugin.h:131
PCB_LAYER_ID
A quick note on layer IDs:
std::map< int, ELAYER > m_eagleLayers
Eagle layers data stored by the layer number.
Definition: eagle_plugin.h:132
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Function SetLayerName changes the name of the layer given by aLayer.
std::vector< ELAYER > ELAYERS
Definition: eagle_plugin.h:128
ELAYERS::const_iterator EITER
Definition: eagle_plugin.h:129
void EAGLE_PLUGIN::loadLibraries ( wxXmlNode *  aLibs)
private

Definition at line 804 of file eagle_plugin.cpp.

References loadLibrary(), m_xpath, XPATH::pop(), XPATH::push(), and XPATH::Value().

Referenced by loadAllSections().

805 {
806  m_xpath->push( "libraries.library", "name" );
807 
808  // Get the first library and iterate
809  wxXmlNode* library = aLibs->GetChildren();
810 
811  while( library )
812  {
813  const wxString& lib_name = library->GetAttribute( "name" );
814 
815  m_xpath->Value( lib_name.c_str() );
816  loadLibrary( library, &lib_name );
817  library = library->GetNext();
818  }
819 
820  m_xpath->pop();
821 }
void push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:117
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
void loadLibrary(wxXmlNode *aLib, const wxString *aLibName)
Function loadLibrary loads the Eagle "library" XML element, which can occur either under a "libraries...
void pop()
Definition: eagle_parser.h:124
void Value(const char *aValue)
modify the last path node&#39;s value
Definition: eagle_parser.h:127
void EAGLE_PLUGIN::loadLibrary ( wxXmlNode *  aLib,
const wxString *  aLibName 
)
private

Function loadLibrary loads the Eagle "library" XML element, which can occur either under a "libraries" element (if a *.brd file) or under a "drawing" element if a *.lbr file.

Parameters
aLibis the portion of the loaded XML document tree that is the "library" element.
aLibNameis a pointer to the library name or NULL. If NULL this means we are loading a *.lbr not a *.brd file and the key used in m_templates is to exclude the library name.

Definition at line 748 of file eagle_plugin.cpp.

References Format(), FROM_UTF8(), GetChars(), m_lib_path, m_templates, m_xpath, makeKey(), makeModule(), MapChildren(), XPATH::pop(), XPATH::push(), ReplaceIllegalFileNameChars(), THROW_IO_ERROR, and XPATH::Value().

Referenced by cacheLib(), and loadLibraries().

749 {
750  m_xpath->push( "packages" );
751 
752  // library will have <xmlattr> node, skip that and get the single packages node
753  wxXmlNode* packages = MapChildren( aLib )["packages"];
754 
755 
756  // Create a MODULE for all the eagle packages, for use later via a copy constructor
757  // to instantiate needed MODULES in our BOARD. Save the MODULE templates in
758  // a MODULE_MAP using a single lookup key consisting of libname+pkgname.
759 
760  // Get the first package and iterate
761  wxXmlNode* package = packages->GetChildren();
762 
763  while( package )
764  {
765  m_xpath->push( "package", "name" );
766 
767  const wxString& pack_ref = package->GetAttribute( "name" );
768  std::string pack_name( pack_ref );
769  ReplaceIllegalFileNameChars( &pack_name, '_' );
770 
771  m_xpath->Value( pack_name.c_str() );
772 
773  wxString key = aLibName ? makeKey( *aLibName, pack_name ) : wxString( pack_name );
774 
775  MODULE* m = makeModule( package, pack_name );
776 
777  // add the templating MODULE to the MODULE template factory "m_templates"
778  std::pair<MODULE_ITER, bool> r = m_templates.insert( {key, m} );
779 
780  if( !r.second
781  // && !( m_props && m_props->Value( "ignore_duplicates" ) )
782  )
783  {
784  wxString lib = aLibName ? FROM_UTF8( aLibName->c_str() ) : m_lib_path;
785  wxString pkg = FROM_UTF8( pack_name.c_str() );
786 
787  wxString emsg = wxString::Format(
788  _( "<package> name: \"%s\" duplicated in eagle <library>: \"%s\"" ),
789  GetChars( pkg ),
790  GetChars( lib )
791  );
792  THROW_IO_ERROR( emsg );
793  }
794 
795  m_xpath->pop();
796 
797  package = package->GetNext();
798  }
799 
800  m_xpath->pop(); // "packages"
801 }
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 push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:117
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Function ReplaceIllegalFileNameChars checks aName for illegal file name characters.
Definition: string.cpp:483
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Function MapChildren provides an easy access to the children of an XML node via their names...
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
static wxString makeKey(const wxString &aFirst, const wxString &aSecond)
Assemble a two part key as a simple concatenation of aFirst and aSecond parts, using a separator...
wxString m_lib_path
Definition: eagle_plugin.h:154
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 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
MODULE_MAP m_templates
is part of a MODULE factory that operates using copy construction.
Definition: eagle_plugin.h:142
void pop()
Definition: eagle_parser.h:124
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
MODULE * makeModule(wxXmlNode *aPackage, const wxString &aPkgName) const
Function makeModule creates a MODULE from an Eagle package.
void Value(const char *aValue)
modify the last path node&#39;s value
Definition: eagle_parser.h:127
void EAGLE_PLUGIN::loadPlain ( wxXmlNode *  aPlain)
private

Definition at line 424 of file eagle_plugin.cpp.

References abs, BOARD::Add(), ADD_APPEND, DIMENSION::AdjustDimensionDetails(), ETEXT::align, LSET::AllCuMask(), ZONE_CONTAINER::AppendCorner(), ETEXT::BOTTOM_CENTER, ETEXT::BOTTOM_LEFT, ETEXT::BOTTOM_RIGHT, ETEXT::CENTER, ETEXT::CENTER_LEFT, ETEXT::CENTER_RIGHT, Clamp_Text_PenSize(), ConvertArcCenter(), EWIRE::curve, DEFAULT_PCB_EDGE_THICKNESS, EROT::degrees, ZONE_CONTAINER::DIAGONAL_EDGE, EDIMENSION::dimensionType, EHOLE::drill, EagleTimeStamp(), FROM_UTF8(), ZONE_CONTAINER::GetDefaultHatchPitch(), BOARD::GetDesignSettings(), EDA_TEXT::GetTextSize(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, IsCopperLayer(), kicad_fontz(), kicad_layer(), kicad_x(), kicad_y(), EWIRE::layer, ECIRCLE::layer, ERECT::layer, EDIMENSION::layer, ETEXT::layer, m_board, m_hole_count, BOARD_DESIGN_SETTINGS::m_PcbTextSize, BOARD_DESIGN_SETTINGS::m_PcbTextWidth, m_xpath, EROT::mirror, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_SHAPE_CIRCLE, MODULE::PadsList(), XPATH::pop(), XPATH::push(), DLIST< T >::PushBack(), ECIRCLE::radius, ETEXT::ratio, MODULE::Reference(), ETEXT::rot, S_ARC, S_CIRCLE, DRAWSEGMENT::SetAngle(), D_PAD::SetAttribute(), D_PAD::SetDrillSize(), DRAWSEGMENT::SetEnd(), DIMENSION::SetEnd(), ZONE_CONTAINER::SetHatch(), DIMENSION::SetHeight(), EDA_TEXT::SetHorizJustify(), DIMENSION::SetLayer(), BOARD_ITEM::SetLayer(), ZONE_CONTAINER::SetLayer(), D_PAD::SetLayerSet(), EDA_TEXT::SetMirrored(), BOARD_CONNECTED_ITEM::SetNetCode(), DIMENSION::SetOrigin(), MODULE::SetPosition(), MODULE::SetReference(), DRAWSEGMENT::SetShape(), D_PAD::SetShape(), D_PAD::SetSize(), DRAWSEGMENT::SetStart(), EDA_TEXT::SetText(), TEXTE_PCB::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), EDA_ITEM::SetTimeStamp(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), DRAWSEGMENT::SetWidth(), DIMENSION::SetWidth(), sign(), ETEXT::size, EROT::spin, DIMENSION::Text(), ETEXT::text, ETEXT::TOP_CENTER, ETEXT::TOP_LEFT, ETEXT::TOP_RIGHT, ECOORD::ToPcbUnits(), NETINFO_LIST::UNCONNECTED, UNDEFINED_LAYER, ECIRCLE::width, ECIRCLE::x, ETEXT::x, EHOLE::x, EWIRE::x1, ERECT::x1, EDIMENSION::x1, EWIRE::x2, ERECT::x2, EDIMENSION::x2, EDIMENSION::x3, ECIRCLE::y, ETEXT::y, EHOLE::y, EWIRE::y1, ERECT::y1, EDIMENSION::y1, EWIRE::y2, ERECT::y2, EDIMENSION::y2, and EDIMENSION::y3.

Referenced by loadAllSections().

425 {
426  m_xpath->push( "plain" );
427 
428  // Get the first graphic and iterate
429  wxXmlNode* gr = aGraphics->GetChildren();
430 
431  // (polygon | wire | text | circle | rectangle | frame | hole)*
432  while( gr )
433  {
434  wxString grName = gr->GetName();
435 
436  if( grName == "wire" )
437  {
438  m_xpath->push( "wire" );
439 
440  EWIRE w( gr );
441  PCB_LAYER_ID layer = kicad_layer( w.layer );
442 
443  wxPoint start( kicad_x( w.x1 ), kicad_y( w.y1 ) );
444  wxPoint end( kicad_x( w.x2 ), kicad_y( w.y2 ) );
445 
446  if( layer != UNDEFINED_LAYER )
447  {
448  DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
449  m_board->Add( dseg, ADD_APPEND );
450 
451  if( !w.curve )
452  {
453  dseg->SetStart( start );
454  dseg->SetEnd( end );
455  }
456  else
457  {
458  wxPoint center = ConvertArcCenter( start, end, *w.curve );
459 
460  dseg->SetShape( S_ARC );
461  dseg->SetStart( center );
462  dseg->SetEnd( start );
463  dseg->SetAngle( *w.curve * -10.0 ); // KiCad rotates the other way
464  }
465 
466  dseg->SetTimeStamp( EagleTimeStamp( gr ) );
467  dseg->SetLayer( layer );
468  dseg->SetWidth( Millimeter2iu( DEFAULT_PCB_EDGE_THICKNESS ) );
469  }
470  m_xpath->pop();
471  }
472  else if( grName == "text" )
473  {
474  m_xpath->push( "text" );
475 
476  ETEXT t( gr );
477  PCB_LAYER_ID layer = kicad_layer( t.layer );
478 
479  if( layer != UNDEFINED_LAYER )
480  {
481  TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board );
482  m_board->Add( pcbtxt, ADD_APPEND );
483 
484  pcbtxt->SetLayer( layer );
485  pcbtxt->SetTimeStamp( EagleTimeStamp( gr ) );
486  pcbtxt->SetText( FROM_UTF8( t.text.c_str() ) );
487  pcbtxt->SetTextPos( wxPoint( kicad_x( t.x ), kicad_y( t.y ) ) );
488 
489  pcbtxt->SetTextSize( kicad_fontz( t.size ) );
490 
491  double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default
492 
493  pcbtxt->SetThickness( t.size.ToPcbUnits() * ratio / 100 );
494 
495  int align = t.align ? *t.align : ETEXT::BOTTOM_LEFT;
496 
497  if( t.rot )
498  {
499  int sign = t.rot->mirror ? -1 : 1;
500  pcbtxt->SetMirrored( t.rot->mirror );
501 
502  double degrees = t.rot->degrees;
503 
504  if( degrees == 90 || t.rot->spin )
505  pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 );
506  else if( degrees == 180 )
507  align = ETEXT::TOP_RIGHT;
508  else if( degrees == 270 )
509  {
510  pcbtxt->SetTextAngle( sign * 90 * 10 );
511  align = ETEXT::TOP_RIGHT;
512  }
513  else // Ok so text is not at 90,180 or 270 so do some funny stuf to get placement right
514  {
515  if( ( degrees > 0 ) && ( degrees < 90 ) )
516  pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 );
517  else if( ( degrees > 90 ) && ( degrees < 180 ) )
518  {
519  pcbtxt->SetTextAngle( sign * ( t.rot->degrees + 180 ) * 10 );
520  align = ETEXT::TOP_RIGHT;
521  }
522  else if( ( degrees > 180 ) && ( degrees < 270 ) )
523  {
524  pcbtxt->SetTextAngle( sign * ( t.rot->degrees - 180 ) * 10 );
525  align = ETEXT::TOP_RIGHT;
526  }
527  else if( ( degrees > 270 ) && ( degrees < 360 ) )
528  {
529  pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 );
530  align = ETEXT::BOTTOM_LEFT;
531  }
532  }
533  }
534 
535  switch( align )
536  {
537  case ETEXT::CENTER:
538  // this was the default in pcbtxt's constructor
539  break;
540 
541  case ETEXT::CENTER_LEFT:
543  break;
544 
545  case ETEXT::CENTER_RIGHT:
547  break;
548 
549  case ETEXT::TOP_CENTER:
551  break;
552 
553  case ETEXT::TOP_LEFT:
556  break;
557 
558  case ETEXT::TOP_RIGHT:
561  break;
562 
565  break;
566 
567  case ETEXT::BOTTOM_LEFT:
570  break;
571 
572  case ETEXT::BOTTOM_RIGHT:
575  break;
576  }
577  }
578  m_xpath->pop();
579  }
580  else if( grName == "circle" )
581  {
582  m_xpath->push( "circle" );
583 
584  ECIRCLE c( gr );
585  PCB_LAYER_ID layer = kicad_layer( c.layer );
586 
587  if( layer != UNDEFINED_LAYER ) // unsupported layer
588  {
589  DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
590  m_board->Add( dseg, ADD_APPEND );
591 
592  dseg->SetShape( S_CIRCLE );
593  dseg->SetTimeStamp( EagleTimeStamp( gr ) );
594  dseg->SetLayer( layer );
595  dseg->SetStart( wxPoint( kicad_x( c.x ), kicad_y( c.y ) ) );
596  dseg->SetEnd( wxPoint( kicad_x( c.x + c.radius ), kicad_y( c.y ) ) );
597  dseg->SetWidth( c.width.ToPcbUnits() );
598  }
599  m_xpath->pop();
600  }
601  else if( grName == "rectangle" )
602  {
603  // This seems to be a simplified rectangular [copper] zone, cannot find any
604  // net related info on it from the DTD.
605  m_xpath->push( "rectangle" );
606 
607  ERECT r( gr );
608  PCB_LAYER_ID layer = kicad_layer( r.layer );
609 
610  if( IsCopperLayer( layer ) )
611  {
612  // use a "netcode = 0" type ZONE:
613  ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
614  m_board->Add( zone, ADD_APPEND );
615 
616  zone->SetTimeStamp( EagleTimeStamp( gr ) );
617  zone->SetLayer( layer );
619 
621 
622  const int outlineIdx = -1; // this is the id of the copper zone main outline
623  zone->AppendCorner( wxPoint( kicad_x( r.x1 ), kicad_y( r.y1 ) ), outlineIdx );
624  zone->AppendCorner( wxPoint( kicad_x( r.x2 ), kicad_y( r.y1 ) ), outlineIdx );
625  zone->AppendCorner( wxPoint( kicad_x( r.x2 ), kicad_y( r.y2 ) ), outlineIdx );
626  zone->AppendCorner( wxPoint( kicad_x( r.x1 ), kicad_y( r.y2 ) ), outlineIdx );
627 
628  // this is not my fault:
629  zone->SetHatch( outline_hatch, zone->GetDefaultHatchPitch(), true );
630  }
631 
632  m_xpath->pop();
633  }
634  else if( grName == "hole" )
635  {
636  m_xpath->push( "hole" );
637  EHOLE e( gr );
638 
639  // Fabricate a MODULE with a single PAD_ATTRIB_HOLE_NOT_PLATED pad.
640  // Use m_hole_count to gen up a unique name.
641 
642  MODULE* module = new MODULE( m_board );
643  m_board->Add( module, ADD_APPEND );
644 
645  char temp[40];
646  sprintf( temp, "@HOLE%d", m_hole_count++ );
647  module->SetReference( FROM_UTF8( temp ) );
648  module->Reference().SetVisible( false );
649 
650  wxPoint pos( kicad_x( e.x ), kicad_y( e.y ) );
651 
652  module->SetPosition( pos );
653 
654  // Add a PAD_ATTRIB_HOLE_NOT_PLATED pad to this module.
655  D_PAD* pad = new D_PAD( module );
656  module->PadsList().PushBack( pad );
657 
658  pad->SetShape( PAD_SHAPE_CIRCLE );
660 
661  /* pad's position is already centered on module at relative (0, 0)
662  wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
663 
664  pad->SetPos0( padpos );
665  pad->SetPosition( padpos + module->GetPosition() );
666  */
667 
668  wxSize sz( e.drill.ToPcbUnits(), e.drill.ToPcbUnits() );
669 
670  pad->SetDrillSize( sz );
671  pad->SetSize( sz );
672 
673  pad->SetLayerSet( LSET::AllCuMask() );
674  m_xpath->pop();
675  }
676  else if( grName == "frame" )
677  {
678  // picture this
679  }
680  else if( grName == "polygon" )
681  {
682  // could be on a copper layer, could be on another layer.
683  // copper layer would be done using netCode=0 type of ZONE_CONTAINER.
684  }
685  else if( grName == "dimension" )
686  {
687  EDIMENSION d( gr );
688  PCB_LAYER_ID layer = kicad_layer( d.layer );
689 
690  if( layer != UNDEFINED_LAYER )
691  {
692  DIMENSION* dimension = new DIMENSION( m_board );
693  m_board->Add( dimension, ADD_APPEND );
694 
695  if( d.dimensionType )
696  {
697  // Eagle dimension graphic arms may have different lengths, but they look
698  // incorrect in KiCad (the graphic is tilted). Make them even lenght in such case.
699  if( *d.dimensionType == "horizontal" )
700  {
701  int newY = ( d.y1.ToPcbUnits() + d.y2.ToPcbUnits() ) / 2;
702  d.y1 = ECOORD( newY, ECOORD::EAGLE_UNIT::EAGLE_NM );
703  d.y2 = ECOORD( newY, ECOORD::EAGLE_UNIT::EAGLE_NM );
704  }
705  else if( *d.dimensionType == "vertical" )
706  {
707  int newX = ( d.x1.ToPcbUnits() + d.x2.ToPcbUnits() ) / 2;
708  d.x1 = ECOORD( newX, ECOORD::EAGLE_UNIT::EAGLE_NM );
709  d.x2 = ECOORD( newX, ECOORD::EAGLE_UNIT::EAGLE_NM );
710  }
711  }
712 
713  dimension->SetLayer( layer );
714  // The origin and end are assumed to always be in this order from eagle
715  dimension->SetOrigin( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) );
716  dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) );
718 
720  int maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetTextSize() );
721 
722  if( width > maxThickness )
723  width = maxThickness;
724 
725  dimension->Text().SetThickness( width );
726  dimension->SetWidth( width );
727 
728  // check which axis the dimension runs in
729  // because the "height" of the dimension is perpendicular to that axis
730  // Note the check is just if two axes are close enough to each other
731  // Eagle appears to have some rounding errors
732  if( abs( ( d.x1 - d.x2 ).ToPcbUnits() ) < 50000 ) // 50000 nm = 0.05 mm
733  dimension->SetHeight( kicad_x( d.x3 - d.x1 ) );
734  else
735  dimension->SetHeight( kicad_y( d.y3 - d.y1 ) );
736 
737  dimension->AdjustDimensionDetails();
738  }
739  }
740 
741  // Get next graphic
742  gr = gr->GetNext();
743  }
744  m_xpath->pop();
745 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:176
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:673
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
void SetTextAngle(double aAngle)
TEXTE_MODULE & Reference()
Definition: class_module.h:483
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...
void SetShape(STROKE_T aShape)
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
BOARD * m_board
which BOARD is being worked on, no ownership here
Definition: eagle_plugin.h:148
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
int m_PcbTextWidth
current Pcb (not module) Text width
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
void push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:117
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:221
void SetVisible(bool aVisible)
Definition: eda_text.h:173
void SetHatch(int aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetHatch sets all hatch parameters for the zone.
void SetDrillSize(const wxSize &aSize)
Definition: class_pad.h:274
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:212
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
Eagle hole element.
Definition: eagle_parser.h:781
Eagle text element.
Definition: eagle_parser.h:643
#define abs(a)
Definition: auxiliary.h:84
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:135
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
PCB_LAYER_ID
A quick note on layer IDs:
void SetOrigin(const wxPoint &aOrigin)
Function SetOrigin Sets a new origin of the crossbar line.
wxSize m_PcbTextSize
current Pcb (not module) Text size
void SetEnd(const wxPoint &aEnd)
Function SetEnd Sets a new end of the crossbar line.
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:192
Arcs (with rounded ends)
Eagle circle.
Definition: eagle_parser.h:568
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
Definition: class_zone.cpp:198
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
void SetSize(const wxSize &aSize)
Definition: class_pad.h:268
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
void SetReference(const wxString &aReference)
Function SetReference.
Definition: class_module.h:449
HATCH_STYLE
Zone hatch styles.
Definition: class_zone.h:67
void SetPosition(const wxPoint &aPos) override
int m_hole_count
generates unique module names from eagle "hole"s.
Definition: eagle_plugin.h:138
Eagle XML rectangle in binary.
Definition: eagle_parser.h:581
void SetAttribute(PAD_ATTR_T aAttribute)
Definition: class_pad.cpp:391
#define DEFAULT_PCB_EDGE_THICKNESS
void AdjustDimensionDetails(bool aDoNotChangeText=false)
Function AdjustDimensionDetails Calculate coordinates of segments used to draw the dimension...
void SetStart(const wxPoint &aStart)
unsigned long EagleTimeStamp(wxXmlNode *aTree)
Make a unique time stamp.
void SetLayerSet(LSET aLayerMask)
Definition: class_pad.h:394
wxSize kicad_fontz(const ECOORD &d) const
create a font size (fontz) from an eagle font size scalar
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:191
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
wxPoint ConvertArcCenter(const wxPoint &aStart, const wxPoint &aEnd, double aAngle)
Convert an Eagle curve end to a KiCad center for S_ARC.
TEXTE_PCB & Text()
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:217
void SetEnd(const wxPoint &aEnd)
Eagle wire.
Definition: eagle_parser.h:497
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.
bool AppendCorner(wxPoint aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
Eagle dimension element.
Definition: eagle_parser.h:626
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
const wxSize & GetTextSize() const
Definition: eda_text.h:213
void pop()
Definition: eagle_parser.h:124
void SetWidth(int aWidth)
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:461
Class DIMENSION.
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:146
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:232
int sign(T val)
Definition: math_util.h:44
virtual void SetText(const wxString &aText)
Definition: eda_text.h:139
void SetWidth(int aWidth)
void EAGLE_PLUGIN::loadSignals ( wxXmlNode *  aSignals)
private

Definition at line 1703 of file eagle_plugin.cpp.

References BOARD::Add(), ADD_APPEND, ZONE_CONTAINER::AppendCorner(), B_Cu, Clamp(), EPOLYGON::CUTOUT, ZONE_CONTAINER::DIAGONAL_EDGE, EVIA::diam, EVIA::drill, EagleTimeStamp(), escapeName(), F_Cu, ZONE_CONTAINER::GetDefaultHatchPitch(), VIA::GetDrill(), TRACK::GetWidth(), DLIST< T >::Insert(), IsCopperLayer(), EPOLYGON::isolate, kicad_layer(), kicad_x(), kicad_y(), KiROUND(), EWIRE::layer, EPOLYGON::layer, EVIA::layer_back_most, EVIA::layer_front_most, m_board, m_min_trace, m_min_via, m_min_via_hole, m_pads_to_nets, m_rules, BOARD::m_Track, m_xpath, makeKey(), EPOLYGON::max_priority, ZONE_CONTAINER::NO_HATCH, PAD_ZONE_CONN_FULL, PAD_ZONE_CONN_THERMAL, XPATH::pop(), EPOLYGON::pour, XPATH::push(), EPOLYGON::rank, ERULES::rlMaxViaOuter, ERULES::rlMinViaOuter, ERULES::rvViaOuter, ZONE_CONTAINER::SetArcSegmentCount(), ZONE_CONTAINER::SetDoNotAllowCopperPour(), VIA::SetDrill(), TRACK::SetEnd(), ZONE_CONTAINER::SetHatch(), ZONE_CONTAINER::SetHatchStyle(), ZONE_CONTAINER::SetIsKeepout(), BOARD_ITEM::SetLayer(), ZONE_CONTAINER::SetLayer(), VIA::SetLayerPair(), ZONE_CONTAINER::SetMinThickness(), BOARD_CONNECTED_ITEM::SetNetCode(), ZONE_CONTAINER::SetPadConnection(), TRACK::SetPosition(), VIA::SetPosition(), ZONE_CONTAINER::SetPriority(), ZONE_CONTAINER::SetThermalReliefCopperBridge(), ZONE_CONTAINER::SetThermalReliefGap(), EDA_ITEM::SetTimeStamp(), VIA::SetViaType(), TRACK::SetWidth(), ZONE_CONTAINER::SetZoneClearance(), EPOLYGON::spacing, EPOLYGON::thermals, ECOORD::ToPcbUnits(), NETINFO_LIST::UNCONNECTED, XPATH::Value(), VIA, VIA_BLIND_BURIED, VIA_MICROVIA, VIA_THROUGH, EWIRE::width, EPOLYGON::width, EVIA::x, EVERTEX::x, EWIRE::x1, EWIRE::x2, EVIA::y, EVERTEX::y, EWIRE::y1, and EWIRE::y2.

Referenced by loadAllSections().

1704 {
1705  ZONES zones; // per net
1706 
1707  m_xpath->push( "signals.signal", "name" );
1708 
1709  int netCode = 1;
1710 
1711  // Get the first signal and iterate
1712  wxXmlNode* net = aSignals->GetChildren();
1713 
1714  while( net )
1715  {
1716  bool sawPad = false;
1717 
1718  zones.clear();
1719 
1720  const wxString& netName = escapeName( net->GetAttribute( "name" ) );
1721  m_board->Add( new NETINFO_ITEM( m_board, netName, netCode ) );
1722 
1723  m_xpath->Value( netName.c_str() );
1724 
1725  // Get the first net item and iterate
1726  wxXmlNode* netItem = net->GetChildren();
1727 
1728  // (contactref | polygon | wire | via)*
1729  while( netItem )
1730  {
1731  const wxString& itemName = netItem->GetName();
1732 
1733  if( itemName == "wire" )
1734  {
1735  m_xpath->push( "wire" );
1736 
1737  EWIRE w( netItem );
1738  PCB_LAYER_ID layer = kicad_layer( w.layer );
1739 
1740  if( IsCopperLayer( layer ) )
1741  {
1742  TRACK* t = new TRACK( m_board );
1743 
1744  t->SetTimeStamp( EagleTimeStamp( netItem ) );
1745 
1746  t->SetPosition( wxPoint( kicad_x( w.x1 ), kicad_y( w.y1 ) ) );
1747  t->SetEnd( wxPoint( kicad_x( w.x2 ), kicad_y( w.y2 ) ) );
1748 
1749  int width = w.width.ToPcbUnits();
1750  if( width < m_min_trace )
1751  m_min_trace = width;
1752 
1753  t->SetWidth( width );
1754  t->SetLayer( layer );
1755  t->SetNetCode( netCode );
1756 
1757  m_board->m_Track.Insert( t, NULL );
1758  }
1759  else
1760  {
1761  // put non copper wires where the sun don't shine.
1762  }
1763 
1764  m_xpath->pop();
1765  }
1766 
1767  else if( itemName == "via" )
1768  {
1769  m_xpath->push( "via" );
1770  EVIA v( netItem );
1771 
1772  PCB_LAYER_ID layer_front_most = kicad_layer( v.layer_front_most );
1773  PCB_LAYER_ID layer_back_most = kicad_layer( v.layer_back_most );
1774 
1775  if( IsCopperLayer( layer_front_most ) &&
1776  IsCopperLayer( layer_back_most ) )
1777  {
1778  int kidiam;
1779  int drillz = v.drill.ToPcbUnits();
1780  VIA* via = new VIA( m_board );
1781  m_board->m_Track.Insert( via, NULL );
1782 
1783  via->SetLayerPair( layer_front_most, layer_back_most );
1784 
1785  if( v.diam )
1786  {
1787  kidiam = v.diam->ToPcbUnits();
1788  via->SetWidth( kidiam );
1789  }
1790  else
1791  {
1792  double annulus = drillz * m_rules->rvViaOuter; // eagle "restring"
1793  annulus = Clamp( m_rules->rlMinViaOuter, annulus, m_rules->rlMaxViaOuter );
1794  kidiam = KiROUND( drillz + 2 * annulus );
1795  via->SetWidth( kidiam );
1796  }
1797 
1798  via->SetDrill( drillz );
1799 
1800  // make sure the via diameter respects the restring rules
1801 
1802  if( !v.diam || via->GetWidth() <= via->GetDrill() )
1803  {
1804  double annulus = Clamp( m_rules->rlMinViaOuter,
1805  (double)( via->GetWidth() / 2 - via->GetDrill() ), m_rules->rlMaxViaOuter );
1806  via->SetWidth( drillz + 2 * annulus );
1807  }
1808 
1809  if( kidiam < m_min_via )
1810  m_min_via = kidiam;
1811 
1812  if( drillz < m_min_via_hole )
1813  m_min_via_hole = drillz;
1814 
1815  if( layer_front_most == F_Cu && layer_back_most == B_Cu )
1816  via->SetViaType( VIA_THROUGH );
1817  else if( layer_front_most == F_Cu || layer_back_most == B_Cu )
1818  via->SetViaType( VIA_MICROVIA );
1819  else
1820  via->SetViaType( VIA_BLIND_BURIED );
1821 
1822  via->SetTimeStamp( EagleTimeStamp( netItem ) );
1823 
1824  wxPoint pos( kicad_x( v.x ), kicad_y( v.y ) );
1825 
1826  via->SetPosition( pos );
1827  via->SetEnd( pos );
1828 
1829  via->SetNetCode( netCode );
1830  }
1831 
1832  m_xpath->pop();
1833  }
1834 
1835  else if( itemName == "contactref" )
1836  {
1837  m_xpath->push( "contactref" );
1838  // <contactref element="RN1" pad="7"/>
1839 
1840  const wxString& reference = netItem->GetAttribute( "element" );
1841  const wxString& pad = netItem->GetAttribute( "pad" );
1842  wxString key = makeKey( reference, pad ) ;
1843 
1844  // D(printf( "adding refname:'%s' pad:'%s' netcode:%d netname:'%s'\n", reference.c_str(), pad.c_str(), netCode, netName.c_str() );)
1845 
1846  m_pads_to_nets[ key ] = ENET( netCode, netName );
1847 
1848  m_xpath->pop();
1849 
1850  sawPad = true;
1851  }
1852 
1853  else if( itemName == "polygon" )
1854  {
1855  m_xpath->push( "polygon" );
1856 
1857  EPOLYGON p( netItem );
1858  PCB_LAYER_ID layer = kicad_layer( p.layer );
1859 
1860  if( IsCopperLayer( layer ) )
1861  {
1862  // use a "netcode = 0" type ZONE:
1863  ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
1864  m_board->Add( zone, ADD_APPEND );
1865  zones.push_back( zone );
1866 
1867  zone->SetTimeStamp( EagleTimeStamp( netItem ) );
1868  zone->SetLayer( layer );
1869  zone->SetNetCode( netCode );
1870 
1871  // Get the first vertex and iterate
1872  wxXmlNode* vertex = netItem->GetChildren();
1873 
1874  while( vertex )
1875  {
1876  if( vertex->GetName() != "vertex" ) // skip <xmlattr> node
1877  continue;
1878 
1879  EVERTEX v( vertex );
1880 
1881  // Append the corner
1882  zone->AppendCorner( wxPoint( kicad_x( v.x ), kicad_y( v.y ) ), -1 );
1883 
1884  vertex = vertex->GetNext();
1885  }
1886 
1887  // If the pour is a cutout it needs to be set to a keepout
1888  if( p.pour == EPOLYGON::CUTOUT )
1889  {
1890  zone->SetIsKeepout( true );
1891  zone->SetDoNotAllowCopperPour( true );
1893  }
1894 
1895  // if spacing is set the zone should be hatched
1896  // However, use the default hatch step, p.spacing value has no meaning for Kicad
1897  // TODO: see if this parameter is related to a grid fill option.
1898  if( p.spacing )
1900 
1901  // clearances, etc.
1902  zone->SetArcSegmentCount( 32 ); // @todo: should be a constructor default?
1903  zone->SetMinThickness( p.width.ToPcbUnits() );
1904 
1905  // FIXME: KiCad zones have very rounded corners compared to eagle.
1906  // This means that isolation amounts that work well in eagle
1907  // tend to make copper intrude in soldermask free areas around pads.
1908  if( p.isolate )
1909  {
1910  zone->SetZoneClearance( p.isolate->ToPcbUnits() );
1911  } else
1912  {
1913  zone->SetZoneClearance( 0 );
1914  }
1915 
1916  // missing == yes per DTD.
1917  bool thermals = !p.thermals || *p.thermals;
1919  if( thermals )
1920  {
1921  // FIXME: eagle calculates dimensions for thermal spokes
1922  // based on what the zone is connecting to.
1923  // (i.e. width of spoke is half of the smaller side of an smd pad)
1924  // This is a basic workaround
1925  zone->SetThermalReliefGap( p.width.ToPcbUnits() + 50000 ); // 50000nm == 0.05mm
1926  zone->SetThermalReliefCopperBridge( p.width.ToPcbUnits() + 50000 );
1927  }
1928 
1929  int rank = p.rank ? (p.max_priority - *p.rank) : p.max_priority;
1930  zone->SetPriority( rank );
1931  }
1932 
1933  m_xpath->pop(); // "polygon"
1934  }
1935 
1936  netItem = netItem->GetNext();
1937  }
1938 
1939  if( zones.size() && !sawPad )
1940  {
1941  // KiCad does not support an unconnected zone with its own non-zero netcode,
1942  // but only when assigned netcode = 0 w/o a name...
1943  for( ZONES::iterator it = zones.begin(); it != zones.end(); ++it )
1944  (*it)->SetNetCode( NETINFO_LIST::UNCONNECTED );
1945 
1946  // therefore omit this signal/net.
1947  }
1948  else
1949  netCode++;
1950 
1951  // Get next signal
1952  net = net->GetNext();
1953  }
1954 
1955  m_xpath->pop(); // "signals.signal"
1956 }
Eagle vertex.
Definition: eagle_parser.h:742
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:60
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
BOARD * m_board
which BOARD is being worked on, no ownership here
Definition: eagle_plugin.h:148
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:456
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
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:428
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:118
ERULES * m_rules
Eagle design rules.
Definition: eagle_plugin.h:134
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
void push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:117
void SetArcSegmentCount(int aArcSegCount)
Definition: class_zone.h:186
void SetHatch(int aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetHatch sets all hatch parameters for the zone.
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
int m_min_via
smallest via we find on Load(), in BIU.
Definition: eagle_plugin.h:151
double rvViaOuter
copper annulus is this percent of via hole
Definition: eagle_plugin.h:55
int GetDrill() const
Function GetDrill returns the local drill setting for this VIA.
Definition: class_track.h:470
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:135
void SetWidth(int aWidth)
Definition: class_track.h:115
void SetPriority(unsigned aPriority)
Function SetPriority.
Definition: class_zone.h:95
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:152
static wxString makeKey(const wxString &aFirst, const wxString &aSecond)
Assemble a two part key as a simple concatenation of aFirst and aSecond parts, using a separator...
wxString escapeName(const wxString &aNetName)
Translates Eagle special characters to their counterparts in KiCad.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
Definition: class_zone.cpp:198
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
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 SetZoneClearance(int aZoneClearance)
Definition: class_zone.h:193
std::vector< ZONE_CONTAINER * > ZONES
non-owning container
int m_min_trace
smallest trace we find on Load(), in BIU.
Definition: eagle_plugin.h:150
Eagle net.
Definition: eagle_parser.h:459
void SetThermalReliefCopperBridge(int aThermalReliefCopperBridge)
Definition: class_zone.h:180
void SetDoNotAllowCopperPour(bool aEnable)
Definition: class_zone.h:608
Eagle via.
Definition: eagle_parser.h:553
unsigned long EagleTimeStamp(wxXmlNode *aTree)
Make a unique time stamp.
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
int GetWidth() const
Definition: class_track.h:116
void SetPosition(const wxPoint &aPos) override
Definition: class_track.h:112
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:463
void SetHatchStyle(HATCH_STYLE aStyle)
Definition: class_zone.h:503
NET_MAP m_pads_to_nets
net list
Definition: eagle_plugin.h:140
Eagle wire.
Definition: eagle_parser.h:497
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
bool AppendCorner(wxPoint aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
DLIST< TRACK > m_Track
Definition: class_board.h:246
Eagle polygon, without vertices which are parsed as needed.
Definition: eagle_parser.h:752
void pop()
Definition: eagle_parser.h:124
void SetIsKeepout(bool aEnable)
Definition: class_zone.h:607
void SetPadConnection(ZoneConnection aPadConnection)
Definition: class_zone.h:196
void SetMinThickness(int aMinThickness)
Definition: class_zone.h:199
double rlMinViaOuter
minimum copper annulus on via
Definition: eagle_plugin.h:56
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:461
Use thermal relief for pads.
Definition: zones.h:58
void SetThermalReliefGap(int aThermalReliefGap)
Definition: class_zone.h:177
void Insert(T *aNewElement, T *aElementAfterMe)
Function Insert puts aNewElement just in front of aElementAfterMe in the list sequence.
Definition: dlist.h:200
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:232
pads are covered by copper
Definition: zones.h:59
void Value(const char *aValue)
modify the last path node&#39;s value
Definition: eagle_parser.h:127
MODULE * EAGLE_PLUGIN::makeModule ( wxXmlNode *  aPackage,
const wxString &  aPkgName 
) const
private

Function makeModule creates a MODULE from an Eagle package.

Definition at line 1180 of file eagle_plugin.cpp.

References FROM_UTF8(), m_board, packageCircle(), packageHole(), packagePad(), packagePolygon(), packageRectangle(), packageSMD(), packageText(), and packageWire().

Referenced by loadLibrary().

1181 {
1182  std::unique_ptr<MODULE> m( new MODULE( m_board ) );
1183 
1184  m->SetFPID( LIB_ID( UTF8( aPkgName ) ) );
1185 
1186  // Get the first package item and iterate
1187  wxXmlNode* packageItem = aPackage->GetChildren();
1188 
1189  while( packageItem )
1190  {
1191  const wxString& itemName = packageItem->GetName();
1192 
1193  if( itemName == "description" )
1194  m->SetDescription( FROM_UTF8( packageItem->GetNodeContent().c_str() ) );
1195 
1196  else if( itemName == "wire" )
1197  packageWire( m.get(), packageItem );
1198 
1199  else if( itemName == "pad" )
1200  packagePad( m.get(), packageItem );
1201 
1202  else if( itemName == "text" )
1203  packageText( m.get(), packageItem );
1204 
1205  else if( itemName == "rectangle" )
1206  packageRectangle( m.get(), packageItem );
1207 
1208  else if( itemName == "polygon" )
1209  packagePolygon( m.get(), packageItem );
1210 
1211  else if( itemName == "circle" )
1212  packageCircle( m.get(), packageItem );
1213 
1214  else if( itemName == "hole" )
1215  packageHole( m.get(), packageItem );
1216 
1217  else if( itemName == "smd" )
1218  packageSMD( m.get(), packageItem );
1219 
1220  packageItem = packageItem->GetNext();
1221  }
1222 
1223  return m.release();
1224 }
Class UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion supp...
Definition: utf8.h:73
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
BOARD * m_board
which BOARD is being worked on, no ownership here
Definition: eagle_plugin.h:148
void packageHole(MODULE *aModule, wxXmlNode *aTree) const
void packageText(MODULE *aModule, wxXmlNode *aTree) const
void packagePolygon(MODULE *aModule, wxXmlNode *aTree) const
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void packageCircle(MODULE *aModule, wxXmlNode *aTree) const
void packageSMD(MODULE *aModule, wxXmlNode *aTree) const
void packagePad(MODULE *aModule, wxXmlNode *aTree) const
void packageWire(MODULE *aModule, wxXmlNode *aTree) const
void packageRectangle(MODULE *aModule, wxXmlNode *aTree) const
void EAGLE_PLUGIN::orientModuleAndText ( MODULE m,
const EELEMENT e,
const EATTR nameAttr,
const EATTR valueAttr 
)
private

Definition at line 1050 of file eagle_plugin.cpp.

References EROT::degrees, MODULE::Flip(), MODULE::GetPosition(), EROT::mirror, orientModuleText(), MODULE::Reference(), EELEMENT::rot, MODULE::SetOrientation(), and MODULE::Value().

Referenced by loadElements().

1052 {
1053  if( e.rot )
1054  {
1055  if( e.rot->mirror )
1056  {
1057  double orientation = e.rot->degrees + 180.0;
1058  m->SetOrientation( orientation * 10 );
1059  m->Flip( m->GetPosition() );
1060  }
1061  else
1062  m->SetOrientation( e.rot->degrees * 10 );
1063  }
1064 
1065  orientModuleText( m, e, &m->Reference(), nameAttr );
1066  orientModuleText( m, e, &m->Value(), valueAttr );
1067 }
bool mirror
Definition: eagle_parser.h:478
TEXTE_MODULE & Reference()
Definition: class_module.h:483
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
opt_erot rot
Definition: eagle_parser.h:802
double degrees
Definition: eagle_parser.h:480
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:482
void SetOrientation(double newangle)
const wxPoint GetPosition() const override
Definition: class_module.h:175
void orientModuleText(MODULE *m, const EELEMENT &e, TEXTE_MODULE *txt, const EATTR *a)
void EAGLE_PLUGIN::orientModuleText ( MODULE m,
const EELEMENT e,
TEXTE_MODULE txt,
const EATTR a 
)
private

Definition at line 1070 of file eagle_plugin.cpp.

References abs, ETEXT::BOTTOM_LEFT, EROT::degrees, FROM_UTF8(), MODULE::GetOrientation(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, EDA_TEXT::IsMirrored(), kicad_fontz(), kicad_x(), kicad_y(), EROT::mirror, EATTR::ratio, EATTR::rot, EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetMirrored(), EDA_TEXT::SetText(), TEXTE_MODULE::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), EDA_TEXT::SetVertJustify(), sign(), EATTR::size, EROT::spin, ETEXT::TOP_RIGHT, EATTR::value, EATTR::x, and EATTR::y.

Referenced by orientModuleAndText().

1072 {
1073  // Smashed part ?
1074  if( aAttr )
1075  { // Yes
1076  const EATTR& a = *aAttr;
1077 
1078  if( a.value )
1079  {
1080  txt->SetText( FROM_UTF8( a.value->c_str() ) );
1081  }
1082 
1083  if( a.x && a.y ) // OPT
1084  {
1085  wxPoint pos( kicad_x( *a.x ), kicad_y( *a.y ) );
1086  txt->SetTextPos( pos );
1087  }
1088 
1089  // Even though size and ratio are both optional, I am not seeing
1090  // a case where ratio is present but size is not.
1091  double ratio = 8;
1092  wxSize fontz = txt->GetTextSize();
1093 
1094  if( a.size )
1095  {
1096  fontz = kicad_fontz( *a.size );
1097  txt->SetTextSize( fontz );
1098 
1099  if( a.ratio )
1100  ratio = *a.ratio;
1101  }
1102 
1103  int lw = int( fontz.y * ratio / 100 );
1104  txt->SetThickness( lw );
1105 
1106  int align = ETEXT::BOTTOM_LEFT; // bottom-left is eagle default
1107 
1108  // The "rot" in a EATTR seems to be assumed to be zero if it is not
1109  // present, and this zero rotation becomes an override to the
1110  // package's text field. If they did not want zero, they specify
1111  // what they want explicitly.
1112  double degrees = a.rot ? a.rot->degrees : 0;
1113  double orient; // relative to parent
1114 
1115  int sign = 1;
1116  bool spin = false;
1117 
1118  if( a.rot )
1119  {
1120  spin = a.rot->spin;
1121  sign = a.rot->mirror ? -1 : 1;
1122  txt->SetMirrored( a.rot->mirror );
1123  }
1124 
1125  if( degrees == 90 || degrees == 0 || spin )
1126  {
1127  orient = degrees - m->GetOrientation() / 10;
1128  txt->SetTextAngle( sign * orient * 10 );
1129  }
1130  else if( degrees == 180 )
1131  {
1132  orient = 0 - m->GetOrientation() / 10;
1133  txt->SetTextAngle( sign * orient * 10 );
1134  align = ETEXT::TOP_RIGHT;
1135  }
1136  else if( degrees == 270 )
1137  {
1138  orient = 90 - m->GetOrientation() / 10;
1139  align = ETEXT::TOP_RIGHT;
1140  txt->SetTextAngle( sign * orient * 10 );
1141  }
1142  else
1143  {
1144  orient = 90 - degrees - m->GetOrientation() / 10;
1145  txt->SetTextAngle( sign * orient * 10 );
1146  }
1147 
1148  switch( align )
1149  {
1150  case ETEXT::TOP_RIGHT:
1153  break;
1154 
1155  case ETEXT::BOTTOM_LEFT:
1158  break;
1159 
1160  default:
1161  ;
1162  }
1163  }
1164  else // Part is not smash so use Lib default for NAME/VALUE // the text is per the original package, sans <attribute>
1165  {
1166  double degrees = ( txt->GetTextAngle() + m->GetOrientation() ) / 10;
1167 
1168  // @todo there are a few more cases than these to contend with:
1169  if( (!txt->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ))
1170  || ( txt->IsMirrored() && ( degrees == 360 ) ) )
1171  {
1172  // ETEXT::TOP_RIGHT:
1175  }
1176  }
1177 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:176
bool mirror
Definition: eagle_parser.h:478
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 SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:221
double degrees
Definition: eagle_parser.h:480
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:212
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
#define abs(a)
Definition: auxiliary.h:84
opt_erot rot
Definition: eagle_parser.h:609
double GetTextAngle() const
Definition: eda_text.h:162
opt_ecoord y
Definition: eagle_parser.h:605
double GetOrientation() const
Definition: class_module.h:180
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:192
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
opt_wxString value
Definition: eagle_parser.h:603
Class EATTR parses an Eagle "attribute" XML element.
Definition: eagle_parser.h:600
opt_ecoord x
Definition: eagle_parser.h:604
wxSize kicad_fontz(const ECOORD &d) const
create a font size (fontz) from an eagle font size scalar
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:191
bool IsMirrored() const
Definition: eda_text.h:177
opt_double ratio
Definition: eagle_parser.h:608
void SetTextAngle(double aAngle)
bool spin
Definition: eagle_parser.h:479
const wxSize & GetTextSize() const
Definition: eda_text.h:213
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:146
opt_ecoord size
Definition: eagle_parser.h:606
int sign(T val)
Definition: math_util.h:44
virtual void SetText(const wxString &aText)
Definition: eda_text.h:139
void EAGLE_PLUGIN::packageCircle ( MODULE aModule,
wxXmlNode *  aTree 
) const
private

Definition at line 1561 of file eagle_plugin.cpp.

References UTF8::c_str(), Cmts_User, Dwgs_User, EagleTimeStamp(), Format(), MODULE::GetFPID(), LIB_ID::GetLibItemName(), MODULE::GraphicalItemsList(), IsCopperLayer(), kicad_layer(), kicad_x(), kicad_y(), ECIRCLE::layer, DLIST< T >::PushBack(), ECIRCLE::radius, S_CIRCLE, EDGE_MODULE::SetDrawCoord(), EDGE_MODULE::SetEnd0(), BOARD_ITEM::SetLayer(), EDGE_MODULE::SetStart0(), EDA_ITEM::SetTimeStamp(), DRAWSEGMENT::SetWidth(), ECOORD::ToPcbUnits(), UNDEFINED_LAYER, ECIRCLE::width, ECIRCLE::x, and ECIRCLE::y.

Referenced by makeModule().

1562 {
1563  ECIRCLE e( aTree );
1564  PCB_LAYER_ID layer = kicad_layer( e.layer );
1565 
1566  if( IsCopperLayer( layer ) ) // skip copper "package.circle"s
1567  {
1568  wxLogMessage( wxString::Format(
1569  "Unsupported circle on copper layer in package %s.\nMoving to Dwgs.User layer.",
1570  aModule->GetFPID().GetLibItemName().c_str() ) );
1571  layer = Dwgs_User;
1572  }
1573 
1574  EDGE_MODULE* gr = new EDGE_MODULE( aModule, S_CIRCLE );
1575 
1576  aModule->GraphicalItemsList().PushBack( gr );
1577 
1578  gr->SetWidth( e.width.ToPcbUnits() );
1579 
1580  switch( (int) layer )
1581  {
1582  case UNDEFINED_LAYER: layer = Cmts_User; break;
1583  /*
1584  case Eco1_User: layer = F_SilkS; break;
1585  case Eco2_User: layer = B_SilkS; break;
1586  */
1587  default:
1588  break;
1589  }
1590 
1591  gr->SetLayer( layer );
1592  gr->SetTimeStamp( EagleTimeStamp( aTree ) );
1593  gr->SetStart0( wxPoint( kicad_x( e.x ), kicad_y( e.y ) ) );
1594  gr->SetEnd0( wxPoint( kicad_x( e.x + e.radius ), kicad_y( e.y ) ) );
1595  gr->SetDrawCoord();
1596 }
void SetEnd0(const wxPoint &aPoint)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
const LIB_ID & GetFPID() const
Definition: class_module.h:184
PCB_LAYER_ID
A quick note on layer IDs:
const UTF8 & GetLibItemName() const
Definition: lib_id.h:115
Eagle circle.
Definition: eagle_parser.h:568
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
unsigned long EagleTimeStamp(wxXmlNode *aTree)
Make a unique time stamp.
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
const char * c_str() const
Definition: utf8.h:107
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
void SetStart0(const wxPoint &aPoint)
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:232
void SetWidth(int aWidth)
void EAGLE_PLUGIN::packageHole ( MODULE aModule,
wxXmlNode *  aTree 
) const
private

Definition at line 1599 of file eagle_plugin.cpp.

References LSET::AllCuMask(), EHOLE::drill, MODULE::GetPosition(), kicad_x(), kicad_y(), PAD_ATTRIB_HOLE_NOT_PLATED, PAD_SHAPE_CIRCLE, MODULE::PadsList(), DLIST< T >::PushBack(), D_PAD::SetAttribute(), D_PAD::SetDrillSize(), D_PAD::SetLayerSet(), D_PAD::SetPos0(), D_PAD::SetPosition(), D_PAD::SetShape(), D_PAD::SetSize(), ECOORD::ToPcbUnits(), EHOLE::x, and EHOLE::y.

Referenced by makeModule().

1600 {
1601  EHOLE e( aTree );
1602 
1603  // we add a PAD_ATTRIB_HOLE_NOT_PLATED pad to this module.
1604  D_PAD* pad = new D_PAD( aModule );
1605  aModule->PadsList().PushBack( pad );
1606 
1607  pad->SetShape( PAD_SHAPE_CIRCLE );
1609 
1610  // Mechanical purpose only:
1611  // no offset, no net name, no pad name allowed
1612  // pad->SetOffset( wxPoint( 0, 0 ) );
1613  // pad->SetName( wxEmptyString );
1614 
1615  wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
1616 
1617  pad->SetPos0( padpos );
1618  pad->SetPosition( padpos + aModule->GetPosition() );
1619 
1620  wxSize sz( e.drill.ToPcbUnits(), e.drill.ToPcbUnits() );
1621 
1622  pad->SetDrillSize( sz );
1623  pad->SetSize( sz );
1624 
1625  pad->SetLayerSet( LSET::AllCuMask() /* | SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT */ );
1626 }
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:673
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:219
void SetDrillSize(const wxSize &aSize)
Definition: class_pad.h:274
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
Eagle hole element.
Definition: eagle_parser.h:781
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:262
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
void SetSize(const wxSize &aSize)
Definition: class_pad.h:268
void SetAttribute(PAD_ATTR_T aAttribute)
Definition: class_pad.cpp:391
void SetLayerSet(LSET aLayerMask)
Definition: class_pad.h:394
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:217
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
const wxPoint GetPosition() const override
Definition: class_module.h:175
void EAGLE_PLUGIN::packagePad ( MODULE aModule,
wxXmlNode *  aTree 
) const
private

Definition at line 1275 of file eagle_plugin.cpp.

References LSET::AllCuMask(), B_Mask, Clamp(), EROT::degrees, EPAD::diameter, EPAD::drill, F_Mask, FROM_UTF8(), D_PAD::GetDrillSize(), MODULE::GetOrientation(), MODULE::GetPosition(), D_PAD::GetShape(), D_PAD::GetSize(), kicad_x(), kicad_y(), KiROUND(), EPAD::LONG, m_rules, EPAD::name, EPAD::OCTAGON, EPAD::OFFSET, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, MODULE::PadsList(), ERULES::psElongationLong, DLIST< T >::PushBack(), ERULES::rlMaxPadTop, ERULES::rlMinPadTop, EPAD::rot, RotatePoint(), EPAD::ROUND, ERULES::rvPadTop, D_PAD::SetDrillSize(), D_PAD::SetLayerSet(), D_PAD::SetName(), D_PAD::SetOrientation(), D_PAD::SetPos0(), D_PAD::SetPosition(), D_PAD::SetShape(), D_PAD::SetSize(), EPAD::shape, EPAD::SQUARE, ECOORD::ToPcbUnits(), EPAD::x, and EPAD::y.

Referenced by makeModule().

1276 {
1277  // this is thru hole technology here, no SMDs
1278  EPAD e( aTree );
1279 
1280  D_PAD* pad = new D_PAD( aModule );
1281  aModule->PadsList().PushBack( pad );
1282 
1283  pad->SetName( FROM_UTF8( e.name.c_str() ) );
1284 
1285  // pad's "Position" is not relative to the module's,
1286  // whereas Pos0 is relative to the module's but is the unrotated coordinate.
1287 
1288  wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
1289 
1290  pad->SetPos0( padpos );
1291 
1292  RotatePoint( &padpos, aModule->GetOrientation() );
1293 
1294  pad->SetPosition( padpos + aModule->GetPosition() );
1295  pad->SetDrillSize( wxSize( e.drill.ToPcbUnits(), e.drill.ToPcbUnits() ) );
1296  pad->SetLayerSet( LSET::AllCuMask().set( B_Mask ).set( F_Mask ) );
1297 
1298  if( e.shape )
1299  {
1300  switch( *e.shape )
1301  {
1302  case EPAD::ROUND:
1303  wxASSERT( pad->GetShape()==PAD_SHAPE_CIRCLE ); // verify set in D_PAD constructor
1304  break;
1305 
1306  case EPAD::OCTAGON:
1307  // no KiCad octagonal pad shape, use PAD_CIRCLE for now.
1308  // pad->SetShape( PAD_OCTAGON );
1309  wxASSERT( pad->GetShape()==PAD_SHAPE_CIRCLE ); // verify set in D_PAD constructor
1310  break;
1311 
1312  case EPAD::LONG:
1313  pad->SetShape( PAD_SHAPE_OVAL );
1314  break;
1315 
1316  case EPAD::SQUARE:
1317  pad->SetShape( PAD_SHAPE_RECT );
1318  break;
1319 
1320  case EPAD::OFFSET:
1321  ; // don't know what to do here.
1322  }
1323  }
1324  else
1325  {
1326  // if shape is not present, our default is circle and that matches their default "round"
1327  }
1328 
1329  if( e.diameter )
1330  {
1331  int diameter = e.diameter->ToPcbUnits();
1332  pad->SetSize( wxSize( diameter, diameter ) );
1333  }
1334  else
1335  {
1336  double drillz = pad->GetDrillSize().x;
1337  double annulus = drillz * m_rules->rvPadTop; // copper annulus, eagle "restring"
1338  annulus = Clamp( m_rules->rlMinPadTop, annulus, m_rules->rlMaxPadTop );
1339  int diameter = KiROUND( drillz + 2 * annulus );
1340  pad->SetSize( wxSize( KiROUND( diameter ), KiROUND( diameter ) ) );
1341  }
1342 
1343  if( pad->GetShape() == PAD_SHAPE_OVAL )
1344  {
1345  // The Eagle "long" pad is wider than it is tall,
1346  // m_elongation is percent elongation
1347  wxSize sz = pad->GetSize();
1348  sz.x = ( sz.x * ( 100 + m_rules->psElongationLong ) ) / 100;
1349  pad->SetSize( sz );
1350  }
1351 
1352  if( e.rot )
1353  {
1354  pad->SetOrientation( e.rot->degrees * 10 );
1355  }
1356 
1357  // @todo: handle stop and thermal
1358 }
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:673
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
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
ERULES * m_rules
Eagle design rules.
Definition: eagle_plugin.h:134
double rlMaxPadTop
maximum copper annulus on through hole pads
Definition: eagle_plugin.h:53
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:219
void SetDrillSize(const wxSize &aSize)
Definition: class_pad.h:274
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
Eagle thru hol pad.
Definition: eagle_parser.h:678
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12)...
Definition: class_pad.h:182
double GetOrientation() const
Definition: class_module.h:180
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:262
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
const wxSize & GetSize() const
Definition: class_pad.h:269
void SetSize(const wxSize &aSize)
Definition: class_pad.h:268
int psElongationLong
percent over 100%.
Definition: eagle_plugin.h:44
void SetLayerSet(LSET aLayerMask)
Definition: class_pad.h:394
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:217
void SetOrientation(double aAngle)
Function SetOrientation sets the rotation angle of the pad.
Definition: class_pad.cpp:400
double rvPadTop
top pad size as percent of drill size
Definition: eagle_plugin.h:49
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
double rlMinPadTop
minimum copper annulus on through hole pads
Definition: eagle_plugin.h:52
const wxPoint GetPosition() const override
Definition: class_module.h:175
void EAGLE_PLUGIN::packagePolygon ( MODULE aModule,
wxXmlNode *  aTree 
) const
private

Definition at line 1513 of file eagle_plugin.cpp.

References UTF8::c_str(), Dwgs_User, EagleTimeStamp(), Format(), MODULE::GetFPID(), LIB_ID::GetLibItemName(), MODULE::GraphicalItemsList(), IsCopperLayer(), kicad_layer(), kicad_x(), kicad_y(), EPOLYGON::layer, DLIST< T >::PushBack(), S_POLYGON, EDGE_MODULE::SetDrawCoord(), EDGE_MODULE::SetEnd0(), BOARD_ITEM::SetLayer(), DRAWSEGMENT::SetPolyPoints(), EDGE_MODULE::SetStart0(), EDA_ITEM::SetTimeStamp(), DRAWSEGMENT::SetWidth(), EVERTEX::x, and EVERTEX::y.

Referenced by makeModule().

1514 {
1515  EPOLYGON p( aTree );
1516  PCB_LAYER_ID layer = kicad_layer( p.layer );
1517 
1518  if( IsCopperLayer( layer ) ) // skip copper "package.circle"s
1519  {
1520  wxLogMessage( wxString::Format(
1521  "Unsupported polygon on copper layer in package %s.\nMoving to Dwgs.User layer.",
1522  aModule->GetFPID().GetLibItemName().c_str() ) );
1523  layer = Dwgs_User;
1524  }
1525 
1526  EDGE_MODULE* dwg = new EDGE_MODULE( aModule, S_POLYGON );
1527  aModule->GraphicalItemsList().PushBack( dwg );
1528 
1529  dwg->SetWidth( 0 ); // it's filled, no need for boundary width
1530 
1531  dwg->SetLayer( layer );
1532 
1533  dwg->SetTimeStamp( EagleTimeStamp( aTree ) );
1534 
1535  std::vector<wxPoint> pts;
1536  // TODO: I think there's no way to know a priori the number of children in wxXmlNode :()
1537  // pts.reserve( aTree.size() );
1538 
1539  // Get the first vertex and iterate
1540  wxXmlNode* vertex = aTree->GetChildren();
1541 
1542  while( vertex )
1543  {
1544  if( vertex->GetName() != "vertex" ) // skip <xmlattr> node
1545  continue;
1546 
1547  EVERTEX v( vertex );
1548 
1549  pts.push_back( wxPoint( kicad_x( v.x ), kicad_y( v.y ) ) );
1550 
1551  vertex = vertex->GetNext();
1552  }
1553 
1554  dwg->SetPolyPoints( pts );
1555  dwg->SetStart0( *pts.begin() );
1556  dwg->SetEnd0( pts.back() );
1557  dwg->SetDrawCoord();
1558 }
Eagle vertex.
Definition: eagle_parser.h:742
void SetEnd0(const wxPoint &aPoint)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
polygon (not yet used for tracks, but could be in microwave apps)
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
const LIB_ID & GetFPID() const
Definition: class_module.h:184
PCB_LAYER_ID
A quick note on layer IDs:
const UTF8 & GetLibItemName() const
Definition: lib_id.h:115
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
unsigned long EagleTimeStamp(wxXmlNode *aTree)
Make a unique time stamp.
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
const char * c_str() const
Definition: utf8.h:107
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
void SetStart0(const wxPoint &aPoint)
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
Eagle polygon, without vertices which are parsed as needed.
Definition: eagle_parser.h:752
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:232
void SetWidth(int aWidth)
void EAGLE_PLUGIN::packageRectangle ( MODULE aModule,
wxXmlNode *  aTree 
) const
private

Definition at line 1475 of file eagle_plugin.cpp.

References UTF8::c_str(), Dwgs_User, EagleTimeStamp(), Format(), MODULE::GetFPID(), LIB_ID::GetLibItemName(), MODULE::GraphicalItemsList(), IsCopperLayer(), kicad_layer(), kicad_x(), kicad_y(), ERECT::layer, DLIST< T >::PushBack(), S_POLYGON, EDGE_MODULE::SetEnd0(), BOARD_ITEM::SetLayer(), DRAWSEGMENT::SetPolyPoints(), EDGE_MODULE::SetStart0(), EDA_ITEM::SetTimeStamp(), DRAWSEGMENT::SetWidth(), ERECT::x1, ERECT::x2, ERECT::y1, and ERECT::y2.

Referenced by makeModule().

1476 {
1477  ERECT r( aTree );
1478  PCB_LAYER_ID layer = kicad_layer( r.layer );
1479 
1480  if( IsCopperLayer( layer ) ) // skip copper "package.circle"s
1481  {
1482  wxLogMessage( wxString::Format(
1483  "Unsupported rectangle on copper layer in package %s.\nMoving to Dwgs.User layer.",
1484  aModule->GetFPID().GetLibItemName().c_str() ) );
1485  layer = Dwgs_User;
1486  }
1487 
1488  EDGE_MODULE* dwg = new EDGE_MODULE( aModule, S_POLYGON );
1489  aModule->GraphicalItemsList().PushBack( dwg );
1490 
1491  dwg->SetLayer( layer );
1492  dwg->SetWidth( 0 );
1493 
1494  dwg->SetTimeStamp( EagleTimeStamp( aTree ) );
1495 
1496  std::vector<wxPoint> pts;
1497 
1498  wxPoint start( wxPoint( kicad_x( r.x1 ), kicad_y( r.y1 ) ) );
1499  wxPoint end( wxPoint( kicad_x( r.x1 ), kicad_y( r.y2 ) ) );
1500 
1501  pts.push_back( start );
1502  pts.push_back( wxPoint( kicad_x( r.x2 ), kicad_y( r.y1 ) ) );
1503  pts.push_back( wxPoint( kicad_x( r.x2 ), kicad_y( r.y2 ) ) );
1504  pts.push_back( end );
1505 
1506  dwg->SetPolyPoints( pts );
1507 
1508  dwg->SetStart0( start );
1509  dwg->SetEnd0( end );
1510 }
void SetEnd0(const wxPoint &aPoint)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
polygon (not yet used for tracks, but could be in microwave apps)
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
const LIB_ID & GetFPID() const
Definition: class_module.h:184
PCB_LAYER_ID
A quick note on layer IDs:
const UTF8 & GetLibItemName() const
Definition: lib_id.h:115
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
Eagle XML rectangle in binary.
Definition: eagle_parser.h:581
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
unsigned long EagleTimeStamp(wxXmlNode *aTree)
Make a unique time stamp.
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
const char * c_str() const
Definition: utf8.h:107
void SetStart0(const wxPoint &aPoint)
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:232
void SetWidth(int aWidth)
void EAGLE_PLUGIN::packageSMD ( MODULE aModule,
wxXmlNode *  aTree 
) const
private

Definition at line 1629 of file eagle_plugin.cpp.

References B_Cu, B_Mask, B_Paste, EROT::degrees, ESMD::dx, ESMD::dy, F_Cu, F_Mask, F_Paste, FROM_UTF8(), MODULE::GetOrientation(), MODULE::GetPosition(), IsCopperLayer(), kicad_layer(), kicad_x(), kicad_y(), ESMD::layer, ESMD::name, PAD_ATTRIB_SMD, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, MODULE::PadsList(), DLIST< T >::PushBack(), ESMD::rot, RotatePoint(), ESMD::roundness, D_PAD::SetAttribute(), BOARD_ITEM::SetLayer(), D_PAD::SetLayerSet(), D_PAD::SetName(), D_PAD::SetOrientation(), D_PAD::SetPos0(), D_PAD::SetPosition(), D_PAD::SetShape(), D_PAD::SetSize(), ECOORD::ToPcbUnits(), ESMD::x, and ESMD::y.

Referenced by makeModule().

1630 {
1631  ESMD e( aTree );
1632  PCB_LAYER_ID layer = kicad_layer( e.layer );
1633 
1634  if( !IsCopperLayer( layer ) )
1635  {
1636  return;
1637  }
1638 
1639  D_PAD* pad = new D_PAD( aModule );
1640  aModule->PadsList().PushBack( pad );
1641 
1642  pad->SetName( FROM_UTF8( e.name.c_str() ) );
1643  pad->SetShape( PAD_SHAPE_RECT );
1644  pad->SetAttribute( PAD_ATTRIB_SMD );
1645 
1646  // pad's "Position" is not relative to the module's,
1647  // whereas Pos0 is relative to the module's but is the unrotated coordinate.
1648 
1649  wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
1650 
1651  pad->SetPos0( padpos );
1652 
1653  RotatePoint( &padpos, aModule->GetOrientation() );
1654 
1655  pad->SetPosition( padpos + aModule->GetPosition() );
1656 
1657  pad->SetSize( wxSize( e.dx.ToPcbUnits(), e.dy.ToPcbUnits() ) );
1658 
1659  pad->SetLayer( layer );
1660 
1661  static const LSET front( 3, F_Cu, F_Paste, F_Mask );
1662  static const LSET back( 3, B_Cu, B_Paste, B_Mask );
1663 
1664  if( layer == F_Cu )
1665  pad->SetLayerSet( front );
1666  else if( layer == B_Cu )
1667  pad->SetLayerSet( back );
1668 
1669  // Optional according to DTD
1670  if( e.roundness ) // set set shape to PAD_SHAPE_RECT above, in case roundness is not present
1671  {
1672  if( *e.roundness >= 75 ) // roundness goes from 0-100% as integer
1673  {
1674  if( e.dy == e.dx )
1675  pad->SetShape( PAD_SHAPE_CIRCLE );
1676  else
1677  pad->SetShape( PAD_SHAPE_OVAL );
1678  }
1679  }
1680 
1681  if( e.rot )
1682  {
1683  pad->SetOrientation( e.rot->degrees * 10 );
1684  }
1685 
1686  // don't know what stop, thermals, and cream should look like now.
1687 }
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
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:61
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:219
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
Eagle SMD pad.
Definition: eagle_parser.h:705
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
PCB_LAYER_ID
A quick note on layer IDs:
Class LSET is a set of PCB_LAYER_IDs.
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12)...
Definition: class_pad.h:182
double GetOrientation() const
Definition: class_module.h:180
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:262
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
void SetSize(const wxSize &aSize)
Definition: class_pad.h:268
void SetAttribute(PAD_ATTR_T aAttribute)
Definition: class_pad.cpp:391
void SetLayerSet(LSET aLayerMask)
Definition: class_pad.h:394
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:217
void SetOrientation(double aAngle)
Function SetOrientation sets the rotation angle of the pad.
Definition: class_pad.cpp:400
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
const wxPoint GetPosition() const override
Definition: class_module.h:175
void EAGLE_PLUGIN::packageText ( MODULE aModule,
wxXmlNode *  aTree 
) const
private

Definition at line 1361 of file eagle_plugin.cpp.

References ETEXT::align, ETEXT::BOTTOM_CENTER, ETEXT::BOTTOM_LEFT, ETEXT::BOTTOM_RIGHT, UTF8::c_str(), ETEXT::CENTER, ETEXT::CENTER_LEFT, ETEXT::CENTER_RIGHT, Cmts_User, EROT::degrees, Dwgs_User, EagleTimeStamp(), Format(), FROM_UTF8(), MODULE::GetFPID(), LIB_ID::GetLibItemName(), MODULE::GetPosition(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, MODULE::GraphicalItemsList(), IsCopperLayer(), kicad_fontz(), kicad_layer(), kicad_x(), kicad_y(), ETEXT::layer, EROT::mirror, DLIST< T >::PushBack(), ETEXT::ratio, MODULE::Reference(), ETEXT::rot, EDA_TEXT::SetHorizJustify(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), TEXTE_MODULE::SetPos0(), EDA_TEXT::SetText(), TEXTE_MODULE::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), EDA_ITEM::SetTimeStamp(), EDA_TEXT::SetVertJustify(), sign(), ETEXT::size, EROT::spin, ETEXT::text, ETEXT::TOP_CENTER, ETEXT::TOP_LEFT, ETEXT::TOP_RIGHT, ECOORD::ToPcbUnits(), UNDEFINED_LAYER, MODULE::Value(), ETEXT::x, and ETEXT::y.

Referenced by makeModule().

1362 {
1363  ETEXT t( aTree );
1364  PCB_LAYER_ID layer = kicad_layer( t.layer );
1365 
1366  if( IsCopperLayer( layer ) ) // skip copper texts
1367  {
1368  wxLogMessage( wxString::Format(
1369  "Unsupported text on copper layer in package %s.\nMoving to Dwgs.User layer.",
1370  aModule->GetFPID().GetLibItemName().c_str() ) );
1371  layer = Dwgs_User;
1372  }
1373 
1374  if( layer == UNDEFINED_LAYER )
1375  {
1376  layer = Cmts_User;
1377  }
1378 
1379  TEXTE_MODULE* txt;
1380 
1381  if( t.text == ">NAME" || t.text == ">name" )
1382  txt = &aModule->Reference();
1383  else if( t.text == ">VALUE" || t.text == ">value" )
1384  txt = &aModule->Value();
1385  else
1386  {
1387  // FIXME: graphical text items are rotated for some reason.
1388  txt = new TEXTE_MODULE( aModule );
1389  aModule->GraphicalItemsList().PushBack( txt );
1390  }
1391 
1392  txt->SetTimeStamp( EagleTimeStamp( aTree ) );
1393  txt->SetText( FROM_UTF8( t.text.c_str() ) );
1394 
1395  wxPoint pos( kicad_x( t.x ), kicad_y( t.y ) );
1396 
1397  txt->SetTextPos( pos );
1398  txt->SetPos0( pos - aModule->GetPosition() );
1399 
1400  txt->SetLayer( layer );
1401  txt->SetTextSize( kicad_fontz( t.size ) );
1402 
1403  double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default
1404 
1405  txt->SetThickness( t.size.ToPcbUnits() * ratio / 100 );
1406 
1407  int align = t.align ? *t.align : ETEXT::BOTTOM_LEFT; // bottom-left is eagle default
1408 
1409  // An eagle package is never rotated, the DTD does not allow it.
1410  // angle -= aModule->GetOrienation();
1411 
1412  if( t.rot )
1413  {
1414  int sign = t.rot->mirror ? -1 : 1;
1415  txt->SetMirrored( t.rot->mirror );
1416 
1417  double degrees = t.rot->degrees;
1418 
1419  if( degrees == 90 || t.rot->spin )
1420  txt->SetTextAngle( sign * degrees * 10 );
1421  else if( degrees == 180 )
1422  align = ETEXT::TOP_RIGHT;
1423  else if( degrees == 270 )
1424  {
1425  align = ETEXT::TOP_RIGHT;
1426  txt->SetTextAngle( sign * 90 * 10 );
1427  }
1428  }
1429 
1430  switch( align )
1431  {
1432  case ETEXT::CENTER:
1433  // this was the default in pcbtxt's constructor
1434  break;
1435 
1436  case ETEXT::CENTER_LEFT:
1438  break;
1439 
1440  case ETEXT::CENTER_RIGHT:
1442  break;
1443 
1444  case ETEXT::TOP_CENTER:
1446  break;
1447 
1448  case ETEXT::TOP_LEFT:
1451  break;
1452 
1453  case ETEXT::TOP_RIGHT:
1456  break;
1457 
1458  case ETEXT::BOTTOM_CENTER:
1460  break;
1461 
1462  case ETEXT::BOTTOM_LEFT:
1465  break;
1466 
1467  case ETEXT::BOTTOM_RIGHT:
1470  break;
1471  }
1472 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:176
TEXTE_MODULE & Reference()
Definition: class_module.h:483
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
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:221
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:212
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
Eagle text element.
Definition: eagle_parser.h:643
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
const LIB_ID & GetFPID() const
Definition: class_module.h:184
PCB_LAYER_ID
A quick note on layer IDs:
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:482
const UTF8 & GetLibItemName() const
Definition: lib_id.h:115
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:192
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
void SetPos0(const wxPoint &aPos)
unsigned long EagleTimeStamp(wxXmlNode *aTree)
Make a unique time stamp.
wxSize kicad_fontz(const ECOORD &d) const
create a font size (fontz) from an eagle font size scalar
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 SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:191
const char * c_str() const
Definition: utf8.h:107
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
void SetTextAngle(double aAngle)
const wxPoint GetPosition() const override
Definition: class_module.h:175
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:146
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:232
int sign(T val)
Definition: math_util.h:44
virtual void SetText(const wxString &aText)
Definition: eda_text.h:139
void EAGLE_PLUGIN::packageWire ( MODULE aModule,
wxXmlNode *  aTree 
) const
private

Definition at line 1227 of file eagle_plugin.cpp.

References UTF8::c_str(), ConvertArcCenter(), EWIRE::curve, Dwgs_User, Format(), MODULE::GetFPID(), LIB_ID::GetLibItemName(), MODULE::GraphicalItemsList(), IsCopperLayer(), kicad_layer(), kicad_x(), kicad_y(), EWIRE::layer, DLIST< T >::PushBack(), S_ARC, S_SEGMENT, DRAWSEGMENT::SetAngle(), EDGE_MODULE::SetDrawCoord(), EDGE_MODULE::SetEnd0(), BOARD_ITEM::SetLayer(), EDGE_MODULE::SetStart0(), DRAWSEGMENT::SetWidth(), ECOORD::ToMm(), ECOORD::ToPcbUnits(), EWIRE::width, EWIRE::x1, EWIRE::x2, EWIRE::y1, and EWIRE::y2.

Referenced by makeModule().

1228 {
1229  EWIRE w( aTree );
1230  PCB_LAYER_ID layer = kicad_layer( w.layer );
1231 
1232  if( IsCopperLayer( layer ) ) // skip copper "package.circle"s
1233  {
1234  wxLogMessage( wxString::Format(
1235  "Line on copper layer in package %s (%f mm, %f mm) (%f mm, %f mm)."
1236  "\nMoving to Dwgs.User layer",
1237  aModule->GetFPID().GetLibItemName().c_str(), w.x1.ToMm(), w.y1.ToMm(),
1238  w.x2.ToMm(), w.y2.ToMm() ) );
1239  layer = Dwgs_User;
1240  }
1241 
1242  wxPoint start( kicad_x( w.x1 ), kicad_y( w.y1 ) );
1243  wxPoint end( kicad_x( w.x2 ), kicad_y( w.y2 ) );
1244  int width = w.width.ToPcbUnits();
1245 
1246  // FIXME: the cap attribute is ignored because kicad can't create lines
1247  // with flat ends.
1248  EDGE_MODULE* dwg;
1249 
1250  if( !w.curve )
1251  {
1252  dwg = new EDGE_MODULE( aModule, S_SEGMENT );
1253 
1254  dwg->SetStart0( start );
1255  dwg->SetEnd0( end );
1256  }
1257  else
1258  {
1259  dwg = new EDGE_MODULE( aModule, S_ARC );
1260  wxPoint center = ConvertArcCenter( start, end, *w.curve );
1261 
1262  dwg->SetStart0( center );
1263  dwg->SetEnd0( start );
1264  dwg->SetAngle( *w.curve * -10.0 ); // KiCad rotates the other way
1265  }
1266 
1267  dwg->SetLayer( layer );
1268  dwg->SetWidth( width );
1269  dwg->SetDrawCoord();
1270 
1271  aModule->GraphicalItemsList().PushBack( dwg );
1272 }
void SetEnd0(const wxPoint &aPoint)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
usual segment : line with rounded ends
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:164
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
const LIB_ID & GetFPID() const
Definition: class_module.h:184
PCB_LAYER_ID
A quick note on layer IDs:
const UTF8 & GetLibItemName() const
Definition: lib_id.h:115
Arcs (with rounded ends)
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:163
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
wxPoint ConvertArcCenter(const wxPoint &aStart, const wxPoint &aEnd, double aAngle)
Convert an Eagle curve end to a KiCad center for S_ARC.
const char * c_str() const
Definition: utf8.h:107
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
void SetStart0(const wxPoint &aPoint)
Eagle wire.
Definition: eagle_parser.h:497
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.
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
void SetWidth(int aWidth)
const wxString EAGLE_PLUGIN::PluginName ( ) const
overridevirtual

Function PluginName returns a brief hard coded name for this PLUGIN.

Implements PLUGIN.

Definition at line 160 of file eagle_plugin.cpp.

161 {
162  return wxT( "Eagle" );
163 }
void PLUGIN::PrefetchLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function PrefetchLib If possible, prefetches the specified library (e.g.

performing downloads). Does not parse. Threadsafe.

This is a no-op for libraries that cannot be prefetched.

Plugins that cannot prefetch need not override this; a default no-op is provided.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aPropertiesis an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is an error prefetching the library.

Reimplemented in GITHUB_PLUGIN.

Definition at line 69 of file plugin.cpp.

Referenced by FP_LIB_TABLE::PrefetchLib().

70 {
71  (void) aLibraryPath;
72  (void) aProperties;
73 }
void PLUGIN::Save ( const wxString &  aFileName,
BOARD aBoard,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function Save will write aBoard to a storage file in a format that this PLUGIN implementation knows about, or it can be used to write a portion of aBoard to a special kind of export file.

Parameters
aFileNameis the name of a file to save to on disk.
aBoardis the class BOARD in memory document tree from which to extract information when writing to aFileName. The caller continues to own the BOARD, and the plugin should refrain from modifying the BOARD if possible.
aPropertiesis an associative array that can be used to tell the saver how to save the file, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem saving or exporting.

Reimplemented in PCB_IO, and CLIPBOARD_IO.

Definition at line 54 of file plugin.cpp.

References not_implemented().

Referenced by IO_MGR::Save(), PCB_EDIT_FRAME::SavePcbCopy(), and PCB_EDIT_FRAME::SavePcbFile().

55 {
56  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
57  not_implemented( this, __FUNCTION__ );
58 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38

Member Data Documentation

BOARD* EAGLE_PLUGIN::m_board
private

which BOARD is being worked on, no ownership here

Definition at line 148 of file eagle_plugin.h.

Referenced by centerBoard(), init(), Load(), loadElements(), loadLayerDefs(), loadPlain(), loadSignals(), and makeModule().

int EAGLE_PLUGIN::m_cu_map[17]
private

map eagle to kicad, cu layers only.

Definition at line 131 of file eagle_plugin.h.

Referenced by clear_cu_map(), kicad_layer(), and loadLayerDefs().

std::map<int, ELAYER> EAGLE_PLUGIN::m_eagleLayers
private

Eagle layers data stored by the layer number.

Definition at line 132 of file eagle_plugin.h.

Referenced by eagle_layer_name(), and loadLayerDefs().

int EAGLE_PLUGIN::m_hole_count
private

generates unique module names from eagle "hole"s.

Definition at line 138 of file eagle_plugin.h.

Referenced by init(), and loadPlain().

wxString EAGLE_PLUGIN::m_lib_path
private

Definition at line 154 of file eagle_plugin.h.

Referenced by cacheLib(), and loadLibrary().

int EAGLE_PLUGIN::m_min_trace
private

smallest trace we find on Load(), in BIU.

Definition at line 150 of file eagle_plugin.h.

Referenced by init(), Load(), and loadSignals().

int EAGLE_PLUGIN::m_min_via
private

smallest via we find on Load(), in BIU.

Definition at line 151 of file eagle_plugin.h.

Referenced by init(), Load(), and loadSignals().

int EAGLE_PLUGIN::m_min_via_hole
private

smallest via diameter hole we find on Load(), in BIU.

Definition at line 152 of file eagle_plugin.h.

Referenced by init(), Load(), and loadSignals().

wxDateTime EAGLE_PLUGIN::m_mod_time
private

Definition at line 155 of file eagle_plugin.h.

Referenced by cacheLib().

NET_MAP EAGLE_PLUGIN::m_pads_to_nets
private

net list

Definition at line 140 of file eagle_plugin.h.

Referenced by init(), loadElements(), and loadSignals().

const PROPERTIES* EAGLE_PLUGIN::m_props
private

passed via Save() or Load(), no ownership, may be NULL.

Definition at line 147 of file eagle_plugin.h.

Referenced by centerBoard(), and init().

ERULES* EAGLE_PLUGIN::m_rules
private

Eagle design rules.

Definition at line 134 of file eagle_plugin.h.

Referenced by init(), Load(), loadDesignRules(), loadSignals(), packagePad(), and ~EAGLE_PLUGIN().

MODULE_MAP EAGLE_PLUGIN::m_templates
private

is part of a MODULE factory that operates using copy construction.

lookup key is either libname.packagename or simply packagename if FootprintLoad() or FootprintEnumberate()

Definition at line 142 of file eagle_plugin.h.

Referenced by deleteTemplates(), FootprintEnumerate(), FootprintLoad(), loadElements(), and loadLibrary().

XPATH* EAGLE_PLUGIN::m_xpath
private

keeps track of what we are working on within XML document during a Load().

Definition at line 135 of file eagle_plugin.h.

Referenced by cacheLib(), init(), Load(), loadAllSections(), loadDesignRules(), loadElements(), loadLibraries(), loadLibrary(), loadPlain(), loadSignals(), and ~EAGLE_PLUGIN().


The documentation for this class was generated from the following files: