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 The 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>
30#include <eeschema_id.h>
31#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>
42#include <sch_view.h>
43#include <sch_painter.h>
44#include <symbol_lib_table.h>
46#include <pgm_base.h>
48#include <project_sch.h>
50#include <symbol_async_loader.h>
51#include <tool/action_toolbar.h>
52#include <tool/common_control.h>
53#include <tool/common_tools.h>
55#include <tool/selection.h>
57#include <tool/tool_manager.h>
58#include <tool/zoom_tool.h>
59#include <tools/sch_actions.h>
62#include <view/view_controls.h>
63#include <wx/srchctrl.h>
64#include <wx/log.h>
65#include <wx/choice.h>
67
68#include <default_values.h>
69#include <string_utils.h>
70#include "eda_pattern_match.h"
71
72// Save previous symbol library viewer state.
74
78
79
80BEGIN_EVENT_TABLE( SYMBOL_VIEWER_FRAME, SCH_BASE_FRAME )
81 // Window events
84
85 // Toolbar events
89
90 // listbox events
96
97 // Menu (and/or hotkey) events
98 EVT_MENU( wxID_CLOSE, SYMBOL_VIEWER_FRAME::CloseLibraryViewer )
99
101
102END_EVENT_TABLE()
103
104
105SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
106 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_VIEWER, _( "Symbol Library Browser" ),
107 wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
109 m_unitChoice( nullptr ),
110 m_libList( nullptr ),
111 m_symbolList( nullptr )
112{
113 m_aboutTitle = _HKI( "KiCad Symbol Library Browser" );
114
115 // Force the frame name used in config. the lib viewer frame has a name
116 // depending on aFrameType (needed to identify the frame by wxWidgets),
117 // but only one configuration is preferable.
118 m_configName = LIB_VIEW_FRAME_NAME;
119
120 // Give an icon
121 wxIcon icon;
122 icon.CopyFromBitmap( KiBitmap( BITMAPS::library_browser ) );
123 SetIcon( icon );
124
125 m_libListWidth = 200;
126 m_symbolListWidth = 300;
127 m_listPowerOnly = false;
128
129 SetScreen( new SCH_SCREEN );
130 GetScreen()->m_Center = true; // Axis origin centered on screen.
131 LoadSettings( config() );
132
133 // Ensure axis are always drawn (initial default display was not drawn)
134 KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions();
135 gal_opts.m_axesEnabled = true;
136 gal_opts.m_gridMinSpacing = 10.0;
137 gal_opts.NotifyChanged();
138
139 GetRenderSettings()->LoadColors( GetColorSettings() );
140 GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
141
142 GetRenderSettings()->SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS );
143
144 setupTools();
145 setupUIConditions();
146
147 m_toolbarSettings = GetToolbarSettings<SYMBOL_VIEWER_TOOLBAR_SETTINGS>( "symbol_viewer-toolbars" );
148 configureToolbars();
149 RecreateToolbars();
150
151 ReCreateMenuBar();
152
153 wxPanel* libPanel = new wxPanel( this );
154 wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
155
156 m_libFilter = new wxSearchCtrl( libPanel, ID_LIBVIEW_LIB_FILTER, wxEmptyString,
157 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
158 m_libFilter->SetDescriptiveText( _( "Filter" ) );
159 libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
160
161 m_libList = new WX_LISTBOX( libPanel, ID_LIBVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
162 0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
163 libSizer->Add( m_libList, 1, wxEXPAND, 5 );
164
165 libPanel->SetSizer( libSizer );
166 libPanel->Fit();
167
168 wxPanel* symbolPanel = new wxPanel( this );
169 wxSizer* symbolSizer = new wxBoxSizer( wxVERTICAL );
170
171 m_symbolFilter = new wxSearchCtrl( symbolPanel, ID_LIBVIEW_SYM_FILTER, wxEmptyString,
172 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
173 m_symbolFilter->SetDescriptiveText( _( "Filter" ) );
174 m_symbolFilter->SetToolTip(
175 _( "Filter on symbol name, keywords, description and pin count.\n"
176 "Search terms are separated by spaces. All search terms must match.\n"
177 "A term which is a number will also match against the pin count." ) );
178 symbolSizer->Add( m_symbolFilter, 0, wxEXPAND, 5 );
179
180#ifdef __WXGTK__
181 // wxSearchCtrl vertical height is not calculated correctly on some GTK setups
182 // See https://gitlab.com/kicad/code/kicad/-/issues/9019
183 m_libFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
184 m_symbolFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
185#endif
186
187 m_symbolList = new WX_LISTBOX( symbolPanel, ID_LIBVIEW_SYM_LIST, wxDefaultPosition,
188 wxDefaultSize, 0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
189 symbolSizer->Add( m_symbolList, 1, wxEXPAND, 5 );
190
191 symbolPanel->SetSizer( symbolSizer );
192 symbolPanel->Fit();
193
194 // Preload libraries
195 loadAllLibraries();
196 ReCreateLibList();
197
198 m_selection_changed = false;
199
200 DisplayLibInfos();
201
202 m_auimgr.SetManagedWindow( this );
203
204 CreateInfoBar();
205
206 // Manage main toolbar
207 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( "TopMainToolbar" ).Top().Layer(6) );
208 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) .Bottom().Layer(6) );
209
210 m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
211 .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
212 m_auimgr.AddPane( symbolPanel, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1)
213 .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
214
215 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
216
217 m_auimgr.Update();
218
219 if( m_libListWidth > 0 )
220 SetAuiPaneSize( m_auimgr, m_auimgr.GetPane( "Libraries" ), m_libListWidth, -1 );
221
222 if( m_symbolListWidth > 0 )
223 SetAuiPaneSize( m_auimgr, m_auimgr.GetPane( "Symbols" ), m_symbolListWidth, -1 );
224
225 FinishAUIInitialization();
226
227 Raise();
228 Show( true );
229
230 SyncView();
231 GetCanvas()->SetCanFocus( false );
232
233 setupUnits( config() );
234
235 // Set the working/draw area size to display a symbol to a reasonable value:
236 // A 450mm x 450mm with a origin at the area center looks like a large working area
237 double max_size_x = schIUScale.mmToIU( 450 );
238 double max_size_y = schIUScale.mmToIU( 450 );
239 BOX2D bbox;
240 bbox.SetOrigin( -max_size_x / 2, -max_size_y / 2 );
241 bbox.SetSize( max_size_x, max_size_y );
242 GetCanvas()->GetView()->SetBoundary( bbox );
243 GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
244
245 // If a symbol was previously selected in m_symbolList from a previous run, show it
246 wxString symbName = m_symbolList->GetStringSelection();
247
248 if( !symbName.IsEmpty() )
249 {
250 SetSelectedSymbol( symbName );
251 updatePreviewSymbol();
252 }
253}
254
255
257{
258 // Shutdown all running tools
259 if( m_toolManager )
261
262 if( m_previewItem )
263 {
264 GetCanvas()->GetView()->Remove( m_previewItem.get() );
265 m_previewItem = nullptr;
266 }
267}
268
269
271{
272 // TODO: deduplicate with SYMBOL_TREE_MODEL_ADAPTER::AddLibraries
273 std::vector<wxString> libraryNames = PROJECT_SCH::SchSymbolLibTable( &Prj() )->GetLogicalLibs();
274 std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter = nullptr;
275
276 if( m_show_progress )
277 {
278 progressReporter = std::make_unique<WX_PROGRESS_REPORTER>( this, _( "Load Symbol Libraries" ),
279 libraryNames.size(), PR_CAN_ABORT );
280 }
281
282 // Disable KIID generation: not needed for library parts; sometimes very slow
283 KIID::CreateNilUuids( true );
284
285 std::unordered_map<wxString, std::vector<LIB_SYMBOL*>> loadedSymbols;
286
287 SYMBOL_ASYNC_LOADER loader( libraryNames, PROJECT_SCH::SchSymbolLibTable( &Prj() ), false,
288 nullptr, progressReporter.get() );
289
290 LOCALE_IO toggle;
291
292 loader.Start();
293
294 while( !loader.Done() )
295 {
296 if( progressReporter && !progressReporter->KeepRefreshing() )
297 break;
298
299 wxMilliSleep( 33 );
300 }
301
302 loader.Join();
303
304 KIID::CreateNilUuids( false );
305
306 if( !loader.GetErrors().IsEmpty() )
307 {
308 HTML_MESSAGE_BOX dlg( this, _( "Load Error" ) );
309
310 dlg.MessageSet( _( "Errors loading symbols:" ) );
311
312 wxString msg = loader.GetErrors();
313 msg.Replace( "\n", "<BR>" );
314
315 dlg.AddHTML_Text( msg );
316 dlg.ShowModal();
317 }
318}
319
320
322{
323 // Create the manager and dispatcher & route draw panel events to the dispatcher
326 GetCanvas()->GetViewControls(), config(), this );
327 m_actions = new SCH_ACTIONS();
329
330 // Register tools
334 m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL ); // manage show datasheet
335 m_toolManager->RegisterTool( new SCH_SELECTION_TOOL ); // manage context menu
336 m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL ); // manage render settings
337
339
340 // Run the selection tool, it is supposed to be always active
341 // It also manages the mouse right click to show the context menu
342 m_toolManager->InvokeTool( "common.InteractiveSelection" );
343
345}
346
347
349{
351
353 EDITOR_CONDITIONS cond( this );
354
355 wxASSERT( mgr );
356
357#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
358#define CHECK( x ) ACTION_CONDITIONS().Check( x )
359
361
362 auto electricalTypesShownCondition =
363 [this]( const SELECTION& aSel )
364 {
366 };
367
368 auto pinNumbersShownCondition =
369 [this]( const SELECTION& )
370 {
372 };
373
374 auto demorganCond =
375 [this]( const SELECTION& )
376 {
377 LIB_SYMBOL* symbol = GetSelectedSymbol();
378 return symbol && symbol->HasAlternateBodyStyle();
379 };
380
381 auto demorganStandardCond =
382 []( const SELECTION& )
383 {
384 return m_bodyStyle == BODY_STYLE::BASE;
385 };
386
387 auto demorganAlternateCond =
388 []( const SELECTION& )
389 {
390 return m_bodyStyle == BODY_STYLE::DEMORGAN;
391 };
392
393 auto haveDatasheetCond =
394 [this]( const SELECTION& )
395 {
396 LIB_SYMBOL* symbol = GetSelectedSymbol();
397 return symbol && !symbol->GetDatasheetField().GetText().IsEmpty();
398 };
399
400 mgr->SetConditions( ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
401 mgr->SetConditions( SCH_ACTIONS::showElectricalTypes, CHECK( electricalTypesShownCondition ) );
402 mgr->SetConditions( SCH_ACTIONS::showPinNumbers, CHECK( pinNumbersShownCondition ) );
403
404 mgr->SetConditions( SCH_ACTIONS::showDeMorganStandard, ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) );
405 mgr->SetConditions( SCH_ACTIONS::showDeMorganAlternate, ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) );
406
407#undef CHECK
408#undef ENABLE
409}
410
411
412void SYMBOL_VIEWER_FRAME::SetUnitAndBodyStyle( int aUnit, int aBodyStyle )
413{
414 m_unit = aUnit > 0 ? aUnit : 1;
415 m_bodyStyle = aBodyStyle > 0 ? aBodyStyle : BODY_STYLE::BASE;
416 m_selection_changed = false;
417
419}
420
421
423{
424 LIB_SYMBOL* symbol = nullptr;
425
428
429 return symbol;
430}
431
432
434{
435 LIB_SYMBOL* symbol = GetSelectedSymbol();
436 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
437
438 if( m_previewItem )
439 {
440 view->Remove( m_previewItem.get() );
441 m_previewItem = nullptr;
442 }
443
445
446 if( symbol )
447 {
450
451 m_previewItem = symbol->Flatten();
452 view->Add( m_previewItem.get() );
453
454 wxString parentName;
455 std::shared_ptr<LIB_SYMBOL> parent = symbol->GetParent().lock();
456
457 if( parent )
458 parentName = parent->GetName();
459
460 AppendMsgPanel( _( "Name" ), UnescapeString( m_previewItem->GetName() ) );
461 AppendMsgPanel( _( "Parent" ), UnescapeString( parentName ) );
462 AppendMsgPanel( _( "Description" ), m_previewItem->GetDescription() );
463 AppendMsgPanel( _( "Keywords" ), m_previewItem->GetKeyWords() );
464 }
465
467 GetCanvas()->Refresh();
468}
469
470
472{
474
475 delete m_toolManager;
476 m_toolManager = nullptr;
477
478 Destroy();
479}
480
481
482void SYMBOL_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
483{
484 if( m_auimgr.GetManagedWindow() )
485 m_auimgr.Update();
486
487 SizeEv.Skip();
488}
489
490
491void SYMBOL_VIEWER_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent )
492{
493 LIB_SYMBOL* symbol = GetSelectedSymbol();
494
495 int unit_count = 1;
496
497 if( symbol )
498 unit_count = std::max( symbol->GetUnitCount(), 1 );
499
500 m_unitChoice->Enable( unit_count > 1 );
501
502 if( unit_count > 1 )
503 {
504 // rebuild the unit list if it is not suitable (after a new selection for instance)
505 if( unit_count != (int)m_unitChoice->GetCount() )
506 {
507 m_unitChoice->Clear();
508
509 for( int ii = 0; ii < unit_count; ii++ )
510 {
511 wxString unit = symbol->GetUnitDisplayName( ii + 1, true );
512 m_unitChoice->Append( unit );
513 }
514
515 }
516
517 if( m_unitChoice->GetSelection() != std::max( 0, m_unit - 1 ) )
518 m_unitChoice->SetSelection( std::max( 0, m_unit - 1 ) );
519 }
520 else if( m_unitChoice->GetCount() )
521 {
522 m_unitChoice->Clear();
523 }
524}
525
526
528{
529 if( !m_libList )
530 return false;
531
532 m_libList->Clear();
533
537 std::vector<wxString> libs = libTable->GetLogicalLibs();
538 std::vector<wxString> pinnedMatches;
539 std::vector<wxString> otherMatches;
540
541 auto doAddLib =
542 [&]( const wxString& aLib )
543 {
544 if( alg::contains( project.m_PinnedSymbolLibs, aLib )
546 {
547 pinnedMatches.push_back( aLib );
548 }
549 else
550 {
551 otherMatches.push_back( aLib );
552 }
553 };
554
555 auto process =
556 [&]( const wxString& aLib )
557 {
558 // Remove not allowed libs, if the allowed lib list is not empty
559 if( m_allowedLibs.GetCount() )
560 {
561 if( m_allowedLibs.Index( aLib ) == wxNOT_FOUND )
562 return;
563 }
564
565 // Remove libs which have no power symbols, if this filter is activated
566 if( m_listPowerOnly )
567 {
568 wxArrayString aliasNames;
569
571 aliasNames,
572 true );
573
574 if( aliasNames.IsEmpty() )
575 return;
576 }
577
578 SYMBOL_LIB_TABLE_ROW* row = libTable->FindRow( aLib );
579
580 wxCHECK( row, /* void */ );
581
582 if( !row->GetIsVisible() )
583 return;
584
585 if( row->SupportsSubLibraries() )
586 {
587 std::vector<wxString> subLibraries;
588 row->GetSubLibraryNames( subLibraries );
589
590 for( const wxString& lib : subLibraries )
591 {
592 wxString suffix = lib.IsEmpty() ? wxString( wxT( "" ) )
593 : wxString::Format( wxT( " - %s" ), lib );
594 wxString name = wxString::Format( wxT( "%s%s" ), aLib, suffix );
595
596 doAddLib( name );
597 }
598 }
599 else
600 {
601 doAddLib( aLib );
602 }
603 };
604
605 if( m_libFilter->GetValue().IsEmpty() )
606 {
607 for( const wxString& lib : libs )
608 process( lib );
609 }
610 else
611 {
612 wxStringTokenizer tokenizer( m_libFilter->GetValue() );
613
614 while( tokenizer.HasMoreTokens() )
615 {
616 const wxString term = tokenizer.GetNextToken().Lower();
617 EDA_COMBINED_MATCHER matcher( term, CTX_LIBITEM );
618
619 for( const wxString& lib : libs )
620 {
621 if( matcher.Find( lib.Lower() ) )
622 process( lib );
623 }
624 }
625 }
626
627 if( libs.empty() )
628 return true;
629
630 for( const wxString& name : pinnedMatches )
632
633 for( const wxString& name : otherMatches )
634 m_libList->Append( UnescapeString( name ) );
635
636 // Search for a previous selection:
637 int index =
639
640 if( index != wxNOT_FOUND )
641 {
642 m_libList->SetSelection( index, true );
643 }
644 else
645 {
646 // If not found, clear current library selection because it can be deleted after a
647 // config change.
649 ? m_libList->GetBaseString( 0 ) : wxString( wxT( "" ) ) );
650 m_currentSymbol.SetLibItemName( wxEmptyString );
651 m_unit = 1;
652 m_bodyStyle = BODY_STYLE::BASE;
653 }
654
655 bool cmp_changed = ReCreateSymbolList();
657 GetCanvas()->Refresh();
658
659 return cmp_changed;
660}
661
662
664{
665 if( m_symbolList == nullptr )
666 return false;
667
668 m_symbolList->Clear();
669
670 wxString libName = m_currentSymbol.GetUniStringLibNickname();
671
672 if( libName.IsEmpty() )
673 return false;
674
675 std::vector<LIB_SYMBOL*> symbols;
677
678 try
679 {
680 if( row )
681 PROJECT_SCH::SchSymbolLibTable( &Prj() )->LoadSymbolLib( symbols, libName,
683 }
684 catch( const IO_ERROR& ) {} // ignore, it is handled below
685
686 std::set<wxString> excludes;
687
688 if( !m_symbolFilter->GetValue().IsEmpty() )
689 {
690 wxStringTokenizer tokenizer( m_symbolFilter->GetValue() );
691
692 while( tokenizer.HasMoreTokens() )
693 {
694 const wxString filterTerm = tokenizer.GetNextToken().Lower();
695 EDA_COMBINED_MATCHER matcher( filterTerm, CTX_LIBITEM );
696
697 for( LIB_SYMBOL* symbol : symbols )
698 {
699 std::vector<SEARCH_TERM> searchTerms = symbol->GetSearchTerms();
700 int matched = matcher.ScoreTerms( searchTerms );
701
702 if( filterTerm.IsNumber() && wxAtoi( filterTerm ) == (int)symbol->GetPinCount() )
703 matched++;
704
705 if( !matched )
706 excludes.insert( symbol->GetName() );
707 }
708 }
709 }
710
711 wxString subLib = m_currentSymbol.GetSubLibraryName();
712
713 for( const LIB_SYMBOL* symbol : symbols )
714 {
715 if( row && row->SupportsSubLibraries()
716 && !subLib.IsSameAs( symbol->GetLibId().GetSubLibraryName() ) )
717 {
718 continue;
719 }
720
721 if( !excludes.count( symbol->GetName() ) )
722 m_symbolList->Append( UnescapeString( symbol->GetName() ) );
723 }
724
725 if( m_symbolList->IsEmpty() )
726 {
727 SetSelectedSymbol( wxEmptyString );
728 m_bodyStyle = BODY_STYLE::BASE;
729 m_unit = 1;
730 return true;
731 }
732
733 int index =
735 bool changed = false;
736
737 if( index == wxNOT_FOUND )
738 {
739 // Select the first library entry when the previous entry name does not exist in
740 // the current library.
741 m_bodyStyle = BODY_STYLE::BASE;
742 m_unit = 1;
743 index = -1;
744 changed = true;
745 SetSelectedSymbol( wxEmptyString );
746 }
747
748 m_symbolList->SetSelection( index, true );
749
750 return changed;
751}
752
753
754void SYMBOL_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event )
755{
756 int ii = m_libList->GetSelection();
757
758 if( ii < 0 )
759 return;
760
761 m_selection_changed = true;
762
763 wxString selection = EscapeString( m_libList->GetBaseString( ii ), CTX_LIBID );
764
765 if( !PROJECT_SCH::SchSymbolLibTable( &Prj() )->FindRow( selection )
766 && selection.Find( '-' ) != wxNOT_FOUND )
767 {
768 // Probably a sub-library
769 wxString sublib;
770 selection = selection.BeforeLast( '-', &sublib ).Trim();
771 sublib.Trim( false );
772 SetSelectedLibrary( selection, sublib );
773 }
774 else
775 {
776 SetSelectedLibrary( selection );
777 }
778}
779
780
781void SYMBOL_VIEWER_FRAME::SetSelectedLibrary( const wxString& aLibraryName,
782 const wxString& aSubLibName )
783{
784 if( m_currentSymbol.GetUniStringLibNickname() == aLibraryName
785 && wxString( m_currentSymbol.GetSubLibraryName().wx_str() ) == aSubLibName )
786 return;
787
788 m_currentSymbol.SetLibNickname( aLibraryName );
789 m_currentSymbol.SetSubLibraryName( aSubLibName );
791 GetCanvas()->Refresh();
793
794 // Ensure the corresponding line in m_libList is selected
795 // (which is not necessary the case if SetSelectedLibrary is called
796 // by another caller than ClickOnLibList.
798
799 // The m_libList has now the focus, in order to be able to use arrow keys
800 // to navigate inside the list.
801 // the gal canvas must not steal the focus to allow navigation
802 GetCanvas()->SetStealsFocus( false );
803 m_libList->SetFocus();
804}
805
806
807void SYMBOL_VIEWER_FRAME::ClickOnSymbolList( wxCommandEvent& event )
808{
809 int ii = m_symbolList->GetSelection();
810
811 if( ii < 0 )
812 return;
813
814 m_selection_changed = true;
815
817
818 // The m_symbolList has now the focus, in order to be able to use arrow keys
819 // to navigate inside the list.
820 // the gal canvas must not steal the focus to allow navigation
821 GetCanvas()->SetStealsFocus( false );
822 m_symbolList->SetFocus();
823}
824
825
826void SYMBOL_VIEWER_FRAME::SetSelectedSymbol( const wxString& aSymbolName )
827{
828 if( m_currentSymbol.GetUniStringLibItemName() != aSymbolName )
829 {
830 m_currentSymbol.SetLibItemName( aSymbolName );
831
832 // Ensure the corresponding line in m_symbolList is selected
833 // (which is not necessarily the case if SetSelectedSymbol is called
834 // by another caller than ClickOnSymbolList.
835 m_symbolList->SetStringSelection( UnescapeString( aSymbolName ), true );
837
839 {
840 m_unit = 1;
841 m_bodyStyle = BODY_STYLE::BASE;
842 m_selection_changed = false;
843 }
844
846 }
847}
848
849
850void SYMBOL_VIEWER_FRAME::DClickOnSymbolList( wxCommandEvent& event )
851{
853}
854
855
857{
858 SCH_BASE_FRAME::LoadSettings( GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) );
859
860 if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
861 {
862 // Grid shape, etc.
863 GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
864
865 m_libListWidth = cfg->m_LibViewPanel.lib_list_width;
866 m_symbolListWidth = cfg->m_LibViewPanel.cmp_list_width;
867
868 GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_LibViewPanel.show_pin_electrical_type;
869 GetRenderSettings()->m_ShowPinNumbers = cfg->m_LibViewPanel.show_pin_numbers;
870
871 // Set parameters to a reasonable value.
872 int maxWidth = cfg->m_LibViewPanel.window.state.size_x - 80;
873
874 if( m_libListWidth + m_symbolListWidth > maxWidth )
875 {
878 }
879 }
880}
881
882
884{
885 SCH_BASE_FRAME::SaveSettings( GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) );
886
888 m_libListWidth = m_libList->GetSize().x;
889
890 m_symbolListWidth = m_symbolList->GetSize().x;
891
892 if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
893 {
894 cfg->m_LibViewPanel.lib_list_width = m_libListWidth;
895 cfg->m_LibViewPanel.cmp_list_width = m_symbolListWidth;
896
897 if( SCH_RENDER_SETTINGS* renderSettings = GetRenderSettings() )
898 {
899 cfg->m_LibViewPanel.show_pin_electrical_type = renderSettings->m_ShowPinsElectricalType;
900 cfg->m_LibViewPanel.show_pin_numbers = renderSettings->m_ShowPinNumbers;
901 }
902 }
903}
904
905
907{
908 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg ) )
909 return &cfg->m_LibViewPanel.window;
910
911 wxFAIL_MSG( wxT( "SYMBOL_VIEWER not running with EESCHEMA_SETTINGS" ) );
912 return &aCfg->m_Window; // non-null fail-safe
913}
914
915
917{
919
920 if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
921 GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
922
924 GetCanvas()->GetGAL()->DrawGrid();
926
927 if( aFlags && ENVVARS_CHANGED )
929}
930
931
932void SYMBOL_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
933{
934 if( event.GetActive() )
935 {
936 bool changed = m_libList ? ReCreateLibList() : false;
937
938 if (changed)
939 m_selection_changed = true;
940
942
944 }
945
946 event.Skip(); // required under wxMAC
947}
948
949
950void SYMBOL_VIEWER_FRAME::CloseLibraryViewer( wxCommandEvent& event )
951{
952 Close();
953}
954
955
956const BOX2I SYMBOL_VIEWER_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
957{
958 LIB_SYMBOL* symbol = GetSelectedSymbol();
959
960 if( !symbol )
961 {
962 return BOX2I( VECTOR2I( -200, -200 ), VECTOR2I( 400, 400 ) );
963 }
964 else
965 {
966 std::shared_ptr<LIB_SYMBOL> tmp = symbol->IsDerived() ? symbol->GetParent().lock()
967 : symbol->SharedPtr();
968
969 wxCHECK( tmp, BOX2I( VECTOR2I( -200, -200 ), VECTOR2I( 400, 400 ) ) );
970
971 return tmp->GetUnitBoundingBox( m_unit, m_bodyStyle );
972 }
973}
974
975
976void SYMBOL_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
977{
979
980 // Required to avoid interaction with SetHint()
981 // See documentation for wxTextEntry::SetHint
982 aEvent.Skip();
983}
984
985
986void SYMBOL_VIEWER_FRAME::OnSymFilter( wxCommandEvent& aEvent )
987{
989
990 // Required to avoid interaction with SetHint()
991 // See documentation for wxTextEntry::SetHint
992 aEvent.Skip();
993}
994
995
996void SYMBOL_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
997{
998 if( aEvent.GetKeyCode() == WXK_UP )
999 {
1000 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
1001 {
1002 int prev = m_libList->GetSelection() - 1;
1003
1004 if( prev >= 0 )
1005 {
1006 m_libList->SetSelection( prev );
1007 m_libList->EnsureVisible( prev );
1008
1009 wxCommandEvent dummy;
1011 }
1012 }
1013 else
1014 {
1015 wxCommandEvent dummy;
1017 }
1018 }
1019 else if( aEvent.GetKeyCode() == WXK_DOWN )
1020 {
1021 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
1022 {
1023 int next = m_libList->GetSelection() + 1;
1024
1025 if( next < (int)m_libList->GetCount() )
1026 {
1027 m_libList->SetSelection( next );
1028 m_libList->EnsureVisible( next );
1029
1030 wxCommandEvent dummy;
1032 }
1033 }
1034 else
1035 {
1036 wxCommandEvent dummy;
1038 }
1039 }
1040 else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
1041 {
1042 if( !aEvent.ShiftDown() )
1043 m_symbolFilter->SetFocus();
1044 else
1045 aEvent.Skip();
1046 }
1047 else if( aEvent.GetKeyCode() == WXK_TAB && m_symbolFilter->HasFocus() )
1048 {
1049 if( aEvent.ShiftDown() )
1050 m_libFilter->SetFocus();
1051 else
1052 aEvent.Skip();
1053 }
1054 else if( ( aEvent.GetKeyCode() == WXK_RETURN || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER )
1055 && m_symbolList->GetSelection() >= 0 )
1056 {
1057 wxCommandEvent dummy;
1059 }
1060 else
1061 {
1062 aEvent.Skip();
1063 }
1064}
1065
1066
1067void SYMBOL_VIEWER_FRAME::onSelectNextSymbol( wxCommandEvent& aEvent )
1068{
1069 wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_SYM_LIST );
1070 int ii = m_symbolList->GetSelection();
1071
1072 // Select the next symbol or stop at the end of the list.
1073 if( ii != wxNOT_FOUND && ii < (int) ( m_symbolList->GetCount() - 1 ) )
1074 ii += 1;
1075
1076 m_symbolList->SetSelection( ii );
1077 ProcessEvent( evt );
1078}
1079
1080
1082{
1083 wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_SYM_LIST );
1084 int ii = m_symbolList->GetSelection();
1085
1086 // Select the previous symbol or stop at the beginning of list.
1087 if( ii != wxNOT_FOUND && ii != 0 )
1088 ii -= 1;
1089
1090 m_symbolList->SetSelection( ii );
1091 ProcessEvent( evt );
1092}
1093
1094
1095void SYMBOL_VIEWER_FRAME::onSelectSymbolUnit( wxCommandEvent& aEvent )
1096{
1097 int ii = m_unitChoice->GetSelection();
1098
1099 if( ii < 0 )
1100 return;
1101
1102 m_unit = ii + 1;
1103
1105}
1106
1107
1109{
1110 wxString libName = m_currentSymbol.GetUniStringLibNickname();
1111
1112 if( m_libList && !m_libList->IsEmpty() && !libName.IsEmpty() )
1113 {
1114 const SYMBOL_LIB_TABLE_ROW* row =
1115 PROJECT_SCH::SchSymbolLibTable( &Prj() )->FindRow( libName, true );
1116
1117 wxString title = row ? row->GetFullURI( true ) : _( "[no library selected]" );
1118
1119 title += wxT( " \u2014 " ) + _( "Symbol Library Browser" );
1120 SetTitle( title );
1121 }
1122}
1123
1124
1126{
1127 return m_toolManager->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
1128}
1129
1130
1132{
1133
1134 switch( mail.Command() )
1135 {
1136 case MAIL_RELOAD_LIB:
1137 {
1139 break;
1140 }
1142 {
1144 LIB_SYMBOL* symbol = GetSelectedSymbol();
1145
1146 wxCHECK2( tbl && symbol, break );
1147
1148 const SYMBOL_LIB_TABLE_ROW* row = tbl->FindRow( symbol->GetLibId().GetLibNickname() );
1149
1150 if( !row )
1151 return;
1152
1153 wxString libfullname = row->GetFullURI( true );
1154
1155 wxString lib( mail.GetPayload() );
1156 wxLogTrace( "KICAD_LIB_WATCH", "Received refresh symbol request for %s, current symbols "
1157 "is %s", lib, libfullname );
1158
1159 if( lib == libfullname )
1160 {
1161 wxLogTrace( "KICAD_LIB_WATCH", "Refreshing symbol %s", symbol->GetName() );
1164 }
1165
1166 break;
1167 }
1168 default:;
1169 }
1170}
const char * name
Definition: DXF_plotter.cpp:62
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:114
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:104
@ library_browser
BOX2< VECTOR2I > BOX2I
Definition: box2.h:922
static TOOL_ACTION toggleGrid
Definition: actions.h:195
static TOOL_ACTION showDatasheet
Definition: actions.h:264
static TOOL_ACTION zoomFitScreen
Definition: actions.h:141
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:108
WINDOW_SETTINGS m_Window
Definition: app_settings.h:233
constexpr void SetOrigin(const Vec &pos)
Definition: box2.h:237
constexpr void SetSize(const SizeVec &size)
Definition: box2.h:248
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
int ShowModal() override
virtual APP_SETTINGS_BASE * config() const
Return 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.
wxAuiManager m_auimgr
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
int ScoreTerms(std::vector< SEARCH_TERM > &aWeightedTerms)
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
Look in all existing matchers, return the earliest match of any of the existing.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
COLOR_SETTINGS * m_colorSettings
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.
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:97
Class that groups generic conditions for editor states.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
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:77
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.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:298
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:341
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1561
static void CreateNilUuids(bool aNil=true)
A performance optimization which disables/enables the generation of pseudo-random UUIDs.
Definition: kiid.cpp:288
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:40
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition: kiway_express.h:58
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition: kiway_express.h:50
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:286
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 SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition: lib_id.cpp:111
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:172
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
Definition: lib_id.cpp:100
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
const wxString GetUniStringLibNickname() const
Definition: lib_id.h:88
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:275
Define a library symbol object.
Definition: lib_symbol.h:85
const LIB_ID & GetLibId() const override
Definition: lib_symbol.h:155
SCH_FIELD & GetDatasheetField()
Return reference to the datasheet field.
Definition: lib_symbol.h:346
bool IsDerived() const
Definition: lib_symbol.h:207
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
wxString GetName() const override
Definition: lib_symbol.h:149
LIB_SYMBOL_SPTR SharedPtr() const
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared.
Definition: lib_symbol.h:96
int GetUnitCount() const override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:344
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:118
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
Definition: lib_symbol.cpp:287
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
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
static const wxString GetPinningSymbol()
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:565
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:68
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:204
Gather all the actions that are shared by tools.
Definition: sch_actions.h:40
static TOOL_ACTION showDeMorganAlternate
Definition: sch_actions.h:132
static TOOL_ACTION showElectricalTypes
Definition: sch_actions.h:251
static TOOL_ACTION showPinNumbers
Definition: sch_actions.h:252
static TOOL_ACTION showDeMorganStandard
Definition: sch_actions.h:131
static TOOL_ACTION addSymbolToSchematic
Definition: sch_actions.h:180
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_RENDER_SETTINGS * GetRenderSettings()
void doCloseWindow() override
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 CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
const wxString & GetErrors() const
void Start()
Spin up threads to load all the libraries in m_nicknames.
bool Join()
Finalize the threads and combines the output into the target output map.
Handle actions for the various symbol editor and viewers.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_IO object i...
void GetSubLibraryNames(std::vector< wxString > &aNames) const
bool SupportsSubLibraries() const
void LoadSymbolLib(std::vector< LIB_SYMBOL * > &aAliasList, const wxString &aNickname, bool aPowerSymbolsOnly=false)
void EnumerateSymbolLib(const wxString &aNickname, wxArrayString &aAliasNames, bool aPowerSymbolsOnly=false)
Return a list of symbol alias names contained within the library given by aNickname.
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
Symbol library viewer main window.
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)
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 SetSelectedSymbol(const wxString &aSymbolName)
Set the selected symbol.
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Receive KIWAY_EXPRESS messages from other players.
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
Return bounding box of document with option to not include some items.
void SetUnitAndBodyStyle(int aUnit, int aBodyStyle)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
wxSearchCtrl * m_symbolFilter
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
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.
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.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:171
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:173
ACTIONS * m_actions
Definition: tools_holder.h:172
Master controller class:
Definition: tool_manager.h:62
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
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:306
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()
Initialize all registered tools.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
wxString wx_str() const
Definition: utf8.cpp:45
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
bool SetStringSelection(const wxString &s) override
Definition: wx_listbox.cpp:43
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)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define LIB_VIEW_FRAME_NAME
Abstract pattern-matching tool and implementations.
@ CTX_LIBITEM
@ ID_LIBVIEW_SELECT_UNIT_NUMBER
Definition: eeschema_id.h:65
@ ID_LIBVIEW_SYM_LIST
Definition: eeschema_id.h:69
@ ID_LIBVIEW_NEXT
Definition: eeschema_id.h:63
@ ID_LIBVIEW_LIB_FILTER
Definition: eeschema_id.h:66
@ ID_LIBVIEW_LIB_LIST
Definition: eeschema_id.h:67
@ ID_LIBVIEW_SYM_FILTER
Definition: eeschema_id.h:68
@ ID_LIBVIEW_PREVIOUS
Definition: eeschema_id.h:64
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
PROJECT & Prj()
Definition: kicad.cpp:608
@ LAYER_SCHEMATIC_GRID_AXES
Definition: layer_ids.h:477
@ MAIL_REFRESH_SYMBOL
Definition: mail_type.h:59
@ MAIL_RELOAD_LIB
Definition: mail_type.h:57
Message panel definition file.
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:59
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:100
static PGM_BASE * process
Definition: pgm_base.cpp:899
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:902
see class PGM_BASE
CITER next(CITER it)
Definition: ptree.cpp:124
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
KIWAY Kiway(KFCTL_STANDALONE)
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:54
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:77
constexpr int mmToIU(double mm) const
Definition: base_units.h:92
Store the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:90
#define ENVVARS_CHANGED
Definition: tools_holder.h:152
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.
#define PR_CAN_ABORT