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;
479 aContainer.PackFrom( def );
489 const SchematicSymbol& def = aInput;
496 case SchematicSymbolType::SST_GLOBAL_POWER:
SetGlobalPower();
break;
497 case SchematicSymbolType::SST_LOCAL_POWER:
SetLocalPower();
break;
501 if( def.has_attributes() )
507 SetDNP( def.attributes().do_not_populate() );
516 for(
const SchematicSymbolChild& child : def.items() )
525 if( !item || !item->Deserialize( child.item() ) )
530 if( child.has_unit() )
531 schItem->
SetUnit( child.unit().unit() );
533 if( child.has_body_style() )
541 if( def.unit_count() > 0 )
544 if( def.body_style_size() > 0 )
546 std::vector<wxString> bodyStyleNames;
548 for(
const SchematicBodyStyle& bodyStyle : def.body_style() )
549 bodyStyleNames.emplace_back( wxString::FromUTF8( bodyStyle.name() ) );
555 if( !def.keywords().empty() )
556 SetKeyWords( wxString::FromUTF8( def.keywords() ) );
558 if( def.footprint_filters_size() > 0 )
562 for(
const std::string&
filter : def.footprint_filters() )
571 jumperGroups.
Clear();
573 for(
const JumperGroup&
group : def.jumpers().groups() )
575 std::set<wxString> pinNumbers;
577 for(
const std::string& pinNumber :
group.pin_numbers() )
578 pinNumbers.insert( wxString::FromUTF8( pinNumber ) );
580 jumperGroups.
Add( std::move( pinNumbers ) );
586 for(
const SchematicUnitDisplayName&
displayName : def.unit_display_names() )
593 if( def.has_extends() )
594 SetParentName( wxString::FromUTF8( def.extends().entry_name() ) );
596 if( def.has_pin_maps() )
600 for(
const PinMap& map : def.pin_maps().pin_maps() )
602 PIN_MAP pinMap( wxString::FromUTF8( map.name() ) );
604 for(
const PinMapEntry& entry : map.entries() )
606 pinMap.
SetEntry( wxString::FromUTF8( entry.pin_number() ), wxString::FromUTF8( entry.pad_number() ) );
612 std::vector<ASSOCIATED_FOOTPRINT> associatedFootprints;
614 for(
const AssociatedFootprint& footprint : def.pin_maps().associated_footprints() )
618 assoc.
m_MapName = wxString::FromUTF8( footprint.map_name() );
619 associatedFootprints.push_back( std::move( assoc ) );
633 kiapi::schematic::types::SchematicSymbol def;
635 if( !aContainer.UnpackTo( &def ) )
644 if( &aSymbol ==
this )
725 std::set<const LIB_SYMBOL*> visited;
726 visited.insert(
this );
728 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
733 if( visited.count( parent.get() ) )
736 wxT(
"GetInheritanceDepth: Circular inheritance detected in symbol '%s' "
742 visited.insert( parent.get() );
744 parent = parent->m_parent.lock();
753 std::set<const LIB_SYMBOL*> visited;
754 visited.insert(
this );
756 std::shared_ptr<LIB_SYMBOL> current =
m_me;
757 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
762 if( visited.count( parent.get() ) )
765 wxT(
"GetRootSymbol: Circular inheritance detected in symbol '%s' "
771 visited.insert( parent.get() );
773 parent = parent->m_parent.lock();
786 if( root.get() !=
this )
787 return root->m_unitsLocked;
797 std::shared_ptr<LIB_SYMBOL> root;
819 return aLabel ?
_(
"Alternate" ) : wxString(
_HKI(
"Alternate" ) );
821 return aLabel ?
_(
"Standard" ) : wxString(
_HKI(
"Standard" ) );
829 return names[aBodyStyle - 1];
839 m_libId.SetLibItemName( aName );
858 std::set<const LIB_SYMBOL*> visited;
859 visited.insert(
this );
861 std::shared_ptr<LIB_SYMBOL> ancestor = aParent->
SharedPtr();
865 if( visited.count( ancestor.get() ) )
868 "- would create circular inheritance (lib: %s)" ),
875 visited.insert( ancestor.get() );
876 ancestor = ancestor->m_parent.lock();
901 return wxEmptyString;
907 if( std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock() )
908 return parent->GetFootprint();
917 std::unique_ptr<LIB_SYMBOL> retv;
922 std::vector<const LIB_SYMBOL*> parentChain;
923 std::set<const LIB_SYMBOL*> visited;
924 visited.insert(
this );
926 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
928 wxCHECK_MSG( parent, retv, wxString::Format(
"Parent of derived symbol '%s' undefined",
m_name ) );
933 if( visited.count( parent.get() ) )
936 wxT(
"Flatten: Circular inheritance detected in symbol '%s' (lib: %s)" ),
941 visited.insert( parent.get() );
942 parentChain.push_back( parent.get() );
943 parent = parent->m_parent.lock();
947 if( !parentChain.empty() )
949 retv = std::make_unique<LIB_SYMBOL>( *parentChain.back() );
952 for(
int i =
static_cast<int>( parentChain.size() ) - 2; i >= 0; --i )
960 *retv->GetField( fieldId ) = *derived->
GetField( fieldId );
978 retv->AddDrawItem( newField );
982 retv->RemoveDrawItem( parentField );
983 retv->AddDrawItem( newField );
997 retv = std::make_unique<LIB_SYMBOL>( *
this );
998 retv->m_parent.reset();
1010 *retv->GetField( fieldId ) = *
GetField( fieldId );
1029 retv->AddDrawItem( newField );
1033 retv->RemoveDrawItem( parentField );
1034 retv->AddDrawItem( newField );
1052 retv->AddFile( newFile );
1055 for(
const LIB_SYMBOL* ancestor : parentChain )
1057 for(
const auto& [
name, file] : ancestor->EmbeddedFileMap() )
1060 retv->AddFile( newFile );
1067 if( !parentChain.empty() )
1069 retv->SetExcludedFromSim( parentChain.back()->GetExcludedFromSim() );
1070 retv->SetExcludedFromBOM( parentChain.back()->GetExcludedFromBOM() );
1071 retv->SetExcludedFromBoard( parentChain.back()->GetExcludedFromBoard() );
1072 retv->SetExcludedFromPosFiles( parentChain.back()->GetExcludedFromPosFiles() );
1080 retv->m_cachesDirty =
true;
1081 retv->m_parent.reset();
1085 retv = std::make_unique<LIB_SYMBOL>( *
this );
1105 return m_libId.GetLibNickname();
1115 if( root.get() !=
this )
1116 return root->IsLocalPower();
1129 if( root.get() !=
this )
1131 root->SetLocalPower();
1148 if( root.get() !=
this )
1149 return root->IsGlobalPower();
1168 if( root.get() !=
this )
1170 root->SetGlobalPower();
1187 if( root.get() !=
this )
1188 return root->IsNormal();
1201 if( root.get() !=
this )
1224 u = ( aUnit - 1 ) % 26;
1225 suffix = wxChar( aInitialLetter + u ) + suffix;
1226 aUnit = ( aUnit - u ) / 26;
1227 }
while( aUnit > 0 );
1255 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
1256 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
1257 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
1259 *token = wxEmptyString;
1263 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
1265 wxArrayString parts = wxSplit( footprint,
':' );
1267 if( parts.Count() > 0 )
1270 *token = wxEmptyString;
1274 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
1276 wxArrayString parts = wxSplit( footprint,
':' );
1278 if( parts.Count() > 1 )
1279 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
1281 *token = wxEmptyString;
1285 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
1287 *token =
m_libId.GetUniStringLibNickname();
1290 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
1292 *token =
m_libId.GetUniStringLibItemName();
1295 else if( token->IsSameAs( wxT(
"SYMBOL_PARENT" ) ) )
1297 std::shared_ptr<LIB_SYMBOL> parent =
GetParent().lock();
1298 *token = parent ? parent->GetName() : wxString();
1301 else if( token->IsSameAs( wxT(
"SYMBOL_ROOT" ) ) )
1304 *token = root ? root->GetName() :
GetName();
1307 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
1312 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
1317 else if( token->IsSameAs( wxT(
"SYMBOL_IS_POWER" ) ) )
1319 *token = this->
IsPower() ? wxString( wxS(
"Power Symbol" ) ) : wxString(
"" );
1322 else if( token->IsSameAs( wxT(
"SYMBOL_IS_LOCAL_POWER" ) ) )
1324 *token = this->
IsLocalPower() ? wxString( wxS(
"Local Power Symbol" ) ) : wxString(
"" );
1327 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
1332 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
1337 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
1339 *token = this->
GetExcludedFromSim() ? wxS(
"Excluded from simulation" ) : wxEmptyString;
1342 else if( token->IsSameAs( wxT(
"DNP" ) ) )
1344 *token = this->
GetDNP() ? wxS(
"DNP" ) : wxEmptyString;
1353 const VECTOR2I& aOffset,
bool aDimmed )
1355 wxASSERT( aPlotter !=
nullptr );
1370 color = color.
Mix( bg, 0.5f );
1378 if( item.IsPrivate() )
1386 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1389 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1392 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1398 int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
1400 wxASSERT( aPlotter !=
nullptr );
1412 color = color.
Mix( bg, 0.5f );
1426 wxString tmp = field.
GetText();
1429 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1438 std::vector<SCH_SHAPE*> potential_top_items;
1439 std::vector<SCH_ITEM*> bottom_items;
1448 potential_top_items.push_back( &shape );
1450 bottom_items.push_back( &item );
1454 bottom_items.push_back( &item );
1458 std::sort( potential_top_items.begin(), potential_top_items.end(),
1461 return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea();
1464 for(
SCH_SHAPE* item : potential_top_items )
1466 for(
SCH_ITEM* bottom_item : bottom_items )
1468 if( item->GetBoundingBox().Contains( bottom_item->GetBoundingBox() ) )
1480 wxASSERT( aItem !=
nullptr );
1486 if(
static_cast<SCH_FIELD*
>( aItem )->IsMandatory() )
1492 for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
1526 if( root.get() !=
this )
1527 return const_cast<const LIB_SYMBOL*
>( root.get() )->GetGraphicalPins( aUnit, aBodyStyle );
1530 std::vector<SCH_PIN*> pins;
1542 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1546 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1549 pins.push_back(
static_cast<SCH_PIN*
>(
const_cast<SCH_ITEM*
>( &item ) ) );
1558 std::vector<UNIT_PIN_INFO> units;
1562 auto compareByPosition =
1566 VECTOR2I positionB = b->GetPosition();
1568 if( positionA.
x != positionB.
x )
1569 return positionA.
x < positionB.
x;
1571 return positionA.
y < positionB.
y;
1574 for(
int unitIdx = 1; unitIdx <= unitCount; ++unitIdx )
1581 std::sort( pinList.begin(), pinList.end(), compareByPosition );
1583 std::unordered_set<wxString> seenNumbers;
1585 for(
const SCH_PIN* basePin : pinList )
1587 bool stackedValid =
false;
1588 std::vector<wxString> expandedNumbers = basePin->GetStackedPinNumbers( &stackedValid );
1590 if( stackedValid && !expandedNumbers.empty() )
1592 for(
const wxString& number : expandedNumbers )
1594 if( seenNumbers.insert( number ).second )
1601 const wxString& number = basePin->GetNumber();
1603 if( !number.IsEmpty() && seenNumbers.insert( number ).second )
1607 units.push_back( std::move( unitInfo ) );
1616 std::vector<LOGICAL_PIN> out;
1621 std::vector<wxString> expanded =
pin->GetStackedPinNumbers( &valid );
1623 if( valid && !expanded.empty() )
1625 for(
const wxString& num : expanded )
1628 wxLogTrace(
traceStackedPins,
"GetLogicalPins: base='%s' -> '%s'",
pin->GetShownNumber(), num );
1634 wxLogTrace(
traceStackedPins,
"GetLogicalPins: base='%s' (no expansion)",
pin->GetShownNumber() );
1655 if( aNumber ==
pin->GetNumber() )
1665 std::vector<SCH_PIN*> pins;
1669 if( aNumber ==
pin->GetNumber() )
1670 pins.push_back(
pin );
1684 for(
const wxString& logicalNumber :
pin->GetStackedPinNumbers() )
1686 if( aNumber == logicalNumber )
1696 bool aTestOrientation,
bool aTestLength )
const
1701 bool foundMatch =
false;
1705 wxASSERT( otherPin );
1708 if(
pin->GetUnit() != otherPin->GetUnit() )
1712 if(
pin->GetBodyStyle() != otherPin->GetBodyStyle() )
1716 if(
pin->GetPosition() != otherPin->GetPosition() )
1720 if( aTestNums && (
pin->GetNumber() != otherPin->GetNumber() ) )
1724 if( aTestNames && (
pin->GetName() != otherPin->GetName() ) )
1728 if( aTestType && (
pin->GetType() != otherPin->GetType() ) )
1732 if( aTestOrientation && (
pin->GetOrientation() != otherPin->GetOrientation() ) )
1736 if( aTestLength && (
pin->GetLength() != otherPin->GetLength() ) )
1756 bool aIgnoreLabelsOnInvisiblePins )
const
1764 if( root.get() !=
this )
1765 bBox = root->GetUnitBoundingBox( aUnit, aBodyStyle, aIgnoreHiddenFields, aIgnoreLabelsOnInvisiblePins );
1770 if( item.m_unit > 0 &&
m_unitCount > 1 && aUnit > 0 && aUnit != item.m_unit )
1773 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
1776 if( aIgnoreHiddenFields && item.Type() ==
SCH_FIELD_T )
1778 if( !
static_cast<const SCH_FIELD&
>( item ).IsVisible() )
1782 if( item.Type() ==
SCH_PIN_T && !aIgnoreLabelsOnInvisiblePins )
1785 bBox.
Merge(
pin.GetBoundingBox(
true,
true,
false ) );
1789 bBox.
Merge( item.GetBoundingBox() );
1798 bool aIncludePrivateItems )
const
1804 if( item.m_unit > 0 && aUnit > 0 && aUnit != item.m_unit )
1807 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
1810 if( item.IsPrivate() && !aIncludePrivateItems )
1820 if(
pin.IsVisible() )
1826 bbox.
Merge(
pin.GetBoundingBox(
false,
false,
false ) );
1833 bbox.
Merge( item.GetBoundingBox() );
1864 for(
const SCH_FIELD& src : aFieldsList )
1890 aList.push_back(
const_cast<SCH_FIELD*
>( field ) );
1893 std::sort( aList.begin(), aList.end(),
1896 return lhs->GetOrdinal() < rhs->GetOrdinal();
1903 std::vector<SCH_FIELD*> orderedFields;
1908 aList.emplace_back( *field );
1914 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
1919 std::unique_ptr<LIB_SYMBOL> flattenedParent = parent->Flatten();
1922 [&](
const wxString& aFieldName )
1928 std::vector<SCH_FIELD> fieldsCopy;
1929 std::vector<SCH_FIELD>
result;
1937 if( selected( field.GetName() ) )
1939 if( field.IsMandatory() )
1940 parentField = flattenedParent->GetField( field.GetId() );
1942 parentField = flattenedParent->GetField( field.GetName() );
1950 field.SetText( parentField->
GetText() );
1954 field.SetVisible( parentField->
IsVisible() );
1962 bool visible = field.IsVisible();
1963 VECTOR2I pos = field.GetPosition();
1965 field.SetAttributes( *parentField );
1967 field.SetVisible( visible );
1968 field.SetPosition( pos );
1972 field.SetTextPos( parentField->
GetTextPos() );
1981 result.emplace_back( std::move( field ) );
1985 std::vector<SCH_FIELD*> parentFields;
1987 flattenedParent->GetFields( parentFields );
1989 for(
SCH_FIELD* parentField : parentFields )
1991 if( !selected( parentField->GetName() ) )
1994 if( !
GetField( parentField->GetName() ) )
1999 newField->
SetName( parentField->GetUntranslatedName() );
2000 newField->
SetText( parentField->GetText() );
2015 ordinal = std::max( ordinal,
static_cast<const SCH_FIELD*
>( &item )->GetOrdinal() + 1 );
2027 if( field->
GetId() == aFieldType )
2041 if( field->
GetId() == aFieldType )
2055 if( field.
GetName() == aFieldName )
2069 if( field.
GetName() == aFieldName )
2108 wxASSERT( field !=
nullptr );
2116 wxASSERT( field !=
nullptr );
2124 wxASSERT( field !=
nullptr );
2132 wxASSERT( field !=
nullptr );
2140 wxASSERT( field !=
nullptr );
2149 refDesignator.Replace( wxS(
"~" ), wxS(
" " ) );
2151 wxString prefix = refDesignator;
2153 while( prefix.Length() )
2155 wxUniCharRef last = prefix.Last();
2157 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
2158 prefix.RemoveLast();
2164 prefix.Trim(
true );
2165 prefix.Trim(
false );
2184 item.Move( aOffset );
2204 if( root.get() !=
this )
2205 return root->HasLegacyAlternateBodyStyle();
2218 if( root.get() !=
this )
2219 return root->GetMaxPinNumber();
2222 int maxPinNumber = 0;
2227 long currentPinNumber = 0;
2229 if(
pin->GetNumber().ToLong( ¤tPinNumber ) )
2230 maxPinNumber = std::max( maxPinNumber, (
int) currentPinNumber );
2233 return maxPinNumber;
2242 item.ClearTempFlags();
2251 item.ClearEditFlags();
2259 if( ( aUnit && item.m_unit && aUnit != item.m_unit )
2260 || ( aBodyStyle && item.m_bodyStyle && aBodyStyle != item.m_bodyStyle )
2266 if( item.HitTest( aPoint ) )
2299 if( item.IsType( aScanTypes ) )
2315 wxCHECK_RET( aCount >= 1, wxString::Format( wxT(
"Invalid unit count %d, ignoring." ), aCount ) );
2329 if( it->m_unit > aCount )
2336 else if( aDuplicateDrawItems )
2343 std::vector<SCH_ITEM*> tmp;
2347 if( item.m_unit != 1 )
2350 for(
int j = prevCount + 1; j <= aCount; j++ )
2354 tmp.push_back( newItem );
2374 if( root.get() !=
this )
2375 return root->GetUnitCount();
2397 if( root.get() !=
this )
2398 return root->m_demorgan;
2411 if( root.get() !=
this )
2412 return root->m_bodyStyleNames;
2421 wxCHECK_RET( aCount >= 1,
2422 wxString::Format( wxT(
"Invalid body style count %d, ignoring." ), aCount ) );
2427 if( prevCount < aCount && ( aDuplicateDrawItems || aDuplicatePins ) )
2429 std::vector<SCH_ITEM*> tmp;
2435 if( !aDuplicatePins )
2440 if( !aDuplicateDrawItems )
2446 for(
int j = prevCount + 1; j <= aCount; j++ )
2450 tmp.push_back( newItem );
2475 if( i->m_bodyStyle > aBodyStyleCount )
2485 std::vector<SCH_ITEM*> unitItems;
2494 && aUnit != item.GetUnit() )
2501 && aBodyStyle != item.GetBodyStyle() )
2506 unitItems.push_back( &item );
2515 std::vector<LIB_SYMBOL_UNIT> units;
2525 units.push_back( std::move( record ) );
2534 int unit = item.GetUnit();
2535 int bodyStyle = item.GetBodyStyle();
2537 auto it = std::find_if( units.begin(), units.end(),
2540 return a.m_unit == unit && a.m_bodyStyle == bodyStyle;
2543 if( it == units.end() )
2548 it = units.insert( units.end(), std::move( record ) );
2551 it->m_items.push_back( &item );
2554 std::sort( units.begin(), units.end(),
2557 if( a.m_unit == b.m_unit )
2558 return a.m_bodyStyle < b.m_bodyStyle;
2560 return a.m_unit < b.m_unit;
2567#define REPORT( msg ) \
2570 aReporter->Report( msg ); \
2573#define ITEM_DESC( item ) ( item )->GetItemDescription( &unitsProvider, false )
2598 if( ( aCompareFlags & FLAGS::PIN_VISIBILITIES )
2607 && ( !( aCompareFlags & FLAGS::EXCLUDE_FROM_POS_FILES )
2609 && ( !( aCompareFlags & FLAGS::DNP ) ||
dnp == aOther.
dnp );
2627 REPORT(
_(
"Name differs." ) );
2636 REPORT(
_(
"Library ID differs." ) );
2649 REPORT(
_(
"Symbol parent differs." ) );
2659 REPORT(
_(
"Power flag differs." ) );
2668 REPORT(
_(
"Unit count differs." ) );
2676 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aShapes;
2677 std::set<const SCH_FIELD*> aFields;
2678 std::set<const SCH_PIN*> aPins;
2683 aShapes.insert( &( *it ) );
2685 aFields.insert(
static_cast<const SCH_FIELD*
>( &( *it ) ) );
2687 aPins.insert(
static_cast<const SCH_PIN*
>( &( *it ) ) );
2690 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bShapes;
2691 std::set<const SCH_FIELD*> bFields;
2692 std::set<const SCH_PIN*> bPins;
2697 bShapes.insert( &( *it ) );
2699 bFields.insert(
static_cast<const SCH_FIELD*
>( &( *it ) ) );
2701 bPins.insert(
static_cast<const SCH_PIN*
>( &( *it ) ) );
2704 if(
int tmp =
static_cast<int>( aShapes.size() - bShapes.size() ) )
2707 REPORT(
_(
"Graphic item count differs." ) );
2714 for(
auto aIt = aShapes.begin(), bIt = bShapes.begin(); aIt != aShapes.end(); aIt++, bIt++ )
2716 if(
int tmp2 = ( *aIt )->compare( *( *bIt ), aCompareFlags ) )
2719 REPORT( wxString::Format(
_(
"Graphic item differs: %s; %s." ),
2729 for(
const SCH_PIN* aPin : aPins )
2731 const SCH_PIN* bPin = aRhs.
GetPin( aPin->GetNumber(), aPin->GetUnit(), aPin->GetBodyStyle() );
2736 REPORT( wxString::Format(
_(
"Extra pin in schematic symbol: %s." ),
ITEM_DESC( aPin ) ) );
2741 else if(
int tmp =
static_cast<const SCH_ITEM*
>( aPin )->
compare( *bPin, aCompareFlags ) )
2744 REPORT( wxString::Format(
_(
"Pin %s differs: %s; %s" ),
2754 for(
const SCH_PIN* bPin : bPins )
2756 const SCH_PIN* aPin =
GetPin( bPin->GetNumber(), bPin->GetUnit(), bPin->GetBodyStyle() );
2761 REPORT( wxString::Format(
_(
"Missing pin in schematic symbol: %s." ),
ITEM_DESC( bPin ) ) );
2768 for(
const SCH_FIELD* aField : aFields )
2772 if( aField->IsMandatory() )
2773 bField = aRhs.
GetField( aField->GetId() );
2775 bField = aRhs.
GetField( aField->GetName() );
2782 REPORT( wxString::Format(
_(
"Extra field in schematic symbol: %s." ), aField->GetName(
false ) ) );
2792 if(
int tmp = aField->GetText().compare( bField->
GetText() ) )
2795 REPORT( wxString::Format(
_(
"Field '%s' differs: %s; %s." ),
2796 aField->GetName(
false ),
2807 if( aField->GetFont() != bField->
GetFont() )
2809 retv = std::less<KIFONT::FONT*>{}( aField->GetFont(), bField->
GetFont() ) ? -1 : 1;
2810 REPORT( wxString::Format(
_(
"Field '%s' fonts differ." ), aField->GetName(
false ) ) );
2816 if( aField->GetTextSize() != bField->
GetTextSize() )
2818 if( aField->GetTextSize().x != bField->
GetTextSize().
x )
2819 retv = aField->GetTextSize().x - bField->
GetTextSize().
x;
2821 retv = aField->GetTextSize().y - bField->
GetTextSize().
y;
2823 REPORT( wxString::Format(
_(
"Field '%s' text sizes differ." ), aField->GetName(
false ) ) );
2829 if(
int tmp = aField->GetAttributes().Compare( bField->
GetAttributes() ) )
2832 REPORT( wxString::Format(
_(
"Field '%s' text styles differ." ), aField->GetName(
false ) ) );
2841 if( aField->IsVisible() != bField->
IsVisible() )
2843 retv = aField->IsVisible() ? 1 : -1;
2844 REPORT( wxString::Format(
_(
"Field '%s' visibility flags differ." ), aField->GetName(
false ) ) );
2850 if( aField->IsNameShown() != bField->
IsNameShown() )
2852 retv = aField->IsNameShown() ? 1 : -1;
2853 REPORT( wxString::Format(
_(
"Field '%s' name shown flags differ." ), aField->GetName(
false ) ) );
2860 if( aField->IsPrivate() != bField->
IsPrivate() )
2862 retv = aField->IsPrivate() ? 1 : -1;
2863 REPORT( wxString::Format(
_(
"Field '%s' privacy flags differ." ), aField->GetName(
false ) ) );
2871 if( aField->GetPosition() != bField->
GetPosition() )
2873 if( aField->GetPosition().x != bField->
GetPosition().
x )
2874 retv = aField->GetPosition().x - bField->
GetPosition().
x;
2875 else if( aField->GetPosition().y != bField->
GetPosition().
y )
2876 retv = aField->GetPosition().y - bField->
GetPosition().
y;
2878 REPORT( wxString::Format(
_(
"Field '%s' positions differ." ), aField->GetName(
false ) ) );
2889 for(
const SCH_FIELD* bField : bFields )
2893 if( bField->IsMandatory() )
2894 aField =
GetField( bField->GetId() );
2896 aField =
GetField( bField->GetName() );
2901 REPORT( wxString::Format(
_(
"Missing field in schematic symbol: %s." ), bField->GetName(
false ) ) );
2912 REPORT(
_(
"Footprint filter count differs." ) );
2919 for(
size_t i = 0; i <
m_fpFilters.GetCount(); i++ )
2924 REPORT(
_(
"Footprint filters differ." ) );
2935 REPORT(
_(
"Pin map count differs." ) );
2943 REPORT(
_(
"Pin maps differ." ) );
2952 REPORT(
_(
"Associated footprint count differs." ) );
2960 REPORT(
_(
"Associated footprints differ." ) );
2969 REPORT(
_(
"Symbol keywords differ." ) );
2978 REPORT(
_(
"Symbol pin name offsets differ." ) );
2989 REPORT(
_(
"Show pin names settings differ." ) );
2998 REPORT(
_(
"Show pin numbers settings differ." ) );
3010 REPORT(
_(
"Exclude from simulation settings differ." ) );
3022 REPORT(
_(
"Exclude from bill of materials settings differ." ) );
3034 REPORT(
_(
"Exclude from board settings differ." ) );
3045 retv = (
m_DNP ) ? -1 : 1;
3046 REPORT(
_(
"Do not populate settings differ." ) );
3058 REPORT(
_(
"Exclude from position files settings differ." ) );
3094 return Compare( *tmp, aCompareFlags );
3103 double similarity = 0.0;
3112 double max_similarity = 0.0;
3116 double temp_similarity = item.Similarity( otherItem );
3117 max_similarity = std::max( max_similarity, temp_similarity );
3119 if( max_similarity == 1.0 )
3123 similarity += max_similarity;
3129 double max_similarity = 0.0;
3133 double temp_similarity =
pin->Similarity( *otherPin );
3134 max_similarity = std::max( max_similarity, temp_similarity );
3136 if( max_similarity == 1.0 )
3140 similarity += max_similarity;
3143 if( totalItems == 0 )
3146 similarity /= totalItems;
3198 std::set<const LIB_SYMBOL*> visited;
3199 visited.insert(
this );
3201 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
3206 if( visited.count( parent.get() ) )
3209 wxT(
"AppendParentEmbeddedFiles: Circular inheritance detected in "
3210 "symbol '%s' (lib: %s)" ),
3215 visited.insert( parent.get() );
3216 aStack.push_back( parent->GetEmbeddedFiles() );
3217 parent = parent->GetParent().lock();
3226 std::set<KIFONT::OUTLINE_FONT*>
fonts;
3231 if( font && !font->IsStroke() )
3236 if( permission == PERMISSION::EDITABLE || permission == PERMISSION::INSTALLABLE )
3237 fonts.insert( outline );
3245 processFont(
text->GetFont() );
3247 processFont( field->GetFont() );
3264 wxLogTrace(
"EMBED",
"Failed to add font file: %s", font->GetFileName() );
3280 const wxString groupFields =
_HKI(
"Fields" );
3298 const wxString groupSymbolDef =
_HKI(
"Symbol Definition" );
3307 const wxString groupPinDisplay =
_HKI(
"Pin Display" );
3322 const wxString groupAttributes =
_HKI(
"Attributes" );
3337 const wxString groupUnits =
_HKI(
"Units and Body Styles" );
3346 auto multiBodyStyle =
3350 return symbol->IsMultiBodyStyle();
3361 wxPGChoices choices;
3365 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
3366 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