KiCad PCB EDA Suite
PANEL_SETUP_NETCLASSES Class Reference

#include <panel_setup_netclasses.h>

Inheritance diagram for PANEL_SETUP_NETCLASSES:
PANEL_SETUP_NETCLASSES_BASE

Public Member Functions

 PANEL_SETUP_NETCLASSES (PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame, PANEL_SETUP_FEATURE_CONSTRAINTS *aConstraintsPanel)
 
 ~PANEL_SETUP_NETCLASSES () override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
void ImportSettingsFrom (BOARD *aBoard)
 

Protected Attributes

WX_GRIDm_netclassGrid
 
wxBitmapButton * m_addButton
 
wxBitmapButton * m_removeButton
 
wxStaticText * m_ncfilterLabel
 
wxChoice * m_netClassFilter
 
wxStaticText * m_filterLabel
 
wxTextCtrl * m_netNameFilter
 
wxButton * m_showAllButton
 
wxButton * m_filterNetsButton
 
wxStaticText * m_assignLabel
 
wxChoice * m_assignNetClass
 
wxButton * m_assignAllButton
 
wxButton * m_assignSelectedButton
 
WX_GRIDm_membershipGrid
 

Private Member Functions

void OnAddNetclassClick (wxCommandEvent &event) override
 
void OnRemoveNetclassClick (wxCommandEvent &event) override
 
void OnSizeNetclassGrid (wxSizeEvent &event) override
 
void OnSizeMembershipGrid (wxSizeEvent &event) override
 
void OnUpdateUI (wxUpdateUIEvent &event) override
 
void OnNetclassGridCellChanging (wxGridEvent &event)
 
void OnShowAll (wxCommandEvent &event) override
 
void OnApplyFilters (wxCommandEvent &event) override
 
void OnAssignAll (wxCommandEvent &event) override
 
void OnAssignSelected (wxCommandEvent &event) override
 
bool validateNetclassName (int aRow, wxString aName, bool focusFirst=true)
 
bool validateData ()
 
void rebuildNetclassDropdowns ()
 
int getNetclassValue (int aRow, int aCol)
 
void addNet (wxString netName, const wxString &netclass)
 
void doApplyFilters (bool aShowAll)
 
void doAssignments (bool aAssignAll)
 
void AdjustNetclassGridColumns (int aWidth)
 
void AdjustMembershipGridColumns (int aWidth)
 

Private Attributes

PAGED_DIALOGm_Parent
 
PCB_EDIT_FRAMEm_Frame
 
BOARDm_Pcb
 
BOARD_DESIGN_SETTINGSm_BrdSettings
 
PANEL_SETUP_FEATURE_CONSTRAINTSm_ConstraintsPanel
 
int * m_originalColWidths
 
bool m_netclassesDirty
 

Detailed Description

Definition at line 39 of file panel_setup_netclasses.h.

Constructor & Destructor Documentation

PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES ( PAGED_DIALOG aParent,
PCB_EDIT_FRAME aFrame,
PANEL_SETUP_FEATURE_CONSTRAINTS aConstraintsPanel 
)

Definition at line 54 of file panel_setup_netclasses.cpp.

References PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), i, KiBitmap(), PANEL_SETUP_NETCLASSES_BASE::m_addButton, m_BrdSettings, m_ConstraintsPanel, m_Frame, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, m_netclassesDirty, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_originalColWidths, m_Parent, m_Pcb, PANEL_SETUP_NETCLASSES_BASE::m_removeButton, and OnNetclassGridCellChanging().

Referenced by OnAssignSelected().

