40 static const wxRegEx globStarPattern( wxT( R
"((?<!\.)\*)" ) );
42 wxString result = aPattern;
43 globStarPattern.ReplaceAll( &result, ".*" );
53 wxString commonPrefix = *aSet.begin();
55 for(
const wxString& str : aSet )
57 const size_t minLength = std::min( commonPrefix.size(), str.size() );
58 size_t matchUntil = 0;
59 while( matchUntil < minLength && commonPrefix[matchUntil] == str[matchUntil] )
64 commonPrefix = commonPrefix.substr( 0, matchUntil );
68 if( commonPrefix.empty() )
92 if( aNetNames.empty() )
95 if( aNetNames.size() == 1 )
97 return *aNetNames.begin();
100 wxArrayString netNames;
101 for(
const wxString& netName : aNetNames )
115 if( !commonPrefix.IsEmpty() && commonPrefix != wxT(
"/" ) )
121 wxArrayString netTails;
123 for(
const wxString& netName : netNames )
126 netTails.Add( netName.Mid( commonPrefix.size() ) );
129 return commonPrefix + + wxT(
"(") + wxJoin( netTails, wxT(
'|' ) ) + wxT(
")");
133 return wxJoin( netNames, wxT(
'|' ) );
138 const std::set<wxString>& aNetNames,
139 const std::set<wxString> aCandidateNetNames,
140 const std::function<
void(
const std::vector<wxString>& )>& aPreviewer ) :
152 m_info->SetLabel( wxT(
"Note: complete netclass assignments can be edited in Board "
153 "Setup > Project." ) );
163 if( !wxWindow::TransferDataToWindow() )
166 std::shared_ptr<NET_SETTINGS>& netSettings =
m_frame->Prj().GetProjectFile().m_NetSettings;
170 for(
const auto& [
name, netclass] : netSettings->GetNetclasses() )
187 std::shared_ptr<NET_SETTINGS>& netSettings =
m_frame->Prj().GetProjectFile().m_NetSettings;
192 netSettings->SetNetclassPatternAssignment(
m_patternCtrl->GetValue(),
207 std::vector<wxString> matchingNetNames;
209 if( !pattern.IsEmpty() )
220 matchingNetNames.push_back( net );
WX_HTML_REPORT_BOX * m_matchingNets
wxComboBox * m_netclassCtrl
wxTextCtrl * m_patternCtrl
DIALOG_ASSIGN_NETCLASS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Add Netclass Assignment"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE)
void onPatternText(wxCommandEvent &aEvent) override
const std::set< wxString > m_selectedNetNames
std::function< void(const std::vector< wxString > &)> m_previewer
DIALOG_ASSIGN_NETCLASS(EDA_BASE_FRAME *aParent, const std::set< wxString > &aNetNames, const std::set< wxString > aCandidateNetNames, const std::function< void(const std::vector< wxString > &)> &aPreviewer)
bool TransferDataToWindow() override
bool TransferDataFromWindow() override
std::set< wxString > m_netCandidates
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
The base frame for deriving all KiCad main window classes.
FRAME_T GetFrameType() const
bool StartsWith(const wxString &aTerm)
static const char Default[]
the name of the default NETCLASS
static wxString GetStringCommonPrefix(const wxArrayString &aSet)
static wxString GetNetclassPatternForSet(const std::set< wxString > &aNetNames)
Propose a netclass pattern for a set of net names.
wxString UpgradeGlobStarToRegex(const wxString &aPattern)
Base window classes and related definitions.
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
void StrNumSort(T &aList, CASE_SENSITIVITY aCaseSensitivity)
Sort a container of wxString objects, in place, using the StrNumCmp() function.
wxString result
Test unit parsing edge cases and error handling.