Pcbnew: Array tool should not number NPTHs
Devolve the logic as to whether a pad should be numbered or not to a pad utility function. Add a very simplistic test for this function (demonstrating how to test BOARD_ITEMs in general). Fixes: lp:1804787 * https://bugs.launchpad.net/kicad/+bug/1804787
This commit is contained in:
parent
81bac449d3
commit
ec91329da0
|
@ -280,6 +280,7 @@ set( PCBNEW_CLASS_SRCS
|
|||
onleftclick.cpp
|
||||
onrightclick.cpp
|
||||
pad_edit_functions.cpp
|
||||
pad_naming.cpp
|
||||
pcb_base_edit_frame.cpp
|
||||
pcb_footprint_edit_utils.cpp
|
||||
pcb_layer_box_selector.cpp
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
*/
|
||||
|
||||
#include "array_creator.h"
|
||||
|
||||
#include <board_commit.h>
|
||||
#include <pad_naming.h>
|
||||
|
||||
#include <dialogs/dialog_create_array.h>
|
||||
|
||||
|
@ -108,7 +110,7 @@ void ARRAY_CREATOR::Invoke()
|
|||
{
|
||||
D_PAD* pad = static_cast<D_PAD*>( new_item );
|
||||
|
||||
if( !pad->IsAperturePad() )
|
||||
if( PAD_NAMING::PadCanHaveName( *pad ) )
|
||||
pad->SetName( array_opts->GetItemNumber( ptN ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 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
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "pad_naming.h"
|
||||
|
||||
bool PAD_NAMING::PadCanHaveName( const D_PAD& aPad )
|
||||
{
|
||||
// Aperture pads don't get a number
|
||||
if( aPad.IsAperturePad() )
|
||||
return false;
|
||||
|
||||
// NPTH pads don't get numbers
|
||||
if( aPad.GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2017 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
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef PAD_NAMING_H
|
||||
#define PAD_NAMING_H
|
||||
|
||||
#include <class_pad.h>
|
||||
|
||||
/**
|
||||
* The PAD_NAMING namespace contains helper functions for common operations
|
||||
* to do with naming of #D_PAD objects.
|
||||
*/
|
||||
namespace PAD_NAMING
|
||||
{
|
||||
|
||||
/**
|
||||
* Check if a pad should be named.
|
||||
*
|
||||
* For example, NPTH or paste apertures normally do not have names, as they
|
||||
* cannot be assigned to a netlist.
|
||||
*
|
||||
* @param aPad the pad to check
|
||||
* @return true if the pad gets a name
|
||||
*/
|
||||
bool PadCanHaveName( const D_PAD& aPad );
|
||||
|
||||
} // namespace PAD_NAMING
|
||||
|
||||
#endif // PAD_NAMING_H
|
|
@ -35,6 +35,7 @@ add_executable( qa_pcbnew
|
|||
../../common/observable.cpp
|
||||
|
||||
test_graphics_import_mgr.cpp
|
||||
test_pad_naming.cpp
|
||||
)
|
||||
|
||||
if( BUILD_GITHUB_PLUGIN )
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 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
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <class_board.h>
|
||||
#include <class_module.h>
|
||||
#include <pad_naming.h>
|
||||
|
||||
struct PAD_FIXTURE
|
||||
{
|
||||
PAD_FIXTURE() : m_board(), m_module( &m_board )
|
||||
{
|
||||
}
|
||||
|
||||
D_PAD MakeNPTH()
|
||||
{
|
||||
D_PAD pad( &m_module );
|
||||
|
||||
pad.SetAttribute( PAD_ATTRIB_HOLE_NOT_PLATED );
|
||||
pad.SetLayerSet( D_PAD::UnplatedHoleMask() );
|
||||
|
||||
return pad;
|
||||
}
|
||||
|
||||
D_PAD MakeAperture()
|
||||
{
|
||||
D_PAD pad( &m_module );
|
||||
|
||||
pad.SetAttribute( PAD_ATTRIB_STANDARD );
|
||||
pad.SetLayerSet( D_PAD::ApertureMask() );
|
||||
|
||||
return pad;
|
||||
}
|
||||
|
||||
D_PAD MakeSmd()
|
||||
{
|
||||
D_PAD pad( &m_module );
|
||||
|
||||
pad.SetAttribute( PAD_ATTRIB_SMD );
|
||||
pad.SetLayerSet( D_PAD::SMDMask() );
|
||||
|
||||
return pad;
|
||||
}
|
||||
|
||||
BOARD m_board;
|
||||
MODULE m_module;
|
||||
};
|
||||
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE( PadNaming, PAD_FIXTURE )
|
||||
|
||||
/**
|
||||
* Check what gets names and what doesn't
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE( CanName )
|
||||
{
|
||||
auto npth = MakeNPTH();
|
||||
BOOST_CHECK_EQUAL( false, PAD_NAMING::PadCanHaveName( npth ) );
|
||||
|
||||
auto aperture = MakeAperture();
|
||||
BOOST_CHECK_EQUAL( false, PAD_NAMING::PadCanHaveName( aperture ) );
|
||||
|
||||
auto smd = MakeSmd();
|
||||
BOOST_CHECK_EQUAL( true, PAD_NAMING::PadCanHaveName( smd ) );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
Loading…
Reference in New Issue