2011-07-12 06:57:11 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2011-07-12 06:57:11 +00:00
|
|
|
*
|
2021-02-24 13:48:02 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-08-20 09:27:35 +00:00
|
|
|
* Copyright (C) 2011-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2011-07-12 06:57:11 +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.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
#ifndef EE_COLLECTORS_H
|
|
|
|
#define EE_COLLECTORS_H
|
2011-07-12 06:57:11 +00:00
|
|
|
|
2021-02-24 13:48:02 +00:00
|
|
|
#include <lib_symbol.h>
|
2018-02-04 09:49:37 +00:00
|
|
|
#include <collector.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <dialogs/dialog_schematic_find.h>
|
2019-05-10 19:57:24 +00:00
|
|
|
#include <sch_item.h>
|
2020-03-30 13:14:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SCH_SHEET_PATH;
|
2021-06-10 14:10:55 +00:00
|
|
|
class SCH_SYMBOL;
|
2011-07-12 06:57:11 +00:00
|
|
|
|
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
class EE_COLLECTOR : public COLLECTOR
|
2011-07-12 06:57:11 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-08-21 19:54:07 +00:00
|
|
|
static const std::vector<KICAD_T> EditableItems;
|
|
|
|
static const std::vector<KICAD_T> MovableItems;
|
|
|
|
static const std::vector<KICAD_T> FieldOwners;
|
2022-08-20 09:27:35 +00:00
|
|
|
|
2022-08-21 19:54:07 +00:00
|
|
|
EE_COLLECTOR( const std::vector<KICAD_T>& aScanTypes = { SCH_LOCATE_ANY_T } ) :
|
2019-05-19 21:04:04 +00:00
|
|
|
m_Unit( 0 ),
|
2022-07-24 07:33:43 +00:00
|
|
|
m_Convert( 0 ),
|
|
|
|
m_ShowPinElectricalTypes( false )
|
2011-07-12 06:57:11 +00:00
|
|
|
{
|
|
|
|
SetScanTypes( aScanTypes );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-28 17:00:24 +00:00
|
|
|
* Overload COLLECTOR::operator[](int) to return a SCH_ITEM instead of an EDA_ITEM.
|
|
|
|
*
|
2011-07-12 06:57:11 +00:00
|
|
|
* @param aIndex The index into the list.
|
|
|
|
* @return SCH_ITEM* at \a aIndex or NULL.
|
|
|
|
*/
|
2019-04-21 23:45:34 +00:00
|
|
|
SCH_ITEM* operator[]( int aIndex ) const override
|
2011-07-12 06:57:11 +00:00
|
|
|
{
|
|
|
|
if( (unsigned)aIndex < (unsigned)GetCount() )
|
2020-10-02 20:25:14 +00:00
|
|
|
return (SCH_ITEM*) m_list[ aIndex ];
|
2011-07-12 06:57:11 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
return nullptr;
|
2011-07-12 06:57:11 +00:00
|
|
|
}
|
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
INSPECT_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
|
2011-07-12 06:57:11 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-06 11:13:08 +00:00
|
|
|
* Scan a #EDA_ITEM using this class's Inspector method which does the collection.
|
|
|
|
*
|
2019-06-25 23:39:58 +00:00
|
|
|
* @param aScreen The eeschema screen to use for scanning
|
2022-08-21 19:54:07 +00:00
|
|
|
* @param aScanTypes A list of #KICAD_T types that determines what is to be collected and
|
|
|
|
* the priority order of the resulting collection.
|
2021-05-06 11:13:08 +00:00
|
|
|
* @param aPos are the coordinates to use in hit testing.
|
|
|
|
* @param aUnit is the symbol unit filter (for symbol editor).
|
|
|
|
* @param aConvert is the DeMorgan filter (for symbol editor)
|
2011-07-12 06:57:11 +00:00
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
void Collect( SCH_SCREEN* aScreen, const std::vector<KICAD_T>& aScanTypes,
|
2022-08-20 09:27:35 +00:00
|
|
|
const VECTOR2I& aPos, int aUnit = 0, int aConvert = 0 );
|
2019-06-25 23:39:58 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-06 11:13:08 +00:00
|
|
|
* Scan an #EDA_ITEM using this class's Inspector method which does the collection.
|
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* @param aItems is a LIB_SYMBOL multivector holding the symbol items.
|
2022-08-21 19:54:07 +00:00
|
|
|
* @param aScanTypes is a list of #KICAD_T types that determines what is to be collected
|
|
|
|
* and the priority order of the resulting collection.
|
2021-05-06 11:13:08 +00:00
|
|
|
* @param aPos are the coordinates to use in hit testing.
|
|
|
|
* @param aUnit is the symbol unit filter (for symbol editor).
|
|
|
|
* @param aConvert is the DeMorgan filter (for symbol editor).
|
2019-06-25 23:39:58 +00:00
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
void Collect( LIB_ITEMS_CONTAINER& aItems, const std::vector<KICAD_T>& aScanTypes,
|
2022-08-20 09:27:35 +00:00
|
|
|
const VECTOR2I& aPos, int aUnit = 0, int aConvert = 0 );
|
2011-07-12 06:57:11 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-06 11:13:08 +00:00
|
|
|
* Test if the collected items form a corner of two line segments.
|
|
|
|
*
|
2011-07-12 06:57:11 +00:00
|
|
|
* @return True if the collected items form a corner of two line segments.
|
|
|
|
*/
|
|
|
|
bool IsCorner() const;
|
|
|
|
|
2019-04-25 20:25:44 +00:00
|
|
|
public:
|
2019-05-06 02:32:01 +00:00
|
|
|
int m_Unit; // Fixed symbol unit filter (for symbol editor)
|
|
|
|
int m_Convert; // Fixed DeMorgan filter (for symbol editor)
|
2022-07-23 22:26:03 +00:00
|
|
|
|
|
|
|
bool m_ShowPinElectricalTypes;
|
2011-07-12 06:57:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-05-06 11:13:08 +00:00
|
|
|
void CollectOtherUnits( const wxString& thisRef, int thisUnit, const LIB_ID& aLibId,
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SHEET_PATH& aSheet, std::vector<SCH_SYMBOL*>* otherUnits );
|
2020-03-30 13:14:44 +00:00
|
|
|
|
2019-05-10 19:22:26 +00:00
|
|
|
#endif // EE_COLLECTORS_H
|