55  :
57 {
58  m_Parent = aParent;
59  m_Frame = aFrame;
60  m_Pcb = m_Frame->GetBoard();
62  m_ConstraintsPanel = aConstraintsPanel;
63 
64  m_netclassesDirty = true;
65 
66  m_originalColWidths = new int[ m_netclassGrid->GetNumberCols() ];
67 
68  for( int i = 0; i < m_netclassGrid->GetNumberCols(); ++i )
69  m_originalColWidths[ i ] = m_netclassGrid->GetColSize( i );
70 
71  // Membership combobox editors require a bit more room, so increase the row size of
72  // all our grids for consistency
73  m_netclassGrid->SetDefaultRowSize( m_netclassGrid->GetDefaultRowSize() + 4 );
74  m_membershipGrid->SetDefaultRowSize( m_membershipGrid->GetDefaultRowSize() + 4 );
75 
76  m_netclassGrid->PushEventHandler( new GRID_TRICKS( m_netclassGrid ) );
77  m_membershipGrid->PushEventHandler( new GRID_TRICKS( m_membershipGrid ) );
78 
79  m_netclassGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
80  m_membershipGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
81 
82  // Set up the net name column of the netclass membership grid to read-only
83  wxGridCellAttr* attr = new wxGridCellAttr;
84  attr->SetReadOnly( true );
85  m_membershipGrid->SetColAttr( 0, attr );
86 
87  m_addButton->SetBitmap( KiBitmap( small_plus_xpm ) );
88  m_removeButton->SetBitmap( KiBitmap( trash_xpm ) );
89 
90  // wxFormBuilder doesn't include this event...
91  m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), NULL, this );
92 }
Class GRID_TRICKS is used to add cut, copy, and paste to an otherwise unmodied wxGrid instance...
Definition: grid_tricks.h:51
BOARD * GetBoard() const
wxTreebook * GetTreebook()
Definition: paged_dialog.h:43
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
void OnNetclassGridCellChanging(wxGridEvent &event)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:539
BOARD_DESIGN_SETTINGS * m_BrdSettings
PANEL_SETUP_FEATURE_CONSTRAINTS * m_ConstraintsPanel
size_t i
Definition: json11.cpp:597
PANEL_SETUP_NETCLASSES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL)
PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES ( )
override

Definition at line 95 of file panel_setup_netclasses.cpp.

References PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_originalColWidths, and OnNetclassGridCellChanging().

Referenced by OnAssignSelected().

96 {
97  delete [] m_originalColWidths;
98 
99  // Delete the GRID_TRICKS.
100  m_netclassGrid->PopEventHandler( true );
101  m_membershipGrid->PopEventHandler( true );
102 
103  m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), NULL, this );
104 }
void OnNetclassGridCellChanging(wxGridEvent &event)

Member Function Documentation

void PANEL_SETUP_NETCLASSES::addNet ( wxString  netName,
const wxString &  netclass 
)
private

Definition at line 165 of file panel_setup_netclasses.cpp.

References i, and PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid.

Referenced by OnAssignSelected(), and TransferDataToWindow().

166 {
167  int i = m_membershipGrid->GetNumberRows();
168 
169  m_membershipGrid->AppendRows( 1 );
170 
171  m_membershipGrid->SetCellValue( i, 0, netName );
172  m_membershipGrid->SetCellValue( i, 1, netclass );
173 }
size_t i
Definition: json11.cpp:597
void PANEL_SETUP_NETCLASSES::AdjustMembershipGridColumns ( int  aWidth)
private

Definition at line 375 of file panel_setup_netclasses.cpp.

References PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, m_originalColWidths, and max.

Referenced by OnAssignSelected(), and OnSizeMembershipGrid().

376 {
377  // Account for scroll bars
378  aWidth -= ( m_membershipGrid->GetSize().x - m_membershipGrid->GetClientSize().x );
379 
380  // Set className column width to original className width from netclasses grid
381  int classNameWidth = m_originalColWidths[ 0 ];
382  m_membershipGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
383  m_membershipGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
384 }
#define max(a, b)
Definition: auxiliary.h:86
void PANEL_SETUP_NETCLASSES::AdjustNetclassGridColumns ( int  aWidth)
private

Definition at line 352 of file panel_setup_netclasses.cpp.

References i, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_originalColWidths, and max.

Referenced by OnAssignSelected(), and OnSizeNetclassGrid().

353 {
354  // Account for scroll bars
355  aWidth -= ( m_netclassGrid->GetSize().x - m_netclassGrid->GetClientSize().x );
356 
357  for( int i = 1; i < m_netclassGrid->GetNumberCols(); i++ )
358  {
359  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
360  aWidth -= m_originalColWidths[ i ];
361  }
362 
363  m_netclassGrid->SetColSize( 0, std::max( aWidth, m_originalColWidths[ 0 ] ) );
364 }
#define max(a, b)
Definition: auxiliary.h:86
size_t i
Definition: json11.cpp:597
void PANEL_SETUP_NETCLASSES::doApplyFilters ( bool  aShowAll)
private

Definition at line 395 of file panel_setup_netclasses.cpp.

References WX_GRID::CommitPendingChanges(), PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, PANEL_SETUP_NETCLASSES_BASE::m_netClassFilter, and PANEL_SETUP_NETCLASSES_BASE::m_netNameFilter.

Referenced by OnApplyFilters(), OnAssignSelected(), and OnShowAll().

396 {
398  return;
399 
400  wxString netClassFilter = m_netClassFilter->GetStringSelection();
401  wxString netFilter = m_netNameFilter->GetValue().MakeLower();
402 
403  if( !netFilter.IsEmpty() )
404  netFilter = wxT( "*" ) + netFilter + wxT( "*" );
405 
406  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
407  {
408  wxString net = m_membershipGrid->GetCellValue( row, 0 );
409  wxString netClass = m_membershipGrid->GetCellValue( row, 1 );
410  bool show = true;
411 
412  if( !aShowAll )
413  {
414  if( !netFilter.IsEmpty() && !net.MakeLower().Matches( netFilter ) )
415  show = false;
416 
417  if( !netClassFilter.IsEmpty() && netClass != netClassFilter )
418  show = false;
419  }
420 
421  if( show )
422  m_membershipGrid->ShowRow( row );
423  else
424  m_membershipGrid->HideRow( row );
425  }
426 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:156
void PANEL_SETUP_NETCLASSES::doAssignments ( bool  aAssignAll)
private

Definition at line 429 of file panel_setup_netclasses.cpp.

References WX_GRID::CommitPendingChanges(), PANEL_SETUP_NETCLASSES_BASE::m_assignNetClass, and PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid.

Referenced by OnAssignAll(), and OnAssignSelected().

430 {
432  return;
433 
434  wxArrayInt selectedRows = m_membershipGrid->GetSelectedRows();
435 
436  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
437  {
438  if( !m_membershipGrid->IsRowShown( row ) )
439  continue;
440 
441  if( !aAssignAll && selectedRows.Index( row ) == wxNOT_FOUND )
442  continue;
443 
444  m_membershipGrid->SetCellValue( row, 1, m_assignNetClass->GetStringSelection() );
445  }
446 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:156
int PANEL_SETUP_NETCLASSES::getNetclassValue ( int  aRow,
int  aCol 
)
private

Definition at line 459 of file panel_setup_netclasses.cpp.

References EDA_DRAW_FRAME::GetUserUnits(), m_Frame, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, and ValueFromString().

Referenced by OnAssignSelected(), and validateData().

460 {
461  return ValueFromString( m_Frame->GetUserUnits(), m_netclassGrid->GetCellValue( aRow, aCol ), true );
462 }
int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application...
Definition: base_units.cpp:409
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:281
void PANEL_SETUP_NETCLASSES::ImportSettingsFrom ( BOARD aBoard)

Definition at line 556 of file panel_setup_netclasses.cpp.

References BOARD::GetDesignSettings(), m_BrdSettings, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, and TransferDataToWindow().

Referenced by OnAssignSelected(), and DIALOG_BOARD_SETUP::OnAuxiliaryAction().

557 {
558  // Note: do not change the board, as we need to get the current nets from it for
559  // netclass memberships. All the netclass definitions and dimension lists are in
560  // the BOARD_DESIGN_SETTINGS.
561 
562  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
563 
564  m_BrdSettings = &aBoard->GetDesignSettings();
566 
567  m_netclassGrid->ForceRefresh();
568  m_membershipGrid->ForceRefresh();
569 
570  m_BrdSettings = savedSettings;
571 }
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:539
BOARD_DESIGN_SETTINGS * m_BrdSettings
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
void PANEL_SETUP_NETCLASSES::OnAddNetclassClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 297 of file panel_setup_netclasses.cpp.

References WX_GRID::CommitPendingChanges(), m_netclassesDirty, and PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid.

298 {
300  return;
301 
302  int row = m_netclassGrid->GetNumberRows();
303  m_netclassGrid->AppendRows();
304 
305  // Copy values of the default class:
306  for( int col = 1; col < m_netclassGrid->GetNumberCols(); col++ )
307  m_netclassGrid->SetCellValue( row, col, m_netclassGrid->GetCellValue( 0, col ) );
308 
309  m_netclassGrid->MakeCellVisible( row, 0 );
310  m_netclassGrid->SetGridCursor( row, 0 );
311 
312  m_netclassGrid->EnableCellEditControl( true );
313  m_netclassGrid->ShowCellEditControl();
314 
315  m_netclassesDirty = true;
316 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:156
void PANEL_SETUP_NETCLASSES::OnApplyFilters ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 62 of file panel_setup_netclasses.h.

References doApplyFilters().

62 { doApplyFilters( false ); }
void doApplyFilters(bool aShowAll)
void PANEL_SETUP_NETCLASSES::OnAssignAll ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 63 of file panel_setup_netclasses.h.

References doAssignments().

63 { doAssignments( true ); }
void doAssignments(bool aAssignAll)
void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ( wxGridEvent &  event)
private

Definition at line 285 of file panel_setup_netclasses.cpp.

References GRID_NAME, m_netclassesDirty, and validateNetclassName().

Referenced by PANEL_SETUP_NETCLASSES(), and ~PANEL_SETUP_NETCLASSES().

286 {
287  if( event.GetCol() == GRID_NAME )
288  {
289  if( validateNetclassName( event.GetRow(), event.GetString() ) )
290  m_netclassesDirty = true;
291  else
292  event.Veto();
293  }
294 }
bool validateNetclassName(int aRow, wxString aName, bool focusFirst=true)
void PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 319 of file panel_setup_netclasses.cpp.

References WX_GRID::CommitPendingChanges(), NETCLASS::Default, DisplayErrorMessage(), GRID_NAME, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, m_netclassesDirty, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, and max.

320 {
322  return;
323 
324  int curRow = m_netclassGrid->GetGridCursorRow();
325 
326  if( curRow < 0 )
327  return;
328  else if( curRow == 0 )
329  {
330  DisplayErrorMessage( this, _( "The default net class is required." ) );
331  return;
332  }
333 
334  // reset the net class to default for members of the removed class
335  wxString classname = m_netclassGrid->GetCellValue( curRow, GRID_NAME );
336 
337  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
338  {
339  if( m_membershipGrid->GetCellValue( row, 1 ) == classname )
340  m_membershipGrid->SetCellValue( row, 1, NETCLASS::Default );
341  }
342 
343  m_netclassGrid->DeleteRows( curRow, 1 );
344 
345  m_netclassGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
346  m_netclassGrid->SetGridCursor( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
347 
348  m_netclassesDirty = true;
349 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:259
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:80
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:156
#define max(a, b)
Definition: auxiliary.h:86
void PANEL_SETUP_NETCLASSES::OnShowAll ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 61 of file panel_setup_netclasses.h.

References doApplyFilters().

61 { doApplyFilters( true ); }
void doApplyFilters(bool aShowAll)
void PANEL_SETUP_NETCLASSES::OnSizeMembershipGrid ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 387 of file panel_setup_netclasses.cpp.

References AdjustMembershipGridColumns().

388 {
389  AdjustMembershipGridColumns( event.GetSize().GetX() );
390 
391  event.Skip();
392 }
void AdjustMembershipGridColumns(int aWidth)
void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 367 of file panel_setup_netclasses.cpp.

References AdjustNetclassGridColumns().

368 {
369  AdjustNetclassGridColumns( event.GetSize().GetX() );
370 
371  event.Skip();
372 }
void AdjustNetclassGridColumns(int aWidth)
void PANEL_SETUP_NETCLASSES::OnUpdateUI ( wxUpdateUIEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 449 of file panel_setup_netclasses.cpp.

References m_netclassesDirty, and rebuildNetclassDropdowns().

450 {
451  if( m_netclassesDirty )
452  {
454  m_netclassesDirty = false;
455  }
456 }
void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns ( )
private

Definition at line 178 of file panel_setup_netclasses.cpp.

References WX_GRID::CommitPendingChanges(), GRID_NAME, PANEL_SETUP_NETCLASSES_BASE::m_assignNetClass, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, PANEL_SETUP_NETCLASSES_BASE::m_netClassFilter, and PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid.

Referenced by OnAssignSelected(), and OnUpdateUI().

179 {
181 
182  wxArrayString netclassNames;
183 
184  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
185  {
186  wxString netclassName = m_netclassGrid->GetCellValue( ii, GRID_NAME );
187  if( !netclassName.IsEmpty() )
188  netclassNames.push_back( netclassName );
189  }
190 
191  wxGridCellAttr* attr = new wxGridCellAttr;
192  attr->SetEditor( new wxGridCellChoiceEditor( netclassNames ) );
193  m_membershipGrid->SetColAttr( 1, attr );
194 
195  m_assignNetClass->Set( netclassNames );
196 
197  netclassNames.Insert( wxEmptyString, 0 );
198  m_netClassFilter->Set( netclassNames );
199 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:156
bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow ( )
override

Definition at line 221 of file panel_setup_netclasses.cpp.

References NETCLASSES::Add(), NETCLASSES::Clear(), NETCLASS::Default, NETCLASSES::Find(), NETCLASSES::GetDefault(), EDA_DRAW_FRAME::GetUserUnits(), GRID_NAME, gridRowToNetclass(), m_BrdSettings, m_Frame, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, BOARD_DESIGN_SETTINGS::m_NetClasses, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_Pcb, BOARD_DESIGN_SETTINGS::SetCurrentNetClass(), BOARD::SynchronizeNetsAndNetClasses(), and validateData().

Referenced by OnAssignSelected().

222 {
223  if( !validateData() )
224  return false;
225 
226  NETCLASSES& netclasses = m_BrdSettings->m_NetClasses;
227 
228  // Remove all netclasses from board. We'll copy new list after
229  netclasses.Clear();
230 
231  // Copy the default NetClass:
233 
234  // Copy other NetClasses :
235  for( int row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
236  {
237  NETCLASSPTR nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row, GRID_NAME ) );
238 
239  if( m_BrdSettings->m_NetClasses.Add( nc ) )
241  }
242 
243  // Now read all nets and push them in the corresponding netclass net buffer
244  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
245  {
246  NETCLASSPTR nc = netclasses.Find( m_membershipGrid->GetCellValue( row, 1 ) );
247 
248  if( nc )
249  nc->Add( m_membershipGrid->GetCellValue( row, 0 ) );
250  }
251 
254 
255  return true;
256 }
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:141
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
Definition: netclass.cpp:155
Class NETCLASSES is a container for NETCLASS instances.
Definition: netclass.h:224
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:80
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:281
static void gridRowToNetclass(EDA_UNITS_T aUnits, wxGrid *grid, int row, const NETCLASSPTR &nc)
BOARD_DESIGN_SETTINGS * m_BrdSettings
bool Add(const NETCLASSPTR &aNetclass)
Function Add takes aNetclass and puts it into this NETCLASSES container.
Definition: netclass.cpp:99
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one.
Definition: netclass.h:242
NETCLASSPTR GetDefault() const
Function GetDefault.
Definition: netclass.h:268
bool PANEL_SETUP_NETCLASSES::TransferDataToWindow ( )
override

Definition at line 126 of file panel_setup_netclasses.cpp.

References addNet(), NETCLASSES::begin(), BOARD::BuildListOfNets(), NETCLASSES::end(), NETCLASSES::GetCount(), NETCLASSES::GetDefault(), BOARD::GetNetInfo(), EDA_DRAW_FRAME::GetUserUnits(), GRID_NAME, i, m_BrdSettings, m_Frame, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, BOARD_DESIGN_SETTINGS::m_NetClasses, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_Pcb, and netclassToGridRow().

Referenced by ImportSettingsFrom(), and OnAssignSelected().

127 {
128  NETCLASSES& netclasses = m_BrdSettings->m_NetClasses;
129  NETCLASSPTR netclass = netclasses.GetDefault();
130 
131  if( m_netclassGrid->GetNumberRows() )
132  m_netclassGrid->DeleteRows( 0, m_netclassGrid->GetNumberRows() );
133  m_netclassGrid->AppendRows( netclasses.GetCount() + 1 ); // + 1 for default netclass
134 
135  // enter the Default NETCLASS.
137 
138  // make the Default NETCLASS name read-only
139  wxGridCellAttr* cellAttr = m_netclassGrid->GetOrCreateCellAttr( 0, GRID_NAME );
140  cellAttr->SetReadOnly();
141  cellAttr->DecRef();
142 
143  // enter other netclasses
144  int row = 1;
145 
146  for( NETCLASSES::iterator i = netclasses.begin(); i != netclasses.end(); ++i, ++row )
148 
149  // ensure that all nets have net classes assigned
151 
152  if( m_membershipGrid->GetNumberRows() )
153  m_membershipGrid->DeleteRows( 0, m_membershipGrid->GetNumberRows() );
154 
155  for( NETINFO_ITEM* net : m_Pcb->GetNetInfo() )
156  {
157  if( net->GetNet() > 0 && net->IsCurrent() )
158  addNet( net->GetNetname(), net->GetNetClass()->GetName() );
159  }
160 
161  return true;
162 }
void BuildListOfNets()
Definition: class_board.h:735
iterator end()
Definition: netclass.h:249
static void netclassToGridRow(EDA_UNITS_T aUnits, wxGrid *aGrid, int aRow, const NETCLASSPTR &nc)
NETCLASS_MAP::iterator iterator
Definition: netclass.h:247
iterator begin()
Definition: netclass.h:248
Class NETCLASSES is a container for NETCLASS instances.
Definition: netclass.h:224
void addNet(wxString netName, const wxString &netclass)
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:281
BOARD_DESIGN_SETTINGS * m_BrdSettings
NETINFO_LIST & GetNetInfo()
Definition: class_board.h:756
unsigned GetCount() const
Function GetCount.
Definition: netclass.h:259
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
NETCLASSPTR GetDefault() const
Function GetDefault.
Definition: netclass.h:268
size_t i
Definition: json11.cpp:597
bool PANEL_SETUP_NETCLASSES::validateData ( )
private

Definition at line 465 of file panel_setup_netclasses.cpp.

References WX_GRID::CommitPendingChanges(), getNetclassValue(), EDA_DRAW_FRAME::GetUserUnits(), UNIT_BINDER::GetValue(), GRID_DIFF_PAIR_WIDTH, GRID_NAME, GRID_TRACKSIZE, GRID_uVIADRILL, GRID_uVIASIZE, GRID_VIADRILL, GRID_VIASIZE, m_ConstraintsPanel, m_Frame, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_Parent, PANEL_SETUP_FEATURE_CONSTRAINTS::m_trackMinWidth, PANEL_SETUP_FEATURE_CONSTRAINTS::m_uviaMinDrill, PANEL_SETUP_FEATURE_CONSTRAINTS::m_uviaMinSize, PANEL_SETUP_FEATURE_CONSTRAINTS::m_viaMinDrill, PANEL_SETUP_FEATURE_CONSTRAINTS::m_viaMinSize, PAGED_DIALOG::SetError(), StringFromValue(), and validateNetclassName().

Referenced by OnAssignSelected(), and TransferDataFromWindow().

466 {
468  return false;
469 
470  wxString msg;
471  int minViaDia = m_ConstraintsPanel->m_viaMinSize.GetValue();
472  int minViaDrill = m_ConstraintsPanel->m_viaMinDrill.GetValue();
473  int minUViaDia = m_ConstraintsPanel->m_uviaMinSize.GetValue();
474  int minUViaDrill = m_ConstraintsPanel->m_uviaMinDrill.GetValue();
475  int minTrackWidth = m_ConstraintsPanel->m_trackMinWidth.GetValue();
476 
477  // Test net class parameters.
478  for( int row = 0; row < m_netclassGrid->GetNumberRows(); row++ )
479  {
480  wxString netclassName = m_netclassGrid->GetCellValue( row, GRID_NAME );
481  netclassName.Trim( true );
482  netclassName.Trim( false );
483 
484  if( !validateNetclassName( row, netclassName, false ) )
485  return false;
486 
487  if( getNetclassValue( row, GRID_TRACKSIZE ) < minTrackWidth )
488  {
489  msg.Printf( _( "Track width less than minimum track width (%s)." ),
490  StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) );
491  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_TRACKSIZE );
492  return false;
493  }
494 
495  if( getNetclassValue( row, GRID_DIFF_PAIR_WIDTH ) < minTrackWidth )
496  {
497  msg.Printf( _( "Differential pair width less than minimum track width (%s)." ),
498  StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) );
500  return false;
501  }
502 
503  // Test vias
504  if( getNetclassValue( row, GRID_VIASIZE ) < minViaDia )
505  {
506  msg.Printf( _( "Via diameter less than minimum via diameter (%s)." ),
507  StringFromValue( m_Frame->GetUserUnits(), minViaDia, true, true ) );
508  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIASIZE );
509  return false;
510  }
511 
513  {
514  msg = _( "Via drill larger than via diameter." );
515  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIADRILL );
516  return false;
517  }
518 
519  if( getNetclassValue( row, GRID_VIADRILL ) < minViaDrill )
520  {
521  msg.Printf( _( "Via drill less than minimum via drill (%s)." ),
522  StringFromValue( m_Frame->GetUserUnits(), minViaDrill, true, true ) );
523  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIADRILL );
524  return false;
525  }
526 
527  // Test Micro vias
528  if( getNetclassValue( row, GRID_uVIASIZE ) < minUViaDia )
529  {
530  msg.Printf( _( "Microvia diameter less than minimum microvia diameter (%s)." ),
531  StringFromValue( m_Frame->GetUserUnits(), minUViaDia, true, true ) );
532  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIASIZE );
533  return false;
534  }
535 
537  {
538  msg = _( "Microvia drill larger than microvia diameter." );
539  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIADRILL );
540  return false;
541  }
542 
543  if( getNetclassValue( row, GRID_uVIADRILL ) < minUViaDrill )
544  {
545  msg.Printf( _( "Microvia drill less than minimum microvia drill (%s)." ),
546  StringFromValue( m_Frame->GetUserUnits(), minUViaDrill, true, true ) );
547  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIADRILL );
548  return false;
549  }
550  }
551 
552  return true;
553 }
int getNetclassValue(int aRow, int aCol)
virtual int GetValue()
Function GetValue Returns the current value in Internal Units.
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:281
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:156
void SetError(const wxString &aMessage, wxWindow *aPage, wxObject *aCtrl, int aRow=-1, int aCol=-1)
PANEL_SETUP_FEATURE_CONSTRAINTS * m_ConstraintsPanel
wxString StringFromValue(EDA_UNITS_T aUnits, int aValue, bool aAddUnitSymbol, bool aUseMils)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:210
bool validateNetclassName(int aRow, wxString aName, bool focusFirst=true)
bool PANEL_SETUP_NETCLASSES::validateNetclassName ( int  aRow,
wxString  aName,
bool  focusFirst = true 
)
private

