KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <algorithm>
22#include <api/api_handler_sch.h>
23#include <api/api_server.h>
24#include <base_units.h>
25#include <bitmaps.h>
26#include <confirm.h>
27#include <connection_graph.h>
28#include <dialogs/dialog_erc.h>
33#include <wx/srchctrl.h>
34#include <mail_type.h>
35#include <wx/clntdata.h>
36#include <wx/panel.h>
37#include <wx/sizer.h>
38#include <wx/menu.h>
39#include <local_history.h>
40#include <eeschema_id.h>
41#include <executable_names.h>
44#include <gestfich.h>
46#include <string_utils.h>
47#include <kiface_base.h>
48#include <kiplatform/app.h>
49#include <kiplatform/ui.h>
50#include <kiway.h>
51#include <symbol_edit_frame.h>
52#include <symbol_viewer_frame.h>
53#include <pgm_base.h>
54#include <core/profile.h>
57#include <sch_edit_frame.h>
59#include <sch_painter.h>
60#include <sch_marker.h>
61#include <sch_sheet_pin.h>
62#include <sch_commit.h>
63#include <sch_rule_area.h>
65#include <advanced_config.h>
66#include <sim/simulator_frame.h>
67#include <tool/action_manager.h>
68#include <tool/action_toolbar.h>
69#include <tool/common_control.h>
70#include <tool/common_tools.h>
71#include <tool/embed_tool.h>
72#include <tool/picker_tool.h>
74#include <tool/selection.h>
76#include <tool/tool_manager.h>
77#include <tool/zoom_tool.h>
78#include <tools/sch_actions.h>
84#include <sch_io/sch_io_mgr.h>
85#include <sch_io/sch_io.h>
87#include <tools/sch_edit_tool.h>
93#include <tools/sch_move_tool.h>
96#include <trace_helpers.h>
97#include <unordered_set>
98#include <view/view_controls.h>
99#include <widgets/wx_infobar.h>
105#include <wx/cmdline.h>
106#include <wx/app.h>
107#include <wx/filedlg.h>
108#include <wx/socket.h>
109#include <wx/debug.h>
111#include <widgets/wx_aui_utils.h>
114#include <toolbars_sch_editor.h>
115#include <wx/log.h>
116#include <wx/choicdlg.h>
117#include <wx/textdlg.h>
118#include <wx/generic/treectlg.h>
119
120
121#ifdef KICAD_IPC_API
123#include <api/api_utils.h>
124#endif
125
127
128
129#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
130
131
132BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
135
136 EVT_SIZE( SCH_EDIT_FRAME::OnSize )
137
140
141 EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
142 EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
143
146
147 // Drop files event
148 EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
149END_EVENT_TABLE()
150
151
152wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
153wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
154
155
156SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
157 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
159 m_ercDialog( nullptr ),
160 m_diffSymbolDialog( nullptr ),
161 m_symbolFieldsTableDialog( nullptr ),
162 m_netNavigator( nullptr ),
163 m_netNavigatorFilter( nullptr ),
167 m_designBlocksPane( nullptr ),
168 m_remoteSymbolPane( nullptr ),
169 m_currentVariantCtrl( nullptr )
170{
171 m_maximizeByDefault = true;
172 m_schematic = new SCHEMATIC( &Prj() );
173 m_schematic->SetSchematicHolder( this );
175
176 m_showBorderAndTitleBlock = true; // true to show sheet references
177 m_supportsAutoSave = true;
179 m_aboutTitle = _HKI( "KiCad Schematic Editor" );
180 m_show_search = false;
181 // Ensure timer has an owner before binding so it generates events.
182 m_crossProbeFlashTimer.SetOwner( this );
183 Bind( wxEVT_TIMER, &SCH_EDIT_FRAME::OnCrossProbeFlashTimer, this, m_crossProbeFlashTimer.GetId() );
184
185 // Give an icon
186 wxIcon icon;
187 wxIconBundle icon_bundle;
188
189 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 48 ) );
190 icon_bundle.AddIcon( icon );
191 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 128 ) );
192 icon_bundle.AddIcon( icon );
193 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 256 ) );
194 icon_bundle.AddIcon( icon );
195 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
196 icon_bundle.AddIcon( icon );
197 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
198 icon_bundle.AddIcon( icon );
199
200 SetIcons( icon_bundle );
201
203
204 setupTools();
207
211
212 // Ensure the "Line modes" toolbar group shows the current angle mode on startup
213 if( GetToolManager() )
215
216#ifdef KICAD_IPC_API
217 wxTheApp->Bind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED, &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
218#endif
219
220 m_hierarchy = new HIERARCHY_PANE( this );
221
222 // Initialize common print setup dialog settings.
223 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
224 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
225 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
226 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
227
228 m_searchPane = new SCH_SEARCH_PANE( this );
229 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
231
232 m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
233
236
237 m_auimgr.SetManagedWindow( this );
238
240
241 // Fetch a COPY of the config as a lot of these initializations are going to overwrite our
242 // data.
243 EESCHEMA_SETTINGS::AUI_PANELS aui_cfg = eeconfig()->m_AuiPanels;
244 EESCHEMA_SETTINGS::APPEARANCE appearance_cfg = eeconfig()->m_Appearance;
245
246 // Rows; layers 4 - 6
247 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( wxS( "TopMainToolbar" ) )
248 .Top().Layer( 6 ) );
249
250 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
251 .Bottom().Layer( 6 ) );
252
253 // Columns; layers 1 - 3
254 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
255 .Caption( _( "Schematic Hierarchy" ) )
256 .Left().Layer( 3 ).Position( 1 )
257 .TopDockable( false )
258 .BottomDockable( false )
259 .CloseButton( true )
260 .MinSize( FromDIP( wxSize( 120, 60 ) ) )
261 .BestSize( FromDIP( wxSize( 200, 200 ) ) )
262 .FloatingSize( FromDIP( wxSize( 200, 200 ) ) )
263 .FloatingPosition( FromDIP( wxPoint( 50, 50 ) ) )
264 .Show( false ) );
265
268
271
273
274 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( wxS( "LeftToolbar" ) )
275 .Left().Layer( 2 ) );
276
277 m_auimgr.AddPane( m_tbRight, EDA_PANE().VToolbar().Name( wxS( "RightToolbar" ) )
278 .Right().Layer( 2 ) );
279
280 // Center
281 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
282 .Center() );
283
284 m_auimgr.AddPane( m_searchPane, EDA_PANE()
285 .Name( SearchPaneName() )
286 .Bottom()
287 .Caption( _( "Search" ) )
288 .PaneBorder( false )
289 .MinSize( FromDIP( wxSize( 180, 60 ) ) )
290 .BestSize( FromDIP( wxSize( 180, 100 ) ) )
291 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
292 .CloseButton( true )
293 .DestroyOnClose( false )
294 .Show( m_show_search ) );
295
298
299 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
300 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
301 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
302 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
303 wxAuiPaneInfo& designBlocksPane = m_auimgr.GetPane( DesignBlocksPaneName() );
304 wxAuiPaneInfo& remoteSymbolPane = m_auimgr.GetPane( RemoteSymbolPaneName() );
305
306 hierarchy_pane.Show( aui_cfg.show_schematic_hierarchy );
307 netNavigatorPane.Show( aui_cfg.show_net_nav_panel );
308 propertiesPane.Show( aui_cfg.show_properties );
309 designBlocksPane.Show( aui_cfg.design_blocks_show );
310
311 if( m_remoteSymbolPane && !m_remoteSymbolPane->HasDataSources() )
312 remoteSymbolPane.Show( false );
313 else
314 remoteSymbolPane.Show( aui_cfg.remote_symbol_show );
315
317
318 // The selection filter doesn't need to grow in the vertical direction when docked
319 selectionFilterPane.dock_proportion = 0;
320
321 if( aui_cfg.hierarchy_panel_float_width > 0 && aui_cfg.hierarchy_panel_float_height > 0 )
322 {
323 // Show at end, after positioning
324 hierarchy_pane.FloatingSize( aui_cfg.hierarchy_panel_float_width,
326 }
327
328 if( aui_cfg.net_nav_panel_float_size.GetWidth() > 0
329 && aui_cfg.net_nav_panel_float_size.GetHeight() > 0 )
330 {
331 netNavigatorPane.FloatingSize( aui_cfg.net_nav_panel_float_size );
332 netNavigatorPane.FloatingPosition( aui_cfg.net_nav_panel_float_pos );
333 }
334
335 if( aui_cfg.properties_panel_width > 0 )
336 SetAuiPaneSize( m_auimgr, propertiesPane, aui_cfg.properties_panel_width, -1 );
337
338 if( aui_cfg.schematic_hierarchy_float )
339 hierarchy_pane.Float();
340
341 if( aui_cfg.search_panel_height > 0 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_TOP
342 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
343 {
344 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
345 searchPane.Direction( aui_cfg.search_panel_dock_direction );
346 SetAuiPaneSize( m_auimgr, searchPane, -1, aui_cfg.search_panel_height );
347 }
348
349 else if( aui_cfg.search_panel_width > 0 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_LEFT
350 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
351 {
352 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
353 searchPane.Direction( aui_cfg.search_panel_dock_direction );
354 SetAuiPaneSize( m_auimgr, searchPane, aui_cfg.search_panel_width, -1 );
355 }
356
357 if( aui_cfg.float_net_nav_panel )
358 netNavigatorPane.Float();
359
360 if( aui_cfg.design_blocks_show )
361 SetAuiPaneSize( m_auimgr, designBlocksPane, aui_cfg.design_blocks_panel_docked_width, -1 );
362
363 if( aui_cfg.remote_symbol_show )
364 {
365 SetAuiPaneSize( m_auimgr, remoteSymbolPane, aui_cfg.remote_symbol_panel_docked_width, -1 );
366 }
367
368 if( aui_cfg.hierarchy_panel_docked_width > 0 )
369 {
370 // If the net navigator is not show, let the hierarchy navigator take all of the vertical
371 // space.
372 if( !aui_cfg.show_net_nav_panel )
373 {
374 SetAuiPaneSize( m_auimgr, hierarchy_pane, aui_cfg.hierarchy_panel_docked_width, -1 );
375 }
376 else
377 {
378 SetAuiPaneSize( m_auimgr, hierarchy_pane,
381
382 SetAuiPaneSize( m_auimgr, netNavigatorPane,
383 aui_cfg.net_nav_panel_docked_size.GetWidth(),
384 aui_cfg.net_nav_panel_docked_size.GetHeight() );
385 }
386
387 // wxAUI hack: force width by setting MinSize() and then Fixed()
388 // thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
389 hierarchy_pane.MinSize( aui_cfg.hierarchy_panel_docked_width, 60 );
390 hierarchy_pane.Fixed();
391 netNavigatorPane.MinSize( aui_cfg.net_nav_panel_docked_size.GetWidth(), 60 );
392 netNavigatorPane.Fixed();
393 m_auimgr.Update();
394
395 // now make it resizable again
396 hierarchy_pane.Resizable();
397 netNavigatorPane.Resizable();
398 m_auimgr.Update();
399
400 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
401 // back to minimum.
402 hierarchy_pane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
403 netNavigatorPane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
404 }
405 else
406 {
407 m_auimgr.Update();
408 }
409
410 CallAfter( [this]()
411 {
412 wxAuiPaneInfo& remotePane = m_auimgr.GetPane( RemoteSymbolPaneName() );
413
414 if( remotePane.IsShown() && m_remoteSymbolPane )
415 m_remoteSymbolPane->Activate();
416 } );
417
420
421 GetCanvas()->GetGAL()->SetAxesEnabled( false );
422
423 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
424 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
425
428
429 view->SetLayerVisible( LAYER_ERC_ERR, appearance_cfg.show_erc_errors );
430 view->SetLayerVisible( LAYER_ERC_WARN, appearance_cfg.show_erc_warnings );
432 view->SetLayerVisible( LAYER_OP_VOLTAGES, appearance_cfg.show_op_voltages );
433 view->SetLayerVisible( LAYER_OP_CURRENTS, appearance_cfg.show_op_currents );
434
436
438 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging, this );
439 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
440 m_netNavigator->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onResizeNetNavigator, this );
441
442 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
443 // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
444 Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
445
446 setupUnits( eeconfig() );
447
448 // Net list generator
450
451 updateTitle();
452 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
453
454#ifdef KICAD_IPC_API
455 m_apiHandler = std::make_unique<API_HANDLER_SCH>( this );
456 Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
457#endif
458
459 // Default shutdown reason until a file is loaded
460 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
461
462 // Init for dropping files
466 m_acceptedExts.emplace( wxS( "jpeg" ), &SCH_ACTIONS::ddAddImage );
467 m_acceptedExts.emplace( wxS( "dxf" ), &SCH_ACTIONS::ddImportGraphics );
469 DragAcceptFiles( true );
470
471 // Ensure the window is on top
472 Raise();
473
474 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
475 // top-left corner of the canvas
476 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
477 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
478
479 Bind( wxEVT_CHOICE, &SCH_EDIT_FRAME::onVariantSelected, this );
480 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
481 Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
482 Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog, this );
483}
484
485void SCH_EDIT_FRAME::StartCrossProbeFlash( const std::vector<SCH_ITEM*>& aItems )
486{
487 if( !eeconfig()->m_CrossProbing.flash_selection )
488 {
489 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: aborted (setting disabled) items=%zu", aItems.size() );
490 return;
491 }
492
493 if( aItems.empty() )
494 {
495 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: aborted (no items)" );
496 return;
497 }
498
500 {
501 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: restarting existing flash (phase=%d)",
504 }
505
506 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: starting with %zu items", aItems.size() );
508
509 for( SCH_ITEM* it : aItems )
510 m_crossProbeFlashItems.push_back( it->m_Uuid );
511
514
515 if( !m_crossProbeFlashTimer.GetOwner() )
516 m_crossProbeFlashTimer.SetOwner( this );
517
518 bool started = m_crossProbeFlashTimer.Start( 500, wxTIMER_CONTINUOUS );
519 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: timer start=%d id=%d", (int) started,
520 m_crossProbeFlashTimer.GetId() );
521}
522
523
524void SCH_EDIT_FRAME::OnCrossProbeFlashTimer( wxTimerEvent& aEvent )
525{
526 wxLogTrace( traceCrossProbeFlash, "Timer(SCH) fired: phase=%d running=%d items=%zu", m_crossProbeFlashPhase,
528
530 {
531 wxLogTrace( traceCrossProbeFlash, "Timer fired but not flashing (ignored)" );
532 return;
533 }
534
536
537 if( !selTool )
538 return;
539
540 bool prevGuard = m_syncingPcbToSchSelection;
542
543 if( m_crossProbeFlashPhase % 2 == 0 )
544 {
545 selTool->ClearSelection( true );
546 wxLogTrace( traceCrossProbeFlash, "Phase %d: cleared selection", m_crossProbeFlashPhase );
547 }
548 else
549 {
550 for( const KIID& id : m_crossProbeFlashItems )
551 {
552 if( SCH_ITEM* item = Schematic().ResolveItem( id, nullptr, true ) )
553 selTool->AddItemToSel( item, true );
554 }
555
556 wxLogTrace( traceCrossProbeFlash, "Phase %d: restored %zu items", m_crossProbeFlashPhase,
557 m_crossProbeFlashItems.size() );
558 }
559
560 if( GetCanvas() )
561 {
563 wxLogTrace( traceCrossProbeFlash, "Phase %d: forced canvas refresh", m_crossProbeFlashPhase );
564 }
565
566 m_syncingPcbToSchSelection = prevGuard;
568
569 if( m_crossProbeFlashPhase > 6 )
570 {
571 for( const KIID& id : m_crossProbeFlashItems )
572 {
573 if( SCH_ITEM* item = Schematic().ResolveItem( id, nullptr, true ) )
574 selTool->AddItemToSel( item, true );
575 }
576
577 m_crossProbeFlashing = false;
579 wxLogTrace( traceCrossProbeFlash, "Flashing complete. Final selection size=%zu",
580 m_crossProbeFlashItems.size() );
581 }
582}
583
584
586{
587 m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
588
589 // Ensure m_canvasType is up to date, to save it in config
591
592 SetScreen( nullptr );
593
594 if( m_schematic )
595 m_schematic->RemoveAllListeners();
596
597 // Canvas outlives m_schematic; detach tracker consumers before delete.
598 if( GetCanvas() && GetCanvas()->GetView() )
600
601 // Delete all items not in draw list before deleting schematic
602 // to avoid dangling pointers stored in these items
605
606 delete m_schematic;
607 m_schematic = nullptr;
608
609 // Close the project if we are standalone, so it gets cleaned up properly
610 if( Kiface().IsSingle() )
611 {
612 try
613 {
614 GetSettingsManager()->UnloadProject( &Prj(), false );
615 }
616 catch( const std::runtime_error& e )
617 {
618 wxFAIL_MSG( wxString::Format( wxT( "Settings exception occurred: %s" ), e.what() ) );
619 }
620 }
621
622 // We passed ownership of these to wxAuiManager.
623 // delete m_hierarchy;
624 // delete m_selectionFilterPanel;
625}
626
627
629{
630 aEvent.Skip();
631
632 // 1st Call: Handle the size update during the first resize event.
634
635 // Defer the second size capture
636 CallAfter( [this]()
637 {
639 } );
640}
641
642
644{
645 // Called when resizing the Hierarchy Navigator panel
646 // Store the current pane size
647 // It allows to retrieve the last defined pane size when switching between
648 // docked and floating pane state
649 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
650
651 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
652 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
653
654 if( cfg && m_hierarchy->IsShownOnScreen() )
655 {
656 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
657 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
658
659 // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
660 // width is > 0 (i.e. if its size is already set and has meaning)
661 // if it is floating, its size is not initialized (only floating_size is initialized)
662 // initializing hierarchy_pane.best_size is useful when switching to float pane and
663 // after switching to the docked pane, to retrieve the last docked pane width
664 if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
665 {
666 cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
667 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
668 }
669 }
670}
671
672
674{
675 // Create the manager and dispatcher & route draw panel events to the dispatcher
677 m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
678 GetCanvas()->GetViewControls(), config(), this );
679 m_actions = new SCH_ACTIONS();
681
682 // Register tools
683 m_toolManager->RegisterTool( new COMMON_CONTROL );
684 m_toolManager->RegisterTool( new COMMON_TOOLS );
685 m_toolManager->RegisterTool( new ZOOM_TOOL );
686 m_toolManager->RegisterTool( new SCH_SELECTION_TOOL );
687 m_toolManager->RegisterTool( new PICKER_TOOL );
688 m_toolManager->RegisterTool( new SCH_DRAWING_TOOLS );
689 m_toolManager->RegisterTool( new SCH_LINE_WIRE_BUS_TOOL );
690 m_toolManager->RegisterTool( new SCH_MOVE_TOOL );
691 m_toolManager->RegisterTool( new SCH_ALIGN_TOOL );
692 m_toolManager->RegisterTool( new SCH_EDIT_TOOL );
693 m_toolManager->RegisterTool( new SCH_EDIT_TABLE_TOOL );
694 m_toolManager->RegisterTool( new SCH_GROUP_TOOL );
695 m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL );
696 m_toolManager->RegisterTool( new SCH_DESIGN_BLOCK_CONTROL );
697 m_toolManager->RegisterTool( new SCH_EDITOR_CONTROL );
698 m_toolManager->RegisterTool( new SCH_FIND_REPLACE_TOOL );
699 m_toolManager->RegisterTool( new SCH_POINT_EDITOR );
700 m_toolManager->RegisterTool( new SCH_NAVIGATE_TOOL );
701 m_toolManager->RegisterTool( new PROPERTIES_TOOL );
702 m_toolManager->RegisterTool( new EMBED_TOOL );
703 m_toolManager->InitTools();
704
705 // Run the selection tool, it is supposed to be always active
707
709}
710
711
713{
715
716 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
717 SCH_EDITOR_CONDITIONS cond( this );
718
719 wxASSERT( mgr );
720
721 auto hasElements =
722 [ this ] ( const SELECTION& aSel )
723 {
724 return GetScreen() &&
725 ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
726 };
727
728 auto searchPaneCond =
729 [this] ( const SELECTION& )
730 {
731 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
732 };
733
734 auto propertiesCond =
735 [this] ( const SELECTION& )
736 {
737 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
738 };
739
740 auto hierarchyNavigatorCond =
741 [ this ] ( const SELECTION& aSel )
742 {
743 return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
744 };
745
746 auto netNavigatorCond =
747 [ this ] (const SELECTION& aSel )
748 {
749 return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
750 };
751
752 auto designBlockCond =
753 [ this ] (const SELECTION& aSel )
754 {
755 return m_auimgr.GetPane( DesignBlocksPaneName() ).IsShown();
756 };
757
758 auto remoteSymbolCond =
759 [ this ] (const SELECTION& aSel )
760 {
761 return m_auimgr.GetPane( RemoteSymbolPaneName() ).IsShown();
762 };
763
764 auto undoCond =
765 [ this ] (const SELECTION& aSel )
766 {
768 return true;
769
770 return GetUndoCommandCount() > 0;
771 };
772
773 auto groupWithDesignBlockLink =
774 [] ( const SELECTION& aSel )
775 {
776 if( aSel.Size() != 1 )
777 return false;
778
779 if( aSel[0]->Type() != SCH_GROUP_T )
780 return false;
781
782 SCH_GROUP* group = static_cast<SCH_GROUP*>( aSel.GetItem( 0 ) );
783
784 return group->HasDesignBlockLink();
785 };
786
787#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
788#define CHECK( x ) ACTION_CONDITIONS().Check( x )
789
791 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
793
794 mgr->SetConditions( SCH_ACTIONS::showSearch, CHECK( searchPaneCond ) );
795 mgr->SetConditions( SCH_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
796 mgr->SetConditions( SCH_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
797 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
798 mgr->SetConditions( SCH_ACTIONS::showDesignBlockPanel, CHECK( designBlockCond ) );
799 mgr->SetConditions( SCH_ACTIONS::showRemoteSymbolPanel, CHECK( remoteSymbolCond ) );
802
803 mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
804 mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
805 mgr->SetConditions( ACTIONS::copyAsText, ENABLE( hasElements ) );
808 mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
809 mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
816 mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
817 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
818
819 mgr->SetConditions( SCH_ACTIONS::rotateCW, ENABLE( hasElements ) );
820 mgr->SetConditions( SCH_ACTIONS::rotateCCW, ENABLE( hasElements ) );
821 mgr->SetConditions( SCH_ACTIONS::mirrorH, ENABLE( hasElements ) );
822 mgr->SetConditions( SCH_ACTIONS::mirrorV, ENABLE( hasElements ) );
825
826 mgr->SetConditions( SCH_ACTIONS::placeLinkedDesignBlock, ENABLE( groupWithDesignBlockLink ) );
827 mgr->SetConditions( SCH_ACTIONS::saveToLinkedDesignBlock, ENABLE( groupWithDesignBlockLink ) );
828
833
834 auto showHiddenPinsCond =
835 [this]( const SELECTION& )
836 {
837 return GetShowAllPins();
838 };
839
840 auto showHiddenFieldsCond =
841 [this]( const SELECTION& )
842 {
844 return cfg && cfg->m_Appearance.show_hidden_fields;
845 };
846
847 auto showDirectiveLabelsCond =
848 [this]( const SELECTION& )
849 {
851 return cfg && cfg->m_Appearance.show_directive_labels;
852 };
853
854 auto showERCErrorsCond =
855 [this]( const SELECTION& )
856 {
858 return cfg && cfg->m_Appearance.show_erc_errors;
859 };
860
861 auto showERCWarningsCond =
862 [this]( const SELECTION& )
863 {
865 return cfg && cfg->m_Appearance.show_erc_warnings;
866 };
867
868 auto showERCExclusionsCond =
869 [this]( const SELECTION& )
870 {
872 return cfg && cfg->m_Appearance.show_erc_exclusions;
873 };
874
875 auto markSimExclusionsCond =
876 [this]( const SELECTION& )
877 {
879 return cfg && cfg->m_Appearance.mark_sim_exclusions;
880 };
881
882 auto showOPVoltagesCond =
883 [this]( const SELECTION& )
884 {
886 return cfg && cfg->m_Appearance.show_op_voltages;
887 };
888
889 auto showOPCurrentsCond =
890 [this]( const SELECTION& )
891 {
893 return cfg && cfg->m_Appearance.show_op_currents;
894 };
895
896 auto showPinAltModeIconsCond =
897 [this]( const SELECTION& )
898 {
900 return cfg && cfg->m_Appearance.show_pin_alt_icons;
901 };
902
903 auto showAnnotateAutomaticallyCond =
904 [this]( const SELECTION& )
905 {
907 };
908
909 auto remapSymbolsCondition =
910 [&]( const SELECTION& aSel )
911 {
912 SCH_SCREENS schematic( Schematic().Root() );
913
914 // The remapping can only be performed on legacy projects.
915 return schematic.HasNoFullyDefinedLibIds();
916 };
917
918 auto belowRootSheetCondition =
919 [this]( const SELECTION& aSel )
920 {
921 SCH_NAVIGATE_TOOL* navigateTool = m_toolManager->GetTool<SCH_NAVIGATE_TOOL>();
922 return navigateTool && navigateTool->CanGoUp();
923 };
924
925 mgr->SetConditions( SCH_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
926
927 /* Some of these are bound by default to arrow keys which will get a different action if we
928 * disable the buttons. So always leave them enabled so the action is consistent.
929 * https://gitlab.com/kicad/code/kicad/-/issues/14783
930 mgr->SetConditions( SCH_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
931 mgr->SetConditions( SCH_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
932 mgr->SetConditions( SCH_ACTIONS::navigateBack, ENABLE( navHistoryHsBackward ) );
933 */
934
935 mgr->SetConditions( SCH_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
936 mgr->SetConditions( SCH_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
937 mgr->SetConditions( SCH_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
938 mgr->SetConditions( SCH_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
939 mgr->SetConditions( SCH_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
940 mgr->SetConditions( SCH_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
941 mgr->SetConditions( SCH_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
942 mgr->SetConditions( SCH_ACTIONS::markSimExclusions, CHECK( markSimExclusionsCond ) );
943 mgr->SetConditions( SCH_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
944 mgr->SetConditions( SCH_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
945 mgr->SetConditions( SCH_ACTIONS::togglePinAltIcons, CHECK( showPinAltModeIconsCond ) );
946 mgr->SetConditions( SCH_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
948
951
952#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
953
985
986#undef CURRENT_TOOL
987#undef CHECK
988#undef ENABLE
989}
990
991
993{
994 // we cannot store a pointer to an item in the display list here since
995 // that item may be deleted, such as part of a line concatenation or other.
996 // So simply always keep a copy of the object which is to be repeated.
997
998 if( aItem )
999 {
1000 m_items_to_repeat.clear();
1001
1002 AddCopyForRepeatItem( aItem );
1003 }
1004}
1005
1006
1008{
1009 // we cannot store a pointer to an item in the display list here since
1010 // that item may be deleted, such as part of a line concatenation or other.
1011 // So simply always keep a copy of the object which is to be repeated.
1012
1013 if( aItem )
1014 {
1015 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate( IGNORE_PARENT_GROUP ) ) );
1016
1017 // Clone() preserves the flags & parent, we want 'em cleared.
1018 repeatItem->ClearFlags();
1019 repeatItem->SetParent( nullptr );
1020
1021 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
1022 }
1023}
1024
1025
1026EDA_ITEM* SCH_EDIT_FRAME::ResolveItem( const KIID& aId, bool aAllowNullptrReturn ) const
1027{
1028 return Schematic().ResolveItem( aId, nullptr, aAllowNullptrReturn );
1029}
1030
1031
1036
1037
1042
1043
1045{
1046 return *m_schematic;
1047}
1048
1049
1051{
1052 return GetCurrentSheet().Last()->GetName();
1053}
1054
1055
1057{
1059}
1060
1061
1063{
1064 m_schematic->CreateDefaultScreens();
1065 SetScreen( Schematic().RootScreen() );
1066
1067 if( GetScreen() == nullptr )
1068 {
1069 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
1070 SetScreen( screen );
1071 }
1072}
1073
1074
1076{
1077 return m_schematic->CurrentSheet();
1078}
1079
1080
1082{
1083 if( aSheet != GetCurrentSheet() )
1084 {
1085 ClearFocus();
1086
1087 wxLogTrace( traceSchCurrentSheet,
1088 "SCH_EDIT_FRAME::SetCurrentSheet: Changing from path='%s' (size=%zu) to path='%s' (size=%zu)",
1089 GetCurrentSheet().Path().AsString(),
1090 GetCurrentSheet().size(),
1091 aSheet.Path().AsString(),
1092 aSheet.size() );
1093
1094 Schematic().SetCurrentSheet( aSheet );
1095 GetCanvas()->DisplaySheet( aSheet.LastScreen() );
1096 }
1097}
1098
1099
1101{
1103
1104 for( SCH_ITEM* item : screen->Items() )
1105 item->ClearCaches();
1106
1107 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
1108 {
1109 wxCHECK2( libSymbol.second, continue );
1110 libSymbol.second->ClearCaches();
1111 }
1112
1113 if( Schematic().Settings().m_IntersheetRefsShow )
1115
1116 ClearFocus();
1117
1118 GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
1119
1120 if( SCH_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>() )
1121 selectionTool->Reset( TOOL_BASE::REDRAW );
1122
1124}
1125
1126
1127bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
1128{
1129 // Exit interactive editing
1130 // Note this this will commit *some* pending changes. For instance, the SCH_POINT_EDITOR
1131 // will cancel any drag currently in progress, but commit all changes from previous drags.
1132 if( m_toolManager )
1134
1135 // Shutdown blocks must be determined and vetoed as early as possible
1136 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
1137 && IsContentModified() )
1138 {
1139 return false;
1140 }
1141
1142 if( Kiface().IsSingle() )
1143 {
1144 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1145
1146 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
1147 return false;
1148
1149 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
1150
1151 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
1152 return false;
1153
1154 // SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
1155 // sorry.
1156 auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
1157
1158 if( chooser && !chooser->Close() ) // Can close symbol chooser?
1159 return false;
1160 }
1161 else
1162 {
1163 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1164
1165 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
1166 {
1167 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
1168 return false;
1169 }
1170 }
1171
1172 if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
1173 return false;
1174
1176 && !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
1177 {
1178 return false;
1179 }
1180
1181 // We may have gotten multiple events; don't clean up twice
1182 if( !Schematic().IsValid() )
1183 return false;
1184
1185 if( IsContentModified() )
1186 {
1187 wxFileName fileName = Schematic().RootScreen()->GetFileName();
1188 wxString msg = _( "Save changes to '%s' before closing?" );
1189
1190 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1191 [&]() -> bool
1192 {
1193 return SaveProject();
1194 } ) )
1195 {
1196 return false;
1197 }
1198
1199 // If user selected 'No' (discard), create duplicate commit of last saved state and
1200 // move Last_Save tag forward so history shows an explicit discard event.
1201 if( GetLastUnsavedChangesResponse() == wxID_NO )
1202 {
1203 wxString projPath = Prj().GetProjectPath();
1204
1205 if( !projPath.IsEmpty() && Kiway().LocalHistory().HistoryExists( projPath ) )
1206 {
1207 Kiway().LocalHistory().CommitDuplicateOfLastSave( projPath, wxS( "Schematic" ),
1208 wxS( "Discard unsaved schematic changes" ) );
1209 }
1210 }
1211 }
1212
1213 return true;
1214}
1215
1216
1218{
1219 // Unregister the autosave saver before any cleanup that might invalidate m_schematic
1220 if( m_schematic )
1222
1224
1225 SCH_SHEET_LIST sheetlist = Schematic().Hierarchy();
1226
1227 if( !Prj().IsNullProject() )
1228 {
1229 std::vector<wxString> sheetSrcs;
1230 sheetSrcs.reserve( sheetlist.size() );
1231
1232 for( const SCH_SHEET_PATH& path : sheetlist )
1233 {
1234 SCH_SCREEN* screen = path.LastScreen();
1235
1236 // Only sweep autosaves for sheets actually dirtied in this session.
1237 // A clean sheet's autosave, if any, is a previous-session leftover the
1238 // user explicitly deferred in the recovery dialog.
1239 if( screen && screen->IsContentModified() )
1240 sheetSrcs.push_back( Prj().AbsolutePath( screen->GetFileName() ) );
1241 }
1242
1243 Kiway().LocalHistory().RemoveAutosaveFiles( Prj().GetProjectPath(), sheetSrcs );
1244 }
1245
1246#ifdef KICAD_IPC_API
1247 Pgm().GetApiServer().DeregisterHandler( m_apiHandler.get() );
1248 wxTheApp->Unbind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED, &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
1249#endif
1250
1251 // Close modeless dialogs. They're trouble when they get destroyed after the frame.
1252 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
1253 Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
1254 Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog, this );
1255 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging, this );
1256 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
1257
1258 if( m_diffSymbolDialog )
1259 {
1260 m_diffSymbolDialog->Destroy();
1261 m_diffSymbolDialog = nullptr;
1262 }
1263
1264 if( m_ercDialog )
1265 {
1266 m_ercDialog->Destroy();
1267 m_ercDialog = nullptr;
1268 }
1269
1271 {
1272 m_symbolFieldsTableDialog->Destroy();
1273 m_symbolFieldsTableDialog = nullptr;
1274 }
1275
1276 // Make sure local settings are persisted
1277 if( Prj().GetLocalSettings().ShouldAutoSave() )
1279
1280 delete m_toolManager;
1281 m_toolManager = nullptr;
1282
1283 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
1284
1285 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
1286 {
1287 hierarchy_pane.Show( false );
1288 m_auimgr.Update();
1289 }
1290
1291 sheetlist.ClearModifyStatus();
1292
1293 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
1294
1295 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
1296 UpdateFileHistory( fileName );
1297
1298 // Clear the view before freeing any schematic items. VIEW::Clear() walks m_allItems and
1299 // touches each item's private data, so the items must still be alive when this runs.
1300 SetScreen( nullptr );
1301
1302 Schematic().RootScreen()->Clear( true );
1303
1304 // all sub sheets are deleted, only the main sheet is usable
1306
1307 Schematic().Reset();
1308
1309 // Prevents any rogue events from continuing (i.e. search panel tries to redraw)
1310 Show( false );
1311
1312 Destroy();
1313}
1314
1315
1317{
1318 m_searchPane->FocusSearch();
1319}
1320
1321
1323{
1324 return Schematic().ErcSettings().GetSeverity( aErrorCode );
1325}
1326
1327
1329{
1331
1332 if( GetScreen() )
1333 {
1335 Kiway().LocalHistory().NoteFileChange( GetScreen()->GetFileName() );
1336 }
1337
1338 if( m_isClosing )
1339 return;
1340
1341 if( GetCanvas() )
1342 GetCanvas()->Refresh();
1343
1344 if( GetScreen() && !GetTitle().StartsWith( wxS( "*" ) ) )
1345 updateTitle();
1346}
1347
1348
1350{
1351 if( Kiface().IsSingle() )
1352 {
1353 DisplayError( this, _( "Cannot update the PCB because the Schematic Editor is opened in stand-alone "
1354 "mode. In order to create/update PCBs from schematics, launch the main KiCad "
1355 "application and create a project." ) );
1356 return;
1357 }
1358
1359 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1360 wxEventBlocker blocker( this );
1361
1362 if( !frame )
1363 {
1364 wxFileName fn = Prj().GetProjectFullName();
1365 fn.SetExt( FILEEXT::PcbFileExtension );
1366
1367 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1368
1369 // If Kiway() cannot create the Pcbnew frame, it shows a error message, and
1370 // frame is null
1371 if( !frame )
1372 return;
1373
1374 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1375 }
1376
1377 if( !frame->IsVisible() )
1378 frame->Show( true );
1379
1380 // On Windows, Raise() does not bring the window on screen, when iconized
1381 if( frame->IsIconized() )
1382 frame->Iconize( false );
1383
1384 frame->Raise();
1385
1386 std::string payload;
1388}
1389
1390
1391void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator, bool aClear )
1392{
1393 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
1394 m_hierarchy->UpdateHierarchyTree( aClear );
1395
1396 if( aRefreshNetNavigator )
1398}
1399
1400
1402{
1403 // Update only the hierarchy navigation tree labels.
1404 // The tree list is expected to be up to date
1405 m_hierarchy->UpdateLabelsHierarchyTree();
1406}
1407
1408
1410{
1411 m_hierarchy->UpdateHierarchySelection();
1412}
1413
1414
1415void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1416{
1417 wxString filename = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1418
1419 if( !filename.IsEmpty() )
1420 OpenProjectFiles( std::vector<wxString>( 1, filename ) );
1421}
1422
1423
1424void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
1425{
1427}
1428
1429
1431{
1432 // Only standalone mode can directly load a new document
1433 if( !Kiface().IsSingle() )
1434 return;
1435
1436 wxString pro_dir = m_mruPath;
1437
1438 wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString, FILEEXT::KiCadSchematicFileWildcard(),
1439 wxFD_SAVE );
1440
1442
1443 if( dlg.ShowModal() != wxID_CANCEL )
1444 {
1445 // Enforce the extension, wxFileDialog is inept.
1446 wxFileName create_me = EnsureFileExtension( dlg.GetPath(), FILEEXT::KiCadSchematicFileExtension );
1447
1448 if( create_me.FileExists() )
1449 {
1450 wxString msg;
1451 msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
1452 DisplayError( this, msg );
1453 return ;
1454 }
1455
1456 // OpenProjectFiles() requires absolute
1457 wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
1458
1459 OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1460 m_mruPath = create_me.GetPath();
1461 }
1462}
1463
1464
1466{
1467 // Only standalone mode can directly load a new document
1468 if( !Kiface().IsSingle() )
1469 return;
1470
1471 wxString pro_dir = m_mruPath;
1472 wxString wildcards = FILEEXT::AllSchematicFilesWildcard()
1474 + wxS( "|" ) + FILEEXT::LegacySchematicFileWildcard();
1475
1476 wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString, wildcards,
1477 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1478
1480
1481 if( dlg.ShowModal() != wxID_CANCEL )
1482 {
1483 OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1485 }
1486
1487 // Since we know we're single-top here: trigger library reload
1488 CallAfter(
1489 [&]()
1490 {
1491 KIFACE *schface = Kiway().KiFACE( KIWAY::FACE_SCH );
1492 schface->PreloadLibraries( &Kiway() );
1493
1495 } );
1496}
1497
1498
1500{
1502
1503 // Register schematic saver for autosave history
1505 [this]( const wxString& aProjectPath, std::vector<HISTORY_FILE_DATA>& aFileData )
1506 {
1507 m_schematic->SaveToHistory( aProjectPath, aFileData );
1508 } );
1509
1510 m_designBlocksPane->ProjectChanged();
1511}
1512
1513
1515{
1516 // Use the project's board, not the active sheet's name, which may belong to another project.
1517 wxString projectName = Prj().GetProjectFullName();
1518
1519 wxFileName kicad_board =
1520 projectName.IsEmpty() ? Prj().AbsolutePath( Schematic().GetFileName() ) : wxFileName( projectName );
1521
1522 if( kicad_board.IsOk() && !kicad_board.GetName().IsEmpty() )
1523 {
1524 kicad_board.SetExt( FILEEXT::PcbFileExtension );
1525 wxFileName legacy_board( kicad_board );
1526 legacy_board.SetExt( FILEEXT::LegacyPcbFileExtension );
1527 wxFileName& boardfn = legacy_board;
1528
1529 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1530 boardfn = kicad_board;
1531
1532 if( Kiface().IsSingle() )
1533 {
1534 ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
1535 }
1536 else
1537 {
1538 wxEventBlocker blocker(this);
1539 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1540
1541 if( !frame )
1542 {
1543 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1544
1545 // frame can be null if Cvpcb cannot be run. No need to show a warning
1546 // Kiway() generates the error messages
1547 if( !frame )
1548 return;
1549
1550 frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1551 }
1552
1553 if( !frame->IsVisible() )
1554 frame->Show( true );
1555
1556 // On Windows, Raise() does not bring the window on screen, when iconized
1557 if( frame->IsIconized() )
1558 frame->Iconize( false );
1559
1560 frame->Raise();
1561 }
1562 }
1563 else
1564 {
1566 }
1567}
1568
1569
1571{
1572 wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1573 fn.SetExt( FILEEXT::NetlistFileExtension );
1574
1575 if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1576 return;
1577
1578 try
1579 {
1580 KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1581
1582 if( !player )
1583 {
1584 player = Kiway().Player( FRAME_CVPCB, true );
1585
1586 // player can be null if Cvpcb cannot be run. No need to show a warning
1587 // Kiway() generates the error messages
1588 if( !player )
1589 return;
1590
1591 player->Show( true );
1592 }
1593
1594 // Ensure the netlist (mainly info about symbols) is up to date
1597
1598 player->Raise();
1599 }
1600 catch( const IO_ERROR& )
1601 {
1602 DisplayError( this, _( "Could not open CvPcb" ) );
1603 }
1604}
1605
1606
1607void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1608{
1609 if( event.GetId() == wxID_EXIT )
1610 Kiway().OnKiCadExit();
1611
1612 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1613 Close( false );
1614}
1615
1616
1618{
1619 SCHEMATIC_SETTINGS& settings = m_schematic->Settings();
1620 SIM_LIB_MGR simLibMgr( &Prj() );
1621 NULL_REPORTER devnull;
1622 SCH_SHEET_PATH& sheetPath = GetCurrentSheet();
1623 wxString variant = m_schematic->GetCurrentVariant();
1624
1625 // Patch for bug early in V7.99 dev
1626 if( settings.m_OPO_VRange.EndsWith( 'A' ) )
1627 settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
1628
1629 // Update items which may have ${OP} text variables
1630 //
1632 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1633 {
1634 int flags = 0;
1635
1636 auto invalidateTextVars =
1637 [&flags]( EDA_TEXT* text )
1638 {
1639 if( text->HasTextVars() )
1640 {
1641 text->ClearRenderCache();
1642 text->ClearBoundingBoxCache();
1644 }
1645 };
1646
1647 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1648 {
1649 item->RunOnChildren(
1650 [&invalidateTextVars]( SCH_ITEM* aChild )
1651 {
1652 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1653 invalidateTextVars( text );
1654 },
1656 }
1657
1658 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1659 invalidateTextVars( text );
1660
1661 return flags;
1662 } );
1663
1664 // Update OP overlay items
1665 //
1666 for( SCH_ITEM* item : GetScreen()->Items() )
1667 {
1668 if( sheetPath.GetExcludedFromSim( variant ) )
1669 continue;
1670
1671 if( item->Type() == SCH_LINE_T )
1672 {
1673 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1674
1675 if( !line->GetOperatingPoint().IsEmpty() )
1676 GetCanvas()->GetView()->Update( line );
1677
1678 line->SetOperatingPoint( wxEmptyString );
1679
1680 // update value from netlist, below
1681 }
1682 else if( item->Type() == SCH_SYMBOL_T )
1683 {
1684 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1685 wxString ref = symbol->GetRef( &sheetPath );
1686 std::vector<SCH_PIN*> pins = symbol->GetPins( &sheetPath );
1687
1688 // Power symbols and other symbols which have the reference starting with "#" are
1689 // not included in simulation
1690 if( ref.StartsWith( '#' ) || symbol->ResolveExcludedFromSim( &sheetPath, variant ) )
1691 continue;
1692
1693 for( SCH_PIN* pin : pins )
1694 {
1695 if( !pin->GetOperatingPoint().IsEmpty() )
1696 GetCanvas()->GetView()->Update( pin );
1697
1698 pin->SetOperatingPoint( wxEmptyString );
1699 }
1700
1701 if( pins.size() == 2 )
1702 {
1703 wxString op = m_schematic->GetOperatingPoint( ref, settings.m_OPO_IPrecision, settings.m_OPO_IRange );
1704
1705 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1706 {
1707 pins[0]->SetOperatingPoint( op );
1708 GetCanvas()->GetView()->Update( symbol );
1709 }
1710 }
1711 else
1712 {
1713 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
1714 embeddedFilesStack.push_back( m_schematic->GetEmbeddedFiles() );
1715
1716 if( EMBEDDED_FILES* symbolEmbeddedFiles = symbol->GetEmbeddedFiles() )
1717 {
1718 embeddedFilesStack.push_back( symbolEmbeddedFiles );
1719 symbol->GetLibSymbolRef()->AppendParentEmbeddedFiles( embeddedFilesStack );
1720 }
1721
1722 simLibMgr.SetFilesStack( std::move( embeddedFilesStack ) );
1723
1724 SIM_MODEL& model = simLibMgr.CreateModel( &sheetPath, *symbol, true, 0, variant, devnull ).model;
1725
1726 SPICE_ITEM spiceItem;
1727 spiceItem.refName = ref;
1728 ref = model.SpiceGenerator().ItemName( spiceItem );
1729
1730 for( const auto& modelPin : model.GetPins() )
1731 {
1732 SCH_PIN* symbolPin = symbol->GetPin( modelPin.get().symbolPinNumber );
1733 wxString netChainName = ref + wxS( ":" ) + modelPin.get().modelPinName;
1734 wxString op = m_schematic->GetOperatingPoint( netChainName, settings.m_OPO_IPrecision,
1735 settings.m_OPO_IRange );
1736
1737 if( symbolPin && !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1738 {
1739 symbolPin->SetOperatingPoint( op );
1740 GetCanvas()->GetView()->Update( symbol );
1741 }
1742 }
1743 }
1744 }
1745 }
1746
1747 for( const auto& [ key, subgraphList ] : m_schematic->m_connectionGraph->GetNetMap() )
1748 {
1749 wxString op = m_schematic->GetOperatingPoint( key.Name, settings.m_OPO_VPrecision, settings.m_OPO_VRange );
1750
1751 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1752 {
1753 for( CONNECTION_SUBGRAPH* subgraph : subgraphList )
1754 {
1755 SCH_LINE* longestWire = nullptr;
1756 double length = 0.0;
1757
1758 if( subgraph->GetSheet().GetExcludedFromSim( variant ) )
1759 continue;
1760
1761 for( SCH_ITEM* item : subgraph->GetItems() )
1762 {
1763 if( item->Type() == SCH_LINE_T )
1764 {
1765 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1766
1767 if( line->IsWire() && line->GetLength() > length )
1768 {
1769 longestWire = line;
1770 length = line->GetLength();
1771 }
1772 }
1773 }
1774
1775 if( longestWire )
1776 {
1777 longestWire->SetOperatingPoint( op );
1778 GetCanvas()->GetView()->Update( longestWire );
1779 }
1780 }
1781 }
1782 }
1783}
1784
1785
1787{
1788 if( aItem->Type() == SCH_GLOBAL_LABEL_T || aItem->Type() == SCH_HIER_LABEL_T )
1789 {
1790 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
1791
1792 if( label->AutoRotateOnPlacement() )
1793 {
1794 SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(), label->GetSpinStyle(),
1795 &GetCurrentSheet() );
1796
1797 if( spin != label->GetSpinStyle() )
1798 {
1799 label->SetSpinStyle( spin );
1800
1801 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1802 {
1803 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1804
1805 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1806 otherLabel->AutoplaceFields( aScreen, AUTOPLACE_AUTO );
1807 }
1808 }
1809 }
1810 }
1811}
1812
1813
1815{
1816 SCH_SCREEN* screen = GetScreen();
1817
1818 wxCHECK( screen, /* void */ );
1819
1820 wxString title;
1821
1822 if( !screen->GetFileName().IsEmpty() )
1823 {
1824 wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1825 bool readOnly = false;
1826 bool unsaved = false;
1827
1828 if( fn.IsOk() && screen->FileExists() )
1829 readOnly = screen->IsReadOnly();
1830 else
1831 unsaved = true;
1832
1833 if( IsContentModified() )
1834 title = wxT( "*" );
1835
1836 title += fn.GetName();
1837
1838 wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
1839
1840 if( sheetPath != fn.GetName() )
1841 title += wxString::Format( wxT( " [%s]" ), sheetPath );
1842
1843 if( readOnly )
1844 title += wxS( " " ) + _( "[Read Only]" );
1845
1846 if( unsaved )
1847 title += wxS( " " ) + _( "[Unsaved]" );
1848 }
1849 else
1850 {
1851 title = _( "[no schematic loaded]" );
1852 }
1853
1854 title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1855
1856 SetTitle( title );
1857}
1858
1859
1861{
1863
1864 if( GetScreen() )
1865 GetScreen()->m_zoomInitialized = true;
1866}
1867
1868
1870 PROGRESS_REPORTER* aProgressReporter )
1871{
1872 wxString highlightedConn = GetHighlightedConnection();
1873 bool hasHighlightedConn = !highlightedConn.IsEmpty();
1874
1875 std::function<void( SCH_ITEM* )> changeHandler =
1876 [&]( SCH_ITEM* aChangedItem ) -> void
1877 {
1878 GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1879
1880 SCH_CONNECTION* connection = aChangedItem->Connection();
1881
1883 return;
1884
1885 if( !hasHighlightedConn )
1886 {
1887 // No highlighted connection, but connectivity has changed, so refresh
1888 // the list of all nets
1890 }
1891 else if( connection && ( connection->Name() == highlightedConn
1892 || connection->HasDriverChanged() ) )
1893 {
1895 }
1896 };
1897
1898 Schematic().RecalculateConnections( aCommit, aCleanupFlags,
1900 aProgressReporter,
1901 GetCanvas()->GetView(),
1902 &changeHandler,
1903 m_undoList.m_CommandsList.empty() ? nullptr
1904 : m_undoList.m_CommandsList.back() );
1905
1907 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1908 {
1909 int flags = 0;
1910 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
1911 SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
1912
1913 auto invalidateTextVars =
1914 [&flags]( EDA_TEXT* text )
1915 {
1916 if( text->HasTextVars() )
1917 {
1918 text->ClearRenderCache();
1919 text->ClearBoundingBoxCache();
1921 }
1922 };
1923
1924 if( connection && connection->HasDriverChanged() )
1925 {
1926 connection->ClearDriverChanged();
1927 flags |= KIGFX::REPAINT;
1928 }
1929
1930 if( item )
1931 {
1932 item->RunOnChildren(
1933 [&invalidateTextVars]( SCH_ITEM* aChild )
1934 {
1935 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1936 invalidateTextVars( text );
1937 },
1939
1940 if( flags & KIGFX::GEOMETRY )
1941 GetScreen()->Update( item, false ); // Refresh RTree
1942 }
1943
1944 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1945 invalidateTextVars( text );
1946
1947 return flags;
1948 } );
1949
1951 || !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
1952 {
1956 }
1957}
1958
1959
1964
1965
1967{
1968 GetCanvas()->GetView()->Update( aItem );
1969}
1970
1971
1978
1979
1980std::unique_ptr<GRID_HELPER> SCH_EDIT_FRAME::MakeGridHelper()
1981{
1982 return std::make_unique<EE_GRID_HELPER>( m_toolManager );
1983}
1984
1985
1987{
1989
1990 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1991
1993
1994 if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
1995 {
1996 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1997 GetRenderSettings()->SetDefaultFont( cfg->m_Appearance.default_font );
1998
1999 KIGFX::VIEW* view = GetCanvas()->GetView();
2000 view->SetLayerVisible( LAYER_ERC_ERR, cfg->m_Appearance.show_erc_errors );
2001 view->SetLayerVisible( LAYER_ERC_WARN, cfg->m_Appearance.show_erc_warnings );
2002 view->SetLayerVisible( LAYER_ERC_EXCLUSION, cfg->m_Appearance.show_erc_exclusions );
2003 view->SetLayerVisible( LAYER_OP_VOLTAGES, cfg->m_Appearance.show_op_voltages );
2004 view->SetLayerVisible( LAYER_OP_CURRENTS, cfg->m_Appearance.show_op_currents );
2005
2006 GetRenderSettings()->m_ShowPinAltIcons = cfg->m_Appearance.show_pin_alt_icons;
2007
2009
2010 settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
2011
2012 if( !cfg->m_Drawing.field_names.IsEmpty() )
2013 settings.m_TemplateFieldNames.AddTemplateFieldNames( cfg->m_Drawing.field_names );
2014 }
2015
2017
2018 for( SCH_ITEM* item : screen->Items() )
2019 {
2020 item->ClearCaches();
2021
2022 if( item->Type() == SCH_LINE_T )
2023 {
2024 SCH_LINE* line = static_cast<SCH_LINE*>( item );
2025
2026 if( line->IsWire() || line->IsBus() )
2027 UpdateHopOveredWires( line );
2028 }
2029 }
2030
2031 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
2032 libSymbol->ClearCaches();
2033
2035
2037 Layout();
2038 SendSizeEvent();
2039}
2040
2041
2043{
2044 // Store the current zoom level into the current screen before calling
2045 // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
2047
2048 // Rebuild the sheet view (draw area and any other items):
2050}
2051
2052
2054{
2055 // call my base class
2057
2058 // tooltips in toolbars
2060
2061 // For some obscure reason, the AUI manager hides the first modified pane.
2062 // So force show panes
2063 wxAuiPaneInfo& design_blocks_pane_info = m_auimgr.GetPane( m_designBlocksPane );
2064 bool panel_shown = design_blocks_pane_info.IsShown();
2065 design_blocks_pane_info.Caption( _( "Design Blocks" ) );
2066 design_blocks_pane_info.Show( panel_shown );
2067
2068 m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
2069 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
2070 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
2071 m_auimgr.GetPane( m_designBlocksPane ).Caption( _( "Design Blocks" ) );
2072 m_auimgr.GetPane( RemoteSymbolPaneName() ).Caption( _( "Remote Symbols" ) );
2073 m_auimgr.Update();
2074 m_hierarchy->UpdateHierarchyTree();
2075
2076 // status bar
2078
2079 updateTitle();
2080
2081 // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
2082 // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
2083 // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
2084 // toolbar to update correctly.
2085#if defined( __WXMSW__ )
2086 PostSizeEvent();
2087#endif
2088}
2089
2090
2092{
2093 if( !GetHighlightedNetChain().IsEmpty() )
2094 {
2095 if( CONNECTION_GRAPH* graph = m_schematic->ConnectionGraph() )
2096 {
2097 if( SCH_NETCHAIN* sig = graph->GetNetChainByName( GetHighlightedNetChain() ) )
2098 {
2099 wxString nets;
2100
2101 for( const wxString& n : sig->GetNets() )
2102 {
2103 if( !nets.IsEmpty() )
2104 nets += wxT( ", " );
2105 nets += n;
2106 }
2107
2108 SetStatusText( wxString::Format( _( "Net chain members: %s" ), nets ) );
2109 return;
2110 }
2111 }
2112 }
2113
2114 if( !GetHighlightedConnection().IsEmpty() )
2115 {
2116 SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
2118 }
2119 else
2120 {
2121 SetStatusText( wxT( "" ) );
2122 }
2123}
2124
2125
2127{
2128 if( m_toolManager )
2130
2131 SCH_BASE_FRAME::SetScreen( aScreen );
2132 GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
2133
2134 if( m_toolManager )
2136}
2137
2138
2139const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
2140{
2141 BOX2I bBoxDoc;
2142
2143 if( !GetScreen() )
2144 return bBoxDoc;
2145
2146 if( aIncludeAllVisible )
2147 {
2148 // Get the whole page size and return that
2149 int sizeX = GetScreen()->GetPageSettings().GetWidthIU( schIUScale.IU_PER_MILS );
2150 int sizeY = GetScreen()->GetPageSettings().GetHeightIU( schIUScale.IU_PER_MILS );
2151 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
2152 }
2153 else
2154 {
2155 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
2157 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
2158
2159 // Calc the bounding box of all items on screen except the page border
2160 for( EDA_ITEM* item : GetScreen()->Items() )
2161 {
2162 if( item != dsAsItem ) // Ignore the drawing-sheet itself
2163 bBoxDoc.Merge( item->GetBoundingBox() );
2164 }
2165 }
2166
2167 return bBoxDoc;
2168}
2169
2170
2172{
2173 if( !Schematic().HasHierarchy() )
2174 return false;
2175
2176 return Schematic().Hierarchy().IsModified();
2177}
2178
2179
2181{
2182 EESCHEMA_SETTINGS* cfg = eeconfig();
2183 return cfg && cfg->m_Appearance.show_hidden_pins;
2184}
2185
2186
2187void SCH_EDIT_FRAME::FocusOnItem( EDA_ITEM* aItem, bool aAllowScroll )
2188{
2189 // nullptr will clear the current focus
2190 if( aItem != nullptr && !aItem->IsSCH_ITEM() )
2191 return;
2192
2193 static KIID lastBrightenedItemID( niluuid );
2194
2195 SCH_ITEM* lastItem = Schematic().ResolveItem( lastBrightenedItemID, nullptr, true );
2196
2197 if( lastItem && lastItem != aItem )
2198 {
2199 lastItem->ClearBrightened();
2200
2201 UpdateItem( lastItem );
2202 lastBrightenedItemID = niluuid;
2203 }
2204
2205 if( aItem )
2206 {
2207 if( !aItem->IsBrightened() )
2208 {
2209 aItem->SetBrightened();
2210
2211 UpdateItem( aItem );
2212 lastBrightenedItemID = aItem->m_Uuid;
2213 }
2214
2215 FocusOnLocation( aItem->GetFocusPosition(), aAllowScroll );
2216 }
2217}
2218
2219
2221{
2222 return Schematic().GetFileName();
2223}
2224
2225
2227{
2228 return m_toolManager->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
2229}
2230
2231void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2232{
2233 if( IsShown() )
2234 {
2235 // We only need this until the frame is done resizing and the final client size is
2236 // established.
2237 Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
2239 }
2240
2241 // Skip() is called in the base class.
2242 EDA_DRAW_FRAME::OnSize( aEvent );
2243}
2244
2245
2247 const KIID& aSchematicSymbolUUID )
2248{
2249 SCH_SHEET_PATH principalPath;
2250 SCH_SHEET_LIST sheets = Schematic().Hierarchy();
2251 SCH_ITEM* item = sheets.ResolveItem( aSchematicSymbolUUID, &principalPath, true );
2252 SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
2253 SCH_COMMIT commit( m_toolManager );
2254
2255 if( !principalSymbol )
2256 return;
2257
2258 wxString principalRef;
2259
2260 if( principalSymbol->IsAnnotated( &principalPath ) )
2261 principalRef = principalSymbol->GetRef( &principalPath, false );
2262
2263 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
2264
2265 for( const SCH_SHEET_PATH& path : sheets )
2266 {
2267 for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2268 {
2269 SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
2270
2271 if( candidateSymbol == principalSymbol
2272 || ( candidateSymbol->IsAnnotated( &path )
2273 && candidateSymbol->GetRef( &path, false ) == principalRef ) )
2274 {
2275 allUnits.emplace_back( candidateSymbol, path );
2276 }
2277 }
2278 }
2279
2280 for( auto& [ unit, path ] : allUnits )
2281 {
2282 // This needs to be done before the LIB_SYMBOL is changed to prevent stale
2283 // library symbols in the schematic file.
2284 path.LastScreen()->Remove( unit );
2285
2286 if( !unit->IsNew() )
2287 commit.Modify( unit, path.LastScreen() );
2288
2289 unit->SetLibSymbol( aSymbol.Flatten().release() );
2290 unit->UpdateFields( &GetCurrentSheet(),
2291 true, /* update style */
2292 true, /* update ref */
2293 true, /* update other fields */
2294 false, /* reset ref */
2295 false /* reset other fields */ );
2296
2297 path.LastScreen()->Append( unit );
2298 GetCanvas()->GetView()->Update( unit );
2299 }
2300
2301 // Clear any orphaned alternate pins.
2302 for( SCH_PIN* pin : principalSymbol->GetPins() )
2303 {
2304 wxString altName = pin->GetAlt();
2305
2306 if( altName.IsEmpty() )
2307 continue;
2308
2309 if( pin->GetAlternates().count( altName ) == 0 )
2310 pin->SetAlt( wxEmptyString );
2311 }
2312
2313 if( !commit.Empty() )
2314 commit.Push( _( "Save Symbol to Schematic" ) );
2315}
2316
2317
2318void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2319{
2320 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2321
2322 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
2323 sch_item->ClearCaches();
2324}
2325
2326
2328{
2329 wxCHECK( m_toolManager, /* void */ );
2330
2334
2335 wxCHECK( screen, /* void */ );
2336
2338
2339 SCH_BASE_FRAME::SetScreen( screen );
2340
2341 SetSheetNumberAndCount(); // will also update CurrentScreen()'s sheet number info
2342
2344
2345 // update the references, units, and intersheet-refs
2347
2348 // dangling state can also have changed if different units with different pin locations are
2349 // used
2352
2353 SCH_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>();
2354
2355 wxCHECK( selectionTool, /* void */ );
2356
2357 auto visit =
2358 [&]( EDA_ITEM* item )
2359 {
2361 && !m_findReplaceData->findString.IsEmpty()
2362 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
2363 {
2364 item->SetForceVisible( true );
2365 selectionTool->BrightenItem( item );
2366 }
2367 else if( item->IsBrightened() )
2368 {
2369 item->SetForceVisible( false );
2370 selectionTool->UnbrightenItem( item );
2371 }
2372 };
2373
2374 for( SCH_ITEM* item : screen->Items() )
2375 {
2376 visit( item );
2377
2378 item->RunOnChildren(
2379 [&]( SCH_ITEM* aChild )
2380 {
2381 visit( aChild );
2382 },
2384 }
2385
2386 if( !screen->m_zoomInitialized )
2387 {
2389 }
2390 else
2391 {
2392 // Set zoom to last used in this screen
2393 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
2394 GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
2395 }
2396
2397 updateTitle();
2398
2399 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
2400
2401 // Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
2403
2404 SCH_EDITOR_CONTROL* editTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
2405
2406 wxCHECK( editTool, /* void */ );
2407
2409 editTool->UpdateNetHighlighting( dummy );
2410
2411 m_hierarchy->UpdateHierarchySelection();
2412
2413 m_schematic->OnSchSheetChanged();
2414}
2415
2416
2418{
2419 if( !m_diffSymbolDialog )
2420 {
2422 _( "Compare Symbol with Library" ) );
2423
2424 m_diffSymbolDialog->m_sdbSizerApply->SetLabel( _( "Update Symbol from Library..." ) );
2425 m_diffSymbolDialog->m_sdbSizerApply->PostSizeEventToParent();
2426 m_diffSymbolDialog->m_sdbSizerApply->Show();
2427 }
2428
2429 return m_diffSymbolDialog;
2430}
2431
2432
2433void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
2434{
2435 if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
2436 {
2437 if( aEvent.GetId() == wxID_APPLY )
2438 {
2439 KIID symbolUUID = m_diffSymbolDialog->GetUserItemID();
2440
2441 CallAfter(
2442 [this, symbolUUID]()
2443 {
2444 EDA_ITEM* item = ResolveItem( symbolUUID );
2445
2446 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item ) )
2447 {
2448 m_toolManager->RunAction<EDA_ITEM*>( ACTIONS::selectItem, symbol );
2449
2451 dlg.ShowQuasiModal();
2452 }
2453 } );
2454 }
2455
2456 m_diffSymbolDialog->Destroy();
2457 m_diffSymbolDialog = nullptr;
2458 }
2459}
2460
2461
2463{
2464 if( !m_ercDialog )
2465 m_ercDialog = new DIALOG_ERC( this );
2466
2467 return m_ercDialog;
2468}
2469
2470
2471void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
2472{
2473 if( m_ercDialog )
2474 {
2475 m_ercDialog->Destroy();
2476 m_ercDialog = nullptr;
2477 }
2478}
2479
2480
2482{
2484 {
2485 auto* dlg = new DIALOG_SYMBOL_FIELDS_TABLE( this );
2486
2487 if( dlg->WasAborted() )
2488 {
2489 dlg->Destroy();
2490 return nullptr;
2491 }
2492
2494 }
2495
2497}
2498
2499
2501{
2502 return m_netNavigator;
2503}
2504
2505
2507{
2509 {
2510 m_symbolFieldsTableDialog->Destroy();
2511 m_symbolFieldsTableDialog = nullptr;
2512 }
2513}
2514
2515
2516void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
2517{
2518 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(), aListener );
2519
2520 // Don't add duplicate listeners.
2521 if( it == m_schematicChangeListeners.end() )
2522 m_schematicChangeListeners.push_back( aListener );
2523}
2524
2525
2527{
2528 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(), aListener );
2529
2530 // Don't add duplicate listeners.
2531 if( it != m_schematicChangeListeners.end() )
2532 m_schematicChangeListeners.erase( it );
2533}
2534
2535
2537{
2538 wxPanel* panel = new wxPanel( this );
2539
2540 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
2541
2542 // Create horizontal sizer for search control and gear button
2543 wxBoxSizer* searchSizer = new wxBoxSizer( wxHORIZONTAL );
2544
2545 m_netNavigatorFilter = new wxSearchCtrl( panel, wxID_ANY );
2546 m_netNavigatorFilter->SetDescriptiveText( _( "Filter nets" ) );
2547 m_netNavigatorFilter->ShowCancelButton( false );
2548 searchSizer->Add( m_netNavigatorFilter, 1, wxEXPAND | wxRIGHT, FromDIP( 2 ) );
2549
2550 m_netNavigatorMenuButton = new BITMAP_BUTTON( panel, wxID_ANY );
2552 m_netNavigatorMenuButton->SetPadding( 2 );
2553 searchSizer->Add( m_netNavigatorMenuButton, 0, wxALIGN_CENTER_VERTICAL );
2554
2555 sizer->Add( searchSizer, 0, wxEXPAND | wxALL, FromDIP( 2 ) );
2556
2557 m_netNavigator = new wxGenericTreeCtrl( panel, wxID_ANY, wxPoint( 0, 0 ), FromDIP( wxSize( 160, 250 ) ),
2558 wxTR_DEFAULT_STYLE | wxNO_BORDER );
2559 sizer->Add( m_netNavigator, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP( 2 ) );
2560
2561 panel->SetSizer( sizer );
2562
2563 m_netNavigatorFilter->Bind( wxEVT_COMMAND_TEXT_UPDATED, &SCH_EDIT_FRAME::onNetNavigatorFilterChanged, this );
2564 m_netNavigatorFilter->Bind( wxEVT_KEY_DOWN, &SCH_EDIT_FRAME::onNetNavigatorKey, this );
2565 m_netNavigator->Bind( wxEVT_KEY_DOWN, &SCH_EDIT_FRAME::onNetNavigatorKey, this );
2566 m_netNavigator->Bind( wxEVT_TREE_ITEM_MENU, &SCH_EDIT_FRAME::onNetNavigatorItemMenu, this );
2567 m_netNavigator->Bind( wxEVT_CONTEXT_MENU, &SCH_EDIT_FRAME::onNetNavigatorContextMenu, this );
2568
2569 m_netNavigatorMenuButton->Bind( wxEVT_LEFT_DOWN,
2570 [this]( wxMouseEvent& event )
2571 {
2572 wxMenu menu;
2573 wxMenuItem* wildcardItem = menu.AppendRadioItem( ID_NET_NAVIGATOR_SEARCH_WILDCARD,
2574 _( "Wildcard Search" ) );
2575 wxMenuItem* regexItem = menu.AppendRadioItem( ID_NET_NAVIGATOR_SEARCH_REGEX,
2576 _( "Regex Search" ) );
2577
2578 EESCHEMA_SETTINGS* cfg = eeconfig();
2579
2581 wildcardItem->Check();
2582 else
2583 regexItem->Check();
2584
2585 PopupMenu( &menu );
2586 } );
2587
2593
2594 return panel;
2595}
2596
2597
2598void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection,
2599 const NET_NAVIGATOR_ITEM_DATA* aSelection )
2600{
2601 bool refreshNetNavigator = aConnection != m_highlightedConn;
2602
2603 m_highlightedConn = aConnection;
2604
2605 if( refreshNetNavigator )
2606 {
2607 RefreshNetNavigator( aSelection );
2608
2609 if( m_hierarchy )
2610 m_hierarchy->UpdateNetHighlight( aConnection );
2611 }
2612}
2613
2614
2616{
2618
2619 if( m_netNavigator )
2620 {
2621 NET_NAVIGATOR_ITEM_DATA itemData;
2622 wxTreeItemId selection = m_netNavigator->GetSelection();
2623 bool refreshSelection = selection.IsOk() && selection != m_netNavigator->GetRootItem();
2624
2625 if( refreshSelection )
2626 {
2628 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
2629
2630 wxCHECK( tmp, /* void */ );
2631 itemData = *tmp;
2632 }
2633
2634 m_netNavigator->DeleteAllItems();
2635 RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
2636 }
2637}
2638
2639
2641{
2642 if( !m_netNavigator )
2643 return;
2644
2645 wxString newFilter = m_netNavigatorFilter ? m_netNavigatorFilter->GetValue() : wxString();
2646
2647 if( newFilter == m_netNavigatorFilterValue )
2648 return;
2649
2650 m_netNavigatorFilterValue = newFilter;
2651
2652 NET_NAVIGATOR_ITEM_DATA selectionData;
2653 NET_NAVIGATOR_ITEM_DATA* selectionPtr = nullptr;
2654
2655 wxTreeItemId selection = m_netNavigator->GetSelection();
2656
2657 if( selection.IsOk() )
2658 {
2659 if( NET_NAVIGATOR_ITEM_DATA* tmp =
2660 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) ) )
2661 {
2662 selectionData = *tmp;
2663 selectionPtr = &selectionData;
2664 }
2665 }
2666
2667 RefreshNetNavigator( selectionPtr );
2668
2669 aEvent.Skip();
2670}
2671
2672
2673void SCH_EDIT_FRAME::onNetNavigatorKey( wxKeyEvent& aEvent )
2674{
2675 if( aEvent.GetKeyCode() == WXK_ESCAPE )
2676 {
2677 // Clear the search string and refresh
2679 m_netNavigatorFilter->SetValue( wxEmptyString );
2680
2681 m_netNavigatorFilterValue = wxEmptyString;
2682
2684
2685 // Don't skip the event - we handled it
2686 return;
2687 }
2688
2689 aEvent.Skip();
2690}
2691
2692
2693
2695{
2696 showNetNavigatorMenu( aEvent.GetItem() );
2697}
2698
2699
2700void SCH_EDIT_FRAME::onNetNavigatorContextMenu( wxContextMenuEvent& aEvent )
2701{
2702 if( !m_netNavigator )
2703 return;
2704
2705 wxPoint screenPos = aEvent.GetPosition();
2706
2707 if( screenPos == wxDefaultPosition )
2708 screenPos = wxGetMousePosition();
2709
2710 wxPoint clientPos = m_netNavigator->ScreenToClient( screenPos );
2711 int flags = 0;
2712 wxTreeItemId item = m_netNavigator->HitTest( clientPos, flags );
2713
2714 showNetNavigatorMenu( item );
2715}
2716
2717
2718void SCH_EDIT_FRAME::showNetNavigatorMenu( const wxTreeItemId& aItem )
2719{
2720 if( !m_netNavigator )
2721 return;
2722
2723 wxMenu menu;
2724
2725 menu.Append( ID_NET_NAVIGATOR_EXPAND_ALL, _( "Expand All" ) );
2726 menu.Append( ID_NET_NAVIGATOR_COLLAPSE_ALL, _( "Collapse All" ) );
2727
2728 wxMenuItem* findInInspector = new wxMenuItem( &menu, ID_NET_NAVIGATOR_FIND_IN_INSPECTOR,
2729 _( "Find in Net Inspector" ) );
2730 menu.Append( findInInspector );
2731
2732 wxString netName;
2733
2734 if( aItem.IsOk() )
2735 {
2736 wxTreeItemId netItem = aItem;
2737
2738 if( m_netNavigator->GetItemParent( netItem ) != m_netNavigator->GetRootItem() )
2739 {
2740 wxTreeItemId parent = m_netNavigator->GetItemParent( netItem );
2741
2742 while( parent.IsOk() && parent != m_netNavigator->GetRootItem() )
2743 {
2744 netItem = parent;
2745 parent = m_netNavigator->GetItemParent( netItem );
2746 }
2747
2748 if( parent == m_netNavigator->GetRootItem() )
2749 {
2750 if( wxStringClientData* data =
2751 dynamic_cast<wxStringClientData*>( m_netNavigator->GetItemData( netItem ) ) )
2752 {
2753 netName = data->GetData();
2754 }
2755 }
2756 }
2757 else if( m_netNavigator->GetItemParent( netItem ) == m_netNavigator->GetRootItem() )
2758 {
2759 if( wxStringClientData* data =
2760 dynamic_cast<wxStringClientData*>( m_netNavigator->GetItemData( netItem ) ) )
2761 {
2762 netName = data->GetData();
2763 }
2764 }
2765 else if( !m_highlightedConn.IsEmpty() && netItem == m_netNavigator->GetRootItem() )
2766 {
2767 netName = m_highlightedConn;
2768 }
2769 }
2770 else if( !m_highlightedConn.IsEmpty() && m_netNavigator->GetRootItem().IsOk() )
2771 {
2772 netName = m_highlightedConn;
2773 }
2774
2775 if( netName.IsEmpty() )
2776 {
2777 findInInspector->Enable( false );
2779 }
2780 else
2781 {
2782 m_netNavigatorMenuNetName = netName;
2783 }
2784
2785 PopupMenu( &menu );
2786}
2787
2788
2789void SCH_EDIT_FRAME::onNetNavigatorMenuCommand( wxCommandEvent& aEvent )
2790{
2791 if( !m_netNavigator )
2792 return;
2793
2794 switch( aEvent.GetId() )
2795 {
2797 m_netNavigator->ExpandAll();
2798 break;
2799
2801 m_netNavigator->CollapseAll();
2802
2803 if( m_netNavigator->GetRootItem().IsOk() )
2804 m_netNavigator->Expand( m_netNavigator->GetRootItem() );
2805 break;
2806
2808 if( !m_netNavigatorMenuNetName.IsEmpty() )
2810 break;
2811
2814 if( EESCHEMA_SETTINGS* cfg = eeconfig() )
2815 {
2816 cfg->m_AuiPanels.net_nav_search_mode_wildcard = ( aEvent.GetId() == ID_NET_NAVIGATOR_SEARCH_WILDCARD );
2817
2818 // Refresh the navigator with current filter
2820 }
2821
2822 break;
2823
2824 default:
2825 aEvent.Skip();
2826 return;
2827 }
2828
2830
2831 aEvent.Skip( false );
2832}
2833
2834
2836{
2837 wxAuiPaneInfo& hierarchyPane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2838 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
2839 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
2840 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
2841
2842 // Don't give the selection filter its own visibility controls; instead show it if
2843 // anything else is visible
2844 bool showFilter = ( hierarchyPane.IsShown() && hierarchyPane.IsDocked() )
2845 || ( netNavigatorPane.IsShown() && netNavigatorPane.IsDocked() )
2846 || ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
2847
2848 selectionFilterPane.Show( showFilter );
2849}
2850
2851
2852#ifdef KICAD_IPC_API
2853void SCH_EDIT_FRAME::onPluginAvailabilityChanged( wxCommandEvent& aEvt )
2854{
2855 wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
2857 aEvt.Skip();
2858}
2859#endif
2860
2861
2863{
2864 EESCHEMA_SETTINGS* cfg = eeconfig();
2865
2866 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
2867 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
2868
2870
2871 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
2872 searchPaneInfo.Show( m_show_search );
2873
2874 if( m_show_search )
2875 {
2876 searchPaneInfo.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
2877
2878 if( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
2879 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
2880 {
2881 SetAuiPaneSize( m_auimgr, searchPaneInfo, -1, cfg->m_AuiPanels.search_panel_height );
2882 }
2883 else if( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
2884 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
2885 {
2886 SetAuiPaneSize( m_auimgr, searchPaneInfo, cfg->m_AuiPanels.search_panel_width, -1 );
2887 }
2888
2889 m_searchPane->FocusSearch();
2890 m_searchPane->RefreshSearch();
2891 }
2892 else
2893 {
2894 cfg->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
2895 cfg->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
2896 cfg->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
2897 m_auimgr.Update();
2898 }
2899}
2900
2901
2903{
2904 if( !m_propertiesPanel )
2905 return;
2906
2907 bool show = !m_propertiesPanel->IsShownOnScreen();
2908
2909 wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
2910 propertiesPaneInfo.Show( show );
2911
2913
2914 EESCHEMA_SETTINGS* settings = eeconfig();
2915
2916 if( show )
2917 {
2918 SetAuiPaneSize( m_auimgr, propertiesPaneInfo, settings->m_AuiPanels.properties_panel_width, -1 );
2919 }
2920 else
2921 {
2922 settings->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
2923 m_auimgr.Update();
2924 }
2925}
2926
2927
2929{
2930 EESCHEMA_SETTINGS* cfg = eeconfig();
2931
2932 wxCHECK( cfg, /* void */ );
2933
2934 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2935
2936 hierarchy_pane.Show( !hierarchy_pane.IsShown() );
2937
2939
2940 if( hierarchy_pane.IsShown() )
2941 {
2942 if( hierarchy_pane.IsFloating() )
2943 {
2944 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
2946 m_auimgr.Update();
2947 }
2948 else if( cfg->m_AuiPanels.hierarchy_panel_docked_width > 0 )
2949 {
2950 // SetAuiPaneSize also updates m_auimgr
2952 }
2953 }
2954 else
2955 {
2956 if( hierarchy_pane.IsFloating() )
2957 {
2958 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
2959 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
2960 }
2961 else
2962 {
2964 }
2965
2966 m_auimgr.Update();
2967 }
2968}
2969
2970
2972{
2973 EESCHEMA_SETTINGS* cfg = eeconfig();
2974
2975 wxCHECK( cfg, /* void */ );
2976
2977 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
2978
2979 db_library_pane.Show( !db_library_pane.IsShown() );
2980
2981 if( db_library_pane.IsShown() )
2982 {
2983 if( db_library_pane.IsFloating() )
2984 {
2985 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
2987 m_auimgr.Update();
2988 }
2989 else
2990 {
2991 // SetAuiPaneSize also updates m_auimgr
2992 SetAuiPaneSize( m_auimgr, db_library_pane,
2994 }
2995 }
2996 else
2997 {
2998 if( db_library_pane.IsFloating() )
2999 {
3000 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
3001 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
3002 }
3003 else
3004 {
3006 }
3007
3008 m_auimgr.Update();
3009 }
3010}
3011
3012
3014{
3015 EESCHEMA_SETTINGS* cfg = eeconfig();
3016
3017 wxCHECK( cfg, /* void */ );
3018
3019 wxAuiPaneInfo& remotePane = m_auimgr.GetPane( RemoteSymbolPaneName() );
3020
3021 remotePane.Show( !remotePane.IsShown() );
3022
3023 if( remotePane.IsShown() )
3024 {
3025 if( m_remoteSymbolPane )
3026 m_remoteSymbolPane->Activate();
3027
3028 if( remotePane.IsFloating() )
3029 {
3030 remotePane.FloatingSize( cfg->m_AuiPanels.remote_symbol_panel_float_width,
3032 m_auimgr.Update();
3033 }
3035 {
3036 SetAuiPaneSize( m_auimgr, remotePane,
3038 }
3039 }
3040 else
3041 {
3042 if( remotePane.IsFloating() )
3043 {
3044 cfg->m_AuiPanels.remote_symbol_panel_float_width = remotePane.floating_size.x;
3045 cfg->m_AuiPanels.remote_symbol_panel_float_height = remotePane.floating_size.y;
3046 }
3047 else if( m_remoteSymbolPane )
3048 {
3050 }
3051
3052 m_auimgr.Update();
3053 }
3054}
3055
3056
3058{
3059 wxCHECK( aSchematic, /* void */ );
3060
3061 if( m_schematic )
3062 {
3063 m_schematic->SetProject( nullptr );
3064
3065 // Detach before the outgoing schematic (and its tracker) is freed.
3066 if( GetCanvas() && GetCanvas()->GetView() )
3068
3070 }
3071
3072 aSchematic->SetProject( &Prj() );
3073 delete m_schematic;
3074
3075 m_schematic = aSchematic;
3076 m_schematic->SetSchematicHolder( this );
3077
3078 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
3079 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
3080 m_toolManager->SetEnvironment( m_schematic, GetCanvas()->GetView(), GetCanvas()->GetViewControls(), config(),
3081 this );
3082}
3083
3084
3086{
3088 return;
3089
3090 m_currentVariantCtrl->SetSelection( m_currentVariantCtrl->GetCount() - 1 );
3091
3092 wxCommandEvent dummy( wxEVT_CHOICE, ID_TOOLBAR_SCH_SELECT_VARAIANT );
3094}
3095
3096
3098{
3099 wxArrayString choices = Schematic().GetVariantNamesForUI();
3100
3101 // Default variant cannot be edited.
3102 choices.RemoveAt( 0 );
3103
3104 if( choices.IsEmpty() )
3105 {
3106 GetInfoBar()->ShowMessageFor( _( "No design variants to edit." ), 10000, wxICON_ERROR );
3107 return;
3108 }
3109
3110 wxSingleChoiceDialog chooser( this, _( "Select variant to edit description:" ) + wxS( " " ),
3111 _( "Edit Variant Description" ), choices );
3112 chooser.Layout();
3113
3114 if( chooser.ShowModal() == wxID_CANCEL )
3115 return;
3116
3117 wxString variantName = chooser.GetStringSelection();
3118
3119 if( variantName.IsEmpty() )
3120 return;
3121
3122 wxString currentDesc = Schematic().GetVariantDescription( variantName );
3123
3124 wxDialog dlg( this, wxID_ANY, wxString::Format( _( "Edit Description for '%s'" ), variantName ), wxDefaultPosition,
3125 wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
3126
3127 wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
3128
3129 wxStaticText* label = new wxStaticText( &dlg, wxID_ANY, _( "Description:" ) );
3130 mainSizer->Add( label, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 10 );
3131
3132 mainSizer->AddSpacer( 3 );
3133
3134 wxTextCtrl* descCtrl =
3135 new wxTextCtrl( &dlg, wxID_ANY, currentDesc, wxDefaultPosition, wxSize( 300, 60 ), wxTE_MULTILINE );
3136 mainSizer->Add( descCtrl, 1, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 10 );
3137
3138 wxStdDialogButtonSizer* btnSizer = new wxStdDialogButtonSizer();
3139 btnSizer->AddButton( new wxButton( &dlg, wxID_OK ) );
3140 btnSizer->AddButton( new wxButton( &dlg, wxID_CANCEL ) );
3141 btnSizer->Realize();
3142 mainSizer->Add( btnSizer, 0, wxALL | wxALIGN_RIGHT, 5 );
3143
3144 dlg.SetSizer( mainSizer );
3145 dlg.Fit();
3146 dlg.Centre();
3147
3148 if( dlg.ShowModal() == wxID_CANCEL )
3149 return;
3150
3151 wxString newDesc = descCtrl->GetValue().Trim().Trim( false );
3152
3153 Schematic().SetVariantDescription( variantName, newDesc );
3154 OnModify();
3155 GetCanvas()->Refresh();
3156}
3157
3158
3160{
3162 return;
3163
3164 wxArrayString choices = Schematic().GetVariantNamesForUI();
3165
3166 // Default variant cannot be removed.
3167 choices.RemoveAt( 0 );
3168
3169 // wxSingleChoiceDialog will ellipsize the title bar if the contents aren't wide enough. The set
3170 // of spaces in the control label are to prevent this.
3171 wxSingleChoiceDialog dlg( this, _( "Select variant name to remove:" ) + wxS( " " ),
3172 _( "Remove Design Variant" ), choices );
3173 dlg.Layout();
3174
3175 if( dlg.ShowModal() == wxID_CANCEL )
3176 return;
3177
3178 wxString variantName = dlg.GetStringSelection();
3179
3180 if( variantName.IsEmpty() )
3181 return;
3182
3183 SCH_COMMIT commit( this );
3184 Schematic().DeleteVariant( variantName, &commit );
3185
3186 if( !commit.Empty() )
3187 {
3188 commit.Push( wxString::Format( wxS( "Delete variant '%s'" ), variantName ) );
3189 OnModify();
3190 }
3191
3192 if( Schematic().GetCurrentVariant() == variantName )
3193 SetCurrentVariant( wxEmptyString );
3194
3195 UpdateVariantSelectionCtrl( Schematic().GetVariantNamesForUI() );
3196
3197 GetCanvas()->Refresh();
3198}
3199
3200
3202{
3203 // Delegate to base auto-save behavior (commits pending local history) for now.
3205}
const KICOMMON_API wxEventTypeTag< wxCommandEvent > EDA_EVT_PLUGIN_AVAILABILITY_CHANGED
Notifies other parts of KiCad when plugin availability changes.
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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:100
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
@ icon_eeschema_16
@ icon_eeschema_32
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
static TOOL_ACTION toggleGrid
Definition actions.h:194
static TOOL_ACTION paste
Definition actions.h:76
static TOOL_ACTION cancelInteractive
Definition actions.h:68
static TOOL_ACTION unselectAll
Definition actions.h:79
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition actions.h:223
static TOOL_ACTION copy
Definition actions.h:74
static TOOL_ACTION selectSetLasso
Definition actions.h:217
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition actions.h:216
static TOOL_ACTION group
Definition actions.h:235
static TOOL_ACTION pasteSpecial
Definition actions.h:77
static TOOL_ACTION ungroup
Definition actions.h:236
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:153
static TOOL_ACTION showSearch
Definition actions.h:112
static TOOL_ACTION undo
Definition actions.h:71
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition actions.h:210
static TOOL_ACTION duplicate
Definition actions.h:80
static TOOL_ACTION doDelete
Definition actions.h:81
static TOOL_ACTION selectionTool
Definition actions.h:247
static TOOL_ACTION save
Definition actions.h:54
static TOOL_ACTION zoomFitScreen
Definition actions.h:138
static TOOL_ACTION redo
Definition actions.h:72
static TOOL_ACTION deleteTool
Definition actions.h:82
static TOOL_ACTION zoomTool
Definition actions.h:142
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:220
static TOOL_ACTION showProperties
Definition actions.h:262
static TOOL_ACTION cut
Definition actions.h:73
static TOOL_ACTION copyAsText
Definition actions.h:75
static TOOL_ACTION toggleGridOverrides
Definition actions.h:195
static TOOL_ACTION selectAll
Definition actions.h:78
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...
Handles how to draw a screen (a board, a schematic ...)
Definition base_screen.h:37
bool IsContentModified() const
Definition base_screen.h:56
void SetContentModified(bool aModified=true)
Definition base_screen.h:55
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:654
bool Empty() const
Definition commit.h:134
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
Calculate the connectivity of a schematic and generates netlists.
A subgraph is a set of items that are electrically connected on a single sheet.
Dialog to update or change schematic library symbols.
virtual bool doAutoSave()
This should be overridden by the derived class to handle the auto save feature.
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void ProjectChanged()
Notification event that the project has changed.
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
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
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxAuiManager m_auimgr
virtual void RecreateToolbars()
ACTION_TOOLBAR * m_tbLeft
virtual void OnSize(wxSizeEvent &aEvent)
virtual void ClearFileHistory()
Remove all files from the file history.
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.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetch the file name from the file history list.
virtual int GetUndoCommandCount() const
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()
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 OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
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)
static const wxString RemoteSymbolPaneName()
virtual void UpdateMsgPanel()
Redraw the message panel.
void FocusOnLocation(const VECTOR2I &aPos, bool aAllowScroll=true)
Useful to focus on a particular location, in find functions.
virtual void ClearFocus()
SEARCH_PANE * m_searchPane
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
static const wxString DesignBlocksPaneName()
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
PROPERTIES_PANEL * m_propertiesPanel
bool m_showBorderAndTitleBlock
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
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:96
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition() but allows items to return their visual center rather than their anchor.
Definition eda_item.h:289
const KIID m_Uuid
Definition eda_item.h:531
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
void ClearBrightened()
Definition eda_item.h:148
void SetBrightened()
Definition eda_item.h:145
bool IsBrightened() const
Definition eda_item.h:134
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:89
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:110
SELECTION_CONDITION BoundingBoxes()
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SELECTION_CONDITION 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.
PANEL_ANNOTATE m_AnnotatePanel
bool empty() const
Definition sch_rtree.h:155
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:221
SEVERITY GetSeverity(int aErrorCode) const
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:91
void SetDefaultFont(const wxString &aFont)
Contains methods for drawing schematic-specific items.
Definition sch_painter.h:65
void SetSchematic(SCHEMATIC *aSchematic)
Definition sch_painter.h:75
void Update(const KIGFX::VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition sch_view.cpp:73
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition sch_view.h:125
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Set the scaling factor, zooming around a given anchor point.
Definition sch_view.cpp:115
void DetachTextVarTracker()
Drop every cached reference into the currently-attached SCHEMATIC's TEXT_VAR_TRACKER: unregister the ...
Definition sch_view.cpp:59
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:82
bool IsSCH_ITEM() const
Definition view_item.h:97
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
double GetScale() const
Definition view.h:281
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition view.h:405
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition view.h:225
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition view.cpp:663
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition view.cpp:1697
wxString AsString() const
Definition kiid.cpp:393
Definition kiid.h:44
KIWAY_PLAYER(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
void OnSockRequestServer(wxSocketEvent &evt)
void OnSockRequest(wxSocketEvent &evt)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:311
void OnKiCadExit()
Definition kiway.cpp:796
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:398
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:496
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
Definition kiway.cpp:207
@ FACE_SCH
eeschema DSO
Definition kiway.h:318
LOCAL_HISTORY & LocalHistory()
Return the LOCAL_HISTORY associated with this KIWAY.
Definition kiway.h:422
Define a library symbol object.
Definition lib_symbol.h:79
void AppendParentEmbeddedFiles(std::vector< EMBEDDED_FILES * > &aStack) const
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
bool CommitDuplicateOfLastSave(const wxString &aProjectPath, const wxString &aFileType, const wxString &aMessage)
Create a new commit duplicating the tree pointed to by Last_Save_<fileType> and move the Last_Save_<f...
void RegisterSaver(const void *aSaverObject, const std::function< void(const wxString &, std::vector< HISTORY_FILE_DATA > &)> &aSaver)
Register a saver callback invoked during autosave history commits.
void NoteFileChange(const wxString &aFile)
Record that a file has been modified and should be included in the next snapshot.
void UnregisterSaver(const void *aSaverObject)
Unregister a previously registered saver callback.
void RemoveAutosaveFiles(const wxString &aProjectPath) const
Remove every autosave file under the project at aProjectPath regardless of which source it shadowed.
Tree view item data for the net navigator.
A singleton reporter that reports to nowhere.
Definition reporter.h:214
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition page_info.h:164
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition page_info.h:155
void PreloadDesignBlockLibraries(KIWAY *aKiway)
Starts a background job to preload the global and project design block libraries.
Definition pgm_base.cpp:883
A progress reporter interface for use in multi-threaded environments.
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition project.cpp:177
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition project.cpp:183
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
Definition project.cpp:407
Action handler for the Properties panel.
These are loaded from Eeschema settings but then overwritten by the project settings.
Holds all the data relating to one schematic.
Definition schematic.h:90
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition schematic.h:194
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
void DeleteVariant(const wxString &aVariantName, SCH_COMMIT *aCommit=nullptr)
Delete all information for aVariantName.
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
wxString GetVariantDescription(const wxString &aVariantName) const
Return the description for a variant.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
SCHEMATIC_SETTINGS & Settings() const
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Definition schematic.h:128
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
void SetProject(PROJECT *aPrj)
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
void SetVariantDescription(const wxString &aVariantName, const wxString &aDescription)
Set the description for a variant.
wxArrayString GetVariantNamesForUI() const
Return an array of variant names for using in wxWidgets UI controls.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, TOOL_MANAGER *aToolManager, PROGRESS_REPORTER *aProgressReporter=nullptr, KIGFX::SCH_VIEW *aSchView=nullptr, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PICKED_ITEMS_LIST *aLastChangeList=nullptr)
Generate the connection data for the entire schematic hierarchy.
ERC_SETTINGS & ErcSettings() const
Gather all the actions that are shared by tools.
Definition sch_actions.h:36
static TOOL_ACTION rotateCCW
static TOOL_ACTION placeClassLabel
Definition sch_actions.h:75
static TOOL_ACTION placeSheetPin
Definition sch_actions.h:81
static TOOL_ACTION saveSheetAsDesignBlock
static TOOL_ACTION mirrorV
static TOOL_ACTION drawSheetFromFile
Definition sch_actions.h:79
static TOOL_ACTION toggleOPCurrents
static TOOL_ACTION saveToLinkedDesignBlock
Definition sch_actions.h:67
static TOOL_ACTION saveSelectionAsDesignBlock
static TOOL_ACTION placeGlobalLabel
Definition sch_actions.h:76
static TOOL_ACTION drawEllipseArc
Definition sch_actions.h:94
static TOOL_ACTION drawTextBox
Definition sch_actions.h:89
static TOOL_ACTION toggleAnnotateAuto
static TOOL_ACTION ddAddImage
static TOOL_ACTION drawArc
Definition sch_actions.h:95
static TOOL_ACTION drawSheet
Definition sch_actions.h:78
static TOOL_ACTION toggleERCWarnings
static TOOL_ACTION toggleDirectiveLabels
static TOOL_ACTION highlightNetTool
static TOOL_ACTION leaveSheet
static TOOL_ACTION ddImportGraphics
static TOOL_ACTION toggleHiddenFields
static TOOL_ACTION drawRectangle
Definition sch_actions.h:91
static TOOL_ACTION drawLines
Definition sch_actions.h:97
static TOOL_ACTION placeHierLabel
Definition sch_actions.h:77
static TOOL_ACTION alignTop
static TOOL_ACTION alignRight
static TOOL_ACTION drawEllipse
Definition sch_actions.h:93
static TOOL_ACTION placeLabel
Definition sch_actions.h:74
static TOOL_ACTION drawCircle
Definition sch_actions.h:92
static TOOL_ACTION placeBusWireEntry
Definition sch_actions.h:73
static TOOL_ACTION showRemoteSymbolPanel
static TOOL_ACTION drawBezier
Definition sch_actions.h:96
static TOOL_ACTION drawWire
Definition sch_actions.h:68
static TOOL_ACTION remapSymbols
static TOOL_ACTION rotateCW
static TOOL_ACTION alignBottom
static TOOL_ACTION showHierarchy
static TOOL_ACTION showNetNavigator
static TOOL_ACTION placeJunction
Definition sch_actions.h:72
static TOOL_ACTION markSimExclusions
static TOOL_ACTION drawRuleArea
static TOOL_ACTION placeSymbol
Definition sch_actions.h:62
static TOOL_ACTION placeImage
Definition sch_actions.h:98
static TOOL_ACTION alignLeft
static TOOL_ACTION toggleERCErrors
static TOOL_ACTION alignCenterX
static TOOL_ACTION angleSnapModeChanged
static TOOL_ACTION placeLinkedDesignBlock
Definition sch_actions.h:66
static TOOL_ACTION drawSheetFromDesignBlock
Definition sch_actions.h:80
static TOOL_ACTION mirrorH
static TOOL_ACTION placeDesignBlock
Definition sch_actions.h:65
static TOOL_ACTION toggleOPVoltages
static TOOL_ACTION drawBus
Definition sch_actions.h:69
static TOOL_ACTION drawTable
Definition sch_actions.h:90
static TOOL_ACTION ddAppendFile
static TOOL_ACTION placeSchematicText
Definition sch_actions.h:88
static TOOL_ACTION showDesignBlockPanel
static TOOL_ACTION togglePinAltIcons
static TOOL_ACTION toggleERCExclusions
static TOOL_ACTION updateNetHighlighting
static TOOL_ACTION alignCenterY
static TOOL_ACTION placeNoConnect
Definition sch_actions.h:71
static TOOL_ACTION toggleHiddenPins
static TOOL_ACTION syncSheetPins
Definition sch_actions.h:85
static TOOL_ACTION placePower
Definition sch_actions.h:64
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
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
DIALOG_SCH_FIND * m_findReplaceDialog
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
EESCHEMA_SETTINGS * eeconfig() const
PANEL_SCH_SELECTION_FILTER * m_selectionFilterPanel
virtual void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool HasDriverChanged() const
wxString Name(bool aIgnoreSheet=false) const
Handle design block actions in the schematic editor.
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.).
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplaySheet(SCH_SCREEN *aScreen)
Group generic conditions for PCB editor states.
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
Schematic editor (Eeschema) main window.
void DefaultExecFlags()
Reset the execution flags to defaults for external netlist and bom generators.
void OnCrossProbeFlashTimer(wxTimerEvent &aEvent)
void ToggleProperties() override
bool IsContentModified() const override
Get if the current schematic has been modified but not saved.
void RefreshOperatingPointDisplay()
Refresh the display of any operating points.
wxPageSetupDialogData m_pageSetupData
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
std::vector< std::unique_ptr< SCH_ITEM > > m_items_to_repeat
For the repeat-last-item cmd.
void FocusOnItem(EDA_ITEM *aItem, bool aAllowScroll=true) override
Focus on a particular canvas item.
void onResizeNetNavigator(wxSizeEvent &aEvent)
void updateSelectionFilterVisbility() override
Selection filter panel doesn't have a dedicated visibility control, so show it if any other AUI panel...
void onNetNavigatorSelChanging(wxTreeEvent &aEvent)
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void showNetNavigatorMenu(const wxTreeItemId &aItem)
void ShowAllIntersheetRefs(bool aShow)
void SaveProjectLocalSettings() override
Save changes to the project settings to the project (.pro) file.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void doCloseWindow() override
DIALOG_BOOK_REPORTER * m_diffSymbolDialog
void ToggleLibraryTree() override
void SetHighlightedConnection(const wxString &aConnection, const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
wxWindow * createHighlightedNetNavigator()
void onCloseErcDialog(wxCommandEvent &aEvent)
void UpdateHierarchySelection()
Update the hierarchy navigation tree selection (cross-probe from schematic to hierarchy pane).
bool m_syncingPcbToSchSelection
void SetScreen(BASE_SCREEN *aScreen) override
friend class SCH_EDITOR_CONTROL
bool doAutoSave() override
Save the schematic files that have been modified and not yet saved.
wxChoice * m_currentVariantCtrl
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
Update a schematic symbol from a LIB_SYMBOL.
void SetCurrentVariant(const wxString &aVariantName)
void onSize(wxSizeEvent &aEvent)
void CommonSettingsChanged(int aFlags) override
Called after the preferences dialog is run.
void UpdateVariantSelectionCtrl(const wxArrayString &aVariantNames)
Update the variant name control on the main toolbar.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
BITMAP_BUTTON * m_netNavigatorMenuButton
void onNetNavigatorKey(wxKeyEvent &aEvent)
void configureToolbars() override
std::vector< wxEvtHandler * > m_schematicChangeListeners
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void OnClearFileHistory(wxCommandEvent &aEvent)
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
PANEL_REMOTE_SYMBOL * m_remoteSymbolPane
SCHEMATIC * m_schematic
The currently loaded schematic.
void onNetNavigatorFilterChanged(wxCommandEvent &aEvent)
void onCloseSymbolFieldsTableDialog(wxCommandEvent &aEvent)
SCH_SHEET_PATH & GetCurrentSheet() const
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr)
Generate the connection data for the entire schematic hierarchy.
wxString m_netNavigatorFilterValue
void ProjectChanged() override
Notification event that the project has changed.
void OnLoadFile(wxCommandEvent &event)
SCHEMATIC & Schematic() const
void updateTitle()
Set the main window title bar text.
void SetSchematic(SCHEMATIC *aSchematic)
void ToggleSearch()
Toggle the show/hide state of Search pane.
bool LoadProjectSettings()
Load the KiCad project file (*.pro) settings specific to Eeschema.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void RefreshNetNavigator(const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
wxSearchCtrl * m_netNavigatorFilter
wxString GetFullScreenDesc() const override
static const wxString SearchPaneName()
DIALOG_BOOK_REPORTER * GetSymbolDiffDialog()
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
void onNetNavigatorContextMenu(wxContextMenuEvent &aEvent)
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
const wxString & GetHighlightedNetChain() const
DIALOG_ERC * GetErcDialog()
void sendNetlistToCvpcb()
Send the KiCad netlist over to CVPCB.
SCH_DESIGN_BLOCK_PANE * m_designBlocksPane
void UpdateHierarchyNavigator(bool aRefreshNetNavigator=true, bool aClear=false)
Update the hierarchy navigation tree and history.
SCH_EDIT_FRAME(KIWAY *aKiway, wxWindow *aParent)
void ToggleSchematicHierarchy()
Toggle the show/hide state of the left side schematic navigation panel.
std::vector< KIID > m_crossProbeFlashItems
Items to flash.
void LoadDrawingSheet()
Load the drawing sheet file.
void onNetNavigatorMenuCommand(wxCommandEvent &aEvent)
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
std::vector< LIB_ID > m_designBlockHistoryList
void OnPageSettingsChange() override
Called when modifying the page settings.
void ClearRepeatItemsList()
Clear the list of items which are to be repeated with the insert key.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Return bounding box of document with option to not include some items.
wxGenericTreeCtrl * m_netNavigator
void CaptureHierarchyPaneSize()
void StartCrossProbeFlash(const std::vector< SCH_ITEM * > &aItems)
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
void UpdateLabelsHierarchyNavigator()
Update the hierarchy navigation tree labels.
static const wxString SchematicHierarchyPaneName()
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
EDA_ITEM * ResolveItem(const KIID &aId, bool aAllowNullptrReturn=false) const override
Fetch an item by KIID.
wxString m_netNavigatorMenuNetName
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void RemoveSchematicChangeListener(wxEvtHandler *aListener)
Remove aListener to from the schematic changed listener list.
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
void DisplayCurrentSheet()
Draw the current sheet on the display.
~SCH_EDIT_FRAME() override
void onVariantSelected(wxCommandEvent &aEvent)
const wxString & GetHighlightedConnection() const
DIALOG_ERC * m_ercDialog
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
void UpdateNetHighlightStatus()
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
void onNetNavigatorItemMenu(wxTreeEvent &aEvent)
void AddCopyForRepeatItem(const SCH_ITEM *aItem)
DIALOG_SYMBOL_FIELDS_TABLE * GetSymbolFieldsTableDialog()
void OnResizeHierarchyNavigator(wxSizeEvent &aEvent)
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
wxString m_highlightedConn
The highlighted net or bus or empty string.
wxGenericTreeCtrl * GetNetNavigator()
static const wxString NetNavigatorPaneName()
void onCloseSymbolDiffDialog(wxCommandEvent &aEvent)
void IntersheetRefUpdate(SCH_GLOBALLABEL *aItem) override
Callback from schematic ref update.
void OnExit(wxCommandEvent &event)
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it).
wxTimer m_crossProbeFlashTimer
Timer to toggle selection visibility.
void AddSchematicChangeListener(wxEvtHandler *aListener)
Add aListener to post #EDA_EVT_SCHEMATIC_CHANGED command events to.
HIERARCHY_PANE * m_hierarchy
DIALOG_SYMBOL_FIELDS_TABLE * m_symbolFieldsTableDialog
std::unique_ptr< GRID_HELPER > MakeGridHelper() override
void UpdateHopOveredWires(SCH_ITEM *aItem)
SEVERITY GetSeverity(int aErrorCode) const override
void onNetNavigatorSelection(wxTreeEvent &aEvent)
void FindNetInInspector(const wxString &aNetName)
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Handle actions specific to the schematic editor.
A set of SCH_ITEMs (i.e., without duplicates).
Definition sch_group.h:48
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool doClone=false) const
Routine to create a new copy of given item.
Definition sch_item.cpp:160
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition sch_item.h:628
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition sch_item.cpp:487
bool ResolveExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:298
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
SPIN_STYLE GetSpinStyle() const
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.)
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:38
void SetOperatingPoint(const wxString &aText)
Definition sch_line.h:344
bool IsWire() const
Return true if the line is a wire.
bool IsBus() const
Return true if the line is a bus.
double GetLength() const
Definition sch_line.cpp:288
const wxString & GetOperatingPoint() const
Definition sch_line.h:343
Handle actions specific to the schematic editor.
A net chain is a collection of nets that are connected together through passive components.
void SetOperatingPoint(const wxString &aText)
Definition sch_pin.h:343
Tool that displays edit points allowing to modify items by dragging the points.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:746
const PAGE_INFO & GetPageSettings() const
Definition sch_screen.h:137
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
void TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr, std::function< void(SCH_ITEM *)> *aChangedHandler=nullptr) const
Test all of the connectable objects in the schematic for unused connection points.
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition sch_screen.h:494
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition sch_screen.h:673
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:115
const wxString & GetFileName() const
Definition sch_screen.h:150
bool IsReadOnly() const
Definition sch_screen.h:153
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
bool m_zoomInitialized
Definition sch_screen.h:698
bool FileExists() const
Definition sch_screen.h:156
SPIN_STYLE GetLabelOrientationForPoint(const VECTOR2I &aPosition, SPIN_STYLE aDefaultOrientation, const SCH_SHEET_PATH *aSheet) const
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Fetch a SCH_ITEM by ID.
bool IsModified() const
Check the entire hierarchy for any modifications.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false, bool aEscapeSheetNames=false) const
Return the sheet path in a human readable form made from the sheet names.
bool GetExcludedFromSim() const
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void clear()
Forwarded method from std::vector.
size_t size() const
Forwarded method from std::vector.
wxString GetName() const
Definition sch_sheet.h:136
Schematic symbol object.
Definition sch_symbol.h:69
EMBEDDED_FILES * GetEmbeddedFiles() override
SCH_SYMBOLs don't currently support embedded files, but their LIB_SYMBOL counterparts do.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:177
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
VECTOR2I GetPosition() const override
Definition sch_text.h:146
static SELECTION_CONDITION HasType(KICAD_T aType)
Create a functor that tests if among the selected items there is at least one of a given type.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
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).
void BrightenItem(EDA_ITEM *aItem)
int AddItemToSel(const TOOL_EVENT &aEvent)
void UnbrightenItem(EDA_ITEM *aItem)
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Save, unload and unregister the given PROJECT.
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
Definition sim_lib_mgr.h:44
Symbol library viewer main window.
The symbol library editor main window.
Symbol library viewer main window.
void AddTemplateFieldNames(const wxString &aSerializedFieldNames)
Add a serialized list of template field names.
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
TOOL_MANAGER * m_toolManager
TOOL_DISPATCHER * m_toolDispatcher
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
ACTIONS * m_actions
@ REDRAW
Full drawing refresh.
Definition tool_base.h:79
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:76
Generic, UI-independent tool event.
Definition tool_event.h:167
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.
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
Definition common.cpp:775
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition confirm.cpp:146
int GetLastUnsavedChangesResponse()
Return the result code from the last call to HandleUnsavedChanges(): wxID_YES, wxID_NO or wxID_CANCEL...
Definition confirm.cpp:159
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:192
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#define _(s)
wxDEFINE_EVENT(wxEVT_REFRESH_CUSTOM_COMMAND, wxEvent)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define SCH_EDIT_FRAME_NAME
@ NO_RECURSE
Definition eda_item.h:50
#define IGNORE_PARENT_GROUP
Definition eda_item.h:53
@ ID_TOOLBAR_SCH_SELECT_VARAIANT
const wxAuiPaneInfo & defaultSchSelectionFilterPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultPropertiesPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultNetNavigatorPaneInfo()
const wxAuiPaneInfo & defaultDesignBlocksPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultRemoteSymbolPaneInfo(wxWindow *aWindow)
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
KiCad executable names.
const wxString PCBNEW_EXE
@ FRAME_PCB_EDITOR
Definition frame_type.h:38
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:31
@ FRAME_SCH_VIEWER
Definition frame_type.h:32
@ FRAME_SCH
Definition frame_type.h:30
@ FRAME_SIMULATOR
Definition frame_type.h:34
@ FRAME_CVPCB
Definition frame_type.h:48
@ FRAME_SYMBOL_CHOOSER
Definition frame_type.h:33
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition gestfich.cpp:160
static const std::string NetlistFileExtension
static const std::string JpegFileExtension
static const std::string PngFileExtension
static const std::string LegacyPcbFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string SVGFileExtension
static wxString LegacySchematicFileWildcard()
static wxString AllSchematicFilesWildcard()
static wxString KiCadSchematicFileWildcard()
const wxChar *const traceSchCurrentSheet
Flag to enable debug output of current sheet tracking in the schematic editor.
const wxChar *const traceCrossProbeFlash
Flag to enable debug output for cross-probe flash operations.
const wxChar *const traceApi
Flag to enable debug output related to the IPC API and its plugin system.
Definition api_utils.cpp:29
@ ID_ON_GRID_SELECT
Definition id.h:112
@ ID_FILE_LIST_CLEAR
Definition id.h:58
@ ID_EDA_SOCKET_EVENT
Definition id.h:132
@ ID_EDA_SOCKET_EVENT_SERV
Definition id.h:131
@ ID_ON_ZOOM_SELECT
Definition id.h:111
@ ID_FILEMAX
Definition id.h:56
@ ID_FILE1
Definition id.h:55
PROJECT & Prj()
Definition kicad.cpp:739
EVT_MENU(ID_COMPARE_PROJECT_BRANCHES, KICAD_MANAGER_FRAME::OnCompareProjectBranches) KICAD_MANAGER_FRAME
KIID niluuid(0)
#define KICTL_CREATE
caller thinks requested project files may not exist.
@ LAYER_ERC_WARN
Definition layer_ids.h:477
@ LAYER_ERC_EXCLUSION
Definition layer_ids.h:479
@ LAYER_ERC_ERR
Definition layer_ids.h:478
@ LAYER_OP_CURRENTS
Definition layer_ids.h:500
@ LAYER_INTERSHEET_REFS
Definition layer_ids.h:461
@ LAYER_OP_VOLTAGES
Definition layer_ids.h:499
@ MAIL_PCB_UPDATE
Definition mail_type.h:43
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:54
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:51
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
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:448
#define _HKI(x)
Definition page_info.cpp:40
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
SEVERITY
#define DIFF_SYMBOLS_DIALOG_NAME
#define CURRENT_TOOL(action)
@ AUTOPLACE_AUTO
Definition sch_item.h:67
SCH_CLEANUP_FLAGS
Definition schematic.h:76
@ GLOBAL_CLEANUP
Definition schematic.h:79
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
Implement a participant in the KIWAY alchemy.
Definition kiway.h:152
virtual void PreloadLibraries(KIWAY *aKiway)
Definition kiway.h:275
std::string refName
std::string path
KIBIS_MODEL * model
KIBIS_PIN * pin
wxLogTrace helper definitions.
@ SCH_GROUP_T
Definition typeinfo.h:170
@ SCH_LINE_T
Definition typeinfo.h:160
@ SCH_SYMBOL_T
Definition typeinfo.h:169
@ SCH_HIER_LABEL_T
Definition typeinfo.h:166
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:165
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
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.