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::PANEL_SETUP_NETCLASSES ( PAGED_DIALOG aParent,
PCB_EDIT_FRAME aFrame,
PANEL_SETUP_FEATURE_CONSTRAINTS aConstraintsPanel 
)

Definition at line 55 of file panel_setup_netclasses.cpp.

56  :
58 {
59  m_Parent = aParent;
60  m_Frame = aFrame;
61  m_Pcb = m_Frame->GetBoard();
63  m_ConstraintsPanel = aConstraintsPanel;
64 
65  m_netclassesDirty = true;
66 
67  m_originalColWidths = new int[ m_netclassGrid->GetNumberCols() ];
68  // Calculate a min best size to handle longest usual numeric values:
69  // (The 'M' large char is used to give a margin)
70  int min_best_width = m_netclassGrid->GetTextExtent( "555,555555 milsM" ).x;
71 
72  for( int i = 0; i < m_netclassGrid->GetNumberCols(); ++i )
73  {
74  // We calculate the column min size only from texts sizes, not using the initial col width
75  // as this initial width is sometimes strange depending on the language (wxGrid bug?)
76  int min_width = m_netclassGrid->GetVisibleWidth( i, true, true, false );
77  m_netclassGrid->SetColMinimalWidth( i, min_width );
78  // We use a "best size" >= min_best_width
79  m_originalColWidths[ i ] = std::max( min_width, min_best_width );
80  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
81  }
82 
83  // Be sure the column labels are readable
85 
86  // Membership combobox editors require a bit more room, so increase the row size of
87  // all our grids for consistency
88  m_netclassGrid->SetDefaultRowSize( m_netclassGrid->GetDefaultRowSize() + 4 );
89  m_membershipGrid->SetDefaultRowSize( m_membershipGrid->GetDefaultRowSize() + 4 );
90 
91  m_netclassGrid->PushEventHandler( new GRID_TRICKS( m_netclassGrid ) );
92  m_membershipGrid->PushEventHandler( new GRID_TRICKS( m_membershipGrid ) );
93 
94  m_netclassGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
95  m_membershipGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
96 
97  // Set up the net name column of the netclass membership grid to read-only
98  wxGridCellAttr* attr = new wxGridCellAttr;
99  attr->SetReadOnly( true );
100  m_membershipGrid->SetColAttr( 0, attr );
101 
102  m_addButton->SetBitmap( KiBitmap( small_plus_xpm ) );
103  m_removeButton->SetBitmap( KiBitmap( trash_xpm ) );
104 
105  // wxFormBuilder doesn't include this event...
106  m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), NULL, this );
107 }
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:539
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, m_netclassesDirty, 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 110 of file panel_setup_netclasses.cpp.

111 {
112  delete [] m_originalColWidths;
113 
114  // Delete the GRID_TRICKS.
115  m_netclassGrid->PopEventHandler( true );
116  m_membershipGrid->PopEventHandler( true );
117 
118  m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), NULL, this );
119 }
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 180 of file panel_setup_netclasses.cpp.

181 {
182  int i = m_membershipGrid->GetNumberRows();
183 
184  m_membershipGrid->AppendRows( 1 );
185 
186  m_membershipGrid->SetCellValue( i, 0, netName );
187  m_membershipGrid->SetCellValue( i, 1, netclass );
188 }
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 390 of file panel_setup_netclasses.cpp.

391 {
392  // Account for scroll bars
393  aWidth -= ( m_membershipGrid->GetSize().x - m_membershipGrid->GetClientSize().x );
394 
395  // Set className column width to original className width from netclasses grid
396  int classNameWidth = m_originalColWidths[ 0 ];
397  m_membershipGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
398  m_membershipGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
399 }
#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 367 of file panel_setup_netclasses.cpp.

368 {
369  // Account for scroll bars
370  aWidth -= ( m_netclassGrid->GetSize().x - m_netclassGrid->GetClientSize().x );
371 
372  for( int i = 1; i < m_netclassGrid->GetNumberCols(); i++ )
373  {
374  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
375  aWidth -= m_originalColWidths[ i ];
376  }
377 
378  m_netclassGrid->SetColSize( 0, std::max( aWidth, m_originalColWidths[ 0 ] ) );
379 }
#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 410 of file panel_setup_netclasses.cpp.

411 {
413  return;
414 
415  wxString netClassFilter = m_netClassFilter->GetStringSelection();
416  wxString netFilter = m_netNameFilter->GetValue().MakeLower();
417 
418  if( !netFilter.IsEmpty() )
419  netFilter = wxT( "*" ) + netFilter + wxT( "*" );
420 
421  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
422  {
423  wxString net = m_membershipGrid->GetCellValue( row, 0 );
424  wxString netClass = m_membershipGrid->GetCellValue( row, 1 );
425  bool show = true;
426 
427  if( !aShowAll )
428  {
429  if( !netFilter.IsEmpty() && !net.MakeLower().Matches( netFilter ) )
430  show = false;
431 
432  if( !netClassFilter.IsEmpty() && netClass != netClassFilter )
433  show = false;
434  }
435 
436  if( show )
437  m_membershipGrid->ShowRow( row );
438  else
439  m_membershipGrid->HideRow( row );
440  }
441 }
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 444 of file panel_setup_netclasses.cpp.

445 {
447  return;
448 
449  wxArrayInt selectedRows = m_membershipGrid->GetSelectedRows();
450 
451  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
452  {
453  if( !m_membershipGrid->IsRowShown( row ) )
454  continue;
455 
456  if( !aAssignAll && selectedRows.Index( row ) == wxNOT_FOUND )
457  continue;
458 
459  m_membershipGrid->SetCellValue( row, 1, m_assignNetClass->GetStringSelection() );
460  }
461 }
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 474 of file panel_setup_netclasses.cpp.

475 {
476  return ValueFromString( m_Frame->GetUserUnits(), m_netclassGrid->GetCellValue( aRow, aCol ), true );
477 }
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:291

References EDA_DRAW_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 571 of file panel_setup_netclasses.cpp.

572 {
573  // Note: do not change the board, as we need to get the current nets from it for
574  // netclass memberships. All the netclass definitions and dimension lists are in
575  // the BOARD_DESIGN_SETTINGS.
576 
577  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
578 
579  m_BrdSettings = &aBoard->GetDesignSettings();
581 
582  m_netclassGrid->ForceRefresh();
583  m_membershipGrid->ForceRefresh();
584 
585  m_BrdSettings = savedSettings;
586 }
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.

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 312 of file panel_setup_netclasses.cpp.

313 {
315  return;
316 
317  int row = m_netclassGrid->GetNumberRows();
318  m_netclassGrid->AppendRows();
319 
320  // Copy values of the default class:
321  for( int col = 1; col < m_netclassGrid->GetNumberCols(); col++ )
322  m_netclassGrid->SetCellValue( row, col, m_netclassGrid->GetCellValue( 0, col ) );
323 
324  m_netclassGrid->MakeCellVisible( row, 0 );
325  m_netclassGrid->SetGridCursor( row, 0 );
326 
327  m_netclassGrid->EnableCellEditControl( true );
328  m_netclassGrid->ShowCellEditControl();
329 
330  m_netclassesDirty = true;
331 }
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 62 of file panel_setup_netclasses.h.

