KiCad PCB EDA Suite
symbol_viewer_frame.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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <bitmaps.h>
28#include <confirm.h>
31#include <eeschema_id.h>
32#include <eeschema_settings.h>
33#include <kiface_base.h>
34#include <kiway.h>
35#include <locale_io.h>
36#include <symbol_viewer_frame.h>
37#include <widgets/msgpanel.h>
38#include <widgets/wx_listbox.h>
39#include <sch_view.h>
40#include <sch_painter.h>
41#include <symbol_lib_table.h>
43#include <pgm_base.h>
46#include <symbol_async_loader.h>
47#include <tool/action_toolbar.h>
48#include <tool/common_control.h>
49#include <tool/common_tools.h>
51#include <tool/selection.h>
53#include <tool/tool_manager.h>
54#include <tool/zoom_tool.h>
55#include <tools/ee_actions.h>
58#include <view/view_controls.h>
60#include <wx/srchctrl.h>
61
62#include <default_values.h>
63#include <string_utils.h>
64#include "eda_pattern_match.h"
65
66// Save previous symbol library viewer state.
68
72
73
74BEGIN_EVENT_TABLE( SYMBOL_VIEWER_FRAME, SCH_BASE_FRAME )
75 // Window events
78
79 // Toolbar events
84
85 // listbox events
91
92 // Menu (and/or hotkey) events
93 EVT_MENU( wxID_CLOSE, SYMBOL_VIEWER_FRAME::CloseLibraryViewer )
95
97
98END_EVENT_TABLE()
99
100
101#define LIB_VIEW_NAME "ViewlibFrame"
102#define LIB_VIEW_NAME_MODAL "ViewlibFrameModal"
103
104#define LIB_VIEW_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
105#define LIB_VIEW_STYLE_MODAL ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
106
107
108SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
109 const wxString& aLibraryName ) :
110 SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Symbol Library Browser" ),
111 wxDefaultPosition, wxDefaultSize,
114 m_unitChoice( nullptr ),
115 m_libList( nullptr ),
116 m_symbolList( nullptr ),
117 m_previewItem( nullptr )
118{
119 wxASSERT( aFrameType == FRAME_SCH_VIEWER || aFrameType == FRAME_SCH_VIEWER_MODAL );
120
121 if( aFrameType == FRAME_SCH_VIEWER_MODAL )
122 SetModal( true );
123
124 m_aboutTitle = _HKI( "KiCad Symbol Library Viewer" );
125
126 // Force the frame name used in config. the lib viewer frame has a name
127 // depending on aFrameType (needed to identify the frame by wxWidgets),
128 // but only one configuration is preferable.
130
131 // Give an icon
132 wxIcon icon;
133 icon.CopyFromBitmap( KiBitmap( BITMAPS::library_browser ) );
134 SetIcon( icon );
135
136 m_libListWidth = 200;
137 m_symbolListWidth = 300;
138 m_listPowerOnly = false;
139
140 SetScreen( new SCH_SCREEN );
141 GetScreen()->m_Center = true; // Axis origin centered on screen.
142 LoadSettings( config() );
143
144 // Ensure axis are always drawn (initial default display was not drawn)
146 gal_opts.m_axesEnabled = true;
147 gal_opts.m_gridMinSpacing = 10.0;
148 gal_opts.NotifyChanged();
149
152
154
155 setupTools();
157
161
162 wxPanel* libPanel = new wxPanel( this );
163 wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
164
165 m_libFilter = new wxSearchCtrl( libPanel, ID_LIBVIEW_LIB_FILTER, wxEmptyString,
166 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
167 m_libFilter->SetDescriptiveText( _( "Filter" ) );
168 libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
169
170 m_libList = new WX_LISTBOX( libPanel, ID_LIBVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
171 0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
172 libSizer->Add( m_libList, 1, wxEXPAND, 5 );
173
174 libPanel->SetSizer( libSizer );
175 libPanel->Fit();
176
177 wxPanel* symbolPanel = new wxPanel( this );
178 wxSizer* symbolSizer = new wxBoxSizer( wxVERTICAL );
179
180 m_symbolFilter = new wxSearchCtrl( symbolPanel, ID_LIBVIEW_SYM_FILTER, wxEmptyString,
181 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
182 m_symbolFilter->SetDescriptiveText( _( "Filter" ) );
183 m_symbolFilter->SetToolTip(
184 _( "Filter on symbol name, keywords, description and pin count.\n"
185 "Search terms are separated by spaces. All search terms must match.\n"
186 "A term which is a number will also match against the pin count." ) );
187 symbolSizer->Add( m_symbolFilter, 0, wxEXPAND, 5 );
188
189#ifdef __WXGTK__
190 // wxSearchCtrl vertical height is not calculated correctly on some GTK setups
191 // See https://gitlab.com/kicad/code/kicad/-/issues/9019
192 m_libFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
193 m_symbolFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
194#endif
195
196 m_symbolList = new WX_LISTBOX( symbolPanel, ID_LIBVIEW_SYM_LIST, wxDefaultPosition, wxDefaultSize,
197 0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
198 symbolSizer->Add( m_symbolList, 1, wxEXPAND, 5 );
199
200 symbolPanel->SetSizer( symbolSizer );
201 symbolPanel->Fit();
202
203 // Preload libraries
205
206 if( aLibraryName.empty() )
207 {
209 }
210 else
211 {
212 m_currentSymbol.SetLibNickname( aLibraryName );
214 m_unit = 1;
215 m_convert = 1;
216 }
217
218 m_selection_changed = false;
219
221
222 m_auimgr.SetManagedWindow( this );
223
225
226 // Manage main toolbar
227 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
228 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) .Bottom().Layer(6) );
229
230 m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
231 .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
232 m_auimgr.AddPane( symbolPanel, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1)
233 .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
234
235 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
236
237 m_auimgr.GetPane( libPanel ).Show( aLibraryName.empty() );
238
239 m_auimgr.Update();
240
241 if( m_libListWidth > 0 )
242 {
243 wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Libraries" );
244
245 // wxAUI hack: force width by setting MinSize() and then Fixed()
246 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
247 treePane.MinSize( m_libListWidth, -1 );
248 treePane.Fixed();
249 m_auimgr.Update();
250
251 // now make it resizable again
252 treePane.Resizable();
253 m_auimgr.Update();
254
255 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
256 // back to minimum.
257 treePane.MinSize( 100, -1 );
258 }
259
260 if( m_symbolListWidth > 0 )
261 {
262 wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Symbols" );
263
264 // wxAUI hack: force width by setting MinSize() and then Fixed()
265 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
266 treePane.MinSize( m_symbolListWidth, -1 );
267 treePane.Fixed();
268 m_auimgr.Update();
269
270 // now make it resizable again
271 treePane.Resizable();
272 m_auimgr.Update();
273
274 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
275 // back to minimum.
276 treePane.MinSize( 100, -1 );
277 }
278
280
281 if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
282 {
283 Raise();
284 Show( true );
285 }
286
287 SyncView();
288 GetCanvas()->SetCanFocus( false );
289
290 setupUnits( config() );
291
292 // Set the working/draw area size to display a symbol to a reasonable value:
293 // A 450mm x 450mm with a origin at the area center looks like a large working area
294 double max_size_x = schIUScale.mmToIU( 450 );
295 double max_size_y = schIUScale.mmToIU( 450 );
296 BOX2D bbox;
297 bbox.SetOrigin( -max_size_x / 2, -max_size_y / 2 );
298 bbox.SetSize( max_size_x, max_size_y );
299 GetCanvas()->GetView()->SetBoundary( bbox );
301
302 // If a symbol was previously selected in m_symbolList from a previous run, show it
303 wxString symbName = m_symbolList->GetStringSelection();
304
305 if( !symbName.IsEmpty() )
306 {
307 SetSelectedSymbol( symbName );
309 }
310}
311
312
314{
315 // Shutdown all running tools
316 if( m_toolManager )
318
319 if( m_previewItem )
321}
322
323
325{
326 // TODO: deduplicate with SYMBOL_TREE_MODEL_ADAPTER::AddLibraries
327 std::vector<wxString> libraryNames = Prj().SchSymbolLibTable()->GetLogicalLibs();
328 std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter = nullptr;
329
330 if( m_show_progress )
331 {
332 progressReporter = std::make_unique<WX_PROGRESS_REPORTER>( this,
333 _( "Loading Symbol Libraries" ),
334 libraryNames.size(), true );
335 }
336
337 // Disable KIID generation: not needed for library parts; sometimes very slow
338 KIID::CreateNilUuids( true );
339
340 std::unordered_map<wxString, std::vector<LIB_SYMBOL*>> loadedSymbols;
341
342 SYMBOL_ASYNC_LOADER loader( libraryNames, Prj().SchSymbolLibTable(), false, nullptr,
343 progressReporter.get() );
344
345 LOCALE_IO toggle;
346
347 loader.Start();
348
349 while( !loader.Done() )
350 {
351 if( progressReporter && !progressReporter->KeepRefreshing() )
352 break;
353
354 wxMilliSleep( 33 );
355 }
356
357 loader.Join();
358
359 KIID::CreateNilUuids( false );
360
361 if( !loader.GetErrors().IsEmpty() )
362 {
363 HTML_MESSAGE_BOX dlg( this, _( "Load Error" ) );
364
365 dlg.MessageSet( _( "Errors loading symbols:" ) );
366
367 wxString msg = loader.GetErrors();
368 msg.Replace( "\n", "<BR>" );
369
370 dlg.AddHTML_Text( msg );
371 dlg.ShowModal();
372 }
373}
374
375
377{
378 // Create the manager and dispatcher & route draw panel events to the dispatcher
381 GetCanvas()->GetViewControls(), config(), this );
382 m_actions = new EE_ACTIONS();
384
385 // Register tools
389 m_toolManager->RegisterTool( new EE_INSPECTION_TOOL ); // manage show datasheet
390 m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); // manage context menu
391 m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL ); // manage render settings
392
394
395 // Run the selection tool, it is supposed to be always active
396 // It also manages the mouse right click to show the context menu
397 m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
398
400}
401
402
404{
406
408 EDITOR_CONDITIONS cond( this );
409
410 wxASSERT( mgr );
411
412#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
413#define CHECK( x ) ACTION_CONDITIONS().Check( x )
414
416
417 auto electricalTypesShownCondition =
418 [this]( const SELECTION& aSel )
419 {
421 };
422
423 auto pinNumbersShownCondition =
424 [this]( const SELECTION& )
425 {
427 };
428
429 auto demorganCond =
430 [this]( const SELECTION& )
431 {
432 LIB_SYMBOL* symbol = GetSelectedSymbol();
433
434 return symbol && symbol->HasConversion();
435 };
436
437 auto demorganStandardCond =
438 []( const SELECTION& )
439 {
440 return m_convert == LIB_ITEM::LIB_CONVERT::BASE;
441 };
442
443 auto demorganAlternateCond =
444 []( const SELECTION& )
445 {
446 return m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN;
447 };
448
449 auto haveDatasheetCond =
450 [this]( const SELECTION& )
451 {
452 LIB_SYMBOL* symbol = GetSelectedSymbol();
453
454 return symbol && !symbol->GetDatasheetField().GetText().IsEmpty();
455 };
456
457 mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
458 mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( electricalTypesShownCondition ) );
459 mgr->SetConditions( EE_ACTIONS::showPinNumbers, CHECK( pinNumbersShownCondition ) );
460
462 ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) );
464 ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) );
465
466#undef CHECK
467#undef ENABLE
468}
469
470
471void SYMBOL_VIEWER_FRAME::SetUnitAndConvert( int aUnit, int aConvert )
472{
473 m_unit = aUnit > 0 ? aUnit : 1;
474 m_convert = aConvert > 0 ? aConvert : LIB_ITEM::LIB_CONVERT::BASE;
475 m_selection_changed = false;
476
478}
479
480
482{
483 LIB_SYMBOL* symbol = nullptr;
484
486 symbol = Prj().SchSymbolLibTable()->LoadSymbol( m_currentSymbol );
487
488 return symbol;
489}
490
491
493{
494 LIB_SYMBOL* symbol = GetSelectedSymbol();
495 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
496
497 if( m_previewItem )
498 {
499 view->Remove( m_previewItem );
500 m_previewItem = nullptr;
501 }
502
504
505 if( symbol )
506 {
509
510 m_previewItem = symbol;
511 view->Add( m_previewItem );
512
513 wxString parentName;
514 std::shared_ptr<LIB_SYMBOL> parent = m_previewItem->GetParent().lock();
515
516 if( parent )
517 parentName = parent->GetName();
518
520 AppendMsgPanel( _( "Parent" ), UnescapeString( parentName ) );
521 AppendMsgPanel( _( "Description" ), m_previewItem->GetDescription() );
522 AppendMsgPanel( _( "Keywords" ), m_previewItem->GetKeyWords() );
523 }
524
526 GetCanvas()->Refresh();
527}
528
529
530bool SYMBOL_VIEWER_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent )
531{
532 if( aSymbol && !aSymbol->IsEmpty() )
533 {
534 wxString msg;
535 LIB_TABLE* libTable = Prj().SchSymbolLibTable();
536 LIB_ID libid;
537
538 libid.Parse( *aSymbol, true );
539
540 if( libid.IsValid() )
541 {
542 wxString libName = libid.GetLibNickname();
543
544 if( !libTable->HasLibrary( libid.GetLibNickname(), false ) )
545 {
546 msg.Printf( _( "The current configuration does not include the library '%s'.\n"
547 "Use Manage Symbol Libraries to edit the configuration." ),
548 UnescapeString( libName ) );
549 DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
550 }
551 else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
552 {
553 msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n"
554 "Use Manage Symbol Libraries to edit the configuration." ),
555 UnescapeString( libName ) );
556 DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
557 }
558 else
559 {
562 }
563 }
564 }
565
566 m_libFilter->SetFocus();
567 return KIWAY_PLAYER::ShowModal( aSymbol, aParent );
568}
569
570
572{
574
575 if( !IsModal() )
576 {
577 Destroy();
578 }
579 else if( !IsDismissed() )
580 {
581 // only dismiss modal frame if not already dismissed.
582 DismissModal( false );
583
584 // Modal frame will be destroyed by the calling function.
585 }
586}
587
588
589void SYMBOL_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
590{
591 if( m_auimgr.GetManagedWindow() )
592 m_auimgr.Update();
593
594 SizeEv.Skip();
595}
596
597
598void SYMBOL_VIEWER_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent )
599{
600 LIB_SYMBOL* symbol = GetSelectedSymbol();
601
602 int unit_count = 1;
603
604 if( symbol )
605 unit_count = std::max( symbol->GetUnitCount(), 1 );
606
607 m_unitChoice->Enable( unit_count > 1 );
608
609 if( unit_count > 1 )
610 {
611 // rebuild the unit list if it is not suitable (after a new selection for instance)
612 if( unit_count != (int)m_unitChoice->GetCount() )
613 {
614 m_unitChoice->Clear();
615
616 for( int ii = 0; ii < unit_count; ii++ )
617 {
618 wxString unit = symbol->GetUnitDisplayName( ii + 1 );
619 m_unitChoice->Append( unit );
620 }
621
622 }
623
624 if( m_unitChoice->GetSelection() != std::max( 0, m_unit - 1 ) )
625 m_unitChoice->SetSelection( std::max( 0, m_unit - 1 ) );
626 }
627 else if( m_unitChoice->GetCount() )
628 {
629 m_unitChoice->Clear();
630 }
631}
632
633
635{
636 if( !m_libList )
637 return false;
638
639 m_libList->Clear();
640
641 COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
643 SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
644 std::vector<wxString> libs = libTable->GetLogicalLibs();
645 std::vector<wxString> pinnedMatches;
646 std::vector<wxString> otherMatches;
647
648 auto doAddLib =
649 [&]( const wxString& aLib )
650 {
651 if( alg::contains( project.m_PinnedSymbolLibs, aLib )
653 {
654 pinnedMatches.push_back( aLib );
655 }
656 else
657 {
658 otherMatches.push_back( aLib );
659 }
660 };
661
662 auto process =
663 [&]( const wxString& aLib )
664 {
665 // Remove not allowed libs, if the allowed lib list is not empty
666 if( m_allowedLibs.GetCount() )
667 {
668 if( m_allowedLibs.Index( aLib ) == wxNOT_FOUND )
669 return;
670 }
671
672 // Remove libs which have no power symbols, if this filter is activated
673 if( m_listPowerOnly )
674 {
675 wxArrayString aliasNames;
676
677 Prj().SchSymbolLibTable()->EnumerateSymbolLib( aLib, aliasNames, true );
678
679 if( aliasNames.IsEmpty() )
680 return;
681 }
682
683 SYMBOL_LIB_TABLE_ROW* row = libTable->FindRow( aLib );
684
685 if( !row->GetIsVisible() )
686 return;
687
688 if( row->SupportsSubLibraries() )
689 {
690 std::vector<wxString> subLibraries;
691 row->GetSubLibraryNames( subLibraries );
692
693 for( const wxString& lib : subLibraries )
694 {
695 wxString suffix = lib.IsEmpty() ? wxT( "" )
696 : wxString::Format( wxT( " - %s" ), lib );
697 wxString name = wxString::Format( wxT( "%s%s" ), aLib, suffix );
698
699 doAddLib( name );
700 }
701 }
702 else
703 {
704 doAddLib( aLib );
705 }
706 };
707
708 if( m_libFilter->GetValue().IsEmpty() )
709 {
710 for( const wxString& lib : libs )
711 process( lib );
712 }
713 else
714 {
715 wxStringTokenizer tokenizer( m_libFilter->GetValue() );
716
717 while( tokenizer.HasMoreTokens() )
718 {
719 const wxString term = tokenizer.GetNextToken().Lower();
720 EDA_COMBINED_MATCHER matcher( term, CTX_LIBITEM );
721 int matches, position;
722
723 for( const wxString& lib : libs )
724 {
725 if( matcher.Find( lib.Lower(), matches, position ) )
726 process( lib );
727 }
728 }
729 }
730
731 if( libs.empty() )
732 return true;
733
734 for( const wxString& name : pinnedMatches )
736
737 for( const wxString& name : otherMatches )
738 m_libList->Append( UnescapeString( name ) );
739
740 // Search for a previous selection:
742
743 if( index != wxNOT_FOUND )
744 {
745 m_libList->SetSelection( index, true );
746 }
747 else
748 {
749 // If not found, clear current library selection because it can be deleted after a
750 // config change.
752 ? m_libList->GetBaseString( 0 ) : wxT( "" ) );
753 m_currentSymbol.SetLibItemName( wxEmptyString );
754 m_unit = 1;
755 m_convert = LIB_ITEM::LIB_CONVERT::BASE;
756 }
757
758 bool cmp_changed = ReCreateSymbolList();
760 GetCanvas()->Refresh();
761
762 return cmp_changed;
763}
764
765
767{
768 if( m_symbolList == nullptr )
769 return false;
770
771 m_symbolList->Clear();
772
773 wxString libName = m_currentSymbol.GetUniStringLibNickname();
774
775 if( libName.IsEmpty() )
776 return false;
777
778 std::vector<LIB_SYMBOL*> symbols;
779 SYMBOL_LIB_TABLE_ROW* row = Prj().SchSymbolLibTable()->FindRow( libName );
780
781 try
782 {
783 if( row )
784 Prj().SchSymbolLibTable()->LoadSymbolLib( symbols, libName, m_listPowerOnly );
785 }
786 catch( const IO_ERROR& ) {} // ignore, it is handled below
787
788 std::set<wxString> excludes;
789
790 if( !m_symbolFilter->GetValue().IsEmpty() )
791 {
792 wxStringTokenizer tokenizer( m_symbolFilter->GetValue() );
793
794 while( tokenizer.HasMoreTokens() )
795 {
796 const wxString term = tokenizer.GetNextToken().Lower();
797 EDA_COMBINED_MATCHER matcher( term, CTX_LIBITEM );
798 int matches, position;
799
800 for( LIB_SYMBOL* symbol : symbols )
801 {
802 wxString search = symbol->GetName() + wxS( " " ) + symbol->GetSearchText();
803 bool matched = matcher.Find( search.Lower(), matches, position );
804
805 if( !matched && term.IsNumber() )
806 matched = ( wxAtoi( term ) == (int)symbol->GetPinCount() );
807
808 if( !matched )
809 excludes.insert( symbol->GetName() );
810 }
811 }
812 }
813
814 wxString subLib = m_currentSymbol.GetSubLibraryName();
815
816 for( const LIB_SYMBOL* symbol : symbols )
817 {
818 if( row && row->SupportsSubLibraries()
819 && !subLib.IsSameAs( symbol->GetLibId().GetSubLibraryName() ) )
820 {
821 continue;
822 }
823
824 if( !excludes.count( symbol->GetName() ) )
825 m_symbolList->Append( UnescapeString( symbol->GetName() ) );
826 }
827
828 if( m_symbolList->IsEmpty() )
829 {
830 SetSelectedSymbol( wxEmptyString );
831 m_convert = LIB_ITEM::LIB_CONVERT::BASE;
832 m_unit = 1;
833 return true;
834 }
835
837 bool changed = false;
838
839 if( index == wxNOT_FOUND )
840 {
841 // Select the first library entry when the previous entry name does not exist in
842 // the current library.
843 m_convert = LIB_ITEM::LIB_CONVERT::BASE;
844 m_unit = 1;
845 index = -1;
846 changed = true;
847 SetSelectedSymbol( wxEmptyString );
848 }
849
850 m_symbolList->SetSelection( index, true );
851
852 return changed;
853}
854
855
856void SYMBOL_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event )
857{
858 int ii = m_libList->GetSelection();
859
860 if( ii < 0 )
861 return;
862
863 m_selection_changed = true;
864
865 wxString selection = EscapeString( m_libList->GetBaseString( ii ), CTX_LIBID );
866
867 if( !Prj().SchSymbolLibTable()->FindRow( selection )
868 && selection.Find( '-' ) != wxNOT_FOUND )
869 {
870 // Probably a sub-library
871 wxString sublib;
872 selection = selection.BeforeLast( '-', &sublib ).Trim();
873 sublib.Trim( false );
874 SetSelectedLibrary( selection, sublib );
875 }
876 else
877 {
878 SetSelectedLibrary( selection );
879 }
880}
881
882
883void SYMBOL_VIEWER_FRAME::SetSelectedLibrary( const wxString& aLibraryName,
884 const wxString& aSubLibName )
885{
886 if( m_currentSymbol.GetUniStringLibNickname() == aLibraryName &&
887 wxString( m_currentSymbol.GetSubLibraryName() ) == aSubLibName )
888 return;
889
890 m_currentSymbol.SetLibNickname( aLibraryName );
891 m_currentSymbol.SetSubLibraryName( aSubLibName );
893 GetCanvas()->Refresh();
895
896 // Ensure the corresponding line in m_libList is selected
897 // (which is not necessary the case if SetSelectedLibrary is called
898 // by another caller than ClickOnLibList.
900
901 // The m_libList has now the focus, in order to be able to use arrow keys
902 // to navigate inside the list.
903 // the gal canvas must not steal the focus to allow navigation
904 GetCanvas()->SetStealsFocus( false );
905 m_libList->SetFocus();
906}
907
908
909void SYMBOL_VIEWER_FRAME::ClickOnSymbolList( wxCommandEvent& event )
910{
911 int ii = m_symbolList->GetSelection();
912
913 if( ii < 0 )
914 return;
915
916 m_selection_changed = true;
917
919
920 // The m_symbolList has now the focus, in order to be able to use arrow keys
921 // to navigate inside the list.
922 // the gal canvas must not steal the focus to allow navigation
923 GetCanvas()->SetStealsFocus( false );
924 m_symbolList->SetFocus();
925}
926
927
928void SYMBOL_VIEWER_FRAME::SetSelectedSymbol( const wxString& aSymbolName )
929{
930 if( m_currentSymbol.GetUniStringLibItemName() != aSymbolName )
931 {
932 m_currentSymbol.SetLibItemName( aSymbolName );
933
934 // Ensure the corresponding line in m_symbolList is selected
935 // (which is not necessarily the case if SetSelectedSymbol is called
936 // by another caller than ClickOnSymbolList.
937 m_symbolList->SetStringSelection( UnescapeString( aSymbolName ), true );
939
941 {
942 m_unit = 1;
943 m_convert = LIB_ITEM::LIB_CONVERT::BASE;
944 m_selection_changed = false;
945 }
946
948 }
949}
950
951
952void SYMBOL_VIEWER_FRAME::DClickOnSymbolList( wxCommandEvent& event )
953{
955}
956
957
959{
960 auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
961
963
964 // Grid shape, etc.
965 GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
966
967 m_libListWidth = cfg->m_LibViewPanel.lib_list_width;
968 m_symbolListWidth = cfg->m_LibViewPanel.cmp_list_width;
969
970 GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_LibViewPanel.show_pin_electrical_type;
971 GetRenderSettings()->m_ShowPinNumbers = cfg->m_LibViewPanel.show_pin_numbers;
972
973 // Set parameters to a reasonable value.
974 int maxWidth = cfg->m_LibViewPanel.window.state.size_x - 80;
975
976 if( m_libListWidth + m_symbolListWidth > maxWidth )
977 {
980 }
981}
982
983
985{
986 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
987
989
991 m_libListWidth = m_libList->GetSize().x;
992
993 m_symbolListWidth = m_symbolList->GetSize().x;
994
997
998 if( KIGFX::SCH_RENDER_SETTINGS* renderSettings = GetRenderSettings() )
999 {
1000 cfg->m_LibViewPanel.show_pin_electrical_type = renderSettings->m_ShowPinsElectricalType;
1001 cfg->m_LibViewPanel.show_pin_numbers = renderSettings->m_ShowPinNumbers;
1002 }
1003}
1004
1005
1007{
1008 auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
1009 wxASSERT( cfg );
1010 return &cfg->m_LibViewPanel.window;
1011}
1012
1013
1014void SYMBOL_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1015{
1016 SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1017
1018 auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
1019 GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
1020
1022 GetCanvas()->GetGAL()->DrawGrid();
1024
1025 if( aEnvVarsChanged )
1027}
1028
1029
1030void SYMBOL_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
1031{
1032 if( event.GetActive() )
1033 {
1034 bool changed = m_libList ? ReCreateLibList() : false;
1035
1036 if (changed)
1037 m_selection_changed = true;
1038
1040
1042 }
1043
1044 event.Skip(); // required under wxMAC
1045}
1046
1047
1048void SYMBOL_VIEWER_FRAME::CloseLibraryViewer( wxCommandEvent& event )
1049{
1050 Close();
1051}
1052
1053
1055{
1056 m_listPowerOnly = false;
1057 m_allowedLibs.Clear();
1058
1059 if( aFilter )
1060 {
1061 m_allowedLibs = aFilter->GetAllowedLibList();
1063 }
1064
1066}
1067
1068
1069const BOX2I SYMBOL_VIEWER_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1070{
1071 LIB_SYMBOL* symbol = GetSelectedSymbol();
1072
1073 if( !symbol )
1074 {
1075 return BOX2I( VECTOR2I( -200, -200 ), VECTOR2I( 400, 400 ) );
1076 }
1077 else
1078 {
1079 std::shared_ptr<LIB_SYMBOL> tmp = symbol->IsAlias() ? symbol->GetParent().lock()
1080 : symbol->SharedPtr();
1081
1082 wxCHECK( tmp, BOX2I( VECTOR2I( -200, -200 ), VECTOR2I( 400, 400 ) ) );
1083
1084 return tmp->GetUnitBoundingBox( m_unit, m_convert );
1085 }
1086}
1087
1088
1090{
1091 if( m_symbolList->GetSelection() >= 0 )
1092 {
1094 }
1095 else
1096 {
1097 DismissModal( false );
1098 }
1099
1100 Close( true );
1101}
1102
1103
1104void SYMBOL_VIEWER_FRAME::OnSelectSymbol( wxCommandEvent& aEvent )
1105{
1106 std::unique_lock<std::mutex> dialogLock( DIALOG_CHOOSE_SYMBOL::g_Mutex, std::defer_lock );
1107
1108 // One CHOOSE_SYMBOL dialog at a time. User probably can't handle more anyway.
1109 if( !dialogLock.try_lock() )
1110 return;
1111
1112 // Container doing search-as-you-type.
1113 SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
1114 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> dataPtr
1115 = SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs );
1116 SYMBOL_TREE_MODEL_ADAPTER* modelAdapter
1117 = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( dataPtr.get() );
1118
1119 if( !modelAdapter->AddLibraries( libs->GetLogicalLibs(), this ) )
1120 {
1121 // loading cancelled by user
1122 return;
1123 }
1124
1125 LIB_SYMBOL* current = GetSelectedSymbol();
1126 LIB_ID id;
1127 int unit = 0;
1128
1129 if( current )
1130 {
1131 id = current->GetLibId();
1132 modelAdapter->SetPreselectNode( id, unit );
1133 }
1134
1135 wxString dialogTitle;
1136 dialogTitle.Printf( _( "Choose Symbol (%d items loaded)" ), modelAdapter->GetItemCount() );
1137
1138 DIALOG_CHOOSE_SYMBOL dlg( this, dialogTitle, dataPtr, m_convert, false, false, false );
1139
1140 if( dlg.ShowQuasiModal() == wxID_CANCEL )
1141 return;
1142
1143 // Save any changes to column widths, etc.
1144 modelAdapter->SaveSettings();
1145
1146 id = dlg.GetSelectedLibId( &unit );
1147
1148 if( !id.IsValid() )
1149 return;
1150
1151 SetSelectedLibrary( id.GetLibNickname(), id.GetSubLibraryName() );
1152 SetSelectedSymbol( id.GetLibItemName() );
1153 SetUnitAndConvert( unit, 1 );
1154}
1155
1156
1157void SYMBOL_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
1158{
1160
1161 // Required to avoid interaction with SetHint()
1162 // See documentation for wxTextEntry::SetHint
1163 aEvent.Skip();
1164}
1165
1166
1167void SYMBOL_VIEWER_FRAME::OnSymFilter( wxCommandEvent& aEvent )
1168{
1170
1171 // Required to avoid interaction with SetHint()
1172 // See documentation for wxTextEntry::SetHint
1173 aEvent.Skip();
1174}
1175
1176
1177void SYMBOL_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
1178{
1179 if( aEvent.GetKeyCode() == WXK_UP )
1180 {
1181 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
1182 {
1183 int prev = m_libList->GetSelection() - 1;
1184
1185 if( prev >= 0 )
1186 {
1187 m_libList->SetSelection( prev );
1188 m_libList->EnsureVisible( prev );
1189
1190 wxCommandEvent dummy;
1192 }
1193 }
1194 else
1195 {
1196 wxCommandEvent dummy;
1198 }
1199 }
1200 else if( aEvent.GetKeyCode() == WXK_DOWN )
1201 {
1202 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
1203 {
1204 int next = m_libList->GetSelection() + 1;
1205
1206 if( next < (int)m_libList->GetCount() )
1207 {
1208 m_libList->SetSelection( next );
1209 m_libList->EnsureVisible( next );
1210
1211 wxCommandEvent dummy;
1213 }
1214 }
1215 else
1216 {
1217 wxCommandEvent dummy;
1219 }
1220 }
1221 else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
1222 {
1223 if( !aEvent.ShiftDown() )
1224 m_symbolFilter->SetFocus();
1225 else
1226 aEvent.Skip();
1227 }
1228 else if( aEvent.GetKeyCode() == WXK_TAB && m_symbolFilter->HasFocus() )
1229 {
1230 if( aEvent.ShiftDown() )
1231 m_libFilter->SetFocus();
1232 else
1233 aEvent.Skip();
1234 }
1235 else if( aEvent.GetKeyCode() == WXK_RETURN && m_symbolList->GetSelection() >= 0 )
1236 {
1237 wxCommandEvent dummy;
1239 }
1240 else
1241 {
1242 aEvent.Skip();
1243 }
1244}
1245
1246
1247void SYMBOL_VIEWER_FRAME::onSelectNextSymbol( wxCommandEvent& aEvent )
1248{
1249 wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_SYM_LIST );
1250 int ii = m_symbolList->GetSelection();
1251
1252 // Select the next symbol or stop at the end of the list.
1253 if( ii != wxNOT_FOUND || ii != (int) m_symbolList->GetCount() - 1 )
1254 ii += 1;
1255
1256 m_symbolList->SetSelection( ii );
1257 ProcessEvent( evt );
1258}
1259
1260
1262{
1263 wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_SYM_LIST );
1264 int ii = m_symbolList->GetSelection();
1265
1266 // Select the previous symbol or stop at the beginning of list.
1267 if( ii != wxNOT_FOUND && ii != 0 )
1268 ii -= 1;
1269
1270 m_symbolList->SetSelection( ii );
1271 ProcessEvent( evt );
1272}
1273
1274
1275void SYMBOL_VIEWER_FRAME::onSelectSymbolUnit( wxCommandEvent& aEvent )
1276{
1277 int ii = m_unitChoice->GetSelection();
1278
1279 if( ii < 0 )
1280 return;
1281
1282 m_unit = ii + 1;
1283
1285}
1286
1287
1289{
1290 wxString libName = m_currentSymbol.GetUniStringLibNickname();
1291
1292 if( m_libList && !m_libList->IsEmpty() && !libName.IsEmpty() )
1293 {
1294 const SYMBOL_LIB_TABLE_ROW* row =
1295 Prj().SchSymbolLibTable()->FindRow( libName, true );
1296
1297 wxString title = row ? row->GetFullURI( true ) : _( "[no library selected]" );
1298
1299 title += wxT( " \u2014 " ) + _( "Symbol Library Browser" );
1300 SetTitle( title );
1301 }
1302}
1303
1304
1306{
1307 return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1308}
const char * name
Definition: DXF_plotter.cpp:56
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ library_browser
BOX2< VECTOR2I > BOX2I
Definition: box2.h:847
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:110
bool m_Center
Center on screen.
Definition: base_screen.h:96
void SetOrigin(const Vec &pos)
Definition: box2.h:202
void SetSize(const Vec &size)
Definition: box2.h:213
COLOR4D GetColor(int aLayer) const
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
Definition: common_tools.h:38
Dialog class to select a symbol from the libraries.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
static std::mutex g_Mutex
int ShowQuasiModal()
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void FinishAUIInitialization()
wxString m_configName
wxAuiManager m_auimgr
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
wxString m_aboutTitle
void ReCreateMenuBar()
Recreates the menu bar.
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
virtual void ClearMsgPanel()
Clear all messages from the message panel.
COLOR_SETTINGS * m_colorSettings
void setupUnits(APP_SETTINGS_BASE *aCfg)
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
EDA_MSG_PANEL * m_messagePanel
virtual void SetScreen(BASE_SCREEN *aScreen)
ACTION_TOOLBAR * m_mainToolBar
void OnGridSettings(wxCommandEvent &event)
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void SetStealsFocus(bool aStealsFocus)
Set whether focus is taken on certain events (mouseover, keys, etc).
Specialization of the wxAuiPaneInfo class for KiCad panels.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
Class that groups generic conditions for editor states.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
PANEL_LIB_VIEW m_LibViewPanel
Gather all the actions that are shared by tools.
Definition: ee_actions.h:39
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:135
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:134
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:176
static TOOL_ACTION showPinNumbers
Definition: ee_actions.h:225
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:149
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:224
void MessageSet(const wxString &message)
Add a message (in bold) to message list.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
double m_gridMinSpacing
Whether or not to draw the coordinate system axes.
bool m_axesEnabled
Fullscreen crosshair or small cross.
virtual void DrawGrid()
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
void SetDefaultPenWidth(int aWidth)
Store schematic specific render settings.
Definition: sch_painter.h:71
void LoadColors(const COLOR_SETTINGS *aSettings) override
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:349
void SetBoundary(const BOX2D &aBoundary)
Set limits for view area.
Definition: view.h:279
static void CreateNilUuids(bool aNil=true)
A performance optimization which disables/enables the generation of pseudo-random UUIDs.
Definition: kiid.cpp:294
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
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
bool IsDismissed()
void SetModal(bool aIsModal)
Definition: kiway_player.h:160
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
bool IsModal() const override
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
Definition: kiway_player.h:159
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:274
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:192
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:50
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition: lib_id.cpp:109
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:172
UTF8 Format() const
Definition: lib_id.cpp:117
void SetSubLibraryName(const UTF8 &aName)
Definition: lib_id.h:131
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition: lib_id.h:112
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:98
const wxString GetUniStringLibNickname() const
Definition: lib_id.h:88
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
UTF8 GetSubLibraryName() const
Some LIB_IDs can have a sub-library identifier in addition to a library nickname.
Definition: lib_id.h:130
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
const wxString GetFullLibraryName() const
Definition: lib_id.cpp:276
Define a library symbol object.
Definition: lib_symbol.h:99
wxString GetKeyWords() const
Definition: lib_symbol.h:164
wxString GetUnitDisplayName(int aUnit) override
Return the user-defined display name for aUnit for symbols with units.
Definition: lib_symbol.cpp:399
bool IsAlias() const
Definition: lib_symbol.h:188
LIB_ID GetLibId() const override
Definition: lib_symbol.h:141
wxString GetName() const override
Definition: lib_symbol.h:138
LIB_SYMBOL_SPTR SharedPtr() const
Definition: lib_symbol.h:110
wxString GetDescription() override
Definition: lib_symbol.h:151
int GetUnitCount() const override
For items with units, return the number of units.
LIB_FIELD & GetDatasheetField()
Return reference to the datasheet field.
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:127
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
bool GetIsVisible() const
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.
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.
static const wxString GetPinningSymbol()
void SaveSettings()
Save the column widths to the config file.
int GetItemCount() const
Return the number of symbols loaded in the tree.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:65
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:149
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SyncView()
Mark all items for refresh.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
bool Done()
Returns a string containing any errors generated during the load.
const wxString & GetErrors() const
Represents a pair of <nickname, loaded parts list>
void Start()
Spins up threads to load all the libraries in m_nicknames.
bool Join()
Finalizes the threads and combines the output into the target output map.
Handle actions for the various symbol editor and viewers.
Helper object to filter a list of libraries.
const wxArrayString & GetAllowedLibList() const
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
void GetSubLibraryNames(std::vector< wxString > &aNames) const
bool SupportsSubLibraries() const
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...
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.
Symbol library viewer main window.
void SetUnitAndConvert(int aUnit, int aConvert)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
void OnLibFilter(wxCommandEvent &aEvent)
void CloseLibraryViewer(wxCommandEvent &event)
void onSelectNextSymbol(wxCommandEvent &aEvent)
wxSearchCtrl * m_libFilter
void SetSelectedLibrary(const wxString &aLibName, const wxString &aSubLibName=wxEmptyString)
Set the selected library in the library window.
void ClickOnLibList(wxCommandEvent &event)
void onUpdateUnitChoice(wxUpdateUIEvent &aEvent)
void DClickOnSymbolList(wxCommandEvent &event)
bool ShowModal(wxString *aSymbol, wxWindow *aParent) override
Runs the symbol viewer as a modal dialog.
void OnActivate(wxActivateEvent &event)
Called when the frame is activated to reload the libraries and symbol lists that can be changed by th...
void OnSymFilter(wxCommandEvent &aEvent)
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void doCloseWindow() override
void FinishModal()
Send the selected symbol back to the caller.
void SetSelectedSymbol(const wxString &aSymbolName)
Set the selected symbol.
void SetFilter(const SYMBOL_LIBRARY_FILTER *aFilter)
Set a filter to display only libraries and/or symbols which match the filter.
bool ReCreateLibList()
Create o recreates a sorted list of currently loaded libraries.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void ClickOnSymbolList(wxCommandEvent &event)
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void OnSelectSymbol(wxCommandEvent &aEvent)
void ReCreateVToolbar() override
wxSearchCtrl * m_symbolFilter
void ReCreateHToolbar() override
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
static LIB_ID m_currentSymbol
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
void OnCharHook(wxKeyEvent &aEvent) override
Capture the key event before it is sent to the GUI.
SYMBOL_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aLibraryName=wxEmptyString)
LIB_SYMBOL * GetSelectedSymbol() const
void onSelectSymbolUnit(wxCommandEvent &aEvent)
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
void onSelectPreviousSymbol(wxCommandEvent &aEvent)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
bool m_selection_changed
Updated to true if a list rewrite on GUI activation resulted in the symbol selection changing,...
bool ReCreateSymbolList()
Create or recreate the list of symbols in the currently selected library.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:172
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
ACTIONS * m_actions
Definition: tools_holder.h:171
Master controller class:
Definition: tool_manager.h:55
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:196
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void InitTools()
Initializes all registered tools.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
wxString GetBaseString(int n) const
Definition: wx_listbox.cpp:61
int FindString(const wxString &s, bool bCase=false) const override
Definition: wx_listbox.cpp:72
wxString GetStringSelection() const override
Definition: wx_listbox.cpp:32
bool SetStringSelection(const wxString &s) override
Definition: wx_listbox.cpp:43
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
This file is part of the common library.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define _HKI(x)
#define _(s)
Abstract pattern-matching tool and implementations.
@ CTX_LIBITEM
@ ID_LIBVIEW_SELECT_UNIT_NUMBER
Definition: eeschema_id.h:72
@ ID_LIBVIEW_SYM_LIST
Definition: eeschema_id.h:76
@ ID_LIBVIEW_NEXT
Definition: eeschema_id.h:70
@ ID_LIBVIEW_SELECT_PART
Definition: eeschema_id.h:69
@ ID_LIBVIEW_LIB_FILTER
Definition: eeschema_id.h:73
@ ID_LIBVIEW_LIB_LIST
Definition: eeschema_id.h:74
@ ID_LIBVIEW_SYM_FILTER
Definition: eeschema_id.h:75
@ ID_LIBVIEW_PREVIOUS
Definition: eeschema_id.h:71
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SCH_VIEWER_MODAL
Definition: frame_type.h:37
@ ID_GRID_SETTINGS
Definition: id.h:146
@ LAYER_SCHEMATIC_GRID_AXES
Definition: layer_ids.h:375
Message panel definition file.
bool IsValid(const std::string &aString, SIM_VALUE::TYPE aValueType=SIM_VALUE::TYPE_FLOAT, NOTATION aNotation=NOTATION::SI)
Definition: sim_value.cpp:127
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
see class PGM_BASE
void process(const BOARD_CONNECTED_ITEM *item, int net)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
CITER next(CITER it)
Definition: ptree.cpp:126
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LIBID
Definition: string_utils.h:55
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
std::vector< wxString > pinned_symbol_libs
const double IU_PER_MILS
Definition: base_units.h:78
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:92
#define LIB_VIEW_STYLE
#define LIB_VIEW_STYLE_MODAL
#define CHECK(x)
#define ENABLE(x)
#define LIB_VIEW_NAME_MODAL
#define LIB_VIEW_NAME
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618