27#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 );
550 wxString tmp = aName;
557 [&](
const wxString& aMsg,
int aErrorRow )
565 [
this, aMsg, aErrorRow, rowName]()
569 if( !dialog || !dialog->IsShown() || aErrorRow >=
m_netclassGrid->GetNumberRows()
586 report(
_(
"Netclass must have a name." ), aRow );
594 report(
_(
"Netclass name already in use." ), focusFirst ? aRow : ii );
612 wxString msg = wxString::Format(
_(
"Clearance was too large. It has been clipped to %s." ),
630 wxString newName =
event.GetString();
632 if( !oldName.IsEmpty() )
661 if( ( event.GetCol() < 0 ) || ( event.GetCol() >=
m_assignmentGrid->GetNumberCols() ) )
675 std::vector<std::pair<wxString, wxString>> netclassesassignments;
680 netclassesassignments.emplace_back(
m_assignmentGrid->GetCellValue( row, 0 ),
684 std::sort( netclassesassignments.begin(), netclassesassignments.end(),
685 [
this](
const std::pair<wxString, wxString>& assign1,
686 const std::pair<wxString, wxString>& assign2 )
688 const wxString& str1 = ( m_sortCol == 0 ) ? assign1.first : assign1.second;
689 const wxString& str2 = ( m_sortCol == 0 ) ? assign2.first : assign2.second;
690 return m_sortAsc ? ( str1 < str2 ) : ( str1 > str2 );
698 for(
const auto& [pattern, netclassName] : netclassesassignments )
710 if( aEvent.Moving() || aEvent.Entering() )
714 if( col == wxNOT_FOUND )
734 case GRID_uVIADRILL: tip =
_(
"Microvia plated hole diameter" );
break;
747 else if( aEvent.Leaving() )
760 [&]() -> std::pair<int, int>
797 for(
int assignment = 0; assignment <
m_assignmentGrid->GetNumberRows(); ++assignment )
843 [&]() -> std::pair<int, int>
865 const std::map<wxString, std::shared_ptr<NETCLASS>>& netclasses =
868 for(
int row = 0; row <
m_netclassGrid->GetNumberRows() - 1; ++row )
872 if( netclasses.find( netclassName ) != netclasses.end() )
874 const KIGFX::COLOR4D ncColor = netclasses.at( netclassName )->GetSchematicColor();
886 int classNameWidth = 160;
888 m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
928 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
929 pattern = txt->GetValue();
931 cellEditor->DecRef();
938 if( !pattern.IsEmpty() )
942 m_matchingNets->Report( wxString::Format(
_(
"<b>Nets matching '%s':</b>" ), pattern ) );
966 netclassName.Trim(
true );
967 netclassName.Trim(
false );
1030 wxArrayString profileNames;
1031 profileNames.push_back( wxEmptyString );
1032 std::ranges::for_each( aNames,
1033 [&](
const wxString& aName )
1035 profileNames.push_back( aName );
1038 wxGridCellAttr* attr =
new wxGridCellAttr;
1039 attr->SetEditor(
new wxGridCellChoiceEditor( profileNames,
false ) );
1050 auto it = aRenames.find( profileName );
1052 if( it != aRenames.end() )
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
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
bool validateNetclassName(int aRow, const wxString &aName, bool focusFirst=true, bool aDeferError=false)
void RemapDelayProfileNames(const std::map< wxString, wxString > &aRenames) const
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