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() );
316 nc->GetTrackWidthOpt() );
320 nc->GetuViaDiameterOpt() );
323 nc->GetDiffPairWidthOpt() );
325 nc->GetDiffPairGapOpt() );
327 colorAsString = nc->GetPcbColor().ToCSSString();
330 if( nc->IsDefault() )
342 std::vector<const NETCLASS*> netclasses;
346 netclasses.push_back( netclass.get() );
348 std::sort( netclasses.begin(), netclasses.end(),
351 return nc1->GetPriority() < nc2->GetPriority();
356 m_netclassGrid->AppendRows(
static_cast<int>( netclasses.size() ) );
360 for(
const NETCLASS* nc : netclasses )
361 netclassToGridRow( row++, nc );
365 netclassToGridRow( row,
m_netSettings->GetDefaultNetclass().get() );
372 for(
const auto& [matcher, netclassName] :
m_netSettings->GetNetclassPatternAssignments() )
384 auto setCellEditor = [
this, aRowId, aIsDefault](
int aCol )
393 wxGridCellAttr* attr =
m_netclassGrid->GetOrCreateCellAttr( aRowId, aCol );
394 attr->SetEditor( cellEditor );
418 if(
IsOK( m_parent,
_(
"The netclasses have been changed outside the Setup dialog.\n"
419 "Do you wish to reload them?" ) ) )
429 std::shared_ptr<NET_SETTINGS> tempNetSettings = std::make_shared<NET_SETTINGS>(
nullptr,
"" );
430 std::shared_ptr<NET_SETTINGS> saveNetSettings =
m_netSettings;
463 wxArrayString netclassNames;
469 if( !netclassName.IsEmpty() )
470 netclassNames.push_back( netclassName );
473 wxGridCellAttr* attr =
new wxGridCellAttr;
474 attr->SetEditor(
new wxGridCellChoiceEditor( netclassNames ) );
484 auto gridRowToNetclass =
485 [&](
int aRow,
const std::shared_ptr<NETCLASS>& nc )
487 if( nc->IsDefault() )
488 nc->SetPriority( std::numeric_limits<int>::max() );
490 nc->SetPriority( aRow );
501 nc->SetLineStyle( std::optional<int>() );
503 nc->SetLineStyle( lineIdx - 1 );
505 wxASSERT_MSG( lineIdx >= 0,
"Line style name not found." );
513 nc->SetDiffPairWidth(
518 if( !nc->IsDefault() )
524 nc->SetPcbColor( newPcbColor );
530 nc->SetSchematicColor( newSchematicColor );
540 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
544 gridRowToNetclass( row, nc );
556 m_netSettings->SetNetclassPatternAssignment( pattern, netclass );
566 wxString tmp = aName;
573 wxString msg =
_(
"Netclass must have a name." );
582 wxString msg =
_(
"Netclass name already in use." );
600 wxString newName =
event.GetString();
602 if( !oldName.IsEmpty() )
625 if( aEvent.Moving() || aEvent.Entering() )
629 if( col == wxNOT_FOUND )
649 case GRID_uVIADRILL: tip =
_(
"Microvia plated hole diameter" );
break;
662 else if( aEvent.Leaving() )
711 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
806 const std::map<wxString, std::shared_ptr<NETCLASS>>& netclasses =
809 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
813 if( netclasses.find( netclassName ) != netclasses.end() )
815 const KIGFX::COLOR4D ncColor = netclasses.at( netclassName )->GetSchematicColor();
827 int classNameWidth = 160;
829 m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
869 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
870 pattern = txt->GetValue();
872 cellEditor->DecRef();
879 if( !pattern.IsEmpty() )
910 netclassName.Trim(
true );
911 netclassName.Trim(
false );
943 std::vector<int> selectedRows;
948 selectedRows.push_back( i );
952 if( selectedRows.size() != 1 )
956 if( selectedRows[0] == 0 || selectedRows[0] == (
m_netclassGrid->GetNumberRows() - 1 ) )
959 int newRowId = selectedRows[0] - 1;
983 std::vector<int> selectedRows;
988 selectedRows.push_back( i );
992 if( selectedRows.size() != 1 )
1000 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)
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 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()
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