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