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-2020 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 
42 // PCBNEW columns of netclasses grid
43 enum {
44  GRID_NAME = 0,
45 
55 
61 
63 };
64 
65 
66 // These are conceptually constexpr
67 std::vector<BITMAP_DEF> g_lineStyleIcons;
68 wxArrayString g_lineStyleNames;
69 
70 
72  const std::vector<wxString>& aNetNames,
73  bool aIsEEschema ) :
74  PANEL_SETUP_NETCLASSES_BASE( aParent->GetTreebook() ),
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" ) );
84  g_lineStyleIcons.push_back( stroke_dash_xpm );
85  g_lineStyleNames.push_back( _( "Dashed" ) );
86  g_lineStyleIcons.push_back( stroke_dot_xpm );
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( small_plus_xpm ) );
170  m_removeButton->SetBitmap( KiBitmap( small_trash_xpm ) );
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 }
186 
187 
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 }
203 
204 
205 static void netclassToGridRow( EDA_UNITS aUnits, wxGrid* aGrid, int aRow, const NETCLASSPTR& nc )
206 {
207  aGrid->SetCellValue( aRow, GRID_NAME, nc->GetName() );
208 
209 #define SET_MILS_CELL( col, val ) \
210  aGrid->SetCellValue( aRow, col, StringFromValue( aUnits, val, true ) )
211 
212  SET_MILS_CELL( GRID_CLEARANCE, nc->GetClearance() );
213  SET_MILS_CELL( GRID_TRACKSIZE, nc->GetTrackWidth() );
214  SET_MILS_CELL( GRID_VIASIZE, nc->GetViaDiameter() );
215  SET_MILS_CELL( GRID_VIADRILL, nc->GetViaDrill() );
216  SET_MILS_CELL( GRID_uVIASIZE, nc->GetuViaDiameter() );
217  SET_MILS_CELL( GRID_uVIADRILL, nc->GetuViaDrill() );
218  SET_MILS_CELL( GRID_DIFF_PAIR_WIDTH, nc->GetDiffPairWidth() );
219  SET_MILS_CELL( GRID_DIFF_PAIR_GAP, nc->GetDiffPairGap() );
220 
221  SET_MILS_CELL( GRID_WIREWIDTH, nc->GetWireWidth() );
222  SET_MILS_CELL( GRID_BUSWIDTH, nc->GetBusWidth() );
223 
224  wxString colorAsString = nc->GetSchematicColor().ToWxString( wxC2S_CSS_SYNTAX );
225  aGrid->SetCellValue( aRow, GRID_SCHEMATIC_COLOR, colorAsString );
226  aGrid->SetCellValue( aRow, GRID_LINESTYLE, g_lineStyleNames[ nc->GetLineStyle() ] );
227 }
228 
229 
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 }
281 
282 
283 void PANEL_SETUP_NETCLASSES::addNet( const wxString& netName, const wxString& netclass,
284  bool aStale )
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 }
303 
304 
305 /*
306  * Populates drop-downs with the list of net classes
307  */
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 }
331 
332 
333 static void gridRowToNetclass( EDA_UNITS aUnits, wxGrid* grid, int row, const NETCLASSPTR& nc )
334 {
335  nc->SetName( grid->GetCellValue( row, GRID_NAME ) );
336 
337 #define MYCELL( col ) \
338  ValueFromString( aUnits, grid->GetCellValue( row, col ) )
339 
340  nc->SetClearance( MYCELL( GRID_CLEARANCE ) );
341  nc->SetTrackWidth( MYCELL( GRID_TRACKSIZE ) );
342  nc->SetViaDiameter( MYCELL( GRID_VIASIZE ) );
343  nc->SetViaDrill( MYCELL( GRID_VIADRILL ) );
344  nc->SetuViaDiameter( MYCELL( GRID_uVIASIZE ) );
345  nc->SetuViaDrill( MYCELL( GRID_uVIADRILL ) );
346  nc->SetDiffPairWidth( MYCELL( GRID_DIFF_PAIR_WIDTH ) );
347  nc->SetDiffPairGap( MYCELL( GRID_DIFF_PAIR_GAP ) );
348 
349  nc->SetWireWidth( MYCELL( GRID_WIREWIDTH ) );
350  nc->SetBusWidth( MYCELL( GRID_BUSWIDTH ) );
351 
352  nc->SetSchematicColor( wxColour( grid->GetCellValue( row, GRID_SCHEMATIC_COLOR ) ) );
353  nc->SetLineStyle( g_lineStyleNames.Index( grid->GetCellValue( row, GRID_LINESTYLE ) ) );
354 }
355 
356 
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 }
393 
394 
395 bool PANEL_SETUP_NETCLASSES::validateNetclassName( int aRow, wxString aName, bool focusFirst )
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 }
419 
420 
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 }
447 
448 
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 }
497 
498 
499 void PANEL_SETUP_NETCLASSES::OnAddNetclassClick( wxCommandEvent& event )
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 }
519 
520 
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 }
554 
555 
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 }
569 
570 
572 {
573  AdjustNetclassGridColumns( event.GetSize().GetX() );
574 
575  event.Skip();
576 }
577 
578 
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 }
589 
590 
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 }
607 
608 
610 {
611  AdjustMembershipGridColumns( event.GetSize().GetX() );
612 
613  event.Skip();
614 }
615 
616 
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 }
649 
650 
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 }
669 
670 
671 void PANEL_SETUP_NETCLASSES::OnUpdateUI( wxUpdateUIEvent& event )
672 {
673  if( m_netclassesDirty )
674  {
676  m_netclassesDirty = false;
677  }
678 }
679 
680 
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 }
701 
702 
704 {
705  NETCLASSES* savedSettings = m_netclasses;
706 
707  m_netclasses = aNetclasses;
709 
711 
712  m_netclassGrid->ForceRefresh();
713  m_membershipGrid->ForceRefresh();
714 
715  m_netclasses = savedSettings;
716 }
717 
718 
PANEL_SETUP_NETCLASSES(PAGED_DIALOG *aParent, NETCLASSES *aNetclasses, const std::vector< wxString > &aNetNames, bool isEEschema)
const BITMAP_OPAQUE stroke_dot_xpm[1]
Definition: stroke_dot.cpp:29
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:266
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:120
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
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
std::vector< BITMAP_DEF > g_lineStyleIcons
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49
const BITMAP_OPAQUE stroke_dash_xpm[1]
Definition: stroke_dash.cpp:25
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)
static void gridRowToNetclass(EDA_UNITS aUnits, wxGrid *grid, int row, const NETCLASSPTR &nc)
const BITMAP_OPAQUE stroke_dashdot_xpm[1]
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:182
const BITMAP_OPAQUE small_trash_xpm[1]
Definition: small_trash.cpp:23
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
#define _(s)
Definition: 3d_actions.cpp:33
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
const BITMAP_OPAQUE stroke_solid_xpm[1]
void ImportSettingsFrom(NETCLASSES *aBoard)
void OnUpdateUI(wxUpdateUIEvent &event) override
bool validateNetclassName(int aRow, wxString aName, bool focusFirst=true)
#define MYCELL(col)
const BITMAP_OPAQUE small_plus_xpm[1]
Definition: small_plus.cpp:18
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)