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.
 
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
 
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 48 of file pin_layout_cache.h.

Member Enumeration Documentation

◆ DIRTY_FLAGS

Enumerator
NAME 
NUMBER 
ELEC_TYPE 
ALL 

Definition at line 53 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 731 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 503 of file pin_layout_cache.cpp.

References m_pin, and TARGET_PIN_RADIUS.

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

◆ GetPinBoundingBox()

◆ GetPinElectricalTypeInfo()

◆ GetPinNameBBox()

OPT_BOX2I PIN_LAYOUT_CACHE::GetPinNameBBox ( )

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

Definition at line 707 of file pin_layout_cache.cpp.

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

Referenced by SCH_TOOL_BASE< T >::Increment().

◆ GetPinNameInfo()

◆ GetPinNumberBBox()

OPT_BOX2I PIN_LAYOUT_CACHE::GetPinNumberBBox ( )

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

Definition at line 719 of file pin_layout_cache.cpp.

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

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

◆ 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 520 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 119 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 185 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 124 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 358 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 184 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 195 of file pin_layout_cache.h.

Referenced by getUntransformedPinNameBox(), and recomputeCaches().

◆ m_nameThickness

int PIN_LAYOUT_CACHE::m_nameThickness = 0
private

Definition at line 188 of file pin_layout_cache.h.

Referenced by GetPinNameInfo(), and SetRenderParameters().

◆ m_numberThickness

int PIN_LAYOUT_CACHE::m_numberThickness = 0
private

Definition at line 189 of file pin_layout_cache.h.

Referenced by GetPinNumberInfo(), and SetRenderParameters().

◆ m_numExtentsCache

TEXT_EXTENTS_CACHE PIN_LAYOUT_CACHE::m_numExtentsCache
private

Definition at line 194 of file pin_layout_cache.h.

Referenced by getUntransformedPinNumberBox(), and 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 187 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 191 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 196 of file pin_layout_cache.h.

Referenced by getUntransformedPinTypeBox(), and recomputeCaches().


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