|
|
@ -581,7 +581,6 @@ LIB_PIN* LIB_COMPONENT::GetPin( const wxString& aNumber, int aUnit, int aConvert |
|
|
|
|
|
|
|
bool LIB_COMPONENT::Save( OUTPUTFORMATTER& aFormatter ) |
|
|
|
{ |
|
|
|
size_t i; |
|
|
|
LIB_FIELD& value = GetValueField(); |
|
|
|
|
|
|
|
// First line: it s a comment (component name for readers)
|
|
|
@ -590,6 +589,14 @@ bool LIB_COMPONENT::Save( OUTPUTFORMATTER& aFormatter ) |
|
|
|
// Save data
|
|
|
|
aFormatter.Print( 0, "DEF" ); |
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
if( value.GetText() == wxT( "R" ) ) |
|
|
|
{ |
|
|
|
int breakhere = 1; |
|
|
|
(void) breakhere; |
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
if( value.IsVisible() ) |
|
|
|
{ |
|
|
|
aFormatter.Print( 0, " %s", TO_UTF8( value.GetText() ) ); |
|
|
@ -627,7 +634,7 @@ bool LIB_COMPONENT::Save( OUTPUTFORMATTER& aFormatter ) |
|
|
|
// may have their own save policy so there is a separate loop for them.
|
|
|
|
// Empty fields are saved, because the user may have set visibility,
|
|
|
|
// size and orientation
|
|
|
|
for( i = 0; i < MANDATORY_FIELDS; ++i ) |
|
|
|
for( int i = 0; i < MANDATORY_FIELDS; ++i ) |
|
|
|
{ |
|
|
|
if( !fields[i].Save( aFormatter ) ) |
|
|
|
return false; |
|
|
@ -638,7 +645,7 @@ bool LIB_COMPONENT::Save( OUTPUTFORMATTER& aFormatter ) |
|
|
|
|
|
|
|
int fieldId = MANDATORY_FIELDS; // really wish this would go away.
|
|
|
|
|
|
|
|
for( i = MANDATORY_FIELDS; i < fields.size(); ++i ) |
|
|
|
for( unsigned i = MANDATORY_FIELDS; i < fields.size(); ++i ) |
|
|
|
{ |
|
|
|
// There is no need to save empty fields, i.e. no reason to preserve field
|
|
|
|
// names now that fields names come in dynamically through the template
|
|
|
@ -659,7 +666,7 @@ bool LIB_COMPONENT::Save( OUTPUTFORMATTER& aFormatter ) |
|
|
|
{ |
|
|
|
aFormatter.Print( 0, "ALIAS" ); |
|
|
|
|
|
|
|
for( i = 1; i < m_aliases.size(); i++ ) |
|
|
|
for( unsigned i = 1; i < m_aliases.size(); i++ ) |
|
|
|
{ |
|
|
|
aFormatter.Print( 0, " %s", TO_UTF8( m_aliases[i]->GetName() ) ); |
|
|
|
} |
|
|
@ -672,7 +679,7 @@ bool LIB_COMPONENT::Save( OUTPUTFORMATTER& aFormatter ) |
|
|
|
{ |
|
|
|
aFormatter.Print( 0, "$FPLIST\n" ); |
|
|
|
|
|
|
|
for( i = 0; i < m_FootprintList.GetCount(); i++ ) |
|
|
|
for( unsigned i = 0; i < m_FootprintList.GetCount(); i++ ) |
|
|
|
{ |
|
|
|
aFormatter.Print( 0, " %s\n", TO_UTF8( m_FootprintList[i] ) ); |
|
|
|
} |
|
|
@ -715,7 +722,7 @@ bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) |
|
|
|
char* prefix = NULL; |
|
|
|
char* line; |
|
|
|
|
|
|
|
bool Res; |
|
|
|
bool result; |
|
|
|
wxString Msg; |
|
|
|
|
|
|
|
line = aLineReader.Line(); |
|
|
@ -749,10 +756,8 @@ bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) |
|
|
|
aErrorMsg.Printf( wxT( "Wrong DEF format in line %d, skipped." ), |
|
|
|
aLineReader.LineNumber() ); |
|
|
|
|
|
|
|
while( aLineReader.ReadLine() ) |
|
|
|
while( (line = aLineReader.ReadLine()) != NULL ) |
|
|
|
{ |
|
|
|
line = aLineReader.Line(); |
|
|
|
|
|
|
|
p = strtok( line, " \t\n" ); |
|
|
|
|
|
|
|
if( stricmp( p, "ENDDEF" ) == 0 ) |
|
|
@ -808,36 +813,34 @@ bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) |
|
|
|
m_options = ENTRY_POWER; |
|
|
|
|
|
|
|
// Read next lines, until "ENDDEF" is found
|
|
|
|
while( aLineReader.ReadLine() ) |
|
|
|
while( ( line = aLineReader.ReadLine() ) != NULL ) |
|
|
|
{ |
|
|
|
line = aLineReader.Line(); |
|
|
|
|
|
|
|
p = strtok( line, " \t\r\n" ); |
|
|
|
|
|
|
|
// This is the error flag ( if an error occurs, Res = false)
|
|
|
|
Res = true; |
|
|
|
// This is the error flag ( if an error occurs, result = false)
|
|
|
|
result = true; |
|
|
|
|
|
|
|
if( *line == '#' ) // a comment
|
|
|
|
continue; |
|
|
|
|
|
|
|
if( (*line == 'T') && (*(line + 1) == 'i') ) |
|
|
|
Res = LoadDateAndTime( aLineReader ); |
|
|
|
if( line[0] == 'T' && line[1] == 'i' ) |
|
|
|
result = LoadDateAndTime( aLineReader ); |
|
|
|
else if( *line == 'F' ) |
|
|
|
Res = LoadField( aLineReader, Msg ); |
|
|
|
result = LoadField( aLineReader, Msg ); |
|
|
|
else if( strcmp( p, "ENDDEF" ) == 0 ) // End of component description
|
|
|
|
break; |
|
|
|
goto ok; |
|
|
|
else if( strcmp( p, "DRAW" ) == 0 ) |
|
|
|
Res = LoadDrawEntries( aLineReader, Msg ); |
|
|
|
result = LoadDrawEntries( aLineReader, Msg ); |
|
|
|
else if( strncmp( p, "ALIAS", 5 ) == 0 ) |
|
|
|
{ |
|
|
|
p = strtok( NULL, "\r\n" ); |
|
|
|
Res = LoadAliases( p, aErrorMsg ); |
|
|
|
result = LoadAliases( p, aErrorMsg ); |
|
|
|
} |
|
|
|
else if( strncmp( p, "$FPLIST", 5 ) == 0 ) |
|
|
|
Res = LoadFootprints( aLineReader, Msg ); |
|
|
|
result = LoadFootprints( aLineReader, Msg ); |
|
|
|
|
|
|
|
// End line or block analysis: test for an error
|
|
|
|
if( !Res ) |
|
|
|
if( !result ) |
|
|
|
{ |
|
|
|
if( Msg.IsEmpty() ) |
|
|
|
aErrorMsg.Printf( wxT( "error occurred at line %d " ), aLineReader.LineNumber() ); |
|
|
@ -849,6 +852,9 @@ bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
ok: |
|
|
|
// If we are here, this part is O.k. - put it in:
|
|
|
|
drawings.sort(); |
|
|
|
|
|
|
@ -863,14 +869,12 @@ bool LIB_COMPONENT::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorM |
|
|
|
|
|
|
|
while( true ) |
|
|
|
{ |
|
|
|
if( !aLineReader.ReadLine() ) |
|
|
|
if( !( line = aLineReader.ReadLine() ) ) |
|
|
|
{ |
|
|
|
aErrorMsg = wxT( "file ended prematurely loading component draw element" ); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
line = aLineReader.Line(); |
|
|
|
|
|
|
|
if( strncmp( line, "ENDDRAW", 7 ) == 0 ) |
|
|
|
break; |
|
|
|
|
|
|
@ -925,8 +929,8 @@ bool LIB_COMPONENT::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorM |
|
|
|
{ |
|
|
|
if( !aLineReader.ReadLine() ) |
|
|
|
{ |
|
|
|
aErrorMsg = wxT( "file ended prematurely while attempting \
|
|
|
|
to flush to end of drawing section." ); |
|
|
|
aErrorMsg = wxT( "file ended prematurely while attempting " |
|
|
|
"to flush to end of drawing section." ); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} while( strncmp( line, "ENDDRAW", 7 ) != 0 ); |
|
|
@ -999,13 +1003,12 @@ bool LIB_COMPONENT::LoadFootprints( LINE_READER& aLineReader, wxString& aErrorMs |
|
|
|
|
|
|
|
while( true ) |
|
|
|
{ |
|
|
|
if( !aLineReader.ReadLine() ) |
|
|
|
if( !( line = aLineReader.ReadLine() ) ) |
|
|
|
{ |
|
|
|
aErrorMsg = wxT( "file ended prematurely while loading footprints" ); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
line = aLineReader.Line(); |
|
|
|
p = strtok( line, " \t\r\n" ); |
|
|
|
|
|
|
|
if( stricmp( p, "$ENDFPLIST" ) == 0 ) |
|
|
@ -1459,7 +1462,7 @@ LIB_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, |
|
|
|
|
|
|
|
item = LocateDrawItem( aUnit, aConvert, aType, aPoint ); |
|
|
|
|
|
|
|
//Restore matrix
|
|
|
|
// Restore matrix
|
|
|
|
DefaultTransform = transform; |
|
|
|
|
|
|
|
return item; |
|
|
|