KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_edit_frame.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <algorithm>
26#include <api/api_handler_sch.h>
27#include <api/api_server.h>
28#include <base_units.h>
29#include <bitmaps.h>
30#include <symbol_library.h>
31#include <confirm.h>
32#include <connection_graph.h>
33#include <dialogs/dialog_erc.h>
37#include <eeschema_id.h>
38#include <executable_names.h>
41#include <gestfich.h>
43#include <string_utils.h>
44#include <kiface_base.h>
45#include <kiplatform/app.h>
46#include <kiway.h>
47#include <symbol_edit_frame.h>
48#include <symbol_viewer_frame.h>
49#include <pgm_base.h>
50#include <core/profile.h>
53#include <python_scripting.h>
54#include <sch_edit_frame.h>
56#include <sch_painter.h>
57#include <sch_marker.h>
58#include <sch_sheet_pin.h>
59#include <sch_commit.h>
60#include <sch_rule_area.h>
62#include <advanced_config.h>
63#include <sim/simulator_frame.h>
64#include <tool/action_manager.h>
65#include <tool/action_toolbar.h>
66#include <tool/common_control.h>
67#include <tool/common_tools.h>
68#include <tool/embed_tool.h>
69#include <tool/picker_tool.h>
71#include <tool/selection.h>
73#include <tool/tool_manager.h>
74#include <tool/zoom_tool.h>
75#include <tools/sch_actions.h>
81#include <tools/sch_edit_tool.h>
87#include <tools/sch_move_tool.h>
90#include <unordered_set>
91#include <view/view_controls.h>
92#include <widgets/wx_infobar.h>
97#include <wx/cmdline.h>
98#include <wx/app.h>
99#include <wx/filedlg.h>
100#include <wx/socket.h>
101#include <wx/debug.h>
103#include <widgets/wx_aui_utils.h>
106#include <toolbars_sch_editor.h>
107#include <wx/log.h>
108
109#ifdef KICAD_IPC_API
111#include <api/api_utils.h>
112#endif
113
115
116
117#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
118
119
120BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
123
124 EVT_SIZE( SCH_EDIT_FRAME::OnSize )
125
128
130
131 EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
132 EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
133
134 // Drop files event
135 EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
136END_EVENT_TABLE()
137
138
139wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
140wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
141
142
143SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
144 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
146 m_ercDialog( nullptr ),
147 m_diffSymbolDialog( nullptr ),
148 m_symbolFieldsTableDialog( nullptr ),
149 m_netNavigator( nullptr ),
151 m_designBlocksPane( nullptr )
152{
153 m_maximizeByDefault = true;
154 m_schematic = new SCHEMATIC( &Prj() );
155 m_schematic->SetSchematicHolder( this );
157
158 m_showBorderAndTitleBlock = true; // true to show sheet references
159 m_supportsAutoSave = true;
161 m_aboutTitle = _HKI( "KiCad Schematic Editor" );
162 m_show_search = false;
163 // Ensure timer has an owner before binding so it generates events.
164 m_crossProbeFlashTimer.SetOwner( this );
165 Bind( wxEVT_TIMER, &SCH_EDIT_FRAME::OnCrossProbeFlashTimer, this, m_crossProbeFlashTimer.GetId() );
166
167 // Give an icon
168 wxIcon icon;
169 wxIconBundle icon_bundle;
170
171 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 48 ) );
172 icon_bundle.AddIcon( icon );
173 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 128 ) );
174 icon_bundle.AddIcon( icon );
175 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 256 ) );
176 icon_bundle.AddIcon( icon );
177 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
178 icon_bundle.AddIcon( icon );
179 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
180 icon_bundle.AddIcon( icon );
181
182 SetIcons( icon_bundle );
183
185
186 SCH_SHEET_PATH root;
187 root.push_back( &Schematic().Root() );
188 SetCurrentSheet( root );
189
190 setupTools();
193
197
198 // Ensure the "Line modes" toolbar group shows the current angle mode on startup
199 if( GetToolManager() )
201
202#ifdef KICAD_IPC_API
203 wxTheApp->Bind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED, &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
204#endif
205
206 m_hierarchy = new HIERARCHY_PANE( this );
207
208 // Initialize common print setup dialog settings.
209 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
210 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
211 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
212 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
213
214 m_searchPane = new SCH_SEARCH_PANE( this );
215 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
216
217 m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
218
221
222 m_auimgr.SetManagedWindow( this );
223
225
226 // Fetch a COPY of the config as a lot of these initializations are going to overwrite our
227 // data.
228 EESCHEMA_SETTINGS::AUI_PANELS aui_cfg = eeconfig()->m_AuiPanels;
229 EESCHEMA_SETTINGS::APPEARANCE appearance_cfg = eeconfig()->m_Appearance;
230
231 // Rows; layers 4 - 6
232 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( wxS( "TopMainToolbar" ) )
233 .Top().Layer( 6 ) );
234
235 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
236 .Bottom().Layer( 6 ) );
237
238 // Columns; layers 1 - 3
239 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
240 .Caption( _( "Schematic Hierarchy" ) )
241 .Left().Layer( 3 ).Position( 1 )
242 .TopDockable( false )
243 .BottomDockable( false )
244 .CloseButton( true )
245 .MinSize( FromDIP( wxSize( 120, 60 ) ) )
246 .BestSize( FromDIP( wxSize( 200, 200 ) ) )
247 .FloatingSize( FromDIP( wxSize( 200, 200 ) ) )
248 .FloatingPosition( FromDIP( wxPoint( 50, 50 ) ) )
249 .Show( false ) );
250
253
255
257
258 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( wxS( "LeftToolbar" ) )
259 .Left().Layer( 2 ) );
260
261 m_auimgr.AddPane( m_tbRight, EDA_PANE().VToolbar().Name( wxS( "RightToolbar" ) )
262 .Right().Layer( 2 ) );
263
264 // Center
265 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
266 .Center() );
267
268 m_auimgr.AddPane( m_searchPane, EDA_PANE()
269 .Name( SearchPaneName() )
270 .Bottom()
271 .Caption( _( "Search" ) )
272 .PaneBorder( false )
273 .MinSize( FromDIP( wxSize( 180, 60 ) ) )
274 .BestSize( FromDIP( wxSize( 180, 100 ) ) )
275 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
276 .CloseButton( true )
277 .DestroyOnClose( false )
278 .Show( m_show_search ) );
279
282
283 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
284 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
285 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
286 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
287 wxAuiPaneInfo& designBlocksPane = m_auimgr.GetPane( DesignBlocksPaneName() );
288
289 hierarchy_pane.Show( aui_cfg.show_schematic_hierarchy );
290 netNavigatorPane.Show( aui_cfg.show_net_nav_panel );
291 propertiesPane.Show( aui_cfg.show_properties );
292 designBlocksPane.Show( aui_cfg.design_blocks_show );
294
295 // The selection filter doesn't need to grow in the vertical direction when docked
296 selectionFilterPane.dock_proportion = 0;
297
298 if( aui_cfg.hierarchy_panel_float_width > 0 && aui_cfg.hierarchy_panel_float_height > 0 )
299 {
300 // Show at end, after positioning
301 hierarchy_pane.FloatingSize( aui_cfg.hierarchy_panel_float_width,
303 }
304
305 if( aui_cfg.net_nav_panel_float_size.GetWidth() > 0
306 && aui_cfg.net_nav_panel_float_size.GetHeight() > 0 )
307 {
308 netNavigatorPane.FloatingSize( aui_cfg.net_nav_panel_float_size );
309 netNavigatorPane.FloatingPosition( aui_cfg.net_nav_panel_float_pos );
310 }
311
312 if( aui_cfg.properties_panel_width > 0 )
313 SetAuiPaneSize( m_auimgr, propertiesPane, aui_cfg.properties_panel_width, -1 );
314
315 if( aui_cfg.schematic_hierarchy_float )
316 hierarchy_pane.Float();
317
318 if( aui_cfg.search_panel_height > 0
319 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_TOP
320 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
321 {
322 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
323 searchPane.Direction( aui_cfg.search_panel_dock_direction );
324 SetAuiPaneSize( m_auimgr, searchPane, -1, aui_cfg.search_panel_height );
325 }
326
327 else if( aui_cfg.search_panel_width > 0
328 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_LEFT
329 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
330 {
331 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
332 searchPane.Direction( aui_cfg.search_panel_dock_direction );
333 SetAuiPaneSize( m_auimgr, searchPane, aui_cfg.search_panel_width, -1 );
334 }
335
336 if( aui_cfg.float_net_nav_panel )
337 netNavigatorPane.Float();
338
339 if( aui_cfg.design_blocks_show )
340 SetAuiPaneSize( m_auimgr, designBlocksPane, aui_cfg.design_blocks_panel_docked_width, -1 );
341
342 if( aui_cfg.hierarchy_panel_docked_width > 0 )
343 {
344 // If the net navigator is not show, let the hierarchy navigator take all of the vertical
345 // space.
346 if( !aui_cfg.show_net_nav_panel )
347 {
348 SetAuiPaneSize( m_auimgr, hierarchy_pane, aui_cfg.hierarchy_panel_docked_width, -1 );
349 }
350 else
351 {
352 SetAuiPaneSize( m_auimgr, hierarchy_pane,
355
356 SetAuiPaneSize( m_auimgr, netNavigatorPane,
357 aui_cfg.net_nav_panel_docked_size.GetWidth(),
358 aui_cfg.net_nav_panel_docked_size.GetHeight() );
359 }
360
361 // wxAUI hack: force width by setting MinSize() and then Fixed()
362 // thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
363 hierarchy_pane.MinSize( aui_cfg.hierarchy_panel_docked_width, 60 );
364 hierarchy_pane.Fixed();
365 netNavigatorPane.MinSize( aui_cfg.net_nav_panel_docked_size.GetWidth(), 60 );
366 netNavigatorPane.Fixed();
367 m_auimgr.Update();
368
369 // now make it resizable again
370 hierarchy_pane.Resizable();
371 netNavigatorPane.Resizable();
372 m_auimgr.Update();
373
374 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
375 // back to minimum.
376 hierarchy_pane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
377 netNavigatorPane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
378 }
379 else
380 {
381 m_auimgr.Update();
382 }
383
386
387 GetCanvas()->GetGAL()->SetAxesEnabled( false );
388
389 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
390 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
391
394
395 view->SetLayerVisible( LAYER_ERC_ERR, appearance_cfg.show_erc_errors );
396 view->SetLayerVisible( LAYER_ERC_WARN, appearance_cfg.show_erc_warnings );
398 view->SetLayerVisible( LAYER_OP_VOLTAGES, appearance_cfg.show_op_voltages );
399 view->SetLayerVisible( LAYER_OP_CURRENTS, appearance_cfg.show_op_currents );
400
402
404 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging, this );
405 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
406 m_netNavigator->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onResizeNetNavigator, this );
407
408 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
409 // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
410 Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
411
412 setupUnits( eeconfig() );
413
414 // Net list generator
416
417 updateTitle();
418 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
419
420#ifdef KICAD_IPC_API
421 m_apiHandler = std::make_unique<API_HANDLER_SCH>( this );
422 Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
423#endif
424
425 // Default shutdown reason until a file is loaded
426 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
427
428 // Init for dropping files
432 m_acceptedExts.emplace( wxS( "jpeg" ), &SCH_ACTIONS::ddAddImage );
433 m_acceptedExts.emplace( wxS( "dxf" ), &SCH_ACTIONS::ddImportGraphics );
435 DragAcceptFiles( true );
436
437 // Ensure the window is on top
438 Raise();
439
440 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
441 // top-left corner of the canvas
442 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
443 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
444
445 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
446 Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
447 Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog, this );
448}
449
450void SCH_EDIT_FRAME::StartCrossProbeFlash( const std::vector<SCH_ITEM*>& aItems )
451{
452 if( !eeconfig()->m_CrossProbing.flash_selection )
453 {
454 wxLogTrace( "CROSS_PROBE_FLASH", "StartCrossProbeFlash: aborted (setting disabled) items=%zu", aItems.size() );
455 return;
456 }
457 if( aItems.empty() )
458 {
459 wxLogTrace( "CROSS_PROBE_FLASH", "StartCrossProbeFlash: aborted (no items)" );
460 return;
461 }
462
464 {
465 wxLogTrace( "CROSS_PROBE_FLASH", "StartCrossProbeFlash: restarting existing flash (phase=%d)", m_crossProbeFlashPhase );
467 }
468
469 wxLogTrace( "CROSS_PROBE_FLASH", "StartCrossProbeFlash: starting with %zu items", aItems.size() );
471 for( SCH_ITEM* it : aItems )
472 m_crossProbeFlashItems.push_back( it->m_Uuid );
473
476 if( !m_crossProbeFlashTimer.GetOwner() )
477 m_crossProbeFlashTimer.SetOwner( this );
478
479 bool started = m_crossProbeFlashTimer.Start( 500, wxTIMER_CONTINUOUS );
480 wxLogTrace( "CROSS_PROBE_FLASH", "StartCrossProbeFlash: timer start=%d id=%d", (int) started, m_crossProbeFlashTimer.GetId() );
481}
482
483
484void SCH_EDIT_FRAME::OnCrossProbeFlashTimer( wxTimerEvent& aEvent )
485{
486 wxLogTrace( "CROSS_PROBE_FLASH", "Timer(SCH) fired: phase=%d running=%d items=%zu", m_crossProbeFlashPhase, (int) m_crossProbeFlashing, m_crossProbeFlashItems.size() );
487
489 {
490 wxLogTrace( "CROSS_PROBE_FLASH", "Timer fired but not flashing (ignored)" );
491 return;
492 }
493
495 if( !selTool )
496 return;
497
498 bool prevGuard = m_syncingPcbToSchSelection;
500
501 if( m_crossProbeFlashPhase % 2 == 0 )
502 {
503 selTool->ClearSelection( true );
504 wxLogTrace( "CROSS_PROBE_FLASH", "Phase %d: cleared selection", m_crossProbeFlashPhase );
505 }
506 else
507 {
508 for( const KIID& id : m_crossProbeFlashItems )
509 {
510 if( SCH_ITEM* item = Schematic().ResolveItem( id, nullptr, true ) )
511 selTool->AddItemToSel( item, true );
512 }
513 wxLogTrace( "CROSS_PROBE_FLASH", "Phase %d: restored %zu items", m_crossProbeFlashPhase, m_crossProbeFlashItems.size() );
514 }
515
516 if( GetCanvas() )
517 {
519 wxLogTrace( "CROSS_PROBE_FLASH", "Phase %d: forced canvas refresh", m_crossProbeFlashPhase );
520 }
521
522 m_syncingPcbToSchSelection = prevGuard;
524
525 if( m_crossProbeFlashPhase > 6 )
526 {
527 for( const KIID& id : m_crossProbeFlashItems )
528 {
529 if( SCH_ITEM* item = Schematic().ResolveItem( id, nullptr, true ) )
530 selTool->AddItemToSel( item, true );
531 }
532
533 m_crossProbeFlashing = false;
535 wxLogTrace( "CROSS_PROBE_FLASH", "Flashing complete. Final selection size=%zu", m_crossProbeFlashItems.size() );
536 }
537}
538
539
541{
542 m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
543
544 // Ensure m_canvasType is up to date, to save it in config
546
547 SetScreen( nullptr );
548
549 if( m_schematic )
550 m_schematic->RemoveAllListeners();
551
552 // Delete all items not in draw list before deleting schematic
553 // to avoid dangling pointers stored in these items
556
557 delete m_schematic;
558 m_schematic = nullptr;
559
560 // Close the project if we are standalone, so it gets cleaned up properly
561 if( Kiface().IsSingle() )
562 {
563 try
564 {
565 GetSettingsManager()->UnloadProject( &Prj(), false );
566 }
567 catch( const nlohmann::detail::type_error& e )
568 {
569 wxFAIL_MSG( wxString::Format( wxT( "Settings exception occurred: %s" ), e.what() ) );
570 }
571 }
572
573 // We passed ownership of these to wxAuiManager.
574 // delete m_hierarchy;
575 // delete m_selectionFilterPanel;
576}
577
578
580{
581 aEvent.Skip();
582
583 // 1st Call: Handle the size update during the first resize event.
585
586 // Defer the second size capture
587 CallAfter( [this]()
588 {
590 } );
591}
592
593
595{
596 // Called when resizing the Hierarchy Navigator panel
597 // Store the current pane size
598 // It allows to retrieve the last defined pane size when switching between
599 // docked and floating pane state
600 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
601
602 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
603 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
604
605 if( cfg && m_hierarchy->IsShownOnScreen() )
606 {
607 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
608 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
609
610 // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
611 // width is > 0 (i.e. if its size is already set and has meaning)
612 // if it is floating, its size is not initialized (only floating_size is initialized)
613 // initializing hierarchy_pane.best_size is useful when switching to float pane and
614 // after switching to the docked pane, to retrieve the last docked pane width
615 if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
616 {
617 cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
618 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
619 }
620 }
621}
622
623
625{
626 // Create the manager and dispatcher & route draw panel events to the dispatcher
628 m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
629 GetCanvas()->GetViewControls(), config(), this );
630 m_actions = new SCH_ACTIONS();
632
633 // Register tools
634 m_toolManager->RegisterTool( new COMMON_CONTROL );
635 m_toolManager->RegisterTool( new COMMON_TOOLS );
636 m_toolManager->RegisterTool( new ZOOM_TOOL );
637 m_toolManager->RegisterTool( new SCH_SELECTION_TOOL );
638 m_toolManager->RegisterTool( new PICKER_TOOL );
639 m_toolManager->RegisterTool( new SCH_DRAWING_TOOLS );
640 m_toolManager->RegisterTool( new SCH_LINE_WIRE_BUS_TOOL );
641 m_toolManager->RegisterTool( new SCH_MOVE_TOOL );
642 m_toolManager->RegisterTool( new SCH_EDIT_TOOL );
643 m_toolManager->RegisterTool( new SCH_EDIT_TABLE_TOOL );
644 m_toolManager->RegisterTool( new SCH_GROUP_TOOL );
645 m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL );
646 m_toolManager->RegisterTool( new SCH_DESIGN_BLOCK_CONTROL );
647 m_toolManager->RegisterTool( new SCH_EDITOR_CONTROL );
648 m_toolManager->RegisterTool( new SCH_FIND_REPLACE_TOOL );
649 m_toolManager->RegisterTool( new SCH_POINT_EDITOR );
650 m_toolManager->RegisterTool( new SCH_NAVIGATE_TOOL );
651 m_toolManager->RegisterTool( new PROPERTIES_TOOL );
652 m_toolManager->RegisterTool( new EMBED_TOOL );
653 m_toolManager->InitTools();
654
655 // Run the selection tool, it is supposed to be always active
657
659}
660
661
663{
665
666 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
667 SCH_EDITOR_CONDITIONS cond( this );
668
669 wxASSERT( mgr );
670
671 auto hasElements =
672 [ this ] ( const SELECTION& aSel )
673 {
674 return GetScreen() &&
675 ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
676 };
677
678 auto searchPaneCond =
679 [this] ( const SELECTION& )
680 {
681 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
682 };
683
684 auto propertiesCond =
685 [this] ( const SELECTION& )
686 {
687 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
688 };
689
690 auto hierarchyNavigatorCond =
691 [ this ] ( const SELECTION& aSel )
692 {
693 return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
694 };
695
696 auto netNavigatorCond =
697 [ this ] (const SELECTION& aSel )
698 {
699 return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
700 };
701
702 auto designBlockCond =
703 [ this ] (const SELECTION& aSel )
704 {
705 return m_auimgr.GetPane( DesignBlocksPaneName() ).IsShown();
706 };
707
708 auto undoCond =
709 [ this ] (const SELECTION& aSel )
710 {
712 return true;
713
714 return GetUndoCommandCount() > 0;
715 };
716
717 auto groupWithDesignBlockLink =
718 [] ( const SELECTION& aSel )
719 {
720 if( aSel.Size() != 1 )
721 return false;
722
723 if( aSel[0]->Type() != SCH_GROUP_T )
724 return false;
725
726 SCH_GROUP* group = static_cast<SCH_GROUP*>( aSel.GetItem( 0 ) );
727
728 return group->HasDesignBlockLink();
729 };
730
731#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
732#define CHECK( x ) ACTION_CONDITIONS().Check( x )
733
735 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
737
738 mgr->SetConditions( SCH_ACTIONS::showSearch, CHECK( searchPaneCond ) );
739 mgr->SetConditions( SCH_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
740 mgr->SetConditions( SCH_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
741 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
742 mgr->SetConditions( SCH_ACTIONS::showDesignBlockPanel, CHECK( designBlockCond ) );
745
746 mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
747 mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
748 mgr->SetConditions( ACTIONS::copyAsText, ENABLE( hasElements ) );
751 mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
752 mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
753 mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
754 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
755
756 mgr->SetConditions( SCH_ACTIONS::rotateCW, ENABLE( hasElements ) );
757 mgr->SetConditions( SCH_ACTIONS::rotateCCW, ENABLE( hasElements ) );
758 mgr->SetConditions( SCH_ACTIONS::mirrorH, ENABLE( hasElements ) );
759 mgr->SetConditions( SCH_ACTIONS::mirrorV, ENABLE( hasElements ) );
762
763 mgr->SetConditions( SCH_ACTIONS::placeLinkedDesignBlock, ENABLE( groupWithDesignBlockLink ) );
764 mgr->SetConditions( SCH_ACTIONS::saveToLinkedDesignBlock, ENABLE( groupWithDesignBlockLink ) );
765
768
769 auto showHiddenPinsCond =
770 [this]( const SELECTION& )
771 {
772 return GetShowAllPins();
773 };
774
775 auto showHiddenFieldsCond =
776 [this]( const SELECTION& )
777 {
779 return cfg && cfg->m_Appearance.show_hidden_fields;
780 };
781
782 auto showDirectiveLabelsCond =
783 [this]( const SELECTION& )
784 {
786 return cfg && cfg->m_Appearance.show_directive_labels;
787 };
788
789 auto showERCErrorsCond =
790 [this]( const SELECTION& )
791 {
793 return cfg && cfg->m_Appearance.show_erc_errors;
794 };
795
796 auto showERCWarningsCond =
797 [this]( const SELECTION& )
798 {
800 return cfg && cfg->m_Appearance.show_erc_warnings;
801 };
802
803 auto showERCExclusionsCond =
804 [this]( const SELECTION& )
805 {
807 return cfg && cfg->m_Appearance.show_erc_exclusions;
808 };
809
810 auto markSimExclusionsCond =
811 [this]( const SELECTION& )
812 {
814 return cfg && cfg->m_Appearance.mark_sim_exclusions;
815 };
816
817 auto showOPVoltagesCond =
818 [this]( const SELECTION& )
819 {
821 return cfg && cfg->m_Appearance.show_op_voltages;
822 };
823
824 auto showOPCurrentsCond =
825 [this]( const SELECTION& )
826 {
828 return cfg && cfg->m_Appearance.show_op_currents;
829 };
830
831 auto showPinAltModeIconsCond =
832 [this]( const SELECTION& )
833 {
835 return cfg && cfg->m_Appearance.show_pin_alt_icons;
836 };
837
838 auto showAnnotateAutomaticallyCond =
839 [this]( const SELECTION& )
840 {
842 };
843
844 auto remapSymbolsCondition =
845 [&]( const SELECTION& aSel )
846 {
847 SCH_SCREENS schematic( Schematic().Root() );
848
849 // The remapping can only be performed on legacy projects.
850 return schematic.HasNoFullyDefinedLibIds();
851 };
852
853 auto belowRootSheetCondition =
854 [this]( const SELECTION& aSel )
855 {
856 SCH_NAVIGATE_TOOL* navigateTool = m_toolManager->GetTool<SCH_NAVIGATE_TOOL>();
857 return navigateTool && navigateTool->CanGoUp();
858 };
859
860 mgr->SetConditions( SCH_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
861
862 /* Some of these are bound by default to arrow keys which will get a different action if we
863 * disable the buttons. So always leave them enabled so the action is consistent.
864 * https://gitlab.com/kicad/code/kicad/-/issues/14783
865 mgr->SetConditions( SCH_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
866 mgr->SetConditions( SCH_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
867 mgr->SetConditions( SCH_ACTIONS::navigateBack, ENABLE( navHistoryHsBackward ) );
868 */
869
870 mgr->SetConditions( SCH_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
871 mgr->SetConditions( SCH_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
872 mgr->SetConditions( SCH_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
873 mgr->SetConditions( SCH_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
874 mgr->SetConditions( SCH_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
875 mgr->SetConditions( SCH_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
876 mgr->SetConditions( SCH_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
877 mgr->SetConditions( SCH_ACTIONS::markSimExclusions, CHECK( markSimExclusionsCond ) );
878 mgr->SetConditions( SCH_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
879 mgr->SetConditions( SCH_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
880 mgr->SetConditions( SCH_ACTIONS::togglePinAltIcons, CHECK( showPinAltModeIconsCond ) );
881 mgr->SetConditions( SCH_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
883
886
887#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
888
918
919#undef CURRENT_TOOL
920#undef CHECK
921#undef ENABLE
922}
923
924
926{
927 // we cannot store a pointer to an item in the display list here since
928 // that item may be deleted, such as part of a line concatenation or other.
929 // So simply always keep a copy of the object which is to be repeated.
930
931 if( aItem )
932 {
933 m_items_to_repeat.clear();
934
935 AddCopyForRepeatItem( aItem );
936 }
937}
938
939
941{
942 // we cannot store a pointer to an item in the display list here since
943 // that item may be deleted, such as part of a line concatenation or other.
944 // So simply always keep a copy of the object which is to be repeated.
945
946 if( aItem )
947 {
948 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate( IGNORE_PARENT_GROUP ) ) );
949
950 // Clone() preserves the flags & parent, we want 'em cleared.
951 repeatItem->ClearFlags();
952 repeatItem->SetParent( nullptr );
953
954 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
955 }
956}
957
958
959EDA_ITEM* SCH_EDIT_FRAME::ResolveItem( const KIID& aId, bool aAllowNullptrReturn ) const
960{
961 return Schematic().ResolveItem( aId, nullptr, aAllowNullptrReturn );
962}
963
964
969
970
975
976
978{
979 return *m_schematic;
980}
981
982
984{
985 return GetCurrentSheet().Last()->GetName();
986}
987
988
990{
992}
993
994
996{
997 m_schematic->CreateDefaultScreens();
998 SetScreen( Schematic().RootScreen() );
999
1000 if( GetScreen() == nullptr )
1001 {
1002 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
1003 SetScreen( screen );
1004 }
1005}
1006
1007
1009{
1010 return m_schematic->CurrentSheet();
1011}
1012
1013
1015{
1016 if( aSheet != GetCurrentSheet() )
1017 {
1018 ClearFocus();
1019
1020 Schematic().SetCurrentSheet( aSheet );
1021 GetCanvas()->DisplaySheet( aSheet.LastScreen() );
1022 }
1023}
1024
1025
1027{
1029
1030 for( SCH_ITEM* item : screen->Items() )
1031 item->ClearCaches();
1032
1033 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
1034 {
1035 wxCHECK2( libSymbol.second, continue );
1036 libSymbol.second->ClearCaches();
1037 }
1038
1039 if( Schematic().Settings().m_IntersheetRefsShow )
1041
1042 ClearFocus();
1043
1044 GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
1045
1046 if( SCH_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>() )
1047 selectionTool->Reset( TOOL_BASE::REDRAW );
1048
1050}
1051
1052
1053bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
1054{
1055 // Exit interactive editing
1056 // Note this this will commit *some* pending changes. For instance, the SCH_POINT_EDITOR
1057 // will cancel any drag currently in progress, but commit all changes from previous drags.
1058 if( m_toolManager )
1060
1061 // Shutdown blocks must be determined and vetoed as early as possible
1062 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
1063 && IsContentModified() )
1064 {
1065 return false;
1066 }
1067
1068 if( Kiface().IsSingle() )
1069 {
1070 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1071
1072 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
1073 return false;
1074
1075 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
1076
1077 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
1078 return false;
1079
1080 // SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
1081 // sorry.
1082 auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
1083
1084 if( chooser && !chooser->Close() ) // Can close symbol chooser?
1085 return false;
1086 }
1087 else
1088 {
1089 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1090
1091 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
1092 {
1093 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
1094 return false;
1095 }
1096 }
1097
1098 if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
1099 return false;
1100
1102 && !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
1103 {
1104 return false;
1105 }
1106
1107 // We may have gotten multiple events; don't clean up twice
1108 if( !Schematic().IsValid() )
1109 return false;
1110
1111 if( IsContentModified() )
1112 {
1113 wxFileName fileName = Schematic().RootScreen()->GetFileName();
1114 wxString msg = _( "Save changes to '%s' before closing?" );
1115
1116 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1117 [&]() -> bool
1118 {
1119 return SaveProject();
1120 } ) )
1121 {
1122 return false;
1123 }
1124 }
1125
1126 return true;
1127}
1128
1129
1131{
1133
1134 SCH_SHEET_LIST sheetlist = Schematic().Hierarchy();
1135
1136#ifdef KICAD_IPC_API
1137 Pgm().GetApiServer().DeregisterHandler( m_apiHandler.get() );
1138 wxTheApp->Unbind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED, &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
1139#endif
1140
1141 // Close modeless dialogs. They're trouble when they get destroyed after the frame.
1142 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
1143 Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
1144 Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog, this );
1145 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging, this );
1146 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
1147
1148 if( m_diffSymbolDialog )
1149 {
1150 m_diffSymbolDialog->Destroy();
1151 m_diffSymbolDialog = nullptr;
1152 }
1153
1154 if( m_ercDialog )
1155 {
1156 m_ercDialog->Destroy();
1157 m_ercDialog = nullptr;
1158 }
1159
1161 {
1162 m_symbolFieldsTableDialog->Destroy();
1163 m_symbolFieldsTableDialog = nullptr;
1164 }
1165
1166 // Make sure local settings are persisted
1167 if( Prj().GetLocalSettings().ShouldAutoSave() )
1169
1170 delete m_toolManager;
1171 m_toolManager = nullptr;
1172
1173 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
1174
1175 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
1176 {
1177 hierarchy_pane.Show( false );
1178 m_auimgr.Update();
1179 }
1180
1181 SCH_SCREENS screens( Schematic().Root() );
1182 wxFileName fn;
1183
1184 for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
1185 {
1186 fn = Prj().AbsolutePath( screen->GetFileName() );
1187
1188 // Auto save file name is the normal file name prepended with FILEEXT::AutoSaveFilePrefix.
1189 fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() );
1190
1191 if( fn.IsFileWritable() )
1192 wxRemoveFile( fn.GetFullPath() );
1193 }
1194
1195 wxFileName tmpFn = Prj().GetProjectFullName();
1196 wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
1197
1198 if( autoSaveFileName.IsFileWritable() )
1199 wxRemoveFile( autoSaveFileName.GetFullPath() );
1200
1201 sheetlist.ClearModifyStatus();
1202
1203 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
1204
1205 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
1206 UpdateFileHistory( fileName );
1207
1208 Schematic().RootScreen()->Clear( true );
1209
1210 // all sub sheets are deleted, only the main sheet is usable
1212
1213 // Clear view before destroying schematic as repaints depend on schematic being valid
1214 SetScreen( nullptr );
1215
1216 Schematic().Reset();
1217
1218 // Prevents any rogue events from continuing (i.e. search panel tries to redraw)
1219 Show( false );
1220
1221 Destroy();
1222}
1223
1224
1226{
1227 m_searchPane->FocusSearch();
1228}
1229
1230
1232{
1233 return Schematic().ErcSettings().GetSeverity( aErrorCode );
1234}
1235
1236
1238{
1240
1241 if( GetScreen() )
1243
1244 if( m_isClosing )
1245 return;
1246
1247 if( GetCanvas() )
1248 GetCanvas()->Refresh();
1249
1250 if( !GetTitle().StartsWith( wxS( "*" ) ) )
1251 updateTitle();
1252}
1253
1254
1256{
1257 if( Kiface().IsSingle() )
1258 {
1259 DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
1260 " in stand-alone mode. In order to create/update PCBs from"
1261 " schematics, launch the KiCad shell and create a project." ) );
1262 return;
1263 }
1264
1265 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1266 wxEventBlocker blocker( this );
1267
1268 if( !frame )
1269 {
1270 wxFileName fn = Prj().GetProjectFullName();
1271 fn.SetExt( FILEEXT::PcbFileExtension );
1272
1273 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1274
1275 // If Kiway() cannot create the Pcbnew frame, it shows a error message, and
1276 // frame is null
1277 if( !frame )
1278 return;
1279
1280 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1281 }
1282
1283 if( !frame->IsVisible() )
1284 frame->Show( true );
1285
1286 // On Windows, Raise() does not bring the window on screen, when iconized
1287 if( frame->IsIconized() )
1288 frame->Iconize( false );
1289
1290 frame->Raise();
1291
1292 std::string payload;
1294}
1295
1296
1297void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator, bool aClear )
1298{
1299 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
1300 m_hierarchy->UpdateHierarchyTree( aClear );
1301
1302 if( aRefreshNetNavigator )
1304}
1305
1306
1308{
1309 // Update only the hierarchy navigation tree labels.
1310 // The tree list is expected to be up to date
1311 m_hierarchy->UpdateLabelsHierarchyTree();
1312}
1313
1314
1316{
1317 m_hierarchy->UpdateHierarchySelection();
1318}
1319
1320
1321void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1322{
1323 wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1324
1325 if( fn.size() )
1326 OpenProjectFiles( std::vector<wxString>( 1, fn ) );
1327}
1328
1329
1330void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
1331{
1333}
1334
1335
1337{
1338 // Only standalone mode can directly load a new document
1339 if( !Kiface().IsSingle() )
1340 return;
1341
1342 wxString pro_dir = m_mruPath;
1343
1344 wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
1346
1347 if( dlg.ShowModal() != wxID_CANCEL )
1348 {
1349 // Enforce the extension, wxFileDialog is inept.
1350 wxFileName create_me =
1352
1353 if( create_me.FileExists() )
1354 {
1355 wxString msg;
1356 msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
1357 DisplayError( this, msg );
1358 return ;
1359 }
1360
1361 // OpenProjectFiles() requires absolute
1362 wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
1363
1364 OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1365 m_mruPath = create_me.GetPath();
1366 }
1367}
1368
1369
1371{
1372 // Only standalone mode can directly load a new document
1373 if( !Kiface().IsSingle() )
1374 return;
1375
1376 wxString pro_dir = m_mruPath;
1377 wxString wildcards = FILEEXT::AllSchematicFilesWildcard()
1379 + wxS( "|" ) + FILEEXT::LegacySchematicFileWildcard();
1380
1381 wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
1382 wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1383
1384 if( dlg.ShowModal() != wxID_CANCEL )
1385 {
1386 OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1388 }
1389}
1390
1391
1393{
1394 wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
1395
1396 if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
1397 {
1398 kicad_board.SetExt( FILEEXT::PcbFileExtension );
1399 wxFileName legacy_board( kicad_board );
1400 legacy_board.SetExt( FILEEXT::LegacyPcbFileExtension );
1401 wxFileName& boardfn = legacy_board;
1402
1403 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1404 boardfn = kicad_board;
1405
1406 if( Kiface().IsSingle() )
1407 {
1408 ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
1409 }
1410 else
1411 {
1412 wxEventBlocker blocker(this);
1413 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1414
1415 if( !frame )
1416 {
1417 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1418
1419 // frame can be null if Cvpcb cannot be run. No need to show a warning
1420 // Kiway() generates the error messages
1421 if( !frame )
1422 return;
1423
1424 frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1425 }
1426
1427 if( !frame->IsVisible() )
1428 frame->Show( true );
1429
1430 // On Windows, Raise() does not bring the window on screen, when iconized
1431 if( frame->IsIconized() )
1432 frame->Iconize( false );
1433
1434 frame->Raise();
1435 }
1436 }
1437 else
1438 {
1440 }
1441}
1442
1443
1445{
1446 wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1447 fn.SetExt( FILEEXT::NetlistFileExtension );
1448
1449 if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1450 return;
1451
1452 try
1453 {
1454 KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1455
1456 if( !player )
1457 {
1458 player = Kiway().Player( FRAME_CVPCB, true );
1459
1460 // player can be null if Cvpcb cannot be run. No need to show a warning
1461 // Kiway() generates the error messages
1462 if( !player )
1463 return;
1464
1465 player->Show( true );
1466 }
1467
1468 // Ensure the netlist (mainly info about symbols) is up to date
1471
1472 player->Raise();
1473 }
1474 catch( const IO_ERROR& )
1475 {
1476 DisplayError( this, _( "Could not open CvPcb" ) );
1477 }
1478}
1479
1480
1481void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1482{
1483 if( event.GetId() == wxID_EXIT )
1484 Kiway().OnKiCadExit();
1485
1486 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1487 Close( false );
1488}
1489
1490
1492{
1493 SCHEMATIC_SETTINGS& settings = m_schematic->Settings();
1494 SIM_LIB_MGR simLibMgr( &Prj() );
1495 NULL_REPORTER devnull;
1496
1497 // Patch for bug early in V7.99 dev
1498 if( settings.m_OPO_VRange.EndsWith( 'A' ) )
1499 settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
1500
1501 // Update items which may have ${OP} text variables
1502 //
1504 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1505 {
1506 int flags = 0;
1507
1508 auto invalidateTextVars =
1509 [&flags]( EDA_TEXT* text )
1510 {
1511 if( text->HasTextVars() )
1512 {
1513 text->ClearRenderCache();
1514 text->ClearBoundingBoxCache();
1516 }
1517 };
1518
1519 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1520 {
1521 item->RunOnChildren(
1522 [&invalidateTextVars]( SCH_ITEM* aChild )
1523 {
1524 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1525 invalidateTextVars( text );
1526 },
1528 }
1529
1530 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1531 invalidateTextVars( text );
1532
1533 return flags;
1534 } );
1535
1536 // Update OP overlay items
1537 //
1538 for( SCH_ITEM* item : GetScreen()->Items() )
1539 {
1540 if( GetCurrentSheet().GetExcludedFromSim() )
1541 continue;
1542
1543 if( item->Type() == SCH_LINE_T )
1544 {
1545 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1546
1547 if( !line->GetOperatingPoint().IsEmpty() )
1548 GetCanvas()->GetView()->Update( line );
1549
1550 line->SetOperatingPoint( wxEmptyString );
1551
1552 // update value from netlist, below
1553 }
1554 else if( item->Type() == SCH_SYMBOL_T )
1555 {
1556 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1557 wxString ref = symbol->GetRef( &GetCurrentSheet() );
1558 std::vector<SCH_PIN*> pins = symbol->GetPins( &GetCurrentSheet() );
1559
1560 // Power symbols and other symbols which have the reference starting with "#" are
1561 // not included in simulation
1562 if( ref.StartsWith( '#' ) || symbol->ResolveExcludedFromSim() )
1563 continue;
1564
1565 for( SCH_PIN* pin : pins )
1566 {
1567 if( !pin->GetOperatingPoint().IsEmpty() )
1568 GetCanvas()->GetView()->Update( pin );
1569
1570 pin->SetOperatingPoint( wxEmptyString );
1571 }
1572
1573 if( pins.size() == 2 )
1574 {
1575 wxString op = m_schematic->GetOperatingPoint( ref, settings.m_OPO_IPrecision,
1576 settings.m_OPO_IRange );
1577
1578 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1579 {
1580 pins[0]->SetOperatingPoint( op );
1581 GetCanvas()->GetView()->Update( symbol );
1582 }
1583 }
1584 else
1585 {
1586 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
1587 embeddedFilesStack.push_back( m_schematic->GetEmbeddedFiles() );
1588
1589 if( EMBEDDED_FILES* symbolEmbeddedFiles = symbol->GetEmbeddedFiles() )
1590 embeddedFilesStack.push_back( symbolEmbeddedFiles );
1591
1592 simLibMgr.SetFilesStack( std::move( embeddedFilesStack ) );
1593
1594 SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol, true, 0, devnull ).model;
1595
1596 SPICE_ITEM spiceItem;
1597 spiceItem.refName = ref;
1598 ref = model.SpiceGenerator().ItemName( spiceItem );
1599
1600 for( const auto& modelPin : model.GetPins() )
1601 {
1602 SCH_PIN* symbolPin = symbol->GetPin( modelPin.get().symbolPinNumber );
1603 wxString signalName = ref + wxS( ":" ) + modelPin.get().modelPinName;
1604 wxString op = m_schematic->GetOperatingPoint( signalName,
1605 settings.m_OPO_IPrecision,
1606 settings.m_OPO_IRange );
1607
1608 if( symbolPin && !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1609 {
1610 symbolPin->SetOperatingPoint( op );
1611 GetCanvas()->GetView()->Update( symbol );
1612 }
1613 }
1614 }
1615 }
1616 }
1617
1618 for( const auto& [ key, subgraphList ] : m_schematic->m_connectionGraph->GetNetMap() )
1619 {
1620 wxString op = m_schematic->GetOperatingPoint( key.Name, settings.m_OPO_VPrecision,
1621 settings.m_OPO_VRange );
1622
1623 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1624 {
1625 for( CONNECTION_SUBGRAPH* subgraph : subgraphList )
1626 {
1627 SCH_LINE* longestWire = nullptr;
1628 double length = 0.0;
1629
1630 if( subgraph->GetSheet().GetExcludedFromSim() )
1631 continue;
1632
1633 for( SCH_ITEM* item : subgraph->GetItems() )
1634 {
1635 if( item->Type() == SCH_LINE_T )
1636 {
1637 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1638
1639 if( line->IsWire() && line->GetLength() > length )
1640 {
1641 longestWire = line;
1642 length = line->GetLength();
1643 }
1644 }
1645 }
1646
1647 if( longestWire )
1648 {
1649 longestWire->SetOperatingPoint( op );
1650 GetCanvas()->GetView()->Update( longestWire );
1651 }
1652 }
1653 }
1654 }
1655}
1656
1657
1659{
1660 if( aItem->Type() == SCH_GLOBAL_LABEL_T || aItem->Type() == SCH_HIER_LABEL_T )
1661 {
1662 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
1663
1664 if( label->AutoRotateOnPlacement() )
1665 {
1666 SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
1667 label->GetSpinStyle(),
1668 &GetCurrentSheet() );
1669
1670 if( spin != label->GetSpinStyle() )
1671 {
1672 label->SetSpinStyle( spin );
1673
1674 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1675 {
1676 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1677
1678 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1679 otherLabel->AutoplaceFields( aScreen, AUTOPLACE_AUTO );
1680 }
1681 }
1682 }
1683 }
1684}
1685
1686
1688{
1689 SCH_SCREEN* screen = GetScreen();
1690
1691 wxCHECK( screen, /* void */ );
1692
1693 wxString title;
1694
1695 if( !screen->GetFileName().IsEmpty() )
1696 {
1697 wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1698 bool readOnly = false;
1699 bool unsaved = false;
1700
1701 if( fn.IsOk() && screen->FileExists() )
1702 readOnly = screen->IsReadOnly();
1703 else
1704 unsaved = true;
1705
1706 if( IsContentModified() )
1707 title = wxT( "*" );
1708
1709 title += fn.GetName();
1710
1711 wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
1712
1713 if( sheetPath != title )
1714 title += wxString::Format( wxT( " [%s]" ), sheetPath );
1715
1716 if( readOnly )
1717 title += wxS( " " ) + _( "[Read Only]" );
1718
1719 if( unsaved )
1720 title += wxS( " " ) + _( "[Unsaved]" );
1721 }
1722 else
1723 {
1724 title = _( "[no schematic loaded]" );
1725 }
1726
1727 title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1728
1729 SetTitle( title );
1730}
1731
1732
1738
1739
1741 PROGRESS_REPORTER* aProgressReporter )
1742{
1743 wxString highlightedConn = GetHighlightedConnection();
1744 bool hasHighlightedConn = !highlightedConn.IsEmpty();
1745
1746 std::function<void( SCH_ITEM* )> changeHandler =
1747 [&]( SCH_ITEM* aChangedItem ) -> void
1748 {
1749 GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1750
1751 SCH_CONNECTION* connection = aChangedItem->Connection();
1752
1754 return;
1755
1756 if( !hasHighlightedConn )
1757 {
1758 // No highlighted connection, but connectivity has changed, so refresh
1759 // the list of all nets
1761 }
1762 else if( connection
1763 && ( connection->Name() == highlightedConn
1764 || connection->HasDriverChanged() ) )
1765 {
1767 }
1768 };
1769
1770 Schematic().RecalculateConnections( aCommit, aCleanupFlags,
1772 aProgressReporter,
1773 GetCanvas()->GetView(),
1774 &changeHandler,
1775 m_undoList.m_CommandsList.empty() ? nullptr
1776 : m_undoList.m_CommandsList.back() );
1777
1779 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1780 {
1781 int flags = 0;
1782 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
1783 SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
1784
1785 auto invalidateTextVars =
1786 [&flags]( EDA_TEXT* text )
1787 {
1788 if( text->HasTextVars() )
1789 {
1790 text->ClearRenderCache();
1791 text->ClearBoundingBoxCache();
1793 }
1794 };
1795
1796 if( connection && connection->HasDriverChanged() )
1797 {
1798 connection->ClearDriverChanged();
1799 flags |= KIGFX::REPAINT;
1800 }
1801
1802 if( item )
1803 {
1804 item->RunOnChildren(
1805 [&invalidateTextVars]( SCH_ITEM* aChild )
1806 {
1807 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1808 invalidateTextVars( text );
1809 },
1811
1812 if( flags & KIGFX::GEOMETRY )
1813 GetScreen()->Update( item, false ); // Refresh RTree
1814 }
1815
1816 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1817 invalidateTextVars( text );
1818
1819 return flags;
1820 } );
1821
1823 || !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
1824 {
1828 }
1829}
1830
1831
1836
1837
1839{
1840 GetCanvas()->GetView()->Update( aItem );
1841}
1842
1843
1850
1851
1852std::unique_ptr<GRID_HELPER> SCH_EDIT_FRAME::MakeGridHelper()
1853{
1854 return std::make_unique<EE_GRID_HELPER>( m_toolManager );
1855}
1856
1857
1859{
1861
1862 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1863
1866
1868
1869 if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
1870 {
1871 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1872 GetRenderSettings()->SetDefaultFont( cfg->m_Appearance.default_font );
1873
1874 KIGFX::VIEW* view = GetCanvas()->GetView();
1875 view->SetLayerVisible( LAYER_ERC_ERR, cfg->m_Appearance.show_erc_errors );
1876 view->SetLayerVisible( LAYER_ERC_WARN, cfg->m_Appearance.show_erc_warnings );
1877 view->SetLayerVisible( LAYER_ERC_EXCLUSION, cfg->m_Appearance.show_erc_exclusions );
1878 view->SetLayerVisible( LAYER_OP_VOLTAGES, cfg->m_Appearance.show_op_voltages );
1879 view->SetLayerVisible( LAYER_OP_CURRENTS, cfg->m_Appearance.show_op_currents );
1880
1881 GetRenderSettings()->m_ShowPinAltIcons = cfg->m_Appearance.show_pin_alt_icons;
1882
1884
1885 settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
1886
1887 if( !cfg->m_Drawing.field_names.IsEmpty() )
1888 settings.m_TemplateFieldNames.AddTemplateFieldNames( cfg->m_Drawing.field_names );
1889 }
1890
1892
1893 for( SCH_ITEM* item : screen->Items() )
1894 {
1895 item->ClearCaches();
1896
1897 if( item->Type() == SCH_LINE_T )
1898 {
1899 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1900
1901 if( line->IsWire() )
1902 UpdateHopOveredWires( line );
1903 }
1904 }
1905
1906 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
1907 libSymbol->ClearCaches();
1908
1910
1912 Layout();
1913 SendSizeEvent();
1914}
1915
1916
1918{
1919 // Store the current zoom level into the current screen before calling
1920 // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
1922
1923 // Rebuild the sheet view (draw area and any other items):
1925}
1926
1927
1929{
1930 // call my base class
1932
1933 // tooltips in toolbars
1935
1936 // For some obscure reason, the AUI manager hides the first modified pane.
1937 // So force show panes
1938 wxAuiPaneInfo& design_blocks_pane_info = m_auimgr.GetPane( m_designBlocksPane );
1939 bool panel_shown = design_blocks_pane_info.IsShown();
1940 design_blocks_pane_info.Caption( _( "Design Blocks" ) );
1941 design_blocks_pane_info.Show( panel_shown );
1942
1943 m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
1944 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
1945 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
1946 m_auimgr.GetPane( m_designBlocksPane ).Caption( _( "Design Blocks" ) );
1947 m_auimgr.Update();
1948 m_hierarchy->UpdateHierarchyTree();
1949
1950 // status bar
1952
1953 updateTitle();
1954
1955 // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1956 // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1957 // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1958 // toolbar to update correctly.
1959#if defined( __WXMSW__ )
1960 PostSizeEvent();
1961#endif
1962}
1963
1964
1966{
1967 if( !GetHighlightedConnection().IsEmpty() )
1968 {
1969 SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
1971 }
1972 else
1973 {
1974 SetStatusText( wxT( "" ) );
1975 }
1976}
1977
1978
1980{
1981 if( m_toolManager )
1983
1984 SCH_BASE_FRAME::SetScreen( aScreen );
1985 GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1986
1987 if( m_toolManager )
1989}
1990
1991
1992const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1993{
1994 BOX2I bBoxDoc;
1995
1996 if( aIncludeAllVisible )
1997 {
1998 // Get the whole page size and return that
1999 int sizeX = GetScreen()->GetPageSettings().GetWidthIU( schIUScale.IU_PER_MILS );
2000 int sizeY = GetScreen()->GetPageSettings().GetHeightIU( schIUScale.IU_PER_MILS );
2001 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
2002 }
2003 else
2004 {
2005 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
2007 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
2008
2009 // Calc the bounding box of all items on screen except the page border
2010 for( EDA_ITEM* item : GetScreen()->Items() )
2011 {
2012 if( item != dsAsItem ) // Ignore the drawing-sheet itself
2013 bBoxDoc.Merge( item->GetBoundingBox() );
2014 }
2015 }
2016
2017 return bBoxDoc;
2018}
2019
2020
2022{
2023 return Schematic().Hierarchy().IsModified();
2024}
2025
2026
2028{
2029 EESCHEMA_SETTINGS* cfg = eeconfig();
2030 return cfg && cfg->m_Appearance.show_hidden_pins;
2031}
2032
2033
2034void SCH_EDIT_FRAME::FocusOnItem( EDA_ITEM* aItem, bool aAllowScroll )
2035{
2036 // nullptr will clear the current focus
2037 if( aItem != nullptr && !aItem->IsSCH_ITEM() )
2038 return;
2039
2040 static KIID lastBrightenedItemID( niluuid );
2041
2042 SCH_ITEM* lastItem = Schematic().ResolveItem( lastBrightenedItemID, nullptr, true );
2043
2044 if( lastItem && lastItem != aItem )
2045 {
2046 lastItem->ClearBrightened();
2047
2048 UpdateItem( lastItem );
2049 lastBrightenedItemID = niluuid;
2050 }
2051
2052 if( aItem )
2053 {
2054 if( !aItem->IsBrightened() )
2055 {
2056 aItem->SetBrightened();
2057
2058 UpdateItem( aItem );
2059 lastBrightenedItemID = aItem->m_Uuid;
2060 }
2061
2062 FocusOnLocation( aItem->GetFocusPosition(), aAllowScroll );
2063 }
2064}
2065
2066
2068{
2069 return Schematic().GetFileName();
2070}
2071
2072
2074{
2075 return m_toolManager->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
2076}
2077
2078
2079void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2080{
2081 if( IsShown() )
2082 {
2083 // We only need this until the frame is done resizing and the final client size is
2084 // established.
2085 Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
2087 }
2088
2089 // Skip() is called in the base class.
2090 EDA_DRAW_FRAME::OnSize( aEvent );
2091}
2092
2093
2095 const KIID& aSchematicSymbolUUID )
2096{
2097 SCH_SHEET_PATH principalPath;
2098 SCH_SHEET_LIST sheets = Schematic().Hierarchy();
2099 SCH_ITEM* item = sheets.ResolveItem( aSchematicSymbolUUID, &principalPath, true );
2100 SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
2101 SCH_COMMIT commit( m_toolManager );
2102
2103 if( !principalSymbol )
2104 return;
2105
2106 wxString principalRef;
2107
2108 if( principalSymbol->IsAnnotated( &principalPath ) )
2109 principalRef = principalSymbol->GetRef( &principalPath, false );
2110
2111 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
2112
2113 for( const SCH_SHEET_PATH& path : sheets )
2114 {
2115 for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2116 {
2117 SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
2118
2119 if( candidateSymbol == principalSymbol
2120 || ( candidateSymbol->IsAnnotated( &path )
2121 && candidateSymbol->GetRef( &path, false ) == principalRef ) )
2122 {
2123 allUnits.emplace_back( candidateSymbol, path );
2124 }
2125 }
2126 }
2127
2128 for( auto& [ unit, path ] : allUnits )
2129 {
2130 // This needs to be done before the LIB_SYMBOL is changed to prevent stale
2131 // library symbols in the schematic file.
2132 path.LastScreen()->Remove( unit );
2133
2134 if( !unit->IsNew() )
2135 commit.Modify( unit, path.LastScreen() );
2136
2137 unit->SetLibSymbol( aSymbol.Flatten().release() );
2138 unit->UpdateFields( &GetCurrentSheet(),
2139 true, /* update style */
2140 true, /* update ref */
2141 true, /* update other fields */
2142 false, /* reset ref */
2143 false /* reset other fields */ );
2144
2145 path.LastScreen()->Append( unit );
2146 GetCanvas()->GetView()->Update( unit );
2147 }
2148
2149 // Clear any orphaned alternate pins.
2150 for( SCH_PIN* pin : principalSymbol->GetPins() )
2151 {
2152 wxString altName = pin->GetAlt();
2153
2154 if( altName.IsEmpty() )
2155 continue;
2156
2157 if( pin->GetAlternates().count( altName ) == 0 )
2158 pin->SetAlt( wxEmptyString );
2159 }
2160
2161 if( !commit.Empty() )
2162 commit.Push( _( "Save Symbol to Schematic" ) );
2163}
2164
2165
2166void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2167{
2168 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2169
2170 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
2171 sch_item->ClearCaches();
2172}
2173
2174
2176{
2177 wxCHECK( m_toolManager, /* void */ );
2178
2182
2183 wxCHECK( screen, /* void */ );
2184
2186
2187 SCH_BASE_FRAME::SetScreen( screen );
2188
2189 SetSheetNumberAndCount(); // will also update CurrentScreen()'s sheet number info
2190
2192
2193 // update the references, units, and intersheet-refs
2195
2196 // dangling state can also have changed if different units with different pin locations are
2197 // used
2200
2201 SCH_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>();
2202
2203 wxCHECK( selectionTool, /* void */ );
2204
2205 auto visit =
2206 [&]( EDA_ITEM* item )
2207 {
2209 && !m_findReplaceData->findString.IsEmpty()
2210 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
2211 {
2212 item->SetForceVisible( true );
2213 selectionTool->BrightenItem( item );
2214 }
2215 else if( item->IsBrightened() )
2216 {
2217 item->SetForceVisible( false );
2218 selectionTool->UnbrightenItem( item );
2219 }
2220 };
2221
2222 for( SCH_ITEM* item : screen->Items() )
2223 {
2224 visit( item );
2225
2226 item->RunOnChildren(
2227 [&]( SCH_ITEM* aChild )
2228 {
2229 visit( aChild );
2230 },
2232 }
2233
2234 if( !screen->m_zoomInitialized )
2235 {
2237 }
2238 else
2239 {
2240 // Set zoom to last used in this screen
2241 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
2242 GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
2243 }
2244
2245 updateTitle();
2246
2247 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
2248
2249 // Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
2251
2252 SCH_EDITOR_CONTROL* editTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
2253
2254 wxCHECK( editTool, /* void */ );
2255
2257 editTool->UpdateNetHighlighting( dummy );
2258
2259 m_hierarchy->UpdateHierarchySelection();
2260
2261 m_schematic->OnSchSheetChanged();
2262}
2263
2264
2266{
2267 if( !m_diffSymbolDialog )
2268 {
2270 _( "Compare Symbol with Library" ) );
2271
2272 m_diffSymbolDialog->m_sdbSizerApply->SetLabel( _( "Update Symbol from Library..." ) );
2273 m_diffSymbolDialog->m_sdbSizerApply->Show();
2274 }
2275
2276 return m_diffSymbolDialog;
2277}
2278
2279
2280void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
2281{
2282 if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
2283 {
2284 if( aEvent.GetId() == wxID_APPLY )
2285 {
2286 KIID symbolUUID = m_diffSymbolDialog->GetUserItemID();
2287
2288 CallAfter(
2289 [this, symbolUUID]()
2290 {
2291 EDA_ITEM* item = ResolveItem( symbolUUID );
2292
2293 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item ) )
2294 {
2295 m_toolManager->RunAction<EDA_ITEM*>( ACTIONS::selectItem, symbol );
2296
2298 dlg.ShowQuasiModal();
2299 }
2300 } );
2301 }
2302
2303 m_diffSymbolDialog->Destroy();
2304 m_diffSymbolDialog = nullptr;
2305 }
2306}
2307
2308
2310{
2311 if( !m_ercDialog )
2312 m_ercDialog = new DIALOG_ERC( this );
2313
2314 return m_ercDialog;
2315}
2316
2317
2318void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
2319{
2320 if( m_ercDialog )
2321 {
2322 m_ercDialog->Destroy();
2323 m_ercDialog = nullptr;
2324 }
2325}
2326
2327
2335
2336
2338{
2340 {
2341 m_symbolFieldsTableDialog->Destroy();
2342 m_symbolFieldsTableDialog = nullptr;
2343 }
2344}
2345
2346
2347void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
2348{
2349 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(), aListener );
2350
2351 // Don't add duplicate listeners.
2352 if( it == m_schematicChangeListeners.end() )
2353 m_schematicChangeListeners.push_back( aListener );
2354}
2355
2356
2358{
2359 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(), aListener );
2360
2361 // Don't add duplicate listeners.
2362 if( it != m_schematicChangeListeners.end() )
2363 m_schematicChangeListeners.erase( it );
2364}
2365
2366
2368{
2369 m_netNavigator = new wxTreeCtrl( this, wxID_ANY, wxPoint( 0, 0 ), FromDIP( wxSize( 160, 250 ) ),
2370 wxTR_DEFAULT_STYLE | wxNO_BORDER );
2371
2372 return m_netNavigator;
2373}
2374
2375
2376void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection,
2377 const NET_NAVIGATOR_ITEM_DATA* aSelection )
2378{
2379 bool refreshNetNavigator = aConnection != m_highlightedConn;
2380
2381 m_highlightedConn = aConnection;
2382
2383 if( refreshNetNavigator )
2384 RefreshNetNavigator( aSelection );
2385}
2386
2387
2389{
2390 if( m_netNavigator )
2391 {
2392 NET_NAVIGATOR_ITEM_DATA itemData;
2393 wxTreeItemId selection = m_netNavigator->GetSelection();
2394 bool refreshSelection = selection.IsOk() && ( selection != m_netNavigator->GetRootItem() );
2395
2396 if( refreshSelection )
2397 {
2399 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
2400
2401 wxCHECK( tmp, /* void */ );
2402 itemData = *tmp;
2403 }
2404
2405 m_netNavigator->DeleteAllItems();
2406 RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
2407 }
2408
2410}
2411
2412
2414{
2415 wxAuiPaneInfo& hierarchyPane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2416 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
2417 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
2418 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
2419
2420 // Don't give the selection filter its own visibility controls; instead show it if
2421 // anything else is visible
2422 bool showFilter = ( hierarchyPane.IsShown() && hierarchyPane.IsDocked() )
2423 || ( netNavigatorPane.IsShown() && netNavigatorPane.IsDocked() )
2424 || ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
2425
2426 selectionFilterPane.Show( showFilter );
2427}
2428
2429
2430#ifdef KICAD_IPC_API
2431void SCH_EDIT_FRAME::onPluginAvailabilityChanged( wxCommandEvent& aEvt )
2432{
2433 wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
2435 aEvt.Skip();
2436}
2437#endif
2438
2439
2441{
2442 EESCHEMA_SETTINGS* cfg = eeconfig();
2443
2444 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
2445 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
2446
2448
2449 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
2450 searchPaneInfo.Show( m_show_search );
2451
2452 if( m_show_search )
2453 {
2454 searchPaneInfo.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
2455
2456 if( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
2457 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
2458 {
2459 SetAuiPaneSize( m_auimgr, searchPaneInfo, -1, cfg->m_AuiPanels.search_panel_height );
2460 }
2461 else if( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
2462 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
2463 {
2464 SetAuiPaneSize( m_auimgr, searchPaneInfo, cfg->m_AuiPanels.search_panel_width, -1 );
2465 }
2466
2467 m_searchPane->FocusSearch();
2468 m_searchPane->RefreshSearch();
2469 }
2470 else
2471 {
2472 cfg->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
2473 cfg->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
2474 cfg->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
2475 m_auimgr.Update();
2476 }
2477}
2478
2479
2481{
2482 if( !m_propertiesPanel )
2483 return;
2484
2485 bool show = !m_propertiesPanel->IsShownOnScreen();
2486
2487 wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
2488 propertiesPaneInfo.Show( show );
2489
2491
2492 EESCHEMA_SETTINGS* settings = eeconfig();
2493
2494 if( show )
2495 {
2496 SetAuiPaneSize( m_auimgr, propertiesPaneInfo,
2497 settings->m_AuiPanels.properties_panel_width, -1 );
2498 }
2499 else
2500 {
2501 settings->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
2502 m_auimgr.Update();
2503 }
2504}
2505
2506
2508{
2509 EESCHEMA_SETTINGS* cfg = eeconfig();
2510
2511 wxCHECK( cfg, /* void */ );
2512
2513 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2514
2515 hierarchy_pane.Show( !hierarchy_pane.IsShown() );
2516
2518
2519 if( hierarchy_pane.IsShown() )
2520 {
2521 if( hierarchy_pane.IsFloating() )
2522 {
2523 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
2525 m_auimgr.Update();
2526 }
2527 else if( cfg->m_AuiPanels.hierarchy_panel_docked_width > 0 )
2528 {
2529 // SetAuiPaneSize also updates m_auimgr
2530 SetAuiPaneSize( m_auimgr, hierarchy_pane,
2532 }
2533 }
2534 else
2535 {
2536 if( hierarchy_pane.IsFloating() )
2537 {
2538 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
2539 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
2540 }
2541 else
2542 {
2544 }
2545
2546 m_auimgr.Update();
2547 }
2548}
2549
2550
2552{
2553 EESCHEMA_SETTINGS* cfg = eeconfig();
2554
2555 wxCHECK( cfg, /* void */ );
2556
2557 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
2558
2559 db_library_pane.Show( !db_library_pane.IsShown() );
2560
2561 if( db_library_pane.IsShown() )
2562 {
2563 if( db_library_pane.IsFloating() )
2564 {
2565 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
2567 m_auimgr.Update();
2568 }
2570 {
2571 // SetAuiPaneSize also updates m_auimgr
2572 SetAuiPaneSize( m_auimgr, db_library_pane,
2574 }
2575 }
2576 else
2577 {
2578 if( db_library_pane.IsFloating() )
2579 {
2580 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
2581 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
2582 }
2583 else
2584 {
2586 }
2587
2588 m_auimgr.Update();
2589 }
2590}
2591
2593{
2594 wxCHECK( aSchematic, /* void */ );
2595
2596 if( m_schematic )
2597 m_schematic->SetProject( nullptr );
2598
2599 aSchematic->SetProject( &Prj() );
2600 delete m_schematic;
2601
2602 m_schematic = aSchematic;
2603 m_schematic->SetSchematicHolder( this );
2604
2605 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
2606 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
2607 m_toolManager->SetEnvironment( m_schematic, GetCanvas()->GetView(), GetCanvas()->GetViewControls(), config(),
2608 this );
2609}
const KICOMMON_API wxEventTypeTag< wxCommandEvent > EDA_EVT_PLUGIN_AVAILABILITY_CHANGED
Notifies other parts of KiCad when plugin availability changes.
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:114
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition bitmap.cpp:104
@ icon_eeschema_16
@ icon_eeschema_32
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
static TOOL_ACTION toggleGrid
Definition actions.h:197
static TOOL_ACTION paste
Definition actions.h:80
static TOOL_ACTION cancelInteractive
Definition actions.h:72
static TOOL_ACTION unselectAll
Definition actions.h:83
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition actions.h:226
static TOOL_ACTION copy
Definition actions.h:78
static TOOL_ACTION group
Definition actions.h:238
static TOOL_ACTION pasteSpecial
Definition actions.h:81
static TOOL_ACTION ungroup
Definition actions.h:239
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:156
static TOOL_ACTION showSearch
Definition actions.h:115
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition actions.h:213
static TOOL_ACTION duplicate
Definition actions.h:84
static TOOL_ACTION doDelete
Definition actions.h:85
static TOOL_ACTION selectionTool
Definition actions.h:250
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:141
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:145
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:223
static TOOL_ACTION showProperties
Definition actions.h:265
static TOOL_ACTION cut
Definition actions.h:77
static TOOL_ACTION copyAsText
Definition actions.h:79
static TOOL_ACTION toggleGridOverrides
Definition actions.h:198
static TOOL_ACTION selectAll
Definition actions.h:82
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
Handles how to draw a screen (a board, a schematic ...)
Definition base_screen.h:41
void SetContentModified(bool aModified=true)
Definition base_screen.h:59
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:658
bool Empty() const
Definition commit.h:137
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:106
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
A subgraph is a set of items that are electrically connected on a single sheet.
Dialog to update or change schematic library symbols.
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
UNDO_REDO_CONTAINER m_undoList
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
SETTINGS_MANAGER * GetSettingsManager() const
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
ACTION_TOOLBAR * m_tbRight
TOOLBAR_SETTINGS * m_toolbarSettings
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxAuiManager m_auimgr
virtual void RecreateToolbars()
ACTION_TOOLBAR * m_tbLeft
virtual void OnSize(wxSizeEvent &aEvent)
virtual void ClearFileHistory()
Remove all files from the file history.
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handle event fired when a file is dropped to the window.
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetch the file name from the file history list.
virtual int GetUndoCommandCount() const
ACTION_TOOLBAR * m_tbTopMain
wxString m_aboutTitle
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
void ReCreateMenuBar()
Recreate the menu bar.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
void setupUnits(APP_SETTINGS_BASE *aCfg)
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Change the current rendering backend.
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual void resolveCanvasType()
Determine the canvas type to load (with prompt if required) and initializes m_canvasType.
static const wxString PropertiesPaneName()
EDA_MSG_PANEL * m_messagePanel
virtual void SetScreen(BASE_SCREEN *aScreen)
virtual void UpdateMsgPanel()
Redraw the message panel.
void FocusOnLocation(const VECTOR2I &aPos, bool aAllowScroll=true)
Useful to focus on a particular location, in find functions.
virtual void ClearFocus()
SEARCH_PANE * m_searchPane
static const wxString DesignBlocksPaneName()
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
PROPERTIES_PANEL * m_propertiesPanel
bool m_showBorderAndTitleBlock
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition() but allows items to return their visual center rather than their anchor.
Definition eda_item.h:279
const KIID m_Uuid
Definition eda_item.h:516
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
void ClearBrightened()
Definition eda_item.h:138
void SetBrightened()
Definition eda_item.h:135
bool IsBrightened() const
Definition eda_item.h:129
Specialization of the wxAuiPaneInfo class for KiCad panels.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:80
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:98
SELECTION_CONDITION NoActiveTool()
Create a functor testing if there are no tools active in the frame.
SELECTION_CONDITION BoundingBoxes()
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION GridOverrides()
Create a functor testing if the grid overrides wires is enabled in a frame.
PANEL_ANNOTATE m_AnnotatePanel
bool empty() const
Definition sch_rtree.h:179
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:241
SEVERITY GetSeverity(int aErrorCode) const
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:95
void SetDefaultFont(const wxString &aFont)
Contains methods for drawing schematic-specific items.
Definition sch_painter.h:69
void SetSchematic(SCHEMATIC *aSchematic)
Definition sch_painter.h:79
void Update(const KIGFX::VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition sch_view.cpp:60
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition sch_view.h:120
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Set the scaling factor, zooming around a given anchor point.
Definition sch_view.cpp:102
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:86
bool IsSCH_ITEM() const
Definition view_item.h:101
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:66
double GetScale() const
Definition view.h:276
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition view.h:400
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition view.h:220
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition view.cpp:596
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition view.cpp:1571
Definition kiid.h:49
KIWAY_PLAYER(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
void OnSockRequestServer(wxSocketEvent &evt)
Definition eda_dde.cpp:99
void OnSockRequest(wxSocketEvent &evt)
Definition eda_dde.cpp:69
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:286
void OnKiCadExit()
Definition kiway.cpp:717
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:395
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition kiway.cpp:499
Define a library symbol object.
Definition lib_symbol.h:85
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Tree view item data for the net navigator.
A singleton reporter that reports to nowhere.
Definition reporter.h:216
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition page_info.h:168
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition page_info.h:159
A progress reporter interface for use in multi-threaded environments.
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition project.cpp:156
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition project.cpp:162
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:386
Action handler for the Properties panel.
These are loaded from Eeschema settings but then overwritten by the project settings.
Holds all the data relating to one schematic.
Definition schematic.h:88
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition schematic.h:176
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
SCHEMATIC_SETTINGS & Settings() const
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Definition schematic.h:134
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
void SetProject(PROJECT *aPrj)
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, TOOL_MANAGER *aToolManager, PROGRESS_REPORTER *aProgressReporter=nullptr, KIGFX::SCH_VIEW *aSchView=nullptr, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PICKED_ITEMS_LIST *aLastChangeList=nullptr)
Generate the connection data for the entire schematic hierarchy.
ERC_SETTINGS & ErcSettings() const
Gather all the actions that are shared by tools.
Definition sch_actions.h:40
static TOOL_ACTION rotateCCW
static TOOL_ACTION placeClassLabel
Definition sch_actions.h:79
static TOOL_ACTION placeSheetPin
Definition sch_actions.h:85
static TOOL_ACTION saveSheetAsDesignBlock
static TOOL_ACTION mirrorV
static TOOL_ACTION drawSheetFromFile
Definition sch_actions.h:83
static TOOL_ACTION toggleOPCurrents
static TOOL_ACTION saveToLinkedDesignBlock
Definition sch_actions.h:71
static TOOL_ACTION saveSelectionAsDesignBlock
static TOOL_ACTION placeGlobalLabel
Definition sch_actions.h:80
static TOOL_ACTION drawTextBox
Definition sch_actions.h:93
static TOOL_ACTION toggleAnnotateAuto
static TOOL_ACTION ddAddImage
static TOOL_ACTION drawArc
Definition sch_actions.h:97
static TOOL_ACTION drawSheet
Definition sch_actions.h:82
static TOOL_ACTION toggleERCWarnings
static TOOL_ACTION toggleDirectiveLabels
static TOOL_ACTION highlightNetTool
static TOOL_ACTION leaveSheet
static TOOL_ACTION ddImportGraphics
static TOOL_ACTION toggleHiddenFields
static TOOL_ACTION drawRectangle
Definition sch_actions.h:95
static TOOL_ACTION drawLines
Definition sch_actions.h:99
static TOOL_ACTION placeHierLabel
Definition sch_actions.h:81
static TOOL_ACTION placeLabel
Definition sch_actions.h:78
static TOOL_ACTION drawCircle
Definition sch_actions.h:96
static TOOL_ACTION placeBusWireEntry
Definition sch_actions.h:77
static TOOL_ACTION drawBezier
Definition sch_actions.h:98
static TOOL_ACTION drawWire
Definition sch_actions.h:72
static TOOL_ACTION remapSymbols
static TOOL_ACTION rotateCW
static TOOL_ACTION showHierarchy
static TOOL_ACTION showNetNavigator
static TOOL_ACTION placeJunction
Definition sch_actions.h:76
static TOOL_ACTION markSimExclusions
static TOOL_ACTION drawRuleArea
static TOOL_ACTION placeSymbol
Definition sch_actions.h:66
static TOOL_ACTION placeImage
static TOOL_ACTION toggleERCErrors
static TOOL_ACTION angleSnapModeChanged
static TOOL_ACTION placeLinkedDesignBlock
Definition sch_actions.h:70
static TOOL_ACTION drawSheetFromDesignBlock
Definition sch_actions.h:84
static TOOL_ACTION mirrorH
static TOOL_ACTION placeDesignBlock
Definition sch_actions.h:69
static TOOL_ACTION toggleOPVoltages
static TOOL_ACTION drawBus
Definition sch_actions.h:73
static TOOL_ACTION drawTable
Definition sch_actions.h:94
static TOOL_ACTION ddAppendFile
static TOOL_ACTION placeSchematicText
Definition sch_actions.h:92
static TOOL_ACTION showDesignBlockPanel
static TOOL_ACTION togglePinAltIcons
static TOOL_ACTION toggleERCExclusions
static TOOL_ACTION updateNetHighlighting
static TOOL_ACTION placeNoConnect
Definition sch_actions.h:75
static TOOL_ACTION toggleHiddenPins
static TOOL_ACTION syncSheetPins
Definition sch_actions.h:89
static TOOL_ACTION placePower
Definition sch_actions.h:68
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
SCH_RENDER_SETTINGS * GetRenderSettings()
void doCloseWindow() override
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
DIALOG_SCH_FIND * m_findReplaceDialog
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
EESCHEMA_SETTINGS * eeconfig() const
PANEL_SCH_SELECTION_FILTER * m_selectionFilterPanel
virtual void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool HasDriverChanged() const
wxString Name(bool aIgnoreSheet=false) const
Handle design block actions in the schematic editor.
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.).
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplaySheet(SCH_SCREEN *aScreen)
Group generic conditions for PCB editor states.
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
Schematic editor (Eeschema) main window.
void DefaultExecFlags()
Reset the execution flags to defaults for external netlist and bom generators.
void OnCrossProbeFlashTimer(wxTimerEvent &aEvent)
void ToggleProperties() override
bool IsContentModified() const override
Get if the current schematic has been modified but not saved.
void RefreshOperatingPointDisplay()
Refresh the display of any operating points.
wxPageSetupDialogData m_pageSetupData
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
const wxString & getAutoSaveFileName() const
wxTreeCtrl * m_netNavigator
std::vector< std::unique_ptr< SCH_ITEM > > m_items_to_repeat
For the repeat-last-item cmd.
void FocusOnItem(EDA_ITEM *aItem, bool aAllowScroll=true) override
Focus on a particular canvas item.
void onResizeNetNavigator(wxSizeEvent &aEvent)
void updateSelectionFilterVisbility() override
Selection filter panel doesn't have a dedicated visibility control, so show it if any other AUI panel...
void onNetNavigatorSelChanging(wxTreeEvent &aEvent)
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void ShowAllIntersheetRefs(bool aShow)
void SaveProjectLocalSettings() override
Save changes to the project settings to the project (.pro) file.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void doCloseWindow() override
DIALOG_BOOK_REPORTER * m_diffSymbolDialog
void ToggleLibraryTree() override
void SetHighlightedConnection(const wxString &aConnection, const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
void onCloseErcDialog(wxCommandEvent &aEvent)
void UpdateHierarchySelection()
Update the hierarchy navigation tree selection (cross-probe from schematic to hierarchy pane).
bool m_syncingPcbToSchSelection
void SetScreen(BASE_SCREEN *aScreen) override
friend class SCH_EDITOR_CONTROL
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
Update a schematic symbol from a LIB_SYMBOL.
void onSize(wxSizeEvent &aEvent)
void CommonSettingsChanged(int aFlags) override
Called after the preferences dialog is run.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
void configureToolbars() override
std::vector< wxEvtHandler * > m_schematicChangeListeners
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void OnClearFileHistory(wxCommandEvent &aEvent)
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
SCHEMATIC * m_schematic
The currently loaded schematic.
void 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.
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)
wxString GetFullScreenDesc() const override
static const wxString SearchPaneName()
DIALOG_BOOK_REPORTER * GetSymbolDiffDialog()
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
DIALOG_ERC * GetErcDialog()
void sendNetlistToCvpcb()
Send the KiCad netlist over to CVPCB.
SCH_DESIGN_BLOCK_PANE * m_designBlocksPane
void UpdateHierarchyNavigator(bool aRefreshNetNavigator=true, bool aClear=false)
Update the hierarchy navigation tree and history.
SCH_EDIT_FRAME(KIWAY *aKiway, wxWindow *aParent)
void ToggleSchematicHierarchy()
Toggle the show/hide state of the left side schematic navigation panel.
std::vector< KIID > m_crossProbeFlashItems
Items to flash.
void LoadDrawingSheet()
Load the drawing sheet file.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
std::vector< LIB_ID > m_designBlockHistoryList
void OnPageSettingsChange() override
Called when modifying the page settings.
void ClearRepeatItemsList()
Clear the list of items which are to be repeated with the insert key.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Return bounding box of document with option to not include some items.
void CaptureHierarchyPaneSize()
void StartCrossProbeFlash(const std::vector< SCH_ITEM * > &aItems)
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
void UpdateLabelsHierarchyNavigator()
Update the hierarchy navigation tree labels.
void OnImportProject(wxCommandEvent &event)
double GetSchematicHopOverScale()
static const wxString SchematicHierarchyPaneName()
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
EDA_ITEM * ResolveItem(const KIID &aId, bool aAllowNullptrReturn=false) const override
Fetch an item by KIID.
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void RemoveSchematicChangeListener(wxEvtHandler *aListener)
Remove aListener to from the schematic changed listener list.
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
void DisplayCurrentSheet()
Draw the current sheet on the display.
~SCH_EDIT_FRAME() override
const wxString & GetHighlightedConnection() const
DIALOG_ERC * m_ercDialog
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
void UpdateNetHighlightStatus()
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
void AddCopyForRepeatItem(const SCH_ITEM *aItem)
DIALOG_SYMBOL_FIELDS_TABLE * GetSymbolFieldsTableDialog()
void OnResizeHierarchyNavigator(wxSizeEvent &aEvent)
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
wxString m_highlightedConn
The highlighted net or bus or empty string.
static const wxString NetNavigatorPaneName()
void onCloseSymbolDiffDialog(wxCommandEvent &aEvent)
wxTreeCtrl * createHighlightedNetNavigator()
void IntersheetRefUpdate(SCH_GLOBALLABEL *aItem) override
Callback from schematic ref update.
void OnExit(wxCommandEvent &event)
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it).
wxTimer m_crossProbeFlashTimer
Timer to toggle selection visibility.
void AddSchematicChangeListener(wxEvtHandler *aListener)
Add aListener to post #EDA_EVT_SCHEMATIC_CHANGED command events to.
HIERARCHY_PANE * m_hierarchy
DIALOG_SYMBOL_FIELDS_TABLE * m_symbolFieldsTableDialog
std::unique_ptr< GRID_HELPER > MakeGridHelper() override
void UpdateHopOveredWires(SCH_ITEM *aItem)
SEVERITY GetSeverity(int aErrorCode) const override
void onNetNavigatorSelection(wxTreeEvent &aEvent)
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Handle actions specific to the schematic editor.
A set of SCH_ITEMs (i.e., without duplicates).
Definition sch_group.h:52
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool doClone=false) const
Routine to create a new copy of given item.
Definition sch_item.cpp:137
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition sch_item.h:597
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:323
bool ResolveExcludedFromSim() const
Definition sch_item.cpp:247
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
SPIN_STYLE GetSpinStyle() const
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.)
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:42
void SetOperatingPoint(const wxString &aText)
Definition sch_line.h:339
bool IsWire() const
Return true if the line is a wire.
Definition sch_line.cpp:961
double GetLength() const
Definition sch_line.cpp:247
const wxString & GetOperatingPoint() const
Definition sch_line.h:338
Handle actions specific to the schematic editor.
void SetOperatingPoint(const wxString &aText)
Definition sch_pin.h:325
Tool that displays edit points allowing to modify items by dragging the points.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:758
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
const PAGE_INFO & GetPageSettings() const
Definition sch_screen.h:139
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
void TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr, std::function< void(SCH_ITEM *)> *aChangedHandler=nullptr) const
Test all of the connectable objects in the schematic for unused connection points.
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition sch_screen.h:488
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition sch_screen.h:682
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:117
const wxString & GetFileName() const
Definition sch_screen.h:152
bool IsReadOnly() const
Definition sch_screen.h:155
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
bool m_zoomInitialized
Definition sch_screen.h:707
bool FileExists() const
Definition sch_screen.h:158
SPIN_STYLE GetLabelOrientationForPoint(const VECTOR2I &aPosition, SPIN_STYLE aDefaultOrientation, const SCH_SHEET_PATH *aSheet) const
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Fetch a SCH_ITEM by ID.
bool IsModified() const
Check the entire hierarchy for any modifications.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void clear()
Forwarded method from std::vector.
wxString GetName() const
Definition sch_sheet.h:113
Schematic symbol object.
Definition sch_symbol.h:75
EMBEDDED_FILES * GetEmbeddedFiles() override
SCH_SYMBOLs don't currently support embedded files, but their LIB_SYMBOL counterparts do.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
VECTOR2I GetPosition() const override
Definition sch_text.h:141
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 bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void BrightenItem(EDA_ITEM *aItem)
int AddItemToSel(const TOOL_EVENT &aEvent)
void UnbrightenItem(EDA_ITEM *aItem)
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Save, unload and unregister the given PROJECT.
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
Definition sim_lib_mgr.h:48
const SPICE_GENERATOR & SpiceGenerator() const
Definition sim_model.h:431
std::vector< std::reference_wrapper< const SIM_MODEL_PIN > > GetPins() const
virtual std::string ItemName(const SPICE_ITEM &aItem) const
Symbol library viewer main window.
The symbol library editor main window.
Symbol library viewer main window.
void AddTemplateFieldNames(const wxString &aSerializedFieldNames)
Add a serialized list of template field names.
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
TOOL_MANAGER * m_toolManager
TOOL_DISPATCHER * m_toolDispatcher
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
ACTIONS * m_actions
@ REDRAW
Full drawing refresh.
Definition tool_base.h:83
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:80
Generic, UI-independent tool event.
Definition tool_event.h:171
Master controller class:
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
Definition common.cpp:429
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition confirm.cpp:129
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:169
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#define _(s)
wxDEFINE_EVENT(wxEVT_REFRESH_CUSTOM_COMMAND, wxEvent)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define SCH_EDIT_FRAME_NAME
@ NO_RECURSE
Definition eda_item.h:52
#define IGNORE_PARENT_GROUP
Definition eda_item.h:55
@ ID_IMPORT_NON_KICAD_SCH
Definition eeschema_id.h:62
const wxAuiPaneInfo & defaultSchSelectionFilterPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultPropertiesPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultNetNavigatorPaneInfo()
const wxAuiPaneInfo & defaultDesignBlocksPaneInfo(wxWindow *aWindow)
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
KiCad executable names.
const wxString PCBNEW_EXE
@ FRAME_PCB_EDITOR
Definition frame_type.h:42
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:35
@ FRAME_SCH_VIEWER
Definition frame_type.h:36
@ FRAME_SCH
Definition frame_type.h:34
@ FRAME_SIMULATOR
Definition frame_type.h:38
@ FRAME_CVPCB
Definition frame_type.h:52
@ FRAME_SYMBOL_CHOOSER
Definition frame_type.h:37
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition gestfich.cpp:143
static const std::string NetlistFileExtension
static const std::string JpegFileExtension
static const std::string PngFileExtension
static const std::string LegacyPcbFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string AutoSaveFilePrefix
static const std::string SVGFileExtension
static wxString LegacySchematicFileWildcard()
static wxString AllSchematicFilesWildcard()
static wxString KiCadSchematicFileWildcard()
const wxChar *const traceApi
Flag to enable debug output related to the IPC API and its plugin system.
Definition api_utils.cpp:27
@ ID_FILE_LIST_CLEAR
Definition id.h:62
@ ID_EDA_SOCKET_EVENT
Definition id.h:132
@ ID_EDA_SOCKET_EVENT_SERV
Definition id.h:131
@ ID_FILEMAX
Definition id.h:60
@ ID_FILE1
Definition id.h:59
PROJECT & Prj()
Definition kicad.cpp:612
KIID niluuid(0)
#define KICTL_CREATE
caller thinks requested project files may not exist.
@ LAYER_ERC_WARN
Definition layer_ids.h:478
@ LAYER_ERC_EXCLUSION
Definition layer_ids.h:480
@ LAYER_ERC_ERR
Definition layer_ids.h:479
@ LAYER_OP_CURRENTS
Definition layer_ids.h:500
@ LAYER_INTERSHEET_REFS
Definition layer_ids.h:462
@ LAYER_OP_VOLTAGES
Definition layer_ids.h:499
@ MAIL_PCB_UPDATE
Definition mail_type.h:46
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:58
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:55
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition unix/app.cpp:90
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition unix/app.cpp:79
#define _HKI(x)
Definition page_info.cpp:44
PGM_BASE & Pgm()
The global program "get" accessor.
Definition pgm_base.cpp:913
see class PGM_BASE
SEVERITY
#define DIFF_SYMBOLS_DIALOG_NAME
#define CURRENT_TOOL(action)
@ AUTOPLACE_AUTO
Definition sch_item.h:70
SCH_CLEANUP_FLAGS
Definition schematic.h:74
@ GLOBAL_CLEANUP
Definition schematic.h:77
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
std::string refName
Definition for symbol library class.
@ SCH_GROUP_T
Definition typeinfo.h:175
@ SCH_LINE_T
Definition typeinfo.h:165
@ SCH_SYMBOL_T
Definition typeinfo.h:174
@ SCH_HIER_LABEL_T
Definition typeinfo.h:171
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:170
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
Definition of file extensions used in Kicad.
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.