Eagle import plugin: Code clean-up and formatting
This commit is contained in:
parent
25b8111341
commit
ee8012a5cc
|
@ -178,7 +178,7 @@ ECOORD Convert<ECOORD>( const wxString& aCoord )
|
|||
* @return T - the attributed parsed as the specified type.
|
||||
*/
|
||||
template<typename T>
|
||||
T parseRequiredAttribute( wxXmlNode* aNode, string aAttribute )
|
||||
T parseRequiredAttribute( wxXmlNode* aNode, const string& aAttribute )
|
||||
{
|
||||
wxString value;
|
||||
|
||||
|
@ -197,7 +197,7 @@ T parseRequiredAttribute( wxXmlNode* aNode, string aAttribute )
|
|||
* found.
|
||||
*/
|
||||
template<typename T>
|
||||
OPTIONAL_XML_ATTRIBUTE<T> parseOptionalAttribute( wxXmlNode* aNode, string aAttribute )
|
||||
OPTIONAL_XML_ATTRIBUTE<T> parseOptionalAttribute( wxXmlNode* aNode, const string& aAttribute )
|
||||
{
|
||||
return OPTIONAL_XML_ATTRIBUTE<T>( aNode->GetAttribute( aAttribute ) );
|
||||
}
|
||||
|
@ -859,7 +859,6 @@ EPART::EPART( wxXmlNode* aPart )
|
|||
device = parseRequiredAttribute<string>( aPart, "device" );
|
||||
technology = parseOptionalAttribute<string>( aPart, "technology" );
|
||||
value = parseOptionalAttribute<string>( aPart, "value" );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -658,10 +658,10 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
|
|||
PAGE_INFO pageInfo = m_currentSheet->GetScreen()->GetPageSettings();
|
||||
|
||||
// Increase if necessary
|
||||
if( pageSizeIU.x<targetSheetSize.x )
|
||||
if( pageSizeIU.x < targetSheetSize.x )
|
||||
pageInfo.SetWidthMils( targetSheetSize.x );
|
||||
|
||||
if( pageSizeIU.y<targetSheetSize.y )
|
||||
if( pageSizeIU.y < targetSheetSize.y )
|
||||
pageInfo.SetHeightMils( targetSheetSize.y );
|
||||
|
||||
// Set the new sheet size.
|
||||
|
@ -765,7 +765,7 @@ void SCH_EAGLE_PLUGIN::loadSegments( wxXmlNode* aSegmentsNode, const wxString& n
|
|||
wxString netname = escapeName( 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() );
|
||||
|
@ -847,7 +847,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 );
|
||||
|
@ -902,7 +902,7 @@ SCH_TEXT* SCH_EAGLE_PLUGIN::loadLabel( wxXmlNode* aLabelNode,
|
|||
std::unique_ptr<SCH_LABEL> label( new SCH_LABEL );
|
||||
label->SetPosition( elabelpos );
|
||||
label->SetText( netname );
|
||||
label->SetTextSize( wxSize( elabel.size * EUNIT_TO_MIL, elabel.size * EUNIT_TO_MIL ) );
|
||||
label->SetTextSize( wxSize( elabel.size.ToSchUnits(), elabel.size.ToSchUnits() ) );
|
||||
|
||||
label->SetLabelSpinStyle( 0 );
|
||||
|
||||
|
@ -998,8 +998,6 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
{
|
||||
auto einstance = EINSTANCE( aInstanceNode );
|
||||
|
||||
bool smashed = false;
|
||||
|
||||
SCH_SCREEN* screen = m_currentSheet->GetScreen();
|
||||
|
||||
// Find the part in the list for the sheet.
|
||||
|
@ -1011,8 +1009,8 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
|
||||
std::string libraryname = epart->library;
|
||||
std::string gatename = epart->deviceset + epart->device + einstance.gate;
|
||||
wxString sntemp = wxString( epart->deviceset + epart->device );
|
||||
|
||||
wxString sntemp = wxString( epart->deviceset + epart->device );
|
||||
sntemp.Replace( "*", "" );
|
||||
std::string symbolname = sntemp.ToStdString();
|
||||
|
||||
|
@ -1086,20 +1084,8 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
}
|
||||
|
||||
// Set the visibility of fields.
|
||||
if( part->GetField( REFERENCE )->IsVisible() )
|
||||
component->GetField( REFERENCE )->SetVisible( true );
|
||||
else
|
||||
component->GetField( REFERENCE )->SetVisible( false );
|
||||
|
||||
if( part->GetField( VALUE )->IsVisible() )
|
||||
component->GetField( VALUE )->SetVisible( true );
|
||||
else
|
||||
component->GetField( VALUE )->SetVisible( false );
|
||||
|
||||
if( einstance.smashed )
|
||||
{
|
||||
smashed = einstance.smashed.Get();
|
||||
}
|
||||
component->GetField( REFERENCE )->SetVisible( part->GetField( REFERENCE )->IsVisible() );
|
||||
component->GetField( VALUE )->SetVisible( part->GetField( VALUE )->IsVisible() );
|
||||
|
||||
bool valueAttributeFound = false;
|
||||
bool nameAttributeFound = false;
|
||||
|
@ -1108,7 +1094,6 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
wxXmlNode* attributeNode = aInstanceNode->GetChildren();
|
||||
|
||||
// Parse attributes for the instance
|
||||
//
|
||||
while( attributeNode )
|
||||
{
|
||||
if( attributeNode->GetName() == "attribute" )
|
||||
|
@ -1136,20 +1121,15 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
bool mirror = attr.rot ? attr.rot->mirror : false;
|
||||
|
||||
if( einstance.rot && einstance.rot->mirror )
|
||||
{
|
||||
mirror = !mirror;
|
||||
}
|
||||
|
||||
|
||||
bool spin = attr.rot ? attr.rot->spin : false;
|
||||
|
||||
if( attr.display == EATTR::Off )
|
||||
{
|
||||
field->SetVisible( false );
|
||||
}
|
||||
|
||||
int rotation = einstance.rot ? einstance.rot->degrees : 0;
|
||||
int reldegrees = ( absdegrees - rotation + 360.0);
|
||||
int reldegrees = ( absdegrees - rotation + 360.0 );
|
||||
reldegrees %= 360;
|
||||
|
||||
eagleToKicadAlignment( (EDA_TEXT*) field, align, reldegrees, mirror, spin,
|
||||
|
@ -1160,7 +1140,7 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
attributeNode = attributeNode->GetNext();
|
||||
}
|
||||
|
||||
if( smashed )
|
||||
if( einstance.smashed && einstance.smashed.Get() )
|
||||
{
|
||||
if( !valueAttributeFound )
|
||||
component->GetField( VALUE )->SetVisible( false );
|
||||
|
@ -1226,14 +1206,10 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode,
|
|||
|
||||
LIB_FIELD* reference = kpart->GetField( REFERENCE );
|
||||
|
||||
if( prefix.length() ==0 )
|
||||
{
|
||||
if( prefix.length() == 0 )
|
||||
reference->SetVisible( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
reference->SetText( prefix );
|
||||
}
|
||||
|
||||
int gateindex = 1;
|
||||
bool ispower = false;
|
||||
|
@ -1348,7 +1324,7 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode,
|
|||
{
|
||||
if( connect.gate == aGateName and pin->GetName().ToStdString() == connect.pin )
|
||||
{
|
||||
wxArrayString pads = wxSplit( wxString(connect.pad), ' ');
|
||||
wxArrayString pads = wxSplit( wxString( connect.pad ), ' ');
|
||||
|
||||
pin->SetPartNumber( aGateNumber );
|
||||
pin->SetUnit( aGateNumber );
|
||||
|
@ -1365,10 +1341,9 @@ bool SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode,
|
|||
|
||||
wxString padname( pads[i] );
|
||||
apin->SetNumber( padname );
|
||||
aPart->AddDrawItem( apin);
|
||||
aPart->AddDrawItem( apin );
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -447,9 +447,9 @@ struct ECOORD
|
|||
struct ENET
|
||||
{
|
||||
int netcode;
|
||||
std::string netname;
|
||||
string netname;
|
||||
|
||||
ENET( int aNetCode, const std::string& aNetName ) :
|
||||
ENET( int aNetCode, const string& aNetName ) :
|
||||
netcode( aNetCode ),
|
||||
netname( aNetName )
|
||||
{}
|
||||
|
@ -991,7 +991,7 @@ struct EDEVICE
|
|||
package %String; #IMPLIED
|
||||
>
|
||||
*/
|
||||
std::string name;
|
||||
string name;
|
||||
opt_string package;
|
||||
|
||||
std::vector<ECONNECT> connects;
|
||||
|
@ -1011,7 +1011,7 @@ struct EDEVICE_SET
|
|||
>
|
||||
*/
|
||||
|
||||
std::string name;
|
||||
string name;
|
||||
opt_string prefix;
|
||||
opt_bool uservalue;
|
||||
//std::vector<EDEVICE> devices;
|
||||
|
|
|
@ -1169,7 +1169,7 @@ MODULE* EAGLE_PLUGIN::makeModule( wxXmlNode* aPackage, const string& aPkgName )
|
|||
{
|
||||
std::unique_ptr<MODULE> m( new MODULE( m_board ) );
|
||||
|
||||
m->SetFPID( LIB_ID( UTF8(aPkgName) ) );
|
||||
m->SetFPID( LIB_ID( UTF8( aPkgName ) ) );
|
||||
|
||||
// Get the first package item and iterate
|
||||
wxXmlNode* packageItem = aPackage->GetChildren();
|
||||
|
@ -1233,6 +1233,7 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
// FIXME: the cap attribute is ignored because kicad can't create lines
|
||||
// with flat ends.
|
||||
EDGE_MODULE* dwg;
|
||||
|
||||
if( !w.curve )
|
||||
{
|
||||
dwg = new EDGE_MODULE( aModule, S_SEGMENT );
|
||||
|
@ -1252,10 +1253,9 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
|
||||
dwg->SetLayer( layer );
|
||||
dwg->SetWidth( width );
|
||||
|
||||
dwg->SetDrawCoord();
|
||||
aModule->GraphicalItemsList().PushBack( dwg );
|
||||
|
||||
aModule->GraphicalItemsList().PushBack( dwg );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1352,7 +1352,9 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
|
||||
if( IsCopperLayer( layer ) ) // skip copper "package.circle"s
|
||||
{
|
||||
wxLogMessage( wxString::Format( "Unsupported text on copper layer in package %s \n Moving to drawings layer.", aModule->GetFPID().GetLibItemName().c_str() ) );
|
||||
wxLogMessage( wxString::Format(
|
||||
"Unsupported text on copper layer in package %s\nMoving to drawings layer.",
|
||||
aModule->GetFPID().GetLibItemName().c_str() ) );
|
||||
layer = Dwgs_User;
|
||||
}
|
||||
|
||||
|
@ -1471,7 +1473,9 @@ void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
|
||||
if( IsCopperLayer( layer ) ) // skip copper "package.circle"s
|
||||
{
|
||||
wxLogMessage( wxString::Format( "Unsupported rectangle on copper layer in package %s \n Moving to drawings layer.", aModule->GetFPID().GetLibItemName().c_str() ) );
|
||||
wxLogMessage( wxString::Format(
|
||||
"Unsupported rectangle on copper layer in package %s\nMoving to drawings layer.",
|
||||
aModule->GetFPID().GetLibItemName().c_str() ) );
|
||||
layer = Dwgs_User;
|
||||
}
|
||||
|
||||
|
@ -1497,7 +1501,6 @@ void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
|
||||
dwg->SetStart0( start );
|
||||
dwg->SetEnd0( end );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1508,7 +1511,9 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
|
||||
if( IsCopperLayer( layer ) ) // skip copper "package.circle"s
|
||||
{
|
||||
wxLogMessage( wxString::Format( "Unsupported polygon on copper layer in package %s \n Moving to drawings layer.", aModule->GetFPID().GetLibItemName().c_str() ) );
|
||||
wxLogMessage( wxString::Format(
|
||||
"Unsupported polygon on copper layer in package %s\nMoving to drawings layer.",
|
||||
aModule->GetFPID().GetLibItemName().c_str() ) );
|
||||
layer = Dwgs_User;
|
||||
}
|
||||
|
||||
|
@ -1541,11 +1546,9 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
}
|
||||
|
||||
dwg->SetPolyPoints( pts );
|
||||
|
||||
dwg->SetStart0( *pts.begin() );
|
||||
dwg->SetEnd0( pts.back() );
|
||||
dwg->SetDrawCoord();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1556,7 +1559,9 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
|
||||
if( IsCopperLayer( layer ) ) // skip copper "package.circle"s
|
||||
{
|
||||
wxLogMessage( wxString::Format( "Unsupported circle on copper layer in package %s \n Moving to drawings layer.", aModule->GetFPID().GetLibItemName().c_str() ) );
|
||||
wxLogMessage( wxString::Format(
|
||||
"Unsupported circle on copper layer in package%s\nMoving to drawings layer.",
|
||||
aModule->GetFPID().GetLibItemName().c_str() ) );
|
||||
layer = Dwgs_User;
|
||||
}
|
||||
|
||||
|
@ -1579,12 +1584,9 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
|
||||
gr->SetLayer( layer );
|
||||
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 ) ) );
|
||||
gr->SetDrawCoord();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue