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:538
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 373 of file panel_setup_netclasses.cpp.

References PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, m_originalColWidths, and max.

Referenced by OnAssignSelected(), and OnSizeMembershipGrid().

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

Definition at line 350 of file panel_setup_netclasses.cpp.

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

Referenced by OnAssignSelected(), and OnSizeNetclassGrid().

351 {
352  // Account for scroll bars
353  aWidth -= ( m_netclassGrid->GetSize().x - m_netclassGrid->GetClientSize().x );
354 
355  for( int i = 1; i < m_netclassGrid->GetNumberCols(); i++ )
356  {
357  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
358  aWidth -= m_originalColWidths[ i ];
359  }
360 
361  m_netclassGrid->SetColSize( 0, std::max( aWidth, m_originalColWidths[ 0 ] ) );
362 }
#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 393 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().

394 {
396  return;
397 
398  wxString netClassFilter = m_netClassFilter->GetStringSelection();
399  wxString netFilter = m_netNameFilter->GetValue().MakeLower();
400 
401  if( !netFilter.IsEmpty() )
402  netFilter = wxT( "*" ) + netFilter + wxT( "*" );
403 
404  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
405  {
406  wxString net = m_membershipGrid->GetCellValue( row, 0 );
407  wxString netClass = m_membershipGrid->GetCellValue( row, 1 );
408  bool show = true;
409 
410  if( !aShowAll )
411  {
412  if( !netFilter.IsEmpty() && !net.MakeLower().Matches( netFilter ) )
413  show = false;
414 
415  if( !netClassFilter.IsEmpty() && netClass != netClassFilter )
416  show = false;
417  }
418 
419  if( show )
420  m_membershipGrid->ShowRow( row );
421  else
422  m_membershipGrid->HideRow( row );
423  }
424 }
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 427 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().

428 {
430  return;
431 
432  wxArrayInt selectedRows = m_membershipGrid->GetSelectedRows();
433 
434  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
435  {
436  if( !m_membershipGrid->IsRowShown( row ) )
437  continue;
438 
439  if( !aAssignAll && selectedRows.Index( row ) == wxNOT_FOUND )
440  continue;
441 
442  m_membershipGrid->SetCellValue( row, 1, m_assignNetClass->GetStringSelection() );
443  }
444 }
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 457 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().

458 {
459  return ValueFromString( m_Frame->GetUserUnits(), m_netclassGrid->GetCellValue( aRow, aCol ), true );
460 }
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:284
void PANEL_SETUP_NETCLASSES::ImportSettingsFrom ( BOARD aBoard)

Definition at line 554 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().

555 {
556  // Note: do not change the board, as we need to get the current nets from it for
557  // netclass memberships. All the netclass definitions and dimension lists are in
558  // the BOARD_DESIGN_SETTINGS.
559 
560  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
561 
562  m_BrdSettings = &aBoard->GetDesignSettings();
564 
565  m_netclassGrid->ForceRefresh();
566  m_membershipGrid->ForceRefresh();
567 
568  m_BrdSettings = savedSettings;
569 }
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
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 295 of file panel_setup_netclasses.cpp.

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

296 {
298  return;
299 
300  int row = m_netclassGrid->GetNumberRows();
301  m_netclassGrid->AppendRows();
302 
303  // Copy values of the default class:
304  for( int col = 1; col < m_netclassGrid->GetNumberCols(); col++ )
305  m_netclassGrid->SetCellValue( row, col, m_netclassGrid->GetCellValue( 0, col ) );
306 
307  m_netclassGrid->MakeCellVisible( row, 0 );
308  m_netclassGrid->SetGridCursor( row, 0 );
309 
310  m_netclassGrid->EnableCellEditControl( true );
311  m_netclassGrid->ShowCellEditControl();
312 
313  m_netclassesDirty = true;
314 }
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 283 of file panel_setup_netclasses.cpp.

References GRID_NAME, m_netclassesDirty, and validateNetclassName().

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

284 {
285  if( event.GetCol() == GRID_NAME )
286  {
287  if( validateNetclassName( event.GetRow(), event.GetString() ) )
288  m_netclassesDirty = true;
289  else
290  event.Veto();
291  }
292 }
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 317 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.

318 {
320  return;
321 
322  int curRow = m_netclassGrid->GetGridCursorRow();
323 
324  if( curRow < 0 )
325  return;
326  else if( curRow == 0 )
327  {
328  DisplayErrorMessage( this, _( "The default net class is required." ) );
329  return;
330  }
331 
332  // reset the net class to default for members of the removed class
333  wxString classname = m_netclassGrid->GetCellValue( curRow, GRID_NAME );
334 
335  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
336  {
337  if( m_membershipGrid->GetCellValue( row, 1 ) == classname )
338  m_membershipGrid->SetCellValue( row, 1, NETCLASS::Default );
339  }
340 
341  m_netclassGrid->DeleteRows( curRow, 1 );
342 
343  m_netclassGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
344  m_netclassGrid->SetGridCursor( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
345 
346  m_netclassesDirty = true;
347 }
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 385 of file panel_setup_netclasses.cpp.

References AdjustMembershipGridColumns().

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

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 365 of file panel_setup_netclasses.cpp.

References AdjustNetclassGridColumns().

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

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 447 of file panel_setup_netclasses.cpp.

References m_netclassesDirty, and rebuildNetclassDropdowns().

448 {
449  if( m_netclassesDirty )
450  {
452  m_netclassesDirty = false;
453  }
454 }
void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns ( )
private

Definition at line 178 of file panel_setup_netclasses.cpp.

References 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 {
180  wxArrayString netclassNames;
181 
182  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
183  {
184  wxString netclassName = m_netclassGrid->GetCellValue( ii, GRID_NAME );
185  if( !netclassName.IsEmpty() )
186  netclassNames.push_back( netclassName );
187  }
188 
189  wxGridCellAttr* attr = new wxGridCellAttr;
190  attr->SetEditor( new wxGridCellChoiceEditor( netclassNames ) );
191  m_membershipGrid->SetColAttr( 1, attr );
192 
193  m_assignNetClass->Set( netclassNames );
194 
195  netclassNames.Insert( wxEmptyString, 0 );
196  m_netClassFilter->Set( netclassNames );
197 }
bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow ( )
override

Definition at line 219 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().

220 {
221  if( !validateData() )
222  return false;
223 
224  NETCLASSES& netclasses = m_BrdSettings->m_NetClasses;
225 
226  // Remove all netclasses from board. We'll copy new list after
227  netclasses.Clear();
228 
229  // Copy the default NetClass:
231 
232  // Copy other NetClasses :
233  for( int row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
234  {
235  NETCLASSPTR nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row, GRID_NAME ) );
236 
237  if( m_BrdSettings->m_NetClasses.Add( nc ) )
239  }
240 
241  // Now read all nets and push them in the corresponding netclass net buffer
242  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
243  {
244  NETCLASSPTR nc = netclasses.Find( m_membershipGrid->GetCellValue( row, 1 ) );
245 
246  if( nc )
247  nc->Add( m_membershipGrid->GetCellValue( row, 0 ) );
248  }
249 
252 
253  return true;
254 }
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:146
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
Definition: netclass.cpp:160
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:284
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:104
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: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)
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
BOARD_DESIGN_SETTINGS * m_BrdSettings
NETINFO_LIST & GetNetInfo()
Definition: class_board.h:750
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 463 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().

464 {
466  return false;
467 
468  wxString msg;
469  int minViaDia = m_ConstraintsPanel->m_viaMinSize.GetValue();
470  int minViaDrill = m_ConstraintsPanel->m_viaMinDrill.GetValue();
471  int minUViaDia = m_ConstraintsPanel->m_uviaMinSize.GetValue();
472  int minUViaDrill = m_ConstraintsPanel->m_uviaMinDrill.GetValue();
473  int minTrackWidth = m_ConstraintsPanel->m_trackMinWidth.GetValue();
474 
475  // Test net class parameters.
476  for( int row = 0; row < m_netclassGrid->GetNumberRows(); row++ )
477  {
478  wxString netclassName = m_netclassGrid->GetCellValue( row, GRID_NAME );
479  netclassName.Trim( true );
480  netclassName.Trim( false );
481 
482  if( !validateNetclassName( row, netclassName, false ) )
483  return false;
484 
485  if( getNetclassValue( row, GRID_TRACKSIZE ) < minTrackWidth )
486  {
487  msg.Printf( _( "Track width less than minimum track width (%s)." ),
488  StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) );
489  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_TRACKSIZE );
490  return false;
491  }
492 
493  if( getNetclassValue( row, GRID_DIFF_PAIR_WIDTH ) < minTrackWidth )
494  {
495  msg.Printf( _( "Differential pair width less than minimum track width (%s)." ),
496  StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) );
498  return false;
499  }
500 
501  // Test vias
502  if( getNetclassValue( row, GRID_VIASIZE ) < minViaDia )
503  {
504  msg.Printf( _( "Via diameter less than minimum via diameter (%s)." ),
505  StringFromValue( m_Frame->GetUserUnits(), minViaDia, true, true ) );
506  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIASIZE );
507  return false;
508  }
509 
511  {
512  msg = _( "Via drill larger than via diameter." );
513  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIADRILL );
514  return false;
515  }
516 
517  if( getNetclassValue( row, GRID_VIADRILL ) < minViaDrill )
518  {
519  msg.Printf( _( "Via drill less than minimum via drill (%s)." ),
520  StringFromValue( m_Frame->GetUserUnits(), minViaDrill, true, true ) );
521  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_VIADRILL );
522  return false;
523  }
524 
525  // Test Micro vias
526  if( getNetclassValue( row, GRID_uVIASIZE ) < minUViaDia )
527  {
528  msg.Printf( _( "Microvia diameter less than minimum microvia diameter (%s)." ),
529  StringFromValue( m_Frame->GetUserUnits(), minUViaDia, true, true ) );
530  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIASIZE );
531  return false;
532  }
533 
535  {
536  msg = _( "Microvia drill larger than microvia diameter." );
537  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIADRILL );
538  return false;
539  }
540 
541  if( getNetclassValue( row, GRID_uVIADRILL ) < minUViaDrill )
542  {
543  msg.Printf( _( "Microvia drill less than minimum microvia drill (%s)." ),
544  StringFromValue( m_Frame->GetUserUnits(), minUViaDrill, true, true ) );
545  m_Parent->SetError( msg, this, m_netclassGrid, row, GRID_uVIADRILL );
546  return false;
547  }
548  }
549 
550  return true;
551 }
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:284
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 257 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().

258 {
259  aName.Trim( true );
260  aName.Trim( false );
261 
262  if( aName.IsEmpty() )
263  {
264  wxString msg = _( "Netclass must have a name." );
265  m_Parent->SetError( msg, this, m_netclassGrid, aRow, GRID_NAME );
266  return false;
267  }
268 
269  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
270  {
271  if( ii != aRow && m_netclassGrid->GetRowLabelValue( ii ).CmpNoCase( aName ) == 0 )
272  {
273  wxString msg = _( "Netclass name already in use." );
274  m_Parent->SetError( msg, this, m_netclassGrid, focusFirst ? aRow : ii, GRID_NAME );
275  return false;
276  }
277  }
278 
279  return true;
280 }
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: