KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PIN_LAYOUT_CACHE Class Reference

A pin layout helper is a class that manages the layout of the parts of a pin on a schematic symbol: More...

#include <pin_layout_cache.h>

Classes

struct  TEXT_EXTENTS_CACHE
 Cached extent of a text item. More...
 
struct  TEXT_INFO
 

Public Types

enum  DIRTY_FLAGS { NAME = 1 , NUMBER = 2 , ELEC_TYPE = 4 , ALL = NAME | NUMBER | ELEC_TYPE }
 

Public Member Functions

 PIN_LAYOUT_CACHE (const SCH_PIN &aPin)
 
void MarkDirty (int aFlags)
 Recompute all the layout information.
 
void SetRenderParameters (int aNameThickness, int aNumberThickness, bool aShowElectricalType, bool aShowAltIcons)
 
BOX2I GetPinBoundingBox (bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber, bool aIncludeElectricalType)
 Get the bounding box of the pin itself.
 
OPT_BOX2I GetPinNameBBox ()
 Get the bounding box of the pin name, if there is one.
 
OPT_BOX2I GetPinNumberBBox ()
 Get the bounding box of the pin number, if there is one.
 
OPT_BOX2I GetAltIconBBox ()
 Get the box of the alt mode icon, if there is one.
 
CIRCLE GetDanglingIndicator () const
 Gets the dangling indicator geometry for this pin, if the pin were to be dangling.
 
std::optional< TEXT_INFOGetPinNameInfo (int aShadowWidth)
 Get the text info for the pin name.
 
std::optional< TEXT_INFOGetPinNumberInfo (int aShadowWidth)
 
std::optional< TEXT_INFOGetPinElectricalTypeInfo (int aShadowWidth)
 

Private Member Functions

bool isDirty (int aMask) const
 
void setClean (int aMask)
 
void recomputeCaches ()
 Recompute all the caches that have become dirty.
 
void transformBoxForPin (BOX2I &aBox) const
 Transform a box (in-place) to the pin's orientation.
 
void transformTextForPin (TEXT_INFO &aTextInfo) const
 Transform text info to suit a pin's.
 
int getPinTextOffset () const
 Get the current pin text offset.
 
int getNumberBlockOffset () const
 Get the distance from the pin to the centre of the drawn number, measured perpendicular to the pin.
 
OPT_BOX2I getUntransformedPinNameBox () const
 Get the untransformd text box in the default orientation.
 
OPT_BOX2I getUntransformedPinNumberBox () const
 
OPT_BOX2I getUntransformedPinTypeBox () const
 
OPT_BOX2I getUntransformedAltIconBox () const
 
OPT_BOX2I getUntransformedDecorationBox () const
 Pin type decoration if any.
 

Static Private Member Functions

static void recomputeExtentsCache (bool aDefinitelyDirty, KIFONT::FONT *aFont, int aSize, const wxString &aText, const KIFONT::METRICS &aFontMetrics, TEXT_EXTENTS_CACHE &aCache)
 

Private Attributes

const SCH_PINm_pin
 The pin in question.
 
const SCHEMATIC_SETTINGSm_schSettings
 
int m_dirtyFlags
 
float m_shadowOffsetAdjust = 1.0f
 
int m_nameThickness = 0
 
int m_numberThickness = 0
 
bool m_showElectricalType = false
 
bool m_showAltIcons = false
 
wxString m_numSource
 
int m_numSourceLength = -1
 
TEXT_EXTENTS_CACHE m_numExtentsCache
 
TEXT_EXTENTS_CACHE m_nameExtentsCache
 
TEXT_EXTENTS_CACHE m_typeExtentsCache
 

Detailed Description

A pin layout helper is a class that manages the layout of the parts of a pin on a schematic symbol:

including, extents of:

  • the pin itself
  • the pin number, number, type
  • decorations
  • alternate mode icons

This is useful, because this information is used in multiple places, and regenerating it in multiple places is error-prone. It can also be cached if it's encapsulated in one place.

Definition at line 47 of file pin_layout_cache.h.

Member Enumeration Documentation

◆ DIRTY_FLAGS

Enumerator
NAME 
NUMBER 
ELEC_TYPE 
ALL 

