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, EDA_DRAW_FRAME *aFrame, 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
 
void onUnitsChanged (wxCommandEvent &aEvent)
 
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

EDA_DRAW_FRAMEm_frame
 
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,
EDA_DRAW_FRAME aFrame,
NETCLASSES aNetclasses,
const std::vector< wxString > &  aNetNames,
bool  isEEschema 
)

Definition at line 73 of file panel_setup_netclasses.cpp.

76  :
78  m_frame( aFrame ),
79  m_parent( aParent ),
80  m_netclasses( aNetclasses ),
81  m_netNames( aNetNames ),
82  m_hoveredCol( -1 )
83 {
84  // Clear and re-load each time. Language (or darkmode) might have changed.
85  g_lineStyleIcons.clear();
86  g_lineStyleNames.clear();
87 
89  g_lineStyleNames.push_back( _( "Solid" ) );
91  g_lineStyleNames.push_back( _( "Dashed" ) );
93  g_lineStyleNames.push_back( _( "Dotted" ) );
95  g_lineStyleNames.push_back( _( "Dash-Dot" ) );
96 
97  m_netclassesDirty = true;
98 
99  // Prevent Size events from firing before we are ready
100  Freeze();
101  m_netclassGrid->BeginBatch();
102  m_membershipGrid->BeginBatch();
103 
104  m_originalColWidths = new int[ m_netclassGrid->GetNumberCols() ];
105  // Calculate a min best size to handle longest usual numeric values:
106  int min_best_width = m_netclassGrid->GetTextExtent( "555,555555 mils" ).x;
107 
108  for( int i = 0; i < m_netclassGrid->GetNumberCols(); ++i )
109  {
110  // We calculate the column min size only from texts sizes, not using the initial col width
111  // as this initial width is sometimes strange depending on the language (wxGrid bug?)
112  int min_width = m_netclassGrid->GetVisibleWidth( i, true, true, false );
113 
114  if( i == GRID_LINESTYLE )
115  min_best_width *= 1.5;
116 
117  m_netclassGrid->SetColMinimalWidth( i, min_width );
118 
119  // We use a "best size" >= min_best_width
120  m_originalColWidths[ i ] = std::max( min_width, min_best_width );
121  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
122  }
123 
124  if( aIsEEschema )
125  {
126  for( int i = GRID_FIRST_PCBNEW; i < GRID_FIRST_EESCHEMA; ++i )
127  {
128  m_netclassGrid->HideCol( i );
129  m_originalColWidths[ i ] = 0;
130  }
131 
132  wxGridCellAttr* attr = new wxGridCellAttr;
133  attr->SetRenderer( new GRID_CELL_COLOR_RENDERER( aParent ) );
134  attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( aParent, m_netclassGrid ) );
135  m_netclassGrid->SetColAttr( GRID_SCHEMATIC_COLOR, attr );
136 
137  attr = new wxGridCellAttr;
140  m_netclassGrid->SetColAttr( GRID_LINESTYLE, attr );
141 
142  m_colorDefaultHelpText->SetFont( KIUI::GetInfoFont( this ).Italic() );
143  }
144  else
145  {
146  for( int i = GRID_FIRST_EESCHEMA; i < GRID_END; ++i )
147  {
148  m_netclassGrid->HideCol( i );
149  m_originalColWidths[ i ] = 0;
150  }
151 
152  m_colorDefaultHelpText->Hide();
153  }
154 
155  // Be sure the column labels are readable
157 
158  // Membership combobox editors require a bit more room, so increase the row size of
159  // all our grids for consistency
160  m_netclassGrid->SetDefaultRowSize( m_netclassGrid->GetDefaultRowSize() + 4 );
161  m_membershipGrid->SetDefaultRowSize( m_membershipGrid->GetDefaultRowSize() + 4 );
162 
163  m_netclassGrid->PushEventHandler( new GRID_TRICKS( m_netclassGrid ) );
164  m_membershipGrid->PushEventHandler( new GRID_TRICKS( m_membershipGrid ) );
165 
166  m_netclassGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
167  m_membershipGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
168 
169  // Set up the net name column of the netclass membership grid to read-only
170  wxGridCellAttr* attr = new wxGridCellAttr;
171  attr->SetReadOnly( true );
172  attr->SetRenderer( new GRID_CELL_ESCAPED_TEXT_RENDERER );
173  m_membershipGrid->SetColAttr( 0, attr );
174 
175  COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
176  m_splitter->SetSashPosition( cfg->m_NetclassPanel.sash_pos );
177 
178  m_addButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
180 
181  // wxFormBuilder doesn't include this event...
182  m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING,
184  nullptr, this );
185 
186  // Handle tooltips for grid
187  m_netclassGrid->GetGridColLabelWindow()->Bind( wxEVT_MOTION,
189  this );
190 
191  m_frame->Bind( UNITS_CHANGED, &PANEL_SETUP_NETCLASSES::onUnitsChanged, this );
192 
193  m_netclassGrid->EndBatch();
194  m_membershipGrid->EndBatch();
195  Thaw();
196 }
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144
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
void onUnitsChanged(wxCommandEvent &aEvent)
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:282
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:327
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, m_frame, 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(), onUnitsChanged(), 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 199 of file panel_setup_netclasses.cpp.

200 {
201  COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
202  cfg->m_NetclassPanel.sash_pos = m_splitter->GetSashPosition();
203 
204  delete [] m_originalColWidths;
205 
206  // Delete the GRID_TRICKS.
207  m_netclassGrid->PopEventHandler( true );
208  m_membershipGrid->PopEventHandler( true );
209 
210  m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING,
212  nullptr, this );
213 
214  m_frame->Unbind( UNITS_CHANGED, &PANEL_SETUP_NETCLASSES::onUnitsChanged, this );
215 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
void onUnitsChanged(wxCommandEvent &aEvent)
NETCLASS_PANEL m_NetclassPanel
void OnNetclassGridCellChanging(wxGridEvent &event)

References m_frame, 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(), onUnitsChanged(), 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 315 of file panel_setup_netclasses.cpp.

317 {
318  int i = m_membershipGrid->GetNumberRows();
319 
320  m_membershipGrid->AppendRows( 1 );
321 
322  m_membershipGrid->SetCellValue( i, 0, netName );
323 
324  if( aStale )
325  {
326  wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
327  m_membershipGrid->SetCellTextColour( i, 0, color );
328  }
329 
330  if( netclass.IsEmpty() )
331  m_membershipGrid->SetCellValue( i, 1, NETCLASS::Default );
332  else
333  m_membershipGrid->SetCellValue( i, 1, netclass );
334 }
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 617 of file panel_setup_netclasses.cpp.

618 {
619  // Account for scroll bars
620  aWidth -= ( m_membershipGrid->GetSize().x - m_membershipGrid->GetClientSize().x );
621 
622  // Set className column width to original className width from netclasses grid
623  int classNameWidth = m_originalColWidths[ 0 ];
624  m_membershipGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
625  m_membershipGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
626 }

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

595 {
596  // Account for scroll bars
597  aWidth -= ( m_netclassGrid->GetSize().x - m_netclassGrid->GetClientSize().x );
598 
599  for( int i = 1; i < m_netclassGrid->GetNumberCols(); i++ )
600  {
601  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
602  aWidth -= m_originalColWidths[ i ];
603  }
604 
605  m_netclassGrid->SetColSize( 0, std::max( aWidth - 2, m_originalColWidths[ 0 ] ) );
606 }

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

