28#include <wx/wupdlock.h>
81 std::shared_ptr<NET_SETTINGS> aNetSettings,
82 const std::set<wxString>& aNetNames,
bool aIsEEschema ) :
120 wxWindowUpdateLocker updateLock(
this );
132 int const min_best_width =
m_netclassGrid->GetTextExtent(
"555,555555 mils" ).x;
138 int const min_width =
m_netclassGrid->GetVisibleWidth( i,
true,
true );
140 int const weighted_min_best_width = ( i ==
GRID_LINESTYLE ) ? min_best_width * 3 / 2
160 wxGridCellAttr* attr =
new wxGridCellAttr;
165 attr =
new wxGridCellAttr;
170 attr =
new wxGridCellAttr;
236 [
this]( wxIdleEvent& aEvent )
242 wxWindow* dialog = wxGetTopLevelParent(
this );
243 wxWindow* topLevelFocus = wxGetTopLevelParent( wxWindow::FindFocus() );
274 auto netclassToGridRow =
283 wxString colorAsString = nc->GetSchematicColor().ToCSSString();
286 if( nc->HasLineStyle() )
288 int lineStyleIdx = std::max( 0, nc->GetLineStyle() );
310 colorAsString = nc->GetPcbColor().ToCSSString();
313 if( nc->IsDefault() )
325 std::vector<const NETCLASS*> netclasses;
329 netclasses.push_back( netclass.get() );
331 std::sort( netclasses.begin(), netclasses.end(),
334 return nc1->GetPriority() < nc2->GetPriority();
339 m_netclassGrid->AppendRows(
static_cast<int>( netclasses.size() ) );
343 for(
const NETCLASS* nc : netclasses )
344 netclassToGridRow( row++, nc );
348 netclassToGridRow( row,
m_netSettings->GetDefaultNetclass().get() );
355 for(
const auto& [matcher, netclassName] :
m_netSettings->GetNetclassPatternAssignments() )
368 [
this, aRowId, aIsDefault](
int aCol )
377 wxGridCellAttr* attr =
m_netclassGrid->GetOrCreateCellAttr( aRowId, aCol );
378 attr->SetEditor( cellEditor );
402 if(
IsOK( m_parent,
_(
"The netclasses have been changed outside the Setup dialog.\n"
403 "Do you wish to reload them?" ) ) )
413 std::shared_ptr<NET_SETTINGS> tempNetSettings = std::make_shared<NET_SETTINGS>(
nullptr,
"" );
414 std::shared_ptr<NET_SETTINGS> saveNetSettings =
m_netSettings;
447 wxArrayString netclassNames;
453 if( !netclassName.IsEmpty() )
454 netclassNames.push_back( netclassName );
457 wxGridCellAttr* attr =
new wxGridCellAttr;
458 attr->SetEditor(
new wxGridCellChoiceEditor( netclassNames ) );
468 auto gridRowToNetclass =
469 [&](
int aRow,
const std::shared_ptr<NETCLASS>& nc )
471 if( nc->IsDefault() )
472 nc->SetPriority( std::numeric_limits<int>::max() );
474 nc->SetPriority( aRow );
486 nc->SetLineStyle( std::optional<int>() );
488 nc->SetLineStyle( lineIdx - 1 );
490 wxASSERT_MSG( lineIdx >= 0,
"Line style name not found." );
503 if( !nc->IsDefault() )
509 nc->SetPcbColor( newPcbColor );
515 nc->SetSchematicColor( newSchematicColor );
525 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
528 gridRowToNetclass( row, nc );
540 m_netSettings->SetNetclassPatternAssignment( pattern, netclass );
549 wxString tmp = aName;
556 wxString msg =
_(
"Netclass must have a name." );
565 wxString msg =
_(
"Netclass name already in use." );
585 wxString msg = wxString::Format(
_(
"Clearance was too large. It has been clipped to %s." ),
603 wxString newName =
event.GetString();
605 if( !oldName.IsEmpty() )
634 if( ( event.GetCol() < 0 ) || ( event.GetCol() >=
m_assignmentGrid->GetNumberCols() ) )
648 std::vector<std::pair<wxString, wxString>> netclassesassignments;
653 netclassesassignments.emplace_back(
m_assignmentGrid->GetCellValue( row, 0 ),
657 std::sort( netclassesassignments.begin(), netclassesassignments.end(),
658 [
this](
const std::pair<wxString, wxString>& assign1,
659 const std::pair<wxString, wxString>& assign2 )
661 const wxString& str1 = ( m_sortCol == 0 ) ? assign1.first : assign1.second;
662 const wxString& str2 = ( m_sortCol == 0 ) ? assign2.first : assign2.second;
663 return m_sortAsc ? ( str1 < str2 ) : ( str1 > str2 );
671 for(
const auto& [pattern, netclassName] : netclassesassignments )
683 if( aEvent.Moving() || aEvent.Entering() )
687 if( col == wxNOT_FOUND )
707 case GRID_uVIADRILL: tip =
_(
"Microvia plated hole diameter" );
break;
720 else if( aEvent.Leaving() )
733 [&]() -> std::pair<int, int>
770 for(
int assignment = 0; assignment <
m_assignmentGrid->GetNumberRows(); ++assignment )
816 [&]() -> std::pair<int, int>
838 const std::map<wxString, std::shared_ptr<NETCLASS>>& netclasses =
841 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
845 if( netclasses.find( netclassName ) != netclasses.end() )
847 const KIGFX::COLOR4D ncColor = netclasses.at( netclassName )->GetSchematicColor();
859 int classNameWidth = 160;
861 m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
901 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
902 pattern = txt->GetValue();
904 cellEditor->DecRef();
911 if( !pattern.IsEmpty() )
915 m_matchingNets->Report( wxString::Format(
_(
"<b>Nets matching '%s':</b>" ), pattern ) );
939 netclassName.Trim(
true );
940 netclassName.Trim(
false );
1003 wxArrayString profileNames;
1004 profileNames.push_back( wxEmptyString );
1005 std::ranges::for_each( aNames,
1006 [&](
const wxString& aName )
1008 profileNames.push_back( aName );
1011 wxGridCellAttr* attr =
new wxGridCellAttr;
1012 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
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.
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)
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
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)
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
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