KiCad PCB EDA Suite
ERC_ITEM Class Reference

#include <erc_item.h>

Inheritance diagram for ERC_ITEM:
RC_ITEM

Public Member Functions

 ERC_ITEM (int aErrorCode)
 
wxString GetErrorText (int aErrorCode=-1, bool aTranslate=true) const override
 Function GetErrorText returns the string form of an erc error code. More...
 
void SetErrorMessage (const wxString &aMessage)
 
void SetItems (EDA_ITEM *aItem, EDA_ITEM *bItem=nullptr)
 
void SetItems (const KIID &aItem, const KIID &bItem=niluuid)
 
KIID GetMainItemID () const
 
KIID GetAuxItemID () const
 
void SetParent (MARKER_BASE *aMarker)
 
MARKER_BASEGetParent () const
 
virtual wxString ShowReport (EDA_UNITS aUnits, const std::map< KIID, EDA_ITEM * > &aItemMap) const
 Function ShowReport translates this object into a text string suitable for saving to disk in a report. More...
 
int GetErrorCode () const
 
void SetErrorCode (int aCode)
 
virtual wxString GetErrorMessage () const
 Function GetErrorMessage returns the error message of a RC_ITEM. More...
 

Static Public Member Functions

static wxString ShowCoord (EDA_UNITS aUnits, const wxPoint &aPos)
 Function ShowCoord formats a coordinate or position to text. More...
 

Protected Attributes

int m_errorCode
 
wxString m_errorMessage
 
MARKER_BASEm_parent
 
KIID m_mainItemUuid
 
KIID m_auxItemUuid
 

Detailed Description

Definition at line 30 of file erc_item.h.

Constructor & Destructor Documentation

◆ ERC_ITEM()

ERC_ITEM::ERC_ITEM ( int  aErrorCode)
inline

Definition at line 33 of file erc_item.h.

34  {
35  m_errorCode = aErrorCode;
36  }
int m_errorCode
Definition: rc_item.h:80

References RC_ITEM::m_errorCode.

Member Function Documentation

◆ GetAuxItemID()

◆ GetErrorCode()

◆ GetErrorMessage()

wxString RC_ITEM::GetErrorMessage ( ) const
virtualinherited

Function GetErrorMessage returns the error message of a RC_ITEM.

Definition at line 36 of file rc_item.cpp.

37 {
38  if( m_errorMessage.IsEmpty() )
39  return GetErrorText( m_errorCode );
40  else
41  return m_errorMessage;
42 }
int m_errorCode
Definition: rc_item.h:80
wxString m_errorMessage
Definition: rc_item.h:81
virtual wxString GetErrorText(int aCode=-1, bool aTranslate=true) const =0
Function GetErrorText returns the string form of a RC error code.

References RC_ITEM::GetErrorText(), RC_ITEM::m_errorCode, and RC_ITEM::m_errorMessage.

Referenced by MARKER_PCB::GetMsgPanelInfo(), SCH_MARKER::GetMsgPanelInfo(), RC_TREE_MODEL::GetValue(), MARKER_PCB::Matches(), SCH_MARKER::Matches(), and RC_ITEM::ShowReport().

◆ GetErrorText()

wxString ERC_ITEM::GetErrorText ( int  aErrorCode = -1,
bool  aTranslate = true 
) const
overridevirtual

Function GetErrorText returns the string form of an erc error code.

Implements RC_ITEM.

Definition at line 32 of file erc_item.cpp.

33 {
34  wxString msg;
35 
36  if( aErrorCode < 0 )
37  aErrorCode = m_errorCode;
38 
39  switch( aErrorCode )
40  {
41  case ERCE_UNSPECIFIED:
42  msg = _HKI("ERC err unspecified" );
43  break;
45  msg = _HKI("Duplicate sheet names within a given sheet" );
46  break;
48  msg = _HKI("Pin not connected" );
49  break;
51  msg = _HKI( "Pin connected to other pins, but not driven by any pin" );
52  break;
55  msg = _HKI("Conflict problem between pins" );
56  break;
58  msg = _HKI("Mismatch between hierarchical labels and pins sheets" );
59  break;
61  msg = _HKI("A pin with a \"no connection\" flag is connected" );
62  break;
64  msg = _HKI("Unconnected \"no connection\" flag" );
65  break;
67  msg = _HKI("Label not connected anywhere else in the schematic" );
68  break;
70  msg = _HKI("Labels are similar (lower/upper case difference only)" );
71  break;
73  msg = _HKI("Different footprint assigned in another unit of the same component" );
74  break;
76  msg = _HKI("Different net assigned to a shared pin in another unit of the same component" );
77  break;
79  msg = _HKI("Conflict between bus alias definitions across schematic sheets" );
80  break;
82  msg = _HKI( "More than one name given to this bus or net" );
83  break;
85  msg = _HKI( "Net is graphically connected to a bus but not a bus member" );
86  break;
88  msg = _HKI( "Label attached to bus item does not describe a bus" );
89  break;
91  msg = _HKI( "Buses are graphically connected but share no bus members" );
92  break;
94  msg = _HKI( "Invalid connection between bus and net items" );
95  break;
96  case ERCE_GLOBLABEL:
97  msg = _HKI( "Global label not connected anywhere else in the schematic" );
98  break;
100  msg = _HKI( "Unresolved text variable" );
101  break;
102  default:
103  wxFAIL_MSG( "Missing ERC error description" );
104  msg = _HKI( "Unknown ERC violation" );
105  break;
106  }
107 
108  if( aTranslate )
109  return wxGetTranslation( msg );
110  else
111  return msg;
112 }
int m_errorCode
Definition: rc_item.h:80
#define _HKI(x)

