KiCad PCB EDA Suite
Loading...
Searching...
No Matches
erc.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) 2011 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <algorithm>
27#include <numeric>
28#include <set>
29
30#include "connection_graph.h"
31#include "kiface_ids.h"
32#include <advanced_config.h>
33#include <common.h> // for ExpandEnvVarSubstitutions
34#include <erc/erc.h>
37#include <string_utils.h>
38#include <sch_pin.h>
39#include <project_sch.h>
42#include <sch_bus_entry.h>
43#include <sch_edit_frame.h>
44#include <sch_marker.h>
45#include <sch_reference_list.h>
46#include <sch_rule_area.h>
47#include <sch_sheet.h>
48#include <sch_sheet_pin.h>
49#include <sch_pin.h>
50#include <sch_textbox.h>
51#include <sch_line.h>
52#include <schematic.h>
55#include <vector>
56#include <wx/ffile.h>
57#include <sim/sim_lib_mgr.h>
58#include <progress_reporter.h>
59#include <kiway.h>
60#include <pgm_base.h>
62
63
64/* ERC tests :
65 * 1 - conflicts between connected pins ( example: 2 connected outputs )
66 * 2 - minimal connections requirements ( 1 input *must* be connected to an
67 * output, or a passive pin )
68 */
69
70/*
71 * Minimal ERC requirements:
72 * All pins *must* be connected (except ELECTRICAL_PINTYPE::PT_NC).
73 * When a pin is not connected in schematic, the user must place a "non
74 * connected" symbol to this pin.
75 * This ensures a forgotten connection will be detected.
76 */
77
78// Messages for matrix rows:
79const wxString CommentERC_H[] =
80{
81 _( "Input Pin" ),
82 _( "Output Pin" ),
83 _( "Bidirectional Pin" ),
84 _( "Tri-State Pin" ),
85 _( "Passive Pin" ),
86 _( "Free Pin" ),
87 _( "Unspecified Pin" ),
88 _( "Power Input Pin" ),
89 _( "Power Output Pin" ),
90 _( "Open Collector" ),
91 _( "Open Emitter" ),
92 _( "No Connection" )
93};
94
95// Messages for matrix columns
96const wxString CommentERC_V[] =
97{
98 _( "Input Pin" ),
99 _( "Output Pin" ),
100 _( "Bidirectional Pin" ),
101 _( "Tri-State Pin" ),
102 _( "Passive Pin" ),
103 _( "Free Pin" ),
104 _( "Unspecified Pin" ),
105 _( "Power Input Pin" ),
106 _( "Power Output Pin" ),
107 _( "Open Collector" ),
108 _( "Open Emitter" ),
109 _( "No Connection" )
110};
111
112
113// List of pin types that are considered drivers for usual input pins
114// i.e. pin type = ELECTRICAL_PINTYPE::PT_INPUT, but not PT_POWER_IN
115// that need only a PT_POWER_OUT pin type to be driven
124
125// List of pin types that are considered drivers for power pins
126// In fact only a ELECTRICAL_PINTYPE::PT_POWER_OUT pin type can drive
127// power input pins
128const std::set<ELECTRICAL_PINTYPE> DrivingPowerPinTypes =
129{
131};
132
133// List of pin types that require a driver elsewhere on the net
134const std::set<ELECTRICAL_PINTYPE> DrivenPinTypes =
135{
138};
139
140extern void CheckDuplicatePins( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
141 UNITS_PROVIDER* aUnitsProvider );
142
143int ERC_TESTER::TestDuplicateSheetNames( bool aCreateMarker )
144{
145 int err_count = 0;
146
147 for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
148 {
149 std::vector<SCH_SHEET*> list;
150
151 for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
152 list.push_back( static_cast<SCH_SHEET*>( item ) );
153
154 for( size_t i = 0; i < list.size(); i++ )
155 {
156 SCH_SHEET* sheet = list[i];
157
158 for( size_t j = i + 1; j < list.size(); j++ )
159 {
160 SCH_SHEET* test_item = list[j];
161
162 // We have found a second sheet: compare names
163 // we are using case insensitive comparison to avoid mistakes between
164 // similar names like Mysheet and mysheet
165 if( sheet->GetShownName( false ).IsSameAs( test_item->GetShownName( false ), false ) )
166 {
167 if( aCreateMarker )
168 {
170 ercItem->SetItems( sheet, test_item );
171
172 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), sheet->GetPosition() );
173 screen->Append( marker );
174 }
175
176 err_count++;
177 }
178 }
179 }
180 }
181
182 return err_count;
183}
184
185
187{
189
190 auto unresolved =
191 [this]( wxString str )
192 {
193 str = ExpandEnvVarSubstitutions( str, &m_schematic->Project() );
194 return str.Matches( wxS( "*${*}*" ) );
195 };
196
197 auto testAssertion =
198 []( const SCH_ITEM* item, const SCH_SHEET_PATH& sheet, SCH_SCREEN* screen,
199 const wxString& text, const VECTOR2I& pos )
200 {
201 static wxRegEx warningExpr( wxS( "^\\$\\{ERC_WARNING\\s*([^}]*)\\}(.*)$" ) );
202 static wxRegEx errorExpr( wxS( "^\\$\\{ERC_ERROR\\s*([^}]*)\\}(.*)$" ) );
203
204 if( warningExpr.Matches( text ) )
205 {
206 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_GENERIC_WARNING );
207 wxString ercText = warningExpr.GetMatch( text, 1 );
208
209 if( item )
210 ercItem->SetItems( item );
211 else
212 ercText += _( " (in drawing sheet)" );
213
214 ercItem->SetSheetSpecificPath( sheet );
215 ercItem->SetErrorMessage( ercText );
216
217 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
218 screen->Append( marker );
219
220 return true;
221 }
222
223 if( errorExpr.Matches( text ) )
224 {
225 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_GENERIC_ERROR );
226 wxString ercText = errorExpr.GetMatch( text, 1 );
227
228 if( item )
229 ercItem->SetItems( item );
230 else
231 ercText += _( " (in drawing sheet)" );
232
233 ercItem->SetSheetSpecificPath( sheet );
234 ercItem->SetErrorMessage( ercText );
235
236 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
237 screen->Append( marker );
238
239 return true;
240 }
241
242 return false;
243 };
244
245 if( aDrawingSheet )
246 {
247 wsItems.SetPageNumber( wxS( "1" ) );
248 wsItems.SetSheetCount( 1 );
249 wsItems.SetFileName( wxS( "dummyFilename" ) );
250 wsItems.SetSheetName( wxS( "dummySheet" ) );
251 wsItems.SetSheetLayer( wxS( "dummyLayer" ) );
252 wsItems.SetProject( &m_schematic->Project() );
253 wsItems.BuildDrawItemsList( aDrawingSheet->GetPageInfo(), aDrawingSheet->GetTitleBlock() );
254 }
255
256 for( const SCH_SHEET_PATH& sheet : m_sheetList )
257 {
258 SCH_SCREEN* screen = sheet.LastScreen();
259
260 for( SCH_ITEM* item : screen->Items().OfType( SCH_LOCATE_ANY_T ) )
261 {
262 if( item->Type() == SCH_SYMBOL_T )
263 {
264 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
265
266 for( SCH_FIELD& field : symbol->GetFields() )
267 {
268 if( unresolved( field.GetShownText( &sheet, true ) ) )
269 {
271 ercItem->SetItems( symbol );
272 ercItem->SetSheetSpecificPath( sheet );
273
274 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
275 screen->Append( marker );
276 }
277
278 testAssertion( &field, sheet, screen, field.GetText(), field.GetPosition() );
279 }
280
281 if( symbol->GetLibSymbolRef() )
282 {
284 [&]( SCH_ITEM* child )
285 {
286 if( child->Type() == SCH_FIELD_T )
287 {
288 // test only SCH_SYMBOL fields, not LIB_SYMBOL fields
289 }
290 else if( child->Type() == SCH_TEXT_T )
291 {
292 SCH_TEXT* textItem = static_cast<SCH_TEXT*>( child );
293
294 if( unresolved( textItem->GetShownText( &sheet, true ) ) )
295 {
297 ercItem->SetItems( symbol );
298 ercItem->SetSheetSpecificPath( sheet );
299
300 BOX2I bbox = textItem->GetBoundingBox();
301 bbox = symbol->GetTransform().TransformCoordinate( bbox );
302 VECTOR2I pos = bbox.Centre() + symbol->GetPosition();
303
304 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
305 screen->Append( marker );
306 }
307
308 testAssertion( symbol, sheet, screen, textItem->GetText(),
309 textItem->GetPosition() );
310 }
311 else if( child->Type() == SCH_TEXTBOX_T )
312 {
313 SCH_TEXTBOX* textboxItem = static_cast<SCH_TEXTBOX*>( child );
314
315 if( unresolved( textboxItem->GetShownText( nullptr, &sheet, true ) ) )
316 {
318 ercItem->SetItems( symbol );
319 ercItem->SetSheetSpecificPath( sheet );
320
321 BOX2I bbox = textboxItem->GetBoundingBox();
322 bbox = symbol->GetTransform().TransformCoordinate( bbox );
323 VECTOR2I pos = bbox.Centre() + symbol->GetPosition();
324
325 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pos );
326 screen->Append( marker );
327 }
328
329 testAssertion( symbol, sheet, screen, textboxItem->GetText(),
330 textboxItem->GetPosition() );
331 }
332 },
334 }
335 }
336 else if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item ) )
337 {
338 for( SCH_FIELD& field : label->GetFields() )
339 {
340 if( unresolved( field.GetShownText( &sheet, true ) ) )
341 {
343 ercItem->SetItems( label );
344 ercItem->SetSheetSpecificPath( sheet );
345
346 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
347 screen->Append( marker );
348 }
349
350 testAssertion( &field, sheet, screen, field.GetText(), field.GetPosition() );
351 }
352 }
353 else if( item->Type() == SCH_SHEET_T )
354 {
355 SCH_SHEET* subSheet = static_cast<SCH_SHEET*>( item );
356
357 for( SCH_FIELD& field : subSheet->GetFields() )
358 {
359 if( unresolved( field.GetShownText( &sheet, true ) ) )
360 {
362 ercItem->SetItems( subSheet );
363 ercItem->SetSheetSpecificPath( sheet );
364
365 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), field.GetPosition() );
366 screen->Append( marker );
367 }
368
369 testAssertion( &field, sheet, screen, field.GetText(), field.GetPosition() );
370 }
371
372 SCH_SHEET_PATH subSheetPath = sheet;
373 subSheetPath.push_back( subSheet );
374
375 for( SCH_SHEET_PIN* pin : subSheet->GetPins() )
376 {
377 if( pin->GetShownText( &subSheetPath, true ).Matches( wxS( "*${*}*" ) ) )
378 {
380 ercItem->SetItems( pin );
381 ercItem->SetSheetSpecificPath( sheet );
382
383 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
384 screen->Append( marker );
385 }
386 }
387 }
388 else if( SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( item ) )
389 {
390 if( text->GetShownText( &sheet, true ).Matches( wxS( "*${*}*" ) ) )
391 {
393 ercItem->SetItems( text );
394 ercItem->SetSheetSpecificPath( sheet );
395
396 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), text->GetPosition() );
397 screen->Append( marker );
398 }
399
400 testAssertion( text, sheet, screen, text->GetText(), text->GetPosition() );
401 }
402 else if( SCH_TEXTBOX* textBox = dynamic_cast<SCH_TEXTBOX*>( item ) )
403 {
404 if( textBox->GetShownText( nullptr, &sheet, true ).Matches( wxS( "*${*}*" ) ) )
405 {
407 ercItem->SetItems( textBox );
408 ercItem->SetSheetSpecificPath( sheet );
409
410 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), textBox->GetPosition() );
411 screen->Append( marker );
412 }
413
414 testAssertion( textBox, sheet, screen, textBox->GetText(), textBox->GetPosition() );
415 }
416 }
417
418 for( DS_DRAW_ITEM_BASE* item = wsItems.GetFirst(); item; item = wsItems.GetNext() )
419 {
420 if( DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item ) )
421 {
422 if( testAssertion( nullptr, sheet, screen, text->GetText(), text->GetPosition() ) )
423 {
424 // Don't run unresolved test
425 }
426 else if( text->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
427 {
428 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
429 ercItem->SetErrorMessage( _( "Unresolved text variable in drawing sheet" ) );
430 ercItem->SetSheetSpecificPath( sheet );
431
432 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), text->GetPosition() );
433 screen->Append( marker );
434 }
435 }
436 }
437 }
438}
439
440
442{
443 int errors = 0;
444
445 for( std::pair<const wxString, SCH_REFERENCE_LIST>& symbol : m_refMap )
446 {
447 SCH_REFERENCE_LIST& refList = symbol.second;
448
449 if( refList.GetCount() == 0 )
450 {
451 wxFAIL; // it should not happen
452 continue;
453 }
454
455 // Reference footprint
456 SCH_SYMBOL* unit = nullptr;
457 wxString unitName;
458 wxString unitFP;
459
460 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
461 {
462 SCH_SHEET_PATH sheetPath = refList.GetItem( ii ).GetSheetPath();
463 unitFP = refList.GetItem( ii ).GetFootprint();
464
465 if( !unitFP.IsEmpty() )
466 {
467 unit = refList.GetItem( ii ).GetSymbol();
468 unitName = unit->GetRef( &sheetPath, true );
469 break;
470 }
471 }
472
473 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
474 {
475 SCH_REFERENCE& secondRef = refList.GetItem( ii );
476 SCH_SYMBOL* secondUnit = secondRef.GetSymbol();
477 wxString secondName = secondUnit->GetRef( &secondRef.GetSheetPath(), true );
478 const wxString secondFp = secondRef.GetFootprint();
479 wxString msg;
480
481 if( unit && !secondFp.IsEmpty() && unitFP != secondFp )
482 {
483 msg.Printf( _( "Different footprints assigned to %s and %s" ),
484 unitName, secondName );
485
486 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_FP );
487 ercItem->SetErrorMessage( msg );
488 ercItem->SetItems( unit, secondUnit );
489
490 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), secondUnit->GetPosition() );
491 secondRef.GetSheetPath().LastScreen()->Append( marker );
492
493 ++errors;
494 }
495 }
496 }
497
498 return errors;
499}
500
501
503{
504 int errors = 0;
505
506 for( std::pair<const wxString, SCH_REFERENCE_LIST>& symbol : m_refMap )
507 {
508 SCH_REFERENCE_LIST& refList = symbol.second;
509
510 wxCHECK2( refList.GetCount(), continue );
511
512 // Reference unit
513 SCH_REFERENCE& base_ref = refList.GetItem( 0 );
514 SCH_SYMBOL* unit = base_ref.GetSymbol();
515 LIB_SYMBOL* libSymbol = base_ref.GetLibPart();
516
517 if( static_cast<ssize_t>( refList.GetCount() ) == libSymbol->GetUnitCount() )
518 continue;
519
520 std::set<int> lib_units;
521 std::set<int> instance_units;
522 std::set<int> missing_units;
523
524 auto report =
525 [&]( std::set<int>& aMissingUnits, const wxString& aErrorMsg, int aErrorCode )
526 {
527 wxString msg;
528 wxString missing_pin_units = wxS( "[ " );
529 int ii = 0;
530
531 for( int missing_unit : aMissingUnits )
532 {
533 if( ii++ == 3 )
534 {
535 missing_pin_units += wxS( "..." );
536 break;
537 }
538
539 missing_pin_units += libSymbol->GetUnitDisplayName( missing_unit, false ) + ", " ;
540 }
541
542 missing_pin_units.Truncate( missing_pin_units.length() - 2 );
543 missing_pin_units += wxS( " ]" );
544
545 msg.Printf( aErrorMsg, symbol.first, missing_pin_units );
546
547 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( aErrorCode );
548 ercItem->SetErrorMessage( msg );
549 ercItem->SetItems( unit );
550 ercItem->SetSheetSpecificPath( base_ref.GetSheetPath() );
551 ercItem->SetItemsSheetPaths( base_ref.GetSheetPath() );
552
553 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), unit->GetPosition() );
554 base_ref.GetSheetPath().LastScreen()->Append( marker );
555
556 ++errors;
557 };
558
559 for( int ii = 1; ii <= libSymbol->GetUnitCount(); ++ii )
560 lib_units.insert( lib_units.end(), ii );
561
562 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
563 instance_units.insert( instance_units.end(), refList.GetItem( ii ).GetUnit() );
564
565 std::set_difference( lib_units.begin(), lib_units.end(),
566 instance_units.begin(), instance_units.end(),
567 std::inserter( missing_units, missing_units.begin() ) );
568
569 if( !missing_units.empty() && m_settings.IsTestEnabled( ERCE_MISSING_UNIT ) )
570 {
571 report( missing_units, _( "Symbol %s has unplaced units %s" ), ERCE_MISSING_UNIT );
572 }
573
574 std::set<int> missing_power;
575 std::set<int> missing_input;
576 std::set<int> missing_bidi;
577
578 for( int missing_unit : missing_units )
579 {
580 int bodyStyle = 0;
581
582 for( size_t ii = 0; ii < refList.GetCount(); ++ii )
583 {
584 if( refList.GetItem( ii ).GetUnit() == missing_unit )
585 {
586 bodyStyle = refList.GetItem( ii ).GetSymbol()->GetBodyStyle();
587 break;
588 }
589 }
590
591 for( SCH_PIN* pin : libSymbol->GetGraphicalPins( missing_unit, bodyStyle ) )
592 {
593 switch( pin->GetType() )
594 {
596 missing_power.insert( missing_unit );
597 break;
598
600 missing_bidi.insert( missing_unit );
601 break;
602
604 missing_input.insert( missing_unit );
605 break;
606
607 default:
608 break;
609 }
610 }
611 }
612
613 if( !missing_power.empty() && m_settings.IsTestEnabled( ERCE_MISSING_POWER_INPUT_PIN ) )
614 {
615 report( missing_power, _( "Symbol %s has input power pins in units %s that are not placed" ),
617 }
618
619 if( !missing_input.empty() && m_settings.IsTestEnabled( ERCE_MISSING_INPUT_PIN ) )
620 {
621 report( missing_input, _( "Symbol %s has input pins in units %s that are not placed" ),
623 }
624
625 if( !missing_bidi.empty() && m_settings.IsTestEnabled( ERCE_MISSING_BIDI_PIN ) )
626 {
627 report( missing_bidi, _( "Symbol %s has bidirectional pins in units %s that are not placed" ),
629 }
630 }
631
632 return errors;
633}
634
635
637{
638 int err_count = 0;
639 std::shared_ptr<NET_SETTINGS>& settings = m_schematic->Project().GetProjectFile().NetSettings();
640 wxString defaultNetclass = settings->GetDefaultNetclass()->GetName();
641
642 auto logError =
643 [&]( const SCH_SHEET_PATH& sheet, SCH_ITEM* item, const wxString& netclass )
644 {
645 err_count++;
646
647 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNDEFINED_NETCLASS );
648
649 ercItem->SetItems( item );
650 ercItem->SetErrorMessage( wxString::Format( _( "Netclass %s is not defined" ), netclass ) );
651
652 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), item->GetPosition() );
653 sheet.LastScreen()->Append( marker );
654 };
655
656 for( const SCH_SHEET_PATH& sheet : m_sheetList )
657 {
658 for( SCH_ITEM* item : sheet.LastScreen()->Items() )
659 {
660 item->RunOnChildren(
661 [&]( SCH_ITEM* aChild )
662 {
663 if( aChild->Type() == SCH_FIELD_T )
664 {
665 SCH_FIELD* field = static_cast<SCH_FIELD*>( aChild );
666
667 if( field->GetCanonicalName() == wxT( "Netclass" ) )
668 {
669 wxString netclass = field->GetShownText( &sheet, false );
670
671 if( !netclass.empty() && !netclass.IsSameAs( defaultNetclass )
672 && !settings->HasNetclass( netclass ) )
673 {
674 logError( sheet, item, netclass );
675 }
676 }
677 }
678
679 return true;
680 },
682 }
683 }
684
685 return err_count;
686}
687
688
690{
691 int err_count = 0;
692
693 for( const SCH_SHEET_PATH& sheet : m_sheetList )
694 {
695 std::map<VECTOR2I, std::vector<SCH_ITEM*>> connMap;
696
697 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_LABEL_T ) )
698 {
699 SCH_LABEL* label = static_cast<SCH_LABEL*>( item );
700
701 for( const VECTOR2I& pt : label->GetConnectionPoints() )
702 connMap[pt].emplace_back( label );
703 }
704
705 for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : connMap )
706 {
707 std::vector<SCH_ITEM*> lines;
708
709 for( SCH_ITEM* item : sheet.LastScreen()->Items().Overlapping( SCH_LINE_T, pair.first ) )
710 {
711 SCH_LINE* line = static_cast<SCH_LINE*>( item );
712
713 if( line->IsGraphicLine() )
714 continue;
715
716 // If the line is connected at the endpoint, then there will be a junction
717 if( !line->IsEndPoint( pair.first ) )
718 lines.emplace_back( line );
719 }
720
721 if( lines.size() > 1 )
722 {
723 err_count++;
724 lines.resize( 3 ); // Only show the first 3 lines and if there are only two, adds a nullptr
725
726 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LABEL_MULTIPLE_WIRES );
727 wxString msg = wxString::Format( _( "Label connects more than one wire at %d, %d" ),
728 pair.first.x, pair.first.y );
729
730 ercItem->SetItems( pair.second.front(), lines[0], lines[1], lines[2] );
731 ercItem->SetErrorMessage( msg );
732 ercItem->SetSheetSpecificPath( sheet );
733
734 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pair.first );
735 sheet.LastScreen()->Append( marker );
736 }
737 }
738 }
739
740 return err_count;
741}
742
743
745{
746 int err_count = 0;
747
748 auto pinStackAlreadyRepresented =
749 []( SCH_PIN* pin, std::vector<SCH_ITEM*>& collection ) -> bool
750 {
751 for( SCH_ITEM*& item : collection )
752 {
753 if( item->Type() == SCH_PIN_T && item->GetParentSymbol() == pin->GetParentSymbol() )
754 {
755 if( pin->IsVisible() && !static_cast<SCH_PIN*>( item )->IsVisible() )
756 item = pin;
757
758 return true;
759 }
760 }
761
762 return false;
763 };
764
765 for( const SCH_SHEET_PATH& sheet : m_sheetList )
766 {
767 std::map<VECTOR2I, std::vector<SCH_ITEM*>> connMap;
768 SCH_SCREEN* screen = sheet.LastScreen();
769
770 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
771 {
772 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
773
774 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
775 {
776 std::vector<SCH_ITEM*>& entry = connMap[pin->GetPosition()];
777
778 // Only one pin per pin-stack.
779 if( pinStackAlreadyRepresented( pin, entry ) )
780 continue;
781
782 entry.emplace_back( pin );
783 }
784 }
785
786 for( SCH_ITEM* item : screen->Items().OfType( SCH_LINE_T ) )
787 {
788 SCH_LINE* line = static_cast<SCH_LINE*>( item );
789
790 if( line->IsGraphicLine() )
791 continue;
792
793 for( const VECTOR2I& pt : line->GetConnectionPoints() )
794 connMap[pt].emplace_back( line );
795 }
796
797 for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : connMap )
798 {
799 if( pair.second.size() >= 4 )
800 {
801 err_count++;
802
803 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOUR_WAY_JUNCTION );
804
805 ercItem->SetItems( pair.second[0], pair.second[1], pair.second[2], pair.second[3] );
806
807 wxString msg = wxString::Format( _( "Four items connected at %d, %d" ),
808 pair.first.x, pair.first.y );
809 ercItem->SetErrorMessage( msg );
810
811 ercItem->SetSheetSpecificPath( sheet );
812
813 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pair.first );
814 sheet.LastScreen()->Append( marker );
815 }
816 }
817 }
818
819 return err_count;
820}
821
822
824{
825 int err_count = 0;
826
827 for( const SCH_SHEET_PATH& sheet : m_sheetList )
828 {
829 std::map<VECTOR2I, std::vector<SCH_ITEM*>> pinMap;
830
831 auto addOther =
832 [&]( const VECTOR2I& pt, SCH_ITEM* aOther )
833 {
834 if( pinMap.count( pt ) )
835 pinMap[pt].emplace_back( aOther );
836 };
837
838 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
839 {
840 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
841
842 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
843 {
844 if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
845 pinMap[pin->GetPosition()].emplace_back( pin );
846 }
847 }
848
849 for( SCH_ITEM* item : sheet.LastScreen()->Items() )
850 {
851 if( item->Type() == SCH_SYMBOL_T )
852 {
853 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
854
855 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
856 {
857 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_NC )
858 addOther( pin->GetPosition(), pin );
859 }
860 }
861 else if( item->IsConnectable() && item->Type() != SCH_NO_CONNECT_T )
862 {
863 for( const VECTOR2I& pt : item->GetConnectionPoints() )
864 addOther( pt, item );
865 }
866 }
867
868 for( const std::pair<const VECTOR2I, std::vector<SCH_ITEM*>>& pair : pinMap )
869 {
870 if( pair.second.size() > 1 )
871 {
872 bool all_nc = true;
873
874 for( SCH_ITEM* item : pair.second )
875 {
876 if( item->Type() != SCH_PIN_T )
877 {
878 all_nc = false;
879 break;
880 }
881
882 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
883
884 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_NC )
885 {
886 all_nc = false;
887 break;
888 }
889 }
890
891 if( all_nc )
892 continue;
893
894 err_count++;
895
896 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
897
898 ercItem->SetItems( pair.second[0], pair.second[1],
899 pair.second.size() > 2 ? pair.second[2] : nullptr,
900 pair.second.size() > 3 ? pair.second[3] : nullptr );
901 ercItem->SetErrorMessage( _( "Pin with 'no connection' type is connected" ) );
902 ercItem->SetSheetSpecificPath( sheet );
903
904 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pair.first );
905 sheet.LastScreen()->Append( marker );
906 }
907 }
908 }
909
910 return err_count;
911}
912
913
915{
916 int errors = 0;
917
918 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
919 {
920 using iterator_t = std::vector<ERC_SCH_PIN_CONTEXT>::iterator;
921 std::vector<ERC_SCH_PIN_CONTEXT> pins;
922 std::unordered_map<EDA_ITEM*, SCH_SCREEN*> pinToScreenMap;
923 bool has_noconnect = false;
924
925 for( CONNECTION_SUBGRAPH* subgraph: net.second )
926 {
927 if( subgraph->GetNoConnect() )
928 has_noconnect = true;
929
930 for( SCH_ITEM* item : subgraph->GetItems() )
931 {
932 if( item->Type() == SCH_PIN_T )
933 {
934 pins.emplace_back( static_cast<SCH_PIN*>( item ), subgraph->GetSheet() );
935 pinToScreenMap[item] = subgraph->GetSheet().LastScreen();
936 }
937 }
938 }
939
940 std::sort( pins.begin(), pins.end(),
941 []( const ERC_SCH_PIN_CONTEXT& lhs, const ERC_SCH_PIN_CONTEXT& rhs )
942 {
943 int ret = StrNumCmp( lhs.Pin()->GetParentSymbol()->GetRef( &lhs.Sheet() ),
944 rhs.Pin()->GetParentSymbol()->GetRef( &rhs.Sheet() ) );
945
946 if( ret == 0 )
947 ret = StrNumCmp( lhs.Pin()->GetNumber(), rhs.Pin()->GetNumber() );
948
949 if( ret == 0 )
950 ret = lhs < rhs; // Fallback to hash to guarantee deterministic sort
951
952 return ret < 0;
953 } );
954
955 ERC_SCH_PIN_CONTEXT needsDriver;
957 bool hasDriver = false;
958 std::vector<ERC_SCH_PIN_CONTEXT*> pinsNeedingDrivers;
959 std::vector<ERC_SCH_PIN_CONTEXT*> nonPowerPinsNeedingDrivers;
960
961 // We need different drivers for power nets and normal nets.
962 // A power net has at least one pin having the ELECTRICAL_PINTYPE::PT_POWER_IN
963 // and power nets can be driven only by ELECTRICAL_PINTYPE::PT_POWER_OUT pins
964 bool ispowerNet = false;
965
966 for( ERC_SCH_PIN_CONTEXT& refPin : pins )
967 {
968 if( refPin.Pin()->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN )
969 {
970 ispowerNet = true;
971 break;
972 }
973 }
974
975 std::vector<std::tuple<iterator_t, iterator_t, PIN_ERROR>> pin_mismatches;
976 std::map<iterator_t, int> pin_mismatch_counts;
977
978 for( auto refIt = pins.begin(); refIt != pins.end(); ++refIt )
979 {
980 ERC_SCH_PIN_CONTEXT& refPin = *refIt;
981 ELECTRICAL_PINTYPE refType = refPin.Pin()->GetType();
982
983 if( DrivenPinTypes.contains( refType ) )
984 {
985 // needsDriver will be the pin shown in the error report eventually, so try to
986 // upgrade to a "better" pin if possible: something visible and only a power symbol
987 // if this net needs a power driver
988 pinsNeedingDrivers.push_back( &refPin );
989
990 if( !refPin.Pin()->IsPower() )
991 nonPowerPinsNeedingDrivers.push_back( &refPin );
992
993 if( !needsDriver.Pin()
994 || ( !needsDriver.Pin()->IsVisible() && refPin.Pin()->IsVisible() )
995 || ( ispowerNet != ( needsDriverType == ELECTRICAL_PINTYPE::PT_POWER_IN )
996 && ispowerNet == ( refType == ELECTRICAL_PINTYPE::PT_POWER_IN ) ) )
997 {
998 needsDriver = refPin;
999 needsDriverType = needsDriver.Pin()->GetType();
1000 }
1001 }
1002
1003 if( ispowerNet )
1004 hasDriver |= ( DrivingPowerPinTypes.count( refType ) != 0 );
1005 else
1006 hasDriver |= ( DrivingPinTypes.count( refType ) != 0 );
1007
1008 for( auto testIt = refIt + 1; testIt != pins.end(); ++testIt )
1009 {
1010 ERC_SCH_PIN_CONTEXT& testPin = *testIt;
1011
1012 // Multiple pins in the same symbol that share a type,
1013 // name and position are considered
1014 // "stacked" and shouldn't trigger ERC errors
1015 if( refPin.Pin()->IsStacked( testPin.Pin() ) && refPin.Sheet() == testPin.Sheet() )
1016 continue;
1017
1018 ELECTRICAL_PINTYPE testType = testPin.Pin()->GetType();
1019
1020 if( ispowerNet )
1021 hasDriver |= DrivingPowerPinTypes.contains( testType );
1022 else
1023 hasDriver |= DrivingPinTypes.contains( testType );
1024
1025 PIN_ERROR erc = m_settings.GetPinMapValue( refType, testType );
1026
1027 if( erc != PIN_ERROR::OK && m_settings.IsTestEnabled( ERCE_PIN_TO_PIN_WARNING ) )
1028 {
1029 pin_mismatches.emplace_back( std::tuple<iterator_t, iterator_t, PIN_ERROR>{ refIt, testIt, erc } );
1030
1031 if( m_settings.GetERCSortingMetric() == ERC_PIN_SORTING_METRIC::SM_HEURISTICS )
1032 {
1033 pin_mismatch_counts[refIt] = m_settings.GetPinTypeWeight( ( *refIt ).Pin()->GetType() );
1034 pin_mismatch_counts[testIt] = m_settings.GetPinTypeWeight( ( *testIt ).Pin()->GetType() );
1035 }
1036 else
1037 {
1038 if( !pin_mismatch_counts.contains( testIt ) )
1039 pin_mismatch_counts.emplace( testIt, 1 );
1040 else
1041 pin_mismatch_counts[testIt]++;
1042
1043 if( !pin_mismatch_counts.contains( refIt ) )
1044 pin_mismatch_counts.emplace( refIt, 1 );
1045 else
1046 pin_mismatch_counts[refIt]++;
1047 }
1048 }
1049 }
1050 }
1051
1052 std::multimap<size_t, iterator_t, std::greater<size_t>> pins_dsc;
1053
1054 std::transform( pin_mismatch_counts.begin(), pin_mismatch_counts.end(),
1055 std::inserter( pins_dsc, pins_dsc.begin() ),
1056 []( const auto& p )
1057 {
1058 return std::pair<size_t, iterator_t>( p.second, p.first );
1059 } );
1060
1061 for( const auto& [amount, pinItBind] : pins_dsc )
1062 {
1063 auto& pinIt = pinItBind;
1064
1065 if( pin_mismatches.empty() )
1066 break;
1067
1068 SCH_PIN* pin = ( *pinIt ).Pin();
1069 VECTOR2I position = pin->GetPosition();
1070
1071 iterator_t nearest_pin = pins.end();
1072 double smallest_distance = std::numeric_limits<double>::infinity();
1073 PIN_ERROR erc;
1074
1075 std::erase_if(
1076 pin_mismatches,
1077 [&]( const auto& tuple )
1078 {
1079 iterator_t other;
1080
1081 if( pinIt == std::get<0>( tuple ) )
1082 other = std::get<1>( tuple );
1083 else if( pinIt == std::get<1>( tuple ) )
1084 other = std::get<0>( tuple );
1085 else
1086 return false;
1087
1088 if( ( *pinIt ).Sheet().Cmp( ( *other ).Sheet() ) != 0 )
1089 {
1090 if( std::isinf( smallest_distance ) )
1091 {
1092 nearest_pin = other;
1093 erc = std::get<2>( tuple );
1094 }
1095 }
1096 else
1097 {
1098 double distance = position.Distance( ( *other ).Pin()->GetPosition() );
1099
1100 if( std::isinf( smallest_distance ) || distance < smallest_distance )
1101 {
1102 smallest_distance = distance;
1103 nearest_pin = other;
1104 erc = std::get<2>( tuple );
1105 }
1106 }
1107
1108 return true;
1109 } );
1110
1111 if( nearest_pin != pins.end() )
1112 {
1113 SCH_PIN* other_pin = ( *nearest_pin ).Pin();
1114
1117 ercItem->SetItems( pin, other_pin );
1118 ercItem->SetSheetSpecificPath( ( *pinIt ).Sheet() );
1119 ercItem->SetItemsSheetPaths( ( *pinIt ).Sheet(), ( *nearest_pin ).Sheet() );
1120
1121 ercItem->SetErrorMessage( wxString::Format( _( "Pins of type %s and %s are connected" ),
1122 ElectricalPinTypeGetText( pin->GetType() ),
1123 ElectricalPinTypeGetText( other_pin->GetType() ) ) );
1124
1125 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1126 pinToScreenMap[pin]->Append( marker );
1127 errors++;
1128 }
1129 }
1130
1131 if( needsDriver.Pin() && !hasDriver && !has_noconnect )
1132 {
1133 int err_code = ispowerNet ? ERCE_POWERPIN_NOT_DRIVEN : ERCE_PIN_NOT_DRIVEN;
1134
1135 if( m_settings.IsTestEnabled( err_code ) )
1136 {
1137 std::vector<ERC_SCH_PIN_CONTEXT*> pinsToMark;
1138
1139 if( m_showAllErrors )
1140 {
1141 if( !nonPowerPinsNeedingDrivers.empty() )
1142 pinsToMark = nonPowerPinsNeedingDrivers;
1143 else
1144 pinsToMark = pinsNeedingDrivers;
1145 }
1146 else
1147 {
1148 if( !nonPowerPinsNeedingDrivers.empty() )
1149 pinsToMark.push_back( nonPowerPinsNeedingDrivers.front() );
1150 else
1151 pinsToMark.push_back( &needsDriver );
1152 }
1153
1154 for( ERC_SCH_PIN_CONTEXT* pinCtx : pinsToMark )
1155 {
1156 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( err_code );
1157
1158 ercItem->SetItems( pinCtx->Pin() );
1159 ercItem->SetSheetSpecificPath( pinCtx->Sheet() );
1160 ercItem->SetItemsSheetPaths( pinCtx->Sheet() );
1161
1162 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pinCtx->Pin()->GetPosition() );
1163 pinToScreenMap[pinCtx->Pin()]->Append( marker );
1164 errors++;
1165 }
1166 }
1167 }
1168 }
1169
1170 return errors;
1171}
1172
1173
1175{
1176 int errors = 0;
1177
1178 std::unordered_map<wxString, std::pair<wxString, SCH_PIN*>> pinToNetMap;
1179
1180 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
1181 {
1182 const wxString& netName = net.first.Name;
1183
1184 for( CONNECTION_SUBGRAPH* subgraph : net.second )
1185 {
1186 for( SCH_ITEM* item : subgraph->GetItems() )
1187 {
1188 if( item->Type() == SCH_PIN_T )
1189 {
1190 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
1191 const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
1192
1193 if( !pin->GetParentSymbol()->IsMultiUnit() )
1194 continue;
1195
1196 wxString name = pin->GetParentSymbol()->GetRef( &sheet ) + ":" + pin->GetShownNumber();
1197
1198 if( !pinToNetMap.count( name ) )
1199 {
1200 pinToNetMap[name] = std::make_pair( netName, pin );
1201 }
1202 else if( pinToNetMap[name].first != netName )
1203 {
1204 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_NET );
1205
1206 ercItem->SetErrorMessage( wxString::Format( _( "Pin %s is connected to both %s and %s" ),
1207 pin->GetShownNumber(),
1208 netName,
1209 pinToNetMap[name].first ) );
1210
1211 ercItem->SetItems( pin, pinToNetMap[name].second );
1212 ercItem->SetSheetSpecificPath( sheet );
1213 ercItem->SetItemsSheetPaths( sheet, sheet );
1214
1215 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1216 sheet.LastScreen()->Append( marker );
1217 errors += 1;
1218 }
1219 }
1220 }
1221 }
1222 }
1223
1224 return errors;
1225}
1226
1227
1229{
1230 int errors = 0;
1231
1232 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1233 {
1234 SCH_SCREEN* screen = sheet.LastScreen();
1235
1236 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1237 {
1238 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1239 LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get();
1240
1241 if( !libSymbol )
1242 continue;
1243
1244 if( libSymbol->GetDuplicatePinNumbersAreJumpers() )
1245 continue;
1246
1247 std::vector<SCH_PIN*> pins = symbol->GetPins( &sheet );
1248
1249 std::map<wxString, std::vector<std::pair<SCH_PIN*, wxString>>> pinsByNumber;
1250
1251 for( SCH_PIN* pin : pins )
1252 {
1253 SCH_CONNECTION* conn = pin->Connection( &sheet );
1254 wxString netName = conn ? conn->GetNetName() : wxString();
1255
1256 pinsByNumber[pin->GetNumber()].emplace_back( pin, netName );
1257 }
1258
1259 for( const auto& [pinNumber, pinNetPairs] : pinsByNumber )
1260 {
1261 if( pinNetPairs.size() < 2 )
1262 continue;
1263
1264 wxString firstNet = pinNetPairs[0].second;
1265 bool hasDifferentNets = false;
1266 SCH_PIN* conflictPin = nullptr;
1267
1268 for( size_t i = 1; i < pinNetPairs.size(); i++ )
1269 {
1270 if( pinNetPairs[i].second != firstNet )
1271 {
1272 hasDifferentNets = true;
1273 conflictPin = pinNetPairs[i].first;
1274 break;
1275 }
1276 }
1277
1278 if( hasDifferentNets )
1279 {
1280 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DUPLICATE_PIN_ERROR );
1281 wxString msg;
1282
1283 msg.Printf( _( "Pin %s on symbol '%s' is connected to different nets: %s and %s" ),
1284 pinNumber,
1285 symbol->GetRef( &sheet ),
1286 firstNet.IsEmpty() ? _( "<no net>" ) : firstNet,
1287 pinNetPairs[1].second.IsEmpty() ? _( "<no net>" ) : pinNetPairs[1].second );
1288
1289 ercItem->SetErrorMessage( msg );
1290 ercItem->SetItems( pinNetPairs[0].first, conflictPin );
1291 ercItem->SetSheetSpecificPath( sheet );
1292 ercItem->SetItemsSheetPaths( sheet, sheet );
1293
1294 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ),
1295 pinNetPairs[0].first->GetPosition() );
1296 screen->Append( marker );
1297 errors++;
1298 }
1299 }
1300 }
1301 }
1302
1303 return errors;
1304}
1305
1306
1308{
1309 int errors = 0;
1310
1311 auto isGround =
1312 []( const wxString& txt )
1313 {
1314 wxString upper = txt.Upper();
1315 return upper.Contains( wxT( "GND" ) );
1316 };
1317
1318 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1319 {
1320 SCH_SCREEN* screen = sheet.LastScreen();
1321
1322 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1323 {
1324 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1325 bool hasGroundNet = false;
1326 std::vector<SCH_PIN*> mismatched;
1327
1328 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
1329 {
1330 SCH_CONNECTION* conn = pin->Connection( &sheet );
1331 wxString net = conn ? conn->GetNetName() : wxString();
1332 bool netIsGround = isGround( net );
1333
1334 // We are only interested in power pins
1335 if( pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_OUT
1336 && pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_IN )
1337 {
1338 continue;
1339 }
1340
1341 if( netIsGround )
1342 hasGroundNet = true;
1343
1344 if( isGround( pin->GetShownName() ) && !netIsGround )
1345 mismatched.push_back( pin );
1346 }
1347
1348 if( hasGroundNet )
1349 {
1350 for( SCH_PIN* pin : mismatched )
1351 {
1352 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_GROUND_PIN_NOT_GROUND );
1353
1354 ercItem->SetErrorMessage( wxString::Format( _( "Pin %s not connected to ground net" ),
1355 pin->GetShownName() ) );
1356 ercItem->SetItems( pin );
1357 ercItem->SetSheetSpecificPath( sheet );
1358 ercItem->SetItemsSheetPaths( sheet );
1359
1360 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1361 screen->Append( marker );
1362 errors++;
1363 }
1364 }
1365 }
1366 }
1367
1368 return errors;
1369}
1370
1371
1373{
1374 int warnings = 0;
1375
1376 for( const SCH_SHEET_PATH& sheet : m_sheetList )
1377 {
1378 SCH_SCREEN* screen = sheet.LastScreen();
1379
1380 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1381 {
1382 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1383
1384 for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
1385 {
1386 bool valid;
1387 pin->GetStackedPinNumbers( &valid );
1388
1389 if( !valid )
1390 {
1391 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_STACKED_PIN_SYNTAX );
1392 ercItem->SetItems( pin );
1393 ercItem->SetSheetSpecificPath( sheet );
1394 ercItem->SetItemsSheetPaths( sheet );
1395
1396 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), pin->GetPosition() );
1397 screen->Append( marker );
1398 warnings++;
1399 }
1400 }
1401 }
1402 }
1403
1404 return warnings;
1405}
1406
1407
1409{
1410 int errCount = 0;
1411
1412 std::unordered_map<wxString, std::pair<SCH_ITEM*, SCH_SHEET_PATH>> globalLabels;
1413 std::unordered_map<wxString, std::pair<SCH_ITEM*, SCH_SHEET_PATH>> localLabels;
1414
1415 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
1416 {
1417 for( CONNECTION_SUBGRAPH* subgraph : net.second )
1418 {
1419 const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
1420
1421 for( SCH_ITEM* item : subgraph->GetItems() )
1422 {
1423 if( item->Type() == SCH_LABEL_T || item->Type() == SCH_GLOBAL_LABEL_T )
1424 {
1425 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item );
1426 wxString text = label->GetShownText( &sheet, false );
1427
1428 auto& map = item->Type() == SCH_LABEL_T ? localLabels : globalLabels;
1429
1430 if( !map.count( text ) )
1431 {
1432 map[text] = std::make_pair( label, sheet );
1433 }
1434 }
1435 }
1436 }
1437 }
1438
1439 for( auto& [globalText, globalItem] : globalLabels )
1440 {
1441 for( auto& [localText, localItem] : localLabels )
1442 {
1443 if( globalText == localText )
1444 {
1445 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SAME_LOCAL_GLOBAL_LABEL );
1446 ercItem->SetItems( globalItem.first, localItem.first );
1447 ercItem->SetSheetSpecificPath( globalItem.second );
1448 ercItem->SetItemsSheetPaths( globalItem.second, localItem.second );
1449
1450 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), globalItem.first->GetPosition() );
1451 globalItem.second.LastScreen()->Append( marker );
1452
1453 errCount++;
1454 }
1455 }
1456 }
1457
1458 return errCount;
1459}
1460
1461
1463{
1464 int errors = 0;
1465 std::unordered_map<wxString, std::vector<std::tuple<wxString, SCH_ITEM*, SCH_SHEET_PATH>>> generalMap;
1466
1467 auto logError =
1468 [&]( const wxString& normalized, SCH_ITEM* item, const SCH_SHEET_PATH& sheet,
1469 const std::tuple<wxString, SCH_ITEM*, SCH_SHEET_PATH>& other )
1470 {
1471 auto& [otherText, otherItem, otherSheet] = other;
1472 ERCE_T typeOfWarning = ERCE_SIMILAR_LABELS;
1473
1474 if( item->Type() == SCH_PIN_T && otherItem->Type() == SCH_PIN_T )
1475 {
1476 //Two Pins
1477 typeOfWarning = ERCE_SIMILAR_POWER;
1478 }
1479 else if( item->Type() == SCH_PIN_T || otherItem->Type() == SCH_PIN_T )
1480 {
1481 //Pin and Label
1482 typeOfWarning = ERCE_SIMILAR_LABEL_AND_POWER;
1483 }
1484 else
1485 {
1486 //Two Labels
1487 typeOfWarning = ERCE_SIMILAR_LABELS;
1488 }
1489
1490 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( typeOfWarning );
1491 ercItem->SetItems( item, otherItem );
1492 ercItem->SetSheetSpecificPath( sheet );
1493 ercItem->SetItemsSheetPaths( sheet, otherSheet );
1494
1495 SCH_MARKER* marker = new SCH_MARKER( std::move( ercItem ), item->GetPosition() );
1496 sheet.LastScreen()->Append( marker );
1497 };
1498
1499 for( const std::pair<NET_NAME_CODE_CACHE_KEY, std::vector<CONNECTION_SUBGRAPH*>> net : m_nets )
1500 {
1501 for( CONNECTION_SUBGRAPH* subgraph : net.second )
1502 {
1503 const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
1504
1505 for( SCH_ITEM* item : subgraph->GetItems() )
1506 {
1507 switch( item->Type() )
1508 {
1509 case SCH_LABEL_T:
1510 case SCH_HIER_LABEL_T:
1511 case SCH_GLOBAL_LABEL_T:
1512 {
1513 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item );
1514 wxString unnormalized = label->GetShownText( &sheet, false );
1515 wxString normalized = unnormalized.Lower();
1516
1517 generalMap[normalized].emplace_back( std::make_tuple( unnormalized, label, sheet ) );
1518
1519 for( const auto& otherTuple : generalMap.at( normalized ) )
1520 {
1521 const auto& [otherText, otherItem, otherSheet] = otherTuple;
1522
1523 if( unnormalized != otherText )
1524 {
1525 // Similar local labels on different sheets are fine
1526 if( item->Type() == SCH_LABEL_T && otherItem->Type() == SCH_LABEL_T
1527 && sheet != otherSheet )
1528 {
1529 continue;
1530 }
1531
1532 logError( normalized, label, sheet, otherTuple );
1533 errors += 1;
1534 }
1535 }
1536
1537 break;
1538 }
1539 case SCH_PIN_T:
1540 {
1541 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
1542
1543 if( !pin->IsPower() )
1544 continue;
1545
1546 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( pin->GetParentSymbol() );
1547 wxString unnormalized = symbol->GetValue( true, &sheet, false );
1548 wxString normalized = unnormalized.Lower();
1549
1550 generalMap[normalized].emplace_back( std::make_tuple( unnormalized, pin, sheet ) );
1551
1552 for( const auto& otherTuple : generalMap.at( normalized ) )
1553 {
1554 const auto& [otherText, otherItem, otherSheet] = otherTuple;
1555
1556 if( unnormalized != otherText )
1557 {
1558 logError( normalized, pin, sheet, otherTuple );
1559 errors += 1;
1560 }
1561 }
1562
1563 break;
1564 }
1565
1566 default:
1567 break;
1568 }
1569 }
1570 }
1571 }
1572
1573 return errors;
1574}
1575
1576
1578{
1579 wxCHECK( m_schematic, 0 );
1580
1581 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
1583 wxString msg;
1584 int err_count = 0;
1585
1586 for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
1587 {
1588 std::vector<SCH_MARKER*> markers;
1589
1590 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1591 {
1592 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1593 LIB_SYMBOL* libSymbolInSchematic = symbol->GetLibSymbolRef().get();
1594
1595 if( !libSymbolInSchematic )
1596 continue;
1597
1598 wxString libName = symbol->GetLibId().GetLibNickname();
1599
1600 std::optional<const LIBRARY_TABLE_ROW*> optRow =
1601 manager.GetRow( LIBRARY_TABLE_TYPE::SYMBOL, libName );
1602
1603 if( !optRow || ( *optRow )->Disabled() )
1604 {
1605 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
1606 {
1607 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
1608 ercItem->SetItems( symbol );
1609 msg.Printf( _( "The current configuration does not include the symbol library '%s'" ),
1610 UnescapeString( libName ) );
1611 ercItem->SetErrorMessage( msg );
1612
1613 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1614 }
1615
1616 continue;
1617 }
1618 else if( !adapter->IsLibraryLoaded( libName ) )
1619 {
1620 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
1621 {
1622 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
1623 std::optional<wxString> uri =
1624 manager.GetFullURI( LIBRARY_TABLE_TYPE::SYMBOL, libName, true );
1625 wxCHECK2( uri.has_value(), uri = wxEmptyString );
1626 ercItem->SetItems( symbol );
1627 msg.Printf( _( "The symbol library '%s' was not found at '%s'" ),
1628 UnescapeString( libName ), *uri );
1629 ercItem->SetErrorMessage( msg );
1630
1631 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1632 }
1633
1634 continue;
1635 }
1636
1637 wxString symbolName = symbol->GetLibId().GetLibItemName();
1638 LIB_SYMBOL* libSymbol = adapter->LoadSymbol( symbol->GetLibId() );
1639
1640 if( libSymbol == nullptr )
1641 {
1642 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
1643 {
1644 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
1645 ercItem->SetItems( symbol );
1646 msg.Printf( _( "Symbol '%s' not found in symbol library '%s'" ),
1647 UnescapeString( symbolName ),
1648 UnescapeString( libName ) );
1649 ercItem->SetErrorMessage( msg );
1650
1651 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1652 }
1653
1654 continue;
1655 }
1656
1657 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
1659
1660 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_MISMATCH ) )
1661 {
1662 // We have to check for duplicate pins first as they will cause Compare() to fail.
1663 // Symbols with duplicate pins are valid if those pins share the same net, so we
1664 // only skip the comparison here. The actual error checking for duplicate pins on
1665 // different nets is done in TestDuplicatePinNets().
1666 std::vector<wxString> messages;
1667
1668 if( !libSymbolInSchematic->GetDuplicatePinNumbersAreJumpers() )
1669 {
1670 UNITS_PROVIDER unitsProvider( schIUScale, EDA_UNITS::MILS );
1671 CheckDuplicatePins( libSymbolInSchematic, messages, &unitsProvider );
1672 }
1673
1674 if( messages.empty() && flattenedSymbol->Compare( *libSymbolInSchematic, flags ) != 0 )
1675 {
1676 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_MISMATCH );
1677 ercItem->SetItems( symbol );
1678 msg.Printf( _( "Symbol '%s' doesn't match copy in library '%s'" ),
1679 UnescapeString( symbolName ),
1680 UnescapeString( libName ) );
1681 ercItem->SetErrorMessage( msg );
1682
1683 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1684 }
1685 }
1686 }
1687
1688 for( SCH_MARKER* marker : markers )
1689 {
1690 screen->Append( marker );
1691 err_count += 1;
1692 }
1693 }
1694
1695 return err_count;
1696}
1697
1698
1700{
1701 wxCHECK( m_schematic, 0 );
1702
1703 wxString msg;
1704 int err_count = 0;
1705
1706 typedef int (*TESTER_FN_PTR)( const wxString&, PROJECT* );
1707
1708 TESTER_FN_PTR linkTester = (TESTER_FN_PTR) aCvPcb->IfaceOrAddress( KIFACE_TEST_FOOTPRINT_LINK );
1709
1710 for( SCH_SHEET_PATH& sheet : m_sheetList )
1711 {
1712 std::vector<SCH_MARKER*> markers;
1713
1714 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
1715 {
1716 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1717 wxString footprint = symbol->GetFootprintFieldText( true, &sheet, false );
1718
1719 if( footprint.IsEmpty() )
1720 continue;
1721
1722 LIB_ID fpID;
1723
1724 if( fpID.Parse( footprint, true ) >= 0 )
1725 {
1726 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
1727 msg.Printf( _( "'%s' is not a valid footprint identifier" ), footprint );
1728 ercItem->SetErrorMessage( msg );
1729 ercItem->SetItems( symbol );
1730 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1731 continue;
1732 }
1733
1734 wxString libName = fpID.GetLibNickname();
1735 wxString fpName = fpID.GetLibItemName();
1736 int ret = (linkTester)( footprint, aProject );
1737
1739 {
1740 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
1741 msg.Printf( _( "The current configuration does not include the footprint library '%s'" ),
1742 libName );
1743 ercItem->SetErrorMessage( msg );
1744 ercItem->SetItems( symbol );
1745 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1746 }
1748 {
1749 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
1750 msg.Printf( _( "The footprint library '%s' is not enabled in the current configuration" ),
1751 libName );
1752 ercItem->SetErrorMessage( msg );
1753 ercItem->SetItems( symbol );
1754 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1755 }
1757 {
1758 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
1759 msg.Printf( _( "Footprint '%s' not found in library '%s'" ),
1760 fpName,
1761 libName );
1762 ercItem->SetErrorMessage( msg );
1763 ercItem->SetItems( symbol );
1764 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1765 }
1766 }
1767
1768 for( SCH_MARKER* marker : markers )
1769 {
1770 sheet.LastScreen()->Append( marker );
1771 err_count += 1;
1772 }
1773 }
1774
1775 return err_count;
1776}
1777
1778
1780{
1781 wxCHECK( m_schematic, 0 );
1782
1783 wxString msg;
1784 int err_count = 0;
1785
1786 for( SCH_SHEET_PATH& sheet : m_sheetList )
1787 {
1788 std::vector<SCH_MARKER*> markers;
1789
1790 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
1791 {
1792 SCH_SYMBOL* sch_symbol = static_cast<SCH_SYMBOL*>( item );
1793 std::unique_ptr<LIB_SYMBOL>& lib_symbol = sch_symbol->GetLibSymbolRef();
1794
1795 if( !lib_symbol )
1796 continue;
1797
1798 wxArrayString filters = lib_symbol->GetFPFilters();
1799
1800 if( filters.empty() )
1801 continue;
1802
1803 wxString lowerId = sch_symbol->GetFootprintFieldText( true, &sheet, false ).Lower();
1804 LIB_ID footprint;
1805
1806 if( footprint.Parse( lowerId ) > 0 )
1807 continue;
1808
1809 wxString lowerItemName = footprint.GetUniStringLibItemName().Lower();
1810 bool found = false;
1811
1812 for( wxString filter : filters )
1813 {
1814 filter.LowerCase();
1815
1816 // If the filter contains a ':' character, include the library name in the pattern
1817 if( filter.Contains( wxS( ":" ) ) )
1818 found |= lowerId.Matches( filter );
1819 else
1820 found |= lowerItemName.Matches( filter );
1821
1822 if( found )
1823 break;
1824 }
1825
1826 if( !found )
1827 {
1828 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_FOOTPRINT_LINK_ISSUES );
1829 msg.Printf( _( "Assigned footprint (%s) doesn't match footprint filters (%s)" ),
1830 footprint.GetUniStringLibItemName(),
1831 wxJoin( filters, ' ' ) );
1832 ercItem->SetErrorMessage( msg );
1833 ercItem->SetItems( sch_symbol );
1834 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), sch_symbol->GetPosition() ) );
1835 }
1836 }
1837
1838 for( SCH_MARKER* marker : markers )
1839 {
1840 sheet.LastScreen()->Append( marker );
1841 err_count += 1;
1842 }
1843 }
1844
1845 return err_count;
1846}
1847
1848
1850{
1851 const int gridSize = m_schematic->Settings().m_ConnectionGridSize;
1852 int err_count = 0;
1853
1854 for( SCH_SCREEN* screen = m_screens.GetFirst(); screen; screen = m_screens.GetNext() )
1855 {
1856 std::vector<SCH_MARKER*> markers;
1857
1858 for( SCH_ITEM* item : screen->Items() )
1859 {
1860 if( item->Type() == SCH_LINE_T && item->IsConnectable() )
1861 {
1862 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1863
1864 if( ( line->GetStartPoint().x % gridSize ) != 0
1865 || ( line->GetStartPoint().y % gridSize ) != 0 )
1866 {
1867 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
1868 ercItem->SetItems( line );
1869
1870 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), line->GetStartPoint() ) );
1871 }
1872 else if( ( line->GetEndPoint().x % gridSize ) != 0
1873 || ( line->GetEndPoint().y % gridSize ) != 0 )
1874 {
1875 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
1876 ercItem->SetItems( line );
1877
1878 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), line->GetEndPoint() ) );
1879 }
1880 }
1881 if( item->Type() == SCH_BUS_WIRE_ENTRY_T )
1882 {
1883 SCH_BUS_WIRE_ENTRY* entry = static_cast<SCH_BUS_WIRE_ENTRY*>( item );
1884
1885 for( const VECTOR2I& point : entry->GetConnectionPoints() )
1886 {
1887 if( ( point.x % gridSize ) != 0
1888 || ( point.y % gridSize ) != 0 )
1889 {
1890 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
1891 ercItem->SetItems( entry );
1892
1893 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), point ) );
1894 }
1895 }
1896 }
1897 else if( item->Type() == SCH_SYMBOL_T )
1898 {
1899 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1900
1901 for( SCH_PIN* pin : symbol->GetPins( nullptr ) )
1902 {
1903 if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
1904 continue;
1905
1906 VECTOR2I pinPos = pin->GetPosition();
1907
1908 if( ( pinPos.x % gridSize ) != 0 || ( pinPos.y % gridSize ) != 0 )
1909 {
1910 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_ENDPOINT_OFF_GRID );
1911 ercItem->SetItems( pin );
1912
1913 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), pinPos ) );
1914 break;
1915 }
1916 }
1917 }
1918 }
1919
1920 for( SCH_MARKER* marker : markers )
1921 {
1922 screen->Append( marker );
1923 err_count += 1;
1924 }
1925 }
1926
1927 return err_count;
1928}
1929
1930
1932{
1933 WX_STRING_REPORTER reporter;
1934 int err_count = 0;
1935 SIM_LIB_MGR libMgr( &m_schematic->Project() );
1936 wxString variant = m_schematic->GetCurrentVariant();
1937
1938 for( SCH_SHEET_PATH& sheet : m_sheetList )
1939 {
1940 if( sheet.GetExcludedFromSim( variant ) )
1941 continue;
1942
1943 std::vector<SCH_MARKER*> markers;
1944
1945 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
1946 {
1947 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1948
1949 // Power symbols and other symbols which have the reference starting with "#" are
1950 // not included in simulation
1951 if( symbol->GetRef( &sheet ).StartsWith( '#' ) || symbol->ResolveExcludedFromSim() )
1952 continue;
1953
1954 // Reset for each symbol
1955 reporter.Clear();
1956
1957 SIM_LIBRARY::MODEL model = libMgr.CreateModel( &sheet, *symbol, true, 0, variant, reporter );
1958
1959 if( reporter.HasMessage() )
1960 {
1961 wxString msg = reporter.GetMessages();
1962 std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMULATION_MODEL );
1963
1964 //Remove \n and \r at e.o.l if any:
1965 msg.Trim();
1966
1967 ercItem->SetErrorMessage( msg );
1968 ercItem->SetItems( symbol );
1969
1970 markers.emplace_back( new SCH_MARKER( std::move( ercItem ), symbol->GetPosition() ) );
1971 }
1972 }
1973
1974 for( SCH_MARKER* marker : markers )
1975 {
1976 sheet.LastScreen()->Append( marker );
1977 err_count += 1;
1978 }
1979 }
1980
1981 return err_count;
1982}
1983
1984
1986 KIFACE* aCvPcb, PROJECT* aProject, PROGRESS_REPORTER* aProgressReporter )
1987{
1988 m_sheetList.AnnotatePowerSymbols();
1989
1990 // Test duplicate sheet names inside a given sheet. While one can have multiple references
1991 // to the same file, each must have a unique name.
1992 if( m_settings.IsTestEnabled( ERCE_DUPLICATE_SHEET_NAME ) )
1993 {
1994 if( aProgressReporter )
1995 aProgressReporter->AdvancePhase( _( "Checking sheet names..." ) );
1996
1998 }
1999
2000 // The connection graph has a whole set of ERC checks it can run
2001 if( aProgressReporter )
2002 aProgressReporter->AdvancePhase( _( "Checking conflicts..." ) );
2003
2004 // If we are using the new connectivity, make sure that we do a full-rebuild
2005 if( aEditFrame )
2006 {
2007 if( ADVANCED_CFG::GetCfg().m_IncrementalConnectivity )
2008 aEditFrame->RecalculateConnections( nullptr, GLOBAL_CLEANUP );
2009 else
2010 aEditFrame->RecalculateConnections( nullptr, NO_CLEANUP );
2011 }
2012
2013 m_schematic->ConnectionGraph()->RunERC();
2014
2015 if( aProgressReporter )
2016 aProgressReporter->AdvancePhase( _( "Checking units..." ) );
2017
2018 // Test is all units of each multiunit symbol have the same footprint assigned.
2019 if( m_settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_FP ) )
2020 {
2021 if( aProgressReporter )
2022 aProgressReporter->AdvancePhase( _( "Checking footprints..." ) );
2023
2025 }
2026
2027 if( m_settings.IsTestEnabled( ERCE_MISSING_UNIT )
2028 || m_settings.IsTestEnabled( ERCE_MISSING_INPUT_PIN )
2029 || m_settings.IsTestEnabled( ERCE_MISSING_POWER_INPUT_PIN )
2030 || m_settings.IsTestEnabled( ERCE_MISSING_BIDI_PIN ) )
2031 {
2033 }
2034
2035 if( aProgressReporter )
2036 aProgressReporter->AdvancePhase( _( "Checking pins..." ) );
2037
2038 if( m_settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_NET ) )
2040
2041 if( m_settings.IsTestEnabled( ERCE_DUPLICATE_PIN_ERROR ) )
2043
2044 // Test pins on each net against the pin connection table
2045 if( m_settings.IsTestEnabled( ERCE_PIN_TO_PIN_ERROR )
2046 || m_settings.IsTestEnabled( ERCE_POWERPIN_NOT_DRIVEN )
2047 || m_settings.IsTestEnabled( ERCE_PIN_NOT_DRIVEN ) )
2048 {
2049 TestPinToPin();
2050 }
2051
2052 if( m_settings.IsTestEnabled( ERCE_GROUND_PIN_NOT_GROUND ) )
2054
2055 if( m_settings.IsTestEnabled( ERCE_STACKED_PIN_SYNTAX ) )
2057
2058 // Test similar labels (i;e. labels which are identical when
2059 // using case insensitive comparisons)
2060 if( m_settings.IsTestEnabled( ERCE_SIMILAR_LABELS )
2061 || m_settings.IsTestEnabled( ERCE_SIMILAR_POWER )
2062 || m_settings.IsTestEnabled( ERCE_SIMILAR_LABEL_AND_POWER ) )
2063 {
2064 if( aProgressReporter )
2065 aProgressReporter->AdvancePhase( _( "Checking similar labels..." ) );
2066
2068 }
2069
2070 if( m_settings.IsTestEnabled( ERCE_SAME_LOCAL_GLOBAL_LABEL ) )
2071 {
2072 if( aProgressReporter )
2073 aProgressReporter->AdvancePhase( _( "Checking local and global labels..." ) );
2074
2076 }
2077
2078 if( m_settings.IsTestEnabled( ERCE_UNRESOLVED_VARIABLE ) )
2079 {
2080 if( aProgressReporter )
2081 aProgressReporter->AdvancePhase( _( "Checking for unresolved variables..." ) );
2082
2083 TestTextVars( aDrawingSheet );
2084 }
2085
2086 if( m_settings.IsTestEnabled( ERCE_SIMULATION_MODEL ) )
2087 {
2088 if( aProgressReporter )
2089 aProgressReporter->AdvancePhase( _( "Checking SPICE models..." ) );
2090
2092 }
2093
2094 if( m_settings.IsTestEnabled( ERCE_NOCONNECT_CONNECTED ) )
2095 {
2096 if( aProgressReporter )
2097 aProgressReporter->AdvancePhase( _( "Checking no connect pins for connections..." ) );
2098
2100 }
2101
2102 if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES )
2103 || m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_MISMATCH ) )
2104 {
2105 if( aProgressReporter )
2106 aProgressReporter->AdvancePhase( _( "Checking for library symbol issues..." ) );
2107
2109 }
2110
2111 if( m_settings.IsTestEnabled( ERCE_FOOTPRINT_LINK_ISSUES ) && aCvPcb )
2112 {
2113 if( aProgressReporter )
2114 aProgressReporter->AdvancePhase( _( "Checking for footprint link issues..." ) );
2115
2116 TestFootprintLinkIssues( aCvPcb, aProject );
2117 }
2118
2119 if( m_settings.IsTestEnabled( ERCE_FOOTPRINT_FILTERS ) )
2120 {
2121 if( aProgressReporter )
2122 aProgressReporter->AdvancePhase( _( "Checking footprint assignments against footprint filters..." ) );
2123
2125 }
2126
2127 if( m_settings.IsTestEnabled( ERCE_ENDPOINT_OFF_GRID ) )
2128 {
2129 if( aProgressReporter )
2130 aProgressReporter->AdvancePhase( _( "Checking for off grid pins and wires..." ) );
2131
2133 }
2134
2135 if( m_settings.IsTestEnabled( ERCE_FOUR_WAY_JUNCTION ) )
2136 {
2137 if( aProgressReporter )
2138 aProgressReporter->AdvancePhase( _( "Checking for four way junctions..." ) );
2139
2141 }
2142
2143 if( m_settings.IsTestEnabled( ERCE_LABEL_MULTIPLE_WIRES ) )
2144 {
2145 if( aProgressReporter )
2146 aProgressReporter->AdvancePhase( _( "Checking for labels on more than one wire..." ) );
2147
2149 }
2150
2151 if( m_settings.IsTestEnabled( ERCE_UNDEFINED_NETCLASS ) )
2152 {
2153 if( aProgressReporter )
2154 aProgressReporter->AdvancePhase( _( "Checking for undefined netclasses..." ) );
2155
2157 }
2158
2159 m_schematic->ResolveERCExclusionsPostUpdate();
2160}
const char * name
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:114
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr Vec Centre() const
Definition box2.h:97
A subgraph is a set of items that are electrically connected on a single sheet.
const std::set< SCH_ITEM * > & GetItems() const
Provide a read-only reference to the items in the subgraph.
const SCH_ITEM * GetNoConnect() const
const SCH_SHEET_PATH & GetSheet() const
Base class to handle basic graphic items.
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
DS_DRAW_ITEM_BASE * GetFirst()
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
DS_DRAW_ITEM_BASE * GetNext()
void SetProject(const PROJECT *aProject)
A graphic text.
const PAGE_INFO & GetPageInfo()
const TITLE_BLOCK & GetTitleBlock()
virtual VECTOR2I GetPosition() const
Definition eda_item.h:277
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:98
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:241
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Definition erc_item.cpp:307
A class used to associate a SCH_PIN with its owning SCH_SHEET_PATH, in order to handle ERC checks acr...
const SCH_SHEET_PATH & Sheet() const
Get the SCH_SHEET_PATH context for the paired SCH_PIN.
SCH_PIN * Pin() const
Get the SCH_PIN for this context.
int TestLibSymbolIssues()
Test symbols for changed library symbols and broken symbol library links.
Definition erc.cpp:1577
const NET_MAP & m_nets
Definition erc.h:202
int TestStackedPinNotation()
Checks for pin numbers that resemble stacked pin notation but are invalid.
Definition erc.cpp:1372
void TestTextVars(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Check for any unresolved text variable references.
Definition erc.cpp:186
int TestPinToPin()
Checks the full netlist against the pin-to-pin connectivity requirements.
Definition erc.cpp:914
int TestSimilarLabels()
Checks for labels that differ only in capitalization.
Definition erc.cpp:1462
SCH_MULTI_UNIT_REFERENCE_MAP m_refMap
Definition erc.h:201
SCH_SCREENS m_screens
Definition erc.h:200
int TestFootprintLinkIssues(KIFACE *aCvPcb, PROJECT *aProject)
Test footprint links against the current footprint libraries.
Definition erc.cpp:1699
int TestOffGridEndpoints()
Test pins and wire ends for being off grid.
Definition erc.cpp:1849
int TestDuplicateSheetNames(bool aCreateMarker)
Inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).
Definition erc.cpp:143
int TestSameLocalGlobalLabel()
Checks for global and local labels with the same name.
Definition erc.cpp:1408
int TestMultUnitPinConflicts()
Checks if shared pins on multi-unit symbols have been connected to different nets.
Definition erc.cpp:1174
int TestNoConnectPins()
In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type.
Definition erc.cpp:823
int TestFootprintFilters()
Test symbols to ensure that assigned footprint passes any given footprint filters.
Definition erc.cpp:1779
int TestDuplicatePinNets()
Checks if duplicate pin numbers within a symbol are connected to different nets.
Definition erc.cpp:1228
ERC_SETTINGS & m_settings
Definition erc.h:198
int TestFourWayJunction()
Test to see if there are potentially confusing 4-way junctions in the schematic.
Definition erc.cpp:744
int TestMissingNetclasses()
Tests for netclasses that are referenced but not defined.
Definition erc.cpp:636
int TestSimModelIssues()
Test SPICE models for various issues.
Definition erc.cpp:1931
SCH_SHEET_LIST m_sheetList
Definition erc.h:199
bool m_showAllErrors
Definition erc.h:203
int TestGroundPins()
Checks for ground-labeled pins not on a ground net while another pin is.
Definition erc.cpp:1307
SCHEMATIC * m_schematic
Definition erc.h:197
void RunTests(DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, KIFACE *aCvPcb, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter)
Definition erc.cpp:1985
int TestMissingUnits()
Test for uninstantiated units of multi unit symbols.
Definition erc.cpp:502
int TestLabelMultipleWires()
Test to see if there are labels that are connected to more than one wire.
Definition erc.cpp:689
int TestMultiunitFootprints()
Test if all units of each multiunit symbol have the same footprint assigned.
Definition erc.cpp:441
bool IsLibraryLoaded(const wxString &aNickname)
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
std::optional< LIBRARY_TABLE_ROW * > GetRow(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition lib_id.cpp:52
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition lib_id.h:112
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
Define a library symbol object.
Definition lib_symbol.h:83
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
int GetUnitCount() const override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
bool GetDuplicatePinNumbersAreJumpers() const
Definition lib_symbol.h:753
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
virtual LIBRARY_MANAGER & GetLibraryManager() const
Definition pgm_base.h:134
A progress reporter interface for use in multi-threaded environments.
virtual void AdvancePhase()=0
Use the next available virtual zone of the dialog progress bar.
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
Container for project specific data.
Definition project.h:65
virtual bool HasMessage() const
Returns true if any messages were reported.
Definition reporter.h:134
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Class for a wire to bus entry.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString GetNetName() const
Schematic editor (Eeschema) main window.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr)
Generate the connection data for the entire schematic hierarchy.
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0, const wxString &aVariantName=wxEmptyString) const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
int GetBodyStyle() const
Definition sch_item.h:247
bool ResolveExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:282
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:42
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition sch_line.cpp:716
VECTOR2I GetEndPoint() const
Definition sch_line.h:148
VECTOR2I GetStartPoint() const
Definition sch_line.h:139
bool IsEndPoint(const VECTOR2I &aPoint) const override
Test if aPt is an end point of this schematic object.
Definition sch_line.h:91
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
Definition sch_line.cpp:985
bool IsVisible() const
Definition sch_pin.cpp:377
bool IsStacked(const SCH_PIN *aPin) const
Definition sch_pin.cpp:466
bool IsPower() const
Check if the pin is either a global or local power pin.
Definition sch_pin.cpp:371
ELECTRICAL_PINTYPE GetType() const
Definition sch_pin.cpp:313
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
SCH_REFERENCE & GetItem(size_t aIdx)
A helper to define a symbol's reference designator in a schematic.
const SCH_SHEET_PATH & GetSheetPath() const
const wxString GetFootprint() const
SCH_SYMBOL * GetSymbol() const
LIB_SYMBOL * GetLibPart() const
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:118
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
VECTOR2I GetPosition() const override
Definition sch_shape.h:85
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SCREEN * LastScreen()
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
Definition sch_sheet.h:88
VECTOR2I GetPosition() const override
Definition sch_sheet.h:496
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition sch_sheet.h:233
wxString GetShownName(bool aAllowExtraText) const
Definition sch_sheet.h:138
Schematic symbol object.
Definition sch_symbol.h:76
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const override
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const
VECTOR2I GetPosition() const override
Definition sch_symbol.h:867
const LIB_ID & GetLibId() const override
Definition sch_symbol.h:165
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:184
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
virtual wxString GetShownText(const RENDER_SETTINGS *aSettings, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
VECTOR2I GetPosition() const override
Definition sch_text.h:147
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition sch_text.cpp:295
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition sch_text.cpp:316
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
An interface to the global shared library manager that is schematic-specific and linked to one projec...
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
const TRANSFORM & GetTransform() const
Definition symbol.h:247
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition transform.cpp:44
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
Definition vector2d.h:561
A wrapper for reporting to a wxString object.
Definition reporter.h:191
void Clear() override
Definition reporter.cpp:84
const wxString & GetMessages() const
Definition reporter.cpp:78
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition common.cpp:558
The common library.
#define FOR_ERC_DRC
Expand '${var-name}' templates in text.
Definition common.h:96
#define _(s)
@ NO_RECURSE
Definition eda_item.h:52
void CheckDuplicatePins(LIB_SYMBOL *aSymbol, std::vector< wxString > &aMessages, UNITS_PROVIDER *aUnitsProvider)
const wxString CommentERC_V[]
Definition erc.cpp:96
const wxString CommentERC_H[]
Definition erc.cpp:79
const std::set< ELECTRICAL_PINTYPE > DrivenPinTypes
Definition erc.cpp:134
const std::set< ELECTRICAL_PINTYPE > DrivingPinTypes
Definition erc.cpp:116
const std::set< ELECTRICAL_PINTYPE > DrivingPowerPinTypes
Definition erc.cpp:128
ERCE_T
ERC error codes.
@ ERCE_POWERPIN_NOT_DRIVEN
Power input pin connected to some others pins but no power out pin to drive it.
@ ERCE_SIMILAR_POWER
2 power pins are equal for case insensitive comparisons.
@ ERCE_MISSING_POWER_INPUT_PIN
Symbol has power input pins that are not placed on the schematic.
@ ERCE_GROUND_PIN_NOT_GROUND
A ground-labeled pin is not on a ground net while another pin is.
@ ERCE_SIMILAR_LABELS
2 labels are equal for case insensitive comparisons.
@ ERCE_STACKED_PIN_SYNTAX
Pin name resembles stacked pin notation.
@ ERCE_ENDPOINT_OFF_GRID
Pin or wire-end off grid.
@ ERCE_SAME_LOCAL_GLOBAL_LABEL
2 labels are equal for case insensitive comparisons.
@ ERCE_SIMILAR_LABEL_AND_POWER
label and pin are equal for case insensitive comparisons.
@ ERCE_FOOTPRINT_LINK_ISSUES
The footprint link is invalid, or points to a missing (or inactive) footprint or library.
@ ERCE_DUPLICATE_PIN_ERROR
@ ERCE_DIFFERENT_UNIT_NET
Shared pin in a multi-unit symbol is connected to more than one net.
@ ERCE_FOUR_WAY_JUNCTION
A four-way junction was found.
@ ERCE_UNDEFINED_NETCLASS
A netclass was referenced but not defined.
@ ERCE_UNRESOLVED_VARIABLE
A text variable could not be resolved.
@ ERCE_SIMULATION_MODEL
An error was found in the simulation model.
@ ERCE_LIB_SYMBOL_MISMATCH
Symbol doesn't match copy in library.
@ ERCE_GENERIC_ERROR
@ ERCE_DIFFERENT_UNIT_FP
Different units of the same symbol have different footprints assigned.
@ ERCE_NOCONNECT_CONNECTED
A no connect symbol is connected to more than 1 pin.
@ ERCE_PIN_TO_PIN_WARNING
@ ERCE_PIN_NOT_DRIVEN
Pin connected to some others pins but no pin to drive it.
@ ERCE_MISSING_INPUT_PIN
Symbol has input pins that are not placed.
@ ERCE_MISSING_UNIT
Symbol has units that are not placed on the schematic.
@ ERCE_DUPLICATE_SHEET_NAME
Duplicate sheet names within a given sheet.
@ ERCE_MISSING_BIDI_PIN
Symbol has bi-directional pins that are not placed.
@ ERCE_LIB_SYMBOL_ISSUES
Symbol not found in active libraries.
@ ERCE_FOOTPRINT_FILTERS
The assigned footprint doesn't match the footprint filters.
@ ERCE_GENERIC_WARNING
@ ERCE_LABEL_MULTIPLE_WIRES
A label is connected to more than one wire.
@ ERCE_PIN_TO_PIN_ERROR
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
@ KIFACE_TEST_FOOTPRINT_LINK_LIBRARY_NOT_ENABLED
Definition kiface_ids.h:48
@ KIFACE_TEST_FOOTPRINT_LINK
Definition kiface_ids.h:46
@ KIFACE_TEST_FOOTPRINT_LINK_NO_LIBRARY
Definition kiface_ids.h:47
@ KIFACE_TEST_FOOTPRINT_LINK_NO_FOOTPRINT
Definition kiface_ids.h:49
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition pin_type.h:36
@ PT_INPUT
usual pin input: must be connected
Definition pin_type.h:37
@ PT_NC
not connected (must be left open)
Definition pin_type.h:50
@ PT_OUTPUT
usual output
Definition pin_type.h:38
@ PT_TRISTATE
tri state bus pin
Definition pin_type.h:40
@ PT_BIDI
input or output (like port for a microprocessor)
Definition pin_type.h:39
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
Definition pin_type.h:47
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
Definition pin_type.h:46
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
Definition pin_type.h:45
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
Definition pin_type.h:43
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE)
Definition pin_type.cpp:207
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
@ NO_CLEANUP
Definition schematic.h:75
@ GLOBAL_CLEANUP
Definition schematic.h:77
wxString UnescapeString(const wxString &aSource)
Implement a participant in the KIWAY alchemy.
Definition kiway.h:155
virtual void * IfaceOrAddress(int aDataId)=0
Return pointer to the requested object.
KIBIS_MODEL * model
KIBIS_PIN * pin
@ SCH_LINE_T
Definition typeinfo.h:167
@ SCH_NO_CONNECT_T
Definition typeinfo.h:164
@ SCH_SYMBOL_T
Definition typeinfo.h:176
@ SCH_FIELD_T
Definition typeinfo.h:154
@ SCH_LABEL_T
Definition typeinfo.h:171
@ SCH_LOCATE_ANY_T
Definition typeinfo.h:203
@ SCH_SHEET_T
Definition typeinfo.h:179
@ SCH_HIER_LABEL_T
Definition typeinfo.h:173
@ SCH_TEXT_T
Definition typeinfo.h:155
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:165
@ SCH_TEXTBOX_T
Definition typeinfo.h:156
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:172
@ SCH_PIN_T
Definition typeinfo.h:157
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695