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 );
87 case COL_FOOTPRINT_USERS_PINS:
88 if( GetItemData( GetItem( aRow ) ) & ROW_DATA_FLAG_PIN_COUNT_MATCHES )
90 aAttr.SetBold(
true );
106 int aFootprintPinCount ) :
115 FOOTPRINT_USERS_LIST_STORE* store =
new FOOTPRINT_USERS_LIST_STORE();
125 m_footprintUserList->AppendToggleColumn(
_(
"Footprint field match" ), wxDATAVIEW_CELL_INERT, 120 );
193 categories |= MATCH_FILTERS;
196 categories |= MATCH_FOOTPRINT_FIELD;
199 categories |= MATCH_PIN_MAPS;
212 if( progress >= 1.0f )
228 std::vector<FOOTPRINT_USER_MATCH> matches = aResult.
m_Matches;
230 const auto libThenSymbolNameCmp =
234 aRight.m_Symbol.GetUniStringLibNickname(),
241 aRight.m_Symbol.GetUniStringLibItemName(),
245 std::sort( matches.begin(), matches.end(), libThenSymbolNameCmp );
252 wxVector<wxVariant> row;
254 row.push_back( wxVariant( match.m_Symbol.GetUniStringLibNickname() ) );
255 row.push_back( wxVariant( match.m_Symbol.GetUniStringLibItemName() ) );
256 row.push_back( wxVariant( wxString::Format( wxS(
"%d" ), match.m_PinCount ) ) );
257 row.push_back( wxVariant( match.m_MatchedFilter ) );
258 row.push_back( wxVariant( match.m_MatchesFootprintField ) );
261 wxString pinMapNames;
263 for(
const wxString& mapName : match.m_MatchedPinMaps )
265 if( !pinMapNames.IsEmpty() )
266 pinMapNames += wxS(
", " );
268 pinMapNames += mapName;
271 row.push_back( wxVariant( pinMapNames ) );
273 wxUIntPtr rowData = 0;
276 rowData |= ROW_DATA_FLAG_PIN_COUNT_MATCHES;
278 if( match.m_IsDerived )
279 rowData |= ROW_DATA_FLAG_DERIVED_SYMBOL;
286 m_statusText->SetLabel(
_(
"Failed to query matching symbols." ) );
291 wxString::Format(
_(
"This footprint is referenced by more than %zu symbols" ), matches.size() ) );
296 wxString::Format(
_(
"This footprint is referenced by %zu symbols" ), matches.size() ) );
310 wxString::Format(
_(
"Loading symbol libraries (%d%%)..." ),
static_cast<int>( aProgress * 100.0f ) ) );
340 return wxEmptyString;
343 const wxString symbol =
m_footprintUserList->GetTextValue( aRow, COL_FOOTPRINT_USERS_SYMBOL );
346 if(
library.IsEmpty() || symbol.IsEmpty() )
347 return wxEmptyString;
352 return wxEmptyString;
362 std::string packet = aSymbolName.utf8_string();
372 if( wxTheClipboard->Open() )
374 wxTheClipboard->SetData(
new wxTextDataObject( aSymbolName ) );
375 wxTheClipboard->Close();
384 if( !symbolName.IsEmpty() )
391 const wxDataViewItem item = aEvent.GetItem();
399 if( symbolName.IsEmpty() )
404 OPEN_IN_SYMBOL_EDITOR = 1,
410 menu.Append( OPEN_IN_SYMBOL_EDITOR,
_(
"Open in Symbol Editor" ) );
411 menu.Append( COPY_SYMBOL_NAME,
_(
"Copy Symbol Name" ) +
"\tCtrl+C" );
413 switch( GetPopupMenuSelectionFromUser( menu ) )
415 case OPEN_IN_SYMBOL_EDITOR:
418 case COPY_SYMBOL_NAME:
429 if( aEvent.ControlDown() && aEvent.GetKeyCode() ==
'C' )
433 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, bool aIgnoreCase)
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.