29#include <unordered_map>
30#include <unordered_set>
50#include <api/schematic/schematic_types.pb.h>
70 std::set<const LIB_SYMBOL*> visited;
71 visited.insert( aSymbol );
73 std::shared_ptr<LIB_SYMBOL> current = aSymbol->
SharedPtr();
74 std::shared_ptr<LIB_SYMBOL> parent = aSymbol->
GetParent().lock();
78 if( visited.count( parent.get() ) )
86 chain += wxT(
" -> " ) + sym->GetName();
89 chain += wxT(
" -> " ) + parent->GetName() + wxT(
" (CYCLE)" );
92 wxT(
"%s: Circular inheritance detected in symbol '%s' (lib: %s). Chain: %s" ),
102 visited.insert( parent.get() );
104 parent = parent->GetParent().lock();
119 if( root.get() !=
this )
120 shownText = root->GetDescriptionField().GetShownText( aContext, aDepth );
165 const wxString localizedKeywords =
_(
"Keywords" );
177 int pinCount =
pin->GetStackedPinCount();
194 while( keywordTokenizer.HasMoreTokens() )
206 if( !footprint.IsEmpty() )
232 std::function<bool( wxString* )> libSymbolResolver =
233 [&]( wxString* token ) ->
bool
289 [&](
FIELD_T id,
bool visible )
352 wxFAIL_MSG(
"Failed to clone SCH_ITEM." );
367 SchematicSymbol& def = aOutput;
371 SchematicSymbolType symbolType = SchematicSymbolType::SST_NORMAL;
374 symbolType = SchematicSymbolType::SST_GLOBAL_POWER;
376 symbolType = SchematicSymbolType::SST_LOCAL_POWER;
378 def.set_type( symbolType );
380 SchematicSymbolAttributes* attributes = def.mutable_attributes();
385 attributes->set_do_not_populate(
GetDNP() );
398 if( aSkipPins && drawItem.Type() ==
SCH_PIN_T )
401 SchematicSymbolChild* item = def.add_items();
402 item->mutable_unit()->set_unit( drawItem.GetUnit() );
403 item->mutable_body_style()->set_style( drawItem.GetBodyStyle() );
404 item->set_is_private( drawItem.IsPrivate() );
405 drawItem.Serialize( *item->mutable_item() );
416 def.add_footprint_filters(
filter.ToUTF8() );
418 JumperSettings* jumpers = def.mutable_jumpers();
423 JumperGroup* jumperGroup = jumpers->add_groups();
425 for(
const wxString& pinNumber :
group.GetNames() )
426 jumperGroup->add_pin_numbers( pinNumber.ToUTF8() );
441 PackLibId( def.mutable_extends(), parentId );
446 SchematicUnitDisplayName* protoName = def.add_unit_display_names();
447 protoName->set_unit( unit );
451 SymbolPinMaps* pinMaps = def.mutable_pin_maps();
455 AssociatedFootprint* a = pinMaps->add_associated_footprints();
456 PackLibId( a->mutable_footprint(), assoc.m_FootprintLibId );
457 a->set_map_name( assoc.m_MapName.ToUTF8() );
462 PinMap* m = pinMaps->add_pin_maps();
463 m->set_name( map.GetName().ToUTF8() );
467 PinMapEntry* e = m->add_entries();
468 e->set_pin_number( entry.m_PinNumber.ToUTF8() );
469 e->set_pad_number( entry.m_PadNumber.ToUTF8() );
477 kiapi::schematic::types::SchematicSymbol def;
480 if( !aContainer.PackFrom( def ) )
481 wxFAIL_MSG( wxT(
"Failed to pack LIB_SYMBOL" ) );
491 const SchematicSymbol& def = aInput;
498 case SchematicSymbolType::SST_GLOBAL_POWER:
SetGlobalPower();
break;
499 case SchematicSymbolType::SST_LOCAL_POWER:
SetLocalPower();
break;
503 if( def.has_attributes() )
509 SetDNP( def.attributes().do_not_populate() );
518 for(
const SchematicSymbolChild& child : def.items() )
527 if( !item || !item->Deserialize( child.item() ) )
532 if( child.has_unit() )
533 schItem->
SetUnit( child.unit().unit() );
535 if( child.has_body_style() )
543 if( def.unit_count() > 0 )
546 if( def.body_style_size() > 0 )
548 std::vector<wxString> bodyStyleNames;
550 for(
const SchematicBodyStyle& bodyStyle : def.body_style() )
551 bodyStyleNames.emplace_back( wxString::FromUTF8( bodyStyle.name() ) );
557 if( !def.keywords().empty() )
558 SetKeyWords( wxString::FromUTF8( def.keywords() ) );
560 if( def.footprint_filters_size() > 0 )
564 for(
const std::string&
filter : def.footprint_filters() )
573 jumperGroups.
Clear();
575 for(
const JumperGroup&
group : def.jumpers().groups() )
577 std::set<wxString> pinNumbers;
579 for(
const std::string& pinNumber :
group.pin_numbers() )
580 pinNumbers.insert( wxString::FromUTF8( pinNumber ) );
582 jumperGroups.
Add( std::move( pinNumbers ) );
588 for(
const SchematicUnitDisplayName&
displayName : def.unit_display_names() )
594 if( def.has_pin_name_offset() )
597 if( def.has_extends() )
598 SetParentName( wxString::FromUTF8( def.extends().entry_name() ) );
600 if( def.has_pin_maps() )
604 for(
const PinMap& map : def.pin_maps().pin_maps() )
606 PIN_MAP pinMap( wxString::FromUTF8( map.name() ) );
608 for(
const PinMapEntry& entry : map.entries() )
610 pinMap.
SetEntry( wxString::FromUTF8( entry.pin_number() ), wxString::FromUTF8( entry.pad_number() ) );
616 std::vector<ASSOCIATED_FOOTPRINT> associatedFootprints;
618 for(
const AssociatedFootprint& footprint : def.pin_maps().associated_footprints() )
622 assoc.
m_MapName = wxString::FromUTF8( footprint.map_name() );
623 associatedFootprints.push_back( std::move( assoc ) );
637 kiapi::schematic::types::SchematicSymbol def;
639 if( !aContainer.UnpackTo( &def ) )
648 if( &aSymbol ==
this )
729 std::set<const LIB_SYMBOL*> visited;
730 visited.insert(
this );
732 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
737 if( visited.count( parent.get() ) )
740 wxT(
"GetInheritanceDepth: Circular inheritance detected in symbol '%s' "
746 visited.insert( parent.get() );
748 parent = parent->m_parent.lock();
757 std::set<const LIB_SYMBOL*> visited;
758 visited.insert(
this );
760 std::shared_ptr<LIB_SYMBOL> current =
m_me;
761 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
766 if( visited.count( parent.get() ) )
769 wxT(
"GetRootSymbol: Circular inheritance detected in symbol '%s' "
775 visited.insert( parent.get() );
777 parent = parent->m_parent.lock();
790 if( root.get() !=
this )
791 return root->m_unitsLocked;
801 std::shared_ptr<LIB_SYMBOL> root;
823 return aLabel ?
_(
"Alternate" ) : wxString(
_HKI(
"Alternate" ) );
825 return aLabel ?
_(
"Standard" ) : wxString(
_HKI(
"Standard" ) );
833 return names[aBodyStyle - 1];
843 m_libId.SetLibItemName( aName );
862 std::set<const LIB_SYMBOL*> visited;
863 visited.insert(
this );
865 std::shared_ptr<LIB_SYMBOL> ancestor = aParent->
SharedPtr();
869 if( visited.count( ancestor.get() ) )
872 "- would create circular inheritance (lib: %s)" ),
879 visited.insert( ancestor.get() );
880 ancestor = ancestor->m_parent.lock();
905 return wxEmptyString;
911 if( std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock() )
912 return parent->GetFootprint();
921 std::unique_ptr<LIB_SYMBOL> retv;
926 std::vector<const LIB_SYMBOL*> parentChain;
927 std::set<const LIB_SYMBOL*> visited;
928 visited.insert(
this );
930 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
932 wxCHECK_MSG( parent, retv, wxString::Format(
"Parent of derived symbol '%s' undefined",
m_name ) );
937 if( visited.count( parent.get() ) )
940 wxT(
"Flatten: Circular inheritance detected in symbol '%s' (lib: %s)" ),
945 visited.insert( parent.get() );
946 parentChain.push_back( parent.get() );
947 parent = parent->m_parent.lock();
951 if( !parentChain.empty() )
953 retv = std::make_unique<LIB_SYMBOL>( *parentChain.back() );
956 for(
int i =
static_cast<int>( parentChain.size() ) - 2; i >= 0; --i )
964 *retv->GetField( fieldId ) = *derived->
GetField( fieldId );
982 retv->AddDrawItem( newField );
986 retv->RemoveDrawItem( parentField );
987 retv->AddDrawItem( newField );
1001 retv = std::make_unique<LIB_SYMBOL>( *
this );
1002 retv->m_parent.reset();
1014 *retv->GetField( fieldId ) = *
GetField( fieldId );
1033 retv->AddDrawItem( newField );
1037 retv->RemoveDrawItem( parentField );
1038 retv->AddDrawItem( newField );
1056 retv->AddFile( newFile );
1059 for(
const LIB_SYMBOL* ancestor : parentChain )
1061 for(
const auto& [
name, file] : ancestor->EmbeddedFileMap() )
1064 retv->AddFile( newFile );
1071 if( !parentChain.empty() )
1073 retv->SetExcludedFromSim( parentChain.back()->GetExcludedFromSim() );
1074 retv->SetExcludedFromBOM( parentChain.back()->GetExcludedFromBOM() );
1075 retv->SetExcludedFromBoard( parentChain.back()->GetExcludedFromBoard() );
1076 retv->SetExcludedFromPosFiles( parentChain.back()->GetExcludedFromPosFiles() );
1084 retv->m_cachesDirty =
true;
1085 retv->m_parent.reset();
1089 retv = std::make_unique<LIB_SYMBOL>( *
this );
1109 return m_libId.GetLibNickname();
1119 if( root.get() !=
this )
1120 return root->IsLocalPower();
1133 if( root.get() !=
this )
1135 root->SetLocalPower();
1152 if( root.get() !=
this )
1153 return root->IsGlobalPower();
1172 if( root.get() !=
this )
1174 root->SetGlobalPower();
1191 if( root.get() !=
this )
1192 return root->IsNormal();
1205 if( root.get() !=
this )
1228 u = ( aUnit - 1 ) % 26;
1229 suffix = wxChar( aInitialLetter + u ) + suffix;
1230 aUnit = ( aUnit - u ) / 26;
1231 }
while( aUnit > 0 );
1259 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
1260 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
1261 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
1263 *token = wxEmptyString;
1267 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
1269 wxArrayString parts = wxSplit( footprint,
':' );
1271 if( parts.Count() > 0 )
1274 *token = wxEmptyString;
1278 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
1280 wxArrayString parts = wxSplit( footprint,
':' );
1282 if( parts.Count() > 1 )
1283 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
1285 *token = wxEmptyString;
1289 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
1291 *token =
m_libId.GetUniStringLibNickname();
1294 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
1296 *token =
m_libId.GetUniStringLibItemName();
1299 else if( token->IsSameAs( wxT(
"SYMBOL_PARENT" ) ) )
1301 std::shared_ptr<LIB_SYMBOL> parent =
GetParent().lock();
1302 *token = parent ? parent->GetName() : wxString();
1305 else if( token->IsSameAs( wxT(
"SYMBOL_ROOT" ) ) )
1308 *token = root ? root->GetName() :
GetName();
1311 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
1316 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
1321 else if( token->IsSameAs( wxT(
"SYMBOL_IS_POWER" ) ) )
1323 *token = this->
IsPower() ? wxString( wxS(
"Power Symbol" ) ) : wxString(
"" );
1326 else if( token->IsSameAs( wxT(
"SYMBOL_IS_LOCAL_POWER" ) ) )
1328 *token = this->
IsLocalPower() ? wxString( wxS(
"Local Power Symbol" ) ) : wxString(
"" );
1331 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
1336 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
1341 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
1343 *token = this->
GetExcludedFromSim() ? wxS(
"Excluded from simulation" ) : wxEmptyString;
1346 else if( token->IsSameAs( wxT(
"DNP" ) ) )
1348 *token = this->
GetDNP() ? wxS(
"DNP" ) : wxEmptyString;
1357 const VECTOR2I& aOffset,
bool aDimmed )
1359 wxASSERT( aPlotter !=
nullptr );
1374 color = color.
Mix( bg, 0.5f );
1382 if( item.IsPrivate() )
1390 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1393 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1396 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1402 int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
1404 wxASSERT( aPlotter !=
nullptr );
1416 color = color.
Mix( bg, 0.5f );
1430 wxString tmp = field.
GetText();
1433 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1442 std::vector<SCH_SHAPE*> potential_top_items;
1443 std::vector<SCH_ITEM*> bottom_items;
1452 potential_top_items.push_back( &shape );
1454 bottom_items.push_back( &item );
1458 bottom_items.push_back( &item );
1462 std::sort( potential_top_items.begin(), potential_top_items.end(),
1465 return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea();
1468 for(
SCH_SHAPE* item : potential_top_items )
1470 for(
SCH_ITEM* bottom_item : bottom_items )
1472 if( item->GetBoundingBox().Contains( bottom_item->GetBoundingBox() ) )
1484 wxASSERT( aItem !=
nullptr );
1490 if(
static_cast<SCH_FIELD*
>( aItem )->IsMandatory() )
1496 for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
1530 if( root.get() !=
this )
1531 return const_cast<const LIB_SYMBOL*
>( root.get() )->GetGraphicalPins( aUnit, aBodyStyle );
1534 std::vector<SCH_PIN*> pins;
1546 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1550 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1553 pins.push_back(
static_cast<SCH_PIN*
>(
const_cast<SCH_ITEM*
>( &item ) ) );
1562 std::vector<UNIT_PIN_INFO> units;
1566 auto compareByPosition =
1570 VECTOR2I positionB = b->GetPosition();
1572 if( positionA.
x != positionB.
x )
1573 return positionA.
x < positionB.
x;
1575 return positionA.
y < positionB.
y;
1578 for(
int unitIdx = 1; unitIdx <= unitCount; ++unitIdx )
1585 std::sort( pinList.begin(), pinList.end(), compareByPosition );
1587 std::unordered_set<wxString> seenNumbers;
1589 for(
const SCH_PIN* basePin : pinList )
1591 bool stackedValid =
false;
1592 std::vector<wxString> expandedNumbers = basePin->GetStackedPinNumbers( &stackedValid );
1594 if( stackedValid && !expandedNumbers.empty() )
1596 for(
const wxString& number : expandedNumbers )
1598 if( seenNumbers.insert( number ).second )
1605 const wxString& number = basePin->GetNumber();
1607 if( !number.IsEmpty() && seenNumbers.insert( number ).second )
1611 units.push_back( std::move( unitInfo ) );
1620 std::vector<LOGICAL_PIN> out;
1625 std::vector<wxString> expanded =
pin->GetStackedPinNumbers( &valid );
1627 if( valid && !expanded.empty() )
1629 for(
const wxString& num : expanded )
1632 wxLogTrace(
traceStackedPins,
"GetLogicalPins: base='%s' -> '%s'",
pin->GetShownNumber(), num );
1638 wxLogTrace(
traceStackedPins,
"GetLogicalPins: base='%s' (no expansion)",
pin->GetShownNumber() );
1659 if( aNumber ==
pin->GetNumber() )
1669 std::vector<SCH_PIN*> pins;
1673 if( aNumber ==
pin->GetNumber() )
1674 pins.push_back(
pin );
1688 for(
const wxString& logicalNumber :
pin->GetStackedPinNumbers() )
1690 if( aNumber == logicalNumber )
1700 bool aTestOrientation,
bool aTestLength )
const
1705 bool foundMatch =
false;
1709 wxASSERT( otherPin );
1712 if(
pin->GetUnit() != otherPin->GetUnit() )
1716 if(
pin->GetBodyStyle() != otherPin->GetBodyStyle() )
1720 if(
pin->GetPosition() != otherPin->GetPosition() )
1724 if( aTestNums && (
pin->GetNumber() != otherPin->GetNumber() ) )
1728 if( aTestNames && (
pin->GetName() != otherPin->GetName() ) )
1732 if( aTestType && (
pin->GetType() != otherPin->GetType() ) )
1736 if( aTestOrientation && (
pin->GetOrientation() != otherPin->GetOrientation() ) )
1740 if( aTestLength && (
pin->GetLength() != otherPin->GetLength() ) )
1760 bool aIgnoreLabelsOnInvisiblePins )
const
1768 if( root.get() !=
this )
1769 bBox = root->GetUnitBoundingBox( aUnit, aBodyStyle, aIgnoreHiddenFields, aIgnoreLabelsOnInvisiblePins );
1774 if( item.m_unit > 0 &&
m_unitCount > 1 && aUnit > 0 && aUnit != item.m_unit )
1777 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
1780 if( aIgnoreHiddenFields && item.Type() ==
SCH_FIELD_T )
1782 if( !
static_cast<const SCH_FIELD&
>( item ).IsVisible() )
1786 if( item.Type() ==
SCH_PIN_T && !aIgnoreLabelsOnInvisiblePins )
1789 bBox.
Merge(
pin.GetBoundingBox(
true,
true,
false ) );
1793 bBox.
Merge( item.GetBoundingBox() );
1802 bool aIncludePrivateItems )
const
1808 if( item.m_unit > 0 && aUnit > 0 && aUnit != item.m_unit )
1811 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
1814 if( item.IsPrivate() && !aIncludePrivateItems )
1824 if(
pin.IsVisible() )
1830 bbox.
Merge(
pin.GetBoundingBox(
false,
false,
false ) );
1837 bbox.
Merge( item.GetBoundingBox() );
1868 for(
const SCH_FIELD& src : aFieldsList )
1894 aList.push_back(
const_cast<SCH_FIELD*
>( field ) );
1897 std::sort( aList.begin(), aList.end(),
1900 return lhs->GetOrdinal() < rhs->GetOrdinal();
1907 std::vector<SCH_FIELD*> orderedFields;
1912 aList.emplace_back( *field );
1918 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
1923 std::unique_ptr<LIB_SYMBOL> flattenedParent = parent->Flatten();
1926 [&](
const wxString& aFieldName )
1932 std::vector<SCH_FIELD> fieldsCopy;
1933 std::vector<SCH_FIELD>
result;
1941 if( selected( field.GetName() ) )
1943 if( field.IsMandatory() )
1944 parentField = flattenedParent->GetField( field.GetId() );
1946 parentField = flattenedParent->GetField( field.GetName() );
1954 field.SetText( parentField->
GetText() );
1958 field.SetVisible( parentField->
IsVisible() );
1966 bool visible = field.IsVisible();
1967 VECTOR2I pos = field.GetPosition();
1969 field.SetAttributes( *parentField );
1971 field.SetVisible( visible );
1972 field.SetPosition( pos );
1976 field.SetTextPos( parentField->
GetTextPos() );
1985 result.emplace_back( std::move( field ) );
1989 std::vector<SCH_FIELD*> parentFields;
1991 flattenedParent->GetFields( parentFields );
1993 for(
SCH_FIELD* parentField : parentFields )
1995 if( !selected( parentField->GetName() ) )
1998 if( !
GetField( parentField->GetName() ) )
2003 newField->
SetName( parentField->GetUntranslatedName() );
2004 newField->
SetText( parentField->GetText() );
2019 ordinal = std::max( ordinal,
static_cast<const SCH_FIELD*
>( &item )->GetOrdinal() + 1 );
2031 if( field->
GetId() == aFieldType )
2045 if( field->
GetId() == aFieldType )
2059 if( field.
GetName() == aFieldName )
2073 if( field.
GetName() == aFieldName )
2112 wxASSERT( field !=
nullptr );
2120 wxASSERT( field !=
nullptr );
2128 wxASSERT( field !=
nullptr );
2136 wxASSERT( field !=
nullptr );
2144 wxASSERT( field !=
nullptr );
2153 refDesignator.Replace( wxS(
"~" ), wxS(
" " ) );
2155 wxString prefix = refDesignator;
2157 while( prefix.Length() )
2159 wxUniCharRef last = prefix.Last();
2161 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
2162 prefix.RemoveLast();
2168 prefix.Trim(
true );
2169 prefix.Trim(
false );
2188 item.Move( aOffset );
2208 if( root.get() !=
this )
2209 return root->HasLegacyAlternateBodyStyle();
2222 if( root.get() !=
this )
2223 return root->GetMaxPinNumber();
2226 int maxPinNumber = 0;
2231 long currentPinNumber = 0;
2233 if(
pin->GetNumber().ToLong( ¤tPinNumber ) )
2234 maxPinNumber = std::max( maxPinNumber, (
int) currentPinNumber );
2237 return maxPinNumber;
2246 item.ClearTempFlags();
2255 item.ClearEditFlags();
2263 if( ( aUnit && item.m_unit && aUnit != item.m_unit )
2264 || ( aBodyStyle && item.m_bodyStyle && aBodyStyle != item.m_bodyStyle )
2270 if( item.HitTest( aPoint ) )
2303 if( item.IsType( aScanTypes ) )
2319 wxCHECK_RET( aCount >= 1, wxString::Format( wxT(
"Invalid unit count %d, ignoring." ), aCount ) );
2333 if( it->m_unit > aCount )
2340 else if( aDuplicateDrawItems )
2347 std::vector<SCH_ITEM*> tmp;
2351 if( item.m_unit != 1 )
2354 for(
int j = prevCount + 1; j <= aCount; j++ )
2358 tmp.push_back( newItem );
2378 if( root.get() !=
this )
2379 return root->GetUnitCount();
2401 if( root.get() !=
this )
2402 return root->m_demorgan;
2415 if( root.get() !=
this )
2416 return root->m_bodyStyleNames;
2425 wxCHECK_RET( aCount >= 1,
2426 wxString::Format( wxT(
"Invalid body style count %d, ignoring." ), aCount ) );
2431 if( prevCount < aCount && ( aDuplicateDrawItems || aDuplicatePins ) )
2433 std::vector<SCH_ITEM*> tmp;
2439 if( !aDuplicatePins )
2444 if( !aDuplicateDrawItems )
2450 for(
int j = prevCount + 1; j <= aCount; j++ )
2454 tmp.push_back( newItem );
2479 if( i->m_bodyStyle > aBodyStyleCount )
2489 std::vector<SCH_ITEM*> unitItems;
2498 && aUnit != item.GetUnit() )
2505 && aBodyStyle != item.GetBodyStyle() )
2510 unitItems.push_back( &item );
2519 std::vector<LIB_SYMBOL_UNIT> units;
2529 units.push_back( std::move( record ) );
2538 int unit = item.GetUnit();
2539 int bodyStyle = item.GetBodyStyle();
2541 auto it = std::find_if( units.begin(), units.end(),
2544 return a.m_unit == unit && a.m_bodyStyle == bodyStyle;
2547 if( it == units.end() )
2552 it = units.insert( units.end(), std::move( record ) );
2555 it->m_items.push_back( &item );
2558 std::sort( units.begin(), units.end(),
2561 if( a.m_unit == b.m_unit )
2562 return a.m_bodyStyle < b.m_bodyStyle;
2564 return a.m_unit < b.m_unit;
2571#define REPORT( msg ) \
2574 aReporter->Report( msg ); \
2577#define ITEM_DESC( item ) ( item )->GetItemDescription( &unitsProvider, false )
2602 if( ( aCompareFlags & FLAGS::PIN_VISIBILITIES )
2611 && ( !( aCompareFlags & FLAGS::EXCLUDE_FROM_POS_FILES )
2613 && ( !( aCompareFlags & FLAGS::DNP ) ||
dnp == aOther.
dnp );
2631 REPORT(
_(
"Name differs." ) );
2640 REPORT(
_(
"Library ID differs." ) );
2653 REPORT(
_(
"Symbol parent differs." ) );
2663 REPORT(
_(
"Power flag differs." ) );
2672 REPORT(
_(
"Unit count differs." ) );
2680 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aShapes;
2681 std::set<const SCH_FIELD*> aFields;
2682 std::set<const SCH_PIN*> aPins;
2687 aShapes.insert( &( *it ) );
2689 aFields.insert(
static_cast<const SCH_FIELD*
>( &( *it ) ) );
2691 aPins.insert(
static_cast<const SCH_PIN*
>( &( *it ) ) );
2694 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bShapes;
2695 std::set<const SCH_FIELD*> bFields;
2696 std::set<const SCH_PIN*> bPins;
2701 bShapes.insert( &( *it ) );
2703 bFields.insert(
static_cast<const SCH_FIELD*
>( &( *it ) ) );
2705 bPins.insert(
static_cast<const SCH_PIN*
>( &( *it ) ) );
2708 if(
int tmp =
static_cast<int>( aShapes.size() - bShapes.size() ) )
2711 REPORT(
_(
"Graphic item count differs." ) );
2718 for(
auto aIt = aShapes.begin(), bIt = bShapes.begin(); aIt != aShapes.end(); aIt++, bIt++ )
2720 if(
int tmp2 = ( *aIt )->compare( *( *bIt ), aCompareFlags ) )
2723 REPORT( wxString::Format(
_(
"Graphic item differs: %s; %s." ),
2733 for(
const SCH_PIN* aPin : aPins )
2735 const SCH_PIN* bPin = aRhs.
GetPin( aPin->GetNumber(), aPin->GetUnit(), aPin->GetBodyStyle() );
2740 REPORT( wxString::Format(
_(
"Extra pin in schematic symbol: %s." ),
ITEM_DESC( aPin ) ) );
2745 else if(
int tmp =
static_cast<const SCH_ITEM*
>( aPin )->
compare( *bPin, aCompareFlags ) )
2748 REPORT( wxString::Format(
_(
"Pin %s differs: %s; %s" ),
2758 for(
const SCH_PIN* bPin : bPins )
2760 const SCH_PIN* aPin =
GetPin( bPin->GetNumber(), bPin->GetUnit(), bPin->GetBodyStyle() );
2765 REPORT( wxString::Format(
_(
"Missing pin in schematic symbol: %s." ),
ITEM_DESC( bPin ) ) );
2772 for(
const SCH_FIELD* aField : aFields )
2776 if( aField->IsMandatory() )
2777 bField = aRhs.
GetField( aField->GetId() );
2779 bField = aRhs.
GetField( aField->GetName() );
2786 REPORT( wxString::Format(
_(
"Extra field in schematic symbol: %s." ), aField->GetName(
false ) ) );
2796 if(
int tmp = aField->GetText().compare( bField->
GetText() ) )
2799 REPORT( wxString::Format(
_(
"Field '%s' differs: %s; %s." ),
2800 aField->GetName(
false ),
2811 if( aField->GetFont() != bField->
GetFont() )
2813 retv = std::less<KIFONT::FONT*>{}( aField->GetFont(), bField->
GetFont() ) ? -1 : 1;
2814 REPORT( wxString::Format(
_(
"Field '%s' fonts differ." ), aField->GetName(
false ) ) );
2820 if( aField->GetTextSize() != bField->
GetTextSize() )
2822 if( aField->GetTextSize().x != bField->
GetTextSize().
x )
2823 retv = aField->GetTextSize().x - bField->
GetTextSize().
x;
2825 retv = aField->GetTextSize().y - bField->
GetTextSize().
y;
2827 REPORT( wxString::Format(
_(
"Field '%s' text sizes differ." ), aField->GetName(
false ) ) );
2833 if(
int tmp = aField->GetAttributes().Compare( bField->
GetAttributes() ) )
2836 REPORT( wxString::Format(
_(
"Field '%s' text styles differ." ), aField->GetName(
false ) ) );
2845 if( aField->IsVisible() != bField->
IsVisible() )
2847 retv = aField->IsVisible() ? 1 : -1;
2848 REPORT( wxString::Format(
_(
"Field '%s' visibility flags differ." ), aField->GetName(
false ) ) );
2854 if( aField->IsNameShown() != bField->
IsNameShown() )
2856 retv = aField->IsNameShown() ? 1 : -1;
2857 REPORT( wxString::Format(
_(
"Field '%s' name shown flags differ." ), aField->GetName(
false ) ) );
2864 if( aField->IsPrivate() != bField->
IsPrivate() )
2866 retv = aField->IsPrivate() ? 1 : -1;
2867 REPORT( wxString::Format(
_(
"Field '%s' privacy flags differ." ), aField->GetName(
false ) ) );
2875 if( aField->GetPosition() != bField->
GetPosition() )
2877 if( aField->GetPosition().x != bField->
GetPosition().
x )
2878 retv = aField->GetPosition().x - bField->
GetPosition().
x;
2879 else if( aField->GetPosition().y != bField->
GetPosition().
y )
2880 retv = aField->GetPosition().y - bField->
GetPosition().
y;
2882 REPORT( wxString::Format(
_(
"Field '%s' positions differ." ), aField->GetName(
false ) ) );
2893 for(
const SCH_FIELD* bField : bFields )
2897 if( bField->IsMandatory() )
2898 aField =
GetField( bField->GetId() );
2900 aField =
GetField( bField->GetName() );
2905 REPORT( wxString::Format(
_(
"Missing field in schematic symbol: %s." ), bField->GetName(
false ) ) );
2916 REPORT(
_(
"Footprint filter count differs." ) );
2923 for(
size_t i = 0; i <
m_fpFilters.GetCount(); i++ )
2928 REPORT(
_(
"Footprint filters differ." ) );
2939 REPORT(
_(
"Pin map count differs." ) );
2947 REPORT(
_(
"Pin maps differ." ) );
2956 REPORT(
_(
"Associated footprint count differs." ) );
2964 REPORT(
_(
"Associated footprints differ." ) );
2973 REPORT(
_(
"Symbol keywords differ." ) );
2982 REPORT(
_(
"Symbol pin name offsets differ." ) );
2993 REPORT(
_(
"Show pin names settings differ." ) );
3002 REPORT(
_(
"Show pin numbers settings differ." ) );
3014 REPORT(
_(
"Exclude from simulation settings differ." ) );
3026 REPORT(
_(
"Exclude from bill of materials settings differ." ) );
3038 REPORT(
_(
"Exclude from board settings differ." ) );
3049 retv = (
m_DNP ) ? -1 : 1;
3050 REPORT(
_(
"Do not populate settings differ." ) );
3062 REPORT(
_(
"Exclude from position files settings differ." ) );
3098 return Compare( *tmp, aCompareFlags );
3107 double similarity = 0.0;
3116 double max_similarity = 0.0;
3120 double temp_similarity = item.Similarity( otherItem );
3121 max_similarity = std::max( max_similarity, temp_similarity );
3123 if( max_similarity == 1.0 )
3127 similarity += max_similarity;
3133 double max_similarity = 0.0;
3137 double temp_similarity =
pin->Similarity( *otherPin );
3138 max_similarity = std::max( max_similarity, temp_similarity );
3140 if( max_similarity == 1.0 )
3144 similarity += max_similarity;
3147 if( totalItems == 0 )
3150 similarity /= totalItems;
3202 std::set<const LIB_SYMBOL*> visited;
3203 visited.insert(
this );
3205 std::vector<EMBEDDED_FILES*> ancestralEmbeddedFiles;
3207 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
3212 if( visited.count( parent.get() ) )
3215 wxT(
"AppendParentEmbeddedFiles: Circular inheritance detected in symbol '%s' (lib: %s)" ),
3220 visited.insert( parent.get() );
3221 ancestralEmbeddedFiles.push_back( parent->GetEmbeddedFiles() );
3222 parent = parent->GetParent().lock();
3226 for(
EMBEDDED_FILES* files : std::ranges::reverse_view( ancestralEmbeddedFiles ) )
3227 aStack.push_back( files );
3235 std::set<KIFONT::OUTLINE_FONT*>
fonts;
3240 if( font && !font->IsStroke() )
3245 if( permission == PERMISSION::EDITABLE || permission == PERMISSION::INSTALLABLE )
3246 fonts.insert( outline );
3254 processFont(
text->GetFont() );
3256 processFont( field->GetFont() );
3273 wxLogTrace(
"EMBED",
"Failed to add font file: %s", font->GetFileName() );
3289 const wxString groupFields =
_HKI(
"Fields" );
3307 const wxString groupSymbolDef =
_HKI(
"Symbol Definition" );
3316 const wxString groupPinDisplay =
_HKI(
"Pin Display" );
3331 const wxString groupAttributes =
_HKI(
"Attributes" );
3346 const wxString groupUnits =
_HKI(
"Units and Body Styles" );
3355 auto multiBodyStyle =
3359 return symbol->IsMultiBodyStyle();
3370 wxPGChoices choices;
3374 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
3375 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
constexpr EDA_IU_SCALE schIUScale
static double square(double x)
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 VECTOR2I GetTextSize() const
virtual VECTOR2I GetTextPos() const
virtual bool IsVisible() const
KIFONT::FONT * GetFont() const
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
virtual void SetVisible(bool aVisible)
const TEXT_ATTRIBUTES & GetAttributes() const
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.
void SetAreFontsEmbedded(bool aEmbedFonts)
bool GetAreFontsEmbedded() const
Class that other classes need to inherit from, in order to be inspectable.
Represents an (ordered) list of JUMPER_GROUP objects.
void Add(JUMPER_GROUP aGroup)
Add a JUMPER_GROUP to the set.
Represents a group of jumper pins or pads, keyed by name.
FONT is an abstract base class for both outline and stroke fonts.
Implement 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.
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Define a library symbol object.
std::vector< SEARCH_TERM > & GetSearchTerms() override
LIB_ITEMS_CONTAINER m_drawings
SCH_FIELD & GetDescriptionField()
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.
void rebuildCaches() const
int GetPinCount() const override
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
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
const std::vector< ASSOCIATED_FOOTPRINT > & GetEffectiveAssociatedFootprints() const
bool UnitsLocked() const
Check whether symbol units are interchangeable.
SCH_FIELD & GetDatasheetField()
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
void ClearTempFlags() override
Clears the status flag all draw objects in this symbol.
void Serialize(kiapi::schematic::types::SchematicSymbol &aOutput, bool aSkipPins=false) const
void SetKeywordsProp(const wxString &aKeywords)
std::map< int, wxString > & GetUnitDisplayNames()
void SetDuplicatePinNumbersAreJumpers(bool aEnabled)
bool m_demorgan
True if there are two body styles: normal and De Morgan If false, the body style count is taken from ...
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
JUMPER_GROUP_SET & JumperPinGroups()
Each jumper pin group is a set of pin numbers that should be treated as internally connected.
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()
void SetAssociatedFootprints(std::vector< ASSOCIATED_FOOTPRINT > aList)
void FixupDrawItems()
This function finds the filled draw items that are covering up smaller draw items and replaces their ...
void SetBodyStyleNames(const std::vector< wxString > &aBodyStyleNames)
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()
Return 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
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
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)
Set the Description field text value.
std::shared_ptr< LIB_SYMBOL > m_me
wxString GetValueProp() const
bool GetExcludedFromBOMProp() const
void SetKeyWords(const wxString &aKeyWords)
SCH_FIELD & GetValueField()
void deleteAllUserFields()
bool IsLocalPower() const override
LIB_SYMBOL(const wxString &aName, LIB_SYMBOL *aParent=nullptr, LEGACY_SYMBOL_LIB *aLibrary=nullptr)
wxArrayString GetFPFilters() const
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
bool ResolveTextVar(wxString *aToken, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
void SetBodyStyleProp(const wxString &aBodyStyle) override
void SetPinMaps(const PIN_MAP_SET &aPinMaps)
timestamp_t m_lastModDate
void SetExcludedFromSimProp(bool aExclude)
bool GetExcludedFromBoardProp() const
wxString getShownDescription(RESOLUTION_CONTEXT aContext, int aDepth) const
JUMPER_GROUP_SET m_jumperPinGroups
A list of jumper pin groups, each of which is a set of pin numbers that should be jumpered together (...
bool HasPinNumber(const wxString &aNumber) const
Return true if aNumber names a pin of this symbol, in any unit or body style.
void SetBodyStyleCount(int aCount, bool aDuplicateDrawItems, bool aDuplicatePins)
Set the number of body styles for the symbol.
wxString GetLibNickname() const override
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.
void SetFPFilters(const wxArrayString &aFilters)
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
int compare(const SCH_ITEM &aOther, int aCompareFlags=~(COMPARE_FLAGS::UUID|COMPARE_FLAGS::UNIT)) const override
The library symbol specific sort order is as follows:
bool GetExcludedFromSimProp() const
int GetBodyStyleCount() const override
The body styles are a property of the drawings, which a derived symbol inherits from its root symbol ...
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...
wxString GetFootprint() const override
For items with footprint fields.
EMBEDDED_FILES * GetEmbeddedFiles() override
void SetPowerSymbolProp(bool aIsPower)
LIB_SYMBOL_ATTRIBUTES ComparisonAttributes() const
void SetExcludedFromBOMProp(bool aExclude)
int m_unitCount
Number of units (parts) per package.
void SyncFieldsFromParent(const LIB_FIELD_SYNC_OPTIONS &aOptions)
Reconcile this derived symbol's fields with those of its (flattened) parent.
wxString GetShownKeyWords(RESOLUTION_CONTEXT aContext, 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
bool Deserialize(const kiapi::schematic::types::SchematicSymbol &aInput)
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)
void SetParentName(const wxString &aParentName)
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
bool GetDuplicatePinNumbersAreJumpers() const
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
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)
int Compare(const LIB_SYMBOL &aRhs, int aCompareFlags=~COMPARE_FLAGS::UNIT, REPORTER *aReporter=nullptr) const
Comparison test that can be used for operators.
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)
void PruneBodyStyleDrawItems(int aBodyStyleCount)
Delete the draw items belonging to a body style beyond aBodyStyleCount.
SCH_FIELD & GetReferenceField()
wxString GetShownDescription(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
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)
A symbol-owned ordered set of named pin maps.
const std::vector< PIN_MAP > & GetAll() const
void AddOrReplace(PIN_MAP aMap)
Insert aMap, replacing any existing entry with the same name.
void SetEntry(const wxString &aPinNumber, const wxString &aPadNumber)
Set the pad number for a symbol pin.
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.
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.
VECTOR2I GetPosition() const override
void SetOrdinal(int aOrdinal, FIELD_T aType)
virtual const wxString & GetText() const override
Return the string associated with the text object.
wxString GetUntranslatedName() const
Get the untranslated field name for storage, variable look-up, etc.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString, int aDepth=0) const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetName(const wxString &aName)
bool ShowInChooser() const
void SetText(const wxString &aText) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
virtual void SetBodyStyle(int aBodyStyle)
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
void SetPrivate(bool aPrivate)
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
COMPARE_FLAGS
The list of flags used by various compare functions.
void SetLayer(SCH_LAYER_ID aLayer)
virtual void SetUnit(int aUnit)
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_DNP
True if symbol is set to 'Do Not Populate'.
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
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 void SetExcludedFromSim(bool aExcludeFromSim, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
virtual void SetDNP(bool aDNP, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) 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
void SetExcludedFromPosFiles(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from position files flag.
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
SYMBOL & operator=(const SYMBOL &aItem)
virtual bool GetShowPinNumbers() const
virtual void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
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 offset of the pin name string from the end of the pin in mils.
static wxString displayName(const DATABASE_LIB_TABLE &aTable)
@ FILLED_WITH_BG_BODYCOLOR
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.
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.
Definition for symbol library class.
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
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API std::optional< KICAD_T > TypeNameFromAny(const google::protobuf::Any &aMessage)
KICOMMON_API void PackDistance(types::Distance &aOutput, int aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackLibId(types::LibraryIdentifier *aOutput, const LIB_ID &aId)
KICOMMON_API LIB_ID UnpackLibId(const types::LibraryIdentifier &aId)
static const std::vector< std::string > filters
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
@ PT_SIZE
Size expressed in distance units (mm/inch)
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Options controlling how a derived symbol's fields are reconciled with its parent.
bool m_removeExtraFields
Drop fields not present in the parent.
bool m_resetPositions
Copy parent field positions.
bool m_resetVisibility
Copy parent visibility and name-shown flags.
bool m_updateAllFields
Reconcile every field. When false only the names in m_updateFields are touched.
std::set< wxString > m_updateFields
Field names to reconcile when m_updateAllFields is false.
bool m_resetEffects
Copy parent text effects (font, justification, etc.) but keep local visibility/position.
bool m_resetEmptyText
Copy parent text even when the parent value is empty.
bool m_resetText
Copy parent text when the parent value is non-empty.
Logical pins: Return expanded logical pins based on stacked-pin notation.
std::vector< wxString > m_pinNumbers
bool excludedFromPosFiles
bool Matches(const LIB_SYMBOL_ATTRIBUTES &aOther, int aCompareFlags) const
std::map< int, wxString > unitDisplayNames
std::vector< ASSOCIATED_FOOTPRINT > associatedFootprints
wxArrayString footprintFilters
std::vector< wxString > bodyStyleNames
int m_bodyStyle
The alternate body style of the unit.
int m_unit
The unit number.
One symbol-pin to footprint-pad mapping inside a PIN_MAP.
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...
@ USER
The field ID hasn't been set yet; field is invalid.
@ 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
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I