62 { 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 63 of file panel_setup_netclasses.h.

63 { 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 64 of file panel_setup_netclasses.h.

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

References doAssignments().

◆ OnNetclassGridCellChanging()

void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ( wxGridEvent &  event)
private

Definition at line 300 of file panel_setup_netclasses.cpp.

301 {
302  if( event.GetCol() == GRID_NAME )
303  {
304  if( validateNetclassName( event.GetRow(), event.GetString() ) )
305  m_netclassesDirty = true;
306  else
307  event.Veto();
308  }
309 }
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 334 of file panel_setup_netclasses.cpp.

335 {
337  return;
338 
339  int curRow = m_netclassGrid->GetGridCursorRow();
340 
341  if( curRow < 0 )
342  return;
343  else if( curRow == 0 )
344  {
345  DisplayErrorMessage( this, _( "The default net class is required." ) );
346  return;
347  }
348 
349  // reset the net class to default for members of the removed class
350  wxString classname = m_netclassGrid->GetCellValue( curRow, GRID_NAME );
351 
352  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
353  {
354  if( m_membershipGrid->GetCellValue( row, 1 ) == classname )
355  m_membershipGrid->SetCellValue( row, 1, NETCLASS::Default );
356  }
357 
358  m_netclassGrid->DeleteRows( curRow, 1 );
359 
360  m_netclassGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
361  m_netclassGrid->SetGridCursor( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
362 
363  m_netclassesDirty = true;
364 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:257
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 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 61 of file panel_setup_netclasses.h.

61 { 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 402 of file panel_setup_netclasses.cpp.

403 {
404  AdjustMembershipGridColumns( event.GetSize().GetX() );
405 
406  event.Skip();
407 }
void AdjustMembershipGridColumns(int aWidth)

References AdjustMembershipGridColumns().

◆ OnSizeNetclassGrid()

void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 382 of file panel_setup_netclasses.cpp.

383 {
384  AdjustNetclassGridColumns( event.GetSize().GetX() );
385 
386  event.Skip();
387 }
void AdjustNetclassGridColumns(int aWidth)

References AdjustNetclassGridColumns().

◆ OnUpdateUI()

void PANEL_SETUP_NETCLASSES::OnUpdateUI ( wxUpdateUIEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 464 of file panel_setup_netclasses.cpp.

465 {
466  if( m_netclassesDirty )
467  {
469  m_netclassesDirty = false;
470  }
471 }

References m_netclassesDirty, and rebuildNetclassDropdowns().

◆ rebuildNetclassDropdowns()

void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns ( )
private

Definition at line 193 of file panel_setup_netclasses.cpp.

194 {
196 
197  wxArrayString netclassNames;
198 
199  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
200  {
201  wxString netclassName = m_netclassGrid->GetCellValue( ii, GRID_NAME );
202  if( !netclassName.IsEmpty() )
203  netclassNames.push_back( netclassName );
204  }
205 
206  wxGridCellAttr* attr = new wxGridCellAttr;
207  attr->SetEditor( new wxGridCellChoiceEditor( netclassNames ) );
208  m_membershipGrid->SetColAttr( 1, attr );
209 
210  m_assignNetClass->Set( netclassNames );
211 
212  netclassNames.Insert( wxEmptyString, 0 );
213  m_netClassFilter->Set( netclassNames );
214 }
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 236 of file panel_setup_netclasses.cpp.

237 {
238  if( !validateData() )
239  return false;
240 
241  NETCLASSES& netclasses = m_BrdSettings->m_NetClasses;
242 
243  // Remove all netclasses from board. We'll copy new list after
244  netclasses.Clear();
245 
246  // Copy the default NetClass:
248 
249  // Copy other NetClasses :
250  for( int row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
251  {
252  NETCLASSPTR nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row, GRID_NAME ) );
253 
254  if( m_BrdSettings->m_NetClasses.Add( nc ) )
256  }
257 
258  // Now read all nets and push them in the corresponding netclass net buffer
259  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
260  {
261  NETCLASSPTR nc = netclasses.Find( m_membershipGrid->GetCellValue( row, 1 ) );
262 
263  if( nc )
264  nc->Add( m_membershipGrid->GetCellValue( row, 0 ) );
265  }
266 
269 
270  return true;
271 }
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:291
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

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

◆ TransferDataToWindow()

bool PANEL_SETUP_NETCLASSES::TransferDataToWindow ( )
override

Definition at line 141 of file panel_setup_netclasses.cpp.

142 {
143  NETCLASSES& netclasses = m_BrdSettings->m_NetClasses;
144  NETCLASSPTR netclass = netclasses.GetDefault();
145 
146  if( m_netclassGrid->GetNumberRows() )
147  m_netclassGrid->DeleteRows( 0, m_netclassGrid->GetNumberRows() );
148  m_netclassGrid->AppendRows( netclasses.GetCount() + 1 ); // + 1 for default netclass
149 
150  // enter the Default NETCLASS.
152 
153  // make the Default NETCLASS name read-only
154  wxGridCellAttr* cellAttr = m_netclassGrid->GetOrCreateCellAttr( 0, GRID_NAME );
155  cellAttr->SetReadOnly();
156  cellAttr->DecRef();
157 
158  // enter other netclasses
159  int row = 1;
160 
161  for( NETCLASSES::iterator i = netclasses.begin(); i != netclasses.end(); ++i, ++row )
163 
164  // ensure that all nets have net classes assigned
166 
167  if( m_membershipGrid->GetNumberRows() )
168  m_membershipGrid->DeleteRows( 0, m_membershipGrid->GetNumberRows() );
169 
170  for( NETINFO_ITEM* net : m_Pcb->GetNetInfo() )
171  {
172  if( net->GetNet() > 0 && net->IsCurrent() )
173  addNet( net->GetNetname(), net->GetNetClass()->GetName() );
174  }
175 
176  return true;
177 }
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:291
BOARD_DESIGN_SETTINGS * m_BrdSettings
NETINFO_LIST & GetNetInfo()
Definition: class_board.h:756
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
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_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().

◆ validateData()

bool PANEL_SETUP_NETCLASSES::validateData ( )
private

Definition at line 480 of file panel_setup_netclasses.cpp.

481 {
483  return false;
484 
485  wxString msg;
486  int minViaDia = m_ConstraintsPanel->m_viaMinSize.GetValue();
487  int minViaDrill = m_ConstraintsPanel->m_viaMinDrill.GetValue();
488  int minUViaDia = m_ConstraintsPanel->m_uviaMinSize.GetValue();
489  int minUViaDrill = m_ConstraintsPanel->m_uviaMinDrill.GetValue();
490  int minTrackWidth = m_ConstraintsPanel->m_trackMinWidth.GetValue();
491 
492  // Test net class parameters.
493  for( int row = 0; row < m_netclassGrid->GetNumberRows(); row++ )
494  {
495  wxString netclassName = m_netclassGrid->GetCellValue( row, GRID_NAME );
496  netclassName.Trim( true );
497  netclassName.Trim( false );
498 
499  if( !validateNetclassName( row, netclassName, false ) )
500  return false;
501 
502  if( getNetclassValue( row, GRID_TRACKSIZE ) < minTrackWidth )
503  {
504  msg.Printf( _( "Track width less than minimum track width (%s)." ),
505  StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) );
506  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_TRACKSIZE );
507  return false;
508  }
509 
510  if( getNetclassValue( row, GRID_DIFF_PAIR_WIDTH ) < minTrackWidth )
511  {
512  msg.Printf( _( "Differential pair width less than minimum track width (%s)." ),
513  StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) );
515  return false;
516  }
517 
518  // Test vias
519  if( getNetclassValue( row, GRID_VIASIZE ) < minViaDia )
520  {
521  msg.Printf( _( "Via diameter less than minimum via diameter (%s)." ),
522  StringFromValue( m_Frame->GetUserUnits(), minViaDia, true, true ) );
523  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIASIZE );
524  return false;
525  }
526 
528  {
529  msg = _( "Via drill larger than via diameter." );
530  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIADRILL );
531  return false;
532  }
533 
534  if( getNetclassValue( row, GRID_VIADRILL ) < minViaDrill )
535  {
536  msg.Printf( _( "Via drill less than minimum via drill (%s)." ),
537  StringFromValue( m_Frame->GetUserUnits(), minViaDrill, true, true ) );
538  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIADRILL );
539  return false;
540  }
541 
542  // Test Micro vias
543  if( getNetclassValue( row, GRID_uVIASIZE ) < minUViaDia )
544  {
545  msg.Printf( _( "Microvia diameter less than minimum microvia diameter (%s)." ),
546  StringFromValue( m_Frame->GetUserUnits(), minUViaDia, true, true ) );
547  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIASIZE );
548  return false;
549  }
550 
552  {
553  msg = _( "Microvia drill larger than microvia diameter." );
554  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIADRILL );
555  return false;
556  }
557 
558  if( getNetclassValue( row, GRID_uVIADRILL ) < minUViaDrill )
559  {
560  msg.Printf( _( "Microvia drill less than minimum microvia drill (%s)." ),
561  StringFromValue( m_Frame->GetUserUnits(), minUViaDrill, true, true ) );
562  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIADRILL );
563  return false;
564  }
565  }
566 
567  return true;
568 }
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:291
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:167
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)

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

◆ validateNetclassName()

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

Definition at line 274 of file panel_setup_netclasses.cpp.

275 {
276  aName.Trim( true );
277  aName.Trim( false );
278 
279  if( aName.IsEmpty() )
280  {
281  wxString msg = _( "Netclass must have a name." );
282  m_Parent->SetError( msg, this, m_netclassGrid, aRow, GRID_NAME );
283  return false;
284  }
285 
286  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
287  {
288  if( ii != aRow && m_netclassGrid->GetRowLabelValue( ii ).CmpNoCase( aName ) == 0 )
289  {
290  wxString msg = _( "Netclass name already in use." );
291  m_Parent->SetError( msg, this, m_netclassGrid, focusFirst ? aRow : ii, GRID_NAME );
292  return false;
293  }
294  }
295 
296  return true;
297 }
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_ncfilterLabel

wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_ncfilterLabel
protectedinherited

◆ m_netclassesDirty

bool PANEL_SETUP_NETCLASSES::m_netclassesDirty
private

◆ 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: