2007-12-11 20:26:40 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
|
|
|
/* Routines de lecture et sauvegarde des structures en format ASCii */
|
|
|
|
/* Fichier common a PCBNEW et CVPCB */
|
|
|
|
/********************************************************************/
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
/* ioascii.cpp */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
#ifdef PCBNEW
|
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "autorout.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CVPCB
|
|
|
|
#include "cvpcb.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
/* Format des structures de sauvegarde type ASCII :
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
Structure PAD:
|
|
|
|
|
|
|
|
$PAD
|
|
|
|
Sh "name" forme dimv dimH dV dH orient :forme generale dV, dH = delta dimensions
|
|
|
|
Dr diam, dV dH :drill : diametre offsets de percage
|
|
|
|
At type S/N layers : type standard,cms,conn,hole,meca.,
|
|
|
|
Stack/Normal,
|
|
|
|
Hexadecimal 32 bits: occupation des couches
|
|
|
|
Nm net_code netname
|
|
|
|
Po posrefX posrefy : position refX,Y (= position orient 0 / ancre)
|
|
|
|
$EndPAD
|
|
|
|
|
|
|
|
****** Structure module ***********
|
|
|
|
|
|
|
|
$MODULE namelib
|
|
|
|
Po ax ay orient layer masquelayer m_TimeCode
|
|
|
|
ax ay = coord ancre (position module)
|
|
|
|
orient = orient en 0.1 degre
|
|
|
|
layer = numero de couche
|
|
|
|
masquelayer = couche pour serigraphie
|
|
|
|
m_TimeCode a usage interne (groupements)
|
|
|
|
Li <namelib>
|
|
|
|
|
|
|
|
Cd <text> Description du composant (Composant Doc)
|
|
|
|
Kw <text> Liste des mots cle
|
|
|
|
|
|
|
|
Sc schematimestamp de reference schematique
|
|
|
|
|
|
|
|
Op rot90 rot180 Options de placement auto (cout rot 90, 180 )
|
|
|
|
rot90 est sur 2x4 bits:
|
|
|
|
lsb = cout rot 90, msb = cout rot -90;
|
|
|
|
|
|
|
|
Tn px py dimv dimh orient epaisseur miroir visible "texte"
|
|
|
|
n = type (0 = ref, 1 = val, > 1 =qcq
|
|
|
|
Textes POS x,y / ancre et orient module 0
|
|
|
|
dimv dimh orient
|
|
|
|
epaisseur miroir (Normal/miroir)
|
|
|
|
visible V/I
|
|
|
|
DS ox oy fx fy w
|
|
|
|
edge: segment coord ox,oy a fx,fy, relatives
|
|
|
|
a l'ancre et orient 0
|
|
|
|
epaisseur w
|
|
|
|
DC ox oy fx fy w descr cercle (centre, 1 point, epaisseur)
|
|
|
|
$PAD
|
|
|
|
$EndPAD section pads s'il y en a
|
|
|
|
$EndMODULE
|
2007-06-05 12:10:51 +00:00
|
|
|
*/
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
extern Ki_PageDescr* SheetList[];
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/* Local Variables */
|
2007-08-06 02:02:39 +00:00
|
|
|
int NbDraw, NbTrack, NbZone, NbMod, NbNets;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2007-12-03 06:54:19 +00:00
|
|
|
int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
|
2007-08-30 22:20:52 +00:00
|
|
|
TRACK* PtSegm, int StructType, int* LineNum, int NumSegm )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/** Read a list of segments (Tracks, zones)
|
|
|
|
* @return items count or - count if no end block ($End...) found.
|
2007-08-06 02:02:39 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-01-12 20:31:56 +00:00
|
|
|
int shape, width, drill, layer, type, flags, net_code;
|
2007-12-03 06:54:19 +00:00
|
|
|
int ii = 0;
|
2007-08-30 22:20:52 +00:00
|
|
|
char line1[256];
|
|
|
|
char line2[256];
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
TRACK* NewTrack;
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
while( GetLine( File, line1, LineNum ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2007-08-30 22:20:52 +00:00
|
|
|
int makeType;
|
|
|
|
unsigned long timeStamp;
|
|
|
|
|
|
|
|
if( line1[0] == '$' )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2007-12-03 06:54:19 +00:00
|
|
|
return ii; /* end of segmentlist: OK */
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
// Read the 2nd line to determine the exact type, one of:
|
|
|
|
// TYPETRACK, TYPEVIA, or TYPEZONE. The type field in 2nd line
|
|
|
|
// differentiates between TYPETRACK and TYPEVIA. With virtual
|
|
|
|
// functions in use, it is critical to instantiate the TYPEVIA exactly.
|
|
|
|
if( GetLine( File, line2, LineNum ) == NULL )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( line2[0] == '$' )
|
|
|
|
break;
|
|
|
|
|
|
|
|
// parse the 2nd line first to determine the type of object
|
|
|
|
sscanf( line2 + 2, " %d %d %d %lX %X", &layer, &type, &net_code,
|
|
|
|
&timeStamp, &flags );
|
|
|
|
|
|
|
|
if( StructType==TYPETRACK && type==1 )
|
|
|
|
makeType = TYPEVIA;
|
|
|
|
else
|
|
|
|
makeType = StructType;
|
|
|
|
|
|
|
|
switch( makeType )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case TYPETRACK:
|
|
|
|
NewTrack = new TRACK( m_Pcb );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEVIA:
|
|
|
|
NewTrack = new SEGVIA( m_Pcb );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPEZONE:
|
|
|
|
NewTrack = new SEGZONE( m_Pcb );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
NewTrack->Insert( m_Pcb, PtSegm );
|
|
|
|
|
|
|
|
PtSegm = NewTrack;
|
|
|
|
|
|
|
|
PtSegm->m_TimeStamp = timeStamp;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
int arg_count = sscanf( line1 + 2, " %d %d %d %d %d %d %d", &shape,
|
2007-08-06 02:02:39 +00:00
|
|
|
&PtSegm->m_Start.x, &PtSegm->m_Start.y,
|
|
|
|
&PtSegm->m_End.x, &PtSegm->m_End.y, &width,
|
2008-01-12 20:31:56 +00:00
|
|
|
&drill );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-10-15 07:50:59 +00:00
|
|
|
PtSegm->m_Width = width;
|
2007-08-30 22:20:52 +00:00
|
|
|
PtSegm->m_Shape = shape;
|
2007-10-15 07:50:59 +00:00
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
if( arg_count < 7 || drill <= 0 )
|
|
|
|
PtSegm->SetDrillDefault();
|
|
|
|
else
|
|
|
|
PtSegm->SetDrillValue(drill);
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
PtSegm->SetLayer( layer );
|
2007-10-13 06:18:44 +00:00
|
|
|
PtSegm->SetNet( net_code );
|
2007-08-30 22:20:52 +00:00
|
|
|
PtSegm->SetState( flags, ON );
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayError( this, _( "Error: Unexpected end of file !" ) );
|
|
|
|
return -ii;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
2007-12-03 06:54:19 +00:00
|
|
|
int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************************************/
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
char Line[1024], * data;
|
|
|
|
|
|
|
|
while( GetLine( File, Line, LineNum ) != NULL )
|
|
|
|
{
|
|
|
|
data = strtok( Line, " =\n\r" );
|
|
|
|
if( strnicmp( data, "$EndGENERAL", 10 ) == 0 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( strncmp( data, "Ly", 2 ) == 0 ) // Old format for Layer count
|
|
|
|
{
|
|
|
|
int Masque_Layer = 1, ii;
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
sscanf( data, "%X", &Masque_Layer );
|
|
|
|
|
|
|
|
// Setup layer count
|
|
|
|
m_Pcb->m_BoardSettings->m_CopperLayerCount = 0;
|
|
|
|
for( ii = 0; ii < NB_COPPER_LAYERS; ii++ )
|
|
|
|
{
|
|
|
|
if( Masque_Layer & 1 )
|
|
|
|
m_Pcb->m_BoardSettings->m_CopperLayerCount++;
|
|
|
|
Masque_Layer >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( data, "Links", 5 ) == 0 )
|
|
|
|
{
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
m_Pcb->m_NbLinks = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( data, "NoConn", 6 ) == 0 )
|
|
|
|
{
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
m_Pcb->m_NbNoconnect = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( data, "Di", 2 ) == 0 )
|
|
|
|
{
|
|
|
|
wxSize pcbsize, screensize;
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
m_Pcb->m_BoundaryBox.SetX( atoi( data ) );
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
m_Pcb->m_BoundaryBox.SetY( atoi( data ) );
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
m_Pcb->m_BoundaryBox.SetWidth( atoi( data ) - m_Pcb->m_BoundaryBox.GetX() );
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
m_Pcb->m_BoundaryBox.SetHeight( atoi( data ) - m_Pcb->m_BoundaryBox.GetY() );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lecture du nombre de segments type DRAW , TRACT, ZONE */
|
|
|
|
if( stricmp( data, "Ndraw" ) == 0 )
|
|
|
|
{
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
NbDraw = atoi( data );;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( data, "Ntrack" ) == 0 )
|
|
|
|
{
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
NbTrack = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( data, "Nzone" ) == 0 )
|
|
|
|
{
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
NbZone = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( data, "Nmodule" ) == 0 )
|
|
|
|
{
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
NbMod = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( data, "Nnets" ) == 0 )
|
|
|
|
{
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
NbNets = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************************/
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
char Line[1024], * data;
|
|
|
|
|
|
|
|
while( GetLine( File, Line, LineNum ) != NULL )
|
|
|
|
{
|
|
|
|
strtok( Line, " =\n\r" );
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
|
|
|
|
if( stricmp( Line, "$EndSETUP" ) == 0 )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "AuxiliaryAxisOrg" ) == 0 )
|
|
|
|
{
|
|
|
|
int gx = 0, gy = 0;
|
|
|
|
gx = atoi( data );
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
if( data )
|
|
|
|
gy = atoi( data );
|
2007-10-13 06:18:44 +00:00
|
|
|
m_Auxiliary_Axis_Position.x = gx;
|
|
|
|
m_Auxiliary_Axis_Position.y = gy;
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
#ifdef PCBNEW
|
2007-08-06 02:02:39 +00:00
|
|
|
if( stricmp( Line, "Layers" ) == 0 )
|
|
|
|
{
|
|
|
|
int tmp;
|
|
|
|
sscanf( data, "%d", &tmp );
|
|
|
|
m_Pcb->m_BoardSettings->m_CopperLayerCount = tmp;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "TrackWidth" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_CurrentTrackWidth = atoi( data );
|
|
|
|
AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPETRACK );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "TrackWidthHistory" ) == 0 )
|
|
|
|
{
|
|
|
|
int tmp = atoi( data );
|
|
|
|
AddHistory( tmp, TYPETRACK );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "TrackClearence" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_TrackClearence = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "ZoneClearence" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_ZoneClearence = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "GridSize" ) == 0 )
|
|
|
|
{
|
|
|
|
wxSize Grid;
|
|
|
|
Grid.x = atoi( data );
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
if( data )
|
|
|
|
Grid.y = atoi( data );
|
|
|
|
else
|
|
|
|
Grid.y = Grid.x;
|
|
|
|
GetScreen()->SetGrid( Grid );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "ZoneGridSize" ) == 0 )
|
|
|
|
{
|
|
|
|
g_GridRoutingSize = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "UserGridSize" ) == 0 )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
if( data )
|
|
|
|
{
|
|
|
|
msg = CONV_FROM_UTF8( data );
|
|
|
|
msg.ToDouble( &g_UserGrid.x );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
if( data )
|
|
|
|
{
|
|
|
|
msg = CONV_FROM_UTF8( data );
|
|
|
|
msg.ToDouble( &g_UserGrid.y );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_UserGrid.y = g_UserGrid.x;
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
GetScreen()->m_UserGrid = g_UserGrid;
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
if( data )
|
|
|
|
{
|
|
|
|
if( stricmp( data, "mm" ) == 0 )
|
|
|
|
g_UserGrid_Unit = MILLIMETRE;
|
|
|
|
else
|
|
|
|
g_UserGrid_Unit = INCHES;
|
|
|
|
GetScreen()->m_UserGridUnit = g_UserGrid_Unit;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "DrawSegmWidth" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_DrawSegmentWidth = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "EdgeSegmWidth" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_EdgeSegmentWidth = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "ViaSize" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_CurrentViaSize = atoi( data );
|
|
|
|
AddHistory( g_DesignSettings.m_CurrentViaSize, TYPEVIA );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
if( stricmp( Line, "MicroViaSize" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_CurrentMicroViaSize = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
if( stricmp( Line, "ViaSizeHistory" ) == 0 )
|
|
|
|
{
|
|
|
|
int tmp = atoi( data );
|
|
|
|
AddHistory( tmp, TYPEVIA );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "ViaDrill" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_ViaDrill = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
if( stricmp( Line, "MicroViaDrill" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_MicroViaDrill = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "MicroViasAllowed" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_MicroViasAllowed = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
if( stricmp( Line, "TextPcbWidth" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_PcbTextWidth = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "TextPcbSize" ) == 0 )
|
|
|
|
{
|
|
|
|
g_DesignSettings.m_PcbTextSize.x = atoi( data );
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
g_DesignSettings.m_PcbTextSize.y = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "EdgeModWidth" ) == 0 )
|
|
|
|
{
|
|
|
|
ModuleSegmentWidth = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "TextModWidth" ) == 0 )
|
|
|
|
{
|
|
|
|
ModuleTextWidth = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "TextModSize" ) == 0 )
|
|
|
|
{
|
|
|
|
ModuleTextSize.x = atoi( data );
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
ModuleTextSize.y = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "PadSize" ) == 0 )
|
|
|
|
{
|
|
|
|
g_Pad_Master.m_Size.x = atoi( data );
|
|
|
|
data = strtok( NULL, " =\n\r" );
|
|
|
|
g_Pad_Master.m_Size.y = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( Line, "PadDrill" ) == 0 )
|
|
|
|
{
|
|
|
|
g_Pad_Master.m_Drill.x = atoi( data );
|
|
|
|
g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x;
|
|
|
|
continue;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef PCBNEW
|
|
|
|
/***************************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
static int WriteSetup( FILE* File, WinEDA_BasePcbFrame* frame )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
char text[1024];
|
|
|
|
int ii, jj;
|
|
|
|
|
|
|
|
fprintf( File, "$SETUP\n" );
|
|
|
|
sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
|
|
|
|
fprintf( File, text );
|
|
|
|
|
|
|
|
if( frame->GetScreen()->m_UserGridIsON )
|
|
|
|
ii = jj = -1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ii = frame->GetScreen()->GetGrid().x;
|
|
|
|
jj = frame->GetScreen()->GetGrid().y;
|
|
|
|
}
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
sprintf( text, "GridSize %d %d\n", ii, jj );
|
|
|
|
fprintf( File, text );
|
|
|
|
|
|
|
|
sprintf( text, "UserGridSize %lf %lf %s\n",
|
|
|
|
frame->GetScreen()->m_UserGrid.x, frame->GetScreen()->m_UserGrid.y,
|
|
|
|
( g_UserGrid_Unit == 0 ) ? "INCH" : "mm" );
|
|
|
|
fprintf( File, text );
|
|
|
|
|
|
|
|
fprintf( File, "ZoneGridSize %d\n", g_GridRoutingSize );
|
|
|
|
|
|
|
|
fprintf( File, "Layers %d\n", g_DesignSettings.m_CopperLayerCount );
|
|
|
|
fprintf( File, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth );
|
2008-01-26 02:02:27 +00:00
|
|
|
for( ii = 0; ii < HISTORY_NUMBER; ii++ )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2008-01-26 02:02:27 +00:00
|
|
|
if( g_DesignSettings.m_TrackWidthHistory[ii] == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
break;
|
|
|
|
fprintf( File, "TrackWidthHistory %d\n",
|
2008-01-26 02:02:27 +00:00
|
|
|
g_DesignSettings.m_TrackWidthHistory[ii] );
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf( File, "TrackClearence %d\n", g_DesignSettings.m_TrackClearence );
|
|
|
|
fprintf( File, "ZoneClearence %d\n", g_DesignSettings.m_ZoneClearence );
|
|
|
|
|
|
|
|
fprintf( File, "DrawSegmWidth %d\n", g_DesignSettings.m_DrawSegmentWidth );
|
|
|
|
fprintf( File, "EdgeSegmWidth %d\n", g_DesignSettings.m_EdgeSegmentWidth );
|
|
|
|
fprintf( File, "ViaSize %d\n", g_DesignSettings.m_CurrentViaSize );
|
|
|
|
fprintf( File, "ViaDrill %d\n", g_DesignSettings.m_ViaDrill );
|
2008-01-26 02:02:27 +00:00
|
|
|
for( ii = 0; ii < HISTORY_NUMBER; ii++ )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
|
|
|
if( g_DesignSettings.m_ViaSizeHistory[ii] == 0 )
|
|
|
|
break;
|
|
|
|
fprintf( File, "ViaSizeHistory %d\n", g_DesignSettings.m_ViaSizeHistory[ii] );
|
|
|
|
}
|
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
fprintf( File, "MicroViaSize %d\n", g_DesignSettings.m_CurrentMicroViaSize);
|
|
|
|
fprintf( File, "MicroViaDrill %d\n", g_DesignSettings.m_MicroViaDrill);
|
|
|
|
fprintf( File, "MicroViasAllowed %d\n", g_DesignSettings.m_MicroViasAllowed);
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
fprintf( File, "TextPcbWidth %d\n", g_DesignSettings.m_PcbTextWidth );
|
|
|
|
fprintf( File, "TextPcbSize %d %d\n",
|
|
|
|
g_DesignSettings.m_PcbTextSize.x, g_DesignSettings.m_PcbTextSize.y );
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
fprintf( File, "EdgeModWidth %d\n", ModuleSegmentWidth );
|
|
|
|
fprintf( File, "TextModSize %d %d\n", ModuleTextSize.x, ModuleTextSize.y );
|
|
|
|
fprintf( File, "TextModWidth %d\n", ModuleTextWidth );
|
|
|
|
fprintf( File, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y );
|
|
|
|
fprintf( File, "PadDrill %d\n", g_Pad_Master.m_Drill.x );
|
|
|
|
|
|
|
|
fprintf( File, "AuxiliaryAxisOrg %d %d\n",
|
|
|
|
frame->m_Auxiliary_Axis_Position.x, frame->m_Auxiliary_Axis_Position.y );
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
fprintf( File, "$EndSETUP\n\n" );
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************/
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
EDA_BaseStruct* PtStruct = m_Pcb->m_Modules;
|
|
|
|
int NbModules, NbDrawItem, NbLayers;
|
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/* Write copper layer count */
|
2007-08-06 02:02:39 +00:00
|
|
|
NbLayers = m_Pcb->m_BoardSettings->m_CopperLayerCount;
|
|
|
|
fprintf( File, "$GENERAL\n" );
|
|
|
|
fprintf( File, "LayerCount %d\n", NbLayers );
|
|
|
|
|
|
|
|
// Write old format for Layer count (for compatibility with old versions of pcbnew
|
|
|
|
fprintf( File, "Ly %8X\n", g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS ); // For compatibility with old version of pcbnew
|
|
|
|
fprintf( File, "Links %d\n", m_Pcb->m_NbLinks );
|
|
|
|
fprintf( File, "NoConn %d\n", m_Pcb->m_NbNoconnect );
|
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/* Write Bounding box info */
|
2007-08-06 02:02:39 +00:00
|
|
|
m_Pcb->ComputeBoundaryBox();
|
|
|
|
fprintf( File, "Di %d %d %d %d\n",
|
|
|
|
m_Pcb->m_BoundaryBox.GetX(), m_Pcb->m_BoundaryBox.GetY(),
|
|
|
|
m_Pcb->m_BoundaryBox.GetRight(),
|
|
|
|
m_Pcb->m_BoundaryBox.GetBottom() );
|
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/* Write segment count for footprints, drawings, track and zones */
|
|
|
|
/* Calculate the footprint count */
|
|
|
|
for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
|
|
|
NbModules++;
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
PtStruct = m_Pcb->m_Drawings; NbDrawItem = 0;
|
|
|
|
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
|
|
|
NbDrawItem++;
|
|
|
|
|
|
|
|
fprintf( File, "Ndraw %d\n", NbDrawItem );
|
|
|
|
fprintf( File, "Ntrack %d\n", m_Pcb->GetNumSegmTrack() );
|
|
|
|
fprintf( File, "Nzone %d\n", m_Pcb->GetNumSegmZone() );
|
|
|
|
|
|
|
|
fprintf( File, "Nmodule %d\n", NbModules );
|
|
|
|
fprintf( File, "Nnets %d\n", m_Pcb->m_NbNets );
|
|
|
|
|
|
|
|
fprintf( File, "$EndGENERAL\n\n" );
|
|
|
|
return TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************/
|
2007-12-03 06:54:19 +00:00
|
|
|
/** Function WriteSheetDescr
|
|
|
|
* Save the page information (size, texts, date ..)
|
|
|
|
* @param screen BASE_SCREEN to save
|
|
|
|
* @param File = an openen FILE to write info
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
Ki_PageDescr* sheet = screen->m_CurrentSheetDesc;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
fprintf( File, "$SHEETDESCR\n" );
|
|
|
|
fprintf( File, "Sheet %s %d %d\n",
|
|
|
|
CONV_TO_UTF8( sheet->m_Name ), sheet->m_Size.x, sheet->m_Size.y );
|
|
|
|
fprintf( File, "Title \"%s\"\n", CONV_TO_UTF8( screen->m_Title ) );
|
|
|
|
fprintf( File, "Date \"%s\"\n", CONV_TO_UTF8( screen->m_Date ) );
|
|
|
|
fprintf( File, "Rev \"%s\"\n", CONV_TO_UTF8( screen->m_Revision ) );
|
|
|
|
fprintf( File, "Comp \"%s\"\n", CONV_TO_UTF8( screen->m_Company ) );
|
|
|
|
fprintf( File, "Comment1 \"%s\"\n", CONV_TO_UTF8( screen->m_Commentaire1 ) );
|
|
|
|
fprintf( File, "Comment2 \"%s\"\n", CONV_TO_UTF8( screen->m_Commentaire2 ) );
|
|
|
|
fprintf( File, "Comment3 \"%s\"\n", CONV_TO_UTF8( screen->m_Commentaire3 ) );
|
|
|
|
fprintf( File, "Comment4 \"%s\"\n", CONV_TO_UTF8( screen->m_Commentaire4 ) );
|
|
|
|
|
|
|
|
fprintf( File, "$EndSHEETDESCR\n\n" );
|
|
|
|
return TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
static bool ReadSheetDescr( BASE_SCREEN* screen, FILE* File, int* LineNum )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************************/
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
char Line[1024], buf[1024], * text;
|
|
|
|
|
|
|
|
while( GetLine( File, Line, LineNum ) != NULL )
|
|
|
|
{
|
|
|
|
if( strnicmp( Line, "$End", 4 ) == 0 )
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if( strnicmp( Line, "Sheet", 4 ) == 0 )
|
|
|
|
{
|
|
|
|
text = strtok( Line, " \t\n\r" );
|
|
|
|
text = strtok( NULL, " \t\n\r" );
|
|
|
|
Ki_PageDescr* sheet = SheetList[0];
|
|
|
|
int ii;
|
|
|
|
for( ii = 0; sheet != NULL; ii++, sheet = SheetList[ii] )
|
|
|
|
{
|
|
|
|
if( stricmp( CONV_TO_UTF8( sheet->m_Name ), text ) == 0 )
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
screen->m_CurrentSheetDesc = sheet;
|
2007-08-06 02:02:39 +00:00
|
|
|
if( sheet == &g_Sheet_user )
|
|
|
|
{
|
|
|
|
text = strtok( NULL, " \t\n\r" );
|
|
|
|
if( text )
|
|
|
|
sheet->m_Size.x = atoi( text );
|
|
|
|
text = strtok( NULL, " \t\n\r" );
|
|
|
|
if( text )
|
|
|
|
sheet->m_Size.y = atoi( text );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "Title", 2 ) == 0 )
|
|
|
|
{
|
|
|
|
ReadDelimitedText( buf, Line, 256 );
|
|
|
|
screen->m_Title = CONV_FROM_UTF8( buf );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "Date", 2 ) == 0 )
|
|
|
|
{
|
|
|
|
ReadDelimitedText( buf, Line, 256 );
|
|
|
|
screen->m_Date = CONV_FROM_UTF8( buf );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "Rev", 2 ) == 0 )
|
|
|
|
{
|
|
|
|
ReadDelimitedText( buf, Line, 256 );
|
|
|
|
screen->m_Revision = CONV_FROM_UTF8( buf );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "Comp", 4 ) == 0 )
|
|
|
|
{
|
|
|
|
ReadDelimitedText( buf, Line, 256 );
|
|
|
|
screen->m_Company = CONV_FROM_UTF8( buf );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "Comment1", 8 ) == 0 )
|
|
|
|
{
|
|
|
|
ReadDelimitedText( buf, Line, 256 );
|
|
|
|
screen->m_Commentaire1 = CONV_FROM_UTF8( buf );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "Comment2", 8 ) == 0 )
|
|
|
|
{
|
|
|
|
ReadDelimitedText( buf, Line, 256 );
|
|
|
|
screen->m_Commentaire2 = CONV_FROM_UTF8( buf );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "Comment3", 8 ) == 0 )
|
|
|
|
{
|
|
|
|
ReadDelimitedText( buf, Line, 256 );
|
|
|
|
screen->m_Commentaire3 = CONV_FROM_UTF8( buf );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "Comment4", 8 ) == 0 )
|
|
|
|
{
|
|
|
|
ReadDelimitedText( buf, Line, 256 );
|
|
|
|
screen->m_Commentaire4 = CONV_FROM_UTF8( buf );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/** ReadPcbFile
|
|
|
|
* Read a board file <file>.brd
|
|
|
|
* @param Append if 0: a previoulsy loaded boar is delete before loadin the file.
|
|
|
|
* else all items of the board file are added to the existing board
|
2007-08-06 02:02:39 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
char Line[1024];
|
|
|
|
int LineNum = 0;
|
|
|
|
int nbsegm, nbmod;
|
2007-08-23 04:28:46 +00:00
|
|
|
BOARD_ITEM* LastStructPcb = NULL, * StructPcb;
|
2007-08-06 02:02:39 +00:00
|
|
|
MODULE* LastModule = NULL, * Module;
|
|
|
|
EQUIPOT* LastEquipot = NULL, * Equipot;
|
|
|
|
|
|
|
|
wxBusyCursor dummy;
|
|
|
|
|
|
|
|
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
|
|
|
|
setlocale( LC_NUMERIC, "C" );
|
|
|
|
|
|
|
|
NbDraw = NbTrack = NbZone = NbMod = NbNets = -1;
|
|
|
|
m_Pcb->m_NbNets = 0;
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
nbmod = 0;
|
|
|
|
|
|
|
|
if( Append )
|
|
|
|
{
|
|
|
|
LastModule = m_Pcb->m_Modules;
|
|
|
|
for( ; LastModule != NULL; LastModule = (MODULE*) LastModule->Pnext )
|
|
|
|
{
|
|
|
|
if( LastModule->Pnext == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
LastStructPcb = m_Pcb->m_Drawings;
|
2007-08-23 04:28:46 +00:00
|
|
|
for( ; LastStructPcb != NULL; LastStructPcb = LastStructPcb->Next() )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
|
|
|
if( LastStructPcb->Pnext == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
LastEquipot = m_Pcb->m_Equipots;
|
|
|
|
for( ; LastEquipot != NULL; LastEquipot = (EQUIPOT*) LastEquipot->Pnext )
|
|
|
|
{
|
|
|
|
if( LastEquipot->Pnext == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while( GetLine( File, Line, &LineNum ) != NULL )
|
|
|
|
{
|
|
|
|
if( strnicmp( Line, "$EndPCB", 6 ) == 0 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( strnicmp( Line, "$GENERAL", 8 ) == 0 )
|
|
|
|
{
|
2007-12-03 06:54:19 +00:00
|
|
|
ReadGeneralDescrPcb( File, &LineNum );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "$SHEETDESCR", 11 ) == 0 )
|
|
|
|
{
|
|
|
|
ReadSheetDescr( m_CurrentScreen, File, &LineNum );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "$SETUP", 6 ) == 0 )
|
|
|
|
{
|
|
|
|
if( !Append )
|
|
|
|
{
|
|
|
|
ReadSetup( File, &LineNum );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while( GetLine( File, Line, &LineNum ) != NULL )
|
|
|
|
if( strnicmp( Line, "$EndSETUP", 6 ) == 0 )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "$EQUIPOT", 7 ) == 0 )
|
|
|
|
{
|
|
|
|
Equipot = new EQUIPOT( m_Pcb );
|
|
|
|
Equipot->ReadEquipotDescr( File, &LineNum );
|
|
|
|
if( LastEquipot == NULL )
|
|
|
|
{
|
|
|
|
m_Pcb->m_Equipots = Equipot;
|
|
|
|
Equipot->Pback = m_Pcb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Equipot->Pback = LastEquipot;
|
|
|
|
LastEquipot->Pnext = Equipot;
|
|
|
|
}
|
|
|
|
LastEquipot = Equipot;
|
|
|
|
m_Pcb->m_NbNets++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
if( strnicmp( Line, "$CZONE_OUTLINE", 7 ) == 0 )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER * zone_descr = new ZONE_CONTAINER(m_Pcb);
|
|
|
|
zone_descr->ReadDescr( File, &LineNum );
|
2008-01-06 20:58:27 +00:00
|
|
|
m_Pcb->Add(zone_descr);
|
2008-02-07 06:49:16 +00:00
|
|
|
continue;
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
|
|
|
|
{
|
|
|
|
Module = new MODULE( m_Pcb );
|
|
|
|
if( Module == NULL )
|
|
|
|
continue;
|
|
|
|
Module->ReadDescr( File, &LineNum );
|
|
|
|
|
|
|
|
if( LastModule == NULL )
|
|
|
|
{
|
|
|
|
m_Pcb->m_Modules = Module;
|
|
|
|
Module->Pback = m_Pcb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Module->Pback = LastModule;
|
|
|
|
LastModule->Pnext = Module;
|
|
|
|
}
|
|
|
|
LastModule = Module;
|
|
|
|
nbmod++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "$TEXTPCB", 8 ) == 0 )
|
|
|
|
{
|
|
|
|
TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_Pcb );
|
2007-08-23 04:28:46 +00:00
|
|
|
StructPcb = pcbtxt;
|
2007-08-06 02:02:39 +00:00
|
|
|
pcbtxt->ReadTextePcbDescr( File, &LineNum );
|
|
|
|
if( LastStructPcb == NULL )
|
|
|
|
{
|
|
|
|
m_Pcb->m_Drawings = StructPcb;
|
|
|
|
StructPcb->Pback = m_Pcb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StructPcb->Pback = LastStructPcb;
|
|
|
|
LastStructPcb->Pnext = StructPcb;
|
|
|
|
}
|
|
|
|
LastStructPcb = StructPcb;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "$DRAWSEGMENT", 10 ) == 0 )
|
|
|
|
{
|
|
|
|
DRAWSEGMENT* DrawSegm = new DRAWSEGMENT( m_Pcb );
|
|
|
|
DrawSegm->ReadDrawSegmentDescr( File, &LineNum );
|
|
|
|
if( LastStructPcb == NULL )
|
|
|
|
{
|
|
|
|
m_Pcb->m_Drawings = DrawSegm;
|
|
|
|
DrawSegm->Pback = m_Pcb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawSegm->Pback = LastStructPcb;
|
|
|
|
LastStructPcb->Pnext = DrawSegm;
|
|
|
|
}
|
|
|
|
LastStructPcb = DrawSegm;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( strnicmp( Line, "$COTATION", 9 ) == 0 )
|
|
|
|
{
|
|
|
|
COTATION* Cotation = new COTATION( m_Pcb );
|
|
|
|
Cotation->ReadCotationDescr( File, &LineNum );
|
|
|
|
if( LastStructPcb == NULL )
|
|
|
|
{
|
|
|
|
m_Pcb->m_Drawings = Cotation;
|
|
|
|
Cotation->Pback = m_Pcb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Cotation->Pback = LastStructPcb;
|
|
|
|
LastStructPcb->Pnext = Cotation;
|
|
|
|
}
|
|
|
|
LastStructPcb = Cotation;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "$MIREPCB", 8 ) == 0 )
|
|
|
|
{
|
|
|
|
MIREPCB* Mire = new MIREPCB( m_Pcb );
|
|
|
|
Mire->ReadMirePcbDescr( File, &LineNum );
|
|
|
|
|
|
|
|
if( LastStructPcb == NULL )
|
|
|
|
{
|
|
|
|
m_Pcb->m_Drawings = Mire;
|
|
|
|
Mire->Pback = m_Pcb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Mire->Pback = LastStructPcb;
|
|
|
|
LastStructPcb->Pnext = Mire;
|
|
|
|
}
|
|
|
|
LastStructPcb = Mire;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "$TRACK", 6 ) == 0 )
|
|
|
|
{
|
|
|
|
TRACK* StartTrack = m_Pcb->m_Track;
|
|
|
|
nbsegm = 0;
|
|
|
|
|
|
|
|
if( Append )
|
|
|
|
{
|
2007-11-15 10:09:12 +00:00
|
|
|
for( ; StartTrack != NULL; StartTrack = StartTrack->Next() )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
|
|
|
if( StartTrack->Pnext == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifdef PCBNEW
|
2007-12-03 06:54:19 +00:00
|
|
|
int ii = ReadListeSegmentDescr( File, StartTrack, TYPETRACK,
|
2007-08-06 02:02:39 +00:00
|
|
|
&LineNum, NbTrack );
|
|
|
|
m_Pcb->m_NbSegmTrack += ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( Line, "$ZONE", 5 ) == 0 )
|
|
|
|
{
|
2007-11-15 10:09:12 +00:00
|
|
|
SEGZONE* StartZone = m_Pcb->m_Zone;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
if( Append )
|
|
|
|
{
|
2007-11-15 10:09:12 +00:00
|
|
|
for( ; StartZone != NULL; StartZone = StartZone->Next() )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
|
|
|
if( StartZone->Pnext == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifdef PCBNEW
|
2007-12-03 06:54:19 +00:00
|
|
|
int ii = ReadListeSegmentDescr( File, StartZone, TYPEZONE,
|
2007-08-06 02:02:39 +00:00
|
|
|
&LineNum, NbZone );
|
|
|
|
m_Pcb->m_NbSegmZone += ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
setlocale( LC_NUMERIC, "" ); // revert to the current locale
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
Affiche_Message( wxEmptyString );
|
2007-12-03 06:54:19 +00:00
|
|
|
|
|
|
|
BestZoom();
|
|
|
|
DrawPanel->ReDraw(DC, true);
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifdef PCBNEW
|
2007-08-06 02:02:39 +00:00
|
|
|
Compile_Ratsnest( DC, TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2007-08-06 02:02:39 +00:00
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef PCBNEW
|
|
|
|
/***************************************************/
|
2007-10-30 21:30:58 +00:00
|
|
|
int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine de sauvegarde du PCB courant sous format ASCII
|
2007-08-06 02:02:39 +00:00
|
|
|
* retourne
|
|
|
|
* 1 si OK
|
|
|
|
* 0 si sauvegarde non faite
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-30 21:30:58 +00:00
|
|
|
bool rc;
|
|
|
|
char line[256];
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
m_Pcb->m_Status_Pcb &= ~CONNEXION_OK;
|
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
wxBeginBusyCursor();
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
|
|
|
|
setlocale( LC_NUMERIC, "C" );
|
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
/* Ecriture de l'entete PCB : */
|
|
|
|
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
|
|
|
|
DateAndTime( line ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
WriteGeneralDescrPcb( aFile );
|
|
|
|
WriteSheetDescr( m_CurrentScreen, aFile );
|
|
|
|
WriteSetup( aFile, this );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
rc = m_Pcb->Save( aFile );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
setlocale( LC_NUMERIC, "" ); // revert to the current locale
|
|
|
|
wxEndBusyCursor();
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
if( !rc )
|
|
|
|
DisplayError( this, wxT( "Unable to save PCB file" ) );
|
|
|
|
else
|
|
|
|
Affiche_Message( wxEmptyString );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
return rc;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
#endif
|