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