KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pin_layout_cache.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20
21#pragma once
22
23#include <optional>
24
25#include <geometry/circle.h>
26#include <geometry/seg.h>
27#include <math/box2.h>
28#include <sch_pin.h>
29
30
32
48{
49public:
50 PIN_LAYOUT_CACHE( const SCH_PIN& aPin );
51
53 {
54 NAME = 1,
55 NUMBER = 2,
57
59 };
60
64 void MarkDirty( int aFlags );
65
66 void SetRenderParameters( int aNameThickness, int aNumberThickness, bool aShowElectricalType,
67 bool aShowAltIcons );
68
72 BOX2I GetPinBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber,
73 bool aIncludeElectricalType );
74
79
84
89
95
106
112 std::optional<TEXT_INFO> GetPinNameInfo( int aShadowWidth );
113 std::optional<TEXT_INFO> GetPinNumberInfo( int aShadowWidth );
114 std::optional<TEXT_INFO> GetPinElectricalTypeInfo( int aShadowWidth );
115
116private:
117
118 bool isDirty( int aMask ) const
119 {
120 return m_dirtyFlags & aMask;
121 }
122
123 void setClean( int aMask )
124 {
125 m_dirtyFlags &= ~aMask;
126 }
127
132 {
134 int m_FontSize = 0;
135 wxString m_Text;
137 };
138
139 static void recomputeExtentsCache( bool aDefinitelyDirty, KIFONT::FONT* aFont, int aSize,
140 const wxString& aText, const KIFONT::METRICS& aFontMetrics,
141 TEXT_EXTENTS_CACHE& aCache );
142
146 void recomputeCaches();
147
151 void transformBoxForPin( BOX2I& aBox ) const;
152
158 void transformTextForPin( TEXT_INFO& aTextInfo ) const;
159
163 int getPinTextOffset() const;
164
169 int getNumberBlockOffset() const;
170
180
183
186
187 // The schematic settings if there are any
189
191
192 // Cached render parameters
197 bool m_showAltIcons = false;
198
199 // Inputs the stacked-number formatting depends on, so a repeat call can skip it
200 wxString m_numSource;
202
203 // Various cache members
207};
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
std::optional< BOX2I > OPT_BOX2I
Definition box2.h:931
Represent basic circle geometry with utility geometry functions.
Definition circle.h:33
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:94
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)
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
void setClean(int aMask)
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
These are loaded from Eeschema settings but then overwritten by the project settings.
Cached extent of a text item.
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683