2011-10-31 16:49:48 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-06 10:34:11 -05:00
|
|
|
* Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-09-21 08:58:08 -04:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-12-08 23:56:55 +00:00
|
|
|
* Copyright (C) 2022 CERN
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-31 16:49:48 -04: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
|
|
|
|
*/
|
|
|
|
|
2024-04-02 18:28:17 +01:00
|
|
|
#ifndef LIB_SYMBOL_H
|
|
|
|
#define LIB_SYMBOL_H
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2024-05-16 09:15:40 -07:00
|
|
|
#include <embedded_files.h>
|
2024-04-02 18:28:17 +01:00
|
|
|
#include <symbol.h>
|
2024-04-12 22:00:41 +01:00
|
|
|
#include <sch_field.h>
|
2024-04-20 10:44:34 +01:00
|
|
|
#include <sch_pin.h>
|
2018-07-27 21:47:51 +01:00
|
|
|
#include <lib_tree_item.h>
|
2015-06-07 20:07:42 -04:00
|
|
|
#include <vector>
|
2023-09-08 07:07:52 -04:00
|
|
|
#include <core/multivector.h>
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2011-10-31 16:49:48 -04:00
|
|
|
class LINE_READER;
|
2011-11-01 11:06:26 -04:00
|
|
|
class OUTPUTFORMATTER;
|
2023-03-09 11:25:32 +00:00
|
|
|
class REPORTER;
|
2021-06-15 08:31:28 -04:00
|
|
|
class SYMBOL_LIB;
|
2021-06-10 14:51:46 -04:00
|
|
|
class LIB_SYMBOL;
|
2025-01-16 18:05:29 -08:00
|
|
|
class OUTLINE_FONT;
|
2021-06-10 14:51:46 -04:00
|
|
|
class TEST_LIB_SYMBOL_FIXTURE;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2025-01-16 18:05:29 -08:00
|
|
|
namespace KIFONT
|
|
|
|
{
|
|
|
|
class OUTLINE_FONT;
|
|
|
|
}
|
|
|
|
|
2010-10-20 16:24:26 -04:00
|
|
|
|
2021-06-15 08:31:28 -04:00
|
|
|
typedef std::shared_ptr<LIB_SYMBOL> LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL
|
|
|
|
typedef std::weak_ptr<LIB_SYMBOL> LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL
|
2024-04-20 10:44:34 +01:00
|
|
|
typedef MULTIVECTOR<SCH_ITEM, SCH_SHAPE_T, SCH_PIN_T> LIB_ITEMS_CONTAINER;
|
2017-09-17 14:04:38 +02:00
|
|
|
typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS;
|
2010-10-04 14:54:14 -04:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2010-02-17 13:22:25 +00:00
|
|
|
/* values for member .m_options */
|
2021-02-09 19:10:58 -05:00
|
|
|
enum LIBRENTRYOPTIONS
|
2009-09-02 18:12:45 +00:00
|
|
|
{
|
2025-02-26 18:13:36 -08:00
|
|
|
ENTRY_NORMAL, // Libentry is a standard symbol (real or alias)
|
|
|
|
ENTRY_GLOBAL_POWER, // Libentry is a power symbol
|
|
|
|
ENTRY_LOCAL_POWER // Libentry is a local power symbol
|
2008-12-31 09:27:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-06-10 14:51:46 -04:00
|
|
|
extern bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
|
2021-11-02 18:32:39 +00:00
|
|
|
struct LIB_SYMBOL_UNIT
|
2020-02-13 08:39:52 -05:00
|
|
|
{
|
|
|
|
int m_unit; ///< The unit number.
|
2024-01-26 16:16:13 +00:00
|
|
|
int m_bodyStyle; ///< The alternate body style of the unit.
|
2024-04-06 14:14:44 +01:00
|
|
|
std::vector<SCH_ITEM*> m_items; ///< The items unique to this unit and alternate body style.
|
2020-02-13 08:39:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
2017-12-01 11:49:19 -05:00
|
|
|
* Define a library symbol object.
|
2009-08-19 19:34:03 +00:00
|
|
|
*
|
2021-06-10 14:51:46 -04:00
|
|
|
* A library symbol object is typically saved and loaded in a symbol library file (.lib).
|
2017-12-01 11:49:19 -05:00
|
|
|
* Library symbols are different from schematic symbols.
|
2009-08-19 19:34:03 +00:00
|
|
|
*/
|
2024-05-16 09:15:40 -07:00
|
|
|
class LIB_SYMBOL : public SYMBOL, public LIB_TREE_ITEM, public EMBEDDED_FILES
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2010-09-09 13:37:25 -04:00
|
|
|
public:
|
2021-06-10 14:51:46 -04:00
|
|
|
LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent = nullptr,
|
2021-06-15 08:31:28 -04:00
|
|
|
SYMBOL_LIB* aLibrary = nullptr );
|
2019-11-06 14:15:42 -05:00
|
|
|
|
2021-07-16 16:13:26 -04:00
|
|
|
LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary = nullptr );
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2022-12-09 20:02:47 +00:00
|
|
|
virtual ~LIB_SYMBOL()
|
|
|
|
{}
|
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 15:28:54 -05:00
|
|
|
|
2025-02-06 09:47:00 -05:00
|
|
|
/// http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared.
|
2021-06-15 08:31:28 -04:00
|
|
|
LIB_SYMBOL_SPTR SharedPtr() const { return m_me; }
|
2019-11-06 14:15:42 -05:00
|
|
|
|
2020-11-23 20:34:57 +00:00
|
|
|
/**
|
2021-06-10 14:51:46 -04:00
|
|
|
* Create a copy of a LIB_SYMBOL and assigns unique KIIDs to the copy and its children.
|
2020-11-23 20:34:57 +00:00
|
|
|
*/
|
2021-06-10 14:51:46 -04:00
|
|
|
virtual LIB_SYMBOL* Duplicate() const
|
2020-11-23 20:34:57 +00:00
|
|
|
{
|
2021-06-10 14:51:46 -04:00
|
|
|
LIB_SYMBOL* dupe = new LIB_SYMBOL( *this, m_library );
|
2020-11-23 20:34:57 +00:00
|
|
|
const_cast<KIID&>( dupe->m_Uuid ) = KIID();
|
|
|
|
|
2024-04-06 14:14:44 +01:00
|
|
|
for( SCH_ITEM& item : dupe->m_drawings )
|
2020-11-23 20:34:57 +00:00
|
|
|
const_cast<KIID&>( item.m_Uuid ) = KIID();
|
|
|
|
|
|
|
|
return dupe;
|
|
|
|
}
|
|
|
|
|
2025-01-10 00:12:54 +00:00
|
|
|
/**
|
|
|
|
* Returns a dummy LIB_SYMBOL, used when one is missing in the schematic
|
|
|
|
*/
|
|
|
|
static LIB_SYMBOL* GetDummy();
|
|
|
|
|
2021-06-10 14:51:46 -04:00
|
|
|
void SetParent( LIB_SYMBOL* aParent = nullptr );
|
2021-06-15 08:31:28 -04:00
|
|
|
LIB_SYMBOL_REF& GetParent() { return m_parent; }
|
|
|
|
const LIB_SYMBOL_REF& GetParent() const { return m_parent; }
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2023-08-20 12:05:31 -04:00
|
|
|
/**
|
|
|
|
* Get the number of parents for this symbol.
|
|
|
|
*
|
2025-02-06 09:47:00 -05:00
|
|
|
* @return the inheritance depth for this symbol.
|
2023-08-20 12:05:31 -04:00
|
|
|
*/
|
|
|
|
unsigned GetInheritanceDepth() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the parent symbol that does not have another parent.
|
|
|
|
*
|
|
|
|
* Now that derived symbols can be derived from other derived symbols, this method provides
|
|
|
|
* way to get to the base symbol in the derivation change.
|
|
|
|
*
|
|
|
|
* @return the weak_ptr to the root symbol of this symbol.
|
|
|
|
*/
|
2023-10-28 13:15:45 -04:00
|
|
|
LIB_SYMBOL_SPTR GetRootSymbol() const;
|
2023-08-20 12:05:31 -04:00
|
|
|
|
2016-09-25 19:06:49 +02:00
|
|
|
virtual wxString GetClass() const override
|
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 15:28:54 -05:00
|
|
|
{
|
2021-06-10 14:51:46 -04:00
|
|
|
return wxT( "LIB_SYMBOL" );
|
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 15:28:54 -05:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2023-04-28 17:02:42 -07:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && aItem->Type() == LIB_SYMBOL_T;
|
|
|
|
}
|
|
|
|
|
2010-10-22 08:11:52 -04:00
|
|
|
virtual void SetName( const wxString& aName );
|
2019-11-08 15:50:04 -05:00
|
|
|
wxString GetName() const override { return m_name; }
|
2010-10-25 11:43:42 -04:00
|
|
|
|
2024-04-02 17:10:23 +01:00
|
|
|
LIB_ID GetLIB_ID() const override { return m_libId; }
|
|
|
|
wxString GetDesc() override { return GetDescription(); }
|
2024-04-02 18:28:17 +01:00
|
|
|
int GetSubUnitCount() const override { return GetUnitCount(); }
|
2024-04-02 17:10:23 +01:00
|
|
|
|
2024-04-02 18:28:17 +01:00
|
|
|
const LIB_ID& GetLibId() const override { return m_libId; }
|
2018-01-09 13:26:31 +01:00
|
|
|
void SetLibId( const LIB_ID& aLibId ) { m_libId = aLibId; }
|
2016-11-20 13:33:07 -05:00
|
|
|
|
2023-01-19 22:45:46 -05:00
|
|
|
LIB_ID GetSourceLibId() const { return m_sourceLibId; }
|
|
|
|
void SetSourceLibId( const LIB_ID& aLibId ) { m_sourceLibId = aLibId; }
|
|
|
|
|
2019-11-06 14:15:42 -05:00
|
|
|
wxString GetLibNickname() const override { return GetLibraryName(); }
|
2016-08-18 19:23:10 -04:00
|
|
|
|
2023-06-19 13:08:18 -04:00
|
|
|
///< Sets the Description field text value
|
|
|
|
void SetDescription( const wxString& aDescription )
|
|
|
|
{
|
|
|
|
GetDescriptionField().SetText( aDescription );
|
|
|
|
}
|
2020-12-14 13:47:32 +00:00
|
|
|
|
2023-06-19 13:08:18 -04:00
|
|
|
///< Gets the Description field text value */
|
2024-04-02 18:28:17 +01:00
|
|
|
wxString GetDescription() const override
|
2019-11-06 14:15:42 -05:00
|
|
|
{
|
2025-01-25 20:06:08 +00:00
|
|
|
if( GetDescriptionField().GetText().IsEmpty() && IsDerived() )
|
2020-12-14 13:47:32 +00:00
|
|
|
{
|
2021-06-15 08:31:28 -04:00
|
|
|
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
2020-12-14 13:47:32 +00:00
|
|
|
return parent->GetDescription();
|
|
|
|
}
|
|
|
|
|
2023-06-19 13:08:18 -04:00
|
|
|
return GetDescriptionField().GetText();
|
2019-11-06 14:15:42 -05:00
|
|
|
}
|
2010-09-09 13:37:25 -04:00
|
|
|
|
2020-12-14 13:47:32 +00:00
|
|
|
void SetKeyWords( const wxString& aKeyWords ) { m_keyWords = aKeyWords; }
|
2018-08-13 18:00:08 +01:00
|
|
|
|
2024-04-02 18:28:17 +01:00
|
|
|
wxString GetKeyWords() const override
|
2019-11-06 14:15:42 -05:00
|
|
|
{
|
2025-01-25 20:06:08 +00:00
|
|
|
if( m_keyWords.IsEmpty() && IsDerived() )
|
2020-12-14 13:47:32 +00:00
|
|
|
{
|
2021-06-15 08:31:28 -04:00
|
|
|
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
2020-12-14 13:47:32 +00:00
|
|
|
return parent->GetKeyWords();
|
|
|
|
}
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2020-12-14 13:47:32 +00:00
|
|
|
return m_keyWords;
|
|
|
|
}
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2023-05-01 21:26:29 +01:00
|
|
|
std::vector<SEARCH_TERM> GetSearchTerms() override;
|
2018-08-13 18:00:08 +01:00
|
|
|
|
2022-06-05 18:58:27 +01:00
|
|
|
wxString GetFootprint() override
|
|
|
|
{
|
|
|
|
return GetFootprintField().GetText();
|
|
|
|
}
|
|
|
|
|
2022-08-28 19:02:12 -04:00
|
|
|
void GetChooserFields( std::map<wxString , wxString>& aColumnMap ) override;
|
|
|
|
|
2023-06-04 10:29:46 +01:00
|
|
|
/**
|
2019-11-06 14:15:42 -05:00
|
|
|
* For symbols derived from other symbols, IsRoot() indicates no derivation.
|
2010-02-17 13:22:25 +00:00
|
|
|
*/
|
2019-11-06 14:15:42 -05:00
|
|
|
bool IsRoot() const override { return m_parent.use_count() == 0; }
|
2025-01-25 20:06:08 +00:00
|
|
|
bool IsDerived() const { return !m_parent.expired() && m_parent.use_count() > 0; }
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2019-11-06 14:15:42 -05:00
|
|
|
const wxString GetLibraryName() const;
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2021-06-15 08:31:28 -04:00
|
|
|
SYMBOL_LIB* GetLib() const { return m_library; }
|
|
|
|
void SetLib( SYMBOL_LIB* aLibrary ) { m_library = aLibrary; }
|
2010-12-02 16:41:56 -05:00
|
|
|
|
2020-12-14 13:47:32 +00:00
|
|
|
timestamp_t GetLastModDate() const { return m_lastModDate; }
|
|
|
|
|
|
|
|
void SetFPFilters( const wxArrayString& aFilters ) { m_fpFilters = aFilters; }
|
2019-11-06 14:15:42 -05:00
|
|
|
|
2020-12-14 13:47:32 +00:00
|
|
|
wxArrayString GetFPFilters() const
|
2019-11-06 14:15:42 -05:00
|
|
|
{
|
2025-01-25 20:06:08 +00:00
|
|
|
if( m_fpFilters.IsEmpty() && IsDerived() )
|
2020-12-14 13:47:32 +00:00
|
|
|
{
|
2021-06-15 08:31:28 -04:00
|
|
|
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
2020-12-14 13:47:32 +00:00
|
|
|
return parent->GetFPFilters();
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_fpFilters;
|
2019-11-06 14:15:42 -05:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-02-27 20:54:01 +01:00
|
|
|
/**
|
2017-12-01 11:49:19 -05:00
|
|
|
* Get the bounding box for the symbol.
|
|
|
|
*
|
2021-06-10 14:51:46 -04:00
|
|
|
* @return the symbol bounding box ( in user coordinates )
|
2011-02-27 20:54:01 +01:00
|
|
|
* @param aUnit = unit selection = 0, or 1..n
|
2024-01-26 16:16:13 +00:00
|
|
|
* @param aBodyStyle = 0, 1 or 2
|
2011-02-27 20:54:01 +01:00
|
|
|
* If aUnit == 0, unit is not used
|
2024-01-26 16:16:13 +00:00
|
|
|
* if aBodyStyle == 0 Convert is non used
|
2022-12-12 22:47:56 -05:00
|
|
|
* @param aIgnoreHiddenFields default true, ignores any hidden fields
|
2011-02-27 20:54:01 +01:00
|
|
|
**/
|
2024-01-26 16:16:13 +00:00
|
|
|
const BOX2I GetUnitBoundingBox( int aUnit, int aBodyStyle,
|
|
|
|
bool aIgnoreHiddenFields = true ) const;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2024-12-22 20:20:32 +00:00
|
|
|
const BOX2I GetBoundingBox() const override
|
|
|
|
{
|
|
|
|
return GetUnitBoundingBox( 0, 0 );
|
|
|
|
}
|
|
|
|
|
2011-02-27 20:54:01 +01:00
|
|
|
/**
|
2017-12-01 11:49:19 -05:00
|
|
|
* Get the symbol bounding box excluding fields.
|
|
|
|
*
|
2021-06-10 14:51:46 -04:00
|
|
|
* @return the symbol bounding box ( in user coordinates ) without fields
|
2011-02-27 20:54:01 +01:00
|
|
|
* @param aUnit = unit selection = 0, or 1..n
|
2024-01-26 16:16:13 +00:00
|
|
|
* @param aBodyStyle = 0, 1 or 2
|
2011-02-27 20:54:01 +01:00
|
|
|
* If aUnit == 0, unit is not used
|
2024-01-26 16:16:13 +00:00
|
|
|
* if aBodyStyle == 0 Convert is non used
|
2011-02-27 20:54:01 +01:00
|
|
|
* Fields are not taken in account
|
2025-02-06 09:47:00 -05:00
|
|
|
*/
|
2024-01-26 16:16:13 +00:00
|
|
|
const BOX2I GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins,
|
2022-08-31 00:28:18 +01:00
|
|
|
bool aIncludePrivateItems ) const;
|
2011-02-27 20:54:01 +01:00
|
|
|
|
2024-12-22 20:20:32 +00:00
|
|
|
BOX2I GetBodyBoundingBox() const override
|
2016-09-30 01:31:48 -04:00
|
|
|
{
|
2024-12-22 20:20:32 +00:00
|
|
|
return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, false, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
BOX2I GetBodyAndPinsBoundingBox() const override
|
|
|
|
{
|
|
|
|
return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, true, false );
|
2016-09-30 01:31:48 -04:00
|
|
|
}
|
|
|
|
|
2025-02-26 18:13:36 -08:00
|
|
|
bool IsGlobalPower() const override;
|
|
|
|
bool IsLocalPower() const override;
|
2024-04-02 18:28:17 +01:00
|
|
|
bool IsPower() const override;
|
|
|
|
bool IsNormal() const override;
|
2010-02-16 17:49:17 +00:00
|
|
|
|
2025-02-26 18:13:36 -08:00
|
|
|
void SetGlobalPower();
|
|
|
|
void SetLocalPower();
|
2021-02-09 19:10:58 -05:00
|
|
|
void SetNormal();
|
2010-02-16 17:49:17 +00:00
|
|
|
|
2018-01-24 15:09:08 +01:00
|
|
|
/**
|
2021-06-10 14:51:46 -04:00
|
|
|
* Set interchangeable the property for symbol units.
|
2018-01-24 15:09:08 +01:00
|
|
|
* @param aLockUnits when true then units are set as not interchangeable.
|
|
|
|
*/
|
2010-06-24 14:31:43 -04:00
|
|
|
void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
|
2018-01-24 15:09:08 +01:00
|
|
|
|
|
|
|
/**
|
2021-06-10 14:51:46 -04:00
|
|
|
* Check whether symbol units are interchangeable.
|
2018-01-24 15:09:08 +01:00
|
|
|
* @return False when interchangeable, true otherwise.
|
|
|
|
*/
|
2016-04-02 08:25:44 -04:00
|
|
|
bool UnitsLocked() const { return m_unitsLocked; }
|
2010-06-24 14:31:43 -04:00
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
2022-12-09 20:02:47 +00:00
|
|
|
* Overwrite all the existing fields in this symbol with fields supplied in \a aFieldsList.
|
2017-12-01 11:49:19 -05:00
|
|
|
*
|
|
|
|
* @param aFieldsList is a set of fields to import, removing all previous fields.
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2024-04-12 22:00:41 +01:00
|
|
|
void SetFields( const std::vector<SCH_FIELD>& aFieldsList );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-10-21 20:02:25 +00:00
|
|
|
/**
|
2025-02-08 13:45:57 +00:00
|
|
|
* Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
|
2009-10-21 20:02:25 +00:00
|
|
|
*
|
2025-02-08 13:45:57 +00:00
|
|
|
* @param aList is the vector to populate.
|
2009-10-21 20:02:25 +00:00
|
|
|
*/
|
2025-02-08 13:45:57 +00:00
|
|
|
void GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly = false ) const override;
|
2024-12-22 20:20:32 +00:00
|
|
|
|
2025-02-08 13:45:57 +00:00
|
|
|
/**
|
|
|
|
* Create a copy of the SCH_FIELDs, sorted in ordinal order.
|
|
|
|
*/
|
2024-12-22 20:20:32 +00:00
|
|
|
void CopyFields( std::vector<SCH_FIELD>& aList );
|
2020-12-15 15:06:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a field. Takes ownership of the pointer.
|
|
|
|
*/
|
2024-04-12 22:00:41 +01:00
|
|
|
void AddField( SCH_FIELD* aField );
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2024-04-12 22:00:41 +01:00
|
|
|
void AddField( SCH_FIELD& aField ) { AddField( new SCH_FIELD( aField ) ); }
|
2022-12-08 23:56:55 +00:00
|
|
|
|
2025-03-07 15:34:57 +00:00
|
|
|
/**
|
|
|
|
* Return the next ordinal for a user field for this symbol
|
|
|
|
*/
|
|
|
|
int GetNextFieldOrdinal() const;
|
|
|
|
|
2010-06-17 11:30:10 -05:00
|
|
|
/**
|
2025-02-08 13:45:57 +00:00
|
|
|
* Find a field within this symbol matching \a aFieldName; return nullptr if not found.
|
2010-06-17 11:30:10 -05:00
|
|
|
*/
|
2025-02-08 13:45:57 +00:00
|
|
|
SCH_FIELD* GetField( const wxString& aFieldName );
|
|
|
|
const SCH_FIELD* GetField( const wxString& aFieldName ) const;
|
2010-06-17 11:30:10 -05:00
|
|
|
|
2025-02-08 13:45:57 +00:00
|
|
|
SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
|
2020-06-01 13:45:46 -04:00
|
|
|
|
2025-02-08 13:45:57 +00:00
|
|
|
const SCH_FIELD* GetField( FIELD_T aFieldType ) const;
|
|
|
|
SCH_FIELD* GetField( FIELD_T aFieldType );
|
2009-10-21 20:02:25 +00:00
|
|
|
|
|
|
|
/** Return reference to the value field. */
|
2025-02-08 13:45:57 +00:00
|
|
|
SCH_FIELD& GetValueField() { return *GetField( FIELD_T::VALUE ); }
|
|
|
|
const SCH_FIELD& GetValueField() const;
|
2009-10-21 20:02:25 +00:00
|
|
|
|
|
|
|
/** Return reference to the reference designator field. */
|
2025-02-08 13:45:57 +00:00
|
|
|
SCH_FIELD& GetReferenceField() { return *GetField( FIELD_T::REFERENCE ); }
|
|
|
|
const SCH_FIELD& GetReferenceField() const;
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2017-07-09 23:08:33 +10:00
|
|
|
/** Return reference to the footprint field */
|
2025-02-08 13:45:57 +00:00
|
|
|
SCH_FIELD& GetFootprintField() { return *GetField( FIELD_T::FOOTPRINT ); }
|
|
|
|
const SCH_FIELD& GetFootprintField() const;
|
2017-07-09 23:08:33 +10:00
|
|
|
|
2020-06-01 09:13:32 -04:00
|
|
|
/** Return reference to the datasheet field. */
|
2025-02-08 13:45:57 +00:00
|
|
|
SCH_FIELD& GetDatasheetField() { return *GetField( FIELD_T::DATASHEET ); }
|
|
|
|
const SCH_FIELD& GetDatasheetField() const;
|
2020-06-01 09:13:32 -04:00
|
|
|
|
2023-06-19 13:08:18 -04:00
|
|
|
/** Return reference to the description field. */
|
2025-02-08 13:45:57 +00:00
|
|
|
SCH_FIELD& GetDescriptionField() {return *GetField( FIELD_T::DESCRIPTION ); }
|
|
|
|
const SCH_FIELD& GetDescriptionField() const;
|
2023-06-19 13:08:18 -04:00
|
|
|
|
2022-12-08 23:56:55 +00:00
|
|
|
wxString GetPrefix();
|
|
|
|
|
2024-04-05 22:35:32 +01:00
|
|
|
const wxString GetRef( const SCH_SHEET_PATH* aSheet, bool aIncludeUnit = false ) const override
|
|
|
|
{
|
|
|
|
return GetReferenceField().GetText();
|
|
|
|
}
|
|
|
|
|
|
|
|
const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
|
|
|
|
bool aAllowExtraText ) const override
|
|
|
|
{
|
|
|
|
return GetValueField().GetText();
|
|
|
|
}
|
|
|
|
|
2025-01-16 18:05:29 -08:00
|
|
|
std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
|
|
|
|
|
2024-05-16 09:15:40 -07:00
|
|
|
EMBEDDED_FILES* GetEmbeddedFiles() override;
|
|
|
|
const EMBEDDED_FILES* GetEmbeddedFiles() const;
|
|
|
|
|
|
|
|
void EmbedFonts() override;
|
|
|
|
|
2025-01-02 10:59:50 +00:00
|
|
|
/**
|
|
|
|
* Automatically orient all the fields in the symbol.
|
|
|
|
*
|
|
|
|
* @param aScreen is the SCH_SCREEN associated with the current instance of the symbol.
|
|
|
|
* Required when \a aAlgo is AUTOPLACE_MANUAL; optional otherwise.
|
|
|
|
*/
|
|
|
|
void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
|
|
|
|
|
2025-03-27 13:11:07 -04:00
|
|
|
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
|
2023-04-28 17:02:42 -07:00
|
|
|
|
2024-05-29 22:52:39 +01:00
|
|
|
/**
|
|
|
|
* Resolve any references to system tokens supported by the symbol.
|
|
|
|
*
|
|
|
|
* @param aDepth a counter to limit recursion and circular references.
|
|
|
|
*/
|
|
|
|
bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
|
|
|
|
|
2024-04-05 22:35:32 +01:00
|
|
|
void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
|
|
|
|
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
|
2013-05-18 11:38:23 +02:00
|
|
|
|
|
|
|
/**
|
2024-04-05 22:35:32 +01:00
|
|
|
* Plot symbol fields.
|
2013-05-18 11:38:23 +02:00
|
|
|
*/
|
2024-04-05 22:35:32 +01:00
|
|
|
void PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
|
2024-04-08 12:26:56 +01:00
|
|
|
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed );
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
2021-03-04 17:59:24 -05:00
|
|
|
* Add a new draw \a aItem to the draw object list and sort according to \a aSort.
|
2009-09-29 18:38:21 +00:00
|
|
|
*
|
2021-03-04 17:59:24 -05:00
|
|
|
* @param aItem is the new draw object to add to the symbol.
|
|
|
|
* @param aSort is the flag to determine if the newly added item should be sorted.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
2024-04-06 14:14:44 +01:00
|
|
|
void AddDrawItem( SCH_ITEM* aItem, bool aSort = true );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/**
|
2010-06-24 14:31:43 -04:00
|
|
|
* Remove draw \a aItem from list.
|
2009-09-04 18:57:37 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aItem - Draw item to remove from list.
|
2009-09-04 18:57:37 +00:00
|
|
|
*/
|
2024-04-06 14:14:44 +01:00
|
|
|
void RemoveDrawItem( SCH_ITEM* aItem );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2024-04-12 22:00:41 +01:00
|
|
|
void RemoveField( SCH_FIELD* aField ) { RemoveDrawItem( aField ); }
|
2022-12-08 23:56:55 +00:00
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
/**
|
|
|
|
* Return a list of pin object pointers from the draw item list.
|
|
|
|
*
|
2022-12-16 13:42:49 +00:00
|
|
|
* Note pin objects are owned by the draw list of the symbol. Deleting any of the objects
|
|
|
|
* will leave list in a unstable state and will likely segfault when the list is destroyed.
|
2009-10-14 19:43:31 +00:00
|
|
|
*
|
2022-12-16 13:42:49 +00:00
|
|
|
* @param aUnit - Unit number of pins to collect. Set to 0 to get pins from any symbol unit.
|
2024-01-26 16:16:13 +00:00
|
|
|
* @param aBodyStyle - Symbol alternate body style of pins to collect. Set to 0 to get pins
|
|
|
|
* from any DeMorgan variant of symbol.
|
2009-10-14 19:43:31 +00:00
|
|
|
*/
|
2024-12-22 20:20:32 +00:00
|
|
|
std::vector<SCH_PIN*> GetPins( int aUnit, int aBodyStyle ) const;
|
2009-10-14 19:43:31 +00:00
|
|
|
|
2022-12-16 13:42:49 +00:00
|
|
|
/**
|
|
|
|
* Return a list of pin pointers for all units / converts. Used primarily for SPICE where
|
|
|
|
* we want to treat all unit as a single part.
|
|
|
|
*/
|
2024-12-22 20:20:32 +00:00
|
|
|
std::vector<SCH_PIN*> GetPins() const override;
|
2022-12-16 13:42:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return a count of pins for all units / converts.
|
|
|
|
*/
|
2023-10-02 23:32:20 +01:00
|
|
|
int GetPinCount() override;
|
2022-12-09 20:02:47 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2010-06-24 14:31:43 -04:00
|
|
|
* Return pin object with the requested pin \a aNumber.
|
2009-10-30 19:26:25 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aNumber - Number of the pin to find.
|
2022-12-16 13:42:49 +00:00
|
|
|
* @param aUnit - Unit filter. Set to 0 if a specific unit number is not required.
|
2024-01-26 16:16:13 +00:00
|
|
|
* @param aBodyStyle - DeMorgan variant filter. Set to 0 if no specific DeMorgan variant is
|
2022-12-16 13:42:49 +00:00
|
|
|
* required.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return The pin object if found. Otherwise NULL.
|
|
|
|
*/
|
2024-04-20 10:44:34 +01:00
|
|
|
SCH_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 ) const;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2015-04-25 18:26:51 -04:00
|
|
|
/**
|
2022-12-16 13:42:49 +00:00
|
|
|
* Return true if this symbol's pins do not match another symbol's pins. This is used to
|
|
|
|
* detect whether the project cache is out of sync with the system libs.
|
2015-04-25 18:26:51 -04:00
|
|
|
*
|
2021-06-10 14:51:46 -04:00
|
|
|
* @param aOtherSymbol - The other library symbol to test
|
2015-04-25 18:26:51 -04:00
|
|
|
* @param aTestNums - Whether two pins at the same point must have the same number.
|
|
|
|
* @param aTestNames - Whether two pins at the same point must have the same name.
|
|
|
|
* @param aTestType - Whether two pins at the same point must have the same electrical type.
|
|
|
|
* @param aTestOrientation - Whether two pins at the same point must have the same orientation.
|
|
|
|
* @param aTestLength - Whether two pins at the same point must have the same length.
|
|
|
|
*/
|
2021-06-10 14:51:46 -04:00
|
|
|
bool PinsConflictWith( const LIB_SYMBOL& aOtherSymbol, bool aTestNums, bool aTestNames,
|
2021-03-06 10:27:41 +01:00
|
|
|
bool aTestType, bool aTestOrientation, bool aTestLength ) const;
|
2015-04-25 18:26:51 -04:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
/**
|
2021-06-10 14:51:46 -04:00
|
|
|
* Move the symbol \a aOffset.
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aOffset - Offset displacement.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2024-04-02 18:28:17 +01:00
|
|
|
void Move( const VECTOR2I& aOffset ) override;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-10 14:51:46 -04:00
|
|
|
* Test if symbol has more than one body conversion type (DeMorgan).
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
2021-06-10 14:51:46 -04:00
|
|
|
* @return True if symbol has more than one conversion.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2024-04-02 18:28:17 +01:00
|
|
|
bool HasAlternateBodyStyle() const override;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2022-05-15 00:33:43 +02:00
|
|
|
/**
|
|
|
|
* @return the highest pin number of the symbol's pins.
|
|
|
|
* If none of the pins has pin number assigned it returns 0.
|
|
|
|
*/
|
|
|
|
int GetMaxPinNumber() const;
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
2021-06-10 14:51:46 -04:00
|
|
|
* Clears the status flag all draw objects in this symbol.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
2024-04-06 14:14:44 +01:00
|
|
|
void ClearTempFlags() override;
|
|
|
|
void ClearEditFlags() override;
|
2020-12-14 13:47:32 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
|
|
|
* Locate a draw object.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aUnit - Unit number of draw item.
|
2024-01-26 16:16:13 +00:00
|
|
|
* @param aBodyStyle - Body style of draw item.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aType - Draw object type, set to 0 to search for any type.
|
|
|
|
* @param aPoint - Coordinate for hit testing.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return The draw object if found. Otherwise NULL.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
2024-04-06 14:14:44 +01:00
|
|
|
SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint );
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-10-06 13:52:43 +00:00
|
|
|
/**
|
|
|
|
* Locate a draw object (overlaid)
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aUnit - Unit number of draw item.
|
2024-01-26 16:16:13 +00:00
|
|
|
* @param aBodyStyle - Body style of draw item.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aType - Draw object type, set to 0 to search for any type.
|
|
|
|
* @param aPoint - Coordinate for hit testing.
|
|
|
|
* @param aTransform = the transform matrix
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return The draw object if found. Otherwise NULL.
|
2009-10-06 13:52:43 +00:00
|
|
|
*/
|
2024-04-06 14:14:44 +01:00
|
|
|
SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint,
|
2019-05-31 13:15:25 +01:00
|
|
|
const TRANSFORM& aTransform );
|
2009-10-06 13:52:43 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
|
|
|
* Return a reference to the draw item list.
|
|
|
|
*
|
2017-09-17 10:26:06 +02:00
|
|
|
* @return LIB_ITEMS_CONTAINER& - Reference to the draw item object container.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2019-11-06 14:15:42 -05:00
|
|
|
LIB_ITEMS_CONTAINER& GetDrawItems() { return m_drawings; }
|
2020-12-20 19:44:13 +01:00
|
|
|
const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; }
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2023-09-05 14:01:27 -07:00
|
|
|
/**
|
|
|
|
* This function finds the filled draw items that are covering up smaller draw items
|
|
|
|
* and replaces their body fill color with the background fill color.
|
|
|
|
*/
|
|
|
|
void FixupDrawItems();
|
|
|
|
|
2022-08-20 10:27:35 +01:00
|
|
|
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
2022-08-21 20:54:07 +01:00
|
|
|
const std::vector<KICAD_T>& aScanTypes ) override;
|
2019-05-06 03:32:01 +01:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
2021-06-10 14:51:46 -04:00
|
|
|
* Set the units per symbol count.
|
2009-10-05 17:52:41 +00:00
|
|
|
*
|
|
|
|
* If the count is greater than the current count, then the all of the
|
2021-06-10 14:51:46 -04:00
|
|
|
* current draw items are duplicated for each additional symbol. If the
|
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 15:28:54 -05:00
|
|
|
* count is less than the current count, all draw objects for units
|
2021-06-10 14:51:46 -04:00
|
|
|
* greater that count are removed from the symbol.
|
2009-10-05 17:52:41 +00:00
|
|
|
*
|
2020-02-28 09:03:09 -05:00
|
|
|
* @param aCount - Number of units per package.
|
2025-02-06 09:47:00 -05:00
|
|
|
* @param aDuplicateDrawItems Create duplicate draw items of unit 1 for each additional unit.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2020-02-28 09:03:09 -05:00
|
|
|
void SetUnitCount( int aCount, bool aDuplicateDrawItems = true );
|
2019-11-06 14:15:42 -05:00
|
|
|
int GetUnitCount() const override;
|
|
|
|
|
2022-09-14 22:11:37 +00:00
|
|
|
/**
|
|
|
|
* Return true if the given unit \a aUnit has a display name defined
|
|
|
|
*/
|
2025-07-23 14:33:29 +01:00
|
|
|
bool HasUnitDisplayName( int aUnit ) const;
|
|
|
|
|
|
|
|
wxString GetUnitName( int aUnit ) const override
|
|
|
|
{
|
|
|
|
return GetUnitDisplayName( aUnit, true );
|
|
|
|
}
|
2022-09-14 22:11:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the user-defined display name for \a aUnit for symbols with units.
|
|
|
|
*/
|
2025-07-23 14:33:29 +01:00
|
|
|
wxString GetUnitDisplayName( int aUnit, bool aLabel ) const override;
|
|
|
|
|
|
|
|
wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const override;
|
2022-09-14 22:11:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy all unit display names into the given map \a aTarget
|
|
|
|
*/
|
|
|
|
void CopyUnitDisplayNames( std::map<int, wxString>& aTarget ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the user-defined display name for \a aUnit to \a aName for symbols with units.
|
|
|
|
*/
|
|
|
|
void SetUnitDisplayName( int aUnit, const wxString& aName );
|
|
|
|
|
2025-03-18 20:35:11 -04:00
|
|
|
bool GetDuplicatePinNumbersAreJumpers() const { return m_duplicatePinNumbersAreJumpers; }
|
|
|
|
void SetDuplicatePinNumbersAreJumpers( bool aEnabled ) { m_duplicatePinNumbersAreJumpers = aEnabled; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Each jumper pin group is a set of pin numbers that should be treated as internally connected.
|
|
|
|
* @return The list of jumper pin groups in this symbols
|
|
|
|
*/
|
|
|
|
std::vector<std::set<wxString>>& JumperPinGroups() { return m_jumperPinGroups; }
|
|
|
|
const std::vector<std::set<wxString>>& JumperPinGroups() const { return m_jumperPinGroups; }
|
|
|
|
|
|
|
|
/// Retrieves the jumper group containing the specified pin number, if one exists
|
|
|
|
std::optional<const std::set<wxString>> GetJumperPinGroup( const wxString& aPinNumber ) const;
|
|
|
|
|
2010-11-12 09:17:10 -06:00
|
|
|
/**
|
2021-06-10 14:51:46 -04:00
|
|
|
* @return true if the symbol has multiple units per symbol.
|
|
|
|
* When true, the reference has a sub reference to identify symbol.
|
2010-04-24 13:27:38 +02:00
|
|
|
*/
|
2024-04-02 18:28:17 +01:00
|
|
|
bool IsMulti() const override { return m_unitCount > 1; }
|
2010-04-24 13:27:38 +02:00
|
|
|
|
2025-07-23 14:33:29 +01:00
|
|
|
static wxString LetterSubReference( int aUnit, wxChar aInitialLetter );
|
2010-04-24 13:27:38 +02:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
2021-06-10 14:51:46 -04:00
|
|
|
* Set or clear the alternate body style (DeMorgan) for the symbol.
|
2009-10-05 17:52:41 +00:00
|
|
|
*
|
2024-01-26 16:16:13 +00:00
|
|
|
* If the symbol already has an alternate body style set and aHasAlternate is false, all
|
|
|
|
* of the existing draw items for the alternate body style are remove. If the alternate
|
|
|
|
* body style is not set and aHasAlternate is true, than the base draw items are duplicated
|
|
|
|
* and added to the symbol.
|
2009-10-05 17:52:41 +00:00
|
|
|
*
|
2024-01-26 16:16:13 +00:00
|
|
|
* @param aHasAlternate - Set or clear the symbol alternate body style.
|
2020-02-28 09:03:09 -05:00
|
|
|
* @param aDuplicatePins - Duplicate all pins from original body style if true.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2024-01-26 16:16:13 +00:00
|
|
|
void SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePins = true );
|
2010-06-24 14:31:43 -04:00
|
|
|
|
2019-11-06 14:15:42 -05:00
|
|
|
/**
|
|
|
|
* Comparison test that can be used for operators.
|
|
|
|
*
|
|
|
|
* @param aRhs is the right hand side symbol used for comparison.
|
|
|
|
*
|
|
|
|
* @return -1 if this symbol is less than \a aRhs
|
|
|
|
* 1 if this symbol is greater than \a aRhs
|
|
|
|
* 0 if this symbol is the same as \a aRhs
|
|
|
|
*/
|
2023-03-09 11:25:32 +00:00
|
|
|
int Compare( const LIB_SYMBOL& aRhs, int aCompareFlags = 0,
|
|
|
|
REPORTER* aReporter = nullptr ) const;
|
2019-11-06 14:15:42 -05:00
|
|
|
|
2021-06-10 14:51:46 -04:00
|
|
|
const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol );
|
2019-12-26 08:00:59 -05:00
|
|
|
|
2019-11-06 14:15:42 -05:00
|
|
|
/**
|
|
|
|
* Return a flattened symbol inheritance to the caller.
|
|
|
|
*
|
|
|
|
* If the symbol does not inherit from another symbol, a copy of the symbol is returned.
|
|
|
|
*
|
|
|
|
* @return a flattened symbol on the heap
|
|
|
|
*/
|
2021-06-10 14:51:46 -04:00
|
|
|
std::unique_ptr< LIB_SYMBOL > Flatten() const;
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2020-02-13 08:39:52 -05:00
|
|
|
/**
|
2024-04-06 14:14:44 +01:00
|
|
|
* Return a list of SCH_ITEM objects separated by unit and convert number.
|
2020-02-13 08:39:52 -05:00
|
|
|
*
|
2024-04-12 22:00:41 +01:00
|
|
|
* @note This does not include SCH_FIELD objects since they are not associated with
|
2020-02-13 08:39:52 -05:00
|
|
|
* unit and/or convert numbers.
|
|
|
|
*/
|
2021-11-02 18:32:39 +00:00
|
|
|
std::vector<struct LIB_SYMBOL_UNIT> GetUnitDrawItems();
|
2020-02-13 08:39:52 -05:00
|
|
|
|
|
|
|
/**
|
2024-01-26 16:16:13 +00:00
|
|
|
* Return a list of item pointers for \a aUnit and \a aBodyStyle for this symbol.
|
2020-02-13 08:39:52 -05:00
|
|
|
*
|
2024-04-12 22:00:41 +01:00
|
|
|
* @note #SCH_FIELD objects are not included.
|
2020-02-13 08:39:52 -05:00
|
|
|
*
|
|
|
|
* @param aUnit is the unit number of the item, -1 includes all units.
|
2025-02-06 09:47:00 -05:00
|
|
|
* @param aBodyStyle is the alternate body style of the item, -1 includes all body styles.
|
2020-02-13 08:39:52 -05:00
|
|
|
*
|
|
|
|
* @return a list of unit items.
|
|
|
|
*/
|
2024-04-06 14:14:44 +01:00
|
|
|
std::vector<SCH_ITEM*> GetUnitDrawItems( int aUnit, int aBodyStyle );
|
2020-02-13 08:39:52 -05:00
|
|
|
|
2023-09-14 14:39:42 -07:00
|
|
|
/**
|
|
|
|
* Return a measure of similarity between this symbol and \a aSymbol.
|
|
|
|
* @param aSymbol is the symbol to compare to.
|
|
|
|
*
|
|
|
|
* @return a measure of similarity from 1.0 (identical) to 0.0 (no similarity).
|
|
|
|
*/
|
2024-04-02 18:28:17 +01:00
|
|
|
double Similarity( const SCH_ITEM& aSymbol ) const override;
|
2011-12-14 11:25:42 -06:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 19:06:49 +02:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
2011-12-14 11:25:42 -06:00
|
|
|
#endif
|
2020-12-14 13:47:32 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// We create a different set parent function for this class, so we hide the inherited one.
|
|
|
|
using EDA_ITEM::SetParent;
|
|
|
|
|
2024-06-10 20:14:40 -04:00
|
|
|
/**
|
|
|
|
* The library symbol specific sort order is as follows:
|
|
|
|
*
|
|
|
|
* - The result of #SCH_ITEM::compare()
|
|
|
|
*/
|
|
|
|
int compare( const SCH_ITEM& aOther,
|
|
|
|
int aCompareFlags = SCH_ITEM::COMPARE_FLAGS::EQUALITY ) const override;
|
|
|
|
|
2020-12-14 13:47:32 +00:00
|
|
|
void deleteAllFields();
|
|
|
|
|
|
|
|
private:
|
2021-06-15 08:31:28 -04:00
|
|
|
LIB_SYMBOL_SPTR m_me;
|
|
|
|
LIB_SYMBOL_REF m_parent; ///< Use for inherited symbols.
|
2020-12-14 13:47:32 +00:00
|
|
|
LIB_ID m_libId;
|
2023-01-19 22:45:46 -05:00
|
|
|
LIB_ID m_sourceLibId; ///< For database library symbols; the original symbol
|
2020-12-14 13:47:32 +00:00
|
|
|
timestamp_t m_lastModDate;
|
|
|
|
|
|
|
|
int m_unitCount; ///< Number of units (parts) per package.
|
2021-06-10 14:51:46 -04:00
|
|
|
bool m_unitsLocked; ///< True if symbol has multiple units and changing one
|
2020-12-14 13:47:32 +00:00
|
|
|
///< unit does not automatically change another unit.
|
|
|
|
|
2021-06-10 14:51:46 -04:00
|
|
|
LIBRENTRYOPTIONS m_options; ///< Special symbol features such as POWER or NORMAL.)
|
2020-12-14 13:47:32 +00:00
|
|
|
|
|
|
|
LIB_ITEMS_CONTAINER m_drawings;
|
|
|
|
|
2021-06-15 08:31:28 -04:00
|
|
|
SYMBOL_LIB* m_library;
|
2020-12-14 13:47:32 +00:00
|
|
|
wxString m_name;
|
|
|
|
wxString m_keyWords; ///< Search keywords
|
|
|
|
wxArrayString m_fpFilters; ///< List of suitable footprint names for the
|
2021-06-10 14:51:46 -04:00
|
|
|
///< symbol (wild card names accepted).
|
2020-12-14 13:47:32 +00:00
|
|
|
|
2025-03-18 20:35:11 -04:00
|
|
|
/// A list of jumper pin groups, each of which is a set of pin numbers that should be jumpered
|
|
|
|
/// together (treated as internally connected for the purposes of connectivity)
|
|
|
|
std::vector<std::set<wxString> > m_jumperPinGroups;
|
|
|
|
|
|
|
|
/// Flag that this symbol should automatically treat sets of two or more pins with the same
|
|
|
|
/// number as jumpered pin groups
|
|
|
|
bool m_duplicatePinNumbersAreJumpers;
|
|
|
|
|
2022-09-14 22:11:37 +00:00
|
|
|
std::map<int, wxString> m_unitDisplayNames;
|
2011-12-14 11:25:42 -06:00
|
|
|
};
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
#endif // CLASS_LIBENTRY_H
|