KiCad PCB EDA Suite
sch_symbol.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <sch_edit_frame.h>
26#include <widgets/msgpanel.h>
27#include <bitmaps.h>
28#include <core/mirror.h>
29#include <lib_pin.h>
30#include <lib_text.h>
31#include <lib_shape.h>
32#include <pgm_base.h>
33#include <sch_symbol.h>
34#include <sch_sheet_path.h>
35#include <schematic.h>
36#include <trace_helpers.h>
37#include <trigo.h>
38#include <refdes_utils.h>
39#include <wx/log.h>
41#include <string_utils.h>
42
43#include <utility>
44#include "plotters/plotter.h"
45
46
47std::unordered_map<TRANSFORM, int> SCH_SYMBOL::s_transformToOrientationCache;
48
49
54std::string toUTFTildaText( const wxString& txt )
55{
56 std::string ret = TO_UTF8( txt );
57
58 for( std::string::iterator it = ret.begin(); it!=ret.end(); ++it )
59 {
60 if( (unsigned char) *it <= ' ' )
61 *it = '~';
62 }
63
64 return ret;
65}
66
67
82{
83 static LIB_SYMBOL* symbol;
84
85 if( !symbol )
86 {
87 symbol = new LIB_SYMBOL( wxEmptyString );
88
89 LIB_SHAPE* square = new LIB_SHAPE( symbol, SHAPE_T::RECT );
90
91 square->MoveTo( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
92 square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) );
93
94 LIB_TEXT* text = new LIB_TEXT( symbol );
95
96 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) );
97 text->SetText( wxString( wxT( "??" ) ) );
98
99 symbol->AddDrawItem( square );
100 symbol->AddDrawItem( text );
101 }
102
103 return symbol;
104}
105
106
108 SCH_ITEM( nullptr, SCH_SYMBOL_T )
109{
110 m_DNP = false;
111 Init( VECTOR2I( 0, 0 ) );
112}
113
114
115SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId,
116 const SCH_SHEET_PATH* aSheet, int aUnit, int aConvert,
117 const VECTOR2I& aPosition, EDA_ITEM* aParent ) :
118 SCH_ITEM( aParent, SCH_SYMBOL_T )
119{
120 Init( aPosition );
121
122 m_unit = aUnit;
123 m_convert = aConvert;
124 m_lib_id = aLibId;
125
126 std::unique_ptr< LIB_SYMBOL > part;
127
128 part = aSymbol.Flatten();
129 part->SetParent();
130 SetLibSymbol( part.release() );
131
132 // Copy fields from the library symbol
133 UpdateFields( aSheet,
134 true, /* update style */
135 false, /* update ref */
136 false, /* update other fields */
137 true, /* reset ref */
138 true /* reset other fields */ );
139
140 m_prefix = UTIL::GetRefDesPrefix( m_part->GetReferenceField().GetText() );
141
142 if( aSheet )
143 {
145 }
146
147 // Inherit the include in bill of materials and board netlist settings from library symbol.
148 m_inBom = aSymbol.GetIncludeInBom();
149 m_onBoard = aSymbol.GetIncludeOnBoard();
150 m_DNP = false;
151
152}
153
154
155SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet,
156 const PICKED_SYMBOL& aSel, const VECTOR2I& aPosition,
157 EDA_ITEM* aParent ) :
158 SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, aPosition, aParent )
159{
160 // Set any fields that were modified as part of the symbol selection
161 for( const std::pair<int, wxString>& i : aSel.Fields )
162 {
163 if( i.first == REFERENCE_FIELD )
164 SetRef( aSheet, i.second );
165 else if( SCH_FIELD* field = GetFieldById( i.first ) )
166 field->SetText( i.second );
167 }
168}
169
170
172 SCH_ITEM( aSymbol )
173{
174 m_parent = aSymbol.m_parent;
175 m_pos = aSymbol.m_pos;
176 m_unit = aSymbol.m_unit;
177 m_convert = aSymbol.m_convert;
178 m_lib_id = aSymbol.m_lib_id;
180 m_inBom = aSymbol.m_inBom;
181 m_onBoard = aSymbol.m_onBoard;
182 m_DNP = aSymbol.m_DNP;
183
184 if( aSymbol.m_part )
185 SetLibSymbol( new LIB_SYMBOL( *aSymbol.m_part.get() ) );
186
187 const_cast<KIID&>( m_Uuid ) = aSymbol.m_Uuid;
188
189 m_transform = aSymbol.m_transform;
190 m_prefix = aSymbol.m_prefix;
192 m_fields = aSymbol.m_fields;
193
194 // Re-parent the fields, which before this had aSymbol as parent
195 for( SCH_FIELD& field : m_fields )
196 field.SetParent( this );
197
200}
201
202
203void SCH_SYMBOL::Init( const VECTOR2I& pos )
204{
206 m_pos = pos;
207 m_unit = 1; // In multi unit chip - which unit to draw.
208 m_convert = LIB_ITEM::LIB_CONVERT::BASE; // De Morgan Handling
209
210 // The rotation/mirror transformation matrix. pos normal
212
213 // construct only the mandatory fields, which are the first 4 only.
214 for( int i = 0; i < MANDATORY_FIELDS; ++i )
215 {
216 m_fields.emplace_back( pos, i, this, TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) );
217
218 if( i == REFERENCE_FIELD )
219 m_fields.back().SetLayer( LAYER_REFERENCEPART );
220 else if( i == VALUE_FIELD )
221 m_fields.back().SetLayer( LAYER_VALUEPART );
222 else
223 m_fields.back().SetLayer( LAYER_FIELDS );
224 }
225
226 m_prefix = wxString( wxT( "U" ) );
227 m_isInNetlist = true;
228 m_inBom = true;
229 m_onBoard = true;
230}
231
232
234{
235 return new SCH_SYMBOL( *this );
236}
237
238
240{
241 if( !m_part )
242 return true;
243
244 return false;
245}
246
247
248void SCH_SYMBOL::ViewGetLayers( int aLayers[], int& aCount ) const
249{
250 aCount = 8;
251 aLayers[0] = LAYER_DANGLING; // Pins are drawn by their parent symbol, so the parent
252 // symbol needs to draw to LAYER_DANGLING
253 aLayers[1] = LAYER_OP_CURRENTS; // Same for pin operating points
254 aLayers[2] = LAYER_DEVICE;
255 aLayers[3] = LAYER_REFERENCEPART;
256 aLayers[4] = LAYER_VALUEPART;
257 aLayers[5] = LAYER_FIELDS;
258 aLayers[6] = LAYER_DEVICE_BACKGROUND;
259 aLayers[7] = LAYER_SELECTION_SHADOWS;
260}
261
262
264{
265 // If a symbol's anchor is not grid-aligned to its pins then moving from the anchor is
266 // going to end up moving the symbol's pins off-grid.
267
268 // The minimal grid size allowed to place a pin is 25 mils
269 const int min_grid_size = schIUScale.MilsToIU( 25 );
270
271 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
272 {
273 if( ( ( pin->GetPosition().x - m_pos.x ) % min_grid_size ) != 0 )
274 return false;
275
276 if( ( ( pin->GetPosition().y - m_pos.y ) % min_grid_size ) != 0 )
277 return false;
278 }
279
280 return true;
281}
282
283
284void SCH_SYMBOL::SetLibId( const LIB_ID& aLibId )
285{
286 if( m_lib_id != aLibId )
287 {
288 m_lib_id = aLibId;
289 SetModified();
290 }
291}
292
293
295{
296 if( !m_schLibSymbolName.IsEmpty() )
297 return m_schLibSymbolName;
298 else
299 return m_lib_id.Format();
300}
301
302
304{
305 wxCHECK2( ( aLibSymbol == nullptr ) || ( aLibSymbol->IsRoot() ), aLibSymbol = nullptr );
306
307 m_part.reset( aLibSymbol );
308 UpdatePins();
309}
310
311
313{
314 if( m_part )
315 return m_part->GetDescription();
316
317 return wxEmptyString;
318}
319
320
322{
323 if( m_part )
324 return m_part->GetKeyWords();
325
326 return wxEmptyString;
327}
328
329
331{
332 if( m_part )
333 return m_part->GetDatasheetField().GetText();
334
335 return wxEmptyString;
336}
337
338
340{
341 std::map<wxString, wxString> altPinMap;
342 std::map<wxString, KIID> pinUuidMap;
343
344 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
345 {
346 pinUuidMap[ pin->GetNumber() ] = pin->m_Uuid;
347
348 if( !pin->GetAlt().IsEmpty() )
349 altPinMap[ pin->GetNumber() ] = pin->GetAlt();
350 }
351
352 m_pins.clear();
353 m_pinMap.clear();
354
355 if( !m_part )
356 return;
357
358 unsigned i = 0;
359
360 std::vector<LIB_PIN*> pins = m_part->GetAllLibPins();
361
362 for( LIB_PIN* libPin : pins )
363 {
364 // NW: Don't filter by unit: this data-structure is used for all instances,
365 // some if which might have different units.
366 if( libPin->GetConvert() && m_convert && m_convert != libPin->GetConvert() )
367 continue;
368
369 m_pins.push_back( std::make_unique<SCH_PIN>( libPin, this ) );
370
371 auto ii = pinUuidMap.find( libPin->GetNumber() );
372
373 if( ii != pinUuidMap.end() )
374 const_cast<KIID&>( m_pins.back()->m_Uuid ) = ii->second;
375
376 auto iii = altPinMap.find( libPin->GetNumber() );
377
378 if( iii != altPinMap.end() )
379 m_pins.back()->SetAlt( iii->second );
380
381 m_pinMap[ libPin ] = i;
382
383 ++i;
384 }
385}
386
387
388void SCH_SYMBOL::SetUnit( int aUnit )
389{
390 if( m_unit != aUnit )
391 {
392 UpdateUnit( aUnit );
393 SetModified();
394 }
395}
396
397
398void SCH_SYMBOL::UpdateUnit( int aUnit )
399{
400 m_unit = aUnit;
401}
402
403
404void SCH_SYMBOL::SetConvert( int aConvert )
405{
406 if( m_convert != aConvert )
407 {
408 m_convert = aConvert;
409
410 // The convert may have a different pin layout so the update the pin map.
411 UpdatePins();
412 SetModified();
413 }
414}
415
416
417void SCH_SYMBOL::SetTransform( const TRANSFORM& aTransform )
418{
419 if( m_transform != aTransform )
420 {
421 m_transform = aTransform;
422 SetModified();
423 }
424}
425
426
428{
429 if( m_part )
430 return m_part->GetUnitCount();
431
432 return 0;
433}
434
435
437{
438 wxCHECK( m_part, ( wxString::Format( _( "Unit %s" ), LIB_SYMBOL::SubReference( aUnit ) ) ) );
439
440 return m_part->GetUnitDisplayName( aUnit );
441}
442
443
445{
446 wxCHECK( m_part, false );
447
448 return m_part->HasUnitDisplayName( aUnit );
449}
450
451
452void SCH_SYMBOL::PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
453{
455 opts.transform = m_transform;
456 opts.draw_visible_fields = false;
457 opts.draw_hidden_fields = false;
458
459 if( m_part )
460 m_part->PrintBackground( aSettings, m_pos + aOffset, m_unit, m_convert, opts, GetDNP() );
461}
462
463
464void SCH_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
465{
467 opts.transform = m_transform;
468 opts.draw_visible_fields = false;
469 opts.draw_hidden_fields = false;
470
471 if( m_part )
472 {
473 LIB_PINS libPins;
474 m_part->GetPins( libPins, m_unit, m_convert );
475
476 LIB_SYMBOL tempSymbol( *m_part );
477 LIB_PINS tempPins;
478 tempSymbol.GetPins( tempPins, m_unit, m_convert );
479
480 // Copy the pin info from the symbol to the temp pins
481 for( unsigned i = 0; i < tempPins.size(); ++ i )
482 {
483 SCH_PIN* symbolPin = GetPin( libPins[ i ] );
484 LIB_PIN* tempPin = tempPins[ i ];
485
486 tempPin->SetName( symbolPin->GetShownName() );
487 tempPin->SetType( symbolPin->GetType() );
488 tempPin->SetShape( symbolPin->GetShape() );
489 }
490
491 tempSymbol.Print( aSettings, m_pos + aOffset, m_unit, m_convert, opts, GetDNP() );
492 }
493 else // Use dummy() part if the actual cannot be found.
494 {
495 dummy()->Print( aSettings, m_pos + aOffset, 0, 0, opts, GetDNP() );
496 }
497
498 for( SCH_FIELD& field : m_fields )
499 field.Print( aSettings, aOffset );
500
501 if( m_DNP )
502 {
504 wxDC* DC = aSettings->GetPrintDC();
505 COLOR4D dnp_color = aSettings->GetLayerColor( LAYER_ERC_ERR );
506
507 GRFilledSegment( DC, bbox.GetOrigin(), bbox.GetEnd(),
509 dnp_color );
510
511 GRFilledSegment( DC, bbox.GetOrigin() + VECTOR2I( bbox.GetWidth(), 0 ),
512 bbox.GetOrigin() + VECTOR2I( 0, bbox.GetHeight() ),
514 dnp_color );
515 }
516}
517
518
520 const KIID_PATH& aSheetPath, bool aTestFromEnd ) const
521{
522 for( const SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
523 {
524 if( !aTestFromEnd )
525 {
526 if( instance.m_Path == aSheetPath )
527 {
528 aInstance = instance;
529 return true;
530 }
531 }
532 else if( instance.m_Path.EndsWith( aSheetPath ) )
533 {
534 aInstance = instance;
535 return true;
536 }
537 }
538
539 return false;
540}
541
542
543void SCH_SYMBOL::RemoveInstance( const SCH_SHEET_PATH& aInstancePath )
544{
545 // Search for an existing path and remove it if found (should not occur)
546 for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
547 {
548 if( m_instanceReferences[ii].m_Path == aInstancePath.Path() )
549 {
550 wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
551 " sheet path %s\n"
552 " reference %s, unit %d from symbol %s.",
553 aInstancePath.Path().AsString(),
554 m_instanceReferences[ii].m_Reference,
555 m_instanceReferences[ii].m_Unit,
556 m_Uuid.AsString() );
557
558 m_instanceReferences.erase( m_instanceReferences.begin() + ii );
559 ii--;
560 }
561 }
562}
563
564
565void SCH_SYMBOL::SortInstances( bool (*aSortFunction)( const SCH_SYMBOL_INSTANCE& aLhs,
566 const SCH_SYMBOL_INSTANCE& aRhs ) )
567{
568 std::sort( m_instanceReferences.begin(), m_instanceReferences.end(), aSortFunction );
569}
570
571
572void SCH_SYMBOL::AddHierarchicalReference( const KIID_PATH& aPath, const wxString& aRef, int aUnit )
573{
574 // Search for an existing path and remove it if found (should not occur)
575 for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
576 {
577 if( m_instanceReferences[ii].m_Path == aPath )
578 {
579 wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
580 " sheet path %s\n"
581 " reference %s, unit %d from symbol %s.",
582 aPath.AsString(),
583 m_instanceReferences[ii].m_Reference,
584 m_instanceReferences[ii].m_Unit,
585 m_Uuid.AsString() );
586
587 m_instanceReferences.erase( m_instanceReferences.begin() + ii );
588 ii--;
589 }
590 }
591
592 SCH_SYMBOL_INSTANCE instance;
593 instance.m_Path = aPath;
594 instance.m_Reference = aRef;
595 instance.m_Unit = aUnit;
596
597 wxLogTrace( traceSchSheetPaths,
598 "Adding symbol '%s' instance:\n"
599 " sheet path '%s'\n"
600 " reference '%s'\n"
601 " unit %d\n",
603 aPath.AsString(),
604 aRef,
605 aUnit );
606
607 m_instanceReferences.push_back( instance );
608
609 // This should set the default instance to the first saved instance data for each symbol
610 // when importing sheets.
611 if( m_instanceReferences.size() == 1 )
612 {
613 m_fields[ REFERENCE_FIELD ].SetText( aRef );
614 m_unit = aUnit;
615 }
616}
617
618
620{
621 KIID_PATH searchPath( aInstance.m_Path );
622
623 std::vector<SCH_SYMBOL_INSTANCE>::iterator resultIt;
624
625 do
626 {
627 resultIt = std::find_if( m_instanceReferences.begin(), m_instanceReferences.end(),
628 [searchPath]( const auto& it )
629 {
630 return it.m_Path == searchPath;
631 } );
632
633 if( resultIt != m_instanceReferences.end() )
634 {
635 wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
636 " sheet path %s\n"
637 " reference %s, unit %d from symbol %s.",
638 aInstance.m_Path.AsString(),
639 resultIt->m_Reference,
640 resultIt->m_Unit,
641 m_Uuid.AsString() );
642
643 // Instance data should be unique by path. Double check just in case there was
644 // some buggy code in the past.
645 resultIt = m_instanceReferences.erase( resultIt );
646 }
647 }
648 while( resultIt != m_instanceReferences.end() );
649
650 SCH_SYMBOL_INSTANCE instance = aInstance;
651
652 wxLogTrace( traceSchSheetPaths,
653 "Adding symbol '%s' instance:\n"
654 " sheet path '%s'\n"
655 " reference '%s'\n"
656 " unit %d\n",
658 instance.m_Path.AsString(),
659 instance.m_Reference,
660 instance.m_Unit );
661
662 m_instanceReferences.push_back( instance );
663
664 // This should set the default instance to the first saved instance data for each symbol
665 // when importing sheets.
666 if( m_instanceReferences.size() == 1 )
667 {
668 m_fields[ REFERENCE_FIELD ].SetText( instance.m_Reference );
669 m_unit = instance.m_Unit;
670 }
671}
672
673
674const wxString SCH_SYMBOL::GetRef( const SCH_SHEET_PATH* sheet, bool aIncludeUnit ) const
675{
676 KIID_PATH path = sheet->Path();
677 wxString ref;
678 wxString subRef;
679
680 for( const SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
681 {
682 if( instance.m_Path == path )
683 {
684 ref = instance.m_Reference;
685 subRef = LIB_SYMBOL::SubReference( instance.m_Unit );
686 break;
687 }
688 }
689
690 // If it was not found in m_Paths array, then see if it is in m_Field[REFERENCE] -- if so,
691 // use this as a default for this path. This will happen if we load a version 1 schematic
692 // file. It will also mean that multiple instances of the same sheet by default all have
693 // the same symbol references, but perhaps this is best.
694 if( ref.IsEmpty() && !GetField( REFERENCE_FIELD )->GetText().IsEmpty() )
695 {
696 const_cast<SCH_SYMBOL*>( this )->SetRef( sheet, GetField( REFERENCE_FIELD )->GetText() );
697 ref = GetField( REFERENCE_FIELD )->GetText();
698 }
699
700 if( ref.IsEmpty() )
702
703 if( aIncludeUnit && GetUnitCount() > 1 )
704 ref += subRef;
705
706 return ref;
707}
708
709
710bool SCH_SYMBOL::IsReferenceStringValid( const wxString& aReferenceString )
711{
712 return !UTIL::GetRefDesPrefix( aReferenceString ).IsEmpty();
713}
714
715
716void SCH_SYMBOL::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
717{
718 KIID_PATH path = sheet->Path();
719 bool found = false;
720
721 // check to see if it is already there before inserting it
723 {
724 if( instance.m_Path == path )
725 {
726 found = true;
727 instance.m_Reference = ref;
728 break;
729 }
730 }
731
732 if( !found )
734
735 for( std::unique_ptr<SCH_PIN>& pin : m_pins )
736 pin->ClearDefaultNetName( sheet );
737
738 if( Schematic() && *sheet == Schematic()->CurrentSheet() )
739 m_fields[ REFERENCE_FIELD ].SetText( ref );
740
741 // Reinit the m_prefix member if needed
743
744 if( m_prefix.IsEmpty() )
745 m_prefix = wxT( "U" );
746
747 // Power symbols have references starting with # and are not included in netlists
748 m_isInNetlist = ! ref.StartsWith( wxT( "#" ) );
749}
750
751
753{
754 KIID_PATH path = aSheet->Path();
755
756 for( const SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
757 {
758 if( instance.m_Path == path )
759 return instance.m_Reference.Last() != '?';
760 }
761
762 return false;
763}
764
765
767{
768 wxString refDesignator = GetField( REFERENCE_FIELD )->GetText();
769
770 refDesignator.Replace( "~", " " );
771
772 wxString prefix = refDesignator;
773
774 while( prefix.Length() )
775 {
776 wxUniCharRef last = prefix.Last();
777
778 if( ( last >= '0' && last <= '9' ) || last == '?' || last == '*' )
779 prefix.RemoveLast();
780 else
781 break;
782 }
783
784 // Avoid a prefix containing trailing/leading spaces
785 prefix.Trim( true );
786 prefix.Trim( false );
787
788 if( !prefix.IsEmpty() )
789 SetPrefix( prefix );
790}
791
792
794{
795 KIID_PATH path = aSheet->Path();
796
797 for( const SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
798 {
799 if( instance.m_Path == path )
800 return instance.m_Unit;
801 }
802
803 // If it was not found in m_Paths array, then use m_unit. This will happen if we load a
804 // version 1 schematic file.
805 return m_unit;
806}
807
808
809void SCH_SYMBOL::SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection )
810{
811 KIID_PATH path = aSheet->Path();
812
813 // check to see if it is already there before inserting it
815 {
816 if( instance.m_Path == path )
817 {
818 instance.m_Unit = aUnitSelection;
819 return;
820 }
821 }
822
823 // didn't find it; better add it
825}
826
827
828void SCH_SYMBOL::SetUnitSelection( int aUnitSelection )
829{
831 instance.m_Unit = aUnitSelection;
832}
833
834
835const wxString SCH_SYMBOL::GetValueFieldText( bool aResolve ) const
836{
837 if( aResolve )
838 return GetField( VALUE_FIELD )->GetShownText();
839
840 return GetField( VALUE_FIELD )->GetText();
841}
842
843
844void SCH_SYMBOL::SetValueFieldText( const wxString& aValue )
845{
846 m_fields[ VALUE_FIELD ].SetText( aValue );
847}
848
849
850const wxString SCH_SYMBOL::GetFootprintFieldText( bool aResolve ) const
851{
852 if( aResolve )
854
855 return GetField( FOOTPRINT_FIELD )->GetText();
856}
857
858
859void SCH_SYMBOL::SetFootprintFieldText( const wxString& aFootprint )
860{
861 m_fields[ FOOTPRINT_FIELD ].SetText( aFootprint );
862}
863
864
866{
867 return &m_fields[aFieldType];
868}
869
870
872{
873 return &m_fields[aFieldType];
874}
875
876
878{
879 for( size_t ii = 0; ii < m_fields.size(); ++ii )
880 {
881 if( m_fields[ii].GetId() == aFieldId )
882 return &m_fields[ii];
883 }
884
885 return nullptr;
886}
887
888
889wxString SCH_SYMBOL::GetFieldText( const wxString& aFieldName ) const
890{
891 for( const SCH_FIELD& field : m_fields )
892 {
893 if( aFieldName == field.GetName() || aFieldName == field.GetCanonicalName() )
894 return field.GetText();
895 }
896
897 return wxEmptyString;
898}
899
900
901void SCH_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly )
902{
903 for( SCH_FIELD& field : m_fields )
904 {
905 if( aVisibleOnly )
906 {
907 if( !field.IsVisible() || field.GetShownText().IsEmpty() )
908 continue;
909 }
910
911 aVector.push_back( &field );
912 }
913}
914
915
917{
918 int newNdx = m_fields.size();
919
920 m_fields.push_back( aField );
921 return &m_fields[newNdx];
922}
923
924
925void SCH_SYMBOL::RemoveField( const wxString& aFieldName )
926{
927 for( unsigned i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
928 {
929 if( aFieldName == m_fields[i].GetName( false ) )
930 {
931 m_fields.erase( m_fields.begin() + i );
932 return;
933 }
934 }
935}
936
937
938SCH_FIELD* SCH_SYMBOL::FindField( const wxString& aFieldName, bool aIncludeDefaultFields )
939{
940 unsigned start = aIncludeDefaultFields ? 0 : MANDATORY_FIELDS;
941
942 for( unsigned i = start; i < m_fields.size(); ++i )
943 {
944 if( aFieldName == m_fields[i].GetName( false ) )
945 return &m_fields[i];
946 }
947
948 return nullptr;
949}
950
951
952void SCH_SYMBOL::UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, bool aUpdateRef,
953 bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields )
954{
955 if( m_part )
956 {
957 std::vector<LIB_FIELD*> fields;
958
959 m_part->GetFields( fields );
960
961 for( const LIB_FIELD* libField : fields )
962 {
963 int id = libField->GetId();
964 SCH_FIELD* schField;
965
966 if( id >= 0 && id < MANDATORY_FIELDS )
967 {
968 schField = GetFieldById( id );
969 }
970 else
971 {
972 schField = FindField( libField->GetCanonicalName() );
973
974 if( !schField )
975 {
976 wxString fieldName = libField->GetCanonicalName();
977 SCH_FIELD newField( VECTOR2I( 0, 0 ), GetFieldCount(), this, fieldName );
978 schField = AddField( newField );
979 }
980 }
981
982 if( aUpdateStyle )
983 {
984 schField->ImportValues( *libField );
985 schField->SetTextPos( m_pos + libField->GetTextPos() );
986 }
987
988 if( id == REFERENCE_FIELD && aPath )
989 {
990 if( aResetRef )
991 SetRef( aPath, m_part->GetReferenceField().GetText() );
992 else if( aUpdateRef )
993 SetRef( aPath, libField->GetText() );
994 }
995 else if( id == VALUE_FIELD )
996 {
997 SetValueFieldText( UnescapeString( libField->GetText() ) );
998 }
999 else if( id == FOOTPRINT_FIELD )
1000 {
1001 if( aResetOtherFields || aUpdateOtherFields )
1002 SetFootprintFieldText( libField->GetText() );
1003 }
1004 else if( id == DATASHEET_FIELD )
1005 {
1006 if( aResetOtherFields )
1007 schField->SetText( GetDatasheet() ); // alias-specific value
1008 else if( aUpdateOtherFields )
1009 schField->SetText( libField->GetText() );
1010 }
1011 else
1012 {
1013 if( aResetOtherFields || aUpdateOtherFields )
1014 schField->SetText( libField->GetText() );
1015 }
1016 }
1017 }
1018}
1019
1020
1021void SCH_SYMBOL::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction )
1022{
1023 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1024 aFunction( pin.get() );
1025
1026 for( SCH_FIELD& field : m_fields )
1027 aFunction( &field );
1028}
1029
1030
1031SCH_PIN* SCH_SYMBOL::GetPin( const wxString& aNumber ) const
1032{
1033 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1034 {
1035 if( pin->GetNumber() == aNumber )
1036 return pin.get();
1037 }
1038
1039 return nullptr;
1040}
1041
1042
1043void SCH_SYMBOL::GetLibPins( std::vector<LIB_PIN*>& aPinsList ) const
1044{
1045 if( m_part )
1046 m_part->GetPins( aPinsList, m_unit, m_convert );
1047}
1048
1049
1050std::vector<LIB_PIN*> SCH_SYMBOL::GetAllLibPins() const
1051{
1052 std::vector<LIB_PIN*> pinList;
1053
1054 if( m_part )
1055 m_part->GetPins( pinList, 0, 0 );
1056
1057 return pinList;
1058}
1059
1060
1062{
1063 wxASSERT( m_pinMap.count( aLibPin ) );
1064 return m_pins[ m_pinMap.at( aLibPin ) ].get();
1065}
1066
1067
1068std::vector<SCH_PIN*> SCH_SYMBOL::GetPins( const SCH_SHEET_PATH* aSheet ) const
1069{
1070 std::vector<SCH_PIN*> pins;
1071
1072 if( aSheet == nullptr )
1073 {
1074 wxCHECK_MSG( Schematic(), pins, "Can't call GetPins on a symbol with no schematic" );
1075
1076 aSheet = &Schematic()->CurrentSheet();
1077 }
1078
1079 int unit = GetUnitSelection( aSheet );
1080
1081 for( const std::unique_ptr<SCH_PIN>& p : m_pins )
1082 {
1083 if( unit && p->GetLibPin()->GetUnit() && ( p->GetLibPin()->GetUnit() != unit ) )
1084 continue;
1085
1086 pins.push_back( p.get() );
1087 }
1088
1089 return pins;
1090}
1091
1092
1094{
1095 wxCHECK_RET( aItem != nullptr && aItem->Type() == SCH_SYMBOL_T,
1096 wxT( "Cannot swap data with invalid symbol." ) );
1097
1098 SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
1099
1100 std::swap( m_lib_id, symbol->m_lib_id );
1101
1102 LIB_SYMBOL* libSymbol = symbol->m_part.release();
1103 symbol->m_part = std::move( m_part );
1104 symbol->UpdatePins();
1105 m_part.reset( libSymbol );
1106 UpdatePins();
1107
1108 std::swap( m_pos, symbol->m_pos );
1109 std::swap( m_unit, symbol->m_unit );
1110 std::swap( m_convert, symbol->m_convert );
1111
1112 m_fields.swap( symbol->m_fields ); // std::vector's swap()
1113
1114 for( SCH_FIELD& field : symbol->m_fields )
1115 field.SetParent( symbol );
1116
1117 for( SCH_FIELD& field : m_fields )
1118 field.SetParent( this );
1119
1120 TRANSFORM tmp = m_transform;
1121
1122 m_transform = symbol->m_transform;
1123 symbol->m_transform = tmp;
1124
1125 std::swap( m_inBom, symbol->m_inBom );
1126 std::swap( m_DNP, symbol->m_DNP );
1127 std::swap( m_onBoard, symbol->m_onBoard );
1128
1129 std::swap( m_instanceReferences, symbol->m_instanceReferences );
1130 std::swap( m_schLibSymbolName, symbol->m_schLibSymbolName );
1131}
1132
1133
1134void SCH_SYMBOL::GetContextualTextVars( wxArrayString* aVars ) const
1135{
1136 for( int i = 0; i < MANDATORY_FIELDS; ++i )
1137 aVars->push_back( m_fields[i].GetCanonicalName().Upper() );
1138
1139 for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
1140 aVars->push_back( m_fields[i].GetName() );
1141
1142 aVars->push_back( wxT( "OP" ) );
1143 aVars->push_back( wxT( "FOOTPRINT_LIBRARY" ) );
1144 aVars->push_back( wxT( "FOOTPRINT_NAME" ) );
1145 aVars->push_back( wxT( "UNIT" ) );
1146 aVars->push_back( wxT( "SYMBOL_LIBRARY" ) );
1147 aVars->push_back( wxT( "SYMBOL_NAME" ) );
1148 aVars->push_back( wxT( "SYMBOL_DESCRIPTION" ) );
1149 aVars->push_back( wxT( "SYMBOL_KEYWORDS" ) );
1150 aVars->push_back( wxT( "EXCLUDE_FROM_BOM" ) );
1151 aVars->push_back( wxT( "EXCLUDE_FROM_BOARD" ) );
1152 aVars->push_back( wxT( "DNP" ) );
1153}
1154
1155
1156bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth ) const
1157{
1158 static wxRegEx operatingPoint( wxT( "^"
1159 "OP"
1160 "(:[a-zA-Z]*)?" // port
1161 "(.([0-9])?([a-zA-Z]*))?" // format
1162 "$" ) );
1163
1164 SCHEMATIC* schematic = Schematic();
1165
1166 // SCH_SYMOL object has no context outside a schematic.
1167 if( !schematic )
1168 return false;
1169
1170 if( operatingPoint.Matches( *token ) )
1171 {
1172 wxString port( operatingPoint.GetMatch( *token, 1 ) );
1173 wxString precisionStr( operatingPoint.GetMatch( *token, 3 ) );
1174 wxString range( operatingPoint.GetMatch( *token, 4 ) );
1175
1176 wxString signal = GetRef( &schematic->CurrentSheet() ) + port;
1177 int precision = 3;
1178
1179 if( !precisionStr.IsEmpty() )
1180 precision = precisionStr[0] - '0';
1181
1182 if( range.IsEmpty() )
1183 {
1184 if( port == wxS( ":power" ) )
1185 range = wxS( "~W" );
1186 else
1187 range = wxS( "~A" );
1188 }
1189
1190 *token = Schematic()->GetOperatingPoint( signal.Lower(), precision, range );
1191
1192 return true;
1193 }
1194
1195 if( token->Contains( ':' ) )
1196 {
1197 if( schematic->ResolveCrossReference( token, aDepth + 1 ) )
1198 return true;
1199 }
1200
1201 for( int i = 0; i < MANDATORY_FIELDS; ++i )
1202 {
1203 if( token->IsSameAs( m_fields[ i ].GetCanonicalName().Upper() ) )
1204 {
1205 if( i == REFERENCE_FIELD )
1206 *token = GetRef( &schematic->CurrentSheet(), true );
1207 else if( i == VALUE_FIELD )
1208 *token = GetValueFieldText( true );
1209 else if( i == FOOTPRINT_FIELD )
1210 *token = GetFootprintFieldText( true );
1211 else
1212 *token = m_fields[ i ].GetShownText( aDepth + 1 );
1213
1214 return true;
1215 }
1216 }
1217
1218 for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
1219 {
1220 if( token->IsSameAs( m_fields[ i ].GetName() )
1221 || token->IsSameAs( m_fields[ i ].GetName().Upper() ) )
1222 {
1223 *token = m_fields[ i ].GetShownText( aDepth + 1 );
1224 return true;
1225 }
1226 }
1227
1228 for( const TEMPLATE_FIELDNAME& templateFieldname :
1230 {
1231 if( token->IsSameAs( templateFieldname.m_Name )
1232 || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
1233 {
1234 // If we didn't find it in the fields list then it isn't set on this symbol.
1235 // Just return an empty string.
1236 *token = wxEmptyString;
1237 return true;
1238 }
1239 }
1240
1241 if( token->IsSameAs( wxT( "FOOTPRINT_LIBRARY" ) ) )
1242 {
1243 wxString footprint;
1244
1245 footprint = GetFootprintFieldText( true );
1246
1247 wxArrayString parts = wxSplit( footprint, ':' );
1248
1249 *token = parts[ 0 ];
1250 return true;
1251 }
1252 else if( token->IsSameAs( wxT( "FOOTPRINT_NAME" ) ) )
1253 {
1254 wxString footprint;
1255
1256 footprint = GetFootprintFieldText( true );
1257
1258 wxArrayString parts = wxSplit( footprint, ':' );
1259
1260 *token = parts[ std::min( 1, (int) parts.size() - 1 ) ];
1261 return true;
1262 }
1263 else if( token->IsSameAs( wxT( "UNIT" ) ) )
1264 {
1265 int unit;
1266
1267 unit = GetUnitSelection( &schematic->CurrentSheet() );
1268
1269 *token = LIB_SYMBOL::SubReference( unit );
1270 return true;
1271 }
1272 else if( token->IsSameAs( wxT( "SYMBOL_LIBRARY" ) ) )
1273 {
1274 *token = m_lib_id.GetLibNickname();
1275 return true;
1276 }
1277 else if( token->IsSameAs( wxT( "SYMBOL_NAME" ) ) )
1278 {
1279 *token = m_lib_id.GetLibItemName();
1280 return true;
1281 }
1282 else if( token->IsSameAs( wxT( "SYMBOL_DESCRIPTION" ) ) )
1283 {
1284 *token = GetDescription();
1285 return true;
1286 }
1287 else if( token->IsSameAs( wxT( "SYMBOL_KEYWORDS" ) ) )
1288 {
1289 *token = GetKeyWords();
1290 return true;
1291 }
1292 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOM" ) ) )
1293 {
1294 *token = this->GetIncludeInBom() ? wxString( wxT( "" ) )
1295 : _( "Excluded from BOM" );
1296 return true;
1297 }
1298 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOARD" ) ) )
1299 {
1300 *token = this->GetIncludeOnBoard() ? wxString( wxT( "" ) )
1301 : _( "Excluded from board" );
1302 return true;
1303 }
1304 else if( token->IsSameAs( wxT( "DNP" ) ) )
1305 {
1306 *token = this->GetDNP() ? _( "DNP" ) : wxString( wxT( "" ) );
1307 return true;
1308 }
1309
1310 // See if parent can resolve it (this will recurse to ancestors)
1311
1312 if( SCH_SHEET* sheet = schematic->CurrentSheet().Last() )
1313 {
1314 if( sheet->ResolveTextVar( token, aDepth + 1 ) )
1315 return true;
1316 }
1317
1318 return false;
1319}
1320
1321
1322void SCH_SYMBOL::ClearAnnotation( const SCH_SHEET_PATH* aSheetPath, bool aResetPrefix )
1323{
1324 if( aSheetPath )
1325 {
1326 KIID_PATH path = aSheetPath->Path();
1327
1328 for( SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
1329 {
1330 if( instance.m_Path == path )
1331 {
1332 if( instance.m_Reference.IsEmpty() || aResetPrefix )
1333 instance.m_Reference = UTIL::GetRefDesUnannotated( m_prefix );
1334 else
1335 instance.m_Reference = UTIL::GetRefDesUnannotated( instance.m_Reference );
1336 }
1337 }
1338 }
1339 else
1340 {
1341 for( SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
1342 {
1343 if( instance.m_Reference.IsEmpty() || aResetPrefix)
1344 instance.m_Reference = UTIL::GetRefDesUnannotated( m_prefix );
1345 else
1346 instance.m_Reference = UTIL::GetRefDesUnannotated( instance.m_Reference );
1347 }
1348 }
1349
1350 for( std::unique_ptr<SCH_PIN>& pin : m_pins )
1351 pin->ClearDefaultNetName( aSheetPath );
1352
1353 // These 2 changes do not work in complex hierarchy.
1354 // When a clear annotation is made, the calling function must call a
1355 // UpdateAllScreenReferences for the active sheet.
1356 // But this call cannot made here.
1357 wxString currentReference = m_fields[REFERENCE_FIELD].GetText();
1358
1359 if( currentReference.IsEmpty() || aResetPrefix )
1361 else
1362 m_fields[REFERENCE_FIELD].SetText( UTIL::GetRefDesUnannotated( currentReference ) );
1363}
1364
1365
1367{
1368 // An empty sheet path is illegal, at a minimum the root sheet UUID must be present.
1369 wxCHECK( aSheetPath.size() > 0, false );
1370
1371 for( const SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
1372 {
1373 // if aSheetPath is found, nothing to do:
1374 if( instance.m_Path == aSheetPath )
1375 return false;
1376 }
1377
1378 // This entry does not exist: add it, with its last-used reference
1380 return true;
1381}
1382
1383
1385 const KIID_PATH& aNewSheetPath )
1386{
1387 auto it = std::find_if( m_instanceReferences.begin(), m_instanceReferences.end(),
1388 [ aOldSheetPath ]( SCH_SYMBOL_INSTANCE& r )->bool
1389 {
1390 return aOldSheetPath == r.m_Path;
1391 }
1392 );
1393
1394 if( it != m_instanceReferences.end() )
1395 {
1396 wxLogTrace( traceSchSheetPaths,
1397 "Replacing sheet path %s\n with sheet path %s\n for symbol %s.",
1398 aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
1399
1400 it->m_Path = aNewSheetPath;
1401 return true;
1402 }
1403
1404 wxLogTrace( traceSchSheetPaths,
1405 "Could not find sheet path %s\n to replace with sheet path %s\n for symbol %s.",
1406 aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
1407
1408 return false;
1409}
1410
1411
1412void SCH_SYMBOL::SetOrientation( int aOrientation )
1413{
1414 TRANSFORM temp = TRANSFORM();
1415 bool transform = false;
1416
1417 switch( aOrientation )
1418 {
1419 case SYM_ORIENT_0:
1420 case SYM_NORMAL: // default transform matrix
1421 m_transform.x1 = 1;
1422 m_transform.y2 = -1;
1424 break;
1425
1426 case SYM_ROTATE_COUNTERCLOCKWISE: // Rotate + (incremental rotation)
1427 temp.x1 = temp.y2 = 0;
1428 temp.y1 = 1;
1429 temp.x2 = -1;
1430 transform = true;
1431 break;
1432
1433 case SYM_ROTATE_CLOCKWISE: // Rotate - (incremental rotation)
1434 temp.x1 = temp.y2 = 0;
1435 temp.y1 = -1;
1436 temp.x2 = 1;
1437 transform = true;
1438 break;
1439
1440 case SYM_MIRROR_Y: // Mirror Y (incremental rotation)
1441 temp.x1 = -1;
1442 temp.y2 = 1;
1443 temp.y1 = temp.x2 = 0;
1444 transform = true;
1445 break;
1446
1447 case SYM_MIRROR_X: // Mirror X (incremental rotation)
1448 temp.x1 = 1;
1449 temp.y2 = -1;
1450 temp.y1 = temp.x2 = 0;
1451 transform = true;
1452 break;
1453
1454 case SYM_ORIENT_90:
1457 break;
1458
1459 case SYM_ORIENT_180:
1463 break;
1464
1465 case SYM_ORIENT_270:
1468 break;
1469
1470 case ( SYM_ORIENT_0 + SYM_MIRROR_X ):
1473 break;
1474
1475 case ( SYM_ORIENT_0 + SYM_MIRROR_Y ):
1478 break;
1479
1480 case ( SYM_ORIENT_90 + SYM_MIRROR_X ):
1483 break;
1484
1485 case ( SYM_ORIENT_90 + SYM_MIRROR_Y ):
1488 break;
1489
1490 case ( SYM_ORIENT_180 + SYM_MIRROR_X ):
1493 break;
1494
1495 case ( SYM_ORIENT_180 + SYM_MIRROR_Y ):
1498 break;
1499
1500 case ( SYM_ORIENT_270 + SYM_MIRROR_X ):
1503 break;
1504
1505 case ( SYM_ORIENT_270 + SYM_MIRROR_Y ):
1508 break;
1509
1510 default:
1511 transform = false;
1512 wxFAIL_MSG( "Invalid schematic symbol orientation type." );
1513 break;
1514 }
1515
1516 if( transform )
1517 {
1518 /* The new matrix transform is the old matrix transform modified by the
1519 * requested transformation, which is the temp transform (rot,
1520 * mirror ..) in order to have (in term of matrix transform):
1521 * transform coord = new_m_transform * coord
1522 * where transform coord is the coord modified by new_m_transform from
1523 * the initial value coord.
1524 * new_m_transform is computed (from old_m_transform and temp) to
1525 * have:
1526 * transform coord = old_m_transform * temp
1527 */
1528 TRANSFORM newTransform;
1529
1530 newTransform.x1 = m_transform.x1 * temp.x1 + m_transform.x2 * temp.y1;
1531 newTransform.y1 = m_transform.y1 * temp.x1 + m_transform.y2 * temp.y1;
1532 newTransform.x2 = m_transform.x1 * temp.x2 + m_transform.x2 * temp.y2;
1533 newTransform.y2 = m_transform.y1 * temp.x2 + m_transform.y2 * temp.y2;
1534 m_transform = newTransform;
1535 }
1536}
1537
1538
1540{
1541 /*
1542 * This is slow, but also a bizarre algorithm. I don't feel like unteasing the algorithm right
1543 * now, so let's just cache it for the moment.
1544 */
1547
1548 int rotate_values[] =
1549 {
1562 };
1563
1564 // Try to find the current transform option:
1565 TRANSFORM transform = m_transform;
1566 SCH_SYMBOL temp( *this );
1567
1568 for( int type_rotate : rotate_values )
1569 {
1570 temp.SetOrientation( type_rotate );
1571
1572 if( transform == temp.GetTransform() )
1573 {
1575 return type_rotate;
1576 }
1577 }
1578
1579 // Error: orientation not found in list (should not happen)
1580 wxFAIL_MSG( "Schematic symbol orientation matrix internal error." );
1581
1582 return SYM_NORMAL;
1583}
1584
1585
1586#if defined(DEBUG)
1587
1588void SCH_SYMBOL::Show( int nestLevel, std::ostream& os ) const
1589{
1590 // for now, make it look like XML:
1591 NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
1592 << " ref=\"" << TO_UTF8( GetField( REFERENCE_FIELD )->GetName() )
1593 << '"' << " chipName=\""
1594 << GetLibId().Format() << '"' << m_pos
1595 << " layer=\"" << m_layer
1596 << '"' << ">\n";
1597
1598 // skip the reference, it's been output already.
1599 for( int i = 1; i < GetFieldCount(); ++i )
1600 {
1601 const wxString& value = GetFields()[i].GetText();
1602
1603 if( !value.IsEmpty() )
1604 {
1605 NestedSpace( nestLevel + 1, os ) << "<field" << " name=\""
1606 << TO_UTF8( GetFields()[i].GetName() )
1607 << '"' << " value=\""
1608 << TO_UTF8( value ) << "\"/>\n";
1609 }
1610 }
1611
1612 NestedSpace( nestLevel, os ) << "</" << TO_UTF8( GetClass().Lower() ) << ">\n";
1613}
1614
1615#endif
1616
1617
1618BOX2I SCH_SYMBOL::doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const
1619{
1620 BOX2I bBox;
1621
1622 if( m_part )
1623 bBox = m_part->GetBodyBoundingBox( m_unit, m_convert, aIncludePins, false );
1624 else
1625 bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert, aIncludePins, false );
1626
1627 int x0 = bBox.GetX();
1628 int xm = bBox.GetRight();
1629
1630 // We must reverse Y values, because matrix orientation
1631 // suppose Y axis normal for the library items coordinates,
1632 // m_transform reverse Y values, but bBox is already reversed!
1633 int y0 = -bBox.GetY();
1634 int ym = -bBox.GetBottom();
1635
1636 // Compute the real Boundary box (rotated, mirrored ...)
1637 int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
1638 int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
1639 int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
1640 int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
1641
1642 bBox.SetX( x1 );
1643 bBox.SetY( y1 );
1644 bBox.SetWidth( x2 - x1 );
1645 bBox.SetHeight( y2 - y1 );
1646 bBox.Normalize();
1647
1648 bBox.Offset( m_pos );
1649
1650 if( aIncludeFields )
1651 {
1652 for( const SCH_FIELD& field : m_fields )
1653 {
1654 if( field.IsVisible() )
1655 bBox.Merge( field.GetBoundingBox() );
1656 }
1657 }
1658
1659 return bBox;
1660}
1661
1662
1664{
1665 return doGetBoundingBox( false, false );
1666}
1667
1668
1670{
1671 return doGetBoundingBox( true, false );
1672}
1673
1674
1676{
1677 return doGetBoundingBox( true, true );
1678}
1679
1680
1681void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1682{
1683 wxString msg;
1684
1685 SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
1686 SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
1687
1688 // part and alias can differ if alias is not the root
1689 if( m_part )
1690 {
1691 if( m_part.get() != dummy() )
1692 {
1693 if( m_part->IsPower() )
1694 {
1695 aList.emplace_back( _( "Power symbol" ), GetValueFieldText( true ) );
1696 }
1697 else
1698 {
1699 aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
1700 aList.emplace_back( _( "Value" ), GetValueFieldText( true ) );
1701 aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) );
1702 }
1703
1704#if 0 // Display symbol flags, for debug only
1705 aList.emplace_back( _( "flags" ), wxString::Format( "%X", GetEditFlags() ) );
1706#endif
1707
1708 if( !m_part->IsRoot() )
1709 {
1710 msg = _( "Missing parent" );
1711
1712 std::shared_ptr< LIB_SYMBOL > parent = m_part->GetParent().lock();
1713
1714 if( parent )
1715 msg = parent->GetName();
1716
1717 aList.emplace_back( _( "Derived from" ), UnescapeString( msg ) );
1718 }
1719 else if( !m_lib_id.GetLibNickname().empty() )
1720 {
1721 aList.emplace_back( _( "Library" ), m_lib_id.GetLibNickname() );
1722 }
1723 else
1724 {
1725 aList.emplace_back( _( "Library" ), _( "Undefined!!!" ) );
1726 }
1727
1728 // Display the current associated footprint, if exists.
1729 msg = GetFootprintFieldText( true );
1730
1731 if( msg.IsEmpty() )
1732 msg = _( "<Unknown>" );
1733
1734 aList.emplace_back( _( "Footprint" ), msg );
1735
1736 // Display description of the symbol, and keywords found in lib
1737 aList.emplace_back( _( "Description" ), m_part->GetDescription() );
1738 aList.emplace_back( _( "Keywords" ), m_part->GetKeyWords() );
1739 }
1740 }
1741 else
1742 {
1743 aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
1744
1745 aList.emplace_back( _( "Value" ), GetValueFieldText( true ) );
1746 aList.emplace_back( _( "Name" ), GetLibId().GetLibItemName() );
1747
1748 wxString libNickname = GetLibId().GetLibNickname();
1749
1750 if( libNickname.empty() )
1751 msg = _( "No library defined!" );
1752 else
1753 msg.Printf( _( "Symbol not found in %s!" ), libNickname );
1754
1755 aList.emplace_back( _( "Library" ), msg );
1756 }
1757}
1758
1759
1761{
1763}
1764
1765
1767{
1768 int dx = m_pos.x;
1769
1771 MIRROR( m_pos.x, aCenter );
1772 dx -= m_pos.x; // dx,0 is the move vector for this transform
1773
1774 for( SCH_FIELD& field : m_fields )
1775 {
1776 // Move the fields to the new position because the symbol itself has moved.
1777 VECTOR2I pos = field.GetTextPos();
1778 pos.x -= dx;
1779 field.SetTextPos( pos );
1780 }
1781}
1782
1783
1785{
1786 int dy = m_pos.y;
1787
1789 MIRROR( m_pos.y, aCenter );
1790 dy -= m_pos.y; // 0,dy is the move vector for this transform
1791
1792 for( SCH_FIELD& field : m_fields )
1793 {
1794 // Move the fields to the new position because the symbol itself has moved.
1795 VECTOR2I pos = field.GetTextPos();
1796 pos.y -= dy;
1797 field.SetTextPos( pos );
1798 }
1799}
1800
1801
1802void SCH_SYMBOL::Rotate( const VECTOR2I& aCenter )
1803{
1804 VECTOR2I prev = m_pos;
1805
1806 RotatePoint( m_pos, aCenter, ANGLE_90 );
1807
1809
1810 for( SCH_FIELD& field : m_fields )
1811 {
1812 // Move the fields to the new position because the symbol itself has moved.
1813 VECTOR2I pos = field.GetTextPos();
1814 pos.x -= prev.x - m_pos.x;
1815 pos.y -= prev.y - m_pos.y;
1816 field.SetTextPos( pos );
1817 }
1818}
1819
1820
1821bool SCH_SYMBOL::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
1822{
1823 // Symbols are searchable via the child field and pin item text.
1824 return false;
1825}
1826
1827
1828void SCH_SYMBOL::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
1829{
1830 for( auto& pin : m_pins )
1831 {
1832 LIB_PIN* lib_pin = pin->GetLibPin();
1833
1834 if( lib_pin->GetUnit() && m_unit && ( m_unit != lib_pin->GetUnit() ) )
1835 continue;
1836
1837 DANGLING_END_ITEM item( PIN_END, lib_pin, GetPinPhysicalPosition( lib_pin ), this );
1838 aItemList.push_back( item );
1839 }
1840}
1841
1842
1843bool SCH_SYMBOL::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
1844 const SCH_SHEET_PATH* aPath )
1845{
1846 bool changed = false;
1847
1848 for( std::unique_ptr<SCH_PIN>& pin : m_pins )
1849 {
1850 bool previousState = pin->IsDangling();
1851 pin->SetIsDangling( true );
1852
1853 VECTOR2I pos = m_transform.TransformCoordinate( pin->GetLocalPosition() ) + m_pos;
1854
1855 for( DANGLING_END_ITEM& each_item : aItemList )
1856 {
1857 // Some people like to stack pins on top of each other in a symbol to indicate
1858 // internal connection. While technically connected, it is not particularly useful
1859 // to display them that way, so skip any pins that are in the same symbol as this
1860 // one.
1861 if( each_item.GetParent() == this )
1862 continue;
1863
1864 switch( each_item.GetType() )
1865 {
1866 case PIN_END:
1867 case LABEL_END:
1868 case SHEET_LABEL_END:
1869 case WIRE_END:
1870 case NO_CONNECT_END:
1871 case JUNCTION_END:
1872
1873 if( pos == each_item.GetPosition() )
1874 pin->SetIsDangling( false );
1875
1876 break;
1877
1878 default:
1879 break;
1880 }
1881
1882 if( !pin->IsDangling() )
1883 break;
1884 }
1885
1886 changed = ( changed || ( previousState != pin->IsDangling() ) );
1887 }
1888
1889 return changed;
1890}
1891
1892
1894{
1895 wxCHECK_MSG( Pin != nullptr && Pin->Type() == LIB_PIN_T, VECTOR2I( 0, 0 ),
1896 wxT( "Cannot get physical position of pin." ) );
1897
1899}
1900
1901
1902std::vector<VECTOR2I> SCH_SYMBOL::GetConnectionPoints() const
1903{
1904 std::vector<VECTOR2I> retval;
1905
1906 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1907 {
1908 // Collect only pins attached to the current unit and convert.
1909 // others are not associated to this symbol instance
1910 int pin_unit = pin->GetLibPin()->GetUnit();
1911 int pin_convert = pin->GetLibPin()->GetConvert();
1912
1913 if( pin_unit > 0 && pin_unit != GetUnit() )
1914 continue;
1915
1916 if( pin_convert > 0 && pin_convert != GetConvert() )
1917 continue;
1918
1919 retval.push_back( m_transform.TransformCoordinate( pin->GetLocalPosition() ) + m_pos );
1920 }
1921
1922 return retval;
1923}
1924
1925
1927{
1928 if( m_part )
1929 {
1930 // Calculate the position relative to the symbol.
1931 VECTOR2I libPosition = aPosition - m_pos;
1932
1933 return m_part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
1934 }
1935
1936 return nullptr;
1937}
1938
1939
1940wxString SCH_SYMBOL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
1941{
1942 return wxString::Format( _( "Symbol %s [%s]" ),
1943 GetField( REFERENCE_FIELD )->GetShownText(),
1944 UnescapeString( GetLibId().GetLibItemName() ) );
1945}
1946
1947
1948INSPECT_RESULT SCH_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData,
1949 const std::vector<KICAD_T>& aScanTypes )
1950{
1951 for( KICAD_T scanType : aScanTypes )
1952 {
1953 if( scanType == SCH_LOCATE_ANY_T
1954 || ( scanType == SCH_SYMBOL_T )
1955 || ( scanType == SCH_SYMBOL_LOCATE_POWER_T && m_part && m_part->IsPower() ) )
1956 {
1957 if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
1958 return INSPECT_RESULT::QUIT;
1959 }
1960
1961 if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_FIELD_T )
1962 {
1963 for( SCH_FIELD& field : m_fields )
1964 {
1965 if( INSPECT_RESULT::QUIT == aInspector( &field, (void*) this ) )
1966 return INSPECT_RESULT::QUIT;
1967 }
1968 }
1969
1970 if( scanType == SCH_FIELD_LOCATE_REFERENCE_T )
1971 {
1972 if( INSPECT_RESULT::QUIT == aInspector( GetField( REFERENCE_FIELD ), (void*) this ) )
1973 return INSPECT_RESULT::QUIT;
1974 }
1975
1976 if( scanType == SCH_FIELD_LOCATE_VALUE_T
1977 || ( scanType == SCH_SYMBOL_LOCATE_POWER_T && m_part && m_part->IsPower() ) )
1978 {
1979 if( INSPECT_RESULT::QUIT == aInspector( GetField( VALUE_FIELD ), (void*) this ) )
1980 return INSPECT_RESULT::QUIT;
1981 }
1982
1983 if( scanType == SCH_FIELD_LOCATE_FOOTPRINT_T )
1984 {
1985 if( INSPECT_RESULT::QUIT == aInspector( GetField( FOOTPRINT_FIELD ), (void*) this ) )
1986 return INSPECT_RESULT::QUIT;
1987 }
1988
1989 if( scanType == SCH_FIELD_LOCATE_DATASHEET_T )
1990 {
1991 if( INSPECT_RESULT::QUIT == aInspector( GetField( DATASHEET_FIELD ), (void*) this ) )
1992 return INSPECT_RESULT::QUIT;
1993 }
1994
1995 if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_PIN_T )
1996 {
1997 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1998 {
1999 // Collect only pins attached to the current unit and convert.
2000 // others are not associated to this symbol instance
2001 int pin_unit = pin->GetLibPin()->GetUnit();
2002 int pin_convert = pin->GetLibPin()->GetConvert();
2003
2004 if( pin_unit > 0 && pin_unit != GetUnit() )
2005 continue;
2006
2007 if( pin_convert > 0 && pin_convert != GetConvert() )
2008 continue;
2009
2010 if( INSPECT_RESULT::QUIT == aInspector( pin.get(), (void*) this ) )
2011 return INSPECT_RESULT::QUIT;
2012 }
2013 }
2014 }
2015
2017}
2018
2019
2020bool SCH_SYMBOL::operator <( const SCH_ITEM& aItem ) const
2021{
2022 if( Type() != aItem.Type() )
2023 return Type() < aItem.Type();
2024
2025 auto symbol = static_cast<const SCH_SYMBOL*>( &aItem );
2026
2028
2029 if( rect.GetArea() != symbol->GetBodyAndPinsBoundingBox().GetArea() )
2030 return rect.GetArea() < symbol->GetBodyAndPinsBoundingBox().GetArea();
2031
2032 if( m_pos.x != symbol->m_pos.x )
2033 return m_pos.x < symbol->m_pos.x;
2034
2035 if( m_pos.y != symbol->m_pos.y )
2036 return m_pos.y < symbol->m_pos.y;
2037
2038 return m_Uuid < aItem.m_Uuid; // Ensure deterministic sort
2039}
2040
2041
2042bool SCH_SYMBOL::operator==( const SCH_SYMBOL& aSymbol ) const
2043{
2044 if( GetFieldCount() != aSymbol.GetFieldCount() )
2045 return false;
2046
2047 for( int i = VALUE_FIELD; i < GetFieldCount(); i++ )
2048 {
2049 if( GetFields()[i].GetText().Cmp( aSymbol.GetFields()[i].GetText() ) != 0 )
2050 return false;
2051 }
2052
2053 return true;
2054}
2055
2056
2057bool SCH_SYMBOL::operator!=( const SCH_SYMBOL& aSymbol ) const
2058{
2059 return !( *this == aSymbol );
2060}
2061
2062
2064{
2065 wxCHECK_MSG( Type() == aItem.Type(), *this,
2066 wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
2067 GetClass() );
2068
2069 if( &aItem != this )
2070 {
2071 SCH_ITEM::operator=( aItem );
2072
2073 SCH_SYMBOL* c = (SCH_SYMBOL*) &aItem;
2074
2075 m_lib_id = c->m_lib_id;
2076
2077 LIB_SYMBOL* libSymbol = c->m_part ? new LIB_SYMBOL( *c->m_part.get() ) : nullptr;
2078
2079 m_part.reset( libSymbol );
2080 m_pos = c->m_pos;
2081 m_unit = c->m_unit;
2082 m_convert = c->m_convert;
2084
2086
2087 m_fields = c->m_fields; // std::vector's assignment operator
2088
2089 // Reparent fields after assignment to new symbol.
2090 for( SCH_FIELD& field : m_fields )
2091 field.SetParent( this );
2092
2093 UpdatePins();
2094 }
2095
2096 return *this;
2097}
2098
2099
2100bool SCH_SYMBOL::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
2101{
2102 BOX2I bBox = GetBodyBoundingBox();
2103 bBox.Inflate( aAccuracy / 2 );
2104
2105 if( bBox.Contains( aPosition ) )
2106 return true;
2107
2108 return false;
2109}
2110
2111
2112bool SCH_SYMBOL::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
2113{
2115 return false;
2116
2117 BOX2I rect = aRect;
2118
2119 rect.Inflate( aAccuracy / 2 );
2120
2121 if( aContained )
2122 return rect.Contains( GetBodyBoundingBox() );
2123
2124 return rect.Intersects( GetBodyBoundingBox() );
2125}
2126
2127
2128bool SCH_SYMBOL::doIsConnected( const VECTOR2I& aPosition ) const
2129{
2131
2132 for( const auto& pin : m_pins )
2133 {
2134 if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
2135 continue;
2136
2137 // Collect only pins attached to the current unit and convert.
2138 // others are not associated to this symbol instance
2139 int pin_unit = pin->GetLibPin()->GetUnit();
2140 int pin_convert = pin->GetLibPin()->GetConvert();
2141
2142 if( pin_unit > 0 && pin_unit != GetUnit() )
2143 continue;
2144
2145 if( pin_convert > 0 && pin_convert != GetConvert() )
2146 continue;
2147
2148 if( pin->GetLocalPosition() == new_pos )
2149 return true;
2150 }
2151
2152 return false;
2153}
2154
2155
2157{
2158 return m_isInNetlist;
2159}
2160
2161
2162void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const
2163{
2164 if( aBackground )
2165 return;
2166
2167 if( m_part )
2168 {
2169 LIB_PINS libPins;
2170 m_part->GetPins( libPins, GetUnit(), GetConvert() );
2171
2172 // Copy the source so we can re-orient and translate it.
2173 LIB_SYMBOL tempSymbol( *m_part );
2174 LIB_PINS tempPins;
2175 tempSymbol.GetPins( tempPins, GetUnit(), GetConvert() );
2176
2177 // Copy the pin info from the symbol to the temp pins
2178 for( unsigned i = 0; i < tempPins.size(); ++ i )
2179 {
2180 SCH_PIN* symbolPin = GetPin( libPins[ i ] );
2181 LIB_PIN* tempPin = tempPins[ i ];
2182
2183 tempPin->SetName( symbolPin->GetShownName() );
2184 tempPin->SetType( symbolPin->GetType() );
2185 tempPin->SetShape( symbolPin->GetShape() );
2186
2187 if( symbolPin->IsDangling() )
2188 tempPin->SetFlags( IS_DANGLING );
2189 }
2190
2191 TRANSFORM temp = GetTransform();
2192 aPlotter->StartBlock( nullptr );
2193
2194 for( bool local_background : { true, false } )
2195 {
2196 tempSymbol.Plot( aPlotter, GetUnit(), GetConvert(), local_background, m_pos, temp,
2197 GetDNP() );
2198
2199 for( const SCH_FIELD& field : m_fields )
2200 field.Plot( aPlotter, local_background );
2201 }
2202
2203 if( m_DNP )
2204 PlotDNP( aPlotter );
2205
2206 // Plot attributes to a hypertext menu
2207 std::vector<wxString> properties;
2208
2209 for( const SCH_FIELD& field : GetFields() )
2210 {
2211 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
2212 field.GetName(),
2213 field.GetShownText() ) );
2214 }
2215
2216 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
2217 _( "Description" ),
2218 m_part->GetDescription() ) );
2219
2220 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
2221 _( "Keywords" ),
2222 m_part->GetKeyWords() ) );
2223
2224 aPlotter->HyperlinkMenu( GetBoundingBox(), properties );
2225
2226
2227
2228 aPlotter->EndBlock( nullptr );
2229
2230 if( !m_part->IsPower() )
2231 aPlotter->Bookmark( GetBoundingBox(), GetField( REFERENCE_FIELD )->GetShownText(), _("Symbols") );
2232 }
2233}
2234
2235
2236void SCH_SYMBOL::PlotDNP( PLOTTER* aPlotter ) const
2237{
2239
2240 COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
2241
2242 aPlotter->SetColor( colors->GetColor( LAYER_ERC_ERR ) );
2243
2244 aPlotter->ThickSegment( bbox.GetOrigin(), bbox.GetEnd(),
2246 FILLED, nullptr );
2247
2248 aPlotter->ThickSegment( bbox.GetOrigin() + VECTOR2I( bbox.GetWidth(), 0 ),
2249 bbox.GetOrigin() + VECTOR2I( 0, bbox.GetHeight() ),
2251 FILLED, nullptr );
2252}
2253
2254
2255void SCH_SYMBOL::PlotPins( PLOTTER* aPlotter ) const
2256{
2257 if( m_part )
2258 {
2259 LIB_PINS libPins;
2260 m_part->GetPins( libPins, GetUnit(), GetConvert() );
2261
2262 // Copy the source to stay const
2263 LIB_SYMBOL tempSymbol( *m_part );
2264 LIB_PINS tempPins;
2265 tempSymbol.GetPins( tempPins, GetUnit(), GetConvert() );
2266
2267 TRANSFORM transform = GetTransform();
2268
2269 // Copy the pin info from the symbol to the temp pins
2270 for( unsigned i = 0; i < tempPins.size(); ++ i )
2271 {
2272 SCH_PIN* symbolPin = GetPin( libPins[ i ] );
2273 LIB_PIN* tempPin = tempPins[ i ];
2274
2275 tempPin->SetName( symbolPin->GetShownName() );
2276 tempPin->SetType( symbolPin->GetType() );
2277 tempPin->SetShape( symbolPin->GetShape() );
2278 tempPin->Plot( aPlotter, false, m_pos, transform, GetDNP() );
2279 }
2280 }
2281}
2282
2283
2285{
2286 for( const auto& pin : m_pins )
2287 {
2288 if( pin->IsBrightened() )
2289 return true;
2290 }
2291
2292 return false;
2293}
2294
2295
2297{
2298 for( auto& pin : m_pins )
2299 pin->ClearBrightened();
2300}
2301
2302
2304{
2305 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
2306 {
2307 int pin_unit = pin->GetLibPin()->GetUnit();
2308 int pin_convert = pin->GetLibPin()->GetConvert();
2309
2310 if( pin_unit > 0 && pin_unit != GetUnit() )
2311 continue;
2312
2313 if( pin_convert > 0 && pin_convert != GetConvert() )
2314 continue;
2315
2316 if( pin->IsPointClickableAnchor( aPos ) )
2317 return true;
2318 }
2319
2320 return false;
2321}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
double square(double x)
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
@ add_component
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
const Vec & GetOrigin() const
Definition: box2.h:183
void Offset(coord_type dx, coord_type dy)
Definition: box2.h:224
void SetX(coord_type val)
Definition: box2.h:235
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
void SetY(coord_type val)
Definition: box2.h:240
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetY() const
Definition: box2.h:181
coord_type GetWidth() const
Definition: box2.h:187
void SetWidth(coord_type val)
Definition: box2.h:245
const Vec GetEnd() const
Definition: box2.h:185
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
coord_type GetX() const
Definition: box2.h:180
coord_type GetRight() const
Definition: box2.h:189
ecoord_type GetArea() const
Return the area of the rectangle.
Definition: box2.h:701
void SetHeight(coord_type val)
Definition: box2.h:250
coord_type GetBottom() const
Definition: box2.h:190
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:588
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:82
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:145
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
void SetModified()
Definition: eda_item.cpp:64
const KIID m_Uuid
Definition: eda_item.h:492
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:498
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:496
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:373
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:165
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
wxString AsString() const
Definition: kiid.cpp:359
Definition: kiid.h:48
wxString AsString() const
Definition: kiid.cpp:257
Field object used in symbol libraries.
Definition: lib_field.h:61
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
UTF8 Format() const
Definition: lib_id.cpp:117
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
int GetUnit() const
Definition: lib_item.h:273
void SetShape(GRAPHIC_PINSHAPE aShape)
Definition: lib_pin.h:78
void SetName(const wxString &aName)
Definition: lib_pin.h:114
void SetType(ELECTRICAL_PINTYPE aType)
Definition: lib_pin.h:91
VECTOR2I GetPosition() const override
Definition: lib_pin.h:228
void Plot(PLOTTER *aPlotter, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const override
Plot the draw item using the plot object.
Definition: lib_pin.cpp:1148
Define a library symbol object.
Definition: lib_symbol.h:99
void Plot(PLOTTER *aPlotter, int aUnit, int aConvert, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const
Plot lib symbol to plotter.
Definition: lib_symbol.cpp:702
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:187
bool GetIncludeOnBoard() const
Definition: lib_symbol.h:649
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:820
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:581
const BOX2I GetBodyBoundingBox(int aUnit, int aConvert, bool aIncludePins, bool aIncludePrivateItems) const
Get the symbol bounding box excluding fields.
Definition: lib_symbol.cpp:994
bool GetIncludeInBom() const
Definition: lib_symbol.h:641
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0) const
Return a list of pin object pointers from the draw item list.
Definition: lib_symbol.cpp:831
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:453
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, int aMulti, int aConvert, const LIB_SYMBOL_OPTIONS &aOpts, bool aDimmed)
Print symbol.
Definition: lib_symbol.cpp:651
Define a symbol library graphical text item.
Definition: lib_text.h:40
Base plotter engine class.
Definition: plotter.h:110
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:549
virtual void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
Create a bookmark to a symbol.
Definition: plotter.h:477
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
Definition: plotter.h:538
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Definition: plotter.h:466
virtual void SetColor(const COLOR4D &color)=0
virtual void EndBlock(void *aData)
calling this function allows one to define the end of a group of drawing items for instance in SVG or...
Definition: plotter.h:547
TEMPLATES m_TemplateFieldNames
Holds all the data relating to one schematic.
Definition: schematic.h:61
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:122
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
Definition: schematic.cpp:630
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:205
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Definition: schematic.cpp:325
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:175
void ImportValues(const LIB_FIELD &aSource)
Copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:382
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition: sch_item.cpp:70
virtual wxString GetClass() const override
Return the class name.
Definition: sch_item.h:157
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:493
SCH_LAYER_ID m_layer
Definition: sch_item.h:491
bool IsDangling() const override
Definition: sch_pin.h:103
wxString GetShownName() const
Definition: sch_pin.cpp:94
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:126
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:117
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
Schematic symbol object.
Definition: sch_symbol.h:81
void UpdatePrefix()
Set the prefix based on the current reference designator.
Definition: sch_symbol.cpp:766
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:771
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
void GetLibPins(std::vector< LIB_PIN * > &aPinsList) const
Populate a vector with all the pins from the library object.
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:427
VECTOR2I m_pos
Definition: sch_symbol.h:765
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:766
void SetConvert(int aConvert)
Definition: sch_symbol.cpp:404
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
wxString GetDatasheet() const
Return the documentation text for the given part alias.
Definition: sch_symbol.cpp:330
void SetLibId(const LIB_ID &aName)
Definition: sch_symbol.cpp:284
bool ReplaceInstanceSheetPath(const KIID_PATH &aOldSheetPath, const KIID_PATH &aNewSheetPath)
Replace aOldSheetPath with aNewSheetPath in the instance list.
bool HasBrightenedPins()
std::vector< SCH_FIELD > & GetFields()
Return a vector of fields from the symbol.
Definition: sch_symbol.h:423
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a symbol.
Definition: sch_symbol.cpp:464
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
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.
void PlotDNP(PLOTTER *aPlotter) const
Plot the red 'X' over the symbol.
bool operator!=(const SCH_SYMBOL &aSymbol) const
LIB_ITEM * GetDrawItem(const VECTOR2I &aPosition, KICAD_T aType=TYPE_NOT_INIT)
Return the symbol library item at aPosition that is part of this symbol.
int GetUnit() const
Definition: sch_symbol.h:228
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:486
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Search for a SCH_FIELD with aFieldName.
Definition: sch_symbol.cpp:938
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
Definition: sch_symbol.cpp:398
wxString GetClass() const override
Return the class name.
Definition: sch_symbol.h:120
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
Definition: sch_symbol.cpp:543
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:710
void PlotPins(PLOTTER *aPlotter) const
Plot just the symbol pins.
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:844
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
Definition: sch_symbol.cpp:925
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:768
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:294
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:674
bool IsInNetlist() const
bool GetIncludeOnBoard() const
Definition: sch_symbol.h:750
std::unordered_map< LIB_PIN *, unsigned > m_pinMap
library pin pointer : SCH_PIN's index
Definition: sch_symbol.h:791
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
bool GetIncludeInBom() const
Definition: sch_symbol.h:747
void ClearBrightenedPins()
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_symbol.cpp:233
bool AddSheetPathReferenceEntryIfMissing(const KIID_PATH &aSheetPath)
Add an instance to the alternate references list (m_instanceReferences), if this entry does not alrea...
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:865
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
static std::unordered_map< TRANSFORM, int > s_transformToOrientationCache
Definition: sch_symbol.h:803
VECTOR2I GetPinPhysicalPosition(const LIB_PIN *Pin) const
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:339
int GetConvert() const
Definition: sch_symbol.h:270
std::vector< SCH_SYMBOL_INSTANCE > m_instanceReferences
Definition: sch_symbol.h:800
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
void UpdateFields(const SCH_SHEET_PATH *aPath, bool aUpdateStyle, bool aUpdateRef, bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields)
Restore fields to the original library values.
Definition: sch_symbol.cpp:952
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
Definition: sch_symbol.h:783
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:716
const wxString GetFootprintFieldText(bool aResolve) const
Definition: sch_symbol.cpp:850
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
void PrintBackground(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print only the background parts of a symbol (if any)
Definition: sch_symbol.cpp:452
wxString GetDescription() const
Definition: sch_symbol.cpp:312
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:786
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
bool m_onBoard
True to include in netlist when updating board.
Definition: sch_symbol.h:795
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:767
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:859
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
Definition: sch_symbol.cpp:572
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:239
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
void SetTransform(const TRANSFORM &aTransform)
Definition: sch_symbol.cpp:417
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
Definition: sch_symbol.cpp:203
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_symbol.cpp:248
bool operator<(const SCH_ITEM &aItem) const override
bool m_DNP
True if symbol is set to 'Do Not Populate'.
Definition: sch_symbol.h:796
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
wxString GetKeyWords() const
Definition: sch_symbol.cpp:321
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
SCH_FIELD * GetFieldById(int aFieldId)
Return a field in this symbol.
Definition: sch_symbol.cpp:877
const wxString GetValueFieldText(bool aResolve) const
Definition: sch_symbol.cpp:835
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
Definition: sch_symbol.cpp:519
TRANSFORM & GetTransform()
Definition: sch_symbol.h:283
bool HasUnitDisplayName(int aUnit)
Return true if the given unit aUnit has a display name set.
Definition: sch_symbol.cpp:444
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
Definition: sch_symbol.cpp:916
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Test if the symbol's dangling state has changed for all pins.
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
int GetOrientation() const
Get the display symbol orientation.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet)
Check if the symbol has a valid annotation (reference) for the given sheet path.
Definition: sch_symbol.cpp:752
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool m_isInNetlist
True if the symbol should appear in the netlist.
Definition: sch_symbol.h:793
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:793
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:388
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:175
wxString GetUnitDisplayName(int aUnit)
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:436
BOX2I GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:785
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
SCH_SYMBOL & operator=(const SCH_ITEM &aItem)
std::vector< LIB_PIN * > GetAllLibPins() const
void SetPrefix(const wxString &aPrefix)
Definition: sch_symbol.h:276
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:901
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:809
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:790
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:303
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
void SortInstances(bool(*aSortFunction)(const SCH_SYMBOL_INSTANCE &aLhs, const SCH_SYMBOL_INSTANCE &aRhs))
Definition: sch_symbol.cpp:565
wxString GetFieldText(const wxString &aFieldName) const
Search for a field named aFieldName and returns text associated with this field.
Definition: sch_symbol.cpp:889
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
Definition: sch_symbol.cpp:263
bool m_inBom
True to include in bill of materials export.
Definition: sch_symbol.h:794
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:788
bool operator==(const SCH_SYMBOL &aSymbol) const
bool GetDNP() const
Definition: sch_symbol.h:753
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field name list for read only access.
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:47
int x2
Definition: transform.h:51
int y1
Definition: transform.h:50
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:61
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:46
int y2
Definition: transform.h:52
int x1
Definition: transform.h:49
bool empty() const
Definition: utf8.h:103
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
T Convert(const wxString &aValue)
Convert a wxString to a generic type T.
Definition: eagle_parser.h:179
#define _(s)
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:431
INSPECT_RESULT
Definition: eda_item.h:42
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:78
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define IS_DANGLING
indicates a pin is dangling
void GRFilledSegment(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:278
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
@ LAYER_DANGLING
Definition: layer_ids.h:368
@ LAYER_DEVICE
Definition: layer_ids.h:357
@ LAYER_ERC_ERR
Definition: layer_ids.h:370
@ LAYER_VALUEPART
Definition: layer_ids.h:353
@ LAYER_FIELDS
Definition: layer_ids.h:354
@ LAYER_DEVICE_BACKGROUND
Definition: layer_ids.h:372
@ LAYER_REFERENCEPART
Definition: layer_ids.h:352
@ LAYER_OP_CURRENTS
Definition: layer_ids.h:388
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:381
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:54
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
Message panel definition file.
wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
Definition: eda_units.cpp:101
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
@ FILLED
Definition: outline_mode.h:27
see class PGM_BASE
@ PT_NC
not connected (must be left open)
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Collection of utility functions for component reference designators (refdes)
@ SYM_ORIENT_270
@ SYM_ROTATE_CLOCKWISE
@ SYM_ROTATE_COUNTERCLOCKWISE
@ SYM_MIRROR_Y
@ SYM_ORIENT_180
@ SYM_MIRROR_X
@ SYM_NORMAL
@ SYM_ORIENT_90
@ SYM_ORIENT_0
@ NO_CONNECT_END
Definition: sch_item.h:73
@ SHEET_LABEL_END
Definition: sch_item.h:72
@ LABEL_END
Definition: sch_item.h:69
@ JUNCTION_END
Definition: sch_item.h:67
@ PIN_END
Definition: sch_item.h:68
@ WIRE_END
Definition: sch_item.h:65
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
Definition: sch_symbol.cpp:54
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:81
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
wxString UnescapeString(const wxString &aSource)
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
bool draw_visible_fields
Definition: lib_symbol.h:66
TRANSFORM transform
Definition: lib_symbol.h:64
std::vector< std::pair< int, wxString > > Fields
Definition: sch_screen.h:84
A simple container for schematic symbol instance information.
Hold a name of a symbol's field, field value, and default visibility.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
MANDATORY_FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_FIELD_LOCATE_REFERENCE_T
Definition: typeinfo.h:164
@ SCH_FIELD_LOCATE_FOOTPRINT_T
Definition: typeinfo.h:166
@ SCH_SYMBOL_T
Definition: typeinfo.h:156
@ SCH_FIELD_T
Definition: typeinfo.h:155
@ SCH_LOCATE_ANY_T
Definition: typeinfo.h:183
@ SCH_FIELD_LOCATE_VALUE_T
Definition: typeinfo.h:165
@ LIB_PIN_T
Definition: typeinfo.h:202
@ SCH_FIELD_LOCATE_DATASHEET_T
Definition: typeinfo.h:167
@ SCH_SYMBOL_LOCATE_POWER_T
Definition: typeinfo.h:180
@ SCH_PIN_T
Definition: typeinfo.h:159
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590