KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <kiway_express.h>
36#include <locale_io.h>
37#include <symbol_viewer_frame.h>
38#include <widgets/msgpanel.h>
39#include <widgets/wx_listbox.h>
40#include <sch_view.h>
41#include <sch_painter.h>
42#include <symbol_lib_table.h>
44#include <pgm_base.h>
47#include <symbol_async_loader.h>
48#include <tool/action_toolbar.h>
49#include <tool/common_control.h>
50#include <tool/common_tools.h>
52#include <tool/selection.h>
54#include <tool/tool_manager.h>
55#include <tool/zoom_tool.h>
56#include <tools/ee_actions.h>
59#include <view/view_controls.h>
61#include <wx/srchctrl.h>
62
63#include <default_values.h>
64#include <string_utils.h>
65#include "eda_pattern_match.h"
66
67// Save previous symbol library viewer state.
69
73
74
75BEGIN_EVENT_TABLE( SYMBOL_VIEWER_FRAME, SCH_BASE_FRAME )
76 // Window events
79
80 // Toolbar events
85
86 // listbox events
92
93 // Menu (and/or hotkey) events
94 EVT_MENU( wxID_CLOSE, SYMBOL_VIEWER_FRAME::CloseLibraryViewer )
96
98
99END_EVENT_TABLE()
100
101
102#define LIB_VIEW_NAME "ViewlibFrame"
103#define LIB_VIEW_NAME_MODAL "ViewlibFrameModal"
104
105#define LIB_VIEW_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
106#define LIB_VIEW_STYLE_MODAL ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
107
108
109SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
110 const wxString& aLibraryName ) :
111 SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Symbol Library Browser" ),
112 wxDefaultPosition, wxDefaultSize,
115 m_unitChoice( nullptr ),
116 m_libList( nullptr ),
117 m_symbolList( 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 )
320 {
321 GetCanvas()->GetView()->Remove( m_previewItem.get() );
322 m_previewItem = nullptr;
323 }
324}
325
326
328{
329 // TODO: deduplicate with SYMBOL_TREE_MODEL_ADAPTER::AddLibraries
330 std::vector<wxString> libraryNames = Prj().SchSymbolLibTable()->GetLogicalLibs();
331 std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter = nullptr;
332
333 if( m_show_progress )
334 {
335 progressReporter = std::make_unique<WX_PROGRESS_REPORTER>( this,
336 _( "Loading Symbol Libraries" ),
337 libraryNames.size(), true );
338 }
339
340 // Disable KIID generation: not needed for library parts; sometimes very slow
341 KIID::CreateNilUuids( true );
342
343 std::unordered_map<wxString, std::vector<LIB_SYMBOL*>> loadedSymbols;
344
345 SYMBOL_ASYNC_LOADER loader( libraryNames, Prj().SchSymbolLibTable(), false, nullptr,
346 progressReporter.get() );
347
348 LOCALE_IO toggle;
349
350 loader.Start();
351
352 while( !loader.Done() )
353 {
354 if( progressReporter && !progressReporter->KeepRefreshing() )
355 break;
356
357 wxMilliSleep( 33 );
358 }
359
360 loader.Join();
361
362 KIID::CreateNilUuids( false );
363
364 if( !loader.GetErrors().IsEmpty() )
365 {
366 HTML_MESSAGE_BOX dlg( this, _( "Load Error" ) );
367
368 dlg.MessageSet( _( "Errors loading symbols:" ) );
369
370 wxString msg = loader.GetErrors();
371 msg.Replace( "\n", "<BR>" );
372
373 dlg.AddHTML_Text( msg );
374 dlg.ShowModal();
375 }
376}
377
378
380{
381 // Create the manager and dispatcher & route draw panel events to the dispatcher
384 GetCanvas()->GetViewControls(), config(), this );
385 m_actions = new EE_ACTIONS();
387
388 // Register tools
392 m_toolManager->RegisterTool( new EE_INSPECTION_TOOL ); // manage show datasheet
393 m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); // manage context menu
394 m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL ); // manage render settings
395
397
398 // Run the selection tool, it is supposed to be always active
399 // It also manages the mouse right click to show the context menu
400 m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
401
403}
404
405
407{
409
411 EDITOR_CONDITIONS cond( this );
412
413 wxASSERT( mgr );
414
415#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
416#define CHECK( x ) ACTION_CONDITIONS().Check( x )
417
419
420 auto electricalTypesShownCondition =
421 [this]( const SELECTION& aSel )
422 {
424 };
425
426 auto pinNumbersShownCondition =
427 [this]( const SELECTION& )
428 {
430 };
431
432 auto demorganCond =
433 [this]( const SELECTION& )
434 {
435 LIB_SYMBOL* symbol = GetSelectedSymbol();
436
437 return symbol && symbol->HasConversion();
438 };
439
440 auto demorganStandardCond =
441 []( const SELECTION& )
442 {
444 };
445
446 auto demorganAlternateCond =
447 []( const SELECTION& )
448 {
450 };
451
452 auto haveDatasheetCond =
453 [this]( const SELECTION& )
454 {
455 LIB_SYMBOL* symbol = GetSelectedSymbol();
456
457 return symbol && !symbol->GetDatasheetField().GetText().IsEmpty();
458 };
459
460 mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
461 mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( electricalTypesShownCondition ) );
462 mgr->SetConditions( EE_ACTIONS::showPinNumbers, CHECK( pinNumbersShownCondition ) );
463
465 ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) );
467 ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) );
468
469#undef CHECK
470#undef ENABLE
471}
472
473
474void SYMBOL_VIEWER_FRAME::SetUnitAndConvert( int aUnit, int aConvert )
475{
476 m_unit = aUnit > 0 ? aUnit : 1;
477 m_convert = aConvert > 0 ? aConvert : LIB_ITEM::LIB_CONVERT::BASE;
478 m_selection_changed = false;
479
481}
482
483
485{
486 LIB_SYMBOL* symbol = nullptr;
487
489 symbol = Prj().SchSymbolLibTable()->LoadSymbol( m_currentSymbol );
490
491 return symbol;
492}
493
494
496{
497 LIB_SYMBOL* symbol = GetSelectedSymbol();
498 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
499
500 if( m_previewItem )
501 {
502 view->Remove( m_previewItem.get() );
503 m_previewItem = nullptr;
504 }
505
507
508 if( symbol )
509 {
512
513 m_previewItem = symbol->Flatten();
514 view->Add( m_previewItem.get() );
515
516 wxString parentName;
517 std::shared_ptr<LIB_SYMBOL> parent = symbol->GetParent().lock();
518
519 if( parent )
520 parentName = parent->GetName();
521
522 AppendMsgPanel( _( "Name" ), UnescapeString( m_previewItem->GetName() ) );
523 AppendMsgPanel( _( "Parent" ), UnescapeString( parentName ) );
524 AppendMsgPanel( _( "Description" ), m_previewItem->GetDescription() );
525 AppendMsgPanel( _( "Keywords" ), m_previewItem->GetKeyWords() );
526 }
527
529 GetCanvas()->Refresh();
530}
531
532
533bool SYMBOL_VIEWER_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent )
534{
535 if( aSymbol && !aSymbol->IsEmpty() )
536 {
537 wxString msg;
538 LIB_TABLE* libTable = Prj().SchSymbolLibTable();
539 LIB_ID libid;
540
541 libid.Parse( *aSymbol, true );
542
543 if( libid.IsValid() )
544 {
545 wxString libName = libid.GetLibNickname();
546
547 if( !libTable->HasLibrary( libid.GetLibNickname(), false ) )
548 {
549 msg.Printf( _( "The current configuration does not include the library '%s'.\n"
550 "Use Manage Symbol Libraries to edit the configuration." ),
551 UnescapeString( libName ) );
552 DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
553 }
554 else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
555 {
556 msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n"
557 "Use Manage Symbol Libraries to edit the configuration." ),
558 UnescapeString( libName ) );
559 DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
560 }
561 else
562 {
565 }
566 }
567 }
568
569 m_libFilter->SetFocus();
570 return KIWAY_PLAYER::ShowModal( aSymbol, aParent );
571}
572
573
575{
577
578 if( !IsModal() )
579 {
580 Destroy();
581 }
582 else if( !IsDismissed() )
583 {
584 // only dismiss modal frame if not already dismissed.
585 DismissModal( false );
586
587 // Modal frame will be destroyed by the calling function.
588 }
589}
590
591
592void SYMBOL_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
593{
594 if( m_auimgr.GetManagedWindow() )
595 m_auimgr.Update();
596
597 SizeEv.Skip();
598}
599
600
601void SYMBOL_VIEWER_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent )
602{
603 LIB_SYMBOL* symbol = GetSelectedSymbol();
604
605 int unit_count = 1;
606
607 if( symbol )
608 unit_count = std::max( symbol->GetUnitCount(), 1 );
609
610 m_unitChoice->Enable( unit_count > 1 );
611
612 if( unit_count > 1 )
613 {
614 // rebuild the unit list if it is not suitable (after a new selection for instance)
615 if( unit_count != (int)m_unitChoice->GetCount() )
616 {
617 m_unitChoice->Clear();
618
619 for( int ii = 0; ii < unit_count; ii++ )
620 {
621 wxString unit = symbol->GetUnitDisplayName( ii + 1 );
622 m_unitChoice->Append( unit );
623 }
624
625 }
626
627 if( m_unitChoice->GetSelection() != std::max( 0, m_unit - 1 ) )
628 m_unitChoice->SetSelection( std::max( 0, m_unit - 1 ) );
629 }
630 else if( m_unitChoice->GetCount() )
631 {
632 m_unitChoice->Clear();
633 }
634}
635
636
638{
639 if( !m_libList )
640 return false;
641
642 m_libList->Clear();
643
644 COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
646 SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
647 std::vector<wxString> libs = libTable->GetLogicalLibs();
648 std::vector<wxString> pinnedMatches;
649 std::vector<wxString> otherMatches;
650
651 auto doAddLib =
652 [&]( const wxString& aLib )
653 {
654 if( alg::contains( project.m_PinnedSymbolLibs, aLib )
656 {
657 pinnedMatches.push_back( aLib );
658 }
659 else
660 {
661 otherMatches.push_back( aLib );
662 }
663 };
664
665 auto process =
666 [&]( const wxString& aLib )
667 {
668 // Remove not allowed libs, if the allowed lib list is not empty
669 if( m_allowedLibs.GetCount() )
670 {
671 if( m_allowedLibs.Index( aLib ) == wxNOT_FOUND )
672 return;
673 }
674
675 // Remove libs which have no power symbols, if this filter is activated
676 if( m_listPowerOnly )
677 {
678 wxArrayString aliasNames;
679
680 Prj().SchSymbolLibTable()->EnumerateSymbolLib( aLib, aliasNames, true );
681
682 if( aliasNames.IsEmpty() )
683 return;
684 }
685
686 SYMBOL_LIB_TABLE_ROW* row = libTable->FindRow( aLib );
687
688 if( !row->GetIsVisible() )
689 return;
690
691 if( row->SupportsSubLibraries() )
692 {
693 std::vector<wxString> subLibraries;
694 row->GetSubLibraryNames( subLibraries );
695
696 for( const wxString& lib : subLibraries )
697 {
698 wxString suffix = lib.IsEmpty() ? wxString( wxT( "" ) )
699 : wxString::Format( wxT( " - %s" ), lib );
700 wxString name = wxString::Format( wxT( "%s%s" ), aLib, suffix );
701
702 doAddLib( name );
703 }
704 }
705 else
706 {
707 doAddLib( aLib );
708 }
709 };
710
711 if( m_libFilter->GetValue().IsEmpty() )
712 {
713 for( const wxString& lib : libs )
714 process( lib );
715 }
716 else
717 {
718 wxStringTokenizer tokenizer( m_libFilter->GetValue() );
719
720 while( tokenizer.HasMoreTokens() )
721 {
722 const wxString term = tokenizer.GetNextToken().Lower();
723 EDA_COMBINED_MATCHER matcher( term, CTX_LIBITEM );
724
725 for( const wxString& lib : libs )
726 {
727 if( matcher.Find( lib.Lower() ) )
728 process( lib );
729 }
730 }
731 }
732
733 if( libs.empty() )
734 return true;
735
736 for( const wxString& name : pinnedMatches )
738
739 for( const wxString& name : otherMatches )
740 m_libList->Append( UnescapeString( name ) );
741
742 // Search for a previous selection:
744
745 if( index != wxNOT_FOUND )
746 {
747 m_libList->SetSelection( index, true );
748 }
749 else
750 {
751 // If not found, clear current library selection because it can be deleted after a
752 // config change.
754 ? m_libList->GetBaseString( 0 ) : wxString( wxT( "" ) ) );
755 m_currentSymbol.SetLibItemName( wxEmptyString );
756 m_unit = 1;
758 }
759
760 bool cmp_changed = ReCreateSymbolList();
762 GetCanvas()->Refresh();
763
764 return cmp_changed;
765}
766
767
769{
770 if( m_symbolList == nullptr )
771 return false;
772
773 m_symbolList->Clear();
774
775 wxString libName = m_currentSymbol.GetUniStringLibNickname();
776
777 if( libName.IsEmpty() )
778 return false;
779
780 std::vector<LIB_SYMBOL*> symbols;
781 SYMBOL_LIB_TABLE_ROW* row = Prj().SchSymbolLibTable()->FindRow( libName );
782
783 try
784 {
785 if( row )
786 Prj().SchSymbolLibTable()->LoadSymbolLib( symbols, libName, m_listPowerOnly );
787 }
788 catch( const IO_ERROR& ) {} // ignore, it is handled below
789
790 std::set<wxString> excludes;
791
792 if( !m_symbolFilter->GetValue().IsEmpty() )
793 {
794 wxStringTokenizer tokenizer( m_symbolFilter->GetValue() );
795
796 while( tokenizer.HasMoreTokens() )
797 {
798 const wxString filterTerm = tokenizer.GetNextToken().Lower();
799 EDA_COMBINED_MATCHER matcher( filterTerm, CTX_LIBITEM );
800
801 for( LIB_SYMBOL* symbol : symbols )
802 {
803 std::vector<SEARCH_TERM> searchTerms = symbol->GetSearchTerms();
804 int matched = matcher.ScoreTerms( searchTerms );
805
806 if( filterTerm.IsNumber() && wxAtoi( filterTerm ) == (int)symbol->GetPinCount() )
807 matched++;
808
809 if( !matched )
810 excludes.insert( symbol->GetName() );
811 }
812 }
813 }
814
815 wxString subLib = m_currentSymbol.GetSubLibraryName();
816
817 for( const LIB_SYMBOL* symbol : symbols )
818 {
819 if( row && row->SupportsSubLibraries()
820 && !subLib.IsSameAs( symbol->GetLibId().GetSubLibraryName() ) )
821 {
822 continue;
823 }
824
825 if( !excludes.count( symbol->GetName() ) )
826 m_symbolList->Append( UnescapeString( symbol->GetName() ) );
827 }
828
829 if( m_symbolList->IsEmpty() )
830 {
831 SetSelectedSymbol( wxEmptyString );
833 m_unit = 1;
834 return true;
835 }
836
838 bool changed = false;
839
840 if( index == wxNOT_FOUND )
841 {
842 // Select the first library entry when the previous entry name does not exist in
843 // the current library.
845 m_unit = 1;
846 index = -1;
847 changed = true;
848 SetSelectedSymbol( wxEmptyString );
849 }
850
851 m_symbolList->SetSelection( index, true );
852
853 return changed;
854}
855
856
857void SYMBOL_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event )
858{
859 int ii = m_libList->GetSelection();
860
861 if( ii < 0 )
862 return;
863
864 m_selection_changed = true;
865
866 wxString selection = EscapeString( m_libList->GetBaseString( ii ), CTX_LIBID );
867
868 if( !Prj().SchSymbolLibTable()->FindRow( selection )
869 && selection.Find( '-' ) != wxNOT_FOUND )
870 {
871 // Probably a sub-library
872 wxString sublib;
873 selection = selection.BeforeLast( '-', &sublib ).Trim();
874 sublib.Trim( false );
875 SetSelectedLibrary( selection, sublib );
876 }
877 else
878 {
879 SetSelectedLibrary( selection );
880 }
881}
882
883
884void SYMBOL_VIEWER_FRAME::SetSelectedLibrary( const wxString& aLibraryName,
885 const wxString& aSubLibName )
886{
887 if( m_currentSymbol.GetUniStringLibNickname() == aLibraryName &&
888 wxString( m_currentSymbol.GetSubLibraryName() ) == aSubLibName )
889 return;
890
891 m_currentSymbol.SetLibNickname( aLibraryName );
892 m_currentSymbol.SetSubLibraryName( aSubLibName );
894 GetCanvas()->Refresh();
896
897 // Ensure the corresponding line in m_libList is selected
898 // (which is not necessary the case if SetSelectedLibrary is called
899 // by another caller than ClickOnLibList.
901
902 // The m_libList has now the focus, in order to be able to use arrow keys
903 // to navigate inside the list.
904 // the gal canvas must not steal the focus to allow navigation
905 GetCanvas()->SetStealsFocus( false );
906 m_libList->SetFocus();
907}
908
909
910void SYMBOL_VIEWER_FRAME::ClickOnSymbolList( wxCommandEvent& event )
911{
912 int ii = m_symbolList->GetSelection();
913
914 if( ii < 0 )
915 return;
916
917 m_selection_changed = true;
918
920
921 // The m_symbolList has now the focus, in order to be able to use arrow keys
922 // to navigate inside the list.
923 // the gal canvas must not steal the focus to allow navigation
924 GetCanvas()->SetStealsFocus( false );
925 m_symbolList->SetFocus();
926}
927
928
929void SYMBOL_VIEWER_FRAME::SetSelectedSymbol( const wxString& aSymbolName )
930{
931 if( m_currentSymbol.GetUniStringLibItemName() != aSymbolName )
932 {
933 m_currentSymbol.SetLibItemName( aSymbolName );
934
935 // Ensure the corresponding line in m_symbolList is selected
936 // (which is not necessarily the case if SetSelectedSymbol is called
937 // by another caller than ClickOnSymbolList.
938 m_symbolList->SetStringSelection( UnescapeString( aSymbolName ), true );
940
942 {
943 m_unit = 1;
945 m_selection_changed = false;
946 }
947
949 }
950}
951
952
953void SYMBOL_VIEWER_FRAME::DClickOnSymbolList( wxCommandEvent& event )
954{
956}
957
958
960{
961 auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
962
964
965 // Grid shape, etc.
966 GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
967
968 m_libListWidth = cfg->m_LibViewPanel.lib_list_width;
969 m_symbolListWidth = cfg->m_LibViewPanel.cmp_list_width;
970
971 GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_LibViewPanel.show_pin_electrical_type;
972 GetRenderSettings()->m_ShowPinNumbers = cfg->m_LibViewPanel.show_pin_numbers;
973
974 // Set parameters to a reasonable value.
975 int maxWidth = cfg->m_LibViewPanel.window.state.size_x - 80;
976
977 if( m_libListWidth + m_symbolListWidth > maxWidth )
978 {
981 }
982}
983
984
986{
987 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
988
990
992 m_libListWidth = m_libList->GetSize().x;
993
994 m_symbolListWidth = m_symbolList->GetSize().x;
995
998
999 if( KIGFX::SCH_RENDER_SETTINGS* renderSettings = GetRenderSettings() )
1000 {
1001 cfg->m_LibViewPanel.show_pin_electrical_type = renderSettings->m_ShowPinsElectricalType;
1002 cfg->m_LibViewPanel.show_pin_numbers = renderSettings->m_ShowPinNumbers;
1003 }
1004}
1005
1006
1008{
1009 auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
1010 wxASSERT( cfg );
1011 return &cfg->m_LibViewPanel.window;
1012}
1013
1014
1015void SYMBOL_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1016{
1017 SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1018
1019 auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
1020 GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
1021
1023 GetCanvas()->GetGAL()->DrawGrid();
1025
1026 if( aEnvVarsChanged )
1028}
1029
1030
1031void SYMBOL_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
1032{
1033 if( event.GetActive() )
1034 {
1035 bool changed = m_libList ? ReCreateLibList() : false;
1036
1037 if (changed)
1038 m_selection_changed = true;
1039
1041
1043 }
1044
1045 event.Skip(); // required under wxMAC
1046}
1047
1048
1049void SYMBOL_VIEWER_FRAME::CloseLibraryViewer( wxCommandEvent& event )
1050{
1051 Close();
1052}
1053
1054
1056{
1057 m_listPowerOnly = false;
1058 m_allowedLibs.Clear();
1059
1060 if( aFilter )
1061 {
1062 m_allowedLibs = aFilter->GetAllowedLibList();
1064 }
1065
1067}
1068
1069
1070const BOX2I SYMBOL_VIEWER_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1071{
1072 LIB_SYMBOL* symbol = GetSelectedSymbol();
1073
1074 if( !symbol )
1075 {
1076 return BOX2I( VECTOR2I( -200, -200 ), VECTOR2I( 400, 400 ) );
1077 }
1078 else
1079 {
1080 std::shared_ptr<LIB_SYMBOL> tmp = symbol->IsAlias() ? symbol->GetParent().lock()
1081 : symbol->SharedPtr();
1082
1083 wxCHECK( tmp, BOX2I( VECTOR2I( -200, -200 ), VECTOR2I( 400, 400 ) ) );
1084
1085 return tmp->GetUnitBoundingBox( m_unit, m_convert );
1086 }
1087}
1088
1089
1091{
1092 if( m_symbolList->GetSelection() >= 0 )
1093 {
1095 }
1096 else
1097 {
1098 DismissModal( false );
1099 }
1100
1101 Close( true );
1102}
1103
1104
1105void SYMBOL_VIEWER_FRAME::OnSelectSymbol( wxCommandEvent& aEvent )
1106{
1107 std::unique_lock<std::mutex> dialogLock( DIALOG_CHOOSE_SYMBOL::g_Mutex, std::defer_lock );
1108
1109 // One CHOOSE_SYMBOL dialog at a time. User probably can't handle more anyway.
1110 if( !dialogLock.try_lock() )
1111 return;
1112
1113 // Container doing search-as-you-type.
1114 SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
1115 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> dataPtr
1116 = SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs );
1117 SYMBOL_TREE_MODEL_ADAPTER* modelAdapter
1118 = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( dataPtr.get() );
1119
1120 if( !modelAdapter->AddLibraries( libs->GetLogicalLibs(), this ) )
1121 {
1122 // loading cancelled by user
1123 return;
1124 }
1125
1126 LIB_SYMBOL* current = GetSelectedSymbol();
1127 LIB_ID id;
1128 int unit = 0;
1129
1130 if( current )
1131 {
1132 id = current->GetLibId();
1133 modelAdapter->SetPreselectNode( id, unit );
1134 }
1135
1136 wxString dialogTitle;
1137 dialogTitle.Printf( _( "Choose Symbol (%d items loaded)" ), modelAdapter->GetItemCount() );
1138
1139 DIALOG_CHOOSE_SYMBOL dlg( this, dialogTitle, dataPtr, m_convert, false, false, false );
1140
1141 if( dlg.ShowQuasiModal() == wxID_CANCEL )
1142 return;
1143
1144 // Save any changes to column widths, etc.
1145 modelAdapter->SaveSettings();
1146
1147 id = dlg.GetSelectedLibId( &unit );
1148
1149 if( !id.IsValid() )
1150 return;
1151
1152 SetSelectedLibrary( id.GetLibNickname(), id.GetSubLibraryName() );
1153 SetSelectedSymbol( id.GetLibItemName() );
1154 SetUnitAndConvert( unit, 1 );
1155}
1156
1157
1158void SYMBOL_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
1159{
1161
1162 // Required to avoid interaction with SetHint()
1163 // See documentation for wxTextEntry::SetHint
1164 aEvent.Skip();
1165}
1166
1167
1168void SYMBOL_VIEWER_FRAME::OnSymFilter( wxCommandEvent& aEvent )
1169{
1171
1172 // Required to avoid interaction with SetHint()
1173 // See documentation for wxTextEntry::SetHint
1174 aEvent.Skip();
1175}
1176
1177
1178void SYMBOL_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
1179{
1180 if( aEvent.GetKeyCode() == WXK_UP )
1181 {
1182 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
1183 {
1184 int prev = m_libList->GetSelection() - 1;
1185
1186 if( prev >= 0 )
1187 {
1188 m_libList->SetSelection( prev );
1189 m_libList->EnsureVisible( prev );
1190
1191 wxCommandEvent dummy;
1193 }
1194 }
1195 else
1196 {
1197 wxCommandEvent dummy;
1199 }
1200 }
1201 else if( aEvent.GetKeyCode() == WXK_DOWN )
1202 {
1203 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
1204 {
1205 int next = m_libList->GetSelection() + 1;
1206
1207 if( next < (int)m_libList->GetCount() )
1208 {
1209 m_libList->SetSelection( next );
1210 m_libList->EnsureVisible( next );
1211
1212 wxCommandEvent dummy;
1214 }
1215 }
1216 else
1217 {
1218 wxCommandEvent dummy;
1220 }
1221 }
1222 else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
1223 {
1224 if( !aEvent.ShiftDown() )
1225 m_symbolFilter->SetFocus();
1226 else
1227 aEvent.Skip();
1228 }
1229 else if( aEvent.GetKeyCode() == WXK_TAB && m_symbolFilter->HasFocus() )
1230 {
1231 if( aEvent.ShiftDown() )
1232 m_libFilter->SetFocus();
1233 else
1234 aEvent.Skip();
1235 }
1236 else if( ( aEvent.GetKeyCode() == WXK_RETURN || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER )
1237 && m_symbolList->GetSelection() >= 0 )
1238 {
1239 wxCommandEvent dummy;
1241 }
1242 else
1243 {
1244 aEvent.Skip();
1245 }
1246}
1247
1248
1249void SYMBOL_VIEWER_FRAME::onSelectNextSymbol( wxCommandEvent& aEvent )
1250{
1251 wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_SYM_LIST );
1252 int ii = m_symbolList->GetSelection();
1253
1254 // Select the next symbol or stop at the end of the list.
1255 if( ii != wxNOT_FOUND || ii != (int) m_symbolList->GetCount() - 1 )
1256 ii += 1;
1257
1258 m_symbolList->SetSelection( ii );
1259 ProcessEvent( evt );
1260}
1261
1262
1264{
1265 wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_SYM_LIST );
1266 int ii = m_symbolList->GetSelection();
1267
1268 // Select the previous symbol or stop at the beginning of list.
1269 if( ii != wxNOT_FOUND && ii != 0 )
1270 ii -= 1;
1271
1272 m_symbolList->SetSelection( ii );
1273 ProcessEvent( evt );
1274}
1275
1276
1277void SYMBOL_VIEWER_FRAME::onSelectSymbolUnit( wxCommandEvent& aEvent )
1278{
1279 int ii = m_unitChoice->GetSelection();
1280
1281 if( ii < 0 )
1282 return;
1283
1284 m_unit = ii + 1;
1285
1287}
1288
1289
1291{
1292 wxString libName = m_currentSymbol.GetUniStringLibNickname();
1293
1294 if( m_libList && !m_libList->IsEmpty() && !libName.IsEmpty() )
1295 {
1296 const SYMBOL_LIB_TABLE_ROW* row =
1297 Prj().SchSymbolLibTable()->FindRow( libName, true );
1298
1299 wxString title = row ? row->GetFullURI( true ) : _( "[no library selected]" );
1300
1301 title += wxT( " \u2014 " ) + _( "Symbol Library Browser" );
1302 SetTitle( title );
1303 }
1304}
1305
1306
1308{
1309 return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1310}
1311
1312
1314{
1315 switch( mail.Command() )
1316 {
1317 case MAIL_RELOAD_LIB:
1318 {
1320 break;
1321 }
1322 default:;
1323 }
1324}
const char * name
Definition: DXF_plotter.cpp:56
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
static PGM_BASE * process
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:106
BOX2< VECTOR2I > BOX2I
Definition: box2.h:847
static TOOL_ACTION toggleGrid
Definition: actions.h:144
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
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.
int ScoreTerms(std::vector< SEARCH_TERM > &aWeightedTerms)
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
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:136
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:135
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:178
static TOOL_ACTION showPinNumbers
Definition: ee_actions.h:245
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:150
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:244
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:314
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:351
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
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition: kiway_express.h:49
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:279
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:196
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
@ BASE
Definition: lib_item.h:70
@ DEMORGAN
Definition: lib_item.h:70
Define a library symbol object.
Definition: lib_symbol.h:99
wxString GetUnitDisplayName(int aUnit) override
Return the user-defined display name for aUnit for symbols with units.
Definition: lib_symbol.cpp:534
bool IsAlias() const
Definition: lib_symbol.h:193
LIB_ID GetLibId() const override
Definition: lib_symbol.h:146
LIB_SYMBOL_SPTR SharedPtr() const
Definition: lib_symbol.h:110
int GetUnitCount() const override
For items with units, return the number of units.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:588
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)
std::unique_ptr< LIB_SYMBOL > m_previewItem
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 KiwayMailIn(KIWAY_EXPRESS &mail) override
Receive KIWAY_EXPRESS messages from other players.
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:308
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#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
PROJECT & Prj()
Definition: kicad.cpp:554
KIWAY Kiway
@ LAYER_SCHEMATIC_GRID_AXES
Definition: layer_ids.h:379
@ MAIL_RELOAD_LIB
Definition: mail_type.h:55
Message panel definition file.
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
CITER next(CITER it)
Definition: ptree.cpp:126
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
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 LIB_VIEW_NAME_MODAL
#define LIB_VIEW_NAME
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588