KiCad PCB EDA Suite
|
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_INFO > | GetPinNameInfo (int aShadowWidth) |
Get the text info for the pin name. | |
std::optional< TEXT_INFO > | GetPinNumberInfo (int aShadowWidth) |
std::optional< TEXT_INFO > | GetPinElectricalTypeInfo (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_PIN & | m_pin |
The pin in question. | |
const SCHEMATIC_SETTINGS * | m_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 |
A pin layout helper is a class that manages the layout of the parts of a pin on a schematic symbol:
including, extents of:
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.
Enumerator | |
---|---|
NAME | |
NUMBER | |
ELEC_TYPE | |
ALL |
Definition at line 55 of file pin_layout_cache.h.
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().
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().
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().
BOX2I PIN_LAYOUT_CACHE::GetPinBoundingBox | ( | bool | aIncludeLabelsOnInvisiblePins, |
bool | aIncludeNameAndNumber, | ||
bool | aIncludeElectricalType | ||
) |
Get the bounding box of the pin itself.
Definition at line 259 of file pin_layout_cache.cpp.
References BOX2< VECTOR2I >::ByCenter(), BOX2< VECTOR2I >::ByCorners(), CIRCLE::Center, SCH_PIN::GetBoundingBox(), GetDanglingIndicator(), SCH_PIN::GetLength(), SCH_PIN::GetLibPin(), SCH_ITEM::GetParentSymbol(), SCH_PIN::GetPenWidth(), SCH_PIN::GetShownName(), SCH_PIN::GetShownNumber(), getUntransformedAltIconBox(), getUntransformedDecorationBox(), getUntransformedPinNameBox(), getUntransformedPinNumberBox(), getUntransformedPinTypeBox(), BOX2< Vec >::Inflate(), SCH_PIN::IsDangling(), SCH_PIN::IsVisible(), m_pin, BOX2< Vec >::Merge(), BOX2< Vec >::Normalize(), BOX2< Vec >::Offset(), recomputeCaches(), and transformBoxForPin().
std::optional< PIN_LAYOUT_CACHE::TEXT_INFO > PIN_LAYOUT_CACHE::GetPinElectricalTypeInfo | ( | int | aShadowWidth | ) |
Definition at line 691 of file pin_layout_cache.cpp.
References ANGLE_HORIZONTAL, SCH_PIN::GetElectricalTypeName(), SCH_PIN::GetNameTextSize(), getPinTextOffset(), GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, info, SCH_PIN::IsDangling(), KiROUND(), m_pin, m_shadowOffsetAdjust, m_showElectricalType, EDA_IU_SCALE::mmToIU(), recomputeCaches(), schIUScale, TARGET_PIN_RADIUS, and transformTextForPin().
Referenced by KIGFX::SCH_PAINTER::draw().
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().
std::optional< PIN_LAYOUT_CACHE::TEXT_INFO > PIN_LAYOUT_CACHE::GetPinNameInfo | ( | int | aShadowWidth | ) |
Get the text info for the pin name.
If the pin name is not visible, this will return an empty optional.
Definition at line 605 of file pin_layout_cache.cpp.
References ANGLE_HORIZONTAL, SCH_PIN::GetLength(), SCH_PIN::GetNameTextSize(), SCH_ITEM::GetParentSymbol(), SYMBOL::GetPinNameOffset(), getPinTextOffset(), SCH_PIN::GetShownName(), SYMBOL::GetShowPinNames(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, info, KiROUND(), m_nameThickness, m_pin, m_shadowOffsetAdjust, name, recomputeCaches(), and transformTextForPin().
Referenced by KIGFX::SCH_PAINTER::draw().
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().
std::optional< PIN_LAYOUT_CACHE::TEXT_INFO > PIN_LAYOUT_CACHE::GetPinNumberInfo | ( | int | aShadowWidth | ) |
Definition at line 653 of file pin_layout_cache.cpp.
References ANGLE_HORIZONTAL, SCH_PIN::GetLength(), SCH_PIN::GetNumberTextSize(), SCH_ITEM::GetParentSymbol(), SYMBOL::GetPinNameOffset(), getPinTextOffset(), SCH_PIN::GetShownName(), SCH_PIN::GetShownNumber(), SYMBOL::GetShowPinNames(), SYMBOL::GetShowPinNumbers(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_TOP, info, m_numberThickness, m_pin, recomputeCaches(), and transformTextForPin().
Referenced by KIGFX::SCH_PAINTER::draw().
|
private |
Get the current pin text offset.
Definition at line 376 of file pin_layout_cache.cpp.
References DEFAULT_TEXT_OFFSET_RATIO, KiROUND(), m_schSettings, SCHEMATIC_SETTINGS::m_TextOffsetRatio, EDA_IU_SCALE::MilsToIU(), and schIUScale.
Referenced by GetPinElectricalTypeInfo(), GetPinNameInfo(), GetPinNumberInfo(), getUntransformedPinNameBox(), and getUntransformedPinNumberBox().
|
private |
Pin type decoration if any.
Definition at line 469 of file pin_layout_cache.cpp.
References BOX2< VECTOR2I >::ByCenter(), SCH_PIN::GetAlternates(), SCH_PIN::GetNameTextSize(), SCH_ITEM::GetParentSymbol(), SYMBOL::GetPinNameOffset(), getUntransformedPinNameBox(), m_pin, m_showAltIcons, EDA_IU_SCALE::mmToIU(), schIUScale, and VECTOR2< T >::x.
Referenced by GetAltIconBBox(), and GetPinBoundingBox().
|
private |
Definition at line 493 of file pin_layout_cache.cpp.
References BOX2< VECTOR2I >::ByCenter(), BOX2< VECTOR2I >::ByCorners(), externalPinDecoSize(), SCH_PIN::GetLength(), SCH_PIN::GetPenWidth(), SCH_PIN::GetShape(), internalPinDecoSize(), m_pin, m_schSettings, and BOX2< Vec >::Move().
Referenced by GetPinBoundingBox().
|
private |
Get the untransformd text box in the default orientation.
This will have to be offset and rotated.
Definition at line 384 of file pin_layout_cache.cpp.
References BOX2< VECTOR2I >::ByCenter(), SCH_PIN::GetLength(), SCH_ITEM::GetParentSymbol(), getPinTextOffset(), PIN_LAYOUT_CACHE::TEXT_EXTENTS_CACHE::m_Extents, m_nameExtentsCache, m_pin, BOX2< Vec >::Move(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by GetPinBoundingBox(), GetPinNameBBox(), and getUntransformedAltIconBox().
|
private |
Definition at line 424 of file pin_layout_cache.cpp.
References BOX2< VECTOR2I >::ByCenter(), SCH_PIN::GetLength(), SCH_ITEM::GetParentSymbol(), getPinTextOffset(), SCH_PIN::GetShownName(), SYMBOL::GetShowPinNames(), PIN_LAYOUT_CACHE::TEXT_EXTENTS_CACHE::m_Extents, m_numExtentsCache, m_pin, and VECTOR2< T >::y.
Referenced by GetPinBoundingBox(), and GetPinNumberBBox().
|
private |
Definition at line 452 of file pin_layout_cache.cpp.
References PIN_LAYOUT_CACHE::TEXT_EXTENTS_CACHE::m_Extents, m_showElectricalType, m_typeExtentsCache, EDA_IU_SCALE::MilsToIU(), PIN_TEXT_MARGIN, schIUScale, TARGET_PIN_RADIUS, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by GetPinBoundingBox().
|
inlineprivate |
Definition at line 121 of file pin_layout_cache.h.
References m_dirtyFlags.
Referenced by recomputeCaches().
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().
|
private |
Recompute all the caches that have become dirty.
Definition at line 139 of file pin_layout_cache.cpp.
References EESCHEMA_SETTINGS::APPEARANCE::default_font, ELEC_TYPE, SETTINGS_MANAGER::GetAppSettings(), SCH_PIN::GetElectricalTypeName(), KIFONT::FONT::GetFont(), SCH_ITEM::GetFontMetrics(), SCH_PIN::GetNameTextSize(), SCH_PIN::GetNumberTextSize(), PGM_BASE::GetSettingsManager(), SCH_PIN::GetShownName(), SCH_PIN::GetShownNumber(), isDirty(), EESCHEMA_SETTINGS::m_Appearance, m_nameExtentsCache, m_numExtentsCache, m_pin, m_shadowOffsetAdjust, m_typeExtentsCache, EDA_IU_SCALE::mmToIU(), name, NAME, NUMBER, Pgm(), recomputeExtentsCache(), schIUScale, and setClean().
Referenced by GetPinBoundingBox(), GetPinElectricalTypeInfo(), GetPinNameBBox(), GetPinNameInfo(), GetPinNumberBBox(), and GetPinNumberInfo().
|
staticprivate |
Definition at line 117 of file pin_layout_cache.cpp.
References GetPenSizeForNormal(), PIN_LAYOUT_CACHE::TEXT_EXTENTS_CACHE::m_Extents, PIN_LAYOUT_CACHE::TEXT_EXTENTS_CACHE::m_Font, PIN_LAYOUT_CACHE::TEXT_EXTENTS_CACHE::m_FontSize, and KIFONT::FONT::StringBoundaryLimits().
Referenced by recomputeCaches().
|
inlineprivate |
Definition at line 126 of file pin_layout_cache.h.
References m_dirtyFlags.
Referenced by recomputeCaches().
void PIN_LAYOUT_CACHE::SetRenderParameters | ( | int | aNameThickness, |
int | aNumberThickness, | ||
bool | aShowElectricalType, | ||
bool | aShowAltIcons | ||
) |
Definition at line 91 of file pin_layout_cache.cpp.
References ELEC_TYPE, m_nameThickness, m_numberThickness, m_showAltIcons, m_showElectricalType, MarkDirty(), NAME, and NUMBER.
Referenced by KIGFX::SCH_PAINTER::draw().
|
private |
Transform a box (in-place) to the pin's orientation.
Definition at line 179 of file pin_layout_cache.cpp.
References ANGLE_90, BOX2< VECTOR2I >::ByCorners(), DefaultTransform, BOX2< Vec >::GetBottom(), BOX2< Vec >::GetCenter(), BOX2< Vec >::GetLeft(), SCH_PIN::GetPosition(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), m_pin, BOX2< Vec >::Move(), SCH_PIN::PinDrawOrient(), and RotatePoint().
Referenced by GetAltIconBBox(), GetPinBoundingBox(), GetPinNameBBox(), and GetPinNumberBBox().
|
private |
Transform text info to suit a pin's.
the | 'nominal' text info for a PIN_RIGHT pin, which will be adjusted |
Definition at line 225 of file pin_layout_cache.cpp.
References ANGLE_VERTICAL, DefaultTransform, GetFlippedAlignment(), SCH_PIN::GetPosition(), PIN_LAYOUT_CACHE::TEXT_INFO::m_Angle, PIN_LAYOUT_CACHE::TEXT_INFO::m_HAlign, m_pin, PIN_LAYOUT_CACHE::TEXT_INFO::m_TextPosition, SCH_PIN::PinDrawOrient(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by GetPinElectricalTypeInfo(), GetPinNameInfo(), and GetPinNumberInfo().
|
private |
Definition at line 186 of file pin_layout_cache.h.
Referenced by isDirty(), MarkDirty(), and setClean().
|
private |
Definition at line 197 of file pin_layout_cache.h.
Referenced by getUntransformedPinNameBox(), and recomputeCaches().
|
private |
Definition at line 190 of file pin_layout_cache.h.
Referenced by GetPinNameInfo(), and SetRenderParameters().
|
private |
Definition at line 191 of file pin_layout_cache.h.
Referenced by GetPinNumberInfo(), and SetRenderParameters().
|
private |
Definition at line 196 of file pin_layout_cache.h.
Referenced by getUntransformedPinNumberBox(), and recomputeCaches().
|
private |
The pin in question.
Definition at line 181 of file pin_layout_cache.h.
Referenced by GetDanglingIndicator(), GetPinBoundingBox(), GetPinElectricalTypeInfo(), GetPinNameInfo(), GetPinNumberInfo(), getUntransformedAltIconBox(), getUntransformedDecorationBox(), getUntransformedPinNameBox(), getUntransformedPinNumberBox(), recomputeCaches(), transformBoxForPin(), and transformTextForPin().
|
private |
Definition at line 184 of file pin_layout_cache.h.
Referenced by getPinTextOffset(), getUntransformedDecorationBox(), and PIN_LAYOUT_CACHE().
|
private |
Definition at line 189 of file pin_layout_cache.h.
Referenced by GetPinElectricalTypeInfo(), GetPinNameInfo(), and recomputeCaches().
|
private |
Definition at line 193 of file pin_layout_cache.h.
Referenced by getUntransformedAltIconBox(), and SetRenderParameters().
|
private |
Definition at line 192 of file pin_layout_cache.h.
Referenced by GetPinElectricalTypeInfo(), getUntransformedPinTypeBox(), and SetRenderParameters().
|
private |
Definition at line 198 of file pin_layout_cache.h.
Referenced by getUntransformedPinTypeBox(), and recomputeCaches().