References _HKI, ERCE_BUS_ALIAS_CONFLICT, ERCE_BUS_ENTRY_CONFLICT, ERCE_BUS_LABEL_ERROR, ERCE_BUS_TO_BUS_CONFLICT, ERCE_BUS_TO_NET_CONFLICT, ERCE_DIFFERENT_UNIT_FP, ERCE_DIFFERENT_UNIT_NET, ERCE_DRIVER_CONFLICT, ERCE_DUPLICATE_SHEET_NAME, ERCE_GLOBLABEL, ERCE_HIERACHICAL_LABEL, ERCE_LABEL_NOT_CONNECTED, ERCE_NOCONNECT_CONNECTED, ERCE_NOCONNECT_NOT_CONNECTED, ERCE_PIN_NOT_CONNECTED, ERCE_PIN_NOT_DRIVEN, ERCE_PIN_TO_PIN_ERROR, ERCE_PIN_TO_PIN_WARNING, ERCE_SIMILAR_LABELS, ERCE_UNRESOLVED_VARIABLE, ERCE_UNSPECIFIED, and RC_ITEM::m_errorCode.

◆ GetMainItemID()

◆ GetParent()

MARKER_BASE* RC_ITEM::GetParent ( void  ) const
inlineinherited

◆ SetErrorCode()

void RC_ITEM::SetErrorCode ( int  aCode)
inlineinherited

Definition at line 139 of file rc_item.h.

139 { m_errorCode = aCode; }
int m_errorCode
Definition: rc_item.h:80

References RC_ITEM::m_errorCode.

◆ SetErrorMessage()

◆ SetItems() [1/2]

void RC_ITEM::SetItems ( EDA_ITEM aItem,
EDA_ITEM bItem = nullptr 
)
inlineinherited

Definition at line 109 of file rc_item.h.

110  {
111  m_mainItemUuid = aItem->m_Uuid;
112 
113  if( bItem )
114  m_auxItemUuid = bItem->m_Uuid;
115  }
KIID m_auxItemUuid
Definition: rc_item.h:84
const KIID m_Uuid
Definition: base_struct.h:166
KIID m_mainItemUuid
Definition: rc_item.h:83

References RC_ITEM::m_auxItemUuid, RC_ITEM::m_mainItemUuid, and EDA_ITEM::m_Uuid.

Referenced by DRC_KEEPOUT_TESTER::checkDrawings(), DRC_KEEPOUT_TESTER::checkFootprints(), DRC_DRILLED_HOLE_TESTER::checkHoles(), DRC_DRILLED_HOLE_TESTER::checkMicroVia(), DRC_DRILLED_HOLE_TESTER::checkPad(), DRC_KEEPOUT_TESTER::checkPads(), DRC_KEEPOUT_TESTER::checkTracksAndVias(), DRC_DRILLED_HOLE_TESTER::checkVia(), TRACKS_CLEANER::cleanupSegments(), TRACKS_CLEANER::cleanupVias(), TRACKS_CLEANER::deleteDanglingTracks(), TRACKS_CLEANER::deleteNullSegments(), TRACKS_CLEANER::deleteTracksInPads(), MARKER_PCB::Deserialize(), Diagnose(), DRC::doPadToPadsDrc(), DRC::doTrackDrc(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::ercCheckNoConnects(), TRACKS_CLEANER::mergeCollinearSegments(), TRACKS_CLEANER::removeBadTrackSegments(), CONNECTION_SUBGRAPH::ResolveDrivers(), DRC_COURTYARD_TESTER::RunDRC(), DRC_TEXTVAR_TESTER::RunDRC(), SimilarLabelsDiagnose(), DRC::testCopperDrawItem(), DRC::testDisabledLayers(), TestDuplicateSheetNames(), DIALOG_ERC::TestErc(), TestFootprints(), TestMultiunitFootprints(), DRC::testOutline(), DRC::testPadClearances(), TestTextVars(), DRC::testTracks(), DRC::testUnconnected(), and DRC::testZones().

◆ SetItems() [2/2]

void RC_ITEM::SetItems ( const KIID aItem,
const KIID bItem = niluuid 
)
inlineinherited

Definition at line 117 of file rc_item.h.

118  {
119  m_mainItemUuid = aItem;
120  m_auxItemUuid = bItem;
121  }
KIID m_auxItemUuid
Definition: rc_item.h:84
KIID m_mainItemUuid
Definition: rc_item.h:83

References RC_ITEM::m_auxItemUuid, and RC_ITEM::m_mainItemUuid.

◆ SetParent()

void RC_ITEM::SetParent ( MARKER_BASE aMarker)
inlineinherited

Definition at line 126 of file rc_item.h.

126 { m_parent = aMarker; }
MARKER_BASE * m_parent
Definition: rc_item.h:82

References RC_ITEM::m_parent.

Referenced by MARKER_PCB::MARKER_PCB(), and SCH_MARKER::SCH_MARKER().

◆ ShowCoord()

wxString RC_ITEM::ShowCoord ( EDA_UNITS  aUnits,
const wxPoint aPos 
)
staticinherited

Function ShowCoord formats a coordinate or position to text.

Definition at line 45 of file rc_item.cpp.

46 {
47  return wxString::Format( "@(%s, %s)",
48  MessageTextFromValue( aUnits, aPos.x ),
49  MessageTextFromValue( aUnits, aPos.y ) );
50 }
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aUseMils, EDA_DATA_TYPE aType)
Definition: base_units.cpp:124
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:205

