56 std::string ret =
TO_UTF8( txt );
58 for( std::string::iterator it = ret.begin(); it!=ret.end(); ++it )
60 if( (
unsigned char) *it <=
' ' )
89 text->SetText( wxString( wxT(
"??" ) ) );
118 std::unique_ptr< LIB_SYMBOL > part;
150 SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.
Convert, aPosition, aParent )
153 for(
const std::pair<int, wxString>& i : aSel.
Fields )
156 SetRef( aSheet, i.second );
158 field->SetText( i.second );
186 field.SetParent(
this );
191 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol.
m_pins )
193 m_pins.emplace_back( std::make_unique<SCH_PIN>( *
pin ) );
194 m_pins.back()->SetParent(
this );
274 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
276 if( ( (
pin->GetPosition().x -
m_pos.
x ) % min_grid_size ) != 0 )
279 if( ( (
pin->GetPosition().y -
m_pos.
y ) % min_grid_size ) != 0 )
304 wxCHECK2( ( aLibSymbol ==
nullptr ) || ( aLibSymbol->
IsRoot() ), aLibSymbol =
nullptr );
306 m_part.reset( aLibSymbol );
314 return m_part->GetDescription();
316 return wxEmptyString;
323 return m_part->GetKeyWords();
325 return wxEmptyString;
332 return m_part->GetDatasheetField().GetText();
334 return wxEmptyString;
340 std::map<wxString, wxString> altPinMap;
341 std::map<wxString, std::set<SCH_PIN*>> pinUuidMap;
342 std::set<SCH_PIN*> unassignedSchPins;
343 std::set<LIB_PIN*> unassignedLibPins;
345 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
347 pinUuidMap[
pin->GetNumber() ].insert(
pin.get() );
349 unassignedSchPins.insert(
pin.get() );
351 if( !
pin->GetAlt().IsEmpty() )
352 altPinMap[
pin->GetNumber() ] =
pin->GetAlt();
360 std::vector<LIB_PIN*> pins =
m_part->GetAllLibPins();
371 auto ii = pinUuidMap.find( libPin->GetNumber() );
373 if( ii == pinUuidMap.end() || ii->second.empty() )
375 unassignedLibPins.insert( libPin );
379 auto it = ii->second.begin();
381 ii->second.erase( it );
382 pin->SetLibPin( libPin );
383 pin->SetPosition( libPin->GetPosition() );
385 unassignedSchPins.erase(
pin );
387 auto iii = altPinMap.find( libPin->GetNumber() );
389 if( iii != altPinMap.end() )
390 pin->SetAlt( iii->second );
396 for(
LIB_PIN* libPin : unassignedLibPins )
401 if( !unassignedSchPins.empty() )
403 auto it = unassignedSchPins.begin();
405 unassignedSchPins.erase( it );
410 pin =
m_pins.emplace_back( std::make_unique<SCH_PIN>(
SCH_PIN( libPin,
this ) ) ).get();
414 pin->SetLibPin( libPin );
415 pin->SetPosition( libPin->GetPosition() );
416 pin->SetNumber( libPin->GetNumber() );
418 auto iii = altPinMap.find( libPin->GetNumber() );
420 if( iii != altPinMap.end() )
421 pin->SetAlt( iii->second );
425 for(
auto it1 =
m_pins.begin(); it1 !=
m_pins.end() && !unassignedSchPins.empty(); )
427 auto it2 = unassignedSchPins.find( it1->get() );
429 if( it2 != unassignedSchPins.end() )
431 it1 =
m_pins.erase( it1 );
432 unassignedSchPins.erase( it2 );
476 return m_part->GetUnitCount();
486 return m_part->GetUnitDisplayName( aUnit );
494 return m_part->HasUnitDisplayName( aUnit );
527 for(
unsigned i = 0; i < tempPins.size(); ++ i )
530 LIB_PIN* tempPin = tempPins[ i ];
545 field.Print( aSettings, aOffset );
566 const KIID_PATH& aSheetPath,
bool aTestFromEnd )
const
572 if( instance.m_Path == aSheetPath )
574 aInstance = instance;
578 else if( instance.m_Path.EndsWith( aSheetPath ) )
580 aInstance = instance;
598 " reference %s, unit %d from symbol %s.",
627 " reference %s, unit %d from symbol %s.",
644 "Adding symbol '%s' instance:\n"
669 std::vector<SCH_SYMBOL_INSTANCE>::iterator resultIt;
674 [searchPath](
const auto& it )
676 return it.m_Path == searchPath;
683 " reference %s, unit %d from symbol %s.",
685 resultIt->m_Reference,
699 "Adding symbol '%s' instance:\n"
728 if( instance.m_Path ==
path )
730 ref = instance.m_Reference;
770 if( instance.m_Path ==
path )
773 instance.m_Reference = ref;
781 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
782 pin->ClearDefaultNetName( sheet );
804 if( instance.m_Path ==
path )
805 return instance.m_Reference.Last() !=
'?';
816 refDesignator.Replace(
"~",
" " );
818 wxString prefix = refDesignator;
820 while( prefix.Length() )
822 wxUniCharRef last = prefix.Last();
824 if( ( last >=
'0' && last <=
'9' ) || last ==
'?' || last ==
'*' )
832 prefix.Trim(
false );
834 if( !prefix.IsEmpty() )
845 if( instance.m_Path ==
path )
846 return instance.m_Unit;
862 if( instance.m_Path ==
path )
864 instance.m_Unit = aUnitSelection;
877 instance.m_Unit = aUnitSelection;
882 bool aAllowExtraText )
const
898 bool aAllowExtraText )
const
927 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
929 if(
m_fields[ii].GetId() == aFieldId )
939 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
941 if(
m_fields[ii].GetName() == aFieldName )
951 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
953 if(
m_fields[ii].GetName() == aFieldName )
965 if( aFieldName == field.GetName() || aFieldName == field.GetCanonicalName() )
966 return field.GetText();
969 return wxEmptyString;
979 if( !field.IsVisible() || field.GetShownText(
nullptr,
true ).IsEmpty() )
983 aVector.push_back( &field );
1001 if( aFieldName ==
m_fields[i].GetName(
false ) )
1011 bool aCaseInsensitive )
1015 for(
unsigned i = start; i <
m_fields.size(); ++i )
1017 if( aCaseInsensitive )
1019 if( aFieldName.Upper() ==
m_fields[i].GetName(
false ).Upper() )
1024 if( aFieldName ==
m_fields[i].GetName(
false ) )
1034 bool aUpdateOtherFields,
bool aResetRef,
bool aResetOtherFields )
1038 std::vector<LIB_FIELD*> fields;
1040 m_part->GetFields( fields );
1042 for(
const LIB_FIELD* libField : fields )
1044 int id = libField->GetId();
1053 schField =
FindField( libField->GetCanonicalName() );
1057 wxString fieldName = libField->GetCanonicalName();
1072 SetRef( aPath,
m_part->GetReferenceField().GetText() );
1073 else if( aUpdateRef )
1074 SetRef( aPath, libField->GetText() );
1082 if( aResetOtherFields || aUpdateOtherFields )
1087 if( aResetOtherFields )
1089 else if( aUpdateOtherFields )
1090 schField->
SetText( libField->GetText() );
1094 if( aResetOtherFields || aUpdateOtherFields )
1095 schField->
SetText( libField->GetText() );
1104 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1105 aFunction(
pin.get() );
1108 aFunction( &field );
1114 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1116 if(
pin->GetNumber() == aNumber )
1133 std::vector<LIB_PIN*> pinList;
1136 m_part->GetPins( pinList, 0, 0 );
1144 auto it =
m_pinMap.find( aLibPin );
1149 wxFAIL_MSG_AT(
"Pin not found", __FILE__, __LINE__, __FUNCTION__ );
1156 std::vector<SCH_PIN*> pins;
1158 if( aSheet ==
nullptr )
1160 wxCHECK_MSG(
Schematic(), pins,
"Can't call GetPins on a symbol with no schematic" );
1167 for(
const std::unique_ptr<SCH_PIN>& p :
m_pins )
1169 if( unit && p->GetLibPin()->GetUnit() && ( p->GetLibPin()->GetUnit() != unit ) )
1172 pins.push_back( p.get() );
1184 wxT(
"Cannot swap data with invalid symbol." ) );
1192 for( std::unique_ptr<SCH_PIN>&
pin : symbol->
m_pins )
1193 pin->SetParent( symbol );
1195 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1196 pin->SetParent(
this );
1201 m_part.reset( libSymbol );
1234 aVars->push_back(
m_fields[i].GetCanonicalName().Upper() );
1237 aVars->push_back(
m_fields[i].GetName() );
1239 aVars->push_back( wxT(
"OP" ) );
1240 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
1241 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
1242 aVars->push_back( wxT(
"UNIT" ) );
1243 aVars->push_back( wxT(
"SYMBOL_LIBRARY" ) );
1244 aVars->push_back( wxT(
"SYMBOL_NAME" ) );
1245 aVars->push_back( wxT(
"SYMBOL_DESCRIPTION" ) );
1246 aVars->push_back( wxT(
"SYMBOL_KEYWORDS" ) );
1247 aVars->push_back( wxT(
"EXCLUDE_FROM_BOM" ) );
1248 aVars->push_back( wxT(
"EXCLUDE_FROM_BOARD" ) );
1249 aVars->push_back( wxT(
"EXCLUDE_FROM_SIM" ) );
1250 aVars->push_back( wxT(
"DNP" ) );
1251 aVars->push_back( wxT(
"SHORT_NET_NAME(<pin_number>)" ) );
1252 aVars->push_back( wxT(
"NET_NAME(<pin_number>)" ) );
1253 aVars->push_back( wxT(
"NET_CLASS(<pin_number>)" ) );
1254 aVars->push_back( wxT(
"PIN_NAME(<pin_number>)" ) );
1260 static wxRegEx operatingPoint( wxT(
"^"
1263 "(.([0-9])?([a-zA-Z]*))?"
1269 if( !schematic || !aPath )
1272 if( operatingPoint.Matches( *token ) )
1274 wxString port( operatingPoint.GetMatch( *token, 1 ) );
1275 wxString precisionStr( operatingPoint.GetMatch( *token, 3 ) );
1276 wxString range( operatingPoint.GetMatch( *token, 4 ) );
1278 wxString signal =
GetRef( aPath ) + port;
1281 if( !precisionStr.IsEmpty() )
1282 precision = precisionStr[0] -
'0';
1284 if( range.IsEmpty() )
1286 if( port == wxS(
":power" ) )
1287 range = wxS(
"~W" );
1289 range = wxS(
"~A" );
1297 if( token->Contains(
':' ) )
1305 if( token->IsSameAs(
m_fields[ i ].GetCanonicalName().Upper() ) )
1308 *token =
GetRef( aPath,
true );
1310 *token =
m_fields[ i ].GetShownText( aPath,
false, aDepth + 1 );
1318 if( token->IsSameAs(
m_fields[ i ].GetName() )
1319 || token->IsSameAs(
m_fields[ i ].GetName().Upper() ) )
1321 *token =
m_fields[ i ].GetShownText( aPath,
false, aDepth + 1 );
1329 if( token->IsSameAs( templateFieldname.m_Name )
1330 || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
1334 *token = wxEmptyString;
1339 if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
1343 wxArrayString parts = wxSplit( footprint,
':' );
1345 if( parts.Count() > 0 )
1346 *token = parts[ 0 ];
1348 *token = wxEmptyString;
1352 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
1356 wxArrayString parts = wxSplit( footprint,
':' );
1358 if( parts.Count() > 1 )
1359 *token = parts[ std::min( 1, (
int) parts.size() - 1 ) ];
1361 *token = wxEmptyString;
1365 else if( token->IsSameAs( wxT(
"UNIT" ) ) )
1372 else if( token->IsSameAs( wxT(
"SYMBOL_LIBRARY" ) ) )
1377 else if( token->IsSameAs( wxT(
"SYMBOL_NAME" ) ) )
1382 else if( token->IsSameAs( wxT(
"SYMBOL_DESCRIPTION" ) ) )
1387 else if( token->IsSameAs( wxT(
"SYMBOL_KEYWORDS" ) ) )
1392 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOM" ) ) )
1395 : wxString( wxT(
"" ) );
1398 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_BOARD" ) ) )
1401 : wxString( wxT(
"" ) );
1404 else if( token->IsSameAs( wxT(
"EXCLUDE_FROM_SIM" ) ) )
1407 : wxString( wxT(
"" ) );
1410 else if( token->IsSameAs( wxT(
"DNP" ) ) )
1412 *token = this->
GetDNP() ?
_(
"DNP" ) : wxString( wxT(
"" ) );
1415 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) )
1416 || token->StartsWith( wxT(
"NET_NAME(" ) )
1417 || token->StartsWith( wxT(
"NET_CLASS(" ) )
1418 || token->StartsWith( wxT(
"PIN_NAME(" ) ) )
1420 wxString pinNumber = token->AfterFirst(
'(' );
1421 pinNumber = pinNumber.BeforeLast(
')' );
1425 if(
pin->GetNumber() == pinNumber )
1427 if( token->StartsWith( wxT(
"PIN_NAME" ) ) )
1429 *token =
pin->GetAlt().IsEmpty() ?
pin->GetName() :
pin->GetAlt();
1436 *token = wxEmptyString;
1437 else if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
1439 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
1440 *token = conn->
Name();
1441 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
1442 *token =
pin->GetEffectiveNetClass( aPath )->GetName();
1465 if( instance.m_Path ==
path )
1467 if( instance.m_Reference.IsEmpty() || aResetPrefix )
1478 if( instance.m_Reference.IsEmpty() || aResetPrefix)
1485 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1486 pin->ClearDefaultNetName( aSheetPath );
1494 if( currentReference.IsEmpty() || aResetPrefix )
1504 wxCHECK( aSheetPath.size() > 0,
false );
1509 if( instance.m_Path == aSheetPath )
1522 bool transform =
false;
1524 switch( aOrientation )
1534 temp.
x1 = temp.
y2 = 0;
1541 temp.
x1 = temp.
y2 = 0;
1550 temp.
y1 = temp.
x2 = 0;
1557 temp.
y1 = temp.
x2 = 0;
1619 wxFAIL_MSG(
"Invalid schematic symbol orientation type." );
1655 int rotate_values[] =
1675 for(
int type_rotate : rotate_values )
1687 wxFAIL_MSG(
"Schematic symbol orientation matrix internal error." );
1695void SCH_SYMBOL::Show(
int nestLevel, std::ostream& os )
const
1698 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str()
1700 <<
'"' <<
" chipName=\""
1708 const wxString& value =
GetFields()[i].GetText();
1710 if( !value.IsEmpty() )
1712 NestedSpace( nestLevel + 1, os ) <<
"<field" <<
" name=\""
1714 <<
'"' <<
" value=\""
1715 <<
TO_UTF8( value ) <<
"\"/>\n";
1719 NestedSpace( nestLevel, os ) <<
"</" <<
TO_UTF8(
GetClass().Lower() ) <<
">\n";
1734 int x0 = bBox.
GetX();
1740 int y0 = -bBox.
GetY();
1757 if( aIncludeFields )
1761 if( field.IsVisible() )
1762 bBox.
Merge( field.GetBoundingBox() );
1801 msgs.Add(
_(
"Simulation" ) );
1804 msgs.Add(
_(
"BOM" ) );
1807 msgs.Add(
_(
"Board" ) );
1810 msgs.Add(
_(
"DNP" ) );
1812 msg = wxJoin( msgs,
'|' );
1813 msg.Replace(
'|', wxS(
", " ) );
1816 aList.emplace_back(
_(
"Exclude from" ), msg );
1827 aList.emplace_back(
_(
"Power symbol" ),
1832 aList.emplace_back(
_(
"Reference" ),
1836 aList.emplace_back(
_(
"Value" ),
1839 aList.emplace_back(
_(
"Name" ),
1844 aList.emplace_back(
_(
"flags" ), wxString::Format(
"%X",
GetEditFlags() ) );
1849 msg =
_(
"Missing parent" );
1851 std::shared_ptr< LIB_SYMBOL > parent =
m_part->GetParent().lock();
1854 msg = parent->GetName();
1864 aList.emplace_back(
_(
"Library" ),
_(
"Undefined!!!" ) );
1872 msg =
_(
"<Unknown>" );
1874 aList.emplace_back(
_(
"Footprint" ), msg );
1877 aList.emplace_back(
_(
"Description" ) + wxT(
": " )
1879 _(
"Keywords" ) + wxT(
": " ) +
m_part->GetKeyWords() );
1884 aList.emplace_back(
_(
"Reference" ),
GetRef( currentSheet ) );
1886 aList.emplace_back(
_(
"Value" ),
1889 aList.emplace_back(
_(
"Name" ),
1894 if( libNickname.empty() )
1895 msg =
_(
"No library defined!" );
1897 msg.Printf(
_(
"Symbol not found in %s!" ), libNickname );
1899 aList.emplace_back(
_(
"Library" ), msg );
1906 return BITMAPS::add_component;
1923 field.SetTextPos( pos );
1941 field.SetTextPos( pos );
1960 field.SetTextPos( pos );
1982 aItemList.push_back( item );
1990 bool changed =
false;
1992 for( std::unique_ptr<SCH_PIN>&
pin :
m_pins )
1994 bool previousState =
pin->IsDangling();
1995 pin->SetIsDangling(
true );
2005 if( each_item.GetParent() ==
this )
2008 switch( each_item.GetType() )
2017 if( pos == each_item.GetPosition() )
2018 pin->SetIsDangling(
false );
2026 if( !
pin->IsDangling() )
2030 changed = ( changed || ( previousState !=
pin->IsDangling() ) );
2040 wxT(
"Cannot get physical position of pin." ) );
2048 std::vector<VECTOR2I> retval;
2050 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2054 int pin_unit =
pin->GetLibPin()->GetUnit();
2055 int pin_convert =
pin->GetLibPin()->GetConvert();
2057 if( pin_unit > 0 && pin_unit !=
GetUnit() )
2060 if( pin_convert > 0 && pin_convert !=
GetConvert() )
2086 return wxString::Format(
_(
"Symbol %s [%s]" ),
2093 const std::vector<KICAD_T>& aScanTypes )
2095 for(
KICAD_T scanType : aScanTypes )
2101 if( INSPECT_RESULT::QUIT == aInspector(
this, aTestData ) )
2102 return INSPECT_RESULT::QUIT;
2109 if( INSPECT_RESULT::QUIT == aInspector( &field, (
void*)
this ) )
2110 return INSPECT_RESULT::QUIT;
2117 return INSPECT_RESULT::QUIT;
2124 return INSPECT_RESULT::QUIT;
2130 return INSPECT_RESULT::QUIT;
2136 return INSPECT_RESULT::QUIT;
2141 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2145 int pin_unit =
pin->GetLibPin()->GetUnit();
2146 int pin_convert =
pin->GetLibPin()->GetConvert();
2148 if( pin_unit > 0 && pin_unit !=
GetUnit() )
2151 if( pin_convert > 0 && pin_convert !=
GetConvert() )
2154 if( INSPECT_RESULT::QUIT == aInspector(
pin.get(), (
void*)
this ) )
2155 return INSPECT_RESULT::QUIT;
2160 return INSPECT_RESULT::CONTINUE;
2169 auto symbol =
static_cast<const SCH_SYMBOL*
>( &aItem );
2173 if( rect.
GetArea() != symbol->GetBodyAndPinsBoundingBox().GetArea() )
2174 return rect.
GetArea() < symbol->GetBodyAndPinsBoundingBox().GetArea();
2176 if(
m_pos.
x != symbol->m_pos.x )
2177 return m_pos.
x < symbol->m_pos.x;
2179 if(
m_pos.
y != symbol->m_pos.y )
2180 return m_pos.
y < symbol->m_pos.y;
2203 return !( *
this == aSymbol );
2209 wxCHECK_MSG(
Type() == aItem.
Type(), *
this,
2210 wxT(
"Cannot assign object type " ) + aItem.
GetClass() + wxT(
" to type " ) +
2213 if( &aItem !=
this )
2223 m_part.reset( libSymbol );
2235 field.SetParent(
this );
2247 bBox.
Inflate( aAccuracy / 2 );
2263 rect.
Inflate( aAccuracy / 2 );
2278 if(
pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
2283 int pin_unit =
pin->GetLibPin()->GetUnit();
2284 int pin_convert =
pin->GetLibPin()->GetConvert();
2286 if( pin_unit > 0 && pin_unit !=
GetUnit() )
2289 if( pin_convert > 0 && pin_convert !=
GetConvert() )
2292 if(
pin->GetLocalPosition() == new_pos )
2322 for(
unsigned i = 0; i < tempPins.size(); ++ i )
2325 LIB_PIN* tempPin = tempPins[ i ];
2342 text->SetText(
dummy.GetShownText(
false ) );
2349 for(
bool local_background : {
true,
false } )
2356 field.ClearRenderCache();
2357 field.Plot( aPlotter, local_background );
2365 std::vector<wxString> properties;
2370 wxString text_field = field.GetShownText( sheet,
false);
2372 if( text_field.IsEmpty() )
2375 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ),
2376 field.GetName(), text_field ) );
2379 if( !
m_part->GetKeyWords().IsEmpty() )
2381 properties.emplace_back( wxString::Format( wxT(
"!%s = %s" ),
2383 m_part->GetKeyWords() ) );
2432 for(
unsigned i = 0; i < tempPins.size(); ++ i )
2435 LIB_PIN* tempPin = tempPins[ i ];
2450 if(
pin->IsBrightened() )
2461 pin->ClearBrightened();
2467 for(
const std::unique_ptr<SCH_PIN>&
pin :
m_pins )
2469 int pin_unit =
pin->GetLibPin()->GetUnit();
2470 int pin_convert =
pin->GetLibPin()->GetConvert();
2472 if( pin_unit > 0 && pin_unit !=
GetUnit() )
2475 if( pin_convert > 0 && pin_convert !=
GetConvert() )
2478 if(
pin->IsPointClickableAnchor( aPos ) )
2497 if( pin_list.size() != 1 )
2500 return pin_list[0]->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN;
2506 wxCHECK(
m_part,
false );
2508 return m_part->IsPower();
2520 const wxString groupAttributes =
_HKI(
"Attributes" );
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
const Vec & GetOrigin() const
void Offset(coord_type dx, coord_type dy)
void SetX(coord_type val)
bool Intersects(const BOX2< Vec > &aRect) const
void SetY(coord_type val)
coord_type GetHeight() const
coord_type GetWidth() const
void SetWidth(coord_type val)
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
coord_type GetRight() const
ecoord_type GetArea() const
Return the area of the rectangle.
void SetHeight(coord_type val)
coord_type GetBottom() const
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
Helper class used to store the state of schematic items that can be connected to other schematic item...
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
EDA_ITEM_FLAGS GetEditFlags() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * m_parent
Linked list: Link (parent struct)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextPos(const VECTOR2I &aPoint)
A color representation with 4 components: red, green, blue, alpha.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
wxString AsString() const
wxString AsString() const
Field object used in symbol libraries.
A logical library item identifier and consists of various portions much like a URI.
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
const wxString GetUniStringLibNickname() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
The base class for drawable items used by schematic library symbols.
void SetShape(GRAPHIC_PINSHAPE aShape)
void SetName(const wxString &aName)
void SetType(ELECTRICAL_PINTYPE aType)
VECTOR2I GetPosition() const override
void Plot(PLOTTER *aPlotter, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const override
Plot the draw item using the plot object.
Define a library symbol object.
void Plot(PLOTTER *aPlotter, int aUnit, int aConvert, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const
Plot lib symbol to plotter.
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
static wxString SubReference(int aUnit, bool aAddSeparator=true)
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0) const
Return a list of pin object pointers from the draw item list.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, int aMulti, int aConvert, const LIB_SYMBOL_OPTIONS &aOpts, bool aDimmed)
Print symbol.
Define a symbol library graphical text item.
Base plotter engine class.
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
virtual void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
Create a bookmark to a symbol.
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
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...
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
TEMPLATES m_TemplateFieldNames
Holds all the data relating to one schematic.
SCH_SHEET_PATH & CurrentSheet() const override
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
SCHEMATIC_SETTINGS & Settings() const
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString LocalName() const
wxString Name(bool aIgnoreSheet=false) const
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
void ImportValues(const LIB_FIELD &aSource)
Copy parameters from a LIB_FIELD source.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM & operator=(const SCH_ITEM &aPin)
virtual wxString GetClass() const override
Return the class name.
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
FIELDS_AUTOPLACED m_fieldsAutoplaced
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
bool IsDangling() const override
wxString GetShownName() 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...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
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.
SCH_FIELD * GetFieldByName(const wxString &aFieldName)
Return a field in this symbol.
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
void GetLibPins(std::vector< LIB_PIN * > &aPinsList) const
Populate a vector with all the pins from the library object.
int GetUnitCount() const
Return the number of units per package of the symbol.
bool IsSymbolLikePowerGlobalLabel() const
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
void SetConvert(int aConvert)
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
wxString GetDatasheet() const
Return the documentation text for the given part alias.
void SetLibId(const LIB_ID &aName)
std::vector< SCH_FIELD > & GetFields()
Return a vector of fields from the symbol.
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a symbol.
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...
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void PlotDNP(PLOTTER *aPlotter) const
Plot the red 'X' over the symbol.
bool operator!=(const SCH_SYMBOL &aSymbol) const
LIB_ITEM * GetDrawItem(const VECTOR2I &aPosition, KICAD_T aType=TYPE_NOT_INIT)
Return the symbol library item at aPosition that is part of this symbol.
int GetFieldCount() const
Return the number of fields in this symbol.
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
wxString GetClass() const override
Return the class name.
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
void PlotPins(PLOTTER *aPlotter) const
Plot just the symbol pins.
void SetValueFieldText(const wxString &aValue)
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
int m_convert
The alternate body style for symbols that have more than one body style defined.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
wxString GetSchSymbolLibraryName() const
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true, bool aCaseInsensitive=false)
Search for a SCH_FIELD with aFieldName.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
void ClearBrightenedPins()
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void SetExcludedFromSim(bool aExclude) override
bool m_excludedFromSim
True to exclude from simulation.
bool AddSheetPathReferenceEntryIfMissing(const KIID_PATH &aSheetPath)
Add an instance to the alternate references list (m_instanceReferences), if this entry does not alrea...
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
bool m_excludedFromBoard
True to exclude from netlist when updating board.
static std::unordered_map< TRANSFORM, int > s_transformToOrientationCache
VECTOR2I GetPinPhysicalPosition(const LIB_PIN *Pin) const
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
std::vector< SCH_SYMBOL_INSTANCE > m_instanceReferences
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
void UpdateFields(const SCH_SHEET_PATH *aPath, bool aUpdateStyle, bool aUpdateRef, bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields)
Restore fields to the original library values.
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const
void PrintBackground(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print only the background parts of a symbol (if any)
wxString GetDescription() const
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
std::unordered_map< LIB_PIN *, SCH_PIN * > m_pinMap
library pin pointer : SCH_PIN's index
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
int m_unit
The unit for multiple part per package symbols.
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.
bool GetExcludedFromBOM() const
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.
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
void SetTransform(const TRANSFORM &aTransform)
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
bool GetExcludedFromSim() const override
bool operator<(const SCH_ITEM &aItem) const override
bool m_DNP
True if symbol is set to 'Do Not Populate'.
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
wxString GetKeyWords() const
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
SCH_FIELD * GetFieldById(int aFieldId)
Return a field in this symbol.
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
TRANSFORM & GetTransform()
bool HasUnitDisplayName(int aUnit)
Return true if the given unit aUnit has a display name set.
void SetExcludedFromBOM(bool aIncludeInBOM)
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Test if the symbol's dangling state has changed for all pins.
const wxString GetValueFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
int GetOrientation() const
Get the display symbol orientation.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet)
Check if the symbol has a valid annotation (reference) for the given sheet path.
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 the netlist.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
void SetUnit(int aUnit)
Change the unit number to aUnit.
const LIB_ID & GetLibId() const
wxString GetUnitDisplayName(int aUnit)
Return the display name for a given unit aUnit.
BOX2I GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
TRANSFORM m_transform
The rotation/mirror transformation.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
SCH_SYMBOL & operator=(const SCH_ITEM &aItem)
std::vector< LIB_PIN * > GetAllLibPins() const
bool GetExcludedFromBoard() const
void SetPrefix(const wxString &aPrefix)
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
bool m_excludedFromBOM
True to exclude from bill of materials export.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
void SetExcludedFromBoard(bool aIncludeOnBoard)
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
void SortInstances(bool(*aSortFunction)(const SCH_SYMBOL_INSTANCE &aLhs, const SCH_SYMBOL_INSTANCE &aRhs))
wxString GetFieldText(const wxString &aFieldName) const
Search for a field named aFieldName and returns text associated with this field.
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
bool operator==(const SCH_SYMBOL &aSymbol) const
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field name list for read only access.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
T Convert(const wxString &aValue)
Convert a wxString to a generic type T.
static constexpr EDA_ANGLE & ANGLE_90
const INSPECTOR_FUNC & INSPECTOR
#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
void GRFilledSegment(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
@ LAYER_DEVICE_BACKGROUND
@ LAYER_SELECTION_SHADOWS
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Message panel definition file.
wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
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.
Collection of utility functions for component reference designators (refdes)
@ SYM_ROTATE_COUNTERCLOCKWISE
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
static struct SCH_SYMBOL_DESC _SCH_SYMBOL_DESC
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
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.
constexpr int MilsToIU(int mils) const
std::vector< std::pair< int, wxString > > Fields
A simple container for schematic symbol instance information.
Hold a name of a symbol's field, field value, and default visibility.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
MANDATORY_FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ DESCRIPTION_FIELD
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
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