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 <kicad_string.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  else
140  {
141  for( int i = GRID_FIRST_EESCHEMA; i < GRID_END; ++i )
142  {
143  m_netclassGrid->HideCol( i );
144  m_originalColWidths[ i ] = 0;
145  }
146  }
147 
148  // Be sure the column labels are readable
150 
151  // Membership combobox editors require a bit more room, so increase the row size of
152  // all our grids for consistency
153  m_netclassGrid->SetDefaultRowSize( m_netclassGrid->GetDefaultRowSize() + 4 );
154  m_membershipGrid->SetDefaultRowSize( m_membershipGrid->GetDefaultRowSize() + 4 );
155 
156  m_netclassGrid->PushEventHandler( new GRID_TRICKS( m_netclassGrid ) );
157  m_membershipGrid->PushEventHandler( new GRID_TRICKS( m_membershipGrid ) );
158 
159  m_netclassGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
160  m_membershipGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
161 
162  // Set up the net name column of the netclass membership grid to read-only
163  wxGridCellAttr* attr = new wxGridCellAttr;
164  attr->SetReadOnly( true );
165  attr->SetRenderer( new GRID_CELL_ESCAPED_TEXT_RENDERER );
166  m_membershipGrid->SetColAttr( 0, attr );
167 
168  COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
169  m_splitter->SetSashPosition( cfg->m_NetclassPanel.sash_pos );
170 
171  m_addButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
173 
174  // wxFormBuilder doesn't include this event...
175  m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING,
177  NULL, this );
178 
179  // Handle tooltips for grid
180  m_netclassGrid->GetGridColLabelWindow()->Bind( wxEVT_MOTION,
182  this );
183 
184  m_netclassGrid->EndBatch();
185  m_membershipGrid->EndBatch();
186  Thaw();
187 }
188 
189 
191 {
192  COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
193  cfg->m_NetclassPanel.sash_pos = m_splitter->GetSashPosition();
194 
195  delete [] m_originalColWidths;
196 
197  // Delete the GRID_TRICKS.
198  m_netclassGrid->PopEventHandler( true );
199  m_membershipGrid->PopEventHandler( true );
200 
201  m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING,
203  NULL, this );
204 }
205 
206 
207 static void netclassToGridRow( EDA_UNITS aUnits, wxGrid* aGrid, int aRow, const NETCLASSPTR& nc )
208 {
209  aGrid->SetCellValue( aRow, GRID_NAME, nc->GetName() );
210 
211 #define SET_MILS_CELL( col, val ) \
212  aGrid->SetCellValue( aRow, col, StringFromValue( aUnits, val, true ) )
213 
214  SET_MILS_CELL( GRID_CLEARANCE, nc->GetClearance() );
215  SET_MILS_CELL( GRID_TRACKSIZE, nc->GetTrackWidth() );
216  SET_MILS_CELL( GRID_VIASIZE, nc->GetViaDiameter() );
217  SET_MILS_CELL( GRID_VIADRILL, nc->GetViaDrill() );
218  SET_MILS_CELL( GRID_uVIASIZE, nc->GetuViaDiameter() );
219  SET_MILS_CELL( GRID_uVIADRILL, nc->GetuViaDrill() );
220  SET_MILS_CELL( GRID_DIFF_PAIR_WIDTH, nc->GetDiffPairWidth() );
221  SET_MILS_CELL( GRID_DIFF_PAIR_GAP, nc->GetDiffPairGap() );
222 
223  SET_MILS_CELL( GRID_WIREWIDTH, nc->GetWireWidth() );
224  SET_MILS_CELL( GRID_BUSWIDTH, nc->GetBusWidth() );
225 
226  wxString colorAsString = nc->GetSchematicColor().ToWxString( wxC2S_CSS_SYNTAX );
227  aGrid->SetCellValue( aRow, GRID_SCHEMATIC_COLOR, colorAsString );
228  aGrid->SetCellValue( aRow, GRID_LINESTYLE, g_lineStyleNames[ nc->GetLineStyle() ] );
229 }
230 
231 
233 {
234  std::map<wxString, wxString> netToNetclassMap;
235  std::map<wxString, wxString> staleNetMap;
236 
237  for( const wxString& candidate : m_netNames )
238  netToNetclassMap[ candidate ] = wxEmptyString;
239 
240  if( m_netclassGrid->GetNumberRows() )
241  m_netclassGrid->DeleteRows( 0, m_netclassGrid->GetNumberRows() );
242 
243  m_netclassGrid->AppendRows((int) m_netclasses->GetCount() + 1 ); // + 1 for default netclass
244 
245  // enter the Default NETCLASS.
247 
248  // make the Default NETCLASS name read-only
249  wxGridCellAttr* cellAttr = m_netclassGrid->GetOrCreateCellAttr( 0, GRID_NAME );
250  cellAttr->SetReadOnly();
251  cellAttr->DecRef();
252 
253  // enter other netclasses
254  int row = 1;
255 
256  for( NETCLASSES::iterator i = m_netclasses->begin(); i != m_netclasses->end(); ++i, ++row )
257  {
258  NETCLASSPTR netclass = i->second;
259 
261 
262  for( const wxString& net : *netclass )
263  {
264  if( netToNetclassMap.count( net ) )
265  netToNetclassMap[ net ] = i->second->GetName();
266  else
267  staleNetMap[ net ] = i->second->GetName();
268  }
269  }
270 
271  if( m_membershipGrid->GetNumberRows() )
272  m_membershipGrid->DeleteRows( 0, m_membershipGrid->GetNumberRows() );
273 
274  // add currently-assigned and candidate netnames to membership lists
275  for( const std::pair<const wxString, wxString>& ii : netToNetclassMap )
276  addNet( ii.first, ii.second, false );
277 
278  for( const std::pair<const wxString, wxString>& ii : staleNetMap )
279  addNet( ii.first, ii.second, true );
280 
281  return true;
282 }
283 
284 
285 void PANEL_SETUP_NETCLASSES::addNet( const wxString& netName, const wxString& netclass,
286  bool aStale )
287 {
288  int i = m_membershipGrid->GetNumberRows();
289 
290  m_membershipGrid->AppendRows( 1 );
291 
292  m_membershipGrid->SetCellValue( i, 0, netName );
293 
294  if( aStale )
295  {
296  wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
297  m_membershipGrid->SetCellTextColour( i, 0, color );
298  }
299 
300  if( netclass.IsEmpty() )
301  m_membershipGrid->SetCellValue( i, 1, NETCLASS::Default );
302  else
303  m_membershipGrid->SetCellValue( i, 1, netclass );
304 }
305 
306 
307 /*
308  * Populates drop-downs with the list of net classes
309  */
311 {
313 
314  wxArrayString netclassNames;
315 
316  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
317  {
318  wxString netclassName = m_netclassGrid->GetCellValue( ii, GRID_NAME );
319 
320  if( !netclassName.IsEmpty() )
321  netclassNames.push_back( netclassName );
322  }
323 
324  wxGridCellAttr* attr = new wxGridCellAttr;
325  attr->SetEditor( new wxGridCellChoiceEditor( netclassNames ) );
326  m_membershipGrid->SetColAttr( 1, attr );
327 
328  m_assignNetClass->Set( netclassNames );
329 
330  netclassNames.Insert( wxEmptyString, 0 );
331  m_netClassFilter->Set( netclassNames );
332 }
333 
334 
335 static void gridRowToNetclass( EDA_UNITS aUnits, wxGrid* grid, int row, const NETCLASSPTR& nc )
336 {
337  nc->SetName( grid->GetCellValue( row, GRID_NAME ) );
338 
339 #define MYCELL( col ) \
340  ValueFromString( aUnits, grid->GetCellValue( row, col ) )
341 
342  nc->SetClearance( MYCELL( GRID_CLEARANCE ) );
343  nc->SetTrackWidth( MYCELL( GRID_TRACKSIZE ) );
344  nc->SetViaDiameter( MYCELL( GRID_VIASIZE ) );
345  nc->SetViaDrill( MYCELL( GRID_VIADRILL ) );
346  nc->SetuViaDiameter( MYCELL( GRID_uVIASIZE ) );
347  nc->SetuViaDrill( MYCELL( GRID_uVIADRILL ) );
348  nc->SetDiffPairWidth( MYCELL( GRID_DIFF_PAIR_WIDTH ) );
349  nc->SetDiffPairGap( MYCELL( GRID_DIFF_PAIR_GAP ) );
350 
351  nc->SetWireWidth( MYCELL( GRID_WIREWIDTH ) );
352  nc->SetBusWidth( MYCELL( GRID_BUSWIDTH ) );
353 
354  nc->SetSchematicColor( wxColour( grid->GetCellValue( row, GRID_SCHEMATIC_COLOR ) ) );
355  nc->SetLineStyle( g_lineStyleNames.Index( grid->GetCellValue( row, GRID_LINESTYLE ) ) );
356 }
357 
358 
360 {
361  if( !Validate() )
362  return false;
363 
364  m_netclasses->Clear();
365 
366  // Copy the default NetClass:
368 
369  // Copy other NetClasses:
370  for( int row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
371  {
372  NETCLASSPTR nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row, GRID_NAME ) );
373 
374  if( m_netclasses->Add( nc ) )
376  }
377 
378  // Now read all nets and push them in the corresponding netclass net buffer
379  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
380  {
381  const wxString& netname = m_membershipGrid->GetCellValue( row, 0 );
382  const wxString& classname = m_membershipGrid->GetCellValue( row, 1 );
383 
384  if( classname != NETCLASS::Default )
385  {
386  const NETCLASSPTR& nc = m_netclasses->Find( classname );
387 
388  if( nc )
389  nc->Add( netname );
390  }
391  }
392 
393  return true;
394 }
395 
396 
397 bool PANEL_SETUP_NETCLASSES::validateNetclassName( int aRow, wxString aName, bool focusFirst )
398 {
399  aName.Trim( true );
400  aName.Trim( false );
401 
402  if( aName.IsEmpty() )
403  {
404  wxString msg = _( "Netclass must have a name." );
405  m_Parent->SetError( msg, this, m_netclassGrid, aRow, GRID_NAME );
406  return false;
407  }
408 
409  for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
410  {
411  if( ii != aRow && m_netclassGrid->GetCellValue( ii, GRID_NAME ).CmpNoCase( aName ) == 0 )
412  {
413  wxString msg = _( "Netclass name already in use." );
414  m_Parent->SetError( msg, this, m_netclassGrid, focusFirst ? aRow : ii, GRID_NAME );
415  return false;
416  }
417  }
418 
419  return true;
420 }
421 
422 
424 {
425  if( event.GetCol() == GRID_NAME )
426  {
427  if( validateNetclassName( event.GetRow(), event.GetString() ) )
428  {
429  wxString oldName = m_netclassGrid->GetCellValue( event.GetRow(), GRID_NAME );
430  wxString newName = event.GetString();
431 
432  if( !oldName.IsEmpty() )
433  {
434  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
435  {
436  if( m_membershipGrid->GetCellValue( row, 1 ) == oldName )
437  m_membershipGrid->SetCellValue( row, 1, newName );
438  }
439  }
440 
441  m_netclassesDirty = true;
442  }
443  else
444  {
445  event.Veto();
446  }
447  }
448 }
449 
450 
452 {
453  int col = m_netclassGrid->XToCol( aEvent.GetPosition().x );
454 
455  if( aEvent.Moving() || aEvent.Entering() )
456  {
457  aEvent.Skip();
458 
459  if( col == wxNOT_FOUND )
460  {
461  m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
462  return;
463  }
464 
465  if( col == m_hoveredCol )
466  return;
467 
468  m_hoveredCol = col;
469 
470  wxString tip;
471 
472  switch( col )
473  {
474  case GRID_CLEARANCE: tip = _( "Minimum copper clearance" ); break;
475  case GRID_TRACKSIZE: tip = _( "Minimum track width" ); break;
476  case GRID_VIASIZE: tip = _( "Via pad diameter" ); break;
477  case GRID_VIADRILL: tip = _( "Via plated hole diameter" ); break;
478  case GRID_uVIASIZE: tip = _( "Microvia pad diameter" ); break;
479  case GRID_uVIADRILL: tip = _( "Microvia plated hole diameter" ); break;
480  case GRID_DIFF_PAIR_WIDTH: tip = _( "Differential pair track width" ); break;
481  case GRID_DIFF_PAIR_GAP: tip = _( "Differential pair gap" ); break;
482  case GRID_WIREWIDTH: tip = _( "Schematic wire thickness" ); break;
483  case GRID_BUSWIDTH: tip = _( "Bus wire thickness" ); break;
484  case GRID_SCHEMATIC_COLOR: tip = _( "Schematic wire color" ); break;
485  case GRID_LINESTYLE: tip = _( "Schematic wire line style" ); break;
486  }
487 
488  m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
489  m_netclassGrid->GetGridColLabelWindow()->SetToolTip( tip );
490  }
491  else if( aEvent.Leaving() )
492  {
493  m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
494  aEvent.Skip();
495  }
496 
497  aEvent.Skip();
498 }
499 
500 
501 void PANEL_SETUP_NETCLASSES::OnAddNetclassClick( wxCommandEvent& event )
502 {
504  return;
505 
506  int row = m_netclassGrid->GetNumberRows();
507  m_netclassGrid->AppendRows();
508 
509  // Copy values of the default class:
510  for( int col = 1; col < m_netclassGrid->GetNumberCols(); col++ )
511  m_netclassGrid->SetCellValue( row, col, m_netclassGrid->GetCellValue( 0, col ) );
512 
513  m_netclassGrid->MakeCellVisible( row, 0 );
514  m_netclassGrid->SetGridCursor( row, 0 );
515 
516  m_netclassGrid->EnableCellEditControl( true );
517  m_netclassGrid->ShowCellEditControl();
518 
519  m_netclassesDirty = true;
520 }
521 
522 
524 {
526  return;
527 
528  int curRow = m_netclassGrid->GetGridCursorRow();
529 
530  if( curRow < 0 )
531  {
532  return;
533  }
534  else if( curRow == 0 )
535  {
536  DisplayErrorMessage( this, _( "The default net class is required." ) );
537  return;
538  }
539 
540  // reset the net class to default for members of the removed class
541  wxString classname = m_netclassGrid->GetCellValue( curRow, GRID_NAME );
542 
543  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
544  {
545  if( m_membershipGrid->GetCellValue( row, 1 ) == classname )
546  m_membershipGrid->SetCellValue( row, 1, NETCLASS::Default );
547  }
548 
549  m_netclassGrid->DeleteRows( curRow, 1 );
550 
551  m_netclassGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
552  m_netclassGrid->SetGridCursor( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
553 
554  m_netclassesDirty = true;
555 }
556 
557 
559 {
560  // Account for scroll bars
561  aWidth -= ( m_netclassGrid->GetSize().x - m_netclassGrid->GetClientSize().x );
562 
563  for( int i = 1; i < m_netclassGrid->GetNumberCols(); i++ )
564  {
565  m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
566  aWidth -= m_originalColWidths[ i ];
567  }
568 
569  m_netclassGrid->SetColSize( 0, std::max( aWidth - 2, m_originalColWidths[ 0 ] ) );
570 }
571 
572 
574 {
575  AdjustNetclassGridColumns( event.GetSize().GetX() );
576 
577  event.Skip();
578 }
579 
580 
582 {
583  // Account for scroll bars
584  aWidth -= ( m_membershipGrid->GetSize().x - m_membershipGrid->GetClientSize().x );
585 
586  // Set className column width to original className width from netclasses grid
587  int classNameWidth = m_originalColWidths[ 0 ];
588  m_membershipGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
589  m_membershipGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
590 }
591 
592 
594 {
595  // When a class name choice widget is selected (activated), in
596  // wxGrid m_membershipGrid, resizing its wxGrid parent is not taken in account
597  // by the widget until it is deselected and stay in the old position.
598  // So we deselect it if this is the case
599  // Note also this is made here, not in OnSizeMembershipGrid because on Linux
600  // there are a lot of wxSizeEvent send to m_membershipGrid when opening a choice widget
601  int c_row = m_membershipGrid->GetGridCursorRow();
602  int c_col = m_membershipGrid->GetGridCursorCol();
603 
604  if( c_row >= 0 && c_col == 1 ) // this means the class name choice widget is selected (opened)
605  m_membershipGrid->SetGridCursor( c_row, 0 ); // Close it
606 
607  event.Skip();
608 }
609 
610 
612 {
613  AdjustMembershipGridColumns( event.GetSize().GetX() );
614 
615  event.Skip();
616 }
617 
618 
620 {
622  return;
623 
624  wxString netClassFilter = m_netClassFilter->GetStringSelection();
625  wxString netFilter = m_netNameFilter->GetValue().MakeLower();
626 
627  if( !netFilter.IsEmpty() )
628  netFilter = wxT( "*" ) + netFilter + wxT( "*" );
629 
630  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
631  {
632  wxString net = m_membershipGrid->GetCellValue( row, 0 );
633  wxString netClass = m_membershipGrid->GetCellValue( row, 1 );
634  bool show = true;
635 
636  if( !aShowAll )
637  {
638  if( !netFilter.IsEmpty() && !net.MakeLower().Matches( netFilter ) )
639  show = false;
640 
641  if( !netClassFilter.IsEmpty() && netClass != netClassFilter )
642  show = false;
643  }
644 
645  if( show )
646  m_membershipGrid->ShowRow( row );
647  else
648  m_membershipGrid->HideRow( row );
649  }
650 }
651 
652 
654 {
656  return;
657 
658  wxArrayInt selectedRows = m_membershipGrid->GetSelectedRows();
659 
660  for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
661  {
662  if( !m_membershipGrid->IsRowShown( row ) )
663  continue;
664 
665  if( !aAssignAll && selectedRows.Index( row ) == wxNOT_FOUND )
666  continue;
667 
668  m_membershipGrid->SetCellValue( row, 1, m_assignNetClass->GetStringSelection() );
669  }
670 }
671 
672 
673 void PANEL_SETUP_NETCLASSES::OnUpdateUI( wxUpdateUIEvent& event )
674 {
675  if( m_netclassesDirty )
676  {
678  m_netclassesDirty = false;
679  }
680 }
681 
682 
684 {
686  return false;
687 
688  wxString msg;
689 
690  // Test net class parameters.
691  for( int row = 0; row < m_netclassGrid->GetNumberRows(); row++ )
692  {
693  wxString netclassName = m_netclassGrid->GetCellValue( row, GRID_NAME );
694  netclassName.Trim( true );
695  netclassName.Trim( false );
696 
697  if( !validateNetclassName( row, netclassName, false ) )
698  return false;
699  }
700 
701  return true;
702 }
703 
704 
706 {
707  NETCLASSES* savedSettings = m_netclasses;
708 
709  m_netclasses = aNetclasses;
711 
713 
714  m_netclassGrid->ForceRefresh();
715  m_membershipGrid->ForceRefresh();
716 
717  m_netclasses = savedSettings;
718 }
719 
720 
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:265
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:60
#define SET_MILS_CELL(col, val)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:52
iterator end()
Definition: netclass.h:236
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
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:238
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
#define NULL
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:283
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:182
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
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
bool validateNetclassName(int aRow, wxString aName, bool focusFirst=true)
#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)