KiCad PCB EDA Suite
panel_setup_netclasses.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2004-2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2009 Dick Hollenbeck, dick@softplc.com
6  * Copyright (C) 2009-2021 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <algorithm>
27 
28 #include <pgm_base.h>
29 #include <base_units.h>
30 #include <bitmaps.h>
31 #include <netclass.h>
32 #include <confirm.h>
33 #include <grid_tricks.h>
35 #include <tool/tool_manager.h>
36 #include <widgets/wx_grid.h>
37 #include <string_utils.h>
41 #include <wx/treebook.h>
42 
43 
44 // PCBNEW columns of netclasses grid
45 enum {
46  GRID_NAME = 0,
47 
57 
63 
65 };
66 
67 
68 // These are conceptually constexpr
69 std::vector<BITMAPS> g_lineStyleIcons;
70 wxArrayString g_lineStyleNames;
71 
72 
74  const std::vector<wxString>& aNetNames,
75  bool aIsEEschema ) :
76  PANEL_SETUP_NETCLASSES_BASE( aParent->GetTreebook() ),
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 }
192 
193 
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 }
209 
210 
211 static void netclassToGridRow( EDA_UNITS aUnits, wxGrid* aGrid, int aRow, const NETCLASSPTR& nc )
212 {
213  aGrid->SetCellValue( aRow, GRID_NAME, nc->GetName() );
214 
215 #define SET_MILS_CELL( col, val ) \
216  aGrid->SetCellValue( aRow, col, StringFromValue( aUnits, val, true ) )
217 
218  SET_MILS_CELL( GRID_CLEARANCE, nc->GetClearance() );
219  SET_MILS_CELL( GRID_TRACKSIZE, nc->GetTrackWidth() );
220  SET_MILS_CELL( GRID_VIASIZE, nc->GetViaDiameter() );
221  SET_MILS_CELL( GRID_VIADRILL, nc->GetViaDrill() );
222  SET_MILS_CELL( GRID_uVIASIZE, nc->GetuViaDiameter() );
223  SET_MILS_CELL( GRID_uVIADRILL, nc->GetuViaDrill() );
224  SET_MILS_CELL( GRID_DIFF_PAIR_WIDTH, nc->GetDiffPairWidth() );
225  SET_MILS_CELL( GRID_DIFF_PAIR_GAP, nc->GetDiffPairGap() );
226 
227  SET_MILS_CELL( GRID_WIREWIDTH, nc->GetWireWidth() );
228  SET_MILS_CELL( GRID_BUSWIDTH, nc->GetBusWidth() );
229 
230  wxString colorAsString = nc->GetSchematicColor().ToWxString( wxC2S_CSS_SYNTAX );
231  aGrid->SetCellValue( aRow, GRID_SCHEMATIC_COLOR, colorAsString );
232  aGrid->SetCellValue( aRow, GRID_LINESTYLE, g_lineStyleNames[ nc->GetLineStyle() ] );
233 }
234 
235 
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 }
284 
285 
286 void PANEL_SETUP_NETCLASSES::addNet( const wxString& netName, const wxString& netclass,
287  bool aStale )
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 }
306 
307 
308 /*
309  * Populates drop-downs with the list of net classes
310  */
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 }
334 
335 
336 static void gridRowToNetclass( EDA_UNITS aUnits, wxGrid* grid, int row, const NETCLASSPTR& nc )
337 {
338  nc->SetName( grid->GetCellValue( row, GRID_NAME ) );
339 
340 #define MYCELL( col ) \
341  ValueFromString( aUnits, grid->GetCellValue( row, col ) )
342 
343  nc->SetClearance( MYCELL( GRID_CLEARANCE ) );
344  nc->SetTrackWidth( MYCELL( GRID_TRACKSIZE ) );
345  nc->SetViaDiameter( MYCELL( GRID_VIASIZE ) );
346  nc->SetViaDrill( MYCELL( GRID_VIADRILL ) );
347  nc->SetuViaDiameter( MYCELL( GRID_uVIASIZE ) );
348  nc->SetuViaDrill( MYCELL( GRID_uVIADRILL ) );
349  nc->SetDiffPairWidth( MYCELL( GRID_DIFF_PAIR_WIDTH ) );
350  nc->SetDiffPairGap( MYCELL( GRID_DIFF_PAIR_GAP ) );
351 
352  nc->SetWireWidth( MYCELL( GRID_WIREWIDTH ) );
353  nc->SetBusWidth( MYCELL( GRID_BUSWIDTH ) );
354 
355  nc->SetSchematicColor( wxColour( grid->GetCellValue( row, GRID_SCHEMATIC_COLOR ) ) );
356  nc->SetLineStyle( g_lineStyleNames.Index( grid->GetCellValue( row, GRID_LINESTYLE ) ) );
357 }
358 
359 
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 }
397 
398 
399 bool PANEL_SETUP_NETCLASSES::validateNetclassName( int aRow, const wxString& aName,
400  bool focusFirst )
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 }
426 
427 
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 }
454 
455 
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 }
504 
505 
506 void PANEL_SETUP_NETCLASSES::OnAddNetclassClick( wxCommandEvent& event )
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 }
526 
527 
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 }
561 
562 
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 }
576 
577 
579 {
580  AdjustNetclassGridColumns( event.GetSize().GetX() );
581 
582  event.Skip();
583 }
584 
585 
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 }
596 
597 
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 }
614 
615 
617 {
618  AdjustMembershipGridColumns( event.GetSize().GetX() );
619 
620  event.Skip();
621 }
622 
623 
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 }
656 
657 
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 }
676 
677 
678 void PANEL_SETUP_NETCLASSES::OnUpdateUI( wxUpdateUIEvent& event )
679 {
680  if( m_netclassesDirty )
681  {
683  m_netclassesDirty = false;
684  }
685 }
686 
687 
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 }
708 
709 
711 {
712  NETCLASSES* savedSettings = m_netclasses;
713 
714  m_netclasses = aNetclasses;
716 
718 
719  m_netclassGrid->ForceRefresh();
720  m_membershipGrid->ForceRefresh();
721 
722  m_netclasses = savedSettings;
723 }
724 
725 
PANEL_SETUP_NETCLASSES(PAGED_DIALOG *aParent, NETCLASSES *aNetclasses, const std::vector< wxString > &aNetNames, bool isEEschema)
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
void OnSizeNetclassGrid(wxSizeEvent &event) override
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:284
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
void onmembershipPanelSize(wxSizeEvent &event) override
int color
Definition: DXF_plotter.cpp:57
#define SET_MILS_CELL(col, val)
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
iterator end()
Definition: netclass.h:236
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
bool validateNetclassName(int aRow, const wxString &aName, bool focusFirst=true)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
void addNet(const wxString &netName, const wxString &netclass, bool aStale)
void doAssignments(bool aAssignAll)
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
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:119
std::vector< BITMAPS > g_lineStyleIcons
NETCLASS_MAP::iterator iterator
Definition: netclass.h:234
NETCLASS_PANEL m_NetclassPanel
iterator begin()
Definition: netclass.h:235
A container for NETCLASS instances.
Definition: netclass.h:218
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49
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)
static void gridRowToNetclass(EDA_UNITS aUnits, wxGrid *grid, int row, const NETCLASSPTR &nc)
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:190
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
Class PANEL_SETUP_NETCLASSES_BASE.
EDA_UNITS
Definition: eda_units.h:38
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
see class PGM_BASE
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
wxArrayString g_lineStyleNames
void ImportSettingsFrom(NETCLASSES *aBoard)
void OnUpdateUI(wxUpdateUIEvent &event) override
#define MYCELL(col)
void OnSizeMembershipGrid(wxSizeEvent &event) override
void OnRemoveNetclassClick(wxCommandEvent &event) override
void AdjustNetclassGridColumns(int aWidth)
void AdjustMembershipGridColumns(int aWidth)
void OnAddNetclassClick(wxCommandEvent &event) override
A text renderer that can unescape text for display This is useful where it's desired to keep the unde...
void doApplyFilters(bool aShowAll)