KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pin_layout_cache.cpp
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, see AUTHORS.txt for contributors.
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 2
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 here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include "pin_layout_cache.h"
25
27#include <pgm_base.h>
29#include <sch_symbol.h>
30#include <eeschema_settings.h>
31#include <schematic_settings.h>
32
34
35
36namespace
37{
38
39// small margin in internal units between the pin text and the pin line
40const int PIN_TEXT_MARGIN = 4;
41
42struct EXTENTS_CACHE
43{
44 KIFONT::FONT* m_Font = nullptr;
45 int m_FontSize = 0;
46 VECTOR2I m_Extents;
47};
48
50// i.e. the negation circle, the polarity 'slopes' and the nonlogic
51// marker
52int externalPinDecoSize( const SCHEMATIC_SETTINGS* aSettings, const SCH_PIN& aPin )
53{
54 if( aSettings && aSettings->m_PinSymbolSize )
55 return aSettings->m_PinSymbolSize;
56
57 return aPin.GetNumberTextSize() / 2;
58}
59
60
61int internalPinDecoSize( const SCHEMATIC_SETTINGS* aSettings, const SCH_PIN& aPin )
62{
63 if( aSettings && aSettings->m_PinSymbolSize > 0 )
64 return aSettings->m_PinSymbolSize;
65
66 return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
67}
68
69} // namespace
70
71
73 m_pin( aPin ), m_schSettings( nullptr ), m_dirtyFlags( DIRTY_FLAGS::ALL )
74{
75 // Resolve the schematic (can be null, e.g. in previews)
76 const SCHEMATIC* schematic = aPin.Schematic();
77
78 if( schematic )
79 {
80 m_schSettings = &schematic->Settings();
81 }
82}
83
84
85void PIN_LAYOUT_CACHE::MarkDirty( int aDirtyFlags )
86{
87 m_dirtyFlags |= aDirtyFlags;
88}
89
90
91void PIN_LAYOUT_CACHE::SetRenderParameters( int aNameThickness, int aNumberThickness,
92 bool aShowElectricalType, bool aShowAltIcons )
93{
94 if( aNameThickness != m_nameThickness )
95 {
97 m_nameThickness = aNameThickness;
98 }
99
100 if( aNumberThickness != m_numberThickness )
101 {
103 m_numberThickness = aNumberThickness;
104 }
105
106 if( aShowElectricalType != m_showElectricalType )
107 {
109 m_showElectricalType = aShowElectricalType;
110 }
111
112 // Not (yet?) cached
113 m_showAltIcons = aShowAltIcons;
114}
115
116
117void PIN_LAYOUT_CACHE::recomputeExtentsCache( bool aDefinitelyDirty, KIFONT::FONT* aFont, int aSize,
118 const wxString& aText,
119 const KIFONT::METRICS& aFontMetrics,
120 TEXT_EXTENTS_CACHE& aCache )
121{
122 // Even if not definitely dirty, verify no font changes
123 if( !aDefinitelyDirty && aCache.m_Font == aFont && aCache.m_FontSize == aSize )
124 {
125 return;
126 }
127
128 aCache.m_Font = aFont;
129 aCache.m_FontSize = aSize;
130
131 VECTOR2D fontSize( aSize, aSize );
132 int penWidth = GetPenSizeForNormal( aSize );
133
134 aCache.m_Extents = aFont->StringBoundaryLimits( aText, fontSize, penWidth, false, false, aFontMetrics );
135}
136
137
139{
140 EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
141 KIFONT::FONT* font = KIFONT::FONT::GetFont( cfg ? cfg->m_Appearance.default_font : wxString( "" ) );
142 const KIFONT::METRICS& metrics = m_pin.GetFontMetrics();
143
144 // Due to the fact a shadow text in position INSIDE or OUTSIDE is drawn left or right aligned,
145 // it needs an offset = shadowWidth/2 to be drawn at the same place as normal text
146 // texts drawn as GR_TEXT_H_ALIGN_CENTER do not need a specific offset.
147 // this offset is shadowWidth/2 but for some reason we need to slightly modify this offset
148 // for a better look (better alignment of shadow shape), for KiCad font only
149 if( !font->IsOutline() )
150 m_shadowOffsetAdjust = 1.2f; // Value chosen after tests
151 else
153
154 {
155 const bool dirty = isDirty( DIRTY_FLAGS::NUMBER );
156 const wxString number = m_pin.GetShownNumber();
157 recomputeExtentsCache( dirty, font, m_pin.GetNumberTextSize(), number, metrics, m_numExtentsCache );
158 }
159
160 {
161 const bool dirty = isDirty( DIRTY_FLAGS::NAME );
162 const wxString name = m_pin.GetShownName();
164 }
165
166 {
167 double fontSize = std::max( m_pin.GetNameTextSize() * 3 / 4, schIUScale.mmToIU( 0.7 ) );
170 }
171
173}
174
175
177{
178 // Now, calculate boundary box corners position for the actual pin orientation
180 {
181 case PIN_ORIENTATION::PIN_UP:
182 {
183 // Pin is rotated and texts positions are mirrored
184 VECTOR2I c1{ aBox.GetLeft(), aBox.GetTop() };
185 VECTOR2I c2{ aBox.GetRight(), aBox.GetBottom() };
186
187 RotatePoint( c1, VECTOR2I( 0, 0 ), ANGLE_90 );
188 RotatePoint( c2, VECTOR2I( 0, 0 ), ANGLE_90 );
189
190 aBox = BOX2I::ByCorners( c1, c2 );
191 break;
192 }
193 case PIN_ORIENTATION::PIN_DOWN:
194 {
195 VECTOR2I c1{ aBox.GetLeft(), aBox.GetTop() };
196 VECTOR2I c2{ aBox.GetRight(), aBox.GetBottom() };
197
198 RotatePoint( c1, VECTOR2I( 0, 0 ), -ANGLE_90 );
199 RotatePoint( c2, VECTOR2I( 0, 0 ), -ANGLE_90 );
200
201 c1.x = -c1.x;
202 c2.x = -c2.x;
203
204 aBox = BOX2I::ByCorners( c1, c2 );
205 break;
206 }
207 case PIN_ORIENTATION::PIN_LEFT:
208 // Flip it around
209 aBox.Move( { -aBox.GetCenter().x * 2, 0 } );
210 break;
211
212 default:
213 case PIN_ORIENTATION::PIN_RIGHT:
214 // Already in this form
215 break;
216 }
217
218 aBox.Move( m_pin.GetPosition() );
219}
220
221
223{
224 // Now, calculate boundary box corners position for the actual pin orientation
226 {
227 case PIN_ORIENTATION::PIN_LEFT:
228 {
229 aInfo.m_HAlign = GetFlippedAlignment( aInfo.m_HAlign );
230 aInfo.m_TextPosition.x = -aInfo.m_TextPosition.x;
231 break;
232 }
233 case PIN_ORIENTATION::PIN_UP:
234 {
235 aInfo.m_Angle = ANGLE_VERTICAL;
236 aInfo.m_TextPosition = { aInfo.m_TextPosition.y, -aInfo.m_TextPosition.x };
237 break;
238 }
239 case PIN_ORIENTATION::PIN_DOWN:
240 {
241 aInfo.m_Angle = ANGLE_VERTICAL;
242 aInfo.m_TextPosition = { aInfo.m_TextPosition.y, aInfo.m_TextPosition.x };
243 aInfo.m_HAlign = GetFlippedAlignment( aInfo.m_HAlign );
244 break;
245 }
246 default:
247 case PIN_ORIENTATION::PIN_RIGHT:
248 // Already in this form
249 break;
250 }
251
253}
254
255
256BOX2I PIN_LAYOUT_CACHE::GetPinBoundingBox( bool aIncludeLabelsOnInvisiblePins,
257 bool aIncludeNameAndNumber, bool aIncludeElectricalType )
258{
259 if( const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( m_pin.GetParentSymbol() ) )
260 {
261 SCH_PIN* const libPin = m_pin.GetLibPin();
262 wxCHECK( libPin, BOX2I() );
263
264 BOX2I r = libPin->GetBoundingBox( aIncludeLabelsOnInvisiblePins, aIncludeNameAndNumber,
265 aIncludeElectricalType );
266
267 r = symbol->GetTransform().TransformCoordinate( r );
268 r.Offset( symbol->GetPosition() );
269 r.Normalize();
270
271 return r;
272 }
273
274 bool includeName = aIncludeNameAndNumber && !m_pin.GetShownName().IsEmpty();
275 bool includeNumber = aIncludeNameAndNumber && !m_pin.GetShownNumber().IsEmpty();
276 bool includeType = aIncludeElectricalType;
277
278 if( !aIncludeLabelsOnInvisiblePins && !m_pin.IsVisible() )
279 {
280 includeName = false;
281 includeNumber = false;
282 includeType = false;
283 }
284
285 if( const SYMBOL* parentSymbol = m_pin.GetParentSymbol() )
286 {
287 if( !parentSymbol->GetShowPinNames() )
288 includeName = false;
289
290 if( !parentSymbol->GetShowPinNumbers() )
291 includeNumber = false;
292 }
293
295
296 const int pinLength = m_pin.GetLength();
297
298 // Creating and merging all the boxes is pretty quick, if cached we'd have
299 // to track many variables here, which is possible, but unlikely to be worth it.
300 BOX2I bbox;
301
302 // Untransformed pin box
303 {
304 BOX2I pinBox = BOX2I::ByCorners( { 0, 0 }, { pinLength, 0 } );
305 pinBox.Inflate( m_pin.GetPenWidth() / 2 );
306 bbox.Merge( pinBox );
307 }
308
310 {
311 bbox.Merge( *decoBox );
312 }
313
314 if( includeName )
315 {
316 if( OPT_BOX2I nameBox = getUntransformedPinNameBox() )
317 {
318 bbox.Merge( *nameBox );
319 }
320
321 if( OPT_BOX2I altIconBox = getUntransformedAltIconBox() )
322 {
323 bbox.Merge( *altIconBox );
324 }
325 }
326
327 if( includeNumber )
328 {
330 {
331 bbox.Merge( *numBox );
332 }
333 }
334
335 if( includeType )
336 {
337 if( OPT_BOX2I typeBox = getUntransformedPinTypeBox() )
338 {
339 bbox.Merge( *typeBox );
340 }
341 }
342
343 transformBoxForPin( bbox );
344
345 if( m_pin.IsDangling() )
346 {
347 // Not much point caching this, but we could
348 const CIRCLE c = GetDanglingIndicator();
349
350 BOX2I cBox = BOX2I::ByCenter( c.Center, { c.Radius * 2, c.Radius * 2 } );
351 // TODO: need some way to find the thickness...?
352 // cBox.Inflate( ??? );
353
354 bbox.Merge( cBox );
355 }
356
357 bbox.Normalize();
358 bbox.Inflate( ( m_pin.GetPenWidth() / 2 ) + 1 );
359
360 return bbox;
361}
362
363
365{
366 return CIRCLE{
369 };
370}
371
372
374{
375 const float offsetRatio =
377 return schIUScale.MilsToIU( KiROUND( 24 * offsetRatio ) );
378}
379
380
382{
383 int pinNameOffset = 0;
384 if( const SYMBOL* parentSymbol = m_pin.GetParentSymbol() )
385 {
386 if( parentSymbol->GetShowPinNames() )
387 pinNameOffset = parentSymbol->GetPinNameOffset();
388 }
389
390 // We're considering the PIN_RIGHT scenario
391 // TEXT
392 // X-------| TEXT
393 // TEXT
394 //
395 // We'll rotate it later.
396
397 OPT_BOX2I box;
398 const int pinLength = m_pin.GetLength();
399
400 if( pinNameOffset > 0 )
401 {
402 // This means name inside the pin
403 box = BOX2I::ByCenter( { pinLength, 0 }, m_nameExtentsCache.m_Extents );
404
405 // Bump over to be left aligned just inside the pin
406 box->Move( { m_nameExtentsCache.m_Extents.x / 2 + pinNameOffset, 0 } );
407 }
408 else
409 {
410 // The pin name is always over the pin
411 box = BOX2I::ByCenter( { pinLength / 2, 0 }, m_nameExtentsCache.m_Extents );
412
413 // Bump it up
414 box->Move( { 0, -m_nameExtentsCache.m_Extents.y / 2 - getPinTextOffset() } );
415 }
416
417 return box;
418}
419
420
422{
423 int pinNameOffset = 0;
424
425 if( const SYMBOL* parentSymbol = m_pin.GetParentSymbol() )
426 {
427 if( parentSymbol->GetShowPinNames() )
428 pinNameOffset = parentSymbol->GetPinNameOffset();
429 }
430
431 const int pinLength = m_pin.GetLength();
432
433 // The pin name is always over the pin
434 OPT_BOX2I box = BOX2I::ByCenter( { pinLength / 2, 0 }, m_numExtentsCache.m_Extents );
435
436 int textPos = -m_numExtentsCache.m_Extents.y / 2 - getPinTextOffset();
437
438 // The number goes below, if there is a name outside
439 if( pinNameOffset == 0 && !m_pin.GetShownName().empty()
441 textPos *= -1;
442
443 // Bump it up (or down)
444 box->Move( { 0, textPos } );
445
446 return box;
447}
448
449
451{
453 return std::nullopt;
454
455 BOX2I box{
458 };
459
460 // Jog left
461 box.Move( { -schIUScale.MilsToIU( PIN_TEXT_MARGIN ) - TARGET_PIN_RADIUS, 0 } );
462
463 return box;
464}
465
466
468{
469 const OPT_BOX2I nameBox = getUntransformedPinNameBox();
470
471 if( !nameBox || m_pin.GetAlternates().empty() || !m_showAltIcons )
472 return std::nullopt;
473
474 const int iconSize = std::min( m_pin.GetNameTextSize(), schIUScale.mmToIU( 1.5 ) );
475
476 VECTOR2I c{ 0, ( nameBox->GetTop() + nameBox->GetBottom() ) / 2 };
478 {
479 // name inside, so icon more inside
480 c.x = nameBox->GetRight() + iconSize * 0.75;
481 }
482 else
483 {
484 c.x = nameBox->GetLeft() - iconSize * 0.75;
485 }
486
487 return BOX2I::ByCenter( c, { iconSize, iconSize } );
488}
489
490
492{
493 const GRAPHIC_PINSHAPE shape = m_pin.GetShape();
494 const int decoSize = externalPinDecoSize( m_schSettings, m_pin );
495 const int intDecoSize = internalPinDecoSize( m_schSettings, m_pin );
496
497 const auto makeInvertBox = [&]()
498 {
499 return BOX2I::ByCenter( { -decoSize, 0 }, { decoSize * 2, decoSize * 2 } );
500 };
501
502 const auto makeLowBox = [&]()
503 {
504 return BOX2I::ByCorners( { -decoSize * 2, -decoSize * 2 }, { 0, 0 } );
505 };
506
507 const auto makeClockBox = [&]()
508 {
509 return BOX2I::ByCorners( { 0, -intDecoSize }, { intDecoSize, intDecoSize } );
510 };
511
512 OPT_BOX2I box;
513
514 switch( shape )
515 {
516 case GRAPHIC_PINSHAPE::INVERTED:
517 {
518 box = makeInvertBox();
519 break;
520 }
521 case GRAPHIC_PINSHAPE::CLOCK:
522 {
523 box = makeClockBox();
524 break;
525 }
526 case GRAPHIC_PINSHAPE::INVERTED_CLOCK:
527 {
528 box = makeInvertBox();
529 box->Merge( makeClockBox() );
530 break;
531 }
532 case GRAPHIC_PINSHAPE::INPUT_LOW:
533 {
534 box = makeLowBox();
535 break;
536 }
537 case GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK:
538 case GRAPHIC_PINSHAPE::CLOCK_LOW:
539 {
540 box = makeLowBox();
541 box->Merge( makeClockBox() );
542 break;
543 }
544 case GRAPHIC_PINSHAPE::NONLOGIC:
545 {
546 box = BOX2I::ByCenter( { 0, 0 }, { decoSize * 2, decoSize * 2 } );
547 break;
548 }
549 case GRAPHIC_PINSHAPE::LINE:
550 default:
551 {
552 // No decoration
553 break;
554 }
555 }
556
557 if( box )
558 {
559 // Put the box at the root of the pin
560 box->Move( { m_pin.GetLength(), 0 } );
561 box->Inflate( m_pin.GetPenWidth() / 2 );
562 }
563
564 return box;
565}
566
567
569{
572
573 if( box )
574 transformBoxForPin( *box );
575
576 return box;
577}
578
579
581{
584
585 if( box )
586 transformBoxForPin( *box );
587
588 return box;
589}
590
591
593{
595
596 if( box )
597 transformBoxForPin( *box );
598
599 return box;
600}
601
602
603std::optional<PIN_LAYOUT_CACHE::TEXT_INFO> PIN_LAYOUT_CACHE::GetPinNameInfo( int aShadowWidth )
604{
606 wxString name = m_pin.GetShownName();
607
608 // TODO - work out exactly what we need to do to cache this
609 // (or if it's worth the memory/complexity)
610 // But it's not hugely expensive to recompute, and that's what's always been
611 // done to now
612 //
613 // Because pins are very likely to share a lot of characteristics, a global
614 // cache might make more sense than a per-pin cache.
615
616 if( name.IsEmpty() || !m_pin.GetParentSymbol()->GetShowPinNames() )
617 return std::nullopt;
618
619 std::optional<TEXT_INFO> info = TEXT_INFO();
620 info->m_Text = std::move( name );
621 info->m_TextSize = m_pin.GetNameTextSize();
622 info->m_Thickness = m_nameThickness;
623 info->m_Angle = ANGLE_HORIZONTAL;
624
626 {
627 // This means name inside the pin
629 const int thickOffset =
630 info->m_Thickness - KiROUND( aShadowWidth * m_shadowOffsetAdjust ) / 2;
631
632 info->m_TextPosition = pos + VECTOR2I{ thickOffset, 0 };
633 info->m_HAlign = GR_TEXT_H_ALIGN_LEFT;
634 info->m_VAlign = GR_TEXT_V_ALIGN_CENTER;
635 }
636 else
637 {
638 // The pin name is always over the pin
639 VECTOR2I pos = { m_pin.GetLength() / 2, -getPinTextOffset() - info->m_Thickness / 2 };
640
641 info->m_TextPosition = pos;
642 info->m_HAlign = GR_TEXT_H_ALIGN_CENTER;
643 info->m_VAlign = GR_TEXT_V_ALIGN_BOTTOM;
644 }
645
647 return info;
648}
649
650
651std::optional<PIN_LAYOUT_CACHE::TEXT_INFO> PIN_LAYOUT_CACHE::GetPinNumberInfo( int aShadowWidth )
652{
654
655 wxString number = m_pin.GetShownNumber();
656 if( number.IsEmpty() || !m_pin.GetParentSymbol()->GetShowPinNumbers() )
657 return std::nullopt;
658
659 std::optional<TEXT_INFO> info;
660
661 info = TEXT_INFO();
662 info->m_Text = std::move( number );
663 info->m_TextSize = m_pin.GetNumberTextSize();
664 info->m_Thickness = m_numberThickness;
665 info->m_Angle = ANGLE_HORIZONTAL;
666 info->m_TextPosition = { m_pin.GetLength() / 2, 0 };
667 info->m_HAlign = GR_TEXT_H_ALIGN_CENTER;
668
669 // The pin number is above the pin if there's no name, or the name is inside
670 const bool numAbove =
672 || ( m_pin.GetShownName().empty() || !m_pin.GetParentSymbol()->GetShowPinNames() );
673
674 if( numAbove )
675 {
676 info->m_TextPosition.y -= getPinTextOffset() + info->m_Thickness / 2;
677 info->m_VAlign = GR_TEXT_V_ALIGN_BOTTOM;
678 }
679 else
680 {
681 info->m_TextPosition.y += getPinTextOffset() + info->m_Thickness / 2;
682 info->m_VAlign = GR_TEXT_V_ALIGN_TOP;
683 }
684
686 return info;
687}
688
689
690std::optional<PIN_LAYOUT_CACHE::TEXT_INFO>
692{
694
696 return std::nullopt;
697
698 std::optional<TEXT_INFO> info = TEXT_INFO();
699 info->m_Text = m_pin.GetElectricalTypeName();
700 info->m_TextSize = std::max( m_pin.GetNameTextSize() * 3 / 4, schIUScale.mmToIU( 0.7 ) );
701 info->m_Angle = ANGLE_HORIZONTAL;
702 info->m_Thickness = info->m_TextSize / 8;
703 info->m_TextPosition = { -getPinTextOffset() - info->m_Thickness / 2
704 + KiROUND( aShadowWidth * m_shadowOffsetAdjust ) / 2,
705 0 };
706 info->m_HAlign = GR_TEXT_H_ALIGN_RIGHT;
707 info->m_VAlign = GR_TEXT_V_ALIGN_CENTER;
708
709 info->m_TextPosition.x -= TARGET_PIN_RADIUS;
710
711 if( m_pin.IsDangling() )
712 {
713 info->m_TextPosition.x -= TARGET_PIN_RADIUS / 2;
714 }
715
717 return info;
718}
const char * name
Definition: DXF_plotter.cpp:62
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:114
BOX2< VECTOR2I > BOX2I
Definition: box2.h:922
std::optional< BOX2I > OPT_BOX2I
Definition: box2.h:926
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:558
static constexpr BOX2< VECTOR2I > ByCorners(const VECTOR2I &aCorner1, const VECTOR2I &aCorner2)
Definition: box2.h:70
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:146
static constexpr BOX2< VECTOR2I > ByCenter(const VECTOR2I &aCenter, const SizeVec &aSize)
Definition: box2.h:75
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:658
constexpr const Vec GetCenter() const
Definition: box2.h:230
constexpr coord_type GetLeft() const
Definition: box2.h:228
constexpr void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
Definition: box2.h:138
constexpr coord_type GetRight() const
Definition: box2.h:217
constexpr coord_type GetTop() const
Definition: box2.h:229
constexpr void Offset(coord_type dx, coord_type dy)
Definition: box2.h:259
constexpr coord_type GetBottom() const
Definition: box2.h:222
Represent basic circle geometry with utility geometry functions.
Definition: circle.h:33
VECTOR2I Center
Public to make access simpler.
Definition: circle.h:130
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition: font.cpp:147
virtual bool IsOutline() const
Definition: font.h:139
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic, const METRICS &aFontMetrics) const
Compute the boundary limits of aText (the bounding box of all shapes).
Definition: font.cpp:427
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.
Holds all the data relating to one schematic.
Definition: schematic.h:88
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:356
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:252
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:246
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:617
int GetNumberTextSize() const
Definition: sch_pin.cpp:578
int GetLength() const
Definition: sch_pin.cpp:255
const std::map< wxString, ALT > & GetAlternates() const
Definition: sch_pin.h:133
PIN_ORIENTATION PinDrawOrient(const TRANSFORM &aTransform) const
Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), according to its orientation...
Definition: sch_pin.cpp:964
wxString GetShownNumber() const
Definition: sch_pin.cpp:535
bool IsVisible() const
Definition: sch_pin.cpp:343
SCH_PIN * GetLibPin() const
Definition: sch_pin.h:88
wxString GetElectricalTypeName() const
Definition: sch_pin.cpp:311
int GetPenWidth() const override
Definition: sch_pin.h:218
bool IsDangling() const override
Definition: sch_pin.cpp:417
VECTOR2I GetPosition() const override
Definition: sch_pin.cpp:212
int GetNameTextSize() const
Definition: sch_pin.cpp:554
wxString GetShownName() const
Definition: sch_pin.cpp:524
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_pin.h:188
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:234
Schematic symbol object.
Definition: sch_symbol.h:75
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition: symbol.h:63
int GetPinNameOffset() const
Definition: symbol.h:153
virtual bool GetShowPinNames() const
Definition: symbol.h:159
virtual bool GetShowPinNumbers() const
Definition: symbol.h:165
#define DEFAULT_TEXT_OFFSET_RATIO
Ratio of the font height to space around global labels.
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:413
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:408
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:407
TRANSFORM DefaultTransform
Definition: transform.cpp:32
int GetPenSizeForNormal(int aTextSize)
Definition: gr_text.cpp:60
see class PGM_BASE
GRAPHIC_PINSHAPE
Definition: pin_type.h:84
static int externalPinDecoSize(const RENDER_SETTINGS *aSettings, const SCH_PIN &aPin)
Utility for getting the size of the 'external' pin decorators (as a radius) i.e.
Definition: sch_pin.cpp:63
#define PIN_TEXT_MARGIN
Definition: sch_pin.cpp:44
static int internalPinDecoSize(const RENDER_SETTINGS *aSettings, const SCH_PIN &aPin)
Utility for getting the size of the 'internal' pin decorators (as a radius) i.e.
Definition: sch_pin.cpp:49
#define TARGET_PIN_RADIUS
Definition: sch_pin.h:36
Utility functions for working with shapes.
constexpr int MilsToIU(int mils) const
Definition: base_units.h:97
constexpr int mmToIU(double mm) const
Definition: base_units.h:92
Cached extent of a text item.
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
constexpr GR_TEXT_H_ALIGN_T GetFlippedAlignment(GR_TEXT_H_ALIGN_T aAlign)
Get the reverse alignment: left-right are swapped, others are unchanged.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition: trigo.cpp:229
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695