KiCad PCB EDA Suite
sch_eagle_plugin.cpp File Reference
#include <sch_plugins/eagle/sch_eagle_plugin.h>
#include <locale_io.h>
#include <properties.h>
#include <algorithm>
#include <memory>
#include <wx/filename.h>
#include <wx/tokenzr.h>
#include <wx/wfstream.h>
#include <wx/xml/xml.h>
#include <symbol_library.h>
#include <plugins/eagle/eagle_parser.h>
#include <string_utils.h>
#include <gr_text.h>
#include <lib_shape.h>
#include <lib_id.h>
#include <lib_item.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <project.h>
#include <sch_bus_entry.h>
#include <sch_symbol.h>
#include <project/net_settings.h>
#include <sch_edit_frame.h>
#include <sch_junction.h>
#include <sch_plugins/legacy/sch_legacy_plugin.h>
#include <sch_marker.h>
#include <sch_screen.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_label.h>
#include <schematic.h>
#include <symbol_lib_table.h>
#include <wildcards_and_files_ext.h>
#include <progress_reporter.h>

Go to the source code of this file.

Functions

static int countChildren (wxXmlNode *aCurrentNode, const wxString &aName)
 Provide an easy access to the children of an XML node via their names. More...
 
static EDA_RECT getSheetBbox (SCH_SHEET *aSheet)
 Extract the net name part from a pin name (e.g. return 'GND' for pin named '[email protected]') More...
 
static wxString extractNetName (const wxString &aPinName)
 
static SYMBOL_ORIENTATION_T kiCadComponentRotation (float eagleDegrees)
 
static void eagleToKicadAlignment (EDA_TEXT *aText, int aEagleAlignment, int aRelDegress, bool aMirror, bool aSpin, int aAbsDegress)
 

Variables

static const std::map< wxString, ELECTRICAL_PINTYPEpinDirectionsMap
 Map of EAGLE pin type values to KiCad pin type values. More...
 

Function Documentation

◆ countChildren()

static int countChildren ( wxXmlNode *  aCurrentNode,
const wxString &  aName 
)
static

Provide an easy access to the children of an XML node via their names.

Parameters
aCurrentNodeis a pointer to a wxXmlNode, whose children will be mapped.
aNamethe name of the specific child names to be counted.
Returns
number of children with the give node name. Compute a bounding box for all items in a schematic sheet

Definition at line 92 of file sch_eagle_plugin.cpp.

Referenced by SCH_EAGLE_PLUGIN::loadLibrary(), SCH_EAGLE_PLUGIN::loadSchematic(), and SCH_EAGLE_PLUGIN::loadSegments().

◆ eagleToKicadAlignment()

static void eagleToKicadAlignment ( EDA_TEXT aText,
int  aEagleAlignment,
int  aRelDegress,
bool  aMirror,
bool  aSpin,
int  aAbsDegress 
)
static

Definition at line 251 of file sch_eagle_plugin.cpp.

253{
254 int align = aEagleAlignment;
255
256 if( aRelDegress == 90 )
257 {
259 }
260 else if( aRelDegress == 180 )
261 align = -align;
262 else if( aRelDegress == 270 )
263 {
265 align = -align;
266 }
267
268 if( aMirror == true )
269 {
270 if( aAbsDegress == 90 || aAbsDegress == 270 )
271 {
272 if( align == ETEXT::BOTTOM_RIGHT )
273 align = ETEXT::TOP_RIGHT;
274 else if( align == ETEXT::BOTTOM_LEFT )
275 align = ETEXT::TOP_LEFT;
276 else if( align == ETEXT::TOP_LEFT )
277 align = ETEXT::BOTTOM_LEFT;
278 else if( align == ETEXT::TOP_RIGHT )
279 align = ETEXT::BOTTOM_RIGHT;
280 }
281 else if( aAbsDegress == 0 || aAbsDegress == 180 )
282 {
283 if( align == ETEXT::BOTTOM_RIGHT )
284 align = ETEXT::BOTTOM_LEFT;
285 else if( align == ETEXT::BOTTOM_LEFT )
286 align = ETEXT::BOTTOM_RIGHT;
287 else if( align == ETEXT::TOP_LEFT )
288 align = ETEXT::TOP_RIGHT;
289 else if( align == ETEXT::TOP_RIGHT )
290 align = ETEXT::TOP_LEFT;
291 else if( align == ETEXT::CENTER_LEFT )
292 align = ETEXT::CENTER_RIGHT;
293 else if( align == ETEXT::CENTER_RIGHT )
294 align = ETEXT::CENTER_LEFT;
295 }
296 }
297
298 switch( align )
299 {
300 case ETEXT::CENTER:
303 break;
304
308 break;
309
313 break;
314
318 break;
319
320 case ETEXT::TOP_LEFT:
323 break;
324
325 case ETEXT::TOP_RIGHT:
328 break;
329
333 break;
334
338 break;
339
343 break;
344
345 default:
348 break;
349 }
350}
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:248
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 constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:420
@ 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
@ 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

References ANGLE_VERTICAL, ETEXT::BOTTOM_CENTER, ETEXT::BOTTOM_LEFT, ETEXT::BOTTOM_RIGHT, ETEXT::CENTER, ETEXT::CENTER_LEFT, ETEXT::CENTER_RIGHT, 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::SetHorizJustify(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetVertJustify(), ETEXT::TOP_CENTER, ETEXT::TOP_LEFT, and ETEXT::TOP_RIGHT.

Referenced by SCH_EAGLE_PLUGIN::loadInstance(), and SCH_EAGLE_PLUGIN::loadTextAttributes().

◆ extractNetName()

static wxString extractNetName ( const wxString &  aPinName)
inlinestatic

Definition at line 126 of file sch_eagle_plugin.cpp.

127{
128 return aPinName.BeforeFirst( '@' );
129}

Referenced by SCH_EAGLE_PLUGIN::addImplicitConnections().

◆ getSheetBbox()

static EDA_RECT getSheetBbox ( SCH_SHEET aSheet)
static

Extract the net name part from a pin name (e.g. return 'GND' for pin named '[email protected]')

Definition at line 114 of file sch_eagle_plugin.cpp.

References SCH_SHEET::GetScreen(), SCH_SCREEN::Items(), and EDA_RECT::Merge().

Referenced by SCH_EAGLE_PLUGIN::loadSchematic(), and SCH_EAGLE_PLUGIN::loadSheet().

◆ kiCadComponentRotation()

static SYMBOL_ORIENTATION_T kiCadComponentRotation ( float  eagleDegrees)
static

Definition at line 223 of file sch_eagle_plugin.cpp.

224{
225 int roti = int( eagleDegrees );
226
227 switch( roti )
228 {
229 default:
230 wxASSERT_MSG( false, wxString::Format( wxT( "Unhandled orientation (%d degrees)" ), roti ) );
232
233 case 0:
234 return SYM_ORIENT_0;
235
236 case 90:
237 return SYM_ORIENT_90;
238
239 case 180:
240 return SYM_ORIENT_180;
241
242 case 270:
243 return SYM_ORIENT_270;
244 }
245
246 return SYM_ORIENT_0;
247}
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
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
@ SYM_ORIENT_270
@ SYM_ORIENT_180
@ SYM_ORIENT_90
@ SYM_ORIENT_0

References Format(), KI_FALLTHROUGH, SYM_ORIENT_0, SYM_ORIENT_180, SYM_ORIENT_270, and SYM_ORIENT_90.

Referenced by SCH_EAGLE_PLUGIN::loadInstance().

Variable Documentation

◆ pinDirectionsMap

const std::map<wxString, ELECTRICAL_PINTYPE> pinDirectionsMap
static
Initial value:
= {
{ wxT( "pas" ), ELECTRICAL_PINTYPE::PT_PASSIVE },
{ wxT( "out" ), ELECTRICAL_PINTYPE::PT_OUTPUT },
{ wxT( "in" ), ELECTRICAL_PINTYPE::PT_INPUT },
{ wxT( "nc" ), ELECTRICAL_PINTYPE::PT_NC },
{ wxT( "io" ), ELECTRICAL_PINTYPE::PT_BIDI },
}
@ PT_INPUT
usual pin input: must be connected
@ PT_NC
not connected (must be left open)
@ PT_OUTPUT
usual output
@ PT_TRISTATE
tris state bus pin
@ PT_BIDI
input or output (like port for a microprocessor)
@ PT_OPENCOLLECTOR
pin type open collector
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin

Map of EAGLE pin type values to KiCad pin type values.

Definition at line 72 of file sch_eagle_plugin.cpp.

Referenced by SCH_EAGLE_PLUGIN::loadSymbol().