Definition at line 52 of file pin_layout_cache.h.

Constructor & Destructor Documentation

◆ PIN_LAYOUT_CACHE()

PIN_LAYOUT_CACHE::PIN_LAYOUT_CACHE ( const SCH_PIN & aPin)

Member Function Documentation

◆ GetAltIconBBox()

OPT_BOX2I PIN_LAYOUT_CACHE::GetAltIconBBox ( )

Get the box of the alt mode icon, if there is one.

Definition at line 752 of file pin_layout_cache.cpp.

References getUntransformedAltIconBox(), and transformBoxForPin().

Referenced by KIGFX::SCH_PAINTER::draw().

◆ GetDanglingIndicator()

CIRCLE PIN_LAYOUT_CACHE::GetDanglingIndicator ( ) const

Gets the dangling indicator geometry for this pin, if the pin were to be dangling.

Definition at line 495 of file pin_layout_cache.cpp.

References m_pin, and TARGET_PIN_RADIUS.

Referenced by KIGFX::SCH_PAINTER::draw(), KIGFX::SCH_PAINTER::drawPinDanglingIndicator(), and GetPinBoundingBox().

◆ getNumberBlockOffset()

int PIN_LAYOUT_CACHE::getNumberBlockOffset ( ) const
private

Get the distance from the pin to the centre of the drawn number, measured perpendicular to the pin.

A stacked number is a column of lines, so this grows with the line count.

Definition at line 504 of file pin_layout_cache.cpp.

References getPinTextOffset(), KiROUND(), m_numberThickness, m_numExtentsCache, m_pin, PIN_TEXT_MARGIN, schIUScale, and wxStringSplit().

Referenced by GetPinNumberInfo().

◆ GetPinBoundingBox()

◆ GetPinElectricalTypeInfo()

◆ GetPinNameBBox()

OPT_BOX2I PIN_LAYOUT_CACHE::GetPinNameBBox ( )

Get the bounding box of the pin name, if there is one.

Definition at line 728 of file pin_layout_cache.cpp.

References getUntransformedPinNameBox(), recomputeCaches(), and transformBoxForPin().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and SCH_TOOL_BASE< T >::Increment().

◆ GetPinNameInfo()

◆ GetPinNumberBBox()

◆ GetPinNumberInfo()

◆ getPinTextOffset()

int PIN_LAYOUT_CACHE::getPinTextOffset ( ) const
private

◆ getUntransformedAltIconBox()

OPT_BOX2I PIN_LAYOUT_CACHE::getUntransformedAltIconBox ( ) const
private

◆ getUntransformedDecorationBox()

OPT_BOX2I PIN_LAYOUT_CACHE::getUntransformedDecorationBox ( ) const
private

◆ getUntransformedPinNameBox()

OPT_BOX2I PIN_LAYOUT_CACHE::getUntransformedPinNameBox ( ) const
private

Get the untransformd text box in the default orientation.

This will have to be offset and rotated.

Definition at line 528 of file pin_layout_cache.cpp.

References BOX2< VECTOR2I >::ByCenter(), getPinTextOffset(), m_nameExtentsCache, m_pin, and BOX2< Vec >::Move().

Referenced by GetPinBoundingBox(), GetPinNameBBox(), and getUntransformedAltIconBox().

◆ getUntransformedPinNumberBox()

OPT_BOX2I PIN_LAYOUT_CACHE::getUntransformedPinNumberBox ( ) const
private

◆ getUntransformedPinTypeBox()

OPT_BOX2I PIN_LAYOUT_CACHE::getUntransformedPinTypeBox ( ) const
private

◆ isDirty()

bool PIN_LAYOUT_CACHE::isDirty ( int aMask) const
inlineprivate

Definition at line 118 of file pin_layout_cache.h.

References m_dirtyFlags.

Referenced by recomputeCaches().

◆ MarkDirty()

void PIN_LAYOUT_CACHE::MarkDirty ( int aFlags)

Recompute all the layout information.

Definition at line 160 of file pin_layout_cache.cpp.

References m_dirtyFlags.

Referenced by SetRenderParameters().

◆ recomputeCaches()

◆ recomputeExtentsCache()

