Eeschema Eagle Import: Code clean-up and formatting
This commit is contained in:
parent
630a883f80
commit
2a0a999350
|
@ -133,65 +133,38 @@ OPTIONAL_XML_ATTRIBUTE<T> parseOptionalAttribute( wxXmlNode* aNode, string aAttr
|
|||
}
|
||||
|
||||
|
||||
NODE_MAP MapChildren( wxXmlNode* currentNode )
|
||||
NODE_MAP MapChildren( wxXmlNode* aCurrentNode )
|
||||
{
|
||||
// Map node_name -> node_pointer
|
||||
NODE_MAP nodesMap;
|
||||
|
||||
// Loop through all children mapping them in nodesMap
|
||||
if( currentNode )
|
||||
currentNode = currentNode->GetChildren();
|
||||
if( aCurrentNode )
|
||||
aCurrentNode = aCurrentNode->GetChildren();
|
||||
|
||||
while( currentNode )
|
||||
while( aCurrentNode )
|
||||
{
|
||||
// Create a new pair in the map
|
||||
// key: current node name
|
||||
// value: current node pointer
|
||||
nodesMap[currentNode->GetName().ToStdString()] = currentNode;
|
||||
|
||||
// Get next child
|
||||
currentNode = currentNode->GetNext();
|
||||
}
|
||||
|
||||
return nodesMap;
|
||||
}
|
||||
|
||||
int CountChildren( wxXmlNode* aCurrentNode, const std::string& aName )
|
||||
{
|
||||
// Map node_name -> node_pointer
|
||||
int count = 0;
|
||||
|
||||
// Loop through all children counting them if they match the given name
|
||||
aCurrentNode = aCurrentNode->GetChildren();
|
||||
|
||||
while( aCurrentNode )
|
||||
{
|
||||
if( aCurrentNode->GetName().ToStdString() == aName )
|
||||
count++;
|
||||
nodesMap[aCurrentNode->GetName().ToStdString()] = aCurrentNode;
|
||||
|
||||
// Get next child
|
||||
aCurrentNode = aCurrentNode->GetNext();
|
||||
}
|
||||
|
||||
return count;
|
||||
return nodesMap;
|
||||
}
|
||||
|
||||
|
||||
string makeKey( const string& aFirst, const string& aSecond )
|
||||
{
|
||||
string key = aFirst + '\x02' + aSecond;
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
unsigned long timeStamp( wxXmlNode* aTree )
|
||||
unsigned long EagleTimeStamp( wxXmlNode* aTree )
|
||||
{
|
||||
// in this case from a unique tree memory location
|
||||
return (unsigned long)(void*) aTree;
|
||||
}
|
||||
|
||||
|
||||
time_t moduleTstamp( const string& aName, const string& aValue, int aUnit )
|
||||
time_t EagleModuleTstamp( const string& aName, const string& aValue, int aUnit )
|
||||
{
|
||||
std::size_t h1 = std::hash<string>{}( aName );
|
||||
std::size_t h2 = std::hash<string>{}( aValue );
|
||||
|
@ -201,19 +174,7 @@ time_t moduleTstamp( const string& aName, const string& aValue, int aUnit )
|
|||
}
|
||||
|
||||
|
||||
string modulePath( const string& aName, const string& aValue )
|
||||
{
|
||||
// TODO handle subsheet
|
||||
std::ostringstream s;
|
||||
|
||||
s << '/' << std::setfill( '0' ) << std::uppercase << std::hex << std::setw( 8 )
|
||||
<< moduleTstamp( aName, aValue, 0 );
|
||||
|
||||
return s.str();
|
||||
}
|
||||
|
||||
|
||||
wxPoint kicad_arc_center( const wxPoint& aStart, const wxPoint& aEnd, double aAngle )
|
||||
wxPoint ConvertArcCenter( const wxPoint& aStart, const wxPoint& aEnd, double aAngle )
|
||||
{
|
||||
// Eagle give us start and end.
|
||||
// S_ARC wants start to give the center, and end to give the start.
|
||||
|
@ -231,27 +192,28 @@ wxPoint kicad_arc_center( const wxPoint& aStart, const wxPoint& aEnd, double aAn
|
|||
return center;
|
||||
}
|
||||
|
||||
int parseAlignment( const wxString& alignment )
|
||||
|
||||
static int parseAlignment( const wxString& aAlignment )
|
||||
{
|
||||
// (bottom-left | bottom-center | bottom-right | center-left |
|
||||
// center | center-right | top-left | top-center | top-right)
|
||||
if( alignment == "center" )
|
||||
if( aAlignment == "center" )
|
||||
return ETEXT::CENTER;
|
||||
else if( alignment == "center-right" )
|
||||
else if( aAlignment == "center-right" )
|
||||
return ETEXT::CENTER_RIGHT;
|
||||
else if( alignment == "top-left" )
|
||||
else if( aAlignment == "top-left" )
|
||||
return ETEXT::TOP_LEFT;
|
||||
else if( alignment == "top-center" )
|
||||
else if( aAlignment == "top-center" )
|
||||
return ETEXT::TOP_CENTER;
|
||||
else if( alignment == "top-right" )
|
||||
else if( aAlignment == "top-right" )
|
||||
return ETEXT::TOP_RIGHT;
|
||||
else if( alignment == "bottom-left" )
|
||||
else if( aAlignment == "bottom-left" )
|
||||
return ETEXT::BOTTOM_LEFT;
|
||||
else if( alignment == "bottom-center" )
|
||||
else if( aAlignment == "bottom-center" )
|
||||
return ETEXT::BOTTOM_CENTER;
|
||||
else if( alignment == "bottom-right" )
|
||||
else if( aAlignment == "bottom-right" )
|
||||
return ETEXT::BOTTOM_RIGHT;
|
||||
else if( alignment == "center-left" )
|
||||
else if( aAlignment == "center-left" )
|
||||
return ETEXT::CENTER_LEFT;
|
||||
|
||||
return DEFAULT_ALIGNMENT;
|
||||
|
|
|
@ -48,8 +48,6 @@
|
|||
#include <eeschema_config.h>
|
||||
#include <sch_legacy_plugin.h>
|
||||
#include <sch_eagle_plugin.h>
|
||||
#include <schframe.h>
|
||||
#include <netlist.h>
|
||||
|
||||
|
||||
//#define USE_SCH_LEGACY_IO_PLUGIN
|
||||
|
@ -634,7 +632,7 @@ bool SCH_EDIT_FRAME::ImportFile( const wxString& aFileName, int aFileType )
|
|||
SCH_SHEET_LIST sheetList( g_RootSheet );
|
||||
SCH_SCREENS schematic;
|
||||
|
||||
switch( (SCH_IO_MGR::SCH_FILE_T)aFileType )
|
||||
switch( (SCH_IO_MGR::SCH_FILE_T) aFileType )
|
||||
{
|
||||
case SCH_IO_MGR::SCH_EAGLE:
|
||||
// We insist on caller sending us an absolute path, if it does not, we say it's a bug.
|
||||
|
@ -643,10 +641,8 @@ bool SCH_EDIT_FRAME::ImportFile( const wxString& aFileName, int aFileType )
|
|||
|
||||
if( !LockFile( fullFileName ) )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Schematic file '%s' is already open." ),
|
||||
GetChars( fullFileName )
|
||||
);
|
||||
wxString msg = wxString::Format( _( "Schematic file '%s' is already open." ),
|
||||
GetChars( fullFileName ) );
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -110,9 +110,9 @@ void SCH_EDIT_FRAME::sendNetlist()
|
|||
|
||||
|
||||
bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
|
||||
unsigned aNetlistOptions, REPORTER* aReporter, bool silent )
|
||||
unsigned aNetlistOptions, REPORTER* aReporter, bool aSilent )
|
||||
{
|
||||
if( !silent ) // checks for errors and invokes annotation dialog as neccessary
|
||||
if( !aSilent ) // checks for errors and invokes annotation dialog as neccessary
|
||||
{
|
||||
if( !prepareForNetlist() )
|
||||
return false;
|
||||
|
@ -135,7 +135,6 @@ bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
|
|||
}
|
||||
|
||||
|
||||
|
||||
//#define NETLIST_DEBUG
|
||||
|
||||
NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST()
|
||||
|
|
|
@ -61,6 +61,32 @@ using std::string;
|
|||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Provides an easy access to the children of an XML node via their names.
|
||||
* @param aCurrentNode is a pointer to a wxXmlNode, whose children will be mapped.
|
||||
* @param aName the name of the specific child names to be counted.
|
||||
* @return number of children with the give node name.
|
||||
*/
|
||||
static int countChildren( wxXmlNode* aCurrentNode, const std::string& aName )
|
||||
{
|
||||
// Map node_name -> node_pointer
|
||||
int count = 0;
|
||||
|
||||
// Loop through all children counting them if they match the given name
|
||||
aCurrentNode = aCurrentNode->GetChildren();
|
||||
|
||||
while( aCurrentNode )
|
||||
{
|
||||
if( aCurrentNode->GetName().ToStdString() == aName )
|
||||
count++;
|
||||
|
||||
// Get next child
|
||||
aCurrentNode = aCurrentNode->GetNext();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
void SCH_EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
|
||||
{
|
||||
|
@ -100,39 +126,31 @@ void SCH_EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
|
|||
|
||||
if( elayer.name == "Nets" )
|
||||
{
|
||||
m_LayerMap[elayer.number] = LAYER_WIRE;
|
||||
m_layerMap[elayer.number] = LAYER_WIRE;
|
||||
}
|
||||
else if( elayer.name == "Info" || elayer.name == "Guide" )
|
||||
{
|
||||
m_LayerMap[elayer.number] = LAYER_NOTES;
|
||||
m_layerMap[elayer.number] = LAYER_NOTES;
|
||||
}
|
||||
else if( elayer.name == "Busses" )
|
||||
{
|
||||
m_LayerMap[elayer.number] = LAYER_BUS;
|
||||
m_layerMap[elayer.number] = LAYER_BUS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return the matching layer or return LAYER_NOTES
|
||||
SCH_LAYER_ID SCH_EAGLE_PLUGIN::kiCadLayer( int aEagleLayer )
|
||||
{
|
||||
if( m_LayerMap.find( aEagleLayer ) == m_LayerMap.end() )
|
||||
{
|
||||
return LAYER_NOTES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_LayerMap[aEagleLayer];
|
||||
}
|
||||
auto it = m_layerMap.find( aEagleLayer );
|
||||
return it == m_layerMap.end() ? LAYER_NOTES : it->second;
|
||||
}
|
||||
|
||||
|
||||
// Return the kicad component orientation based on eagle rotation degrees.
|
||||
static COMPONENT_ORIENTATION_T kiCadComponentRotation( float eagleDegrees )
|
||||
{
|
||||
int roti = int(eagleDegrees);
|
||||
|
||||
int roti = int( eagleDegrees );
|
||||
|
||||
switch( roti )
|
||||
{
|
||||
|
@ -157,30 +175,26 @@ static COMPONENT_ORIENTATION_T kiCadComponentRotation( float eagleDegrees )
|
|||
|
||||
|
||||
// Calculate text alignment based on the given Eagle text alignment parameters.
|
||||
void eagleToKicadAlignment( EDA_TEXT* aText,
|
||||
int aEagleAlignment,
|
||||
int reldegrees,
|
||||
bool mirror,
|
||||
bool spin,
|
||||
int absdegrees )
|
||||
static void eagleToKicadAlignment( EDA_TEXT* aText, int aEagleAlignment,
|
||||
int aRelDegress, bool aMirror, bool aSpin, int aAbsDegress )
|
||||
{
|
||||
int align = aEagleAlignment;
|
||||
|
||||
if( reldegrees == 90 )
|
||||
if( aRelDegress == 90 )
|
||||
{
|
||||
aText->SetTextAngle( 900 );
|
||||
}
|
||||
else if( reldegrees == 180 )
|
||||
else if( aRelDegress == 180 )
|
||||
align = -align;
|
||||
else if( reldegrees == 270 )
|
||||
else if( aRelDegress == 270 )
|
||||
{
|
||||
aText->SetTextAngle( 900 );
|
||||
align = -align;
|
||||
}
|
||||
|
||||
if( mirror == true )
|
||||
if( aMirror == true )
|
||||
{
|
||||
if( absdegrees == 90 || absdegrees == 270 )
|
||||
if( aAbsDegress == 90 || aAbsDegress == 270 )
|
||||
{
|
||||
if( align == ETEXT::BOTTOM_RIGHT )
|
||||
align = ETEXT::TOP_RIGHT;
|
||||
|
@ -191,7 +205,7 @@ void eagleToKicadAlignment( EDA_TEXT* aText,
|
|||
else if( align == ETEXT::TOP_RIGHT )
|
||||
align = ETEXT::BOTTOM_RIGHT;
|
||||
}
|
||||
else if( absdegrees == 0 || absdegrees == 180 )
|
||||
else if( aAbsDegress == 0 || aAbsDegress == 180 )
|
||||
{
|
||||
if( align == ETEXT::BOTTOM_RIGHT )
|
||||
align = ETEXT::BOTTOM_LEFT;
|
||||
|
@ -208,7 +222,6 @@ void eagleToKicadAlignment( EDA_TEXT* aText,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
switch( align )
|
||||
{
|
||||
case ETEXT::CENTER:
|
||||
|
@ -292,12 +305,6 @@ int SCH_EAGLE_PLUGIN::GetModifyHash() const
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* void SCH_EAGLE_PLUGIN::SaveLibrary( const wxString& aFileName, const PROPERTIES* aProperties )
|
||||
* {
|
||||
* }
|
||||
*/
|
||||
|
||||
SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway,
|
||||
SCH_SHEET* aAppendToMe, const PROPERTIES* aProperties )
|
||||
{
|
||||
|
@ -416,16 +423,15 @@ void SCH_EAGLE_PLUGIN::countNets( wxXmlNode* aSchematicNode )
|
|||
{
|
||||
std::string netName = netNode->GetAttribute( "name" ).ToStdString();
|
||||
|
||||
if( m_NetCounts.count( netName ) )
|
||||
m_NetCounts[netName] = m_NetCounts[netName] + 1;
|
||||
if( m_netCounts.count( netName ) )
|
||||
m_netCounts[netName] = m_netCounts[netName] + 1;
|
||||
else
|
||||
m_NetCounts[netName] = 1;
|
||||
m_netCounts[netName] = 1;
|
||||
|
||||
// Get next net
|
||||
netNode = netNode->GetNext();
|
||||
}
|
||||
|
||||
|
||||
sheetNode = sheetNode->GetNext();
|
||||
}
|
||||
}
|
||||
|
@ -455,10 +461,10 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
|
|||
// Read the library name
|
||||
wxString libName = libraryNode->GetAttribute( "name" );
|
||||
|
||||
EAGLE_LIBRARY* elib = &m_eaglelibraries[libName.ToStdString()];
|
||||
EAGLE_LIBRARY* elib = &m_eagleLibs[libName.ToStdString()];
|
||||
elib->name = libName.ToStdString();
|
||||
|
||||
loadLibrary( libraryNode, &m_eaglelibraries[libName.ToStdString()] );
|
||||
loadLibrary( libraryNode, &m_eagleLibs[libName.ToStdString()] );
|
||||
|
||||
libraryNode = libraryNode->GetNext();
|
||||
}
|
||||
|
@ -470,7 +476,7 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode )
|
|||
// Loop through all the sheets
|
||||
wxXmlNode* sheetNode = schematicChildren["sheets"]->GetChildren();
|
||||
|
||||
int sheet_count = CountChildren( schematicChildren["sheets"], "sheet" );
|
||||
int sheet_count = countChildren( schematicChildren["sheets"], "sheet" );
|
||||
|
||||
// If eagle schematic has multiple sheets.
|
||||
|
||||
|
@ -527,7 +533,6 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
|
|||
NODE_MAP sheetChildren = MapChildren( aSheetNode );
|
||||
|
||||
// Get description node
|
||||
|
||||
wxXmlNode* descriptionNode = getChildrenNodes( sheetChildren, "description" );
|
||||
|
||||
wxString des;
|
||||
|
@ -689,7 +694,7 @@ void SCH_EAGLE_PLUGIN::loadSegments( wxXmlNode* aSegmentsNode, const wxString& n
|
|||
wxXmlNode* currentSegment = aSegmentsNode->GetChildren();
|
||||
SCH_SCREEN* screen = m_currentSheet->GetScreen();
|
||||
|
||||
int segmentCount = CountChildren( aSegmentsNode, "segment" );
|
||||
int segmentCount = countChildren( aSegmentsNode, "segment" );
|
||||
|
||||
// wxCHECK( screen, [>void<] );
|
||||
while( currentSegment )
|
||||
|
@ -759,7 +764,7 @@ void SCH_EAGLE_PLUGIN::loadSegments( wxXmlNode* aSegmentsNode, const wxString& n
|
|||
wxString netname = fixNetName( netName );
|
||||
|
||||
// Add a global label if the net appears on more than one Eagle sheet
|
||||
if( m_NetCounts[netName.ToStdString()]>1 )
|
||||
if( m_netCounts[netName.ToStdString()]>1 )
|
||||
{
|
||||
std::unique_ptr<SCH_GLOBALLABEL> glabel( new SCH_GLOBALLABEL );
|
||||
glabel->SetPosition( wire->MidPoint() );
|
||||
|
@ -841,7 +846,7 @@ SCH_TEXT* SCH_EAGLE_PLUGIN::loadLabel( wxXmlNode* aLabelNode,
|
|||
|
||||
|
||||
// Determine if the Label is a local and global label based on the number of sheets the net appears on.
|
||||
if( m_NetCounts[aNetName.ToStdString()]>1 )
|
||||
if( m_netCounts[aNetName.ToStdString()]>1 )
|
||||
{
|
||||
std::unique_ptr<SCH_GLOBALLABEL> glabel( new SCH_GLOBALLABEL );
|
||||
glabel->SetPosition( elabelpos );
|
||||
|
@ -944,13 +949,13 @@ SCH_TEXT* SCH_EAGLE_PLUGIN::loadLabel( wxXmlNode* aLabelNode,
|
|||
}
|
||||
|
||||
|
||||
wxPoint SCH_EAGLE_PLUGIN::findNearestLinePoint( const wxPoint aPoint, const DLIST<SCH_LINE>& lines )
|
||||
wxPoint SCH_EAGLE_PLUGIN::findNearestLinePoint( const wxPoint& aPoint, const DLIST<SCH_LINE>& aLines )
|
||||
{
|
||||
wxPoint nearestPoint;
|
||||
|
||||
float mindistance = std::numeric_limits<float>::max();
|
||||
float d;
|
||||
SCH_LINE* line = lines.begin();
|
||||
SCH_LINE* line = aLines.begin();
|
||||
|
||||
// Find the nearest start, middle or end of a line from the list of lines.
|
||||
while( line != NULL )
|
||||
|
@ -1011,10 +1016,10 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
sntemp.Replace( "*", "" );
|
||||
std::string symbolname = sntemp.ToStdString();
|
||||
|
||||
int unit = m_eaglelibraries[libraryname].GateUnit[gatename];
|
||||
int unit = m_eagleLibs[libraryname].GateUnit[gatename];
|
||||
|
||||
std::string package;
|
||||
EAGLE_LIBRARY* elib = &m_eaglelibraries[libraryname];
|
||||
EAGLE_LIBRARY* elib = &m_eagleLibs[libraryname];
|
||||
|
||||
auto p = elib->package.find( symbolname );
|
||||
|
||||
|
@ -1035,7 +1040,7 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
component->SetUnit( unit );
|
||||
component->SetPosition( wxPoint( einstance.x * EUNIT_TO_MIL, -einstance.y * EUNIT_TO_MIL ) );
|
||||
component->GetField( FOOTPRINT )->SetText( wxString( package ) );
|
||||
component->SetTimeStamp( moduleTstamp( einstance.part, epart->value ? *epart->value : "",
|
||||
component->SetTimeStamp( EagleModuleTstamp( einstance.part, epart->value ? *epart->value : "",
|
||||
unit ) );
|
||||
|
||||
if( einstance.rot )
|
||||
|
@ -1096,8 +1101,8 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
smashed = einstance.smashed.Get();
|
||||
}
|
||||
|
||||
bool valueAttributeFound = false;
|
||||
bool nameAttributeFound = false;
|
||||
bool valueAttributeFound = false;
|
||||
bool nameAttributeFound = false;
|
||||
|
||||
|
||||
wxXmlNode* attributeNode = aInstanceNode->GetChildren();
|
||||
|
@ -1127,16 +1132,13 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
|
||||
field->SetPosition( wxPoint( *attr.x * EUNIT_TO_MIL, *attr.y * -EUNIT_TO_MIL ) );
|
||||
int align = attr.align ? *attr.align : ETEXT::BOTTOM_LEFT;
|
||||
|
||||
int absdegrees = attr.rot ? attr.rot->degrees : 0;
|
||||
bool mirror = attr.rot ? attr.rot->mirror : false;
|
||||
|
||||
if( einstance.rot )
|
||||
if( einstance.rot->mirror )
|
||||
{
|
||||
mirror = !mirror;
|
||||
}
|
||||
|
||||
if( einstance.rot && einstance.rot->mirror )
|
||||
{
|
||||
mirror = !mirror;
|
||||
}
|
||||
|
||||
|
||||
bool spin = attr.rot ? attr.rot->spin : false;
|
||||
|
@ -1173,18 +1175,11 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* void SCH_EAGLE_PLUGIN::loadModuleinst( wxXmlNode* aModuleinstNode )
|
||||
* {
|
||||
* }
|
||||
*/
|
||||
|
||||
EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode,
|
||||
EAGLE_LIBRARY* aEagleLibrary )
|
||||
{
|
||||
NODE_MAP libraryChildren = MapChildren( aLibraryNode );
|
||||
|
||||
|
||||
// Loop through the symbols and load each of them
|
||||
wxXmlNode* symbolNode = libraryChildren["symbols"]->GetChildren();
|
||||
|
||||
|
@ -1218,24 +1213,15 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode,
|
|||
wxString symbolName = wxString( edeviceset.name + edevice.name );
|
||||
symbolName.Replace( "*", "" );
|
||||
|
||||
|
||||
std::string symbolname = symbolName.ToStdString();
|
||||
|
||||
std::string package;
|
||||
|
||||
if( edevice.package )
|
||||
{
|
||||
package = edevice.package.Get();
|
||||
aEagleLibrary->package[symbolname] = package;
|
||||
}
|
||||
|
||||
aEagleLibrary->package[symbolName.ToStdString()] = edevice.package.Get();
|
||||
|
||||
// Create KiCad symbol.
|
||||
unique_ptr<LIB_PART> kpart( new LIB_PART( symbolName ) );
|
||||
|
||||
// Process each gate in the deviceset for this device.
|
||||
wxXmlNode* gateNode = getChildrenNodes( aDeviceSetChildren, "gates" );
|
||||
int gates_count = CountChildren( aDeviceSetChildren["gates"], "gate" );
|
||||
int gates_count = countChildren( aDeviceSetChildren["gates"], "gate" );
|
||||
kpart->SetUnitCount( gates_count );
|
||||
|
||||
LIB_FIELD* reference = kpart->GetField( REFERENCE );
|
||||
|
@ -1249,18 +1235,15 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode,
|
|||
reference->SetText( prefix );
|
||||
}
|
||||
|
||||
int gateindex;
|
||||
int gateindex = 1;
|
||||
bool ispower = false;
|
||||
|
||||
gateindex = 1;
|
||||
|
||||
while( gateNode )
|
||||
{
|
||||
EGATE egate = EGATE( gateNode );
|
||||
|
||||
aEagleLibrary->GateUnit[edeviceset.name + edevice.name + egate.name] = gateindex;
|
||||
|
||||
|
||||
ispower = loadSymbol( aEagleLibrary->SymbolNodes[egate.symbol],
|
||||
kpart, &edevice, gateindex, egate.name );
|
||||
|
||||
|
@ -1514,7 +1497,7 @@ LIB_ITEM* SCH_EAGLE_PLUGIN::loadSymbolWire( std::unique_ptr<LIB_PART>& aPart,
|
|||
if( ewire.curve )
|
||||
{
|
||||
std::unique_ptr<LIB_ARC> arc( new LIB_ARC( aPart.get() ) );
|
||||
wxRealPoint center = kicad_arc_center( begin, end, *ewire.curve * -1 );
|
||||
wxRealPoint center = ConvertArcCenter( begin, end, *ewire.curve * -1 );
|
||||
|
||||
arc->SetPosition( center );
|
||||
|
||||
|
@ -1632,22 +1615,15 @@ LIB_POLYLINE* SCH_EAGLE_PLUGIN::loadSymbolPolyLine( std::unique_ptr<LIB_PART>& a
|
|||
|
||||
LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( std::unique_ptr<LIB_PART>& aPart,
|
||||
wxXmlNode* aPin,
|
||||
EPIN* epin,
|
||||
EPIN* aEPin,
|
||||
int aGateNumber )
|
||||
{
|
||||
std::unique_ptr<LIB_PIN> pin( new LIB_PIN( aPart.get() ) );
|
||||
|
||||
|
||||
pin->SetPosition( wxPoint( epin->x * EUNIT_TO_MIL, epin->y * EUNIT_TO_MIL ) );
|
||||
pin->SetName( epin->name );
|
||||
pin->SetPosition( wxPoint( aEPin->x * EUNIT_TO_MIL, aEPin->y * EUNIT_TO_MIL ) );
|
||||
pin->SetName( aEPin->name );
|
||||
pin->SetUnit( aGateNumber );
|
||||
|
||||
int roti = 0;
|
||||
|
||||
if( epin->rot )
|
||||
{
|
||||
roti = int(epin->rot->degrees);
|
||||
}
|
||||
int roti = aEPin->rot ? aEPin->rot->degrees : 0;
|
||||
|
||||
switch( roti )
|
||||
{
|
||||
|
@ -1672,9 +1648,9 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( std::unique_ptr<LIB_PART>& aPart,
|
|||
break;
|
||||
}
|
||||
|
||||
if( epin->length )
|
||||
if( aEPin->length )
|
||||
{
|
||||
wxString length = epin->length.Get();
|
||||
wxString length = aEPin->length.Get();
|
||||
|
||||
if( length =="short" )
|
||||
{
|
||||
|
@ -1695,9 +1671,9 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( std::unique_ptr<LIB_PART>& aPart,
|
|||
}
|
||||
|
||||
// emaulate the visibility of pin elements
|
||||
if( epin->visible )
|
||||
if( aEPin->visible )
|
||||
{
|
||||
wxString visible = epin->visible.Get();
|
||||
wxString visible = aEPin->visible.Get();
|
||||
|
||||
if( visible == "off" )
|
||||
{
|
||||
|
@ -1720,9 +1696,9 @@ LIB_PIN* SCH_EAGLE_PLUGIN::loadPin( std::unique_ptr<LIB_PART>& aPart,
|
|||
*/
|
||||
}
|
||||
|
||||
if( epin->function )
|
||||
if( aEPin->function )
|
||||
{
|
||||
wxString function = epin->function.Get();
|
||||
wxString function = aEPin->function.Get();
|
||||
|
||||
if( function == "dot" )
|
||||
{
|
||||
|
@ -1765,15 +1741,12 @@ LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymbolText( std::unique_ptr<LIB_PART>& aPart,
|
|||
}
|
||||
|
||||
int align = etext.align ? *etext.align : ETEXT::BOTTOM_LEFT;
|
||||
|
||||
|
||||
int degrees = etext.rot ? etext.rot->degrees : 0;
|
||||
bool mirror = etext.rot ? etext.rot->mirror : false;
|
||||
bool spin = etext.rot ? etext.rot->spin : false;
|
||||
bool mirror = etext.rot ? etext.rot->mirror : false;
|
||||
bool spin = etext.rot ? etext.rot->spin : false;
|
||||
|
||||
eagleToKicadAlignment( (EDA_TEXT*) libtext.get(), align, degrees, mirror, spin, 0 );
|
||||
|
||||
|
||||
return libtext.release();
|
||||
}
|
||||
|
||||
|
@ -1781,10 +1754,8 @@ LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymbolText( std::unique_ptr<LIB_PART>& aPart,
|
|||
SCH_TEXT* SCH_EAGLE_PLUGIN::loadPlainText( wxXmlNode* aSchText )
|
||||
{
|
||||
std::unique_ptr<SCH_TEXT> schtext( new SCH_TEXT() );
|
||||
|
||||
auto etext = ETEXT( aSchText );
|
||||
|
||||
|
||||
schtext->SetItalic( false );
|
||||
schtext->SetPosition( wxPoint( etext.x * EUNIT_TO_MIL, -etext.y * EUNIT_TO_MIL ) );
|
||||
|
||||
|
@ -1806,15 +1777,12 @@ SCH_TEXT* SCH_EAGLE_PLUGIN::loadPlainText( wxXmlNode* aSchText )
|
|||
|
||||
|
||||
int align = etext.align ? *etext.align : ETEXT::BOTTOM_LEFT;
|
||||
|
||||
|
||||
int degrees = etext.rot ? etext.rot->degrees : 0;
|
||||
bool mirror = etext.rot ? etext.rot->mirror : false;
|
||||
bool spin = etext.rot ? etext.rot->spin : false;
|
||||
bool mirror = etext.rot ? etext.rot->mirror : false;
|
||||
bool spin = etext.rot ? etext.rot->spin : false;
|
||||
|
||||
eagleToKicadAlignment( (EDA_TEXT*) schtext.get(), align, degrees, mirror, spin, 0 );
|
||||
|
||||
|
||||
return schtext.release();
|
||||
}
|
||||
|
||||
|
@ -1837,25 +1805,22 @@ bool SCH_EAGLE_PLUGIN::CheckHeader( const wxString& aFileName )
|
|||
}
|
||||
|
||||
|
||||
// Moves any labels on the wire to the new end point of the wire.
|
||||
void SCH_EAGLE_PLUGIN::moveLabels( SCH_ITEM* wire, wxPoint newendpoint )
|
||||
void SCH_EAGLE_PLUGIN::moveLabels( SCH_ITEM* aWire, const wxPoint& aNewEndPoint )
|
||||
{
|
||||
for( SCH_ITEM* item = m_currentSheet->GetScreen()->GetDrawItems(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() == SCH_LABEL_T || item->Type() == SCH_GLOBAL_LABEL_T )
|
||||
{
|
||||
if( TestSegmentHit( item->GetPosition(), ( (SCH_LINE*) wire )->GetStartPoint(),
|
||||
( (SCH_LINE*) wire )->GetEndPoint(), 0 ) )
|
||||
if( TestSegmentHit( item->GetPosition(), ( (SCH_LINE*) aWire )->GetStartPoint(),
|
||||
( (SCH_LINE*) aWire )->GetEndPoint(), 0 ) )
|
||||
{
|
||||
item->SetPosition( newendpoint );
|
||||
item->SetPosition( aNewEndPoint );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This monster of a function finds best way to place a bus entry symbol for when an Eagle wire segment
|
||||
// ends on an Eagle bus segment
|
||||
void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||
{
|
||||
// Add bus entry symbols
|
||||
|
@ -1863,7 +1828,6 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
// for each wire segment, compare each end with all busess.
|
||||
// If the wire end is found to end on a bus segment, place a bus entry symbol.
|
||||
|
||||
|
||||
for( SCH_ITEM* bus = m_currentSheet->GetScreen()->GetDrawItems(); bus; bus = bus->Next() )
|
||||
{
|
||||
// Check line type for line
|
||||
|
@ -1880,7 +1844,7 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
|
||||
SCH_ITEM* nextline;
|
||||
|
||||
for( SCH_ITEM* line = m_currentSheet->GetScreen()->GetDrawItems(); line; line = nextline )
|
||||
for( SCH_ITEM* line = m_currentSheet->GetScreen()->GetDrawItems(); line; line = nextline )
|
||||
{
|
||||
nextline = line->Next();
|
||||
|
||||
|
@ -2437,76 +2401,3 @@ wxString SCH_EAGLE_PLUGIN::fixNetName( const wxString& aNetName )
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// The below functions are not overriden and will trigger an assert if called for this plugin.
|
||||
/*
|
||||
* void SCH_EAGLE_PLUGIN::Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY* aKiway,
|
||||
* const PROPERTIES* aProperties )
|
||||
* {
|
||||
* }
|
||||
*
|
||||
*
|
||||
* size_t SCH_EAGLE_PLUGIN::GetSymbolLibCount( const wxString& aLibraryPath,
|
||||
* const PROPERTIES* aProperties )
|
||||
* {
|
||||
* return 0;
|
||||
* }
|
||||
*
|
||||
*
|
||||
* void SCH_EAGLE_PLUGIN::EnumerateSymbolLib( wxArrayString& aAliasNameList,
|
||||
* const wxString& aLibraryPath,
|
||||
* const PROPERTIES* aProperties )
|
||||
* {
|
||||
* }
|
||||
*
|
||||
*
|
||||
* LIB_ALIAS* SCH_EAGLE_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
|
||||
* const PROPERTIES* aProperties )
|
||||
* {
|
||||
* return nullptr;
|
||||
* }
|
||||
*
|
||||
*
|
||||
* void SCH_EAGLE_PLUGIN::SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol,
|
||||
* const PROPERTIES* aProperties )
|
||||
* {
|
||||
* }
|
||||
*
|
||||
*
|
||||
* void SCH_EAGLE_PLUGIN::DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName,
|
||||
* const PROPERTIES* aProperties )
|
||||
* {
|
||||
* }
|
||||
*
|
||||
*
|
||||
* void SCH_EAGLE_PLUGIN::DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
|
||||
* const PROPERTIES* aProperties )
|
||||
* {
|
||||
* }
|
||||
*
|
||||
*
|
||||
* void SCH_EAGLE_PLUGIN::CreateSymbolLib( const wxString& aLibraryPath,
|
||||
* const PROPERTIES* aProperties )
|
||||
* {
|
||||
* }
|
||||
*
|
||||
*
|
||||
* bool SCH_EAGLE_PLUGIN::DeleteSymbolLib( const wxString& aLibraryPath,
|
||||
* const PROPERTIES* aProperties )
|
||||
* {
|
||||
* return false;
|
||||
* }
|
||||
*
|
||||
*
|
||||
* bool SCH_EAGLE_PLUGIN::IsSymbolLibWritable( const wxString& aLibraryPath )
|
||||
* {
|
||||
* return false;
|
||||
* }
|
||||
*
|
||||
*
|
||||
* void SCH_EAGLE_PLUGIN::SymbolLibOptions( PROPERTIES* aListToAppendTo ) const
|
||||
* {
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -58,16 +58,6 @@ class LIB_PIN;
|
|||
class LIB_TEXT;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Class SCH_EAGLE_PLUGIN
|
||||
* is 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.
|
||||
*/
|
||||
|
||||
typedef struct EAGLE_LIBRARY
|
||||
{
|
||||
std::string name;
|
||||
|
@ -75,16 +65,20 @@ typedef struct EAGLE_LIBRARY
|
|||
std::unordered_map<std::string, wxXmlNode*> SymbolNodes;
|
||||
std::unordered_map<std::string, int> GateUnit;
|
||||
std::unordered_map<std::string, std::string> package;
|
||||
|
||||
} EAGLE_LIBRARY;
|
||||
|
||||
typedef boost::ptr_map< std::string, EPART > EPART_LIST;
|
||||
typedef boost::ptr_map<std::string, EPART> EPART_LIST;
|
||||
|
||||
|
||||
/**
|
||||
* Class SCH_EAGLE_PLUGIN
|
||||
* is 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.
|
||||
*/
|
||||
class SCH_EAGLE_PLUGIN : public SCH_PLUGIN
|
||||
{
|
||||
public:
|
||||
|
||||
SCH_EAGLE_PLUGIN();
|
||||
~SCH_EAGLE_PLUGIN();
|
||||
|
||||
|
@ -100,7 +94,7 @@ public:
|
|||
bool CheckHeader( const wxString& aFileName ) override;
|
||||
|
||||
|
||||
// unimplemented functions. Will trigger a not_implemented IO error.
|
||||
// unimplemented functions. Will trigger a not_implemented IO error.
|
||||
//void SaveLibrary( const wxString& aFileName, const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
//void Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY* aKiway,
|
||||
|
@ -134,38 +128,43 @@ public:
|
|||
|
||||
//void SymbolLibOptions( PROPERTIES* aListToAppendTo ) const override;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void loadDrawing( wxXmlNode* aDrawingNode );
|
||||
void loadLayerDefs( wxXmlNode* aLayers );
|
||||
void loadSchematic( wxXmlNode* aSchematicNode );
|
||||
void loadSheet( wxXmlNode* aSheetNode, int sheetcount );
|
||||
void loadInstance( wxXmlNode* aInstanceNode );
|
||||
//void loadModuleinst( wxXmlNode* aModuleinstNode ); // Eagle 8 feature that defines a replicatable schematic circuit and pcb layout.
|
||||
EAGLE_LIBRARY* loadLibrary( wxXmlNode* aLibraryNode, EAGLE_LIBRARY* elib);
|
||||
EAGLE_LIBRARY* loadLibrary( wxXmlNode* aLibraryNode, EAGLE_LIBRARY* aEagleLib );
|
||||
void countNets( wxXmlNode* aSchematicNode );
|
||||
void moveLabels( SCH_ITEM* wire, wxPoint newendpoint);
|
||||
|
||||
/// Moves any labels on the wire to the new end point of the wire.
|
||||
void moveLabels( SCH_ITEM* aWire, const wxPoint& aNewEndPoint );
|
||||
|
||||
/// This function finds best way to place a bus entry symbol for when an Eagle wire segment
|
||||
/// ends on an Eagle bus segment.
|
||||
void addBusEntries();
|
||||
|
||||
static wxString fixNetName( const wxString& aNetName );
|
||||
|
||||
/// Return the matching layer or return LAYER_NOTES
|
||||
SCH_LAYER_ID kiCadLayer( int aEagleLayer );
|
||||
wxPoint findNearestLinePoint(wxPoint aPoint, const DLIST< SCH_LINE >& lines);
|
||||
|
||||
wxPoint findNearestLinePoint( const wxPoint& aPoint, const DLIST<SCH_LINE>& aLines );
|
||||
|
||||
void loadSegments( wxXmlNode* aSegmentsNode, const wxString& aNetName,
|
||||
const wxString& aNetClass );
|
||||
const wxString& aNetClass );
|
||||
SCH_LINE* loadWire( wxXmlNode* aWireNode );
|
||||
SCH_TEXT* loadLabel( wxXmlNode* aLabelNode, const wxString& aNetName, const DLIST< SCH_LINE >& segmentWires);
|
||||
SCH_JUNCTION* loadJunction( wxXmlNode* aJunction );
|
||||
SCH_TEXT* loadPlainText( wxXmlNode* aSchText );
|
||||
|
||||
bool loadSymbol(wxXmlNode *aSymbolNode, std::unique_ptr< LIB_PART >& aPart, EDEVICE* aDevice, int aGateNumber, string aGateName);
|
||||
LIB_CIRCLE* loadSymbolCircle( std::unique_ptr< LIB_PART >& aPart, wxXmlNode* aCircleNode, int aGateNumber);
|
||||
LIB_RECTANGLE* loadSymbolRectangle( std::unique_ptr< LIB_PART >& aPart, wxXmlNode* aRectNode, int aGateNumber );
|
||||
LIB_POLYLINE* loadSymbolPolyLine( std::unique_ptr< LIB_PART >& aPart, wxXmlNode* aPolygonNode, int aGateNumber );
|
||||
LIB_ITEM* loadSymbolWire( std::unique_ptr< LIB_PART >& aPart, wxXmlNode* aWireNode, int aGateNumber);
|
||||
LIB_PIN* loadPin( std::unique_ptr< LIB_PART >& aPart, wxXmlNode*, EPIN* epin, int aGateNumber);
|
||||
LIB_TEXT* loadSymbolText( std::unique_ptr< LIB_PART >& aPart, wxXmlNode* aLibText, int aGateNumber);
|
||||
bool loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_PART>& aPart, EDEVICE* aDevice, int aGateNumber, string aGateName );
|
||||
LIB_CIRCLE* loadSymbolCircle( std::unique_ptr<LIB_PART>& aPart, wxXmlNode* aCircleNode, int aGateNumber );
|
||||
LIB_RECTANGLE* loadSymbolRectangle( std::unique_ptr<LIB_PART>& aPart, wxXmlNode* aRectNode, int aGateNumber );
|
||||
LIB_POLYLINE* loadSymbolPolyLine( std::unique_ptr<LIB_PART>& aPart, wxXmlNode* aPolygonNode, int aGateNumber );
|
||||
LIB_ITEM* loadSymbolWire( std::unique_ptr<LIB_PART>& aPart, wxXmlNode* aWireNode, int aGateNumber );
|
||||
LIB_PIN* loadPin( std::unique_ptr<LIB_PART>& aPart, wxXmlNode*, EPIN* epin, int aGateNumber );
|
||||
LIB_TEXT* loadSymbolText( std::unique_ptr<LIB_PART>& aPart, wxXmlNode* aLibText, int aGateNumber );
|
||||
|
||||
KIWAY* m_kiway; ///< For creating sub sheets.
|
||||
SCH_SHEET* m_rootSheet; ///< The root sheet of the schematic being loaded..
|
||||
|
@ -175,12 +174,10 @@ private:
|
|||
PART_LIB* m_partlib; ///< symbol library for imported file.
|
||||
|
||||
EPART_MAP m_partlist;
|
||||
std::map<std::string, EAGLE_LIBRARY> m_eaglelibraries;
|
||||
std::map<std::string, EAGLE_LIBRARY> m_eagleLibs;
|
||||
|
||||
std::map<std::string, int > m_NetCounts;
|
||||
std::map<int, SCH_LAYER_ID> m_LayerMap;
|
||||
|
||||
protected:
|
||||
std::map<std::string, int> m_netCounts;
|
||||
std::map<int, SCH_LAYER_ID> m_layerMap;
|
||||
};
|
||||
|
||||
#endif // _SCH_EAGLE_PLUGIN_H_
|
||||
|
|
|
@ -602,5 +602,5 @@ void SCH_LINE::SetPosition( const wxPoint& aPosition )
|
|||
|
||||
wxPoint SCH_LINE::MidPoint()
|
||||
{
|
||||
return wxPoint( (m_start.x+m_end.x)/2.0, (m_start.y+m_end.y)/2.0 );
|
||||
return wxPoint( ( m_start.x + m_end.x ) / 2, ( m_start.y + m_end.y ) / 2 );
|
||||
}
|
||||
|
|
|
@ -791,7 +791,7 @@ public:
|
|||
* @param full filepath of file to be imported.
|
||||
* @param aFileType SCH_FILE_T value for filetype
|
||||
*/
|
||||
bool ImportFile( const wxString& aFileName, int aFileType ) override ;
|
||||
bool ImportFile( const wxString& aFileName, int aFileType ) override;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ using std::string;
|
|||
class MODULE;
|
||||
struct EINSTANCE;
|
||||
struct EPART;
|
||||
struct ETEXT;
|
||||
|
||||
typedef std::unordered_map<string, wxXmlNode*> NODE_MAP;
|
||||
typedef std::map<string, MODULE*> MODULE_MAP;
|
||||
|
@ -358,35 +359,16 @@ public:
|
|||
* @return NODE_MAP - a map linking the name of each children to the children itself (via a
|
||||
* wxXmlNode*)
|
||||
*/
|
||||
NODE_MAP MapChildren( wxXmlNode* currentNode );
|
||||
|
||||
|
||||
/**
|
||||
* Function CountChildren
|
||||
* provides an easy access to the children of an XML node via their names.
|
||||
* @param aCurrentNode is a pointer to a wxXmlNode, whose children will be mapped.
|
||||
* @param aName the name of the specific child names to be counted.
|
||||
* @return number of children with the give node name.
|
||||
*/
|
||||
int CountChildren( wxXmlNode* aCurrentNode, const std::string& aName );
|
||||
|
||||
/// Assemble a two part key as a simple concatenation of aFirst and aSecond parts,
|
||||
/// using a separator.
|
||||
string makeKey( const string& aFirst, const string& aSecond );
|
||||
NODE_MAP MapChildren( wxXmlNode* aCurrentNode );
|
||||
|
||||
/// Make a unique time stamp
|
||||
unsigned long timeStamp( wxXmlNode* aTree );
|
||||
unsigned long EagleTimeStamp( wxXmlNode* aTree );
|
||||
|
||||
/// Computes module timestamp basing on its name, value and unit
|
||||
time_t moduleTstamp( const string& aName, const string& aValue, int aUnit );
|
||||
|
||||
/// Returns module path using the module timestamp
|
||||
// TODO does not handle multisheet schematics correctly
|
||||
string modulePath( const string& aName, const string& aValue );
|
||||
time_t EagleModuleTstamp( const string& aName, const string& aValue, int aUnit );
|
||||
|
||||
/// Convert an Eagle curve end to a KiCad center for S_ARC
|
||||
wxPoint kicad_arc_center( const wxPoint& aStart, const wxPoint& aEnd, double aAngle );
|
||||
|
||||
wxPoint ConvertArcCenter( const wxPoint& aStart, const wxPoint& aEnd, double aAngle );
|
||||
|
||||
// Pre-declare for typedefs
|
||||
struct EROT;
|
||||
|
@ -398,8 +380,6 @@ typedef OPTIONAL_XML_ATTRIBUTE<bool> opt_bool;
|
|||
typedef OPTIONAL_XML_ATTRIBUTE<EROT> opt_erot;
|
||||
|
||||
|
||||
|
||||
|
||||
// All of the 'E'STRUCTS below merely hold Eagle XML information verbatim, in binary.
|
||||
// For maintenance and troubleshooting purposes, it was thought that we'd need to
|
||||
// separate the conversion process into distinct steps. There is no intent to have KiCad
|
||||
|
@ -475,6 +455,7 @@ struct EWIRE
|
|||
EWIRE( wxXmlNode* aWire );
|
||||
};
|
||||
|
||||
|
||||
/// Eagle Junction
|
||||
struct EJUNCTION
|
||||
{
|
||||
|
@ -484,6 +465,7 @@ struct EJUNCTION
|
|||
EJUNCTION( wxXmlNode* aJunction);
|
||||
};
|
||||
|
||||
|
||||
/// Eagle label
|
||||
struct ELABEL
|
||||
{
|
||||
|
@ -615,7 +597,7 @@ struct ETEXT
|
|||
BOTTOM_RIGHT = -TOP_LEFT,
|
||||
};
|
||||
|
||||
opt_int align;
|
||||
opt_int align;
|
||||
|
||||
ETEXT( wxXmlNode* aText );
|
||||
};
|
||||
|
@ -668,6 +650,7 @@ struct ESMD
|
|||
ESMD( wxXmlNode* aSMD );
|
||||
};
|
||||
|
||||
|
||||
/// Eagle pin element
|
||||
struct EPIN
|
||||
{
|
||||
|
@ -685,6 +668,7 @@ struct EPIN
|
|||
EPIN( wxXmlNode* aPin );
|
||||
};
|
||||
|
||||
|
||||
/// Eagle vertex
|
||||
struct EVERTEX
|
||||
{
|
||||
|
@ -835,7 +819,6 @@ struct EAGLE_LAYER
|
|||
};
|
||||
|
||||
|
||||
|
||||
struct EPART
|
||||
{
|
||||
/*
|
||||
|
@ -885,6 +868,7 @@ struct EINSTANCE
|
|||
EINSTANCE( wxXmlNode* aInstance );
|
||||
};
|
||||
|
||||
|
||||
struct EGATE
|
||||
{
|
||||
/*
|
||||
|
@ -941,7 +925,7 @@ struct ECONNECT
|
|||
};
|
||||
|
||||
|
||||
typedef struct EDEVICE
|
||||
struct EDEVICE
|
||||
{
|
||||
/*
|
||||
<!ELEMENT device (connects?, technologies?)>
|
||||
|
@ -956,7 +940,8 @@ typedef struct EDEVICE
|
|||
std::vector<ECONNECT> connects;
|
||||
|
||||
EDEVICE( wxXmlNode* aDevice );
|
||||
} EDEVICE;
|
||||
};
|
||||
|
||||
|
||||
struct EDEVICE_SET
|
||||
{
|
||||
|
@ -980,5 +965,4 @@ struct EDEVICE_SET
|
|||
};
|
||||
|
||||
|
||||
|
||||
#endif // _EAGLE_PARSER_H_
|
||||
|
|
|
@ -196,7 +196,6 @@ public:
|
|||
* Function ReadPcbNetlist
|
||||
* provides access to PcbNew's function ReadPcbNetlist.
|
||||
*/
|
||||
|
||||
VTBL_ENTRY void ReadPcbNetlist( const wxString& aNetlistFileName,
|
||||
const wxString& aCmpFileName,
|
||||
REPORTER* aReporter,
|
||||
|
|
|
@ -196,7 +196,7 @@ public:
|
|||
void RecreateBaseHToolbar();
|
||||
|
||||
/**
|
||||
* Open dialog to import Eagle schematic and board files.
|
||||
* Open dialog to import Eagle schematic and board files.
|
||||
*/
|
||||
void OnImportEagleFiles( wxCommandEvent& event );
|
||||
|
||||
|
|
|
@ -94,6 +94,14 @@ static double parseEagle( const wxString& aDistance )
|
|||
return ret;
|
||||
}
|
||||
|
||||
/// Assemble a two part key as a simple concatenation of aFirst and aSecond parts,
|
||||
/// using a separator.
|
||||
static string makeKey( const string& aFirst, const string& aSecond )
|
||||
{
|
||||
string key = aFirst + '\x02' + aSecond;
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
void ERULES::parse( wxXmlNode* aRules )
|
||||
{
|
||||
|
@ -457,7 +465,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
|||
}
|
||||
else
|
||||
{
|
||||
wxPoint center = kicad_arc_center( start, end, *w.curve);
|
||||
wxPoint center = ConvertArcCenter( start, end, *w.curve );
|
||||
|
||||
dseg->SetShape( S_ARC );
|
||||
dseg->SetStart( center );
|
||||
|
@ -465,7 +473,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
|||
dseg->SetAngle( *w.curve * -10.0 ); // KiCad rotates the other way
|
||||
}
|
||||
|
||||
dseg->SetTimeStamp( timeStamp( gr ) );
|
||||
dseg->SetTimeStamp( EagleTimeStamp( gr ) );
|
||||
dseg->SetLayer( layer );
|
||||
dseg->SetWidth( Millimeter2iu( DEFAULT_PCB_EDGE_THICKNESS ) );
|
||||
}
|
||||
|
@ -484,7 +492,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
|||
m_board->Add( pcbtxt, ADD_APPEND );
|
||||
|
||||
pcbtxt->SetLayer( layer );
|
||||
pcbtxt->SetTimeStamp( timeStamp( gr ) );
|
||||
pcbtxt->SetTimeStamp( EagleTimeStamp( gr ) );
|
||||
pcbtxt->SetText( FROM_UTF8( t.text.c_str() ) );
|
||||
pcbtxt->SetTextPos( wxPoint( kicad_x( t.x ), kicad_y( t.y ) ) );
|
||||
|
||||
|
@ -592,7 +600,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
|||
m_board->Add( dseg, ADD_APPEND );
|
||||
|
||||
dseg->SetShape( S_CIRCLE );
|
||||
dseg->SetTimeStamp( timeStamp( gr ) );
|
||||
dseg->SetTimeStamp( EagleTimeStamp( gr ) );
|
||||
dseg->SetLayer( layer );
|
||||
dseg->SetStart( wxPoint( kicad_x( c.x ), kicad_y( c.y ) ) );
|
||||
dseg->SetEnd( wxPoint( kicad_x( c.x + c.radius ), kicad_y( c.y ) ) );
|
||||
|
@ -615,7 +623,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
|||
ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
|
||||
m_board->Add( zone, ADD_APPEND );
|
||||
|
||||
zone->SetTimeStamp( timeStamp( gr ) );
|
||||
zone->SetTimeStamp( EagleTimeStamp( gr ) );
|
||||
zone->SetLayer( layer );
|
||||
zone->SetNetCode( NETINFO_LIST::UNCONNECTED );
|
||||
|
||||
|
@ -853,9 +861,6 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
|
|||
|
||||
// copy constructor to clone the template
|
||||
MODULE* m = new MODULE( *mi->second );
|
||||
// TODO currently not handled correctly for multisheet schematics
|
||||
//m->SetTimeStamp( moduleTstamp( e.name, e.value ) );
|
||||
//m->SetPath( modulePath( e.name, e.value ) );
|
||||
m_board->Add( m, ADD_APPEND );
|
||||
|
||||
// update the nets within the pads of the clone
|
||||
|
@ -1239,7 +1244,7 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
else
|
||||
{
|
||||
dwg = new EDGE_MODULE( aModule, S_ARC );
|
||||
wxPoint center = kicad_arc_center( start, end, *w.curve);
|
||||
wxPoint center = ConvertArcCenter( start, end, *w.curve );
|
||||
|
||||
dwg->SetStart0( center );
|
||||
dwg->SetEnd0( start );
|
||||
|
@ -1365,7 +1370,7 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
aModule->GraphicalItemsList().PushBack( txt );
|
||||
}
|
||||
|
||||
txt->SetTimeStamp( timeStamp( aTree ) );
|
||||
txt->SetTimeStamp( EagleTimeStamp( aTree ) );
|
||||
txt->SetText( FROM_UTF8( t.text.c_str() ) );
|
||||
|
||||
wxPoint pos( kicad_x( t.x ), kicad_y( t.y ) );
|
||||
|
@ -1461,7 +1466,7 @@ void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
dwg->SetLayer( layer );
|
||||
dwg->SetWidth( 0 );
|
||||
|
||||
dwg->SetTimeStamp( timeStamp( aTree ) );
|
||||
dwg->SetTimeStamp( EagleTimeStamp( aTree ) );
|
||||
|
||||
std::vector<wxPoint> pts;
|
||||
|
||||
|
@ -1505,9 +1510,10 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
dwg->SetLayer( layer );
|
||||
|
||||
dwg->SetTimeStamp( timeStamp( aTree ) );
|
||||
dwg->SetTimeStamp( EagleTimeStamp( aTree ) );
|
||||
|
||||
std::vector<wxPoint> pts;
|
||||
// TODO: I think there's no way to know a priori the number of children in wxXmlNode :()
|
||||
|
@ -1558,7 +1564,7 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
}
|
||||
|
||||
gr->SetLayer( layer );
|
||||
gr->SetTimeStamp( timeStamp( aTree ) );
|
||||
gr->SetTimeStamp( EagleTimeStamp( aTree ) );
|
||||
|
||||
gr->SetStart0( wxPoint( kicad_x( e.x ), kicad_y( e.y ) ) );
|
||||
gr->SetEnd0( wxPoint( kicad_x( e.x + e.radius ), kicad_y( e.y ) ) );
|
||||
|
@ -1710,7 +1716,7 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
|
|||
{
|
||||
TRACK* t = new TRACK( m_board );
|
||||
|
||||
t->SetTimeStamp( timeStamp( netItem ) );
|
||||
t->SetTimeStamp( EagleTimeStamp( netItem ) );
|
||||
|
||||
t->SetPosition( wxPoint( kicad_x( w.x1 ), kicad_y( w.y1 ) ) );
|
||||
t->SetEnd( wxPoint( kicad_x( w.x2 ), kicad_y( w.y2 ) ) );
|
||||
|
@ -1788,7 +1794,7 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
|
|||
else
|
||||
via->SetViaType( VIA_BLIND_BURIED );
|
||||
|
||||
via->SetTimeStamp( timeStamp( netItem ) );
|
||||
via->SetTimeStamp( EagleTimeStamp( netItem ) );
|
||||
|
||||
wxPoint pos( kicad_x( v.x ), kicad_y( v.y ) );
|
||||
|
||||
|
@ -1834,7 +1840,7 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals )
|
|||
m_board->Add( zone, ADD_APPEND );
|
||||
zones.push_back( zone );
|
||||
|
||||
zone->SetTimeStamp( timeStamp( netItem ) );
|
||||
zone->SetTimeStamp( EagleTimeStamp( netItem ) );
|
||||
zone->SetLayer( layer );
|
||||
zone->SetNetCode( netCode );
|
||||
|
||||
|
|
|
@ -96,10 +96,10 @@ bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName, bo
|
|||
IO_MGR::PCB_FILE_T pluginType;
|
||||
} loaders[] =
|
||||
{
|
||||
{ PcbFileWildcard, IO_MGR::KICAD_SEXP }, // Current Kicad board files
|
||||
{ LegacyPcbFileWildcard, IO_MGR::LEGACY }, // Old Kicad board files
|
||||
{ EaglePcbFileWildcard, IO_MGR::EAGLE }, // Import board files
|
||||
{ PCadPcbFileWildcard, IO_MGR::PCAD }, // Import board files
|
||||
{ PcbFileWildcard, IO_MGR::KICAD_SEXP }, // Current Kicad board files
|
||||
{ LegacyPcbFileWildcard, IO_MGR::LEGACY }, // Old Kicad board files
|
||||
{ EaglePcbFileWildcard, IO_MGR::EAGLE }, // Import board files
|
||||
{ PCadPcbFileWildcard, IO_MGR::PCAD }, // Import board files
|
||||
};
|
||||
|
||||
wxFileName fileName( *aFileName );
|
||||
|
|
|
@ -460,6 +460,7 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary(const wxString& aLibName )
|
|||
if( aLibName.IsEmpty() )
|
||||
{
|
||||
DIALOG_SELECT_PRETTY_LIB dlg( this, initialPath );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return wxEmptyString;
|
||||
|
||||
|
|
Loading…
Reference in New Issue