KiCad PCB EDA Suite
SCH_EAGLE_PLUGIN Class Reference

A SCH_PLUGIN derivation for loading 6.x+ Eagle schematic files. More...

#include <sch_eagle_plugin.h>

Inheritance diagram for SCH_EAGLE_PLUGIN:
SCH_PLUGIN

Classes

struct  EAGLE_MISSING_CMP
 
struct  SEG_DESC
 Segments representing wires for intersection checking. More...
 

Public Member Functions

 SCH_EAGLE_PLUGIN ()
 
 ~SCH_EAGLE_PLUGIN ()
 
const wxString GetName () const override
 Return a brief hard coded name for this SCH_PLUGIN. More...
 
void SetReporter (REPORTER *aReporter) override
 Set an optional reporter for warnings/errors. More...
 
void SetProgressReporter (PROGRESS_REPORTER *aReporter) override
 Set an optional progress reporter. More...
 
const wxString GetFileExtension () const override
 Return the file extension for the SCH_PLUGIN. More...
 
const wxString GetLibraryFileExtension () const override
 Return the library file extension for the SCH_PLUGIN object. More...
 
int GetModifyHash () const override
 Return the modification hash from the library cache. More...
 
SCH_SHEETLoad (const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const PROPERTIES *aProperties=nullptr) override
 Load information from some input file format that this SCH_PLUGIN implementation knows about, into either a new SCH_SHEET or an existing one. More...
 
bool CheckHeader (const wxString &aFileName) override
 Return true if the first line in aFileName begins with the expected header. More...
 
virtual void SaveLibrary (const wxString &aFileName, const PROPERTIES *aProperties=nullptr)
 
virtual void Save (const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const PROPERTIES *aProperties=nullptr)
 Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about, or it can be used to write a portion of aSchematic to a special kind of export file. More...
 
virtual void EnumerateSymbolLib (wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath. More...
 
virtual void EnumerateSymbolLib (std::vector< LIB_SYMBOL * > &aSymbolList, const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Populate a list of LIB_SYMBOL aliases contained within the library aLibraryPath. More...
 
virtual LIB_SYMBOLLoadSymbol (const wxString &aLibraryPath, const wxString &aPartName, const PROPERTIES *aProperties=nullptr)
 Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this SCH_PLUGIN knows about. More...
 
virtual void SaveSymbol (const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const PROPERTIES *aProperties=nullptr)
 Write aSymbol to an existing library located at aLibraryPath. More...
 
virtual void DeleteSymbol (const wxString &aLibraryPath, const wxString &aSymbolName, const PROPERTIES *aProperties=nullptr)
 Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath. More...
 
virtual void CreateSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Create a new empty symbol library at aLibraryPath. More...
 
virtual bool DeleteSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Delete an existing symbol library and returns true if successful, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason. More...
 
virtual bool IsSymbolLibWritable (const wxString &aLibraryPath)
 Return true if the library at aLibraryPath is writable. More...
 
virtual void SymbolLibOptions (PROPERTIES *aListToAppendTo) const
 Append supported SCH_PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 
virtual const wxString & GetError () const
 Return an error string to the caller. More...
 

Private Member Functions

void checkpoint ()
 
void loadDrawing (wxXmlNode *aDrawingNode)
 
void loadLayerDefs (wxXmlNode *aLayers)
 
void loadSchematic (wxXmlNode *aSchematicNode)
 
void loadSheet (wxXmlNode *aSheetNode, int sheetcount)
 
void loadInstance (wxXmlNode *aInstanceNode)
 
EAGLE_LIBRARYloadLibrary (wxXmlNode *aLibraryNode, EAGLE_LIBRARY *aEagleLib)
 
void countNets (wxXmlNode *aSchematicNode)
 
void moveLabels (SCH_LINE *aWire, const wxPoint &aNewEndPoint)
 Move any labels on the wire to the new end point of the wire. More...
 
void addBusEntries ()
 This function finds best way to place a bus entry symbol for when an Eagle wire segment ends on an Eagle bus segment. More...
 
SCH_LAYER_ID kiCadLayer (int aEagleLayer)
 Return the matching layer or return LAYER_NOTES. More...
 
std::pair< VECTOR2I, const SEG * > findNearestLinePoint (const wxPoint &aPoint, const std::vector< SEG > &aLines) const
 
void loadSegments (wxXmlNode *aSegmentsNode, const wxString &aNetName, const wxString &aNetClass)
 
SCH_LINEloadWire (wxXmlNode *aWireNode)
 
SCH_TEXTloadLabel (wxXmlNode *aLabelNode, const wxString &aNetName)
 
SCH_JUNCTIONloadJunction (wxXmlNode *aJunction)
 
SCH_TEXTloadPlainText (wxXmlNode *aSchText)
 
void loadFrame (wxXmlNode *aFrameNode, std::vector< SCH_LINE * > &aLines)
 
bool loadSymbol (wxXmlNode *aSymbolNode, std::unique_ptr< LIB_SYMBOL > &aSymbol, EDEVICE *aDevice, int aGateNumber, const wxString &aGateName)
 
LIB_SHAPEloadSymbolCircle (std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aCircleNode, int aGateNumber)
 
LIB_SHAPEloadSymbolRectangle (std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aRectNode, int aGateNumber)
 
LIB_SHAPEloadSymbolPolyLine (std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aPolygonNode, int aGateNumber)
 
LIB_ITEMloadSymbolWire (std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aWireNode, int aGateNumber)
 
LIB_PINloadPin (std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *, EPIN *epin, int aGateNumber)
 
LIB_TEXTloadSymbolText (std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aLibText, int aGateNumber)
 
void loadFrame (wxXmlNode *aFrameNode, std::vector< LIB_ITEM * > &aLines)
 
void loadTextAttributes (EDA_TEXT *aText, const ETEXT &aAttribs) const
 
void loadFieldAttributes (LIB_FIELD *aField, const LIB_TEXT *aText) const
 Move net labels that are detached from any wire to the nearest wire. More...
 
void adjustNetLabels ()
 
wxString translateEagleBusName (const wxString &aEagleName) const
 Translate an Eagle-style bus name into one that is KiCad-compatible. More...
 
wxString getLibName ()
 
wxFileName getLibFileName ()
 Checks if there are other wires or pins at the position of the tested pin. More...
 
bool checkConnections (const SCH_SYMBOL *aSymbol, const LIB_PIN *aPin) const
 
void addImplicitConnections (SCH_SYMBOL *aSymbol, SCH_SCREEN *aScreen, bool aUpdateSet)
 Create net labels to emulate implicit connections in Eagle. More...
 
bool netHasPowerDriver (SCH_LINE *aLine, const wxString &aNetName) const
 

Private Attributes

REPORTERm_reporter
 Reporter for warnings/errors. More...
 
std::map< wxString, EAGLE_MISSING_CMPm_missingCmps
 
SCH_SHEETm_rootSheet
 The root sheet of the schematic being loaded. More...
 
SCH_SHEETm_currentSheet
 The current sheet of the schematic being loaded. More...
 
wxString m_version
 Eagle file version. More...
 
wxFileName m_filename
 
wxString m_libName
 Library name to save symbols. More...
 
SCHEMATICm_schematic
 Passed to Load(), the schematic object being loaded. More...
 
EPART_MAP m_partlist
 
std::map< wxString, EAGLE_LIBRARYm_eagleLibs
 
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
 PI to create KiCad symbol library. More...
 
std::unique_ptr< PROPERTIESm_properties
 Library plugin properties. More...
 
PROGRESS_REPORTERm_progressReporter
 optional; may be nullptr More...
 
unsigned m_doneCount
 
unsigned m_lastProgressCount
 
unsigned m_totalCount
 for progress reporting More...
 
std::map< wxString, int > m_netCounts
 
std::map< int, SCH_LAYER_IDm_layerMap
 
std::map< wxString, wxString > m_powerPorts
 map from symbol reference to global label equivalent More...
 
std::vector< VECTOR2Im_wireIntersections
 Wires and labels of a single connection (segment in Eagle nomenclature) More...
 
std::vector< SEG_DESCm_segments
 Nets as defined in the <nets> sections of an Eagle schematic file. More...
 
std::map< wxString, ENETm_nets
 Positions of pins and wire endings mapped to its parent. More...
 
std::map< wxPoint, std::set< const EDA_ITEM * > > m_connPoints
 

Detailed Description

A SCH_PLUGIN derivation for loading 6.x+ Eagle schematic files.

As with all SCH_PLUGINs there is no UI dependencies i.e. windowing calls allowed.

Definition at line 80 of file sch_eagle_plugin.h.

Constructor & Destructor Documentation

◆ SCH_EAGLE_PLUGIN()

SCH_EAGLE_PLUGIN::SCH_EAGLE_PLUGIN ( )

Definition at line 353 of file sch_eagle_plugin.cpp.

353  :
354  m_progressReporter( nullptr ),
355  m_doneCount( 0 ),
356  m_lastProgressCount( 0 ),
357  m_totalCount( 0 )
358 {
359  m_rootSheet = nullptr;
360  m_currentSheet = nullptr;
361  m_schematic = nullptr;
362 
364 }
SCH_SHEET * m_currentSheet
The current sheet of the schematic being loaded.
static REPORTER & GetInstance()
Definition: reporter.cpp:175
unsigned m_totalCount
for progress reporting
unsigned m_lastProgressCount
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
REPORTER * m_reporter
Reporter for warnings/errors.
SCHEMATIC * m_schematic
Passed to Load(), the schematic object being loaded.
PROGRESS_REPORTER * m_progressReporter
optional; may be nullptr

References WXLOG_REPORTER::GetInstance(), m_currentSheet, m_reporter, m_rootSheet, and m_schematic.

◆ ~SCH_EAGLE_PLUGIN()

SCH_EAGLE_PLUGIN::~SCH_EAGLE_PLUGIN ( )

Definition at line 367 of file sch_eagle_plugin.cpp.

368 {
369 }

Member Function Documentation

◆ addBusEntries()

void SCH_EAGLE_PLUGIN::addBusEntries ( )
private

This function finds best way to place a bus entry symbol for when an Eagle wire segment ends on an Eagle bus segment.

Definition at line 2373 of file sch_eagle_plugin.cpp.

2374 {
2375  // Add bus entry symbols
2376  // TODO: Cleanup this function and break into pieces
2377 
2378  // for each wire segment, compare each end with all busses.
2379  // If the wire end is found to end on a bus segment, place a bus entry symbol.
2380 
2381  std::vector<SCH_LINE*> buses;
2382  std::vector<SCH_LINE*> wires;
2383 
2384  for( SCH_ITEM* ii : m_currentSheet->GetScreen()->Items().OfType( SCH_LINE_T ) )
2385  {
2386  SCH_LINE* line = static_cast<SCH_LINE*>( ii );
2387 
2388  if( line->IsBus() )
2389  buses.push_back( line );
2390  else if( line->IsWire() )
2391  wires.push_back( line );
2392  }
2393 
2394  for( SCH_LINE* wire : wires )
2395  {
2396  wxPoint wireStart = wire->GetStartPoint();
2397  wxPoint wireEnd = wire->GetEndPoint();
2398 
2399  for( SCH_LINE* bus : buses )
2400  {
2401  wxPoint busStart = bus->GetStartPoint();
2402  wxPoint busEnd = bus->GetEndPoint();
2403 
2404  auto entrySize =
2405  []( int signX, int signY ) -> wxPoint
2406  {
2407  return wxPoint( Mils2iu( DEFAULT_SCH_ENTRY_SIZE ) * signX,
2408  Mils2iu( DEFAULT_SCH_ENTRY_SIZE ) * signY );
2409  };
2410 
2411  auto testBusHit =
2412  [&]( const wxPoint& aPt ) -> bool
2413  {
2414  return TestSegmentHit( aPt, busStart, busEnd, 0 );
2415  };
2416 
2417  if( wireStart.y == wireEnd.y && busStart.x == busEnd.x )
2418  {
2419  // Horizontal wire and vertical bus
2420 
2421  if( testBusHit( wireStart ) )
2422  {
2423  // Wire start is on the vertical bus
2424 
2425  if( wireEnd.x < busStart.x )
2426  {
2427  /* the end of the wire is to the left of the bus
2428  * ⎥⎢
2429  * ——————⎥⎢
2430  * ⎥⎢
2431  */
2432  wxPoint p = wireStart + entrySize( -1, 0 );
2433 
2434  if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
2435  {
2436  /* there is room above the wire for the bus entry
2437  * ⎥⎢
2438  * _____/⎥⎢
2439  * ⎥⎢
2440  */
2441  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
2442  busEntry->SetFlags( IS_NEW );
2443  m_currentSheet->GetScreen()->Append( busEntry );
2444  moveLabels( wire, p );
2445  wire->SetStartPoint( p );
2446  }
2447  else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
2448  {
2449  /* there is room below the wire for the bus entry
2450  * _____ ⎥⎢
2451  * \⎥⎢
2452  * ⎥⎢
2453  */
2454  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
2455  busEntry->SetFlags( IS_NEW );
2456  m_currentSheet->GetScreen()->Append( busEntry );
2457  moveLabels( wire, p );
2458  wire->SetStartPoint( p );
2459  }
2460  else
2461  {
2462  auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
2463  SCH_MARKER* marker = new SCH_MARKER( ercItem, wireStart );
2464  m_currentSheet->GetScreen()->Append( marker );
2465  }
2466  }
2467  else
2468  {
2469  /* the wire end is to the right of the bus
2470  * ⎥⎢
2471  * ⎥⎢——————
2472  * ⎥⎢
2473  */
2474  wxPoint p = wireStart + entrySize( 1, 0 );
2475 
2476  if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
2477  {
2478  /* There is room above the wire for the bus entry
2479  * ⎥⎢
2480  * ⎥⎢\_____
2481  * ⎥⎢
2482  */
2483  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p , 4 );
2484  busEntry->SetFlags( IS_NEW );
2485  m_currentSheet->GetScreen()->Append( busEntry );
2486  moveLabels( wire, p );
2487  wire->SetStartPoint( p );
2488  }
2489  else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
2490  {
2491  /* There is room below the wire for the bus entry
2492  * ⎥⎢ _____
2493  * ⎥⎢/
2494  * ⎥⎢
2495  */
2496  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
2497  busEntry->SetFlags( IS_NEW );
2498  m_currentSheet->GetScreen()->Append( busEntry );
2499  moveLabels( wire, p );
2500  wire->SetStartPoint( p );
2501  }
2502  else
2503  {
2504  auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
2505  SCH_MARKER* marker = new SCH_MARKER( ercItem, wireStart );
2506  m_currentSheet->GetScreen()->Append( marker );
2507  }
2508  }
2509 
2510  break;
2511  }
2512  else if( testBusHit( wireEnd ) )
2513  {
2514  // Wire end is on the vertical bus
2515 
2516  if( wireStart.x < busStart.x )
2517  {
2518  /* start of the wire is to the left of the bus
2519  * ⎥⎢
2520  * ——————⎥⎢
2521  * ⎥⎢
2522  */
2523  wxPoint p = wireEnd + entrySize( -1, 0 );
2524 
2525  if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2526  {
2527  /* there is room above the wire for the bus entry
2528  * ⎥⎢
2529  * _____/⎥⎢
2530  * ⎥⎢
2531  */
2532  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
2533  busEntry->SetFlags( IS_NEW );
2534  m_currentSheet->GetScreen()->Append( busEntry );
2535  moveLabels( wire, p );
2536  wire->SetEndPoint( p );
2537  }
2538  else if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2539  {
2540  /* there is room below the wire for the bus entry
2541  * _____ ⎥⎢
2542  * \⎥⎢
2543  * ⎥⎢
2544  */
2545  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
2546  busEntry->SetFlags( IS_NEW );
2547  m_currentSheet->GetScreen()->Append( busEntry );
2548  moveLabels( wire, wireEnd + entrySize( -1, 0 ) );
2549  wire->SetEndPoint( wireEnd + entrySize( -1, 0 ) );
2550  }
2551  else
2552  {
2553  auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
2554  SCH_MARKER* marker = new SCH_MARKER( ercItem, wireEnd );
2555  m_currentSheet->GetScreen()->Append( marker );
2556  }
2557  }
2558  else
2559  {
2560  /* the start of the wire is to the right of the bus
2561  * ⎥⎢
2562  * ⎥⎢——————
2563  * ⎥⎢
2564  */
2565  wxPoint p = wireEnd + entrySize( 1, 0 );
2566 
2567  if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2568  {
2569  /* There is room above the wire for the bus entry
2570  * ⎥⎢
2571  * ⎥⎢\_____
2572  * ⎥⎢
2573  */
2574  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
2575  busEntry->SetFlags( IS_NEW );
2576  m_currentSheet->GetScreen()->Append( busEntry );
2577  moveLabels( wire, p );
2578  wire->SetEndPoint( p );
2579  }
2580  else if( testBusHit( wireEnd + entrySize( 0, 1 ) ) )
2581  {
2582  /* There is room below the wire for the bus entry
2583  * ⎥⎢ _____
2584  * ⎥⎢/
2585  * ⎥⎢
2586  */
2587  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
2588  busEntry->SetFlags( IS_NEW );
2589  m_currentSheet->GetScreen()->Append( busEntry );
2590  moveLabels( wire, p );
2591  wire->SetEndPoint( p );
2592  }
2593  else
2594  {
2595  auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
2596  SCH_MARKER* marker = new SCH_MARKER( ercItem, wireEnd );
2597  m_currentSheet->GetScreen()->Append( marker );
2598  }
2599  }
2600 
2601  break;
2602  }
2603  }
2604  else if( wireStart.x == wireEnd.x && busStart.y == busEnd.y )
2605  {
2606  // Vertical wire and horizontal bus
2607 
2608  if( testBusHit( wireStart ) )
2609  {
2610  // Wire start is on the bus
2611 
2612  if( wireEnd.y < busStart.y )
2613  {
2614  /* the end of the wire is above the bus
2615  * |
2616  * |
2617  * |
2618  * =======
2619  */
2620  wxPoint p = wireStart + entrySize( 0, -1 );
2621 
2622  if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
2623  {
2624  /* there is room to the left of the wire for the bus entry
2625  * |
2626  * |
2627  * /
2628  * =======
2629  */
2630  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
2631  busEntry->SetFlags( IS_NEW );
2632  m_currentSheet->GetScreen()->Append( busEntry );
2633  moveLabels( wire, p );
2634  wire->SetStartPoint( p );
2635  }
2636  else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
2637  {
2638  /* there is room to the right of the wire for the bus entry
2639  * |
2640  * |
2641  * \
2642  * =======
2643  */
2644  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
2645  busEntry->SetFlags( IS_NEW );
2646  m_currentSheet->GetScreen()->Append( busEntry );
2647  moveLabels( wire, p );
2648  wire->SetStartPoint( p );
2649  }
2650  else
2651  {
2652  auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
2653  SCH_MARKER* marker = new SCH_MARKER( ercItem, wireStart );
2654  m_currentSheet->GetScreen()->Append( marker );
2655  }
2656  }
2657  else
2658  {
2659  /* wire end is below the bus
2660  * =======
2661  * |
2662  * |
2663  * |
2664  */
2665  wxPoint p = wireStart + entrySize( 0, 1 );
2666 
2667  if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
2668  {
2669  /* there is room to the left of the wire for the bus entry
2670  * =======
2671  * \
2672  * |
2673  * |
2674  */
2675  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
2676  busEntry->SetFlags( IS_NEW );
2677  m_currentSheet->GetScreen()->Append( busEntry );
2678  moveLabels( wire, p );
2679  wire->SetStartPoint( p );
2680  }
2681  else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
2682  {
2683  /* there is room to the right of the wire for the bus entry
2684  * =======
2685  * /
2686  * |
2687  * |
2688  */
2689  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
2690  busEntry->SetFlags( IS_NEW );
2691  m_currentSheet->GetScreen()->Append( busEntry );
2692  moveLabels( wire, p );
2693  wire->SetStartPoint( p );
2694  }
2695  else
2696  {
2697  auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
2698  SCH_MARKER* marker = new SCH_MARKER( ercItem, wireStart );
2699  m_currentSheet->GetScreen()->Append( marker );
2700  }
2701  }
2702 
2703  break;
2704  }
2705  else if( testBusHit( wireEnd ) )
2706  {
2707  // Wire end is on the bus
2708 
2709  if( wireStart.y < busStart.y )
2710  {
2711  /* the start of the wire is above the bus
2712  * |
2713  * |
2714  * |
2715  * =======
2716  */
2717  wxPoint p = wireEnd + entrySize( 0, -1 );
2718 
2719  if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
2720  {
2721  /* there is room to the left of the wire for the bus entry
2722  * |
2723  * |
2724  * /
2725  * =======
2726  */
2727  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
2728  busEntry->SetFlags( IS_NEW );
2729  m_currentSheet->GetScreen()->Append( busEntry );
2730  moveLabels( wire, p );
2731  wire->SetEndPoint( p );
2732  }
2733  else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
2734  {
2735  /* there is room to the right of the wire for the bus entry
2736  * |
2737  * |
2738  * \
2739  * =======
2740  */
2741  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
2742  busEntry->SetFlags( IS_NEW );
2743  m_currentSheet->GetScreen()->Append( busEntry );
2744  moveLabels( wire, p );
2745  wire->SetEndPoint( p );
2746  }
2747  else
2748  {
2749  auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
2750  SCH_MARKER* marker = new SCH_MARKER( ercItem, wireEnd );
2751  m_currentSheet->GetScreen()->Append( marker );
2752  }
2753  }
2754  else
2755  {
2756  /* wire start is below the bus
2757  * =======
2758  * |
2759  * |
2760  * |
2761  */
2762  wxPoint p = wireEnd + entrySize( 0, 1 );
2763 
2764  if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
2765  {
2766  /* there is room to the left of the wire for the bus entry
2767  * =======
2768  * \
2769  * |
2770  * |
2771  */
2772  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
2773  busEntry->SetFlags( IS_NEW );
2774  m_currentSheet->GetScreen()->Append( busEntry );
2775  moveLabels( wire, p );
2776  wire->SetEndPoint( p );
2777  }
2778  else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
2779  {
2780  /* there is room to the right of the wire for the bus entry
2781  * =======
2782  * /
2783  * |
2784  * |
2785  */
2786  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
2787  busEntry->SetFlags( IS_NEW );
2788  m_currentSheet->GetScreen()->Append( busEntry );
2789  moveLabels( wire, p );
2790  wire->SetEndPoint( p );
2791  }
2792  else
2793  {
2794  auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
2795  SCH_MARKER* marker = new SCH_MARKER( ercItem, wireEnd );
2796  m_currentSheet->GetScreen()->Append( marker );
2797  }
2798  }
2799 
2800  break;
2801  }
2802  }
2803  else
2804  {
2805  // Wire isn't horizontal or vertical
2806 
2807  if( testBusHit( wireStart ) )
2808  {
2809  wxPoint wirevector = wireStart - wireEnd;
2810 
2811  if( wirevector.x > 0 )
2812  {
2813  if( wirevector.y > 0 )
2814  {
2815  wxPoint p = wireStart + entrySize( -1, -1 );
2816  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
2817  busEntry->SetFlags( IS_NEW );
2818  m_currentSheet->GetScreen()->Append( busEntry );
2819 
2820  moveLabels( wire, p );
2821  wire->SetStartPoint( p );
2822  }
2823  else
2824  {
2825  wxPoint p = wireStart + entrySize( -1, 1 );
2826  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
2827  busEntry->SetFlags( IS_NEW );
2828  m_currentSheet->GetScreen()->Append( busEntry );
2829 
2830  moveLabels( wire, p );
2831  wire->SetStartPoint( p );
2832  }
2833  }
2834  else
2835  {
2836  if( wirevector.y > 0 )
2837  {
2838  wxPoint p = wireStart + entrySize( 1, -1 );
2839  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
2840  busEntry->SetFlags( IS_NEW );
2841  m_currentSheet->GetScreen()->Append( busEntry );
2842 
2843  moveLabels( wire, p );
2844  wire->SetStartPoint( p );
2845  }
2846  else
2847  {
2848  wxPoint p = wireStart + entrySize( 1, 1 );
2849  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
2850  busEntry->SetFlags( IS_NEW );
2851  m_currentSheet->GetScreen()->Append( busEntry );
2852 
2853  moveLabels( wire, p );
2854  wire->SetStartPoint( p );
2855  }
2856  }
2857 
2858  break;
2859  }
2860  else if( testBusHit( wireEnd ) )
2861  {
2862  wxPoint wirevector = wireStart - wireEnd;
2863 
2864  if( wirevector.x > 0 )
2865  {
2866  if( wirevector.y > 0 )
2867  {
2868  wxPoint p = wireEnd + entrySize( 1, 1 );
2869  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
2870  busEntry->SetFlags( IS_NEW );
2871  m_currentSheet->GetScreen()->Append( busEntry );
2872 
2873  moveLabels( wire, p );
2874  wire->SetEndPoint( p );
2875  }
2876  else
2877  {
2878  wxPoint p = wireEnd + entrySize( 1, -1 );
2879  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
2880  busEntry->SetFlags( IS_NEW );
2881  m_currentSheet->GetScreen()->Append( busEntry );
2882 
2883  moveLabels( wire, p );
2884  wire->SetEndPoint( p );
2885  }
2886  }
2887  else
2888  {
2889  if( wirevector.y > 0 )
2890  {
2891  wxPoint p = wireEnd + entrySize( -1, 1 );
2892  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
2893  busEntry->SetFlags( IS_NEW );
2894  m_currentSheet->GetScreen()->Append( busEntry );
2895 
2896  moveLabels( wire, p );
2897  wire->SetEndPoint( p );
2898  }
2899  else
2900  {
2901  wxPoint p = wireEnd + entrySize( -1, -1 );
2902  SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
2903  busEntry->SetFlags( IS_NEW );
2904  m_currentSheet->GetScreen()->Append( busEntry );
2905 
2906  moveLabels( wire, p );
2907  wire->SetEndPoint( p );
2908  }
2909  }
2910 
2911  break;
2912  }
2913  }
2914  }
2915  }
2916 }
SCH_SHEET * m_currentSheet
The current sheet of the schematic being loaded.
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
void moveLabels(SCH_LINE *aWire, const wxPoint &aNewEndPoint)
Move any labels on the wire to the new end point of the wire.
bool IsWire() const
Return true if the line is a wire.
Definition: sch_line.cpp:972
#define DEFAULT_SCH_ENTRY_SIZE
The default text size in mils. (can be changed in preference menu)
#define IS_NEW
New item, just created.
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Definition: erc_item.cpp:194
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:102
bool TestSegmentHit(const wxPoint &aRefPoint, const wxPoint &aStart, const wxPoint &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
Importer failed to auto-place a bus entry.
Definition: erc_settings.h:72
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
Class for a wire to bus entry.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
bool IsBus() const
Return true if the line is a bus.
Definition: sch_line.cpp:977

References SCH_SCREEN::Append(), ERC_ITEM::Create(), DEFAULT_SCH_ENTRY_SIZE, ERCE_BUS_ENTRY_NEEDED, SCH_SHEET::GetScreen(), IS_NEW, SCH_LINE::IsBus(), SCH_LINE::IsWire(), SCH_SCREEN::Items(), m_currentSheet, moveLabels(), EE_RTREE::OfType(), SCH_LINE_T, EDA_ITEM::SetFlags(), and TestSegmentHit().

Referenced by loadSheet().

◆ addImplicitConnections()

void SCH_EAGLE_PLUGIN::addImplicitConnections ( SCH_SYMBOL aSymbol,
SCH_SCREEN aScreen,
bool  aUpdateSet 
)
private

Create net labels to emulate implicit connections in Eagle.

Each named power input pin creates an implicit connection in Eagle. To emulate this behavior one needs to attach global net labels to the mentioned pins. This is is also expected for the units that are not instantiated in the schematics, therefore such units need to be stored in order to create them at later stage.

Parameters
aSymbolis the symbol to process.
aScreenis the screen where net labels should be added.
aUpdateSetdecides whether the missing units data should be updated.

Definition at line 2949 of file sch_eagle_plugin.cpp.

2951 {
2952  wxCHECK( aSymbol->GetLibSymbolRef(), /*void*/ );
2953 
2954  // Normally power parts also have power input pins,
2955  // but they already force net names on the attached wires
2956  if( aSymbol->GetLibSymbolRef()->IsPower() )
2957  return;
2958 
2959  int unit = aSymbol->GetUnit();
2960  const wxString reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
2961  std::vector<LIB_PIN*> pins;
2962  aSymbol->GetLibSymbolRef()->GetPins( pins );
2963  std::set<int> missingUnits;
2964 
2965  // Search all units for pins creating implicit connections
2966  for( const LIB_PIN* pin : pins )
2967  {
2968  if( pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN )
2969  {
2970  bool pinInUnit = !unit || pin->GetUnit() == unit; // pin belongs to the tested unit
2971 
2972  // Create a global net label only if there are no other wires/pins attached
2973  if( pinInUnit )
2974  {
2975  if( !checkConnections( aSymbol, pin ) )
2976  {
2977  // Create a net label to force the net name on the pin
2978  SCH_GLOBALLABEL* netLabel = new SCH_GLOBALLABEL;
2979  netLabel->SetPosition( aSymbol->GetPinPhysicalPosition( pin ) );
2980  netLabel->SetText( extractNetName( pin->GetName() ) );
2981  netLabel->SetTextSize( wxSize( Mils2iu( 40 ), Mils2iu( 40 ) ) );
2982 
2983  switch( pin->GetOrientation() )
2984  {
2985  case PIN_LEFT: netLabel->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT ); break;
2986  case PIN_RIGHT: netLabel->SetLabelSpinStyle( LABEL_SPIN_STYLE::LEFT ); break;
2987  case PIN_UP: netLabel->SetLabelSpinStyle( LABEL_SPIN_STYLE::UP ); break;
2988  case PIN_DOWN: netLabel->SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM ); break;
2989  }
2990 
2991  aScreen->Append( netLabel );
2992  }
2993  }
2994  else if( aUpdateSet )
2995  {
2996  // Found a pin creating implicit connection information in another unit.
2997  // Such units will be instantiated if they do not appear in another sheet and
2998  // processed later.
2999  wxASSERT( pin->GetUnit() );
3000  missingUnits.insert( pin->GetUnit() );
3001  }
3002  }
3003  }
3004 
3005  if( aUpdateSet && aSymbol->GetLibSymbolRef()->GetUnitCount() > 1 )
3006  {
3007  auto cmpIt = m_missingCmps.find( reference );
3008 
3009  // The first unit found has always already been processed.
3010  if( cmpIt == m_missingCmps.end() )
3011  {
3012  EAGLE_MISSING_CMP& entry = m_missingCmps[reference];
3013  entry.cmp = aSymbol;
3014  entry.units.emplace( unit, false );
3015  }
3016  else
3017  {
3018  // Set the flag indicating this unit has been processed.
3019  cmpIt->second.units[unit] = false;
3020  }
3021 
3022  if( !missingUnits.empty() ) // Save the units that need later processing
3023  {
3024  EAGLE_MISSING_CMP& entry = m_missingCmps[reference];
3025  entry.cmp = aSymbol;
3026 
3027  // Add units that haven't already been processed.
3028  for( int i : missingUnits )
3029  {
3030  if( entry.units.find( i ) != entry.units.end() )
3031  entry.units.emplace( i, true );
3032  }
3033  }
3034  }
3035 }
Field Reference of part, i.e. "IC21".
power input (GND, VCC for ICs). Must be connected to a power output.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:705
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
wxPoint GetPinPhysicalPosition(const LIB_PIN *Pin) const
Definition: lib_pin.h:48
std::map< wxString, EAGLE_MISSING_CMP > m_missingCmps
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:165
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
static wxString extractNetName(const wxString &aPinName)
bool checkConnections(const SCH_SYMBOL *aSymbol, const LIB_PIN *aPin) const
void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:1059
int GetUnit() const
Definition: sch_symbol.h:196
void SetPosition(const wxPoint &aPosition) override
Definition: sch_text.h:242
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154

References SCH_SCREEN::Append(), LABEL_SPIN_STYLE::BOTTOM, checkConnections(), SCH_EAGLE_PLUGIN::EAGLE_MISSING_CMP::cmp, extractNetName(), SCH_SYMBOL::GetField(), SCH_SYMBOL::GetLibSymbolRef(), SCH_SYMBOL::GetPinPhysicalPosition(), EDA_TEXT::GetText(), SCH_SYMBOL::GetUnit(), LABEL_SPIN_STYLE::LEFT, m_missingCmps, pin, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_UP, PT_POWER_IN, REFERENCE_FIELD, LABEL_SPIN_STYLE::RIGHT, SCH_GLOBALLABEL::SetLabelSpinStyle(), SCH_TEXT::SetPosition(), EDA_TEXT::SetText(), EDA_TEXT::SetTextSize(), SCH_EAGLE_PLUGIN::EAGLE_MISSING_CMP::units, and LABEL_SPIN_STYLE::UP.

Referenced by loadSchematic(), and loadSheet().

◆ adjustNetLabels()

void SCH_EAGLE_PLUGIN::adjustNetLabels ( )
private

Definition at line 2263 of file sch_eagle_plugin.cpp.

2264 {
2265  // Eagle supports detached labels, so a label does not need to be placed on a wire
2266  // to be associated with it. KiCad needs to move them, so the labels actually touch the
2267  // corresponding wires.
2268 
2269  // Sort the intersection points to speed up the search process
2270  std::sort( m_wireIntersections.begin(), m_wireIntersections.end() );
2271 
2272  auto onIntersection =
2273  [&]( const VECTOR2I& aPos )
2274  {
2275  return std::binary_search( m_wireIntersections.begin(),
2276  m_wireIntersections.end(), aPos );
2277  };
2278 
2279  for( SEG_DESC& segDesc : m_segments )
2280  {
2281  for( SCH_TEXT* label : segDesc.labels )
2282  {
2283  VECTOR2I labelPos( label->GetPosition() );
2284  const SEG* segAttached = segDesc.LabelAttached( label );
2285 
2286  if( segAttached && !onIntersection( labelPos ) )
2287  continue; // label is placed correctly
2288 
2289  // Move the label to the nearest wire
2290  if( !segAttached )
2291  {
2292  std::tie( labelPos, segAttached ) = findNearestLinePoint( label->GetPosition(),
2293  segDesc.segs );
2294 
2295  if( !segAttached ) // we cannot do anything
2296  continue;
2297  }
2298 
2299  // Create a vector pointing in the direction of the wire, 50 mils long
2300  VECTOR2I wireDirection( segAttached->B - segAttached->A );
2301  wireDirection = wireDirection.Resize( Mils2iu( 50 ) );
2302  const VECTOR2I origPos( labelPos );
2303 
2304  // Flags determining the search direction
2305  bool checkPositive = true, checkNegative = true, move = false;
2306  int trial = 0;
2307 
2308  // Be sure the label is not placed on a wire intersection
2309  while( ( !move || onIntersection( labelPos ) ) && ( checkPositive || checkNegative ) )
2310  {
2311  move = false;
2312 
2313  // Move along the attached wire to find the new label position
2314  if( trial % 2 == 1 )
2315  {
2316  labelPos = wxPoint( origPos + wireDirection * trial / 2 );
2317  move = checkPositive = segAttached->Contains( labelPos );
2318  }
2319  else
2320  {
2321  labelPos = wxPoint( origPos - wireDirection * trial / 2 );
2322  move = checkNegative = segAttached->Contains( labelPos );
2323  }
2324 
2325  ++trial;
2326  }
2327 
2328  if( move )
2329  label->SetPosition( wxPoint( labelPos ) );
2330  }
2331  }
2332 
2333  m_segments.clear();
2334  m_wireIntersections.clear();
2335 }
std::pair< VECTOR2I, const SEG * > findNearestLinePoint(const wxPoint &aPoint, const std::vector< SEG > &aLines) const
std::vector< VECTOR2I > m_wireIntersections
Wires and labels of a single connection (segment in Eagle nomenclature)
wxPoint GetPosition() const override
Definition: sch_text.h:241
Definition: seg.h:40
std::vector< SEG_DESC > m_segments
Nets as defined in the <nets> sections of an Eagle schematic file.
void SetPosition(const wxPoint &aPosition) override
Definition: sch_text.h:242

References findNearestLinePoint(), SCH_TEXT::GetPosition(), m_segments, m_wireIntersections, move, VECTOR2< T >::Resize(), and SCH_TEXT::SetPosition().

Referenced by loadSheet().

◆ checkConnections()

bool SCH_EAGLE_PLUGIN::checkConnections ( const SCH_SYMBOL aSymbol,
const LIB_PIN aPin 
) const
private

Definition at line 2935 of file sch_eagle_plugin.cpp.

2936 {
2937  wxPoint pinPosition = aSymbol->GetPinPhysicalPosition( aPin );
2938  auto pointIt = m_connPoints.find( pinPosition );
2939 
2940  if( pointIt == m_connPoints.end() )
2941  return false;
2942 
2943  const auto& items = pointIt->second;
2944  wxASSERT( items.find( aPin ) != items.end() );
2945  return items.size() > 1;
2946 }
wxPoint GetPinPhysicalPosition(const LIB_PIN *Pin) const
std::map< wxPoint, std::set< const EDA_ITEM * > > m_connPoints

References SCH_SYMBOL::GetPinPhysicalPosition(), and m_connPoints.

Referenced by addImplicitConnections().

◆ CheckHeader()

bool SCH_EAGLE_PLUGIN::CheckHeader ( const wxString &  aFileName)
overridevirtual

Return true if the first line in aFileName begins with the expected header.

Parameters
aFileNameis the name of the file to use as input

Reimplemented from SCH_PLUGIN.

Definition at line 2338 of file sch_eagle_plugin.cpp.

2339 {
2340  // Open file and check first line
2341  wxTextFile tempFile;
2342 
2343  tempFile.Open( aFileName );
2344  wxString firstline;
2345 
2346  // read the first line
2347  firstline = tempFile.GetFirstLine();
2348  wxString secondline = tempFile.GetNextLine();
2349  wxString thirdline = tempFile.GetNextLine();
2350  tempFile.Close();
2351 
2352  return firstline.StartsWith( wxT( "<?xml" ) ) && secondline.StartsWith( wxT( "<!DOCTYPE eagle SYSTEM" ) )
2353  && thirdline.StartsWith( wxT( "<eagle version" ) );
2354 }

◆ checkpoint()

void SCH_EAGLE_PLUGIN::checkpoint ( )
private

Definition at line 396 of file sch_eagle_plugin.cpp.

397 {
398  const unsigned PROGRESS_DELTA = 5;
399 
400  if( m_progressReporter )
401  {
402  if( ++m_doneCount > m_lastProgressCount + PROGRESS_DELTA )
403  {
405  / std::max( 1U, m_totalCount ) );
406 
408  THROW_IO_ERROR( ( "Open canceled by user." ) );
409 
411  }
412  }
413 }
unsigned m_totalCount
for progress reporting
unsigned m_lastProgressCount
PROGRESS_REPORTER * m_progressReporter
optional; may be nullptr
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).

References PROGRESS_REPORTER::KeepRefreshing(), m_doneCount, m_lastProgressCount, m_progressReporter, m_totalCount, PROGRESS_REPORTER::SetCurrentProgress(), and THROW_IO_ERROR.

Referenced by loadLibrary(), loadSchematic(), and loadSheet().

◆ countNets()

void SCH_EAGLE_PLUGIN::countNets ( wxXmlNode *  aSchematicNode)
private

Definition at line 552 of file sch_eagle_plugin.cpp.

553 {
554  // Map all children into a readable dictionary
555  NODE_MAP schematicChildren = MapChildren( aSchematicNode );
556 
557  // Loop through all the sheets
558  wxXmlNode* sheetNode = getChildrenNodes( schematicChildren, wxT( "sheets" ) );
559 
560  while( sheetNode )
561  {
562  NODE_MAP sheetChildren = MapChildren( sheetNode );
563 
564  // Loop through all nets
565  // From the DTD: "Net is an electrical connection in a schematic."
566  wxXmlNode* netNode = getChildrenNodes( sheetChildren, wxT( "nets" ) );
567 
568  while( netNode )
569  {
570  wxString netName = netNode->GetAttribute( wxT( "name" ) );
571 
572  if( m_netCounts.count( netName ) )
573  m_netCounts[netName] = m_netCounts[netName] + 1;
574  else
575  m_netCounts[netName] = 1;
576 
577  // Get next net
578  netNode = netNode->GetNext();
579  }
580 
581  sheetNode = sheetNode->GetNext();
582  }
583 }
std::map< wxString, int > m_netCounts
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:47
static wxXmlNode * getChildrenNodes(NODE_MAP &aMap, const wxString &aName)
Definition: eagle_parser.h:57

References getChildrenNodes(), m_netCounts, and MapChildren().

Referenced by loadSchematic().

◆ CreateSymbolLib()

void SCH_PLUGIN::CreateSymbolLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Create a new empty symbol library at aLibraryPath.

It is an error to attempt to create an existing library or to attempt to create on a "read only" location.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aPropertiesis an associative array that can be used to tell the library create function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem finding the library, or creating it.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 110 of file sch_plugin.cpp.

