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>
|
2023-03-30 11:49:23 +00:00
|
|
|
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2008-02-19 16:54:57 +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-02-19 16:54:57 +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-02-19 16:54:57 +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-02-19 16:54:57 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COLLECTORS_H
|
|
|
|
#define COLLECTORS_H
|
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
/*
|
|
|
|
* This module contains a number of COLLECTOR implementations which are used
|
2017-09-28 17:00:24 +00:00
|
|
|
* to augment the functionality of class PCB_EDIT_FRAME.
|
|
|
|
*/
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2018-02-04 09:49:37 +00:00
|
|
|
#include <collector.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h> // LAYER_COUNT, layer defs
|
2018-11-17 00:34:12 +00:00
|
|
|
#include <view/view.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <board_item.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2007-08-30 03:53:26 +00:00
|
|
|
/**
|
2022-08-20 09:27:35 +00:00
|
|
|
* An abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR telling it what
|
|
|
|
* should be collected (aside from HitTest()ing and KICAD_T scanTypes, which are provided to the
|
|
|
|
* GENERAL_COLLECTOR through attributes or arguments separately).
|
2007-08-30 22:20:52 +00:00
|
|
|
* <p>
|
2022-08-20 09:27:35 +00:00
|
|
|
* A justification for this class is to keep the structural storage details of the program's
|
|
|
|
* "configuration options" out of GENERAL_COLLECTOR::Inspect(). This class carries all the
|
|
|
|
* necessary details with it into the Inspect() call. The constructors or other functions of this
|
|
|
|
* class's derivatives are then the only place where knowledge of the specific structure of the
|
|
|
|
* global preference storage is needed. Thus, GENERAL_COLLECTOR::Inspect() can be kept as simple
|
|
|
|
* as possible, and insulated from changes in global preference storage.
|
2017-09-28 17:00:24 +00:00
|
|
|
* </p>
|
2007-08-30 03:53:26 +00:00
|
|
|
* This class introduces the notion of layer locking.
|
|
|
|
*/
|
2008-02-19 16:54:57 +00:00
|
|
|
class COLLECTORS_GUIDE
|
2007-08-30 03:53:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual ~COLLECTORS_GUIDE() {}
|
2007-08-30 03:53:26 +00:00
|
|
|
|
2022-08-20 15:40:08 +00:00
|
|
|
/**
|
|
|
|
* @return true if the given layer is visible, else false.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IsLayerVisible( PCB_LAYER_ID layer ) const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the preferred layer for HitTest()ing.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual PCB_LAYER_ID GetPreferredLayer() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore locked items, else false.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreLockedItems() const = 0;
|
2007-08-30 22:20:52 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Determine if the secondary criteria or 2nd choice items should be included.
|
|
|
|
*
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should include, else false.
|
2007-08-30 22:20:52 +00:00
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IncludeSecondary() const = 0;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if footprint texts marked as "no show" should be ignored.
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreHiddenFPText() const = 0;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2022-08-20 15:40:08 +00:00
|
|
|
/**
|
|
|
|
* @return true if should ignore footprint text on back layers
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreFPTextOnBack() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore footprint text on front layers.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreFPTextOnFront() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore FOOTPRINTs on Back Side.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreFootprintsOnBack() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore FOOTPRINTs on Front Side.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreFootprintsOnFront() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore Pads on Back Side.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnorePadsOnBack() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore PADSs on Front Side.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnorePadsOnFront() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore through-hole PADSs.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreThroughHolePads() const = 0;
|
2018-11-11 20:06:23 +00:00
|
|
|
|
2022-08-20 15:40:08 +00:00
|
|
|
/**
|
|
|
|
* @return true if should ignore PADSs on Front side and Back side.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnorePads() const
|
2010-02-05 10:56:23 +00:00
|
|
|
{
|
2018-11-11 20:06:23 +00:00
|
|
|
return IgnorePadsOnFront() && IgnorePadsOnBack() && IgnoreThroughHolePads();
|
2010-02-05 10:56:23 +00:00
|
|
|
}
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2022-08-20 15:40:08 +00:00
|
|
|
/**
|
|
|
|
* @return true if should ignore footprint values.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreFPValues() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore footprint references.
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreFPReferences() const = 0;
|
2011-12-14 22:35:03 +00:00
|
|
|
|
2022-08-20 15:40:08 +00:00
|
|
|
/**
|
|
|
|
* @return true if should ignore through-hole vias
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreThroughVias() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore blind/buried vias
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreBlindBuriedVias() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore micro vias
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreMicroVias() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore tracks
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreTracks() const = 0;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore the interiors of zones
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IgnoreZoneFills() const = 0;
|
2018-11-02 23:50:33 +00:00
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual double OnePixelInIU() const = 0;
|
2007-08-30 03:53:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Collect #BOARD_ITEM objects.
|
|
|
|
*
|
|
|
|
* All this object really does is override the [] operator and return a #BOARD_ITEM instead
|
|
|
|
* of a #EDA_ITEM. Derive all board collector objects from this class instead of the base
|
|
|
|
* #COLLECTOR object.
|
|
|
|
*
|
|
|
|
* @see class COLLECTOR
|
|
|
|
*/
|
|
|
|
class PCB_COLLECTOR : public COLLECTOR
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Overload the COLLECTOR::operator[](int) to return a #BOARD_ITEM instead of an #EDA_ITEM.
|
|
|
|
*
|
|
|
|
* @param ndx The index into the list.
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return a board item or NULL.
|
2017-09-28 17:00:24 +00:00
|
|
|
*/
|
2019-04-21 23:45:34 +00:00
|
|
|
BOARD_ITEM* operator[]( int ndx ) const override
|
2017-09-28 17:00:24 +00:00
|
|
|
{
|
|
|
|
if( (unsigned)ndx < (unsigned)GetCount() )
|
2020-10-02 20:25:14 +00:00
|
|
|
return (BOARD_ITEM*) m_list[ ndx ];
|
2017-09-28 17:00:24 +00:00
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
return nullptr;
|
2017-09-28 17:00:24 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used when the right click button is pressed, or when the select tool is in effect.
|
|
|
|
* This class can be used by window classes such as PCB_EDIT_FRAME.
|
2007-08-23 04:28:46 +00:00
|
|
|
*
|
2022-08-20 09:27:35 +00:00
|
|
|
* Philosophy: this class knows nothing of the context in which a BOARD is used and that means
|
|
|
|
* it knows nothing about which layers are visible or current, but can handle those concerns by
|
|
|
|
* the SetPreferredLayer() function and the SetLayerSet() function.
|
2007-08-23 04:28:46 +00:00
|
|
|
*/
|
2017-09-28 17:00:24 +00:00
|
|
|
class GENERAL_COLLECTOR : public PCB_COLLECTOR
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2008-02-19 16:54:57 +00:00
|
|
|
protected:
|
2007-08-23 04:28:46 +00:00
|
|
|
/**
|
2008-02-19 16:54:57 +00:00
|
|
|
* A place to hold collected objects which don't match precisely the search
|
|
|
|
* criteria, but would be acceptable if nothing else is found.
|
|
|
|
* "2nd" choice, which will be appended to the end of COLLECTOR's prime
|
2007-08-23 04:28:46 +00:00
|
|
|
* "list" at the end of the search.
|
|
|
|
*/
|
2007-08-30 22:20:52 +00:00
|
|
|
std::vector<BOARD_ITEM*> m_List2nd;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Determine which items are to be collected by Inspect().
|
2007-08-23 04:28:46 +00:00
|
|
|
*/
|
2007-09-11 04:15:39 +00:00
|
|
|
const COLLECTORS_GUIDE* m_Guide;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
public:
|
|
|
|
|
2007-09-11 04:15:39 +00:00
|
|
|
/**
|
2019-05-27 16:55:13 +00:00
|
|
|
* A scan list for all editable board items
|
2007-09-11 04:15:39 +00:00
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
static const std::vector<KICAD_T> AllBoardItems;
|
2011-05-12 11:06:32 +00:00
|
|
|
|
2022-08-20 15:40:08 +00:00
|
|
|
/**
|
|
|
|
* A scan list for zones outlines only
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
static const std::vector<KICAD_T> Zones;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
2008-02-19 16:54:57 +00:00
|
|
|
/**
|
2007-09-11 04:15:39 +00:00
|
|
|
* A scan list for all primary board items, omitting items which are subordinate to
|
2023-03-30 11:49:23 +00:00
|
|
|
* a FOOTPRINT, such as PAD and PCB_TEXT.
|
2007-10-10 14:08:26 +00:00
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
static const std::vector<KICAD_T> BoardLevelItems;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2022-08-20 15:40:08 +00:00
|
|
|
/**
|
|
|
|
* A scan list for only FOOTPRINTs
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
static const std::vector<KICAD_T> Footprints;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A scan list for PADs, TRACKs, or VIAs
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
static const std::vector<KICAD_T> PadsOrTracks;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
2007-10-27 18:05:50 +00:00
|
|
|
/**
|
2020-11-14 19:16:42 +00:00
|
|
|
* A scan list for primary footprint items.
|
2014-07-09 11:50:27 +00:00
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
static const std::vector<KICAD_T> FootprintItems;
|
2020-09-11 23:52:45 +00:00
|
|
|
|
2022-08-20 15:40:08 +00:00
|
|
|
/**
|
|
|
|
* A scan list for only TRACKs and ARCs
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
static const std::vector<KICAD_T> Tracks;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A scan list for dimensions
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
static const std::vector<KICAD_T> Dimensions;
|
2022-08-20 15:40:08 +00:00
|
|
|
|
2021-01-27 19:55:42 +00:00
|
|
|
/**
|
|
|
|
* A scan list for items that can be dragged
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
static const std::vector<KICAD_T> DraggableItems;
|
2021-01-27 19:55:42 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
GENERAL_COLLECTOR() :
|
|
|
|
m_Guide( nullptr )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
SetScanTypes( AllBoardItems );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Empty2nd()
|
|
|
|
{
|
2007-08-30 22:20:52 +00:00
|
|
|
m_List2nd.clear();
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
void Append2nd( BOARD_ITEM* item )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2007-08-30 22:20:52 +00:00
|
|
|
m_List2nd.push_back( item );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Record which COLLECTORS_GUIDE to use.
|
|
|
|
*
|
2007-08-30 22:20:52 +00:00
|
|
|
* @param aGuide Which guide to use in the collection.
|
|
|
|
*/
|
|
|
|
void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; }
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2020-11-27 18:04:30 +00:00
|
|
|
const COLLECTORS_GUIDE* GetGuide() const { return m_Guide; }
|
2018-11-17 00:34:12 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* The examining function within the INSPECTOR which is passed to the Iterate function.
|
2021-06-04 13:04:30 +00:00
|
|
|
* Search and collect all the objects which match the test data.
|
2007-08-23 04:28:46 +00:00
|
|
|
*
|
2010-12-08 20:12:46 +00:00
|
|
|
* @param testItem An EDA_ITEM to examine.
|
2007-08-23 04:28:46 +00:00
|
|
|
* @param testData is not used in this class.
|
2022-08-20 09:27:35 +00:00
|
|
|
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE
|
2008-02-19 16:54:57 +00:00
|
|
|
*/
|
2022-07-30 00:00:39 +00:00
|
|
|
INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
|
|
|
|
*
|
2020-11-13 21:07:01 +00:00
|
|
|
* @param aItem A BOARD_ITEM to scan, may be a BOARD or FOOTPRINT, or whatever.
|
2022-08-20 09:27:35 +00:00
|
|
|
* @param aScanList A list of KICAD_Ts that specs what is to be collected and the priority
|
|
|
|
* order of the resultant collection in "m_list".
|
2007-08-30 22:20:52 +00:00
|
|
|
* @param aRefPos A wxPoint to use in hit-testing.
|
|
|
|
* @param aGuide The COLLECTORS_GUIDE to use in collecting items.
|
2007-08-30 03:53:26 +00:00
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
void Collect( BOARD_ITEM* aItem, const std::vector<KICAD_T>& aScanList,
|
2022-08-20 09:27:35 +00:00
|
|
|
const VECTOR2I& aRefPos, const COLLECTORS_GUIDE& aGuide );
|
2007-08-23 04:28:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* A general implementation of a COLLECTORS_GUIDE. One of its constructors is
|
2007-08-30 22:20:52 +00:00
|
|
|
* entitled to grab information from the program's global preferences.
|
2008-02-19 16:54:57 +00:00
|
|
|
*/
|
2007-08-30 22:20:52 +00:00
|
|
|
class GENERAL_COLLECTORS_GUIDE : public COLLECTORS_GUIDE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Grab stuff from global preferences and uses reasonable defaults.
|
|
|
|
*
|
2007-08-30 22:20:52 +00:00
|
|
|
* Add more constructors as needed.
|
2017-09-28 17:00:24 +00:00
|
|
|
*
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aVisibleLayerMask is the current visible layers (bit mask).
|
|
|
|
* @param aPreferredLayer is the layer to search first.
|
2007-08-30 22:20:52 +00:00
|
|
|
*/
|
2018-11-17 00:34:12 +00:00
|
|
|
GENERAL_COLLECTORS_GUIDE( LSET aVisibleLayerMask, PCB_LAYER_ID aPreferredLayer,
|
|
|
|
KIGFX::VIEW* aView )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2018-11-17 00:34:12 +00:00
|
|
|
VECTOR2I one( 1, 1 );
|
|
|
|
|
2020-11-12 23:06:47 +00:00
|
|
|
m_preferredLayer = aPreferredLayer;
|
2021-01-13 21:02:21 +00:00
|
|
|
m_visibleLayers = aVisibleLayerMask;
|
2020-11-12 23:06:47 +00:00
|
|
|
m_ignoreLockedItems = false;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
#if defined(USE_MATCH_LAYER)
|
2021-04-28 22:53:31 +00:00
|
|
|
m_includeSecondary = false;
|
2008-02-19 16:54:57 +00:00
|
|
|
#else
|
2020-11-12 23:06:47 +00:00
|
|
|
m_includeSecondary = true;
|
2008-02-19 16:54:57 +00:00
|
|
|
#endif
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2021-01-13 21:02:21 +00:00
|
|
|
m_ignoreHiddenFPText = true; // g_ModuleTextNOVColor;
|
2020-11-12 23:06:47 +00:00
|
|
|
m_ignoreFPTextOnBack = true;
|
|
|
|
m_ignoreFPTextOnFront = false;
|
2021-01-13 21:02:21 +00:00
|
|
|
m_ignoreFootprintsOnBack = true; // !Show_footprints_Cmp;
|
|
|
|
m_ignoreFootprintsOnFront = false;
|
2010-12-29 17:47:32 +00:00
|
|
|
|
2020-11-12 23:06:47 +00:00
|
|
|
m_ignorePadsOnFront = false;
|
|
|
|
m_ignorePadsOnBack = false;
|
|
|
|
m_ignoreThroughHolePads = false;
|
2011-12-14 22:35:03 +00:00
|
|
|
|
2021-01-13 21:02:21 +00:00
|
|
|
m_ignoreFPValues = false;
|
|
|
|
m_ignoreFPReferences = false;
|
2018-01-18 02:12:51 +00:00
|
|
|
|
2020-11-12 23:06:47 +00:00
|
|
|
m_ignoreThroughVias = false;
|
|
|
|
m_ignoreBlindBuriedVias = false;
|
|
|
|
m_ignoreMicroVias = false;
|
|
|
|
m_ignoreTracks = false;
|
|
|
|
m_ignoreZoneFills = true;
|
2018-11-17 00:34:12 +00:00
|
|
|
|
2020-11-12 23:06:47 +00:00
|
|
|
m_onePixelInIU = abs( aView->ToWorld( one, false ).x );
|
2007-09-05 04:48:47 +00:00
|
|
|
}
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if the given layer is visible, else false.
|
2007-08-30 22:20:52 +00:00
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const override
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
2020-11-12 23:06:47 +00:00
|
|
|
return m_visibleLayers[aLayerId];
|
2013-03-30 17:24:04 +00:00
|
|
|
}
|
2017-03-13 03:19:33 +00:00
|
|
|
void SetLayerVisible( PCB_LAYER_ID aLayerId, bool isVisible )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2020-11-12 23:06:47 +00:00
|
|
|
m_visibleLayers.set( aLayerId, isVisible );
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
2020-11-12 23:06:47 +00:00
|
|
|
void SetLayerVisibleBits( LSET aLayerBits ) { m_visibleLayers = aLayerBits; }
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
/**
|
|
|
|
* @return int - the preferred layer for HitTest()ing.
|
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
PCB_LAYER_ID GetPreferredLayer() const override { return m_preferredLayer; }
|
|
|
|
void SetPreferredLayer( PCB_LAYER_ID aLayer ) { m_preferredLayer = aLayer; }
|
2007-08-30 22:20:52 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should ignore locked items, else false.
|
2007-08-30 22:20:52 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreLockedItems() const override { return m_ignoreLockedItems; }
|
|
|
|
void SetIgnoreLockedItems( bool ignore ) { m_ignoreLockedItems = ignore; }
|
2007-08-30 22:20:52 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Determine if the secondary criteria, or 2nd choice items should be included.
|
|
|
|
*
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should include, else false.
|
2007-08-30 22:20:52 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IncludeSecondary() const override { return m_includeSecondary; }
|
|
|
|
void SetIncludeSecondary( bool include ) { m_includeSecondary = include; }
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if MTexts marked as "no show" should be ignored.
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreHiddenFPText() const override { return m_ignoreHiddenFPText; }
|
|
|
|
void SetIgnoreMTextsMarkedNoShow( bool ignore ) { m_ignoreHiddenFPText = ignore; }
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should ignore MTexts on back layers
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreFPTextOnBack() const override { return m_ignoreFPTextOnBack; }
|
|
|
|
void SetIgnoreMTextsOnBack( bool ignore ) { m_ignoreFPTextOnBack = ignore; }
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should ignore MTexts on front layers
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreFPTextOnFront() const override { return m_ignoreFPTextOnFront; }
|
|
|
|
void SetIgnoreMTextsOnFront( bool ignore ) { m_ignoreFPTextOnFront = ignore; }
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should ignore MODULEs on the back side
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreFootprintsOnBack() const override { return m_ignoreFootprintsOnBack; }
|
|
|
|
void SetIgnoreModulesOnBack( bool ignore ) { m_ignoreFootprintsOnBack = ignore; }
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should ignore MODULEs on component layer.
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreFootprintsOnFront() const override { return m_ignoreFootprintsOnFront; }
|
|
|
|
void SetIgnoreModulesOnFront( bool ignore ) { m_ignoreFootprintsOnFront = ignore; }
|
2010-02-05 10:56:23 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should ignore Pads on Back Side.
|
2010-02-05 10:56:23 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnorePadsOnBack() const override { return m_ignorePadsOnBack; }
|
|
|
|
void SetIgnorePadsOnBack(bool ignore) { m_ignorePadsOnBack = ignore; }
|
2010-02-05 10:56:23 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should ignore PADSs on Front Side.
|
2010-02-05 10:56:23 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnorePadsOnFront() const override { return m_ignorePadsOnFront; }
|
|
|
|
void SetIgnorePadsOnFront(bool ignore) { m_ignorePadsOnFront = ignore; }
|
2011-12-14 22:35:03 +00:00
|
|
|
|
2018-11-11 20:06:23 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should ignore through-hole PADSs.
|
2018-11-11 20:06:23 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreThroughHolePads() const override { return m_ignoreThroughHolePads; }
|
|
|
|
void SetIgnoreThroughHolePads(bool ignore) { m_ignoreThroughHolePads = ignore; }
|
2018-11-11 20:06:23 +00:00
|
|
|
|
2011-12-14 22:35:03 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should ignore footprints values.
|
2011-12-14 22:35:03 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreFPValues() const override { return m_ignoreFPValues; }
|
|
|
|
void SetIgnoreModulesVals(bool ignore) { m_ignoreFPValues = ignore; }
|
2011-12-14 22:35:03 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return true if should ignore footprints references.
|
2011-12-14 22:35:03 +00:00
|
|
|
*/
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreFPReferences() const override { return m_ignoreFPReferences; }
|
|
|
|
void SetIgnoreModulesRefs(bool ignore) { m_ignoreFPReferences = ignore; }
|
2018-01-18 02:12:51 +00:00
|
|
|
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreThroughVias() const override { return m_ignoreThroughVias; }
|
|
|
|
void SetIgnoreThroughVias( bool ignore ) { m_ignoreThroughVias = ignore; }
|
2018-01-18 02:12:51 +00:00
|
|
|
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreBlindBuriedVias() const override { return m_ignoreBlindBuriedVias; }
|
|
|
|
void SetIgnoreBlindBuriedVias( bool ignore ) { m_ignoreBlindBuriedVias = ignore; }
|
2018-01-18 02:12:51 +00:00
|
|
|
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreMicroVias() const override { return m_ignoreMicroVias; }
|
|
|
|
void SetIgnoreMicroVias( bool ignore ) { m_ignoreMicroVias = ignore; }
|
2018-02-22 06:53:16 +00:00
|
|
|
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreTracks() const override { return m_ignoreTracks; }
|
|
|
|
void SetIgnoreTracks( bool ignore ) { m_ignoreTracks = ignore; }
|
2018-11-02 23:50:33 +00:00
|
|
|
|
2020-11-12 23:06:47 +00:00
|
|
|
bool IgnoreZoneFills() const override { return m_ignoreZoneFills; }
|
|
|
|
void SetIgnoreZoneFills( bool ignore ) { m_ignoreZoneFills = ignore; }
|
2018-11-17 00:34:12 +00:00
|
|
|
|
2020-11-12 23:06:47 +00:00
|
|
|
double OnePixelInIU() const override { return m_onePixelInIU; }
|
2021-01-13 21:02:21 +00:00
|
|
|
void SetOnePixelInIU( double aValue ) { m_onePixelInIU = aValue; }
|
2021-06-04 13:04:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// the storage architecture here is not important, since this is only
|
|
|
|
// a carrier object and its functions are what is used, and data only indirectly.
|
|
|
|
|
|
|
|
PCB_LAYER_ID m_preferredLayer;
|
|
|
|
|
|
|
|
LSET m_visibleLayers; ///< bit-mapped layer visible bits
|
|
|
|
|
|
|
|
bool m_ignoreLockedItems;
|
|
|
|
bool m_includeSecondary;
|
|
|
|
|
|
|
|
bool m_ignoreHiddenFPText;
|
|
|
|
bool m_ignoreFPTextOnBack;
|
|
|
|
bool m_ignoreFPTextOnFront;
|
|
|
|
bool m_ignoreFootprintsOnBack;
|
|
|
|
bool m_ignoreFootprintsOnFront;
|
|
|
|
bool m_ignorePadsOnFront;
|
|
|
|
bool m_ignorePadsOnBack;
|
|
|
|
bool m_ignoreThroughHolePads;
|
|
|
|
bool m_ignoreFPValues;
|
|
|
|
bool m_ignoreFPReferences;
|
|
|
|
bool m_ignoreThroughVias;
|
|
|
|
bool m_ignoreBlindBuriedVias;
|
|
|
|
bool m_ignoreMicroVias;
|
|
|
|
bool m_ignoreTracks;
|
|
|
|
bool m_ignoreZoneFills;
|
|
|
|
|
|
|
|
double m_onePixelInIU;
|
2007-08-30 22:20:52 +00:00
|
|
|
};
|
|
|
|
|
2008-01-22 20:35:46 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Collect all #BOARD_ITEM objects of a given set of #KICAD_T type(s).
|
|
|
|
*
|
2008-01-22 20:35:46 +00:00
|
|
|
* @see class COLLECTOR
|
|
|
|
*/
|
2017-09-28 17:00:24 +00:00
|
|
|
class PCB_TYPE_COLLECTOR : public PCB_COLLECTOR
|
2008-01-22 20:35:46 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* The examining function within the INSPECTOR which is passed to the Iterate function.
|
|
|
|
*
|
|
|
|
* @param testItem An EDA_ITEM to examine.
|
|
|
|
* @param testData is not used in this class.
|
2022-08-20 09:27:35 +00:00
|
|
|
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE
|
2008-01-22 20:35:46 +00:00
|
|
|
*/
|
2022-07-30 00:00:39 +00:00
|
|
|
INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
2017-09-28 17:00:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Collect #BOARD_ITEM objects using this class's Inspector method, which does the collection.
|
|
|
|
*
|
|
|
|
* @param aBoard The BOARD_ITEM to scan.
|
2022-08-20 09:27:35 +00:00
|
|
|
* @param aTypes The KICAD_Ts to gather up.
|
2017-09-28 17:00:24 +00:00
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
void Collect( BOARD_ITEM* aBoard, const std::vector<KICAD_T>& aTypes );
|
2017-09-28 17:00:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Collect all #BOARD_ITEM objects on a given layer.
|
|
|
|
*
|
|
|
|
* This only uses the primary object layer for comparison.
|
|
|
|
*/
|
|
|
|
class PCB_LAYER_COLLECTOR : public PCB_COLLECTOR
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PCB_LAYER_COLLECTOR( PCB_LAYER_ID aLayerId = UNDEFINED_LAYER ) :
|
|
|
|
m_layer_id( aLayerId )
|
2022-08-20 09:27:35 +00:00
|
|
|
{ }
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
void SetLayerId( PCB_LAYER_ID aLayerId ) { m_layer_id = aLayerId; }
|
|
|
|
|
2008-01-22 20:35:46 +00:00
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* The examining function within the INSPECTOR which is passed to the iterate function.
|
2008-01-22 20:35:46 +00:00
|
|
|
*
|
2010-12-08 20:12:46 +00:00
|
|
|
* @param testItem An EDA_ITEM to examine.
|
2008-01-22 20:35:46 +00:00
|
|
|
* @param testData is not used in this class.
|
2022-08-20 09:27:35 +00:00
|
|
|
* @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE
|
2008-02-19 16:54:57 +00:00
|
|
|
*/
|
2022-07-30 00:00:39 +00:00
|
|
|
INSPECT_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
2008-01-22 20:35:46 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Test a BOARD_ITEM using this class's Inspector method, which does the collection.
|
2017-09-28 17:00:24 +00:00
|
|
|
*
|
2008-01-22 20:35:46 +00:00
|
|
|
* @param aBoard The BOARD_ITEM to scan.
|
2022-08-20 09:27:35 +00:00
|
|
|
* @param aTypes The KICAD_Ts to gather up.
|
2008-01-22 20:35:46 +00:00
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
void Collect( BOARD_ITEM* aBoard, const std::vector<KICAD_T>& aTypes );
|
2021-06-04 13:04:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
PCB_LAYER_ID m_layer_id;
|
2008-01-22 20:35:46 +00:00
|
|
|
};
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
#endif // COLLECTORS_H
|