2011-10-31 20:49:48 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-06 15:34:11 +00:00
|
|
|
* Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-09-21 12:58:08 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2021-02-10 00:10:58 +00:00
|
|
|
* Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors.
|
2011-10-31 20:49:48 +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
|
|
|
|
*/
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
#ifndef CLASS_LIBENTRY_H
|
|
|
|
#define CLASS_LIBENTRY_H
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
2018-07-27 20:47:51 +00:00
|
|
|
#include <lib_tree_item.h>
|
2019-08-15 07:09:52 +00:00
|
|
|
#include <lib_item.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <lib_field.h>
|
2015-06-08 00:07:42 +00:00
|
|
|
#include <vector>
|
2017-09-17 12:04:38 +00:00
|
|
|
#include <multivector.h>
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2017-02-22 16:54:01 +00:00
|
|
|
class EDA_RECT;
|
2011-10-31 20:49:48 +00:00
|
|
|
class LINE_READER;
|
2011-11-01 15:06:26 +00:00
|
|
|
class OUTPUTFORMATTER;
|
2021-06-15 12:31:28 +00:00
|
|
|
class SYMBOL_LIB;
|
2021-06-10 18:51:46 +00:00
|
|
|
class LIB_SYMBOL;
|
2010-10-22 12:11:52 +00:00
|
|
|
class LIB_FIELD;
|
2021-06-10 18:51:46 +00:00
|
|
|
class TEST_LIB_SYMBOL_FIXTURE;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2021-06-15 12:31:28 +00: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
|
2021-07-18 23:08:54 +00:00
|
|
|
typedef MULTIVECTOR<LIB_ITEM, LIB_SHAPE_T, LIB_FIELD_T> LIB_ITEMS_CONTAINER;
|
2017-09-17 12:04:38 +00:00
|
|
|
typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS;
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2010-02-17 13:22:25 +00:00
|
|
|
/* values for member .m_options */
|
2021-02-10 00:10:58 +00:00
|
|
|
enum LIBRENTRYOPTIONS
|
2009-09-02 18:12:45 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
ENTRY_NORMAL, // Libentry is a standard symbol (real or alias)
|
2008-12-31 09:27:19 +00:00
|
|
|
ENTRY_POWER // Libentry is a power symbol
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
extern bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
struct LIB_SYMBOL_OPTIONS
|
2017-02-19 18:40:26 +00:00
|
|
|
{
|
2021-05-27 18:44:06 +00:00
|
|
|
TRANSFORM transform; // Coordinate adjustment settings
|
2021-12-31 14:07:24 +00:00
|
|
|
bool force_draw_pin_text; // Whether or not to force the drawing of pin names and numbers
|
2021-05-27 18:44:06 +00:00
|
|
|
bool draw_visible_fields; // Whether to draw "visible" fields
|
|
|
|
bool draw_hidden_fields; // Whether to draw "hidden" fields
|
|
|
|
bool show_elec_type; // Whether to show the pin electrical type
|
|
|
|
bool show_connect_point; // Whether to show the pin connect point marker (small circle)
|
2021-06-09 19:32:58 +00:00
|
|
|
// useful in dialog pin properties
|
2017-02-19 18:40:26 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL_OPTIONS()
|
2017-02-19 18:40:26 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
transform = DefaultTransform;
|
2021-12-31 14:07:24 +00:00
|
|
|
force_draw_pin_text = false;
|
2020-04-14 12:25:00 +00:00
|
|
|
draw_visible_fields = true;
|
|
|
|
draw_hidden_fields = true;
|
|
|
|
show_elec_type = false;
|
2021-05-27 18:44:06 +00:00
|
|
|
show_connect_point = false;
|
2017-02-19 18:40:26 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-11-02 18:32:39 +00:00
|
|
|
struct LIB_SYMBOL_UNIT
|
2020-02-13 13:39:52 +00:00
|
|
|
{
|
|
|
|
int m_unit; ///< The unit number.
|
|
|
|
int m_convert; ///< The alternate body style of the unit.
|
|
|
|
std::vector<LIB_ITEM*> m_items; ///< The items unique to this unit and alternate body style.
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Define a library symbol object.
|
2009-08-19 19:34:03 +00:00
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* A library symbol object is typically saved and loaded in a symbol library file (.lib).
|
2017-12-01 16:49:19 +00:00
|
|
|
* Library symbols are different from schematic symbols.
|
2009-08-19 19:34:03 +00:00
|
|
|
*/
|
2021-06-10 18:51:46 +00:00
|
|
|
class LIB_SYMBOL : public EDA_ITEM, public LIB_TREE_ITEM
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2010-09-09 17:37:25 +00:00
|
|
|
public:
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent = nullptr,
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB* aLibrary = nullptr );
|
2019-11-06 19:15:42 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary = nullptr );
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2021-06-10 18:51:46 +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 20:28:54 +00:00
|
|
|
|
2020-12-14 13:47:32 +00:00
|
|
|
///< http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL_SPTR SharedPtr() const { return m_me; }
|
2019-11-06 19:15:42 +00:00
|
|
|
|
2020-11-23 20:34:57 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00: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 18:51:46 +00:00
|
|
|
virtual LIB_SYMBOL* Duplicate() const
|
2020-11-23 20:34:57 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00: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();
|
|
|
|
|
|
|
|
for( LIB_ITEM& item : dupe->m_drawings )
|
|
|
|
const_cast<KIID&>( item.m_Uuid ) = KIID();
|
|
|
|
|
|
|
|
return dupe;
|
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
void SetParent( LIB_SYMBOL* aParent = nullptr );
|
2021-06-15 12:31:28 +00: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
|
|
|
|
2022-01-07 17:42:43 +00:00
|
|
|
void ClearCaches();
|
|
|
|
|
2016-09-25 17:06:49 +00: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 20:28:54 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00: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 20:28:54 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2010-10-22 12:11:52 +00:00
|
|
|
virtual void SetName( const wxString& aName );
|
2019-11-08 20:50:04 +00:00
|
|
|
wxString GetName() const override { return m_name; }
|
2010-10-25 15:43:42 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
LIB_ID GetLibId() const override { return m_libId; }
|
2018-01-09 12:26:31 +00:00
|
|
|
void SetLibId( const LIB_ID& aLibId ) { m_libId = aLibId; }
|
2016-11-20 18:33:07 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
wxString GetLibNickname() const override { return GetLibraryName(); }
|
2016-08-18 23:23:10 +00:00
|
|
|
|
2020-12-14 13:47:32 +00:00
|
|
|
void SetDescription( const wxString& aDescription ) { m_description = aDescription; }
|
|
|
|
|
|
|
|
wxString GetDescription() override
|
2019-11-06 19:15:42 +00:00
|
|
|
{
|
2020-12-14 13:47:32 +00:00
|
|
|
if( m_description.IsEmpty() && IsAlias() )
|
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
|
2020-12-14 13:47:32 +00:00
|
|
|
return parent->GetDescription();
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_description;
|
2019-11-06 19:15:42 +00:00
|
|
|
}
|
2010-09-09 17:37:25 +00:00
|
|
|
|
2020-12-14 13:47:32 +00:00
|
|
|
void SetKeyWords( const wxString& aKeyWords ) { m_keyWords = aKeyWords; }
|
2018-08-13 17:00:08 +00:00
|
|
|
|
2020-12-14 13:47:32 +00:00
|
|
|
wxString GetKeyWords() const
|
2019-11-06 19:15:42 +00:00
|
|
|
{
|
2020-12-14 13:47:32 +00:00
|
|
|
if( m_keyWords.IsEmpty() && IsAlias() )
|
|
|
|
{
|
2021-06-15 12:31:28 +00: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
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
wxString GetSearchText() override;
|
2018-08-13 17:00:08 +00:00
|
|
|
|
2022-06-05 17:58:27 +00:00
|
|
|
wxString GetFootprint() override
|
|
|
|
{
|
|
|
|
return GetFootprintField().GetText();
|
|
|
|
}
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
/**
|
2019-11-06 19:15:42 +00:00
|
|
|
* For symbols derived from other symbols, IsRoot() indicates no derivation.
|
2010-02-17 13:22:25 +00:00
|
|
|
*/
|
2019-11-06 19:15:42 +00:00
|
|
|
bool IsRoot() const override { return m_parent.use_count() == 0; }
|
2020-01-12 00:40:38 +00:00
|
|
|
bool IsAlias() const { return !m_parent.expired() && m_parent.use_count() > 0; }
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
const wxString GetLibraryName() const;
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB* GetLib() const { return m_library; }
|
|
|
|
void SetLib( SYMBOL_LIB* aLibrary ) { m_library = aLibrary; }
|
2010-12-02 21:41:56 +00: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 19:15:42 +00:00
|
|
|
|
2020-12-14 13:47:32 +00:00
|
|
|
wxArrayString GetFPFilters() const
|
2019-11-06 19:15:42 +00:00
|
|
|
{
|
2020-12-14 13:47:32 +00:00
|
|
|
if( m_fpFilters.IsEmpty() && IsAlias() )
|
|
|
|
{
|
2021-06-15 12:31:28 +00: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 19:15:42 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
2011-02-27 19:54:01 +00:00
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Get the bounding box for the symbol.
|
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* @return the symbol bounding box ( in user coordinates )
|
2011-02-27 19:54:01 +00:00
|
|
|
* @param aUnit = unit selection = 0, or 1..n
|
|
|
|
* @param aConvert = 0, 1 or 2
|
|
|
|
* If aUnit == 0, unit is not used
|
|
|
|
* if aConvert == 0 Convert is non used
|
|
|
|
* Invisible fields are not taken in account
|
|
|
|
**/
|
2016-09-30 05:31:48 +00:00
|
|
|
const EDA_RECT GetUnitBoundingBox( int aUnit, int aConvert ) const;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-02-27 19:54:01 +00:00
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Get the symbol bounding box excluding fields.
|
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* @return the symbol bounding box ( in user coordinates ) without fields
|
2011-02-27 19:54:01 +00:00
|
|
|
* @param aUnit = unit selection = 0, or 1..n
|
|
|
|
* @param aConvert = 0, 1 or 2
|
|
|
|
* If aUnit == 0, unit is not used
|
|
|
|
* if aConvert == 0 Convert is non used
|
|
|
|
* Fields are not taken in account
|
|
|
|
**/
|
2022-03-06 16:12:49 +00:00
|
|
|
const EDA_RECT GetBodyBoundingBox( int aUnit, int aConvert, bool aIncludePins,
|
|
|
|
bool aIncludePrivateItems ) const;
|
2011-02-27 19:54:01 +00:00
|
|
|
|
2016-09-30 05:31:48 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override
|
|
|
|
{
|
|
|
|
return GetUnitBoundingBox( 0, 0 );
|
|
|
|
}
|
|
|
|
|
2021-02-10 00:10:58 +00:00
|
|
|
bool IsPower() const;
|
|
|
|
bool IsNormal() const;
|
2010-02-16 17:49:17 +00:00
|
|
|
|
2021-02-10 00:10:58 +00:00
|
|
|
void SetPower();
|
|
|
|
void SetNormal();
|
2010-02-16 17:49:17 +00:00
|
|
|
|
2018-01-24 14:09:08 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Set interchangeable the property for symbol units.
|
2018-01-24 14:09:08 +00:00
|
|
|
* @param aLockUnits when true then units are set as not interchangeable.
|
|
|
|
*/
|
2010-06-24 18:31:43 +00:00
|
|
|
void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
|
2018-01-24 14:09:08 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Check whether symbol units are interchangeable.
|
2018-01-24 14:09:08 +00:00
|
|
|
* @return False when interchangeable, true otherwise.
|
|
|
|
*/
|
2016-04-02 12:25:44 +00:00
|
|
|
bool UnitsLocked() const { return m_unitsLocked; }
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
2017-12-01 16:49:19 +00:00
|
|
|
* Overwrite all the existing fields in this symbol with fields supplied
|
|
|
|
* in \a aFieldsList.
|
2009-08-19 19:34:03 +00:00
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* The only known caller of this function is the library symbol field editor, and it
|
2017-12-01 16:49:19 +00:00
|
|
|
* establishes needed behavior.
|
|
|
|
*
|
|
|
|
* @param aFieldsList is a set of fields to import, removing all previous fields.
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2010-06-17 16:30:10 +00:00
|
|
|
void SetFields( const std::vector <LIB_FIELD>& aFieldsList );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-10-21 20:02:25 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Return a list of fields within this symbol.
|
2009-10-21 20:02:25 +00:00
|
|
|
*
|
2010-06-17 16:30:10 +00:00
|
|
|
* @param aList - List to add fields to
|
2009-10-21 20:02:25 +00:00
|
|
|
*/
|
2020-12-15 15:06:19 +00:00
|
|
|
void GetFields( std::vector<LIB_FIELD*>& aList );
|
|
|
|
void GetFields( std::vector<LIB_FIELD>& aList );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a field. Takes ownership of the pointer.
|
|
|
|
*/
|
|
|
|
void AddField( LIB_FIELD* aField );
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Find a field within this symbol matching \a aFieldName and returns it
|
2020-02-16 12:51:44 +00:00
|
|
|
* or NULL if not found.
|
2010-06-17 16:30:10 +00:00
|
|
|
*/
|
2010-10-04 18:54:14 +00:00
|
|
|
LIB_FIELD* FindField( const wxString& aFieldName );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2020-06-02 19:27:22 +00:00
|
|
|
const LIB_FIELD* FindField( const wxString& aFieldName ) const;
|
2020-06-01 17:45:46 +00:00
|
|
|
|
2009-10-21 20:02:25 +00:00
|
|
|
/**
|
|
|
|
* Return pointer to the requested field.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aId - Id of field to return.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return The field if found, otherwise NULL.
|
2009-10-21 20:02:25 +00:00
|
|
|
*/
|
2021-02-28 13:28:23 +00:00
|
|
|
LIB_FIELD* GetFieldById( int aId ) const;
|
2009-10-21 20:02:25 +00:00
|
|
|
|
|
|
|
/** Return reference to the value field. */
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_FIELD& GetValueField();
|
2009-10-21 20:02:25 +00:00
|
|
|
|
|
|
|
/** Return reference to the reference designator field. */
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_FIELD& GetReferenceField();
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2017-07-09 13:08:33 +00:00
|
|
|
/** Return reference to the footprint field */
|
|
|
|
LIB_FIELD& GetFootprintField();
|
|
|
|
|
2020-06-01 13:13:32 +00:00
|
|
|
/** Return reference to the datasheet field. */
|
|
|
|
LIB_FIELD& GetDatasheetField();
|
|
|
|
|
2021-12-12 22:01:13 +00:00
|
|
|
/**
|
|
|
|
* Order optional field indices.
|
|
|
|
*
|
|
|
|
* It's possible when calling #LIB_SYMBOL::Flatten that there can be gaps and/or duplicate
|
|
|
|
* optional field indices. This method correctly orders the indices so there are no gaps
|
|
|
|
* and/or duplicate indices.
|
|
|
|
*/
|
|
|
|
int UpdateFieldOrdinals();
|
|
|
|
|
|
|
|
int GetNextAvailableFieldId() const;
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Print symbol.
|
2009-09-04 18:57:37 +00:00
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* @param aOffset - Position of symbol.
|
|
|
|
* @param aMulti - unit if multiple units per symbol.
|
2021-06-14 18:00:08 +00:00
|
|
|
* @param aConvert - Symbol conversion (DeMorgan) if available.
|
2017-02-19 18:40:26 +00:00
|
|
|
* @param aOpts - Drawing options
|
2009-12-15 21:11:05 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, int aMulti, int aConvert,
|
|
|
|
const LIB_SYMBOL_OPTIONS& aOpts );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Plot lib symbol to plotter.
|
2013-05-18 09:38:23 +00:00
|
|
|
* Lib Fields not are plotted here, because this plot function
|
|
|
|
* is used to plot schematic items, which have they own fields
|
2009-10-05 17:52:41 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aPlotter - Plotter object to plot to.
|
2021-06-14 18:00:08 +00:00
|
|
|
* @param aUnit - Symbol symbol to plot.
|
|
|
|
* @param aConvert - Symbol alternate body style to plot.
|
2022-02-10 19:49:25 +00:00
|
|
|
* @param aBackground - A poor-man's Z-order.
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aOffset - Distance to shift the plot coordinates.
|
2021-06-14 18:00:08 +00:00
|
|
|
* @param aTransform - Symbol plot transform matrix.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2022-02-10 19:49:25 +00:00
|
|
|
void Plot( PLOTTER* aPlotter, int aUnit, int aConvert, bool aBackground,
|
|
|
|
const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const;
|
2013-05-18 09:38:23 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Plot Lib Fields only of the symbol to plotter.
|
|
|
|
* is used to plot the full lib symbol, outside the schematic
|
2013-05-18 09:38:23 +00:00
|
|
|
*
|
|
|
|
* @param aPlotter - Plotter object to plot to.
|
2021-06-14 18:00:08 +00:00
|
|
|
* @param aUnit - Symbol to plot.
|
|
|
|
* @param aConvert - Symbol alternate body style to plot.
|
2022-02-10 19:49:25 +00:00
|
|
|
* @param aBackground - A poor-man's Z-order.
|
2013-05-18 09:38:23 +00:00
|
|
|
* @param aOffset - Distance to shift the plot coordinates.
|
2021-06-14 18:00:08 +00:00
|
|
|
* @param aTransform - Symbol plot transform matrix.
|
2013-05-18 09:38:23 +00:00
|
|
|
*/
|
2022-02-10 19:49:25 +00:00
|
|
|
void PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, bool aBackground,
|
|
|
|
const VECTOR2I& aOffset, const TRANSFORM& aTransform );
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
2021-03-04 22:59:24 +00: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 22:59:24 +00: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
|
|
|
*/
|
2021-03-04 22:59:24 +00:00
|
|
|
void AddDrawItem( LIB_ITEM* aItem, bool aSort = true );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/**
|
2010-06-24 18:31:43 +00: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
|
|
|
*/
|
2019-05-31 12:15:25 +00:00
|
|
|
void RemoveDrawItem( LIB_ITEM* aItem );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-09-29 18:38:21 +00:00
|
|
|
* Return the next draw object pointer.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aItem - Pointer to the current draw item. Setting item NULL
|
|
|
|
* with return the first item of type in the list.
|
|
|
|
* @param aType - type of searched item (filter).
|
|
|
|
* if TYPE_NOT_INIT search for all items types
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return - The next drawing object in the list if found, otherwise NULL.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
2021-07-16 20:13:26 +00:00
|
|
|
LIB_ITEM* GetNextDrawItem( const LIB_ITEM* aItem = nullptr, KICAD_T aType = TYPE_NOT_INIT );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2020-05-05 22:35:27 +00:00
|
|
|
size_t GetPinCount() const { return m_drawings.size( LIB_PIN_T ); }
|
|
|
|
|
2021-03-28 18:03:11 +00:00
|
|
|
size_t GetFieldCount() const { return m_drawings.size( LIB_FIELD_T ); }
|
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
/**
|
|
|
|
* Return the next pin object from the draw list.
|
|
|
|
*
|
|
|
|
* This is just a pin object specific version of GetNextDrawItem().
|
|
|
|
*
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aItem - Pointer to the previous pin item, or NULL to get the
|
|
|
|
* first pin in the draw object list.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return - The next pin object in the list if found, otherwise NULL.
|
2009-10-14 19:43:31 +00:00
|
|
|
*/
|
2021-07-16 20:13:26 +00:00
|
|
|
LIB_PIN* GetNextPin( LIB_PIN* aItem = nullptr )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
return (LIB_PIN*) GetNextDrawItem( (LIB_ITEM*) aItem, LIB_PIN_T );
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
/**
|
|
|
|
* Return a list of pin object pointers from the draw item list.
|
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* Note pin objects are owned by the draw list of the symbol.
|
2009-10-14 19:43:31 +00:00
|
|
|
* Deleting any of the objects will leave list in a unstable state
|
|
|
|
* and will likely segfault when the list is destroyed.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aList - Pin list to place pin object pointers into.
|
|
|
|
* @param aUnit - Unit number of pin to add to list. Set to 0 to
|
2021-06-10 18:51:46 +00:00
|
|
|
* get pins from any symbol unit.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aConvert - Convert number of pin to add to list. Set to 0 to
|
2021-06-10 18:51:46 +00:00
|
|
|
* get pins from any convert of symbol.
|
2009-10-14 19:43:31 +00:00
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
void GetPins( LIB_PINS& aList, int aUnit = 0, int aConvert = 0 ) const;
|
2009-10-14 19:43:31 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2010-06-24 18:31:43 +00: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.
|
2021-06-10 18:51:46 +00:00
|
|
|
* @param aUnit - Unit of the symbol to find. Set to 0 if a specific
|
2009-12-15 21:11:05 +00:00
|
|
|
* unit number is not required.
|
|
|
|
* @param aConvert - Alternate body style filter (DeMorgan). Set to 0 if
|
|
|
|
* no alternate body style is required.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return The pin object if found. Otherwise NULL.
|
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
LIB_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aConvert = 0 ) const;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2015-04-25 22:26:51 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Return true if this symbol's pins do not match another symbol's pins. This
|
2015-04-25 22:26:51 +00:00
|
|
|
* is used to detect whether the project cache is out of sync with the
|
|
|
|
* system libs.
|
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* @param aOtherSymbol - The other library symbol to test
|
2015-04-25 22:26:51 +00: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 18:51:46 +00:00
|
|
|
bool PinsConflictWith( const LIB_SYMBOL& aOtherSymbol, bool aTestNums, bool aTestNames,
|
2021-03-06 09:27:41 +00:00
|
|
|
bool aTestType, bool aTestOrientation, bool aTestLength ) const;
|
2015-04-25 22:26:51 +00:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00: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
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetOffset( const VECTOR2I& aOffset );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove duplicate draw items from list.
|
|
|
|
*/
|
|
|
|
void RemoveDuplicateDrawItems();
|
|
|
|
|
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Test if symbol has more than one body conversion type (DeMorgan).
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* @return True if symbol has more than one conversion.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
|
|
|
bool HasConversion() const;
|
|
|
|
|
2022-05-14 22:33:43 +00: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 18:51:46 +00:00
|
|
|
* Clears the status flag all draw objects in this symbol.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
2019-05-11 10:06:28 +00:00
|
|
|
void ClearTempFlags();
|
|
|
|
void ClearEditFlags();
|
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.
|
|
|
|
* @param aConvert - Body style of draw item.
|
|
|
|
* @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
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
LIB_ITEM* LocateDrawItem( int aUnit, int aConvert, 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.
|
|
|
|
* @param aConvert - Body style of draw item.
|
|
|
|
* @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
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
LIB_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, const VECTOR2I& aPoint,
|
2019-05-31 12:15:25 +00: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 08:26:06 +00:00
|
|
|
* @return LIB_ITEMS_CONTAINER& - Reference to the draw item object container.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2019-11-06 19:15:42 +00:00
|
|
|
LIB_ITEMS_CONTAINER& GetDrawItems() { return m_drawings; }
|
2020-12-20 18:44:13 +00:00
|
|
|
const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; }
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2019-05-06 02:32:01 +00:00
|
|
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00: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 18:51:46 +00: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 20:28:54 +00:00
|
|
|
* count is less than the current count, all draw objects for units
|
2021-06-10 18:51:46 +00:00
|
|
|
* greater that count are removed from the symbol.
|
2009-10-05 17:52:41 +00:00
|
|
|
*
|
2020-02-28 14:03:09 +00:00
|
|
|
* @param aCount - Number of units per package.
|
|
|
|
* @param aDuplicateDrawItems Create duplicate draw items of unit 1 for each additionl unit.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2020-02-28 14:03:09 +00:00
|
|
|
void SetUnitCount( int aCount, bool aDuplicateDrawItems = true );
|
2019-11-06 19:15:42 +00:00
|
|
|
int GetUnitCount() const override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an identifier for \a aUnit for symbols with units.
|
|
|
|
*/
|
|
|
|
wxString GetUnitReference( int aUnit ) override;
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00: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 11:27:38 +00:00
|
|
|
*/
|
2014-05-04 17:08:36 +00:00
|
|
|
bool IsMulti() const { return m_unitCount > 1; }
|
2010-04-24 11:27:38 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* @return the sub reference for symbol having multiple units per symbol.
|
|
|
|
* The sub reference identify the symbol (or unit)
|
|
|
|
* @param aUnit = the symbol identifier ( 1 to max count)
|
2019-11-06 19:15:42 +00:00
|
|
|
* @param aAddSeparator = true (default) to prepend the sub ref
|
2013-05-19 19:35:49 +00:00
|
|
|
* by the separator symbol (if any)
|
2010-04-24 11:27:38 +00:00
|
|
|
* Note: this is a static function.
|
|
|
|
*/
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
static wxString SubReference( int aUnit, bool aAddSeparator = true );
|
2013-05-19 19:35:49 +00:00
|
|
|
|
|
|
|
// Accessors to sub ref parameters
|
|
|
|
static int GetSubpartIdSeparator() { return m_subpartIdSeparator; }
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2021-02-10 00:10:58 +00:00
|
|
|
/**
|
|
|
|
* Return a reference to m_subpartIdSeparator, only for read/save setting functions.
|
2013-07-19 18:27:22 +00:00
|
|
|
*/
|
|
|
|
static int* SubpartIdSeparatorPtr() { return &m_subpartIdSeparator; }
|
2013-05-19 19:35:49 +00:00
|
|
|
static int GetSubpartFirstId() { return m_subpartFirstId; }
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2021-02-10 00:10:58 +00:00
|
|
|
/**
|
|
|
|
* Return a reference to m_subpartFirstId, only for read/save setting functions.
|
2013-07-19 18:27:22 +00:00
|
|
|
*/
|
|
|
|
static int* SubpartFirstIdPtr() { return &m_subpartFirstId; }
|
|
|
|
|
2017-12-01 16:49:19 +00:00
|
|
|
/**
|
|
|
|
* Set the separator char between the subpart id and the reference
|
2013-07-19 18:27:22 +00:00
|
|
|
* 0 (no separator) or '.' , '-' and '_'
|
2021-06-10 18:51:46 +00:00
|
|
|
* and the ascii char value to calculate the subpart symbol id from the symbol number:
|
2013-07-19 18:27:22 +00:00
|
|
|
* 'A' or '1' only are allowed. (to print U1.A or U1.1)
|
|
|
|
* if this is a digit, a number is used as id symbol
|
|
|
|
* Note also if the subpart symbol is a digit, the separator cannot be null.
|
|
|
|
* @param aSep = the separator symbol (0 (no separator) or '.' , '-' and '_')
|
2021-06-10 18:51:46 +00:00
|
|
|
* @param aFirstId = the Id of the first symbol ('A' or '1')
|
2013-07-19 18:27:22 +00:00
|
|
|
*/
|
|
|
|
static void SetSubpartIdNotation( int aSep, int aFirstId );
|
2010-04-24 11:27:38 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
2021-06-10 18:51:46 +00:00
|
|
|
* Set or clear the alternate body style (DeMorgan) for the symbol.
|
2009-10-05 17:52:41 +00:00
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* If the symbol already has an alternate body style set and a
|
2009-10-05 17:52:41 +00:00
|
|
|
* asConvert if false, all of the existing draw items for the alternate
|
|
|
|
* body style are remove. If the alternate body style is not set and
|
|
|
|
* asConvert is true, than the base draw items are duplicated and
|
2021-06-10 18:51:46 +00:00
|
|
|
* added to the symbol.
|
2009-10-05 17:52:41 +00:00
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* @param aSetConvert - Set or clear the symbol alternate body style.
|
2020-02-28 14:03:09 +00:00
|
|
|
* @param aDuplicatePins - Duplicate all pins from original body style if true.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2020-02-28 14:03:09 +00:00
|
|
|
void SetConversion( bool aSetConvert, bool aDuplicatePins = true );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the offset in mils of the pin name text from the pin symbol.
|
|
|
|
*
|
|
|
|
* Set the offset to 0 to draw the pin name above the pin symbol.
|
|
|
|
*
|
|
|
|
* @param aOffset - The offset in mils.
|
|
|
|
*/
|
|
|
|
void SetPinNameOffset( int aOffset ) { m_pinNameOffset = aOffset; }
|
2021-03-06 09:27:41 +00:00
|
|
|
int GetPinNameOffset() const { return m_pinNameOffset; }
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set or clear the pin name visibility flag.
|
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* @param aShow - True to make the symbol pin names visible.
|
2010-06-24 18:31:43 +00:00
|
|
|
*/
|
|
|
|
void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
|
2021-03-06 09:27:41 +00:00
|
|
|
bool ShowPinNames() const { return m_showPinNames; }
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set or clear the pin number visibility flag.
|
|
|
|
*
|
2021-06-10 18:51:46 +00:00
|
|
|
* @param aShow - True to make the symbol pin numbers visible.
|
2010-06-24 18:31:43 +00:00
|
|
|
*/
|
|
|
|
void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
|
2021-03-06 09:27:41 +00:00
|
|
|
bool ShowPinNumbers() const { return m_showPinNumbers; }
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2020-09-09 13:03:37 +00:00
|
|
|
/**
|
|
|
|
* Set or clear the include in schematic bill of materials flag.
|
|
|
|
*
|
|
|
|
* @param aIncludeInBom true to include symbol in schematic bill of material
|
|
|
|
*/
|
|
|
|
void SetIncludeInBom( bool aIncludeInBom ) { m_includeInBom = aIncludeInBom; }
|
|
|
|
bool GetIncludeInBom() const { return m_includeInBom; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set or clear include in board netlist flag.
|
|
|
|
*
|
|
|
|
* @param aIncludeOnBoard true to include symbol in the board netlist
|
|
|
|
*/
|
|
|
|
void SetIncludeOnBoard( bool aIncludeOnBoard ) { m_includeOnBoard = aIncludeOnBoard; }
|
|
|
|
bool GetIncludeOnBoard() const { return m_includeOnBoard; }
|
|
|
|
|
2019-11-06 19:15:42 +00: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
|
|
|
|
*/
|
2022-03-03 12:20:30 +00:00
|
|
|
int Compare( const LIB_SYMBOL& aRhs, int aCompareFlags = 0 ) const;
|
2019-11-06 19:15:42 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
bool operator==( const LIB_SYMBOL* aSymbol ) const { return this == aSymbol; }
|
2021-12-12 22:01:13 +00:00
|
|
|
bool operator==( const LIB_SYMBOL& aSymbol ) const
|
|
|
|
{
|
|
|
|
return Compare( aSymbol, LIB_ITEM::COMPARE_FLAGS::EQUALITY ) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( const LIB_SYMBOL& aSymbol ) const
|
|
|
|
{
|
|
|
|
return Compare( aSymbol, LIB_ITEM::COMPARE_FLAGS::EQUALITY ) != 0;
|
|
|
|
}
|
2019-11-06 19:15:42 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol );
|
2019-12-26 13:00:59 +00:00
|
|
|
|
2019-11-06 19:15:42 +00: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 18:51:46 +00:00
|
|
|
std::unique_ptr< LIB_SYMBOL > Flatten() const;
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2020-02-13 13:39:52 +00:00
|
|
|
/**
|
|
|
|
* Return a list of LIB_ITEM objects separated by unit and convert number.
|
|
|
|
*
|
|
|
|
* @note This does not include LIB_FIELD objects since they are not associated with
|
|
|
|
* unit and/or convert numbers.
|
|
|
|
*/
|
2021-11-02 18:32:39 +00:00
|
|
|
std::vector<struct LIB_SYMBOL_UNIT> GetUnitDrawItems();
|
2020-02-13 13:39:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a list of unit numbers that are unique to this symbol.
|
|
|
|
*
|
|
|
|
* If the symbol is inherited (alias), the unique units of the parent symbol are returned.
|
|
|
|
* When comparing pins, the pin number is ignored.
|
|
|
|
*
|
|
|
|
* @return a list of unique unit numbers and their associated draw items.
|
|
|
|
*/
|
2021-11-02 18:32:39 +00:00
|
|
|
std::vector<struct LIB_SYMBOL_UNIT> GetUniqueUnits();
|
2020-02-13 13:39:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a list of item pointers for \a aUnit and \a aConvert for this symbol.
|
|
|
|
*
|
|
|
|
* @note #LIB_FIELD objects are not included.
|
|
|
|
*
|
|
|
|
* @param aUnit is the unit number of the item, -1 includes all units.
|
|
|
|
* @param aConvert is the alternate body styple of the item, -1 includes all body styles.
|
|
|
|
*
|
|
|
|
* @return a list of unit items.
|
|
|
|
*/
|
2021-11-02 18:32:39 +00:00
|
|
|
std::vector<LIB_ITEM*> GetUnitDrawItems( int aUnit, int aConvert );
|
2020-02-13 13:39:52 +00:00
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 17:06:49 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
2011-12-14 17:25:42 +00: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;
|
|
|
|
|
|
|
|
void deleteAllFields();
|
|
|
|
|
|
|
|
private:
|
2021-06-15 12:31:28 +00: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;
|
|
|
|
timestamp_t m_lastModDate;
|
|
|
|
|
|
|
|
int m_unitCount; ///< Number of units (parts) per package.
|
2021-06-10 18:51:46 +00: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.
|
|
|
|
|
|
|
|
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to
|
|
|
|
///< 0 to draw the pin name above the pin.
|
|
|
|
bool m_showPinNames;
|
|
|
|
bool m_showPinNumbers;
|
|
|
|
|
|
|
|
bool m_includeInBom;
|
|
|
|
bool m_includeOnBoard;
|
2021-06-10 18:51:46 +00: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 12:31:28 +00:00
|
|
|
SYMBOL_LIB* m_library;
|
2020-12-14 13:47:32 +00:00
|
|
|
wxString m_name;
|
|
|
|
wxString m_description;
|
|
|
|
wxString m_keyWords; ///< Search keywords
|
|
|
|
wxArrayString m_fpFilters; ///< List of suitable footprint names for the
|
2021-06-10 18:51:46 +00:00
|
|
|
///< symbol (wild card names accepted).
|
2020-12-14 13:47:32 +00:00
|
|
|
|
|
|
|
static int m_subpartIdSeparator; ///< the separator char between
|
|
|
|
///< the subpart id and the reference like U1A
|
|
|
|
///< ( m_subpartIdSeparator = 0 ) or U1.A or U1-A
|
|
|
|
static int m_subpartFirstId; ///< the ASCII char value to calculate the subpart
|
2021-06-10 18:51:46 +00:00
|
|
|
///< symbol id from the symbol number: only 'A', 'a'
|
2020-12-14 13:47:32 +00:00
|
|
|
///< or '1' can be used, other values have no sense.
|
2011-12-14 17:25:42 +00:00
|
|
|
};
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
#endif // CLASS_LIBENTRY_H
|