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, NETCLASSES *aNetclasses, const std::vector< wxString > &aNetNames, bool isEEschema)
 
 ~PANEL_SETUP_NETCLASSES () override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
bool Validate () override
 
void ImportSettingsFrom (NETCLASSES *aBoard)
 

Protected Attributes

wxSplitterWindow * m_splitter
 
wxPanel * m_netclassesPane
 
WX_GRIDm_netclassGrid
 
wxBitmapButton * m_addButton
 
wxBitmapButton * m_removeButton
 
wxStaticText * m_colorDefaultHelpText
 
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 onmembershipPanelSize (wxSizeEvent &event) override
 
void OnUpdateUI (wxUpdateUIEvent &event) override
 
void OnNetclassGridCellChanging (wxGridEvent &event)
 
void OnNetclassGridMouseEvent (wxMouseEvent &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, const wxString &aName, bool focusFirst=true)
 
void rebuildNetclassDropdowns ()
 
void addNet (const wxString &netName, const wxString &netclass, bool aStale)
 
void doApplyFilters (bool aShowAll)
 
void doAssignments (bool aAssignAll)
 
void AdjustNetclassGridColumns (int aWidth)
 
void AdjustMembershipGridColumns (int aWidth)
 

Private Attributes

PAGED_DIALOGm_Parent
 
NETCLASSESm_netclasses
 
std::vector< wxString > m_netNames
 
int * m_originalColWidths
 
bool m_netclassesDirty
 
int m_hoveredCol
 

Detailed Description

Definition at line 35 of file panel_setup_netclasses.h.

Constructor & Destructor Documentation

◆ PANEL_SETUP_NETCLASSES()

PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES ( PAGED_DIALOG aParent,
NETCLASSES aNetclasses,
const std::vector< wxString > &  aNetNames,
bool  isEEschema 
)

Definition at line 73 of file panel_setup_netclasses.cpp.

75  :
77  m_Parent( aParent ),
78  m_netclasses( aNetclasses ),
79  m_netNames( aNetNames ),
80  m_hoveredCol( -1 )
81 {
82  if( g_lineStyleIcons.empty() )
83  {
85  g_lineStyleNames.push_back( _( "Solid" ) );
87  g_lineStyleNames.push_back( _( "Dashed" ) );
89  g_lineStyleNames.push_back( _( "Dotted" ) );
91  g_lineStyleNames.push_back( _( "Dash-Dot" ) );
92  }
93 
94  m_netclassesDirty = true;
95 
96  // Prevent Size events from firing before we are ready
97  Freeze();
98  m_netclassGrid->BeginBatch();
99  m_membershipGrid->BeginBatch();
100 
101  m_originalColWidths = new int[ m_netclassGrid->GetNumberCols() ];
102  // Calculate a min best size to handle longest usual numeric values:
103  int min_best_width = m_netclassGrid->GetTextExtent( "555,555555 mils" ).x;
104 
105  for( int i = 0; i < m_netclassGrid->GetNumberCols(); ++i )
106  {
107  // We calculate the column min size only from texts sizes, not using the initial col width
108  // as this initial width is sometimes strange depending on the language (wxGrid bug?)
109  int min_width = m_netclassGrid->GetVisibleWidth( i, true, true, false );
110 
111  if( i == GRID_LINESTYLE )
112  min_best_width *= 1.5;
113 
114  m_netclassGrid->SetColMinimalWidth( i, min_width );
115 
116  // We use a "best size" >= min_best_width
117  m_originalColWidths[ i ] = std::max( min_width, min_best_width );
118  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
119  }
120 
121  if( aIsEEschema )
122  {
123  for( int i = GRID_FIRST_PCBNEW; i < GRID_FIRST_EESCHEMA; ++i )
124  {
125  m_netclassGrid->HideCol( i );
126  m_originalColWidths[ i ] = 0;
127  }
128 
129  wxGridCellAttr* attr = new wxGridCellAttr;
130  attr->SetRenderer( new GRID_CELL_COLOR_RENDERER( aParent ) );
131  attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( aParent, m_netclassGrid ) );
132  m_netclassGrid->SetColAttr( GRID_SCHEMATIC_COLOR, attr );
133 
134  attr = new wxGridCellAttr;
137  m_netclassGrid->SetColAttr( GRID_LINESTYLE, attr );
138 
139  m_colorDefaultHelpText->SetFont( KIUI::GetInfoFont( this ).Italic() );
140  }
141  else
142  {
143  for( int i = GRID_FIRST_EESCHEMA; i < GRID_END; ++i )
144  {
145  m_netclassGrid->HideCol( i );
146  m_originalColWidths[ i ] = 0;
147  }
148 
149  m_colorDefaultHelpText->Hide();
150  }
151 
152  // Be sure the column labels are readable
154 
155  // Membership combobox editors require a bit more room, so increase the row size of
156  // all our grids for consistency
157  m_netclassGrid->SetDefaultRowSize( m_netclassGrid->GetDefaultRowSize() + 4 );
158  m_membershipGrid->SetDefaultRowSize( m_membershipGrid->GetDefaultRowSize() + 4 );
159 
160  m_netclassGrid->PushEventHandler( new GRID_TRICKS( m_netclassGrid ) );
161  m_membershipGrid->PushEventHandler( new GRID_TRICKS( m_membershipGrid ) );
162 
163  m_netclassGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
164  m_membershipGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
165 
166  // Set up the net name column of the netclass membership grid to read-only
167  wxGridCellAttr* attr = new wxGridCellAttr;
168  attr->SetReadOnly( true );
169  attr->SetRenderer( new GRID_CELL_ESCAPED_TEXT_RENDERER );
170  m_membershipGrid->SetColAttr( 0, attr );
171 
172  COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
173  m_splitter->SetSashPosition( cfg->m_NetclassPanel.sash_pos );
174 
175  m_addButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
177 
178  // wxFormBuilder doesn't include this event...
179  m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING,
181  nullptr, this );
182 
183  // Handle tooltips for grid
184  m_netclassGrid->GetGridColLabelWindow()->Bind( wxEVT_MOTION,
186  this );
187 
188  m_netclassGrid->EndBatch();
189  m_membershipGrid->EndBatch();
190  Thaw();
191 }
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:141
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:55
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
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:246
void OnNetclassGridMouseEvent(wxMouseEvent &event)
std::vector< wxString > m_netNames
std::vector< BITMAPS > g_lineStyleIcons
wxTreebook * GetTreebook()
Definition: paged_dialog.h:37
NETCLASS_PANEL m_NetclassPanel
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:291
void OnNetclassGridCellChanging(wxGridEvent &event)
#define _(s)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
wxArrayString g_lineStyleNames
A text renderer that can unescape text for display This is useful where it's desired to keep the unde...

References _, WX_GRID::EnsureColLabelsVisible(), g_lineStyleIcons, g_lineStyleNames, KIUI::GetInfoFont(), WX_GRID::GetVisibleWidth(), GRID_END, GRID_FIRST_EESCHEMA, GRID_FIRST_PCBNEW, GRID_LINESTYLE, GRID_SCHEMATIC_COLOR, KiBitmap(), PANEL_SETUP_NETCLASSES_BASE::m_addButton, PANEL_SETUP_NETCLASSES_BASE::m_colorDefaultHelpText, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, m_netclassesDirty, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, COMMON_SETTINGS::m_NetclassPanel, m_originalColWidths, PANEL_SETUP_NETCLASSES_BASE::m_removeButton, PANEL_SETUP_NETCLASSES_BASE::m_splitter, OnNetclassGridCellChanging(), OnNetclassGridMouseEvent(), Pgm(), COMMON_SETTINGS::NETCLASS_PANEL::sash_pos, small_plus, small_trash, stroke_dash, stroke_dashdot, stroke_dot, and stroke_solid.

◆ ~PANEL_SETUP_NETCLASSES()

PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES ( )
override

Definition at line 194 of file panel_setup_netclasses.cpp.

195 {
196  COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
197  cfg->m_NetclassPanel.sash_pos = m_splitter->GetSashPosition();
198 
199  delete [] m_originalColWidths;
200 
201  // Delete the GRID_TRICKS.
202  m_netclassGrid->PopEventHandler( true );
203  m_membershipGrid->PopEventHandler( true );
204 
205  m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING,
207  nullptr, this );
208 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
NETCLASS_PANEL m_NetclassPanel
void OnNetclassGridCellChanging(wxGridEvent &event)

References PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, COMMON_SETTINGS::m_NetclassPanel, m_originalColWidths, PANEL_SETUP_NETCLASSES_BASE::m_splitter, OnNetclassGridCellChanging(), Pgm(), and COMMON_SETTINGS::NETCLASS_PANEL::sash_pos.

Member Function Documentation

◆ addNet()

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

Definition at line 286 of file panel_setup_netclasses.cpp.

288 {
289  int i = m_membershipGrid->GetNumberRows();
290 
291  m_membershipGrid->AppendRows( 1 );
292 
293  m_membershipGrid->SetCellValue( i, 0, netName );
294 
295  if( aStale )
296  {
297  wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
298  m_membershipGrid->SetCellTextColour( i, 0, color );
299  }
300 
301  if( netclass.IsEmpty() )
302  m_membershipGrid->SetCellValue( i, 1, NETCLASS::Default );
303  else
304  m_membershipGrid->SetCellValue( i, 1, netclass );
305 }
int color
Definition: DXF_plotter.cpp:57
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49

References color, NETCLASS::Default, and PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid.

Referenced by TransferDataToWindow().

◆ AdjustMembershipGridColumns()

void PANEL_SETUP_NETCLASSES::AdjustMembershipGridColumns ( int  aWidth)
private

Definition at line 586 of file panel_setup_netclasses.cpp.

587 {
588  // Account for scroll bars
589  aWidth -= ( m_membershipGrid->GetSize().x - m_membershipGrid->GetClientSize().x );
590 
591  // Set className column width to original className width from netclasses grid
592  int classNameWidth = m_originalColWidths[ 0 ];
593  m_membershipGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
594  m_membershipGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
595 }

References PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, and m_originalColWidths.

Referenced by OnSizeMembershipGrid().

◆ AdjustNetclassGridColumns()

void PANEL_SETUP_NETCLASSES::AdjustNetclassGridColumns ( int  aWidth)
private

Definition at line 563 of file panel_setup_netclasses.cpp.

564 {
565  // Account for scroll bars
566  aWidth -= ( m_netclassGrid->GetSize().x - m_netclassGrid->GetClientSize().x );
567 
568  for( int i = 1; i < m_netclassGrid->GetNumberCols(); i++ )
569  {
570  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
571  aWidth -= m_originalColWidths[ i ];
572  }
573 
574  m_netclassGrid->SetColSize( 0, std::max( aWidth - 2, m_originalColWidths[ 0 ] ) );
575 }

References PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, and m_originalColWidths.

Referenced by OnSizeNetclassGrid().

◆ doApplyFilters()

void PANEL_SETUP_NETCLASSES::doApplyFilters ( bool  aShowAll)
private

Definition at line 624 of file panel_setup_netclasses.cpp.

625 {
627  return;
628 
629  wxString netClassFilter = m_netClassFilter->GetStringSelection();
630  wxString netFilter = m_netNameFilter->GetValue().MakeLower();
631 
632  if( !netFilter.IsEmpty() )
633  netFilter = wxT( "*" ) + netFilter + wxT( "*" );
634 
635  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
636  {
637  wxString net = m_membershipGrid->GetCellValue( row, 0 );
638  wxString netClass = m_membershipGrid->GetCellValue( row, 1 );
639  bool show = true;
640 
641  if( !aShowAll )
642  {
643  if( !netFilter.IsEmpty() && !net.MakeLower().Matches( netFilter ) )
644  show = false;
645 
646  if( !netClassFilter.IsEmpty() && netClass != netClassFilter )
647  show = false;
648  }
649 
650  if( show )
651  m_membershipGrid->ShowRow( row );
652  else
653  m_membershipGrid->HideRow( row );
654  }
655 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:190

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

659 {
661  return;
662 
663  wxArrayInt selectedRows = m_membershipGrid->GetSelectedRows();
664 
665  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
666  {
667  if( !m_membershipGrid->IsRowShown( row ) )
668  continue;
669 
670  if( !aAssignAll && selectedRows.Index( row ) == wxNOT_FOUND )
671  continue;
672 
673  m_membershipGrid->SetCellValue( row, 1, m_assignNetClass->GetStringSelection() );
674  }
675 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:190

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

Referenced by OnAssignAll(), and OnAssignSelected().

◆ ImportSettingsFrom()

void PANEL_SETUP_NETCLASSES::ImportSettingsFrom ( NETCLASSES aBoard)

◆ OnAddNetclassClick()

void PANEL_SETUP_NETCLASSES::OnAddNetclassClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 506 of file panel_setup_netclasses.cpp.

507 {
509  return;
510 
511  int row = m_netclassGrid->GetNumberRows();
512  m_netclassGrid->AppendRows();
513 
514  // Copy values of the default class:
515  for( int col = 1; col < m_netclassGrid->GetNumberCols(); col++ )
516  m_netclassGrid->SetCellValue( row, col, m_netclassGrid->GetCellValue( 0, col ) );
517 
518  m_netclassGrid->MakeCellVisible( row, 0 );
519  m_netclassGrid->SetGridCursor( row, 0 );
520 
521  m_netclassGrid->EnableCellEditControl( true );
522  m_netclassGrid->ShowCellEditControl();
523 
524  m_netclassesDirty = true;
525 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:190

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 59 of file panel_setup_netclasses.h.

59 { 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 60 of file panel_setup_netclasses.h.

60 { 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 61 of file panel_setup_netclasses.h.

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

References doAssignments().

◆ onmembershipPanelSize()

void PANEL_SETUP_NETCLASSES::onmembershipPanelSize ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 598 of file panel_setup_netclasses.cpp.

599 {
600  // When a class name choice widget is selected (activated), in
601  // wxGrid m_membershipGrid, resizing its wxGrid parent is not taken in account
602  // by the widget until it is deselected and stay in the old position.
603  // So we deselect it if this is the case
604  // Note also this is made here, not in OnSizeMembershipGrid because on Linux
605  // there are a lot of wxSizeEvent send to m_membershipGrid when opening a choice widget
606  int c_row = m_membershipGrid->GetGridCursorRow();
607  int c_col = m_membershipGrid->GetGridCursorCol();
608 
609  if( c_row >= 0 && c_col == 1 ) // this means the class name choice widget is selected (opened)
610  m_membershipGrid->SetGridCursor( c_row, 0 ); // Close it
611 
612  event.Skip();
613 }

References PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid.

◆ OnNetclassGridCellChanging()

void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ( wxGridEvent &  event)
private

Definition at line 428 of file panel_setup_netclasses.cpp.

429 {
430  if( event.GetCol() == GRID_NAME )
431  {
432  if( validateNetclassName( event.GetRow(), event.GetString() ) )
433  {
434  wxString oldName = m_netclassGrid->GetCellValue( event.GetRow(), GRID_NAME );
435  wxString newName = event.GetString();
436 
437  if( !oldName.IsEmpty() )
438  {
439  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
440  {
441  if( m_membershipGrid->GetCellValue( row, 1 ) == oldName )
442  m_membershipGrid->SetCellValue( row, 1, newName );
443  }
444  }
445 
446  m_netclassesDirty = true;
447  }
448  else
449  {
450  event.Veto();
451  }
452  }
453 }
bool validateNetclassName(int aRow, const wxString &aName, bool focusFirst=true)

References GRID_NAME, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, m_netclassesDirty, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, and validateNetclassName().

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

◆ OnNetclassGridMouseEvent()

void PANEL_SETUP_NETCLASSES::OnNetclassGridMouseEvent ( wxMouseEvent &  event)
private

Definition at line 456 of file panel_setup_netclasses.cpp.

457 {
458  int col = m_netclassGrid->XToCol( aEvent.GetPosition().x );
459 
460  if( aEvent.Moving() || aEvent.Entering() )
461  {
462  aEvent.Skip();
463 
464  if( col == wxNOT_FOUND )
465  {
466  m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
467  return;
468  }
469 
470  if( col == m_hoveredCol )
471  return;
472 
473  m_hoveredCol = col;
474 
475  wxString tip;
476 
477  switch( col )
478  {
479  case GRID_CLEARANCE: tip = _( "Minimum copper clearance" ); break;
480  case GRID_TRACKSIZE: tip = _( "Minimum track width" ); break;
481  case GRID_VIASIZE: tip = _( "Via pad diameter" ); break;
482  case GRID_VIADRILL: tip = _( "Via plated hole diameter" ); break;
483  case GRID_uVIASIZE: tip = _( "Microvia pad diameter" ); break;
484  case GRID_uVIADRILL: tip = _( "Microvia plated hole diameter" ); break;
485  case GRID_DIFF_PAIR_WIDTH: tip = _( "Differential pair track width" ); break;
486  case GRID_DIFF_PAIR_GAP: tip = _( "Differential pair gap" ); break;
487  case GRID_WIREWIDTH: tip = _( "Schematic wire thickness" ); break;
488  case GRID_BUSWIDTH: tip = _( "Bus wire thickness" ); break;
489  case GRID_SCHEMATIC_COLOR: tip = _( "Schematic wire color" ); break;
490  case GRID_LINESTYLE: tip = _( "Schematic wire line style" ); break;
491  }
492 
493  m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
494  m_netclassGrid->GetGridColLabelWindow()->SetToolTip( tip );
495  }
496  else if( aEvent.Leaving() )
497  {
498  m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
499  aEvent.Skip();
500  }
501 
502  aEvent.Skip();
503 }
#define _(s)

References _, GRID_BUSWIDTH, GRID_CLEARANCE, GRID_DIFF_PAIR_GAP, GRID_DIFF_PAIR_WIDTH, GRID_LINESTYLE, GRID_SCHEMATIC_COLOR, GRID_TRACKSIZE, GRID_uVIADRILL, GRID_uVIASIZE, GRID_VIADRILL, GRID_VIASIZE, GRID_WIREWIDTH, m_hoveredCol, and PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid.

Referenced by PANEL_SETUP_NETCLASSES().

◆ OnRemoveNetclassClick()

void PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 528 of file panel_setup_netclasses.cpp.

529 {
531  return;
532 
533  int curRow = m_netclassGrid->GetGridCursorRow();
534 
535  if( curRow < 0 )
536  {
537  return;
538  }
539  else if( curRow == 0 )
540  {
541  DisplayErrorMessage( this, _( "The default net class is required." ) );
542  return;
543  }
544 
545  // reset the net class to default for members of the removed class
546  wxString classname = m_netclassGrid->GetCellValue( curRow, GRID_NAME );
547 
548  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
549  {
550  if( m_membershipGrid->GetCellValue( row, 1 ) == classname )
551  m_membershipGrid->SetCellValue( row, 1, NETCLASS::Default );
552  }
553 
554  m_netclassGrid->DeleteRows( curRow, 1 );
555 
556  m_netclassGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
557  m_netclassGrid->SetGridCursor( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
558 
559  m_netclassesDirty = true;
560 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:284
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49
#define _(s)
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:190

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

◆ OnShowAll()

void PANEL_SETUP_NETCLASSES::OnShowAll ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 58 of file panel_setup_netclasses.h.

58 { 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 616 of file panel_setup_netclasses.cpp.

617 {
618  AdjustMembershipGridColumns( event.GetSize().GetX() );
619 
620  event.Skip();
621 }
void AdjustMembershipGridColumns(int aWidth)

References AdjustMembershipGridColumns().

◆ OnSizeNetclassGrid()

void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 578 of file panel_setup_netclasses.cpp.

579 {
580  AdjustNetclassGridColumns( event.GetSize().GetX() );
581 
582  event.Skip();
583 }
void AdjustNetclassGridColumns(int aWidth)

References AdjustNetclassGridColumns().

◆ OnUpdateUI()

void PANEL_SETUP_NETCLASSES::OnUpdateUI ( wxUpdateUIEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 678 of file panel_setup_netclasses.cpp.

679 {
680  if( m_netclassesDirty )
681  {
683  m_netclassesDirty = false;
684  }
685 }

References m_netclassesDirty, and rebuildNetclassDropdowns().

◆ rebuildNetclassDropdowns()

void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns ( )
private

Definition at line 311 of file panel_setup_netclasses.cpp.

312 {
314 
315  wxArrayString netclassNames;
316 
317  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
318  {
319  wxString netclassName = m_netclassGrid->GetCellValue( ii, GRID_NAME );
320 
321  if( !netclassName.IsEmpty() )
322  netclassNames.push_back( netclassName );
323  }
324 
325  wxGridCellAttr* attr = new wxGridCellAttr;
326  attr->SetEditor( new wxGridCellChoiceEditor( netclassNames ) );
327  m_membershipGrid->SetColAttr( 1, attr );
328 
329  m_assignNetClass->Set( netclassNames );
330 
331  netclassNames.Insert( wxEmptyString, 0 );
332  m_netClassFilter->Set( netclassNames );
333 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:190

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

◆ TransferDataFromWindow()

bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow ( )
override

Definition at line 360 of file panel_setup_netclasses.cpp.

361 {
362  if( !Validate() )
363  return false;
364 
365  m_netclasses->Clear();
366 
367  // Copy the default NetClass:
369 
370  // Copy other NetClasses:
371  for( int row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
372  {
373  NETCLASSPTR nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row,
374  GRID_NAME ) );
375 
376  if( m_netclasses->Add( nc ) )
378  }
379 
380  // Now read all nets and push them in the corresponding netclass net buffer
381  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
382  {
383  const wxString& netname = m_membershipGrid->GetCellValue( row, 0 );
384  const wxString& classname = m_membershipGrid->GetCellValue( row, 1 );
385 
386  if( classname != NETCLASS::Default )
387  {
388  const NETCLASSPTR& nc = m_netclasses->Find( classname );
389 
390  if( nc )
391  nc->Add( netname );
392  }
393  }
394 
395  return true;
396 }
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:119
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49
static void gridRowToNetclass(EDA_UNITS aUnits, wxGrid *grid, int row, const NETCLASSPTR &nc)
bool Add(const NETCLASSPTR &aNetclass)
Add aNetclass and puts it into this NETCLASSES container.
Definition: netclass.cpp:90
void Clear()
Destroy any contained NETCLASS instances except the default one, and clears any members from the defa...
Definition: netclass.h:228
NETCLASSPTR GetDefault() const
Definition: netclass.h:253

References NETCLASSES::Add(), NETCLASSES::Clear(), NETCLASS::Default, NETCLASSES::Find(), NETCLASSES::GetDefault(), DIALOG_SHIM::GetUserUnits(), GRID_NAME, gridRowToNetclass(), PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, m_netclasses, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_Parent, and Validate().

◆ TransferDataToWindow()

bool PANEL_SETUP_NETCLASSES::TransferDataToWindow ( )
override

Definition at line 236 of file panel_setup_netclasses.cpp.

237 {
238  std::map<wxString, wxString> netToNetclassMap;
239  std::map<wxString, wxString> staleNetMap;
240 
241  for( const wxString& candidate : m_netNames )
242  netToNetclassMap[ candidate ] = wxEmptyString;
243 
245  m_netclassGrid->AppendRows((int) m_netclasses->GetCount() + 1 ); // + 1 for default netclass
246 
247  // enter the Default NETCLASS.
249 
250  // make the Default NETCLASS name read-only
251  wxGridCellAttr* cellAttr = m_netclassGrid->GetOrCreateCellAttr( 0, GRID_NAME );
252  cellAttr->SetReadOnly();
253  cellAttr->DecRef();
254 
255  // enter other netclasses
256  int row = 1;
257 
258  for( NETCLASSES::iterator i = m_netclasses->begin(); i != m_netclasses->end(); ++i, ++row )
259  {
260  NETCLASSPTR netclass = i->second;
261 
263 
264  for( const wxString& net : *netclass )
265  {
266  if( netToNetclassMap.count( net ) )
267  netToNetclassMap[ net ] = i->second->GetName();
268  else
269  staleNetMap[ net ] = i->second->GetName();
270  }
271  }
272 
274 
275  // add currently-assigned and candidate netnames to membership lists
276  for( const std::pair<const wxString, wxString>& ii : netToNetclassMap )
277  addNet( ii.first, ii.second, false );
278 
279  for( const std::pair<const wxString, wxString>& ii : staleNetMap )
280  addNet( ii.first, ii.second, true );
281 
282  return true;
283 }
iterator end()
Definition: netclass.h:236
void addNet(const wxString &netName, const wxString &netclass, bool aStale)
std::vector< wxString > m_netNames
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:119
NETCLASS_MAP::iterator iterator
Definition: netclass.h:234
iterator begin()
Definition: netclass.h:235
unsigned GetCount() const
Definition: netclass.h:245
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
Definition: wx_grid.h:106
static void netclassToGridRow(EDA_UNITS aUnits, wxGrid *aGrid, int aRow, const NETCLASSPTR &nc)
NETCLASSPTR GetDefault() const
Definition: netclass.h:253

References addNet(), NETCLASSES::begin(), WX_GRID::ClearRows(), NETCLASSES::end(), NETCLASSES::GetCount(), NETCLASSES::GetDefault(), DIALOG_SHIM::GetUserUnits(), GRID_NAME, PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid, m_netclasses, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_netNames, m_Parent, and netclassToGridRow().

Referenced by ImportSettingsFrom().

◆ Validate()

bool PANEL_SETUP_NETCLASSES::Validate ( )
override

Definition at line 688 of file panel_setup_netclasses.cpp.

689 {
691  return false;
692 
693  wxString msg;
694 
695  // Test net class parameters.
696  for( int row = 0; row < m_netclassGrid->GetNumberRows(); row++ )
697  {
698  wxString netclassName = m_netclassGrid->GetCellValue( row, GRID_NAME );
699  netclassName.Trim( true );
700  netclassName.Trim( false );
701 
702  if( !validateNetclassName( row, netclassName, false ) )
703  return false;
704  }
705 
706  return true;
707 }
bool validateNetclassName(int aRow, const wxString &aName, bool focusFirst=true)
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:190

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

Referenced by TransferDataFromWindow().

◆ validateNetclassName()

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

Definition at line 399 of file panel_setup_netclasses.cpp.

401 {
402  wxString tmp = aName;
403 
404  tmp.Trim( true );
405  tmp.Trim( false );
406 
407  if( tmp.IsEmpty() )
408  {
409  wxString msg = _( "Netclass must have a name." );
410  m_Parent->SetError( msg, this, m_netclassGrid, aRow, GRID_NAME );
411  return false;
412  }
413 
414  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
415  {
416  if( ii != aRow && m_netclassGrid->GetCellValue( ii, GRID_NAME ).CmpNoCase( tmp ) == 0 )
417  {
418  wxString msg = _( "Netclass name already in use." );
419  m_Parent->SetError( msg, this, m_netclassGrid, focusFirst ? aRow : ii, GRID_NAME );
420  return false;
421  }
422  }
423 
424  return true;
425 }
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
#define _(s)

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

Referenced by OnNetclassGridCellChanging(), and Validate().

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_colorDefaultHelpText

wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_colorDefaultHelpText
protectedinherited

◆ m_filterLabel

wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_filterLabel
protectedinherited

◆ m_filterNetsButton

wxButton* PANEL_SETUP_NETCLASSES_BASE::m_filterNetsButton
protectedinherited

◆ m_hoveredCol

int PANEL_SETUP_NETCLASSES::m_hoveredCol
private

Definition at line 80 of file panel_setup_netclasses.h.

Referenced by OnNetclassGridMouseEvent().

◆ m_membershipGrid

◆ m_membershipPane

wxPanel* PANEL_SETUP_NETCLASSES_BASE::m_membershipPane
protectedinherited

◆ m_ncfilterLabel

wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_ncfilterLabel
protectedinherited

◆ m_netclasses

NETCLASSES* PANEL_SETUP_NETCLASSES::m_netclasses
private

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

std::vector<wxString> PANEL_SETUP_NETCLASSES::m_netNames
private

Definition at line 76 of file panel_setup_netclasses.h.

Referenced by TransferDataToWindow().

◆ m_originalColWidths

int* PANEL_SETUP_NETCLASSES::m_originalColWidths
private

◆ m_Parent

PAGED_DIALOG* PANEL_SETUP_NETCLASSES::m_Parent
private

◆ m_removeButton

wxBitmapButton* PANEL_SETUP_NETCLASSES_BASE::m_removeButton
protectedinherited

◆ m_showAllButton

wxButton* PANEL_SETUP_NETCLASSES_BASE::m_showAllButton
protectedinherited

◆ m_splitter

wxSplitterWindow* PANEL_SETUP_NETCLASSES_BASE::m_splitter
protectedinherited

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