KiCad PCB EDA Suite
netlist_generator.cpp File Reference
#include <fctsys.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <pgm_base.h>
#include <sch_edit_frame.h>
#include <reporter.h>
#include <confirm.h>
#include <kiway.h>
#include <netlist.h>
#include <netlist_exporter.h>
#include <netlist_exporter_orcadpcb2.h>
#include <netlist_exporter_cadstar.h>
#include <netlist_exporter_pspice.h>
#include <netlist_exporter_kicad.h>
#include <netlist_exporter_generic.h>
#include <invoke_sch_dialog.h>

Go to the source code of this file.

Functions

int TestDuplicateSheetNames (bool aCreateMarker)
 Function TestDuplicateSheetNames( ) inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated). More...
 

Function Documentation

◆ TestDuplicateSheetNames()

int TestDuplicateSheetNames ( bool  aCreateMarker)

Function TestDuplicateSheetNames( ) inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).

Returns
the error count
Parameters
aCreateMarkertrue = create error markers in schematic, false = calculate error count only

Definition at line 174 of file erc.cpp.

175 {
176  SCH_SCREEN* screen;
177  SCH_ITEM* item;
178  SCH_ITEM* test_item;
179  int err_count = 0;
180  SCH_SCREENS screenList; // Created the list of screen
181 
182  for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() )
183  {
184  for( item = screen->GetDrawItems(); item != NULL; item = item->Next() )
185  {
186  // search for a sheet;
187  if( item->Type() != SCH_SHEET_T )
188  continue;
189 
190  for( test_item = item->Next(); test_item != NULL; test_item = test_item->Next() )
191  {
192  if( test_item->Type() != SCH_SHEET_T )
193  continue;
194 
195  // We have found a second sheet: compare names
196  // we are using case insensitive comparison to avoid mistakes between
197  // similar names like Mysheet and mysheet
198  if( ( (SCH_SHEET*) item )->GetName().CmpNoCase(
199  ( ( SCH_SHEET* ) test_item )->GetName() ) == 0 )
200  {
201  if( aCreateMarker )
202  {
203  /* Create a new marker type ERC error*/
204  SCH_MARKER* marker = new SCH_MARKER();
205  marker->SetTimeStamp( GetNewTimeStamp() );
207  ( (SCH_SHEET*) test_item )->GetPosition(),
208  _( "Duplicate sheet name" ),
209  ( (SCH_SHEET*) test_item )->GetPosition() );
212  screen->Append( marker );
213  }
214 
215  err_count++;
216  }
217  }
218  }
219  }
220 
221  return err_count;
222 }
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
Definition: sch_item.h:153
void SetData(EDA_UNITS_T aUnits, int aErrorCode, const wxPoint &aMarkerPos, EDA_ITEM *aItem, const wxPoint &aPos, EDA_ITEM *bItem=nullptr, const wxPoint &bPos=wxPoint())
Function SetData fills in all the reportable data associated with a MARKER.
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
void SetMarkerType(enum TYPEMARKER aMarkerType)
accessors to set/get marker type (DRC, ERC, or other)
Definition: marker_base.h:182
#define _(s)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void Append(SCH_ITEM *aItem)
Definition: sch_screen.h:154
void SetErrorLevel(MARKER_SEVERITY aErrorLevel)
accessors to set/get error levels (warning, error, fatal error..)
Definition: marker_base.h:170
SCH_SCREEN * GetFirst()
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:215
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:152

References _, SCH_SCREEN::Append(), ERCE_DUPLICATE_SHEET_NAME, SCH_SCREEN::GetDrawItems(), SCH_SCREENS::GetFirst(), GetNewTimeStamp(), SCH_SCREENS::GetNext(), MARKER_BASE::MARKER_ERC, MARKER_BASE::MARKER_SEVERITY_ERROR, SCH_ITEM::Next(), SCH_SHEET_T, MARKER_BASE::SetData(), MARKER_BASE::SetErrorLevel(), MARKER_BASE::SetMarkerType(), EDA_ITEM::SetTimeStamp(), and EDA_ITEM::Type().

Referenced by highlightNet(), SCH_EDIT_FRAME::prepareForNetlist(), and DIALOG_ERC::TestErc().