KiCad PCB EDA Suite
PANEL_SETUP_PINMAP Class Reference

#include <panel_setup_pinmap.h>

Inheritance diagram for PANEL_SETUP_PINMAP:
PANEL_SETUP_PINMAP_BASE RESETTABLE_PANEL

Public Member Functions

 PANEL_SETUP_PINMAP (wxWindow *aWindow, SCH_EDIT_FRAME *aParent)
 
void ImportSettingsFrom (PIN_ERROR aPinMap[][ELECTRICAL_PINTYPES_TOTAL])
 
void ResetPanel () override
 Reset the contents of this panel. More...
 
virtual wxString GetResetTooltip ()
 Get the tooltip the reset button should display when showing this panel. More...
 

Protected Attributes

wxPanel * m_matrixPanel
 

Private Member Functions

void changeErrorLevel (wxCommandEvent &event)
 
void reBuildMatrixPanel ()
 
void setDRCMatrixButtonState (wxBitmapButton *aButton, PIN_ERROR aState)
 

Private Attributes

SCH_EDIT_FRAMEm_parent
 
SCHEMATICm_schematic
 
wxBitmapButton * m_buttonList [ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
 
bool m_initialized
 

Detailed Description

Definition at line 39 of file panel_setup_pinmap.h.

Constructor & Destructor Documentation

◆ PANEL_SETUP_PINMAP()

PANEL_SETUP_PINMAP::PANEL_SETUP_PINMAP ( wxWindow *  aWindow,
SCH_EDIT_FRAME aParent 
)

Member Function Documentation

◆ changeErrorLevel()

void PANEL_SETUP_PINMAP::changeErrorLevel ( wxCommandEvent &  event)
private

Definition at line 194 of file panel_setup_pinmap.cpp.

195 {
196  int id = event.GetId();
197  int ii = id - ID_MATRIX_0;
198  int x = ii / ELECTRICAL_PINTYPES_TOTAL;
199  int y = ii % ELECTRICAL_PINTYPES_TOTAL;
200  wxBitmapButton* butt = (wxBitmapButton*) event.GetEventObject();
201 
202  int level = static_cast<int>( m_schematic->ErcSettings().GetPinMapValue( y, x ) );
203  level = ( level + 1 ) % 3;
204 
205  setDRCMatrixButtonState( butt, static_cast<PIN_ERROR>( level ) );
206 
207  m_schematic->ErcSettings().SetPinMapValue( y, x, static_cast<PIN_ERROR>( level ) );
208  m_schematic->ErcSettings().SetPinMapValue( x, y, static_cast<PIN_ERROR>( level ) );
209 }
void setDRCMatrixButtonState(wxBitmapButton *aButton, PIN_ERROR aState)
#define ID_MATRIX_0
void SetPinMapValue(int aFirstType, int aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:146
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
Definition: erc_settings.h:134
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:174
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:53

References ELECTRICAL_PINTYPES_TOTAL, SCHEMATIC::ErcSettings(), ERC_SETTINGS::GetPinMapValue(), ID_MATRIX_0, m_schematic, setDRCMatrixButtonState(), and ERC_SETTINGS::SetPinMapValue().

◆ GetResetTooltip()

virtual wxString RESETTABLE_PANEL::GetResetTooltip ( )
inlinevirtualinherited

Get the tooltip the reset button should display when showing this panel.

Returns
the tooltip

Reimplemented in PANEL_HOTKEYS_EDITOR, and PANEL_COLOR_SETTINGS.

Definition at line 52 of file resettable_panel.h.

53  {
54  return _( "Reset all settings on this page to their default" );
55  }
#define _(s)

References _.

◆ ImportSettingsFrom()

void PANEL_SETUP_PINMAP::ImportSettingsFrom ( PIN_ERROR  aPinMap[][ELECTRICAL_PINTYPES_TOTAL])

Definition at line 212 of file panel_setup_pinmap.cpp.

213 {
214  for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
215  {
216  for( int jj = 0; jj <= ii; jj++ )
217  setDRCMatrixButtonState( m_buttonList[ii][jj], aPinMap[ii][jj] );
218  }
219 }
void setDRCMatrixButtonState(wxBitmapButton *aButton, PIN_ERROR aState)
wxBitmapButton * m_buttonList[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:53

References ELECTRICAL_PINTYPES_TOTAL, m_buttonList, and setDRCMatrixButtonState().

Referenced by DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction().

◆ reBuildMatrixPanel()

void PANEL_SETUP_PINMAP::reBuildMatrixPanel ( )
private

Definition at line 70 of file panel_setup_pinmap.cpp.

71 {
72  // Try to know the size of bitmap button used in drc matrix
73  wxBitmapButton* dummy = new wxBitmapButton( m_matrixPanel, wxID_ANY, KiBitmap( BITMAPS::ercerr ) );
74  wxSize bmapSize = dummy->GetSize();
75  delete dummy;
76 
77  wxSize charSize = KIUI::GetTextSize( "X", m_matrixPanel );
78  wxPoint pos( 0, charSize.y * 2 );
79  wxStaticText* text;
80 
81 #ifdef __WXMAC__
82  bmapSize.y += 2;
83  charSize.y += 2;
84 #endif
85 
86  if( !m_initialized )
87  {
88  std::vector<wxStaticText*> labels;
89 
90  // Print row labels
91  for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
92  {
93  int y = pos.y + (ii * bmapSize.y);
94  text = new wxStaticText( m_matrixPanel, -1, CommentERC_H[ii],
95  wxPoint( 5, y + ( bmapSize.y / 2 ) - ( 12 / 2 ) ) );
96  labels.push_back( text );
97 
98  int x = text->GetRect().GetRight();
99  pos.x = std::max( pos.x, x );
100  }
101 
102  // Right-align
103  for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
104  {
105  wxPoint labelPos = labels[ ii ]->GetPosition();
106  labelPos.x = pos.x - labels[ ii ]->GetRect().GetWidth();
107  labels[ ii ]->SetPosition( labelPos );
108  }
109 
110  pos.x += 5;
111  }
112  else
113  {
114  pos = m_buttonList[0][0]->GetPosition();
115  }
116 
117  for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
118  {
119  int y = pos.y + (ii * bmapSize.y);
120 
121  for( int jj = 0; jj <= ii; jj++ )
122  {
123  // Add column labels (only once)
124  PIN_ERROR diag = m_schematic->ErcSettings().GetPinMapValue( ii, jj );
125 
126  int x = pos.x + ( jj * ( bmapSize.x + 2 ) );
127 
128  if( ( ii == jj ) && !m_initialized )
129  {
130  wxPoint textPos( x + KiROUND( bmapSize.x / 2 ) - KiROUND( charSize.x ),
131  y - charSize.y * 2 );
132  new wxStaticText( m_matrixPanel, wxID_ANY, CommentERC_V[ii], textPos );
133 
134  wxPoint calloutPos( x + KiROUND( bmapSize.x / 2 ) - KiROUND( charSize.x / 2 ),
135  y - charSize.y );
136  new wxStaticText( m_matrixPanel, wxID_ANY, "|", calloutPos );
137  }
138 
139  int event_id = ID_MATRIX_0 + ii + ( jj * ELECTRICAL_PINTYPES_TOTAL );
140  BITMAPS bitmap_butt = BITMAPS::erc_green;
141 
142  delete m_buttonList[ii][jj];
143  wxBitmapButton* btn = new wxBitmapButton( m_matrixPanel, event_id,
144  KiBitmap( bitmap_butt ), wxPoint( x, y ) );
145 
146 #ifdef __WXMAC__
147  btn->SetSize( btn->GetSize().x - 1, btn->GetSize().y );
148 #else
149  btn->SetSize( btn->GetSize().x + 4, btn->GetSize().y );
150 #endif
151  m_buttonList[ii][jj] = btn;
152  setDRCMatrixButtonState( m_buttonList[ii][jj], diag );
153  }
154  }
155 
156  m_initialized = true;
157 }
void setDRCMatrixButtonState(wxBitmapButton *aButton, PIN_ERROR aState)
const wxString CommentERC_H[]
Definition: erc.cpp:57
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
Definition: erc_settings.h:85
#define ID_MATRIX_0
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
wxBitmapButton * m_buttonList[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: ui_common.cpp:67
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
Definition: erc_settings.h:134
const wxString CommentERC_V[]
Definition: erc.cpp:74
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:174
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:53

References CommentERC_H, CommentERC_V, dummy(), ELECTRICAL_PINTYPES_TOTAL, erc_green, ercerr, SCHEMATIC::ErcSettings(), ERC_SETTINGS::GetPinMapValue(), KIUI::GetTextSize(), ID_MATRIX_0, KiBitmap(), KiROUND(), m_buttonList, m_initialized, PANEL_SETUP_PINMAP_BASE::m_matrixPanel, m_schematic, setDRCMatrixButtonState(), and text.

Referenced by ResetPanel().

◆ ResetPanel()

void PANEL_SETUP_PINMAP::ResetPanel ( )
overridevirtual

Reset the contents of this panel.

Implements RESETTABLE_PANEL.

Definition at line 63 of file panel_setup_pinmap.cpp.

64 {
67 }
void ResetPinMap()
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:174

References SCHEMATIC::ErcSettings(), m_schematic, reBuildMatrixPanel(), and ERC_SETTINGS::ResetPinMap().

◆ setDRCMatrixButtonState()

void PANEL_SETUP_PINMAP::setDRCMatrixButtonState ( wxBitmapButton *  aButton,
PIN_ERROR  aState 
)
private

Definition at line 160 of file panel_setup_pinmap.cpp.

161 {
162  BITMAPS bitmap_butt = BITMAPS::INVALID_BITMAP;
163  wxString tooltip;
164 
165  switch( aState )
166  {
167  case PIN_ERROR::OK:
168  bitmap_butt = BITMAPS::erc_green;
169  tooltip = _( "No error or warning" );
170  break;
171 
172  case PIN_ERROR::WARNING:
173  bitmap_butt = BITMAPS::ercwarn;
174  tooltip = _( "Generate warning" );
175  break;
176 
177  case PIN_ERROR::PP_ERROR:
178  bitmap_butt = BITMAPS::ercerr;
179  tooltip = _( "Generate error" );
180  break;
181 
182  default:
183  break;
184  }
185 
186  if( !!bitmap_butt )
187  {
188  aButton->SetBitmap( KiBitmap( bitmap_butt ) );
189  aButton->SetToolTip( tooltip );
190  }
191 }
#define _(s)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32

References _, erc_green, ercerr, ercwarn, INVALID_BITMAP, KiBitmap(), OK, PP_ERROR, and WARNING.

Referenced by changeErrorLevel(), ImportSettingsFrom(), and reBuildMatrixPanel().

Member Data Documentation

◆ m_buttonList

wxBitmapButton* PANEL_SETUP_PINMAP::m_buttonList[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
private

Definition at line 57 of file panel_setup_pinmap.h.

Referenced by ImportSettingsFrom(), and reBuildMatrixPanel().

◆ m_initialized

bool PANEL_SETUP_PINMAP::m_initialized
private

Definition at line 58 of file panel_setup_pinmap.h.

Referenced by reBuildMatrixPanel().

◆ m_matrixPanel

wxPanel* PANEL_SETUP_PINMAP_BASE::m_matrixPanel
protectedinherited

◆ m_parent

SCH_EDIT_FRAME* PANEL_SETUP_PINMAP::m_parent
private

Definition at line 55 of file panel_setup_pinmap.h.

◆ m_schematic

SCHEMATIC* PANEL_SETUP_PINMAP::m_schematic
private

Definition at line 56 of file panel_setup_pinmap.h.

Referenced by changeErrorLevel(), reBuildMatrixPanel(), and ResetPanel().


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