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 getOrCreateFieldProperty =
721 [&](
const wxString& aName )
727 auto prop = std::make_unique<SCH_SYMBOL_FIELD_PROPERTY>( aName );
731 return it->second.get();
734 auto getOrCreatePinMapProperty =
735 [&](
const wxString& aName,
const std::function<std::unique_ptr<PROPERTY_BASE>()>& aCreator )
742 return it->second.get();
747 if( !field.IsMandatory() )
750 if( field.IsPrivate() )
753 const wxString&
name = field.GetUntranslatedName();
758 props.push_back( getOrCreateFieldProperty(
name ) );
761 std::vector<const SCH_FIELD*> userFields;
765 if( field.IsMandatory() || field.IsPrivate() )
768 userFields.push_back( &field );
771 std::ranges::sort( userFields,
777 for(
const SCH_FIELD* field : userFields )
779 const wxString&
name = field->GetUntranslatedName();
780 props.push_back( getOrCreateFieldProperty(
name ) );
784 props.push_back( prop );
792 return std::make_unique<SCH_SYMBOL_PIN_MAP_FOOTPRINT_PROPERTY>();
797 return std::make_unique<SCH_SYMBOL_PIN_MAP_MODE_PROPERTY>();
802 return std::make_unique<SCH_SYMBOL_PIN_MAP_NAME_PROPERTY>();
811 for(
const wxString& number :
pin->GetStackedPinNumbers() )
813 if( number.IsEmpty() )
818 props.push_back( getOrCreatePinMapProperty( propName,
821 return std::make_unique<SCH_SYMBOL_PIN_MAP_ENTRY_PROPERTY>( propName, number );
872 kiapi::schematic::types::SchematicSymbolInstance symbol;
874 aContainer.PackFrom( symbol );
883 aSymbol.mutable_id()->set_value(
m_Uuid.AsStdString() );
885 aSymbol.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
892 PackLibId( aSymbol.mutable_lib_id(),
id );
897 SchematicSymbolTransform* transform = aSymbol.mutable_transform();
898 transform->set_orientation(
904 aSymbol.mutable_body_style()->set_style(
GetBodyStyle() );
914 if( field.IsMandatory() )
917 field.Serialize( *aSymbol.add_user_fields(),
schIUScale );
921 m_part->Serialize( *aSymbol.mutable_definition(),
true );
934 kiapi::schematic::types::SchematicSymbolInstance symbol;
936 if( !aContainer.UnpackTo( &symbol ) )
951 screen->BumpConnectivityRevision();
955 SetLocked( aSymbol.locked() == LockedState::LS_LOCKED );
959 if( aSymbol.has_lib_id() )
970 const bool haveDefinition = aSymbol.has_definition();
972 std::unordered_map<::KIID, wxString> pinAltMap;
976 const SchematicSymbol& def = aSymbol.definition();
981 for(
const SchematicSymbolChild& child : def.items() )
986 SchematicPin pinProto;
988 if( child.item().UnpackTo( &pinProto ) && pinProto.has_active_alternate() )
989 pinAltMap[
::KIID( pinProto.id().value() )] = wxString::FromUTF8( pinProto.active_alternate() );
1003 if( aSymbol.has_body_style() )
1012 std::set<wxString> incoming;
1014 for(
const SchematicField& fieldProto : aSymbol.user_fields() )
1016 wxString
name = wxString::FromUTF8( fieldProto.name() );
1023 incoming.insert(
name );
1031 std::vector<wxString> toRemove;
1035 if( !field.IsMandatory() && !incoming.count( field.GetName(
false ) ) )
1036 toRemove.push_back( field.GetName(
false ) );
1039 for(
const wxString&
name : toRemove )
1042 if( aSymbol.has_show_pin_names() )
1045 if( aSymbol.has_show_pin_numbers() )
1048 if( aSymbol.has_pin_name_offset() )
1057 if( haveDefinition )
1063 m_pins.emplace_back( std::make_unique<SCH_PIN>( *
pin ) );
1064 m_pins.back()->SetParent(
this );
1072 if( pinAltMap.contains(
pin->m_Uuid ) )
1073 pin->SetAlt( pinAltMap.at(
pin->m_Uuid ) );
1083 return m_part ==
nullptr;
1093 const int min_grid_size =
schIUScale.MilsToIU( 25 );
1095 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1097 if( ( (
pin->GetPosition().x -
m_pos.x ) % min_grid_size ) != 0 )
1100 if( ( (
pin->GetPosition().y -
m_pos.y ) % min_grid_size ) != 0 )
1125 wxCHECK2( !aLibSymbol || aLibSymbol->
IsRoot(), aLibSymbol =
nullptr );
1127 m_part.reset( aLibSymbol );
1134 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1135 pin->SetLibPin(
nullptr );
1144 return m_part->GetDescription();
1146 return wxEmptyString;
1153 return m_part->GetShownDescription( aContext, aDepth );
1155 return wxEmptyString;
1162 return m_part->GetKeyWords();
1164 return wxEmptyString;
1171 return m_part->GetShownKeyWords( aContext, aDepth );
1173 return wxEmptyString;
1180 return m_part->GetDatasheetField().GetText();
1182 return wxEmptyString;
1189 screen->BumpConnectivityRevision();
1197 std::map<wxString, wxString> altPinMap;
1198 std::map<wxString, SCH_PIN::ALT> altPinDefs;
1199 std::map<wxString, std::vector<SCH_PIN*>> pinUuidMap;
1200 std::set<SCH_PIN*> unassignedSchPins;
1201 std::vector<SCH_PIN*> unassignedLibPins;
1203 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1206 pinUuidMap[
pin->GetNumber()].push_back(
pin.get() );
1208 unassignedSchPins.insert(
pin.get() );
1210 if( !
pin->GetAlt().IsEmpty() )
1212 altPinMap[
pin->GetNumber()] =
pin->GetAlt();
1213 auto altDefIt =
pin->GetAlternates().find(
pin->GetAlt() );
1215 if( altDefIt !=
pin->GetAlternates().end() )
1216 altPinDefs[
pin->GetNumber()] = altDefIt->second;
1219 pin->SetLibPin(
nullptr );
1233 auto ii = pinUuidMap.find( libPin->GetNumber() );
1235 if( ii == pinUuidMap.end() || ii->second.empty() )
1237 unassignedLibPins.push_back( libPin );
1241 auto it = ii->second.begin();
1243 ii->second.erase( it );
1244 pin->GetAlternates() = libPin->GetAlternates();
1245 pin->SetLibPin( libPin );
1246 pin->SetPosition( libPin->GetPosition() );
1247 pin->SetUnit( libPin->GetUnit() );
1248 pin->SetBodyStyle( libPin->GetBodyStyle() );
1250 unassignedSchPins.erase(
pin );
1252 auto iii = altPinMap.find( libPin->GetNumber() );
1254 if( iii != altPinMap.end() )
1256 wxString altName = iii->second;
1258 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
1260 auto defIt = altPinDefs.find( libPin->GetNumber() );
1262 if( defIt != altPinDefs.end() )
1264 for(
const auto& [
name, alt] :
pin->GetAlternates() )
1266 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
1275 pin->SetAlt( altName );
1282 size_t nextUnassigned = 0;
1284 for(
SCH_PIN* libPin : unassignedLibPins )
1289 if( !unassignedSchPins.empty() )
1291 while( nextUnassigned <
m_pins.size()
1292 && !unassignedSchPins.contains(
m_pins[nextUnassigned].get() ) )
1297 pin =
m_pins.at( nextUnassigned++ ).get();
1298 unassignedSchPins.erase(
pin );
1303 pin =
m_pins.emplace_back( std::make_unique<SCH_PIN>(
SCH_PIN(
this, libPin ) ) ).get();
1307 pin->GetAlternates() = libPin->GetAlternates();
1308 pin->SetLibPin( libPin );
1309 pin->SetPosition( libPin->GetPosition() );
1310 pin->SetUnit( libPin->GetUnit() );
1311 pin->SetBodyStyle( libPin->GetBodyStyle() );
1312 pin->SetNumber( libPin->GetNumber() );
1314 auto iii = altPinMap.find( libPin->GetNumber() );
1316 if( iii != altPinMap.end() )
1318 wxString altName = iii->second;
1320 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
1322 auto defIt = altPinDefs.find( libPin->GetNumber() );
1324 if( defIt != altPinDefs.end() )
1326 for(
const auto& [
name, alt] :
pin->GetAlternates() )
1328 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
1337 pin->SetAlt( altName );
1342 for(
auto it1 =
m_pins.begin(); it1 !=
m_pins.end() && !unassignedSchPins.empty(); )
1344 auto it2 = unassignedSchPins.find( it1->get() );
1346 if( it2 != unassignedSchPins.end() )
1348 it1 =
m_pins.erase( it1 );
1349 unassignedSchPins.erase( it2 );
1360 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1381 return m_part->GetUnitCount();
1390 return m_part->GetBodyStyleCount();
1399 return m_part->HasDeMorganBodyStyles();
1408 return m_part->GetUnitDisplayName( aUnit, aLabel );
1410 return wxString::Format(
_(
"Unit %s" ),
SubReference( aUnit ) );
1419 return m_part->GetBodyStyleDescription( aBodyStyle, aLabel );
1442 if( instance.m_Path.EndsWith( aSheetPath ) )
1444 aInstance = instance;
1466 size_t ii = indexIt->second;
1468 wxASSERT(
m_instances[ii].m_Path == aInstancePath );
1473 wxS(
"Removing symbol instance:\n"
1475 " reference %s, unit %d from symbol %s." ),
1517 wxS(
"Adding symbol '%s' instance:\n"
1518 " sheet path '%s'\n"
1547 wxLogTrace(
traceSchSymbolRef,
"GetRef for symbol %s on path %s (sheet path has %zu sheets)",
1572 wxLogTrace(
traceSchSymbolRef,
" Using fallback from REFERENCE field: %s", ref );
1597 if(
validator.DoValidate( aRef,
nullptr ) )
1612 const wxString previousPrefix =
m_prefix;
1614 bool changed =
false;
1617 changed = std::exchange(
m_instances[it->second].m_Reference, ref ) != ref;
1621 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1622 pin->ClearDefaultNetName( sheet );
1647 switch( aField->
GetId() )
1651 SetRef( aPath, aFieldText );
1656 wxString defaultText = aField->
GetText( aPath );
1658 if( aVariantName.IsEmpty() )
1660 if( aFieldText != defaultText )
1661 aField->
SetText( aFieldText );
1667 wxCHECK( instance, );
1673 const SCH_FIELD* altField = altSymbol->GetField( aFieldName );
1675 if( altField && !altField->
GetText().IsEmpty() )
1676 defaultText = altField->
GetText();
1679 bool changed =
false;
1681 if( instance->
m_Variants.contains( aVariantName ) )
1683 std::map<wxString, wxString>& fields = instance->
m_Variants[aVariantName].m_Fields;
1685 if( aFieldText != defaultText )
1687 auto [entry, inserted] = fields.try_emplace( aFieldName, aFieldText );
1688 changed = inserted || std::exchange( entry->second, aFieldText ) != aFieldText;
1692 changed = fields.erase( aFieldName ) != 0;
1695 else if( aFieldText != defaultText )
1700 newVariant.
m_Fields[aFieldName] = aFieldText;
1701 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
1716 const wxString& aVariantName )
1718 wxCHECK_MSG( !aFieldName.IsEmpty(), , wxT(
"Can't set text on a field with no name!" ) );
1722 wxCHECK_MSG( field, , wxT(
"Can't set text on a field not yet added to the symbol!" ) );
1724 SetFieldText( field, aFieldName, aFieldText, aPath, aVariantName );
1729 const wxString& aVariantName )
const
1731 switch( aField->
GetId() )
1734 wxCHECK( aPath, aField->
GetText() );
1735 return GetRef( aPath,
false );
1739 if( !aVariantName.IsEmpty() && aPath )
1743 if( instance && instance->
m_Variants.contains( aVariantName )
1744 && instance->
m_Variants.at( aVariantName ).m_Fields.contains( aFieldName ) )
1746 return instance->
m_Variants.at( aVariantName ).m_Fields.at( aFieldName );
1755 if( altField && !altField->
GetText().IsEmpty() )
1763 if( aVariantName.IsEmpty() )
1771 if( instance && instance->
m_Variants.contains( aVariantName ) )
1775 if( variant.
m_Fields.contains( aFieldName ) )
1776 return variant.
m_Fields.at( aFieldName );
1784 if( altField && !altField->
GetText().IsEmpty() )
1798 const wxString& aVariantName )
const
1800 wxCHECK_MSG( !aFieldName.IsEmpty(), wxEmptyString, wxT(
"Can't get text from a field with no name!" ) );
1804 wxCHECK_MSG( field, wxEmptyString, wxT(
"Can't get text from a field not yet added to the symbol!" ) );
1806 return GetFieldText( field, aFieldName, aPath, aVariantName );
1816 if( instance.m_Path ==
path )
1817 return !instance.m_Reference.IsEmpty() && instance.m_Reference.Last() !=
'?';
1828 refDesignator.Replace(
"~",
" " );
1830 wxString prefix = refDesignator;
1832 while( prefix.Length() )
1834 wxUniCharRef last = prefix.Last();
1836 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
1837 prefix.RemoveLast();
1843 prefix.Trim(
true );
1844 prefix.Trim(
false );
1846 if( !prefix.IsEmpty() )
1856 const std::map<int, wxString>& names =
m_part->GetUnitDisplayNames();
1857 auto it = names.find( aUnit );
1859 if( it != names.end() )
1865 int sep =
schematic->Settings().m_SubpartIdSeparator;
1867 if( sep != 0 && aAddSeparator )
1868 subRef << wxChar( sep );
1871 subRef << it->second;
1877 return schematic->Settings().SubReference( aUnit, aAddSeparator );
1902 if( std::exchange(
m_instances[it->second].m_Unit, aUnitSelection ) != aUnitSelection )
1916 bool* attribute = &( this->*aBase );
1918 if( aInstance && !aVariantName.IsEmpty() )
1922 wxCHECK_MSG( instance, ,
1923 wxString::Format( wxS(
"Cannot set attribute for invalid sheet path '%s'." ),
1926 auto it = instance->
m_Variants.find( aVariantName );
1930 if( aEnable == this->*aBase )
1935 newVariant.*aOverride = aEnable;
1940 attribute = &( it->second.*aOverride );
1943 if( *attribute == aEnable )
1946 *attribute = aEnable;
1959 if( !aInstance || aVariantName.IsEmpty() )
1967 if( instance.
m_Variants.contains( aVariantName ) )
1968 return instance.
m_Variants[aVariantName].m_DNP;
1975 const wxString& aVariantName )
1977 if( !aInstance || aVariantName.IsEmpty() )
1985 wxCHECK_MSG( instance, ,
1986 wxString::Format( wxS(
"Cannot set pin map override for invalid sheet path '%s'." ),
1989 if( instance->
m_Variants.contains( aVariantName ) )
1991 instance->
m_Variants[aVariantName].m_PinMapOverride = aOverride;
2010 for(
auto& [
name, variant] : instance.m_Variants )
2017 const wxString& aVariantName )
const
2021 if( aInstance && !aVariantName.IsEmpty() )
2030 if(
result.IsDelegate() && aInstance )
2038 const wxString& aVariantName )
const
2043 wxString ref =
GetRef( &aSheet );
2051 if( sibling ==
this || sibling->
GetUnit() != 1 )
2054 if( sibling->
GetRef( &sheet ).CmpNoCase( ref ) != 0 )
2080 if( !aInstance || aVariantName.IsEmpty() )
2088 if( instance.
m_Variants.contains( aVariantName ) )
2089 return instance.
m_Variants[aVariantName].m_ExcludedFromBOM;
2105 if( !aInstance || aVariantName.IsEmpty() )
2113 if( instance.
m_Variants.contains( aVariantName ) )
2114 return instance.
m_Variants[aVariantName].m_ExcludedFromSim;
2122 const wxString& aVariantName )
2130 const wxString& aVariantName )
const
2132 if( !aInstance || aVariantName.IsEmpty() )
2140 if( instance.
m_Variants.contains( aVariantName ) )
2141 return instance.
m_Variants[aVariantName].m_ExcludedFromBoard;
2149 const wxString& aVariantName )
2157 const wxString& aVariantName )
const
2159 if( !aInstance || aVariantName.IsEmpty() )
2167 if( instance.
m_Variants.contains( aVariantName ) )
2168 return instance.
m_Variants[aVariantName].m_ExcludedFromPosFiles;
2177 bool changed =
false;
2180 changed |= std::exchange( instance.m_Unit, aUnitSelection ) != aUnitSelection;
2188 const wxString& aVariantName )
const
2190 if( aVariantName.IsEmpty() || !aInstance )
2193 std::optional variant =
GetVariant( *aInstance, aVariantName );
2200 [&](
const wxString& aText ) -> wxString
2202 std::function<bool( wxString* )> resolver =
2203 [&]( wxString* token ) ->
bool
2211 if( variant->m_Fields.contains( fieldName ) )
2212 return resolve( variant->m_Fields[fieldName] );
2220 if( altField && !altField->
GetText().IsEmpty() )
2221 return resolve( altField->
GetText() );
2232 const wxString& aVariantName )
2234 if( !aInstance || aVariantName.IsEmpty() )
2242 wxCHECK( instance, );
2246 if( instance->
m_Variants.contains( aVariantName ) )
2248 instance->
m_Variants[aVariantName].m_Fields[fieldName] = aValue;
2255 newVariant.
m_Fields[fieldName] = aValue;
2256 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
2262 const wxString& aVariantName )
const
2280 m_fields.emplace_back(
this, aFieldType );
2309 if( !field.IsVisible() || field.GetText().IsEmpty() )
2313 aVector.push_back(
const_cast<SCH_FIELD*
>( &field ) );
2316 std::sort( aVector.begin(), aVector.end(),
2319 return lhs->GetOrdinal() < rhs->GetOrdinal();
2343 wxString fieldName = aFieldName;
2345 for(
unsigned ii = 0; ii <
m_fields.size(); ++ii )
2350 if( fieldName ==
m_fields[ii].GetName(
false ) )
2356 for(
auto& [
name, variant] : instance.m_Variants )
2357 variant.m_Fields.erase( fieldName );
2372 if( field.GetName().IsSameAs( aFieldName,
false ) )
2384 if( field.GetName().IsSameAs( aFieldName,
false ) )
2393 bool aResetRef,
bool aResetOtherFields )
2397 std::vector<SCH_FIELD*> fields;
2398 m_part->GetFields( fields );
2400 for(
const SCH_FIELD* libField : fields )
2405 if( libField->IsMandatory() )
2407 fieldType = libField->GetId();
2412 schField =
GetField( libField->GetUntranslatedName() );
2422 schField->
SetPrivate( libField->IsPrivate() );
2434 else if( aUpdateRef )
2435 SetRef( aPath, libField->GetText() );
2443 if( aResetOtherFields )
2445 else if( aUpdateOtherFields )
2446 schField->
SetText( libField->GetText() );
2450 if( aResetOtherFields || aUpdateOtherFields )
2451 schField->
SetText( libField->GetText() );
2461 bool updateValue =
true;
2462 bool updateExclFromBOM =
true;
2463 bool updateExclFromBoard =
true;
2464 bool updateExclFromPosFiles =
true;
2465 bool updateDNP =
true;
2466 bool updateOtherFields =
true;
2468 bool updatePinMapOverride =
true;
2472 updateValue = aProperty->
Name() ==
_HKI(
"Value" );
2473 updateExclFromBoard = aProperty->
Name() ==
_HKI(
"Exclude From Board" );
2474 updateExclFromBOM = aProperty->
Name() ==
_HKI(
"Exclude From Bill of Materials" );
2475 updateExclFromPosFiles = aProperty->
Name() ==
_HKI(
"Exclude From Position Files" );
2476 updateDNP = aProperty->
Name() ==
_HKI(
"Do not Populate" );
2477 updatePinMapOverride = aProperty->
Name() == wxS(
"Pin Map Mode" ) || aProperty->
Name() == wxS(
"Pin Map Name" );
2478 updateOtherFields =
false;
2482 if( !updateValue && !updateExclFromBOM && !updateExclFromBoard && !updateExclFromPosFiles && !updateDNP
2483 && !updateOtherFields && !
updatePins && !updatePinMapOverride )
2492 wxString ref =
GetRef( &aSourceSheet );
2497 std::vector<SCH_SYMBOL*> otherUnits;
2503 aCommit.
Modify( otherUnit, screen );
2509 &sheet, aVariantName );
2512 if( updateOtherFields )
2524 if( field.IsMandatory() )
2525 otherField = otherUnit->GetField( field.GetId() );
2527 otherField = otherUnit->GetField( field.GetName() );
2531 otherField->
SetText( field.GetText( &aSourceSheet, aVariantName ), &sheet, aVariantName );
2539 newField.
Offset( otherUnit->GetPosition() );
2542 SCH_FIELD* addedField = otherUnit->AddField( newField );
2544 if( !aVariantName.IsEmpty() )
2546 addedField->
SetText( field.GetText( &aSourceSheet, aVariantName ), &sheet,
2552 for(
int ii = (
int) otherUnit->GetFields().size() - 1; ii >= 0; ii-- )
2554 SCH_FIELD& otherField = otherUnit->GetFields()[ii];
2557 otherUnit->RemoveField( otherField.
GetName() );
2561 if( updateExclFromBOM )
2563 otherUnit->SetExcludedFromBOM(
GetExcludedFromBOM( &aSourceSheet, aVariantName ), &sheet,
2567 if( updateExclFromBoard )
2573 if( updateExclFromPosFiles )
2580 otherUnit->SetDNP(
GetDNP( &aSourceSheet, aVariantName ), &sheet, aVariantName );
2582 if( updatePinMapOverride )
2583 otherUnit->SetPinMapOverride(
GetPinMapOverride( &aSourceSheet, aVariantName ), &sheet,
2588 for(
const std::unique_ptr<SCH_PIN>& model_pin :
m_pins )
2590 for(
SCH_PIN* src_pin : otherUnit->GetPinsByNumber( model_pin->GetNumber() ) )
2591 src_pin->SetAlt( model_pin->GetAlt() );
2602 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2603 aFunction(
pin.get() );
2606 aFunction( &field );
2619 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2621 if(
pin->GetNumber() == aNumber )
2630 const wxString& aVariantName )
const
2635 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2639 if(
pad == aPadNumber )
2650 std::vector<SCH_PIN*> pins;
2652 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2654 if(
pin->GetNumber() == aNumber )
2655 pins.push_back(
pin.get() );
2664 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2666 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
2667 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
2675 if(
pin->GetPosition() == aPos )
2688 return std::vector<SCH_PIN*>();
2697 return std::vector<SCH_PIN*>();
2709 auto it =
m_pinMap.find( aLibPin );
2714 wxFAIL_MSG_AT(
"Pin not found", __FILE__, __LINE__, __FUNCTION__ );
2721 std::vector<const SCH_PIN*> pins;
2730 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2735 pins.push_back(
pin.get() );
2744 std::vector<SCH_PIN*> pins;
2753 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2758 pins.push_back(
pin.get() );
2767 std::vector<SCH_PIN*> pins;
2769 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2774 &&
pin->GetUnit() != aUnit )
2782 &&
pin->GetBodyStyle() != aBodyStyle )
2787 pins.push_back(
pin.get() );
2796 wxCHECK_RET( aItem !=
nullptr && aItem->
Type() ==
SCH_SYMBOL_T, wxT(
"Cannot swap data with invalid symbol." ) );
2807 for( std::unique_ptr<SCH_PIN>&
pin : symbol->
m_pins )
2808 pin->SetParent( symbol );
2810 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2811 pin->SetParent(
this );
2817 m_part.reset( libSymbol );
2861 if( field.IsPrivate() )
2864 if( field.IsMandatory() )
2865 aVars->push_back( field.GetUntranslatedName().Upper() );
2867 aVars->push_back( field.GetName() );
2870 aVars->push_back( wxT(
"OP" ) );
2871 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
2872 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
2873 aVars->push_back( wxT(
"UNIT" ) );
2874 aVars->push_back( wxT(
"SHORT_REFERENCE" ) );
2875 aVars->push_back( wxT(
"SYMBOL_LIBRARY" ) );
2876 aVars->push_back( wxT(
"SYMBOL_NAME" ) );
2877 aVars->push_back( wxT(
"SYMBOL_DESCRIPTION" ) );
2878 aVars->push_back( wxT(
"SYMBOL_KEYWORDS" ) );
2879 aVars->push_back( wxT(
"SYMBOL_IS_POWER" ) );
2880 aVars->push_back( wxT(
"SYMBOL_IS_LOCAL_POWER" ) );
2881 aVars->push_back( wxT(
"EXCLUDE_FROM_BOM" ) );
2882 aVars->push_back( wxT(
"EXCLUDE_FROM_BOARD" ) );
2883 aVars->push_back( wxT(
"EXCLUDE_FROM_SIM" ) );
2884 aVars->push_back( wxT(
"DNP" ) );
2885 aVars->push_back( wxT(
"SHORT_NET_NAME(<pin_number>)" ) );
2886 aVars->push_back( wxT(
"NET_NAME(<pin_number>)" ) );
2887 aVars->push_back( wxT(
"NET_CLASS(<pin_number>)" ) );
2888 aVars->push_back( wxT(
"PIN_NAME(<pin_number>)" ) );
2889 aVars->push_back( wxT(
"REFERENCE(<pin_number>)" ) );
2890 aVars->push_back( wxT(
"SHORT_REFERENCE(<pin_number>)" ) );
2891 aVars->push_back( wxT(
"UNIT(<pin_number>)" ) );
2911 thread_local wxRegEx operatingPoint( wxT(
"^"
2927 && ( operatingPoint.Matches( *token ) || token->StartsWith( wxS(
"NET_NAME(" ) )
2928 || token->StartsWith( wxS(
"SHORT_NET_NAME(" ) ) || token->StartsWith( wxS(
"NET_CLASS(" ) ) ) )
2934 if( operatingPoint.Matches( *token ) )
2936 wxString
pin( operatingPoint.GetMatch( *token, 1 ).Lower() );
2937 wxString precisionStr( operatingPoint.GetMatch( *token, 3 ) );
2938 wxString rangeStr( operatingPoint.GetMatch( *token, 4 ) );
2940 int precision = precisionStr.IsEmpty() ? 3 : precisionStr[0] -
'0';
2941 wxString range = rangeStr.IsEmpty() ? wxString( wxS(
"~A" ) ) : rangeStr;
2945 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
2946 embeddedFilesStack.push_back(
schematic->GetEmbeddedFiles() );
2949 embeddedFilesStack.push_back(
m_part->GetEmbeddedFiles() );
2955 aVariantName, devnull ).model;
2959 wxString spiceRef =
model.SpiceGenerator().ItemName( spiceItem );
2960 spiceRef = spiceRef.Lower();
2964 *token =
schematic->GetOperatingPoint( spiceRef, precision, range );
2967 else if(
pin == wxS(
":power" ) )
2969 if( rangeStr.IsEmpty() )
2970 range = wxS(
"~W" );
2972 *token =
schematic->GetOperatingPoint( spiceRef + wxS(
":power" ), precision, range );
2977 pin =
pin.SubString( 1, -1 );
2979 for(
const std::reference_wrapper<const SIM_MODEL_PIN>& modelPin :
model.GetPins() )
2981 SCH_PIN* symbolPin =
GetPin( modelPin.get().symbolPinNumber );
2988 if(
model.GetPins().size() == 2 )
2990 *token =
schematic->GetOperatingPoint( spiceRef, precision, range );
2994 wxString netChainName = spiceRef + wxS(
":" ) + modelPin.get().modelPinName;
2995 *token =
schematic->GetOperatingPoint( netChainName, precision, range );
3003 *token = wxS(
"?" );
3007 if( token->Contains(
':' ) )
3009 if(
schematic->ResolveCrossReference( token, aDepth + 1 ) )
3015 wxString fieldName = field.IsMandatory() ? field.GetUntranslatedName() : field.GetName();
3017 wxString textToken = field.GetText();
3018 textToken.Replace(
" ", wxEmptyString );
3019 wxString tokenString =
"${" + fieldName +
"}";
3022 if( textToken.IsSameAs( tokenString,
false ) )
3025 if( token->IsSameAs( fieldName,
false ) )
3028 *token =
GetRef( aPath,
true );
3030 *token = field.GetShownText( aPath,
INTERNAL, aVariantName, aDepth + 1 );
3037 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
3038 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
3039 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
3041 *token = wxEmptyString;
3046 schematic->Project().GetProjectFile().m_TemplateFieldNames.GetResolvedTemplateFieldNames() )
3048 if( token->IsSameAs( templateFieldname.m_Name ) || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
3052 *token = wxEmptyString;
3057 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
3061 wxArrayString parts = wxSplit( footprint,
':' );
3063 if( parts.Count() > 0 )
3066 *token = wxEmptyString;
3070 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
3074 wxArrayString parts = wxSplit( footprint,
':' );
3076 if( parts.Count() > 1 )
3077 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
3079 *token = wxEmptyString;
3083 else if( token->IsSameAs( wxT(
"UNIT" ) ) )
3088 else if( token->IsSameAs( wxT(
"SHORT_REFERENCE" ) ) )
3090 *token =
GetRef( aPath,
false );
3093 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
3095 *token =
m_lib_id.GetUniStringLibNickname();
3098 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
3100 *token =
m_lib_id.GetUniStringLibItemName();
3103 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
3108 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
3113 else if( token->IsSameAs( wxT(
"SYMBOL_IS_POWER" ) ) )
3115 *token = this->
IsPower() ? wxString( wxS(
"Power Symbol" ) ) : wxString(
"" );
3118 else if( token->IsSameAs( wxT(
"SYMBOL_IS_LOCAL_POWER" ) ) )
3120 *token = this->
IsLocalPower() ? wxString( wxS(
"Local Power Symbol" ) ) : wxString(
"" );
3123 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
3125 *token = wxEmptyString;
3127 if( aPath->
GetExcludedFromBOM( aVariantName ) || this->ResolveExcludedFromBOM( aPath, aVariantName ) )
3128 *token = wxS(
"Excluded from BOM" );
3132 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
3134 *token = wxEmptyString;
3136 if( aPath->
GetExcludedFromBoard( aVariantName ) || this->ResolveExcludedFromBoard( aPath, aVariantName ) )
3137 *token = wxS(
"Excluded from board" );
3141 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
3143 *token = wxEmptyString;
3145 if( aPath->
GetExcludedFromSim( aVariantName ) || this->ResolveExcludedFromSim( aPath, aVariantName ) )
3146 *token = wxS(
"Excluded from simulation" );
3150 else if( token->IsSameAs( wxT(
"DNP" ) ) )
3152 *token = wxEmptyString;
3154 if( aPath->
GetDNP( aVariantName ) || this->ResolveDNP( aPath, aVariantName ) )
3155 *token = wxS(
"DNP" );
3159 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) ) || token->StartsWith( wxT(
"NET_NAME(" ) )
3160 || token->StartsWith( wxT(
"NET_CLASS(" ) ) || token->StartsWith( wxT(
"PIN_NAME(" ) )
3161 || token->StartsWith( wxT(
"PIN_BASE_NAME(" ) ) || token->StartsWith( wxT(
"PIN_ALT_LIST(" ) )
3162 || token->StartsWith( wxT(
"REFERENCE(" ) ) || token->StartsWith( wxT(
"SHORT_REFERENCE(" ) )
3163 || token->StartsWith( wxT(
"UNIT(" ) ) )
3165 wxString pinNumber = token->AfterFirst(
'(' );
3166 pinNumber = pinNumber.BeforeLast(
')' );
3168 auto resolvePinConnection =
3171 const bool local = token->StartsWith( wxS(
"SHORT_NET_NAME" ) );
3172 const std::optional<wxString>
name =
pin.GetConnectionName( &
path, local );
3181 *token =
name->Lower().StartsWith( wxS(
"unconnected" ) ) ? wxString(
"NC" ) : *
name;
3182 else if( token->StartsWith( wxS(
"NET_NAME" ) ) )
3184 else if( token->StartsWith( wxS(
"NET_CLASS" ) ) )
3185 *token =
pin.GetEffectiveNetClass( &
path )->GetName();
3188 bool isReferenceFunction = token->StartsWith( wxT(
"REFERENCE(" ) );
3189 bool isShortReferenceFunction = token->StartsWith( wxT(
"SHORT_REFERENCE(" ) );
3190 bool isUnitFunction = token->StartsWith( wxT(
"UNIT(" ) );
3194 std::vector<const SCH_PIN*> pinsToSearch;
3195 std::vector<const SCH_PIN*> altPinsToSearch;
3197 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
3200 pinsToSearch.push_back(
pin );
3205 pinsToSearch.push_back(
pin );
3208 altPinsToSearch.push_back(
pin );
3213 if(
pin->GetNumber() == pinNumber )
3215 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
3217 int pinUnit =
pin->GetUnit();
3220 if( isReferenceFunction )
3228 else if( isShortReferenceFunction )
3233 else if( isUnitFunction )
3242 *token = std::move(
result );
3245 else if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
3247 *token =
pin->GetAlt().IsEmpty() ?
pin->GetName() :
pin->GetAlt();
3250 else if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
3252 *token =
pin->GetBaseName();
3255 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
3260 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
3262 for(
const auto& [altName, altDef] : alts )
3264 if( !altList.IsEmpty() )
3265 altList += wxT(
", " );
3270 *token = std::move( altList );
3274 resolvePinConnection( *
pin, *aPath );
3283 if(
pin->GetNumber() == pinNumber )
3286 if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
3288 *token =
pin->GetBaseName();
3291 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
3296 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
3298 for(
const auto& [altName, altDef] : alts )
3300 if( !altList.IsEmpty() )
3301 altList += wxT(
", " );
3310 int pinUnit =
pin->GetUnit();
3326 if( symbol->
GetRef( &sheetPath,
false ) ==
GetRef( aPath,
false )
3329 targetPath = sheetPath;
3330 targetSymbol = symbol;
3343 *token = wxString::Format( wxT(
"<Unit %s not placed>" ),
SubReference( pinUnit,
false ) );
3349 SCH_PIN* instancePin =
nullptr;
3353 if( candidate->GetNumber() == pinNumber )
3355 instancePin = candidate;
3362 *token = wxEmptyString;
3367 if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
3369 *token = instancePin->
GetAlt().IsEmpty() ? instancePin->
GetName() : instancePin->
GetAlt();
3373 resolvePinConnection( *instancePin, targetPath );
3380 *token = wxString::Format( wxT(
"<Unresolved: pin %s>" ), pinNumber );
3384 else if( token->StartsWith( wxS(
"PROPERTY." ) ) )
3387 wxString propertyName = token->AfterFirst(
'.' );
3388 propertyName.Replace( wxS(
"_" ), wxS(
" " ) );
3398 if( propertyName.CmpNoCase( candidate->Name() ) == 0 )
3400 property = candidate;
3406 if( !property || property->IsHiddenFromPropertiesManager() )
3414 const wxString&
name =
property->Name();
3416 if(
name == wxS(
"Reference" ) )
3417 sourceValue =
GetRef( aPath );
3418 else if(
name == wxS(
"Value" ) )
3420 else if(
name == wxS(
"Unit" ) )
3422 else if(
name == wxS(
"Exclude From Simulation" ) )
3424 else if(
name == wxS(
"Exclude From Bill of Materials" ) )
3426 else if(
name == wxS(
"Exclude From Board" ) )
3428 else if(
name == wxS(
"Exclude From Position Files" ) )
3430 else if(
name == wxS(
"Do not Populate" ) )
3431 sourceValue =
GetDNP( aPath, aVariantName );
3433 sourceValue = instanceProperty->ValueForInstance(
this, aPath, aVariantName );
3435 sourceValue =
Get( property );
3462 if( instance.m_Path ==
path )
3464 if( instance.m_Reference.IsEmpty() || aResetPrefix )
3475 if( instance.m_Reference.IsEmpty() || aResetPrefix )
3482 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3483 pin->ClearDefaultNetName( aSheetPath );
3493 if( currentReference.IsEmpty() || aResetPrefix )
3504 wxCHECK( aSheetPath.size() > 0,
false );
3509 if( instance.m_Path == aSheetPath )
3534 bool transform =
false;
3536 switch( aOrientation )
3657 wxFAIL_MSG(
"Invalid schematic symbol orientation type." );
3711 for(
int type_rotate : rotate_values )
3723 wxFAIL_MSG(
"Schematic symbol orientation matrix internal error." );
3731void SCH_SYMBOL::Show(
int nestLevel, std::ostream& os )
const
3734 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
" ref=\""
3740 for(
int i = 1; i < (int)
GetFields().size(); ++i )
3742 const wxString& value =
GetFields()[i].GetText();
3744 if( !value.IsEmpty() )
3746 NestedSpace( nestLevel + 1, os ) <<
"<field" <<
" name=\"" <<
TO_UTF8(
GetFields()[i].GetName() ) <<
'"'
3747 <<
" value=\"" <<
TO_UTF8( value ) <<
"\"/>\n";
3751 NestedSpace( nestLevel, os ) <<
"</" <<
TO_UTF8(
GetClass().Lower() ) <<
">\n";
3773 if( aIncludeFields )
3777 if( field.IsVisible() )
3778 bBox.
Merge( field.GetBoundingBox() );
3792 catch(
const boost::bad_pointer& e )
3794 wxFAIL_MSG( wxString::Format( wxT(
"Boost pointer exception occurred: %s" ), e.what() ) );
3826 msgs.Add(
_(
"Simulation" ) );
3829 msgs.Add(
_(
"BOM" ) );
3832 msgs.Add(
_(
"Board" ) );
3834 if(
GetDNP( currentSheet, currentVariant ) )
3835 msgs.Add(
_(
"DNP" ) );
3837 msg = wxJoin( msgs,
'|' );
3838 msg.Replace(
'|', wxS(
", " ) );
3841 aList.emplace_back(
_(
"Exclude from" ), msg );
3852 aList.emplace_back(
_(
"Power symbol" ),
3860 aList.emplace_back(
_(
"Value" ),
3867 aList.emplace_back(
_(
"flags" ), wxString::Format(
"%X",
GetEditFlags() ) );
3872 msg =
_(
"Missing parent" );
3874 std::shared_ptr<LIB_SYMBOL> parent =
m_part->GetParent().lock();
3877 msg = parent->GetName();
3881 else if( !
m_lib_id.GetLibNickname().empty() )
3883 aList.emplace_back(
_(
"Library" ),
m_lib_id.GetLibNickname() );
3887 aList.emplace_back(
_(
"Library" ),
_(
"Undefined!!!" ) );
3895 msg =
_(
"<Unknown>" );
3897 aList.emplace_back(
_(
"Footprint" ), msg );
3901 _(
"Keywords" ) + wxT(
": " ) +
m_part->GetKeyWords() );
3906 aList.emplace_back(
_(
"Reference" ),
GetRef( currentSheet ) );
3915 if( libNickname.empty() )
3916 msg =
_(
"No library defined!" );
3918 msg.Printf(
_(
"Symbol not found in %s!" ), libNickname );
3920 aList.emplace_back(
_(
"Library" ), msg );
3934 return libSymbol->GetEmbeddedFiles();
3953 field.SetTextPos( pos );
3971 field.SetTextPos( pos );
3990 field.SetTextPos( pos );
4012 if(
const std::unique_ptr<LIB_SYMBOL>& libSymbol =
GetLibSymbolRef() )
4014 for(
const SCH_ITEM& drawItem : libSymbol->GetDrawItems() )
4019 if( drawItem.Matches( aSearchData, aAuxData ) )
4031 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4039 aItemList.push_back( item );
4046 std::vector<DANGLING_END_ITEM>& aItemListByPos,
const SCH_SHEET_PATH* aPath )
4048 bool changed =
false;
4050 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4052 bool previousState =
pin->IsDangling();
4053 pin->SetIsDangling(
true );
4058 bool do_break =
false;
4060 for(
auto it = lower; it < aItemListByPos.end() && it->GetPosition() == pos; it++ )
4079 pin->SetIsDangling(
false );
4090 changed = ( changed || ( previousState !=
pin->IsDangling() ) );
4115 wxCHECK( symbol,
false );
4121 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4123 if(
pin->IsDangling() )
4139 if(
GetRef( aInstance ) != symbol->
GetRef( aInstance ) )
4152 for(
size_t i = 0; i <
m_pins.size(); i++ )
4164 std::vector<VECTOR2I> retval;
4166 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4170 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
4171 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
4191 if( effectiveSymbol )
4205 return wxString::Format(
_(
"Symbol %s [%s]" ),
4213 for(
KICAD_T scanType : aScanTypes )
4258 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4262 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
4263 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
4324 std::vector<SCH_FIELD*> fields, otherFields;
4327 aSymbol.
GetFields( otherFields,
false );
4329 if( fields.size() != otherFields.size() )
4332 for(
int ii = 0; ii < (int) fields.size(); ii++ )
4337 if( fields[ii]->GetText().Cmp( otherFields[ii]->GetText() ) != 0 )
4356 std::set<SCH_PIN*, SCH_SYMBOL::cmp_pins> sortedPins;
4357 std::set<SCH_PIN*, SCH_SYMBOL::cmp_pins> sortedOtherPins;
4359 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4360 sortedPins.insert(
pin.get() );
4362 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol.
m_pins )
4363 sortedOtherPins.insert(
pin.get() );
4365 if( sortedPins.size() != sortedOtherPins.size() )
4368 for(
auto aIt = sortedPins.begin(), bIt = sortedOtherPins.begin(); aIt != sortedPins.end(); ++aIt, ++bIt )
4370 if( !( *aIt )->operator==( *( *bIt ) ) )
4380 return !( *
this == aSymbol );
4386 wxCHECK_MSG(
Type() == aSymbol.
Type(), *
this,
4387 wxT(
"Cannot assign object type " ) + aSymbol.
GetClass() + wxT(
" to type " ) +
GetClass() );
4389 if( &aSymbol !=
this )
4398 auto oldPart = std::exchange(
m_part, aSymbol.
m_part ? std::make_unique<LIB_SYMBOL>( *aSymbol.
m_part )
4417 field.SetParent(
this );
4431 bBox.
Inflate( aAccuracy / 2 );
4447 rect.
Inflate( aAccuracy / 2 );
4469 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4482 if(
pin->GetLocalPosition() == new_pos )
4497 const VECTOR2I& aOffset,
bool aDimmed )
4507 bool usingAlternate = ( effectiveSym !=
m_part.get() );
4514 std::vector<SCH_PIN*> symbolPins =
MapLibPins( libPins, usingAlternate );
4517 for(
unsigned i = 0; i < tempPins.size(); ++i )
4519 SCH_PIN* symbolPin = symbolPins[i];
4520 SCH_PIN* tempPin = tempPins[i];
4550 bool dnp =
GetDNP( sheet, variant );
4552 for(
bool local_background : {
true,
false } )
4558 field.ClearRenderCache();
4563 && ( field.IsVisible() || field.IsForceVisible() )
4564 && !local_background )
4577 std::vector<wxString> properties;
4581 wxString text_field = field.GetShownText( sheet,
FOR_GUI, variant );
4583 if( text_field.IsEmpty() )
4586 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ), field.GetName(), text_field ) );
4591 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ),
4602 if( !effectiveSym->
IsPower() )
4616 margins.
x = std::max( margins.
x * 0.6, margins.
y * 0.3 );
4617 margins.
y = std::max( margins.
y * 0.6, margins.
x * 0.3 );
4635 double lineWidth = aSize / 10.0;
4637 std::vector<SCH_SHAPE> shapeList;
4639 int tolerance = 100;
4641 for(
const SCH_SHAPE& shape : shapeList )
4648 aPlotter->
BezierCurve( shape.GetStart(), shape.GetBezierC1(), shape.GetBezierC2(), shape.GetEnd(),
4649 tolerance, lineWidth );
4653 aPlotter->
Circle( shape.getCenter(), shape.GetRadius() * 2, filled, lineWidth );
4704 bool usingAlternate = ( effectiveSym !=
m_part.get() );
4715 std::vector<SCH_PIN*> symbolPins =
MapLibPins( libPins, usingAlternate );
4719 for(
unsigned i = 0; i < tempPins.size(); ++i )
4721 SCH_PIN* symbolPin = symbolPins[i];
4722 SCH_PIN* tempPin = tempPins[i];
4740 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4742 if(
pin->IsBrightened() )
4752 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4753 pin->ClearBrightened();
4771 m_part->SetShowPinNames( aShow );
4784 m_part->SetShowPinNumbers( aShow );
4790 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
4792 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
4793 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
4801 if(
pin->IsPointClickableAnchor( aPos ) )
4820 if( pin_list.size() != 1 )
4838 if( pin_list.size() != 1 )
4850 return m_part->IsLocalPower();
4859 return m_part->IsGlobalPower();
4871 m_part->SetGlobalPower();
4883 wxCHECK(
m_part,
false );
4885 return m_part->IsNormal();
4890 const wxString& aVariantName )
const
4892 std::unordered_set<wxString> componentClass;
4894 auto getComponentClassFields =
4895 [&](
const std::vector<SCH_FIELD>& fields )
4899 if( field.GetUntranslatedName() == wxT(
"Component Class" ) )
4901 if( field.GetShownText( aPath,
INTERNAL ) != wxEmptyString )
4902 componentClass.insert( field.GetShownText( aPath,
INTERNAL, aVariantName ) );
4908 getComponentClassFields(
m_fields );
4915 getComponentClassFields( label->GetFields() );
4919 return componentClass;
4924 const wxString& aVariantName )
const
4929 return std::nullopt;
4931 return instance.
m_Variants.find( aVariantName )->second;
4943 if( instance->
m_Variants.insert( std::make_pair( aVariant.
m_Name, aVariant ) ).second )
4951 if( aVariantName.IsEmpty() )
4956 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
4965 wxString libIdStr = libId.
Format();
4974 return cacheIt->second.get();
4982 std::unique_ptr<LIB_SYMBOL> resolved;
4989 if(
auto it = libSymbols.find( libIdStr ); it != libSymbols.end() && it->second )
4990 resolved = it->second->Flatten();
5009 cached = std::move( resolved );
5017 return cached.get();
5023 std::vector<LIB_ID> overrides;
5027 for(
const auto& [
name, variant] : instance.m_Variants )
5029 if( variant.m_SymbolOverride
5030 && std::find( overrides.begin(), overrides.end(), *variant.m_SymbolOverride ) == overrides.end() )
5032 overrides.push_back( *variant.m_SymbolOverride );
5061 return libSymbol->Flatten();
5077 if( !variantName.IsEmpty() )
5092 std::vector<SCH_PIN*> mapped;
5094 mapped.reserve( aLibPins.size() );
5102 mapped.resize( aLibPins.size(),
nullptr );
5107 std::vector<bool> matched( basePins.size(),
false );
5109 for(
const SCH_PIN* alternatePin : aLibPins )
5111 SCH_PIN* instancePin =
nullptr;
5113 for(
size_t i = 0; i < basePins.size(); ++i )
5119 instancePin =
GetPin(
const_cast<SCH_PIN*
>( basePins[i] ) );
5123 mapped.push_back( instancePin );
5128 for(
const SCH_PIN* libPin : aLibPins )
5129 mapped.push_back(
GetPin(
const_cast<SCH_PIN*
>( libPin ) ) );
5141 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
5151 const wxString& aFieldName )
5155 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
5158 if( instance->
m_Variants[aVariantName].m_Fields.erase( aFieldName ) )
5164 const wxString& aNewName )
5169 if( aOldName == aNewName || !instance || !instance->
m_Variants.contains( aOldName ) )
5174 variant.
m_Name = aNewName;
5176 instance->
m_Variants.insert( std::make_pair( aNewName, variant ) );
5183 const wxString& aNewVariant )
5188 if( !instance || !instance->
m_Variants.contains( aSourceVariant ) )
5193 variant.
m_Name = aNewVariant;
5195 if( instance->
m_Variants.insert( std::make_pair( aNewVariant, variant ) ).second )
5201 const wxString& aVariantName,
5209 if( !instance->
m_Variants.contains( aVariantName ) )
5213 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
5216 const bool changed = std::exchange( instance->
m_Variants[aVariantName].m_SymbolOverride, aLibId ) != aLibId;
5225 const wxString& aVariantName )
5229 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
5292 for(
unsigned i = 0; i <
m_pins.size(); ++i )
5301 if( m_instanceReferences != symbol.m_instanceReferences )
5327 double aLineWidth,
bool aHorizontal )
5331 double x_right = aSize / 1.6180339887;
5332 double x_middle = x_right / 2.0;
5345 aShapeList.back().SetStart( bottomPt );
5346 aShapeList.back().SetBezierC1( bottomAnchorPt );
5347 aShapeList.back().SetBezierC2( leftSideAnchorPt1 );
5348 aShapeList.back().SetEnd( leftPt );
5352 aShapeList.back().SetStart( leftPt );
5353 aShapeList.back().SetBezierC1( leftSideAnchorPt2 );
5354 aShapeList.back().SetBezierC2( rightSideAnchorPt2 );
5355 aShapeList.back().SetEnd( rightPt );
5358 aShapeList.back().SetStart( rightPt );
5359 aShapeList.back().SetBezierC1( rightSideAnchorPt1 );
5360 aShapeList.back().SetBezierC2( bottomAnchorPt );
5361 aShapeList.back().SetEnd( bottomPt );
5364 aShapeList.back().SetCenter( ( leftPt + rightPt ) / 2.0 );
5365 aShapeList.back().SetRadius( aSize / 15.0 );
5370 shape.Rotate(
VECTOR2I( 0, 0 ),
true );
5429 return symbol->GetLibSymbolRef() !=
nullptr;
5442 const wxString groupFields =
_HKI(
"Fields" );
5464 return symbol->IsMultiUnit();
5469 auto multiBodyStyle =
5473 return symbol->IsMultiBodyStyle();
5484 wxPGChoices choices;
5488 for(
int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
5489 choices.Add( symbol->GetUnitDisplayName( ii,
false ), ii );
5501 wxPGChoices choices;
5505 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
5506 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
5518 return symbol->IsPower();
5523 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)
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)
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
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)
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.
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
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 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...
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 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)
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::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.
#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