79 std::shared_ptr<NET_SETTINGS> aNetSettings,
80 const std::set<wxString>& aNetNames,
84 m_isEEschema( aIsEEschema ),
85 m_netSettings(
std::
move( aNetSettings ) ),
86 m_netNames( aNetNames ),
87 m_lastCheckedTicker( 0 ),
89 m_lastNetclassGridWidth( -1 )
128 int const min_best_width =
m_netclassGrid->GetTextExtent(
"555,555555 mils" ).x;
136 int const weighted_min_best_width = ( i ==
GRID_LINESTYLE ) ? min_best_width * 3 / 2
158 wxGridCellAttr* attr =
new wxGridCellAttr;
164 attr =
new wxGridCellAttr;
170 attr =
new wxGridCellAttr;
182 _(
"Set color to transparent to use layer default color." ) );
242 [
this]( wxIdleEvent& aEvent )
248 wxWindow* dialog = wxGetTopLevelParent( this );
249 wxWindow* topLevelFocus = wxGetTopLevelParent( wxWindow::FindFocus() );
251 if( topLevelFocus == dialog && m_lastLoaded != m_netSettings->GetNetclasses() )
284 auto netclassToGridRow =
290 nc->GetWireWidthOpt() );
292 nc->GetBusWidthOpt() );
294 wxString colorAsString = nc->GetSchematicColor().ToCSSString();
297 if( nc->HasLineStyle() )
299 int lineStyleIdx = std::max( 0, nc->GetLineStyle() );
323 colorAsString = nc->GetPcbColor().ToCSSString();
326 if( nc->IsDefault() )
338 std::vector<const NETCLASS*> netclasses;
342 netclasses.push_back( netclass.get() );
344 std::sort( netclasses.begin(), netclasses.end(),
347 return nc1->GetPriority() < nc2->GetPriority();
352 m_netclassGrid->AppendRows(
static_cast<int>( netclasses.size() ) );
356 for(
const NETCLASS* nc : netclasses )
357 netclassToGridRow( row++, nc );
361 netclassToGridRow( row,
m_netSettings->GetDefaultNetclass().get() );
368 for(
const auto& [matcher, netclassName] :
m_netSettings->GetNetclassPatternAssignments() )
380 auto setCellEditor = [
this, aRowId, aIsDefault](
int aCol )
389 wxGridCellAttr* attr =
m_netclassGrid->GetOrCreateCellAttr( aRowId, aCol );
390 attr->SetEditor( cellEditor );
414 if(
IsOK( m_parent,
_(
"The netclasses have been changed outside the Setup dialog.\n"
415 "Do you wish to reload them?" ) ) )
425 std::shared_ptr<NET_SETTINGS> tempNetSettings = std::make_shared<NET_SETTINGS>(
nullptr,
"" );
426 std::shared_ptr<NET_SETTINGS> saveNetSettings =
m_netSettings;
459 wxArrayString netclassNames;
465 if( !netclassName.IsEmpty() )
466 netclassNames.push_back( netclassName );
469 wxGridCellAttr* attr =
new wxGridCellAttr;
470 attr->SetEditor(
new wxGridCellChoiceEditor( netclassNames ) );
480 auto gridRowToNetclass =
481 [&](
int aRow,
const std::shared_ptr<NETCLASS>& nc )
483 if( nc->IsDefault() )
484 nc->SetPriority( std::numeric_limits<int>::max() );
486 nc->SetPriority( aRow );
497 nc->SetLineStyle( std::optional<int>() );
499 nc->SetLineStyle( lineIdx - 1 );
501 wxASSERT_MSG( lineIdx >= 0,
"Line style name not found." );
512 if( !nc->IsDefault() )
518 nc->SetPcbColor( newPcbColor );
524 nc->SetSchematicColor( newSchematicColor );
534 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
538 gridRowToNetclass( row, nc );
550 m_netSettings->SetNetclassPatternAssignment( pattern, netclass );
560 wxString tmp = aName;
567 wxString msg =
_(
"Netclass must have a name." );
576 wxString msg =
_(
"Netclass name already in use." );
594 wxString newName =
event.GetString();
596 if( !oldName.IsEmpty() )
619 if( aEvent.Moving() || aEvent.Entering() )
623 if( col == wxNOT_FOUND )
643 case GRID_uVIADRILL: tip =
_(
"Microvia plated hole diameter" );
break;
656 else if( aEvent.Leaving() )
705 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
800 const std::map<wxString, std::shared_ptr<NETCLASS>>& netclasses =
803 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
807 if( netclasses.find( netclassName ) != netclasses.end() )
809 const KIGFX::COLOR4D ncColor = netclasses.at( netclassName )->GetSchematicColor();
821 int classNameWidth = 160;
823 m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
863 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
864 pattern = txt->GetValue();
866 cellEditor->DecRef();
873 if( !pattern.IsEmpty() )
904 netclassName.Trim(
true );
905 netclassName.Trim(
false );
937 std::vector<int> selectedRows;
942 selectedRows.push_back( i );
946 if( selectedRows.size() != 1 )
950 if( selectedRows[0] == 0 || selectedRows[0] == (
m_netclassGrid->GetNumberRows() - 1 ) )
953 int newRowId = selectedRows[0] - 1;
977 std::vector<int> selectedRows;
982 selectedRows.push_back( i );
986 if( selectedRows.size() != 1 )
994 int newRowId = selectedRows[0] + 2;
constexpr EDA_IU_SCALE schIUScale
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
NETCLASS_PANEL m_NetclassPanel
bool StartsWith(const wxString &aTerm)
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.
A color representation with 4 components: red, green, blue, alpha.
wxString ToCSSString() const
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
A collection of nets and the parameters used to route or test these nets.
static const char Default[]
the name of the default NETCLASS
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
Class PANEL_SETUP_NETCLASSES_BASE.
wxStaticText * m_colorDefaultHelpText
STD_BITMAP_BUTTON * m_removeAssignmentButton
STD_BITMAP_BUTTON * m_addAssignmentButton
STD_BITMAP_BUTTON * m_removeButton
WX_PANEL * m_netclassesPane
wxButton * m_importColorsButton
WX_PANEL * m_membershipPane
STD_BITMAP_BUTTON * m_moveUpButton
WX_HTML_REPORT_BOX * m_matchingNets
STD_BITMAP_BUTTON * m_moveDownButton
STD_BITMAP_BUTTON * m_addButton
WX_GRID * m_assignmentGrid
wxSplitterWindow * m_splitter
void OnImportColorsClick(wxCommandEvent &event) override
std::map< int, int > m_originalColWidths
void OnUpdateUI(wxUpdateUIEvent &event) override
void OnSizeAssignmentGrid(wxSizeEvent &event) override
PANEL_SETUP_NETCLASSES(wxWindow *aParentWindow, EDA_DRAW_FRAME *aFrame, std::shared_ptr< NET_SETTINGS > aSettings, const std::set< wxString > &aNetNames, bool isEEschema)
int m_lastNetclassGridWidth
void OnRemoveNetclassClick(wxCommandEvent &event) override
void OnRemoveAssignmentClick(wxCommandEvent &event) override
std::map< wxString, std::shared_ptr< NETCLASS > > m_lastLoaded
void ImportSettingsFrom(const std::shared_ptr< NET_SETTINGS > &aNetSettings)
void onUnitsChanged(wxCommandEvent &aEvent)
void rebuildNetclassDropdowns()
~PANEL_SETUP_NETCLASSES() override
void OnNetclassGridCellChanging(wxGridEvent &event)
void setNetclassRowNullableEditors(int aRowId, bool aIsDefault)
bool TransferDataToWindow() override
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)
void OnMoveNetclassUpClick(wxCommandEvent &event) override
std::set< wxString > m_netNames
void OnAddNetclassClick(wxCommandEvent &event) override
bool TransferDataFromWindow() override
std::unique_ptr< UNITS_PROVIDER > m_schUnitsProvider
std::bitset< 64 > m_shownColumns
void OnSizeNetclassGrid(wxSizeEvent &event) override
void AdjustNetclassGridColumns(int aWidth)
std::shared_ptr< NET_SETTINGS > m_netSettings
void OnMoveNetclassDownClick(wxCommandEvent &event) override
virtual COMMON_SETTINGS * GetCommonSettings() const
int GetNetclassesTicker() const
int GetTextVarsTicker() const
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.
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
void SetOptionalUnitValue(int aRow, int aCol, std::optional< int > aValue)
Set a unitized cell's optional value.
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
std::bitset< 64 > GetShownColumns()
std::optional< int > GetOptionalUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
void SetAutoEvalCols(const std::vector< int > &aCols)
void SetUnitsProvider(UNITS_PROVIDER *aProvider, int aCol=0)
Set a UNITS_PROVIDER to enable use of unit- and eval-based Getters.
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
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 SetBorders(bool aLeft, bool aRight, bool aTop, bool aBottom)
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
std::vector< BITMAPS > g_lineStyleIcons
wxArrayString g_lineStyleNames
PGM_BASE & Pgm()
The global Program "get" accessor.
wxString pcbnew_visible_columns
wxString eeschema_visible_columns