Loading eeschema/load_one_schematic_file.cpp +42 −38 Original line number Original line Diff line number Diff line Loading @@ -52,18 +52,21 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, SCH_BUS_ENTRY* busEntry; SCH_BUS_ENTRY* busEntry; SCH_NO_CONNECT* NoConnectStruct; SCH_NO_CONNECT* NoConnectStruct; int LineCount; int LineCount; wxString MsgDiag; /* Error and log messages */ wxString MsgDiag; // Error and log messages FILE* f; FILE* f; if( screen == NULL ) if( screen == NULL ) return FALSE; return FALSE; if( FullFileName.IsEmpty() ) if( FullFileName.IsEmpty() ) return FALSE; return FALSE; screen->SetCurItem( NULL ); screen->SetCurItem( NULL ); screen->m_FileName = FullFileName; screen->m_FileName = FullFileName; // D(printf("LoadOneEEFile:%s\n", CONV_TO_UTF8( FullFileName ) ); ) LineCount = 1; LineCount = 1; if( ( f = wxFopen( FullFileName, wxT( "rt" ) ) ) == NULL ) if( ( f = wxFopen( FullFileName, wxT( "rt" ) ) ) == NULL ) { { Loading Loading @@ -136,7 +139,7 @@ again." ); switch( Line[0] ) switch( Line[0] ) { { case '$': /* identification block */ case '$': // identification block if( Line[1] == 'C' ) if( Line[1] == 'C' ) Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); Loading @@ -145,6 +148,7 @@ again." ); else if( Line[1] == 'D' ) else if( Line[1] == 'D' ) Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, screen ); Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, screen ); else if( Line[1] == 'T' ) // text part else if( Line[1] == 'T' ) // text part { { printf( "**** TEXT PART\n" ); printf( "**** TEXT PART\n" ); Loading @@ -161,15 +165,13 @@ again." ); Failed = true; Failed = true; } } } } break; break; case 'L': /* Its a library item. */ case 'L': // Its a library item. Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); break; break; case 'W': // Its a Segment (WIRE or BUS) item. case 'W': /* Its a Segment (WIRE or BUS) item. */ if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) { { MsgDiag.Printf( wxT( "EESchema file segment error at line %d, aborted" ), MsgDiag.Printf( wxT( "EESchema file segment error at line %d, aborted" ), Loading @@ -178,7 +180,9 @@ again." ); Failed = true; Failed = true; break; break; } } layer = LAYER_NOTES; layer = LAYER_NOTES; if( Name1[0] == 'W' ) if( Name1[0] == 'W' ) layer = LAYER_WIRE; layer = LAYER_WIRE; if( Name1[0] == 'B' ) if( Name1[0] == 'B' ) Loading Loading @@ -207,8 +211,7 @@ again." ); } } break; break; case 'E': // Its a WIRE or BUS item. case 'E': /* Its a WIRE or BUS item. */ if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) { { MsgDiag.Printf( wxT( "EESchema file record struct error at line %d, aborted" ), MsgDiag.Printf( wxT( "EESchema file record struct error at line %d, aborted" ), Loading @@ -224,6 +227,7 @@ again." ); busEntry = new SCH_BUS_ENTRY( wxPoint( 0, 0 ), '\\', ii ); busEntry = new SCH_BUS_ENTRY( wxPoint( 0, 0 ), '\\', ii ); LineCount++; LineCount++; if( fgets( Line, 256 - 1, f ) == NULL if( fgets( Line, 256 - 1, f ) == NULL || sscanf( Line, "%d %d %d %d ", &busEntry->m_Pos.x, &busEntry->m_Pos.y, || sscanf( Line, "%d %d %d %d ", &busEntry->m_Pos.x, &busEntry->m_Pos.y, &busEntry->m_Size.x, &busEntry->m_Size.y ) != 4 ) &busEntry->m_Size.x, &busEntry->m_Size.y ) != 4 ) Loading @@ -245,7 +249,7 @@ again." ); } } break; break; case 'P': /* Its a polyline item. */ case 'P': // Its a polyline item. if( sscanf( SLine, "%s %s %d", Name1, Name2, &ii ) != 3 ) if( sscanf( SLine, "%s %s %d", Name1, Name2, &ii ) != 3 ) { { MsgDiag.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), MsgDiag.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), Loading Loading @@ -287,7 +291,7 @@ at line %d, aborted" ), } } break; break; case 'C': /* It is a connection item. */ case 'C': // It is a connection item. ConnectionStruct = new SCH_JUNCTION( wxPoint( 0, 0 ) ); ConnectionStruct = new SCH_JUNCTION( wxPoint( 0, 0 ) ); if( sscanf( SLine, "%s %d %d", Name1, &ConnectionStruct->m_Pos.x, if( sscanf( SLine, "%s %d %d", Name1, &ConnectionStruct->m_Pos.x, Loading @@ -307,7 +311,7 @@ at line %d, aborted" ), } } break; break; case 'N': /* It is a NoConnect item. */ case 'N': // It is a NoConnect item. if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) { { MsgDiag.Printf( wxT( "EESchema file NoConnect struct error at line %d, aborted" ), MsgDiag.Printf( wxT( "EESchema file NoConnect struct error at line %d, aborted" ), Loading @@ -323,12 +327,12 @@ at line %d, aborted" ), } } break; break; case 'K': /* It is a Marker item. */ case 'K': // It is a Marker item. // Markers are no more read from file. they are only created on // Markers are no more read from file. they are only created on // demand in schematic // demand in schematic break; break; case 'T': /* It is a text item. */ case 'T': // It is a text item. { { SCH_ITEM* Struct; SCH_ITEM* Struct; Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), &LineCount, version); Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), &LineCount, version); Loading @@ -340,8 +344,8 @@ at line %d, aborted" ), } } else else Failed = true; Failed = true; break; } } break; default: default: Failed = true; Failed = true; Loading Loading @@ -381,7 +385,7 @@ at line %d, aborted" ), MsgDiag = _( "Done Loading " ) + screen->m_FileName; MsgDiag = _( "Done Loading " ) + screen->m_FileName; PrintMsg( MsgDiag ); PrintMsg( MsgDiag ); return true; /* Although it may be that file is only partially loaded. */ return true; // Although it may be that file is only partially loaded. } } Loading Loading
eeschema/load_one_schematic_file.cpp +42 −38 Original line number Original line Diff line number Diff line Loading @@ -52,18 +52,21 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, SCH_BUS_ENTRY* busEntry; SCH_BUS_ENTRY* busEntry; SCH_NO_CONNECT* NoConnectStruct; SCH_NO_CONNECT* NoConnectStruct; int LineCount; int LineCount; wxString MsgDiag; /* Error and log messages */ wxString MsgDiag; // Error and log messages FILE* f; FILE* f; if( screen == NULL ) if( screen == NULL ) return FALSE; return FALSE; if( FullFileName.IsEmpty() ) if( FullFileName.IsEmpty() ) return FALSE; return FALSE; screen->SetCurItem( NULL ); screen->SetCurItem( NULL ); screen->m_FileName = FullFileName; screen->m_FileName = FullFileName; // D(printf("LoadOneEEFile:%s\n", CONV_TO_UTF8( FullFileName ) ); ) LineCount = 1; LineCount = 1; if( ( f = wxFopen( FullFileName, wxT( "rt" ) ) ) == NULL ) if( ( f = wxFopen( FullFileName, wxT( "rt" ) ) ) == NULL ) { { Loading Loading @@ -136,7 +139,7 @@ again." ); switch( Line[0] ) switch( Line[0] ) { { case '$': /* identification block */ case '$': // identification block if( Line[1] == 'C' ) if( Line[1] == 'C' ) Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); Loading @@ -145,6 +148,7 @@ again." ); else if( Line[1] == 'D' ) else if( Line[1] == 'D' ) Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, screen ); Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, screen ); else if( Line[1] == 'T' ) // text part else if( Line[1] == 'T' ) // text part { { printf( "**** TEXT PART\n" ); printf( "**** TEXT PART\n" ); Loading @@ -161,15 +165,13 @@ again." ); Failed = true; Failed = true; } } } } break; break; case 'L': /* Its a library item. */ case 'L': // Its a library item. Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); break; break; case 'W': // Its a Segment (WIRE or BUS) item. case 'W': /* Its a Segment (WIRE or BUS) item. */ if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) { { MsgDiag.Printf( wxT( "EESchema file segment error at line %d, aborted" ), MsgDiag.Printf( wxT( "EESchema file segment error at line %d, aborted" ), Loading @@ -178,7 +180,9 @@ again." ); Failed = true; Failed = true; break; break; } } layer = LAYER_NOTES; layer = LAYER_NOTES; if( Name1[0] == 'W' ) if( Name1[0] == 'W' ) layer = LAYER_WIRE; layer = LAYER_WIRE; if( Name1[0] == 'B' ) if( Name1[0] == 'B' ) Loading Loading @@ -207,8 +211,7 @@ again." ); } } break; break; case 'E': // Its a WIRE or BUS item. case 'E': /* Its a WIRE or BUS item. */ if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 ) { { MsgDiag.Printf( wxT( "EESchema file record struct error at line %d, aborted" ), MsgDiag.Printf( wxT( "EESchema file record struct error at line %d, aborted" ), Loading @@ -224,6 +227,7 @@ again." ); busEntry = new SCH_BUS_ENTRY( wxPoint( 0, 0 ), '\\', ii ); busEntry = new SCH_BUS_ENTRY( wxPoint( 0, 0 ), '\\', ii ); LineCount++; LineCount++; if( fgets( Line, 256 - 1, f ) == NULL if( fgets( Line, 256 - 1, f ) == NULL || sscanf( Line, "%d %d %d %d ", &busEntry->m_Pos.x, &busEntry->m_Pos.y, || sscanf( Line, "%d %d %d %d ", &busEntry->m_Pos.x, &busEntry->m_Pos.y, &busEntry->m_Size.x, &busEntry->m_Size.y ) != 4 ) &busEntry->m_Size.x, &busEntry->m_Size.y ) != 4 ) Loading @@ -245,7 +249,7 @@ again." ); } } break; break; case 'P': /* Its a polyline item. */ case 'P': // Its a polyline item. if( sscanf( SLine, "%s %s %d", Name1, Name2, &ii ) != 3 ) if( sscanf( SLine, "%s %s %d", Name1, Name2, &ii ) != 3 ) { { MsgDiag.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), MsgDiag.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), Loading Loading @@ -287,7 +291,7 @@ at line %d, aborted" ), } } break; break; case 'C': /* It is a connection item. */ case 'C': // It is a connection item. ConnectionStruct = new SCH_JUNCTION( wxPoint( 0, 0 ) ); ConnectionStruct = new SCH_JUNCTION( wxPoint( 0, 0 ) ); if( sscanf( SLine, "%s %d %d", Name1, &ConnectionStruct->m_Pos.x, if( sscanf( SLine, "%s %d %d", Name1, &ConnectionStruct->m_Pos.x, Loading @@ -307,7 +311,7 @@ at line %d, aborted" ), } } break; break; case 'N': /* It is a NoConnect item. */ case 'N': // It is a NoConnect item. if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) { { MsgDiag.Printf( wxT( "EESchema file NoConnect struct error at line %d, aborted" ), MsgDiag.Printf( wxT( "EESchema file NoConnect struct error at line %d, aborted" ), Loading @@ -323,12 +327,12 @@ at line %d, aborted" ), } } break; break; case 'K': /* It is a Marker item. */ case 'K': // It is a Marker item. // Markers are no more read from file. they are only created on // Markers are no more read from file. they are only created on // demand in schematic // demand in schematic break; break; case 'T': /* It is a text item. */ case 'T': // It is a text item. { { SCH_ITEM* Struct; SCH_ITEM* Struct; Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), &LineCount, version); Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), &LineCount, version); Loading @@ -340,8 +344,8 @@ at line %d, aborted" ), } } else else Failed = true; Failed = true; break; } } break; default: default: Failed = true; Failed = true; Loading Loading @@ -381,7 +385,7 @@ at line %d, aborted" ), MsgDiag = _( "Done Loading " ) + screen->m_FileName; MsgDiag = _( "Done Loading " ) + screen->m_FileName; PrintMsg( MsgDiag ); PrintMsg( MsgDiag ); return true; /* Although it may be that file is only partially loaded. */ return true; // Although it may be that file is only partially loaded. } } Loading