28#include <wx/wupdlock.h>
82 std::shared_ptr<NET_SETTINGS> aNetSettings,
83 const std::set<wxString>& aNetNames,
bool aIsEEschema ) :
121 wxWindowUpdateLocker updateLock(
this );
133 int const min_best_width =
m_netclassGrid->GetTextExtent(
"555,555555 mils" ).x;
139 int const min_width =
m_netclassGrid->GetVisibleWidth( i,
true,
true );
141 int const weighted_min_best_width = ( i ==
GRID_LINESTYLE ) ? min_best_width * 3 / 2
161 wxGridCellAttr* attr =
new wxGridCellAttr;
166 attr =
new wxGridCellAttr;
171 attr =
new wxGridCellAttr;
237 [
this]( wxIdleEvent& aEvent )
243 wxWindow* dialog = wxGetTopLevelParent(
this );
244 wxWindow* topLevelFocus = wxGetTopLevelParent( wxWindow::FindFocus() );
275 auto netclassToGridRow =
284 wxString colorAsString = nc->GetSchematicColor().ToCSSString();
287 if( nc->HasLineStyle() )
289 int lineStyleIdx = std::max( 0, nc->GetLineStyle() );
311 colorAsString = nc->GetPcbColor().ToCSSString();
314 if( nc->IsDefault() )
326 std::vector<const NETCLASS*> netclasses;
330 netclasses.push_back( netclass.get() );
332 std::sort( netclasses.begin(), netclasses.end(),
335 return nc1->GetPriority() < nc2->GetPriority();
340 m_netclassGrid->AppendRows(
static_cast<int>( netclasses.size() ) );
344 for(
const NETCLASS* nc : netclasses )
345 netclassToGridRow( row++, nc );
349 netclassToGridRow( row,
m_netSettings->GetDefaultNetclass().get() );
356 for(
const auto& [matcher, netclassName] :
m_netSettings->GetNetclassPatternAssignments() )
369 [
this, aRowId, aIsDefault](
int aCol )
378 wxGridCellAttr* attr =
m_netclassGrid->GetOrCreateCellAttr( aRowId, aCol );
379 attr->SetEditor( cellEditor );
403 if(
IsOK( m_parent,
_(
"The netclasses have been changed outside the Setup dialog.\n"
404 "Do you wish to reload them?" ) ) )
414 std::shared_ptr<NET_SETTINGS> tempNetSettings = std::make_shared<NET_SETTINGS>(
nullptr,
"" );
415 std::shared_ptr<NET_SETTINGS> saveNetSettings =
m_netSettings;
448 wxArrayString netclassNames;
454 if( !netclassName.IsEmpty() )
455 netclassNames.push_back( netclassName );
458 wxGridCellAttr* attr =
new wxGridCellAttr;
459 attr->SetEditor(
new wxGridCellChoiceEditor( netclassNames ) );
469 auto gridRowToNetclass =
470 [&](
int aRow,
const std::shared_ptr<NETCLASS>& nc )
472 if( nc->IsDefault() )
473 nc->SetPriority( std::numeric_limits<int>::max() );
475 nc->SetPriority( aRow );
487 nc->SetLineStyle( std::optional<int>() );
489 nc->SetLineStyle( lineIdx - 1 );
491 wxASSERT_MSG( lineIdx >= 0,
"Line style name not found." );
504 if( !nc->IsDefault() )
510 nc->SetPcbColor( newPcbColor );
516 nc->SetSchematicColor( newSchematicColor );
526 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
529 gridRowToNetclass( row, nc );
541 m_netSettings->SetNetclassPatternAssignment( pattern, netclass );
550 wxString tmp = aName;
557 wxString msg =
_(
"Netclass must have a name." );
566 wxString msg =
_(
"Netclass name already in use." );
586 wxString msg = wxString::Format(
_(
"Clearance was too large. It has been clipped to %s." ),
604 wxString newName =
event.GetString();
606 if( !oldName.IsEmpty() )
635 if( ( event.GetCol() < 0 ) || ( event.GetCol() >=
m_assignmentGrid->GetNumberCols() ) )
649 std::vector<std::pair<wxString, wxString>> netclassesassignments;
654 netclassesassignments.emplace_back(
m_assignmentGrid->GetCellValue( row, 0 ),
658 std::sort( netclassesassignments.begin(), netclassesassignments.end(),
659 [
this](
const std::pair<wxString, wxString>& assign1,
660 const std::pair<wxString, wxString>& assign2 )
662 const wxString& str1 = ( m_sortCol == 0 ) ? assign1.first : assign1.second;
663 const wxString& str2 = ( m_sortCol == 0 ) ? assign2.first : assign2.second;
664 return m_sortAsc ? ( str1 < str2 ) : ( str1 > str2 );
672 for(
const auto& [pattern, netclassName] : netclassesassignments )
684 if( aEvent.Moving() || aEvent.Entering() )
688 if( col == wxNOT_FOUND )
708 case GRID_uVIADRILL: tip =
_(
"Microvia plated hole diameter" );
break;
721 else if( aEvent.Leaving() )
734 [&]() -> std::pair<int, int>
771 for(
int assignment = 0; assignment <
m_assignmentGrid->GetNumberRows(); ++assignment )
817 [&]() -> std::pair<int, int>
839 const std::map<wxString, std::shared_ptr<NETCLASS>>& netclasses =
842 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
846 if( netclasses.find( netclassName ) != netclasses.end() )
848 const KIGFX::COLOR4D ncColor = netclasses.at( netclassName )->GetSchematicColor();
860 int classNameWidth = 160;
862 m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
902 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
903 pattern = txt->GetValue();
905 cellEditor->DecRef();
912 if( !pattern.IsEmpty() )
916 m_matchingNets->Report( wxString::Format(
_(
"<b>Nets matching '%s':</b>" ), pattern ) );
940 netclassName.Trim(
true );
941 netclassName.Trim(
false );
1004 wxArrayString profileNames;
1005 profileNames.push_back( wxEmptyString );
1006 std::ranges::for_each( aNames,
1007 [&](
const wxString& aName )
1009 profileNames.push_back( aName );
1012 wxGridCellAttr* attr =
new wxGridCellAttr;
1013 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