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

wxPanel * m_netclassesPane
 
WX_GRIDm_netclassGrid
 
wxBitmapButton * m_addButton
 
wxBitmapButton * m_removeButton
 
wxPanel * m_membershipPane
 
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
 
wxSize m_membershipSize
 

Detailed Description

Definition at line 39 of file panel_setup_netclasses.h.

Constructor & Destructor Documentation

◆ PANEL_SETUP_NETCLASSES()

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

Definition at line 51 of file panel_setup_netclasses.cpp.

52  :
54 {
55  m_Parent = aParent;
56  m_Frame = aFrame;
57  m_Pcb = m_Frame->GetBoard();
59  m_ConstraintsPanel = aConstraintsPanel;
60 
61  m_netclassesDirty = true;
62 
63  // Figure out the smallest the netclass membership pane can ever be so that nothing is cutoff
64  // and force it to be that size.
65  m_membershipSize = GetSize();
66  m_membershipSize.y -= m_netclassesPane->GetSize().y;
67  m_membershipSize.x = -1;
68  m_membershipPane->SetMinSize( m_membershipSize );
69  m_membershipPane->SetMaxSize( m_membershipSize );
70 
71  // Prevent Size events from firing before we are ready
72  Freeze();
73  m_originalColWidths = new int[ m_netclassGrid->GetNumberCols() ];
74  // Calculate a min best size to handle longest usual numeric values:
75  // (The 'M' large char is used to give a margin)
76  int min_best_width = m_netclassGrid->GetTextExtent( "555,555555 milsM" ).x;
77 
78  for( int i = 0; i < m_netclassGrid->GetNumberCols(); ++i )
79  {
80  // We calculate the column min size only from texts sizes, not using the initial col width
81  // as this initial width is sometimes strange depending on the language (wxGrid bug?)
82  int min_width = m_netclassGrid->GetVisibleWidth( i, true, true, false );
83  m_netclassGrid->SetColMinimalWidth( i, min_width );
84  // We use a "best size" >= min_best_width
85  m_originalColWidths[ i ] = std::max( min_width, min_best_width );
86  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
87  }
88 
89  // Be sure the column labels are readable
91 
92  // Membership combobox editors require a bit more room, so increase the row size of
93  // all our grids for consistency
94  m_netclassGrid->SetDefaultRowSize( m_netclassGrid->GetDefaultRowSize() + 4 );
95  m_membershipGrid->SetDefaultRowSize( m_membershipGrid->GetDefaultRowSize() + 4 );
96 
97  m_netclassGrid->PushEventHandler( new GRID_TRICKS( m_netclassGrid ) );
98  m_membershipGrid->PushEventHandler( new GRID_TRICKS( m_membershipGrid ) );
99 
100  m_netclassGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
101  m_membershipGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
102 
103  // Set up the net name column of the netclass membership grid to read-only
104  wxGridCellAttr* attr = new wxGridCellAttr;
105  attr->SetReadOnly( true );
106  m_membershipGrid->SetColAttr( 0, attr );
107 
108  m_addButton->SetBitmap( KiBitmap( small_plus_xpm ) );
109  m_removeButton->SetBitmap( KiBitmap( trash_xpm ) );
110 
111  // wxFormBuilder doesn't include this event...
112  m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), NULL, this );
113 
114  Thaw();
115 }
Class GRID_TRICKS is used to add mouse and command handling (such as cut, copy, and paste) to a WX_GR...
Definition: grid_tricks.h:51
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:540
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=false, bool aKeep=true)
Calculates the specified column based on the actual size of the text on screen.
Definition: wx_grid.cpp:223
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
PANEL_SETUP_NETCLASSES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
Definition: wx_grid.cpp:265
void OnNetclassGridCellChanging(wxGridEvent &event)
BOARD_DESIGN_SETTINGS * m_BrdSettings
PANEL_SETUP_FEATURE_CONSTRAINTS * m_ConstraintsPanel
#define max(a, b)
Definition: auxiliary.h:86
size_t i
Definition: json11.cpp:597
BOARD * GetBoard() const

