KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 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>
27#include <wx/hyperlink.h>
28#include <base_screen.h>
29#include <confirm.h>
30#include <core/kicad_algo.h>
31#include <core/throttle.h>
32#include <eeschema_id.h>
33#include <eeschema_settings.h>
34#include <env_paths.h>
36#include <kidialog.h>
37#include <kiface_base.h>
38#include <kiplatform/app.h>
39#include <kiway_mail.h>
40#include <symbol_edit_frame.h>
43#include <paths.h>
44#include <pgm_base.h>
45#include <project_sch.h>
46#include <sch_painter.h>
47#include <sch_view.h>
51#include <tool/action_manager.h>
52#include <tool/action_toolbar.h>
53#include <tool/common_control.h>
54#include <tool/common_tools.h>
56#include <tool/embed_tool.h>
58#include <tool/picker_tool.h>
60#include <tool/selection.h>
62#include <tool/tool_manager.h>
63#include <tool/zoom_tool.h>
64#include <tools/sch_actions.h>
75#include <view/view_controls.h>
77#include <widgets/wx_infobar.h>
81#include <widgets/lib_tree.h>
86#include <panel_sym_lib_table.h>
87#include <string_utils.h>
89#include <wx/msgdlg.h>
90#include <wx/combobox.h>
91#include <wx/log.h>
92#include <trace_helpers.h>
93
94
96
97
98BEGIN_EVENT_TABLE( SYMBOL_EDIT_FRAME, SCH_BASE_FRAME )
101
102 // menubar commands
103 EVT_MENU( wxID_EXIT, SYMBOL_EDIT_FRAME::OnExitKiCad )
104 EVT_MENU( wxID_CLOSE, SYMBOL_EDIT_FRAME::CloseWindow )
105
106 // Update user interface elements.
109
112
113 // Drop files event
114 EVT_DROP_FILES( SYMBOL_EDIT_FRAME::OnDropFiles )
115
116END_EVENT_TABLE()
117
118
119SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
120 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_SYMBOL_EDITOR, _( "Library Editor" ),
121 wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
123 m_unitSelectBox( nullptr ),
124 m_bodyStyleSelectBox( nullptr ),
126{
127 m_SyncPinEdit = false;
128
129 m_symbol = nullptr;
130 m_treePane = nullptr;
131 m_libMgr = nullptr;
132 m_unit = 1;
133 m_bodyStyle = 1;
134 m_aboutTitle = _HKI( "KiCad Symbol Editor" );
135
136 wxIcon icon;
137 wxIconBundle icon_bundle;
138
139 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit, 48 ) );
140 icon_bundle.AddIcon( icon );
141 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit, 256 ) );
142 icon_bundle.AddIcon( icon );
143 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit, 128 ) );
144 icon_bundle.AddIcon( icon );
145 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit_32 ) );
146 icon_bundle.AddIcon( icon );
147 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit_16 ) );
148 icon_bundle.AddIcon( icon );
149
150 SetIcons( icon_bundle );
151
154
156
157 m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
158 m_treePane->GetLibTree()->SetSortMode( (LIB_TREE_MODEL_ADAPTER::SORT_MODE) m_settings->m_LibrarySortMode );
159
162
163 // Ensure axis are always drawn
165 gal_opts.m_axesEnabled = true;
166
169 GetScreen()->m_Center = true;
170
171 GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
172
173 GetRenderSettings()->LoadColors( GetColorSettings() );
174 GetRenderSettings()->m_IsSymbolEditor = true;
175 GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
176
177 setupTools();
179
181
185
186 UpdateTitle();
189
190 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
191 m_propertiesPanel->SetSplitterProportion( m_settings->m_AuiPanels.properties_splitter );
192
194
195 m_auimgr.SetManagedWindow( this );
196
198
199 // Rows; layers 4 - 6
200 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( "TopMainToolbar" )
201 .Top().Layer( 6 ) );
202
203 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
204 .Bottom().Layer( 6 ) );
205
206 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( "LeftToolbar" )
207 .Left().Layer( 2 ) );
208
209 m_auimgr.AddPane( m_tbRight, EDA_PANE().VToolbar().Name( "RightToolbar" )
210 .Right().Layer( 2 ) );
211
212 // Center
213 m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" )
214 .CentrePane() );
215
216 // Columns; layers 1 - 3
217 m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "LibraryTree" )
218 .Left().Layer( 3 )
219 .TopDockable( false ).BottomDockable( false )
220 .Caption( _( "Libraries" ) )
221 // Don't use -1 for don't-change-height on a growable panel; it has side-effects.
222 .MinSize( FromDIP( 250 ), FromDIP( 80 ) )
223 .BestSize( FromDIP( 250 ), -1 ) );
224
227
228 // Can be called only when all panes are created, because (at least on Windows) when items
229 // managed by m_auimgr are not the same as those existing when saved by Perspective()
230 // in config, broken settings can happen.
232
233 // Protect against broken saved Perspective() due to bugs in previous version
234 // This is currently a workaround.
235 m_auimgr.GetPane( "TopMainToolbar" ).Top().Layer( 6 ).Position(0).Show( true );
236 m_auimgr.GetPane( "LeftToolbar" ).Position(0).Show( true );
237 m_auimgr.GetPane( "RightToolbar" ).Show( true );
238
239 // Show or hide m_propertiesPanel depending on current settings:
240 wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
241 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
242 // The selection filter doesn't need to grow in the vertical direction when docked
243 selectionFilterPane.dock_proportion = 0;
244
245 propertiesPaneInfo.Show( m_settings->m_AuiPanels.show_properties );
247
249
250 // Can't put this in LoadSettings, because it has to be called before setupTools :/
252 selTool->GetFilter() = GetSettings()->m_SelectionFilter;
253 m_selectionFilterPanel->SetCheckboxesFromFilter( selTool->GetFilter() );
254
255 if( m_settings->m_LibWidth > 0 )
256 SetAuiPaneSize( m_auimgr, m_auimgr.GetPane( "LibraryTree" ), m_settings->m_LibWidth, -1 );
257
258 Raise();
259 Show( true );
260
261 SyncView();
262 GetCanvas()->GetView()->UseDrawPriority( true );
263 GetCanvas()->GetGAL()->SetAxesEnabled( true );
264
266
267 // Set the working/draw area size to display a symbol to a reasonable value:
268 // A 600mm x 600mm with a origin at the area center looks like a large working area
269 double max_size_x = schIUScale.mmToIU( 600 );
270 double max_size_y = schIUScale.mmToIU( 600 );
271 BOX2D bbox;
272 bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
273 bbox.SetSize( max_size_x, max_size_y );
274 GetCanvas()->GetView()->SetBoundary( bbox );
275
277
279 DragAcceptFiles( true );
280
281 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Library changes are unsaved" ) );
282
283 // Catch unhandled accelerator command characters that were no handled by the library tree
284 // panel.
286 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
287
288 // Ensure the window is on top
289 Raise();
290
291 // run SyncLibraries with progress reporter enabled. The progress reporter is useful
292 // in debug mode because the loading time of ecah library can be really noticeable
293 SyncLibraries( true );
294}
295
296
298{
299 // Shutdown all running tools
300 if( m_toolManager )
301 m_toolManager->ShutdownAllTools();
302
303 setSymWatcher( nullptr );
304
306 {
307 delete m_symbol;
308 m_symbol = nullptr;
309
310 SCH_SCREEN* screen = GetScreen();
311 delete screen;
313 }
314
315 // current screen is destroyed in EDA_DRAW_FRAME
317
319 Pgm().GetSettingsManager().Save( cfg );
320
321 delete m_libMgr;
322}
323
324
326{
327 wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_settings" );
328
330
331 GetRenderSettings()->m_ShowPinsElectricalType = m_settings->m_ShowPinElectricalType;
332 GetRenderSettings()->m_ShowHiddenPins = m_settings->m_ShowHiddenPins;
333 GetRenderSettings()->m_ShowHiddenFields = m_settings->m_ShowHiddenFields;
334 GetRenderSettings()->m_ShowPinAltIcons = m_settings->m_ShowPinAltIcons;
335 GetRenderSettings()->SetDefaultFont( wxEmptyString );
336}
337
338
340{
341 wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME:SaveSettings with null m_settings" );
342
344
346
347 m_settings->m_ShowPinElectricalType = GetRenderSettings()->m_ShowPinsElectricalType;
348 m_settings->m_ShowHiddenPins = GetRenderSettings()->m_ShowHiddenPins;
349 m_settings->m_ShowHiddenFields = GetRenderSettings()->m_ShowHiddenFields;
350 m_settings->m_ShowPinAltIcons = GetRenderSettings()->m_ShowPinAltIcons;
351
352 m_settings->m_LibWidth = m_treePane->GetSize().x;
353
354 m_settings->m_LibrarySortMode = GetLibTree()->GetSortMode();
355
356 m_settings->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
357 bool prop_shown = m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
358 m_settings->m_AuiPanels.show_properties = prop_shown;
359
360 if( TOOL_MANAGER* toolMgr = GetToolManager() )
361 {
362 if( SCH_SELECTION_TOOL* selTool = toolMgr->GetTool<SCH_SELECTION_TOOL>() )
363 m_settings->m_SelectionFilter = selTool->GetFilter();
364 }
365}
366
367
369{
370 return static_cast<APP_SETTINGS_BASE*>( GetSettings() );
371}
372
373
375{
377
378 if( cfg && static_cast<SYMBOL_EDITOR_SETTINGS*>( cfg )->m_UseEeschemaColorSettings )
379 cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
380
381 return ::GetColorSettings( cfg ? cfg->m_ColorTheme : DEFAULT_THEME );
382}
383
384
386{
387 // Create the manager and dispatcher & route draw panel events to the dispatcher
389 m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
390 GetCanvas()->GetViewControls(), GetSettings(), this );
391 m_actions = new SCH_ACTIONS();
393
394 // Register tools
395 m_toolManager->RegisterTool( new COMMON_CONTROL );
396 m_toolManager->RegisterTool( new COMMON_TOOLS );
397 m_toolManager->RegisterTool( new ZOOM_TOOL );
398 m_toolManager->RegisterTool( new SCH_SELECTION_TOOL );
399 m_toolManager->RegisterTool( new PICKER_TOOL );
400 m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL );
401 m_toolManager->RegisterTool( new SYMBOL_EDITOR_PIN_TOOL );
402 m_toolManager->RegisterTool( new SYMBOL_EDITOR_DRAWING_TOOLS );
403 m_toolManager->RegisterTool( new SCH_POINT_EDITOR );
404 m_toolManager->RegisterTool( new SCH_FIND_REPLACE_TOOL );
405 m_toolManager->RegisterTool( new SYMBOL_EDITOR_MOVE_TOOL );
406 m_toolManager->RegisterTool( new SYMBOL_EDITOR_EDIT_TOOL );
407 m_toolManager->RegisterTool( new LIBRARY_EDITOR_CONTROL );
408 m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL );
409 m_toolManager->RegisterTool( new PROPERTIES_TOOL );
410 m_toolManager->RegisterTool( new EMBED_TOOL );
411 m_toolManager->InitTools();
412
413 // Run the selection tool, it is supposed to be always active
414 m_toolManager->InvokeTool( "common.InteractiveSelection" );
415
417}
418
419
421{
423
424 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
425 EDITOR_CONDITIONS cond( this );
426
427 wxASSERT( mgr );
428
429#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
430#define CHECK( x ) ACTION_CONDITIONS().Check( x )
431
432 auto haveSymbolCond =
433 [this]( const SELECTION& )
434 {
435 return m_symbol;
436 };
437
438 auto isEditableCond =
439 [this]( const SELECTION& )
440 {
441 // Only root symbols from the new s-expression libraries or the schematic
442 // are editable.
443 return IsSymbolEditable() && !IsSymbolAlias();
444 };
445
446 auto isEditableInAliasCond =
447 [this]( const SELECTION& )
448 {
449 // Less restrictive than isEditableCond
450 // Symbols fields (root symbols and aliases) from the new s-expression libraries
451 // or in the schematic are editable.
452 return IsSymbolEditable();
453 };
454
455 auto symbolModifiedCondition =
456 [this]( const SELECTION& sel )
457 {
458 return m_libMgr && m_libMgr->IsSymbolModified( GetTargetLibId().GetLibItemName(),
459 GetTargetLibId().GetLibNickname() );
460 };
461
462 auto libSelectedCondition =
463 [this]( const SELECTION& sel )
464 {
465 return !GetTargetLibId().GetLibNickname().empty();
466 };
467
468 auto canEditProperties =
469 [this]( const SELECTION& sel )
470 {
472 };
473
474 auto symbolSelectedInTreeCondition =
475 [this]( const SELECTION& sel )
476 {
477 LIB_ID targetLibId = GetTargetLibId();
478 return !targetLibId.GetLibNickname().empty() && !targetLibId.GetLibItemName().empty();
479 };
480
481 auto saveSymbolAsCondition =
482 [this]( const SELECTION& aSel )
483 {
484 return getTargetSymbol() != nullptr;
485 };
486
487 const auto isSymbolFromSchematicCond =
488 [this]( const SELECTION& )
489 {
490 return IsSymbolFromSchematic();
491 };
492
493 // clang-format off
496 mgr->SetConditions( SCH_ACTIONS::saveLibraryAs, ENABLE( libSelectedCondition ) );
497 mgr->SetConditions( SCH_ACTIONS::saveSymbolAs, ENABLE( saveSymbolAsCondition ) );
498 mgr->SetConditions( SCH_ACTIONS::saveSymbolCopyAs, ENABLE( saveSymbolAsCondition ) );
501 mgr->SetConditions( SCH_ACTIONS::editLibSymbolWithLibEdit, ENABLE( isSymbolFromSchematicCond ) );
502
503 mgr->SetConditions( ACTIONS::undo, ENABLE( haveSymbolCond && cond.UndoAvailable() ) );
504 mgr->SetConditions( ACTIONS::redo, ENABLE( haveSymbolCond && cond.RedoAvailable() ) );
505 mgr->SetConditions( ACTIONS::revert, ENABLE( symbolModifiedCondition ) );
506
509
510 mgr->SetConditions( ACTIONS::cut, ENABLE( isEditableCond ) );
511 mgr->SetConditions( ACTIONS::copy, ENABLE( haveSymbolCond ) );
512 mgr->SetConditions( ACTIONS::copyAsText, ENABLE( haveSymbolCond ) );
513 mgr->SetConditions( ACTIONS::paste, ENABLE( isEditableCond &&
515 mgr->SetConditions( ACTIONS::doDelete, ENABLE( isEditableCond ) );
516 mgr->SetConditions( ACTIONS::duplicate, ENABLE( isEditableCond ) );
517 mgr->SetConditions( ACTIONS::selectAll, ENABLE( haveSymbolCond ) );
518 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( haveSymbolCond ) );
519
520 // These actions in symbol editor when editing alias field rotations are allowed.
521 mgr->SetConditions( SCH_ACTIONS::rotateCW, ENABLE( isEditableInAliasCond ) );
522 mgr->SetConditions( SCH_ACTIONS::rotateCCW, ENABLE( isEditableInAliasCond ) );
523
524 mgr->SetConditions( SCH_ACTIONS::mirrorH, ENABLE( isEditableCond ) );
525 mgr->SetConditions( SCH_ACTIONS::mirrorV, ENABLE( isEditableCond ) );
526
529 // clang-format on
530
531 auto pinTypeCond =
532 [this]( const SELECTION& )
533 {
535 };
536
537 auto hiddenPinCond =
538 [this]( const SELECTION& )
539 {
541 };
542
543 auto hiddenFieldCond =
544 [this]( const SELECTION& )
545 {
547 };
548
549 auto showPinAltIconsCond =
550 [this]( const SELECTION& )
551 {
553 };
554
555 auto showLibraryTreeCond =
556 [this]( const SELECTION& )
557 {
558 return IsLibraryTreeShown();
559 };
560
561 auto propertiesCond =
562 [this] ( const SELECTION& )
563 {
564 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
565 };
566
569 mgr->SetConditions( ACTIONS::showLibraryTree, CHECK( showLibraryTreeCond ) );
570 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
571 mgr->SetConditions( SCH_ACTIONS::showHiddenPins, CHECK( hiddenPinCond ) );
572 mgr->SetConditions( SCH_ACTIONS::showHiddenFields, CHECK( hiddenFieldCond ) );
573 mgr->SetConditions( SCH_ACTIONS::togglePinAltIcons, CHECK( showPinAltIconsCond ) );
574
575 auto multiUnitModeCond =
576 [this]( const SELECTION& )
577 {
578 return m_symbol && m_symbol->IsMultiUnit() && !m_symbol->UnitsLocked();
579 };
580
581 auto multiBodyStyleModeCond =
582 [this]( const SELECTION& )
583 {
584 return m_symbol && m_symbol->IsMultiBodyStyle();
585 };
586
587 auto syncedPinsModeCond =
588 [this]( const SELECTION& )
589 {
590 return m_SyncPinEdit;
591 };
592
593 auto haveDatasheetCond =
594 [this]( const SELECTION& )
595 {
596 return m_symbol && !m_symbol->GetDatasheetField().GetText().IsEmpty();
597 };
598
599 mgr->SetConditions( ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
600 mgr->SetConditions( SCH_ACTIONS::symbolProperties, ENABLE( symbolSelectedInTreeCondition || ( canEditProperties && haveSymbolCond ) ) );
601 mgr->SetConditions( SCH_ACTIONS::runERC, ENABLE( haveSymbolCond ) );
602 mgr->SetConditions( SCH_ACTIONS::pinTable, ENABLE( isEditableCond && haveSymbolCond ) );
603 mgr->SetConditions( SCH_ACTIONS::updateSymbolFields, ENABLE( isEditableCond && haveSymbolCond ) );
604 mgr->SetConditions( SCH_ACTIONS::cycleBodyStyle, ENABLE( multiBodyStyleModeCond ) );
605
606 mgr->SetConditions( SCH_ACTIONS::toggleSyncedPinsMode, ACTION_CONDITIONS().Enable( multiUnitModeCond ).Check( syncedPinsModeCond ) );
607
608// Only enable a tool if the symbol is edtable
609#define EDIT_TOOL( tool ) ACTION_CONDITIONS().Enable( isEditableCond ).Check( cond.CurrentTool( tool ) )
610
623
624#undef CHECK
625#undef ENABLE
626#undef EDIT_TOOL
627}
628
629
631{
632 if( IsContentModified() )
633 {
634 SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
635 wxString msg = _( "Save changes to '%s' before closing?" );
636
637 switch( UnsavedChangesDialog( this, wxString::Format( msg, m_reference ), nullptr ) )
638 {
639 case wxID_YES:
640 if( schframe && GetCurSymbol() ) // Should be always the case
642
643 break;
644
645 case wxID_NO:
646 break;
647
648 default:
649 case wxID_CANCEL:
650 return false;
651 }
652 }
653
654 if( doClose )
655 {
656 SetCurSymbol( nullptr, false );
657 UpdateTitle();
658 }
659
660 return true;
661}
662
663
664bool SYMBOL_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
665{
666 // Shutdown blocks must be determined and vetoed as early as possible
668 && aEvent.GetId() == wxEVT_QUERY_END_SESSION
669 && IsContentModified() )
670 {
671 return false;
672 }
673
675 return false;
676
677 if( !saveAllLibraries( true ) )
678 return false;
679
680 // Save symbol tree column widths
681 m_libMgr->GetAdapter()->SaveSettings();
682
683 return true;
684}
685
686
688{
690
691 if( GetLibTree() )
693
694 delete m_toolManager;
695 m_toolManager = nullptr;
696
697 Destroy();
698}
699
700
702{
703 if( m_unitSelectBox )
704 {
705 if( m_unitSelectBox->GetCount() != 0 )
706 m_unitSelectBox->Clear();
707
708 if( !m_symbol || m_symbol->GetUnitCount() <= 1 )
709 {
710 m_unit = 1;
711 m_unitSelectBox->Append( wxEmptyString );
712 }
713 else
714 {
715 for( int i = 0; i < m_symbol->GetUnitCount(); i++ )
716 m_unitSelectBox->Append( m_symbol->GetUnitDisplayName( i + 1, true ) );
717 }
718
719 // Ensure the selected unit is compatible with the number of units of the current symbol:
720 if( m_symbol && m_symbol->GetUnitCount() < m_unit )
721 m_unit = 1;
722
723 m_unitSelectBox->SetSelection( ( m_unit > 0 ) ? m_unit - 1 : 0 );
724 }
725
727 {
728 if( m_bodyStyleSelectBox->GetCount() != 0 )
729 m_bodyStyleSelectBox->Clear();
730
731 if( !m_symbol || !m_symbol->IsMultiBodyStyle() )
732 {
733 m_bodyStyle = 1;
734 m_bodyStyleSelectBox->Append( wxEmptyString );
735 }
736 else if( m_symbol && m_symbol->HasDeMorganBodyStyles() )
737 {
738 m_bodyStyleSelectBox->Append( wxGetTranslation( DEMORGAN_STD ) );
739 m_bodyStyleSelectBox->Append( wxGetTranslation( DEMORGAN_ALT ) );
740 }
741 else
742 {
743 for( int i = 0; i < m_symbol->GetBodyStyleCount(); i++ )
744 m_bodyStyleSelectBox->Append( m_symbol->GetBodyStyleNames()[i] );
745 }
746
747 // Ensure the selected body style is compatible with the number of body styles of the current symbol:
748 if( m_symbol && m_symbol->GetBodyStyleCount() < m_bodyStyle )
749 m_bodyStyle = 1;
750
751 m_bodyStyleSelectBox->SetSelection( ( m_bodyStyle > 0 ) ? m_bodyStyle - 1 : 0 );
752 }
753}
754
755
757{
758 if( !m_propertiesPanel )
759 return;
760
761 bool show = !m_propertiesPanel->IsShownOnScreen();
762
763 wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
764 propertiesPaneInfo.Show( show );
766
767 if( show )
768 {
769 SetAuiPaneSize( m_auimgr, propertiesPaneInfo,
770 m_settings->m_AuiPanels.properties_panel_width, -1 );
771 }
772 else
773 {
774 m_settings->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
775 }
776
777 m_auimgr.Update();
778 Refresh();
779}
780
781
783{
784 wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
785 treePane.Show( !IsLibraryTreeShown() );
787 m_auimgr.Update();
788 Refresh();
789}
790
791
793{
794 return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
795}
796
797
802
803
805{
806 m_treePane->Freeze();
807 m_libMgr->GetAdapter()->Freeze();
808}
809
810
812{
813 m_libMgr->GetAdapter()->Thaw();
814 m_treePane->Thaw();
815}
816
817
818void SYMBOL_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
819{
820 Kiway().OnKiCadExit();
821}
822
823
824void SYMBOL_EDIT_FRAME::OnUpdateUnitNumber( wxUpdateUIEvent& event )
825{
826 event.Enable( m_symbol && m_symbol->GetUnitCount() > 1 );
827}
828
829
830void SYMBOL_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event )
831{
832 if( event.GetSelection() == wxNOT_FOUND )
833 return;
834
835 SetUnit( event.GetSelection() + 1 );
836}
837
838
839void SYMBOL_EDIT_FRAME::OnUpdateBodyStyle( wxUpdateUIEvent& event )
840{
841 event.Enable( m_symbol && m_symbol->GetBodyStyleCount() > 1 );
842}
843
844
845void SYMBOL_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
846{
847 if( event.GetSelection() == wxNOT_FOUND )
848 return;
849
850 SetBodyStyle( event.GetSelection() + 1 );
851}
852
853
855{
856 if( m_symbol )
857 {
859
860 if( auto row = adapter->GetRow( m_symbol->GetLibNickname() ); row.has_value() )
861 {
862 if( ( *row )->Type() == SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_LEGACY ) )
863 return true;
864 }
865 }
866
867 return false;
868}
869
870
872{
873 wxString libNickname = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB );
874
875 if( !libNickname.empty() )
876 {
877 if( !PROJECT_SCH::SymbolLibAdapter( &Prj() )->HasLibrary( libNickname ) )
878 {
879 Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
880 libNickname = wxEmptyString;
881 }
882 }
883
884 return libNickname;
885}
886
887
888wxString SYMBOL_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
889{
890 wxString old = GetCurLib();
891
892 if( aLibNickname.empty() || !PROJECT_SCH::SymbolLibAdapter( &Prj() )->HasLibrary( aLibNickname ) )
893 Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
894 else
896
897 return old;
898}
899
900
901void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom )
902{
903 wxCHECK( m_toolManager, /* void */ );
904
906 GetCanvas()->GetView()->Clear();
907 delete m_symbol;
908
909 m_symbol = aSymbol;
910
911 // select the current symbol in the tree widget
913 GetLibTree()->SelectLibId( m_symbol->GetLibId() );
914 else
915 GetLibTree()->Unselect();
916
917 wxString symbolName;
918 wxString libName;
919
920 if( m_symbol )
921 {
922 symbolName = m_symbol->GetName();
923 libName = UnescapeString( m_symbol->GetLibId().GetLibNickname() );
924 }
925
926 // retain in case this wxFrame is re-opened later on the same PROJECT
928
929 // Ensure synchronized pin edit can be enabled only symbols with interchangeable units
930 m_SyncPinEdit = aSymbol && aSymbol->IsRoot() && aSymbol->IsMultiUnit() && !aSymbol->UnitsLocked();
931
933
941
942 if( aUpdateZoom )
944
945 GetCanvas()->Refresh();
946 m_propertiesPanel->UpdateData();
947
948 WX_INFOBAR& infobar = *GetInfoBar();
949 infobar.RemoveAllButtons();
950
951 wxArrayString msgs;
952 int infobarFlags = wxICON_INFORMATION;
953
955 {
956 msgs.push_back( wxString::Format( _( "Editing symbol %s from schematic. Saving will "
957 "update the schematic only." ),
958 m_reference ) );
959
960 wxString link = wxString::Format( _( "Open symbol from library %s" ), libName );
961 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( &infobar, wxID_ANY, link, wxEmptyString );
962
963 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
964 [this, symbolName, libName]( wxHyperlinkEvent& aEvent )
965 {
967 } ) );
968
969 infobar.AddButton( button );
970 }
971 else if( IsSymbolFromLegacyLibrary() )
972 {
973 msgs.push_back( _( "Symbols in legacy libraries are not editable. Use Manage Symbol "
974 "Libraries to migrate to current format." ) );
975
976 wxString link = _( "Manage symbol libraries" );
977 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( &infobar, wxID_ANY, link, wxEmptyString );
978
979 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
980 [this]( wxHyperlinkEvent& aEvent )
981 {
983 } ) );
984
985 infobar.AddButton( button );
986 }
987 else if( IsSymbolAlias() )
988 {
989 msgs.push_back( wxString::Format( _( "Symbol %s is a derived symbol. Symbol graphics will "
990 "not be editable." ),
991 UnescapeString( symbolName ) ) );
992
993 // Don't assume the parent symbol shared pointer is still valid.
994 if( std::shared_ptr<LIB_SYMBOL> rootSymbol = m_symbol->GetRootSymbol() )
995 {
996 int unit = GetUnit();
997 int bodyStyle = GetBodyStyle();
998 wxString rootSymbolName = rootSymbol->GetName();
999 wxString link = wxString::Format( _( "Open %s" ), UnescapeString( rootSymbolName ) );
1000
1001 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( &infobar, wxID_ANY, link,
1002 wxEmptyString );
1003
1004 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
1005 [this, rootSymbolName, unit, bodyStyle]( wxHyperlinkEvent& aEvent )
1006 {
1007 LoadSymbolFromCurrentLib( rootSymbolName, unit, bodyStyle );
1008 } ) );
1009
1010 infobar.AddButton( button );
1011 }
1012 }
1013
1014 if( m_symbol
1016 && m_libMgr->IsLibraryReadOnly( m_symbol->GetLibId().GetFullLibraryName() ) )
1017 {
1018 msgs.push_back( _( "Library is read-only. Changes cannot be saved to this library." ) );
1019
1020 wxString link = wxString::Format( _( "Create an editable copy" ) );
1021 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( &infobar, wxID_ANY, link, wxEmptyString );
1022
1023 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
1024 [this, symbolName, libName]( wxHyperlinkEvent& aEvent )
1025 {
1026 wxString msg = wxString::Format( _( "Create an editable copy of the symbol or "
1027 "the entire library (%s)?" ),
1028 libName );
1029
1030 KIDIALOG errorDlg( this, msg, _( "Select type of item to save" ),
1031 wxYES_NO | wxCANCEL | wxICON_QUESTION );
1032 // These buttons are in a weird order(?)
1033 errorDlg.SetYesNoCancelLabels( _( "Copy symbol" ), _( "Cancel" ),
1034 _( "Copy library" ) );
1035
1036 int choice = errorDlg.ShowModal();
1037
1038 switch( choice )
1039 {
1040 case wxID_YES:
1041 SaveSymbolCopyAs( true );
1042 break;
1043 case wxID_CANCEL:
1044 SaveLibraryAs();
1045 break;
1046 default:
1047 // Do nothing
1048 break;
1049 }
1050 } ) );
1051
1052 infobar.AddButton( button );
1053 }
1054
1055 if( msgs.empty() )
1056 {
1057 infobar.Dismiss();
1058 }
1059 else
1060 {
1061 wxString msg = wxJoin( msgs, '\n', '\0' );
1062 infobar.ShowMessage( msg, infobarFlags );
1063 }
1064}
1065
1066
1072
1073
1075{
1077
1079
1080 if( !IsSymbolFromSchematic() )
1082
1083 if( m_isClosing )
1084 return;
1085
1087
1088 if( !GetTitle().StartsWith( "*" ) )
1089 UpdateTitle();
1090}
1091
1092
1094{
1095 wxCHECK( aUnit > 0 && aUnit <= GetCurSymbol()->GetUnitCount(), /* void*/ );
1096
1097 if( m_unit == aUnit )
1098 return;
1099
1102
1103 m_unit = aUnit;
1104
1105 if( m_unitSelectBox->GetSelection() != ( m_unit - 1 ) )
1106 m_unitSelectBox->SetSelection( m_unit - 1 );
1107
1109 RebuildView();
1111}
1112
1113
1115{
1116 wxCHECK( aBodyStyle > 0 && aBodyStyle <= GetCurSymbol()->GetBodyStyleCount(), /* void */ );
1117
1118 if( m_bodyStyle == aBodyStyle )
1119 return;
1120
1123
1124 m_bodyStyle = aBodyStyle;
1125
1126 if( m_bodyStyleSelectBox->GetSelection() != ( m_bodyStyle - 1 ) )
1127 m_bodyStyleSelectBox->SetSelection( m_bodyStyle - 1 );
1128
1129
1131 RebuildView();
1133}
1134
1135
1137{
1138 return m_SyncPinEdit && m_symbol && m_symbol->IsMultiUnit() && !m_symbol->UnitsLocked();
1139}
1140
1141
1142wxString SYMBOL_EDIT_FRAME::AddLibraryFile( bool aCreateNew )
1143{
1144 wxFileName fn = m_libMgr->GetUniqueLibraryName();
1145 bool useGlobalTable = true;
1146 FILEDLG_HOOK_NEW_LIBRARY tableChooser( useGlobalTable );
1147
1148 if( !LibraryFileBrowser( aCreateNew ? _( "New Symbol Library" ) : _( "Add Symbol Library" ),
1149 !aCreateNew, fn, FILEEXT::KiCadSymbolLibFileWildcard(),
1151 Pgm().GetSettingsManager().IsProjectOpenNotDummy() ? &tableChooser : nullptr ) )
1152 {
1153 return wxEmptyString;
1154 }
1155
1158
1159 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
1160 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, scope );
1161
1162 wxCHECK( optTable.has_value(), wxEmptyString );
1163 LIBRARY_TABLE* table = optTable.value();
1164
1165 wxString libName = fn.GetName();
1166
1167 if( libName.IsEmpty() )
1168 return wxEmptyString;
1169
1171
1172 if( adapter->HasLibrary( libName ) )
1173 {
1174 DisplayError( this, wxString::Format( _( "Library '%s' already exists." ), libName ) );
1175 return wxEmptyString;
1176 }
1177
1178 if( aCreateNew )
1179 {
1180 if( !m_libMgr->CreateLibrary( fn.GetFullPath(), scope ) )
1181 {
1182 DisplayError( this, wxString::Format( _( "Could not create the library file '%s'.\n"
1183 "Make sure you have write permissions and try again." ),
1184 fn.GetFullPath() ) );
1185 return wxEmptyString;
1186 }
1187 }
1188 else
1189 {
1190 if( !m_libMgr->AddLibrary( fn.GetFullPath(), scope ) )
1191 {
1192 DisplayError( this, _( "Could not open the library file." ) );
1193 return wxEmptyString;
1194 }
1195 }
1196
1197 bool success = true;
1198
1199 // Tables are reinitialized by m_libMgr->AddLibrary(). So reinit table reference.
1200 optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, scope );
1201 wxCHECK( optTable.has_value(), wxEmptyString );
1202 table = optTable.value();
1203
1204 table->Save().map_error(
1205 [&]( const LIBRARY_ERROR& aError )
1206 {
1207 KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ),
1208 wxOK | wxICON_ERROR );
1209 dlg.SetExtendedMessage( aError.message );
1210 dlg.ShowModal();
1211
1212 success = false;
1213 } );
1214
1215 if( success )
1216 adapter->LoadOne( fn.GetName() );
1217
1218 std::string packet = fn.GetFullPath().ToStdString();
1221
1222 return fn.GetFullPath();
1223}
1224
1225
1226void SYMBOL_EDIT_FRAME::DdAddLibrary( wxString aLibFile )
1227{
1228 wxFileName fn = wxFileName( aLibFile );
1229 wxString libName = fn.GetName();
1230
1231 if( libName.IsEmpty() )
1232 return;
1233
1234 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
1236
1237 if( adapter->HasLibrary( libName ) )
1238 {
1239 DisplayError( this, wxString::Format( _( "Library '%s' already exists." ), libName ) );
1240 return;
1241 }
1242
1243 if( !m_libMgr->AddLibrary( fn.GetFullPath(), LIBRARY_TABLE_SCOPE::PROJECT ) )
1244 {
1245 DisplayError( this, _( "Could not open the library file." ) );
1246 return;
1247 }
1248
1249 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, LIBRARY_TABLE_SCOPE::PROJECT );
1250 wxCHECK( optTable.has_value(), /* void */ );
1251 LIBRARY_TABLE* table = optTable.value();
1252 bool success = true;
1253
1254 table->Save().map_error(
1255 [&]( const LIBRARY_ERROR& aError )
1256 {
1257 KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ),
1258 wxOK | wxICON_ERROR );
1259 dlg.SetExtendedMessage( aError.message );
1260 dlg.ShowModal();
1261
1262 success = false;
1263 } );
1264
1265 if( success )
1266 adapter->LoadOne( libName );
1267
1268 std::string packet = fn.GetFullPath().ToStdString();
1271}
1272
1273
1275{
1276 return GetLibTree()->GetSelectedLibId( aUnit );
1277}
1278
1279
1284
1285int SYMBOL_EDIT_FRAME::GetTreeLIBIDs( std::vector<LIB_ID>& aSelection ) const
1286{
1287 return GetLibTree()->GetSelectedLibIds( aSelection );
1288}
1289
1290
1292{
1293 if( IsLibraryTreeShown() )
1294 {
1295 LIB_ID libId = GetTreeLIBID();
1296
1297 if( libId.IsValid() )
1298 return m_libMgr->GetSymbol( libId.GetLibItemName(), libId.GetLibNickname() );
1299 }
1300
1301 return m_symbol;
1302}
1303
1304
1306{
1307 LIB_ID id;
1308
1309 if( IsLibraryTreeShown() )
1310 id = GetTreeLIBID();
1311
1312 if( id.GetLibNickname().empty() && m_symbol )
1313 id = m_symbol->GetLibId();
1314
1315 return id;
1316}
1317
1318
1319std::vector<LIB_ID> SYMBOL_EDIT_FRAME::GetSelectedLibIds() const
1320{
1321 std::vector<LIB_ID> ids;
1322 GetTreeLIBIDs( ids );
1323 return ids;
1324}
1325
1326
1328{
1329 return GetTargetLibId().GetLibNickname();
1330}
1331
1332
1333void SYMBOL_EDIT_FRAME::SyncLibraries( bool aShowProgress, bool aPreloadCancelled,
1334 const wxString& aForceRefresh )
1335{
1336 LIB_ID selected;
1337
1338 if( m_treePane )
1339 selected = GetLibTree()->GetSelectedLibId();
1340
1341 // Ensure any in-progress background library preloading is complete before syncing the
1342 // tree. Without this, libraries still in LOADING state get skipped by Sync(), resulting
1343 // in an incomplete tree that requires a manual refresh to fully populate.
1345 adapter->BlockUntilLoaded();
1346
1347 if( aShowProgress )
1348 {
1349 APP_PROGRESS_DIALOG progressDlg( _( "Loading Symbol Libraries" ), wxEmptyString,
1350 m_libMgr->GetAdapter()->GetLibrariesCount(), this );
1351
1352 THROTTLE progressThrottle( std::chrono::milliseconds( 350 ) );
1353 int pendingProgress = 0;
1354 bool callbackFired = false;
1355 wxString pendingLibName;
1356
1357 m_libMgr->Sync( aForceRefresh,
1358 [&]( int progress, int max, const wxString& libName )
1359 {
1360 pendingProgress = progress;
1361 pendingLibName = libName;
1362 callbackFired = true;
1363
1364 if( progressThrottle.Ready() )
1365 progressDlg.Update( progress, wxString::Format( _( "Loading library '%s'..." ), libName ) );
1366 } );
1367
1368 if( callbackFired )
1369 progressDlg.Update( pendingProgress, wxString::Format( _( "Loading library '%s'..." ), pendingLibName ) );
1370 }
1371 else if( !aPreloadCancelled )
1372 {
1373 m_libMgr->Sync( aForceRefresh, [&]( int progress, int max, const wxString& libName ) {} );
1374 }
1375
1376 if( m_treePane )
1377 {
1378 wxDataViewItem found;
1379
1380 if( selected.IsValid() )
1381 {
1382 // Check if the previously selected item is still valid,
1383 // if not - it has to be unselected to prevent crash
1384 found = m_libMgr->GetAdapter()->FindItem( selected );
1385
1386 if( !found )
1387 GetLibTree()->Unselect();
1388 }
1389
1390 GetLibTree()->Regenerate( true );
1391
1392 // Try to select the parent library, in case the symbol is not found
1393 if( !found && selected.IsValid() )
1394 {
1395 selected.SetLibItemName( "" );
1396 found = m_libMgr->GetAdapter()->FindItem( selected );
1397
1398 if( found )
1399 GetLibTree()->SelectLibId( selected );
1400 }
1401
1402 // If no selection, see if there's a current symbol to centre
1403 if( !selected.IsValid() && m_symbol )
1404 {
1405 LIB_ID current( GetCurLib(), m_symbol->GetName() );
1406 GetLibTree()->CenterLibId( current );
1407 }
1408 }
1409}
1410
1411
1416
1417
1419{
1420 GetLibTree()->SelectLibId( aLibID );
1421}
1422
1423
1424void SYMBOL_EDIT_FRAME::UpdateLibraryTree( const wxDataViewItem& aTreeItem, LIB_SYMBOL* aSymbol )
1425{
1426 if( aTreeItem.IsOk() ) // Can be not found in tree if the current footprint is imported
1427 // from file therefore not yet in tree.
1428 {
1429 static_cast<LIB_TREE_NODE_ITEM*>( aTreeItem.GetID() )->Update( aSymbol );
1431 }
1432}
1433
1434
1435bool SYMBOL_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt )
1436{
1437 if( aOriginalFile.FileExists() )
1438 {
1439 wxFileName backupFileName( aOriginalFile );
1440 backupFileName.SetExt( aBackupExt );
1441
1442 if( backupFileName.FileExists() )
1443 wxRemoveFile( backupFileName.GetFullPath() );
1444
1445 if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
1446 {
1447 DisplayError( this, wxString::Format( _( "Failed to save backup to '%s'." ),
1448 backupFileName.GetFullPath() ) );
1449 return false;
1450 }
1451 }
1452
1453 return true;
1454}
1455
1456
1458{
1459 if( m_symbol && !GetCurLib().IsEmpty() && GetScreen()->IsContentModified() )
1460 m_libMgr->UpdateSymbol( m_symbol, GetCurLib() ); // UpdateSymbol() makes a copy
1461}
1462
1463
1465{
1466 // This will return the root symbol of any alias
1467 LIB_SYMBOL* symbol = m_libMgr->GetBufferedSymbol( aLibId.GetLibItemName(), aLibId.GetLibNickname() );
1468
1469 // Now we can compare the libId of the current symbol and the root symbol
1470 return ( symbol && m_symbol && symbol->GetLibId() == m_symbol->GetLibId() );
1471}
1472
1473
1475{
1476 GetLibTree()->Unselect();
1477 SetCurLib( wxEmptyString );
1478 SetCurSymbol( nullptr, false );
1482 Refresh();
1483}
1484
1485
1487{
1489
1491 {
1492 GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_ShowPinElectricalType;
1493 GetRenderSettings()->m_ShowHiddenPins = cfg->m_ShowHiddenPins;
1494 GetRenderSettings()->m_ShowHiddenFields = cfg->m_ShowHiddenFields;
1495 GetRenderSettings()->m_ShowPinAltIcons = cfg->m_ShowPinAltIcons;
1496
1497 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1498 }
1499
1500 if( m_symbol )
1501 m_symbol->ClearCaches();
1502
1504
1506 GetCanvas()->Refresh();
1507
1509
1510 if( aFlags & ENVVARS_CHANGED )
1511 SyncLibraries( true );
1512
1513 Layout();
1514 SendSizeEvent();
1515}
1516
1517
1519{
1520 // call my base class
1522
1523 // tooltips in toolbars
1525
1526 // For some obscure reason, the AUI manager hides the first modified pane.
1527 // So force show panes
1528 wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
1529 bool tree_shown = tree_pane_info.IsShown();
1530 tree_pane_info.Caption( _( "Libraries" ) );
1531 tree_pane_info.Show( tree_shown );
1532 m_auimgr.Update();
1533
1535
1536 // status bar
1538
1539 if( GetRenderSettings()->m_ShowPinsElectricalType )
1540 {
1542 GetCanvas()->Refresh();
1543 }
1544
1545 UpdateTitle();
1546}
1547
1548
1550{
1551 SCH_BASE_FRAME::SetScreen( aScreen );
1552
1553 // Let tools add things to the view if necessary
1554 if( m_toolManager )
1556}
1557
1558
1576
1577
1579{
1580 SyncLibraries( true );
1581
1582 if( m_symbol )
1583 {
1584 SCH_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>();
1585 SCH_SELECTION& selection = selectionTool->GetSelection();
1586
1587 for( SCH_ITEM& item : m_symbol->GetDrawItems() )
1588 {
1589 if( !alg::contains( selection, &item ) )
1590 item.ClearSelected();
1591 else
1592 item.SetSelected();
1593 }
1594
1595 m_symbol->ClearCaches();
1596 }
1597
1598 RebuildView();
1599}
1600
1601
1602const BOX2I SYMBOL_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1603{
1604 if( !m_symbol )
1605 {
1606 // Gives a reasonable drawing area size
1607 int width = schIUScale.mmToIU( 50 );
1608 int height = schIUScale.mmToIU( 30 );
1609
1610 return BOX2I( VECTOR2I( -width/2, -height/2 ), VECTOR2I( width, height ) );
1611 }
1612 else
1613 {
1614 return m_symbol->Flatten()->GetUnitBoundingBox( m_unit, m_bodyStyle );
1615 }
1616}
1617
1618
1619void SYMBOL_EDIT_FRAME::FocusOnItem( EDA_ITEM* aItem, bool aAllowScroll )
1620{
1621 static KIID lastBrightenedItemID( niluuid );
1622
1623 SCH_ITEM* lastItem = nullptr;
1624
1625 // nullptr will clear the current focus
1626 if( aItem != nullptr && !aItem->IsSCH_ITEM() )
1627 return;
1628
1629 if( m_symbol )
1630 {
1631 for( SCH_PIN* pin : m_symbol->GetGraphicalPins( 0, 0 ) )
1632 {
1633 if( pin->m_Uuid == lastBrightenedItemID )
1634 lastItem = pin;
1635 }
1636
1637 std::vector<SCH_FIELD*> fields;
1638 m_symbol->GetFields( fields );
1639
1640 for( SCH_FIELD* field : fields )
1641 {
1642 if( field->m_Uuid == lastBrightenedItemID )
1643 lastItem = field;
1644 }
1645 }
1646
1647 if( lastItem && lastItem != aItem )
1648 {
1649 lastItem->ClearBrightened();
1650
1651 UpdateItem( lastItem );
1652 lastBrightenedItemID = niluuid;
1653 }
1654
1655 if( aItem )
1656 {
1657 if( aItem->IsSCH_ITEM() )
1658 {
1659 SCH_ITEM* item = static_cast<SCH_ITEM*>( aItem );
1660
1661 if( int unit = item->GetUnit() )
1662 SetUnit( unit );
1663
1664 if( int bodyStyle = item->GetBodyStyle() )
1665 SetBodyStyle( bodyStyle );
1666 }
1667
1668 if( !aItem->IsBrightened() )
1669 {
1670 aItem->SetBrightened();
1671
1672 UpdateItem( aItem );
1673 lastBrightenedItemID = aItem->m_Uuid;
1674 }
1675
1676 FocusOnLocation( VECTOR2I( aItem->GetFocusPosition().x, aItem->GetFocusPosition().y ), aAllowScroll );
1677 }
1678}
1679
1680
1682{
1683 const std::string& payload = mail.GetPayload();
1684
1685 switch( mail.Command() )
1686 {
1687 case MAIL_LIB_EDIT:
1688 if( !payload.empty() )
1689 {
1690 wxString uri( payload );
1691 wxString libNickname;
1692 wxString msg;
1693
1695 std::optional<const LIBRARY_TABLE_ROW*> libTableRow = adapter->FindRowByURI( uri );
1696
1697 if( !libTableRow )
1698 {
1699 msg.Printf( _( "The current configuration does not include the symbol library '%s'." ),
1700 uri );
1701 msg += wxS( "\n" ) + _( "Use Manage Symbol Libraries to edit the configuration." );
1702 DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
1703 break;
1704 }
1705
1706 libNickname = ( *libTableRow )->Nickname();
1707
1708 if( !adapter->HasLibrary( libNickname, true ) )
1709 {
1710 msg.Printf( _( "The symbol library '%s' is not enabled in the current configuration." ),
1711 UnescapeString( libNickname ) );
1712 msg += wxS( "\n" ) + _( "Use Manage Symbol Libraries to edit the configuration." );
1713 DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg );
1714 break;
1715 }
1716
1717 SetCurLib( libNickname );
1718
1719 if( m_treePane )
1720 {
1721 LIB_ID id( libNickname, wxEmptyString );
1722 GetLibTree()->SelectLibId( id );
1723 GetLibTree()->ExpandLibId( id );
1724 GetLibTree()->CenterLibId( id );
1725 }
1726 }
1727
1728 break;
1729
1730 case MAIL_RELOAD_LIB:
1731 {
1732 wxString currentLib = GetCurLib();
1733
1735
1736 // Check if the currently selected symbol library been removed or disabled.
1737 if( !currentLib.empty()
1738 && !PROJECT_SCH::SymbolLibAdapter( &Prj() )->HasLibrary( currentLib, true ) )
1739 {
1740 SetCurLib( wxEmptyString );
1741 emptyScreen();
1742 }
1743
1744 SyncLibraries( true );
1747
1748 break;
1749 }
1750
1752 {
1754 LIB_SYMBOL* symbol = GetCurSymbol();
1755
1756 wxLogTrace( traceLibWatch, "Received refresh symbol request for %s", payload );
1757
1758 if( !symbol )
1759 break;
1760
1761 wxString libName = symbol->GetLibId().GetLibNickname();
1762 std::optional<const LIBRARY_TABLE_ROW*> row = adapter->GetRow( libName );
1763
1764 if( !row )
1765 return;
1766
1767 wxFileName libfullname( LIBRARY_MANAGER::GetFullURI( *row, true ) );
1768
1769 wxFileName changedLib( mail.GetPayload() );
1770
1771 wxLogTrace( traceLibWatch, "Received refresh symbol request for %s, current symbols is %s",
1772 changedLib.GetFullPath(), libfullname.GetFullPath() );
1773
1774 if( changedLib == libfullname )
1775 {
1776 wxLogTrace( traceLibWatch, "Refreshing symbol %s", symbol->GetName() );
1777
1778 SetScreen( m_dummyScreen ); // UpdateLibraryBuffer will destroy the old screen
1779 m_libMgr->UpdateLibraryBuffer( libName );
1780
1781 if( LIB_SYMBOL* lib_symbol = m_libMgr->GetBufferedSymbol( symbol->GetName(), libName ) )
1782 {
1783 // The buffered screen for the symbol
1784 SCH_SCREEN* symbol_screen = m_libMgr->GetScreen( lib_symbol->GetName(), libName );
1785
1786 SetScreen( symbol_screen );
1787 SetCurSymbol( new LIB_SYMBOL( *lib_symbol ), false );
1789
1790 if( m_toolManager )
1792 }
1793 }
1794
1795 break;
1796 }
1797
1798 default:
1799 break;
1800 }
1801}
1802
1803
1804std::unique_ptr<GRID_HELPER> SYMBOL_EDIT_FRAME::MakeGridHelper()
1805{
1806 return std::make_unique<EE_GRID_HELPER>( m_toolManager );
1807}
1808
1809
1811{
1812 // switches currently used canvas ( Cairo / OpenGL):
1813 SCH_BASE_FRAME::SwitchCanvas( aCanvasType );
1814
1815 // Set options specific to symbol editor (axies are always enabled):
1816 GetCanvas()->GetGAL()->SetAxesEnabled( true );
1818}
1819
1820
1822{
1823 wxCHECK( m_libMgr, false );
1824
1825 return m_libMgr->HasModifications();
1826}
1827
1828
1830{
1831 wxCHECK( m_libMgr, false );
1832
1833 // Test if the currently edited symbol is modified
1835 return true;
1836
1837 // Test if any library has been modified
1838 for( const wxString& libName : m_libMgr->GetLibraryNames() )
1839 {
1840 if( m_libMgr->IsLibraryModified( libName ) && !m_libMgr->IsLibraryReadOnly( libName ) )
1841 return true;
1842 }
1843
1844 return false;
1845}
1846
1847
1849{
1850 if( aItemCount == 0 )
1851 return;
1852
1853 UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
1854
1855 if( aItemCount < 0 )
1856 {
1857 list.ClearCommandList();
1858 }
1859 else
1860 {
1861 for( int ii = 0; ii < aItemCount; ii++ )
1862 {
1863 if( list.m_CommandsList.size() == 0 )
1864 break;
1865
1866 PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
1867 list.m_CommandsList.erase( list.m_CommandsList.begin() );
1868
1869 curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
1870 {
1871 delete aItem;
1872 } );
1873 delete curr_cmd; // Delete command
1874 }
1875 }
1876}
1877
1878
1880{
1881 return m_toolManager->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
1882}
1883
1884
1886{
1887 std::unique_ptr<LIB_SYMBOL> symbol = aSymbol->GetLibSymbolRef()->Flatten();
1888 wxCHECK( symbol, /* void */ );
1889
1890 symbol->SetLibId( aSymbol->GetLibId() );
1891
1892 // Take in account the symbol orientation and mirroring. to calculate the field
1893 // positions in symbol editor (i.e. no rotation, no mirroring)
1894 int orientation = aSymbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
1895 int mirror = aSymbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
1896
1897 std::vector<SCH_FIELD> fullSetOfFields;
1898
1899 for( const SCH_FIELD& field : aSymbol->GetFields() )
1900 {
1901 VECTOR2I pos = field.GetPosition() - aSymbol->GetPosition();
1902 SCH_FIELD libField( symbol.get(), field.GetId() );
1903
1904 libField = field;
1905
1906 // The inverse transform is mirroring before, rotate after
1907 switch( mirror )
1908 {
1909 case SYM_MIRROR_X: pos.y = -pos.y; break;
1910 case SYM_MIRROR_Y: pos.x = -pos.x; break;
1911 default: break;
1912 }
1913
1914 switch( orientation )
1915 {
1916 case SYM_ORIENT_90:
1917 std::swap( pos.x, pos.y );
1918 pos.x = - pos.x;
1919 break;
1920 case SYM_ORIENT_270:
1921 std::swap( pos.x, pos.y );
1922 pos.y = - pos.y;
1923 break;
1924 case SYM_ORIENT_180:
1925 pos.x = - pos.x;
1926 pos.y = - pos.y;
1927 break;
1928 default:
1929 break;
1930 }
1931
1932 libField.SetPosition( pos );
1933
1934 fullSetOfFields.emplace_back( std::move( libField ) );
1935 }
1936
1937 symbol->SetFields( fullSetOfFields );
1938
1939 if( m_symbol )
1940 SetCurSymbol( nullptr, false );
1941
1943 m_schematicSymbolUUID = aSymbol->m_Uuid;
1944 m_reference = symbol->GetReferenceField().GetText();
1945 m_unit = std::max( 1, aSymbol->GetUnit() );
1946 m_bodyStyle = std::max( 1, aSymbol->GetBodyStyle() );
1947
1948 // Optimize default edit options for this symbol
1949 // Usually if units are locked, graphic items are specific to each unit
1950 // and if units are interchangeable, graphic items are common to units
1952 tools->SetDrawSpecificUnit( symbol->UnitsLocked() );
1953
1954 // The buffered screen for the symbol
1955 SCH_SCREEN* tmpScreen = new SCH_SCREEN();
1956
1957 SetScreen( tmpScreen );
1958 SetCurSymbol( symbol.release(), true );
1959 setSymWatcher( nullptr );
1960
1963
1964 if( IsLibraryTreeShown() )
1966
1967 UpdateTitle();
1970
1971 // Let tools add things to the view if necessary
1972 if( m_toolManager )
1974
1976 GetCanvas()->Refresh();
1977}
1978
1979
1980bool SYMBOL_EDIT_FRAME::addLibTableEntry( const wxString& aLibFile, LIBRARY_TABLE_SCOPE aScope )
1981{
1982 wxFileName fn = aLibFile;
1983 wxFileName libTableFileName( Prj().GetProjectPath(), FILEEXT::SymbolLibraryTableFileName );
1984 wxString libNickname = fn.GetName();
1986 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
1987 const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
1988
1989 if( adapter->HasLibrary( libNickname ) )
1990 {
1991 wxString tmp;
1992 int suffix = 1;
1993
1994 while( adapter->HasLibrary( libNickname ) )
1995 {
1996 tmp.Printf( "%s%d", fn.GetName(), suffix );
1997 libNickname = tmp;
1998 suffix += 1;
1999 }
2000 }
2001
2002 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, aScope );
2003 wxCHECK( optTable.has_value(), false );
2004 LIBRARY_TABLE* table = optTable.value();
2005
2006 LIBRARY_TABLE_ROW* row = &table->InsertRow();
2007
2008 row->SetNickname( libNickname );
2009
2010 // We cannot normalize against the current project path when saving to global table.
2011 wxString normalizedPath = NormalizePath( aLibFile, &envVars,
2012 aScope == LIBRARY_TABLE_SCOPE::PROJECT ? Prj().GetProjectPath()
2013 : wxString( wxEmptyString ) );
2014
2015 row->SetURI( normalizedPath );
2017
2018 bool success = true;
2019
2020 table->Save().map_error(
2021 [&]( const LIBRARY_ERROR& aError )
2022 {
2023 KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ),
2024 wxOK | wxICON_ERROR );
2025 dlg.SetExtendedMessage( aError.message );
2026 dlg.ShowModal();
2027
2028 success = false;
2029 } );
2030
2031 if( success )
2032 {
2033 manager.ReloadTables( aScope, { LIBRARY_TABLE_TYPE::SYMBOL } );
2034 adapter->LoadOne( libNickname );
2035 }
2036
2037 return success;
2038}
2039
2040
2041bool SYMBOL_EDIT_FRAME::replaceLibTableEntry( const wxString& aLibNickname, const wxString& aLibFile )
2042{
2044 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
2045 LIBRARY_TABLE* table = nullptr;
2047
2048 // Check the global library table first because checking the project library table
2049 // checks the global library table as well due to library chaining.
2050 if( adapter->GetRow( aLibNickname, scope ) )
2051 {
2052 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, scope );
2053 wxCHECK( optTable.has_value(), false );
2054 table = optTable.value();
2055 }
2056 else
2057 {
2059
2060 if( adapter->GetRow( aLibNickname, scope ) )
2061 {
2062 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, scope );
2063
2064 if( optTable.has_value() )
2065 table = optTable.value();
2066 }
2067 }
2068
2069 wxCHECK( table, false );
2070
2071 std::optional<LIBRARY_TABLE_ROW*> optRow = adapter->GetRow( aLibNickname, scope );
2072 wxCHECK( optRow.has_value(), false );
2073 LIBRARY_TABLE_ROW* row = optRow.value();
2074
2075 const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
2076
2077 wxString projectPath;
2078
2079 if( scope == LIBRARY_TABLE_SCOPE::PROJECT )
2080 projectPath = Prj().GetProjectPath();
2081
2082 wxString normalizedPath = NormalizePath( aLibFile, &envVars, projectPath );
2083
2084 row->SetURI( normalizedPath );
2085 row->SetType( "KiCad" );
2086
2087 bool success = true;
2088
2089 table->Save().map_error(
2090 [&]( const LIBRARY_ERROR& aError )
2091 {
2092 KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ),
2093 wxOK | wxICON_ERROR );
2094 dlg.SetExtendedMessage( aError.message );
2095 dlg.ShowModal();
2096
2097 success = false;
2098 } );
2099
2100 if( success )
2101 {
2102 manager.ReloadTables( scope, { LIBRARY_TABLE_TYPE::SYMBOL } );
2103 adapter->LoadOne( aLibNickname );
2104 }
2105
2106 return success;
2107}
2108
2109
2111{
2112 return m_symbol && !m_symbol->IsRoot();
2113}
2114
2115
2120
2121
2122void SYMBOL_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2123{
2124 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2125
2126 if( EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( aItem ) )
2127 {
2128 eda_text->ClearBoundingBoxCache();
2129 eda_text->ClearRenderCache();
2130 }
2131}
2132
2133
2135{
2136 wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
2137 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
2138 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
2139
2140 // Don't give the selection filter its own visibility controls; instead show it if
2141 // anything else is visible
2142 bool showFilter = ( treePane.IsShown() && treePane.IsDocked() )
2143 || ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
2144
2145 selectionFilterPane.Show( showFilter );
2146}
2147
2148
2150{
2151 // Returns the current render option for invisible fields
2153}
2154
2155
2157{
2158 // Returns the current render option for invisible pins
2160}
BASE_SCREEN class implementation.
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
@ icon_libedit_32
@ icon_libedit_16
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
BOX2< VECTOR2D > BOX2D
Definition box2.h:923
static TOOL_ACTION toggleGrid
Definition actions.h:198
static TOOL_ACTION paste
Definition actions.h:80
static TOOL_ACTION cancelInteractive
Definition actions.h:72
static TOOL_ACTION unselectAll
Definition actions.h:83
static TOOL_ACTION revert
Definition actions.h:62
static TOOL_ACTION showLibraryTree
Definition actions.h:164
static TOOL_ACTION copy
Definition actions.h:78
static TOOL_ACTION showDatasheet
Definition actions.h:267
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:157
static TOOL_ACTION saveAll
Definition actions.h:61
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION duplicate
Definition actions.h:84
static TOOL_ACTION doDelete
Definition actions.h:85
static TOOL_ACTION selectionTool
Definition actions.h:251
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:142
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:146
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:224
static TOOL_ACTION showProperties
Definition actions.h:266
static TOOL_ACTION cut
Definition actions.h:77
static TOOL_ACTION ddAddLibrary
Definition actions.h:67
static TOOL_ACTION copyAsText
Definition actions.h:79
static TOOL_ACTION toggleGridOverrides
Definition actions.h:199
static TOOL_ACTION selectAll
Definition actions.h:82
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.
wxString m_ColorTheme
Active color theme name.
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
constexpr void SetOrigin(const Vec &pos)
Definition box2.h:237
constexpr void SetSize(const SizeVec &size)
Definition box2.h:248
Color settings are a bit different than most of the settings objects in that there can be more than o...
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
UNDO_REDO_CONTAINER m_undoList
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
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
Specify whether we are interacting with the undo or redo stacks.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
ACTION_TOOLBAR * m_tbRight
TOOLBAR_SETTINGS * m_toolbarSettings
wxAuiManager m_auimgr
virtual void RecreateToolbars()
UNDO_REDO_CONTAINER m_redoList
ACTION_TOOLBAR * m_tbLeft
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handle event fired when a file is dropped to the window.
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
ACTION_TOOLBAR * m_tbTopMain
wxString m_aboutTitle
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
void ReCreateMenuBar()
Recreate the menu bar.
WX_INFOBAR * GetInfoBar()
COLOR_SETTINGS * m_colorSettings
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void setupUnits(APP_SETTINGS_BASE *aCfg)
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Change the current rendering backend.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual void resolveCanvasType()
Determine the canvas type to load (with prompt if required) and initializes m_canvasType.
static const wxString PropertiesPaneName()
EDA_MSG_PANEL * m_messagePanel
virtual void SetScreen(BASE_SCREEN *aScreen)
bool LibraryFileBrowser(const wxString &aTitle, bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory, FILEDLG_HOOK_NEW_LIBRARY *aFileDlgHook=nullptr)
void FocusOnLocation(const VECTOR2I &aPos, bool aAllowScroll=true)
Useful to focus on a particular location, in find functions.
PROPERTIES_PANEL * m_propertiesPanel
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.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:99
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition() but allows items to return their visual center rather than their anchor.
Definition eda_item.h:285
const KIID m_Uuid
Definition eda_item.h:527
void ClearBrightened()
Definition eda_item.h:144
void SetBrightened()
Definition eda_item.h:141
bool IsBrightened() const
Definition eda_item.h:130
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:80
Class that groups generic conditions for editor states.
SELECTION_CONDITION NoActiveTool()
Create a functor testing if there are no tools active in the frame.
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.
virtual SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION GridOverrides()
Create a functor testing if the grid overrides wires is enabled in a frame.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition kidialog.h:42
int ShowModal() override
Definition kidialog.cpp:93
bool m_axesEnabled
Crosshair drawing mode.
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
void SetDefaultFont(const wxString &aFont)
void HideDrawingSheet()
Definition sch_view.cpp:206
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition sch_view.cpp:194
bool IsSCH_ITEM() const
Definition view_item.h:101
void Clear()
Remove all items from the view.
Definition view.cpp:1151
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition view.cpp:1584
Definition kiid.h:49
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition kiway_mail.h:38
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition kiway_mail.h:56
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition kiway_mail.h:48
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:295
void OnKiCadExit()
Definition kiway.cpp:760
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:407
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr, bool aFromOtherThread=false)
Send aPayload to aDestination from aSource.
Definition kiway.cpp:505
Module editor specific tools.
std::optional< LIBRARY_TABLE_ROW * > FindRowByURI(const wxString &aUri, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
Like LIBRARY_MANAGER::FindRowByURI but filtered to the LIBRARY_TABLE_TYPE of this adapter.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library tables.
std::optional< LIBRARY_TABLE_ROW * > GetRow(const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
Like LIBRARY_MANAGER::GetRow but filtered to the LIBRARY_TABLE_TYPE of this adapter.
void ReloadTables(LIBRARY_TABLE_SCOPE aScope, std::initializer_list< LIBRARY_TABLE_TYPE > aTablesToLoad={})
std::optional< LIBRARY_TABLE * > Table(LIBRARY_TABLE_TYPE aType, LIBRARY_TABLE_SCOPE aScope)
Retrieves a given table; creating a new empty project table if a valid project is loaded and the give...
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
void SetNickname(const wxString &aNickname)
void SetType(const wxString &aType)
void SetURI(const wxString &aUri)
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
const UTF8 & GetLibItemName() const
Definition lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition lib_id.h:87
Symbol library management helper that is specific to the symbol library editor frame.
Define a library symbol object.
Definition lib_symbol.h:83
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:152
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition lib_symbol.h:287
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition lib_symbol.h:199
wxString GetName() const override
Definition lib_symbol.h:145
bool IsMultiUnit() const override
Definition lib_symbol.h:770
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Node type: LIB_ID.
void Update(LIB_TREE_ITEM *aItem)
Update the node using data from a LIB_ALIAS object.
void RefreshLibTree()
Refresh the tree (mainly to update highlighting and asterisking)
Definition lib_tree.cpp:472
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
Definition lib_tree.cpp:381
int GetSelectionCount() const
Definition lib_tree.h:92
void ShutdownPreviews()
Definition lib_tree.cpp:287
void ShowChangedLanguage()
Definition lib_tree.cpp:304
void FocusSearchFieldIfExists()
Focus the search widget if it exists.
Definition lib_tree.cpp:487
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition lib_tree.cpp:375
LIB_TREE_MODEL_ADAPTER::SORT_MODE GetSortMode() const
Definition lib_tree.h:156
int GetSelectedLibIds(std::vector< LIB_ID > &aSelection, std::vector< int > *aUnit=nullptr) const
Retrieve a list of selections for trees that allow multi-selection.
Definition lib_tree.cpp:334
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition lib_tree.cpp:387
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:314
void ExpandLibId(const LIB_ID &aLibId)
Expand and item i the tree widget.
Definition lib_tree.cpp:395
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition lib_tree.cpp:454
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
Definition pgm_base.cpp:793
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:131
virtual LIBRARY_MANAGER & GetLibraryManager() const
Definition pgm_base.h:133
A holder to handle information on schematic or board items.
void ClearListAndDeleteItems(std::function< void(EDA_ITEM *)> aItemDeleter)
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
@ SCH_LIBEDIT_CUR_LIB
Definition project.h:221
@ SCH_LIBEDIT_CUR_SYMBOL
Definition project.h:222
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition project.cpp:177
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:349
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:360
Action handler for the Properties panel.
Gather all the actions that are shared by tools.
Definition sch_actions.h:40
static TOOL_ACTION rotateCCW
static TOOL_ACTION importSymbol
static TOOL_ACTION newSymbol
static TOOL_ACTION saveLibraryAs
static TOOL_ACTION mirrorV
static TOOL_ACTION editLibSymbolWithLibEdit
static TOOL_ACTION drawArc
Definition sch_actions.h:97
static TOOL_ACTION pinTable
static TOOL_ACTION drawSymbolLines
static TOOL_ACTION placeSymbolPin
static TOOL_ACTION drawSymbolTextBox
static TOOL_ACTION drawRectangle
Definition sch_actions.h:95
static TOOL_ACTION drawCircle
Definition sch_actions.h:96
static TOOL_ACTION importGraphics
static TOOL_ACTION drawBezier
Definition sch_actions.h:98
static TOOL_ACTION saveSymbolCopyAs
static TOOL_ACTION rotateCW
static TOOL_ACTION showElectricalTypes
static TOOL_ACTION drawSymbolPolygon
static TOOL_ACTION showHiddenFields
static TOOL_ACTION placeSymbolAnchor
static TOOL_ACTION showHiddenPins
static TOOL_ACTION cycleBodyStyle
static TOOL_ACTION mirrorH
static TOOL_ACTION runERC
Inspection and Editing.
static TOOL_ACTION symbolProperties
static TOOL_ACTION placeSymbolText
static TOOL_ACTION toggleSyncedPinsMode
static TOOL_ACTION togglePinAltIcons
static TOOL_ACTION updateSymbolFields
static TOOL_ACTION saveSymbolAs
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
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.
SYMBOL_EDITOR_SETTINGS * libeditconfig() const
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.
void SyncView()
Mark all items for refresh.
PANEL_SCH_SELECTION_FILTER * m_selectionFilterPanel
virtual void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
void setSymWatcher(const LIB_ID *aSymbol)
Creates (or removes) a watcher on the specified symbol library.
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.
void SetPosition(const VECTOR2I &aPosition) override
Handle actions specific to the schematic editor.
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
int GetBodyStyle() const
Definition sch_item.h:248
int GetUnit() const
Definition sch_item.h:239
Tool that displays edit points allowing to modify items by dragging the points.
SCH_SELECTION & GetSelection()
SCH_SELECTION_FILTER_OPTIONS & GetFilter()
Schematic symbol object.
Definition sch_symbol.h:76
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
VECTOR2I GetPosition() const override
Definition sch_symbol.h:867
const LIB_ID & GetLibId() const override
Definition sch_symbol.h:165
int GetOrientation() const override
Get the display symbol orientation.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:184
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).
Handle actions for the various symbol editor and viewers.
bool m_ShowPinAltIcons
When true, dragging an outline edge will drag pins rooted on it.
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.
std::unique_ptr< GRID_HELPER > MakeGridHelper() override
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
APP_SETTINGS_BASE * config() const override
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void storeCurrentSymbol()
Rename LIB_SYMBOL aliases to avoid conflicts before adding a symbol to a library.
bool IsLibraryTreeShown() const override
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Return bounding box 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.
void OnSelectBodyStyle(wxCommandEvent &event)
bool backupFile(const wxFileName &aOriginalFile, const wxString &aBackupExt)
Return currently edited symbol.
void RefreshLibraryTree()
Redisplay the library tree.
void updateSelectionFilterVisbility() override
Selection filter panel doesn't have a dedicated visibility control, so show it if any other AUI panel...
void CommonSettingsChanged(int aFlags) override
Called after the preferences dialog is run.
void FocusLibraryTreeInput() override
wxComboBox * m_unitSelectBox
void RebuildSymbolUnitAndBodyStyleLists()
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.
void FocusOnLibId(const LIB_ID &aLibID)
bool IsSymbolAlias() const
Return true if aLibId is an alias for the editor screen symbol.
void ToggleProperties() override
SYMBOL_EDITOR_SETTINGS * m_settings
void HardRedraw() override
Rebuild the GAL and redraw the screen.
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
int GetTreeSelectionCount() const
bool addLibTableEntry(const wxString &aLibFile, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::GLOBAL)
Add aLibFile to the symbol library table defined by aScope.
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 SetScreen(BASE_SCREEN *aScreen) override
void KiwayMailIn(KIWAY_MAIL_EVENT &mail) override
Receive #KIWAY_ROUTED_EVENT messages from other players.
SYMBOL_EDITOR_SETTINGS * GetSettings() const
SCH_SCREEN * m_dummyScreen
< Helper screen used when no symbol is loaded
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)
SYMBOL_EDIT_FRAME(KIWAY *aKiway, wxWindow *aParent)
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
std::vector< LIB_ID > GetSelectedLibIds() 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 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
LIB_ID GetTargetLibId() const override
Return either the symbol selected in the symbol tree (if context menu is active) or the symbol on the...
void SetBodyStyle(int aBodyStyle)
int m_bodyStyle
Flag if the symbol being edited was loaded directly from a schematic.
bool saveAllLibraries(bool aRequireConfirmation)
Save the current symbol.
void UpdateMsgPanel() override
Redraw the message panel.
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from aList element.
LIB_TREE * GetLibTree() const override
wxString SetCurLib(const wxString &aLibNickname)
Set the current library nickname and returns the old library nickname.
void UpdateTitle()
Update the main window title bar with the current library name and read only status of the library.
bool LoadSymbolFromCurrentLib(const wxString &aSymbolName, int aUnit=0, int aBodyStyle=0)
Load a symbol from the current active library, optionally setting the selected unit and convert.
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 OnUpdateBodyStyle(wxUpdateUIEvent &event)
void SaveSymbolCopyAs(bool aOpenCopy)
Save the currently selected symbol to a new name and/or location.
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 FocusOnItem(EDA_ITEM *aItem, bool aAllowScroll=true) override
Focus on a particular canvas item.
void configureToolbars() override
void CloseWindow(wxCommandEvent &event)
Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:
wxComboBox * m_bodyStyleSelectBox
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 ShowChangedLanguage() override
Redraw the menus and what not in current language.
void SaveLibraryAs()
Save the currently selected library to a new file.
bool IsContentModified() const override
Get if any symbols or libraries have been modified but not saved.
void ToggleLibraryTree() override
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)
An interface to the global shared library manager that is schematic-specific and linked to one projec...
std::optional< LIB_STATUS > LoadOne(LIB_DATA *aLib) override
Loads or reloads the given library, if it exists.
Library Editor pane with symbol tree and symbol library table selector.
Rate-limiter that fires at most once per interval.
Definition throttle.h:35
bool Ready()
Definition throttle.h:48
TOOL_MANAGER * m_toolManager
TOOL_DISPATCHER * m_toolDispatcher
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
ACTIONS * m_actions
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
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:
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
A holder to handle a list of undo (or redo) commands.
bool empty() const
Definition utf8.h:109
A modified version of the wxInfoBar class that allows us to:
Definition wx_infobar.h:77
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:202
int UnsavedChangesDialog(wxWindow *parent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition confirm.cpp:64
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:177
This file is part of the common library.
#define KICAD_MESSAGE_DIALOG
Definition confirm.h:52
#define CHECK(x)
#define ENABLE(x)
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:65
@ ID_LIBEDIT_SELECT_BODY_STYLE
Definition eeschema_id.h:66
const wxAuiPaneInfo & defaultSchSelectionFilterPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultPropertiesPaneInfo(wxWindow *aWindow)
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:73
Helper functions to substitute paths with environmental variables.
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:35
@ FRAME_SCH
Definition frame_type.h:34
static const std::string SymbolLibraryTableFileName
static const std::string KiCadSymbolLibFileExtension
static wxString KiCadSymbolLibFileWildcard()
const wxChar *const traceLibWatch
Flag to enable debug output for library file watch refreshes.
@ ID_ON_GRID_SELECT
Definition id.h:116
@ ID_ON_ZOOM_SELECT
Definition id.h:115
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
PROJECT & Prj()
Definition kicad.cpp:642
KIID niluuid(0)
@ LAYER_SCHEMATIC_GRID_AXES
Definition layer_ids.h:487
LIBRARY_TABLE_SCOPE
@ MAIL_LIB_EDIT
Definition mail_type.h:55
@ MAIL_REFRESH_SYMBOL
Definition mail_type.h:59
@ MAIL_RELOAD_LIB
Definition mail_type.h:57
@ ALL
All except INITIAL_ADD.
Definition view_item.h:59
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition unix/app.cpp:97
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition unix/app.cpp:86
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:100
#define _HKI(x)
Definition page_info.cpp:44
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...
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
#define DEFAULT_THEME
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
KIWAY Kiway(KFCTL_STANDALONE)
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 ...
wxString message
@ SYM_ORIENT_270
Definition symbol.h:42
@ SYM_MIRROR_Y
Definition symbol.h:44
@ SYM_ORIENT_180
Definition symbol.h:41
@ SYM_MIRROR_X
Definition symbol.h:43
@ SYM_ORIENT_90
Definition symbol.h:40
#define EDIT_TOOL(tool)
#define DEMORGAN_ALT
#define DEMORGAN_STD
KIBIS_PIN * pin
#define ENVVARS_CHANGED
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
VECTOR2< double > VECTOR2D
Definition vector2d.h:694
Definition of file extensions used in Kicad.
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.