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>
29#include <dialogs/dialog_erc.h>
34#include <wx/srchctrl.h>
35#include <mail_type.h>
36#include <wx/clntdata.h>
37#include <wx/panel.h>
38#include <wx/sizer.h>
39#include <wx/menu.h>
43#include <api/api_utils.h>
44#include <local_history.h>
45#include <eeschema_id.h>
46#include <executable_names.h>
49#include <gestfich.h>
51#include <string_utils.h>
52#include <kiface_base.h>
53#include <kiplatform/app.h>
54#include <kiplatform/ui.h>
55#include <kiway.h>
56#include <symbol_edit_frame.h>
57#include <symbol_viewer_frame.h>
58#include <pgm_base.h>
59#include <core/profile.h>
62#include <sch_edit_frame.h>
64#include <sch_painter.h>
65#include <sch_marker.h>
66#include <sch_sheet_pin.h>
67#include <sch_commit.h>
68#include <sch_rule_area.h>
70#include <advanced_config.h>
71#include <sim/simulator_frame.h>
72#include <tool/action_manager.h>
73#include <tool/action_toolbar.h>
74#include <tool/common_control.h>
75#include <tool/common_tools.h>
76#include <tool/embed_tool.h>
77#include <tool/picker_tool.h>
79#include <tool/selection.h>
81#include <tool/tool_manager.h>
82#include <tool/zoom_tool.h>
83#include <tools/sch_actions.h>
91#include <sch_io/sch_io_mgr.h>
92#include <sch_io/sch_io.h>
94#include <tools/sch_edit_tool.h>
100#include <tools/sch_move_tool.h>
104#include <trace_helpers.h>
105#include <unordered_set>
106#include <view/view_controls.h>
107#include <widgets/wx_infobar.h>
113#include <wx/cmdline.h>
114#include <wx/app.h>
115#include <wx/filedlg.h>
116#include <wx/socket.h>
117#include <wx/debug.h>
119#include <widgets/wx_aui_utils.h>
122#include <toolbars_sch_editor.h>
123#include <wx/log.h>
124#include <wx/choicdlg.h>
125#include <wx/textdlg.h>
126#include <wx/generic/treectlg.h>
127
128
130
131
132#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
133
134
135BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
138
139 EVT_SIZE( SCH_EDIT_FRAME::OnSize )
140
143
144 EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
145 EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
146
149
150 // Drop files event
151 EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
152END_EVENT_TABLE()
153
154
155wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
156wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
157
158
159SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
160 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
162 m_ercDialog( nullptr ),
163 m_diffSymbolDialog( nullptr ),
164 m_symbolFieldsTableDialog( nullptr ),
165 m_netNavigator( nullptr ),
166 m_netNavigatorFilter( nullptr ),
170 m_designBlocksPane( nullptr ),
171 m_remoteSymbolPane( nullptr ),
172 m_currentVariantCtrl( nullptr )
173{
174 m_maximizeByDefault = true;
175 m_schematic = new SCHEMATIC( &Prj() );
176 m_schematic->SetSchematicHolder( this );
178
179 m_showBorderAndTitleBlock = true; // true to show sheet references
180 m_supportsAutoSave = true;
182 m_aboutTitle = _HKI( "KiCad Schematic Editor" );
183 m_show_search = false;
184 // Ensure timer has an owner before binding so it generates events.
185 m_crossProbeFlashTimer.SetOwner( this );
186 Bind( wxEVT_TIMER, &SCH_EDIT_FRAME::OnCrossProbeFlashTimer, this, m_crossProbeFlashTimer.GetId() );
187
188 // Give an icon
189 wxIcon icon;
190 wxIconBundle icon_bundle;
191
192 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 48 ) );
193 icon_bundle.AddIcon( icon );
194 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 128 ) );
195 icon_bundle.AddIcon( icon );
196 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 256 ) );
197 icon_bundle.AddIcon( icon );
198 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
199 icon_bundle.AddIcon( icon );
200 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
201 icon_bundle.AddIcon( icon );
202
203 SetIcons( icon_bundle );
204
206
207 setupTools();
210
214
215 // Ensure the "Line modes" toolbar group shows the current angle mode on startup
216 if( GetToolManager() )
218
220
221 m_hierarchy = new HIERARCHY_PANE( this );
222
223 // Initialize common print setup dialog settings.
224 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
225 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
226 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
227 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
228
229 m_searchPane = new SCH_SEARCH_PANE( this );
230 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
232
233 m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
234
237
238 m_auimgr.SetManagedWindow( this );
239
241
242 // Fetch a COPY of the config as a lot of these initializations are going to overwrite our
243 // data.
244 EESCHEMA_SETTINGS::AUI_PANELS aui_cfg = eeconfig()->m_AuiPanels;
245 EESCHEMA_SETTINGS::APPEARANCE appearance_cfg = eeconfig()->m_Appearance;
246
247 // Rows; layers 4 - 6
248 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( wxS( "TopMainToolbar" ) )
249 .Top().Layer( 6 ) );
250
251 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
252 .Bottom().Layer( 6 ) );
253
254 // Columns; layers 1 - 3
255 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
256 .Caption( _( "Schematic Hierarchy" ) )
257 .Left().Layer( 3 ).Position( 1 )
258 .TopDockable( false )
259 .BottomDockable( false )
260 .CloseButton( true )
261 .MinSize( FromDIP( wxSize( 120, 60 ) ) )
262 .BestSize( FromDIP( wxSize( 200, 200 ) ) )
263 .FloatingSize( FromDIP( wxSize( 200, 200 ) ) )
264 .FloatingPosition( FromDIP( wxPoint( 50, 50 ) ) )
265 .Show( false ) );
266
269
272
274
275 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( wxS( "LeftToolbar" ) )
276 .Left().Layer( 2 ) );
277
278 m_auimgr.AddPane( m_tbRight, EDA_PANE().VToolbar().Name( wxS( "RightToolbar" ) )
279 .Right().Layer( 2 ) );
280
281 // Center
282 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
283 .Center() );
284
285 m_auimgr.AddPane( m_searchPane, EDA_PANE()
286 .Name( SearchPaneName() )
287 .Bottom()
288 .Caption( _( "Search" ) )
289 .PaneBorder( false )
290 .MinSize( FromDIP( wxSize( 180, 60 ) ) )
291 .BestSize( FromDIP( wxSize( 180, 100 ) ) )
292 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
293 .CloseButton( true )
294 .DestroyOnClose( false )
295 .Show( m_show_search ) );
296
299
300 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
301 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
302 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
303 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
304 wxAuiPaneInfo& designBlocksPane = m_auimgr.GetPane( DesignBlocksPaneName() );
305 wxAuiPaneInfo& remoteSymbolPane = m_auimgr.GetPane( RemoteSymbolPaneName() );
306
307 hierarchy_pane.Show( aui_cfg.show_schematic_hierarchy );
308 netNavigatorPane.Show( aui_cfg.show_net_nav_panel );
309 propertiesPane.Show( aui_cfg.show_properties );
310 designBlocksPane.Show( aui_cfg.design_blocks_show );
311
312 if( m_remoteSymbolPane && !m_remoteSymbolPane->HasDataSources() )
313 remoteSymbolPane.Show( false );
314 else
315 remoteSymbolPane.Show( aui_cfg.remote_symbol_show );
316
318
319 // The selection filter doesn't need to grow in the vertical direction when docked
320 selectionFilterPane.dock_proportion = 0;
321
322 if( aui_cfg.hierarchy_panel_float_width > 0 && aui_cfg.hierarchy_panel_float_height > 0 )
323 {
324 // Show at end, after positioning
325 hierarchy_pane.FloatingSize( aui_cfg.hierarchy_panel_float_width,
327 }
328
329 if( aui_cfg.net_nav_panel_float_size.GetWidth() > 0
330 && aui_cfg.net_nav_panel_float_size.GetHeight() > 0 )
331 {
332 netNavigatorPane.FloatingSize( aui_cfg.net_nav_panel_float_size );
333 netNavigatorPane.FloatingPosition( aui_cfg.net_nav_panel_float_pos );
334 }
335
336 if( aui_cfg.properties_panel_width > 0 )
337 SetAuiPaneSize( m_auimgr, propertiesPane, aui_cfg.properties_panel_width, -1 );
338
339 if( aui_cfg.schematic_hierarchy_float )
340 hierarchy_pane.Float();
341
342 if( aui_cfg.search_panel_height > 0 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_TOP
343 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
344 {
345 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
346 searchPane.Direction( aui_cfg.search_panel_dock_direction );
347 SetAuiPaneSize( m_auimgr, searchPane, -1, aui_cfg.search_panel_height );
348 }
349
350 else if( aui_cfg.search_panel_width > 0 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_LEFT
351 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
352 {
353 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
354 searchPane.Direction( aui_cfg.search_panel_dock_direction );
355 SetAuiPaneSize( m_auimgr, searchPane, aui_cfg.search_panel_width, -1 );
356 }
357
358 if( aui_cfg.float_net_nav_panel )
359 netNavigatorPane.Float();
360
361 if( aui_cfg.design_blocks_show )
362 SetAuiPaneSize( m_auimgr, designBlocksPane, aui_cfg.design_blocks_panel_docked_width, -1 );
363
364 if( aui_cfg.remote_symbol_show )
365 {
366 SetAuiPaneSize( m_auimgr, remoteSymbolPane, aui_cfg.remote_symbol_panel_docked_width, -1 );
367 }
368
369 if( aui_cfg.hierarchy_panel_docked_width > 0 )
370 {
371 // If the net navigator is not show, let the hierarchy navigator take all of the vertical
372 // space.
373 if( !aui_cfg.show_net_nav_panel )
374 {
375 SetAuiPaneSize( m_auimgr, hierarchy_pane, aui_cfg.hierarchy_panel_docked_width, -1 );
376 }
377 else
378 {
379 SetAuiPaneSize( m_auimgr, hierarchy_pane,
382
383 SetAuiPaneSize( m_auimgr, netNavigatorPane,
384 aui_cfg.net_nav_panel_docked_size.GetWidth(),
385 aui_cfg.net_nav_panel_docked_size.GetHeight() );
386 }
387
388 // wxAUI hack: force width by setting MinSize() and then Fixed()
389 // thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
390 hierarchy_pane.MinSize( aui_cfg.hierarchy_panel_docked_width, 60 );
391 hierarchy_pane.Fixed();
392 netNavigatorPane.MinSize( aui_cfg.net_nav_panel_docked_size.GetWidth(), 60 );
393 netNavigatorPane.Fixed();
394 m_auimgr.Update();
395
396 // now make it resizable again
397 hierarchy_pane.Resizable();
398 netNavigatorPane.Resizable();
399 m_auimgr.Update();
400
401 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
402 // back to minimum.
403 hierarchy_pane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
404 netNavigatorPane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
405 }
406 else
407 {
408 m_auimgr.Update();
409 }
410
411 CallAfter( [this]()
412 {
413 wxAuiPaneInfo& remotePane = m_auimgr.GetPane( RemoteSymbolPaneName() );
414
415 if( remotePane.IsShown() && m_remoteSymbolPane )
416 m_remoteSymbolPane->Activate();
417 } );
418
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 m_apiHandler = std::make_unique<API_HANDLER_SCH>( this );
456
457 if( Kiface().IsSingle() )
458 {
459 m_apiHandlerCommon = std::make_unique<API_HANDLER_COMMON>();
461 m_apiLibrariesHandler = std::make_unique<API_HANDLER_LIBRARIES>( LIBRARY_TABLE_TYPE::DESIGN_BLOCK );
463 }
464
465 // Default shutdown reason until a file is loaded
466 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
467
468 // Init for dropping files
472 m_acceptedExts.emplace( wxS( "jpeg" ), &SCH_ACTIONS::ddAddImage );
473 m_acceptedExts.emplace( wxS( "dxf" ), &SCH_ACTIONS::ddImportGraphics );
475 DragAcceptFiles( true );
476
477 // Ensure the window is on top
478 Raise();
479
480 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
481 // top-left corner of the canvas
482 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
483 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
484
485 Bind( wxEVT_CHOICE, &SCH_EDIT_FRAME::onVariantSelected, this );
486 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
487 Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
488 Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog, this );
489}
490
491void SCH_EDIT_FRAME::StartCrossProbeFlash( const std::vector<SCH_ITEM*>& aItems )
492{
493 if( !eeconfig()->m_CrossProbing.flash_selection )
494 {
495 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: aborted (setting disabled) items=%zu", aItems.size() );
496 return;
497 }
498
499 if( aItems.empty() )
500 {
501 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: aborted (no items)" );
502 return;
503 }
504
506 {
507 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: restarting existing flash (phase=%d)",
510 }
511
512 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: starting with %zu items", aItems.size() );
514
515 for( SCH_ITEM* it : aItems )
516 m_crossProbeFlashItems.push_back( it->m_Uuid );
517
520
521 if( !m_crossProbeFlashTimer.GetOwner() )
522 m_crossProbeFlashTimer.SetOwner( this );
523
524 bool started = m_crossProbeFlashTimer.Start( 500, wxTIMER_CONTINUOUS );
525 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: timer start=%d id=%d", (int) started,
526 m_crossProbeFlashTimer.GetId() );
527}
528
529
530void SCH_EDIT_FRAME::OnCrossProbeFlashTimer( wxTimerEvent& aEvent )
531{
532 wxLogTrace( traceCrossProbeFlash, "Timer(SCH) fired: phase=%d running=%d items=%zu", m_crossProbeFlashPhase,
534
536 {
537 wxLogTrace( traceCrossProbeFlash, "Timer fired but not flashing (ignored)" );
538 return;
539 }
540
542
543 if( !selTool )
544 return;
545
546 bool prevGuard = m_syncingPcbToSchSelection;
548
549 if( m_crossProbeFlashPhase % 2 == 0 )
550 {
551 selTool->ClearSelection( true );
552 wxLogTrace( traceCrossProbeFlash, "Phase %d: cleared selection", m_crossProbeFlashPhase );
553 }
554 else
555 {
556 for( const KIID& id : m_crossProbeFlashItems )
557 {
558 if( SCH_ITEM* item = Schematic().ResolveItem( id, nullptr, true ) )
559 selTool->AddItemToSel( item, true );
560 }
561
562 wxLogTrace( traceCrossProbeFlash, "Phase %d: restored %zu items", m_crossProbeFlashPhase,
563 m_crossProbeFlashItems.size() );
564 }
565
566 if( GetCanvas() )
567 {
569 wxLogTrace( traceCrossProbeFlash, "Phase %d: forced canvas refresh", m_crossProbeFlashPhase );
570 }
571
572 m_syncingPcbToSchSelection = prevGuard;
574
575 if( m_crossProbeFlashPhase > 6 )
576 {
577 for( const KIID& id : m_crossProbeFlashItems )
578 {
579 if( SCH_ITEM* item = Schematic().ResolveItem( id, nullptr, true ) )
580 selTool->AddItemToSel( item, true );
581 }
582
583 m_crossProbeFlashing = false;
585 wxLogTrace( traceCrossProbeFlash, "Flashing complete. Final selection size=%zu",
586 m_crossProbeFlashItems.size() );
587 }
588}
589
590
592{
593 // Ensure that teardowns without doCloseWindow are fully unregistered
594 if( m_schematic )
596
597 // A forced teardown (wx deletes every top level window at session end) skips doCloseWindow,
598 // leaving live tools. When we SetScreen(nullptr), we dispatch another tool call, potentially
599 // crashing when the frame is gone
600 if( m_toolManager )
601 {
602 GetCanvas()->SetEvtHandlerEnabled( false );
604 m_toolManager->ShutdownAllTools();
605
606 delete m_toolManager;
607 m_toolManager = nullptr;
608 }
609
610 m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
611
612 // Ensure m_canvasType is up to date, to save it in config
614
615 SetScreen( nullptr );
616
617 if( m_schematic )
618 m_schematic->RemoveAllListeners();
619
620 // Canvas outlives m_schematic; detach tracker consumers before delete.
621 if( GetCanvas() && GetCanvas()->GetView() )
623
624 // Delete all items not in draw list before deleting schematic
625 // to avoid dangling pointers stored in these items
628
629 delete m_schematic;
630 m_schematic = nullptr;
631
632 // Close the project if we are standalone, so it gets cleaned up properly
633 if( Kiface().IsSingle() )
634 {
635 try
636 {
637 GetSettingsManager()->UnloadProject( &Prj(), false );
638 }
639 catch( const std::runtime_error& e )
640 {
641 wxFAIL_MSG( wxString::Format( wxT( "Settings exception occurred: %s" ), e.what() ) );
642 }
643 }
644
645 // We passed ownership of these to wxAuiManager.
646 // delete m_hierarchy;
647 // delete m_selectionFilterPanel;
648}
649
650
652{
653 aEvent.Skip();
654
655 // 1st Call: Handle the size update during the first resize event.
657
658 // Defer the second size capture
659 CallAfter( [this]()
660 {
662 } );
663}
664
665
667{
668 // Called when resizing the Hierarchy Navigator panel
669 // Store the current pane size
670 // It allows to retrieve the last defined pane size when switching between
671 // docked and floating pane state
672 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
673
674 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
675 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
676
677 if( cfg && m_hierarchy->IsShownOnScreen() )
678 {
679 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
680 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
681
682 // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
683 // width is > 0 (i.e. if its size is already set and has meaning)
684 // if it is floating, its size is not initialized (only floating_size is initialized)
685 // initializing hierarchy_pane.best_size is useful when switching to float pane and
686 // after switching to the docked pane, to retrieve the last docked pane width
687 if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
688 {
689 cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
690 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
691 }
692 }
693}
694
695
697{
698 // Create the manager and dispatcher & route draw panel events to the dispatcher
700 m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
701 GetCanvas()->GetViewControls(), config(), this );
702 m_actions = new SCH_ACTIONS();
704
705 // Register tools
706 m_toolManager->RegisterTool( new COMMON_CONTROL );
707 m_toolManager->RegisterTool( new COMMON_TOOLS );
708 m_toolManager->RegisterTool( new ZOOM_TOOL );
709 m_toolManager->RegisterTool( new SCH_SELECTION_TOOL );
710 m_toolManager->RegisterTool( new PICKER_TOOL );
711 m_toolManager->RegisterTool( new SCH_DRAWING_TOOLS );
712 m_toolManager->RegisterTool( new EE_GRAPHIC_TOOL );
713 m_toolManager->RegisterTool( new SCH_LINE_WIRE_BUS_TOOL );
714 m_toolManager->RegisterTool( new SCH_MOVE_TOOL );
715 m_toolManager->RegisterTool( new SCH_ALIGN_TOOL );
716 m_toolManager->RegisterTool( new SCH_EDIT_TOOL );
717 m_toolManager->RegisterTool( new SCH_EDIT_TABLE_TOOL );
718 m_toolManager->RegisterTool( new SCH_GROUP_TOOL );
719 m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL );
720 m_toolManager->RegisterTool( new SCH_DESIGN_BLOCK_CONTROL );
721 m_toolManager->RegisterTool( new SCH_EDITOR_CONTROL );
722 m_toolManager->RegisterTool( new SCH_FIND_REPLACE_TOOL );
723 m_toolManager->RegisterTool( new SCH_POINT_EDITOR );
724 m_toolManager->RegisterTool( new SCH_NAVIGATE_TOOL );
725 m_toolManager->RegisterTool( new PROPERTIES_TOOL );
726 m_toolManager->RegisterTool( new EMBED_TOOL );
727 m_toolManager->InitTools();
728
729 // Run the selection tool, it is supposed to be always active
731
733}
734
735
737{
739
740 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
741 SCH_EDITOR_CONDITIONS cond( this );
742
743 wxASSERT( mgr );
744
745 auto hasElements =
746 [ this ] ( const SELECTION& aSel )
747 {
748 return GetScreen() &&
749 ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
750 };
751
752 auto searchPaneCond =
753 [this] ( const SELECTION& )
754 {
755 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
756 };
757
758 auto propertiesCond =
759 [this] ( const SELECTION& )
760 {
761 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
762 };
763
764 auto hierarchyNavigatorCond =
765 [ this ] ( const SELECTION& aSel )
766 {
767 return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
768 };
769
770 auto netNavigatorCond =
771 [ this ] (const SELECTION& aSel )
772 {
773 return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
774 };
775
776 auto designBlockCond =
777 [ this ] (const SELECTION& aSel )
778 {
779 return m_auimgr.GetPane( DesignBlocksPaneName() ).IsShown();
780 };
781
782 auto remoteSymbolCond =
783 [ this ] (const SELECTION& aSel )
784 {
785 return m_auimgr.GetPane( RemoteSymbolPaneName() ).IsShown();
786 };
787
788 auto undoCond =
789 [ this ] (const SELECTION& aSel )
790 {
792 return true;
793
794 return GetUndoCommandCount() > 0;
795 };
796
797 auto groupWithDesignBlockLink =
798 [] ( const SELECTION& aSel )
799 {
800 if( aSel.Size() != 1 )
801 return false;
802
803 if( aSel[0]->Type() != SCH_GROUP_T )
804 return false;
805
806 SCH_GROUP* group = static_cast<SCH_GROUP*>( aSel.GetItem( 0 ) );
807
808 return group->HasDesignBlockLink();
809 };
810
811#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
812#define CHECK( x ) ACTION_CONDITIONS().Check( x )
813
815 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
817
818 mgr->SetConditions( SCH_ACTIONS::showSearch, CHECK( searchPaneCond ) );
819 mgr->SetConditions( SCH_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
820 mgr->SetConditions( SCH_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
821 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
822 mgr->SetConditions( SCH_ACTIONS::showDesignBlockPanel, CHECK( designBlockCond ) );
823 mgr->SetConditions( SCH_ACTIONS::showRemoteSymbolPanel, CHECK( remoteSymbolCond ) );
826
827 mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
828 mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
829 mgr->SetConditions( ACTIONS::copyAsText, ENABLE( hasElements ) );
832 mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
833 mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
840 mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
841 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
842
844 ENABLE( SELECTION_CONDITIONS::NotEmpty ).HotkeyEnable( hasElements ) );
846 ENABLE( SELECTION_CONDITIONS::NotEmpty ).HotkeyEnable( hasElements ) );
848 ENABLE( SELECTION_CONDITIONS::NotEmpty ).HotkeyEnable( hasElements ) );
850 ENABLE( SELECTION_CONDITIONS::NotEmpty ).HotkeyEnable( hasElements ) );
853
854 mgr->SetConditions( SCH_ACTIONS::placeLinkedDesignBlock, ENABLE( groupWithDesignBlockLink ) );
855 mgr->SetConditions( SCH_ACTIONS::saveToLinkedDesignBlock, ENABLE( groupWithDesignBlockLink ) );
856
861
862 auto showHiddenPinsCond =
863 [this]( const SELECTION& )
864 {
865 return GetShowAllPins();
866 };
867
868 auto showHiddenFieldsCond =
869 [this]( const SELECTION& )
870 {
872 return cfg && cfg->m_Appearance.show_hidden_fields;
873 };
874
875 auto showDirectiveLabelsCond =
876 [this]( const SELECTION& )
877 {
879 return cfg && cfg->m_Appearance.show_directive_labels;
880 };
881
882 auto showERCErrorsCond =
883 [this]( const SELECTION& )
884 {
886 return cfg && cfg->m_Appearance.show_erc_errors;
887 };
888
889 auto showERCWarningsCond =
890 [this]( const SELECTION& )
891 {
893 return cfg && cfg->m_Appearance.show_erc_warnings;
894 };
895
896 auto showERCExclusionsCond =
897 [this]( const SELECTION& )
898 {
900 return cfg && cfg->m_Appearance.show_erc_exclusions;
901 };
902
903 auto markSimExclusionsCond =
904 [this]( const SELECTION& )
905 {
907 return cfg && cfg->m_Appearance.mark_sim_exclusions;
908 };
909
910 auto showOPVoltagesCond =
911 [this]( const SELECTION& )
912 {
914 return cfg && cfg->m_Appearance.show_op_voltages;
915 };
916
917 auto showOPCurrentsCond =
918 [this]( const SELECTION& )
919 {
921 return cfg && cfg->m_Appearance.show_op_currents;
922 };
923
924 auto showPinAltModeIconsCond =
925 [this]( const SELECTION& )
926 {
928 return cfg && cfg->m_Appearance.show_pin_alt_icons;
929 };
930
931 auto showAnnotateAutomaticallyCond =
932 [this]( const SELECTION& )
933 {
935 };
936
937 auto remapSymbolsCondition =
938 [&]( const SELECTION& aSel )
939 {
940 SCH_SCREENS schematic( Schematic().Root() );
941
942 // The remapping can only be performed on legacy projects.
943 return schematic.HasNoFullyDefinedLibIds();
944 };
945
946 auto belowRootSheetCondition =
947 [this]( const SELECTION& aSel )
948 {
949 SCH_NAVIGATE_TOOL* navigateTool = m_toolManager->GetTool<SCH_NAVIGATE_TOOL>();
950 return navigateTool && navigateTool->CanGoUp();
951 };
952
953 mgr->SetConditions( SCH_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
954
955 /* Some of these are bound by default to arrow keys which will get a different action if we
956 * disable the buttons. So always leave them enabled so the action is consistent.
957 * https://gitlab.com/kicad/code/kicad/-/issues/14783
958 mgr->SetConditions( SCH_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
959 mgr->SetConditions( SCH_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
960 mgr->SetConditions( SCH_ACTIONS::navigateBack, ENABLE( navHistoryHsBackward ) );
961 */
962
963 mgr->SetConditions( SCH_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
964 mgr->SetConditions( SCH_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
965 mgr->SetConditions( SCH_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
966 mgr->SetConditions( SCH_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
967 mgr->SetConditions( SCH_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
968 mgr->SetConditions( SCH_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
969 mgr->SetConditions( SCH_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
970 mgr->SetConditions( SCH_ACTIONS::markSimExclusions, CHECK( markSimExclusionsCond ) );
971 mgr->SetConditions( SCH_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
972 mgr->SetConditions( SCH_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
973 mgr->SetConditions( SCH_ACTIONS::togglePinAltIcons, CHECK( showPinAltModeIconsCond ) );
974 mgr->SetConditions( SCH_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
976
979
980#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
981
1013
1014#undef CURRENT_TOOL
1015#undef CHECK
1016#undef ENABLE
1017}
1018
1019
1021{
1022 // we cannot store a pointer to an item in the display list here since
1023 // that item may be deleted, such as part of a line concatenation or other.
1024 // So simply always keep a copy of the object which is to be repeated.
1025
1026 if( aItem )
1027 {
1028 m_items_to_repeat.clear();
1029
1030 AddCopyForRepeatItem( aItem );
1031 }
1032}
1033
1034
1036{
1037 // we cannot store a pointer to an item in the display list here since
1038 // that item may be deleted, such as part of a line concatenation or other.
1039 // So simply always keep a copy of the object which is to be repeated.
1040
1041 if( aItem )
1042 {
1043 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate( IGNORE_PARENT_GROUP ) ) );
1044
1045 // Clone() preserves the flags & parent, we want 'em cleared.
1046 repeatItem->ClearFlags();
1047 repeatItem->SetParent( nullptr );
1048
1049 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
1050 }
1051}
1052
1053
1054EDA_ITEM* SCH_EDIT_FRAME::ResolveItem( const KIID& aId, bool aAllowNullptrReturn ) const
1055{
1056 return Schematic().ResolveItem( aId, nullptr, aAllowNullptrReturn );
1057}
1058
1059
1064
1065
1070
1071
1073{
1074 return *m_schematic;
1075}
1076
1077
1079{
1080 return GetCurrentSheet().Last()->GetName();
1081}
1082
1083
1085{
1087}
1088
1089
1091{
1092 m_schematic->CreateDefaultScreens();
1093 SetScreen( Schematic().RootScreen() );
1094
1095 if( GetScreen() == nullptr )
1096 {
1097 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
1098 SetScreen( screen );
1099 }
1100}
1101
1102
1104{
1105 return m_schematic->CurrentSheet();
1106}
1107
1108
1110{
1111 if( aSheet != GetCurrentSheet() )
1112 {
1113 ClearFocus();
1114
1115 wxLogTrace( traceSchCurrentSheet,
1116 "SCH_EDIT_FRAME::SetCurrentSheet: Changing from path='%s' (size=%zu) to path='%s' (size=%zu)",
1117 GetCurrentSheet().Path().AsString(),
1118 GetCurrentSheet().size(),
1119 aSheet.Path().AsString(),
1120 aSheet.size() );
1121
1122 Schematic().SetCurrentSheet( aSheet );
1124 GetCanvas()->DisplaySheet( aSheet.LastScreen() );
1125 }
1126}
1127
1128
1130{
1132
1133 for( SCH_ITEM* item : screen->Items() )
1134 item->ClearCaches();
1135
1136 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
1137 {
1138 wxCHECK2( libSymbol.second, continue );
1139 libSymbol.second->ClearCaches();
1140 }
1141
1142 if( Schematic().Settings().m_IntersheetRefsShow )
1144
1145 ClearFocus();
1146
1147 GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
1148
1149 if( SCH_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>() )
1150 selectionTool->Reset( TOOL_BASE::REDRAW );
1151
1153}
1154
1155
1156bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
1157{
1158 // Exit interactive editing
1159 // Note this this will commit *some* pending changes. For instance, the SCH_POINT_EDITOR
1160 // will cancel any drag currently in progress, but commit all changes from previous drags.
1161 if( m_toolManager )
1163
1164 // Shutdown blocks must be determined and vetoed as early as possible
1165 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
1166 && IsContentModified() )
1167 {
1168 return false;
1169 }
1170
1171 if( Kiface().IsSingle() )
1172 {
1173 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1174
1175 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
1176 return false;
1177
1178 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
1179
1180 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
1181 return false;
1182
1183 // SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
1184 // sorry.
1185 auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
1186
1187 if( chooser && !chooser->Close() ) // Can close symbol chooser?
1188 return false;
1189 }
1190 else
1191 {
1192 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1193
1194 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
1195 {
1196 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
1197 return false;
1198 }
1199 }
1200
1201 if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
1202 return false;
1203
1205 && !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
1206 {
1207 return false;
1208 }
1209
1210 // We may have gotten multiple events; don't clean up twice
1211 if( !Schematic().IsValid() )
1212 return false;
1213
1214 if( IsContentModified() )
1215 {
1216 wxFileName fileName = Schematic().RootScreen()->GetFileName();
1217 wxString msg = _( "Save changes to '%s' before closing?" );
1218
1219 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1220 [&]() -> bool
1221 {
1222 return SaveProject();
1223 } ) )
1224 {
1225 return false;
1226 }
1227
1228 // If user selected 'No' (discard), create duplicate commit of last saved state and
1229 // move Last_Save tag forward so history shows an explicit discard event.
1230 if( GetLastUnsavedChangesResponse() == wxID_NO )
1231 {
1232 wxString projPath = Prj().GetProjectPath();
1233
1234 if( !projPath.IsEmpty() && Kiway().LocalHistory().HistoryExists( projPath ) )
1235 {
1236 Kiway().LocalHistory().CommitDuplicateOfLastSave( projPath, wxS( "Schematic" ),
1237 wxS( "Discard unsaved schematic changes" ) );
1238 }
1239 }
1240 }
1241
1242 return true;
1243}
1244
1245
1247{
1250
1251 // Unregister the autosave saver before any cleanup that might invalidate m_schematic
1252 if( m_schematic )
1254
1256
1257 SCH_SHEET_LIST sheetlist = Schematic().Hierarchy();
1258
1259 if( !Prj().IsNullProject() )
1260 {
1261 std::vector<wxString> sheetSrcs;
1262 sheetSrcs.reserve( sheetlist.size() );
1263
1264 for( const SCH_SHEET_PATH& path : sheetlist )
1265 {
1266 SCH_SCREEN* screen = path.LastScreen();
1267
1268 // Only sweep autosaves for sheets actually dirtied in this session.
1269 // A clean sheet's autosave, if any, is a previous-session leftover the
1270 // user explicitly deferred in the recovery dialog.
1271 if( screen && screen->IsContentModified() )
1272 sheetSrcs.push_back( Prj().AbsolutePath( screen->GetFileName() ) );
1273 }
1274
1275 Kiway().LocalHistory().RemoveAutosaveFiles( Prj().GetProjectPath(), sheetSrcs );
1276 }
1277
1278 // Close modeless dialogs. They're trouble when they get destroyed after the frame.
1279 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
1280 Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
1281 Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog, this );
1282 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging, this );
1283 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
1284
1285 if( m_diffSymbolDialog )
1286 {
1287 m_diffSymbolDialog->Destroy();
1288 m_diffSymbolDialog = nullptr;
1289 }
1290
1291 if( m_ercDialog )
1292 {
1293 m_ercDialog->Destroy();
1294 m_ercDialog = nullptr;
1295 }
1296
1298 {
1299 m_symbolFieldsTableDialog->Destroy();
1300 m_symbolFieldsTableDialog = nullptr;
1301 }
1302
1303 // Make sure local settings are persisted
1304 if( Prj().GetLocalSettings().ShouldAutoSave() )
1306
1307 delete m_toolManager;
1308 m_toolManager = nullptr;
1309
1310 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
1311
1312 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
1313 {
1314 hierarchy_pane.Show( false );
1315 m_auimgr.Update();
1316 }
1317
1318 sheetlist.ClearModifyStatus();
1319
1320 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
1321
1322 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
1323 UpdateFileHistory( fileName );
1324
1325 // Clear the view before freeing any schematic items. VIEW::Clear() walks m_allItems and
1326 // touches each item's private data, so the items must still be alive when this runs.
1327 SetScreen( nullptr );
1328
1329 Schematic().RootScreen()->Clear( true );
1330
1331 // all sub sheets are deleted, only the main sheet is usable
1333
1334 Schematic().Reset();
1335
1336 // Prevents any rogue events from continuing (i.e. search panel tries to redraw)
1337 Show( false );
1338
1339 Destroy();
1340}
1341
1342
1344{
1345 m_searchPane->FocusSearch();
1346}
1347
1348
1350{
1351 return Schematic().ErcSettings().GetSeverity( aErrorCode );
1352}
1353
1354
1356{
1358
1359 if( GetScreen() )
1360 {
1362 Kiway().LocalHistory().NoteFileChange( GetScreen()->GetFileName() );
1363 }
1364
1365 if( m_isClosing )
1366 return;
1367
1368 if( GetCanvas() )
1369 GetCanvas()->Refresh();
1370
1371 if( GetScreen() && !GetTitle().StartsWith( wxS( "*" ) ) )
1372 updateTitle();
1373}
1374
1375
1377{
1378 if( Kiface().IsSingle() )
1379 {
1380 DisplayError( this, _( "Cannot update the PCB because the Schematic Editor is opened in stand-alone "
1381 "mode. In order to create/update PCBs from schematics, launch the main KiCad "
1382 "application and create a project." ) );
1383 return;
1384 }
1385
1386 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1387 wxEventBlocker blocker( this );
1388
1389 if( !frame )
1390 {
1391 wxFileName fn = Prj().GetProjectFullName();
1392 fn.SetExt( FILEEXT::PcbFileExtension );
1393
1394 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1395
1396 // If Kiway() cannot create the Pcbnew frame, it shows a error message, and
1397 // frame is null
1398 if( !frame )
1399 return;
1400
1401 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1402 }
1403
1404 if( !frame->IsVisible() )
1405 frame->Show( true );
1406
1407 // On Windows, Raise() does not bring the window on screen, when iconized
1408 if( frame->IsIconized() )
1409 frame->Iconize( false );
1410
1411 frame->Raise();
1412
1413 std::string payload;
1415}
1416
1417
1418void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator, bool aClear )
1419{
1420 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
1421 m_hierarchy->UpdateHierarchyTree( aClear );
1422
1423 if( aRefreshNetNavigator )
1425}
1426
1427
1429{
1430 // Update only the hierarchy navigation tree labels.
1431 // The tree list is expected to be up to date
1432 m_hierarchy->UpdateLabelsHierarchyTree();
1433}
1434
1435
1437{
1438 m_hierarchy->UpdateHierarchySelection();
1439}
1440
1441
1442void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1443{
1444 wxString filename = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1445
1446 if( !filename.IsEmpty() )
1447 OpenProjectFiles( std::vector<wxString>( 1, filename ), KICTL_KICAD_ONLY );
1448}
1449
1450
1451void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
1452{
1454}
1455
1456
1458{
1459 // Only standalone mode can directly load a new document
1460 if( !Kiface().IsSingle() )
1461 return;
1462
1463 wxString pro_dir = m_mruPath;
1464
1465 wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString, FILEEXT::KiCadSchematicFileWildcard(),
1466 wxFD_SAVE );
1467
1469
1470 if( dlg.ShowModal() != wxID_CANCEL )
1471 {
1472 // Enforce the extension, wxFileDialog is inept.
1473 wxFileName create_me = EnsureFileExtension( dlg.GetPath(), FILEEXT::KiCadSchematicFileExtension );
1474
1475 if( create_me.FileExists() )
1476 {
1477 wxString msg;
1478 msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
1479 DisplayError( this, msg );
1480 return ;
1481 }
1482
1483 // OpenProjectFiles() requires absolute
1484 wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
1485
1486 OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1487 m_mruPath = create_me.GetPath();
1488 }
1489}
1490
1491
1493{
1494 // Only standalone mode can directly load a new document
1495 if( !Kiface().IsSingle() )
1496 return;
1497
1498 wxString pro_dir = m_mruPath;
1499 wxString wildcards = FILEEXT::AllSchematicFilesWildcard()
1501 + wxS( "|" ) + FILEEXT::LegacySchematicFileWildcard();
1502
1503 wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString, wildcards,
1504 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1505
1507
1508 if( dlg.ShowModal() != wxID_CANCEL )
1509 {
1510 OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ), KICTL_KICAD_ONLY );
1512 }
1513
1514 // Since we know we're single-top here: trigger library reload
1515 CallAfter(
1516 [&]()
1517 {
1518 KIFACE *schface = Kiway().KiFACE( KIWAY::FACE_SCH );
1519 schface->PreloadLibraries( &Kiway() );
1520
1522 } );
1523}
1524
1525
1527{
1529
1530 // Drop the symbol fields table so export paths re-bind to the new project (#22395).
1532 {
1533 m_symbolFieldsTableDialog->Destroy();
1534 m_symbolFieldsTableDialog = nullptr;
1535 }
1536
1537 // Register schematic saver for autosave history
1539 [this]( const wxString& aProjectPath, std::vector<HISTORY_FILE_DATA>& aFileData )
1540 {
1541 m_schematic->SaveToHistory( aProjectPath, aFileData );
1542 },
1543 m_schematic->GetHistoryLifetimeToken() );
1544
1545 m_designBlocksPane->ProjectChanged();
1546}
1547
1548
1550{
1551 // Use the project's board, not the active sheet's name, which may belong to another project.
1552 wxString projectName = Prj().GetProjectFullName();
1553
1554 wxFileName kicad_board =
1555 projectName.IsEmpty() ? Prj().AbsolutePath( Schematic().GetFileName() ) : wxFileName( projectName );
1556
1557 if( kicad_board.IsOk() && !kicad_board.GetName().IsEmpty() )
1558 {
1559 kicad_board.SetExt( FILEEXT::PcbFileExtension );
1560 wxFileName legacy_board( kicad_board );
1561 legacy_board.SetExt( FILEEXT::LegacyPcbFileExtension );
1562 wxFileName& boardfn = legacy_board;
1563
1564 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1565 boardfn = kicad_board;
1566
1567 if( Kiface().IsSingle() )
1568 {
1569 ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
1570 }
1571 else
1572 {
1573 wxEventBlocker blocker(this);
1574 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1575
1576 if( !frame )
1577 {
1578 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1579
1580 // frame can be null if Cvpcb cannot be run. No need to show a warning
1581 // Kiway() generates the error messages
1582 if( !frame )
1583 return;
1584
1585 frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1586 }
1587
1588 if( !frame->IsVisible() )
1589 frame->Show( true );
1590
1591 // On Windows, Raise() does not bring the window on screen, when iconized
1592 if( frame->IsIconized() )
1593 frame->Iconize( false );
1594
1595 frame->Raise();
1596 }
1597 }
1598 else
1599 {
1601 }
1602}
1603
1604
1606{
1607 wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1608 fn.SetExt( FILEEXT::NetlistFileExtension );
1609
1610 if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1611 return;
1612
1613 try
1614 {
1615 KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1616
1617 if( !player )
1618 {
1619 player = Kiway().Player( FRAME_CVPCB, true );
1620
1621 // player can be null if Cvpcb cannot be run. No need to show a warning
1622 // Kiway() generates the error messages
1623 if( !player )
1624 return;
1625
1626 player->Show( true );
1627 }
1628
1630
1631 player->Raise();
1632 }
1633 catch( const IO_ERROR& )
1634 {
1635 DisplayError( this, _( "Could not open CvPcb" ) );
1636 }
1637}
1638
1639
1640void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1641{
1642 if( event.GetId() == wxID_EXIT )
1643 Kiway().OnKiCadExit();
1644
1645 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1646 Close( false );
1647}
1648
1649
1651{
1652 SCHEMATIC_SETTINGS& settings = m_schematic->Settings();
1653 SIM_LIB_MGR simLibMgr( &Prj() );
1654 NULL_REPORTER devnull;
1655 SCH_SHEET_PATH& sheetPath = GetCurrentSheet();
1656 wxString variant = m_schematic->GetCurrentVariant();
1657
1658 // Patch for bug early in V7.99 dev
1659 if( settings.m_OPO_VRange.EndsWith( 'A' ) )
1660 settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
1661
1662 // Update items which may have ${OP} text variables
1663 //
1665 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1666 {
1667 int flags = 0;
1668
1669 auto invalidateTextVars =
1670 [&flags]( EDA_TEXT* text )
1671 {
1672 if( text->HasTextVars() )
1673 {
1674 text->ClearRenderCache();
1675 text->ClearBoundingBoxCache();
1677 }
1678 };
1679
1680 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1681 {
1682 item->RunOnChildren(
1683 [&invalidateTextVars]( SCH_ITEM* aChild )
1684 {
1685 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1686 invalidateTextVars( text );
1687 },
1689 }
1690
1691 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1692 invalidateTextVars( text );
1693
1694 return flags;
1695 } );
1696
1697 // Update OP overlay items
1698 //
1699 for( SCH_ITEM* item : GetScreen()->Items() )
1700 {
1701 if( sheetPath.GetExcludedFromSim( variant ) )
1702 continue;
1703
1704 if( item->Type() == SCH_LINE_T )
1705 {
1706 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1707
1708 if( !line->GetOperatingPoint().IsEmpty() )
1709 GetCanvas()->GetView()->Update( line );
1710
1711 line->SetOperatingPoint( wxEmptyString );
1712
1713 // update value from netlist, below
1714 }
1715 else if( item->Type() == SCH_SYMBOL_T )
1716 {
1717 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1718 wxString ref = symbol->GetRef( &sheetPath );
1719 std::vector<SCH_PIN*> pins = symbol->GetPins( &sheetPath );
1720
1721 // Power symbols and other symbols which have the reference starting with "#" are
1722 // not included in simulation
1723 if( ref.StartsWith( '#' ) || symbol->ResolveExcludedFromSim( &sheetPath, variant ) )
1724 continue;
1725
1726 for( SCH_PIN* pin : pins )
1727 {
1728 if( !pin->GetOperatingPoint().IsEmpty() )
1729 GetCanvas()->GetView()->Update( pin );
1730
1731 pin->SetOperatingPoint( wxEmptyString );
1732 }
1733
1734 if( pins.size() == 2 )
1735 {
1736 wxString op = m_schematic->GetOperatingPoint( ref, settings.m_OPO_IPrecision, settings.m_OPO_IRange );
1737
1738 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1739 {
1740 pins[0]->SetOperatingPoint( op );
1741 GetCanvas()->GetView()->Update( symbol );
1742 }
1743 }
1744 else
1745 {
1746 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
1747 embeddedFilesStack.push_back( m_schematic->GetEmbeddedFiles() );
1748
1749 if( EMBEDDED_FILES* symbolEmbeddedFiles = symbol->GetEmbeddedFiles() )
1750 {
1751 embeddedFilesStack.push_back( symbolEmbeddedFiles );
1752 symbol->GetLibSymbolRef()->AppendParentEmbeddedFiles( embeddedFilesStack );
1753 }
1754
1755 simLibMgr.SetFilesStack( std::move( embeddedFilesStack ) );
1756
1757 SIM_MODEL& model = simLibMgr.CreateModel( &sheetPath, *symbol, true, 0, variant, devnull ).model;
1758
1759 SPICE_ITEM spiceItem;
1760 spiceItem.refName = ref;
1761 ref = model.SpiceGenerator().ItemName( spiceItem );
1762
1763 for( const auto& modelPin : model.GetPins() )
1764 {
1765 SCH_PIN* symbolPin = symbol->GetPin( modelPin.get().symbolPinNumber );
1766 wxString netChainName = ref + wxS( ":" ) + modelPin.get().modelPinName;
1767 wxString op = m_schematic->GetOperatingPoint( netChainName, settings.m_OPO_IPrecision,
1768 settings.m_OPO_IRange );
1769
1770 if( symbolPin && !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1771 {
1772 symbolPin->SetOperatingPoint( op );
1773 GetCanvas()->GetView()->Update( symbol );
1774 }
1775 }
1776 }
1777 }
1778 }
1779
1780 for( const auto& [ key, subgraphList ] : m_schematic->m_connectionGraph->GetNetMap() )
1781 {
1782 wxString op = m_schematic->GetOperatingPoint( key.Name, settings.m_OPO_VPrecision, settings.m_OPO_VRange );
1783
1784 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1785 {
1786 for( CONNECTION_SUBGRAPH* subgraph : subgraphList )
1787 {
1788 SCH_LINE* longestWire = nullptr;
1789 double length = 0.0;
1790
1791 if( subgraph->GetSheet().GetExcludedFromSim( variant ) )
1792 continue;
1793
1794 for( SCH_ITEM* item : subgraph->GetItems() )
1795 {
1796 if( item->Type() == SCH_LINE_T )
1797 {
1798 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1799
1800 if( line->IsWire() && line->GetLength() > length )
1801 {
1802 longestWire = line;
1803 length = line->GetLength();
1804 }
1805 }
1806 }
1807
1808 if( longestWire )
1809 {
1810 longestWire->SetOperatingPoint( op );
1811 GetCanvas()->GetView()->Update( longestWire );
1812 }
1813 }
1814 }
1815 }
1816}
1817
1818
1820{
1821 if( aItem->Type() == SCH_GLOBAL_LABEL_T || aItem->Type() == SCH_HIER_LABEL_T )
1822 {
1823 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
1824
1825 if( label->AutoRotateOnPlacement() )
1826 {
1827 SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(), label->GetSpinStyle(),
1828 &GetCurrentSheet() );
1829
1830 if( spin != label->GetSpinStyle() )
1831 {
1832 label->SetSpinStyle( spin );
1833
1834 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1835 {
1836 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1837
1838 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1839 otherLabel->AutoplaceFields( aScreen, AUTOPLACE_AUTO );
1840 }
1841 }
1842 }
1843 }
1844}
1845
1846
1848{
1849 SCH_SCREEN* screen = GetScreen();
1850
1851 wxCHECK( screen, /* void */ );
1852
1853 wxString title;
1854
1855 if( !screen->GetFileName().IsEmpty() )
1856 {
1857 wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1858 bool readOnly = false;
1859 bool unsaved = false;
1860
1861 if( fn.IsOk() && screen->FileExists() )
1862 readOnly = screen->IsReadOnly();
1863 else
1864 unsaved = true;
1865
1866 if( IsContentModified() )
1867 title = wxT( "*" );
1868
1869 title += fn.GetName();
1870
1871 wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
1872
1873 if( sheetPath != fn.GetName() )
1874 title += wxString::Format( wxT( " [%s]" ), sheetPath );
1875
1876 if( readOnly )
1877 title += wxS( " " ) + _( "[Read Only]" );
1878
1879 if( unsaved )
1880 title += wxS( " " ) + _( "[Unsaved]" );
1881 }
1882 else
1883 {
1884 title = _( "[no schematic loaded]" );
1885 }
1886
1887 title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1888
1889 SetTitle( title );
1890}
1891
1892
1894{
1896
1897 if( GetScreen() )
1898 GetScreen()->m_zoomInitialized = true;
1899}
1900
1901
1903 PROGRESS_REPORTER* aProgressReporter, bool aCleanupDone )
1904{
1905 wxString highlightedConn = GetHighlightedConnection();
1906 bool hasHighlightedConn = !highlightedConn.IsEmpty();
1907
1908 std::function<void( SCH_ITEM* )> changeHandler =
1909 [&]( SCH_ITEM* aChangedItem ) -> void
1910 {
1911 GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1912
1913 SCH_CONNECTION* connection = aChangedItem->Connection();
1914
1916 return;
1917
1918 if( !hasHighlightedConn )
1919 {
1920 // No highlighted connection, but connectivity has changed, so refresh
1921 // the list of all nets
1923 }
1924 else if( connection && ( connection->Name() == highlightedConn
1925 || connection->HasDriverChanged() ) )
1926 {
1928 }
1929 };
1930
1931 Schematic().RecalculateConnections( aCommit, aCleanupFlags,
1933 aProgressReporter,
1934 GetCanvas()->GetView(),
1935 &changeHandler,
1936 m_undoList.m_CommandsList.empty() ? nullptr
1937 : m_undoList.m_CommandsList.back(),
1938 aCleanupDone );
1939
1941}
1942
1943
1945{
1946 SCH_COMMIT cleanup( m_toolManager );
1948 cleanup.Push( _( "Schematic Cleanup" ), SKIP_CONNECTIVITY );
1949}
1950
1951
1953{
1954 const wxString highlightedConn = GetHighlightedConnection();
1955
1957 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1958 {
1959 int flags = aForce ? KIGFX::REPAINT : 0;
1960 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
1961 SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
1962
1963 auto invalidateTextVars =
1964 [&flags]( EDA_TEXT* text )
1965 {
1966 if( text->HasTextVars() )
1967 {
1968 text->ClearRenderCache();
1969 text->ClearBoundingBoxCache();
1971 }
1972 };
1973
1974 if( connection && connection->HasDriverChanged() )
1975 {
1976 connection->ClearDriverChanged();
1977 flags |= KIGFX::REPAINT;
1978 }
1979
1980 if( item )
1981 {
1982 item->RunOnChildren(
1983 [&invalidateTextVars]( SCH_ITEM* aChild )
1984 {
1985 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1986 invalidateTextVars( text );
1987 },
1989
1990 if( flags & KIGFX::GEOMETRY )
1991 GetScreen()->Update( item, false ); // Refresh RTree
1992 }
1993
1994 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1995 invalidateTextVars( text );
1996
1997 return flags;
1998 } );
1999
2000 if( aForce || m_highlightedConnChanged
2001 || !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
2002 {
2006 }
2007}
2008
2009
2014
2015
2017{
2018 GetCanvas()->GetView()->Update( aItem );
2019}
2020
2021
2028
2029
2030std::unique_ptr<GRID_HELPER> SCH_EDIT_FRAME::MakeGridHelper()
2031{
2032 return std::make_unique<EE_GRID_HELPER>( m_toolManager );
2033}
2034
2035
2037{
2039
2040 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
2041
2043
2044 if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
2045 {
2046 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
2047 GetRenderSettings()->SetDefaultFont( cfg->m_Appearance.default_font );
2048
2049 KIGFX::VIEW* view = GetCanvas()->GetView();
2050 view->SetLayerVisible( LAYER_ERC_ERR, cfg->m_Appearance.show_erc_errors );
2051 view->SetLayerVisible( LAYER_ERC_WARN, cfg->m_Appearance.show_erc_warnings );
2052 view->SetLayerVisible( LAYER_ERC_EXCLUSION, cfg->m_Appearance.show_erc_exclusions );
2053 view->SetLayerVisible( LAYER_OP_VOLTAGES, cfg->m_Appearance.show_op_voltages );
2054 view->SetLayerVisible( LAYER_OP_CURRENTS, cfg->m_Appearance.show_op_currents );
2055
2056 GetRenderSettings()->m_ShowPinAltIcons = cfg->m_Appearance.show_pin_alt_icons;
2057 GetRenderSettings()->m_ShowRemappedPinNumbers = cfg->m_Appearance.show_remapped_pin_numbers;
2058
2060
2061 }
2062
2064
2065 for( SCH_ITEM* item : screen->Items() )
2066 {
2067 item->ClearCaches();
2068
2069 if( item->Type() == SCH_LINE_T )
2070 {
2071 SCH_LINE* line = static_cast<SCH_LINE*>( item );
2072
2073 if( line->IsWire() || line->IsBus() )
2074 UpdateHopOveredWires( line );
2075 }
2076 }
2077
2078 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
2079 libSymbol->ClearCaches();
2080
2082
2084 Layout();
2085 SendSizeEvent();
2086}
2087
2088
2090{
2091 // Store the current zoom level into the current screen before calling
2092 // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
2094
2095 // Rebuild the sheet view (draw area and any other items):
2097}
2098
2099
2101{
2102 // call my base class
2104
2105 // tooltips in toolbars
2107
2108 // For some obscure reason, the AUI manager hides the first modified pane.
2109 // So force show panes
2110 wxAuiPaneInfo& design_blocks_pane_info = m_auimgr.GetPane( m_designBlocksPane );
2111 bool panel_shown = design_blocks_pane_info.IsShown();
2112 design_blocks_pane_info.Caption( _( "Design Blocks" ) );
2113 design_blocks_pane_info.Show( panel_shown );
2114
2115 m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
2116 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
2117 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
2118 m_auimgr.GetPane( m_designBlocksPane ).Caption( _( "Design Blocks" ) );
2119 m_auimgr.GetPane( RemoteSymbolPaneName() ).Caption( _( "Remote Symbols" ) );
2120 m_auimgr.Update();
2121 m_hierarchy->UpdateHierarchyTree();
2122
2123 // status bar
2125
2126 updateTitle();
2127
2128 // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
2129 // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
2130 // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
2131 // toolbar to update correctly.
2132#if defined( __WXMSW__ )
2133 PostSizeEvent();
2134#endif
2135}
2136
2137
2139{
2140 if( !GetHighlightedNetChain().IsEmpty() )
2141 {
2142 if( SCH_NETCHAIN* sig = m_schematic->NetChains().GetNetChainByName( GetHighlightedNetChain() ) )
2143 {
2144 wxString nets;
2145
2146 for( const wxString& n : sig->GetNets() )
2147 {
2148 if( !nets.IsEmpty() )
2149 nets += wxT( ", " );
2150
2151 nets += n;
2152 }
2153
2154 SetStatusText( wxString::Format( _( "Net chain members: %s" ), nets ) );
2155 return;
2156 }
2157 }
2158
2159 if( !GetHighlightedConnection().IsEmpty() )
2160 {
2161 SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
2163 }
2164 else
2165 {
2166 SetStatusText( wxT( "" ) );
2167 }
2168}
2169
2170
2172{
2173 if( m_toolManager )
2175
2176 SCH_BASE_FRAME::SetScreen( aScreen );
2177
2178 // SetSheetNumberAndCount() dereferences the current sheet's screen, which is absent on the
2179 // unload paths that pass a null screen.
2180 if( aScreen )
2182
2183 GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
2184
2185 if( m_toolManager )
2187}
2188
2189
2190const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
2191{
2192 BOX2I bBoxDoc;
2193
2194 if( !GetScreen() )
2195 return bBoxDoc;
2196
2197 if( aIncludeAllVisible )
2198 {
2199 // Get the whole page size and return that
2200 int sizeX = GetScreen()->GetPageSettings().GetWidthIU( schIUScale.IU_PER_MILS );
2201 int sizeY = GetScreen()->GetPageSettings().GetHeightIU( schIUScale.IU_PER_MILS );
2202 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
2203 }
2204 else
2205 {
2206 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
2208 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
2209
2210 // Calc the bounding box of all items on screen except the page border
2211 for( EDA_ITEM* item : GetScreen()->Items() )
2212 {
2213 if( item != dsAsItem ) // Ignore the drawing-sheet itself
2214 bBoxDoc.Merge( item->GetBoundingBox() );
2215 }
2216 }
2217
2218 return bBoxDoc;
2219}
2220
2221
2223{
2224 if( !Schematic().HasHierarchy() )
2225 return false;
2226
2227 return Schematic().Hierarchy().IsModified();
2228}
2229
2230
2232{
2233 EESCHEMA_SETTINGS* cfg = eeconfig();
2234 return cfg && cfg->m_Appearance.show_hidden_pins;
2235}
2236
2237
2238void SCH_EDIT_FRAME::FocusOnItem( EDA_ITEM* aItem, bool aAllowScroll )
2239{
2240 // nullptr will clear the current focus
2241 if( aItem != nullptr && !aItem->IsSCH_ITEM() )
2242 return;
2243
2244 static KIID lastBrightenedItemID( niluuid );
2245
2246 SCH_ITEM* lastItem = Schematic().ResolveItem( lastBrightenedItemID, nullptr, true );
2247
2248 if( lastItem && lastItem != aItem )
2249 {
2250 lastItem->ClearBrightened();
2251
2252 UpdateItem( lastItem );
2253 lastBrightenedItemID = niluuid;
2254 }
2255
2256 if( aItem )
2257 {
2258 if( !aItem->IsBrightened() )
2259 {
2260 aItem->SetBrightened();
2261
2262 UpdateItem( aItem );
2263 lastBrightenedItemID = aItem->m_Uuid;
2264 }
2265
2266 FocusOnLocation( aItem->GetFocusPosition(), aAllowScroll );
2267 }
2268}
2269
2270
2272{
2273 return Schematic().GetFileName();
2274}
2275
2276
2278{
2279 return m_toolManager->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
2280}
2281
2282void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2283{
2284 // doCloseWindow() destroys the tool manager and then updates the AUI layout, which can
2285 // dispatch a deferred size event back to this still-bound handler.
2286 if( IsShown() && GetToolManager() )
2287 {
2288 // We only need this until the frame is done resizing and the final client size is
2289 // established.
2290 Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
2292 }
2293
2294 // Skip() is called in the base class.
2295 EDA_DRAW_FRAME::OnSize( aEvent );
2296}
2297
2298
2300 const KIID& aSchematicSymbolUUID )
2301{
2302 SCH_SHEET_PATH principalPath;
2303 SCH_SHEET_LIST sheets = Schematic().Hierarchy();
2304 SCH_ITEM* item = sheets.ResolveItem( aSchematicSymbolUUID, &principalPath, true );
2305 SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
2306 SCH_COMMIT commit( m_toolManager );
2307
2308 if( !principalSymbol )
2309 return false;
2310
2311 wxString principalRef;
2312
2313 if( principalSymbol->IsAnnotated( &principalPath ) )
2314 principalRef = principalSymbol->GetRef( &principalPath, false );
2315
2316 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
2317
2318 for( const SCH_SHEET_PATH& path : sheets )
2319 {
2320 for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2321 {
2322 SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
2323
2324 if( candidateSymbol == principalSymbol
2325 || ( candidateSymbol->IsAnnotated( &path )
2326 && candidateSymbol->GetRef( &path, false ) == principalRef ) )
2327 {
2328 allUnits.emplace_back( candidateSymbol, path );
2329 }
2330 }
2331 }
2332
2333 for( auto& [ unit, path ] : allUnits )
2334 {
2335 // This needs to be done before the LIB_SYMBOL is changed to prevent stale
2336 // library symbols in the schematic file.
2337 path.LastScreen()->Remove( unit );
2338
2339 if( !unit->IsNew() )
2340 commit.Modify( unit, path.LastScreen() );
2341
2342 unit->SetLibSymbol( aSymbol.Flatten().release() );
2343 unit->UpdateFields( &GetCurrentSheet(),
2344 true, /* update style */
2345 true, /* update ref */
2346 true, /* update other fields */
2347 false, /* reset ref */
2348 false /* reset other fields */ );
2349
2350 path.LastScreen()->Append( unit );
2351 GetCanvas()->GetView()->Update( unit );
2352 }
2353
2354 // Clear any orphaned alternate pins.
2355 for( SCH_PIN* pin : principalSymbol->GetPins() )
2356 {
2357 wxString altName = pin->GetAlt();
2358
2359 if( altName.IsEmpty() )
2360 continue;
2361
2362 if( pin->GetAlternates().count( altName ) == 0 )
2363 pin->SetAlt( wxEmptyString );
2364 }
2365
2366 if( !commit.Empty() )
2367 commit.Push( _( "Save Symbol to Schematic" ) );
2368
2369 return true;
2370}
2371
2372
2373void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2374{
2375 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2376
2377 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
2378 sch_item->ClearCaches();
2379}
2380
2381
2383{
2384 wxCHECK( m_toolManager, /* void */ );
2385
2389
2390 wxCHECK( screen, /* void */ );
2391
2393
2394 SCH_BASE_FRAME::SetScreen( screen );
2395
2396 SetSheetNumberAndCount(); // will also update CurrentScreen()'s sheet number info
2397
2399
2400 // update the references, units, and intersheet-refs
2402
2403 // dangling state can also have changed if different units with different pin locations are
2404 // used
2407
2408 SCH_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>();
2409
2410 wxCHECK( selectionTool, /* void */ );
2411
2412 auto visit =
2413 [&]( EDA_ITEM* item )
2414 {
2416 && !m_findReplaceData->findString.IsEmpty()
2417 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
2418 {
2419 item->SetForceVisible( true );
2420 selectionTool->BrightenItem( item );
2421 }
2422 else if( item->IsBrightened() )
2423 {
2424 item->SetForceVisible( false );
2425 selectionTool->UnbrightenItem( item );
2426 }
2427 };
2428
2429 for( SCH_ITEM* item : screen->Items() )
2430 {
2431 visit( item );
2432
2433 item->RunOnChildren(
2434 [&]( SCH_ITEM* aChild )
2435 {
2436 visit( aChild );
2437 },
2439 }
2440
2441 if( !screen->m_zoomInitialized )
2442 {
2444 }
2445 else
2446 {
2447 // Set zoom to last used in this screen
2448 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
2449 GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
2450 }
2451
2452 updateTitle();
2453
2454 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
2455
2456 // Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
2458
2459 SCH_EDITOR_CONTROL* editTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
2460
2461 wxCHECK( editTool, /* void */ );
2462
2464 editTool->UpdateNetHighlighting( dummy );
2465
2466 m_hierarchy->UpdateHierarchySelection();
2467
2468 m_schematic->OnSchSheetChanged();
2469
2470 std::string sheetPath = TO_UTF8( GetCurrentSheet().PathAsString() );
2472}
2473
2474
2476{
2477 if( !m_diffSymbolDialog )
2478 {
2480 _( "Compare Symbol with Library" ) );
2481
2482 m_diffSymbolDialog->m_sdbSizerApply->SetLabel( _( "Update Symbol from Library..." ) );
2483 m_diffSymbolDialog->m_sdbSizerApply->PostSizeEventToParent();
2484 m_diffSymbolDialog->m_sdbSizerApply->Show();
2485 }
2486
2487 return m_diffSymbolDialog;
2488}
2489
2490
2491void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
2492{
2493 if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
2494 {
2495 if( aEvent.GetId() == wxID_APPLY )
2496 {
2497 KIID symbolUUID = m_diffSymbolDialog->GetUserItemID();
2498
2499 CallAfter(
2500 [this, symbolUUID]()
2501 {
2502 EDA_ITEM* item = ResolveItem( symbolUUID );
2503
2504 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item ) )
2505 {
2506 m_toolManager->RunAction<EDA_ITEM*>( ACTIONS::selectItem, symbol );
2507
2509 dlg.ShowQuasiModal();
2510 }
2511 } );
2512 }
2513
2514 m_diffSymbolDialog->Destroy();
2515 m_diffSymbolDialog = nullptr;
2516 }
2517}
2518
2519
2521{
2522 if( !m_ercDialog )
2523 m_ercDialog = new DIALOG_ERC( this );
2524
2525 return m_ercDialog;
2526}
2527
2528
2530{
2532
2533 if( m_ercDialog )
2534 {
2535 m_ercDialog->DeleteAllMarkers( true );
2536 }
2537 else
2538 {
2540 SCH_SCREENS screens( Schematic().Root() );
2542 }
2543}
2544
2545
2547{
2548 if( m_ercDialog )
2549 m_ercDialog->UpdateData();
2550
2551 for( SCH_ITEM* marker : GetScreen()->Items().OfType( SCH_MARKER_T ) )
2552 {
2553 GetCanvas()->GetView()->Remove( marker );
2554 GetCanvas()->GetView()->Add( marker );
2555 }
2556
2557 GetCanvas()->Refresh();
2558}
2559
2560
2561void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
2562{
2563 if( m_ercDialog )
2564 {
2565 m_ercDialog->Destroy();
2566 m_ercDialog = nullptr;
2567 }
2568}
2569
2570
2572{
2574 {
2575 auto* dlg = new DIALOG_SYMBOL_FIELDS_TABLE( this );
2576
2577 if( dlg->WasAborted() )
2578 {
2579 dlg->Destroy();
2580 return nullptr;
2581 }
2582
2584 }
2585
2587}
2588
2589
2591{
2592 return m_netNavigator;
2593}
2594
2595
2597{
2599 {
2600 m_symbolFieldsTableDialog->Destroy();
2601 m_symbolFieldsTableDialog = nullptr;
2602 }
2603}
2604
2605
2606void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
2607{
2608 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(), aListener );
2609
2610 // Don't add duplicate listeners.
2611 if( it == m_schematicChangeListeners.end() )
2612 m_schematicChangeListeners.push_back( aListener );
2613}
2614
2615
2617{
2618 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(), aListener );
2619
2620 // Don't add duplicate listeners.
2621 if( it != m_schematicChangeListeners.end() )
2622 m_schematicChangeListeners.erase( it );
2623}
2624
2625
2627{
2628 wxPanel* panel = new wxPanel( this );
2629
2630 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
2631
2632 // Create horizontal sizer for search control and gear button
2633 wxBoxSizer* searchSizer = new wxBoxSizer( wxHORIZONTAL );
2634
2635 m_netNavigatorFilter = new wxSearchCtrl( panel, wxID_ANY );
2636 m_netNavigatorFilter->SetDescriptiveText( _( "Filter nets" ) );
2637 m_netNavigatorFilter->ShowCancelButton( false );
2638 searchSizer->Add( m_netNavigatorFilter, 1, wxEXPAND | wxRIGHT, FromDIP( 2 ) );
2639
2640 m_netNavigatorMenuButton = new BITMAP_BUTTON( panel, wxID_ANY );
2642 m_netNavigatorMenuButton->SetPadding( 2 );
2643 searchSizer->Add( m_netNavigatorMenuButton, 0, wxALIGN_CENTER_VERTICAL );
2644
2645 sizer->Add( searchSizer, 0, wxEXPAND | wxALL, FromDIP( 2 ) );
2646
2647 m_netNavigator = new wxGenericTreeCtrl( panel, wxID_ANY, wxPoint( 0, 0 ), FromDIP( wxSize( 160, 250 ) ),
2648 wxTR_DEFAULT_STYLE | wxNO_BORDER );
2649 sizer->Add( m_netNavigator, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP( 2 ) );
2650
2651 panel->SetSizer( sizer );
2652
2653 m_netNavigatorFilter->Bind( wxEVT_COMMAND_TEXT_UPDATED, &SCH_EDIT_FRAME::onNetNavigatorFilterChanged, this );
2654 m_netNavigatorFilter->Bind( wxEVT_KEY_DOWN, &SCH_EDIT_FRAME::onNetNavigatorKey, this );
2655 m_netNavigator->Bind( wxEVT_KEY_DOWN, &SCH_EDIT_FRAME::onNetNavigatorKey, this );
2656 m_netNavigator->Bind( wxEVT_TREE_ITEM_MENU, &SCH_EDIT_FRAME::onNetNavigatorItemMenu, this );
2657 m_netNavigator->Bind( wxEVT_CONTEXT_MENU, &SCH_EDIT_FRAME::onNetNavigatorContextMenu, this );
2658
2659 m_netNavigatorMenuButton->Bind( wxEVT_LEFT_DOWN,
2660 [this]( wxMouseEvent& event )
2661 {
2662 wxMenu menu;
2663 wxMenuItem* wildcardItem = menu.AppendRadioItem( ID_NET_NAVIGATOR_SEARCH_WILDCARD,
2664 _( "Wildcard Search" ) );
2665 wxMenuItem* regexItem = menu.AppendRadioItem( ID_NET_NAVIGATOR_SEARCH_REGEX,
2666 _( "Regex Search" ) );
2667
2668 EESCHEMA_SETTINGS* cfg = eeconfig();
2669
2671 wildcardItem->Check();
2672 else
2673 regexItem->Check();
2674
2675 PopupMenu( &menu );
2676 } );
2677
2683
2684 return panel;
2685}
2686
2687
2688void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection, const NET_NAVIGATOR_ITEM_DATA* aSelection,
2689 bool aForceNetNavigatorRefresh )
2690{
2691 bool connectionChanged = aConnection != m_highlightedConn;
2692
2693 m_highlightedConn = aConnection;
2694
2695 if( connectionChanged || aForceNetNavigatorRefresh )
2696 RefreshNetNavigator( aSelection );
2697
2698 if( connectionChanged && m_hierarchy )
2699 m_hierarchy->UpdateNetHighlight( aConnection );
2700}
2701
2702
2704{
2706
2707 if( m_netNavigator )
2708 {
2709 NET_NAVIGATOR_ITEM_DATA itemData;
2710 wxTreeItemId selection = m_netNavigator->GetSelection();
2711 bool refreshSelection = selection.IsOk() && selection != m_netNavigator->GetRootItem();
2712
2713 if( refreshSelection )
2714 {
2716 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
2717
2718 wxCHECK( tmp, /* void */ );
2719 itemData = *tmp;
2720 }
2721
2722 m_netNavigator->DeleteAllItems();
2723 RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
2724 }
2725}
2726
2727
2729{
2730 if( !m_netNavigator )
2731 return;
2732
2733 wxString newFilter = m_netNavigatorFilter ? m_netNavigatorFilter->GetValue() : wxString();
2734
2735 if( newFilter == m_netNavigatorFilterValue )
2736 return;
2737
2738 m_netNavigatorFilterValue = newFilter;
2739
2740 NET_NAVIGATOR_ITEM_DATA selectionData;
2741 NET_NAVIGATOR_ITEM_DATA* selectionPtr = nullptr;
2742
2743 wxTreeItemId selection = m_netNavigator->GetSelection();
2744
2745 if( selection.IsOk() )
2746 {
2747 if( NET_NAVIGATOR_ITEM_DATA* tmp =
2748 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) ) )
2749 {
2750 selectionData = *tmp;
2751 selectionPtr = &selectionData;
2752 }
2753 }
2754
2755 RefreshNetNavigator( selectionPtr );
2756
2757 aEvent.Skip();
2758}
2759
2760
2761void SCH_EDIT_FRAME::onNetNavigatorKey( wxKeyEvent& aEvent )
2762{
2763 if( aEvent.GetKeyCode() == WXK_ESCAPE )
2764 {
2765 // Clear the search string and refresh
2767 m_netNavigatorFilter->SetValue( wxEmptyString );
2768
2769 m_netNavigatorFilterValue = wxEmptyString;
2770
2772
2773 // Don't skip the event - we handled it
2774 return;
2775 }
2776
2777 aEvent.Skip();
2778}
2779
2780
2781
2783{
2784 showNetNavigatorMenu( aEvent.GetItem() );
2785}
2786
2787
2788void SCH_EDIT_FRAME::onNetNavigatorContextMenu( wxContextMenuEvent& aEvent )
2789{
2790 if( !m_netNavigator )
2791 return;
2792
2793 wxPoint screenPos = aEvent.GetPosition();
2794
2795 if( screenPos == wxDefaultPosition )
2796 screenPos = wxGetMousePosition();
2797
2798 wxPoint clientPos = m_netNavigator->ScreenToClient( screenPos );
2799 int flags = 0;
2800 wxTreeItemId item = m_netNavigator->HitTest( clientPos, flags );
2801
2802 showNetNavigatorMenu( item );
2803}
2804
2805
2806void SCH_EDIT_FRAME::showNetNavigatorMenu( const wxTreeItemId& aItem )
2807{
2808 if( !m_netNavigator )
2809 return;
2810
2811 wxMenu menu;
2812
2813 menu.Append( ID_NET_NAVIGATOR_EXPAND_ALL, _( "Expand All" ) );
2814 menu.Append( ID_NET_NAVIGATOR_COLLAPSE_ALL, _( "Collapse All" ) );
2815
2816 wxMenuItem* findInInspector = new wxMenuItem( &menu, ID_NET_NAVIGATOR_FIND_IN_INSPECTOR,
2817 _( "Find in Net Inspector" ) );
2818 menu.Append( findInInspector );
2819
2820 wxString netName;
2821
2822 if( aItem.IsOk() )
2823 {
2824 wxTreeItemId netItem = aItem;
2825
2826 if( m_netNavigator->GetItemParent( netItem ) != m_netNavigator->GetRootItem() )
2827 {
2828 wxTreeItemId parent = m_netNavigator->GetItemParent( netItem );
2829
2830 while( parent.IsOk() && parent != m_netNavigator->GetRootItem() )
2831 {
2832 netItem = parent;
2833 parent = m_netNavigator->GetItemParent( netItem );
2834 }
2835
2836 if( parent == m_netNavigator->GetRootItem() )
2837 {
2838 if( wxStringClientData* data =
2839 dynamic_cast<wxStringClientData*>( m_netNavigator->GetItemData( netItem ) ) )
2840 {
2841 netName = data->GetData();
2842 }
2843 }
2844 }
2845 else if( m_netNavigator->GetItemParent( netItem ) == m_netNavigator->GetRootItem() )
2846 {
2847 if( wxStringClientData* data =
2848 dynamic_cast<wxStringClientData*>( m_netNavigator->GetItemData( netItem ) ) )
2849 {
2850 netName = data->GetData();
2851 }
2852 }
2853 else if( !m_highlightedConn.IsEmpty() && netItem == m_netNavigator->GetRootItem() )
2854 {
2855 netName = m_highlightedConn;
2856 }
2857 }
2858 else if( !m_highlightedConn.IsEmpty() && m_netNavigator->GetRootItem().IsOk() )
2859 {
2860 netName = m_highlightedConn;
2861 }
2862
2863 if( netName.IsEmpty() )
2864 {
2865 findInInspector->Enable( false );
2867 }
2868 else
2869 {
2870 m_netNavigatorMenuNetName = netName;
2871 }
2872
2873 PopupMenu( &menu );
2874}
2875
2876
2877void SCH_EDIT_FRAME::onNetNavigatorMenuCommand( wxCommandEvent& aEvent )
2878{
2879 if( !m_netNavigator )
2880 return;
2881
2882 switch( aEvent.GetId() )
2883 {
2885 m_netNavigator->ExpandAll();
2886 break;
2887
2889 m_netNavigator->CollapseAll();
2890
2891 if( m_netNavigator->GetRootItem().IsOk() )
2892 m_netNavigator->Expand( m_netNavigator->GetRootItem() );
2893 break;
2894
2896 if( !m_netNavigatorMenuNetName.IsEmpty() )
2898 break;
2899
2902 if( EESCHEMA_SETTINGS* cfg = eeconfig() )
2903 {
2904 cfg->m_AuiPanels.net_nav_search_mode_wildcard = ( aEvent.GetId() == ID_NET_NAVIGATOR_SEARCH_WILDCARD );
2905
2906 // Refresh the navigator with current filter
2908 }
2909
2910 break;
2911
2912 default:
2913 aEvent.Skip();
2914 return;
2915 }
2916
2918
2919 aEvent.Skip( false );
2920}
2921
2922
2924{
2925 wxAuiPaneInfo& hierarchyPane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2926 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
2927 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
2928 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
2929
2930 // Don't give the selection filter its own visibility controls; instead show it if
2931 // anything else is visible
2932 bool showFilter = ( hierarchyPane.IsShown() && hierarchyPane.IsDocked() )
2933 || ( netNavigatorPane.IsShown() && netNavigatorPane.IsDocked() )
2934 || ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
2935
2936 selectionFilterPane.Show( showFilter );
2937}
2938
2939
2941{
2942 wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
2944 aEvt.Skip();
2945}
2946
2947
2949{
2950 EESCHEMA_SETTINGS* cfg = eeconfig();
2951
2952 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
2953 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
2954
2956
2957 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
2958 searchPaneInfo.Show( m_show_search );
2959
2960 if( m_show_search )
2961 {
2962 searchPaneInfo.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
2963
2964 if( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
2965 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
2966 {
2967 SetAuiPaneSize( m_auimgr, searchPaneInfo, -1, cfg->m_AuiPanels.search_panel_height );
2968 }
2969 else if( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
2970 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
2971 {
2972 SetAuiPaneSize( m_auimgr, searchPaneInfo, cfg->m_AuiPanels.search_panel_width, -1 );
2973 }
2974
2975 m_searchPane->FocusSearch();
2976 m_searchPane->RefreshSearch();
2977 }
2978 else
2979 {
2980 cfg->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
2981 cfg->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
2982 cfg->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
2983 m_auimgr.Update();
2984 }
2985}
2986
2987
2989{
2990 if( !m_propertiesPanel )
2991 return;
2992
2993 bool show = !m_propertiesPanel->IsShownOnScreen();
2994
2995 wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
2996 propertiesPaneInfo.Show( show );
2997
2999
3000 EESCHEMA_SETTINGS* settings = eeconfig();
3001
3002 if( show )
3003 {
3004 SetAuiPaneSize( m_auimgr, propertiesPaneInfo, settings->m_AuiPanels.properties_panel_width, -1 );
3005 }
3006 else
3007 {
3008 settings->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
3009 m_auimgr.Update();
3010 }
3011}
3012
3013
3015{
3016 EESCHEMA_SETTINGS* cfg = eeconfig();
3017
3018 wxCHECK( cfg, /* void */ );
3019
3020 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
3021
3022 hierarchy_pane.Show( !hierarchy_pane.IsShown() );
3023
3025
3026 if( hierarchy_pane.IsShown() )
3027 {
3028 if( hierarchy_pane.IsFloating() )
3029 {
3030 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
3032 m_auimgr.Update();
3033 }
3034 else if( cfg->m_AuiPanels.hierarchy_panel_docked_width > 0 )
3035 {
3036 // SetAuiPaneSize also updates m_auimgr
3038 }
3039 }
3040 else
3041 {
3042 if( hierarchy_pane.IsFloating() )
3043 {
3044 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
3045 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
3046 }
3047 else
3048 {
3050 }
3051
3052 m_auimgr.Update();
3053 }
3054}
3055
3056
3058{
3059 EESCHEMA_SETTINGS* cfg = eeconfig();
3060
3061 wxCHECK( cfg, /* void */ );
3062
3063 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
3064
3065 db_library_pane.Show( !db_library_pane.IsShown() );
3066
3067 if( db_library_pane.IsShown() )
3068 {
3069 if( db_library_pane.IsFloating() )
3070 {
3071 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
3073 m_auimgr.Update();
3074 }
3075 else
3076 {
3077 // SetAuiPaneSize also updates m_auimgr
3078 SetAuiPaneSize( m_auimgr, db_library_pane,
3080 }
3081 }
3082 else
3083 {
3084 if( db_library_pane.IsFloating() )
3085 {
3086 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
3087 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
3088 }
3089 else
3090 {
3092 }
3093
3094 m_auimgr.Update();
3095 }
3096}
3097
3098
3100{
3101 EESCHEMA_SETTINGS* cfg = eeconfig();
3102
3103 wxCHECK( cfg, /* void */ );
3104
3105 wxAuiPaneInfo& remotePane = m_auimgr.GetPane( RemoteSymbolPaneName() );
3106
3107 remotePane.Show( !remotePane.IsShown() );
3108
3109 if( remotePane.IsShown() )
3110 {
3111 if( m_remoteSymbolPane )
3112 m_remoteSymbolPane->Activate();
3113
3114 if( remotePane.IsFloating() )
3115 {
3116 remotePane.FloatingSize( cfg->m_AuiPanels.remote_symbol_panel_float_width,
3118 m_auimgr.Update();
3119 }
3121 {
3122 SetAuiPaneSize( m_auimgr, remotePane,
3124 }
3125 }
3126 else
3127 {
3128 if( remotePane.IsFloating() )
3129 {
3130 cfg->m_AuiPanels.remote_symbol_panel_float_width = remotePane.floating_size.x;
3131 cfg->m_AuiPanels.remote_symbol_panel_float_height = remotePane.floating_size.y;
3132 }
3133 else if( m_remoteSymbolPane )
3134 {
3136 }
3137
3138 m_auimgr.Update();
3139 }
3140}
3141
3142
3144{
3145 wxCHECK( aSchematic, /* void */ );
3146
3147 if( m_schematic )
3148 {
3151 SetScreen( nullptr );
3152 m_schematic->SetProject( nullptr );
3153
3154 // Detach before the outgoing schematic (and its tracker) is freed.
3155 if( GetCanvas() && GetCanvas()->GetView() )
3157
3159 }
3160
3161 aSchematic->SetProject( &Prj() );
3162 delete m_schematic;
3163
3164 m_schematic = aSchematic;
3165 m_schematic->SetSchematicHolder( this );
3166
3167 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
3168 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
3169 m_toolManager->SetEnvironment( m_schematic, GetCanvas()->GetView(), GetCanvas()->GetViewControls(), config(),
3170 this );
3171}
3172
3173
3175{
3177 return;
3178
3179 m_currentVariantCtrl->SetSelection( m_currentVariantCtrl->GetCount() - 1 );
3180
3181 wxCommandEvent dummy( wxEVT_CHOICE, ID_TOOLBAR_SCH_SELECT_VARAIANT );
3183}
3184
3185
3187{
3188 wxArrayString choices = Schematic().GetVariantNamesForUI();
3189
3190 // Default variant cannot be edited.
3191 choices.RemoveAt( 0 );
3192
3193 if( choices.IsEmpty() )
3194 {
3195 GetInfoBar()->ShowMessageFor( _( "No design variants to edit." ), 10000, wxICON_ERROR );
3196 return;
3197 }
3198
3199 wxSingleChoiceDialog chooser( this, _( "Select variant to edit description:" ) + wxS( " " ),
3200 _( "Edit Variant Description" ), choices );
3201 chooser.Layout();
3202
3203 if( chooser.ShowModal() == wxID_CANCEL )
3204 return;
3205
3206 wxString variantName = chooser.GetStringSelection();
3207
3208 if( variantName.IsEmpty() )
3209 return;
3210
3211 wxString currentDesc = Schematic().GetVariantDescription( variantName );
3212
3213 wxDialog dlg( this, wxID_ANY, wxString::Format( _( "Edit Description for '%s'" ), variantName ), wxDefaultPosition,
3214 wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
3215
3216 wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
3217
3218 wxStaticText* label = new wxStaticText( &dlg, wxID_ANY, _( "Description:" ) );
3219 mainSizer->Add( label, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 10 );
3220
3221 mainSizer->AddSpacer( 3 );
3222
3223 wxTextCtrl* descCtrl =
3224 new wxTextCtrl( &dlg, wxID_ANY, currentDesc, wxDefaultPosition, wxSize( 300, 60 ), wxTE_MULTILINE );
3225 mainSizer->Add( descCtrl, 1, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 10 );
3226
3227 wxStdDialogButtonSizer* btnSizer = new wxStdDialogButtonSizer();
3228 btnSizer->AddButton( new wxButton( &dlg, wxID_OK ) );
3229 btnSizer->AddButton( new wxButton( &dlg, wxID_CANCEL ) );
3230 btnSizer->Realize();
3231 mainSizer->Add( btnSizer, 0, wxALL | wxALIGN_RIGHT, 5 );
3232
3233 dlg.SetSizer( mainSizer );
3234 dlg.Fit();
3235 dlg.Centre();
3236
3237 if( dlg.ShowModal() == wxID_CANCEL )
3238 return;
3239
3240 wxString newDesc = descCtrl->GetValue().Trim().Trim( false );
3241
3242 Schematic().SetVariantDescription( variantName, newDesc );
3243 OnModify();
3244 GetCanvas()->Refresh();
3245}
3246
3247
3249{
3251 return;
3252
3253 wxArrayString choices = Schematic().GetVariantNamesForUI();
3254
3255 // Default variant cannot be removed.
3256 choices.RemoveAt( 0 );
3257
3258 // wxSingleChoiceDialog will ellipsize the title bar if the contents aren't wide enough. The set
3259 // of spaces in the control label are to prevent this.
3260 wxSingleChoiceDialog dlg( this, _( "Select variant name to remove:" ) + wxS( " " ),
3261 _( "Remove Design Variant" ), choices );
3262 dlg.Layout();
3263
3264 if( dlg.ShowModal() == wxID_CANCEL )
3265 return;
3266
3267 wxString variantName = dlg.GetStringSelection();
3268
3269 if( variantName.IsEmpty() )
3270 return;
3271
3272 SCH_COMMIT commit( this );
3273 Schematic().DeleteVariant( variantName, &commit );
3274
3275 if( !commit.Empty() )
3276 {
3277 commit.Push( wxString::Format( wxS( "Delete variant '%s'" ), variantName ) );
3278 OnModify();
3279 }
3280
3281 if( Schematic().GetCurrentVariant() == variantName )
3282 SetCurrentVariant( wxEmptyString );
3283
3284 UpdateVariantSelectionCtrl( Schematic().GetVariantNamesForUI() );
3285
3286 GetCanvas()->Refresh();
3287}
3288
3289
3290bool SCH_EDIT_FRAME::validateNewVariantName( const wxString& aName, const wxString& aExcludeName )
3291{
3292 if( aName.IsEmpty() )
3293 {
3294 GetInfoBar()->ShowMessageFor( _( "Variant name cannot be empty." ), 10000, wxICON_ERROR );
3295 return false;
3296 }
3297
3298 if( aName.CmpNoCase( GetDefaultVariantName() ) == 0 )
3299 {
3300 GetInfoBar()->ShowMessageFor( wxString::Format( _( "'%s' is a reserved variant name." ),
3302 10000, wxICON_ERROR );
3303 return false;
3304 }
3305
3306 for( const wxString& existingName : Schematic().GetVariantNames() )
3307 {
3308 if( existingName.CmpNoCase( aName ) == 0 && existingName.CmpNoCase( aExcludeName ) != 0 )
3309 {
3310 GetInfoBar()->ShowMessageFor( wxString::Format( _( "Variant '%s' already exists." ), existingName ),
3311 10000, wxICON_ERROR );
3312 return false;
3313 }
3314 }
3315
3316 return true;
3317}
3318
3319
3321{
3322 wxArrayString choices = Schematic().GetVariantNamesForUI();
3323
3324 // Default variant cannot be renamed.
3325 choices.RemoveAt( 0 );
3326
3327 if( choices.IsEmpty() )
3328 {
3329 GetInfoBar()->ShowMessageFor( _( "No variants to rename." ), 10000, wxICON_INFORMATION );
3330 return;
3331 }
3332
3333 wxSingleChoiceDialog selDlg( this,
3334 _( "Select variant to rename:" ) + wxS( " " ),
3335 _( "Rename Design Variant" ), choices );
3336 selDlg.Layout();
3337
3338 if( selDlg.ShowModal() == wxID_CANCEL )
3339 return;
3340
3341 wxString oldName = selDlg.GetStringSelection();
3342
3343 if( oldName.IsEmpty() )
3344 return;
3345
3346 wxTextEntryDialog nameDlg( this, _( "Enter new variant name:" ),
3347 _( "Rename Design Variant" ), oldName,
3348 wxOK | wxCANCEL | wxCENTER );
3349
3350 if( nameDlg.ShowModal() == wxID_CANCEL )
3351 return;
3352
3353 wxString newName = nameDlg.GetValue().Trim().Trim( false );
3354
3355 if( newName == oldName )
3356 return;
3357
3358 if( !validateNewVariantName( newName, oldName ) )
3359 return;
3360
3361 // The model retargets the current variant to the new name, so capture whether the toolbar was
3362 // showing the variant being renamed before the rename runs.
3363 bool wasCurrent = Schematic().GetCurrentVariant() == oldName;
3364
3365 SCH_COMMIT commit( this );
3366 Schematic().RenameVariant( oldName, newName, &commit );
3367
3368 if( !commit.Empty() )
3369 commit.Push( wxString::Format( _( "Rename variant '%s' to '%s'" ), oldName, newName ) );
3370
3371 // The registry entry changes even when no symbol carries an override, so always mark dirty.
3372 OnModify();
3373
3374 UpdateVariantSelectionCtrl( Schematic().GetVariantNamesForUI() );
3375
3376 // The renamed label just disappeared from the control, so a plain repopulate falls back to the
3377 // default selection. Re-selecting the new name resyncs the toolbar and (via SetCurrentVariant)
3378 // repaints ${VARIANT} text; a non-current rename needs no redraw.
3379 if( wasCurrent )
3380 SetCurrentVariant( newName );
3381}
3382
3383
3385{
3386 wxArrayString choices = Schematic().GetVariantNamesForUI();
3387
3388 // Default variant cannot be copied.
3389 choices.RemoveAt( 0 );
3390
3391 if( choices.IsEmpty() )
3392 {
3393 GetInfoBar()->ShowMessageFor( _( "No variants to copy." ), 10000, wxICON_INFORMATION );
3394 return;
3395 }
3396
3397 wxSingleChoiceDialog selDlg( this,
3398 _( "Select variant to copy:" ) + wxS( " " ),
3399 _( "Copy Design Variant" ), choices );
3400 selDlg.Layout();
3401
3402 if( selDlg.ShowModal() == wxID_CANCEL )
3403 return;
3404
3405 wxString sourceName = selDlg.GetStringSelection();
3406
3407 if( sourceName.IsEmpty() )
3408 return;
3409
3410 wxTextEntryDialog nameDlg( this, _( "Enter name for the copied variant:" ),
3411 _( "Copy Design Variant" ),
3412 sourceName + wxS( "_copy" ),
3413 wxOK | wxCANCEL | wxCENTER );
3414
3415 if( nameDlg.ShowModal() == wxID_CANCEL )
3416 return;
3417
3418 wxString newName = nameDlg.GetValue().Trim().Trim( false );
3419
3420 if( !validateNewVariantName( newName, wxEmptyString ) )
3421 return;
3422
3423 SCH_COMMIT commit( this );
3424 Schematic().CopyVariant( sourceName, newName, &commit );
3425
3426 if( !commit.Empty() )
3427 commit.Push( wxString::Format( _( "Copy variant '%s' to '%s'" ), sourceName, newName ) );
3428
3429 // The new registry entry changes project state even when no symbol carries an override.
3430 OnModify();
3431
3432 UpdateVariantSelectionCtrl( Schematic().GetVariantNamesForUI() );
3433
3434 // Switching to the freshly-created variant already refreshes properties and redraws.
3435 SetCurrentVariant( newName );
3436}
3437
3438
3440{
3441 // Delegate to base auto-save behavior (commits pending local history) for now.
3443}
3444
3445
3447{
3449
3450 if( !mgr )
3451 return false;
3452
3453 TOOL_BASE* currentTool = mgr->GetCurrentTool();
3454 SCH_POINT_EDITOR* pointEditor = mgr->GetTool<SCH_POINT_EDITOR>();
3455
3456 // The point editor is the active tool whenever a point-editable item is selected, even while
3457 // idle, so it is safe to snapshot unless a drag is actively mutating the model.
3458 if( currentTool == pointEditor )
3459 return pointEditor && pointEditor->IsDragging();
3460
3461 return currentTool != mgr->GetTool<SCH_SELECTION_TOOL>();
3462}
3463
3464
3466{
3468 return false;
3469
3471}
3472
3473
3475{
3476 // Serializing the schematic on the UI thread freezes the editor; defer it while the user
3477 // is mid-operation (any tool other than passive selection or point editing is active) so
3478 // the snapshot waits for the timer to retry once the edit finishes.
3480}
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:927
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:653
bool Empty() const
Definition commit.h:142
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.
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 bool CanAcceptApiCommands()
Check if this frame is ready to accept API commands.
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 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 StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
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:98
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition() but allows items to return their visual center rather than their anchor.
Definition eda_item.h:355
const KIID m_Uuid
Definition eda_item.h:597
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
void ClearBrightened()
Definition eda_item.h:154
void SetBrightened()
Definition eda_item.h:151
bool IsBrightened() const
Definition eda_item.h:136
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:94
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:118
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
Tool responsible for drawing graphical shapes (rectangles, circles, arcs, beziers,...
bool empty() const
Definition sch_rtree.h:182
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:248
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.
void RegisterHandler(API_HANDLER *aHandler)
Adds a new request handler to the server.
void DeregisterHandler(API_HANDLER *aHandler)
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:66
void SetSchematic(SCHEMATIC *aSchematic)
Definition sch_painter.h:76
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:133
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
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition view.cpp:301
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition view.cpp:416
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:681
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:1719
wxString AsString() const
Definition kiid.cpp:423
Definition kiid.h:46
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:340
void OnKiCadExit()
Definition kiway.cpp:790
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:388
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:486
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:347
LOCAL_HISTORY & LocalHistory()
Return the LOCAL_HISTORY associated with this KIWAY.
Definition kiway.h:451
Define a library symbol object.
Definition lib_symbol.h:119
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 NoteFileChange(const wxString &aFile)
Record that a file has been modified and should be included in the next snapshot.
void RegisterSaver(const void *aSaverObject, const std::function< void(const wxString &, std::vector< HISTORY_FILE_DATA > &)> &aSaver, const std::weak_ptr< void > &aLifetime={})
Register a saver callback invoked during autosave history commits.
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:267
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:892
KICAD_API_SERVER & GetApiServer()
Definition pgm_base.h:141
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:148
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition schematic.h:308
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.
void CopyVariant(const wxString &aSourceVariant, const wxString &aNewVariant, SCH_COMMIT *aCommit=nullptr)
Copy a variant from aSourceVariant to aNewVariant.
SCHEMATIC_SETTINGS & Settings() const
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Definition schematic.h:193
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
void RenameVariant(const wxString &aOldName, const wxString &aNewName, SCH_COMMIT *aCommit=nullptr)
Rename a variant from aOldName to aNewName.
void SetProject(PROJECT *aPrj)
wxString GetCurrentVariant() const
Return the current variant being edited.
void CleanUpConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, const std::set< SCH_SCREEN * > &aLocalScreens={})
Prepare source geometry and intersheet references before rebuilding connectivity.
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.
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, bool aCleanupDone=false)
Generate the connection data for the entire schematic hierarchy.
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.
ERC_SETTINGS & ErcSettings() const
Gather all the actions that are shared by tools.
Definition sch_actions.h:45
static TOOL_ACTION rotateCCW
static TOOL_ACTION placeClassLabel
Definition sch_actions.h:84
static TOOL_ACTION placeSheetPin
Definition sch_actions.h:90
static TOOL_ACTION saveSheetAsDesignBlock
static TOOL_ACTION mirrorV
static TOOL_ACTION drawSheetFromFile
Definition sch_actions.h:88
static TOOL_ACTION toggleOPCurrents
static TOOL_ACTION saveToLinkedDesignBlock
Definition sch_actions.h:76
static TOOL_ACTION saveSelectionAsDesignBlock
static TOOL_ACTION placeGlobalLabel
Definition sch_actions.h:85
static TOOL_ACTION drawEllipseArc
static TOOL_ACTION drawTextBox
Definition sch_actions.h:98
static TOOL_ACTION toggleAnnotateAuto
static TOOL_ACTION ddAddImage
static TOOL_ACTION drawArc
static TOOL_ACTION drawSheet
Definition sch_actions.h:87
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
static TOOL_ACTION drawLines
static TOOL_ACTION placeHierLabel
Definition sch_actions.h:86
static TOOL_ACTION alignTop
static TOOL_ACTION alignRight
static TOOL_ACTION drawEllipse
static TOOL_ACTION placeLabel
Definition sch_actions.h:83
static TOOL_ACTION drawCircle
static TOOL_ACTION placeBusWireEntry
Definition sch_actions.h:82
static TOOL_ACTION showRemoteSymbolPanel
static TOOL_ACTION drawBezier
static TOOL_ACTION drawWire
Definition sch_actions.h:77
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:81
static TOOL_ACTION markSimExclusions
static TOOL_ACTION drawRuleArea
static TOOL_ACTION placeSymbol
Definition sch_actions.h:71
static TOOL_ACTION placeImage
static TOOL_ACTION alignLeft
static TOOL_ACTION toggleERCErrors
static TOOL_ACTION alignCenterX
static TOOL_ACTION angleSnapModeChanged
static TOOL_ACTION placeLinkedDesignBlock
Definition sch_actions.h:75
static TOOL_ACTION drawSheetFromDesignBlock
Definition sch_actions.h:89
static TOOL_ACTION mirrorH
static TOOL_ACTION placeDesignBlock
Definition sch_actions.h:74
static TOOL_ACTION toggleOPVoltages
static TOOL_ACTION drawBus
Definition sch_actions.h:78
static TOOL_ACTION drawTable
Definition sch_actions.h:99
static TOOL_ACTION ddAppendFile
static TOOL_ACTION placeSchematicText
Definition sch_actions.h:97
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:80
static TOOL_ACTION toggleHiddenPins
static TOOL_ACTION syncSheetPins
Definition sch_actions.h:94
static TOOL_ACTION placePower
Definition sch_actions.h:73
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 interactiveOperationInProgress() const
Return true when a tool other than passive selection or an idle point editor is active.
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.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr, bool aCleanupDone=false)
Generate the connection data for the entire schematic hierarchy.
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...
bool SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
Update a schematic symbol from a LIB_SYMBOL.
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
std::unique_ptr< API_HANDLER_SCH > m_apiHandler
DIALOG_BOOK_REPORTER * m_diffSymbolDialog
void ToggleLibraryTree() override
void RefreshConnectivity(bool aForce=false)
Refresh connectivity-dependent display state after a model rebuild.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxWindow * createHighlightedNetNavigator()
void onCloseErcDialog(wxCommandEvent &aEvent)
bool validateNewVariantName(const wxString &aName, const wxString &aExcludeName)
Validate a user-entered variant name for the rename/copy dialogs.
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 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.
bool canRunAutoSave() const override
Return true when it is safe to run an autosave snapshot right now.
BITMAP_BUTTON * m_netNavigatorMenuButton
std::unique_ptr< API_HANDLER_COMMON > m_apiHandlerCommon
bool ReadyToNetlist(const wxString &aAnnotateMessage, bool *aUserCancelled=nullptr)
Check if we are ready to write a netlist file for the current schematic.
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.
bool CanAcceptApiCommands() override
Check if this frame is ready to accept API commands.
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
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 PrepareForNetlist()
Commit source cleanup before the exporter's full connectivity rebuild.
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
std::unique_ptr< API_HANDLER_LIBRARIES > m_apiLibrariesHandler
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 SetHighlightedConnection(const wxString &aConnection, const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr, bool aForceNetNavigatorRefresh=false)
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 onPluginAvailabilityChanged(wxCommandEvent &aEvt)
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:165
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:170
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition sch_item.h:641
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:503
bool ResolveExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:311
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:39
void SetOperatingPoint(const wxString &aText)
Definition sch_line.h:372
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:340
const wxString & GetOperatingPoint() const
Definition sch_line.h:371
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:403
Tool that displays edit points allowing to modify items by dragging the points.
bool IsDragging() const
Return true while a point is actively being dragged (the model is mid-mutation between grab and relea...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:758
void DeleteAllMarkers(enum MARKER_BASE::MARKER_T aMarkerType, bool aIncludeExclusions)
Delete all electronic rules check markers of aMarkerType from all the screens in the list.
const PAGE_INFO & GetPageSettings() const
Definition sch_screen.h:140
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:503
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition sch_screen.h:685
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:118
const wxString & GetFileName() const
Definition sch_screen.h:153
bool IsReadOnly() const
Definition sch_screen.h:156
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
bool m_zoomInitialized
Definition sch_screen.h:710
bool FileExists() const
Definition sch_screen.h:159
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:142
Schematic symbol object.
Definition sch_symbol.h:75
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:183
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
VECTOR2I GetPosition() const override
Definition sch_text.h:143
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, std::span< const wxString > aPins, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
Definition sim_lib_mgr.h:45
Symbol library viewer main window.
The symbol library editor main window.
Symbol library viewer main window.
TOOL_MANAGER * m_toolManager
TOOL_DISPATCHER * m_toolDispatcher
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
ACTIONS * m_actions
Base abstract interface for all kinds of tools.
Definition tool_base.h:62
@ 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.
TOOL_BASE * GetCurrentTool() const
Return the tool that is on the top of the active tools stack (was invoked the most recently).
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:848
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, wxCommandEvent)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define SCH_EDIT_FRAME_NAME
@ NO_RECURSE
Definition eda_item.h:52
#define IGNORE_PARENT_GROUP
Definition eda_item.h:55
@ 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:161
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:33
@ ID_ON_GRID_SELECT
Definition id.h:113
@ ID_FILE_LIST_CLEAR
Definition id.h:58
@ ID_EDA_SOCKET_EVENT
Definition id.h:133
@ ID_EDA_SOCKET_EVENT_SERV
Definition id.h:132
@ ID_ON_ZOOM_SELECT
Definition id.h:112
@ ID_FILEMAX
Definition id.h:56
@ ID_FILE1
Definition id.h:55
PROJECT & Prj()
Definition kicad.cpp:727
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.
#define KICTL_KICAD_ONLY
chosen file is from KiCad according to user
@ LAYER_ERC_WARN
Definition layer_ids.h:501
@ LAYER_ERC_EXCLUSION
Definition layer_ids.h:503
@ LAYER_ERC_ERR
Definition layer_ids.h:502
@ LAYER_OP_CURRENTS
Definition layer_ids.h:524
@ LAYER_INTERSHEET_REFS
Definition layer_ids.h:485
@ LAYER_OP_VOLTAGES
Definition layer_ids.h:523
@ MAIL_PCB_UPDATE
Definition mail_type.h:42
@ MAIL_SCH_SHEET_CHANGED
Definition mail_type.h:57
@ 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:521
#define _HKI(x)
Definition page_info.cpp:40
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
SEVERITY
#define SKIP_CONNECTIVITY
Definition sch_commit.h:41
#define DIFF_SYMBOLS_DIALOG_NAME
#define CURRENT_TOOL(action)
@ AUTOPLACE_AUTO
Definition sch_item.h:70
SCH_CLEANUP_FLAGS
Definition schematic.h:91
@ GLOBAL_CLEANUP
Definition schematic.h:94
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
wxString GetDefaultVariantName()
wxString UnescapeString(const wxString &aSource)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Implement a participant in the KIWAY alchemy.
Definition kiway.h:153
virtual void PreloadLibraries(KIWAY *aKiway)
Definition kiway.h:290
std::string refName
std::string path
KIBIS_MODEL * model
KIBIS_PIN * pin
wxLogTrace helper definitions.
@ SCH_GROUP_T
Definition typeinfo.h:169
@ SCH_LINE_T
Definition typeinfo.h:159
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_MARKER_T
Definition typeinfo.h:154
@ SCH_HIER_LABEL_T
Definition typeinfo.h:165
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:164
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.