46#include <unordered_map>
47#include <unordered_set>
52#include <api/schematic/schematic_types.pb.h>
63 std::set<const LIB_SYMBOL*> visited;
64 visited.insert( aSymbol );
66 std::shared_ptr<LIB_SYMBOL> current = aSymbol->
SharedPtr();
67 std::shared_ptr<LIB_SYMBOL> parent = aSymbol->
GetParent().lock();
71 if( visited.count( parent.get() ) )
79 chain += wxT(
" -> " ) + sym->GetName();
82 chain += wxT(
" -> " ) + parent->GetName() + wxT(
" (CYCLE)" );
85 wxT(
"%s: Circular inheritance detected in symbol '%s' (lib: %s). Chain: %s" ),
95 visited.insert( parent.get() );
97 parent = parent->GetParent().lock();
112 if( root.get() !=
this )
113 shownText = root->GetDescriptionField().GetShownText( aContext, aDepth );
157 std::function<bool( wxString* )> libSymbolResolver =
158 [&]( wxString* token ) ->
bool
189 while( keywordTokenizer.HasMoreTokens() )
201 if( !footprint.IsEmpty() )
226 const wxString localizedKeywords =
_(
"Keywords" );
259 auto addField = [&](
FIELD_T id,
bool visible )
324 wxFAIL_MSG(
"Failed to clone SCH_ITEM." );
342 SchematicSymbol& def = aOutput;
346 SchematicSymbolType symbolType = SchematicSymbolType::SST_NORMAL;
349 symbolType = SchematicSymbolType::SST_GLOBAL_POWER;
351 symbolType = SchematicSymbolType::SST_LOCAL_POWER;
353 def.set_type( symbolType );
355 SchematicSymbolAttributes* attributes = def.mutable_attributes();
360 attributes->set_do_not_populate(
GetDNP() );
372 if( aSkipPins && drawItem.Type() ==
SCH_PIN_T )
375 SchematicSymbolChild* item = def.add_items();
376 item->mutable_unit()->set_unit( drawItem.GetUnit() );
377 item->mutable_body_style()->set_style( drawItem.GetBodyStyle() );
378 item->set_is_private( drawItem.IsPrivate() );
379 drawItem.Serialize( *item->mutable_item() );
390 def.add_footprint_filters(
filter.ToUTF8() );
392 JumperSettings* jumpers = def.mutable_jumpers();
397 JumperGroup* jumperGroup = jumpers->add_groups();
399 for(
const wxString& pinNumber :
group )
400 jumperGroup->add_pin_numbers( pinNumber.ToUTF8() );
411 SchematicUnitDisplayName* protoName = def.add_unit_display_names();
412 protoName->set_unit( unit );
413 protoName->set_name( displayName.ToUTF8() );
416 SymbolPinMaps* pinMaps = def.mutable_pin_maps();
420 AssociatedFootprint* a = pinMaps->add_associated_footprints();
421 PackLibId( a->mutable_footprint(), assoc.m_FootprintLibId );
422 a->set_map_name( assoc.m_MapName.ToUTF8() );
427 PinMap* m = pinMaps->add_pin_maps();
428 m->set_name( map.GetName().ToUTF8() );
432 PinMapEntry* e = m->add_entries();
433 e->set_pin_number( entry.m_PinNumber.ToUTF8() );
434 e->set_pad_number( entry.m_PadNumber.ToUTF8() );
442 kiapi::schematic::types::SchematicSymbol def;
444 aContainer.PackFrom( def );
454 const SchematicSymbol& def = aInput;
461 case SchematicSymbolType::SST_GLOBAL_POWER:
SetGlobalPower();
break;
462 case SchematicSymbolType::SST_LOCAL_POWER:
SetLocalPower();
break;
466 if( def.has_attributes() )
472 SetDNP( def.attributes().do_not_populate() );
481 for(
const SchematicSymbolChild& child : def.items() )
490 if( !item || !item->Deserialize( child.item() ) )
495 if( child.has_unit() )
496 schItem->
SetUnit( child.unit().unit() );
498 if( child.has_body_style() )
506 if( def.unit_count() > 0 )
509 if( def.body_style_size() > 0 )
511 std::vector<wxString> bodyStyleNames;
513 for(
const SchematicBodyStyle& bodyStyle : def.body_style() )
514 bodyStyleNames.emplace_back( wxString::FromUTF8( bodyStyle.name() ) );
520 if( !def.keywords().empty() )
521 SetKeyWords( wxString::FromUTF8( def.keywords() ) );
523 if( def.footprint_filters_size() > 0 )
525 wxArrayString filters;
527 for(
const std::string&
filter : def.footprint_filters() )
528 filters.Add( wxString::FromUTF8(
filter ) );
535 for(
const JumperGroup&
group : def.jumpers().groups() )
537 std::set<wxString> pinNumbers;
539 for(
const std::string& pinNumber :
group.pin_numbers() )
540 pinNumbers.insert( wxString::FromUTF8( pinNumber ) );
542 if( !pinNumbers.empty() )
549 for(
const SchematicUnitDisplayName& displayName : def.unit_display_names() )
556 if( def.has_pin_maps() )
560 for(
const PinMap& map : def.pin_maps().pin_maps() )
562 PIN_MAP pinMap( wxString::FromUTF8( map.name() ) );
564 for(
const PinMapEntry& entry : map.entries() )
566 pinMap.
SetEntry( wxString::FromUTF8( entry.pin_number() ), wxString::FromUTF8( entry.pad_number() ) );
572 std::vector<ASSOCIATED_FOOTPRINT> associatedFootprints;
574 for(
const AssociatedFootprint& footprint : def.pin_maps().associated_footprints() )
578 assoc.
m_MapName = wxString::FromUTF8( footprint.map_name() );
579 associatedFootprints.push_back( std::move( assoc ) );
592 kiapi::schematic::types::SchematicSymbol def;
594 if( !aContainer.UnpackTo( &def ) )
603 if( &aSymbol ==
this )
687 std::set<const LIB_SYMBOL*> visited;
688 visited.insert(
this );
690 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
695 if( visited.count( parent.get() ) )
698 wxT(
"GetInheritanceDepth: Circular inheritance detected in symbol '%s' "
704 visited.insert( parent.get() );
706 parent = parent->m_parent.lock();
715 std::set<const LIB_SYMBOL*> visited;
716 visited.insert(
this );
718 std::shared_ptr<LIB_SYMBOL> current =
m_me;
719 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
724 if( visited.count( parent.get() ) )
727 wxT(
"GetRootSymbol: Circular inheritance detected in symbol '%s' "
733 visited.insert( parent.get() );
735 parent = parent->m_parent.lock();
748 if( root.get() !=
this )
749 return root->m_unitsLocked;
759 std::shared_ptr<LIB_SYMBOL> root;
781 return aLabel ?
_(
"Alternate" ) : wxString(
_HKI(
"Alternate" ) );
783 return aLabel ?
_(
"Standard" ) : wxString(
_HKI(
"Standard" ) );
791 return names[aBodyStyle - 1];
801 m_libId.SetLibItemName( aName );
827 std::set<const LIB_SYMBOL*> visited;
828 visited.insert(
this );
830 std::shared_ptr<LIB_SYMBOL> ancestor = aParent->
SharedPtr();
834 if( visited.count( ancestor.get() ) )
837 wxT(
"SetParent: Rejecting parent '%s' for symbol '%s' - would create "
838 "circular inheritance (lib: %s)" ),
845 visited.insert( ancestor.get() );
846 ancestor = ancestor->m_parent.lock();
867 return wxEmptyString;
875 std::unique_ptr<LIB_SYMBOL> retv;
880 std::vector<const LIB_SYMBOL*> parentChain;
881 std::set<const LIB_SYMBOL*> visited;
882 visited.insert(
this );
884 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
886 wxCHECK_MSG( parent, retv, wxString::Format(
"Parent of derived symbol '%s' undefined",
m_name ) );
891 if( visited.count( parent.get() ) )
894 wxT(
"Flatten: Circular inheritance detected in symbol '%s' (lib: %s)" ),
899 visited.insert( parent.get() );
900 parentChain.push_back( parent.get() );
901 parent = parent->m_parent.lock();
905 if( !parentChain.empty() )
907 retv = std::make_unique<LIB_SYMBOL>( *parentChain.back() );
910 for(
int i =
static_cast<int>( parentChain.size() ) - 2; i >= 0; --i )
918 *retv->GetField( fieldId ) = *derived->
GetField( fieldId );
936 retv->AddDrawItem( newField );
940 retv->RemoveDrawItem( parentField );
941 retv->AddDrawItem( newField );
955 retv = std::make_unique<LIB_SYMBOL>( *
this );
956 retv->m_parent.reset();
968 *retv->GetField( fieldId ) = *
GetField( fieldId );
987 retv->AddDrawItem( newField );
991 retv->RemoveDrawItem( parentField );
992 retv->AddDrawItem( newField );
1006 retv->AddFile( newFile );
1010 if( !parentChain.empty() )
1012 retv->SetExcludedFromSim( parentChain.front()->GetExcludedFromSim() );
1013 retv->SetExcludedFromBOM( parentChain.front()->GetExcludedFromBOM() );
1014 retv->SetExcludedFromBoard( parentChain.front()->GetExcludedFromBoard() );
1015 retv->SetExcludedFromPosFiles( parentChain.front()->GetExcludedFromPosFiles() );
1023 retv->m_parent.reset();
1027 retv = std::make_unique<LIB_SYMBOL>( *
this );
1050 return m_libId.GetLibNickname();
1060 if( root.get() !=
this )
1061 return root->IsLocalPower();
1074 if( root.get() !=
this )
1076 root->SetLocalPower();
1091 if( root.get() !=
this )
1092 return root->IsGlobalPower();
1111 if( root.get() !=
this )
1113 root->SetGlobalPower();
1128 if( root.get() !=
this )
1129 return root->IsNormal();
1142 if( root.get() !=
this )
1163 u = ( aUnit - 1 ) % 26;
1164 suffix = wxChar( aInitialLetter + u ) + suffix;
1165 aUnit = ( aUnit - u ) / 26;
1166 }
while( aUnit > 0 );
1194 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
1195 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
1196 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
1198 *token = wxEmptyString;
1202 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
1204 wxArrayString parts = wxSplit( footprint,
':' );
1206 if( parts.Count() > 0 )
1209 *token = wxEmptyString;
1213 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
1215 wxArrayString parts = wxSplit( footprint,
':' );
1217 if( parts.Count() > 1 )
1218 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
1220 *token = wxEmptyString;
1224 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
1226 *token =
m_libId.GetUniStringLibNickname();
1229 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
1231 *token =
m_libId.GetUniStringLibItemName();
1234 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
1239 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
1244 else if( token->IsSameAs( wxT(
"SYMBOL_IS_POWER" ) ) )
1246 *token = this->
IsPower() ? wxString( wxS(
"Power Symbol" ) ) : wxString(
"" );
1249 else if( token->IsSameAs( wxT(
"SYMBOL_IS_LOCAL_POWER" ) ) )
1251 *token = this->
IsLocalPower() ? wxString( wxS(
"Local Power Symbol" ) ) : wxString(
"" );
1254 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
1259 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
1264 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
1266 *token = this->
GetExcludedFromSim() ? wxS(
"Excluded from simulation" ) : wxEmptyString;
1269 else if( token->IsSameAs( wxT(
"DNP" ) ) )
1271 *token = this->
GetDNP() ? wxS(
"DNP" ) : wxEmptyString;
1280 const VECTOR2I& aOffset,
bool aDimmed )
1282 wxASSERT( aPlotter !=
nullptr );
1297 color = color.
Mix( bg, 0.5f );
1305 if( item.IsPrivate() )
1313 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1316 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1319 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1325 int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
1327 wxASSERT( aPlotter !=
nullptr );
1339 color = color.
Mix( bg, 0.5f );
1353 wxString tmp = field.
GetText();
1356 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1365 std::vector<SCH_SHAPE*> potential_top_items;
1366 std::vector<SCH_ITEM*> bottom_items;
1375 potential_top_items.push_back( &shape );
1377 bottom_items.push_back( &item );
1381 bottom_items.push_back( &item );
1385 std::sort( potential_top_items.begin(), potential_top_items.end(),
1388 return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea();
1391 for(
SCH_SHAPE* item : potential_top_items )
1393 for(
SCH_ITEM* bottom_item : bottom_items )
1395 if( item->GetBoundingBox().Contains( bottom_item->GetBoundingBox() ) )
1407 wxASSERT( aItem !=
nullptr );
1413 if(
static_cast<SCH_FIELD*
>( aItem )->IsMandatory() )
1419 for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
1455 if( root.get() !=
this )
1456 return const_cast<const LIB_SYMBOL*
>( root.get() )->GetGraphicalPins( aUnit, aBodyStyle );
1459 std::vector<const SCH_PIN*> pins;
1471 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1475 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1478 pins.push_back(
static_cast<const SCH_PIN*
>( &item ) );
1491 if( root.get() !=
this )
1492 return root->GetGraphicalPins( aUnit, aBodyStyle );
1495 std::vector<SCH_PIN*> pins;
1507 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1511 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1514 pins.push_back(
static_cast<SCH_PIN*
>( &item ) );
1523 std::vector<UNIT_PIN_INFO> units;
1527 auto compareByPosition =
1531 VECTOR2I positionB = b->GetPosition();
1533 if( positionA.
x != positionB.
x )
1534 return positionA.
x < positionB.
x;
1536 return positionA.
y < positionB.
y;
1539 for(
int unitIdx = 1; unitIdx <= unitCount; ++unitIdx )
1546 std::sort( pinList.begin(), pinList.end(), compareByPosition );
1548 std::unordered_set<wxString> seenNumbers;
1550 for(
const SCH_PIN* basePin : pinList )
1552 bool stackedValid =
false;
1553 std::vector<wxString> expandedNumbers = basePin->GetStackedPinNumbers( &stackedValid );
1555 if( stackedValid && !expandedNumbers.empty() )
1557 for(
const wxString& number : expandedNumbers )
1559 if( seenNumbers.insert( number ).second )
1566 const wxString& number = basePin->GetNumber();
1568 if( !number.IsEmpty() && seenNumbers.insert( number ).second )
1572 units.push_back( std::move( unitInfo ) );
1581 std::vector<LOGICAL_PIN> out;
1586 std::vector<wxString> expanded =
pin->GetStackedPinNumbers( &valid );
1588 if( valid && !expanded.empty() )
1590 for(
const wxString& num : expanded )
1593 wxLogTrace(
traceStackedPins,
"GetLogicalPins: base='%s' -> '%s'",
pin->GetShownNumber(), num );
1599 wxLogTrace(
traceStackedPins,
"GetLogicalPins: base='%s' (no expansion)",
pin->GetShownNumber() );
1619 int pinCount =
pin->GetStackedPinCount();
1629 if( aNumber ==
pin->GetNumber() )
1639 std::vector<SCH_PIN*> pins;
1643 if( aNumber ==
pin->GetNumber() )
1644 pins.push_back(
pin );
1658 for(
const wxString& logicalNumber :
pin->GetStackedPinNumbers() )
1660 if( aNumber == logicalNumber )
1670 bool aTestOrientation,
bool aTestLength )
const
1675 bool foundMatch =
false;
1679 wxASSERT( otherPin );
1682 if(
pin->GetUnit() != otherPin->GetUnit() )
1686 if(
pin->GetBodyStyle() != otherPin->GetBodyStyle() )
1690 if(
pin->GetPosition() != otherPin->GetPosition() )
1694 if( aTestNums && (
pin->GetNumber() != otherPin->GetNumber() ) )
1698 if( aTestNames && (
pin->GetName() != otherPin->GetName() ) )
1702 if( aTestType && (
pin->GetType() != otherPin->GetType() ) )
1706 if( aTestOrientation && (
pin->GetOrientation() != otherPin->GetOrientation() ) )
1710 if( aTestLength && (
pin->GetLength() != otherPin->GetLength() ) )
1737 bool aIgnoreLabelsOnInvisiblePins )
const
1745 if( root.get() !=
this )
1746 bBox = root->GetUnitBoundingBox( aUnit, aBodyStyle, aIgnoreHiddenFields, aIgnoreLabelsOnInvisiblePins );
1751 if( item.m_unit > 0 &&
m_unitCount > 1 && aUnit > 0 && aUnit != item.m_unit )
1754 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
1757 if( aIgnoreHiddenFields && item.Type() ==
SCH_FIELD_T )
1759 if( !
static_cast<const SCH_FIELD&
>( item ).IsVisible() )
1763 if( item.Type() ==
SCH_PIN_T && !aIgnoreLabelsOnInvisiblePins )
1766 bBox.
Merge(
pin.GetBoundingBox(
true,
true,
false ) );
1770 bBox.
Merge( item.GetBoundingBox() );
1779 bool aIncludePrivateItems )
const
1785 if( item.m_unit > 0 && aUnit > 0 && aUnit != item.m_unit )
1788 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
1791 if( item.IsPrivate() && !aIncludePrivateItems )
1801 if(
pin.IsVisible() )
1807 bbox.
Merge(
pin.GetBoundingBox(
false,
false,
false ) );
1814 bbox.
Merge( item.GetBoundingBox() );
1850 for(
const SCH_FIELD& src : aFieldsList )
1878 aList.push_back(
const_cast<SCH_FIELD*
>( field ) );
1881 std::sort( aList.begin(), aList.end(),
1884 return lhs->GetOrdinal() < rhs->GetOrdinal();
1891 std::vector<SCH_FIELD*> orderedFields;
1896 aList.emplace_back( *field );
1902 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
1907 std::unique_ptr<LIB_SYMBOL> flattenedParent = parent->Flatten();
1910 [&](
const wxString& aFieldName )
1916 std::vector<SCH_FIELD> fields;
1917 std::vector<SCH_FIELD>
result;
1925 if( selected( field.GetName() ) )
1927 if( field.IsMandatory() )
1928 parentField = flattenedParent->GetField( field.GetId() );
1930 parentField = flattenedParent->GetField( field.GetName() );
1938 field.SetText( parentField->
GetText() );
1942 field.SetVisible( parentField->
IsVisible() );
1950 bool visible = field.IsVisible();
1951 VECTOR2I pos = field.GetPosition();
1953 field.SetAttributes( *parentField );
1955 field.SetVisible( visible );
1956 field.SetPosition( pos );
1960 field.SetTextPos( parentField->
GetTextPos() );
1969 result.emplace_back( std::move( field ) );
1972 std::vector<SCH_FIELD*> parentFields;
1974 flattenedParent->GetFields( parentFields );
1976 for(
SCH_FIELD* parentField : parentFields )
1978 if( !selected( parentField->GetName() ) )
1981 if( !
GetField( parentField->GetName() ) )
1986 newField->
SetName( parentField->GetUntranslatedName() );
1987 newField->
SetText( parentField->GetText() );
2001 ordinal = std::max( ordinal,
static_cast<const SCH_FIELD*
>( &item )->GetOrdinal() + 1 );
2013 if( field->
GetId() == aFieldType )
2027 if( field->
GetId() == aFieldType )
2041 if( field.
GetName() == aFieldName )
2055 if( field.
GetName() == aFieldName )
2094 wxASSERT( field !=
nullptr );
2102 wxASSERT( field !=
nullptr );
2110 wxASSERT( field !=
nullptr );
2118 wxASSERT( field !=
nullptr );
2126 wxASSERT( field !=
nullptr );
2135 refDesignator.Replace( wxS(
"~" ), wxS(
" " ) );
2137 wxString prefix = refDesignator;
2139 while( prefix.Length() )
2141 wxUniCharRef last = prefix.Last();
2143 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
2144 prefix.RemoveLast();
2150 prefix.Trim(
true );
2151 prefix.Trim(
false );
2167 item.Move( aOffset );
2187 if( root.get() !=
this )
2188 return root->HasLegacyAlternateBodyStyle();
2201 if( root.get() !=
this )
2202 return root->GetMaxPinNumber();
2205 int maxPinNumber = 0;
2210 long currentPinNumber = 0;
2212 if(
pin->GetNumber().ToLong( ¤tPinNumber ) )
2213 maxPinNumber = std::max( maxPinNumber, (
int) currentPinNumber );
2216 return maxPinNumber;
2225 item.ClearTempFlags();
2234 item.ClearEditFlags();
2242 if( ( aUnit && item.m_unit && aUnit != item.m_unit )
2243 || ( aBodyStyle && item.m_bodyStyle && aBodyStyle != item.m_bodyStyle )
2249 if( item.HitTest( aPoint ) )
2282 if( item.IsType( aScanTypes ) )
2298 wxCHECK_RET( aCount >= 1, wxString::Format( wxT(
"Invalid unit count %d, ignoring." ), aCount ) );
2312 if( it->m_unit > aCount )
2319 else if( aDuplicateDrawItems )
2326 std::vector<SCH_ITEM*> tmp;
2330 if( item.m_unit != 1 )
2333 for(
int j = prevCount + 1; j <= aCount; j++ )
2337 tmp.push_back( newItem );
2357 if( root.get() !=
this )
2358 return root->GetUnitCount();
2380 if( root.get() !=
this )
2381 return root->m_demorgan;
2394 if( root.get() !=
this )
2395 return root->m_bodyStyleNames;
2404 wxCHECK_RET( aCount >= 1,
2405 wxString::Format( wxT(
"Invalid body style count %d, ignoring." ), aCount ) );
2410 if( prevCount < aCount && ( aDuplicateDrawItems || aDuplicatePins ) )
2412 std::vector<SCH_ITEM*> tmp;
2416 if( item.Type() !=
SCH_PIN_T && !aDuplicateDrawItems )
2421 for(
int j = prevCount + 1; j <= aCount; j++ )
2425 tmp.push_back( newItem );
2448 if( i->m_bodyStyle > aBodyStyleCount )
2458 std::vector<SCH_ITEM*> unitItems;
2465 if( ( aBodyStyle == -1 && item.GetUnit() == aUnit ) || ( aUnit == -1 && item.GetBodyStyle() == aBodyStyle )
2466 || ( aUnit == item.GetUnit() && aBodyStyle == item.GetBodyStyle() ) )
2468 unitItems.push_back( &item );
2478 std::vector<LIB_SYMBOL_UNIT> units;
2488 units.push_back( std::move( record ) );
2497 int unit = item.GetUnit();
2498 int bodyStyle = item.GetBodyStyle();
2500 auto it = std::find_if( units.begin(), units.end(),
2503 return a.m_unit == unit && a.m_bodyStyle == bodyStyle;
2506 if( it == units.end() )
2511 it = units.insert( units.end(), std::move( record ) );
2514 it->m_items.push_back( &item );
2517 std::sort( units.begin(), units.end(),
2520 if( a.m_unit == b.m_unit )
2521 return a.m_bodyStyle < b.m_bodyStyle;
2523 return a.m_unit < b.m_unit;
2530#define REPORT( msg ) \
2533 aReporter->Report( msg ); \
2535#define ITEM_DESC( item ) ( item )->GetItemDescription( &unitsProvider, false )
2551 REPORT(
_(
"Name differs." ) );
2560 REPORT(
_(
"Library ID differs." ) );
2573 REPORT(
_(
"Symbol parent differs." ) );
2583 REPORT(
_(
"Power flag differs." ) );
2592 REPORT(
_(
"Unit count differs." ) );
2600 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aShapes;
2601 std::set<const SCH_FIELD*> aFields;
2602 std::set<const SCH_PIN*> aPins;
2607 aShapes.insert( &( *it ) );
2609 aFields.insert(
static_cast<const SCH_FIELD*
>( &( *it ) ) );
2611 aPins.insert(
static_cast<const SCH_PIN*
>( &( *it ) ) );
2614 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bShapes;
2615 std::set<const SCH_FIELD*> bFields;
2616 std::set<const SCH_PIN*> bPins;
2621 bShapes.insert( &( *it ) );
2623 bFields.insert(
static_cast<const SCH_FIELD*
>( &( *it ) ) );
2625 bPins.insert(
static_cast<const SCH_PIN*
>( &( *it ) ) );
2628 if(
int tmp =
static_cast<int>( aShapes.size() - bShapes.size() ) )
2631 REPORT(
_(
"Graphic item count differs." ) );
2638 for(
auto aIt = aShapes.begin(), bIt = bShapes.begin(); aIt != aShapes.end(); aIt++, bIt++ )
2640 if(
int tmp2 = ( *aIt )->compare( *( *bIt ), aCompareFlags ) )
2643 REPORT( wxString::Format(
_(
"Graphic item differs: %s; %s." ),
2653 for(
const SCH_PIN* aPin : aPins )
2655 const SCH_PIN* bPin = aRhs.
GetPin( aPin->GetNumber(), aPin->GetUnit(), aPin->GetBodyStyle() );
2660 REPORT( wxString::Format(
_(
"Extra pin in schematic symbol: %s." ),
ITEM_DESC( aPin ) ) );
2665 else if(
int tmp =
static_cast<const SCH_ITEM*
>( aPin )->
compare( *bPin, aCompareFlags ) )
2668 REPORT( wxString::Format(
_(
"Pin %s differs: %s; %s" ),
2678 for(
const SCH_PIN* bPin : bPins )
2680 const SCH_PIN* aPin =
GetPin( bPin->GetNumber(), bPin->GetUnit(), bPin->GetBodyStyle() );
2685 REPORT( wxString::Format(
_(
"Missing pin in schematic symbol: %s." ),
ITEM_DESC( bPin ) ) );
2692 for(
const SCH_FIELD* aField : aFields )
2696 if( aField->IsMandatory() )
2697 bField = aRhs.
GetField( aField->GetId() );
2699 bField = aRhs.
GetField( aField->GetName() );
2706 REPORT( wxString::Format(
_(
"Extra field in schematic symbol: %s." ), aField->GetName(
false ) ) );
2716 if(
int tmp = aField->GetText().compare( bField->
GetText() ) )
2719 REPORT( wxString::Format(
_(
"Field '%s' differs: %s; %s." ),
2720 aField->GetName(
false ),
2731 if( aField->GetFont() != bField->
GetFont() )
2733 retv = std::less<KIFONT::FONT*>{}( aField->GetFont(), bField->
GetFont() ) ? -1 : 1;
2734 REPORT( wxString::Format(
_(
"Field '%s' fonts differ." ), aField->GetName(
false ) ) );
2740 if( aField->GetTextSize() != bField->
GetTextSize() )
2742 if( aField->GetTextSize().x != bField->
GetTextSize().
x )
2743 retv = aField->GetTextSize().x - bField->
GetTextSize().
x;
2745 retv = aField->GetTextSize().y - bField->
GetTextSize().
y;
2747 REPORT( wxString::Format(
_(
"Field '%s' text sizes differ." ), aField->GetName(
false ) ) );
2753 if(
int tmp = aField->GetAttributes().Compare( bField->
GetAttributes() ) )
2756 REPORT( wxString::Format(
_(
"Field '%s' text styles differ." ), aField->GetName(
false ) ) );
2765 if( aField->IsVisible() != bField->
IsVisible() )
2767 retv = aField->IsVisible() ? 1 : -1;
2768 REPORT( wxString::Format(
_(
"Field '%s' visibility flags differ." ), aField->GetName(
false ) ) );
2774 if( aField->IsNameShown() != bField->
IsNameShown() )
2776 retv = aField->IsNameShown() ? 1 : -1;
2777 REPORT( wxString::Format(
_(
"Field '%s' name shown flags differ." ), aField->GetName(
false ) ) );
2784 if( aField->IsPrivate() != bField->
IsPrivate() )
2786 retv = aField->IsPrivate() ? 1 : -1;
2787 REPORT( wxString::Format(
_(
"Field '%s' privacy flags differ." ), aField->GetName(
false ) ) );
2795 if( aField->GetPosition().x != bField->
GetPosition().
x )
2796 retv = aField->GetPosition().x - bField->
GetPosition().
x;
2798 if( aField->GetPosition().y != bField->
GetPosition().
y )
2799 retv = aField->GetPosition().y - bField->
GetPosition().
y;
2803 REPORT( wxString::Format(
_(
"Field '%s' positions differ." ), aField->GetName(
false ) ) );
2814 for(
const SCH_FIELD* bField : bFields )
2818 if( bField->IsMandatory() )
2819 aField =
GetField( bField->GetId() );
2821 aField =
GetField( bField->GetName() );
2826 REPORT( wxString::Format(
_(
"Missing field in schematic symbol: %s." ), bField->GetName(
false ) ) );
2837 REPORT(
_(
"Footprint filter count differs." ) );
2844 for(
size_t i = 0; i <
m_fpFilters.GetCount(); i++ )
2849 REPORT(
_(
"Footprint filters differ." ) );
2860 REPORT(
_(
"Pin map count differs." ) );
2868 REPORT(
_(
"Pin maps differ." ) );
2877 REPORT(
_(
"Associated footprint count differs." ) );
2885 REPORT(
_(
"Associated footprints differ." ) );
2894 REPORT(
_(
"Symbol keywords differ." ) );
2903 REPORT(
_(
"Symbol pin name offsets differ." ) );
2914 REPORT(
_(
"Show pin names settings differ." ) );
2923 REPORT(
_(
"Show pin numbers settings differ." ) );
2935 REPORT(
_(
"Exclude from simulation settings differ." ) );
2947 REPORT(
_(
"Exclude from bill of materials settings differ." ) );
2959 REPORT(
_(
"Exclude from board settings differ." ) );
2970 retv = (
m_DNP ) ? -1 : 1;
2971 REPORT(
_(
"Do not populate settings differ." ) );
2983 REPORT(
_(
"Exclude from position files settings differ." ) );
3019 return Compare( *tmp, aCompareFlags );
3028 double similarity = 0.0;
3037 double max_similarity = 0.0;
3041 double temp_similarity = item.Similarity( otherItem );
3042 max_similarity = std::max( max_similarity, temp_similarity );
3044 if( max_similarity == 1.0 )
3048 similarity += max_similarity;
3054 double max_similarity = 0.0;
3058 double temp_similarity =
pin->Similarity( *otherPin );
3059 max_similarity = std::max( max_similarity, temp_similarity );
3061 if( max_similarity == 1.0 )
3065 similarity += max_similarity;
3068 if( totalItems == 0 )
3071 similarity /= totalItems;
3123 std::set<const LIB_SYMBOL*> visited;
3124 visited.insert(
this );
3126 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
3131 if( visited.count( parent.get() ) )
3134 wxT(
"AppendParentEmbeddedFiles: Circular inheritance detected in "
3135 "symbol '%s' (lib: %s)" ),
3140 visited.insert( parent.get() );
3141 aStack.push_back( parent->GetEmbeddedFiles() );
3142 parent = parent->GetParent().lock();
3151 std::set<KIFONT::OUTLINE_FONT*>
fonts;
3164 if( permission == EMBEDDING_PERMISSION::EDITABLE || permission == EMBEDDING_PERMISSION::INSTALLABLE )
3165 fonts.insert( outline );
3184 wxLogTrace(
"EMBED",
"Failed to add font file: %s", font->GetFileName() );
3197 if(
group.contains( aPinNumber ) )
3201 return std::nullopt;
3212 const wxString groupFields =
_HKI(
"Fields" );
3230 const wxString groupSymbolDef =
_HKI(
"Symbol Definition" );
3239 const wxString groupPinDisplay =
_HKI(
"Pin Display" );
3254 const wxString groupAttributes =
_HKI(
"Attributes" );
3269 const wxString groupUnits =
_HKI(
"Units and Body Styles" );
3278 auto multiBodyStyle =
3282 return symbol->IsMultiBodyStyle();
3293 wxPGChoices choices;
3297 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
3298 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
static const COLOR4D WHITE
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
virtual void ClearEditFlags()
KICAD_T Type() const
Returns the type of object.
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM_FLAGS GetFlags() const
virtual void ClearTempFlags()
FILL_T GetFillMode() const
virtual 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.
FONT is an abstract base class for both outline and stroke fonts.
Class OUTLINE_FONT implements outline font drawing.
EMBEDDING_PERMISSION GetEmbeddingPermission() const
A color representation with 4 components: red, green, blue, alpha.
std::shared_ptr< wxString > m_text
COLOR4D & Desaturate()
Removes color (in HSL model)
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Object used to load, save, search, and otherwise manipulate symbol library files.
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Define a library symbol object.
LIB_ITEMS_CONTAINER m_drawings
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
SCH_FIELD & GetDescriptionField()
Return reference to the description field.
const LIB_ID & GetLibId() const override
const BOX2I GetUnitBoundingBox(int aUnit, int aBodyStyle, bool aIgnoreHiddenFields=true, bool aIgnoreLabelsOnInvisiblePins=true) const
Get the bounding box for the symbol.
wxString GetKeyWords() const override
std::weak_ptr< LIB_SYMBOL > & GetParent()
wxString GetBodyStyleProp() const override
LIBRENTRYOPTIONS m_options
Special symbol features such as POWER or NORMAL.
wxString GetRefProp() const
bool PinsConflictWith(const LIB_SYMBOL &aOtherSymbol, bool aTestNums, bool aTestNames, bool aTestType, bool aTestOrientation, bool aTestLength) const
Return true if this symbol's pins do not match another symbol's pins.
bool GetUnitsInterchangeableProp() const
wxString m_shownDescriptionCache
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void GetFields(std::vector< SCH_FIELD * > &aList, bool aVisibleOnly=false) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
bool IsPower() const override
const std::vector< ASSOCIATED_FOOTPRINT > & GetEffectiveAssociatedFootprints() const
bool UnitsLocked() const
Check whether symbol units are interchangeable.
SCH_FIELD & GetDatasheetField()
Return reference to the datasheet field.
void RefreshLibraryTreeCaches()
std::weak_ptr< LIB_SYMBOL > m_parent
Use for inherited symbols.
void SetExcludedFromBoardProp(bool aExclude)
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of SCH_ITEM objects separated by unit and convert number.
std::map< int, wxString > m_unitDisplayNames
std::vector< std::set< wxString > > m_jumperPinGroups
A list of jumper pin groups, each of which is a set of pin numbers that should be jumpered together (...
void ClearTempFlags() override
Clears the status flag all draw objects in this symbol.
void 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 ...
wxString GetFootprint() override
For items with footprint fields.
const wxString GetLibraryName() const
void SetFields(const std::vector< SCH_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
void SetExcludedFromPosFilesProp(bool aExclude)
void SetLib(LEGACY_SYMBOL_LIB *aLibrary)
bool GetPowerSymbolProp() const
bool IsMultiBodyStyle() const override
int GetMaxPinNumber() const
std::vector< SEARCH_TERM > m_searchTermsCache
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
SCH_FIELD * GetField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName; return nullptr if not found.
SCH_FIELD & GetFootprintField()
Return reference to the footprint field.
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()
Returns a dummy LIB_SYMBOL, used when one is missing in the schematic.
void PlotFields(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed)
Plot symbol fields.
wxString GetDatasheetProp() const
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)
Gets the Description field text value */.
void cacheChooserFields()
std::shared_ptr< LIB_SYMBOL > m_me
wxString GetValueProp() const
bool GetExcludedFromBOMProp() const
void SetKeyWords(const wxString &aKeyWords)
SCH_FIELD & GetValueField()
Return reference to the value field.
bool IsLocalPower() const override
LIB_SYMBOL(const wxString &aName, LIB_SYMBOL *aParent=nullptr, LEGACY_SYMBOL_LIB *aLibrary=nullptr)
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
void SetBodyStyleProp(const wxString &aBodyStyle) override
void SetPinMaps(const PIN_MAP_SET &aPinMaps)
timestamp_t m_lastModDate
void SetExcludedFromSimProp(bool aExclude)
bool GetExcludedFromBoardProp() const
std::optional< const std::set< wxString > > GetJumperPinGroup(const wxString &aPinNumber) const
Retrieves the jumper group containing the specified pin number, if one exists.
wxString getShownDescription(RESOLUTION_CONTEXT aContext, int aDepth) const
std::vector< SCH_PIN * > GetPins() const override
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
Sets the Description field text value.
void SetFootprintProp(const wxString &aFootprint)
std::vector< LOGICAL_PIN > GetLogicalPins(int aUnit, int aBodyStyle) const
Return all logical pins (expanded) filtered by unit/body.
bool HasDeMorganBodyStyles() const override
const LIB_SYMBOL & operator=(const LIB_SYMBOL &aSymbol)
bool m_unitsLocked
True if symbol has multiple units and changing one unit does not automatically change another unit.
wxArrayString m_fpFilters
List of suitable footprint names for the symbol (wild card names accepted).
void Move(const VECTOR2I &aOffset) override
Move the symbol aOffset.
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...
EMBEDDED_FILES * GetEmbeddedFiles() override
void SetPowerSymbolProp(bool aIsPower)
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)
int GetPinCount() override
std::map< wxString, wxString > m_chooserFieldsCache
void SetLibId(const LIB_ID &aLibId)
void AddField(SCH_FIELD *aField)
Add a field.
void ClearEditFlags() override
bool GetLocalPowerSymbolProp() const
bool GetDuplicatePinNumbersAreJumpers() const
LIB_ID GetLIB_ID() const override
std::vector< ASSOCIATED_FOOTPRINT > m_associatedFootprints
Footprints associated with this symbol, each tied to a named pin map.
const SCH_PIN * GetPin(const wxString &aNumber, int aUnit=0, int aBodyStyle=0) const
Return pin object with the requested pin aNumber.
bool m_duplicatePinNumbersAreJumpers
Flag that this symbol should automatically treat sets of two or more pins with the same number as jum...
void SetUnitProp(int aUnits)
wxString GetFootprintProp() const
std::vector< std::set< wxString > > & JumperPinGroups()
Each jumper pin group is a set of pin numbers that should be treated as internally connected.
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()
Return reference to the reference designator field.
wxString GetShownDescription(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
void cacheShownDescription()
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this symbol.
static constexpr int FIRST_TYPE
ITERATOR_BASE< SCH_ITEM, MULTIVECTOR< SCH_ITEM, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::iterator > ITERATOR
ITERATOR end(int aType=UNDEFINED_TYPE)
static constexpr int LAST_TYPE
ITERATOR begin(int aType=UNDEFINED_TYPE)
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.
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
A pure virtual class used to derive REPORTER objects from.
wxString GetFullText(int unit=1) const
Return the text of a field.
VECTOR2I GetPosition() const override
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.
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 intersheets references prefix string.
@ 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.
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)
@ PT_SIZE
Size expressed in distance units (mm/inch)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
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
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