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, int > &aSeverities, RC_ITEM *aPinMapSpecialCase=nullptr)
 Creates the severities setup panel. More...
 
void ImportSettingsFrom (std::map< int, int > &aSettings)
 

Private Member Functions

bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 

Private Attributes

std::map< int, int > & 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, int > &  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 30 of file panel_setup_severities.cpp.

33  :
34  wxPanel( aParent->GetTreebook() ),
35  m_severities( aSeverities ),
36  m_items( aItems ),
37  m_pinMapSpecialCase( aPinMapSpecialCase )
38 {
39  wxString severities[] = { _( "Error" ), _( "Warning" ), _( "Ignore" ) };
40  int severityCount = sizeof( severities ) / sizeof( wxString );
41  int baseID = 1000;
42  wxBoxSizer* panelSizer = new wxBoxSizer( wxVERTICAL );
43  wxScrolledWindow* scrollWin = new wxScrolledWindow( this, wxID_ANY,
44  wxDefaultPosition, wxDefaultSize,
45  wxTAB_TRAVERSAL | wxVSCROLL );
46 
47  scrollWin->SetScrollRate( 0, 5 );
48 
49  wxFlexGridSizer* gridSizer = new wxFlexGridSizer( 0, 2, 0, 5 );
50  gridSizer->SetFlexibleDirection( wxBOTH );
51 
52  for( const RC_ITEM& item : m_items )
53  {
54  int errorCode = item.GetErrorCode();
55  wxString msg = item.GetErrorText();
56 
57  // When msg is empty, for some reason, the current errorCode is not supported
58  // by the RC_ITEM aDummyItem.
59  // Skip this errorCode.
60  if( !msg.IsEmpty() )
61  {
62  wxStaticText* errorLabel = new wxStaticText( scrollWin, wxID_ANY, msg + wxT( ":" ) );
63  gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 4 );
64 
65  // OSX can't handle more than 100 radio buttons in a single window (yes, seriously),
66  // so we have to create a window for each set
67  wxPanel* radioPanel = new wxPanel( scrollWin );
68  wxBoxSizer* radioSizer = new wxBoxSizer( wxHORIZONTAL );
69 
70  for( int i = 0; i < severityCount; ++i )
71  {
72  m_buttonMap[ errorCode ][i] = new wxRadioButton( radioPanel,
73  baseID + errorCode * 10 + i,
74  severities[i],
75  wxDefaultPosition,
76  wxDefaultSize,
77  i == 0 ? wxRB_GROUP : 0 );
78  radioSizer->Add( m_buttonMap[ errorCode ][i], 0, wxRIGHT | wxEXPAND, 30 );
79  }
80 
81  radioPanel->SetSizer( radioSizer );
82  radioPanel->Layout();
83  gridSizer->Add( radioPanel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 4 );
84  }
85  }
86 
88  {
89  wxString pinMapSeverities[] = { _( "From Pin Conflicts Map" ), wxT( "" ), _( "Ignore" ) };
90  int errorCode = m_pinMapSpecialCase->GetErrorCode();
91  wxString msg = m_pinMapSpecialCase->GetErrorText();
92 
93  wxStaticText* errorLabel = new wxStaticText( scrollWin, wxID_ANY, msg + wxT( ":" ) );
94  gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 4 );
95 
96  wxPanel* radioPanel = new wxPanel( scrollWin );
97  wxBoxSizer* radioSizer = new wxBoxSizer( wxHORIZONTAL );
98 
99  for( size_t i = 0; i < 3; ++i )
100  {
101  if( pinMapSeverities[i] == wxT( "" ) )
102  {
103  wxStaticText* spacer = new wxStaticText( radioPanel, wxID_ANY, wxT( "" ) );
104  radioSizer->Add( spacer, 0, wxRIGHT | wxEXPAND, 17 );
105  }
106  else
107  {
108  m_buttonMap[ errorCode ][i] = new wxRadioButton( radioPanel,
109  baseID + errorCode * 10 + i,
110  pinMapSeverities[i],
111  wxDefaultPosition,
112  wxDefaultSize,
113  i == 0 ? wxRB_GROUP : 0 );
114  radioSizer->Add( m_buttonMap[ errorCode ][i], 0, wxEXPAND );
115  }
116  }
117 
118  radioPanel->SetSizer( radioSizer );
119  radioPanel->Layout();
120  gridSizer->Add( radioPanel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 4 );
121  }
122 
123  scrollWin->SetSizer( gridSizer );
124  scrollWin->Layout();
125  gridSizer->Fit( scrollWin );
126  panelSizer->Add( scrollWin, 1, wxEXPAND | wxALL, 5 );
127 
128  this->SetSizer( panelSizer );
129  this->Layout();
130  panelSizer->Fit( this );
131 }
std::map< int, int > & m_severities
RC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
Definition: rc_item.h:77
wxString GetErrorText() const
Definition: rc_item.h:169
RC_ITEM * m_pinMapSpecialCase
For ERC settings; a pointer to ERC_ITEM::pinTableConflict.
wxTreebook * GetTreebook()
Definition: paged_dialog.h:45
std::map< int, wxRadioButton *[4]> m_buttonMap
int GetErrorCode() const
Definition: rc_item.h:160
#define _(s)
Definition: 3d_actions.cpp:33
std::vector< std::reference_wrapper< RC_ITEM > > m_items
A list of item templates (to get descriptive text and error codes from)

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, int > &  aSettings)

Definition at line 134 of file panel_setup_severities.cpp.

135 {
136  for( const RC_ITEM& item : m_items )
137  {
138  int errorCode = item.GetErrorCode();
139 
140  if(! m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
141  continue;
142 
143  switch( aSettings[ errorCode ] )
144  {
145  case RPT_SEVERITY_ERROR: m_buttonMap[ errorCode ][0]->SetValue( true ); break;
146  case RPT_SEVERITY_WARNING: m_buttonMap[ errorCode ][1]->SetValue( true ); break;
147  case RPT_SEVERITY_IGNORE: m_buttonMap[ errorCode ][2]->SetValue( true ); break;
148  default: break;
149  }
150  }
151 
152  if( m_pinMapSpecialCase )
153  {
154  int pinMapCode = m_pinMapSpecialCase->GetErrorCode();
155  int newSeverity = aSettings[ pinMapCode ];
156 
157  m_buttonMap[ pinMapCode ][0]->SetValue( newSeverity != RPT_SEVERITY_IGNORE );
158  m_buttonMap[ pinMapCode ][1]->SetValue( newSeverity == RPT_SEVERITY_IGNORE );
159  }
160 }
RC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
Definition: rc_item.h:77
RC_ITEM * m_pinMapSpecialCase
For ERC settings; a pointer to ERC_ITEM::pinTableConflict.
std::map< int, wxRadioButton *[4]> m_buttonMap
int GetErrorCode() const
Definition: rc_item.h:160
std::vector< std::reference_wrapper< RC_ITEM > > m_items
A list of item templates (to get descriptive text and error codes from)

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 194 of file panel_setup_severities.cpp.

195 {
196  for( const RC_ITEM& item : m_items )
197  {
198  int errorCode = item.GetErrorCode();
199 
200  if( !m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
201  continue;
202 
203  int severity = RPT_SEVERITY_UNDEFINED;
204 
205  if( m_buttonMap[ errorCode ][0]->GetValue() )
206  severity = RPT_SEVERITY_ERROR;
207  else if( m_buttonMap[ errorCode ][1]->GetValue() )
208  severity = RPT_SEVERITY_WARNING;
209  else if( m_buttonMap[ errorCode ][2]->GetValue() )
210  severity = RPT_SEVERITY_IGNORE;
211 
212  m_severities[ errorCode ] = severity;
213  }
214 
215  if( m_pinMapSpecialCase )
216  {
217  int pinMapCode = m_pinMapSpecialCase->GetErrorCode();
218  int severity = RPT_SEVERITY_UNDEFINED;
219 
220  if( m_buttonMap[ pinMapCode ][0]->GetValue() )
221  severity = RPT_SEVERITY_ERROR;
222  else if( m_buttonMap[ pinMapCode ][2]->GetValue() )
223  severity = RPT_SEVERITY_IGNORE;
224 
225  m_severities[ pinMapCode ] = severity;
226  }
227 
228  return true;
229 }
std::map< int, int > & m_severities
RC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
Definition: rc_item.h:77
RC_ITEM * m_pinMapSpecialCase
For ERC settings; a pointer to ERC_ITEM::pinTableConflict.
std::map< int, wxRadioButton *[4]> m_buttonMap
int GetErrorCode() const
Definition: rc_item.h:160
std::vector< std::reference_wrapper< RC_ITEM > > m_items
A list of item templates (to get descriptive text and error codes from)

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 163 of file panel_setup_severities.cpp.

164 {
165  for( const RC_ITEM& item : m_items )
166  {
167  int errorCode = item.GetErrorCode();
168 
169  if( !m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
170  continue;
171 
172  switch( m_severities[ errorCode ] )
173  {
174  case RPT_SEVERITY_ERROR: m_buttonMap[ errorCode ][0]->SetValue( true ); break;
175  case RPT_SEVERITY_WARNING: m_buttonMap[ errorCode ][1]->SetValue( true ); break;
176  case RPT_SEVERITY_IGNORE: m_buttonMap[ errorCode ][2]->SetValue( true ); break;
177  default: break;
178  }
179  }
180 
181  if( m_pinMapSpecialCase )
182  {
183  int pinMapCode = m_pinMapSpecialCase->GetErrorCode();
184  int severity = m_severities[pinMapCode];
185 
186  m_buttonMap[ pinMapCode ][0]->SetValue( severity != RPT_SEVERITY_IGNORE );
187  m_buttonMap[ pinMapCode ][2]->SetValue( severity == RPT_SEVERITY_IGNORE );
188  }
189 
190  return true;
191 }
std::map< int, int > & m_severities
RC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
Definition: rc_item.h:77
RC_ITEM * m_pinMapSpecialCase
For ERC settings; a pointer to ERC_ITEM::pinTableConflict.
std::map< int, wxRadioButton *[4]> m_buttonMap
int GetErrorCode() const
Definition: rc_item.h:160
std::vector< std::reference_wrapper< RC_ITEM > > m_items
A list of item templates (to get descriptive text and error codes from)

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, int>& 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: