40 if(
m_pin.GetShownNumber().IsEmpty() || !
m_pin.GetParentSymbol()->GetShowPinNumbers() )
45 const int num_size =
m_pin.GetNumberTextSize();
48 info->m_Text = formatted;
49 info->m_TextSize = num_size;
59 const int halfLength =
m_pin.GetLength() / 2;
65 const bool flipStacked = formatted.Contains(
'\n' )
73 bool showBothNameAndNumber = !
m_pin.GetShownName().IsEmpty()
80 if( showBothNameAndNumber )
83 centerX = pinPos.
x + perpendicularOffset;
88 centerX = flipStacked ? pinPos.
x + perpendicularOffset : pinPos.
x - perpendicularOffset;
91 info->m_TextPosition.x = centerX;
94 info->m_TextPosition.y = pinPos.
y + halfLength;
96 info->m_TextPosition.y = pinPos.
y - halfLength;
105 bool showBothNameAndNumber = !
m_pin.GetShownName().IsEmpty()
112 if( showBothNameAndNumber )
115 centerY = pinPos.
y + perpendicularOffset;
120 centerY = flipStacked ? pinPos.
y + perpendicularOffset : pinPos.
y - perpendicularOffset;
124 info->m_TextPosition.x = pinPos.
x - halfLength;
126 info->m_TextPosition.x = pinPos.
x + halfLength;
128 info->m_TextPosition.y = centerY;
170 bool aShowElectricalType,
bool aShowAltIcons )
196 const wxString& aText,
202 if( !aDefinitelyDirty && aCache.
m_Font == aFont && aCache.
m_FontSize == aSize
203 && aCache.
m_Text == aText )
216 if( aText.StartsWith(
"[" ) && aText.EndsWith(
"]" ) && aText.Contains(
"\n" ) )
219 wxString content = aText.Mid( 1, aText.Length() - 2 );
223 if( lines.size() > 1 )
225 int lineSpacing =
KiROUND( aSize * 1.3 );
229 for(
const wxString& line : lines )
231 wxString trimmedLine = line;
232 trimmedLine.Trim(
true ).Trim(
false );
234 maxWidth = std::max( maxWidth, lineExtents.
x );
238 int totalHeight = aSize + ( lines.size() - 1 ) * lineSpacing;
242 int braceWidth = aSize / 3;
243 maxWidth += braceWidth * 4;
244 totalHeight += aSize / 3;
273 const int numSize =
m_pin.GetNumberTextSize();
274 const int length =
m_pin.GetLength();
275 const wxString& number =
m_pin.GetShownNumber();
293 const wxString
name =
m_pin.GetShownName();
298 double fontSize = std::max(
m_pin.GetNameTextSize() * 3 / 4,
schIUScale.mmToIU( 0.7 ) );
368 rotated.
x = -rotated.
x;
369 rotated.
y = -rotated.
y;
373 rotated = { baseLocal.
y, -baseLocal.
x };
377 rotated = { -baseLocal.
y, baseLocal.
x };
391 bool aIncludeNameAndNumber,
bool aIncludeElectricalType )
396 wxCHECK( libPin,
BOX2I() );
399 aIncludeElectricalType );
401 r = symbol->GetTransform().TransformCoordinate( r );
402 r.
Offset( symbol->GetPosition() );
408 bool includeName = aIncludeNameAndNumber && !
m_pin.GetShownName().IsEmpty();
409 bool includeNumber = aIncludeNameAndNumber && !
m_pin.GetShownNumber().IsEmpty();
410 bool includeType = aIncludeElectricalType;
412 if( !aIncludeLabelsOnInvisiblePins && !
m_pin.IsVisible() )
415 includeNumber =
false;
419 if(
const SYMBOL* parentSymbol =
m_pin.GetParentSymbol() )
421 if( !parentSymbol->GetShowPinNames() )
424 if( !parentSymbol->GetShowPinNumbers() )
425 includeNumber =
false;
430 const int pinLength =
m_pin.GetLength();
440 bbox.
Merge( pinBox );
445 bbox.
Merge( *decoBox );
452 bbox.
Merge( *nameBox );
457 bbox.
Merge( *altIconBox );
465 bbox.
Merge( *numBox );
473 bbox.
Merge( *typeBox );
479 if(
m_pin.IsDangling() )
509 const int numSize =
m_pin.GetNumberTextSize();
510 int perpHeight = numSize;
516 perpHeight = (int) lines.size() *
KiROUND( numSize * 1.3 );
525 const float offsetRatio =
533 int pinNameOffset = 0;
534 if(
const SYMBOL* parentSymbol =
m_pin.GetParentSymbol() )
536 if( parentSymbol->GetShowPinNames() )
537 pinNameOffset = parentSymbol->GetPinNameOffset();
548 const int pinLength =
m_pin.GetLength();
550 if( pinNameOffset > 0 )
573 int pinNameOffset = 0;
575 if(
const SYMBOL* parentSymbol =
m_pin.GetParentSymbol() )
577 if( parentSymbol->GetShowPinNames() )
578 pinNameOffset = parentSymbol->GetPinNameOffset();
581 const int pinLength =
m_pin.GetLength();
587 bool showBothNameAndNumber = ( pinNameOffset == 0
589 &&
m_pin.GetParentSymbol()->GetShowPinNames() );
599 if( showBothNameAndNumber )
608 textPos = flipStacked ? offset : -offset;
612 box->Move( { 0, textPos } );
642 const int iconSize = std::min(
m_pin.GetNameTextSize(),
schIUScale.mmToIU( 1.5 ) );
644 VECTOR2I c{ 0, ( nameBox->GetTop() + nameBox->GetBottom() ) / 2 };
645 if(
m_pin.GetParentSymbol()->GetPinNameOffset() > 0 )
648 c.x = nameBox->GetRight() + iconSize * 0.75;
652 c.x = nameBox->GetLeft() - iconSize * 0.75;
665 const auto makeInvertBox =
668 return BOX2I::ByCenter( { -decoSize, 0 }, { decoSize * 2, decoSize * 2 } );
671 const auto makeLowBox =
677 const auto makeClockBox =
680 return BOX2I::ByCorners( { 0, -intDecoSize }, { intDecoSize, intDecoSize } );
688 box = makeInvertBox();
692 box = makeClockBox();
696 box = makeInvertBox();
697 box->Merge( makeClockBox() );
707 box->Merge( makeClockBox() );
723 box->Move( {
m_pin.GetLength(), 0 } );
724 box->Inflate(
m_pin.GetPenWidth() / 2 );
779 if(
name.IsEmpty() || !
m_pin.GetParentSymbol()->GetShowPinNames() )
784 info->m_TextSize =
m_pin.GetNameTextSize();
788 bool nameInside =
m_pin.GetParentSymbol()->GetPinNameOffset() > 0;
793 VECTOR2I pos = {
m_pin.GetLength() +
m_pin.GetParentSymbol()->GetPinNameOffset(), 0 };
796 info->m_TextPosition = pos +
VECTOR2I{ -shadowOffset, 0 };
806 info->m_TextPosition = pos;
817 int maxHalfHeight = 0;
821 wxString n = p->GetShownName();
826 maxHalfHeight = std::max( maxHalfHeight, p->GetNameTextSize() / 2 );
831 const int halfLength =
m_pin.GetLength() / 2;
841 int centerX = pinPos.
x - perpendicularOffset;
842 info->m_TextPosition = { centerX, pinPos.
y };
845 info->m_TextPosition.y += halfLength;
847 info->m_TextPosition.y -= halfLength;
856 info->m_TextPosition = { pinPos.
x, pinPos.
y - ( maxHalfHeight +
clearance +
info->m_Thickness ) };
859 info->m_TextPosition.x -= halfLength;
861 info->m_TextPosition.x += halfLength;
876std::optional<PIN_LAYOUT_CACHE::TEXT_INFO>
885 info->m_Text =
m_pin.GetElectricalTypeName();
888 info->m_Thickness =
info->m_TextSize / 8;
897 if(
m_pin.IsDangling() )
constexpr EDA_IU_SCALE schIUScale
std::optional< BOX2I > OPT_BOX2I
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.
static constexpr BOX2< VECTOR2I > ByCorners(const VECTOR2I &aCorner1, const VECTOR2I &aCorner2)
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
static constexpr BOX2< VECTOR2I > ByCenter(const VECTOR2I &aCenter, const SizeVec &aSize)
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr const Vec GetCenter() const
constexpr coord_type GetLeft() const
constexpr void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr void Offset(coord_type dx, coord_type dy)
constexpr coord_type GetBottom() const
Represent basic circle geometry with utility geometry functions.
VECTOR2I Center
Public to make access simpler.
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)
virtual bool IsOutline() const
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).
OPT_BOX2I getUntransformedPinNameBox() const
Get the untransformd text box in the default orientation.
TEXT_EXTENTS_CACHE m_nameExtentsCache
void transformTextForPin(TEXT_INFO &aTextInfo) const
Transform text info to suit a pin's.
int getNumberBlockOffset() const
Get the distance from the pin to the centre of the drawn number, measured perpendicular to the pin.
OPT_BOX2I GetAltIconBBox()
Get the box of the alt mode icon, if there is one.
void transformBoxForPin(BOX2I &aBox) const
Transform a box (in-place) to the pin's orientation.
void recomputeCaches()
Recompute all the caches that have become dirty.
const SCHEMATIC_SETTINGS * m_schSettings
OPT_BOX2I GetPinNumberBBox()
Get the bounding box of the pin number, if there is one.
PIN_LAYOUT_CACHE(const SCH_PIN &aPin)
bool m_showElectricalType
TEXT_EXTENTS_CACHE m_typeExtentsCache
BOX2I GetPinBoundingBox(bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber, bool aIncludeElectricalType)
Get the bounding box of the pin itself.
TEXT_EXTENTS_CACHE m_numExtentsCache
OPT_BOX2I getUntransformedPinTypeBox() const
std::optional< TEXT_INFO > GetPinNameInfo(int aShadowWidth)
Get the text info for the pin name.
static void recomputeExtentsCache(bool aDefinitelyDirty, KIFONT::FONT *aFont, int aSize, const wxString &aText, const KIFONT::METRICS &aFontMetrics, TEXT_EXTENTS_CACHE &aCache)
std::optional< TEXT_INFO > GetPinElectricalTypeInfo(int aShadowWidth)
bool isDirty(int aMask) const
CIRCLE GetDanglingIndicator() const
Gets the dangling indicator geometry for this pin, if the pin were to be dangling.
std::optional< TEXT_INFO > GetPinNumberInfo(int aShadowWidth)
OPT_BOX2I GetPinNameBBox()
Get the bounding box of the pin name, if there is one.
void MarkDirty(int aFlags)
Recompute all the layout information.
void SetRenderParameters(int aNameThickness, int aNumberThickness, bool aShowElectricalType, bool aShowAltIcons)
OPT_BOX2I getUntransformedAltIconBox() const
int getPinTextOffset() const
Get the current pin text offset.
OPT_BOX2I getUntransformedDecorationBox() const
Pin type decoration if any.
const SCH_PIN & m_pin
The pin in question.
OPT_BOX2I getUntransformedPinNumberBox() const
float m_shadowOffsetAdjust
These are loaded from Eeschema settings but then overwritten by the project settings.
Holds all the data relating to one schematic.
SCHEMATIC_SETTINGS & Settings() const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
int GetNumberTextSize() const
int GetNameTextSize() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
A base class for LIB_SYMBOL and SCH_SYMBOL.
int GetPinNameOffset() const
virtual std::vector< SCH_PIN * > GetGraphicalPins(int aUnit, int aBodyStyle) const =0
virtual bool GetShowPinNames() const
#define DEFAULT_TEXT_OFFSET_RATIO
Ratio of the font height to the baseline of the text above the wire.
static bool empty(const wxTextEntryBase *aCtrl)
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
TRANSFORM DefaultTransform
int GetPenSizeForNormal(int aTextSize)
static int externalPinDecoSize(const SCHEMATIC_SETTINGS *aSettings, const SCH_PIN &aPin)
static int internalPinDecoSize(const SCHEMATIC_SETTINGS *aSettings, const SCH_PIN &aPin)
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.
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
T * GetAppSettings(const char *aFilename)
Utility functions for working with shapes.
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Cached extent of a text item.
GR_TEXT_H_ALIGN_T m_HAlign
constexpr GR_TEXT_H_ALIGN_T GetFlippedAlignment(GR_TEXT_H_ALIGN_T aAlign)
Get the reverse alignment: left-right are swapped, others are unchanged.
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