beautification

This commit is contained in:
dickelbeck 2007-09-21 13:23:51 +00:00
parent 63cf8c53f2
commit 00bda3c9a0
5 changed files with 963 additions and 839 deletions

View File

@ -136,12 +136,16 @@ void LoadLibraries( WinEDA_DrawFrame* frame )
if( LibName.IsEmpty() ) if( LibName.IsEmpty() )
continue; continue;
FullLibName = MakeFileName( g_RealLibDirBuffer, LibName, g_LibExtBuffer ); FullLibName = MakeFileName( g_RealLibDirBuffer, LibName, g_LibExtBuffer );
msg = wxT( "Loading " ) + FullLibName; msg = wxT( "Loading " ) + FullLibName;
if( LoadLibraryName( frame, FullLibName, LibName ) ) if( LoadLibraryName( frame, FullLibName, LibName ) )
msg += wxT( " OK" ); msg += wxT( " OK" );
else else
msg += wxT( " ->Error" ); msg += wxT( " ->Error" );
frame->PrintMsg( msg ); frame->PrintMsg( msg );
} }
@ -348,7 +352,10 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
*/ */
{ {
int unused; int unused;
char* p, * Name, * Prefix = NULL; char* p;
char* name;
char* prefix = NULL;
EDA_LibComponentStruct* LibEntry = NULL; EDA_LibComponentStruct* LibEntry = NULL;
bool Res; bool Res;
wxString Msg; wxString Msg;
@ -366,8 +373,8 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
char drawnum = 0, drawname = 0; char drawnum = 0, drawname = 0;
LibEntry = new EDA_LibComponentStruct( NULL ); LibEntry = new EDA_LibComponentStruct( NULL );
if( ( Name = strtok( NULL, " \t\n" ) ) == NULL /* Part name: */ if( ( name = strtok( NULL, " \t\n" ) ) == NULL /* Part name: */
|| ( Prefix = strtok( NULL, " \t\n" ) ) == NULL /* Prefix name: */ || ( prefix = strtok( NULL, " \t\n" ) ) == NULL /* Prefix name: */
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */
|| sscanf( p, "%d", &unused ) != 1 || sscanf( p, "%d", &unused ) != 1
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */
@ -394,23 +401,24 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
{ {
LibEntry->m_DrawPinNum = (drawnum == 'N') ? FALSE : TRUE; LibEntry->m_DrawPinNum = (drawnum == 'N') ? FALSE : TRUE;
LibEntry->m_DrawPinName = (drawname == 'N') ? FALSE : TRUE; LibEntry->m_DrawPinName = (drawname == 'N') ? FALSE : TRUE;
/* Copy part name and prefix. */ /* Copy part name and prefix. */
strupper( Name ); strupper( name );
if( Name[0] != '~' ) if( name[0] != '~' )
LibEntry->m_Name.m_Text = CONV_FROM_UTF8( Name ); LibEntry->m_Name.m_Text = CONV_FROM_UTF8( name );
else else
{ {
LibEntry->m_Name.m_Text = CONV_FROM_UTF8( &Name[1] ); LibEntry->m_Name.m_Text = CONV_FROM_UTF8( &name[1] );
LibEntry->m_Name.m_Attributs |= TEXT_NO_VISIBLE; LibEntry->m_Name.m_Attributs |= TEXT_NO_VISIBLE;
} }
if( strcmp( Prefix, "~" ) == 0 ) if( strcmp( prefix, "~" ) == 0 )
{ {
LibEntry->m_Prefix.m_Text.Empty(); LibEntry->m_Prefix.m_Text.Empty();
LibEntry->m_Prefix.m_Attributs |= TEXT_NO_VISIBLE; LibEntry->m_Prefix.m_Attributs |= TEXT_NO_VISIBLE;
} }
else else
LibEntry->m_Prefix.m_Text = CONV_FROM_UTF8( Prefix ); LibEntry->m_Prefix.m_Text = CONV_FROM_UTF8( prefix );
// Copy optional infos // Copy optional infos
if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) // m_UnitSelectionLocked param if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) // m_UnitSelectionLocked param
@ -525,7 +533,10 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
&Arc->m_Width, chartmp, &startx, &starty, &endx, &endy ); &Arc->m_Width, chartmp, &startx, &starty, &endx, &endy );
if( nbarg < 8 ) if( nbarg < 8 )
Error = TRUE; Error = TRUE;
Arc->m_Unit = Unit; Arc->m_Convert = Convert;
Arc->m_Unit = Unit;
Arc->m_Convert = Convert;
if( chartmp[0] == 'F' ) if( chartmp[0] == 'F' )
Arc->m_Fill = FILLED_SHAPE; Arc->m_Fill = FILLED_SHAPE;
if( chartmp[0] == 'f' ) if( chartmp[0] == 'f' )
@ -625,8 +636,11 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
Pin->m_PinLen = ll; Pin->m_PinLen = ll;
Pin->m_Orient = chartmp1[0] & 255; Pin->m_Orient = chartmp1[0] & 255;
Pin->m_Unit = Unit; Pin->m_Convert = Convert; Pin->m_Unit = Unit;
Pin->m_Convert = Convert;
strncpy( (char*) &Pin->m_PinNum, PinNum, 4 ); strncpy( (char*) &Pin->m_PinNum, PinNum, 4 );
Error = (i != 11 && i != 12); Error = (i != 11 && i != 12);
Pin->m_PinName = CONV_FROM_UTF8( BufName ); Pin->m_PinName = CONV_FROM_UTF8( BufName );
@ -672,6 +686,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
} }
if( i == 12 ) /* Special Symbole defined */ if( i == 12 ) /* Special Symbole defined */
{
for( jj = strlen( Buffer ); jj > 0; ) for( jj = strlen( Buffer ); jj > 0; )
{ {
switch( Buffer[--jj] ) switch( Buffer[--jj] )
@ -700,6 +715,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
DisplayError( frame, MsgLine ); break; DisplayError( frame, MsgLine ); break;
} }
} }
}
} }
break; break;
@ -852,7 +868,8 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
if( *line == 0 ) if( *line == 0 )
return 0; return 0;
line++; Text = line; line++;
Text = line;
/* recherche fin de texte */ /* recherche fin de texte */
while( *line && (*line != '"') ) while( *line && (*line != '"') )
@ -860,17 +877,23 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
if( *line == 0 ) if( *line == 0 )
return 0; return 0;
*line = 0; line++; *line = 0;
line++;
FieldUserName[0] = 0; FieldUserName[0] = 0;
nbparam = sscanf( line, " %d %d %d %c %c %c %c", nbparam = sscanf( line, " %d %d %d %c %c %c %c",
&posx, &posy, &size, Char1, Char2, Char3, Char4 ); &posx, &posy, &size, Char1, Char2, Char3, Char4 );
orient = TEXT_ORIENT_HORIZ; if( Char1[0] == 'V' ) orient = TEXT_ORIENT_HORIZ;
if( Char1[0] == 'V' )
orient = TEXT_ORIENT_VERT; orient = TEXT_ORIENT_VERT;
draw = TRUE; if( Char2[0] == 'I' ) draw = TRUE; if( Char2[0] == 'I' )
draw = FALSE; draw = FALSE;
hjustify = GR_TEXT_HJUSTIFY_CENTER; hjustify = GR_TEXT_HJUSTIFY_CENTER;
vjustify = GR_TEXT_VJUSTIFY_CENTER; vjustify = GR_TEXT_VJUSTIFY_CENTER;
if( nbparam >= 6 ) if( nbparam >= 6 )
{ {
if( *Char3 == 'L' ) if( *Char3 == 'L' )
@ -898,6 +921,7 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
default: default:
if( NumOfField >= NUMBER_OF_FIELDS ) if( NumOfField >= NUMBER_OF_FIELDS )
break; break;
Field = new LibDrawField( NumOfField ); Field = new LibDrawField( NumOfField );
Field->Pnext = LibEntry->Fields; Field->Pnext = LibEntry->Fields;
@ -910,15 +934,19 @@ static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
Field->m_Pos.x = posx; Field->m_Pos.y = posy; Field->m_Pos.x = posx; Field->m_Pos.y = posy;
Field->m_Orient = orient; Field->m_Orient = orient;
if( draw == FALSE ) if( draw == FALSE )
Field->m_Attributs |= TEXT_NO_VISIBLE; Field->m_Attributs |= TEXT_NO_VISIBLE;
Field->m_Size.x = Field->m_Size.y = size; Field->m_Size.x = Field->m_Size.y = size;
Field->m_Text = CONV_FROM_UTF8( Text ); Field->m_Text = CONV_FROM_UTF8( Text );
if( NumOfField >= FIELD1 ) if( NumOfField >= FIELD1 )
{ {
ReadDelimitedText( FieldUserName, line, sizeof(FieldUserName) ); ReadDelimitedText( FieldUserName, line, sizeof(FieldUserName) );
Field->m_Name = CONV_FROM_UTF8( FieldUserName ); Field->m_Name = CONV_FROM_UTF8( FieldUserName );
} }
Field->m_HJustify = hjustify; Field->m_HJustify = hjustify;
Field->m_VJustify = vjustify; Field->m_VJustify = vjustify;
return TRUE; return TRUE;
@ -992,7 +1020,8 @@ int LoadDocLib( WinEDA_DrawFrame* frame, const wxString& FullDocLibName, const w
return 0; return 0;
if( GetLine( f, Line, &LineNum, sizeof(Line) ) == NULL ) if( GetLine( f, Line, &LineNum, sizeof(Line) ) == NULL )
{ /* pas de lignes utiles */ {
/* pas de lignes utiles */
fclose( f ); fclose( f );
return 0; return 0;
} }
@ -1100,6 +1129,7 @@ void EDA_LibComponentStruct::SortDrawItems()
BufentryBase = BufentryBase =
(LibEDA_BaseStruct**) MyZMalloc( (nbitems + 1) * sizeof(LibEDA_BaseStruct *) ); (LibEDA_BaseStruct**) MyZMalloc( (nbitems + 1) * sizeof(LibEDA_BaseStruct *) );
/* memorisation du chainage : */ /* memorisation du chainage : */
for( Entry = m_Drawings, ii = 0; Entry != NULL; Entry = Entry->Next() ) for( Entry = m_Drawings, ii = 0; Entry != NULL; Entry = Entry->Next() )
BufentryBase[ii++] = Entry; BufentryBase[ii++] = Entry;

View File

@ -440,7 +440,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
screen->EEDrawList = Phead; screen->EEDrawList = Phead;
#if defined(DEBUG) #if 0 && defined(DEBUG)
screen->Show( 0, std::cout ); screen->Show( 0, std::cout );
#endif #endif

View File

@ -32,20 +32,18 @@ static void EraseDuplicatePins(ObjetNetListStruct **TabPin, int NbrPin);
static void ClearUsedFlags( WinEDA_SchematicFrame* frame ); static void ClearUsedFlags( WinEDA_SchematicFrame* frame );
/* Variable locales */ /* Variable locales */
static int s_SortedPinCount; static int s_SortedPinCount;
static ObjetNetListStruct** s_SortedComponentPinList; static ObjetNetListStruct** s_SortedComponentPinList;
/******************************************************************************/ /******************************************************************************/
void WriteNetList( WinEDA_SchematicFrame* frame, const wxString& FileNameNL, void WriteNetList( WinEDA_SchematicFrame* frame, const wxString& FileNameNL,
bool use_netnames ) bool use_netnames )
/*******************************************************************************/ /*******************************************************************************/
/* Create the netlist file ( Format is given by g_NetFormat ) /* Create the netlist file ( Format is given by g_NetFormat )
bool use_netnames is used only for Spice netlist * bool use_netnames is used only for Spice netlist
*/ */
{ {
FILE* f = NULL; FILE* f = NULL;
@ -106,13 +104,14 @@ wxBusyCursor Busy;
static EDA_SchComponentStruct* FindNextComponentAndCreatPinList( static EDA_SchComponentStruct* FindNextComponentAndCreatPinList(
EDA_BaseStruct* DrawList ) EDA_BaseStruct* DrawList )
/****************************************************************************/ /****************************************************************************/
/* Find a "suitable" component from the DrawList
build its pin list s_SortedComponentPinList.
The list is sorted by pin num
A suitable component is a "new" real component (power symbols are not considered)
alloc memory for s_SortedComponentPinList if s_SortedComponentPinList == NULL /* Find a "suitable" component from the DrawList
Must be deallocated by the user * build its pin list s_SortedComponentPinList.
* The list is sorted by pin num
* A suitable component is a "new" real component (power symbols are not considered)
*
* alloc memory for s_SortedComponentPinList if s_SortedComponentPinList == NULL
* Must be deallocated by the user
*/ */
{ {
EDA_SchComponentStruct* Component = NULL; EDA_SchComponentStruct* Component = NULL;
@ -123,18 +122,22 @@ LibEDA_BaseStruct *DEntry;
for( ; DrawList != NULL; DrawList = DrawList->Next() ) for( ; DrawList != NULL; DrawList = DrawList->Next() )
{ {
if ( DrawList->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) continue; if( DrawList->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
continue;
Component = (EDA_SchComponentStruct*) DrawList; Component = (EDA_SchComponentStruct*) DrawList;
/* already tested ? : */ /* already tested ? : */
if( Component->m_FlagControlMulti == 1 ) continue; /* yes */ if( Component->m_FlagControlMulti == 1 )
continue; /* yes */
Entry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); Entry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
if( Entry == NULL) continue; if( Entry == NULL )
continue;
/* Power symbol and other component which have the reference starting by /* Power symbol and other component which have the reference starting by
"#" are not included in netlist (pseudo components) */ * "#" are not included in netlist (pseudo components) */
if( Component->m_Field[REFERENCE].m_Text[0] == '#' ) continue; if( Component->m_Field[REFERENCE].m_Text[0] == '#' )
continue;
/* Create the pin table for this component */ /* Create the pin table for this component */
int ii = sizeof(ObjetNetListStruct) * MAXPIN; int ii = sizeof(ObjetNetListStruct) * MAXPIN;
@ -145,11 +148,14 @@ LibEDA_BaseStruct *DEntry;
DEntry = Entry->m_Drawings; DEntry = Entry->m_Drawings;
for( ; DEntry != NULL; DEntry = DEntry->Next() ) for( ; DEntry != NULL; DEntry = DEntry->Next() )
{ {
if ( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE) continue; if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE )
if( DEntry->m_Unit && continue;
(DEntry->m_Unit != Component->m_Multi) ) continue; if( DEntry->m_Unit
if( DEntry->m_Convert && && (DEntry->m_Unit != Component->m_Multi) )
(DEntry->m_Convert != Component->m_Convert)) continue; continue;
if( DEntry->m_Convert
&& (DEntry->m_Convert != Component->m_Convert) )
continue;
{ {
AddPinToComponentPinList( Component, (LibDrawPin*) DEntry ); AddPinToComponentPinList( Component, (LibDrawPin*) DEntry );
} }
@ -157,7 +163,8 @@ LibEDA_BaseStruct *DEntry;
Component->m_FlagControlMulti = 1; Component->m_FlagControlMulti = 1;
if (Entry->m_UnitCount > 1) FindOthersUnits(Component); if( Entry->m_UnitCount > 1 )
FindOthersUnits( Component );
/* Tri sur le numero de Pin de TabListePin */ /* Tri sur le numero de Pin de TabListePin */
qsort( s_SortedComponentPinList, s_SortedPinCount, sizeof(ObjetNetListStruct*), qsort( s_SortedComponentPinList, s_SortedPinCount, sizeof(ObjetNetListStruct*),
@ -172,15 +179,17 @@ LibEDA_BaseStruct *DEntry;
return NULL; return NULL;
} }
/**************************************************************************************/ /**************************************************************************************/
static wxString ReturnPinNetName( ObjetNetListStruct* Pin, static wxString ReturnPinNetName( ObjetNetListStruct* Pin,
const wxString& DefaultFormatNetname ) const wxString& DefaultFormatNetname )
/**************************************************************************************/ /**************************************************************************************/
/* Return the net name for the pin Pin. /* Return the net name for the pin Pin.
Net name is: * Net name is:
"?" if pin not connected * "?" if pin not connected
"netname" for global net (like gnd, vcc .. * "netname" for global net (like gnd, vcc ..
"netname_sheetnumber" for the usual nets * "netname_sheetnumber" for the usual nets
*/ */
{ {
int netcode = Pin->m_NetCode; int netcode = Pin->m_NetCode;
@ -195,10 +204,12 @@ wxString NetName;
int jj; int jj;
for( jj = 0; jj < g_NbrObjNet; jj++ ) for( jj = 0; jj < g_NbrObjNet; jj++ )
{ {
if( g_TabObjNet[jj].m_NetCode != netcode) continue; if( g_TabObjNet[jj].m_NetCode != netcode )
if( ( g_TabObjNet[jj].m_Type != NET_GLOBLABEL) && continue;
( g_TabObjNet[jj].m_Type != NET_LABEL) && if( ( g_TabObjNet[jj].m_Type != NET_GLOBLABEL)
( g_TabObjNet[jj].m_Type != NET_PINLABEL) ) continue; && ( g_TabObjNet[jj].m_Type != NET_LABEL)
&& ( g_TabObjNet[jj].m_Type != NET_PINLABEL) )
continue;
NetName = *g_TabObjNet[jj].m_Label; NetName = *g_TabObjNet[jj].m_Label;
break; break;
@ -217,12 +228,14 @@ wxString NetName;
return NetName; return NetName;
} }
/***********************************************************************/ /***********************************************************************/
void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
const wxString& FullFileName ) const wxString& FullFileName )
/***********************************************************************/ /***********************************************************************/
/* Create a generic netlist, and call an external netlister /* Create a generic netlist, and call an external netlister
to change the netlist syntax and create the file * to change the netlist syntax and create the file
*/ */
{ {
wxString Line, FootprintName; wxString Line, FootprintName;
@ -253,7 +266,8 @@ wxString TmpFullFileName = FullFileName;
for( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) for( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext )
{ {
DrawList = Component = FindNextComponentAndCreatPinList( DrawList ); DrawList = Component = FindNextComponentAndCreatPinList( DrawList );
if ( Component == NULL ) break; // No component left if( Component == NULL )
break; // No component left
FootprintName.Empty(); FootprintName.Empty();
if( !Component->m_Field[FOOTPRINT].IsVoid() ) if( !Component->m_Field[FOOTPRINT].IsVoid() )
@ -282,9 +296,11 @@ wxString TmpFullFileName = FullFileName;
for( ii = 0; ii < s_SortedPinCount; ii++ ) for( ii = 0; ii < s_SortedPinCount; ii++ )
{ {
ObjetNetListStruct* Pin = s_SortedComponentPinList[ii]; ObjetNetListStruct* Pin = s_SortedComponentPinList[ii];
if( ! Pin ) continue; if( !Pin )
continue;
netname = ReturnPinNetName( Pin, wxT( "$-%.6d" ) ); netname = ReturnPinNetName( Pin, wxT( "$-%.6d" ) );
if ( netname.IsEmpty() ) netname = wxT("?"); if( netname.IsEmpty() )
netname = wxT( "?" );
fprintf( tmpfile, "%.4s=%s\n", (char*) &Pin->m_PinNum, fprintf( tmpfile, "%.4s=%s\n", (char*) &Pin->m_PinNum,
CONV_TO_UTF8( netname ) ); CONV_TO_UTF8( netname ) );
} }
@ -307,18 +323,19 @@ wxString TmpFullFileName = FullFileName;
// Call the external module (plug in ) // Call the external module (plug in )
if ( g_NetListerCommandLine.IsEmpty() ) return; if( g_NetListerCommandLine.IsEmpty() )
return;
wxString CommandFile; wxString CommandFile;
if( wxIsAbsolutePath( g_NetListerCommandLine ) ) if( wxIsAbsolutePath( g_NetListerCommandLine ) )
CommandFile = g_NetListerCommandLine; CommandFile = g_NetListerCommandLine;
else CommandFile = FindKicadFile(g_NetListerCommandLine); else
CommandFile = FindKicadFile( g_NetListerCommandLine );
CommandFile += wxT( " " ) + TmpFullFileName; CommandFile += wxT( " " ) + TmpFullFileName;
CommandFile += wxT( " " ) + FullFileName; CommandFile += wxT( " " ) + FullFileName;
wxExecute( CommandFile, wxEXEC_SYNC ); wxExecute( CommandFile, wxEXEC_SYNC );
} }
@ -331,6 +348,7 @@ SCH_SCREEN *screen;
EDA_BaseStruct* DrawList; EDA_BaseStruct* DrawList;
EDA_ScreenList ScreenList( NULL ); EDA_ScreenList ScreenList( NULL );
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{ {
DrawList = screen->EEDrawList; DrawList = screen->EEDrawList;
@ -346,18 +364,20 @@ EDA_BaseStruct *DrawList;
} }
} }
/*************************************************************/ /*************************************************************/
static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
bool use_netnames ) bool use_netnames )
/*************************************************************/ /*************************************************************/
/* Routine de generation du fichier netliste ( Format PSPICE )
si use_netnames = TRUE
les nodes sont identifies par le netname
sinon les nodes sont identifies par le netnumber
tous les textes graphiques commençant par [.-+]pspice ou [.-+]gnucap /* Routine de generation du fichier netliste ( Format PSPICE )
sont considérés comme des commandes a placer dans la netliste * si use_netnames = TRUE
[.-]pspice ou gnucap sont en debut * les nodes sont identifies par le netname
* sinon les nodes sont identifies par le netnumber
*
* tous les textes graphiques commençant par [.-+]pspice ou [.-+]gnucap
* sont considérés comme des commandes a placer dans la netliste
* [.-]pspice ou gnucap sont en debut
+pspice et +gnucap sont en fin de netliste +pspice et +gnucap sont en fin de netliste
*/ */
{ {
@ -369,6 +389,7 @@ int ii, nbitems;
wxString text; wxString text;
wxArrayString SpiceCommandAtBeginFile, SpiceCommandAtEndFile; wxArrayString SpiceCommandAtBeginFile, SpiceCommandAtEndFile;
wxString msg; wxString msg;
#define BUFYPOS_LEN 4 #define BUFYPOS_LEN 4
wxChar bufnum[BUFYPOS_LEN + 1]; wxChar bufnum[BUFYPOS_LEN + 1];
@ -379,31 +400,38 @@ wxChar bufnum[BUFYPOS_LEN+1];
/* and create text list starting by [+]pspice , or [+]gnucap (simulator commands) */ /* and create text list starting by [+]pspice , or [+]gnucap (simulator commands) */
bufnum[BUFYPOS_LEN] = 0; bufnum[BUFYPOS_LEN] = 0;
EDA_ScreenList ScreenList( NULL ); EDA_ScreenList ScreenList( NULL );
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{ {
for( DrawList = screen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) for( DrawList = screen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext )
{ {
wxChar ident; wxChar ident;
if ( DrawList->Type() != DRAW_TEXT_STRUCT_TYPE ) continue; if( DrawList->Type() != DRAW_TEXT_STRUCT_TYPE )
continue;
#define DRAWTEXT ( (DrawTextStruct*) DrawList ) #define DRAWTEXT ( (DrawTextStruct*) DrawList )
text = DRAWTEXT->m_Text; if ( text.IsEmpty() ) continue; text = DRAWTEXT->m_Text; if( text.IsEmpty() )
continue;
ident = text.GetChar( 0 ); ident = text.GetChar( 0 );
if ( ident != '.' && ident != '-' && ident != '+' ) continue; if( ident != '.' && ident != '-' && ident != '+' )
continue;
text.Remove( 0, 1 ); //Remove the first char. text.Remove( 0, 1 ); //Remove the first char.
text.Remove( 6 ); //text contains 6 char. text.Remove( 6 ); //text contains 6 char.
if( ( text == wxT( "pspice" ) ) || ( text == wxT( "gnucap" ) ) ) if( ( text == wxT( "pspice" ) ) || ( text == wxT( "gnucap" ) ) )
{ {
/* Put the Y position as an ascii string, for sort by vertical position, /* Put the Y position as an ascii string, for sort by vertical position,
using usual sort string by alphabetic value */ * using usual sort string by alphabetic value */
int ypos = DRAWTEXT->m_Pos.y; int ypos = DRAWTEXT->m_Pos.y;
for( ii = 0; ii < BUFYPOS_LEN; ii++ ) for( ii = 0; ii < BUFYPOS_LEN; ii++ )
{ {
bufnum[BUFYPOS_LEN - 1 - ii] = (ypos & 63) + ' '; ypos >>= 6; bufnum[BUFYPOS_LEN - 1 - ii] = (ypos & 63) + ' '; ypos >>= 6;
} }
text = DRAWTEXT->m_Text.AfterFirst( ' ' ); text = DRAWTEXT->m_Text.AfterFirst( ' ' );
msg.Printf( wxT( "%s %s" ), bufnum, text.GetData() ); // First BUFYPOS_LEN char are the Y position msg.Printf( wxT( "%s %s" ), bufnum, text.GetData() ); // First BUFYPOS_LEN char are the Y position
if ( ident == '+' ) SpiceCommandAtEndFile.Add(msg); if( ident == '+' )
else SpiceCommandAtBeginFile.Add(msg); SpiceCommandAtEndFile.Add( msg );
else
SpiceCommandAtBeginFile.Add( msg );
} }
} }
} }
@ -431,7 +459,8 @@ wxChar bufnum[BUFYPOS_LEN+1];
for( DrawList = screen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) for( DrawList = screen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext )
{ {
DrawList = Component = FindNextComponentAndCreatPinList( DrawList ); DrawList = Component = FindNextComponentAndCreatPinList( DrawList );
if ( Component == NULL ) break; if( Component == NULL )
break;
fprintf( f, "%s ", CONV_TO_UTF8( Component->m_Field[REFERENCE].m_Text ) ); fprintf( f, "%s ", CONV_TO_UTF8( Component->m_Field[REFERENCE].m_Text ) );
@ -439,18 +468,23 @@ wxChar bufnum[BUFYPOS_LEN+1];
for( ii = 0; ii < s_SortedPinCount; ii++ ) for( ii = 0; ii < s_SortedPinCount; ii++ )
{ {
ObjetNetListStruct* Pin = s_SortedComponentPinList[ii]; ObjetNetListStruct* Pin = s_SortedComponentPinList[ii];
if( ! Pin ) continue; if( !Pin )
continue;
wxString NetName = ReturnPinNetName( Pin, wxT( "N-%.6d" ) ); wxString NetName = ReturnPinNetName( Pin, wxT( "N-%.6d" ) );
if ( NetName.IsEmpty() ) NetName = wxT("?"); if( NetName.IsEmpty() )
if( use_netnames) fprintf( f," %s", CONV_TO_UTF8(NetName)); NetName = wxT( "?" );
if( use_netnames )
fprintf( f, " %s", CONV_TO_UTF8( NetName ) );
else // Use number for net names (with net number = 0 for "GND" else // Use number for net names (with net number = 0 for "GND"
{ {
// NetName = "0" is "GND" net for Spice // NetName = "0" is "GND" net for Spice
if( NetName == wxT( "0" ) || NetName == wxT( "GND" ) ) if( NetName == wxT( "0" ) || NetName == wxT( "GND" ) )
fprintf( f, " 0" ); fprintf( f, " 0" );
else fprintf( f," %d", Pin->m_NetCode); else
fprintf( f, " %d", Pin->m_NetCode );
} }
} }
fprintf( f, " %s\n", CONV_TO_UTF8( Component->m_Field[VALUE].m_Text ) ); fprintf( f, " %s\n", CONV_TO_UTF8( Component->m_Field[VALUE].m_Text ) );
} }
} }
@ -476,14 +510,16 @@ wxChar bufnum[BUFYPOS_LEN+1];
fprintf( f, "\n.end\n" ); fprintf( f, "\n.end\n" );
} }
/*****************************************************************************************/ /*****************************************************************************************/
static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with_pcbnew ) static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with_pcbnew )
/*****************************************************************************************/ /*****************************************************************************************/
/* Routine de generation du fichier netliste ( Format ORCAD PCB 2 ameliore ) /* Routine de generation du fichier netliste ( Format ORCAD PCB 2 ameliore )
si with_pcbnew = FALSE * si with_pcbnew = FALSE
format PCBNEW (OrcadPcb2 + commentaires et liste des nets) * format PCBNEW (OrcadPcb2 + commentaires et liste des nets)
si with_pcbnew = FALSE * si with_pcbnew = FALSE
Format ORCADPCB2 strict * Format ORCADPCB2 strict
*/ */
{ {
wxString Line, FootprintName; wxString Line, FootprintName;
@ -498,32 +534,42 @@ int CmpListCount = 0, CmpListSize = 1000;
DateAndTime( Buf ); DateAndTime( Buf );
if( with_pcbnew ) if( with_pcbnew )
fprintf( f, "# %s created %s\n(\n", NETLIST_HEAD_STRING, Buf ); fprintf( f, "# %s created %s\n(\n", NETLIST_HEAD_STRING, Buf );
else fprintf( f, "( { %s created %s }\n", NETLIST_HEAD_STRING, Buf ); else
fprintf( f, "( { %s created %s }\n", NETLIST_HEAD_STRING, Buf );
/* Create netlist module section */ /* Create netlist module section */
ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/ ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/
EDA_ScreenList ScreenList( NULL ); EDA_ScreenList ScreenList( NULL );
for( CurrScreen = ScreenList.GetFirst(); CurrScreen != NULL; CurrScreen = ScreenList.GetNext() ) for( CurrScreen = ScreenList.GetFirst(); CurrScreen != NULL; CurrScreen = ScreenList.GetNext() )
{ {
for( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) for( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext )
{ {
DrawList = Component = FindNextComponentAndCreatPinList( DrawList ); DrawList = Component = FindNextComponentAndCreatPinList( DrawList );
if ( Component == NULL ) break; if( Component == NULL )
break;
/* Get the Component FootprintFilter and put the component in CmpList if filter is not void */ /* Get the Component FootprintFilter and put the component in CmpList if filter is not void */
EDA_LibComponentStruct* Entry; EDA_LibComponentStruct* Entry;
if( (Entry = FindLibPart(Component->m_ChipName.GetData(),wxEmptyString,FIND_ROOT)) != NULL) if( ( Entry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString,
FIND_ROOT ) ) != NULL )
{ {
if( Entry->m_FootprintList.GetCount() != 0 ) /* Put in list */ if( Entry->m_FootprintList.GetCount() != 0 ) /* Put in list */
{ {
if( CmpList == NULL ) if( CmpList == NULL )
CmpList = (EDA_SchComponentStruct **) MyZMalloc(sizeof(EDA_SchComponentStruct *) * CmpListSize); CmpList = (EDA_SchComponentStruct**) MyZMalloc( sizeof(
EDA_SchComponentStruct
*) * CmpListSize );
if( CmpListCount >= CmpListSize ) if( CmpListCount >= CmpListSize )
{ {
CmpListSize += 1000; CmpListSize += 1000;
CmpList = (EDA_SchComponentStruct **) realloc(CmpList, sizeof(EDA_SchComponentStruct *) * CmpListSize); CmpList = (EDA_SchComponentStruct**) realloc(
CmpList,
sizeof(
EDA_SchComponentStruct*)
* CmpListSize );
} }
CmpList[CmpListCount] = Component; CmpList[CmpListCount] = Component;
CmpListCount++; CmpListCount++;
@ -535,7 +581,8 @@ int CmpListCount = 0, CmpListSize = 1000;
FootprintName = Component->m_Field[FOOTPRINT].m_Text; FootprintName = Component->m_Field[FOOTPRINT].m_Text;
FootprintName.Replace( wxT( " " ), wxT( "_" ) ); FootprintName.Replace( wxT( " " ), wxT( "_" ) );
} }
else FootprintName = wxT("$noname"); else
FootprintName = wxT( "$noname" );
Line = Component->m_Field[REFERENCE].m_Text; Line = Component->m_Field[REFERENCE].m_Text;
Line.Replace( wxT( " " ), wxT( "_" ) ); Line.Replace( wxT( " " ), wxT( "_" ) );
@ -560,9 +607,11 @@ int CmpListCount = 0, CmpListSize = 1000;
for( ii = 0; ii < s_SortedPinCount; ii++ ) for( ii = 0; ii < s_SortedPinCount; ii++ )
{ {
ObjetNetListStruct* Pin = s_SortedComponentPinList[ii]; ObjetNetListStruct* Pin = s_SortedComponentPinList[ii];
if( ! Pin ) continue; if( !Pin )
continue;
wxString netname = ReturnPinNetName( Pin, wxT( "N-%.6d" ) ); wxString netname = ReturnPinNetName( Pin, wxT( "N-%.6d" ) );
if ( netname.IsEmpty() ) netname = wxT(" ?"); if( netname.IsEmpty() )
netname = wxT( " ?" );
fprintf( f, " ( %4.4s %s )\n", (char*) &Pin->m_PinNum, fprintf( f, " ( %4.4s %s )\n", (char*) &Pin->m_PinNum,
CONV_TO_UTF8( netname ) ); CONV_TO_UTF8( netname ) );
} }
@ -570,6 +619,7 @@ int CmpListCount = 0, CmpListSize = 1000;
fprintf( f, " )\n" ); fprintf( f, " )\n" );
} }
} }
fprintf( f, ")\n*\n" ); fprintf( f, ")\n*\n" );
MyFree( s_SortedComponentPinList ); MyFree( s_SortedComponentPinList );
@ -592,11 +642,14 @@ int CmpListCount = 0, CmpListSize = 1000;
{ {
fprintf( f, " %s\n", CONV_TO_UTF8( Entry->m_FootprintList[jj] ) ); fprintf( f, " %s\n", CONV_TO_UTF8( Entry->m_FootprintList[jj] ) );
} }
fprintf( f, "$endlist\n" ); fprintf( f, "$endlist\n" );
} }
fprintf( f, "$endfootprintlist\n}\n" ); fprintf( f, "$endfootprintlist\n}\n" );
} }
if ( CmpList ) free(CmpList); if( CmpList )
free( CmpList );
if( with_pcbnew ) if( with_pcbnew )
{ {
@ -611,9 +664,10 @@ int CmpListCount = 0, CmpListSize = 1000;
/*************************************************************************************/ /*************************************************************************************/
static void AddPinToComponentPinList( EDA_SchComponentStruct* Component, LibDrawPin* Pin ) static void AddPinToComponentPinList( EDA_SchComponentStruct* Component, LibDrawPin* Pin )
/*************************************************************************************/ /*************************************************************************************/
/* Add a new pin description in the pin list s_SortedComponentPinList /* Add a new pin description in the pin list s_SortedComponentPinList
a pin description is a pointer to the corresponding structure * a pin description is a pointer to the corresponding structure
created by BuildNetList() in the table g_TabObjNet * created by BuildNetList() in the table g_TabObjNet
*/ */
{ {
int ii; int ii;
@ -621,16 +675,20 @@ int ii;
/* Search the PIN description for Pin in g_TabObjNet*/ /* Search the PIN description for Pin in g_TabObjNet*/
for( ii = 0; ii < g_NbrObjNet; ii++ ) for( ii = 0; ii < g_NbrObjNet; ii++ )
{ {
if ( g_TabObjNet[ii].m_Type != NET_PIN) continue; if( g_TabObjNet[ii].m_Type != NET_PIN )
if ( g_TabObjNet[ii].m_Link != Component) continue; continue;
if ( g_TabObjNet[ii].m_PinNum != Pin->m_PinNum) continue; if( g_TabObjNet[ii].m_Link != Component )
continue;
if( g_TabObjNet[ii].m_PinNum != Pin->m_PinNum )
continue;
{ {
s_SortedComponentPinList[s_SortedPinCount] = &g_TabObjNet[ii]; s_SortedComponentPinList[s_SortedPinCount] = &g_TabObjNet[ii];
s_SortedPinCount++; s_SortedPinCount++;
if( s_SortedPinCount >= MAXPIN ) if( s_SortedPinCount >= MAXPIN )
{ {
/* Log message for Internal error */ /* Log message for Internal error */
DisplayError(NULL, wxT("AddPinToComponentPinList err: MAXPIN reached")); return; DisplayError( NULL, wxT( "AddPinToComponentPinList err: MAXPIN reached" ) );
return;
} }
} }
} }
@ -640,37 +698,40 @@ int ii;
/**********************************************************************/ /**********************************************************************/
static void EraseDuplicatePins( ObjetNetListStruct** TabPin, int NbrPin ) static void EraseDuplicatePins( ObjetNetListStruct** TabPin, int NbrPin )
/**********************************************************************/ /**********************************************************************/
/* /*
Routine qui elimine les Pins de meme Numero de la liste des objets * Routine qui elimine les Pins de meme Numero de la liste des objets
(Liste des Pins d'un boitier) passee en entree * (Liste des Pins d'un boitier) passee en entree
Ces pins redondantes proviennent des pins (alims... ) communes a plusieurs * Ces pins redondantes proviennent des pins (alims... ) communes a plusieurs
elements d'un boitier a multiple parts. * elements d'un boitier a multiple parts.
*/ */
{ {
int ii, jj; int ii, jj;
for( ii = 0; ii < NbrPin - 1; ii++ ) for( ii = 0; ii < NbrPin - 1; ii++ )
{ {
if( TabPin[ii] == NULL) continue; /* Deja supprime */ if( TabPin[ii] == NULL )
if( TabPin[ii]->m_PinNum != TabPin[ii+1]->m_PinNum) continue; continue; /* Deja supprime */
if( TabPin[ii]->m_PinNum != TabPin[ii + 1]->m_PinNum )
continue;
/* 2 Pins doublees */ /* 2 Pins doublees */
for( jj = ii + 1; jj < NbrPin; jj++ ) for( jj = ii + 1; jj < NbrPin; jj++ )
{ {
if( TabPin[ii]->m_PinNum != TabPin[jj]->m_PinNum) break; if( TabPin[ii]->m_PinNum != TabPin[jj]->m_PinNum )
break;
TabPin[jj] = NULL; TabPin[jj] = NULL;
} }
} }
} }
/**********************************************************************/ /**********************************************************************/
static void FindOthersUnits( EDA_SchComponentStruct* Component ) static void FindOthersUnits( EDA_SchComponentStruct* Component )
/**********************************************************************/ /**********************************************************************/
/* Recherche les autres parts du boitier auquel appartient la part Component, /* Recherche les autres parts du boitier auquel appartient la part Component,
pour les boitiers a parts multiples. * pour les boitiers a parts multiples.
Appelle AddPinToComponentPinList() pour classer les pins des parts trouvees * Appelle AddPinToComponentPinList() pour classer les pins des parts trouvees
*/ */
{ {
EDA_BaseStruct* DrawList; EDA_BaseStruct* DrawList;
@ -680,6 +741,7 @@ LibEDA_BaseStruct *DEntry;
SCH_SCREEN* screen; SCH_SCREEN* screen;
EDA_ScreenList ScreenList( NULL ); EDA_ScreenList ScreenList( NULL );
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{ {
DrawList = screen->EEDrawList; DrawList = screen->EEDrawList;
@ -690,26 +752,32 @@ SCH_SCREEN * screen;
case DRAW_LIB_ITEM_STRUCT_TYPE: case DRAW_LIB_ITEM_STRUCT_TYPE:
Component2 = (EDA_SchComponentStruct*) DrawList; Component2 = (EDA_SchComponentStruct*) DrawList;
if ( Component2->m_FlagControlMulti == 1 ) break; if( Component2->m_FlagControlMulti == 1 )
break;
if( Component2->m_Field[REFERENCE].m_Text.CmpNoCase( if( Component2->m_Field[REFERENCE].m_Text.CmpNoCase(
Component->m_Field[REFERENCE].m_Text ) != 0 ) Component->m_Field[REFERENCE].m_Text ) != 0 )
break; break;
Entry = FindLibPart( Component2->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); Entry = FindLibPart( Component2->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
if( Entry == NULL) break; if( Entry == NULL )
if( Component2->m_Field[REFERENCE].m_Text[0] == '#' ) break; break;
if( Component2->m_Field[REFERENCE].m_Text[0] == '#' )
break;
if( Entry->m_Drawings != NULL ) if( Entry->m_Drawings != NULL )
{ {
DEntry = Entry->m_Drawings; DEntry = Entry->m_Drawings;
for( ; DEntry != NULL; DEntry = DEntry->Next() ) for( ; DEntry != NULL; DEntry = DEntry->Next() )
{ {
if ( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE) continue; if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE )
if( DEntry->m_Unit && continue;
(DEntry->m_Unit != Component2->m_Multi) ) continue; if( DEntry->m_Unit
if( DEntry->m_Convert && && (DEntry->m_Unit != Component2->m_Multi) )
(DEntry->m_Convert != Component2->m_Convert)) continue; continue;
if( DEntry->m_Convert
&& (DEntry->m_Convert != Component2->m_Convert) )
continue;
{ {
AddPinToComponentPinList( Component2, (LibDrawPin*) DEntry ); AddPinToComponentPinList( Component2, (LibDrawPin*) DEntry );
} }
@ -718,8 +786,10 @@ SCH_SCREEN * screen;
Component2->m_FlagControlMulti = 1; Component2->m_FlagControlMulti = 1;
break; break;
default: break; default:
break;
} }
DrawList = DrawList->Pnext; DrawList = DrawList->Pnext;
} }
} }
@ -729,8 +799,9 @@ SCH_SCREEN * screen;
/**************************************************************************/ /**************************************************************************/
static int SortPinsByNum( ObjetNetListStruct** Pin1, ObjetNetListStruct** Pin2 ) static int SortPinsByNum( ObjetNetListStruct** Pin1, ObjetNetListStruct** Pin2 )
/**************************************************************************/ /**************************************************************************/
/* Routine de comparaison pour le tri des pins par numero croissant /* Routine de comparaison pour le tri des pins par numero croissant
du tableau des pins s_SortedComponentPinList par qsort() * du tableau des pins s_SortedComponentPinList par qsort()
*/ */
{ {
ObjetNetListStruct* Obj1, * Obj2; ObjetNetListStruct* Obj1, * Obj2;
@ -741,14 +812,16 @@ char Line[5];
Num1 = Obj1->m_PinNum; Num2 = Obj2->m_PinNum; Num1 = Obj1->m_PinNum; Num2 = Obj2->m_PinNum;
Line[4] = 0; memcpy( Line, &Num1, 4 ); Num1 = atoi( Line ); Line[4] = 0; memcpy( Line, &Num1, 4 ); Num1 = atoi( Line );
memcpy( Line, &Num2, 4 ); Num2 = atoi( Line ); memcpy( Line, &Num2, 4 ); Num2 = atoi( Line );
return (Num1 - Num2); return Num1 - Num2;
} }
/*************************************************************************/ /*************************************************************************/
static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet ) static void WriteGENERICListOfNets( FILE* f, ObjetNetListStruct* ObjNet )
/*************************************************************************/ /*************************************************************************/
/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des /* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des
elements qui y sont connectes * elements qui y sont connectes
*/ */
{ {
int ii, jj; int ii, jj;
@ -767,10 +840,12 @@ char FirstItemInNet[1024];
NetName.Empty(); NetName.Empty();
for( jj = 0; jj < g_NbrObjNet; jj++ ) // Find a label (if exists) for this net for( jj = 0; jj < g_NbrObjNet; jj++ ) // Find a label (if exists) for this net
{ {
if( ObjNet[jj].m_NetCode != NetCode) continue; if( ObjNet[jj].m_NetCode != NetCode )
if( ( ObjNet[jj].m_Type != NET_GLOBLABEL) && continue;
( ObjNet[jj].m_Type != NET_LABEL) && if( ( ObjNet[jj].m_Type != NET_GLOBLABEL)
( ObjNet[jj].m_Type != NET_PINLABEL) ) continue; && ( ObjNet[jj].m_Type != NET_LABEL)
&& ( ObjNet[jj].m_Type != NET_PINLABEL) )
continue;
NetName = *g_TabObjNet[jj].m_Label; break; NetName = *g_TabObjNet[jj].m_Label; break;
} }
@ -787,16 +862,18 @@ char FirstItemInNet[1024];
LastNetCode = NetCode; LastNetCode = NetCode;
} }
if ( ObjNet[ii].m_Type != NET_PIN ) continue; if( ObjNet[ii].m_Type != NET_PIN )
continue;
Cmp = (EDA_SchComponentStruct*) ObjNet[ii].m_Link; Cmp = (EDA_SchComponentStruct*) ObjNet[ii].m_Link;
CmpRef = Cmp->m_Field[REFERENCE].m_Text; CmpRef = Cmp->m_Field[REFERENCE].m_Text;
if ( CmpRef.StartsWith( wxT("#") ) ) continue; // Pseudo component (Like Power symbol) if( CmpRef.StartsWith( wxT( "#" ) ) )
continue; // Pseudo component (Like Power symbol)
// Print the pin list for this net, if 2 or more items are connected: // Print the pin list for this net, if 2 or more items are connected:
SameNetcodeCount++; SameNetcodeCount++;
if( SameNetcodeCount == 1 ) /* first item for this net found, if( SameNetcodeCount == 1 ) /* first item for this net found,
Print this connection, when a second item will be found */ * Print this connection, when a second item will be found */
{ {
sprintf( FirstItemInNet, " %s %.4s\n", CONV_TO_UTF8( CmpRef ), sprintf( FirstItemInNet, " %s %.4s\n", CONV_TO_UTF8( CmpRef ),
(const char*) &ObjNet[ii].m_PinNum ); (const char*) &ObjNet[ii].m_PinNum );
@ -814,38 +891,38 @@ char FirstItemInNet[1024];
} }
/* Generation des netlistes au format CadStar */ /* Generation des netlistes au format CadStar */
wxString StartLine( wxT( "." ) ); wxString StartLine( wxT( "." ) );
/*********************************************************/ /*********************************************************/
static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f )
/*********************************************************/ /*********************************************************/
/* Routine de generation du fichier netliste ( Format CADSTAR ) /* Routine de generation du fichier netliste ( Format CADSTAR )
Entete: * Entete:
..HEA * ..HEA
..TIM 2004 07 29 16 22 17 * ..TIM 2004 07 29 16 22 17
..APP "Cadstar RINF Output - Version 6.0.2.3" * ..APP "Cadstar RINF Output - Version 6.0.2.3"
..UNI INCH 1000.0 in * ..UNI INCH 1000.0 in
..TYP FULL * ..TYP FULL
*
liste des composants: * liste des composants:
..ADD_COM X1 "CNT D41612 (48PTS MC CONTOUR)" * ..ADD_COM X1 "CNT D41612 (48PTS MC CONTOUR)"
..ADD_COM U2 "74HCT245D" "74HCT245D" * ..ADD_COM U2 "74HCT245D" "74HCT245D"
*
Connexions: * Connexions:
..ADD_TER RR2 6 "$42" * ..ADD_TER RR2 6 "$42"
..TER U1 100 * ..TER U1 100
CA 6 * CA 6
*
..ADD_TER U2 6 "$59" * ..ADD_TER U2 6 "$59"
..TER U7 39 * ..TER U7 39
U6 17 * U6 17
U1 122 * U1 122
*
..ADD_TER P2 1 "$9" * ..ADD_TER P2 1 "$9"
..TER T3 1 * ..TER T3 1
U1 14 * U1 14
*/ */
{ {
wxString StartCmpDesc = StartLine + wxT( "ADD_COM" ); wxString StartCmpDesc = StartLine + wxT( "ADD_COM" );
@ -867,19 +944,22 @@ EDA_SchComponentStruct *Component;
/* Create netlist module section */ /* Create netlist module section */
ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/ ClearUsedFlags( frame ); /* Reset the flags FlagControlMulti in all schematic files*/
EDA_ScreenList ScreenList( NULL ); EDA_ScreenList ScreenList( NULL );
for( CurrScreen = ScreenList.GetFirst(); CurrScreen != NULL; CurrScreen = ScreenList.GetNext() ) for( CurrScreen = ScreenList.GetFirst(); CurrScreen != NULL; CurrScreen = ScreenList.GetNext() )
{ {
for( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext ) for( DrawList = CurrScreen->EEDrawList; DrawList != NULL; DrawList = DrawList->Pnext )
{ {
DrawList = Component = FindNextComponentAndCreatPinList( DrawList ); DrawList = Component = FindNextComponentAndCreatPinList( DrawList );
if ( Component == NULL ) break; if( Component == NULL )
break;
if( !Component->m_Field[FOOTPRINT].IsVoid() ) if( !Component->m_Field[FOOTPRINT].IsVoid() )
{ {
FootprintName = Component->m_Field[FOOTPRINT].m_Text; FootprintName = Component->m_Field[FOOTPRINT].m_Text;
FootprintName.Replace( wxT( " " ), wxT( "_" ) ); FootprintName.Replace( wxT( " " ), wxT( "_" ) );
} }
else FootprintName = wxT("$noname"); else
FootprintName = wxT( "$noname" );
msg = Component->m_Field[REFERENCE].m_Text; msg = Component->m_Field[REFERENCE].m_Text;
msg.Replace( wxT( " " ), wxT( "_" ) ); msg.Replace( wxT( " " ), wxT( "_" ) );
@ -890,9 +970,9 @@ EDA_SchComponentStruct *Component;
msg.Replace( wxT( " " ), wxT( "_" ) ); msg.Replace( wxT( " " ), wxT( "_" ) );
fprintf( f, " \"%s\"", CONV_TO_UTF8( msg ) ); fprintf( f, " \"%s\"", CONV_TO_UTF8( msg ) );
fprintf( f, "\n" ); fprintf( f, "\n" );
}
}
}
}
fprintf( f, "\n" ); fprintf( f, "\n" );
MyFree( s_SortedComponentPinList ); MyFree( s_SortedComponentPinList );
@ -903,15 +983,17 @@ EDA_SchComponentStruct *Component;
fprintf( f, "\n%sEND\n", CONV_TO_UTF8( StartLine ) ); fprintf( f, "\n%sEND\n", CONV_TO_UTF8( StartLine ) );
} }
/*************************************************************************/ /*************************************************************************/
static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet ) static void WriteListOfNetsCADSTAR( FILE* f, ObjetNetListStruct* ObjNet )
/*************************************************************************/ /*************************************************************************/
/* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des /* Ecrit dans le fichier f la liste des nets ( classee par NetCodes ), et des
pins qui y sont connectes * pins qui y sont connectes
format: * format:
.ADD_TER RR2 6 "$42" * .ADD_TER RR2 6 "$42"
.TER U1 100 * .TER U1 100
CA 6 * CA 6
*/ */
{ {
wxString InitNetDesc = StartLine + wxT( "ADD_TER" ); wxString InitNetDesc = StartLine + wxT( "ADD_TER" );
@ -922,7 +1004,8 @@ int NetCode, LastNetCode = -1;
EDA_SchComponentStruct* Cmp; EDA_SchComponentStruct* Cmp;
wxString NetName; wxString NetName;
for (ii = 0; ii < g_NbrObjNet; ii++) ObjNet[ii].m_Flag = 0; for( ii = 0; ii < g_NbrObjNet; ii++ )
ObjNet[ii].m_Flag = 0;
for( ii = 0; ii < g_NbrObjNet; ii++ ) for( ii = 0; ii < g_NbrObjNet; ii++ )
{ {
@ -932,13 +1015,16 @@ wxString NetName;
NetName.Empty(); NetName.Empty();
for( jj = 0; jj < g_NbrObjNet; jj++ ) for( jj = 0; jj < g_NbrObjNet; jj++ )
{ {
if( ObjNet[jj].m_NetCode != NetCode) continue; if( ObjNet[jj].m_NetCode != NetCode )
if( ( ObjNet[jj].m_Type != NET_GLOBLABEL) && continue;
( ObjNet[jj].m_Type != NET_LABEL) && if( ( ObjNet[jj].m_Type != NET_GLOBLABEL)
( ObjNet[jj].m_Type != NET_PINLABEL) ) continue; && ( ObjNet[jj].m_Type != NET_LABEL)
&& ( ObjNet[jj].m_Type != NET_PINLABEL) )
continue;
NetName = *ObjNet[jj].m_Label; break; NetName = *ObjNet[jj].m_Label; break;
} }
NetcodeName = wxT( "\"" ); NetcodeName = wxT( "\"" );
if( !NetName.IsEmpty() ) if( !NetName.IsEmpty() )
{ {
@ -954,9 +1040,11 @@ wxString NetName;
} }
if ( ObjNet[ii].m_Type != NET_PIN ) continue; if( ObjNet[ii].m_Type != NET_PIN )
continue;
if ( ObjNet[ii].m_Flag != 0 ) continue; if( ObjNet[ii].m_Flag != 0 )
continue;
Cmp = (EDA_SchComponentStruct*) ObjNet[ii].m_Link; Cmp = (EDA_SchComponentStruct*) ObjNet[ii].m_Link;
@ -996,18 +1084,22 @@ wxString NetName;
} }
ObjNet[ii].m_Flag = 1; ObjNet[ii].m_Flag = 1;
// Recherche des pins redondantes et mise a 1 de m_Flag, // Recherche des pins redondantes et mise a 1 de m_Flag,
// pour ne pas generer plusieurs fois la connexion // pour ne pas generer plusieurs fois la connexion
for( jj = ii + 1; jj < g_NbrObjNet; jj++ ) for( jj = ii + 1; jj < g_NbrObjNet; jj++ )
{ {
if( ObjNet[jj].m_NetCode != NetCode) break; if( ObjNet[jj].m_NetCode != NetCode )
if( ObjNet[jj].m_Type != NET_PIN ) continue; break;
if( ObjNet[jj].m_Type != NET_PIN )
continue;
EDA_SchComponentStruct* tstcmp = EDA_SchComponentStruct* tstcmp =
(EDA_SchComponentStruct*) ObjNet[jj].m_Link; (EDA_SchComponentStruct*) ObjNet[jj].m_Link;
if( Cmp->m_Field[REFERENCE].m_Text != tstcmp->m_Field[REFERENCE].m_Text ) continue; if( Cmp->m_Field[REFERENCE].m_Text != tstcmp->m_Field[REFERENCE].m_Text )
continue;
if ( ObjNet[jj].m_PinNum == ObjNet[ii].m_PinNum ) ObjNet[jj].m_Flag = 1; if( ObjNet[jj].m_PinNum == ObjNet[ii].m_PinNum )
ObjNet[jj].m_Flag = 1;
} }
} }
} }

View File

@ -77,6 +77,8 @@ void ObjetNetListStruct::Show( std::ostream& out, int ndx )
if( m_Comp ) if( m_Comp )
m_Comp->Show( 1, out ); m_Comp->Show( 1, out );
else
out << " m_Comp==NULL\n";
out << "</netItem>\n"; out << "</netItem>\n";
} }
@ -294,7 +296,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
} }
#if defined(DEBUG) #if 0 && defined(DEBUG)
std::cout << "after sheet local\n"; std::cout << "after sheet local\n";
dumpNetTable(); dumpNetTable();
#endif #endif
@ -333,7 +335,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
} }
} }
#if defined(DEBUG) #if 0 && defined(DEBUG)
std::cout << "after sheet global\n"; std::cout << "after sheet global\n";
dumpNetTable(); dumpNetTable();
#endif #endif
@ -354,7 +356,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
qsort( g_TabObjNet, g_NbrObjNet, sizeof(ObjetNetListStruct), TriNetCode ); qsort( g_TabObjNet, g_NbrObjNet, sizeof(ObjetNetListStruct), TriNetCode );
#if defined(DEBUG) #if 0 && defined(DEBUG)
std::cout << "after qsort()\n"; std::cout << "after qsort()\n";
dumpNetTable(); dumpNetTable();
#endif #endif

View File

@ -422,7 +422,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay()
SetCurItem( item ); SetCurItem( item );
} }
// If the first item is a pad or moduletext, and the 2nd item is its parent module: // If the count is 2, and first item is a pad or moduletext, and the 2nd item is its parent module:
else if( m_Collector->GetCount() == 2 && else if( m_Collector->GetCount() == 2 &&
( (*m_Collector)[0]->Type() == TYPEPAD || (*m_Collector)[0]->Type() == TYPETEXTEMODULE) && ( (*m_Collector)[0]->Type() == TYPEPAD || (*m_Collector)[0]->Type() == TYPETEXTEMODULE) &&
(*m_Collector)[1]->Type() == TYPEMODULE && (*m_Collector)[0]->GetParent()==(*m_Collector)[1] ) (*m_Collector)[1]->Type() == TYPEMODULE && (*m_Collector)[0]->GetParent()==(*m_Collector)[1] )