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 <class_library.h>
#include <plugins/eagle/eagle_parser.h>
#include <kicad_string.h>
#include <lib_arc.h>
#include <lib_circle.h>
#include <lib_id.h>
#include <lib_item.h>
#include <lib_pin.h>
#include <lib_polyline.h>
#include <lib_rectangle.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_text.h>
#include <schematic.h>
#include <symbol_lib_table.h>
#include <wildcards_and_files_ext.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 'GND@2') More...
 
static wxString extractNetName (const wxString &aPinName)
 
static COMPONENT_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 91 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 250 of file sch_eagle_plugin.cpp.

252 {
253  int align = aEagleAlignment;
254 
255  if( aRelDegress == 90 )
256  {
257  aText->SetTextAngle( 900 );
258  }
259  else if( aRelDegress == 180 )
260  align = -align;
261  else if( aRelDegress == 270 )
262  {
263  aText->SetTextAngle( 900 );
264  align = -align;
265  }
266 
267  if( aMirror == true )
268  {
269  if( aAbsDegress == 90 || aAbsDegress == 270 )
270  {
271  if( align == ETEXT::BOTTOM_RIGHT )
272  align = ETEXT::TOP_RIGHT;
273  else if( align == ETEXT::BOTTOM_LEFT )
274  align = ETEXT::TOP_LEFT;
275  else if( align == ETEXT::TOP_LEFT )
276  align = ETEXT::BOTTOM_LEFT;
277  else if( align == ETEXT::TOP_RIGHT )
278  align = ETEXT::BOTTOM_RIGHT;
279  }
280  else if( aAbsDegress == 0 || aAbsDegress == 180 )
281  {
282  if( align == ETEXT::BOTTOM_RIGHT )
283  align = ETEXT::BOTTOM_LEFT;
284  else if( align == ETEXT::BOTTOM_LEFT )
285  align = ETEXT::BOTTOM_RIGHT;
286  else if( align == ETEXT::TOP_LEFT )
287  align = ETEXT::TOP_RIGHT;
288  else if( align == ETEXT::TOP_RIGHT )
289  align = ETEXT::TOP_LEFT;
290  else if( align == ETEXT::CENTER_LEFT )
291  align = ETEXT::CENTER_RIGHT;
292  else if( align == ETEXT::CENTER_RIGHT )
293  align = ETEXT::CENTER_LEFT;
294  }
295  }
296 
297  switch( align )
298  {
299  case ETEXT::CENTER:
302  break;
303 
304  case ETEXT::CENTER_LEFT:
307  break;
308 
309  case ETEXT::CENTER_RIGHT:
312  break;
313 
314  case ETEXT::TOP_CENTER:
317  break;
318 
319  case ETEXT::TOP_LEFT:
322  break;
323 
324  case ETEXT::TOP_RIGHT:
327  break;
328 
332  break;
333 
334  case ETEXT::BOTTOM_LEFT:
337  break;
338 
339  case ETEXT::BOTTOM_RIGHT:
342  break;
343 
344  default:
347  break;
348  }
349 }
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:209
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:174

References ETEXT::BOTTOM_CENTER, ETEXT::BOTTOM_LEFT, ETEXT::BOTTOM_RIGHT, ETEXT::CENTER, ETEXT::CENTER_LEFT, ETEXT::CENTER_RIGHT, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_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 125 of file sch_eagle_plugin.cpp.

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

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 'GND@2')

Definition at line 113 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 COMPONENT_ORIENTATION_T kiCadComponentRotation ( float  eagleDegrees)
static

Definition at line 222 of file sch_eagle_plugin.cpp.

223 {
224  int roti = int( eagleDegrees );
225 
226  switch( roti )
227  {
228  default:
229  wxASSERT_MSG( false, wxString::Format( "Unhandled orientation (%d degrees)", roti ) );
231 
232  case 0:
233  return CMP_ORIENT_0;
234 
235  case 90:
236  return CMP_ORIENT_90;
237 
238  case 180:
239  return CMP_ORIENT_180;
240 
241  case 270:
242  return CMP_ORIENT_270;
243  }
244 
245  return CMP_ORIENT_0;
246 }
#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

References CMP_ORIENT_0, CMP_ORIENT_180, CMP_ORIENT_270, CMP_ORIENT_90, Format(), and KI_FALLTHROUGH.

Referenced by SCH_EAGLE_PLUGIN::loadInstance().

Variable Documentation

◆ pinDirectionsMap

const std::map<wxString, ELECTRICAL_PINTYPE> pinDirectionsMap
static
Initial value:
= {
}
power input (GND, VCC for ICs). Must be connected to a power output.
pin for passive components: must be connected, and can be connected to any pin
usual pin input: must be connected
input or output (like port for a microprocessor)
not connected (must be left open)

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

Definition at line 71 of file sch_eagle_plugin.cpp.

Referenced by SCH_EAGLE_PLUGIN::loadSymbol().