KiCad PCB EDA Suite
RC_ITEM Class Reference

A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema. More...

#include <rc_item.h>

Inheritance diagram for RC_ITEM:
CLEANUP_ITEM DRC_ITEM ERC_ITEM

Public Types

typedef std::vector< KIIDKIIDS
 

Public Member Functions

 RC_ITEM ()
 
 RC_ITEM (std::shared_ptr< RC_ITEM > aItem)
 
virtual ~RC_ITEM ()
 
void SetErrorMessage (const wxString &aMessage)
 
void SetItems (const KIIDS &aIds)
 
void AddItem (EDA_ITEM *aItem)
 
void SetItems (const EDA_ITEM *aItem, const EDA_ITEM *bItem=nullptr, const EDA_ITEM *cItem=nullptr, const EDA_ITEM *dItem=nullptr)
 
void SetItems (const KIID &aItem, const KIID &bItem=niluuid, const KIID &cItem=niluuid, const KIID &dItem=niluuid)
 
KIID GetMainItemID () const
 
KIID GetAuxItemID () const
 
KIID GetAuxItem2ID () const
 
KIID GetAuxItem3ID () const
 
void SetParent (MARKER_BASE *aMarker)
 
MARKER_BASEGetParent () const
 
virtual wxString ShowReport (EDA_UNITS aUnits, SEVERITY aSeverity, const std::map< KIID, EDA_ITEM * > &aItemMap) const
 Translate 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
 Return the error message of a RC_ITEM. More...
 
wxString GetErrorText () const
 
wxString GetSettingsKey () const
 

Static Public Member Functions

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

Protected Attributes

int m_errorCode
 The error code's numeric value. More...
 
wxString m_errorMessage
 A message describing the details of this specific error. More...
 
wxString m_errorTitle
 The string describing the type of error. More...
 
wxString m_settingsKey
 The key used to describe this type of error in settings. More...
 
MARKER_BASEm_parent
 The marker this item belongs to, if any. More...
 
KIIDS m_ids
 

Detailed Description

A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.

RC_ITEMs can have zero, one, or two related EDA_ITEMs.

Definition at line 72 of file rc_item.h.

Member Typedef Documentation

◆ KIIDS

typedef std::vector<KIID> RC_ITEM::KIIDS

Definition at line 75 of file rc_item.h.

Constructor & Destructor Documentation

◆ RC_ITEM() [1/2]

RC_ITEM::RC_ITEM ( )
inline

Definition at line 87 of file rc_item.h.

87  :
88  m_errorCode( 0 ),
89  m_parent( nullptr )
90  {
91  }
int m_errorCode
The error code's numeric value.
Definition: rc_item.h:78
MARKER_BASE * m_parent
The marker this item belongs to, if any.
Definition: rc_item.h:82

◆ RC_ITEM() [2/2]

RC_ITEM::RC_ITEM ( std::shared_ptr< RC_ITEM aItem)
inline

Definition at line 93 of file rc_item.h.

94  {
95  m_errorCode = aItem->m_errorCode;
96  m_errorMessage = aItem->m_errorMessage;
97  m_errorTitle = aItem->m_errorTitle;
98  m_settingsKey = aItem->m_settingsKey;
99  m_parent = aItem->m_parent;
100  m_ids = aItem->m_ids;
101  }
KIIDS m_ids
Definition: rc_item.h:84
wxString m_settingsKey
The key used to describe this type of error in settings.
Definition: rc_item.h:81
int m_errorCode
The error code's numeric value.
Definition: rc_item.h:78
wxString m_errorMessage
A message describing the details of this specific error.
Definition: rc_item.h:79
MARKER_BASE * m_parent
The marker this item belongs to, if any.
Definition: rc_item.h:82
wxString m_errorTitle
The string describing the type of error.
Definition: rc_item.h:80

References m_errorCode, m_errorMessage, m_errorTitle, m_ids, m_parent, and m_settingsKey.

◆ ~RC_ITEM()

virtual RC_ITEM::~RC_ITEM ( )
inlinevirtual

Definition at line 103 of file rc_item.h.

103 { }

Member Function Documentation

◆ AddItem()

void RC_ITEM::AddItem ( EDA_ITEM aItem)
inline

Definition at line 112 of file rc_item.h.

113  {
114  m_ids.push_back( aItem->m_Uuid );
115  }
KIIDS m_ids
Definition: rc_item.h:84
const KIID m_Uuid
Definition: eda_item.h:151

References m_ids, and EDA_ITEM::m_Uuid.

◆ GetAuxItem2ID()

KIID RC_ITEM::GetAuxItem2ID ( ) const
inline

Definition at line 147 of file rc_item.h.

147 { return m_ids.size() > 2 ? m_ids[2] : niluuid;; }
KIIDS m_ids
Definition: rc_item.h:84
KIID niluuid(0)

References m_ids, and niluuid.

◆ GetAuxItem3ID()

KIID RC_ITEM::GetAuxItem3ID ( ) const
inline

Definition at line 148 of file rc_item.h.

148 { return m_ids.size() > 3 ? m_ids[3] : niluuid;; }
KIIDS m_ids
Definition: rc_item.h:84
KIID niluuid(0)

References m_ids, and niluuid.

◆ GetAuxItemID()

KIID RC_ITEM::GetAuxItemID ( ) const
inline

Definition at line 146 of file rc_item.h.

146 { return m_ids.size() > 1 ? m_ids[1] : niluuid;; }
KIIDS m_ids
Definition: rc_item.h:84
KIID niluuid(0)

References m_ids, and niluuid.

Referenced by ShowReport().

◆ GetErrorCode()

int RC_ITEM::GetErrorCode ( ) const
inline

◆ GetErrorMessage()

wxString RC_ITEM::GetErrorMessage ( ) const
virtual

Return the error message of a RC_ITEM.

Definition at line 37 of file rc_item.cpp.

38 {
39  if( m_errorMessage.IsEmpty() )
40  return GetErrorText();
41  else
42  return m_errorMessage;
43 }
wxString GetErrorText() const
Definition: rc_item.h:170
wxString m_errorMessage
A message describing the details of this specific error.
Definition: rc_item.h:79

References GetErrorText(), and m_errorMessage.

Referenced by ShowReport().

◆ GetErrorText()

wxString RC_ITEM::GetErrorText ( ) const
inline

Definition at line 170 of file rc_item.h.

171  {
172  return wxGetTranslation( m_errorTitle );
173  }
wxString m_errorTitle
The string describing the type of error.
Definition: rc_item.h:80

References m_errorTitle.

Referenced by CLEANUP_ITEM::CLEANUP_ITEM(), GetErrorMessage(), and PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES().

◆ GetMainItemID()

KIID RC_ITEM::GetMainItemID ( ) const
inline

Definition at line 145 of file rc_item.h.

145 { return m_ids.size() > 0 ? m_ids[0] : niluuid; }
KIIDS m_ids
Definition: rc_item.h:84
KIID niluuid(0)

References m_ids, and niluuid.

Referenced by ShowReport().

◆ GetParent()

MARKER_BASE* RC_ITEM::GetParent ( void  ) const
inline

Definition at line 151 of file rc_item.h.

151 { return m_parent; }
MARKER_BASE * m_parent
The marker this item belongs to, if any.
Definition: rc_item.h:82

References m_parent.

◆ GetSettingsKey()

wxString RC_ITEM::GetSettingsKey ( ) const
inline

Definition at line 175 of file rc_item.h.

176  {
177  return m_settingsKey;
178  }
wxString m_settingsKey
The key used to describe this type of error in settings.
Definition: rc_item.h:81

References m_settingsKey.

Referenced by ShowReport().

◆ SetErrorCode()

void RC_ITEM::SetErrorCode ( int  aCode)
inline

Definition at line 163 of file rc_item.h.

163 { m_errorCode = aCode; }
int m_errorCode
The error code's numeric value.
Definition: rc_item.h:78

References m_errorCode.

◆ SetErrorMessage()

void RC_ITEM::SetErrorMessage ( const wxString &  aMessage)
inline

Definition at line 105 of file rc_item.h.

105 { m_errorMessage = aMessage; }
wxString m_errorMessage
A message describing the details of this specific error.
Definition: rc_item.h:79

References m_errorMessage.

◆ SetItems() [1/3]

void RC_ITEM::SetItems ( const KIIDS aIds)
inline

Definition at line 107 of file rc_item.h.

108  {
109  m_ids = aIds;
110  }
KIIDS m_ids
Definition: rc_item.h:84

References m_ids.

◆ SetItems() [2/3]

void RC_ITEM::SetItems ( const EDA_ITEM aItem,
const EDA_ITEM bItem = nullptr,
const EDA_ITEM cItem = nullptr,
const EDA_ITEM dItem = nullptr 
)
inline

Definition at line 117 of file rc_item.h.

119  {
120  m_ids.clear();
121 
122  m_ids.push_back( aItem->m_Uuid );
123 
124  if( bItem )
125  m_ids.push_back( bItem->m_Uuid );
126 
127  if( cItem )
128  m_ids.push_back( cItem->m_Uuid );
129 
130  if( dItem )
131  m_ids.push_back( dItem->m_Uuid );
132  }
KIIDS m_ids
Definition: rc_item.h:84
const KIID m_Uuid
Definition: eda_item.h:151

References m_ids, and EDA_ITEM::m_Uuid.

◆ SetItems() [3/3]

void RC_ITEM::SetItems ( const KIID aItem,
const KIID bItem = niluuid,
const KIID cItem = niluuid,
const KIID dItem = niluuid 
)
inline

Definition at line 134 of file rc_item.h.

136  {
137  m_ids.clear();
138 
139  m_ids.push_back( aItem );
140  m_ids.push_back( bItem );
141  m_ids.push_back( cItem );
142  m_ids.push_back( dItem );
143  }
KIIDS m_ids
Definition: rc_item.h:84

References m_ids.

◆ SetParent()

void RC_ITEM::SetParent ( MARKER_BASE aMarker)
inline

Definition at line 150 of file rc_item.h.

150 { m_parent = aMarker; }
MARKER_BASE * m_parent
The marker this item belongs to, if any.
Definition: rc_item.h:82

References m_parent.

◆ ShowCoord()

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

Format a coordinate or position to text.

Definition at line 46 of file rc_item.cpp.

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

References Format(), and MessageTextFromValue().

Referenced by ShowReport().

◆ ShowReport()

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

Translate 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 54 of file rc_item.cpp.

56 {
57  wxString severity;
58 
59  switch( aSeverity )
60  {
61  case RPT_SEVERITY_ERROR: severity = wxT( "Severity: error" ); break;
62  case RPT_SEVERITY_WARNING: severity = wxT( "Severity: warning" ); break;
63  case RPT_SEVERITY_ACTION: severity = wxT( "Severity: action" ); break;
64  case RPT_SEVERITY_INFO: severity = wxT( "Severity: info" ); break;
65  default: ;
66  };
67 
68  if( m_parent && m_parent->IsExcluded() )
69  severity += wxT( " (excluded)" );
70 
71  EDA_ITEM* mainItem = nullptr;
72  EDA_ITEM* auxItem = nullptr;
73 
74  auto ii = aItemMap.find( GetMainItemID() );
75 
76  if( ii != aItemMap.end() )
77  mainItem = ii->second;
78 
79  ii = aItemMap.find( GetAuxItemID() );
80 
81  if( ii != aItemMap.end() )
82  auxItem = ii->second;
83 
84  // Note: some customers machine-process these. So:
85  // 1) don't translate
86  // 2) try not to re-order or change syntax
87  // 3) report numeric error code (which should be more stable) in addition to message
88 
89  if( mainItem && auxItem )
90  {
91  return wxString::Format( wxT( "[%s]: %s %s\n %s: %s\n %s: %s\n" ),
94  severity,
95  ShowCoord( aUnits, mainItem->GetPosition() ),
96  mainItem->GetSelectMenuText( aUnits ),
97  ShowCoord( aUnits, auxItem->GetPosition() ),
98  auxItem->GetSelectMenuText( aUnits ) );
99  }
100  else if( mainItem )
101  {
102  return wxString::Format( wxT( "[%s]: %s %s\n %s: %s\n" ),
103  GetSettingsKey(),
104  GetErrorMessage(),
105  severity,
106  ShowCoord( aUnits, mainItem->GetPosition() ),
107  mainItem->GetSelectMenuText( aUnits ) );
108  }
109  else
110  {
111  return wxString::Format( wxT( "[%s]: %s %s\n" ),
112  GetSettingsKey(),
113  GetErrorMessage(),
114  severity );
115  }
116 }
virtual wxPoint GetPosition() const
Definition: eda_item.h:326
static wxString ShowCoord(EDA_UNITS aUnits, const wxPoint &aPos)
Format a coordinate or position to text.
Definition: rc_item.cpp:46
KIID GetAuxItemID() const
Definition: rc_item.h:146
bool IsExcluded() const
Definition: marker_base.h:109
MARKER_BASE * m_parent
The marker this item belongs to, if any.
Definition: rc_item.h:82
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
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: eda_item.cpp:123
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: eda_item.h:148
wxString GetSettingsKey() const
Definition: rc_item.h:175
KIID GetMainItemID() const
Definition: rc_item.h:145
virtual wxString GetErrorMessage() const
Return the error message of a RC_ITEM.
Definition: rc_item.cpp:37

References Format(), GetAuxItemID(), GetErrorMessage(), GetMainItemID(), EDA_ITEM::GetPosition(), EDA_ITEM::GetSelectMenuText(), GetSettingsKey(), MARKER_BASE::IsExcluded(), m_parent, RPT_SEVERITY_ACTION, RPT_SEVERITY_ERROR, RPT_SEVERITY_INFO, RPT_SEVERITY_WARNING, and ShowCoord().

Member Data Documentation

◆ m_errorCode

int RC_ITEM::m_errorCode
protected

◆ m_errorMessage

wxString RC_ITEM::m_errorMessage
protected

A message describing the details of this specific error.

Definition at line 79 of file rc_item.h.

Referenced by GetErrorMessage(), RC_ITEM(), and SetErrorMessage().

◆ m_errorTitle

wxString RC_ITEM::m_errorTitle
protected

The string describing the type of error.

Definition at line 80 of file rc_item.h.

Referenced by CLEANUP_ITEM::CLEANUP_ITEM(), DRC_ITEM::DRC_ITEM(), ERC_ITEM::ERC_ITEM(), GetErrorText(), and RC_ITEM().

◆ m_ids

KIIDS RC_ITEM::m_ids
protected

◆ m_parent

MARKER_BASE* RC_ITEM::m_parent
protected

The marker this item belongs to, if any.

Definition at line 82 of file rc_item.h.

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

◆ m_settingsKey

wxString RC_ITEM::m_settingsKey
protected

The key used to describe this type of error in settings.

Definition at line 81 of file rc_item.h.

Referenced by DRC_ITEM::DRC_ITEM(), ERC_ITEM::ERC_ITEM(), GetSettingsKey(), and RC_ITEM().


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