Fix pcad2kicad issue, from A. Lunev, and a minor code cleaning in component_references_lister.cpp.

This commit is contained in:
Alexander Lunev 2013-06-12 21:43:22 +02:00 committed by jean-pierre charras
parent 179ada1c70
commit a3f2980d80
6 changed files with 49 additions and 55 deletions

View File

@ -72,7 +72,7 @@ const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) );
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) );
const wxString EaglePcbFileWildcard( _( "Eagle ver. 6.x XML PCB files (*.brd)|*.brd" ) );
const wxString PCadPcbFileWildcard( _( "P-Cad 2002/2004 ASCII PCB files (*.pcb)|*.pcb" ) );
const wxString PCadPcbFileWildcard( _( "P-Cad 200x ASCII PCB files (*.pcb)|*.pcb" ) );
const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.kicad_pcb)|*.kicad_pcb" ) );
const wxString KiCadFootprintLibFileWildcard( _( "KiCad footprint s-expre library file (*.kicad_mod)|*.kicad_mod" ) );
const wxString KiCadFootprintLibPathWildcard( _( "KiCad footprint s-expre library path (*.pretty)|*.pretty" ) );

View File

@ -837,27 +837,17 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
if( componentFlatList[ii].CompareValue( componentFlatList[next] ) != 0 )
{
#if defined(KICAD_GOST)
msg.Printf( _( "Different values for %s%d.%d (%s) and %s%d.%d (%s)" ),
msg.Printf( _( "Different values for %s%d%s (%s) and %s%d%s (%s)" ),
GetChars( componentFlatList[ii].GetRef() ),
componentFlatList[ii].m_NumRef,
componentFlatList[ii].m_Unit,
GetChars( LIB_COMPONENT::ReturnSubReference(
componentFlatList[ii].m_Unit ) ),
GetChars( componentFlatList[ii].m_Value->GetText() ),
GetChars( componentFlatList[next].GetRef() ),
componentFlatList[next].m_NumRef,
componentFlatList[next].m_Unit,
componentFlatList[next].m_Value->GetText().GetData() );
#else
msg.Printf( _( "Different values for %s%d%c (%s) and %s%d%c (%s)" ),
GetChars( componentFlatList[ii].GetRef() ),
componentFlatList[ii].m_NumRef,
componentFlatList[ii].m_Unit + 'A' - 1,
GetChars( componentFlatList[ii].m_Value->GetText() ),
GetChars( componentFlatList[next].GetRef() ),
componentFlatList[next].m_NumRef,
componentFlatList[next].m_Unit + 'A' - 1,
GetChars( LIB_COMPONENT::ReturnSubReference(
componentFlatList[next].m_Unit ) ),
GetChars( componentFlatList[next].m_Value->GetText() ) );
#endif
if( aMessageList )
aMessageList->Add( msg + wxT( "\n" ));

View File

@ -106,15 +106,19 @@ public:
wxString GetAttribute( const wxString& attrName, const wxString& defaultVal ) const
{
return GetPropVal(attrName, defaultVal);
return GetPropVal( attrName, defaultVal );
}
bool GetAttribute( const wxString& attrName, wxString *value ) const
{
return GetPropVal(attrName, value);
return GetPropVal( attrName, value );
}
void AddAttribute( const wxString& attrName, const wxString& value )
{
AddProperty(attrName, value);
AddProperty( attrName, value );
}
bool DeleteAttribute( const wxString& attrName )
{
DeleteProperty( attrName );
}
wxXmlProperty* GetAttributes() const
{

View File

@ -131,7 +131,8 @@ double StrToDoublePrecisionUnits( wxString aStr, char aAxe, wxString aActualConv
{
ls.ToDouble( &i );
#ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID
if( aActualConversion == wxT( "SCH" ) )
if( aActualConversion == wxT( "SCH" )
|| aActualConversion == wxT( "SCHLIB" ) )
i = i * (0.0254 / 0.025);
#endif
i = Millimeter2iu( i );

View File

@ -76,10 +76,7 @@ void PCB_TEXT::Parse( XNODE* aNode,
m_rotation = StrToInt1Units( str );
}
lNode = FindNode( aNode, wxT( "value" ) );
if( lNode )
m_name.text = lNode->GetNodeContent();
aNode->GetAttribute( wxT( "Name" ), &m_name.text );
str = FindNodeGetContent( aNode, wxT( "isFlipped" ) );

View File

@ -39,9 +39,7 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc )
{
int tok;
XNODE* iNode = NULL, *cNode = NULL;
wxString str;
bool growing = false;
bool attr = false;
wxString str, propValue, content;
wxCSConv conv( wxT( "windows-1251" ) );
FILE* fp = wxFopen( aFileName, wxT( "rt" ) );
@ -56,21 +54,6 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc )
while( ( tok = lexer.NextTok() ) != DSN_EOF )
{
if( growing && ( tok == DSN_LEFT || tok == DSN_RIGHT ) )
{
if( attr )
{
cNode->AddAttribute( wxT( "Name" ), str.Trim( false ) );
}
else if( str != wxEmptyString )
{
cNode->AddChild( new XNODE( wxXML_TEXT_NODE, wxEmptyString, str ) );
}
growing = false;
attr = false;
}
if( tok == DSN_RIGHT )
{
iNode = iNode->GetParent();
@ -82,14 +65,33 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc )
cNode = new XNODE( wxXML_ELEMENT_NODE, wxString( lexer.CurText(), conv ) );
iNode->AddChild( cNode );
iNode = cNode;
growing = true;
}
else if( cNode )
{
str = wxString( lexer.CurText(), conv );
if( tok == DSN_STRING )
{
// update attribute
if( iNode->GetAttribute( wxT( "Name" ), &propValue ) )
{
iNode->DeleteAttribute( wxT( "Name" ) );
iNode->AddAttribute( wxT( "Name" ), propValue + wxT( ' ' ) + str );
}
else
iNode->AddAttribute( wxT( "Name" ), str );
}
else if( str != wxEmptyString )
{
str += wxT( ' ' );
str += wxString( lexer.CurText(), conv );
if( tok == DSN_STRING )
attr = true;
// update node content
content = cNode->GetNodeContent() + wxT( ' ' ) + str;
if( cNode->GetChildren() )
cNode->GetChildren()->SetContent( content );
else
cNode->AddChild( new wxXmlNode( wxXML_TEXT_NODE,
wxEmptyString,
content ) );
}
}
}