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,
char* aLine,
int aBufsize,
int* aLineNum,
int aSchematicFileVersion)
{
int aSchematicFileVersion ) {
/**
* Function ReadTextDescr
* Reads the data structures for a Text (Comment, label, Hlabel and Hlabel
......@@ -56,7 +55,7 @@ SCH_ITEM* ReadTextDescr( FILE * aFile,
return NULL;
}
if( feof( aFile ) || GetLine( aFile, aLine, aLineNum, aBufsize) == NULL )
if( feof( aFile ) || GetLine( aFile, aLine, aLineNum, aBufsize ) == NULL )
{
aMsgDiag.Printf(
wxT( "EESchema file text struct error line %d (No text), aborted" ),
......@@ -76,9 +75,9 @@ SCH_ITEM* ReadTextDescr( FILE * aFile,
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient;
if ( isdigit(Name3[0]) )
if( isdigit( Name3[0] ) )
{
thickness = atol(Name3);
thickness = atol( Name3 );
TextStruct->m_Width = thickness;
}
Struct = TextStruct;
......@@ -134,9 +133,9 @@ SCH_ITEM* ReadTextDescr( FILE * aFile,
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient;
if ( isdigit(Name3[0]) )
if( isdigit( Name3[0] ) )
{
thickness = atol(Name3);
thickness = atol( Name3 );
TextStruct->m_Width = thickness;
}
......@@ -198,7 +197,7 @@ int ReadSheetDescr( wxWindow* frame,
aMsgDiag.Printf(
wxT( " ** EESchema file sheet struct error at line %d, aborted\n" ),
*aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line);
aMsgDiag << CONV_FROM_UTF8( Line );
Failed = TRUE;
return Failed;
}
......@@ -233,7 +232,7 @@ int ReadSheetDescr( wxWindow* frame,
aMsgDiag.Printf(
wxT( "EESchema file sheet label F%d at line %d, aborted\n" ),
fieldNdx, *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line);
aMsgDiag << CONV_FROM_UTF8( Line );
return TRUE;
}
......@@ -244,7 +243,7 @@ int ReadSheetDescr( wxWindow* frame,
{
aMsgDiag.Printf(
wxT( "EESchema file sheet field F at line %d, aborted\n" ), *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line);
aMsgDiag << CONV_FROM_UTF8( Line );
return TRUE;
}
if( *ptcar == '"' )
......@@ -261,7 +260,7 @@ int ReadSheetDescr( wxWindow* frame,
aMsgDiag.Printf(
wxT(
"EESchema file sheet Label Caract error line %d, aborted\n" ), *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line);
aMsgDiag << CONV_FROM_UTF8( Line );
DisplayError( frame, aMsgDiag );
}
if( size == 0 )
......@@ -301,7 +300,7 @@ int ReadSheetDescr( wxWindow* frame,
aMsgDiag.Printf(
wxT(
"EESchema file Sheet Label Caract error line %d, aborted\n" ), *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line);
aMsgDiag << CONV_FROM_UTF8( Line );
DisplayError( frame, aMsgDiag );
continue;
}
......@@ -339,7 +338,7 @@ int ReadSheetDescr( wxWindow* frame,
aMsgDiag.Printf(
wxT( " **EESchema file end_sheet struct error at line %d, aborted\n" ),
*aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line);
aMsgDiag << CONV_FROM_UTF8( Line );
Failed = TRUE;
}
if( !Failed )
......@@ -394,7 +393,7 @@ bool ReadSchemaDescr( wxWindow* frame,
/* Erreur ici: descr non trouvee */
aMsgDiag.Printf(
wxT( "EESchema file Dims Caract error line %d, aborted\n" ), *aLineNum );
aMsgDiag << CONV_FROM_UTF8(Line);
aMsgDiag << CONV_FROM_UTF8( Line );
DisplayError( frame, aMsgDiag );
}
......@@ -511,7 +510,7 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
aMsgDiag.Printf(
wxT( "EESchema Component descr error at line %d, aborted" ),
*aLineNum );
aMsgDiag << wxT("\n") << CONV_FROM_UTF8(Line);
aMsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
Failed = TRUE;
return Failed;
}
......@@ -605,6 +604,14 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
{
sscanf( Line + 1, "%d %d",
&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' )
{
......@@ -706,7 +713,7 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
}
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,
&component->GetField( fieldNdx )->m_Pos.x,
&component->GetField( fieldNdx )->m_Pos.y,
......@@ -745,7 +752,8 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
else
component->GetField( fieldNdx )->m_Italic = false;
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
component->GetField( fieldNdx )->m_Width = 0;
......@@ -812,4 +820,3 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
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