111 {
112  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
113  not_implemented( this, __FUNCTION__ );
114 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ DeleteSymbol()

void SCH_PLUGIN::DeleteSymbol ( const wxString &  aLibraryPath,
const wxString &  aSymbolName,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aSymbolNameis the name of a LIB_SYMBOL associated with it's root LIB_SYMBOL object to delete from the specified library.
aPropertiesis an associative array that can be used to tell the library delete function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem finding the alias or the library or deleting it.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 102 of file sch_plugin.cpp.

104 {
105  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
106  not_implemented( this, __FUNCTION__ );
107 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

Referenced by SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer().

◆ DeleteSymbolLib()

bool SCH_PLUGIN::DeleteSymbolLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Delete an existing symbol library and returns true if successful, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason.

Parameters
aLibraryPathis a locator for the "library", usually a directory or file which will contain symbols.
aPropertiesis an associative array that can be used to tell the library delete implementation function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
true if library deleted or false if library did not exist.
Exceptions
IO_ERRORif there is a problem deleting an existing library.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 117 of file sch_plugin.cpp.

118 {
119  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
120  not_implemented( this, __FUNCTION__ );
121  return false;
122 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ EnumerateSymbolLib() [1/2]

void SCH_PLUGIN::EnumerateSymbolLib ( wxArrayString &  aSymbolNameList,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.

Parameters
aSymbolNameListis an array to populate with the LIB_SYMBOL names associated with the library.
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing one or more LIB_SYMBOL objects.
aPropertiesis an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif the library cannot be found, the part library cannot be loaded.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 67 of file sch_plugin.cpp.

70 {
71  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
72  not_implemented( this, __FUNCTION__ );
73 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ EnumerateSymbolLib() [2/2]

void SCH_PLUGIN::EnumerateSymbolLib ( std::vector< LIB_SYMBOL * > &  aSymbolList,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Populate a list of LIB_SYMBOL aliases contained within the library aLibraryPath.

Note
It is the responsibility of the caller to delete the returned object from the heap. Failure to do this will result in memory leaks.
Parameters
aSymbolListis an array to populate with the LIB_SYMBOL pointers associated with the library.
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing one or more LIB_SYMBOL objects.
aPropertiesis an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif the library cannot be found, the part library cannot be loaded.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 76 of file sch_plugin.cpp.

79 {
80  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
81  not_implemented( this, __FUNCTION__ );
82 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ findNearestLinePoint()

std::pair< VECTOR2I, const SEG * > SCH_EAGLE_PLUGIN::findNearestLinePoint ( const wxPoint &  aPoint,
const std::vector< SEG > &  aLines 
) const
private

Definition at line 1232 of file sch_eagle_plugin.cpp.

1234 {
1235  VECTOR2I nearestPoint;
1236  const SEG* nearestLine = nullptr;
1237 
1238  float d, mindistance = std::numeric_limits<float>::max();
1239 
1240  // Find the nearest start, middle or end of a line from the list of lines.
1241  for( const SEG& line : aLines )
1242  {
1243  VECTOR2I testpoint = line.A;
1244  d = sqrt( abs( ( ( aPoint.x - testpoint.x ) ^ 2 ) + ( ( aPoint.y - testpoint.y ) ^ 2 ) ) );
1245 
1246  if( d < mindistance )
1247  {
1248  mindistance = d;
1249  nearestPoint = testpoint;
1250  nearestLine = &line;
1251  }
1252 
1253  testpoint = line.Center();
1254  d = sqrt( abs( ( ( aPoint.x - testpoint.x ) ^ 2 ) + ( ( aPoint.y - testpoint.y ) ^ 2 ) ) );
1255 
1256  if( d < mindistance )
1257  {
1258  mindistance = d;
1259  nearestPoint = testpoint;
1260  nearestLine = &line;
1261  }
1262 
1263  testpoint = line.B;
1264  d = sqrt( abs( ( ( aPoint.x - testpoint.x ) ^ 2 ) + ( ( aPoint.y - testpoint.y ) ^ 2 ) ) );
1265 
1266  if( d < mindistance )
1267  {
1268  mindistance = d;
1269  nearestPoint = testpoint;
1270  nearestLine = &line;
1271  }
1272  }
1273 
1274  return std::make_pair( nearestPoint, nearestLine );
1275 }
Definition: seg.h:40

References VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by adjustNetLabels().

◆ GetError()

const wxString & SCH_PLUGIN::GetError ( ) const
virtualinherited

Return an error string to the caller.

This is useful for schematic loaders that can load partial schematics where throwing an exception would be problematic such as the KiCad legacy plugin.

Returns
an unformatted string containing errors if any.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 177 of file sch_plugin.cpp.

178 {
179  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
180  not_implemented( this, __FUNCTION__ );
181  static wxString error;
182  return error;
183 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

Referenced by TEST_SCH_SHEET_LIST_FIXTURE::loadSchematic(), and TEST_NETLISTS_FIXTURE::loadSchematic().

◆ GetFileExtension()

const wxString SCH_EAGLE_PLUGIN::GetFileExtension ( ) const
overridevirtual

Return the file extension for the SCH_PLUGIN.

Implements SCH_PLUGIN.

Definition at line 378 of file sch_eagle_plugin.cpp.

379 {
380  return wxT( "sch" );
381 }

◆ getLibFileName()

wxFileName SCH_EAGLE_PLUGIN::getLibFileName ( )
private

Checks if there are other wires or pins at the position of the tested pin.

Definition at line 156 of file sch_eagle_plugin.cpp.

157 {
159 
160  return fn;
161 }
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:122
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
SCHEMATIC * m_schematic
Passed to Load(), the schematic object being loaded.
const std::string KiCadSymbolLibFileExtension

References KiCadSymbolLibFileExtension.

Referenced by Load(), loadInstance(), loadLibrary(), and loadSchematic().

◆ getLibName()

wxString SCH_EAGLE_PLUGIN::getLibName ( )
private

Definition at line 132 of file sch_eagle_plugin.cpp.

133 {
134  if( m_libName.IsEmpty() )
135  {
136  // Try to come up with a meaningful name
138 
139  if( m_libName.IsEmpty() )
140  {
141  wxFileName fn( m_rootSheet->GetFileName() );
142  m_libName = fn.GetName();
143  }
144 
145  if( m_libName.IsEmpty() )
146  m_libName = wxT( "noname" );
147 
148  m_libName += wxT( "-eagle-import" );
150  }
151 
152  return m_libName;
153 }
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Definition: lib_id.cpp:189
wxString m_libName
Library name to save symbols.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:314
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
SCHEMATIC * m_schematic
Passed to Load(), the schematic object being loaded.
virtual const wxString GetProjectName() const
Return the short name of the project.
Definition: project.cpp:128

References LIB_ID::FixIllegalChars().

Referenced by Load(), and loadInstance().

◆ GetLibraryFileExtension()

const wxString SCH_EAGLE_PLUGIN::GetLibraryFileExtension ( ) const
overridevirtual

Return the library file extension for the SCH_PLUGIN object.

Implements SCH_PLUGIN.

Definition at line 384 of file sch_eagle_plugin.cpp.

385 {
386  return wxT( "lbr" );
387 }

◆ GetModifyHash()

int SCH_EAGLE_PLUGIN::GetModifyHash ( ) const
overridevirtual

Return the modification hash from the library cache.

Note
This is temporary until the new s-expr file format is implement. The new file format will embed symbols instead of referencing them from the library. This function can be removed when the new file format is implemented.
Returns
the modification hash of the library cache.

Implements SCH_PLUGIN.

Definition at line 390 of file sch_eagle_plugin.cpp.

391 {
392  return 0;
393 }

◆ GetName()

const wxString SCH_EAGLE_PLUGIN::GetName ( ) const
overridevirtual

Return a brief hard coded name for this SCH_PLUGIN.

Implements SCH_PLUGIN.

Definition at line 372 of file sch_eagle_plugin.cpp.

373 {
374  return wxT( "EAGLE" );
375 }

◆ IsSymbolLibWritable()

bool SCH_PLUGIN::IsSymbolLibWritable ( const wxString &  aLibraryPath)
virtualinherited

Return true if the library at aLibraryPath is writable.

(Often system libraries are read only because of where they are installed.)

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
Exceptions
IO_ERRORif no library at aLibraryPath exists.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 125 of file sch_plugin.cpp.

126 {
127  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
128  not_implemented( this, __FUNCTION__ );
129  return false;
130 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ kiCadLayer()

SCH_LAYER_ID SCH_EAGLE_PLUGIN::kiCadLayer ( int  aEagleLayer)
private

Return the matching layer or return LAYER_NOTES.

Definition at line 215 of file sch_eagle_plugin.cpp.

216 {
217  auto it = m_layerMap.find( aEagleLayer );
218  return it == m_layerMap.end() ? LAYER_NOTES : it->second;
219 }
std::map< int, SCH_LAYER_ID > m_layerMap

References LAYER_NOTES.

Referenced by loadWire().

◆ Load()

SCH_SHEET * SCH_EAGLE_PLUGIN::Load ( const wxString &  aFileName,
SCHEMATIC aSchematic,
SCH_SHEET aAppendToMe = nullptr,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Load information from some input file format that this SCH_PLUGIN implementation knows about, into either a new SCH_SHEET or an existing one.

This may be used to load an entire new SCH_SHEET, or to augment an existing one if aAppendToMe is not NULL.

Parameters
aFileNameis the name of the file to use as input and may be foreign in nature or native in nature.
aKiwayis the KIWAY object used to access the symbol libraries loaded by the project.
aAppendToMeis an existing SCH_SHEET to append to, but if NULL then this means "do not append, rather load anew".
aPropertiesis an associative array that can be used to tell the loader how to load the file, because it can take any number of additional named arguments that the plugin is known to support. These are tuning parameters for the import or load. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
the successfully loaded schematic, or the same one as aAppendToMe if aAppendToMe was not NULL, and the caller owns it.
Exceptions
IO_ERRORif there is a problem loading, and its contents should say what went wrong, using line number and character offsets of the input file if possible.
Note
No check is being done here to see if the existing symbol library exists so this will overwrite the existing one.

Reimplemented from SCH_PLUGIN.

Definition at line 416 of file sch_eagle_plugin.cpp.

418 {
419  wxASSERT( !aFileName || aSchematic != nullptr );
420  LOCALE_IO toggle; // toggles on, then off, the C locale.
421 
422  m_filename = aFileName;
423  m_schematic = aSchematic;
424 
425  if( m_progressReporter )
426  {
427  m_progressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
428 
430  THROW_IO_ERROR( ( "Open canceled by user." ) );
431  }
432 
433  // Load the document
434  wxXmlDocument xmlDocument;
435  wxFFileInputStream stream( m_filename.GetFullPath() );
436 
437  if( !stream.IsOk() || !xmlDocument.Load( stream ) )
438  {
439  THROW_IO_ERROR( wxString::Format( _( "Unable to read file '%s'." ),
440  m_filename.GetFullPath() ) );
441  }
442 
443  // Delete on exception, if I own m_rootSheet, according to aAppendToMe
444  unique_ptr<SCH_SHEET> deleter( aAppendToMe ? nullptr : m_rootSheet );
445 
446  wxFileName newFilename( m_filename );
447  newFilename.SetExt( KiCadSchematicFileExtension );
448 
449  if( aAppendToMe )
450  {
451  wxCHECK_MSG( aSchematic->IsValid(), nullptr, wxT( "Can't append to a schematic with no root!" ) );
452  m_rootSheet = &aSchematic->Root();
453  }
454  else
455  {
456  m_rootSheet = new SCH_SHEET( aSchematic );
457  m_rootSheet->SetFileName( newFilename.GetFullPath() );
458  aSchematic->SetRoot( m_rootSheet );
459  }
460 
461  if( !m_rootSheet->GetScreen() )
462  {
463  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
464  screen->SetFileName( newFilename.GetFullPath() );
465  m_rootSheet->SetScreen( screen );
466  }
467 
468  SYMBOL_LIB_TABLE* libTable = m_schematic->Prj().SchSymbolLibTable();
469 
470  wxCHECK_MSG( libTable, nullptr, wxT( "Could not load symbol lib table." ) );
471 
472  m_pi.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
473  m_properties = std::make_unique<PROPERTIES>();
474  ( *m_properties )[SCH_LEGACY_PLUGIN::PropBuffering] = "";
475 
478  if( !libTable->HasLibrary( getLibName() ) )
479  {
480  // Create a new empty symbol library.
481  m_pi->CreateSymbolLib( getLibFileName().GetFullPath() );
482  wxString libTableUri = wxT( "${KIPRJMOD}/" ) + getLibFileName().GetFullName();
483 
484  // Add the new library to the project symbol library table.
485  libTable->InsertRow(
486  new SYMBOL_LIB_TABLE_ROW( getLibName(), libTableUri, wxString( wxT( "KiCad" ) ) ) );
487 
488  // Save project symbol library table.
489  wxFileName fn( m_schematic->Prj().GetProjectPath(),
491 
492  // So output formatter goes out of scope and closes the file before reloading.
493  {
494  FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
495  libTable->Format( &formatter, 0 );
496  }
497 
498  // Reload the symbol library table.
500  m_schematic->Prj().SchSymbolLibTable();
501  }
502 
503  // Retrieve the root as current node
504  wxXmlNode* currentNode = xmlDocument.GetRoot();
505 
506  // If the attribute is found, store the Eagle version;
507  // otherwise, store the dummy "0.0" version.
508  m_version = currentNode->GetAttribute( wxT( "version" ), wxT( "0.0" ) );
509 
510  // Map all children into a readable dictionary
511  NODE_MAP children = MapChildren( currentNode );
512 
513  // Load drawing
514  loadDrawing( children[wxT( "drawing" )] );
515 
516  m_pi->SaveLibrary( getLibFileName().GetFullPath() );
517 
518  SCH_SCREENS allSheets( m_rootSheet );
519  allSheets.UpdateSymbolLinks(); // Update all symbol library links for all sheets.
520 
521  return m_rootSheet;
522 }
static const wxString & GetSymbolLibTableFileName()
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:320
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:175
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:108
void set(SCH_PLUGIN *aPlugin)
Definition: sch_io_mgr.h:507
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:102
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:122
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:258
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:104
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
PI to create KiCad symbol library.
#define _(s)
wxFileName getLibFileName()
Checks if there are other wires or pins at the position of the tested pin.
wxString m_version
Eagle file version.
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
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
SCH_SHEET & Root() const
Definition: schematic.h:92
void loadDrawing(wxXmlNode *aDrawingNode)
const std::string KiCadSchematicFileExtension
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
SCHEMATIC * m_schematic
Passed to Load(), the schematic object being loaded.
Used for text file output.
Definition: richio.h:456
PROGRESS_REPORTER * m_progressReporter
optional; may be nullptr
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
std::unique_ptr< PROPERTIES > m_properties
Library plugin properties.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:110
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:47

References _, PROJECT::ELEM_SYMBOL_LIB_TABLE, SYMBOL_LIB_TABLE::Format(), Format(), getLibFileName(), getLibName(), PROJECT::GetProjectPath(), SCH_SHEET::GetScreen(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName(), LIB_TABLE::HasLibrary(), LIB_TABLE::InsertRow(), SCHEMATIC::IsValid(), PROGRESS_REPORTER::KeepRefreshing(), KiCadSchematicFileExtension, loadDrawing(), m_filename, m_pi, m_progressReporter, m_properties, m_rootSheet, m_schematic, m_version, MapChildren(), SCHEMATIC::Prj(), SCH_LEGACY_PLUGIN::PropBuffering, PROGRESS_REPORTER::Report(), SCHEMATIC::Root(), SCH_PLUGIN::SCH_PLUGIN_RELEASER::set(), PROJECT::SetElem(), SCH_SCREEN::SetFileName(), SCH_SHEET::SetFileName(), SCHEMATIC::SetRoot(), SCH_SHEET::SetScreen(), THROW_IO_ERROR, and SCH_SCREENS::UpdateSymbolLinks().

◆ loadDrawing()

void SCH_EAGLE_PLUGIN::loadDrawing ( wxXmlNode *  aDrawingNode)
private

Definition at line 525 of file sch_eagle_plugin.cpp.

526 {
527  // Map all children into a readable dictionary
528  NODE_MAP drawingChildren = MapChildren( aDrawingNode );
529 
530  // Board nodes should not appear in .sch files
531  // wxXmlNode* board = drawingChildren["board"]
532 
533  // wxXmlNode* grid = drawingChildren["grid"]
534 
535  auto layers = drawingChildren[wxT( "layers" )];
536 
537  if( layers )
538  loadLayerDefs( layers );
539 
540  // wxXmlNode* library = drawingChildren["library"]
541 
542  // wxXmlNode* settings = drawingChildren["settings"]
543 
544  // Load schematic
545  auto schematic = drawingChildren[wxT( "schematic" )];
546 
547  if( schematic )
548  loadSchematic( schematic );
549 }
void loadSchematic(wxXmlNode *aSchematicNode)
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
void loadLayerDefs(wxXmlNode *aLayers)
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:47

References loadLayerDefs(), loadSchematic(), and MapChildren().

Referenced by Load().

◆ loadFieldAttributes()

void SCH_EAGLE_PLUGIN::loadFieldAttributes ( LIB_FIELD aField,
const LIB_TEXT aText 
) const
private

Move net labels that are detached from any wire to the nearest wire.

Definition at line 2251 of file sch_eagle_plugin.cpp.

2252 {
2253  aField->SetTextPos( aText->GetPosition() );
2254  aField->SetTextSize( aText->GetTextSize() );
2255  aField->SetTextAngle( aText->GetTextAngle() );
2256  aField->SetBold( aText->IsBold() );
2257  aField->SetVertJustify( aText->GetVertJustify() );
2258  aField->SetHorizJustify( aText->GetHorizJustify() );
2259  aField->SetVisible( true );
2260 }
bool IsBold() const
Definition: eda_text.h:204
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:220
wxPoint GetPosition() const override
Definition: lib_text.h:91
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:267
double GetTextAngle() const
Definition: eda_text.h:195
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:219
const wxSize & GetTextSize() const
Definition: eda_text.h:259
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:223
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:222
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:188
void SetBold(bool aBold)
Definition: eda_text.h:203

References EDA_TEXT::GetHorizJustify(), LIB_TEXT::GetPosition(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), EDA_TEXT::IsBold(), EDA_TEXT::SetBold(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetVertJustify(), and EDA_TEXT::SetVisible().

Referenced by loadSymbol().

◆ loadFrame() [1/2]

void SCH_EAGLE_PLUGIN::loadFrame ( wxXmlNode *  aFrameNode,
std::vector< SCH_LINE * > &  aLines 
)
private

Definition at line 989 of file sch_eagle_plugin.cpp.

990 {
991  EFRAME eframe( aFrameNode );
992 
993  wxPoint corner1( eframe.x1.ToSchUnits(), -eframe.y1.ToSchUnits() );
994  wxPoint corner3( eframe.x2.ToSchUnits(), -eframe.y2.ToSchUnits() );
995  wxPoint corner2( corner3.x, corner1.y );
996  wxPoint corner4( corner1.x, corner3.y );
997 
998  SCH_LINE* line = new SCH_LINE();
1000  line->SetStartPoint( corner1 );
1001  line->SetEndPoint( corner2 );
1002  aLines.push_back( line );
1003 
1004  line = new SCH_LINE();
1006  line->SetStartPoint( corner2 );
1007  line->SetEndPoint( corner3 );
1008  aLines.push_back( line );
1009 
1010  line = new SCH_LINE();
1012  line->SetStartPoint( corner3 );
1013  line->SetEndPoint( corner4 );
1014  aLines.push_back( line );
1015 
1016  line = new SCH_LINE();
1018  line->SetStartPoint( corner4 );
1019  line->SetEndPoint( corner1 );
1020  aLines.push_back( line );
1021 }
Parse an Eagle frame element.
Definition: eagle_parser.h:674
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
Definition: sch_line.cpp:269
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:91
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37

References SCH_LINE::SetEndPoint(), SCH_LINE::SetLineStyle(), SCH_LINE::SetStartPoint(), SOLID, ECOORD::ToSchUnits(), EFRAME::x1, EFRAME::x2, EFRAME::y1, and EFRAME::y2.

Referenced by loadSheet(), and loadSymbol().

◆ loadFrame() [2/2]

void SCH_EAGLE_PLUGIN::loadFrame ( wxXmlNode *  aFrameNode,
std::vector< LIB_ITEM * > &  aLines 
)
private

Definition at line 2020 of file sch_eagle_plugin.cpp.

2021 {
2022  EFRAME eframe( aFrameNode );
2023 
2024  int xMin = eframe.x1.ToSchUnits();
2025  int xMax = eframe.x2.ToSchUnits();
2026  int yMin = eframe.y1.ToSchUnits();
2027  int yMax = eframe.y2.ToSchUnits();
2028 
2029  if( xMin > xMax )
2030  std::swap( xMin, xMax );
2031 
2032  if( yMin > yMax )
2033  std::swap( yMin, yMax );
2034 
2035  LIB_SHAPE* lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
2036  lines->AddPoint( wxPoint( xMin, yMin ) );
2037  lines->AddPoint( wxPoint( xMax, yMin ) );
2038  lines->AddPoint( wxPoint( xMax, yMax ) );
2039  lines->AddPoint( wxPoint( xMin, yMax ) );
2040  lines->AddPoint( wxPoint( xMin, yMin ) );
2041  aItems.push_back( lines );
2042 
2043  if( !eframe.border_left )
2044  {
2045  lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
2046  lines->AddPoint( wxPoint( xMin + Mils2iu( 150 ), yMin + Mils2iu( 150 ) ) );
2047  lines->AddPoint( wxPoint( xMin + Mils2iu( 150 ), yMax - Mils2iu( 150 ) ) );
2048  aItems.push_back( lines );
2049 
2050  int i;
2051  int height = yMax - yMin;
2052  int x1 = xMin;
2053  int x2 = x1 + Mils2iu( 150 );
2054  int legendPosX = xMin + Mils2iu( 75 );
2055  double rowSpacing = height / double( eframe.rows );
2056  double legendPosY = yMax - ( rowSpacing / 2 );
2057 
2058  for( i = 1; i < eframe.rows; i++ )
2059  {
2060  int newY = KiROUND( yMin + ( rowSpacing * (double) i ) );
2061  lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
2062  lines->AddPoint( wxPoint( x1, newY ) );
2063  lines->AddPoint( wxPoint( x2, newY ) );
2064  aItems.push_back( lines );
2065  }
2066 
2067  char legendChar = 'A';
2068 
2069  for( i = 0; i < eframe.rows; i++ )
2070  {
2071  LIB_TEXT* legendText = new LIB_TEXT( nullptr );
2072  legendText->SetPosition( wxPoint( legendPosX, KiROUND( legendPosY ) ) );
2073  legendText->SetText( wxString( legendChar ) );
2074  legendText->SetTextSize( wxSize( Mils2iu( 90 ), Mils2iu( 100 ) ) );
2075  aItems.push_back( legendText );
2076  legendChar++;
2077  legendPosY -= rowSpacing;
2078  }
2079  }
2080 
2081  if( !eframe.border_right )
2082  {
2083  lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
2084  lines->AddPoint( wxPoint( xMax - Mils2iu( 150 ), yMin + Mils2iu( 150 ) ) );
2085  lines->AddPoint( wxPoint( xMax - Mils2iu( 150 ), yMax - Mils2iu( 150 ) ) );
2086  aItems.push_back( lines );
2087 
2088  int i;
2089  int height = yMax - yMin;
2090  int x1 = xMax - Mils2iu( 150 );
2091  int x2 = xMax;
2092  int legendPosX = xMax - Mils2iu( 75 );
2093  double rowSpacing = height / double( eframe.rows );
2094  double legendPosY = yMax - ( rowSpacing / 2 );
2095 
2096  for( i = 1; i < eframe.rows; i++ )
2097  {
2098  int newY = KiROUND( yMin + ( rowSpacing * (double) i ) );
2099  lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
2100  lines->AddPoint( wxPoint( x1, newY ) );
2101  lines->AddPoint( wxPoint( x2, newY ) );
2102  aItems.push_back( lines );
2103  }
2104 
2105  char legendChar = 'A';
2106 
2107  for( i = 0; i < eframe.rows; i++ )
2108  {
2109  LIB_TEXT* legendText = new LIB_TEXT( nullptr );
2110  legendText->SetPosition( wxPoint( legendPosX, KiROUND( legendPosY ) ) );
2111  legendText->SetText( wxString( legendChar ) );
2112  legendText->SetTextSize( wxSize( Mils2iu( 90 ), Mils2iu( 100 ) ) );
2113  aItems.push_back( legendText );
2114  legendChar++;
2115  legendPosY -= rowSpacing;
2116  }
2117  }
2118 
2119  if( !eframe.border_top )
2120  {
2121  lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
2122  lines->AddPoint( wxPoint( xMax - Mils2iu( 150 ), yMax - Mils2iu( 150 ) ) );
2123  lines->AddPoint( wxPoint( xMin + Mils2iu( 150 ), yMax - Mils2iu( 150 ) ) );
2124  aItems.push_back( lines );
2125 
2126  int i;
2127  int width = xMax - xMin;
2128  int y1 = yMin;
2129  int y2 = yMin + Mils2iu( 150 );
2130  int legendPosY = yMax - Mils2iu( 75 );
2131  double columnSpacing = width / double( eframe.columns );
2132  double legendPosX = xMin + ( columnSpacing / 2 );
2133 
2134  for( i = 1; i < eframe.columns; i++ )
2135  {
2136  int newX = KiROUND( xMin + ( columnSpacing * (double) i ) );
2137  lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
2138  lines->AddPoint( wxPoint( newX, y1 ) );
2139  lines->AddPoint( wxPoint( newX, y2 ) );
2140  aItems.push_back( lines );
2141  }
2142 
2143  char legendChar = '1';
2144 
2145  for( i = 0; i < eframe.columns; i++ )
2146  {
2147  LIB_TEXT* legendText = new LIB_TEXT( nullptr );
2148  legendText->SetPosition( wxPoint( KiROUND( legendPosX ), legendPosY ) );
2149  legendText->SetText( wxString( legendChar ) );
2150  legendText->SetTextSize( wxSize( Mils2iu( 90 ), Mils2iu( 100 ) ) );
2151  aItems.push_back( legendText );
2152  legendChar++;
2153  legendPosX += columnSpacing;
2154  }
2155  }
2156 
2157  if( !eframe.border_bottom )
2158  {
2159  lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
2160  lines->AddPoint( wxPoint( xMax - Mils2iu( 150 ), yMin + Mils2iu( 150 ) ) );
2161  lines->AddPoint( wxPoint( xMin + Mils2iu( 150 ), yMin + Mils2iu( 150 ) ) );
2162  aItems.push_back( lines );
2163 
2164  int i;
2165  int width = xMax - xMin;
2166  int y1 = yMax - Mils2iu( 150 );
2167  int y2 = yMax;
2168  int legendPosY = yMin + Mils2iu( 75 );
2169  double columnSpacing = width / double( eframe.columns );
2170  double legendPosX = xMin + ( columnSpacing / 2 );
2171 
2172  for( i = 1; i < eframe.columns; i++ )
2173  {
2174  int newX = KiROUND( xMin + ( columnSpacing * (double) i ) );
2175  lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
2176  lines->AddPoint( wxPoint( newX, y1 ) );
2177  lines->AddPoint( wxPoint( newX, y2 ) );
2178  aItems.push_back( lines );
2179  }
2180 
2181  char legendChar = '1';
2182 
2183  for( i = 0; i < eframe.columns; i++ )
2184  {
2185  LIB_TEXT* legendText = new LIB_TEXT( nullptr );
2186  legendText->SetPosition( wxPoint( KiROUND( legendPosX ), legendPosY ) );
2187  legendText->SetText( wxString( legendChar ) );
2188  legendText->SetTextSize( wxSize( Mils2iu( 90 ), Mils2iu( 100 ) ) );
2189  aItems.push_back( legendText );
2190  legendChar++;
2191  legendPosX += columnSpacing;
2192  }
2193  }
2194 }
void AddPoint(const wxPoint &aPosition)
Definition: lib_shape.cpp:414
Define a symbol library graphical text item.
Definition: lib_text.h:39
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
Parse an Eagle frame element.
Definition: eagle_parser.h:674
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
void SetPosition(const wxPoint &aPosition) override
Definition: lib_item.h:230

References LIB_SHAPE::AddPoint(), EFRAME::border_bottom, EFRAME::border_left, EFRAME::border_right, EFRAME::border_top, EFRAME::columns, KiROUND(), POLY, EFRAME::rows, LIB_ITEM::SetPosition(), EDA_TEXT::SetText(), EDA_TEXT::SetTextSize(), ECOORD::ToSchUnits(), EFRAME::x1, EFRAME::x2, EFRAME::y1, and EFRAME::y2.

◆ loadInstance()

void SCH_EAGLE_PLUGIN::loadInstance ( wxXmlNode *  aInstanceNode)
private

Definition at line 1278 of file sch_eagle_plugin.cpp.

1279 {
1280  EINSTANCE einstance = EINSTANCE( aInstanceNode );
1281  SCH_SCREEN* screen = m_currentSheet->GetScreen();
1282 
1283  // Find the part in the list for the sheet.
1284  // Assign the symbol its value from the part entry
1285  // Calculate the unit number from the gate entry of the instance
1286  // Assign the LIB_ID from device set and device names
1287 
1288  auto part_it = m_partlist.find( einstance.part.Upper() );
1289 
1290  if( part_it == m_partlist.end() )
1291  {
1292  m_reporter->Report( wxString::Format( _( "Error parsing Eagle file. Could not find '%s' "
1293  "instance but it is referenced in the schematic." ),
1294  einstance.part ),
1296 
1297  return;
1298  }
1299 
1300  EPART* epart = part_it->second.get();
1301 
1302  wxString libraryname = epart->library;
1303  wxString gatename = epart->deviceset + epart->device + einstance.gate;
1304  wxString symbolname = wxString( epart->deviceset + epart->device );
1305  symbolname.Replace( wxT( "*" ), wxEmptyString );
1306  wxString kisymbolname = EscapeString( symbolname, CTX_LIBID );
1307 
1308  int unit = m_eagleLibs[libraryname].GateUnit[gatename];
1309 
1310  wxString package;
1311  EAGLE_LIBRARY* elib = &m_eagleLibs[libraryname];
1312 
1313  auto p = elib->package.find( kisymbolname );
1314 
1315  if( p != elib->package.end() )
1316  package = p->second;
1317 
1318  LIB_SYMBOL* part = m_pi->LoadSymbol( getLibFileName().GetFullPath(), kisymbolname,
1319  m_properties.get() );
1320 
1321  if( !part )
1322  {
1323  m_reporter->Report( wxString::Format( _( "Could not find '%s' in the imported library." ),
1324  UnescapeString( kisymbolname ) ),
1326  return;
1327  }
1328 
1329  LIB_ID libId( getLibName(), kisymbolname );
1330  std::unique_ptr<SCH_SYMBOL> symbol = std::make_unique<SCH_SYMBOL>();
1331  symbol->SetLibId( libId );
1332  symbol->SetUnit( unit );
1333  symbol->SetPosition( wxPoint( einstance.x.ToSchUnits(), -einstance.y.ToSchUnits() ) );
1334 
1335  // assume that footprint library is identical to project name
1336  wxString packageString = m_schematic->Prj().GetProjectName() + wxT( ":" ) + package;
1337  symbol->GetField( FOOTPRINT_FIELD )->SetText( packageString );
1338 
1339  if( einstance.rot )
1340  {
1341  symbol->SetOrientation( kiCadComponentRotation( einstance.rot->degrees ) );
1342 
1343  if( einstance.rot->mirror )
1344  symbol->MirrorHorizontally( einstance.x.ToSchUnits() );
1345  }
1346 
1347  std::vector<LIB_FIELD*> partFields;
1348  part->GetFields( partFields );
1349 
1350  for( const LIB_FIELD* field : partFields )
1351  {
1352  symbol->GetFieldById( field->GetId() )->ImportValues( *field );
1353  symbol->GetFieldById( field->GetId() )->SetTextPos( symbol->GetPosition()
1354  + field->GetTextPos() );
1355  }
1356 
1357  // If there is no footprint assigned, then prepend the reference value
1358  // with a hash character to mute netlist updater complaints
1359  wxString reference = package.IsEmpty() ? '#' + einstance.part : einstance.part;
1360 
1361  // reference must end with a number but EAGLE does not enforce this
1362  if( reference.find_last_not_of( "0123456789" ) == (reference.Length()-1) )
1363  reference.Append( "0" );
1364 
1365  // EAGLE allows references to be single digits. This breaks KiCad netlisting, which requires
1366  // parts to have non-digit + digit annotation. If the reference begins with a number,
1367  // we prepend 'UNK' (unknown) for the symbol designator
1368  if( reference.find_first_not_of( "0123456789" ) != 0 )
1369  reference.Prepend( "UNK" );
1370 
1371  // EAGLE allows designator to start with # but that is used in KiCad
1372  // for symbols which do not have a footprint
1373  if( einstance.part.find_first_not_of( "#" ) != 0 )
1374  reference.Prepend( "UNK" );
1375 
1376  SCH_SHEET_PATH sheetpath;
1377  m_rootSheet->LocatePathOfScreen( screen, &sheetpath );
1378  wxString current_sheetpath = sheetpath.PathAsString() + symbol->m_Uuid.AsString();
1379 
1380  symbol->GetField( REFERENCE_FIELD )->SetText( reference );
1381  symbol->AddHierarchicalReference( current_sheetpath, reference, unit );
1382 
1383  if( epart->value )
1384  symbol->GetField( VALUE_FIELD )->SetText( *epart->value );
1385  else
1386  symbol->GetField( VALUE_FIELD )->SetText( kisymbolname );
1387 
1388  // Set the visibility of fields.
1389  symbol->GetField( REFERENCE_FIELD )->SetVisible(
1390  part->GetFieldById( REFERENCE_FIELD )->IsVisible() );
1391  symbol->GetField( VALUE_FIELD )->SetVisible( part->GetFieldById( VALUE_FIELD )->IsVisible() );
1392 
1393  for( const auto& a : epart->attribute )
1394  {
1395  SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) );
1396  field->SetName( a.first );
1397  field->SetText( a.second );
1398  field->SetVisible( false );
1399  }
1400 
1401  for( const auto& a : epart->variant )
1402  {
1403  SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) );
1404  field->SetName( wxT( "VARIANT_" ) + a.first );
1405  field->SetText( a.second );
1406  field->SetVisible( false );
1407  }
1408 
1409  bool valueAttributeFound = false;
1410  bool nameAttributeFound = false;
1411 
1412  wxXmlNode* attributeNode = aInstanceNode->GetChildren();
1413 
1414  // Parse attributes for the instance
1415  while( attributeNode )
1416  {
1417  if( attributeNode->GetName() == wxT( "attribute" ) )
1418  {
1419  EATTR attr = EATTR( attributeNode );
1420  SCH_FIELD* field = nullptr;
1421 
1422  if( attr.name.Lower() == wxT( "name" ) )
1423  {
1424  field = symbol->GetField( REFERENCE_FIELD );
1425  nameAttributeFound = true;
1426  }
1427  else if( attr.name.Lower() == wxT( "value" ) )
1428  {
1429  field = symbol->GetField( VALUE_FIELD );
1430  valueAttributeFound = true;
1431  }
1432  else
1433  {
1434  field = symbol->FindField( attr.name );
1435 
1436  if( field )
1437  field->SetVisible( false );
1438  }
1439 
1440  if( field )
1441  {
1442 
1443  field->SetPosition( wxPoint( attr.x->ToSchUnits(), -attr.y->ToSchUnits() ) );
1444  int align = attr.align ? *attr.align : ETEXT::BOTTOM_LEFT;
1445  int absdegrees = attr.rot ? attr.rot->degrees : 0;
1446  bool mirror = attr.rot ? attr.rot->mirror : false;
1447 
1448  if( einstance.rot && einstance.rot->mirror )
1449  mirror = !mirror;
1450 
1451  bool spin = attr.rot ? attr.rot->spin : false;
1452 
1453  if( attr.display == EATTR::Off || attr.display == EATTR::NAME )
1454  field->SetVisible( false );
1455 
1456  int rotation = einstance.rot ? einstance.rot->degrees : 0;
1457  int reldegrees = ( absdegrees - rotation + 360.0 );
1458  reldegrees %= 360;
1459 
1460  eagleToKicadAlignment( (EDA_TEXT*) field, align, reldegrees, mirror, spin,
1461  absdegrees );
1462  }
1463  }
1464  else if( attributeNode->GetName() == wxT( "variant" ) )
1465  {
1466  wxString variant, value;
1467 
1468  if( attributeNode->GetAttribute( wxT( "name" ), &variant )
1469  && attributeNode->GetAttribute( wxT( "value" ), &value ) )
1470  {
1471  SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) );
1472  field->SetName( wxT( "VARIANT_" ) + variant );
1473  field->SetText( value );
1474  field->SetVisible( false );
1475  }
1476  }
1477 
1478  attributeNode = attributeNode->GetNext();
1479  }
1480 
1481  if( einstance.smashed && einstance.smashed.Get() )
1482  {
1483  if( !valueAttributeFound )
1484  symbol->GetField( VALUE_FIELD )->SetVisible( false );
1485 
1486  if( !nameAttributeFound )
1487  symbol->GetField( REFERENCE_FIELD )->SetVisible( false );
1488  }
1489 
1490  // Save the pin positions
1491  SYMBOL_LIB_TABLE& schLibTable = *m_schematic->Prj().SchSymbolLibTable();
1492  LIB_SYMBOL* libSymbol = schLibTable.LoadSymbol( symbol->GetLibId() );
1493 
1494  wxCHECK( libSymbol, /*void*/ );
1495 
1496  symbol->SetLibSymbol( new LIB_SYMBOL( *libSymbol ) );
1497 
1498  std::vector<LIB_PIN*> pins;
1499  symbol->GetLibPins( pins );
1500 
1501  for( const LIB_PIN* pin : pins )
1502  m_connPoints[symbol->GetPinPhysicalPosition( pin )].emplace( pin );
1503 
1504  if( part->IsPower() )
1505  m_powerPorts[ reference ] = symbol->GetField( VALUE_FIELD )->GetText();
1506 
1507  symbol->ClearFlags();
1508 
1509  screen->Append( symbol.release() );
1510 }
Field Reference of part, i.e. "IC21".
SCH_SHEET * m_currentSheet
The current sheet of the schematic being loaded.
wxString deviceset
Definition: eagle_parser.h:925
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
bool mirror
Definition: eagle_parser.h:472
wxString part
Definition: eagle_parser.h:950
int ToSchUnits() const
Definition: eagle_parser.h:429
wxString library
Definition: eagle_parser.h:924
std::unordered_map< wxString, wxString > package
T & Get()
Return a reference to the value of the attribute assuming it is available.
Definition: eagle_parser.h:292
Field object used in symbol libraries.
Definition: lib_field.h:59
std::map< std::string, std::string > variant
Definition: eagle_parser.h:930
wxString PathAsString() const
Return the path of time stamps which do not changes even when editing sheet parameters.
double degrees
Definition: eagle_parser.h:474
ECOORD x
Definition: eagle_parser.h:952
static void eagleToKicadAlignment(EDA_TEXT *aText, int aEagleAlignment, int aRelDegress, bool aMirror, bool aSpin, int aAbsDegress)
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:102
Define a library symbol object.
Definition: lib_symbol.h:96
std::map< wxString, wxString > m_powerPorts
map from symbol reference to global label equivalent
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
opt_erot rot
Definition: eagle_parser.h:603
opt_wxString value
Definition: eagle_parser.h:928
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:140
opt_int align
Definition: eagle_parser.h:612
wxString gate
Definition: eagle_parser.h:951
wxString name
Definition: eagle_parser.h:596
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
std::map< wxString, EAGLE_LIBRARY > m_eagleLibs
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
opt_ecoord y
Definition: eagle_parser.h:599
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
PI to create KiCad symbol library.
#define _(s)
wxFileName getLibFileName()
Checks if there are other wires or pins at the position of the tested pin.
std::map< std::string, std::string > attribute
Definition: eagle_parser.h:929
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
wxString UnescapeString(const wxString &aSource)
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
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
Parse an Eagle "attribute" XML element.
Definition: eagle_parser.h:594
opt_ecoord x
Definition: eagle_parser.h:598
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:729
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
REPORTER * m_reporter
Reporter for warnings/errors.
void SetName(const wxString &aName)
Definition: sch_field.h:111
opt_bool smashed
Definition: eagle_parser.h:954
SCHEMATIC * m_schematic
Passed to Load(), the schematic object being loaded.
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
virtual const wxString GetProjectName() const
Return the short name of the project.
Definition: project.cpp:128
opt_erot rot
Definition: eagle_parser.h:955
bool spin
Definition: eagle_parser.h:473
ECOORD y
Definition: eagle_parser.h:953
std::unique_ptr< PROPERTIES > m_properties
Library plugin properties.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
opt_int display
Definition: eagle_parser.h:611
wxString device
Definition: eagle_parser.h:926
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:822
std::map< wxPoint, std::set< const EDA_ITEM * > > m_connPoints
static SYMBOL_ORIENTATION_T kiCadComponentRotation(float eagleDegrees)
Field Name Module PCB, i.e. "16DIP300".

References _, EATTR::align, SCH_SCREEN::Append(), EPART::attribute, ETEXT::BOTTOM_LEFT, CTX_LIBID, EROT::degrees, EPART::device, EPART::deviceset, EATTR::display, eagleToKicadAlignment(), EscapeString(), FOOTPRINT_FIELD, Format(), EINSTANCE::gate, OPTIONAL_XML_ATTRIBUTE< T >::Get(), getLibFileName(), getLibName(), PROJECT::GetProjectName(), SCH_SHEET::GetScreen(), kiCadComponentRotation(), EPART::library, SYMBOL_LIB_TABLE::LoadSymbol(), SCH_SHEET::LocatePathOfScreen(), m_connPoints, m_currentSheet, m_eagleLibs, m_partlist, m_pi, m_powerPorts, m_properties, m_reporter, m_rootSheet, m_schematic, EROT::mirror, EATTR::name, EATTR::NAME, EATTR::Off, EAGLE_LIBRARY::package, EINSTANCE::part, SCH_SHEET_PATH::PathAsString(), pin, SCHEMATIC::Prj(), REFERENCE_FIELD, REPORTER::Report(), EATTR::rot, EINSTANCE::rot, RPT_SEVERITY_ERROR, SCH_FIELD::SetName(), SCH_FIELD::SetPosition(), EDA_TEXT::SetText(), EDA_TEXT::SetVisible(), EINSTANCE::smashed, EROT::spin, ECOORD::ToSchUnits(), UnescapeString(), EPART::value, VALUE_FIELD, EPART::variant, EATTR::x, EINSTANCE::x, EATTR::y, and EINSTANCE::y.

Referenced by loadSheet().

◆ loadJunction()

SCH_JUNCTION * SCH_EAGLE_PLUGIN::loadJunction ( wxXmlNode *  aJunction)
private

Definition at line 1182 of file sch_eagle_plugin.cpp.

1183 {
1184  std::unique_ptr<SCH_JUNCTION> junction = std::make_unique<SCH_JUNCTION>();
1185 
1186  EJUNCTION ejunction = EJUNCTION( aJunction );
1187  wxPoint pos( ejunction.x.ToSchUnits(), -ejunction.y.ToSchUnits() );
1188 
1189  junction->SetPosition( pos );
1190 
1191  return junction.release();
1192 }
Eagle Junction.
Definition: eagle_parser.h:522
int ToSchUnits() const
Definition: eagle_parser.h:429
ECOORD y
Definition: eagle_parser.h:525
ECOORD x
Definition: eagle_parser.h:524

References ECOORD::ToSchUnits(), EJUNCTION::x, and EJUNCTION::y.

Referenced by loadSegments().

◆ loadLabel()

SCH_TEXT * SCH_EAGLE_PLUGIN::loadLabel ( wxXmlNode *  aLabelNode,
const wxString &  aNetName 
)
private

Definition at line 1195 of file sch_eagle_plugin.cpp.

1196 {
1197  ELABEL elabel = ELABEL( aLabelNode, aNetName );
1198  wxPoint elabelpos( elabel.x.ToSchUnits(), -elabel.y.ToSchUnits() );
1199 
1200  // Determine if the label is local or global depending on
1201  // the number of sheets the net appears in
1202  bool global = m_netCounts[aNetName] > 1;
1203  std::unique_ptr<SCH_TEXT> label;
1204 
1205  wxSize textSize = wxSize( KiROUND( elabel.size.ToSchUnits() * 0.7 ),
1206  KiROUND( elabel.size.ToSchUnits() * 0.7 ) );
1207 
1208  if( global )
1209  label = std::make_unique<SCH_GLOBALLABEL>();
1210  else
1211  label = std::make_unique<SCH_LABEL>();
1212 
1213  label->SetPosition( elabelpos );
1214  label->SetText( escapeName( elabel.netname ) );
1215  label->SetTextSize( textSize );
1216  label->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT );
1217 
1218  if( elabel.rot )
1219  {
1220  for( int i = 0; i < KiROUND( elabel.rot->degrees / 90 ) %4; ++i )
1221  label->Rotate90( false );
1222 
1223  if( elabel.rot->mirror )
1224  label->MirrorSpinStyle( false );
1225  }
1226 
1227  return label.release();
1228 }
bool mirror
Definition: eagle_parser.h:472
int ToSchUnits() const
Definition: eagle_parser.h:429
ECOORD x
Definition: eagle_parser.h:534
opt_erot rot
Definition: eagle_parser.h:538
std::map< wxString, int > m_netCounts
double degrees
Definition: eagle_parser.h:474
wxString netname
Definition: eagle_parser.h:540
Eagle label.
Definition: eagle_parser.h:532
ECOORD y
Definition: eagle_parser.h:535
wxString escapeName(const wxString &aNetName)
ECOORD size
Definition: eagle_parser.h:536
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73

References EROT::degrees, escapeName(), KiROUND(), m_netCounts, EROT::mirror, ELABEL::netname, LABEL_SPIN_STYLE::RIGHT, ELABEL::rot, ELABEL::size, ECOORD::ToSchUnits(), ELABEL::x, and ELABEL::y.

Referenced by loadSegments().

◆ loadLayerDefs()

void SCH_EAGLE_PLUGIN::loadLayerDefs ( wxXmlNode *  aLayers)
private

Layers in KiCad schematics are not actually layers, but abstract groups mainly used to decide item colors.

<layers> <layer number="90" name="Modules" color="5" fill="1" visible="yes" active="yes"> <layer number="91" name="Nets" color="2" fill="1" visible="yes" active="yes"> <layer number="92" name="Busses" color="1" fill="1" visible="yes" active="yes"> <layer number="93" name="Pins" color="2" fill="1" visible="no" active="yes"> <layer number="94" name="Symbols" color="4" fill="1" visible="yes" active="yes"> <layer number="95" name="Names" color="7" fill="1" visible="yes" active="yes"> <layer number="96" name="Values" color="7" fill="1" visible="yes" active="yes"> <layer number="97" name="Info" color="7" fill="1" visible="yes" active="yes"> <layer number="98" name="Guide" color="6" fill="1" visible="yes" active="yes"> </layers>

Definition at line 164 of file sch_eagle_plugin.cpp.

165 {
166  std::vector<ELAYER> eagleLayers;
167 
168  // Get the first layer and iterate
169  wxXmlNode* layerNode = aLayers->GetChildren();
170 
171  while( layerNode )
172  {
173  ELAYER elayer( layerNode );
174  eagleLayers.push_back( elayer );
175 
176  layerNode = layerNode->GetNext();
177  }
178 
179  // match layers based on their names
180  for( const ELAYER& elayer : eagleLayers )
181  {
199  if( elayer.name == wxT( "Nets" ) )
200  {
201  m_layerMap[elayer.number] = LAYER_WIRE;
202  }
203  else if( elayer.name == wxT( "Info" ) || elayer.name == wxT( "Guide" ) )
204  {
205  m_layerMap[elayer.number] = LAYER_NOTES;
206  }
207  else if( elayer.name == wxT( "Busses" ) )
208  {
209  m_layerMap[elayer.number] = LAYER_BUS;
210  }
211  }
212 }
std::map< int, SCH_LAYER_ID > m_layerMap

References LAYER_BUS, LAYER_NOTES, and LAYER_WIRE.

Referenced by loadDrawing().

◆ loadLibrary()

EAGLE_LIBRARY * SCH_EAGLE_PLUGIN::loadLibrary ( wxXmlNode *  aLibraryNode,
EAGLE_LIBRARY aEagleLib 
)
private

Definition at line 1513 of file sch_eagle_plugin.cpp.

1515 {
1516  NODE_MAP libraryChildren = MapChildren( aLibraryNode );
1517 
1518  // Loop through the symbols and load each of them
1519  wxXmlNode* symbolNode = getChildrenNodes( libraryChildren, wxT( "symbols" ) );
1520 
1521  while( symbolNode )
1522  {
1523  wxString symbolName = symbolNode->GetAttribute( wxT( "name" ) );
1524  aEagleLibrary->SymbolNodes[symbolName] = symbolNode;
1525  symbolNode = symbolNode->GetNext();
1526  }
1527 
1528  // Loop through the device sets and load each of them
1529  wxXmlNode* devicesetNode = getChildrenNodes( libraryChildren, wxT( "devicesets" ) );
1530 
1531  while( devicesetNode )
1532  {
1533  // Get Device set information
1534  EDEVICE_SET edeviceset = EDEVICE_SET( devicesetNode );
1535 
1536  wxString prefix;
1537 
1538  if( edeviceset.prefix )
1539  prefix = edeviceset.prefix.Get();
1540 
1541  NODE_MAP deviceSetChildren = MapChildren( devicesetNode );
1542  wxXmlNode* deviceNode = getChildrenNodes( deviceSetChildren, wxT( "devices" ) );
1543 
1544  // For each device in the device set:
1545  while( deviceNode )
1546  {
1547  // Get device information
1548  EDEVICE edevice = EDEVICE( deviceNode );
1549 
1550  // Create symbol name from deviceset and device names.
1551  wxString symbolName = edeviceset.name + edevice.name;
1552  symbolName.Replace( wxT( "*" ), wxEmptyString );
1553  wxASSERT( !symbolName.IsEmpty() );
1554  symbolName = EscapeString( symbolName, CTX_LIBID );
1555 
1556  if( edevice.package )
1557  aEagleLibrary->package[symbolName] = edevice.package.Get();
1558 
1559  // Create KiCad symbol.
1560  unique_ptr<LIB_SYMBOL> libSymbol( new LIB_SYMBOL( symbolName ) );
1561 
1562  // Process each gate in the deviceset for this device.
1563  wxXmlNode* gateNode = getChildrenNodes( deviceSetChildren, wxT( "gates" ) );
1564  int gates_count = countChildren( deviceSetChildren[wxT( "gates" )], wxT( "gate" ) );
1565  libSymbol->SetUnitCount( gates_count );
1566  libSymbol->LockUnits( true );
1567 
1568  LIB_FIELD* reference = libSymbol->GetFieldById( REFERENCE_FIELD );
1569 
1570  if( prefix.length() == 0 )
1571  {
1572  reference->SetVisible( false );
1573  }
1574  else
1575  {
1576  // If there is no footprint assigned, then prepend the reference value
1577  // with a hash character to mute netlist updater complaints
1578  reference->SetText( edevice.package ? prefix : '#' + prefix );
1579  }
1580 
1581  int gateindex = 1;
1582  bool ispower = false;
1583 
1584  while( gateNode )
1585  {
1586  checkpoint();
1587 
1588  EGATE egate = EGATE( gateNode );
1589 
1590  aEagleLibrary->GateUnit[edeviceset.name + edevice.name + egate.name] = gateindex;
1591  ispower = loadSymbol( aEagleLibrary->SymbolNodes[egate.symbol], libSymbol, &edevice,
1592  gateindex, egate.name );
1593 
1594  gateindex++;
1595  gateNode = gateNode->GetNext();
1596  } // gateNode
1597 
1598  libSymbol->SetUnitCount( gates_count );
1599 
1600  if( gates_count == 1 && ispower )
1601  libSymbol->SetPower();
1602 
1603  // assume that footprint library is identical to project name
1604  wxString packageString = m_schematic->Prj().GetProjectName() + wxT( ":" ) + aEagleLibrary->package[symbolName];
1605  libSymbol->GetFootprintField().SetText( packageString );
1606 
1607  wxString name = libSymbol->GetName();
1608  libSymbol->SetName( name );
1609  m_pi->SaveSymbol( getLibFileName().GetFullPath(), new LIB_SYMBOL( *libSymbol.get() ),
1610  m_properties.get() );
1611  aEagleLibrary->KiCadSymbols.insert( name, libSymbol.release() );
1612 
1613  deviceNode = deviceNode->GetNext();
1614  } // devicenode
1615 
1616  devicesetNode = devicesetNode->GetNext();
1617  } // devicesetNode
1618 
1619  return aEagleLibrary;
1620 }
Field Reference of part, i.e. "IC21".
wxString name
T & Get()
Return a reference to the value of the attribute assuming it is available.
Definition: eagle_parser.h:292
Field object used in symbol libraries.
Definition: lib_field.h:59
static int countChildren(wxXmlNode *aCurrentNode, const wxString &aName)
Provide an easy access to the children of an XML node via their names.
Define a library symbol object.
Definition: lib_symbol.h:96
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
wxString name
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
PI to create KiCad symbol library.
wxString symbol
Definition: eagle_parser.h:976
wxFileName getLibFileName()
Checks if there are other wires or pins at the position of the tested pin.
wxString name
Definition: eagle_parser.h:975
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
opt_wxString prefix
const char * name
Definition: DXF_plotter.cpp:56
bool loadSymbol(wxXmlNode *aSymbolNode, std::unique_ptr< LIB_SYMBOL > &aSymbol, EDEVICE *aDevice, int aGateNumber, const wxString &aGateName)
SCHEMATIC * m_schematic
Passed to Load(), the schematic object being loaded.
virtual const wxString GetProjectName() const
Return the short name of the project.
Definition: project.cpp:128
opt_wxString package
std::unique_ptr< PROPERTIES > m_properties
Library plugin properties.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:47
static wxXmlNode * getChildrenNodes(NODE_MAP &aMap, const wxString &aName)
Definition: eagle_parser.h:57

References checkpoint(), countChildren(), CTX_LIBID, EscapeString(), EAGLE_LIBRARY::GateUnit, OPTIONAL_XML_ATTRIBUTE< T >::Get(), getChildrenNodes(), getLibFileName(), PROJECT::GetProjectName(), EAGLE_LIBRARY::KiCadSymbols, loadSymbol(), m_pi, m_properties, m_schematic, MapChildren(), name, EGATE::name, EDEVICE::name, EDEVICE_SET::name, EAGLE_LIBRARY::package, EDEVICE::package, EDEVICE_SET::prefix, SCHEMATIC::Prj(), REFERENCE_FIELD, EDA_TEXT::SetText(), EDA_TEXT::SetVisible(), EGATE::symbol, and EAGLE_LIBRARY::SymbolNodes.

Referenced by loadSchematic().

◆ loadPin()

LIB_PIN * SCH_EAGLE_PLUGIN::loadPin ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
wxXmlNode *  aPin,
EPIN epin,
int  aGateNumber 
)
private

Definition at line 1918 of file sch_eagle_plugin.cpp.

1920 {
1921  std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( aSymbol.get() );
1922  pin->SetPosition( wxPoint( aEPin->x.ToSchUnits(), aEPin->y.ToSchUnits() ) );
1923  pin->SetName( aEPin->name );
1924  pin->SetUnit( aGateNumber );
1925 
1926  int roti = aEPin->rot ? aEPin->rot->degrees : 0;
1927 
1928  switch( roti )
1929  {
1930  case 0: pin->SetOrientation( 'R' ); break;
1931  case 90: pin->SetOrientation( 'U' ); break;
1932  case 180: pin->SetOrientation( 'L' ); break;
1933  case 270: pin->SetOrientation( 'D' ); break;
1934  default: wxFAIL_MSG( wxString::Format( wxT( "Unhandled orientation (%d degrees)." ), roti ) );
1935  }
1936 
1937  pin->SetLength( Mils2iu( 300 ) ); // Default pin length when not defined.
1938 
1939  if( aEPin->length )
1940  {
1941  wxString length = aEPin->length.Get();
1942 
1943  if( length == wxT( "short" ) )
1944  pin->SetLength( Mils2iu( 100 ) );
1945  else if( length == wxT( "middle" ) )
1946  pin->SetLength( Mils2iu( 200 ) );
1947  else if( length == wxT( "long" ) )
1948  pin->SetLength( Mils2iu( 300 ) );
1949  else if( length == wxT( "point" ) )
1950  pin->SetLength( Mils2iu( 0 ) );
1951  }
1952 
1953  // emulate the visibility of pin elements
1954  if( aEPin->visible )
1955  {
1956  wxString visible = aEPin->visible.Get();
1957 
1958  if( visible == wxT( "off" ) )
1959  {
1960  pin->SetNameTextSize( 0 );
1961  pin->SetNumberTextSize( 0 );
1962  }
1963  else if( visible == wxT( "pad" ) )
1964  {
1965  pin->SetNameTextSize( 0 );
1966  }
1967  else if( visible == wxT( "pin" ) )
1968  {
1969  pin->SetNumberTextSize( 0 );
1970  }
1971 
1972  /*
1973  * else if( visible == "both" )
1974  * {
1975  * }
1976  */
1977  }
1978 
1979  if( aEPin->function )
1980  {
1981  wxString function = aEPin->function.Get();
1982 
1983  if( function == wxT( "dot" ) )
1984  pin->SetShape( GRAPHIC_PINSHAPE::INVERTED );
1985  else if( function == wxT( "clk" ) )
1986  pin->SetShape( GRAPHIC_PINSHAPE::CLOCK );
1987  else if( function == wxT( "dotclk" ) )
1989  }
1990 
1991  return pin.release();
1992 }
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 CLOCK, EROT::degrees, Format(), EPIN::function, OPTIONAL_XML_ATTRIBUTE< T >::Get(), INVERTED, INVERTED_CLOCK, EPIN::length, EPIN::name, pin, EPIN::rot, ECOORD::ToSchUnits(), EPIN::visible, EPIN::x, and EPIN::y.

Referenced by loadSymbol().

◆ loadPlainText()

SCH_TEXT * SCH_EAGLE_PLUGIN::loadPlainText ( wxXmlNode *  aSchText)
private

Definition at line 2197 of file sch_eagle_plugin.cpp.

2198 {
2199  std::unique_ptr<SCH_TEXT> schtext = std::make_unique<SCH_TEXT>();
2200  ETEXT etext = ETEXT( aSchText );
2201 
2202  const wxString& thetext = aSchText->GetNodeContent();
2203 
2204  wxString adjustedText;
2205  wxStringTokenizer tokenizer( thetext, wxT( "\r\n" ) );
2206 
2207  // Strip the whitespace from both ends of each line.
2208  while( tokenizer.HasMoreTokens() )
2209  {
2210  wxString tmp = tokenizer.GetNextToken().Trim();
2211 
2212  tmp = tmp.Trim( false );
2213 
2214  if( tokenizer.HasMoreTokens() )
2215  tmp += wxT( "\n" );
2216 
2217  adjustedText += tmp;
2218  }
2219 
2220  schtext->SetText( adjustedText.IsEmpty() ? wxT( "\"" ) : escapeName( adjustedText ) );
2221  schtext->SetPosition( wxPoint( etext.x.ToSchUnits(), -etext.y.ToSchUnits() ) );
2222  loadTextAttributes( schtext.get(), etext );
2223  schtext->SetItalic( false );
2224 
2225  return schtext.release();
2226 }
int ToSchUnits() const
Definition: eagle_parser.h:429
Eagle text element.
Definition: eagle_parser.h:637
wxString escapeName(const wxString &aNetName)
ECOORD x
Definition: eagle_parser.h:640
void loadTextAttributes(EDA_TEXT *aText, const ETEXT &aAttribs) const
ECOORD y
Definition: eagle_parser.h:641

References escapeName(), loadTextAttributes(), ECOORD::ToSchUnits(), ETEXT::x, and ETEXT::y.

Referenced by loadSheet().

◆ loadSchematic()

void SCH_EAGLE_PLUGIN::loadSchematic ( wxXmlNode *  aSchematicNode)
private

Definition at line 586 of file sch_eagle_plugin.cpp.

587 {
588  // Map all children into a readable dictionary
589  NODE_MAP schematicChildren = MapChildren( aSchematicNode );
590  wxXmlNode* partNode = getChildrenNodes( schematicChildren, wxT( "parts" ) );
591  wxXmlNode* libraryNode = getChildrenNodes( schematicChildren, wxT( "libraries" ) );
592  wxXmlNode* sheetNode = getChildrenNodes( schematicChildren, wxT( "sheets" ) );
593 
594  if( !sheetNode )
595  return;
596 
597  auto count_nodes =
598  []( wxXmlNode* aNode ) -> unsigned
599  {
600  unsigned count = 0;
601 
602  while( aNode )
603  {
604  count++;
605  aNode = aNode->GetNext();
606  }
607 
608  return count;
609  };
610 
611  if( m_progressReporter )
612  {
613  m_totalCount = 0;
614  m_doneCount = 0;
615 
616  m_totalCount += count_nodes( partNode );
617 
618  while( libraryNode )
619  {
620  NODE_MAP libraryChildren = MapChildren( libraryNode );
621  wxXmlNode* devicesetNode = getChildrenNodes( libraryChildren, wxT( "devicesets" ) );
622 
623  while( devicesetNode )
624  {
625  NODE_MAP deviceSetChildren = MapChildren( devicesetNode );
626  wxXmlNode* deviceNode = getChildrenNodes( deviceSetChildren, wxT( "devices" ) );
627  wxXmlNode* gateNode = getChildrenNodes( deviceSetChildren, wxT( "gates" ) );
628 
629  m_totalCount += count_nodes( deviceNode ) * count_nodes( gateNode );
630 
631  devicesetNode = devicesetNode->GetNext();
632  }
633 
634  libraryNode = libraryNode->GetNext();
635  }
636 
637  // Rewind
638  libraryNode = getChildrenNodes( schematicChildren, wxT( "libraries" ) );
639 
640  while( sheetNode )
641  {
642  NODE_MAP sheetChildren = MapChildren( sheetNode );
643 
644  m_totalCount += count_nodes( getChildrenNodes( sheetChildren, wxT( "instances" ) ) );
645  m_totalCount += count_nodes( getChildrenNodes( sheetChildren, wxT( "busses" ) ) );
646  m_totalCount += count_nodes( getChildrenNodes( sheetChildren, wxT( "nets" ) ) );
647  m_totalCount += count_nodes( getChildrenNodes( sheetChildren, wxT( "plain" ) ) );
648 
649  sheetNode = sheetNode->GetNext();
650  }
651 
652  // Rewind
653  sheetNode = getChildrenNodes( schematicChildren, wxT( "sheets" ) );
654  }
655 
656  while( partNode )
657  {
658  checkpoint();
659 
660  std::unique_ptr<EPART> epart = std::make_unique<EPART>( partNode );
661 
662  // N.B. Eagle parts are case-insensitive in matching but we keep the display case
663  m_partlist[epart->name.Upper()] = std::move( epart );
664  partNode = partNode->GetNext();
665  }
666 
667  if( libraryNode )
668  {
669  while( libraryNode )
670  {
671  // Read the library name
672  wxString libName = libraryNode->GetAttribute( wxT( "name" ) );
673 
674  EAGLE_LIBRARY* elib = &m_eagleLibs[libName];
675  elib->name = libName;
676 
677  loadLibrary( libraryNode, &m_eagleLibs[libName] );
678 
679  libraryNode = libraryNode->GetNext();
680  }
681  m_pi->SaveLibrary( getLibFileName().GetFullPath() );
682  }
683 
684  // find all nets and count how many sheets they appear on.
685  // local labels will be used for nets found only on that sheet.
686  countNets( aSchematicNode );
687 
688  // Loop through all the sheets
689  int sheet_count = countChildren( sheetNode->GetParent(), wxT( "sheet" ) );
690 
691  // If eagle schematic has multiple sheets then create corresponding subsheets on the root sheet
692  if( sheet_count > 1 )
693  {
694  int x, y, i;
695  i = 2;
696  x = 1;
697  y = 1;
698 
699  SCH_SHEET_PATH rootsheetpath;
700  rootsheetpath.push_back( m_rootSheet );
701  m_rootSheet->AddInstance( rootsheetpath );
702  m_rootSheet->SetPageNumber( rootsheetpath, wxT( "1" ) );
703 
704  while( sheetNode )
705  {
706  wxPoint pos = wxPoint( x * Mils2iu( 1000 ), y * Mils2iu( 1000 ) );
707  std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>( m_rootSheet, pos );
708  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
709  wxString pageNo = wxString::Format( wxT( "%d" ), i );
710 
711  sheet->SetScreen( screen );
712  sheet->GetScreen()->SetFileName( sheet->GetFileName() );
713 
714  m_currentSheet = sheet.get();
715  loadSheet( sheetNode, i );
716  m_rootSheet->GetScreen()->Append( sheet.release() );
717 
718  SCH_SHEET_PATH sheetpath;
720  m_currentSheet->AddInstance( sheetpath );
721  m_currentSheet->SetPageNumber( sheetpath, pageNo );
722  m_rootSheet->AddInstance( sheetpath );
723  m_rootSheet->SetPageNumber( sheetpath, pageNo );
724 
725  sheetNode = sheetNode->GetNext();
726  x += 2;
727 
728  if( x > 10 ) // start next row
729  {
730  x = 1;
731  y += 2;
732  }
733 
734  i++;
735  }
736  }
737  else
738  {
739  while( sheetNode )
740  {
742  loadSheet( sheetNode, 0 );
743  sheetNode = sheetNode->GetNext();
744 
745  SCH_SHEET_PATH rootPath;
746  rootPath.push_back( m_rootSheet );
747  m_rootSheet->AddInstance( rootPath );
748  m_rootSheet->SetPageNumber( rootPath, wxT( "1" ) );
749  }
750  }
751 
752  // Handle the missing symbol units that need to be instantiated
753  // to create the missing implicit connections
754 
755  // Calculate the already placed items bounding box and the page size to determine
756  // placement for the new symbols
757  wxSize pageSizeIU = m_rootSheet->GetScreen()->GetPageSettings().GetSizeIU();
758  EDA_RECT sheetBbox = getSheetBbox( m_rootSheet );
759  wxPoint newCmpPosition( sheetBbox.GetLeft(), sheetBbox.GetBottom() );
760  int maxY = sheetBbox.GetY();
761 
762  SCH_SHEET_PATH sheetpath;
764 
765  for( auto& cmp : m_missingCmps )
766  {
767  const SCH_SYMBOL* origSymbol = cmp.second.cmp;
768 
769  for( auto unitEntry : cmp.second.units )
770  {
771  if( unitEntry.second == false )
772  continue; // unit has been already processed
773 
774  // Instantiate the missing symbol unit
775  int unit = unitEntry.first;
776  const wxString reference = origSymbol->GetField( REFERENCE_FIELD )->GetText();
777  std::unique_ptr<SCH_SYMBOL> symbol( (SCH_SYMBOL*) origSymbol->Duplicate() );
778 
779  symbol->SetUnitSelection( &sheetpath, unit );
780  symbol->SetUnit( unit );
781  symbol->SetOrientation( 0 );
782  symbol->AddHierarchicalReference( sheetpath.Path(), reference, unit );
783 
784  // Calculate the placement position
785  EDA_RECT cmpBbox = symbol->GetBoundingBox();
786  int posY = newCmpPosition.y + cmpBbox.GetHeight();
787  symbol->SetPosition( wxPoint( newCmpPosition.x, posY ) );
788  newCmpPosition.x += cmpBbox.GetWidth();
789  maxY = std::max( maxY, posY );
790 
791  if( newCmpPosition.x >= pageSizeIU.GetWidth() ) // reached the page boundary?
792  newCmpPosition = wxPoint( sheetBbox.GetLeft(), maxY ); // then start a new row
793 
794  // Add the global net labels to recreate the implicit connections
795  addImplicitConnections( symbol.get(), m_rootSheet->GetScreen(), false );
796  m_rootSheet->GetScreen()->Append( symbol.release() );
797  }
798  }
799 
800  m_missingCmps.clear();
801 }
Field Reference of part, i.e. "IC21".
SCH_SHEET * m_currentSheet
The current sheet of the schematic being loaded.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:705
EAGLE_LIBRARY * loadLibrary(wxXmlNode *aLibraryNode, EAGLE_LIBRARY *aEagleLib)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
int GetLeft() const
Definition: eda_rect.h:121
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
int GetWidth() const
Definition: eda_rect.h:118
static int countChildren(wxXmlNode *aCurrentNode, const wxString &aName)
Provide an easy access to the children of an XML node via their names.
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:102
std::map< wxString, EAGLE_MISSING_CMP > m_missingCmps
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:132
unsigned m_totalCount
for progress reporting
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1210
int GetBottom() const
Definition: eda_rect.h:123
void addImplicitConnections(SCH_SYMBOL *aSymbol, SCH_SCREEN *aScreen, bool aUpdateSet)
Create net labels to emulate implicit connections in Eagle.
std::map< wxString, EAGLE_LIBRARY > m_eagleLibs
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:85
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
PI to create KiCad symbol library.
wxFileName getLibFileName()
Checks if there are other wires or pins at the position of the tested pin.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
int GetHeight() const
Definition: eda_rect.h:119
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
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]')
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:729
Schematic symbol object.
Definition: sch_symbol.h:78
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
Handle the component boundary box.
Definition: eda_rect.h:42
int GetY() const
Definition: eda_rect.h:108
SCHEMATIC * m_schematic
Passed to Load(), the schematic object being loaded.
PROGRESS_REPORTER * m_progressReporter
optional; may be nullptr
void countNets(wxXmlNode *aSchematicNode)
void loadSheet(wxXmlNode *aSheetNode, int sheetcount)
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:47
static wxXmlNode * getChildrenNodes(NODE_MAP &aMap, const wxString &aName)
Definition: eagle_parser.h:57
bool AddInstance(const SCH_SHEET_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1165

References addImplicitConnections(), SCH_SHEET::AddInstance(), SCH_SCREEN::Append(), checkpoint(), countChildren(), countNets(), SCH_ITEM::Duplicate(), Format(), EDA_RECT::GetBottom(), getChildrenNodes(), SCH_SYMBOL::GetField(), EDA_RECT::GetHeight(), EDA_RECT::GetLeft(), getLibFileName(), SCH_SCREEN::GetPageSettings(), SCH_SHEET::GetScreen(), getSheetBbox(), EDA_TEXT::GetText(), EDA_RECT::GetWidth(), EDA_RECT::GetY(), loadLibrary(), loadSheet(), SCH_SHEET::LocatePathOfScreen(), m_currentSheet, m_doneCount, m_eagleLibs, m_missingCmps, m_partlist, m_pi, m_progressReporter, m_rootSheet, m_schematic, m_totalCount, MapChildren(), EAGLE_LIBRARY::name, SCH_SHEET_PATH::Path(), SCH_SHEET_PATH::push_back(), REFERENCE_FIELD, and SCH_SHEET::SetPageNumber().

Referenced by loadDrawing().

◆ loadSegments()

void SCH_EAGLE_PLUGIN::loadSegments ( wxXmlNode *  aSegmentsNode,
const wxString &  aNetName,
const wxString &  aNetClass 
)
private

Definition at line 1024 of file sch_eagle_plugin.cpp.

1026 {
1027  // Loop through all segments
1028  wxXmlNode* currentSegment = aSegmentsNode->GetChildren();
1029  SCH_SCREEN* screen = m_currentSheet->GetScreen();
1030 
1031  int segmentCount = countChildren( aSegmentsNode, wxT( "segment" ) );
1032 
1033  // wxCHECK( screen, [>void<] );
1034  while( currentSegment )
1035  {
1036  bool labelled = false; // has a label been added to this continuously connected segment
1037  NODE_MAP segmentChildren = MapChildren( currentSegment );
1038  SCH_LINE* firstWire = nullptr;
1039  m_segments.emplace_back();
1040  SEG_DESC& segDesc = m_segments.back();
1041 
1042  // Loop through all segment children
1043  wxXmlNode* segmentAttribute = currentSegment->GetChildren();
1044 
1045  while( segmentAttribute )
1046  {
1047  if( segmentAttribute->GetName() == wxT( "wire" ) )
1048  {
1049  SCH_LINE* wire = loadWire( segmentAttribute );
1050 
1051  if( !firstWire )
1052  firstWire = wire;
1053 
1054  // Test for intersections with other wires
1055  SEG thisWire( wire->GetStartPoint(), wire->GetEndPoint() );
1056 
1057  for( SEG_DESC& desc : m_segments )
1058  {
1059  if( !desc.labels.empty() && desc.labels.front()->GetText() == netName )
1060  continue; // no point in saving intersections of the same net
1061 
1062  for( const SEG& seg : desc.segs )
1063  {
1064  OPT_VECTOR2I intersection = thisWire.Intersect( seg, true );
1065 
1066  if( intersection )
1067  m_wireIntersections.push_back( *intersection );
1068  }
1069  }
1070 
1071  segDesc.segs.push_back( thisWire );
1072  screen->Append( wire );
1073  }
1074 
1075  segmentAttribute = segmentAttribute->GetNext();
1076  }
1077 
1078  segmentAttribute = currentSegment->GetChildren();
1079 
1080  while( segmentAttribute )
1081  {
1082  wxString nodeName = segmentAttribute->GetName();
1083 
1084  if( nodeName == wxT( "junction" ) )
1085  {
1086  screen->Append( loadJunction( segmentAttribute ) );
1087  }
1088  else if( nodeName == wxT( "label" ) )
1089  {
1090  SCH_TEXT* label = loadLabel( segmentAttribute, netName );
1091  screen->Append( label );
1092  wxASSERT( segDesc.labels.empty()
1093  || segDesc.labels.front()->GetText() == label->GetText() );
1094  segDesc.labels.push_back( label );
1095  labelled = true;
1096  }
1097  else if( nodeName == wxT( "pinref" ) )
1098  {
1099  segmentAttribute->GetAttribute( wxT( "gate" ) ); // REQUIRED
1100  wxString part = segmentAttribute->GetAttribute( wxT( "part" ) ); // REQUIRED
1101  wxString pin = segmentAttribute->GetAttribute( wxT( "pin" ) ); // REQUIRED
1102 
1103  auto powerPort = m_powerPorts.find( wxT( "#" ) + part );
1104 
1105  if( powerPort != m_powerPorts.end()
1106  && powerPort->second == EscapeString( pin, CTX_NETNAME ) )
1107  {
1108  labelled = true;
1109  }
1110  }
1111  else if( nodeName == wxT( "wire" ) )
1112  {
1113  // already handled;
1114  }
1115  else // DEFAULT
1116  {
1117  // THROW_IO_ERROR( wxString::Format( _( "XML node '%s' unknown" ), nodeName ) );
1118  }
1119 
1120  // Get next segment attribute
1121  segmentAttribute = segmentAttribute->GetNext();
1122  }
1123 
1124  // Add a small label to the net segment if it hasn't been labeled already or is not
1125  // connect to a power symbol with a pin on the same net. This preserves the named net
1126  // feature of Eagle schematics.
1127  if( !labelled && firstWire )
1128  {
1129  std::unique_ptr<SCH_TEXT> label;
1130 
1131  // Add a global label if the net appears on more than one Eagle sheet
1132  if( m_netCounts[netName.ToStdString()] > 1 )
1133  label.reset( new SCH_GLOBALLABEL );
1134  else if( segmentCount > 1 )
1135  label.reset( new SCH_LABEL );
1136 
1137  if( label )
1138  {
1139  label->SetPosition( firstWire->GetStartPoint() );
1140  label->SetText( escapeName( netName ) );
1141  label->SetTextSize( wxSize( Mils2iu( 40 ), Mils2iu( 40 ) ) );
1142 
1143  if( firstWire->GetEndPoint().x > firstWire->GetStartPoint().x )
1144  label->SetLabelSpinStyle( LABEL_SPIN_STYLE::LEFT );
1145  else
1146  label->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT );
1147 
1148  screen->Append( label.release() );
1149  }
1150  }
1151 
1152  currentSegment = currentSegment->GetNext();
1153  }
1154 }
SCH_SHEET * m_currentSheet
The current sheet of the schematic being loaded.
wxPoint GetStartPoint() const
Definition: sch_line.h:90
SCH_LINE * loadWire(wxXmlNode *aWireNode)
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Compute intersection point of segment (this) with segment aSeg.
Definition: seg.cpp:187
std::map< wxString, int > m_netCounts
static int countChildren(wxXmlNode *aCurrentNode, const wxString &aName)
Provide an easy access to the children of an XML node via their names.
std::vector< VECTOR2I > m_wireIntersections
Wires and labels of a single connection (segment in Eagle nomenclature)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:102
std::map< wxString, wxString > m_powerPorts
map from symbol reference to global label equivalent
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
SCH_JUNCTION * loadJunction(wxXmlNode *aJunction)
wxString escapeName(const wxString &aNetName)
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:38
SCH_TEXT * loadLabel(wxXmlNode *aLabelNode, const wxString &aNetName)
Definition: seg.h:40
std::vector< SEG_DESC > m_segments
Nets as defined in the <nets> sections of an Eagle schematic file.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
void SetPosition(const wxPoint &aPosition) override
Definition: sch_text.h:242
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:47
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References SCH_SCREEN::Append(), countChildren(), CTX_NETNAME, escapeName(), EscapeString(), SCH_LINE::GetEndPoint(), SCH_SHEET::GetScreen(), SCH_LINE::GetStartPoint(), EDA_TEXT::GetText(), SEG::Intersect(), SCH_EAGLE_PLUGIN::SEG_DESC::labels, LABEL_SPIN_STYLE::LEFT, loadJunction(), loadLabel(), loadWire(), m_currentSheet, m_netCounts, m_powerPorts, m_segments, m_wireIntersections, MapChildren(), pin, LABEL_SPIN_STYLE::RIGHT, and SCH_EAGLE_PLUGIN::SEG_DESC::segs.

Referenced by loadSheet().

◆ loadSheet()

void SCH_EAGLE_PLUGIN::loadSheet ( wxXmlNode *  aSheetNode,
int  sheetcount 
)
private

Definition at line 804 of file sch_eagle_plugin.cpp.

805 {
806  // Map all children into a readable dictionary
807  NODE_MAP sheetChildren = MapChildren( aSheetNode );
808 
809  // Get description node
810  wxXmlNode* descriptionNode = getChildrenNodes( sheetChildren, wxT( "description" ) );
811 
812  wxString des;
813  std::string filename;
814  SCH_FIELD& sheetNameField = m_currentSheet->GetFields()[SHEETNAME];
815  SCH_FIELD& filenameField = m_currentSheet->GetFields()[SHEETFILENAME];
816 
817  if( descriptionNode )
818  {
819  des = descriptionNode->GetContent();
820  des.Replace( wxT( "\n" ), wxT( "_" ), true );
821  sheetNameField.SetText( des );
822  filename = des.ToStdString();
823  }
824  else
825  {
826  filename = wxString::Format( wxT( "%s_%d" ), m_filename.GetName(), aSheetIndex );
827  sheetNameField.SetText( filename );
828  }
829 
830  ReplaceIllegalFileNameChars( &filename );
831  replace( filename.begin(), filename.end(), ' ', '_' );
832 
833  wxFileName fn( m_filename );
834  fn.SetName( filename );
835  fn.SetExt( KiCadSchematicFileExtension );
836 
837  filenameField.SetText( fn.GetFullName() );
838  m_currentSheet->GetScreen()->SetFileName( fn.GetFullPath() );
840 
841 
842  // Loop through all of the symbol instances.
843  wxXmlNode* instanceNode = getChildrenNodes( sheetChildren, wxT( "instances" ) );
844 
845  while( instanceNode )
846  {
847  checkpoint();
848 
849  loadInstance( instanceNode );
850  instanceNode = instanceNode->GetNext();
851  }
852 
853  // Loop through all buses
854  // From the DTD: "Buses receive names which determine which signals they include.
855  // A bus is a drawing object. It does not create any electrical connections.
856  // These are always created by means of the nets and their names."
857  wxXmlNode* busNode = getChildrenNodes( sheetChildren, wxT( "busses" ) );
858 
859  while( busNode )
860  {
861  checkpoint();
862 
863  // Get the bus name
864  wxString busName = translateEagleBusName( busNode->GetAttribute( wxT( "name" ) ) );
865 
866  // Load segments of this bus
867  loadSegments( busNode, busName, wxString() );
868 
869  // Get next bus
870  busNode = busNode->GetNext();
871  }
872 
873  // Loop through all nets
874  // From the DTD: "Net is an electrical connection in a schematic."
875  wxXmlNode* netNode = getChildrenNodes( sheetChildren, wxT( "nets" ) );
876 
877  while( netNode )
878  {
879  checkpoint();
880 
881  // Get the net name and class
882  wxString netName = netNode->GetAttribute( wxT( "name" ) );
883  wxString netClass = netNode->GetAttribute( wxT( "class" ) );
884 
885  // Load segments of this net
886  loadSegments( netNode, netName, netClass );
887 
888  // Get next net
889  netNode = netNode->GetNext();
890  }
891 
892  adjustNetLabels(); // needs to be called before addBusEntries()
893  addBusEntries();
894 
895  /* moduleinst is a design block definition and is an EagleCad 8 feature,
896  *
897  * // Loop through all moduleinsts
898  * wxXmlNode* moduleinstNode = getChildrenNodes( sheetChildren, wxT( "moduleinsts" ) );
899  *
900  * while( moduleinstNode )
901  * {
902  * loadModuleinst( moduleinstNode );
903  * moduleinstNode = moduleinstNode->GetNext();
904  * }
905  */
906 
907  wxXmlNode* plainNode = getChildrenNodes( sheetChildren, wxT( "plain" ) );
908 
909  while( plainNode )
910  {
911  checkpoint();
912 
913  wxString nodeName = plainNode->GetName();
914 
915  if( nodeName == wxT( "text" ) )
916  {
917  m_currentSheet->GetScreen()->Append( loadPlainText( plainNode ) );
918  }
919  else if( nodeName == wxT( "wire" ) )
920  {
921  m_currentSheet->GetScreen()->Append( loadWire( plainNode ) );
922  }
923  else if( nodeName == wxT( "frame" ) )
924  {
925  std::vector<SCH_LINE*> lines;
926 
927  loadFrame( plainNode, lines );
928 
929  for( SCH_LINE* line : lines )
930  m_currentSheet->GetScreen()->Append( line );
931  }
932 
933  plainNode = plainNode->GetNext();
934  }
935 
936  // Calculate the new sheet size.
937  EDA_RECT sheetBoundingBox = getSheetBbox( m_currentSheet );
938  wxSize targetSheetSize = sheetBoundingBox.GetSize();
939  targetSheetSize.IncBy( Mils2iu( 1500 ), Mils2iu( 1500 ) );
940 
941  // Get current Eeschema sheet size.
942  wxSize pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU();
944 
945  // Increase if necessary
946  if( pageSizeIU.x < targetSheetSize.x )
947  pageInfo.SetWidthMils( Iu2Mils( targetSheetSize.x ) );
948 
949  if( pageSizeIU.y < targetSheetSize.y )
950  pageInfo.SetHeightMils( Iu2Mils( targetSheetSize.y ) );
951 
952  // Set the new sheet size.
953  m_currentSheet->GetScreen()->SetPageSettings( pageInfo );
954 
955  pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU();
956  wxPoint sheetcentre( pageSizeIU.x / 2, pageSizeIU.y / 2 );
957  wxPoint itemsCentre = sheetBoundingBox.Centre();
958 
959  // round the translation to nearest 100mil to place it on the grid.
960  wxPoint translation = sheetcentre - itemsCentre;
961  translation.x = translation.x - translation.x % Mils2iu( 100 );
962  translation.y = translation.y - translation.y % Mils2iu( 100 );
963 
964  // Add global net labels for the named power input pins in this sheet
965  for( SCH_ITEM* item : m_currentSheet->GetScreen()->Items().OfType( SCH_SYMBOL_T ) )
966  {
967  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
968  addImplicitConnections( symbol, m_currentSheet->GetScreen(), true );
969  }
970 
971  m_connPoints.clear();
972 
973  // Translate the items.
974  std::vector<SCH_ITEM*> allItems;
975 
976  std::copy( m_currentSheet->GetScreen()->Items().begin(),
977  m_currentSheet->GetScreen()->Items().end(), std::back_inserter( allItems ) );
978 
979  for( SCH_ITEM* item : allItems )
980  {
981  item->SetPosition( item->GetPosition() + translation );
982  item->ClearFlags();
983  m_currentSheet->GetScreen()->Update( item );
984 
985  }
986 }
SCH_SHEET * m_currentSheet
The current sheet of the schematic being loaded.
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
SCH_LINE * loadWire(wxXmlNode *aWireNode)
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: sch_screen.h:133
SCH_TEXT * loadPlainText(wxXmlNode *aSchText)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:102
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:132
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:90
void addImplicitConnections(SCH_SYMBOL *aSymbol, SCH_SCREEN *aScreen, bool aUpdateSet)
Create net labels to emulate implicit connections in Eagle.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Checks aName for illegal file name characters.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
iterator end()
Returns a read/write iterator that points to one past the last element in the EE_RTREE.
Definition: sch_rtree.h:277
void loadSegments(wxXmlNode *aSegmentsNode, const wxString &aNetName, const wxString &aNetClass)
void loadFrame(wxXmlNode *aFrameNode, std::vector< SCH_LINE * > &aLines)
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:257
void addBusEntries()
This function finds best way to place a bus entry symbol for when an Eagle wire segment ends on an Ea...
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
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]')
void loadInstance(wxXmlNode *aInstanceNode)
wxString translateEagleBusName(const wxString &aEagleName) const
Translate an Eagle-style bus name into one that is KiCad-compatible.
Schematic symbol object.
Definition: sch_symbol.h:78
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
iterator begin()
Returns a read/write iterator that points to the first element in the EE_RTREE N.B.
Definition: sch_rtree.h:268
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:243
Handle the component boundary box.
Definition: eda_rect.h:42
const std::string KiCadSchematicFileExtension
wxPoint Centre() const
Definition: eda_rect.h:64
void Update(SCH_ITEM *aItem)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:266
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:110
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_sheet.cpp:579
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
Definition: eagle_parser.h:47
static wxXmlNode * getChildrenNodes(NODE_MAP &aMap, const wxString &aName)
Definition: eagle_parser.h:57
const wxSize GetSize() const
Definition: eda_rect.h:100
std::map< wxPoint, std::set< const EDA_ITEM * > > m_connPoints

References addBusEntries(), addImplicitConnections(), adjustNetLabels(), SCH_SCREEN::Append(), SCH_SHEET::AutoplaceFields(), EE_RTREE::begin(), EDA_RECT::Centre(), checkpoint(), EE_RTREE::end(), Format(), getChildrenNodes(), SCH_SHEET::GetFields(), SCH_SCREEN::GetPageSettings(), SCH_SHEET::GetScreen(), getSheetBbox(), EDA_RECT::GetSize(), SCH_SCREEN::Items(), KiCadSchematicFileExtension, loadFrame(), loadInstance(), loadPlainText(), loadSegments(), loadWire(), m_connPoints, m_currentSheet, m_filename, MapChildren(), EE_RTREE::OfType(), ReplaceIllegalFileNameChars(), SCH_SYMBOL_T, SCH_SCREEN::SetFileName(), PAGE_INFO::SetHeightMils(), SCH_SCREEN::SetPageSettings(), EDA_TEXT::SetText(), PAGE_INFO::SetWidthMils(), SHEETFILENAME, SHEETNAME, translateEagleBusName(), and SCH_SCREEN::Update().

Referenced by loadSchematic().

◆ loadSymbol()

bool SCH_EAGLE_PLUGIN::loadSymbol ( wxXmlNode *  aSymbolNode,
std::unique_ptr< LIB_SYMBOL > &  aSymbol,
EDEVICE aDevice,
int  aGateNumber,
const wxString &  aGateName 
)
private

Definition at line 1623 of file sch_eagle_plugin.cpp.

1625 {
1626  wxString symbolName = aSymbolNode->GetAttribute( wxT( "name" ) );
1627  std::vector<LIB_ITEM*> items;
1628 
1629  wxXmlNode* currentNode = aSymbolNode->GetChildren();
1630 
1631  bool foundName = false;
1632  bool foundValue = false;
1633  bool ispower = false;
1634  int pincount = 0;
1635 
1636  while( currentNode )
1637  {
1638  wxString nodeName = currentNode->GetName();
1639 
1640  if( nodeName == wxT( "circle" ) )
1641  {
1642  aSymbol->AddDrawItem( loadSymbolCircle( aSymbol, currentNode, aGateNumber ) );
1643  }
1644  else if( nodeName == wxT( "pin" ) )
1645  {
1646  EPIN ePin = EPIN( currentNode );
1647  std::unique_ptr<LIB_PIN> pin( loadPin( aSymbol, currentNode, &ePin, aGateNumber ) );
1648  pincount++;
1649 
1650  pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI );
1651 
1652  if( ePin.direction )
1653  {
1654  for( const auto& pinDir : pinDirectionsMap )
1655  {
1656  if( ePin.direction->Lower() == pinDir.first )
1657  {
1658  pin->SetType( pinDir.second );
1659 
1660  if( pinDir.first == wxT( "sup" ) ) // power supply symbol
1661  ispower = true;
1662 
1663  break;
1664  }
1665  }
1666  }
1667 
1668  if( aDevice->connects.size() != 0 )
1669  {
1670  for( const ECONNECT& connect : aDevice->connects )
1671  {
1672  if( connect.gate == aGateName && pin->GetName() == connect.pin )
1673  {
1674  wxArrayString pads = wxSplit( wxString( connect.pad ), ' ' );
1675 
1676  pin->SetUnit( aGateNumber );
1677  pin->SetName( escapeName( pin->GetName() ) );
1678 
1679  if( pads.GetCount() > 1 )
1680  {
1681  pin->SetNumberTextSize( 0 );
1682  }
1683 
1684  for( unsigned i = 0; i < pads.GetCount(); i++ )
1685  {
1686  LIB_PIN* apin = new LIB_PIN( *pin );
1687 
1688  wxString padname( pads[i] );
1689  apin->SetNumber( padname );
1690  aSymbol->AddDrawItem( apin );
1691  }
1692 
1693  break;
1694  }
1695  }
1696  }
1697  else
1698  {
1699  pin->SetUnit( aGateNumber );
1700  pin->SetNumber( wxString::Format( wxT( "%i" ), pincount ) );
1701  aSymbol->AddDrawItem( pin.release() );
1702  }
1703  }
1704  else if( nodeName == wxT( "polygon" ) )
1705  {
1706  aSymbol->AddDrawItem( loadSymbolPolyLine( aSymbol, currentNode, aGateNumber ) );
1707  }
1708  else if( nodeName == wxT( "rectangle" ) )
1709  {
1710  aSymbol->AddDrawItem( loadSymbolRectangle( aSymbol, currentNode, aGateNumber ) );
1711  }
1712  else if( nodeName == wxT( "text" ) )
1713  {
1714  std::unique_ptr<LIB_TEXT> libtext( loadSymbolText( aSymbol, currentNode,
1715  aGateNumber ) );
1716 
1717  if( libtext->GetText().Upper() == wxT( ">NAME" ) )
1718  {
1719  LIB_FIELD* field = aSymbol->GetFieldById( REFERENCE_FIELD );
1720  loadFieldAttributes( field, libtext.get() );
1721  foundName = true;
1722  }
1723  else if( libtext->GetText().Upper() == wxT( ">VALUE" ) )
1724  {
1725  LIB_FIELD* field = aSymbol->GetFieldById( VALUE_FIELD );
1726  loadFieldAttributes( field, libtext.get() );
1727  foundValue = true;
1728  }
1729  else
1730  {
1731  aSymbol->AddDrawItem( libtext.release() );
1732  }
1733  }
1734  else if( nodeName == wxT( "wire" ) )
1735  {
1736  aSymbol->AddDrawItem( loadSymbolWire( aSymbol, currentNode, aGateNumber ) );
1737  }
1738  else if( nodeName == wxT( "frame" ) )
1739  {
1740  std::vector<LIB_ITEM*> frameItems;
1741 
1742  loadFrame( currentNode, frameItems );
1743 
1744  for( LIB_ITEM* item : frameItems )
1745  {
1746  item->SetParent( aSymbol.get() );
1747  aSymbol->AddDrawItem( item );
1748  }
1749  }
1750 
1751  /*
1752  * else if( nodeName == wxT( "description" ) )
1753  * {
1754  * }
1755  * else if( nodeName == "dimension" )
1756  * {
1757  * }
1758  */
1759 
1760  currentNode = currentNode->GetNext();
1761  }
1762 
1763  if( foundName == false )
1764  aSymbol->GetFieldById( REFERENCE_FIELD )->SetVisible( false );
1765 
1766  if( foundValue == false )
1767  aSymbol->GetFieldById( VALUE_FIELD )->SetVisible( false );
1768 
1769  return pincount == 1 ? ispower : false;
1770 }
Field Reference of part, i.e. "IC21".
wxString pad
opt_wxString direction
Definition: eagle_parser.h:749
Field object used in symbol libraries.
Definition: lib_field.h:59
wxString gate
Eagle pin element.
Definition: eagle_parser.h:741
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
LIB_SHAPE * loadSymbolCircle(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aCircleNode, int aGateNumber)
void SetNumber(const wxString &aNumber)
Definition: lib_pin.h:118
wxString escapeName(const wxString &aNetName)
Field Value of part, i.e. "3.3K".
LIB_TEXT * loadSymbolText(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aLibText, int aGateNumber)
LIB_SHAPE * loadSymbolPolyLine(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aPolygonNode, int aGateNumber)
void loadFrame(wxXmlNode *aFrameNode, std::vector< SCH_LINE * > &aLines)
LIB_ITEM * loadSymbolWire(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aWireNode, int aGateNumber)
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
void loadFieldAttributes(LIB_FIELD *aField, const LIB_TEXT *aText) const
Move net labels that are detached from any wire to the nearest wire.
std::vector< ECONNECT > connects
static const std::map< wxString, ELECTRICAL_PINTYPE > pinDirectionsMap
Map of EAGLE pin type values to KiCad pin type values.
LIB_PIN * loadPin(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *, EPIN *epin, int aGateNumber)
input or output (like port for a microprocessor)
LIB_SHAPE * loadSymbolRectangle(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aRectNode, int aGateNumber)
wxString pin

References EDEVICE::connects, EPIN::direction, escapeName(), Format(), ECONNECT::gate, loadFieldAttributes(), loadFrame(), loadPin(), loadSymbolCircle(), loadSymbolPolyLine(), loadSymbolRectangle(), loadSymbolText(), loadSymbolWire(), ECONNECT::pad, pin, ECONNECT::pin, pinDirectionsMap, PT_BIDI, REFERENCE_FIELD, LIB_PIN::SetNumber(), and VALUE_FIELD.

Referenced by loadLibrary().

◆ LoadSymbol()

LIB_SYMBOL * SCH_PLUGIN::LoadSymbol ( const wxString &  aLibraryPath,
const wxString &  aPartName,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this SCH_PLUGIN knows about.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aPartNameis the name of the LIB_SYMBOL to load.
aPropertiesis an associative array that can be used to tell the loader implementation to do something special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
the part created on the heap if found caller shares it or NULL if not found.
Exceptions
IO_ERRORif the library cannot be found or read. No exception is thrown in the case where aAliasName cannot be found.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 85 of file sch_plugin.cpp.

87 {
88  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
89  not_implemented( this, __FUNCTION__ );
90  return nullptr;
91 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

Referenced by SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer().

◆ loadSymbolCircle()

LIB_SHAPE * SCH_EAGLE_PLUGIN::loadSymbolCircle ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
wxXmlNode *  aCircleNode,
int  aGateNumber 
)
private

Definition at line 1773 of file sch_eagle_plugin.cpp.

1775 {
1776  // Parse the circle properties
1777  ECIRCLE c( aCircleNode );
1778  LIB_SHAPE* circle = new LIB_SHAPE( aSymbol.get(), SHAPE_T::CIRCLE );
1779  wxPoint center( c.x.ToSchUnits(), c.y.ToSchUnits() );
1780 
1781  circle->SetPosition( center );
1782  circle->SetEnd( wxPoint( center.x + c.radius.ToSchUnits(), center.y ) );
1783  circle->SetWidth( c.width.ToSchUnits() );
1784  circle->SetUnit( aGateNumber );
1785 
1786  return circle;
1787 }
void SetEnd(const wxPoint &aEnd)
Definition: eda_shape.h:135
void SetPosition(const wxPoint &aPosition) override
Definition: lib_shape.h:88
Eagle circle.
Definition: eagle_parser.h:562
void SetWidth(int aWidth)
Definition: eda_shape.h:97
void SetUnit(int aUnit)
Definition: lib_item.h:265

References CIRCLE, ECIRCLE::radius, EDA_SHAPE::SetEnd(), LIB_SHAPE::SetPosition(), LIB_ITEM::SetUnit(), EDA_SHAPE::SetWidth(), ECOORD::ToSchUnits(), ECIRCLE::width, ECIRCLE::x, and ECIRCLE::y.

Referenced by loadSymbol().

◆ loadSymbolPolyLine()

LIB_SHAPE * SCH_EAGLE_PLUGIN::loadSymbolPolyLine ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
wxXmlNode *  aPolygonNode,
int  aGateNumber 
)
private

Definition at line 1891 of file sch_eagle_plugin.cpp.

1893 {
1894  LIB_SHAPE* poly = new LIB_SHAPE( aSymbol.get(), SHAPE_T::POLY );
1895  EPOLYGON epoly( aPolygonNode );
1896  wxXmlNode* vertex = aPolygonNode->GetChildren();
1897  wxPoint pt;
1898 
1899  while( vertex )
1900  {
1901  if( vertex->GetName() == wxT( "vertex" ) ) // skip <xmlattr> node
1902  {
1903  EVERTEX evertex( vertex );
1904  pt = wxPoint( evertex.x.ToSchUnits(), evertex.y.ToSchUnits() );
1905  poly->AddPoint( pt );
1906  }
1907 
1908  vertex = vertex->GetNext();
1909  }
1910 
1912  poly->SetUnit( aGateNumber );
1913 
1914  return poly;
1915 }
Eagle vertex.
Definition: eagle_parser.h:759
void AddPoint(const wxPoint &aPosition)
Definition: lib_shape.cpp:414
void SetUnit(int aUnit)
Definition: lib_item.h:265
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:87
Eagle polygon, without vertices which are parsed as needed.
Definition: eagle_parser.h:770

References LIB_SHAPE::AddPoint(), FILLED_SHAPE, POLY, EDA_SHAPE::SetFillMode(), LIB_ITEM::SetUnit(), ECOORD::ToSchUnits(), EVERTEX::x, and EVERTEX::y.

Referenced by loadSymbol().

◆ loadSymbolRectangle()

LIB_SHAPE * SCH_EAGLE_PLUGIN::loadSymbolRectangle ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
wxXmlNode *  aRectNode,
int  aGateNumber 
)
private

Definition at line 1790 of file sch_eagle_plugin.cpp.

1792 {
1793  ERECT rect( aRectNode );
1794  LIB_SHAPE* rectangle = new LIB_SHAPE( aSymbol.get(), SHAPE_T::RECT );
1795 
1796  rectangle->SetPosition( wxPoint( rect.x1.ToSchUnits(), rect.y1.ToSchUnits() ) );
1797  rectangle->SetEnd( wxPoint( rect.x2.ToSchUnits(), rect.y2.ToSchUnits() ) );
1798 
1799  if( rect.rot )
1800  {
1801  wxPoint pos( rectangle->GetPosition() );
1802  wxPoint end( rectangle->GetEnd() );
1803  wxPoint center( rectangle->GetCenter() );
1804 
1805  RotatePoint( &pos, center, rect.rot->degrees * 10 );
1806  RotatePoint( &end, center, rect.rot->degrees * 10 );
1807 
1808  rectangle->SetPosition( pos );
1809  rectangle->SetEnd( end );
1810  }
1811 
1812  rectangle->SetUnit( aGateNumber );
1813 
1814  // Eagle rectangles are filled by definition.
1815  rectangle->SetFillMode( FILL_T::FILLED_SHAPE );
1816 
1817  return rectangle;
1818 }
void SetEnd(const wxPoint &aEnd)
Definition: eda_shape.h:135
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
void SetPosition(const wxPoint &aPosition) override
Definition: lib_shape.h:88
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:131
wxPoint GetCenter() const
Definition: lib_shape.h:90
Eagle XML rectangle in binary.
Definition: eagle_parser.h:575
void SetUnit(int aUnit)
Definition: lib_item.h:265
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:87
wxPoint GetPosition() const override
Definition: lib_shape.h:87

References EROT::degrees, FILLED_SHAPE, LIB_SHAPE::GetCenter(), EDA_SHAPE::GetEnd(), LIB_SHAPE::GetPosition(), RECT, ERECT::rot, RotatePoint(), EDA_SHAPE::SetEnd(), EDA_SHAPE::SetFillMode(), LIB_SHAPE::SetPosition(), LIB_ITEM::SetUnit(), ECOORD::ToSchUnits(), ERECT::x1, ERECT::x2, ERECT::y1, and ERECT::y2.

Referenced by loadSymbol().

◆ loadSymbolText()

LIB_TEXT * SCH_EAGLE_PLUGIN::loadSymbolText ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
wxXmlNode *  aLibText,
int  aGateNumber 
)
private

Definition at line 1995 of file sch_eagle_plugin.cpp.

1997 {
1998  std::unique_ptr<LIB_TEXT> libtext = std::make_unique<LIB_TEXT>( aSymbol.get() );
1999  ETEXT etext( aLibText );
2000 
2001  libtext->SetUnit( aGateNumber );
2002  libtext->SetPosition( wxPoint( etext.x.ToSchUnits(), etext.y.ToSchUnits() ) );
2003 
2004  // Eagle supports multiple line text in library symbols. Legacy library symbol text cannot
2005  // contain CRs or LFs.
2006  //
2007  // @todo Split this into multiple text objects and offset the Y position so that it looks
2008  // more like the original Eagle schematic.
2009  wxString text = aLibText->GetNodeContent();
2010  std::replace( text.begin(), text.end(), '\n', '_' );
2011  std::replace( text.begin(), text.end(), '\r', '_' );
2012 
2013  libtext->SetText( text.IsEmpty() ? wxT( "~" ) : text );
2014  loadTextAttributes( libtext.get(), etext );
2015 
2016  return libtext.release();
2017 }
Eagle text element.
Definition: eagle_parser.h:637
void loadTextAttributes(EDA_TEXT *aText, const ETEXT &aAttribs) const

References loadTextAttributes(), and text.

Referenced by loadSymbol().

◆ loadSymbolWire()

LIB_ITEM * SCH_EAGLE_PLUGIN::loadSymbolWire ( std::unique_ptr< LIB_SYMBOL > &  aSymbol,
wxXmlNode *  aWireNode,
int  aGateNumber 
)
private

Definition at line 1821 of file sch_eagle_plugin.cpp.

1823 {
1824  EWIRE ewire = EWIRE( aWireNode );
1825 
1826  wxPoint begin, end;
1827 
1828  begin.x = ewire.x1.ToSchUnits();
1829  begin.y = ewire.y1.ToSchUnits();
1830  end.x = ewire.x2.ToSchUnits();
1831  end.y = ewire.y2.ToSchUnits();
1832 
1833  if( begin == end )
1834  return nullptr;
1835 
1836  // if the wire is an arc
1837  if( ewire.curve )
1838  {
1839  LIB_SHAPE* arc = new LIB_SHAPE( aSymbol.get(), SHAPE_T::ARC );
1840  wxPoint center = ConvertArcCenter( begin, end, *ewire.curve * -1 );
1841  double radius = sqrt( abs( ( ( center.x - begin.x ) * ( center.x - begin.x ) )
1842  + ( ( center.y - begin.y ) * ( center.y - begin.y ) ) ) )
1843  * 2;
1844 
1845  // this emulates the filled semicircles created by a thick arc with flat ends caps.
1846  if( ewire.width.ToSchUnits() * 2 > radius )
1847  {
1848  wxPoint centerStartVector = begin - center;
1849  wxPoint centerEndVector = end - center;
1850 
1851  centerStartVector.x = centerStartVector.x * ewire.width.ToSchUnits() * 2 / radius;
1852  centerStartVector.y = centerStartVector.y * ewire.width.ToSchUnits() * 2 / radius;
1853 
1854  centerEndVector.x = centerEndVector.x * ewire.width.ToSchUnits() * 2 / radius;
1855  centerEndVector.y = centerEndVector.y * ewire.width.ToSchUnits() * 2 / radius;
1856 
1857  begin = center + centerStartVector;
1858  end = center + centerEndVector;
1859 
1860  radius = sqrt( abs( ( ( center.x - begin.x ) * ( center.x - begin.x ) )
1861  + ( ( center.y - begin.y ) * ( center.y - begin.y ) ) ) )
1862  * 2;
1863 
1864  arc->SetWidth( 1 );
1866  }
1867  else
1868  {
1869  arc->SetWidth( ewire.width.ToSchUnits() );
1870  }
1871 
1872  arc->SetArcGeometry( begin, (wxPoint) CalcArcMid( begin, end, center ), end );
1873  arc->SetUnit( aGateNumber );
1874 
1875  return arc;
1876  }
1877  else
1878  {
1879  LIB_SHAPE* poly = new LIB_SHAPE( aSymbol.get(), SHAPE_T::POLY );
1880 
1881  poly->AddPoint( begin );
1882  poly->AddPoint( end );
1883  poly->SetUnit( aGateNumber );
1884  poly->SetWidth( ewire.width.ToSchUnits() );
1885 
1886  return poly;
1887  }
1888 }
opt_double curve
range is -359.9..359.9
Definition: eagle_parser.h:508
void AddPoint(const wxPoint &aPosition)
Definition: lib_shape.cpp:414
int ToSchUnits() const
Definition: eagle_parser.h:429
const VECTOR2I CalcArcMid(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aMinArcAngle=true)
Return the middle point of an arc, half-way between aStart and aEnd.
Definition: trigo.cpp:163
void SetArcGeometry(const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd)
Set the three controlling points for an arc.
Definition: eda_shape.cpp:504
ECOORD width
Definition: eagle_parser.h:497
ECOORD y1
Definition: eagle_parser.h:494
void SetWidth(int aWidth)
Definition: eda_shape.h:97
ECOORD y2
Definition: eagle_parser.h:496
void SetUnit(int aUnit)
Definition: lib_item.h:265
wxPoint ConvertArcCenter(const wxPoint &aStart, const wxPoint &aEnd, double aAngle)
Eagle wire.
Definition: eagle_parser.h:491
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:87
ECOORD x1
Definition: eagle_parser.h:493
ECOORD x2
Definition: eagle_parser.h:495

References LIB_SHAPE::AddPoint(), ARC, CalcArcMid(), ConvertArcCenter(), EWIRE::curve, FILLED_SHAPE, POLY, EDA_SHAPE::SetArcGeometry(), EDA_SHAPE::SetFillMode(), LIB_ITEM::SetUnit(), EDA_SHAPE::SetWidth(), ECOORD::ToSchUnits(), EWIRE::width, EWIRE::x1, EWIRE::x2, EWIRE::y1, and EWIRE::y2.

Referenced by loadSymbol().

◆ loadTextAttributes()

void SCH_EAGLE_PLUGIN::loadTextAttributes ( EDA_TEXT aText,
const ETEXT aAttribs 
) const
private

Definition at line 2229 of file sch_eagle_plugin.cpp.

2230 {
2231  aText->SetTextSize( aAttribs.ConvertSize() );
2232 
2233  if( aAttribs.ratio )
2234  {
2235  if( aAttribs.ratio.CGet() > 12 )
2236  {
2237  aText->SetBold( true );
2238  aText->SetTextThickness( GetPenSizeForBold( aText->GetTextWidth() ) );
2239  }
2240  }
2241 
2242  int align = aAttribs.align ? *aAttribs.align : ETEXT::BOTTOM_LEFT;
2243  int degrees = aAttribs.rot ? aAttribs.rot->degrees : 0;
2244  bool mirror = aAttribs.rot ? aAttribs.rot->mirror : false;
2245  bool spin = aAttribs.rot ? aAttribs.rot->spin : false;
2246 
2247  eagleToKicadAlignment( aText, align, degrees, mirror, spin, 0 );
2248 }
bool mirror
Definition: eagle_parser.h:472
int GetPenSizeForBold(int aTextSize)
Definition: gr_text.cpp:46
const T & CGet() const
Return a constant reference to the value of the attribute assuming it is available.
Definition: eagle_parser.h:303
opt_double ratio
Definition: eagle_parser.h:645
double degrees
Definition: eagle_parser.h:474
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
static void eagleToKicadAlignment(EDA_TEXT *aText, int aEagleAlignment, int aRelDegress, bool aMirror, bool aSpin, int aAbsDegress)
wxSize ConvertSize() const
Calculate text size based on font type and size.
opt_int align
Definition: eagle_parser.h:662
opt_erot rot
Definition: eagle_parser.h:646
int GetTextWidth() const
Definition: eda_text.h:262
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:180
bool spin
Definition: eagle_parser.h:473
void SetBold(bool aBold)
Definition: eda_text.h:203

References ETEXT::align, ETEXT::BOTTOM_LEFT, OPTIONAL_XML_ATTRIBUTE< T >::CGet(), ETEXT::ConvertSize(), EROT::degrees, eagleToKicadAlignment(), GetPenSizeForBold(), EDA_TEXT::GetTextWidth(), EROT::mirror, ETEXT::ratio, ETEXT::rot, EDA_TEXT::SetBold(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), and EROT::spin.

Referenced by loadPlainText(), and loadSymbolText().

◆ loadWire()

SCH_LINE * SCH_EAGLE_PLUGIN::loadWire ( wxXmlNode *  aWireNode)
private

Definition at line 1157 of file sch_eagle_plugin.cpp.

1158 {
1159  std::unique_ptr<SCH_LINE> wire = std::make_unique<SCH_LINE>();
1160 
1161  EWIRE ewire = EWIRE( aWireNode );
1162 
1163  wire->SetLayer( kiCadLayer( ewire.layer ) );
1164 
1165  wxPoint begin, end;
1166 
1167  begin.x = ewire.x1.ToSchUnits();
1168  begin.y = -ewire.y1.ToSchUnits();
1169  end.x = ewire.x2.ToSchUnits();
1170  end.y = -ewire.y2.ToSchUnits();
1171 
1172  wire->SetStartPoint( begin );
1173  wire->SetEndPoint( end );
1174 
1175  m_connPoints[begin].emplace( wire.get() );
1176  m_connPoints[end].emplace( wire.get() );
1177 
1178  return wire.release();
1179 }
int ToSchUnits() const
Definition: eagle_parser.h:429
SCH_LAYER_ID kiCadLayer(int aEagleLayer)
Return the matching layer or return LAYER_NOTES.
ECOORD y1
Definition: eagle_parser.h:494
LAYER_NUM layer
Definition: eagle_parser.h:498
ECOORD y2
Definition: eagle_parser.h:496
Eagle wire.
Definition: eagle_parser.h:491
ECOORD x1
Definition: eagle_parser.h:493
ECOORD x2
Definition: eagle_parser.h:495
std::map< wxPoint, std::set< const EDA_ITEM * > > m_connPoints

References kiCadLayer(), EWIRE::layer, m_connPoints, ECOORD::ToSchUnits(), EWIRE::x1, EWIRE::x2, EWIRE::y1, and EWIRE::y2.

Referenced by loadSegments(), and loadSheet().

◆ moveLabels()

void SCH_EAGLE_PLUGIN::moveLabels ( SCH_LINE aWire,
const wxPoint &  aNewEndPoint 
)
private

Move any labels on the wire to the new end point of the wire.

Definition at line 2357 of file sch_eagle_plugin.cpp.

2358 {
2359  for( SCH_ITEM* item : m_currentSheet->GetScreen()->Items().Overlapping( aWire->GetBoundingBox() ) )
2360  {
2361  if( item->Type() == SCH_LABEL_T || item->Type() == SCH_GLOBAL_LABEL_T )
2362  {
2363  if( TestSegmentHit( item->GetPosition(), aWire->GetStartPoint(), aWire->GetEndPoint(),
2364  0 ) )
2365  {
2366  item->SetPosition( aNewEndPoint );
2367  }
2368  }
2369  }
2370 }
SCH_SHEET * m_currentSheet
The current sheet of the schematic being loaded.
wxPoint GetStartPoint() const
Definition: sch_line.h:90
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:102
bool TestSegmentHit(const wxPoint &aRefPoint, const wxPoint &aStart, const wxPoint &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
EE_TYPE Overlapping(const EDA_RECT &aRect) const
Definition: sch_rtree.h:235
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_line.cpp:190
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References SCH_LINE::GetBoundingBox(), SCH_LINE::GetEndPoint(), SCH_SHEET::GetScreen(), SCH_LINE::GetStartPoint(), SCH_SCREEN::Items(), m_currentSheet, EE_RTREE::Overlapping(), SCH_GLOBAL_LABEL_T, SCH_LABEL_T, and TestSegmentHit().

Referenced by addBusEntries().

◆ netHasPowerDriver()

bool SCH_EAGLE_PLUGIN::netHasPowerDriver ( SCH_LINE aLine,
const wxString &  aNetName 
) const
private

◆ Save()

void SCH_PLUGIN::Save ( const wxString &  aFileName,
SCH_SHEET aSheet,
SCHEMATIC aSchematic,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about, or it can be used to write a portion of aSchematic to a special kind of export file.

Parameters
aFileNameis the name of a file to save to on disk.
aSheetis the class SCH_SHEET in memory document tree from which to extract information when writing to aFileName. The caller continues to own the SCHEMATIC, and the plugin should refrain from modifying the SCHEMATIC if possible.
aSchematicis the SCHEMATIC object used to access any schematic-wide or project information needed to save the document.
aPropertiesis an associative array that can be used to tell the saver how to save the file, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. Set the #PropSaveCurrentSheetOnly property to only save the current sheet. Otherwise, all hierarchical sheets are saved.
Exceptions
IO_ERRORif there is a problem saving or exporting.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 59 of file sch_plugin.cpp.

61 {
62  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
63  not_implemented( this, __FUNCTION__ );
64 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ SaveLibrary()

void SCH_PLUGIN::SaveLibrary ( const wxString &  aFileName,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 45 of file sch_plugin.cpp.

46 {
47  not_implemented( this, __FUNCTION__ );
48 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ SaveSymbol()

void SCH_PLUGIN::SaveSymbol ( const wxString &  aLibraryPath,
const LIB_SYMBOL aSymbol,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Write aSymbol to an existing library located at aLibraryPath.

If a LIB_SYMBOL by the same name already exists or there are any conflicting alias names, the new LIB_SYMBOL will silently overwrite any existing aliases and/or part because libraries cannot have duplicate alias names. It is the responsibility of the caller to check the library for conflicts before saving.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aSymbolis what to store in the library. The library is refreshed and the caller must update any LIB_SYMBOL pointers that may have changed.
aPropertiesis an associative array that can be used to tell the saver how to save the symbol, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem saving.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 94 of file sch_plugin.cpp.

96 {
97  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
98  not_implemented( this, __FUNCTION__ );
99 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

Referenced by SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer().

◆ SetProgressReporter()

void SCH_EAGLE_PLUGIN::SetProgressReporter ( PROGRESS_REPORTER aReporter)
inlineoverridevirtual

Set an optional progress reporter.

Reimplemented from SCH_PLUGIN.

Definition at line 90 of file sch_eagle_plugin.h.

91  {
92  m_progressReporter = aReporter;
93  }
PROGRESS_REPORTER * m_progressReporter
optional; may be nullptr

References m_progressReporter.

◆ SetReporter()

void SCH_EAGLE_PLUGIN::SetReporter ( REPORTER aReporter)
inlineoverridevirtual

Set an optional reporter for warnings/errors.

Reimplemented from SCH_PLUGIN.

Definition at line 88 of file sch_eagle_plugin.h.

88 { m_reporter = aReporter; }
REPORTER * m_reporter
Reporter for warnings/errors.

References m_reporter.

◆ SymbolLibOptions()

void SCH_PLUGIN::SymbolLibOptions ( PROPERTIES aListToAppendTo) const
virtualinherited

Append supported SCH_PLUGIN options to aListToAppenTo along with internationalized descriptions.

Options are typically appended so that a derived SCH_PLUGIN can call its base class function by the same name first, thus inheriting options declared there. (Some base class options could pertain to all Symbol*() functions in all derived SCH_PLUGINs.) Note that since aListToAppendTo is a PROPERTIES object, all options will be unique and last guy wins.

Parameters
aListToAppendToholds a tuple of
option
This eventually is what shows up into the fp-lib-table "options" field, possibly combined with others.
internationalized description
The internationalized description is displayed in DIALOG_FP_SCH_PLUGIN_OPTIONS. It may be multi-line and be quite explanatory of the option.

In the future perhaps aListToAppendTo evolves to something capable of also holding a wxValidator for the cells in said dialog: http://forums.wxwidgets.org/viewtopic.php?t=23277&p=104180. This would require a 3 column list, and introducing wx GUI knowledge to SCH_PLUGIN, which has been avoided to date.

Definition at line 133 of file sch_plugin.cpp.

134 {
135  // disable all these in another couple of months, after everyone has seen them:
136 #if 1
137  (*aListToAppendTo)["debug_level"] = UTF8( _(
138  "Enable <b>debug</b> logging for Symbol*() functions in this SCH_PLUGIN."
139  ) );
140 
141  (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
142  "Regular expression <b>symbol name</b> filter."
143  ) );
144 
145  (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
146  "Enable transaction logging. The mere presence of this option turns on the "
147  "logging, no need to set a Value."
148  ) );
149 
150  (*aListToAppendTo)["username"] = UTF8( _(
151  "User name for <b>login</b> to some special library server."
152  ) );
153 
154  (*aListToAppendTo)["password"] = UTF8( _(
155  "Password for <b>login</b> to some special library server."
156  ) );
157 #endif
158 
159 #if 1
160  // Suitable for a C++ to python SCH_PLUGIN::Footprint*() adapter, move it to the adapter
161  // if and when implemented.
162  (*aListToAppendTo)["python_symbol_plugin"] = UTF8( _(
163  "Enter the python symbol which implements the SCH_PLUGIN::Symbol*() functions."
164  ) );
165 #endif
166 }
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:70
#define _(s)

References _.

◆ translateEagleBusName()

wxString SCH_EAGLE_PLUGIN::translateEagleBusName ( const wxString &  aEagleName) const
private

Translate an Eagle-style bus name into one that is KiCad-compatible.

For vector buses such as A[7..0] this has no impact. For group buses, we translate from Eagle-style to KiCad-style.

Parameters
aEagleNameis the name of the bus from the Eagle schematic

Definition at line 3038 of file sch_eagle_plugin.cpp.

3039 {
3040  if( NET_SETTINGS::ParseBusVector( aEagleName, nullptr, nullptr ) )
3041  return aEagleName;
3042 
3043  wxString ret = wxT( "{" );
3044 
3045  wxStringTokenizer tokenizer( aEagleName, wxT( "," ) );
3046 
3047  while( tokenizer.HasMoreTokens() )
3048  {
3049  wxString member = tokenizer.GetNextToken();
3050 
3051  // In Eagle, overbar text is automatically stopped at the end of the net name, even when
3052  // that net name is part of a bus definition. In KiCad, we don't (currently) do that, so
3053  // if there is an odd number of overbar markers in this net name, we need to append one
3054  // to close it out before appending the space.
3055 
3056  if( member.Freq( '!' ) % 2 > 0 )
3057  member << wxT( "!" );
3058 
3059  ret << member << wxT( " " );
3060  }
3061 
3062  ret.Trim( true );
3063  ret << wxT( "}" );
3064 
3065  return ret;
3066 }
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.

References NET_SETTINGS::ParseBusVector().

Referenced by loadSheet().

Member Data Documentation

◆ m_connPoints

std::map<wxPoint, std::set<const EDA_ITEM*> > SCH_EAGLE_PLUGIN::m_connPoints
private

Definition at line 261 of file sch_eagle_plugin.h.

Referenced by checkConnections(), loadInstance(), loadSheet(), and loadWire().

◆ m_currentSheet

SCH_SHEET* SCH_EAGLE_PLUGIN::m_currentSheet
private

The current sheet of the schematic being loaded.

Definition at line 218 of file sch_eagle_plugin.h.

Referenced by addBusEntries(), loadInstance(), loadSchematic(), loadSegments(), loadSheet(), moveLabels(), and SCH_EAGLE_PLUGIN().

◆ m_doneCount

unsigned SCH_EAGLE_PLUGIN::m_doneCount
private

Definition at line 231 of file sch_eagle_plugin.h.

Referenced by checkpoint(), and loadSchematic().

◆ m_eagleLibs

std::map<wxString, EAGLE_LIBRARY> SCH_EAGLE_PLUGIN::m_eagleLibs
private

Definition at line 225 of file sch_eagle_plugin.h.

Referenced by loadInstance(), and loadSchematic().

◆ m_filename

wxFileName SCH_EAGLE_PLUGIN::m_filename
private

Definition at line 220 of file sch_eagle_plugin.h.

Referenced by Load(), and loadSheet().

◆ m_lastProgressCount

unsigned SCH_EAGLE_PLUGIN::m_lastProgressCount
private

Definition at line 232 of file sch_eagle_plugin.h.

Referenced by checkpoint().

◆ m_layerMap

std::map<int, SCH_LAYER_ID> SCH_EAGLE_PLUGIN::m_layerMap
private

Definition at line 236 of file sch_eagle_plugin.h.

◆ m_libName

wxString SCH_EAGLE_PLUGIN::m_libName
private

Library name to save symbols.

Definition at line 221 of file sch_eagle_plugin.h.

◆ m_missingCmps

std::map<wxString, EAGLE_MISSING_CMP> SCH_EAGLE_PLUGIN::m_missingCmps
private

Definition at line 215 of file sch_eagle_plugin.h.

Referenced by addImplicitConnections(), and loadSchematic().

◆ m_netCounts

std::map<wxString, int> SCH_EAGLE_PLUGIN::m_netCounts
private

Definition at line 235 of file sch_eagle_plugin.h.

Referenced by countNets(), loadLabel(), and loadSegments().

◆ m_nets

std::map<wxString, ENET> SCH_EAGLE_PLUGIN::m_nets
private

Positions of pins and wire endings mapped to its parent.

Definition at line 258 of file sch_eagle_plugin.h.

◆ m_partlist

EPART_MAP SCH_EAGLE_PLUGIN::m_partlist
private

Definition at line 224 of file sch_eagle_plugin.h.

Referenced by loadInstance(), and loadSchematic().

◆ m_pi

SCH_PLUGIN::SCH_PLUGIN_RELEASER SCH_EAGLE_PLUGIN::m_pi
private

PI to create KiCad symbol library.

Definition at line 227 of file sch_eagle_plugin.h.

Referenced by Load(), loadInstance(), loadLibrary(), and loadSchematic().

◆ m_powerPorts

std::map<wxString, wxString> SCH_EAGLE_PLUGIN::m_powerPorts
private

map from symbol reference to global label equivalent

Wire intersection points, used for quick checks whether placing a net label in a particular place would short two nets.

Definition at line 237 of file sch_eagle_plugin.h.

Referenced by loadInstance(), and loadSegments().

◆ m_progressReporter

PROGRESS_REPORTER* SCH_EAGLE_PLUGIN::m_progressReporter
private

optional; may be nullptr

Definition at line 230 of file sch_eagle_plugin.h.

Referenced by checkpoint(), Load(), loadSchematic(), and SetProgressReporter().

◆ m_properties

std::unique_ptr< PROPERTIES > SCH_EAGLE_PLUGIN::m_properties
private

Library plugin properties.

Definition at line 228 of file sch_eagle_plugin.h.

Referenced by Load(), loadInstance(), and loadLibrary().

◆ m_reporter

REPORTER* SCH_EAGLE_PLUGIN::m_reporter
private

Reporter for warnings/errors.

Map references to missing symbol units data

Definition at line 212 of file sch_eagle_plugin.h.

Referenced by loadInstance(), SCH_EAGLE_PLUGIN(), and SetReporter().

◆ m_rootSheet

SCH_SHEET* SCH_EAGLE_PLUGIN::m_rootSheet
private

The root sheet of the schematic being loaded.

Definition at line 217 of file sch_eagle_plugin.h.

Referenced by Load(), loadInstance(), loadSchematic(), and SCH_EAGLE_PLUGIN().

◆ m_schematic

SCHEMATIC* SCH_EAGLE_PLUGIN::m_schematic
private

Passed to Load(), the schematic object being loaded.

Definition at line 222 of file sch_eagle_plugin.h.

Referenced by Load(), loadInstance(), loadLibrary(), loadSchematic(), and SCH_EAGLE_PLUGIN().

◆ m_segments

std::vector<SEG_DESC> SCH_EAGLE_PLUGIN::m_segments
private

Nets as defined in the <nets> sections of an Eagle schematic file.

Definition at line 255 of file sch_eagle_plugin.h.

Referenced by adjustNetLabels(), and loadSegments().

◆ m_totalCount

unsigned SCH_EAGLE_PLUGIN::m_totalCount
private

for progress reporting

Definition at line 233 of file sch_eagle_plugin.h.

Referenced by checkpoint(), and loadSchematic().

◆ m_version

wxString SCH_EAGLE_PLUGIN::m_version
private

Eagle file version.

Definition at line 219 of file sch_eagle_plugin.h.

Referenced by Load().

◆ m_wireIntersections

std::vector<VECTOR2I> SCH_EAGLE_PLUGIN::m_wireIntersections
private

Wires and labels of a single connection (segment in Eagle nomenclature)

Definition at line 242 of file sch_eagle_plugin.h.

Referenced by adjustNetLabels(), and loadSegments().


The documentation for this class was generated from the following files: