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>
|
2018-02-04 09:49:37 +00:00
|
|
|
* Copyright (C) 2004-2018 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
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file collectors.h
|
|
|
|
*/
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
#ifndef COLLECTORS_H
|
|
|
|
#define COLLECTORS_H
|
|
|
|
|
|
|
|
|
|
|
|
/* 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>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <layers_id_colors_and_visibility.h> // LAYER_COUNT, layer defs
|
2011-09-23 13:57:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BOARD_ITEM;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-08-30 03:53:26 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* An abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR,
|
2008-02-19 16:54:57 +00:00
|
|
|
* telling GENERAL_COLLECTOR what should be collected (aside from HitTest()ing
|
|
|
|
* and KICAD_T scanTypes[], information which are provided to the GENERAL_COLLECTOR
|
|
|
|
* through attributes or arguments separately).
|
2007-08-30 22:20:52 +00:00
|
|
|
* <p>
|
|
|
|
* A justification for this class is to keep the structural storage details of
|
2008-02-19 16:54:57 +00:00
|
|
|
* the program's "global preferences" or "configuration options" out of
|
2007-08-30 22:20:52 +00:00
|
|
|
* GENERAL_COLLECTOR::Inspect(). This class carries all the necessary details
|
|
|
|
* in with it to the Inspect() call. The constructors or other functions of
|
|
|
|
* this class's derivatives are then the only place where knowledge of the
|
2008-02-19 16:54:57 +00:00
|
|
|
* 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 (and even then it is
|
2007-08-30 22:20:52 +00:00
|
|
|
* not simple enough).
|
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
|
|
|
{
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 03:53:26 +00:00
|
|
|
public:
|
|
|
|
virtual ~COLLECTORS_GUIDE() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool - true if the given layer is locked, else false.
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
virtual bool IsLayerLocked( PCB_LAYER_ID layer ) const = 0;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 03:53:26 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if the given layer is visible, else false.
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
virtual bool IsLayerVisible( PCB_LAYER_ID layer ) const = 0;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 03:53:26 +00:00
|
|
|
/**
|
2007-08-30 22:20:52 +00:00
|
|
|
* @return bool - true if should ignore locked layers, else false.
|
2007-08-30 03:53:26 +00:00
|
|
|
*/
|
|
|
|
virtual bool IgnoreLockedLayers() const = 0;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 03:53:26 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore non-visible layers, else false.
|
|
|
|
*/
|
|
|
|
virtual bool IgnoreNonVisibleLayers() const = 0;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 03:53:26 +00:00
|
|
|
/**
|
|
|
|
* @return int - the preferred layer for HitTest()ing.
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
virtual PCB_LAYER_ID GetPreferredLayer() const = 0;
|
2007-08-30 22:20:52 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Provide wildcard behavior regarding the preferred layer.
|
|
|
|
*
|
2007-08-30 22:20:52 +00:00
|
|
|
* @return bool - true if should ignore preferred layer, else false.
|
|
|
|
*/
|
|
|
|
virtual bool IgnorePreferredLayer() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore locked items, else false.
|
|
|
|
*/
|
|
|
|
virtual bool IgnoreLockedItems() const = 0;
|
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Determine if the secondary criteria or 2nd choice items should be included.
|
|
|
|
*
|
2007-08-30 22:20:52 +00:00
|
|
|
* @return bool - true if should include, else false.
|
|
|
|
*/
|
|
|
|
virtual bool IncludeSecondary() const = 0;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
/**
|
2007-10-31 20:02:34 +00:00
|
|
|
* @return bool - true if MTexts marked as "no show" should be ignored.
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
|
|
|
virtual bool IgnoreMTextsMarkedNoShow() const = 0;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
/**
|
2014-09-11 16:35:19 +00:00
|
|
|
* @return bool - true if should ignore MTexts on back layers
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2014-09-11 16:35:19 +00:00
|
|
|
virtual bool IgnoreMTextsOnBack() const = 0;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
/**
|
2014-09-11 16:35:19 +00:00
|
|
|
* @return bool - true if should ignore MTexts on front layers.
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2014-09-11 16:35:19 +00:00
|
|
|
virtual bool IgnoreMTextsOnFront() const = 0;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
/**
|
2010-02-05 10:56:23 +00:00
|
|
|
* @return bool - true if should ignore MODULEs on Back Side.
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2014-09-11 16:35:19 +00:00
|
|
|
virtual bool IgnoreModulesOnBack() const = 0;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
/**
|
2010-02-05 10:56:23 +00:00
|
|
|
* @return bool - ture if should ignore MODULEs on Front Side.
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2014-09-11 16:35:19 +00:00
|
|
|
virtual bool IgnoreModulesOnFront() const = 0;
|
2007-09-25 15:10:01 +00:00
|
|
|
|
2010-02-05 10:56:23 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore Pads on Back Side.
|
|
|
|
*/
|
|
|
|
virtual bool IgnorePadsOnBack() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool - ture if should ignore PADSs on Front Side.
|
|
|
|
*/
|
|
|
|
virtual bool IgnorePadsOnFront() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore PADSs on Front side and Back side.
|
|
|
|
*/
|
|
|
|
virtual bool IgnorePads() const
|
|
|
|
{
|
|
|
|
return IgnorePadsOnFront() && IgnorePadsOnBack();
|
|
|
|
}
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2011-12-14 22:35:03 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore modules values.
|
|
|
|
*/
|
|
|
|
virtual bool IgnoreModulesVals() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore module references.
|
|
|
|
*/
|
|
|
|
virtual bool IgnoreModulesRefs() const = 0;
|
|
|
|
|
2018-01-18 02:12:51 +00:00
|
|
|
/**
|
|
|
|
* @return true if should ignore through-hole vias
|
|
|
|
*/
|
|
|
|
virtual bool IgnoreThroughVias() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore blind/buried vias
|
|
|
|
*/
|
|
|
|
virtual bool IgnoreBlindBuriedVias() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if should ignore micro vias
|
|
|
|
*/
|
|
|
|
virtual bool IgnoreMicroVias() const = 0;
|
|
|
|
|
2018-02-22 06:53:16 +00:00
|
|
|
/**
|
|
|
|
* @return true if should ignore tracks
|
|
|
|
*/
|
|
|
|
virtual bool IgnoreTracks() const = 0;
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if Inspect() should use BOARD_ITEM::HitTest()
|
|
|
|
* or false if Inspect() should use BOARD_ITEM::BoundsTest().
|
|
|
|
virtual bool UseHitTesting() 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.
|
|
|
|
* @return BOARD_ITEM* - or something derived from it, or NULL.
|
|
|
|
*/
|
|
|
|
BOARD_ITEM* operator[]( int ndx ) const
|
|
|
|
{
|
|
|
|
if( (unsigned)ndx < (unsigned)GetCount() )
|
|
|
|
return (BOARD_ITEM*) m_List[ ndx ];
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*
|
2007-08-24 03:40:04 +00:00
|
|
|
* Philosophy: this class knows nothing of the context in which a BOARD is used
|
2008-02-19 16:54:57 +00:00
|
|
|
* and that means it knows nothing about which layers are visible or current,
|
2007-08-23 04:28:46 +00:00
|
|
|
* but can handle those concerns by the SetPreferredLayer() function and the
|
2014-06-24 16:17:18 +00:00
|
|
|
* 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
|
|
|
/**
|
2007-08-30 22:20:52 +00:00
|
|
|
* Determines 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-09-12 02:14:07 +00:00
|
|
|
/**
|
2008-02-19 16:54:57 +00:00
|
|
|
* The number of items that were originally in the primary list before the
|
2015-04-03 09:13:06 +00:00
|
|
|
* m_List2nd was concatenated onto the end of it.
|
2007-09-12 02:14:07 +00:00
|
|
|
*/
|
|
|
|
int m_PrimaryLength;
|
2007-08-30 22:20:52 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
public:
|
|
|
|
|
2007-09-11 04:15:39 +00:00
|
|
|
/**
|
|
|
|
* A scan list for all editable board items, like PcbGeneralLocateAndDisplay()
|
|
|
|
*/
|
2007-08-23 04:28:46 +00:00
|
|
|
static const KICAD_T AllBoardItems[];
|
|
|
|
|
2007-09-25 15:10:01 +00:00
|
|
|
/**
|
|
|
|
* A scan list for all editable board items, except zones
|
|
|
|
*/
|
|
|
|
static const KICAD_T AllButZones[];
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2011-05-12 11:06:32 +00:00
|
|
|
/**
|
|
|
|
* A scan list for zones outlines only
|
|
|
|
*/
|
|
|
|
static const KICAD_T Zones[];
|
|
|
|
|
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
|
2007-09-06 04:34:03 +00:00
|
|
|
* a MODULE, such as D_PAD and TEXTEMODULE.
|
2007-10-10 14:08:26 +00:00
|
|
|
*/
|
2017-09-28 17:00:24 +00:00
|
|
|
static const KICAD_T BoardLevelItems[];
|
2007-09-12 02:14:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A scan list for only MODULEs
|
|
|
|
*/
|
2014-07-09 11:50:27 +00:00
|
|
|
static const KICAD_T Modules[];
|
2007-09-12 02:14:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A scan list for PADs or MODULEs
|
|
|
|
*/
|
|
|
|
static const KICAD_T PadsOrModules[];
|
|
|
|
|
2007-12-13 06:24:09 +00:00
|
|
|
/**
|
|
|
|
* A scan list for PADs, TRACKs, VIAs, or ZONEs
|
|
|
|
*/
|
2008-02-19 16:54:57 +00:00
|
|
|
static const KICAD_T PadsTracksOrZones[];
|
|
|
|
|
2007-10-27 18:05:50 +00:00
|
|
|
/**
|
|
|
|
* A scan list for MODULEs and their items (for Modedit)
|
|
|
|
*/
|
|
|
|
static const KICAD_T ModulesAndTheirItems[];
|
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
/**
|
|
|
|
* A scan list for primary module items.
|
|
|
|
*/
|
|
|
|
static const KICAD_T ModuleItems[];
|
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
/**
|
|
|
|
* A scan list for only TRACKS
|
|
|
|
*/
|
|
|
|
static const KICAD_T Tracks[];
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
/**
|
2007-08-24 03:40:04 +00:00
|
|
|
* Constructor GENERALCOLLECTOR
|
2008-02-19 16:54:57 +00:00
|
|
|
*/
|
2007-08-30 22:20:52 +00:00
|
|
|
GENERAL_COLLECTOR()
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2015-03-13 16:48:42 +00:00
|
|
|
m_Guide = NULL;
|
|
|
|
m_PrimaryLength = 0;
|
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
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
/**
|
2007-09-12 02:14:07 +00:00
|
|
|
* @return int - The number if items which met the primary search criteria
|
|
|
|
*/
|
|
|
|
int GetPrimaryCount() { return m_PrimaryLength; }
|
2008-02-19 16:54:57 +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.
|
|
|
|
*
|
|
|
|
* Searches and collects all the objects that the old function PcbGeneralLocateAndDisplay()
|
|
|
|
* would find, except that it keeps all that it finds and does not do any displaying.
|
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.
|
|
|
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
|
|
|
* else SCAN_CONTINUE;
|
2008-02-19 16:54:57 +00:00
|
|
|
*/
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_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.
|
|
|
|
*
|
2007-09-11 04:15:39 +00:00
|
|
|
* @param aItem A BOARD_ITEM to scan, may be a BOARD or MODULE, or whatever.
|
2008-02-19 16:54:57 +00:00
|
|
|
* @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
|
|
|
|
* what is to be collected and the priority order of the resultant
|
2007-09-11 04:15:39 +00:00
|
|
|
* 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
|
|
|
*/
|
2008-02-19 16:54:57 +00:00
|
|
|
void Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
|
|
|
|
const wxPoint& 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
|
|
|
|
{
|
|
|
|
private:
|
2008-02-19 16:54:57 +00:00
|
|
|
// the storage architecture here is not important, since this is only
|
2007-08-30 22:20:52 +00:00
|
|
|
// a carrier object and its functions are what is used, and data only indirectly.
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID m_PreferredLayer;
|
2007-08-30 22:20:52 +00:00
|
|
|
bool m_IgnorePreferredLayer;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET m_LayerLocked; ///< bit-mapped layer locked bits
|
2007-08-30 22:20:52 +00:00
|
|
|
bool m_IgnoreLockedLayers;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET m_LayerVisible; ///< bit-mapped layer visible bits
|
2007-08-30 22:20:52 +00:00
|
|
|
bool m_IgnoreNonVisibleLayers;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
|
|
|
bool m_IgnoreLockedItems;
|
2007-08-30 22:20:52 +00:00
|
|
|
bool m_IncludeSecondary;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
bool m_IgnoreMTextsMarkedNoShow;
|
2014-09-11 16:35:19 +00:00
|
|
|
bool m_IgnoreMTextsOnBack;
|
|
|
|
bool m_IgnoreMTextsOnFront;
|
|
|
|
bool m_IgnoreModulesOnBack;
|
|
|
|
bool m_IgnoreModulesOnFront;
|
2010-02-05 10:56:23 +00:00
|
|
|
bool m_IgnorePadsOnFront;
|
|
|
|
bool m_IgnorePadsOnBack;
|
2011-12-14 22:35:03 +00:00
|
|
|
bool m_IgnoreModulesVals;
|
|
|
|
bool m_IgnoreModulesRefs;
|
2018-01-18 02:12:51 +00:00
|
|
|
bool m_IgnoreThroughVias;
|
|
|
|
bool m_IgnoreBlindBuriedVias;
|
|
|
|
bool m_IgnoreMicroVias;
|
2018-02-22 06:53:16 +00:00
|
|
|
bool m_IgnoreTracks;
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
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
|
|
|
*
|
2010-12-29 17:47:32 +00:00
|
|
|
* @param aVisibleLayerMask = current visible layers (bit mask)
|
|
|
|
* @param aPreferredLayer = the layer to search first
|
2007-08-30 22:20:52 +00:00
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
GENERAL_COLLECTORS_GUIDE( LSET aVisibleLayerMask, PCB_LAYER_ID aPreferredLayer )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
m_PreferredLayer = aPreferredLayer;
|
2007-08-30 22:20:52 +00:00
|
|
|
m_IgnorePreferredLayer = false;
|
2008-02-19 16:54:57 +00:00
|
|
|
m_LayerVisible = aVisibleLayerMask;
|
2007-08-30 22:20:52 +00:00
|
|
|
m_IgnoreLockedLayers = true;
|
|
|
|
m_IgnoreNonVisibleLayers = true;
|
2007-09-05 04:48: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)
|
|
|
|
m_IncludeSecondary = false;
|
2008-02-19 16:54:57 +00:00
|
|
|
#else
|
2007-08-30 22:20:52 +00:00
|
|
|
m_IncludeSecondary = true;
|
2008-02-19 16:54:57 +00:00
|
|
|
#endif
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
m_IgnoreMTextsMarkedNoShow = true; // g_ModuleTextNOVColor;
|
2014-09-11 16:35:19 +00:00
|
|
|
m_IgnoreMTextsOnBack = true;
|
|
|
|
m_IgnoreMTextsOnFront = false;
|
|
|
|
m_IgnoreModulesOnBack = true; // !Show_Modules_Cmp;
|
|
|
|
m_IgnoreModulesOnFront = false;
|
2010-12-29 17:47:32 +00:00
|
|
|
|
2010-02-05 10:56:23 +00:00
|
|
|
m_IgnorePadsOnFront = false;
|
|
|
|
m_IgnorePadsOnBack = false;
|
2011-12-14 22:35:03 +00:00
|
|
|
|
|
|
|
m_IgnoreModulesVals = false;
|
|
|
|
m_IgnoreModulesRefs = false;
|
2018-01-18 02:12:51 +00:00
|
|
|
|
|
|
|
m_IgnoreThroughVias = false;
|
|
|
|
m_IgnoreBlindBuriedVias = false;
|
|
|
|
m_IgnoreMicroVias = false;
|
2018-02-22 06:53:16 +00:00
|
|
|
m_IgnoreTracks = false;
|
2007-09-05 04:48:47 +00:00
|
|
|
}
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if the given layer is locked, else false.
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
bool IsLayerLocked( PCB_LAYER_ID aLayerId ) const override
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
return m_LayerLocked[aLayerId];
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void SetLayerLocked( PCB_LAYER_ID aLayerId, bool isLocked )
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
m_LayerLocked.set( aLayerId, isLocked );
|
|
|
|
}
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if the given layer is visible, else false.
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const override
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
return m_LayerVisible[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
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
m_LayerVisible.set( aLayerId, isVisible );
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
2014-06-24 16:17:18 +00:00
|
|
|
void SetLayerVisibleBits( LSET aLayerBits ) { m_LayerVisible = aLayerBits; }
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore locked layers, else false.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnoreLockedLayers() const override { return m_IgnoreLockedLayers; }
|
2014-06-24 16:17:18 +00:00
|
|
|
void SetIgnoreLockedLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore non-visible layers, else false.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnoreNonVisibleLayers() const override { return m_IgnoreNonVisibleLayers; }
|
2014-06-24 16:17:18 +00:00
|
|
|
void SetIgnoreNonVisibleLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
|
2007-08-30 22:20:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int - the preferred layer for HitTest()ing.
|
|
|
|
*/
|
2017-03-13 03:19:33 +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
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Provide wildcard behavior regarding the preferred layer.
|
|
|
|
*
|
2007-08-30 22:20:52 +00:00
|
|
|
* @return bool - true if should ignore preferred layer, else false.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnorePreferredLayer() const override { return m_IgnorePreferredLayer; }
|
2014-06-24 16:17:18 +00:00
|
|
|
void SetIgnorePreferredLayer( bool ignore ) { m_IgnorePreferredLayer = ignore; }
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore locked items, else false.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnoreLockedItems() const override { return m_IgnoreLockedItems; }
|
2014-06-24 16:17:18 +00:00
|
|
|
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.
|
|
|
|
*
|
2007-08-30 22:20:52 +00:00
|
|
|
* @return bool - true if should include, else false.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IncludeSecondary() const override { return m_IncludeSecondary; }
|
2007-09-01 12:00:30 +00:00
|
|
|
void SetIncludeSecondary( bool include ) { m_IncludeSecondary = include; }
|
|
|
|
|
|
|
|
/**
|
2007-10-31 20:02:34 +00:00
|
|
|
* @return bool - true if MTexts marked as "no show" should be ignored.
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnoreMTextsMarkedNoShow() const override { return m_IgnoreMTextsMarkedNoShow; }
|
2007-09-01 12:00:30 +00:00
|
|
|
void SetIgnoreMTextsMarkedNoShow( bool ignore ) { m_IgnoreMTextsMarkedNoShow = ignore; }
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
/**
|
2014-09-11 16:35:19 +00:00
|
|
|
* @return bool - true if should ignore MTexts on back layers
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnoreMTextsOnBack() const override { return m_IgnoreMTextsOnBack; }
|
2014-09-11 16:35:19 +00:00
|
|
|
void SetIgnoreMTextsOnBack( bool ignore ) { m_IgnoreMTextsOnBack = ignore; }
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
/**
|
2014-09-11 16:35:19 +00:00
|
|
|
* @return bool - true if should ignore MTexts on front layers
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnoreMTextsOnFront() const override { return m_IgnoreMTextsOnFront; }
|
2014-09-11 16:35:19 +00:00
|
|
|
void SetIgnoreMTextsOnFront( bool ignore ) { m_IgnoreMTextsOnFront = ignore; }
|
2008-02-19 16:54:57 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
/**
|
2014-09-11 16:35:19 +00:00
|
|
|
* @return bool - true if should ignore MODULEs on the back side
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnoreModulesOnBack() const override { return m_IgnoreModulesOnBack; }
|
2014-09-11 16:35:19 +00:00
|
|
|
void SetIgnoreModulesOnBack( bool ignore ) { m_IgnoreModulesOnBack = ignore; }
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
/**
|
2010-02-05 10:56:23 +00:00
|
|
|
* @return bool - true if should ignore MODULEs on component layer.
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnoreModulesOnFront() const override { return m_IgnoreModulesOnFront; }
|
2014-09-11 16:35:19 +00:00
|
|
|
void SetIgnoreModulesOnFront( bool ignore ) { m_IgnoreModulesOnFront = ignore; }
|
2010-02-05 10:56:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore Pads on Back Side.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnorePadsOnBack() const override { return m_IgnorePadsOnBack; }
|
2010-02-05 10:56:23 +00:00
|
|
|
void SetIgnorePadsOnBack(bool ignore) { m_IgnorePadsOnBack = ignore; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore PADSs on Front Side.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnorePadsOnFront() const override { return m_IgnorePadsOnFront; }
|
2010-02-05 10:56:23 +00:00
|
|
|
void SetIgnorePadsOnFront(bool ignore) { m_IgnorePadsOnFront = ignore; }
|
2011-12-14 22:35:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore modules values.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnoreModulesVals() const override { return m_IgnoreModulesVals; }
|
2011-12-14 22:35:03 +00:00
|
|
|
void SetIgnoreModulesVals(bool ignore) { m_IgnoreModulesVals = ignore; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool - true if should ignore modules references.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool IgnoreModulesRefs() const override { return m_IgnoreModulesRefs; }
|
2011-12-14 22:35:03 +00:00
|
|
|
void SetIgnoreModulesRefs(bool ignore) { m_IgnoreModulesRefs = ignore; }
|
2018-01-18 02:12:51 +00:00
|
|
|
|
|
|
|
bool IgnoreThroughVias() const override { return m_IgnoreThroughVias; }
|
|
|
|
void SetIgnoreThroughVias( bool ignore ) { m_IgnoreThroughVias = ignore; }
|
|
|
|
|
|
|
|
bool IgnoreBlindBuriedVias() const override { return m_IgnoreBlindBuriedVias; }
|
|
|
|
void SetIgnoreBlindBuriedVias( bool ignore ) { m_IgnoreBlindBuriedVias = ignore; }
|
|
|
|
|
|
|
|
bool IgnoreMicroVias() const override { return m_IgnoreMicroVias; }
|
|
|
|
void SetIgnoreMicroVias( bool ignore ) { m_IgnoreMicroVias = ignore; }
|
2018-02-22 06:53:16 +00:00
|
|
|
|
|
|
|
bool IgnoreTracks() const override { return m_IgnoreTracks; }
|
|
|
|
void SetIgnoreTracks( bool ignore ) { m_IgnoreTracks = ignore; }
|
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.
|
|
|
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
|
|
|
* else SCAN_CONTINUE;
|
2008-01-22 20:35:46 +00:00
|
|
|
*/
|
2017-09-28 17:00:24 +00:00
|
|
|
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Collect #BOARD_ITEM objects using this class's Inspector method, which does the collection.
|
|
|
|
*
|
|
|
|
* @param aBoard The BOARD_ITEM to scan.
|
|
|
|
* @param aScanList The KICAD_Ts to gather up.
|
|
|
|
*/
|
|
|
|
void Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
{
|
|
|
|
PCB_LAYER_ID m_layer_id;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PCB_LAYER_COLLECTOR( PCB_LAYER_ID aLayerId = UNDEFINED_LAYER ) :
|
|
|
|
m_layer_id( aLayerId )
|
2008-01-22 20:35:46 +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.
|
|
|
|
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
|
|
|
* else SCAN_CONTINUE;
|
2008-02-19 16:54:57 +00:00
|
|
|
*/
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
2008-01-22 20:35:46 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Tests a BOARD_ITEM using this class's Inspector method, which does the collection.
|
|
|
|
*
|
2008-01-22 20:35:46 +00:00
|
|
|
* @param aBoard The BOARD_ITEM to scan.
|
|
|
|
* @param aScanList The KICAD_Ts to gather up.
|
|
|
|
*/
|
|
|
|
void Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] );
|
|
|
|
};
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
#endif // COLLECTORS_H
|