24#include <wx/clipbrd.h>
27#include <wx/wupdlock.h>
38static constexpr int MAX_USER_RESULTS = 400;
42enum FOOTPRINT_USERS_MATCH_CATEGORY
44 MATCH_FILTERS = 1 << 0,
45 MATCH_FOOTPRINT_FIELD = 1 << 1,
46 MATCH_PIN_MAPS = 1 << 2
51enum FOOTPRINT_USERS_COLUMN
53 COL_FOOTPRINT_USERS_LIBRARY = 0,
54 COL_FOOTPRINT_USERS_SYMBOL,
55 COL_FOOTPRINT_USERS_PINS,
56 COL_FOOTPRINT_USERS_FILTER,
57 COL_FOOTPRINT_USERS_FOOTPRINT_FIELD_MATCH,
58 COL_FOOTPRINT_USERS_PIN_MAP_MATCH
64 ROW_DATA_FLAG_PIN_COUNT_MATCHES = 0x01,
65 ROW_DATA_FLAG_DERIVED_SYMBOL = 0x02
73class FOOTPRINT_USERS_LIST_STORE :
public wxDataViewListStore
76 bool GetAttrByRow(
unsigned int aRow,
unsigned int aCol, wxDataViewItemAttr& aAttr )
const override
80 case COL_FOOTPRINT_USERS_SYMBOL:
81 if( GetItemData( GetItem( aRow ) ) & ROW_DATA_FLAG_DERIVED_SYMBOL )
83 aAttr.SetItalic(
true );
89 case COL_FOOTPRINT_USERS_PINS:
90 if( GetItemData( GetItem( aRow ) ) & ROW_DATA_FLAG_PIN_COUNT_MATCHES )
92 aAttr.SetBold(
true );
110 int aFootprintPinCount ) :
119 FOOTPRINT_USERS_LIST_STORE* store =
new FOOTPRINT_USERS_LIST_STORE();
129 m_footprintUserList->AppendToggleColumn(
_(
"Footprint field match" ), wxDATAVIEW_CELL_INERT, 120 );
197 categories |= MATCH_FILTERS;
200 categories |= MATCH_FOOTPRINT_FIELD;
203 categories |= MATCH_PIN_MAPS;
216 if( progress >= 1.0f )
232 std::vector<FOOTPRINT_USER_MATCH> matches = aResult.
m_Matches;
234 const auto libThenSymbolNameCmp =
247 std::sort( matches.begin(), matches.end(), libThenSymbolNameCmp );
254 wxVector<wxVariant> row;
256 row.push_back( wxVariant( match.m_Symbol.GetUniStringLibNickname() ) );
257 row.push_back( wxVariant( match.m_Symbol.GetUniStringLibItemName() ) );
258 row.push_back( wxVariant( wxString::Format( wxS(
"%d" ), match.m_PinCount ) ) );
259 row.push_back( wxVariant( match.m_MatchedFilter ) );
260 row.push_back( wxVariant( match.m_MatchesFootprintField ) );
263 wxString pinMapNames;
265 for(
const wxString& mapName : match.m_MatchedPinMaps )
267 if( !pinMapNames.IsEmpty() )
268 pinMapNames += wxS(
", " );
270 pinMapNames += mapName;
273 row.push_back( wxVariant( pinMapNames ) );
275 wxUIntPtr rowData = 0;
278 rowData |= ROW_DATA_FLAG_PIN_COUNT_MATCHES;
280 if( match.m_IsDerived )
281 rowData |= ROW_DATA_FLAG_DERIVED_SYMBOL;
288 m_statusText->SetLabel(
_(
"Failed to query matching symbols." ) );
292 m_statusText->SetLabel( wxString::Format(
_(
"This footprint is referenced by more than %zu symbols" ),
297 m_statusText->SetLabel( wxString::Format(
_(
"This footprint is referenced by %zu symbols" ),
311 m_statusText->SetLabel( wxString::Format(
_(
"Loading symbol libraries (%d%%)..." ),
312 static_cast<int>( aProgress * 100.0f ) ) );
342 return wxEmptyString;
345 const wxString symbol =
m_footprintUserList->GetTextValue( aRow, COL_FOOTPRINT_USERS_SYMBOL );
348 if(
library.IsEmpty() || symbol.IsEmpty() )
349 return wxEmptyString;
354 return wxEmptyString;
364 std::string packet = aSymbolName.utf8_string();
374 if( wxTheClipboard->Open() )
376 wxTheClipboard->SetData(
new wxTextDataObject( aSymbolName ) );
377 wxTheClipboard->Close();
386 if( !symbolName.IsEmpty() )
393 const wxDataViewItem item = aEvent.GetItem();
401 if( symbolName.IsEmpty() )
406 OPEN_IN_SYMBOL_EDITOR = 1,
412 menu.Append( OPEN_IN_SYMBOL_EDITOR,
_(
"Open in Symbol Editor" ) );
413 menu.Append( COPY_SYMBOL_NAME,
_(
"Copy Symbol Name" ) +
"\tCtrl+C" );
415 switch( GetPopupMenuSelectionFromUser( menu ) )
417 case OPEN_IN_SYMBOL_EDITOR:
420 case COPY_SYMBOL_NAME:
431 if( aEvent.ControlDown() && aEvent.GetKeyCode() ==
'C' )
435 if( !symbolName.IsEmpty() )
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
bool IsValid() const
Check if this LID_ID is valid.
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
const wxString GetUniStringLibNickname() const
@ FRAME_SCH_SYMBOL_EDITOR
int StrNumCmp(const wxString &aString1, const wxString &aString2, CMP_T aCaseSensitivity)
Compare two strings with alphanumerical content.
FOOTPRINT_USERS_RESULT QueryFootprintUsers(KIWAY &aKiway, const FOOTPRINT_USERS_QUERY &aQuery)
Ask the symbol libraries, for the symbols that use a given footprint (over the Eeschema kiface).
bool StartSymbolLibrariesLoad(KIWAY &aKiway)
Start loading the symbol libraries in the background.
float GetSymbolLibrariesLoadProgress(KIWAY &aKiway)
Return how far the background load of the symbol libraries has got.