KiCad PCB EDA Suite
sch_eagle_plugin.cpp File Reference
#include <sch_eagle_plugin.h>
#include <kiway.h>
#include <properties.h>
#include <algorithm>
#include <memory>
#include <wx/filename.h>
#include <wx/tokenzr.h>
#include <class_libentry.h>
#include <class_library.h>
#include <eagle_parser.h>
#include <gr_text.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 <macros.h>
#include <project.h>
#include <sch_bus_entry.h>
#include <sch_component.h>
#include <project/net_settings.h>
#include <sch_edit_frame.h>
#include <sch_junction.h>
#include <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 <template_fieldnames.h>
#include <wildcards_and_files_ext.h>
#include <ws_draw_item.h>

Go to the source code of this file.

Functions

static int countChildren (wxXmlNode *aCurrentNode, const wxString &aName)
 Provides an easy access to the children of an XML node via their names. More...
 
static EDA_RECT getSheetBbox (SCH_SHEET *aSheet)
 

Computes a bounding box for all items in a schematic sheet

More...
 
static wxString extractNetName (const wxString &aPinName)
 

Extracts the net name part from a pin name (e.g. return 'GND' for pin named 'GND@2')

More...
 
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

Provides 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.

Definition at line 94 of file sch_eagle_plugin.cpp.

95 {
96  // Map node_name -> node_pointer
97  int count = 0;
98 
99  // Loop through all children counting them if they match the given name
100  aCurrentNode = aCurrentNode->GetChildren();
101 
102  while( aCurrentNode )
103  {
104  if( aCurrentNode->GetName() == aName )
105  count++;
106 
107  // Get next child
108  aCurrentNode = aCurrentNode->GetNext();
109  }
110 
111  return count;
112 }

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 254 of file sch_eagle_plugin.cpp.

256 {
257  int align = aEagleAlignment;
258 
259  if( aRelDegress == 90 )
260  {
261  aText->SetTextAngle( 900 );
262  }
263  else if( aRelDegress == 180 )
264  align = -align;
265  else if( aRelDegress == 270 )
266  {
267  aText->SetTextAngle( 900 );
268  align = -align;
269  }
270 
271  if( aMirror == true )
272  {
273  if( aAbsDegress == 90 || aAbsDegress == 270 )
274  {
275  if( align == ETEXT::BOTTOM_RIGHT )
276  align = ETEXT::TOP_RIGHT;
277  else if( align == ETEXT::BOTTOM_LEFT )
278  align = ETEXT::TOP_LEFT;
279  else if( align == ETEXT::TOP_LEFT )
280  align = ETEXT::BOTTOM_LEFT;
281  else if( align == ETEXT::TOP_RIGHT )
282  align = ETEXT::BOTTOM_RIGHT;
283  }
284  else if( aAbsDegress == 0 || aAbsDegress == 180 )
285  {
286  if( align == ETEXT::BOTTOM_RIGHT )
287  align = ETEXT::BOTTOM_LEFT;
288  else if( align == ETEXT::BOTTOM_LEFT )
289  align = ETEXT::BOTTOM_RIGHT;
290  else if( align == ETEXT::TOP_LEFT )
291  align = ETEXT::TOP_RIGHT;
292  else if( align == ETEXT::TOP_RIGHT )
293  align = ETEXT::TOP_LEFT;
294  else if( align == ETEXT::CENTER_LEFT )
295  align = ETEXT::CENTER_RIGHT;
296  else if( align == ETEXT::CENTER_RIGHT )
297  align = ETEXT::CENTER_LEFT;
298  }
299  }
300 
301  switch( align )
302  {
303  case ETEXT::CENTER:
306  break;
307 
308  case ETEXT::CENTER_LEFT:
311  break;
312 
313  case ETEXT::CENTER_RIGHT:
316  break;
317 
318  case ETEXT::TOP_CENTER:
321  break;
322 
323  case ETEXT::TOP_LEFT:
326  break;
327 
328  case ETEXT::TOP_RIGHT:
331  break;
332 
336  break;
337 
338  case ETEXT::BOTTOM_LEFT:
341  break;
342 
343  case ETEXT::BOTTOM_RIGHT:
346  break;
347 
348  default:
351  break;
352  }
353 }
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:203
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:202
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:167

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

Extracts the net name part from a pin name (e.g. return 'GND' for pin named 'GND@2')

Definition at line 128 of file sch_eagle_plugin.cpp.

129 {
130  return aPinName.BeforeFirst( '@' );
131 }

Referenced by SCH_EAGLE_PLUGIN::addImplicitConnections().

◆ getSheetBbox()

static EDA_RECT getSheetBbox ( SCH_SHEET aSheet)
static

Computes a bounding box for all items in a schematic sheet

Definition at line 116 of file sch_eagle_plugin.cpp.

117 {
118  EDA_RECT bbox;
119 
120  for( auto item : aSheet->GetScreen()->Items() )
121  bbox.Merge( item->GetBoundingBox() );
122 
123  return bbox;
124 }
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:282
EE_RTREE & Items()
Definition: sch_screen.h:158
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44

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 226 of file sch_eagle_plugin.cpp.

227 {
228  int roti = int( eagleDegrees );
229 
230  switch( roti )
231  {
232  default:
233  wxASSERT_MSG( false, wxString::Format( "Unhandled orientation (%d degrees)", roti ) );
235 
236  case 0:
237  return CMP_ORIENT_0;
238 
239  case 90:
240  return CMP_ORIENT_90;
241 
242  case 180:
243  return CMP_ORIENT_180;
244 
245  case 270:
246  return CMP_ORIENT_270;
247  }
248 
249  return CMP_ORIENT_0;
250 }
#define KI_FALLTHROUGH
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205

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 75 of file sch_eagle_plugin.cpp.

Referenced by SCH_EAGLE_PLUGIN::loadSymbol().