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, [email protected]
6 * Copyright (C) 2009-2022 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 <eda_draw_frame.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 <string_utils.h>
40#include <wx/treebook.h>
42
43
44// columns of netclasses grid
45enum {
47
57
63
65};
66
67std::vector<BITMAPS> g_lineStyleIcons;
68wxArrayString g_lineStyleNames;
69
70
72 std::shared_ptr<NET_SETTINGS> aNetSettings,
73 const std::set<wxString>& aNetNames,
74 bool aIsEEschema ) :
75 PANEL_SETUP_NETCLASSES_BASE( aParent->GetTreebook() ),
76 m_frame( aFrame ),
77 m_parent( aParent ),
78 m_isEEschema( aIsEEschema ),
79 m_netSettings( aNetSettings ),
80 m_netNames( aNetNames ),
81 m_hoveredCol( -1 ),
82 m_lastNetclassGridWidth( -1 )
83{
84 // Clear and re-load each time. Language (or darkmode) might have changed.
85 g_lineStyleIcons.clear();
86 g_lineStyleNames.clear();
87
89 g_lineStyleNames.push_back( _( "Solid" ) );
91 g_lineStyleNames.push_back( _( "Dashed" ) );
93 g_lineStyleNames.push_back( _( "Dotted" ) );
95 g_lineStyleNames.push_back( _( "Dash-Dot" ) );
97 g_lineStyleNames.push_back( _( "Dash-Dot-Dot" ) );
98
99 m_netclassesDirty = true;
100
101 m_schUnitsProvider = std::make_unique<UNITS_PROVIDER>( schIUScale, m_frame->GetUserUnits() );
102 m_pcbUnitsProvider = std::make_unique<UNITS_PROVIDER>( pcbIUScale, m_frame->GetUserUnits() );
103
104 // Prevent Size events from firing before we are ready
105 Freeze();
106 m_netclassGrid->BeginBatch();
107 m_assignmentGrid->BeginBatch();
108
109 m_originalColWidths = new int[ m_netclassGrid->GetNumberCols() ];
110 // Calculate a min best size to handle longest usual numeric values:
111 int min_best_width = m_netclassGrid->GetTextExtent( "555,555555 mils" ).x;
112
113 for( int i = 0; i < m_netclassGrid->GetNumberCols(); ++i )
114 {
115 // We calculate the column min size only from texts sizes, not using the initial col width
116 // as this initial width is sometimes strange depending on the language (wxGrid bug?)
117 int min_width = m_netclassGrid->GetVisibleWidth( i, true, true );
118
119 if( i == GRID_LINESTYLE )
120 min_best_width *= 1.5;
121
122 m_netclassGrid->SetColMinimalWidth( i, min_width );
123
124 // We use a "best size" >= min_best_width
125 m_originalColWidths[ i ] = std::max( min_width, min_best_width );
126 m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
127 }
128
129 for( int i = GRID_FIRST_PCBNEW; i < GRID_END; ++i )
130 {
131 if( i >= GRID_FIRST_EESCHEMA )
132 {
134
135 if( !m_isEEschema )
136 {
137 m_netclassGrid->HideCol( i );
138 m_originalColWidths[ i ] = 0;
139 }
140 }
141 else
142 {
144
145 if( m_isEEschema )
146 {
147 m_netclassGrid->HideCol( i );
148 m_originalColWidths[ i ] = 0;
149 }
150 }
151 }
152
153 wxGridCellAttr* attr = new wxGridCellAttr;
154 attr->SetRenderer( new GRID_CELL_COLOR_RENDERER( aParent ) );
155 attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( aParent, m_netclassGrid ) );
156 m_netclassGrid->SetColAttr( GRID_SCHEMATIC_COLOR, attr );
157
158 attr = new wxGridCellAttr;
161 m_netclassGrid->SetColAttr( GRID_LINESTYLE, attr );
162
163 if( m_isEEschema )
164 m_colorDefaultHelpText->SetFont( KIUI::GetInfoFont( this ).Italic() );
165 else
167
170
179
180
181 // Be sure the column labels are readable
183
184 // Membership combobox editors require a bit more room, so increase the row size of
185 // all our grids for consistency
186 m_netclassGrid->SetDefaultRowSize( m_netclassGrid->GetDefaultRowSize() + 4 );
187 m_assignmentGrid->SetDefaultRowSize( m_assignmentGrid->GetDefaultRowSize() + 4 );
188
189 m_netclassGrid->PushEventHandler( new GRID_TRICKS( m_netclassGrid ) );
190 m_assignmentGrid->PushEventHandler( new GRID_TRICKS( m_assignmentGrid ) );
191
192 m_netclassGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
193 m_assignmentGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
194
195 COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
196 m_splitter->SetSashPosition( cfg->m_NetclassPanel.sash_pos );
197
200
203
204 // wxFormBuilder doesn't include this event...
205 m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING,
207 nullptr, this );
208
209 // Handle tooltips for grid
210 m_netclassGrid->GetGridColLabelWindow()->Bind( wxEVT_MOTION,
212 this );
213
214 m_frame->Bind( UNITS_CHANGED, &PANEL_SETUP_NETCLASSES::onUnitsChanged, this );
215
216 m_netclassGrid->EndBatch();
217 m_assignmentGrid->EndBatch();
218 Thaw();
219
220 m_matchingNets->SetFont( KIUI::GetInfoFont( this ) );
221}
222
223
225{
226 COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
227 cfg->m_NetclassPanel.sash_pos = m_splitter->GetSashPosition();
228
229 delete [] m_originalColWidths;
230
231 // Delete the GRID_TRICKS.
232 m_netclassGrid->PopEventHandler( true );
233 m_assignmentGrid->PopEventHandler( true );
234
235 m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING,
237 nullptr, this );
238
239 m_frame->Unbind( UNITS_CHANGED, &PANEL_SETUP_NETCLASSES::onUnitsChanged, this );
240}
241
242
243void PANEL_SETUP_NETCLASSES::onUnitsChanged( wxCommandEvent& aEvent )
244{
245 std::shared_ptr<NET_SETTINGS> tempNetSettings = std::make_shared<NET_SETTINGS>( nullptr, "" );
246 std::shared_ptr<NET_SETTINGS> saveNetSettings = m_netSettings;
247
248 m_netSettings = tempNetSettings;
249
251
252 m_schUnitsProvider->SetUserUnits( m_frame->GetUserUnits() );
253 m_pcbUnitsProvider->SetUserUnits( m_frame->GetUserUnits() );
254
256
257 m_netSettings = saveNetSettings;
258
259 aEvent.Skip();
260}
261
262
264{
265 int row = 0;
266
267 auto netclassToGridRow =
268 [&]( int aRow, const std::shared_ptr<NETCLASS>& nc )
269 {
270 m_netclassGrid->SetCellValue( aRow, GRID_NAME, nc->GetName() );
271
272 m_netclassGrid->SetUnitValue( aRow, GRID_WIREWIDTH, nc->GetWireWidth() );
273 m_netclassGrid->SetUnitValue( aRow, GRID_BUSWIDTH, nc->GetBusWidth() );
274
275 wxString colorAsString = nc->GetSchematicColor().ToCSSString();
276 m_netclassGrid->SetCellValue( aRow, GRID_SCHEMATIC_COLOR, colorAsString );
277
278 int lineStyleIdx = std::max( 0, nc->GetLineStyle() );
279
280 if( lineStyleIdx >= (int) g_lineStyleNames.size() )
281 lineStyleIdx = 0;
282
283 m_netclassGrid->SetCellValue( aRow, GRID_LINESTYLE, g_lineStyleNames[ lineStyleIdx ] );
284
285 m_netclassGrid->SetUnitValue( aRow, GRID_CLEARANCE, nc->GetClearance() );
286 m_netclassGrid->SetUnitValue( aRow, GRID_TRACKSIZE, nc->GetTrackWidth() );
287 m_netclassGrid->SetUnitValue( aRow, GRID_VIASIZE, nc->GetViaDiameter() );
288 m_netclassGrid->SetUnitValue( aRow, GRID_VIADRILL, nc->GetViaDrill() );
289 m_netclassGrid->SetUnitValue( aRow, GRID_uVIASIZE, nc->GetuViaDiameter() );
290 m_netclassGrid->SetUnitValue( aRow, GRID_uVIADRILL, nc->GetuViaDrill() );
291 m_netclassGrid->SetUnitValue( aRow, GRID_DIFF_PAIR_WIDTH, nc->GetDiffPairWidth() );
292 m_netclassGrid->SetUnitValue( aRow, GRID_DIFF_PAIR_GAP, nc->GetDiffPairGap() );
293 };
294
296
297 // enter the Default NETCLASS.
298 m_netclassGrid->AppendRows( 1 );
299 netclassToGridRow( row++, m_netSettings->m_DefaultNetClass );
300
301 // make the Default NETCLASS name read-only
302 wxGridCellAttr* cellAttr = m_netclassGrid->GetOrCreateCellAttr( 0, GRID_NAME );
303 cellAttr->SetReadOnly();
304 cellAttr->DecRef();
305
306 // enter other netclasses
307 m_netclassGrid->AppendRows( (int) m_netSettings->m_NetClasses.size() );
308
309 for( const auto& [ name, netclass ] : m_netSettings->m_NetClasses )
310 netclassToGridRow( row++, netclass );
311
313 m_assignmentGrid->AppendRows( m_netSettings->m_NetClassPatternAssignments.size() );
314 row = 0;
315
316 for( const auto& [ matcher, netclassName ] : m_netSettings->m_NetClassPatternAssignments )
317 {
318 m_assignmentGrid->SetCellValue( row, 0, matcher->GetPattern() );
319 m_assignmentGrid->SetCellValue( row, 1, netclassName );
320 row++;
321 }
322
323 return true;
324}
325
326
327/*
328 * Populates drop-downs with the list of net classes
329 */
331{
333
334 wxArrayString netclassNames;
335
336 for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
337 {
338 wxString netclassName = m_netclassGrid->GetCellValue( ii, GRID_NAME );
339
340 if( !netclassName.IsEmpty() )
341 netclassNames.push_back( netclassName );
342 }
343
344 wxGridCellAttr* attr = new wxGridCellAttr;
345 attr->SetEditor( new wxGridCellChoiceEditor( netclassNames ) );
346 m_assignmentGrid->SetColAttr( 1, attr );
347}
348
349
351{
352 if( !Validate() )
353 return false;
354
355 int row = 0;
356
357 auto gridRowToNetclass =
358 [&]( int aRow, const std::shared_ptr<NETCLASS>& nc )
359 {
360 nc->SetName( m_netclassGrid->GetCellValue( aRow, GRID_NAME ) );
361
362 nc->SetWireWidth( m_netclassGrid->GetUnitValue( aRow, GRID_WIREWIDTH ) );
363 nc->SetBusWidth( m_netclassGrid->GetUnitValue( aRow, GRID_BUSWIDTH ) );
364
365 wxString color = m_netclassGrid->GetCellValue( aRow, GRID_SCHEMATIC_COLOR );
366 nc->SetSchematicColor( wxColour( color ) );
367
368 wxString lineStyle = m_netclassGrid->GetCellValue( aRow, GRID_LINESTYLE );
369 nc->SetLineStyle( g_lineStyleNames.Index( lineStyle ) );
370 wxASSERT_MSG( nc->GetLineStyle() >= 0, "Line style name not found." );
371
372 nc->SetClearance( m_netclassGrid->GetUnitValue( aRow, GRID_CLEARANCE ) );
373 nc->SetTrackWidth( m_netclassGrid->GetUnitValue( aRow, GRID_TRACKSIZE ) );
374 nc->SetViaDiameter( m_netclassGrid->GetUnitValue( aRow, GRID_VIASIZE ) );
375 nc->SetViaDrill( m_netclassGrid->GetUnitValue( aRow, GRID_VIADRILL ) );
376 nc->SetuViaDiameter( m_netclassGrid->GetUnitValue( aRow, GRID_uVIASIZE ) );
377 nc->SetuViaDrill( m_netclassGrid->GetUnitValue( aRow, GRID_uVIADRILL ) );
378 nc->SetDiffPairWidth( m_netclassGrid->GetUnitValue( aRow, GRID_DIFF_PAIR_WIDTH ) );
379 nc->SetDiffPairGap( m_netclassGrid->GetUnitValue( aRow, GRID_DIFF_PAIR_GAP ) );
380 };
381
382 m_netSettings->m_NetClasses.clear();
383
384 // Copy the default NetClass:
385 gridRowToNetclass( row++, m_netSettings->m_DefaultNetClass );
386
387 // Copy other NetClasses:
388 for( row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
389 {
390 auto nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row, GRID_NAME ) );
391 gridRowToNetclass( row, nc );
392 m_netSettings->m_NetClasses[ nc->GetName() ] = nc;
393 }
394
395 m_netSettings->m_NetClassPatternAssignments.clear();
396
397 for( row = 0; row < m_assignmentGrid->GetNumberRows(); ++row )
398 {
399 wxString pattern = m_assignmentGrid->GetCellValue( row, 0 );
400 wxString netclass = m_assignmentGrid->GetCellValue( row, 1 );
401
402 m_netSettings->m_NetClassPatternAssignments.push_back(
403 {
404 std::make_unique<EDA_COMBINED_MATCHER>( pattern, CTX_NETCLASS ),
405 netclass
406 } );
407 }
408
409 return true;
410}
411
412
413bool PANEL_SETUP_NETCLASSES::validateNetclassName( int aRow, const wxString& aName,
414 bool focusFirst )
415{
416 wxString tmp = aName;
417
418 tmp.Trim( true );
419 tmp.Trim( false );
420
421 if( tmp.IsEmpty() )
422 {
423 wxString msg = _( "Netclass must have a name." );
424 m_parent->SetError( msg, this, m_netclassGrid, aRow, GRID_NAME );
425 return false;
426 }
427
428 for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
429 {
430 if( ii != aRow && m_netclassGrid->GetCellValue( ii, GRID_NAME ).CmpNoCase( tmp ) == 0 )
431 {
432 wxString msg = _( "Netclass name already in use." );
433 m_parent->SetError( msg, this, m_netclassGrid, focusFirst ? aRow : ii, GRID_NAME );
434 return false;
435 }
436 }
437
438 return true;
439}
440
441
443{
444 if( event.GetCol() == GRID_NAME )
445 {
446 if( validateNetclassName( event.GetRow(), event.GetString() ) )
447 {
448 wxString oldName = m_netclassGrid->GetCellValue( event.GetRow(), GRID_NAME );
449 wxString newName = event.GetString();
450
451 if( !oldName.IsEmpty() )
452 {
453 for( int row = 0; row < m_assignmentGrid->GetNumberRows(); ++row )
454 {
455 if( m_assignmentGrid->GetCellValue( row, 1 ) == oldName )
456 m_assignmentGrid->SetCellValue( row, 1, newName );
457 }
458 }
459
460 m_netclassesDirty = true;
461 }
462 else
463 {
464 event.Veto();
465 }
466 }
467}
468
469
471{
472 int col = m_netclassGrid->XToCol( aEvent.GetPosition().x );
473
474 if( aEvent.Moving() || aEvent.Entering() )
475 {
476 aEvent.Skip();
477
478 if( col == wxNOT_FOUND )
479 {
480 m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
481 return;
482 }
483
484 if( col == m_hoveredCol )
485 return;
486
487 m_hoveredCol = col;
488
489 wxString tip;
490
491 switch( col )
492 {
493 case GRID_CLEARANCE: tip = _( "Minimum copper clearance" ); break;
494 case GRID_TRACKSIZE: tip = _( "Minimum track width" ); break;
495 case GRID_VIASIZE: tip = _( "Via pad diameter" ); break;
496 case GRID_VIADRILL: tip = _( "Via plated hole diameter" ); break;
497 case GRID_uVIASIZE: tip = _( "Microvia pad diameter" ); break;
498 case GRID_uVIADRILL: tip = _( "Microvia plated hole diameter" ); break;
499 case GRID_DIFF_PAIR_WIDTH: tip = _( "Differential pair track width" ); break;
500 case GRID_DIFF_PAIR_GAP: tip = _( "Differential pair gap" ); break;
501 case GRID_WIREWIDTH: tip = _( "Schematic wire thickness" ); break;
502 case GRID_BUSWIDTH: tip = _( "Bus wire thickness" ); break;
503 case GRID_SCHEMATIC_COLOR: tip = _( "Schematic wire color" ); break;
504 case GRID_LINESTYLE: tip = _( "Schematic wire line style" ); break;
505 }
506
507 m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
508 m_netclassGrid->GetGridColLabelWindow()->SetToolTip( tip );
509 }
510 else if( aEvent.Leaving() )
511 {
512 m_netclassGrid->GetGridColLabelWindow()->UnsetToolTip();
513 aEvent.Skip();
514 }
515
516 aEvent.Skip();
517}
518
519
521{
523 return;
524
525 int row = m_netclassGrid->GetNumberRows();
526 m_netclassGrid->AppendRows();
527
528 // Copy values of the default class:
529 for( int col = 1; col < m_netclassGrid->GetNumberCols(); col++ )
530 m_netclassGrid->SetCellValue( row, col, m_netclassGrid->GetCellValue( 0, col ) );
531
532 m_netclassGrid->MakeCellVisible( row, 0 );
533 m_netclassGrid->SetGridCursor( row, 0 );
534
535 m_netclassGrid->EnableCellEditControl( true );
536 m_netclassGrid->ShowCellEditControl();
537
538 m_netclassesDirty = true;
539}
540
541
543{
545 return;
546
547 int curRow = m_netclassGrid->GetGridCursorRow();
548
549 if( curRow < 0 )
550 {
551 return;
552 }
553 else if( curRow == 0 )
554 {
555 DisplayErrorMessage( this, _( "The default net class is required." ) );
556 return;
557 }
558
559 // reset the net class to default for members of the removed class
560 wxString classname = m_netclassGrid->GetCellValue( curRow, GRID_NAME );
561
562 for( int row = 0; row < m_assignmentGrid->GetNumberRows(); ++row )
563 {
564 if( m_assignmentGrid->GetCellValue( row, 1 ) == classname )
565 m_assignmentGrid->SetCellValue( row, 1, NETCLASS::Default );
566 }
567
568 m_netclassGrid->DeleteRows( curRow, 1 );
569
570 m_netclassGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
571 m_netclassGrid->SetGridCursor( std::max( 0, curRow-1 ), m_netclassGrid->GetGridCursorCol() );
572
573 m_netclassesDirty = true;
574}
575
576
578{
579 if( aWidth != m_lastNetclassGridWidth )
580 {
582
583 // Account for scroll bars
584 aWidth -= ( m_netclassGrid->GetSize().x - m_netclassGrid->GetClientSize().x );
585
586 for( int i = 1; i < m_netclassGrid->GetNumberCols(); i++ )
587 {
588 m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
589 aWidth -= m_originalColWidths[ i ];
590 }
591
592 m_netclassGrid->SetColSize( 0, std::max( aWidth - 2, m_originalColWidths[ 0 ] ) );
593 }
594}
595
596
598{
599 AdjustNetclassGridColumns( event.GetSize().GetX() );
600
601 event.Skip();
602}
603
604
606{
608 return;
609
610 int row = m_assignmentGrid->GetNumberRows();
611 m_assignmentGrid->AppendRows();
612
613 m_assignmentGrid->SetCellValue( row, 1, m_netSettings->m_DefaultNetClass->GetName() );
614
615 m_assignmentGrid->MakeCellVisible( row, 0 );
616 m_assignmentGrid->SetGridCursor( row, 0 );
617
618 m_assignmentGrid->EnableCellEditControl( true );
619 m_assignmentGrid->ShowCellEditControl();
620}
621
622
624{
626 return;
627
628 int curRow = m_assignmentGrid->GetGridCursorRow();
629
630 if( curRow < 0 )
631 return;
632
633 m_assignmentGrid->DeleteRows( curRow, 1 );
634
635 if( m_assignmentGrid->GetNumberRows() > 0 )
636 {
637 m_assignmentGrid->MakeCellVisible( std::max( 0, curRow-1 ), 0 );
638 m_assignmentGrid->SetGridCursor( std::max( 0, curRow-1 ), 0 );
639 }
640}
641
642
644{
645 // Account for scroll bars
646 aWidth -= ( m_assignmentGrid->GetSize().x - m_assignmentGrid->GetClientSize().x );
647
648 // Set className column width to original className width from netclasses grid
649 int classNameWidth = m_originalColWidths[ 0 ];
650 m_assignmentGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
651 m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
652}
653
654
656{
657 AdjustAssignmentGridColumns( event.GetSize().GetX());
658
659 event.Skip();
660}
661
662
663void PANEL_SETUP_NETCLASSES::OnUpdateUI( wxUpdateUIEvent& event )
664{
666 {
668 m_netclassesDirty = false;
669 }
670
671 if( m_assignmentGrid->GetNumberRows() == 0 )
672 return;
673
674 wxString pattern;
675 int row = m_assignmentGrid->GetGridCursorRow();
676 int col = m_assignmentGrid->GetGridCursorCol();
677
678 if( row >= 0 )
679 pattern = m_assignmentGrid->GetCellValue( row, 0 );
680
681 if( col == 0 && m_assignmentGrid->IsCellEditControlShown() )
682 {
683 wxGridCellEditor* cellEditor = m_assignmentGrid->GetCellEditor( row, 0 );
684
685 if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
686 pattern = txt->GetValue();
687
688 cellEditor->DecRef();
689 }
690
691 if( pattern != m_lastPattern )
692 {
694
695 if( !pattern.IsEmpty() )
696 {
697 EDA_COMBINED_MATCHER matcher( pattern, CTX_NETCLASS );
698
699 m_matchingNets->Report( wxString::Format( _( "<b>Nets matching '%s':</b>" ),
700 pattern ) );
701
702 for( const wxString& net : m_netNames )
703 {
704 int matches;
705 int offset;
706
707 if( matcher.Find( net, matches, offset ) && offset == 0 )
708 m_matchingNets->Report( net );
709 }
710 }
711
713 m_lastPattern = pattern;
714 }
715}
716
717
719{
721 return false;
722
723 wxString msg;
724
725 // Test net class parameters.
726 for( int row = 0; row < m_netclassGrid->GetNumberRows(); row++ )
727 {
728 wxString netclassName = m_netclassGrid->GetCellValue( row, GRID_NAME );
729 netclassName.Trim( true );
730 netclassName.Trim( false );
731
732 if( !validateNetclassName( row, netclassName, false ) )
733 return false;
734 }
735
736 return true;
737}
738
739
740void PANEL_SETUP_NETCLASSES::ImportSettingsFrom( const std::shared_ptr<NET_SETTINGS>& aNetSettings )
741{
742 std::shared_ptr<NET_SETTINGS> savedSettings = m_netSettings;
743
744 m_netSettings = aNetSettings;
746
748
749 m_netclassGrid->ForceRefresh();
750 m_assignmentGrid->ForceRefresh();
751
752 m_netSettings = savedSettings;
753}
754
755
int color
Definition: DXF_plotter.cpp:57
const char * name
Definition: DXF_plotter.cpp:56
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
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
@ stroke_dashdotdot
@ stroke_dashdot
@ stroke_solid
NETCLASS_PANEL m_NetclassPanel
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
The base class for create windows for drawing purpose.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:61
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
Class PANEL_SETUP_NETCLASSES_BASE.
void OnUpdateUI(wxUpdateUIEvent &event) override
void OnSizeAssignmentGrid(wxSizeEvent &event) override
void OnRemoveNetclassClick(wxCommandEvent &event) override
void OnRemoveAssignmentClick(wxCommandEvent &event) override
PANEL_SETUP_NETCLASSES(PAGED_DIALOG *aParent, EDA_DRAW_FRAME *aFrame, std::shared_ptr< NET_SETTINGS > aSettings, const std::set< wxString > &aNetNames, bool isEEschema)
void ImportSettingsFrom(const std::shared_ptr< NET_SETTINGS > &aNetSettings)
void onUnitsChanged(wxCommandEvent &aEvent)
void OnNetclassGridCellChanging(wxGridEvent &event)
bool validateNetclassName(int aRow, const wxString &aName, bool focusFirst=true)
std::unique_ptr< UNITS_PROVIDER > m_pcbUnitsProvider
void OnNetclassGridMouseEvent(wxMouseEvent &event)
void OnAddAssignmentClick(wxCommandEvent &event) override
void AdjustAssignmentGridColumns(int aWidth)
std::set< wxString > m_netNames
void OnAddNetclassClick(wxCommandEvent &event) override
std::unique_ptr< UNITS_PROVIDER > m_schUnitsProvider
void OnSizeNetclassGrid(wxSizeEvent &event) override
void AdjustNetclassGridColumns(int aWidth)
std::shared_ptr< NET_SETTINGS > m_netSettings
EDA_UNITS GetUserUnits() const
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculates the specified column based on the actual size of the text on screen.
Definition: wx_grid.cpp:377
void SetUnitValue(int aRow, int aCol, int aValue)
Set a unitized cell's value.
Definition: wx_grid.cpp:359
int GetUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
Definition: wx_grid.cpp:338
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
Definition: wx_grid.cpp:422
void SetAutoEvalCols(const std::vector< int > &aCols)
Definition: wx_grid.h:90
void SetUnitsProvider(UNITS_PROVIDER *aProvider, int aCol=0)
Set a UNITS_PROVIDER to enable use of unit- and eval-based Getters.
Definition: wx_grid.cpp:329
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
Definition: wx_grid.h:133
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:280
void Clear()
Delete the stored messages.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
void Flush()
Build the HTML messages page.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:299
This file is part of the common library.
#define _(s)
@ CTX_NETCLASS
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144
@ GRID_FIRST_PCBNEW
@ GRID_DIFF_PAIR_GAP
@ GRID_SCHEMATIC_COLOR
@ GRID_DIFF_PAIR_WIDTH
@ GRID_FIRST_EESCHEMA
std::vector< BITMAPS > g_lineStyleIcons
wxArrayString g_lineStyleNames
see class PGM_BASE
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111