48#include <api/schematic/schematic_types.pb.h>
54 if( !aPinNumber.StartsWith(
"[" ) || !aPinNumber.EndsWith(
"]" ) )
59 wxString inner = aPinNumber.Mid( 1, aPinNumber.Length() - 2 );
65 for( wxString& part : parts )
66 part.Trim(
true ).Trim(
false );
69 wxString singleLine =
"[";
71 for(
size_t i = 0; i < parts.size(); ++i )
76 singleLine += parts[i];
81 const int minPinTextWidth =
schIUScale.MilsToIU( 50 );
82 const int maxPinTextWidth = std::max( aPinLength, minPinTextWidth );
84 VECTOR2D fontSize( aTextSize, aTextSize );
88 if( textExtents.
x <= maxPinTextWidth )
94 for(
size_t i = 0; i < parts.size(); ++i )
108#define PIN_TEXT_MARGIN 4
153 m_length =
schIUScale.MilsToIU( cfg->m_Defaults.pin_length );
154 m_numTextSize =
schIUScale.MilsToIU( cfg->m_Defaults.pin_num_size );
155 m_nameTextSize =
schIUScale.MilsToIU( cfg->m_Defaults.pin_name_size );
164 int aNameTextSize,
int aNumTextSize,
int aBodyStyle,
const VECTOR2I& aPos,
193 wxASSERT( aParentSymbol );
204 const KIID& aUuid ) :
214 wxASSERT( aParentSymbol );
278 pin.mutable_id()->set_value(
m_Uuid.AsStdString() );
295 SchematicPinAlternate* altProto =
pin.add_alternates();
296 altProto->set_name( alt.m_Name.ToUTF8() );
302 pin.set_active_alternate(
m_alt.ToUTF8() );
305 aContainer.PackFrom(
pin );
316 if( !aContainer.UnpackTo( &
pin ) )
320 m_name = wxString::FromUTF8(
pin.name() );
336 for(
const SchematicPinAlternate& altProto :
pin.alternates() )
339 alt.
m_Name = wxString::FromUTF8( altProto.name() );
342 alts.emplace( alt.
m_Name, alt );
357 return symbol->GetTransform().TransformCoordinate(
m_position ) + symbol->GetPosition();
378 if( !
m_alt.IsEmpty() )
413 if( !
m_alt.IsEmpty() )
446 return ::GetCanonicalElectricalTypeName(
GetType() );
505 if( !
m_alt.IsEmpty() )
529 m_name.Replace( wxT(
" " ), wxT(
"_" ) );
543 m_alt = wxEmptyString;
549 wxFAIL_MSG( wxString::Format( wxS(
"Pin '%s' has no corresponding lib_pin" ),
m_number ) );
550 m_alt = wxEmptyString;
554 if( !
m_libPin->GetAlternates().contains( aAlt ) )
556 wxFAIL_MSG( wxString::Format( wxS(
"Pin '%s' has no alterate '%s'" ),
m_number, aAlt ) );
557 m_alt = wxEmptyString;
591 || isPassiveOrNic( aPin->
GetType() );
594 wxString::Format(
"IsStacked: this='%s/%s' other='%s/%s' sameParent=%d samePos=%d sameName=%d typeCompat=%d",
596 samePos, sameName, typeCompat ) );
598 return sameParent && samePos && sameName && typeCompat;
631 bool isReplaced =
false;
655 aAccuracy = std::max( aAccuracy,
Schematic()->Settings().m_PinSymbolSize / 4 );
682 if( !
m_alt.IsEmpty() )
715 if( valid && !numbers.empty() )
716 return numbers.front();
732 const LIB_ID& aFootprintLibId,
const std::set<wxString>* aFootprintPadNumbers,
742 const LIB_SYMBOL* lib = symbol->GetLibSymbolRef().get();
752 if( assoc.m_FootprintLibId == aFootprintLibId )
766 if(
edit.m_PinNumber == pinNumber )
769 *aState = PAD_RESOLUTION::MAPPED;
771 return edit.m_PadNumber;
778 if( map && map->
HasEntry( pinNumber ) )
781 *aState = PAD_RESOLUTION::MAPPED;
786 if( aFootprintPadNumbers &&
HasIdentityPad( pinNumber, *aFootprintPadNumbers ) )
789 *aState = PAD_RESOLUTION::IDENTITY;
796 *aState = aFootprintPadNumbers ? PAD_RESOLUTION::UNMAPPED : PAD_RESOLUTION::IDENTITY;
798 return aFootprintPadNumbers ? wxString() : pinNumber;
804 if( aPads.contains( aPinNumber ) )
809 return valid && std::any_of( numbers.begin(), numbers.end(),
810 [&](
const wxString& number ) { return aPads.contains( number ); } );
819 footprintLibId.
Parse( symbol->GetFootprintFieldText( &aSheet,
RESOLVED, aVariantName ) );
832 m_number.Replace( wxT(
" " ), wxT(
"_" ) );
872 return m_libPin->GetNumberTextSize();
895 const TRANSFORM& t = symbol->GetTransform();
917 int MapX1, MapY1, x1, y1;
933 color = color.
Mix( bg, 0.5f );
940 x1 = aPosition.
x; y1 = aPosition.
y;
942 switch( aOrientation )
976 aPlotter->
MoveTo(
VECTOR2I( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ) );
1013 aPlotter->
LineTo(
VECTOR2I( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
1019 aPlotter->
LineTo(
VECTOR2I( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
1043 y1 - ( MapY1 - MapX1 ) * deco_size ) );
1045 y1 + ( MapY1 - MapX1 ) * deco_size ) );
1047 y1 - ( MapY1 + MapX1 ) * deco_size ) );
1049 y1 + ( MapY1 + MapX1 ) * deco_size ) );
1055 const int ex1 = aPosition.
x;
1056 const int ey1 = aPosition.
y;
1057 aPlotter->
MoveTo(
VECTOR2I( ex1 - deco_size, ey1 - deco_size ) );
1059 aPlotter->
MoveTo(
VECTOR2I( ex1 + deco_size, ey1 - deco_size ) );
1066 int aTextInside,
bool aDrawPinNum,
bool aDrawPinName,
bool aDimmed )
const
1074 if( aDrawPinNum && !number.IsEmpty() )
1081 aDrawPinName =
false;
1084 aDrawPinNum =
false;
1086 if( !aDrawPinNum && !aDrawPinName )
1115 nameColor = nameColor.
Mix( bg, 0.5f );
1116 numColor = numColor.
Mix( bg, 0.5f );
1122 switch( aPinOrient )
1132 const bool flipStacked =
1135 auto plotSimpleText =
1137 const wxString& txt,
int size,
int penWidth,
const COLOR4D& col )
1149 auto plotMultiLineWithBraces =
1153 if( !number.StartsWith(
"[" ) || !number.EndsWith(
"]" ) || !number.Contains(
"\n" ) )
1156 numPenWidth, numColor );
1160 wxString content = number.Mid( 1, number.Length() - 2 );
1161 wxArrayString lines;
1164 if( lines.size() <= 1 )
1167 numPenWidth, numColor );
1172 const int lineSpacing =
KiROUND( textSize * 1.3 );
1173 const int numLines = (int) lines.size();
1177 if( aAllowFlip && flipStacked )
1181 anchorX = 2 * aPinPos.
x - anchorX;
1183 anchorY = 2 * aPinPos.
y - anchorY;
1193 int firstLineCentre;
1200 firstLineCentre = -( numLines - 1 ) * lineSpacing / 2;
1204 firstLineCentre += verticalText ? anchorX : anchorY;
1207 int maxLineWidth = 0;
1209 for(
int i = 0; i < numLines; ++i )
1211 wxString l = lines[i];
1212 l.Trim(
true ).Trim(
false );
1216 maxLineWidth = std::max( maxLineWidth, ext.
x );
1218 int stack = firstLineCentre + i * lineSpacing;
1219 int lx = verticalText ? stack : anchorX;
1220 int ly = verticalText ? anchorY : stack;
1226 auto plotBrace = [&](
const VECTOR2I&
top,
const VECTOR2I& bottom,
bool leftOrTop,
bool isVerticalText )
1230 int braceWidth = textSize / 3;
1236 int offset = leftOrTop ? -braceWidth : braceWidth;
1238 if( isVerticalText )
1266 const int braceWidth = textSize / 3;
1267 const int extraHeight = textSize / 3;
1268 const int braceSpacing = maxLineWidth / 2 + braceWidth;
1269 const int blockSpan = ( numLines - 1 ) * lineSpacing;
1273 VECTOR2I braceStart( firstLineCentre - 2 * extraHeight, anchorY );
1274 VECTOR2I braceEnd( firstLineCentre + blockSpan, anchorY );
1277 topStart.
y -= braceSpacing;
1279 topEnd.
y -= braceSpacing;
1281 bottomStart.
y += braceSpacing;
1283 bottomEnd.
y += braceSpacing;
1285 plotBrace( topStart, topEnd,
true,
true );
1286 plotBrace( bottomStart, bottomEnd,
false,
true );
1290 VECTOR2I braceStart( anchorX, firstLineCentre - 2 * extraHeight );
1291 VECTOR2I braceEnd( anchorX, firstLineCentre + blockSpan );
1294 leftTop.
x -= braceSpacing;
1296 leftBot.
x -= braceSpacing;
1298 rightTop.
x += braceSpacing;
1300 rightBot.
x += braceSpacing;
1302 plotBrace( leftTop, leftBot,
true,
false );
1303 plotBrace( rightTop, rightBot,
false,
false );
1328 plotMultiLineWithBraces( ( x1 + aPinPos.
x ) / 2, y1 - num_offset,
ANGLE_HORIZONTAL,
1344 plotMultiLineWithBraces( x1 - num_offset, ( y1 + aPinPos.
y ) / 2,
ANGLE_VERTICAL,
1358 plotMultiLineWithBraces( x1 - num_offset, ( y1 + aPinPos.
y ) / 2,
ANGLE_VERTICAL,
1368 if( aDrawPinName && aDrawPinNum )
1376 else if( aDrawPinName )
1382 else if( aDrawPinNum )
1384 plotMultiLineWithBraces( ( x1 + aPinPos.
x ) / 2, y1 - name_offset,
ANGLE_HORIZONTAL,
1390 if( aDrawPinName && aDrawPinNum )
1392 plotSimpleText( x1 - name_offset, ( y1 + aPinPos.
y ) / 2,
ANGLE_VERTICAL,
1398 else if( aDrawPinName )
1400 plotSimpleText( x1 - name_offset, ( y1 + aPinPos.
y ) / 2,
ANGLE_VERTICAL,
1404 else if( aDrawPinNum )
1406 plotMultiLineWithBraces( x1 - num_offset, ( y1 + aPinPos.
y ) / 2,
ANGLE_VERTICAL,
1477 int lengthChange =
GetLength() - aLength;
1485 offsetX = lengthChange;
1488 offsetX = -1 * lengthChange;
1491 offsetY = -1 * lengthChange;
1494 offsetY = lengthChange;
1588 int aUnit,
int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
1612 aList.emplace_back(
_(
"Type" ),
_(
"Pin" ) );
1621 aList.emplace_back(
_(
"Visible" ),
IsVisible() ?
_(
"Yes" ) :
_(
"No" ) );
1639 aList.emplace_back( symbol->
GetRef( currentSheet ),
1694 if( it->second.second == aForceNoConnect )
1695 return it->second.first;
1705 if( !aForceNoConnect && !fact.
noConnect )
1722 wxString::Format(
"GetDefaultNetName: stacked pin shown='%s' -> using smallest logical='%s'",
1731 if( !reference.reference.IsEmpty() && reference.reference.Last() !=
'?' )
1754 if( aCache->
m_Font == aFont
1773 bool aIncludeElectricalType )
const
1777 aIncludeNameAndNumber,
1778 aIncludeElectricalType );
1785 m_layoutCache = std::make_unique<PIN_LAYOUT_CACHE>( *
this );
1801 wxCHECK(
pin,
false );
1835 if( parentSymbol->IsLocked() )
1865 if( !
m_alt.IsEmpty() )
1868 alt = &localStorage;
1871 wxString itemDesc =
m_libPin ?
m_libPin->GetItemDescription( aUnitsProvider, alt )
1872 : wxString( wxS(
"Undefined library pin." ) );
1876 return wxString::Format(
"Symbol %s %s",
1893 if ( !
name.IsEmpty() )
1895 return wxString::Format(
_(
"Pin %s [%s, %s, %s]" ),
1903 return wxString::Format(
_(
"Pin %s [%s, %s]" ),
1911 if( !
name.IsEmpty() )
1913 return wxString::Format(
_(
"Hidden pin %s [%s, %s, %s]" ),
1921 return wxString::Format(
_(
"Hidden pin %s [%s, %s]" ),
1932struct PIN_COMPARISON_VIEW
1938 const wxString& number;
1939 std::optional<int> length;
1943 std::optional<bool> hidden;
1944 std::optional<int> numberTextSize;
1945 std::optional<int> nameTextSize;
1946 const std::map<wxString, PIN_ALTERNATE>& alternates;
1948 int Compare(
const PIN_COMPARISON_VIEW& aOther,
int aCompareFlags )
const
1952 if( unit != aOther.unit )
1953 return unit - aOther.unit;
1955 if( bodyStyle != aOther.bodyStyle )
1956 return bodyStyle - aOther.bodyStyle;
1959 if( isPrivate != aOther.isPrivate )
1960 return isPrivate ? 1 : -1;
1962 if( number != aOther.number )
1963 return StrNumCmp( number, aOther.number );
1965 if( position.x != aOther.position.
x )
1966 return position.x - aOther.position.
x;
1968 if( position.y != aOther.position.
y )
1969 return position.y - aOther.position.
y;
1971 if( length != aOther.length )
1972 return length.value_or( 0 ) - aOther.length.value_or( 0 );
1974 if( orientation != aOther.orientation )
1975 return static_cast<int>( orientation ) -
static_cast<int>( aOther.orientation );
1977 if( shape != aOther.shape )
1978 return static_cast<int>( shape ) -
static_cast<int>( aOther.shape );
1980 if( type != aOther.type )
1981 return static_cast<int>( type ) -
static_cast<int>( aOther.type );
1984 return hidden.value_or(
false ) - aOther.hidden.value_or(
false );
1986 if( numberTextSize != aOther.numberTextSize )
1987 return numberTextSize.value_or( 0 ) - aOther.numberTextSize.value_or( 0 );
1989 if( nameTextSize != aOther.nameTextSize )
1990 return nameTextSize.value_or( 0 ) - aOther.nameTextSize.value_or( 0 );
1995 if( alternates.size() != aOther.alternates.size() )
1996 return static_cast<int>( alternates.size() - aOther.alternates.size() );
1998 auto lhsItem = alternates.begin();
1999 auto rhsItem = aOther.alternates.begin();
2001 while( lhsItem != alternates.end() )
2003 const PIN_ALTERNATE& lhsAlt = lhsItem->second;
2004 const PIN_ALTERNATE& rhsAlt = rhsItem->second;
2012 return static_cast<int>( lhsAlt.
m_Type ) -
static_cast<int>( rhsAlt.
m_Type );
2015 return static_cast<int>( lhsAlt.
m_Shape ) -
static_cast<int>( rhsAlt.
m_Shape );
2035 return pinComparisonView( *this ).Compare( pinComparisonView( aOther ), aCompareFlags );
2067 return lhs.Compare( rhs, aCompareFlags );
2165 aStream <<
"SCH_PIN:" << std::endl
2166 <<
" Name: \"" <<
m_name <<
"\"" << std::endl
2167 <<
" Number: \"" <<
m_number <<
"\"" << std::endl
2169 <<
" Length: " <<
GetLength() << std::endl
2182void SCH_PIN::Show(
int nestLevel, std::ostream& os )
const
2184 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str()
2205 if( pinTypeEnum.Choices().GetCount() == 0 )
2223 if( pinShapeEnum.Choices().GetCount() == 0 )
2238 if( orientationEnum.Choices().GetCount() == 0 )
2246 auto isSymbolEditor =
2250 return dynamic_cast<LIB_SYMBOL*
>(
pin->GetParentSymbol() ) !=
nullptr;
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr bool Contains(const Vec &aPoint) const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
static const COLOR4D WHITE
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
The base class for create windows for drawing purpose.
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.
EDA_ITEM * GetParent() const
EDA_ITEM * m_parent
Owner.
static bool Replace(const EDA_SEARCH_DATA &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
static ENUM_MAP< T > & Instance()
Class that other classes need to inherit from, in order to be inspectable.
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic, const METRICS &aFontMetrics) const
Compute the boundary limits of aText (the bounding box of all shapes).
A color representation with 4 components: red, green, blue, alpha.
std::shared_ptr< wxString > m_text
COLOR4D & Desaturate()
Removes color (in HSL model)
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
wxString AsString() const
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Define a library symbol object.
const std::vector< ASSOCIATED_FOOTPRINT > & GetEffectiveAssociatedFootprints() const
const PIN_MAP_SET & GetEffectivePinMaps() const
A pin layout helper is a class that manages the layout of the parts of a pin on a schematic symbol:
BOX2I GetPinBoundingBox(bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber, bool aIncludeElectricalType)
Get the bounding box of the pin itself.
const PIN_MAP * FindByName(const wxString &aName) const
const wxString & GetPadNumber(const wxString &aPinNumber) const
bool HasEntry(const wxString &aPinNumber) const
Base plotter engine class.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width)=0
void MoveTo(const VECTOR2I &pos)
void FinishTo(const VECTOR2I &pos)
RENDER_SETTINGS * RenderSettings()
bool GetColorMode() const
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
void LineTo(const VECTOR2I &pos)
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
virtual void SetColor(const COLOR4D &color)=0
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
PROPERTY_BASE & SetWriteableFunc(std::function< bool(INSPECTABLE *)> aFunc)
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.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
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.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString GetNetName() const
void AppendInfoToMsgPanel(std::vector< MSG_PANEL_ITEM > &aList) const
Adds information about the connection object to aList.
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Base class for any item which can be embedded within the SCHEMATIC container class,...
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.
SCH_ITEM & operator=(const SCH_ITEM &aPin)
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
const SYMBOL * GetParentSymbol() const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
bool IsLocked() const override
bool IsConnectivityDirty() const
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.
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
virtual int compare(const SCH_ITEM &aOther, int aCompareFlags=~COMPARE_FLAGS::UNIT) const
Provide the draw object specific comparison called by the == and < operators.
const KIFONT::METRICS & GetFontMetrics() const
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
double SimilarityBase(const SCH_ITEM &aItem) const
Calculate the boilerplate similarity for all LIB_ITEMs without preventing the use above of a pure vir...
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
std::ostream & operator<<(std::ostream &aStream)
void SetAlt(const wxString &aAlt)
Set the name of the alternate pin.
void PlotPinTexts(PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient, int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed) const
Plot the pin name and number.
VECTOR2I GetLocalPosition() const
int GetNumberTextSize() const
std::optional< bool > m_hidden
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
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.
std::unique_ptr< PIN_LAYOUT_CACHE > m_layoutCache
The layout cache for this pin.
void MirrorVerticallyPin(int aCenter)
void validateExtentsCache(KIFONT::FONT *aFont, int aSize, const wxString &aText, EXTENTS_CACHE *aCache) const
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
const std::map< wxString, ALT > & GetAlternates() const
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
void SetNumber(const wxString &aNumber)
std::optional< int > m_nameTextSize
PIN_ORIENTATION PinDrawOrient(const TRANSFORM &aTransform) const
Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), according to its orientation...
void SetVisible(bool aVisible)
void ChangeLength(int aLength)
Change the length of a pin and adjust its position based on orientation.
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
SCH_PIN & operator=(const SCH_PIN &aPin)
std::optional< wxString > GetSmallestLogicalNumber() const
Return the smallest logical pin number if this pin uses stacked notation and it is valid.
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
std::map< const SCH_SHEET_PATH, std::pair< wxString, bool > > m_net_name_map
PIN_ORIENTATION m_orientation
void SetOrientation(PIN_ORIENTATION aOrientation)
void SetName(const wxString &aName)
bool IsGlobalPower() const
Return whether this pin forms a global power connection: i.e., is part of a power symbol and of type ...
wxString getItemDescription(ALT *aAlt) const
bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Return true if this item should propagate connection info to aItem.
bool IsLocked() const override
std::optional< int > m_numTextSize
VECTOR2I GetPinRoot() const
bool IsLocalPower() const
Local power pin is the same except that it is sheet-local and it does not support the legacy hidden p...
ELECTRICAL_PINTYPE m_type
PAD_RESOLUTION
Outcome of pin-to-pad resolution (issue #2282).
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
SCH_PIN * GetLibPin() const
void SetPosition(const VECTOR2I &aPos) override
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void SetIsDangling(bool aIsDangling)
wxString GetElectricalTypeName() const
std::vector< wxString > GetStackedPinNumbers(bool *aValid=nullptr) const
std::map< wxString, ALT > m_alternates
const wxString & GetName() const
int GetStackedPinCount(bool *aValid=nullptr) const
Return the count of logical pins represented by this pin's stacked notation.
void SetLength(int aLength)
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 MirrorHorizontally(int aCenter) override
These transforms have effect only if the pin has a LIB_SYMBOL as parent.
std::recursive_mutex m_netmap_mutex
The name that this pin connection will drive onto a net.
PIN_ORIENTATION GetOrientation() const
wxString GetClass() const override
Return the class name.
void SetNumberTextSize(int aSize)
void SetShape(GRAPHIC_PINSHAPE aShape)
void RotatePin(const VECTOR2I &aCenter, bool aRotateCCW=true)
VECTOR2I GetPosition() const override
bool StackedTextSideFlipped(const TRANSFORM &aTransform) const
Return true when aTransform maps the side the stacked number block is drawn on (above horizontal pins...
wxString GetCanonicalElectricalTypeName() const
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
int GetNameTextSize() const
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
The pin specific sort order is as follows:
const wxString & GetShownName() const
void MirrorHorizontallyPin(int aCenter)
These transforms have always effects.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
PIN_LAYOUT_CACHE & GetLayoutCache() const
Get the layout cache associated with this pin.
void SetType(ELECTRICAL_PINTYPE aType)
const wxString & GetBaseName() const
Get the name without any alternates.
void ClearDefaultNetName(const SCH_SHEET_PATH *aPath)
PIN_COMPARISON_DATA ComparisonData() const
SCH_PIN(LIB_SYMBOL *aParentSymbol)
wxString GetEffectivePadNumber(const SCH_SHEET_PATH &aSheet, const wxString &aVariantName, const LIB_ID &aFootprintLibId, const std::set< wxString > *aFootprintPadNumbers, PAD_RESOLUTION *aState=nullptr) const
Resolve the footprint pad number this symbol pin lands on (issue #2282).
const wxString & GetShownNumber() const
bool IsStacked(const SCH_PIN *aPin) const
const wxString & GetNumber() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
static bool HasIdentityPad(const wxString &aPinNumber, const std::set< wxString > &aPads)
wxString GetSmallestStackedPadNumber() const
Return the pin number to be used for deterministic operations such as auto‑generated net names.
wxString GetDefaultNetName(const SCH_SHEET_PATH &aPath, bool aForceNoConnect=false)
std::optional< int > m_length
GRAPHIC_PINSHAPE GetShape() const
void PlotPinType(PLOTTER *aPlotter, const VECTOR2I &aPosition, PIN_ORIENTATION aOrientation, bool aDimmed) const
bool IsPower() const
Check if the pin is either a global or local power pin.
ELECTRICAL_PINTYPE GetType() const
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void SetNameTextSize(int aSize)
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
const wxString GetValue(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString) const override
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
A base class for LIB_SYMBOL and SCH_SYMBOL.
virtual bool IsGlobalPower() const =0
virtual bool IsLocalPower() const =0
virtual const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const =0
int GetPinNameOffset() const
virtual bool GetShowPinNames() const
virtual bool GetShowPinNumbers() const
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
#define DEFAULT_PINNUM_SIZE
The default pin name size when creating pins(can be changed in preference menu)
#define DEFAULT_PINNAME_SIZE
The default selection highlight thickness (can be changed in preference menu)
#define DEFAULT_PIN_LENGTH
The default pin number size when creating pins(can be changed in preference menu)
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define SHOW_ELEC_TYPE
Show pin electrical type.
int GetPenSizeForNormal(int aTextSize)
const wxChar *const traceStackedPins
Flag to enable debug output for stacked pins handling in symbol/pin code.
@ LAYER_SELECTION_SHADOWS
wxString RenderPinNetName(const PIN_NAME_FACT &aPin, const PIN_NAME_REFERENCE &aReference, bool aForceNoConnect)
Render a non-power pin name from unescaped values; an absent reference uses the symbol UUID.
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackDistance(types::Distance &aOutput, int aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
static int externalPinDecoSize(const SCHEMATIC_SETTINGS *aSettings, const SCH_PIN &aPin)
static int internalPinDecoSize(const SCHEMATIC_SETTINGS *aSettings, const SCH_PIN &aPin)
wxString PinShapeGetText(GRAPHIC_PINSHAPE shape)
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
@ PT_INPUT
usual pin input: must be connected
@ PT_NC
not connected (must be left open)
@ PT_TRISTATE
tri state bus pin
@ PT_NIC
not internally connected (may be connected to anything)
@ PT_BIDI
input or output (like port for a microprocessor)
@ PT_OPENEMITTER
pin type open emitter
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
@ PT_OPENCOLLECTOR
pin type open collector
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
BITMAPS ElectricalPinTypeGetBitmap(ELECTRICAL_PINTYPE)
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE)
wxString PinOrientationName(PIN_ORIENTATION aOrientation)
PIN_ORIENTATION
The symbol library pin object orientations.
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
@ PIN_RIGHT
The pin extends rightwards from the connection point.
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
@ PT_SIZE
Size expressed in distance units (mm/inch)
wxString FormatStackedPinForDisplay(const wxString &aPinNumber, int aPinLength, int aTextSize, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics)
Break a stacked pin number of the form "[A,B,C]" into one number per line when it is too wide to sit ...
static int externalPinDecoSize(const RENDER_SETTINGS *aSettings, const SCH_PIN &aPin)
Utility for getting the size of the 'external' pin decorators (as a radius) i.e.
static int internalPinDecoSize(const RENDER_SETTINGS *aSettings, const SCH_PIN &aPin)
Utility for getting the size of the 'internal' pin decorators (as a radius) i.e.
static struct SCH_PIN_DESC _SCH_PIN_DESC
wxString FormatStackedPinForDisplay(const wxString &aPinNumber, int aPinLength, int aTextSize, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics)
Break a stacked pin number of the form "[A,B,C]" into one number per line when it is too wide to sit ...
#define TARGET_PIN_RADIUS
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
T * GetAppSettings(const char *aFilename)
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
std::vector< wxString > ExpandStackedPinNotation(const wxString &aPinName, bool *aValid)
Expand stacked pin notation like [1,2,3], [1-4], [A1-A4], or [AA1-AA3,AB4,CD12-CD14] into individual ...
wxString UnescapeString(const wxString &aSource)
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
std::vector< wxString > SplitStackedPinDisplayItems(const wxString &aInner)
Split the inner part of a stacked notation string (the text between the brackets) into its individual...
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
int CountStackedPinNotation(const wxString &aPinName, bool *aValid)
Count the number of pins represented by stacked pin notation.
ELECTRICAL_PINTYPE m_Type
Owned library-pin inputs; no parent, layout cache or schematic pointers.
std::map< wxString, PIN_ALTERNATE > alternates
PIN_ORIENTATION orientation
std::optional< int > numberTextSize
std::optional< int > nameTextSize
std::optional< int > length
int Compare(const PIN_COMPARISON_DATA &aOther, int aCompareFlags) const
std::optional< bool > hidden
One symbol-pin to footprint-pad mapping inside a PIN_MAP.
Per-instance override of the active pin map and a sparse delta on top.
std::vector< PIN_MAP_ENTRY > m_Edits
PIN_MAP_OVERRIDE_MODE m_Mode
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
KIBIS top(path, &reporter)
wxString result
Test unit parsing edge cases and error handling.
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
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.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D