81 std::shared_ptr<NET_SETTINGS> aNetSettings,
82 const std::set<wxString>& aNetNames,
86 m_isEEschema( aIsEEschema ),
87 m_netSettings(
std::
move( aNetSettings ) ),
88 m_netNames( aNetNames ),
89 m_lastCheckedTicker( 0 ),
91 m_lastNetclassGridWidth( -1 ),
132 int const min_best_width =
m_netclassGrid->GetTextExtent(
"555,555555 mils" ).x;
140 int const weighted_min_best_width = ( i ==
GRID_LINESTYLE ) ? min_best_width * 3 / 2
162 wxGridCellAttr* attr =
new wxGridCellAttr;
167 attr =
new wxGridCellAttr;
172 attr =
new wxGridCellAttr;
242 [
this]( wxIdleEvent& aEvent )
248 wxWindow* dialog = wxGetTopLevelParent( this );
249 wxWindow* topLevelFocus = wxGetTopLevelParent( wxWindow::FindFocus() );
251 if( topLevelFocus == dialog && m_lastLoaded != m_netSettings->GetNetclasses() )
288 auto netclassToGridRow =
297 wxString colorAsString = nc->GetSchematicColor().ToCSSString();
300 if( nc->HasLineStyle() )
302 int lineStyleIdx = std::max( 0, nc->GetLineStyle() );
324 colorAsString = nc->GetPcbColor().ToCSSString();
327 if( nc->IsDefault() )
339 std::vector<const NETCLASS*> netclasses;
343 netclasses.push_back( netclass.get() );
345 std::sort( netclasses.begin(), netclasses.end(),
348 return nc1->GetPriority() < nc2->GetPriority();
353 m_netclassGrid->AppendRows(
static_cast<int>( netclasses.size() ) );
357 for(
const NETCLASS* nc : netclasses )
358 netclassToGridRow( row++, nc );
362 netclassToGridRow( row,
m_netSettings->GetDefaultNetclass().get() );
369 for(
const auto& [matcher, netclassName] :
m_netSettings->GetNetclassPatternAssignments() )
381 auto setCellEditor = [
this, aRowId, aIsDefault](
int aCol )
390 wxGridCellAttr* attr =
m_netclassGrid->GetOrCreateCellAttr( aRowId, aCol );
391 attr->SetEditor( cellEditor );
415 if(
IsOK( m_parent,
_(
"The netclasses have been changed outside the Setup dialog.\n"
416 "Do you wish to reload them?" ) ) )
426 std::shared_ptr<NET_SETTINGS> tempNetSettings = std::make_shared<NET_SETTINGS>(
nullptr,
"" );
427 std::shared_ptr<NET_SETTINGS> saveNetSettings =
m_netSettings;
460 wxArrayString netclassNames;
466 if( !netclassName.IsEmpty() )
467 netclassNames.push_back( netclassName );
470 wxGridCellAttr* attr =
new wxGridCellAttr;
471 attr->SetEditor(
new wxGridCellChoiceEditor( netclassNames ) );
481 auto gridRowToNetclass =
482 [&](
int aRow,
const std::shared_ptr<NETCLASS>& nc )
484 if( nc->IsDefault() )
485 nc->SetPriority( std::numeric_limits<int>::max() );
487 nc->SetPriority( aRow );
499 nc->SetLineStyle( std::optional<int>() );
501 nc->SetLineStyle( lineIdx - 1 );
503 wxASSERT_MSG( lineIdx >= 0,
"Line style name not found." );
516 if( !nc->IsDefault() )
522 nc->SetPcbColor( newPcbColor );
528 nc->SetSchematicColor( newSchematicColor );
538 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
541 gridRowToNetclass( row, nc );
553 m_netSettings->SetNetclassPatternAssignment( pattern, netclass );
563 wxString tmp = aName;
570 wxString msg =
_(
"Netclass must have a name." );
579 wxString msg =
_(
"Netclass name already in use." );
599 wxString msg = wxString::Format(
_(
"Clearance was too large. It has been clipped to %s." ),
617 wxString newName =
event.GetString();
619 if( !oldName.IsEmpty() )
648 if( ( event.GetCol() < 0 ) || ( event.GetCol() >=
m_assignmentGrid->GetNumberCols() ) )
662 std::vector<std::pair<wxString, wxString>> netclassesassignments;
667 netclassesassignments.emplace_back(
m_assignmentGrid->GetCellValue( row, 0 ),
671 std::sort( netclassesassignments.begin(), netclassesassignments.end(),
672 [
this](
const std::pair<wxString, wxString>& assign1,
673 const std::pair<wxString, wxString>& assign2 )
675 const wxString& str1 = ( m_sortCol == 0 ) ? assign1.first : assign1.second;
676 const wxString& str2 = ( m_sortCol == 0 ) ? assign2.first : assign2.second;
677 return m_sortAsc ? ( str1 < str2 ) : ( str1 > str2 );
685 for(
const auto& [pattern, netclassName] : netclassesassignments )
697 if( aEvent.Moving() || aEvent.Entering() )
701 if( col == wxNOT_FOUND )
721 case GRID_uVIADRILL: tip =
_(
"Microvia plated hole diameter" );
break;
734 else if( aEvent.Leaving() )
783 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
878 const std::map<wxString, std::shared_ptr<NETCLASS>>& netclasses =
881 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
885 if( netclasses.find( netclassName ) != netclasses.end() )
887 const KIGFX::COLOR4D ncColor = netclasses.at( netclassName )->GetSchematicColor();
899 int classNameWidth = 160;
901 m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
941 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
942 pattern = txt->GetValue();
944 cellEditor->DecRef();
951 if( !pattern.IsEmpty() )
979 netclassName.Trim(
true );
980 netclassName.Trim(
false );
1015 std::vector<int> selectedRows;
1020 selectedRows.push_back( i );
1024 if( selectedRows.size() != 1 )
1028 if( selectedRows[0] == 0 || selectedRows[0] == (
m_netclassGrid->GetNumberRows() - 1 ) )
1031 int newRowId = selectedRows[0] - 1;
1054 std::vector<int> selectedRows;
1059 selectedRows.push_back( i );
1063 if( selectedRows.size() != 1 )
1073 int newRowId = selectedRows[0] + 2;
1089 wxArrayString profileNames;
1090 profileNames.push_back( wxEmptyString );
1091 std::ranges::for_each( aNames,
1092 [&](
const wxString& aName )
1094 profileNames.push_back( aName );
1097 wxGridCellAttr* attr =
new wxGridCellAttr;
1098 attr->SetEditor(
new wxGridCellChoiceEditor( profileNames,
false ) );
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 UpdateDelayProfileNames(const std::vector< wxString > &aNames) const
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 OnNetclassAssignmentSort(wxGridEvent &event)
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