References WX_GRID::EnsureColLabelsVisible(), PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), WX_GRID::GetVisibleWidth(), i, KiBitmap(), PANEL_SETUP_NETCLASSES_BASE::m_addButton, m_BrdSettings, m_ConstraintsPanel, m_Frame, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, PANEL_SETUP_NETCLASSES_BASE::m_membershipPane, m_membershipSize, m_netclassesDirty, PANEL_SETUP_NETCLASSES_BASE::m_netclassesPane, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_originalColWidths, m_Parent, m_Pcb, PANEL_SETUP_NETCLASSES_BASE::m_removeButton, max, and OnNetclassGridCellChanging().

◆ ~PANEL_SETUP_NETCLASSES()

PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES ( )
override

Definition at line 118 of file panel_setup_netclasses.cpp.

119 {
120  delete [] m_originalColWidths;
121 
122  // Delete the GRID_TRICKS.
123  m_netclassGrid->PopEventHandler( true );
124  m_membershipGrid->PopEventHandler( true );
125 
126  m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), NULL, this );
127 }
void OnNetclassGridCellChanging(wxGridEvent &event)

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

Member Function Documentation

◆ addNet()

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

Definition at line 188 of file panel_setup_netclasses.cpp.

189 {
190  int i = m_membershipGrid->GetNumberRows();
191 
192  m_membershipGrid->AppendRows( 1 );
193 
194  m_membershipGrid->SetCellValue( i, 0, netName );
195  m_membershipGrid->SetCellValue( i, 1, netclass );
196 }
size_t i
Definition: json11.cpp:597

References i, and PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid.

Referenced by TransferDataToWindow().

◆ AdjustMembershipGridColumns()

void PANEL_SETUP_NETCLASSES::AdjustMembershipGridColumns ( int  aWidth)
private

Definition at line 401 of file panel_setup_netclasses.cpp.

402 {
403  // Account for scroll bars
404  aWidth -= ( m_membershipGrid->GetSize().x - m_membershipGrid->GetClientSize().x );
405 
406  // Set className column width to original className width from netclasses grid
407  int classNameWidth = m_originalColWidths[ 0 ];
408  m_membershipGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
409  m_membershipGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
410 }
#define max(a, b)
Definition: auxiliary.h:86

References PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, m_originalColWidths, and max.

Referenced by OnSizeMembershipGrid().

◆ AdjustNetclassGridColumns()

void PANEL_SETUP_NETCLASSES::AdjustNetclassGridColumns ( int  aWidth)
private

Definition at line 378 of file panel_setup_netclasses.cpp.

379 {
380  // Account for scroll bars
381  aWidth -= ( m_netclassGrid->GetSize().x - m_netclassGrid->GetClientSize().x );
382 
383  for( int i = 1; i < m_netclassGrid->GetNumberCols(); i++ )
384  {
385  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
386  aWidth -= m_originalColWidths[ i ];
387  }
388 
389  m_netclassGrid->SetColSize( 0, std::max( aWidth, m_originalColWidths[ 0 ] ) );
390 }
#define max(a, b)
Definition: auxiliary.h:86
size_t i
Definition: json11.cpp:597

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

Referenced by OnSizeNetclassGrid().

◆ doApplyFilters()

void PANEL_SETUP_NETCLASSES::doApplyFilters ( bool  aShowAll)
private

Definition at line 421 of file panel_setup_netclasses.cpp.

422 {
424  return;
425 
426  wxString netClassFilter = m_netClassFilter->GetStringSelection();
427  wxString netFilter = m_netNameFilter->GetValue().MakeLower();
428 
429  if( !netFilter.IsEmpty() )
430  netFilter = wxT( "*" ) + netFilter + wxT( "*" );
431 
432  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
433  {
434  wxString net = m_membershipGrid->GetCellValue( row, 0 );
435  wxString netClass = m_membershipGrid->GetCellValue( row, 1 );
436  bool show = true;
437 
438  if( !aShowAll )
439  {
440  if( !netFilter.IsEmpty() && !net.MakeLower().Matches( netFilter ) )
441  show = false;
442 
443  if( !netClassFilter.IsEmpty() && netClass != netClassFilter )
444  show = false;
445  }
446 
447  if( show )
448  m_membershipGrid->ShowRow( row );
449  else
450  m_membershipGrid->HideRow( row );
451  }
452 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:167

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(), and OnShowAll().

◆ doAssignments()

void PANEL_SETUP_NETCLASSES::doAssignments ( bool  aAssignAll)
private

Definition at line 455 of file panel_setup_netclasses.cpp.

456 {
458  return;
459 
460  wxArrayInt selectedRows = m_membershipGrid->GetSelectedRows();
461 
462  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
463  {
464  if( !m_membershipGrid->IsRowShown( row ) )
465  continue;
466 
467  if( !aAssignAll && selectedRows.Index( row ) == wxNOT_FOUND )
468  continue;
469 
470  m_membershipGrid->SetCellValue( row, 1, m_assignNetClass->GetStringSelection() );
471  }
472 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:167

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

Referenced by OnAssignAll(), and OnAssignSelected().

◆ getNetclassValue()

int PANEL_SETUP_NETCLASSES::getNetclassValue ( int  aRow,
int  aCol 
)
private

Definition at line 496 of file panel_setup_netclasses.cpp.

497 {
498  return ValueFromString( m_Frame->GetUserUnits(), m_netclassGrid->GetCellValue( aRow, aCol ), true );
499 }
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:414
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.

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

Referenced by validateData().

◆ ImportSettingsFrom()

void PANEL_SETUP_NETCLASSES::ImportSettingsFrom ( BOARD aBoard)

Definition at line 593 of file panel_setup_netclasses.cpp.

594 {
595  // Note: do not change the board, as we need to get the current nets from it for
596  // netclass memberships. All the netclass definitions and dimension lists are in
597  // the BOARD_DESIGN_SETTINGS.
598 
599  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
600 
601  m_BrdSettings = &aBoard->GetDesignSettings();
603 
604  m_netclassGrid->ForceRefresh();
605  m_membershipGrid->ForceRefresh();
606 
607  m_BrdSettings = savedSettings;
608 }
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:540
BOARD_DESIGN_SETTINGS * m_BrdSettings
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

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

Referenced by DIALOG_BOARD_SETUP::OnAuxiliaryAction().

◆ OnAddNetclassClick()

void PANEL_SETUP_NETCLASSES::OnAddNetclassClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 323 of file panel_setup_netclasses.cpp.

324 {
326  return;
327 
328  int row = m_netclassGrid->GetNumberRows();
329  m_netclassGrid->AppendRows();
330 
331  // Copy values of the default class:
332  for( int col = 1; col < m_netclassGrid->GetNumberCols(); col++ )
333  m_netclassGrid->SetCellValue( row, col, m_netclassGrid->GetCellValue( 0, col ) );
334 
335  m_netclassGrid->MakeCellVisible( row, 0 );
336  m_netclassGrid->SetGridCursor( row, 0 );
337 
338  m_netclassGrid->EnableCellEditControl( true );
339  m_netclassGrid->ShowCellEditControl();
340 
341  m_netclassesDirty = true;
342 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:167

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

◆ OnApplyFilters()

void PANEL_SETUP_NETCLASSES::OnApplyFilters ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 64 of file panel_setup_netclasses.h.

64 { doApplyFilters( false ); }
void doApplyFilters(bool aShowAll)

References doApplyFilters().

◆ OnAssignAll()

void PANEL_SETUP_NETCLASSES::OnAssignAll ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 65 of file panel_setup_netclasses.h.

65 { doAssignments( true ); }
void doAssignments(bool aAssignAll)

References doAssignments().

◆ OnAssignSelected()

void PANEL_SETUP_NETCLASSES::OnAssignSelected ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 66 of file panel_setup_netclasses.h.

66 { doAssignments( false ); }
void doAssignments(bool aAssignAll)

References doAssignments().

◆ OnNetclassGridCellChanging()

void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ( wxGridEvent &  event)
private

Definition at line 311 of file panel_setup_netclasses.cpp.

312 {
313  if( event.GetCol() == GRID_NAME )
314  {
315  if( validateNetclassName( event.GetRow(), event.GetString() ) )
316  m_netclassesDirty = true;
317  else
318  event.Veto();
319  }
320 }
bool validateNetclassName(int aRow, wxString aName, bool focusFirst=true)

References GRID_NAME, m_netclassesDirty, and validateNetclassName().

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

◆ OnRemoveNetclassClick()

void PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 345 of file panel_setup_netclasses.cpp.

346 {
348  return;
349 
350  int curRow = m_netclassGrid->GetGridCursorRow();
351 
352  if( curRow < 0 )
353  return;
354  else if( curRow == 0 )
355  {
356  DisplayErrorMessage( this, _( "The default net class is required." ) );
357  return;
358  }
359 
360  // reset the net class to default for members of the removed class
361  wxString classname = m_netclassGrid->GetCellValue( curRow, GRID_NAME );
362 
363  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
364  {
365  if( m_membershipGrid->GetCellValue( row, 1 ) == classname )
366  m_membershipGrid->SetCellValue( row, 1, NETCLASS::Default );
367  }
368 
369  m_netclassGrid->DeleteRows( curRow, 1 );
370 
371  m_netclassGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
372  m_netclassGrid->SetGridCursor( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
373 
374  m_netclassesDirty = true;
375 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:258
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:167
#define _(s)
#define max(a, b)
Definition: auxiliary.h:86

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.

◆ OnShowAll()

void PANEL_SETUP_NETCLASSES::OnShowAll ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 63 of file panel_setup_netclasses.h.

63 { doApplyFilters( true ); }
void doApplyFilters(bool aShowAll)

References doApplyFilters().

◆ OnSizeMembershipGrid()

void PANEL_SETUP_NETCLASSES::OnSizeMembershipGrid ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 413 of file panel_setup_netclasses.cpp.

414 {
415  AdjustMembershipGridColumns( event.GetSize().GetX() );
416 
417  event.Skip();
418 }
void AdjustMembershipGridColumns(int aWidth)

References AdjustMembershipGridColumns().

◆ OnSizeNetclassGrid()

void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 393 of file panel_setup_netclasses.cpp.

394 {
395  AdjustNetclassGridColumns( event.GetSize().GetX() );
396 
397  event.Skip();
398 }
void AdjustNetclassGridColumns(int aWidth)

References AdjustNetclassGridColumns().

◆ OnUpdateUI()

void PANEL_SETUP_NETCLASSES::OnUpdateUI ( wxUpdateUIEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 475 of file panel_setup_netclasses.cpp.

476 {
477  if( m_netclassesDirty )
478  {
480  m_netclassesDirty = false;
481  }
482 
483  // Recompute the desired size for the two content panes. We cannot leave this sizing to
484  // wxWidgets because it wants to shrink the membership panel to an unusable size when the
485  // netlist panel grows, and also it introduces undesired artifacts when the window is resized
486  // and the panes can grow/shrink.
487  wxSize netclassSize = GetClientSize();
488  netclassSize.y -= m_membershipSize.y;
489 
490  m_netclassesPane->SetMinSize( netclassSize );
491  m_netclassesPane->SetMaxSize( netclassSize );
492  Layout();
493 }

References m_membershipSize, m_netclassesDirty, PANEL_SETUP_NETCLASSES_BASE::m_netclassesPane, and rebuildNetclassDropdowns().

◆ rebuildNetclassDropdowns()

void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns ( )
private

Definition at line 201 of file panel_setup_netclasses.cpp.

202 {
204 
205  wxArrayString netclassNames;
206 
207  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
208  {
209  wxString netclassName = m_netclassGrid->GetCellValue( ii, GRID_NAME );
210  if( !netclassName.IsEmpty() )
211  netclassNames.push_back( netclassName );
212  }
213 
214  wxGridCellAttr* attr = new wxGridCellAttr;
215  attr->SetEditor( new wxGridCellChoiceEditor( netclassNames ) );
216  m_membershipGrid->SetColAttr( 1, attr );
217 
218  m_assignNetClass->Set( netclassNames );
219 
220  netclassNames.Insert( wxEmptyString, 0 );
221  m_netClassFilter->Set( netclassNames );
222 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:167

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 OnUpdateUI().

◆ TransferDataFromWindow()

bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow ( )
override

Definition at line 244 of file panel_setup_netclasses.cpp.

245 {
246  if( !validateData() )
247  return false;
248 
249  NETCLASSES& netclasses = m_BrdSettings->m_NetClasses;
250 
251  // Remove all netclasses from board. We'll copy new list after
252  netclasses.Clear();
253 
254  // Copy the default NetClass:
256 
257  // Copy other NetClasses :
258  for( int row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
259  {
260  NETCLASSPTR nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row, GRID_NAME ) );
261 
262  if( m_BrdSettings->m_NetClasses.Add( nc ) )
264  }
265 
266  // Now read all nets and push them in the corresponding netclass net buffer
267  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
268  {
269  NETCLASSPTR nc = netclasses.Find( m_membershipGrid->GetCellValue( row, 1 ) );
270 
271  if( nc )
272  nc->Add( m_membershipGrid->GetCellValue( row, 0 ) );
273  }
274 
277 
278  if( auto toolmgr = m_Frame->GetToolManager() )
279  toolmgr->ResetTools( TOOL_BASE::MODEL_RELOAD );
280 
281  return true;
282 }
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:141
Model changes (required full reload)
Definition: tool_base.h:82
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
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
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
NETCLASSPTR GetDefault() const
Function GetDefault.
Definition: netclass.h:268

References NETCLASSES::Add(), NETCLASSES::Clear(), NETCLASS::Default, NETCLASSES::Find(), NETCLASSES::GetDefault(), EDA_BASE_FRAME::GetToolManager(), EDA_BASE_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, TOOL_BASE::MODEL_RELOAD, BOARD_DESIGN_SETTINGS::SetCurrentNetClass(), BOARD::SynchronizeNetsAndNetClasses(), and validateData().

◆ TransferDataToWindow()

bool PANEL_SETUP_NETCLASSES::TransferDataToWindow ( )
override

Definition at line 149 of file panel_setup_netclasses.cpp.

150 {
151  NETCLASSES& netclasses = m_BrdSettings->m_NetClasses;
152  NETCLASSPTR netclass = netclasses.GetDefault();
153 
154  if( m_netclassGrid->GetNumberRows() )
155  m_netclassGrid->DeleteRows( 0, m_netclassGrid->GetNumberRows() );
156  m_netclassGrid->AppendRows( netclasses.GetCount() + 1 ); // + 1 for default netclass
157 
158  // enter the Default NETCLASS.
160 
161  // make the Default NETCLASS name read-only
162  wxGridCellAttr* cellAttr = m_netclassGrid->GetOrCreateCellAttr( 0, GRID_NAME );
163  cellAttr->SetReadOnly();
164  cellAttr->DecRef();
165 
166  // enter other netclasses
167  int row = 1;
168 
169  for( NETCLASSES::iterator i = netclasses.begin(); i != netclasses.end(); ++i, ++row )
171 
172  // ensure that all nets have net classes assigned
174 
175  if( m_membershipGrid->GetNumberRows() )
176  m_membershipGrid->DeleteRows( 0, m_membershipGrid->GetNumberRows() );
177 
178  for( NETINFO_ITEM* net : m_Pcb->GetNetInfo() )
179  {
180  if( net->GetNet() > 0 && net->IsCurrent() )
181  addNet( UnescapeString( net->GetNetname() ), net->GetNetClass()->GetName() );
182  }
183 
184  return true;
185 }
void BuildListOfNets()
Definition: class_board.h:729
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)
BOARD_DESIGN_SETTINGS * m_BrdSettings
NETINFO_LIST & GetNetInfo()
Definition: class_board.h:750
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:123
size_t i
Definition: json11.cpp:597
unsigned GetCount() const
Function GetCount.
Definition: netclass.h:259
NETCLASSPTR GetDefault() const
Function GetDefault.
Definition: netclass.h:268

References addNet(), NETCLASSES::begin(), BOARD::BuildListOfNets(), NETCLASSES::end(), NETCLASSES::GetCount(), NETCLASSES::GetDefault(), BOARD::GetNetInfo(), EDA_BASE_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, netclassToGridRow(), and UnescapeString().

Referenced by ImportSettingsFrom().

◆ validateData()

bool PANEL_SETUP_NETCLASSES::validateData ( )
private

Definition at line 502 of file panel_setup_netclasses.cpp.

503 {
505  return false;
506 
507  wxString msg;
508  int minViaDia = m_ConstraintsPanel->m_viaMinSize.GetValue();
509  int minViaDrill = m_ConstraintsPanel->m_viaMinDrill.GetValue();
510  int minUViaDia = m_ConstraintsPanel->m_uviaMinSize.GetValue();
511  int minUViaDrill = m_ConstraintsPanel->m_uviaMinDrill.GetValue();
512  int minTrackWidth = m_ConstraintsPanel->m_trackMinWidth.GetValue();
513 
514  // Test net class parameters.
515  for( int row = 0; row < m_netclassGrid->GetNumberRows(); row++ )
516  {
517  wxString netclassName = m_netclassGrid->GetCellValue( row, GRID_NAME );
518  netclassName.Trim( true );
519  netclassName.Trim( false );
520 
521  if( !validateNetclassName( row, netclassName, false ) )
522  return false;
523 
524  if( getNetclassValue( row, GRID_TRACKSIZE ) < minTrackWidth )
525  {
526  msg.Printf( _( "Track width less than minimum track width (%s)." ),
527  StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) );
528  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_TRACKSIZE );
529  return false;
530  }
531 
532  if( getNetclassValue( row, GRID_DIFF_PAIR_WIDTH ) < minTrackWidth )
533  {
534  msg.Printf( _( "Differential pair width less than minimum track width (%s)." ),
535  StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) );
537  return false;
538  }
539 
540  // Test vias
541  if( getNetclassValue( row, GRID_VIASIZE ) < minViaDia )
542  {
543  msg.Printf( _( "Via diameter less than minimum via diameter (%s)." ),
544  StringFromValue( m_Frame->GetUserUnits(), minViaDia, true, true ) );
545  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIASIZE );
546  return false;
547  }
548 
550  {
551  msg = _( "Via drill larger than via diameter." );
552  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIADRILL );
553  return false;
554  }
555 
556  if( getNetclassValue( row, GRID_VIADRILL ) < minViaDrill )
557  {
558  msg.Printf( _( "Via drill less than minimum via drill (%s)." ),
559  StringFromValue( m_Frame->GetUserUnits(), minViaDrill, true, true ) );
560  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIADRILL );
561  return false;
562  }
563 
564  // Test Micro vias
565  if( getNetclassValue( row, GRID_uVIASIZE ) < minUViaDia )
566  {
567  msg.Printf( _( "Microvia diameter less than minimum microvia diameter (%s)." ),
568  StringFromValue( m_Frame->GetUserUnits(), minUViaDia, true, true ) );
569  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIASIZE );
570  return false;
571  }
572 
574  {
575  msg = _( "Microvia drill larger than microvia diameter." );
576  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIADRILL );
577  return false;
578  }
579 
580  if( getNetclassValue( row, GRID_uVIADRILL ) < minUViaDrill )
581  {
582  msg.Printf( _( "Microvia drill less than minimum microvia drill (%s)." ),
583  StringFromValue( m_Frame->GetUserUnits(), minUViaDrill, true, true ) );
584  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIADRILL );
585  return false;
586  }
587  }
588 
589  return true;
590 }
int getNetclassValue(int aRow, int aCol)
virtual int GetValue()
Function GetValue Returns the current value in Internal Units.
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:167
#define _(s)
void SetError(const wxString &aMessage, wxWindow *aPage, wxObject *aCtrl, int aRow=-1, int aCol=-1)
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
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)

References _, WX_GRID::CommitPendingChanges(), getNetclassValue(), EDA_BASE_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 TransferDataFromWindow().

◆ validateNetclassName()

bool PANEL_SETUP_NETCLASSES::validateNetclassName ( int  aRow,
wxString  aName,
bool  focusFirst = true 
)
private

Definition at line 285 of file panel_setup_netclasses.cpp.

286 {
287  aName.Trim( true );
288  aName.Trim( false );
289 
290  if( aName.IsEmpty() )
291  {
292  wxString msg = _( "Netclass must have a name." );
293  m_Parent->SetError( msg, this, m_netclassGrid, aRow, GRID_NAME );
294  return false;
295  }
296 
297  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
298  {
299  if( ii != aRow && m_netclassGrid->GetRowLabelValue( ii ).CmpNoCase( aName ) == 0 )
300  {
301  wxString msg = _( "Netclass name already in use." );
302  m_Parent->SetError( msg, this, m_netclassGrid, focusFirst ? aRow : ii, GRID_NAME );
303  return false;
304  }
305  }
306 
307  return true;
308 }
#define _(s)
void SetError(const wxString &aMessage, wxWindow *aPage, wxObject *aCtrl, int aRow=-1, int aCol=-1)

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

Referenced by OnNetclassGridCellChanging(), and validateData().

Member Data Documentation

◆ m_addButton

wxBitmapButton* PANEL_SETUP_NETCLASSES_BASE::m_addButton
protectedinherited

◆ m_assignAllButton

wxButton* PANEL_SETUP_NETCLASSES_BASE::m_assignAllButton
protectedinherited

◆ m_assignLabel

wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_assignLabel
protectedinherited

◆ m_assignNetClass

wxChoice* PANEL_SETUP_NETCLASSES_BASE::m_assignNetClass
protectedinherited

◆ m_assignSelectedButton

wxButton* PANEL_SETUP_NETCLASSES_BASE::m_assignSelectedButton
protectedinherited

◆ m_BrdSettings

BOARD_DESIGN_SETTINGS* PANEL_SETUP_NETCLASSES::m_BrdSettings
private

◆ m_ConstraintsPanel

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().

◆ m_filterLabel

wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_filterLabel
protectedinherited

◆ m_filterNetsButton

wxButton* PANEL_SETUP_NETCLASSES_BASE::m_filterNetsButton
protectedinherited

◆ m_Frame

PCB_EDIT_FRAME* PANEL_SETUP_NETCLASSES::m_Frame
private

◆ m_membershipGrid

◆ m_membershipPane

wxPanel* PANEL_SETUP_NETCLASSES_BASE::m_membershipPane
protectedinherited

◆ m_membershipSize

wxSize PANEL_SETUP_NETCLASSES::m_membershipSize
private

Definition at line 54 of file panel_setup_netclasses.h.

Referenced by OnUpdateUI(), and PANEL_SETUP_NETCLASSES().

◆ m_ncfilterLabel

wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_ncfilterLabel
protectedinherited

◆ m_netclassesDirty

bool PANEL_SETUP_NETCLASSES::m_netclassesDirty
private

◆ m_netclassesPane

wxPanel* PANEL_SETUP_NETCLASSES_BASE::m_netclassesPane
protectedinherited

◆ m_netClassFilter

wxChoice* PANEL_SETUP_NETCLASSES_BASE::m_netClassFilter
protectedinherited

◆ m_netclassGrid

◆ m_netNameFilter

wxTextCtrl* PANEL_SETUP_NETCLASSES_BASE::m_netNameFilter
protectedinherited

◆ m_originalColWidths

int* PANEL_SETUP_NETCLASSES::m_originalColWidths
private

◆ m_Parent

PAGED_DIALOG* PANEL_SETUP_NETCLASSES::m_Parent
private

◆ m_Pcb

BOARD* PANEL_SETUP_NETCLASSES::m_Pcb
private

◆ m_removeButton

wxBitmapButton* PANEL_SETUP_NETCLASSES_BASE::m_removeButton
protectedinherited

◆ m_showAllButton

wxButton* PANEL_SETUP_NETCLASSES_BASE::m_showAllButton
protectedinherited

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