KiCad PCB EDA Suite
PANEL_SETUP_PINMAP Class Reference

#include <panel_setup_pinmap.h>

Inheritance diagram for PANEL_SETUP_PINMAP:
PANEL_SETUP_PINMAP_BASE

Public Member Functions

 PANEL_SETUP_PINMAP (wxWindow *aWindow, SCH_EDIT_FRAME *aParent)
 
bool Show (bool show) override
 
void ImportSettingsFrom (PIN_ERROR aPinMap[][ELECTRICAL_PINTYPES_TOTAL])
 

Protected Types

enum  { ID_RESET_MATRIX = 1000 }
 

Protected Attributes

wxPanel * m_matrixPanel
 
wxButton * m_ResetOptButton
 

Private Member Functions

void OnResetMatrixClick (wxCommandEvent &aEvent) override
 
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 38 of file panel_setup_pinmap.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protectedinherited
Enumerator
ID_RESET_MATRIX 

Definition at line 36 of file panel_setup_pinmap_base.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 214 of file panel_setup_pinmap.cpp.

215 {
216  int id = event.GetId();
217  int ii = id - ID_MATRIX_0;
218  int x = ii / ELECTRICAL_PINTYPES_TOTAL;
219  int y = ii % ELECTRICAL_PINTYPES_TOTAL;
220  wxBitmapButton* butt = (wxBitmapButton*) event.GetEventObject();
221 
222  int level = static_cast<int>( m_schematic->ErcSettings().GetPinMapValue( y, x ) );
223  level = ( level + 1 ) % 3;
224 
225  setDRCMatrixButtonState( butt, static_cast<PIN_ERROR>( level ) );
226 
227  m_schematic->ErcSettings().SetPinMapValue( y, x, static_cast<PIN_ERROR>( level ) );
228  m_schematic->ErcSettings().SetPinMapValue( x, y, static_cast<PIN_ERROR>( level ) );
229 }
void setDRCMatrixButtonState(wxBitmapButton *aButton, PIN_ERROR aState)
#define ID_MATRIX_0
void SetPinMapValue(int aFirstType, int aSecondType, PIN_ERROR aValue)
Definition: erc_settings.h:137
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
Definition: erc_settings.h:125
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:145
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:54

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

◆ ImportSettingsFrom()

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

Definition at line 232 of file panel_setup_pinmap.cpp.

