80 std::shared_ptr<NET_SETTINGS> aNetSettings,
81 const std::set<wxString>& aNetNames,
85 m_isEEschema( aIsEEschema ),
86 m_netSettings(
std::
move( aNetSettings ) ),
87 m_netNames( aNetNames ),
88 m_lastCheckedTicker( 0 ),
90 m_lastNetclassGridWidth( -1 )
129 int const min_best_width =
m_netclassGrid->GetTextExtent(
"555,555555 mils" ).x;
137 int const weighted_min_best_width = ( i ==
GRID_LINESTYLE ) ? min_best_width * 3 / 2
159 wxGridCellAttr* attr =
new wxGridCellAttr;
165 attr =
new wxGridCellAttr;
171 attr =
new wxGridCellAttr;
183 _(
"Set color to transparent to use layer default color." ) );
243 [
this]( wxIdleEvent& aEvent )
249 wxWindow* dialog = wxGetTopLevelParent( this );
250 wxWindow* topLevelFocus = wxGetTopLevelParent( wxWindow::FindFocus() );
252 if( topLevelFocus == dialog && m_lastLoaded != m_netSettings->GetNetclasses() )
285 auto netclassToGridRow =
291 nc->GetWireWidthOpt() );
293 nc->GetBusWidthOpt() );
295 wxString colorAsString = nc->GetSchematicColor().ToCSSString();
298 if( nc->HasLineStyle() )
300 int lineStyleIdx = std::max( 0, nc->GetLineStyle() );
317 nc->GetTrackWidthOpt() );
321 nc->GetuViaDiameterOpt() );
324 nc->GetDiffPairWidthOpt() );
326 nc->GetDiffPairGapOpt() );
328 colorAsString = nc->GetPcbColor().ToCSSString();
331 if( nc->IsDefault() )
343 std::vector<const NETCLASS*> netclasses;
347 netclasses.push_back( netclass.get() );
349 std::sort( netclasses.begin(), netclasses.end(),
352 return nc1->GetPriority() < nc2->GetPriority();
357 m_netclassGrid->AppendRows(
static_cast<int>( netclasses.size() ) );
361 for(
const NETCLASS* nc : netclasses )
362 netclassToGridRow( row++, nc );
366 netclassToGridRow( row,
m_netSettings->GetDefaultNetclass().get() );
373 for(
const auto& [matcher, netclassName] :
m_netSettings->GetNetclassPatternAssignments() )
385 auto setCellEditor = [
this, aRowId, aIsDefault](
int aCol )
394 wxGridCellAttr* attr =
m_netclassGrid->GetOrCreateCellAttr( aRowId, aCol );
395 attr->SetEditor( cellEditor );
419 if(
IsOK( m_parent,
_(
"The netclasses have been changed outside the Setup dialog.\n"
420 "Do you wish to reload them?" ) ) )
430 std::shared_ptr<NET_SETTINGS> tempNetSettings = std::make_shared<NET_SETTINGS>(
nullptr,
"" );
431 std::shared_ptr<NET_SETTINGS> saveNetSettings =
m_netSettings;
464 wxArrayString netclassNames;
470 if( !netclassName.IsEmpty() )
471 netclassNames.push_back( netclassName );
474 wxGridCellAttr* attr =
new wxGridCellAttr;
475 attr->SetEditor(
new wxGridCellChoiceEditor( netclassNames ) );
485 auto gridRowToNetclass =
486 [&](
int aRow,
const std::shared_ptr<NETCLASS>& nc )
488 if( nc->IsDefault() )
489 nc->SetPriority( std::numeric_limits<int>::max() );
491 nc->SetPriority( aRow );
502 nc->SetLineStyle( std::optional<int>() );
504 nc->SetLineStyle( lineIdx - 1 );
506 wxASSERT_MSG( lineIdx >= 0,
"Line style name not found." );
519 if( !nc->IsDefault() )
525 nc->SetPcbColor( newPcbColor );
531 nc->SetSchematicColor( newSchematicColor );
541 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
545 gridRowToNetclass( row, nc );
557 m_netSettings->SetNetclassPatternAssignment( pattern, netclass );
567 wxString tmp = aName;
574 wxString msg =
_(
"Netclass must have a name." );
583 wxString msg =
_(
"Netclass name already in use." );
603 wxString msg = wxString::Format(
_(
"Clearance was too large. It has been clipped to %s." ),
621 wxString newName =
event.GetString();
623 if( !oldName.IsEmpty() )
650 if( aEvent.Moving() || aEvent.Entering() )
654 if( col == wxNOT_FOUND )
674 case GRID_uVIADRILL: tip =
_(
"Microvia plated hole diameter" );
break;
687 else if( aEvent.Leaving() )
736 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
831 const std::map<wxString, std::shared_ptr<NETCLASS>>& netclasses =
834 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
838 if( netclasses.find( netclassName ) != netclasses.end() )
840 const KIGFX::COLOR4D ncColor = netclasses.at( netclassName )->GetSchematicColor();
852 int classNameWidth = 160;
854 m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
894 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
895 pattern = txt->GetValue();
897 cellEditor->DecRef();
904 if( !pattern.IsEmpty() )
933 netclassName.Trim(
true );
934 netclassName.Trim(
false );
969 std::vector<int> selectedRows;
974 selectedRows.push_back( i );
978 if( selectedRows.size() != 1 )
982 if( selectedRows[0] == 0 || selectedRows[0] == (
m_netclassGrid->GetNumberRows() - 1 ) )
985 int newRowId = selectedRows[0] - 1;
1009 std::vector<int> selectedRows;
1014 selectedRows.push_back( i );
1018 if( selectedRows.size() != 1 )
1026 int newRowId = selectedRows[0] + 2;
constexpr EDA_IU_SCALE schIUScale
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
#define MAXIMUM_CLEARANCE
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
bool validateNetclassClearance(int aRow)
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
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aValue in internal units into a united string.
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculate 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 SetUnitValue(int aRow, int aCol, int aValue)
Set a unitized cell's value.
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 EUNITS_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() override
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