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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <algorithm>
26#include <api/api_handler_sch.h>
27#include <api/api_server.h>
28#include <base_units.h>
29#include <bitmaps.h>
30#include <confirm.h>
31#include <connection_graph.h>
32#include <dialogs/dialog_erc.h>
36#include <wx/srchctrl.h>
37#include <mail_type.h>
38#include <wx/clntdata.h>
39#include <wx/panel.h>
40#include <wx/sizer.h>
41#include <wx/menu.h>
42#include <eeschema_id.h>
43#include <executable_names.h>
46#include <gestfich.h>
48#include <string_utils.h>
49#include <kiface_base.h>
50#include <kiplatform/app.h>
51#include <kiway.h>
52#include <symbol_edit_frame.h>
53#include <symbol_viewer_frame.h>
54#include <pgm_base.h>
55#include <core/profile.h>
58#include <python_scripting.h>
59#include <sch_edit_frame.h>
61#include <sch_painter.h>
62#include <sch_marker.h>
63#include <sch_sheet_pin.h>
64#include <sch_commit.h>
65#include <sch_rule_area.h>
67#include <advanced_config.h>
68#include <sim/simulator_frame.h>
69#include <tool/action_manager.h>
70#include <tool/action_toolbar.h>
71#include <tool/common_control.h>
72#include <tool/common_tools.h>
73#include <tool/embed_tool.h>
74#include <tool/picker_tool.h>
76#include <tool/selection.h>
78#include <tool/tool_manager.h>
79#include <tool/zoom_tool.h>
80#include <tools/sch_actions.h>
87#include <tools/sch_edit_tool.h>
93#include <tools/sch_move_tool.h>
96#include <trace_helpers.h>
97#include <unordered_set>
98#include <view/view_controls.h>
99#include <widgets/wx_infobar.h>
105#include <wx/cmdline.h>
106#include <wx/app.h>
107#include <wx/filedlg.h>
108#include <wx/socket.h>
109#include <wx/debug.h>
111#include <widgets/wx_aui_utils.h>
114#include <toolbars_sch_editor.h>
115#include <wx/log.h>
116
117#ifdef KICAD_IPC_API
119#include <api/api_utils.h>
120#endif
121
123
124
125#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
126
127
128BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
131
132 EVT_SIZE( SCH_EDIT_FRAME::OnSize )
133
136
138
139 EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
140 EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
141
142 // Drop files event
143 EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
144END_EVENT_TABLE()
145
146
147wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
148wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
149
150
151SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
152 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
154 m_ercDialog( nullptr ),
155 m_diffSymbolDialog( nullptr ),
156 m_symbolFieldsTableDialog( nullptr ),
157 m_netNavigator( nullptr ),
158 m_netNavigatorFilter( nullptr ),
162 m_designBlocksPane( nullptr )
163{
164 m_maximizeByDefault = true;
165 m_schematic = new SCHEMATIC( &Prj() );
166 m_schematic->SetSchematicHolder( this );
168
169 m_showBorderAndTitleBlock = true; // true to show sheet references
170 m_supportsAutoSave = true;
172 m_aboutTitle = _HKI( "KiCad Schematic Editor" );
173 m_show_search = false;
174 // Ensure timer has an owner before binding so it generates events.
175 m_crossProbeFlashTimer.SetOwner( this );
176 Bind( wxEVT_TIMER, &SCH_EDIT_FRAME::OnCrossProbeFlashTimer, this, m_crossProbeFlashTimer.GetId() );
177
178 // Give an icon
179 wxIcon icon;
180 wxIconBundle icon_bundle;
181
182 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 48 ) );
183 icon_bundle.AddIcon( icon );
184 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 128 ) );
185 icon_bundle.AddIcon( icon );
186 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 256 ) );
187 icon_bundle.AddIcon( icon );
188 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
189 icon_bundle.AddIcon( icon );
190 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
191 icon_bundle.AddIcon( icon );
192
193 SetIcons( icon_bundle );
194
196
197 setupTools();
200
204
205 // Ensure the "Line modes" toolbar group shows the current angle mode on startup
206 if( GetToolManager() )
208
209#ifdef KICAD_IPC_API
210 wxTheApp->Bind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED, &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
211#endif
212
213 m_hierarchy = new HIERARCHY_PANE( this );
214
215 // Initialize common print setup dialog settings.
216 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
217 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
218 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
219 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
220
221 m_searchPane = new SCH_SEARCH_PANE( this );
222 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
223
224 m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
225
228
229 m_auimgr.SetManagedWindow( this );
230
232
233 // Fetch a COPY of the config as a lot of these initializations are going to overwrite our
234 // data.
235 EESCHEMA_SETTINGS::AUI_PANELS aui_cfg = eeconfig()->m_AuiPanels;
236 EESCHEMA_SETTINGS::APPEARANCE appearance_cfg = eeconfig()->m_Appearance;
237
238 // Rows; layers 4 - 6
239 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( wxS( "TopMainToolbar" ) )
240 .Top().Layer( 6 ) );
241
242 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
243 .Bottom().Layer( 6 ) );
244
245 // Columns; layers 1 - 3
246 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
247 .Caption( _( "Schematic Hierarchy" ) )
248 .Left().Layer( 3 ).Position( 1 )
249 .TopDockable( false )
250 .BottomDockable( false )
251 .CloseButton( true )
252 .MinSize( FromDIP( wxSize( 120, 60 ) ) )
253 .BestSize( FromDIP( wxSize( 200, 200 ) ) )
254 .FloatingSize( FromDIP( wxSize( 200, 200 ) ) )
255 .FloatingPosition( FromDIP( wxPoint( 50, 50 ) ) )
256 .Show( false ) );
257
260
262
264
265 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( wxS( "LeftToolbar" ) )
266 .Left().Layer( 2 ) );
267
268 m_auimgr.AddPane( m_tbRight, EDA_PANE().VToolbar().Name( wxS( "RightToolbar" ) )
269 .Right().Layer( 2 ) );
270
271 // Center
272 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
273 .Center() );
274
275 m_auimgr.AddPane( m_searchPane, EDA_PANE()
276 .Name( SearchPaneName() )
277 .Bottom()
278 .Caption( _( "Search" ) )
279 .PaneBorder( false )
280 .MinSize( FromDIP( wxSize( 180, 60 ) ) )
281 .BestSize( FromDIP( wxSize( 180, 100 ) ) )
282 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
283 .CloseButton( true )
284 .DestroyOnClose( false )
285 .Show( m_show_search ) );
286
289
290 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
291 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
292 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
293 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
294 wxAuiPaneInfo& designBlocksPane = m_auimgr.GetPane( DesignBlocksPaneName() );
295
296 hierarchy_pane.Show( aui_cfg.show_schematic_hierarchy );
297 netNavigatorPane.Show( aui_cfg.show_net_nav_panel );
298 propertiesPane.Show( aui_cfg.show_properties );
299 designBlocksPane.Show( aui_cfg.design_blocks_show );
301
302 // The selection filter doesn't need to grow in the vertical direction when docked
303 selectionFilterPane.dock_proportion = 0;
304
305 if( aui_cfg.hierarchy_panel_float_width > 0 && aui_cfg.hierarchy_panel_float_height > 0 )
306 {
307 // Show at end, after positioning
308 hierarchy_pane.FloatingSize( aui_cfg.hierarchy_panel_float_width,
310 }
311
312 if( aui_cfg.net_nav_panel_float_size.GetWidth() > 0
313 && aui_cfg.net_nav_panel_float_size.GetHeight() > 0 )
314 {
315 netNavigatorPane.FloatingSize( aui_cfg.net_nav_panel_float_size );
316 netNavigatorPane.FloatingPosition( aui_cfg.net_nav_panel_float_pos );
317 }
318
319 if( aui_cfg.properties_panel_width > 0 )
320 SetAuiPaneSize( m_auimgr, propertiesPane, aui_cfg.properties_panel_width, -1 );
321
322 if( aui_cfg.schematic_hierarchy_float )
323 hierarchy_pane.Float();
324
325 if( aui_cfg.search_panel_height > 0
326 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_TOP
327 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
328 {
329 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
330 searchPane.Direction( aui_cfg.search_panel_dock_direction );
331 SetAuiPaneSize( m_auimgr, searchPane, -1, aui_cfg.search_panel_height );
332 }
333
334 else if( aui_cfg.search_panel_width > 0
335 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_LEFT
336 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
337 {
338 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
339 searchPane.Direction( aui_cfg.search_panel_dock_direction );
340 SetAuiPaneSize( m_auimgr, searchPane, aui_cfg.search_panel_width, -1 );
341 }
342
343 if( aui_cfg.float_net_nav_panel )
344 netNavigatorPane.Float();
345
346 if( aui_cfg.design_blocks_show )
347 SetAuiPaneSize( m_auimgr, designBlocksPane, aui_cfg.design_blocks_panel_docked_width, -1 );
348
349 if( aui_cfg.hierarchy_panel_docked_width > 0 )
350 {
351 // If the net navigator is not show, let the hierarchy navigator take all of the vertical
352 // space.
353 if( !aui_cfg.show_net_nav_panel )
354 {
355 SetAuiPaneSize( m_auimgr, hierarchy_pane, aui_cfg.hierarchy_panel_docked_width, -1 );
356 }
357 else
358 {
359 SetAuiPaneSize( m_auimgr, hierarchy_pane,
362
363 SetAuiPaneSize( m_auimgr, netNavigatorPane,
364 aui_cfg.net_nav_panel_docked_size.GetWidth(),
365 aui_cfg.net_nav_panel_docked_size.GetHeight() );
366 }
367
368 // wxAUI hack: force width by setting MinSize() and then Fixed()
369 // thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
370 hierarchy_pane.MinSize( aui_cfg.hierarchy_panel_docked_width, 60 );
371 hierarchy_pane.Fixed();
372 netNavigatorPane.MinSize( aui_cfg.net_nav_panel_docked_size.GetWidth(), 60 );
373 netNavigatorPane.Fixed();
374 m_auimgr.Update();
375
376 // now make it resizable again
377 hierarchy_pane.Resizable();
378 netNavigatorPane.Resizable();
379 m_auimgr.Update();
380
381 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
382 // back to minimum.
383 hierarchy_pane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
384 netNavigatorPane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
385 }
386 else
387 {
388 m_auimgr.Update();
389 }
390
393
394 GetCanvas()->GetGAL()->SetAxesEnabled( false );
395
396 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
397 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
398
401
402 view->SetLayerVisible( LAYER_ERC_ERR, appearance_cfg.show_erc_errors );
403 view->SetLayerVisible( LAYER_ERC_WARN, appearance_cfg.show_erc_warnings );
405 view->SetLayerVisible( LAYER_OP_VOLTAGES, appearance_cfg.show_op_voltages );
406 view->SetLayerVisible( LAYER_OP_CURRENTS, appearance_cfg.show_op_currents );
407
409
411 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging, this );
412 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
413 m_netNavigator->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onResizeNetNavigator, this );
414
415 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
416 // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
417 Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
418
419 setupUnits( eeconfig() );
420
421 // Net list generator
423
424 updateTitle();
425 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
426
427#ifdef KICAD_IPC_API
428 m_apiHandler = std::make_unique<API_HANDLER_SCH>( this );
429 Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
430#endif
431
432 // Default shutdown reason until a file is loaded
433 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
434
435 // Init for dropping files
439 m_acceptedExts.emplace( wxS( "jpeg" ), &SCH_ACTIONS::ddAddImage );
440 m_acceptedExts.emplace( wxS( "dxf" ), &SCH_ACTIONS::ddImportGraphics );
442 DragAcceptFiles( true );
443
444 // Ensure the window is on top
445 Raise();
446
447 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
448 // top-left corner of the canvas
449 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
450 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
451
452 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
453 Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
454 Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog, this );
455}
456
457void SCH_EDIT_FRAME::StartCrossProbeFlash( const std::vector<SCH_ITEM*>& aItems )
458{
459 if( !eeconfig()->m_CrossProbing.flash_selection )
460 {
461 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: aborted (setting disabled) items=%zu", aItems.size() );
462 return;
463 }
464 if( aItems.empty() )
465 {
466 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: aborted (no items)" );
467 return;
468 }
469
471 {
472 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: restarting existing flash (phase=%d)", m_crossProbeFlashPhase );
474 }
475
476 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: starting with %zu items", aItems.size() );
478 for( SCH_ITEM* it : aItems )
479 m_crossProbeFlashItems.push_back( it->m_Uuid );
480
483 if( !m_crossProbeFlashTimer.GetOwner() )
484 m_crossProbeFlashTimer.SetOwner( this );
485
486 bool started = m_crossProbeFlashTimer.Start( 500, wxTIMER_CONTINUOUS );
487 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash: timer start=%d id=%d", (int) started, m_crossProbeFlashTimer.GetId() );
488}
489
490
491void SCH_EDIT_FRAME::OnCrossProbeFlashTimer( wxTimerEvent& aEvent )
492{
493 wxLogTrace( traceCrossProbeFlash, "Timer(SCH) fired: phase=%d running=%d items=%zu", m_crossProbeFlashPhase, (int) m_crossProbeFlashing, m_crossProbeFlashItems.size() );
494
496 {
497 wxLogTrace( traceCrossProbeFlash, "Timer fired but not flashing (ignored)" );
498 return;
499 }
500
502 if( !selTool )
503 return;
504
505 bool prevGuard = m_syncingPcbToSchSelection;
507
508 if( m_crossProbeFlashPhase % 2 == 0 )
509 {
510 selTool->ClearSelection( true );
511 wxLogTrace( traceCrossProbeFlash, "Phase %d: cleared selection", m_crossProbeFlashPhase );
512 }
513 else
514 {
515 for( const KIID& id : m_crossProbeFlashItems )
516 {
517 if( SCH_ITEM* item = Schematic().ResolveItem( id, nullptr, true ) )
518 selTool->AddItemToSel( item, true );
519 }
520 wxLogTrace( traceCrossProbeFlash, "Phase %d: restored %zu items", m_crossProbeFlashPhase, m_crossProbeFlashItems.size() );
521 }
522
523 if( GetCanvas() )
524 {
526 wxLogTrace( traceCrossProbeFlash, "Phase %d: forced canvas refresh", m_crossProbeFlashPhase );
527 }
528
529 m_syncingPcbToSchSelection = prevGuard;
531
532 if( m_crossProbeFlashPhase > 6 )
533 {
534 for( const KIID& id : m_crossProbeFlashItems )
535 {
536 if( SCH_ITEM* item = Schematic().ResolveItem( id, nullptr, true ) )
537 selTool->AddItemToSel( item, true );
538 }
539
540 m_crossProbeFlashing = false;
542 wxLogTrace( traceCrossProbeFlash, "Flashing complete. Final selection size=%zu", m_crossProbeFlashItems.size() );
543 }
544}
545
546
548{
549 m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
550
551 // Ensure m_canvasType is up to date, to save it in config
553
554 SetScreen( nullptr );
555
556 if( m_schematic )
557 m_schematic->RemoveAllListeners();
558
559 // Delete all items not in draw list before deleting schematic
560 // to avoid dangling pointers stored in these items
563
564 delete m_schematic;
565 m_schematic = nullptr;
566
567 // Close the project if we are standalone, so it gets cleaned up properly
568 if( Kiface().IsSingle() )
569 {
570 try
571 {
572 GetSettingsManager()->UnloadProject( &Prj(), false );
573 }
574 catch( const nlohmann::detail::type_error& e )
575 {
576 wxFAIL_MSG( wxString::Format( wxT( "Settings exception occurred: %s" ), e.what() ) );
577 }
578 }
579
580 // We passed ownership of these to wxAuiManager.
581 // delete m_hierarchy;
582 // delete m_selectionFilterPanel;
583}
584
585
587{
588 aEvent.Skip();
589
590 // 1st Call: Handle the size update during the first resize event.
592
593 // Defer the second size capture
594 CallAfter( [this]()
595 {
597 } );
598}
599
600
602{
603 // Called when resizing the Hierarchy Navigator panel
604 // Store the current pane size
605 // It allows to retrieve the last defined pane size when switching between
606 // docked and floating pane state
607 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
608
609 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
610 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
611
612 if( cfg && m_hierarchy->IsShownOnScreen() )
613 {
614 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
615 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
616
617 // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
618 // width is > 0 (i.e. if its size is already set and has meaning)
619 // if it is floating, its size is not initialized (only floating_size is initialized)
620 // initializing hierarchy_pane.best_size is useful when switching to float pane and
621 // after switching to the docked pane, to retrieve the last docked pane width
622 if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
623 {
624 cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
625 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
626 }
627 }
628}
629
630
632{
633 // Create the manager and dispatcher & route draw panel events to the dispatcher
635 m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
636 GetCanvas()->GetViewControls(), config(), this );
637 m_actions = new SCH_ACTIONS();
639
640 // Register tools
641 m_toolManager->RegisterTool( new COMMON_CONTROL );
642 m_toolManager->RegisterTool( new COMMON_TOOLS );
643 m_toolManager->RegisterTool( new ZOOM_TOOL );
644 m_toolManager->RegisterTool( new SCH_SELECTION_TOOL );
645 m_toolManager->RegisterTool( new PICKER_TOOL );
646 m_toolManager->RegisterTool( new SCH_DRAWING_TOOLS );
647 m_toolManager->RegisterTool( new SCH_LINE_WIRE_BUS_TOOL );
648 m_toolManager->RegisterTool( new SCH_MOVE_TOOL );
649 m_toolManager->RegisterTool( new SCH_ALIGN_TOOL );
650 m_toolManager->RegisterTool( new SCH_EDIT_TOOL );
651 m_toolManager->RegisterTool( new SCH_EDIT_TABLE_TOOL );
652 m_toolManager->RegisterTool( new SCH_GROUP_TOOL );
653 m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL );
654 m_toolManager->RegisterTool( new SCH_DESIGN_BLOCK_CONTROL );
655 m_toolManager->RegisterTool( new SCH_EDITOR_CONTROL );
656 m_toolManager->RegisterTool( new SCH_FIND_REPLACE_TOOL );
657 m_toolManager->RegisterTool( new SCH_POINT_EDITOR );
658 m_toolManager->RegisterTool( new SCH_NAVIGATE_TOOL );
659 m_toolManager->RegisterTool( new PROPERTIES_TOOL );
660 m_toolManager->RegisterTool( new EMBED_TOOL );
661 m_toolManager->InitTools();
662
663 // Run the selection tool, it is supposed to be always active
665
667}
668
669
671{
673
674 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
675 SCH_EDITOR_CONDITIONS cond( this );
676
677 wxASSERT( mgr );
678
679 auto hasElements =
680 [ this ] ( const SELECTION& aSel )
681 {
682 return GetScreen() &&
683 ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
684 };
685
686 auto searchPaneCond =
687 [this] ( const SELECTION& )
688 {
689 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
690 };
691
692 auto propertiesCond =
693 [this] ( const SELECTION& )
694 {
695 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
696 };
697
698 auto hierarchyNavigatorCond =
699 [ this ] ( const SELECTION& aSel )
700 {
701 return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
702 };
703
704 auto netNavigatorCond =
705 [ this ] (const SELECTION& aSel )
706 {
707 return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
708 };
709
710 auto designBlockCond =
711 [ this ] (const SELECTION& aSel )
712 {
713 return m_auimgr.GetPane( DesignBlocksPaneName() ).IsShown();
714 };
715
716 auto undoCond =
717 [ this ] (const SELECTION& aSel )
718 {
720 return true;
721
722 return GetUndoCommandCount() > 0;
723 };
724
725 auto groupWithDesignBlockLink =
726 [] ( const SELECTION& aSel )
727 {
728 if( aSel.Size() != 1 )
729 return false;
730
731 if( aSel[0]->Type() != SCH_GROUP_T )
732 return false;
733
734 SCH_GROUP* group = static_cast<SCH_GROUP*>( aSel.GetItem( 0 ) );
735
736 return group->HasDesignBlockLink();
737 };
738
739#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
740#define CHECK( x ) ACTION_CONDITIONS().Check( x )
741
743 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
745
746 mgr->SetConditions( SCH_ACTIONS::showSearch, CHECK( searchPaneCond ) );
747 mgr->SetConditions( SCH_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
748 mgr->SetConditions( SCH_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
749 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
750 mgr->SetConditions( SCH_ACTIONS::showDesignBlockPanel, CHECK( designBlockCond ) );
753
754 mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
755 mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
756 mgr->SetConditions( ACTIONS::copyAsText, ENABLE( hasElements ) );
759 mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
760 mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
767 mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
768 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
769
770 mgr->SetConditions( SCH_ACTIONS::rotateCW, ENABLE( hasElements ) );
771 mgr->SetConditions( SCH_ACTIONS::rotateCCW, ENABLE( hasElements ) );
772 mgr->SetConditions( SCH_ACTIONS::mirrorH, ENABLE( hasElements ) );
773 mgr->SetConditions( SCH_ACTIONS::mirrorV, ENABLE( hasElements ) );
776
777 mgr->SetConditions( SCH_ACTIONS::placeLinkedDesignBlock, ENABLE( groupWithDesignBlockLink ) );
778 mgr->SetConditions( SCH_ACTIONS::saveToLinkedDesignBlock, ENABLE( groupWithDesignBlockLink ) );
779
782
783 auto showHiddenPinsCond =
784 [this]( const SELECTION& )
785 {
786 return GetShowAllPins();
787 };
788
789 auto showHiddenFieldsCond =
790 [this]( const SELECTION& )
791 {
793 return cfg && cfg->m_Appearance.show_hidden_fields;
794 };
795
796 auto showDirectiveLabelsCond =
797 [this]( const SELECTION& )
798 {
800 return cfg && cfg->m_Appearance.show_directive_labels;
801 };
802
803 auto showERCErrorsCond =
804 [this]( const SELECTION& )
805 {
807 return cfg && cfg->m_Appearance.show_erc_errors;
808 };
809
810 auto showERCWarningsCond =
811 [this]( const SELECTION& )
812 {
814 return cfg && cfg->m_Appearance.show_erc_warnings;
815 };
816
817 auto showERCExclusionsCond =
818 [this]( const SELECTION& )
819 {
821 return cfg && cfg->m_Appearance.show_erc_exclusions;
822 };
823
824 auto markSimExclusionsCond =
825 [this]( const SELECTION& )
826 {
828 return cfg && cfg->m_Appearance.mark_sim_exclusions;
829 };
830
831 auto showOPVoltagesCond =
832 [this]( const SELECTION& )
833 {
835 return cfg && cfg->m_Appearance.show_op_voltages;
836 };
837
838 auto showOPCurrentsCond =
839 [this]( const SELECTION& )
840 {
842 return cfg && cfg->m_Appearance.show_op_currents;
843 };
844
845 auto showPinAltModeIconsCond =
846 [this]( const SELECTION& )
847 {
849 return cfg && cfg->m_Appearance.show_pin_alt_icons;
850 };
851
852 auto showAnnotateAutomaticallyCond =
853 [this]( const SELECTION& )
854 {
856 };
857
858 auto remapSymbolsCondition =
859 [&]( const SELECTION& aSel )
860 {
861 SCH_SCREENS schematic( Schematic().Root() );
862
863 // The remapping can only be performed on legacy projects.
864 return schematic.HasNoFullyDefinedLibIds();
865 };
866
867 auto belowRootSheetCondition =
868 [this]( const SELECTION& aSel )
869 {
870 SCH_NAVIGATE_TOOL* navigateTool = m_toolManager->GetTool<SCH_NAVIGATE_TOOL>();
871 return navigateTool && navigateTool->CanGoUp();
872 };
873
874 mgr->SetConditions( SCH_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
875
876 /* Some of these are bound by default to arrow keys which will get a different action if we
877 * disable the buttons. So always leave them enabled so the action is consistent.
878 * https://gitlab.com/kicad/code/kicad/-/issues/14783
879 mgr->SetConditions( SCH_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
880 mgr->SetConditions( SCH_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
881 mgr->SetConditions( SCH_ACTIONS::navigateBack, ENABLE( navHistoryHsBackward ) );
882 */
883
884 mgr->SetConditions( SCH_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
885 mgr->SetConditions( SCH_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
886 mgr->SetConditions( SCH_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
887 mgr->SetConditions( SCH_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
888 mgr->SetConditions( SCH_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
889 mgr->SetConditions( SCH_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
890 mgr->SetConditions( SCH_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
891 mgr->SetConditions( SCH_ACTIONS::markSimExclusions, CHECK( markSimExclusionsCond ) );
892 mgr->SetConditions( SCH_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
893 mgr->SetConditions( SCH_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
894 mgr->SetConditions( SCH_ACTIONS::togglePinAltIcons, CHECK( showPinAltModeIconsCond ) );
895 mgr->SetConditions( SCH_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
897
900
901#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
902
932
933#undef CURRENT_TOOL
934#undef CHECK
935#undef ENABLE
936}
937
938
940{
941 // we cannot store a pointer to an item in the display list here since
942 // that item may be deleted, such as part of a line concatenation or other.
943 // So simply always keep a copy of the object which is to be repeated.
944
945 if( aItem )
946 {
947 m_items_to_repeat.clear();
948
949 AddCopyForRepeatItem( aItem );
950 }
951}
952
953
955{
956 // we cannot store a pointer to an item in the display list here since
957 // that item may be deleted, such as part of a line concatenation or other.
958 // So simply always keep a copy of the object which is to be repeated.
959
960 if( aItem )
961 {
962 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate( IGNORE_PARENT_GROUP ) ) );
963
964 // Clone() preserves the flags & parent, we want 'em cleared.
965 repeatItem->ClearFlags();
966 repeatItem->SetParent( nullptr );
967
968 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
969 }
970}
971
972
973EDA_ITEM* SCH_EDIT_FRAME::ResolveItem( const KIID& aId, bool aAllowNullptrReturn ) const
974{
975 return Schematic().ResolveItem( aId, nullptr, aAllowNullptrReturn );
976}
977
978
983
984
989
990
992{
993 return *m_schematic;
994}
995
996
998{
999 return GetCurrentSheet().Last()->GetName();
1000}
1001
1002
1004{
1006}
1007
1008
1010{
1011 m_schematic->CreateDefaultScreens();
1012 SetScreen( Schematic().RootScreen() );
1013
1014 if( GetScreen() == nullptr )
1015 {
1016 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
1017 SetScreen( screen );
1018 }
1019}
1020
1021
1023{
1024 return m_schematic->CurrentSheet();
1025}
1026
1027
1029{
1030 if( aSheet != GetCurrentSheet() )
1031 {
1032 ClearFocus();
1033
1034 wxLogTrace( traceSchCurrentSheet,
1035 "SCH_EDIT_FRAME::SetCurrentSheet: Changing from path='%s' (size=%zu) to path='%s' (size=%zu)",
1036 GetCurrentSheet().Path().AsString(),
1037 GetCurrentSheet().size(),
1038 aSheet.Path().AsString(),
1039 aSheet.size() );
1040
1041 Schematic().SetCurrentSheet( aSheet );
1042 GetCanvas()->DisplaySheet( aSheet.LastScreen() );
1043 }
1044}
1045
1046
1048{
1050
1051 for( SCH_ITEM* item : screen->Items() )
1052 item->ClearCaches();
1053
1054 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
1055 {
1056 wxCHECK2( libSymbol.second, continue );
1057 libSymbol.second->ClearCaches();
1058 }
1059
1060 if( Schematic().Settings().m_IntersheetRefsShow )
1062
1063 ClearFocus();
1064
1065 GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
1066
1067 if( SCH_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>() )
1068 selectionTool->Reset( TOOL_BASE::REDRAW );
1069
1071}
1072
1073
1074bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
1075{
1076 // Exit interactive editing
1077 // Note this this will commit *some* pending changes. For instance, the SCH_POINT_EDITOR
1078 // will cancel any drag currently in progress, but commit all changes from previous drags.
1079 if( m_toolManager )
1081
1082 // Shutdown blocks must be determined and vetoed as early as possible
1083 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
1084 && IsContentModified() )
1085 {
1086 return false;
1087 }
1088
1089 if( Kiface().IsSingle() )
1090 {
1091 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1092
1093 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
1094 return false;
1095
1096 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
1097
1098 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
1099 return false;
1100
1101 // SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
1102 // sorry.
1103 auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
1104
1105 if( chooser && !chooser->Close() ) // Can close symbol chooser?
1106 return false;
1107 }
1108 else
1109 {
1110 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1111
1112 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
1113 {
1114 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
1115 return false;
1116 }
1117 }
1118
1119 if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
1120 return false;
1121
1123 && !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
1124 {
1125 return false;
1126 }
1127
1128 // We may have gotten multiple events; don't clean up twice
1129 if( !Schematic().IsValid() )
1130 return false;
1131
1132 if( IsContentModified() )
1133 {
1134 wxFileName fileName = Schematic().RootScreen()->GetFileName();
1135 wxString msg = _( "Save changes to '%s' before closing?" );
1136
1137 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1138 [&]() -> bool
1139 {
1140 return SaveProject();
1141 } ) )
1142 {
1143 return false;
1144 }
1145 }
1146
1147 return true;
1148}
1149
1150
1152{
1154
1155 SCH_SHEET_LIST sheetlist = Schematic().Hierarchy();
1156
1157#ifdef KICAD_IPC_API
1158 Pgm().GetApiServer().DeregisterHandler( m_apiHandler.get() );
1159 wxTheApp->Unbind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED, &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
1160#endif
1161
1162 // Close modeless dialogs. They're trouble when they get destroyed after the frame.
1163 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
1164 Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
1165 Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog, this );
1166 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging, this );
1167 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
1168
1169 if( m_diffSymbolDialog )
1170 {
1171 m_diffSymbolDialog->Destroy();
1172 m_diffSymbolDialog = nullptr;
1173 }
1174
1175 if( m_ercDialog )
1176 {
1177 m_ercDialog->Destroy();
1178 m_ercDialog = nullptr;
1179 }
1180
1182 {
1183 m_symbolFieldsTableDialog->Destroy();
1184 m_symbolFieldsTableDialog = nullptr;
1185 }
1186
1187 // Make sure local settings are persisted
1188 if( Prj().GetLocalSettings().ShouldAutoSave() )
1190
1191 delete m_toolManager;
1192 m_toolManager = nullptr;
1193
1194 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
1195
1196 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
1197 {
1198 hierarchy_pane.Show( false );
1199 m_auimgr.Update();
1200 }
1201
1202 SCH_SCREENS screens( Schematic().Root() );
1203 wxFileName fn;
1204
1205 for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
1206 {
1207 fn = Prj().AbsolutePath( screen->GetFileName() );
1208
1209 // Auto save file name is the normal file name prepended with FILEEXT::AutoSaveFilePrefix.
1210 fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() );
1211
1212 if( fn.IsFileWritable() )
1213 wxRemoveFile( fn.GetFullPath() );
1214 }
1215
1216 wxFileName tmpFn = Prj().GetProjectFullName();
1217 wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
1218
1219 if( autoSaveFileName.IsFileWritable() )
1220 wxRemoveFile( autoSaveFileName.GetFullPath() );
1221
1222 sheetlist.ClearModifyStatus();
1223
1224 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
1225
1226 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
1227 UpdateFileHistory( fileName );
1228
1229 Schematic().RootScreen()->Clear( true );
1230
1231 // all sub sheets are deleted, only the main sheet is usable
1233
1234 // Clear view before destroying schematic as repaints depend on schematic being valid
1235 SetScreen( nullptr );
1236
1237 Schematic().Reset();
1238
1239 // Prevents any rogue events from continuing (i.e. search panel tries to redraw)
1240 Show( false );
1241
1242 Destroy();
1243}
1244
1245
1247{
1248 m_searchPane->FocusSearch();
1249}
1250
1251
1253{
1254 return Schematic().ErcSettings().GetSeverity( aErrorCode );
1255}
1256
1257
1259{
1261
1262 if( GetScreen() )
1264
1265 if( m_isClosing )
1266 return;
1267
1268 if( GetCanvas() )
1269 GetCanvas()->Refresh();
1270
1271 if( !GetTitle().StartsWith( wxS( "*" ) ) )
1272 updateTitle();
1273}
1274
1275
1277{
1278 if( Kiface().IsSingle() )
1279 {
1280 DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
1281 " in stand-alone mode. In order to create/update PCBs from"
1282 " schematics, launch the KiCad shell and create a project." ) );
1283 return;
1284 }
1285
1286 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1287 wxEventBlocker blocker( this );
1288
1289 if( !frame )
1290 {
1291 wxFileName fn = Prj().GetProjectFullName();
1292 fn.SetExt( FILEEXT::PcbFileExtension );
1293
1294 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1295
1296 // If Kiway() cannot create the Pcbnew frame, it shows a error message, and
1297 // frame is null
1298 if( !frame )
1299 return;
1300
1301 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1302 }
1303
1304 if( !frame->IsVisible() )
1305 frame->Show( true );
1306
1307 // On Windows, Raise() does not bring the window on screen, when iconized
1308 if( frame->IsIconized() )
1309 frame->Iconize( false );
1310
1311 frame->Raise();
1312
1313 std::string payload;
1315}
1316
1317
1318void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator, bool aClear )
1319{
1320 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
1321 m_hierarchy->UpdateHierarchyTree( aClear );
1322
1323 if( aRefreshNetNavigator )
1325}
1326
1327
1329{
1330 // Update only the hierarchy navigation tree labels.
1331 // The tree list is expected to be up to date
1332 m_hierarchy->UpdateLabelsHierarchyTree();
1333}
1334
1335
1337{
1338 m_hierarchy->UpdateHierarchySelection();
1339}
1340
1341
1342void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1343{
1344 wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1345
1346 if( fn.size() )
1347 OpenProjectFiles( std::vector<wxString>( 1, fn ) );
1348}
1349
1350
1351void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
1352{
1354}
1355
1356
1358{
1359 // Only standalone mode can directly load a new document
1360 if( !Kiface().IsSingle() )
1361 return;
1362
1363 wxString pro_dir = m_mruPath;
1364
1365 wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
1367
1368 if( dlg.ShowModal() != wxID_CANCEL )
1369 {
1370 // Enforce the extension, wxFileDialog is inept.
1371 wxFileName create_me =
1373
1374 if( create_me.FileExists() )
1375 {
1376 wxString msg;
1377 msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
1378 DisplayError( this, msg );
1379 return ;
1380 }
1381
1382 // OpenProjectFiles() requires absolute
1383 wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
1384
1385 OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1386 m_mruPath = create_me.GetPath();
1387 }
1388}
1389
1390
1392{
1393 // Only standalone mode can directly load a new document
1394 if( !Kiface().IsSingle() )
1395 return;
1396
1397 wxString pro_dir = m_mruPath;
1398 wxString wildcards = FILEEXT::AllSchematicFilesWildcard()
1400 + wxS( "|" ) + FILEEXT::LegacySchematicFileWildcard();
1401
1402 wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
1403 wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1404
1405 if( dlg.ShowModal() != wxID_CANCEL )
1406 {
1407 OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1409 }
1410
1411 // Since we know we're single-top here: trigger library reload
1412 CallAfter( [&]()
1413 {
1414 KIFACE *schface = Kiway().KiFACE( KIWAY::FACE_SCH );
1415 schface->PreloadLibraries( &Prj() );
1416 } );
1417}
1418
1419
1421{
1422 wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
1423
1424 if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
1425 {
1426 kicad_board.SetExt( FILEEXT::PcbFileExtension );
1427 wxFileName legacy_board( kicad_board );
1428 legacy_board.SetExt( FILEEXT::LegacyPcbFileExtension );
1429 wxFileName& boardfn = legacy_board;
1430
1431 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1432 boardfn = kicad_board;
1433
1434 if( Kiface().IsSingle() )
1435 {
1436 ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
1437 }
1438 else
1439 {
1440 wxEventBlocker blocker(this);
1441 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1442
1443 if( !frame )
1444 {
1445 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1446
1447 // frame can be null if Cvpcb cannot be run. No need to show a warning
1448 // Kiway() generates the error messages
1449 if( !frame )
1450 return;
1451
1452 frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1453 }
1454
1455 if( !frame->IsVisible() )
1456 frame->Show( true );
1457
1458 // On Windows, Raise() does not bring the window on screen, when iconized
1459 if( frame->IsIconized() )
1460 frame->Iconize( false );
1461
1462 frame->Raise();
1463 }
1464 }
1465 else
1466 {
1468 }
1469}
1470
1471
1473{
1474 wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1475 fn.SetExt( FILEEXT::NetlistFileExtension );
1476
1477 if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1478 return;
1479
1480 try
1481 {
1482 KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1483
1484 if( !player )
1485 {
1486 player = Kiway().Player( FRAME_CVPCB, true );
1487
1488 // player can be null if Cvpcb cannot be run. No need to show a warning
1489 // Kiway() generates the error messages
1490 if( !player )
1491 return;
1492
1493 player->Show( true );
1494 }
1495
1496 // Ensure the netlist (mainly info about symbols) is up to date
1499
1500 player->Raise();
1501 }
1502 catch( const IO_ERROR& )
1503 {
1504 DisplayError( this, _( "Could not open CvPcb" ) );
1505 }
1506}
1507
1508
1509void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1510{
1511 if( event.GetId() == wxID_EXIT )
1512 Kiway().OnKiCadExit();
1513
1514 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1515 Close( false );
1516}
1517
1518
1520{
1521 SCHEMATIC_SETTINGS& settings = m_schematic->Settings();
1522 SIM_LIB_MGR simLibMgr( &Prj() );
1523 NULL_REPORTER devnull;
1524
1525 // Patch for bug early in V7.99 dev
1526 if( settings.m_OPO_VRange.EndsWith( 'A' ) )
1527 settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
1528
1529 // Update items which may have ${OP} text variables
1530 //
1532 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1533 {
1534 int flags = 0;
1535
1536 auto invalidateTextVars =
1537 [&flags]( EDA_TEXT* text )
1538 {
1539 if( text->HasTextVars() )
1540 {
1541 text->ClearRenderCache();
1542 text->ClearBoundingBoxCache();
1544 }
1545 };
1546
1547 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1548 {
1549 item->RunOnChildren(
1550 [&invalidateTextVars]( SCH_ITEM* aChild )
1551 {
1552 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1553 invalidateTextVars( text );
1554 },
1556 }
1557
1558 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1559 invalidateTextVars( text );
1560
1561 return flags;
1562 } );
1563
1564 // Update OP overlay items
1565 //
1566 for( SCH_ITEM* item : GetScreen()->Items() )
1567 {
1568 if( GetCurrentSheet().GetExcludedFromSim() )
1569 continue;
1570
1571 if( item->Type() == SCH_LINE_T )
1572 {
1573 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1574
1575 if( !line->GetOperatingPoint().IsEmpty() )
1576 GetCanvas()->GetView()->Update( line );
1577
1578 line->SetOperatingPoint( wxEmptyString );
1579
1580 // update value from netlist, below
1581 }
1582 else if( item->Type() == SCH_SYMBOL_T )
1583 {
1584 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1585 wxString ref = symbol->GetRef( &GetCurrentSheet() );
1586 std::vector<SCH_PIN*> pins = symbol->GetPins( &GetCurrentSheet() );
1587
1588 // Power symbols and other symbols which have the reference starting with "#" are
1589 // not included in simulation
1590 if( ref.StartsWith( '#' ) || symbol->ResolveExcludedFromSim() )
1591 continue;
1592
1593 for( SCH_PIN* pin : pins )
1594 {
1595 if( !pin->GetOperatingPoint().IsEmpty() )
1596 GetCanvas()->GetView()->Update( pin );
1597
1598 pin->SetOperatingPoint( wxEmptyString );
1599 }
1600
1601 if( pins.size() == 2 )
1602 {
1603 wxString op = m_schematic->GetOperatingPoint( ref, settings.m_OPO_IPrecision,
1604 settings.m_OPO_IRange );
1605
1606 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1607 {
1608 pins[0]->SetOperatingPoint( op );
1609 GetCanvas()->GetView()->Update( symbol );
1610 }
1611 }
1612 else
1613 {
1614 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
1615 embeddedFilesStack.push_back( m_schematic->GetEmbeddedFiles() );
1616
1617 if( EMBEDDED_FILES* symbolEmbeddedFiles = symbol->GetEmbeddedFiles() )
1618 embeddedFilesStack.push_back( symbolEmbeddedFiles );
1619
1620 simLibMgr.SetFilesStack( std::move( embeddedFilesStack ) );
1621
1622 SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol, true, 0, devnull ).model;
1623
1624 SPICE_ITEM spiceItem;
1625 spiceItem.refName = ref;
1626 ref = model.SpiceGenerator().ItemName( spiceItem );
1627
1628 for( const auto& modelPin : model.GetPins() )
1629 {
1630 SCH_PIN* symbolPin = symbol->GetPin( modelPin.get().symbolPinNumber );
1631 wxString signalName = ref + wxS( ":" ) + modelPin.get().modelPinName;
1632 wxString op = m_schematic->GetOperatingPoint( signalName,
1633 settings.m_OPO_IPrecision,
1634 settings.m_OPO_IRange );
1635
1636 if( symbolPin && !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1637 {
1638 symbolPin->SetOperatingPoint( op );
1639 GetCanvas()->GetView()->Update( symbol );
1640 }
1641 }
1642 }
1643 }
1644 }
1645
1646 for( const auto& [ key, subgraphList ] : m_schematic->m_connectionGraph->GetNetMap() )
1647 {
1648 wxString op = m_schematic->GetOperatingPoint( key.Name, settings.m_OPO_VPrecision,
1649 settings.m_OPO_VRange );
1650
1651 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1652 {
1653 for( CONNECTION_SUBGRAPH* subgraph : subgraphList )
1654 {
1655 SCH_LINE* longestWire = nullptr;
1656 double length = 0.0;
1657
1658 if( subgraph->GetSheet().GetExcludedFromSim() )
1659 continue;
1660
1661 for( SCH_ITEM* item : subgraph->GetItems() )
1662 {
1663 if( item->Type() == SCH_LINE_T )
1664 {
1665 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1666
1667 if( line->IsWire() && line->GetLength() > length )
1668 {
1669 longestWire = line;
1670 length = line->GetLength();
1671 }
1672 }
1673 }
1674
1675 if( longestWire )
1676 {
1677 longestWire->SetOperatingPoint( op );
1678 GetCanvas()->GetView()->Update( longestWire );
1679 }
1680 }
1681 }
1682 }
1683}
1684
1685
1687{
1688 if( aItem->Type() == SCH_GLOBAL_LABEL_T || aItem->Type() == SCH_HIER_LABEL_T )
1689 {
1690 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
1691
1692 if( label->AutoRotateOnPlacement() )
1693 {
1694 SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
1695 label->GetSpinStyle(),
1696 &GetCurrentSheet() );
1697
1698 if( spin != label->GetSpinStyle() )
1699 {
1700 label->SetSpinStyle( spin );
1701
1702 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1703 {
1704 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1705
1706 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1707 otherLabel->AutoplaceFields( aScreen, AUTOPLACE_AUTO );
1708 }
1709 }
1710 }
1711 }
1712}
1713
1714
1716{
1717 SCH_SCREEN* screen = GetScreen();
1718
1719 wxCHECK( screen, /* void */ );
1720
1721 wxString title;
1722
1723 if( !screen->GetFileName().IsEmpty() )
1724 {
1725 wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1726 bool readOnly = false;
1727 bool unsaved = false;
1728
1729 if( fn.IsOk() && screen->FileExists() )
1730 readOnly = screen->IsReadOnly();
1731 else
1732 unsaved = true;
1733
1734 if( IsContentModified() )
1735 title = wxT( "*" );
1736
1737 title += fn.GetName();
1738
1739 wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
1740
1741 if( sheetPath != title )
1742 title += wxString::Format( wxT( " [%s]" ), sheetPath );
1743
1744 if( readOnly )
1745 title += wxS( " " ) + _( "[Read Only]" );
1746
1747 if( unsaved )
1748 title += wxS( " " ) + _( "[Unsaved]" );
1749 }
1750 else
1751 {
1752 title = _( "[no schematic loaded]" );
1753 }
1754
1755 title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1756
1757 SetTitle( title );
1758}
1759
1760
1762{
1764
1765 if( GetScreen() )
1766 GetScreen()->m_zoomInitialized = true;
1767}
1768
1769
1771 PROGRESS_REPORTER* aProgressReporter )
1772{
1773 wxString highlightedConn = GetHighlightedConnection();
1774 bool hasHighlightedConn = !highlightedConn.IsEmpty();
1775
1776 std::function<void( SCH_ITEM* )> changeHandler =
1777 [&]( SCH_ITEM* aChangedItem ) -> void
1778 {
1779 GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1780
1781 SCH_CONNECTION* connection = aChangedItem->Connection();
1782
1784 return;
1785
1786 if( !hasHighlightedConn )
1787 {
1788 // No highlighted connection, but connectivity has changed, so refresh
1789 // the list of all nets
1791 }
1792 else if( connection
1793 && ( connection->Name() == highlightedConn
1794 || connection->HasDriverChanged() ) )
1795 {
1797 }
1798 };
1799
1800 Schematic().RecalculateConnections( aCommit, aCleanupFlags,
1802 aProgressReporter,
1803 GetCanvas()->GetView(),
1804 &changeHandler,
1805 m_undoList.m_CommandsList.empty() ? nullptr
1806 : m_undoList.m_CommandsList.back() );
1807
1809 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1810 {
1811 int flags = 0;
1812 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
1813 SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
1814
1815 auto invalidateTextVars =
1816 [&flags]( EDA_TEXT* text )
1817 {
1818 if( text->HasTextVars() )
1819 {
1820 text->ClearRenderCache();
1821 text->ClearBoundingBoxCache();
1823 }
1824 };
1825
1826 if( connection && connection->HasDriverChanged() )
1827 {
1828 connection->ClearDriverChanged();
1829 flags |= KIGFX::REPAINT;
1830 }
1831
1832 if( item )
1833 {
1834 item->RunOnChildren(
1835 [&invalidateTextVars]( SCH_ITEM* aChild )
1836 {
1837 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1838 invalidateTextVars( text );
1839 },
1841
1842 if( flags & KIGFX::GEOMETRY )
1843 GetScreen()->Update( item, false ); // Refresh RTree
1844 }
1845
1846 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1847 invalidateTextVars( text );
1848
1849 return flags;
1850 } );
1851
1853 || !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
1854 {
1858 }
1859}
1860
1861
1866
1867
1869{
1870 GetCanvas()->GetView()->Update( aItem );
1871}
1872
1873
1880
1881
1882std::unique_ptr<GRID_HELPER> SCH_EDIT_FRAME::MakeGridHelper()
1883{
1884 return std::make_unique<EE_GRID_HELPER>( m_toolManager );
1885}
1886
1887
1889{
1891
1892 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1893
1896
1898
1899 if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
1900 {
1901 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1902 GetRenderSettings()->SetDefaultFont( cfg->m_Appearance.default_font );
1903
1904 KIGFX::VIEW* view = GetCanvas()->GetView();
1905 view->SetLayerVisible( LAYER_ERC_ERR, cfg->m_Appearance.show_erc_errors );
1906 view->SetLayerVisible( LAYER_ERC_WARN, cfg->m_Appearance.show_erc_warnings );
1907 view->SetLayerVisible( LAYER_ERC_EXCLUSION, cfg->m_Appearance.show_erc_exclusions );
1908 view->SetLayerVisible( LAYER_OP_VOLTAGES, cfg->m_Appearance.show_op_voltages );
1909 view->SetLayerVisible( LAYER_OP_CURRENTS, cfg->m_Appearance.show_op_currents );
1910
1911 GetRenderSettings()->m_ShowPinAltIcons = cfg->m_Appearance.show_pin_alt_icons;
1912
1914
1915 settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
1916
1917 if( !cfg->m_Drawing.field_names.IsEmpty() )
1918 settings.m_TemplateFieldNames.AddTemplateFieldNames( cfg->m_Drawing.field_names );
1919 }
1920
1922
1923 for( SCH_ITEM* item : screen->Items() )
1924 {
1925 item->ClearCaches();
1926
1927 if( item->Type() == SCH_LINE_T )
1928 {
1929 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1930
1931 if( line->IsWire() )
1932 UpdateHopOveredWires( line );
1933 }
1934 }
1935
1936 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
1937 libSymbol->ClearCaches();
1938
1940
1942 Layout();
1943 SendSizeEvent();
1944}
1945
1946
1948{
1949 // Store the current zoom level into the current screen before calling
1950 // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
1952
1953 // Rebuild the sheet view (draw area and any other items):
1955}
1956
1957
1959{
1960 // call my base class
1962
1963 // tooltips in toolbars
1965
1966 // For some obscure reason, the AUI manager hides the first modified pane.
1967 // So force show panes
1968 wxAuiPaneInfo& design_blocks_pane_info = m_auimgr.GetPane( m_designBlocksPane );
1969 bool panel_shown = design_blocks_pane_info.IsShown();
1970 design_blocks_pane_info.Caption( _( "Design Blocks" ) );
1971 design_blocks_pane_info.Show( panel_shown );
1972
1973 m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
1974 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
1975 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
1976 m_auimgr.GetPane( m_designBlocksPane ).Caption( _( "Design Blocks" ) );
1977 m_auimgr.Update();
1978 m_hierarchy->UpdateHierarchyTree();
1979
1980 // status bar
1982
1983 updateTitle();
1984
1985 // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1986 // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1987 // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1988 // toolbar to update correctly.
1989#if defined( __WXMSW__ )
1990 PostSizeEvent();
1991#endif
1992}
1993
1994
1996{
1997 if( !GetHighlightedConnection().IsEmpty() )
1998 {
1999 SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
2001 }
2002 else
2003 {
2004 SetStatusText( wxT( "" ) );
2005 }
2006}
2007
2008
2010{
2011 if( m_toolManager )
2013
2014 SCH_BASE_FRAME::SetScreen( aScreen );
2015 GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
2016
2017 if( m_toolManager )
2019}
2020
2021
2022const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
2023{
2024 BOX2I bBoxDoc;
2025
2026 if( !GetScreen() )
2027 return bBoxDoc;
2028
2029 if( aIncludeAllVisible )
2030 {
2031 // Get the whole page size and return that
2032 int sizeX = GetScreen()->GetPageSettings().GetWidthIU( schIUScale.IU_PER_MILS );
2033 int sizeY = GetScreen()->GetPageSettings().GetHeightIU( schIUScale.IU_PER_MILS );
2034 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
2035 }
2036 else
2037 {
2038 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
2040 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
2041
2042 // Calc the bounding box of all items on screen except the page border
2043 for( EDA_ITEM* item : GetScreen()->Items() )
2044 {
2045 if( item != dsAsItem ) // Ignore the drawing-sheet itself
2046 bBoxDoc.Merge( item->GetBoundingBox() );
2047 }
2048 }
2049
2050 return bBoxDoc;
2051}
2052
2053
2055{
2056 return Schematic().Hierarchy().IsModified();
2057}
2058
2059
2061{
2062 EESCHEMA_SETTINGS* cfg = eeconfig();
2063 return cfg && cfg->m_Appearance.show_hidden_pins;
2064}
2065
2066
2067void SCH_EDIT_FRAME::FocusOnItem( EDA_ITEM* aItem, bool aAllowScroll )
2068{
2069 // nullptr will clear the current focus
2070 if( aItem != nullptr && !aItem->IsSCH_ITEM() )
2071 return;
2072
2073 static KIID lastBrightenedItemID( niluuid );
2074
2075 SCH_ITEM* lastItem = Schematic().ResolveItem( lastBrightenedItemID, nullptr, true );
2076
2077 if( lastItem && lastItem != aItem )
2078 {
2079 lastItem->ClearBrightened();
2080
2081 UpdateItem( lastItem );
2082 lastBrightenedItemID = niluuid;
2083 }
2084
2085 if( aItem )
2086 {
2087 if( !aItem->IsBrightened() )
2088 {
2089 aItem->SetBrightened();
2090
2091 UpdateItem( aItem );
2092 lastBrightenedItemID = aItem->m_Uuid;
2093 }
2094
2095 FocusOnLocation( aItem->GetFocusPosition(), aAllowScroll );
2096 }
2097}
2098
2099
2101{
2102 return Schematic().GetFileName();
2103}
2104
2105
2107{
2108 return m_toolManager->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
2109}
2110
2111
2112void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2113{
2114 if( IsShown() )
2115 {
2116 // We only need this until the frame is done resizing and the final client size is
2117 // established.
2118 Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
2120 }
2121
2122 // Skip() is called in the base class.
2123 EDA_DRAW_FRAME::OnSize( aEvent );
2124}
2125
2126
2128 const KIID& aSchematicSymbolUUID )
2129{
2130 SCH_SHEET_PATH principalPath;
2131 SCH_SHEET_LIST sheets = Schematic().Hierarchy();
2132 SCH_ITEM* item = sheets.ResolveItem( aSchematicSymbolUUID, &principalPath, true );
2133 SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
2134 SCH_COMMIT commit( m_toolManager );
2135
2136 if( !principalSymbol )
2137 return;
2138
2139 wxString principalRef;
2140
2141 if( principalSymbol->IsAnnotated( &principalPath ) )
2142 principalRef = principalSymbol->GetRef( &principalPath, false );
2143
2144 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
2145
2146 for( const SCH_SHEET_PATH& path : sheets )
2147 {
2148 for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2149 {
2150 SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
2151
2152 if( candidateSymbol == principalSymbol
2153 || ( candidateSymbol->IsAnnotated( &path )
2154 && candidateSymbol->GetRef( &path, false ) == principalRef ) )
2155 {
2156 allUnits.emplace_back( candidateSymbol, path );
2157 }
2158 }
2159 }
2160
2161 for( auto& [ unit, path ] : allUnits )
2162 {
2163 // This needs to be done before the LIB_SYMBOL is changed to prevent stale
2164 // library symbols in the schematic file.
2165 path.LastScreen()->Remove( unit );
2166
2167 if( !unit->IsNew() )
2168 commit.Modify( unit, path.LastScreen() );
2169
2170 unit->SetLibSymbol( aSymbol.Flatten().release() );
2171 unit->UpdateFields( &GetCurrentSheet(),
2172 true, /* update style */
2173 true, /* update ref */
2174 true, /* update other fields */
2175 false, /* reset ref */
2176 false /* reset other fields */ );
2177
2178 path.LastScreen()->Append( unit );
2179 GetCanvas()->GetView()->Update( unit );
2180 }
2181
2182 // Clear any orphaned alternate pins.
2183 for( SCH_PIN* pin : principalSymbol->GetPins() )
2184 {
2185 wxString altName = pin->GetAlt();
2186
2187 if( altName.IsEmpty() )
2188 continue;
2189
2190 if( pin->GetAlternates().count( altName ) == 0 )
2191 pin->SetAlt( wxEmptyString );
2192 }
2193
2194 if( !commit.Empty() )
2195 commit.Push( _( "Save Symbol to Schematic" ) );
2196}
2197
2198
2199void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2200{
2201 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2202
2203 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
2204 sch_item->ClearCaches();
2205}
2206
2207
2209{
2210 wxCHECK( m_toolManager, /* void */ );
2211
2215
2216 wxCHECK( screen, /* void */ );
2217
2219
2220 SCH_BASE_FRAME::SetScreen( screen );
2221
2222 SetSheetNumberAndCount(); // will also update CurrentScreen()'s sheet number info
2223
2225
2226 // update the references, units, and intersheet-refs
2228
2229 // dangling state can also have changed if different units with different pin locations are
2230 // used
2233
2234 SCH_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>();
2235
2236 wxCHECK( selectionTool, /* void */ );
2237
2238 auto visit =
2239 [&]( EDA_ITEM* item )
2240 {
2242 && !m_findReplaceData->findString.IsEmpty()
2243 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
2244 {
2245 item->SetForceVisible( true );
2246 selectionTool->BrightenItem( item );
2247 }
2248 else if( item->IsBrightened() )
2249 {
2250 item->SetForceVisible( false );
2251 selectionTool->UnbrightenItem( item );
2252 }
2253 };
2254
2255 for( SCH_ITEM* item : screen->Items() )
2256 {
2257 visit( item );
2258
2259 item->RunOnChildren(
2260 [&]( SCH_ITEM* aChild )
2261 {
2262 visit( aChild );
2263 },
2265 }
2266
2267 if( !screen->m_zoomInitialized )
2268 {
2270 }
2271 else
2272 {
2273 // Set zoom to last used in this screen
2274 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
2275 GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
2276 }
2277
2278 updateTitle();
2279
2280 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
2281
2282 // Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
2284
2285 SCH_EDITOR_CONTROL* editTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
2286
2287 wxCHECK( editTool, /* void */ );
2288
2290 editTool->UpdateNetHighlighting( dummy );
2291
2292 m_hierarchy->UpdateHierarchySelection();
2293
2294 m_schematic->OnSchSheetChanged();
2295}
2296
2297
2299{
2300 if( !m_diffSymbolDialog )
2301 {
2303 _( "Compare Symbol with Library" ) );
2304
2305 m_diffSymbolDialog->m_sdbSizerApply->SetLabel( _( "Update Symbol from Library..." ) );
2306 m_diffSymbolDialog->m_sdbSizerApply->Show();
2307 }
2308
2309 return m_diffSymbolDialog;
2310}
2311
2312
2313void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
2314{
2315 if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
2316 {
2317 if( aEvent.GetId() == wxID_APPLY )
2318 {
2319 KIID symbolUUID = m_diffSymbolDialog->GetUserItemID();
2320
2321 CallAfter(
2322 [this, symbolUUID]()
2323 {
2324 EDA_ITEM* item = ResolveItem( symbolUUID );
2325
2326 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item ) )
2327 {
2328 m_toolManager->RunAction<EDA_ITEM*>( ACTIONS::selectItem, symbol );
2329
2331 dlg.ShowQuasiModal();
2332 }
2333 } );
2334 }
2335
2336 m_diffSymbolDialog->Destroy();
2337 m_diffSymbolDialog = nullptr;
2338 }
2339}
2340
2341
2343{
2344 if( !m_ercDialog )
2345 m_ercDialog = new DIALOG_ERC( this );
2346
2347 return m_ercDialog;
2348}
2349
2350
2351void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
2352{
2353 if( m_ercDialog )
2354 {
2355 m_ercDialog->Destroy();
2356 m_ercDialog = nullptr;
2357 }
2358}
2359
2360
2368
2369
2371{
2373 {
2374 m_symbolFieldsTableDialog->Destroy();
2375 m_symbolFieldsTableDialog = nullptr;
2376 }
2377}
2378
2379
2380void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
2381{
2382 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(), aListener );
2383
2384 // Don't add duplicate listeners.
2385 if( it == m_schematicChangeListeners.end() )
2386 m_schematicChangeListeners.push_back( aListener );
2387}
2388
2389
2391{
2392 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(), aListener );
2393
2394 // Don't add duplicate listeners.
2395 if( it != m_schematicChangeListeners.end() )
2396 m_schematicChangeListeners.erase( it );
2397}
2398
2399
2401{
2402 wxPanel* panel = new wxPanel( this );
2403
2404 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
2405
2406 // Create horizontal sizer for search control and gear button
2407 wxBoxSizer* searchSizer = new wxBoxSizer( wxHORIZONTAL );
2408
2409 m_netNavigatorFilter = new wxSearchCtrl( panel, wxID_ANY );
2410 m_netNavigatorFilter->SetDescriptiveText( _( "Filter nets" ) );
2411 m_netNavigatorFilter->ShowCancelButton( false );
2412 searchSizer->Add( m_netNavigatorFilter, 1, wxEXPAND | wxRIGHT, FromDIP( 2 ) );
2413
2414 m_netNavigatorMenuButton = new BITMAP_BUTTON( panel, wxID_ANY );
2416 m_netNavigatorMenuButton->SetPadding( FromDIP( 2 ) );
2417 searchSizer->Add( m_netNavigatorMenuButton, 0, wxALIGN_CENTER_VERTICAL );
2418
2419 sizer->Add( searchSizer, 0, wxEXPAND | wxALL, FromDIP( 2 ) );
2420
2421 m_netNavigator = new wxTreeCtrl( panel, wxID_ANY, wxPoint( 0, 0 ), FromDIP( wxSize( 160, 250 ) ),
2422 wxTR_DEFAULT_STYLE | wxNO_BORDER );
2423 sizer->Add( m_netNavigator, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, FromDIP( 2 ) );
2424
2425 panel->SetSizer( sizer );
2426
2427 m_netNavigatorFilter->Bind( wxEVT_COMMAND_TEXT_UPDATED,
2429 m_netNavigatorFilter->Bind( wxEVT_KEY_DOWN, &SCH_EDIT_FRAME::onNetNavigatorKey, this );
2430 m_netNavigator->Bind( wxEVT_KEY_DOWN, &SCH_EDIT_FRAME::onNetNavigatorKey, this );
2431 m_netNavigator->Bind( wxEVT_TREE_ITEM_MENU, &SCH_EDIT_FRAME::onNetNavigatorItemMenu, this );
2432 m_netNavigator->Bind( wxEVT_CONTEXT_MENU, &SCH_EDIT_FRAME::onNetNavigatorContextMenu, this );
2433
2434 m_netNavigatorMenuButton->Bind( wxEVT_LEFT_DOWN,
2435 [this]( wxMouseEvent& event )
2436 {
2437 wxMenu menu;
2438 wxMenuItem* wildcardItem = menu.AppendRadioItem( ID_NET_NAVIGATOR_SEARCH_WILDCARD,
2439 _( "Wildcard Search" ) );
2440 wxMenuItem* regexItem = menu.AppendRadioItem( ID_NET_NAVIGATOR_SEARCH_REGEX,
2441 _( "Regex Search" ) );
2442
2443 EESCHEMA_SETTINGS* cfg = eeconfig();
2444
2446 wildcardItem->Check();
2447 else
2448 regexItem->Check();
2449
2450 PopupMenu( &menu );
2451 } );
2452
2458
2459 return panel;
2460}
2461
2462
2463void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection,
2464 const NET_NAVIGATOR_ITEM_DATA* aSelection )
2465{
2466 bool refreshNetNavigator = aConnection != m_highlightedConn;
2467
2468 m_highlightedConn = aConnection;
2469
2470 if( refreshNetNavigator )
2471 RefreshNetNavigator( aSelection );
2472}
2473
2474
2476{
2477 if( m_netNavigator )
2478 {
2479 NET_NAVIGATOR_ITEM_DATA itemData;
2480 wxTreeItemId selection = m_netNavigator->GetSelection();
2481 bool refreshSelection = selection.IsOk() && ( selection != m_netNavigator->GetRootItem() );
2482
2483 if( refreshSelection )
2484 {
2486 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
2487
2488 wxCHECK( tmp, /* void */ );
2489 itemData = *tmp;
2490 }
2491
2492 m_netNavigator->DeleteAllItems();
2493 RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
2494 }
2495
2497}
2498
2499
2501{
2502 if( !m_netNavigator )
2503 return;
2504
2505 wxString newFilter = m_netNavigatorFilter ? m_netNavigatorFilter->GetValue() : wxString();
2506
2507 if( newFilter == m_netNavigatorFilterValue )
2508 return;
2509
2510 m_netNavigatorFilterValue = newFilter;
2511
2512 NET_NAVIGATOR_ITEM_DATA selectionData;
2513 NET_NAVIGATOR_ITEM_DATA* selectionPtr = nullptr;
2514
2515 wxTreeItemId selection = m_netNavigator->GetSelection();
2516
2517 if( selection.IsOk() )
2518 {
2519 if( NET_NAVIGATOR_ITEM_DATA* tmp =
2520 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) ) )
2521 {
2522 selectionData = *tmp;
2523 selectionPtr = &selectionData;
2524 }
2525 }
2526
2527 RefreshNetNavigator( selectionPtr );
2528
2529 aEvent.Skip();
2530}
2531
2532
2533void SCH_EDIT_FRAME::onNetNavigatorKey( wxKeyEvent& aEvent )
2534{
2535 if( aEvent.GetKeyCode() == WXK_ESCAPE )
2536 {
2537 // Clear the search string and refresh
2539 m_netNavigatorFilter->SetValue( wxEmptyString );
2540
2541 m_netNavigatorFilterValue = wxEmptyString;
2542
2544
2545 // Don't skip the event - we handled it
2546 return;
2547 }
2548
2549 aEvent.Skip();
2550}
2551
2552
2553
2555{
2556 showNetNavigatorMenu( aEvent.GetItem() );
2557}
2558
2559
2560void SCH_EDIT_FRAME::onNetNavigatorContextMenu( wxContextMenuEvent& aEvent )
2561{
2562 if( !m_netNavigator )
2563 return;
2564
2565 wxPoint screenPos = aEvent.GetPosition();
2566
2567 if( screenPos == wxDefaultPosition )
2568 screenPos = wxGetMousePosition();
2569
2570 wxPoint clientPos = m_netNavigator->ScreenToClient( screenPos );
2571 int flags = 0;
2572 wxTreeItemId item = m_netNavigator->HitTest( clientPos, flags );
2573
2574 showNetNavigatorMenu( item );
2575}
2576
2577
2578void SCH_EDIT_FRAME::showNetNavigatorMenu( const wxTreeItemId& aItem )
2579{
2580 if( !m_netNavigator )
2581 return;
2582
2583 wxMenu menu;
2584
2585 menu.Append( ID_NET_NAVIGATOR_EXPAND_ALL, _( "Expand All" ) );
2586 menu.Append( ID_NET_NAVIGATOR_COLLAPSE_ALL, _( "Collapse All" ) );
2587
2588 wxMenuItem* findInInspector = new wxMenuItem( &menu, ID_NET_NAVIGATOR_FIND_IN_INSPECTOR,
2589 _( "Find in Net Inspector" ) );
2590 menu.Append( findInInspector );
2591
2592 wxString netName;
2593
2594 if( aItem.IsOk() )
2595 {
2596 wxTreeItemId netItem = aItem;
2597
2598 if( m_netNavigator->GetItemParent( netItem ) != m_netNavigator->GetRootItem() )
2599 {
2600 wxTreeItemId parent = m_netNavigator->GetItemParent( netItem );
2601
2602 while( parent.IsOk() && parent != m_netNavigator->GetRootItem() )
2603 {
2604 netItem = parent;
2605 parent = m_netNavigator->GetItemParent( netItem );
2606 }
2607
2608 if( parent == m_netNavigator->GetRootItem() )
2609 {
2610 if( wxStringClientData* data =
2611 dynamic_cast<wxStringClientData*>( m_netNavigator->GetItemData( netItem ) ) )
2612 {
2613 netName = data->GetData();
2614 }
2615 }
2616 }
2617 else if( m_netNavigator->GetItemParent( netItem ) == m_netNavigator->GetRootItem() )
2618 {
2619 if( wxStringClientData* data =
2620 dynamic_cast<wxStringClientData*>( m_netNavigator->GetItemData( netItem ) ) )
2621 {
2622 netName = data->GetData();
2623 }
2624 }
2625 else if( !m_highlightedConn.IsEmpty() && netItem == m_netNavigator->GetRootItem() )
2626 {
2627 netName = m_highlightedConn;
2628 }
2629 }
2630 else if( !m_highlightedConn.IsEmpty() && m_netNavigator->GetRootItem().IsOk() )
2631 {
2632 netName = m_highlightedConn;
2633 }
2634
2635 if( netName.IsEmpty() )
2636 {
2637 findInInspector->Enable( false );
2639 }
2640 else
2641 {
2642 m_netNavigatorMenuNetName = netName;
2643 }
2644
2645 PopupMenu( &menu );
2646}
2647
2648
2649void SCH_EDIT_FRAME::onNetNavigatorMenuCommand( wxCommandEvent& aEvent )
2650{
2651 if( !m_netNavigator )
2652 return;
2653
2654 switch( aEvent.GetId() )
2655 {
2657 m_netNavigator->ExpandAll();
2658 break;
2659
2661 m_netNavigator->CollapseAll();
2662
2663 if( m_netNavigator->GetRootItem().IsOk() )
2664 m_netNavigator->Expand( m_netNavigator->GetRootItem() );
2665 break;
2666
2668 if( !m_netNavigatorMenuNetName.IsEmpty() )
2670 break;
2671
2674 {
2675 EESCHEMA_SETTINGS* cfg = eeconfig();
2676 if( cfg )
2677 {
2679 ( aEvent.GetId() == ID_NET_NAVIGATOR_SEARCH_WILDCARD );
2680
2681 // Refresh the navigator with current filter
2683 }
2684 break;
2685 }
2686
2687 default:
2688 aEvent.Skip();
2689 return;
2690 }
2691
2693
2694 aEvent.Skip( false );
2695}
2696
2697
2699{
2700 wxAuiPaneInfo& hierarchyPane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2701 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
2702 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
2703 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
2704
2705 // Don't give the selection filter its own visibility controls; instead show it if
2706 // anything else is visible
2707 bool showFilter = ( hierarchyPane.IsShown() && hierarchyPane.IsDocked() )
2708 || ( netNavigatorPane.IsShown() && netNavigatorPane.IsDocked() )
2709 || ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
2710
2711 selectionFilterPane.Show( showFilter );
2712}
2713
2714
2715#ifdef KICAD_IPC_API
2716void SCH_EDIT_FRAME::onPluginAvailabilityChanged( wxCommandEvent& aEvt )
2717{
2718 wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
2720 aEvt.Skip();
2721}
2722#endif
2723
2724
2726{
2727 EESCHEMA_SETTINGS* cfg = eeconfig();
2728
2729 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
2730 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
2731
2733
2734 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
2735 searchPaneInfo.Show( m_show_search );
2736
2737 if( m_show_search )
2738 {
2739 searchPaneInfo.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
2740
2741 if( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
2742 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
2743 {
2744 SetAuiPaneSize( m_auimgr, searchPaneInfo, -1, cfg->m_AuiPanels.search_panel_height );
2745 }
2746 else if( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
2747 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
2748 {
2749 SetAuiPaneSize( m_auimgr, searchPaneInfo, cfg->m_AuiPanels.search_panel_width, -1 );
2750 }
2751
2752 m_searchPane->FocusSearch();
2753 m_searchPane->RefreshSearch();
2754 }
2755 else
2756 {
2757 cfg->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
2758 cfg->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
2759 cfg->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
2760 m_auimgr.Update();
2761 }
2762}
2763
2764
2766{
2767 if( !m_propertiesPanel )
2768 return;
2769
2770 bool show = !m_propertiesPanel->IsShownOnScreen();
2771
2772 wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
2773 propertiesPaneInfo.Show( show );
2774
2776
2777 EESCHEMA_SETTINGS* settings = eeconfig();
2778
2779 if( show )
2780 {
2781 SetAuiPaneSize( m_auimgr, propertiesPaneInfo,
2782 settings->m_AuiPanels.properties_panel_width, -1 );
2783 }
2784 else
2785 {
2786 settings->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
2787 m_auimgr.Update();
2788 }
2789}
2790
2791
2793{
2794 EESCHEMA_SETTINGS* cfg = eeconfig();
2795
2796 wxCHECK( cfg, /* void */ );
2797
2798 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2799
2800 hierarchy_pane.Show( !hierarchy_pane.IsShown() );
2801
2803
2804 if( hierarchy_pane.IsShown() )
2805 {
2806 if( hierarchy_pane.IsFloating() )
2807 {
2808 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
2810 m_auimgr.Update();
2811 }
2812 else if( cfg->m_AuiPanels.hierarchy_panel_docked_width > 0 )
2813 {
2814 // SetAuiPaneSize also updates m_auimgr
2815 SetAuiPaneSize( m_auimgr, hierarchy_pane,
2817 }
2818 }
2819 else
2820 {
2821 if( hierarchy_pane.IsFloating() )
2822 {
2823 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
2824 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
2825 }
2826 else
2827 {
2829 }
2830
2831 m_auimgr.Update();
2832 }
2833}
2834
2835
2837{
2838 EESCHEMA_SETTINGS* cfg = eeconfig();
2839
2840 wxCHECK( cfg, /* void */ );
2841
2842 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
2843
2844 db_library_pane.Show( !db_library_pane.IsShown() );
2845
2846 if( db_library_pane.IsShown() )
2847 {
2848 if( db_library_pane.IsFloating() )
2849 {
2850 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
2852 m_auimgr.Update();
2853 }
2855 {
2856 // SetAuiPaneSize also updates m_auimgr
2857 SetAuiPaneSize( m_auimgr, db_library_pane,
2859 }
2860 }
2861 else
2862 {
2863 if( db_library_pane.IsFloating() )
2864 {
2865 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
2866 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
2867 }
2868 else
2869 {
2871 }
2872
2873 m_auimgr.Update();
2874 }
2875}
2876
2878{
2879 wxCHECK( aSchematic, /* void */ );
2880
2881 if( m_schematic )
2882 m_schematic->SetProject( nullptr );
2883
2884 aSchematic->SetProject( &Prj() );
2885 delete m_schematic;
2886
2887 m_schematic = aSchematic;
2888 m_schematic->SetSchematicHolder( this );
2889
2890 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
2891 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
2892 m_toolManager->SetEnvironment( m_schematic, GetCanvas()->GetView(), GetCanvas()->GetViewControls(), config(),
2893 this );
2894}
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:114
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:104
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
@ icon_eeschema_16
@ icon_eeschema_32
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
static TOOL_ACTION toggleGrid
Definition actions.h:197
static TOOL_ACTION paste
Definition actions.h:80
static TOOL_ACTION cancelInteractive
Definition actions.h:72
static TOOL_ACTION unselectAll
Definition actions.h:83
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition actions.h:226
static TOOL_ACTION copy
Definition actions.h:78
static TOOL_ACTION group
Definition actions.h:238
static TOOL_ACTION pasteSpecial
Definition actions.h:81
static TOOL_ACTION ungroup
Definition actions.h:239
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:156
static TOOL_ACTION showSearch
Definition actions.h:115
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition actions.h:213
static TOOL_ACTION duplicate
Definition actions.h:84
static TOOL_ACTION doDelete
Definition actions.h:85
static TOOL_ACTION selectionTool
Definition actions.h:250
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:141
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:145
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:223
static TOOL_ACTION showProperties
Definition actions.h:265
static TOOL_ACTION cut
Definition actions.h:77
static TOOL_ACTION copyAsText
Definition actions.h:79
static TOOL_ACTION toggleGridOverrides
Definition actions.h:198
static TOOL_ACTION selectAll
Definition actions.h:82
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
Handles how to draw a screen (a board, a schematic ...)
Definition base_screen.h:41
void SetContentModified(bool aModified=true)
Definition base_screen.h:59
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:658
bool Empty() const
Definition commit.h:137
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:106
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
A subgraph is a set of items that are electrically connected on a single sheet.
Dialog to update or change schematic library symbols.
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
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.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
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.
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)
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
static const wxString DesignBlocksPaneName()
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
PROPERTIES_PANEL * m_propertiesPanel
bool m_showBorderAndTitleBlock
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition() but allows items to return their visual center rather than their anchor.
Definition eda_item.h:279
const KIID m_Uuid
Definition eda_item.h:516
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
void ClearBrightened()
Definition eda_item.h:138
void SetBrightened()
Definition eda_item.h:135
bool IsBrightened() const
Definition eda_item.h:129
Specialization of the wxAuiPaneInfo class for KiCad panels.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:80
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:98
SELECTION_CONDITION NoActiveTool()
Create a functor testing if there are no tools active in the frame.
SELECTION_CONDITION BoundingBoxes()
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION GridOverrides()
Create a functor testing if the grid overrides wires is enabled in a frame.
PANEL_ANNOTATE m_AnnotatePanel
bool empty() const
Definition sch_rtree.h:179
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:241
SEVERITY GetSeverity(int aErrorCode) const
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:95
void SetDefaultFont(const wxString &aFont)
Contains methods for drawing schematic-specific items.
Definition sch_painter.h:69
void SetSchematic(SCHEMATIC *aSchematic)
Definition sch_painter.h:79
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:60
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition sch_view.h:120
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Set the scaling factor, zooming around a given anchor point.
Definition sch_view.cpp:102
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:86
bool IsSCH_ITEM() const
Definition view_item.h:101
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:66
double GetScale() const
Definition view.h:276
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition view.h:400
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition view.h:220
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition view.cpp:596
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:1571
wxString AsString() const
Definition kiid.cpp:356
Definition kiid.h:49
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)
Definition eda_dde.cpp:99
void OnSockRequest(wxSocketEvent &evt)
Definition eda_dde.cpp:69
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:291
void OnKiCadExit()
Definition kiway.cpp:724
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:395
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
Definition kiway.cpp:198
@ FACE_SCH
eeschema DSO
Definition kiway.h:298
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition kiway.cpp:499
Define a library symbol object.
Definition lib_symbol.h:87
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Tree view item data for the net navigator.
A singleton reporter that reports to nowhere.
Definition reporter.h:216
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition page_info.h:168
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition page_info.h:159
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:158
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition project.cpp:164
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:388
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:88
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition schematic.h:191
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
SCHEMATIC_SETTINGS & Settings() const
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Definition schematic.h:119
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
void SetProject(PROJECT *aPrj)
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
void 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:40
static TOOL_ACTION rotateCCW
static TOOL_ACTION placeClassLabel
Definition sch_actions.h:79
static TOOL_ACTION placeSheetPin
Definition sch_actions.h:85
static TOOL_ACTION saveSheetAsDesignBlock
static TOOL_ACTION mirrorV
static TOOL_ACTION drawSheetFromFile
Definition sch_actions.h:83
static TOOL_ACTION toggleOPCurrents
static TOOL_ACTION saveToLinkedDesignBlock
Definition sch_actions.h:71
static TOOL_ACTION saveSelectionAsDesignBlock
static TOOL_ACTION placeGlobalLabel
Definition sch_actions.h:80
static TOOL_ACTION drawTextBox
Definition sch_actions.h:93
static TOOL_ACTION toggleAnnotateAuto
static TOOL_ACTION ddAddImage
static TOOL_ACTION drawArc
Definition sch_actions.h:97
static TOOL_ACTION drawSheet
Definition sch_actions.h:82
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:95
static TOOL_ACTION drawLines
Definition sch_actions.h:99
static TOOL_ACTION placeHierLabel
Definition sch_actions.h:81
static TOOL_ACTION alignTop
static TOOL_ACTION alignRight
static TOOL_ACTION placeLabel
Definition sch_actions.h:78
static TOOL_ACTION drawCircle
Definition sch_actions.h:96
static TOOL_ACTION placeBusWireEntry
Definition sch_actions.h:77
static TOOL_ACTION drawBezier
Definition sch_actions.h:98
static TOOL_ACTION drawWire
Definition sch_actions.h:72
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:76
static TOOL_ACTION markSimExclusions
static TOOL_ACTION drawRuleArea
static TOOL_ACTION placeSymbol
Definition sch_actions.h:66
static TOOL_ACTION placeImage
static TOOL_ACTION alignLeft
static TOOL_ACTION toggleERCErrors
static TOOL_ACTION alignCenterX
static TOOL_ACTION angleSnapModeChanged
static TOOL_ACTION placeLinkedDesignBlock
Definition sch_actions.h:70
static TOOL_ACTION drawSheetFromDesignBlock
Definition sch_actions.h:84
static TOOL_ACTION mirrorH
static TOOL_ACTION placeDesignBlock
Definition sch_actions.h:69
static TOOL_ACTION toggleOPVoltages
static TOOL_ACTION drawBus
Definition sch_actions.h:73
static TOOL_ACTION drawTable
Definition sch_actions.h:94
static TOOL_ACTION ddAppendFile
static TOOL_ACTION placeSchematicText
Definition sch_actions.h:92
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:75
static TOOL_ACTION toggleHiddenPins
static TOOL_ACTION syncSheetPins
Definition sch_actions.h:89
static TOOL_ACTION placePower
Definition sch_actions.h:68
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.
const wxString & getAutoSaveFileName() const
wxTreeCtrl * m_netNavigator
std::vector< std::unique_ptr< SCH_ITEM > > m_items_to_repeat
For the repeat-last-item cmd.
void FocusOnItem(EDA_ITEM *aItem, bool aAllowScroll=true) override
Focus on a particular canvas item.
void onResizeNetNavigator(wxSizeEvent &aEvent)
void updateSelectionFilterVisbility() override
Selection filter panel doesn't have a dedicated visibility control, so show it if any other AUI panel...
void onNetNavigatorSelChanging(wxTreeEvent &aEvent)
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void showNetNavigatorMenu(const wxTreeItemId &aItem)
void ShowAllIntersheetRefs(bool aShow)
void SaveProjectLocalSettings() override
Save changes to the project settings to the project (.pro) file.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void doCloseWindow() override
DIALOG_BOOK_REPORTER * m_diffSymbolDialog
void ToggleLibraryTree() override
void SetHighlightedConnection(const wxString &aConnection, const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
wxWindow * createHighlightedNetNavigator()
void onCloseErcDialog(wxCommandEvent &aEvent)
void UpdateHierarchySelection()
Update the hierarchy navigation tree selection (cross-probe from schematic to hierarchy pane).
bool m_syncingPcbToSchSelection
void SetScreen(BASE_SCREEN *aScreen) override
friend class SCH_EDITOR_CONTROL
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
Update a schematic symbol from a LIB_SYMBOL.
void onSize(wxSizeEvent &aEvent)
void CommonSettingsChanged(int aFlags) override
Called after the preferences dialog is run.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
BITMAP_BUTTON * m_netNavigatorMenuButton
void onNetNavigatorKey(wxKeyEvent &aEvent)
void configureToolbars() override
std::vector< wxEvtHandler * > m_schematicChangeListeners
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void OnClearFileHistory(wxCommandEvent &aEvent)
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
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 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 ...
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.
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.
void OnImportProject(wxCommandEvent &event)
double GetSchematicHopOverScale()
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
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.
static const wxString NetNavigatorPaneName()
void onCloseSymbolDiffDialog(wxCommandEvent &aEvent)
void IntersheetRefUpdate(SCH_GLOBALLABEL *aItem) override
Callback from schematic ref update.
void OnExit(wxCommandEvent &event)
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it).
wxTimer m_crossProbeFlashTimer
Timer to toggle selection visibility.
void AddSchematicChangeListener(wxEvtHandler *aListener)
Add aListener to post #EDA_EVT_SCHEMATIC_CHANGED command events to.
HIERARCHY_PANE * m_hierarchy
DIALOG_SYMBOL_FIELDS_TABLE * m_symbolFieldsTableDialog
std::unique_ptr< GRID_HELPER > MakeGridHelper() override
void UpdateHopOveredWires(SCH_ITEM *aItem)
SEVERITY GetSeverity(int aErrorCode) const override
void onNetNavigatorSelection(wxTreeEvent &aEvent)
void FindNetInInspector(const wxString &aNetName)
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Handle actions specific to the schematic editor.
A set of SCH_ITEMs (i.e., without duplicates).
Definition sch_group.h:52
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
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:137
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition sch_item.h:609
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:352
bool ResolveExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:274
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:42
void SetOperatingPoint(const wxString &aText)
Definition sch_line.h:348
bool IsWire() const
Return true if the line is a wire.
Definition sch_line.cpp:989
double GetLength() const
Definition sch_line.cpp:249
const wxString & GetOperatingPoint() const
Definition sch_line.h:347
Handle actions specific to the schematic editor.
void SetOperatingPoint(const wxString &aText)
Definition sch_pin.h:338
Tool that displays edit points allowing to modify items by dragging the points.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:731
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
const PAGE_INFO & GetPageSettings() const
Definition sch_screen.h:139
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:488
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition sch_screen.h:658
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:117
const wxString & GetFileName() const
Definition sch_screen.h:152
bool IsReadOnly() const
Definition sch_screen.h:155
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
bool m_zoomInitialized
Definition sch_screen.h:683
bool FileExists() const
Definition sch_screen.h:158
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...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
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()
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:113
Schematic symbol object.
Definition sch_symbol.h:75
EMBEDDED_FILES * GetEmbeddedFiles() override
SCH_SYMBOLs don't currently support embedded files, but their LIB_SYMBOL counterparts do.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
std::vector< 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.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
VECTOR2I GetPosition() const override
Definition sch_text.h:150
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:48
const SPICE_GENERATOR & SpiceGenerator() const
Definition sim_model.h:431
std::vector< std::reference_wrapper< const SIM_MODEL_PIN > > GetPins() const
virtual std::string ItemName(const SPICE_ITEM &aItem) const
Symbol library viewer main window.
The symbol library editor main window.
Symbol library viewer main window.
void AddTemplateFieldNames(const wxString &aSerializedFieldNames)
Add a serialized list of template field names.
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
TOOL_MANAGER * m_toolManager
TOOL_DISPATCHER * m_toolDispatcher
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
ACTIONS * m_actions
@ REDRAW
Full drawing refresh.
Definition tool_base.h:83
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:80
Generic, UI-independent tool event.
Definition tool_event.h:171
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.
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:429
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:129
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:169
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:52
#define IGNORE_PARENT_GROUP
Definition eda_item.h:55
@ ID_IMPORT_NON_KICAD_SCH
Definition eeschema_id.h:62
const wxAuiPaneInfo & defaultSchSelectionFilterPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultPropertiesPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultNetNavigatorPaneInfo()
const wxAuiPaneInfo & defaultDesignBlocksPaneInfo(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:42
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:35
@ FRAME_SCH_VIEWER
Definition frame_type.h:36
@ FRAME_SCH
Definition frame_type.h:34
@ FRAME_SIMULATOR
Definition frame_type.h:38
@ FRAME_CVPCB
Definition frame_type.h:52
@ FRAME_SYMBOL_CHOOSER
Definition frame_type.h:37
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition gestfich.cpp:143
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 AutoSaveFilePrefix
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:27
@ ID_FILE_LIST_CLEAR
Definition id.h:62
@ ID_EDA_SOCKET_EVENT
Definition id.h:132
@ ID_EDA_SOCKET_EVENT_SERV
Definition id.h:131
@ ID_FILEMAX
Definition id.h:60
@ ID_FILE1
Definition id.h:59
PROJECT & Prj()
Definition kicad.cpp:623
KIID niluuid(0)
#define KICTL_CREATE
caller thinks requested project files may not exist.
@ LAYER_ERC_WARN
Definition layer_ids.h:479
@ LAYER_ERC_EXCLUSION
Definition layer_ids.h:481
@ LAYER_ERC_ERR
Definition layer_ids.h:480
@ LAYER_OP_CURRENTS
Definition layer_ids.h:502
@ LAYER_INTERSHEET_REFS
Definition layer_ids.h:463
@ LAYER_OP_VOLTAGES
Definition layer_ids.h:501
@ MAIL_PCB_UPDATE
Definition mail_type.h:46
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:58
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:55
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition unix/app.cpp:90
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition unix/app.cpp:79
#define _HKI(x)
Definition page_info.cpp:44
PGM_BASE & Pgm()
The global program "get" accessor.
Definition pgm_base.cpp:946
see class PGM_BASE
SEVERITY
#define DIFF_SYMBOLS_DIALOG_NAME
#define CURRENT_TOOL(action)
@ AUTOPLACE_AUTO
Definition sch_item.h:70
SCH_CLEANUP_FLAGS
Definition schematic.h:74
@ GLOBAL_CLEANUP
Definition schematic.h:77
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
Implement a participant in the KIWAY alchemy.
Definition kiway.h:154
virtual void PreloadLibraries(PROJECT *aProject)
Definition kiway.h:257
std::string refName
wxLogTrace helper definitions.
@ SCH_GROUP_T
Definition typeinfo.h:177
@ SCH_LINE_T
Definition typeinfo.h:167
@ SCH_SYMBOL_T
Definition typeinfo.h:176
@ SCH_HIER_LABEL_T
Definition typeinfo.h:173
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:172
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
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.