49#include <api/schematic/schematic_types.pb.h>
66 std::string ret =
TO_UTF8( txt );
70 if( (
unsigned char) c <=
' ' )
95 std::unique_ptr<LIB_SYMBOL> part;
124 SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.
Convert, aPosition, aParent )
127 for(
const auto& [fieldId, fieldValue] : aSel.
Fields )
129 if( fieldId == FIELD_T::REFERENCE )
130 SetRef( aSheet, fieldValue );
131 else if( SCH_FIELD* field = GetField( fieldId ) )
132 field->SetText( fieldValue );
157 field.SetParent(
this );
162 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol.
m_pins )
164 m_pins.emplace_back( std::make_unique<SCH_PIN>( *pin ) );
165 m_pins.back()->SetParent( this );
219 using namespace kiapi::schematic::types;
221 SchematicSymbolInstance symbol;
223 symbol.mutable_id()->set_value(
m_Uuid.AsStdString() );
225 symbol.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
227 SchematicSymbolTransform* transform = symbol.mutable_transform();
228 transform->set_orientation(
234 symbol.mutable_body_style()->set_style(
GetBodyStyle() );
236 SchematicSymbol* def = symbol.mutable_definition();
239 google::protobuf::Any
any;
242 any.UnpackTo( symbol.mutable_reference_field() );
245 any.UnpackTo( symbol.mutable_value_field() );
248 any.UnpackTo( symbol.mutable_footprint_field() );
251 any.UnpackTo( symbol.mutable_datasheet_field() );
254 any.UnpackTo( symbol.mutable_description_field() );
259 any.UnpackTo( def->mutable_reference_field() );
262 any.UnpackTo( def->mutable_value_field() );
265 any.UnpackTo( def->mutable_footprint_field() );
268 any.UnpackTo( def->mutable_datasheet_field() );
271 any.UnpackTo( def->mutable_description_field() );
283 SchematicSymbolChild* item = def->add_items();
284 item->mutable_unit()->set_unit( drawItem.GetUnit() );
285 item->mutable_body_style()->set_style( drawItem.GetBodyStyle() );
286 item->set_is_private( drawItem.IsPrivate() );
287 drawItem.Serialize( *item->mutable_item() );
290 def->set_unit_count(
m_part->GetUnitCount() );
291 def->set_body_style_count(
m_part->GetBodyStyleCount() );
292 def->set_keywords(
m_part->GetKeyWords().ToUTF8() );
295 def->add_footprint_filters(
filter.ToUTF8() );
303 aContainer.PackFrom( symbol );
310 using namespace kiapi::common::types;
311 using namespace kiapi::schematic::types;
313 SchematicSymbolInstance symbol;
315 if( !aContainer.UnpackTo( &symbol ) )
320 SetLocked( symbol.locked() == LockedState::LS_LOCKED );
326 const SchematicSymbol& def = symbol.definition();
334 google::protobuf::Any
any;
336 any.PackFrom( def.reference_field() );
339 any.PackFrom( def.value_field() );
342 any.PackFrom( def.footprint_field() );
345 any.PackFrom( def.datasheet_field() );
348 any.PackFrom( def.description_field() );
351 std::unordered_map<::KIID, wxString> pinAltMap;
353 for(
const SchematicSymbolChild& child : def.items() )
362 if( !item || !item->Deserialize( child.item() ) )
369 SchematicPin pinProto;
371 if( child.item().UnpackTo( &pinProto ) )
373 if( pinProto.has_active_alternate() )
374 pinAltMap[schItem->
m_Uuid] = wxString::FromUTF8( pinProto.active_alternate() );
378 if( child.has_unit() )
379 schItem->
SetUnit( child.unit().unit() );
381 if( child.has_body_style() )
389 if( def.unit_count() > 0 )
392 if( def.body_style_count() > 0 )
395 if( !def.keywords().empty() )
396 libSymbol->
SetKeyWords( wxString::FromUTF8( def.keywords() ) );
398 if( def.footprint_filters_size() > 0 )
400 wxArrayString filters;
402 for(
const std::string&
filter : def.footprint_filters() )
403 filters.Add( wxString::FromUTF8(
filter ) );
410 if( symbol.has_body_style() )
413 any.PackFrom( symbol.reference_field() );
416 any.PackFrom( symbol.value_field() );
419 any.PackFrom( symbol.footprint_field() );
422 any.PackFrom( symbol.datasheet_field() );
425 any.PackFrom( symbol.description_field() );
443 m_pins.emplace_back( std::make_unique<SCH_PIN>( *
pin ) );
444 m_pins.back()->SetParent(
this );
455 if( pinAltMap.contains(
pin->m_Uuid ) )
456 pin->SetAlt( pinAltMap.at(
pin->m_Uuid ) );
475 const int min_grid_size =
schIUScale.MilsToIU( 25 );
477 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
479 if( ( (
pin->GetPosition().x -
m_pos.x ) % min_grid_size ) != 0 )
482 if( ( (
pin->GetPosition().y -
m_pos.y ) % min_grid_size ) != 0 )
507 wxCHECK2( !aLibSymbol || aLibSymbol->
IsRoot(), aLibSymbol =
nullptr );
509 m_part.reset( aLibSymbol );
514 pin->SetLibPin(
nullptr );
523 return m_part->GetDescription();
525 return wxEmptyString;
532 return m_part->GetShownDescription( aDepth );
534 return wxEmptyString;
541 return m_part->GetKeyWords();
543 return wxEmptyString;
550 return m_part->GetShownKeyWords( aDepth );
552 return wxEmptyString;
559 return m_part->GetDatasheetField().GetText();
561 return wxEmptyString;
567 std::map<wxString, wxString> altPinMap;
568 std::map<wxString, SCH_PIN::ALT> altPinDefs;
569 std::map<wxString, std::set<SCH_PIN*>> pinUuidMap;
570 std::set<SCH_PIN*> unassignedSchPins;
571 std::set<SCH_PIN*> unassignedLibPins;
573 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
575 pinUuidMap[
pin->GetNumber()].insert(
pin.get() );
577 unassignedSchPins.insert(
pin.get() );
579 if( !
pin->GetAlt().IsEmpty() )
581 altPinMap[
pin->GetNumber()] =
pin->GetAlt();
582 auto altDefIt =
pin->GetAlternates().find(
pin->GetAlt() );
584 if( altDefIt !=
pin->GetAlternates().end() )
585 altPinDefs[
pin->GetNumber()] = altDefIt->second;
588 pin->SetLibPin(
nullptr );
605 auto ii = pinUuidMap.find( libPin->GetNumber() );
607 if( ii == pinUuidMap.end() || ii->second.empty() )
609 unassignedLibPins.insert( libPin );
613 auto it = ii->second.begin();
615 ii->second.erase( it );
616 pin->GetAlternates() = libPin->GetAlternates();
617 pin->SetLibPin( libPin );
618 pin->SetPosition( libPin->GetPosition() );
619 pin->SetUnit( libPin->GetUnit() );
620 pin->SetBodyStyle( libPin->GetBodyStyle() );
622 unassignedSchPins.erase(
pin );
624 auto iii = altPinMap.find( libPin->GetNumber() );
626 if( iii != altPinMap.end() )
628 wxString altName = iii->second;
630 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
632 auto defIt = altPinDefs.find( libPin->GetNumber() );
634 if( defIt != altPinDefs.end() )
636 for(
const auto& [
name, alt] :
pin->GetAlternates() )
638 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
647 pin->SetAlt( altName );
654 for(
SCH_PIN* libPin : unassignedLibPins )
659 if( !unassignedSchPins.empty() )
661 auto it = unassignedSchPins.begin();
663 unassignedSchPins.erase( it );
668 pin =
m_pins.emplace_back( std::make_unique<SCH_PIN>(
SCH_PIN(
this, libPin ) ) ).get();
672 pin->GetAlternates() = libPin->GetAlternates();
673 pin->SetLibPin( libPin );
674 pin->SetPosition( libPin->GetPosition() );
675 pin->SetUnit( libPin->GetUnit() );
676 pin->SetBodyStyle( libPin->GetBodyStyle() );
677 pin->SetNumber( libPin->GetNumber() );
679 auto iii = altPinMap.find( libPin->GetNumber() );
681 if( iii != altPinMap.end() )
683 wxString altName = iii->second;
685 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
687 auto defIt = altPinDefs.find( libPin->GetNumber() );
689 if( defIt != altPinDefs.end() )
691 for(
const auto& [
name, alt] :
pin->GetAlternates() )
693 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
702 pin->SetAlt( altName );
707 for(
auto it1 =
m_pins.begin(); it1 !=
m_pins.end() && !unassignedSchPins.empty(); )
709 auto it2 = unassignedSchPins.find( it1->get() );
711 if( it2 != unassignedSchPins.end() )
713 it1 =
m_pins.erase( it1 );
714 unassignedSchPins.erase( it2 );
725 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
746 return m_part->GetUnitCount();
755 return m_part->GetBodyStyleCount();
764 return m_part->HasDeMorganBodyStyles();
773 return m_part->GetUnitDisplayName( aUnit, aLabel );
775 return wxString::Format(
_(
"Unit %s" ),
SubReference( aUnit ) );
784 return m_part->GetBodyStyleDescription( aBodyStyle, aLabel );
796 if( instance.m_Path == aSheetPath )
798 aInstance = instance;
802 else if( instance.m_Path.EndsWith( aSheetPath ) )
804 aInstance = instance;
823 for(
int ii =
m_instances.size() - 1; ii >= 0; --ii )
828 wxS(
"Removing symbol instance:\n"
830 " reference %s, unit %d from symbol %s." ),
858 wxS(
"Adding symbol '%s' instance:\n"
882 wxLogTrace(
traceSchSymbolRef,
"GetRef for symbol %s on path %s (sheet path has %zu sheets)",
m_Uuid.AsString(),
889 wxLogTrace(
traceSchSymbolRef,
" Instance: path=%s, ref=%s", instance.m_Path.AsString(),
890 instance.m_Reference );
892 if( instance.m_Path ==
path )
894 ref = instance.m_Reference;
908 wxLogTrace(
traceSchSymbolRef,
" Using fallback from REFERENCE field: %s", ref );
950 if( instance.m_Path ==
path )
953 instance.m_Reference = ref;
961 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
962 pin->ClearDefaultNetName( sheet );
979 const wxString& aVariantName )
981 wxCHECK( !aFieldName.IsEmpty(), );
987 switch( field->
GetId() )
991 SetRef( aPath, aFieldText );
996 wxString defaultText = field->
GetText( aPath );
998 if( aVariantName.IsEmpty() )
1000 if( aFieldText != defaultText )
1007 wxCHECK( instance, );
1009 if( instance->
m_Variants.contains( aVariantName ) )
1011 if( aFieldText != defaultText )
1012 instance->
m_Variants[aVariantName].m_Fields[aFieldName] = aFieldText;
1014 instance->
m_Variants[aVariantName].m_Fields.erase( aFieldName );
1016 else if( aFieldText != defaultText )
1021 newVariant.
m_Fields[aFieldName] = aFieldText;
1022 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
1033 const wxString& aVariantName )
const
1035 wxCHECK( !aFieldName.IsEmpty(), wxEmptyString );
1039 wxCHECK( field, wxEmptyString );
1041 switch( field->
GetId() )
1044 wxCHECK( aPath, field->
GetText() );
1045 return GetRef( aPath,
false );
1049 if( !aVariantName.IsEmpty() && aPath )
1053 if( instance && instance->
m_Variants.contains( aVariantName )
1054 && instance->
m_Variants.at( aVariantName ).m_Fields.contains( aFieldName ) )
1056 return instance->
m_Variants.at( aVariantName ).m_Fields.at( aFieldName );
1063 if( aVariantName.IsEmpty() )
1071 if( instance->
m_Variants.contains( aVariantName )
1072 && instance->
m_Variants.at( aVariantName ).m_Fields.contains( aFieldName ) )
1073 return instance->
m_Variants.at( aVariantName ).m_Fields.at( aFieldName );
1089 if( instance.m_Path ==
path )
1090 return !instance.m_Reference.IsEmpty() && instance.m_Reference.Last() !=
'?';
1101 refDesignator.Replace(
"~",
" " );
1103 wxString prefix = refDesignator;
1105 while( prefix.Length() )
1107 wxUniCharRef last = prefix.Last();
1109 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
1110 prefix.RemoveLast();
1116 prefix.Trim(
true );
1117 prefix.Trim(
false );
1119 if( !prefix.IsEmpty() )
1127 return schematic->Settings().SubReference( aUnit, aAddSeparator );
1139 if( instance.m_Path ==
path )
1140 return instance.m_Unit;
1156 if( instance.m_Path ==
path )
1158 instance.m_Unit = aUnitSelection;
1170 if( !aInstance || aVariantName.IsEmpty() )
1178 wxCHECK_MSG( instance, ,
1179 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
1182 if( aVariantName.IsEmpty() )
1188 if( instance->
m_Variants.contains( aVariantName ) && ( aEnable != instance->
m_Variants[aVariantName].m_DNP ) )
1190 instance->
m_Variants[aVariantName].m_DNP = aEnable;
1197 variant.
m_DNP = aEnable;
1206 if( !aInstance || aVariantName.IsEmpty() )
1214 if( instance.
m_Variants.contains( aVariantName ) )
1215 return instance.
m_Variants[aVariantName].m_DNP;
1223 if( !aInstance || aVariantName.IsEmpty() )
1231 wxCHECK_MSG( instance, ,
1232 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
1235 if( aVariantName.IsEmpty() )
1241 if( instance->
m_Variants.contains( aVariantName )
1242 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromBOM ) )
1244 instance->
m_Variants[aVariantName].m_ExcludedFromBOM = aEnable;
1260 if( !aInstance || aVariantName.IsEmpty() )
1268 if( instance.
m_Variants.contains( aVariantName ) )
1269 return instance.
m_Variants[aVariantName].m_ExcludedFromBOM;
1278 if( !aInstance || aVariantName.IsEmpty() )
1286 wxCHECK_MSG( instance, ,
1287 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
1290 if( aVariantName.IsEmpty() )
1296 if( instance->
m_Variants.contains( aVariantName )
1297 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromSim ) )
1299 instance->
m_Variants[aVariantName].m_ExcludedFromSim = aEnable;
1315 if( !aInstance || aVariantName.IsEmpty() )
1323 if( instance.
m_Variants.contains( aVariantName ) )
1324 return instance.
m_Variants[aVariantName].m_ExcludedFromSim;
1332 const wxString& aVariantName )
1334 if( !aInstance || aVariantName.IsEmpty() )
1342 wxCHECK_MSG( instance, ,
1343 wxString::Format( wxS(
"Cannot set exclude from board for invalid sheet path '%s'." ),
1346 if( aVariantName.IsEmpty() )
1352 if( instance->
m_Variants.contains( aVariantName )
1353 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromBoard ) )
1355 instance->
m_Variants[aVariantName].m_ExcludedFromBoard = aEnable;
1370 const wxString& aVariantName )
const
1372 if( !aInstance || aVariantName.IsEmpty() )
1380 if( instance.
m_Variants.contains( aVariantName ) )
1381 return instance.
m_Variants[aVariantName].m_ExcludedFromBoard;
1389 const wxString& aVariantName )
1391 if( !aInstance || aVariantName.IsEmpty() )
1399 wxCHECK_MSG( instance, ,
1400 wxString::Format( wxS(
"Cannot set exclude from pos files for invalid sheet path '%s'." ),
1403 if( aVariantName.IsEmpty() )
1409 if( instance->
m_Variants.contains( aVariantName )
1410 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromPosFiles ) )
1412 instance->
m_Variants[aVariantName].m_ExcludedFromPosFiles = aEnable;
1427 const wxString& aVariantName )
const
1429 if( !aInstance || aVariantName.IsEmpty() )
1437 if( instance.
m_Variants.contains( aVariantName ) )
1438 return instance.
m_Variants[aVariantName].m_ExcludedFromPosFiles;
1448 instance.m_Unit = aUnitSelection;
1453 bool aAllowExtraText,
const wxString& aVariantName )
const
1455 if( aVariantName.IsEmpty() )
1463 std::optional variant =
GetVariant( *aInstance, aVariantName );
1477 const wxString& aVariantName )
1479 if( !aInstance || aVariantName.IsEmpty() )
1487 wxCHECK( instance, );
1491 if( instance->
m_Variants.contains( aVariantName ) )
1493 instance->
m_Variants[aVariantName].m_Fields[fieldName] = aValue;
1500 newVariant.
m_Fields[fieldName] = aValue;
1501 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
1507 bool aAllowExtraText,
const wxString& aVariantName )
const
1527 m_fields.emplace_back(
this, aFieldType );
1556 if( !field.IsVisible() || field.GetText().IsEmpty() )
1560 aVector.push_back(
const_cast<SCH_FIELD*
>( &field ) );
1563 std::sort( aVector.begin(), aVector.end(),
1566 return lhs->GetOrdinal() < rhs->GetOrdinal();
1586 for(
unsigned ii = 0; ii <
m_fields.size(); ++ii )
1591 if( aFieldName ==
m_fields[ii].GetName(
false ) )
1604 if( field.GetName().IsSameAs( aFieldName,
false ) )
1613 bool aResetRef,
bool aResetOtherFields )
1617 std::vector<SCH_FIELD*> fields;
1618 m_part->GetFields( fields );
1620 for(
const SCH_FIELD* libField : fields )
1625 if( libField->IsMandatory() )
1627 fieldType = libField->GetId();
1632 schField =
GetField( libField->GetCanonicalName() );
1642 schField->
SetPrivate( libField->IsPrivate() );
1654 else if( aUpdateRef )
1655 SetRef( aPath, libField->GetText() );
1663 if( aResetOtherFields )
1665 else if( aUpdateOtherFields )
1666 schField->
SetText( libField->GetText() );
1670 if( aResetOtherFields || aUpdateOtherFields )
1671 schField->
SetText( libField->GetText() );
1681 bool updateValue =
true;
1682 bool updateExclFromBOM =
true;
1683 bool updateExclFromBoard =
true;
1684 bool updateExclFromPosFiles =
true;
1685 bool updateDNP =
true;
1686 bool updateOtherFields =
true;
1687 bool updatePins =
true;
1691 updateValue = aProperty->
Name() ==
_HKI(
"Value" );
1692 updateExclFromBoard = aProperty->
Name() ==
_HKI(
"Exclude From Board" );
1693 updateExclFromBOM = aProperty->
Name() ==
_HKI(
"Exclude From Bill of Materials" );
1694 updateExclFromPosFiles = aProperty->
Name() ==
_HKI(
"Exclude From Position Files" );
1695 updateDNP = aProperty->
Name() ==
_HKI(
"Do not Populate" );
1696 updateOtherFields =
false;
1700 if( !updateValue && !updateExclFromBOM && !updateExclFromBoard && !updateExclFromPosFiles && !updateDNP && !updateOtherFields && !updatePins )
1709 wxString ref =
GetRef( &aSourceSheet );
1714 std::vector<SCH_SYMBOL*> otherUnits;
1720 aCommit.
Modify( otherUnit, screen );
1725 if( updateOtherFields )
1737 if( field.IsMandatory() )
1738 otherField = otherUnit->GetField( field.GetId() );
1740 otherField = otherUnit->GetField( field.GetName() );
1744 otherField->
SetText( field.GetText() );
1752 newField.
Offset( otherUnit->GetPosition() );
1755 otherUnit->AddField( newField );
1759 for(
int ii = (
int) otherUnit->GetFields().size() - 1; ii >= 0; ii-- )
1761 SCH_FIELD& otherField = otherUnit->GetFields()[ii];
1764 otherUnit->GetFields().erase( otherUnit->GetFields().begin() + ii );
1768 if( updateExclFromBOM )
1771 if( updateExclFromBoard )
1774 if( updateExclFromPosFiles )
1778 otherUnit->SetDNP(
GetDNP( &aSourceSheet, aVariantName ), &sheet, aVariantName );
1782 for(
const std::unique_ptr<SCH_PIN>& model_pin :
m_pins )
1784 for(
SCH_PIN* src_pin : otherUnit->GetPinsByNumber( model_pin->GetNumber() ) )
1785 src_pin->SetAlt( model_pin->GetAlt() );
1796 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1797 aFunction(
pin.get() );
1800 aFunction( &field );
1806 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1808 if(
pin->GetNumber() == aNumber )
1818 std::vector<SCH_PIN*> pins;
1820 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1822 if(
pin->GetNumber() == aNumber )
1823 pins.push_back(
pin.get() );
1832 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1834 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
1835 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
1837 if( pin_unit > 0 && pin_unit !=
GetUnit() )
1840 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
1843 if(
pin->GetPosition() == aPos )
1856 return std::vector<SCH_PIN*>();
1863 return m_part->GetPins();
1865 return std::vector<SCH_PIN*>();
1877 auto it =
m_pinMap.find( aLibPin );
1882 wxFAIL_MSG_AT(
"Pin not found", __FILE__, __LINE__, __FUNCTION__ );
1889 std::vector<const SCH_PIN*> pins;
1898 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1900 if( unit &&
pin->GetUnit() &&
pin->GetUnit() != unit )
1903 pins.push_back(
pin.get() );
1912 std::vector<SCH_PIN*> pins;
1921 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1923 if( unit &&
pin->GetUnit() &&
pin->GetUnit() != unit )
1926 pins.push_back(
pin.get() );
1942 wxCHECK_RET( aItem !=
nullptr && aItem->
Type() ==
SCH_SYMBOL_T, wxT(
"Cannot swap data with invalid symbol." ) );
1950 for( std::unique_ptr<SCH_PIN>&
pin : symbol->
m_pins )
1951 pin->SetParent( symbol );
1953 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1954 pin->SetParent(
this );
1959 m_part.reset( libSymbol );
1992 if( field.IsPrivate() )
1995 if( field.IsMandatory() )
1996 aVars->push_back( field.GetCanonicalName().Upper() );
1998 aVars->push_back( field.GetName() );
2001 aVars->push_back( wxT(
"OP" ) );
2002 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
2003 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
2004 aVars->push_back( wxT(
"UNIT" ) );
2005 aVars->push_back( wxT(
"SHORT_REFERENCE" ) );
2006 aVars->push_back( wxT(
"SYMBOL_LIBRARY" ) );
2007 aVars->push_back( wxT(
"SYMBOL_NAME" ) );
2008 aVars->push_back( wxT(
"SYMBOL_DESCRIPTION" ) );
2009 aVars->push_back( wxT(
"SYMBOL_KEYWORDS" ) );
2010 aVars->push_back( wxT(
"EXCLUDE_FROM_BOM" ) );
2011 aVars->push_back( wxT(
"EXCLUDE_FROM_BOARD" ) );
2012 aVars->push_back( wxT(
"EXCLUDE_FROM_SIM" ) );
2013 aVars->push_back( wxT(
"DNP" ) );
2014 aVars->push_back( wxT(
"SHORT_NET_NAME(<pin_number>)" ) );
2015 aVars->push_back( wxT(
"NET_NAME(<pin_number>)" ) );
2016 aVars->push_back( wxT(
"NET_CLASS(<pin_number>)" ) );
2017 aVars->push_back( wxT(
"PIN_NAME(<pin_number>)" ) );
2018 aVars->push_back( wxT(
"REFERENCE(<pin_number>)" ) );
2019 aVars->push_back( wxT(
"SHORT_REFERENCE(<pin_number>)" ) );
2020 aVars->push_back( wxT(
"UNIT(<pin_number>)" ) );
2031 const wxString& aVariantName,
int aDepth )
const
2033 static wxRegEx operatingPoint( wxT(
"^"
2048 wxString variant = aVariantName.IsEmpty() ? schematic->GetCurrentVariant() : aVariantName;
2050 if( operatingPoint.Matches( *token ) )
2052 wxString
pin( operatingPoint.GetMatch( *token, 1 ).Lower() );
2053 wxString precisionStr( operatingPoint.GetMatch( *token, 3 ) );
2054 wxString rangeStr( operatingPoint.GetMatch( *token, 4 ) );
2056 int precision = precisionStr.IsEmpty() ? 3 : precisionStr[0] -
'0';
2057 wxString range = rangeStr.IsEmpty() ? wxString( wxS(
"~A" ) ) : rangeStr;
2061 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
2062 embeddedFilesStack.push_back( schematic->GetEmbeddedFiles() );
2065 embeddedFilesStack.push_back(
m_part->GetEmbeddedFiles() );
2071 aVariantName, devnull ).model;
2075 wxString spiceRef =
model.SpiceGenerator().ItemName( spiceItem );
2076 spiceRef = spiceRef.Lower();
2080 *token = schematic->GetOperatingPoint( spiceRef, precision, range );
2083 else if(
pin == wxS(
":power" ) )
2085 if( rangeStr.IsEmpty() )
2086 range = wxS(
"~W" );
2088 *token = schematic->GetOperatingPoint( spiceRef + wxS(
":power" ), precision, range );
2093 pin =
pin.SubString( 1, -1 );
2095 for(
const std::reference_wrapper<const SIM_MODEL_PIN>& modelPin :
model.GetPins() )
2097 SCH_PIN* symbolPin =
GetPin( modelPin.get().symbolPinNumber );
2101 if(
model.GetPins().size() == 2 )
2103 *token = schematic->GetOperatingPoint( spiceRef, precision, range );
2107 wxString signalName = spiceRef + wxS(
":" ) + modelPin.get().modelPinName;
2108 *token = schematic->GetOperatingPoint( signalName, precision, range );
2116 *token = wxS(
"?" );
2120 if( token->Contains(
':' ) )
2122 if( schematic->ResolveCrossReference( token, aDepth + 1 ) )
2128 wxString fieldName = field.IsMandatory() ? field.GetCanonicalName() : field.GetName();
2130 wxString textToken = field.GetText();
2131 textToken.Replace(
" ", wxEmptyString );
2132 wxString tokenString =
"${" + fieldName +
"}";
2135 if( textToken.IsSameAs( tokenString,
false ) )
2138 if( token->IsSameAs( fieldName,
false ) )
2142 *token =
GetRef( aPath,
true );
2144 else if( !aVariantName.IsEmpty() )
2147 std::optional<SCH_SYMBOL_VARIANT> symVariant =
GetVariant( *aPath, aVariantName );
2149 if( symVariant && symVariant->m_Fields.contains( fieldName ) )
2150 *token = symVariant->m_Fields.at( fieldName );
2152 *token = field.GetShownText( aPath,
false, aDepth + 1 );
2156 *token = field.GetShownText( aPath,
false, aDepth + 1 );
2164 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
2165 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
2166 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
2168 *token = wxEmptyString;
2173 schematic->Settings().m_TemplateFieldNames.GetTemplateFieldNames() )
2175 if( token->IsSameAs( templateFieldname.m_Name ) || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
2179 *token = wxEmptyString;
2184 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
2188 wxArrayString parts = wxSplit( footprint,
':' );
2190 if( parts.Count() > 0 )
2193 *token = wxEmptyString;
2197 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
2201 wxArrayString parts = wxSplit( footprint,
':' );
2203 if( parts.Count() > 1 )
2204 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
2206 *token = wxEmptyString;
2210 else if( token->IsSameAs( wxT(
"UNIT" ) ) )
2215 else if( token->IsSameAs( wxT(
"SHORT_REFERENCE" ) ) )
2217 *token =
GetRef( aPath,
false );
2220 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
2222 *token =
m_lib_id.GetUniStringLibNickname();
2225 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
2227 *token =
m_lib_id.GetUniStringLibItemName();
2230 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
2235 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
2240 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
2242 *token = wxEmptyString;
2244 if( aPath->
GetExcludedFromBOM( variant ) || this->ResolveExcludedFromBOM( aPath, variant ) )
2245 *token =
_(
"Excluded from BOM" );
2249 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
2251 *token = wxEmptyString;
2253 if( aPath->
GetExcludedFromBoard( variant ) || this->ResolveExcludedFromBoard( aPath, variant ) )
2254 *token =
_(
"Excluded from board" );
2258 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
2260 *token = wxEmptyString;
2262 if( aPath->
GetExcludedFromSim( variant ) || this->ResolveExcludedFromSim( aPath, variant ) )
2263 *token =
_(
"Excluded from simulation" );
2267 else if( token->IsSameAs( wxT(
"DNP" ) ) )
2269 *token = wxEmptyString;
2271 if( aPath->
GetDNP( variant ) || this->ResolveDNP( aPath, variant ) )
2272 *token =
_(
"DNP" );
2276 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) ) || token->StartsWith( wxT(
"NET_NAME(" ) )
2277 || token->StartsWith( wxT(
"NET_CLASS(" ) ) || token->StartsWith( wxT(
"PIN_NAME(" ) )
2278 || token->StartsWith( wxT(
"PIN_BASE_NAME(" ) ) || token->StartsWith( wxT(
"PIN_ALT_LIST(" ) )
2279 || token->StartsWith( wxT(
"REFERENCE(" ) ) || token->StartsWith( wxT(
"SHORT_REFERENCE(" ) )
2280 || token->StartsWith( wxT(
"UNIT(" ) ) )
2282 wxString pinNumber = token->AfterFirst(
'(' );
2283 pinNumber = pinNumber.BeforeLast(
')' );
2285 bool isReferenceFunction = token->StartsWith( wxT(
"REFERENCE(" ) );
2286 bool isShortReferenceFunction = token->StartsWith( wxT(
"SHORT_REFERENCE(" ) );
2287 bool isUnitFunction = token->StartsWith( wxT(
"UNIT(" ) );
2291 std::vector<const SCH_PIN*> pinsToSearch;
2292 std::vector<const SCH_PIN*> altPinsToSearch;
2294 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
2297 pinsToSearch.push_back(
pin );
2302 pinsToSearch.push_back(
pin );
2305 altPinsToSearch.push_back(
pin );
2310 if(
pin->GetNumber() == pinNumber )
2312 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
2314 int pinUnit =
pin->GetUnit();
2317 if( isReferenceFunction )
2325 else if( isShortReferenceFunction )
2330 else if( isUnitFunction )
2342 else if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
2344 *token =
pin->GetAlt().IsEmpty() ?
pin->GetName() :
pin->GetAlt();
2347 else if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
2349 *token =
pin->GetBaseName();
2352 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
2357 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
2359 for(
const auto& [altName, altDef] : alts )
2361 if( !altList.IsEmpty() )
2362 altList += wxT(
", " );
2374 *token = wxEmptyString;
2376 else if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
2379 if( netName.Lower().StartsWith( wxT(
"unconnected" ) ) )
2380 *token = wxT(
"NC" );
2384 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
2386 *token = conn->
Name();
2388 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
2390 *token =
pin->GetEffectiveNetClass( aPath )->GetName();
2400 if(
pin->GetNumber() == pinNumber )
2403 if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
2405 *token =
pin->GetBaseName();
2408 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
2413 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
2415 for(
const auto& [altName, altDef] : alts )
2417 if( !altList.IsEmpty() )
2418 altList += wxT(
", " );
2427 int pinUnit =
pin->GetUnit();
2443 if( symbol->
GetRef( &sheetPath,
false ) ==
GetRef( aPath,
false )
2446 targetPath = sheetPath;
2447 targetSymbol = symbol;
2460 *token = wxString::Format( wxT(
"<Unit %s not placed>" ),
SubReference( pinUnit,
false ) );
2466 SCH_PIN* instancePin =
nullptr;
2470 if( candidate->GetNumber() == pinNumber )
2472 instancePin = candidate;
2479 *token = wxEmptyString;
2484 if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
2486 *token = instancePin->
GetAlt().IsEmpty() ? instancePin->
GetName() : instancePin->
GetAlt();
2495 *token = wxEmptyString;
2497 else if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
2500 if( netName.Lower().StartsWith( wxT(
"unconnected" ) ) )
2501 *token = wxT(
"NC" );
2505 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
2507 *token = conn->
Name();
2509 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
2519 *token = wxString::Format( wxT(
"<Unresolved: pin %s>" ), pinNumber );
2539 if( instance.m_Path ==
path )
2541 if( instance.m_Reference.IsEmpty() || aResetPrefix )
2552 if( instance.m_Reference.IsEmpty() || aResetPrefix )
2559 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2560 pin->ClearDefaultNetName( aSheetPath );
2570 if( currentReference.IsEmpty() || aResetPrefix )
2581 wxCHECK( aSheetPath.size() > 0,
false );
2586 if( instance.m_Path == aSheetPath )
2599 bool transform =
false;
2601 switch( aOrientation )
2722 wxFAIL_MSG(
"Invalid schematic symbol orientation type." );
2776 for(
int type_rotate : rotate_values )
2788 wxFAIL_MSG(
"Schematic symbol orientation matrix internal error." );
2796void SCH_SYMBOL::Show(
int nestLevel, std::ostream& os )
const
2799 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
" ref=\""
2805 for(
int i = 1; i < (int)
GetFields().size(); ++i )
2807 const wxString& value =
GetFields()[i].GetText();
2809 if( !value.IsEmpty() )
2811 NestedSpace( nestLevel + 1, os ) <<
"<field" <<
" name=\"" <<
TO_UTF8(
GetFields()[i].GetName() ) <<
'"'
2812 <<
" value=\"" <<
TO_UTF8( value ) <<
"\"/>\n";
2816 NestedSpace( nestLevel, os ) <<
"</" <<
TO_UTF8(
GetClass().Lower() ) <<
">\n";
2836 if( aIncludeFields )
2840 if( field.IsVisible() )
2841 bBox.
Merge( field.GetBoundingBox() );
2855 catch(
const boost::bad_pointer& e )
2857 wxFAIL_MSG( wxString::Format( wxT(
"Boost pointer exception occurred: %s" ), e.what() ) );
2883 auto addExcludes = [&]()
2888 msgs.Add(
_(
"Simulation" ) );
2891 msgs.Add(
_(
"BOM" ) );
2894 msgs.Add(
_(
"Board" ) );
2896 if(
GetDNP( currentSheet, currentVariant ) )
2897 msgs.Add(
_(
"DNP" ) );
2899 msg = wxJoin( msgs,
'|' );
2900 msg.Replace(
'|', wxS(
", " ) );
2903 aList.emplace_back(
_(
"Exclude from" ), msg );
2914 aList.emplace_back(
_(
"Power symbol" ),
2922 aList.emplace_back(
_(
"Value" ),
2929 aList.emplace_back(
_(
"flags" ), wxString::Format(
"%X",
GetEditFlags() ) );
2934 msg =
_(
"Missing parent" );
2936 std::shared_ptr<LIB_SYMBOL> parent =
m_part->GetParent().lock();
2939 msg = parent->GetName();
2943 else if( !
m_lib_id.GetLibNickname().empty() )
2945 aList.emplace_back(
_(
"Library" ),
m_lib_id.GetLibNickname() );
2949 aList.emplace_back(
_(
"Library" ),
_(
"Undefined!!!" ) );
2957 msg =
_(
"<Unknown>" );
2959 aList.emplace_back(
_(
"Footprint" ), msg );
2963 _(
"Keywords" ) + wxT(
": " ) +
m_part->GetKeyWords() );
2968 aList.emplace_back(
_(
"Reference" ),
GetRef( currentSheet ) );
2977 if( libNickname.empty() )
2978 msg =
_(
"No library defined!" );
2980 msg.Printf(
_(
"Symbol not found in %s!" ), libNickname );
2982 aList.emplace_back(
_(
"Library" ), msg );
3017 field.SetTextPos( pos );
3035 field.SetTextPos( pos );
3054 field.SetTextPos( pos );
3082 if( field.Matches( aSearchData, aAuxData ) )
3092 if( drawItem.Matches( aSearchData, aAuxData ) )
3103 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3111 aItemList.push_back( item );
3117 std::vector<DANGLING_END_ITEM>& aItemListByPos,
const SCH_SHEET_PATH* aPath )
3119 bool changed =
false;
3121 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3123 bool previousState =
pin->IsDangling();
3124 pin->SetIsDangling(
true );
3129 bool do_break =
false;
3131 for(
auto it = lower; it < aItemListByPos.end() && it->GetPosition() == pos; it++ )
3150 pin->SetIsDangling(
false );
3161 changed = ( changed || ( previousState !=
pin->IsDangling() ) );
3186 wxCHECK( symbol,
false );
3192 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3194 if(
pin->IsDangling() )
3207 if(
GetRef( aInstance ) != symbol->
GetRef( aInstance ) )
3217 for(
size_t i = 0; i <
m_pins.size(); i++ )
3229 std::vector<VECTOR2I> retval;
3231 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3235 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
3236 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
3238 if( pin_unit > 0 && pin_unit !=
GetUnit() )
3241 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
3267 return wxString::Format(
_(
"Symbol %s [%s]" ),
3275 for(
KICAD_T scanType : aScanTypes )
3320 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3324 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
3325 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
3327 if( pin_unit > 0 && pin_unit !=
GetUnit() )
3330 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
3367 std::vector<SCH_FIELD*> fields, otherFields;
3370 aSymbol.
GetFields( otherFields,
false );
3372 if( fields.size() != otherFields.size() )
3375 for(
int ii = 0; ii < (int) fields.size(); ii++ )
3380 if( fields[ii]->GetText().Cmp( otherFields[ii]->GetText() ) != 0 )
3390 return !( *
this == aSymbol );
3396 wxCHECK_MSG(
Type() == aSymbol.
Type(), *
this,
3397 wxT(
"Cannot assign object type " ) + aSymbol.
GetClass() + wxT(
" to type " ) +
GetClass() );
3399 if( &aSymbol !=
this )
3416 field.SetParent(
this );
3428 bBox.
Inflate( aAccuracy / 2 );
3444 rect.
Inflate( aAccuracy / 2 );
3466 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3479 if(
pin->GetLocalPosition() == new_pos )
3494 const VECTOR2I& aOffset,
bool aDimmed )
3508 for(
unsigned i = 0; i < tempPins.size(); ++i )
3511 SCH_PIN* tempPin = tempPins[i];
3531 text->SetText(
dummy.GetShownText(
false ) );
3542 bool dnp =
GetDNP( sheet, variant );
3544 for(
bool local_background : {
true,
false } )
3550 field.ClearRenderCache();
3554 && ( field.IsVisible() || field.IsForceVisible() ) )
3567 std::vector<wxString> properties;
3571 wxString text_field = field.GetShownText( sheet,
false, 0, variant );
3573 if( text_field.IsEmpty() )
3576 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ), field.GetName(), text_field ) );
3579 if( !
m_part->GetKeyWords().IsEmpty() )
3581 properties.emplace_back(
3582 wxString::Format( wxT(
"!%s = %s" ),
_(
"Keywords" ),
m_part->GetKeyWords() ) );
3605 margins.
x = std::max( margins.
x * 0.6, margins.
y * 0.3 );
3606 margins.
y = std::max( margins.
y * 0.6, margins.
x * 0.3 );
3624 double lineWidth = aSize / 10.0;
3626 std::vector<SCH_SHAPE> shapeList;
3628 int tolerance = 100;
3630 for(
const SCH_SHAPE& shape : shapeList )
3636 aPlotter->
BezierCurve( shape.GetStart(), shape.GetBezierC1(), shape.GetBezierC2(), shape.GetEnd(),
3637 tolerance, lineWidth );
3639 aPlotter->
Circle( shape.getCenter(), shape.GetRadius() * 2, filled, lineWidth );
3699 for(
unsigned i = 0; i < tempPins.size(); ++i )
3702 SCH_PIN* tempPin = tempPins[i];
3720 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3722 if(
pin->IsBrightened() )
3732 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3733 pin->ClearBrightened();
3751 m_part->SetShowPinNames( aShow );
3764 m_part->SetShowPinNumbers( aShow );
3770 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3772 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
3773 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
3775 if( pin_unit > 0 && pin_unit !=
GetUnit() )
3778 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
3781 if(
pin->IsPointClickableAnchor( aPos ) )
3800 if( pin_list.size() != 1 )
3818 if( pin_list.size() != 1 )
3830 return m_part->IsLocalPower();
3839 return m_part->IsGlobalPower();
3851 wxCHECK(
m_part,
false );
3853 return m_part->IsNormal();
3859 std::unordered_set<wxString> componentClass;
3861 auto getComponentClassFields = [&](
const std::vector<SCH_FIELD>& fields )
3865 if( field.GetCanonicalName() == wxT(
"Component Class" ) )
3867 if( field.GetShownText( aPath,
false ) != wxEmptyString )
3868 componentClass.insert( field.GetShownText( aPath,
false ) );
3874 getComponentClassFields(
m_fields );
3881 getComponentClassFields( label->GetFields() );
3885 return componentClass;
3890 const wxString& aVariantName )
const
3895 return std::nullopt;
3897 return instance.
m_Variants.find( aVariantName )->second;
3909 instance->
m_Variants.insert( std::make_pair( aVariant.
m_Name, aVariant ) );
3918 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
3926 const wxString& aNewName )
3931 if( !instance || !instance->
m_Variants.contains( aOldName ) )
3936 variant.
m_Name = aNewName;
3938 instance->
m_Variants.insert( std::make_pair( aNewName, variant ) );
3943 const wxString& aNewVariant )
3948 if( !instance || !instance->
m_Variants.contains( aSourceVariant ) )
3953 variant.
m_Name = aNewVariant;
3954 instance->
m_Variants.insert( std::make_pair( aNewVariant, variant ) );
4004 for(
unsigned i = 0; i <
m_pins.size(); ++i )
4013 if( m_instanceReferences != symbol.m_instanceReferences )
4039 double aLineWidth,
bool aHorizontal )
4043 double x_right = aSize / 1.6180339887;
4044 double x_middle = x_right / 2.0;
4057 aShapeList.back().SetStart( bottomPt );
4058 aShapeList.back().SetBezierC1( bottomAnchorPt );
4059 aShapeList.back().SetBezierC2( leftSideAnchorPt1 );
4060 aShapeList.back().SetEnd( leftPt );
4064 aShapeList.back().SetStart( leftPt );
4065 aShapeList.back().SetBezierC1( leftSideAnchorPt2 );
4066 aShapeList.back().SetBezierC2( rightSideAnchorPt2 );
4067 aShapeList.back().SetEnd( rightPt );
4070 aShapeList.back().SetStart( rightPt );
4071 aShapeList.back().SetBezierC1( rightSideAnchorPt1 );
4072 aShapeList.back().SetBezierC2( bottomAnchorPt );
4073 aShapeList.back().SetEnd( bottomPt );
4076 aShapeList.back().SetCenter( ( leftPt + rightPt ) / 2.0 );
4077 aShapeList.back().SetRadius( aSize / 15.0 );
4082 shape.Rotate(
VECTOR2I( 0, 0 ),
true );
4093 if( instance.m_Path == aSheetPath )
4105 if( instance.m_Path == aSheetPath )
4143 auto hasLibPart = [](
INSPECTABLE* aItem ) ->
bool
4146 return symbol->GetLibSymbolRef() !=
nullptr;
4159 const wxString groupFields =
_HKI(
"Fields" );
4179 auto multiUnit = [=](
INSPECTABLE* aItem ) ->
bool
4182 return symbol->IsMultiUnit();
4187 auto multiBodyStyle = [=](
INSPECTABLE* aItem ) ->
bool
4190 return symbol->IsMultiBodyStyle();
4201 wxPGChoices choices;
4205 for(
int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
4206 choices.Add( symbol->GetUnitDisplayName( ii,
false ), ii );
4218 wxPGChoices choices;
4222 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
4223 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
4229 const wxString groupAttributes =
_HKI(
"Attributes" );
types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr const Vec GetEnd() const
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr coord_type GetX() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr ecoord_type GetArea() const
Return the area of the rectangle.
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr void Offset(coord_type dx, coord_type dy)
constexpr bool Intersects(const BOX2< Vec > &aRect) const
constexpr coord_type GetBottom() const
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
static std::vector< DANGLING_END_ITEM >::iterator get_lower_pos(std::vector< DANGLING_END_ITEM > &aItemListByPos, const VECTOR2I &aPos)
Helper class used to store the state of schematic items that can be connected to other schematic item...
DANGLING_END_T GetType() const
const EDA_ITEM * GetParent() const
bool IsHorizontal() const
The base class for create windows for drawing purpose.
EDA_ITEM_FLAGS GetEditFlags() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
virtual void SetParentGroup(EDA_GROUP *aGroup)
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * m_parent
Owner.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
const EDA_ANGLE & GetTextAngle() const
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 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
SCH_FIELD * GetField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName; return nullptr if not found.
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
static LIB_SYMBOL * GetDummy()
Returns a dummy LIB_SYMBOL, used when one is missing in the schematic.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void SetUnitCount(int aCount, bool aDuplicateDrawItems)
Set the units per symbol count.
void SetKeyWords(const wxString &aKeyWords)
void SetBodyStyleCount(int aCount, bool aDuplicateDrawItems, bool aDuplicatePins)
Set or clear the alternate body style (DeMorgan) for the symbol.
void SetFPFilters(const wxArrayString &aFilters)
const BOX2I GetBodyBoundingBox(int aUnit, int aBodyStyle, bool aIncludePins, bool aIncludePrivateItems) const
Get the symbol bounding box excluding fields.
EMBEDDED_FILES * GetEmbeddedFiles() override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
void SetLibId(const LIB_ID &aLibId)
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
const wxString GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
A singleton reporter that reports to nowhere.
Base plotter engine class.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width)=0
virtual void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
Create a bookmark to a symbol.
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness)
Generic fallback: Cubic Bezier curve rendered as a polyline.
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, void *aData)
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
virtual void SetColor(const COLOR4D &color)=0
virtual void EndBlock(void *aData)
calling this function allows one to define the end of a group of drawing items for instance in SVG or...
PROPERTY_BASE & SetChoicesFunc(std::function< wxPGChoices(INSPECTABLE *)> aFunc)
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
const wxString & Name() const
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Holds all the data relating to one schematic.
wxString GetCurrentVariant() const
Return the current variant being edited.
SCH_SHEET_PATH & CurrentSheet() const
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString LocalName() const
wxString Name(bool aIgnoreSheet=false) const
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
virtual const wxString & GetText() const override
Return the string associated with the text object.
void ImportValues(const SCH_FIELD &aSource)
Copy parameters from a SCH_FIELD source.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0, const wxString &aVariantName=wxEmptyString) const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetText(const wxString &aText) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void SetBodyStyle(int aBodyStyle)
void SetLocked(bool aLocked) override
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
void SetPrivate(bool aPrivate)
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
bool IsLocked() const override
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
void SetLayer(SCH_LAYER_ID aLayer)
virtual void SetUnit(int aUnit)
AUTOPLACE_ALGO m_fieldsAutoplaced
std::unordered_set< SCH_RULE_AREA * > m_rule_areas_cache
Store pointers to rule areas which this item is contained within.
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
ALT GetAlt(const wxString &aAlt)
void SetName(const wxString &aName)
const wxString & GetName() const
bool IsDangling() const override
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
void SetShape(GRAPHIC_PINSHAPE aShape)
VECTOR2I GetPosition() const override
const wxString & GetShownName() const
void SetType(ELECTRICAL_PINTYPE aType)
const wxString & GetNumber() const
GRAPHIC_PINSHAPE GetShape() const
ELECTRICAL_PINTYPE GetType() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool GetExcludedFromBOM() const
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false, bool aEscapeSheetNames=false) const
Return the sheet path in a human readable form made from the sheet names.
bool GetExcludedFromSim() const
bool GetExcludedFromBoard() const
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
size_t size() const
Forwarded method from std::vector.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Variant information for a schematic symbol.
void InitializeAttributes(const SCH_SYMBOL &aSymbol)
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the display name for a given unit aUnit.
SCH_SYMBOL & operator=(const SCH_SYMBOL &aItem)
size_t GetFullPinCount() const
std::vector< SCH_SYMBOL_INSTANCE > m_instances
Define the hierarchical path and reference of the symbol.
void UpdatePrefix()
Set the prefix based on the current reference designator.
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
wxString GetDescription() const override
std::unordered_map< SCH_PIN *, SCH_PIN * > m_pinMap
Library pin pointer : SCH_PIN indices.
void SetMirrorX(bool aMirror)
bool IsSymbolLikePowerGlobalLabel() const
EMBEDDED_FILES * GetEmbeddedFiles() override
SCH_SYMBOLs don't currently support embedded files, but their LIB_SYMBOL counterparts do.
wxString GetSymbolIDAsString() const
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool GetShowPinNumbers() const override
wxString GetDatasheet() const
Return the documentation text for the given part alias.
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void SetLibId(const LIB_ID &aName)
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the symbol's fields.
BOX2I GetBodyAndPinsBoundingBox() const override
Return a bounding box for the symbol body and pins but not the fields.
wxString GetBodyStyleProp() const override
void SetRefProp(const wxString &aRef)
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
virtual void SetDNP(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
SCH_ITEM * GetDrawItem(const VECTOR2I &aPosition, KICAD_T aType=TYPE_NOT_INIT)
Return the symbol library item at aPosition that is part of this symbol.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void SetPosition(const VECTOR2I &aPosition) override
void PlotDNP(PLOTTER *aPlotter) const
Plot the red 'X' over the symbol.
bool operator!=(const SCH_SYMBOL &aSymbol) const
void SetShowPinNumbers(bool aShow) override
Set or clear the pin number visibility flag.
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
SCH_SYMBOL_INSTANCE * getInstance(const KIID_PATH &aPath)
wxString SubReference(int aUnit, bool aAddSeparator=true) const
wxString GetClass() const override
Return the class name.
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
void SetFieldText(const wxString &aFieldName, const wxString &aFieldText, const SCH_SHEET_PATH *aPath=nullptr, const wxString &aVariantName=wxEmptyString)
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
void SetMirrorY(bool aMirror)
void SetBodyStyleProp(const wxString &aBodyStyle) override
std::vector< SCH_PIN * > GetPins() const override
bool GetExcludedFromPosFilesProp() const
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
wxString GetFieldText(const wxString &aFieldName, const SCH_SHEET_PATH *aPath=nullptr, const wxString &aVariantName=wxEmptyString) const
void SetExcludedFromSim(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
void SetExcludedFromSimProp(bool aEnable)
void SetBodyStyle(int aBodyStyle) override
void SetShowPinNames(bool aShow) override
Set or clear the pin name visibility flag.
wxString GetKeyWords() const override
wxString GetSchSymbolLibraryName() const
wxString GetShownKeyWords(int aDepth=0) const override
std::optional< SCH_SYMBOL_VARIANT > GetVariant(const SCH_SHEET_PATH &aInstance, const wxString &aVariantName) const
bool GetExcludedFromBoardProp() const
void ClearBrightenedPins()
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
bool GetExcludedFromSimProp() const
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool IsGlobalPower() const override
wxString GetRefProp() const
wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const override
bool AddSheetPathReferenceEntryIfMissing(const KIID_PATH &aSheetPath)
Add an instance to the alternate references list (m_instances), if this entry does not already exist.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void SetExcludedFromBOMProp(bool aEnable)
static std::unordered_map< TRANSFORM, int > s_transformToOrientationCache
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
Search for a SCH_FIELD with aFieldName.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
void UpdateFields(const SCH_SHEET_PATH *aPath, bool aUpdateStyle, bool aUpdateRef, bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields)
Restore fields to the original library values.
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const override
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
void RenameVariant(const KIID_PATH &aPath, const wxString &aOldName, const wxString &aNewName)
void SetOrientationProp(SYMBOL_ORIENTATION_PROP aAngle)
Orientation/mirroring access for property manager.
bool GetShowPinNames() const override
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
bool HasDeMorganBodyStyles() const override
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
std::vector< SCH_PIN * > GetAllLibPins() const
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const
int GetBodyStyleCount() const override
Return the number of body styles of the symbol.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void PlotPins(PLOTTER *aPlotter, bool aDnp) const
Plot just the symbol pins.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetFootprintFieldText(const wxString &aFootprint)
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
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 SetExcludedFromPosFiles(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
void SyncOtherUnits(const SCH_SHEET_PATH &aSourceSheet, SCH_COMMIT &aCommit, PROPERTY_BASE *aProperty, const wxString &aVariantName=wxEmptyString)
Keep fields other than the reference, include/exclude flags, and alternate pin assignments in sync in...
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
void SetExcludedFromPosFilesProp(bool aEnable)
wxString GetShownDescription(int aDepth=0) const override
const LIB_ID & GetLibId() const override
bool operator<(const SCH_ITEM &aItem) const override
static void BuildLocalPowerIconShape(std::vector< SCH_SHAPE > &aShapeList, const VECTOR2D &aPos, double aSize, double aLineWidth, bool aHorizontal)
Build the local power pin indicator icon shape, at coordinate aPos.
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
void SetValueProp(const wxString &aValue)
void SetUnitProp(int aUnit)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void SetValueFieldText(const wxString &aValue, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
std::vector< SCH_PIN * > GetLibPins() const
Populate a vector with all the pins from the library object that match the current unit and bodyStyle...
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test if the symbol's dangling state has changed for all pins.
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
void AddVariant(const SCH_SHEET_PATH &aInstance, const SCH_SYMBOL_VARIANT &aVariant)
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
void SetDNPProp(bool aEnable)
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
std::vector< SCH_PIN * > GetPinsByNumber(const wxString &aNumber) const
Find all symbol pins with the given number.
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool m_isInNetlist
True if the symbol should appear in netlist.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
wxString GetValueProp() const
bool IsLocalPower() const override
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
int GetUnitCount() const override
Return the number of units per package of the symbol.
void SetPrefix(const wxString &aPrefix)
int GetOrientation() const override
Get the display symbol orientation.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
bool IsSymbolLikePowerLocalLabel() const
bool GetExcludedFromBOMProp() const
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
void SetExcludedFromBoardProp(bool aEnable)
void SetExcludedFromBOM(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
void PlotLocalPowerIconShape(PLOTTER *aPlotter) const
Plot the local power pin indicator icon shape.
bool IsNormal() const override
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
std::unordered_set< wxString > GetComponentClassNames(const SCH_SHEET_PATH *aPath) const
Return the component classes this symbol belongs in.
std::vector< std::unique_ptr< SCH_PIN > > m_pins
A SCH_PIN for every #LIB_PIN.
void DeleteVariant(const KIID_PATH &aPath, const wxString &aVariantName)
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
VECTOR2I GetPinPhysicalPosition(const SCH_PIN *Pin) const
BOX2I GetBodyBoundingBox() const override
Return a bounding box for the symbol body but not the pins or fields.
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
bool IsPower() const override
void SetExcludedFromBoard(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void CopyVariant(const KIID_PATH &aPath, const wxString &aSourceVariant, const wxString &aNewVariant)
bool operator==(const SCH_SYMBOL &aSymbol) const
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
A base class for LIB_SYMBOL and SCH_SYMBOL.
bool m_DNP
True if symbol is set to 'Do Not Populate'.
bool m_excludedFromPosFiles
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
const TRANSFORM & GetTransform() const
int GetPinNameOffset() const
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
virtual bool GetShowPinNames() const
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
SYMBOL & operator=(const SYMBOL &aItem)
virtual bool GetShowPinNumbers() const
TRANSFORM m_transform
The rotation/mirror transformation.
std::map< wxString, wxString > m_Fields
bool m_ExcludedFromPosFiles
A type-safe container of any type.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
T Convert(const wxString &aValue)
Convert a wxString to a generic type T.
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
static constexpr EDA_ANGLE ANGLE_270
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define IS_DANGLING
indicates a pin is dangling
@ FILLED_SHAPE
Fill with object color.
a few functions useful in geometry calculations.
const wxChar *const traceSchSymbolRef
Flag to enable debug output of schematic symbol reference resolution.
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
SCH_LAYER_ID
Eeschema drawing layers.
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Message panel definition file.
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API std::optional< KICAD_T > TypeNameFromAny(const google::protobuf::Any &aMessage)
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackDistance(types::Distance &aOutput, int aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackLibId(types::LibraryIdentifier *aOutput, const LIB_ID &aId)
KICOMMON_API LIB_ID UnpackLibId(const types::LibraryIdentifier &aId)
@ PT_NC
not connected (must be left open)
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
#define NO_SETTER(owner, type)
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
Collection of utility functions for component reference designators (refdes)
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
const SCH_FIELD * FindField(const std::vector< SCH_FIELD > &aFields, FIELD_T aFieldId)
int NextFieldOrdinal(const std::vector< SCH_FIELD > &aFields)
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
static void plotLocalPowerIcon(PLOTTER *aPlotter, const VECTOR2D &aPos, double aSize, bool aRotate)
plot a local power pin indicator icon.
static struct SCH_SYMBOL_DESC _SCH_SYMBOL_DESC
std::vector< FAB_LAYER_COLOR > dummy
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