KiCad PCB EDA Suite
eeschema/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 <stambaughw@gmail.com>
6  * Copyright (C) 1992-2020 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 
31 #include "connection_graph.h"
32 #include <erc.h>
33 #include <kicad_string.h>
34 #include <lib_pin.h>
35 #include <sch_edit_frame.h>
36 #include <sch_marker.h>
37 #include <sch_reference_list.h>
38 #include <sch_sheet.h>
39 #include <schematic.h>
42 #include <wx/ffile.h>
43 
44 
45 /* ERC tests :
46  * 1 - conflicts between connected pins ( example: 2 connected outputs )
47  * 2 - minimal connections requirements ( 1 input *must* be connected to an
48  * output, or a passive pin )
49  */
50 
51 
52 /*
53  * Minimal ERC requirements:
54  * All pins *must* be connected (except ELECTRICAL_PINTYPE::PT_NC).
55  * When a pin is not connected in schematic, the user must place a "non
56  * connected" symbol to this pin.
57  * This ensures a forgotten connection will be detected.
58  */
59 
60 /* Messages for conflicts :
61  * ELECTRICAL_PINTYPE::PT_INPUT, ELECTRICAL_PINTYPE::PT_OUTPUT, ELECTRICAL_PINTYPE:PT_:BIDI,
62  * ELECTRICAL_PINTYPE::PT_TRISTATE, ELECTRICAL_PINTYPE::PT_PASSIVE,
63  * ELECTRICAL_PINTYPE::PT_UNSPECIFIED, ELECTRICAL_PINTYPE::PT_POWER_IN,
64  * ELECTRICAL_PINTYPE::PT_POWER_OUT, ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR,
65  * ELECTRICAL_PINTYPE::PT_OPENEMITTER, ELECTRICAL_PINTYPE::PT_NC
66  *
67  * These messages are used to show the ERC matrix in ERC dialog
68  */
69 
70 // Messages for matrix rows:
71 const wxString CommentERC_H[] =
72 {
73  _( "Input Pin" ),
74  _( "Output Pin" ),
75  _( "Bidirectional Pin" ),
76  _( "Tri-State Pin" ),
77  _( "Passive Pin" ),
78  _( "Unspecified Pin" ),
79  _( "Power Input Pin" ),
80  _( "Power Output Pin" ),
81  _( "Open Collector" ),
82  _( "Open Emitter" ),
83  _( "No Connection" )
84 };
85 
86 // Messages for matrix columns
87 const wxString CommentERC_V[] =
88 {
89  _( "Input Pin" ),
90  _( "Output Pin" ),
91  _( "Bidirectional Pin" ),
92  _( "Tri-State Pin" ),
93  _( "Passive Pin" ),
94  _( "Unspecified Pin" ),
95  _( "Power Input Pin" ),
96  _( "Power Output Pin" ),
97  _( "Open Collector" ),
98  _( "Open Emitter" ),
99  _( "No Connection" )
100 };
101 
102 
103 int ERC_TESTER::TestDuplicateSheetNames( bool aCreateMarker )
104 {
105  SCH_SCREEN* screen;
106  int err_count = 0;
107 
108  SCH_SCREENS screenList( m_schematic->Root() );
109 
110  for( screen = screenList.GetFirst(); screen != nullptr; screen = screenList.GetNext() )
111  {
112  std::vector<SCH_SHEET*> list;
113 
114  for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
115  list.push_back( static_cast<SCH_SHEET*>( item ) );
116 
117  for( size_t i = 0; i < list.size(); i++ )
118  {
119  SCH_SHEET* sheet = list[i];
120 
121  for( size_t j = i + 1; j < list.size(); j++ )
122  {
123  SCH_SHEET* test_item = list[j];
124 
125  // We have found a second sheet: compare names
126  // we are using case insensitive comparison to avoid mistakes between
127  // similar names like Mysheet and mysheet
128  if( sheet->GetName().CmpNoCase( test_item->GetName() ) == 0 )
129  {
130  if( aCreateMarker )
131  {
132  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DUPLICATE_SHEET_NAME );
133  ercItem->SetItems( sheet, test_item );
134 
135  SCH_MARKER* marker = new SCH_MARKER( ercItem, sheet->GetPosition() );
136  screen->Append( marker );
137  }
138 
139  err_count++;
140  }
141  }
142  }
143  }
144 
145  return err_count;
146 }
147 
148 
150 {
151  WS_DRAW_ITEM_LIST wsItems;
152 
153  auto unresolved = [this]( wxString str )
154  {
155  str = ExpandEnvVarSubstitutions( str, &m_schematic->Prj() );
156  return str.Matches( wxT( "*${*}*" ) );
157  };
158 
159  if( aWorksheet )
160  {
161  wsItems.SetMilsToIUfactor( IU_PER_MILS );
162  wsItems.SetSheetNumber( 1 );
163  wsItems.SetSheetCount( 1 );
164  wsItems.SetFileName( "dummyFilename" );
165  wsItems.SetSheetName( "dummySheet" );
166  wsItems.SetSheetLayer( "dummyLayer" );
167  wsItems.SetProject( &m_schematic->Prj() );
168  wsItems.BuildWorkSheetGraphicList( aWorksheet->GetPageInfo(), aWorksheet->GetTitleBlock() );
169  }
170 
171  SCH_SHEET_PATH savedCurrentSheet = m_schematic->CurrentSheet();
173 
174  for( SCH_SHEET_PATH& sheet : sheets )
175  {
176  m_schematic->SetCurrentSheet( sheet );
177  SCH_SCREEN* screen = sheet.LastScreen();
178 
179  for( SCH_ITEM* item : screen->Items().OfType( SCH_LOCATE_ANY_T ) )
180  {
181  if( item->Type() == SCH_COMPONENT_T )
182  {
183  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
184 
185  for( SCH_FIELD& field : component->GetFields() )
186  {
187  if( unresolved( field.GetShownText() ) )
188  {
189  wxPoint pos = field.GetPosition() - component->GetPosition();
190  pos = component->GetTransform().TransformCoordinate( pos );
191  pos += component->GetPosition();
192 
193  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
194  ercItem->SetItems( &field );
195 
196  SCH_MARKER* marker = new SCH_MARKER( ercItem, pos );
197  screen->Append( marker );
198  }
199  }
200  }
201  else if( item->Type() == SCH_SHEET_T )
202  {
203  SCH_SHEET* subSheet = static_cast<SCH_SHEET*>( item );
204 
205  for( SCH_FIELD& field : subSheet->GetFields() )
206  {
207  if( unresolved( field.GetShownText() ) )
208  {
209  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
210  ercItem->SetItems( &field );
211 
212  SCH_MARKER* marker = new SCH_MARKER( ercItem, field.GetPosition() );
213  screen->Append( marker );
214  }
215  }
216 
217  for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
218  {
219  if( pin->GetShownText().Matches( wxT( "*${*}*" ) ) )
220  {
221  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
222  ercItem->SetItems( pin );
223 
224  SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetPosition() );
225  screen->Append( marker );
226  }
227  }
228  }
229  else if( SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( item ) )
230  {
231  if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
232  {
233  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
234  ercItem->SetItems( text );
235 
236  SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
237  screen->Append( marker );
238  }
239  }
240  }
241 
242  for( WS_DRAW_ITEM_BASE* item = wsItems.GetFirst(); item; item = wsItems.GetNext() )
243  {
244  if( WS_DRAW_ITEM_TEXT* text = dynamic_cast<WS_DRAW_ITEM_TEXT*>( item ) )
245  {
246  if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
247  {
248  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
249  ercItem->SetErrorMessage( _( "Unresolved text variable in worksheet." ) );
250 
251  SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
252  screen->Append( marker );
253  }
254  }
255  }
256  }
257 
258  m_schematic->SetCurrentSheet( savedCurrentSheet );
259 }
260 
261 
263 {
264  wxString msg;
265  int err_count = 0;
266 
267  SCH_SCREENS screens( m_schematic->Root() );
268  std::vector< std::shared_ptr<BUS_ALIAS> > aliases;
269 
270  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
271  {
272  std::unordered_set< std::shared_ptr<BUS_ALIAS> > screen_aliases = screen->GetBusAliases();
273 
274  for( const std::shared_ptr<BUS_ALIAS>& alias : screen_aliases )
275  {
276  for( const std::shared_ptr<BUS_ALIAS>& test : aliases )
277  {
278  if( alias->GetName() == test->GetName() && alias->Members() != test->Members() )
279  {
280  msg.Printf( _( "Bus alias %s has conflicting definitions on %s and %s" ),
281  alias->GetName(),
282  alias->GetParent()->GetFileName(),
283  test->GetParent()->GetFileName() );
284 
285  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_BUS_ALIAS_CONFLICT );
286  ercItem->SetErrorMessage( msg );
287 
288  SCH_MARKER* marker = new SCH_MARKER( ercItem, wxPoint() );
289  test->GetParent()->Append( marker );
290 
291  ++err_count;
292  }
293  }
294  }
295 
296  aliases.insert( aliases.end(), screen_aliases.begin(), screen_aliases.end() );
297  }
298 
299  return err_count;
300 }
301 
302 
304 {
306 
307  int errors = 0;
308  std::map<wxString, LIB_ID> footprints;
310  sheets.GetMultiUnitComponents( refMap, true );
311 
312  for( std::pair<const wxString, SCH_REFERENCE_LIST>& component : refMap )
313  {
314  SCH_REFERENCE_LIST& refList = component.second;
315 
316  if( refList.GetCount() == 0 )
317  {
318  wxFAIL; // it should not happen
319  continue;
320  }
321 
322  // Reference footprint
323  SCH_COMPONENT* unit = nullptr;
324  wxString unitName;
325  wxString unitFP;
326 
327  for( unsigned i = 0; i < refList.GetCount(); ++i )
328  {
329  SCH_SHEET_PATH sheetPath = refList.GetItem( i ).GetSheetPath();
330  unitFP = refList.GetItem( i ).GetFootprint();
331 
332  if( !unitFP.IsEmpty() )
333  {
334  unit = refList.GetItem( i ).GetComp();
335  unitName = unit->GetRef( &sheetPath, true );
336  break;
337  }
338  }
339 
340  for( unsigned i = 0; i < refList.GetCount(); ++i )
341  {
342  SCH_REFERENCE& secondRef = refList.GetItem( i );
343  SCH_COMPONENT* secondUnit = secondRef.GetComp();
344  wxString secondName = secondUnit->GetRef( &secondRef.GetSheetPath(), true );
345  const wxString secondFp = secondRef.GetFootprint();
346  wxString msg;
347 
348  if( unit && !secondFp.IsEmpty() && unitFP != secondFp )
349  {
350  msg.Printf( _( "Different footprints assigned to %s and %s" ),
351  unitName, secondName );
352 
353  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_FP );
354  ercItem->SetErrorMessage( msg );
355  ercItem->SetItems( unit, secondUnit );
356 
357  SCH_MARKER* marker = new SCH_MARKER( ercItem, secondUnit->GetPosition() );
358  secondRef.GetSheetPath().LastScreen()->Append( marker );
359 
360  ++errors;
361  }
362  }
363  }
364 
365  return errors;
366 }
367 
368 
370 {
371  int err_count = 0;
372 
373  for( const SCH_SHEET_PATH& sheet : m_schematic->GetSheets() )
374  {
375  std::map<wxPoint, std::vector<SCH_PIN*>> pinMap;
376 
377  for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
378  {
379  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
380 
381  for( SCH_PIN* pin : comp->GetPins( &sheet ) )
382  {
383  if( pin->GetLibPin()->GetType() == ELECTRICAL_PINTYPE::PT_NC )
384  pinMap[pin->GetPosition()].emplace_back( pin );
385  }
386  }
387 
388  for( auto& pair : pinMap )
389  {
390  if( pair.second.size() > 1 )
391  {
392  err_count++;
393 
394  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
395 
396  ercItem->SetItems( pair.second[0], pair.second[1],
397  pair.second.size() > 2 ? pair.second[2] : nullptr,
398  pair.second.size() > 3 ? pair.second[3] : nullptr );
399  ercItem->SetErrorMessage( _( "Pins with \"no connection\" type are connected" ) );
400 
401  SCH_MARKER* marker = new SCH_MARKER( ercItem, pair.first );
402  sheet.LastScreen()->Append( marker );
403  }
404  }
405  }
406 
407  return err_count;
408 }
409 
410 
412 {
413  ERC_SETTINGS& settings = m_schematic->ErcSettings();
414  const NET_MAP& nets = m_schematic->ConnectionGraph()->GetNetMap();
415 
416  int errors = 0;
417 
418  for( const std::pair<NET_NAME_CODE, std::vector<CONNECTION_SUBGRAPH*>> net : nets )
419  {
420  std::vector<SCH_PIN*> pins;
421  std::unordered_map<EDA_ITEM*, SCH_SCREEN*> pinToScreenMap;
422 
423  for( CONNECTION_SUBGRAPH* subgraph: net.second )
424  {
425  for( EDA_ITEM* item : subgraph->m_items )
426  {
427  if( item->Type() == SCH_PIN_T )
428  {
429  pins.emplace_back( static_cast<SCH_PIN*>( item ) );
430  pinToScreenMap[item] = subgraph->m_sheet.LastScreen();
431  }
432  }
433  }
434 
435  // Single-pin nets are handled elsewhere
436  if( pins.size() < 2 )
437  continue;
438 
439  std::set<std::pair<SCH_PIN*, SCH_PIN*>> tested;
440 
441  for( SCH_PIN* refPin : pins )
442  {
443  ELECTRICAL_PINTYPE refType = refPin->GetType();
444 
445  for( SCH_PIN* testPin : pins )
446  {
447  if( testPin == refPin )
448  continue;
449 
450  std::pair<SCH_PIN*, SCH_PIN*> pair1 = std::make_pair( refPin, testPin );
451  std::pair<SCH_PIN*, SCH_PIN*> pair2 = std::make_pair( testPin, refPin );
452 
453  if( tested.count( pair1 ) || tested.count( pair2 ) )
454  continue;
455 
456  tested.insert( pair1 );
457  tested.insert( pair2 );
458 
459  ELECTRICAL_PINTYPE testType = testPin->GetType();
460 
461  PIN_ERROR erc = settings.GetPinMapValue( refType, testType );
462 
463  if( erc != PIN_ERROR::OK )
464  {
465  std::shared_ptr<ERC_ITEM> ercItem =
468  ercItem->SetItems( refPin, testPin );
469 
470  ercItem->SetErrorMessage(
471  wxString::Format( _( "Pins of type %s and %s are connected" ),
472  ElectricalPinTypeGetText( refType ),
473  ElectricalPinTypeGetText( testType ) ) );
474 
475  SCH_MARKER* marker =
476  new SCH_MARKER( ercItem, refPin->GetTransformedPosition() );
477  pinToScreenMap[refPin]->Append( marker );
478  errors++;
479  }
480  }
481  }
482  }
483 
484  return errors;
485 }
486 
487 
489 {
490  const NET_MAP& nets = m_schematic->ConnectionGraph()->GetNetMap();
491 
492  int errors = 0;
493 
494  std::unordered_map<wxString, std::pair<wxString, SCH_PIN*>> pinToNetMap;
495 
496  for( const std::pair<NET_NAME_CODE, std::vector<CONNECTION_SUBGRAPH*>> net : nets )
497  {
498  const wxString& netName = net.first.first;
499  std::vector<SCH_PIN*> pins;
500 
501  for( CONNECTION_SUBGRAPH* subgraph : net.second )
502  {
503  for( EDA_ITEM* item : subgraph->m_items )
504  {
505  if( item->Type() == SCH_PIN_T )
506  {
507  SCH_PIN* pin = static_cast<SCH_PIN*>( item );
508 
509  if( !pin->GetLibPin()->GetParent()->IsMulti() )
510  continue;
511 
512  wxString name = ( pin->GetParentComponent()->GetRef( &subgraph->m_sheet ) +
513  ":" + pin->GetNumber() );
514 
515  if( !pinToNetMap.count( name ) )
516  {
517  pinToNetMap[name] = std::make_pair( netName, pin );
518  }
519  else if( pinToNetMap[name].first != netName )
520  {
521  std::shared_ptr<ERC_ITEM> ercItem =
523 
524  ercItem->SetErrorMessage( wxString::Format(
525  _( "Pin %s is connected to both %s and %s" ),
526  pin->GetNumber(), netName, pinToNetMap[name].first ) );
527 
528  ercItem->SetItems( pin, pinToNetMap[name].second );
529 
530  SCH_MARKER* marker = new SCH_MARKER( ercItem,
531  pin->GetTransformedPosition() );
532  subgraph->m_sheet.LastScreen()->Append( marker );
533  errors += 1;
534  }
535  }
536  }
537  }
538  }
539 
540  return errors;
541 }
542 
543 
545 {
546  const NET_MAP& nets = m_schematic->ConnectionGraph()->GetNetMap();
547 
548  int errors = 0;
549 
550  std::unordered_map<wxString, SCH_TEXT*> labelMap;
551 
552  for( const std::pair<NET_NAME_CODE, std::vector<CONNECTION_SUBGRAPH*>> net : nets )
553  {
554  std::vector<SCH_PIN*> pins;
555 
556  for( CONNECTION_SUBGRAPH* subgraph : net.second )
557  {
558  for( EDA_ITEM* item : subgraph->m_items )
559  {
560  switch( item->Type() )
561  {
562  case SCH_LABEL_T:
563  case SCH_HIER_LABEL_T:
564  case SCH_GLOBAL_LABEL_T:
565  {
566  SCH_TEXT* text = static_cast<SCH_TEXT*>( item );
567 
568  wxString normalized = text->GetShownText().Lower();
569 
570  if( !labelMap.count( normalized ) )
571  {
572  labelMap[normalized] = text;
573  }
574  else if( labelMap.at( normalized )->GetShownText() != text->GetShownText() )
575  {
576  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS );
577  ercItem->SetItems( text, labelMap.at( normalized ) );
578 
579  SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
580  subgraph->m_sheet.LastScreen()->Append( marker );
581  errors += 1;
582  }
583 
584  break;
585  }
586 
587  default:
588  break;
589  }
590  }
591  }
592  }
593 
594  return errors;
595 }
596 
597 
599 {
600  wxCHECK( m_schematic, 0 );
601 
602  wxString msg;
603  int err_count = 0;
604 
605  SCH_SCREENS screens( m_schematic->Root() );
606 
607  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
608  {
609  for( SCH_ITEM* item : screen->Items().OfType( SCH_COMPONENT_T ) )
610  {
611  SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
612 
613  wxCHECK2( symbol, continue );
614 
615  LIB_PART* libSymbolInSchematic = screen->GetLibSymbols()[
616  symbol->GetLibId().GetUniStringLibId() ];
617 
618  wxCHECK2( libSymbolInSchematic, continue );
619 
620  LIB_PART* libSymbol = SchGetLibPart( symbol->GetLibId(),
621  m_schematic->Prj().SchSymbolLibTable() );
622 
623  if( libSymbol == nullptr )
624  {
625  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
626  ercItem->SetItems( symbol );
627  msg.Printf( "Library symbol link \"%s\" cannot be found in symbol library table",
628  symbol->GetLibId().GetUniStringLibId() );
629  ercItem->SetErrorMessage( msg );
630 
631  SCH_MARKER* marker = new SCH_MARKER( ercItem, symbol->GetPosition() );
632  screen->Append( marker );
633  err_count += 1;
634  }
635  else if( *libSymbol != *libSymbolInSchematic )
636  {
637  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
638  ercItem->SetItems( symbol );
639  msg.Printf( "Library symbol \"%s\" has been modified",
640  symbol->GetLibId().GetUniStringLibId() );
641  ercItem->SetErrorMessage( msg );
642 
643  SCH_MARKER* marker = new SCH_MARKER( ercItem, symbol->GetPosition() );
644  screen->Append( marker );
645  err_count += 1;
646  }
647  }
648  }
649 
650  return err_count;
651 }
SCH_SHEET_PATH m_sheet
SCH_SHEET_LIST.
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:67
SCH_REFERENCE & GetItem(int aIdx)
Function GetItem.
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
Definition: ws_draw_item.h:407
Different units of the same component have different footprints assigned.
Definition: erc_settings.h:47
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:89
int TestMultUnitPinConflicts()
Checks if shared pins on multi-unit components have been connected to different nets.
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:129
const SCH_SHEET_PATH & GetSheetPath() const
const wxString CommentERC_V[]
LIB_PART * GetParent() const
Definition: lib_item.h:183
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Definition: erc_item.cpp:155
const wxString CommentERC_H[]
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE aType)
Definition: pin_type.cpp:239
WS_DRAW_ITEM_BASE * GetNext()
Definition: ws_draw_item.h:479
SCH_COMPONENT * GetComp() const
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
Definition: ws_draw_item.h:423
std::pair< wxString, int > NET_NAME_CODE
Associates a net code with the final name of a net.
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
Definition: ws_draw_item.h:415
void TestTextVars(KIGFX::WS_PROXY_VIEW_ITEM *aWorksheet)
Check for any unresolved text variable references.
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
Definition: erc_settings.h:73
wxString GetNumber() const
Definition: sch_pin.h:114
WS_DRAW_ITEM_BASE * GetFirst()
Definition: ws_draw_item.h:469
const wxString ExpandEnvVarSubstitutions(const wxString &aString, PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:610
A subgraph is a set of items that are electrically connected on a single sheet.
Library symbol changed from current symbol in schematic or the library symbol link no longer valid.
Definition: erc_settings.h:62
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
void GetMultiUnitComponents(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference ...
SCH_REFERENCE_LIST is used to create a flattened list of components because in a complex hierarchy,...
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:270
int TestConflictingBusAliases()
Check that there are no conflicting bus alias definitions in the schematic.
#define NULL
wxString GetName() const
Definition: sch_sheet.h:282
void BuildWorkSheetGraphicList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Function BuildWorkSheetGraphicList is a core function for drawing or plotting the page layout with th...
void SetSheetCount(int aSheetCount)
Function SetSheetCount Set the value of the count of sheets, for basic inscriptions.
Definition: ws_draw_item.h:453
int TestMultiunitFootprints()
Test if all units of each multiunit component have the same footprint assigned.
TRANSFORM & GetTransform() const
std::vector< SCH_ITEM * > m_items
Shared pin in a multi-unit component is connected to more than one net.
Definition: erc_settings.h:49
2 labels are equal for case insensitive comparisons.
Definition: erc_settings.h:46
const NET_MAP & GetNetMap() const
void SetMilsToIUfactor(double aScale)
Function SetMilsToIUfactor Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ws_draw_item.h:435
const TITLE_BLOCK & GetTitleBlock()
Define a library symbol object.
const wxString GetFootprint() const
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
Container for ERC settings.
Definition: erc_settings.h:94
SCH_SHEET_PATH.
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_text.cpp:485
wxPoint GetPosition() const override
Definition: sch_text.h:313
wxPoint GetPosition() const override
Definition: sch_sheet.h:569
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Type SCH_MULTI_UNIT_REFERENCE_MAP is used to create a map of reference designators for multi-unit par...
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieves a list of the SCH_PINs for the given sheet path.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:218
unsigned GetCount() const
Function GetCount.
A text variable could not be resolved.
Definition: erc_settings.h:60
A no connect symbol is connected to more than 1 pin.
Definition: erc_settings.h:43
int TestLibSymbolIssues()
Test symbols for changed library symbols and broken symbol library links.
SCH_SHEET & Root() const
Definition: schematic.h:94
SCH_SCREEN * LastScreen()
Function LastScreen.
const char * name
Definition: DXF_plotter.cpp:59
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:34
std::map< NET_NAME_CODE, std::vector< CONNECTION_SUBGRAPH * > > NET_MAP
Associates a NET_CODE_NAME with all the subgraphs in that net.
void SetSheetNumber(int aSheetNumber)
Function SetSheetNumber Set the value of the sheet number, for basic inscriptions.
Definition: ws_draw_item.h:444
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:129
#define _(s)
Definition: 3d_actions.cpp:33
int TestPinToPin()
Checks the full netlist against the pin-to-pin connectivity requirements.
EE_RTREE & Items()
Definition: sch_screen.h:158
Schematic symbol object.
Definition: sch_component.h:80
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:77
wxPoint GetPosition() const override
#define IU_PER_MILS
Definition: plotter.cpp:137
Conflicting bus alias definitions across sheets.
Definition: erc_settings.h:51
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
Definition: erc_settings.h:122
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: eda_item.h:147
bool IsMulti() const
LIB_PART * SchGetLibPart(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, PART_LIB *aCacheLib, wxWindow *aParent, bool aShowErrorMsg)
Load symbol from symbol library table.
wxString GetUniStringLibId() const
Definition: lib_id.h:148
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:131
SCHEMATIC * m_schematic
Definition: erc.h:137
int TestSimilarLabels()
Checks for labels that differ only in capitalization.
Duplicate sheet names within a given sheet.
Definition: erc_settings.h:39
void SetProject(const PROJECT *aProject)
Definition: ws_draw_item.h:392
not connected (must be left open)
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition: schematic.h:124
const LIB_ID & GetLibId() const
SCH_COMPONENT * GetParentComponent() const
Definition: sch_pin.cpp:127
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
int TestNoConnectPins()
In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type.
const PAGE_INFO & GetPageInfo()
SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:515
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
int TestDuplicateSheetNames(bool aCreateMarker)
Inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:119
wxPoint GetTransformedPosition() const
Returns the pin's position in global coordinates.
Definition: sch_pin.cpp:252