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, you may find one at
18 * http://www.gnu.org/licenses/
19 */
20
21
22#pragma once
23
24#include <optional>
25
26#include <geometry/circle.h>
27#include <geometry/seg.h>
28#include <math/box2.h>
29#include <sch_pin.h>
30
31
33
49{
50public:
51 PIN_LAYOUT_CACHE( const SCH_PIN& aPin );
52
54 {
55 NAME = 1,
56 NUMBER = 2,
58
60 };
61
65 void MarkDirty( int aFlags );
66
67 void SetRenderParameters( int aNameThickness, int aNumberThickness, bool aShowElectricalType,
68 bool aShowAltIcons );
69
73 BOX2I GetPinBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber,
74 bool aIncludeElectricalType );
75
80
85
90
96
107
113 std::optional<TEXT_INFO> GetPinNameInfo( int aShadowWidth );
114 std::optional<TEXT_INFO> GetPinNumberInfo( int aShadowWidth );
115 std::optional<TEXT_INFO> GetPinElectricalTypeInfo( int aShadowWidth );
116
117private:
118
119 bool isDirty( int aMask ) const
120 {
121 return m_dirtyFlags & aMask;
122 }
123
124 void setClean( int aMask )
125 {
126 m_dirtyFlags &= ~aMask;
127 }
128
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
174
177
180
181 // The schematic settings if there are any
183
185
186 // Cached render parameters
191 bool m_showAltIcons = false;
192
193 // Various cache members
197};
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
std::optional< BOX2I > OPT_BOX2I
Definition box2.h:926
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:131
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.
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:695