52#include <api/schematic/schematic_types.pb.h>
167 const wxString& aVariant = wxEmptyString )
169 const std::unique_ptr<LIB_SYMBOL>& libSymbol = aSymbol->
GetLibSymbolRef();
174 const std::vector<ASSOCIATED_FOOTPRINT>& assoc = libSymbol->GetEffectiveAssociatedFootprints();
182 fpId.
Parse( fpField->GetText( aPath, aVariant ) );
186 if( candidate.m_FootprintLibId == fpId )
190 return &assoc.front();
199 wxAny
getter(
const void* aObject )
const final
201 const auto* symbol =
reinterpret_cast<const SCH_SYMBOL*
>( aObject );
202 SCHEMATIC* schematic = symbol->Schematic();
208 const wxString& aVariant )
const = 0;
226 void setter(
void* obj, wxAny& v )
override
230 if( !v.GetAs( &value ) )
236 wxString variantName;
267 field->
SetText( value, sheetPath, variantName );
271 const wxString& variantName )
const override
280 if( !variantName.IsEmpty() && sheetPath )
285 return wxAny(
text );
311 void setter(
void* obj, wxAny& v )
override {}
314 const wxString& variantName )
const override
317 return wxAny( active->m_FootprintLibId.Format() );
319 return wxAny( wxEmptyString );
356 void setter(
void* obj, wxAny& v )
override
360 if( !v.GetAs( &value ) )
366 wxString variantName;
383 override.m_ActiveMapName = active->m_MapName;
390 const wxString& variantName )
const override
394 switch(
override.m_Mode )
426 return wxPGChoices();
436 std::vector<wxString> names;
438 if(
const std::unique_ptr<LIB_SYMBOL>& libSymbol = aSymbol->
GetLibSymbolRef() )
440 for(
const PIN_MAP& map : libSymbol->GetEffectivePinMaps().GetAll() )
441 names.push_back( map.GetName() );
450 const std::vector<wxString> names =
MapNames( aSymbol );
452 for(
size_t ii = 0; ii < names.size(); ++ii )
453 choices.Add( names[ii], (
int) ii );
458 void setter(
void* obj, wxAny& v )
override
462 if( !v.GetAs( &value ) )
466 const std::vector<wxString> names =
MapNames( symbol );
468 if( value < 0 || value >= (
int) names.size() )
472 wxString variantName;
482 override.m_ActiveMapName = names[value];
487 const wxString& variantName )
const override
496 const std::vector<wxString> names =
MapNames( symbol );
498 if( std::find( names.begin(), names.end(), active ) == names.end() )
501 active = fp->m_MapName;
504 for(
size_t ii = 0; ii < names.size(); ++ii )
506 if( names[ii] == active )
507 return wxAny( (
int) ii );
534 void setter(
void* obj, wxAny& v )
override {}
537 const wxString& variantName )
const override
544 std::vector<wxString> logical =
pin->GetStackedPinNumbers();
546 if( std::find( logical.begin(), logical.end(),
m_pinNumber ) == logical.end() )
549 wxString
pad =
pin->GetEffectivePadNumber( *sheetPath, variantName );
552 return wxAny( wxString::Format(
_(
"%s (identity)" ),
pad ) );
574 std::string ret =
TO_UTF8( txt );
578 if( (
unsigned char) c <=
' ' )
605 std::unique_ptr<LIB_SYMBOL> part;
636 SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.BodyStyle, aPosition, aParent )
639 for(
const auto& [fieldId, fieldValue] : aSel.
Fields )
641 if( fieldId == FIELD_T::REFERENCE )
642 SetRef( aSheet, fieldValue );
643 else if( SCH_FIELD* field = GetField( fieldId ) )
644 field->SetText( fieldValue );
674 field.SetParent(
this );
681 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol.
m_pins )
683 m_pins.emplace_back( std::make_unique<SCH_PIN>( *
pin ) );
684 m_pins.back()->SetParent(
this );
690 m_part = std::make_unique<LIB_SYMBOL>( *aSymbol.m_part );
709 return libSymbol && !libSymbol->GetEffectiveAssociatedFootprints().empty();
721 std::vector<PROPERTY_BASE*> props;
723 auto getOrCreateFieldProperty =
724 [&](
const wxString& aName )
730 auto prop = std::make_unique<SCH_SYMBOL_FIELD_PROPERTY>( aName );
734 return it->second.get();
737 auto getOrCreatePinMapProperty =
738 [&](
const wxString& aName,
const std::function<std::unique_ptr<PROPERTY_BASE>()>& aCreator )
745 return it->second.get();
750 if( !field.IsMandatory() )
753 if( field.IsPrivate() )
756 const wxString&
name = field.GetUntranslatedName();
761 props.push_back( getOrCreateFieldProperty(
name ) );
764 std::vector<const SCH_FIELD*> userFields;
768 if( field.IsMandatory() || field.IsPrivate() )
771 userFields.push_back( &field );
774 std::ranges::sort( userFields,
780 for(
const SCH_FIELD* field : userFields )
782 const wxString&
name = field->GetUntranslatedName();
783 props.push_back( getOrCreateFieldProperty(
name ) );
787 props.push_back( prop );
795 return std::make_unique<SCH_SYMBOL_PIN_MAP_FOOTPRINT_PROPERTY>();
800 return std::make_unique<SCH_SYMBOL_PIN_MAP_MODE_PROPERTY>();
805 return std::make_unique<SCH_SYMBOL_PIN_MAP_NAME_PROPERTY>();
814 for(
const wxString& number :
pin->GetStackedPinNumbers() )
816 if( number.IsEmpty() )
821 props.push_back( getOrCreatePinMapProperty( propName,
824 return std::make_unique<SCH_SYMBOL_PIN_MAP_ENTRY_PROPERTY>( propName, number );
875 kiapi::schematic::types::SchematicSymbolInstance symbol;
878 if( !aContainer.PackFrom( symbol ) )
879 wxFAIL_MSG( wxT(
"Failed to pack SCH_SYMBOL" ) );
888 aSymbol.mutable_id()->set_value(
m_Uuid.AsStdString() );
890 aSymbol.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
897 PackLibId( aSymbol.mutable_lib_id(),
id );
902 SchematicSymbolTransform* transform = aSymbol.mutable_transform();
903 transform->set_orientation(
909 aSymbol.mutable_body_style()->set_style(
GetBodyStyle() );
919 if( field.IsMandatory() )
922 field.Serialize( *aSymbol.add_user_fields(),
schIUScale );
926 m_part->Serialize( *aSymbol.mutable_definition(),
true );
939 kiapi::schematic::types::SchematicSymbolInstance symbol;
941 if( !aContainer.UnpackTo( &symbol ) )
956 screen->BumpConnectivityRevision();
960 SetLocked( aSymbol.locked() == LockedState::LS_LOCKED );
964 if( aSymbol.has_lib_id() )
975 const bool haveDefinition = aSymbol.has_definition();
977 std::unordered_map<::KIID, wxString> pinAltMap;
981 const SchematicSymbol& def = aSymbol.definition();
986 for(
const SchematicSymbolChild& child : def.items() )
991 SchematicPin pinProto;
993 if( child.item().UnpackTo( &pinProto ) && pinProto.has_active_alternate() )
994 pinAltMap[
::KIID( pinProto.id().value() )] = wxString::FromUTF8( pinProto.active_alternate() );
1008 if( aSymbol.has_body_style() )
1017 std::set<wxString> incoming;
1019 for(
const SchematicField& fieldProto : aSymbol.user_fields() )
1021 wxString
name = wxString::FromUTF8( fieldProto.name() );
1028 incoming.insert(
name );
1036 std::vector<wxString> toRemove;
1040 if( !field.IsMandatory() && !incoming.count( field.GetName(
false ) ) )
1041 toRemove.push_back( field.GetName(
false ) );
1044 for(
const wxString&
name : toRemove )
1047 if( aSymbol.has_show_pin_names() )
1050 if( aSymbol.has_show_pin_numbers() )
1053 if( aSymbol.has_pin_name_offset() )
1062 if( haveDefinition )
1068 m_pins.emplace_back( std::make_unique<SCH_PIN>( *
pin ) );
1069 m_pins.back()->SetParent(
this );
1077 if( pinAltMap.contains(
pin->m_Uuid ) )
1078 pin->SetAlt( pinAltMap.at(
pin->m_Uuid ) );
1088 return m_part ==
nullptr;
1098 const int min_grid_size =
schIUScale.MilsToIU( 25 );
1100 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1102 if( ( (
pin->GetPosition().x -
m_pos.x ) % min_grid_size ) != 0 )
1105 if( ( (
pin->GetPosition().y -
m_pos.y ) % min_grid_size ) != 0 )
1131 wxCHECK2( !aLibSymbol || aLibSymbol->
IsRoot(), aLibSymbol =
nullptr );
1133 m_part.reset( aLibSymbol );
1140 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1141 pin->SetLibPin(
nullptr );
1150 return m_part->GetDescription();
1152 return wxEmptyString;
1159 return m_part->GetShownDescription( aContext, aDepth );
1161 return wxEmptyString;
1168 return m_part->GetKeyWords();
1170 return wxEmptyString;
1177 return m_part->GetShownKeyWords( aContext, aDepth );
1179 return wxEmptyString;
1186 return m_part->GetDatasheetField().GetText();
1188 return wxEmptyString;
1195 screen->BumpConnectivityRevision();
1203 std::map<wxString, wxString> altPinMap;
1204 std::map<wxString, SCH_PIN::ALT> altPinDefs;
1205 std::map<wxString, std::vector<SCH_PIN*>> pinUuidMap;
1206 std::set<SCH_PIN*> unassignedSchPins;
1207 std::vector<SCH_PIN*> unassignedLibPins;
1209 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1212 pinUuidMap[
pin->GetNumber()].push_back(
pin.get() );
1214 unassignedSchPins.insert(
pin.get() );
1216 if( !
pin->GetAlt().IsEmpty() )
1218 altPinMap[
pin->GetNumber()] =
pin->GetAlt();
1219 auto altDefIt =
pin->GetAlternates().find(
pin->GetAlt() );
1221 if( altDefIt !=
pin->GetAlternates().end() )
1222 altPinDefs[
pin->GetNumber()] = altDefIt->second;
1225 pin->SetLibPin(
nullptr );
1239 auto ii = pinUuidMap.find( libPin->GetNumber() );
1241 if( ii == pinUuidMap.end() || ii->second.empty() )
1243 unassignedLibPins.push_back( libPin );
1247 auto it = ii->second.begin();
1249 ii->second.erase( it );
1250 pin->GetAlternates() = libPin->GetAlternates();
1251 pin->SetLibPin( libPin );
1252 pin->SetCustomProperties( libPin->GetCustomProperties() );
1253 pin->SetPosition( libPin->GetPosition() );
1254 pin->SetUnit( libPin->GetUnit() );
1255 pin->SetBodyStyle( libPin->GetBodyStyle() );
1257 unassignedSchPins.erase(
pin );
1259 auto iii = altPinMap.find( libPin->GetNumber() );
1261 if( iii != altPinMap.end() )
1263 wxString altName = iii->second;
1265 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
1267 auto defIt = altPinDefs.find( libPin->GetNumber() );
1269 if( defIt != altPinDefs.end() )
1271 for(
const auto& [
name, alt] :
pin->GetAlternates() )
1273 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
1282 pin->SetAlt( altName );
1289 size_t nextUnassigned = 0;
1291 for(
SCH_PIN* libPin : unassignedLibPins )
1296 if( !unassignedSchPins.empty() )
1298 while( nextUnassigned <
m_pins.size()
1299 && !unassignedSchPins.contains(
m_pins[nextUnassigned].get() ) )
1304 pin =
m_pins.at( nextUnassigned++ ).get();
1305 unassignedSchPins.erase(
pin );
1310 pin =
m_pins.emplace_back( std::make_unique<SCH_PIN>(
SCH_PIN(
this, libPin ) ) ).get();
1314 pin->GetAlternates() = libPin->GetAlternates();
1315 pin->SetLibPin( libPin );
1316 pin->SetPosition( libPin->GetPosition() );
1317 pin->SetUnit( libPin->GetUnit() );
1318 pin->SetBodyStyle( libPin->GetBodyStyle() );
1319 pin->SetNumber( libPin->GetNumber() );
1321 auto iii = altPinMap.find( libPin->GetNumber() );
1323 if( iii != altPinMap.end() )
1325 wxString altName = iii->second;
1327 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
1329 auto defIt = altPinDefs.find( libPin->GetNumber() );
1331 if( defIt != altPinDefs.end() )
1333 for(
const auto& [
name, alt] :
pin->GetAlternates() )
1335 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
1344 pin->SetAlt( altName );
1349 for(
auto it1 =
m_pins.begin(); it1 !=
m_pins.end() && !unassignedSchPins.empty(); )
1351 auto it2 = unassignedSchPins.find( it1->get() );
1353 if( it2 != unassignedSchPins.end() )
1355 it1 =
m_pins.erase( it1 );
1356 unassignedSchPins.erase( it2 );
1367 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1388 return m_part->GetUnitCount();
1397 return m_part->GetBodyStyleCount();
1406 return m_part->HasDeMorganBodyStyles();
1415 return m_part->GetUnitDisplayName( aUnit, aLabel );
1417 return wxString::Format(
_(
"Unit %s" ),
SubReference( aUnit ) );
1426 return m_part->GetBodyStyleDescription( aBodyStyle, aLabel );
1449 if( instance.m_Path.EndsWith( aSheetPath ) )
1451 aInstance = instance;
1473 size_t ii = indexIt->second;
1475 wxASSERT(
m_instances[ii].m_Path == aInstancePath );
1480 wxS(
"Removing symbol instance:\n"
1482 " reference %s, unit %d from symbol %s." ),
1527 wxS(
"Adding symbol '%s' instance:\n"
1528 " sheet path '%s'\n"
1549 return refFor( sheet, aIncludeUnit,
true );
1555 return refFor( aSheet, aIncludeUnit,
false );
1561 return refFor( aSheet,
true,
true, aUnit );
1590 std::optional<int> aUnit )
const
1594 int instanceUnit = 0;
1595 bool onPath =
false;
1601 wxLogTrace(
traceSchSymbolRef,
"GetRef for symbol %s on path %s (sheet path has %zu sheets)",
1611 instanceUnit = instance.
m_Unit;
1627 wxLogTrace(
traceSchSymbolRef,
" Using fallback from REFERENCE field: %s", ref );
1639 const bool compose = aCompose && onPath && ref.Last() !=
'?';
1641 const bool withUnit = aUnit || ( aIncludeUnit && unitCount > 1 );
1645 else if( withUnit && onPath )
1654 ref +=
schematic->GetUnitRefSuffix(
this, *sheet, *aUnit );
1655 else if( withUnit || unitCount < 2 )
1656 schematic->AppendRefSuffix( ref, *sheet );
1658 ref +=
schematic->GetPackageRefSuffix(
this, *sheet );
1687 return wxEmptyString;
1691 const wxString own =
schematic->GetRefSuffix( aSheet );
1692 const wxString
package = schematic->GetPackageRefSuffix( this, aSheet );
1696 return wxEmptyString;
1699 if( onPath && ( ( !own.IsEmpty() && aText == existing.
m_Reference + own )
1700 || ( !package.IsEmpty() && aText == existing.
m_Reference + package ) ) )
1702 aBase = existing.m_Reference;
1703 return wxEmptyString;
1707 [&](
const wxString& aSuffix )
1709 return !aSuffix.IsEmpty() && aText.length() > aSuffix.length() && aText.EndsWith( aSuffix );
1713 size_t matched = endsIn( own ) ? own.length() : 0;
1715 if( endsIn( package ) )
1716 matched = std::max( matched, package.length() );
1723 if( path == aSheet )
1726 const wxString suffix = schematic->GetRefSuffix( path );
1728 if( endsIn( suffix ) && suffix.length() > matched )
1730 matched = suffix.length();
1731 sibling = path.PathHumanReadable( false );
1735 if( !sibling.IsEmpty() )
1736 return wxString::Format(
_(
"%s ends with the reference suffix of sheet %s." ), aText, sibling );
1738 aBase = aText.Left( aText.length() - matched );
1739 return wxEmptyString;
1745 SetRef( &aSheet, aBase );
1752 std::vector<SCH_SHEET_PATH> copies;
1757 if(
path == aSheet )
1764 copies.push_back(
path );
1782 m_instances[it->second].m_RefLacksSuffix = aLacksSuffix;
1789 const wxString previousPrefix =
m_prefix;
1791 bool changed =
false;
1796 changed = std::exchange( instance.
m_Reference, ref ) != ref;
1806 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1807 pin->ClearDefaultNetName( sheet );
1832 switch( aField->
GetId() )
1836 SetRef( aPath, aFieldText );
1841 wxString defaultText = aField->
GetText( aPath );
1843 if( aVariantName.IsEmpty() )
1845 if( aFieldText != defaultText )
1846 aField->
SetText( aFieldText );
1852 wxCHECK( instance, );
1858 const SCH_FIELD* altField = altSymbol->GetField( aFieldName );
1860 if( altField && !altField->
GetText().IsEmpty() )
1861 defaultText = altField->
GetText();
1864 bool changed =
false;
1866 if( instance->
m_Variants.contains( aVariantName ) )
1868 std::map<wxString, wxString>& fields = instance->
m_Variants[aVariantName].m_Fields;
1870 if( aFieldText != defaultText )
1872 auto [entry, inserted] = fields.try_emplace( aFieldName, aFieldText );
1873 changed = inserted || std::exchange( entry->second, aFieldText ) != aFieldText;
1877 changed = fields.erase( aFieldName ) != 0;
1880 else if( aFieldText != defaultText )
1885 newVariant.
m_Fields[aFieldName] = aFieldText;
1886 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
1901 const wxString& aVariantName )
1903 wxCHECK_MSG( !aFieldName.IsEmpty(), , wxT(
"Can't set text on a field with no name!" ) );
1907 wxCHECK_MSG( field, , wxT(
"Can't set text on a field not yet added to the symbol!" ) );
1909 SetFieldText( field, aFieldName, aFieldText, aPath, aVariantName );
1914 const wxString& aVariantName )
const
1916 switch( aField->
GetId() )
1919 wxCHECK( aPath, aField->
GetText() );
1924 if( !aVariantName.IsEmpty() && aPath )
1928 if( instance && instance->
m_Variants.contains( aVariantName )
1929 && instance->
m_Variants.at( aVariantName ).m_Fields.contains( aFieldName ) )
1931 return instance->
m_Variants.at( aVariantName ).m_Fields.at( aFieldName );
1940 if( altField && !altField->
GetText().IsEmpty() )
1948 if( aVariantName.IsEmpty() )
1956 if( instance && instance->
m_Variants.contains( aVariantName ) )
1960 if( variant.
m_Fields.contains( aFieldName ) )
1961 return variant.
m_Fields.at( aFieldName );
1969 if( altField && !altField->
GetText().IsEmpty() )
1983 const wxString& aVariantName )
const
1985 wxCHECK_MSG( !aFieldName.IsEmpty(), wxEmptyString, wxT(
"Can't get text from a field with no name!" ) );
1989 wxCHECK_MSG( field, wxEmptyString, wxT(
"Can't get text from a field not yet added to the symbol!" ) );
1991 return GetFieldText( field, aFieldName, aPath, aVariantName );
2001 if( instance.m_Path ==
path )
2002 return !instance.m_Reference.IsEmpty() && instance.m_Reference.Last() !=
'?';
2013 refDesignator.Replace(
"~",
" " );
2015 wxString prefix = refDesignator;
2017 while( prefix.Length() )
2019 wxUniCharRef last = prefix.Last();
2021 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
2022 prefix.RemoveLast();
2028 prefix.Trim(
true );
2029 prefix.Trim(
false );
2031 if( !prefix.IsEmpty() )
2041 const std::map<int, wxString>& names =
m_part->GetUnitDisplayNames();
2042 auto it = names.find( aUnit );
2044 if( it != names.end() )
2050 int sep =
schematic->Settings().m_SubpartIdSeparator;
2052 if( sep != 0 && aAddSeparator )
2053 subRef << wxChar( sep );
2056 subRef << it->second;
2062 return schematic->Settings().SubReference( aUnit, aAddSeparator );
2087 if( std::exchange(
m_instances[it->second].m_Unit, aUnitSelection ) != aUnitSelection )
2101 bool* attribute = &( this->*aBase );
2103 if( aInstance && !aVariantName.IsEmpty() )
2107 wxCHECK_MSG( instance, ,
2108 wxString::Format( wxS(
"Cannot set attribute for invalid sheet path '%s'." ),
2111 auto it = instance->
m_Variants.find( aVariantName );
2115 if( aEnable == this->*aBase )
2120 newVariant.*aOverride = aEnable;
2125 attribute = &( it->second.*aOverride );
2128 if( *attribute == aEnable )
2131 *attribute = aEnable;
2144 if( !aInstance || aVariantName.IsEmpty() )
2152 if( instance.
m_Variants.contains( aVariantName ) )
2153 return instance.
m_Variants[aVariantName].m_DNP;
2160 const wxString& aVariantName )
2162 if( !aInstance || aVariantName.IsEmpty() )
2170 wxCHECK_MSG( instance, ,
2171 wxString::Format( wxS(
"Cannot set pin map override for invalid sheet path '%s'." ),
2174 if( instance->
m_Variants.contains( aVariantName ) )
2176 instance->
m_Variants[aVariantName].m_PinMapOverride = aOverride;
2195 for(
auto& [
name, variant] : instance.m_Variants )
2202 const wxString& aVariantName )
const
2206 if( aInstance && !aVariantName.IsEmpty() )
2215 if(
result.IsDelegate() && aInstance )
2223 const wxString& aVariantName )
const
2228 wxString ref =
GetRef( &aSheet );
2236 if( sibling ==
this || sibling->
GetUnit() != 1 )
2239 if( sibling->
GetRef( &sheet ).CmpNoCase( ref ) != 0 )
2265 if( !aInstance || aVariantName.IsEmpty() )
2273 if( instance.
m_Variants.contains( aVariantName ) )
2274 return instance.
m_Variants[aVariantName].m_ExcludedFromBOM;
2290 if( !aInstance || aVariantName.IsEmpty() )
2298 if( instance.
m_Variants.contains( aVariantName ) )
2299 return instance.
m_Variants[aVariantName].m_ExcludedFromSim;
2307 const wxString& aVariantName )
2315 const wxString& aVariantName )
const
2317 if( !aInstance || aVariantName.IsEmpty() )
2325 if( instance.
m_Variants.contains( aVariantName ) )
2326 return instance.
m_Variants[aVariantName].m_ExcludedFromBoard;
2334 const wxString& aVariantName )
2342 const wxString& aVariantName )
const
2344 if( !aInstance || aVariantName.IsEmpty() )
2352 if( instance.
m_Variants.contains( aVariantName ) )
2353 return instance.
m_Variants[aVariantName].m_ExcludedFromPosFiles;
2362 bool changed =
false;
2365 changed |= std::exchange( instance.m_Unit, aUnitSelection ) != aUnitSelection;
2373 const wxString& aVariantName )
const
2375 if( aVariantName.IsEmpty() || !aInstance )
2378 std::optional variant =
GetVariant( *aInstance, aVariantName );
2385 [&](
const wxString& aText ) -> wxString
2387 std::function<bool( wxString* )> resolver =
2388 [&]( wxString* token ) ->
bool
2396 if( variant->m_Fields.contains( fieldName ) )
2397 return resolve( variant->m_Fields[fieldName] );
2405 if( altField && !altField->
GetText().IsEmpty() )
2406 return resolve( altField->
GetText() );
2417 const wxString& aVariantName )
2419 if( !aInstance || aVariantName.IsEmpty() )
2427 wxCHECK( instance, );
2431 if( instance->
m_Variants.contains( aVariantName ) )
2433 instance->
m_Variants[aVariantName].m_Fields[fieldName] = aValue;
2440 newVariant.
m_Fields[fieldName] = aValue;
2441 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
2447 const wxString& aVariantName )
const
2465 m_fields.emplace_back(
this, aFieldType );
2494 if( !field.IsVisible() || field.GetText().IsEmpty() )
2498 aVector.push_back(
const_cast<SCH_FIELD*
>( &field ) );
2501 std::sort( aVector.begin(), aVector.end(),
2504 return lhs->GetOrdinal() < rhs->GetOrdinal();
2528 wxString fieldName = aFieldName;
2530 for(
unsigned ii = 0; ii <
m_fields.size(); ++ii )
2535 if( fieldName ==
m_fields[ii].GetName(
false ) )
2541 for(
auto& [
name, variant] : instance.m_Variants )
2542 variant.m_Fields.erase( fieldName );
2557 if( field.GetName().IsSameAs( aFieldName,
false ) )
2569 if( field.GetName().IsSameAs( aFieldName,
false ) )
2578 bool aResetRef,
bool aResetOtherFields )
2582 std::vector<SCH_FIELD*> fields;
2583 m_part->GetFields( fields );
2585 for(
const SCH_FIELD* libField : fields )
2590 if( libField->IsMandatory() )
2592 fieldType = libField->GetId();
2597 schField =
GetField( libField->GetUntranslatedName() );
2607 schField->
SetPrivate( libField->IsPrivate() );
2619 else if( aUpdateRef )
2620 SetRef( aPath, libField->GetText() );
2628 if( aResetOtherFields )
2630 else if( aUpdateOtherFields )
2631 schField->
SetText( libField->GetText() );
2635 if( aResetOtherFields || aUpdateOtherFields )
2636 schField->
SetText( libField->GetText() );
2646 bool updateValue =
true;
2647 bool updateExclFromBOM =
true;
2648 bool updateExclFromBoard =
true;
2649 bool updateExclFromPosFiles =
true;
2650 bool updateDNP =
true;
2651 bool updateOtherFields =
true;
2653 bool updatePinMapOverride =
true;
2657 updateValue = aProperty->
Name() ==
_HKI(
"Value" );
2658 updateExclFromBoard = aProperty->
Name() ==
_HKI(
"Exclude From Board" );
2659 updateExclFromBOM = aProperty->
Name() ==
_HKI(
"Exclude From Bill of Materials" );
2660 updateExclFromPosFiles = aProperty->
Name() ==
_HKI(
"Exclude From Position Files" );
2661 updateDNP = aProperty->
Name() ==
_HKI(
"Do not Populate" );
2662 updatePinMapOverride = aProperty->
Name() == wxS(
"Pin Map Mode" ) || aProperty->
Name() == wxS(
"Pin Map Name" );
2663 updateOtherFields =
false;
2667 if( !updateValue && !updateExclFromBOM && !updateExclFromBoard && !updateExclFromPosFiles && !updateDNP
2668 && !updateOtherFields && !
updatePins && !updatePinMapOverride )
2677 wxString ref =
GetRef( &aSourceSheet );
2682 std::vector<SCH_SYMBOL*> otherUnits;
2688 aCommit.
Modify( otherUnit, screen );
2694 &sheet, aVariantName );
2697 if( updateOtherFields )
2709 if( field.IsMandatory() )
2710 otherField = otherUnit->GetField( field.GetId() );
2712 otherField = otherUnit->GetField( field.GetName() );
2716 otherField->
SetText( field.GetText( &aSourceSheet, aVariantName ), &sheet, aVariantName );
2724 newField.
Offset( otherUnit->GetPosition() );
2727 SCH_FIELD* addedField = otherUnit->AddField( newField );
2729 if( !aVariantName.IsEmpty() )
2731 addedField->
SetText( field.GetText( &aSourceSheet, aVariantName ), &sheet,
2737 for(
int ii = (
int) otherUnit->GetFields().size() - 1; ii >= 0; ii-- )
2739 SCH_FIELD& otherField = otherUnit->GetFields()[ii];
2742 otherUnit->RemoveField( otherField.
GetName() );
2746 if( updateExclFromBOM )
2748 otherUnit->SetExcludedFromBOM(
GetExcludedFromBOM( &aSourceSheet, aVariantName ), &sheet,
2752 if( updateExclFromBoard )
2758 if( updateExclFromPosFiles )
2765 otherUnit->SetDNP(
GetDNP( &aSourceSheet, aVariantName ), &sheet, aVariantName );
2767 if( updatePinMapOverride )
2768 otherUnit->SetPinMapOverride(
GetPinMapOverride( &aSourceSheet, aVariantName ), &sheet,
2773 for(
const std::unique_ptr<SCH_PIN>& model_pin :
m_pins )
2775 for(
SCH_PIN* src_pin : otherUnit->GetPinsByNumber( model_pin->GetNumber() ) )
2776 src_pin->SetAlt( model_pin->GetAlt() );
2787 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2788 aFunction(
pin.get() );
2791 aFunction( &field );
2804 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2806 if(
pin->GetNumber() == aNumber )
2815 const wxString& aVariantName )
const
2820 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2824 if(
pad == aPadNumber )
2835 std::vector<SCH_PIN*> pins;
2837 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2839 if(
pin->GetNumber() == aNumber )
2840 pins.push_back(
pin.get() );
2849 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2851 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
2852 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
2860 if(
pin->GetPosition() == aPos )
2873 return std::vector<SCH_PIN*>();
2882 return std::vector<SCH_PIN*>();
2894 auto it =
m_pinMap.find( aLibPin );
2899 wxFAIL_MSG_AT(
"Pin not found", __FILE__, __LINE__, __FUNCTION__ );
2906 std::vector<const SCH_PIN*> pins;
2915 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2920 pins.push_back(
pin.get() );
2929 std::vector<SCH_PIN*> pins;
2938 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2943 pins.push_back(
pin.get() );
2952 std::vector<SCH_PIN*> pins;
2954 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2959 &&
pin->GetUnit() != aUnit )
2967 &&
pin->GetBodyStyle() != aBodyStyle )
2972 pins.push_back(
pin.get() );
2981 wxCHECK_RET( aItem !=
nullptr && aItem->
Type() ==
SCH_SYMBOL_T, wxT(
"Cannot swap data with invalid symbol." ) );
2992 for( std::unique_ptr<SCH_PIN>&
pin : symbol->
m_pins )
2993 pin->SetParent( symbol );
2995 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2996 pin->SetParent(
this );
3002 m_part.reset( libSymbol );
3047 if( field.IsPrivate() )
3050 if( field.IsMandatory() )
3051 aVars->push_back( field.GetUntranslatedName().Upper() );
3053 aVars->push_back( field.GetName() );
3056 aVars->push_back( wxT(
"OP" ) );
3057 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
3058 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
3059 aVars->push_back( wxT(
"UNIT" ) );
3060 aVars->push_back( wxT(
"SHORT_REFERENCE" ) );
3061 aVars->push_back( wxT(
"SYMBOL_LIBRARY" ) );
3062 aVars->push_back( wxT(
"SYMBOL_NAME" ) );
3063 aVars->push_back( wxT(
"SYMBOL_DESCRIPTION" ) );
3064 aVars->push_back( wxT(
"SYMBOL_KEYWORDS" ) );
3065 aVars->push_back( wxT(
"SYMBOL_IS_POWER" ) );
3066 aVars->push_back( wxT(
"SYMBOL_IS_LOCAL_POWER" ) );
3067 aVars->push_back( wxT(
"EXCLUDE_FROM_BOM" ) );
3068 aVars->push_back( wxT(
"EXCLUDE_FROM_BOARD" ) );
3069 aVars->push_back( wxT(
"EXCLUDE_FROM_SIM" ) );
3070 aVars->push_back( wxT(
"DNP" ) );
3071 aVars->push_back( wxT(
"SHORT_NET_NAME(<pin_number>)" ) );
3072 aVars->push_back( wxT(
"NET_NAME(<pin_number>)" ) );
3073 aVars->push_back( wxT(
"NET_CLASS(<pin_number>)" ) );
3074 aVars->push_back( wxT(
"PIN_NAME(<pin_number>)" ) );
3075 aVars->push_back( wxT(
"REFERENCE(<pin_number>)" ) );
3076 aVars->push_back( wxT(
"SHORT_REFERENCE(<pin_number>)" ) );
3077 aVars->push_back( wxT(
"UNIT(<pin_number>)" ) );
3097 thread_local wxRegEx operatingPoint( wxT(
"^"
3113 && ( operatingPoint.Matches( *token ) || token->StartsWith( wxS(
"NET_NAME(" ) )
3114 || token->StartsWith( wxS(
"SHORT_NET_NAME(" ) ) || token->StartsWith( wxS(
"NET_CLASS(" ) ) ) )
3120 if( operatingPoint.Matches( *token ) )
3122 wxString
pin( operatingPoint.GetMatch( *token, 1 ).Lower() );
3123 wxString precisionStr( operatingPoint.GetMatch( *token, 3 ) );
3124 wxString rangeStr( operatingPoint.GetMatch( *token, 4 ) );
3126 int precision = precisionStr.IsEmpty() ? 3 : precisionStr[0] -
'0';
3127 wxString range = rangeStr.IsEmpty() ? wxString( wxS(
"~A" ) ) : rangeStr;
3131 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
3132 embeddedFilesStack.push_back(
schematic->GetEmbeddedFiles() );
3136 m_part->AppendParentEmbeddedFiles( embeddedFilesStack );
3137 embeddedFilesStack.push_back(
m_part->GetEmbeddedFiles() );
3144 aVariantName, devnull ).model;
3148 wxString spiceRef =
model.SpiceGenerator().ItemName( spiceItem );
3149 spiceRef = spiceRef.Lower();
3153 *token =
schematic->GetOperatingPoint( spiceRef, precision, range );
3156 else if(
pin == wxS(
":power" ) )
3158 if( rangeStr.IsEmpty() )
3159 range = wxS(
"~W" );
3161 *token =
schematic->GetOperatingPoint( spiceRef + wxS(
":power" ), precision, range );
3166 pin =
pin.SubString( 1, -1 );
3168 for(
const std::reference_wrapper<const SIM_MODEL_PIN>& modelPin :
model.GetPins() )
3170 SCH_PIN* symbolPin =
GetPin( modelPin.get().symbolPinNumber );
3177 if(
model.GetPins().size() == 2 )
3179 *token =
schematic->GetOperatingPoint( spiceRef, precision, range );
3183 wxString netChainName = spiceRef + wxS(
":" ) + modelPin.get().modelPinName;
3184 *token =
schematic->GetOperatingPoint( netChainName, precision, range );
3192 *token = wxS(
"?" );
3196 if( token->Contains(
':' ) )
3198 if(
schematic->ResolveCrossReference( token, aDepth + 1 ) )
3204 wxString fieldName = field.IsMandatory() ? field.GetUntranslatedName() : field.GetName();
3206 wxString textToken = field.GetText();
3207 textToken.Replace(
" ", wxEmptyString );
3208 wxString tokenString =
"${" + fieldName +
"}";
3211 if( textToken.IsSameAs( tokenString,
false ) )
3214 if( token->IsSameAs( fieldName,
false ) )
3217 *token =
GetRef( aPath,
true );
3219 *token = field.GetShownText( aPath,
INTERNAL, aVariantName, aDepth + 1 );
3226 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
3227 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
3228 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
3230 *token = wxEmptyString;
3235 schematic->Project().GetProjectFile().m_TemplateFieldNames.GetResolvedTemplateFieldNames() )
3237 if( token->IsSameAs( templateFieldname.m_Name ) || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
3241 *token = wxEmptyString;
3246 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
3250 wxArrayString parts = wxSplit( footprint,
':' );
3252 if( parts.Count() > 0 )
3255 *token = wxEmptyString;
3259 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
3263 wxArrayString parts = wxSplit( footprint,
':' );
3265 if( parts.Count() > 1 )
3266 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
3268 *token = wxEmptyString;
3272 else if( token->IsSameAs( wxT(
"UNIT" ) ) )
3277 else if( token->IsSameAs( wxT(
"SHORT_REFERENCE" ) ) )
3279 *token =
GetRef( aPath,
false );
3282 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
3284 *token =
m_lib_id.GetUniStringLibNickname();
3287 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
3289 *token =
m_lib_id.GetUniStringLibItemName();
3292 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
3297 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
3302 else if( token->IsSameAs( wxT(
"SYMBOL_IS_POWER" ) ) )
3304 *token = this->
IsPower() ? wxString( wxS(
"Power Symbol" ) ) : wxString(
"" );
3307 else if( token->IsSameAs( wxT(
"SYMBOL_IS_LOCAL_POWER" ) ) )
3309 *token = this->
IsLocalPower() ? wxString( wxS(
"Local Power Symbol" ) ) : wxString(
"" );
3312 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
3314 *token = wxEmptyString;
3316 if( aPath->
GetExcludedFromBOM( aVariantName ) || this->ResolveExcludedFromBOM( aPath, aVariantName ) )
3317 *token = wxS(
"Excluded from BOM" );
3321 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
3323 *token = wxEmptyString;
3325 if( aPath->
GetExcludedFromBoard( aVariantName ) || this->ResolveExcludedFromBoard( aPath, aVariantName ) )
3326 *token = wxS(
"Excluded from board" );
3330 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
3332 *token = wxEmptyString;
3334 if( aPath->
GetExcludedFromSim( aVariantName ) || this->ResolveExcludedFromSim( aPath, aVariantName ) )
3335 *token = wxS(
"Excluded from simulation" );
3339 else if( token->IsSameAs( wxT(
"DNP" ) ) )
3341 *token = wxEmptyString;
3343 if( aPath->
GetDNP( aVariantName ) || this->ResolveDNP( aPath, aVariantName ) )
3344 *token = wxS(
"DNP" );
3348 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) ) || token->StartsWith( wxT(
"NET_NAME(" ) )
3349 || token->StartsWith( wxT(
"NET_CLASS(" ) ) || token->StartsWith( wxT(
"PIN_NAME(" ) )
3350 || token->StartsWith( wxT(
"PIN_BASE_NAME(" ) ) || token->StartsWith( wxT(
"PIN_ALT_LIST(" ) )
3351 || token->StartsWith( wxT(
"REFERENCE(" ) ) || token->StartsWith( wxT(
"SHORT_REFERENCE(" ) )
3352 || token->StartsWith( wxT(
"UNIT(" ) ) )
3354 wxString pinNumber = token->AfterFirst(
'(' );
3355 pinNumber = pinNumber.BeforeLast(
')' );
3357 auto resolvePinConnection =
3360 const bool local = token->StartsWith( wxS(
"SHORT_NET_NAME" ) );
3361 const std::optional<wxString>
name =
pin.GetConnectionName( &
path, local );
3370 *token =
name->Lower().StartsWith( wxS(
"unconnected" ) ) ? wxString(
"NC" ) : *
name;
3371 else if( token->StartsWith( wxS(
"NET_NAME" ) ) )
3373 else if( token->StartsWith( wxS(
"NET_CLASS" ) ) )
3374 *token =
pin.GetEffectiveNetClass( &
path )->GetName();
3377 bool isReferenceFunction = token->StartsWith( wxT(
"REFERENCE(" ) );
3378 bool isShortReferenceFunction = token->StartsWith( wxT(
"SHORT_REFERENCE(" ) );
3379 bool isUnitFunction = token->StartsWith( wxT(
"UNIT(" ) );
3383 std::vector<const SCH_PIN*> pinsToSearch;
3384 std::vector<const SCH_PIN*> altPinsToSearch;
3386 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
3389 pinsToSearch.push_back(
pin );
3394 pinsToSearch.push_back(
pin );
3397 altPinsToSearch.push_back(
pin );
3402 if(
pin->GetNumber() == pinNumber )
3404 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
3406 int pinUnit =
pin->GetUnit();
3409 if( isReferenceFunction )
3417 else if( isShortReferenceFunction )
3422 else if( isUnitFunction )
3431 *token = std::move(
result );
3434 else if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
3436 *token =
pin->GetAlt().IsEmpty() ?
pin->GetName() :
pin->GetAlt();
3439 else if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
3441 *token =
pin->GetBaseName();
3444 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
3449 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
3451 for(
const auto& [altName, altDef] : alts )
3453 if( !altList.IsEmpty() )
3454 altList += wxT(
", " );
3459 *token = std::move( altList );
3463 resolvePinConnection( *
pin, *aPath );
3472 if(
pin->GetNumber() == pinNumber )
3475 if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
3477 *token =
pin->GetBaseName();
3480 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
3485 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
3487 for(
const auto& [altName, altDef] : alts )
3489 if( !altList.IsEmpty() )
3490 altList += wxT(
", " );
3499 int pinUnit =
pin->GetUnit();
3515 if( symbol->
GetRef( &sheetPath,
false ) ==
GetRef( aPath,
false )
3518 targetPath = sheetPath;
3519 targetSymbol = symbol;
3532 *token = wxString::Format( wxT(
"<Unit %s not placed>" ),
SubReference( pinUnit,
false ) );
3538 SCH_PIN* instancePin =
nullptr;
3542 if( candidate->GetNumber() == pinNumber )
3544 instancePin = candidate;
3551 *token = wxEmptyString;
3556 if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
3558 *token = instancePin->
GetAlt().IsEmpty() ? instancePin->
GetName() : instancePin->
GetAlt();
3562 resolvePinConnection( *instancePin, targetPath );
3569 *token = wxString::Format( wxT(
"<Unresolved: pin %s>" ), pinNumber );
3573 else if( token->StartsWith( wxS(
"PROPERTY." ) ) )
3576 wxString propertyName = token->AfterFirst(
'.' );
3577 propertyName.Replace( wxS(
"_" ), wxS(
" " ) );
3587 if( propertyName.CmpNoCase( candidate->Name() ) == 0 )
3589 property = candidate;
3595 if( !property || property->IsHiddenFromPropertiesManager() )
3603 const wxString&
name =
property->Name();
3605 if(
name == wxS(
"Reference" ) )
3606 sourceValue =
GetRef( aPath );
3607 else if(
name == wxS(
"Value" ) )
3609 else if(
name == wxS(
"Unit" ) )
3611 else if(
name == wxS(
"Exclude From Simulation" ) )
3613 else if(
name == wxS(
"Exclude From Bill of Materials" ) )
3615 else if(
name == wxS(
"Exclude From Board" ) )
3617 else if(
name == wxS(
"Exclude From Position Files" ) )
3619 else if(
name == wxS(
"Do not Populate" ) )
3620 sourceValue =
GetDNP( aPath, aVariantName );
3622 sourceValue = instanceProperty->ValueForInstance(
this, aPath, aVariantName );
3624 sourceValue =
Get( property );
3651 if( instance.m_Path ==
path )
3653 if( instance.m_Reference.IsEmpty() || aResetPrefix )
3658 instance.m_RefLacksSuffix =
false;
3666 if( instance.m_Reference.IsEmpty() || aResetPrefix )
3671 instance.m_RefLacksSuffix =
false;
3675 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3676 pin->ClearDefaultNetName( aSheetPath );
3688 if( currentReference.IsEmpty() || aResetPrefix )
3699 wxCHECK( aSheetPath.size() > 0,
false );
3704 if( instance.m_Path == aSheetPath )
3729 bool transform =
false;
3731 switch( aOrientation )
3852 wxFAIL_MSG(
"Invalid schematic symbol orientation type." );
3906 for(
int type_rotate : rotate_values )
3918 wxFAIL_MSG(
"Schematic symbol orientation matrix internal error." );
3926void SCH_SYMBOL::Show(
int nestLevel, std::ostream& os )
const
3929 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
" ref=\""
3935 for(
int i = 1; i < (int)
GetFields().size(); ++i )
3937 const wxString& value =
GetFields()[i].GetText();
3939 if( !value.IsEmpty() )
3941 NestedSpace( nestLevel + 1, os ) <<
"<field" <<
" name=\"" <<
TO_UTF8(
GetFields()[i].GetName() ) <<
'"'
3942 <<
" value=\"" <<
TO_UTF8( value ) <<
"\"/>\n";
3946 NestedSpace( nestLevel, os ) <<
"</" <<
TO_UTF8(
GetClass().Lower() ) <<
">\n";
3968 if( aIncludeFields )
3972 if( field.IsVisible() )
3973 bBox.
Merge( field.GetBoundingBox() );
3987 catch(
const boost::bad_pointer& e )
3989 wxFAIL_MSG( wxString::Format( wxT(
"Boost pointer exception occurred: %s" ), e.what() ) );
4021 msgs.Add(
_(
"Simulation" ) );
4024 msgs.Add(
_(
"BOM" ) );
4027 msgs.Add(
_(
"Board" ) );
4029 if(
GetDNP( currentSheet, currentVariant ) )
4030 msgs.Add(
_(
"DNP" ) );
4032 msg = wxJoin( msgs,
'|' );
4033 msg.Replace(
'|', wxS(
", " ) );
4036 aList.emplace_back(
_(
"Exclude from" ), msg );
4047 aList.emplace_back(
_(
"Power symbol" ),
4055 aList.emplace_back(
_(
"Value" ),
4062 aList.emplace_back(
_(
"flags" ), wxString::Format(
"%X",
GetEditFlags() ) );
4067 msg =
_(
"Missing parent" );
4069 std::shared_ptr<LIB_SYMBOL> parent =
m_part->GetParent().lock();
4072 msg = parent->GetName();
4076 else if( !
m_lib_id.GetLibNickname().empty() )
4078 aList.emplace_back(
_(
"Library" ),
m_lib_id.GetLibNickname() );
4082 aList.emplace_back(
_(
"Library" ),
_(
"Undefined!!!" ) );
4090 msg =
_(
"<Unknown>" );
4092 aList.emplace_back(
_(
"Footprint" ), msg );
4096 _(
"Keywords" ) + wxT(
": " ) +
m_part->GetKeyWords() );
4101 aList.emplace_back(
_(
"Reference" ),
GetRef( currentSheet ) );
4110 if( libNickname.empty() )
4111 msg =
_(
"No library defined!" );
4113 msg.Printf(
_(
"Symbol not found in %s!" ), libNickname );
4115 aList.emplace_back(
_(
"Library" ), msg );
4129 return libSymbol->GetEmbeddedFiles();
4148 field.SetTextPos( pos );
4166 field.SetTextPos( pos );
4185 field.SetTextPos( pos );
4207 if(
const std::unique_ptr<LIB_SYMBOL>& libSymbol =
GetLibSymbolRef() )
4209 for(
const SCH_ITEM& drawItem : libSymbol->GetDrawItems() )
4214 if( drawItem.Matches( aSearchData, aAuxData ) )
4226 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4234 aItemList.push_back( item );
4241 std::vector<DANGLING_END_ITEM>& aItemListByPos,
const SCH_SHEET_PATH* aPath )
4243 bool changed =
false;
4245 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4247 bool previousState =
pin->IsDangling();
4248 pin->SetIsDangling(
true );
4253 bool do_break =
false;
4255 for(
auto it = lower; it < aItemListByPos.end() && it->GetPosition() == pos; it++ )
4274 pin->SetIsDangling(
false );
4285 changed = ( changed || ( previousState !=
pin->IsDangling() ) );
4310 wxCHECK( symbol,
false );
4316 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4318 if(
pin->IsDangling() )
4348 for(
size_t i = 0; i <
m_pins.size(); i++ )
4360 std::vector<VECTOR2I> retval;
4362 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4366 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
4367 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
4387 if( effectiveSymbol )
4401 return wxString::Format(
_(
"Symbol %s [%s]" ),
4409 for(
KICAD_T scanType : aScanTypes )
4454 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4458 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
4459 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
4520 std::vector<SCH_FIELD*> fields, otherFields;
4523 aSymbol.
GetFields( otherFields,
false );
4525 if( fields.size() != otherFields.size() )
4528 for(
int ii = 0; ii < (int) fields.size(); ii++ )
4533 if( fields[ii]->GetText().Cmp( otherFields[ii]->GetText() ) != 0 )
4552 std::set<SCH_PIN*, SCH_SYMBOL::cmp_pins> sortedPins;
4553 std::set<SCH_PIN*, SCH_SYMBOL::cmp_pins> sortedOtherPins;
4555 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4556 sortedPins.insert(
pin.get() );
4558 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol.
m_pins )
4559 sortedOtherPins.insert(
pin.get() );
4561 if( sortedPins.size() != sortedOtherPins.size() )
4564 for(
auto aIt = sortedPins.begin(), bIt = sortedOtherPins.begin(); aIt != sortedPins.end(); ++aIt, ++bIt )
4566 if( !( *aIt )->operator==( *( *bIt ) ) )
4576 return !( *
this == aSymbol );
4582 wxCHECK_MSG(
Type() == aSymbol.
Type(), *
this,
4583 wxT(
"Cannot assign object type " ) + aSymbol.
GetClass() + wxT(
" to type " ) +
GetClass() );
4585 if( &aSymbol !=
this )
4594 auto oldPart = std::exchange(
m_part, aSymbol.
m_part ? std::make_unique<LIB_SYMBOL>( *aSymbol.
m_part )
4614 field.SetParent(
this );
4628 bBox.
Inflate( aAccuracy / 2 );
4644 rect.Inflate( aAccuracy / 2 );
4666 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4679 if(
pin->GetLocalPosition() == new_pos )
4694 const VECTOR2I& aOffset,
bool aDimmed )
4704 bool usingAlternate = ( effectiveSym !=
m_part.get() );
4711 std::vector<SCH_PIN*> symbolPins =
MapLibPins( libPins, usingAlternate );
4714 for(
unsigned i = 0; i < tempPins.size(); ++i )
4716 SCH_PIN* symbolPin = symbolPins[i];
4717 SCH_PIN* tempPin = tempPins[i];
4747 bool dnp =
GetDNP( sheet, variant );
4749 for(
bool local_background : {
true,
false } )
4755 field.ClearRenderCache();
4760 && ( field.IsVisible() || field.IsForceVisible() )
4761 && !local_background )
4774 std::vector<wxString> properties;
4778 wxString text_field = field.GetShownText( sheet,
FOR_GUI, variant );
4780 if( text_field.IsEmpty() )
4783 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ), field.GetName(), text_field ) );
4788 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ),
4799 if( !effectiveSym->
IsPower() )
4813 margins.
x = std::max( margins.
x * 0.6, margins.
y * 0.3 );
4814 margins.
y = std::max( margins.
y * 0.6, margins.
x * 0.3 );
4832 double lineWidth = aSize / 10.0;
4834 std::vector<SCH_SHAPE> shapeList;
4836 int tolerance = 100;
4838 for(
const SCH_SHAPE& shape : shapeList )
4845 aPlotter->
BezierCurve( shape.GetStart(), shape.GetBezierC1(), shape.GetBezierC2(), shape.GetEnd(),
4846 tolerance, lineWidth );
4850 aPlotter->
Circle( shape.getCenter(), shape.GetRadius() * 2, filled, lineWidth );
4901 bool usingAlternate = ( effectiveSym !=
m_part.get() );
4912 std::vector<SCH_PIN*> symbolPins =
MapLibPins( libPins, usingAlternate );
4916 for(
unsigned i = 0; i < tempPins.size(); ++i )
4918 SCH_PIN* symbolPin = symbolPins[i];
4919 SCH_PIN* tempPin = tempPins[i];
4937 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4939 if(
pin->IsBrightened() )
4949 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4950 pin->ClearBrightened();
4968 m_part->SetShowPinNames( aShow );
4981 m_part->SetShowPinNumbers( aShow );
4987 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4989 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
4990 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
4998 if(
pin->IsPointClickableAnchor( aPos ) )
5017 if( pin_list.size() != 1 )
5035 if( pin_list.size() != 1 )
5047 return m_part->IsLocalPower();
5056 return m_part->IsGlobalPower();
5068 m_part->SetGlobalPower();
5080 wxCHECK(
m_part,
false );
5082 return m_part->IsNormal();
5087 const wxString& aVariantName )
const
5089 std::unordered_set<wxString> componentClass;
5091 auto getComponentClassFields =
5092 [&](
const std::vector<SCH_FIELD>& fields )
5096 if( field.GetUntranslatedName() == wxT(
"Component Class" ) )
5098 const wxString classname = field.GetShownText( aPath,
INTERNAL, aVariantName );
5100 if( classname != wxEmptyString )
5101 componentClass.insert( classname );
5107 getComponentClassFields(
m_fields );
5113 getComponentClassFields( label->GetFields() );
5116 return componentClass;
5121 const wxString& aVariantName )
const
5126 return std::nullopt;
5128 return instance.
m_Variants.find( aVariantName )->second;
5140 if( instance->
m_Variants.insert( std::make_pair( aVariant.
m_Name, aVariant ) ).second )
5148 if( aVariantName.IsEmpty() )
5153 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
5162 wxString libIdStr = libId.
Format();
5171 return cacheIt->second.get();
5179 std::unique_ptr<LIB_SYMBOL> resolved;
5186 if(
auto it = libSymbols.find( libIdStr ); it != libSymbols.end() && it->second )
5187 resolved = it->second->Flatten();
5206 cached = std::move( resolved );
5214 return cached.get();
5220 std::vector<LIB_ID> overrides;
5224 for(
const auto& [
name, variant] : instance.m_Variants )
5226 if( variant.m_SymbolOverride
5227 && std::find( overrides.begin(), overrides.end(), *variant.m_SymbolOverride ) == overrides.end() )
5229 overrides.push_back( *variant.m_SymbolOverride );
5258 return libSymbol->Flatten();
5274 if( !variantName.IsEmpty() )
5289 std::vector<SCH_PIN*> mapped;
5291 mapped.reserve( aLibPins.size() );
5299 mapped.resize( aLibPins.size(),
nullptr );
5304 std::vector<bool> matched( basePins.size(),
false );
5306 for(
const SCH_PIN* alternatePin : aLibPins )
5308 SCH_PIN* instancePin =
nullptr;
5310 for(
size_t i = 0; i < basePins.size(); ++i )
5316 instancePin =
GetPin(
const_cast<SCH_PIN*
>( basePins[i] ) );
5320 mapped.push_back( instancePin );
5325 for(
const SCH_PIN* libPin : aLibPins )
5326 mapped.push_back(
GetPin(
const_cast<SCH_PIN*
>( libPin ) ) );
5338 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
5348 const wxString& aFieldName )
5352 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
5355 if( instance->
m_Variants[aVariantName].m_Fields.erase( aFieldName ) )
5361 const wxString& aNewName )
5366 if( aOldName == aNewName || !instance || !instance->
m_Variants.contains( aOldName ) )
5371 variant.
m_Name = aNewName;
5373 instance->
m_Variants.insert( std::make_pair( aNewName, variant ) );
5380 const wxString& aNewVariant )
5385 if( !instance || !instance->
m_Variants.contains( aSourceVariant ) )
5390 variant.
m_Name = aNewVariant;
5392 if( instance->
m_Variants.insert( std::make_pair( aNewVariant, variant ) ).second )
5398 const wxString& aVariantName,
5406 if( !instance->
m_Variants.contains( aVariantName ) )
5410 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
5413 const bool changed = std::exchange( instance->
m_Variants[aVariantName].m_SymbolOverride, aLibId ) != aLibId;
5422 const wxString& aVariantName )
5426 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
5489 for(
unsigned i = 0; i <
m_pins.size(); ++i )
5498 if( m_instanceReferences != symbol.m_instanceReferences )
5524 double aLineWidth,
bool aHorizontal )
5528 double x_right = aSize / 1.6180339887;
5529 double x_middle = x_right / 2.0;
5542 aShapeList.back().SetStart( bottomPt );
5543 aShapeList.back().SetBezierC1( bottomAnchorPt );
5544 aShapeList.back().SetBezierC2( leftSideAnchorPt1 );
5545 aShapeList.back().SetEnd( leftPt );
5549 aShapeList.back().SetStart( leftPt );
5550 aShapeList.back().SetBezierC1( leftSideAnchorPt2 );
5551 aShapeList.back().SetBezierC2( rightSideAnchorPt2 );
5552 aShapeList.back().SetEnd( rightPt );
5555 aShapeList.back().SetStart( rightPt );
5556 aShapeList.back().SetBezierC1( rightSideAnchorPt1 );
5557 aShapeList.back().SetBezierC2( bottomAnchorPt );
5558 aShapeList.back().SetEnd( bottomPt );
5561 aShapeList.back().SetCenter( ( leftPt + rightPt ) / 2.0 );
5562 aShapeList.back().SetRadius( aSize / 15.0 );
5567 shape.Rotate(
VECTOR2I( 0, 0 ),
true );
5626 return symbol->GetLibSymbolRef() !=
nullptr;
5639 const wxString groupFields =
_HKI(
"Fields" );
5650 if( !symbol || !symbol->
Schematic() || !aValue.GetAs( &value ) )
5659 return std::make_unique<VALIDATION_ERROR_MSG>( msg );
5689 return symbol->IsMultiUnit();
5694 auto multiBodyStyle =
5698 return symbol->IsMultiBodyStyle();
5709 wxPGChoices choices;
5713 for(
int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
5714 choices.Add( symbol->GetUnitDisplayName( ii,
false ), ii );
5726 wxPGChoices choices;
5730 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
5731 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
5743 return symbol->IsPower();
5748 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 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.
A base class for most all the KiCad significant classes used in schematics and boards.
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)
EDA_ITEM * GetParent() const
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
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library tables.
std::optional< LIBRARY_TABLE_ROW * > GetRow(const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
Like LIBRARY_MANAGER::GetRow but filtered to the LIBRARY_TABLE_TYPE of this adapter.
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)
PROPERTY_BASE & SetValidator(PROPERTY_VALIDATOR_FN &&aValidator)
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.
wxString GetRefSuffix(const SCH_SHEET_PATH &aPath) const
Return the composed reference suffix of aPath as of the last RefreshHierarchy().
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.
SCH_SCREEN * LastScreen()
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.
const KIID_PATH & PathRef() const
Borrow the cached path until this sheet path is modified or destroyed.
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)
wxString refFor(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit, bool aCompose, std::optional< int > aUnit=std::nullopt) const
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
std::map< wxString, std::unique_ptr< PROPERTY_BASE > > m_pinMapPropsStorageCache
Same for effective pin-map entries.
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
void ClearPinMapOverrides()
Clear the base pin-to-pad map override and every variant's override.
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)
void SetFieldText(SCH_FIELD *aField, const wxString &aFieldName, const wxString &aFieldText, const SCH_SHEET_PATH *aPath, const wxString &aVariantName)
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.
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
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)
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)
wxString GetCurrentSheetRef() const
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
wxString BaseRefFromUser(const SCH_SHEET_PATH &aSheet, const wxString &aText, wxString &aBase, const SCHEMATIC *aSchematic=nullptr) const
Convert a reference typed on aSheet to the base reference.
bool GetExcludedFromPosFilesProp() const
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
std::vector< LIB_ID > GetVariantSymbolOverrides() 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
wxString GetBaseRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) 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 SetLocalPowerProp(bool aLocal)
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 SetRefLacksSuffix(const KIID_PATH &aPath, bool aLacksSuffix=true)
Flag the reference loaded for aPath as saved without its sheet suffix.
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 base 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.
wxString GetUnitRef(const SCH_SHEET_PATH *aSheet, int aUnit) const
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...
std::unique_ptr< LIB_SYMBOL > LoadAlternateFromLibrary(const LIB_ID &aLibId) const
Load a flattened copy of an alternate symbol from the project's symbol libraries.
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.
std::unordered_set< wxString > GetComponentClassNames(const SCH_SHEET_PATH *aPath, const wxString &aVariantName) const
Return the component classes this symbol belongs in.
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 SetUserRef(const SCH_SHEET_PATH &aSheet, const wxString &aBase)
Set a base reference chosen by the user on aSheet.
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
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
void SetDNPProp(bool aEnable)
static uint64_t RefGeneration()
Count of changes to any symbol's references, units, library links or placement.
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.
static void BumpRefGeneration()
Mark every cache built from references as stale.
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::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
wxString GetFieldText(const SCH_FIELD *aField, const wxString &aFieldName, const SCH_SHEET_PATH *aPath, const wxString &aVariantName) const
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
std::map< wxString, std::unique_ptr< SCH_SYMBOL_FIELD_PROPERTY > > m_fieldPropsStorageCache
Per-object cache of dynamic property descriptors for custom fields, keyed by descriptor name and popu...
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...
std::optional< LIB_STATUS > LoadOne(LIB_DATA *aLib) override
Loads or reloads the given library, if it exists.
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.
int m_pinNameOffset
The offset in mils to draw the pin name.
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.
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.
std::optional< std::unique_ptr< VALIDATION_ERROR > > VALIDATOR_RESULT
Null optional means validation succeeded.
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 std::atomic< uint64_t > s_refGeneration
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.
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.
bool m_RefLacksSuffix
Set at load when the saved reference lacked its sheet suffix, cleared when the reference changes.
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
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)