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
 Return 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)
 
virtual KIID GetMainItemID () const
 
virtual KIID GetAuxItemID () const
 
virtual KIID GetAuxItem2ID () const
 
virtual KIID GetAuxItem3ID () const
 
std::vector< KIIDGetIDs () const
 
void SetParent (MARKER_BASE *aMarker)
 
MARKER_BASEGetParent () const
 
virtual wxString ShowReport (UNITS_PROVIDER *aUnitsProvider, 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
 
wxString GetErrorText () const
 
wxString GetSettingsKey () const
 
virtual wxString GetViolatingRuleDesc () const
 

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 77 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}
int m_errorCode
The error code's numeric value.
Definition: rc_item.h:165
wxString GetErrorText() const
Definition: rc_item.h:149
wxString m_errorTitle
The string describing the type of error.
Definition: rc_item.h:167

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

Member Function Documentation

◆ AddItem()

void RC_ITEM::AddItem ( EDA_ITEM aItem)
inherited

Definition at line 55 of file rc_item.cpp.

56{
57 m_ids.push_back( aItem->m_Uuid );
58}
const KIID m_Uuid
Definition: eda_item.h:492
KIIDS m_ids
Definition: rc_item.h:171

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

◆ GetAuxItem2ID()

virtual KIID RC_ITEM::GetAuxItem2ID ( ) const
inlinevirtualinherited

Reimplemented in DRC_ITEM.

Definition at line 119 of file rc_item.h.

119{ return m_ids.size() > 2 ? m_ids[2] : niluuid; }
KIID niluuid(0)

References RC_ITEM::m_ids, and niluuid.

◆ GetAuxItem3ID()

virtual KIID RC_ITEM::GetAuxItem3ID ( ) const
inlinevirtualinherited

Reimplemented in DRC_ITEM.

Definition at line 120 of file rc_item.h.

120{ return m_ids.size() > 3 ? m_ids[3] : niluuid; }

References RC_ITEM::m_ids, and niluuid.

◆ GetAuxItemID()

virtual KIID RC_ITEM::GetAuxItemID ( ) const
inlinevirtualinherited

Definition at line 118 of file rc_item.h.

118{ return m_ids.size() > 1 ? m_ids[1] : niluuid; }

References RC_ITEM::m_ids, and niluuid.

Referenced by RC_ITEM::ShowReport().

◆ GetErrorCode()

◆ GetErrorMessage()

wxString RC_ITEM::GetErrorMessage ( ) const
virtualinherited
Returns
the error message describing the specific details of a RC_ITEM. For instance, "Clearance violation (netclass '100ohm' clearance 0.4000mm; actual 0.3200mm)"

Definition at line 38 of file rc_item.cpp.

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

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

Referenced by RC_ITEM::ShowReport().

◆ GetErrorText() [1/2]

wxString RC_ITEM::GetErrorText ( ) const
inlineinherited
Returns
the error text for the class of error of this RC_ITEM represents. For instance, "Clearance violation".

Definition at line 149 of file rc_item.h.

150 {
151 return wxGetTranslation( m_errorTitle );
152 }

References RC_ITEM::m_errorTitle.

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

◆ GetErrorText() [2/2]

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

Return 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_SHORTING_TRACK: msg = _HKI( "Remove track shorting two nets" ); break;
47 case CLEANUP_SHORTING_VIA: msg = _HKI( "Remove via shorting two nets" ); break;
48 case CLEANUP_REDUNDANT_VIA: msg = _HKI( "Remove redundant via" ); break;
49 case CLEANUP_DUPLICATE_TRACK: msg = _HKI( "Remove duplicate track" ); break;
50 case CLEANUP_MERGE_TRACKS: msg = _HKI( "Merge co-linear tracks" ); break;
51 case CLEANUP_DANGLING_TRACK: msg = _HKI( "Remove track not connected at both ends" ); break;
52 case CLEANUP_DANGLING_VIA: msg = _HKI( "Remove via connected on less than 2 layers" ); break;
53 case CLEANUP_ZERO_LENGTH_TRACK: msg = _HKI( "Remove zero-length track" ); break;
54 case CLEANUP_TRACK_IN_PAD: msg = _HKI( "Remove track inside pad" ); break;
55
56 // For cleanup graphics:
57 case CLEANUP_NULL_GRAPHIC: msg = _HKI( "Remove zero-size graphic" ); break;
58 case CLEANUP_DUPLICATE_GRAPHIC: msg = _HKI( "Remove duplicated graphic" ); break;
59 case CLEANUP_LINES_TO_RECT: msg = _HKI( "Convert lines to rectangle" ); break;
60 case CLEANUP_MERGE_PAD: msg = _HKI( "Merge overlapping shapes into pad" ); break;
61
62 default:
63 wxFAIL_MSG( wxT( "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}
@ CLEANUP_TRACK_IN_PAD
Definition: cleanup_item.h:42
@ CLEANUP_NULL_GRAPHIC
Definition: cleanup_item.h:43
@ CLEANUP_DANGLING_VIA
Definition: cleanup_item.h:40
@ CLEANUP_MERGE_TRACKS
Definition: cleanup_item.h:38
@ CLEANUP_DANGLING_TRACK
Definition: cleanup_item.h:39
@ CLEANUP_DUPLICATE_TRACK
Definition: cleanup_item.h:37
@ CLEANUP_MERGE_PAD
Definition: cleanup_item.h:46
@ CLEANUP_ZERO_LENGTH_TRACK
Definition: cleanup_item.h:41
@ CLEANUP_DUPLICATE_GRAPHIC
Definition: cleanup_item.h:44
@ CLEANUP_LINES_TO_RECT
Definition: cleanup_item.h:45
@ CLEANUP_SHORTING_VIA
Definition: cleanup_item.h:35
@ CLEANUP_REDUNDANT_VIA
Definition: cleanup_item.h:36
@ CLEANUP_SHORTING_TRACK
Definition: cleanup_item.h:34
#define _HKI(x)

References _HKI, CLEANUP_DANGLING_TRACK, CLEANUP_DANGLING_VIA, CLEANUP_DUPLICATE_GRAPHIC, CLEANUP_DUPLICATE_TRACK, CLEANUP_LINES_TO_RECT, CLEANUP_MERGE_PAD, 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.

◆ GetIDs()

std::vector< KIID > RC_ITEM::GetIDs ( ) const
inlineinherited

Definition at line 122 of file rc_item.h.

122{ return m_ids; }

References RC_ITEM::m_ids.

◆ GetMainItemID()

virtual KIID RC_ITEM::GetMainItemID ( ) const
inlinevirtualinherited

Definition at line 117 of file rc_item.h.

117{ return m_ids.size() > 0 ? m_ids[0] : niluuid; }

References RC_ITEM::m_ids, and niluuid.

Referenced by RC_ITEM::ShowReport().

◆ GetParent()

MARKER_BASE * RC_ITEM::GetParent ( void  ) const
inlineinherited

Definition at line 125 of file rc_item.h.

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

References RC_ITEM::m_parent.

◆ GetSettingsKey()

wxString RC_ITEM::GetSettingsKey ( ) const
inlineinherited

Definition at line 154 of file rc_item.h.

155 {
156 return m_settingsKey;
157 }
wxString m_settingsKey
The key used to describe this type of error in settings.
Definition: rc_item.h:168

References RC_ITEM::m_settingsKey.

Referenced by RC_ITEM::ShowReport().

◆ GetViolatingRuleDesc()

virtual wxString RC_ITEM::GetViolatingRuleDesc ( ) const
inlinevirtualinherited

Reimplemented in DRC_ITEM.

Definition at line 159 of file rc_item.h.

160 {
161 return wxEmptyString;
162 }

Referenced by RC_ITEM::ShowReport().

◆ SetErrorCode()

void RC_ITEM::SetErrorCode ( int  aCode)
inlineinherited

Definition at line 137 of file rc_item.h.

137{ m_errorCode = aCode; }

References RC_ITEM::m_errorCode.

◆ SetErrorMessage()

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

Definition at line 97 of file rc_item.h.

97{ m_errorMessage = aMessage; }

References RC_ITEM::m_errorMessage.

◆ SetItems() [1/3]

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

Definition at line 61 of file rc_item.cpp.

63{
64 m_ids.clear();
65
66 m_ids.push_back( aItem->m_Uuid );
67
68 if( bItem )
69 m_ids.push_back( bItem->m_Uuid );
70
71 if( cItem )
72 m_ids.push_back( cItem->m_Uuid );
73
74 if( dItem )
75 m_ids.push_back( dItem->m_Uuid );
76}

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

◆ SetItems() [2/3]

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

Definition at line 106 of file rc_item.h.

108 {
109 m_ids.clear();
110
111 m_ids.push_back( aItem );
112 m_ids.push_back( bItem );
113 m_ids.push_back( cItem );
114 m_ids.push_back( dItem );
115 }

References RC_ITEM::m_ids.

◆ SetItems() [3/3]

void RC_ITEM::SetItems ( const KIIDS aIds)
inlineinherited

Definition at line 99 of file rc_item.h.

99{ m_ids = aIds; }

References RC_ITEM::m_ids.

◆ SetParent()

void RC_ITEM::SetParent ( MARKER_BASE aMarker)
inlineinherited

Definition at line 124 of file rc_item.h.

124{ m_parent = aMarker; }

References RC_ITEM::m_parent.

◆ ShowReport()

wxString RC_ITEM::ShowReport ( UNITS_PROVIDER aUnitsProvider,
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 79 of file rc_item.cpp.

81{
82 wxString severity;
83
84 switch( aSeverity )
85 {
86 case RPT_SEVERITY_ERROR: severity = wxT( "Severity: error" ); break;
87 case RPT_SEVERITY_WARNING: severity = wxT( "Severity: warning" ); break;
88 case RPT_SEVERITY_ACTION: severity = wxT( "Severity: action" ); break;
89 case RPT_SEVERITY_INFO: severity = wxT( "Severity: info" ); break;
90 case RPT_SEVERITY_EXCLUSION: severity = wxT( "Severity: exclusion" ); break;
91 case RPT_SEVERITY_DEBUG: severity = wxT( "Severity: debug" ); break;
92 default: ;
93 };
94
95 if( m_parent && m_parent->IsExcluded() )
96 severity += wxT( " (excluded)" );
97
98 EDA_ITEM* mainItem = nullptr;
99 EDA_ITEM* auxItem = nullptr;
100
101 auto ii = aItemMap.find( GetMainItemID() );
102
103 if( ii != aItemMap.end() )
104 mainItem = ii->second;
105
106 ii = aItemMap.find( GetAuxItemID() );
107
108 if( ii != aItemMap.end() )
109 auxItem = ii->second;
110
111 // Note: some customers machine-process these. So:
112 // 1) don't translate
113 // 2) try not to re-order or change syntax
114 // 3) report settings key (which should be more stable) in addition to message
115
116 if( mainItem && auxItem )
117 {
118 return wxString::Format( wxT( "[%s]: %s\n %s; %s\n %s: %s\n %s: %s\n" ),
122 severity,
123 showCoord( aUnitsProvider, mainItem->GetPosition()),
124 mainItem->GetItemDescription( aUnitsProvider ),
125 showCoord( aUnitsProvider, auxItem->GetPosition()),
126 auxItem->GetItemDescription( aUnitsProvider ) );
127 }
128 else if( mainItem )
129 {
130 return wxString::Format( wxT( "[%s]: %s\n %s; %s\n %s: %s\n" ),
134 severity,
135 showCoord( aUnitsProvider, mainItem->GetPosition()),
136 mainItem->GetItemDescription( aUnitsProvider ) );
137 }
138 else
139 {
140 return wxString::Format( wxT( "[%s]: %s\n %s; %s\n" ),
144 severity );
145 }
146}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const
Return a user-visible description string of this item.
Definition: eda_item.cpp:108
bool IsExcluded() const
Definition: marker_base.h:97
virtual KIID GetMainItemID() const
Definition: rc_item.h:117
virtual KIID GetAuxItemID() const
Definition: rc_item.h:118
virtual wxString GetErrorMessage() const
Definition: rc_item.cpp:38
wxString GetSettingsKey() const
Definition: rc_item.h:154
virtual wxString GetViolatingRuleDesc() const
Definition: rc_item.h:159
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
static wxString showCoord(UNITS_PROVIDER *aUnitsProvider, const VECTOR2I &aPos)
Definition: rc_item.cpp:47
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_EXCLUSION
@ RPT_SEVERITY_DEBUG
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION

References Format(), RC_ITEM::GetAuxItemID(), RC_ITEM::GetErrorMessage(), EDA_ITEM::GetItemDescription(), RC_ITEM::GetMainItemID(), EDA_ITEM::GetPosition(), RC_ITEM::GetSettingsKey(), RC_ITEM::GetViolatingRuleDesc(), MARKER_BASE::IsExcluded(), RC_ITEM::m_parent, RPT_SEVERITY_ACTION, RPT_SEVERITY_DEBUG, RPT_SEVERITY_ERROR, RPT_SEVERITY_EXCLUSION, RPT_SEVERITY_INFO, RPT_SEVERITY_WARNING, and showCoord().

Member Data Documentation

◆ m_errorCode

int RC_ITEM::m_errorCode
protectedinherited

◆ m_errorMessage

wxString CLEANUP_ITEM::m_errorMessage
private

Definition at line 60 of file cleanup_item.h.

◆ m_errorTitle

wxString RC_ITEM::m_errorTitle
protectedinherited

The string describing the type of error.

Definition at line 167 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 169 of file rc_item.h.

Referenced by DRC_ITEM::DRC_ITEM(), 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 168 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: