KiCad PCB EDA Suite
PANEL_SETUP_NETCLASSES Class Reference

#include <panel_setup_netclasses.h>

Inheritance diagram for PANEL_SETUP_NETCLASSES:
PANEL_SETUP_NETCLASSES_BASE

Public Member Functions

 PANEL_SETUP_NETCLASSES (PAGED_DIALOG *aParent, EDA_DRAW_FRAME *aFrame, std::shared_ptr< NET_SETTINGS > aSettings, const std::set< wxString > &aNetNames, bool isEEschema)
 
 ~PANEL_SETUP_NETCLASSES () override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
bool Validate () override
 
void ImportSettingsFrom (const std::shared_ptr< NET_SETTINGS > &aNetSettings)
 

Protected Member Functions

virtual void onmembershipPanelSize (wxSizeEvent &event)
 

Protected Attributes

wxSplitterWindow * m_splitter
 
wxPanel * m_netclassesPane
 
WX_GRIDm_netclassGrid
 
wxBitmapButton * m_addButton
 
wxBitmapButton * m_removeButton
 
wxStaticText * m_colorDefaultHelpText
 
wxPanel * m_membershipPane
 
wxStaticText * m_staticText5
 
WX_GRIDm_assignmentGrid
 
WX_HTML_REPORT_BOXm_matchingNets
 
wxBitmapButton * m_addAssignmentButton
 
wxBitmapButton * m_removeAssignmentButton
 

Private Member Functions

void OnAddNetclassClick (wxCommandEvent &event) override
 
void OnRemoveNetclassClick (wxCommandEvent &event) override
 
void OnSizeNetclassGrid (wxSizeEvent &event) override
 
void OnSizeAssignmentGrid (wxSizeEvent &event) override
 
void OnAddAssignmentClick (wxCommandEvent &event) override
 
void OnRemoveAssignmentClick (wxCommandEvent &event) override
 
void OnUpdateUI (wxUpdateUIEvent &event) override
 
void OnNetclassGridCellChanging (wxGridEvent &event)
 
void OnNetclassGridMouseEvent (wxMouseEvent &event)
 
void onUnitsChanged (wxCommandEvent &aEvent)
 
bool validateNetclassName (int aRow, const wxString &aName, bool focusFirst=true)
 
void rebuildNetclassDropdowns ()
 
void AdjustNetclassGridColumns (int aWidth)
 
void AdjustAssignmentGridColumns (int aWidth)
 

Private Attributes

EDA_DRAW_FRAMEm_frame
 
PAGED_DIALOGm_parent
 
bool m_isEEschema
 
std::shared_ptr< NET_SETTINGSm_netSettings
 
std::set< wxString > m_netNames
 
std::unique_ptr< UNITS_PROVIDERm_schUnitsProvider
 
std::unique_ptr< UNITS_PROVIDERm_pcbUnitsProvider
 
int * m_originalColWidths
 
bool m_netclassesDirty
 
int m_hoveredCol
 
wxString m_lastPattern
 
int m_lastNetclassGridWidth
 

Detailed Description

Definition at line 35 of file panel_setup_netclasses.h.

Constructor & Destructor Documentation

◆ PANEL_SETUP_NETCLASSES()

PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES ( PAGED_DIALOG aParent,
EDA_DRAW_FRAME aFrame,
std::shared_ptr< NET_SETTINGS aSettings,
const std::set< wxString > &  aNetNames,
bool  isEEschema 
)

Definition at line 71 of file panel_setup_netclasses.cpp.

