2007-08-20 01:20:48 +00:00
|
|
|
/****************************************/
|
|
|
|
/* Module to load/save EESchema files. */
|
|
|
|
/****************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-04-12 18:39:20 +00:00
|
|
|
//#include "gr_basic.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
/* in read_from_file_schematic_items_description.cpp */
|
|
|
|
SCH_ITEM* ReadTextDescr( FILE* aFile, wxString& aMsgDiag, char* aLine,
|
|
|
|
int aBufsize, int* aLineNum, int aSchematicFileVersion );
|
|
|
|
int ReadSheetDescr( wxWindow* frame,
|
|
|
|
char* Line,
|
|
|
|
FILE* f,
|
|
|
|
wxString& aMsgDiag,
|
|
|
|
int* aLineNum,
|
|
|
|
BASE_SCREEN* Window );
|
|
|
|
int ReadSchemaDescr( wxWindow* frame,
|
|
|
|
char* Line,
|
|
|
|
FILE* f,
|
|
|
|
wxString& aMsgDiag,
|
|
|
|
int* aLineNum,
|
|
|
|
BASE_SCREEN* Window );
|
|
|
|
|
|
|
|
int ReadPartDescr( wxWindow* frame,
|
|
|
|
char* Line,
|
|
|
|
FILE* f,
|
|
|
|
wxString& aMsgDiag,
|
|
|
|
int* aLineNum,
|
|
|
|
BASE_SCREEN* Window );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Fonctions locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
static void LoadLayers( FILE* f, int* linecnt );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/************************************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine to load an EESchema file.
|
2008-12-19 20:40:08 +00:00
|
|
|
* Returns true if file has been loaded (at least partially.)
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
char Line[1024], * SLine;
|
|
|
|
char Name1[256],
|
|
|
|
Name2[256];
|
2008-12-19 20:40:08 +00:00
|
|
|
int ii, layer;
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint pos;
|
|
|
|
bool Failed = FALSE;
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM* Phead, * Pnext;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawJunctionStruct* ConnectionStruct;
|
|
|
|
DrawPolylineStruct* PolylineStruct;
|
|
|
|
EDA_DrawLineStruct* SegmentStruct;
|
|
|
|
DrawBusEntryStruct* RaccordStruct;
|
|
|
|
DrawMarkerStruct* MarkerStruct;
|
|
|
|
DrawNoConnectStruct* NoConnectStruct;
|
2008-12-19 20:40:08 +00:00
|
|
|
int LineCount; /* Decompte de num de ligne lue dans eeload() */
|
|
|
|
wxString MsgDiag; /* Error and log messages */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
FILE* f;
|
|
|
|
|
|
|
|
if( screen == NULL )
|
|
|
|
return FALSE;
|
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
screen->SetCurItem( NULL );
|
2008-03-20 01:50:21 +00:00
|
|
|
screen->m_FileName = FullFileName;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
LineCount = 1;
|
|
|
|
if( ( f = wxFopen( FullFileName, wxT( "rt" ) ) ) == NULL )
|
|
|
|
{
|
|
|
|
MsgDiag = _( "Failed to open " ) + FullFileName;
|
|
|
|
DisplayError( this, MsgDiag );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
MsgDiag = _( "Loading " ) + screen->m_FileName;
|
2007-08-20 01:20:48 +00:00
|
|
|
PrintMsg( MsgDiag );
|
|
|
|
|
|
|
|
if( fgets( Line, 1024 - 1, f ) == NULL
|
|
|
|
|| strncmp( Line + 9, SCHEMATIC_HEAD_STRING, sizeof(SCHEMATIC_HEAD_STRING) - 1 )
|
|
|
|
!= 0 )
|
|
|
|
{
|
2008-04-06 16:05:23 +00:00
|
|
|
MsgDiag = FullFileName + _( " is NOT an EESchema file!" );
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayError( this, MsgDiag );
|
|
|
|
fclose( f );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-04-06 15:12:24 +00:00
|
|
|
//get the file version here. TODO: Support version numbers > 9
|
2008-03-20 01:50:21 +00:00
|
|
|
char version = Line[9 + sizeof(SCHEMATIC_HEAD_STRING)];
|
2008-12-19 20:40:08 +00:00
|
|
|
int ver = version - '0';
|
2008-10-06 05:44:29 +00:00
|
|
|
if( ver > EESCHEMA_VERSION )
|
2008-04-06 15:12:24 +00:00
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
MsgDiag = FullFileName + _(
|
|
|
|
" was created by a more recent version of EESchema and may not load correctly. Please consider updating!" );
|
|
|
|
DisplayInfo( this, MsgDiag );
|
2008-04-06 15:12:24 +00:00
|
|
|
}
|
2008-12-19 20:40:08 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
#if 0
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
// Compile it if the new version is unreadable by previous eeschema versions
|
2008-10-06 05:44:29 +00:00
|
|
|
else if( ver < EESCHEMA_VERSION )
|
2008-04-06 15:12:24 +00:00
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
MsgDiag = FullFileName + _(
|
|
|
|
" was created by an older version of EESchema. It will be stored in the new file format when you save this file again." );
|
|
|
|
DisplayInfo( this, MsgDiag );
|
2008-04-06 15:12:24 +00:00
|
|
|
}
|
2008-04-15 19:38:19 +00:00
|
|
|
#endif
|
2008-04-06 15:12:24 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
LineCount++;
|
|
|
|
if( fgets( Line, 1024 - 1, f ) == NULL || strncmp( Line, "LIBS:", 5 ) != 0 )
|
|
|
|
{
|
2008-04-06 16:05:23 +00:00
|
|
|
MsgDiag = FullFileName + _( " is NOT an EESchema file!" );
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayError( this, MsgDiag );
|
|
|
|
fclose( f );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LoadLayers( f, &LineCount );
|
|
|
|
|
|
|
|
while( !feof( f ) && GetLine( f, Line, &LineCount, sizeof(Line) ) != NULL )
|
|
|
|
{
|
|
|
|
SLine = Line;
|
|
|
|
while( (*SLine != ' ' ) && *SLine )
|
|
|
|
SLine++;
|
|
|
|
|
|
|
|
switch( Line[0] )
|
|
|
|
{
|
|
|
|
case '$': /* identification de bloc */
|
|
|
|
if( Line[1] == 'C' )
|
2008-12-19 20:40:08 +00:00
|
|
|
Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
else if( Line[1] == 'S' )
|
2008-12-19 20:40:08 +00:00
|
|
|
Failed = ReadSheetDescr( this, Line, f, MsgDiag, &LineCount, screen );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
else if( Line[1] == 'D' )
|
2008-12-19 20:40:08 +00:00
|
|
|
Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, screen );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'L': /* Its a library item. */
|
2008-12-19 20:40:08 +00:00
|
|
|
Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen );
|
2007-08-20 01:20:48 +00:00
|
|
|
break; /* Fin lecture 1 composant */
|
|
|
|
|
|
|
|
|
|
|
|
case 'W': /* Its a Segment (WIRE or BUS) item. */
|
|
|
|
if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 )
|
|
|
|
{
|
|
|
|
MsgDiag.Printf(
|
|
|
|
wxT( "EESchema file Segment struct error at line %d, aborted" ),
|
|
|
|
LineCount );
|
2008-12-19 20:40:08 +00:00
|
|
|
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
|
|
|
|
Failed = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
layer = LAYER_NOTES;
|
|
|
|
if( Name1[0] == 'W' )
|
|
|
|
layer = LAYER_WIRE;
|
|
|
|
if( Name1[0] == 'B' )
|
|
|
|
layer = LAYER_BUS;
|
|
|
|
|
|
|
|
SegmentStruct = new EDA_DrawLineStruct( wxPoint( 0, 0 ), layer );
|
|
|
|
|
|
|
|
LineCount++;
|
|
|
|
if( fgets( Line, 256 - 1, f ) == NULL
|
|
|
|
|| sscanf( Line, "%d %d %d %d ",
|
2008-10-06 05:44:29 +00:00
|
|
|
&SegmentStruct->m_Start.x, &SegmentStruct->m_Start.y,
|
|
|
|
&SegmentStruct->m_End.x, &SegmentStruct->m_End.y ) != 4 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
MsgDiag.Printf(
|
|
|
|
wxT( "EESchema file Segment struct error at line %d, aborted" ),
|
|
|
|
LineCount );
|
2008-12-19 20:40:08 +00:00
|
|
|
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
|
|
|
|
Failed = true;
|
2008-10-06 05:44:29 +00:00
|
|
|
SAFE_DELETE( SegmentStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !Failed )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
SegmentStruct->SetNext( screen->EEDrawList );
|
2008-12-19 20:40:08 +00:00
|
|
|
screen->EEDrawList = SegmentStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 'E': /* Its a Raccord (WIRE or BUS) item. */
|
|
|
|
if( sscanf( SLine, "%s %s", Name1, Name2 ) != 2 )
|
|
|
|
{
|
|
|
|
MsgDiag.Printf(
|
2008-02-12 21:12:46 +00:00
|
|
|
wxT( "EESchema file record struct error at line %d, aborted" ),
|
2007-08-20 01:20:48 +00:00
|
|
|
LineCount );
|
2008-12-19 20:40:08 +00:00
|
|
|
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
|
|
|
|
Failed = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ii = WIRE_TO_BUS;
|
|
|
|
if( Name1[0] == 'B' )
|
|
|
|
ii = BUS_TO_BUS;
|
|
|
|
RaccordStruct = new DrawBusEntryStruct( wxPoint( 0, 0 ), '\\', ii );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
LineCount++;
|
|
|
|
if( fgets( Line, 256 - 1, f ) == NULL
|
|
|
|
|| sscanf( Line, "%d %d %d %d ",
|
2008-10-06 05:44:29 +00:00
|
|
|
&RaccordStruct->m_Pos.x, &RaccordStruct->m_Pos.y,
|
|
|
|
&RaccordStruct->m_Size.x, &RaccordStruct->m_Size.y ) != 4 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
MsgDiag.Printf(
|
2008-12-19 20:40:08 +00:00
|
|
|
wxT( "EESchema file Bus Entry struct error at line %d, aborted" ),
|
2007-08-20 01:20:48 +00:00
|
|
|
LineCount );
|
2008-12-19 20:40:08 +00:00
|
|
|
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
|
|
|
|
Failed = true;
|
2008-10-06 05:44:29 +00:00
|
|
|
SAFE_DELETE( RaccordStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !Failed )
|
|
|
|
{
|
|
|
|
RaccordStruct->m_Size.x -= RaccordStruct->m_Pos.x;
|
|
|
|
RaccordStruct->m_Size.y -= RaccordStruct->m_Pos.y;
|
2008-11-24 06:53:43 +00:00
|
|
|
RaccordStruct->SetNext( screen->EEDrawList );
|
2008-12-19 20:40:08 +00:00
|
|
|
screen->EEDrawList = RaccordStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'P': /* Its a polyline item. */
|
|
|
|
if( sscanf( SLine, "%s %s %d", Name1, Name2, &ii ) != 3 )
|
|
|
|
{
|
|
|
|
MsgDiag.Printf(
|
|
|
|
wxT( "EESchema file polyline struct error at line %d, aborted" ),
|
|
|
|
LineCount );
|
2008-12-19 20:40:08 +00:00
|
|
|
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
|
|
|
|
Failed = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
layer = LAYER_NOTES;
|
|
|
|
if( Name2[0] == 'W' )
|
|
|
|
layer = LAYER_WIRE;
|
|
|
|
if( Name2[0] == 'B' )
|
|
|
|
layer = LAYER_BUS;
|
|
|
|
|
|
|
|
PolylineStruct = new DrawPolylineStruct( layer );
|
|
|
|
|
|
|
|
PolylineStruct->m_NumOfPoints = ii;
|
|
|
|
PolylineStruct->m_Points = (int*) MyZMalloc( sizeof(int) * 2 *
|
2008-10-06 05:44:29 +00:00
|
|
|
PolylineStruct->m_NumOfPoints );
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ii = 0; ii < PolylineStruct->m_NumOfPoints; ii++ )
|
|
|
|
{
|
|
|
|
LineCount++;
|
|
|
|
if( fgets( Line, 256 - 1, f ) == NULL
|
|
|
|
|| sscanf( Line, "%d %d", &PolylineStruct->m_Points[ii * 2],
|
2008-10-06 05:44:29 +00:00
|
|
|
&PolylineStruct->m_Points[ii * 2 + 1] ) != 2 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
MsgDiag.Printf(
|
|
|
|
wxT( "EESchema file polyline struct error at line %d, aborted" ),
|
|
|
|
LineCount );
|
2008-12-19 20:40:08 +00:00
|
|
|
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
|
|
|
|
Failed = true;
|
2008-10-06 05:44:29 +00:00
|
|
|
SAFE_DELETE( PolylineStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !Failed )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
PolylineStruct->SetNext( screen->EEDrawList );
|
2008-12-19 20:40:08 +00:00
|
|
|
screen->EEDrawList = PolylineStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
case 'C': /* It is a connection item. */
|
2007-08-20 01:20:48 +00:00
|
|
|
ConnectionStruct = new DrawJunctionStruct( wxPoint( 0, 0 ) );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( sscanf( SLine, "%s %d %d", Name1,
|
2008-10-06 05:44:29 +00:00
|
|
|
&ConnectionStruct->m_Pos.x,
|
|
|
|
&ConnectionStruct->m_Pos.y ) != 3 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
MsgDiag.Printf(
|
|
|
|
wxT( "EESchema file connection struct error at line %d, aborted" ),
|
|
|
|
LineCount );
|
2008-12-19 20:40:08 +00:00
|
|
|
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
|
|
|
|
Failed = true;
|
2008-10-06 05:44:29 +00:00
|
|
|
SAFE_DELETE( ConnectionStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
ConnectionStruct->SetNext( screen->EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
screen->EEDrawList = ConnectionStruct;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
case 'N': /* It is a NoConnect item. */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 )
|
|
|
|
{
|
|
|
|
MsgDiag.Printf(
|
|
|
|
wxT( "EESchema file NoConnect struct error at line %d, aborted" ),
|
|
|
|
LineCount );
|
2008-12-19 20:40:08 +00:00
|
|
|
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
|
|
|
|
Failed = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NoConnectStruct = new DrawNoConnectStruct( pos );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
NoConnectStruct->SetNext( screen->EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
screen->EEDrawList = NoConnectStruct;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
case 'K': /* It is a Marker item. */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 )
|
|
|
|
{
|
|
|
|
MsgDiag.Printf(
|
|
|
|
wxT( "EESchema file marker struct error line %d, aborted" ),
|
|
|
|
LineCount );
|
2008-12-19 20:40:08 +00:00
|
|
|
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
|
|
|
|
Failed = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char* text;
|
|
|
|
char BufLine[1024];
|
|
|
|
MarkerStruct = new DrawMarkerStruct( pos, wxEmptyString );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
ii = ReadDelimitedText( BufLine, Line, 256 );
|
|
|
|
MarkerStruct->m_Type = (TypeMarker) ( (Name1[0] & 255) - 'A' );
|
|
|
|
if( MarkerStruct->m_Type < 0 )
|
|
|
|
MarkerStruct->m_Type = MARQ_UNSPEC;
|
|
|
|
if( ii )
|
|
|
|
MarkerStruct->m_Comment = CONV_FROM_UTF8( BufLine );
|
|
|
|
text = strstr( Line, " F=" );
|
|
|
|
if( text )
|
|
|
|
{
|
|
|
|
sscanf( text + 3, "%X", &ii );
|
|
|
|
MarkerStruct->m_MarkFlags = ii;
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
MarkerStruct->SetNext( screen->EEDrawList );
|
2008-12-19 20:40:08 +00:00
|
|
|
screen->EEDrawList = MarkerStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
case 'T': /* It is a text item. */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-19 20:40:08 +00:00
|
|
|
SCH_ITEM* Struct;
|
|
|
|
Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), &LineCount, version);
|
|
|
|
if( Struct )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-19 20:40:08 +00:00
|
|
|
Struct->SetNext( screen->EEDrawList );
|
|
|
|
screen->EEDrawList = Struct;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
2008-12-19 20:40:08 +00:00
|
|
|
Failed = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2008-12-19 20:40:08 +00:00
|
|
|
Failed = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
MsgDiag.Printf(
|
|
|
|
wxT( "EESchema file undef structdef at line %d, aborted" ),
|
|
|
|
LineCount );
|
2008-12-19 20:40:08 +00:00
|
|
|
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Failed )
|
|
|
|
{
|
|
|
|
DisplayError( this, MsgDiag );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EEDrawList was constructed in reverse order - reverse it back: */
|
|
|
|
Phead = NULL;
|
|
|
|
while( screen->EEDrawList )
|
|
|
|
{
|
|
|
|
Pnext = screen->EEDrawList;
|
2008-04-14 19:22:48 +00:00
|
|
|
screen->EEDrawList = screen->EEDrawList->Next();
|
2008-11-24 06:53:43 +00:00
|
|
|
Pnext->SetNext( Phead );
|
2007-08-20 01:20:48 +00:00
|
|
|
Phead = Pnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
screen->EEDrawList = Phead;
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
#if 0 && defined (DEBUG)
|
2007-09-20 21:06:49 +00:00
|
|
|
screen->Show( 0, std::cout );
|
|
|
|
#endif
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
fclose( f );
|
|
|
|
|
|
|
|
TestDanglingEnds( screen->EEDrawList, NULL );
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
MsgDiag = _( "Done Loading " ) + screen->m_FileName;
|
2008-03-20 01:50:21 +00:00
|
|
|
PrintMsg( MsgDiag );
|
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
return true; /* Although it may be that file is only partially loaded. */
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void LoadLayers( FILE* f, int* linecnt )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Load the Layer Struct from a file
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int cnt = 0, Number;
|
|
|
|
char Line[1024];
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
//int Mode,Color,Layer;
|
2007-08-20 01:20:48 +00:00
|
|
|
char Name[256];
|
|
|
|
|
|
|
|
GetLine( f, Line, NULL, sizeof(Line) ); /* read line */
|
|
|
|
(*linecnt)++;
|
|
|
|
sscanf( Line, "%s %d %d", Name, &Number, &g_LayerDescr.CurrentLayer );
|
|
|
|
if( strcmp( Name, "EELAYER" ) !=0 )
|
|
|
|
{
|
|
|
|
/* error : init par defaut */
|
|
|
|
Number = MAX_LAYER;
|
|
|
|
}
|
|
|
|
if( Number <= 0 )
|
|
|
|
Number = MAX_LAYER;
|
|
|
|
if( Number > MAX_LAYER )
|
|
|
|
Number = MAX_LAYER;
|
|
|
|
|
|
|
|
g_LayerDescr.NumberOfLayers = Number;
|
|
|
|
|
|
|
|
while( GetLine( f, Line, NULL, sizeof(Line) ) )
|
|
|
|
{
|
|
|
|
(*linecnt)++;
|
|
|
|
if( strnicmp( Line, "EELAYER END", 11 ) == 0 )
|
|
|
|
break;
|
|
|
|
cnt++;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|