References Format(), MessageTextFromValue(), wxPoint::x, and wxPoint::y.

Referenced by RC_ITEM::ShowReport().

◆ ShowReport()

wxString RC_ITEM::ShowReport ( EDA_UNITS  aUnits,
const std::map< KIID, EDA_ITEM * > &  aItemMap 
) const
virtualinherited

Function ShowReport translates this object into a text string suitable for saving to disk in a report.

Returns
wxString - the simple multi-line report text.

Definition at line 53 of file rc_item.cpp.

54 {
55  EDA_ITEM* mainItem = nullptr;
56  EDA_ITEM* auxItem = nullptr;
57 
58  if( m_mainItemUuid != niluuid )
59  mainItem = aItemMap.at( m_mainItemUuid );
60 
61  if( m_auxItemUuid != niluuid )
62  auxItem = aItemMap.at( m_auxItemUuid );
63 
64  if( mainItem && auxItem )
65  {
66  return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ),
67  GetErrorCode(),
69  ShowCoord( aUnits, mainItem->GetPosition() ),
70  mainItem->GetSelectMenuText( aUnits ),
71  ShowCoord( aUnits, auxItem->GetPosition() ),
72  auxItem->GetSelectMenuText( aUnits ) );
73  }
74  else if( mainItem )
75  {
76  return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ),
77  GetErrorCode(),
79  ShowCoord( aUnits, mainItem->GetPosition() ),
80  mainItem->GetSelectMenuText( aUnits ) );
81  }
82  else
83  {
84  return wxString::Format( wxT( "ErrType(%d): %s\n" ),
85  GetErrorCode(),
86  GetErrorMessage() );
87  }
88 }
KIID m_auxItemUuid
Definition: rc_item.h:84
virtual const wxPoint GetPosition() const
Definition: base_struct.h:344
static wxString ShowCoord(EDA_UNITS aUnits, const wxPoint &aPos)
Function ShowCoord formats a coordinate or position to text.
Definition: rc_item.cpp:45
KIID niluuid(0)
int GetErrorCode() const
Definition: rc_item.h:138
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:205
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
KIID m_mainItemUuid
Definition: rc_item.h:83
virtual wxString GetErrorMessage() const
Function GetErrorMessage returns the error message of a RC_ITEM.
Definition: rc_item.cpp:36

References Format(), RC_ITEM::GetErrorCode(), RC_ITEM::GetErrorMessage(), EDA_ITEM::GetPosition(), EDA_ITEM::GetSelectMenuText(), RC_ITEM::m_auxItemUuid, RC_ITEM::m_mainItemUuid, niluuid, and RC_ITEM::ShowCoord().

Referenced by DIALOG_DRC::writeReport(), and DIALOG_ERC::writeReport().

Member Data Documentation

◆ m_auxItemUuid

KIID RC_ITEM::m_auxItemUuid
protectedinherited

◆ m_errorCode

◆ m_errorMessage

wxString RC_ITEM::m_errorMessage
protectedinherited

◆ m_mainItemUuid

KIID RC_ITEM::m_mainItemUuid
protectedinherited

◆ m_parent

MARKER_BASE* RC_ITEM::m_parent
protectedinherited

Definition at line 82 of file rc_item.h.

Referenced by RC_ITEM::GetParent(), RC_ITEM::RC_ITEM(), and RC_ITEM::SetParent().


The documentation for this class was generated from the following files: