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 <api/api_enums.h>
31#include <api/api_utils.h>
32#include <base_units.h>
33#include <pgm_base.h>
34#include <pin_layout_cache.h>
35#include <plotters/plotter.h>
36#include <sch_draw_panel.h>
37#include <sch_edit_frame.h>
38#include <symbol_edit_frame.h>
41#include <trace_helpers.h>
42#include <trigo.h>
43#include <string_utils.h>
44#include <properties/property.h>
46#include <api/schematic/schematic_types.pb.h>
47
48wxString FormatStackedPinForDisplay( const wxString& aPinNumber, int aPinLength, int aTextSize, KIFONT::FONT* aFont,
49 const KIFONT::METRICS& aFontMetrics )
50{
51 // Check if this is stacked pin notation: [A,B,C]
52 if( !aPinNumber.StartsWith( "[" ) || !aPinNumber.EndsWith( "]" ) )
53 return aPinNumber;
54
55 const int minPinTextWidth = schIUScale.MilsToIU( 50 );
56 const int maxPinTextWidth = std::max( aPinLength, minPinTextWidth );
57
58 VECTOR2D fontSize( aTextSize, aTextSize );
59 int penWidth = GetPenSizeForNormal( aTextSize );
60 VECTOR2I textExtents = aFont->StringBoundaryLimits( aPinNumber, fontSize, penWidth, false, false, aFontMetrics );
61
62 if( textExtents.x <= maxPinTextWidth )
63 return aPinNumber; // Fits already
64
65 // Strip brackets and split by comma
66 wxString inner = aPinNumber.Mid( 1, aPinNumber.Length() - 2 );
67 wxArrayString parts;
68 wxStringSplit( inner, parts, ',' );
69
70 if( parts.empty() )
71 return aPinNumber; // malformed; fallback
72
73 // Build multi-line representation inside braces, each line trimmed
74 wxString result = "[";
75
76 for( size_t i = 0; i < parts.size(); ++i )
77 {
78 wxString line = parts[i];
79 line.Trim( true ).Trim( false );
80
81 if( i > 0 )
82 result += "\n";
83
84 result += line;
85 }
86
87 result += "]";
88 return result;
89}
90
91
92// small margin in internal units between the pin text and the pin line
93#define PIN_TEXT_MARGIN 4
94
98static int internalPinDecoSize( const RENDER_SETTINGS* aSettings, const SCH_PIN &aPin )
99{
100 const SCH_RENDER_SETTINGS* settings = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
101
102 if( settings && settings->m_PinSymbolSize )
103 return settings->m_PinSymbolSize;
104
105 return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
106}
107
108
112static int externalPinDecoSize( const RENDER_SETTINGS* aSettings, const SCH_PIN &aPin )
113{
114 const SCH_RENDER_SETTINGS* settings = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
115
116 if( settings && settings->m_PinSymbolSize )
117 return settings->m_PinSymbolSize;
118
119 return aPin.GetNumberTextSize() / 2;
120}
121
122
123SCH_PIN::SCH_PIN( LIB_SYMBOL* aParentSymbol ) :
124 SCH_ITEM( aParentSymbol, SCH_PIN_T, 0, 0 ),
125 m_libPin( nullptr ),
126 m_position( { 0, 0 } ),
127 m_length( schIUScale.MilsToIU( DEFAULT_PIN_LENGTH ) ),
128 m_orientation( PIN_ORIENTATION::PIN_RIGHT ),
129 m_shape( GRAPHIC_PINSHAPE::LINE ),
131 m_hidden( false ),
132 m_numTextSize( schIUScale.MilsToIU( DEFAULT_PINNUM_SIZE ) ),
133 m_nameTextSize( schIUScale.MilsToIU( DEFAULT_PINNAME_SIZE ) ),
134 m_isDangling( true )
135{
137 {
138 m_length = schIUScale.MilsToIU( cfg->m_Defaults.pin_length );
139 m_numTextSize = schIUScale.MilsToIU( cfg->m_Defaults.pin_num_size );
140 m_nameTextSize = schIUScale.MilsToIU( cfg->m_Defaults.pin_name_size );
141 }
142
143 m_layer = LAYER_DEVICE;
144}
145
146
147SCH_PIN::SCH_PIN( LIB_SYMBOL* aParentSymbol, const wxString& aName, const wxString& aNumber,
148 PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength,
149 int aNameTextSize, int aNumTextSize, int aBodyStyle, const VECTOR2I& aPos,
150 int aUnit ) :
151 SCH_ITEM( aParentSymbol, SCH_PIN_T, aUnit, aBodyStyle ),
152 m_libPin( nullptr ),
153 m_position( aPos ),
154 m_length( aLength ),
155 m_orientation( aOrientation ),
157 m_type( aPinType ),
158 m_hidden( false ),
159 m_numTextSize( aNumTextSize ),
160 m_nameTextSize( aNameTextSize ),
161 m_isDangling( true )
162{
163 SetName( aName );
164 SetNumber( aNumber );
165
167}
168
169
170SCH_PIN::SCH_PIN( SCH_SYMBOL* aParentSymbol, SCH_PIN* aLibPin ) :
171 SCH_ITEM( aParentSymbol, SCH_PIN_T, 0, 0 ),
172 m_libPin( aLibPin ),
176 m_isDangling( true )
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{
199 wxASSERT( aParentSymbol );
200
201 const_cast<KIID&>( m_Uuid ) = aUuid;
203}
204
205
206SCH_PIN::SCH_PIN( const SCH_PIN& aPin ) :
207 SCH_ITEM( aPin ),
208 m_libPin( aPin.m_libPin ),
210 m_position( aPin.m_position ),
211 m_length( aPin.m_length ),
213 m_shape( aPin.m_shape ),
214 m_type( aPin.m_type ),
215 m_hidden( aPin.m_hidden ),
218 m_alt( aPin.m_alt ),
220{
221 SetName( aPin.m_name );
222 SetNumber( aPin.m_number );
223
224 m_layer = aPin.m_layer;
225}
226
227
231
232
234{
235 SCH_ITEM::operator=( aPin );
236
237 m_libPin = aPin.m_libPin;
239 m_alt = aPin.m_alt;
240 m_name = aPin.m_name;
241 m_number = aPin.m_number;
242 m_position = aPin.m_position;
243 m_length = aPin.m_length;
245 m_shape = aPin.m_shape;
246 m_type = aPin.m_type;
247 m_hidden = aPin.m_hidden;
251 m_layoutCache.reset();
252
253 return *this;
254}
255
256
257void SCH_PIN::Serialize( google::protobuf::Any& aContainer ) const
258{
259 using namespace kiapi::common;
260 using namespace kiapi::schematic::types;
261 SchematicPin pin;
262
263 pin.mutable_id()->set_value( m_Uuid.AsStdString() );
264 pin.set_name( GetBaseName().ToUTF8() );
265 pin.set_number( GetNumber().ToUTF8() );
266
267 PackVector2( *pin.mutable_position(), GetPosition(), schIUScale );
268 PackDistance( *pin.mutable_length(), GetLength(), schIUScale );
270
273 pin.set_visible( IsVisible() );
274
275 PackDistance( *pin.mutable_name_text_size(), GetNameTextSize(), schIUScale );
276 PackDistance( *pin.mutable_number_text_size(), GetNumberTextSize(), schIUScale );
277
278 for( const ALT& alt : GetAlternates() | std::views::values )
279 {
280 SchematicPinAlternate* altProto = pin.add_alternates();
281 altProto->set_name( alt.m_Name.ToUTF8() );
282 altProto->set_shape( ToProtoEnum<GRAPHIC_PINSHAPE, SchematicPinShape>( alt.m_Shape ) );
283 altProto->set_electrical_type( ToProtoEnum<ELECTRICAL_PINTYPE, types::ElectricalPinType>( alt.m_Type ) );
284 }
285
286 if( !m_alt.IsEmpty() && m_alt != GetBaseName() )
287 pin.set_active_alternate( m_alt.ToUTF8() );
288
289 aContainer.PackFrom( pin );
290}
291
292
293bool SCH_PIN::Deserialize( const google::protobuf::Any& aContainer )
294{
295 using namespace kiapi::common;
296 using namespace kiapi::schematic::types;
297
298 SchematicPin pin;
299
300 if( !aContainer.UnpackTo( &pin ) )
301 return false;
302
303 const_cast<KIID&>( m_Uuid ) = KIID( pin.id().value() );
304 m_name = wxString::FromUTF8( pin.name() );
305 m_number = wxString::FromUTF8( pin.number() );
306
307 SetPosition( UnpackVector2( pin.position(), schIUScale ) );
308 SetLength( UnpackDistance( pin.length(), schIUScale ) );
310
311 m_type = FromProtoEnum<ELECTRICAL_PINTYPE>( pin.electrical_type() );
313 SetVisible( pin.visible() );
314
315 m_nameTextSize = UnpackDistance( pin.name_text_size(), schIUScale );
316 m_numTextSize = UnpackDistance( pin.number_text_size(), schIUScale );
317
318 std::map<wxString, ALT>& alts = GetAlternates();
319
320 for( const SchematicPinAlternate& altProto : pin.alternates() )
321 {
322 ALT alt;
323 alt.m_Name = wxString::FromUTF8( altProto.name() );
324 alt.m_Shape = FromProtoEnum<GRAPHIC_PINSHAPE>( altProto.shape() );
325 alt.m_Type = FromProtoEnum<ELECTRICAL_PINTYPE>( altProto.electrical_type() );
326 alts.emplace( alt.m_Name, alt );
327 }
328
329 if( m_layoutCache )
331
332 return true;
333}
334
335
337{
338 if( const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( GetParentSymbol() ) )
339 return symbol->GetTransform().TransformCoordinate( m_position ) + symbol->GetPosition();
340 else
341 return m_position;
342}
343
345{
347 {
348 if( !m_libPin )
350
351 return m_libPin->GetOrientation();
352 }
353
354 return m_orientation;
355}
356
357
359{
360 if( !m_alt.IsEmpty() )
361 {
362 if( !m_libPin )
364
365 return m_libPin->GetAlt( m_alt ).m_Shape;
366 }
368 {
369 if( !m_libPin )
371
372 return m_libPin->GetShape();
373 }
374
375 return m_shape;
376}
377
378
380{
381 if( !m_length.has_value() )
382 {
383 if( !m_libPin )
384 return 0;
385
386 return m_libPin->GetLength();
387 }
388
389 return m_length.value();
390}
391
392
394{
395 if( !m_alt.IsEmpty() )
396 {
397 if( !m_libPin )
399
400 return m_libPin->GetAlt( m_alt ).m_Type;
401 }
403 {
404 if( !m_libPin )
406
407 return m_libPin->GetType();
408 }
409
410 return m_type;
411}
412
414{
415 if( aType == m_type )
416 return;
417
418 m_type = aType;
419
420 if( m_layoutCache )
422}
423
424
426{
427 // Use GetType() which correctly handles alternates
428 return ::GetCanonicalElectricalTypeName( GetType() );
429}
430
431
433{
434 // Use GetType() which correctly handles alternates
436}
437
438
440{
442 return false;
443
444 const SYMBOL* parent = GetParentSymbol();
445
446 if( parent->IsGlobalPower() )
447 return true;
448
449 // Local power symbols are never global, even with invisible pins
450 if( parent->IsLocalPower() )
451 return false;
452
453 // Legacy support: invisible power-in pins on non-power symbols act as global power
454 return !IsVisible();
455}
456
457
463
464
466{
467 return IsLocalPower() || IsGlobalPower();
468}
469
470
472{
473 if( !m_hidden.has_value() )
474 {
475 if( !m_libPin )
476 return true;
477
478 return m_libPin->IsVisible();
479 }
480
481 return !m_hidden.value();
482}
483
484
485const wxString& SCH_PIN::GetName() const
486{
487 if( !m_alt.IsEmpty() )
488 return m_alt;
489
490 return GetBaseName();
491}
492
493
494const wxString& SCH_PIN::GetBaseName() const
495{
496 if( m_libPin )
497 return m_libPin->GetBaseName();
498
499 return m_name;
500}
501
502
503void SCH_PIN::SetName( const wxString& aName )
504{
505 if( m_name == aName )
506 return;
507
508 m_name = aName;
509
510 // pin name string does not support spaces
511 m_name.Replace( wxT( " " ), wxT( "_" ) );
512
513 if( m_layoutCache )
515}
516
517
518void SCH_PIN::SetAlt( const wxString& aAlt )
519{
520 // Do not set the alternate pin definition to the default pin name. This breaks the library
521 // symbol comparison for the ERC and the library diff tool. It also incorrectly causes the
522 // schematic symbol pin alternate to be set.
523 if( aAlt.IsEmpty() || aAlt == GetBaseName() )
524 {
525 m_alt = wxEmptyString;
526 return;
527 }
528
529 if( !m_libPin )
530 {
531 wxFAIL_MSG( wxString::Format( wxS( "Pin '%s' has no corresponding lib_pin" ), m_number ) );
532 m_alt = wxEmptyString;
533 return;
534 }
535
536 if( !m_libPin->GetAlternates().contains( aAlt ) )
537 {
538 wxFAIL_MSG( wxString::Format( wxS( "Pin '%s' has no alterate '%s'" ), m_number, aAlt ) );
539 m_alt = wxEmptyString;
540 return;
541 }
542
543 m_alt = aAlt;
544}
545
547{
549 return false;
550
551 return m_isDangling;
552}
553
554
555void SCH_PIN::SetIsDangling( bool aIsDangling )
556{
557 m_isDangling = aIsDangling;
558}
559
560
561bool SCH_PIN::IsStacked( const SCH_PIN* aPin ) const
562{
563 const auto isPassiveOrNic = []( ELECTRICAL_PINTYPE t )
564 {
566 };
567
568 const bool sameParent = m_parent == aPin->GetParent();
569 const bool samePos = GetPosition() == aPin->GetPosition();
570 const bool sameName = GetName() == aPin->GetName();
571 const bool typeCompat = GetType() == aPin->GetType()
572 || isPassiveOrNic( GetType() )
573 || isPassiveOrNic( aPin->GetType() );
574
575 wxLogTrace( traceStackedPins,
576 wxString::Format( "IsStacked: this='%s/%s' other='%s/%s' sameParent=%d samePos=%d sameName=%d typeCompat=%d",
577 GetName(), GetNumber(), aPin->GetName(), aPin->GetNumber(), sameParent,
578 samePos, sameName, typeCompat ) );
579
580 return sameParent && samePos && sameName && typeCompat;
581}
582
583
584bool SCH_PIN::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
585{
586 const SCH_SEARCH_DATA& schSearchData =
587 dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData );
588
589 if( schSearchData.searchAllPins
590 && ( EDA_ITEM::Matches( GetName(), aSearchData )
591 || EDA_ITEM::Matches( GetNumber(), aSearchData ) ) )
592 {
593 return true;
594 }
595
596 SCH_CONNECTION* connection = nullptr;
597 SCH_SHEET_PATH* sheetPath = reinterpret_cast<SCH_SHEET_PATH*>( aAuxData );
598
599 if( schSearchData.searchNetNames && sheetPath && ( connection = Connection( sheetPath ) ) )
600 {
601 wxString netName = connection->GetNetName();
602
603 if( EDA_ITEM::Matches( netName, aSearchData ) )
604 return true;
605 }
606
607 return false;
608}
609
610
611bool SCH_PIN::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
612{
613 bool isReplaced = false;
614
615 if( dynamic_cast<LIB_SYMBOL*>( GetParentSymbol() ) )
616 {
617 isReplaced |= EDA_ITEM::Replace( aSearchData, m_name );
618 isReplaced |= EDA_ITEM::Replace( aSearchData, m_number );
619 }
620 else
621 {
622 /* TODO: waiting on a way to override pins in the schematic...
623 isReplaced |= EDA_ITEM::Replace( aSearchData, m_name );
624 isReplaced |= EDA_ITEM::Replace( aSearchData, m_number );
625 */
626 }
627
628 return isReplaced;
629}
630
631
632bool SCH_PIN::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
633{
634 // When looking for an "exact" hit aAccuracy will be 0 which works poorly if the pin has
635 // no pin number or name. Give it a floor.
636 if( Schematic() )
637 aAccuracy = std::max( aAccuracy, Schematic()->Settings().m_PinSymbolSize / 4 );
638
639 BOX2I rect = GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE );
640
641 return rect.Inflate( aAccuracy ).Contains( aPosition );
642}
643
644
645bool SCH_PIN::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
646{
648 return false;
649
650 BOX2I sel = aRect;
651
652 if ( aAccuracy )
653 sel.Inflate( aAccuracy );
654
655 if( aContained )
656 return sel.Contains( GetBoundingBox( false, false, false ) );
657
658 return sel.Intersects( GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE ) );
659}
660
661
662const wxString& SCH_PIN::GetShownName() const
663{
664 if( !m_alt.IsEmpty() )
665 return m_alt;
666 else if( m_libPin )
667 return m_libPin->GetShownName();
668
669 return m_name;
670}
671
672
673const wxString& SCH_PIN::GetShownNumber() const
674{
675 return m_number;
676}
677
678
679std::vector<wxString> SCH_PIN::GetStackedPinNumbers( bool* aValid ) const
680{
681 const wxString& shown = GetShownNumber();
682 wxLogTrace( traceStackedPins, "GetStackedPinNumbers: shown='%s'", shown );
683
684 std::vector<wxString> numbers = ExpandStackedPinNotation( shown, aValid );
685
686 // Log the expansion for debugging
687 wxLogTrace( traceStackedPins, "Expanded '%s' to %zu pins", shown, numbers.size() );
688 for( const wxString& num : numbers )
689 {
690 wxLogTrace( traceStackedPins, wxString::Format( " -> '%s'", num ) );
691 }
692
693 return numbers;
694}
695
696
697int SCH_PIN::GetStackedPinCount( bool* aValid ) const
698{
699 const wxString& shown = GetShownNumber();
700 return CountStackedPinNotation( shown, aValid );
701}
702
703
704std::optional<wxString> SCH_PIN::GetSmallestLogicalNumber() const
705{
706 bool valid = false;
707 auto numbers = GetStackedPinNumbers( &valid );
708
709 if( valid && !numbers.empty() )
710 return numbers.front(); // Already in ascending order
711
712 return std::nullopt;
713}
714
715
717{
718 if( auto smallest = GetSmallestLogicalNumber() )
719 return *smallest;
720
721 return GetShownNumber();
722}
723
724
725void SCH_PIN::SetNumber( const wxString& aNumber )
726{
727 if( m_number == aNumber )
728 return;
729
730 m_number = aNumber;
731 // pin number string does not support spaces
732 m_number.Replace( wxT( " " ), wxT( "_" ) );
733
734 if( m_layoutCache )
736}
737
738
740{
741 if( !m_nameTextSize.has_value() )
742 {
743 if( !m_libPin )
744 return schIUScale.MilsToIU( DEFAULT_PINNAME_SIZE );
745
746 return m_libPin->GetNameTextSize();
747 }
748
749 return m_nameTextSize.value();
750}
751
752
754{
755 if( aSize == m_nameTextSize )
756 return;
757
758 m_nameTextSize = aSize;
759
760 if( m_layoutCache )
762}
763
764
766{
767 if( !m_numTextSize.has_value() )
768 {
769 if( !m_libPin )
770 return schIUScale.MilsToIU( DEFAULT_PINNUM_SIZE );
771
772 return m_libPin->GetNumberTextSize();
773 }
774
775 return m_numTextSize.value();
776}
777
778
780{
781 if( aSize == m_numTextSize )
782 return;
783
784 m_numTextSize = aSize;
785
786 if( m_layoutCache )
788}
789
790
792{
793 if( const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( GetParentSymbol() ) )
794 {
795 const TRANSFORM& t = symbol->GetTransform();
796
797 if( !m_libPin )
798 return GetPosition();
799
800 return t.TransformCoordinate( m_libPin->GetPinRoot() ) + symbol->GetPosition();
801 }
802
803 switch( GetOrientation() )
804 {
805 default:
810 }
811}
812
813
814void SCH_PIN::PlotPinType( PLOTTER *aPlotter, const VECTOR2I &aPosition,
815 PIN_ORIENTATION aOrientation, bool aDimmed ) const
816{
817 int MapX1, MapY1, x1, y1;
818 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
819 COLOR4D color = renderSettings->GetLayerColor( LAYER_PIN );
820 COLOR4D bg = renderSettings->GetBackgroundColor();
821 int penWidth = GetEffectivePenWidth( renderSettings );
822 int pinLength = GetLength();
823
824 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
825 bg = COLOR4D::WHITE;
826
827 if( color.m_text && Schematic() )
828 color = COLOR4D( ResolveText( *color.m_text, &Schematic()->CurrentSheet() ) );
829
830 if( aDimmed )
831 {
832 color.Desaturate( );
833 color = color.Mix( bg, 0.5f );
834 }
835
836 aPlotter->SetColor( color );
837 aPlotter->SetCurrentLineWidth( penWidth );
838
839 MapX1 = MapY1 = 0;
840 x1 = aPosition.x; y1 = aPosition.y;
841
842 switch( aOrientation )
843 {
844 case PIN_ORIENTATION::PIN_UP: y1 = aPosition.y - pinLength; MapY1 = 1; break;
845 case PIN_ORIENTATION::PIN_DOWN: y1 = aPosition.y + pinLength; MapY1 = -1; break;
846 case PIN_ORIENTATION::PIN_LEFT: x1 = aPosition.x - pinLength; MapX1 = 1; break;
847 case PIN_ORIENTATION::PIN_RIGHT: x1 = aPosition.x + pinLength; MapX1 = -1; break;
848 case PIN_ORIENTATION::INHERIT: wxFAIL_MSG( wxS( "aOrientation must be resolved!" ) ); break;
849 }
850
852 {
853 const int radius = externalPinDecoSize( aPlotter->RenderSettings(), *this );
854 aPlotter->Circle( VECTOR2I( MapX1 * radius + x1, MapY1 * radius + y1 ), radius * 2,
855 FILL_T::NO_FILL, penWidth );
856
857 aPlotter->MoveTo( VECTOR2I( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) );
858 aPlotter->FinishTo( aPosition );
859 }
861 {
862 const int deco_size = internalPinDecoSize( aPlotter->RenderSettings(), *this );
863 if( MapY1 == 0 ) /* MapX1 = +- 1 */
864 {
865 aPlotter->MoveTo( VECTOR2I( x1, y1 + deco_size ) );
866 aPlotter->LineTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 ) );
867 aPlotter->FinishTo( VECTOR2I( x1, y1 - deco_size ) );
868 }
869 else /* MapX1 = 0 */
870 {
871 aPlotter->MoveTo( VECTOR2I( x1 + deco_size, y1 ) );
872 aPlotter->LineTo( VECTOR2I( x1, y1 + MapY1 * deco_size * 2 ) );
873 aPlotter->FinishTo( VECTOR2I( x1 - deco_size, y1 ) );
874 }
875
876 aPlotter->MoveTo( VECTOR2I( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ) );
877 aPlotter->FinishTo( aPosition );
878 }
879 else
880 {
881 aPlotter->MoveTo( VECTOR2I( x1, y1 ) );
882 aPlotter->FinishTo( aPosition );
883 }
884
888 {
889 const int deco_size = internalPinDecoSize( aPlotter->RenderSettings(), *this );
890
891 if( MapY1 == 0 ) /* MapX1 = +- 1 */
892 {
893 aPlotter->MoveTo( VECTOR2I( x1, y1 + deco_size ) );
894 aPlotter->LineTo( VECTOR2I( x1 - MapX1 * deco_size * 2, y1 ) );
895 aPlotter->FinishTo( VECTOR2I( x1, y1 - deco_size ) );
896 }
897 else /* MapX1 = 0 */
898 {
899 aPlotter->MoveTo( VECTOR2I( x1 + deco_size, y1 ) );
900 aPlotter->LineTo( VECTOR2I( x1, y1 - MapY1 * deco_size * 2 ) );
901 aPlotter->FinishTo( VECTOR2I( x1 - deco_size, y1 ) );
902 }
903 }
904
906 || m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW ) /* IEEE symbol "Active Low Input" */
907 {
908 const int deco_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
909
910 if( MapY1 == 0 ) /* MapX1 = +- 1 */
911 {
912 aPlotter->MoveTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 ) );
913 aPlotter->LineTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
914 aPlotter->FinishTo( VECTOR2I( x1, y1 ) );
915 }
916 else /* MapX1 = 0 */
917 {
918 aPlotter->MoveTo( VECTOR2I( x1, y1 + MapY1 * deco_size * 2 ) );
919 aPlotter->LineTo( VECTOR2I( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
920 aPlotter->FinishTo( VECTOR2I( x1, y1 ) );
921 }
922 }
923
924 if( m_shape == GRAPHIC_PINSHAPE::OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
925 {
926 const int symbol_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
927
928 if( MapY1 == 0 ) /* MapX1 = +- 1 */
929 {
930 aPlotter->MoveTo( VECTOR2I( x1, y1 - symbol_size * 2 ) );
931 aPlotter->FinishTo( VECTOR2I( x1 + MapX1 * symbol_size * 2, y1 ) );
932 }
933 else /* MapX1 = 0 */
934 {
935 aPlotter->MoveTo( VECTOR2I( x1 - symbol_size * 2, y1 ) );
936 aPlotter->FinishTo( VECTOR2I( x1, y1 + MapY1 * symbol_size * 2 ) );
937 }
938 }
939 else if( m_shape == GRAPHIC_PINSHAPE::NONLOGIC ) /* NonLogic pin symbol */
940 {
941 const int deco_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
942 aPlotter->MoveTo( VECTOR2I( x1 - ( MapX1 + MapY1 ) * deco_size,
943 y1 - ( MapY1 - MapX1 ) * deco_size ) );
944 aPlotter->FinishTo( VECTOR2I( x1 + ( MapX1 + MapY1 ) * deco_size,
945 y1 + ( MapY1 - MapX1 ) * deco_size ) );
946 aPlotter->MoveTo( VECTOR2I( x1 - ( MapX1 - MapY1 ) * deco_size,
947 y1 - ( MapY1 + MapX1 ) * deco_size ) );
948 aPlotter->FinishTo( VECTOR2I( x1 + ( MapX1 - MapY1 ) * deco_size,
949 y1 + ( MapY1 + MapX1 ) * deco_size ) );
950 }
951
952 if( GetType() == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
953 {
954 const int deco_size = TARGET_PIN_RADIUS;
955 const int ex1 = aPosition.x;
956 const int ey1 = aPosition.y;
957 aPlotter->MoveTo( VECTOR2I( ex1 - deco_size, ey1 - deco_size ) );
958 aPlotter->FinishTo( VECTOR2I( ex1 + deco_size, ey1 + deco_size ) );
959 aPlotter->MoveTo( VECTOR2I( ex1 + deco_size, ey1 - deco_size ) );
960 aPlotter->FinishTo( VECTOR2I( ex1 - deco_size, ey1 + deco_size ) );
961 }
962}
963
964
965void SCH_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient,
966 int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed ) const
967{
968 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
969 KIFONT::FONT* font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), false, false );
970 wxString name = GetShownName();
971 wxString number = GetShownNumber();
972
973 // Apply stacked pin display formatting (reuse helper from pin_layout_cache)
974 if( aDrawPinNum && !number.IsEmpty() )
975 {
976 const KIFONT::METRICS& metrics = GetFontMetrics();
977 number = FormatStackedPinForDisplay( number, GetLength(), GetNumberTextSize(), font, metrics );
978 }
979
980 if( name.IsEmpty() || m_nameTextSize == 0 )
981 aDrawPinName = false;
982
983 if( number.IsEmpty() || m_numTextSize == 0 )
984 aDrawPinNum = false;
985
986 if( !aDrawPinNum && !aDrawPinName )
987 return;
988
989 int namePenWidth = settings->GetDefaultPenWidth();
990 int numPenWidth = settings->GetDefaultPenWidth();
991 int name_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + namePenWidth;
992 int num_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + numPenWidth;
993
994 COLOR4D nameColor = settings->GetLayerColor( LAYER_PINNAM );
995 COLOR4D numColor = settings->GetLayerColor( LAYER_PINNUM );
996 COLOR4D bg = settings->GetBackgroundColor();
997
998 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
999 bg = COLOR4D::WHITE;
1000
1001 if( nameColor.m_text && Schematic() )
1002 nameColor = COLOR4D( ResolveText( *nameColor.m_text, &Schematic()->CurrentSheet() ) );
1003
1004 if( numColor.m_text && Schematic() )
1005 numColor = COLOR4D( ResolveText( *numColor.m_text, &Schematic()->CurrentSheet() ) );
1006
1007 if( aDimmed )
1008 {
1009 nameColor.Desaturate();
1010 numColor.Desaturate();
1011 nameColor = nameColor.Mix( bg, 0.5f );
1012 numColor = numColor.Mix( bg, 0.5f );
1013 }
1014
1015 int x1 = aPinPos.x;
1016 int y1 = aPinPos.y;
1017
1018 switch( aPinOrient )
1019 {
1020 case PIN_ORIENTATION::PIN_UP: y1 -= GetLength(); break;
1021 case PIN_ORIENTATION::PIN_DOWN: y1 += GetLength(); break;
1022 case PIN_ORIENTATION::PIN_LEFT: x1 -= GetLength(); break;
1023 case PIN_ORIENTATION::PIN_RIGHT: x1 += GetLength(); break;
1024 default: break;
1025 }
1026
1027 auto plotSimpleText =
1028 [&]( int x, int y, const EDA_ANGLE& angle, GR_TEXT_H_ALIGN_T hJustify, GR_TEXT_V_ALIGN_T vJustify,
1029 const wxString& txt, int size, int penWidth, const COLOR4D& col )
1030 {
1031 TEXT_ATTRIBUTES attrs;
1032 attrs.m_StrokeWidth = penWidth;
1033 attrs.m_Angle = angle;
1034 attrs.m_Size = VECTOR2I( size, size );
1035 attrs.m_Halign = hJustify;
1036 attrs.m_Valign = vJustify;
1037 attrs.m_Multiline = false; // we'll manage multi-line manually
1038 aPlotter->PlotText( VECTOR2I( x, y ), col, txt, attrs, font, GetFontMetrics() );
1039 };
1040
1041 auto plotMultiLineWithBraces =
1042 [&]( int anchorX, int anchorY, EDA_ANGLE angle, GR_TEXT_V_ALIGN_T vAlign, bool /*numberBlock*/ )
1043 {
1044 // If not multi-line formatted, just plot single line centered.
1045 if( !number.StartsWith( "[" ) || !number.EndsWith( "]" ) || !number.Contains( "\n" ) )
1046 {
1047 plotSimpleText( anchorX, anchorY, angle, GR_TEXT_H_ALIGN_CENTER, vAlign, number,
1048 GetNumberTextSize(), numPenWidth, numColor );
1049 return;
1050 }
1051
1052 wxString content = number.Mid( 1, number.Length() - 2 );
1053 wxArrayString lines;
1054 wxStringSplit( content, lines, '\n' );
1055
1056 if( lines.size() <= 1 )
1057 {
1058 plotSimpleText( anchorX, anchorY, angle, GR_TEXT_H_ALIGN_CENTER, vAlign, content,
1059 GetNumberTextSize(), numPenWidth, numColor );
1060 return;
1061 }
1062
1063 int textSize = GetNumberTextSize();
1064 int lineSpacing = KiROUND( textSize * 1.3 );
1065 const KIFONT::METRICS& metrics = GetFontMetrics();
1066
1067 // Measure line widths for brace spacing
1068 int maxLineWidth = 0;
1069 for( const wxString& rawLine : lines )
1070 {
1071 wxString trimmed = rawLine; trimmed.Trim(true).Trim(false);
1072 VECTOR2I ext = font->StringBoundaryLimits( trimmed, VECTOR2D( textSize, textSize ),
1073 GetPenSizeForNormal( textSize ), false, false, metrics );
1074 if( ext.x > maxLineWidth )
1075 maxLineWidth = ext.x;
1076 }
1077
1078 // Determine starting position
1079 int startX = anchorX;
1080 int startY = anchorY;
1081
1082 if( angle == ANGLE_VERTICAL )
1083 {
1084 int totalWidth = ( (int) lines.size() - 1 ) * lineSpacing;
1085 startX -= totalWidth;
1086 }
1087 else
1088 {
1089 int totalHeight = ( (int) lines.size() - 1 ) * lineSpacing;
1090 startY -= totalHeight;
1091 }
1092
1093 for( size_t i = 0; i < lines.size(); ++i )
1094 {
1095 wxString l = lines[i]; l.Trim( true ).Trim( false );
1096 int lx = startX + ( angle == ANGLE_VERTICAL ? (int) i * lineSpacing : 0 );
1097 int ly = startY + ( angle == ANGLE_VERTICAL ? 0 : (int) i * lineSpacing );
1098 plotSimpleText( lx, ly, angle, GR_TEXT_H_ALIGN_CENTER, vAlign, l, textSize, numPenWidth, numColor );
1099 }
1100
1101 // Now draw braces emulating SCH_PAINTER brace geometry
1102 auto plotBrace =
1103 [&]( const VECTOR2I& top, const VECTOR2I& bottom, bool leftOrTop, bool isVerticalText )
1104 {
1105 // Build 4 small segments approximating curly brace
1106 VECTOR2I mid = ( top + bottom ) / 2;
1107 int braceWidth = textSize / 3; // same scale as painter
1108 VECTOR2I p1 = top;
1109 VECTOR2I p5 = bottom;
1110 VECTOR2I p2 = top;
1111 VECTOR2I p3 = mid;
1112 VECTOR2I p4 = bottom;
1113 int offset = leftOrTop ? -braceWidth : braceWidth;
1114
1115 if( isVerticalText )
1116 {
1117 // Text vertical => brace extends in Y (horizontal brace lines across X axis set)
1118 // For vertical orientation we offset Y for p2/p3/p4
1119 p2.y += offset / 2;
1120 p3.y += offset;
1121 p4.y += offset / 2;
1122 }
1123 else
1124 {
1125 // Horizontal text => brace extends in X
1126 p2.x += offset / 2;
1127 p3.x += offset;
1128 p4.x += offset / 2;
1129 }
1130
1131 aPlotter->MoveTo( p1 ); aPlotter->FinishTo( p2 );
1132 aPlotter->MoveTo( p2 ); aPlotter->FinishTo( p3 );
1133 aPlotter->MoveTo( p3 ); aPlotter->FinishTo( p4 );
1134 aPlotter->MoveTo( p4 ); aPlotter->FinishTo( p5 );
1135 };
1136
1137 aPlotter->SetCurrentLineWidth( numPenWidth );
1138 int braceWidth = textSize / 3;
1139 int extraHeight = textSize / 3; // extend beyond text block
1140
1141 if( angle == ANGLE_VERTICAL )
1142 {
1143 // Lines spaced horizontally, braces horizontal (above & below)
1144 int totalWidth = ( (int) lines.size() - 1 ) * lineSpacing;
1145 VECTOR2I braceStart( startX - 2 * extraHeight, anchorY );
1146 VECTOR2I braceEnd( startX + totalWidth + extraHeight, anchorY );
1147 int braceSpacing = maxLineWidth / 2 + braceWidth;
1148
1149 VECTOR2I topStart = braceStart; topStart.y -= braceSpacing;
1150 VECTOR2I topEnd = braceEnd; topEnd.y -= braceSpacing;
1151 VECTOR2I bottomStart = braceStart; bottomStart.y += braceSpacing;
1152 VECTOR2I bottomEnd = braceEnd; bottomEnd.y += braceSpacing;
1153
1154 plotBrace( topStart, topEnd, true, true ); // leftOrTop=true
1155 plotBrace( bottomStart, bottomEnd, false, true );
1156 }
1157 else
1158 {
1159 // Lines spaced vertically, braces vertical (left & right)
1160 int totalHeight = ( (int) lines.size() - 1 ) * lineSpacing;
1161 VECTOR2I braceStart( anchorX, startY - 2 * extraHeight );
1162 VECTOR2I braceEnd( anchorX, startY + totalHeight + extraHeight );
1163 int braceSpacing = maxLineWidth / 2 + braceWidth;
1164
1165 VECTOR2I leftTop = braceStart; leftTop.x -= braceSpacing;
1166 VECTOR2I leftBot = braceEnd; leftBot.x -= braceSpacing;
1167 VECTOR2I rightTop = braceStart; rightTop.x += braceSpacing;
1168 VECTOR2I rightBot = braceEnd; rightBot.x += braceSpacing;
1169
1170 plotBrace( leftTop, leftBot, true, false );
1171 plotBrace( rightTop, rightBot, false, false );
1172 }
1173 };
1174
1175 // Logic largely mirrors original single-line placement but calls multi-line path for numbers
1176 if( aTextInside )
1177 {
1178 if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT ) || ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
1179 {
1180 if( aDrawPinName )
1181 {
1182 if( aPinOrient == PIN_ORIENTATION::PIN_RIGHT )
1183 {
1184 plotSimpleText( x1 + aTextInside, y1, ANGLE_HORIZONTAL, GR_TEXT_H_ALIGN_LEFT,
1185 GR_TEXT_V_ALIGN_CENTER, name, GetNameTextSize(), namePenWidth, nameColor );
1186 }
1187 else
1188 {
1189 plotSimpleText( x1 - aTextInside, y1, ANGLE_HORIZONTAL, GR_TEXT_H_ALIGN_RIGHT,
1190 GR_TEXT_V_ALIGN_CENTER, name, GetNameTextSize(), namePenWidth, nameColor );
1191 }
1192 }
1193
1194 if( aDrawPinNum )
1195 {
1196 plotMultiLineWithBraces( ( x1 + aPinPos.x ) / 2, y1 - num_offset, ANGLE_HORIZONTAL,
1197 GR_TEXT_V_ALIGN_BOTTOM, true );
1198 }
1199 }
1200 else
1201 {
1202 if( aPinOrient == PIN_ORIENTATION::PIN_DOWN )
1203 {
1204 if( aDrawPinName )
1205 {
1206 plotSimpleText( x1, y1 + aTextInside, ANGLE_VERTICAL, GR_TEXT_H_ALIGN_RIGHT,
1207 GR_TEXT_V_ALIGN_CENTER, name, GetNameTextSize(), namePenWidth, nameColor );
1208 }
1209
1210 if( aDrawPinNum )
1211 {
1212 plotMultiLineWithBraces( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1213 GR_TEXT_V_ALIGN_BOTTOM, true );
1214 }
1215 }
1216 else // PIN_UP
1217 {
1218 if( aDrawPinName )
1219 {
1220 plotSimpleText( x1, y1 - aTextInside, ANGLE_VERTICAL, GR_TEXT_H_ALIGN_LEFT,
1221 GR_TEXT_V_ALIGN_CENTER, name, GetNameTextSize(), namePenWidth, nameColor );
1222 }
1223
1224 if( aDrawPinNum )
1225 {
1226 plotMultiLineWithBraces( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1227 GR_TEXT_V_ALIGN_BOTTOM, true );
1228 }
1229 }
1230 }
1231 }
1232 else
1233 {
1234 if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT ) || ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
1235 {
1236 if( aDrawPinName && aDrawPinNum )
1237 {
1238 plotSimpleText( ( x1 + aPinPos.x ) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
1240 GetNameTextSize(), namePenWidth, nameColor );
1241 plotMultiLineWithBraces( ( x1 + aPinPos.x ) / 2, y1 + num_offset, ANGLE_HORIZONTAL,
1242 GR_TEXT_V_ALIGN_TOP, true );
1243 }
1244 else if( aDrawPinName )
1245 {
1246 plotSimpleText( ( x1 + aPinPos.x ) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
1248 GetNameTextSize(), namePenWidth, nameColor );
1249 }
1250 else if( aDrawPinNum )
1251 {
1252 plotMultiLineWithBraces( ( x1 + aPinPos.x ) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
1253 GR_TEXT_V_ALIGN_BOTTOM, true );
1254 }
1255 }
1256 else
1257 {
1258 if( aDrawPinName && aDrawPinNum )
1259 {
1260 plotSimpleText( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1262 GetNameTextSize(), namePenWidth, nameColor );
1263 plotMultiLineWithBraces( x1 + num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1264 GR_TEXT_V_ALIGN_TOP, true );
1265 }
1266 else if( aDrawPinName )
1267 {
1268 plotSimpleText( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1270 GetNameTextSize(), namePenWidth, nameColor );
1271 }
1272 else if( aDrawPinNum )
1273 {
1274 plotMultiLineWithBraces( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
1275 GR_TEXT_V_ALIGN_BOTTOM, true );
1276 }
1277 }
1278 }
1279}
1280
1281
1283{
1284 PIN_ORIENTATION orient;
1285 VECTOR2I end; // position of pin end starting at 0,0 according to its orientation, length = 1
1286
1287 switch( GetOrientation() )
1288 {
1289 default:
1290 case PIN_ORIENTATION::PIN_RIGHT: end.x = 1; break;
1291 case PIN_ORIENTATION::PIN_UP: end.y = -1; break;
1292 case PIN_ORIENTATION::PIN_DOWN: end.y = 1; break;
1293 case PIN_ORIENTATION::PIN_LEFT: end.x = -1; break;
1294 }
1295
1296 // = pos of end point, according to the symbol orientation.
1297 end = aTransform.TransformCoordinate( end );
1298 orient = PIN_ORIENTATION::PIN_UP;
1299
1300 if( end.x == 0 )
1301 {
1302 if( end.y > 0 )
1304 }
1305 else
1306 {
1308
1309 if( end.x < 0 )
1311 }
1312
1313 return orient;
1314}
1315
1316
1318{
1319 //return new SCH_PIN( *this );
1320 SCH_ITEM* newPin = new SCH_PIN( *this );
1321 wxASSERT( newPin->GetUnit() == m_unit && newPin->GetBodyStyle() == m_bodyStyle );
1322 return newPin;
1323}
1324
1325
1326void SCH_PIN::ChangeLength( int aLength )
1327{
1328 int lengthChange = GetLength() - aLength;
1329 int offsetX = 0;
1330 int offsetY = 0;
1331
1332 switch( GetOrientation() )
1333 {
1334 default:
1336 offsetX = lengthChange;
1337 break;
1339 offsetX = -1 * lengthChange;
1340 break;
1342 offsetY = -1 * lengthChange;
1343 break;
1345 offsetY = lengthChange;
1346 break;
1347 }
1348
1349 m_position += VECTOR2I( offsetX, offsetY );
1350 m_length = aLength;
1351}
1352
1353
1354void SCH_PIN::Move( const VECTOR2I& aOffset )
1355{
1356 m_position += aOffset;
1357}
1358
1359
1361{
1362 m_position.x -= aCenter;
1363 m_position.x *= -1;
1364 m_position.x += aCenter;
1365
1370}
1371
1372
1374{
1375 if( dynamic_cast<LIB_SYMBOL*>( GetParentSymbol() ) )
1376 MirrorHorizontallyPin( aCenter );
1377}
1378
1379
1381{
1382 m_position.y -= aCenter;
1383 m_position.y *= -1;
1384 m_position.y += aCenter;
1385
1390}
1391
1392
1393void SCH_PIN::MirrorVertically( int aCenter )
1394{
1395 if( dynamic_cast<LIB_SYMBOL*>( GetParentSymbol() ) )
1396 MirrorVerticallyPin( aCenter );
1397}
1398
1399
1400void SCH_PIN::RotatePin( const VECTOR2I& aCenter, bool aRotateCCW )
1401{
1402 if( aRotateCCW )
1403 {
1404 RotatePoint( m_position, aCenter, ANGLE_90 );
1405
1406 switch( GetOrientation() )
1407 {
1408 default:
1413 }
1414 }
1415 else
1416 {
1417 RotatePoint( m_position, aCenter, -ANGLE_90 );
1418
1419 switch( GetOrientation() )
1420 {
1421 default:
1426 }
1427 }
1428}
1429
1430
1431void SCH_PIN::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
1432{
1433 if( dynamic_cast<LIB_SYMBOL*>( GetParentSymbol() ) )
1434 RotatePin( aCenter, aRotateCCW );
1435}
1436
1437
1438void SCH_PIN::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
1439 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
1440{
1441 if( aBackground )
1442 return;
1443
1444 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
1445
1446 if( !IsVisible() && !renderSettings->m_ShowHiddenPins )
1447 return;
1448
1449 const SYMBOL* part = GetParentSymbol();
1450 PIN_ORIENTATION orient = PinDrawOrient( renderSettings->m_Transform );
1451 VECTOR2I pos = renderSettings->TransformCoordinate( m_position ) + aOffset;
1452
1453 PlotPinType( aPlotter, pos, orient, aDimmed );
1454 PlotPinTexts( aPlotter, pos, orient, part->GetPinNameOffset(), part->GetShowPinNumbers(),
1455 part->GetShowPinNames(), aDimmed );
1456}
1457
1458
1459void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1460{
1461 SYMBOL* symbol = GetParentSymbol();
1462
1463 aList.emplace_back( _( "Type" ), _( "Pin" ) );
1464
1465 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
1466
1467 aList.emplace_back( _( "Name" ), UnescapeString( GetShownName() ) );
1468 aList.emplace_back( _( "Number" ), GetShownNumber() );
1469 aList.emplace_back( _( "Type" ), ElectricalPinTypeGetText( GetType() ) );
1470 aList.emplace_back( _( "Style" ), PinShapeGetText( GetShape() ) );
1471
1472 aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
1473
1474 // Display pin length
1475 aList.emplace_back( _( "Length" ), aFrame->MessageTextFromValue( GetLength(), true ) );
1476
1477 aList.emplace_back( _( "Orientation" ), PinOrientationName( GetOrientation() ) );
1478
1479 if( dynamic_cast<LIB_SYMBOL*>( symbol ) )
1480 {
1481 aList.emplace_back( _( "Pos X" ), aFrame->MessageTextFromValue( GetPosition().x, true ) );
1482 aList.emplace_back( _( "Pos Y" ), aFrame->MessageTextFromValue( GetPosition().y, true ) );
1483 }
1484 else if( SCH_SYMBOL* schsymbol = dynamic_cast<SCH_SYMBOL*>( symbol ) )
1485 {
1486 SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
1487 SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
1488
1489 // Don't use GetShownText(); we want to see the variable references here
1490 aList.emplace_back( symbol->GetRef( currentSheet ),
1491 UnescapeString( schsymbol->GetField( FIELD_T::VALUE )->GetText() ) );
1492 }
1493
1494#if defined(DEBUG)
1495 if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
1496 {
1497 SCH_CONNECTION* conn = Connection();
1498
1499 if( conn )
1500 conn->AppendInfoToMsgPanel( aList );
1501 }
1502#endif
1503}
1504
1505
1507{
1508 std::lock_guard<std::recursive_mutex> lock( m_netmap_mutex );
1509
1510 if( aPath )
1511 m_net_name_map.erase( *aPath );
1512 else
1513 m_net_name_map.clear();
1514}
1515
1516
1517wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoConnect )
1518{
1519 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( GetParentSymbol() );
1520
1521 // Need to check for parent as power symbol to make sure we aren't dealing
1522 // with legacy global power pins on non-power symbols
1523 if( IsGlobalPower() || IsLocalPower() )
1524 {
1525 SYMBOL* parent = GetLibPin() ? GetLibPin()->GetParentSymbol() : nullptr;
1526
1527 if( parent && ( parent->IsGlobalPower() || parent->IsLocalPower() ) )
1528 {
1529 return EscapeString( symbol->GetValue( true, &aPath, false ), CTX_NETNAME );
1530 }
1531 else
1532 {
1533 wxString tmp = m_libPin ? m_libPin->GetName() : wxString( "??" );
1534
1535 return EscapeString( tmp, CTX_NETNAME );
1536 }
1537 }
1538
1539 std::lock_guard<std::recursive_mutex> lock( m_netmap_mutex );
1540
1541 auto it = m_net_name_map.find( aPath );
1542
1543 if( it != m_net_name_map.end() )
1544 {
1545 if( it->second.second == aForceNoConnect )
1546 return it->second.first;
1547 }
1548
1549 wxString name = "Net-(";
1550 bool unconnected = false;
1551
1552 if( aForceNoConnect || GetType() == ELECTRICAL_PINTYPE::PT_NC )
1553 {
1554 unconnected = true;
1555 name = ( "unconnected-(" );
1556 }
1557
1558 bool annotated = true;
1559
1560 std::vector<const SCH_PIN*> pins = symbol->GetPins( &aPath );
1561 bool has_multiple = false;
1562
1563 for( const SCH_PIN* pin : pins )
1564 {
1565 if( pin->GetShownName() == GetShownName()
1566 && pin->GetShownNumber() != GetShownNumber()
1567 && unconnected == ( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC ) )
1568 {
1569 has_multiple = true;
1570 break;
1571 }
1572 }
1573
1574 wxString libPinShownName = m_libPin ? m_libPin->GetShownName() : wxString( "??" );
1575 wxString libPinShownNumber = m_libPin ? m_libPin->GetShownNumber() : wxString( "??" );
1576 wxString effectivePadNumber = m_libPin ? m_libPin->GetEffectivePadNumber() : libPinShownNumber;
1577
1578 if( effectivePadNumber != libPinShownNumber )
1579 {
1580 wxLogTrace( traceStackedPins,
1581 wxString::Format( "GetDefaultNetName: stacked pin shown='%s' -> using smallest logical='%s'",
1582 libPinShownNumber, effectivePadNumber ) );
1583 }
1584
1585 // Use timestamp for unannotated symbols
1586 if( symbol->GetRef( &aPath, false ).Last() == '?' )
1587 {
1589
1590 wxString libPinNumber = m_libPin ? m_libPin->GetNumber() : wxString( "??" );
1591 // Apply same smallest-logical substitution for unannotated symbols
1592 if( effectivePadNumber != libPinShownNumber && !effectivePadNumber.IsEmpty() )
1593 libPinNumber = effectivePadNumber;
1594
1595 name << "-Pad" << libPinNumber << ")";
1596 annotated = false;
1597 }
1598 else if( !libPinShownName.IsEmpty() && ( libPinShownName != libPinShownNumber ) )
1599 {
1600 // Pin names might not be unique between different units so we must have the
1601 // unit token in the reference designator
1602 name << symbol->GetRef( &aPath, true );
1603 name << "-" << EscapeString( libPinShownName, CTX_NETNAME );
1604
1605 if( unconnected || has_multiple )
1606 {
1607 // Use effective (possibly de-stacked) pad number in net name
1608 name << "-Pad" << EscapeString( effectivePadNumber, CTX_NETNAME );
1609 }
1610
1611 name << ")";
1612 }
1613 else
1614 {
1615 // Pin numbers are unique, so we skip the unit token
1616 name << symbol->GetRef( &aPath, false );
1617 name << "-Pad" << EscapeString( effectivePadNumber, CTX_NETNAME ) << ")";
1618 }
1619
1620 if( annotated )
1621 m_net_name_map[ aPath ] = std::make_pair( name, aForceNoConnect );
1622
1623 return name;
1624}
1625
1626
1628{
1629 return GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE );
1630}
1631
1632
1638
1639
1640void SCH_PIN::validateExtentsCache( KIFONT::FONT* aFont, int aSize, const wxString& aText,
1641 EXTENTS_CACHE* aCache ) const
1642{
1643 if( aCache->m_Font == aFont
1644 && aCache->m_FontSize == aSize
1645 && aCache->m_Extents != VECTOR2I() )
1646 {
1647 return;
1648 }
1649
1650 aCache->m_Font = aFont;
1651 aCache->m_FontSize = aSize;
1652
1653 VECTOR2D fontSize( aSize, aSize );
1654 int penWidth = GetPenSizeForNormal( aSize );
1655
1656 aCache->m_Extents = aFont->StringBoundaryLimits( aText, fontSize, penWidth, false, false,
1657 GetFontMetrics() );
1658}
1659
1660
1661BOX2I SCH_PIN::GetBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber,
1662 bool aIncludeElectricalType ) const
1663{
1664 // Just defer to the cache
1665 return GetLayoutCache().GetPinBoundingBox( aIncludeLabelsOnInvisiblePins,
1666 aIncludeNameAndNumber,
1667 aIncludeElectricalType );
1668}
1669
1670
1672{
1673 if( !m_layoutCache )
1674 m_layoutCache = std::make_unique<PIN_LAYOUT_CACHE>( *this );
1675
1676 return *m_layoutCache;
1677}
1678
1679
1681 const SCH_SHEET_PATH* aInstance ) const
1682{
1683 // Do not compare to ourself.
1684 if( aItem == this )
1685 return false;
1686
1687 const SCH_PIN* pin = dynamic_cast<const SCH_PIN*>( aItem );
1688
1689 // Don't compare against a different SCH_ITEM.
1690 wxCHECK( pin, false );
1691
1692 if( GetPosition() != pin->GetPosition() )
1693 return true;
1694
1695 if( GetNumber() != pin->GetNumber() )
1696 return true;
1697
1698 if( GetName() != pin->GetName() )
1699 return true;
1700
1701 // For power input pins, visibility changes affect IsGlobalPower() which changes
1702 // connectivity semantics. Hidden power pins create implicit global net connections.
1703 // Also check if a pin changed type to/from PT_POWER_IN.
1705 {
1706 if( IsVisible() != pin->IsVisible() || GetType() != pin->GetType() )
1707 return true;
1708 }
1709
1710 return false;
1711}
1712
1713
1715{
1717}
1718
1719
1721{
1722 if( const SYMBOL* parentSymbol = GetParentSymbol() )
1723 {
1724 if( parentSymbol->IsLocked() )
1725 return true;
1726 }
1727
1728 return SCH_ITEM::IsLocked();
1729}
1730
1731
1733{
1734 if( m_libPin )
1735 return m_libPin->GetMenuImage();
1736
1738}
1739
1740
1741wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, ALT* aAlt ) const
1742{
1743 return getItemDescription( aAlt );
1744}
1745
1746
1747wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
1748{
1749 if( m_libPin )
1750 {
1751 SCH_PIN::ALT localStorage;
1752 SCH_PIN::ALT* alt = nullptr;
1753
1754 if( !m_alt.IsEmpty() )
1755 {
1756 localStorage = m_libPin->GetAlt( m_alt );
1757 alt = &localStorage;
1758 }
1759
1760 wxString itemDesc = m_libPin ? m_libPin->GetItemDescription( aUnitsProvider, alt )
1761 : wxString( wxS( "Undefined library pin." ) );
1762
1763 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( GetParentSymbol() );
1764
1765 return wxString::Format( "Symbol %s %s",
1767 itemDesc );
1768 }
1769
1770 return getItemDescription( nullptr );
1771}
1772
1773
1774wxString SCH_PIN::getItemDescription( ALT* aAlt ) const
1775{
1776 wxString name = UnescapeString( aAlt ? aAlt->m_Name : GetShownName() );
1777 wxString electricalTypeName = ElectricalPinTypeGetText( aAlt ? aAlt->m_Type : m_type );
1778 wxString pinShapeName = PinShapeGetText( aAlt ? aAlt->m_Shape : m_shape );
1779
1780 if( IsVisible() )
1781 {
1782 if ( !name.IsEmpty() )
1783 {
1784 return wxString::Format( _( "Pin %s [%s, %s, %s]" ),
1786 name,
1787 electricalTypeName,
1788 pinShapeName );
1789 }
1790 else
1791 {
1792 return wxString::Format( _( "Pin %s [%s, %s]" ),
1794 electricalTypeName,
1795 pinShapeName );
1796 }
1797 }
1798 else
1799 {
1800 if( !name.IsEmpty() )
1801 {
1802 return wxString::Format( _( "Hidden pin %s [%s, %s, %s]" ),
1804 name,
1805 electricalTypeName,
1806 pinShapeName );
1807 }
1808 else
1809 {
1810 return wxString::Format( _( "Hidden pin %s [%s, %s]" ),
1812 electricalTypeName,
1813 pinShapeName );
1814 }
1815 }
1816}
1817
1818
1819int SCH_PIN::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
1820{
1821 // Ignore the UUID here
1822 // And the position, which we'll do after the number.
1823 int retv = SCH_ITEM::compare( aOther, aCompareFlags | SCH_ITEM::COMPARE_FLAGS::EQUALITY
1825
1826 if( retv )
1827 return retv;
1828
1829 const SCH_PIN* tmp = static_cast<const SCH_PIN*>( &aOther );
1830
1831 wxCHECK( tmp, -1 );
1832
1833 if( m_number != tmp->m_number )
1834 {
1835 // StrNumCmp: sort the same as the pads in the footprint file
1836 return StrNumCmp( m_number, tmp->m_number );
1837 }
1838
1839 if( m_position.x != tmp->m_position.x )
1840 return m_position.x - tmp->m_position.x;
1841
1842 if( m_position.y != tmp->m_position.y )
1843 return m_position.y - tmp->m_position.y;
1844
1845 if( dynamic_cast<const SCH_SYMBOL*>( GetParentSymbol() ) )
1846 {
1847 if( ( m_libPin == nullptr ) || ( tmp->m_libPin == nullptr ) )
1848 return -1;
1849
1850 retv = m_libPin->compare( *tmp->m_libPin );
1851
1852 if( retv )
1853 return retv;
1854
1855 retv = m_alt.Cmp( tmp->m_alt );
1856
1857 if( retv )
1858 return retv;
1859 }
1860
1861 if( dynamic_cast<const LIB_SYMBOL*>( GetParentSymbol() ) )
1862 {
1863 if( m_length != tmp->m_length )
1864 return m_length.value_or( 0 ) - tmp->m_length.value_or( 0 );
1865
1866 if( m_orientation != tmp->m_orientation )
1867 return static_cast<int>( m_orientation ) - static_cast<int>( tmp->m_orientation );
1868
1869 if( m_shape != tmp->m_shape )
1870 return static_cast<int>( m_shape ) - static_cast<int>( tmp->m_shape );
1871
1872 if( m_type != tmp->m_type )
1873 return static_cast<int>( m_type ) - static_cast<int>( tmp->m_type );
1874
1875 if( m_hidden != tmp->m_hidden )
1876 return m_hidden.value_or( false ) - tmp->m_hidden.value_or( false );
1877
1878 if( m_numTextSize != tmp->m_numTextSize )
1879 return m_numTextSize.value_or( 0 ) - tmp->m_numTextSize.value_or( 0 );
1880
1881 if( m_nameTextSize != tmp->m_nameTextSize )
1882 return m_nameTextSize.value_or( 0 ) - tmp->m_nameTextSize.value_or( 0 );
1883
1884 if( m_alternates.size() != tmp->m_alternates.size() )
1885 return static_cast<int>( m_alternates.size() - tmp->m_alternates.size() );
1886
1887 auto lhsItem = m_alternates.begin();
1888 auto rhsItem = tmp->m_alternates.begin();
1889
1890 while( lhsItem != m_alternates.end() )
1891 {
1892 const ALT& lhsAlt = lhsItem->second;
1893 const ALT& rhsAlt = rhsItem->second;
1894
1895 retv = lhsAlt.m_Name.Cmp( rhsAlt.m_Name );
1896
1897 if( retv )
1898 return retv;
1899
1900 if( lhsAlt.m_Type != rhsAlt.m_Type )
1901 return static_cast<int>( lhsAlt.m_Type ) - static_cast<int>( rhsAlt.m_Type );
1902
1903 if( lhsAlt.m_Shape != rhsAlt.m_Shape )
1904 return static_cast<int>( lhsAlt.m_Shape ) - static_cast<int>( rhsAlt.m_Shape );
1905
1906 ++lhsItem;
1907 ++rhsItem;
1908 }
1909 }
1910
1911 return 0;
1912}
1913
1914
1915double SCH_PIN::Similarity( const SCH_ITEM& aOther ) const
1916{
1917 if( aOther.m_Uuid == m_Uuid )
1918 return 1.0;
1919
1920 if( aOther.Type() != SCH_PIN_T )
1921 return 0.0;
1922
1923 const SCH_PIN* other = static_cast<const SCH_PIN*>( &aOther );
1924
1925 if( m_libPin )
1926 {
1927 if( m_number != other->m_number )
1928 return 0.0;
1929
1930 if( m_position != other->m_position )
1931 return 0.0;
1932
1933 return m_libPin->Similarity( *other->m_libPin );
1934 }
1935
1936 double similarity = SimilarityBase( aOther );
1937
1938 if( m_name != other->m_name )
1939 similarity *= 0.9;
1940
1941 if( m_number != other->m_number )
1942 similarity *= 0.9;
1943
1944 if( m_position != other->m_position )
1945 similarity *= 0.9;
1946
1947 if( m_length != other->m_length )
1948 similarity *= 0.9;
1949
1950 if( m_orientation != other->m_orientation )
1951 similarity *= 0.9;
1952
1953 if( m_shape != other->m_shape )
1954 similarity *= 0.9;
1955
1956 if( m_type != other->m_type )
1957 similarity *= 0.9;
1958
1959 if( m_hidden != other->m_hidden )
1960 similarity *= 0.9;
1961
1962 if( m_numTextSize != other->m_numTextSize )
1963 similarity *= 0.9;
1964
1965 if( m_nameTextSize != other->m_nameTextSize )
1966 similarity *= 0.9;
1967
1968 if( m_alternates.size() != other->m_alternates.size() )
1969 similarity *= 0.9;
1970
1971 return similarity;
1972}
1973
1974
1975std::ostream& SCH_PIN::operator<<( std::ostream& aStream )
1976{
1977 aStream << "SCH_PIN:" << std::endl
1978 << " Name: \"" << m_name << "\"" << std::endl
1979 << " Number: \"" << m_number << "\"" << std::endl
1980 << " Position: " << m_position << std::endl
1981 << " Length: " << GetLength() << std::endl
1982 << " Orientation: " << PinOrientationName( m_orientation ) << std::endl
1983 << " Shape: " << PinShapeGetText( m_shape ) << std::endl
1984 << " Type: " << ElectricalPinTypeGetText( m_type ) << std::endl
1985 << " Name Text Size: " << GetNameTextSize() << std::endl
1986 << " Number Text Size: " << GetNumberTextSize() << std::endl;
1987
1988 return aStream;
1989}
1990
1991
1992#if defined(DEBUG)
1993
1994void SCH_PIN::Show( int nestLevel, std::ostream& os ) const
1995{
1996 NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
1997 << " num=\"" << m_number.mb_str()
1998 << '"' << "/>\n";
1999}
2000
2001#endif
2002
2003
2004void SCH_PIN::CalcEdit( const VECTOR2I& aPosition )
2005{
2006 if( IsMoving() )
2007 SetPosition( aPosition );
2008}
2009
2010
2011static struct SCH_PIN_DESC
2012{
2014 {
2015 auto& pinTypeEnum = ENUM_MAP<ELECTRICAL_PINTYPE>::Instance();
2016
2017 if( pinTypeEnum.Choices().GetCount() == 0 )
2018 {
2019 pinTypeEnum.Map( ELECTRICAL_PINTYPE::PT_INPUT, _HKI( "Input" ) )
2020 .Map( ELECTRICAL_PINTYPE::PT_OUTPUT, _HKI( "Output" ) )
2021 .Map( ELECTRICAL_PINTYPE::PT_BIDI, _HKI( "Bidirectional" ) )
2022 .Map( ELECTRICAL_PINTYPE::PT_TRISTATE, _HKI( "Tri-state" ) )
2023 .Map( ELECTRICAL_PINTYPE::PT_PASSIVE, _HKI( "Passive" ) )
2024 .Map( ELECTRICAL_PINTYPE::PT_NIC, _HKI( "Free" ) )
2025 .Map( ELECTRICAL_PINTYPE::PT_UNSPECIFIED, _HKI( "Unspecified" ) )
2026 .Map( ELECTRICAL_PINTYPE::PT_POWER_IN, _HKI( "Power input" ) )
2027 .Map( ELECTRICAL_PINTYPE::PT_POWER_OUT, _HKI( "Power output" ) )
2028 .Map( ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR, _HKI( "Open collector" ) )
2029 .Map( ELECTRICAL_PINTYPE::PT_OPENEMITTER, _HKI( "Open emitter" ) )
2030 .Map( ELECTRICAL_PINTYPE::PT_NC, _HKI( "Unconnected" ) );
2031 }
2032
2033 auto& pinShapeEnum = ENUM_MAP<GRAPHIC_PINSHAPE>::Instance();
2034
2035 if( pinShapeEnum.Choices().GetCount() == 0 )
2036 {
2037 pinShapeEnum.Map( GRAPHIC_PINSHAPE::LINE, _HKI( "Line" ) )
2038 .Map( GRAPHIC_PINSHAPE::INVERTED, _HKI( "Inverted" ) )
2039 .Map( GRAPHIC_PINSHAPE::CLOCK, _HKI( "Clock" ) )
2040 .Map( GRAPHIC_PINSHAPE::INVERTED_CLOCK, _HKI( "Inverted clock" ) )
2041 .Map( GRAPHIC_PINSHAPE::INPUT_LOW, _HKI( "Input low" ) )
2042 .Map( GRAPHIC_PINSHAPE::CLOCK_LOW, _HKI( "Clock low" ) )
2043 .Map( GRAPHIC_PINSHAPE::OUTPUT_LOW, _HKI( "Output low" ) )
2044 .Map( GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK, _HKI( "Falling edge clock" ) )
2045 .Map( GRAPHIC_PINSHAPE::NONLOGIC, _HKI( "NonLogic" ) );
2046 }
2047
2048 auto& orientationEnum = ENUM_MAP<PIN_ORIENTATION>::Instance();
2049
2050 if( orientationEnum.Choices().GetCount() == 0 )
2051 {
2052 orientationEnum.Map( PIN_ORIENTATION::PIN_RIGHT, _HKI( "Right" ) )
2053 .Map( PIN_ORIENTATION::PIN_LEFT, _HKI( "Left" ) )
2054 .Map( PIN_ORIENTATION::PIN_UP, _HKI( "Up" ) )
2055 .Map( PIN_ORIENTATION::PIN_DOWN, _HKI( "Down" ) );
2056 }
2057
2058 auto isSymbolEditor =
2059 []( INSPECTABLE* aItem ) -> bool
2060 {
2061 if( SCH_PIN* pin = dynamic_cast<SCH_PIN*>( aItem ) )
2062 return dynamic_cast<LIB_SYMBOL*>( pin->GetParentSymbol() ) != nullptr;
2063
2064 return false;
2065 };
2066
2071
2072 // Lock state is inherited from parent symbol (no independent locking of child items)
2073 propMgr.Mask( TYPE_HASH( SCH_PIN ), TYPE_HASH( SCH_ITEM ), _HKI( "Locked" ) );
2074
2075 propMgr.AddProperty( new PROPERTY<SCH_PIN, wxString>( _HKI( "Pin Name" ),
2077 .SetWriteableFunc( isSymbolEditor );
2078
2079 propMgr.AddProperty( new PROPERTY<SCH_PIN, wxString>( _HKI( "Pin Number" ),
2081 .SetWriteableFunc( isSymbolEditor );
2082
2083 propMgr.AddProperty( new PROPERTY_ENUM<SCH_PIN, ELECTRICAL_PINTYPE>( _HKI( "Electrical Type" ),
2085 .SetWriteableFunc( isSymbolEditor );
2086
2087 propMgr.AddProperty( new PROPERTY_ENUM<SCH_PIN, GRAPHIC_PINSHAPE>( _HKI( "Graphic Style" ),
2089 .SetWriteableFunc( isSymbolEditor );
2090
2091 propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Position X" ),
2093 .SetAvailableFunc( isSymbolEditor );
2094
2095 propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Position Y" ),
2097 .SetAvailableFunc( isSymbolEditor );
2098
2099 propMgr.AddProperty( new PROPERTY_ENUM<SCH_PIN, PIN_ORIENTATION>( _HKI( "Orientation" ),
2101 .SetWriteableFunc( isSymbolEditor );
2102
2103 propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Length" ),
2106 .SetWriteableFunc( isSymbolEditor );
2107
2108 propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Name Text Size" ),
2111 .SetAvailableFunc( isSymbolEditor );
2112
2113 propMgr.AddProperty( new PROPERTY<SCH_PIN, int>( _HKI( "Number Text Size" ),
2116 .SetAvailableFunc( isSymbolEditor );
2117
2118 propMgr.AddProperty( new PROPERTY<SCH_PIN, bool>( _HKI( "Visible" ),
2120 .SetAvailableFunc( isSymbolEditor );
2121
2122 }
2124
2125
const char * name
types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:44
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:127
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:528
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
EDA_ITEM_FLAGS m_flags
Definition eda_item.h:539
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:413
EDA_ITEM * GetParent() const
Definition eda_item.h:114
EDA_ITEM * m_parent
Owner.
Definition eda_item.h:540
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:127
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:48
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:
BOX2I GetPinBoundingBox(bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber, bool aIncludeElectricalType)
Get the bounding box of the pin itself.
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.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
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:126
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:827
int m_unit
Definition sch_item.h:782
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition sch_item.cpp:82
int m_bodyStyle
Definition sch_item.h:783
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition sch_item.h:730
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:278
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:272
int GetBodyStyle() const
Definition sch_item.h:248
bool IsLocked() const override
Definition sch_item.cpp:152
friend class LIB_SYMBOL
Definition sch_item.h:803
@ SKIP_TST_POS
Definition sch_item.h:713
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:722
bool IsConnectivityDirty() const
Definition sch_item.h:591
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:491
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
Definition sch_item.cpp:381
const KIFONT::METRICS & GetFontMetrics() const
Definition sch_item.cpp:783
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition sch_item.cpp:792
SCH_LAYER_ID m_layer
Definition sch_item.h:781
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:383
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition sch_pin.cpp:1431
std::ostream & operator<<(std::ostream &aStream)
Definition sch_pin.cpp:1975
void SetAlt(const wxString &aAlt)
Set the name of the alternate pin.
Definition sch_pin.cpp:518
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:965
int GetNumberTextSize() const
Definition sch_pin.cpp:765
int GetLength() const
Definition sch_pin.cpp:379
std::optional< bool > m_hidden
Definition sch_pin.h:404
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition sch_pin.cpp:584
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:1459
std::unique_ptr< PIN_LAYOUT_CACHE > m_layoutCache
The layout cache for this pin.
Definition sch_pin.h:420
void MirrorVerticallyPin(int aCenter)
Definition sch_pin.cpp:1380
void validateExtentsCache(KIFONT::FONT *aFont, int aSize, const wxString &aText, EXTENTS_CACHE *aCache) const
Definition sch_pin.cpp:1640
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition sch_pin.cpp:1627
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:1633
const std::map< wxString, ALT > & GetAlternates() const
Definition sch_pin.h:163
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition sch_pin.cpp:2004
void SetNumber(const wxString &aNumber)
Definition sch_pin.cpp:725
std::optional< int > m_nameTextSize
Definition sch_pin.h:408
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:1282
void SetVisible(bool aVisible)
Definition sch_pin.h:117
int GetX() const
Definition sch_pin.h:257
void ChangeLength(int aLength)
Change the length of a pin and adjust its position based on orientation.
Definition sch_pin.cpp:1326
void SetX(int aX)
Definition sch_pin.h:258
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:1680
SCH_PIN & operator=(const SCH_PIN &aPin)
Definition sch_pin.cpp:233
SCH_PIN * m_libPin
Definition sch_pin.h:393
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:704
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
Definition sch_pin.cpp:1354
std::map< const SCH_SHEET_PATH, std::pair< wxString, bool > > m_net_name_map
Definition sch_pin.h:424
PIN_ORIENTATION m_orientation
Definition sch_pin.h:401
void SetOrientation(PIN_ORIENTATION aOrientation)
Definition sch_pin.h:96
void SetName(const wxString &aName)
Definition sch_pin.cpp:503
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:439
wxString getItemDescription(ALT *aAlt) const
Definition sch_pin.cpp:1774
bool IsVisible() const
Definition sch_pin.cpp:471
bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Return true if this item should propagate connection info to aItem.
Definition sch_pin.cpp:1714
bool IsLocked() const override
Definition sch_pin.cpp:1720
std::optional< int > m_numTextSize
Definition sch_pin.h:407
VECTOR2I GetPinRoot() const
Definition sch_pin.cpp:791
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:458
ELECTRICAL_PINTYPE m_type
Definition sch_pin.h:403
wxString GetEffectivePadNumber() const
Return the pin number to be used for deterministic operations such as auto‑generated net names.
Definition sch_pin.cpp:716
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition sch_pin.cpp:1393
SCH_PIN * GetLibPin() const
Definition sch_pin.h:92
void SetPosition(const VECTOR2I &aPos) override
Definition sch_pin.h:254
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:1915
bool m_isDangling
Definition sch_pin.h:413
void SetIsDangling(bool aIsDangling)
Definition sch_pin.cpp:555
wxString GetElectricalTypeName() const
Definition sch_pin.cpp:432
std::vector< wxString > GetStackedPinNumbers(bool *aValid=nullptr) const
Definition sch_pin.cpp:679
std::map< wxString, ALT > m_alternates
Definition sch_pin.h:396
const wxString & GetName() const
Definition sch_pin.cpp:485
int GetStackedPinCount(bool *aValid=nullptr) const
Return the count of logical pins represented by this pin's stacked notation.
Definition sch_pin.cpp:697
void SetLength(int aLength)
Definition sch_pin.h:102
bool IsDangling() const override
Definition sch_pin.cpp:546
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:1438
void MirrorHorizontally(int aCenter) override
These transforms have effect only if the pin has a LIB_SYMBOL as parent.
Definition sch_pin.cpp:1373
std::recursive_mutex m_netmap_mutex
The name that this pin connection will drive onto a net.
Definition sch_pin.h:423
PIN_ORIENTATION GetOrientation() const
Definition sch_pin.cpp:344
wxString GetClass() const override
Return the class name.
Definition sch_pin.h:77
void SetNumberTextSize(int aSize)
Definition sch_pin.cpp:779
void SetShape(GRAPHIC_PINSHAPE aShape)
Definition sch_pin.h:99
void RotatePin(const VECTOR2I &aCenter, bool aRotateCCW=true)
Definition sch_pin.cpp:1400
VECTOR2I GetPosition() const override
Definition sch_pin.cpp:336
wxString GetCanonicalElectricalTypeName() const
Definition sch_pin.cpp:425
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:611
int GetNameTextSize() const
Definition sch_pin.cpp:739
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition sch_pin.cpp:1747
VECTOR2I m_position
Definition sch_pin.h:399
GRAPHIC_PINSHAPE m_shape
Definition sch_pin.h:402
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition sch_pin.cpp:293
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
The pin specific sort order is as follows:
Definition sch_pin.cpp:1819
const wxString & GetShownName() const
Definition sch_pin.cpp:662
void MirrorHorizontallyPin(int aCenter)
These transforms have always effects.
Definition sch_pin.cpp:1360
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:632
PIN_LAYOUT_CACHE & GetLayoutCache() const
Get the layout cache associated with this pin.
Definition sch_pin.cpp:1671
wxString m_name
Definition sch_pin.h:405
wxString m_alt
Definition sch_pin.h:409
void SetType(ELECTRICAL_PINTYPE aType)
Definition sch_pin.cpp:413
const wxString & GetBaseName() const
Get the name without any alternates.
Definition sch_pin.cpp:494
void ClearDefaultNetName(const SCH_SHEET_PATH *aPath)
Definition sch_pin.cpp:1506
void SetY(int aY)
Definition sch_pin.h:260
SCH_PIN(LIB_SYMBOL *aParentSymbol)
Definition sch_pin.cpp:123
const wxString & GetShownNumber() const
Definition sch_pin.cpp:673
bool IsStacked(const SCH_PIN *aPin) const
Definition sch_pin.cpp:561
const wxString & GetNumber() const
Definition sch_pin.h:127
wxString m_number
Definition sch_pin.h:406
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_pin.cpp:1317
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition sch_pin.h:218
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition sch_pin.cpp:257
wxString GetDefaultNetName(const SCH_SHEET_PATH &aPath, bool aForceNoConnect=false)
Definition sch_pin.cpp:1517
std::optional< int > m_length
Definition sch_pin.h:400
GRAPHIC_PINSHAPE GetShape() const
Definition sch_pin.cpp:358
void PlotPinType(PLOTTER *aPlotter, const VECTOR2I &aPosition, PIN_ORIENTATION aOrientation, bool aDimmed) const
Definition sch_pin.cpp:814
int GetY() const
Definition sch_pin.h:259
bool IsPower() const
Check if the pin is either a global or local power pin.
Definition sch_pin.cpp:465
ELECTRICAL_PINTYPE GetType() const
Definition sch_pin.cpp:393
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition sch_pin.cpp:1732
void SetNameTextSize(int aSize)
Definition sch_pin.cpp:753
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:60
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:479
@ LAYER_PINNUM
Definition layer_ids.h:460
@ LAYER_DEVICE
Definition layer_ids.h:468
@ LAYER_PINNAM
Definition layer_ids.h:461
@ LAYER_PIN
Definition layer_ids.h:472
@ LAYER_OP_CURRENTS
Definition layer_ids.h:504
@ LAYER_SELECTION_SHADOWS
Definition layer_ids.h:497
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackDistance(types::Distance &aOutput, int aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
#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:48
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:48
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:112
#define PIN_TEXT_MARGIN
Definition sch_pin.cpp:93
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:98
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:363
@ 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:154
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
VECTOR2< double > VECTOR2D
Definition vector2d.h:686