void PIN_LAYOUT_CACHE::recomputeExtentsCache ( bool aDefinitelyDirty,
KIFONT::FONT * aFont,
int aSize,
const wxString & aText,
const KIFONT::METRICS & aFontMetrics,
TEXT_EXTENTS_CACHE & aCache )
staticprivate

◆ setClean()

void PIN_LAYOUT_CACHE::setClean ( int aMask)
inlineprivate

Definition at line 123 of file pin_layout_cache.h.

References m_dirtyFlags.

Referenced by recomputeCaches().

◆ SetRenderParameters()

void PIN_LAYOUT_CACHE::SetRenderParameters ( int aNameThickness,
int aNumberThickness,
bool aShowElectricalType,
bool aShowAltIcons )

◆ transformBoxForPin()

◆ transformTextForPin()

void PIN_LAYOUT_CACHE::transformTextForPin ( TEXT_INFO & aTextInfo) const
private

Transform text info to suit a pin's.

Parameters
the'nominal' text info for a PIN_RIGHT pin, which will be adjusted

Definition at line 350 of file pin_layout_cache.cpp.

References ANGLE_VERTICAL, DefaultTransform, GetFlippedAlignment(), PIN_LAYOUT_CACHE::TEXT_INFO::m_Angle, PIN_LAYOUT_CACHE::TEXT_INFO::m_HAlign, m_pin, PIN_LAYOUT_CACHE::TEXT_INFO::m_TextPosition, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_UP, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GetPinElectricalTypeInfo(), and GetPinNameInfo().

Member Data Documentation

◆ m_dirtyFlags

int PIN_LAYOUT_CACHE::m_dirtyFlags
private

Definition at line 190 of file pin_layout_cache.h.

Referenced by isDirty(), MarkDirty(), PIN_LAYOUT_CACHE(), and setClean().

◆ m_nameExtentsCache

TEXT_EXTENTS_CACHE PIN_LAYOUT_CACHE::m_nameExtentsCache
private

Definition at line 205 of file pin_layout_cache.h.

Referenced by getUntransformedPinNameBox(), and recomputeCaches().

◆ m_nameThickness

int PIN_LAYOUT_CACHE::m_nameThickness = 0
private

Definition at line 194 of file pin_layout_cache.h.

Referenced by GetPinNameInfo(), and SetRenderParameters().

◆ m_numberThickness

int PIN_LAYOUT_CACHE::m_numberThickness = 0
private

Definition at line 195 of file pin_layout_cache.h.

Referenced by getNumberBlockOffset(), GetPinNumberInfo(), and SetRenderParameters().

◆ m_numExtentsCache

TEXT_EXTENTS_CACHE PIN_LAYOUT_CACHE::m_numExtentsCache
private

◆ m_numSource

wxString PIN_LAYOUT_CACHE::m_numSource
private

Definition at line 200 of file pin_layout_cache.h.

Referenced by recomputeCaches().

◆ m_numSourceLength

int PIN_LAYOUT_CACHE::m_numSourceLength = -1
private

Definition at line 201 of file pin_layout_cache.h.

Referenced by recomputeCaches().

◆ m_pin

◆ m_schSettings

const SCHEMATIC_SETTINGS* PIN_LAYOUT_CACHE::m_schSettings
private

◆ m_shadowOffsetAdjust

float PIN_LAYOUT_CACHE::m_shadowOffsetAdjust = 1.0f
private

Definition at line 193 of file pin_layout_cache.h.

Referenced by GetPinElectricalTypeInfo(), GetPinNameInfo(), and recomputeCaches().

◆ m_showAltIcons

bool PIN_LAYOUT_CACHE::m_showAltIcons = false
private

Definition at line 197 of file pin_layout_cache.h.

Referenced by getUntransformedAltIconBox(), and SetRenderParameters().

◆ m_showElectricalType

bool PIN_LAYOUT_CACHE::m_showElectricalType = false
private

◆ m_typeExtentsCache

TEXT_EXTENTS_CACHE PIN_LAYOUT_CACHE::m_typeExtentsCache
private

Definition at line 206 of file pin_layout_cache.h.

Referenced by getUntransformedPinTypeBox(), and recomputeCaches().


The documentation for this class was generated from the following files: