41#include <unordered_map>
42#include <unordered_set>
57 std::set<const LIB_SYMBOL*> visited;
58 visited.insert( aSymbol );
60 std::shared_ptr<LIB_SYMBOL> current = aSymbol->
SharedPtr();
61 std::shared_ptr<LIB_SYMBOL> parent = aSymbol->
GetParent().lock();
65 if( visited.count( parent.get() ) )
73 chain += wxT(
" -> " ) + sym->GetName();
76 chain += wxT(
" -> " ) + parent->GetName() + wxT(
" (CYCLE)" );
79 wxT(
"%s: Circular inheritance detected in symbol '%s' (lib: %s). Chain: %s" ),
89 visited.insert( parent.get() );
91 parent = parent->GetParent().lock();
111 if( root.get() !=
this )
112 shownText = root->GetDescriptionField().GetShownText(
false, 0 );
138 std::function<bool( wxString* )> libSymbolResolver = [&]( wxString* token ) ->
bool
167 wxStringTokenizer keywordTokenizer(
GetShownKeyWords(),
" \t\r\n", wxTOKEN_STRTOK );
169 while( keywordTokenizer.HasMoreTokens() )
178 if( !footprint.IsEmpty() )
203 const wxString localizedKeywords =
_(
"Keywords" );
236 auto addField = [&](
FIELD_T id,
bool visible )
300 wxFAIL_MSG(
"Failed to clone SCH_ITEM." );
315 if( &aSymbol ==
this )
398 std::set<const LIB_SYMBOL*> visited;
399 visited.insert(
this );
401 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
406 if( visited.count( parent.get() ) )
409 wxT(
"GetInheritanceDepth: Circular inheritance detected in symbol '%s' "
415 visited.insert( parent.get() );
417 parent = parent->m_parent.lock();
426 std::set<const LIB_SYMBOL*> visited;
427 visited.insert(
this );
429 std::shared_ptr<LIB_SYMBOL> current =
m_me;
430 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
435 if( visited.count( parent.get() ) )
438 wxT(
"GetRootSymbol: Circular inheritance detected in symbol '%s' "
444 visited.insert( parent.get() );
446 parent = parent->m_parent.lock();
469 return aLabel ?
_(
"Alternate" ) : wxString(
_HKI(
"Alternate" ) );
471 return aLabel ?
_(
"Standard" ) : wxString(
_HKI(
"Standard" ) );
486 m_libId.SetLibItemName( aName );
512 std::set<const LIB_SYMBOL*> visited;
513 visited.insert(
this );
515 std::shared_ptr<LIB_SYMBOL> ancestor = aParent->
SharedPtr();
519 if( visited.count( ancestor.get() ) )
522 wxT(
"SetParent: Rejecting parent '%s' for symbol '%s' - would create "
523 "circular inheritance (lib: %s)" ),
530 visited.insert( ancestor.get() );
531 ancestor = ancestor->m_parent.lock();
552 return wxEmptyString;
560 std::unique_ptr<LIB_SYMBOL> retv;
565 std::vector<const LIB_SYMBOL*> parentChain;
566 std::set<const LIB_SYMBOL*> visited;
567 visited.insert(
this );
569 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
571 wxCHECK_MSG( parent, retv, wxString::Format(
"Parent of derived symbol '%s' undefined",
m_name ) );
576 if( visited.count( parent.get() ) )
579 wxT(
"Flatten: Circular inheritance detected in symbol '%s' (lib: %s)" ),
584 visited.insert( parent.get() );
585 parentChain.push_back( parent.get() );
586 parent = parent->m_parent.lock();
590 if( !parentChain.empty() )
592 retv = std::make_unique<LIB_SYMBOL>( *parentChain.back() );
595 for(
int i =
static_cast<int>( parentChain.size() ) - 2; i >= 0; --i )
603 *retv->GetField( fieldId ) = *derived->
GetField( fieldId );
621 retv->AddDrawItem( newField );
625 retv->RemoveDrawItem( parentField );
626 retv->AddDrawItem( newField );
640 retv = std::make_unique<LIB_SYMBOL>( *
this );
641 retv->m_parent.reset();
653 *retv->GetField( fieldId ) = *
GetField( fieldId );
672 retv->AddDrawItem( newField );
676 retv->RemoveDrawItem( parentField );
677 retv->AddDrawItem( newField );
691 retv->AddFile( newFile );
695 if( !parentChain.empty() )
697 retv->SetExcludedFromSim( parentChain.front()->GetExcludedFromSim() );
698 retv->SetExcludedFromBOM( parentChain.front()->GetExcludedFromBOM() );
699 retv->SetExcludedFromBoard( parentChain.front()->GetExcludedFromBoard() );
700 retv->SetExcludedFromPosFiles( parentChain.front()->GetExcludedFromPosFiles() );
708 retv->m_parent.reset();
712 retv = std::make_unique<LIB_SYMBOL>( *
this );
735 return m_libId.GetLibNickname();
745 if( root.get() !=
this )
746 return root->IsLocalPower();
759 if( root.get() !=
this )
761 root->SetLocalPower();
776 if( root.get() !=
this )
777 return root->IsGlobalPower();
796 if( root.get() !=
this )
798 root->SetGlobalPower();
813 if( root.get() !=
this )
814 return root->IsNormal();
827 if( root.get() !=
this )
848 u = ( aUnit - 1 ) % 26;
849 suffix = wxChar( aInitialLetter + u ) + suffix;
850 aUnit = ( aUnit - u ) / 26;
851 }
while( aUnit > 0 );
868 footprint = field.
GetShownText(
nullptr,
false, aDepth + 1 );
872 *token = field.
GetShownText(
nullptr,
false, aDepth + 1 );
879 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
880 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
881 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
883 *token = wxEmptyString;
887 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
889 wxArrayString parts = wxSplit( footprint,
':' );
891 if( parts.Count() > 0 )
894 *token = wxEmptyString;
898 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
900 wxArrayString parts = wxSplit( footprint,
':' );
902 if( parts.Count() > 1 )
903 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
905 *token = wxEmptyString;
909 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
911 *token =
m_libId.GetUniStringLibNickname();
914 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
916 *token =
m_libId.GetUniStringLibItemName();
919 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
924 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
929 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
934 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
939 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
944 else if( token->IsSameAs( wxT(
"DNP" ) ) )
946 *token = this->
GetDNP() ?
_(
"DNP" ) : wxString(
"" );
955 const VECTOR2I& aOffset,
bool aDimmed )
957 wxASSERT( aPlotter !=
nullptr );
972 color = color.
Mix( bg, 0.5f );
980 if( item.IsPrivate() )
988 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
991 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
994 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1000 int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
1002 wxASSERT( aPlotter !=
nullptr );
1014 color = color.
Mix( bg, 0.5f );
1028 wxString tmp = field.
GetText();
1031 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1040 std::vector<SCH_SHAPE*> potential_top_items;
1041 std::vector<SCH_ITEM*> bottom_items;
1050 potential_top_items.push_back( &shape );
1052 bottom_items.push_back( &item );
1056 bottom_items.push_back( &item );
1060 std::sort( potential_top_items.begin(), potential_top_items.end(),
1063 return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea();
1066 for(
SCH_SHAPE* item : potential_top_items )
1068 for(
SCH_ITEM* bottom_item : bottom_items )
1070 if( item->GetBoundingBox().Contains( bottom_item->GetBoundingBox() ) )
1082 wxASSERT( aItem !=
nullptr );
1088 if(
static_cast<SCH_FIELD*
>( aItem )->IsMandatory() )
1094 for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
1130 if( root.get() !=
this )
1131 return const_cast<const LIB_SYMBOL*
>( root.get() )->GetGraphicalPins( aUnit, aBodyStyle );
1134 std::vector<const SCH_PIN*> pins;
1146 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1150 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1153 pins.push_back(
static_cast<const SCH_PIN*
>( &item ) );
1166 if( root.get() !=
this )
1167 return root->GetGraphicalPins( aUnit, aBodyStyle );
1170 std::vector<SCH_PIN*> pins;
1182 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1186 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1189 pins.push_back(
static_cast<SCH_PIN*
>( &item ) );
1198 std::vector<UNIT_PIN_INFO> units;
1202 auto compareByPosition =
1206 VECTOR2I positionB = b->GetPosition();
1208 if( positionA.
x != positionB.
x )
1209 return positionA.
x < positionB.
x;
1211 return positionA.
y < positionB.
y;
1214 for(
int unitIdx = 1; unitIdx <= unitCount; ++unitIdx )
1221 std::sort( pinList.begin(), pinList.end(), compareByPosition );
1223 std::unordered_set<wxString> seenNumbers;
1225 for(
const SCH_PIN* basePin : pinList )
1227 bool stackedValid =
false;
1228 std::vector<wxString> expandedNumbers = basePin->GetStackedPinNumbers( &stackedValid );
1230 if( stackedValid && !expandedNumbers.empty() )
1232 for(
const wxString& number : expandedNumbers )
1234 if( seenNumbers.insert( number ).second )
1241 const wxString& number = basePin->GetNumber();
1243 if( !number.IsEmpty() && seenNumbers.insert( number ).second )
1247 units.push_back( std::move( unitInfo ) );
1256 std::vector<LOGICAL_PIN> out;
1261 std::vector<wxString> expanded =
pin->GetStackedPinNumbers( &valid );
1263 if( valid && !expanded.empty() )
1265 for(
const wxString& num : expanded )
1268 wxLogTrace(
traceStackedPins,
"GetLogicalPins: base='%s' -> '%s'",
pin->GetShownNumber(), num );
1274 wxLogTrace(
traceStackedPins,
"GetLogicalPins: base='%s' (no expansion)",
pin->GetShownNumber() );
1294 int pinCount =
pin->GetStackedPinCount();
1304 if( aNumber ==
pin->GetNumber() )
1314 std::vector<SCH_PIN*> pins;
1318 if( aNumber ==
pin->GetNumber() )
1319 pins.push_back(
pin );
1327 bool aTestOrientation,
bool aTestLength )
const
1332 bool foundMatch =
false;
1336 wxASSERT( otherPin );
1339 if(
pin->GetUnit() != otherPin->GetUnit() )
1343 if(
pin->GetBodyStyle() != otherPin->GetBodyStyle() )
1347 if(
pin->GetPosition() != otherPin->GetPosition() )
1351 if( aTestNums && (
pin->GetNumber() != otherPin->GetNumber() ) )
1355 if( aTestNames && (
pin->GetName() != otherPin->GetName() ) )
1359 if( aTestType && (
pin->GetType() != otherPin->GetType() ) )
1363 if( aTestOrientation && (
pin->GetOrientation() != otherPin->GetOrientation() ) )
1367 if( aTestLength && (
pin->GetLength() != otherPin->GetLength() ) )
1394 bool aIgnoreLabelsOnInvisiblePins )
const
1402 if( root.get() !=
this )
1403 bBox = root->GetUnitBoundingBox( aUnit, aBodyStyle, aIgnoreHiddenFields, aIgnoreLabelsOnInvisiblePins );
1408 if( item.m_unit > 0 &&
m_unitCount > 1 && aUnit > 0 && aUnit != item.m_unit )
1411 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
1414 if( aIgnoreHiddenFields && item.Type() ==
SCH_FIELD_T )
1416 if( !
static_cast<const SCH_FIELD&
>( item ).IsVisible() )
1420 if( item.Type() ==
SCH_PIN_T && !aIgnoreLabelsOnInvisiblePins )
1423 bBox.
Merge(
pin.GetBoundingBox(
true,
true,
false ) );
1427 bBox.
Merge( item.GetBoundingBox() );
1436 bool aIncludePrivateItems )
const
1442 if( item.m_unit > 0 && aUnit > 0 && aUnit != item.m_unit )
1445 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
1448 if( item.IsPrivate() && !aIncludePrivateItems )
1458 if(
pin.IsVisible() )
1464 bbox.
Merge(
pin.GetBoundingBox(
false,
false,
false ) );
1471 bbox.
Merge( item.GetBoundingBox() );
1507 for(
const SCH_FIELD& src : aFieldsList )
1535 aList.push_back(
const_cast<SCH_FIELD*
>( field ) );
1538 std::sort( aList.begin(), aList.end(),
1541 return lhs->GetOrdinal() < rhs->GetOrdinal();
1548 std::vector<SCH_FIELD*> orderedFields;
1553 aList.emplace_back( *field );
1562 ordinal = std::max( ordinal,
static_cast<const SCH_FIELD*
>( &item )->GetOrdinal() + 1 );
1574 if( field->
GetId() == aFieldType )
1588 if( field->
GetId() == aFieldType )
1602 if( field.
GetName() == aFieldName )
1616 if( field.
GetName() == aFieldName )
1655 wxASSERT( field !=
nullptr );
1663 wxASSERT( field !=
nullptr );
1671 wxASSERT( field !=
nullptr );
1679 wxASSERT( field !=
nullptr );
1687 wxASSERT( field !=
nullptr );
1696 refDesignator.Replace( wxS(
"~" ), wxS(
" " ) );
1698 wxString prefix = refDesignator;
1700 while( prefix.Length() )
1702 wxUniCharRef last = prefix.Last();
1704 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
1705 prefix.RemoveLast();
1711 prefix.Trim(
true );
1712 prefix.Trim(
false );
1728 item.Move( aOffset );
1748 if( root.get() !=
this )
1749 return root->HasLegacyAlternateBodyStyle();
1762 if( root.get() !=
this )
1763 return root->GetMaxPinNumber();
1766 int maxPinNumber = 0;
1771 long currentPinNumber = 0;
1773 if(
pin->GetNumber().ToLong( ¤tPinNumber ) )
1774 maxPinNumber = std::max( maxPinNumber, (
int) currentPinNumber );
1777 return maxPinNumber;
1786 item.ClearTempFlags();
1795 item.ClearEditFlags();
1803 if( ( aUnit && item.m_unit && aUnit != item.m_unit )
1804 || ( aBodyStyle && item.m_bodyStyle && aBodyStyle != item.m_bodyStyle )
1810 if( item.HitTest( aPoint ) )
1843 if( item.IsType( aScanTypes ) )
1859 wxCHECK_RET( aCount >= 1,
1860 wxString::Format( wxT(
"Invalid unit count %d, ignoring." ), aCount ) );
1874 if( it->m_unit > aCount )
1881 else if( aDuplicateDrawItems )
1888 std::vector<SCH_ITEM*> tmp;
1892 if( item.m_unit != 1 )
1895 for(
int j = prevCount + 1; j <= aCount; j++ )
1899 tmp.push_back( newItem );
1918 if( root.get() !=
this )
1919 return root->GetUnitCount();
1930 if( prevCount == aCount )
1934 if( prevCount < aCount )
1936 if( aDuplicateDrawItems || aDuplicatePins )
1938 std::vector<SCH_ITEM*> tmp;
1942 if( item.Type() !=
SCH_PIN_T && !aDuplicateDrawItems )
1945 if( item.m_bodyStyle == 1 )
1947 for(
int j = prevCount + 1; j <= aCount; j++ )
1951 tmp.push_back( newItem );
1968 if( i->m_bodyStyle > aCount )
1981 std::vector<SCH_ITEM*> unitItems;
1988 if( ( aBodyStyle == -1 && item.GetUnit() == aUnit ) || ( aUnit == -1 && item.GetBodyStyle() == aBodyStyle )
1989 || ( aUnit == item.GetUnit() && aBodyStyle == item.GetBodyStyle() ) )
1991 unitItems.push_back( &item );
2001 std::vector<LIB_SYMBOL_UNIT> units;
2008 int unit = item.GetUnit();
2009 int bodyStyle = item.GetBodyStyle();
2011 auto it = std::find_if( units.begin(), units.end(),
2014 return a.m_unit == unit && a.m_bodyStyle == bodyStyle;
2017 if( it == units.end() )
2020 newUnit.
m_unit = item.GetUnit();
2022 newUnit.
m_items.push_back( &item );
2023 units.emplace_back( newUnit );
2027 it->m_items.push_back( &item );
2035#define REPORT( msg ) \
2038 aReporter->Report( msg ); \
2040#define ITEM_DESC( item ) ( item )->GetItemDescription( &unitsProvider, false )
2069 REPORT(
_(
"Power flag differs." ) );
2078 REPORT(
_(
"Unit count differs." ) );
2086 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aShapes;
2087 std::set<const SCH_FIELD*> aFields;
2088 std::set<const SCH_PIN*> aPins;
2093 aShapes.insert( &( *it ) );
2095 aFields.insert(
static_cast<const SCH_FIELD*
>( &( *it ) ) );
2097 aPins.insert(
static_cast<const SCH_PIN*
>( &( *it ) ) );
2100 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bShapes;
2101 std::set<const SCH_FIELD*> bFields;
2102 std::set<const SCH_PIN*> bPins;
2107 bShapes.insert( &( *it ) );
2109 bFields.insert(
static_cast<const SCH_FIELD*
>( &( *it ) ) );
2111 bPins.insert(
static_cast<const SCH_PIN*
>( &( *it ) ) );
2114 if(
int tmp =
static_cast<int>( aShapes.size() - bShapes.size() ) )
2117 REPORT(
_(
"Graphic item count differs." ) );
2124 for(
auto aIt = aShapes.begin(), bIt = bShapes.begin(); aIt != aShapes.end(); aIt++, bIt++ )
2126 if(
int tmp2 = ( *aIt )->compare( *( *bIt ), aCompareFlags ) )
2129 REPORT( wxString::Format(
_(
"Graphic item differs: %s; %s." ),
ITEM_DESC( *aIt ),
2138 for(
const SCH_PIN* aPin : aPins )
2140 const SCH_PIN* bPin = aRhs.
GetPin( aPin->GetNumber(), aPin->GetUnit(), aPin->GetBodyStyle() );
2145 REPORT( wxString::Format(
_(
"Extra pin in schematic symbol: %s." ),
ITEM_DESC( aPin ) ) );
2150 else if(
int tmp = aPin->SCH_ITEM::compare( *bPin, aCompareFlags ) )
2153 REPORT( wxString::Format(
_(
"Pin %s differs: %s; %s" ), aPin->GetNumber(),
ITEM_DESC( aPin ),
2161 for(
const SCH_PIN* bPin : bPins )
2163 const SCH_PIN* aPin = aRhs.
GetPin( bPin->GetNumber(), bPin->GetUnit(), bPin->GetBodyStyle() );
2168 REPORT( wxString::Format(
_(
"Missing pin in schematic symbol: %s." ),
ITEM_DESC( bPin ) ) );
2175 for(
const SCH_FIELD* aField : aFields )
2179 if( aField->IsMandatory() )
2180 bField = aRhs.
GetField( aField->GetId() );
2182 bField = aRhs.
GetField( aField->GetName() );
2187 REPORT( wxString::Format(
_(
"Extra field in schematic symbol: %s." ),
ITEM_DESC( aField ) ) );
2201 tmp = aField->GetText().compare( bField->
GetText() );
2206 int fieldCompareFlags = aCompareFlags;
2214 tmp = aField->SCH_ITEM::compare( *bField, fieldCompareFlags );
2220 REPORT( wxString::Format(
_(
"Field '%s' differs: %s; %s." ), aField->GetName(
false ),
2229 for(
const SCH_FIELD* bField : bFields )
2233 if( bField->IsMandatory() )
2234 aField = aRhs.
GetField( bField->GetId() );
2236 aField = aRhs.
GetField( bField->GetName() );
2241 REPORT( wxString::Format(
_(
"Missing field in schematic symbol: %s." ),
ITEM_DESC( bField ) ) );
2251 REPORT(
_(
"Footprint filter count differs." ) );
2258 for(
size_t i = 0; i <
m_fpFilters.GetCount(); i++ )
2263 REPORT(
_(
"Footprint filters differ." ) );
2274 REPORT(
_(
"Pin map count differs." ) );
2282 REPORT(
_(
"Pin maps differ." ) );
2291 REPORT(
_(
"Associated footprint count differs." ) );
2299 REPORT(
_(
"Associated footprints differ." ) );
2308 REPORT(
_(
"Symbol keywords differ." ) );
2317 REPORT(
_(
"Symbol pin name offsets differ." ) );
2328 REPORT(
_(
"Show pin names settings differ." ) );
2337 REPORT(
_(
"Show pin numbers settings differ." ) );
2346 REPORT(
_(
"Exclude from simulation settings differ." ) );
2355 REPORT(
_(
"Exclude from bill of materials settings differ." ) );
2364 REPORT(
_(
"Exclude from board settings differ." ) );
2373 REPORT(
_(
"Exclude from position files settings differ." ) );
2409 return Compare( *tmp, aCompareFlags );
2418 double similarity = 0.0;
2427 double max_similarity = 0.0;
2431 double temp_similarity = item.Similarity( otherItem );
2432 max_similarity = std::max( max_similarity, temp_similarity );
2434 if( max_similarity == 1.0 )
2438 similarity += max_similarity;
2444 double max_similarity = 0.0;
2448 double temp_similarity =
pin->Similarity( *otherPin );
2449 max_similarity = std::max( max_similarity, temp_similarity );
2451 if( max_similarity == 1.0 )
2455 similarity += max_similarity;
2458 if( totalItems == 0 )
2461 similarity /= totalItems;
2513 std::set<const LIB_SYMBOL*> visited;
2514 visited.insert(
this );
2516 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
2521 if( visited.count( parent.get() ) )
2524 wxT(
"AppendParentEmbeddedFiles: Circular inheritance detected in "
2525 "symbol '%s' (lib: %s)" ),
2530 visited.insert( parent.get() );
2531 aStack.push_back( parent->GetEmbeddedFiles() );
2532 parent = parent->GetParent().lock();
2541 std::set<KIFONT::OUTLINE_FONT*>
fonts;
2549 if(
auto* font =
text.GetFont(); font && !font->IsStroke() )
2554 if( permission == EMBEDDING_PERMISSION::EDITABLE || permission == EMBEDDING_PERMISSION::INSTALLABLE )
2556 fonts.insert( outline );
2582 if(
group.contains( aPinNumber ) )
2586 return std::nullopt;
2597 const wxString groupFields =
_HKI(
"Fields" );
2615 const wxString groupSymbolDef =
_HKI(
"Symbol Definition" );
2626 const wxString groupPinDisplay =
_HKI(
"Pin Display" );
2642 const wxString groupAttributes =
_HKI(
"Attributes" );
2661 const wxString groupUnits =
_HKI(
"Units and Body Styles" );
2671 auto multiBodyStyle = [=](
INSPECTABLE* aItem ) ->
bool
2674 return symbol->IsMultiBodyStyle();
2686 wxPGChoices choices;
2690 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
2691 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
static const COLOR4D WHITE
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
virtual void ClearEditFlags()
KICAD_T Type() const
Returns the type of object.
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM_FLAGS GetFlags() const
virtual void ClearTempFlags()
FILL_T GetFillMode() const
virtual bool IsVisible() const
virtual void SetVisible(bool aVisible)
EMBEDDED_FILES & operator=(EMBEDDED_FILES &&other) noexcept
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
const std::map< wxString, std::shared_ptr< EMBEDDED_FILE > > & EmbeddedFileMap() const
Provide an iterable view of the file collection.
Class that other classes need to inherit from, in order to be inspectable.
Class OUTLINE_FONT implements outline font drawing.
EMBEDDING_PERMISSION GetEmbeddingPermission() const
A color representation with 4 components: red, green, blue, alpha.
std::shared_ptr< wxString > m_text
COLOR4D & Desaturate()
Removes color (in HSL model)
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Object used to load, save, search, and otherwise manipulate symbol library files.
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Define a library symbol object.
LIB_ITEMS_CONTAINER m_drawings
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
SCH_FIELD & GetDescriptionField()
Return reference to the description field.
const LIB_ID & GetLibId() const override
const BOX2I GetUnitBoundingBox(int aUnit, int aBodyStyle, bool aIgnoreHiddenFields=true, bool aIgnoreLabelsOnInvisiblePins=true) const
Get the bounding box for the symbol.
wxString GetKeyWords() const override
std::weak_ptr< LIB_SYMBOL > & GetParent()
wxString GetBodyStyleProp() const override
LIBRENTRYOPTIONS m_options
Special symbol features such as POWER or NORMAL.
wxString GetRefProp() const
bool PinsConflictWith(const LIB_SYMBOL &aOtherSymbol, bool aTestNums, bool aTestNames, bool aTestType, bool aTestOrientation, bool aTestLength) const
Return true if this symbol's pins do not match another symbol's pins.
bool GetUnitsInterchangeableProp() const
wxString m_shownDescriptionCache
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void GetFields(std::vector< SCH_FIELD * > &aList, bool aVisibleOnly=false) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
bool IsPower() const override
wxString GetShownKeyWords(int aDepth=0) const override
const std::vector< ASSOCIATED_FOOTPRINT > & GetEffectiveAssociatedFootprints() const
SCH_FIELD & GetDatasheetField()
Return reference to the datasheet field.
void RefreshLibraryTreeCaches()
std::weak_ptr< LIB_SYMBOL > m_parent
Use for inherited symbols.
void SetExcludedFromBoardProp(bool aExclude)
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of SCH_ITEM objects separated by unit and convert number.
std::map< int, wxString > m_unitDisplayNames
std::vector< std::set< wxString > > m_jumperPinGroups
A list of jumper pin groups, each of which is a set of pin numbers that should be jumpered together (...
void ClearTempFlags() override
Clears the status flag all draw objects in this symbol.
void SetKeywordsProp(const wxString &aKeywords)
std::map< int, wxString > & GetUnitDisplayNames()
bool m_demorgan
True if there are two body styles: normal and De Morgan If false, the body style count is taken from ...
wxString GetFootprint() override
For items with footprint fields.
const wxString GetLibraryName() const
void SetFields(const std::vector< SCH_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
void SetExcludedFromPosFilesProp(bool aExclude)
void SetLib(LEGACY_SYMBOL_LIB *aLibrary)
bool GetPowerSymbolProp() const
bool IsMultiBodyStyle() const override
int GetMaxPinNumber() const
std::vector< SEARCH_TERM > m_searchTermsCache
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
SCH_FIELD * GetField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName; return nullptr if not found.
SCH_FIELD & GetFootprintField()
Return reference to the footprint field.
int Compare(const LIB_SYMBOL &aRhs, int aCompareFlags=0, REPORTER *aReporter=nullptr) const
Comparison test that can be used for operators.
void FixupDrawItems()
This function finds the filled draw items that are covering up smaller draw items and replaces their ...
bool IsNormal() const override
void SetUnitsInterchangeableProp(bool aInterchangeable)
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
LEGACY_SYMBOL_LIB * m_library
bool GetExcludedFromPosFilesProp() const
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
wxString m_keyWords
Search keywords.
SCH_ITEM * LocateDrawItem(int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I &aPoint)
Locate a draw object.
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
double Similarity(const SCH_ITEM &aSymbol) const override
Return a measure of similarity between this symbol and aSymbol.
static LIB_SYMBOL * GetDummy()
Returns a dummy LIB_SYMBOL, used when one is missing in the schematic.
void PlotFields(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed)
Plot symbol fields.
wxString GetDatasheetProp() const
std::shared_ptr< LIB_SYMBOL > GetRootSymbol() const
Get the parent symbol that does not have another parent.
void SetRefProp(const wxString &aRef)
void SetParent(LIB_SYMBOL *aParent=nullptr)
std::vector< UNIT_PIN_INFO > GetUnitPinInfo() const
Return pin-number lists for each unit, ordered consistently for gate swapping.
wxString GetName() const override
void SetUnitCount(int aCount, bool aDuplicateDrawItems)
Set the units per symbol count.
void SetDescription(const wxString &aDescription)
Gets the Description field text value */.
void cacheChooserFields()
std::shared_ptr< LIB_SYMBOL > m_me
wxString GetValueProp() const
bool GetExcludedFromBOMProp() const
void SetKeyWords(const wxString &aKeyWords)
SCH_FIELD & GetValueField()
Return reference to the value field.
bool IsLocalPower() const override
LIB_SYMBOL(const wxString &aName, LIB_SYMBOL *aParent=nullptr, LEGACY_SYMBOL_LIB *aLibrary=nullptr)
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
void GetChooserFields(std::map< wxString, wxString > &aColumnMap) override
Retrieves a key/value map of the fields on this item that should be exposed to the library browser/ch...
bool HasLegacyAlternateBodyStyle() const
Before V10 we didn't store the number of body styles in a symbol – we just looked through all its dra...
std::shared_ptr< LIB_SYMBOL > SharedPtr() const
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared.
bool GetPinNamesInsideProp() const
const std::vector< wxString > & GetBodyStyleNames() const
void SetBodyStyleProp(const wxString &aBodyStyle) override
int compare(const SCH_ITEM &aOther, int aCompareFlags=SCH_ITEM::COMPARE_FLAGS::EQUALITY) const override
The library symbol specific sort order is as follows:
timestamp_t m_lastModDate
void SetExcludedFromSimProp(bool aExclude)
bool GetExcludedFromBoardProp() const
std::optional< const std::set< wxString > > GetJumperPinGroup(const wxString &aPinNumber) const
Retrieves the jumper group containing the specified pin number, if one exists.
std::vector< SCH_PIN * > GetPins() const override
void SetBodyStyleCount(int aCount, bool aDuplicateDrawItems, bool aDuplicatePins)
Set or clear the alternate body style (DeMorgan) for the symbol.
wxString GetLibNickname() const override
Sets the Description field text value.
void SetFootprintProp(const wxString &aFootprint)
std::vector< LOGICAL_PIN > GetLogicalPins(int aUnit, int aBodyStyle) const
Return all logical pins (expanded) filtered by unit/body.
bool HasDeMorganBodyStyles() const override
const LIB_SYMBOL & operator=(const LIB_SYMBOL &aSymbol)
bool m_unitsLocked
True if symbol has multiple units and changing one unit does not automatically change another unit.
wxArrayString m_fpFilters
List of suitable footprint names for the symbol (wild card names accepted).
void Move(const VECTOR2I &aOffset) override
Move the symbol aOffset.
const PIN_MAP_SET & GetEffectivePinMaps() const
void CopyFields(std::vector< SCH_FIELD > &aList)
Create a copy of the SCH_FIELDs, sorted in ordinal order.
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
bool GetExcludedFromSimProp() const
int GetBodyStyleCount() const override
void SetDatasheetProp(const wxString &aDatasheet)
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
EMBEDDED_FILES * GetEmbeddedFiles() override
void SetPowerSymbolProp(bool aIsPower)
void SetExcludedFromBOMProp(bool aExclude)
int m_unitCount
Number of units (parts) per package.
wxString GetShownDescription(int aDepth=0) const override
bool IsGlobalPower() const override
wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const override
unsigned GetInheritanceDepth() const
Get the number of parents for this symbol.
int GetUnitCount() const override
PIN_MAP_SET m_pinMaps
Named pin-to-pad maps owned by this symbol (issue #2282).
wxString GetKeywordsProp() const
std::vector< wxString > m_bodyStyleNames
void AppendParentEmbeddedFiles(std::vector< EMBEDDED_FILES * > &aStack) const
std::vector< SCH_PIN * > GetPinsByNumber(const wxString &aNumber, int aUnit=0, int aBodyStyle=0)
Return all pin objects with the requested pin aNumber.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
BOX2I GetBodyBoundingBox() const override
Return a bounding box for the symbol body but not the pins or fields.
void SetValueProp(const wxString &aValue)
int GetPinCount() override
std::map< wxString, wxString > m_chooserFieldsCache
void SetLibId(const LIB_ID &aLibId)
void AddField(SCH_FIELD *aField)
Add a field.
void ClearEditFlags() override
bool GetLocalPowerSymbolProp() const
LIB_ID GetLIB_ID() const override
std::vector< ASSOCIATED_FOOTPRINT > m_associatedFootprints
Footprints associated with this symbol, each tied to a named pin map.
const SCH_PIN * GetPin(const wxString &aNumber, int aUnit=0, int aBodyStyle=0) const
Return pin object with the requested pin aNumber.
bool m_duplicatePinNumbersAreJumpers
Flag that this symbol should automatically treat sets of two or more pins with the same number as jum...
void SetUnitProp(int aUnits)
wxString GetFootprintProp() const
void SetPinNamesInsideProp(bool aInside)
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
wxString m_parentName
The name of the parent symbol or empty if root symbol.
void EmbedFonts() override
void SetLocalPowerSymbolProp(bool aIsLocalPower)
virtual void SetName(const wxString &aName)
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
void cacheShownDescription()
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this symbol.
static constexpr int FIRST_TYPE
ITERATOR_BASE< SCH_ITEM, MULTIVECTOR< SCH_ITEM, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::iterator > ITERATOR
ITERATOR end(int aType=UNDEFINED_TYPE)
static constexpr int LAST_TYPE
ITERATOR begin(int aType=UNDEFINED_TYPE)
const std::vector< PIN_MAP > & GetAll() const
Base plotter engine class.
bool GetColorMode() const
virtual void SetColor(const COLOR4D &color)=0
PROPERTY_BASE & SetChoicesFunc(std::function< wxPGChoices(INSPECTABLE *)> aFunc)
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
A pure virtual class used to derive REPORTER objects from.
wxString GetFullText(int unit=1) const
Return the text of a field.
virtual const wxString & GetText() const override
Return the string associated with the text object.
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0, const wxString &aVariantName=wxEmptyString) const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
bool ShowInChooser() const
void SetText(const wxString &aText) override
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
VECTOR2I GetPosition() const override
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
A base class for LIB_SYMBOL and SCH_SYMBOL.
bool m_excludedFromPosFiles
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
int GetPinNameOffset() const
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
virtual bool GetShowPinNames() const
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
SYMBOL & operator=(const SYMBOL &aItem)
virtual bool GetShowPinNumbers() const
int m_pinNameOffset
The offset in mils to draw the pin name.
wxString ResolveTextVars(const wxString &aSource, const std::function< bool(wxString *)> *aResolver, int &aDepth)
Multi-pass text variable expansion and math expression evaluation.
#define DEFAULT_PIN_NAME_OFFSET
The intersheets references prefix string.
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
#define IGNORE_PARENT_GROUP
#define IS_NEW
New item, just created.
#define STRUCT_DELETED
flag indication structures to be erased
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
@ FILLED_WITH_BG_BODYCOLOR
TRANSFORM DefaultTransform
const wxChar *const traceSymbolInheritance
Flag to enable tracing of circular symbol inheritance detection.
const wxChar *const traceStackedPins
Flag to enable debug output for stacked pins handling in symbol/pin code.
static std::shared_ptr< LIB_SYMBOL > GetSafeRootSymbol(const LIB_SYMBOL *aSymbol, const char *aCallerName)
Helper to safely get the root symbol, detecting and logging circular inheritance.
static struct LIB_SYMBOL_DESC _LIB_SYMBOL_DESC
bool operator<(const LIB_SYMBOL &aItem1, const LIB_SYMBOL &aItem2)
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
@ PT_SIZE
Size expressed in distance units (mm/inch)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Logical pins: Return expanded logical pins based on stacked-pin notation.
std::vector< wxString > m_pinNumbers
int m_bodyStyle
The alternate body style of the unit.
std::vector< SCH_ITEM * > m_items
The items unique to this unit and alternate body style.
int m_unit
The unit number.
A structure for storing weighted search terms.
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
void operator()(void const *) const
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
const SHAPE_LINE_CHAIN chain
wxLogTrace helper definitions.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I