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
 Pin type decoration if any.
 
OPT_BOX2I getUntransformedDecorationBox () const
 

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

Member Enumeration Documentation

◆ DIRTY_FLAGS

Enumerator
NAME 
NUMBER 
ELEC_TYPE 
ALL 

Definition at line 55 of file pin_layout_cache.h.

Constructor & Destructor Documentation

◆ PIN_LAYOUT_CACHE()

PIN_LAYOUT_CACHE::PIN_LAYOUT_CACHE ( const SCH_PIN aPin)

Definition at line 72 of file pin_layout_cache.cpp.

References m_schSettings, SCH_ITEM::Schematic(), and SCHEMATIC::Settings().

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 594 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 367 of file pin_layout_cache.cpp.

References SCH_PIN::GetPosition(), 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 570 of file pin_layout_cache.cpp.

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

Referenced by SYMBOL_EDITOR_EDIT_TOOL::Increment().

◆ GetPinNameInfo()

◆ GetPinNumberBBox()

OPT_BOX2I PIN_LAYOUT_CACHE::GetPinNumberBBox ( )

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

Definition at line 582 of file pin_layout_cache.cpp.

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

Referenced by SYMBOL_EDITOR_EDIT_TOOL::Increment(), and SYMBOL_EDITOR_EDIT_TOOL::Properties().

◆ GetPinNumberInfo()

◆ getPinTextOffset()

int PIN_LAYOUT_CACHE::getPinTextOffset ( ) const
private

◆ getUntransformedAltIconBox()

◆ getUntransformedDecorationBox()

◆ getUntransformedPinNameBox()

OPT_BOX2I PIN_LAYOUT_CACHE::getUntransformedPinNameBox ( ) const
private

◆ getUntransformedPinNumberBox()

◆ getUntransformedPinTypeBox()

◆ isDirty()

bool PIN_LAYOUT_CACHE::isDirty ( int  aMask) const
inlineprivate

Definition at line 121 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 85 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 126 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

Member Data Documentation

◆ m_dirtyFlags

int PIN_LAYOUT_CACHE::m_dirtyFlags
private

Definition at line 186 of file pin_layout_cache.h.

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

◆ m_nameExtentsCache

TEXT_EXTENTS_CACHE PIN_LAYOUT_CACHE::m_nameExtentsCache
private

Definition at line 197 of file pin_layout_cache.h.

Referenced by getUntransformedPinNameBox(), and recomputeCaches().

◆ m_nameThickness

int PIN_LAYOUT_CACHE::m_nameThickness = 0
private

Definition at line 190 of file pin_layout_cache.h.

Referenced by GetPinNameInfo(), and SetRenderParameters().

◆ m_numberThickness

int PIN_LAYOUT_CACHE::m_numberThickness = 0
private

Definition at line 191 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 196 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 189 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 193 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 198 of file pin_layout_cache.h.

Referenced by getUntransformedPinTypeBox(), and recomputeCaches().


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