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;
135 m_aboutTitle = _HKI( "KiCad Symbol Editor" );
136
137 wxIcon icon;
138 wxIconBundle icon_bundle;
139
140 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit, 48 ) );
141 icon_bundle.AddIcon( icon );
142 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit, 256 ) );
143 icon_bundle.AddIcon( icon );
144 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit, 128 ) );
145 icon_bundle.AddIcon( icon );
146 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit_32 ) );
147 icon_bundle.AddIcon( icon );
148 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit_16 ) );
149 icon_bundle.AddIcon( icon );
150
151 SetIcons( icon_bundle );
152
155
157
158 m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
159 m_treePane->GetLibTree()->SetSortMode( (LIB_TREE_MODEL_ADAPTER::SORT_MODE) m_settings->m_LibrarySortMode );
160
163
164 // Ensure axis are always drawn
166 gal_opts.m_axesEnabled = true;
167
170 GetScreen()->m_Center = true;
171
172 GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
173
174 GetRenderSettings()->LoadColors( GetColorSettings() );
175 GetRenderSettings()->m_IsSymbolEditor = true;
176 GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
177
178 setupTools();
180
182
186
187 UpdateTitle();
190
191 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
192 m_propertiesPanel->SetSplitterProportion( m_settings->m_AuiPanels.properties_splitter );
193
195
196 m_auimgr.SetManagedWindow( this );
197
199
200 // Rows; layers 4 - 6
201 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( "TopMainToolbar" )
202 .Top().Layer( 6 ) );
203
204 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
205 .Bottom().Layer( 6 ) );
206
207 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( "LeftToolbar" )
208 .Left().Layer( 2 ) );
209
210 m_auimgr.AddPane( m_tbRight, EDA_PANE().VToolbar().Name( "RightToolbar" )
211 .Right().Layer( 2 ) );
212
213 // Center
214 m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" )
215 .CentrePane() );
216
217 // Columns; layers 1 - 3
218 m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "LibraryTree" )
219 .Left().Layer( 3 )
220 .TopDockable( false ).BottomDockable( false )
221 .Caption( _( "Libraries" ) )
222 // Don't use -1 for don't-change-height on a growable panel; it has side-effects.
223 .MinSize( FromDIP( 250 ), FromDIP( 80 ) )
224 .BestSize( FromDIP( 250 ), -1 ) );
225
228
229 // Can be called only when all panes are created, because (at least on Windows) when items
230 // managed by m_auimgr are not the same as those existing when saved by Perspective()
231 // in config, broken settings can happen.
233
234 // Protect against broken saved Perspective() due to bugs in previous version
235 // This is currently a workaround.
236 m_auimgr.GetPane( "TopMainToolbar" ).Top().Layer( 6 ).Position(0).Show( true );
237 m_auimgr.GetPane( "LeftToolbar" ).Position(0).Show( true );
238 m_auimgr.GetPane( "RightToolbar" ).Show( true );
239
240 // Show or hide m_propertiesPanel depending on current settings:
241 wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
242 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
243 // The selection filter doesn't need to grow in the vertical direction when docked
244 selectionFilterPane.dock_proportion = 0;
245
246 propertiesPaneInfo.Show( m_settings->m_AuiPanels.show_properties );
248
250
251 // Can't put this in LoadSettings, because it has to be called before setupTools :/
253 selTool->GetFilter() = GetSettings()->m_SelectionFilter;
254 m_selectionFilterPanel->SetCheckboxesFromFilter( selTool->GetFilter() );
255
256 if( m_settings->m_LibWidth > 0 )
257 SetAuiPaneSize( m_auimgr, m_auimgr.GetPane( "LibraryTree" ), m_settings->m_LibWidth, -1 );
258
259 Raise();
260 Show( true );
261
262 SyncView();
263 GetCanvas()->GetView()->UseDrawPriority( true );
264 GetCanvas()->GetGAL()->SetAxesEnabled( true );
265
267
268 // Set the working/draw area size to display a symbol to a reasonable value:
269 // A 600mm x 600mm with a origin at the area center looks like a large working area
270 double max_size_x = schIUScale.mmToIU( 600 );
271 double max_size_y = schIUScale.mmToIU( 600 );
272 BOX2D bbox;
273 bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
274 bbox.SetSize( max_size_x, max_size_y );
275 GetCanvas()->GetView()->SetBoundary( bbox );
276
278
280 DragAcceptFiles( true );
281
282 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Library changes are unsaved" ) );
283
284 // Catch unhandled accelerator command characters that were no handled by the library tree
285 // panel.
287 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
288
289 // Ensure the window is on top
290 Raise();
291
292 // run SyncLibraries with progress reporter enabled. The progress reporter is useful
293 // in debug mode because the loading time of ecah library can be really noticeable
294 SyncLibraries( true );
295}
296
297
299{
300 // Shutdown all running tools
301 if( m_toolManager )
302 m_toolManager->ShutdownAllTools();
303
304 setSymWatcher( nullptr );
305
307 {
308 delete m_symbol;
309 m_symbol = nullptr;
310
311 SCH_SCREEN* screen = GetScreen();
312 delete screen;
314 }
315
316 // current screen is destroyed in EDA_DRAW_FRAME
318
320 Pgm().GetSettingsManager().Save( cfg );
321
322 delete m_libMgr;
323}
324
325
327{
328 wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_settings" );
329
331
332 GetRenderSettings()->m_ShowPinsElectricalType = m_settings->m_ShowPinElectricalType;
333 GetRenderSettings()->m_ShowHiddenPins = m_settings->m_ShowHiddenPins;
334 GetRenderSettings()->m_ShowHiddenFields = m_settings->m_ShowHiddenFields;
335 GetRenderSettings()->m_ShowPinAltIcons = m_settings->m_ShowPinAltIcons;
336 GetRenderSettings()->SetDefaultFont( wxEmptyString );
337}
338
339
341{
342 wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME:SaveSettings with null m_settings" );
343
345
347
348 m_settings->m_ShowPinElectricalType = GetRenderSettings()->m_ShowPinsElectricalType;
349 m_settings->m_ShowHiddenPins = GetRenderSettings()->m_ShowHiddenPins;
350 m_settings->m_ShowHiddenFields = GetRenderSettings()->m_ShowHiddenFields;
351 m_settings->m_ShowPinAltIcons = GetRenderSettings()->m_ShowPinAltIcons;
352
353 m_settings->m_LibWidth = m_treePane->GetSize().x;
354
355 m_settings->m_LibrarySortMode = GetLibTree()->GetSortMode();
356
357 m_settings->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
358 bool prop_shown = m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
359 m_settings->m_AuiPanels.show_properties = prop_shown;
360
361 if( TOOL_MANAGER* toolMgr = GetToolManager() )
362 {
363 if( SCH_SELECTION_TOOL* selTool = toolMgr->GetTool<SCH_SELECTION_TOOL>() )
364 m_settings->m_SelectionFilter = selTool->GetFilter();
365 }
366}
367
368
370{
371 return static_cast<APP_SETTINGS_BASE*>( GetSettings() );
372}
373
374
376{
378
379 if( cfg && static_cast<SYMBOL_EDITOR_SETTINGS*>( cfg )->m_UseEeschemaColorSettings )
380 cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
381
382 return ::GetColorSettings( cfg ? cfg->m_ColorTheme : DEFAULT_THEME );
383}
384
385
387{
388 // Create the manager and dispatcher & route draw panel events to the dispatcher
390 m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
391 GetCanvas()->GetViewControls(), GetSettings(), this );
392 m_actions = new SCH_ACTIONS();
394
395 // Register tools
396 m_toolManager->RegisterTool( new COMMON_CONTROL );
397 m_toolManager->RegisterTool( new COMMON_TOOLS );
398 m_toolManager->RegisterTool( new ZOOM_TOOL );
399 m_toolManager->RegisterTool( new SCH_SELECTION_TOOL );
400 m_toolManager->RegisterTool( new PICKER_TOOL );
401 m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL );
402 m_toolManager->RegisterTool( new SYMBOL_EDITOR_PIN_TOOL );
403 m_toolManager->RegisterTool( new SYMBOL_EDITOR_DRAWING_TOOLS );
404 m_toolManager->RegisterTool( new SCH_POINT_EDITOR );
405 m_toolManager->RegisterTool( new SCH_FIND_REPLACE_TOOL );
406 m_toolManager->RegisterTool( new SYMBOL_EDITOR_MOVE_TOOL );
407 m_toolManager->RegisterTool( new SYMBOL_EDITOR_EDIT_TOOL );
408 m_toolManager->RegisterTool( new LIBRARY_EDITOR_CONTROL );
409 m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL );
410 m_toolManager->RegisterTool( new PROPERTIES_TOOL );
411 m_toolManager->RegisterTool( new EMBED_TOOL );
412 m_toolManager->InitTools();
413
414 // Run the selection tool, it is supposed to be always active
415 m_toolManager->InvokeTool( "common.InteractiveSelection" );
416
418}
419
420
422{
424
425 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
426 EDITOR_CONDITIONS cond( this );
427
428 wxASSERT( mgr );
429
430#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
431#define CHECK( x ) ACTION_CONDITIONS().Check( x )
432
433 auto haveSymbolCond =
434 [this]( const SELECTION& )
435 {
436 return m_symbol;
437 };
438
439 auto isEditableCond =
440 [this]( const SELECTION& )
441 {
442 // Only root symbols from the new s-expression libraries or the schematic
443 // are editable.
444 return IsSymbolEditable() && !IsSymbolAlias();
445 };
446
447 auto isEditableInAliasCond =
448 [this]( const SELECTION& )
449 {
450 // Less restrictive than isEditableCond
451 // Symbols fields (root symbols and aliases) from the new s-expression libraries
452 // or in the schematic are editable.
453 return IsSymbolEditable();
454 };
455
456 auto symbolModifiedCondition =
457 [this]( const SELECTION& sel )
458 {
459 return m_libMgr && m_libMgr->IsSymbolModified( GetTargetLibId().GetLibItemName(),
460 GetTargetLibId().GetLibNickname() );
461 };
462
463 auto libSelectedCondition =
464 [this]( const SELECTION& sel )
465 {
466 return !GetTargetLibId().GetLibNickname().empty();
467 };
468
469 auto canEditProperties =
470 [this]( const SELECTION& sel )
471 {
473 };
474
475 auto symbolSelectedInTreeCondition =
476 [this]( const SELECTION& sel )
477 {
478 LIB_ID targetLibId = GetTargetLibId();
479 return !targetLibId.GetLibNickname().empty() && !targetLibId.GetLibItemName().empty();
480 };
481
482 auto saveSymbolAsCondition =
483 [this]( const SELECTION& aSel )
484 {
485 return getTargetSymbol() != nullptr;
486 };
487
488 const auto isSymbolFromSchematicCond =
489 [this]( const SELECTION& )
490 {
491 return IsSymbolFromSchematic();
492 };
493
494 // clang-format off
497 mgr->SetConditions( SCH_ACTIONS::saveLibraryAs, ENABLE( libSelectedCondition ) );
498 mgr->SetConditions( SCH_ACTIONS::saveSymbolAs, ENABLE( saveSymbolAsCondition ) );
499 mgr->SetConditions( SCH_ACTIONS::saveSymbolCopyAs, ENABLE( saveSymbolAsCondition ) );
502 mgr->SetConditions( SCH_ACTIONS::editLibSymbolWithLibEdit, ENABLE( isSymbolFromSchematicCond ) );
503
504 mgr->SetConditions( ACTIONS::undo, ENABLE( haveSymbolCond && cond.UndoAvailable() ) );
505 mgr->SetConditions( ACTIONS::redo, ENABLE( haveSymbolCond && cond.RedoAvailable() ) );
506 mgr->SetConditions( ACTIONS::revert, ENABLE( symbolModifiedCondition ) );
507
510
511 mgr->SetConditions( ACTIONS::cut, ENABLE( isEditableCond ) );
512 mgr->SetConditions( ACTIONS::copy, ENABLE( haveSymbolCond ) );
513 mgr->SetConditions( ACTIONS::copyAsText, ENABLE( haveSymbolCond ) );
514 mgr->SetConditions( ACTIONS::paste, ENABLE( isEditableCond &&
516 mgr->SetConditions( ACTIONS::doDelete, ENABLE( isEditableCond ) );
517 mgr->SetConditions( ACTIONS::duplicate, ENABLE( isEditableCond ) );
518 mgr->SetConditions( ACTIONS::selectAll, ENABLE( haveSymbolCond ) );
519 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( haveSymbolCond ) );
520
521 // These actions in symbol editor when editing alias field rotations are allowed.
522 mgr->SetConditions( SCH_ACTIONS::rotateCW, ENABLE( isEditableInAliasCond ) );
523 mgr->SetConditions( SCH_ACTIONS::rotateCCW, ENABLE( isEditableInAliasCond ) );
524
525 mgr->SetConditions( SCH_ACTIONS::mirrorH, ENABLE( isEditableCond ) );
526 mgr->SetConditions( SCH_ACTIONS::mirrorV, ENABLE( isEditableCond ) );
527
530 // clang-format on
531
532 auto pinTypeCond =
533 [this]( const SELECTION& )
534 {
536 };
537
538 auto hiddenPinCond =
539 [this]( const SELECTION& )
540 {
542 };
543
544 auto hiddenFieldCond =
545 [this]( const SELECTION& )
546 {
548 };
549
550 auto showPinAltIconsCond =
551 [this]( const SELECTION& )
552 {
554 };
555
556 auto showLibraryTreeCond =
557 [this]( const SELECTION& )
558 {
559 return IsLibraryTreeShown();
560 };
561
562 auto propertiesCond =
563 [this] ( const SELECTION& )
564 {
565 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
566 };
567
570 mgr->SetConditions( ACTIONS::showLibraryTree, CHECK( showLibraryTreeCond ) );
571 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
572 mgr->SetConditions( SCH_ACTIONS::showHiddenPins, CHECK( hiddenPinCond ) );
573 mgr->SetConditions( SCH_ACTIONS::showHiddenFields, CHECK( hiddenFieldCond ) );
574 mgr->SetConditions( SCH_ACTIONS::togglePinAltIcons, CHECK( showPinAltIconsCond ) );
575
576 auto multiUnitModeCond =
577 [this]( const SELECTION& )
578 {
579 return m_symbol && m_symbol->IsMultiUnit() && !m_symbol->UnitsLocked();
580 };
581
582 auto multiBodyStyleModeCond =
583 [this]( const SELECTION& )
584 {
585 return m_symbol && m_symbol->IsMultiBodyStyle();
586 };
587
588 auto syncedPinsModeCond =
589 [this]( const SELECTION& )
590 {
591 return m_SyncPinEdit;
592 };
593
594 auto haveDatasheetCond =
595 [this]( const SELECTION& )
596 {
597 return m_symbol && !m_symbol->GetDatasheetField().GetText().IsEmpty();
598 };
599
600 mgr->SetConditions( ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
601 mgr->SetConditions( SCH_ACTIONS::symbolProperties, ENABLE( symbolSelectedInTreeCondition || ( canEditProperties && haveSymbolCond ) ) );
602 mgr->SetConditions( SCH_ACTIONS::runERC, ENABLE( haveSymbolCond ) );
603 mgr->SetConditions( SCH_ACTIONS::pinTable, ENABLE( isEditableCond && haveSymbolCond ) );
604 mgr->SetConditions( SCH_ACTIONS::updateSymbolFields, ENABLE( isEditableCond && haveSymbolCond ) );
605 mgr->SetConditions( SCH_ACTIONS::cycleBodyStyle, ENABLE( multiBodyStyleModeCond ) );
606
607 mgr->SetConditions( SCH_ACTIONS::toggleSyncedPinsMode, ACTION_CONDITIONS().Enable( multiUnitModeCond ).Check( syncedPinsModeCond ) );
608
609// Only enable a tool if the symbol is edtable
610#define EDIT_TOOL( tool ) ACTION_CONDITIONS().Enable( isEditableCond ).Check( cond.CurrentTool( tool ) )
611
626
627#undef CHECK
628#undef ENABLE
629#undef EDIT_TOOL
630}
631
632
634{
635 if( IsContentModified() )
636 {
637 SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
638 wxString msg = _( "Save changes to '%s' before closing?" );
639
640 switch( UnsavedChangesDialog( this, wxString::Format( msg, m_reference ), nullptr ) )
641 {
642 case wxID_YES:
643 if( schframe && GetCurSymbol() ) // Should be always the case
645
646 break;
647
648 case wxID_NO:
649 break;
650
651 default:
652 case wxID_CANCEL:
653 return false;
654 }
655 }
656
657 if( doClose )
658 {
659 SetCurSymbol( nullptr, false );
660 UpdateTitle();
661 }
662
663 return true;
664}
665
666
667bool SYMBOL_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
668{
669 // Shutdown blocks must be determined and vetoed as early as possible
671 && aEvent.GetId() == wxEVT_QUERY_END_SESSION
672 && IsContentModified() )
673 {
674 return false;
675 }
676
678 return false;
679
680 if( !saveAllLibraries( true ) )
681 return false;
682
683 // Save symbol tree column widths
684 m_libMgr->GetAdapter()->SaveSettings();
685
686 return true;
687}
688
689
691{
693
694 if( GetLibTree() )
696
697 delete m_toolManager;
698 m_toolManager = nullptr;
699
700 Destroy();
701}
702
703
705{
706 if( m_unitSelectBox )
707 {
708 if( m_unitSelectBox->GetCount() != 0 )
709 m_unitSelectBox->Clear();
710
711 if( !m_symbol || m_symbol->GetUnitCount() <= 1 )
712 {
713 m_unit = 1;
714 m_unitSelectBox->Append( wxEmptyString );
715 }
716 else
717 {
718 for( int i = 0; i < m_symbol->GetUnitCount(); i++ )
719 m_unitSelectBox->Append( m_symbol->GetUnitDisplayName( i + 1, true ) );
720 }
721
722 // Ensure the selected unit is compatible with the number of units of the current symbol:
723 if( m_symbol && m_symbol->GetUnitCount() < m_unit )
724 m_unit = 1;
725
726 m_unitSelectBox->SetSelection( ( m_unit > 0 ) ? m_unit - 1 : 0 );
727 }
728
730 {
731 if( m_bodyStyleSelectBox->GetCount() != 0 )
732 m_bodyStyleSelectBox->Clear();
733
734 if( !m_symbol || !m_symbol->IsMultiBodyStyle() )
735 {
736 m_bodyStyle = 1;
737 m_bodyStyleSelectBox->Append( wxEmptyString );
738 }
739 else if( m_symbol && m_symbol->HasDeMorganBodyStyles() )
740 {
741 m_bodyStyleSelectBox->Append( wxGetTranslation( DEMORGAN_STD ) );
742 m_bodyStyleSelectBox->Append( wxGetTranslation( DEMORGAN_ALT ) );
743 }
744 else
745 {
746 for( int i = 0; i < m_symbol->GetBodyStyleCount(); i++ )
747 m_bodyStyleSelectBox->Append( m_symbol->GetBodyStyleNames()[i] );
748 }
749
750 // Ensure the selected body style is compatible with the number of body styles of the current symbol:
751 if( m_symbol && m_symbol->GetBodyStyleCount() < m_bodyStyle )
752 m_bodyStyle = 1;
753
754 m_bodyStyleSelectBox->SetSelection( ( m_bodyStyle > 0 ) ? m_bodyStyle - 1 : 0 );
755 }
756}
757
758
760{
761 if( !m_propertiesPanel )
762 return;
763
764 bool show = !m_propertiesPanel->IsShownOnScreen();
765
766 wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
767 propertiesPaneInfo.Show( show );
769
770 if( show )
771 {
772 SetAuiPaneSize( m_auimgr, propertiesPaneInfo,
773 m_settings->m_AuiPanels.properties_panel_width, -1 );
774 }
775 else
776 {
777 m_settings->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
778 }
779
780 m_auimgr.Update();
781 Refresh();
782}
783
784
786{
787 wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
788 treePane.Show( !IsLibraryTreeShown() );
790 m_auimgr.Update();
791 Refresh();
792}
793
794
796{
797 return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
798}
799
800
805
806
808{
809 m_treePane->Freeze();
810 m_libMgr->GetAdapter()->Freeze();
811}
812
813
815{
816 m_libMgr->GetAdapter()->Thaw();
817 m_treePane->Thaw();
818}
819
820
821void SYMBOL_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
822{
823 Kiway().OnKiCadExit();
824}
825
826
827void SYMBOL_EDIT_FRAME::OnUpdateUnitNumber( wxUpdateUIEvent& event )
828{
829 event.Enable( m_symbol && m_symbol->GetUnitCount() > 1 );
830}
831
832
833void SYMBOL_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event )
834{
835 if( event.GetSelection() == wxNOT_FOUND )
836 return;
837
838 SetUnit( event.GetSelection() + 1 );
839}
840
841
842void SYMBOL_EDIT_FRAME::OnUpdateBodyStyle( wxUpdateUIEvent& event )
843{
844 event.Enable( m_symbol && m_symbol->GetBodyStyleCount() > 1 );
845}
846
847
848void SYMBOL_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
849{
850 if( event.GetSelection() == wxNOT_FOUND )
851 return;
852
853 SetBodyStyle( event.GetSelection() + 1 );
854}
855
856
858{
859 if( m_symbol )
860 {
862
863 if( auto row = adapter->GetRow( m_symbol->GetLibNickname() ); row.has_value() )
864 {
865 if( ( *row )->Type() == SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_LEGACY ) )
866 return true;
867 }
868 }
869
870 return false;
871}
872
873
875{
876 wxString libNickname = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB );
877
878 if( !libNickname.empty() )
879 {
880 if( !PROJECT_SCH::SymbolLibAdapter( &Prj() )->HasLibrary( libNickname ) )
881 {
882 Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
883 libNickname = wxEmptyString;
884 }
885 }
886
887 return libNickname;
888}
889
890
891wxString SYMBOL_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
892{
893 wxString old = GetCurLib();
894
895 if( aLibNickname.empty() || !PROJECT_SCH::SymbolLibAdapter( &Prj() )->HasLibrary( aLibNickname ) )
896 Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
897 else
899
900 return old;
901}
902
903
904void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom )
905{
906 wxCHECK( m_toolManager, /* void */ );
907
909 GetCanvas()->GetView()->Clear();
910 delete m_symbol;
911
912 m_symbol = aSymbol;
913
914 // select the current symbol in the tree widget
916 GetLibTree()->SelectLibId( m_symbol->GetLibId() );
917 else
918 GetLibTree()->Unselect();
919
920 wxString symbolName;
921 wxString libName;
922
923 if( m_symbol )
924 {
925 symbolName = m_symbol->GetName();
926 libName = UnescapeString( m_symbol->GetLibId().GetLibNickname() );
927 }
928
929 // retain in case this wxFrame is re-opened later on the same PROJECT
931
932 // Ensure synchronized pin edit can be enabled only symbols with interchangeable units
933 m_SyncPinEdit = aSymbol && aSymbol->IsRoot() && aSymbol->IsMultiUnit() && !aSymbol->UnitsLocked();
934
936
944
945 if( aUpdateZoom )
947
948 GetCanvas()->Refresh();
949 m_propertiesPanel->UpdateData();
950
951 WX_INFOBAR& infobar = *GetInfoBar();
952 infobar.RemoveAllButtons();
953
954 wxArrayString msgs;
955 int infobarFlags = wxICON_INFORMATION;
956
958 {
959 msgs.push_back( wxString::Format( _( "Editing symbol %s from schematic. Saving will "
960 "update the schematic only." ),
961 m_reference ) );
962
963 wxString link = wxString::Format( _( "Open symbol from library %s" ), libName );
964 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( &infobar, wxID_ANY, link, wxEmptyString );
965
966 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
967 [this, symbolName, libName]( wxHyperlinkEvent& aEvent )
968 {
970 } ) );
971
972 infobar.AddButton( button );
973 }
974 else if( IsSymbolFromLegacyLibrary() )
975 {
976 msgs.push_back( _( "Symbols in legacy libraries are not editable. Use Manage Symbol "
977 "Libraries to migrate to current format." ) );
978
979 wxString link = _( "Manage symbol libraries" );
980 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( &infobar, wxID_ANY, link, wxEmptyString );
981
982 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
983 [this]( wxHyperlinkEvent& aEvent )
984 {
986 } ) );
987
988 infobar.AddButton( button );
989 }
990 else if( IsSymbolAlias() )
991 {
992 msgs.push_back( wxString::Format( _( "Symbol %s is a derived symbol. Symbol graphics will "
993 "not be editable." ),
994 UnescapeString( symbolName ) ) );
995
996 // Don't assume the parent symbol shared pointer is still valid.
997 if( std::shared_ptr<LIB_SYMBOL> rootSymbol = m_symbol->GetRootSymbol() )
998 {
999 int unit = GetUnit();
1000 int bodyStyle = GetBodyStyle();
1001 wxString rootSymbolName = rootSymbol->GetName();
1002 wxString link = wxString::Format( _( "Open %s" ), UnescapeString( rootSymbolName ) );
1003
1004 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( &infobar, wxID_ANY, link,
1005 wxEmptyString );
1006
1007 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
1008 [this, rootSymbolName, unit, bodyStyle]( wxHyperlinkEvent& aEvent )
1009 {
1010 LoadSymbolFromCurrentLib( rootSymbolName, unit, bodyStyle );
1011 } ) );
1012
1013 infobar.AddButton( button );
1014 }
1015 }
1016
1017 if( m_symbol
1019 && m_libMgr->IsLibraryReadOnly( m_symbol->GetLibId().GetFullLibraryName() ) )
1020 {
1021 msgs.push_back( _( "Library is read-only. Changes cannot be saved to this library." ) );
1022
1023 wxString link = wxString::Format( _( "Create an editable copy" ) );
1024 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( &infobar, wxID_ANY, link, wxEmptyString );
1025
1026 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
1027 [this, symbolName, libName]( wxHyperlinkEvent& aEvent )
1028 {
1029 wxString msg = wxString::Format( _( "Create an editable copy of the symbol or "
1030 "the entire library (%s)?" ),
1031 libName );
1032
1033 KIDIALOG errorDlg( this, msg, _( "Select type of item to save" ),
1034 wxYES_NO | wxCANCEL | wxICON_QUESTION );
1035 // These buttons are in a weird order(?)
1036 errorDlg.SetYesNoCancelLabels( _( "Copy symbol" ), _( "Cancel" ),
1037 _( "Copy library" ) );
1038
1039 int choice = errorDlg.ShowModal();
1040
1041 switch( choice )
1042 {
1043 case wxID_YES:
1044 SaveSymbolCopyAs( true );
1045 break;
1046 case wxID_CANCEL:
1047 SaveLibraryAs();
1048 break;
1049 default:
1050 // Do nothing
1051 break;
1052 }
1053 } ) );
1054
1055 infobar.AddButton( button );
1056 }
1057
1058 if( msgs.empty() )
1059 {
1060 infobar.Dismiss();
1061 }
1062 else
1063 {
1064 wxString msg = wxJoin( msgs, '\n', '\0' );
1065 infobar.ShowMessage( msg, infobarFlags );
1066 }
1067}
1068
1069
1075
1076
1078{
1080
1082
1083 if( !IsSymbolFromSchematic() )
1085
1086 if( m_isClosing )
1087 return;
1088
1090
1091 if( !GetTitle().StartsWith( "*" ) )
1092 UpdateTitle();
1093}
1094
1095
1097{
1098 wxCHECK( aUnit > 0 && aUnit <= GetCurSymbol()->GetUnitCount(), /* void*/ );
1099
1100 if( m_unit == aUnit )
1101 return;
1102
1105
1106 m_unit = aUnit;
1107
1108 if( m_unitSelectBox->GetSelection() != ( m_unit - 1 ) )
1109 m_unitSelectBox->SetSelection( m_unit - 1 );
1110
1112 RebuildView();
1114}
1115
1116
1118{
1119 wxCHECK( aBodyStyle > 0 && aBodyStyle <= GetCurSymbol()->GetBodyStyleCount(), /* void */ );
1120
1121 if( m_bodyStyle == aBodyStyle )
1122 return;
1123
1126
1127 m_bodyStyle = aBodyStyle;
1128
1129 if( m_bodyStyleSelectBox->GetSelection() != ( m_bodyStyle - 1 ) )
1130 m_bodyStyleSelectBox->SetSelection( m_bodyStyle - 1 );
1131
1132
1134 RebuildView();
1136}
1137
1138
1140{
1141 return m_SyncPinEdit && m_symbol && m_symbol->IsMultiUnit() && !m_symbol->UnitsLocked();
1142}
1143
1144
1145wxString SYMBOL_EDIT_FRAME::AddLibraryFile( bool aCreateNew )
1146{
1147 wxFileName fn = m_libMgr->GetUniqueLibraryName();
1148 bool useGlobalTable = true;
1149 FILEDLG_HOOK_NEW_LIBRARY tableChooser( useGlobalTable );
1150
1151 if( !LibraryFileBrowser( aCreateNew ? _( "New Symbol Library" ) : _( "Add Symbol Library" ),
1152 !aCreateNew, fn, FILEEXT::KiCadSymbolLibFileWildcard(),
1154 Pgm().GetSettingsManager().IsProjectOpenNotDummy() ? &tableChooser : nullptr ) )
1155 {
1156 return wxEmptyString;
1157 }
1158
1161
1162 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
1163 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, scope );
1164
1165 wxCHECK( optTable.has_value(), wxEmptyString );
1166 LIBRARY_TABLE* table = optTable.value();
1167
1168 wxString libName = fn.GetName();
1169
1170 if( libName.IsEmpty() )
1171 return wxEmptyString;
1172
1174
1175 if( adapter->HasLibrary( libName ) )
1176 {
1177 DisplayError( this, wxString::Format( _( "Library '%s' already exists." ), libName ) );
1178 return wxEmptyString;
1179 }
1180
1181 if( aCreateNew )
1182 {
1183 if( !m_libMgr->CreateLibrary( fn.GetFullPath(), scope ) )
1184 {
1185 DisplayError( this, wxString::Format( _( "Could not create the library file '%s'.\n"
1186 "Make sure you have write permissions and try again." ),
1187 fn.GetFullPath() ) );
1188 return wxEmptyString;
1189 }
1190 }
1191 else
1192 {
1193 if( !m_libMgr->AddLibrary( fn.GetFullPath(), scope ) )
1194 {
1195 DisplayError( this, _( "Could not open the library file." ) );
1196 return wxEmptyString;
1197 }
1198 }
1199
1200 bool success = true;
1201
1202 // Tables are reinitialized by m_libMgr->AddLibrary(). So reinit table reference.
1203 optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, scope );
1204 wxCHECK( optTable.has_value(), wxEmptyString );
1205 table = optTable.value();
1206
1207 table->Save().map_error(
1208 [&]( const LIBRARY_ERROR& aError )
1209 {
1210 KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ),
1211 wxOK | wxICON_ERROR );
1212 dlg.SetExtendedMessage( aError.message );
1213 dlg.ShowModal();
1214
1215 success = false;
1216 } );
1217
1218 if( success )
1219 adapter->LoadOne( fn.GetName() );
1220
1221 std::string packet = fn.GetFullPath().ToStdString();
1224
1225 return fn.GetFullPath();
1226}
1227
1228
1229void SYMBOL_EDIT_FRAME::DdAddLibrary( wxString aLibFile )
1230{
1231 wxFileName fn = wxFileName( aLibFile );
1232 wxString libName = fn.GetName();
1233
1234 if( libName.IsEmpty() )
1235 return;
1236
1237 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
1239
1240 if( adapter->HasLibrary( libName ) )
1241 {
1242 DisplayError( this, wxString::Format( _( "Library '%s' already exists." ), libName ) );
1243 return;
1244 }
1245
1246 if( !m_libMgr->AddLibrary( fn.GetFullPath(), LIBRARY_TABLE_SCOPE::PROJECT ) )
1247 {
1248 DisplayError( this, _( "Could not open the library file." ) );
1249 return;
1250 }
1251
1252 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, LIBRARY_TABLE_SCOPE::PROJECT );
1253 wxCHECK( optTable.has_value(), /* void */ );
1254 LIBRARY_TABLE* table = optTable.value();
1255 bool success = true;
1256
1257 table->Save().map_error(
1258 [&]( const LIBRARY_ERROR& aError )
1259 {
1260 KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ),
1261 wxOK | wxICON_ERROR );
1262 dlg.SetExtendedMessage( aError.message );
1263 dlg.ShowModal();
1264
1265 success = false;
1266 } );
1267
1268 if( success )
1269 adapter->LoadOne( libName );
1270
1271 std::string packet = fn.GetFullPath().ToStdString();
1274}
1275
1276
1278{
1279 return GetLibTree()->GetSelectedLibId( aUnit );
1280}
1281
1282
1287
1288int SYMBOL_EDIT_FRAME::GetTreeLIBIDs( std::vector<LIB_ID>& aSelection ) const
1289{
1290 return GetLibTree()->GetSelectedLibIds( aSelection );
1291}
1292
1293
1295{
1296 if( IsLibraryTreeShown() )
1297 {
1298 LIB_ID libId = GetTreeLIBID();
1299
1300 if( libId.IsValid() )
1301 return m_libMgr->GetSymbol( libId.GetLibItemName(), libId.GetLibNickname() );
1302 }
1303
1304 return m_symbol;
1305}
1306
1307
1309{
1310 LIB_ID id;
1311
1312 if( IsLibraryTreeShown() )
1313 id = GetTreeLIBID();
1314
1315 if( id.GetLibNickname().empty() && m_symbol )
1316 id = m_symbol->GetLibId();
1317
1318 return id;
1319}
1320
1321
1322std::vector<LIB_ID> SYMBOL_EDIT_FRAME::GetSelectedLibIds() const
1323{
1324 std::vector<LIB_ID> ids;
1325 GetTreeLIBIDs( ids );
1326 return ids;
1327}
1328
1329
1331{
1332 return GetTargetLibId().GetLibNickname();
1333}
1334
1335
1336void SYMBOL_EDIT_FRAME::SyncLibraries( bool aShowProgress, bool aPreloadCancelled,
1337 const wxString& aForceRefresh )
1338{
1339 // Prevent re-entrant calls. The progress dialog yields the event loop during Sync(),
1340 // which can dispatch queued UI events (e.g. menu clicks queued while the app was busy
1341 // loading libraries). A re-entrant call would corrupt the library tree mid-rebuild.
1343 return;
1344
1346
1347 auto resetGuard = [this]( bool* )
1348 {
1350 };
1351
1352 std::unique_ptr<bool, decltype( resetGuard )> guard( &m_syncLibrariesInProgress, resetGuard );
1353
1354 LIB_ID selected;
1355
1356 if( m_treePane )
1357 selected = GetLibTree()->GetSelectedLibId();
1358
1359 // Ensure any in-progress background library preloading is complete before syncing the
1360 // tree. Without this, libraries still in LOADING state get skipped by Sync(), resulting
1361 // in an incomplete tree that requires a manual refresh to fully populate.
1363 adapter->BlockUntilLoaded();
1364
1365 if( aShowProgress )
1366 {
1367 APP_PROGRESS_DIALOG progressDlg( _( "Loading Symbol Libraries" ), wxEmptyString,
1368 m_libMgr->GetAdapter()->GetLibrariesCount(), this );
1369
1370 THROTTLE progressThrottle( std::chrono::milliseconds( 350 ) );
1371 int pendingProgress = 0;
1372 bool callbackFired = false;
1373 wxString pendingLibName;
1374
1375 m_libMgr->Sync( aForceRefresh,
1376 [&]( int progress, int max, const wxString& libName )
1377 {
1378 pendingProgress = progress;
1379 pendingLibName = libName;
1380 callbackFired = true;
1381
1382 if( progressThrottle.Ready() )
1383 progressDlg.Update( progress, wxString::Format( _( "Loading library '%s'..." ), libName ) );
1384 } );
1385
1386 if( callbackFired )
1387 progressDlg.Update( pendingProgress, wxString::Format( _( "Loading library '%s'..." ), pendingLibName ) );
1388 }
1389 else if( !aPreloadCancelled )
1390 {
1391 m_libMgr->Sync( aForceRefresh, [&]( int progress, int max, const wxString& libName ) {} );
1392 }
1393
1394 if( m_treePane )
1395 {
1396 wxDataViewItem found;
1397
1398 if( selected.IsValid() )
1399 {
1400 // Check if the previously selected item is still valid,
1401 // if not - it has to be unselected to prevent crash
1402 found = m_libMgr->GetAdapter()->FindItem( selected );
1403
1404 if( !found )
1405 GetLibTree()->Unselect();
1406 }
1407
1408 GetLibTree()->Regenerate( true );
1409
1410 // Try to select the parent library, in case the symbol is not found
1411 if( !found && selected.IsValid() )
1412 {
1413 selected.SetLibItemName( "" );
1414 found = m_libMgr->GetAdapter()->FindItem( selected );
1415
1416 if( found )
1417 GetLibTree()->SelectLibId( selected );
1418 }
1419
1420 // If no selection, see if there's a current symbol to centre
1421 if( !selected.IsValid() && m_symbol )
1422 {
1423 LIB_ID current( GetCurLib(), m_symbol->GetName() );
1424 GetLibTree()->CenterLibId( current );
1425 }
1426 }
1427
1428}
1429
1430
1435
1436
1438{
1439 GetLibTree()->SelectLibId( aLibID );
1440}
1441
1442
1443void SYMBOL_EDIT_FRAME::UpdateLibraryTree( const wxDataViewItem& aTreeItem, LIB_SYMBOL* aSymbol )
1444{
1445 if( aTreeItem.IsOk() ) // Can be not found in tree if the current footprint is imported
1446 // from file therefore not yet in tree.
1447 {
1448 static_cast<LIB_TREE_NODE_ITEM*>( aTreeItem.GetID() )->Update( aSymbol );
1450 }
1451}
1452
1453
1454bool SYMBOL_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt )
1455{
1456 if( aOriginalFile.FileExists() )
1457 {
1458 wxFileName backupFileName( aOriginalFile );
1459 backupFileName.SetExt( aBackupExt );
1460
1461 if( backupFileName.FileExists() )
1462 wxRemoveFile( backupFileName.GetFullPath() );
1463
1464 if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
1465 {
1466 DisplayError( this, wxString::Format( _( "Failed to save backup to '%s'." ),
1467 backupFileName.GetFullPath() ) );
1468 return false;
1469 }
1470 }
1471
1472 return true;
1473}
1474
1475
1477{
1478 if( m_symbol && !GetCurLib().IsEmpty() && GetScreen()->IsContentModified() )
1479 m_libMgr->UpdateSymbol( m_symbol, GetCurLib() ); // UpdateSymbol() makes a copy
1480}
1481
1482
1484{
1485 // This will return the root symbol of any alias
1486 LIB_SYMBOL* symbol = m_libMgr->GetBufferedSymbol( aLibId.GetLibItemName(), aLibId.GetLibNickname() );
1487
1488 // Now we can compare the libId of the current symbol and the root symbol
1489 return ( symbol && m_symbol && symbol->GetLibId() == m_symbol->GetLibId() );
1490}
1491
1492
1494{
1495 GetLibTree()->Unselect();
1496 SetCurLib( wxEmptyString );
1497 SetCurSymbol( nullptr, false );
1501 Refresh();
1502}
1503
1504
1506{
1508
1510 {
1511 GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_ShowPinElectricalType;
1512 GetRenderSettings()->m_ShowHiddenPins = cfg->m_ShowHiddenPins;
1513 GetRenderSettings()->m_ShowHiddenFields = cfg->m_ShowHiddenFields;
1514 GetRenderSettings()->m_ShowPinAltIcons = cfg->m_ShowPinAltIcons;
1515
1516 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1517 }
1518
1519 if( m_symbol )
1520 m_symbol->ClearCaches();
1521
1523
1525 GetCanvas()->Refresh();
1526
1528
1529 if( aFlags & ENVVARS_CHANGED )
1530 SyncLibraries( true );
1531
1532 Layout();
1533 SendSizeEvent();
1534}
1535
1536
1538{
1539 // call my base class
1541
1542 // tooltips in toolbars
1544
1545 // For some obscure reason, the AUI manager hides the first modified pane.
1546 // So force show panes
1547 wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
1548 bool tree_shown = tree_pane_info.IsShown();
1549 tree_pane_info.Caption( _( "Libraries" ) );
1550 tree_pane_info.Show( tree_shown );
1551 m_auimgr.Update();
1552
1554
1555 // status bar
1557
1558 if( GetRenderSettings()->m_ShowPinsElectricalType )
1559 {
1561 GetCanvas()->Refresh();
1562 }
1563
1564 UpdateTitle();
1565}
1566
1567
1569{
1570 SCH_BASE_FRAME::SetScreen( aScreen );
1571
1572 // Let tools add things to the view if necessary
1573 if( m_toolManager )
1575}
1576
1577
1595
1596
1598{
1599 SyncLibraries( true );
1600
1601 if( m_symbol )
1602 {
1603 SCH_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>();
1604 SCH_SELECTION& selection = selectionTool->GetSelection();
1605
1606 for( SCH_ITEM& item : m_symbol->GetDrawItems() )
1607 {
1608 if( !alg::contains( selection, &item ) )
1609 item.ClearSelected();
1610 else
1611 item.SetSelected();
1612 }
1613
1614 m_symbol->ClearCaches();
1615 }
1616
1617 RebuildView();
1618}
1619
1620
1621const BOX2I SYMBOL_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1622{
1623 if( !m_symbol )
1624 {
1625 // Gives a reasonable drawing area size
1626 int width = schIUScale.mmToIU( 50 );
1627 int height = schIUScale.mmToIU( 30 );
1628
1629 return BOX2I( VECTOR2I( -width/2, -height/2 ), VECTOR2I( width, height ) );
1630 }
1631 else
1632 {
1633 return m_symbol->Flatten()->GetUnitBoundingBox( m_unit, m_bodyStyle );
1634 }
1635}
1636
1637
1638void SYMBOL_EDIT_FRAME::FocusOnItem( EDA_ITEM* aItem, bool aAllowScroll )
1639{
1640 static KIID lastBrightenedItemID( niluuid );
1641
1642 SCH_ITEM* lastItem = nullptr;
1643
1644 // nullptr will clear the current focus
1645 if( aItem != nullptr && !aItem->IsSCH_ITEM() )
1646 return;
1647
1648 if( m_symbol )
1649 {
1650 for( SCH_PIN* pin : m_symbol->GetGraphicalPins( 0, 0 ) )
1651 {
1652 if( pin->m_Uuid == lastBrightenedItemID )
1653 lastItem = pin;
1654 }
1655
1656 std::vector<SCH_FIELD*> fields;
1657 m_symbol->GetFields( fields );
1658
1659 for( SCH_FIELD* field : fields )
1660 {
1661 if( field->m_Uuid == lastBrightenedItemID )
1662 lastItem = field;
1663 }
1664 }
1665
1666 if( lastItem && lastItem != aItem )
1667 {
1668 lastItem->ClearBrightened();
1669
1670 UpdateItem( lastItem );
1671 lastBrightenedItemID = niluuid;
1672 }
1673
1674 if( aItem )
1675 {
1676 if( aItem->IsSCH_ITEM() )
1677 {
1678 SCH_ITEM* item = static_cast<SCH_ITEM*>( aItem );
1679
1680 if( int unit = item->GetUnit() )
1681 SetUnit( unit );
1682
1683 if( int bodyStyle = item->GetBodyStyle() )
1684 SetBodyStyle( bodyStyle );
1685 }
1686
1687 if( !aItem->IsBrightened() )
1688 {
1689 aItem->SetBrightened();
1690
1691 UpdateItem( aItem );
1692 lastBrightenedItemID = aItem->m_Uuid;
1693 }
1694
1695 FocusOnLocation( VECTOR2I( aItem->GetFocusPosition().x, aItem->GetFocusPosition().y ), aAllowScroll );
1696 }
1697}
1698
1699
1701{
1702 const std::string& payload = mail.GetPayload();
1703
1704 switch( mail.Command() )
1705 {
1706 case MAIL_LIB_EDIT:
1707 if( !payload.empty() )
1708 {
1709 wxString uri( payload );
1710 wxString libNickname;
1711 wxString msg;
1712
1714 std::optional<const LIBRARY_TABLE_ROW*> libTableRow = adapter->FindRowByURI( uri );
1715
1716 if( !libTableRow )
1717 {
1718 msg.Printf( _( "The current configuration does not include the symbol library '%s'." ),
1719 uri );
1720 msg += wxS( "\n" ) + _( "Use Manage Symbol Libraries to edit the configuration." );
1721 DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
1722 break;
1723 }
1724
1725 libNickname = ( *libTableRow )->Nickname();
1726
1727 if( !adapter->HasLibrary( libNickname, true ) )
1728 {
1729 msg.Printf( _( "The symbol library '%s' is not enabled in the current configuration." ),
1730 UnescapeString( libNickname ) );
1731 msg += wxS( "\n" ) + _( "Use Manage Symbol Libraries to edit the configuration." );
1732 DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg );
1733 break;
1734 }
1735
1736 SetCurLib( libNickname );
1737
1738 if( m_treePane )
1739 {
1740 LIB_ID id( libNickname, wxEmptyString );
1741 GetLibTree()->SelectLibId( id );
1742 GetLibTree()->ExpandLibId( id );
1743 GetLibTree()->CenterLibId( id );
1744 }
1745 }
1746
1747 break;
1748
1749 case MAIL_RELOAD_LIB:
1750 {
1751 wxString currentLib = GetCurLib();
1752
1754
1755 // Check if the currently selected symbol library been removed or disabled.
1756 if( !currentLib.empty()
1757 && !PROJECT_SCH::SymbolLibAdapter( &Prj() )->HasLibrary( currentLib, true ) )
1758 {
1759 SetCurLib( wxEmptyString );
1760 emptyScreen();
1761 }
1762
1763 SyncLibraries( true );
1766
1767 break;
1768 }
1769
1771 {
1773 LIB_SYMBOL* symbol = GetCurSymbol();
1774
1775 wxLogTrace( traceLibWatch, "Received refresh symbol request for %s", payload );
1776
1777 if( !symbol )
1778 break;
1779
1780 // If the frame is disabled then a modal/quasi-modal dialog (such as the symbol
1781 // properties dialog) is editing the current LIB_SYMBOL. Refreshing it here would
1782 // delete the symbol out from under the dialog and crash on dismissal. The file
1783 // watcher timer will retry the reload once the dialog has closed.
1784 if( !IsEnabled() )
1785 {
1786 wxLogTrace( traceLibWatch,
1787 "Deferring symbol refresh; dialog is open on the symbol editor." );
1788 break;
1789 }
1790
1791 wxString libName = symbol->GetLibId().GetLibNickname();
1792 std::optional<const LIBRARY_TABLE_ROW*> row = adapter->GetRow( libName );
1793
1794 if( !row )
1795 return;
1796
1797 wxFileName libfullname( LIBRARY_MANAGER::GetFullURI( *row, true ) );
1798
1799 wxFileName changedLib( mail.GetPayload() );
1800
1801 wxLogTrace( traceLibWatch, "Received refresh symbol request for %s, current symbols is %s",
1802 changedLib.GetFullPath(), libfullname.GetFullPath() );
1803
1804 if( changedLib == libfullname )
1805 {
1806 wxLogTrace( traceLibWatch, "Refreshing symbol %s", symbol->GetName() );
1807
1808 SetScreen( m_dummyScreen ); // UpdateLibraryBuffer will destroy the old screen
1809 m_libMgr->UpdateLibraryBuffer( libName );
1810
1811 if( LIB_SYMBOL* lib_symbol = m_libMgr->GetBufferedSymbol( symbol->GetName(), libName ) )
1812 {
1813 // The buffered screen for the symbol
1814 SCH_SCREEN* symbol_screen = m_libMgr->GetScreen( lib_symbol->GetName(), libName );
1815
1816 SetScreen( symbol_screen );
1817 SetCurSymbol( new LIB_SYMBOL( *lib_symbol ), false );
1819
1820 if( m_toolManager )
1822 }
1823 }
1824
1825 break;
1826 }
1827
1828 default:
1829 break;
1830 }
1831}
1832
1833
1834std::unique_ptr<GRID_HELPER> SYMBOL_EDIT_FRAME::MakeGridHelper()
1835{
1836 return std::make_unique<EE_GRID_HELPER>( m_toolManager );
1837}
1838
1839
1841{
1842 // switches currently used canvas ( Cairo / OpenGL):
1843 SCH_BASE_FRAME::SwitchCanvas( aCanvasType );
1844
1845 // Set options specific to symbol editor (axies are always enabled):
1846 GetCanvas()->GetGAL()->SetAxesEnabled( true );
1848}
1849
1850
1852{
1853 wxCHECK( m_libMgr, false );
1854
1855 return m_libMgr->HasModifications();
1856}
1857
1858
1860{
1861 wxCHECK( m_libMgr, false );
1862
1863 // Test if the currently edited symbol is modified
1865 return true;
1866
1867 // Test if any library has been modified
1868 for( const wxString& libName : m_libMgr->GetLibraryNames() )
1869 {
1870 if( m_libMgr->IsLibraryModified( libName ) && !m_libMgr->IsLibraryReadOnly( libName ) )
1871 return true;
1872 }
1873
1874 return false;
1875}
1876
1877
1879{
1880 if( aItemCount == 0 )
1881 return;
1882
1883 UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
1884
1885 if( aItemCount < 0 )
1886 {
1887 list.ClearCommandList();
1888 }
1889 else
1890 {
1891 for( int ii = 0; ii < aItemCount; ii++ )
1892 {
1893 if( list.m_CommandsList.size() == 0 )
1894 break;
1895
1896 PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
1897 list.m_CommandsList.erase( list.m_CommandsList.begin() );
1898
1899 curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
1900 {
1901 delete aItem;
1902 } );
1903 delete curr_cmd; // Delete command
1904 }
1905 }
1906}
1907
1908
1910{
1911 return m_toolManager->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
1912}
1913
1914
1916{
1917 std::unique_ptr<LIB_SYMBOL> symbol = aSymbol->GetLibSymbolRef()->Flatten();
1918 wxCHECK( symbol, /* void */ );
1919
1920 symbol->SetLibId( aSymbol->GetLibId() );
1921
1922 // Take in account the symbol orientation and mirroring. to calculate the field
1923 // positions in symbol editor (i.e. no rotation, no mirroring)
1924 int orientation = aSymbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
1925 int mirror = aSymbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
1926
1927 std::vector<SCH_FIELD> fullSetOfFields;
1928
1929 for( const SCH_FIELD& field : aSymbol->GetFields() )
1930 {
1931 VECTOR2I pos = field.GetPosition() - aSymbol->GetPosition();
1932 SCH_FIELD libField( symbol.get(), field.GetId() );
1933
1934 libField = field;
1935
1936 // The inverse transform is mirroring before, rotate after
1937 switch( mirror )
1938 {
1939 case SYM_MIRROR_X: pos.y = -pos.y; break;
1940 case SYM_MIRROR_Y: pos.x = -pos.x; break;
1941 default: break;
1942 }
1943
1944 switch( orientation )
1945 {
1946 case SYM_ORIENT_90:
1947 std::swap( pos.x, pos.y );
1948 pos.x = - pos.x;
1949 break;
1950 case SYM_ORIENT_270:
1951 std::swap( pos.x, pos.y );
1952 pos.y = - pos.y;
1953 break;
1954 case SYM_ORIENT_180:
1955 pos.x = - pos.x;
1956 pos.y = - pos.y;
1957 break;
1958 default:
1959 break;
1960 }
1961
1962 libField.SetPosition( pos );
1963
1964 fullSetOfFields.emplace_back( std::move( libField ) );
1965 }
1966
1967 symbol->SetFields( fullSetOfFields );
1968
1969 if( m_symbol )
1970 SetCurSymbol( nullptr, false );
1971
1973 m_schematicSymbolUUID = aSymbol->m_Uuid;
1974 m_reference = symbol->GetReferenceField().GetText();
1975 m_unit = std::max( 1, aSymbol->GetUnit() );
1976 m_bodyStyle = std::max( 1, aSymbol->GetBodyStyle() );
1977
1978 // Optimize default edit options for this symbol
1979 // Usually if units are locked, graphic items are specific to each unit
1980 // and if units are interchangeable, graphic items are common to units
1982 tools->SetDrawSpecificUnit( symbol->UnitsLocked() );
1983
1984 // The buffered screen for the symbol
1985 SCH_SCREEN* tmpScreen = new SCH_SCREEN();
1986
1987 SetScreen( tmpScreen );
1988 SetCurSymbol( symbol.release(), true );
1989 setSymWatcher( nullptr );
1990
1993
1994 if( IsLibraryTreeShown() )
1996
1997 UpdateTitle();
2000
2001 // Let tools add things to the view if necessary
2002 if( m_toolManager )
2004
2006 GetCanvas()->Refresh();
2007}
2008
2009
2010bool SYMBOL_EDIT_FRAME::addLibTableEntry( const wxString& aLibFile, LIBRARY_TABLE_SCOPE aScope )
2011{
2012 wxFileName fn = aLibFile;
2013 wxFileName libTableFileName( Prj().GetProjectPath(), FILEEXT::SymbolLibraryTableFileName );
2014 wxString libNickname = fn.GetName();
2016 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
2017 const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
2018
2019 if( adapter->HasLibrary( libNickname ) )
2020 {
2021 wxString tmp;
2022 int suffix = 1;
2023
2024 while( adapter->HasLibrary( libNickname ) )
2025 {
2026 tmp.Printf( "%s%d", fn.GetName(), suffix );
2027 libNickname = tmp;
2028 suffix += 1;
2029 }
2030 }
2031
2032 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, aScope );
2033 wxCHECK( optTable.has_value(), false );
2034 LIBRARY_TABLE* table = optTable.value();
2035
2036 LIBRARY_TABLE_ROW* row = &table->InsertRow();
2037
2038 row->SetNickname( libNickname );
2039
2040 // We cannot normalize against the current project path when saving to global table.
2041 wxString normalizedPath = NormalizePath( aLibFile, &envVars,
2042 aScope == LIBRARY_TABLE_SCOPE::PROJECT ? Prj().GetProjectPath()
2043 : wxString( wxEmptyString ) );
2044
2045 row->SetURI( normalizedPath );
2047
2048 bool success = true;
2049
2050 table->Save().map_error(
2051 [&]( const LIBRARY_ERROR& aError )
2052 {
2053 KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ),
2054 wxOK | wxICON_ERROR );
2055 dlg.SetExtendedMessage( aError.message );
2056 dlg.ShowModal();
2057
2058 success = false;
2059 } );
2060
2061 if( success )
2062 {
2063 manager.ReloadTables( aScope, { LIBRARY_TABLE_TYPE::SYMBOL } );
2064 adapter->LoadOne( libNickname );
2065 }
2066
2067 return success;
2068}
2069
2070
2071bool SYMBOL_EDIT_FRAME::replaceLibTableEntry( const wxString& aLibNickname, const wxString& aLibFile )
2072{
2074 LIBRARY_MANAGER& manager = Pgm().GetLibraryManager();
2075 LIBRARY_TABLE* table = nullptr;
2077
2078 // Check the global library table first because checking the project library table
2079 // checks the global library table as well due to library chaining.
2080 if( adapter->GetRow( aLibNickname, scope ) )
2081 {
2082 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, scope );
2083 wxCHECK( optTable.has_value(), false );
2084 table = optTable.value();
2085 }
2086 else
2087 {
2089
2090 if( adapter->GetRow( aLibNickname, scope ) )
2091 {
2092 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL, scope );
2093
2094 if( optTable.has_value() )
2095 table = optTable.value();
2096 }
2097 }
2098
2099 wxCHECK( table, false );
2100
2101 std::optional<LIBRARY_TABLE_ROW*> optRow = adapter->GetRow( aLibNickname, scope );
2102 wxCHECK( optRow.has_value(), false );
2103 LIBRARY_TABLE_ROW* row = optRow.value();
2104
2105 const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
2106
2107 wxString projectPath;
2108
2109 if( scope == LIBRARY_TABLE_SCOPE::PROJECT )
2110 projectPath = Prj().GetProjectPath();
2111
2112 wxString normalizedPath = NormalizePath( aLibFile, &envVars, projectPath );
2113
2114 row->SetURI( normalizedPath );
2115 row->SetType( "KiCad" );
2116
2117 bool success = true;
2118
2119 table->Save().map_error(
2120 [&]( const LIBRARY_ERROR& aError )
2121 {
2122 KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ),
2123 wxOK | wxICON_ERROR );
2124 dlg.SetExtendedMessage( aError.message );
2125 dlg.ShowModal();
2126
2127 success = false;
2128 } );
2129
2130 if( success )
2131 {
2132 manager.ReloadTables( scope, { LIBRARY_TABLE_TYPE::SYMBOL } );
2133 adapter->LoadOne( aLibNickname );
2134 }
2135
2136 return success;
2137}
2138
2139
2141{
2142 return m_symbol && !m_symbol->IsRoot();
2143}
2144
2145
2150
2151
2152void SYMBOL_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2153{
2154 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2155
2156 if( EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( aItem ) )
2157 {
2158 eda_text->ClearBoundingBoxCache();
2159 eda_text->ClearRenderCache();
2160 }
2161}
2162
2163
2165{
2166 wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
2167 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
2168 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
2169
2170 // Don't give the selection filter its own visibility controls; instead show it if
2171 // anything else is visible
2172 bool showFilter = ( treePane.IsShown() && treePane.IsDocked() )
2173 || ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
2174
2175 selectionFilterPane.Show( showFilter );
2176}
2177
2178
2180{
2181 // Returns the current render option for invisible fields
2183}
2184
2185
2187{
2188 // Returns the current render option for invisible pins
2190}
BASE_SCREEN class implementation.
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:127
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:100
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition() but allows items to return their visual center rather than their anchor.
Definition eda_item.h:286
const KIID m_Uuid
Definition eda_item.h:528
void ClearBrightened()
Definition eda_item.h:145
void SetBrightened()
Definition eda_item.h:142
bool IsBrightened() const
Definition eda_item.h:131
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:93
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:270
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition sch_view.cpp:258
bool IsSCH_ITEM() const
Definition view_item.h:101
void Clear()
Remove all items from the view.
Definition view.cpp:1222
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition view.cpp:1685
Definition kiid.h:48
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:315
void OnKiCadExit()
Definition kiway.cpp:800
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:402
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:500
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:771
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:787
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:130
virtual LIBRARY_MANAGER & GetLibraryManager() const
Definition pgm_base.h:132
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:222
@ SCH_LIBEDIT_CUR_SYMBOL
Definition project.h:223
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition project.cpp:187
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:359
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:370
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 drawEllipseArc
Definition sch_actions.h:98
static TOOL_ACTION editLibSymbolWithLibEdit
static TOOL_ACTION drawArc
Definition sch_actions.h:99
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 drawEllipse
Definition sch_actions.h:97
static TOOL_ACTION drawCircle
Definition sch_actions.h:96
static TOOL_ACTION importGraphics
static TOOL_ACTION drawBezier
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:892
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:221
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:196
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:63
@ ID_LIBEDIT_SELECT_BODY_STYLE
Definition eeschema_id.h:64
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:655
KIID niluuid(0)
@ LAYER_SCHEMATIC_GRID_AXES
Definition layer_ids.h:489
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:102
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition unix/app.cpp:91
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)
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
std::vector< std::vector< std::string > > table
#define ENVVARS_CHANGED
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
VECTOR2< double > VECTOR2D
Definition vector2d.h:686
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.