KiCad PCB EDA Suite
sch_eagle_plugin.cpp File Reference
#include <properties.h>
#include <kiway.h>
#include <wx/filename.h>
#include <memory>
#include <algorithm>
#include <sch_junction.h>
#include <sch_sheet.h>
#include <sch_edit_frame.h>
#include <worksheet_shape_builder.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_draw_item.h>
#include <lib_id.h>
#include <sch_component.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 <draw_graphic_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

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

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

72 {
73  // Map node_name -> node_pointer
74  int count = 0;
75 
76  // Loop through all children counting them if they match the given name
77  aCurrentNode = aCurrentNode->GetChildren();
78 
79  while( aCurrentNode )
80  {
81  if( aCurrentNode->GetName() == aName )
82  count++;
83 
84  // Get next child
85  aCurrentNode = aCurrentNode->GetNext();
86  }
87 
88  return count;
89 }
static void eagleToKicadAlignment ( EDA_TEXT aText,
int  aEagleAlignment,
int  aRelDegress,
bool  aMirror,
bool  aSpin,
int  aAbsDegress 
)
static

Definition at line 240 of file sch_eagle_plugin.cpp.

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().

242 {
243  int align = aEagleAlignment;
244 
245  if( aRelDegress == 90 )
246  {
247  aText->SetTextAngle( 900 );
248  }
249  else if( aRelDegress == 180 )
250  align = -align;
251  else if( aRelDegress == 270 )
252  {
253  aText->SetTextAngle( 900 );
254  align = -align;
255  }
256 
257  if( aMirror == true )
258  {
259  if( aAbsDegress == 90 || aAbsDegress == 270 )
260  {
261  if( align == ETEXT::BOTTOM_RIGHT )
262  align = ETEXT::TOP_RIGHT;
263  else if( align == ETEXT::BOTTOM_LEFT )
264  align = ETEXT::TOP_LEFT;
265  else if( align == ETEXT::TOP_LEFT )
266  align = ETEXT::BOTTOM_LEFT;
267  else if( align == ETEXT::TOP_RIGHT )
268  align = ETEXT::BOTTOM_RIGHT;
269  }
270  else if( aAbsDegress == 0 || aAbsDegress == 180 )
271  {
272  if( align == ETEXT::BOTTOM_RIGHT )
273  align = ETEXT::BOTTOM_LEFT;
274  else if( align == ETEXT::BOTTOM_LEFT )
275  align = ETEXT::BOTTOM_RIGHT;
276  else if( align == ETEXT::TOP_LEFT )
277  align = ETEXT::TOP_RIGHT;
278  else if( align == ETEXT::TOP_RIGHT )
279  align = ETEXT::TOP_LEFT;
280  else if( align == ETEXT::CENTER_LEFT )
281  align = ETEXT::CENTER_RIGHT;
282  else if( align == ETEXT::CENTER_RIGHT )
283  align = ETEXT::CENTER_LEFT;
284  }
285  }
286 
287  switch( align )
288  {
289  case ETEXT::CENTER:
292  break;
293 
294  case ETEXT::CENTER_LEFT:
297  break;
298 
299  case ETEXT::CENTER_RIGHT:
302  break;
303 
304  case ETEXT::TOP_CENTER:
307  break;
308 
309  case ETEXT::TOP_LEFT:
312  break;
313 
314  case ETEXT::TOP_RIGHT:
317  break;
318 
322  break;
323 
324  case ETEXT::BOTTOM_LEFT:
327  break;
328 
329  case ETEXT::BOTTOM_RIGHT:
332  break;
333 
334  default:
337  }
338 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:169
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:207
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:206
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 115 of file sch_eagle_plugin.cpp.

Referenced by SCH_EAGLE_PLUGIN::addImplicitConnections().

116 {
117  return aPinName.BeforeFirst( '@' );
118 }
static EDA_RECT getSheetBbox ( SCH_SHEET aSheet)
static

Computes a bounding box for all items in a schematic sheet

Definition at line 93 of file sch_eagle_plugin.cpp.

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().

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

Definition at line 213 of file sch_eagle_plugin.cpp.

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

Referenced by SCH_EAGLE_PLUGIN::loadInstance().

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