74 :
76 m_frame( aFrame ),
77 m_parent( aParent ),
78 m_isEEschema( aIsEEschema ),
79 m_netSettings( aNetSettings ),
80 m_netNames( aNetNames ),
81 m_hoveredCol( -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}
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
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:61
wxTreebook * GetTreebook()
Definition: paged_dialog.h:37
PANEL_SETUP_NETCLASSES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void onUnitsChanged(wxCommandEvent &aEvent)
void OnNetclassGridCellChanging(wxGridEvent &event)
std::unique_ptr< UNITS_PROVIDER > m_pcbUnitsProvider
void OnNetclassGridMouseEvent(wxMouseEvent &event)
std::set< wxString > m_netNames
std::unique_ptr< UNITS_PROVIDER > m_schUnitsProvider
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 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
#define _(s)
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
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References _, WX_GRID::EnsureColLabelsVisible(), g_lineStyleIcons, g_lineStyleNames, KIUI::GetInfoFont(), UNITS_PROVIDER::GetUserUnits(), WX_GRID::GetVisibleWidth(), GRID_BUSWIDTH, GRID_CLEARANCE, GRID_DIFF_PAIR_GAP, GRID_DIFF_PAIR_WIDTH, GRID_END, GRID_FIRST_EESCHEMA, GRID_FIRST_PCBNEW, GRID_LINESTYLE, GRID_SCHEMATIC_COLOR, GRID_TRACKSIZE, GRID_uVIADRILL, GRID_uVIASIZE, GRID_VIADRILL, GRID_VIASIZE, GRID_WIREWIDTH, KiBitmap(), PANEL_SETUP_NETCLASSES_BASE::m_addAssignmentButton, PANEL_SETUP_NETCLASSES_BASE::m_addButton, PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, PANEL_SETUP_NETCLASSES_BASE::m_colorDefaultHelpText, m_frame, m_isEEschema, PANEL_SETUP_NETCLASSES_BASE::m_matchingNets, m_netclassesDirty, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, COMMON_SETTINGS::m_NetclassPanel, m_originalColWidths, m_pcbUnitsProvider, PANEL_SETUP_NETCLASSES_BASE::m_removeAssignmentButton, PANEL_SETUP_NETCLASSES_BASE::m_removeButton, m_schUnitsProvider, PANEL_SETUP_NETCLASSES_BASE::m_splitter, OnNetclassGridCellChanging(), OnNetclassGridMouseEvent(), onUnitsChanged(), pcbIUScale, Pgm(), COMMON_SETTINGS::NETCLASS_PANEL::sash_pos, schIUScale, WX_GRID::SetAutoEvalCols(), WX_GRID::SetUnitsProvider(), small_plus, small_trash, stroke_dash, stroke_dashdot, stroke_dashdotdot, stroke_dot, and stroke_solid.

◆ ~PANEL_SETUP_NETCLASSES()

PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES ( )
override

Definition at line 224 of file panel_setup_netclasses.cpp.

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}

References PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, m_frame, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, COMMON_SETTINGS::m_NetclassPanel, m_originalColWidths, PANEL_SETUP_NETCLASSES_BASE::m_splitter, OnNetclassGridCellChanging(), onUnitsChanged(), Pgm(), and COMMON_SETTINGS::NETCLASS_PANEL::sash_pos.

Member Function Documentation

◆ AdjustAssignmentGridColumns()

void PANEL_SETUP_NETCLASSES::AdjustAssignmentGridColumns ( int  aWidth)
private

Definition at line 643 of file panel_setup_netclasses.cpp.

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}

References PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, and m_originalColWidths.

Referenced by OnSizeAssignmentGrid().

◆ AdjustNetclassGridColumns()

void PANEL_SETUP_NETCLASSES::AdjustNetclassGridColumns ( int  aWidth)
private

Definition at line 577 of file panel_setup_netclasses.cpp.

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}

References m_lastNetclassGridWidth, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, and m_originalColWidths.

Referenced by OnSizeNetclassGrid().

◆ ImportSettingsFrom()

void PANEL_SETUP_NETCLASSES::ImportSettingsFrom ( const std::shared_ptr< NET_SETTINGS > &  aNetSettings)

Definition at line 740 of file panel_setup_netclasses.cpp.

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}

References PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_netSettings, rebuildNetclassDropdowns(), and TransferDataToWindow().

Referenced by DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction(), and DIALOG_BOARD_SETUP::onAuxiliaryAction().

◆ OnAddAssignmentClick()

void PANEL_SETUP_NETCLASSES::OnAddAssignmentClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 605 of file panel_setup_netclasses.cpp.

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}
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:280

References WX_GRID::CommitPendingChanges(), PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, and m_netSettings.

◆ OnAddNetclassClick()

void PANEL_SETUP_NETCLASSES::OnAddNetclassClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 520 of file panel_setup_netclasses.cpp.

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}

References WX_GRID::CommitPendingChanges(), m_netclassesDirty, and PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid.

◆ onmembershipPanelSize()

virtual void PANEL_SETUP_NETCLASSES_BASE::onmembershipPanelSize ( wxSizeEvent &  event)
inlineprotectedvirtualinherited

◆ OnNetclassGridCellChanging()

void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ( wxGridEvent &  event)
private

Definition at line 442 of file panel_setup_netclasses.cpp.

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}
bool validateNetclassName(int aRow, const wxString &aName, bool focusFirst=true)

References GRID_NAME, PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, m_netclassesDirty, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, and validateNetclassName().

Referenced by PANEL_SETUP_NETCLASSES(), and ~PANEL_SETUP_NETCLASSES().

◆ OnNetclassGridMouseEvent()

void PANEL_SETUP_NETCLASSES::OnNetclassGridMouseEvent ( wxMouseEvent &  event)
private

Definition at line 470 of file panel_setup_netclasses.cpp.

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}

References _, GRID_BUSWIDTH, GRID_CLEARANCE, GRID_DIFF_PAIR_GAP, GRID_DIFF_PAIR_WIDTH, GRID_LINESTYLE, GRID_SCHEMATIC_COLOR, GRID_TRACKSIZE, GRID_uVIADRILL, GRID_uVIASIZE, GRID_VIADRILL, GRID_VIASIZE, GRID_WIREWIDTH, m_hoveredCol, and PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid.

Referenced by PANEL_SETUP_NETCLASSES().

◆ OnRemoveAssignmentClick()

void PANEL_SETUP_NETCLASSES::OnRemoveAssignmentClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 623 of file panel_setup_netclasses.cpp.

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}

References WX_GRID::CommitPendingChanges(), and PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid.

◆ OnRemoveNetclassClick()

void PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 542 of file panel_setup_netclasses.cpp.

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}
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:299

References _, WX_GRID::CommitPendingChanges(), NETCLASS::Default, DisplayErrorMessage(), GRID_NAME, PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, m_netclassesDirty, and PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid.

◆ OnSizeAssignmentGrid()

void PANEL_SETUP_NETCLASSES::OnSizeAssignmentGrid ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 655 of file panel_setup_netclasses.cpp.

656{
657 AdjustAssignmentGridColumns( event.GetSize().GetX());
658
659 event.Skip();
660}
void AdjustAssignmentGridColumns(int aWidth)

References AdjustAssignmentGridColumns().

◆ OnSizeNetclassGrid()

void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid ( wxSizeEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 597 of file panel_setup_netclasses.cpp.

598{
599 AdjustNetclassGridColumns( event.GetSize().GetX() );
600
601 event.Skip();
602}
void AdjustNetclassGridColumns(int aWidth)

References AdjustNetclassGridColumns().

◆ onUnitsChanged()

void PANEL_SETUP_NETCLASSES::onUnitsChanged ( wxCommandEvent &  aEvent)
private

Definition at line 243 of file panel_setup_netclasses.cpp.

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}

References UNITS_PROVIDER::GetUserUnits(), m_frame, m_netSettings, m_pcbUnitsProvider, m_schUnitsProvider, TransferDataFromWindow(), and TransferDataToWindow().

Referenced by PANEL_SETUP_NETCLASSES(), and ~PANEL_SETUP_NETCLASSES().

