Pcbnew: Fix Bug #1185556. fix issue about Solder Paste Ratio value which was accepting only one digit in mantissa in 3 dialogs (now 6 digits in all dialogs).

fix potential issue in .kicad_pcb file creation, in some places where a %g or %.16g format was used:
al least under Mingw/gcc4.7.2, the floating number was written using scientific notation, not accepted by the S-expr reader.
This commit is contained in:
jean-pierre charras 2013-05-30 21:32:00 +02:00
parent 5e8c38d293
commit 57b30ad254
16 changed files with 78 additions and 52 deletions

View File

@ -48,22 +48,20 @@
* application class.
*/
wxString g_ProductName = wxT( "KiCad E.D.A. " );
bool g_ShowPageLimits = true;
wxString g_UserLibDirBuffer;
EDA_UNITS_T g_UserUnit;
EDA_COLOR_T g_GhostColor;
#if defined(KICAD_GOST)
static const bool s_gost = true;
#else
static const bool s_gost = false;
#endif
bool IsGOST()
{
return s_gost;
#if defined(KICAD_GOST)
return true;
#else
return false;
#endif
}

View File

@ -44,6 +44,9 @@
#include <worksheet_shape_builder.h>
static const wxString productName = wxT( "KiCad E.D.A. " );
void DrawPageLayout( wxDC* aDC, EDA_DRAW_PANEL * aCanvas,
const PAGE_INFO& aPageInfo,
const wxString &aFullSheetName,
@ -251,7 +254,7 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
break;
case 'K':
msg += g_ProductName + wxGetApp().GetAppName();
msg += productName + wxGetApp().GetAppName();
msg += wxT( " " ) + GetBuildVersion();
break;

View File

@ -1,10 +1,10 @@
/*
* 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) 2007-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -447,9 +447,6 @@ private:
void setMargins();
};
extern wxString g_ProductName;
/// Default user lib path can be left void, if the standard lib path is used
extern wxString g_UserLibDirBuffer;
@ -461,8 +458,6 @@ extern EDA_UNITS_T g_UserUnit; ///< display units
extern EDA_COLOR_T g_GhostColor;
// COMMON.CPP
/**
* Function SetLocaleTo_C_standard
* because KiCad is internationalized, switch internalization to "C" standard
@ -628,12 +623,12 @@ wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter );
*/
unsigned GetRunningMicroSecs();
/**
/**
* Formats a wxDateTime using the long date format (on wx 2.9) or
* an hardcoded format in wx 2.8; the idea is to avoid like the plague
* the numeric-only date formats: it's difficult to discriminate between
* dd/mm/yyyy and mm/dd/yyyy. The output is meant for user consumption
* so no attempt to parse it should be done
* so no attempt to parse it should be done
*/
wxString FormatDateLong( const wxDateTime &aDate );

View File

@ -148,7 +148,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
// Add solder paste margin ration in per cent
// for the usual default value 0.0, display -0.0 (or -0,0 in some countries)
msg.Printf( wxT( "%.1f" ),
msg.Printf( wxT( "%f" ),
m_CurrentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
if( m_CurrentModule->GetLocalSolderPasteMarginRatio() == 0.0 &&

View File

@ -263,7 +263,7 @@ DIALOG_MODULE_BOARD_EDITOR_BASE::DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* pare
m_SolderPasteMarginUnits->Wrap( -1 );
fgSizerClearances->Add( m_SolderPasteMarginUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_staticTextRatio = new wxStaticText( m_PanelProperties, wxID_ANY, _("Solder mask ratio clearance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRatio = new wxStaticText( m_PanelProperties, wxID_ANY, _("Solder paste ratio clearance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRatio->Wrap( -1 );
m_staticTextRatio->SetToolTip( _("This is the local clearance ratio in per cent between pads and the solder paste\nfor this footprint.\nA value of 10 means the clearance value is 10 per cent of the pad size\nThis value can be superseded by a pad local value.\nThe final clearance value is the sum of this value and the clearance value\nA negative value means a smaller mask size than pad size.") );

View File

@ -3926,7 +3926,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Solder mask ratio clearance:</property>
<property name="label">Solder paste ratio clearance:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>

View File

@ -182,15 +182,15 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
m_SolderPasteMarginCtrl->SetValue( wxT("-") + m_SolderPasteMarginCtrl->GetValue() );
if( m_currentModule->GetLocalSolderPasteMarginRatio() == 0.0 )
msg.Printf( wxT( "-%.1f" ), m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
msg.Printf( wxT( "-%f" ), m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
else
msg.Printf( wxT( "%.1f" ), m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
msg.Printf( wxT( "%f" ), m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
m_SolderPasteMarginRatioCtrl->SetValue( msg );
// Add solder paste margin ration in per cent
// for the usual default value 0.0, display -0.0 (or -0,0 in some countries)
msg.Printf( wxT( "%.1f" ),
msg.Printf( wxT( "%f" ),
m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
if( m_currentModule->GetLocalSolderPasteMarginRatio() == 0.0 &&

View File

@ -206,7 +206,7 @@ DIALOG_MODULE_MODULE_EDITOR_BASE::DIALOG_MODULE_MODULE_EDITOR_BASE( wxWindow* pa
m_SolderPasteMarginUnits->Wrap( -1 );
fgSizer1->Add( m_SolderPasteMarginUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_staticTextRatio = new wxStaticText( m_PanelProperties, wxID_ANY, _("Solder mask ratio clearance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRatio = new wxStaticText( m_PanelProperties, wxID_ANY, _("Solder paste ratio clearance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRatio->Wrap( -1 );
m_staticTextRatio->SetToolTip( _("This is the local clearance ratio in per cent between pads and the solder paste\nfor this footprint.\nA value of 10 means the clearance value is 10 per cent of the pad size\nThis value can be superseded by a pad local value.\nThe final clearance value is the sum of this value and the clearance value\nA negative value means a smaller mask size than pad size.") );

View File

@ -3133,7 +3133,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Solder mask ratio clearance:</property>
<property name="label">Solder paste ratio clearance:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -47,6 +47,7 @@ DIALOG_PADS_MASK_CLEARANCE_BASE::DIALOG_PADS_MASK_CLEARANCE_BASE( wxWindow* pare
fgGridSolderMaskSizer->Add( m_MaskClearanceTitle, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_SolderMaskMarginCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_SolderMaskMarginCtrl->SetMaxLength( 0 );
fgGridSolderMaskSizer->Add( m_SolderMaskMarginCtrl, 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_SolderMaskMarginUnits = new wxStaticText( this, wxID_ANY, _("Inch"), wxDefaultPosition, wxDefaultSize, 0 );
@ -60,6 +61,7 @@ DIALOG_PADS_MASK_CLEARANCE_BASE::DIALOG_PADS_MASK_CLEARANCE_BASE( wxWindow* pare
fgGridSolderMaskSizer->Add( m_staticTextMinWidth, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_SolderMaskMinWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_SolderMaskMinWidthCtrl->SetMaxLength( 0 );
fgGridSolderMaskSizer->Add( m_SolderMaskMinWidthCtrl, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_solderMaskMinWidthUnit = new wxStaticText( this, wxID_ANY, _("Inch"), wxDefaultPosition, wxDefaultSize, 0 );
@ -82,19 +84,21 @@ DIALOG_PADS_MASK_CLEARANCE_BASE::DIALOG_PADS_MASK_CLEARANCE_BASE( wxWindow* pare
fgGridSolderMaskSizer->Add( m_staticTextSolderPaste, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_SolderPasteMarginCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_SolderPasteMarginCtrl->SetMaxLength( 0 );
fgGridSolderMaskSizer->Add( m_SolderPasteMarginCtrl, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_SolderPasteMarginUnits = new wxStaticText( this, wxID_ANY, _("Inch"), wxDefaultPosition, wxDefaultSize, 0 );
m_SolderPasteMarginUnits->Wrap( -1 );
fgGridSolderMaskSizer->Add( m_SolderPasteMarginUnits, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_staticTextRatio = new wxStaticText( this, wxID_ANY, _("Solder mask ratio clearance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRatio = new wxStaticText( this, wxID_ANY, _("Solder paste ratio clearance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRatio->Wrap( -1 );
m_staticTextRatio->SetToolTip( _("This is the global clearance ratio in per cent between pads and the solder paste\nA value of 10 means the clearance value is 10 per cent of the pad size\nThis value can be superseded by local values for a footprint or a pad.\nThe final clearance value is the sum of this value and the clearance value") );
fgGridSolderMaskSizer->Add( m_staticTextRatio, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_SolderPasteMarginRatioCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_SolderPasteMarginRatioCtrl->SetMaxLength( 0 );
fgGridSolderMaskSizer->Add( m_SolderPasteMarginRatioCtrl, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_SolderPasteRatioMarginUnits = new wxStaticText( this, wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 );

View File

@ -1338,7 +1338,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Solder mask ratio clearance:</property>
<property name="label">Solder paste ratio clearance:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -11,6 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>

View File

@ -359,7 +359,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
if( m_dummyPad->GetLocalSolderPasteMargin() == 0 )
m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() );
msg.Printf( wxT( "%.1f" ), m_dummyPad->GetLocalSolderPasteMarginRatio() * 100.0 );
msg.Printf( wxT( "%f" ), m_dummyPad->GetLocalSolderPasteMarginRatio() * 100.0 );
if( m_dummyPad->GetLocalSolderPasteMarginRatio() == 0.0 && msg[0] == '0' )
// Sometimes Printf adds a sign if the value is small

View File

@ -438,7 +438,7 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
m_SolderPasteMarginUnits->Wrap( -1 );
fgClearancesGridSizer->Add( m_SolderPasteMarginUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
m_staticTextRatio = new wxStaticText( m_localSettingsPanel, wxID_ANY, _("Solder mask ratio clearance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRatio = new wxStaticText( m_localSettingsPanel, wxID_ANY, _("Solder paste ratio clearance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRatio->Wrap( -1 );
m_staticTextRatio->SetToolTip( _("This is the local clearance ratio in per cent between this pad and the solder paste.\nA value of 10 means the clearance value is 10 per cent of the pad size\nIf 0 the footprint value or the global value is used..\nThe final clearance value is the sum of this value and the clearance value\nA negative value means a smaller mask size than pad size.") );

View File

@ -7102,7 +7102,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Solder mask ratio clearance:</property>
<property name="label">Solder paste ratio clearance:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>

View File

@ -62,6 +62,30 @@ using namespace std;
*/
static const wxString traceFootprintLibrary( wxT( "KicadFootprintLib" ) );
// Helper function to print a float number without using scientific notation
// and no trailing 0
// For many reasons, S-expr does not accept scientific notation
// for floating numbers, so we cannot use the %g format to print a fp number
// and %f leaves trailing 0.
// this helper function uses the %f format, and then removes trailing 0
std::string double2str( double aValue )
{
char buf[50];
int len = sprintf( buf, "%.16f", aValue );
while( --len > 0 && buf[len] == '0' )
buf[len] = '\0';
// Remove useless separator:
if( buf[len] == '.' )
buf[len] = '\0';
else
++len;
return std::string( buf, len );
}
/**
* Class FP_CACHE_ITEM
@ -549,8 +573,8 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
FMTIU( aBoard->GetDesignSettings().m_SolderPasteMargin ).c_str() );
if( aBoard->GetDesignSettings().m_SolderPasteMarginRatio != 0 )
m_out->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %g)\n",
aBoard->GetDesignSettings().m_SolderPasteMarginRatio );
m_out->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %s)\n",
double2str( aBoard->GetDesignSettings().m_SolderPasteMarginRatio ).c_str() );
m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
FMTIU( aBoard->GetOriginAxisPosition().x ).c_str(),
@ -896,8 +920,8 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
FMT_IU( aModule->GetLocalSolderPasteMargin() ).c_str() );
if( aModule->GetLocalSolderPasteMarginRatio() != 0 )
m_out->Print( aNestLevel+1, "(solder_paste_ratio %g)\n",
aModule->GetLocalSolderPasteMarginRatio() );
m_out->Print( aNestLevel+1, "(solder_paste_ratio %s)\n",
double2str( aModule->GetLocalSolderPasteMarginRatio() ).c_str() );
if( aModule->GetLocalClearance() != 0 )
m_out->Print( aNestLevel+1, "(clearance %s)\n",
@ -947,20 +971,20 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(model %s\n",
m_out->Quotew( t3D->m_Shape3DName ).c_str() );
m_out->Print( aNestLevel+2, "(at (xyz %.16g %.16g %.16g))\n",
t3D->m_MatPosition.x,
t3D->m_MatPosition.y,
t3D->m_MatPosition.z );
m_out->Print( aNestLevel+2, "(at (xyz %s %s %s))\n",
double2str( t3D->m_MatPosition.x ).c_str(),
double2str( t3D->m_MatPosition.y ).c_str(),
double2str( t3D->m_MatPosition.z ).c_str() );
m_out->Print( aNestLevel+2, "(scale (xyz %.16g %.16g %.16g))\n",
t3D->m_MatScale.x,
t3D->m_MatScale.y,
t3D->m_MatScale.z );
m_out->Print( aNestLevel+2, "(scale (xyz %s %s %s))\n",
double2str( t3D->m_MatScale.x ).c_str(),
double2str( t3D->m_MatScale.y ).c_str(),
double2str( t3D->m_MatScale.z ).c_str() );
m_out->Print( aNestLevel+2, "(rotate (xyz %.16g %.16g %.16g))\n",
t3D->m_MatRotation.x,
t3D->m_MatRotation.y,
t3D->m_MatRotation.z );
m_out->Print( aNestLevel+2, "(rotate (xyz %s %s %s))\n",
double2str( t3D->m_MatRotation.x ).c_str(),
double2str( t3D->m_MatRotation.y ).c_str(),
double2str( t3D->m_MatRotation.z ).c_str() );
m_out->Print( aNestLevel+1, ")\n" );
}
@ -1133,8 +1157,8 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const
FMT_IU( aPad->GetLocalSolderPasteMargin() ).c_str() );
if( aPad->GetLocalSolderPasteMarginRatio() != 0 )
m_out->Print( aNestLevel+1, "(solder_paste_margin_ratio %g)\n",
aPad->GetLocalSolderPasteMarginRatio() );
m_out->Print( aNestLevel+1, "(solder_paste_margin_ratio %s)\n",
double2str( aPad->GetLocalSolderPasteMarginRatio() ).c_str() );
if( aPad->GetLocalClearance() != 0 )
m_out->Print( aNestLevel+1, "(clearance %s)\n",