50#include <api/schematic/schematic_types.pb.h>
164 const wxString& aVariant = wxEmptyString )
166 const std::unique_ptr<LIB_SYMBOL>& libSymbol = aSymbol->
GetLibSymbolRef();
171 const std::vector<ASSOCIATED_FOOTPRINT>& assoc = libSymbol->GetEffectiveAssociatedFootprints();
179 fpId.
Parse( fpField->GetText( aPath, aVariant ) );
183 if( candidate.m_FootprintLibId == fpId )
187 return &assoc.front();
196 wxAny
getter(
const void* aObject )
const final
198 const auto* symbol =
reinterpret_cast<const SCH_SYMBOL*
>( aObject );
199 SCHEMATIC* schematic = symbol->Schematic();
205 const wxString& aVariant )
const = 0;
223 void setter(
void* obj, wxAny& v )
override
227 if( !v.GetAs( &value ) )
233 wxString variantName;
264 field->
SetText( value, sheetPath, variantName );
268 const wxString& variantName )
const override
277 if( !variantName.IsEmpty() && sheetPath )
282 return wxAny(
text );
308 void setter(
void* obj, wxAny& v )
override {}
311 const wxString& variantName )
const override
314 return wxAny( active->m_FootprintLibId.Format().wx_str() );
316 return wxAny( wxEmptyString );
353 void setter(
void* obj, wxAny& v )
override
357 if( !v.GetAs( &value ) )
363 wxString variantName;
380 override.m_ActiveMapName = active->m_MapName;
387 const wxString& variantName )
const override
391 switch(
override.m_Mode )
423 return wxPGChoices();
433 std::vector<wxString> names;
435 if(
const std::unique_ptr<LIB_SYMBOL>& libSymbol = aSymbol->
GetLibSymbolRef() )
437 for(
const PIN_MAP& map : libSymbol->GetEffectivePinMaps().GetAll() )
438 names.push_back( map.GetName() );
447 const std::vector<wxString> names =
MapNames( aSymbol );
449 for(
size_t ii = 0; ii < names.size(); ++ii )
450 choices.Add( names[ii], (
int) ii );
455 void setter(
void* obj, wxAny& v )
override
459 if( !v.GetAs( &value ) )
463 const std::vector<wxString> names =
MapNames( symbol );
465 if( value < 0 || value >= (
int) names.size() )
469 wxString variantName;
479 override.m_ActiveMapName = names[value];
484 const wxString& variantName )
const override
493 const std::vector<wxString> names =
MapNames( symbol );
495 if( std::find( names.begin(), names.end(), active ) == names.end() )
498 active = fp->m_MapName;
501 for(
size_t ii = 0; ii < names.size(); ++ii )
503 if( names[ii] == active )
504 return wxAny( (
int) ii );
531 void setter(
void* obj, wxAny& v )
override {}
534 const wxString& variantName )
const override
541 std::vector<wxString> logical =
pin->GetStackedPinNumbers();
543 if( std::find( logical.begin(), logical.end(),
m_pinNumber ) == logical.end() )
546 wxString
pad =
pin->GetEffectivePadNumber( *sheetPath, variantName );
549 return wxAny( wxString::Format(
_(
"%s (identity)" ),
pad ) );
571 std::string ret =
TO_UTF8( txt );
575 if( (
unsigned char) c <=
' ' )
602 std::unique_ptr<LIB_SYMBOL> part;
633 SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.BodyStyle, aPosition, aParent )
636 for(
const auto& [fieldId, fieldValue] : aSel.
Fields )
638 if( fieldId == FIELD_T::REFERENCE )
639 SetRef( aSheet, fieldValue );
640 else if( SCH_FIELD* field = GetField( fieldId ) )
641 field->SetText( fieldValue );
671 field.SetParent(
this );
678 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol.
m_pins )
680 m_pins.emplace_back( std::make_unique<SCH_PIN>( *
pin ) );
681 m_pins.back()->SetParent(
this );
687 m_part = std::make_unique<LIB_SYMBOL>( *aSymbol.m_part );
706 return libSymbol && !libSymbol->GetEffectiveAssociatedFootprints().empty();
718 std::vector<PROPERTY_BASE*> props;
720 auto getOrCreate = [&](
const wxString& aName, std::unique_ptr<PROPERTY_BASE> aProp )
727 return it->second.get();
732 if( !field.IsMandatory() )
735 if( field.IsPrivate() )
738 const wxString&
name = field.GetUntranslatedName();
743 props.push_back( getOrCreate(
name, std::make_unique<SCH_SYMBOL_FIELD_PROPERTY>(
name ) ) );
746 std::vector<const SCH_FIELD*> userFields;
750 if( field.IsMandatory() || field.IsPrivate() )
753 userFields.push_back( &field );
756 std::ranges::sort( userFields,
762 for(
const SCH_FIELD* field : userFields )
764 const wxString&
name = field->GetUntranslatedName();
765 props.push_back( getOrCreate(
name, std::make_unique<SCH_SYMBOL_FIELD_PROPERTY>(
name ) ) );
769 props.push_back( prop );
776 props.push_back( getOrCreate(
PIN_MAP_MODE_PROP, std::make_unique<SCH_SYMBOL_PIN_MAP_MODE_PROPERTY>() ) );
777 props.push_back( getOrCreate(
PIN_MAP_NAME_PROP, std::make_unique<SCH_SYMBOL_PIN_MAP_NAME_PROPERTY>() ) );
785 for(
const wxString& number :
pin->GetStackedPinNumbers() )
787 if( number.IsEmpty() )
792 props.push_back( getOrCreate(
793 propName, std::make_unique<SCH_SYMBOL_PIN_MAP_ENTRY_PROPERTY>( propName, number ) ) );
843 kiapi::schematic::types::SchematicSymbolInstance symbol;
845 aContainer.PackFrom( symbol );
854 aSymbol.mutable_id()->set_value(
m_Uuid.AsStdString() );
856 aSymbol.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
863 PackLibId( aSymbol.mutable_lib_id(),
id );
868 SchematicSymbolTransform* transform = aSymbol.mutable_transform();
869 transform->set_orientation(
875 aSymbol.mutable_body_style()->set_style(
GetBodyStyle() );
885 if( field.IsMandatory() )
888 field.Serialize( *aSymbol.add_user_fields(),
schIUScale );
892 m_part->Serialize( *aSymbol.mutable_definition(),
true );
905 kiapi::schematic::types::SchematicSymbolInstance symbol;
907 if( !aContainer.UnpackTo( &symbol ) )
922 screen->BumpConnectivityRevision();
926 SetLocked( aSymbol.locked() == LockedState::LS_LOCKED );
930 if( aSymbol.has_lib_id() )
941 const bool haveDefinition = aSymbol.has_definition();
943 std::unordered_map<::KIID, wxString> pinAltMap;
947 const SchematicSymbol& def = aSymbol.definition();
952 for(
const SchematicSymbolChild& child : def.items() )
957 SchematicPin pinProto;
959 if( child.item().UnpackTo( &pinProto ) && pinProto.has_active_alternate() )
960 pinAltMap[
::KIID( pinProto.id().value() )] = wxString::FromUTF8( pinProto.active_alternate() );
974 if( aSymbol.has_body_style() )
983 std::set<wxString> incoming;
985 for(
const SchematicField& fieldProto : aSymbol.user_fields() )
987 wxString
name = wxString::FromUTF8( fieldProto.name() );
994 incoming.insert(
name );
1002 std::vector<wxString> toRemove;
1006 if( !field.IsMandatory() && !incoming.count( field.GetName(
false ) ) )
1007 toRemove.push_back( field.GetName(
false ) );
1010 for(
const wxString&
name : toRemove )
1013 if( aSymbol.has_show_pin_names() )
1016 if( aSymbol.has_show_pin_numbers() )
1019 if( aSymbol.has_pin_name_offset() )
1028 if( haveDefinition )
1034 m_pins.emplace_back( std::make_unique<SCH_PIN>( *
pin ) );
1035 m_pins.back()->SetParent(
this );
1043 if( pinAltMap.contains(
pin->m_Uuid ) )
1044 pin->SetAlt( pinAltMap.at(
pin->m_Uuid ) );
1054 return m_part ==
nullptr;
1064 const int min_grid_size =
schIUScale.MilsToIU( 25 );
1066 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1068 if( ( (
pin->GetPosition().x -
m_pos.x ) % min_grid_size ) != 0 )
1071 if( ( (
pin->GetPosition().y -
m_pos.y ) % min_grid_size ) != 0 )
1096 wxCHECK2( !aLibSymbol || aLibSymbol->
IsRoot(), aLibSymbol =
nullptr );
1098 m_part.reset( aLibSymbol );
1106 pin->SetLibPin(
nullptr );
1115 return m_part->GetDescription();
1117 return wxEmptyString;
1124 return m_part->GetShownDescription( aContext, aDepth );
1126 return wxEmptyString;
1133 return m_part->GetKeyWords();
1135 return wxEmptyString;
1142 return m_part->GetShownKeyWords( aContext, aDepth );
1144 return wxEmptyString;
1151 return m_part->GetDatasheetField().GetText();
1153 return wxEmptyString;
1160 screen->BumpConnectivityRevision();
1168 std::map<wxString, wxString> altPinMap;
1169 std::map<wxString, SCH_PIN::ALT> altPinDefs;
1170 std::map<wxString, std::vector<SCH_PIN*>> pinUuidMap;
1171 std::set<SCH_PIN*> unassignedSchPins;
1172 std::vector<SCH_PIN*> unassignedLibPins;
1174 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1177 pinUuidMap[
pin->GetNumber()].push_back(
pin.get() );
1179 unassignedSchPins.insert(
pin.get() );
1181 if( !
pin->GetAlt().IsEmpty() )
1183 altPinMap[
pin->GetNumber()] =
pin->GetAlt();
1184 auto altDefIt =
pin->GetAlternates().find(
pin->GetAlt() );
1186 if( altDefIt !=
pin->GetAlternates().end() )
1187 altPinDefs[
pin->GetNumber()] = altDefIt->second;
1190 pin->SetLibPin(
nullptr );
1204 auto ii = pinUuidMap.find( libPin->GetNumber() );
1206 if( ii == pinUuidMap.end() || ii->second.empty() )
1208 unassignedLibPins.push_back( libPin );
1212 auto it = ii->second.begin();
1214 ii->second.erase( it );
1215 pin->GetAlternates() = libPin->GetAlternates();
1216 pin->SetLibPin( libPin );
1217 pin->SetPosition( libPin->GetPosition() );
1218 pin->SetUnit( libPin->GetUnit() );
1219 pin->SetBodyStyle( libPin->GetBodyStyle() );
1221 unassignedSchPins.erase(
pin );
1223 auto iii = altPinMap.find( libPin->GetNumber() );
1225 if( iii != altPinMap.end() )
1227 wxString altName = iii->second;
1229 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
1231 auto defIt = altPinDefs.find( libPin->GetNumber() );
1233 if( defIt != altPinDefs.end() )
1235 for(
const auto& [
name, alt] :
pin->GetAlternates() )
1237 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
1246 pin->SetAlt( altName );
1253 size_t nextUnassigned = 0;
1255 for(
SCH_PIN* libPin : unassignedLibPins )
1260 if( !unassignedSchPins.empty() )
1262 while( nextUnassigned <
m_pins.size()
1263 && !unassignedSchPins.contains(
m_pins[nextUnassigned].get() ) )
1268 pin =
m_pins.at( nextUnassigned++ ).get();
1269 unassignedSchPins.erase(
pin );
1274 pin =
m_pins.emplace_back( std::make_unique<SCH_PIN>(
SCH_PIN(
this, libPin ) ) ).get();
1278 pin->GetAlternates() = libPin->GetAlternates();
1279 pin->SetLibPin( libPin );
1280 pin->SetPosition( libPin->GetPosition() );
1281 pin->SetUnit( libPin->GetUnit() );
1282 pin->SetBodyStyle( libPin->GetBodyStyle() );
1283 pin->SetNumber( libPin->GetNumber() );
1285 auto iii = altPinMap.find( libPin->GetNumber() );
1287 if( iii != altPinMap.end() )
1289 wxString altName = iii->second;
1291 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
1293 auto defIt = altPinDefs.find( libPin->GetNumber() );
1295 if( defIt != altPinDefs.end() )
1297 for(
const auto& [
name, alt] :
pin->GetAlternates() )
1299 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
1308 pin->SetAlt( altName );
1313 for(
auto it1 =
m_pins.begin(); it1 !=
m_pins.end() && !unassignedSchPins.empty(); )
1315 auto it2 = unassignedSchPins.find( it1->get() );
1317 if( it2 != unassignedSchPins.end() )
1319 it1 =
m_pins.erase( it1 );
1320 unassignedSchPins.erase( it2 );
1331 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1352 return m_part->GetUnitCount();
1361 return m_part->GetBodyStyleCount();
1370 return m_part->HasDeMorganBodyStyles();
1379 return m_part->GetUnitDisplayName( aUnit, aLabel );
1381 return wxString::Format(
_(
"Unit %s" ),
SubReference( aUnit ) );
1390 return m_part->GetBodyStyleDescription( aBodyStyle, aLabel );
1413 if( instance.m_Path.EndsWith( aSheetPath ) )
1415 aInstance = instance;
1432 bool removed =
false;
1436 for(
int ii =
m_instances.size() - 1; ii >= 0; --ii )
1441 wxS(
"Removing symbol instance:\n"
1443 " reference %s, unit %d from symbol %s." ),
1487 wxS(
"Adding symbol '%s' instance:\n"
1488 " sheet path '%s'\n"
1517 wxLogTrace(
traceSchSymbolRef,
"GetRef for symbol %s on path %s (sheet path has %zu sheets)",
1542 wxLogTrace(
traceSchSymbolRef,
" Using fallback from REFERENCE field: %s", ref );
1567 if(
validator.DoValidate( aRef,
nullptr ) )
1582 const wxString previousPrefix =
m_prefix;
1584 bool changed =
false;
1587 changed = std::exchange(
m_instances[it->second].m_Reference, ref ) != ref;
1591 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1592 pin->ClearDefaultNetName( sheet );
1615 const wxString& aVariantName )
1617 wxCHECK_MSG( !aFieldName.IsEmpty(), , wxT(
"Can't set text on a field with no name!" ) );
1621 wxCHECK_MSG( field, , wxT(
"Can't set text on a field not yet added to the symbol!" ) );
1623 switch( field->
GetId() )
1627 SetRef( aPath, aFieldText );
1632 wxString defaultText = field->
GetText( aPath );
1634 if( aVariantName.IsEmpty() )
1636 if( aFieldText != defaultText )
1643 wxCHECK( instance, );
1649 const SCH_FIELD* altField = altSymbol->GetField( aFieldName );
1651 if( altField && !altField->
GetText().IsEmpty() )
1652 defaultText = altField->
GetText();
1655 bool changed =
false;
1657 if( instance->
m_Variants.contains( aVariantName ) )
1659 auto& fields = instance->
m_Variants[aVariantName].m_Fields;
1661 if( aFieldText != defaultText )
1663 auto [entry, inserted] = fields.try_emplace( aFieldName, aFieldText );
1664 changed = inserted || std::exchange( entry->second, aFieldText ) != aFieldText;
1668 changed = fields.erase( aFieldName ) != 0;
1671 else if( aFieldText != defaultText )
1676 newVariant.
m_Fields[aFieldName] = aFieldText;
1677 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
1692 const wxString& aVariantName )
const
1694 wxCHECK( !aFieldName.IsEmpty(), wxEmptyString );
1698 wxCHECK( field, wxEmptyString );
1700 switch( field->
GetId() )
1703 wxCHECK( aPath, field->
GetText() );
1704 return GetRef( aPath,
false );
1708 if( !aVariantName.IsEmpty() && aPath )
1712 if( instance && instance->
m_Variants.contains( aVariantName )
1713 && instance->
m_Variants.at( aVariantName ).m_Fields.contains( aFieldName ) )
1715 return instance->
m_Variants.at( aVariantName ).m_Fields.at( aFieldName );
1724 if( altField && !altField->
GetText().IsEmpty() )
1732 if( aVariantName.IsEmpty() )
1740 if( instance && instance->
m_Variants.contains( aVariantName ) )
1744 if( variant.
m_Fields.contains( aFieldName ) )
1745 return variant.
m_Fields.at( aFieldName );
1753 if( altField && !altField->
GetText().IsEmpty() )
1772 if( instance.m_Path ==
path )
1773 return !instance.m_Reference.IsEmpty() && instance.m_Reference.Last() !=
'?';
1784 refDesignator.Replace(
"~",
" " );
1786 wxString prefix = refDesignator;
1788 while( prefix.Length() )
1790 wxUniCharRef last = prefix.Last();
1792 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
1793 prefix.RemoveLast();
1799 prefix.Trim(
true );
1800 prefix.Trim(
false );
1802 if( !prefix.IsEmpty() )
1812 const std::map<int, wxString>& names =
m_part->GetUnitDisplayNames();
1813 auto it = names.find( aUnit );
1815 if( it != names.end() )
1821 int sep =
schematic->Settings().m_SubpartIdSeparator;
1823 if( sep != 0 && aAddSeparator )
1824 subRef << wxChar( sep );
1827 subRef << it->second;
1833 return schematic->Settings().SubReference( aUnit, aAddSeparator );
1858 if( std::exchange(
m_instances[it->second].m_Unit, aUnitSelection ) != aUnitSelection )
1872 bool* attribute = &( this->*aBase );
1874 if( aInstance && !aVariantName.IsEmpty() )
1878 wxCHECK_MSG( instance, ,
1879 wxString::Format( wxS(
"Cannot set attribute for invalid sheet path '%s'." ),
1882 auto variant = instance->
m_Variants.find( aVariantName );
1886 if( aEnable == this->*aBase )
1891 newVariant.*aOverride = aEnable;
1896 attribute = &( variant->second.*aOverride );
1899 if( *attribute == aEnable )
1902 *attribute = aEnable;
1915 if( !aInstance || aVariantName.IsEmpty() )
1923 if( instance.
m_Variants.contains( aVariantName ) )
1924 return instance.
m_Variants[aVariantName].m_DNP;
1931 const wxString& aVariantName )
1933 if( !aInstance || aVariantName.IsEmpty() )
1941 wxCHECK_MSG( instance, ,
1942 wxString::Format( wxS(
"Cannot set pin map override for invalid sheet path '%s'." ),
1945 if( instance->
m_Variants.contains( aVariantName ) )
1947 instance->
m_Variants[aVariantName].m_PinMapOverride = aOverride;
1961 const wxString& aVariantName )
const
1965 if( aInstance && !aVariantName.IsEmpty() )
1974 if(
result.IsDelegate() && aInstance )
1982 const wxString& aVariantName )
const
1987 wxString ref =
GetRef( &aSheet );
1995 if( sibling ==
this || sibling->
GetUnit() != 1 )
1998 if( sibling->
GetRef( &sheet ).CmpNoCase( ref ) != 0 )
2024 if( !aInstance || aVariantName.IsEmpty() )
2032 if( instance.
m_Variants.contains( aVariantName ) )
2033 return instance.
m_Variants[aVariantName].m_ExcludedFromBOM;
2049 if( !aInstance || aVariantName.IsEmpty() )
2057 if( instance.
m_Variants.contains( aVariantName ) )
2058 return instance.
m_Variants[aVariantName].m_ExcludedFromSim;
2066 const wxString& aVariantName )
2074 const wxString& aVariantName )
const
2076 if( !aInstance || aVariantName.IsEmpty() )
2084 if( instance.
m_Variants.contains( aVariantName ) )
2085 return instance.
m_Variants[aVariantName].m_ExcludedFromBoard;
2093 const wxString& aVariantName )
2101 const wxString& aVariantName )
const
2103 if( !aInstance || aVariantName.IsEmpty() )
2111 if( instance.
m_Variants.contains( aVariantName ) )
2112 return instance.
m_Variants[aVariantName].m_ExcludedFromPosFiles;
2121 bool changed =
false;
2124 changed |= std::exchange( instance.m_Unit, aUnitSelection ) != aUnitSelection;
2132 const wxString& aVariantName )
const
2134 if( aVariantName.IsEmpty() || !aInstance )
2137 std::optional variant =
GetVariant( *aInstance, aVariantName );
2144 [&](
const wxString& aText ) -> wxString
2146 std::function<bool( wxString* )> resolver =
2147 [&]( wxString* token ) ->
bool
2155 if( variant->m_Fields.contains( fieldName ) )
2156 return resolve( variant->m_Fields[fieldName] );
2164 if( altField && !altField->
GetText().IsEmpty() )
2165 return resolve( altField->
GetText() );
2176 const wxString& aVariantName )
2178 if( !aInstance || aVariantName.IsEmpty() )
2186 wxCHECK( instance, );
2190 if( instance->
m_Variants.contains( aVariantName ) )
2192 instance->
m_Variants[aVariantName].m_Fields[fieldName] = aValue;
2199 newVariant.
m_Fields[fieldName] = aValue;
2200 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
2206 const wxString& aVariantName )
const
2224 m_fields.emplace_back(
this, aFieldType );
2253 if( !field.IsVisible() || field.GetText().IsEmpty() )
2257 aVector.push_back(
const_cast<SCH_FIELD*
>( &field ) );
2260 std::sort( aVector.begin(), aVector.end(),
2263 return lhs->GetOrdinal() < rhs->GetOrdinal();
2287 wxString fieldName = aFieldName;
2289 for(
unsigned ii = 0; ii <
m_fields.size(); ++ii )
2294 if( fieldName ==
m_fields[ii].GetName(
false ) )
2300 for(
auto& variant : instance.m_Variants )
2301 variant.second.m_Fields.erase( fieldName );
2316 if( field.GetName().IsSameAs( aFieldName,
false ) )
2328 if( field.GetName().IsSameAs( aFieldName,
false ) )
2337 bool aResetRef,
bool aResetOtherFields )
2341 std::vector<SCH_FIELD*> fields;
2342 m_part->GetFields( fields );
2344 for(
const SCH_FIELD* libField : fields )
2349 if( libField->IsMandatory() )
2351 fieldType = libField->GetId();
2356 schField =
GetField( libField->GetUntranslatedName() );
2366 schField->
SetPrivate( libField->IsPrivate() );
2378 else if( aUpdateRef )
2379 SetRef( aPath, libField->GetText() );
2387 if( aResetOtherFields )
2389 else if( aUpdateOtherFields )
2390 schField->
SetText( libField->GetText() );
2394 if( aResetOtherFields || aUpdateOtherFields )
2395 schField->
SetText( libField->GetText() );
2405 bool updateValue =
true;
2406 bool updateExclFromBOM =
true;
2407 bool updateExclFromBoard =
true;
2408 bool updateExclFromPosFiles =
true;
2409 bool updateDNP =
true;
2410 bool updateOtherFields =
true;
2412 bool updatePinMapOverride =
true;
2416 updateValue = aProperty->
Name() ==
_HKI(
"Value" );
2417 updateExclFromBoard = aProperty->
Name() ==
_HKI(
"Exclude From Board" );
2418 updateExclFromBOM = aProperty->
Name() ==
_HKI(
"Exclude From Bill of Materials" );
2419 updateExclFromPosFiles = aProperty->
Name() ==
_HKI(
"Exclude From Position Files" );
2420 updateDNP = aProperty->
Name() ==
_HKI(
"Do not Populate" );
2421 updatePinMapOverride = aProperty->
Name() == wxS(
"Pin Map Mode" ) || aProperty->
Name() == wxS(
"Pin Map Name" );
2422 updateOtherFields =
false;
2426 if( !updateValue && !updateExclFromBOM && !updateExclFromBoard && !updateExclFromPosFiles && !updateDNP
2427 && !updateOtherFields && !
updatePins && !updatePinMapOverride )
2436 wxString ref =
GetRef( &aSourceSheet );
2441 std::vector<SCH_SYMBOL*> otherUnits;
2447 aCommit.
Modify( otherUnit, screen );
2453 &sheet, aVariantName );
2456 if( updateOtherFields )
2468 if( field.IsMandatory() )
2469 otherField = otherUnit->GetField( field.GetId() );
2471 otherField = otherUnit->GetField( field.GetName() );
2475 otherField->
SetText( field.GetText( &aSourceSheet, aVariantName ), &sheet, aVariantName );
2483 newField.
Offset( otherUnit->GetPosition() );
2486 SCH_FIELD* addedField = otherUnit->AddField( newField );
2488 if( !aVariantName.IsEmpty() )
2490 addedField->
SetText( field.GetText( &aSourceSheet, aVariantName ), &sheet,
2496 for(
int ii = (
int) otherUnit->GetFields().size() - 1; ii >= 0; ii-- )
2498 SCH_FIELD& otherField = otherUnit->GetFields()[ii];
2501 otherUnit->RemoveField( otherField.
GetName() );
2505 if( updateExclFromBOM )
2507 otherUnit->SetExcludedFromBOM(
GetExcludedFromBOM( &aSourceSheet, aVariantName ), &sheet,
2511 if( updateExclFromBoard )
2517 if( updateExclFromPosFiles )
2524 otherUnit->SetDNP(
GetDNP( &aSourceSheet, aVariantName ), &sheet, aVariantName );
2526 if( updatePinMapOverride )
2527 otherUnit->SetPinMapOverride(
GetPinMapOverride( &aSourceSheet, aVariantName ), &sheet,
2532 for(
const std::unique_ptr<SCH_PIN>& model_pin :
m_pins )
2534 for(
SCH_PIN* src_pin : otherUnit->GetPinsByNumber( model_pin->GetNumber() ) )
2535 src_pin->SetAlt( model_pin->GetAlt() );
2546 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2547 aFunction(
pin.get() );
2550 aFunction( &field );
2563 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2565 if(
pin->GetNumber() == aNumber )
2574 const wxString& aVariantName )
const
2579 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2583 if(
pad == aPadNumber )
2594 std::vector<SCH_PIN*> pins;
2596 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2598 if(
pin->GetNumber() == aNumber )
2599 pins.push_back(
pin.get() );
2608 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2610 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
2611 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
2619 if(
pin->GetPosition() == aPos )
2632 return std::vector<SCH_PIN*>();
2641 return std::vector<SCH_PIN*>();
2653 auto it =
m_pinMap.find( aLibPin );
2658 wxFAIL_MSG_AT(
"Pin not found", __FILE__, __LINE__, __FUNCTION__ );
2665 std::vector<const SCH_PIN*> pins;
2674 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2679 pins.push_back(
pin.get() );
2688 std::vector<SCH_PIN*> pins;
2697 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2702 pins.push_back(
pin.get() );
2711 std::vector<SCH_PIN*> pins;
2713 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2718 &&
pin->GetUnit() != aUnit )
2726 &&
pin->GetBodyStyle() != aBodyStyle )
2731 pins.push_back(
pin.get() );
2740 wxCHECK_RET( aItem !=
nullptr && aItem->
Type() ==
SCH_SYMBOL_T, wxT(
"Cannot swap data with invalid symbol." ) );
2751 for( std::unique_ptr<SCH_PIN>&
pin : symbol->
m_pins )
2752 pin->SetParent( symbol );
2754 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2755 pin->SetParent(
this );
2761 m_part.reset( libSymbol );
2801 if( field.IsPrivate() )
2804 if( field.IsMandatory() )
2805 aVars->push_back( field.GetUntranslatedName().Upper() );
2807 aVars->push_back( field.GetName() );
2810 aVars->push_back( wxT(
"OP" ) );
2811 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
2812 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
2813 aVars->push_back( wxT(
"UNIT" ) );
2814 aVars->push_back( wxT(
"SHORT_REFERENCE" ) );
2815 aVars->push_back( wxT(
"SYMBOL_LIBRARY" ) );
2816 aVars->push_back( wxT(
"SYMBOL_NAME" ) );
2817 aVars->push_back( wxT(
"SYMBOL_DESCRIPTION" ) );
2818 aVars->push_back( wxT(
"SYMBOL_KEYWORDS" ) );
2819 aVars->push_back( wxT(
"SYMBOL_IS_POWER" ) );
2820 aVars->push_back( wxT(
"SYMBOL_IS_LOCAL_POWER" ) );
2821 aVars->push_back( wxT(
"EXCLUDE_FROM_BOM" ) );
2822 aVars->push_back( wxT(
"EXCLUDE_FROM_BOARD" ) );
2823 aVars->push_back( wxT(
"EXCLUDE_FROM_SIM" ) );
2824 aVars->push_back( wxT(
"DNP" ) );
2825 aVars->push_back( wxT(
"SHORT_NET_NAME(<pin_number>)" ) );
2826 aVars->push_back( wxT(
"NET_NAME(<pin_number>)" ) );
2827 aVars->push_back( wxT(
"NET_CLASS(<pin_number>)" ) );
2828 aVars->push_back( wxT(
"PIN_NAME(<pin_number>)" ) );
2829 aVars->push_back( wxT(
"REFERENCE(<pin_number>)" ) );
2830 aVars->push_back( wxT(
"SHORT_REFERENCE(<pin_number>)" ) );
2831 aVars->push_back( wxT(
"UNIT(<pin_number>)" ) );
2851 thread_local wxRegEx operatingPoint( wxT(
"^"
2867 && ( operatingPoint.Matches( *token ) || token->StartsWith( wxS(
"NET_NAME(" ) )
2868 || token->StartsWith( wxS(
"SHORT_NET_NAME(" ) ) || token->StartsWith( wxS(
"NET_CLASS(" ) ) ) )
2874 if( operatingPoint.Matches( *token ) )
2876 wxString
pin( operatingPoint.GetMatch( *token, 1 ).Lower() );
2877 wxString precisionStr( operatingPoint.GetMatch( *token, 3 ) );
2878 wxString rangeStr( operatingPoint.GetMatch( *token, 4 ) );
2880 int precision = precisionStr.IsEmpty() ? 3 : precisionStr[0] -
'0';
2881 wxString range = rangeStr.IsEmpty() ? wxString( wxS(
"~A" ) ) : rangeStr;
2885 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
2886 embeddedFilesStack.push_back(
schematic->GetEmbeddedFiles() );
2889 embeddedFilesStack.push_back(
m_part->GetEmbeddedFiles() );
2895 aVariantName, devnull ).model;
2899 wxString spiceRef =
model.SpiceGenerator().ItemName( spiceItem );
2900 spiceRef = spiceRef.Lower();
2904 *token =
schematic->GetOperatingPoint( spiceRef, precision, range );
2907 else if(
pin == wxS(
":power" ) )
2909 if( rangeStr.IsEmpty() )
2910 range = wxS(
"~W" );
2912 *token =
schematic->GetOperatingPoint( spiceRef + wxS(
":power" ), precision, range );
2917 pin =
pin.SubString( 1, -1 );
2919 for(
const std::reference_wrapper<const SIM_MODEL_PIN>& modelPin :
model.GetPins() )
2921 SCH_PIN* symbolPin =
GetPin( modelPin.get().symbolPinNumber );
2928 if(
model.GetPins().size() == 2 )
2930 *token =
schematic->GetOperatingPoint( spiceRef, precision, range );
2934 wxString netChainName = spiceRef + wxS(
":" ) + modelPin.get().modelPinName;
2935 *token =
schematic->GetOperatingPoint( netChainName, precision, range );
2943 *token = wxS(
"?" );
2947 if( token->Contains(
':' ) )
2949 if(
schematic->ResolveCrossReference( token, aDepth + 1 ) )
2955 wxString fieldName = field.IsMandatory() ? field.GetUntranslatedName() : field.GetName();
2957 wxString textToken = field.GetText();
2958 textToken.Replace(
" ", wxEmptyString );
2959 wxString tokenString =
"${" + fieldName +
"}";
2962 if( textToken.IsSameAs( tokenString,
false ) )
2965 if( token->IsSameAs( fieldName,
false ) )
2968 *token =
GetRef( aPath,
true );
2970 *token = field.GetShownText( aPath,
INTERNAL, aVariantName, aDepth + 1 );
2977 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
2978 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
2979 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
2981 *token = wxEmptyString;
2986 schematic->Project().GetProjectFile().m_TemplateFieldNames.GetResolvedTemplateFieldNames() )
2988 if( token->IsSameAs( templateFieldname.m_Name ) || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
2992 *token = wxEmptyString;
2997 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
3001 wxArrayString parts = wxSplit( footprint,
':' );
3003 if( parts.Count() > 0 )
3006 *token = wxEmptyString;
3010 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
3014 wxArrayString parts = wxSplit( footprint,
':' );
3016 if( parts.Count() > 1 )
3017 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
3019 *token = wxEmptyString;
3023 else if( token->IsSameAs( wxT(
"UNIT" ) ) )
3028 else if( token->IsSameAs( wxT(
"SHORT_REFERENCE" ) ) )
3030 *token =
GetRef( aPath,
false );
3033 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
3035 *token =
m_lib_id.GetUniStringLibNickname();
3038 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
3040 *token =
m_lib_id.GetUniStringLibItemName();
3043 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
3048 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
3053 else if( token->IsSameAs( wxT(
"SYMBOL_IS_POWER" ) ) )
3055 *token = this->
IsPower() ? wxString( wxS(
"Power Symbol" ) ) : wxString(
"" );
3058 else if( token->IsSameAs( wxT(
"SYMBOL_IS_LOCAL_POWER" ) ) )
3060 *token = this->
IsLocalPower() ? wxString( wxS(
"Local Power Symbol" ) ) : wxString(
"" );
3063 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
3065 *token = wxEmptyString;
3067 if( aPath->
GetExcludedFromBOM( aVariantName ) || this->ResolveExcludedFromBOM( aPath, aVariantName ) )
3068 *token = wxS(
"Excluded from BOM" );
3072 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
3074 *token = wxEmptyString;
3076 if( aPath->
GetExcludedFromBoard( aVariantName ) || this->ResolveExcludedFromBoard( aPath, aVariantName ) )
3077 *token = wxS(
"Excluded from board" );
3081 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
3083 *token = wxEmptyString;
3085 if( aPath->
GetExcludedFromSim( aVariantName ) || this->ResolveExcludedFromSim( aPath, aVariantName ) )
3086 *token = wxS(
"Excluded from simulation" );
3090 else if( token->IsSameAs( wxT(
"DNP" ) ) )
3092 *token = wxEmptyString;
3094 if( aPath->
GetDNP( aVariantName ) || this->ResolveDNP( aPath, aVariantName ) )
3095 *token = wxS(
"DNP" );
3099 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) ) || token->StartsWith( wxT(
"NET_NAME(" ) )
3100 || token->StartsWith( wxT(
"NET_CLASS(" ) ) || token->StartsWith( wxT(
"PIN_NAME(" ) )
3101 || token->StartsWith( wxT(
"PIN_BASE_NAME(" ) ) || token->StartsWith( wxT(
"PIN_ALT_LIST(" ) )
3102 || token->StartsWith( wxT(
"REFERENCE(" ) ) || token->StartsWith( wxT(
"SHORT_REFERENCE(" ) )
3103 || token->StartsWith( wxT(
"UNIT(" ) ) )
3105 wxString pinNumber = token->AfterFirst(
'(' );
3106 pinNumber = pinNumber.BeforeLast(
')' );
3108 auto resolvePinConnection =
3111 const bool local = token->StartsWith( wxS(
"SHORT_NET_NAME" ) );
3112 const auto name =
pin.GetConnectionName( &
path, local );
3121 *token =
name->Lower().StartsWith( wxS(
"unconnected" ) ) ? wxString(
"NC" ) : *
name;
3122 else if( token->StartsWith( wxS(
"NET_NAME" ) ) )
3124 else if( token->StartsWith( wxS(
"NET_CLASS" ) ) )
3125 *token =
pin.GetEffectiveNetClass( &
path )->GetName();
3128 bool isReferenceFunction = token->StartsWith( wxT(
"REFERENCE(" ) );
3129 bool isShortReferenceFunction = token->StartsWith( wxT(
"SHORT_REFERENCE(" ) );
3130 bool isUnitFunction = token->StartsWith( wxT(
"UNIT(" ) );
3134 std::vector<const SCH_PIN*> pinsToSearch;
3135 std::vector<const SCH_PIN*> altPinsToSearch;
3137 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
3140 pinsToSearch.push_back(
pin );
3145 pinsToSearch.push_back(
pin );
3148 altPinsToSearch.push_back(
pin );
3153 if(
pin->GetNumber() == pinNumber )
3155 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
3157 int pinUnit =
pin->GetUnit();
3160 if( isReferenceFunction )
3168 else if( isShortReferenceFunction )
3173 else if( isUnitFunction )
3182 *token = std::move(
result );
3185 else if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
3187 *token =
pin->GetAlt().IsEmpty() ?
pin->GetName() :
pin->GetAlt();
3190 else if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
3192 *token =
pin->GetBaseName();
3195 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
3200 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
3202 for(
const auto& [altName, altDef] : alts )
3204 if( !altList.IsEmpty() )
3205 altList += wxT(
", " );
3210 *token = std::move( altList );
3214 resolvePinConnection( *
pin, *aPath );
3223 if(
pin->GetNumber() == pinNumber )
3226 if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
3228 *token =
pin->GetBaseName();
3231 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
3236 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
3238 for(
const auto& [altName, altDef] : alts )
3240 if( !altList.IsEmpty() )
3241 altList += wxT(
", " );
3250 int pinUnit =
pin->GetUnit();
3266 if( symbol->
GetRef( &sheetPath,
false ) ==
GetRef( aPath,
false )
3269 targetPath = sheetPath;
3270 targetSymbol = symbol;
3283 *token = wxString::Format( wxT(
"<Unit %s not placed>" ),
SubReference( pinUnit,
false ) );
3289 SCH_PIN* instancePin =
nullptr;
3293 if( candidate->GetNumber() == pinNumber )
3295 instancePin = candidate;
3302 *token = wxEmptyString;
3307 if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
3309 *token = instancePin->
GetAlt().IsEmpty() ? instancePin->
GetName() : instancePin->
GetAlt();
3313 resolvePinConnection( *instancePin, targetPath );
3320 *token = wxString::Format( wxT(
"<Unresolved: pin %s>" ), pinNumber );
3324 else if( token->StartsWith( wxS(
"PROPERTY." ) ) )
3327 wxString propertyName = token->AfterFirst(
'.' );
3328 propertyName.Replace( wxS(
"_" ), wxS(
" " ) );
3338 if( propertyName.CmpNoCase( candidate->Name() ) == 0 )
3340 property = candidate;
3346 if( !property || property->IsHiddenFromPropertiesManager() )
3354 const wxString&
name =
property->Name();
3356 if(
name == wxS(
"Reference" ) )
3357 sourceValue =
GetRef( aPath );
3358 else if(
name == wxS(
"Value" ) )
3360 else if(
name == wxS(
"Unit" ) )
3362 else if(
name == wxS(
"Exclude From Simulation" ) )
3364 else if(
name == wxS(
"Exclude From Bill of Materials" ) )
3366 else if(
name == wxS(
"Exclude From Board" ) )
3368 else if(
name == wxS(
"Exclude From Position Files" ) )
3370 else if(
name == wxS(
"Do not Populate" ) )
3371 sourceValue =
GetDNP( aPath, aVariantName );
3373 sourceValue = instanceProperty->ValueForInstance(
this, aPath, aVariantName );
3375 sourceValue =
Get( property );
3402 if( instance.m_Path ==
path )
3404 if( instance.m_Reference.IsEmpty() || aResetPrefix )
3415 if( instance.m_Reference.IsEmpty() || aResetPrefix )
3422 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3423 pin->ClearDefaultNetName( aSheetPath );
3433 if( currentReference.IsEmpty() || aResetPrefix )
3444 wxCHECK( aSheetPath.size() > 0,
false );
3449 if( instance.m_Path == aSheetPath )
3474 bool transform =
false;
3476 switch( aOrientation )
3597 wxFAIL_MSG(
"Invalid schematic symbol orientation type." );
3651 for(
int type_rotate : rotate_values )
3663 wxFAIL_MSG(
"Schematic symbol orientation matrix internal error." );
3671void SCH_SYMBOL::Show(
int nestLevel, std::ostream& os )
const
3674 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
" ref=\""
3680 for(
int i = 1; i < (int)
GetFields().size(); ++i )
3682 const wxString& value =
GetFields()[i].GetText();
3684 if( !value.IsEmpty() )
3686 NestedSpace( nestLevel + 1, os ) <<
"<field" <<
" name=\"" <<
TO_UTF8(
GetFields()[i].GetName() ) <<
'"'
3687 <<
" value=\"" <<
TO_UTF8( value ) <<
"\"/>\n";
3691 NestedSpace( nestLevel, os ) <<
"</" <<
TO_UTF8(
GetClass().Lower() ) <<
">\n";
3713 if( aIncludeFields )
3717 if( field.IsVisible() )
3718 bBox.
Merge( field.GetBoundingBox() );
3732 catch(
const boost::bad_pointer& e )
3734 wxFAIL_MSG( wxString::Format( wxT(
"Boost pointer exception occurred: %s" ), e.what() ) );
3760 auto addExcludes = [&]()
3765 msgs.Add(
_(
"Simulation" ) );
3768 msgs.Add(
_(
"BOM" ) );
3771 msgs.Add(
_(
"Board" ) );
3773 if(
GetDNP( currentSheet, currentVariant ) )
3774 msgs.Add(
_(
"DNP" ) );
3776 msg = wxJoin( msgs,
'|' );
3777 msg.Replace(
'|', wxS(
", " ) );
3780 aList.emplace_back(
_(
"Exclude from" ), msg );
3791 aList.emplace_back(
_(
"Power symbol" ),
3799 aList.emplace_back(
_(
"Value" ),
3806 aList.emplace_back(
_(
"flags" ), wxString::Format(
"%X",
GetEditFlags() ) );
3811 msg =
_(
"Missing parent" );
3813 std::shared_ptr<LIB_SYMBOL> parent =
m_part->GetParent().lock();
3816 msg = parent->GetName();
3820 else if( !
m_lib_id.GetLibNickname().empty() )
3822 aList.emplace_back(
_(
"Library" ),
m_lib_id.GetLibNickname() );
3826 aList.emplace_back(
_(
"Library" ),
_(
"Undefined!!!" ) );
3834 msg =
_(
"<Unknown>" );
3836 aList.emplace_back(
_(
"Footprint" ), msg );
3840 _(
"Keywords" ) + wxT(
": " ) +
m_part->GetKeyWords() );
3845 aList.emplace_back(
_(
"Reference" ),
GetRef( currentSheet ) );
3854 if( libNickname.empty() )
3855 msg =
_(
"No library defined!" );
3857 msg.Printf(
_(
"Symbol not found in %s!" ), libNickname );
3859 aList.emplace_back(
_(
"Library" ), msg );
3873 return libSymbol->GetEmbeddedFiles();
3892 field.SetTextPos( pos );
3910 field.SetTextPos( pos );
3929 field.SetTextPos( pos );
3951 if(
const std::unique_ptr<LIB_SYMBOL>& libSymbol =
GetLibSymbolRef() )
3953 for(
const SCH_ITEM& drawItem : libSymbol->GetDrawItems() )
3958 if( drawItem.Matches( aSearchData, aAuxData ) )
3970 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3978 aItemList.push_back( item );
3985 std::vector<DANGLING_END_ITEM>& aItemListByPos,
const SCH_SHEET_PATH* aPath )
3987 bool changed =
false;
3989 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3991 bool previousState =
pin->IsDangling();
3992 pin->SetIsDangling(
true );
3997 bool do_break =
false;
3999 for(
auto it = lower; it < aItemListByPos.end() && it->GetPosition() == pos; it++ )
4018 pin->SetIsDangling(
false );
4029 changed = ( changed || ( previousState !=
pin->IsDangling() ) );
4054 wxCHECK( symbol,
false );
4060 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4062 if(
pin->IsDangling() )
4078 if(
GetRef( aInstance ) != symbol->
GetRef( aInstance ) )
4088 for(
size_t i = 0; i <
m_pins.size(); i++ )
4100 std::vector<VECTOR2I> retval;
4102 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4106 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
4107 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
4127 if( effectiveSymbol )
4141 return wxString::Format(
_(
"Symbol %s [%s]" ),
4149 for(
KICAD_T scanType : aScanTypes )
4194 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4198 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
4199 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
4260 std::vector<SCH_FIELD*> fields, otherFields;
4263 aSymbol.
GetFields( otherFields,
false );
4265 if( fields.size() != otherFields.size() )
4268 for(
int ii = 0; ii < (int) fields.size(); ii++ )
4273 if( fields[ii]->GetText().Cmp( otherFields[ii]->GetText() ) != 0 )
4292 for(
int ii = 0; ii < (int)
m_pins.size(); ++ii )
4299 if( *
m_pins[ii] != *matched )
4309 return !( *
this == aSymbol );
4315 wxCHECK_MSG(
Type() == aSymbol.
Type(), *
this,
4316 wxT(
"Cannot assign object type " ) + aSymbol.
GetClass() + wxT(
" to type " ) +
GetClass() );
4318 if( &aSymbol !=
this )
4327 auto oldPart = std::exchange(
m_part, aSymbol.
m_part ? std::make_unique<LIB_SYMBOL>( *aSymbol.
m_part )
4346 field.SetParent(
this );
4360 bBox.
Inflate( aAccuracy / 2 );
4376 rect.
Inflate( aAccuracy / 2 );
4398 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4411 if(
pin->GetLocalPosition() == new_pos )
4426 const VECTOR2I& aOffset,
bool aDimmed )
4436 bool usingAlternate = ( effectiveSym !=
m_part.get() );
4443 std::vector<SCH_PIN*> symbolPins =
MapLibPins( libPins, usingAlternate );
4446 for(
unsigned i = 0; i < tempPins.size(); ++i )
4448 SCH_PIN* symbolPin = symbolPins[i];
4449 SCH_PIN* tempPin = tempPins[i];
4479 bool dnp =
GetDNP( sheet, variant );
4481 for(
bool local_background : {
true,
false } )
4487 field.ClearRenderCache();
4492 && ( field.IsVisible() || field.IsForceVisible() )
4493 && !local_background )
4506 std::vector<wxString> properties;
4510 wxString text_field = field.GetShownText( sheet,
FOR_GUI, variant );
4512 if( text_field.IsEmpty() )
4515 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ), field.GetName(), text_field ) );
4520 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ),
4531 if( !effectiveSym->
IsPower() )
4545 margins.
x = std::max( margins.
x * 0.6, margins.
y * 0.3 );
4546 margins.
y = std::max( margins.
y * 0.6, margins.
x * 0.3 );
4564 double lineWidth = aSize / 10.0;
4566 std::vector<SCH_SHAPE> shapeList;
4568 int tolerance = 100;
4570 for(
const SCH_SHAPE& shape : shapeList )
4577 aPlotter->
BezierCurve( shape.GetStart(), shape.GetBezierC1(), shape.GetBezierC2(), shape.GetEnd(),
4578 tolerance, lineWidth );
4582 aPlotter->
Circle( shape.getCenter(), shape.GetRadius() * 2, filled, lineWidth );
4633 bool usingAlternate = ( effectiveSym !=
m_part.get() );
4644 std::vector<SCH_PIN*> symbolPins =
MapLibPins( libPins, usingAlternate );
4648 for(
unsigned i = 0; i < tempPins.size(); ++i )
4650 SCH_PIN* symbolPin = symbolPins[i];
4651 SCH_PIN* tempPin = tempPins[i];
4669 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4671 if(
pin->IsBrightened() )
4681 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4682 pin->ClearBrightened();
4700 m_part->SetShowPinNames( aShow );
4713 m_part->SetShowPinNumbers( aShow );
4719 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4721 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
4722 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
4730 if(
pin->IsPointClickableAnchor( aPos ) )
4749 if( pin_list.size() != 1 )
4767 if( pin_list.size() != 1 )
4779 return m_part->IsLocalPower();
4788 return m_part->IsGlobalPower();
4800 wxCHECK(
m_part,
false );
4802 return m_part->IsNormal();
4808 std::unordered_set<wxString> componentClass;
4810 auto getComponentClassFields = [&](
const std::vector<SCH_FIELD>& fields )
4814 if( field.GetUntranslatedName() == wxT(
"Component Class" ) )
4816 if( field.GetShownText( aPath,
INTERNAL ) != wxEmptyString )
4817 componentClass.insert( field.GetShownText( aPath,
INTERNAL ) );
4823 getComponentClassFields(
m_fields );
4830 getComponentClassFields( label->GetFields() );
4834 return componentClass;
4839 const wxString& aVariantName )
const
4844 return std::nullopt;
4846 return instance.
m_Variants.find( aVariantName )->second;
4858 if( instance->
m_Variants.insert( std::make_pair( aVariant.
m_Name, aVariant ) ).second )
4866 if( aVariantName.IsEmpty() )
4871 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
4880 wxString libIdStr = libId.
Format();
4889 return cacheIt->second.get();
4913 cached = libSymbol->Flatten();
4921 return cached.get();
4939 if( !variantName.IsEmpty() )
4954 std::vector<SCH_PIN*> mapped;
4956 mapped.reserve( aLibPins.size() );
4964 mapped.resize( aLibPins.size(),
nullptr );
4969 std::vector<bool> matched( basePins.size(),
false );
4971 for(
const SCH_PIN* alternatePin : aLibPins )
4973 SCH_PIN* instancePin =
nullptr;
4975 for(
size_t i = 0; i < basePins.size(); ++i )
4981 instancePin =
GetPin(
const_cast<SCH_PIN*
>( basePins[i] ) );
4985 mapped.push_back( instancePin );
4990 for(
const SCH_PIN* libPin : aLibPins )
4991 mapped.push_back(
GetPin(
const_cast<SCH_PIN*
>( libPin ) ) );
5003 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
5013 const wxString& aFieldName )
5017 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
5020 if( instance->
m_Variants[aVariantName].m_Fields.erase( aFieldName ) )
5026 const wxString& aNewName )
5031 if( aOldName == aNewName || !instance || !instance->
m_Variants.contains( aOldName ) )
5036 variant.
m_Name = aNewName;
5038 instance->
m_Variants.insert( std::make_pair( aNewName, variant ) );
5045 const wxString& aNewVariant )
5050 if( !instance || !instance->
m_Variants.contains( aSourceVariant ) )
5055 variant.
m_Name = aNewVariant;
5057 if( instance->
m_Variants.insert( std::make_pair( aNewVariant, variant ) ).second )
5063 const wxString& aVariantName,
5071 if( !instance->
m_Variants.contains( aVariantName ) )
5075 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
5078 const bool changed = std::exchange( instance->
m_Variants[aVariantName].m_SymbolOverride, aLibId ) != aLibId;
5087 const wxString& aVariantName )
5091 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
5154 for(
unsigned i = 0; i <
m_pins.size(); ++i )
5163 if( m_instanceReferences != symbol.m_instanceReferences )
5189 double aLineWidth,
bool aHorizontal )
5193 double x_right = aSize / 1.6180339887;
5194 double x_middle = x_right / 2.0;
5207 aShapeList.back().SetStart( bottomPt );
5208 aShapeList.back().SetBezierC1( bottomAnchorPt );
5209 aShapeList.back().SetBezierC2( leftSideAnchorPt1 );
5210 aShapeList.back().SetEnd( leftPt );
5214 aShapeList.back().SetStart( leftPt );
5215 aShapeList.back().SetBezierC1( leftSideAnchorPt2 );
5216 aShapeList.back().SetBezierC2( rightSideAnchorPt2 );
5217 aShapeList.back().SetEnd( rightPt );
5220 aShapeList.back().SetStart( rightPt );
5221 aShapeList.back().SetBezierC1( rightSideAnchorPt1 );
5222 aShapeList.back().SetBezierC2( bottomAnchorPt );
5223 aShapeList.back().SetEnd( bottomPt );
5226 aShapeList.back().SetCenter( ( leftPt + rightPt ) / 2.0 );
5227 aShapeList.back().SetRadius( aSize / 15.0 );
5232 shape.Rotate(
VECTOR2I( 0, 0 ),
true );
5291 return symbol->GetLibSymbolRef() !=
nullptr;
5304 const wxString groupFields =
_HKI(
"Fields" );
5326 return symbol->IsMultiUnit();
5331 auto multiBodyStyle =
5335 return symbol->IsMultiBodyStyle();
5346 wxPGChoices choices;
5350 for(
int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
5351 choices.Add( symbol->GetUnitDisplayName( ii,
false ), ii );
5363 wxPGChoices choices;
5367 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
5368 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
5374 const wxString groupAttributes =
_HKI(
"Attributes" );
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
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)
std::vector< PROPERTY_BASE * > GetCustomPropertiesAsInspectables() const
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.
Class that other classes need to inherit from, in order to be inspectable.
wxAny Get(PROPERTY_BASE *aProperty) const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
A typed sum value used to carry the before/after of any single property.
wxString ToDisplayString() const
Human-readable representation with no unit context.
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.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
wxString GetKeyWords() const override
bool IsPower() const override
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.
SCH_ITEM * LocateDrawItem(int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I &aPoint)
Locate a draw object.
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
static LIB_SYMBOL * GetDummy()
Return a dummy LIB_SYMBOL, used when one is missing in the schematic.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
const BOX2I GetBodyBoundingBox(int aUnit, int aBodyStyle, bool aIncludePins, bool aIncludePrivateItems) const
Get the symbol bounding box excluding fields.
wxString GetShownKeyWords(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
bool Deserialize(const kiapi::schematic::types::SchematicSymbol &aInput)
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
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.
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...
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
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.
PROPERTY_BASE(const wxString &aName, PROPERTY_DISPLAY aDisplay=PT_DEFAULT, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
Used to generate unique IDs. Must come up front so it's initialized before ctor.
PROPERTY_BASE & SetGroup(const wxString &aGroup)
const wxString & Name() const
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.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
bool IsAvailableFor(TYPE_ID aItemClass, PROPERTY_BASE *aProp, INSPECTABLE *aItem)
Checks overriden availability and original availability of a property, returns false if the 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
Commit for the schematic and symbol editors.
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.
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 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,...
void SetLocked(bool aLocked) override
SCH_SCREEN * GetParentScreen() const
void invalidateConnectivity(KICAD_T aChangedType=TYPE_NOT_INIT)
Bump the parent screen's connectivity revision when this item, or the item owning it as a child,...
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
virtual void ClearCaches()
void SetConnectivityDirty(bool aDirty=true)
Set the dirty flag.
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
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)
AUTOPLACE_ALGO GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
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.
size_t BaseHash() const override
Return type-id of the Base class.
size_t OwnerHash() const override
Return type-id of the Owner class.
size_t TypeHash() const override
Return type-id of the property type.
SCH_SYMBOL_FIELD_PROPERTY(const wxString &aName)
void setter(void *obj, wxAny &v) override
wxAny ValueForInstance(const SCH_SYMBOL *symbol, const SCH_SHEET_PATH *sheetPath, const wxString &variantName) const override
wxAny getter(const void *aObject) const final
PROPERTY_BASE(const wxString &aName, PROPERTY_DISPLAY aDisplay=PT_DEFAULT, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
Used to generate unique IDs. Must come up front so it's initialized before ctor.
virtual wxAny ValueForInstance(const SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH *aPath, const wxString &aVariant) const =0
size_t TypeHash() const override
Return type-id of the property type.
size_t BaseHash() const override
Return type-id of the Base class.
SCH_SYMBOL_PIN_MAP_ENTRY_PROPERTY(const wxString &aName, const wxString &aPinNumber)
bool Writeable(INSPECTABLE *aObject) const override
wxAny ValueForInstance(const SCH_SYMBOL *symbol, const SCH_SHEET_PATH *sheetPath, const wxString &variantName) const override
size_t OwnerHash() const override
Return type-id of the Owner class.
void setter(void *obj, wxAny &v) override
wxAny ValueForInstance(const SCH_SYMBOL *symbol, const SCH_SHEET_PATH *sheetPath, const wxString &variantName) const override
SCH_SYMBOL_PIN_MAP_MODE_PROPERTY()
void setter(void *obj, wxAny &v) override
size_t TypeHash() const override
Return type-id of the property type.
size_t OwnerHash() const override
Return type-id of the Owner class.
static wxPGChoices BuildChoices()
size_t BaseHash() const override
Return type-id of the Base class.
SCH_SYMBOL_PIN_MAP_NAME_PROPERTY()
size_t TypeHash() const override
Return type-id of the property type.
static wxPGChoices BuildChoices(const SCH_SYMBOL *aSymbol)
static std::vector< wxString > MapNames(const SCH_SYMBOL *aSymbol)
size_t OwnerHash() const override
Return type-id of the Owner class.
void setter(void *obj, wxAny &v) override
wxAny ValueForInstance(const SCH_SYMBOL *symbol, const SCH_SHEET_PATH *sheetPath, const wxString &variantName) const override
size_t BaseHash() const override
Return type-id of the Base class.
Variant information for a schematic symbol.
PIN_MAP_INSTANCE_OVERRIDE m_PinMapOverride
Per-instance pin-to-pad map override for this variant (issue #2282).
std::optional< LIB_ID > m_SymbolOverride
Alternate library symbol to substitute for the base symbol in this variant, if any.
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
PASSTHROUGH_MODE GetPassthroughMode() 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.
bool ClearVariantSymbolOverride(const SCH_SHEET_PATH &aPath, const wxString &aVariantName)
Remove the alternate-symbol override for a given variant and sheet instance.
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
std::map< wxString, std::unique_ptr< LIB_SYMBOL > > m_variantSymbolCache
SCH_SYMBOL_INSTANCE * getInstance(const KIID_PATH &aPath)
wxString SubReference(int aUnit, bool aAddSeparator=true) const
bool m_doNetlist
True if the symbol should appear in netlist.
wxString GetClass() const override
Return the class name.
void setVariantAttribute(bool aEnable, const SCH_SHEET_PATH *aInstance, const wxString &aVariantName, bool SCH_SYMBOL::*aBase, bool SCH_SYMBOL_VARIANT::*aOverride)
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
void SetVariantSymbolOverride(const SCH_SHEET_PATH &aPath, const wxString &aVariantName, const LIB_ID &aLibId)
Set the alternate-symbol override for a given variant and sheet instance.
bool UseLibIdLookup() const
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
bool SetInstanceProjectName(const KIID_PATH &aSheetPath, const wxString &aProjectName)
Set the owning project of the instance stored for aSheetPath.
wxString GetSchSymbolLibraryName() const
void ClearCaches() override
const wxString GetFootprintFieldText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString) const
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()
std::vector< SCH_PIN * > MapLibPins(const std::vector< SCH_PIN * > &aLibPins, bool aByNumber) const
Map pins of an effective library symbol to this symbol's instance pins.
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.
wxString GetShownKeyWords(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void SetExcludedFromBOMProp(bool aEnable)
void ClearVariantField(const KIID_PATH &aPath, const wxString &aVariantName, const wxString &aFieldName)
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.
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
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.
wxString GetShownDescription(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
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)
const LIB_SYMBOL * GetEffectiveLibSymbol(const SCH_SHEET_PATH *aPath=nullptr) const
Return the library symbol to use for rendering and bounding box calculations.
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.
LIB_SYMBOL * GetVariantLibSymbol(const wxString &aVariantName, const SCH_SHEET_PATH &aPath) const
Resolve the alternate library symbol for a given variant.
void SetValueProp(const wxString &aValue)
void SetUnitProp(int aUnit)
void SetSchSymbolLibraryName(const wxString &aName)
The name of the symbol in the schematic library symbol list.
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.
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit, int aBodyStyle) const override
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
std::map< wxString, std::unique_ptr< PROPERTY_BASE > > m_dynamicPropertyCache
Per-object cache of dynamic property descriptors for custom fields and effective pin-map entries,...
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< PROPERTY_BASE * > GetDynamicProperties() const override
Return dynamically-computed properties specific to this object instance (e.g.
void SetPassthroughMode(PASSTHROUGH_MODE aMode)
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
const wxString GetValue(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString) const override
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 ...
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 copy of SCH_PIN objects from the library symbol.
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 HasEffectiveAssociatedFootprint() const
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, std::span< const wxString > aPins, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
An interface to the global shared library manager that is schematic-specific and linked to one projec...
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
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
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, RESOLUTION_CONTEXT aContext)
#define DEFAULT_LINE_WIDTH_MILS
The default line width in mils. (can be changed in preference menu)
static bool empty(const wxTextEntryBase *aCtrl)
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
static constexpr EDA_ANGLE ANGLE_270
@ FILLED_SHAPE
Fill with object color.
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
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.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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.
DIFF_VALUE WxAnyToDiffValue(const wxAny &aValue, PROPERTY_BASE *aProperty)
Convert a wxAny value read from a PROPERTY_BASE getter into a DIFF_VALUE that the engine can store,...
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 void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
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)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
PIN_MAP_OVERRIDE_MODE
Override mode stored on a SCH_SYMBOL_INSTANCE.
@ 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 TYPE_HASH(x)
Macro to generate unique identifier for a type.
#define NO_SETTER(owner, type)
Macro to define read-only fields (no setter method available)
#define ENUM_TO_WXANY(type)
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
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)
static const wxString PIN_MAP_GROUP
static const wxString PIN_MAP_MODE_PROP
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
static const wxString PIN_MAP_FOOTPRINT_PROP
static const ASSOCIATED_FOOTPRINT * activeAssociatedFootprint(const SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH *aPath=nullptr, const wxString &aVariant=wxEmptyString)
static const wxString PIN_MAP_ENTRY_PREFIX
static const wxString PIN_MAP_NAME_PROP
static void plotLocalPowerIcon(PLOTTER *aPlotter, const VECTOR2D &aPos, double aSize, bool aRotate)
plot a local power pin indicator icon.
static const wxString PIN_MAP_TABLE_GROUP
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)
std::vector< std::pair< FIELD_T, wxString > > Fields
Per-instance override of the active pin map and a sparse delta on top.
PIN_MAP_OVERRIDE_MODE m_Mode
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
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
Return a default symbol field name for a mandatory field type.
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".
JSON_SCHEMA_VALIDATOR validator(schema)
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.
std::vector< VARIANT_COMPAT_RESULT > ValidateVariantSymbolCompatibility(const LIB_SYMBOL &aBase, const LIB_SYMBOL &aCandidate)
Check whether aCandidate can be used as a variant symbol override for aBase.
bool VariantSymbolPinsMatch(const SCH_PIN &aBase, const SCH_PIN &aCandidate)
Check whether two graphical pins occupy the same variant-symbol connection slot.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D