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 (C) 2024 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 =
135 aFont->StringBoundaryLimits( aText, fontSize, penWidth, false, false, aFontMetrics );
136}
137
138
140{
142 EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
144 const KIFONT::METRICS& metrics = m_pin.GetFontMetrics();
145
146 // Due to the fact a shadow text in position INSIDE or OUTSIDE is drawn left or right aligned,
147 // it needs an offset = shadowWidth/2 to be drawn at the same place as normal text
148 // texts drawn as GR_TEXT_H_ALIGN_CENTER do not need a specific offset.
149 // this offset is shadowWidth/2 but for some reason we need to slightly modify this offset
150 // for a better look (better alignment of shadow shape), for KiCad font only
151 if( !font->IsOutline() )
152 m_shadowOffsetAdjust = 1.2f; // Value chosen after tests
153 else
155
156 {
157 const bool dirty = isDirty( DIRTY_FLAGS::NUMBER );
158 const wxString number = m_pin.GetShownNumber();
159 recomputeExtentsCache( dirty, font, m_pin.GetNumberTextSize(), number, metrics,
161 }
162
163 {
164 const bool dirty = isDirty( DIRTY_FLAGS::NAME );
165 const wxString name = m_pin.GetShownName();
166 recomputeExtentsCache( dirty, font, m_pin.GetNameTextSize(), name, metrics,
168 }
169
170 {
171 double fontSize = std::max( m_pin.GetNameTextSize() * 3 / 4, schIUScale.mmToIU( 0.7 ) );
174 }
175
177}
178
179
181{
182 // Now, calculate boundary box corners position for the actual pin orientation
184 {
185 case PIN_ORIENTATION::PIN_UP:
186 {
187 // Pin is rotated and texts positions are mirrored
188 VECTOR2I c1{ aBox.GetLeft(), aBox.GetTop() };
189 VECTOR2I c2{ aBox.GetRight(), aBox.GetBottom() };
190
191 RotatePoint( c1, VECTOR2I( 0, 0 ), ANGLE_90 );
192 RotatePoint( c2, VECTOR2I( 0, 0 ), ANGLE_90 );
193
194 aBox = BOX2I::ByCorners( c1, c2 );
195 break;
196 }
197 case PIN_ORIENTATION::PIN_DOWN:
198 {
199 VECTOR2I c1{ aBox.GetLeft(), aBox.GetTop() };
200 VECTOR2I c2{ aBox.GetRight(), aBox.GetBottom() };
201
202 RotatePoint( c1, VECTOR2I( 0, 0 ), -ANGLE_90 );
203 RotatePoint( c2, VECTOR2I( 0, 0 ), -ANGLE_90 );
204
205 c1.x = -c1.x;
206 c2.x = -c2.x;
207
208 aBox = BOX2I::ByCorners( c1, c2 );
209 break;
210 }
211 case PIN_ORIENTATION::PIN_LEFT:
212 // Flip it around
213 aBox.Move( { -aBox.GetCenter().x * 2, 0 } );
214 break;
215
216 default:
217 case PIN_ORIENTATION::PIN_RIGHT:
218 // Already in this form
219 break;
220 }
221
222 aBox.Move( m_pin.GetPosition() );
223}
224
225
227{
228 // Now, calculate boundary box corners position for the actual pin orientation
230 {
231 case PIN_ORIENTATION::PIN_LEFT:
232 {
233 aInfo.m_HAlign = GetFlippedAlignment( aInfo.m_HAlign );
234 aInfo.m_TextPosition.x = -aInfo.m_TextPosition.x;
235 break;
236 }
237 case PIN_ORIENTATION::PIN_UP:
238 {
239 aInfo.m_Angle = ANGLE_VERTICAL;
240 aInfo.m_TextPosition = { aInfo.m_TextPosition.y, -aInfo.m_TextPosition.x };
241 break;
242 }
243 case PIN_ORIENTATION::PIN_DOWN:
244 {
245 aInfo.m_Angle = ANGLE_VERTICAL;
246 aInfo.m_TextPosition = { aInfo.m_TextPosition.y, aInfo.m_TextPosition.x };
247 aInfo.m_HAlign = GetFlippedAlignment( aInfo.m_HAlign );
248 break;
249 }
250 default:
251 case PIN_ORIENTATION::PIN_RIGHT:
252 // Already in this form
253 break;
254 }
255
257}
258
259
260BOX2I PIN_LAYOUT_CACHE::GetPinBoundingBox( bool aIncludeLabelsOnInvisiblePins,
261 bool aIncludeNameAndNumber, bool aIncludeElectricalType )
262{
263 if( const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( m_pin.GetParentSymbol() ) )
264 {
265 SCH_PIN* const libPin = m_pin.GetLibPin();
266 wxCHECK( libPin, BOX2I() );
267
268 BOX2I r = libPin->GetBoundingBox( aIncludeLabelsOnInvisiblePins, aIncludeNameAndNumber,
269 aIncludeElectricalType );
270
271 r = symbol->GetTransform().TransformCoordinate( r );
272 r.Offset( symbol->GetPosition() );
273 r.Normalize();
274
275 return r;
276 }
277
278 bool includeName = aIncludeNameAndNumber && !m_pin.GetShownName().IsEmpty();
279 bool includeNumber = aIncludeNameAndNumber && !m_pin.GetShownNumber().IsEmpty();
280 bool includeType = aIncludeElectricalType;
281
282 if( !aIncludeLabelsOnInvisiblePins && !m_pin.IsVisible() )
283 {
284 includeName = false;
285 includeNumber = false;
286 includeType = false;
287 }
288
289 if( const SYMBOL* parentSymbol = m_pin.GetParentSymbol() )
290 {
291 if( !parentSymbol->GetShowPinNames() )
292 includeName = false;
293
294 if( !parentSymbol->GetShowPinNumbers() )
295 includeNumber = false;
296 }
297
299
300 const int pinLength = m_pin.GetLength();
301
302 // Creating and merging all the boxes is pretty quick, if cached we'd have
303 // to track many variables here, which is possible, but unlikely to be worth it.
304 BOX2I bbox;
305
306 // Untransformed pin box
307 {
308 BOX2I pinBox = BOX2I::ByCorners( { 0, 0 }, { pinLength, 0 } );
309 pinBox.Inflate( m_pin.GetPenWidth() / 2 );
310 bbox.Merge( pinBox );
311 }
312
314 {
315 bbox.Merge( *decoBox );
316 }
317
318 if( includeName )
319 {
320 if( OPT_BOX2I nameBox = getUntransformedPinNameBox() )
321 {
322 bbox.Merge( *nameBox );
323 }
324
325 if( OPT_BOX2I altIconBox = getUntransformedAltIconBox() )
326 {
327 bbox.Merge( *altIconBox );
328 }
329 }
330
331 if( includeNumber )
332 {
334 {
335 bbox.Merge( *numBox );
336 }
337 }
338
339 if( includeType )
340 {
341 if( OPT_BOX2I typeBox = getUntransformedPinTypeBox() )
342 {
343 bbox.Merge( *typeBox );
344 }
345 }
346
347 transformBoxForPin( bbox );
348
349 if( m_pin.IsDangling() )
350 {
351 // Not much point caching this, but we could
352 const CIRCLE c = GetDanglingIndicator();
353
354 BOX2I cBox = BOX2I::ByCenter( c.Center, { c.Radius * 2, c.Radius * 2 } );
355 // TODO: need some way to find the thickness...?
356 // cBox.Inflate( ??? );
357
358 bbox.Merge( cBox );
359 }
360
361 bbox.Normalize();
362 bbox.Inflate( ( m_pin.GetPenWidth() / 2 ) + 1 );
363
364 return bbox;
365}
366
367
369{
370 return CIRCLE{
373 };
374}
375
376
378{
379 const float offsetRatio =
381 return schIUScale.MilsToIU( KiROUND( 24 * offsetRatio ) );
382}
383
384
386{
387 int pinNameOffset = 0;
388 if( const SYMBOL* parentSymbol = m_pin.GetParentSymbol() )
389 {
390 if( parentSymbol->GetShowPinNames() )
391 pinNameOffset = parentSymbol->GetPinNameOffset();
392 }
393
394 // We're considering the PIN_RIGHT scenario
395 // TEXT
396 // X-------| TEXT
397 // TEXT
398 //
399 // We'll rotate it later.
400
401 OPT_BOX2I box;
402 const int pinLength = m_pin.GetLength();
403
404 if( pinNameOffset > 0 )
405 {
406 // This means name inside the pin
407 box = BOX2I::ByCenter( { pinLength, 0 }, m_nameExtentsCache.m_Extents );
408
409 // Bump over to be left aligned just inside the pin
410 box->Move( { m_nameExtentsCache.m_Extents.x / 2 + pinNameOffset, 0 } );
411 }
412 else
413 {
414 // The pin name is always over the pin
415 box = BOX2I::ByCenter( { pinLength / 2, 0 }, m_nameExtentsCache.m_Extents );
416
417 // Bump it up
418 box->Move( { 0, -m_nameExtentsCache.m_Extents.y / 2 - getPinTextOffset() } );
419 }
420
421 return box;
422}
423
424
426{
427 int pinNameOffset = 0;
428 if( const SYMBOL* parentSymbol = m_pin.GetParentSymbol() )
429 {
430 if( parentSymbol->GetShowPinNames() )
431 pinNameOffset = parentSymbol->GetPinNameOffset();
432 }
433
434 const int pinLength = m_pin.GetLength();
435
436 // The pin name is always over the pin
437 OPT_BOX2I box = BOX2I::ByCenter( { pinLength / 2, 0 }, m_numExtentsCache.m_Extents );
438
439 int textPos = -m_numExtentsCache.m_Extents.y / 2 - getPinTextOffset();
440
441 // The number goes below, if there is a name outside
442 if( pinNameOffset == 0 && !m_pin.GetShownName().empty()
444 textPos *= -1;
445
446 // Bump it up (or down)
447 box->Move( { 0, textPos } );
448
449 return box;
450}
451
452
454{
456 return std::nullopt;
457
458 BOX2I box{
461 };
462
463 // Jog left
464 box.Move( { -schIUScale.MilsToIU( PIN_TEXT_MARGIN ) - TARGET_PIN_RADIUS, 0 } );
465
466 return box;
467}
468
469
471{
472 const OPT_BOX2I nameBox = getUntransformedPinNameBox();
473
474 if( !nameBox || m_pin.GetAlternates().empty() || !m_showAltIcons )
475 return std::nullopt;
476
477 const int iconSize = std::min( m_pin.GetNameTextSize(), schIUScale.mmToIU( 1.5 ) );
478
479 VECTOR2I c{ 0, ( nameBox->GetTop() + nameBox->GetBottom() ) / 2 };
481 {
482 // name inside, so icon more inside
483 c.x = nameBox->GetRight() + iconSize * 0.75;
484 }
485 else
486 {
487 c.x = nameBox->GetLeft() - iconSize * 0.75;
488 }
489
490 return BOX2I::ByCenter( c, { iconSize, iconSize } );
491}
492
493
495{
496 const GRAPHIC_PINSHAPE shape = m_pin.GetShape();
497 const int decoSize = externalPinDecoSize( m_schSettings, m_pin );
498 const int intDecoSize = internalPinDecoSize( m_schSettings, m_pin );
499
500 const auto makeInvertBox = [&]()
501 {
502 return BOX2I::ByCenter( { -decoSize, 0 }, { decoSize * 2, decoSize * 2 } );
503 };
504
505 const auto makeLowBox = [&]()
506 {
507 return BOX2I::ByCorners( { -decoSize * 2, -decoSize * 2 }, { 0, 0 } );
508 };
509
510 const auto makeClockBox = [&]()
511 {
512 return BOX2I::ByCorners( { 0, -intDecoSize }, { intDecoSize, intDecoSize } );
513 };
514
515 OPT_BOX2I box;
516
517 switch( shape )
518 {
519 case GRAPHIC_PINSHAPE::INVERTED:
520 {
521 box = makeInvertBox();
522 break;
523 }
524 case GRAPHIC_PINSHAPE::CLOCK:
525 {
526 box = makeClockBox();
527 break;
528 }
529 case GRAPHIC_PINSHAPE::INVERTED_CLOCK:
530 {
531 box = makeInvertBox();
532 box->Merge( makeClockBox() );
533 break;
534 }
535 case GRAPHIC_PINSHAPE::INPUT_LOW:
536 {
537 box = makeLowBox();
538 break;
539 }
540 case GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK:
541 case GRAPHIC_PINSHAPE::CLOCK_LOW:
542 {
543 box = makeLowBox();
544 box->Merge( makeClockBox() );
545 break;
546 }
547 case GRAPHIC_PINSHAPE::NONLOGIC:
548 {
549 box = BOX2I::ByCenter( { 0, 0 }, { decoSize * 2, decoSize * 2 } );
550 break;
551 }
552 case GRAPHIC_PINSHAPE::LINE:
553 default:
554 {
555 // No decoration
556 break;
557 }
558 }
559
560 if( box )
561 {
562 // Put the box at the root of the pin
563 box->Move( { m_pin.GetLength(), 0 } );
564 box->Inflate( m_pin.GetPenWidth() / 2 );
565 }
566
567 return box;
568}
569
570
572{
575
576 if( box )
577 transformBoxForPin( *box );
578
579 return box;
580}
581
582
584{
587
588 if( box )
589 transformBoxForPin( *box );
590
591 return box;
592}
593
594
596{
598
599 if( box )
600 transformBoxForPin( *box );
601
602 return box;
603}
604
605
606std::optional<PIN_LAYOUT_CACHE::TEXT_INFO> PIN_LAYOUT_CACHE::GetPinNameInfo( int aShadowWidth )
607{
609 wxString name = m_pin.GetShownName();
610
611 // TODO - work out exactly what we need to do to cache this
612 // (or if it's worth the memory/complexity)
613 // But it's not hugely expensive to recompute, and that's what's always been
614 // done to now
615 //
616 // Becasue pins are very likely to share a lot of characteristics, a global
617 // cache might make more sense than a per-pin cache.
618
619 if( name.IsEmpty() || !m_pin.GetParentSymbol()->GetShowPinNames() )
620 return std::nullopt;
621
622 std::optional<TEXT_INFO> info = TEXT_INFO();
623 info->m_Text = std::move( name );
624 info->m_TextSize = m_pin.GetNameTextSize();
625 info->m_Thickness = m_nameThickness;
626 info->m_Angle = ANGLE_HORIZONTAL;
627
629 {
630 // This means name inside the pin
632 const int thickOffset =
633 info->m_Thickness - KiROUND( aShadowWidth * m_shadowOffsetAdjust ) / 2;
634
635 info->m_TextPosition = pos + VECTOR2I{ thickOffset, 0 };
636 info->m_HAlign = GR_TEXT_H_ALIGN_LEFT;
637 info->m_VAlign = GR_TEXT_V_ALIGN_CENTER;
638 }
639 else
640 {
641 // The pin name is always over the pin
642 VECTOR2I pos = { m_pin.GetLength() / 2, -getPinTextOffset() - info->m_Thickness / 2 };
643
644 info->m_TextPosition = pos;
645 info->m_HAlign = GR_TEXT_H_ALIGN_CENTER;
646 info->m_VAlign = GR_TEXT_V_ALIGN_BOTTOM;
647 }
648
650 return info;
651}
652
653
654std::optional<PIN_LAYOUT_CACHE::TEXT_INFO> PIN_LAYOUT_CACHE::GetPinNumberInfo( int aShadowWidth )
655{
657
658 wxString number = m_pin.GetShownNumber();
659 if( number.IsEmpty() || !m_pin.GetParentSymbol()->GetShowPinNumbers() )
660 return std::nullopt;
661
662 std::optional<TEXT_INFO> info;
663
664 info = TEXT_INFO();
665 info->m_Text = std::move( number );
666 info->m_TextSize = m_pin.GetNumberTextSize();
667 info->m_Thickness = m_numberThickness;
668 info->m_Angle = ANGLE_HORIZONTAL;
669 info->m_TextPosition = { m_pin.GetLength() / 2, 0 };
670 info->m_HAlign = GR_TEXT_H_ALIGN_CENTER;
671
672 // The pin number is above the pin if there's no name, or the name is inside
673 const bool numAbove =
675 || ( m_pin.GetShownName().empty() || !m_pin.GetParentSymbol()->GetShowPinNames() );
676 if( numAbove )
677 {
678 info->m_TextPosition.y -= getPinTextOffset() + info->m_Thickness / 2;
679 info->m_VAlign = GR_TEXT_V_ALIGN_BOTTOM;
680 }
681 else
682 {
683 info->m_TextPosition.y += getPinTextOffset() + info->m_Thickness / 2;
684 info->m_VAlign = GR_TEXT_V_ALIGN_TOP;
685 }
686
688 return info;
689}
690
691std::optional<PIN_LAYOUT_CACHE::TEXT_INFO>
693{
695
697 return std::nullopt;
698
699 std::optional<TEXT_INFO> info = TEXT_INFO();
700 info->m_Text = m_pin.GetElectricalTypeName();
701 info->m_TextSize = std::max( m_pin.GetNameTextSize() * 3 / 4, schIUScale.mmToIU( 0.7 ) );
702 info->m_Angle = ANGLE_HORIZONTAL;
703 info->m_Thickness = info->m_TextSize / 8;
704 info->m_TextPosition = { -getPinTextOffset() - info->m_Thickness / 2
705 + KiROUND( aShadowWidth * m_shadowOffsetAdjust ) / 2,
706 0 };
707 info->m_HAlign = GR_TEXT_H_ALIGN_RIGHT;
708 info->m_VAlign = GR_TEXT_V_ALIGN_CENTER;
709
710 info->m_TextPosition.x -= TARGET_PIN_RADIUS;
711
712 if( m_pin.IsDangling() )
713 {
714 info->m_TextPosition.x -= TARGET_PIN_RADIUS / 2;
715 }
716
718 return info;
719}
const char * name
Definition: DXF_plotter.cpp:57
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
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:146
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:435
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
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
Pin type decoration if any.
int getPinTextOffset() const
Get the current pin text offset.
OPT_BOX2I getUntransformedDecorationBox() const
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:77
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:312
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:166
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:464
int GetNumberTextSize() const
Definition: sch_pin.cpp:557
int GetLength() const
Definition: sch_pin.cpp:295
const std::map< wxString, ALT > & GetAlternates() const
Definition: sch_pin.h:127
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:1367
wxString GetShownNumber() const
Definition: sch_pin.cpp:511
bool IsVisible() const
Definition: sch_pin.cpp:367
SCH_PIN * GetLibPin() const
Definition: sch_pin.h:82
wxString GetElectricalTypeName() const
Definition: sch_pin.cpp:353
int GetPenWidth() const override
Definition: sch_pin.h:197
bool IsDangling() const override
Definition: sch_pin.cpp:412
VECTOR2I GetPosition() const override
Definition: sch_pin.cpp:252
int GetNameTextSize() const
Definition: sch_pin.cpp:533
wxString GetShownName() const
Definition: sch_pin.cpp:497
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_pin.h:175
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:274
Schematic symbol object.
Definition: sch_symbol.h:104
T * GetAppSettings(const wxString &aFilename)
Returns a handle to the a given settings by type If the settings have already been loaded,...
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition: symbol.h:34
int GetPinNameOffset() const
Definition: symbol.h:118
virtual bool GetShowPinNames() const
Definition: symbol.h:124
virtual bool GetShowPinNumbers() const
Definition: symbol.h:130
#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:403
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:398
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:397
TRANSFORM DefaultTransform
Definition: transform.cpp:32
int GetPenSizeForNormal(int aTextSize)
Definition: gr_text.cpp:64
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
GRAPHIC_PINSHAPE
Definition: pin_type.h:57
static int externalPinDecoSize(const RENDER_SETTINGS *aSettings, const SCH_PIN &aPin)
Utility for getting the size of the 'external' pin decorators (as a radius)
Definition: sch_pin.cpp:89
#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)
Definition: sch_pin.cpp:76
#define TARGET_PIN_RADIUS
Definition: sch_pin.h:37
Utility functions for working with shapes.
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
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:691