36 static const wxRegEx globStarPattern( wxT( R
"((?<!\.)\*)" ) );
38 wxString result = aPattern;
39 globStarPattern.ReplaceAll( &result, ".*" );
49 wxString commonPrefix = *aSet.begin();
51 for(
const wxString& str : aSet )
53 const size_t minLength = std::min( commonPrefix.size(), str.size() );
54 size_t matchUntil = 0;
55 while( matchUntil < minLength && commonPrefix[matchUntil] == str[matchUntil] )
60 commonPrefix = commonPrefix.substr( 0, matchUntil );
64 if( commonPrefix.empty() )
88 if( aNetNames.empty() )
91 if( aNetNames.size() == 1 )
93 return *aNetNames.begin();
96 wxArrayString netNames;
97 for(
const wxString& netName : aNetNames )
111 if( !commonPrefix.IsEmpty() && commonPrefix != wxT(
"/" ) )
117 wxArrayString netTails;
119 for(
const wxString& netName : netNames )
122 netTails.Add( netName.Mid( commonPrefix.size() ) );
125 return commonPrefix + + wxT(
"(") + wxJoin( netTails, wxT(
'|' ) ) + wxT(
")");
129 return wxJoin( netNames, wxT(
'|' ) );
134 const std::set<wxString>& aNetNames,
135 const std::set<wxString> aCandidateNetNames,
136 const std::function<
void(
const std::vector<wxString>& )>& aPreviewer ) :
148 m_info->SetLabel( wxT(
"Note: complete netclass assignments can be edited in Board "
149 "Setup > Project." ) );
159 if( !wxWindow::TransferDataToWindow() )
162 std::shared_ptr<NET_SETTINGS>& netSettings =
m_frame->Prj().GetProjectFile().m_NetSettings;
166 for(
const auto& [
name, netclass] : netSettings->GetNetclasses() )
183 std::shared_ptr<NET_SETTINGS>& netSettings =
m_frame->Prj().GetProjectFile().m_NetSettings;
188 netSettings->SetNetclassPatternAssignment(
m_patternCtrl->GetValue(),
203 std::vector<wxString> matchingNetNames;
205 if( !pattern.IsEmpty() )
216 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.