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

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

References _, WX_GRID::EnsureColLabelsVisible(), g_lineStyleIcons, g_lineStyleNames, 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_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, NULL, 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 188 of file panel_setup_netclasses.cpp.

189 {
190  COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
191  cfg->m_NetclassPanel.sash_pos = m_splitter->GetSashPosition();
192 
193  delete [] m_originalColWidths;
194 
195  // Delete the GRID_TRICKS.
196  m_netclassGrid->PopEventHandler( true );
197  m_membershipGrid->PopEventHandler( true );
198 
199  m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING,
201  NULL, this );
202 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
NETCLASS_PANEL m_NetclassPanel
#define NULL
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, NULL, 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 283 of file panel_setup_netclasses.cpp.

285 {
286  int i = m_membershipGrid->GetNumberRows();
287 
288  m_membershipGrid->AppendRows( 1 );
289 
290  m_membershipGrid->SetCellValue( i, 0, netName );
291 
292  if( aStale )
293  {
294  wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
295  m_membershipGrid->SetCellTextColour( i, 0, color );
296  }
297 
298  if( netclass.IsEmpty() )
299  m_membershipGrid->SetCellValue( i, 1, NETCLASS::Default );
300  else
301  m_membershipGrid->SetCellValue( i, 1, netclass );
302 }
int color
Definition: DXF_plotter.cpp:60
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 579 of file panel_setup_netclasses.cpp.

580 {
581  // Account for scroll bars
582  aWidth -= ( m_membershipGrid->GetSize().x - m_membershipGrid->GetClientSize().x );
583 
584  // Set className column width to original className width from netclasses grid
585  int classNameWidth = m_originalColWidths[ 0 ];
586  m_membershipGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
587  m_membershipGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
588 }

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

557 {
558  // Account for scroll bars
559  aWidth -= ( m_netclassGrid->GetSize().x - m_netclassGrid->GetClientSize().x );
560 
561  for( int i = 1; i < m_netclassGrid->GetNumberCols(); i++ )
562  {
563  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
564  aWidth -= m_originalColWidths[ i ];
565  }
566 
567  m_netclassGrid->SetColSize( 0, std::max( aWidth - 2, m_originalColWidths[ 0 ] ) );
568 }

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

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

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

652 {
654  return;
655 
656  wxArrayInt selectedRows = m_membershipGrid->GetSelectedRows();
657 
658  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
659  {
660  if( !m_membershipGrid->IsRowShown( row ) )
661  continue;
662 
663  if( !aAssignAll && selectedRows.Index( row ) == wxNOT_FOUND )
664  continue;
665 
666  m_membershipGrid->SetCellValue( row, 1, m_assignNetClass->GetStringSelection() );
667  }
668 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:182

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

500 {
502  return;
503 
504  int row = m_netclassGrid->GetNumberRows();
505  m_netclassGrid->AppendRows();
506 
507  // Copy values of the default class:
508  for( int col = 1; col < m_netclassGrid->GetNumberCols(); col++ )
509  m_netclassGrid->SetCellValue( row, col, m_netclassGrid->GetCellValue( 0, col ) );
510 
511  m_netclassGrid->MakeCellVisible( row, 0 );
512  m_netclassGrid->SetGridCursor( row, 0 );
513 
514  m_netclassGrid->EnableCellEditControl( true );
515  m_netclassGrid->ShowCellEditControl();
516 
517  m_netclassesDirty = true;
518 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:182

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

56 { 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 57 of file panel_setup_netclasses.h.

57 { 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 58 of file panel_setup_netclasses.h.

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

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

References PANEL_SETUP_NETCLASSES_BASE::m_membershipGrid.

◆ OnNetclassGridCellChanging()

void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ( wxGridEvent &  event)
private

Definition at line 421 of file panel_setup_netclasses.cpp.

422 {
423  if( event.GetCol() == GRID_NAME )
424  {
425  if( validateNetclassName( event.GetRow(), event.GetString() ) )
426  {
427  wxString oldName = m_netclassGrid->GetCellValue( event.GetRow(), GRID_NAME );
428  wxString newName = event.GetString();
429 
430  if( !oldName.IsEmpty() )
431  {
432  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
433  {
434  if( m_membershipGrid->GetCellValue( row, 1 ) == oldName )
435  m_membershipGrid->SetCellValue( row, 1, newName );
436  }
437  }
438 
439  m_netclassesDirty = true;
440  }
441  else
442  {
443  event.Veto();
444  }
445  }
446 }
bool validateNetclassName(int aRow, 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 449 of file panel_setup_netclasses.cpp.

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

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

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

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

55 { 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 609 of file panel_setup_netclasses.cpp.

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

References AdjustMembershipGridColumns().

◆ OnSizeNetclassGrid()

void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 571 of file panel_setup_netclasses.cpp.

572 {
573  AdjustNetclassGridColumns( event.GetSize().GetX() );
574 
575  event.Skip();
576 }
void AdjustNetclassGridColumns(int aWidth)

References AdjustNetclassGridColumns().

◆ OnUpdateUI()

void PANEL_SETUP_NETCLASSES::OnUpdateUI ( wxUpdateUIEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 671 of file panel_setup_netclasses.cpp.

672 {
673  if( m_netclassesDirty )
674  {
676  m_netclassesDirty = false;
677  }
678 }

References m_netclassesDirty, and rebuildNetclassDropdowns().

◆ rebuildNetclassDropdowns()

void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns ( )
private

Definition at line 308 of file panel_setup_netclasses.cpp.

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

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

358 {
359  if( !Validate() )
360  return false;
361 
362  m_netclasses->Clear();
363 
364  // Copy the default NetClass:
366 
367  // Copy other NetClasses:
368  for( int row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
369  {
370  NETCLASSPTR nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row, GRID_NAME ) );
371 
372  if( m_netclasses->Add( nc ) )
374  }
375 
376  // Now read all nets and push them in the corresponding netclass net buffer
377  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
378  {
379  const wxString& netname = m_membershipGrid->GetCellValue( row, 0 );
380  const wxString& classname = m_membershipGrid->GetCellValue( row, 1 );
381 
382  if( classname != NETCLASS::Default )
383  {
384  const NETCLASSPTR& nc = m_netclasses->Find( classname );
385 
386  if( nc )
387  nc->Add( netname );
388  }
389  }
390 
391  return true;
392 }
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:120
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 230 of file panel_setup_netclasses.cpp.

231 {
232  std::map<wxString, wxString> netToNetclassMap;
233  std::map<wxString, wxString> staleNetMap;
234 
235  for( const wxString& candidate : m_netNames )
236  netToNetclassMap[ candidate ] = wxEmptyString;
237 
238  if( m_netclassGrid->GetNumberRows() )
239  m_netclassGrid->DeleteRows( 0, m_netclassGrid->GetNumberRows() );
240 
241  m_netclassGrid->AppendRows((int) m_netclasses->GetCount() + 1 ); // + 1 for default netclass
242 
243  // enter the Default NETCLASS.
245 
246  // make the Default NETCLASS name read-only
247  wxGridCellAttr* cellAttr = m_netclassGrid->GetOrCreateCellAttr( 0, GRID_NAME );
248  cellAttr->SetReadOnly();
249  cellAttr->DecRef();
250 
251  // enter other netclasses
252  int row = 1;
253 
254  for( NETCLASSES::iterator i = m_netclasses->begin(); i != m_netclasses->end(); ++i, ++row )
255  {
256  NETCLASSPTR netclass = i->second;
257 
259 
260  for( const wxString& net : *netclass )
261  {
262  if( netToNetclassMap.count( net ) )
263  netToNetclassMap[ net ] = i->second->GetName();
264  else
265  staleNetMap[ net ] = i->second->GetName();
266  }
267  }
268 
269  if( m_membershipGrid->GetNumberRows() )
270  m_membershipGrid->DeleteRows( 0, m_membershipGrid->GetNumberRows() );
271 
272  // add currently-assigned and candidate netnames to membership lists
273  for( const std::pair<const wxString, wxString>& ii : netToNetclassMap )
274  addNet( ii.first, ii.second, false );
275 
276  for( const std::pair<const wxString, wxString>& ii : staleNetMap )
277  addNet( ii.first, ii.second, true );
278 
279  return true;
280 }
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:120
NETCLASS_MAP::iterator iterator
Definition: netclass.h:234
iterator begin()
Definition: netclass.h:235
unsigned GetCount() const
Definition: netclass.h:245
static void netclassToGridRow(EDA_UNITS aUnits, wxGrid *aGrid, int aRow, const NETCLASSPTR &nc)
NETCLASSPTR GetDefault() const
Definition: netclass.h:253

References addNet(), NETCLASSES::begin(), 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 681 of file panel_setup_netclasses.cpp.

682 {
684  return false;
685 
686  wxString msg;
687 
688  // Test net class parameters.
689  for( int row = 0; row < m_netclassGrid->GetNumberRows(); row++ )
690  {
691  wxString netclassName = m_netclassGrid->GetCellValue( row, GRID_NAME );
692  netclassName.Trim( true );
693  netclassName.Trim( false );
694 
695  if( !validateNetclassName( row, netclassName, false ) )
696  return false;
697  }
698 
699  return true;
700 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:182
bool validateNetclassName(int aRow, wxString aName, bool focusFirst=true)

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,
wxString  aName,
bool  focusFirst = true 
)
private

Definition at line 395 of file panel_setup_netclasses.cpp.

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

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_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 44 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 40 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: