2007-08-23 04:28:46 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2007-08-23 04:28:46 +00:00
|
|
|
*
|
2008-01-22 20:35:46 +00:00
|
|
|
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2022-08-20 09:27:35 +00:00
|
|
|
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2008-01-08 17:44:20 +00:00
|
|
|
*
|
2007-08-23 04:28:46 +00:00
|
|
|
* 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.
|
2008-01-08 17:44:20 +00:00
|
|
|
*
|
2007-08-23 04:28:46 +00:00
|
|
|
* 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.
|
2008-01-08 17:44:20 +00:00
|
|
|
*
|
2007-08-23 04:28:46 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
2008-01-08 17:44:20 +00:00
|
|
|
* 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.,
|
2007-08-23 04:28:46 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <collectors.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <board_item.h> // class BOARD_ITEM
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
|
|
|
#include <pad.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <pcb_marker.h>
|
2021-06-11 16:59:28 +00:00
|
|
|
#include <pcb_dimension.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_shape.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <pcb_group.h>
|
2020-04-24 23:44:09 +00:00
|
|
|
#include <macros.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> GENERAL_COLLECTOR::AllBoardItems = {
|
2020-11-11 23:05:59 +00:00
|
|
|
PCB_MARKER_T, // in m_markers
|
|
|
|
PCB_TEXT_T, // in m_drawings
|
2022-02-08 19:29:54 +00:00
|
|
|
PCB_BITMAP_T, // in m_drawings
|
2022-01-30 10:52:52 +00:00
|
|
|
PCB_TEXTBOX_T, // in m_drawings
|
2020-11-11 23:05:59 +00:00
|
|
|
PCB_SHAPE_T, // in m_drawings
|
|
|
|
PCB_DIM_ALIGNED_T, // in m_drawings
|
|
|
|
PCB_DIM_CENTER_T, // in m_drawings
|
2021-07-13 18:46:33 +00:00
|
|
|
PCB_DIM_RADIAL_T, // in m_drawings
|
2020-11-11 23:05:59 +00:00
|
|
|
PCB_DIM_ORTHOGONAL_T, // in m_drawings
|
|
|
|
PCB_DIM_LEADER_T, // in m_drawings
|
|
|
|
PCB_TARGET_T, // in m_drawings
|
|
|
|
PCB_VIA_T, // in m_tracks
|
|
|
|
PCB_TRACE_T, // in m_tracks
|
|
|
|
PCB_ARC_T, // in m_tracks
|
|
|
|
PCB_PAD_T, // in footprints
|
2020-11-13 12:21:02 +00:00
|
|
|
PCB_FOOTPRINT_T, // in m_footprints
|
2020-11-11 23:05:59 +00:00
|
|
|
PCB_GROUP_T, // in m_groups
|
2022-08-20 09:27:35 +00:00
|
|
|
PCB_ZONE_T // in m_zones
|
2008-01-08 17:44:20 +00:00
|
|
|
};
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> GENERAL_COLLECTOR::BoardLevelItems = {
|
2017-09-28 17:00:24 +00:00
|
|
|
PCB_MARKER_T,
|
2022-02-08 19:29:54 +00:00
|
|
|
PCB_BITMAP_T,
|
2017-09-28 17:00:24 +00:00
|
|
|
PCB_TEXT_T,
|
2022-01-30 10:52:52 +00:00
|
|
|
PCB_TEXTBOX_T,
|
2020-10-04 14:19:33 +00:00
|
|
|
PCB_SHAPE_T,
|
2020-09-12 20:09:40 +00:00
|
|
|
PCB_DIM_ALIGNED_T,
|
2020-09-22 02:32:40 +00:00
|
|
|
PCB_DIM_ORTHOGONAL_T,
|
|
|
|
PCB_DIM_CENTER_T,
|
2021-07-13 18:46:33 +00:00
|
|
|
PCB_DIM_RADIAL_T,
|
2020-09-12 20:09:40 +00:00
|
|
|
PCB_DIM_LEADER_T,
|
2017-09-28 17:00:24 +00:00
|
|
|
PCB_TARGET_T,
|
|
|
|
PCB_VIA_T,
|
2019-05-17 00:13:21 +00:00
|
|
|
PCB_ARC_T,
|
2017-09-28 17:00:24 +00:00
|
|
|
PCB_TRACE_T,
|
2020-11-13 12:21:02 +00:00
|
|
|
PCB_FOOTPRINT_T,
|
2020-08-11 19:37:07 +00:00
|
|
|
PCB_GROUP_T,
|
2022-08-20 09:27:35 +00:00
|
|
|
PCB_ZONE_T
|
2007-12-13 06:24:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> GENERAL_COLLECTOR::Footprints = {
|
2022-08-20 15:40:08 +00:00
|
|
|
PCB_FOOTPRINT_T
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> GENERAL_COLLECTOR::PadsOrTracks = {
|
2022-08-20 15:40:08 +00:00
|
|
|
PCB_PAD_T,
|
|
|
|
PCB_VIA_T,
|
|
|
|
PCB_TRACE_T,
|
|
|
|
PCB_ARC_T
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> GENERAL_COLLECTOR::FootprintItems = {
|
2022-08-20 10:01:43 +00:00
|
|
|
PCB_MARKER_T,
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXT_T,
|
|
|
|
PCB_TEXTBOX_T,
|
|
|
|
PCB_SHAPE_T,
|
|
|
|
PCB_DIM_ALIGNED_T,
|
|
|
|
PCB_DIM_ORTHOGONAL_T,
|
|
|
|
PCB_DIM_CENTER_T,
|
|
|
|
PCB_DIM_RADIAL_T,
|
|
|
|
PCB_DIM_LEADER_T,
|
2019-10-26 15:49:29 +00:00
|
|
|
PCB_PAD_T,
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_ZONE_T,
|
2020-10-03 11:16:29 +00:00
|
|
|
PCB_GROUP_T,
|
2022-08-20 09:27:35 +00:00
|
|
|
PCB_BITMAP_T
|
2022-08-20 15:40:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> GENERAL_COLLECTOR::Tracks = {
|
2022-08-20 15:40:08 +00:00
|
|
|
PCB_TRACE_T,
|
|
|
|
PCB_ARC_T,
|
|
|
|
PCB_VIA_T
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> GENERAL_COLLECTOR::LockableItems = {
|
2022-08-20 15:40:08 +00:00
|
|
|
PCB_FOOTPRINT_T,
|
|
|
|
PCB_GROUP_T, // Can a group be locked?
|
|
|
|
PCB_TRACE_T,
|
|
|
|
PCB_ARC_T,
|
|
|
|
PCB_VIA_T
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> GENERAL_COLLECTOR::Dimensions = {
|
2022-08-20 15:40:08 +00:00
|
|
|
PCB_DIM_ALIGNED_T,
|
|
|
|
PCB_DIM_LEADER_T,
|
|
|
|
PCB_DIM_ORTHOGONAL_T,
|
|
|
|
PCB_DIM_CENTER_T,
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_DIM_RADIAL_T
|
2020-09-11 23:52:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T> GENERAL_COLLECTOR::DraggableItems = {
|
2021-01-27 19:55:42 +00:00
|
|
|
PCB_TRACE_T,
|
|
|
|
PCB_VIA_T,
|
|
|
|
PCB_FOOTPRINT_T,
|
2022-08-20 09:27:35 +00:00
|
|
|
PCB_ARC_T
|
2021-01-27 19:55:42 +00:00
|
|
|
};
|
2020-09-11 23:52:45 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( testItem );
|
|
|
|
FOOTPRINT* footprint = item->GetParentFootprint();
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_GROUP* group = nullptr;
|
|
|
|
PAD* pad = nullptr;
|
|
|
|
bool pad_through = false;
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via = nullptr;
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_MARKER* marker = nullptr;
|
|
|
|
ZONE* zone = nullptr;
|
|
|
|
PCB_DIMENSION_BASE* dimension = nullptr;
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
#if 0 // debugging
|
2008-01-08 17:44:20 +00:00
|
|
|
static int breakhere = 0;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2007-09-05 15:11:48 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = (FOOTPRINT*) item->GetParent();
|
2013-08-05 20:47:34 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( footprint->GetReference() == wxT( "Y2" ) )
|
2013-08-05 20:47:34 +00:00
|
|
|
breakhere++;
|
2007-09-05 15:11:48 +00:00
|
|
|
}
|
2007-09-05 04:48:47 +00:00
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_VIA_T:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
2019-05-17 00:13:21 +00:00
|
|
|
case PCB_ARC_T:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
case PCB_TEXTBOX_T:
|
|
|
|
breakhere++;
|
|
|
|
break;
|
|
|
|
|
2020-10-04 14:19:33 +00:00
|
|
|
case PCB_SHAPE_T:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
case PCB_DIM_ALIGNED_T:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2020-11-13 12:21:02 +00:00
|
|
|
case PCB_FOOTPRINT_T:
|
2007-09-05 04:48:47 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = (FOOTPRINT*) item;
|
2013-08-05 20:47:34 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( footprint->GetReference() == wxT( "C98" ) )
|
2013-08-05 20:47:34 +00:00
|
|
|
breakhere++;
|
2007-09-05 04:48:47 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
case PCB_MARKER_T:
|
|
|
|
breakhere++;
|
|
|
|
break;
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
default:
|
2007-09-05 04:48:47 +00:00
|
|
|
breakhere++;
|
|
|
|
break;
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
#endif
|
2007-08-30 22:20:52 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2010-02-05 10:56:23 +00:00
|
|
|
// there are pad specific visibility controls.
|
2021-06-09 19:32:58 +00:00
|
|
|
// Criteria to select a pad is:
|
2020-11-13 02:57:11 +00:00
|
|
|
// for smd pads: the footprint parent must be visible, and pads on the corresponding
|
|
|
|
// board side must be visible
|
|
|
|
// if pad is a thru hole, then it can be visible when its parent footprint is not.
|
|
|
|
// for through pads: pads on Front or Back board sides must be visible
|
2020-11-12 22:30:02 +00:00
|
|
|
pad = static_cast<PAD*>( item );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( ( pad->GetAttribute() != PAD_ATTRIB::SMD ) &&
|
|
|
|
( pad->GetAttribute() != PAD_ATTRIB::CONN ) ) // a hole is present, so multiple layers
|
2007-09-22 04:33:44 +00:00
|
|
|
{
|
2020-11-13 02:57:11 +00:00
|
|
|
// proceed to the common tests below, but without the parent footprint test,
|
|
|
|
// by leaving footprint==NULL, but having pad != null
|
2010-02-05 10:56:23 +00:00
|
|
|
pad_through = true;
|
2007-09-22 04:33:44 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2012-10-04 17:47:28 +00:00
|
|
|
case PCB_VIA_T: // vias are on many layers, so layer test is specific
|
2021-06-11 21:07:02 +00:00
|
|
|
via = static_cast<PCB_VIA*>( item );
|
2007-09-05 04:48:47 +00:00
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
2019-05-17 00:13:21 +00:00
|
|
|
case PCB_ARC_T:
|
2018-02-22 06:53:16 +00:00
|
|
|
if( m_Guide->IgnoreTracks() )
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
case PCB_ZONE_T:
|
|
|
|
zone = static_cast<ZONE*>( item );
|
2007-12-29 19:15:58 +00:00
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
case PCB_TEXTBOX_T:
|
2020-10-04 14:19:33 +00:00
|
|
|
case PCB_SHAPE_T:
|
2007-09-05 04:48:47 +00:00
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
case PCB_DIM_ALIGNED_T:
|
2020-09-17 00:54:58 +00:00
|
|
|
case PCB_DIM_CENTER_T:
|
2021-07-13 18:46:33 +00:00
|
|
|
case PCB_DIM_RADIAL_T:
|
2020-09-17 00:54:58 +00:00
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
2020-09-12 20:09:40 +00:00
|
|
|
case PCB_DIM_LEADER_T:
|
2021-06-11 16:59:28 +00:00
|
|
|
dimension = static_cast<PCB_DIMENSION_BASE*>( item );
|
2007-09-05 04:48:47 +00:00
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2008-01-08 17:44:20 +00:00
|
|
|
break;
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_TEXT_T:
|
|
|
|
if( item->GetParentFootprint() )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
|
|
|
|
PCB_LAYER_ID layer = item->GetLayer();
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( m_Guide->IgnoreHiddenFPText() )
|
|
|
|
{
|
|
|
|
if( !text->IsVisible() )
|
|
|
|
return INSPECT_RESULT::CONTINUE;
|
|
|
|
}
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( m_Guide->IgnoreFPTextOnBack() && IsBackLayer( layer ) )
|
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( m_Guide->IgnoreFPTextOnFront() && IsFrontLayer( layer ) )
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
/*
|
|
|
|
* The three text types have different criteria: reference and value have their own
|
|
|
|
* ignore flags; user text instead follows their layer visibility. Checking this here
|
|
|
|
* is simpler than later (when layer visibility is checked for other entities)
|
|
|
|
*/
|
|
|
|
switch( text->GetType() )
|
|
|
|
{
|
|
|
|
case PCB_TEXT::TEXT_is_REFERENCE:
|
|
|
|
if( m_Guide->IgnoreFPReferences() )
|
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2011-12-14 22:35:03 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
break;
|
2011-12-14 22:35:03 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_TEXT::TEXT_is_VALUE:
|
|
|
|
if( m_Guide->IgnoreFPValues() )
|
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2014-09-11 16:35:19 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
break;
|
2014-09-11 16:35:19 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
case PCB_TEXT::TEXT_is_DIVERS:
|
|
|
|
if( !m_Guide->IsLayerVisible( layer ) )
|
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2020-02-03 02:23:27 +00:00
|
|
|
break;
|
|
|
|
|
2020-11-13 12:21:02 +00:00
|
|
|
case PCB_FOOTPRINT_T:
|
2020-11-13 15:15:52 +00:00
|
|
|
footprint = static_cast<FOOTPRINT*>( item );
|
2007-09-05 04:48:47 +00:00
|
|
|
break;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
case PCB_GROUP_T:
|
2020-08-12 11:23:30 +00:00
|
|
|
group = static_cast<PCB_GROUP*>( item );
|
2020-08-11 19:37:07 +00:00
|
|
|
break;
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
case PCB_MARKER_T:
|
2020-11-14 18:11:28 +00:00
|
|
|
marker = static_cast<PCB_MARKER*>( item );
|
2012-02-09 20:33:38 +00:00
|
|
|
break;
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
// common tests:
|
2007-09-05 14:52:28 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( footprint )
|
2007-09-05 14:52:28 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
if( m_Guide->IgnoreFootprintsOnBack() && ( footprint->GetLayer() == B_Cu ) )
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( m_Guide->IgnoreFootprintsOnFront() && ( footprint->GetLayer() == F_Cu ) )
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2007-09-05 14:52:28 +00:00
|
|
|
}
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
// Pads are not sensitive to the layer visibility controls.
|
2010-02-05 10:56:23 +00:00
|
|
|
// They all have their own separate visibility controls
|
|
|
|
// skip them if not visible
|
2013-08-05 20:47:34 +00:00
|
|
|
if( pad )
|
2010-02-05 10:56:23 +00:00
|
|
|
{
|
|
|
|
if( m_Guide->IgnorePads() )
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-02-05 10:56:23 +00:00
|
|
|
if( ! pad_through )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( m_Guide->IgnorePadsOnFront() && pad->IsOnLayer(F_Cu ) )
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( m_Guide->IgnorePadsOnBack() && pad->IsOnLayer(B_Cu ) )
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2010-02-05 10:56:23 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
if( marker )
|
|
|
|
{
|
|
|
|
// Markers are not sensitive to the layer
|
2020-10-02 20:25:14 +00:00
|
|
|
if( marker->HitTest( m_refPos ) )
|
2012-02-09 20:33:38 +00:00
|
|
|
Append( item );
|
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
if( group )
|
|
|
|
{
|
|
|
|
// Groups are not sensitive to the layer ... ?
|
2020-10-02 20:25:14 +00:00
|
|
|
if( group->HitTest( m_refPos ) )
|
2020-08-11 19:37:07 +00:00
|
|
|
Append( item );
|
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2020-08-11 19:37:07 +00:00
|
|
|
}
|
|
|
|
|
2018-01-18 02:12:51 +00:00
|
|
|
if( via )
|
|
|
|
{
|
|
|
|
auto type = via->GetViaType();
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
if( ( m_Guide->IgnoreThroughVias() && type == VIATYPE::THROUGH )
|
|
|
|
|| ( m_Guide->IgnoreBlindBuriedVias() && type == VIATYPE::BLIND_BURIED )
|
|
|
|
|| ( m_Guide->IgnoreMicroVias() && type == VIATYPE::MICROVIA ) )
|
2018-01-18 02:12:51 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2018-01-18 02:12:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-18 10:12:11 +00:00
|
|
|
if( ( item->IsOnLayer( m_Guide->GetPreferredLayer() ) )
|
|
|
|
&& ( !item->IsLocked() || !m_Guide->IgnoreLockedItems() ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2020-10-21 03:48:06 +00:00
|
|
|
// footprints and their subcomponents: reference, value and pads are not sensitive
|
2018-11-17 00:34:12 +00:00
|
|
|
// to the layer visibility controls. They all have their own separate visibility
|
|
|
|
// controls for vias, GetLayer() has no meaning, but IsOnLayer() works fine. User
|
2020-11-13 02:57:11 +00:00
|
|
|
// text in a footprint *is* sensitive to layer visibility but that was already handled.
|
2014-09-11 16:35:19 +00:00
|
|
|
|
2022-02-18 10:12:11 +00:00
|
|
|
int accuracy = KiROUND( 5 * m_Guide->OnePixelInIU() );
|
|
|
|
|
|
|
|
if( zone )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2022-02-18 10:12:11 +00:00
|
|
|
if( zone->HitTestForCorner( m_refPos, accuracy * 2 )
|
|
|
|
|| zone->HitTestForEdge( m_refPos, accuracy ) )
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2022-02-18 10:12:11 +00:00
|
|
|
Append( item );
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2022-02-18 10:12:11 +00:00
|
|
|
}
|
|
|
|
else if( !m_Guide->IgnoreZoneFills() )
|
|
|
|
{
|
|
|
|
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2022-02-18 10:12:11 +00:00
|
|
|
if( m_Guide->IsLayerVisible( layer )
|
|
|
|
&& zone->HitTestFilledArea( layer, m_refPos ) )
|
2020-02-03 02:23:27 +00:00
|
|
|
{
|
2022-02-18 10:12:11 +00:00
|
|
|
Append( item );
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2018-11-02 23:50:33 +00:00
|
|
|
}
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2022-03-01 21:17:15 +00:00
|
|
|
else if( item == footprint )
|
2022-02-18 10:12:11 +00:00
|
|
|
{
|
|
|
|
if( footprint->HitTest( m_refPos, accuracy )
|
|
|
|
&& footprint->HitTestAccurate( m_refPos, accuracy ) )
|
|
|
|
{
|
|
|
|
Append( item );
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2022-02-18 10:12:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( pad || via )
|
|
|
|
{
|
|
|
|
if( item->HitTest( m_refPos, accuracy ) )
|
|
|
|
{
|
|
|
|
Append( item );
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2022-02-18 10:12:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PCB_LAYER_ID layer = item->GetLayer();
|
|
|
|
|
|
|
|
if( m_Guide->IsLayerVisible( layer ) )
|
|
|
|
{
|
|
|
|
if( dimension )
|
|
|
|
{
|
|
|
|
// Dimensions feel particularly hard to select, probably due to their
|
|
|
|
// noisy shape making it feel like they should have a larger boundary.
|
|
|
|
accuracy = KiROUND( accuracy * 1.5 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->HitTest( m_refPos, accuracy ) )
|
|
|
|
{
|
|
|
|
Append( item );
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2022-02-18 10:12:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
if( m_Guide->IncludeSecondary() && ( !item->IsLocked() || !m_Guide->IgnoreLockedItems() ) )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2022-02-18 10:12:11 +00:00
|
|
|
// for now, "secondary" means "tolerate any visible layer". It has no effect on other
|
|
|
|
// criteria, since there is a separate "ignore" control for those in the COLLECTORS_GUIDE
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2020-10-21 03:48:06 +00:00
|
|
|
// footprints and their subcomponents: reference, value and pads are not sensitive
|
2018-11-17 00:34:12 +00:00
|
|
|
// to the layer visibility controls. They all have their own separate visibility
|
|
|
|
// controls for vias, GetLayer() has no meaning, but IsOnLayer() works fine. User
|
2020-11-13 02:57:11 +00:00
|
|
|
// text in a footprint *is* sensitive to layer visibility but that was already handled.
|
2014-09-11 16:35:19 +00:00
|
|
|
|
2022-02-18 10:12:11 +00:00
|
|
|
int accuracy = KiROUND( 5 * m_Guide->OnePixelInIU() );
|
|
|
|
|
|
|
|
if( zone )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2022-02-18 10:12:11 +00:00
|
|
|
if( zone->HitTestForCorner( m_refPos, accuracy * 2 )
|
|
|
|
|| zone->HitTestForEdge( m_refPos, accuracy ) )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2022-02-18 10:12:11 +00:00
|
|
|
Append2nd( item );
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2022-02-18 10:12:11 +00:00
|
|
|
}
|
|
|
|
else if( !m_Guide->IgnoreZoneFills() )
|
|
|
|
{
|
|
|
|
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2022-02-18 10:12:11 +00:00
|
|
|
if( m_Guide->IsLayerVisible( layer )
|
|
|
|
&& zone->HitTestFilledArea( layer, m_refPos ) )
|
2018-11-17 00:34:12 +00:00
|
|
|
{
|
2022-02-18 10:12:11 +00:00
|
|
|
Append2nd( item );
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2018-11-04 19:16:56 +00:00
|
|
|
}
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2022-02-18 10:12:11 +00:00
|
|
|
else if( item->Type() == PCB_FOOTPRINT_T )
|
|
|
|
{
|
|
|
|
if( footprint->HitTest( m_refPos, accuracy )
|
|
|
|
&& footprint->HitTestAccurate( m_refPos, accuracy ) )
|
|
|
|
{
|
|
|
|
Append2nd( item );
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2022-02-18 10:12:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( pad || via )
|
|
|
|
{
|
|
|
|
if( item->HitTest( m_refPos, accuracy ) )
|
|
|
|
{
|
|
|
|
Append2nd( item );
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2022-02-18 10:12:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PCB_LAYER_ID layer = item->GetLayer();
|
|
|
|
|
|
|
|
if( m_Guide->IsLayerVisible( layer ) )
|
|
|
|
{
|
|
|
|
if( dimension )
|
|
|
|
{
|
|
|
|
// Dimensions feel particularly hard to select, probably due to their
|
|
|
|
// noisy shape making it feel like they should have a larger boundary.
|
|
|
|
accuracy = KiROUND( accuracy * 1.5 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->HitTest( m_refPos, accuracy ) )
|
|
|
|
{
|
|
|
|
Append2nd( item );
|
2022-08-20 09:27:35 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2022-02-18 10:12:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE; // always when collecting
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const std::vector<KICAD_T>& aScanTypes,
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I& aRefPos, const COLLECTORS_GUIDE& aGuide )
|
2007-08-30 03:53:26 +00:00
|
|
|
{
|
|
|
|
Empty(); // empty the collection, primary criteria list
|
|
|
|
Empty2nd(); // empty the collection, secondary criteria list
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
// remember guide, pass it to Inspect()
|
2007-09-11 04:16:31 +00:00
|
|
|
SetGuide( &aGuide );
|
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
SetScanTypes( aScanTypes );
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
// remember where the snapshot was taken from and pass refPos to
|
|
|
|
// the Inspect() function.
|
2007-09-06 04:34:03 +00:00
|
|
|
SetRefPos( aRefPos );
|
2007-08-30 03:53:26 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
aItem->Visit( m_inspector, nullptr, m_scanTypes );
|
2008-01-08 17:44:20 +00:00
|
|
|
|
|
|
|
// append 2nd list onto end of the first list
|
|
|
|
for( unsigned i = 0; i<m_List2nd.size(); ++i )
|
2007-08-30 22:20:52 +00:00
|
|
|
Append( m_List2nd[i] );
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2007-08-30 03:53:26 +00:00
|
|
|
Empty2nd();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
INSPECT_RESULT PCB_TYPE_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
2008-01-22 20:35:46 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
// The Visit() function only visits the testItem if its type was in the the scanList,
|
|
|
|
// so therefore we can collect anything given to us here.
|
2008-01-22 20:35:46 +00:00
|
|
|
Append( testItem );
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE; // always when collecting
|
2008-01-22 20:35:46 +00:00
|
|
|
}
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
void PCB_TYPE_COLLECTOR::Collect( BOARD_ITEM* aBoard, const std::vector<KICAD_T>& aTypes )
|
2008-01-22 20:35:46 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
Empty();
|
|
|
|
aBoard->Visit( m_inspector, nullptr, aTypes );
|
2008-01-22 20:35:46 +00:00
|
|
|
}
|
2017-09-28 17:00:24 +00:00
|
|
|
|
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
INSPECT_RESULT PCB_LAYER_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
2017-09-28 17:00:24 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) testItem;
|
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
if( item->IsOnLayer( m_layer_id ) )
|
2017-09-28 17:00:24 +00:00
|
|
|
Append( testItem );
|
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2017-09-28 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
void PCB_LAYER_COLLECTOR::Collect( BOARD_ITEM* aBoard, const std::vector<KICAD_T>& aTypes )
|
2017-09-28 17:00:24 +00:00
|
|
|
{
|
|
|
|
Empty();
|
2022-08-20 09:27:35 +00:00
|
|
|
aBoard->Visit( m_inspector, nullptr, aTypes );
|
2017-09-28 17:00:24 +00:00
|
|
|
}
|