656 {
658  return;
659 
660  wxString netClassFilter = m_netClassFilter->GetStringSelection();
661  wxString netFilter = m_netNameFilter->GetValue().MakeLower();
662 
663  if( !netFilter.IsEmpty() )
664  netFilter = wxT( "*" ) + netFilter + wxT( "*" );
665 
666  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
667  {
668  wxString net = m_membershipGrid->GetCellValue( row, 0 );
669  wxString netClass = m_membershipGrid->GetCellValue( row, 1 );
670  bool show = true;
671 
672  if( !aShowAll )
673  {
674  if( !netFilter.IsEmpty() && !net.MakeLower().Matches( netFilter ) )
675  show = false;
676 
677  if( !netClassFilter.IsEmpty() && netClass != netClassFilter )
678  show = false;
679  }
680 
681  if( show )
682  m_membershipGrid->ShowRow( row );
683  else
684  m_membershipGrid->HideRow( row );
685  }
686 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226

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

690 {
692  return;
693 
694  wxArrayInt selectedRows = m_membershipGrid->GetSelectedRows();
695 
696  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
697  {
698  if( !m_membershipGrid->IsRowShown( row ) )
699  continue;
700 
701  if( !aAssignAll && selectedRows.Index( row ) == wxNOT_FOUND )
702  continue;
703 
704  m_membershipGrid->SetCellValue( row, 1, m_assignNetClass->GetStringSelection() );
705  }
706 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226

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

538 {
540  return;
541 
542  int row = m_netclassGrid->GetNumberRows();
543  m_netclassGrid->AppendRows();
544 
545  // Copy values of the default class:
546  for( int col = 1; col < m_netclassGrid->GetNumberCols(); col++ )
547  m_netclassGrid->SetCellValue( row, col, m_netclassGrid->GetCellValue( 0, col ) );
548 
549  m_netclassGrid->MakeCellVisible( row, 0 );
550  m_netclassGrid->SetGridCursor( row, 0 );
551 
552  m_netclassGrid->EnableCellEditControl( true );
553  m_netclassGrid->ShowCellEditControl();
554 
555  m_netclassesDirty = true;
556 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226

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

630 {
631  // When a class name choice widget is selected (activated), in
632  // wxGrid m_membershipGrid, resizing its wxGrid parent is not taken in account
633  // by the widget until it is deselected and stay in the old position.
634  // So we deselect it if this is the case
635  // Note also this is made here, not in OnSizeMembershipGrid because on Linux
636  // there are a lot of wxSizeEvent send to m_membershipGrid when opening a choice widget
637  int c_row = m_membershipGrid->GetGridCursorRow();
638  int c_col = m_membershipGrid->GetGridCursorCol();
639 
640  if( c_row >= 0 && c_col == 1 ) // this means the class name choice widget is selected (opened)
641  m_membershipGrid->SetGridCursor( c_row, 0 ); // Close it
642 
643  event.Skip();
644 }

References PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid.

◆ OnNetclassGridCellChanging()

void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ( wxGridEvent &  event)
private

Definition at line 459 of file panel_setup_netclasses.cpp.

460 {
461  if( event.GetCol() == GRID_NAME )
462  {
463  if( validateNetclassName( event.GetRow(), event.GetString() ) )
464  {
465  wxString oldName = m_netclassGrid->GetCellValue( event.GetRow(), GRID_NAME );
466  wxString newName = event.GetString();
467 
468  if( !oldName.IsEmpty() )
469  {
470  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
471  {
472  if( m_membershipGrid->GetCellValue( row, 1 ) == oldName )
473  m_membershipGrid->SetCellValue( row, 1, newName );
474  }
475  }
476 
477  m_netclassesDirty = true;
478  }
479  else
480  {
481  event.Veto();
482  }
483  }
484 }
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 487 of file panel_setup_netclasses.cpp.

488 {
489  int col = m_netclassGrid->XToCol( aEvent.GetPosition().x );
490 
491  if( aEvent.Moving() || aEvent.Entering() )
492  {
493  aEvent.Skip();
494 
495  if( col == wxNOT_FOUND )
496  {
497  m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
498  return;
499  }
500 
501  if( col == m_hoveredCol )
502  return;
503 
504  m_hoveredCol = col;
505 
506  wxString tip;
507 
508  switch( col )
509  {
510  case GRID_CLEARANCE: tip = _( "Minimum copper clearance" ); break;
511  case GRID_TRACKSIZE: tip = _( "Minimum track width" ); break;
512  case GRID_VIASIZE: tip = _( "Via pad diameter" ); break;
513  case GRID_VIADRILL: tip = _( "Via plated hole diameter" ); break;
514  case GRID_uVIASIZE: tip = _( "Microvia pad diameter" ); break;
515  case GRID_uVIADRILL: tip = _( "Microvia plated hole diameter" ); break;
516  case GRID_DIFF_PAIR_WIDTH: tip = _( "Differential pair track width" ); break;
517  case GRID_DIFF_PAIR_GAP: tip = _( "Differential pair gap" ); break;
518  case GRID_WIREWIDTH: tip = _( "Schematic wire thickness" ); break;
519  case GRID_BUSWIDTH: tip = _( "Bus wire thickness" ); break;
520  case GRID_SCHEMATIC_COLOR: tip = _( "Schematic wire color" ); break;
521  case GRID_LINESTYLE: tip = _( "Schematic wire line style" ); break;
522  }
523 
524  m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
525  m_netclassGrid->GetGridColLabelWindow()->SetToolTip( tip );
526  }
527  else if( aEvent.Leaving() )
528  {
529  m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
530  aEvent.Skip();
531  }
532 
533  aEvent.Skip();
534 }
#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 559 of file panel_setup_netclasses.cpp.

560 {
562  return;
563 
564  int curRow = m_netclassGrid->GetGridCursorRow();
565 
566  if( curRow < 0 )
567  {
568  return;
569  }
570  else if( curRow == 0 )
571  {
572  DisplayErrorMessage( this, _( "The default net class is required." ) );
573  return;
574  }
575 
576  // reset the net class to default for members of the removed class
577  wxString classname = m_netclassGrid->GetCellValue( curRow, GRID_NAME );
578 
579  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
580  {
581  if( m_membershipGrid->GetCellValue( row, 1 ) == classname )
582  m_membershipGrid->SetCellValue( row, 1, NETCLASS::Default );
583  }
584 
585  m_netclassGrid->DeleteRows( curRow, 1 );
586 
587  m_netclassGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
588  m_netclassGrid->SetGridCursor( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
589 
590  m_netclassesDirty = true;
591 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
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:226

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

648 {
649  AdjustMembershipGridColumns( event.GetSize().GetX() );
650 
651  event.Skip();
652 }
void AdjustMembershipGridColumns(int aWidth)

References AdjustMembershipGridColumns().

◆ OnSizeNetclassGrid()

void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 609 of file panel_setup_netclasses.cpp.

610 {
611  AdjustNetclassGridColumns( event.GetSize().GetX() );
612 
613  event.Skip();
614 }
void AdjustNetclassGridColumns(int aWidth)

References AdjustNetclassGridColumns().

◆ onUnitsChanged()

void PANEL_SETUP_NETCLASSES::onUnitsChanged ( wxCommandEvent &  aEvent)
private

Definition at line 218 of file panel_setup_netclasses.cpp.

219 {
220  NETCLASSES tempNetClasses;
221  NETCLASSES* saveNetClasses = m_netclasses;
222 
223  m_netclasses = &tempNetClasses; // No, address of stack var does not escape function
224 
227 
228  m_netclasses = saveNetClasses;
229 
230  aEvent.Skip();
231 }
A container for NETCLASS instances.
Definition: netclass.h:218

References m_netclasses, TransferDataFromWindow(), and TransferDataToWindow().

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

◆ OnUpdateUI()

void PANEL_SETUP_NETCLASSES::OnUpdateUI ( wxUpdateUIEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 709 of file panel_setup_netclasses.cpp.

710 {
711  if( m_netclassesDirty )
712  {
714  m_netclassesDirty = false;
715  }
716 }

References m_netclassesDirty, and rebuildNetclassDropdowns().

◆ rebuildNetclassDropdowns()

void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns ( )
private

Definition at line 340 of file panel_setup_netclasses.cpp.

341 {
343 
344  wxArrayString netclassNames;
345 
346  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
347  {
348  wxString netclassName = m_netclassGrid->GetCellValue( ii, GRID_NAME );
349 
350  if( !netclassName.IsEmpty() )
351  netclassNames.push_back( netclassName );
352  }
353 
354  wxGridCellAttr* attr = new wxGridCellAttr;
355  attr->SetEditor( new wxGridCellChoiceEditor( netclassNames ) );
356  m_membershipGrid->SetColAttr( 1, attr );
357 
358  m_assignNetClass->Set( netclassNames );
359 
360  netclassNames.Insert( wxEmptyString, 0 );
361  m_netClassFilter->Set( netclassNames );
362 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226

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

392 {
393  if( !Validate() )
394  return false;
395 
396  m_netclasses->Clear();
397 
398  // Copy the default NetClass:
400 
401  // Copy other NetClasses:
402  for( int row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
403  {
404  NETCLASSPTR nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row,
405  GRID_NAME ) );
406 
407  if( m_netclasses->Add( nc ) )
409  }
410 
411  // Now read all nets and push them in the corresponding netclass net buffer
412  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
413  {
414  const wxString& netname = m_membershipGrid->GetCellValue( row, 0 );
415  const wxString& classname = m_membershipGrid->GetCellValue( row, 1 );
416 
417  if( classname != NETCLASS::Default )
418  {
419  const NETCLASSPTR& nc = m_netclasses->Find( classname );
420 
421  if( nc )
422  nc->Add( netname );
423  }
424  }
425 
426  return true;
427 }
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
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
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

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

Referenced by onUnitsChanged().

◆ TransferDataToWindow()

bool PANEL_SETUP_NETCLASSES::TransferDataToWindow ( )
override

Definition at line 265 of file panel_setup_netclasses.cpp.

266 {
267  std::map<wxString, wxString> netToNetclassMap;
268  std::map<wxString, wxString> staleNetMap;
269 
270  for( const wxString& candidate : m_netNames )
271  netToNetclassMap[ candidate ] = wxEmptyString;
272 
274  m_netclassGrid->AppendRows((int) m_netclasses->GetCount() + 1 ); // + 1 for default netclass
275 
276  // enter the Default NETCLASS.
278 
279  // make the Default NETCLASS name read-only
280  wxGridCellAttr* cellAttr = m_netclassGrid->GetOrCreateCellAttr( 0, GRID_NAME );
281  cellAttr->SetReadOnly();
282  cellAttr->DecRef();
283 
284  // enter other netclasses
285  int row = 1;
286 
287  for( NETCLASSES::iterator i = m_netclasses->begin(); i != m_netclasses->end(); ++i, ++row )
288  {
289  NETCLASSPTR netclass = i->second;
290 
292 
293  for( const wxString& net : *netclass )
294  {
295  if( netToNetclassMap.count( net ) )
296  netToNetclassMap[ net ] = i->second->GetName();
297  else
298  staleNetMap[ net ] = i->second->GetName();
299  }
300  }
301 
303 
304  // add currently-assigned and candidate netnames to membership lists
305  for( const std::pair<const wxString, wxString>& ii : netToNetclassMap )
306  addNet( ii.first, ii.second, false );
307 
308  for( const std::pair<const wxString, wxString>& ii : staleNetMap )
309  addNet( ii.first, ii.second, true );
310 
311  return true;
312 }
iterator end()
Definition: netclass.h:236
void addNet(const wxString &netName, const wxString &netclass, bool aStale)
std::vector< wxString > m_netNames
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:109
static void netclassToGridRow(EDA_UNITS aUnits, wxGrid *aGrid, int aRow, const NETCLASSPTR &nc)
NETCLASSPTR GetDefault() const
Definition: netclass.h:253
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

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

Referenced by ImportSettingsFrom(), and onUnitsChanged().

◆ Validate()

bool PANEL_SETUP_NETCLASSES::Validate ( )
override

Definition at line 719 of file panel_setup_netclasses.cpp.

720 {
722  return false;
723 
724  wxString msg;
725 
726  // Test net class parameters.
727  for( int row = 0; row < m_netclassGrid->GetNumberRows(); row++ )
728  {
729  wxString netclassName = m_netclassGrid->GetCellValue( row, GRID_NAME );
730  netclassName.Trim( true );
731  netclassName.Trim( false );
732 
733  if( !validateNetclassName( row, netclassName, false ) )
734  return false;
735  }
736 
737  return true;
738 }
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:226

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

432 {
433  wxString tmp = aName;
434 
435  tmp.Trim( true );
436  tmp.Trim( false );
437 
438  if( tmp.IsEmpty() )
439  {
440  wxString msg = _( "Netclass must have a name." );
441  m_parent->SetError( msg, this, m_netclassGrid, aRow, GRID_NAME );
442  return false;
443  }
444 
445  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
446  {
447  if( ii != aRow && m_netclassGrid->GetCellValue( ii, GRID_NAME ).CmpNoCase( tmp ) == 0 )
448  {
449  wxString msg = _( "Netclass name already in use." );
450  m_parent->SetError( msg, this, m_netclassGrid, focusFirst ? aRow : ii, GRID_NAME );
451  return false;
452  }
453  }
454 
455  return true;
456 }
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_frame

EDA_DRAW_FRAME* PANEL_SETUP_NETCLASSES::m_frame
private

◆ m_hoveredCol

int PANEL_SETUP_NETCLASSES::m_hoveredCol
private

Definition at line 83 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 79 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

Definition at line 77 of file panel_setup_netclasses.h.

Referenced by validateNetclassName().

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