233 {
234  for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
235  {
236  for( int jj = 0; jj <= ii; jj++ )
237  setDRCMatrixButtonState( m_buttonList[ii][jj], aPinMap[ii][jj] );
238  }
239 }
void setDRCMatrixButtonState(wxBitmapButton *aButton, PIN_ERROR aState)
wxBitmapButton * m_buttonList[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:54

References ELECTRICAL_PINTYPES_TOTAL, m_buttonList, and setDRCMatrixButtonState().

Referenced by DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction().

◆ OnResetMatrixClick()

void PANEL_SETUP_PINMAP::OnResetMatrixClick ( wxCommandEvent &  aEvent)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_PINMAP_BASE.

Definition at line 69 of file panel_setup_pinmap.cpp.

70 {
73 }
void ResetPinMap()
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:145

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

◆ reBuildMatrixPanel()

void PANEL_SETUP_PINMAP::reBuildMatrixPanel ( )
private

Definition at line 76 of file panel_setup_pinmap.cpp.

77 {
78  // Try to know the size of bitmap button used in drc matrix
79  wxBitmapButton* dummy = new wxBitmapButton( m_matrixPanel, wxID_ANY, KiBitmap( ercerr_xpm ) );
80  wxSize bmapSize = dummy->GetSize();
81  delete dummy;
82 
83  wxPoint pos;
84  // Get the text size for the angled text
87 
88  bmapSize.y = std::max( bmapSize.y, txtSize.y );
89 
90  // compute the Y pos interval:
91  pos.y = bbox.GetHeight();
92 
93  wxStaticText* text;
94 
95  if( !m_initialized )
96  {
97  std::vector<wxStaticText*> labels;
98 
99  // Print row labels
100  for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
101  {
102  int y = pos.y + (ii * bmapSize.y);
103  text = new wxStaticText( m_matrixPanel, -1, CommentERC_H[ii],
104  wxPoint( 5, y + ( bmapSize.y / 2 ) - ( txtSize.y / 2 ) ) );
105  labels.push_back( text );
106 
107  int x = text->GetRect().GetRight();
108  pos.x = std::max( pos.x, x );
109  }
110 
111  // Right-align
112  for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
113  {
114  wxPoint labelPos = labels[ ii ]->GetPosition();
115  labelPos.x = pos.x - labels[ ii ]->GetRect().GetWidth();
116  labels[ ii ]->SetPosition( labelPos );
117  }
118 
119  pos.x += 5;
120  }
121  else
122  pos = m_buttonList[0][0]->GetPosition();
123 
124  for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
125  {
126  int y = pos.y + (ii * bmapSize.y);
127 
128  for( int jj = 0; jj <= ii; jj++ )
129  {
130  // Add column labels (only once)
131  PIN_ERROR diag = m_schematic->ErcSettings().GetPinMapValue( ii, jj );
132 
133  int x = pos.x + ( jj * ( bmapSize.x + 4 ) );
134 
135  if( ( ii == jj ) && !m_initialized )
136  {
137  wxPoint txtpos;
138  txtpos.x = x + ( bmapSize.x / 2 );
139  txtpos.y = y - txtSize.y;
140  new WX_ANGLE_TEXT( m_matrixPanel, wxID_ANY, CommentERC_V[ii], txtpos, 450 );
141  }
142 
143  int event_id = ID_MATRIX_0 + ii + ( jj * ELECTRICAL_PINTYPES_TOTAL );
144  BITMAP_DEF bitmap_butt = erc_green_xpm;
145 
146  delete m_buttonList[ii][jj];
147  wxBitmapButton* btn = new wxBitmapButton( m_matrixPanel, event_id,
148  KiBitmap( bitmap_butt ), wxPoint( x, y ) );
149  btn->SetSize( btn->GetSize().x + 4, btn->GetSize().y );
150  m_buttonList[ii][jj] = btn;
151  setDRCMatrixButtonState( m_buttonList[ii][jj], diag );
152  }
153  }
154 
155  m_initialized = true;
156 }
PNG memory record (file in memory).
Definition: bitmap_def.h:29
const wxString CommentERC_V[]
void setDRCMatrixButtonState(wxBitmapButton *aButton, PIN_ERROR aState)
const wxString CommentERC_H[]
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
Definition: erc_settings.h:66
#define ID_MATRIX_0
wxBitmapButton * m_buttonList[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
const BITMAP_OPAQUE ercerr_xpm[1]
Definition: ercerr.cpp:24
const BITMAP_OPAQUE erc_green_xpm[1]
Definition: erc_green.cpp:24
static wxSize GetTextSize(wxWindow *aWindow, const wxString &aLabel)
Get the height and width of the unrotated text string that is created for this control.
int GetHeight() const
Definition: eda_rect.h:120
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
Definition: erc_settings.h:125
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:145
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:54
static EDA_RECT GetBoundingBox(wxWindow *aWindow, const wxString &aLabel, double aAngle)
Get the bounding box that this angled text will take up on a certain window.

References CommentERC_H, CommentERC_V, dummy(), ELECTRICAL_PINTYPES_TOTAL, erc_green_xpm, ercerr_xpm, SCHEMATIC::ErcSettings(), WX_ANGLE_TEXT::GetBoundingBox(), EDA_RECT::GetHeight(), ERC_SETTINGS::GetPinMapValue(), WX_ANGLE_TEXT::GetTextSize(), ID_MATRIX_0, KiBitmap(), m_buttonList, m_initialized, PANEL_SETUP_PINMAP_BASE::m_matrixPanel, m_schematic, setDRCMatrixButtonState(), wxPoint::x, and wxPoint::y.

Referenced by OnResetMatrixClick().

◆ setDRCMatrixButtonState()

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

Definition at line 180 of file panel_setup_pinmap.cpp.

181 {
182  BITMAP_DEF bitmap_butt = nullptr;
183  wxString tooltip;
184 
185  switch( aState )
186  {
187  case PIN_ERROR::OK:
188  bitmap_butt = erc_green_xpm;
189  tooltip = _( "No error or warning" );
190  break;
191 
192  case PIN_ERROR::WARNING:
193  bitmap_butt = ercwarn_xpm;
194  tooltip = _( "Generate warning" );
195  break;
196 
197  case PIN_ERROR::PP_ERROR:
198  bitmap_butt = ercerr_xpm;
199  tooltip = _( "Generate error" );
200  break;
201 
202  default:
203  break;
204  }
205 
206  if( bitmap_butt )
207  {
208  aButton->SetBitmap( KiBitmap( bitmap_butt ) );
209  aButton->SetToolTip( tooltip );
210  }
211 }
PNG memory record (file in memory).
Definition: bitmap_def.h:29
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
const BITMAP_OPAQUE ercerr_xpm[1]
Definition: ercerr.cpp:24
const BITMAP_OPAQUE erc_green_xpm[1]
Definition: erc_green.cpp:24
#define _(s)
Definition: 3d_actions.cpp:33
const BITMAP_OPAQUE ercwarn_xpm[1]
Definition: ercwarn.cpp:68

References _, erc_green_xpm, ercerr_xpm, ercwarn_xpm, KiBitmap(), OK, PP_ERROR, and WARNING.

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

◆ Show()

bool PANEL_SETUP_PINMAP::Show ( bool  show)
override

Definition at line 159 of file panel_setup_pinmap.cpp.

160 {
161  wxPanel::Show( show );
162 
163  // For some reason the angle text doesn't get drawn if the paint events are fired while
164  // it's not the active tab.
165  if( show )
166  {
167  for( wxWindow* win : m_matrixPanel->GetChildren() )
168  {
169  WX_ANGLE_TEXT* angleText = dynamic_cast<WX_ANGLE_TEXT*>( win );
170 
171  if( angleText )
172  angleText->Refresh();
173  }
174  }
175 
176  return true;
177 }

References PANEL_SETUP_PINMAP_BASE::m_matrixPanel.

Member Data Documentation

◆ m_buttonList

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

Definition at line 45 of file panel_setup_pinmap.h.

Referenced by ImportSettingsFrom(), and reBuildMatrixPanel().

◆ m_initialized

bool PANEL_SETUP_PINMAP::m_initialized
private

Definition at line 46 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 43 of file panel_setup_pinmap.h.

◆ m_ResetOptButton

wxButton* PANEL_SETUP_PINMAP_BASE::m_ResetOptButton
protectedinherited

◆ m_schematic

SCHEMATIC* PANEL_SETUP_PINMAP::m_schematic
private

Definition at line 44 of file panel_setup_pinmap.h.

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


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