KiCad PCB EDA Suite
sch_eagle_plugin.cpp File Reference
#include <properties.h>
#include <kiway.h>
#include <wx/filename.h>
#include <wx/tokenzr.h>
#include <memory>
#include <algorithm>
#include <sch_junction.h>
#include <sch_sheet.h>
#include <sch_edit_frame.h>
#include <ws_draw_item.h>
#include <template_fieldnames.h>
#include <wildcards_and_files_ext.h>
#include <sch_screen.h>
#include <class_library.h>
#include <class_libentry.h>
#include <lib_item.h>
#include <lib_id.h>
#include <sch_component.h>
#include <sch_connection.h>
#include <sch_sheet_path.h>
#include <lib_arc.h>
#include <lib_circle.h>
#include <lib_rectangle.h>
#include <lib_polyline.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <sch_text.h>
#include <gr_text.h>
#include <sch_marker.h>
#include <sch_bus_entry.h>
#include <eagle_parser.h>
#include <symbol_lib_table.h>
#include <sch_legacy_plugin.h>
#include <sch_eagle_plugin.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)
 

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

74 {
75  // Map node_name -> node_pointer
76  int count = 0;
77 
78  // Loop through all children counting them if they match the given name
79  aCurrentNode = aCurrentNode->GetChildren();
80 
81  while( aCurrentNode )
82  {
83  if( aCurrentNode->GetName() == aName )
84  count++;
85 
86  // Get next child
87  aCurrentNode = aCurrentNode->GetNext();
88  }
89 
90  return count;
91 }

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

244 {
245  int align = aEagleAlignment;
246 
247  if( aRelDegress == 90 )
248  {
249  aText->SetTextAngle( 900 );
250  }
251  else if( aRelDegress == 180 )
252  align = -align;
253  else if( aRelDegress == 270 )
254  {
255  aText->SetTextAngle( 900 );
256  align = -align;
257  }
258 
259  if( aMirror == true )
260  {
261  if( aAbsDegress == 90 || aAbsDegress == 270 )
262  {
263  if( align == ETEXT::BOTTOM_RIGHT )
264  align = ETEXT::TOP_RIGHT;
265  else if( align == ETEXT::BOTTOM_LEFT )
266  align = ETEXT::TOP_LEFT;
267  else if( align == ETEXT::TOP_LEFT )
268  align = ETEXT::BOTTOM_LEFT;
269  else if( align == ETEXT::TOP_RIGHT )
270  align = ETEXT::BOTTOM_RIGHT;
271  }
272  else if( aAbsDegress == 0 || aAbsDegress == 180 )
273  {
274  if( align == ETEXT::BOTTOM_RIGHT )
275  align = ETEXT::BOTTOM_LEFT;
276  else if( align == ETEXT::BOTTOM_LEFT )
277  align = ETEXT::BOTTOM_RIGHT;
278  else if( align == ETEXT::TOP_LEFT )
279  align = ETEXT::TOP_RIGHT;
280  else if( align == ETEXT::TOP_RIGHT )
281  align = ETEXT::TOP_LEFT;
282  else if( align == ETEXT::CENTER_LEFT )
283  align = ETEXT::CENTER_RIGHT;
284  else if( align == ETEXT::CENTER_RIGHT )
285  align = ETEXT::CENTER_LEFT;
286  }
287  }
288 
289  switch( align )
290  {
291  case ETEXT::CENTER:
294  break;
295 
296  case ETEXT::CENTER_LEFT:
299  break;
300 
301  case ETEXT::CENTER_RIGHT:
304  break;
305 
306  case ETEXT::TOP_CENTER:
309  break;
310 
311  case ETEXT::TOP_LEFT:
314  break;
315 
316  case ETEXT::TOP_RIGHT:
319  break;
320 
324  break;
325 
326  case ETEXT::BOTTOM_LEFT:
329  break;
330 
331  case ETEXT::BOTTOM_RIGHT:
334  break;
335 
336  default:
339  }
340 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:150
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:188
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:187

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

118 {
119  return aPinName.BeforeFirst( '@' );
120 }

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

96 {
97  EDA_RECT bbox;
98  SCH_ITEM* item = aSheet->GetScreen()->GetDrawItems();
99 
100  if( !item )
101  return bbox;
102 
103  bbox = item->GetBoundingBox();
104  item = item->Next();
105 
106  while( item )
107  {
108  bbox.Merge( item->GetBoundingBox() );
109  item = item->Next();
110  }
111 
112  return bbox;
113 }
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
SCH_ITEM * Next() const
Definition: sch_item.h:153
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:281
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:152

References EDA_ITEM::GetBoundingBox(), SCH_SCREEN::GetDrawItems(), SCH_SHEET::GetScreen(), EDA_RECT::Merge(), and SCH_ITEM::Next().

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

◆ kiCadComponentRotation()

static COMPONENT_ORIENTATION_T kiCadComponentRotation ( float  eagleDegrees)
static

Definition at line 215 of file sch_eagle_plugin.cpp.

216 {
217  int roti = int( eagleDegrees );
218 
219  switch( roti )
220  {
221  default:
222  wxASSERT_MSG( false, wxString::Format( "Unhandled orientation (%d degrees)", roti ) );
223 
224  case 0:
225  return CMP_ORIENT_0;
226 
227  case 90:
228  return CMP_ORIENT_90;
229 
230  case 180:
231  return CMP_ORIENT_180;
232 
233  case 270:
234  return CMP_ORIENT_270;
235  }
236 
237  return CMP_ORIENT_0;
238 }
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, and Format().

Referenced by SCH_EAGLE_PLUGIN::loadInstance().