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" ) );
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" ) );
......
......@@ -713,14 +713,14 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
&& ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) )
{
msg.Printf( _( "Item not annotated: %s%s (unit %d)\n" ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ),
componentFlatList[ii].m_Unit );
}
else
{
msg.Printf( _( "Item not annotated: %s%s\n" ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ) );
}
......@@ -782,15 +782,15 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
if( ( componentFlatList[ii].m_Unit > 0 )
&& ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) )
{
msg.Printf( _( "Multiple item %s%s (unit %d)\n" ),
GetChars( componentFlatList[ii].GetRef() ),
msg.Printf( _( "Multiple item %s%s (unit %d)\n" ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ),
componentFlatList[ii].m_Unit );
}
else
{
msg.Printf( _( "Multiple item %s%s\n" ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ) );
}
......@@ -814,15 +814,15 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
if( ( componentFlatList[ii].m_Unit > 0 )
&& ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) )
{
msg.Printf( _( "Multiple item %s%s (unit %d)\n" ),
GetChars( componentFlatList[ii].GetRef() ),
msg.Printf( _( "Multiple item %s%s (unit %d)\n" ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ),
componentFlatList[ii].m_Unit );
}
else
{
msg.Printf( _( "Multiple item %s%s\n" ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ) );
}
......@@ -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" ));
......
......@@ -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
{
......
......@@ -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 );
......
......@@ -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" ) );
......
......@@ -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
else if( cNode )
{
str += wxT( ' ' );
str += wxString( lexer.CurText(), conv );
str = wxString( lexer.CurText(), conv );
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