Commit 16e9ddc2 authored by jean-pierre charras's avatar jean-pierre charras

* Gerbview, Pcbnew: add SetLocaleTo_Default() after reading double in config...

* Gerbview, Pcbnew: add SetLocaleTo_Default() after reading double in config to fix issues with decimal separator (when the separator is not a point).
(WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" ) when wxConfig read doubles stored in config, but forget to back to current locale.)
Note: perhaps there are some dialogs that need this call to  SetLocaleTo_Default() ).
* Minor  code cleanup in pcbnew/netlist.cpp
parent f2b0e185
This diff is collapsed.
Cmp-Mod V01 Created by CvPCB (2011-02-21 BZR 2827)-testing date = 21/02/2011 18:31:31 Cmp-Mod V01 Created by CvPCB (2011-03-30 BZR 2935)-testing date = 02/04/2011 13:22:13
BeginCmp BeginCmp
TimeStamp = /322D3011; TimeStamp = /322D3011;
...@@ -123,35 +123,35 @@ BeginCmp ...@@ -123,35 +123,35 @@ BeginCmp
TimeStamp = /322D31F4; TimeStamp = /322D31F4;
Reference = U1; Reference = U1;
ValeurCmp = 74LS245; ValeurCmp = 74LS245;
IdModule = 20dip300; IdModule = DIP-20__300;
EndCmp EndCmp
BeginCmp BeginCmp
TimeStamp = /322D35B4; TimeStamp = /322D35B4;
Reference = U2; Reference = U2;
ValeurCmp = 74LS688; ValeurCmp = 74LS688;
IdModule = 20dip300; IdModule = DIP-20__300;
EndCmp EndCmp
BeginCmp BeginCmp
TimeStamp = /4A087146; TimeStamp = /4A087146;
Reference = U3; Reference = U3;
ValeurCmp = 74LS541; ValeurCmp = 74LS541;
IdModule = ; IdModule = DIP-20__300;
EndCmp EndCmp
BeginCmp BeginCmp
TimeStamp = /3240023F; TimeStamp = /3240023F;
Reference = U5; Reference = U5;
ValeurCmp = 628128; ValeurCmp = 628128;
IdModule = 32dip600; IdModule = DIP-32__600;
EndCmp EndCmp
BeginCmp BeginCmp
TimeStamp = /322D321C; TimeStamp = /322D321C;
Reference = U8; Reference = U8;
ValeurCmp = EP600; ValeurCmp = EP600;
IdModule = 24dip300; IdModule = DIP-24__300;
EndCmp EndCmp
BeginCmp BeginCmp
......
update=07/03/2011 19:57:09 update=02/04/2011 15:02:30
version=1 version=1
last_client=pcbnew last_client=pcbnew
[common] [common]
...@@ -72,13 +72,15 @@ DrawLar=150 ...@@ -72,13 +72,15 @@ DrawLar=150
EdgeLar=50 EdgeLar=50
TxtLar=170 TxtLar=170
MSegLar=150 MSegLar=150
LastNetListRead=..\\pic_programmer\\pic_programmer.net LastNetListRead=interf_u.net
[pcbnew/libraries] [pcbnew/libraries]
LibDir= LibDir=
LibName1=connect LibName1=connect
LibName2=discret LibName2=discret
LibName3=dip_sockets LibName3=led
LibName4=pin_array LibName4=sockets
LibName5=divers LibName5=dip_sockets
LibName6=libcms LibName6=pin_array
LibName7=display LibName7=divers
LibName8=libcms
LibName9=display
...@@ -108,6 +108,7 @@ bool WinEDA_App::OnInit() ...@@ -108,6 +108,7 @@ bool WinEDA_App::OnInit()
frame->Zoom_Automatique( true ); // Zoom fit in frame frame->Zoom_Automatique( true ); // Zoom fit in frame
frame->GetScreen()->m_FirstRedraw = false; frame->GetScreen()->m_FirstRedraw = false;
if( argc <= 1 ) if( argc <= 1 )
return true; return true;
......
...@@ -3,14 +3,12 @@ ...@@ -3,14 +3,12 @@
/************************************************/ /************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h"
#include "gestfich.h" #include "gestfich.h"
#include "pcbcommon.h" #include "pcbcommon.h"
#include "gerbview.h" #include "gerbview.h"
#include "pcbplot.h" //#include "pcbplot.h"
#include "hotkeys.h" #include "hotkeys.h"
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
#include "gerbview_config.h" #include "gerbview_config.h"
...@@ -43,8 +41,8 @@ void GERBVIEW_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -43,8 +41,8 @@ void GERBVIEW_FRAME::Process_Config( wxCommandEvent& event )
break; break;
default: default:
DisplayError( this, wxMessageBox( wxT( "GERBVIEW_FRAME::Process_Config error" ) );
wxT( "GERBVIEW_FRAME::Process_Config internal error" ) ); break;
} }
} }
......
...@@ -64,7 +64,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, ...@@ -64,7 +64,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first. GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first.
GetBoard()->SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible. GetBoard()->SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible.
// Create the PCB_LAYER_WIDGET *after* SetBoard(): // Create the PCB_LAYER_WIDGET *after* SetBoard():
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
int pointSize = font.GetPointSize(); int pointSize = font.GetPointSize();
int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
...@@ -213,6 +213,11 @@ void GERBVIEW_FRAME::LoadSettings() ...@@ -213,6 +213,11 @@ void GERBVIEW_FRAME::LoadSettings()
config->SetPath( wxT("drl_files") ); config->SetPath( wxT("drl_files") );
m_drillFileHistory.Load( *config ); m_drillFileHistory.Load( *config );
config->SetPath( wxT("..") ); config->SetPath( wxT("..") );
// WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
// when reading doubles in config,
// but forget to back to current locale. So we call SetLocaleTo_Default
SetLocaleTo_Default( );
} }
......
...@@ -475,7 +475,10 @@ void PCB_BASE_FRAME::LoadSettings() ...@@ -475,7 +475,10 @@ void PCB_BASE_FRAME::LoadSettings()
cfg->Read( m_FrameName + UserGridSizeXEntry, &m_UserGridSize.x, 0.01 ); cfg->Read( m_FrameName + UserGridSizeXEntry, &m_UserGridSize.x, 0.01 );
cfg->Read( m_FrameName + UserGridSizeYEntry, &m_UserGridSize.y, 0.01 ); cfg->Read( m_FrameName + UserGridSizeYEntry, &m_UserGridSize.y, 0.01 );
cfg->Read( m_FrameName + UserGridUnitsEntry, (long*)&m_UserGridUnit, ( long )INCHES );
long itmp;
cfg->Read( m_FrameName + UserGridUnitsEntry, &itmp, ( long )INCHES );
m_UserGridUnit = (UserUnitType) itmp;
cfg->Read( m_FrameName + DisplayPadFillEntry, &m_DisplayPadFill, true ); cfg->Read( m_FrameName + DisplayPadFillEntry, &m_DisplayPadFill, true );
cfg->Read( m_FrameName + DisplayViaFillEntry, &m_DisplayViaFill, true ); cfg->Read( m_FrameName + DisplayViaFillEntry, &m_DisplayViaFill, true );
cfg->Read( m_FrameName + DisplayPadNumberEntry, &m_DisplayPadNum, true ); cfg->Read( m_FrameName + DisplayPadNumberEntry, &m_DisplayPadNum, true );
...@@ -488,6 +491,11 @@ void PCB_BASE_FRAME::LoadSettings() ...@@ -488,6 +491,11 @@ void PCB_BASE_FRAME::LoadSettings()
if( m_DisplayModText < FILAIRE || m_DisplayModText > SKETCH ) if( m_DisplayModText < FILAIRE || m_DisplayModText > SKETCH )
m_DisplayModText = FILLED; m_DisplayModText = FILLED;
// WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
// when reading doubles in config,
// but forget to back to current locale. So we call SetLocaleTo_Default
SetLocaleTo_Default( );
} }
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
* Recreate and read the new netlist using the Time Stamp identification * Recreate and read the new netlist using the Time Stamp identification
* (that reinit the new references) * (that reinit the new references)
*/ */
#include "vector"
#include "algorithm"
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
...@@ -40,8 +44,6 @@ ...@@ -40,8 +44,6 @@
#include "dialog_netlist.h" #include "dialog_netlist.h"
#include "protos.h"
// constants used by ReadPcbNetlist(): // constants used by ReadPcbNetlist():
#define TESTONLY 1 #define TESTONLY 1
#define READMODULE 0 #define READMODULE 0
...@@ -53,7 +55,6 @@ public: ...@@ -53,7 +55,6 @@ public:
wxString m_LibName; wxString m_LibName;
wxString m_CmpName; wxString m_CmpName;
wxString m_TimeStampPath; wxString m_TimeStampPath;
MODULEtoLOAD* m_Next;
public: MODULEtoLOAD( const wxString& libname, public: MODULEtoLOAD( const wxString& libname,
const wxString& cmpname, const wxString& cmpname,
...@@ -62,25 +63,16 @@ public: MODULEtoLOAD( const wxString& libname, ...@@ -62,25 +63,16 @@ public: MODULEtoLOAD( const wxString& libname,
m_LibName = libname; m_LibName = libname;
m_CmpName = cmpname; m_CmpName = cmpname;
m_TimeStampPath = timestamp_path; m_TimeStampPath = timestamp_path;
m_Next = NULL;
} }
~MODULEtoLOAD() { }; ~MODULEtoLOAD() { };
MODULEtoLOAD* Next() const { return (MODULEtoLOAD*) m_Next; }
void SetNext( MODULEtoLOAD* next ) { m_Next = next; }
}; };
static void SortListModulesToLoadByLibname( int NbModules );
static int BuildFootprintsListFromNetlistFile( static int BuildFootprintsListFromNetlistFile(
const wxString& aNetlistFullFilename, const wxString& aNetlistFullFilename,
wxArrayString& aBufName ); wxArrayString& aBufName );
static FILE * OpenNetlistFile( const wxString& aFullFileName ); static FILE * OpenNetlistFile( const wxString& aFullFileName );
static void AddToList( const wxString& NameLibCmp,
const wxString& NameCmp,
const wxString& TimeStampPath );
static int SetPadNetName( char* Text, static int SetPadNetName( char* Text,
MODULE* Module, MODULE* Module,
wxTextCtrl* aMessageWindow ); wxTextCtrl* aMessageWindow );
...@@ -99,8 +91,7 @@ static MODULE* ReadNetModule( PCB_EDIT_FRAME* aFrame, ...@@ -99,8 +91,7 @@ static MODULE* ReadNetModule( PCB_EDIT_FRAME* aFrame,
static void LoadListeModules( PCB_EDIT_FRAME* aPcbFrame ); static void LoadListeModules( PCB_EDIT_FRAME* aPcbFrame );
static int s_NbNewModules; static std::vector < MODULEtoLOAD* > s_ModuleToLoad_List;
static MODULEtoLOAD* s_ModuleToLoad_List;
/** /**
* Function OpenNetlistFile * Function OpenNetlistFile
...@@ -123,6 +114,16 @@ FILE * OpenNetlistFile( const wxString& aFullFileName ) ...@@ -123,6 +114,16 @@ FILE * OpenNetlistFile( const wxString& aFullFileName )
} }
/* Function to sort the footprint list.
* the given list is sorted by name
*/
static bool SortByLibName( MODULEtoLOAD* ref, MODULEtoLOAD* cmp )
{
int ii = ref->m_LibName.CmpNoCase( cmp->m_LibName );
return ii > 0;
}
/** /**
* Function ReadPcbNetlist * Function ReadPcbNetlist
* Update footprints (load missing footprints and delete on request extra * Update footprints (load missing footprints and delete on request extra
...@@ -171,9 +172,6 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename, ...@@ -171,9 +172,6 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename,
if( !netfile ) if( !netfile )
return false; return false;
FILE_LINE_READER netlistReader( netfile, aNetlistFullFilename );
char* Line = netlistReader;
SetLastNetListRead( aNetlistFullFilename ); SetLastNetListRead( aNetlistFullFilename );
if( aMessageWindow ) if( aMessageWindow )
...@@ -194,19 +192,22 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename, ...@@ -194,19 +192,22 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename,
State = 0; State = 0;
Comment = 0; Comment = 0;
s_NbNewModules = 0; s_ModuleToLoad_List.clear();
wxBusyCursor dummy; // Shows an hourglass while calculating wxBusyCursor dummy; // Shows an hourglass while calculating
/* First, read the netlist: Build the list of footprints to load (new /* First, read the netlist: Build the list of footprints to load (new
* footprints) * footprints)
*/ */
FILE_LINE_READER netlistReader( netfile, aNetlistFullFilename );
while( netlistReader.ReadLine() ) while( netlistReader.ReadLine() )
{ {
char* Line = netlistReader.Line();
Text = StrPurge( Line ); Text = StrPurge( Line );
if( Comment ) /* Comments in progress */ if( Comment ) /* Comments in progress */
{ {
// Test for end of the current comment
if( ( Text = strchr( Text, '}' ) ) == NULL ) if( ( Text = strchr( Text, '}' ) ) == NULL )
continue; continue;
Comment = 0; Comment = 0;
...@@ -237,44 +238,43 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename, ...@@ -237,44 +238,43 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename,
continue; continue;
} }
if( State >= 3 ) /* Do not analyzed pad description here. */ if( State >= 3 ) // First pass: pad descriptions are not read here.
{ {
State--; State--;
} }
} }
/* Load new footprints */ /* Load new footprints */
if( s_NbNewModules ) if( s_ModuleToLoad_List.size() )
{ {
LoadListeModules( this ); LoadListeModules( this );
// Free module list: // Free module list:
MODULEtoLOAD* item, * next_item; for( unsigned ii = 0; ii < s_ModuleToLoad_List.size(); ii++ )
for( item = s_ModuleToLoad_List; item != NULL; item = next_item )
{ {
next_item = item->Next(); delete s_ModuleToLoad_List[ii];
delete item;
} }
s_ModuleToLoad_List = NULL; s_ModuleToLoad_List.clear();
} }
/* Second read , All footprints are on board, one must update the schematic /* Second read , All footprints are on board.
* info (pad netnames) */ * One must update the schematic info (pad netnames)
*/
netlistReader.Rewind(); netlistReader.Rewind();
while( netlistReader.ReadLine() ) while( netlistReader.ReadLine() )
{ {
char* Line = netlistReader.Line();
Text = StrPurge( Line ); Text = StrPurge( Line );
if( Comment ) /* we are reading a if( Comment ) // we are reading a comment
* comment */
{ {
if( ( Text = strchr( Text, '}' ) ) == NULL ) /* this is the end // Test for end of the current comment
* of a comment */ if( ( Text = strchr( Text, '}' ) ) == NULL )
continue; continue;
Comment = 0; Comment = 0;
} }
if( *Text == '{' ) /* this is the beginning of a comment */ if( *Text == '{' ) // this is the beginning of a comment
{ {
Comment = 1; Comment = 1;
if( ( Text = strchr( Text, '}' ) ) == NULL ) if( ( Text = strchr( Text, '}' ) ) == NULL )
...@@ -326,7 +326,7 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename, ...@@ -326,7 +326,7 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename,
if( aDeleteExtraFootprints ) if( aDeleteExtraFootprints )
{ {
wxArrayString ModuleListFromNetlist; wxArrayString ModuleListFromNetlist;
/* Build list of modules in the netlist */ // Build list of modules in the netlist
int NbModulesNetListe = int NbModulesNetListe =
BuildFootprintsListFromNetlistFile( aNetlistFullFilename, BuildFootprintsListFromNetlistFile( aNetlistFullFilename,
ModuleListFromNetlist ); ModuleListFromNetlist );
...@@ -366,7 +366,7 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename, ...@@ -366,7 +366,7 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename,
} }
} }
/* Rebuild the connectivity */ // Rebuild the board connectivity:
Compile_Ratsnest( NULL, true ); Compile_Ratsnest( NULL, true );
if( GetBoard()->m_Track ) if( GetBoard()->m_Track )
...@@ -549,7 +549,11 @@ is [%s] and netlist said [%s]\n" ), ...@@ -549,7 +549,11 @@ is [%s] and netlist said [%s]\n" ),
if( TstOnly == TESTONLY ) if( TstOnly == TESTONLY )
AddToList( NameLibCmp, TextCmpName, TimeStampPath ); {
MODULEtoLOAD* newMod;
newMod = new MODULEtoLOAD( NameLibCmp, TextCmpName, TimeStampPath );
s_ModuleToLoad_List.push_back(newMod);
}
else else
{ {
if( aMessageWindow ) if( aMessageWindow )
...@@ -968,20 +972,6 @@ int ReadListeModules( const wxString& CmpFullFileName, const wxString* RefCmp, ...@@ -968,20 +972,6 @@ int ReadListeModules( const wxString& CmpFullFileName, const wxString* RefCmp,
} }
/* This function add to the current list of footprints found in netlist
* a new MODULEtoLOAD item (a descriptor of footprints)
*/
void AddToList( const wxString& NameLibCmp, const wxString& CmpName, const wxString& path )
{
MODULEtoLOAD* NewMod;
NewMod = new MODULEtoLOAD( NameLibCmp, CmpName, path );
NewMod->SetNext( s_ModuleToLoad_List );
s_ModuleToLoad_List = NewMod;
s_NbNewModules++;
}
/* Load new modules from library. /* Load new modules from library.
* If a module is being loaded it is duplicated, which avoids reading * If a module is being loaded it is duplicated, which avoids reading
* unnecessary library. * unnecessary library.
...@@ -989,15 +979,13 @@ void AddToList( const wxString& NameLibCmp, const wxString& CmpName, const wxStr ...@@ -989,15 +979,13 @@ void AddToList( const wxString& NameLibCmp, const wxString& CmpName, const wxStr
void LoadListeModules( PCB_EDIT_FRAME* aPcbFrame ) void LoadListeModules( PCB_EDIT_FRAME* aPcbFrame )
{ {
MODULEtoLOAD* ref, * cmp; MODULEtoLOAD* ref, * cmp;
int ii;
MODULE* Module = NULL; MODULE* Module = NULL;
wxPoint ModuleBestPosition; wxPoint ModuleBestPosition;
if( s_NbNewModules == 0 ) if( s_ModuleToLoad_List.size() == 0 )
return; return;
SortListModulesToLoadByLibname( s_NbNewModules ); sort( s_ModuleToLoad_List.begin(), s_ModuleToLoad_List.end(), SortByLibName );
ref = cmp = s_ModuleToLoad_List;
// Calculate the footprint "best" position: // Calculate the footprint "best" position:
if( aPcbFrame->GetBoard()->ComputeBoundingBox( true ) ) if( aPcbFrame->GetBoard()->ComputeBoundingBox( true ) )
...@@ -1010,8 +998,10 @@ void LoadListeModules( PCB_EDIT_FRAME* aPcbFrame ) ...@@ -1010,8 +998,10 @@ void LoadListeModules( PCB_EDIT_FRAME* aPcbFrame )
else else
ModuleBestPosition = wxPoint( 0, 0 ); ModuleBestPosition = wxPoint( 0, 0 );
for( ii = 0; ii < s_NbNewModules; ii++, cmp = cmp->Next() ) ref = cmp = s_ModuleToLoad_List[0];
for( unsigned ii = 0; ii < s_ModuleToLoad_List.size(); ii++ )
{ {
cmp = s_ModuleToLoad_List[ii];
if( (ii == 0) || ( ref->m_LibName != cmp->m_LibName) ) if( (ii == 0) || ( ref->m_LibName != cmp->m_LibName) )
{ {
/* New footprint : must be loaded from a library */ /* New footprint : must be loaded from a library */
...@@ -1057,44 +1047,3 @@ void LoadListeModules( PCB_EDIT_FRAME* aPcbFrame ) ...@@ -1057,44 +1047,3 @@ void LoadListeModules( PCB_EDIT_FRAME* aPcbFrame )
} }
} }
/* Routines used by qsort to sort a load module. */
static int SortByLibName( MODULEtoLOAD** ref, MODULEtoLOAD** cmp )
{
int ii = (*ref)->m_LibName.CmpNoCase( (*cmp)->m_LibName );
return ii;
}
/* Sort the module list in alphabetical order by module name.
*/
void SortListModulesToLoadByLibname( int NbModules )
{
MODULEtoLOAD** base_list, * item;
int ii;
base_list = (MODULEtoLOAD**) MyMalloc( NbModules * sizeof(MODULEtoLOAD*) );
for( ii = 0, item = s_ModuleToLoad_List; ii < NbModules; ii++ )
{
base_list[ii] = item;
item = item->Next();
}
qsort( base_list, NbModules, sizeof(MODULEtoLOAD*),
( int ( * )( const void*, const void* ) )SortByLibName );
s_ModuleToLoad_List = *base_list;
for( ii = 0; ii < NbModules - 1; ii++ )
{
item = base_list[ii];
item->SetNext( base_list[ii + 1] );
}
item = base_list[ii];
item->SetNext( NULL );
free( base_list );
}
...@@ -532,6 +532,11 @@ void PCB_EDIT_FRAME::LoadSettings() ...@@ -532,6 +532,11 @@ void PCB_EDIT_FRAME::LoadSettings()
config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption ); config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption );
config->Read( SHOW_MICROWAVE_TOOLS, &m_show_microwave_tools ); config->Read( SHOW_MICROWAVE_TOOLS, &m_show_microwave_tools );
config->Read( SHOW_LAYER_MANAGER_TOOLS, &m_show_layer_manager_tools ); config->Read( SHOW_LAYER_MANAGER_TOOLS, &m_show_layer_manager_tools );
// WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
// when reading doubles in config,
// but forget to back to current locale. So we call SetLocaleTo_Default
SetLocaleTo_Default( );
} }
......
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