KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_pin.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2015 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2018 CERN
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 * @author Jon Evans <[email protected]>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, you may find one here:
22 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23 * or you may search the http://www.gnu.org website for the version 2 license,
24 * or you may write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 */
27
28#include "sch_pin.h"
29
30#include <base_units.h>
31#include <pgm_base.h>
32#include <pin_layout_cache.h>
33#include <plotters/plotter.h>
34#include <sch_draw_panel.h>
35#include <sch_edit_frame.h>
36#include <symbol_edit_frame.h>
39#include <trace_helpers.h>
40#include <trigo.h>
41#include <string_utils.h>
42#include <properties/property.h>
44
45wxString FormatStackedPinForDisplay( const wxString& aPinNumber, int aPinLength, int aTextSize, KIFONT::FONT* aFont,
46 const KIFONT::METRICS& aFontMetrics )
47{
48 // Check if this is stacked pin notation: [A,B,C]
49 if( !aPinNumber.StartsWith( "[" ) || !aPinNumber.EndsWith( "]" ) )
50 return aPinNumber;
51
52 const int minPinTextWidth = schIUScale.MilsToIU( 50 );
53 const int maxPinTextWidth = std::max( aPinLength, minPinTextWidth );
54
55 VECTOR2D fontSize( aTextSize, aTextSize );
56 int penWidth = GetPenSizeForNormal( aTextSize );
57 VECTOR2I textExtents = aFont->StringBoundaryLimits( aPinNumber, fontSize, penWidth, false, false, aFontMetrics );
58
59 if( textExtents.x <= maxPinTextWidth )
60 return aPinNumber; // Fits already
61
62 // Strip brackets and split by comma
63 wxString inner = aPinNumber.Mid( 1, aPinNumber.Length() - 2 );
64 wxArrayString parts;
65 wxStringSplit( inner, parts, ',' );
66
67 if( parts.empty() )
68 return aPinNumber; // malformed; fallback
69
70 // Build multi-line representation inside braces, each line trimmed
71 wxString result = "[";
72
73 for( size_t i = 0; i < parts.size(); ++i )
74 {
75 wxString line = parts[i];
76 line.Trim( true ).Trim( false );
77
78 if( i > 0 )
79 result += "\n";
80
81 result += line;
82 }
83
84 result += "]";
85 return result;
86}
87
88
89// small margin in internal units between the pin text and the pin line
90#define PIN_TEXT_MARGIN 4
91
95static int internalPinDecoSize( const RENDER_SETTINGS* aSettings, const SCH_PIN &aPin )
96{
97 const SCH_RENDER_SETTINGS* settings = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
98
99 if( settings && settings->m_PinSymbolSize )
100 return settings->m_PinSymbolSize;
101
102 return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
103}
104
105
109static int externalPinDecoSize( const RENDER_SETTINGS* aSettings, const SCH_PIN &aPin )
110{
111 const SCH_RENDER_SETTINGS* settings = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
112
113 if( settings && settings->m_PinSymbolSize )
114 return settings->m_PinSymbolSize;
115
116 return aPin.GetNumberTextSize() / 2;
117}
118
119
120SCH_PIN::SCH_PIN( LIB_SYMBOL* aParentSymbol ) :
121 SCH_ITEM( aParentSymbol, SCH_PIN_T, 0, 0 ),
122 m_libPin( nullptr ),
123 m_position( { 0, 0 } ),
124 m_length( schIUScale.MilsToIU( DEFAULT_PIN_LENGTH ) ),
125 m_orientation( PIN_ORIENTATION::PIN_RIGHT ),
126 m_shape( GRAPHIC_PINSHAPE::LINE ),
128 m_hidden( false ),
129 m_numTextSize( schIUScale.MilsToIU( DEFAULT_PINNUM_SIZE ) ),
130 m_nameTextSize( schIUScale.MilsToIU( DEFAULT_PINNAME_SIZE ) ),
131 m_isDangling( true ),
132 m_layoutCache( std::make_unique<PIN_LAYOUT_CACHE>( *this ) )
133{
135 {
136 m_length = schIUScale.MilsToIU( cfg->m_Defaults.pin_length );
137 m_numTextSize = schIUScale.MilsToIU( cfg->m_Defaults.pin_num_size );
138 m_nameTextSize = schIUScale.MilsToIU( cfg->m_Defaults.pin_name_size );
139 }
140
141 m_layer = LAYER_DEVICE;
142}
143
144
145SCH_PIN::SCH_PIN( LIB_SYMBOL* aParentSymbol, const wxString& aName, const wxString& aNumber,
146 PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength,
147 int aNameTextSize, int aNumTextSize, int aBodyStyle, const VECTOR2I& aPos,
148 int aUnit ) :
149 SCH_ITEM( aParentSymbol, SCH_PIN_T, aUnit, aBodyStyle ),
150 m_libPin( nullptr ),
151 m_position( aPos ),
152 m_length( aLength ),
153 m_orientation( aOrientation ),
155 m_type( aPinType ),
156 m_hidden( false ),
157 m_numTextSize( aNumTextSize ),
158 m_nameTextSize( aNameTextSize ),
159 m_isDangling( true ),
160 m_layoutCache( std::make_unique<PIN_LAYOUT_CACHE>( *this ) )
161{
162 SetName( aName );
163 SetNumber( aNumber );
164
166}
167
168
169SCH_PIN::SCH_PIN( SCH_SYMBOL* aParentSymbol, SCH_PIN* aLibPin ) :
170 SCH_ITEM( aParentSymbol, SCH_PIN_T, 0, 0 ),
171 m_libPin( aLibPin ),
175 m_isDangling( true ),
176 m_layoutCache( std::make_unique<PIN_LAYOUT_CACHE>( *this ) )
177{
178 wxASSERT( aParentSymbol );
179
180 SetName( m_libPin->GetName() );
181 SetNumber( m_libPin->GetNumber() );
182 m_position = m_libPin->GetPosition();
183
185}
186
187
188SCH_PIN::SCH_PIN( SCH_SYMBOL* aParentSymbol, const wxString& aNumber, const wxString& aAlt,
189 const KIID& aUuid ) :
190 SCH_ITEM( aParentSymbol, SCH_PIN_T ),
191 m_libPin( nullptr ),
195 m_number( aNumber ),
196 m_alt( aAlt ),
197 m_isDangling( true ),
198 m_layoutCache( std::make_unique<PIN_LAYOUT_CACHE>( *this ) )
199{
200 wxASSERT( aParentSymbol );
201
202 const_cast<KIID&>( m_Uuid ) = aUuid;
204}
205
206
207SCH_PIN::SCH_PIN( const SCH_PIN& aPin ) :
208 SCH_ITEM( aPin ),
209 m_libPin( aPin.m_libPin ),
211 m_position( aPin.m_position ),
212 m_length( aPin.m_length ),
214 m_shape( aPin.m_shape ),
215 m_type( aPin.m_type ),
216 m_hidden( aPin.m_hidden ),
219 m_alt( aPin.m_alt ),
221 m_layoutCache( std::make_unique<PIN_LAYOUT_CACHE>( *this ) )
222{
223 SetName( aPin.m_name );
224 SetNumber( aPin.m_number );
225
226 m_layer = aPin.m_layer;
227}
228
229
233
234
236{
237 SCH_ITEM::operator=( aPin );
238
239 m_libPin = aPin.m_libPin;
241 m_alt = aPin.m_alt;
242 m_name = aPin.m_name;
243 m_number = aPin.m_number;
244 m_position = aPin.m_position;
245 m_length = aPin.m_length;
247 m_shape = aPin.m_shape;
248 m_type = aPin.m_type;
249 m_hidden = aPin.m_hidden;
253
254 return *this;
255}
256
257
259{
260 if( const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( GetParentSymbol() ) )
261 return symbol->GetTransform().TransformCoordinate( m_position ) + symbol->GetPosition();
262 else
263 return m_position;
264}
265
267{
269 {
270 if( !m_libPin )
272
273 return m_libPin->GetOrientation();
274 }
275
276 return m_orientation;
277}
278
279
281{
282 if( !m_alt.IsEmpty() )
283 {
284 if( !m_libPin )
286
287 return m_libPin->GetAlt( m_alt ).m_Shape;
288 }
290 {
291 if( !m_libPin )
293
294 return m_libPin->GetShape();
295 }
296
297 return m_shape;
298}
299
300
302{
303 if( !m_length.has_value() )
304 {
305 if( !m_libPin )
306 return 0;
307
308 return m_libPin->GetLength();
309 }
310
311 return m_length.value();
312}
313
314
316{
317 if( !m_alt.IsEmpty() )
318 {
319 if( !m_libPin )
321
322 return m_libPin->GetAlt( m_alt ).m_Type;
323 }
325 {
326 if( !m_libPin )
328
329 return m_libPin->GetType();
330 }
331
332 return m_type;
333}
334
336{
337 if( aType == m_type )
338 return;
339
340 m_type = aType;
342}
343
344
346{
347 // Use GetType() which correctly handles alternates
348 return ::GetCanonicalElectricalTypeName( GetType() );
349}
350
351
353{
354 // Use GetType() which correctly handles alternates
356}
357
358
360{
362 return false;
363
364 const SYMBOL* parent = GetParentSymbol();
365
366 if( parent->IsGlobalPower() )
367 return true;
368
369 // Local power symbols are never global, even with invisible pins
370 if( parent->IsLocalPower() )
371 return false;
372
373 // Legacy support: invisible power-in pins on non-power symbols act as global power
374 return !IsVisible();
375}
376
377
383
384
386{
387 return IsLocalPower() || IsGlobalPower();
388}
389
390
392{
393 if( !m_hidden.has_value() )
394 {
395 if( !m_libPin )
396 return true;
397
398 return m_libPin->IsVisible();
399 }
400
401 return !m_hidden.value();
402}
403
404
405const wxString& SCH_PIN::GetName() const
406{
407 if( !m_alt.IsEmpty() )
408 return m_alt;
409
410 return GetBaseName();
411}
412
413
414const wxString& SCH_PIN::GetBaseName() const
415{
416 if( m_libPin )
417 return m_libPin->GetBaseName();
418
419 return m_name;
420}
421
422
423void SCH_PIN::SetName( const wxString& aName )
424{
425 if( m_name == aName )
426 return;
427
428 m_name = aName;
429
430 // pin name string does not support spaces
431 m_name.Replace( wxT( " " ), wxT( "_" ) );
432
434}
435
436
437void SCH_PIN::SetAlt( const wxString& aAlt )
438{
439 // Do not set the alternate pin definition to the default pin name. This breaks the library
440 // symbol comparison for the ERC and the library diff tool. It also incorrectly causes the
441 // schematic symbol pin alternate to be set.
442 if( aAlt.IsEmpty() || aAlt == GetBaseName() )
443 {
444 m_alt = wxEmptyString;
445 return;
446 }
447
448 if( !m_libPin )
449 {
450 wxFAIL_MSG( wxString::Format( wxS( "Pin '%s' has no corresponding lib_pin" ), m_number ) );
451 m_alt = wxEmptyString;
452 return;
453 }
454
455 if( !m_libPin->GetAlternates().contains( aAlt ) )
456 {
457 wxFAIL_MSG( wxString::Format( wxS( "Pin '%s' has no alterate '%s'" ), m_number, aAlt ) );
458 m_alt = wxEmptyString;
459 return;
460 }
461
462 m_alt = aAlt;
463}
464
466{
468 return false;
469
470 return m_isDangling;
471}
472
473
474void SCH_PIN::SetIsDangling( bool aIsDangling )
475{
476 m_isDangling = aIsDangling;
477}
478
479
480bool SCH_PIN::IsStacked( const SCH_PIN* aPin ) const
481{
482 const auto isPassiveOrNic = []( ELECTRICAL_PINTYPE t )
483 {
485 };
486
487 const bool sameParent = m_parent == aPin->GetParent();
488 const bool samePos = GetPosition() == aPin->GetPosition();
489 const bool sameName = GetName() == aPin->GetName();
490 const bool typeCompat = GetType() == aPin->GetType()
491 || isPassiveOrNic( GetType() )
492 || isPassiveOrNic( aPin->GetType() );
493
494 wxLogTrace( traceStackedPins,
495 wxString::Format( "IsStacked: this='%s/%s' other='%s/%s' sameParent=%d samePos=%d sameName=%d typeCompat=%d",
496 GetName(), GetNumber(), aPin->GetName(), aPin->GetNumber(), sameParent,
497 samePos, sameName, typeCompat ) );
498
499 return sameParent && samePos && sameName && typeCompat;
500}
501
502
503bool SCH_PIN::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
504{
505 const SCH_SEARCH_DATA& schSearchData =
506 dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData );
507
508 if( schSearchData.searchAllPins
509 && ( EDA_ITEM::Matches( GetName(), aSearchData )
510 || EDA_ITEM::Matches( GetNumber(), aSearchData ) ) )
511 {
512 return true;
513 }
514
515 SCH_CONNECTION* connection = nullptr;
516 SCH_SHEET_PATH* sheetPath = reinterpret_cast<SCH_SHEET_PATH*>( aAuxData );
517
518 if( schSearchData.searchNetNames && sheetPath && ( connection = Connection( sheetPath ) ) )
519 {
520 wxString netName = connection->GetNetName();
521
522 if( EDA_ITEM::Matches( netName, aSearchData ) )
523 return true;
524 }
525
526 return false;
527}
528
529
530bool SCH_PIN::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
531{
532 bool isReplaced = false;
533
534 if( dynamic_cast<LIB_SYMBOL*>( GetParentSymbol() ) )
535 {
536 isReplaced |= EDA_ITEM::Replace( aSearchData, m_name );
537 isReplaced |= EDA_ITEM::Replace( aSearchData, m_number );
538 }
539 else
540 {
541 /* TODO: waiting on a way to override pins in the schematic...
542 isReplaced |= EDA_ITEM::Replace( aSearchData, m_name );
543 isReplaced |= EDA_ITEM::Replace( aSearchData, m_number );
544 */
545 }
546
547 return isReplaced;
548}
549
550
551bool SCH_PIN::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
552{
553 // When looking for an "exact" hit aAccuracy will be 0 which works poorly if the pin has
554 // no pin number or name. Give it a floor.
555 if( Schematic() )
556 aAccuracy = std::max( aAccuracy, Schematic()->Settings().m_PinSymbolSize / 4 );
557
558 BOX2I rect = GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE );
559
560 return rect.Inflate( aAccuracy ).Contains( aPosition );
561}
562
563
564bool SCH_PIN::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
565{
567 return false;
568
569 BOX2I sel = aRect;
570
571 if ( aAccuracy )
572 sel.Inflate( aAccuracy );
573
574 if( aContained )
575 return sel.Contains( GetBoundingBox( false, false, false ) );
576
577 return sel.Intersects( GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE ) );
578}
579
580
581const wxString& SCH_PIN::GetShownName() const
582{
583 if( !m_alt.IsEmpty() )
584 return m_alt;
585 else if( m_libPin )
586 return m_libPin->GetShownName();
587
588 return m_name;
589}
590
591
592const wxString& SCH_PIN::GetShownNumber() const
593{
594 return m_number;
595}
596
597
598std::vector<wxString> SCH_PIN::GetStackedPinNumbers( bool* aValid ) const
599{
600 const wxString& shown = GetShownNumber();
601 wxLogTrace( traceStackedPins, "GetStackedPinNumbers: shown='%s'", shown );
602
603 std::vector<wxString> numbers = ExpandStackedPinNotation( shown, aValid );
604
605 // Log the expansion for debugging
606 wxLogTrace( traceStackedPins, "Expanded '%s' to %zu pins", shown, numbers.size() );
607 for( const wxString& num : numbers )
608 {
609 wxLogTrace( traceStackedPins, wxString::Format( " -> '%s'", num ) );
610 }
611
612 return numbers;
613}
614
615
616int SCH_PIN::GetStackedPinCount( bool* aValid ) const
617{
618 const wxString& shown = GetShownNumber();
619 return CountStackedPinNotation( shown, aValid );
620}
621
622
623std::optional<wxString> SCH_PIN::GetSmallestLogicalNumber() const
624{
625 bool valid = false;
626 auto numbers = GetStackedPinNumbers( &valid );
627
628 if( valid && !numbers.empty() )
629 return numbers.front(); // Already in ascending order
630
631 return std::nullopt;
632}
633
634
636{
637 if( auto smallest = GetSmallestLogicalNumber() )
638 return *smallest;
639
640 return GetShownNumber();
641}
642
643
644void SCH_PIN::SetNumber( const wxString& aNumber )
645{
646 if( m_number == aNumber )
647 return;
648
649 m_number = aNumber;
650 // pin number string does not support spaces
651 m_number.Replace( wxT( " " ), wxT( "_" ) );
652
654}
655
656
658{
659 if( !m_nameTextSize.has_value() )
660 {
661 if( !m_libPin )
662 return schIUScale.MilsToIU( DEFAULT_PINNAME_SIZE );
663
664 return m_libPin->GetNameTextSize();
665 }
666
667 return m_nameTextSize.value();
668}
669
670
672{
673 if( aSize == m_nameTextSize )
674 return;
675
676 m_nameTextSize = aSize;
678}
679
680
682{
683 if( !m_numTextSize.has_value() )
684 {
685 if( !m_libPin )
686 return schIUScale.MilsToIU( DEFAULT_PINNUM_SIZE );
687
688 return m_libPin->GetNumberTextSize();
689 }
690
691 return m_numTextSize.value();
692}
693
694
696{
697 if( aSize == m_numTextSize )
698 return;
699
700 m_numTextSize = aSize;
702}
703
704
706{
707 if( const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( GetParentSymbol() ) )
708 {
709 const TRANSFORM& t = symbol->GetTransform();
710
711 if( !m_libPin )
712 return GetPosition();
713
714 return t.TransformCoordinate( m_libPin->GetPinRoot() ) + symbol->GetPosition();
715 }
716
717 switch( GetOrientation() )
718 {
719 default:
724 }
725}
726
727
728void SCH_PIN::PlotPinType( PLOTTER *aPlotter, const VECTOR2I &aPosition,
729 PIN_ORIENTATION aOrientation, bool aDimmed ) const
730{
731 int MapX1, MapY1, x1, y1;
732 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
733 COLOR4D color = renderSettings->GetLayerColor( LAYER_PIN );
734 COLOR4D bg = renderSettings->GetBackgroundColor();
735 int penWidth = GetEffectivePenWidth( renderSettings );
736 int pinLength = GetLength();
737
738 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
739 bg = COLOR4D::WHITE;
740
741 if( color.m_text && Schematic() )
742 color = COLOR4D( ResolveText( *color.m_text, &Schematic()->CurrentSheet() ) );
743
744 if( aDimmed )
745 {
746 color.Desaturate( );
747 color = color.Mix( bg, 0.5f );
748 }
749
750 aPlotter->SetColor( color );
751 aPlotter->SetCurrentLineWidth( penWidth );
752
753 MapX1 = MapY1 = 0;
754 x1 = aPosition.x; y1 = aPosition.y;
755
756 switch( aOrientation )
757 {
758 case PIN_ORIENTATION::PIN_UP: y1 = aPosition.y - pinLength; MapY1 = 1; break;
759 case PIN_ORIENTATION::PIN_DOWN: y1 = aPosition.y + pinLength; MapY1 = -1; break;
760 case PIN_ORIENTATION::PIN_LEFT: x1 = aPosition.x - pinLength; MapX1 = 1; break;
761 case PIN_ORIENTATION::PIN_RIGHT: x1 = aPosition.x + pinLength; MapX1 = -1; break;
762 case PIN_ORIENTATION::INHERIT: wxFAIL_MSG( wxS( "aOrientation must be resolved!" ) ); break;
763 }
764
766 {
767 const int radius = externalPinDecoSize( aPlotter->RenderSettings(), *this );
768 aPlotter->Circle( VECTOR2I( MapX1 * radius + x1, MapY1 * radius + y1 ), radius * 2,
769 FILL_T::NO_FILL, penWidth );
770
771 aPlotter->MoveTo( VECTOR2I( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) );
772 aPlotter->FinishTo( aPosition );
773 }
775 {
776 const int deco_size = internalPinDecoSize( aPlotter->RenderSettings(), *this );
777 if( MapY1 == 0 ) /* MapX1 = +- 1 */
778 {
779 aPlotter->MoveTo( VECTOR2I( x1, y1 + deco_size ) );
780 aPlotter->LineTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 ) );
781 aPlotter->FinishTo( VECTOR2I( x1, y1 - deco_size ) );
782 }
783 else /* MapX1 = 0 */
784 {
785 aPlotter->MoveTo( VECTOR2I( x1 + deco_size, y1 ) );
786 aPlotter->LineTo( VECTOR2I( x1, y1 + MapY1 * deco_size * 2 ) );
787 aPlotter->FinishTo( VECTOR2I( x1 - deco_size, y1 ) );
788 }
789
790 aPlotter->MoveTo( VECTOR2I( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ) );
791 aPlotter->FinishTo( aPosition );
792 }
793 else
794 {
795 aPlotter->MoveTo( VECTOR2I( x1, y1 ) );
796 aPlotter->FinishTo( aPosition );
797 }
798
802 {
803 const int deco_size = internalPinDecoSize( aPlotter->RenderSettings(), *this );
804
805 if( MapY1 == 0 ) /* MapX1 = +- 1 */
806 {
807 aPlotter->MoveTo( VECTOR2I( x1, y1 + deco_size ) );
808 aPlotter->LineTo( VECTOR2I( x1 - MapX1 * deco_size * 2, y1 ) );
809 aPlotter->FinishTo( VECTOR2I( x1, y1 - deco_size ) );
810 }
811 else /* MapX1 = 0 */
812 {
813 aPlotter->MoveTo( VECTOR2I( x1 + deco_size, y1 ) );
814 aPlotter->LineTo( VECTOR2I( x1, y1 - MapY1 * deco_size * 2 ) );
815 aPlotter->FinishTo( VECTOR2I( x1 - deco_size, y1 ) );
816 }
817 }
818
820 || m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW ) /* IEEE symbol "Active Low Input" */
821 {
822 const int deco_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
823
824 if( MapY1 == 0 ) /* MapX1 = +- 1 */
825 {
826 aPlotter->MoveTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 ) );
827 aPlotter->LineTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
828 aPlotter->FinishTo( VECTOR2I( x1, y1 ) );
829 }
830 else /* MapX1 = 0 */
831 {
832 aPlotter->MoveTo( VECTOR2I( x1, y1 + MapY1 * deco_size * 2 ) );
833 aPlotter->LineTo( VECTOR2I( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
834 aPlotter->FinishTo( VECTOR2I( x1, y1 ) );
835 }
836 }
837
838 if( m_shape == GRAPHIC_PINSHAPE::OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
839 {
840 const int symbol_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
841
842 if( MapY1 == 0 ) /* MapX1 = +- 1 */
843 {
844 aPlotter->MoveTo( VECTOR2I( x1, y1 - symbol_size * 2 ) );
845 aPlotter->FinishTo( VECTOR2I( x1 + MapX1 * symbol_size * 2, y1 ) );
846 }
847 else /* MapX1 = 0 */
848 {
849 aPlotter->MoveTo( VECTOR2I( x1 - symbol_size * 2, y1 ) );
850 aPlotter->FinishTo( VECTOR2I( x1, y1 + MapY1 * symbol_size * 2 ) );
851 }
852 }
853 else if( m_shape == GRAPHIC_PINSHAPE::NONLOGIC ) /* NonLogic pin symbol */
854 {
855 const int deco_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
856 aPlotter->MoveTo( VECTOR2I( x1 - ( MapX1 + MapY1 ) * deco_size,
857 y1 - ( MapY1 - MapX1 ) * deco_size ) );
858 aPlotter->FinishTo( VECTOR2I( x1 + ( MapX1 + MapY1 ) * deco_size,
859 y1 + ( MapY1 - MapX1 ) * deco_size ) );
860 aPlotter->MoveTo( VECTOR2I( x1 - ( MapX1 - MapY1 ) * deco_size,
861 y1 - ( MapY1 + MapX1 ) * deco_size ) );
862 aPlotter->FinishTo( VECTOR2I( x1 + ( MapX1 - MapY1 ) * deco_size,
863 y1 + ( MapY1 + MapX1 ) * deco_size ) );
864 }
865
866 if( GetType() == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
867 {
868 const int deco_size = TARGET_PIN_RADIUS;
869 const int ex1 = aPosition.x;
870 const int ey1 = aPosition.y;
871 aPlotter->MoveTo( VECTOR2I( ex1 - deco_size, ey1 - deco_size ) );
872 aPlotter->FinishTo( VECTOR2I( ex1 + deco_size, ey1 + deco_size ) );
873 aPlotter->MoveTo( VECTOR2I( ex1 + deco_size, ey1 - deco_size ) );
874 aPlotter->FinishTo( VECTOR2I( ex1 - deco_size, ey1 + deco_size ) );
875 }
876}
877
878
879void SCH_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient,
880 int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed ) const
881{
882 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
883 KIFONT::FONT* font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), false, false );
884 wxString name = GetShownName();
885 wxString number = GetShownNumber();
886
887 // Apply stacked pin display formatting (reuse helper from pin_layout_cache)
888 if( aDrawPinNum && !number.IsEmpty() )
889 {
890 const KIFONT::METRICS& metrics = GetFontMetrics();
891 number = FormatStackedPinForDisplay( number, GetLength(), GetNumberTextSize(), font, metrics );
892 }
893
894 if( name.IsEmpty() || m_nameTextSize == 0 )
895 aDrawPinName = false;
896
897 if( number.IsEmpty() || m_numTextSize == 0 )
898 aDrawPinNum = false;
899
900 if( !aDrawPinNum && !aDrawPinName )
901 return;
902
903 int namePenWidth = settings->GetDefaultPenWidth();
904 int numPenWidth = settings->GetDefaultPenWidth();
905 int name_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + namePenWidth;
906 int num_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + numPenWidth;
907
908 COLOR4D nameColor = settings->GetLayerColor( LAYER_PINNAM );
909 COLOR4D numColor = settings->GetLayerColor( LAYER_PINNUM );
910 COLOR4D bg = settings->GetBackgroundColor();
911
912 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
913 bg = COLOR4D::WHITE;
914
915 if( nameColor.m_text && Schematic() )
916 nameColor = COLOR4D( ResolveText( *nameColor.m_text, &Schematic()->CurrentSheet() ) );
917
918 if( numColor.m_text && Schematic() )
919 numColor = COLOR4D( ResolveText( *numColor.m_text, &Schematic()->CurrentSheet() ) );
920
921 if( aDimmed )
922 {
923 nameColor.Desaturate();
924 numColor.Desaturate();
925 nameColor = nameColor.Mix( bg, 0.5f );
926 numColor = numColor.Mix( bg, 0.5f );
927 }
928
929 int x1 = aPinPos.x;
930 int y1 = aPinPos.y;
931
932 switch( aPinOrient )
933 {
934 case PIN_ORIENTATION::PIN_UP: y1 -= GetLength(); break;
935 case PIN_ORIENTATION::PIN_DOWN: y1 += GetLength(); break;
936 case PIN_ORIENTATION::PIN_LEFT: x1 -= GetLength(); break;
937 case PIN_ORIENTATION::PIN_RIGHT: x1 += GetLength(); break;
938 default: break;
939 }
940
941 auto plotSimpleText =
942 [&]( int x, int y, const EDA_ANGLE& angle, GR_TEXT_H_ALIGN_T hJustify, GR_TEXT_V_ALIGN_T vJustify,
943 const wxString& txt, int size, int penWidth, const COLOR4D& col )
944 {
945 TEXT_ATTRIBUTES attrs;
946 attrs.m_StrokeWidth = penWidth;
947 attrs.m_Angle = angle;
948 attrs.m_Size = VECTOR2I( size, size );
949 attrs.m_Halign = hJustify;
950 attrs.m_Valign = vJustify;
951 attrs.m_Multiline = false; // we'll manage multi-line manually
952 aPlotter->PlotText( VECTOR2I( x, y ), col, txt, attrs, font, GetFontMetrics() );
953 };
954
955 auto plotMultiLineWithBraces =
956 [&]( int anchorX, int anchorY, EDA_ANGLE angle, GR_TEXT_V_ALIGN_T vAlign, bool /*numberBlock*/ )
957 {
958 // If not multi-line formatted, just plot single line centered.
959 if( !number.StartsWith( "[" ) || !number.EndsWith( "]" ) || !number.Contains( "\n" ) )
960 {
961 plotSimpleText( anchorX, anchorY, angle, GR_TEXT_H_ALIGN_CENTER, vAlign, number,
962 GetNumberTextSize(), numPenWidth, numColor );
963 return;
964 }
965
966 wxString content = number.Mid( 1, number.Length() - 2 );
967 wxArrayString lines;
968 wxStringSplit( content, lines, '\n' );
969
970 if( lines.size() <= 1 )
971 {
972 plotSimpleText( anchorX, anchorY, angle, GR_TEXT_H_ALIGN_CENTER, vAlign, content,
973 GetNumberTextSize(), numPenWidth, numColor );
974 return;
975 }
976
977 int textSize = GetNumberTextSize();
978 int lineSpacing = KiROUND( textSize * 1.3 );
979 const KIFONT::METRICS& metrics = GetFontMetrics();
980
981 // Measure line widths for brace spacing
982 int maxLineWidth = 0;
983 for( const wxString& rawLine : lines )
984 {
985 wxString trimmed = rawLine; trimmed.Trim(true).Trim(false);
986 VECTOR2I ext = font->StringBoundaryLimits( trimmed, VECTOR2D( textSize, textSize ),
987 GetPenSizeForNormal( textSize ), false, false, metrics );
988 if( ext.x > maxLineWidth )
989 maxLineWidth = ext.x;
990 }
991
992 // Determine starting position
993 int startX = anchorX;
994 int startY = anchorY;
995
996 if( angle == ANGLE_VERTICAL )
997 {
998 int totalWidth = ( (int) lines.size() - 1 ) * lineSpacing;
999 startX -= totalWidth;
1000 }
1001 else
1002 {
1003 int totalHeight = ( (int) lines.size() - 1 ) * lineSpacing;
1004 startY -= totalHeight;
1005 }
1006
1007 for( size_t i = 0; i < lines.size(); ++i )
1008 {
1009 wxString l = lines[i]; l.Trim( true ).Trim( false );
1010 int lx = startX + ( angle == ANGLE_VERTICAL ? (int) i * lineSpacing : 0 );
1011 int ly = startY + ( angle == ANGLE_VERTICAL ? 0 : (int) i * lineSpacing );
1012 plotSimpleText( lx, ly, angle, GR_TEXT_H_ALIGN_CENTER, vAlign, l, textSize, numPenWidth, numColor );
1013 }
1014
1015 // Now draw braces emulating SCH_PAINTER brace geometry
1016 auto plotBrace =
1017 [&]( const VECTOR2I& top, const VECTOR2I& bottom, bool leftOrTop, bool isVerticalText )
1018 {
1019 // Build 4 small segments approximating curly brace
1020 VECTOR2I mid = ( top + bottom ) / 2;
1021 int braceWidth = textSize / 3; // same scale as painter
1022 VECTOR2I p1 = top;
1023 VECTOR2I p5 = bottom;
1024 VECTOR2I p2 = top;
1025 VECTOR2I p3 = mid;
1026 VECTOR2I p4 = bottom;
1027 int offset = leftOrTop ? -braceWidth : braceWidth;
1028
1029 if( isVerticalText )
1030 {
1031 // Text vertical => brace extends in Y (horizontal brace lines across X axis set)
1032 // For vertical orientation we offset Y for p2/p3/p4
1033 p2.y += offset / 2;
1034 p3.y += offset;
1035 p4.y += offset / 2;
1036 }
1037 else
1038 {
1039 // Horizontal text => brace extends in X
1040 p2.x += offset / 2;
1041 p3.x += offset;
1042 p4.x += offset / 2;
1043 }
1044
1045 aPlotter->MoveTo( p1 ); aPlotter->FinishTo( p2 );
1046 aPlotter->MoveTo( p2 ); aPlotter->FinishTo( p3 );
1047 aPlotter->MoveTo( p3 ); aPlotter->FinishTo( p4 );
1048 aPlotter->MoveTo( p4 ); aPlotter->FinishTo( p5 );
1049 };
1050
1051 aPlotter->SetCurrentLineWidth( numPenWidth );
1052 int braceWidth = textSize / 3;
1053 int extraHeight = textSize / 3; // extend beyond text block
1054
1055 if( angle == ANGLE_VERTICAL )
1056 {
1057 // Lines spaced horizontally, braces horizontal (above & below)
1058 int totalWidth = ( (int) lines.size() - 1 ) * lineSpacing;
1059 VECTOR2I braceStart( startX - 2 * extraHeight, anchorY );
1060 VECTOR2I braceEnd( startX + totalWidth + extraHeight, anchorY );
1061 int braceSpacing = maxLineWidth / 2 + braceWidth;
1062
1063 VECTOR2I topStart = braceStart; topStart.y -= braceSpacing;
1064 VECTOR2I topEnd = braceEnd; topEnd.y -= braceSpacing;
1065 VECTOR2I bottomStart = braceStart; bottomStart.y += braceSpacing;
1066 VECTOR2I bottomEnd = braceEnd; bottomEnd.y += braceSpacing;
1067
1068 plotBrace( topStart, topEnd, true, true ); // leftOrTop=true
1069 plotBrace( bottomStart, bottomEnd, false, true );
1070 }
1071 else
1072 {
1073 // Lines spaced vertically, braces vertical (left & right)
1074 int totalHeight = ( (int) lines.size() - 1 ) * lineSpacing;
1075 VECTOR2I braceStart( anchorX, startY - 2 * extraHeight );
1076 VECTOR2I braceEnd( anchorX, startY + totalHeight + extraHeight );
1077 int braceSpacing = maxLineWidth / 2 + braceWidth;
1078
1079 VECTOR2I leftTop = braceStart; leftTop.x -= braceSpacing;
1080 VECTOR2I leftBot = braceEnd; leftBot.x -= braceSpacing;
1081 VECTOR2I rightTop = braceStart; rightTop.x += braceSpacing;
1082 VECTOR2I rightBot = braceEnd; rightBot.x += braceSpacing;
1083
1084 plotBrace( leftTop, leftBot, true, false );
1085 plotBrace( rightTop, rightBot, false, false );
1086 }
1087 };
1088
1089 // Logic largely mirrors original single-line placement but calls multi-line path for numbers
1090 if( aTextInside )
1091 {
1092 if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT ) || ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
1093 {
1094 if( aDrawPinName )
1095 {
1096 if( aPinOrient == PIN_ORIENTATION::PIN_RIGHT )
1097 {
1098 plotSimpleText( x1 + aTextInside, y1, ANGLE_HORIZONTAL, GR_TEXT_H_ALIGN_LEFT,
1099 GR_TEXT_V_ALIGN_CENTER, name, GetNameTextSize(), namePenWidth, nameColor );
1100 }
1101 else
1102 {
1103 plotSimpleText( x1 - aTextInside, y1, ANGLE_HORIZONTAL, GR_TEXT_H_ALIGN_RIGHT,
1104 GR_TEXT_V_ALIGN_CENTER, name, GetNameTextSize(), namePenWidth, nameColor );
1105 }
1106 }
1107
1108 if( aDrawPinNum )
1109 {
1110 plotMultiLineWithBraces( ( x1 + aPinPos.x ) / 2, y1 - num_offset, ANGLE_HORIZONTAL,
1111 GR_TEXT_V_ALIGN_BOTTOM, true );
1112 }
1113 }
1114 else
1115 {
1116 if( aPinOrient == PIN_ORIENTATION::PIN_DOWN )
1117 {
1118 if( aDrawPinName )
1119 {
1120 plotSimpleText( x1, y1 + aTextInside, ANGLE_VERTICAL, GR_TEXT_H_ALIGN_RIGHT,
1121 GR_TEXT_V_ALIGN_CENTER, name, GetNameTextSize(), namePenWidth, nameColor );
1122 }
1123
1124 if( aDrawPinNum )
1125 {
1126 plotMultiLineWithBraces( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1127 GR_TEXT_V_ALIGN_BOTTOM, true );
1128 }
1129 }
1130 else // PIN_UP
1131 {
1132 if( aDrawPinName )
1133 {
1134 plotSimpleText( x1, y1 - aTextInside, ANGLE_VERTICAL, GR_TEXT_H_ALIGN_LEFT,
1135 GR_TEXT_V_ALIGN_CENTER, name, GetNameTextSize(), namePenWidth, nameColor );
1136 }
1137
1138 if( aDrawPinNum )
1139 {
1140 plotMultiLineWithBraces( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1141 GR_TEXT_V_ALIGN_BOTTOM, true );
1142 }
1143 }
1144 }
1145 }
1146 else
1147 {
1148 if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT ) || ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
1149 {
1150 if( aDrawPinName && aDrawPinNum )
1151 {
1152 plotSimpleText( ( x1 + aPinPos.x ) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
1154 GetNameTextSize(), namePenWidth, nameColor );
1155 plotMultiLineWithBraces( ( x1 + aPinPos.x ) / 2, y1 + num_offset, ANGLE_HORIZONTAL,
1156 GR_TEXT_V_ALIGN_TOP, true );
1157 }
1158 else if( aDrawPinName )
1159 {
1160 plotSimpleText( ( x1 + aPinPos.x ) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
1162 GetNameTextSize(), namePenWidth, nameColor );
1163 }
1164 else if( aDrawPinNum )
1165 {
1166 plotMultiLineWithBraces( ( x1 + aPinPos.x ) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
1167 GR_TEXT_V_ALIGN_BOTTOM, true );
1168 }
1169 }
1170 else
1171 {
1172 if( aDrawPinName && aDrawPinNum )
1173 {
1174 plotSimpleText( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1176 GetNameTextSize(), namePenWidth, nameColor );
1177 plotMultiLineWithBraces( x1 + num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1178 GR_TEXT_V_ALIGN_TOP, true );
1179 }
1180 else if( aDrawPinName )
1181 {
1182 plotSimpleText( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1184 GetNameTextSize(), namePenWidth, nameColor );
1185 }
1186 else if( aDrawPinNum )
1187 {
1188 plotMultiLineWithBraces( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1189 GR_TEXT_V_ALIGN_BOTTOM, true );
1190 }
1191 }
1192 }
1193}
1194
1195
1197{
1198 PIN_ORIENTATION orient;
1199 VECTOR2I end; // position of pin end starting at 0,0 according to its orientation, length = 1
1200
1201 switch( GetOrientation() )
1202 {
1203 default:
1204 case PIN_ORIENTATION::PIN_RIGHT: end.x = 1; break;
1205 case PIN_ORIENTATION::PIN_UP: end.y = -1; break;
1206 case PIN_ORIENTATION::PIN_DOWN: end.y = 1; break;
1207 case PIN_ORIENTATION::PIN_LEFT: end.x = -1; break;
1208 }
1209
1210 // = pos of end point, according to the symbol orientation.
1211 end = aTransform.TransformCoordinate( end );
1212 orient = PIN_ORIENTATION::PIN_UP;
1213
1214 if( end.x == 0 )
1215 {
1216 if( end.y > 0 )
1218 }
1219 else
1220 {
1222
1223 if( end.x < 0 )
1225 }
1226
1227 return orient;
1228}
1229
1230
1232{
1233 //return new SCH_PIN( *this );
1234 SCH_ITEM* newPin = new SCH_PIN( *this );
1235 wxASSERT( newPin->GetUnit() == m_unit && newPin->GetBodyStyle() == m_bodyStyle );
1236 return newPin;
1237}
1238
1239
1240void SCH_PIN::ChangeLength( int aLength )
1241{
1242 int lengthChange = GetLength() - aLength;
1243 int offsetX = 0;
1244 int offsetY = 0;
1245
1246 switch( GetOrientation() )
1247 {
1248 default:
1250 offsetX = lengthChange;
1251 break;
1253 offsetX = -1 * lengthChange;
1254 break;
1256 offsetY = -1 * lengthChange;
1257 break;
1259 offsetY = lengthChange;
1260 break;
1261 }
1262
1263 m_position += VECTOR2I( offsetX, offsetY );
1264 m_length = aLength;
1265}
1266
1267
1268void SCH_PIN::Move( const VECTOR2I& aOffset )
1269{
1270 m_position += aOffset;
1271}
1272
1273
1275{
1276 m_position.x -= aCenter;
1277 m_position.x *= -1;
1278 m_position.x += aCenter;
1279
1284}
1285
1286
1288{
1289 if( dynamic_cast<LIB_SYMBOL*>( GetParentSymbol() ) )
1290 MirrorHorizontallyPin( aCenter );
1291}
1292
1293
1295{
1296 m_position.y -= aCenter;
1297 m_position.y *= -1;
1298 m_position.y += aCenter;
1299
1304}
1305
1306
1307void SCH_PIN::MirrorVertically( int aCenter )
1308{
1309 if( dynamic_cast<LIB_SYMBOL*>( GetParentSymbol() ) )
1310 MirrorVerticallyPin( aCenter );
1311}
1312
1313
1314void SCH_PIN::RotatePin( const VECTOR2I& aCenter, bool aRotateCCW )
1315{
1316 if( aRotateCCW )
1317 {
1318 RotatePoint( m_position, aCenter, ANGLE_90 );
1319
1320 switch( GetOrientation() )
1321 {
1322 default:
1327 }
1328 }
1329 else
1330 {
1331 RotatePoint( m_position, aCenter, -ANGLE_90 );
1332
1333 switch( GetOrientation() )
1334 {
1335 default:
1340 }
1341 }
1342}
1343
1344
1345void SCH_PIN::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
1346{
1347 if( dynamic_cast<LIB_SYMBOL*>( GetParentSymbol() ) )
1348 RotatePin( aCenter, aRotateCCW );
1349}
1350
1351
1352void SCH_PIN::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
1353 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
1354{
1355 if( aBackground )
1356 return;
1357
1358 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
1359
1360 if( !IsVisible() && !renderSettings->m_ShowHiddenPins )
1361 return;
1362
1363 const SYMBOL* part = GetParentSymbol();
1364 PIN_ORIENTATION orient = PinDrawOrient( renderSettings->m_Transform );
1365 VECTOR2I pos = renderSettings->TransformCoordinate( m_position ) + aOffset;
1366
1367 PlotPinType( aPlotter, pos, orient, aDimmed );
1368 PlotPinTexts( aPlotter, pos, orient, part->GetPinNameOffset(), part->GetShowPinNumbers(),
1369 part->GetShowPinNames(), aDimmed );
1370}
1371
1372
1373void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1374{
1375 SYMBOL* symbol = GetParentSymbol();
1376
1377 aList.emplace_back( _( "Type" ), _( "Pin" ) );
1378
1379 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
1380
1381 aList.emplace_back( _( "Name" ), UnescapeString( GetShownName() ) );
1382 aList.emplace_back( _( "Number" ), GetShownNumber() );
1383 aList.emplace_back( _( "Type" ), ElectricalPinTypeGetText( GetType() ) );
1384 aList.emplace_back( _( "Style" ), PinShapeGetText( GetShape() ) );
1385
1386 aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
1387
1388 // Display pin length
1389 aList.emplace_back( _( "Length" ), aFrame->MessageTextFromValue( GetLength(), true ) );
1390
1391 aList.emplace_back( _( "Orientation" ), PinOrientationName( GetOrientation() ) );
1392
1393 if( dynamic_cast<LIB_SYMBOL*>( symbol ) )
1394 {
1395 aList.emplace_back( _( "Pos X" ), aFrame->MessageTextFromValue( GetPosition().x, true ) );
1396 aList.emplace_back( _( "Pos Y" ), aFrame->MessageTextFromValue( GetPosition().y, true ) );
1397 }
1398 else if( SCH_SYMBOL* schsymbol = dynamic_cast<SCH_SYMBOL*>( symbol ) )
1399 {
1400 SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
1401 SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
1402
1403 // Don't use GetShownText(); we want to see the variable references here
1404 aList.emplace_back( symbol->GetRef( currentSheet ),
1405 UnescapeString( schsymbol->GetField( FIELD_T::VALUE )->GetText() ) );
1406 }
1407
1408#if defined(DEBUG)
1409 if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
1410 {
1411 SCH_CONNECTION* conn = Connection();
1412
1413 if( conn )
1414 conn->AppendInfoToMsgPanel( aList );
1415 }
1416#endif
1417}
1418
1419
1421{
1422 std::lock_guard<std::recursive_mutex> lock( m_netmap_mutex );
1423
1424 if( aPath )
1425 m_net_name_map.erase( *aPath );
1426 else
1427 m_net_name_map.clear();
1428}
1429
1430
1431wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoConnect )
1432{
1433 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( GetParentSymbol() );
1434
1435 // Need to check for parent as power symbol to make sure we aren't dealing
1436 // with legacy global power pins on non-power symbols
1437 if( IsGlobalPower() || IsLocalPower() )
1438 {
1439 SYMBOL* parent = GetLibPin() ? GetLibPin()->GetParentSymbol() : nullptr;
1440
1441 if( parent && ( parent->IsGlobalPower() || parent->IsLocalPower() ) )
1442 {
1443 return EscapeString( symbol->GetValue( true, &aPath, false ), CTX_NETNAME );
1444 }
1445 else
1446 {
1447 wxString tmp = m_libPin ? m_libPin->GetName() : wxString( "??" );
1448
1449 return EscapeString( tmp, CTX_NETNAME );
1450 }
1451 }
1452
1453 std::lock_guard<std::recursive_mutex> lock( m_netmap_mutex );
1454
1455 auto it = m_net_name_map.find( aPath );
1456
1457 if( it != m_net_name_map.end() )
1458 {
1459 if( it->second.second == aForceNoConnect )
1460 return it->second.first;
1461 }
1462
1463 wxString name = "Net-(";
1464 bool unconnected = false;
1465
1466 if( aForceNoConnect || GetType() == ELECTRICAL_PINTYPE::PT_NC )
1467 {
1468 unconnected = true;
1469 name = ( "unconnected-(" );
1470 }
1471
1472 bool annotated = true;
1473
1474 std::vector<const SCH_PIN*> pins = symbol->GetPins( &aPath );
1475 bool has_multiple = false;
1476
1477 for( const SCH_PIN* pin : pins )
1478 {
1479 if( pin->GetShownName() == GetShownName()
1480 && pin->GetShownNumber() != GetShownNumber()
1481 && unconnected == ( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC ) )
1482 {
1483 has_multiple = true;
1484 break;
1485 }
1486 }
1487
1488 wxString libPinShownName = m_libPin ? m_libPin->GetShownName() : wxString( "??" );
1489 wxString libPinShownNumber = m_libPin ? m_libPin->GetShownNumber() : wxString( "??" );
1490 wxString effectivePadNumber = m_libPin ? m_libPin->GetEffectivePadNumber() : libPinShownNumber;
1491
1492 if( effectivePadNumber != libPinShownNumber )
1493 {
1494 wxLogTrace( traceStackedPins,
1495 wxString::Format( "GetDefaultNetName: stacked pin shown='%s' -> using smallest logical='%s'",
1496 libPinShownNumber, effectivePadNumber ) );
1497 }
1498
1499 // Use timestamp for unannotated symbols
1500 if( symbol->GetRef( &aPath, false ).Last() == '?' )
1501 {
1503
1504 wxString libPinNumber = m_libPin ? m_libPin->GetNumber() : wxString( "??" );
1505 // Apply same smallest-logical substitution for unannotated symbols
1506 if( effectivePadNumber != libPinShownNumber && !effectivePadNumber.IsEmpty() )
1507 libPinNumber = effectivePadNumber;
1508
1509 name << "-Pad" << libPinNumber << ")";
1510 annotated = false;
1511 }
1512 else if( !libPinShownName.IsEmpty() && ( libPinShownName != libPinShownNumber ) )
1513 {
1514 // Pin names might not be unique between different units so we must have the
1515 // unit token in the reference designator
1516 name << symbol->GetRef( &aPath, true );
1517 name << "-" << EscapeString( libPinShownName, CTX_NETNAME );
1518
1519 if( unconnected || has_multiple )
1520 {
1521 // Use effective (possibly de-stacked) pad number in net name
1522 name << "-Pad" << EscapeString( effectivePadNumber, CTX_NETNAME );
1523 }
1524
1525 name << ")";
1526 }
1527 else
1528 {
1529 // Pin numbers are unique, so we skip the unit token
1530 name << symbol->GetRef( &aPath, false );
1531 name << "-Pad" << EscapeString( effectivePadNumber, CTX_NETNAME ) << ")";
1532 }
1533
1534 if( annotated )
1535 m_net_name_map[ aPath ] = std::make_pair( name, aForceNoConnect );
1536
1537 return name;
1538}
1539
1540
1542{
1543 return GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE );
1544}
1545
1546
1552
1553
1554void SCH_PIN::validateExtentsCache( KIFONT::FONT* aFont, int aSize, const wxString& aText,
1555 EXTENTS_CACHE* aCache ) const
1556{
1557 if( aCache->m_Font == aFont
1558 && aCache->m_FontSize == aSize
1559 && aCache->m_Extents != VECTOR2I() )
1560 {
1561 return;
1562 }
1563
1564 aCache->m_Font = aFont;
1565 aCache->m_FontSize = aSize;
1566
1567 VECTOR2D fontSize( aSize, aSize );
1568 int penWidth = GetPenSizeForNormal( aSize );
1569
1570 aCache->m_Extents = aFont->StringBoundaryLimits( aText, fontSize, penWidth, false, false,
1571 GetFontMetrics() );
1572}
1573
1574
1575BOX2I SCH_PIN::GetBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber,
1576 bool aIncludeElectricalType ) const
1577{
1578 // Just defer to the cache
1579 return m_layoutCache->GetPinBoundingBox( aIncludeLabelsOnInvisiblePins, aIncludeNameAndNumber,
1580 aIncludeElectricalType );
1581}
1582
1583
1585 const SCH_SHEET_PATH* aInstance ) const
1586{
1587 // Do not compare to ourself.
1588 if( aItem == this )
1589 return false;
1590
1591 const SCH_PIN* pin = dynamic_cast<const SCH_PIN*>( aItem );
1592
1593 // Don't compare against a different SCH_ITEM.
1594 wxCHECK( pin, false );
1595
1596 if( GetPosition() != pin->GetPosition() )
1597 return true;
1598
1599 if( GetNumber() != pin->GetNumber() )
1600 return true;
1601
1602 if( GetName() != pin->GetName() )
1603 return true;
1604
1605 // For power input pins, visibility changes affect IsGlobalPower() which changes
1606 // connectivity semantics. Hidden power pins create implicit global net connections.
1607 // Also check if a pin changed type to/from PT_POWER_IN.
1609 {
1610 if( IsVisible() != pin->IsVisible() || GetType() != pin->GetType() )
1611 return true;
1612 }
1613
1614 return false;
1615}
1616
1617
1619{
1621}
1622
1623
1625{
1626 if( m_libPin )
1627 return m_libPin->GetMenuImage();
1628
1630}
1631
1632
1633wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, ALT* aAlt ) const
1634{
1635 return getItemDescription( aAlt );
1636}
1637
1638
1639wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
1640{
1641 if( m_libPin )
1642 {
1643 SCH_PIN::ALT localStorage;
1644 SCH_PIN::ALT* alt = nullptr;
1645
1646 if( !m_alt.IsEmpty() )
1647 {
1648 localStorage = m_libPin->GetAlt( m_alt );
1649 alt = &localStorage;
1650 }
1651
1652 wxString itemDesc = m_libPin ? m_libPin->GetItemDescription( aUnitsProvider, alt )
1653 : wxString( wxS( "Undefined library pin." ) );
1654
1655 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( GetParentSymbol() );
1656
1657 return wxString::Format( "Symbol %s %s",
1659 itemDesc );
1660 }
1661
1662 return getItemDescription( nullptr );
1663}
1664
1665
1666wxString SCH_PIN::getItemDescription( ALT* aAlt ) const
1667{
1668 wxString name = UnescapeString( aAlt ? aAlt->m_Name : GetShownName() );
1669 wxString electricalTypeName = ElectricalPinTypeGetText( aAlt ? aAlt->m_Type : m_type );
1670 wxString pinShapeName = PinShapeGetText( aAlt ? aAlt->m_Shape : m_shape );
1671
1672 if( IsVisible() )
1673 {
1674 if ( !name.IsEmpty() )
1675 {
1676 return wxString::Format( _( "Pin %s [%s, %s, %s]" ),
1678 name,
1679 electricalTypeName,
1680 pinShapeName );
1681 }
1682 else
1683 {
1684 return wxString::Format( _( "Pin %s [%s, %s]" ),
1686 electricalTypeName,
1687 pinShapeName );
1688 }
1689 }
1690 else
1691 {
1692 if( !name.IsEmpty() )
1693 {
1694 return wxString::Format( _( "Hidden pin %s [%s, %s, %s]" ),
1696 name,
1697 electricalTypeName,
1698 pinShapeName );
1699 }
1700 else
1701 {
1702 return wxString::Format( _( "Hidden pin %s [%s, %s]" ),
1704 electricalTypeName,
1705 pinShapeName );
1706 }
1707 }
1708}
1709
1710
1711int SCH_PIN::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
1712{
1713 // Ignore the UUID here
1714 // And the position, which we'll do after the number.
1715 int retv = SCH_ITEM::compare( aOther, aCompareFlags | SCH_ITEM::COMPARE_FLAGS::EQUALITY
1717
1718 if( retv )
1719 return retv;
1720
1721 const SCH_PIN* tmp = static_cast<const SCH_PIN*>( &aOther );
1722
1723 wxCHECK( tmp, -1 );
1724
1725 if( m_number != tmp->m_number )
1726 {
1727 // StrNumCmp: sort the same as the pads in the footprint file
1728 return StrNumCmp( m_number, tmp->m_number );
1729 }
1730
1731 if( m_position.x != tmp->m_position.x )
1732 return m_position.x - tmp->m_position.x;
1733
1734 if( m_position.y != tmp->m_position.y )
1735 return m_position.y - tmp->m_position.y;
1736
1737 if( dynamic_cast<const SCH_SYMBOL*>( GetParentSymbol() ) )
1738 {
1739 if( ( m_libPin == nullptr ) || ( tmp->m_libPin == nullptr ) )
1740 return -1;
1741
1742 retv = m_libPin->compare( *tmp->m_libPin );
1743
1744 if( retv )
1745 return retv;
1746
1747 retv = m_alt.Cmp( tmp->m_alt );
1748
1749 if( retv )
1750 return retv;
1751 }
1752
1753 if( dynamic_cast<const LIB_SYMBOL*>( GetParentSymbol() ) )
1754 {
1755 if( m_length != tmp->m_length )
1756 return m_length.value_or( 0 ) - tmp->m_length.value_or( 0 );
1757
1758 if( m_orientation != tmp->m_orientation )
1759 return static_cast<int>( m_orientation ) - static_cast<int>( tmp->m_orientation );
1760
1761 if( m_shape != tmp->m_shape )
1762 return static_cast<int>( m_shape ) - static_cast<int>( tmp->m_shape );
1763
1764 if( m_type != tmp->m_type )
1765 return static_cast<int>( m_type ) - static_cast<int>( tmp->m_type );
1766
1767 if( m_hidden != tmp->m_hidden )
1768 return m_hidden.value_or( false ) - tmp->m_hidden.value_or( false );
1769
1770 if( m_numTextSize != tmp->m_numTextSize )
1771 return m_numTextSize.value_or( 0 ) - tmp->m_numTextSize.value_or( 0 );
1772
1773 if( m_nameTextSize != tmp->m_nameTextSize )
1774 return m_nameTextSize.value_or( 0 ) - tmp->m_nameTextSize.value_or( 0 );
1775
1776 if( m_alternates.size() != tmp->m_alternates.size() )
1777 return static_cast<int>( m_alternates.size() - tmp->m_alternates.size() );
1778
1779 auto lhsItem = m_alternates.begin();
1780 auto rhsItem = tmp->m_alternates.begin();
1781
1782 while( lhsItem != m_alternates.end() )
1783 {
1784 const ALT& lhsAlt = lhsItem->second;
1785 const ALT& rhsAlt = rhsItem->second;
1786
1787 retv = lhsAlt.m_Name.Cmp( rhsAlt.m_Name );
1788
1789 if( retv )
1790 return retv;
1791
1792 if( lhsAlt.m_Type != rhsAlt.m_Type )
1793 return static_cast<int>( lhsAlt.m_Type ) - static_cast<int>( rhsAlt.m_Type );
1794
1795 if( lhsAlt.m_Shape != rhsAlt.m_Shape )
1796 return static_cast<int>( lhsAlt.m_Shape ) - static_cast<int>( rhsAlt.m_Shape );
1797
1798 ++lhsItem;
1799 ++rhsItem;
1800 }
1801 }
1802
1803 return 0;
1804}
1805
1806
1807double SCH_PIN::Similarity( const SCH_ITEM& aOther ) const
1808{
1809 if( aOther.m_Uuid == m_Uuid )
1810 return 1.0;
1811
1812 if( aOther.Type() != SCH_PIN_T )
1813 return 0.0;
1814
1815 const SCH_PIN* other = static_cast<const SCH_PIN*>( &aOther );
1816
1817 if( m_libPin )
1818 {
1819 if( m_number != other->m_number )
1820 return 0.0;
1821
1822 if( m_position != other->m_position )
1823 return 0.0;
1824
1825 return m_libPin->Similarity( *other->m_libPin );
1826 }
1827
1828 double similarity = SimilarityBase( aOther );
1829
1830 if( m_name != other->m_name )
1831 similarity *= 0.9;
1832
1833 if( m_number != other->m_number )
1834 similarity *= 0.9;
1835
1836 if( m_position != other->m_position )
1837 similarity *= 0.9;
1838
1839 if( m_length != other->m_length )
1840 similarity *= 0.9;
1841
1842 if( m_orientation != other->m_orientation )
1843 similarity *= 0.9;
1844
1845 if( m_shape != other->m_shape )
1846 similarity *= 0.9;
1847
1848 if( m_type != other->m_type )
1849 similarity *= 0.9;
1850
1851 if( m_hidden != other->m_hidden )
1852 similarity *= 0.9;
1853
1854 if( m_numTextSize != other->m_numTextSize )
1855 similarity *= 0.9;
1856
1857 if( m_nameTextSize != other->m_nameTextSize )
1858 similarity *= 0.9;
1859
1860 if( m_alternates.size() != other->m_alternates.size() )
1861 similarity *= 0.9;
1862
1863 return similarity;
1864}
1865
1866
1867std::ostream& SCH_PIN::operator<<( std::ostream& aStream )
1868{
1869 aStream << "SCH_PIN:" << std::endl
1870 << " Name: \"" << m_name << "\"" << std::endl
1871 << " Number: \"" << m_number << "\"" << std::endl
1872 << " Position: " << m_position << std::endl
1873 << " Length: " << GetLength() << std::endl
1874 << " Orientation: " << PinOrientationName( m_orientation ) << std::endl
1875 << " Shape: " << PinShapeGetText( m_shape ) << std::endl
1876 << " Type: " << ElectricalPinTypeGetText( m_type ) << std::endl
1877 << " Name Text Size: " << GetNameTextSize() << std::endl
1878 << " Number Text Size: " << GetNumberTextSize() << std::endl;
1879
1880 return aStream;
1881}
1882
1883
1884#if defined(DEBUG)
1885
1886void SCH_PIN::Show( int nestLevel, std::ostream& os ) const
1887{
1888 NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
1889 << " num=\"" << m_number.mb_str()
1890 << '"' << "/>\n";
1891}
1892
1893#endif
1894
1895
1896void SCH_PIN::CalcEdit( const VECTOR2I& aPosition )
1897{
1898 if( IsMoving() )
1899 SetPosition( aPosition );
1900}
1901
1902
1903static struct SCH_PIN_DESC
1904{
1906 {
1907 auto& pinTypeEnum = ENUM_MAP<ELECTRICAL_PINTYPE>::Instance();
1908
1909 if( pinTypeEnum.Choices().GetCount() == 0 )
1910 {
1911 pinTypeEnum.Map( ELECTRICAL_PINTYPE::PT_INPUT, _HKI( "Input" ) )
1912 .Map( ELECTRICAL_PINTYPE::PT_OUTPUT, _HKI( "Output" ) )
1913 .Map( ELECTRICAL_PINTYPE::PT_BIDI, _HKI( "Bidirectional" ) )
1914 .Map( ELECTRICAL_PINTYPE::PT_TRISTATE, _HKI( "Tri-state" ) )
1915 .Map( ELECTRICAL_PINTYPE::PT_PASSIVE, _HKI( "Passive" ) )
1916 .Map( ELECTRICAL_PINTYPE::PT_NIC, _HKI( "Free" ) )
1917 .Map( ELECTRICAL_PINTYPE::PT_UNSPECIFIED, _HKI( "Unspecified" ) )
1918 .Map( ELECTRICAL_PINTYPE::PT_POWER_IN, _HKI( "Power input" ) )
1919 .Map( ELECTRICAL_PINTYPE::PT_POWER_OUT, _HKI( "Power output" ) )
1920 .Map( ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR, _HKI( "Open collector" ) )
1921 .Map( ELECTRICAL_PINTYPE::PT_OPENEMITTER, _HKI( "Open emitter" ) )
1922 .Map( ELECTRICAL_PINTYPE::PT_NC, _HKI( "Unconnected" ) );
1923 }
1924
1925 auto& pinShapeEnum = ENUM_MAP<GRAPHIC_PINSHAPE>::Instance();
1926
1927 if( pinShapeEnum.Choices().GetCount() == 0 )
1928 {
1929 pinShapeEnum.Map( GRAPHIC_PINSHAPE::LINE, _HKI( "Line" ) )
1930 .Map( GRAPHIC_PINSHAPE::INVERTED, _HKI( "Inverted" ) )
1931 .Map( GRAPHIC_PINSHAPE::CLOCK, _HKI( "Clock" ) )
1932 .Map( GRAPHIC_PINSHAPE::INVERTED_CLOCK, _HKI( "Inverted clock" ) )
1933 .Map( GRAPHIC_PINSHAPE::INPUT_LOW, _HKI( "Input low" ) )
1934 .Map( GRAPHIC_PINSHAPE::CLOCK_LOW, _HKI( "Clock low" ) )
1935 .Map( GRAPHIC_PINSHAPE::OUTPUT_LOW, _HKI( "Output low" ) )
1936 .Map( GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK, _HKI( "Falling edge clock" ) )
1937 .Map( GRAPHIC_PINSHAPE::NONLOGIC, _HKI( "NonLogic" ) );
1938 }
1939
1940 auto& orientationEnum = ENUM_MAP<PIN_ORIENTATION>::Instance();
1941
1942 if( orientationEnum.Choices().GetCount() == 0 )
1943 {
1944 orientationEnum.Map( PIN_ORIENTATION::PIN_RIGHT, _HKI( "Right" ) )
1945 .Map( PIN_ORIENTATION::PIN_LEFT, _HKI( "Left" ) )
1946 .Map( PIN_ORIENTATION::PIN_UP, _HKI( "Up" ) )
1947 .Map( PIN_ORIENTATION::PIN_DOWN, _HKI( "Down" ) );
1948 }
1949
1950 auto isSymbolEditor =
1951 []( INSPECTABLE* aItem ) -> bool
1952 {
1953 if( SCH_PIN* pin = dynamic_cast<SCH_PIN*>( aItem ) )
1954 return dynamic_cast<LIB_SYMBOL*>( pin->GetParentSymbol() ) != nullptr;
1955
1956 return false;
1957 };
1958
1963
1964 propMgr.AddProperty( new PROPERTY<SCH_PIN, wxString>( _HKI( "Pin Name" ),
1966 .SetWriteableFunc( isSymbolEditor );
1967
1968 propMgr.AddProperty( new PROPERTY<SCH_PIN, wxString>( _HKI( "Pin Number" ),
1970 .SetWriteableFunc( isSymbolEditor );
1971
1972 propMgr.AddProperty( new PROPERTY_ENUM<SCH_PIN, ELECTRICAL_PINTYPE>( _HKI( "Electrical Type" ),
1974 .SetWriteableFunc( isSymbolEditor );
1975
1976 propMgr.AddProperty( new PROPERTY_ENUM<SCH_PIN, GRAPHIC_PINSHAPE>( _HKI( "Graphic Style" ),
1978 .SetWriteableFunc( isSymbolEditor );
1979
1980 propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Position X" ),
1982 .SetAvailableFunc( isSymbolEditor );
1983
1984 propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Position Y" ),
1986 .SetAvailableFunc( isSymbolEditor );
1987
1988 propMgr.AddProperty( new PROPERTY_ENUM<SCH_PIN, PIN_ORIENTATION>( _HKI( "Orientation" ),
1990 .SetWriteableFunc( isSymbolEditor );
1991
1992 propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Length" ),
1995 .SetWriteableFunc( isSymbolEditor );
1996
1997 propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Name Text Size" ),
2000 .SetAvailableFunc( isSymbolEditor );
2001
2002 propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Number Text Size" ),
2005 .SetAvailableFunc( isSymbolEditor );
2006
2007 propMgr.AddProperty( new PROPERTY<SCH_PIN, bool>( _HKI( "Visible" ),
2009 .SetAvailableFunc( isSymbolEditor );
2010
2011 }
2013
2014
const char * name
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:114
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
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
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:168
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition box2.h:311
static const COLOR4D WHITE
Definition color4d.h:405
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:402
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:522
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:111
EDA_ITEM_FLAGS m_flags
Definition eda_item.h:533
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:407
EDA_ITEM * GetParent() const
Definition eda_item.h:113
EDA_ITEM * m_parent
Owner.
Definition eda_item.h:534
static bool Replace(const EDA_SEARCH_DATA &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
Definition eda_item.cpp:246
bool IsMoving() const
Definition eda_item.h:126
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:41
static ENUM_MAP< T > & Instance()
Definition property.h:721
Class that other classes need to inherit from, in order to be inspectable.
Definition inspectable.h:38
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:98
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
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:451
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
std::shared_ptr< wxString > m_text
Definition color4d.h:399
COLOR4D & Desaturate()
Removes color (in HSL model)
Definition color4d.cpp:532
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition color4d.h:296
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
Definition kiid.h:49
wxString AsString() const
Definition kiid.cpp:244
Define a library symbol object.
Definition lib_symbol.h:83
Definition line.h:36
A pin layout helper is a class that manages the layout of the parts of a pin on a schematic symbol:
Base plotter engine class.
Definition plotter.h:136
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width)=0
void MoveTo(const VECTOR2I &pos)
Definition plotter.h:308
void FinishTo(const VECTOR2I &pos)
Definition plotter.h:318
RENDER_SETTINGS * RenderSettings()
Definition plotter.h:167
bool GetColorMode() const
Definition plotter.h:164
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
void LineTo(const VECTOR2I &pos)
Definition plotter.h:313
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
Definition plotter.cpp:696
virtual void SetColor(const COLOR4D &color)=0
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Definition property.h:262
PROPERTY_BASE & SetWriteableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Definition property.h:287
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString GetNetName() const
void AppendInfoToMsgPanel(std::vector< MSG_PANEL_ITEM > &aList) const
Adds information about the connection object to aList.
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:116
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition sch_item.cpp:803
int m_unit
Definition sch_item.h:779
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition sch_item.cpp:80
int m_bodyStyle
Definition sch_item.h:780
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition sch_item.h:727
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:260
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:254
int GetBodyStyle() const
Definition sch_item.h:248
friend class LIB_SYMBOL
Definition sch_item.h:798
@ SKIP_TST_POS
Definition sch_item.h:710
int GetUnit() const
Definition sch_item.h:239
virtual int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const
Provide the draw object specific comparison called by the == and < operators.
Definition sch_item.cpp:698
bool IsConnectivityDirty() const
Definition sch_item.h:588
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:56
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition sch_item.cpp:473
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
Definition sch_item.cpp:363
const KIFONT::METRICS & GetFontMetrics() const
Definition sch_item.cpp:759
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition sch_item.cpp:768
SCH_LAYER_ID m_layer
Definition sch_item.h:778
double SimilarityBase(const SCH_ITEM &aItem) const
Calculate the boilerplate similarity for all LIB_ITEMs without preventing the use above of a pure vir...
Definition sch_item.h:380
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition sch_pin.cpp:1345
std::ostream & operator<<(std::ostream &aStream)
Definition sch_pin.cpp:1867
void SetAlt(const wxString &aAlt)
Set the name of the alternate pin.
Definition sch_pin.cpp:437
void PlotPinTexts(PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient, int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed) const
Plot the pin name and number.
Definition sch_pin.cpp:879
int GetNumberTextSize() const
Definition sch_pin.cpp:681
int GetLength() const
Definition sch_pin.cpp:301
std::optional< bool > m_hidden
Definition sch_pin.h:399
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition sch_pin.cpp:503
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition sch_pin.cpp:1373
std::unique_ptr< PIN_LAYOUT_CACHE > m_layoutCache
The layout cache for this pin.
Definition sch_pin.h:415
void MirrorVerticallyPin(int aCenter)
Definition sch_pin.cpp:1294
void validateExtentsCache(KIFONT::FONT *aFont, int aSize, const wxString &aText, EXTENTS_CACHE *aCache) const
Definition sch_pin.cpp:1554
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition sch_pin.cpp:1541
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition sch_pin.cpp:1547
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition sch_pin.cpp:1896
void SetNumber(const wxString &aNumber)
Definition sch_pin.cpp:644
std::optional< int > m_nameTextSize
Definition sch_pin.h:403
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:1196
void SetVisible(bool aVisible)
Definition sch_pin.h:114
int GetX() const
Definition sch_pin.h:254
void ChangeLength(int aLength)
Change the length of a pin and adjust its position based on orientation.
Definition sch_pin.cpp:1240
void SetX(int aX)
Definition sch_pin.h:255
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
Definition sch_pin.cpp:1584
SCH_PIN & operator=(const SCH_PIN &aPin)
Definition sch_pin.cpp:235
SCH_PIN * m_libPin
Definition sch_pin.h:388
std::optional< wxString > GetSmallestLogicalNumber() const
Return the smallest logical pin number if this pin uses stacked notation and it is valid.
Definition sch_pin.cpp:623
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
Definition sch_pin.cpp:1268
std::map< const SCH_SHEET_PATH, std::pair< wxString, bool > > m_net_name_map
Definition sch_pin.h:419
PIN_ORIENTATION m_orientation
Definition sch_pin.h:396
void SetOrientation(PIN_ORIENTATION aOrientation)
Definition sch_pin.h:93
void SetName(const wxString &aName)
Definition sch_pin.cpp:423
bool IsGlobalPower() const
Return whether this pin forms a global power connection: i.e., is part of a power symbol and of type ...
Definition sch_pin.cpp:359
wxString getItemDescription(ALT *aAlt) const
Definition sch_pin.cpp:1666
bool IsVisible() const
Definition sch_pin.cpp:391
bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Return true if this item should propagate connection info to aItem.
Definition sch_pin.cpp:1618
std::optional< int > m_numTextSize
Definition sch_pin.h:402
VECTOR2I GetPinRoot() const
Definition sch_pin.cpp:705
bool IsLocalPower() const
Local power pin is the same except that it is sheet-local and it does not support the legacy hidden p...
Definition sch_pin.cpp:378
ELECTRICAL_PINTYPE m_type
Definition sch_pin.h:398
wxString GetEffectivePadNumber() const
Return the pin number to be used for deterministic operations such as auto‑generated net names.
Definition sch_pin.cpp:635
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition sch_pin.cpp:1307
SCH_PIN * GetLibPin() const
Definition sch_pin.h:89
void SetPosition(const VECTOR2I &aPos) override
Definition sch_pin.h:251
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition sch_pin.cpp:1807
bool m_isDangling
Definition sch_pin.h:408
void SetIsDangling(bool aIsDangling)
Definition sch_pin.cpp:474
wxString GetElectricalTypeName() const
Definition sch_pin.cpp:352
std::vector< wxString > GetStackedPinNumbers(bool *aValid=nullptr) const
Definition sch_pin.cpp:598
std::map< wxString, ALT > m_alternates
Definition sch_pin.h:391
const wxString & GetName() const
Definition sch_pin.cpp:405
int GetStackedPinCount(bool *aValid=nullptr) const
Return the count of logical pins represented by this pin's stacked notation.
Definition sch_pin.cpp:616
bool IsDangling() const override
Definition sch_pin.cpp:465
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
Definition sch_pin.cpp:1352
void MirrorHorizontally(int aCenter) override
These transforms have effect only if the pin has a LIB_SYMBOL as parent.
Definition sch_pin.cpp:1287
std::recursive_mutex m_netmap_mutex
The name that this pin connection will drive onto a net.
Definition sch_pin.h:418
PIN_ORIENTATION GetOrientation() const
Definition sch_pin.cpp:266
wxString GetClass() const override
Return the class name.
Definition sch_pin.h:74
void SetNumberTextSize(int aSize)
Definition sch_pin.cpp:695
void SetShape(GRAPHIC_PINSHAPE aShape)
Definition sch_pin.h:96
void RotatePin(const VECTOR2I &aCenter, bool aRotateCCW=true)
Definition sch_pin.cpp:1314
VECTOR2I GetPosition() const override
Definition sch_pin.cpp:258
wxString GetCanonicalElectricalTypeName() const
Definition sch_pin.cpp:345
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
Definition sch_pin.cpp:530
int GetNameTextSize() const
Definition sch_pin.cpp:657
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition sch_pin.cpp:1639
VECTOR2I m_position
Definition sch_pin.h:394
GRAPHIC_PINSHAPE m_shape
Definition sch_pin.h:397
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
The pin specific sort order is as follows:
Definition sch_pin.cpp:1711
const wxString & GetShownName() const
Definition sch_pin.cpp:581
void MirrorHorizontallyPin(int aCenter)
These transforms have always effects.
Definition sch_pin.cpp:1274
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition sch_pin.cpp:551
wxString m_name
Definition sch_pin.h:400
wxString m_alt
Definition sch_pin.h:404
void SetType(ELECTRICAL_PINTYPE aType)
Definition sch_pin.cpp:335
const wxString & GetBaseName() const
Get the name without any alternates.
Definition sch_pin.cpp:414
void ClearDefaultNetName(const SCH_SHEET_PATH *aPath)
Definition sch_pin.cpp:1420
void SetY(int aY)
Definition sch_pin.h:257
SCH_PIN(LIB_SYMBOL *aParentSymbol)
Definition sch_pin.cpp:120
const wxString & GetShownNumber() const
Definition sch_pin.cpp:592
bool IsStacked(const SCH_PIN *aPin) const
Definition sch_pin.cpp:480
const wxString & GetNumber() const
Definition sch_pin.h:124
wxString m_number
Definition sch_pin.h:401
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_pin.cpp:1231
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition sch_pin.h:215
wxString GetDefaultNetName(const SCH_SHEET_PATH &aPath, bool aForceNoConnect=false)
Definition sch_pin.cpp:1431
std::optional< int > m_length
Definition sch_pin.h:395
GRAPHIC_PINSHAPE GetShape() const
Definition sch_pin.cpp:280
void PlotPinType(PLOTTER *aPlotter, const VECTOR2I &aPosition, PIN_ORIENTATION aOrientation, bool aDimmed) const
Definition sch_pin.cpp:728
int GetY() const
Definition sch_pin.h:256
bool IsPower() const
Check if the pin is either a global or local power pin.
Definition sch_pin.cpp:385
ELECTRICAL_PINTYPE GetType() const
Definition sch_pin.cpp:315
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition sch_pin.cpp:1624
void SetNameTextSize(int aSize)
Definition sch_pin.cpp:671
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition sch_symbol.h:76
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const override
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition symbol.h:63
virtual bool IsGlobalPower() const =0
virtual bool IsLocalPower() const =0
virtual const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const =0
int GetPinNameOffset() const
Definition symbol.h:163
virtual bool GetShowPinNames() const
Definition symbol.h:169
virtual bool GetShowPinNumbers() const
Definition symbol.h:175
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
for transforming drawing coordinates for a wxDC device context.
Definition transform.h:46
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition transform.cpp:44
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
#define DEFAULT_PINNUM_SIZE
The default pin name size when creating pins(can be changed in preference menu)
#define DEFAULT_PINNAME_SIZE
The default selection highlight thickness (can be changed in preference menu)
#define DEFAULT_PIN_LENGTH
The default pin number size when creating pins(can be changed in preference menu)
#define _(s)
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
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define SHOW_ELEC_TYPE
Show pin electrical type.
@ NO_FILL
Definition eda_shape.h:57
int GetPenSizeForNormal(int aTextSize)
Definition gr_text.cpp:61
const wxChar *const traceStackedPins
Flag to enable debug output for stacked pins handling in symbol/pin code.
@ LAYER_DANGLING
Definition layer_ids.h:477
@ LAYER_PINNUM
Definition layer_ids.h:458
@ LAYER_DEVICE
Definition layer_ids.h:466
@ LAYER_PINNAM
Definition layer_ids.h:459
@ LAYER_PIN
Definition layer_ids.h:470
@ LAYER_OP_CURRENTS
Definition layer_ids.h:502
@ LAYER_SELECTION_SHADOWS
Definition layer_ids.h:495
STL namespace.
#define _HKI(x)
Definition page_info.cpp:44
see class PGM_BASE
static int externalPinDecoSize(const SCHEMATIC_SETTINGS *aSettings, const SCH_PIN &aPin)
static int internalPinDecoSize(const SCHEMATIC_SETTINGS *aSettings, const SCH_PIN &aPin)
wxString FormatStackedPinForDisplay(const wxString &aPinNumber, int aPinLength, int aTextSize, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics)
Definition sch_pin.cpp:45
wxString PinShapeGetText(GRAPHIC_PINSHAPE shape)
Definition pin_type.cpp:235
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition pin_type.h:36
@ PT_INPUT
usual pin input: must be connected
Definition pin_type.h:37
@ PT_NC
not connected (must be left open)
Definition pin_type.h:50
@ PT_OUTPUT
usual output
Definition pin_type.h:38
@ PT_TRISTATE
tri state bus pin
Definition pin_type.h:40
@ PT_NIC
not internally connected (may be connected to anything)
Definition pin_type.h:44
@ PT_BIDI
input or output (like port for a microprocessor)
Definition pin_type.h:39
@ PT_OPENEMITTER
pin type open emitter
Definition pin_type.h:49
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
Definition pin_type.h:47
@ PT_OPENCOLLECTOR
pin type open collector
Definition pin_type.h:48
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
Definition pin_type.h:46
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
Definition pin_type.h:45
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
Definition pin_type.h:43
BITMAPS ElectricalPinTypeGetBitmap(ELECTRICAL_PINTYPE)
Definition pin_type.cpp:221
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE)
Definition pin_type.cpp:207
wxString PinOrientationName(PIN_ORIENTATION aOrientation)
Definition pin_type.cpp:263
PIN_ORIENTATION
The symbol library pin object orientations.
Definition pin_type.h:105
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
Definition pin_type.h:127
@ PIN_RIGHT
The pin extends rightwards from the connection point.
Definition pin_type.h:111
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
Definition pin_type.h:118
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
Definition pin_type.h:135
GRAPHIC_PINSHAPE
Definition pin_type.h:84
#define TYPE_HASH(x)
Definition property.h:74
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
Definition property.h:823
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
Definition property.h:65
@ PT_SIZE
Size expressed in distance units (mm/inch)
Definition property.h:63
#define REGISTER_TYPE(x)
wxString FormatStackedPinForDisplay(const wxString &aPinNumber, int aPinLength, int aTextSize, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics)
Definition sch_pin.cpp:45
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:109
#define PIN_TEXT_MARGIN
Definition sch_pin.cpp:90
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:95
static struct SCH_PIN_DESC _SCH_PIN_DESC
#define TARGET_PIN_RADIUS
Definition sch_pin.h:37
T * GetAppSettings(const char *aFilename)
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
std::vector< wxString > ExpandStackedPinNotation(const wxString &aPinName, bool *aValid)
Expand stacked pin notation like [1,2,3], [1-4], [A1-A4], or [AA1-AA3,AB4,CD12-CD14] into individual ...
wxString UnescapeString(const wxString &aSource)
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
int CountStackedPinNotation(const wxString &aPinName, bool *aValid)
Count the number of pins represented by stacked pin notation without allocating strings.
@ CTX_NETNAME
wxString m_Name
Definition sch_pin.h:45
GRAPHIC_PINSHAPE m_Shape
Definition sch_pin.h:46
ELECTRICAL_PINTYPE m_Type
Definition sch_pin.h:47
KIFONT::FONT * m_Font
Definition sch_pin.h:358
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
KIBIS top(path, &reporter)
KIBIS_PIN * pin
int radius
VECTOR2I end
wxString result
Test unit parsing edge cases and error handling.
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
wxLogTrace helper definitions.
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
@ SCH_PIN_T
Definition typeinfo.h:157
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
VECTOR2< double > VECTOR2D
Definition vector2d.h:694