2011-10-11 16:23:56 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-28 17:56:09 +01:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2014 Dick Hollenbeck, dick@softplc.com
|
2017-11-18 08:10:32 -05:00
|
|
|
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-12-08 23:56:55 +00:00
|
|
|
* Copyright (C) 2022 CERN
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-11 16:23:56 -04:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2024-04-02 18:28:17 +01:00
|
|
|
#ifndef SCH_SYMBOL_H
|
|
|
|
#define SCH_SYMBOL_H
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2020-10-13 21:06:53 -04:00
|
|
|
#include <eda_item.h>
|
2019-06-25 16:39:58 -07:00
|
|
|
#include <core/typeinfo.h>
|
2021-07-29 10:47:43 +01:00
|
|
|
#include <layer_ids.h>
|
2017-01-30 20:31:19 -05:00
|
|
|
#include <lib_id.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2019-06-25 16:39:58 -07:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
2015-06-07 20:07:42 -04:00
|
|
|
#include <vector>
|
2019-06-25 16:39:58 -07:00
|
|
|
#include <wx/arrstr.h>
|
|
|
|
#include <wx/chartype.h>
|
|
|
|
#include <wx/string.h>
|
|
|
|
|
2024-01-18 16:11:33 +00:00
|
|
|
#include <schematic.h>
|
2024-04-02 18:28:17 +01:00
|
|
|
#include <symbol.h>
|
2019-06-25 16:39:58 -07:00
|
|
|
#include <sch_field.h>
|
2019-04-03 10:14:36 +01:00
|
|
|
#include <sch_pin.h>
|
2023-01-04 15:39:50 -05:00
|
|
|
#include <sch_sheet_path.h> // SCH_SYMBOL_INSTANCE
|
2019-06-25 16:39:58 -07:00
|
|
|
#include <transform.h>
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2020-11-07 14:31:50 +00:00
|
|
|
struct PICKED_SYMBOL;
|
2022-10-01 08:44:21 -04:00
|
|
|
class KIID_PATH;
|
2016-08-11 14:41:38 +02:00
|
|
|
class SCH_SCREEN;
|
2021-06-10 14:51:46 -04:00
|
|
|
class LIB_SYMBOL;
|
2024-04-27 22:57:24 +03:00
|
|
|
class MSG_PANEL_ITEM;
|
2021-06-15 08:31:28 -04:00
|
|
|
class SYMBOL_LIB;
|
|
|
|
class SYMBOL_LIBS;
|
2016-07-06 05:22:56 -04:00
|
|
|
class SCH_SCREEN;
|
2024-07-20 16:01:50 +01:00
|
|
|
class SCH_COMMIT;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 15:28:54 -05:00
|
|
|
|
2008-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 11:09:55 -04: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 15:28:54 -05:00
|
|
|
|
2021-06-10 14:51:46 -04:00
|
|
|
typedef std::weak_ptr<LIB_SYMBOL> PART_REF;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
|
2016-07-11 15:48:46 -04:00
|
|
|
extern std::string toUTFTildaText( const wxString& txt );
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
/**
|
2020-04-16 12:43:50 -04:00
|
|
|
* Schematic symbol object.
|
2007-09-13 11:55:46 +00:00
|
|
|
*/
|
2024-04-02 18:28:17 +01:00
|
|
|
class SCH_SYMBOL : public SYMBOL
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-07-17 20:56:18 +01:00
|
|
|
SCH_SYMBOL();
|
2008-10-19 18:31:09 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
/**
|
2021-03-25 17:13:01 -04:00
|
|
|
* Create schematic symbol from library symbol object.
|
2009-10-16 17:18:23 +00:00
|
|
|
*
|
2021-06-15 08:31:28 -04:00
|
|
|
* @param aSymbol is the library symbol to create schematic symbol from.
|
2021-03-25 17:13:01 -04:00
|
|
|
* @param aLibId is the #LIB_ID of alias to create.
|
|
|
|
* @param aSheet is the schematic sheet the symbol is place into.
|
2022-08-26 13:34:46 -04:00
|
|
|
* @param aUnit is unit for symbols that have multiple parts per package.
|
2024-01-26 16:16:13 +00:00
|
|
|
* @param aBodyStyle is the alternate body style for the schematic symbols.
|
2022-08-26 13:34:46 -04:00
|
|
|
* @param aPosition is the position of the symbol.
|
2009-10-16 17:18:23 +00:00
|
|
|
*/
|
2021-06-10 14:51:46 -04:00
|
|
|
SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet,
|
2024-01-26 16:16:13 +00:00
|
|
|
int aUnit, int aBodyStyle = 0, const VECTOR2I& aPosition = VECTOR2I( 0, 0 ),
|
2022-08-26 13:34:46 -04:00
|
|
|
EDA_ITEM* aParent = nullptr );
|
2021-06-10 10:10:55 -04:00
|
|
|
|
2021-06-10 14:51:46 -04:00
|
|
|
SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel,
|
2022-08-26 13:34:46 -04:00
|
|
|
const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), EDA_ITEM* aParent = nullptr );
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2008-10-19 18:31:09 +00:00
|
|
|
/**
|
2021-03-25 17:13:01 -04:00
|
|
|
* Clone \a aSymbol into a new schematic symbol object.
|
2017-06-27 11:22:25 -04: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 17:13:01 -04:00
|
|
|
* @param aSymbol is the schematic symbol to clone.
|
2008-10-19 18:31:09 +00:00
|
|
|
*/
|
2021-06-10 10:10:55 -04:00
|
|
|
SCH_SYMBOL( const SCH_SYMBOL& aSymbol );
|
2008-10-19 18:31:09 +00:00
|
|
|
|
2024-04-27 22:57:24 +03:00
|
|
|
~SCH_SYMBOL();
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2018-12-24 12:17:35 +01:00
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
|
|
|
{
|
2021-06-10 10:10:55 -04:00
|
|
|
return aItem && SCH_SYMBOL_T == aItem->Type();
|
2018-12-24 12:17:35 +01:00
|
|
|
}
|
|
|
|
|
2016-09-25 19:06:49 +02:00
|
|
|
wxString GetClass() const override
|
2007-09-13 11:28:58 +00:00
|
|
|
{
|
2021-06-10 10:10:55 -04:00
|
|
|
return wxT( "SCH_SYMBOL" );
|
2007-09-13 11:28:58 +00:00
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2024-06-12 13:27:17 -04:00
|
|
|
/**
|
|
|
|
* Check to see if the library symbol is set to the dummy library symbol.
|
|
|
|
*
|
|
|
|
* When the library symbol is missing (which technically should not happen now that the
|
|
|
|
* library symbols are cached in the schematic file), a dummy library symbol is substituted
|
|
|
|
* for the missing symbol as an indicator that something is amiss. The dummy symbol cannot
|
|
|
|
* be edited so a check for this symbol must be performed before attempting to edit the
|
|
|
|
* library symbol with the library editor or it will crash KiCad.
|
|
|
|
*
|
2025-01-10 00:12:54 +00:00
|
|
|
* @see LIB_SYMBOL::GetDummy()
|
2024-06-12 13:27:17 -04:00
|
|
|
*
|
|
|
|
* @return true if the library symbol is missing or false if it is valid.
|
|
|
|
*/
|
|
|
|
bool IsMissingLibSymbol() const;
|
|
|
|
|
2023-12-28 18:25:47 -05:00
|
|
|
const std::vector<SCH_SYMBOL_INSTANCE>& GetInstances() const
|
2020-02-22 21:39:59 +00:00
|
|
|
{
|
|
|
|
return m_instanceReferences;
|
|
|
|
}
|
2016-07-11 15:48:46 -04:00
|
|
|
|
2023-01-04 15:39:50 -05:00
|
|
|
bool GetInstance( SCH_SYMBOL_INSTANCE& aInstance,
|
2022-12-25 11:04:45 -05:00
|
|
|
const KIID_PATH& aSheetPath, bool aTestFromEnd = false ) const;
|
2022-10-01 08:44:21 -04:00
|
|
|
|
|
|
|
void RemoveInstance( const SCH_SHEET_PATH& aInstancePath );
|
|
|
|
|
2023-12-01 14:18:47 -05:00
|
|
|
void RemoveInstance( const KIID_PATH& aInstancePath );
|
|
|
|
|
2015-02-28 17:56:09 +01:00
|
|
|
/**
|
|
|
|
* Return true for items which are moved with the anchor point at mouse cursor
|
2017-06-27 11:22:25 -04: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 17:13:01 -04:00
|
|
|
* be large (hierarchical sheets, symbols).
|
2017-06-27 11:22:25 -04:00
|
|
|
*
|
2021-03-25 17:13:01 -04: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 15:17:24 +01:00
|
|
|
*
|
2022-04-11 11:47:47 +01:00
|
|
|
* @note We now use this to keep poorly-formed symbols from getting dragged off-grid. If
|
|
|
|
* the symbol contains off-grid pins we will not allow it to be moved from its anchor.
|
2015-02-28 17:56:09 +01:00
|
|
|
*/
|
2022-04-11 11:47:47 +01:00
|
|
|
bool IsMovableFromAnchorPoint() const override;
|
2015-02-28 17:56:09 +01:00
|
|
|
|
2020-04-16 12:43:50 -04:00
|
|
|
void SetLibId( const LIB_ID& aName );
|
2017-03-09 18:33:39 -05:00
|
|
|
|
2024-04-02 18:28:17 +01:00
|
|
|
const LIB_ID& GetLibId() const override { 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 15:28:54 -05:00
|
|
|
|
2024-01-18 16:11:33 +00:00
|
|
|
wxString GetSymbolIDAsString() const { return m_lib_id.Format(); }
|
|
|
|
|
2020-04-16 12:43:50 -04: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(); }
|
|
|
|
|
2024-06-12 13:27:17 -04:00
|
|
|
std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() { return m_part; }
|
|
|
|
const std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() const { return m_part; }
|
2017-03-03 19:04:43 -05:00
|
|
|
|
2020-04-16 12:43:50 -04:00
|
|
|
/**
|
2024-06-12 13:27:17 -04: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
|
|
|
|
* accordingly. The #LIB_SYMBOL object can be null to clear the library symbol link
|
|
|
|
* as well as the pin map. If the #LIB_SYMBOL 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 12:43:50 -04:00
|
|
|
*
|
2024-06-12 13:27:17 -04: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_SYMBOL reference. All previous
|
|
|
|
* public resolvers have been deprecated.
|
2020-05-05 10:55:54 -04:00
|
|
|
*
|
|
|
|
* @param aLibSymbol is the library symbol to associate with this schematic symbol.
|
2020-04-16 12:43:50 -04:00
|
|
|
*/
|
2024-06-12 13:27:17 -04:00
|
|
|
void SetLibSymbol( LIB_SYMBOL* aLibSymbol );
|
2020-04-16 12:43:50 -04:00
|
|
|
|
2017-04-02 22:09:01 +10:00
|
|
|
/**
|
2022-09-02 22:32:50 +01:00
|
|
|
* @return the associated LIB_SYMBOL's description field (or wxEmptyString).
|
2017-04-02 22:09:01 +10:00
|
|
|
*/
|
2024-04-02 18:28:17 +01:00
|
|
|
wxString GetDescription() const override;
|
2017-06-27 11:22:25 -04:00
|
|
|
|
|
|
|
/**
|
2022-09-02 22:32:50 +01:00
|
|
|
* @return the associated LIB_SYMBOL's keywords field (or wxEmptyString).
|
|
|
|
*/
|
2024-04-02 18:28:17 +01:00
|
|
|
wxString GetKeyWords() const override;
|
2022-09-02 22:32:50 +01:00
|
|
|
|
|
|
|
/**
|
2017-06-27 11:22:25 -04:00
|
|
|
* Return the documentation text for the given part alias
|
|
|
|
*/
|
2018-11-22 21:30:36 +00:00
|
|
|
wxString GetDatasheet() const;
|
2017-04-02 22:09:01 +10:00
|
|
|
|
2019-03-11 17:32:05 -04:00
|
|
|
/**
|
2020-01-16 21:33:16 -05:00
|
|
|
* Updates the cache of SCH_PIN objects for each pin
|
2019-03-11 17:32:05 -04:00
|
|
|
*/
|
2020-01-16 21:33:16 -05:00
|
|
|
void UpdatePins();
|
2019-03-11 17:32:05 -04:00
|
|
|
|
2022-09-14 22:11:37 +00:00
|
|
|
/**
|
|
|
|
* Return the display name for a given unit \a aUnit.
|
|
|
|
*
|
|
|
|
* @return the display name of a unit if set, or the ordinal name of the unit otherwise.
|
|
|
|
*/
|
2025-07-23 14:33:29 +01:00
|
|
|
wxString GetUnitDisplayName( int aUnit, bool aLabel ) const override;
|
|
|
|
|
|
|
|
wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const override;
|
2022-09-14 22:11:37 +00:00
|
|
|
|
2024-04-08 21:24:32 +01:00
|
|
|
void SetBodyStyle( int aBodyStyle ) override;
|
2010-12-14 10:56:30 -05:00
|
|
|
|
2024-07-18 10:45:12 +02:00
|
|
|
/**
|
|
|
|
* Similar to SetBodyStyle(), but always set the body style, regardless
|
|
|
|
* the lib symbol properties (the LIB_SYMBOL m_part can be not set during
|
|
|
|
* schematic files loading)
|
|
|
|
*/
|
|
|
|
void SetBodyStyleUnconditional( int aBodyStyle );
|
|
|
|
|
2024-04-02 18:28:17 +01:00
|
|
|
bool HasAlternateBodyStyle() const override;
|
2010-12-14 10:56:30 -05:00
|
|
|
|
2024-04-02 18:28:17 +01:00
|
|
|
wxString GetPrefix() const { return m_prefix; }
|
2016-07-06 05:22:56 -04:00
|
|
|
void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; }
|
|
|
|
|
2022-12-07 01:34:10 +00:00
|
|
|
/**
|
|
|
|
* Set the prefix based on the current reference designator.
|
|
|
|
*/
|
|
|
|
void UpdatePrefix();
|
|
|
|
|
2023-11-12 23:42:36 +00:00
|
|
|
wxString SubReference( int aUnit, bool aAddSeparator = true ) const;
|
|
|
|
|
2011-06-17 09:24:22 -04:00
|
|
|
/**
|
2017-06-27 11:22:25 -04:00
|
|
|
* Return the number of units per package of the symbol.
|
2011-06-17 09:24:22 -04:00
|
|
|
*
|
2017-06-27 11:22:25 -04:00
|
|
|
* @return the number of units per package or zero if the library entry cannot be found.
|
2011-06-17 09:24:22 -04:00
|
|
|
*/
|
2024-04-02 18:28:17 +01:00
|
|
|
int GetUnitCount() const override;
|
|
|
|
|
|
|
|
bool IsMulti() const override { return GetUnitCount() > 1; }
|
2011-06-17 09:24:22 -04:00
|
|
|
|
2010-12-14 16:39:31 -05:00
|
|
|
/**
|
2017-06-27 11:22:25 -04:00
|
|
|
* Compute the new transform matrix based on \a aOrientation for the symbol which is
|
2010-12-14 16:39:31 -05:00
|
|
|
* applied to the current transform.
|
2017-06-27 11:22:25 -04:00
|
|
|
*
|
|
|
|
* @param aOrientation is the orientation to apply to the transform.
|
2010-12-14 16:39:31 -05:00
|
|
|
*/
|
2010-12-10 14:47:44 -05:00
|
|
|
void SetOrientation( int aOrientation );
|
2010-01-13 21:15:54 +00:00
|
|
|
|
2010-11-12 09:17:10 -06:00
|
|
|
/**
|
2017-06-27 11:22:25 -04: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
|
2021-06-10 10:10:55 -04:00
|
|
|
* a rotation and a mirror value #SYM_MIRROR_X because this is the first mirror
|
2017-06-27 11:22:25 -04:00
|
|
|
* option tested. This can differs from the orientation made by an user. A
|
2021-06-10 10:10:55 -04:00
|
|
|
* #SYM_MIRROR_Y is returned as a #SYM_MIRROR_X with an orientation 180 because
|
2017-06-27 11:22:25 -04:00
|
|
|
* they are equivalent.
|
|
|
|
*
|
2021-06-10 10:10:55 -04:00
|
|
|
* @sa SYMBOL_ORIENTATION_T
|
2017-06-27 11:22:25 -04:00
|
|
|
*
|
|
|
|
* @return the orientation and mirror of the symbol.
|
2009-04-09 11:34:41 +00:00
|
|
|
*/
|
2024-12-22 20:20:32 +00:00
|
|
|
int GetOrientation() const override;
|
2009-04-09 11:34:41 +00:00
|
|
|
|
2024-01-18 16:11:33 +00:00
|
|
|
/**
|
2024-01-19 13:29:08 +00:00
|
|
|
* Orientation/mirroring access for property manager.
|
2024-01-18 16:11:33 +00:00
|
|
|
*/
|
|
|
|
void SetOrientationProp( SYMBOL_ORIENTATION_PROP aAngle )
|
|
|
|
{
|
2024-01-19 13:29:08 +00:00
|
|
|
int mirroring = GetOrientation();
|
|
|
|
|
|
|
|
mirroring &= ( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
|
|
|
|
|
|
|
|
SetOrientation( aAngle | mirroring );
|
2024-01-18 16:11:33 +00:00
|
|
|
}
|
2024-01-19 13:29:08 +00:00
|
|
|
|
2024-01-18 16:11:33 +00:00
|
|
|
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
|
|
|
|
{
|
2024-01-19 13:29:08 +00:00
|
|
|
int orientation = GetOrientation();
|
|
|
|
|
|
|
|
orientation &= ~( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
|
|
|
|
|
|
|
|
switch( orientation )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case SYM_NORMAL:
|
|
|
|
case SYM_ORIENT_0: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0;
|
|
|
|
case SYM_ORIENT_90: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_90;
|
|
|
|
case SYM_ORIENT_180: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_180;
|
|
|
|
case SYM_ORIENT_270: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_270;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMirrorX( bool aMirror )
|
|
|
|
{
|
|
|
|
int orientation = GetOrientation();
|
|
|
|
|
|
|
|
if( aMirror )
|
|
|
|
orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
|
|
|
|
else
|
|
|
|
orientation &= ~SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
|
|
|
|
|
|
|
|
SetOrientation( orientation );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetMirrorX() const
|
|
|
|
{
|
|
|
|
return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMirrorY( bool aMirror )
|
|
|
|
{
|
|
|
|
int orientation = GetOrientation();
|
|
|
|
|
|
|
|
if( aMirror )
|
|
|
|
orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
|
|
|
|
else
|
|
|
|
orientation &= ~SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
|
|
|
|
|
|
|
|
SetOrientation( orientation );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetMirrorY() const
|
|
|
|
{
|
|
|
|
return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
|
2024-01-18 16:11:33 +00:00
|
|
|
}
|
|
|
|
|
2020-05-27 23:28:36 +01:00
|
|
|
/**
|
|
|
|
* Return the list of system text vars & fields for this symbol.
|
|
|
|
*/
|
|
|
|
void GetContextualTextVars( wxArrayString* aVars ) const;
|
|
|
|
|
2020-04-06 14:06:57 +01:00
|
|
|
/**
|
2021-03-25 17:13:01 -04:00
|
|
|
* Resolve any references to system tokens supported by the symbol.
|
|
|
|
*
|
2020-04-06 14:06:57 +01:00
|
|
|
* @param aDepth a counter to limit recursion and circular references.
|
|
|
|
*/
|
2023-05-06 14:22:14 -04:00
|
|
|
bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth = 0 ) const;
|
2020-04-06 14:06:57 +01:00
|
|
|
|
2020-04-24 14:36:10 +01: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 17:13:01 -04:00
|
|
|
* Clear exiting symbol annotation.
|
2017-06-27 11:22:25 -04: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.
|
2022-04-13 23:37:42 +01:00
|
|
|
* @param[in] aResetPrefix The annotation prefix ('R', 'U', etc.) should be reset to the
|
|
|
|
* symbol library prefix.
|
2008-04-21 06:34:56 +00:00
|
|
|
*/
|
2022-04-13 23:37:42 +01:00
|
|
|
void ClearAnnotation( const SCH_SHEET_PATH* aSheetPath, bool aResetPrefix );
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2018-09-03 12:11:39 +02: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 17:13:01 -04: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 18:46:03 +02:00
|
|
|
* @return false if the alternate reference was existing, true if added.
|
2018-09-03 12:11:39 +02:00
|
|
|
*/
|
2020-02-22 21:39:59 +00:00
|
|
|
bool AddSheetPathReferenceEntryIfMissing( const KIID_PATH& aSheetPath );
|
2018-09-03 12:11:39 +02:00
|
|
|
|
2020-04-26 16:53:29 -04:00
|
|
|
|
2022-08-31 10:15:42 +01:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2015-12-13 11:56:47 -05:00
|
|
|
/**
|
2021-09-23 22:07:19 +01:00
|
|
|
* Return a bounding box for the symbol body but not the pins or fields.
|
2015-12-13 11:56:47 -05:00
|
|
|
*/
|
2024-12-22 20:20:32 +00:00
|
|
|
BOX2I GetBodyBoundingBox() const override;
|
2015-12-13 11:56:47 -05:00
|
|
|
|
2021-09-23 22:07:19 +01:00
|
|
|
/**
|
|
|
|
* Return a bounding box for the symbol body and pins but not the fields.
|
|
|
|
*/
|
2024-12-22 20:20:32 +00:00
|
|
|
BOX2I GetBodyAndPinsBoundingBox() const override;
|
2021-09-23 22:07:19 +01:00
|
|
|
|
2015-12-13 11:56:47 -05:00
|
|
|
|
2010-06-17 11:30:10 -05:00
|
|
|
//-----<Fields>-----------------------------------------------------------
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
/**
|
2025-02-08 13:45:57 +00:00
|
|
|
* Return a mandatory field in this symbol. The const version will return nullptr if the
|
|
|
|
* field is not found; non-const version will create the field.
|
2021-02-28 13:28:23 +00:00
|
|
|
*/
|
2025-02-08 13:45:57 +00:00
|
|
|
SCH_FIELD* GetField( FIELD_T aFieldType );
|
|
|
|
const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2023-05-08 10:59:13 -04:00
|
|
|
/**
|
2025-02-08 13:45:57 +00:00
|
|
|
* Return a field in this symbol. Both versions return nullptr if the field is not found.
|
2023-05-08 10:59:13 -04:00
|
|
|
*/
|
2025-02-08 13:45:57 +00:00
|
|
|
SCH_FIELD* GetField( const wxString& aFieldName );
|
|
|
|
const SCH_FIELD* GetField( const wxString& aFieldName ) const;
|
2017-04-02 22:09:01 +10:00
|
|
|
|
2015-12-13 11:56:47 -05:00
|
|
|
/**
|
2025-02-08 13:45:57 +00:00
|
|
|
* Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
|
2017-06-27 11:22:25 -04: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 11:56:47 -05:00
|
|
|
*/
|
2025-02-08 13:45:57 +00:00
|
|
|
void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) const override;
|
2015-12-13 11:56:47 -05:00
|
|
|
|
2020-02-04 22:48:33 -06:00
|
|
|
/**
|
2025-02-08 13:45:57 +00:00
|
|
|
* Return a reference to the vector holding the symbol's fields
|
2020-02-04 22:48:33 -06: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-04 22:48:33 -06:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
/**
|
2017-06-27 11:22:25 -04: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 11:30:10 -05:00
|
|
|
*/
|
|
|
|
SCH_FIELD* AddField( const SCH_FIELD& aField );
|
|
|
|
|
2018-07-31 22:59:43 +01:00
|
|
|
/**
|
2021-03-25 17:13:01 -04:00
|
|
|
* Remove a user field from the symbol.
|
2025-02-08 13:45:57 +00:00
|
|
|
*
|
|
|
|
* @param aFieldName is the user fieldName to remove.
|
2018-07-31 22:59:43 +01:00
|
|
|
*/
|
|
|
|
void RemoveField( const wxString& aFieldName );
|
|
|
|
|
2022-12-08 23:56:55 +00:00
|
|
|
void RemoveField( SCH_FIELD* aField ) { RemoveField( aField->GetName() ); }
|
|
|
|
|
2010-06-17 11:30:10 -05:00
|
|
|
/**
|
2017-06-27 11:22:25 -04:00
|
|
|
* Search for a #SCH_FIELD with \a aFieldName
|
|
|
|
*
|
|
|
|
* @param aFieldName is the name of the field to find.
|
|
|
|
*
|
|
|
|
* @return the field if found or NULL if the field was not found.
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2025-02-08 13:45:57 +00:00
|
|
|
SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2024-04-05 22:35:32 +01:00
|
|
|
/**
|
|
|
|
* @return the reference for the instance on the given sheet.
|
|
|
|
*/
|
|
|
|
const wxString GetRef( const SCH_SHEET_PATH* aSheet,
|
|
|
|
bool aIncludeUnit = false ) const override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the value for the instance on the given sheet.
|
|
|
|
*/
|
|
|
|
const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
|
|
|
|
bool aAllowExtraText ) const override;
|
|
|
|
|
2022-11-25 09:25:39 -05:00
|
|
|
void SetValueFieldText( const wxString& aValue );
|
|
|
|
|
2023-05-05 14:21:56 +01:00
|
|
|
const wxString GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
|
|
|
|
bool aAllowExtraText ) const;
|
2022-11-25 09:25:39 -05:00
|
|
|
void SetFootprintFieldText( const wxString& aFootprint );
|
|
|
|
|
2024-01-18 16:11:33 +00:00
|
|
|
/*
|
|
|
|
* Field access for property manager
|
|
|
|
*/
|
|
|
|
wxString GetRefProp() const
|
|
|
|
{
|
|
|
|
return GetRef( &Schematic()->CurrentSheet() );
|
|
|
|
}
|
2025-02-06 09:47:00 -05:00
|
|
|
|
2024-10-28 18:39:58 +00:00
|
|
|
void SetRefProp( const wxString& aRef );
|
2025-07-23 14:33:29 +01:00
|
|
|
|
2024-01-18 16:11:33 +00:00
|
|
|
wxString GetValueProp() const
|
|
|
|
{
|
2024-04-05 22:35:32 +01:00
|
|
|
return GetValue( false, &Schematic()->CurrentSheet(), false );
|
2024-01-18 16:11:33 +00:00
|
|
|
}
|
2025-02-06 09:47:00 -05:00
|
|
|
|
2024-04-02 18:28:17 +01:00
|
|
|
void SetValueProp( const wxString& aRef )
|
2024-01-18 16:11:33 +00:00
|
|
|
{
|
|
|
|
SetValueFieldText( aRef );
|
|
|
|
}
|
2025-02-06 09:47:00 -05:00
|
|
|
|
2025-07-23 14:33:29 +01:00
|
|
|
wxString GetUnitProp() const override
|
2024-05-20 23:37:29 +01:00
|
|
|
{
|
2025-02-14 23:02:27 +00:00
|
|
|
int unit = GetUnitSelection( &Schematic()->CurrentSheet() );
|
|
|
|
|
2025-07-23 14:33:29 +01:00
|
|
|
return GetUnitDisplayName( unit, false );
|
2024-05-20 23:37:29 +01:00
|
|
|
}
|
2025-02-06 09:47:00 -05:00
|
|
|
|
2025-07-23 14:33:29 +01:00
|
|
|
void SetUnitProp( const wxString& aUnit ) override
|
2024-05-20 23:37:29 +01:00
|
|
|
{
|
2025-02-14 23:02:27 +00:00
|
|
|
for( int unit = 1; unit <= GetUnitCount(); unit++ )
|
|
|
|
{
|
2025-07-23 14:33:29 +01:00
|
|
|
if( GetUnitDisplayName( unit, false ) == aUnit )
|
2025-02-14 23:02:27 +00:00
|
|
|
{
|
|
|
|
SetUnitSelection( &Schematic()->CurrentSheet(), unit );
|
|
|
|
SetUnit( unit );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2024-05-20 23:37:29 +01:00
|
|
|
}
|
2025-02-06 09:47:00 -05:00
|
|
|
|
2025-07-23 14:33:29 +01:00
|
|
|
wxString GetBodyStyleProp() const override
|
2024-05-20 23:37:29 +01:00
|
|
|
{
|
2025-07-23 14:33:29 +01:00
|
|
|
return GetBodyStyleDescription( GetBodyStyle(), false );
|
2024-05-20 23:37:29 +01:00
|
|
|
}
|
2025-02-06 09:47:00 -05:00
|
|
|
|
2025-07-23 14:33:29 +01:00
|
|
|
void SetBodyStyleProp( const wxString& aBodyStyle ) override
|
2024-05-20 23:37:29 +01:00
|
|
|
{
|
2025-07-23 14:33:29 +01:00
|
|
|
for( int bodyStyle : { BODY_STYLE::BASE, BODY_STYLE::DEMORGAN } )
|
|
|
|
{
|
|
|
|
if( GetBodyStyleDescription( bodyStyle, false ) == aBodyStyle )
|
|
|
|
{
|
|
|
|
SetBodyStyle( bodyStyle );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2024-05-20 23:37:29 +01:00
|
|
|
}
|
2024-01-18 16:11:33 +00:00
|
|
|
|
2017-08-25 15:27:06 +02:00
|
|
|
/**
|
2021-03-25 17:13:01 -04:00
|
|
|
* Restore fields to the original library values.
|
|
|
|
*
|
2021-04-09 17:10:40 +01:00
|
|
|
* @param aUpdateStyle selects whether fields should update the position and text attributes.
|
|
|
|
* @param aUpdateRef selects whether the reference field should be updated.
|
|
|
|
* @param aUpdateOtherFields selects whether non-reference fields should be updated.
|
|
|
|
* @param aResetRef selects whether the reference should be reset to the library value.
|
|
|
|
* @param aResetOtherFields selects whether non-reference fields should be reset to library
|
|
|
|
* values.
|
2017-08-25 15:27:06 +02:00
|
|
|
*/
|
2021-04-09 17:10:40 +01:00
|
|
|
void UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, bool aUpdateRef,
|
|
|
|
bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields );
|
2024-07-20 16:01:50 +01:00
|
|
|
|
|
|
|
/**
|
2025-02-06 09:47:00 -05:00
|
|
|
* Keep fields other than the reference, include/exclude flags, and alternate pin assignments
|
2024-07-20 16:01:50 +01:00
|
|
|
* in sync in multi-unit parts.
|
|
|
|
*
|
|
|
|
* @param aSourceSheet the sheet instance of the unit to sync to
|
|
|
|
* @param aProperty [optional] if present, the single property to sync. (Otherwise the
|
|
|
|
* include/exclude flags, alternate pin assignments, and all fields bar the
|
|
|
|
* reference will be synced.)
|
|
|
|
*/
|
|
|
|
void SyncOtherUnits( const SCH_SHEET_PATH& aSourceSheet, SCH_COMMIT& aCommit,
|
|
|
|
PROPERTY_BASE* aProperty );
|
2017-08-25 15:27:06 +02:00
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
/**
|
2025-02-24 23:41:26 +00:00
|
|
|
* Return the next ordinal for a user field for this symbol
|
2008-10-06 05:44:29 +00:00
|
|
|
*/
|
2025-02-24 23:41:26 +00:00
|
|
|
int GetNextFieldOrdinal() const;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2015-12-13 11:56:47 -05:00
|
|
|
/**
|
2021-03-25 17:13:01 -04:00
|
|
|
* Automatically orient all the fields in the symbol.
|
2017-06-27 11:22:25 -04:00
|
|
|
*
|
2024-12-23 14:19:43 +00:00
|
|
|
* @param aScreen is the SCH_SCREEN associated with the current instance of the symbol.
|
|
|
|
* Required when \a aAlgo is AUTOPLACE_MANUAL; optional otherwise.
|
2015-12-13 11:56:47 -05:00
|
|
|
*/
|
2024-12-23 14:19:43 +00:00
|
|
|
void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
|
2015-12-13 11:56:47 -05:00
|
|
|
|
2025-03-27 13:11:07 -04:00
|
|
|
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
|
2020-11-17 16:02:47 +00:00
|
|
|
|
2015-12-13 11:56:47 -05:00
|
|
|
|
|
|
|
//-----</Fields>----------------------------------------------------------
|
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2017-06-27 11:22:25 -04: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 19:44:13 +01:00
|
|
|
SCH_PIN* GetPin( const wxString& number ) const;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2015-12-13 11:56:47 -05:00
|
|
|
/**
|
2024-04-20 10:44:34 +01:00
|
|
|
* Populate a vector with all the pins from the library object that match the current unit
|
|
|
|
* and bodyStyle.
|
2017-06-27 11:22:25 -04:00
|
|
|
*
|
|
|
|
* @param aPinsList is the list to populate with all of the pins.
|
2015-12-13 11:56:47 -05:00
|
|
|
*/
|
2024-04-20 10:44:34 +01:00
|
|
|
std::vector<SCH_PIN*> GetLibPins() const;
|
2020-08-21 16:54:24 +01:00
|
|
|
|
2022-08-22 07:40:23 +02:00
|
|
|
/**
|
2024-04-20 10:44:34 +01:00
|
|
|
* @return a list of pin pointers for all units / bodyStyles. Used primarily for SPICE where
|
2022-12-16 13:42:49 +00:00
|
|
|
* we want to treat all units together as a single SPICE element.
|
2022-08-22 07:40:23 +02:00
|
|
|
*/
|
2024-04-20 10:44:34 +01:00
|
|
|
std::vector<SCH_PIN*> GetAllLibPins() const;
|
2022-08-22 07:40:23 +02:00
|
|
|
|
2022-12-16 13:42:49 +00:00
|
|
|
/**
|
2023-10-02 23:32:20 +01:00
|
|
|
* @return a count of pins for all units.
|
2022-12-16 13:42:49 +00:00
|
|
|
*/
|
2024-04-27 22:57:24 +03:00
|
|
|
size_t GetFullPinCount() const;
|
2022-12-08 23:56:55 +00:00
|
|
|
|
2022-12-16 13:42:49 +00:00
|
|
|
/**
|
2024-04-20 10:44:34 +01:00
|
|
|
* @return the instance SCH_PIN associated with a particular SCH_PIN from the LIB_SYMBOL.
|
2022-12-16 13:42:49 +00:00
|
|
|
*/
|
2024-04-20 10:44:34 +01:00
|
|
|
SCH_PIN* GetPin( SCH_PIN* aLibPin ) const;
|
2024-04-21 10:54:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the #SCH_PIN object found at \a aPosition.
|
|
|
|
*
|
|
|
|
* @param aPosition is the position of the pin to fetch.
|
|
|
|
*
|
|
|
|
* @return the #SCH_PIN object found at \a aPosition or nullptr.
|
|
|
|
*/
|
|
|
|
const SCH_PIN* GetPin( const VECTOR2I& aPosition ) const;
|
2015-12-13 11:56:47 -05:00
|
|
|
|
2020-01-16 21:33:16 -05:00
|
|
|
/**
|
2021-03-25 17:13:01 -04: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-16 21:33:16 -05:00
|
|
|
* this list returns the subset of pins that exist on a given sheet.
|
2021-03-25 17:13:01 -04:00
|
|
|
*
|
2020-01-16 21:33:16 -05:00
|
|
|
* @return a vector of pointers (non-owning) to SCH_PINs
|
|
|
|
*/
|
2024-12-22 20:20:32 +00:00
|
|
|
std::vector<SCH_PIN*> GetPins( const SCH_SHEET_PATH* aSheet ) const;
|
|
|
|
|
|
|
|
std::vector<SCH_PIN*> GetPins() const override;
|
2020-08-21 16:54:24 +01:00
|
|
|
|
2022-03-09 02:40:59 +01:00
|
|
|
|
2020-08-21 16:54:24 +01:00
|
|
|
std::vector<std::unique_ptr<SCH_PIN>>& GetRawPins() { return m_pins; }
|
2018-08-30 20:44:10 +01:00
|
|
|
|
2011-05-31 18:29:14 +02:00
|
|
|
/**
|
2017-06-27 11:22:25 -04: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 18:29:14 +02:00
|
|
|
*/
|
2017-06-27 11:22:25 -04:00
|
|
|
void SetRef( const SCH_SHEET_PATH* aSheet, const wxString& aReference );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2019-05-19 11:40:14 -04:00
|
|
|
/**
|
2021-03-25 17:13:01 -04: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 11:40:14 -04:00
|
|
|
*/
|
2024-04-05 22:35:32 +01:00
|
|
|
bool IsAnnotated( const SCH_SHEET_PATH* aSheet ) const;
|
2019-05-19 11:40:14 -04:00
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
/**
|
2017-06-27 11:22:25 -04:00
|
|
|
* Add a full hierarchical reference to this symbol.
|
|
|
|
*
|
2021-03-25 17:13:01 -04: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 17:13:01 -04:00
|
|
|
* @param aValue is the value used for this instance.
|
2020-08-29 14:41:47 +01:00
|
|
|
* @param aFootprint is the footprint used for this instance (which might have different
|
2021-03-25 17:13:01 -04: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,
|
2022-11-25 09:25:39 -05:00
|
|
|
int aUnit );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2023-01-04 15:39:50 -05:00
|
|
|
void AddHierarchicalReference( const SCH_SYMBOL_INSTANCE& aInstance );
|
2022-10-01 08:44:21 -04:00
|
|
|
|
2021-03-25 17:13:01 -04:00
|
|
|
/// Return the instance-specific unit selection for the given sheet path.
|
2020-01-16 21:33:16 -05:00
|
|
|
int GetUnitSelection( const SCH_SHEET_PATH* aSheet ) const;
|
2021-01-21 21:00:09 +01:00
|
|
|
|
2021-03-25 17:13:01 -04:00
|
|
|
/// Set the selected unit of this symbol on one sheet.
|
2020-01-16 21:33:16 -05:00
|
|
|
void SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2021-03-25 17:13:01 -04:00
|
|
|
/// Set the selected unit of this symbol for all sheets.
|
2021-01-21 21:00:09 +01:00
|
|
|
void SetUnitSelection( int aUnitSelection );
|
|
|
|
|
2025-04-24 11:33:02 +01:00
|
|
|
/**
|
|
|
|
* SCH_SYMBOLs don't currently support embedded files, but their LIB_SYMBOL counterparts
|
|
|
|
* do.
|
|
|
|
*/
|
|
|
|
EMBEDDED_FILES* GetEmbeddedFiles() override;
|
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
void Move( const VECTOR2I& aMoveVector ) override
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2022-01-01 13:57:44 -05:00
|
|
|
if( aMoveVector == VECTOR2I( 0, 0 ) )
|
2010-12-14 16:39:31 -05:00
|
|
|
return;
|
|
|
|
|
2020-11-16 13:15:54 +00:00
|
|
|
m_pos += aMoveVector;
|
2010-12-14 16:39:31 -05: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 );
|
2010-12-14 16:39:31 -05:00
|
|
|
}
|
2010-09-05 19:01:48 +02:00
|
|
|
|
2021-02-16 20:45:25 +00:00
|
|
|
void MirrorHorizontally( int aCenter ) override;
|
|
|
|
void MirrorVertically( int aCenter ) override;
|
2024-04-04 23:51:22 +01:00
|
|
|
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2022-08-04 22:40:38 -04:00
|
|
|
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
|
2010-11-03 10:13:15 -04:00
|
|
|
|
2016-09-24 14:53:15 -04:00
|
|
|
void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
2010-11-03 10:13:15 -04:00
|
|
|
|
2015-07-20 15:49:32 -04:00
|
|
|
/**
|
2021-03-25 17:13:01 -04:00
|
|
|
* Test if the symbol's dangling state has changed for all pins.
|
2017-06-27 11:22:25 -04:00
|
|
|
*
|
|
|
|
* As a side effect, actually update the dangling status for all pins.
|
|
|
|
*
|
|
|
|
* @note This does not test for short circuits.
|
|
|
|
*
|
2017-06-30 09:50:49 +02:00
|
|
|
* @param aItemList is list of all #DANGLING_END_ITEM items to be tested.
|
2015-07-20 15:49:32 -04:00
|
|
|
* @return true if any pin's state has changed.
|
|
|
|
*/
|
2024-02-12 09:01:45 +01:00
|
|
|
bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
|
|
|
|
std::vector<DANGLING_END_ITEM>& aItemListByPos,
|
|
|
|
const SCH_SHEET_PATH* aPath = nullptr ) override;
|
2015-06-07 20:07:42 -04:00
|
|
|
|
2024-04-20 10:44:34 +01:00
|
|
|
VECTOR2I GetPinPhysicalPosition( const SCH_PIN* Pin ) const;
|
2010-11-03 10:13:15 -04:00
|
|
|
|
2020-10-04 18:39:21 -04:00
|
|
|
bool IsConnectable() const override { return true; }
|
2011-01-07 14:24:24 -05:00
|
|
|
|
2024-03-09 08:50:26 -05:00
|
|
|
bool HasConnectivityChanges( const SCH_ITEM* aItem,
|
|
|
|
const SCH_SHEET_PATH* aInstance = nullptr ) const override;
|
|
|
|
|
2017-12-19 09:45:56 -08:00
|
|
|
bool CanConnect( const SCH_ITEM* aItem ) const override
|
|
|
|
{
|
|
|
|
return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
|
2021-10-12 21:05:37 +01:00
|
|
|
( aItem->Type() == SCH_NO_CONNECT_T ) ||
|
|
|
|
( aItem->Type() == SCH_JUNCTION_T ) ||
|
|
|
|
( aItem->Type() == SCH_SYMBOL_T ) ||
|
2022-01-24 13:40:39 +00:00
|
|
|
( aItem->Type() == SCH_DIRECTIVE_LABEL_T ) ||
|
2021-10-12 21:05:37 +01:00
|
|
|
( aItem->Type() == SCH_LABEL_T ) ||
|
|
|
|
( aItem->Type() == SCH_HIER_LABEL_T ) ||
|
|
|
|
( aItem->Type() == SCH_GLOBAL_LABEL_T );
|
2017-12-19 09:45:56 -08:00
|
|
|
}
|
|
|
|
|
2013-09-27 19:58:58 +02:00
|
|
|
/**
|
2021-03-25 17:13:01 -04:00
|
|
|
* @return true if the symbol is in netlist.
|
2013-09-27 19:58:58 +02:00
|
|
|
*/
|
|
|
|
bool IsInNetlist() const;
|
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
std::vector<VECTOR2I> GetConnectionPoints() const override;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2022-08-20 10:27:35 +01:00
|
|
|
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
2022-08-21 20:54:07 +01:00
|
|
|
const std::vector<KICAD_T>& aScanTypes ) override;
|
2011-03-25 15:16:05 -04:00
|
|
|
|
2010-12-13 10:59:00 -05:00
|
|
|
/**
|
2021-03-25 17:13:01 -04:00
|
|
|
* Return the symbol library item at \a aPosition that is part of this symbol.
|
2010-12-13 10:59:00 -05:00
|
|
|
*
|
2021-03-25 17:13:01 -04:00
|
|
|
* @param aPosition is the schematic position of the symbol library object.
|
2017-06-27 11:22:25 -04: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 10:59:00 -05:00
|
|
|
*/
|
2024-04-06 14:14:44 +01:00
|
|
|
SCH_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT );
|
2011-03-25 15:16:05 -04:00
|
|
|
|
2024-06-27 10:11:55 +01:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
|
2011-03-25 15:16:05 -04:00
|
|
|
|
2021-03-07 21:59:07 -05:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2011-03-25 15:16:05 -04:00
|
|
|
|
2016-09-24 14:53:15 -04:00
|
|
|
bool operator <( const SCH_ITEM& aItem ) const override;
|
2011-03-25 15:16:05 -04:00
|
|
|
|
2021-06-10 10:10:55 -04:00
|
|
|
bool operator==( const SCH_SYMBOL& aSymbol) const;
|
|
|
|
bool operator!=( const SCH_SYMBOL& aSymbol) const;
|
2012-02-22 23:37:34 +02:00
|
|
|
|
2024-04-08 21:24:32 +01:00
|
|
|
SCH_SYMBOL& operator=( const SCH_SYMBOL& aItem );
|
2012-01-09 15:26:55 -05:00
|
|
|
|
2016-09-25 19:06:49 +02:00
|
|
|
bool IsReplaceable() const override { return true; }
|
2011-12-01 11:49:28 -05:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
VECTOR2I GetPosition() const override { return m_pos; }
|
|
|
|
void SetPosition( const VECTOR2I& aPosition ) override { Move( aPosition - m_pos ); }
|
2012-03-15 10:31:16 -04:00
|
|
|
|
2024-01-18 16:11:33 +00:00
|
|
|
int GetX() const { return GetPosition().x; };
|
|
|
|
void SetX( int aX ) { SetPosition( VECTOR2I( aX, GetY() ) ); }
|
|
|
|
|
|
|
|
int GetY() const { return GetPosition().y; }
|
|
|
|
void SetY( int aY ) { SetPosition( VECTOR2I( GetX(), aY ) ); }
|
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2022-08-31 10:33:46 +01:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2012-03-15 10:31:16 -04:00
|
|
|
|
2024-04-05 22:35:32 +01:00
|
|
|
void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
|
|
|
|
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
|
2012-03-15 10:31:16 -04:00
|
|
|
|
2022-07-05 16:37:36 -07:00
|
|
|
/**
|
2022-10-01 08:44:21 -04:00
|
|
|
* Plot just the symbol pins. This is separated to match the GAL display order. The pins
|
|
|
|
* are ALSO plotted with the symbol group. This replotting allows us to ensure that they
|
|
|
|
* are shown above other elements in the schematic.
|
|
|
|
*
|
|
|
|
* @param aPlotter is the #PLOTTER object used to plot pins.
|
2022-07-05 16:37:36 -07:00
|
|
|
*/
|
|
|
|
void PlotPins( PLOTTER* aPlotter ) const;
|
|
|
|
|
2024-04-18 15:20:46 +01:00
|
|
|
/**
|
|
|
|
* Plot the red 'X' over the symbol. This is separated to allow it being used from the
|
|
|
|
* screen plot function, overlapping the pins
|
|
|
|
*
|
|
|
|
* @param aPlotter the #PLOTTER object used to draw the X
|
|
|
|
*/
|
|
|
|
void PlotDNP( PLOTTER* aPlotter ) const;
|
|
|
|
|
2016-09-24 14:53:15 -04:00
|
|
|
EDA_ITEM* Clone() const override;
|
2012-03-17 10:39:27 -04:00
|
|
|
|
2010-12-10 14:47:44 -05:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 19:06:49 +02:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
2008-02-26 19:19:54 +00:00
|
|
|
#endif
|
2010-12-10 14:47:44 -05:00
|
|
|
|
2019-03-08 00:16:59 +00:00
|
|
|
void ClearBrightenedPins();
|
|
|
|
|
|
|
|
bool HasBrightenedPins();
|
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override;
|
2021-02-17 12:03:55 -05:00
|
|
|
|
2023-03-16 15:31:39 +01:00
|
|
|
/**
|
|
|
|
* @return true if the symbol is equivalent to a global label:
|
|
|
|
* It is a Power symbol
|
|
|
|
* It has only one pin type Power input
|
|
|
|
*/
|
|
|
|
bool IsSymbolLikePowerGlobalLabel() const;
|
2025-02-26 18:13:36 -08:00
|
|
|
bool IsSymbolLikePowerLocalLabel() const;
|
2023-03-16 15:31:39 +01:00
|
|
|
|
2025-02-26 18:13:36 -08:00
|
|
|
bool IsGlobalPower() const override;
|
|
|
|
bool IsLocalPower() const override;
|
2024-04-02 18:28:17 +01:00
|
|
|
bool IsPower() const override;
|
|
|
|
bool IsNormal() const override;
|
2023-05-05 08:53:29 -04:00
|
|
|
|
2024-04-27 22:57:24 +03:00
|
|
|
bool GetShowPinNames() const override;
|
2024-04-28 12:51:02 +01:00
|
|
|
void SetShowPinNames( bool aShow ) override;
|
|
|
|
|
2024-04-27 22:57:24 +03:00
|
|
|
bool GetShowPinNumbers() const override;
|
2024-04-28 12:51:02 +01:00
|
|
|
void SetShowPinNumbers( bool aShow ) override;
|
2024-04-20 10:44:34 +01:00
|
|
|
|
2023-09-14 14:39:42 -07:00
|
|
|
double Similarity( const SCH_ITEM& aOther ) const override;
|
|
|
|
|
2025-02-06 09:47:00 -05:00
|
|
|
/// Return the component classes this symbol belongs in.
|
2024-09-27 20:48:12 +01:00
|
|
|
std::unordered_set<wxString> GetComponentClassNames( const SCH_SHEET_PATH* aPath ) const;
|
|
|
|
|
2023-09-14 14:39:42 -07:00
|
|
|
bool operator==( const SCH_ITEM& aOther ) const override;
|
|
|
|
|
2025-03-26 10:13:47 -04:00
|
|
|
protected:
|
|
|
|
void swapData( SCH_ITEM* aItem ) override;
|
|
|
|
|
2010-12-10 14:47:44 -05:00
|
|
|
private:
|
2022-08-31 00:28:18 +01:00
|
|
|
BOX2I doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const;
|
2021-09-23 22:07:19 +01:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
bool doIsConnected( const VECTOR2I& aPosition ) const override;
|
2021-03-25 17:13:01 -04:00
|
|
|
|
2022-01-01 01:04:08 -05:00
|
|
|
void Init( const VECTOR2I& pos = VECTOR2I( 0, 0 ) );
|
2021-03-25 17:13:01 -04:00
|
|
|
|
2024-04-20 10:44:34 +01:00
|
|
|
private:
|
2022-01-01 01:04:08 -05:00
|
|
|
VECTOR2I m_pos;
|
2021-03-25 17:13:01 -04:00
|
|
|
LIB_ID m_lib_id; ///< Name and library the symbol was loaded from, i.e. 74xx:74LS00.
|
2021-04-17 12:29:15 +01:00
|
|
|
wxString m_prefix; ///< C, R, U, Q etc - the first character(s) which typically
|
|
|
|
///< indicate what the symbol is. Determined, upon placement,
|
|
|
|
///< from the library symbol. Created upon file load, by the
|
|
|
|
///< first non-digits in the reference fields.
|
2021-03-25 17:13:01 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2024-04-18 10:58:39 +01:00
|
|
|
wxString m_schLibSymbolName;
|
2021-03-25 17:13:01 -04:00
|
|
|
|
2024-04-18 10:58:39 +01:00
|
|
|
std::vector<SCH_FIELD> m_fields; ///< Variable length list of fields.
|
2021-03-25 17:13:01 -04:00
|
|
|
|
2025-02-06 09:47:00 -05:00
|
|
|
std::unique_ptr<LIB_SYMBOL> m_part; ///< A flattened copy of the #LIB_SYMBOL from the
|
|
|
|
///< #PROJECT object's libraries.
|
2024-04-18 10:58:39 +01:00
|
|
|
bool m_isInNetlist; ///< True if the symbol should appear in netlist
|
2021-03-25 17:13:01 -04:00
|
|
|
|
2025-02-06 09:47:00 -05:00
|
|
|
std::vector<std::unique_ptr<SCH_PIN>> m_pins; ///< A #SCH_PIN for every #LIB_PIN.
|
|
|
|
std::unordered_map<SCH_PIN*, SCH_PIN*> m_pinMap; ///< Library pin pointer : #SCH_PIN indices.
|
2021-03-25 17:13:01 -04:00
|
|
|
|
2025-02-06 09:47:00 -05:00
|
|
|
/**
|
|
|
|
* Define the hierarchical path and reference of the symbol.
|
|
|
|
*
|
|
|
|
* This allows support for multiple references to a single sub-sheet.
|
|
|
|
*/
|
2024-04-18 10:58:39 +01:00
|
|
|
std::vector<SCH_SYMBOL_INSTANCE> m_instanceReferences;
|
2023-03-05 12:25:36 -05:00
|
|
|
|
|
|
|
/// @see SCH_SYMBOL::GetOrientation
|
|
|
|
static std::unordered_map<TRANSFORM, int> s_transformToOrientationCache;
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2024-04-02 18:28:17 +01:00
|
|
|
#endif /* SCH_SYMBOL_H */
|