Commit a3f2980d authored by Alexander Lunev's avatar Alexander Lunev Committed by jean-pierre charras

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

parent 179ada1c
...@@ -72,7 +72,7 @@ const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) ); ...@@ -72,7 +72,7 @@ const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) );
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) ); const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) ); const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) );
const wxString EaglePcbFileWildcard( _( "Eagle ver. 6.x XML PCB 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 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 KiCadFootprintLibFileWildcard( _( "KiCad footprint s-expre library file (*.kicad_mod)|*.kicad_mod" ) );
const wxString KiCadFootprintLibPathWildcard( _( "KiCad footprint s-expre library path (*.pretty)|*.pretty" ) ); const wxString KiCadFootprintLibPathWildcard( _( "KiCad footprint s-expre library path (*.pretty)|*.pretty" ) );
......
...@@ -837,27 +837,17 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) ...@@ -837,27 +837,17 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
if( componentFlatList[ii].CompareValue( componentFlatList[next] ) != 0 ) if( componentFlatList[ii].CompareValue( componentFlatList[next] ) != 0 )
{ {
#if defined(KICAD_GOST) msg.Printf( _( "Different values for %s%d%s (%s) and %s%d%s (%s)" ),
msg.Printf( _( "Different values for %s%d.%d (%s) and %s%d.%d (%s)" ),
GetChars( componentFlatList[ii].GetRef() ), GetChars( componentFlatList[ii].GetRef() ),
componentFlatList[ii].m_NumRef, componentFlatList[ii].m_NumRef,
componentFlatList[ii].m_Unit, GetChars( LIB_COMPONENT::ReturnSubReference(
componentFlatList[ii].m_Unit ) ),
GetChars( componentFlatList[ii].m_Value->GetText() ), GetChars( componentFlatList[ii].m_Value->GetText() ),
GetChars( componentFlatList[next].GetRef() ), GetChars( componentFlatList[next].GetRef() ),
componentFlatList[next].m_NumRef, componentFlatList[next].m_NumRef,
componentFlatList[next].m_Unit, GetChars( LIB_COMPONENT::ReturnSubReference(
componentFlatList[next].m_Value->GetText().GetData() ); componentFlatList[next].m_Unit ) ),
#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( componentFlatList[next].m_Value->GetText() ) ); GetChars( componentFlatList[next].m_Value->GetText() ) );
#endif
if( aMessageList ) if( aMessageList )
aMessageList->Add( msg + wxT( "\n" )); aMessageList->Add( msg + wxT( "\n" ));
......
...@@ -106,15 +106,19 @@ public: ...@@ -106,15 +106,19 @@ public:
wxString GetAttribute( const wxString& attrName, const wxString& defaultVal ) const 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 bool GetAttribute( const wxString& attrName, wxString *value ) const
{ {
return GetPropVal(attrName, value); return GetPropVal( attrName, value );
} }
void AddAttribute( const wxString& attrName, const wxString& 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 wxXmlProperty* GetAttributes() const
{ {
......
...@@ -131,7 +131,8 @@ double StrToDoublePrecisionUnits( wxString aStr, char aAxe, wxString aActualConv ...@@ -131,7 +131,8 @@ double StrToDoublePrecisionUnits( wxString aStr, char aAxe, wxString aActualConv
{ {
ls.ToDouble( &i ); ls.ToDouble( &i );
#ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID #ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID
if( aActualConversion == wxT( "SCH" ) ) if( aActualConversion == wxT( "SCH" )
|| aActualConversion == wxT( "SCHLIB" ) )
i = i * (0.0254 / 0.025); i = i * (0.0254 / 0.025);
#endif #endif
i = Millimeter2iu( i ); i = Millimeter2iu( i );
......
...@@ -76,10 +76,7 @@ void PCB_TEXT::Parse( XNODE* aNode, ...@@ -76,10 +76,7 @@ void PCB_TEXT::Parse( XNODE* aNode,
m_rotation = StrToInt1Units( str ); m_rotation = StrToInt1Units( str );
} }
lNode = FindNode( aNode, wxT( "value" ) ); aNode->GetAttribute( wxT( "Name" ), &m_name.text );
if( lNode )
m_name.text = lNode->GetNodeContent();
str = FindNodeGetContent( aNode, wxT( "isFlipped" ) ); str = FindNodeGetContent( aNode, wxT( "isFlipped" ) );
......
...@@ -39,9 +39,7 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) ...@@ -39,9 +39,7 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc )
{ {
int tok; int tok;
XNODE* iNode = NULL, *cNode = NULL; XNODE* iNode = NULL, *cNode = NULL;
wxString str; wxString str, propValue, content;
bool growing = false;
bool attr = false;
wxCSConv conv( wxT( "windows-1251" ) ); wxCSConv conv( wxT( "windows-1251" ) );
FILE* fp = wxFopen( aFileName, wxT( "rt" ) ); FILE* fp = wxFopen( aFileName, wxT( "rt" ) );
...@@ -56,21 +54,6 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) ...@@ -56,21 +54,6 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc )
while( ( tok = lexer.NextTok() ) != DSN_EOF ) 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 ) if( tok == DSN_RIGHT )
{ {
iNode = iNode->GetParent(); iNode = iNode->GetParent();
...@@ -82,14 +65,33 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) ...@@ -82,14 +65,33 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc )
cNode = new XNODE( wxXML_ELEMENT_NODE, wxString( lexer.CurText(), conv ) ); cNode = new XNODE( wxXML_ELEMENT_NODE, wxString( lexer.CurText(), conv ) );
iNode->AddChild( cNode ); iNode->AddChild( cNode );
iNode = cNode; iNode = cNode;
growing = true;
} }
else else if( cNode )
{ {
str += wxT( ' ' ); str = wxString( lexer.CurText(), conv );
str += wxString( lexer.CurText(), conv );
if( tok == DSN_STRING ) if( tok == DSN_STRING )
attr = true; {
// 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 )
{
// 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 ) );
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment