KiCad PCB EDA Suite
EAGLE_PLUGIN Class Reference

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 LAYER_REMAPPABLE_PLUGIN

Public Types

typedef int BIU
 

Public Member Functions

const wxString PluginName () const override
 Return a brief hard coded name for this PLUGIN. More...
 
BOARDLoad (const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
 Load information from some input file format that this PLUGIN implementation knows about into either a new BOARD or an existing one. More...
 
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints () override
 Return a container with the cached library footprints generated in the last call to Load. More...
 
const wxString GetFileExtension () const override
 Returns the file extension for the PLUGIN. More...
 
void FootprintEnumerate (wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const PROPERTIES *aProperties=nullptr) override
 Return a list of footprint names contained within the library at aLibraryPath. More...
 
FOOTPRINTFootprintLoad (const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const PROPERTIES *aProperties=nullptr) override
 Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about. More...
 
long long GetLibraryTimestamp (const wxString &aLibraryPath) const override
 Generate a timestamp representing all the files in the library (including the library directory). More...
 
bool IsFootprintLibWritable (const wxString &aLibraryPath) override
 Return true if the library at aLibraryPath is writable. More...
 
void FootprintLibOptions (PROPERTIES *aProperties) const override
 Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 
 EAGLE_PLUGIN ()
 
 ~EAGLE_PLUGIN ()
 
std::map< wxString, PCB_LAYER_IDDefaultLayerMappingCallback (const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
 Return the automapped layers. More...
 
virtual void SetQueryUserCallback (std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aAction)> aCallback)
 Registers a KIDIALOG callback for collecting info from the user. More...
 
virtual void Save (const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=nullptr)
 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 void PrefetchLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 If possible, prefetches the specified library (e.g. More...
 
virtual const FOOTPRINTGetEnumeratedFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr)
 A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management. More...
 
virtual bool FootprintExists (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr)
 Check for the existence of a footprint. More...
 
virtual void FootprintSave (const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const PROPERTIES *aProperties=nullptr)
 Write aFootprint to an existing library located at aLibraryPath. More...
 
virtual void FootprintDelete (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr)
 Delete aFootprintName from the library at aLibraryPath. More...
 
virtual void FootprintLibCreate (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Create a new empty footprint library at aLibraryPath empty. More...
 
virtual bool FootprintLibDelete (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Delete 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...
 
virtual void RegisterLayerMappingCallback (LAYER_MAPPING_HANDLER aLayerMappingHandler)
 Register a different handler to be called when mapping of input layers to KiCad layers occurs. More...
 

Protected Attributes

LAYER_MAPPING_HANDLER m_layer_mapping_handler
 Callback to get layer mapping. 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 checkpoint ()
 
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, int aTextThickness) const
 create a font size (fontz) from an eagle font size scalar and KiCad font thickness More...
 
void mapEagleLayersToKicad (bool aIsLibraryCache=false)
 Generate mapping between Eagle and KiCad layers. More...
 
PCB_LAYER_ID kicad_layer (int aLayer) const
 Convert an Eagle layer to a KiCad layer. More...
 
std::tuple< PCB_LAYER_ID, LSET, bool > defaultKicadLayer (int aEagleLayer, bool aIsLibraryCache=false) const
 Get the default KiCad layer corresponding to an Eagle layer of the board, a set of sensible layer mapping options and required flag. More...
 
const wxString & eagle_layer_name (int aLayer) const
 Get Eagle layer name by its number. More...
 
int eagle_layer_id (const wxString &aLayerName) const
 Get Eagle layer number by its name. 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 loadClasses (wxXmlNode *aClasses)
 
void loadSignals (wxXmlNode *aSignals)
 
void loadLibrary (wxXmlNode *aLib, const wxString *aLibName)
 Load 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)
 
ZONEloadPolygon (wxXmlNode *aPolyNode)
 Load a copper or keepout polygon and adds it to the board. More...
 
void orientFootprintAndText (FOOTPRINT *aFootprint, const EELEMENT &e, const EATTR *aNameAttr, const EATTR *aValueAttr)
 
void orientFPText (FOOTPRINT *aFootprint, const EELEMENT &e, FP_TEXT *aFPText, const EATTR *aAttr)
 
void centerBoard ()
 move the BOARD into the center of the page More...
 
FOOTPRINTmakeFootprint (wxXmlNode *aPackage, const wxString &aPkgName)
 Create a FOOTPRINT from an Eagle package. More...
 
void packageWire (FOOTPRINT *aFootprint, wxXmlNode *aTree) const
 
void packagePad (FOOTPRINT *aFootprint, wxXmlNode *aTree)
 
void packageText (FOOTPRINT *aFootprint, wxXmlNode *aTree) const
 
void packageRectangle (FOOTPRINT *aFootprint, wxXmlNode *aTree) const
 
void packagePolygon (FOOTPRINT *aFootprint, wxXmlNode *aTree) const
 
void packageCircle (FOOTPRINT *aFootprint, wxXmlNode *aTree) const
 
void packageHole (FOOTPRINT *aFootprint, wxXmlNode *aTree, bool aCenter) const
 
void packageSMD (FOOTPRINT *aFootprint, wxXmlNode *aTree) const
 Handles common pad properties. More...
 
void transferPad (const EPAD_COMMON &aEaglePad, PAD *aPad) const
 Deletes the footprint templates list. More...
 
void deleteTemplates ()
 

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 layer data stored by layer number. More...
 
std::map< wxString, int > m_eagleLayersIds
 Eagle layer ids stored by layer name. More...
 
std::map< wxString, PCB_LAYER_IDm_layer_map
 Map of Eagle layers to KiCad layers. More...
 
std::map< wxString, std::shared_ptr< NETCLASS > > m_classMap
 
wxString m_customRules
 
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 footprint names from eagle "hole"s. More...
 
NET_MAP m_pads_to_nets
 net list More...
 
FOOTPRINT_MAP m_templates
 is part of a FOOTPRINT 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...
 
PROGRESS_REPORTERm_progressReporter
 optional; may be nullptr More...
 
unsigned m_doneCount
 
unsigned m_lastProgressCount
 
unsigned m_totalCount
 for progress reporting More...
 
int m_min_trace
 smallest trace we find on Load(), in BIU. More...
 
int m_min_hole
 smallest diameter hole we find on Load(), in BIU. More...
 
int m_min_via
 smallest via we find on Load(), in BIU. More...
 
int m_min_annulus
 smallest via annulus we find on Load(), in BIU. More...
 
wxString m_lib_path
 
wxDateTime m_mod_time
 

Detailed Description

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

Definition at line 129 of file eagle_plugin.h.

Member Typedef Documentation

◆ BIU

typedef int EAGLE_PLUGIN::BIU

Definition at line 161 of file eagle_plugin.h.

◆ EITER

typedef ELAYERS::const_iterator EAGLE_PLUGIN::EITER
private

Definition at line 310 of file eagle_plugin.h.

◆ ELAYERS

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

Definition at line 309 of file eagle_plugin.h.

Constructor & Destructor Documentation

◆ EAGLE_PLUGIN()

EAGLE_PLUGIN::EAGLE_PLUGIN ( )

Definition at line 294 of file eagle_plugin.cpp.

294 :
295 m_rules( new ERULES() ),
296 m_xpath( new XPATH() ),
297 m_progressReporter( nullptr ),
298 m_doneCount( 0 ),
300 m_totalCount( 0 ),
301 m_mod_time( wxDateTime::Now() )
302{
303 using namespace std::placeholders;
304
305 init( nullptr );
306 clear_cu_map();
308 this, _1 ) );
309}
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
Definition: eagle_plugin.h:323
void clear_cu_map()
unsigned m_totalCount
for progress reporting
Definition: eagle_plugin.h:341
ERULES * m_rules
Eagle design rules.
Definition: eagle_plugin.h:322
unsigned m_doneCount
Definition: eagle_plugin.h:339
wxDateTime m_mod_time
Definition: eagle_plugin.h:349
std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
Return the automapped layers.
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
unsigned m_lastProgressCount
Definition: eagle_plugin.h:340
PROGRESS_REPORTER * m_progressReporter
optional; may be nullptr
Definition: eagle_plugin.h:338
virtual void RegisterLayerMappingCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler)
Register a different handler to be called when mapping of input layers to KiCad layers occurs.
Keep track of what we are working on within a PTREE.
Definition: eagle_parser.h:111
subset of eagle.drawing.board.designrules in the XML document
Definition: eagle_plugin.h:51

References clear_cu_map(), DefaultLayerMappingCallback(), init(), and LAYER_REMAPPABLE_PLUGIN::RegisterLayerMappingCallback().

◆ ~EAGLE_PLUGIN()

EAGLE_PLUGIN::~EAGLE_PLUGIN ( )

Definition at line 312 of file eagle_plugin.cpp.

313{
315 delete m_rules;
316 delete m_xpath;
317}
void deleteTemplates()

References deleteTemplates(), m_rules, and m_xpath.

Member Function Documentation

◆ cacheLib()

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

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

Definition at line 3149 of file eagle_plugin.cpp.

3150{
3151 try
3152 {
3153 wxDateTime modtime = getModificationTime( aLibPath );
3154
3155 // Fixes assertions in wxWidgets debug builds for the wxDateTime object. Refresh the
3156 // cache if either of the wxDateTime objects are invalid or the last file modification
3157 // time differs from the current file modification time.
3158 bool load = !m_mod_time.IsValid() || !modtime.IsValid() || m_mod_time != modtime;
3159
3160 if( aLibPath != m_lib_path || load )
3161 {
3162 wxXmlNode* doc;
3163 LOCALE_IO toggle; // toggles on, then off, the C locale.
3164
3166
3167 // Set this before completion of loading, since we rely on it for
3168 // text of an exception. Delay setting m_mod_time until after successful load
3169 // however.
3170 m_lib_path = aLibPath;
3171
3172 // 8 bit "filename" should be encoded according to disk filename encoding,
3173 // (maybe this is current locale, maybe not, its a filesystem issue),
3174 // and is not necessarily utf8.
3175 string filename = (const char*) aLibPath.char_str( wxConvFile );
3176
3177 // Load the document
3178 wxFileName fn( filename );
3179 wxFFileInputStream stream( fn.GetFullPath() );
3180 wxXmlDocument xmlDocument;
3181
3182 if( !stream.IsOk() || !xmlDocument.Load( stream ) )
3183 {
3184 THROW_IO_ERROR( wxString::Format( _( "Unable to read file '%s'." ),
3185 fn.GetFullPath() ) );
3186 }
3187
3188 doc = xmlDocument.GetRoot();
3189
3190 wxXmlNode* drawing = MapChildren( doc )["drawing"];
3191 NODE_MAP drawingChildren = MapChildren( drawing );
3192
3193 // clear the cu map and then rebuild it.
3194 clear_cu_map();
3195
3196 m_xpath->push( "eagle.drawing.layers" );
3197 wxXmlNode* layers = drawingChildren["layers"];
3198 loadLayerDefs( layers );
3199 mapEagleLayersToKicad( true );
3200 m_xpath->pop();
3201
3202 m_xpath->push( "eagle.drawing.library" );
3203 wxXmlNode* library = drawingChildren["library"];
3204 loadLibrary( library, nullptr );
3205 m_xpath->pop();
3206
3207 m_mod_time = modtime;
3208 }
3209 }
3210 catch(...){}
3211 // TODO: Handle exceptions
3212 // catch( file_parser_error fpe )
3213 // {
3214 // // for xml_parser_error, what() has the line number in it,
3215 // // but no byte offset. That should be an adequate error message.
3216 // THROW_IO_ERROR( fpe.what() );
3217 // }
3218 //
3219 // // Class ptree_error is a base class for xml_parser_error & file_parser_error,
3220 // // so one catch should be OK for all errors.
3221 // catch( ptree_error pte )
3222 // {
3223 // string errmsg = pte.what();
3224 //
3225 // errmsg += " @\n";
3226 // errmsg += m_xpath->Contents();
3227 //
3228 // THROW_IO_ERROR( errmsg );
3229 // }
3230}
static wxDateTime getModificationTime(const wxString &aPath)
get a file's or dir's modification time.
wxString m_lib_path
Definition: eagle_plugin.h:348
void mapEagleLayersToKicad(bool aIsLibraryCache=false)
Generate mapping between Eagle and KiCad layers.
void loadLibrary(wxXmlNode *aLib, const wxString *aLibName)
Load the Eagle "library" XML element, which can occur either under a "libraries" element (if a *....
void loadLayerDefs(wxXmlNode *aLayers)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
void pop()
Definition: eagle_parser.h:122
void push(const char *aPathSegment, const char *aAttribute="")
Definition: eagle_parser.h:115
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:49
#define _(s)
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

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

Referenced by FootprintEnumerate(), and FootprintLoad().

◆ centerBoard()

void EAGLE_PLUGIN::centerBoard ( )
private

move the BOARD into the center of the page

Definition at line 3110 of file eagle_plugin.cpp.

3111{
3112 if( m_props )
3113 {
3114 UTF8 page_width;
3115 UTF8 page_height;
3116
3117 if( m_props->Value( "page_width", &page_width ) &&
3118 m_props->Value( "page_height", &page_height ) )
3119 {
3121
3122 int w = atoi( page_width.c_str() );
3123 int h = atoi( page_height.c_str() );
3124
3125 int desired_x = ( w - bbbox.GetWidth() ) / 2;
3126 int desired_y = ( h - bbbox.GetHeight() ) / 2;
3127
3128 m_board->Move( VECTOR2I( desired_x - bbbox.GetX(), desired_y - bbbox.GetY() ) );
3129 }
3130 }
3131}
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:821
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: board.cpp:326
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetY() const
Definition: box2.h:181
coord_type GetWidth() const
Definition: box2.h:187
coord_type GetX() const
Definition: box2.h:180
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
Definition: eagle_plugin.h:335
BOARD * m_board
which BOARD is being worked on, no ownership here
Definition: eagle_plugin.h:336
bool Value(const char *aName, UTF8 *aFetchedValue=nullptr) const
Fetch a property by aName and returns true if that property was found, else false.
Definition: properties.cpp:24
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:71
const char * c_str() const
Definition: utf8.h:102
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References UTF8::c_str(), BOARD::GetBoardEdgesBoundingBox(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), m_board, m_props, BOARD::Move(), and PROPERTIES::Value().

Referenced by Load().

◆ checkpoint()

void EAGLE_PLUGIN::checkpoint ( )
private

Definition at line 332 of file eagle_plugin.cpp.

333{
334 const unsigned PROGRESS_DELTA = 50;
335
337 {
338 if( ++m_doneCount > m_lastProgressCount + PROGRESS_DELTA )
339 {
341 / std::max( 1U, m_totalCount ) );
342
344 THROW_IO_ERROR( _( "Open cancelled by user." ) );
345
347 }
348 }
349}
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).

References _, PROGRESS_REPORTER::KeepRefreshing(), m_doneCount, m_lastProgressCount, m_progressReporter, m_totalCount, PROGRESS_REPORTER::SetCurrentProgress(), and THROW_IO_ERROR.

Referenced by loadClasses(), loadDesignRules(), loadElements(), loadLibrary(), loadPlain(), and loadSignals().

◆ clear_cu_map()

void EAGLE_PLUGIN::clear_cu_map ( )
private

Definition at line 523 of file eagle_plugin.cpp.

524{
525 // All cu layers are invalid until we see them in the <layers> section while
526 // loading either a board or library. See loadLayerDefs().
527 for( unsigned i = 0; i < arrayDim(m_cu_map); ++i )
528 m_cu_map[i] = -1;
529}
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
int m_cu_map[17]
map eagle to KiCad, cu layers only.
Definition: eagle_plugin.h:312

References arrayDim(), and m_cu_map.

Referenced by cacheLib(), and EAGLE_PLUGIN().

◆ defaultKicadLayer()

std::tuple< PCB_LAYER_ID, LSET, bool > EAGLE_PLUGIN::defaultKicadLayer ( int  aEagleLayer,
bool  aIsLibraryCache = false 
) const
private

Get the default KiCad layer corresponding to an Eagle layer of the board, a set of sensible layer mapping options and required flag.

Note
The Eagle MILLING, TTEST, BTEST, and HOLES layers are set to UNDEFINED_LAYER for historical purposes. All other Eagle layers that do not directly map to KiCad layers will be set to UNDEFINED_LAYER when loading Eagle footprint libraries. This should be addressed in the future because in some cases this will cause data loss.
See also
EAGLE_LAYER and defaultKiCadLayer().
Parameters
aEagleLayeris the Eagle layer to map.
aIsLibraryCacheis a flag to indicate if the mapping is for board or footprint library cache objects.
Returns
a tuple containing the mapped layer.

Definition at line 2960 of file eagle_plugin.cpp.

2962{
2963 // eagle copper layer:
2964 if( aEagleLayer >= 1 && aEagleLayer < int( arrayDim( m_cu_map ) ) )
2965 {
2966 LSET copperLayers;
2967
2968 for( int copperLayer : m_cu_map )
2969 {
2970 if( copperLayer >= 0 )
2971 copperLayers[copperLayer] = true;
2972 }
2973
2974 return { PCB_LAYER_ID( m_cu_map[aEagleLayer] ), copperLayers, true };
2975 }
2976
2977 int kiLayer = UNSELECTED_LAYER;
2978 bool required = false;
2979 LSET permittedLayers;
2980
2981 permittedLayers.set();
2982
2983 // translate non-copper eagle layer to pcbnew layer
2984 switch( aEagleLayer )
2985 {
2986 // Eagle says "Dimension" layer, but it's for board perimeter
2988 kiLayer = Edge_Cuts;
2989 required = true;
2990 permittedLayers = LSET( 1, Edge_Cuts );
2991 break;
2992
2994 kiLayer = F_SilkS;
2995 break;
2997 kiLayer = B_SilkS;
2998 break;
3000 kiLayer = F_SilkS;
3001 break;
3003 kiLayer = B_SilkS;
3004 break;
3006 kiLayer = F_Fab;
3007 break;
3009 kiLayer = B_Fab;
3010 break;
3011 case EAGLE_LAYER::TSTOP:
3012 kiLayer = F_Mask;
3013 break;
3014 case EAGLE_LAYER::BSTOP:
3015 kiLayer = B_Mask;
3016 break;
3018 kiLayer = F_Paste;
3019 break;
3021 kiLayer = B_Paste;
3022 break;
3024 kiLayer = F_Mask;
3025 break;
3027 kiLayer = B_Mask;
3028 break;
3029 case EAGLE_LAYER::TGLUE:
3030 kiLayer = F_Adhes;
3031 break;
3032 case EAGLE_LAYER::BGLUE:
3033 kiLayer = B_Adhes;
3034 break;
3036 kiLayer = Cmts_User;
3037 break;
3039 kiLayer = Cmts_User;
3040 break;
3042 kiLayer = Cmts_User;
3043 break;
3044
3045 // Packages show the future chip pins on SMD parts using layer 51.
3046 // This is an area slightly smaller than the PAD/SMD copper area.
3047 // Carry those visual aids into the FOOTPRINT on the fabrication layer,
3048 // not silkscreen. This is perhaps not perfect, but there is not a lot
3049 // of other suitable paired layers
3050 case EAGLE_LAYER::TDOCU:
3051 kiLayer = F_Fab;
3052 break;
3053 case EAGLE_LAYER::BDOCU:
3054 kiLayer = B_Fab;
3055 break;
3056
3057 // these layers are defined as user layers. put them on ECO layers
3059 kiLayer = Eco1_User;
3060 break;
3062 kiLayer = Eco2_User;
3063 break;
3064
3065 // these will also appear in the ratsnest, so there's no need for a warning
3067 kiLayer = Dwgs_User;
3068 break;
3069
3071 kiLayer = F_CrtYd;
3072 break;
3074 kiLayer = B_CrtYd;
3075 break;
3076
3078 case EAGLE_LAYER::TTEST:
3079 case EAGLE_LAYER::BTEST:
3080 case EAGLE_LAYER::HOLES:
3081 default:
3082 if( aIsLibraryCache )
3083 kiLayer = UNDEFINED_LAYER;
3084 else
3085 kiLayer = UNSELECTED_LAYER;
3086
3087 break;
3088 }
3089
3090 return { PCB_LAYER_ID( kiLayer ), permittedLayers, required };
3091}
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ F_CrtYd
Definition: layer_ids.h:117
@ B_Adhes
Definition: layer_ids.h:97
@ Edge_Cuts
Definition: layer_ids.h:113
@ Dwgs_User
Definition: layer_ids.h:109
@ F_Paste
Definition: layer_ids.h:101
@ Cmts_User
Definition: layer_ids.h:110
@ F_Adhes
Definition: layer_ids.h:98
@ B_Mask
Definition: layer_ids.h:106
@ Eco1_User
Definition: layer_ids.h:111
@ F_Mask
Definition: layer_ids.h:107
@ B_Paste
Definition: layer_ids.h:100
@ UNSELECTED_LAYER
Definition: layer_ids.h:61
@ F_Fab
Definition: layer_ids.h:120
@ F_SilkS
Definition: layer_ids.h:104
@ B_CrtYd
Definition: layer_ids.h:116
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ Eco2_User
Definition: layer_ids.h:112
@ B_SilkS
Definition: layer_ids.h:103
@ B_Fab
Definition: layer_ids.h:119

References arrayDim(), B_Adhes, B_CrtYd, 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, EAGLE_LAYER::DIMENSION, EAGLE_LAYER::DOCUMENT, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_CrtYd, F_Fab, F_Mask, F_Paste, F_SilkS, 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, UNDEFINED_LAYER, EAGLE_LAYER::UNROUTED, UNSELECTED_LAYER, EAGLE_LAYER::USERLAYER1, and EAGLE_LAYER::USERLAYER2.

Referenced by DefaultLayerMappingCallback(), and mapEagleLayersToKicad().

◆ DefaultLayerMappingCallback()

std::map< wxString, PCB_LAYER_ID > EAGLE_PLUGIN::DefaultLayerMappingCallback ( const std::vector< INPUT_LAYER_DESC > &  aInputLayerDescriptionVector)

Return the automapped layers.

The callback needs to have the context of the current board so it can correctly determine copper layer mapping. Thus, it is not static and is expected to be bind to an instance of EAGLE_PLUGIN.

Parameters
aInputLayerDescriptionVector
Returns
Auto-mapped layers

Definition at line 2908 of file eagle_plugin.cpp.

2910{
2911 std::map<wxString, PCB_LAYER_ID> layer_map;
2912
2913 for ( const INPUT_LAYER_DESC& layer : aInputLayerDescriptionVector )
2914 {
2915 PCB_LAYER_ID layerId = std::get<0>( defaultKicadLayer( eagle_layer_id( layer.Name ) ) );
2916 layer_map.emplace( layer.Name, layerId );
2917 }
2918
2919 return layer_map;
2920}
std::tuple< PCB_LAYER_ID, LSET, bool > defaultKicadLayer(int aEagleLayer, bool aIsLibraryCache=false) const
Get the default KiCad layer corresponding to an Eagle layer of the board, a set of sensible layer map...
int eagle_layer_id(const wxString &aLayerName) const
Get Eagle layer number by its name.
Describes an imported layer and how it could be mapped to KiCad Layers.

References defaultKicadLayer(), and eagle_layer_id().

Referenced by EAGLE_PLUGIN().

◆ deleteTemplates()

void EAGLE_PLUGIN::deleteTemplates ( )
private

Definition at line 2562 of file eagle_plugin.cpp.

2563{
2564 for( auto& t : m_templates )
2565 delete t.second;
2566
2567 m_templates.clear();
2568}
FOOTPRINT_MAP m_templates
is part of a FOOTPRINT factory that operates using copy construction.
Definition: eagle_plugin.h:330

References m_templates.

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

◆ eagle_layer_id()

int EAGLE_PLUGIN::eagle_layer_id ( const wxString &  aLayerName) const
private

Get Eagle layer number by its name.

Definition at line 3102 of file eagle_plugin.cpp.

3103{
3104 static const int unknown = -1;
3105 auto it = m_eagleLayersIds.find( aLayerName );
3106 return it == m_eagleLayersIds.end() ? unknown : it->second;
3107}
std::map< wxString, int > m_eagleLayersIds
Eagle layer ids stored by layer name.
Definition: eagle_plugin.h:314

References m_eagleLayersIds, and unknown.

Referenced by DefaultLayerMappingCallback().

◆ eagle_layer_name()

const wxString & EAGLE_PLUGIN::eagle_layer_name ( int  aLayer) const
private

Get Eagle layer name by its number.

Definition at line 3094 of file eagle_plugin.cpp.

3095{
3096 static const wxString unknown( "unknown" );
3097 auto it = m_eagleLayers.find( aLayer );
3098 return it == m_eagleLayers.end() ? unknown : it->second.name;
3099}
std::map< int, ELAYER > m_eagleLayers
Eagle layer data stored by layer number.
Definition: eagle_plugin.h:313

References m_eagleLayers, and unknown.

Referenced by kicad_layer(), loadPolygon(), packageCircle(), packagePolygon(), packageRectangle(), packageText(), and packageWire().

◆ FootprintDelete()

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

Delete 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 GPCB_PLUGIN, and PCB_PLUGIN.

Definition at line 116 of file plugin.cpp.

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

References not_implemented().

Referenced by FP_LIB_TABLE::FootprintDelete().

◆ FootprintEnumerate()

void EAGLE_PLUGIN::FootprintEnumerate ( wxArrayString &  aFootprintNames,
const wxString &  aLibraryPath,
bool  aBestEfforts,
const PROPERTIES aProperties = nullptr 
)
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.
aBestEffortsif true, don't throw on errors, just return an empty list.
Exceptions
IO_ERRORif the library cannot be found, or footprint cannot be loaded.

Reimplemented from PLUGIN.

Definition at line 3233 of file eagle_plugin.cpp.

3235{
3236 wxString errorMsg;
3237
3238 init( aProperties );
3239
3240 try
3241 {
3242 cacheLib( aLibraryPath );
3243 }
3244 catch( const IO_ERROR& ioe )
3245 {
3246 errorMsg = ioe.What();
3247 }
3248
3249 // Some of the files may have been parsed correctly so we want to add the valid files to
3250 // the library.
3251
3252 for( FOOTPRINT_MAP::const_iterator it = m_templates.begin(); it != m_templates.end(); ++it )
3253 aFootprintNames.Add( it->first );
3254
3255 if( !errorMsg.IsEmpty() && !aBestEfforts )
3256 THROW_IO_ERROR( errorMsg );
3257}
void cacheLib(const wxString &aLibraryPath)
This PLUGIN only caches one footprint library, this determines which one.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30

References cacheLib(), init(), m_templates, THROW_IO_ERROR, and IO_ERROR::What().

◆ FootprintExists()

bool PLUGIN::FootprintExists ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Check for the existence of a footprint.

Reimplemented in PCB_PLUGIN.

Definition at line 89 of file plugin.cpp.

91{
92 // default implementation
93 return FootprintLoad( aLibraryPath, aFootprintName, true, aProperties ) != nullptr;
94}
virtual FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const PROPERTIES *aProperties=nullptr)
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
Definition: plugin.cpp:97

References PLUGIN::FootprintLoad().

Referenced by FP_LIB_TABLE::FootprintExists().

◆ FootprintLibCreate()

void PLUGIN::FootprintLibCreate ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Create 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 PCB_PLUGIN.

Definition at line 124 of file plugin.cpp.

125{
126 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
127 not_implemented( this, __FUNCTION__ );
128}

References not_implemented().

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

◆ FootprintLibDelete()

bool PLUGIN::FootprintLibDelete ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Delete 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
true if library deleted, false if library did not exist.
Exceptions
IO_ERRORif there is a problem deleting an existing library.

Reimplemented in GPCB_PLUGIN, PCB_PLUGIN, and LEGACY_PLUGIN.

Definition at line 131 of file plugin.cpp.

132{
133 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
134 not_implemented( this, __FUNCTION__ );
135 return false;
136}

References not_implemented().

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

◆ FootprintLibOptions()

void EAGLE_PLUGIN::FootprintLibOptions ( PROPERTIES aListToAppendTo) const
overridevirtual

Append 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
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 3278 of file eagle_plugin.cpp.

3279{
3280 PLUGIN::FootprintLibOptions( aListToAppendTo );
3281}
virtual void FootprintLibOptions(PROPERTIES *aListToAppendTo) const
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
Definition: plugin.cpp:147

References PLUGIN::FootprintLibOptions().

◆ FootprintLoad()

FOOTPRINT * EAGLE_PLUGIN::FootprintLoad ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
bool  aKeepUUID = false,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Load 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.
aKeepUUID= true to keep initial items UUID, false to set new UUID normally true if loaded in the footprint editor, false if loaded in the board editor. Make sense only in kicad_plugin
Returns
the FOOTPRINT object 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 3260 of file eagle_plugin.cpp.

3263{
3264 init( aProperties );
3265 cacheLib( aLibraryPath );
3266 FOOTPRINT_MAP::const_iterator it = m_templates.find( aFootprintName );
3267
3268 if( it == m_templates.end() )
3269 return nullptr;
3270
3271 // Return a copy of the template
3272 FOOTPRINT* copy = (FOOTPRINT*) it->second->Duplicate();
3273 copy->SetParent( nullptr );
3274 return copy;
3275}

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

◆ FootprintSave()

