KiCad PCB EDA Suite
symbol_edit_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) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2004-2022 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>
27#include <wx/hyperlink.h>
28#include <base_screen.h>
29#include <symbol_library.h>
30#include <confirm.h>
31#include <core/kicad_algo.h>
32#include <eeschema_id.h>
33#include <eeschema_settings.h>
34#include <env_paths.h>
35#include <kiface_base.h>
36#include <kiplatform/app.h>
37#include <kiway_express.h>
38#include <symbol_edit_frame.h>
40#include <lib_text.h>
42#include <paths.h>
43#include <pgm_base.h>
44#include <sch_painter.h>
45#include <sch_view.h>
47#include <symbol_lib_table.h>
48#include <tool/action_manager.h>
49#include <tool/action_toolbar.h>
50#include <tool/common_control.h>
51#include <tool/common_tools.h>
53#include <tool/picker_tool.h>
54#include <tool/selection.h>
56#include <tool/tool_manager.h>
57#include <tool/zoom_tool.h>
58#include <tools/ee_actions.h>
68#include <widgets/infobar.h>
69#include <widgets/lib_tree.h>
73#include <panel_sym_lib_table.h>
74#include <string_utils.h>
75
76
78
79
80BEGIN_EVENT_TABLE( SYMBOL_EDIT_FRAME, EDA_DRAW_FRAME )
82
84
85 // menubar commands
86 EVT_MENU( wxID_EXIT, SYMBOL_EDIT_FRAME::OnExitKiCad )
87 EVT_MENU( wxID_CLOSE, SYMBOL_EDIT_FRAME::CloseWindow )
89
90 // Update user interface elements.
92
93 // Drop files event
94 EVT_DROP_FILES( SYMBOL_EDIT_FRAME::OnDropFiles )
95
96END_EVENT_TABLE()
97
98
99SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
100 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_SYMBOL_EDITOR, _( "Library Editor" ),
101 wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
103 m_unitSelectBox( nullptr ),
104 m_isSymbolFromSchematic( false )
105{
106 SetShowDeMorgan( false );
107 m_SyncPinEdit = false;
108
109 m_symbol = nullptr;
110 m_treePane = nullptr;
111 m_libMgr = nullptr;
112 m_unit = 1;
113 m_convert = 1;
114 m_aboutTitle = _( "KiCad Symbol Editor" );
115
116 wxIcon icon;
117 wxIconBundle icon_bundle;
118
119 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit ) );
120 icon_bundle.AddIcon( icon );
121 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit_32 ) );
122 icon_bundle.AddIcon( icon );
123 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit_16 ) );
124 icon_bundle.AddIcon( icon );
125
126 SetIcons( icon_bundle );
127
128 m_settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
129 LoadSettings( m_settings );
130
131 m_libMgr = new LIB_SYMBOL_LIBRARY_MANAGER( *this );
132 bool loadingCancelled = false;
133
134 {
135 // Preload libraries before using SyncLibraries the first time, as the preload is
136 // multi-threaded
137 WX_PROGRESS_REPORTER reporter( this, _( "Loading Symbol Libraries" ),
138 m_libMgr->GetLibraryCount(), true );
139 m_libMgr->Preload( reporter );
140
141 loadingCancelled = reporter.IsCancelled();
142 wxSafeYield();
143 }
144
145 SyncLibraries( false, loadingCancelled );
146 m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
147
148 resolveCanvasType();
149 SwitchCanvas( m_canvasType );
150
151 // Ensure axis are always drawn
152 KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions();
153 gal_opts.m_axesEnabled = true;
154
155 m_dummyScreen = new SCH_SCREEN();
156 SetScreen( m_dummyScreen );
157 GetScreen()->m_Center = true;
158
159 GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
160
161 GetRenderSettings()->LoadColors( GetColorSettings() );
162 GetRenderSettings()->m_IsSymbolEditor = true;
163 GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
164
165 setupTools();
166 setupUIConditions();
167
168 ReCreateMenuBar();
169 ReCreateHToolbar();
170 ReCreateVToolbar();
171 ReCreateOptToolbar();
172
173 updateTitle();
174 UpdateSymbolMsgPanelInfo();
175 RebuildSymbolUnitsList();
176
177 m_auimgr.SetManagedWindow( this );
178
179 CreateInfoBar();
180
181 // Rows; layers 4 - 6
182 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
183 .Top().Layer( 6 ) );
184
185 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
186 .Bottom().Layer( 6 ) );
187
188 // Columns; layers 1 - 3
189 m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "SymbolTree" )
190 .Left().Layer( 3 )
191 .Caption( _( "Libraries" ) )
192 .MinSize( 250, -1 ).BestSize( 250, -1 ) );
193 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
194 .Left().Layer( 2 ) );
195
196 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
197 .Right().Layer( 2 ) );
198
199 // Center
200 m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" )
201 .CentrePane() );
202
203 FinishAUIInitialization();
204
205 if( m_settings->m_LibWidth > 0 )
206 {
207 wxAuiPaneInfo& treePane = m_auimgr.GetPane( "SymbolTree" );
208
209 // wxAUI hack: force width by setting MinSize() and then Fixed()
210 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
211 treePane.MinSize( m_settings->m_LibWidth, -1 );
212 treePane.Fixed();
213 m_auimgr.Update();
214
215 // now make it resizable again
216 treePane.Resizable();
217 m_auimgr.Update();
218
219 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
220 // back to minimum.
221 treePane.MinSize( 250, -1 );
222 }
223
224 Raise();
225 Show( true );
226
227 SyncView();
228 GetCanvas()->GetView()->UseDrawPriority( true );
229 GetCanvas()->GetGAL()->SetAxesEnabled( true );
230
231 setupUnits( m_settings );
232
233 // Set the working/draw area size to display a symbol to a reasonable value:
234 // A 600mm x 600mm with a origin at the area center looks like a large working area
235 double max_size_x = schIUScale.mmToIU( 600 );
236 double max_size_y = schIUScale.mmToIU( 600 );
237 BOX2D bbox;
238 bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
239 bbox.SetSize( max_size_x, max_size_y );
240 GetCanvas()->GetView()->SetBoundary( bbox );
241
242 m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
243
244 m_acceptedExts.emplace( KiCadSymbolLibFileExtension, &ACTIONS::ddAddLibrary );
245 DragAcceptFiles( true );
246
247 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Library changes are unsaved" ) );
248
249 // Catch unhandled accelerator command characters that were no handled by the library tree
250 // panel.
251 Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
252 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
253
254 // Ensure the window is on top
255 Raise();
256
257 if( loadingCancelled )
258 ShowInfoBarWarning( _( "Symbol library loading was cancelled by user." ) );
259}
260
261
263{
264 // Shutdown all running tools
265 if( m_toolManager )
267
269 {
270 delete m_symbol;
271 m_symbol = nullptr;
272
273 SCH_SCREEN* screen = GetScreen();
274 delete screen;
276 }
277
278 // current screen is destroyed in EDA_DRAW_FRAME
280
281 auto libedit = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
282 Pgm().GetSettingsManager().Save( libedit );
283
284 delete m_libMgr;
285}
286
287
289{
290 wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" );
291
293
295}
296
297
299{
300 wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" );
301
303
305
307 m_settings->m_LibWidth = m_treePane->GetSize().x;
308}
309
310
312{
313 return static_cast<APP_SETTINGS_BASE*>( GetSettings() );
314}
315
316
318{
319 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
320
321 if( GetSettings()->m_UseEeschemaColorSettings )
323 else
324 return mgr.GetColorSettings( GetSettings()->m_ColorTheme );
325}
326
327
329{
330 // Create the manager and dispatcher & route draw panel events to the dispatcher
333 GetCanvas()->GetViewControls(), GetSettings(), this );
334 m_actions = new EE_ACTIONS();
336
337 // Register tools
351
352 // Run the selection tool, it is supposed to be always active
353 m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
354
356}
357
358
360{
362
364 EDITOR_CONDITIONS cond( this );
365
366 wxASSERT( mgr );
367
368#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
369#define CHECK( x ) ACTION_CONDITIONS().Check( x )
370
371 auto haveSymbolCond =
372 [this]( const SELECTION& )
373 {
374 return m_symbol;
375 };
376
377 auto isEditableCond =
378 [this]( const SELECTION& )
379 {
380 // Only root symbols from the new s-expression libraries or the schematic
381 // are editable.
382 return IsSymbolEditable() && !IsSymbolAlias();
383 };
384
385 auto symbolModifiedCondition =
386 [this]( const SELECTION& sel )
387 {
390 };
391
392 auto libSelectedCondition =
393 [this]( const SELECTION& sel )
394 {
395 return !GetTargetLibId().GetLibNickname().empty();
396 };
397
398 auto canEditProperties =
399 [this]( const SELECTION& sel )
400 {
402 };
403
404 auto saveSymbolAsCondition =
405 [this]( const SELECTION& aSel )
406 {
407 return getTargetSymbol() != nullptr;
408 };
409
412 mgr->SetConditions( EE_ACTIONS::saveLibraryAs, ENABLE( libSelectedCondition ) );
413 mgr->SetConditions( EE_ACTIONS::saveSymbolAs, ENABLE( saveSymbolAsCondition ) );
416
417 mgr->SetConditions( ACTIONS::undo, ENABLE( haveSymbolCond && cond.UndoAvailable() ) );
418 mgr->SetConditions( ACTIONS::redo, ENABLE( haveSymbolCond && cond.RedoAvailable() ) );
419 mgr->SetConditions( ACTIONS::revert, ENABLE( symbolModifiedCondition ) );
420
426
427 mgr->SetConditions( ACTIONS::cut, ENABLE( isEditableCond ) );
428 mgr->SetConditions( ACTIONS::copy, ENABLE( haveSymbolCond ) );
430 mgr->SetConditions( ACTIONS::doDelete, ENABLE( isEditableCond ) );
431 mgr->SetConditions( ACTIONS::duplicate, ENABLE( isEditableCond ) );
432 mgr->SetConditions( ACTIONS::selectAll, ENABLE( haveSymbolCond ) );
433
434 mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( isEditableCond ) );
435 mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( isEditableCond ) );
436 mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( isEditableCond ) );
437 mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( isEditableCond ) );
438
441
442 auto pinTypeCond =
443 [this]( const SELECTION& )
444 {
446 };
447
448 auto showCompTreeCond =
449 [this]( const SELECTION& )
450 {
451 return IsSymbolTreeShown();
452 };
453
456 mgr->SetConditions( EE_ACTIONS::showSymbolTree, CHECK( showCompTreeCond ) );
457
458 auto demorganCond =
459 [this]( const SELECTION& )
460 {
461 return GetShowDeMorgan();
462 };
463
464 auto demorganStandardCond =
465 [this]( const SELECTION& )
466 {
467 return m_convert == LIB_ITEM::LIB_CONVERT::BASE;
468 };
469
470 auto demorganAlternateCond =
471 [this]( const SELECTION& )
472 {
473 return m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN;
474 };
475
476 auto multiUnitModeCond =
477 [this]( const SELECTION& )
478 {
479 return m_symbol && m_symbol->IsMulti() && !m_symbol->UnitsLocked();
480 };
481
482 auto hasMultipleUnitsCond =
483 [this]( const SELECTION& )
484 {
485 return m_symbol && m_symbol->IsMulti();
486 };
487
488 auto syncedPinsModeCond =
489 [this]( const SELECTION& )
490 {
491 return m_SyncPinEdit;
492 };
493
494 auto haveDatasheetCond =
495 [this]( const SELECTION& )
496 {
497 return m_symbol && !m_symbol->GetDatasheetField().GetText().IsEmpty();
498 };
499
500 mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
501 mgr->SetConditions( EE_ACTIONS::symbolProperties, ENABLE( canEditProperties && haveSymbolCond ) );
502 mgr->SetConditions( EE_ACTIONS::runERC, ENABLE( haveSymbolCond ) );
503 mgr->SetConditions( EE_ACTIONS::pinTable, ENABLE( isEditableCond && haveSymbolCond ) );
504
506 ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) );
508 ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) );
510 ACTION_CONDITIONS().Enable( multiUnitModeCond ).Check( syncedPinsModeCond ) );
512 ACTION_CONDITIONS().Enable( isEditableCond && hasMultipleUnitsCond ) );
513
514// Only enable a tool if the symbol is edtable
515#define EDIT_TOOL( tool ) ACTION_CONDITIONS().Enable( isEditableCond ).Check( cond.CurrentTool( tool ) )
516
526
527#undef CHECK
528#undef ENABLE
529#undef EDIT_TOOL
530}
531
532
534{
535 if( IsContentModified() )
536 {
537 SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
538 wxString msg = _( "Save changes to '%s' before closing?" );
539
540 switch( UnsavedChangesDialog( this, wxString::Format( msg, m_reference ), nullptr ) )
541 {
542 case wxID_YES:
543 if( schframe && GetCurSymbol() ) // Should be always the case
545
546 break;
547
548 case wxID_NO:
549 break;
550
551 default:
552 case wxID_CANCEL:
553 return false;
554 }
555 }
556
557 if( doClose )
558 {
559 SetCurSymbol( nullptr, false );
560 updateTitle();
561 }
562
563 return true;
564}
565
566
567bool SYMBOL_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
568{
569 // Shutdown blocks must be determined and vetoed as early as possible
571 && aEvent.GetId() == wxEVT_QUERY_END_SESSION
572 && IsContentModified() )
573 {
574 return false;
575 }
576
578 return false;
579
580 if( !saveAllLibraries( true ) )
581 return false;
582
583 return true;
584}
585
586
588{
589 Destroy();
590}
591
592
594{
595 if( !m_unitSelectBox )
596 return;
597
598 if( m_unitSelectBox->GetCount() != 0 )
599 m_unitSelectBox->Clear();
600
601 if( !m_symbol || m_symbol->GetUnitCount() <= 1 )
602 {
603 m_unit = 1;
604 m_unitSelectBox->Append( wxEmptyString );
605 }
606 else
607 {
608 for( int i = 0; i < m_symbol->GetUnitCount(); i++ )
609 {
610 wxString unitDisplayName = m_symbol->GetUnitDisplayName( i + 1 );
611 m_unitSelectBox->Append( unitDisplayName );
612 }
613 }
614
615 // Ensure the selected unit is compatible with the number of units of the current symbol:
617 m_unit = 1;
618
619 m_unitSelectBox->SetSelection(( m_unit > 0 ) ? m_unit - 1 : 0 );
620}
621
622
623void SYMBOL_EDIT_FRAME::OnToggleSymbolTree( wxCommandEvent& event )
624{
625 wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
626 treePane.Show( !IsSymbolTreeShown() );
627 m_auimgr.Update();
628}
629
630
632{
633 return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
634}
635
636
638{
639 m_treePane->Freeze();
640 m_libMgr->GetAdapter()->Freeze();
641}
642
643
645{
646 m_libMgr->GetAdapter()->Thaw();
647 m_treePane->Thaw();
648}
649
650
651void SYMBOL_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
652{
653 Kiway().OnKiCadExit();
654}
655
656
657void SYMBOL_EDIT_FRAME::OnUpdateUnitNumber( wxUpdateUIEvent& event )
658{
659 event.Enable( m_symbol && m_symbol->GetUnitCount() > 1 );
660}
661
662
663void SYMBOL_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event )
664{
665 int i = event.GetSelection();
666
667 if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) )
668 return;
669
672
673 m_unit = i + 1;
674
676 RebuildView();
678}
679
680
682{
683 if( m_symbol )
684 {
686
687 if( row && row->GetType() == SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_LEGACY ) )
688 return true;
689 }
690
691 return false;
692}
693
694
696{
697 wxString libNickname = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB );
698
699 if( !libNickname.empty() )
700 {
701 if( !Prj().SchSymbolLibTable()->HasLibrary( libNickname ) )
702 {
703 Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
704 libNickname = wxEmptyString;
705 }
706 }
707
708 return libNickname;
709}
710
711
712wxString SYMBOL_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
713{
714 wxString old = GetCurLib();
715
716 if( aLibNickname.empty() || !Prj().SchSymbolLibTable()->HasLibrary( aLibNickname ) )
717 Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
718 else
720
721 return old;
722}
723
724
725void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom )
726{
728 GetCanvas()->GetView()->Clear();
729 delete m_symbol;
730
731 m_symbol = aSymbol;
732
733 // select the current symbol in the tree widget
736 else
738
739 wxString symbolName = m_symbol ? m_symbol->GetName() : wxString();
740
741 // retain in case this wxFrame is re-opened later on the same PROJECT
743
744 // Ensure synchronized pin edit can be enabled only symbols with interchangeable units
745 m_SyncPinEdit = aSymbol && aSymbol->IsRoot() && aSymbol->IsMulti() && !aSymbol->UnitsLocked();
746
748
756
757 if( aUpdateZoom )
759
760 GetCanvas()->Refresh();
761
762 WX_INFOBAR* infobar = GetInfoBar();
763
765 {
766 wxString msg;
767 msg.Printf( _( "Editing symbol %s from schematic. Saving will update the schematic "
768 "only." ), m_reference );
769
770 infobar->RemoveAllButtons();
771 infobar->ShowMessage( msg, wxICON_INFORMATION );
772 }
773 else if( IsSymbolFromLegacyLibrary() )
774 {
775 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
776 _( "Manage symbol libraries" ),
777 wxEmptyString );
778
779 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
780 [&]( wxHyperlinkEvent& aEvent )
781 {
783 } ) );
784
785 infobar->RemoveAllButtons();
786 infobar->AddButton( button );
787 infobar->ShowMessage( _( "Symbols in legacy libraries are not editable. Use Manage "
788 "Symbol Libraries to migrate to current format." ),
789 wxICON_INFORMATION );
790 }
791 else if( IsSymbolAlias() )
792 {
793 wxString parentSymbolName = m_symbol->GetParent().lock()->GetName();
794 wxString msg;
795 wxString link;
796
797 msg.Printf( _( "Symbol %s is derived from %s. Symbol graphics will not be editable." ),
798 UnescapeString( symbolName ),
799 UnescapeString( parentSymbolName ) );
800
801 link.Printf( _( "Open %s" ), UnescapeString( parentSymbolName ) );
802
803 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, link, wxEmptyString );
804 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
805 [&]( wxHyperlinkEvent& aEvent )
806 {
807 LoadSymbolFromCurrentLib( m_symbol->GetParent().lock()->GetName(),
808 GetUnit(), GetConvert() );
809 } ) );
810
811 infobar->RemoveAllButtons();
812 infobar->AddButton( button );
813 infobar->ShowMessage( msg, wxICON_INFORMATION );
814 }
815 else
816 {
817 infobar->Dismiss();
818 }
819}
820
821
823{
824 wxASSERT( m_libMgr );
825 return *m_libMgr;
826}
827
828
830{
832
833 if( !IsSymbolFromSchematic() )
835
837
838 if( !GetTitle().StartsWith( "*" ) )
839 updateTitle();
840}
841
842
844{
846}
847
848
849wxString SYMBOL_EDIT_FRAME::AddLibraryFile( bool aCreateNew )
850{
851 // Select the target library table (global/project)
853
854 if( !libTable )
855 return wxEmptyString;
856
857 wxFileName fn = m_libMgr->GetUniqueLibraryName();
858
859 if( !LibraryFileBrowser( !aCreateNew, fn, KiCadSymbolLibFileWildcard(),
861 ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() ),
863 {
864 return wxEmptyString;
865 }
866
867 wxString libName = fn.GetName();
868
869 if( libName.IsEmpty() )
870 return wxEmptyString;
871
872 if( m_libMgr->LibraryExists( libName ) )
873 {
874 DisplayError( this, wxString::Format( _( "Library '%s' already exists." ), libName ) );
875 return wxEmptyString;
876 }
877
878 if( aCreateNew )
879 {
880 if( !m_libMgr->CreateLibrary( fn.GetFullPath(), libTable ) )
881 {
882 DisplayError( this, wxString::Format( _( "Could not create the library file '%s'.\n"
883 "Make sure you have write permissions and "
884 "try again." ),
885 fn.GetFullPath() ) );
886 return wxEmptyString;
887 }
888 }
889 else
890 {
891 if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
892 {
893 DisplayError( this, _( "Could not open the library file." ) );
894 return wxEmptyString;
895 }
896 }
897
898 bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
899 saveSymbolLibTables( globalTable, !globalTable );
900
901 std::string packet = fn.GetFullPath().ToStdString();
903
904 return fn.GetFullPath();
905}
906
907
908void SYMBOL_EDIT_FRAME::DdAddLibrary( wxString aLibFile )
909{
910 // Select the target library table (global/project)
912
913 if( !libTable )
914 return;
915
916 wxFileName fn = wxFileName( aLibFile );
917
918 wxString libName = fn.GetName();
919
920 if( libName.IsEmpty() )
921 return;
922
923 if( m_libMgr->LibraryExists( libName ) )
924 {
925 DisplayError( this, wxString::Format( _( "Library '%s' already exists." ), libName ) );
926 return;
927 }
928
929 if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
930 {
931 DisplayError( this, _( "Could not open the library file." ) );
932 return;
933 }
934
935 bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
936 saveSymbolLibTables( globalTable, !globalTable );
937
938 std::string packet = fn.GetFullPath().ToStdString();
940}
941
942
944{
945 return m_treePane->GetLibTree()->GetSelectedLibId( aUnit );
946}
947
948
950{
952}
953
954int SYMBOL_EDIT_FRAME::GetTreeLIBIDs( std::vector<LIB_ID>& aSelection ) const
955{
956 return m_treePane->GetLibTree()->GetSelectedLibIds( aSelection );
957}
958
959
961{
962 LIB_ID libId = GetTreeLIBID();
963
964 if( libId.IsValid() )
965 {
966 LIB_SYMBOL* alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
967 return alias;
968 }
969
970 return m_symbol;
971}
972
973
975{
976 LIB_ID id;
977
978 if( IsSymbolTreeShown() )
979 id = GetTreeLIBID();
980
981 if( id.GetLibNickname().empty() && m_symbol )
982 id = m_symbol->GetLibId();
983
984 return id;
985}
986
987
988std::vector<LIB_ID> SYMBOL_EDIT_FRAME::GetSelectedLibIds() const
989{
990 std::vector<LIB_ID> ids;
991 GetTreeLIBIDs( ids );
992 return ids;
993}
994
995
997{
999}
1000
1001
1003{
1004 return GetTargetLibId().GetLibNickname();
1005}
1006
1007
1008void SYMBOL_EDIT_FRAME::SyncLibraries( bool aShowProgress, bool aPreloadCancelled,
1009 const wxString& aForceRefresh )
1010{
1011 LIB_ID selected;
1012
1013 if( m_treePane )
1014 selected = m_treePane->GetLibTree()->GetSelectedLibId();
1015
1016 if( aShowProgress )
1017 {
1018 APP_PROGRESS_DIALOG progressDlg( _( "Loading Symbol Libraries" ), wxEmptyString,
1019 m_libMgr->GetAdapter()->GetLibrariesCount(), this );
1020
1021 m_libMgr->Sync( aForceRefresh,
1022 [&]( int progress, int max, const wxString& libName )
1023 {
1024 progressDlg.Update( progress, wxString::Format( _( "Loading library '%s'..." ),
1025 libName ) );
1026 } );
1027 }
1028 else if( !aPreloadCancelled )
1029 {
1030 m_libMgr->Sync( aForceRefresh,
1031 [&]( int progress, int max, const wxString& libName )
1032 {
1033 } );
1034 }
1035
1036 if( m_treePane )
1037 {
1038 wxDataViewItem found;
1039
1040 if( selected.IsValid() )
1041 {
1042 // Check if the previously selected item is still valid,
1043 // if not - it has to be unselected to prevent crash
1044 found = m_libMgr->GetAdapter()->FindItem( selected );
1045
1046 if( !found )
1048 }
1049
1050 m_treePane->GetLibTree()->Regenerate( true );
1051
1052 // Try to select the parent library, in case the symbol is not found
1053 if( !found && selected.IsValid() )
1054 {
1055 selected.SetLibItemName( "" );
1056 found = m_libMgr->GetAdapter()->FindItem( selected );
1057
1058 if( found )
1059 m_treePane->GetLibTree()->SelectLibId( selected );
1060 }
1061
1062 // If no selection, see if there's a current symbol to centre
1063 if( !selected.IsValid() && m_symbol )
1064 {
1065 LIB_ID current( GetCurLib(), m_symbol->GetName() );
1066 m_treePane->GetLibTree()->CenterLibId( current );
1067 }
1068 }
1069}
1070
1071
1073{
1074 LIB_ID target = GetTargetLibId();
1075
1076 m_treePane->GetLibTree()->Regenerate( true );
1077
1078 if( target.IsValid() )
1079 m_treePane->GetLibTree()->CenterLibId( target );
1080}
1081
1082
1084{
1086}
1087
1088
1090{
1091 m_treePane->GetLibTree()->SelectLibId( aLibID );
1092}
1093
1094
1095void SYMBOL_EDIT_FRAME::UpdateLibraryTree( const wxDataViewItem& aTreeItem, LIB_SYMBOL* aSymbol )
1096{
1097 if( aTreeItem.IsOk() ) // Can be not found in tree if the current footprint is imported
1098 // from file therefore not yet in tree.
1099 {
1100 static_cast<LIB_TREE_NODE_LIB_ID*>( aTreeItem.GetID() )->Update( aSymbol );
1102 }
1103}
1104
1105
1106bool SYMBOL_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt )
1107{
1108 if( aOriginalFile.FileExists() )
1109 {
1110 wxFileName backupFileName( aOriginalFile );
1111 backupFileName.SetExt( aBackupExt );
1112
1113 if( backupFileName.FileExists() )
1114 wxRemoveFile( backupFileName.GetFullPath() );
1115
1116 if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
1117 {
1118 DisplayError( this, wxString::Format( _( "Failed to save backup to '%s'." ),
1119 backupFileName.GetFullPath() ) );
1120 return false;
1121 }
1122 }
1123
1124 return true;
1125}
1126
1127
1129{
1130 if( m_symbol && !GetCurLib().IsEmpty() && GetScreen()->IsContentModified() )
1131 m_libMgr->UpdateSymbol( m_symbol, GetCurLib() ); // UpdateSymbol() makes a copy
1132}
1133
1134
1136{
1137 // This will return the root symbol of any alias
1139 aLibId.GetLibNickname() );
1140
1141 // Now we can compare the libId of the current symbol and the root symbol
1142 return ( symbol && m_symbol && symbol->GetLibId() == m_symbol->GetLibId() );
1143}
1144
1145
1147{
1149 SetCurLib( wxEmptyString );
1150 SetCurSymbol( nullptr, false );
1154 Refresh();
1155}
1156
1157
1158void SYMBOL_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1159{
1160 SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1161
1164
1166
1168
1169 if( m_symbol )
1171
1173
1175 GetCanvas()->Refresh();
1176
1178
1179 if( aEnvVarsChanged )
1180 SyncLibraries( true );
1181
1182 Layout();
1183 SendSizeEvent();
1184}
1185
1186
1188{
1189 // call my base class
1191
1192 // tooltips in toolbars
1194
1195 // status bar
1197
1198 if( GetRenderSettings()->m_ShowPinsElectricalType )
1199 {
1201 GetCanvas()->Refresh();
1202 }
1203
1204 updateTitle();
1205}
1206
1207
1209{
1210 SCH_BASE_FRAME::SetScreen( aScreen );
1211}
1212
1213
1215{
1223
1225 GetCanvas()->Refresh();
1226}
1227
1228
1230{
1231 SyncLibraries( true );
1232
1233 if( m_symbol )
1234 {
1236 EE_SELECTION& selection = selectionTool->GetSelection();
1237
1238 for( LIB_ITEM& item : m_symbol->GetDrawItems() )
1239 {
1240 if( !alg::contains( selection, &item ) )
1241 item.ClearSelected();
1242 else
1243 item.SetSelected();
1244 }
1245
1247 }
1248
1249 RebuildView();
1250}
1251
1252
1253const BOX2I SYMBOL_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1254{
1255 if( !m_symbol )
1256 {
1257 // Gives a reasonable drawing area size
1258 int width = schIUScale.mmToIU( 50 );
1259 int height = schIUScale.mmToIU( 30 );
1260
1261 return BOX2I( VECTOR2I( -width/2, -height/2 ),
1262 VECTOR2I( width, height ) );
1263 }
1264 else
1265 {
1266 return m_symbol->Flatten()->GetUnitBoundingBox( m_unit, m_convert );
1267 }
1268}
1269
1270
1272{
1273 const std::string& payload = mail.GetPayload();
1274
1275 switch( mail.Command() )
1276 {
1277 case MAIL_LIB_EDIT:
1278 if( !payload.empty() )
1279 {
1280 wxString libFileName( payload );
1281 wxString libNickname;
1282 wxString msg;
1283
1284 SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
1285 const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( libFileName );
1286
1287 if( !libTableRow )
1288 {
1289 msg.Printf( _( "The current configuration does not include the library '%s'.\n"
1290 "Use Manage Symbol Libraries to edit the configuration." ),
1291 libFileName );
1292 DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
1293 break;
1294 }
1295
1296 libNickname = libTableRow->GetNickName();
1297
1298 if( !libTable->HasLibrary( libNickname, true ) )
1299 {
1300 msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n"
1301 "Use Manage Symbol Libraries to edit the configuration." ),
1302 UnescapeString( libNickname ) );
1303 DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg );
1304 break;
1305 }
1306
1307 SetCurLib( libNickname );
1308
1309 if( m_treePane )
1310 {
1311 LIB_ID id( libNickname, wxEmptyString );
1315 }
1316 }
1317
1318 break;
1319
1320 default:
1321 ;
1322 }
1323}
1324
1325
1327{
1328 // switches currently used canvas ( Cairo / OpenGL):
1329 SCH_BASE_FRAME::SwitchCanvas( aCanvasType );
1330
1331 // Set options specific to symbol editor (axies are always enabled):
1332 GetCanvas()->GetGAL()->SetAxesEnabled( true );
1334}
1335
1336
1338{
1339 wxCHECK( m_libMgr, false );
1340
1341 return m_libMgr->HasModifications();
1342}
1343
1344
1346{
1347 wxCHECK( m_libMgr, false );
1348
1349 // Test if the currently edited symbol is modified
1351 return true;
1352
1353 // Test if any library has been modified
1354 for( const wxString& libName : m_libMgr->GetLibraryNames() )
1355 {
1356 if( m_libMgr->IsLibraryModified( libName ) && !m_libMgr->IsLibraryReadOnly( libName ) )
1357 return true;
1358 }
1359
1360 return false;
1361}
1362
1363
1365{
1366 if( aItemCount == 0 )
1367 return;
1368
1369 UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
1370
1371 for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
1372 {
1373 command->ClearListAndDeleteItems();
1374 delete command;
1375 }
1376
1377 list.m_CommandsList.clear();
1378}
1379
1380
1382{
1383 return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1384}
1385
1386
1388{
1389 std::unique_ptr<LIB_SYMBOL> symbol = aSymbol->GetLibSymbolRef()->Flatten();
1390 wxCHECK( symbol, /* void */ );
1391
1392 std::vector<LIB_FIELD> fullSetOfFields;
1393
1394 for( int i = 0; i < (int) aSymbol->GetFields().size(); ++i )
1395 {
1396 const SCH_FIELD& field = aSymbol->GetFields()[i];
1397 VECTOR2I pos = field.GetPosition() - aSymbol->GetPosition();
1398 LIB_FIELD libField( symbol.get(), field.GetId() );
1399
1400 if( i >= MANDATORY_FIELDS && !field.GetName( false ).IsEmpty() )
1401 libField.SetName( field.GetName( false ) );
1402
1403 libField.SetText( field.GetText() );
1404 libField.SetAttributes( field );
1405 libField.SetPosition( wxPoint( pos.x, -pos.y ) );
1406
1407 fullSetOfFields.emplace_back( std::move( libField ) );
1408 }
1409
1410 symbol->SetFields( fullSetOfFields );
1411
1412 if( m_symbol )
1413 SetCurSymbol( nullptr, false );
1414
1416 m_schematicSymbolUUID = aSymbol->m_Uuid;
1417 m_reference = symbol->GetFieldById( REFERENCE_FIELD )->GetText();
1418 m_unit = std::max( 1, aSymbol->GetUnit() );
1419 m_convert = std::max( 1, aSymbol->GetConvert() );
1420
1421 // The buffered screen for the symbol
1422 SCH_SCREEN* tmpScreen = new SCH_SCREEN();
1423
1424 SetScreen( tmpScreen );
1425 SetCurSymbol( symbol.release(), true );
1426
1429
1430 if( IsSymbolTreeShown() )
1431 {
1432 wxCommandEvent evt;
1433 OnToggleSymbolTree( evt );
1434 }
1435
1436 updateTitle();
1438 SetShowDeMorgan( GetCurSymbol()->HasConversion() );
1440 Refresh();
1441}
1442
1443
1444bool SYMBOL_EDIT_FRAME::addLibTableEntry( const wxString& aLibFile, TABLE_SCOPE aScope )
1445{
1446 wxFileName fn = aLibFile;
1447 wxFileName libTableFileName( Prj().GetProjectPath(),
1449 wxString libNickname = fn.GetName();
1450 SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
1451 const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
1452
1453 if( libTable->HasLibrary( libNickname ) )
1454 {
1455 wxString tmp;
1456 int suffix = 1;
1457
1458 while( libTable->HasLibrary( libNickname ) )
1459 {
1460 tmp.Printf( "%s%d", fn.GetName(), suffix );
1461 libNickname = tmp;
1462 suffix += 1;
1463 }
1464 }
1465
1467 row->SetNickName( libNickname );
1468
1469 wxString normalizedPath = NormalizePath( aLibFile, &envVars, Prj().GetProjectPath() );
1470
1471 if( aScope == GLOBAL_LIB_TABLE )
1472 {
1474 libTableFileName = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
1475
1476 // We cannot normalize against the current project path when saving to global table.
1477 normalizedPath = NormalizePath( aLibFile, &envVars, wxEmptyString );
1478 }
1479
1480 row->SetFullURI( normalizedPath );
1481
1482 wxCHECK( libTable->InsertRow( row ), false );
1483
1484 try
1485 {
1486 libTable->Save( libTableFileName.GetFullPath() );
1487 }
1488 catch( const IO_ERROR& ioe )
1489 {
1490 wxString msg = aScope == GLOBAL_LIB_TABLE ? _( "Error saving global library table." )
1491 : _( "Error saving project library table." );
1492
1493 wxMessageDialog dlg( this, msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1494 dlg.SetExtendedMessage( ioe.What() );
1495 dlg.ShowModal();
1496
1497 return false;
1498 }
1499
1500 return true;
1501}
1502
1503
1504bool SYMBOL_EDIT_FRAME::replaceLibTableEntry( const wxString& aLibNickname,
1505 const wxString& aLibFile )
1506{
1507 // Check the global library table first because checking the project library table
1508 // checks the global library table as well due to library chaining.
1509 bool isGlobalTable = true;
1510 wxFileName libTableFileName = SYMBOL_LIB_TABLE::GetGlobalTableFileName();;
1511 const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
1513 SYMBOL_LIB_TABLE_ROW* row = libTable->FindRow( aLibNickname );
1514
1515 if( !row )
1516 {
1517 libTableFileName.SetPath( Prj().GetProjectPath() );
1518 libTableFileName.SetName( SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
1519 libTable = Prj().SchSymbolLibTable();
1520 isGlobalTable = false;
1521 row = libTable->FindRow( aLibNickname );
1522 }
1523
1524 wxCHECK( row, false );
1525
1526 wxString projectPath;
1527
1528 if( !isGlobalTable )
1529 projectPath = Prj().GetProjectPath();
1530
1531 wxString normalizedPath = NormalizePath( aLibFile, &envVars, projectPath );
1532
1533 row->SetFullURI( normalizedPath );
1534 row->SetType( "KiCad" );
1535
1536 try
1537 {
1538 libTable->Save( libTableFileName.GetFullPath() );
1539 }
1540 catch( const IO_ERROR& ioe )
1541 {
1542 wxString msg = isGlobalTable ? _( "Error saving global library table." )
1543 : _( "Error saving project library table." );
1544
1545 wxMessageDialog dlg( this, msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1546 dlg.SetExtendedMessage( ioe.What() );
1547 dlg.ShowModal();
1548
1549 return false;
1550 }
1551
1552 return true;
1553}
1554
1555
1557{
1558 return m_symbol && !m_symbol->IsRoot();
1559}
1560
1561
1563{
1565}
1566
1567
1568void SYMBOL_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
1569{
1570 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
1571
1572 if( EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( aItem ) )
1573 {
1574 eda_text->ClearBoundingBoxCache();
1575 eda_text->ClearRenderCache();
1576 }
1577}
BASE_SCREEN class implementation.
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ icon_libedit_32
@ icon_libedit
@ icon_libedit_16
BOX2< VECTOR2I > BOX2I
Definition: box2.h:847
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION copy
Definition: actions.h:68
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:107
static TOOL_ACTION saveAll
Definition: actions.h:54
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION duplicate
Definition: actions.h:72
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:104
static TOOL_ACTION doDelete
Definition: actions.h:73
static TOOL_ACTION selectionTool
Definition: actions.h:156
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:74
static TOOL_ACTION zoomTool
Definition: actions.h:101
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION ddAddLibrary
Definition: actions.h:60
static TOOL_ACTION selectAll
Definition: actions.h:71
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...
wxProgressDialog with the option to also update the application progress on the taskbar
virtual bool Update(int aValue, const wxString &aNewMsg=wxEmptyString, bool *aSkip=nullptr) override
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:101
WINDOW_SETTINGS m_Window
Definition: app_settings.h:184
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:187
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
void SetOrigin(const Vec &pos)
Definition: box2.h:202
void SetSize(const Vec &size)
Definition: box2.h:213
Color settings are a bit different than most of the settings objects in that there can be more than o...
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
UNDO_REDO_CONTAINER m_undoList
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
SETTINGS_MANAGER * GetSettingsManager() const
UNDO_REDO_LIST
Specifies whether we are interacting with the undo or redo stacks.
wxAuiManager m_auimgr
UNDO_REDO_CONTAINER m_redoList
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handles event fired when a file is dropped to the window.
WX_INFOBAR * GetInfoBar()
The base class for create windows for drawing purpose.
COLOR_SETTINGS * m_colorSettings
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
virtual void SetScreen(BASE_SCREEN *aScreen)
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
virtual void UpdateMsgPanel()
Redraw the message panel.
void OnGridSettings(wxCommandEvent &event)
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
const KIID m_Uuid
Definition: eda_item.h:492
Specialization of the wxAuiPaneInfo class for KiCad panels.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
void SetAttributes(const EDA_TEXT &aSrc)
Set the text attributes from another instance.
Definition: eda_text.cpp:264
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
Class that groups generic conditions for editor states.
SELECTION_CONDITION BoundingBoxes()
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
Gather all the actions that are shared by tools.
Definition: ee_actions.h:39
static TOOL_ACTION mirrorV
Definition: ee_actions.h:128
static TOOL_ACTION runERC
Definition: ee_actions.h:153
static TOOL_ACTION pinTable
Definition: ee_actions.h:158
static TOOL_ACTION saveSymbolAs
Definition: ee_actions.h:185
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:116
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:138
static TOOL_ACTION newSymbol
Definition: ee_actions.h:186
static TOOL_ACTION drawCircle
Definition: ee_actions.h:99
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:137
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:127
static TOOL_ACTION saveLibraryAs
Definition: ee_actions.h:184
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:113
static TOOL_ACTION mirrorH
Definition: ee_actions.h:129
static TOOL_ACTION rotateCW
Definition: ee_actions.h:126
static TOOL_ACTION importSymbol
Definition: ee_actions.h:194
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:152
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:157
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:98
static TOOL_ACTION setUnitDisplayName
Definition: ee_actions.h:197
static TOOL_ACTION drawSymbolTextBox
Definition: ee_actions.h:114
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:115
static TOOL_ACTION drawArc
Definition: ee_actions.h:100
static TOOL_ACTION toggleSyncedPinsMode
Definition: ee_actions.h:221
static TOOL_ACTION showSymbolTree
Definition: ee_actions.h:229
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:112
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:227
Tool that displays edit points allowing to modify items by dragging the points.
EE_SELECTION & GetSelection()
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
bool m_axesEnabled
Fullscreen crosshair or small cross.
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
void HideDrawingSheet()
Definition: sch_view.cpp:188
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition: sch_view.cpp:181
void Clear()
Remove all items from the view.
Definition: view.cpp:1096
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1478
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition: kiway_express.h:57
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition: kiway_express.h:49
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
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:267
void OnKiCadExit()
Definition: kiway.cpp:657
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:488
Field object used in symbol libraries.
Definition: lib_field.h:60
void SetName(const wxString &aName)
Set a user definable field name to aName.
Definition: lib_field.cpp:483
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:109
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:165
const UTF8 & GetLibItemName() const
Definition: lib_id.h:101
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
void SetPosition(const VECTOR2I &aPosition) override
Definition: lib_item.h:234
Symbol library management helper that is specific to the symbol library editor frame.
void Sync(const wxString &aForceRefresh, std::function< void(int, int, const wxString &)> aProgressCallback)
Updates the SYMBOL_LIBRARY_MANAGER data to synchronize with Symbol Library Table.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter()
Return the adapter object that provides the stored data.
Define a library symbol object.
Definition: lib_symbol.h:98
bool IsMulti() const
Definition: lib_symbol.h:556
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition: lib_symbol.h:253
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:182
wxString GetUnitDisplayName(int aUnit) override
Return the user-defined display name for aUnit for symbols with units.
Definition: lib_symbol.cpp:403
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:507
LIB_ID GetLibId() const override
Definition: lib_symbol.h:139
wxString GetName() const override
Definition: lib_symbol.h:136
wxString GetLibNickname() const override
Definition: lib_symbol.h:142
void ClearCaches()
Definition: lib_symbol.cpp:530
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:460
LIB_FIELD & GetDatasheetField()
Return reference to the datasheet field.
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:125
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
void SetNickName(const wxString &aNickName)
Change the logical name of this library, useful for an editor.
const wxString & GetNickName() const
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
const LIB_TABLE_ROW * FindRowByURI(const wxString &aURI)
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
Node type: LIB_ID.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
Definition: lib_tree.cpp:309
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:215
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
Definition: lib_tree.cpp:232
int GetSelectionCount() const
Definition: lib_tree.h:87
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:226
int GetSelectedLibIds(std::vector< LIB_ID > &aSelection, std::vector< int > *aUnit=nullptr) const
Retrieves a list of selections for trees that allow multi-selection.
Definition: lib_tree.cpp:198
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:238
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
Definition: lib_tree.cpp:184
void ExpandLibId(const LIB_ID &aLibId)
Expand and item i the tree widget.
Definition: lib_tree.cpp:244
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition: lib_tree.cpp:291
static wxString GetDefaultUserSymbolsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:97
A holder to handle information on schematic or board items.
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
bool IsCancelled() const override
@ SCH_LIBEDIT_CUR_LIB
Definition: project.h:166
@ SCH_LIBEDIT_CUR_SYMBOL
Definition: project.h:167
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:125
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
Definition: project.cpp:253
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:264
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.
SYMBOL_LIB_TABLE * SelectSymLibTable(bool aOptional=false)
Display a dialog asking the user to select a symbol library table.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Save Symbol Library Tables to disk.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
virtual void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplaySymbol(LIB_SYMBOL *aSymbol)
Schematic editor (Eeschema) main window.
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
Update a schematic symbol from a LIB_SYMBOL.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:50
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1052
int GetId() const
Definition: sch_field.h:116
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:811
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
Definition: sch_io_mgr.cpp:81
Schematic symbol object.
Definition: sch_symbol.h:79
int GetUnit() const
Definition: sch_symbol.h:225
int GetConvert() const
Definition: sch_symbol.h:267
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:707
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:812
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:189
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
Handle actions for the various symbol editor and viewers.
SYMBOL_EDITOR_DRAWING_TOOLS.
The symbol library editor main window.
void OnExitKiCad(wxCommandEvent &event)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
int m_convert
Flag if the symbol being edited was loaded directly from a schematic.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
APP_SETTINGS_BASE * config() const override
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
bool addLibTableEntry(const wxString &aLibFile, TABLE_SCOPE aScope=GLOBAL_LIB_TABLE)
Add aLibFile to the symbol library table defined by aScope.
void storeCurrentSymbol()
Rename LIB_SYMBOL aliases to avoid conflicts before adding a symbol to a library.
void updateTitle()
Update the main window title bar with the current library name and read only status of the library.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
wxString getTargetLib() const
bool IsCurrentSymbol(const LIB_ID &aLibId) const
Restore the empty editor screen, without any symbol or library selected.
bool backupFile(const wxFileName &aOriginalFile, const wxString &aBackupExt)
Return currently edited symbol.
void RefreshLibraryTree()
Redisplay the library tree.
wxComboBox * m_unitSelectBox
int GetTreeLIBIDs(std::vector< LIB_ID > &aSelection) const
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
LIB_SYMBOL_LIBRARY_MANAGER * m_libMgr
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
LIB_ID GetTargetLibId() const
Return either the symbol selected in the symbol tree (if context menu is active) or the symbol on the...
void FocusOnLibId(const LIB_ID &aLibID)
bool IsSymbolAlias() const
Return true if aLibId is an alias for the editor screen symbol.
SYMBOL_EDITOR_SETTINGS * m_settings
bool LoadSymbolFromCurrentLib(const wxString &aAliasName, int aUnit=0, int aConvert=0)
Load a symbol from the current active library, optionally setting the selected unit and convert.
void HardRedraw() override
Rebuild the GAL and redraw the screen.
bool GetShowDeMorgan() const
bool IsSymbolTreeShown() const
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
int GetTreeSelectionCount() const
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
bool CanCloseSymbolFromSchematic(bool doClose)
bool IsSymbolFromLegacyLibrary() const
bool replaceLibTableEntry(const wxString &aLibNickname, const wxString &aLibFile)
Replace the file path of the symbol library table entry aLibNickname with aLibFile.
bool IsSymbolFromSchematic() const
void OnToggleSymbolTree(wxCommandEvent &event)
static bool m_showDeMorgan
void SetScreen(BASE_SCREEN *aScreen) override
SYMBOL_EDITOR_SETTINGS * GetSettings() const
SCH_SCREEN * m_dummyScreen
< Helper screen used when no symbol is loaded
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Receive KIWAY_EXPRESS messages from other players.
void SetCurSymbol(LIB_SYMBOL *aSymbol, bool aUpdateZoom)
Take ownership of aSymbol and notes that it is the one currently being edited.
KIID m_schematicSymbolUUID
RefDes of the symbol (only valid if symbol was loaded from schematic)
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
std::vector< LIB_ID > GetSelectedLibIds() const
LIB_TREE_NODE * GetCurrentTreeNode() const
void SyncLibraries(bool aShowProgress, bool aPreloadCancelled=false, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
void OnSelectUnit(wxCommandEvent &event)
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void UpdateSymbolMsgPanelInfo()
Display the documentation of the selected symbol.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
void ReCreateMenuBar() override
Recreates the menu bar.
bool saveAllLibraries(bool aRequireConfirmation)
Save the current symbol.
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from aList element.
wxString SetCurLib(const wxString &aLibNickname)
Set the current library nickname and returns the old library nickname.
void ReCreateHToolbar() override
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
bool HasLibModifications() const
Check if any pending libraries have been modified.
SYMBOL_TREE_PANE * m_treePane
void LoadSymbolFromSchematic(SCH_SYMBOL *aSymbol)
Load a symbol from the schematic to edit in place.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
LIB_SYMBOL_LIBRARY_MANAGER & GetLibManager()
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch currently used canvas ( Cairo / OpenGL).
void doCloseWindow() override
void DdAddLibrary(wxString aLibFile)
Add a library dropped file to the symbol library table.
wxString AddLibraryFile(bool aCreateNew)
Create or add an existing library to the symbol library table.
void CloseWindow(wxCommandEvent &event)
Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:
void UpdateLibraryTree(const wxDataViewItem &aTreeItem, LIB_SYMBOL *aSymbol)
Update a symbol node in the library tree.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void SetShowDeMorgan(bool show)
void ShowChangedLanguage() override
bool IsContentModified() const override
Get if any symbols or libraries have been modified but not saved.
LIB_SYMBOL * getTargetSymbol() const
Return either the library selected in the symbol tree, if context menu is active or the library that ...
void OnUpdateUnitNumber(wxUpdateUIEvent &event)
LIB_SYMBOL * GetBufferedSymbol(const wxString &aAlias, const wxString &aLibrary)
Return the symbol copy from the buffer.
bool IsLibraryReadOnly(const wxString &aLibrary) const
Return true if the library is stored in a read-only file.
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
LIB_SYMBOL * GetAlias(const wxString &aAlias, const wxString &aLibrary) const
Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no w...
bool IsLibraryModified(const wxString &aLibrary) const
Return true if library has unsaved modifications.
wxArrayString GetLibraryNames() const
Return the array of library names.
wxString GetUniqueLibraryName() const
Return a library name that is not currently in use.
bool AddLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Add an existing library.
bool CreateLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Create an empty library and adds it to the library table.
bool IsSymbolModified(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol has unsaved modifications.
SYMBOL_LIB_TABLE_ROW * GetLibrary(const wxString &aLibrary) const
Find a single library within the (aggregate) library table.
bool UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
void SetType(const wxString &aType) override
Change the schematic plugin type represented by this row.
const wxString GetType() const override
Return the type of symbol library table represented by this row.
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
static const wxString & GetSymbolLibTableFileName()
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
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...
Library Editor pane with symbol tree and symbol library table selector.
LIB_TREE * GetLibTree() const
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:172
ACTIONS * m_actions
Definition: tools_holder.h:171
@ MODEL_RELOAD
Model changes (required full reload)
Definition: tool_base.h:80
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
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 ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
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...
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
bool empty() const
Definition: utf8.h:103
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:75
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:286
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:245
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:142
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:299
int UnsavedChangesDialog(wxWindow *parent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition: confirm.cpp:177
This file is part of the common library.
static bool empty(const wxTextEntryBase *aCtrl)
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define LIB_EDIT_FRAME_NAME
@ ID_LIBEDIT_SELECT_UNIT_NUMBER
Definition: eeschema_id.h:66
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Definition: env_paths.cpp:71
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_SCH
Definition: frame_type.h:34
const std::string KiCadSymbolLibFileExtension
wxString KiCadSymbolLibFileWildcard()
@ ID_GRID_SETTINGS
Definition: id.h:146
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
@ LAYER_SCHEMATIC_GRID_AXES
Definition: layer_ids.h:375
@ MAIL_LIB_EDIT
Definition: mail_type.h:53
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:53
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:83
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
void InvokeSchEditSymbolLibTable(KIWAY *aKiway, wxWindow *aParent)
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
see class PGM_BASE
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
wxString UnescapeString(const wxString &aSource)
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
ACTION_CONDITIONS & Enable(const SELECTION_CONDITION &aCondition)
ACTION_CONDITIONS & Check(const SELECTION_CONDITION &aCondition)
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
#define CHECK(x)
#define ENABLE(x)
#define EDIT_TOOL(tool)
Definition for symbol library class.
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618
Definition of file extensions used in Kicad.