◆ OnUpdateUI()

void PANEL_SETUP_NETCLASSES::OnUpdateUI ( wxUpdateUIEvent &  event)
overrideprivatevirtual

Reimplemented from PANEL_SETUP_NETCLASSES_BASE.

Definition at line 663 of file panel_setup_netclasses.cpp.

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}
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.
@ CTX_NETCLASS
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

References _, WX_HTML_REPORT_BOX::Clear(), CTX_NETCLASS, EDA_COMBINED_MATCHER::Find(), WX_HTML_REPORT_BOX::Flush(), Format(), PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, m_lastPattern, PANEL_SETUP_NETCLASSES_BASE::m_matchingNets, m_netclassesDirty, m_netNames, rebuildNetclassDropdowns(), and WX_HTML_REPORT_BOX::Report().

◆ rebuildNetclassDropdowns()

void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns ( )
private

Definition at line 330 of file panel_setup_netclasses.cpp.

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}

References WX_GRID::CommitPendingChanges(), GRID_NAME, PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, and PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid.

Referenced by ImportSettingsFrom(), and OnUpdateUI().

◆ TransferDataFromWindow()

bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow ( )
override

Definition at line 350 of file panel_setup_netclasses.cpp.

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}
int color
Definition: DXF_plotter.cpp:57
int GetUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
Definition: wx_grid.cpp:338

References color, CTX_NETCLASS, g_lineStyleNames, WX_GRID::GetUnitValue(), GRID_BUSWIDTH, GRID_CLEARANCE, GRID_DIFF_PAIR_GAP, GRID_DIFF_PAIR_WIDTH, GRID_LINESTYLE, GRID_NAME, GRID_SCHEMATIC_COLOR, GRID_TRACKSIZE, GRID_uVIADRILL, GRID_uVIASIZE, GRID_VIADRILL, GRID_VIASIZE, GRID_WIREWIDTH, PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_netSettings, and Validate().

Referenced by onUnitsChanged().

◆ TransferDataToWindow()

bool PANEL_SETUP_NETCLASSES::TransferDataToWindow ( )
override

Definition at line 263 of file panel_setup_netclasses.cpp.

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}
const char * name
Definition: DXF_plotter.cpp:56
void SetUnitValue(int aRow, int aCol, int aValue)
Set a unitized cell's value.
Definition: wx_grid.cpp:359
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

References WX_GRID::ClearRows(), g_lineStyleNames, GRID_BUSWIDTH, GRID_CLEARANCE, GRID_DIFF_PAIR_GAP, GRID_DIFF_PAIR_WIDTH, GRID_LINESTYLE, GRID_NAME, GRID_SCHEMATIC_COLOR, GRID_TRACKSIZE, GRID_uVIADRILL, GRID_uVIASIZE, GRID_VIADRILL, GRID_VIASIZE, GRID_WIREWIDTH, PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_netSettings, name, and WX_GRID::SetUnitValue().

Referenced by ImportSettingsFrom(), and onUnitsChanged().

◆ Validate()

bool PANEL_SETUP_NETCLASSES::Validate ( )
override

Definition at line 718 of file panel_setup_netclasses.cpp.

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}

References WX_GRID::CommitPendingChanges(), GRID_NAME, PANEL_SETUP_NETCLASSES_BASE::m_assignmentGrid, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, and validateNetclassName().

Referenced by TransferDataFromWindow().

◆ validateNetclassName()

bool PANEL_SETUP_NETCLASSES::validateNetclassName ( int  aRow,
const wxString &  aName,
bool  focusFirst = true 
)
private

Definition at line 413 of file panel_setup_netclasses.cpp.

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}
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)

References _, GRID_NAME, PANEL_SETUP_NETCLASSES_BASE::m_netclassGrid, m_parent, and PAGED_DIALOG::SetError().

Referenced by OnNetclassGridCellChanging(), and Validate().

Member Data Documentation

◆ m_addAssignmentButton

wxBitmapButton* PANEL_SETUP_NETCLASSES_BASE::m_addAssignmentButton
protectedinherited

◆ m_addButton

wxBitmapButton* PANEL_SETUP_NETCLASSES_BASE::m_addButton
protectedinherited

◆ m_assignmentGrid

◆ m_colorDefaultHelpText

wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_colorDefaultHelpText
protectedinherited

◆ m_frame

EDA_DRAW_FRAME* PANEL_SETUP_NETCLASSES::m_frame
private

◆ m_hoveredCol

int PANEL_SETUP_NETCLASSES::m_hoveredCol
private

Definition at line 82 of file panel_setup_netclasses.h.

Referenced by OnNetclassGridMouseEvent().

◆ m_isEEschema

bool PANEL_SETUP_NETCLASSES::m_isEEschema
private

Definition at line 73 of file panel_setup_netclasses.h.

Referenced by PANEL_SETUP_NETCLASSES().

◆ m_lastNetclassGridWidth

int PANEL_SETUP_NETCLASSES::m_lastNetclassGridWidth
private

Definition at line 85 of file panel_setup_netclasses.h.

Referenced by AdjustNetclassGridColumns().

◆ m_lastPattern

wxString PANEL_SETUP_NETCLASSES::m_lastPattern
private

Definition at line 83 of file panel_setup_netclasses.h.

Referenced by OnUpdateUI().

◆ m_matchingNets

WX_HTML_REPORT_BOX* PANEL_SETUP_NETCLASSES_BASE::m_matchingNets
protectedinherited

◆ m_membershipPane

wxPanel* PANEL_SETUP_NETCLASSES_BASE::m_membershipPane
protectedinherited

◆ m_netclassesDirty

bool PANEL_SETUP_NETCLASSES::m_netclassesDirty
private

◆ m_netclassesPane

wxPanel* PANEL_SETUP_NETCLASSES_BASE::m_netclassesPane
protectedinherited

◆ m_netclassGrid

◆ m_netNames

std::set<wxString> PANEL_SETUP_NETCLASSES::m_netNames
private

Definition at line 75 of file panel_setup_netclasses.h.

Referenced by OnUpdateUI().

◆ m_netSettings

std::shared_ptr<NET_SETTINGS> PANEL_SETUP_NETCLASSES::m_netSettings
private

◆ m_originalColWidths

int* PANEL_SETUP_NETCLASSES::m_originalColWidths
private

◆ m_parent

PAGED_DIALOG* PANEL_SETUP_NETCLASSES::m_parent
private

Definition at line 72 of file panel_setup_netclasses.h.

Referenced by validateNetclassName().

◆ m_pcbUnitsProvider

std::unique_ptr<UNITS_PROVIDER> PANEL_SETUP_NETCLASSES::m_pcbUnitsProvider
private

Definition at line 78 of file panel_setup_netclasses.h.

Referenced by onUnitsChanged(), and PANEL_SETUP_NETCLASSES().

◆ m_removeAssignmentButton

wxBitmapButton* PANEL_SETUP_NETCLASSES_BASE::m_removeAssignmentButton
protectedinherited

◆ m_removeButton

wxBitmapButton* PANEL_SETUP_NETCLASSES_BASE::m_removeButton
protectedinherited

◆ m_schUnitsProvider

std::unique_ptr<UNITS_PROVIDER> PANEL_SETUP_NETCLASSES::m_schUnitsProvider
private

Definition at line 77 of file panel_setup_netclasses.h.

Referenced by onUnitsChanged(), and PANEL_SETUP_NETCLASSES().

◆ m_splitter

wxSplitterWindow* PANEL_SETUP_NETCLASSES_BASE::m_splitter
protectedinherited

◆ m_staticText5

wxStaticText* PANEL_SETUP_NETCLASSES_BASE::m_staticText5
protectedinherited

The documentation for this class was generated from the following files: