Commit ea467e67 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

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
parent 6d1fe6fe
Loading
Loading
Loading
Loading
+2 −9
Original line number Original line Diff line number Diff line
/**
/**
 * @file classpcb.cpp
 * @file class_gbr_screen.cpp
 * @brief Member functions of classes used in Pcbnew (see pcbstruct.h)
 *        except for tracks (see class_track.cpp).
 */
 */


#include <fctsys.h>
#include <fctsys.h>
@@ -24,14 +22,9 @@




/**
/**
    Default Pcbnew zoom values.
    Default GerbView zoom values.
    Limited to 19 values to keep a decent size to menus.
    Limited to 19 values to keep a decent size to menus.
    Roughly a 1.5 progression.
    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[] =
static const double gbrZoomList[] =
{
{
+2 −2
Original line number Original line Diff line number Diff line
/*
/*
 * 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) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
 * Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
 * Copyright (C) 1992-2012 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
+12 −7
Original line number Original line Diff line number Diff line
@@ -120,10 +120,14 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
    if( m_CurrentModule->GetLocalSolderPasteMargin() == 0 )
    if( m_CurrentModule->GetLocalSolderPasteMargin() == 0 )
        m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) +
        m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) +
                                           m_SolderPasteMarginCtrl->GetValue() );
                                           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" ),
    msg.Printf( wxT( "%.1f" ),
                    m_CurrentModule->GetLocalSolderPasteMarginRatio() * 100.0 );
                    m_CurrentModule->GetLocalSolderPasteMarginRatio() * 100.0 );

    if( m_CurrentModule->GetLocalSolderPasteMarginRatio() == 0.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 );
        m_SolderPasteMarginRatioCtrl->SetValue( wxT("-") + msg );
    else
    else
        m_SolderPasteMarginRatioCtrl->SetValue( msg );
        m_SolderPasteMarginRatioCtrl->SetValue( msg );
@@ -487,12 +491,13 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
    msg = m_SolderPasteMarginRatioCtrl->GetValue();
    msg = m_SolderPasteMarginRatioCtrl->GetValue();
    msg.ToDouble( &dtmp );
    msg.ToDouble( &dtmp );


    // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50%
    // A -50% margin ratio means no paste on a pad, the ratio must be >= -50%
    if( dtmp < -50 )
    if( dtmp < -50.0 )
        dtmp = -50;
        dtmp = -50.0;

    // A margin ratio is always <= 0
    if( dtmp > +100 )
    // 0 means use full pad copper area
        dtmp = +100;
    if( dtmp > 0.0 )
        dtmp = 0.0;


    m_CurrentModule->SetLocalSolderPasteMarginRatio( dtmp / 100 );
    m_CurrentModule->SetLocalSolderPasteMarginRatio( dtmp / 100 );


+23 −10
Original line number Original line Diff line number Diff line
/*******************************************************************************************/
/**
/* 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 <fctsys.h>
#include <fctsys.h>
#include <class_drawpanel.h>
#include <class_drawpanel.h>
@@ -89,7 +91,6 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
    m_ValueCtrl->SetValue( m_ValueCopy->m_Text );
    m_ValueCtrl->SetValue( m_ValueCopy->m_Text );
    m_FootprintNameCtrl->SetValue( m_CurrentModule->m_LibRef );
    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( 0, _( "Use this attribute for most non smd components" ) );
    m_AttributsCtrl->SetItemToolTip( 1,
    m_AttributsCtrl->SetItemToolTip( 1,
                                    _(
                                    _(
@@ -97,7 +98,6 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
    m_AttributsCtrl->SetItemToolTip( 2,
    m_AttributsCtrl->SetItemToolTip( 2,
                                    _(
                                    _(
                                        "Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
                                        "Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
#endif


    // Controls on right side of the dialog
    // Controls on right side of the dialog
    switch( m_CurrentModule->m_Attributs & 255 )
    switch( m_CurrentModule->m_Attributs & 255 )
@@ -121,10 +121,9 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()


    m_AutoPlaceCtrl->SetSelection(
    m_AutoPlaceCtrl->SetSelection(
        (m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 );
        (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( 0, _( "Enable hotkey move commands and Auto Placement" ) );
    m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable 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_CostRot90Ctrl->SetValue( m_CurrentModule->m_CntRot90 );


    m_CostRot180Ctrl->SetValue( m_CurrentModule->m_CntRot180 );
    m_CostRot180Ctrl->SetValue( m_CurrentModule->m_CntRot180 );
@@ -165,6 +164,17 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()


    m_SolderPasteMarginRatioCtrl->SetValue( msg );
    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 is not empty, preselect first 3D shape
    if( m_3D_ShapeNameListBox->GetCount() > 0 )
    if( m_3D_ShapeNameListBox->GetCount() > 0 )
    {
    {
@@ -377,9 +387,12 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
    wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
    wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
    msg.ToDouble( &dtmp );
    msg.ToDouble( &dtmp );


    // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 %
    // A  -50% margin ratio means no paste on a pad, the ratio must be >= -50 %
    if( dtmp < -50 )
    if( dtmp < -50.0 )
        dtmp = -50;
        dtmp = -50.0;
    // A margin ratio is always <= 0
    if( dtmp > 0.0 )
        dtmp = 0.0;


    m_CurrentModule->SetLocalSolderPasteMarginRatio( dtmp / 100 );
    m_CurrentModule->SetLocalSolderPasteMarginRatio( dtmp / 100 );


+7 −5
Original line number Original line Diff line number Diff line
@@ -864,11 +864,13 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
    msg = m_SolderPasteMarginRatioCtrl->GetValue();
    msg = m_SolderPasteMarginRatioCtrl->GetValue();
    msg.ToDouble( &dtmp );
    msg.ToDouble( &dtmp );


    // A margin ratio of -50% means no paste on a pad, the ratio must be >= 50 %
    // A -50% margin ratio means no paste on a pad, the ratio must be >= -50%
    if( dtmp < -50 )
    if( dtmp < -50.0 )
        dtmp = -50;
        dtmp = -50.0;
    if( dtmp > +100 )
    // A margin ratio is always <= 0
        dtmp = +100;
    // 0 means use full pad copper area
    if( dtmp > 0.0 )
        dtmp = 0.0;


    aPad->SetLocalSolderPasteMarginRatio( dtmp / 100 );
    aPad->SetLocalSolderPasteMarginRatio( dtmp / 100 );


Loading