KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_symbol_chooser.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014 Henner Zeller <[email protected]>
5 * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <pgm_base.h>
26#include <symbol_library.h> // For SYMBOL_LIBRARY_FILTER
28#include <kiface_base.h>
29#include <sch_base_frame.h>
30#include <project_sch.h>
31#include <widgets/lib_tree.h>
37#include <eeschema_settings.h>
39#include <wx/button.h>
40#include <wx/clipbrd.h>
41#include <wx/panel.h>
42#include <wx/sizer.h>
43#include <wx/splitter.h>
44#include <wx/timer.h>
45#include <wx/wxhtml.h>
46
47
50
51
53 const SYMBOL_LIBRARY_FILTER* aFilter,
54 std::vector<PICKED_SYMBOL>& aHistoryList,
55 std::vector<PICKED_SYMBOL>& aAlreadyPlaced,
56 bool aAllowFieldEdits, bool aShowFootprints,
57 std::function<void()> aCloseHandler ) :
58 wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize ),
59 m_symbol_preview( nullptr ),
60 m_hsplitter( nullptr ),
61 m_vsplitter( nullptr ),
62 m_fp_sel_ctrl( nullptr ),
63 m_fp_preview( nullptr ),
64 m_tree( nullptr ),
65 m_details( nullptr ),
66 m_frame( aFrame ),
67 m_closeHandler( std::move( aCloseHandler ) ),
68 m_showPower( false ),
69 m_allow_field_edits( aAllowFieldEdits ),
70 m_show_footprints( aShowFootprints )
71{
73 COMMON_SETTINGS::SESSION& session = Pgm().GetCommonSettings()->m_Session;
75
76 // Make sure settings are loaded before we start running multi-threaded symbol loaders
77 Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
78 Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
79
81 SYMBOL_TREE_MODEL_ADAPTER* adapter = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( m_adapter.get() );
82 bool loaded = false;
83
84 if( aFilter )
85 {
86 const wxArrayString& liblist = aFilter->GetAllowedLibList();
87
88 for( const wxString& nickname : liblist )
89 {
90 if( libs->HasLibrary( nickname, true ) )
91 {
92 loaded = true;
93
94 bool pinned = alg::contains( session.pinned_symbol_libs, nickname )
95 || alg::contains( project.m_PinnedSymbolLibs, nickname );
96
97 if( libs->FindRow( nickname )->GetIsVisible() )
98 adapter->AddLibrary( nickname, pinned );
99 }
100 }
101
102 adapter->AssignIntrinsicRanks();
103
104 if( aFilter->GetFilterPowerSymbols() )
105 {
106 // HACK ALERT: when loading symbols we presume that *any* filter is a power symbol
107 // filter. So the filter only needs to return true for libraries.
108 static std::function<bool( LIB_TREE_NODE& )> powerFilter =
109 []( LIB_TREE_NODE& aNode ) -> bool
110 {
111 return true;
112 };
113
114 adapter->SetFilter( &powerFilter );
115
116 m_showPower = true;
117 m_show_footprints = false;
118 }
119 }
120
121 std::vector<LIB_SYMBOL> history_list_storage;
122 std::vector<LIB_TREE_ITEM*> history_list;
123 std::vector<LIB_SYMBOL> already_placed_storage;
124 std::vector<LIB_TREE_ITEM*> already_placed;
125
126 // Lambda to encapsulate the common logic
127 auto processList = [&]( const std::vector<PICKED_SYMBOL>& inputList,
128 std::vector<LIB_SYMBOL>& storageList,
129 std::vector<LIB_TREE_ITEM*>& resultList )
130 {
131 storageList.reserve( inputList.size() );
132
133 for( const PICKED_SYMBOL& i : inputList )
134 {
135 LIB_SYMBOL* symbol = m_frame->GetLibSymbol( i.LibId );
136
137 if( symbol )
138 {
139 storageList.emplace_back( *symbol );
140
141 for( const std::pair<int, wxString>& fieldDef : i.Fields )
142 {
143 LIB_FIELD* field = storageList.back().GetFieldById( fieldDef.first );
144
145 if( field )
146 field->SetText( fieldDef.second );
147 }
148
149 resultList.push_back( &storageList.back() );
150 }
151 }
152 };
153
154 processList( aHistoryList, history_list_storage, history_list );
155 processList( aAlreadyPlaced, already_placed_storage, already_placed );
156
157 adapter->DoAddLibrary( wxT( "-- " ) + _( "Recently Used" ) + wxT( " --" ), wxEmptyString,
158 history_list, false, true );
159
160 if( !aHistoryList.empty() )
161 adapter->SetPreselectNode( aHistoryList[0].LibId, aHistoryList[0].Unit );
162
163 adapter->DoAddLibrary( wxT( "-- " ) + _( "Already Placed" ) + wxT( " --" ), wxEmptyString,
164 already_placed, false, true );
165
166 const std::vector< wxString > libNicknames = libs->GetLogicalLibs();
167
168 if( !loaded )
169 {
170 if( !adapter->AddLibraries( libNicknames, m_frame ) )
171 {
172 // loading cancelled by user
174 }
175 }
176
177 // -------------------------------------------------------------------------------------
178 // Construct the actual panel
179 //
180
181 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
182
183 // Use a slightly different layout, with a details pane spanning the entire window,
184 // if we're not showing footprints.
186 {
187 m_hsplitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
188 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
189
190 //Avoid the splitter window being assigned as the Parent to additional windows
191 m_hsplitter->SetExtraStyle( wxWS_EX_TRANSIENT );
192
193 sizer->Add( m_hsplitter, 1, wxEXPAND, 5 );
194 }
195 else
196 {
197 m_vsplitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
198 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
199
200 m_hsplitter = new wxSplitterWindow( m_vsplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize,
201 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
202
203 // Avoid the splitter window being assigned as the parent to additional windows.
204 m_vsplitter->SetExtraStyle( wxWS_EX_TRANSIENT );
205 m_hsplitter->SetExtraStyle( wxWS_EX_TRANSIENT );
206
207 wxPanel* detailsPanel = new wxPanel( m_vsplitter );
208 wxBoxSizer* detailsSizer = new wxBoxSizer( wxVERTICAL );
209 detailsPanel->SetSizer( detailsSizer );
210
211 m_details = new HTML_WINDOW( detailsPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize );
212 detailsSizer->Add( m_details, 1, wxEXPAND, 5 );
213 detailsPanel->Layout();
214 detailsSizer->Fit( detailsPanel );
215
216 m_vsplitter->SetSashGravity( 0.5 );
217 m_vsplitter->SetMinimumPaneSize( 20 );
218 m_vsplitter->SplitHorizontally( m_hsplitter, detailsPanel );
219
220 sizer->Add( m_vsplitter, 1, wxEXPAND, 5 );
221 }
222
223 wxPanel* treePanel = new wxPanel( m_hsplitter );
224 wxBoxSizer* treeSizer = new wxBoxSizer( wxVERTICAL );
225 treePanel->SetSizer( treeSizer );
226
227 m_tree = new LIB_TREE( treePanel, m_showPower ? wxT( "power" ) : wxT( "symbols" ),
229
230 treeSizer->Add( m_tree, 1, wxEXPAND, 5 );
231 treePanel->Layout();
232 treeSizer->Fit( treePanel );
233
234 m_adapter->FinishTreeInitialization();
235
236 if( m_showPower )
238 else
240
241 m_hsplitter->SetSashGravity( 0.8 );
242 m_hsplitter->SetMinimumPaneSize( 20 );
243 m_hsplitter->SplitVertically( treePanel, constructRightPanel( m_hsplitter ) );
244
245 m_dbl_click_timer = new wxTimer( this );
246
247 SetSizer( sizer );
248
249 Layout();
250
251 Bind( wxEVT_TIMER, &PANEL_SYMBOL_CHOOSER::onCloseTimer, this, m_dbl_click_timer->GetId() );
252 Bind( EVT_LIBITEM_SELECTED, &PANEL_SYMBOL_CHOOSER::onSymbolSelected, this );
253 Bind( EVT_LIBITEM_CHOSEN, &PANEL_SYMBOL_CHOOSER::onSymbolChosen, this );
254
255 if( m_fp_sel_ctrl )
256 {
257 m_fp_sel_ctrl->Bind( EVT_FOOTPRINT_SELECTED, &PANEL_SYMBOL_CHOOSER::onFootprintSelected,
258 this );
259 }
260
261 if( m_details )
262 {
263 m_details->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PANEL_SYMBOL_CHOOSER::OnCharHook ),
264 nullptr, this );
265 }
266}
267
268
270{
271 Unbind( wxEVT_TIMER, &PANEL_SYMBOL_CHOOSER::onCloseTimer, this );
272 Unbind( EVT_LIBITEM_SELECTED, &PANEL_SYMBOL_CHOOSER::onSymbolSelected, this );
273 Unbind( EVT_LIBITEM_CHOSEN, &PANEL_SYMBOL_CHOOSER::onSymbolChosen, this );
274
275 // Stop the timer during destruction early to avoid potential race conditions (that do happen)
276 m_dbl_click_timer->Stop();
277 delete m_dbl_click_timer;
278
279 if( m_showPower )
281 else
283
284 if( m_fp_sel_ctrl )
285 {
286 m_fp_sel_ctrl->Unbind( EVT_FOOTPRINT_SELECTED, &PANEL_SYMBOL_CHOOSER::onFootprintSelected,
287 this );
288 }
289
290 if( m_details )
291 {
292 m_details->Disconnect( wxEVT_CHAR_HOOK,
293 wxKeyEventHandler( PANEL_SYMBOL_CHOOSER::OnCharHook ), nullptr,
294 this );
295 }
296
297 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
298 {
299 cfg->m_SymChooserPanel.width = GetParent()->GetSize().x;
300 cfg->m_SymChooserPanel.height = GetParent()->GetSize().y;
301
302 cfg->m_SymChooserPanel.sash_pos_h = m_hsplitter->GetSashPosition();
303
304 if( m_vsplitter )
305 cfg->m_SymChooserPanel.sash_pos_v = m_vsplitter->GetSashPosition();
306
307 cfg->m_SymChooserPanel.sort_mode = m_tree->GetSortMode();
308 }
309}
310
311
312wxPanel* PANEL_SYMBOL_CHOOSER::constructRightPanel( wxWindow* aParent )
313{
315
316 if( m_frame->GetCanvas() )
317 {
318 backend = m_frame->GetCanvas()->GetBackend();
319 }
320 else
321 {
322 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
324 }
325
326 wxPanel* panel = new wxPanel( aParent );
327 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
328
329 m_symbol_preview = new SYMBOL_PREVIEW_WIDGET( panel, &m_frame->Kiway(), true, backend );
330 m_symbol_preview->SetLayoutDirection( wxLayout_LeftToRight );
331
333 {
335
336 sizer->Add( m_symbol_preview, 11, wxEXPAND | wxBOTTOM, 5 );
337
338 if ( fp_list )
339 {
341 m_fp_sel_ctrl = new FOOTPRINT_SELECT_WIDGET( m_frame, panel, fp_list, true );
342
345 }
346
347 if( m_fp_sel_ctrl )
348 sizer->Add( m_fp_sel_ctrl, 0, wxEXPAND | wxTOP | wxBOTTOM, 4 );
349
350 if( m_fp_preview )
351 sizer->Add( m_fp_preview, 10, wxEXPAND, 5 );
352 }
353 else
354 {
355 sizer->Add( m_symbol_preview, 1, wxEXPAND, 5 );
356 }
357
358 panel->SetSizer( sizer );
359 panel->Layout();
360 sizer->Fit( panel );
361
362 return panel;
363}
364
365
367{
368 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
369 {
370 auto horizPixelsFromDU =
371 [&]( int x ) -> int
372 {
373 wxSize sz( x, 0 );
374 return GetParent()->ConvertDialogToPixels( sz ).x;
375 };
376
377 EESCHEMA_SETTINGS::PANEL_SYM_CHOOSER& panelCfg = cfg->m_SymChooserPanel;
378
379 int w = panelCfg.width > 40 ? panelCfg.width : horizPixelsFromDU( 440 );
380 int h = panelCfg.height > 40 ? panelCfg.height : horizPixelsFromDU( 340 );
381
382 GetParent()->SetSize( wxSize( w, h ) );
383 GetParent()->Layout();
384
385 // We specify the width of the right window (m_symbol_view_panel), because specify
386 // the width of the left window does not work as expected when SetSashGravity() is called
387
388 if( panelCfg.sash_pos_h < 0 )
389 panelCfg.sash_pos_h = horizPixelsFromDU( 220 );
390
391 if( panelCfg.sash_pos_v < 0 )
392 panelCfg.sash_pos_v = horizPixelsFromDU( 230 );
393
394 m_hsplitter->SetSashPosition( panelCfg.sash_pos_h );
395
396 if( m_vsplitter )
397 m_vsplitter->SetSashPosition( panelCfg.sash_pos_v );
398
399 m_adapter->SetSortMode( (LIB_TREE_MODEL_ADAPTER::SORT_MODE) panelCfg.sort_mode );
400 }
401
403 {
404 // This hides the GAL panel and shows the status label
405 m_fp_preview->SetStatusText( wxEmptyString );
406 }
407
408 if( m_fp_sel_ctrl )
410}
411
412
414{
415 if( m_details && e.GetKeyCode() == 'C' && e.ControlDown() &&
416 !e.AltDown() && !e.ShiftDown() && !e.MetaDown() )
417 {
418 wxString txt = m_details->SelectionToText();
419 wxLogNull doNotLog; // disable logging of failed clipboard actions
420
421 if( wxTheClipboard->Open() )
422 {
423 wxTheClipboard->SetData( new wxTextDataObject( txt ) );
424 wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
425 wxTheClipboard->Close();
426 }
427 }
428 else
429 {
430 e.Skip();
431 }
432}
433
434
436{
437 m_adapter->SetPreselectNode( aPreselect, 0 );
438}
439
440
442{
443 return m_tree->GetSelectedLibId( aUnit );
444}
445
446
447void PANEL_SYMBOL_CHOOSER::onCloseTimer( wxTimerEvent& aEvent )
448{
449 // Hack because of eaten MouseUp event. See PANEL_SYMBOL_CHOOSER::onSymbolChosen
450 // for the beginning of this spaghetti noodle.
451
452 wxMouseState state = wxGetMouseState();
453
454 if( state.LeftIsDown() )
455 {
456 // Mouse hasn't been raised yet, so fire the timer again. Otherwise the
457 // purpose of this timer is defeated.
459 }
460 else
461 {
463 }
464}
465
466
468{
470 return;
471
472 LIB_SYMBOL* symbol = nullptr;
473
474 try
475 {
476 symbol = PROJECT_SCH::SchSymbolLibTable( &m_frame->Prj() )->LoadSymbol( aLibId );
477 }
478 catch( const IO_ERROR& ioe )
479 {
480 wxLogError( _( "Error loading symbol %s from library '%s'." ) + wxS( "\n%s" ),
481 aLibId.GetLibItemName().wx_str(),
482 aLibId.GetLibNickname().wx_str(),
483 ioe.What() );
484 }
485
486 if( !symbol )
487 return;
488
489 LIB_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD );
490 wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
491
492 showFootprint( fp_name );
493}
494
495
496void PANEL_SYMBOL_CHOOSER::showFootprint( wxString const& aFootprint )
497{
499 return;
500
501 if( aFootprint == wxEmptyString )
502 {
503 m_fp_preview->SetStatusText( _( "No footprint specified" ) );
504 }
505 else
506 {
507 LIB_ID lib_id;
508
509 if( lib_id.Parse( aFootprint ) == -1 && lib_id.IsValid() )
510 {
513 }
514 else
515 {
516 m_fp_preview->SetStatusText( _( "Invalid footprint specified" ) );
517 }
518 }
519}
520
521
523{
524 if( !m_fp_sel_ctrl )
525 return;
526
528
529 LIB_SYMBOL* symbol = nullptr;
530
531 if( aLibId.IsValid() )
532 {
533 try
534 {
535 symbol = PROJECT_SCH::SchSymbolLibTable( &m_frame->Prj() )->LoadSymbol( aLibId );
536 }
537 catch( const IO_ERROR& ioe )
538 {
539 wxLogError( _( "Error loading symbol %s from library '%s'." ) + wxS( "\n%s" ),
540 aLibId.GetLibItemName().wx_str(),
541 aLibId.GetLibNickname().wx_str(),
542 ioe.What() );
543 }
544 }
545
546 if( symbol != nullptr )
547 {
548 LIB_PINS temp_pins;
549 LIB_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD );
550 wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
551
552 // All units, but only a single De Morgan variant.
553 if( symbol->HasConversion() )
554 symbol->GetPins( temp_pins, 0, 1 );
555 else
556 symbol->GetPins( temp_pins );
557
558 m_fp_sel_ctrl->FilterByPinCount( temp_pins.size() );
563 }
564 else
565 {
567 m_fp_sel_ctrl->Disable();
568 }
569}
570
571
572void PANEL_SYMBOL_CHOOSER::onFootprintSelected( wxCommandEvent& aEvent )
573{
574 m_fp_override = aEvent.GetString();
575
576 alg::delete_if( m_field_edits, []( std::pair<int, wxString> const& i )
577 {
578 return i.first == FOOTPRINT_FIELD;
579 } );
580
581 m_field_edits.emplace_back( std::make_pair( FOOTPRINT_FIELD, m_fp_override ) );
582
584}
585
586
587void PANEL_SYMBOL_CHOOSER::onSymbolSelected( wxCommandEvent& aEvent )
588{
590
591 if( node && node->m_LibId.IsValid() )
592 {
594
595 if( !node->m_Footprint.IsEmpty() )
596 showFootprint( node->m_Footprint );
597 else
598 showFootprintFor( node->m_LibId );
599
601 }
602 else
603 {
604 m_symbol_preview->SetStatusText( _( "No symbol selected" ) );
605
607 m_fp_preview->SetStatusText( wxEmptyString );
608
610 }
611}
612
613
614void PANEL_SYMBOL_CHOOSER::onSymbolChosen( wxCommandEvent& aEvent )
615{
617 {
618 // Got a selection. We can't just end the modal dialog here, because wx leaks some events
619 // back to the parent window (in particular, the MouseUp following a double click).
620 //
621 // NOW, here's where it gets really fun. wxTreeListCtrl eats MouseUp. This isn't really
622 // feasible to bypass without a fully custom wxDataViewCtrl implementation, and even then
623 // might not be fully possible (docs are vague). To get around this, we use a one-shot
624 // timer to schedule the dialog close.
625 //
626 // See PANEL_SYMBOL_CHOOSER::onCloseTimer for the other end of this spaghetti noodle.
628 }
629}
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:183
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
static FOOTPRINT_LIST * GetInstance(KIWAY &aKiway)
Factory function to return a FOOTPRINT_LIST via Kiway.
void DisplayFootprint(const LIB_ID &aFPID)
Set the currently displayed footprint.
void SetUserUnits(EDA_UNITS aUnits)
Set the units for the preview.
bool IsInitialized() const
Return whether the widget initialized properly.
void SetStatusText(const wxString &aText)
Set the contents of the status label and display it.
void ClearStatus()
Clear the contents of the status label and hide it.
virtual bool Enable(bool aEnable=true) override
Enable or disable the control for input.
void FilterByFootprintFilters(const wxArrayString &aFilters, bool aZeroFilters)
Filter by footprint filter list.
void SetDefaultFootprint(const wxString &aFp)
Set the default footprint for a part.
void FilterByPinCount(int aPinCount)
Filter by pin count.
bool UpdateList()
Update the contents of the list to match the filters.
void ClearFilters()
Clear all filters.
void Load(KIWAY &aKiway, PROJECT &aProject)
Start loading.
Add dark theme support to wxHtmlWindow.
Definition: html_window.h:34
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
Field object used in symbol libraries.
Definition: lib_field.h:62
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:410
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:51
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:172
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
Define a library symbol object.
Definition: lib_symbol.h:99
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
wxArrayString GetFPFilters() const
Definition: lib_symbol.h:226
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0) const
Return a list of pin object pointers from the draw item list.
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
bool GetIsVisible() const
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
void SetPreselectNode(const LIB_ID &aLibId, int aUnit)
Set the symbol name to be selected if there are no search results.
void DoAddLibrary(const wxString &aNodeName, const wxString &aDesc, const std::vector< LIB_TREE_ITEM * > &aItemList, bool pinned, bool presorted)
Add the given list of symbols by alias.
void AssignIntrinsicRanks()
Sort the tree and assign ranks after adding libraries.
void SetFilter(std::function< bool(LIB_TREE_NODE &aNode)> *aFilter)
Set the symbol filter type.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
wxString m_Footprint
Widget displaying a tree of symbols with optional search text control and description panel....
Definition: lib_tree.h:49
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:302
LIB_TREE_MODEL_ADAPTER::SORT_MODE GetSortMode() const
Definition: lib_tree.h:137
wxString GetSearchString() const
Definition: lib_tree.cpp:343
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
Definition: lib_tree.cpp:271
@ ALL_WIDGETS
Definition: lib_tree.h:57
void SetSearchString(const wxString &aSearchString)
Save/restore search string.
Definition: lib_tree.cpp:337
SYMBOL_PREVIEW_WIDGET * m_symbol_preview
void onSymbolSelected(wxCommandEvent &aEvent)
void showFootprintFor(const LIB_ID &aLibId)
Look up the footprint for a given symbol specified in the LIB_ID and display it.
wxSplitterWindow * m_hsplitter
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
static wxString g_symbolSearchString
std::function< void()> m_closeHandler
void onCloseTimer(wxTimerEvent &aEvent)
wxSplitterWindow * m_vsplitter
std::vector< std::pair< int, wxString > > m_field_edits
void OnCharHook(wxKeyEvent &aEvt)
void showFootprint(const wxString &aFootprint)
Display the given footprint by name.
void populateFootprintSelector(const LIB_ID &aLibId)
Populate the footprint selector for a given alias.
void onFootprintSelected(wxCommandEvent &aEvent)
static wxString g_powerSearchString
void SetPreselect(const LIB_ID &aPreselect)
PANEL_SYMBOL_CHOOSER(SCH_BASE_FRAME *aFrame, wxWindow *aParent, const SYMBOL_LIBRARY_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, std::vector< PICKED_SYMBOL > &aAlreadyPlaced, bool aAllowFieldEdits, bool aShowFootprints, std::function< void()> aCloseHandler)
Create dialog to choose symbol.
static constexpr int DBLCLICK_DELAY
FOOTPRINT_PREVIEW_WIDGET * m_fp_preview
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
void onSymbolChosen(wxCommandEvent &aEvent)
Handle the selection of an item.
wxPanel * constructRightPanel(wxWindow *aParent)
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:70
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:166
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
Helper object to filter a list of libraries.
const wxArrayString & GetAllowedLibList() const
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
void SetStatusText(const wxString &aText)
Set the contents of the status label and display it.
void DisplaySymbol(const LIB_ID &aSymbolID, int aUnit, int aConvert=0)
Set the currently displayed symbol.
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Factory function: create a model adapter in a reference-counting container.
bool AddLibraries(const std::vector< wxString > &aNicknames, SCH_BASE_FRAME *aFrame)
Add all the libraries in a SYMBOL_LIB_TABLE to the model.
void AddLibrary(wxString const &aLibNickname, bool pinned)
EDA_UNITS GetUserUnits() const
wxString wx_str() const
Definition: utf8.cpp:45
#define _(s)
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:61
void delete_if(_Container &__c, _Function &&__f)
Deletes all values from __c for which __f returns true.
Definition: kicad_algo.h:174
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:100
STL namespace.
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:119
std::vector< wxString > pinned_symbol_libs
Definition for symbol library class.
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".