59 std::string ret =
TO_UTF8( txt );
63 if( (
unsigned char) c <=
' ' )
88 std::unique_ptr<LIB_SYMBOL> part;
116 SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.
Convert, aPosition, aParent )
119 for(
const auto& [fieldId, fieldValue] : aSel.
Fields )
121 if( fieldId == FIELD_T::REFERENCE )
122 SetRef( aSheet, fieldValue );
123 else if( SCH_FIELD* field = GetField( fieldId ) )
124 field->SetText( fieldValue );
149 field.SetParent(
this );
154 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol.
m_pins )
156 m_pins.emplace_back( std::make_unique<SCH_PIN>( *pin ) );
157 m_pins.back()->SetParent( this );
220 const int min_grid_size =
schIUScale.MilsToIU( 25 );
222 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
224 if( ( (
pin->GetPosition().x -
m_pos.x ) % min_grid_size ) != 0 )
227 if( ( (
pin->GetPosition().y -
m_pos.y ) % min_grid_size ) != 0 )
252 wxCHECK2( !aLibSymbol || aLibSymbol->
IsRoot(), aLibSymbol =
nullptr );
254 m_part.reset( aLibSymbol );
259 pin->SetLibPin(
nullptr );
268 return m_part->GetDescription();
270 return wxEmptyString;
277 return m_part->GetShownDescription( aDepth );
279 return wxEmptyString;
286 return m_part->GetKeyWords();
288 return wxEmptyString;
295 return m_part->GetShownKeyWords( aDepth );
297 return wxEmptyString;
304 return m_part->GetDatasheetField().GetText();
306 return wxEmptyString;
312 std::map<wxString, wxString> altPinMap;
313 std::map<wxString, SCH_PIN::ALT> altPinDefs;
314 std::map<wxString, std::set<SCH_PIN*>> pinUuidMap;
315 std::set<SCH_PIN*> unassignedSchPins;
316 std::set<SCH_PIN*> unassignedLibPins;
318 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
320 pinUuidMap[
pin->GetNumber()].insert(
pin.get() );
322 unassignedSchPins.insert(
pin.get() );
324 if( !
pin->GetAlt().IsEmpty() )
326 altPinMap[
pin->GetNumber()] =
pin->GetAlt();
327 auto altDefIt =
pin->GetAlternates().find(
pin->GetAlt() );
329 if( altDefIt !=
pin->GetAlternates().end() )
330 altPinDefs[
pin->GetNumber()] = altDefIt->second;
333 pin->SetLibPin(
nullptr );
350 auto ii = pinUuidMap.find( libPin->GetNumber() );
352 if( ii == pinUuidMap.end() || ii->second.empty() )
354 unassignedLibPins.insert( libPin );
358 auto it = ii->second.begin();
360 ii->second.erase( it );
361 pin->GetAlternates() = libPin->GetAlternates();
362 pin->SetLibPin( libPin );
363 pin->SetPosition( libPin->GetPosition() );
364 pin->SetUnit( libPin->GetUnit() );
365 pin->SetBodyStyle( libPin->GetBodyStyle() );
367 unassignedSchPins.erase(
pin );
369 auto iii = altPinMap.find( libPin->GetNumber() );
371 if( iii != altPinMap.end() )
373 wxString altName = iii->second;
375 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
377 auto defIt = altPinDefs.find( libPin->GetNumber() );
379 if( defIt != altPinDefs.end() )
381 for(
const auto& [
name, alt] :
pin->GetAlternates() )
383 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
392 pin->SetAlt( altName );
399 for(
SCH_PIN* libPin : unassignedLibPins )
404 if( !unassignedSchPins.empty() )
406 auto it = unassignedSchPins.begin();
408 unassignedSchPins.erase( it );
413 pin =
m_pins.emplace_back( std::make_unique<SCH_PIN>(
SCH_PIN(
this, libPin ) ) ).get();
417 pin->GetAlternates() = libPin->GetAlternates();
418 pin->SetLibPin( libPin );
419 pin->SetPosition( libPin->GetPosition() );
420 pin->SetUnit( libPin->GetUnit() );
421 pin->SetBodyStyle( libPin->GetBodyStyle() );
422 pin->SetNumber( libPin->GetNumber() );
424 auto iii = altPinMap.find( libPin->GetNumber() );
426 if( iii != altPinMap.end() )
428 wxString altName = iii->second;
430 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
432 auto defIt = altPinDefs.find( libPin->GetNumber() );
434 if( defIt != altPinDefs.end() )
436 for(
const auto& [
name, alt] :
pin->GetAlternates() )
438 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
447 pin->SetAlt( altName );
452 for(
auto it1 =
m_pins.begin(); it1 !=
m_pins.end() && !unassignedSchPins.empty(); )
454 auto it2 = unassignedSchPins.find( it1->get() );
456 if( it2 != unassignedSchPins.end() )
458 it1 =
m_pins.erase( it1 );
459 unassignedSchPins.erase( it2 );
470 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
491 return m_part->GetUnitCount();
500 return m_part->GetBodyStyleCount();
509 return m_part->HasDeMorganBodyStyles();
518 return m_part->GetUnitDisplayName( aUnit, aLabel );
520 return wxString::Format(
_(
"Unit %s" ),
SubReference( aUnit ) );
529 return m_part->GetBodyStyleDescription( aBodyStyle, aLabel );
541 if( instance.m_Path == aSheetPath )
543 aInstance = instance;
547 else if( instance.m_Path.EndsWith( aSheetPath ) )
549 aInstance = instance;
573 wxS(
"Removing symbol instance:\n"
575 " reference %s, unit %d from symbol %s." ),
603 wxS(
"Adding symbol '%s' instance:\n"
627 wxLogTrace(
traceSchSymbolRef,
"GetRef for symbol %s on path %s (sheet path has %zu sheets)",
m_Uuid.AsString(),
634 wxLogTrace(
traceSchSymbolRef,
" Instance: path=%s, ref=%s", instance.m_Path.AsString(),
635 instance.m_Reference );
637 if( instance.m_Path ==
path )
639 ref = instance.m_Reference;
653 wxLogTrace(
traceSchSymbolRef,
" Using fallback from REFERENCE field: %s", ref );
688 if( instance.m_Path ==
path )
691 instance.m_Reference = ref;
699 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
700 pin->ClearDefaultNetName( sheet );
722 if( instance.m_Path ==
path )
723 return !instance.m_Reference.IsEmpty() && instance.m_Reference.Last() !=
'?';
734 refDesignator.Replace(
"~",
" " );
736 wxString prefix = refDesignator;
738 while( prefix.Length() )
740 wxUniCharRef last = prefix.Last();
742 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
750 prefix.Trim(
false );
752 if( !prefix.IsEmpty() )
760 return schematic->Settings().SubReference( aUnit, aAddSeparator );
772 if( instance.m_Path ==
path )
773 return instance.m_Unit;
789 if( instance.m_Path ==
path )
791 instance.m_Unit = aUnitSelection;
812 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
815 if( aVariantName.IsEmpty() )
817 instance.
m_DNP = aEnable;
824 if( instance.
m_Variants.contains( aVariantName ) )
826 instance.
m_Variants[aVariantName].m_DNP = aEnable;
833 variant.
m_DNP = aEnable;
848 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
851 if( aVariantName.IsEmpty() )
860 wxCHECK_MSG( instance.
m_Variants.contains( aVariantName ),
false,
861 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s' for variant '%s'." ),
864 return instance.
m_Variants[aVariantName].m_DNP;
871 for(
const wxString& variantName : aVariantNames )
872 SetDNP( aEnable, &aInstance, variantName );
887 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
890 if( aVariantName.IsEmpty() )
899 if( instance.
m_Variants.contains( aVariantName ) )
901 instance.
m_Variants[aVariantName].m_ExcludedFromBOM = aEnable;
923 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
926 if( aVariantName.IsEmpty() )
934 wxCHECK_MSG( instance.
m_Variants.contains( aVariantName ),
false,
935 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s' variant '%s'." ),
938 return instance.
m_Variants[aVariantName].m_ExcludedFromBOM;
944 const std::vector<wxString>& aVariantNames )
946 for(
const wxString& variantName : aVariantNames )
962 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
965 if( aVariantName.IsEmpty() )
974 if( instance.
m_Variants.contains( aVariantName ) )
976 instance.
m_Variants[aVariantName].m_ExcludedFromSim = aEnable;
998 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
1001 if( aVariantName.IsEmpty() )
1009 wxCHECK_MSG( instance.
m_Variants.contains( aVariantName ),
false,
1010 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s' variant '%s'." ),
1013 return instance.
m_Variants[aVariantName].m_ExcludedFromSim;
1019 const std::vector<wxString>& aVariantNames )
1021 for(
const wxString& variantName : aVariantNames )
1029 instance.m_Unit = aUnitSelection;
1049 bool aAllowExtraText )
const
1069 m_fields.emplace_back(
this, aFieldType );
1098 if( !field.IsVisible() || field.GetText().IsEmpty() )
1102 aVector.push_back(
const_cast<SCH_FIELD*
>( &field ) );
1105 std::sort( aVector.begin(), aVector.end(),
1108 return lhs->GetOrdinal() < rhs->GetOrdinal();
1128 for(
unsigned ii = 0; ii <
m_fields.size(); ++ii )
1133 if( aFieldName ==
m_fields[ii].GetName(
false ) )
1146 if( field.GetName().IsSameAs( aFieldName,
false ) )
1155 bool aResetRef,
bool aResetOtherFields )
1159 std::vector<SCH_FIELD*> fields;
1160 m_part->GetFields( fields );
1162 for(
const SCH_FIELD* libField : fields )
1167 if( libField->IsMandatory() )
1169 fieldType = libField->GetId();
1174 schField =
GetField( libField->GetCanonicalName() );
1184 schField->
SetPrivate( libField->IsPrivate() );
1196 else if( aUpdateRef )
1197 SetRef( aPath, libField->GetText() );
1205 if( aResetOtherFields )
1207 else if( aUpdateOtherFields )
1208 schField->
SetText( libField->GetText() );
1212 if( aResetOtherFields || aUpdateOtherFields )
1213 schField->
SetText( libField->GetText() );
1222 bool updateValue =
true;
1223 bool updateExclFromBOM =
true;
1224 bool updateExclFromBoard =
true;
1225 bool updateDNP =
true;
1226 bool updateOtherFields =
true;
1227 bool updatePins =
true;
1231 updateValue = aProperty->
Name() ==
_HKI(
"Value" );
1232 updateExclFromBoard = aProperty->
Name() ==
_HKI(
"Exclude From Board" );
1233 updateExclFromBOM = aProperty->
Name() ==
_HKI(
"Exclude From Bill of Materials" );
1234 updateDNP = aProperty->
Name() ==
_HKI(
"Do not Populate" );
1235 updateOtherFields =
false;
1239 if( !updateValue && !updateExclFromBOM && !updateExclFromBoard && !updateDNP && !updateOtherFields && !updatePins )
1248 wxString ref =
GetRef( &aSourceSheet );
1253 std::vector<SCH_SYMBOL*> otherUnits;
1259 aCommit.
Modify( otherUnit, screen );
1264 if( updateOtherFields )
1276 if( field.IsMandatory() )
1277 otherField = otherUnit->GetField( field.GetId() );
1279 otherField = otherUnit->GetField( field.GetName() );
1283 otherField->
SetText( field.GetText() );
1291 newField.
Offset( otherUnit->GetPosition() );
1294 otherUnit->AddField( newField );
1298 for(
int ii = (
int) otherUnit->GetFields().size() - 1; ii >= 0; ii-- )
1300 SCH_FIELD& otherField = otherUnit->GetFields()[ii];
1303 otherUnit->GetFields().erase( otherUnit->GetFields().begin() + ii );
1307 if( updateExclFromBOM )
1310 if( updateExclFromBoard )
1314 otherUnit->SetDNP(
GetDNP( &aSourceSheet ), &sheet );
1318 for(
const std::unique_ptr<SCH_PIN>& model_pin :
m_pins )
1320 SCH_PIN* src_pin = otherUnit->GetPin( model_pin->GetNumber() );
1323 src_pin->
SetAlt( model_pin->GetAlt() );
1334 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1335 aFunction(
pin.get() );
1338 aFunction( &field );
1344 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1346 if(
pin->GetNumber() == aNumber )
1356 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1358 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
1359 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
1361 if( pin_unit > 0 && pin_unit !=
GetUnit() )
1364 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
1367 if(
pin->GetPosition() == aPos )
1380 return std::vector<SCH_PIN*>();
1387 return m_part->GetPins();
1389 return std::vector<SCH_PIN*>();
1401 auto it =
m_pinMap.find( aLibPin );
1406 wxFAIL_MSG_AT(
"Pin not found", __FILE__, __LINE__, __FUNCTION__ );
1413 std::vector<SCH_PIN*> pins;
1422 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1424 if( unit &&
pin->GetUnit() &&
pin->GetUnit() != unit )
1427 pins.push_back(
pin.get() );
1442 wxCHECK_RET( aItem !=
nullptr && aItem->
Type() ==
SCH_SYMBOL_T, wxT(
"Cannot swap data with invalid symbol." ) );
1450 for( std::unique_ptr<SCH_PIN>&
pin : symbol->
m_pins )
1451 pin->SetParent( symbol );
1453 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1454 pin->SetParent(
this );
1459 m_part.reset( libSymbol );
1493 if( field.IsPrivate() )
1496 if( field.IsMandatory() )
1497 aVars->push_back( field.GetCanonicalName().Upper() );
1499 aVars->push_back( field.GetName() );
1502 aVars->push_back( wxT(
"OP" ) );
1503 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
1504 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
1505 aVars->push_back( wxT(
"UNIT" ) );
1506 aVars->push_back( wxT(
"SHORT_REFERENCE" ) );
1507 aVars->push_back( wxT(
"SYMBOL_LIBRARY" ) );
1508 aVars->push_back( wxT(
"SYMBOL_NAME" ) );
1509 aVars->push_back( wxT(
"SYMBOL_DESCRIPTION" ) );
1510 aVars->push_back( wxT(
"SYMBOL_KEYWORDS" ) );
1511 aVars->push_back( wxT(
"EXCLUDE_FROM_BOM" ) );
1512 aVars->push_back( wxT(
"EXCLUDE_FROM_BOARD" ) );
1513 aVars->push_back( wxT(
"EXCLUDE_FROM_SIM" ) );
1514 aVars->push_back( wxT(
"DNP" ) );
1515 aVars->push_back( wxT(
"SHORT_NET_NAME(<pin_number>)" ) );
1516 aVars->push_back( wxT(
"NET_NAME(<pin_number>)" ) );
1517 aVars->push_back( wxT(
"NET_CLASS(<pin_number>)" ) );
1518 aVars->push_back( wxT(
"PIN_NAME(<pin_number>)" ) );
1519 aVars->push_back( wxT(
"REFERENCE(<pin_number>)" ) );
1520 aVars->push_back( wxT(
"SHORT_REFERENCE(<pin_number>)" ) );
1521 aVars->push_back( wxT(
"UNIT(<pin_number>)" ) );
1527 static wxRegEx operatingPoint( wxT(
"^"
1534 wxCHECK( aPath,
false );
1541 if( operatingPoint.Matches( *token ) )
1543 wxString
pin( operatingPoint.GetMatch( *token, 1 ).Lower() );
1544 wxString precisionStr( operatingPoint.GetMatch( *token, 3 ) );
1545 wxString rangeStr( operatingPoint.GetMatch( *token, 4 ) );
1547 int precision = precisionStr.IsEmpty() ? 3 : precisionStr[0] -
'0';
1548 wxString range = rangeStr.IsEmpty() ? wxString( wxS(
"~A" ) ) : rangeStr;
1552 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
1556 embeddedFilesStack.push_back(
m_part->GetEmbeddedFiles() );
1566 wxString spiceRef =
model.SpiceGenerator().ItemName( spiceItem );
1567 spiceRef = spiceRef.Lower();
1574 else if(
pin == wxS(
":power" ) )
1576 if( rangeStr.IsEmpty() )
1577 range = wxS(
"~W" );
1579 *token = schematic->
GetOperatingPoint( spiceRef + wxS(
":power" ), precision, range );
1584 pin =
pin.SubString( 1, -1 );
1586 for(
const std::reference_wrapper<const SIM_MODEL_PIN>& modelPin :
model.GetPins() )
1588 SCH_PIN* symbolPin =
GetPin( modelPin.get().symbolPinNumber );
1592 if(
model.GetPins().size() == 2 )
1598 wxString signalName = spiceRef + wxS(
":" ) + modelPin.get().modelPinName;
1607 *token = wxS(
"?" );
1611 if( token->Contains(
':' ) )
1619 wxString fieldName = field.IsMandatory() ? field.GetCanonicalName() : field.GetName();
1621 wxString textToken = field.GetText();
1622 textToken.Replace(
" ", wxEmptyString );
1623 wxString tokenString =
"${" + fieldName +
"}";
1626 if( textToken.IsSameAs( tokenString,
false ) )
1629 if( token->IsSameAs( fieldName,
false ) )
1632 *token =
GetRef( aPath,
true );
1634 *token = field.GetShownText( aPath,
false, aDepth + 1 );
1641 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
1642 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
1643 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
1645 *token = wxEmptyString;
1652 if( token->IsSameAs( templateFieldname.m_Name ) || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
1656 *token = wxEmptyString;
1661 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
1665 wxArrayString parts = wxSplit( footprint,
':' );
1667 if( parts.Count() > 0 )
1670 *token = wxEmptyString;
1674 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
1678 wxArrayString parts = wxSplit( footprint,
':' );
1680 if( parts.Count() > 1 )
1681 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
1683 *token = wxEmptyString;
1687 else if( token->IsSameAs( wxT(
"UNIT" ) ) )
1692 else if( token->IsSameAs( wxT(
"SHORT_REFERENCE" ) ) )
1694 *token =
GetRef( aPath,
false );
1697 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
1699 *token =
m_lib_id.GetUniStringLibNickname();
1702 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
1704 *token =
m_lib_id.GetUniStringLibItemName();
1707 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
1712 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
1717 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
1719 *token = wxEmptyString;
1722 *token =
_(
"Excluded from BOM" );
1726 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
1728 *token = wxEmptyString;
1731 *token =
_(
"Excluded from board" );
1735 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
1737 *token = wxEmptyString;
1740 *token =
_(
"Excluded from simulation" );
1744 else if( token->IsSameAs( wxT(
"DNP" ) ) )
1746 *token = wxEmptyString;
1748 if( aPath->
GetDNP() || this->ResolveDNP() )
1749 *token =
_(
"DNP" );
1753 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) ) || token->StartsWith( wxT(
"NET_NAME(" ) )
1754 || token->StartsWith( wxT(
"NET_CLASS(" ) ) || token->StartsWith( wxT(
"PIN_NAME(" ) )
1755 || token->StartsWith( wxT(
"PIN_BASE_NAME(" ) ) || token->StartsWith( wxT(
"PIN_ALT_LIST(" ) )
1756 || token->StartsWith( wxT(
"REFERENCE(" ) ) || token->StartsWith( wxT(
"SHORT_REFERENCE(" ) )
1757 || token->StartsWith( wxT(
"UNIT(" ) ) )
1759 wxString pinNumber = token->AfterFirst(
'(' );
1760 pinNumber = pinNumber.BeforeLast(
')' );
1762 bool isReferenceFunction = token->StartsWith( wxT(
"REFERENCE(" ) );
1763 bool isShortReferenceFunction = token->StartsWith( wxT(
"SHORT_REFERENCE(" ) );
1764 bool isUnitFunction = token->StartsWith( wxT(
"UNIT(" ) );
1768 std::vector<SCH_PIN*> pinsToSearch = ( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
1773 if(
pin->GetNumber() == pinNumber )
1775 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
1777 int pinUnit =
pin->GetUnit();
1780 if( isReferenceFunction )
1788 else if( isShortReferenceFunction )
1793 else if( isUnitFunction )
1805 else if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
1807 *token =
pin->GetAlt().IsEmpty() ?
pin->GetName() :
pin->GetAlt();
1810 else if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
1812 *token =
pin->GetBaseName();
1815 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
1820 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
1821 for(
const auto& [altName, altDef] : alts )
1823 if( !altList.IsEmpty() )
1824 altList += wxT(
", " );
1835 *token = wxEmptyString;
1836 else if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
1839 if( netName.Lower().StartsWith( wxT(
"unconnected" ) ) )
1840 *token = wxT(
"NC" );
1844 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
1845 *token = conn->
Name();
1846 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
1847 *token =
pin->GetEffectiveNetClass( aPath )->GetName();
1855 if( !isReferenceFunction && !isShortReferenceFunction && !isUnitFunction )
1859 if(
pin->GetNumber() == pinNumber )
1862 if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
1864 *token =
pin->GetBaseName();
1867 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
1872 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
1873 for(
const auto& [altName, altDef] : alts )
1875 if( !altList.IsEmpty() )
1876 altList += wxT(
", " );
1885 int pinUnit =
pin->GetUnit();
1901 if( symbol->
GetRef( &sheetPath,
false ) ==
GetRef( aPath,
false )
1904 targetPath = sheetPath;
1905 targetSymbol = symbol;
1918 *token = wxString::Format( wxT(
"<Unit %s not placed>" ),
SubReference( pinUnit,
false ) );
1924 SCH_PIN* instancePin =
nullptr;
1927 if( candidate->GetNumber() == pinNumber )
1929 instancePin = candidate;
1936 *token = wxEmptyString;
1941 if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
1943 *token = instancePin->
GetAlt().IsEmpty() ? instancePin->
GetName() : instancePin->
GetAlt();
1951 *token = wxEmptyString;
1952 else if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
1955 if( netName.Lower().StartsWith( wxT(
"unconnected" ) ) )
1956 *token = wxT(
"NC" );
1960 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
1961 *token = conn->
Name();
1962 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
1971 *token = wxString::Format( wxT(
"<Unresolved: pin %s>" ), pinNumber );
1991 if( instance.m_Path ==
path )
1993 if( instance.m_Reference.IsEmpty() || aResetPrefix )
2004 if( instance.m_Reference.IsEmpty() || aResetPrefix )
2011 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2012 pin->ClearDefaultNetName( aSheetPath );
2020 if( currentReference.IsEmpty() || aResetPrefix )
2030 wxCHECK( aSheetPath.size() > 0,
false );
2035 if( instance.m_Path == aSheetPath )
2048 bool transform =
false;
2050 switch( aOrientation )
2171 wxFAIL_MSG(
"Invalid schematic symbol orientation type." );
2225 for(
int type_rotate : rotate_values )
2237 wxFAIL_MSG(
"Schematic symbol orientation matrix internal error." );
2245void SCH_SYMBOL::Show(
int nestLevel, std::ostream& os )
const
2248 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
" ref=\""
2254 for(
int i = 1; i < (int)
GetFields().size(); ++i )
2256 const wxString& value =
GetFields()[i].GetText();
2258 if( !value.IsEmpty() )
2260 NestedSpace( nestLevel + 1, os ) <<
"<field" <<
" name=\"" <<
TO_UTF8(
GetFields()[i].GetName() ) <<
'"'
2261 <<
" value=\"" <<
TO_UTF8( value ) <<
"\"/>\n";
2265 NestedSpace( nestLevel, os ) <<
"</" <<
TO_UTF8(
GetClass().Lower() ) <<
">\n";
2285 if( aIncludeFields )
2289 if( field.IsVisible() )
2290 bBox.
Merge( field.GetBoundingBox() );
2304 catch(
const boost::bad_pointer& e )
2306 wxFAIL_MSG( wxString::Format( wxT(
"Boost pointer exception occurred: %s" ), e.what() ) );
2331 auto addExcludes = [&]()
2336 msgs.Add(
_(
"Simulation" ) );
2339 msgs.Add(
_(
"BOM" ) );
2342 msgs.Add(
_(
"Board" ) );
2344 if(
GetDNP( currentSheet ) )
2345 msgs.Add(
_(
"DNP" ) );
2347 msg = wxJoin( msgs,
'|' );
2348 msg.Replace(
'|', wxS(
", " ) );
2351 aList.emplace_back(
_(
"Exclude from" ), msg );
2362 aList.emplace_back(
_(
"Power symbol" ),
2370 aList.emplace_back(
_(
"Value" ),
2377 aList.emplace_back(
_(
"flags" ), wxString::Format(
"%X",
GetEditFlags() ) );
2382 msg =
_(
"Missing parent" );
2384 std::shared_ptr<LIB_SYMBOL> parent =
m_part->GetParent().lock();
2387 msg = parent->GetName();
2391 else if( !
m_lib_id.GetLibNickname().empty() )
2393 aList.emplace_back(
_(
"Library" ),
m_lib_id.GetLibNickname() );
2397 aList.emplace_back(
_(
"Library" ),
_(
"Undefined!!!" ) );
2405 msg =
_(
"<Unknown>" );
2407 aList.emplace_back(
_(
"Footprint" ), msg );
2411 _(
"Keywords" ) + wxT(
": " ) +
m_part->GetKeyWords() );
2416 aList.emplace_back(
_(
"Reference" ),
GetRef( currentSheet ) );
2425 if( libNickname.empty() )
2426 msg =
_(
"No library defined!" );
2428 msg.Printf(
_(
"Symbol not found in %s!" ), libNickname );
2430 aList.emplace_back(
_(
"Library" ), msg );
2465 field.SetTextPos( pos );
2483 field.SetTextPos( pos );
2502 field.SetTextPos( pos );
2523 if( drawItem.Matches( aSearchData, aAuxData ) )
2534 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2542 aItemList.push_back( item );
2548 std::vector<DANGLING_END_ITEM>& aItemListByPos,
const SCH_SHEET_PATH* aPath )
2550 bool changed =
false;
2552 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2554 bool previousState =
pin->IsDangling();
2555 pin->SetIsDangling(
true );
2560 bool do_break =
false;
2562 for(
auto it = lower; it < aItemListByPos.end() && it->GetPosition() == pos; it++ )
2581 pin->SetIsDangling(
false );
2592 changed = ( changed || ( previousState !=
pin->IsDangling() ) );
2617 wxCHECK( symbol,
false );
2623 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2625 if(
pin->IsDangling() )
2638 if(
GetRef( aInstance ) != symbol->
GetRef( aInstance ) )
2648 for(
size_t i = 0; i <
m_pins.size(); i++ )
2660 std::vector<VECTOR2I> retval;
2662 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();
2669 if( pin_unit > 0 && pin_unit !=
GetUnit() )
2672 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
2698 return wxString::Format(
_(
"Symbol %s [%s]" ),
2706 for(
KICAD_T scanType : aScanTypes )
2751 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2755 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
2756 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
2758 if( pin_unit > 0 && pin_unit !=
GetUnit() )
2761 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
2798 std::vector<SCH_FIELD*> fields, otherFields;
2801 aSymbol.
GetFields( otherFields,
false );
2803 if( fields.size() != otherFields.size() )
2806 for(
int ii = 0; ii < (int) fields.size(); ii++ )
2811 if( fields[ii]->GetText().Cmp( otherFields[ii]->GetText() ) != 0 )
2821 return !( *
this == aSymbol );
2827 wxCHECK_MSG(
Type() == aSymbol.
Type(), *
this,
2828 wxT(
"Cannot assign object type " ) + aSymbol.
GetClass() + wxT(
" to type " ) +
GetClass() );
2830 if( &aSymbol !=
this )
2847 field.SetParent(
this );
2859 bBox.
Inflate( aAccuracy / 2 );
2875 rect.
Inflate( aAccuracy / 2 );
2897 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2910 if(
pin->GetLocalPosition() == new_pos )
2925 const VECTOR2I& aOffset,
bool aDimmed )
2939 for(
unsigned i = 0; i < tempPins.size(); ++i )
2942 SCH_PIN* tempPin = tempPins[i];
2959 text->SetText(
dummy.GetShownText(
false ) );
2968 for(
bool local_background : {
true,
false } )
2974 field.ClearRenderCache();
2978 && ( field.IsVisible() || field.IsForceVisible() ) )
2993 std::vector<wxString> properties;
2997 wxString text_field = field.GetShownText( sheet,
false );
2999 if( text_field.IsEmpty() )
3002 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ), field.GetName(), text_field ) );
3005 if( !
m_part->GetKeyWords().IsEmpty() )
3007 properties.emplace_back(
3008 wxString::Format( wxT(
"!%s = %s" ),
_(
"Keywords" ),
m_part->GetKeyWords() ) );
3031 margins.
x = std::max( margins.
x * 0.6, margins.
y * 0.3 );
3032 margins.
y = std::max( margins.
y * 0.6, margins.
x * 0.3 );
3050 double lineWidth = aSize / 10.0;
3052 std::vector<SCH_SHAPE> shapeList;
3054 int tolerance = 100;
3056 for(
const SCH_SHAPE& shape : shapeList )
3062 aPlotter->
BezierCurve( shape.GetStart(), shape.GetBezierC1(), shape.GetBezierC2(), shape.GetEnd(),
3063 tolerance, lineWidth );
3065 aPlotter->
Circle( shape.getCenter(), shape.GetRadius() * 2, filled, lineWidth );
3124 for(
unsigned i = 0; i < tempPins.size(); ++i )
3127 SCH_PIN* tempPin = tempPins[i];
3142 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3144 if(
pin->IsBrightened() )
3154 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3155 pin->ClearBrightened();
3173 m_part->SetShowPinNames( aShow );
3186 m_part->SetShowPinNumbers( aShow );
3192 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3194 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
3195 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
3197 if( pin_unit > 0 && pin_unit !=
GetUnit() )
3200 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
3203 if(
pin->IsPointClickableAnchor( aPos ) )
3222 if( pin_list.size() != 1 )
3240 if( pin_list.size() != 1 )
3252 return m_part->IsLocalPower();
3261 return m_part->IsGlobalPower();
3273 wxCHECK(
m_part,
false );
3275 return m_part->IsNormal();
3281 std::unordered_set<wxString> componentClass;
3283 auto getComponentClassFields = [&](
const std::vector<SCH_FIELD>& fields )
3287 if( field.GetCanonicalName() == wxT(
"Component Class" ) )
3289 if( field.GetShownText( aPath,
false ) != wxEmptyString )
3290 componentClass.insert( field.GetShownText( aPath,
false ) );
3296 getComponentClassFields(
m_fields );
3303 getComponentClassFields( label->GetFields() );
3307 return componentClass;
3312 const wxString& aVariantName )
const
3317 return std::nullopt;
3319 return instance.
m_Variants.find( aVariantName )->second;
3331 instance.
m_Variants.emplace( std::make_pair( aVariant.
m_Name, aVariant ) );
3375 for(
unsigned i = 0; i <
m_pins.size(); ++i )
3403 double aLineWidth,
bool aHorizontal )
3407 double x_right = aSize / 1.6180339887;
3408 double x_middle = x_right / 2.0;
3421 aShapeList.back().SetStart( bottomPt );
3422 aShapeList.back().SetBezierC1( bottomAnchorPt );
3423 aShapeList.back().SetBezierC2( leftSideAnchorPt1 );
3424 aShapeList.back().SetEnd( leftPt );
3428 aShapeList.back().SetStart( leftPt );
3429 aShapeList.back().SetBezierC1( leftSideAnchorPt2 );
3430 aShapeList.back().SetBezierC2( rightSideAnchorPt2 );
3431 aShapeList.back().SetEnd( rightPt );
3434 aShapeList.back().SetStart( rightPt );
3435 aShapeList.back().SetBezierC1( rightSideAnchorPt1 );
3436 aShapeList.back().SetBezierC2( bottomAnchorPt );
3437 aShapeList.back().SetEnd( bottomPt );
3440 aShapeList.back().SetCenter( ( leftPt + rightPt ) / 2.0 );
3441 aShapeList.back().SetRadius( aSize / 15.0 );
3446 shape.Rotate(
VECTOR2I( 0, 0 ),
true );
3481 auto hasLibPart = [](
INSPECTABLE* aItem ) ->
bool
3484 return symbol->GetLibSymbolRef() !=
nullptr;
3497 const wxString groupFields =
_HKI(
"Fields" );
3517 auto multiUnit = [=](
INSPECTABLE* aItem ) ->
bool
3520 return symbol->IsMultiUnit();
3525 auto multiBodyStyle = [=](
INSPECTABLE* aItem ) ->
bool
3528 return symbol->IsMultiBodyStyle();
3539 wxPGChoices choices;
3543 for(
int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
3544 choices.Add( symbol->GetUnitDisplayName( ii,
false ), ii );
3556 wxPGChoices choices;
3560 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
3561 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
3567 const wxString groupAttributes =
_HKI(
"Attributes" );
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr const Vec GetEnd() const
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr coord_type GetX() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr ecoord_type GetArea() const
Return the area of the rectangle.
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr void Offset(coord_type dx, coord_type dy)
constexpr bool Intersects(const BOX2< Vec > &aRect) const
constexpr coord_type GetBottom() const
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
static std::vector< DANGLING_END_ITEM >::iterator get_lower_pos(std::vector< DANGLING_END_ITEM > &aItemListByPos, const VECTOR2I &aPos)
Helper class used to store the state of schematic items that can be connected to other schematic item...
DANGLING_END_T GetType() const
const EDA_ITEM * GetParent() const
bool IsHorizontal() const
The base class for create windows for drawing purpose.
EDA_ITEM_FLAGS GetEditFlags() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
virtual void SetParentGroup(EDA_GROUP *aGroup)
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * m_parent
Owner.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextPos(const VECTOR2I &aPoint)
void Offset(const VECTOR2I &aOffset)
static ENUM_MAP< T > & Instance()
A text control validator used for validating the text allowed in fields.
bool DoValidate(const wxString &aValue, wxWindow *aParent)
Class that other classes need to inherit from, in order to be inspectable.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxString AsString() const
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
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.
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
static LIB_SYMBOL * GetDummy()
Returns a dummy LIB_SYMBOL, used when one is missing in the schematic.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
const BOX2I GetBodyBoundingBox(int aUnit, int aBodyStyle, bool aIncludePins, bool aIncludePrivateItems) const
Get the symbol bounding box excluding fields.
EMBEDDED_FILES * GetEmbeddedFiles() override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
const wxString GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
A singleton reporter that reports to nowhere.
Base plotter engine class.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width)=0
virtual void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
Create a bookmark to a symbol.
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness)
Generic fallback: Cubic Bezier curve rendered as a polyline.
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, void *aData)
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
virtual void SetColor(const COLOR4D &color)=0
virtual void EndBlock(void *aData)
calling this function allows one to define the end of a group of drawing items for instance in SVG or...
PROPERTY_BASE & SetChoicesFunc(std::function< wxPGChoices(INSPECTABLE *)> aFunc)
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
const wxString & Name() const
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
TEMPLATES m_TemplateFieldNames
Holds all the data relating to one schematic.
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
SCHEMATIC_SETTINGS & Settings() const
PROJECT & Project() const
Return a reference to the project this schematic is part of.
EMBEDDED_FILES * GetEmbeddedFiles() override
SCH_SHEET_PATH & CurrentSheet() const
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString LocalName() const
wxString Name(bool aIgnoreSheet=false) const
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void ImportValues(const SCH_FIELD &aSource)
Copy parameters from a SCH_FIELD source.
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
void SetText(const wxString &aText) override
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
void SetPrivate(bool aPrivate)
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
AUTOPLACE_ALGO m_fieldsAutoplaced
std::unordered_set< SCH_RULE_AREA * > m_rule_areas_cache
Store pointers to rule areas which this item is contained within.
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
void SetAlt(const wxString &aAlt)
Set the name of the alternate pin.
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
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
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
bool GetExcludedFromSim() const
bool GetExcludedFromBoard() const
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
size_t size() const
Forwarded method from std::vector.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Variant information for a schematic symbol.
void InitializeAttributes(const SCH_SYMBOL &aSymbol)
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the display name for a given unit aUnit.
void SetValueProp(const wxString &aRef)
SCH_SYMBOL & operator=(const SCH_SYMBOL &aItem)
size_t GetFullPinCount() const
void UpdatePrefix()
Set the prefix based on the current reference designator.
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
wxString GetDescription() const override
std::unordered_map< SCH_PIN *, SCH_PIN * > m_pinMap
Library pin pointer : SCH_PIN indices.
void SetMirrorX(bool aMirror)
bool IsSymbolLikePowerGlobalLabel() const
EMBEDDED_FILES * GetEmbeddedFiles() override
SCH_SYMBOLs don't currently support embedded files, but their LIB_SYMBOL counterparts do.
wxString GetSymbolIDAsString() const
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool GetShowPinNumbers() const override
wxString GetDatasheet() const
Return the documentation text for the given part alias.
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void SetLibId(const LIB_ID &aName)
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the symbol's fields.
BOX2I GetBodyAndPinsBoundingBox() const override
Return a bounding box for the symbol body and pins but not the fields.
wxString GetBodyStyleProp() const override
void SetRefProp(const wxString &aRef)
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
virtual void SetDNP(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
SCH_ITEM * GetDrawItem(const VECTOR2I &aPosition, KICAD_T aType=TYPE_NOT_INIT)
Return the symbol library item at aPosition that is part of this symbol.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void PlotDNP(PLOTTER *aPlotter) const
Plot the red 'X' over the symbol.
bool operator!=(const SCH_SYMBOL &aSymbol) const
void SetShowPinNumbers(bool aShow) override
Set or clear the pin number visibility flag.
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
wxString SubReference(int aUnit, bool aAddSeparator=true) const
wxString GetClass() const override
Return the class name.
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 PlotPins(PLOTTER *aPlotter) const
Plot just the symbol pins.
void SetBodyStyleProp(const wxString &aBodyStyle) override
void SetValueFieldText(const wxString &aValue)
std::vector< SCH_PIN * > GetPins() const override
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
void SetExcludedFromSim(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
void SetExcludedFromSimProp(bool aEnable)
void SetBodyStyle(int aBodyStyle) override
void SetShowPinNames(bool aShow) override
Set or clear the pin name visibility flag.
wxString GetKeyWords() const override
wxString GetSchSymbolLibraryName() const
wxString GetShownKeyWords(int aDepth=0) const override
void DeleteVariant(const SCH_SHEET_PATH &aInstance, const wxString &aVariantName)
std::optional< SCH_SYMBOL_VARIANT > GetVariant(const SCH_SHEET_PATH &aInstance, const wxString &aVariantName) const
void ClearBrightenedPins()
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
bool GetExcludedFromSimProp() const
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool IsGlobalPower() const override
wxString GetRefProp() const
wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const override
bool AddSheetPathReferenceEntryIfMissing(const KIID_PATH &aSheetPath)
Add an instance to the alternate references list (m_instanceReferences), if this entry does not alrea...
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void SetExcludedFromBOMProp(bool aEnable)
static std::unordered_map< TRANSFORM, int > s_transformToOrientationCache
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
std::vector< SCH_SYMBOL_INSTANCE > m_instanceReferences
Define the hierarchical path and reference of the symbol.
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const override
void SyncOtherUnits(const SCH_SHEET_PATH &aSourceSheet, SCH_COMMIT &aCommit, PROPERTY_BASE *aProperty)
Keep fields other than the reference, include/exclude flags, and alternate pin assignments in sync in...
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.
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.
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const
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...
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.
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
VECTOR2I GetPosition() const override
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 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::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
wxString GetShownDescription(int aDepth=0) const override
const LIB_ID & GetLibId() const override
bool operator<(const SCH_ITEM &aItem) const override
static void BuildLocalPowerIconShape(std::vector< SCH_SHAPE > &aShapeList, const VECTOR2D &aPos, double aSize, double aLineWidth, bool aHorizontal)
Build the local power pin indicator icon shape, at coordinate aPos.
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
void SetUnitProp(int aUnit)
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
std::vector< SCH_PIN * > GetLibPins() const
Populate a vector with all the pins from the library object that match the current unit and bodyStyle...
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test if the symbol's dangling state has changed for all pins.
bool 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)
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool m_isInNetlist
True if the symbol should appear in netlist.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
wxString GetValueProp() const
bool IsLocalPower() const override
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
int GetUnitCount() const override
Return the number of units per package of the symbol.
void SetPrefix(const wxString &aPrefix)
int GetOrientation() const override
Get the display symbol orientation.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
bool IsSymbolLikePowerLocalLabel() const
bool GetExcludedFromBOMProp() const
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
void SetExcludedFromBOM(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
void PlotLocalPowerIconShape(PLOTTER *aPlotter) const
Plot the local power pin indicator icon shape.
bool IsNormal() const override
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
std::unordered_set< wxString > GetComponentClassNames(const SCH_SHEET_PATH *aPath) const
Return the component classes this symbol belongs in.
std::vector< std::unique_ptr< SCH_PIN > > m_pins
A SCH_PIN for every #LIB_PIN.
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
VECTOR2I GetPinPhysicalPosition(const SCH_PIN *Pin) const
BOX2I GetBodyBoundingBox() const override
Return a bounding box for the symbol body but not the pins or fields.
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
bool IsPower() const override
bool operator==(const SCH_SYMBOL &aSymbol) const
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
A base class for LIB_SYMBOL and SCH_SYMBOL.
bool m_DNP
True if symbol is set to 'Do Not Populate'.
void SetExcludedFromBoard(bool aExcludeFromBoard) override
Set or clear exclude from board netlist flag.
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
const TRANSFORM & GetTransform() const
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
bool GetExcludedFromBoard() const override
virtual bool GetShowPinNames() const
SYMBOL & operator=(const SYMBOL &aItem)
virtual bool GetShowPinNumbers() const
TRANSFORM m_transform
The rotation/mirror transformation.
const std::vector< TEMPLATE_FIELDNAME > & GetTemplateFieldNames()
Return a template field name list for read only access.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
T Convert(const wxString &aValue)
Convert a wxString to a generic type T.
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
static constexpr EDA_ANGLE ANGLE_270
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define IS_DANGLING
indicates a pin is dangling
@ FILLED_SHAPE
Fill with object color.
a few functions useful in geometry calculations.
const wxChar *const traceSchSymbolRef
Flag to enable debug output of schematic symbol reference resolution.
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
SCH_LAYER_ID
Eeschema drawing layers.
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Message panel definition file.
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
@ PT_NC
not connected (must be left open)
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
#define NO_SETTER(owner, type)
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
Collection of utility functions for component reference designators (refdes)
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
const SCH_FIELD * FindField(const std::vector< SCH_FIELD > &aFields, FIELD_T aFieldId)
int NextFieldOrdinal(const std::vector< SCH_FIELD > &aFields)
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
static void plotLocalPowerIcon(PLOTTER *aPlotter, const VECTOR2D &aPos, double aSize, bool aRotate)
plot a local power pin indicator icon.
static struct SCH_SYMBOL_DESC _SCH_SYMBOL_DESC
std::vector< FAB_LAYER_COLOR > dummy
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
A simple container for schematic symbol instance information.
std::map< wxString, SCH_SYMBOL_VARIANT > m_Variants
A list of symbol variants.
Hold a name of a symbol's field, field value, and default visibility.
@ SYM_ROTATE_COUNTERCLOCKWISE
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ USER
The field ID hasn't been set yet; field is invalid.
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
wxString GetCanonicalFieldName(FIELD_T aFieldType)
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ SCH_FIELD_LOCATE_REFERENCE_T
@ SCH_FIELD_LOCATE_FOOTPRINT_T
@ SCH_FIELD_LOCATE_VALUE_T
@ SCH_FIELD_LOCATE_DATASHEET_T
@ SCH_SYMBOL_LOCATE_POWER_T
Custom text control validator definitions.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D