Browse Source
Pcbnew: Array tool should not number NPTHs
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/1804787pull/13/head
committed by
Seth Hillbrand
6 changed files with 182 additions and 1 deletions
-
1pcbnew/CMakeLists.txt
-
4pcbnew/array_creator.cpp
-
37pcbnew/pad_naming.cpp
-
50pcbnew/pad_naming.h
-
1qa/pcbnew/CMakeLists.txt
-
90qa/pcbnew/test_pad_naming.cpp
@ -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 |
|||
@ -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() |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue