KiCad PCB EDA Suite
CLEANUP_ITEM Class Reference

#include <cleanup_item.h>

Inheritance diagram for CLEANUP_ITEM:
RC_ITEM

Public Types

typedef std::vector< KIIDKIIDS
 

Public Member Functions

 CLEANUP_ITEM (int aErrorCode)
 
wxString GetErrorText (int aErrorCode=-1, bool aTranslate=true) const
 Function GetErrorText returns the string form of a drc error code. More...
 
void SetErrorMessage (const wxString &aMessage)
 
void SetItems (const KIIDS &aIds)
 
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)
 
void AddItem (EDA_ITEM *aItem)
 
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_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
 

Private Attributes

wxString m_errorMessage
 

Detailed Description

Definition at line 49 of file cleanup_item.h.

Member Typedef Documentation

◆ KIIDS

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

Definition at line 75 of file rc_item.h.

Constructor & Destructor Documentation

◆ CLEANUP_ITEM()

CLEANUP_ITEM::CLEANUP_ITEM ( int  aErrorCode)

Definition at line 29 of file cleanup_item.cpp.

30 {
31  m_errorCode = aErrorCode;
32  m_errorTitle = GetErrorText( aErrorCode );
33 }
wxString GetErrorText() const
Definition: rc_item.h:160
int m_errorCode
The error code's numeric value.
Definition: rc_item.h:176
wxString m_errorTitle
The string describing the type of error.
Definition: rc_item.h:178

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

Member Function Documentation

◆ AddItem()

void RC_ITEM::AddItem ( EDA_ITEM aItem)
inlineinherited

Definition at line 102 of file rc_item.h.

103  {
104  m_ids.push_back( aItem->m_Uuid );
105  }
KIIDS m_ids
Definition: rc_item.h:182
const KIID m_Uuid
Definition: eda_item.h:524

References RC_ITEM::m_ids, and EDA_ITEM::m_Uuid.

◆ GetAuxItem2ID()

KIID RC_ITEM::GetAuxItem2ID ( ) const
inlineinherited

Definition at line 137 of file rc_item.h.

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

References RC_ITEM::m_ids, and niluuid.

◆ GetAuxItem3ID()

KIID RC_ITEM::GetAuxItem3ID ( ) const
inlineinherited

Definition at line 138 of file rc_item.h.

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

References RC_ITEM::m_ids, and niluuid.

◆ GetAuxItemID()

KIID RC_ITEM::GetAuxItemID ( ) const
inlineinherited

Definition at line 136 of file rc_item.h.

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

References RC_ITEM::m_ids, and niluuid.

Referenced by RC_ITEM::ShowReport().

◆ GetErrorCode()

int RC_ITEM::GetErrorCode ( ) const
inlineinherited

◆ GetErrorMessage()

wxString RC_ITEM::GetErrorMessage ( ) const
virtualinherited

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:160
wxString m_errorMessage
A message describing the details of this specific error.
Definition: rc_item.h:177

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

Referenced by RC_ITEM::ShowReport().

◆ GetErrorText() [1/2]

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

Function GetErrorText returns the string form of a drc error code.

Definition at line 36 of file cleanup_item.cpp.

37 {
38  wxString msg;
39 
40  if( aCode < 0 )
41  aCode = m_errorCode;
42 
43  switch( aCode )
44  {
45  // For cleanup tracks and vias:
46  case CLEANUP_CHECKING_ZONE_FILLS: msg = _HKI( "Checking zone fills..." ); break;
47  case CLEANUP_SHORTING_TRACK: msg = _HKI( "Remove track shorting two nets" ); break;
48  case CLEANUP_SHORTING_VIA: msg = _HKI( "Remove via shorting two nets" ); break;
49  case CLEANUP_REDUNDANT_VIA: msg = _HKI( "Remove redundant via" ); break;
50  case CLEANUP_DUPLICATE_TRACK: msg = _HKI( "Remove duplicate track" ); break;
51  case CLEANUP_MERGE_TRACKS: msg = _HKI( "Merge co-linear tracks" ); break;
52  case CLEANUP_DANGLING_TRACK: msg = _HKI( "Remove track not connected at both ends" ); break;
53  case CLEANUP_DANGLING_VIA: msg = _HKI( "Remove via connected on fewer than two layers" ); break;
54  case CLEANUP_ZERO_LENGTH_TRACK: msg = _HKI( "Remove zero-length track" ); break;
55  case CLEANUP_TRACK_IN_PAD: msg = _HKI( "Remove track inside pad" ); break;
56 
57  // For cleanup graphics:
58  case CLEANUP_NULL_GRAPHIC: msg = _HKI( "Remove zero-size graphic" ); break;
59  case CLEANUP_DUPLICATE_GRAPHIC: msg = _HKI( "Remove duplicated graphic" ); break;
60  case CLEANUP_LINES_TO_RECT: msg = _HKI( "Convert lines to rectangle" ); break;
61 
62  default:
63  wxFAIL_MSG( "Missing cleanup item description" );
64  msg = _HKI( "Unknown cleanup action" );
65  break;
66  }
67 
68  if( aTranslate )
69  return wxGetTranslation( msg );
70  else
71  return msg;
72 }
int m_errorCode
The error code's numeric value.
Definition: rc_item.h:176
#define _HKI(x)

References _HKI, CLEANUP_CHECKING_ZONE_FILLS, CLEANUP_DANGLING_TRACK, CLEANUP_DANGLING_VIA, CLEANUP_DUPLICATE_GRAPHIC, CLEANUP_DUPLICATE_TRACK, CLEANUP_LINES_TO_RECT, CLEANUP_MERGE_TRACKS, CLEANUP_NULL_GRAPHIC, CLEANUP_REDUNDANT_VIA, CLEANUP_SHORTING_TRACK, CLEANUP_SHORTING_VIA, CLEANUP_TRACK_IN_PAD, CLEANUP_ZERO_LENGTH_TRACK, and RC_ITEM::m_errorCode.

◆ GetErrorText() [2/2]

wxString RC_ITEM::GetErrorText ( ) const
inlineinherited

Definition at line 160 of file rc_item.h.

161  {
162  return wxGetTranslation( m_errorTitle );
163  }
wxString m_errorTitle
The string describing the type of error.
Definition: rc_item.h:178

References RC_ITEM::m_errorTitle.

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

◆ GetMainItemID()

KIID RC_ITEM::GetMainItemID ( ) const
inlineinherited

Definition at line 135 of file rc_item.h.

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

References RC_ITEM::m_ids, and niluuid.

Referenced by RC_ITEM::ShowReport().

◆ GetParent()

MARKER_BASE* RC_ITEM::GetParent ( void  ) const
inlineinherited

Definition at line 141 of file rc_item.h.

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

References RC_ITEM::m_parent.

◆ GetSettingsKey()

wxString RC_ITEM::GetSettingsKey ( ) const
inlineinherited

Definition at line 165 of file rc_item.h.

166  {
167  return m_settingsKey;
168  }
wxString m_settingsKey
The key used to describe this type of error in settings.
Definition: rc_item.h:179

References RC_ITEM::m_settingsKey.

Referenced by RC_ITEM::ShowReport().

◆ SetErrorCode()

void RC_ITEM::SetErrorCode ( int  aCode)
inlineinherited

Definition at line 153 of file rc_item.h.

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

References RC_ITEM::m_errorCode.

◆ SetErrorMessage()

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

Definition at line 95 of file rc_item.h.

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

References RC_ITEM::m_errorMessage.

◆ SetItems() [1/3]

void RC_ITEM::SetItems ( const KIIDS aIds)
inlineinherited

Definition at line 97 of file rc_item.h.

98  {
99  m_ids = aIds;
100  }
KIIDS m_ids
Definition: rc_item.h:182

References RC_ITEM::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 
)
inlineinherited

Definition at line 107 of file rc_item.h.

109  {
110  m_ids.clear();
111 
112  m_ids.push_back( aItem->m_Uuid );
113 
114  if( bItem )
115  m_ids.push_back( bItem->m_Uuid );
116 
117  if( cItem )
118  m_ids.push_back( cItem->m_Uuid );
119 
120  if( dItem )
121  m_ids.push_back( dItem->m_Uuid );
122  }
KIIDS m_ids
Definition: rc_item.h:182
const KIID m_Uuid
Definition: eda_item.h:524

References RC_ITEM::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 
)
inlineinherited

Definition at line 124 of file rc_item.h.

126  {
127  m_ids.clear();
128 
129  m_ids.push_back( aItem );
130  m_ids.push_back( bItem );
131  m_ids.push_back( cItem );
132  m_ids.push_back( dItem );
133  }
KIIDS m_ids
Definition: rc_item.h:182

References RC_ITEM::m_ids.

◆ SetParent()

void RC_ITEM::SetParent ( MARKER_BASE aMarker)
inlineinherited

Definition at line 140 of file rc_item.h.

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

References RC_ITEM::m_parent.

◆ ShowCoord()

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

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, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References Format(), and MessageTextFromValue().

Referenced by RC_ITEM::ShowReport().

◆ ShowReport()

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

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:301
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:136
bool IsExcluded() const
Definition: marker_base.h:94
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
MARKER_BASE * m_parent
The marker this item belongs to, if any.
Definition: rc_item.h:180
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: eda_item.cpp:123
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
wxString GetSettingsKey() const
Definition: rc_item.h:165
KIID GetMainItemID() const
Definition: rc_item.h:135
virtual wxString GetErrorMessage() const
Return the error message of a RC_ITEM.
Definition: rc_item.cpp:37

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

Member Data Documentation

◆ m_errorCode

int RC_ITEM::m_errorCode
protectedinherited

◆ m_errorMessage

wxString CLEANUP_ITEM::m_errorMessage
private

Definition at line 52 of file cleanup_item.h.

◆ m_errorTitle

wxString RC_ITEM::m_errorTitle
protectedinherited

The string describing the type of error.

Definition at line 178 of file rc_item.h.

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

◆ m_ids

◆ m_parent

MARKER_BASE* RC_ITEM::m_parent
protectedinherited

The marker this item belongs to, if any.

Definition at line 180 of file rc_item.h.

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

◆ m_settingsKey

wxString RC_ITEM::m_settingsKey
protectedinherited

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

Definition at line 179 of file rc_item.h.

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


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