void PLUGIN::FootprintSave ( const wxString &  aLibraryPath,
const FOOTPRINT aFootprint,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Write aFootprint 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 PCB_PLUGIN.

Definition at line 108 of file plugin.cpp.

110{
111 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
112 not_implemented( this, __FUNCTION__ );
113}

References not_implemented().

Referenced by PCB_EDIT_FRAME::ExportFootprintsToLibrary(), FP_LIB_TABLE::FootprintSave(), PCB_EDIT_FRAME::OpenProjectFiles(), and FOOTPRINT_EDIT_FRAME::SaveLibraryAs().

◆ GetEnumeratedFootprint()

const FOOTPRINT * PLUGIN::GetEnumeratedFootprint ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.

Reimplemented in GPCB_PLUGIN, and PCB_PLUGIN.

Definition at line 80 of file plugin.cpp.

83{
84 // default implementation
85 return FootprintLoad( aLibraryPath, aFootprintName, false, aProperties );
86}

References PLUGIN::FootprintLoad().

Referenced by FP_LIB_TABLE::GetEnumeratedFootprint(), and FOOTPRINT_EDIT_FRAME::SaveLibraryAs().

◆ GetFileExtension()

const wxString EAGLE_PLUGIN::GetFileExtension ( ) const
overridevirtual

Returns the file extension for the PLUGIN.

Implements PLUGIN.

Definition at line 326 of file eagle_plugin.cpp.

327{
328 return wxT( "brd" );
329}

◆ GetImportedCachedLibraryFootprints()

std::vector< FOOTPRINT * > EAGLE_PLUGIN::GetImportedCachedLibraryFootprints ( )
overridevirtual

Return a container with the cached library footprints generated in the last call to Load.

This function is intended to be used ONLY by the non-KiCad board importers for the purpose of obtaining the footprint library of the design and creating a project-specific library.

Returns
Footprints (caller owns the objects)

Reimplemented from PLUGIN.

Definition at line 493 of file eagle_plugin.cpp.

494{
495 std::vector<FOOTPRINT*> retval;
496
497 for( std::pair<wxString, FOOTPRINT*> fp : m_templates )
498 retval.push_back( static_cast<FOOTPRINT*>( fp.second->Clone() ) );
499
500 return retval;
501}

References m_templates.

◆ GetLibraryTimestamp()

long long EAGLE_PLUGIN::GetLibraryTimestamp ( const wxString &  aLibraryPath) const
inlineoverridevirtual

Generate a timestamp representing all the files in the library (including the library directory).

Timestamps should not be considered ordered, they either match or they don't.

Implements PLUGIN.

Definition at line 149 of file eagle_plugin.h.

150 {
151 return getModificationTime( aLibraryPath ).GetValue().GetValue();
152 }

References getModificationTime().

◆ getModificationTime()

wxDateTime EAGLE_PLUGIN::getModificationTime ( const wxString &  aPath)
staticprivate

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

Definition at line 3134 of file eagle_plugin.cpp.

3135{
3136 // File hasn't been loaded yet.
3137 if( aPath.IsEmpty() )
3138 return wxDateTime::Now();
3139
3140 wxFileName fn( aPath );
3141
3142 if( fn.IsFileReadable() )
3143 return fn.GetModificationTime();
3144 else
3145 return wxDateTime( 0.0 );
3146}

Referenced by cacheLib(), and GetLibraryTimestamp().

◆ init()

void EAGLE_PLUGIN::init ( const PROPERTIES aProperties)
private

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

Definition at line 504 of file eagle_plugin.cpp.

505{
506 m_hole_count = 0;
507 m_min_trace = 0;
508 m_min_hole = 0;
509 m_min_via = 0;
510 m_min_annulus = 0;
511 m_xpath->clear();
512 m_pads_to_nets.clear();
513
514 m_board = nullptr;
515 m_props = aProperties;
516
517
518 delete m_rules;
519 m_rules = new ERULES();
520}
int m_hole_count
generates unique footprint names from eagle "hole"s.
Definition: eagle_plugin.h:326
int m_min_annulus
smallest via annulus we find on Load(), in BIU.
Definition: eagle_plugin.h:346
NET_MAP m_pads_to_nets
net list
Definition: eagle_plugin.h:328
int m_min_trace
smallest trace we find on Load(), in BIU.
Definition: eagle_plugin.h:343
int m_min_via
smallest via we find on Load(), in BIU.
Definition: eagle_plugin.h:345
int m_min_hole
smallest diameter hole we find on Load(), in BIU.
Definition: eagle_plugin.h:344
void clear()
Definition: eagle_parser.h:120

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

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

◆ IsFootprintLibWritable()

bool EAGLE_PLUGIN::IsFootprintLibWritable ( const wxString &  aLibraryPath)
inlineoverridevirtual

Return true if the library at aLibraryPath is writable.

The system libraries are typically 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 154 of file eagle_plugin.h.

155 {
156 return false; // until someone writes others like FootprintSave(), etc.
157 }

◆ kicad_fontz()

wxSize EAGLE_PLUGIN::kicad_fontz ( const ECOORD d,
int  aTextThickness 
) const
inlineprivate

create a font size (fontz) from an eagle font size scalar and KiCad font thickness

Definition at line 352 of file eagle_plugin.cpp.

353{
354 // Eagle includes stroke thickness in the text size, KiCAD does not
355 int kz = d.ToPcbUnits();
356 return wxSize( kz - aTextThickness, kz - aTextThickness );
357}
int ToPcbUnits() const
Definition: eagle_parser.h:430

References ECOORD::ToPcbUnits().

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

◆ kicad_layer()

PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer ( int  aLayer) const
private

Convert an Eagle layer to a KiCad layer.

Definition at line 2953 of file eagle_plugin.cpp.

2954{
2955 auto result = m_layer_map.find( eagle_layer_name( aEagleLayer ) );
2956 return result == m_layer_map.end() ? UNDEFINED_LAYER : result->second;
2957}
const wxString & eagle_layer_name(int aLayer) const
Get Eagle layer name by its number.
std::map< wxString, PCB_LAYER_ID > m_layer_map
Map of Eagle layers to KiCad layers.
Definition: eagle_plugin.h:315

References eagle_layer_name(), m_layer_map, and UNDEFINED_LAYER.

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

◆ kicad_x()

int EAGLE_PLUGIN::kicad_x ( const ECOORD x) const
inlineprivate

◆ kicad_y()

int EAGLE_PLUGIN::kicad_y ( const ECOORD y) const
inlineprivate

Convert an Eagle distance to a KiCad distance.

Definition at line 188 of file eagle_plugin.h.

188{ return -y.ToPcbUnits(); }

References ECOORD::ToPcbUnits().

Referenced by loadElements(), loadPlain(), loadPolygon(), loadSignals(), orientFPText(), packageCircle(), packageHole(), packagePolygon(), packageRectangle(), packageText(), packageWire(), and transferPad().

◆ Load()

BOARD * EAGLE_PLUGIN::Load ( const wxString &  aFileName,
BOARD aAppendToMe,
const PROPERTIES aProperties = nullptr,
PROJECT aProject = nullptr,
PROGRESS_REPORTER aProgressReporter = nullptr 
)
overridevirtual

Load 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.
aProjectis the optional PROJECT object primarily used by third party importers.
aProgressReporteran optional progress reporter
aLineCounta line count (necessary if a progress reporter is supplied)
Returns
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 360 of file eagle_plugin.cpp.

363{
364 LOCALE_IO toggle; // toggles on, then off, the C locale.
365 wxXmlNode* doc;
366
367 init( aProperties );
368
369 m_board = aAppendToMe ? aAppendToMe : new BOARD();
370 m_progressReporter = aProgressReporter;
371
372 // Give the filename to the board if it's new
373 if( !aAppendToMe )
374 m_board->SetFileName( aFileName );
375
376 // delete on exception, if I own m_board, according to aAppendToMe
377 unique_ptr<BOARD> deleter( aAppendToMe ? nullptr : m_board );
378
379 try
380 {
382 {
383 m_progressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
384
386 THROW_IO_ERROR( _( "Open cancelled by user." ) );
387 }
388
389 wxFileName fn = aFileName;
390
391 // Load the document
392 wxFFileInputStream stream( fn.GetFullPath() );
393 wxXmlDocument xmlDocument;
394
395 if( !stream.IsOk() || !xmlDocument.Load( stream ) )
396 {
397 THROW_IO_ERROR( wxString::Format( _( "Unable to read file '%s'" ),
398 fn.GetFullPath() ) );
399 }
400
401 doc = xmlDocument.GetRoot();
402
403 m_min_trace = INT_MAX;
404 m_min_hole = INT_MAX;
405 m_min_via = INT_MAX;
406 m_min_annulus = INT_MAX;
407
408 loadAllSections( doc );
409
411
412 if( m_min_trace < bds.m_TrackMinWidth )
414
415 if( m_min_via < bds.m_ViasMinSize )
417
418 if( m_min_hole < bds.m_MinThroughDrill )
420
423
424 if( m_rules->mdWireWire )
426
427 NETCLASS defaults( wxT( "dummy" ) );
428
429 auto finishNetclass =
430 [&]( std::shared_ptr<NETCLASS> netclass )
431 {
432 // If Eagle has a clearance matrix then we'll build custom rules from that.
433 // Netclasses should just be the board minimum clearance.
434 netclass->SetClearance( KiROUND( bds.m_MinClearance ) );
435
436 if( netclass->GetTrackWidth() == INT_MAX )
437 netclass->SetTrackWidth( defaults.GetTrackWidth() );
438
439 if( netclass->GetViaDiameter() == INT_MAX )
440 netclass->SetViaDiameter( defaults.GetViaDiameter() );
441
442 if( netclass->GetViaDrill() == INT_MAX )
443 netclass->SetViaDrill( defaults.GetViaDrill() );
444 };
445
446 std::shared_ptr<NET_SETTINGS>& netSettings = bds.m_NetSettings;
447
448 finishNetclass( netSettings->m_DefaultNetClass );
449
450 for( const auto& [ name, netclass ] : netSettings->m_NetClasses )
451 finishNetclass( netclass );
452
455
456 fn.SetExt( wxT( "kicad_dru" ) );
457 wxFile rulesFile( fn.GetFullPath(), wxFile::write );
458 rulesFile.Write( m_customRules );
459
460 // should be empty, else missing m_xpath->pop()
461 wxASSERT( m_xpath->Contents().size() == 0 );
462 }
463 catch( const XML_PARSER_ERROR &exc )
464 {
465 wxString errmsg = exc.what();
466
467 errmsg += wxT( "\[email protected] " );
468 errmsg += m_xpath->Contents();
469
470 THROW_IO_ERROR( errmsg );
471 }
472
473 // IO_ERROR exceptions are left uncaught, they pass upwards from here.
474
475 // Ensure the copper layers count is a multiple of 2
476 // Pcbnew does not like boards with odd layers count
477 // (these boards cannot exist. they actually have a even layers count)
478 int lyrcnt = m_board->GetCopperLayerCount();
479
480 if( (lyrcnt % 2) != 0 )
481 {
482 lyrcnt++;
483 m_board->SetCopperLayerCount( lyrcnt );
484 }
485
486 centerBoard();
487
488 deleter.release();
489 return m_board;
490}
const char * name
Definition: DXF_plotter.cpp:56
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
Definition: board.h:342
void SetFileName(const wxString &aFileName)
Definition: board.h:300
int GetCopperLayerCount() const
Definition: board.cpp:488
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
Definition: board.h:346
void SetCopperLayerCount(int aCount)
Definition: board.cpp:494
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:617
void loadAllSections(wxXmlNode *aDocument)
wxString m_customRules
Definition: eagle_plugin.h:320
void centerBoard()
move the BOARD into the center of the page
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:47
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
wxString Contents()
return the contents of the XPATH as a single string
Definition: eagle_parser.h:137
double mdWireWire
wire to wire spacing I presume.
Definition: eagle_plugin.h:121
Implement a simple wrapper around runtime_error to isolate the errors thrown by the Eagle XML parser.
Definition: eagle_parser.h:69
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:80

References _, centerBoard(), XPATH::Contents(), Format(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), NETCLASS::GetTrackWidth(), NETCLASS::GetViaDiameter(), NETCLASS::GetViaDrill(), init(), PROGRESS_REPORTER::KeepRefreshing(), KiROUND(), loadAllSections(), m_board, m_customRules, BOARD::m_LegacyDesignSettingsLoaded, BOARD::m_LegacyNetclassesLoaded, m_min_annulus, m_min_hole, m_min_trace, m_min_via, BOARD_DESIGN_SETTINGS::m_MinClearance, BOARD_DESIGN_SETTINGS::m_MinThroughDrill, BOARD_DESIGN_SETTINGS::m_NetSettings, m_progressReporter, m_rules, BOARD_DESIGN_SETTINGS::m_TrackMinWidth, BOARD_DESIGN_SETTINGS::m_ViasMinAnnularWidth, BOARD_DESIGN_SETTINGS::m_ViasMinSize, m_xpath, ERULES::mdWireWire, name, PROGRESS_REPORTER::Report(), BOARD::SetCopperLayerCount(), BOARD::SetFileName(), and THROW_IO_ERROR.

◆ loadAllSections()

void EAGLE_PLUGIN::loadAllSections ( wxXmlNode *  aDocument)
private

Definition at line 532 of file eagle_plugin.cpp.

533{
534 wxXmlNode* drawing = MapChildren( aDoc )["drawing"];
535 NODE_MAP drawingChildren = MapChildren( drawing );
536
537 wxXmlNode* board = drawingChildren["board"];
538 NODE_MAP boardChildren = MapChildren( board );
539
540 auto count_children = [this]( wxXmlNode* aNode )
541 {
542 if( aNode )
543 {
544 wxXmlNode* child = aNode->GetChildren();
545
546 while( child )
547 {
548 m_totalCount++;
549 child = child->GetNext();
550 }
551 }
552 };
553
554 wxXmlNode* designrules = boardChildren["designrules"];
555 wxXmlNode* layers = drawingChildren["layers"];
556 wxXmlNode* plain = boardChildren["plain"];
557 wxXmlNode* classes = boardChildren["classes"];
558 wxXmlNode* signals = boardChildren["signals"];
559 wxXmlNode* libs = boardChildren["libraries"];
560 wxXmlNode* elems = boardChildren["elements"];
561
563 {
564 m_totalCount = 0;
565 m_doneCount = 0;
566
567 count_children( designrules );
568 count_children( layers );
569 count_children( plain );
570 count_children( signals );
571 count_children( elems );
572
573 while( libs )
574 {
575 count_children( MapChildren( libs )["packages"] );
576 libs = libs->GetNext();
577 }
578
579 // Rewind
580 libs = boardChildren["libraries"];
581 }
582
583 m_xpath->push( "eagle.drawing" );
584
585 {
586 m_xpath->push( "board" );
587
588 loadDesignRules( designrules );
589
590 m_xpath->pop();
591 }
592
593 {
594 m_xpath->push( "layers" );
595
596 loadLayerDefs( layers );
598
599 m_xpath->pop();
600 }
601
602 {
603 m_xpath->push( "board" );
604
605 loadPlain( plain );
606 loadClasses( classes );
607 loadSignals( signals );
608 loadLibraries( libs );
609 loadElements( elems );
610
611 m_xpath->pop();
612 }
613
614 m_xpath->pop(); // "eagle.drawing"
615}
void loadPlain(wxXmlNode *aPlain)
void loadLibraries(wxXmlNode *aLibs)
void loadDesignRules(wxXmlNode *aDesignRules)
void loadSignals(wxXmlNode *aSignals)
void loadClasses(wxXmlNode *aClasses)
void loadElements(wxXmlNode *aElements)

References loadClasses(), loadDesignRules(), loadElements(), loadLayerDefs(), loadLibraries(), loadPlain(), loadSignals(), m_doneCount, m_progressReporter, m_totalCount, m_xpath, MapChildren(), mapEagleLayersToKicad(), XPATH::pop(), and XPATH::push().

Referenced by Load().

◆ loadClasses()

void EAGLE_PLUGIN::loadClasses ( wxXmlNode *  aClasses)
private

Definition at line 2571 of file eagle_plugin.cpp.

2572{
2574
2575 m_xpath->push( "classes.class", "number" );
2576
2577 std::vector<ECLASS> eClasses;
2578 wxXmlNode* classNode = aClasses->GetChildren();
2579
2580 while( classNode )
2581 {
2582 checkpoint();
2583
2584 ECLASS eClass( classNode );
2585 std::shared_ptr<NETCLASS> netclass;
2586
2587 if( eClass.name.CmpNoCase( wxT( "default" ) ) == 0 )
2588 {
2589 netclass = bds.m_NetSettings->m_DefaultNetClass;
2590 }
2591 else
2592 {
2593 netclass.reset( new NETCLASS( eClass.name ) );
2594 bds.m_NetSettings->m_NetClasses[ eClass.name ] = netclass;
2595 }
2596
2597 netclass->SetTrackWidth( INT_MAX );
2598 netclass->SetViaDiameter( INT_MAX );
2599 netclass->SetViaDrill( INT_MAX );
2600
2601 eClasses.emplace_back( eClass );
2602 m_classMap[ eClass.number ] = netclass;
2603
2604 // Get next class
2605 classNode = classNode->GetNext();
2606 }
2607
2608 m_customRules = wxT( "(version 1)" );
2609
2610 for( ECLASS& eClass : eClasses )
2611 {
2612 for( std::pair<const wxString&, ECOORD> entry : eClass.clearanceMap )
2613 {
2614 if( m_classMap[ entry.first ] != nullptr )
2615 {
2616 wxString rule;
2617 rule.Printf( wxT( "(rule \"class %s:%s\"\n"
2618 " (condition \"A.NetClass == '%s' && B.NetClass == '%s'\")\n"
2619 " (constraint clearance (min %smm)))\n" ),
2620 eClass.number,
2621 entry.first,
2622 eClass.name,
2623 m_classMap[ entry.first ]->GetName(),
2625
2626 m_customRules += wxT( "\n" ) + rule;
2627 }
2628 }
2629 }
2630
2631 m_xpath->pop(); // "classes.class"
2632}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
std::map< wxString, std::shared_ptr< NETCLASS > > m_classMap
Definition: eagle_plugin.h:318
wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Returns the string from aValue according to aUnits (inch, mm ...) for display.
Definition: eda_units.cpp:233

References checkpoint(), BOARD::GetDesignSettings(), m_board, m_classMap, m_customRules, BOARD_DESIGN_SETTINGS::m_NetSettings, m_xpath, MILLIMETRES, ECLASS::name, ECLASS::number, pcbIUScale, XPATH::pop(), XPATH::push(), and EDA_UNIT_UTILS::UI::StringFromValue().

Referenced by loadAllSections().

◆ loadDesignRules()

void EAGLE_PLUGIN::loadDesignRules ( wxXmlNode *  aDesignRules)
private

Definition at line 618 of file eagle_plugin.cpp.

619{
620 if( aDesignRules )
621 {
622 m_xpath->push( "designrules" );
623 m_rules->parse( aDesignRules, [this](){ checkpoint(); } );
624 m_xpath->pop(); // "designrules"
625 }
626}
void parse(wxXmlNode *aRules, std::function< void()> aCheckpoint)
percent over 100%.

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

Referenced by loadAllSections().

◆ loadElements()

void EAGLE_PLUGIN::loadElements ( wxXmlNode *  aElements)
private

Definition at line 1225 of file eagle_plugin.cpp.

1226{
1227 if( !aElements )
1228 return;
1229
1230 m_xpath->push( "elements.element", "name" );
1231
1232 EATTR name;
1233 EATTR value;
1234 bool refanceNamePresetInPackageLayout;
1235 bool valueNamePresetInPackageLayout;
1236
1237 // Get the first element and iterate
1238 wxXmlNode* element = aElements->GetChildren();
1239
1240 while( element )
1241 {
1242 checkpoint();
1243
1244 if( element->GetName() != wxT( "element" ) )
1245 {
1246 // Get next item
1247 element = element->GetNext();
1248 continue;
1249 }
1250
1251 EELEMENT e( element );
1252
1253 // use "NULL-ness" as an indication of presence of the attribute:
1254 EATTR* nameAttr = nullptr;
1255 EATTR* valueAttr = nullptr;
1256
1257 m_xpath->Value( e.name.c_str() );
1258
1259 wxString pkg_key = makeKey( e.library, e.package );
1260
1261 FOOTPRINT_MAP::const_iterator it = m_templates.find( pkg_key );
1262
1263 if( it == m_templates.end() )
1264 {
1265 wxString emsg = wxString::Format( _( "No '%s' package in library '%s'." ),
1266 e.package, e.library );
1267 THROW_IO_ERROR( emsg );
1268 }
1269
1270 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( it->second->Duplicate() );
1271
1272 m_board->Add( footprint, ADD_MODE::APPEND );
1273
1274 // update the nets within the pads of the clone
1275 for( PAD* pad : footprint->Pads() )
1276 {
1277 wxString pn_key = makeKey( e.name, pad->GetNumber() );
1278
1279 NET_MAP_CITER ni = m_pads_to_nets.find( pn_key );
1280 if( ni != m_pads_to_nets.end() )
1281 {
1282 const ENET* enet = &ni->second;
1283 pad->SetNetCode( enet->netcode );
1284 }
1285 }
1286
1287 refanceNamePresetInPackageLayout = true;
1288 valueNamePresetInPackageLayout = true;
1289 footprint->SetPosition( VECTOR2I( kicad_x( e.x ), kicad_y( e.y ) ) );
1290
1291 // Is >NAME field set in package layout ?
1292 if( footprint->GetReference().size() == 0 )
1293 {
1294 footprint->Reference().SetVisible( false ); // No so no show
1295 refanceNamePresetInPackageLayout = false;
1296 }
1297
1298 // Is >VALUE field set in package layout
1299 if( footprint->GetValue().size() == 0 )
1300 {
1301 footprint->Value().SetVisible( false ); // No so no show
1302 valueNamePresetInPackageLayout = false;
1303 }
1304
1305 wxString reference = e.name;
1306
1307 // EAGLE allows references to be single digits. This breaks KiCad
1308 // netlisting, which requires parts to have non-digit + digit
1309 // annotation. If the reference begins with a number, we prepend
1310 // 'UNK' (unknown) for the symbol designator.
1311 if( reference.find_first_not_of( "0123456789" ) != 0 )
1312 reference.Prepend( "UNK" );
1313
1314 // EAGLE allows designator to start with # but that is used in KiCad
1315 // for symbols which do not have a footprint
1316 if( reference.find_first_not_of( "#" ) != 0 )
1317 reference.Prepend( "UNK" );
1318
1319 // reference must end with a number but EAGLE does not enforce this
1320 if( reference.find_last_not_of( "0123456789" ) == (reference.Length()-1) )
1321 reference.Append( "0" );
1322
1323 footprint->SetReference( reference );
1324 footprint->SetValue( e.value );
1325
1326 if( !e.smashed )
1327 {
1328 // Not smashed so show NAME & VALUE
1329 if( valueNamePresetInPackageLayout )
1330 footprint->Value().SetVisible( true ); // Only if place holder in package layout
1331
1332 if( refanceNamePresetInPackageLayout )
1333 footprint->Reference().SetVisible( true ); // Only if place holder in package layout
1334 }
1335 else if( *e.smashed == true )
1336 {
1337 // Smashed so set default to no show for NAME and VALUE
1338 footprint->Value().SetVisible( false );
1339 footprint->Reference().SetVisible( false );
1340
1341 // initialize these to default values in case the <attribute> elements are not present.
1342 m_xpath->push( "attribute", "name" );
1343
1344 // VALUE and NAME can have something like our text "effects" overrides
1345 // in SWEET and new schematic. Eagle calls these XML elements "attribute".
1346 // There can be one for NAME and/or VALUE both. Features present in the
1347 // EATTR override the ones established in the package only if they are
1348 // present here (except for rot, which if not present means angle zero).
1349 // So the logic is a bit different than in packageText() and in plain text.
1350
1351 // Get the first attribute and iterate
1352 wxXmlNode* attribute = element->GetChildren();
1353
1354 while( attribute )
1355 {
1356 if( attribute->GetName() != wxT( "attribute" ) )
1357 {
1358 attribute = attribute->GetNext();
1359 continue;
1360 }
1361
1362 EATTR a( attribute );
1363
1364 if( a.name == wxT( "NAME" ) )
1365 {
1366 name = a;
1367 nameAttr = &name;
1368
1369 // do we have a display attribute ?
1370 if( a.display )
1371 {
1372 // Yes!
1373 switch( *a.display )
1374 {
1375 case EATTR::VALUE :
1376 {
1377 nameAttr->name = reference;
1378
1379 if( refanceNamePresetInPackageLayout )
1380 footprint->Reference().SetVisible( true );
1381
1382 break;
1383 }
1384
1385 case EATTR::NAME :
1386 if( refanceNamePresetInPackageLayout )
1387 {
1388 footprint->SetReference( "NAME" );
1389 footprint->Reference().SetVisible( true );
1390 }
1391
1392 break;
1393
1394 case EATTR::BOTH :
1395 if( refanceNamePresetInPackageLayout )
1396 footprint->Reference().SetVisible( true );
1397
1398 nameAttr->name = nameAttr->name + wxT( " = " ) + e.name;
1399 footprint->SetReference( wxT( "NAME = " ) + e.name );
1400 break;
1401
1402 case EATTR::Off :
1403 footprint->Reference().SetVisible( false );
1404 break;
1405
1406 default:
1407 nameAttr->name = e.name;
1408
1409 if( refanceNamePresetInPackageLayout )
1410 footprint->Reference().SetVisible( true );
1411 }
1412 }
1413 else
1414 {
1415 // No display, so default is visible, and show value of NAME
1416 footprint->Reference().SetVisible( true );
1417 }
1418 }
1419 else if( a.name == wxT( "VALUE" ) )
1420 {
1421 value = a;
1422 valueAttr = &value;
1423
1424 if( a.display )
1425 {
1426 // Yes!
1427 switch( *a.display )
1428 {
1429 case EATTR::VALUE :
1430 valueAttr->value = opt_wxString( e.value );
1431 footprint->SetValue( e.value );
1432
1433 if( valueNamePresetInPackageLayout )
1434 footprint->Value().SetVisible( true );
1435
1436 break;
1437
1438 case EATTR::NAME :
1439 if( valueNamePresetInPackageLayout )
1440 footprint->Value().SetVisible( true );
1441
1442 footprint->SetValue( wxT( "VALUE" ) );
1443 break;
1444
1445 case EATTR::BOTH :
1446 if( valueNamePresetInPackageLayout )
1447 footprint->Value().SetVisible( true );
1448
1449 valueAttr->value = opt_wxString( wxT( "VALUE = " ) + e.value );
1450 footprint->SetValue( wxT( "VALUE = " ) + e.value );
1451 break;
1452
1453 case EATTR::Off :
1454 footprint->Value().SetVisible( false );
1455 break;
1456
1457 default:
1458 valueAttr->value = opt_wxString( e.value );
1459
1460 if( valueNamePresetInPackageLayout )
1461 footprint->Value().SetVisible( true );
1462 }
1463 }
1464 else
1465 {
1466 // No display, so default is visible, and show value of NAME
1467 footprint->Value().SetVisible( true );
1468 }
1469
1470 }
1471
1472 attribute = attribute->GetNext();
1473 }
1474
1475 m_xpath->pop(); // "attribute"
1476 }
1477
1478 orientFootprintAndText( footprint, e, nameAttr, valueAttr );
1479
1480 // Set the local coordinates for the footprint text items
1481 footprint->Reference().SetLocalCoord();
1482 footprint->Value().SetLocalCoord();
1483
1484 // Get next element
1485 element = element->GetNext();
1486 }
1487
1488 m_xpath->pop(); // "elements.element"
1489}
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:685
void orientFootprintAndText(FOOTPRINT *aFootprint, const EELEMENT &e, const EATTR *aNameAttr, const EATTR *aValueAttr)
int kicad_x(const ECOORD &x) const
Definition: eagle_plugin.h:189
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
Definition: eagle_plugin.h:188
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:217
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:1636
PADS & Pads()
Definition: footprint.h:174
void SetReference(const wxString &aReference)
Definition: footprint.h:528
void SetValue(const wxString &aValue)
Definition: footprint.h:549
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:555
const wxString & GetValue() const
Definition: footprint.h:541
const wxString & GetReference() const
Definition: footprint.h:519
FP_TEXT & Reference()
Definition: footprint.h:556
void SetLocalCoord()
Definition: fp_text.cpp:217
Definition: pad.h:58
void Value(const char *aValue)
modify the last path node's value
Definition: eagle_parser.h:125
OPTIONAL_XML_ATTRIBUTE< wxString > opt_wxString
Definition: eagle_parser.h:366
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.
NET_MAP::const_iterator NET_MAP_CITER
Definition: eagle_plugin.h:46
Parse an Eagle "attribute" XML element.
Definition: eagle_parser.h:593
opt_wxString value
Definition: eagle_parser.h:595
wxString name
Definition: eagle_parser.h:594
Eagle element element.
Definition: eagle_parser.h:809
Eagle net.
Definition: eagle_parser.h:454
int netcode
Definition: eagle_parser.h:455

References _, BOARD::Add(), APPEND, EATTR::BOTH, checkpoint(), EATTR::display, Format(), FOOTPRINT::GetReference(), FOOTPRINT::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, EATTR::Off, orientFootprintAndText(), EELEMENT::package, pad, FOOTPRINT::Pads(), XPATH::pop(), XPATH::push(), FOOTPRINT::Reference(), FP_TEXT::SetLocalCoord(), FOOTPRINT::SetPosition(), FOOTPRINT::SetReference(), FOOTPRINT::SetValue(), EDA_TEXT::SetVisible(), EELEMENT::smashed, THROW_IO_ERROR, EATTR::VALUE, EELEMENT::value, FOOTPRINT::Value(), XPATH::Value(), EATTR::value, EELEMENT::x, and EELEMENT::y.

Referenced by loadAllSections().

◆ loadLayerDefs()

void EAGLE_PLUGIN::loadLayerDefs ( wxXmlNode *  aLayers)
private

Definition at line 629 of file eagle_plugin.cpp.

630{
631 if( !aLayers )
632 return;
633
634 ELAYERS cu; // copper layers
635
636 // Get the first layer and iterate
637 wxXmlNode* layerNode = aLayers->GetChildren();
638
639 m_eagleLayers.clear();
640 m_eagleLayersIds.clear();
641
642 while( layerNode )
643 {
644 ELAYER elayer( layerNode );
645 m_eagleLayers.insert( std::make_pair( elayer.number, elayer ) );
646 m_eagleLayersIds.insert( std::make_pair( elayer.name, elayer.number ) );
647
648 // find the subset of layers that are copper and active
649 if( elayer.number >= 1 && elayer.number <= 16 && ( !elayer.active || *elayer.active ) )
650 cu.push_back( elayer );
651
652 layerNode = layerNode->GetNext();
653 }
654
655 // establish cu layer map:
656 int ki_layer_count = 0;
657
658 for( EITER it = cu.begin(); it != cu.end(); ++it, ++ki_layer_count )
659 {
660 if( ki_layer_count == 0 )
661 {
662 m_cu_map[it->number] = F_Cu;
663 }
664 else if( ki_layer_count == int( cu.size()-1 ) )
665 {
666 m_cu_map[it->number] = B_Cu;
667 }
668 else
669 {
670 // some eagle boards do not have contiguous layer number sequences.
671 m_cu_map[it->number] = ki_layer_count;
672 }
673 }
674
675 // Set the layer names and cu count if we're loading a board.
676 if( m_board )
677 {
678 m_board->SetCopperLayerCount( cu.size() );
679
680 for( EITER it = cu.begin(); it != cu.end(); ++it )
681 {
682 PCB_LAYER_ID layer = kicad_layer( it->number );
683
684 // these function provide their own protection against non enabled layers:
685 if( layer >= 0 && layer < PCB_LAYER_ID_COUNT ) // layer should be valid
686 {
687 m_board->SetLayerName( layer, it->name );
688 m_board->SetLayerType( layer, LT_SIGNAL );
689 }
690
691 // could map the colors here
692 }
693 }
694}
@ LT_SIGNAL
Definition: board.h:145
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:415
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
Definition: board.cpp:445
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
std::vector< ELAYER > ELAYERS
Definition: eagle_plugin.h:309
ELAYERS::const_iterator EITER
Definition: eagle_plugin.h:310
@ B_Cu
Definition: layer_ids.h:95
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137
@ F_Cu
Definition: layer_ids.h:64

References ELAYER::active, B_Cu, F_Cu, kicad_layer(), LT_SIGNAL, m_board, m_cu_map, m_eagleLayers, m_eagleLayersIds, ELAYER::name, ELAYER::number, PCB_LAYER_ID_COUNT, BOARD::SetCopperLayerCount(), BOARD::SetLayerName(), and BOARD::SetLayerType().

Referenced by cacheLib(), and loadAllSections().

◆ loadLibraries()

void EAGLE_PLUGIN::loadLibraries ( wxXmlNode *  aLibs)
private

Definition at line 1202 of file eagle_plugin.cpp.

1203{
1204 if( !aLibs )
1205 return;
1206
1207 m_xpath->push( "libraries.library", "name" );
1208
1209 // Get the first library and iterate
1210 wxXmlNode* library = aLibs->GetChildren();
1211
1212 while( library )
1213 {
1214 const wxString& lib_name = library->GetAttribute( "name" );
1215
1216 m_xpath->Value( lib_name.c_str() );
1217 loadLibrary( library, &lib_name );
1218 library = library->GetNext();
1219 }
1220
1221 m_xpath->pop();
1222}

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

Referenced by loadAllSections().

◆ loadLibrary()

void EAGLE_PLUGIN::loadLibrary ( wxXmlNode *  aLib,
const wxString *  aLibName 
)
private

Load 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 1144 of file eagle_plugin.cpp.

1145{
1146 if( !aLib )
1147 return;
1148
1149 // library will have <xmlattr> node, skip that and get the single packages node
1150 wxXmlNode* packages = MapChildren( aLib )["packages"];
1151
1152 if( !packages )
1153 return;
1154
1155 m_xpath->push( "packages" );
1156
1157 // Create a FOOTPRINT for all the eagle packages, for use later via a copy constructor
1158 // to instantiate needed footprints in our BOARD. Save the FOOTPRINT templates in
1159 // a FOOTPRINT_MAP using a single lookup key consisting of libname+pkgname.
1160
1161 // Get the first package and iterate
1162 wxXmlNode* package = packages->GetChildren();
1163
1164 while( package )
1165 {
1166 checkpoint();
1167
1168 m_xpath->push( "package", "name" );
1169
1170 wxString pack_ref = package->GetAttribute( "name" );
1171 ReplaceIllegalFileNameChars( pack_ref, '_' );
1172
1173 m_xpath->Value( pack_ref.ToUTF8() );
1174
1175 wxString key = aLibName ? makeKey( *aLibName, pack_ref ) : pack_ref;
1176
1177 FOOTPRINT* footprint = makeFootprint( package, pack_ref );
1178
1179 // add the templating FOOTPRINT to the FOOTPRINT template factory "m_templates"
1180 std::pair<FOOTPRINT_MAP::iterator, bool> r = m_templates.insert( { key, footprint} );
1181
1182 if( !r.second /* && !( m_props && m_props->Value( "ignore_duplicates" ) ) */ )
1183 {
1184 wxString lib = aLibName ? *aLibName : m_lib_path;
1185 const wxString& pkg = pack_ref;
1186
1187 wxString emsg = wxString::Format( _( "<package> '%s' duplicated in <library> '%s'" ),
1188 pkg,
1189 lib );
1190 THROW_IO_ERROR( emsg );
1191 }
1192
1193 m_xpath->pop();
1194
1195 package = package->GetNext();
1196 }
1197
1198 m_xpath->pop(); // "packages"
1199}
FOOTPRINT * makeFootprint(wxXmlNode *aPackage, const wxString &aPkgName)
Create a FOOTPRINT from an Eagle package.
E_SERIE r
Definition: eserie.cpp:41
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Checks aName for illegal file name characters.

References _, checkpoint(), Format(), m_lib_path, m_templates, m_xpath, makeFootprint(), makeKey(), MapChildren(), XPATH::pop(), XPATH::push(), r, ReplaceIllegalFileNameChars(), THROW_IO_ERROR, and XPATH::Value().

Referenced by cacheLib(), and loadLibraries().

◆ loadPlain()

void EAGLE_PLUGIN::loadPlain ( wxXmlNode *  aPlain)
private

Definition at line 700 of file eagle_plugin.cpp.

701{
702 if( !aGraphics )
703 return;
704
705 m_xpath->push( "plain" );
706
707 // Get the first graphic and iterate
708 wxXmlNode* gr = aGraphics->GetChildren();
709
710 // (polygon | wire | text | circle | rectangle | frame | hole)*
711 while( gr )
712 {
713 checkpoint();
714
715 wxString grName = gr->GetName();
716
717 if( grName == wxT( "wire" ) )
718 {
719 m_xpath->push( "wire" );
720
721 EWIRE w( gr );
722 PCB_LAYER_ID layer = kicad_layer( w.layer );
723
724 VECTOR2I start( kicad_x( w.x1 ), kicad_y( w.y1 ) );
725 VECTOR2I end( kicad_x( w.x2 ), kicad_y( w.y2 ) );
726
727 if( layer != UNDEFINED_LAYER )
728 {
729 PCB_SHAPE* shape = new PCB_SHAPE( m_board );
730 int width = w.width.ToPcbUnits();
731
732 // KiCad cannot handle zero or negative line widths
733 if( width <= 0 )
734 width = m_board->GetDesignSettings().GetLineThickness( layer );
735
736 m_board->Add( shape, ADD_MODE::APPEND );
737
738 if( !w.curve )
739 {
740 shape->SetShape( SHAPE_T::SEGMENT );
741 shape->SetStart( start );
742 shape->SetEnd( end );
743 }
744 else
745 {
746 VECTOR2I center = ConvertArcCenter( start, end, *w.curve );
747
748 shape->SetShape( SHAPE_T::ARC );
749 shape->SetCenter( center );
750 shape->SetStart( start );
751 shape->SetArcAngleAndEnd( -EDA_ANGLE( *w.curve, DEGREES_T ), true ); // KiCad rotates the other way
752 }
753
754 shape->SetLayer( layer );
756 }
757
758 m_xpath->pop();
759 }
760 else if( grName == wxT( "text" ) )
761 {
762 m_xpath->push( "text" );
763
764 ETEXT t( gr );
765 PCB_LAYER_ID layer = kicad_layer( t.layer );
766
767 if( layer != UNDEFINED_LAYER )
768 {
769 PCB_TEXT* pcbtxt = new PCB_TEXT( m_board );
770 m_board->Add( pcbtxt, ADD_MODE::APPEND );
771
772 pcbtxt->SetLayer( layer );
773 wxString kicadText = interpret_text( t.text );
774 pcbtxt->SetText( kicadText );
775 pcbtxt->SetTextPos( VECTOR2I( kicad_x( t.x ), kicad_y( t.y ) ) );
776
777 double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default
778 int textThickness = KiROUND( t.size.ToPcbUnits() * ratio / 100 );
779 pcbtxt->SetTextThickness( textThickness );
780 pcbtxt->SetTextSize( kicad_fontz( t.size, textThickness ) );
781
782 int align = t.align ? *t.align : ETEXT::BOTTOM_LEFT;
783
784 if( t.rot )
785 {
786 int sign = t.rot->mirror ? -1 : 1;
787 pcbtxt->SetMirrored( t.rot->mirror );
788
789 double degrees = t.rot->degrees;
790
791 if( degrees == 90 || t.rot->spin )
792 {
793 pcbtxt->SetTextAngle( EDA_ANGLE( sign * t.rot->degrees, DEGREES_T ) );
794 }
795 else if( degrees == 180 )
796 {
797 align = -align;
798 }
799 else if( degrees == 270 )
800 {
801 pcbtxt->SetTextAngle( EDA_ANGLE( sign * 90, DEGREES_T ) );
802 align = -align;
803 }
804 else
805 {
806 // Ok so text is not at 90,180 or 270 so do some funny stuff to get
807 // placement right.
808 if( ( degrees > 0 ) && ( degrees < 90 ) )
809 {
810 pcbtxt->SetTextAngle( EDA_ANGLE( sign * t.rot->degrees, DEGREES_T ) );
811 }
812 else if( ( degrees > 90 ) && ( degrees < 180 ) )
813 {
814 pcbtxt->SetTextAngle( EDA_ANGLE( sign * ( t.rot->degrees + 180 ), DEGREES_T ) );
815 align = ETEXT::TOP_RIGHT;
816 }
817 else if( ( degrees > 180 ) && ( degrees < 270 ) )
818 {
819 pcbtxt->SetTextAngle( EDA_ANGLE( sign * ( t.rot->degrees - 180 ), DEGREES_T ) );
820 align = ETEXT::TOP_RIGHT;
821 }
822 else if( ( degrees > 270 ) && ( degrees < 360 ) )
823 {
824 pcbtxt->SetTextAngle( EDA_ANGLE( sign * t.rot->degrees, DEGREES_T ) );
825 align = ETEXT::BOTTOM_LEFT;
826 }
827 }
828 }
829
830 switch( align )
831 {
832 case ETEXT::CENTER:
835 break;
836
840 break;
841
845 break;
846
850 break;
851
852 case ETEXT::TOP_LEFT:
855 break;
856
857 case ETEXT::TOP_RIGHT:
860 break;
861
865 break;
866
870 break;
871
875 break;
876 }
877 }
878
879 m_xpath->pop();
880 }
881 else if( grName == wxT( "circle" ) )
882 {
883 m_xpath->push( "circle" );
884
885 ECIRCLE c( gr );
886
887 int width = c.width.ToPcbUnits();
888 int radius = c.radius.ToPcbUnits();
889
890 if( c.layer == EAGLE_LAYER::TRESTRICT || c.layer == EAGLE_LAYER::BRESTRICT
891 || c.layer == EAGLE_LAYER::VRESTRICT )
892 {
893 ZONE* zone = new ZONE( m_board );
894 m_board->Add( zone, ADD_MODE::APPEND );
895
896 setKeepoutSettingsToZone( zone, c.layer );
897
898 // approximate circle as polygon
899 VECTOR2I center( kicad_x( c.x ), kicad_y( c.y ) );
900 int outlineRadius = radius + ( width / 2 );
901 int segsInCircle = GetArcToSegmentCount( outlineRadius, ARC_HIGH_DEF, FULL_CIRCLE );
902 EDA_ANGLE delta = ANGLE_360 / segsInCircle;
903
905 {
906 VECTOR2I rotatedPoint( outlineRadius, 0 );
907 RotatePoint( rotatedPoint, angle );
908 zone->AppendCorner( center + rotatedPoint, -1 );
909 }
910
911 if( width > 0 )
912 {
913 zone->NewHole();
914 int innerRadius = radius - ( width / 2 );
915 segsInCircle = GetArcToSegmentCount( innerRadius, ARC_HIGH_DEF, FULL_CIRCLE );
916 delta = ANGLE_360 / segsInCircle;
917
919 {
920 VECTOR2I rotatedPoint( innerRadius, 0 );
921 RotatePoint( rotatedPoint, angle );
922 zone->AppendCorner( center + rotatedPoint, 0 );
923 }
924 }
925
928 }
929 else
930 {
931 PCB_LAYER_ID layer = kicad_layer( c.layer );
932
933 if( layer != UNDEFINED_LAYER ) // unsupported layer
934 {
936 m_board->Add( shape, ADD_MODE::APPEND );
937 shape->SetFilled( false );
938 shape->SetLayer( layer );
939 shape->SetStart( VECTOR2I( kicad_x( c.x ), kicad_y( c.y ) ) );
940 shape->SetEnd( VECTOR2I( kicad_x( c.x ) + radius, kicad_y( c.y ) ) );
942 }
943 }
944
945 m_xpath->pop();
946 }
947 else if( grName == wxT( "rectangle" ) )
948 {
949 // This seems to be a simplified rectangular [copper] zone, cannot find any
950 // net related info on it from the DTD.
951 m_xpath->push( "rectangle" );
952
953 ERECT r( gr );
954 PCB_LAYER_ID layer = kicad_layer( r.layer );
955
956 if( IsCopperLayer( layer ) )
957 {
958 // use a "netcode = 0" type ZONE:
959 ZONE* zone = new ZONE( m_board );
960 m_board->Add( zone, ADD_MODE::APPEND );
961
962 zone->SetLayer( layer );
964
966
967 const int outlineIdx = -1; // this is the id of the copper zone main outline
968 zone->AppendCorner( VECTOR2I( kicad_x( r.x1 ), kicad_y( r.y1 ) ), outlineIdx );
969 zone->AppendCorner( VECTOR2I( kicad_x( r.x2 ), kicad_y( r.y1 ) ), outlineIdx );
970 zone->AppendCorner( VECTOR2I( kicad_x( r.x2 ), kicad_y( r.y2 ) ), outlineIdx );
971 zone->AppendCorner( VECTOR2I( kicad_x( r.x1 ), kicad_y( r.y2 ) ), outlineIdx );
972
973 if( r.rot )
974 zone->Rotate( zone->GetPosition(), EDA_ANGLE( r.rot->degrees, DEGREES_T ) );
975
976 // this is not my fault:
978 true );
979 }
980
981 m_xpath->pop();
982 }
983 else if( grName == wxT( "hole" ) )
984 {
985 m_xpath->push( "hole" );
986
987 // Fabricate a FOOTPRINT with a single PAD_ATTRIB::NPTH pad.
988 // Use m_hole_count to gen up a unique name.
989
990 FOOTPRINT* footprint = new FOOTPRINT( m_board );
991 m_board->Add( footprint, ADD_MODE::APPEND );
992 footprint->SetReference( wxString::Format( wxT( "@HOLE%d" ), m_hole_count++ ) );
993 footprint->Reference().SetVisible( false );
994
995 packageHole( footprint, gr, true );
996
997 m_xpath->pop();
998 }
999 else if( grName == wxT( "frame" ) )
1000 {
1001 // picture this
1002 }
1003 else if( grName == wxT( "polygon" ) )
1004 {
1005 m_xpath->push( "polygon" );
1006 loadPolygon( gr );
1007 m_xpath->pop(); // "polygon"
1008 }
1009 else if( grName == wxT( "dimension" ) )
1010 {
1011 const BOARD_DESIGN_SETTINGS& designSettings = m_board->GetDesignSettings();
1012
1013 EDIMENSION d( gr );
1014 PCB_LAYER_ID layer = kicad_layer( d.layer );
1015 VECTOR2I pt1( kicad_x( d.x1 ), kicad_y( d.y1 ) );
1016 VECTOR2I pt2( kicad_x( d.x2 ), kicad_y( d.y2 ) );
1017 VECTOR2I pt3( kicad_x( d.x3 ), kicad_y( d.y3 ) );
1018 wxSize textSize = designSettings.GetTextSize( layer );
1019 int textThickness = designSettings.GetLineThickness( layer );
1020
1021 if( d.textsize )
1022 {
1023 double ratio = 8; // DTD says 8 is default
1024 textThickness = KiROUND( d.textsize->ToPcbUnits() * ratio / 100 );
1025 textSize = kicad_fontz( *d.textsize, textThickness );
1026 }
1027
1028 if( layer != UNDEFINED_LAYER )
1029 {
1030 if( d.dimensionType == wxT( "angle" ) )
1031 {
1032 // Kicad doesn't (at present) support angle dimensions
1033 }
1034 else if( d.dimensionType == wxT( "radius" ) )
1035 {
1036 PCB_DIM_RADIAL* dimension = new PCB_DIM_RADIAL( m_board );
1037 m_board->Add( dimension, ADD_MODE::APPEND );
1038
1039 dimension->SetLayer( layer );
1040 dimension->SetPrecision( DIMENSION_PRECISION );
1041
1042 dimension->SetStart( pt1 );
1043 dimension->SetEnd( pt2 );
1044 dimension->Text().SetPosition( pt3 );
1045 dimension->Text().SetTextSize( textSize );
1046 dimension->Text().SetTextThickness( textThickness );
1047 dimension->SetLineThickness( designSettings.GetLineThickness( layer ) );
1048 dimension->SetUnits( EDA_UNITS::MILLIMETRES );
1049 }
1050 else if( d.dimensionType == wxT( "leader" ) )
1051 {
1052 PCB_DIM_LEADER* leader = new PCB_DIM_LEADER( m_board );
1053 m_board->Add( leader, ADD_MODE::APPEND );
1054
1055 leader->SetLayer( layer );
1057
1058 leader->SetStart( pt1 );
1059 leader->SetEnd( pt2 );
1060 leader->Text().SetPosition( pt3 );
1061 leader->Text().SetTextSize( textSize );
1062 leader->Text().SetTextThickness( textThickness );
1063 leader->SetText( wxEmptyString );
1064 leader->SetLineThickness( designSettings.GetLineThickness( layer ) );
1065 }
1066 else // horizontal, vertical, <default>, diameter
1067 {
1069 m_board->Add( dimension, ADD_MODE::APPEND );
1070
1071 if( d.dimensionType )
1072 {
1073 // Eagle dimension graphic arms may have different lengths, but they look
1074 // incorrect in KiCad (the graphic is tilted). Make them even length in
1075 // such case.
1076 if( *d.dimensionType == wxT( "horizontal" ) )
1077 {
1078 int newY = ( pt1.y + pt2.y ) / 2;
1079 pt1.y = newY;
1080 pt2.y = newY;
1081 }
1082 else if( *d.dimensionType == wxT( "vertical" ) )
1083 {
1084 int newX = ( pt1.x + pt2.x ) / 2;
1085 pt1.x = newX;
1086 pt2.x = newX;
1087 }
1088 }
1089
1090 dimension->SetLayer( layer );
1091 dimension->SetPrecision( DIMENSION_PRECISION );
1092
1093 // The origin and end are assumed to always be in this order from eagle
1094 dimension->SetStart( pt1 );
1095 dimension->SetEnd( pt2 );
1096 dimension->Text().SetTextSize( textSize );
1097 dimension->Text().SetTextThickness( textThickness );
1098 dimension->SetLineThickness( designSettings.GetLineThickness( layer ) );
1099 dimension->SetUnits( EDA_UNITS::MILLIMETRES );
1100
1101 // check which axis the dimension runs in
1102 // because the "height" of the dimension is perpendicular to that axis
1103 // Note the check is just if two axes are close enough to each other
1104 // Eagle appears to have some rounding errors
1105 if( abs( pt1.x - pt2.x ) < 50000 ) // 50000 nm = 0.05 mm
1106 {
1107 int offset = pt3.x - pt1.x;
1108
1109 if( pt1.y > pt2.y )
1110 dimension->SetHeight( offset );
1111 else
1112 dimension->SetHeight( -offset );
1113 }
1114 else if( abs( pt1.y - pt2.y ) < 50000 )
1115 {
1116 int offset = pt3.y - pt1.y;
1117
1118 if( pt1.x > pt2.x )
1119 dimension->SetHeight( -offset );
1120 else
1121 dimension->SetHeight( offset );
1122 }
1123 else
1124 {
1125 int offset = GetLineLength( pt3, pt1 );
1126
1127 if( pt1.y > pt2.y )
1128 dimension->SetHeight( offset );
1129 else
1130 dimension->SetHeight( -offset );
1131 }
1132 }
1133 }
1134 }
1135
1136 // Get next graphic
1137 gr = gr->GetNext();
1138 }
1139
1140 m_xpath->pop();
1141}
constexpr int ARC_HIGH_DEF
Definition: base_units.h:121
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:201
wxSize kicad_fontz(const ECOORD &d, int aTextThickness) const
create a font size (fontz) from an eagle font size scalar and KiCad font thickness
void packageHole(FOOTPRINT *aFootprint, wxXmlNode *aTree, bool aCenter) const
ZONE * loadPolygon(wxXmlNode *aPolyNode)
Load a copper or keepout polygon and adds it to the board.
void SetCenter(const VECTOR2I &aCenter)
Definition: eda_shape.cpp:423
void SetFilled(bool aFlag)
Definition: eda_shape.h:95
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:120
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:110
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:145
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
Definition: eda_shape.cpp:549
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:371
void SetMirrored(bool isMirrored)
Definition: eda_text.cpp:224
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:248
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.cpp:185
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:193
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:240
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Definition: netinfo.h:373
void SetPrecision(int aPrecision)
void SetUnits(EDA_UNITS aUnits)
PCB_TEXT & Text()
void SetText(const wxString &aNewText)
Set the override text - has no effect if m_overrideValue == false.
void SetLineThickness(int aWidth)
virtual void SetEnd(const VECTOR2I &aPoint)
virtual void SetStart(const VECTOR2I &aPoint)
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
For better understanding of the points that make a dimension:
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
A leader is a dimension-like object pointing to a specific point.
A radial dimension indicates either the radius or diameter of an arc or circle.
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: pcb_shape.h:70
virtual void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_text.h:81
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, bool aRebuilBorderdHatch)
Set all hatch parameters for the zone.
Definition: zone.cpp:756
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:251
void NewHole()
Create a new hole on the zone; i.e., a new contour on the zone's outline.
Definition: zone.h:558
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
Definition: zone.cpp:620
VECTOR2I GetPosition() const override
Definition: zone.cpp:224
bool AppendCorner(VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
Definition: zone.cpp:696
static int GetDefaultHatchPitch()
Definition: zone.cpp:923
VECTOR2I ConvertArcCenter(const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle)
static void setKeepoutSettingsToZone(ZONE *aZone, int aLayer)
static wxString interpret_text(const wxString &aText)
interpret special characters in Eagle text and converts them to KiCAD notation
#define DIMENSION_PRECISION
@ DEGREES_T
Definition: eda_angle.h:31
static constexpr EDA_ANGLE & ANGLE_360
Definition: eda_angle.h:418
static constexpr EDA_ANGLE & FULL_CIRCLE
Definition: eda_angle.h:410
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:823
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
Eagle circle.
Definition: eagle_parser.h:561
Eagle dimension element.
Definition: eagle_parser.h:619
Eagle XML rectangle in binary.
Definition: eagle_parser.h:574
Eagle text element.
Definition: eagle_parser.h:636
@ BOTTOM_CENTER
Definition: eagle_parser.h:655
@ BOTTOM_RIGHT
Definition: eagle_parser.h:657
@ TOP_CENTER
Definition: eagle_parser.h:649
@ TOP_LEFT
Definition: eagle_parser.h:650
@ TOP_RIGHT
Definition: eagle_parser.h:651
@ CENTER_RIGHT
Definition: eagle_parser.h:654
@ CENTER_LEFT
Definition: eagle_parser.h:648
@ BOTTOM_LEFT
Definition: eagle_parser.h:656
Eagle wire.
Definition: eagle_parser.h:492
constexpr int delta
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
double GetLineLength(const VECTOR2I &aPointA, const VECTOR2I &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:188
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:106
int sign(T val)
Definition: util.h:111
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:49

References std::abs(), BOARD::Add(), ETEXT::align, PNS::angle(), ANGLE_0, ANGLE_360, APPEND, ZONE::AppendCorner(), ARC, ARC_HIGH_DEF, ETEXT::BOTTOM_CENTER, ETEXT::BOTTOM_LEFT, ETEXT::BOTTOM_RIGHT, EAGLE_LAYER::BRESTRICT, ETEXT::CENTER, ETEXT::CENTER_LEFT, ETEXT::CENTER_RIGHT, checkpoint(), CIRCLE, ConvertArcCenter(), EWIRE::curve, EROT::degrees, DEGREES_T, delta, DIAGONAL_EDGE, DIMENSION_PRECISION, EDIMENSION::dimensionType, Format(), FULL_CIRCLE, GetArcToSegmentCount(), ZONE::GetDefaultHatchPitch(), BOARD::GetDesignSettings(), GetLineLength(), BOARD_DESIGN_SETTINGS::GetLineThickness(), ZONE::GetPosition(), BOARD_DESIGN_SETTINGS::GetTextSize(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, interpret_text(), IsCopperLayer(), kicad_fontz(), kicad_layer(), kicad_x(), kicad_y(), KiROUND(), EWIRE::layer, ECIRCLE::layer, EDIMENSION::layer, ETEXT::layer, loadPolygon(), m_board, m_hole_count, m_xpath, MILLIMETRES, EROT::mirror, ZONE::NewHole(), packageHole(), PCB_DIM_ALIGNED_T, XPATH::pop(), XPATH::push(), r, ECIRCLE::radius, ETEXT::ratio, FOOTPRINT::Reference(), ETEXT::rot, ZONE::Rotate(), RotatePoint(), SEGMENT, EDA_SHAPE::SetArcAngleAndEnd(), ZONE::SetBorderDisplayStyle(), EDA_SHAPE::SetCenter(), EDA_SHAPE::SetEnd(), PCB_DIMENSION_BASE::SetEnd(), EDA_SHAPE::SetFilled(), PCB_DIM_ALIGNED::SetHeight(), EDA_TEXT::SetHorizJustify(), setKeepoutSettingsToZone(), BOARD_ITEM::SetLayer(), PCB_DIMENSION_BASE::SetLayer(), ZONE::SetLayer(), PCB_DIMENSION_BASE::SetLineThickness(), EDA_TEXT::SetMirrored(), BOARD_CONNECTED_ITEM::SetNetCode(), PCB_TEXT::SetPosition(), PCB_DIMENSION_BASE::SetPrecision(), FOOTPRINT::SetReference(), EDA_SHAPE::SetShape(), PCB_DIMENSION_BASE::SetStart(), EDA_SHAPE::SetStart(), PCB_SHAPE::SetStroke(), PCB_DIMENSION_BASE::SetText(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), PCB_DIMENSION_BASE::SetUnits(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), sign(), ETEXT::size, SOLID, EROT::spin, ETEXT::text, PCB_DIMENSION_BASE::Text(), EDIMENSION::textsize, ETEXT::TOP_CENTER, ETEXT::TOP_LEFT, ETEXT::TOP_RIGHT, ECOORD::ToPcbUnits(), EAGLE_LAYER::TRESTRICT, NETINFO_LIST::UNCONNECTED, UNDEFINED_LAYER, EAGLE_LAYER::VRESTRICT, EWIRE::width, ECIRCLE::width, ECIRCLE::x, ETEXT::x, VECTOR2< T >::x, EWIRE::x1, EDIMENSION::x1, EWIRE::x2, EDIMENSION::x2, EDIMENSION::x3, ECIRCLE::y, ETEXT::y, VECTOR2< T >::y, EWIRE::y1, EDIMENSION::y1, EWIRE::y2, EDIMENSION::y2, and EDIMENSION::y3.

Referenced by loadAllSections().

◆ loadPolygon()

ZONE * EAGLE_PLUGIN::loadPolygon ( wxXmlNode *  aPolyNode)
private

Load a copper or keepout polygon and adds it to the board.

Returns
The loaded zone or nullptr if was not processed.

Definition at line 1492 of file eagle_plugin.cpp.

1493{
1494 EPOLYGON p( aPolyNode );
1495 PCB_LAYER_ID layer = kicad_layer( p.layer );
1496 ZONE* zone = nullptr;
1497 bool keepout = ( p.layer == EAGLE_LAYER::TRESTRICT
1498 || p.layer == EAGLE_LAYER::BRESTRICT
1499 || p.layer == EAGLE_LAYER::VRESTRICT );
1500
1501 if( layer == UNDEFINED_LAYER )
1502 {
1503 wxLogMessage( wxString::Format( _( "Ignoring a polygon since Eagle layer '%s' (%d) "
1504 "was not mapped" ),
1505 eagle_layer_name( p.layer ), p.layer ) );
1506 return nullptr;
1507 }
1508
1509 if( !IsCopperLayer( layer ) && !keepout )
1510 return nullptr;
1511
1512 // use a "netcode = 0" type ZONE:
1513 zone = new ZONE( m_board );
1514 m_board->Add( zone, ADD_MODE::APPEND );
1515
1516 if( !keepout )
1517 zone->SetLayer( layer );
1518 else
1519 setKeepoutSettingsToZone( zone, p.layer );
1520
1521 // Get the first vertex and iterate
1522 wxXmlNode* vertex = aPolyNode->GetChildren();
1523 std::vector<EVERTEX> vertices;
1524
1525 // Create a circular vector of vertices
1526 // The "curve" parameter indicates a curve from the current
1527 // to the next vertex, so we keep the first at the end as well
1528 // to allow the curve to link back
1529 while( vertex )
1530 {
1531 if( vertex->GetName() == wxT( "vertex" ) )
1532 vertices.emplace_back( vertex );
1533
1534 vertex = vertex->GetNext();
1535 }
1536
1537 vertices.push_back( vertices[0] );
1538
1539 SHAPE_POLY_SET polygon;
1540 polygon.NewOutline();
1541
1542 for( size_t i = 0; i < vertices.size() - 1; i++ )
1543 {
1544 EVERTEX v1 = vertices[i];
1545
1546 // Append the corner
1547 polygon.Append( kicad_x( v1.x ), kicad_y( v1.y ) );
1548
1549 if( v1.curve )
1550 {
1551 EVERTEX v2 = vertices[i + 1];
1552 VECTOR2I center =
1553 ConvertArcCenter( VECTOR2I( kicad_x( v1.x ), kicad_y( v1.y ) ),
1554 VECTOR2I( kicad_x( v2.x ), kicad_y( v2.y ) ), *v1.curve );
1555 double angle = DEG2RAD( *v1.curve );
1556 double end_angle = atan2( kicad_y( v2.y ) - center.y, kicad_x( v2.x ) - center.x );
1557 double radius = sqrt( pow( center.x - kicad_x( v1.x ), 2 )
1558 + pow( center.y - kicad_y( v1.y ), 2 ) );
1559
1560 int segCount = GetArcToSegmentCount( KiROUND( radius ), ARC_HIGH_DEF,
1561 EDA_ANGLE( *v1.curve, DEGREES_T ) );
1562 double delta_angle = angle / segCount;
1563
1564 for( double a = end_angle + angle; fabs( a - end_angle ) > fabs( delta_angle );
1565 a -= delta_angle )
1566 {
1567 polygon.Append( KiROUND( radius * cos( a ) ) + center.x,
1568 KiROUND( radius * sin( a ) ) + center.y );
1569 }
1570 }
1571 }
1572
1573 // Eagle traces the zone such that half of the pen width is outside the polygon.
1574 // We trace the zone such that the copper is completely inside.
1575 if( p.width.ToPcbUnits() > 0 )
1576 {
1577 polygon.Inflate( p.width.ToPcbUnits() / 2, 32, SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS );
1579 }
1580
1581 zone->AddPolygon( polygon.COutline( 0 ) );
1582
1583 // If the pour is a cutout it needs to be set to a keepout
1584 if( p.pour == EPOLYGON::CUTOUT )
1585 {
1586 zone->SetIsRuleArea( true );
1587 zone->SetDoNotAllowVias( false );
1588 zone->SetDoNotAllowTracks( false );
1589 zone->SetDoNotAllowPads( false );
1590 zone->SetDoNotAllowFootprints( false );
1591 zone->SetDoNotAllowCopperPour( true );
1593 }
1594 else if( p.pour == EPOLYGON::HATCH )
1595 {
1596 int spacing = p.spacing ? p.spacing->ToPcbUnits() : 50 * pcbIUScale.IU_PER_MILS;
1597
1599 zone->SetHatchThickness( p.width.ToPcbUnits() );
1600 zone->SetHatchGap( spacing - p.width.ToPcbUnits() );
1602 }
1603
1604 // We divide the thickness by half because we are tracing _inside_ the zone outline
1605 // This means the radius of curvature will be twice the size for an equivalent EAGLE zone
1607 p.width.ToPcbUnits() / 2 ) );
1608
1609 if( p.isolate )
1610 zone->SetLocalClearance( p.isolate->ToPcbUnits() );
1611 else
1612 zone->SetLocalClearance( 1 ); // @todo: set minimum clearance value based on board settings
1613
1614 // missing == yes per DTD.
1615 bool thermals = !p.thermals || *p.thermals;
1617
1618 if( thermals )
1619 {
1620 // FIXME: eagle calculates dimensions for thermal spokes
1621 // based on what the zone is connecting to.
1622 // (i.e. width of spoke is half of the smaller side of an smd pad)
1623 // This is a basic workaround
1624 zone->SetThermalReliefGap( p.width.ToPcbUnits() + 50000 ); // 50000nm == 0.05mm
1625 zone->SetThermalReliefSpokeWidth( p.width.ToPcbUnits() + 50000 );
1626 }
1627
1628 int rank = p.rank ? (p.max_priority - *p.rank) : p.max_priority;
1629 zone->SetAssignedPriority( rank );
1630
1631 return zone;
1632}
Represent a set of closed polygons.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
void Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
int NewOutline()
Creates a new hole in a given outline.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void SetHatchThickness(int aThickness)
Definition: zone.h:254
void SetDoNotAllowPads(bool aEnable)
Definition: zone.h:702
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
Definition: zone.cpp:679
void SetMinThickness(int aMinThickness)
Definition: zone.h:245
void SetHatchOrientation(const EDA_ANGLE &aStep)
Definition: zone.h:260
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:699
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
Definition: zone.h:180
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition: zone.h:575
void SetIsRuleArea(bool aEnable)
Definition: zone.h:698
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:701
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition: zone.h:166
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:700
void SetLocalClearance(int aClearance)
Definition: zone.h:146
void SetThermalReliefGap(int aThermalReliefGap)
Definition: zone.h:169
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:703
void SetAssignedPriority(unsigned aPriority)
Definition: zone.h:101
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition: zone.h:242
void SetHatchGap(int aStep)
Definition: zone.h:257
const double IU_PER_MILS
Definition: base_units.h:78
Eagle polygon, without vertices which are parsed as needed.
Definition: eagle_parser.h:769
Eagle vertex.
Definition: eagle_parser.h:758
ECOORD y
Definition: eagle_parser.h:760
ECOORD x
Definition: eagle_parser.h:759
opt_double curve
range is -359.9..359.9
Definition: eagle_parser.h:761
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
double DEG2RAD(double deg)
Definition: trigo.h:195
#define ZONE_THICKNESS_MIN_VALUE_MIL
Definition: zones.h:36
@ THERMAL
Use thermal relief for pads.
@ FULL
pads are covered by copper

References _, BOARD::Add(), ZONE::AddPolygon(), SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS, PNS::angle(), ANGLE_0, SHAPE_POLY_SET::Append(), APPEND, ARC_HIGH_DEF, EAGLE_LAYER::BRESTRICT, ConvertArcCenter(), SHAPE_POLY_SET::COutline(), EVERTEX::curve, EPOLYGON::CUTOUT, DEG2RAD(), DEGREES_T, eagle_layer_name(), Format(), SHAPE_POLY_SET::Fracture(), FULL, GetArcToSegmentCount(), EPOLYGON::HATCH, HATCH_PATTERN, SHAPE_POLY_SET::Inflate(), IsCopperLayer(), EPOLYGON::isolate, EDA_IU_SCALE::IU_PER_MILS, kicad_layer(), kicad_x(), kicad_y(), KiROUND(), EPOLYGON::layer, m_board, EPOLYGON::max_priority, SHAPE_POLY_SET::NewOutline(), NO_HATCH, pcbIUScale, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, EPOLYGON::pour, EPOLYGON::rank, ZONE::SetAssignedPriority(), ZONE::SetDoNotAllowCopperPour(), ZONE::SetDoNotAllowFootprints(), ZONE::SetDoNotAllowPads(), ZONE::SetDoNotAllowTracks(), ZONE::SetDoNotAllowVias(), ZONE::SetFillMode(), ZONE::SetHatchGap(), ZONE::SetHatchOrientation(), ZONE::SetHatchStyle(), ZONE::SetHatchThickness(), ZONE::SetIsRuleArea(), setKeepoutSettingsToZone(), ZONE::SetLayer(), ZONE::SetLocalClearance(), ZONE::SetMinThickness(), ZONE::SetPadConnection(), ZONE::SetThermalReliefGap(), ZONE::SetThermalReliefSpokeWidth(), EPOLYGON::spacing, THERMAL, EPOLYGON::thermals, ECOORD::ToPcbUnits(), EAGLE_LAYER::TRESTRICT, UNDEFINED_LAYER, v2, EAGLE_LAYER::VRESTRICT, EPOLYGON::width, EVERTEX::x, VECTOR2< T >::x, EVERTEX::y, VECTOR2< T >::y, and ZONE_THICKNESS_MIN_VALUE_MIL.

Referenced by loadPlain(), and loadSignals().

◆ loadSignals()

void EAGLE_PLUGIN::loadSignals ( wxXmlNode *  aSignals)
private

This is, at best, a guess. Eagle doesn't seem to differentiate between blind/buried vias that only go one layer and micro vias so the user will need to clean up a bit

Definition at line 2635 of file eagle_plugin.cpp.

2636{
2637 ZONES zones; // per net
2638 int netCode = 1;
2639
2640 m_xpath->push( "signals.signal", "name" );
2641
2642 // Get the first signal and iterate
2643 wxXmlNode* net = aSignals->GetChildren();
2644
2645 while( net )
2646 {
2647 checkpoint();
2648
2649 bool sawPad = false;
2650
2651 zones.clear();
2652
2653 const wxString& netName = escapeName( net->GetAttribute( "name" ) );
2654 NETINFO_ITEM* netInfo = new NETINFO_ITEM( m_board, netName, netCode );
2655 std::shared_ptr<NETCLASS> netclass;
2656
2657 if( net->HasAttribute( "class" ) )
2658 {
2659 netclass = m_classMap[ net->GetAttribute( "class" ) ];
2660
2661 m_board->GetDesignSettings().m_NetSettings->m_NetClassPatternAssignments.push_back(
2662 {
2663 std::make_unique<EDA_COMBINED_MATCHER>( netName, CTX_NETCLASS ),
2664 netclass->GetName()
2665 } );
2666
2667 netInfo->SetNetClass( netclass );
2668 }
2669
2670 m_board->Add( netInfo );
2671
2672 m_xpath->Value( netName.c_str() );
2673
2674 // Get the first net item and iterate
2675 wxXmlNode* netItem = net->GetChildren();
2676
2677 // (contactref | polygon | wire | via)*
2678 while( netItem )
2679 {
2680 const wxString& itemName = netItem->GetName();
2681
2682 if( itemName == wxT( "wire" ) )
2683 {
2684 m_xpath->push( "wire" );
2685
2686 EWIRE w( netItem );
2687 PCB_LAYER_ID layer = kicad_layer( w.layer );
2688
2689 if( IsCopperLayer( layer ) )
2690 {
2691 VECTOR2I start( kicad_x( w.x1 ), kicad_y( w.y1 ) );
2692 double angle = 0.0;
2693 double end_angle = 0.0;
2694 double radius = 0.0;
2695 double delta_angle = 0.0;
2696 VECTOR2I center;
2697
2698 int width = w.width.ToPcbUnits();
2699
2700 if( width < m_min_trace )
2701 m_min_trace = width;
2702
2703 if( netclass && width < netclass->GetTrackWidth() )
2704 netclass->SetTrackWidth( width );
2705
2706 if( w.curve )
2707 {
2708 center = ConvertArcCenter( VECTOR2I( kicad_x( w.x1 ), kicad_y( w.y1 ) ),
2709 VECTOR2I( kicad_x( w.x2 ), kicad_y( w.y2 ) ),
2710 *w.curve );
2711
2712 angle = DEG2RAD( *w.curve );
2713
2714 end_angle = atan2( kicad_y( w.y2 ) - center.y,
2715 kicad_x( w.x2 ) - center.x );
2716
2717 radius = sqrt( pow( center.x - kicad_x( w.x1 ), 2 ) +
2718 pow( center.y - kicad_y( w.y1 ), 2 ) );
2719
2720 int segs = GetArcToSegmentCount( KiROUND( radius ), ARC_HIGH_DEF,
2721 EDA_ANGLE( *w.curve, DEGREES_T ) );
2722 delta_angle = angle / segs;
2723 }
2724
2725 while( fabs( angle ) > fabs( delta_angle ) )
2726 {
2727 wxASSERT( radius > 0.0 );
2728 VECTOR2I end( KiROUND( radius * cos( end_angle + angle ) + center.x ),
2729 KiROUND( radius * sin( end_angle + angle ) + center.y ) );
2730
2731 PCB_TRACK* t = new PCB_TRACK( m_board );
2732
2733 t->SetPosition( start );
2734 t->SetEnd( end );
2735 t->SetWidth( width );
2736 t->SetLayer( layer );
2737 t->SetNetCode( netCode );
2738
2739 m_board->Add( t );
2740
2741 start = end;
2742 angle -= delta_angle;
2743 }
2744
2745 PCB_TRACK* t = new PCB_TRACK( m_board );
2746
2747 t->SetPosition( start );
2748 t->SetEnd( VECTOR2I( kicad_x( w.x2 ), kicad_y( w.y2 ) ) );
2749 t->SetWidth( width );
2750 t->SetLayer( layer );
2751 t->SetNetCode( netCode );
2752
2753 m_board->Add( t );
2754 }
2755 else
2756 {
2757 // put non copper wires where the sun don't shine.
2758 }
2759
2760 m_xpath->pop();
2761 }
2762 else if( itemName == wxT( "via" ) )
2763 {
2764 m_xpath->push( "via" );
2765 EVIA v( netItem );
2766
2767 if( v.layer_front_most > v.layer_back_most )
2768 std::swap( v.layer_front_most, v.layer_back_most );
2769
2770 PCB_LAYER_ID layer_front_most = kicad_layer( v.layer_front_most );
2771 PCB_LAYER_ID layer_back_most = kicad_layer( v.layer_back_most );
2772
2773 if( IsCopperLayer( layer_front_most ) && IsCopperLayer( layer_back_most )
2774 && layer_front_most != layer_back_most )
2775 {
2776 int kidiam;
2777 int drillz = v.drill.ToPcbUnits();
2778 PCB_VIA* via = new PCB_VIA( m_board );
2779 m_board->Add( via );
2780
2781 if( v.diam )
2782 {
2783 kidiam = v.diam->ToPcbUnits();
2784 via->SetWidth( kidiam );
2785 }
2786 else
2787 {
2788 double annulus = drillz * m_rules->rvViaOuter; // eagle "restring"
2789 annulus = eagleClamp( m_rules->rlMinViaOuter, annulus,
2791 kidiam = KiROUND( drillz + 2 * annulus );
2792 via->SetWidth( kidiam );
2793 }
2794
2795 via->SetDrill( drillz );
2796
2797 // make sure the via diameter respects the restring rules
2798
2799 if( !v.diam || via->GetWidth() <= via->GetDrill() )
2800 {
2801 double annulus =
2803 (double) ( via->GetWidth() / 2 - via->GetDrill() ),
2805 via->SetWidth( drillz + 2 * annulus );
2806 }
2807
2808 if( kidiam < m_min_via )
2809 m_min_via = kidiam;
2810
2811 if( netclass && kidiam < netclass->GetViaDiameter() )
2812 netclass->SetViaDiameter( kidiam );
2813
2814 if( drillz < m_min_hole )
2815 m_min_hole = drillz;
2816
2817 if( netclass && drillz < netclass->GetViaDrill() )
2818 netclass->SetViaDrill( drillz );
2819
2820 if( ( kidiam - drillz ) / 2 < m_min_annulus )
2821 m_min_annulus = ( kidiam - drillz ) / 2;
2822
2823 if( layer_front_most == F_Cu && layer_back_most == B_Cu )
2824 {
2825 via->SetViaType( VIATYPE::THROUGH );
2826 }
2830 else if( v.layer_back_most - v.layer_front_most == 1 )
2831 {
2832 via->SetViaType( VIATYPE::MICROVIA );
2833 }
2834 else
2835 {
2836 via->SetViaType( VIATYPE::BLIND_BURIED );
2837 }
2838
2839 VECTOR2I pos( kicad_x( v.x ), kicad_y( v.y ) );
2840
2841 via->SetLayerPair( layer_front_most, layer_back_most );
2842 via->SetPosition( pos );
2843 via->SetEnd( pos );
2844
2845 via->SetNetCode( netCode );
2846 }
2847
2848 m_xpath->pop();
2849 }
2850
2851 else if( itemName == wxT( "contactref" ) )
2852 {
2853 m_xpath->push( "contactref" );
2854 // <contactref element="RN1" pad="7"/>
2855
2856 const wxString& reference = netItem->GetAttribute( "element" );
2857 const wxString& pad = netItem->GetAttribute( "pad" );
2858 wxString key = makeKey( reference, pad ) ;
2859
2860 m_pads_to_nets[ key ] = ENET( netCode, netName );
2861
2862 m_xpath->pop();
2863
2864 sawPad = true;
2865 }
2866
2867 else if( itemName == wxT( "polygon" ) )
2868 {
2869 m_xpath->push( "polygon" );
2870 auto* zone = loadPolygon( netItem );
2871
2872 if( zone )
2873 {
2874 zones.push_back( zone );
2875
2876 if( !zone->GetIsRuleArea() )
2877 zone->SetNetCode( netCode );
2878 }
2879
2880 m_xpath->pop(); // "polygon"
2881 }
2882
2883 netItem = netItem->GetNext();
2884 }
2885
2886 if( zones.size() && !sawPad )
2887 {
2888 // KiCad does not support an unconnected zone with its own non-zero netcode,
2889 // but only when assigned netcode = 0 w/o a name...
2890 for( ZONE* zone : zones )
2891 zone->SetNetCode( NETINFO_LIST::UNCONNECTED );
2892
2893 // therefore omit this signal/net.
2894 }
2895 else
2896 {
2897 netCode++;
2898 }
2899
2900 // Get next signal
2901 net = net->GetNext();
2902 }
2903
2904 m_xpath->pop(); // "signals.signal"
2905}
Handle the data for a net.
Definition: netinfo.h:66
void SetNetClass(const std::shared_ptr< NETCLASS > &aNetClass)
void SetWidth(int aWidth)
Definition: pcb_track.h:104
void SetEnd(const VECTOR2I &aEnd)
Definition: pcb_track.h:107
void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_track.h:100
wxString escapeName(const wxString &aNetName)
static T eagleClamp(T aMin, T aValue, T aMax)
std::vector< ZONE * > ZONES
Definition: eagle_plugin.h:44
@ CTX_NETCLASS
@ BLIND_BURIED
double rlMinViaOuter
minimum copper annulus on via
Definition: eagle_plugin.h:119
double rlMaxViaOuter
maximum copper annulus on via
Definition: eagle_plugin.h:120
double rvViaOuter
copper annulus is this percent of via hole
Definition: eagle_plugin.h:118
Eagle via.
Definition: eagle_parser.h:546

References BOARD::Add(), PNS::angle(), ARC_HIGH_DEF, B_Cu, BLIND_BURIED, checkpoint(), ConvertArcCenter(), CTX_NETCLASS, EWIRE::curve, DEG2RAD(), DEGREES_T, EVIA::diam, EVIA::drill, eagleClamp(), escapeName(), F_Cu, GetArcToSegmentCount(), BOARD::GetDesignSettings(), IsCopperLayer(), kicad_layer(), kicad_x(), kicad_y(), KiROUND(), EWIRE::layer, EVIA::layer_back_most, EVIA::layer_front_most, loadPolygon(), m_board, m_classMap, m_min_annulus, m_min_hole, m_min_trace, m_min_via, BOARD_DESIGN_SETTINGS::m_NetSettings, m_pads_to_nets, m_rules, m_xpath, makeKey(), MICROVIA, pad, XPATH::pop(), XPATH::push(), ERULES::rlMaxViaOuter, ERULES::rlMinViaOuter, ERULES::rvViaOuter, PCB_TRACK::SetEnd(), BOARD_ITEM::SetLayer(), NETINFO_ITEM::SetNetClass(), BOARD_CONNECTED_ITEM::SetNetCode(), PCB_TRACK::SetPosition(), PCB_TRACK::SetWidth(), THROUGH, ECOORD::ToPcbUnits(), NETINFO_LIST::UNCONNECTED, XPATH::Value(), via, EWIRE::width, EVIA::x, VECTOR2< T >::x, EWIRE::x1, EWIRE::x2, EVIA::y, VECTOR2< T >::y, EWIRE::y1, and EWIRE::y2.

Referenced by loadAllSections().

◆ makeFootprint()

FOOTPRINT * EAGLE_PLUGIN::makeFootprint ( wxXmlNode *  aPackage,
const wxString &  aPkgName 
)
private

Create a FOOTPRINT from an Eagle package.

Definition at line 1809 of file eagle_plugin.cpp.

1810{
1811 std::unique_ptr<FOOTPRINT> m = std::make_unique<FOOTPRINT>( m_board );
1812
1813 LIB_ID fpID;
1814 fpID.Parse( aPkgName, true );
1815 m->SetFPID( fpID );
1816
1817 // Get the first package item and iterate
1818 wxXmlNode* packageItem = aPackage->GetChildren();
1819
1820 // layer 27 is default layer for tValues
1821 // set default layer for created footprint
1822 PCB_LAYER_ID layer = kicad_layer( 27 );
1823 m.get()->Value().SetLayer( layer );
1824
1825 while( packageItem )
1826 {
1827 const wxString& itemName = packageItem->GetName();
1828
1829 if( itemName == wxT( "description" ) )
1830 m->SetDescription( packageItem->GetNodeContent() );
1831 else if( itemName == wxT( "wire" ) )
1832 packageWire( m.get(), packageItem );
1833 else if( itemName == wxT( "pad" ) )
1834 packagePad( m.get(), packageItem );
1835 else if( itemName == wxT( "text" ) )
1836 packageText( m.get(), packageItem );
1837 else if( itemName == wxT( "rectangle" ) )
1838 packageRectangle( m.get(), packageItem );
1839 else if( itemName == wxT( "polygon" ) )
1840 packagePolygon( m.get(), packageItem );
1841 else if( itemName == wxT( "circle" ) )
1842 packageCircle( m.get(), packageItem );
1843 else if( itemName == wxT( "hole" ) )
1844 packageHole( m.get(), packageItem, false );
1845 else if( itemName == wxT( "smd" ) )
1846 packageSMD( m.get(), packageItem );
1847
1848 packageItem = packageItem->GetNext();
1849 }
1850
1851 return m.release();
1852}
void packageCircle(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void packageSMD(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
Handles common pad properties.
void packagePolygon(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void packageText(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void packagePad(FOOTPRINT *aFootprint, wxXmlNode *aTree)
void packageWire(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void packageRectangle(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:50

References kicad_layer(), m_board, packageCircle(), packageHole(), packagePad(), packagePolygon(), packageRectangle(), packageSMD(), packageText(), packageWire(), and LIB_ID::Parse().

Referenced by loadLibrary().

◆ mapEagleLayersToKicad()

void EAGLE_PLUGIN::mapEagleLayersToKicad ( bool  aIsLibraryCache = false)
private

Generate mapping between Eagle and KiCad layers.

Warning
It is imperative that this gets called correctly because footprint libraries do not get remapped by the user on load. Otherwise, Pcbnew will crash when attempting to load footprint libraries that contain layers that do not exist in the EAGLE_LAYER definitions.
Parameters
aIsLibraryCacheis the flag to indicate when mapping the footprint library cache layers rather than the board layers.

Definition at line 2923 of file eagle_plugin.cpp.

2924{
2925 std::vector<INPUT_LAYER_DESC> inputDescs;
2926
2927 for ( const std::pair<const int, ELAYER>& layerPair : m_eagleLayers )
2928 {
2929 const ELAYER& eLayer = layerPair.second;
2930
2931 INPUT_LAYER_DESC layerDesc;
2932 std::tie( layerDesc.AutoMapLayer, layerDesc.PermittedLayers, layerDesc.Required ) =
2933 defaultKicadLayer( eLayer.number, aIsLibraryCache );
2934
2935 if( layerDesc.AutoMapLayer == UNDEFINED_LAYER )
2936 continue; // Ignore unused copper layers
2937
2938 layerDesc.Name = eLayer.name;
2939
2940 inputDescs.push_back( layerDesc );
2941 }
2942
2943 if( m_progressReporter && dynamic_cast<wxWindow*>( m_progressReporter ) )
2944 dynamic_cast<wxWindow*>( m_progressReporter )->Hide();
2945
2946 m_layer_map = m_layer_mapping_handler( inputDescs );
2947
2948 if( m_progressReporter && dynamic_cast<wxWindow*>( m_progressReporter ))
2949 dynamic_cast<wxWindow*>( m_progressReporter )->Show();
2950}
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
wxString name
Definition: eagle_parser.h:827
int number
Definition: eagle_parser.h:826
PCB_LAYER_ID AutoMapLayer
Best guess as to what the equivalent KiCad layer might be.
bool Required
Should we require the layer to be assigned?
LSET PermittedLayers
KiCad layers that the imported layer can be mapped onto.
wxString Name
Imported layer name as displayed in original application.

References INPUT_LAYER_DESC::AutoMapLayer, defaultKicadLayer(), m_eagleLayers, m_layer_map, LAYER_REMAPPABLE_PLUGIN::m_layer_mapping_handler, m_progressReporter, ELAYER::name, INPUT_LAYER_DESC::Name, ELAYER::number, INPUT_LAYER_DESC::PermittedLayers, INPUT_LAYER_DESC::Required, and UNDEFINED_LAYER.

Referenced by cacheLib(), and loadAllSections().

◆ orientFootprintAndText()

void EAGLE_PLUGIN::orientFootprintAndText ( FOOTPRINT aFootprint,
const EELEMENT e,
const EATTR aNameAttr,
const EATTR aValueAttr 
)
private

Definition at line 1635 of file eagle_plugin.cpp.

1637{
1638 if( e.rot )
1639 {
1640 if( e.rot->mirror )
1641 {
1642 aFootprint->SetOrientation( EDA_ANGLE( e.rot->degrees + 180.0, DEGREES_T ) );
1643 aFootprint->Flip( aFootprint->GetPosition(), false );
1644 }
1645 else
1646 {
1647 aFootprint->SetOrientation( EDA_ANGLE( e.rot->degrees, DEGREES_T ) );
1648 }
1649 }
1650
1651 orientFPText( aFootprint, e, &aFootprint->Reference(), aNameAttr );
1652 orientFPText( aFootprint, e, &aFootprint->Value(), aValueAttr );
1653}
void orientFPText(FOOTPRINT *aFootprint, const EELEMENT &e, FP_TEXT *aFPText, const EATTR *aAttr)
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:1766
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1553
VECTOR2I GetPosition() const override
Definition: footprint.h:192
opt_erot rot
Definition: eagle_parser.h:818
double degrees
Definition: eagle_parser.h:474
bool mirror
Definition: eagle_parser.h:472

References EROT::degrees, DEGREES_T, FOOTPRINT::Flip(), FOOTPRINT::GetPosition(), EROT::mirror, orientFPText(), FOOTPRINT::Reference(), EELEMENT::rot, FOOTPRINT::SetOrientation(), and FOOTPRINT::Value().

Referenced by loadElements().

◆ orientFPText()

void EAGLE_PLUGIN::orientFPText ( FOOTPRINT aFootprint,
const EELEMENT e,
FP_TEXT aFPText,
const EATTR aAttr 
)
private

Definition at line 1656 of file eagle_plugin.cpp.

1658{
1659 // Smashed part ?
1660 if( aAttr )
1661 {
1662 // Yes
1663 const EATTR& a = *aAttr;
1664
1665 if( a.value )
1666 {
1667 aFPText->SetText( *a.value );
1668 }
1669
1670 if( a.x && a.y ) // std::optional
1671 {
1672 VECTOR2I pos( kicad_x( *a.x ), kicad_y( *a.y ) );
1673 aFPText->SetTextPos( pos );
1674 }
1675
1676 // Even though size and ratio are both optional, I am not seeing
1677 // a case where ratio is present but size is not.
1678 double ratio = 8;
1679
1680 if( a.ratio )
1681 ratio = *a.ratio;
1682
1683 VECTOR2I fontz = aFPText->GetTextSize();
1684 int textThickness = KiROUND( fontz.y * ratio / 100 );
1685
1686 aFPText->SetTextThickness( textThickness );
1687 if( a.size )
1688 {
1689 fontz = kicad_fontz( *a.size, textThickness );
1690 aFPText->SetTextSize( fontz );
1691 }
1692
1693
1694 int align = ETEXT::BOTTOM_LEFT; // bottom-left is eagle default
1695
1696 if( a.align )
1697 align = a.align;
1698
1699 // The "rot" in a EATTR seems to be assumed to be zero if it is not
1700 // present, and this zero rotation becomes an override to the
1701 // package's text field. If they did not want zero, they specify
1702 // what they want explicitly.
1703 double degrees = a.rot ? a.rot->degrees : 0.0;
1704 double orient; // relative to parent
1705
1706 int sign = 1;
1707 bool spin = false;
1708
1709 if( a.rot )
1710 {
1711 spin = a.rot->spin;
1712 sign = a.rot->mirror ? -1 : 1;
1713 aFPText->SetMirrored( a.rot->mirror );
1714 }
1715
1716 if( degrees == 90 || degrees == 0 || spin )
1717 {
1718 orient = degrees - aFootprint->GetOrientation().AsDegrees();
1719 aFPText->SetTextAngle( EDA_ANGLE( sign * orient, DEGREES_T ) );
1720 }
1721 else if( degrees == 180 )
1722 {
1723 orient = 0 - aFootprint->GetOrientation().AsDegrees();
1724 aFPText->SetTextAngle( EDA_ANGLE( sign * orient, DEGREES_T ) );
1725 align = -align;
1726 }
1727 else if( degrees == 270 )
1728 {
1729 orient = 90 - aFootprint->GetOrientation().AsDegrees();
1730 align = -align;
1731 aFPText->SetTextAngle( EDA_ANGLE( sign * orient, DEGREES_T ) );
1732 }
1733 else
1734 {
1735 orient = 90 - degrees - aFootprint->GetOrientation().AsDegrees();
1736 aFPText->SetTextAngle( EDA_ANGLE( sign * orient, DEGREES_T ) );
1737 }
1738
1739 switch( align )
1740 {
1741 case ETEXT::TOP_RIGHT:
1744 break;
1745
1746 case ETEXT::BOTTOM_LEFT:
1749 break;
1750
1751 case ETEXT::TOP_LEFT:
1754 break;
1755
1759 break;
1760
1761 case ETEXT::TOP_CENTER:
1764 break;
1765
1769 break;
1770
1771 case ETEXT::CENTER:
1774 break;
1775
1776 case ETEXT::CENTER_LEFT:
1779 break;
1780
1784 break;
1785
1786 default:
1787 ;
1788 }
1789 }
1790 else
1791 {
1792 // Part is not smash so use Lib default for NAME/VALUE
1793 // the text is per the original package, sans <attribute>.
1794 double degrees = aFPText->GetTextAngle().AsDegrees()
1795 + aFootprint->GetOrientation().AsDegrees();
1796
1797 // @todo there are a few more cases than these to contend with:
1798 if( ( !aFPText->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ) )
1799 || ( aFPText->IsMirrored() && ( degrees == 360 ) ) )
1800 {
1801 // ETEXT::TOP_RIGHT:
1804 }
1805 }
1806}
double AsDegrees() const
Definition: eda_angle.h:149
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:117
bool IsMirrored() const
Definition: eda_text.h:129
VECTOR2I GetTextSize() const
Definition: eda_text.h:186
EDA_ANGLE GetOrientation() const
Definition: footprint.h:195
opt_double ratio
Definition: eagle_parser.h:600
opt_ecoord size
Definition: eagle_parser.h:598
opt_ecoord y
Definition: eagle_parser.h:597
opt_erot rot
Definition: eagle_parser.h:601
opt_int align
Definition: eagle_parser.h:610
opt_ecoord x
Definition: eagle_parser.h:596
bool spin
Definition: eagle_parser.h:473

References std::abs(), EATTR::align, EDA_ANGLE::AsDegrees(), ETEXT::BOTTOM_CENTER, ETEXT::BOTTOM_LEFT, ETEXT::BOTTOM_RIGHT, ETEXT::CENTER, ETEXT::CENTER_LEFT, ETEXT::CENTER_RIGHT, EROT::degrees, DEGREES_T, FOOTPRINT::GetOrientation(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, EDA_TEXT::IsMirrored(), kicad_fontz(), kicad_x(), kicad_y(), KiROUND(), EROT::mirror, EATTR::ratio, EATTR::rot, EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetMirrored(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), EDA_TEXT::SetVertJustify(), sign(), EATTR::size, EROT::spin, ETEXT::TOP_CENTER, ETEXT::TOP_LEFT, ETEXT::TOP_RIGHT, EATTR::value, EATTR::x, EATTR::y, and VECTOR2< T >::y.

Referenced by orientFootprintAndText().

◆ packageCircle()

void EAGLE_PLUGIN::packageCircle ( FOOTPRINT aFootprint,
wxXmlNode *  aTree 
) const
private

Definition at line 2326 of file eagle_plugin.cpp.

2327{
2328 ECIRCLE e( aTree );
2329
2330 int width = e.width.ToPcbUnits();
2331 int radius = e.radius.ToPcbUnits();
2332
2333 if( e.layer == EAGLE_LAYER::TRESTRICT
2334 || e.layer == EAGLE_LAYER::BRESTRICT
2335 || e.layer == EAGLE_LAYER::VRESTRICT )
2336 {
2337 FP_ZONE* zone = new FP_ZONE( aFootprint );
2338 aFootprint->Add( zone, ADD_MODE::APPEND );
2339
2340 setKeepoutSettingsToZone( zone, e.layer );
2341
2342 // approximate circle as polygon
2343 VECTOR2I center( kicad_x( e.x ), kicad_y( e.y ) );
2344 int outlineRadius = radius + ( width / 2 );
2345 int segsInCircle = GetArcToSegmentCount( outlineRadius, ARC_HIGH_DEF, FULL_CIRCLE );
2346 EDA_ANGLE delta = ANGLE_360 / segsInCircle;
2347
2349 {
2350 VECTOR2I rotatedPoint( outlineRadius, 0 );
2351 RotatePoint( rotatedPoint, angle );
2352 zone->AppendCorner( center + rotatedPoint, -1 );
2353 }
2354
2355 if( width > 0 )
2356 {
2357 zone->NewHole();
2358 int innerRadius = radius - ( width / 2 );
2359 segsInCircle = GetArcToSegmentCount( innerRadius, ARC_HIGH_DEF, FULL_CIRCLE );
2360 delta = ANGLE_360 / segsInCircle;
2361
2363 {
2364 VECTOR2I rotatedPoint( innerRadius, 0 );
2365 RotatePoint( rotatedPoint, angle );
2366 zone->AppendCorner( center + rotatedPoint, 0 );
2367 }
2368 }
2369
2372 }
2373 else
2374 {
2375 PCB_LAYER_ID layer = kicad_layer( e.layer );
2376
2377 if( layer == UNDEFINED_LAYER )
2378 {
2379 wxLogMessage( wxString::Format( _( "Ignoring a circle since Eagle layer '%s' (%d) "
2380 "was not mapped" ),
2381 eagle_layer_name( e.layer ), e.layer ) );
2382 return;
2383 }
2384
2385 FP_SHAPE* gr = new FP_SHAPE( aFootprint, SHAPE_T::CIRCLE );
2386
2387 // width == 0 means filled circle
2388 if( width <= 0 )
2389 {
2390 width = radius;
2391 radius = radius / 2;
2392 gr->SetFilled( true );
2393 }
2394
2395 aFootprint->Add( gr );
2397
2398 switch( (int) layer )
2399 {
2400 case UNDEFINED_LAYER:
2401 layer = Cmts_User;
2402 break;
2403 default:
2404 break;
2405 }
2406
2407 gr->SetLayer( layer );
2408 gr->SetStart0( VECTOR2I( kicad_x( e.x ), kicad_y( e.y ) ) );
2409 gr->SetEnd0( VECTOR2I( kicad_x( e.x ) + radius, kicad_y( e.y ) ) );
2410 gr->SetDrawCoord();
2411 }
2412}
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:549
void SetEnd0(const VECTOR2I &aPoint)
Definition: fp_shape.h:94
void SetStart0(const VECTOR2I &aPoint)
Definition: fp_shape.h:91
virtual void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:80
A specialization of ZONE for use in footprints.
Definition: zone.h:897

References _, FOOTPRINT::Add(), PNS::angle(), ANGLE_0, ANGLE_360, APPEND, ZONE::AppendCorner(), ARC_HIGH_DEF, EAGLE_LAYER::BRESTRICT, CIRCLE, Cmts_User, delta, DIAGONAL_EDGE, eagle_layer_name(), Format(), FULL_CIRCLE, GetArcToSegmentCount(), ZONE::GetDefaultHatchPitch(), kicad_layer(), kicad_x(), kicad_y(), ECIRCLE::layer, ZONE::NewHole(), ECIRCLE::radius, RotatePoint(), ZONE::SetBorderDisplayStyle(), FP_SHAPE::SetDrawCoord(), FP_SHAPE::SetEnd0(), EDA_SHAPE::SetFilled(), setKeepoutSettingsToZone(), BOARD_ITEM::SetLayer(), FP_SHAPE::SetStart0(), PCB_SHAPE::SetStroke(), SOLID, ECOORD::ToPcbUnits(), EAGLE_LAYER::TRESTRICT, UNDEFINED_LAYER, EAGLE_LAYER::VRESTRICT, ECIRCLE::width, ECIRCLE::x, and ECIRCLE::y.

Referenced by makeFootprint().

◆ packageHole()

void EAGLE_PLUGIN::packageHole ( FOOTPRINT aFootprint,
wxXmlNode *  aTree,
bool  aCenter 
) const
private
Parameters
aFootprintThe KiCad footprint to which to assign the hole.
aTreeThe Eagle XML node that is of type "hole".
aCenterIf true, center the hole in the footprint and offset the footprint position.

Definition at line 2415 of file eagle_plugin.cpp.

2416{
2417 EHOLE e( aTree );
2418
2419 if( e.drill.value == 0 )
2420 return;
2421
2422 // we add a PAD_ATTRIB::NPTH pad to this footprint.
2423 PAD* pad = new PAD( aFootprint );
2424 aFootprint->Add( pad );
2425
2426 pad->SetKeepTopBottom( false ); // TODO: correct? This seems to be KiCad default on import
2427
2428 pad->SetShape( PAD_SHAPE::CIRCLE );
2429 pad->SetAttribute( PAD_ATTRIB::NPTH );
2430
2431 // Mechanical purpose only:
2432 // no offset, no net name, no pad name allowed
2433 // pad->SetOffset( VECTOR2I( 0, 0 ) );
2434 // pad->SetNumber( wxEmptyString );
2435
2436 VECTOR2I padpos( kicad_x( e.x ), kicad_y( e.y ) );
2437
2438 if( aCenter )
2439 {
2440 pad->SetPos0( VECTOR2I( 0, 0 ) );
2441 aFootprint->SetPosition( padpos );
2442 pad->SetPosition( padpos );
2443 }
2444 else
2445 {
2446 pad->SetPos0( padpos );
2447 pad->SetPosition( padpos + aFootprint->GetPosition() );
2448 }
2449
2450 wxSize sz( e.drill.ToPcbUnits(), e.drill.ToPcbUnits() );
2451
2452 pad->SetDrillSize( sz );
2453 pad->SetSize( sz );
2454
2455 pad->SetLayerSet( LSET::AllCuMask().set( B_Mask ).set( F_Mask ) );
2456}
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
@ NPTH
like PAD_PTH, but not plated
Eagle hole element.
Definition: eagle_parser.h:798

References FOOTPRINT::Add(), LSET::AllCuMask(), B_Mask, CIRCLE, EHOLE::drill, F_Mask, FOOTPRINT::GetPosition(), kicad_x(), kicad_y(), NPTH, pad, PAD, FOOTPRINT::SetPosition(), ECOORD::ToPcbUnits(), ECOORD::value, EHOLE::x, and EHOLE::y.

Referenced by loadPlain(), and makeFootprint().

◆ packagePad()

void EAGLE_PLUGIN::packagePad ( FOOTPRINT aFootprint,
wxXmlNode *  aTree 
)
private

Definition at line 1927 of file eagle_plugin.cpp.

1928{
1929 // this is thru hole technology here, no SMDs
1930 EPAD e( aTree );
1931 int shape = EPAD::UNDEF;
1932 int eagleDrillz = e.drill.ToPcbUnits();
1933
1934 std::unique_ptr<PAD> pad = std::make_unique<PAD>( aFootprint );
1935 transferPad( e, pad.get() );
1936
1937 if( e.first && *e.first && m_rules->psFirst != EPAD::UNDEF )
1938 shape = m_rules->psFirst;
1939 else if( aFootprint->GetLayer() == F_Cu && m_rules->psTop != EPAD::UNDEF )
1940 shape = m_rules->psTop;
1941 else if( aFootprint->GetLayer() == B_Cu && m_rules->psBottom != EPAD::UNDEF )
1942 shape = m_rules->psBottom;
1943
1944 pad->SetDrillSize( wxSize( eagleDrillz, eagleDrillz ) );
1945 pad->SetLayerSet( LSET::AllCuMask() );
1946
1947 if( eagleDrillz < m_min_hole )
1948 m_min_hole = eagleDrillz;
1949
1950 // Solder mask
1951 if( !e.stop || *e.stop == true ) // enabled by default
1952 pad->SetLayerSet( pad->GetLayerSet().set( B_Mask ).set( F_Mask ) );
1953
1954 if( shape == EPAD::ROUND || shape == EPAD::SQUARE || shape == EPAD::OCTAGON )
1955 e.shape = shape;
1956
1957 if( e.shape )
1958 {
1959 switch( *e.shape )
1960 {
1961 case EPAD::ROUND:
1962 pad->SetShape( PAD_SHAPE::CIRCLE );
1963 break;
1964
1965 case EPAD::OCTAGON:
1966 pad->SetShape( PAD_SHAPE::CHAMFERED_RECT );
1967 pad->SetChamferPositions( RECT_CHAMFER_ALL );
1968 pad->SetChamferRectRatio( 1 - M_SQRT1_2 ); // Regular polygon
1969 break;
1970
1971 case EPAD::LONG:
1972 pad->SetShape( PAD_SHAPE::OVAL );
1973 break;
1974
1975 case EPAD::SQUARE:
1976 pad->SetShape( PAD_SHAPE::RECT );
1977 break;
1978
1979 case EPAD::OFFSET:
1980 pad->SetShape( PAD_SHAPE::OVAL );
1981 break;
1982 }
1983 }
1984 else
1985 {
1986 // if shape is not present, our default is circle and that matches their default "round"
1987 }
1988
1989 if( e.diameter && e.diameter->value > 0 )
1990 {
1991 int diameter = e.diameter->ToPcbUnits();
1992 pad->SetSize( wxSize( diameter, diameter ) );
1993 }
1994 else
1995 {
1996 double drillz = pad->GetDrillSize().x;
1997 double annulus = drillz * m_rules->rvPadTop; // copper annulus, eagle "restring"
1998 annulus = eagleClamp( m_rules->rlMinPadTop, annulus, m_rules->rlMaxPadTop );
1999 int diameter = KiROUND( drillz + 2 * annulus );
2000 pad->SetSize( wxSize( KiROUND( diameter ), KiROUND( diameter ) ) );
2001 }
2002
2003 if( pad->GetShape() == PAD_SHAPE::OVAL )
2004 {
2005 // The Eagle "long" pad is wider than it is tall; m_elongation is percent elongation
2006 VECTOR2I sz = pad->GetSize();
2007 sz.x = ( sz.x * ( 100 + m_rules->psElongationLong ) ) / 100;
2008 pad->SetSize( sz );
2009
2010 if( e.shape && *e.shape == EPAD::OFFSET )
2011 {
2012 int offset = KiROUND( ( sz.x - sz.y ) / 2.0 );
2013 pad->SetOffset( VECTOR2I( offset, 0 ) );
2014 }
2015 }
2016
2017 if( e.rot )
2018 pad->SetOrientation( EDA_ANGLE( e.rot->degrees, DEGREES_T ) );
2019
2020 if( pad->GetSizeX() > 0 && pad->GetSizeY() > 0 )
2021 {
2022 aFootprint->Add( pad.release() );
2023 }
2024 else
2025 {
2026 wxLogError( _( "Invalid zero-sized pad ignored in\nfile: %s" ), m_board->GetFileName() );
2027 }
2028}
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:167
const wxString & GetFileName() const
Definition: board.h:302
void transferPad(const EPAD_COMMON &aEaglePad, PAD *aPad) const
Deletes the footprint templates list.
Eagle thru hole pad.
Definition: eagle_parser.h:705
@ OCTAGON
Definition: eagle_parser.h:714
@ SQUARE
Definition: eagle_parser.h:712
@ OFFSET
Definition: eagle_parser.h:716
int psBottom
Shape of the bottom pads.
Definition: eagle_plugin.h:101
int psElongationLong
Definition: eagle_plugin.h:86
int psTop
Shape of the top pads.
Definition: eagle_plugin.h:100
double rvPadTop
top pad size as percent of drill size
Definition: eagle_plugin.h:112
double rlMinPadTop
minimum copper annulus on through hole pads
Definition: eagle_plugin.h:115
double rlMaxPadTop
maximum copper annulus on through hole pads
Definition: eagle_plugin.h:116
int psFirst
Shape of the first pads.
Definition: eagle_plugin.h:102

References _, FOOTPRINT::Add(), LSET::AllCuMask(), B_Cu, B_Mask, CHAMFERED_RECT, CIRCLE, EROT::degrees, DEGREES_T, EPAD::diameter, EPAD::drill, eagleClamp(), F_Cu, F_Mask, EPAD::first, BOARD::GetFileName(), BOARD_ITEM::GetLayer(), KiROUND(), EPAD::LONG, m_board, m_min_hole, m_rules, EPAD::OCTAGON, EPAD::OFFSET, OVAL, pad, ERULES::psBottom, ERULES::psElongationLong, ERULES::psFirst, ERULES::psTop, RECT, RECT_CHAMFER_ALL, ERULES::rlMaxPadTop, ERULES::rlMinPadTop, EPAD_COMMON::rot, EPAD::ROUND, ERULES::rvPadTop, EPAD::shape, EPAD::SQUARE, EPAD_COMMON::stop, ECOORD::ToPcbUnits(), transferPad(), EPAD::UNDEF, ECOORD::value, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by makeFootprint().

◆ packagePolygon()

void EAGLE_PLUGIN::packagePolygon ( FOOTPRINT aFootprint,
wxXmlNode *  aTree 
) const
private

Definition at line 2223 of file eagle_plugin.cpp.

2224{
2225 EPOLYGON p( aTree );
2226
2227 std::vector<VECTOR2I> pts;
2228
2229 // Get the first vertex and iterate
2230 wxXmlNode* vertex = aTree->GetChildren();
2231 std::vector<EVERTEX> vertices;
2232
2233 // Create a circular vector of vertices
2234 // The "curve" parameter indicates a curve from the current
2235 // to the next vertex, so we keep the first at the end as well
2236 // to allow the curve to link back
2237 while( vertex )
2238 {
2239 if( vertex->GetName() == wxT( "vertex" ) )
2240 vertices.emplace_back( vertex );
2241
2242 vertex = vertex->GetNext();
2243 }
2244
2245 vertices.push_back( vertices[0] );
2246
2247 for( size_t i = 0; i < vertices.size() - 1; i++ )
2248 {
2249 EVERTEX v1 = vertices[i];
2250
2251 // Append the corner
2252 pts.emplace_back( kicad_x( v1.x ), kicad_y( v1.y ) );
2253
2254 if( v1.curve )
2255 {
2256 EVERTEX v2 = vertices[i + 1];
2257 VECTOR2I center =
2258 ConvertArcCenter( VECTOR2I( kicad_x( v1.x ), kicad_y( v1.y ) ),
2259 VECTOR2I( kicad_x( v2.x ), kicad_y( v2.y ) ), *v1.curve );
2260 double angle = DEG2RAD( *v1.curve );
2261 double end_angle = atan2( kicad_y( v2.y ) - center.y, kicad_x( v2.x ) - center.x );
2262 double radius = sqrt( pow( center.x - kicad_x( v1.x ), 2 )
2263 + pow( center.y - kicad_y( v1.y ), 2 ) );
2264
2265 // Don't allow a zero-radius curve
2266 if( KiROUND( radius ) == 0 )
2267 radius = 1.0;
2268
2269 int segCount = GetArcToSegmentCount( KiROUND( radius ), ARC_HIGH_DEF,
2270 EDA_ANGLE( *v1.curve, DEGREES_T ) );
2271 double delta = angle / segCount;
2272
2273 for( double a = end_angle + angle; fabs( a - end_angle ) > fabs( delta ); a -= delta )
2274 {
2275 pts.push_back(
2276 VECTOR2I( KiROUND( radius * cos( a ) ), KiROUND( radius * sin( a ) ) )
2277 + center );
2278 }
2279 }
2280 }
2281
2282 if( p.layer == EAGLE_LAYER::TRESTRICT
2283 || p.layer == EAGLE_LAYER::BRESTRICT
2284 || p.layer == EAGLE_LAYER::VRESTRICT )
2285 {
2286 FP_ZONE* zone = new FP_ZONE( aFootprint );
2287 aFootprint->Add( zone, ADD_MODE::APPEND );
2288
2289 setKeepoutSettingsToZone( zone, p.layer );
2290
2291 SHAPE_LINE_CHAIN outline( pts );
2292 outline.SetClosed( true );
2293 zone->Outline()->AddOutline( outline );
2294
2297 }
2298 else
2299 {
2300 PCB_LAYER_ID layer = kicad_layer( p.layer );
2301
2302 if( layer == UNDEFINED_LAYER )
2303 {
2304 wxLogMessage( wxString::Format( _( "Ignoring a polygon since Eagle layer '%s' (%d) "
2305 "was not mapped" ),
2306 eagle_layer_name( p.layer ), p.layer ) );
2307 return;
2308 }
2309
2310 FP_SHAPE* dwg = new FP_SHAPE( aFootprint, SHAPE_T::POLY );
2311
2312 aFootprint->Add( dwg );
2313
2314 dwg->SetStroke( STROKE_PARAMS( 0 ) );
2315 dwg->SetFilled( true );
2316 dwg->SetLayer( layer );
2317
2318 dwg->SetPolyPoints( pts );
2319 dwg->SetDrawCoord();
2320 dwg->GetPolyShape().Inflate( p.width.ToPcbUnits() / 2, 32,
2322 }
2323}
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:243
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
Definition: eda_shape.cpp:1069
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
SHAPE_POLY_SET * Outline()
Definition: zone.h:305

References _, FOOTPRINT::Add(), SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS, PNS::angle(), APPEND, ARC_HIGH_DEF, EAGLE_LAYER::BRESTRICT, ConvertArcCenter(), EVERTEX::curve, DEG2RAD(), DEGREES_T, delta, DIAGONAL_EDGE, eagle_layer_name(), Format(), GetArcToSegmentCount(), ZONE::GetDefaultHatchPitch(), EDA_SHAPE::GetPolyShape(), SHAPE_POLY_SET::Inflate(), kicad_layer(), kicad_x(), kicad_y(), KiROUND(), EPOLYGON::layer, ZONE::Outline(), POLY, ZONE::SetBorderDisplayStyle(), SHAPE_LINE_CHAIN::SetClosed(), FP_SHAPE::SetDrawCoord(), EDA_SHAPE::SetFilled(), setKeepoutSettingsToZone(), BOARD_ITEM::SetLayer(), EDA_SHAPE::SetPolyPoints(), PCB_SHAPE::SetStroke(), ECOORD::ToPcbUnits(), EAGLE_LAYER::TRESTRICT, UNDEFINED_LAYER, v2, EAGLE_LAYER::VRESTRICT, EPOLYGON::width, EVERTEX::x, VECTOR2< T >::x, EVERTEX::y, and VECTOR2< T >::y.

Referenced by makeFootprint().

◆ packageRectangle()

void EAGLE_PLUGIN::packageRectangle ( FOOTPRINT aFootprint,
wxXmlNode *  aTree 
) const
private

Definition at line 2157 of file eagle_plugin.cpp.

2158{
2159 ERECT r( aTree );
2160
2161 if( r.layer == EAGLE_LAYER::TRESTRICT || r.layer == EAGLE_LAYER::BRESTRICT
2162 || r.layer == EAGLE_LAYER::VRESTRICT )
2163 {
2164 FP_ZONE* zone = new FP_ZONE( aFootprint );
2165 aFootprint->Add( zone, ADD_MODE::APPEND );
2166
2167 setKeepoutSettingsToZone( zone, r.layer );
2168
2169 const int outlineIdx = -1; // this is the id of the copper zone main outline
2170 zone->AppendCorner( VECTOR2I( kicad_x( r.x1 ), kicad_y( r.y1 ) ), outlineIdx );
2171 zone->AppendCorner( VECTOR2I( kicad_x( r.x2 ), kicad_y( r.y1 ) ), outlineIdx );
2172 zone->AppendCorner( VECTOR2I( kicad_x( r.x2 ), kicad_y( r.y2 ) ), outlineIdx );
2173 zone->AppendCorner( VECTOR2I( kicad_x( r.x1 ), kicad_y( r.y2 ) ), outlineIdx );
2174
2175 if( r.rot )
2176 {
2177 VECTOR2I center( ( kicad_x( r.x1 ) + kicad_x( r.x2 ) ) / 2,
2178 ( kicad_y( r.y1 ) + kicad_y( r.y2 ) ) / 2 );
2179 zone->Rotate( center, EDA_ANGLE( r.rot->degrees, DEGREES_T ) );
2180 }
2181
2184 }
2185 else
2186 {
2187 PCB_LAYER_ID layer = kicad_layer( r.layer );
2188
2189 if( layer == UNDEFINED_LAYER )
2190 {
2191 wxLogMessage( wxString::Format( _( "Ignoring a rectangle since Eagle layer '%s' (%d) "
2192 "was not mapped" ),
2193 eagle_layer_name( r.layer ), r.layer ) );
2194 return;
2195 }
2196
2197 FP_SHAPE* dwg = new FP_SHAPE( aFootprint, SHAPE_T::POLY );
2198
2199 aFootprint->Add( dwg );
2200
2201 dwg->SetLayer( layer );
2202 dwg->SetStroke( STROKE_PARAMS( 0 ) );
2203 dwg->SetFilled( true );
2204
2205 std::vector<VECTOR2I> pts;
2206
2207 VECTOR2I start( VECTOR2I( kicad_x( r.x1 ), kicad_y( r.y1 ) ) );
2208 VECTOR2I end( VECTOR2I( kicad_x( r.x1 ), kicad_y( r.y2 ) ) );
2209
2210 pts.push_back( start );
2211 pts.emplace_back( kicad_x( r.x2 ), kicad_y( r.y1 ) );
2212 pts.emplace_back( kicad_x( r.x2 ), kicad_y( r.y2 ) );
2213 pts.push_back( end );
2214
2215 dwg->SetPolyPoints( pts );
2216
2217 if( r.rot )
2218 dwg->Rotate( dwg->GetCenter(), EDA_ANGLE( r.rot->degrees, DEGREES_T ) );
2219 }
2220}
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: fp_shape.cpp:343
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:65

References _, FOOTPRINT::Add(), APPEND, ZONE::AppendCorner(), EAGLE_LAYER::BRESTRICT, DEGREES_T, DIAGONAL_EDGE, eagle_layer_name(), Format(), PCB_SHAPE::GetCenter(), ZONE::GetDefaultHatchPitch(), kicad_layer(), kicad_x(), kicad_y(), POLY, r, ZONE::Rotate(), FP_SHAPE::Rotate(), ZONE::SetBorderDisplayStyle(), EDA_SHAPE::SetFilled(), setKeepoutSettingsToZone(), BOARD_ITEM::SetLayer(), EDA_SHAPE::SetPolyPoints(), PCB_SHAPE::SetStroke(), EAGLE_LAYER::TRESTRICT, UNDEFINED_LAYER, and EAGLE_LAYER::VRESTRICT.

Referenced by makeFootprint().

◆ packageSMD()

void EAGLE_PLUGIN::packageSMD ( FOOTPRINT aFootprint,
wxXmlNode *  aTree 
) const
private

Handles common pad properties.

Definition at line 2459 of file eagle_plugin.cpp.

2460{
2461 ESMD e( aTree );
2462 PCB_LAYER_ID layer = kicad_layer( e.layer );
2463
2464 if( !IsCopperLayer( layer ) || e.dx.value == 0 || e.dy.value == 0 )
2465 return;
2466
2467 PAD* pad = new PAD( aFootprint );
2468 aFootprint->Add( pad );
2469 transferPad( e, pad );
2470
2471 pad->SetKeepTopBottom( false ); // TODO: correct? This seems to be KiCad default on import
2472
2473 pad->SetShape( PAD_SHAPE::RECT );
2474 pad->SetAttribute( PAD_ATTRIB::SMD );
2475
2476 wxSize padSize( e.dx.ToPcbUnits(), e.dy.ToPcbUnits() );
2477 pad->SetSize( padSize );
2478 pad->SetLayer( layer );
2479
2480 const LSET front( 3, F_Cu, F_Paste, F_Mask );
2481 const LSET back( 3, B_Cu, B_Paste, B_Mask );
2482
2483 if( layer == F_Cu )
2484 pad->SetLayerSet( front );
2485 else if( layer == B_Cu )
2486 pad->SetLayerSet( back );
2487
2488 int minPadSize = std::min( padSize.x, padSize.y );
2489
2490 // Rounded rectangle pads
2491 int roundRadius =
2492 eagleClamp( m_rules->srMinRoundness * 2, (int) ( minPadSize * m_rules->srRoundness ),
2493 m_rules->srMaxRoundness * 2 );
2494
2495 if( e.roundness || roundRadius > 0 )
2496 {
2497 double roundRatio = (double) roundRadius / minPadSize / 2.0;
2498
2499 // Eagle uses a different definition of roundness, hence division by 200
2500 if( e.roundness )
2501 roundRatio = std::fmax( *e.roundness / 200.0, roundRatio );
2502
2503 pad->SetShape( PAD_SHAPE::ROUNDRECT );
2504 pad->SetRoundRectRadiusRatio( roundRatio );
2505 }
2506
2507 if( e.rot )
2508 pad->SetOrientation( EDA_ANGLE( e.rot->degrees, DEGREES_T ) );
2509
2510 pad->SetLocalSolderPasteMargin( -eagleClamp( m_rules->mlMinCreamFrame,
2511 (int) ( m_rules->mvCreamFrame * minPadSize ),
2513
2514 // Solder mask
2515 if( e.stop && *e.stop == false ) // enabled by default
2516 {
2517 if( layer == F_Cu )
2518 pad->SetLayerSet( pad->GetLayerSet().set( F_Mask, false ) );
2519 else if( layer == B_Cu )
2520 pad->SetLayerSet( pad->GetLayerSet().set( B_Mask, false ) );
2521 }
2522
2523 // Solder paste (only for SMD pads)
2524 if( e.cream && *e.cream == false ) // enabled by default
2525 {
2526 if( layer == F_Cu )
2527 pad->SetLayerSet( pad->GetLayerSet().set( F_Paste, false ) );
2528 else if( layer == B_Cu )
2529 pad->SetLayerSet( pad->GetLayerSet().set( B_Paste, false ) );
2530 }
2531}
@ SMD
Smd pad, appears on the solder paste layer (default)
double srRoundness
corner rounding ratio for SMD pads (percentage)
Definition: eagle_plugin.h:104
int mlMaxCreamFrame
solder paste mask, maximum size (Eagle mils, here nanometers)
Definition: eagle_plugin.h:98
int mlMinCreamFrame
solder paste mask, minimum size (Eagle mils, here nanometers)
Definition: eagle_plugin.h:97
int srMaxRoundness
Definition: eagle_plugin.h:110
double mvCreamFrame
Definition: eagle_plugin.h:94
int srMinRoundness
corner rounding radius, maximum size (Eagle mils, here nanometers)
Definition: eagle_plugin.h:107
Eagle SMD pad.
Definition: eagle_parser.h:727

References FOOTPRINT::Add(), B_Cu, B_Mask, B_Paste, ESMD::cream, EROT::degrees, DEGREES_T, ESMD::dx, ESMD::dy, eagleClamp(), F_Cu, F_Mask, F_Paste, IsCopperLayer(), kicad_layer(), ESMD::layer, m_rules, ERULES::mlMaxCreamFrame, ERULES::mlMinCreamFrame, ERULES::mvCreamFrame, pad, PAD, RECT, EPAD_COMMON::rot, ESMD::roundness, ROUNDRECT, SMD, ERULES::srMaxRoundness, ERULES::srMinRoundness, ERULES::srRoundness, EPAD_COMMON::stop, ECOORD::ToPcbUnits(), transferPad(), and ECOORD::value.

Referenced by makeFootprint().

◆ packageText()

void EAGLE_PLUGIN::packageText ( FOOTPRINT aFootprint,
wxXmlNode *  aTree 
) const
private

Definition at line 2031 of file eagle_plugin.cpp.

2032{
2033 ETEXT t( aTree );
2034 PCB_LAYER_ID layer = kicad_layer( t.layer );
2035
2036 if( layer == UNDEFINED_LAYER )
2037 {
2038 wxLogMessage( wxString::Format( _( "Ignoring a text since Eagle layer '%s' (%d) "
2039 "was not mapped" ),
2040 eagle_layer_name( t.layer ), t.layer ) );
2041 return;
2042 }
2043
2044 FP_TEXT* textItem;
2045
2046 if( t.text.Upper() == wxT( ">NAME" ) && aFootprint->GetReference().IsEmpty() )
2047 {
2048 textItem = &aFootprint->Reference();
2049
2050 textItem->SetText( wxT( "REF**" ) );
2051 }
2052 else if( t.text.Upper() == wxT( ">VALUE" ) && aFootprint->GetValue().IsEmpty() )
2053 {
2054 textItem = &aFootprint->Value();
2055
2056 textItem->SetText( aFootprint->GetFPID().GetLibItemName() );
2057 }
2058 else
2059 {
2060 // FIXME: graphical text items are rotated for some reason.
2061 textItem = new FP_TEXT( aFootprint );
2062 aFootprint->Add( textItem );
2063
2064 textItem->SetText( interpret_text( t.text ) );
2065 }
2066
2067 VECTOR2I pos( kicad_x( t.x ), kicad_y( t.y ) );
2068
2069 textItem->SetTextPos( pos );
2070 textItem->SetPos0( pos - aFootprint->GetPosition() );
2071
2072 textItem->SetLayer( layer );
2073
2074 double ratio = t.ratio ? *t.ratio : 8; // DTD says 8 is default
2075 int textThickness = KiROUND( t.size.ToPcbUnits() * ratio / 100 );
2076
2077 textItem->SetTextThickness( textThickness );
2078 textItem->SetTextSize( kicad_fontz( t.size, textThickness ) );
2079
2080 int align = t.align ? *t.align : ETEXT::BOTTOM_LEFT; // bottom-left is eagle default
2081
2082 // An eagle package is never rotated, the DTD does not allow it.
2083 // angle -= aFootprint->GetOrienation();
2084
2085 if( t.rot )
2086 {
2087 int sign = t.rot->mirror ? -1 : 1;
2088 textItem->SetMirrored( t.rot->mirror );
2089
2090 double degrees = t.rot->degrees;
2091
2092 if( degrees == 90 || t.rot->spin )
2093 {
2094 textItem->SetTextAngle( EDA_ANGLE( sign * degrees, DEGREES_T ) );
2095 }
2096 else if( degrees == 180 )
2097 {
2098 align = ETEXT::TOP_RIGHT;
2099 }
2100 else if( degrees == 270 )
2101 {
2102 align = ETEXT::TOP_RIGHT;
2103 textItem->SetTextAngle( EDA_ANGLE( sign * 90, DEGREES_T ) );
2104 }
2105 }
2106
2107 switch( align )
2108 {
2109 case ETEXT::CENTER:
2112 break;
2113
2114 case ETEXT::CENTER_LEFT:
2117 break;
2118
2122 break;
2123
2124 case ETEXT::TOP_CENTER:
2127 break;
2128
2129 case ETEXT::TOP_LEFT:
2132 break;
2133
2134 case ETEXT::TOP_RIGHT:
2137 break;
2138
2142 break;
2143
2144 case ETEXT::BOTTOM_LEFT:
2147 break;
2148
2152 break;
2153 }
2154}
const LIB_ID & GetFPID() const
Definition: footprint.h:207
void SetPos0(const VECTOR2I &aPos)
Definition: fp_text.h:123
const UTF8 & GetLibItemName() const
Definition: lib_id.h:101

References _, FOOTPRINT::Add(), ETEXT::align, ETEXT::BOTTOM_CENTER, ETEXT::BOTTOM_LEFT, ETEXT::BOTTOM_RIGHT, ETEXT::CENTER, ETEXT::CENTER_LEFT, ETEXT::CENTER_RIGHT, EROT::degrees, DEGREES_T, eagle_layer_name(), Format(), FOOTPRINT::GetFPID(), LIB_ID::GetLibItemName(), FOOTPRINT::GetPosition(), FOOTPRINT::GetReference(), FOOTPRINT::GetValue(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, interpret_text(), kicad_fontz(), kicad_layer(), kicad_x(), kicad_y(), KiROUND(), ETEXT::layer, EROT::mirror, ETEXT::ratio, FOOTPRINT::Reference(), ETEXT::rot, EDA_TEXT::SetHorizJustify(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), FP_TEXT::SetPos0(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), EDA_TEXT::SetVertJustify(), sign(), ETEXT::size, EROT::spin, ETEXT::text, ETEXT::TOP_CENTER, ETEXT::TOP_LEFT, ETEXT::TOP_RIGHT, ECOORD::ToPcbUnits(), UNDEFINED_LAYER, FOOTPRINT::Value(), ETEXT::x, and ETEXT::y.

Referenced by makeFootprint().

◆ packageWire()

void EAGLE_PLUGIN::packageWire ( FOOTPRINT aFootprint,
wxXmlNode *  aTree 
) const
private

Definition at line 1855 of file eagle_plugin.cpp.

1856{
1857 EWIRE w( aTree );
1858 PCB_LAYER_ID layer = kicad_layer( w.layer );
1859 VECTOR2I start( kicad_x( w.x1 ), kicad_y( w.y1 ) );
1860 VECTOR2I end( kicad_x( w.x2 ), kicad_y( w.y2 ) );
1861 int width = w.width.ToPcbUnits();
1862
1863 if( layer == UNDEFINED_LAYER )
1864 {
1865 wxLogMessage( wxString::Format( _( "Ignoring a wire since Eagle layer '%s' (%d) "
1866 "was not mapped" ),
1867 eagle_layer_name( w.layer ), w.layer ) );
1868 return;
1869 }
1870
1871 // KiCad cannot handle zero or negative line widths which apparently have meaning in Eagle.
1872 if( width <= 0 )
1873 {
1874 BOARD* board = aFootprint->GetBoard();
1875
1876 if( board )
1877 {
1878 width = board->GetDesignSettings().GetLineThickness( layer );
1879 }
1880 else
1881 {
1882 // When loading footprint libraries, there is no board so use the default KiCad
1883 // line widths.
1884 switch( layer )
1885 {
1886 case Edge_Cuts: width = pcbIUScale.mmToIU( DEFAULT_EDGE_WIDTH ); break;
1887
1888 case F_SilkS:
1889 case B_SilkS: width = pcbIUScale.mmToIU( DEFAULT_SILK_LINE_WIDTH ); break;
1890
1891 case F_CrtYd:
1892 case B_CrtYd: width = pcbIUScale.mmToIU( DEFAULT_COURTYARD_WIDTH ); break;
1893
1894 default: width = pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ); break;
1895 }
1896 }
1897 }
1898
1899 // FIXME: the cap attribute is ignored because KiCad can't create lines with flat ends.
1900 FP_SHAPE* dwg;
1901
1902 if( !w.curve )
1903 {
1904 dwg = new FP_SHAPE( aFootprint, SHAPE_T::SEGMENT );
1905
1906 dwg->SetStart0( start );
1907 dwg->SetEnd0( end );
1908 }
1909 else
1910 {
1911 dwg = new FP_SHAPE( aFootprint, SHAPE_T::ARC );
1912 VECTOR2I center = ConvertArcCenter( start, end, *w.curve );
1913
1914 dwg->SetCenter0( center );
1915 dwg->SetStart0( start );
1916 dwg->SetArcAngleAndEnd0( -EDA_ANGLE( *w.curve, DEGREES_T ), true ); // KiCad rotates the other way
1917 }
1918
1919 dwg->SetLayer( layer );
1921 dwg->SetDrawCoord();
1922
1923 aFootprint->Add( dwg );
1924}
#define DEFAULT_SILK_LINE_WIDTH
#define DEFAULT_EDGE_WIDTH
#define DEFAULT_LINE_WIDTH
#define DEFAULT_COURTYARD_WIDTH
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:37
void SetArcAngleAndEnd0(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: fp_shape.cpp:193
void SetCenter0(const VECTOR2I &aPt)
Definition: fp_shape.cpp:161
constexpr int mmToIU(double mm) const
Definition: base_units.h:89

References _, FOOTPRINT::Add(), ARC, B_CrtYd, B_SilkS, ConvertArcCenter(), EWIRE::curve, DEFAULT_COURTYARD_WIDTH, DEFAULT_EDGE_WIDTH, DEFAULT_LINE_WIDTH, DEFAULT_SILK_LINE_WIDTH, DEGREES_T, eagle_layer_name(), Edge_Cuts, F_CrtYd, F_SilkS, Format(), BOARD_ITEM::GetBoard(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetLineThickness(), kicad_layer(), kicad_x(), kicad_y(), EWIRE::layer, EDA_IU_SCALE::mmToIU(), pcbIUScale, SEGMENT, FP_SHAPE::SetArcAngleAndEnd0(), FP_SHAPE::SetCenter0(), FP_SHAPE::SetDrawCoord(), FP_SHAPE::SetEnd0(), BOARD_ITEM::SetLayer(), FP_SHAPE::SetStart0(), PCB_SHAPE::SetStroke(), SOLID, ECOORD::ToPcbUnits(), UNDEFINED_LAYER, EWIRE::width, EWIRE::x1, EWIRE::x2, EWIRE::y1, and EWIRE::y2.

Referenced by makeFootprint().

◆ PluginName()

const wxString EAGLE_PLUGIN::PluginName ( ) const
overridevirtual

Return a brief hard coded name for this PLUGIN.

Implements PLUGIN.

Definition at line 320 of file eagle_plugin.cpp.

321{
322 return wxT( "Eagle" );
323}

◆ PrefetchLib()

void PLUGIN::PrefetchLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

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.

Definition at line 75 of file plugin.cpp.

76{
77}

Referenced by FP_LIB_TABLE::PrefetchLib().

◆ RegisterLayerMappingCallback()

virtual void LAYER_REMAPPABLE_PLUGIN::RegisterLayerMappingCallback ( LAYER_MAPPING_HANDLER  aLayerMappingHandler)
inlinevirtualinherited

Register a different handler to be called when mapping of input layers to KiCad layers occurs.

The function is marked as virtual, so the plugins can implement extra logic (e.g., enable warnings or checks)

Parameters
aLayerMappingHandler

Reimplemented in CADSTAR_PCB_ARCHIVE_PLUGIN.

Definition at line 73 of file plugin_common_layer_mapping.h.

74 {
75 m_layer_mapping_handler = aLayerMappingHandler;
76 }

References LAYER_REMAPPABLE_PLUGIN::m_layer_mapping_handler.

Referenced by CADSTAR_PCB_ARCHIVE_PLUGIN::CADSTAR_PCB_ARCHIVE_PLUGIN(), EAGLE_PLUGIN(), PCB_EDIT_FRAME::OpenProjectFiles(), and CADSTAR_PCB_ARCHIVE_PLUGIN::RegisterLayerMappingCallback().

◆ Save()

void PLUGIN::Save ( const wxString &  aFileName,
BOARD aBoard,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

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 CLIPBOARD_IO, and PCB_PLUGIN.

Definition at line 60 of file plugin.cpp.

61{
62 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
63 not_implemented( this, __FUNCTION__ );
64}

References not_implemented().

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

◆ SetQueryUserCallback()

virtual void PLUGIN::SetQueryUserCallback ( std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aAction)>  aCallback)
inlinevirtualinherited

Registers a KIDIALOG callback for collecting info from the user.

Definition at line 285 of file io_mgr.h.

288 { }

Referenced by PCB_CONTROL::AppendBoard(), and PCB_EDIT_FRAME::OpenProjectFiles().

◆ transferPad()

void EAGLE_PLUGIN::transferPad ( const EPAD_COMMON aEaglePad,
PAD aPad 
) const
private

Deletes the footprint templates list.

Definition at line 2534 of file eagle_plugin.cpp.

2535{
2536 aPad->SetNumber( aEaglePad.name );
2537
2538 // pad's "Position" is not relative to the footprint's,
2539 // whereas Pos0 is relative to the footprint's but is the unrotated coordinate.
2540 VECTOR2I padPos( kicad_x( aEaglePad.x ), kicad_y( aEaglePad.y ) );
2541 aPad->SetPos0( padPos );
2542
2543 // Solder mask
2544 const VECTOR2I& padSize( aPad->GetSize() );
2545
2548 (int) ( m_rules->mvStopFrame * std::min( padSize.x, padSize.y ) ),
2550
2551 // Solid connection to copper zones
2552 if( aEaglePad.thermals && !*aEaglePad.thermals )
2554
2555 FOOTPRINT* footprint = aPad->GetParent();
2556 wxCHECK( footprint, /* void */ );
2557 RotatePoint( padPos, footprint->GetOrientation() );
2558 aPad->SetPosition( padPos + footprint->GetPosition() );
2559}
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition: pad.h:133
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: pad.h:502
FOOTPRINT * GetParent() const
Definition: pad.cpp:1464
void SetPosition(const VECTOR2I &aPos) override
Definition: pad.h:190
void SetPos0(const VECTOR2I &aPos)
Definition: pad.h:244
void SetLocalSolderMaskMargin(int aMargin)
Definition: pad.h:410
const VECTOR2I & GetSize() const
Definition: pad.h:251
opt_bool thermals
Definition: eagle_parser.h:697
wxString name
Definition: eagle_parser.h:693
double mvStopFrame
solderpaste mask, expressed as percentage of the smaller pad/via dimension
Definition: eagle_plugin.h:91
int mlMinStopFrame
solder mask, minimum size (Eagle mils, here nanometers)
Definition: eagle_plugin.h:95
int mlMaxStopFrame
solder mask, maximum size (Eagle mils, here nanometers)
Definition: eagle_plugin.h:96

References eagleClamp(), FULL, FOOTPRINT::GetOrientation(), PAD::GetParent(), FOOTPRINT::GetPosition(), PAD::GetSize(), kicad_x(), kicad_y(), m_rules, ERULES::mlMaxStopFrame, ERULES::mlMinStopFrame, ERULES::mvStopFrame, EPAD_COMMON::name, RotatePoint(), PAD::SetLocalSolderMaskMargin(), PAD::SetNumber(), PAD::SetPos0(), PAD::SetPosition(), PAD::SetZoneConnection(), EPAD_COMMON::thermals, EPAD_COMMON::x, VECTOR2< T >::x, EPAD_COMMON::y, and VECTOR2< T >::y.

Referenced by packagePad(), and packageSMD().

Member Data Documentation

◆ m_board

BOARD* EAGLE_PLUGIN::m_board
private

which BOARD is being worked on, no ownership here

Definition at line 336 of file eagle_plugin.h.

Referenced by centerBoard(), init(), Load(), loadClasses(), loadElements(), loadLayerDefs(), loadPlain(), loadPolygon(), loadSignals(), makeFootprint(), and packagePad().

◆ m_classMap

std::map<wxString, std::shared_ptr<NETCLASS> > EAGLE_PLUGIN::m_classMap
private

Definition at line 318 of file eagle_plugin.h.

Referenced by loadClasses(), and loadSignals().

◆ m_cu_map

int EAGLE_PLUGIN::m_cu_map[17]
private

map eagle to KiCad, cu layers only.

Definition at line 312 of file eagle_plugin.h.

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

◆ m_customRules

wxString EAGLE_PLUGIN::m_customRules
private

Definition at line 320 of file eagle_plugin.h.

Referenced by Load(), and loadClasses().

◆ m_doneCount

unsigned EAGLE_PLUGIN::m_doneCount
private

Definition at line 339 of file eagle_plugin.h.

Referenced by checkpoint(), and loadAllSections().

◆ m_eagleLayers

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

Eagle layer data stored by layer number.

Definition at line 313 of file eagle_plugin.h.

Referenced by eagle_layer_name(), loadLayerDefs(), and mapEagleLayersToKicad().

◆ m_eagleLayersIds

std::map<wxString, int> EAGLE_PLUGIN::m_eagleLayersIds
private

Eagle layer ids stored by layer name.

Definition at line 314 of file eagle_plugin.h.

Referenced by eagle_layer_id(), and loadLayerDefs().

◆ m_hole_count

int EAGLE_PLUGIN::m_hole_count
private

generates unique footprint names from eagle "hole"s.

Definition at line 326 of file eagle_plugin.h.

Referenced by init(), and loadPlain().

◆ m_lastProgressCount

unsigned EAGLE_PLUGIN::m_lastProgressCount
private

Definition at line 340 of file eagle_plugin.h.

Referenced by checkpoint().

◆ m_layer_map

std::map<wxString, PCB_LAYER_ID> EAGLE_PLUGIN::m_layer_map
private

Map of Eagle layers to KiCad layers.

Eagle class number to KiCad netclass

Definition at line 315 of file eagle_plugin.h.

Referenced by kicad_layer(), and mapEagleLayersToKicad().

◆ m_layer_mapping_handler

LAYER_MAPPING_HANDLER LAYER_REMAPPABLE_PLUGIN::m_layer_mapping_handler
protectedinherited

◆ m_lib_path

wxString EAGLE_PLUGIN::m_lib_path
private

Definition at line 348 of file eagle_plugin.h.

Referenced by cacheLib(), and loadLibrary().

◆ m_min_annulus

int EAGLE_PLUGIN::m_min_annulus
private

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

Definition at line 346 of file eagle_plugin.h.

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

◆ m_min_hole

int EAGLE_PLUGIN::m_min_hole
private

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

Definition at line 344 of file eagle_plugin.h.

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

◆ m_min_trace

int EAGLE_PLUGIN::m_min_trace
private

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

Definition at line 343 of file eagle_plugin.h.

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

◆ m_min_via

int EAGLE_PLUGIN::m_min_via
private

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

Definition at line 345 of file eagle_plugin.h.

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

◆ m_mod_time

wxDateTime EAGLE_PLUGIN::m_mod_time
private

Definition at line 349 of file eagle_plugin.h.

Referenced by cacheLib().

◆ m_pads_to_nets

NET_MAP EAGLE_PLUGIN::m_pads_to_nets
private

net list

Definition at line 328 of file eagle_plugin.h.

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

◆ m_progressReporter

PROGRESS_REPORTER* EAGLE_PLUGIN::m_progressReporter
private

optional; may be nullptr

Definition at line 338 of file eagle_plugin.h.

Referenced by checkpoint(), Load(), loadAllSections(), and mapEagleLayersToKicad().

◆ m_props

const PROPERTIES* EAGLE_PLUGIN::m_props
private

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

Definition at line 335 of file eagle_plugin.h.

Referenced by centerBoard(), and init().

◆ m_rules

ERULES* EAGLE_PLUGIN::m_rules
private

Eagle design rules.

Definition at line 322 of file eagle_plugin.h.

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

◆ m_templates

FOOTPRINT_MAP EAGLE_PLUGIN::m_templates
private

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

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

Definition at line 330 of file eagle_plugin.h.

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

◆ m_totalCount

unsigned EAGLE_PLUGIN::m_totalCount
private

for progress reporting

Definition at line 341 of file eagle_plugin.h.

Referenced by checkpoint(), and loadAllSections().

◆ m_xpath

XPATH* EAGLE_PLUGIN::m_xpath
private

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

Definition at line 323 of file eagle_plugin.h.

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


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