Commit c4dc992c authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: fix bug #1168116. Netlist generation: remove dead code and fully...

Eeschema: fix bug #1168116. Netlist generation: remove  dead code and fully outdated option pspice "use net number"
Pcbnew: layer manager: display tooltips using translated form (where internationalized, but always shown in English).
parent 70dc51d1
...@@ -188,9 +188,6 @@ NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) : ...@@ -188,9 +188,6 @@ NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) :
long tmp; long tmp;
m_config->Read( NETLIST_USE_DEFAULT_NETNAME, &tmp, 0l ); m_config->Read( NETLIST_USE_DEFAULT_NETNAME, &tmp, 0l );
m_cbUseDefaultNetlistName->SetValue( tmp ); m_cbUseDefaultNetlistName->SetValue( tmp );
m_config->Read( NETLIST_PSPICE_USE_NETNAME, &m_spiceNetlistUseNames, true );
m_NetFmtName = m_Parent->GetNetListFormatName(); m_NetFmtName = m_Parent->GetNetListFormatName();
for( int ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ ) for( int ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ )
...@@ -268,18 +265,6 @@ void NETLIST_DIALOG::InstallPageSpice() ...@@ -268,18 +265,6 @@ void NETLIST_DIALOG::InstallPageSpice()
page->m_AddSubPrefix->SetValue( m_Parent->GetAddReferencePrefix() ); page->m_AddSubPrefix->SetValue( m_Parent->GetAddReferencePrefix() );
page->m_LeftBoxSizer->Add( page->m_AddSubPrefix, 0, wxGROW | wxALL, 5 ); page->m_LeftBoxSizer->Add( page->m_AddSubPrefix, 0, wxGROW | wxALL, 5 );
wxString netlist_opt[2] = { _( "Use Net Names" ), _( "Use Net Numbers" ) };
page->m_NetOption = new wxRadioBox( page, -1, _( "Netlist Options:" ),
wxDefaultPosition, wxDefaultSize,
2, netlist_opt, 1,
wxRA_SPECIFY_COLS );
if( !m_spiceNetlistUseNames )
page->m_NetOption->SetSelection( 1 );
page->m_LeftBoxSizer->Add( page->m_NetOption, 0, wxGROW | wxALL, 5 );
page->m_LowBoxSizer->Add( new wxStaticText( page, -1, _( "Simulator command:" ) ), 0, page->m_LowBoxSizer->Add( new wxStaticText( page, -1, _( "Simulator command:" ) ), 0,
wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
...@@ -438,11 +423,6 @@ void NETLIST_DIALOG::NetlistUpdateOpt() ...@@ -438,11 +423,6 @@ void NETLIST_DIALOG::NetlistUpdateOpt()
if( m_PanelNetType[ii]->m_IsCurrentFormat->GetValue() == true ) if( m_PanelNetType[ii]->m_IsCurrentFormat->GetValue() == true )
m_Parent->SetNetListFormatName( m_PanelNetType[ii]->GetPageNetFmtName() ); m_Parent->SetNetListFormatName( m_PanelNetType[ii]->GetPageNetFmtName() );
} }
m_spiceNetlistUseNames = true; // Used for pspice, gnucap
if( m_PanelNetType[PANELSPICE]->m_NetOption->GetSelection() == 1 )
m_spiceNetlistUseNames = false;
} }
...@@ -475,8 +455,6 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) ...@@ -475,8 +455,6 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
{ {
case NET_TYPE_SPICE: case NET_TYPE_SPICE:
// Set spice netlist options: // Set spice netlist options:
if( m_spiceNetlistUseNames )
netlist_opt |= NET_USE_NETNAMES;
if( currPage->m_AddSubPrefix->GetValue() ) if( currPage->m_AddSubPrefix->GetValue() )
netlist_opt |= NET_USE_X_PREFIX; netlist_opt |= NET_USE_X_PREFIX;
break; break;
...@@ -647,13 +625,10 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event ) ...@@ -647,13 +625,10 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event )
NETLIST_PAGE_DIALOG* currPage; NETLIST_PAGE_DIALOG* currPage;
currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
m_spiceNetlistUseNames = currPage->m_NetOption->GetSelection() == 0;
// Set spice netlist options: // Set spice netlist options:
unsigned netlist_opt = 0; unsigned netlist_opt = 0;
if( m_spiceNetlistUseNames )
netlist_opt |= NET_USE_NETNAMES;
if( currPage->m_AddSubPrefix && currPage->m_AddSubPrefix->GetValue() ) if( currPage->m_AddSubPrefix && currPage->m_AddSubPrefix->GetValue() )
netlist_opt |= NET_USE_X_PREFIX; netlist_opt |= NET_USE_X_PREFIX;
...@@ -676,7 +651,6 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void ) ...@@ -676,7 +651,6 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void )
NetlistUpdateOpt(); NetlistUpdateOpt();
m_config->Write( NETLIST_USE_DEFAULT_NETNAME, GetUseDefaultNetlistName() ); m_config->Write( NETLIST_USE_DEFAULT_NETNAME, GetUseDefaultNetlistName() );
m_config->Write( NETLIST_PSPICE_USE_NETNAME, m_spiceNetlistUseNames );
// Update the new titles // Update the new titles
for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ ) for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
......
...@@ -110,7 +110,6 @@ public: ...@@ -110,7 +110,6 @@ public:
// Options for Spice netlist generation (OR'ed bits // Options for Spice netlist generation (OR'ed bits
enum netlistOptions { enum netlistOptions {
NET_USE_NETNAMES = 1, // for Spice netlist : use netnames instead of numbers
NET_USE_X_PREFIX = 2, // for Spice netlist : change "U" and "IC" reference prefix to "X" NET_USE_X_PREFIX = 2, // for Spice netlist : change "U" and "IC" reference prefix to "X"
NET_PCBNEW_USE_NEW_FORMAT = 1, // For Pcbnew use the new format (S expression and SWEET) NET_PCBNEW_USE_NEW_FORMAT = 1, // For Pcbnew use the new format (S expression and SWEET)
}; };
...@@ -125,8 +124,6 @@ public: ...@@ -125,8 +124,6 @@ public:
private: private:
wxConfig* m_config; wxConfig* m_config;
bool m_spiceNetlistUseNames; /* true to use names rather than net
* numbers (PSPICE netlist only) */
public: public:
......
...@@ -32,10 +32,9 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) ...@@ -32,10 +32,9 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
newitem->SetTimeStamp( GetNewTimeStamp() ); newitem->SetTimeStamp( GetNewTimeStamp() );
newitem->ClearAnnotation( NULL ); newitem->ClearAnnotation( NULL );
newitem->SetFlags( IS_NEW ); newitem->SetFlags( IS_NEW );
MoveItem( (SCH_ITEM*) newitem, &dc ); // Draw the new part, MoveItem() expects it to be already on screen.
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
// Redraw the original part, because StartMovePart() erased it from screen. MoveItem( newitem, &dc );
curr_item->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
} }
break; break;
...@@ -46,10 +45,9 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) ...@@ -46,10 +45,9 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
{ {
SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone(); SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone();
newitem->SetFlags( IS_NEW ); newitem->SetFlags( IS_NEW );
MoveItem( (SCH_ITEM*) newitem, &dc ); // Draw the new item, MoveItem() expects it to be already on screen.
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
/* Redraw the original part in XOR mode */ MoveItem( newitem, &dc );
curr_item->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
} }
break; break;
......
...@@ -298,12 +298,10 @@ public: ...@@ -298,12 +298,10 @@ public:
* .-PSpice or .-gnucap put at beginning of the netlist * .-PSpice or .-gnucap put at beginning of the netlist
* .+PSpice or .-genucap are put at end of the netList * .+PSpice or .-genucap are put at end of the netList
* @param f = the file to write to * @param f = the file to write to
* @param use_netnames = true, to use netnames in netlist,
* false to use net number.
* @param aUsePrefix = true, adds an 'X' prefix to any reference designator starting with "U" or "IC", * @param aUsePrefix = true, adds an 'X' prefix to any reference designator starting with "U" or "IC",
* false to leave reference designator unchanged. * false to leave reference designator unchanged.
*/ */
bool WriteNetListPspice( FILE* f, bool use_netnames, bool aUsePrefix ); bool WriteNetListPspice( FILE* f, bool aUsePrefix );
/** /**
* Function MakeCommandLine * Function MakeCommandLine
...@@ -360,8 +358,6 @@ wxString NETLIST_EXPORT_TOOL::MakeCommandLine( const wxString& aFormatString, ...@@ -360,8 +358,6 @@ wxString NETLIST_EXPORT_TOOL::MakeCommandLine( const wxString& aFormatString,
* param aFullFileName = full netlist file name * param aFullFileName = full netlist file name
* param aNetlistOptions = netlist options using OR'ed bits. * param aNetlistOptions = netlist options using OR'ed bits.
* For SPICE netlist only: * For SPICE netlist only:
* if NET_USE_NETNAMES is set, use net names from labels in schematic
* else use net numbers (net codes)
* if NET_USE_X_PREFIX is set : change "U" and "IC" refernce prefix to "X" * if NET_USE_X_PREFIX is set : change "U" and "IC" refernce prefix to "X"
* return true if success. * return true if success.
*/ */
...@@ -381,7 +377,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam ...@@ -381,7 +377,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL ) if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Failed to create file <%s>" ), msg.Printf( _( "Failed to create file <%s>" ),
GetChars( aFullFileName ) ); GetChars( aFullFileName ) );
DisplayError( this, msg ); DisplayError( this, msg );
return false; return false;
...@@ -413,9 +409,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam ...@@ -413,9 +409,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
break; break;
case NET_TYPE_SPICE: case NET_TYPE_SPICE:
ret = helper.WriteNetListPspice( f, ret = helper.WriteNetListPspice( f, aNetlistOptions & NET_USE_X_PREFIX );
aNetlistOptions & NET_USE_NETNAMES,
aNetlistOptions & NET_USE_X_PREFIX );
fclose( f ); fclose( f );
break; break;
...@@ -1086,110 +1080,16 @@ bool NETLIST_EXPORT_TOOL::WriteGENERICNetList( const wxString& aOutFileName ) ...@@ -1086,110 +1080,16 @@ bool NETLIST_EXPORT_TOOL::WriteGENERICNetList( const wxString& aOutFileName )
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ ) for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
g_NetObjectslist[ii]->m_Flag = 0; g_NetObjectslist[ii]->m_Flag = 0;
#if 1
// output the XML format netlist. // output the XML format netlist.
wxXmlDocument xdoc; wxXmlDocument xdoc;
xdoc.SetRoot( makeGenericRoot() ); xdoc.SetRoot( makeGenericRoot() );
return xdoc.Save( aOutFileName, 2 /* indent bug, today was ignored by wxXml lib */ ); return xdoc.Save( aOutFileName, 2 /* indent bug, today was ignored by wxXml lib */ );
#else // output the well established/old generic net list format which was not XML.
wxString field;
wxString footprint;
wxString netname;
FILE* out;
int ret = 0; // OR on each call, test sign bit at very end.
if( ( out = wxFopen( aOutFileName, wxT( "wt" ) ) ) == NULL )
{
wxString msg;
msg.Printf( _( "Failed to create file <%s>" ), GetChars( aOutFileName ) );
DisplayError( NULL, msg );
return false;
}
m_ReferencesAlreadyFound.Clear();
ret |= fprintf( out, "$BeginNetlist\n" );
// Create netlist module section
ret |= fprintf( out, "$BeginComponentList\n" );
SCH_SHEET_LIST sheetList;
for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path; path = sheetList.GetNext() )
{
for( EDA_ITEM* schItem = path->LastDrawList(); schItem; schItem = schItem->Next() )
{
SCH_COMPONENT* comp = findNextComponentAndCreatePinList( schItem, path );
if( !comp )
break; // No component left
schItem = comp;
footprint.Empty();
if( !comp->GetField( FOOTPRINT )->IsVoid() )
{
footprint = comp->GetField( FOOTPRINT )->m_Text;
footprint.Replace( wxT( " " ), wxT( "_" ) );
}
ret |= fprintf( out, "\n$BeginComponent\n" );
ret |= fprintf( out, "TimeStamp=%8.8lX\n", comp->m_TimeStamp );
ret |= fprintf( out, "Footprint=%s\n", TO_UTF8( footprint ) );
field = wxT( "Reference=" ) + comp->GetRef( path ) + wxT( "\n" );
field.Replace( wxT( " " ), wxT( "_" ) );
ret |= fputs( TO_UTF8( field ), out );
field = comp->GetField( VALUE )->m_Text;
field.Replace( wxT( " " ), wxT( "_" ) );
ret |= fprintf( out, "Value=%s\n", TO_UTF8( field ) );
field = comp->GetLibName();
field.Replace( wxT( " " ), wxT( "_" ) );
ret |= fprintf( out, "Libref=%s\n", TO_UTF8( field ) );
// Write pin list:
ret |= fprintf( out, "$BeginPinList\n" );
for( unsigned ii = 0; ii < m_SortedComponentPinList.size(); ii++ )
{
NETLIST_OBJECT* Pin = m_SortedComponentPinList[ii];
if( !Pin )
continue;
sprintPinNetName( &netname, wxT( "$-%.6d" ), Pin );
if( netname.IsEmpty() )
netname = wxT( "?" );
ret |= fprintf( out, "%.4s=%s\n", (char*) &Pin->m_PinNum, TO_UTF8( netname ) );
}
ret |= fprintf( out, "$EndPinList\n" );
ret |= fprintf( out, "$EndComponent\n" );
}
}
ret |= fprintf( out, "$EndComponentList\n" );
ret |= fprintf( out, "\n$BeginNets\n" );
if( !writeGENERICListOfNets( out, g_NetObjectslist ) )
ret = -1;
ret |= fprintf( out, "$EndNets\n" );
ret |= fprintf( out, "\n$EndNetlist\n" );
ret |= fclose( out );
return ret >= 0;
#endif
} }
bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool use_netnames, bool aUsePrefix ) bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool aUsePrefix )
{ {
int ret = 0; int ret = 0;
int nbitems; int nbitems;
...@@ -1406,17 +1306,8 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool use_netnames, bool a ...@@ -1406,17 +1306,8 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool use_netnames, bool a
if( netName.IsEmpty() ) if( netName.IsEmpty() )
netName = wxT( "?" ); netName = wxT( "?" );
if( use_netnames ) ret |= fprintf( f, " %s", TO_UTF8( netName ) );
ret |= fprintf( f, " %s", TO_UTF8( netName ) );
else // Use number for net names (net number = 0 for "GND")
{
// NetName = "0" is "GND" net for Spice
if( netName == wxT( "0" ) || netName == wxT( "GND" ) )
ret |= fprintf( f, " 0" );
else
ret |= fprintf( f, " %d", pin->GetNet() );
}
} }
// Get Component Value Name: // Get Component Value Name:
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
...@@ -209,9 +209,14 @@ void PCB_LAYER_WIDGET::ReFillRender() ...@@ -209,9 +209,14 @@ void PCB_LAYER_WIDGET::ReFillRender()
ClearRenderRows(); ClearRenderRows();
// Add "Render" tab rows to LAYER_WIDGET, after setting color and checkbox state. // Add "Render" tab rows to LAYER_WIDGET, after setting color and checkbox state.
// Because s_render_rows is created static, we must explicitely call
// wxGetTranslation for texts which are internationalized (tool tips
// and item names)
for( unsigned row=0; row<DIM(s_render_rows); ++row ) for( unsigned row=0; row<DIM(s_render_rows); ++row )
{ {
LAYER_WIDGET::ROW renderRow = s_render_rows[row]; LAYER_WIDGET::ROW renderRow = s_render_rows[row];
renderRow.tooltip = wxGetTranslation( s_render_rows[row].tooltip);
renderRow.rowName = wxGetTranslation( s_render_rows[row].rowName);
if( renderRow.color != -1 ) // does this row show a color? if( renderRow.color != -1 ) // does this row show a color?
{ {
...@@ -288,12 +293,15 @@ void PCB_LAYER_WIDGET::ReFill() ...@@ -288,12 +293,15 @@ void PCB_LAYER_WIDGET::ReFill()
} }
AppendLayerRow( LAYER_WIDGET::ROW( AppendLayerRow( LAYER_WIDGET::ROW(
brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), dsc, true ) ); brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ),
dsc, true ) );
} }
} }
// technical layers are shown in this order: // technical layers are shown in this order:
// Because they are static, wxGetTranslation must be explicitely
// called for tooltips.
static const struct { static const struct {
LAYER_NUM layerId; LAYER_NUM layerId;
wxString tooltip; wxString tooltip;
...@@ -322,7 +330,7 @@ void PCB_LAYER_WIDGET::ReFill() ...@@ -322,7 +330,7 @@ void PCB_LAYER_WIDGET::ReFill()
AppendLayerRow( LAYER_WIDGET::ROW( AppendLayerRow( LAYER_WIDGET::ROW(
brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ),
techLayerSeq[i].tooltip, true ) ); wxGetTranslation( techLayerSeq[i].tooltip ), true ) );
} }
installRightLayerClickHandler(); installRightLayerClickHandler();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment