2011-10-11 20:23:56 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-28 16:56:09 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2014 Dick Hollenbeck, dick@softplc.com
|
2017-11-18 13:10:32 +00:00
|
|
|
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
2021-03-25 21:13:01 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-11 20:23:56 +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
|
|
|
|
*/
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#ifndef COMPONENT_CLASS_H
|
|
|
|
#define COMPONENT_CLASS_H
|
|
|
|
|
2020-10-14 01:06:53 +00:00
|
|
|
#include <eda_item.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <core/typeinfo.h>
|
|
|
|
#include <layers_id_colors_and_visibility.h>
|
2017-01-31 01:31:19 +00:00
|
|
|
#include <lib_id.h>
|
2020-10-25 04:49:02 +00:00
|
|
|
#include <widgets/msgpanel.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
2015-06-08 00:07:42 +00:00
|
|
|
#include <vector>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <wx/arrstr.h>
|
|
|
|
#include <wx/chartype.h>
|
|
|
|
#include <wx/fdrepdlg.h>
|
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
#include <wx/string.h>
|
|
|
|
|
|
|
|
#include <sch_field.h>
|
|
|
|
#include <sch_item.h>
|
2019-04-03 09:14:36 +00:00
|
|
|
#include <sch_pin.h>
|
2020-04-26 20:53:29 +00:00
|
|
|
#include <sch_sheet_path.h> // COMPONENT_INSTANCE_REFERENCE
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <symbol_lib_table.h>
|
|
|
|
#include <transform.h>
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2020-11-07 14:31:50 +00:00
|
|
|
struct PICKED_SYMBOL;
|
2016-08-11 12:41:38 +00:00
|
|
|
class SCH_SCREEN;
|
2011-04-27 19:44:32 +00:00
|
|
|
class LIB_ITEM;
|
2010-11-10 15:30:12 +00:00
|
|
|
class LIB_PIN;
|
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
|
|
|
class LIB_PART;
|
2013-09-25 19:09:57 +00:00
|
|
|
class NETLIST_OBJECT_LIST;
|
2017-09-01 20:42:20 +00:00
|
|
|
class PART_LIB;
|
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
|
|
|
class PART_LIBS;
|
2019-05-10 19:22:26 +00:00
|
|
|
class EE_COLLECTOR;
|
2016-07-06 09:22:56 +00:00
|
|
|
class SCH_SCREEN;
|
2017-03-09 23:33:39 +00:00
|
|
|
class SYMBOL_LIB_TABLE;
|
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-10-06 05:44:29 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/// A container for several SCH_FIELD items
|
2016-06-29 15:09:55 +00:00
|
|
|
typedef std::vector<SCH_FIELD> SCH_FIELDS;
|
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
|
|
|
|
2016-06-29 15:09:55 +00:00
|
|
|
typedef std::weak_ptr<LIB_PART> PART_REF;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
extern std::string toUTFTildaText( const wxString& txt );
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
/**
|
2020-04-16 16:43:50 +00:00
|
|
|
* Schematic symbol object.
|
2007-09-13 11:55:46 +00:00
|
|
|
*/
|
2008-03-20 01:50:21 +00:00
|
|
|
class SCH_COMPONENT : public SCH_ITEM
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-11-03 14:13:15 +00:00
|
|
|
SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ), SCH_ITEM* aParent = NULL );
|
2008-10-19 18:31:09 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Create schematic symbol from library symbol object.
|
2009-10-16 17:18:23 +00:00
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @param aPart is the library part to create schematic symbol from.
|
|
|
|
* @param aLibId is the #LIB_ID of alias to create.
|
|
|
|
* @param aSheet is the schematic sheet the symbol is place into.
|
|
|
|
* @param unit is unit for symbols that have multiple parts per package.
|
|
|
|
* @param convert is the alternate body style for the schematic symbols.
|
|
|
|
* @param pos is the position of the symbol.
|
|
|
|
* @param setNewItemFlag is used to set the symbol #IS_NEW and #IS_MOVED flags.
|
2009-10-16 17:18:23 +00:00
|
|
|
*/
|
2021-02-02 19:20:40 +00:00
|
|
|
SCH_COMPONENT( const LIB_PART& aPart, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet,
|
2009-10-16 17:18:23 +00:00
|
|
|
int unit = 0, int convert = 0,
|
2020-12-20 18:50:45 +00:00
|
|
|
const wxPoint& pos = wxPoint( 0, 0 ) );
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2021-02-02 19:20:40 +00:00
|
|
|
SCH_COMPONENT( const LIB_PART& aPart, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel,
|
2020-08-31 23:01:20 +00:00
|
|
|
const wxPoint& pos = wxPoint( 0, 0 ) );
|
2008-10-19 18:31:09 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Clone \a aSymbol into a new schematic symbol object.
|
2017-06-27 15:22:25 +00:00
|
|
|
*
|
|
|
|
* All fields are copied as is except for the linked list management pointers
|
|
|
|
* which are set to NULL, and the SCH_FIELD's m_Parent pointers which are set
|
|
|
|
* to the new object.
|
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @param aSymbol is the schematic symbol to clone.
|
2008-10-19 18:31:09 +00:00
|
|
|
*/
|
2021-03-25 21:13:01 +00:00
|
|
|
SCH_COMPONENT( const SCH_COMPONENT& aSymbol );
|
2008-10-19 18:31:09 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
~SCH_COMPONENT() { }
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2018-12-24 11:17:35 +00:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
return aItem && SCH_COMPONENT_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
wxString GetClass() const override
|
2007-09-13 11:28:58 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
return wxT( "SCH_COMPONENT" );
|
2007-09-13 11:28:58 +00:00
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2020-11-15 17:03:27 +00:00
|
|
|
const std::vector<SYMBOL_INSTANCE_REFERENCE>& GetInstanceReferences()
|
2020-02-22 21:39:59 +00:00
|
|
|
{
|
|
|
|
return m_instanceReferences;
|
|
|
|
}
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
/**
|
|
|
|
* Return true for items which are moved with the anchor point at mouse cursor
|
2017-06-27 15:22:25 +00:00
|
|
|
* and false for items moved with no reference to anchor.
|
|
|
|
*
|
|
|
|
* Usually return true for small items (labels, junctions) and false for items which can
|
2021-03-25 21:13:01 +00:00
|
|
|
* be large (hierarchical sheets, symbols).
|
2017-06-27 15:22:25 +00:00
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @note We used to try and be smart about this and return false for symbols in case
|
|
|
|
* they are big. However, this annoyed some users and we now have a preference which
|
|
|
|
* controls warping on move in general, so this was switched to true for symbols.
|
2019-06-11 14:17:24 +00:00
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @return true for a symbol.
|
2015-02-28 16:56:09 +00:00
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
bool IsMovableFromAnchorPoint() const override { return true; }
|
2015-02-28 16:56:09 +00:00
|
|
|
|
2020-04-16 16:43:50 +00:00
|
|
|
void SetLibId( const LIB_ID& aName );
|
2017-03-09 23:33:39 +00:00
|
|
|
|
2020-12-20 18:50:45 +00:00
|
|
|
const LIB_ID& GetLibId() const { return m_lib_id; }
|
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-04-16 16:43:50 +00:00
|
|
|
/**
|
|
|
|
* The name of the symbol in the schematic library symbol list.
|
|
|
|
*
|
|
|
|
* @note See #SCH_SCREEN::m_libSymbols
|
|
|
|
*
|
|
|
|
* The name of the schematic symbol list entry can vary from the item name in the #LIB_ID
|
|
|
|
* object because the library symbol may have changed so a new name has to be generated
|
|
|
|
* but the original symbol library link has to be preserved in order to update it from
|
|
|
|
* the library at some point in the future. If this name is empty, then the library item
|
|
|
|
* name from #LIB_ID is used.
|
|
|
|
*/
|
|
|
|
void SetSchSymbolLibraryName( const wxString& aName ) { m_schLibSymbolName = aName; }
|
|
|
|
wxString GetSchSymbolLibraryName() const;
|
|
|
|
bool UseLibIdLookup() const { return m_schLibSymbolName.IsEmpty(); }
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
std::unique_ptr< LIB_PART >& GetPartRef() { return m_part; }
|
2020-12-20 18:44:13 +00:00
|
|
|
const std::unique_ptr< LIB_PART >& GetPartRef() const { return m_part; }
|
2017-03-04 00:04:43 +00:00
|
|
|
|
2020-04-16 16:43:50 +00:00
|
|
|
/**
|
|
|
|
* Set this schematic symbol library symbol reference to \a aLibSymbol
|
|
|
|
*
|
|
|
|
* The schematic symbol object owns \a aLibSymbol and the pin list will be updated
|
2020-05-05 14:55:54 +00:00
|
|
|
* accordingly. The #LIB_PART object can be null to clear the library symbol link
|
|
|
|
* as well as the pin map. If the #LIB_PART object is not null, it must be a root
|
|
|
|
* symbol. Otherwise an assertion will be raised in debug builds and the library
|
|
|
|
* symbol will be cleared. The new file format will no longer require a cache
|
|
|
|
* library so all library symbols must be valid.
|
2020-04-16 16:43:50 +00:00
|
|
|
*
|
|
|
|
* @note This is the only way to publicly set the library symbol for a schematic
|
|
|
|
* symbol except for the ctors that take a LIB_PART reference. All previous
|
|
|
|
* public resolvers have been deprecated.
|
2020-05-05 14:55:54 +00:00
|
|
|
*
|
|
|
|
* @param aLibSymbol is the library symbol to associate with this schematic symbol.
|
2020-04-16 16:43:50 +00:00
|
|
|
*/
|
|
|
|
void SetLibSymbol( LIB_PART* aLibSymbol );
|
|
|
|
|
2017-04-02 12:09:01 +00:00
|
|
|
/**
|
|
|
|
* Return information about the aliased parts
|
|
|
|
*/
|
2018-11-22 21:30:36 +00:00
|
|
|
wxString GetDescription() const;
|
2017-06-27 15:22:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the documentation text for the given part alias
|
|
|
|
*/
|
2018-11-22 21:30:36 +00:00
|
|
|
wxString GetDatasheet() const;
|
2017-04-02 12:09:01 +00:00
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
int GetUnit() const { return m_unit; }
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
/**
|
2020-01-17 02:33:16 +00:00
|
|
|
* Updates the cache of SCH_PIN objects for each pin
|
2019-03-11 21:32:05 +00:00
|
|
|
*/
|
2020-01-17 02:33:16 +00:00
|
|
|
void UpdatePins();
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2013-07-05 17:48:01 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Change the unit number to \a aUnit
|
|
|
|
*
|
|
|
|
* This has meaning only for symbols made up of multiple units per package.
|
|
|
|
*
|
|
|
|
* @note This also set the modified flag bit
|
|
|
|
*
|
|
|
|
* @param aUnit is the new unit to select.
|
2013-07-05 17:48:01 +00:00
|
|
|
*/
|
2010-12-14 15:56:30 +00:00
|
|
|
void SetUnit( int aUnit );
|
|
|
|
|
2013-07-05 17:48:01 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Change the unit number to \a aUnit without setting any internal flags.
|
|
|
|
* This has meaning only for symbols made up of multiple units per package.
|
|
|
|
*
|
|
|
|
* @note This also set the modified flag bit
|
|
|
|
*
|
|
|
|
* @param aUnit is the new unit to select.
|
2013-07-05 17:48:01 +00:00
|
|
|
*/
|
|
|
|
void UpdateUnit( int aUnit );
|
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
int GetConvert() const { return m_convert; }
|
|
|
|
|
|
|
|
void SetConvert( int aConvert );
|
|
|
|
|
|
|
|
wxString GetPrefix() const { return m_prefix; }
|
|
|
|
|
2016-07-06 09:22:56 +00:00
|
|
|
void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; }
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
TRANSFORM& GetTransform() { return m_transform; }
|
|
|
|
const TRANSFORM& GetTransform() const { return m_transform; }
|
2010-12-14 21:39:31 +00:00
|
|
|
|
|
|
|
void SetTransform( const TRANSFORM& aTransform );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Return the number of units per package of the symbol.
|
2011-06-17 13:24:22 +00:00
|
|
|
*
|
2017-06-27 15:22:25 +00:00
|
|
|
* @return the number of units per package or zero if the library entry cannot be found.
|
2011-06-17 13:24:22 +00:00
|
|
|
*/
|
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
|
|
|
int GetUnitCount() const;
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2010-12-14 21:39:31 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Compute the new transform matrix based on \a aOrientation for the symbol which is
|
2010-12-14 21:39:31 +00:00
|
|
|
* applied to the current transform.
|
2017-06-27 15:22:25 +00:00
|
|
|
*
|
|
|
|
* @param aOrientation is the orientation to apply to the transform.
|
2010-12-14 21:39:31 +00:00
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
void SetOrientation( int aOrientation );
|
2010-01-13 21:15:54 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Get the display symbol orientation.
|
|
|
|
*
|
|
|
|
* Because there are different ways to have a given orientation/mirror,
|
|
|
|
* the orientation/mirror is not necessary what the user does. For example:
|
2021-02-16 20:45:25 +00:00
|
|
|
* a mirrorV then a mirrorH returns no mirror but a rotate. This function finds
|
2017-06-27 15:22:25 +00:00
|
|
|
* a rotation and a mirror value #CMP_MIRROR_X because this is the first mirror
|
|
|
|
* option tested. This can differs from the orientation made by an user. A
|
|
|
|
* #CMP_MIRROR_Y is returned as a #CMP_MIRROR_X with an orientation 180 because
|
|
|
|
* they are equivalent.
|
|
|
|
*
|
|
|
|
* @sa COMPONENT_ORIENTATION_T
|
|
|
|
*
|
|
|
|
* @return the orientation and mirror of the symbol.
|
2009-04-09 11:34:41 +00:00
|
|
|
*/
|
2011-03-25 19:16:05 +00:00
|
|
|
int GetOrientation();
|
2009-04-09 11:34:41 +00:00
|
|
|
|
2020-05-27 22:28:36 +00:00
|
|
|
/**
|
|
|
|
* Return the list of system text vars & fields for this symbol.
|
|
|
|
*/
|
|
|
|
void GetContextualTextVars( wxArrayString* aVars ) const;
|
|
|
|
|
2020-04-06 13:06:57 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Resolve any references to system tokens supported by the symbol.
|
|
|
|
*
|
2020-04-06 13:06:57 +00:00
|
|
|
* @param aDepth a counter to limit recursion and circular references.
|
|
|
|
*/
|
|
|
|
bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
|
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Clear exiting symbol annotation.
|
2017-06-27 15:22:25 +00:00
|
|
|
*
|
|
|
|
* For example, IC23 would be changed to IC? and unit number would be reset.
|
|
|
|
*
|
|
|
|
* @param aSheetPath is the hierarchical path of the symbol to clear or remove all
|
|
|
|
* annotations for this symbol if NULL.
|
2008-04-21 06:34:56 +00:00
|
|
|
*/
|
2020-09-06 10:26:39 +00:00
|
|
|
void ClearAnnotation( const SCH_SHEET_PATH* aSheetPath );
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2018-09-03 10:11:39 +00:00
|
|
|
/**
|
2020-02-22 21:39:59 +00:00
|
|
|
* Add an instance to the alternate references list (m_instanceReferences), if this entry
|
|
|
|
* does not already exist.
|
2021-03-25 21:13:01 +00:00
|
|
|
*
|
|
|
|
* Do nothing if already exists. In symbol lists shared by more than one sheet path, an
|
|
|
|
* entry for each sheet path must exist to manage references.
|
|
|
|
*
|
|
|
|
* @param aSheetPath is the candidate sheet path of the sheet containing the symbol not the
|
|
|
|
* full symbol sheet path.
|
2018-09-04 16:46:03 +00:00
|
|
|
* @return false if the alternate reference was existing, true if added.
|
2018-09-03 10:11:39 +00:00
|
|
|
*/
|
2020-02-22 21:39:59 +00:00
|
|
|
bool AddSheetPathReferenceEntryIfMissing( const KIID_PATH& aSheetPath );
|
2018-09-03 10:11:39 +00:00
|
|
|
|
2020-04-26 20:53:29 +00:00
|
|
|
/**
|
|
|
|
* Replace \a aOldSheetPath with \a aNewSheetPath in the instance list.
|
|
|
|
*
|
|
|
|
* @param aOldSheetPath is a #KIID_PATH object of an existing path in the instance list.
|
|
|
|
* @param aNewSheetPath is a #KIID_PATH object of the path to replace the existing path.
|
|
|
|
*
|
|
|
|
* @return true if \a aOldSheetPath was found and replaced or false if \a aOldSheetPath was
|
|
|
|
* not found in the instance list.
|
|
|
|
*/
|
|
|
|
bool ReplaceInstanceSheetPath( const KIID_PATH& aOldSheetPath, const KIID_PATH& aNewSheetPath );
|
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2020-08-13 06:50:41 +00:00
|
|
|
const EDA_RECT GetBoundingBox( bool aIncludeInvisibleText ) const;
|
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Return a bounding box for the symbol body but not the fields.
|
2015-12-13 16:56:47 +00:00
|
|
|
*/
|
|
|
|
EDA_RECT GetBodyBoundingBox() const;
|
|
|
|
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
//-----<Fields>-----------------------------------------------------------
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Return a mandatory field in this symbol.
|
2021-02-28 13:28:23 +00:00
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @note If you need to fetch a user field, use GetFieldById.
|
2017-06-27 15:22:25 +00:00
|
|
|
*
|
2021-02-28 13:28:23 +00:00
|
|
|
* @param aFieldType is one of the mandatory field types (REFERENCE_FIELD, VALUE_FIELD, etc.).
|
|
|
|
* @return is the field at \a aFieldType or NULL if the field does not exist.
|
2008-10-06 05:44:29 +00:00
|
|
|
*/
|
2021-02-28 13:28:23 +00:00
|
|
|
SCH_FIELD* GetField( MANDATORY_FIELD_T aFieldType );
|
|
|
|
const SCH_FIELD* GetField( MANDATORY_FIELD_T aFieldNdx ) const;
|
2020-05-08 19:22:59 +00:00
|
|
|
|
2021-02-28 13:28:23 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Return a field in this symbol.
|
2021-02-28 13:28:23 +00:00
|
|
|
*
|
|
|
|
* @param aFieldId is the id of the field requested. Note that this id ONLY SOMETIMES equates
|
2021-03-25 21:13:01 +00:00
|
|
|
* to the field's position in the vector.
|
2021-02-28 13:28:23 +00:00
|
|
|
* @return is the field at \a aFieldType or NULL if the field does not exist.
|
|
|
|
*/
|
|
|
|
SCH_FIELD* GetFieldById( int aFieldId );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2017-04-02 12:09:01 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Search for a field named \a aFieldName and returns text associated with this field.
|
|
|
|
*
|
2017-06-21 07:32:19 +00:00
|
|
|
* @param aFieldName is the name of the field
|
2017-04-02 12:09:01 +00:00
|
|
|
*/
|
2018-05-29 21:46:13 +00:00
|
|
|
wxString GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME* aFrame ) const;
|
2017-04-02 12:09:01 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Populate a std::vector with SCH_FIELDs.
|
2017-06-27 15:22:25 +00:00
|
|
|
*
|
|
|
|
* @param aVector is the vector to populate.
|
|
|
|
* @param aVisibleOnly is used to add only the fields that are visible and contain text.
|
2015-12-13 16:56:47 +00:00
|
|
|
*/
|
|
|
|
void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly );
|
|
|
|
|
2020-02-05 04:48:33 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Return a vector of fields from the symbol
|
2020-02-05 04:48:33 +00:00
|
|
|
*/
|
2020-11-16 13:15:54 +00:00
|
|
|
std::vector<SCH_FIELD>& GetFields() { return m_fields; }
|
2021-02-28 13:28:23 +00:00
|
|
|
const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
|
2020-02-05 04:48:33 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Add a field to the symbol.
|
|
|
|
*
|
|
|
|
* @param aField is the field to add to this symbol.
|
|
|
|
*
|
|
|
|
* @return the newly inserted field.
|
2010-06-17 16:30:10 +00:00
|
|
|
*/
|
|
|
|
SCH_FIELD* AddField( const SCH_FIELD& aField );
|
|
|
|
|
2018-07-31 21:59:43 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Remove a user field from the symbol.
|
2018-07-31 21:59:43 +00:00
|
|
|
* @param aFieldName is the user fieldName to remove. Attempts to remove a mandatory
|
|
|
|
* field or a non-existant field are silently ignored.
|
|
|
|
*/
|
|
|
|
void RemoveField( const wxString& aFieldName );
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Search for a #SCH_FIELD with \a aFieldName
|
|
|
|
*
|
|
|
|
* @param aFieldName is the name of the field to find.
|
|
|
|
* @param aIncludeDefaultFields searches the library symbol default fields if true.
|
|
|
|
*
|
|
|
|
* @return the field if found or NULL if the field was not found.
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2017-05-22 14:05:36 +00:00
|
|
|
SCH_FIELD* FindField( const wxString& aFieldName, bool aIncludeDefaultFields = true );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2017-06-27 15:22:25 +00:00
|
|
|
/**
|
|
|
|
* Set multiple schematic fields.
|
|
|
|
*
|
|
|
|
* @param aFields are the fields to set in this symbol.
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void SetFields( const SCH_FIELDS& aFields )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2020-11-16 13:15:54 +00:00
|
|
|
m_fields = aFields; // vector copying, length is changed possibly
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2017-06-27 15:22:25 +00:00
|
|
|
|
2017-08-25 13:27:06 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Restore fields to the original library values.
|
|
|
|
*
|
2017-08-25 13:27:06 +00:00
|
|
|
* @param aResetStyle selects whether fields should reset the position and text attribute.
|
|
|
|
* @param aResetRef selects whether the reference field should be restored.
|
|
|
|
*/
|
|
|
|
void UpdateFields( bool aResetStyle, bool aResetRef = false );
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Return the number of fields in this symbol.
|
2008-10-06 05:44:29 +00:00
|
|
|
*/
|
2020-11-16 13:15:54 +00:00
|
|
|
int GetFieldCount() const { return (int)m_fields.size(); }
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Automatically orient all the fields in the symbol.
|
2017-06-27 15:22:25 +00:00
|
|
|
*
|
|
|
|
* @param aScreen is the SCH_SCREEN associated with the current instance of the
|
2021-03-25 21:13:01 +00:00
|
|
|
* symbol. This can be NULL when aManual is false.
|
2017-06-27 15:22:25 +00:00
|
|
|
* @param aManual should be true if the autoplace was manually initiated (e.g. by a hotkey
|
2021-03-25 21:13:01 +00:00
|
|
|
* or a menu item). Some more 'intelligent' routines will be used that would be
|
|
|
|
* annoying if done automatically during moves.
|
2015-12-13 16:56:47 +00:00
|
|
|
*/
|
2020-03-06 20:02:58 +00:00
|
|
|
void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override;
|
2015-12-13 16:56:47 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
|
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
|
|
|
|
//-----</Fields>----------------------------------------------------------
|
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Find a symbol pin by number.
|
|
|
|
*
|
|
|
|
* @param number is the number of the pin to find.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return Pin object if found, otherwise NULL.
|
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
SCH_PIN* GetPin( const wxString& number ) const;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
/**
|
2019-04-03 09:14:36 +00:00
|
|
|
* Populate a vector with all the pins from the library object.
|
2017-06-27 15:22:25 +00:00
|
|
|
*
|
|
|
|
* @param aPinsList is the list to populate with all of the pins.
|
2015-12-13 16:56:47 +00:00
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
void GetLibPins( std::vector<LIB_PIN*>& aPinsList ) const;
|
2020-08-21 15:54:24 +00:00
|
|
|
|
|
|
|
SCH_PIN* GetPin( LIB_PIN* aLibPin );
|
2015-12-13 16:56:47 +00:00
|
|
|
|
2020-01-17 02:33:16 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Retrieve a list of the SCH_PINs for the given sheet path.
|
|
|
|
*
|
|
|
|
* Since a symbol can have a different unit on a different instance of a sheet,
|
2020-01-17 02:33:16 +00:00
|
|
|
* this list returns the subset of pins that exist on a given sheet.
|
2021-03-25 21:13:01 +00:00
|
|
|
*
|
2020-01-17 02:33:16 +00:00
|
|
|
* @return a vector of pointers (non-owning) to SCH_PINs
|
|
|
|
*/
|
2020-08-21 15:54:24 +00:00
|
|
|
std::vector<SCH_PIN*> GetPins( const SCH_SHEET_PATH* aSheet = nullptr ) const;
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<SCH_PIN>>& GetRawPins() { return m_pins; }
|
2018-08-30 19:44:10 +00:00
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Print a symbol.
|
2017-06-30 07:50:49 +00:00
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @param aDC is the device context (can be null).
|
|
|
|
* @param aOffset is the drawing offset (usually wxPoint(0,0), but can be different when
|
|
|
|
* moving an object)
|
2019-04-04 22:49:49 +00:00
|
|
|
*/
|
2020-12-20 18:18:54 +00:00
|
|
|
void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void SwapData( SCH_ITEM* aItem ) override;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2011-05-31 16:29:14 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Test for an acceptable reference string.
|
2017-06-27 15:22:25 +00:00
|
|
|
*
|
|
|
|
* An acceptable reference string must support unannotation i.e starts by letter
|
|
|
|
*
|
|
|
|
* @param aReferenceString is the reference string to validate
|
|
|
|
* @return true if reference string is valid.
|
2011-05-31 16:29:14 +00:00
|
|
|
*/
|
2011-12-14 17:25:42 +00:00
|
|
|
static bool IsReferenceStringValid( const wxString& aReferenceString );
|
2011-05-31 16:29:14 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Return the reference for the given sheet path.
|
|
|
|
*
|
|
|
|
* @return the reference for the sheet.
|
2008-11-24 06:53:43 +00:00
|
|
|
*/
|
2020-08-29 13:41:47 +00:00
|
|
|
const wxString GetRef( const SCH_SHEET_PATH* aSheet, bool aIncludeUnit = false ) const;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2011-05-31 16:29:14 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Set the reference for the given sheet path for this symbol.
|
|
|
|
*
|
|
|
|
* @param aSheet is the hierarchical path of the reference.
|
|
|
|
* @param aReference is the new reference for the symbol.
|
2011-05-31 16:29:14 +00:00
|
|
|
*/
|
2017-06-27 15:22:25 +00:00
|
|
|
void SetRef( const SCH_SHEET_PATH* aSheet, const wxString& aReference );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2019-05-19 15:40:14 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Check if the symbol has a valid annotation (reference) for the given sheet path.
|
|
|
|
*
|
|
|
|
* @param aSheet is the sheet path to test.
|
|
|
|
* @return true if the symbol exists on that sheet and has a valid reference.
|
2019-05-19 15:40:14 +00:00
|
|
|
*/
|
|
|
|
bool IsAnnotated( const SCH_SHEET_PATH* aSheet );
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
/**
|
2017-06-27 15:22:25 +00:00
|
|
|
* Add a full hierarchical reference to this symbol.
|
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @param aPath is the hierarchical path (/<sheet timestamp>/<symbol
|
|
|
|
* timestamp> like /05678E50/A23EF560).
|
|
|
|
* @param aRef is the local reference like C45, R56.
|
2020-02-22 21:39:59 +00:00
|
|
|
* @param aUnit is the unit selection used for symbols with multiple units per package.
|
2021-03-25 21:13:01 +00:00
|
|
|
* @param aValue is the value used for this instance.
|
2020-08-29 13:41:47 +00:00
|
|
|
* @param aFootprint is the footprint used for this instance (which might have different
|
2021-03-25 21:13:01 +00:00
|
|
|
* hole spacing or other board-specific changes from other instances).
|
2008-04-16 08:40:31 +00:00
|
|
|
*/
|
2020-02-22 21:39:59 +00:00
|
|
|
void AddHierarchicalReference( const KIID_PATH& aPath,
|
|
|
|
const wxString& aRef,
|
2020-08-29 13:41:47 +00:00
|
|
|
int aUnit,
|
|
|
|
const wxString& aValue = wxEmptyString,
|
|
|
|
const wxString& aFootprint = wxEmptyString );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
/// Return the instance-specific unit selection for the given sheet path.
|
2020-01-17 02:33:16 +00:00
|
|
|
int GetUnitSelection( const SCH_SHEET_PATH* aSheet ) const;
|
2021-01-21 20:00:09 +00:00
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
/// Set the selected unit of this symbol on one sheet.
|
2020-01-17 02:33:16 +00:00
|
|
|
void SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
/// Set the selected unit of this symbol for all sheets.
|
2021-01-21 20:00:09 +00:00
|
|
|
void SetUnitSelection( int aUnitSelection );
|
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
/// Return the instance-specific value for the given sheet path.
|
2020-11-17 21:36:17 +00:00
|
|
|
const wxString GetValue( const SCH_SHEET_PATH* sheet, bool aResolve ) const;
|
2020-08-29 13:41:47 +00:00
|
|
|
void SetValue( const SCH_SHEET_PATH* sheet, const wxString& aValue );
|
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
/// Set the value for all instances (the default GUI behavior).
|
2020-09-06 12:05:07 +00:00
|
|
|
void SetValue( const wxString& aValue )
|
|
|
|
{
|
|
|
|
SetValue( nullptr, aValue );
|
|
|
|
}
|
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
/// Return the instance-specific footprint assignment for the given sheet path.
|
2020-11-17 21:36:17 +00:00
|
|
|
const wxString GetFootprint( const SCH_SHEET_PATH* sheet, bool aResolve ) const;
|
2020-08-29 13:41:47 +00:00
|
|
|
void SetFootprint( const SCH_SHEET_PATH* sheet, const wxString& aFootprint );
|
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
/// Set the value for all instances (the default GUI behavior).
|
2020-09-06 12:05:07 +00:00
|
|
|
void SetFootprint( const wxString& aFootprint )
|
|
|
|
{
|
|
|
|
SetFootprint( nullptr, aFootprint );
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
// Geometric transforms (used in block operations):
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
void Move( const wxPoint& aMoveVector ) override
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2010-12-14 21:39:31 +00:00
|
|
|
if( aMoveVector == wxPoint( 0, 0 ) )
|
|
|
|
return;
|
|
|
|
|
2020-11-16 13:15:54 +00:00
|
|
|
m_pos += aMoveVector;
|
2010-12-14 21:39:31 +00:00
|
|
|
|
2020-11-16 13:15:54 +00:00
|
|
|
for( SCH_FIELD& field : m_fields )
|
2020-03-06 20:02:58 +00:00
|
|
|
field.Move( aMoveVector );
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2010-12-14 21:39:31 +00:00
|
|
|
SetModified();
|
|
|
|
}
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
void MirrorHorizontally( int aCenter ) override;
|
|
|
|
void MirrorVertically( int aCenter ) override;
|
2021-03-19 19:55:59 +00:00
|
|
|
void Rotate( wxPoint aCenter ) override;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2020-12-20 18:27:51 +00:00
|
|
|
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2015-07-20 19:49:32 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Test if the symbol's dangling state has changed for all pins.
|
2017-06-27 15:22:25 +00:00
|
|
|
*
|
|
|
|
* As a side effect, actually update the dangling status for all pins.
|
|
|
|
*
|
|
|
|
* @note This does not test for short circuits.
|
|
|
|
*
|
2017-06-30 07:50:49 +00:00
|
|
|
* @param aItemList is list of all #DANGLING_END_ITEM items to be tested.
|
2015-07-20 19:49:32 +00:00
|
|
|
* @return true if any pin's state has changed.
|
|
|
|
*/
|
2020-01-17 02:33:16 +00:00
|
|
|
bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
|
|
|
|
const SCH_SHEET_PATH* aPath = nullptr ) override;
|
2015-06-08 00:07:42 +00:00
|
|
|
|
2018-04-12 16:10:22 +00:00
|
|
|
wxPoint GetPinPhysicalPosition( const LIB_PIN* Pin ) const;
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2020-10-04 22:39:21 +00:00
|
|
|
bool IsConnectable() const override { return true; }
|
2011-01-07 19:24:24 +00:00
|
|
|
|
2017-12-19 17:45:56 +00:00
|
|
|
bool CanConnect( const SCH_ITEM* aItem ) const override
|
|
|
|
{
|
|
|
|
return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
|
|
|
|
( aItem->Type() == SCH_NO_CONNECT_T ) ||
|
2019-01-11 01:28:29 +00:00
|
|
|
( aItem->Type() == SCH_JUNCTION_T ) ||
|
2021-02-27 06:56:28 +00:00
|
|
|
( aItem->Type() == SCH_COMPONENT_T ) ||
|
|
|
|
( aItem->Type() == SCH_LABEL_T ) ||
|
|
|
|
( aItem->Type() == SCH_HIER_LABEL_T ) ||
|
|
|
|
( aItem->Type() == SCH_GLOBAL_LABEL_T );
|
2017-12-19 17:45:56 +00:00
|
|
|
}
|
|
|
|
|
2013-09-27 17:58:58 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* @return true if the symbol is in netlist.
|
2013-09-27 17:58:58 +00:00
|
|
|
*/
|
|
|
|
bool IsInNetlist() const;
|
|
|
|
|
2020-09-08 13:27:13 +00:00
|
|
|
std::vector<wxPoint> GetConnectionPoints() const override;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Return the symbol library item at \a aPosition that is part of this symbol.
|
2010-12-13 15:59:00 +00:00
|
|
|
*
|
2021-03-25 21:13:01 +00:00
|
|
|
* @param aPosition is the schematic position of the symbol library object.
|
2017-06-27 15:22:25 +00:00
|
|
|
* @param aType is the type of symbol library object to find or any if set to TYPE_NOT_INIT.
|
|
|
|
* @return is the symbol library object if found otherwise NULL.
|
2010-12-13 15:59:00 +00:00
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* GetDrawItem( const wxPoint& aPosition, KICAD_T aType = TYPE_NOT_INIT );
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
bool operator <( const SCH_ITEM& aItem ) const override;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2021-03-25 21:13:01 +00:00
|
|
|
bool operator==( const SCH_COMPONENT& aSymbol) const;
|
|
|
|
bool operator!=( const SCH_COMPONENT& aSymbol) const;
|
2012-02-22 21:37:34 +00:00
|
|
|
|
2019-04-21 23:45:34 +00:00
|
|
|
SCH_COMPONENT& operator=( const SCH_ITEM& aItem );
|
2012-01-09 20:26:55 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
bool IsReplaceable() const override { return true; }
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2020-11-16 13:15:54 +00:00
|
|
|
wxPoint GetPosition() const override { return m_pos; }
|
|
|
|
void SetPosition( const wxPoint& aPosition ) override { Move( aPosition - m_pos ); }
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
void Plot( PLOTTER* aPlotter ) const override;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 17:06:49 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
2008-02-26 19:19:54 +00:00
|
|
|
#endif
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2019-03-08 00:16:59 +00:00
|
|
|
void ClearBrightenedPins();
|
|
|
|
|
|
|
|
bool HasBrightenedPins();
|
|
|
|
|
2020-06-03 12:30:57 +00:00
|
|
|
bool GetIncludeInBom() const { return m_inBom; }
|
|
|
|
void SetIncludeInBom( bool aIncludeInBom ) { m_inBom = aIncludeInBom; }
|
|
|
|
|
2020-06-09 16:50:05 +00:00
|
|
|
bool GetIncludeOnBoard() const { return m_onBoard; }
|
|
|
|
void SetIncludeOnBoard( bool aIncludeOnBoard ) { m_onBoard = aIncludeOnBoard; }
|
|
|
|
|
2021-02-17 17:03:55 +00:00
|
|
|
bool IsPointClickableAnchor( const wxPoint& aPos ) const override;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
private:
|
2016-09-24 18:53:15 +00:00
|
|
|
bool doIsConnected( const wxPoint& aPosition ) const override;
|
2021-03-25 21:13:01 +00:00
|
|
|
|
|
|
|
void Init( const wxPoint& pos = wxPoint( 0, 0 ) );
|
|
|
|
|
|
|
|
wxPoint m_pos;
|
|
|
|
LIB_ID m_lib_id; ///< Name and library the symbol was loaded from, i.e. 74xx:74LS00.
|
|
|
|
int m_unit; ///< The unit for multiple part per package symbols.
|
|
|
|
int m_convert; ///< The alternate body style for symbols that have more than
|
|
|
|
///< one body style defined. Primarily used for symbols that
|
|
|
|
///< have a De Morgan conversion.
|
|
|
|
wxString m_prefix; ///< C, R, U, Q etc - the first character which typically indicates
|
|
|
|
///< what the symbol is. Determined, upon placement, from the
|
|
|
|
///< library symbol. Created upon file load, by the first
|
|
|
|
///< non-digits in the reference fields.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The name used to look up a symbol in the symbol library embedded in a schematic.
|
|
|
|
*
|
|
|
|
* By default this is the same as #LIB_ID::GetLibItemName(). However, schematics allow for
|
|
|
|
* multiple variants of the same library symbol. Set this member in order to preserve the
|
|
|
|
* link to the original symbol library. If empty, #LIB_ID::GetLibItemName() should be used.
|
|
|
|
*/
|
|
|
|
wxString m_schLibSymbolName;
|
|
|
|
|
|
|
|
TRANSFORM m_transform; ///< The rotation/mirror transformation matrix.
|
|
|
|
SCH_FIELDS m_fields; ///< Variable length list of fields.
|
|
|
|
|
|
|
|
std::unique_ptr< LIB_PART > m_part; // a flattened copy of the LIB_PART from
|
|
|
|
// the PROJECT's libraries.
|
|
|
|
std::vector<std::unique_ptr<SCH_PIN>> m_pins; // a SCH_PIN for every LIB_PIN (all units)
|
|
|
|
std::unordered_map<LIB_PIN*, unsigned> m_pinMap; // library pin pointer to SCH_PIN's index
|
|
|
|
|
|
|
|
bool m_isInNetlist; ///< True if the symbol should appear in the netlist
|
|
|
|
bool m_inBom; ///< True to include in bill of materials export.
|
|
|
|
bool m_onBoard; ///< True to include in netlist when updating board.
|
|
|
|
|
|
|
|
// Defines the hierarchical path and reference of the symbol. This allows support
|
|
|
|
// for multiple references to a single sub-sheet.
|
|
|
|
std::vector<SYMBOL_INSTANCE_REFERENCE> m_instanceReferences;
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* COMPONENT_CLASS_H */
|