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() );
437 SchematicUnitDisplayName* protoName = def.add_unit_display_names();
438 protoName->set_unit( unit );
439 protoName->set_name( displayName.ToUTF8() );
442 SymbolPinMaps* pinMaps = def.mutable_pin_maps();
446 AssociatedFootprint* a = pinMaps->add_associated_footprints();
447 PackLibId( a->mutable_footprint(), assoc.m_FootprintLibId );
448 a->set_map_name( assoc.m_MapName.ToUTF8() );
453 PinMap* m = pinMaps->add_pin_maps();
454 m->set_name( map.GetName().ToUTF8() );
458 PinMapEntry* e = m->add_entries();
459 e->set_pin_number( entry.m_PinNumber.ToUTF8() );
460 e->set_pad_number( entry.m_PadNumber.ToUTF8() );
468 kiapi::schematic::types::SchematicSymbol def;
470 aContainer.PackFrom( def );
480 const SchematicSymbol& def = aInput;
487 case SchematicSymbolType::SST_GLOBAL_POWER:
SetGlobalPower();
break;
488 case SchematicSymbolType::SST_LOCAL_POWER:
SetLocalPower();
break;
492 if( def.has_attributes() )
498 SetDNP( def.attributes().do_not_populate() );
507 for(
const SchematicSymbolChild& child : def.items() )
516 if( !item || !item->Deserialize( child.item() ) )
521 if( child.has_unit() )
522 schItem->
SetUnit( child.unit().unit() );
524 if( child.has_body_style() )
532 if( def.unit_count() > 0 )
535 if( def.body_style_size() > 0 )
537 std::vector<wxString> bodyStyleNames;
539 for(
const SchematicBodyStyle& bodyStyle : def.body_style() )
540 bodyStyleNames.emplace_back( wxString::FromUTF8( bodyStyle.name() ) );
546 if( !def.keywords().empty() )
547 SetKeyWords( wxString::FromUTF8( def.keywords() ) );
549 if( def.footprint_filters_size() > 0 )
553 for(
const std::string&
filter : def.footprint_filters() )
562 jumperGroups.
Clear();
564 for(
const JumperGroup&
group : def.jumpers().groups() )
566 std::set<wxString> pinNumbers;
568 for(
const std::string& pinNumber :
group.pin_numbers() )
569 pinNumbers.insert( wxString::FromUTF8( pinNumber ) );
571 jumperGroups.
Add( std::move( pinNumbers ) );
577 for(
const SchematicUnitDisplayName& displayName : def.unit_display_names() )
584 if( def.has_pin_maps() )
588 for(
const PinMap& map : def.pin_maps().pin_maps() )
590 PIN_MAP pinMap( wxString::FromUTF8( map.name() ) );
592 for(
const PinMapEntry& entry : map.entries() )
594 pinMap.
SetEntry( wxString::FromUTF8( entry.pin_number() ), wxString::FromUTF8( entry.pad_number() ) );
600 std::vector<ASSOCIATED_FOOTPRINT> associatedFootprints;
602 for(
const AssociatedFootprint& footprint : def.pin_maps().associated_footprints() )
606 assoc.
m_MapName = wxString::FromUTF8( footprint.map_name() );
607 associatedFootprints.push_back( std::move( assoc ) );
621 kiapi::schematic::types::SchematicSymbol def;
623 if( !aContainer.UnpackTo( &def ) )
632 if( &aSymbol ==
this )
713 std::set<const LIB_SYMBOL*> visited;
714 visited.insert(
this );
716 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
721 if( visited.count( parent.get() ) )
724 wxT(
"GetInheritanceDepth: Circular inheritance detected in symbol '%s' "
730 visited.insert( parent.get() );
732 parent = parent->m_parent.lock();
741 std::set<const LIB_SYMBOL*> visited;
742 visited.insert(
this );
744 std::shared_ptr<LIB_SYMBOL> current =
m_me;
745 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
750 if( visited.count( parent.get() ) )
753 wxT(
"GetRootSymbol: Circular inheritance detected in symbol '%s' "
759 visited.insert( parent.get() );
761 parent = parent->m_parent.lock();
774 if( root.get() !=
this )
775 return root->m_unitsLocked;
785 std::shared_ptr<LIB_SYMBOL> root;
807 return aLabel ?
_(
"Alternate" ) : wxString(
_HKI(
"Alternate" ) );
809 return aLabel ?
_(
"Standard" ) : wxString(
_HKI(
"Standard" ) );
817 return names[aBodyStyle - 1];
827 m_libId.SetLibItemName( aName );
846 std::set<const LIB_SYMBOL*> visited;
847 visited.insert(
this );
849 std::shared_ptr<LIB_SYMBOL> ancestor = aParent->
SharedPtr();
853 if( visited.count( ancestor.get() ) )
856 "- would create circular inheritance (lib: %s)" ),
863 visited.insert( ancestor.get() );
864 ancestor = ancestor->m_parent.lock();
887 return wxEmptyString;
895 std::unique_ptr<LIB_SYMBOL> retv;
900 std::vector<const LIB_SYMBOL*> parentChain;
901 std::set<const LIB_SYMBOL*> visited;
902 visited.insert(
this );
904 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
906 wxCHECK_MSG( parent, retv, wxString::Format(
"Parent of derived symbol '%s' undefined",
m_name ) );
911 if( visited.count( parent.get() ) )
914 wxT(
"Flatten: Circular inheritance detected in symbol '%s' (lib: %s)" ),
919 visited.insert( parent.get() );
920 parentChain.push_back( parent.get() );
921 parent = parent->m_parent.lock();
925 if( !parentChain.empty() )
927 retv = std::make_unique<LIB_SYMBOL>( *parentChain.back() );
930 for(
int i =
static_cast<int>( parentChain.size() ) - 2; i >= 0; --i )
938 *retv->GetField( fieldId ) = *derived->
GetField( fieldId );
956 retv->AddDrawItem( newField );
960 retv->RemoveDrawItem( parentField );
961 retv->AddDrawItem( newField );
975 retv = std::make_unique<LIB_SYMBOL>( *
this );
976 retv->m_parent.reset();
988 *retv->GetField( fieldId ) = *
GetField( fieldId );
1007 retv->AddDrawItem( newField );
1011 retv->RemoveDrawItem( parentField );
1012 retv->AddDrawItem( newField );
1030 retv->AddFile( newFile );
1033 for(
const LIB_SYMBOL* ancestor : parentChain )
1035 for(
const auto& [
name, file] : ancestor->EmbeddedFileMap() )
1038 retv->AddFile( newFile );
1045 if( !parentChain.empty() )
1047 retv->SetExcludedFromSim( parentChain.back()->GetExcludedFromSim() );
1048 retv->SetExcludedFromBOM( parentChain.back()->GetExcludedFromBOM() );
1049 retv->SetExcludedFromBoard( parentChain.back()->GetExcludedFromBoard() );
1050 retv->SetExcludedFromPosFiles( parentChain.back()->GetExcludedFromPosFiles() );
1058 retv->m_cachesDirty =
true;
1059 retv->m_parent.reset();
1063 retv = std::make_unique<LIB_SYMBOL>( *
this );
1083 return m_libId.GetLibNickname();
1093 if( root.get() !=
this )
1094 return root->IsLocalPower();
1107 if( root.get() !=
this )
1109 root->SetLocalPower();
1126 if( root.get() !=
this )
1127 return root->IsGlobalPower();
1146 if( root.get() !=
this )
1148 root->SetGlobalPower();
1165 if( root.get() !=
this )
1166 return root->IsNormal();
1179 if( root.get() !=
this )
1202 u = ( aUnit - 1 ) % 26;
1203 suffix = wxChar( aInitialLetter + u ) + suffix;
1204 aUnit = ( aUnit - u ) / 26;
1205 }
while( aUnit > 0 );
1233 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
1234 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
1235 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
1237 *token = wxEmptyString;
1241 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
1243 wxArrayString parts = wxSplit( footprint,
':' );
1245 if( parts.Count() > 0 )
1248 *token = wxEmptyString;
1252 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
1254 wxArrayString parts = wxSplit( footprint,
':' );
1256 if( parts.Count() > 1 )
1257 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
1259 *token = wxEmptyString;
1263 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
1265 *token =
m_libId.GetUniStringLibNickname();
1268 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
1270 *token =
m_libId.GetUniStringLibItemName();
1273 else if( token->IsSameAs( wxT(
"SYMBOL_PARENT" ) ) )
1275 std::shared_ptr<LIB_SYMBOL> parent =
GetParent().lock();
1276 *token = parent ? parent->GetName() : wxString();
1279 else if( token->IsSameAs( wxT(
"SYMBOL_ROOT" ) ) )
1282 *token = root ? root->GetName() :
GetName();
1285 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
1290 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
1295 else if( token->IsSameAs( wxT(
"SYMBOL_IS_POWER" ) ) )
1297 *token = this->
IsPower() ? wxString( wxS(
"Power Symbol" ) ) : wxString(
"" );
1300 else if( token->IsSameAs( wxT(
"SYMBOL_IS_LOCAL_POWER" ) ) )
1302 *token = this->
IsLocalPower() ? wxString( wxS(
"Local Power Symbol" ) ) : wxString(
"" );
1305 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
1310 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
1315 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
1317 *token = this->
GetExcludedFromSim() ? wxS(
"Excluded from simulation" ) : wxEmptyString;
1320 else if( token->IsSameAs( wxT(
"DNP" ) ) )
1322 *token = this->
GetDNP() ? wxS(
"DNP" ) : wxEmptyString;
1331 const VECTOR2I& aOffset,
bool aDimmed )
1333 wxASSERT( aPlotter !=
nullptr );
1348 color = color.
Mix( bg, 0.5f );
1356 if( item.IsPrivate() )
1364 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1367 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1370 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1376 int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
1378 wxASSERT( aPlotter !=
nullptr );
1390 color = color.
Mix( bg, 0.5f );
1404 wxString tmp = field.
GetText();
1407 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1416 std::vector<SCH_SHAPE*> potential_top_items;
1417 std::vector<SCH_ITEM*> bottom_items;
1426 potential_top_items.push_back( &shape );
1428 bottom_items.push_back( &item );
1432 bottom_items.push_back( &item );
1436 std::sort( potential_top_items.begin(), potential_top_items.end(),
1439 return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea();
1442 for(
SCH_SHAPE* item : potential_top_items )
1444 for(
SCH_ITEM* bottom_item : bottom_items )
1446 if( item->GetBoundingBox().Contains( bottom_item->GetBoundingBox() ) )
1458 wxASSERT( aItem !=
nullptr );
1464 if(
static_cast<SCH_FIELD*
>( aItem )->IsMandatory() )
1470 for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
1504 if( root.get() !=
this )
1505 return const_cast<const LIB_SYMBOL*
>( root.get() )->GetGraphicalPins( aUnit, aBodyStyle );
1508 std::vector<SCH_PIN*> pins;
1520 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
1524 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
1527 pins.push_back(
static_cast<SCH_PIN*
>(
const_cast<SCH_ITEM*
>( &item ) ) );
1536 std::vector<UNIT_PIN_INFO> units;
1540 auto compareByPosition =
1544 VECTOR2I positionB = b->GetPosition();
1546 if( positionA.
x != positionB.
x )
1547 return positionA.
x < positionB.
x;
1549 return positionA.
y < positionB.
y;
1552 for(
int unitIdx = 1; unitIdx <= unitCount; ++unitIdx )
1559 std::sort( pinList.begin(), pinList.end(), compareByPosition );
1561 std::unordered_set<wxString> seenNumbers;
1563 for(
const SCH_PIN* basePin : pinList )
1565 bool stackedValid =
false;
1566 std::vector<wxString> expandedNumbers = basePin->GetStackedPinNumbers( &stackedValid );
1568 if( stackedValid && !expandedNumbers.empty() )
1570 for(
const wxString& number : expandedNumbers )
1572 if( seenNumbers.insert( number ).second )
1579 const wxString& number = basePin->GetNumber();
1581 if( !number.IsEmpty() && seenNumbers.insert( number ).second )
1585 units.push_back( std::move( unitInfo ) );
1594 std::vector<LOGICAL_PIN> out;
1599 std::vector<wxString> expanded =
pin->GetStackedPinNumbers( &valid );
1601 if( valid && !expanded.empty() )
1603 for(
const wxString& num : expanded )
1606 wxLogTrace(
traceStackedPins,
"GetLogicalPins: base='%s' -> '%s'",
pin->GetShownNumber(), num );
1612 wxLogTrace(
traceStackedPins,
"GetLogicalPins: base='%s' (no expansion)",
pin->GetShownNumber() );
1633 if( aNumber ==
pin->GetNumber() )
1643 std::vector<SCH_PIN*> pins;
1647 if( aNumber ==
pin->GetNumber() )
1648 pins.push_back(
pin );
1662 for(
const wxString& logicalNumber :
pin->GetStackedPinNumbers() )
1664 if( aNumber == logicalNumber )
1674 bool aTestOrientation,
bool aTestLength )
const
1679 bool foundMatch =
false;
1683 wxASSERT( otherPin );
1686 if(
pin->GetUnit() != otherPin->GetUnit() )
1690 if(
pin->GetBodyStyle() != otherPin->GetBodyStyle() )
1694 if(
pin->GetPosition() != otherPin->GetPosition() )
1698 if( aTestNums && (
pin->GetNumber() != otherPin->GetNumber() ) )
1702 if( aTestNames && (
pin->GetName() != otherPin->GetName() ) )
1706 if( aTestType && (
pin->GetType() != otherPin->GetType() ) )
1710 if( aTestOrientation && (
pin->GetOrientation() != otherPin->GetOrientation() ) )
1714 if( aTestLength && (
pin->GetLength() != otherPin->GetLength() ) )
1734 bool aIgnoreLabelsOnInvisiblePins )
const
1742 if( root.get() !=
this )
1743 bBox = root->GetUnitBoundingBox( aUnit, aBodyStyle, aIgnoreHiddenFields, aIgnoreLabelsOnInvisiblePins );
1748 if( item.m_unit > 0 &&
m_unitCount > 1 && aUnit > 0 && aUnit != item.m_unit )
1751 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
1754 if( aIgnoreHiddenFields && item.Type() ==
SCH_FIELD_T )
1756 if( !
static_cast<const SCH_FIELD&
>( item ).IsVisible() )
1760 if( item.Type() ==
SCH_PIN_T && !aIgnoreLabelsOnInvisiblePins )
1763 bBox.
Merge(
pin.GetBoundingBox(
true,
true,
false ) );
1767 bBox.
Merge( item.GetBoundingBox() );
1776 bool aIncludePrivateItems )
const
1782 if( item.m_unit > 0 && aUnit > 0 && aUnit != item.m_unit )
1785 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
1788 if( item.IsPrivate() && !aIncludePrivateItems )
1798 if(
pin.IsVisible() )
1804 bbox.
Merge(
pin.GetBoundingBox(
false,
false,
false ) );
1811 bbox.
Merge( item.GetBoundingBox() );
1842 for(
const SCH_FIELD& src : aFieldsList )
1868 aList.push_back(
const_cast<SCH_FIELD*
>( field ) );
1871 std::sort( aList.begin(), aList.end(),
1874 return lhs->GetOrdinal() < rhs->GetOrdinal();
1881 std::vector<SCH_FIELD*> orderedFields;
1886 aList.emplace_back( *field );
1892 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
1897 std::unique_ptr<LIB_SYMBOL> flattenedParent = parent->Flatten();
1900 [&](
const wxString& aFieldName )
1906 std::vector<SCH_FIELD> fieldsCopy;
1907 std::vector<SCH_FIELD>
result;
1915 if( selected( field.GetName() ) )
1917 if( field.IsMandatory() )
1918 parentField = flattenedParent->GetField( field.GetId() );
1920 parentField = flattenedParent->GetField( field.GetName() );
1928 field.SetText( parentField->
GetText() );
1932 field.SetVisible( parentField->
IsVisible() );
1940 bool visible = field.IsVisible();
1941 VECTOR2I pos = field.GetPosition();
1943 field.SetAttributes( *parentField );
1945 field.SetVisible( visible );
1946 field.SetPosition( pos );
1950 field.SetTextPos( parentField->
GetTextPos() );
1959 result.emplace_back( std::move( field ) );
1963 std::vector<SCH_FIELD*> parentFields;
1965 flattenedParent->GetFields( parentFields );
1967 for(
SCH_FIELD* parentField : parentFields )
1969 if( !selected( parentField->GetName() ) )
1972 if( !
GetField( parentField->GetName() ) )
1977 newField->
SetName( parentField->GetUntranslatedName() );
1978 newField->
SetText( parentField->GetText() );
1993 ordinal = std::max( ordinal,
static_cast<const SCH_FIELD*
>( &item )->GetOrdinal() + 1 );
2005 if( field->
GetId() == aFieldType )
2019 if( field->
GetId() == aFieldType )
2033 if( field.
GetName() == aFieldName )
2047 if( field.
GetName() == aFieldName )
2086 wxASSERT( field !=
nullptr );
2094 wxASSERT( field !=
nullptr );
2102 wxASSERT( field !=
nullptr );
2110 wxASSERT( field !=
nullptr );
2118 wxASSERT( field !=
nullptr );
2127 refDesignator.Replace( wxS(
"~" ), wxS(
" " ) );
2129 wxString prefix = refDesignator;
2131 while( prefix.Length() )
2133 wxUniCharRef last = prefix.Last();
2135 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
2136 prefix.RemoveLast();
2142 prefix.Trim(
true );
2143 prefix.Trim(
false );
2162 item.Move( aOffset );
2182 if( root.get() !=
this )
2183 return root->HasLegacyAlternateBodyStyle();
2196 if( root.get() !=
this )
2197 return root->GetMaxPinNumber();
2200 int maxPinNumber = 0;
2205 long currentPinNumber = 0;
2207 if(
pin->GetNumber().ToLong( ¤tPinNumber ) )
2208 maxPinNumber = std::max( maxPinNumber, (
int) currentPinNumber );
2211 return maxPinNumber;
2220 item.ClearTempFlags();
2229 item.ClearEditFlags();
2237 if( ( aUnit && item.m_unit && aUnit != item.m_unit )
2238 || ( aBodyStyle && item.m_bodyStyle && aBodyStyle != item.m_bodyStyle )
2244 if( item.HitTest( aPoint ) )
2277 if( item.IsType( aScanTypes ) )
2293 wxCHECK_RET( aCount >= 1, wxString::Format( wxT(
"Invalid unit count %d, ignoring." ), aCount ) );
2307 if( it->m_unit > aCount )
2314 else if( aDuplicateDrawItems )
2321 std::vector<SCH_ITEM*> tmp;
2325 if( item.m_unit != 1 )
2328 for(
int j = prevCount + 1; j <= aCount; j++ )
2332 tmp.push_back( newItem );
2352 if( root.get() !=
this )
2353 return root->GetUnitCount();
2375 if( root.get() !=
this )
2376 return root->m_demorgan;
2389 if( root.get() !=
this )
2390 return root->m_bodyStyleNames;
2399 wxCHECK_RET( aCount >= 1,
2400 wxString::Format( wxT(
"Invalid body style count %d, ignoring." ), aCount ) );
2405 if( prevCount < aCount && ( aDuplicateDrawItems || aDuplicatePins ) )
2407 std::vector<SCH_ITEM*> tmp;
2413 if( !aDuplicatePins )
2418 if( !aDuplicateDrawItems )
2424 for(
int j = prevCount + 1; j <= aCount; j++ )
2428 tmp.push_back( newItem );
2453 if( i->m_bodyStyle > aBodyStyleCount )
2463 std::vector<SCH_ITEM*> unitItems;
2472 && aUnit != item.GetUnit() )
2479 && aBodyStyle != item.GetBodyStyle() )
2484 unitItems.push_back( &item );
2493 std::vector<LIB_SYMBOL_UNIT> units;
2503 units.push_back( std::move( record ) );
2512 int unit = item.GetUnit();
2513 int bodyStyle = item.GetBodyStyle();
2515 auto it = std::find_if( units.begin(), units.end(),
2518 return a.m_unit == unit && a.m_bodyStyle == bodyStyle;
2521 if( it == units.end() )
2526 it = units.insert( units.end(), std::move( record ) );
2529 it->m_items.push_back( &item );
2532 std::sort( units.begin(), units.end(),
2535 if( a.m_unit == b.m_unit )
2536 return a.m_bodyStyle < b.m_bodyStyle;
2538 return a.m_unit < b.m_unit;
2545#define REPORT( msg ) \
2548 aReporter->Report( msg ); \
2551#define ITEM_DESC( item ) ( item )->GetItemDescription( &unitsProvider, false )
2576 if( ( aCompareFlags & FLAGS::PIN_VISIBILITIES )
2585 && ( !( aCompareFlags & FLAGS::EXCLUDE_FROM_POS_FILES )
2587 && ( !( aCompareFlags & FLAGS::DNP ) ||
dnp == aOther.
dnp );
2605 REPORT(
_(
"Name differs." ) );
2614 REPORT(
_(
"Library ID differs." ) );
2627 REPORT(
_(
"Symbol parent differs." ) );
2637 REPORT(
_(
"Power flag differs." ) );
2646 REPORT(
_(
"Unit count differs." ) );
2654 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aShapes;
2655 std::set<const SCH_FIELD*> aFields;
2656 std::set<const SCH_PIN*> aPins;
2661 aShapes.insert( &( *it ) );
2663 aFields.insert(
static_cast<const SCH_FIELD*
>( &( *it ) ) );
2665 aPins.insert(
static_cast<const SCH_PIN*
>( &( *it ) ) );
2668 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bShapes;
2669 std::set<const SCH_FIELD*> bFields;
2670 std::set<const SCH_PIN*> bPins;
2675 bShapes.insert( &( *it ) );
2677 bFields.insert(
static_cast<const SCH_FIELD*
>( &( *it ) ) );
2679 bPins.insert(
static_cast<const SCH_PIN*
>( &( *it ) ) );
2682 if(
int tmp =
static_cast<int>( aShapes.size() - bShapes.size() ) )
2685 REPORT(
_(
"Graphic item count differs." ) );
2692 for(
auto aIt = aShapes.begin(), bIt = bShapes.begin(); aIt != aShapes.end(); aIt++, bIt++ )
2694 if(
int tmp2 = ( *aIt )->compare( *( *bIt ), aCompareFlags ) )
2697 REPORT( wxString::Format(
_(
"Graphic item differs: %s; %s." ),
2707 for(
const SCH_PIN* aPin : aPins )
2709 const SCH_PIN* bPin = aRhs.
GetPin( aPin->GetNumber(), aPin->GetUnit(), aPin->GetBodyStyle() );
2714 REPORT( wxString::Format(
_(
"Extra pin in schematic symbol: %s." ),
ITEM_DESC( aPin ) ) );
2719 else if(
int tmp =
static_cast<const SCH_ITEM*
>( aPin )->
compare( *bPin, aCompareFlags ) )
2722 REPORT( wxString::Format(
_(
"Pin %s differs: %s; %s" ),
2732 for(
const SCH_PIN* bPin : bPins )
2734 const SCH_PIN* aPin =
GetPin( bPin->GetNumber(), bPin->GetUnit(), bPin->GetBodyStyle() );
2739 REPORT( wxString::Format(
_(
"Missing pin in schematic symbol: %s." ),
ITEM_DESC( bPin ) ) );
2746 for(
const SCH_FIELD* aField : aFields )
2750 if( aField->IsMandatory() )
2751 bField = aRhs.
GetField( aField->GetId() );
2753 bField = aRhs.
GetField( aField->GetName() );
2760 REPORT( wxString::Format(
_(
"Extra field in schematic symbol: %s." ), aField->GetName(
false ) ) );
2770 if(
int tmp = aField->GetText().compare( bField->
GetText() ) )
2773 REPORT( wxString::Format(
_(
"Field '%s' differs: %s; %s." ),
2774 aField->GetName(
false ),
2785 if( aField->GetFont() != bField->
GetFont() )
2787 retv = std::less<KIFONT::FONT*>{}( aField->GetFont(), bField->
GetFont() ) ? -1 : 1;
2788 REPORT( wxString::Format(
_(
"Field '%s' fonts differ." ), aField->GetName(
false ) ) );
2794 if( aField->GetTextSize() != bField->
GetTextSize() )
2796 if( aField->GetTextSize().x != bField->
GetTextSize().
x )
2797 retv = aField->GetTextSize().x - bField->
GetTextSize().
x;
2799 retv = aField->GetTextSize().y - bField->
GetTextSize().
y;
2801 REPORT( wxString::Format(
_(
"Field '%s' text sizes differ." ), aField->GetName(
false ) ) );
2807 if(
int tmp = aField->GetAttributes().Compare( bField->
GetAttributes() ) )
2810 REPORT( wxString::Format(
_(
"Field '%s' text styles differ." ), aField->GetName(
false ) ) );
2819 if( aField->IsVisible() != bField->
IsVisible() )
2821 retv = aField->IsVisible() ? 1 : -1;
2822 REPORT( wxString::Format(
_(
"Field '%s' visibility flags differ." ), aField->GetName(
false ) ) );
2828 if( aField->IsNameShown() != bField->
IsNameShown() )
2830 retv = aField->IsNameShown() ? 1 : -1;
2831 REPORT( wxString::Format(
_(
"Field '%s' name shown flags differ." ), aField->GetName(
false ) ) );
2838 if( aField->IsPrivate() != bField->
IsPrivate() )
2840 retv = aField->IsPrivate() ? 1 : -1;
2841 REPORT( wxString::Format(
_(
"Field '%s' privacy flags differ." ), aField->GetName(
false ) ) );
2849 if( aField->GetPosition() != bField->
GetPosition() )
2851 if( aField->GetPosition().x != bField->
GetPosition().
x )
2852 retv = aField->GetPosition().x - bField->
GetPosition().
x;
2853 else if( aField->GetPosition().y != bField->
GetPosition().
y )
2854 retv = aField->GetPosition().y - bField->
GetPosition().
y;
2856 REPORT( wxString::Format(
_(
"Field '%s' positions differ." ), aField->GetName(
false ) ) );
2867 for(
const SCH_FIELD* bField : bFields )
2871 if( bField->IsMandatory() )
2872 aField =
GetField( bField->GetId() );
2874 aField =
GetField( bField->GetName() );
2879 REPORT( wxString::Format(
_(
"Missing field in schematic symbol: %s." ), bField->GetName(
false ) ) );
2890 REPORT(
_(
"Footprint filter count differs." ) );
2897 for(
size_t i = 0; i <
m_fpFilters.GetCount(); i++ )
2902 REPORT(
_(
"Footprint filters differ." ) );
2913 REPORT(
_(
"Pin map count differs." ) );
2921 REPORT(
_(
"Pin maps differ." ) );
2930 REPORT(
_(
"Associated footprint count differs." ) );
2938 REPORT(
_(
"Associated footprints differ." ) );
2947 REPORT(
_(
"Symbol keywords differ." ) );
2956 REPORT(
_(
"Symbol pin name offsets differ." ) );
2967 REPORT(
_(
"Show pin names settings differ." ) );
2976 REPORT(
_(
"Show pin numbers settings differ." ) );
2988 REPORT(
_(
"Exclude from simulation settings differ." ) );
3000 REPORT(
_(
"Exclude from bill of materials settings differ." ) );
3012 REPORT(
_(
"Exclude from board settings differ." ) );
3023 retv = (
m_DNP ) ? -1 : 1;
3024 REPORT(
_(
"Do not populate settings differ." ) );
3036 REPORT(
_(
"Exclude from position files settings differ." ) );
3072 return Compare( *tmp, aCompareFlags );
3081 double similarity = 0.0;
3090 double max_similarity = 0.0;
3094 double temp_similarity = item.Similarity( otherItem );
3095 max_similarity = std::max( max_similarity, temp_similarity );
3097 if( max_similarity == 1.0 )
3101 similarity += max_similarity;
3107 double max_similarity = 0.0;
3111 double temp_similarity =
pin->Similarity( *otherPin );
3112 max_similarity = std::max( max_similarity, temp_similarity );
3114 if( max_similarity == 1.0 )
3118 similarity += max_similarity;
3121 if( totalItems == 0 )
3124 similarity /= totalItems;
3176 std::set<const LIB_SYMBOL*> visited;
3177 visited.insert(
this );
3179 std::shared_ptr<LIB_SYMBOL> parent =
m_parent.lock();
3184 if( visited.count( parent.get() ) )
3187 wxT(
"AppendParentEmbeddedFiles: Circular inheritance detected in "
3188 "symbol '%s' (lib: %s)" ),
3193 visited.insert( parent.get() );
3194 aStack.push_back( parent->GetEmbeddedFiles() );
3195 parent = parent->GetParent().lock();
3204 std::set<KIFONT::OUTLINE_FONT*>
fonts;
3209 if( font && !font->IsStroke() )
3214 if( permission == PERMISSION::EDITABLE || permission == PERMISSION::INSTALLABLE )
3215 fonts.insert( outline );
3223 processFont(
text->GetFont() );
3225 processFont( field->GetFont() );
3242 wxLogTrace(
"EMBED",
"Failed to add font file: %s", font->GetFileName() );
3258 const wxString groupFields =
_HKI(
"Fields" );
3276 const wxString groupSymbolDef =
_HKI(
"Symbol Definition" );
3285 const wxString groupPinDisplay =
_HKI(
"Pin Display" );
3300 const wxString groupAttributes =
_HKI(
"Attributes" );
3315 const wxString groupUnits =
_HKI(
"Units and Body Styles" );
3324 auto multiBodyStyle =
3328 return symbol->IsMultiBodyStyle();
3339 wxPGChoices choices;
3343 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
3344 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.
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.
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)
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.
@ 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