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)
 
 ~PANEL_SETUP_PINMAP ()
 
void ImportSettingsFrom (PIN_ERROR aPinMap[][ELECTRICAL_PINTYPES_TOTAL])
 
void ResetPanel () override
 Reset the contents of this panel. More...
 
void OnMouseEnter (wxMouseEvent &aEvent)
 
void OnMouseLeave (wxMouseEvent &aEvent)
 
virtual wxString GetResetTooltip () const
 Get the tooltip the reset button should display when showing this panel. More...
 
wxString GetHelpTextAtPoint (const wxPoint &aPt, wxHelpEvent::Origin aOrigin) const override
 Overridden to supply the reset button tooltip when queried with { -INT_MAX, INT_MAX }. More...
 

Protected Attributes

wxPanel * m_matrixPanel
 

Private Member Functions

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

Private Attributes

SCH_EDIT_FRAMEm_parent
 
SCHEMATICm_schematic
 
wxColour m_btnBackground
 
wxWindow * m_buttonList [ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
 
bool m_initialized
 

Detailed Description

Definition at line 40 of file panel_setup_pinmap.h.

Constructor & Destructor Documentation

◆ PANEL_SETUP_PINMAP()

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

◆ ~PANEL_SETUP_PINMAP()

PANEL_SETUP_PINMAP::~PANEL_SETUP_PINMAP ( )

Definition at line 64 of file panel_setup_pinmap.cpp.

65{
66#ifndef __WXMAC__
67 if( m_initialized )
68 {
69 for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
70 {
71 for( int jj = 0; jj <= ii; jj++ )
72 {
73 m_buttonList[ii][jj]->Unbind( wxEVT_ENTER_WINDOW,
75 m_buttonList[ii][jj]->Unbind( wxEVT_LEAVE_WINDOW,
77 }
78 }
79 }
80#endif
81}
wxWindow * m_buttonList[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
void OnMouseLeave(wxMouseEvent &aEvent)
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:53

References ELECTRICAL_PINTYPES_TOTAL, m_buttonList, m_initialized, and OnMouseLeave().

Member Function Documentation

◆ changeErrorLevel()

void PANEL_SETUP_PINMAP::changeErrorLevel ( wxCommandEvent &  event)
private

Definition at line 249 of file panel_setup_pinmap.cpp.

250{
251 int id = event.GetId();
252 int ii = id - ID_MATRIX_0;
253 int x = ii / ELECTRICAL_PINTYPES_TOTAL;
254 int y = ii % ELECTRICAL_PINTYPES_TOTAL;
255 wxWindow* butt = static_cast<wxWindow*>( event.GetEventObject() );
256
257 int level = static_cast<int>( m_schematic->ErcSettings().GetPinMapValue( y, x ) );
258 level = ( level + 1 ) % 3;
259
260 setDRCMatrixButtonState( butt, static_cast<PIN_ERROR>( level ) );
261
262 m_schematic->ErcSettings().SetPinMapValue( y, x, static_cast<PIN_ERROR>( level ) );
263 m_schematic->ErcSettings().SetPinMapValue( x, y, static_cast<PIN_ERROR>( level ) );
264}
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
Definition: erc_settings.h:141
void SetPinMapValue(int aFirstType, int aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:153
void setDRCMatrixButtonState(wxWindow *aButton, PIN_ERROR aState)
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:212
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
Definition: erc_settings.h:93
#define ID_MATRIX_0

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

◆ GetHelpTextAtPoint()

wxString RESETTABLE_PANEL::GetHelpTextAtPoint ( const wxPoint &  aPt,
wxHelpEvent::Origin  aOrigin 
) const
inlineoverrideinherited

Overridden to supply the reset button tooltip when queried with { -INT_MAX, INT_MAX }.

Definition at line 72 of file resettable_panel.h.

73 {
74 if( aPt == wxPoint( -INT_MAX, INT_MAX ) )
75 return GetResetTooltip();
76 else
77 return wxPanel::GetHelpTextAtPoint( aPt, aOrigin );
78 }
virtual wxString GetResetTooltip() const
Get the tooltip the reset button should display when showing this panel.

References RESETTABLE_PANEL::GetResetTooltip().

◆ GetResetTooltip()

virtual wxString RESETTABLE_PANEL::GetResetTooltip ( ) const
inlinevirtualinherited

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

Returns
the tooltip

Reimplemented in PANEL_COLOR_SETTINGS, and PANEL_HOTKEYS_EDITOR.

Definition at line 64 of file resettable_panel.h.

65 {
66 return _( "Reset all settings on this page to their default" );
67 }
#define _(s)

References _.

Referenced by RESETTABLE_PANEL::GetHelpTextAtPoint().

◆ ImportSettingsFrom()

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

Definition at line 267 of file panel_setup_pinmap.cpp.

268{
269 for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
270 {
271 for( int jj = 0; jj <= ii; jj++ )
272 setDRCMatrixButtonState( m_buttonList[ii][jj], aPinMap[ii][jj] );
273 }
274}

References ELECTRICAL_PINTYPES_TOTAL, m_buttonList, and setDRCMatrixButtonState().

Referenced by DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction().

◆ OnMouseEnter()

void PANEL_SETUP_PINMAP::OnMouseEnter ( wxMouseEvent &  aEvent)

Definition at line 91 of file panel_setup_pinmap.cpp.

92{
93 wxBitmapButton* btn = static_cast<wxBitmapButton*>( aEvent.GetEventObject() );
94 m_btnBackground = btn->GetBackgroundColour();
95
96 btn->SetBackgroundColour( wxSystemSettings::GetColour( wxSystemColour::wxSYS_COLOUR_HIGHLIGHT ) );
97}

References m_btnBackground.

Referenced by reBuildMatrixPanel().

◆ OnMouseLeave()

void PANEL_SETUP_PINMAP::OnMouseLeave ( wxMouseEvent &  aEvent)

Definition at line 100 of file panel_setup_pinmap.cpp.

101{
102 wxBitmapButton* btn = static_cast<wxBitmapButton*>( aEvent.GetEventObject() );
103 btn->SetBackgroundColour( m_btnBackground );
104}

References m_btnBackground.

Referenced by reBuildMatrixPanel(), and ~PANEL_SETUP_PINMAP().

◆ reBuildMatrixPanel()

void PANEL_SETUP_PINMAP::reBuildMatrixPanel ( )
private

Definition at line 107 of file panel_setup_pinmap.cpp.

108{
109 // Try to know the size of bitmap button used in drc matrix
110 wxBitmapButton* dummy = new wxBitmapButton( m_matrixPanel, wxID_ANY, KiBitmap( BITMAPS::ercerr ),
111 wxDefaultPosition, wxDefaultSize, wxBORDER_NONE );
112 wxSize bitmapSize = dummy->GetSize();
113 delete dummy;
114
115#ifdef __WXMAC__
116 const wxSize text_padding( 2, 1 );
117 const int twiddle = -1;
118#else
119 const wxSize text_padding( 8, 6 );
120 const int twiddle = 1;
121#endif
122
123 wxSize charSize = KIUI::GetTextSize( wxS( "X" ), m_matrixPanel );
124 wxPoint pos( 0, charSize.y * 2 );
125 wxStaticText* text;
126
127 if( !m_initialized )
128 {
129 std::vector<wxStaticText*> labels;
130
131 // Print row labels
132 for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
133 {
134 int y = pos.y + ( ii * ( bitmapSize.y + text_padding.y ) );
135 text = new wxStaticText( m_matrixPanel, - 1, CommentERC_H[ii],
136 wxPoint( 5, y + ( bitmapSize.y / 2 ) - ( 12 / 2 ) ) );
137 labels.push_back( text );
138
139 int x = text->GetRect().GetRight();
140 pos.x = std::max( pos.x, x );
141 }
142
143 // Right-align
144 for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
145 {
146 wxPoint labelPos = labels[ ii ]->GetPosition();
147 labelPos.x = pos.x - labels[ ii ]->GetRect().GetWidth();
148 labelPos.y += twiddle;
149 labels[ ii ]->SetPosition( labelPos );
150 }
151
152 pos.x += 5;
153 }
154 else
155 {
156 pos = m_buttonList[0][0]->GetPosition();
157 }
158
159 for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
160 {
161 int y = pos.y + (ii * ( bitmapSize.y + text_padding.y ) );
162
163 for( int jj = 0; jj <= ii; jj++ )
164 {
165 // Add column labels (only once)
167
168 int x = pos.x + ( jj * ( bitmapSize.x + text_padding.x ) );
169
170 if( ( ii == jj ) && !m_initialized )
171 {
172 wxPoint textPos( x + KiROUND( bitmapSize.x / 2 ),
173 y - charSize.y * 2 );
174 new wxStaticText( m_matrixPanel, wxID_ANY, CommentERC_V[ii], textPos );
175
176 wxPoint calloutPos( x + KiROUND( bitmapSize.x / 2 ),
177 y - charSize.y );
178 new wxStaticText( m_matrixPanel, wxID_ANY, "|", calloutPos );
179 }
180
181 int id = ID_MATRIX_0 + ii + ( jj * ELECTRICAL_PINTYPES_TOTAL );
182 BITMAPS bitmap_butt = BITMAPS::erc_green;
183
184#ifdef __WXMAC__
185 BITMAP_BUTTON* btn = new BITMAP_BUTTON( m_matrixPanel, id, KiBitmap( bitmap_butt ),
186 wxPoint( x, y ), bitmapSize );
187#else
188 if( m_initialized )
189 {
190 m_buttonList[ii][jj]->Unbind(wxEVT_ENTER_WINDOW, &PANEL_SETUP_PINMAP::OnMouseLeave, this );
191 m_buttonList[ii][jj]->Unbind(wxEVT_LEAVE_WINDOW, &PANEL_SETUP_PINMAP::OnMouseLeave, this );
192 }
193
194 wxBitmapButton* btn = new wxBitmapButton( m_matrixPanel, id, KiBitmap( bitmap_butt ),
195 wxPoint( x, y ), wxDefaultSize, wxBORDER_NONE );
196 btn->Bind( wxEVT_LEAVE_WINDOW, &PANEL_SETUP_PINMAP::OnMouseLeave, this );
197 btn->Bind( wxEVT_ENTER_WINDOW, &PANEL_SETUP_PINMAP::OnMouseEnter, this );
198#endif
199 btn->SetSize( btn->GetSize() + text_padding );
200
201 delete m_buttonList[ii][jj];
202 m_buttonList[ii][jj] = btn;
203 setDRCMatrixButtonState( m_buttonList[ii][jj], diag );
204 }
205 }
206
207 m_initialized = true;
208}
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:106
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
Definition: bitmap_button.h:41
void OnMouseEnter(wxMouseEvent &aEvent)
const wxString CommentERC_V[]
Definition: erc.cpp:81
const wxString CommentERC_H[]
Definition: erc.cpp:64
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:70
std::vector< FAB_LAYER_COLOR > dummy
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:85

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, OnMouseEnter(), OnMouseLeave(), 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 84 of file panel_setup_pinmap.cpp.

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

◆ setDRCMatrixButtonState()

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

Definition at line 211 of file panel_setup_pinmap.cpp.

212{
213 BITMAPS bitmap_butt = BITMAPS::INVALID_BITMAP;
214 wxString tooltip;
215
216 switch( aState )
217 {
218 case PIN_ERROR::OK:
219 bitmap_butt = BITMAPS::erc_green;
220 tooltip = _( "No error or warning" );
221 break;
222
224 bitmap_butt = BITMAPS::ercwarn;
225 tooltip = _( "Generate warning" );
226 break;
227
229 bitmap_butt = BITMAPS::ercerr;
230 tooltip = _( "Generate error" );
231 break;
232
233 default:
234 break;
235 }
236
237 if( !!bitmap_butt )
238 {
239 if( wxBitmapButton* wx_btn = dynamic_cast<wxBitmapButton*>( aButton ) )
240 wx_btn->SetBitmap( KiBitmap( bitmap_butt ) );
241 else if( BITMAP_BUTTON* ki_btn = dynamic_cast<BITMAP_BUTTON*>( aButton ) )
242 ki_btn->SetBitmap( KiBitmap( bitmap_butt ) );
243
244 aButton->SetToolTip( tooltip );
245 }
246}
@ INVALID_BITMAP

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

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

Member Data Documentation

◆ m_btnBackground

wxColour PANEL_SETUP_PINMAP::m_btnBackground
private

Definition at line 61 of file panel_setup_pinmap.h.

Referenced by OnMouseEnter(), and OnMouseLeave().

◆ m_buttonList

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

◆ m_initialized

bool PANEL_SETUP_PINMAP::m_initialized
private

Definition at line 63 of file panel_setup_pinmap.h.

Referenced by reBuildMatrixPanel(), and ~PANEL_SETUP_PINMAP().

◆ m_matrixPanel

wxPanel* PANEL_SETUP_PINMAP_BASE::m_matrixPanel
protectedinherited

◆ m_parent

SCH_EDIT_FRAME* PANEL_SETUP_PINMAP::m_parent
private

Definition at line 59 of file panel_setup_pinmap.h.

◆ m_schematic

SCHEMATIC* PANEL_SETUP_PINMAP::m_schematic
private

Definition at line 60 of file panel_setup_pinmap.h.

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


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