45#include <api/schematic/schematic_types.pb.h>
62 std::string ret =
TO_UTF8( txt );
66 if( (
unsigned char) c <=
' ' )
93 std::unique_ptr<LIB_SYMBOL> part;
124 SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.
Convert, aPosition, aParent )
127 for(
const auto& [fieldId, fieldValue] : aSel.
Fields )
129 if( fieldId == FIELD_T::REFERENCE )
130 SetRef( aSheet, fieldValue );
131 else if( SCH_FIELD* field = GetField( fieldId ) )
132 field->SetText( fieldValue );
160 field.SetParent(
this );
165 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol.
m_pins )
167 m_pins.emplace_back( std::make_unique<SCH_PIN>( *pin ) );
168 m_pins.back()->SetParent( this );
224 using namespace kiapi::schematic::types;
226 SchematicSymbolInstance symbol;
228 symbol.mutable_id()->set_value(
m_Uuid.AsStdString() );
230 symbol.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
232 SchematicSymbolTransform* transform = symbol.mutable_transform();
233 transform->set_orientation(
239 symbol.mutable_body_style()->set_style(
GetBodyStyle() );
241 SchematicSymbol* def = symbol.mutable_definition();
244 google::protobuf::Any
any;
247 any.UnpackTo( symbol.mutable_reference_field() );
250 any.UnpackTo( symbol.mutable_value_field() );
253 any.UnpackTo( symbol.mutable_footprint_field() );
256 any.UnpackTo( symbol.mutable_datasheet_field() );
259 any.UnpackTo( symbol.mutable_description_field() );
263 if( field.IsMandatory() )
266 field.Serialize(
any );
267 any.UnpackTo( symbol.add_user_fields() );
273 any.UnpackTo( def->mutable_reference_field() );
276 any.UnpackTo( def->mutable_value_field() );
279 any.UnpackTo( def->mutable_footprint_field() );
282 any.UnpackTo( def->mutable_datasheet_field() );
285 any.UnpackTo( def->mutable_description_field() );
297 SchematicSymbolChild* item = def->add_items();
298 item->mutable_unit()->set_unit( drawItem.GetUnit() );
299 item->mutable_body_style()->set_style( drawItem.GetBodyStyle() );
300 item->set_is_private( drawItem.IsPrivate() );
301 drawItem.Serialize( *item->mutable_item() );
304 def->set_unit_count(
m_part->GetUnitCount() );
305 def->set_body_style_count(
m_part->GetBodyStyleCount() );
306 def->set_keywords(
m_part->GetKeyWords().ToUTF8() );
309 def->add_footprint_filters(
filter.ToUTF8() );
317 aContainer.PackFrom( symbol );
324 using namespace kiapi::common::types;
325 using namespace kiapi::schematic::types;
327 SchematicSymbolInstance symbol;
329 if( !aContainer.UnpackTo( &symbol ) )
334 SetLocked( symbol.locked() == LockedState::LS_LOCKED );
340 const SchematicSymbol& def = symbol.definition();
348 google::protobuf::Any
any;
350 any.PackFrom( def.reference_field() );
353 any.PackFrom( def.value_field() );
356 any.PackFrom( def.footprint_field() );
359 any.PackFrom( def.datasheet_field() );
362 any.PackFrom( def.description_field() );
365 std::unordered_map<::KIID, wxString> pinAltMap;
367 for(
const SchematicSymbolChild& child : def.items() )
376 if( !item || !item->Deserialize( child.item() ) )
383 SchematicPin pinProto;
385 if( child.item().UnpackTo( &pinProto ) )
387 if( pinProto.has_active_alternate() )
388 pinAltMap[schItem->
m_Uuid] = wxString::FromUTF8( pinProto.active_alternate() );
392 if( child.has_unit() )
393 schItem->
SetUnit( child.unit().unit() );
395 if( child.has_body_style() )
403 if( def.unit_count() > 0 )
406 if( def.body_style_count() > 0 )
409 if( !def.keywords().empty() )
410 libSymbol->
SetKeyWords( wxString::FromUTF8( def.keywords() ) );
412 if( def.footprint_filters_size() > 0 )
414 wxArrayString filters;
416 for(
const std::string&
filter : def.footprint_filters() )
417 filters.Add( wxString::FromUTF8(
filter ) );
424 if( symbol.has_body_style() )
427 any.PackFrom( symbol.reference_field() );
430 any.PackFrom( symbol.value_field() );
433 any.PackFrom( symbol.footprint_field() );
436 any.PackFrom( symbol.datasheet_field() );
439 any.PackFrom( symbol.description_field() );
442 std::set<wxString> incoming;
444 for(
const SchematicField& fieldProto : symbol.user_fields() )
446 wxString
name = wxString::FromUTF8( fieldProto.name() );
453 incoming.insert(
name );
454 any.PackFrom( fieldProto );
462 std::vector<wxString> toRemove;
466 if( !field.IsMandatory() && !incoming.count( field.GetName(
false ) ) )
467 toRemove.push_back( field.GetName(
false ) );
470 for(
const wxString&
name : toRemove )
488 m_pins.emplace_back( std::make_unique<SCH_PIN>( *
pin ) );
489 m_pins.back()->SetParent(
this );
500 if( pinAltMap.contains(
pin->m_Uuid ) )
501 pin->SetAlt( pinAltMap.at(
pin->m_Uuid ) );
520 const int min_grid_size =
schIUScale.MilsToIU( 25 );
522 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
524 if( ( (
pin->GetPosition().x -
m_pos.x ) % min_grid_size ) != 0 )
527 if( ( (
pin->GetPosition().y -
m_pos.y ) % min_grid_size ) != 0 )
552 wxCHECK2( !aLibSymbol || aLibSymbol->
IsRoot(), aLibSymbol =
nullptr );
554 m_part.reset( aLibSymbol );
559 pin->SetLibPin(
nullptr );
568 return m_part->GetDescription();
570 return wxEmptyString;
577 return m_part->GetShownDescription( aDepth );
579 return wxEmptyString;
586 return m_part->GetKeyWords();
588 return wxEmptyString;
595 return m_part->GetShownKeyWords( aDepth );
597 return wxEmptyString;
604 return m_part->GetDatasheetField().GetText();
606 return wxEmptyString;
612 std::map<wxString, wxString> altPinMap;
613 std::map<wxString, SCH_PIN::ALT> altPinDefs;
614 std::map<wxString, std::set<SCH_PIN*>> pinUuidMap;
615 std::set<SCH_PIN*> unassignedSchPins;
616 std::set<SCH_PIN*> unassignedLibPins;
618 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
620 pinUuidMap[
pin->GetNumber()].insert(
pin.get() );
622 unassignedSchPins.insert(
pin.get() );
624 if( !
pin->GetAlt().IsEmpty() )
626 altPinMap[
pin->GetNumber()] =
pin->GetAlt();
627 auto altDefIt =
pin->GetAlternates().find(
pin->GetAlt() );
629 if( altDefIt !=
pin->GetAlternates().end() )
630 altPinDefs[
pin->GetNumber()] = altDefIt->second;
633 pin->SetLibPin(
nullptr );
650 auto ii = pinUuidMap.find( libPin->GetNumber() );
652 if( ii == pinUuidMap.end() || ii->second.empty() )
654 unassignedLibPins.insert( libPin );
658 auto it = ii->second.begin();
660 ii->second.erase( it );
661 pin->GetAlternates() = libPin->GetAlternates();
662 pin->SetLibPin( libPin );
663 pin->SetPosition( libPin->GetPosition() );
664 pin->SetUnit( libPin->GetUnit() );
665 pin->SetBodyStyle( libPin->GetBodyStyle() );
667 unassignedSchPins.erase(
pin );
669 auto iii = altPinMap.find( libPin->GetNumber() );
671 if( iii != altPinMap.end() )
673 wxString altName = iii->second;
675 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
677 auto defIt = altPinDefs.find( libPin->GetNumber() );
679 if( defIt != altPinDefs.end() )
681 for(
const auto& [
name, alt] :
pin->GetAlternates() )
683 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
692 pin->SetAlt( altName );
699 for(
SCH_PIN* libPin : unassignedLibPins )
704 if( !unassignedSchPins.empty() )
706 auto it = unassignedSchPins.begin();
708 unassignedSchPins.erase( it );
713 pin =
m_pins.emplace_back( std::make_unique<SCH_PIN>(
SCH_PIN(
this, libPin ) ) ).get();
717 pin->GetAlternates() = libPin->GetAlternates();
718 pin->SetLibPin( libPin );
719 pin->SetPosition( libPin->GetPosition() );
720 pin->SetUnit( libPin->GetUnit() );
721 pin->SetBodyStyle( libPin->GetBodyStyle() );
722 pin->SetNumber( libPin->GetNumber() );
724 auto iii = altPinMap.find( libPin->GetNumber() );
726 if( iii != altPinMap.end() )
728 wxString altName = iii->second;
730 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
732 auto defIt = altPinDefs.find( libPin->GetNumber() );
734 if( defIt != altPinDefs.end() )
736 for(
const auto& [
name, alt] :
pin->GetAlternates() )
738 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
747 pin->SetAlt( altName );
752 for(
auto it1 =
m_pins.begin(); it1 !=
m_pins.end() && !unassignedSchPins.empty(); )
754 auto it2 = unassignedSchPins.find( it1->get() );
756 if( it2 != unassignedSchPins.end() )
758 it1 =
m_pins.erase( it1 );
759 unassignedSchPins.erase( it2 );
770 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
791 return m_part->GetUnitCount();
800 return m_part->GetBodyStyleCount();
809 return m_part->HasDeMorganBodyStyles();
818 return m_part->GetUnitDisplayName( aUnit, aLabel );
820 return wxString::Format(
_(
"Unit %s" ),
SubReference( aUnit ) );
829 return m_part->GetBodyStyleDescription( aBodyStyle, aLabel );
852 if( instance.m_Path.EndsWith( aSheetPath ) )
854 aInstance = instance;
871 bool removed =
false;
875 for(
int ii =
m_instances.size() - 1; ii >= 0; --ii )
880 wxS(
"Removing symbol instance:\n"
882 " reference %s, unit %d from symbol %s." ),
924 wxS(
"Adding symbol '%s' instance:\n"
949 wxLogTrace(
traceSchSymbolRef,
"GetRef for symbol %s on path %s (sheet path has %zu sheets)",
970 wxLogTrace(
traceSchSymbolRef,
" Using fallback from REFERENCE field: %s", ref );
1013 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1014 pin->ClearDefaultNetName( sheet );
1031 const wxString& aVariantName )
1033 wxCHECK( !aFieldName.IsEmpty(), );
1039 switch( field->
GetId() )
1043 SetRef( aPath, aFieldText );
1048 wxString defaultText = field->
GetText( aPath );
1050 if( aVariantName.IsEmpty() )
1052 if( aFieldText != defaultText )
1059 wxCHECK( instance, );
1061 if( instance->
m_Variants.contains( aVariantName ) )
1063 if( aFieldText != defaultText )
1064 instance->
m_Variants[aVariantName].m_Fields[aFieldName] = aFieldText;
1066 instance->
m_Variants[aVariantName].m_Fields.erase( aFieldName );
1068 else if( aFieldText != defaultText )
1073 newVariant.
m_Fields[aFieldName] = aFieldText;
1074 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
1085 const wxString& aVariantName )
const
1087 wxCHECK( !aFieldName.IsEmpty(), wxEmptyString );
1091 wxCHECK( field, wxEmptyString );
1093 switch( field->
GetId() )
1096 wxCHECK( aPath, field->
GetText() );
1097 return GetRef( aPath,
false );
1101 if( !aVariantName.IsEmpty() && aPath )
1105 if( instance && instance->
m_Variants.contains( aVariantName )
1106 && instance->
m_Variants.at( aVariantName ).m_Fields.contains( aFieldName ) )
1108 return instance->
m_Variants.at( aVariantName ).m_Fields.at( aFieldName );
1115 if( aVariantName.IsEmpty() )
1123 if( instance->
m_Variants.contains( aVariantName )
1124 && instance->
m_Variants.at( aVariantName ).m_Fields.contains( aFieldName ) )
1125 return instance->
m_Variants.at( aVariantName ).m_Fields.at( aFieldName );
1141 if( instance.m_Path ==
path )
1142 return !instance.m_Reference.IsEmpty() && instance.m_Reference.Last() !=
'?';
1153 refDesignator.Replace(
"~",
" " );
1155 wxString prefix = refDesignator;
1157 while( prefix.Length() )
1159 wxUniCharRef last = prefix.Last();
1161 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
1162 prefix.RemoveLast();
1168 prefix.Trim(
true );
1169 prefix.Trim(
false );
1171 if( !prefix.IsEmpty() )
1181 const std::map<int, wxString>& names =
m_part->GetUnitDisplayNames();
1182 auto it = names.find( aUnit );
1184 if( it != names.end() && !it->second.IsEmpty() )
1190 int sep = schematic->Settings().m_SubpartIdSeparator;
1192 if( sep != 0 && aAddSeparator )
1193 subRef << wxChar( sep );
1196 subRef << it->second;
1202 return schematic->Settings().SubReference( aUnit, aAddSeparator );
1238 if( !aInstance || aVariantName.IsEmpty() )
1246 wxCHECK_MSG( instance, ,
1247 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
1250 if( aVariantName.IsEmpty() )
1256 if( instance->
m_Variants.contains( aVariantName ) && ( aEnable != instance->
m_Variants[aVariantName].m_DNP ) )
1258 instance->
m_Variants[aVariantName].m_DNP = aEnable;
1265 variant.
m_DNP = aEnable;
1274 if( !aInstance || aVariantName.IsEmpty() )
1282 if( instance.
m_Variants.contains( aVariantName ) )
1283 return instance.
m_Variants[aVariantName].m_DNP;
1290 const wxString& aVariantName )
1292 if( !aInstance || aVariantName.IsEmpty() )
1300 wxCHECK_MSG( instance, ,
1301 wxString::Format( wxS(
"Cannot set pin map override for invalid sheet path '%s'." ),
1304 if( instance->
m_Variants.contains( aVariantName ) )
1306 instance->
m_Variants[aVariantName].m_PinMapOverride = aOverride;
1320 const wxString& aVariantName )
const
1324 if( aInstance && !aVariantName.IsEmpty() )
1333 if(
result.IsDelegate() && aInstance )
1341 const wxString& aVariantName )
const
1346 wxString ref =
GetRef( &aSheet );
1354 if( sibling ==
this || sibling->
GetUnit() != 1 )
1357 if( sibling->
GetRef( &sheet ).CmpNoCase( ref ) != 0 )
1376 if( !aInstance || aVariantName.IsEmpty() )
1384 wxCHECK_MSG( instance, ,
1385 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
1388 if( aVariantName.IsEmpty() )
1394 if( instance->
m_Variants.contains( aVariantName )
1395 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromBOM ) )
1397 instance->
m_Variants[aVariantName].m_ExcludedFromBOM = aEnable;
1413 if( !aInstance || aVariantName.IsEmpty() )
1421 if( instance.
m_Variants.contains( aVariantName ) )
1422 return instance.
m_Variants[aVariantName].m_ExcludedFromBOM;
1431 if( !aInstance || aVariantName.IsEmpty() )
1439 wxCHECK_MSG( instance, ,
1440 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
1443 if( aVariantName.IsEmpty() )
1449 if( instance->
m_Variants.contains( aVariantName )
1450 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromSim ) )
1452 instance->
m_Variants[aVariantName].m_ExcludedFromSim = aEnable;
1468 if( !aInstance || aVariantName.IsEmpty() )
1476 if( instance.
m_Variants.contains( aVariantName ) )
1477 return instance.
m_Variants[aVariantName].m_ExcludedFromSim;
1485 const wxString& aVariantName )
1487 if( !aInstance || aVariantName.IsEmpty() )
1495 wxCHECK_MSG( instance, ,
1496 wxString::Format( wxS(
"Cannot set exclude from board for invalid sheet path '%s'." ),
1499 if( aVariantName.IsEmpty() )
1505 if( instance->
m_Variants.contains( aVariantName )
1506 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromBoard ) )
1508 instance->
m_Variants[aVariantName].m_ExcludedFromBoard = aEnable;
1523 const wxString& aVariantName )
const
1525 if( !aInstance || aVariantName.IsEmpty() )
1533 if( instance.
m_Variants.contains( aVariantName ) )
1534 return instance.
m_Variants[aVariantName].m_ExcludedFromBoard;
1542 const wxString& aVariantName )
1544 if( !aInstance || aVariantName.IsEmpty() )
1552 wxCHECK_MSG( instance, ,
1553 wxString::Format( wxS(
"Cannot set exclude from pos files for invalid sheet path '%s'." ),
1556 if( aVariantName.IsEmpty() )
1562 if( instance->
m_Variants.contains( aVariantName )
1563 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromPosFiles ) )
1565 instance->
m_Variants[aVariantName].m_ExcludedFromPosFiles = aEnable;
1580 const wxString& aVariantName )
const
1582 if( !aInstance || aVariantName.IsEmpty() )
1590 if( instance.
m_Variants.contains( aVariantName ) )
1591 return instance.
m_Variants[aVariantName].m_ExcludedFromPosFiles;
1601 instance.m_Unit = aUnitSelection;
1606 bool aAllowExtraText,
const wxString& aVariantName )
const
1608 if( aVariantName.IsEmpty() )
1616 std::optional variant =
GetVariant( *aInstance, aVariantName );
1630 const wxString& aVariantName )
1632 if( !aInstance || aVariantName.IsEmpty() )
1640 wxCHECK( instance, );
1644 if( instance->
m_Variants.contains( aVariantName ) )
1646 instance->
m_Variants[aVariantName].m_Fields[fieldName] = aValue;
1653 newVariant.
m_Fields[fieldName] = aValue;
1654 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
1660 bool aAllowExtraText,
const wxString& aVariantName )
const
1680 m_fields.emplace_back(
this, aFieldType );
1709 if( !field.IsVisible() || field.GetText().IsEmpty() )
1713 aVector.push_back(
const_cast<SCH_FIELD*
>( &field ) );
1716 std::sort( aVector.begin(), aVector.end(),
1719 return lhs->GetOrdinal() < rhs->GetOrdinal();
1739 for(
unsigned ii = 0; ii <
m_fields.size(); ++ii )
1744 if( aFieldName ==
m_fields[ii].GetName(
false ) )
1757 if( field.GetName().IsSameAs( aFieldName,
false ) )
1769 if( field.GetName().IsSameAs( aFieldName,
false ) )
1778 bool aResetRef,
bool aResetOtherFields )
1782 std::vector<SCH_FIELD*> fields;
1783 m_part->GetFields( fields );
1785 for(
const SCH_FIELD* libField : fields )
1790 if( libField->IsMandatory() )
1792 fieldType = libField->GetId();
1797 schField =
GetField( libField->GetCanonicalName() );
1807 schField->
SetPrivate( libField->IsPrivate() );
1819 else if( aUpdateRef )
1820 SetRef( aPath, libField->GetText() );
1828 if( aResetOtherFields )
1830 else if( aUpdateOtherFields )
1831 schField->
SetText( libField->GetText() );
1835 if( aResetOtherFields || aUpdateOtherFields )
1836 schField->
SetText( libField->GetText() );
1846 bool updateValue =
true;
1847 bool updateExclFromBOM =
true;
1848 bool updateExclFromBoard =
true;
1849 bool updateExclFromPosFiles =
true;
1850 bool updateDNP =
true;
1851 bool updateOtherFields =
true;
1852 bool updatePins =
true;
1853 bool updatePinMapOverride =
true;
1857 updateValue = aProperty->
Name() ==
_HKI(
"Value" );
1858 updateExclFromBoard = aProperty->
Name() ==
_HKI(
"Exclude From Board" );
1859 updateExclFromBOM = aProperty->
Name() ==
_HKI(
"Exclude From Bill of Materials" );
1860 updateExclFromPosFiles = aProperty->
Name() ==
_HKI(
"Exclude From Position Files" );
1861 updateDNP = aProperty->
Name() ==
_HKI(
"Do not Populate" );
1862 updatePinMapOverride = aProperty->
Name() == wxS(
"Pin Map Mode" ) || aProperty->
Name() == wxS(
"Pin Map Name" );
1863 updateOtherFields =
false;
1867 if( !updateValue && !updateExclFromBOM && !updateExclFromBoard && !updateExclFromPosFiles && !updateDNP
1868 && !updateOtherFields && !updatePins && !updatePinMapOverride )
1877 wxString ref =
GetRef( &aSourceSheet );
1882 std::vector<SCH_SYMBOL*> otherUnits;
1888 aCommit.
Modify( otherUnit, screen );
1893 if( updateOtherFields )
1905 if( field.IsMandatory() )
1906 otherField = otherUnit->GetField( field.GetId() );
1908 otherField = otherUnit->GetField( field.GetName() );
1912 otherField->
SetText( field.GetText() );
1920 newField.
Offset( otherUnit->GetPosition() );
1923 otherUnit->AddField( newField );
1927 for(
int ii = (
int) otherUnit->GetFields().size() - 1; ii >= 0; ii-- )
1929 SCH_FIELD& otherField = otherUnit->GetFields()[ii];
1932 otherUnit->GetFields().erase( otherUnit->GetFields().begin() + ii );
1936 if( updateExclFromBOM )
1939 if( updateExclFromBoard )
1942 if( updateExclFromPosFiles )
1946 otherUnit->SetDNP(
GetDNP( &aSourceSheet, aVariantName ), &sheet, aVariantName );
1948 if( updatePinMapOverride )
1949 otherUnit->SetPinMapOverride(
GetPinMapOverride( &aSourceSheet, aVariantName ), &sheet,
1954 for(
const std::unique_ptr<SCH_PIN>& model_pin :
m_pins )
1956 for(
SCH_PIN* src_pin : otherUnit->GetPinsByNumber( model_pin->GetNumber() ) )
1957 src_pin->SetAlt( model_pin->GetAlt() );
1968 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1969 aFunction(
pin.get() );
1972 aFunction( &field );
1978 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1980 if(
pin->GetNumber() == aNumber )
1989 const wxString& aVariantName )
const
1994 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1998 if(
pad == aPadNumber )
2009 std::vector<SCH_PIN*> pins;
2011 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2013 if(
pin->GetNumber() == aNumber )
2014 pins.push_back(
pin.get() );
2023 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2025 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
2026 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
2028 if( pin_unit > 0 && pin_unit !=
GetUnit() )
2031 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
2034 if(
pin->GetPosition() == aPos )
2047 return std::vector<SCH_PIN*>();
2054 return m_part->GetPins();
2056 return std::vector<SCH_PIN*>();
2068 auto it =
m_pinMap.find( aLibPin );
2073 wxFAIL_MSG_AT(
"Pin not found", __FILE__, __LINE__, __FUNCTION__ );
2080 std::vector<const SCH_PIN*> pins;
2089 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2091 if( unit &&
pin->GetUnit() &&
pin->GetUnit() != unit )
2094 pins.push_back(
pin.get() );
2103 std::vector<SCH_PIN*> pins;
2112 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2114 if( unit &&
pin->GetUnit() &&
pin->GetUnit() != unit )
2117 pins.push_back(
pin.get() );
2133 wxCHECK_RET( aItem !=
nullptr && aItem->
Type() ==
SCH_SYMBOL_T, wxT(
"Cannot swap data with invalid symbol." ) );
2141 for( std::unique_ptr<SCH_PIN>&
pin : symbol->
m_pins )
2142 pin->SetParent( symbol );
2144 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2145 pin->SetParent(
this );
2150 m_part.reset( libSymbol );
2185 if( field.IsPrivate() )
2188 if( field.IsMandatory() )
2189 aVars->push_back( field.GetCanonicalName().Upper() );
2191 aVars->push_back( field.GetName() );
2194 aVars->push_back( wxT(
"OP" ) );
2195 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
2196 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
2197 aVars->push_back( wxT(
"UNIT" ) );
2198 aVars->push_back( wxT(
"SHORT_REFERENCE" ) );
2199 aVars->push_back( wxT(
"SYMBOL_LIBRARY" ) );
2200 aVars->push_back( wxT(
"SYMBOL_NAME" ) );
2201 aVars->push_back( wxT(
"SYMBOL_DESCRIPTION" ) );
2202 aVars->push_back( wxT(
"SYMBOL_KEYWORDS" ) );
2203 aVars->push_back( wxT(
"EXCLUDE_FROM_BOM" ) );
2204 aVars->push_back( wxT(
"EXCLUDE_FROM_BOARD" ) );
2205 aVars->push_back( wxT(
"EXCLUDE_FROM_SIM" ) );
2206 aVars->push_back( wxT(
"DNP" ) );
2207 aVars->push_back( wxT(
"SHORT_NET_NAME(<pin_number>)" ) );
2208 aVars->push_back( wxT(
"NET_NAME(<pin_number>)" ) );
2209 aVars->push_back( wxT(
"NET_CLASS(<pin_number>)" ) );
2210 aVars->push_back( wxT(
"PIN_NAME(<pin_number>)" ) );
2211 aVars->push_back( wxT(
"REFERENCE(<pin_number>)" ) );
2212 aVars->push_back( wxT(
"SHORT_REFERENCE(<pin_number>)" ) );
2213 aVars->push_back( wxT(
"UNIT(<pin_number>)" ) );
2224 const wxString& aVariantName,
int aDepth )
const
2228 thread_local wxRegEx operatingPoint( wxT(
"^"
2243 wxString variant = aVariantName.IsEmpty() ? schematic->GetCurrentVariant() : aVariantName;
2245 if( operatingPoint.Matches( *token ) )
2247 wxString
pin( operatingPoint.GetMatch( *token, 1 ).Lower() );
2248 wxString precisionStr( operatingPoint.GetMatch( *token, 3 ) );
2249 wxString rangeStr( operatingPoint.GetMatch( *token, 4 ) );
2251 int precision = precisionStr.IsEmpty() ? 3 : precisionStr[0] -
'0';
2252 wxString range = rangeStr.IsEmpty() ? wxString( wxS(
"~A" ) ) : rangeStr;
2256 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
2257 embeddedFilesStack.push_back( schematic->GetEmbeddedFiles() );
2260 embeddedFilesStack.push_back(
m_part->GetEmbeddedFiles() );
2266 aVariantName, devnull ).model;
2270 wxString spiceRef =
model.SpiceGenerator().ItemName( spiceItem );
2271 spiceRef = spiceRef.Lower();
2275 *token = schematic->GetOperatingPoint( spiceRef, precision, range );
2278 else if(
pin == wxS(
":power" ) )
2280 if( rangeStr.IsEmpty() )
2281 range = wxS(
"~W" );
2283 *token = schematic->GetOperatingPoint( spiceRef + wxS(
":power" ), precision, range );
2288 pin =
pin.SubString( 1, -1 );
2290 for(
const std::reference_wrapper<const SIM_MODEL_PIN>& modelPin :
model.GetPins() )
2292 SCH_PIN* symbolPin =
GetPin( modelPin.get().symbolPinNumber );
2296 if(
model.GetPins().size() == 2 )
2298 *token = schematic->GetOperatingPoint( spiceRef, precision, range );
2302 wxString netChainName = spiceRef + wxS(
":" ) + modelPin.get().modelPinName;
2303 *token = schematic->GetOperatingPoint( netChainName, precision, range );
2311 *token = wxS(
"?" );
2315 if( token->Contains(
':' ) )
2317 if( schematic->ResolveCrossReference( token, aDepth + 1 ) )
2323 wxString fieldName = field.IsMandatory() ? field.GetCanonicalName() : field.GetName();
2325 wxString textToken = field.GetText();
2326 textToken.Replace(
" ", wxEmptyString );
2327 wxString tokenString =
"${" + fieldName +
"}";
2330 if( textToken.IsSameAs( tokenString,
false ) )
2333 if( token->IsSameAs( fieldName,
false ) )
2337 *token =
GetRef( aPath,
true );
2339 else if( !aVariantName.IsEmpty() )
2342 std::optional<SCH_SYMBOL_VARIANT> symVariant =
GetVariant( *aPath, aVariantName );
2344 if( symVariant && symVariant->m_Fields.contains( fieldName ) )
2345 *token = symVariant->m_Fields.at( fieldName );
2347 *token = field.GetShownText( aPath,
false, aDepth + 1 );
2351 *token = field.GetShownText( aPath,
false, aDepth + 1 );
2359 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
2360 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
2361 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
2363 *token = wxEmptyString;
2368 schematic->Settings().m_TemplateFieldNames.GetTemplateFieldNames() )
2370 if( token->IsSameAs( templateFieldname.m_Name ) || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
2374 *token = wxEmptyString;
2379 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
2383 wxArrayString parts = wxSplit( footprint,
':' );
2385 if( parts.Count() > 0 )
2388 *token = wxEmptyString;
2392 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
2396 wxArrayString parts = wxSplit( footprint,
':' );
2398 if( parts.Count() > 1 )
2399 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
2401 *token = wxEmptyString;
2405 else if( token->IsSameAs( wxT(
"UNIT" ) ) )
2410 else if( token->IsSameAs( wxT(
"SHORT_REFERENCE" ) ) )
2412 *token =
GetRef( aPath,
false );
2415 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
2417 *token =
m_lib_id.GetUniStringLibNickname();
2420 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
2422 *token =
m_lib_id.GetUniStringLibItemName();
2425 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
2430 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
2435 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
2437 *token = wxEmptyString;
2439 if( aPath->
GetExcludedFromBOM( variant ) || this->ResolveExcludedFromBOM( aPath, variant ) )
2440 *token =
_(
"Excluded from BOM" );
2444 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
2446 *token = wxEmptyString;
2448 if( aPath->
GetExcludedFromBoard( variant ) || this->ResolveExcludedFromBoard( aPath, variant ) )
2449 *token =
_(
"Excluded from board" );
2453 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
2455 *token = wxEmptyString;
2457 if( aPath->
GetExcludedFromSim( variant ) || this->ResolveExcludedFromSim( aPath, variant ) )
2458 *token =
_(
"Excluded from simulation" );
2462 else if( token->IsSameAs( wxT(
"DNP" ) ) )
2464 *token = wxEmptyString;
2466 if( aPath->
GetDNP( variant ) || this->ResolveDNP( aPath, variant ) )
2467 *token =
_(
"DNP" );
2471 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) ) || token->StartsWith( wxT(
"NET_NAME(" ) )
2472 || token->StartsWith( wxT(
"NET_CLASS(" ) ) || token->StartsWith( wxT(
"PIN_NAME(" ) )
2473 || token->StartsWith( wxT(
"PIN_BASE_NAME(" ) ) || token->StartsWith( wxT(
"PIN_ALT_LIST(" ) )
2474 || token->StartsWith( wxT(
"REFERENCE(" ) ) || token->StartsWith( wxT(
"SHORT_REFERENCE(" ) )
2475 || token->StartsWith( wxT(
"UNIT(" ) ) )
2477 wxString pinNumber = token->AfterFirst(
'(' );
2478 pinNumber = pinNumber.BeforeLast(
')' );
2480 bool isReferenceFunction = token->StartsWith( wxT(
"REFERENCE(" ) );
2481 bool isShortReferenceFunction = token->StartsWith( wxT(
"SHORT_REFERENCE(" ) );
2482 bool isUnitFunction = token->StartsWith( wxT(
"UNIT(" ) );
2486 std::vector<const SCH_PIN*> pinsToSearch;
2487 std::vector<const SCH_PIN*> altPinsToSearch;
2489 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
2492 pinsToSearch.push_back(
pin );
2497 pinsToSearch.push_back(
pin );
2500 altPinsToSearch.push_back(
pin );
2505 if(
pin->GetNumber() == pinNumber )
2507 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
2509 int pinUnit =
pin->GetUnit();
2512 if( isReferenceFunction )
2520 else if( isShortReferenceFunction )
2525 else if( isUnitFunction )
2534 *token = std::move(
result );
2537 else if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
2539 *token =
pin->GetAlt().IsEmpty() ?
pin->GetName() :
pin->GetAlt();
2542 else if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
2544 *token =
pin->GetBaseName();
2547 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
2552 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
2554 for(
const auto& [altName, altDef] : alts )
2556 if( !altList.IsEmpty() )
2557 altList += wxT(
", " );
2562 *token = std::move( altList );
2570 *token = wxEmptyString;
2572 else if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
2576 if( netName.Lower().StartsWith( wxT(
"unconnected" ) ) )
2577 *token = wxT(
"NC" );
2579 *token = std::move( netName );
2581 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
2583 *token = conn->
Name();
2585 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
2587 *token =
pin->GetEffectiveNetClass( aPath )->GetName();
2597 if(
pin->GetNumber() == pinNumber )
2600 if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
2602 *token =
pin->GetBaseName();
2605 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
2610 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
2612 for(
const auto& [altName, altDef] : alts )
2614 if( !altList.IsEmpty() )
2615 altList += wxT(
", " );
2624 int pinUnit =
pin->GetUnit();
2640 if( symbol->
GetRef( &sheetPath,
false ) ==
GetRef( aPath,
false )
2643 targetPath = sheetPath;
2644 targetSymbol = symbol;
2657 *token = wxString::Format( wxT(
"<Unit %s not placed>" ),
SubReference( pinUnit,
false ) );
2663 SCH_PIN* instancePin =
nullptr;
2667 if( candidate->GetNumber() == pinNumber )
2669 instancePin = candidate;
2676 *token = wxEmptyString;
2681 if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
2683 *token = instancePin->
GetAlt().IsEmpty() ? instancePin->
GetName() : instancePin->
GetAlt();
2692 *token = wxEmptyString;
2694 else if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
2697 if( netName.Lower().StartsWith( wxT(
"unconnected" ) ) )
2698 *token = wxT(
"NC" );
2702 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
2704 *token = conn->
Name();
2706 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
2716 *token = wxString::Format( wxT(
"<Unresolved: pin %s>" ), pinNumber );
2736 if( instance.m_Path ==
path )
2738 if( instance.m_Reference.IsEmpty() || aResetPrefix )
2749 if( instance.m_Reference.IsEmpty() || aResetPrefix )
2756 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2757 pin->ClearDefaultNetName( aSheetPath );
2767 if( currentReference.IsEmpty() || aResetPrefix )
2778 wxCHECK( aSheetPath.size() > 0,
false );
2783 if( instance.m_Path == aSheetPath )
2796 bool transform =
false;
2798 switch( aOrientation )
2919 wxFAIL_MSG(
"Invalid schematic symbol orientation type." );
2973 for(
int type_rotate : rotate_values )
2985 wxFAIL_MSG(
"Schematic symbol orientation matrix internal error." );
2993void SCH_SYMBOL::Show(
int nestLevel, std::ostream& os )
const
2996 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
" ref=\""
3002 for(
int i = 1; i < (int)
GetFields().size(); ++i )
3004 const wxString& value =
GetFields()[i].GetText();
3006 if( !value.IsEmpty() )
3008 NestedSpace( nestLevel + 1, os ) <<
"<field" <<
" name=\"" <<
TO_UTF8(
GetFields()[i].GetName() ) <<
'"'
3009 <<
" value=\"" <<
TO_UTF8( value ) <<
"\"/>\n";
3013 NestedSpace( nestLevel, os ) <<
"</" <<
TO_UTF8(
GetClass().Lower() ) <<
">\n";
3033 if( aIncludeFields )
3037 if( field.IsVisible() )
3038 bBox.
Merge( field.GetBoundingBox() );
3052 catch(
const boost::bad_pointer& e )
3054 wxFAIL_MSG( wxString::Format( wxT(
"Boost pointer exception occurred: %s" ), e.what() ) );
3080 auto addExcludes = [&]()
3085 msgs.Add(
_(
"Simulation" ) );
3088 msgs.Add(
_(
"BOM" ) );
3091 msgs.Add(
_(
"Board" ) );
3093 if(
GetDNP( currentSheet, currentVariant ) )
3094 msgs.Add(
_(
"DNP" ) );
3096 msg = wxJoin( msgs,
'|' );
3097 msg.Replace(
'|', wxS(
", " ) );
3100 aList.emplace_back(
_(
"Exclude from" ), msg );
3111 aList.emplace_back(
_(
"Power symbol" ),
3119 aList.emplace_back(
_(
"Value" ),
3126 aList.emplace_back(
_(
"flags" ), wxString::Format(
"%X",
GetEditFlags() ) );
3131 msg =
_(
"Missing parent" );
3133 std::shared_ptr<LIB_SYMBOL> parent =
m_part->GetParent().lock();
3136 msg = parent->GetName();
3140 else if( !
m_lib_id.GetLibNickname().empty() )
3142 aList.emplace_back(
_(
"Library" ),
m_lib_id.GetLibNickname() );
3146 aList.emplace_back(
_(
"Library" ),
_(
"Undefined!!!" ) );
3154 msg =
_(
"<Unknown>" );
3156 aList.emplace_back(
_(
"Footprint" ), msg );
3160 _(
"Keywords" ) + wxT(
": " ) +
m_part->GetKeyWords() );
3165 aList.emplace_back(
_(
"Reference" ),
GetRef( currentSheet ) );
3174 if( libNickname.empty() )
3175 msg =
_(
"No library defined!" );
3177 msg.Printf(
_(
"Symbol not found in %s!" ), libNickname );
3179 aList.emplace_back(
_(
"Library" ), msg );
3214 field.SetTextPos( pos );
3232 field.SetTextPos( pos );
3251 field.SetTextPos( pos );
3279 if( field.Matches( aSearchData, aAuxData ) )
3289 if( drawItem.Matches( aSearchData, aAuxData ) )
3300 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3308 aItemList.push_back( item );
3314 std::vector<DANGLING_END_ITEM>& aItemListByPos,
const SCH_SHEET_PATH* aPath )
3316 bool changed =
false;
3318 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3320 bool previousState =
pin->IsDangling();
3321 pin->SetIsDangling(
true );
3326 bool do_break =
false;
3328 for(
auto it = lower; it < aItemListByPos.end() && it->GetPosition() == pos; it++ )
3347 pin->SetIsDangling(
false );
3358 changed = ( changed || ( previousState !=
pin->IsDangling() ) );
3383 wxCHECK( symbol,
false );
3389 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3391 if(
pin->IsDangling() )
3404 if(
GetRef( aInstance ) != symbol->
GetRef( aInstance ) )
3414 for(
size_t i = 0; i <
m_pins.size(); i++ )
3426 std::vector<VECTOR2I> retval;
3428 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3432 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
3433 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
3435 if( pin_unit > 0 && pin_unit !=
GetUnit() )
3438 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
3464 return wxString::Format(
_(
"Symbol %s [%s]" ),
3472 for(
KICAD_T scanType : aScanTypes )
3517 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3521 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
3522 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
3524 if( pin_unit > 0 && pin_unit !=
GetUnit() )
3527 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
3564 std::vector<SCH_FIELD*> fields, otherFields;
3567 aSymbol.
GetFields( otherFields,
false );
3569 if( fields.size() != otherFields.size() )
3572 for(
int ii = 0; ii < (int) fields.size(); ii++ )
3577 if( fields[ii]->GetText().Cmp( otherFields[ii]->GetText() ) != 0 )
3587 return !( *
this == aSymbol );
3593 wxCHECK_MSG(
Type() == aSymbol.
Type(), *
this,
3594 wxT(
"Cannot assign object type " ) + aSymbol.
GetClass() + wxT(
" to type " ) +
GetClass() );
3596 if( &aSymbol !=
this )
3614 field.SetParent(
this );
3626 bBox.
Inflate( aAccuracy / 2 );
3642 rect.
Inflate( aAccuracy / 2 );
3664 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3677 if(
pin->GetLocalPosition() == new_pos )
3692 const VECTOR2I& aOffset,
bool aDimmed )
3706 for(
unsigned i = 0; i < tempPins.size(); ++i )
3709 SCH_PIN* tempPin = tempPins[i];
3729 text->SetText(
dummy.GetShownText(
false ) );
3740 bool dnp =
GetDNP( sheet, variant );
3742 for(
bool local_background : {
true,
false } )
3748 field.ClearRenderCache();
3752 && ( field.IsVisible() || field.IsForceVisible() ) )
3765 std::vector<wxString> properties;
3769 wxString text_field = field.GetShownText( sheet,
false, 0, variant );
3771 if( text_field.IsEmpty() )
3774 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ), field.GetName(), text_field ) );
3777 if( !
m_part->GetKeyWords().IsEmpty() )
3779 properties.emplace_back(
3780 wxString::Format( wxT(
"!%s = %s" ),
_(
"Keywords" ),
m_part->GetKeyWords() ) );
3803 margins.
x = std::max( margins.
x * 0.6, margins.
y * 0.3 );
3804 margins.
y = std::max( margins.
y * 0.6, margins.
x * 0.3 );
3822 double lineWidth = aSize / 10.0;
3824 std::vector<SCH_SHAPE> shapeList;
3826 int tolerance = 100;
3828 for(
const SCH_SHAPE& shape : shapeList )
3834 aPlotter->
BezierCurve( shape.GetStart(), shape.GetBezierC1(), shape.GetBezierC2(), shape.GetEnd(),
3835 tolerance, lineWidth );
3837 aPlotter->
Circle( shape.getCenter(), shape.GetRadius() * 2, filled, lineWidth );
3897 for(
unsigned i = 0; i < tempPins.size(); ++i )
3900 SCH_PIN* tempPin = tempPins[i];
3918 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3920 if(
pin->IsBrightened() )
3930 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3931 pin->ClearBrightened();
3949 m_part->SetShowPinNames( aShow );
3962 m_part->SetShowPinNumbers( aShow );
3968 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3970 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
3971 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
3973 if( pin_unit > 0 && pin_unit !=
GetUnit() )
3976 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
3979 if(
pin->IsPointClickableAnchor( aPos ) )
3998 if( pin_list.size() != 1 )
4016 if( pin_list.size() != 1 )
4028 return m_part->IsLocalPower();
4037 return m_part->IsGlobalPower();
4049 wxCHECK(
m_part,
false );
4051 return m_part->IsNormal();
4057 std::unordered_set<wxString> componentClass;
4059 auto getComponentClassFields = [&](
const std::vector<SCH_FIELD>& fields )
4063 if( field.GetCanonicalName() == wxT(
"Component Class" ) )
4065 if( field.GetShownText( aPath,
false ) != wxEmptyString )
4066 componentClass.insert( field.GetShownText( aPath,
false ) );
4072 getComponentClassFields(
m_fields );
4079 getComponentClassFields( label->GetFields() );
4083 return componentClass;
4088 const wxString& aVariantName )
const
4093 return std::nullopt;
4095 return instance.
m_Variants.find( aVariantName )->second;
4107 instance->
m_Variants.insert( std::make_pair( aVariant.
m_Name, aVariant ) );
4116 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
4124 const wxString& aNewName )
4129 if( !instance || !instance->
m_Variants.contains( aOldName ) )
4134 variant.
m_Name = aNewName;
4136 instance->
m_Variants.insert( std::make_pair( aNewName, variant ) );
4141 const wxString& aNewVariant )
4146 if( !instance || !instance->
m_Variants.contains( aSourceVariant ) )
4151 variant.
m_Name = aNewVariant;
4152 instance->
m_Variants.insert( std::make_pair( aNewVariant, variant ) );
4202 for(
unsigned i = 0; i <
m_pins.size(); ++i )
4211 if( m_instanceReferences != symbol.m_instanceReferences )
4237 double aLineWidth,
bool aHorizontal )
4241 double x_right = aSize / 1.6180339887;
4242 double x_middle = x_right / 2.0;
4255 aShapeList.back().SetStart( bottomPt );
4256 aShapeList.back().SetBezierC1( bottomAnchorPt );
4257 aShapeList.back().SetBezierC2( leftSideAnchorPt1 );
4258 aShapeList.back().SetEnd( leftPt );
4262 aShapeList.back().SetStart( leftPt );
4263 aShapeList.back().SetBezierC1( leftSideAnchorPt2 );
4264 aShapeList.back().SetBezierC2( rightSideAnchorPt2 );
4265 aShapeList.back().SetEnd( rightPt );
4268 aShapeList.back().SetStart( rightPt );
4269 aShapeList.back().SetBezierC1( rightSideAnchorPt1 );
4270 aShapeList.back().SetBezierC2( bottomAnchorPt );
4271 aShapeList.back().SetEnd( bottomPt );
4274 aShapeList.back().SetCenter( ( leftPt + rightPt ) / 2.0 );
4275 aShapeList.back().SetRadius( aSize / 15.0 );
4280 shape.Rotate(
VECTOR2I( 0, 0 ),
true );
4335 auto hasLibPart = [](
INSPECTABLE* aItem ) ->
bool
4338 return symbol->GetLibSymbolRef() !=
nullptr;
4351 const wxString groupFields =
_HKI(
"Fields" );
4371 auto multiUnit = [=](
INSPECTABLE* aItem ) ->
bool
4374 return symbol->IsMultiUnit();
4379 auto multiBodyStyle = [=](
INSPECTABLE* aItem ) ->
bool
4382 return symbol->IsMultiBodyStyle();
4393 wxPGChoices choices;
4397 for(
int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
4398 choices.Add( symbol->GetUnitDisplayName( ii,
false ), ii );
4410 wxPGChoices choices;
4414 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
4415 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
4421 const wxString groupAttributes =
_HKI(
"Attributes" );
types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr const Vec GetEnd() const
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr coord_type GetX() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr ecoord_type GetArea() const
Return the area of the rectangle.
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr void Offset(coord_type dx, coord_type dy)
constexpr bool Intersects(const BOX2< Vec > &aRect) const
constexpr coord_type GetBottom() const
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
static std::vector< DANGLING_END_ITEM >::iterator get_lower_pos(std::vector< DANGLING_END_ITEM > &aItemListByPos, const VECTOR2I &aPos)
Helper class used to store the state of schematic items that can be connected to other schematic item...
DANGLING_END_T GetType() const
const EDA_ITEM * GetParent() const
bool IsHorizontal() const
The base class for create windows for drawing purpose.
EDA_ITEM_FLAGS GetEditFlags() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
virtual void SetParentGroup(EDA_GROUP *aGroup)
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * m_parent
Owner.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual void SetTextPos(const VECTOR2I &aPoint)
virtual void Offset(const VECTOR2I &aOffset)
virtual EDA_ANGLE GetTextAngle() const
static ENUM_MAP< T > & Instance()
A text control validator used for validating the text allowed in fields.
bool DoValidate(const wxString &aValue, wxWindow *aParent)
Class that other classes need to inherit from, in order to be inspectable.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxString AsString() const
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
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.
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
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.
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
static LIB_SYMBOL * GetDummy()
Returns a dummy LIB_SYMBOL, used when one is missing in the schematic.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void SetUnitCount(int aCount, bool aDuplicateDrawItems)
Set the units per symbol count.
void SetKeyWords(const wxString &aKeyWords)
void SetBodyStyleCount(int aCount, bool aDuplicateDrawItems, bool aDuplicatePins)
Set or clear the alternate body style (DeMorgan) for the symbol.
void SetFPFilters(const wxArrayString &aFilters)
const BOX2I GetBodyBoundingBox(int aUnit, int aBodyStyle, bool aIncludePins, bool aIncludePrivateItems) const
Get the symbol bounding box excluding fields.
EMBEDDED_FILES * GetEmbeddedFiles() override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
void SetLibId(const LIB_ID &aLibId)
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
const wxString GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
A singleton reporter that reports to nowhere.
Base plotter engine class.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width)=0
virtual void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
Create a bookmark to a symbol.
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness)
Generic fallback: Cubic Bezier curve rendered as a polyline.
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, void *aData)
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
virtual void SetColor(const COLOR4D &color)=0
virtual void EndBlock(void *aData)
calling this function allows one to define the end of a group of drawing items for instance in SVG or...
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.
const wxString & Name() const
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.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Holds all the data relating to one schematic.
wxString GetCurrentVariant() const
Return the current variant being edited.
SCH_SHEET_PATH & CurrentSheet() const
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString LocalName() const
wxString Name(bool aIgnoreSheet=false) const
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
virtual const wxString & GetText() const override
Return the string associated with the text object.
void ImportValues(const SCH_FIELD &aSource)
Copy parameters from a SCH_FIELD source.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0, const wxString &aVariantName=wxEmptyString) const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetText(const wxString &aText) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void SetBodyStyle(int aBodyStyle)
void SetLocked(bool aLocked) override
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
void SetPrivate(bool aPrivate)
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
bool IsLocked() const override
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
void SetLayer(SCH_LAYER_ID aLayer)
virtual void SetUnit(int aUnit)
AUTOPLACE_ALGO m_fieldsAutoplaced
std::unordered_set< SCH_RULE_AREA * > m_rule_areas_cache
Store pointers to rule areas which this item is contained within.
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
ALT GetAlt(const wxString &aAlt)
void SetName(const wxString &aName)
const wxString & GetName() const
bool IsDangling() const override
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.
void SetShape(GRAPHIC_PINSHAPE aShape)
VECTOR2I GetPosition() const override
const wxString & GetShownName() const
void SetType(ELECTRICAL_PINTYPE aType)
const wxString & GetNumber() const
GRAPHIC_PINSHAPE GetShape() const
ELECTRICAL_PINTYPE GetType() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool GetExcludedFromBOM() const
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false, bool aEscapeSheetNames=false) const
Return the sheet path in a human readable form made from the sheet names.
bool GetExcludedFromSim() const
bool GetExcludedFromBoard() const
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
size_t size() const
Forwarded method from std::vector.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Variant information for a schematic symbol.
PIN_MAP_INSTANCE_OVERRIDE m_PinMapOverride
Per-instance pin-to-pad map override for this variant (issue #2282).
void InitializeAttributes(const SCH_SYMBOL &aSymbol)
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the display name for a given unit aUnit.
SCH_SYMBOL & operator=(const SCH_SYMBOL &aItem)
size_t GetFullPinCount() const
std::vector< SCH_SYMBOL_INSTANCE > m_instances
Define the hierarchical path and reference of the symbol.
void UpdatePrefix()
Set the prefix based on the current reference designator.
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
wxString GetDescription() const override
std::unordered_map< SCH_PIN *, SCH_PIN * > m_pinMap
Library pin pointer : SCH_PIN indices.
void SetMirrorX(bool aMirror)
bool IsSymbolLikePowerGlobalLabel() const
EMBEDDED_FILES * GetEmbeddedFiles() override
SCH_SYMBOLs don't currently support embedded files, but their LIB_SYMBOL counterparts do.
wxString GetSymbolIDAsString() const
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool GetShowPinNumbers() const override
wxString GetDatasheet() const
Return the documentation text for the given part alias.
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void SetLibId(const LIB_ID &aName)
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the symbol's fields.
BOX2I GetBodyAndPinsBoundingBox() const override
Return a bounding box for the symbol body and pins but not the fields.
wxString GetBodyStyleProp() const override
void SetRefProp(const wxString &aRef)
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...
virtual void SetDNP(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
SCH_ITEM * GetDrawItem(const VECTOR2I &aPosition, KICAD_T aType=TYPE_NOT_INIT)
Return the symbol library item at aPosition that is part of this symbol.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void SetPosition(const VECTOR2I &aPosition) override
void PlotDNP(PLOTTER *aPlotter) const
Plot the red 'X' over the symbol.
bool operator!=(const SCH_SYMBOL &aSymbol) const
void SetShowPinNumbers(bool aShow) override
Set or clear the pin number visibility flag.
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
SCH_SYMBOL_INSTANCE * getInstance(const KIID_PATH &aPath)
wxString SubReference(int aUnit, bool aAddSeparator=true) const
wxString GetClass() const override
Return the class name.
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
void SetFieldText(const wxString &aFieldName, const wxString &aFieldText, const SCH_SHEET_PATH *aPath=nullptr, const wxString &aVariantName=wxEmptyString)
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
void SetMirrorY(bool aMirror)
void SetBodyStyleProp(const wxString &aBodyStyle) override
std::vector< SCH_PIN * > GetPins() const override
bool GetExcludedFromPosFilesProp() const
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
wxString GetFieldText(const wxString &aFieldName, const SCH_SHEET_PATH *aPath=nullptr, const wxString &aVariantName=wxEmptyString) const
void SetExcludedFromSim(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
void SetExcludedFromSimProp(bool aEnable)
void SetBodyStyle(int aBodyStyle) override
void SetShowPinNames(bool aShow) override
Set or clear the pin name visibility flag.
wxString GetKeyWords() const override
wxString GetSchSymbolLibraryName() const
wxString GetShownKeyWords(int aDepth=0) const override
PASSTHROUGH_MODE m_passthroughMode
std::optional< SCH_SYMBOL_VARIANT > GetVariant(const SCH_SHEET_PATH &aInstance, const wxString &aVariantName) const
PIN_MAP_INSTANCE_OVERRIDE GetPinMapOverride(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
bool GetExcludedFromBoardProp() const
void ClearBrightenedPins()
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
bool GetExcludedFromSimProp() const
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool IsGlobalPower() const override
wxString GetRefProp() const
void SetPinMapOverride(const PIN_MAP_INSTANCE_OVERRIDE &aOverride, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
Set the per-instance pin-to-pad map override (issue #2282).
wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const override
bool AddSheetPathReferenceEntryIfMissing(const KIID_PATH &aSheetPath)
Add an instance to the alternate references list (m_instances), if this entry does not already exist.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void SetExcludedFromBOMProp(bool aEnable)
static std::unordered_map< TRANSFORM, int > s_transformToOrientationCache
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
Search for a SCH_FIELD with aFieldName.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
void UpdateFields(const SCH_SHEET_PATH *aPath, bool aUpdateStyle, bool aUpdateRef, bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields)
Restore fields to the original library values.
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const override
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
SCH_PIN * GetPinByEffectivePadNumber(const wxString &aPadNumber, const SCH_SHEET_PATH *aSheet, const wxString &aVariantName=wxEmptyString) const
Find the pin whose effective footprint pad number (issue #2282) is aPadNumber on aSheet,...
void RenameVariant(const KIID_PATH &aPath, const wxString &aOldName, const wxString &aNewName)
void SetOrientationProp(SYMBOL_ORIENTATION_PROP aAngle)
Orientation/mirroring access for property manager.
bool GetShowPinNames() const override
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
bool HasDeMorganBodyStyles() const override
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
std::vector< SCH_PIN * > GetAllLibPins() const
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const
int GetBodyStyleCount() const override
Return the number of body styles of the symbol.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void PlotPins(PLOTTER *aPlotter, bool aDnp) const
Plot just the symbol pins.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetFootprintFieldText(const wxString &aFootprint)
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
std::unordered_map< KIID_PATH, size_t > m_instancePathIndex
Index from an instance's sheet path to its position in m_instances for O(1) lookups.
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
VECTOR2I GetPosition() const override
PIN_MAP_INSTANCE_OVERRIDE resolveDelegatedPinMapOverride(const SCH_SHEET_PATH &aSheet, const wxString &aVariantName) const
Return unit 1's pin-map override for a unit that delegates to it (issue #2282).
std::unique_ptr< LIB_SYMBOL > m_part
A flattened copy of the LIB_SYMBOL from the PROJECT object's libraries.
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this symbol.
void SetExcludedFromPosFiles(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void rebuildInstancePathIndex()
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
void SyncOtherUnits(const SCH_SHEET_PATH &aSourceSheet, SCH_COMMIT &aCommit, PROPERTY_BASE *aProperty, const wxString &aVariantName=wxEmptyString)
Keep fields other than the reference, include/exclude flags, and alternate pin assignments in sync in...
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
void SetExcludedFromPosFilesProp(bool aEnable)
wxString GetShownDescription(int aDepth=0) const override
const LIB_ID & GetLibId() const override
bool operator<(const SCH_ITEM &aItem) const override
static void BuildLocalPowerIconShape(std::vector< SCH_SHAPE > &aShapeList, const VECTOR2D &aPos, double aSize, double aLineWidth, bool aHorizontal)
Build the local power pin indicator icon shape, at coordinate aPos.
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
void SetValueProp(const wxString &aValue)
void SetUnitProp(int aUnit)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void SetValueFieldText(const wxString &aValue, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
std::vector< SCH_PIN * > GetLibPins() const
Populate a vector with all the pins from the library object that match the current unit and bodyStyle...
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test if the symbol's dangling state has changed for all pins.
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
void AddVariant(const SCH_SHEET_PATH &aInstance, const SCH_SYMBOL_VARIANT &aVariant)
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
void SetDNPProp(bool aEnable)
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
std::vector< SCH_PIN * > GetPinsByNumber(const wxString &aNumber) const
Find all symbol pins with the given number.
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
PIN_MAP_INSTANCE_OVERRIDE m_pinMapOverride
Base (no-variant) pin-to-pad map override applied when no variant override exists for the sheet path ...
bool m_isInNetlist
True if the symbol should appear in netlist.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
wxString GetValueProp() const
bool IsLocalPower() const override
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
int GetUnitCount() const override
Return the number of units per package of the symbol.
void SetPrefix(const wxString &aPrefix)
int GetOrientation() const override
Get the display symbol orientation.
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.
bool IsSymbolLikePowerLocalLabel() const
bool GetExcludedFromBOMProp() const
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
void SetExcludedFromBoardProp(bool aEnable)
void SetExcludedFromBOM(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
void PlotLocalPowerIconShape(PLOTTER *aPlotter) const
Plot the local power pin indicator icon shape.
bool IsNormal() const override
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
std::unordered_set< wxString > GetComponentClassNames(const SCH_SHEET_PATH *aPath) const
Return the component classes this symbol belongs in.
std::vector< std::unique_ptr< SCH_PIN > > m_pins
A SCH_PIN for every #LIB_PIN.
void DeleteVariant(const KIID_PATH &aPath, const wxString &aVariantName)
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
VECTOR2I GetPinPhysicalPosition(const SCH_PIN *Pin) const
BOX2I GetBodyBoundingBox() const override
Return a bounding box for the symbol body but not the pins or fields.
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
bool IsPower() const override
void SetExcludedFromBoard(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void CopyVariant(const KIID_PATH &aPath, const wxString &aSourceVariant, const wxString &aNewVariant)
bool operator==(const SCH_SYMBOL &aSymbol) const
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
A base class for LIB_SYMBOL and SCH_SYMBOL.
bool m_DNP
True if symbol is set to 'Do Not Populate'.
bool m_excludedFromPosFiles
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
const TRANSFORM & GetTransform() const
int GetPinNameOffset() const
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
virtual bool GetShowPinNames() const
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
SYMBOL & operator=(const SYMBOL &aItem)
virtual bool GetShowPinNumbers() const
TRANSFORM m_transform
The rotation/mirror transformation.
std::map< wxString, wxString > m_Fields
bool m_ExcludedFromPosFiles
A type-safe container of any type.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
T Convert(const wxString &aValue)
Convert a wxString to a generic type T.
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
static constexpr EDA_ANGLE ANGLE_270
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define IS_DANGLING
indicates a pin is dangling
@ FILLED_SHAPE
Fill with object color.
a few functions useful in geometry calculations.
const wxChar *const traceSchSymbolRef
Flag to enable debug output of schematic symbol reference resolution.
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
SCH_LAYER_ID
Eeschema drawing layers.
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Message panel definition file.
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
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 VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackDistance(types::Distance &aOutput, int aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &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_NC
not connected (must be left open)
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
#define NO_SETTER(owner, type)
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
Collection of utility functions for component reference designators (refdes)
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
const SCH_FIELD * FindField(const std::vector< SCH_FIELD > &aFields, FIELD_T aFieldId)
int NextFieldOrdinal(const std::vector< SCH_FIELD > &aFields)
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
static void plotLocalPowerIcon(PLOTTER *aPlotter, const VECTOR2D &aPos, double aSize, bool aRotate)
plot a local power pin indicator icon.
static struct SCH_SYMBOL_DESC _SCH_SYMBOL_DESC
std::vector< FAB_LAYER_COLOR > dummy
std::vector< wxString > ExpandStackedPinNotation(const wxString &aPinName, bool *aValid)
Expand stacked pin notation like [1,2,3], [1-4], [A1-A4], or [AA1-AA3,AB4,CD12-CD14] into individual ...
wxString UnescapeString(const wxString &aSource)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
std::vector< std::pair< FIELD_T, wxString > > Fields
Per-instance override of the active pin map and a sparse delta on top.
A simple container for schematic symbol instance information.
std::map< wxString, SCH_SYMBOL_VARIANT > m_Variants
A list of symbol variants.
Hold a name of a symbol's field, field value, and default visibility.
@ SYM_ROTATE_COUNTERCLOCKWISE
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".
wxString GetCanonicalFieldName(FIELD_T aFieldType)
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ SCH_FIELD_LOCATE_REFERENCE_T
@ SCH_FIELD_LOCATE_FOOTPRINT_T
@ SCH_FIELD_LOCATE_VALUE_T
@ SCH_FIELD_LOCATE_DATASHEET_T
@ SCH_SYMBOL_LOCATE_POWER_T
Custom text control validator definitions.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D