49#include <api/schematic/schematic_types.pb.h>
66 std::string ret =
TO_UTF8( txt );
70 if( (
unsigned char) c <=
' ' )
97 std::unique_ptr<LIB_SYMBOL> part;
128 SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.
Convert, aPosition, aParent )
131 for(
const auto& [fieldId, fieldValue] : aSel.
Fields )
133 if( fieldId == FIELD_T::REFERENCE )
134 SetRef( aSheet, fieldValue );
135 else if( SCH_FIELD* field = GetField( fieldId ) )
136 field->SetText( fieldValue );
163 field.SetParent(
this );
168 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol.
m_pins )
170 m_pins.emplace_back( std::make_unique<SCH_PIN>( *pin ) );
171 m_pins.back()->SetParent( this );
227 using namespace kiapi::schematic::types;
229 SchematicSymbolInstance symbol;
231 symbol.mutable_id()->set_value(
m_Uuid.AsStdString() );
233 symbol.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
235 SchematicSymbolTransform* transform = symbol.mutable_transform();
236 transform->set_orientation(
242 symbol.mutable_body_style()->set_style(
GetBodyStyle() );
244 SchematicSymbol* def = symbol.mutable_definition();
247 google::protobuf::Any
any;
250 any.UnpackTo( symbol.mutable_reference_field() );
253 any.UnpackTo( symbol.mutable_value_field() );
256 any.UnpackTo( symbol.mutable_footprint_field() );
259 any.UnpackTo( symbol.mutable_datasheet_field() );
262 any.UnpackTo( symbol.mutable_description_field() );
267 any.UnpackTo( def->mutable_reference_field() );
270 any.UnpackTo( def->mutable_value_field() );
273 any.UnpackTo( def->mutable_footprint_field() );
276 any.UnpackTo( def->mutable_datasheet_field() );
279 any.UnpackTo( def->mutable_description_field() );
291 SchematicSymbolChild* item = def->add_items();
292 item->mutable_unit()->set_unit( drawItem.GetUnit() );
293 item->mutable_body_style()->set_style( drawItem.GetBodyStyle() );
294 item->set_is_private( drawItem.IsPrivate() );
295 drawItem.Serialize( *item->mutable_item() );
298 def->set_unit_count(
m_part->GetUnitCount() );
299 def->set_body_style_count(
m_part->GetBodyStyleCount() );
300 def->set_keywords(
m_part->GetKeyWords().ToUTF8() );
303 def->add_footprint_filters(
filter.ToUTF8() );
311 aContainer.PackFrom( symbol );
318 using namespace kiapi::common::types;
319 using namespace kiapi::schematic::types;
321 SchematicSymbolInstance symbol;
323 if( !aContainer.UnpackTo( &symbol ) )
328 SetLocked( symbol.locked() == LockedState::LS_LOCKED );
334 const SchematicSymbol& def = symbol.definition();
342 google::protobuf::Any
any;
344 any.PackFrom( def.reference_field() );
347 any.PackFrom( def.value_field() );
350 any.PackFrom( def.footprint_field() );
353 any.PackFrom( def.datasheet_field() );
356 any.PackFrom( def.description_field() );
359 std::unordered_map<::KIID, wxString> pinAltMap;
361 for(
const SchematicSymbolChild& child : def.items() )
370 if( !item || !item->Deserialize( child.item() ) )
377 SchematicPin pinProto;
379 if( child.item().UnpackTo( &pinProto ) )
381 if( pinProto.has_active_alternate() )
382 pinAltMap[schItem->
m_Uuid] = wxString::FromUTF8( pinProto.active_alternate() );
386 if( child.has_unit() )
387 schItem->
SetUnit( child.unit().unit() );
389 if( child.has_body_style() )
397 if( def.unit_count() > 0 )
400 if( def.body_style_count() > 0 )
403 if( !def.keywords().empty() )
404 libSymbol->
SetKeyWords( wxString::FromUTF8( def.keywords() ) );
406 if( def.footprint_filters_size() > 0 )
408 wxArrayString filters;
410 for(
const std::string&
filter : def.footprint_filters() )
411 filters.Add( wxString::FromUTF8(
filter ) );
418 if( symbol.has_body_style() )
421 any.PackFrom( symbol.reference_field() );
424 any.PackFrom( symbol.value_field() );
427 any.PackFrom( symbol.footprint_field() );
430 any.PackFrom( symbol.datasheet_field() );
433 any.PackFrom( symbol.description_field() );
451 m_pins.emplace_back( std::make_unique<SCH_PIN>( *
pin ) );
452 m_pins.back()->SetParent(
this );
463 if( pinAltMap.contains(
pin->m_Uuid ) )
464 pin->SetAlt( pinAltMap.at(
pin->m_Uuid ) );
483 const int min_grid_size =
schIUScale.MilsToIU( 25 );
485 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
487 if( ( (
pin->GetPosition().x -
m_pos.x ) % min_grid_size ) != 0 )
490 if( ( (
pin->GetPosition().y -
m_pos.y ) % min_grid_size ) != 0 )
515 wxCHECK2( !aLibSymbol || aLibSymbol->
IsRoot(), aLibSymbol =
nullptr );
517 m_part.reset( aLibSymbol );
522 pin->SetLibPin(
nullptr );
531 return m_part->GetDescription();
533 return wxEmptyString;
540 return m_part->GetShownDescription( aDepth );
542 return wxEmptyString;
549 return m_part->GetKeyWords();
551 return wxEmptyString;
558 return m_part->GetShownKeyWords( aDepth );
560 return wxEmptyString;
567 return m_part->GetDatasheetField().GetText();
569 return wxEmptyString;
575 std::map<wxString, wxString> altPinMap;
576 std::map<wxString, SCH_PIN::ALT> altPinDefs;
577 std::map<wxString, std::set<SCH_PIN*>> pinUuidMap;
578 std::set<SCH_PIN*> unassignedSchPins;
579 std::set<SCH_PIN*> unassignedLibPins;
581 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
583 pinUuidMap[
pin->GetNumber()].insert(
pin.get() );
585 unassignedSchPins.insert(
pin.get() );
587 if( !
pin->GetAlt().IsEmpty() )
589 altPinMap[
pin->GetNumber()] =
pin->GetAlt();
590 auto altDefIt =
pin->GetAlternates().find(
pin->GetAlt() );
592 if( altDefIt !=
pin->GetAlternates().end() )
593 altPinDefs[
pin->GetNumber()] = altDefIt->second;
596 pin->SetLibPin(
nullptr );
613 auto ii = pinUuidMap.find( libPin->GetNumber() );
615 if( ii == pinUuidMap.end() || ii->second.empty() )
617 unassignedLibPins.insert( libPin );
621 auto it = ii->second.begin();
623 ii->second.erase( it );
624 pin->GetAlternates() = libPin->GetAlternates();
625 pin->SetLibPin( libPin );
626 pin->SetPosition( libPin->GetPosition() );
627 pin->SetUnit( libPin->GetUnit() );
628 pin->SetBodyStyle( libPin->GetBodyStyle() );
630 unassignedSchPins.erase(
pin );
632 auto iii = altPinMap.find( libPin->GetNumber() );
634 if( iii != altPinMap.end() )
636 wxString altName = iii->second;
638 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
640 auto defIt = altPinDefs.find( libPin->GetNumber() );
642 if( defIt != altPinDefs.end() )
644 for(
const auto& [
name, alt] :
pin->GetAlternates() )
646 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
655 pin->SetAlt( altName );
662 for(
SCH_PIN* libPin : unassignedLibPins )
667 if( !unassignedSchPins.empty() )
669 auto it = unassignedSchPins.begin();
671 unassignedSchPins.erase( it );
676 pin =
m_pins.emplace_back( std::make_unique<SCH_PIN>(
SCH_PIN(
this, libPin ) ) ).get();
680 pin->GetAlternates() = libPin->GetAlternates();
681 pin->SetLibPin( libPin );
682 pin->SetPosition( libPin->GetPosition() );
683 pin->SetUnit( libPin->GetUnit() );
684 pin->SetBodyStyle( libPin->GetBodyStyle() );
685 pin->SetNumber( libPin->GetNumber() );
687 auto iii = altPinMap.find( libPin->GetNumber() );
689 if( iii != altPinMap.end() )
691 wxString altName = iii->second;
693 if(
pin->GetAlternates().find( altName ) ==
pin->GetAlternates().end() )
695 auto defIt = altPinDefs.find( libPin->GetNumber() );
697 if( defIt != altPinDefs.end() )
699 for(
const auto& [
name, alt] :
pin->GetAlternates() )
701 if( alt.m_Shape == defIt->second.m_Shape && alt.m_Type == defIt->second.m_Type )
710 pin->SetAlt( altName );
715 for(
auto it1 =
m_pins.begin(); it1 !=
m_pins.end() && !unassignedSchPins.empty(); )
717 auto it2 = unassignedSchPins.find( it1->get() );
719 if( it2 != unassignedSchPins.end() )
721 it1 =
m_pins.erase( it1 );
722 unassignedSchPins.erase( it2 );
733 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
754 return m_part->GetUnitCount();
763 return m_part->GetBodyStyleCount();
772 return m_part->HasDeMorganBodyStyles();
781 return m_part->GetUnitDisplayName( aUnit, aLabel );
783 return wxString::Format(
_(
"Unit %s" ),
SubReference( aUnit ) );
792 return m_part->GetBodyStyleDescription( aBodyStyle, aLabel );
804 if( instance.m_Path == aSheetPath )
806 aInstance = instance;
810 else if( instance.m_Path.EndsWith( aSheetPath ) )
812 aInstance = instance;
831 for(
int ii =
m_instances.size() - 1; ii >= 0; --ii )
836 wxS(
"Removing symbol instance:\n"
838 " reference %s, unit %d from symbol %s." ),
866 wxS(
"Adding symbol '%s' instance:\n"
890 wxLogTrace(
traceSchSymbolRef,
"GetRef for symbol %s on path %s (sheet path has %zu sheets)",
m_Uuid.AsString(),
897 wxLogTrace(
traceSchSymbolRef,
" Instance: path=%s, ref=%s", instance.m_Path.AsString(),
898 instance.m_Reference );
900 if( instance.m_Path ==
path )
902 ref = instance.m_Reference;
916 wxLogTrace(
traceSchSymbolRef,
" Using fallback from REFERENCE field: %s", ref );
958 if( instance.m_Path ==
path )
961 instance.m_Reference = ref;
969 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
970 pin->ClearDefaultNetName( sheet );
987 const wxString& aVariantName )
989 wxCHECK( !aFieldName.IsEmpty(), );
995 switch( field->
GetId() )
999 SetRef( aPath, aFieldText );
1004 wxString defaultText = field->
GetText( aPath );
1006 if( aVariantName.IsEmpty() )
1008 if( aFieldText != defaultText )
1015 wxCHECK( instance, );
1017 if( instance->
m_Variants.contains( aVariantName ) )
1019 if( aFieldText != defaultText )
1020 instance->
m_Variants[aVariantName].m_Fields[aFieldName] = aFieldText;
1022 instance->
m_Variants[aVariantName].m_Fields.erase( aFieldName );
1024 else if( aFieldText != defaultText )
1029 newVariant.
m_Fields[aFieldName] = aFieldText;
1030 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
1041 const wxString& aVariantName )
const
1043 wxCHECK( !aFieldName.IsEmpty(), wxEmptyString );
1047 wxCHECK( field, wxEmptyString );
1049 switch( field->
GetId() )
1052 wxCHECK( aPath, field->
GetText() );
1053 return GetRef( aPath,
false );
1057 if( !aVariantName.IsEmpty() && aPath )
1061 if( instance && instance->
m_Variants.contains( aVariantName )
1062 && instance->
m_Variants.at( aVariantName ).m_Fields.contains( aFieldName ) )
1064 return instance->
m_Variants.at( aVariantName ).m_Fields.at( aFieldName );
1071 if( aVariantName.IsEmpty() )
1079 if( instance->
m_Variants.contains( aVariantName )
1080 && instance->
m_Variants.at( aVariantName ).m_Fields.contains( aFieldName ) )
1081 return instance->
m_Variants.at( aVariantName ).m_Fields.at( aFieldName );
1097 if( instance.m_Path ==
path )
1098 return !instance.m_Reference.IsEmpty() && instance.m_Reference.Last() !=
'?';
1109 refDesignator.Replace(
"~",
" " );
1111 wxString prefix = refDesignator;
1113 while( prefix.Length() )
1115 wxUniCharRef last = prefix.Last();
1117 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
1118 prefix.RemoveLast();
1124 prefix.Trim(
true );
1125 prefix.Trim(
false );
1127 if( !prefix.IsEmpty() )
1135 return schematic->Settings().SubReference( aUnit, aAddSeparator );
1147 if( instance.m_Path ==
path )
1148 return instance.m_Unit;
1164 if( instance.m_Path ==
path )
1166 instance.m_Unit = aUnitSelection;
1178 if( !aInstance || aVariantName.IsEmpty() )
1186 wxCHECK_MSG( instance, ,
1187 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
1190 if( aVariantName.IsEmpty() )
1196 if( instance->
m_Variants.contains( aVariantName ) && ( aEnable != instance->
m_Variants[aVariantName].m_DNP ) )
1198 instance->
m_Variants[aVariantName].m_DNP = aEnable;
1205 variant.
m_DNP = aEnable;
1214 if( !aInstance || aVariantName.IsEmpty() )
1222 if( instance.
m_Variants.contains( aVariantName ) )
1223 return instance.
m_Variants[aVariantName].m_DNP;
1231 if( !aInstance || aVariantName.IsEmpty() )
1239 wxCHECK_MSG( instance, ,
1240 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
1243 if( aVariantName.IsEmpty() )
1249 if( instance->
m_Variants.contains( aVariantName )
1250 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromBOM ) )
1252 instance->
m_Variants[aVariantName].m_ExcludedFromBOM = aEnable;
1268 if( !aInstance || aVariantName.IsEmpty() )
1276 if( instance.
m_Variants.contains( aVariantName ) )
1277 return instance.
m_Variants[aVariantName].m_ExcludedFromBOM;
1286 if( !aInstance || aVariantName.IsEmpty() )
1294 wxCHECK_MSG( instance, ,
1295 wxString::Format( wxS(
"Cannot get DNP attribute for invalid sheet path '%s'." ),
1298 if( aVariantName.IsEmpty() )
1304 if( instance->
m_Variants.contains( aVariantName )
1305 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromSim ) )
1307 instance->
m_Variants[aVariantName].m_ExcludedFromSim = aEnable;
1323 if( !aInstance || aVariantName.IsEmpty() )
1331 if( instance.
m_Variants.contains( aVariantName ) )
1332 return instance.
m_Variants[aVariantName].m_ExcludedFromSim;
1340 const wxString& aVariantName )
1342 if( !aInstance || aVariantName.IsEmpty() )
1350 wxCHECK_MSG( instance, ,
1351 wxString::Format( wxS(
"Cannot set exclude from board for invalid sheet path '%s'." ),
1354 if( aVariantName.IsEmpty() )
1360 if( instance->
m_Variants.contains( aVariantName )
1361 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromBoard ) )
1363 instance->
m_Variants[aVariantName].m_ExcludedFromBoard = aEnable;
1378 const wxString& aVariantName )
const
1380 if( !aInstance || aVariantName.IsEmpty() )
1388 if( instance.
m_Variants.contains( aVariantName ) )
1389 return instance.
m_Variants[aVariantName].m_ExcludedFromBoard;
1397 const wxString& aVariantName )
1399 if( !aInstance || aVariantName.IsEmpty() )
1407 wxCHECK_MSG( instance, ,
1408 wxString::Format( wxS(
"Cannot set exclude from pos files for invalid sheet path '%s'." ),
1411 if( aVariantName.IsEmpty() )
1417 if( instance->
m_Variants.contains( aVariantName )
1418 && ( aEnable != instance->
m_Variants[aVariantName].m_ExcludedFromPosFiles ) )
1420 instance->
m_Variants[aVariantName].m_ExcludedFromPosFiles = aEnable;
1435 const wxString& aVariantName )
const
1437 if( !aInstance || aVariantName.IsEmpty() )
1445 if( instance.
m_Variants.contains( aVariantName ) )
1446 return instance.
m_Variants[aVariantName].m_ExcludedFromPosFiles;
1456 instance.m_Unit = aUnitSelection;
1461 bool aAllowExtraText,
const wxString& aVariantName )
const
1463 if( aVariantName.IsEmpty() )
1471 std::optional variant =
GetVariant( *aInstance, aVariantName );
1485 const wxString& aVariantName )
1487 if( !aInstance || aVariantName.IsEmpty() )
1495 wxCHECK( instance, );
1499 if( instance->
m_Variants.contains( aVariantName ) )
1501 instance->
m_Variants[aVariantName].m_Fields[fieldName] = aValue;
1508 newVariant.
m_Fields[fieldName] = aValue;
1509 instance->
m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
1515 bool aAllowExtraText,
const wxString& aVariantName )
const
1535 m_fields.emplace_back(
this, aFieldType );
1564 if( !field.IsVisible() || field.GetText().IsEmpty() )
1568 aVector.push_back(
const_cast<SCH_FIELD*
>( &field ) );
1571 std::sort( aVector.begin(), aVector.end(),
1574 return lhs->GetOrdinal() < rhs->GetOrdinal();
1594 for(
unsigned ii = 0; ii <
m_fields.size(); ++ii )
1599 if( aFieldName ==
m_fields[ii].GetName(
false ) )
1612 if( field.GetName().IsSameAs( aFieldName,
false ) )
1624 if( field.GetName().IsSameAs( aFieldName,
false ) )
1633 bool aResetRef,
bool aResetOtherFields )
1637 std::vector<SCH_FIELD*> fields;
1638 m_part->GetFields( fields );
1640 for(
const SCH_FIELD* libField : fields )
1645 if( libField->IsMandatory() )
1647 fieldType = libField->GetId();
1652 schField =
GetField( libField->GetCanonicalName() );
1662 schField->
SetPrivate( libField->IsPrivate() );
1674 else if( aUpdateRef )
1675 SetRef( aPath, libField->GetText() );
1683 if( aResetOtherFields )
1685 else if( aUpdateOtherFields )
1686 schField->
SetText( libField->GetText() );
1690 if( aResetOtherFields || aUpdateOtherFields )
1691 schField->
SetText( libField->GetText() );
1701 bool updateValue =
true;
1702 bool updateExclFromBOM =
true;
1703 bool updateExclFromBoard =
true;
1704 bool updateExclFromPosFiles =
true;
1705 bool updateDNP =
true;
1706 bool updateOtherFields =
true;
1707 bool updatePins =
true;
1711 updateValue = aProperty->
Name() ==
_HKI(
"Value" );
1712 updateExclFromBoard = aProperty->
Name() ==
_HKI(
"Exclude From Board" );
1713 updateExclFromBOM = aProperty->
Name() ==
_HKI(
"Exclude From Bill of Materials" );
1714 updateExclFromPosFiles = aProperty->
Name() ==
_HKI(
"Exclude From Position Files" );
1715 updateDNP = aProperty->
Name() ==
_HKI(
"Do not Populate" );
1716 updateOtherFields =
false;
1720 if( !updateValue && !updateExclFromBOM && !updateExclFromBoard && !updateExclFromPosFiles && !updateDNP && !updateOtherFields && !updatePins )
1729 wxString ref =
GetRef( &aSourceSheet );
1734 std::vector<SCH_SYMBOL*> otherUnits;
1740 aCommit.
Modify( otherUnit, screen );
1745 if( updateOtherFields )
1757 if( field.IsMandatory() )
1758 otherField = otherUnit->GetField( field.GetId() );
1760 otherField = otherUnit->GetField( field.GetName() );
1764 otherField->
SetText( field.GetText() );
1772 newField.
Offset( otherUnit->GetPosition() );
1775 otherUnit->AddField( newField );
1779 for(
int ii = (
int) otherUnit->GetFields().size() - 1; ii >= 0; ii-- )
1781 SCH_FIELD& otherField = otherUnit->GetFields()[ii];
1784 otherUnit->GetFields().erase( otherUnit->GetFields().begin() + ii );
1788 if( updateExclFromBOM )
1791 if( updateExclFromBoard )
1794 if( updateExclFromPosFiles )
1798 otherUnit->SetDNP(
GetDNP( &aSourceSheet, aVariantName ), &sheet, aVariantName );
1802 for(
const std::unique_ptr<SCH_PIN>& model_pin :
m_pins )
1804 for(
SCH_PIN* src_pin : otherUnit->GetPinsByNumber( model_pin->GetNumber() ) )
1805 src_pin->SetAlt( model_pin->GetAlt() );
1816 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1817 aFunction(
pin.get() );
1820 aFunction( &field );
1826 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1828 if(
pin->GetNumber() == aNumber )
1838 std::vector<SCH_PIN*> pins;
1840 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1842 if(
pin->GetNumber() == aNumber )
1843 pins.push_back(
pin.get() );
1852 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1854 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
1855 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
1857 if( pin_unit > 0 && pin_unit !=
GetUnit() )
1860 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
1863 if(
pin->GetPosition() == aPos )
1876 return std::vector<SCH_PIN*>();
1883 return m_part->GetPins();
1885 return std::vector<SCH_PIN*>();
1897 auto it =
m_pinMap.find( aLibPin );
1902 wxFAIL_MSG_AT(
"Pin not found", __FILE__, __LINE__, __FUNCTION__ );
1909 std::vector<const SCH_PIN*> pins;
1918 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1920 if( unit &&
pin->GetUnit() &&
pin->GetUnit() != unit )
1923 pins.push_back(
pin.get() );
1932 std::vector<SCH_PIN*> pins;
1941 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1943 if( unit &&
pin->GetUnit() &&
pin->GetUnit() != unit )
1946 pins.push_back(
pin.get() );
1962 wxCHECK_RET( aItem !=
nullptr && aItem->
Type() ==
SCH_SYMBOL_T, wxT(
"Cannot swap data with invalid symbol." ) );
1970 for( std::unique_ptr<SCH_PIN>&
pin : symbol->
m_pins )
1971 pin->SetParent( symbol );
1973 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1974 pin->SetParent(
this );
1979 m_part.reset( libSymbol );
2012 if( field.IsPrivate() )
2015 if( field.IsMandatory() )
2016 aVars->push_back( field.GetCanonicalName().Upper() );
2018 aVars->push_back( field.GetName() );
2021 aVars->push_back( wxT(
"OP" ) );
2022 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
2023 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
2024 aVars->push_back( wxT(
"UNIT" ) );
2025 aVars->push_back( wxT(
"SHORT_REFERENCE" ) );
2026 aVars->push_back( wxT(
"SYMBOL_LIBRARY" ) );
2027 aVars->push_back( wxT(
"SYMBOL_NAME" ) );
2028 aVars->push_back( wxT(
"SYMBOL_DESCRIPTION" ) );
2029 aVars->push_back( wxT(
"SYMBOL_KEYWORDS" ) );
2030 aVars->push_back( wxT(
"EXCLUDE_FROM_BOM" ) );
2031 aVars->push_back( wxT(
"EXCLUDE_FROM_BOARD" ) );
2032 aVars->push_back( wxT(
"EXCLUDE_FROM_SIM" ) );
2033 aVars->push_back( wxT(
"DNP" ) );
2034 aVars->push_back( wxT(
"SHORT_NET_NAME(<pin_number>)" ) );
2035 aVars->push_back( wxT(
"NET_NAME(<pin_number>)" ) );
2036 aVars->push_back( wxT(
"NET_CLASS(<pin_number>)" ) );
2037 aVars->push_back( wxT(
"PIN_NAME(<pin_number>)" ) );
2038 aVars->push_back( wxT(
"REFERENCE(<pin_number>)" ) );
2039 aVars->push_back( wxT(
"SHORT_REFERENCE(<pin_number>)" ) );
2040 aVars->push_back( wxT(
"UNIT(<pin_number>)" ) );
2051 const wxString& aVariantName,
int aDepth )
const
2055 thread_local wxRegEx operatingPoint( wxT(
"^"
2070 wxString variant = aVariantName.IsEmpty() ? schematic->GetCurrentVariant() : aVariantName;
2072 if( operatingPoint.Matches( *token ) )
2074 wxString
pin( operatingPoint.GetMatch( *token, 1 ).Lower() );
2075 wxString precisionStr( operatingPoint.GetMatch( *token, 3 ) );
2076 wxString rangeStr( operatingPoint.GetMatch( *token, 4 ) );
2078 int precision = precisionStr.IsEmpty() ? 3 : precisionStr[0] -
'0';
2079 wxString range = rangeStr.IsEmpty() ? wxString( wxS(
"~A" ) ) : rangeStr;
2083 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
2084 embeddedFilesStack.push_back( schematic->GetEmbeddedFiles() );
2087 embeddedFilesStack.push_back(
m_part->GetEmbeddedFiles() );
2093 aVariantName, devnull ).model;
2097 wxString spiceRef =
model.SpiceGenerator().ItemName( spiceItem );
2098 spiceRef = spiceRef.Lower();
2102 *token = schematic->GetOperatingPoint( spiceRef, precision, range );
2105 else if(
pin == wxS(
":power" ) )
2107 if( rangeStr.IsEmpty() )
2108 range = wxS(
"~W" );
2110 *token = schematic->GetOperatingPoint( spiceRef + wxS(
":power" ), precision, range );
2115 pin =
pin.SubString( 1, -1 );
2117 for(
const std::reference_wrapper<const SIM_MODEL_PIN>& modelPin :
model.GetPins() )
2119 SCH_PIN* symbolPin =
GetPin( modelPin.get().symbolPinNumber );
2123 if(
model.GetPins().size() == 2 )
2125 *token = schematic->GetOperatingPoint( spiceRef, precision, range );
2129 wxString netChainName = spiceRef + wxS(
":" ) + modelPin.get().modelPinName;
2130 *token = schematic->GetOperatingPoint( netChainName, precision, range );
2138 *token = wxS(
"?" );
2142 if( token->Contains(
':' ) )
2144 if( schematic->ResolveCrossReference( token, aDepth + 1 ) )
2150 wxString fieldName = field.IsMandatory() ? field.GetCanonicalName() : field.GetName();
2152 wxString textToken = field.GetText();
2153 textToken.Replace(
" ", wxEmptyString );
2154 wxString tokenString =
"${" + fieldName +
"}";
2157 if( textToken.IsSameAs( tokenString,
false ) )
2160 if( token->IsSameAs( fieldName,
false ) )
2164 *token =
GetRef( aPath,
true );
2166 else if( !aVariantName.IsEmpty() )
2169 std::optional<SCH_SYMBOL_VARIANT> symVariant =
GetVariant( *aPath, aVariantName );
2171 if( symVariant && symVariant->m_Fields.contains( fieldName ) )
2172 *token = symVariant->m_Fields.at( fieldName );
2174 *token = field.GetShownText( aPath,
false, aDepth + 1 );
2178 *token = field.GetShownText( aPath,
false, aDepth + 1 );
2186 if( token->IsSameAs( wxT(
"SIM.DEVICE" ) ) || token->IsSameAs( wxT(
"SIM.TYPE" ) )
2187 || token->IsSameAs( wxT(
"SIM.PINS" ) ) || token->IsSameAs( wxT(
"SIM.PARAMS" ) )
2188 || token->IsSameAs( wxT(
"SIM.LIBRARY" ) ) || token->IsSameAs( wxT(
"SIM.NAME" ) ) )
2190 *token = wxEmptyString;
2195 schematic->Settings().m_TemplateFieldNames.GetTemplateFieldNames() )
2197 if( token->IsSameAs( templateFieldname.m_Name ) || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
2201 *token = wxEmptyString;
2206 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
2210 wxArrayString parts = wxSplit( footprint,
':' );
2212 if( parts.Count() > 0 )
2215 *token = wxEmptyString;
2219 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
2223 wxArrayString parts = wxSplit( footprint,
':' );
2225 if( parts.Count() > 1 )
2226 *token = parts[std::min( 1, (
int) parts.size() - 1 )];
2228 *token = wxEmptyString;
2232 else if( token->IsSameAs( wxT(
"UNIT" ) ) )
2237 else if( token->IsSameAs( wxT(
"SHORT_REFERENCE" ) ) )
2239 *token =
GetRef( aPath,
false );
2242 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
2244 *token =
m_lib_id.GetUniStringLibNickname();
2247 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
2249 *token =
m_lib_id.GetUniStringLibItemName();
2252 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
2257 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
2262 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
2264 *token = wxEmptyString;
2266 if( aPath->
GetExcludedFromBOM( variant ) || this->ResolveExcludedFromBOM( aPath, variant ) )
2267 *token =
_(
"Excluded from BOM" );
2271 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
2273 *token = wxEmptyString;
2275 if( aPath->
GetExcludedFromBoard( variant ) || this->ResolveExcludedFromBoard( aPath, variant ) )
2276 *token =
_(
"Excluded from board" );
2280 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
2282 *token = wxEmptyString;
2284 if( aPath->
GetExcludedFromSim( variant ) || this->ResolveExcludedFromSim( aPath, variant ) )
2285 *token =
_(
"Excluded from simulation" );
2289 else if( token->IsSameAs( wxT(
"DNP" ) ) )
2291 *token = wxEmptyString;
2293 if( aPath->
GetDNP( variant ) || this->ResolveDNP( aPath, variant ) )
2294 *token =
_(
"DNP" );
2298 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) ) || token->StartsWith( wxT(
"NET_NAME(" ) )
2299 || token->StartsWith( wxT(
"NET_CLASS(" ) ) || token->StartsWith( wxT(
"PIN_NAME(" ) )
2300 || token->StartsWith( wxT(
"PIN_BASE_NAME(" ) ) || token->StartsWith( wxT(
"PIN_ALT_LIST(" ) )
2301 || token->StartsWith( wxT(
"REFERENCE(" ) ) || token->StartsWith( wxT(
"SHORT_REFERENCE(" ) )
2302 || token->StartsWith( wxT(
"UNIT(" ) ) )
2304 wxString pinNumber = token->AfterFirst(
'(' );
2305 pinNumber = pinNumber.BeforeLast(
')' );
2307 bool isReferenceFunction = token->StartsWith( wxT(
"REFERENCE(" ) );
2308 bool isShortReferenceFunction = token->StartsWith( wxT(
"SHORT_REFERENCE(" ) );
2309 bool isUnitFunction = token->StartsWith( wxT(
"UNIT(" ) );
2313 std::vector<const SCH_PIN*> pinsToSearch;
2314 std::vector<const SCH_PIN*> altPinsToSearch;
2316 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
2319 pinsToSearch.push_back(
pin );
2324 pinsToSearch.push_back(
pin );
2327 altPinsToSearch.push_back(
pin );
2332 if(
pin->GetNumber() == pinNumber )
2334 if( isReferenceFunction || isShortReferenceFunction || isUnitFunction )
2336 int pinUnit =
pin->GetUnit();
2339 if( isReferenceFunction )
2347 else if( isShortReferenceFunction )
2352 else if( isUnitFunction )
2364 else if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
2366 *token =
pin->GetAlt().IsEmpty() ?
pin->GetName() :
pin->GetAlt();
2369 else if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
2371 *token =
pin->GetBaseName();
2374 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
2379 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
2381 for(
const auto& [altName, altDef] : alts )
2383 if( !altList.IsEmpty() )
2384 altList += wxT(
", " );
2396 *token = wxEmptyString;
2398 else if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
2401 if( netName.Lower().StartsWith( wxT(
"unconnected" ) ) )
2402 *token = wxT(
"NC" );
2406 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
2408 *token = conn->
Name();
2410 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
2412 *token =
pin->GetEffectiveNetClass( aPath )->GetName();
2422 if(
pin->GetNumber() == pinNumber )
2425 if( token->StartsWith( wxT(
"PIN_BASE_NAME" ) ) )
2427 *token =
pin->GetBaseName();
2430 else if( token->StartsWith( wxT(
"PIN_ALT_LIST" ) ) )
2435 const std::map<wxString, SCH_PIN::ALT>& alts =
pin->GetAlternates();
2437 for(
const auto& [altName, altDef] : alts )
2439 if( !altList.IsEmpty() )
2440 altList += wxT(
", " );
2449 int pinUnit =
pin->GetUnit();
2465 if( symbol->
GetRef( &sheetPath,
false ) ==
GetRef( aPath,
false )
2468 targetPath = sheetPath;
2469 targetSymbol = symbol;
2482 *token = wxString::Format( wxT(
"<Unit %s not placed>" ),
SubReference( pinUnit,
false ) );
2488 SCH_PIN* instancePin =
nullptr;
2492 if( candidate->GetNumber() == pinNumber )
2494 instancePin = candidate;
2501 *token = wxEmptyString;
2506 if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
2508 *token = instancePin->
GetAlt().IsEmpty() ? instancePin->
GetName() : instancePin->
GetAlt();
2517 *token = wxEmptyString;
2519 else if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
2522 if( netName.Lower().StartsWith( wxT(
"unconnected" ) ) )
2523 *token = wxT(
"NC" );
2527 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
2529 *token = conn->
Name();
2531 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
2541 *token = wxString::Format( wxT(
"<Unresolved: pin %s>" ), pinNumber );
2561 if( instance.m_Path ==
path )
2563 if( instance.m_Reference.IsEmpty() || aResetPrefix )
2574 if( instance.m_Reference.IsEmpty() || aResetPrefix )
2581 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2582 pin->ClearDefaultNetName( aSheetPath );
2592 if( currentReference.IsEmpty() || aResetPrefix )
2603 wxCHECK( aSheetPath.size() > 0,
false );
2608 if( instance.m_Path == aSheetPath )
2621 bool transform =
false;
2623 switch( aOrientation )
2744 wxFAIL_MSG(
"Invalid schematic symbol orientation type." );
2798 for(
int type_rotate : rotate_values )
2810 wxFAIL_MSG(
"Schematic symbol orientation matrix internal error." );
2818void SCH_SYMBOL::Show(
int nestLevel, std::ostream& os )
const
2821 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
" ref=\""
2827 for(
int i = 1; i < (int)
GetFields().size(); ++i )
2829 const wxString& value =
GetFields()[i].GetText();
2831 if( !value.IsEmpty() )
2833 NestedSpace( nestLevel + 1, os ) <<
"<field" <<
" name=\"" <<
TO_UTF8(
GetFields()[i].GetName() ) <<
'"'
2834 <<
" value=\"" <<
TO_UTF8( value ) <<
"\"/>\n";
2838 NestedSpace( nestLevel, os ) <<
"</" <<
TO_UTF8(
GetClass().Lower() ) <<
">\n";
2858 if( aIncludeFields )
2862 if( field.IsVisible() )
2863 bBox.
Merge( field.GetBoundingBox() );
2877 catch(
const boost::bad_pointer& e )
2879 wxFAIL_MSG( wxString::Format( wxT(
"Boost pointer exception occurred: %s" ), e.what() ) );
2905 auto addExcludes = [&]()
2910 msgs.Add(
_(
"Simulation" ) );
2913 msgs.Add(
_(
"BOM" ) );
2916 msgs.Add(
_(
"Board" ) );
2918 if(
GetDNP( currentSheet, currentVariant ) )
2919 msgs.Add(
_(
"DNP" ) );
2921 msg = wxJoin( msgs,
'|' );
2922 msg.Replace(
'|', wxS(
", " ) );
2925 aList.emplace_back(
_(
"Exclude from" ), msg );
2936 aList.emplace_back(
_(
"Power symbol" ),
2944 aList.emplace_back(
_(
"Value" ),
2951 aList.emplace_back(
_(
"flags" ), wxString::Format(
"%X",
GetEditFlags() ) );
2956 msg =
_(
"Missing parent" );
2958 std::shared_ptr<LIB_SYMBOL> parent =
m_part->GetParent().lock();
2961 msg = parent->GetName();
2965 else if( !
m_lib_id.GetLibNickname().empty() )
2967 aList.emplace_back(
_(
"Library" ),
m_lib_id.GetLibNickname() );
2971 aList.emplace_back(
_(
"Library" ),
_(
"Undefined!!!" ) );
2979 msg =
_(
"<Unknown>" );
2981 aList.emplace_back(
_(
"Footprint" ), msg );
2985 _(
"Keywords" ) + wxT(
": " ) +
m_part->GetKeyWords() );
2990 aList.emplace_back(
_(
"Reference" ),
GetRef( currentSheet ) );
2999 if( libNickname.empty() )
3000 msg =
_(
"No library defined!" );
3002 msg.Printf(
_(
"Symbol not found in %s!" ), libNickname );
3004 aList.emplace_back(
_(
"Library" ), msg );
3039 field.SetTextPos( pos );
3057 field.SetTextPos( pos );
3076 field.SetTextPos( pos );
3104 if( field.Matches( aSearchData, aAuxData ) )
3114 if( drawItem.Matches( aSearchData, aAuxData ) )
3125 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3133 aItemList.push_back( item );
3139 std::vector<DANGLING_END_ITEM>& aItemListByPos,
const SCH_SHEET_PATH* aPath )
3141 bool changed =
false;
3143 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3145 bool previousState =
pin->IsDangling();
3146 pin->SetIsDangling(
true );
3151 bool do_break =
false;
3153 for(
auto it = lower; it < aItemListByPos.end() && it->GetPosition() == pos; it++ )
3172 pin->SetIsDangling(
false );
3183 changed = ( changed || ( previousState !=
pin->IsDangling() ) );
3208 wxCHECK( symbol,
false );
3214 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3216 if(
pin->IsDangling() )
3229 if(
GetRef( aInstance ) != symbol->
GetRef( aInstance ) )
3239 for(
size_t i = 0; i <
m_pins.size(); i++ )
3251 std::vector<VECTOR2I> retval;
3253 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3257 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
3258 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
3260 if( pin_unit > 0 && pin_unit !=
GetUnit() )
3263 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
3289 return wxString::Format(
_(
"Symbol %s [%s]" ),
3297 for(
KICAD_T scanType : aScanTypes )
3342 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3346 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
3347 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
3349 if( pin_unit > 0 && pin_unit !=
GetUnit() )
3352 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
3389 std::vector<SCH_FIELD*> fields, otherFields;
3392 aSymbol.
GetFields( otherFields,
false );
3394 if( fields.size() != otherFields.size() )
3397 for(
int ii = 0; ii < (int) fields.size(); ii++ )
3402 if( fields[ii]->GetText().Cmp( otherFields[ii]->GetText() ) != 0 )
3412 return !( *
this == aSymbol );
3418 wxCHECK_MSG(
Type() == aSymbol.
Type(), *
this,
3419 wxT(
"Cannot assign object type " ) + aSymbol.
GetClass() + wxT(
" to type " ) +
GetClass() );
3421 if( &aSymbol !=
this )
3438 field.SetParent(
this );
3450 bBox.
Inflate( aAccuracy / 2 );
3466 rect.
Inflate( aAccuracy / 2 );
3488 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3501 if(
pin->GetLocalPosition() == new_pos )
3516 const VECTOR2I& aOffset,
bool aDimmed )
3530 for(
unsigned i = 0; i < tempPins.size(); ++i )
3533 SCH_PIN* tempPin = tempPins[i];
3553 text->SetText(
dummy.GetShownText(
false ) );
3564 bool dnp =
GetDNP( sheet, variant );
3566 for(
bool local_background : {
true,
false } )
3572 field.ClearRenderCache();
3576 && ( field.IsVisible() || field.IsForceVisible() ) )
3589 std::vector<wxString> properties;
3593 wxString text_field = field.GetShownText( sheet,
false, 0, variant );
3595 if( text_field.IsEmpty() )
3598 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ), field.GetName(), text_field ) );
3601 if( !
m_part->GetKeyWords().IsEmpty() )
3603 properties.emplace_back(
3604 wxString::Format( wxT(
"!%s = %s" ),
_(
"Keywords" ),
m_part->GetKeyWords() ) );
3627 margins.
x = std::max( margins.
x * 0.6, margins.
y * 0.3 );
3628 margins.
y = std::max( margins.
y * 0.6, margins.
x * 0.3 );
3646 double lineWidth = aSize / 10.0;
3648 std::vector<SCH_SHAPE> shapeList;
3650 int tolerance = 100;
3652 for(
const SCH_SHAPE& shape : shapeList )
3658 aPlotter->
BezierCurve( shape.GetStart(), shape.GetBezierC1(), shape.GetBezierC2(), shape.GetEnd(),
3659 tolerance, lineWidth );
3661 aPlotter->
Circle( shape.getCenter(), shape.GetRadius() * 2, filled, lineWidth );
3721 for(
unsigned i = 0; i < tempPins.size(); ++i )
3724 SCH_PIN* tempPin = tempPins[i];
3742 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3744 if(
pin->IsBrightened() )
3754 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3755 pin->ClearBrightened();
3773 m_part->SetShowPinNames( aShow );
3786 m_part->SetShowPinNumbers( aShow );
3792 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
3794 int pin_unit =
pin->GetLibPin() ?
pin->GetLibPin()->GetUnit() :
GetUnit();
3795 int pin_bodyStyle =
pin->GetLibPin() ?
pin->GetLibPin()->GetBodyStyle() :
GetBodyStyle();
3797 if( pin_unit > 0 && pin_unit !=
GetUnit() )
3800 if( pin_bodyStyle > 0 && pin_bodyStyle !=
GetBodyStyle() )
3803 if(
pin->IsPointClickableAnchor( aPos ) )
3822 if( pin_list.size() != 1 )
3840 if( pin_list.size() != 1 )
3852 return m_part->IsLocalPower();
3861 return m_part->IsGlobalPower();
3873 wxCHECK(
m_part,
false );
3875 return m_part->IsNormal();
3881 std::unordered_set<wxString> componentClass;
3883 auto getComponentClassFields = [&](
const std::vector<SCH_FIELD>& fields )
3887 if( field.GetCanonicalName() == wxT(
"Component Class" ) )
3889 if( field.GetShownText( aPath,
false ) != wxEmptyString )
3890 componentClass.insert( field.GetShownText( aPath,
false ) );
3896 getComponentClassFields(
m_fields );
3903 getComponentClassFields( label->GetFields() );
3907 return componentClass;
3912 const wxString& aVariantName )
const
3917 return std::nullopt;
3919 return instance.
m_Variants.find( aVariantName )->second;
3931 instance->
m_Variants.insert( std::make_pair( aVariant.
m_Name, aVariant ) );
3940 if( !instance || !instance->
m_Variants.contains( aVariantName ) )
3948 const wxString& aNewName )
3953 if( !instance || !instance->
m_Variants.contains( aOldName ) )
3958 variant.
m_Name = aNewName;
3960 instance->
m_Variants.insert( std::make_pair( aNewName, variant ) );
3965 const wxString& aNewVariant )
3970 if( !instance || !instance->
m_Variants.contains( aSourceVariant ) )
3975 variant.
m_Name = aNewVariant;
3976 instance->
m_Variants.insert( std::make_pair( aNewVariant, variant ) );
4026 for(
unsigned i = 0; i <
m_pins.size(); ++i )
4035 if( m_instanceReferences != symbol.m_instanceReferences )
4061 double aLineWidth,
bool aHorizontal )
4065 double x_right = aSize / 1.6180339887;
4066 double x_middle = x_right / 2.0;
4079 aShapeList.back().SetStart( bottomPt );
4080 aShapeList.back().SetBezierC1( bottomAnchorPt );
4081 aShapeList.back().SetBezierC2( leftSideAnchorPt1 );
4082 aShapeList.back().SetEnd( leftPt );
4086 aShapeList.back().SetStart( leftPt );
4087 aShapeList.back().SetBezierC1( leftSideAnchorPt2 );
4088 aShapeList.back().SetBezierC2( rightSideAnchorPt2 );
4089 aShapeList.back().SetEnd( rightPt );
4092 aShapeList.back().SetStart( rightPt );
4093 aShapeList.back().SetBezierC1( rightSideAnchorPt1 );
4094 aShapeList.back().SetBezierC2( bottomAnchorPt );
4095 aShapeList.back().SetEnd( bottomPt );
4098 aShapeList.back().SetCenter( ( leftPt + rightPt ) / 2.0 );
4099 aShapeList.back().SetRadius( aSize / 15.0 );
4104 shape.Rotate(
VECTOR2I( 0, 0 ),
true );
4115 if( instance.m_Path == aSheetPath )
4127 if( instance.m_Path == aSheetPath )
4165 auto hasLibPart = [](
INSPECTABLE* aItem ) ->
bool
4168 return symbol->GetLibSymbolRef() !=
nullptr;
4181 const wxString groupFields =
_HKI(
"Fields" );
4201 auto multiUnit = [=](
INSPECTABLE* aItem ) ->
bool
4204 return symbol->IsMultiUnit();
4209 auto multiBodyStyle = [=](
INSPECTABLE* aItem ) ->
bool
4212 return symbol->IsMultiBodyStyle();
4223 wxPGChoices choices;
4227 for(
int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
4228 choices.Add( symbol->GetUnitDisplayName( ii,
false ), ii );
4240 wxPGChoices choices;
4244 for(
int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ )
4245 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
4251 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
PASSTHROUGH_MODE m_passthroughMode
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