Commit 663959f4 authored by charras's avatar charras

fixed: eeschema: incorrect default position of void fields when loading schematic files

parent b0a2d7a4
...@@ -18,8 +18,7 @@ SCH_ITEM* ReadTextDescr( FILE * aFile, ...@@ -18,8 +18,7 @@ SCH_ITEM* ReadTextDescr( FILE * aFile,
char* aLine, char* aLine,
int aBufsize, int aBufsize,
int* aLineNum, int* aLineNum,
int aSchematicFileVersion) int aSchematicFileVersion ) {
{
/** /**
* Function ReadTextDescr * Function ReadTextDescr
* Reads the data structures for a Text (Comment, label, Hlabel and Hlabel * Reads the data structures for a Text (Comment, label, Hlabel and Hlabel
...@@ -56,7 +55,7 @@ SCH_ITEM* ReadTextDescr( FILE * aFile, ...@@ -56,7 +55,7 @@ SCH_ITEM* ReadTextDescr( FILE * aFile,
return NULL; return NULL;
} }
if( feof( aFile ) || GetLine( aFile, aLine, aLineNum, aBufsize) == NULL ) if( feof( aFile ) || GetLine( aFile, aLine, aLineNum, aBufsize ) == NULL )
{ {
aMsgDiag.Printf( aMsgDiag.Printf(
wxT( "EESchema file text struct error line %d (No text), aborted" ), wxT( "EESchema file text struct error line %d (No text), aborted" ),
...@@ -76,9 +75,9 @@ SCH_ITEM* ReadTextDescr( FILE * aFile, ...@@ -76,9 +75,9 @@ SCH_ITEM* ReadTextDescr( FILE * aFile,
TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->m_Orient = orient;
if ( isdigit(Name3[0]) ) if( isdigit( Name3[0] ) )
{ {
thickness = atol(Name3); thickness = atol( Name3 );
TextStruct->m_Width = thickness; TextStruct->m_Width = thickness;
} }
Struct = TextStruct; Struct = TextStruct;
...@@ -134,9 +133,9 @@ SCH_ITEM* ReadTextDescr( FILE * aFile, ...@@ -134,9 +133,9 @@ SCH_ITEM* ReadTextDescr( FILE * aFile,
TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->m_Orient = orient;
if ( isdigit(Name3[0]) ) if( isdigit( Name3[0] ) )
{ {
thickness = atol(Name3); thickness = atol( Name3 );
TextStruct->m_Width = thickness; TextStruct->m_Width = thickness;
} }
...@@ -198,7 +197,7 @@ int ReadSheetDescr( wxWindow* frame, ...@@ -198,7 +197,7 @@ int ReadSheetDescr( wxWindow* frame,
aMsgDiag.Printf( aMsgDiag.Printf(
wxT( " ** EESchema file sheet struct error at line %d, aborted\n" ), wxT( " ** EESchema file sheet struct error at line %d, aborted\n" ),
*aLineNum ); *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line); aMsgDiag << CONV_FROM_UTF8( Line );
Failed = TRUE; Failed = TRUE;
return Failed; return Failed;
} }
...@@ -233,7 +232,7 @@ int ReadSheetDescr( wxWindow* frame, ...@@ -233,7 +232,7 @@ int ReadSheetDescr( wxWindow* frame,
aMsgDiag.Printf( aMsgDiag.Printf(
wxT( "EESchema file sheet label F%d at line %d, aborted\n" ), wxT( "EESchema file sheet label F%d at line %d, aborted\n" ),
fieldNdx, *aLineNum ); fieldNdx, *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line); aMsgDiag << CONV_FROM_UTF8( Line );
return TRUE; return TRUE;
} }
...@@ -244,7 +243,7 @@ int ReadSheetDescr( wxWindow* frame, ...@@ -244,7 +243,7 @@ int ReadSheetDescr( wxWindow* frame,
{ {
aMsgDiag.Printf( aMsgDiag.Printf(
wxT( "EESchema file sheet field F at line %d, aborted\n" ), *aLineNum ); wxT( "EESchema file sheet field F at line %d, aborted\n" ), *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line); aMsgDiag << CONV_FROM_UTF8( Line );
return TRUE; return TRUE;
} }
if( *ptcar == '"' ) if( *ptcar == '"' )
...@@ -261,7 +260,7 @@ int ReadSheetDescr( wxWindow* frame, ...@@ -261,7 +260,7 @@ int ReadSheetDescr( wxWindow* frame,
aMsgDiag.Printf( aMsgDiag.Printf(
wxT( wxT(
"EESchema file sheet Label Caract error line %d, aborted\n" ), *aLineNum ); "EESchema file sheet Label Caract error line %d, aborted\n" ), *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line); aMsgDiag << CONV_FROM_UTF8( Line );
DisplayError( frame, aMsgDiag ); DisplayError( frame, aMsgDiag );
} }
if( size == 0 ) if( size == 0 )
...@@ -301,7 +300,7 @@ int ReadSheetDescr( wxWindow* frame, ...@@ -301,7 +300,7 @@ int ReadSheetDescr( wxWindow* frame,
aMsgDiag.Printf( aMsgDiag.Printf(
wxT( wxT(
"EESchema file Sheet Label Caract error line %d, aborted\n" ), *aLineNum ); "EESchema file Sheet Label Caract error line %d, aborted\n" ), *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line); aMsgDiag << CONV_FROM_UTF8( Line );
DisplayError( frame, aMsgDiag ); DisplayError( frame, aMsgDiag );
continue; continue;
} }
...@@ -339,7 +338,7 @@ int ReadSheetDescr( wxWindow* frame, ...@@ -339,7 +338,7 @@ int ReadSheetDescr( wxWindow* frame,
aMsgDiag.Printf( aMsgDiag.Printf(
wxT( " **EESchema file end_sheet struct error at line %d, aborted\n" ), wxT( " **EESchema file end_sheet struct error at line %d, aborted\n" ),
*aLineNum ); *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line); aMsgDiag << CONV_FROM_UTF8( Line );
Failed = TRUE; Failed = TRUE;
} }
if( !Failed ) if( !Failed )
...@@ -394,7 +393,7 @@ bool ReadSchemaDescr( wxWindow* frame, ...@@ -394,7 +393,7 @@ bool ReadSchemaDescr( wxWindow* frame,
/* Erreur ici: descr non trouvee */ /* Erreur ici: descr non trouvee */
aMsgDiag.Printf( aMsgDiag.Printf(
wxT( "EESchema file Dims Caract error line %d, aborted\n" ), *aLineNum ); wxT( "EESchema file Dims Caract error line %d, aborted\n" ), *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line); aMsgDiag << CONV_FROM_UTF8( Line );
DisplayError( frame, aMsgDiag ); DisplayError( frame, aMsgDiag );
} }
...@@ -511,7 +510,7 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, ...@@ -511,7 +510,7 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
aMsgDiag.Printf( aMsgDiag.Printf(
wxT( "EESchema Component descr error at line %d, aborted" ), wxT( "EESchema Component descr error at line %d, aborted" ),
*aLineNum ); *aLineNum );
aMsgDiag << wxT("\n") << CONV_FROM_UTF8(Line); aMsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
Failed = TRUE; Failed = TRUE;
return Failed; return Failed;
} }
...@@ -605,6 +604,14 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, ...@@ -605,6 +604,14 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
{ {
sscanf( Line + 1, "%d %d", sscanf( Line + 1, "%d %d",
&component->m_Pos.x, &component->m_Pos.y ); &component->m_Pos.x, &component->m_Pos.y );
// Set fields position to a default position (that is the component position
// For existing fields, the real position will be set later
for( int i = 0; i<component->GetFieldCount(); ++i )
{
if( component->GetField( i )->m_Text.IsEmpty() )
component->GetField( i )->m_Pos = component->m_Pos;
}
} }
else if( Line[0] == 'A' && Line[1] == 'R' ) else if( Line[0] == 'A' && Line[1] == 'R' )
{ {
...@@ -706,7 +713,7 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, ...@@ -706,7 +713,7 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
} }
component->GetField( fieldNdx )->m_Text = CONV_FROM_UTF8( Name1 ); component->GetField( fieldNdx )->m_Text = CONV_FROM_UTF8( Name1 );
memset(Char3, 0, sizeof(Char3) ); memset( Char3, 0, sizeof(Char3) );
if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", Char1, if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", Char1,
&component->GetField( fieldNdx )->m_Pos.x, &component->GetField( fieldNdx )->m_Pos.x,
&component->GetField( fieldNdx )->m_Pos.y, &component->GetField( fieldNdx )->m_Pos.y,
...@@ -745,7 +752,8 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, ...@@ -745,7 +752,8 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
else else
component->GetField( fieldNdx )->m_Italic = false; component->GetField( fieldNdx )->m_Italic = false;
if( Char3[2] == 'B' ) if( Char3[2] == 'B' )
component->GetField( fieldNdx )->m_Width = component->GetField( fieldNdx )->m_Size.x / 4; component->GetField( fieldNdx )->m_Width = component->GetField( fieldNdx )->
m_Size.x / 4;
else else
component->GetField( fieldNdx )->m_Width = 0; component->GetField( fieldNdx )->m_Width = 0;
...@@ -812,4 +820,3 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, ...@@ -812,4 +820,3 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
return Failed; /* Fin lecture 1 composant */ return Failed; /* Fin lecture 1 composant */
} }
No preview for this file type
This source diff could not be displayed because it is too large. You can view the blob instead.
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