Commit 777076c8 authored by charras's avatar charras

minor changes. See changelog

parent 6bb111cb
......@@ -53,7 +53,7 @@ int Struct3D_Master:: ReadData()
}
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
while( GetLine( file, line, &LineNum, 512 ) )
{
text = strtok( line, " \t\n\r" );
......@@ -75,7 +75,7 @@ int Struct3D_Master:: ReadData()
}
fclose( file );
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
return 0;
}
......
......@@ -5,6 +5,16 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-June-06 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+all:
minor changes
added void SetLocaleTo_C_standard(void) and void SetLocaleTo_Default(void)
This is wrapper to the C setlocale( LC_NUMERIC, "C" )
and setlocale( LC_NUMERIC, "" )function,
but could make more easier an optional use of locale in kicad in floating point notations
2008-May-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew
......
......@@ -25,6 +25,39 @@ wxString GetBuildVersion()
}
/********************************/
void SetLocaleTo_C_standard(void)
/********************************/
/** function SetLocaleTo_C_standard
because kicad is internationalized, switch internatization to "C" standard
i.e. uses the . (dot) as separator in print/read float numbers
(some contries (France, Germany ..) use , (comma) as separator)
This function must be called before read or write ascii files using float numbers in data
the SetLocaleTo_C_standard function must be called after reading or writing the file
This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function,
but could make more easier an optional use of locale in kicad
*/
{
setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C
}
/********************************/
void SetLocaleTo_Default(void)
/********************************/
/** function SetLocaleTo_Default
because kicad is internationalized, switch internatization to default
to use the default separator in print/read float numbers
(. (dot) but some contries (France, Germany ..) use , (comma) as separator)
This function must be called after a call to SetLocaleTo_C_standard
This is wrapper to the C setlocale( LC_NUMERIC, "" ) function,
but could make more easier an optional use of locale in kicad
*/
{
setlocale( LC_NUMERIC, "" ); // revert to the current locale
}
/*********************************************************************************************/
Ki_PageDescr::Ki_PageDescr( const wxSize& size, const wxPoint& offset, const wxString& name )
/*********************************************************************************************/
......@@ -285,8 +318,8 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding )
/**************************************************************/
/* Return the name of the layer number "layer_number".
* if "is_filefame" == TRUE, the name can be used for a file name
* (not internatinalized, no space)
* if omitSpacePadding == TRUE, the name can be used for a file name
* (no spaces, replaced by _)
*/
{
const unsigned LAYER_LIMIT = 29;
......@@ -302,7 +335,7 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding )
_( "Adhes Cop" ), _( "Adhes Cmp" ), _( "SoldP Cop" ), _( "SoldP Cmp" ),
_( "SilkS Cop" ), _( "SilkS Cmp" ), _( "Mask Cop " ), _( "Mask Cmp " ),
_( "Drawings " ), _( "Comments " ), _( "Eco1 " ), _( "Eco2 " ),
_( "Edges Pcb" ), _( "BAD INDEX" ),
_( "Edges Pcb" ), _( "BAD INDEX" )
};
if( (unsigned) layer_number > LAYER_LIMIT )
......@@ -445,9 +478,9 @@ int GetTimeStamp()
}
/*************************************************/
/**************************************************************/
const wxString& valeur_param( int valeur, wxString& buf_texte )
/*************************************************/
/**************************************************************/
/* Retourne pour affichage la valeur d'un parametre, selon type d'unites choisies
* entree : valeur en mils , buffer de texte
......
......@@ -263,6 +263,8 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
if( !succes )
{
}
SetLocaleTo_Default( ); // Set locale option for separator used in float numbers
#ifdef KICAD_PYTHON
PyHandler::GetInstance()->SetAppName( name );
......
......@@ -81,9 +81,9 @@ MODULE * Module = NULL;
{
Module = new MODULE(m_Pcb);
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale(LC_NUMERIC, "C");
SetLocaleTo_C_standard( );
Module->ReadDescr(lib_module, &LineNum);
setlocale(LC_NUMERIC, ""); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
Module->SetPosition(wxPoint(0,0) );
fclose(lib_module);
return(Module) ;
......
......@@ -319,8 +319,6 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
switch( DrawItem->Type() )
{
case TYPE_SCH_LABEL:
break;
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
#undef STRUCT
......
......@@ -568,10 +568,10 @@ void WinEDA_PlotHPGLFrame::Plot_Schematic_HPGL( int Select_PlotAll, int HPGL_She
else
PlotFileName = MakeFileName( dirbuf, g_DefaultSchematicFileName, wxT( ".plt" ) );
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
InitPlotParametresHPGL( PlotOffset, g_PlotScaleX, g_PlotScaleY );
Plot_1_Page_HPGL( PlotFileName, screen );
setlocale( LC_NUMERIC, "" );
SetLocaleTo_Default( );
screen = (BASE_SCREEN*) screen->Pnext;
if( Select_PlotAll == FALSE )
break;
......
......@@ -481,7 +481,7 @@ void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName,
return;
}
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
Line.Printf( _( "Plot: %s\n" ), FileName.GetData() );
m_MsgBox->AppendText( Line );
......@@ -610,7 +610,7 @@ void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName,
/* fin */
CloseFilePS( PlotOutput );
setlocale( LC_NUMERIC, "" );
SetLocaleTo_Default( );
m_MsgBox->AppendText( wxT( "Ok\n" ) );
}
......
......@@ -224,7 +224,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
}
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
// write the PCB heading
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
......@@ -238,7 +238,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
// the destructor should destroy all owned sub-objects
delete pcb;
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
wxEndBusyCursor();
return 1;
}
......@@ -154,7 +154,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
wxSetWorkingDirectory( path );
wxBusyCursor show_wait;
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
while( TRUE )
{
......@@ -256,7 +256,7 @@ bool WinEDA_GerberFrame::Read_GERBER_File( wxDC* DC,
}
fclose( gerber_layer->m_Current_File );
setlocale( LC_NUMERIC, "" );
SetLocaleTo_Default( );
/* Init DCodes list and perhaps read a DCODES file,
* if the gerber file is only a RS274D file (without any aperture information)
......
......@@ -355,6 +355,28 @@ class WinEDA_DrawPanel;
/* COMMON.CPP */
/** function SetLocaleTo_C_standard
because kicad is internationalized, switch internatization to "C" standard
i.e. uses the . (dot) as separator in print/read float numbers
(some contries (France, Germany ..) use , (comma) as separator)
This function must be called before read or write ascii files using float numbers in data
the SetLocaleTo_C_standard function must be called after reading or writing the file
This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function,
but could make more easier an optional use of locale in kicad
*/
void SetLocaleTo_C_standard(void);
/** function SetLocaleTo_Default
because kicad is internationalized, switch internatization to default
to use the default separator in print/read float numbers
(. (dot) but some contries (France, Germany ..) use , (comma) as separator)
This function must be called after a call to SetLocaleTo_C_standard
This is wrapper to the C setlocale( LC_NUMERIC, "" ) function,
but could make more easier an optional use of locale in kicad
*/
void SetLocaleTo_Default(void);
/**
* Operator << overload
......
......@@ -247,6 +247,8 @@ void WinEDA_MainFrame::OnCloseWindow( wxCloseEvent& Event )
m_Parent->m_HtmlCtrl->GetFrame()->Close( TRUE );
m_Parent->m_HtmlCtrl = NULL;
}
m_LeftWin->Show(false);
Destroy();
}
......
......@@ -50,7 +50,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, w
wxString msg;
setlocale( LC_NUMERIC, "C" ); // Use the standard notation for float numbers
SetLocaleTo_C_standard( ); // Use the standard notation for float numbers
g_PlotOrient = 0;
/* calcul des dimensions et centre du PCB */
aPcb->ComputeBoundaryBox();
......@@ -357,7 +357,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, w
break;
}
setlocale( LC_NUMERIC, "" ); // Revert to local notation for float numbers
SetLocaleTo_Default( ); // Revert to local notation for float numbers
g_PlotOrient = old_g_PlotOrient;
}
......
......@@ -144,7 +144,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
}
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
/* Affichage du bilan : */
MsgPanel->EraseMsgBox();
......@@ -250,7 +250,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
fclose( LayerCu );
}
MyFree( Liste );
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
msg = wxT( "Cmp File: " ) + NameLayerCmp;
if( GenCu )
......@@ -294,7 +294,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
}
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
/* Generation entete du fichier 'commentaires) */
sprintf( Line, "## Module report - date %s\n", DateAndTime( Buff ) );
......@@ -421,7 +421,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
/* Generation fin du fichier */
fputs( "$EndDESCRIPTION\n", rptfile );
fclose( rptfile );
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
}
......
......@@ -408,7 +408,7 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( std::vector<HOLE_INFO>& aHol
float xt, yt;
char line[1024];
setlocale( LC_NUMERIC, "C" ); // Use the standard notation for float numbers
SetLocaleTo_C_standard( ); // Use the standard notation for float numbers
Write_Excellon_Header( dest );
......@@ -539,7 +539,7 @@ int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( std::vector<HOLE_INFO>& aHol
Write_End_Of_File_Drill( dest );
setlocale( LC_NUMERIC, "" ); // Revert to locale float notation
SetLocaleTo_Default( ); // Revert to locale float notation
return holes_count;
}
......
......@@ -772,7 +772,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
wxBusyCursor dummy;
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
NbDraw = NbTrack = NbZone = NbMod = NbNets = -1;
m_Pcb->m_NbNets = 0;
......@@ -1003,7 +1003,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
}
}
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
Affiche_Message( wxEmptyString );
......@@ -1035,7 +1035,7 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
wxBeginBusyCursor();
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
/* Ecriture de l'entete PCB : */
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
......@@ -1047,7 +1047,7 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
rc = m_Pcb->Save( aFile );
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
wxEndBusyCursor();
if( !rc )
......
......@@ -268,9 +268,9 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
NewModule = new MODULE( m_Pcb );
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
NewModule->ReadDescr( lib_module, &LineNum );
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
if( Module == NULL ) /* 1er Module */
{
m_Pcb->m_Modules = NewModule;
......
......@@ -449,7 +449,7 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event )
bufsize = 100;
ptbuf = PolyEdges = (double*) MyZMalloc( bufsize * 2 * sizeof(double) );
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
int LineNum = 0;
while( GetLine( File, Line, &LineNum, sizeof(Line) - 1 ) != NULL )
{
......@@ -504,7 +504,7 @@ void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event )
PolyEdges = NULL;
}
fclose( File );
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
ShapeScaleX *= unitconv;
ShapeScaleY *= unitconv;
......
This diff is collapsed.
......@@ -74,7 +74,7 @@ void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer
return;
}
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
InitPlotParametresGERBER( g_PlotOffset, scale_x, scale_y );
......@@ -135,7 +135,7 @@ void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer
}
Fin_Trace_GERBER( this, dest );
setlocale( LC_NUMERIC, "" );
SetLocaleTo_Default( );
}
......
......@@ -69,7 +69,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer )
return;
}
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN );
......@@ -185,7 +185,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer )
/* fin */
CloseFileHPGL( dest );
setlocale( LC_NUMERIC, "" );
SetLocaleTo_Default( );
}
......
......@@ -53,7 +53,7 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer, bo
return;
}
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN );
......@@ -226,7 +226,7 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer, bo
// fin
CloseFilePS( dest );
setlocale( LC_NUMERIC, "" );
SetLocaleTo_Default( );
}
......
......@@ -573,7 +573,7 @@ void WinEDA_PcbFrame::ReadAutoroutedTracks( wxDC* DC )
Affiche_Message( msg );
}
setlocale( LC_NUMERIC, "C" );
SetLocaleTo_C_standard( );
track_width = g_DesignSettings.m_CurrentTrackWidth;
via_size = g_DesignSettings.m_CurrentViaSize;
......@@ -654,7 +654,7 @@ void WinEDA_PcbFrame::ReadAutoroutedTracks( wxDC* DC )
fclose( File );
setlocale( LC_NUMERIC, "" );
SetLocaleTo_Default( );
if( NbTrack == 0 )
DisplayError( this, wxT( "Warning: No tracks" ), 10 );
......
......@@ -3971,7 +3971,7 @@ int main( int argc, char** argv )
SPECCTRA_DB db;
bool failed = false;
setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C
SetLocaleTo_C_standard( ); // Switch the locale to standard C
if( argc == 2 )
{
......@@ -4002,7 +4002,7 @@ int main( int argc, char** argv )
db.SetFILE( stdout );
pcb->Format( &db, 0 );
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
}
#endif
......
......@@ -82,7 +82,7 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event )
db.SetPCB( SPECCTRA_DB::MakePCB() );
setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C
SetLocaleTo_C_standard( ); // Switch the locale to standard C
// DSN Images (=Kicad MODULES and pads) must be presented from the
// top view. So we temporarily flip any modules which are on the back
......@@ -105,7 +105,7 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event )
errorText = ioe.errorText;
}
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
// done assuredly, even if an exception was thrown and caught.
db.RevertMODULEs( m_Pcb );
......
......@@ -86,7 +86,7 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
SPECCTRA_DB db;
setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C
SetLocaleTo_C_standard( ); // Switch the locale to standard C
try
{
......@@ -95,7 +95,7 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
}
catch( IOError ioe )
{
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
ioe.errorText += '\n';
ioe.errorText += _("BOARD may be corrupted, do not save it.");
......@@ -106,7 +106,7 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
return;
}
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
m_SelTrackWidthBox_Changed = TRUE;
m_SelViaSizeBox_Changed = TRUE;
......
......@@ -507,9 +507,9 @@ bool WinEDA_PrintSVGFrame::DrawPage( const wxString& FullFileName, BASE_SCREEN*
panel->m_ClipBox.SetWidth( 0x7FFFFF0 ); panel->m_ClipBox.SetHeight( 0x7FFFFF0 );
g_IsPrinting = TRUE;
setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C (needed to print floating point numbers like 1.3)
SetLocaleTo_C_standard( ); // Switch the locale to standard C (needed to print floating point numbers like 1.3)
panel->PrintPage( &dc, m_Print_Sheet_Ref, m_PrintMaskLayer );
setlocale( LC_NUMERIC, "" ); // revert to the current locale
SetLocaleTo_Default( ); // revert to the current locale
g_IsPrinting = FALSE;
panel->m_ClipBox = tmp;
}
......
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