KiCad PCB EDA Suite
PANEL_SETUP_SEVERITIES Class Reference

#include <panel_setup_severities.h>

Inheritance diagram for PANEL_SETUP_SEVERITIES:

Public Member Functions

 PANEL_SETUP_SEVERITIES (PAGED_DIALOG *aParent, std::vector< std::reference_wrapper< RC_ITEM > > aItems, std::map< int, SEVERITY > &aSeverities, RC_ITEM *aPinMapSpecialCase=nullptr)
 Creates the severities setup panel. More...
 
void ImportSettingsFrom (std::map< int, SEVERITY > &aSettings)
 

Private Member Functions

bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 

Private Attributes

std::map< int, SEVERITY > & m_severities
 
std::vector< std::reference_wrapper< RC_ITEM > > m_items
 A list of item templates (to get descriptive text and error codes from) More...
 
RC_ITEMm_pinMapSpecialCase
 For ERC settings; a pointer to ERC_ITEM::pinTableConflict. More...
 
std::map< int, wxRadioButton *[4]> m_buttonMap
 

Detailed Description

Definition at line 37 of file panel_setup_severities.h.

Constructor & Destructor Documentation

◆ PANEL_SETUP_SEVERITIES()

PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES ( PAGED_DIALOG aParent,
std::vector< std::reference_wrapper< RC_ITEM > >  aItems,
std::map< int, SEVERITY > &  aSeverities,
RC_ITEM aPinMapSpecialCase = nullptr 
)

Creates the severities setup panel.

Parameters
aParentis the dialog parent
aItemsis a list of error types that can have a severity. Must have one or more!
aSeveritiesis a map of error code to severity
aPinMapSpecialCaseis used to special-case the ERCE_PIN_TO_PIN_WARNING

Definition at line 34 of file panel_setup_severities.cpp.

37 :
38 wxPanel( aParent->GetTreebook() ),
39 m_severities( aSeverities ),
40 m_items( aItems ),
41 m_pinMapSpecialCase( aPinMapSpecialCase )
42{
43 wxString severities[] = { _( "Error" ), _( "Warning" ), _( "Ignore" ) };
44 int severityCount = sizeof( severities ) / sizeof( wxString );
45 int baseID = 1000;
46 wxBoxSizer* panelSizer = new wxBoxSizer( wxVERTICAL );
47 wxScrolledWindow* scrollWin = new wxScrolledWindow( this, wxID_ANY,
48 wxDefaultPosition, wxDefaultSize,
49 wxTAB_TRAVERSAL | wxVSCROLL );
50 bool firstLine = true;
51
52 scrollWin->SetScrollRate( 0, 5 );
53
54 wxBoxSizer* scrollWinSizer = new wxBoxSizer( wxVERTICAL );
55 scrollWin->SetSizer( scrollWinSizer );
56
57 wxFlexGridSizer* gridSizer = new wxFlexGridSizer( 0, 2, 0, 5 );
58 gridSizer->SetFlexibleDirection( wxBOTH );
59 gridSizer->SetVGap( 5 );
60
61 for( const RC_ITEM& item : m_items )
62 {
63 int errorCode = item.GetErrorCode();
64 wxString msg = item.GetErrorText();
65
67 continue;
68
69 if( errorCode == 0 )
70 {
71 wxStaticText* heading = new wxStaticText( scrollWin, wxID_ANY, msg );
72 wxFont headingFont = heading->GetFont();
73
74 heading->SetFont( headingFont.Bold() );
75
76 if( !firstLine )
77 {
78 gridSizer->AddSpacer( 5 ); // col 1
79 gridSizer->AddSpacer( 5 ); // col 2
80 }
81
82 gridSizer->Add( heading, 0, wxALIGN_BOTTOM | wxALL | wxEXPAND, 4 );
83 gridSizer->AddSpacer( 0 ); // col 2
84 }
85 else if( !msg.IsEmpty() ) // items with no message are for internal use only
86 {
87 wxStaticText* errorLabel = new wxStaticText( scrollWin, wxID_ANY, msg + wxT( ":" ) );
88 gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 15 );
89
90 // OSX can't handle more than 100 radio buttons in a single window (yes, seriously),
91 // so we have to create a window for each set
92 wxPanel* radioPanel = new wxPanel( scrollWin );
93 wxBoxSizer* radioSizer = new wxBoxSizer( wxHORIZONTAL );
94
95 for( int i = 0; i < severityCount; ++i )
96 {
97 m_buttonMap[ errorCode ][i] = new wxRadioButton( radioPanel,
98 baseID + errorCode * 10 + i,
99 severities[i],
100 wxDefaultPosition, wxDefaultSize,
101 i == 0 ? wxRB_GROUP : 0 );
102 radioSizer->Add( m_buttonMap[ errorCode ][i], 0,
103 wxRIGHT | wxALIGN_CENTER_VERTICAL, 30 );
104 }
105
106 radioPanel->SetSizer( radioSizer );
107 radioPanel->Layout();
108 gridSizer->Add( radioPanel, 0, wxALIGN_CENTER_VERTICAL );
109 }
110
111 firstLine = false;
112 }
113
114
116 {
117 wxString pinMapSeverities[] = { _( "From Pin Conflicts Map" ), wxT( "" ), _( "Ignore" ) };
118 int errorCode = m_pinMapSpecialCase->GetErrorCode();
119 wxString msg = m_pinMapSpecialCase->GetErrorText();
120
121 wxStaticText* errorLabel = new wxStaticText( scrollWin, wxID_ANY, msg + wxT( ":" ) );
122 gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 15 );
123
124 wxPanel* radioPanel = new wxPanel( scrollWin );
125 wxBoxSizer* radioSizer = new wxBoxSizer( wxHORIZONTAL );
126
127 for( size_t i = 0; i < 3; ++i )
128 {
129 if( pinMapSeverities[i] == wxT( "" ) )
130 {
131 wxStaticText* spacer = new wxStaticText( radioPanel, wxID_ANY, wxT( "" ) );
132 radioSizer->Add( spacer, 0, wxRIGHT | wxEXPAND, 17 );
133 }
134 else
135 {
136 m_buttonMap[ errorCode ][i] = new wxRadioButton( radioPanel,
137 baseID + errorCode * 10 + i,
138 pinMapSeverities[i],
139 wxDefaultPosition, wxDefaultSize,
140 i == 0 ? wxRB_GROUP : 0 );
141 radioSizer->Add( m_buttonMap[ errorCode ][i], 0, wxEXPAND );
142 }
143 }
144
145 radioPanel->SetSizer( radioSizer );
146 radioPanel->Layout();
147 gridSizer->Add( radioPanel, 0, wxALIGN_CENTER_VERTICAL );
148 }
149
150 scrollWinSizer->Add( gridSizer, 1, wxEXPAND | wxALL, 5 );
151 panelSizer->Add( scrollWin, 1, wxEXPAND, 0 );
152
153 SetSizer( panelSizer );
154 Layout();
155 panelSizer->Fit( this );
156}
wxTreebook * GetTreebook()
Definition: paged_dialog.h:37
std::map< int, SEVERITY > & m_severities
RC_ITEM * m_pinMapSpecialCase
For ERC settings; a pointer to ERC_ITEM::pinTableConflict.
std::map< int, wxRadioButton *[4]> m_buttonMap
std::vector< std::reference_wrapper< RC_ITEM > > m_items
A list of item templates (to get descriptive text and error codes from)
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Definition: rc_item.h:75
int GetErrorCode() const
Definition: rc_item.h:136
wxString GetErrorText() const
Definition: rc_item.h:149
#define _(s)

References _, RC_ITEM::GetErrorCode(), RC_ITEM::GetErrorText(), m_buttonMap, m_items, and m_pinMapSpecialCase.

Member Function Documentation

◆ ImportSettingsFrom()

void PANEL_SETUP_SEVERITIES::ImportSettingsFrom ( std::map< int, SEVERITY > &  aSettings)

Definition at line 159 of file panel_setup_severities.cpp.

160{
161 for( const RC_ITEM& item : m_items )
162 {
163 int errorCode = item.GetErrorCode();
164
165 if(! m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
166 continue;
167
168 switch( aSettings[ errorCode ] )
169 {
170 case RPT_SEVERITY_ERROR: m_buttonMap[ errorCode ][0]->SetValue( true ); break;
171 case RPT_SEVERITY_WARNING: m_buttonMap[ errorCode ][1]->SetValue( true ); break;
172 case RPT_SEVERITY_IGNORE: m_buttonMap[ errorCode ][2]->SetValue( true ); break;
173 default: break;
174 }
175 }
176
178 {
179 int pinMapCode = m_pinMapSpecialCase->GetErrorCode();
180 int newSeverity = aSettings[ pinMapCode ];
181
182 m_buttonMap[ pinMapCode ][0]->SetValue( newSeverity != RPT_SEVERITY_IGNORE );
183 m_buttonMap[ pinMapCode ][2]->SetValue( newSeverity == RPT_SEVERITY_IGNORE );
184 }
185}
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_IGNORE

References RC_ITEM::GetErrorCode(), m_buttonMap, m_items, m_pinMapSpecialCase, RPT_SEVERITY_ERROR, RPT_SEVERITY_IGNORE, and RPT_SEVERITY_WARNING.

Referenced by DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction(), and DIALOG_BOARD_SETUP::onAuxiliaryAction().

◆ TransferDataFromWindow()

bool PANEL_SETUP_SEVERITIES::TransferDataFromWindow ( )
overrideprivate

Definition at line 222 of file panel_setup_severities.cpp.

223{
224 for( const RC_ITEM& item : m_items )
225 {
226 int errorCode = item.GetErrorCode();
227
229 continue;
230
231 if( !m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
232 continue;
233
235
236 if( m_buttonMap[ errorCode ][0]->GetValue() )
237 severity = RPT_SEVERITY_ERROR;
238 else if( m_buttonMap[ errorCode ][1]->GetValue() )
239 severity = RPT_SEVERITY_WARNING;
240 else if( m_buttonMap[ errorCode ][2]->GetValue() )
241 severity = RPT_SEVERITY_IGNORE;
242
243 m_severities[ errorCode ] = severity;
244 }
245
247 {
248 int pinMapCode = m_pinMapSpecialCase->GetErrorCode();
250
251 if( m_buttonMap[ pinMapCode ][0]->GetValue() )
252 severity = RPT_SEVERITY_ERROR;
253 else if( m_buttonMap[ pinMapCode ][2]->GetValue() )
254 severity = RPT_SEVERITY_IGNORE;
255
256 m_severities[ pinMapCode ] = severity;
257 }
258
259 return true;
260}
SEVERITY
@ RPT_SEVERITY_UNDEFINED

References RC_ITEM::GetErrorCode(), m_buttonMap, m_items, m_pinMapSpecialCase, m_severities, RPT_SEVERITY_ERROR, RPT_SEVERITY_IGNORE, RPT_SEVERITY_UNDEFINED, and RPT_SEVERITY_WARNING.

◆ TransferDataToWindow()

bool PANEL_SETUP_SEVERITIES::TransferDataToWindow ( )
overrideprivate

Definition at line 188 of file panel_setup_severities.cpp.

189{
190 for( const RC_ITEM& item : m_items )
191 {
192 int errorCode = item.GetErrorCode();
193
194 if( !m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
195 continue;
196
198 continue;
199
200 switch( m_severities[ errorCode ] )
201 {
202 case RPT_SEVERITY_ERROR: m_buttonMap[ errorCode ][0]->SetValue( true ); break;
203 case RPT_SEVERITY_WARNING: m_buttonMap[ errorCode ][1]->SetValue( true ); break;
204 case RPT_SEVERITY_IGNORE: m_buttonMap[ errorCode ][2]->SetValue( true ); break;
205 default: break;
206 }
207 }
208
210 {
211 int pinMapCode = m_pinMapSpecialCase->GetErrorCode();
212 int severity = m_severities[pinMapCode];
213
214 m_buttonMap[ pinMapCode ][0]->SetValue( severity != RPT_SEVERITY_IGNORE );
215 m_buttonMap[ pinMapCode ][2]->SetValue( severity == RPT_SEVERITY_IGNORE );
216 }
217
218 return true;
219}

References RC_ITEM::GetErrorCode(), m_buttonMap, m_items, m_pinMapSpecialCase, m_severities, RPT_SEVERITY_ERROR, RPT_SEVERITY_IGNORE, and RPT_SEVERITY_WARNING.

Member Data Documentation

◆ m_buttonMap

std::map<int, wxRadioButton*[4]> PANEL_SETUP_SEVERITIES::m_buttonMap
private

◆ m_items

std::vector<std::reference_wrapper<RC_ITEM> > PANEL_SETUP_SEVERITIES::m_items
private

A list of item templates (to get descriptive text and error codes from)

Definition at line 43 of file panel_setup_severities.h.

Referenced by ImportSettingsFrom(), PANEL_SETUP_SEVERITIES(), TransferDataFromWindow(), and TransferDataToWindow().

◆ m_pinMapSpecialCase

RC_ITEM* PANEL_SETUP_SEVERITIES::m_pinMapSpecialCase
private

For ERC settings; a pointer to ERC_ITEM::pinTableConflict.

Definition at line 46 of file panel_setup_severities.h.

Referenced by ImportSettingsFrom(), PANEL_SETUP_SEVERITIES(), TransferDataFromWindow(), and TransferDataToWindow().

◆ m_severities

std::map<int, SEVERITY>& PANEL_SETUP_SEVERITIES::m_severities
private

Definition at line 40 of file panel_setup_severities.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().


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