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