Definition at line 259 of file panel_setup_netclasses.cpp.

References GRID_NAME, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_Parent, and PAGED_DIALOG::SetError().

Referenced by OnAssignSelected(), OnNetclassGridCellChanging(), and validateData().

260 {
261  aName.Trim( true );
262  aName.Trim( false );
263 
264  if( aName.IsEmpty() )
265  {
266  wxString msg = _( "Netclass must have a name." );
267  m_Parent->SetError( msg, this, m_netclassGrid, aRow, GRID_NAME );
268  return false;
269  }
270 
271  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
272  {
273  if( ii != aRow && m_netclassGrid->GetRowLabelValue( ii ).CmpNoCase( aName ) == 0 )
274  {
275  wxString msg = _( "Netclass name already in use." );
276  m_Parent->SetError( msg, this, m_netclassGrid, focusFirst ? aRow : ii, GRID_NAME );
277  return false;
278  }
279  }
280 
281  return true;
282 }
void SetError(const wxString &aMessage, wxWindow *aPage, wxObject *aCtrl, int aRow=-1, int aCol=-1)

Member Data Documentation

wxBitmapButton* PANEL_SETUP_NETCLASSES_BASE::m_addButton
protectedinherited
wxButton* PANEL_SETUP_NETCLASSES_BASE::m_assignAllButton
protectedinherited
wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_assignLabel
protectedinherited
wxChoice* PANEL_SETUP_NETCLASSES_BASE::m_assignNetClass
protectedinherited
wxButton* PANEL_SETUP_NETCLASSES_BASE::m_assignSelectedButton
protectedinherited
BOARD_DESIGN_SETTINGS* PANEL_SETUP_NETCLASSES::m_BrdSettings
private
PANEL_SETUP_FEATURE_CONSTRAINTS* PANEL_SETUP_NETCLASSES::m_ConstraintsPanel
private

Definition at line 49 of file panel_setup_netclasses.h.

Referenced by PANEL_SETUP_NETCLASSES(), and validateData().

wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_filterLabel
protectedinherited
wxButton* PANEL_SETUP_NETCLASSES_BASE::m_filterNetsButton
protectedinherited
PCB_EDIT_FRAME* PANEL_SETUP_NETCLASSES::m_Frame
private
wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_ncfilterLabel
protectedinherited
bool PANEL_SETUP_NETCLASSES::m_netclassesDirty
private
wxChoice* PANEL_SETUP_NETCLASSES_BASE::m_netClassFilter
protectedinherited
wxTextCtrl* PANEL_SETUP_NETCLASSES_BASE::m_netNameFilter
protectedinherited
int* PANEL_SETUP_NETCLASSES::m_originalColWidths
private
PAGED_DIALOG* PANEL_SETUP_NETCLASSES::m_Parent
private
BOARD* PANEL_SETUP_NETCLASSES::m_Pcb
private
wxBitmapButton* PANEL_SETUP_NETCLASSES_BASE::m_removeButton
protectedinherited
wxButton* PANEL_SETUP_NETCLASSES_BASE::m_showAllButton
protectedinherited

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