From f50859fd09bbaf2f4eb53bf4166d15fe0988be85 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 18 May 2012 10:33:57 +0200 Subject: [PATCH] Pcbnew: fix bug Bug #1001107 (Solder Mask Ratio Clearance bad value) Because this bug could create bad values in footprint libraries, this parameter is now checked when reading a footprint description in legacy format --- gerbview/class_gbr_screen.cpp | 11 ++----- gerbview/locate.cpp | 4 +-- .../dialog_edit_module_for_BoardEditor.cpp | 19 +++++++---- .../dialog_edit_module_for_Modedit.cpp | 33 +++++++++++++------ pcbnew/dialogs/dialog_pad_properties.cpp | 12 ++++--- pcbnew/legacy_plugin.cpp | 8 +++++ 6 files changed, 54 insertions(+), 33 deletions(-) diff --git a/gerbview/class_gbr_screen.cpp b/gerbview/class_gbr_screen.cpp index f6670805d8..1deff7c3cf 100644 --- a/gerbview/class_gbr_screen.cpp +++ b/gerbview/class_gbr_screen.cpp @@ -1,7 +1,5 @@ /** - * @file classpcb.cpp - * @brief Member functions of classes used in Pcbnew (see pcbstruct.h) - * except for tracks (see class_track.cpp). + * @file class_gbr_screen.cpp */ #include @@ -24,14 +22,9 @@ /** - Default Pcbnew zoom values. + Default GerbView zoom values. Limited to 19 values to keep a decent size to menus. Roughly a 1.5 progression. - The last 2 values are handy when somebody uses a library import of a module - (or foreign data) which has a bad coordinate. - Also useful in GerbView for this reason. - Zoom 5 and 10 can create artefacts when drawing (integer overflow in low level graphic - functions ) */ static const double gbrZoomList[] = { diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index 1be9544d85..258c506537 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -1,8 +1,8 @@ /* * 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) 1992-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr + * Copyright (C) 1992-2012 KiCad Developers, see change_log.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 diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 4715db5306..192ed40598 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -120,10 +120,14 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties() if( m_CurrentModule->GetLocalSolderPasteMargin() == 0 ) m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() ); + + // 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" ), m_CurrentModule->GetLocalSolderPasteMarginRatio() * 100.0 ); + if( m_CurrentModule->GetLocalSolderPasteMarginRatio() == 0.0 && - msg[0] == '0') // Sometimes Printf add a sign if the value is small + msg[0] == '0') // Sometimes Printf adds a sign if the value is very small (0.0) m_SolderPasteMarginRatioCtrl->SetValue( wxT("-") + msg ); else m_SolderPasteMarginRatioCtrl->SetValue( msg ); @@ -487,12 +491,13 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) msg = m_SolderPasteMarginRatioCtrl->GetValue(); msg.ToDouble( &dtmp ); - // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50% - if( dtmp < -50 ) - dtmp = -50; - - if( dtmp > +100 ) - dtmp = +100; + // A -50% margin ratio means no paste on a pad, the ratio must be >= -50% + if( dtmp < -50.0 ) + dtmp = -50.0; + // A margin ratio is always <= 0 + // 0 means use full pad copper area + if( dtmp > 0.0 ) + dtmp = 0.0; m_CurrentModule->SetLocalSolderPasteMarginRatio( dtmp / 100 ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 87054a0d05..6f3e6e05d9 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -1,6 +1,8 @@ -/*******************************************************************************************/ -/* Dialog box for editing module properties and carateristics in module editor (modedit)*/ -/*******************************************************************************************/ +/** + * @file dialod_edit_module_for_Modedit.cpp + * + * @brief Dialog for editing a module properties in module editor (modedit) + */ #include #include @@ -89,7 +91,6 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() m_ValueCtrl->SetValue( m_ValueCopy->m_Text ); m_FootprintNameCtrl->SetValue( m_CurrentModule->m_LibRef ); -#if wxCHECK_VERSION( 2, 8, 0 ) m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non smd components" ) ); m_AttributsCtrl->SetItemToolTip( 1, _( @@ -97,7 +98,6 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() m_AttributsCtrl->SetItemToolTip( 2, _( "Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) ); -#endif // Controls on right side of the dialog switch( m_CurrentModule->m_Attributs & 255 ) @@ -121,10 +121,9 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() m_AutoPlaceCtrl->SetSelection( (m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 ); -#if wxCHECK_VERSION( 2, 8, 0 ) m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) ); m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) ); -#endif + m_CostRot90Ctrl->SetValue( m_CurrentModule->m_CntRot90 ); m_CostRot180Ctrl->SetValue( m_CurrentModule->m_CntRot180 ); @@ -165,6 +164,17 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() 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" ), + m_CurrentModule->GetLocalSolderPasteMarginRatio() * 100.0 ); + + if( m_CurrentModule->GetLocalSolderPasteMarginRatio() == 0.0 && + msg[0] == '0') // Sometimes Printf adds a sign if the value is very small (0.0) + m_SolderPasteMarginRatioCtrl->SetValue( wxT("-") + msg ); + else + m_SolderPasteMarginRatioCtrl->SetValue( msg ); + // if m_3D_ShapeNameListBox is not empty, preselect first 3D shape if( m_3D_ShapeNameListBox->GetCount() > 0 ) { @@ -377,9 +387,12 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) wxString msg = m_SolderPasteMarginRatioCtrl->GetValue(); msg.ToDouble( &dtmp ); - // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 % - if( dtmp < -50 ) - dtmp = -50; + // A -50% margin ratio means no paste on a pad, the ratio must be >= -50 % + if( dtmp < -50.0 ) + dtmp = -50.0; + // A margin ratio is always <= 0 + if( dtmp > 0.0 ) + dtmp = 0.0; m_CurrentModule->SetLocalSolderPasteMarginRatio( dtmp / 100 ); diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 3c26e9403d..1dce2137be 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -864,11 +864,13 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) msg = m_SolderPasteMarginRatioCtrl->GetValue(); msg.ToDouble( &dtmp ); - // A margin ratio of -50% means no paste on a pad, the ratio must be >= 50 % - if( dtmp < -50 ) - dtmp = -50; - if( dtmp > +100 ) - dtmp = +100; + // A -50% margin ratio means no paste on a pad, the ratio must be >= -50% + if( dtmp < -50.0 ) + dtmp = -50.0; + // A margin ratio is always <= 0 + // 0 means use full pad copper area + if( dtmp > 0.0 ) + dtmp = 0.0; aPad->SetLocalSolderPasteMarginRatio( dtmp / 100 ); diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 1a7d7ce7a1..0caee6f628 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1018,6 +1018,14 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() else if( TESTLINE( ".SolderPasteRatio" ) ) { double tmp = atof( line + SZ( ".SolderPasteRatio" ) ); + // Due to a bug in dialog editor in Modedit, fixed in BZR version 3565 + // this parameter can be broken. + // It should be >= -50% (no solder paste) and <= 0% (full area of the pad) + + if( tmp < -0.50 ) + tmp = -0.50; + if( tmp > 0.0 ) + tmp = 0.0; module->SetLocalSolderPasteMarginRatio( tmp ); }