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 (C) 1992-2024 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 <base_units.h>
26#include <bitmaps.h>
27#include <symbol_library.h>
28#include <confirm.h>
29#include <connection_graph.h>
30#include <dialogs/dialog_erc.h>
34#include <eeschema_id.h>
35#include <executable_names.h>
37#include <gestfich.h>
39#include <core/ignore.h>
40#include <invoke_sch_dialog.h>
41#include <string_utils.h>
42#include <kiface_base.h>
43#include <kiplatform/app.h>
44#include <kiway.h>
45#include <symbol_edit_frame.h>
46#include <symbol_viewer_frame.h>
47#include <pgm_base.h>
48#include <core/profile.h>
51#include <python_scripting.h>
52#include <sch_edit_frame.h>
54#include <sch_painter.h>
55#include <sch_sheet.h>
56#include <sch_marker.h>
57#include <sch_sheet_pin.h>
58#include <schematic.h>
59#include <sch_commit.h>
61#include <advanced_config.h>
62#include <sim/simulator_frame.h>
63#include <tool/action_manager.h>
64#include <tool/action_toolbar.h>
65#include <tool/common_control.h>
66#include <tool/common_tools.h>
67#include <tool/picker_tool.h>
69#include <tool/selection.h>
71#include <tool/tool_manager.h>
72#include <tool/zoom_tool.h>
73#include <tools/ee_actions.h>
78#include <tools/sch_edit_tool.h>
82#include <tools/sch_move_tool.h>
85#include <view/view_controls.h>
86#include <widgets/wx_infobar.h>
91#include <wx/cmdline.h>
92#include <wx/app.h>
93#include <wx/filedlg.h>
94#include <wx/socket.h>
97
98
99#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
100
101
102BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
105
106 EVT_SIZE( SCH_EDIT_FRAME::OnSize )
107
110
113
114 EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
115 EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
116
117 // Drop files event
118 EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
119END_EVENT_TABLE()
120
121
122wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
123wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
124
125
126SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
127 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
129 m_ercDialog( nullptr ),
130 m_diffSymbolDialog( nullptr ),
131 m_symbolFieldsTableDialog( nullptr ),
132 m_netNavigator( nullptr ),
133 m_highlightedConnChanged( false )
134{
135 m_maximizeByDefault = true;
136 m_schematic = new SCHEMATIC( nullptr );
137
138 m_showBorderAndTitleBlock = true; // true to show sheet references
139 m_supportsAutoSave = true;
140 m_syncingPcbToSchSelection = false;
141 m_aboutTitle = _HKI( "KiCad Schematic Editor" );
142 m_show_search = false;
143
144 m_findReplaceDialog = nullptr;
145
146 m_findReplaceData = std::make_unique<SCH_SEARCH_DATA>();
147
148 // Give an icon
149 wxIcon icon;
150 wxIconBundle icon_bundle;
151
152 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 48 ) );
153 icon_bundle.AddIcon( icon );
154 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 128 ) );
155 icon_bundle.AddIcon( icon );
156 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 256 ) );
157 icon_bundle.AddIcon( icon );
158 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
159 icon_bundle.AddIcon( icon );
160 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
161 icon_bundle.AddIcon( icon );
162
163 SetIcons( icon_bundle );
164
165 LoadSettings( eeconfig() );
166
167 // NB: also links the schematic to the loaded project
168 CreateScreens();
169 SetCurrentSheet( Schematic().GetSheets()[0] );
170
171 setupTools();
172 setupUIConditions();
173 ReCreateMenuBar();
174 ReCreateHToolbar();
175 ReCreateVToolbar();
176 ReCreateOptToolbar();
177
178 m_hierarchy = new HIERARCHY_PANE( this );
179
180 // Initialize common print setup dialog settings.
181 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
182 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
183 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
184 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
185
186 m_searchPane = new SCH_SEARCH_PANE( this );
187 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
188
189 m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
190
191 m_auimgr.SetManagedWindow( this );
192
193 CreateInfoBar();
194
195 // Rows; layers 4 - 6
196 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxS( "MainToolbar" ) )
197 .Top().Layer( 6 ) );
198
199 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
200 .Bottom().Layer( 6 ) );
201
202 // Columns; layers 1 - 3
203 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
204 .Caption( _( "Schematic Hierarchy" ) )
205 .Left().Layer( 3 )
206 .TopDockable( false )
207 .BottomDockable( false )
208 .CloseButton( true )
209 .MinSize( FromDIP( wxSize( 120, 60 ) ) )
210 .BestSize( FromDIP( wxSize( 200, 200 ) ) )
211 .FloatingSize( FromDIP( wxSize( 200, 200 ) ) )
212 .FloatingPosition( FromDIP( wxPoint( 50, 50 ) ) )
213 .Show( false ) );
214
215 m_auimgr.AddPane( m_propertiesPanel, defaultPropertiesPaneInfo( this ) );
216
217 m_auimgr.AddPane( createHighlightedNetNavigator(), defaultNetNavigatorPaneInfo() );
218
219 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( wxS( "OptToolbar" ) )
220 .Left().Layer( 2 ) );
221
222 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( wxS( "ToolsToolbar" ) )
223 .Right().Layer( 2 ) );
224
225 // Center
226 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
227 .Center() );
228
229 m_auimgr.AddPane( m_searchPane, EDA_PANE()
230 .Name( SearchPaneName() )
231 .Bottom()
232 .Caption( _( "Search" ) )
233 .PaneBorder( false )
234 .MinSize( FromDIP( wxSize( 180, 60 ) ) )
235 .BestSize( FromDIP( wxSize( 180, 100 ) ) )
236 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
237 .CloseButton( true )
238 .DestroyOnClose( false )
239 .Show( m_show_search ) );
240
241 FinishAUIInitialization();
242
243 resolveCanvasType();
244 SwitchCanvas( m_canvasType );
245
246 GetCanvas()->GetGAL()->SetAxesEnabled( false );
247
248 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
249 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
250
251 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
252 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
253 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
254 EESCHEMA_SETTINGS* cfg = eeconfig();
255
256 hierarchy_pane.Show( cfg->m_AuiPanels.show_schematic_hierarchy );
257 netNavigatorPane.Show( cfg->m_AuiPanels.show_net_nav_panel );
258 propertiesPane.Show( cfg->m_AuiPanels.show_properties );
259
262 {
263 // Show at end, after positioning
264 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
266 }
267
268 if( cfg->m_AuiPanels.net_nav_panel_float_size.GetWidth() > 0
269 && cfg->m_AuiPanels.net_nav_panel_float_size.GetHeight() > 0 )
270 {
271 netNavigatorPane.FloatingSize( cfg->m_AuiPanels.net_nav_panel_float_size );
272 netNavigatorPane.FloatingPosition( cfg->m_AuiPanels.net_nav_panel_float_pos );
273 }
274
276 SetAuiPaneSize( m_auimgr, propertiesPane, cfg->m_AuiPanels.properties_panel_width, -1 );
277
279 hierarchy_pane.Float();
280
282 && ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
283 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
284 {
285 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
286 searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
287 SetAuiPaneSize( m_auimgr, searchPane, -1, cfg->m_AuiPanels.search_panel_height );
288 }
289
290 else if( cfg->m_AuiPanels.search_panel_width > 0
291 && ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
292 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
293 {
294 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
295 searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
296 SetAuiPaneSize( m_auimgr, searchPane, cfg->m_AuiPanels.search_panel_width, -1 );
297 }
298
300 netNavigatorPane.Float();
301
303 {
304 // If the net navigator is not show, let the hierarchy navigator take all of the vertical
305 // space.
307 {
308 SetAuiPaneSize( m_auimgr, hierarchy_pane,
310 }
311 else
312 {
313 SetAuiPaneSize( m_auimgr, hierarchy_pane,
316
317 SetAuiPaneSize( m_auimgr, netNavigatorPane,
319 cfg->m_AuiPanels.net_nav_panel_docked_size.GetHeight() );
320 }
321
322 // wxAUI hack: force width by setting MinSize() and then Fixed()
323 // thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
324 hierarchy_pane.MinSize( cfg->m_AuiPanels.hierarchy_panel_docked_width, 60 );
325 hierarchy_pane.Fixed();
326 netNavigatorPane.MinSize( cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth(), 60 );
327 netNavigatorPane.Fixed();
328 m_auimgr.Update();
329
330 // now make it resizable again
331 hierarchy_pane.Resizable();
332 netNavigatorPane.Resizable();
333 m_auimgr.Update();
334
335 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
336 // back to minimum.
337 hierarchy_pane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
338 netNavigatorPane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
339 }
340 else
341 {
342 m_auimgr.Update();
343 }
344
345 LoadProjectSettings();
346
352
353 initScreenZoom();
354
355 m_hierarchy->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
356 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
357 this );
358 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
359 m_netNavigator->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onResizeNetNavigator, this );
360
361 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
362 // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
363 Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
364
365 setupUnits( eeconfig() );
366
367 // Net list generator
368 DefaultExecFlags();
369
370 updateTitle();
371 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
372
373 // Default shutdown reason until a file is loaded
374 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
375
376 // Init for dropping files
378 DragAcceptFiles( true );
379
380 // Ensure the window is on top
381 Raise();
382
383 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
384 // top-left corner of the canvas
385 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
386 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
387
388 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
389 Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
390 Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog,
391 this );
392}
393
394
396{
397 m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
398
399 // Ensure m_canvasType is up to date, to save it in config
401
402 SetScreen( nullptr );
403
404 if( m_schematic )
406
407 delete m_schematic;
408 m_schematic = nullptr;
409
410 // Close the project if we are standalone, so it gets cleaned up properly
411 if( Kiface().IsSingle() )
412 {
413 try
414 {
415 GetSettingsManager()->UnloadProject( &Prj(), false );
416 }
417 catch( const nlohmann::detail::type_error& exc )
418 {
419 // This may be overkill and could be an assertion but we are more likely to
420 // find any settings manager errors this way.
421 wxLogError( wxT( "Settings exception '%s' occurred." ), exc.what() );
422 }
423 }
424
425 delete m_hierarchy;
426}
427
428
430{
431 aEvent.Skip();
432
433 // Called when resizing the Hierarchy Navigator panel
434 // Store the current pane size
435 // It allows to retrieve the last defined pane size when switching between
436 // docked and floating pane state
437 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
438
439 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
440 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
441
442 if( cfg && m_hierarchy->IsShownOnScreen() )
443 {
444 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
445 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
446
447 // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
448 // width is > 0 (i.e. if its size is already set and has meaning)
449 // if it is floating, its size is not initialized (only floating_size is initialized)
450 // initializing hierarchy_pane.best_size is useful when switching to float pane and
451 // after switching to the docked pane, to retrieve the last docked pane width
452 if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
453 {
454 cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
455 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
456 }
457 }
458}
459
460
462{
463 // Create the manager and dispatcher & route draw panel events to the dispatcher
466 GetCanvas()->GetViewControls(), config(), this );
467 m_actions = new EE_ACTIONS();
469
470 // Register tools
487
488 // Run the selection tool, it is supposed to be always active
490
492}
493
494
496{
498
500 SCH_EDITOR_CONDITIONS cond( this );
501
502 wxASSERT( mgr );
503
504 auto hasElements =
505 [ this ] ( const SELECTION& aSel )
506 {
507 return GetScreen() &&
508 ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
509 };
510
511 auto searchPaneCond =
512 [this] ( const SELECTION& )
513 {
514 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
515 };
516
517 auto propertiesCond =
518 [this] ( const SELECTION& )
519 {
520 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
521 };
522
523 auto hierarchyNavigatorCond =
524 [ this ] ( const SELECTION& aSel )
525 {
526 return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
527 };
528
529 auto netNavigatorCond =
530 [ this ] (const SELECTION& aSel )
531 {
532 return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
533 };
534
535 auto undoCond =
536 [ this ] (const SELECTION& aSel )
537 {
539 return true;
540
541 return GetUndoCommandCount() > 0;
542 };
543
544#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
545#define CHECK( x ) ACTION_CONDITIONS().Check( x )
546
548 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
550
551 mgr->SetConditions( EE_ACTIONS::showSearch, CHECK( searchPaneCond ) );
552 mgr->SetConditions( EE_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
553 mgr->SetConditions( EE_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
554 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
559 CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
560 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
561 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
562
564 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_FREE ) ) );
566 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_90 ) ) );
568 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_45 ) ) );
569
570 mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
571 mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
574 mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
575 mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
576 mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
577 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
578
579 mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( hasElements ) );
580 mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( hasElements ) );
581 mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( hasElements ) );
582 mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( hasElements ) );
583
588
589 if( SCRIPTING::IsWxAvailable() )
590 {
592 CHECK( cond.ScriptingConsoleVisible() ) );
593 }
594
595 auto showHiddenPinsCond =
596 [this]( const SELECTION& )
597 {
598 return GetShowAllPins();
599 };
600
601 auto showHiddenFieldsCond =
602 [this]( const SELECTION& )
603 {
605 return cfg && cfg->m_Appearance.show_hidden_fields;
606 };
607
608 auto showDirectiveLabelsCond =
609 [this]( const SELECTION& )
610 {
612 return cfg && cfg->m_Appearance.show_directive_labels;
613 };
614
615 auto showERCErrorsCond =
616 [this]( const SELECTION& )
617 {
619 return cfg && cfg->m_Appearance.show_erc_errors;
620 };
621
622 auto showERCWarningsCond =
623 [this]( const SELECTION& )
624 {
626 return cfg && cfg->m_Appearance.show_erc_warnings;
627 };
628
629 auto showERCExclusionsCond =
630 [this]( const SELECTION& )
631 {
633 return cfg && cfg->m_Appearance.show_erc_exclusions;
634 };
635
636 auto showOPVoltagesCond =
637 [this]( const SELECTION& )
638 {
640 return cfg && cfg->m_Appearance.show_op_voltages;
641 };
642
643 auto showOPCurrentsCond =
644 [this]( const SELECTION& )
645 {
647 return cfg && cfg->m_Appearance.show_op_currents;
648 };
649
650 auto showAnnotateAutomaticallyCond =
651 [this]( const SELECTION& )
652 {
654 return cfg && cfg->m_AnnotatePanel.automatic;
655 };
656
657 auto remapSymbolsCondition =
658 [&]( const SELECTION& aSel )
659 {
660 SCH_SCREENS schematic( Schematic().Root() );
661
662 // The remapping can only be performed on legacy projects.
663 return schematic.HasNoFullyDefinedLibIds();
664 };
665
666 auto belowRootSheetCondition =
667 [this]( const SELECTION& aSel )
668 {
670 return navigateTool && navigateTool->CanGoUp();
671 };
672
673 auto navSchematicHasPreviousSheet =
674 [this]( const SELECTION& aSel )
675 {
677 return navigateTool && navigateTool->CanGoPrevious();
678 };
679
680 auto navSchematicHasNextSheet =
681 [this]( const SELECTION& aSel )
682 {
684 return navigateTool && navigateTool->CanGoNext();
685 };
686
687 mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
688
689 /* Some of these are bound by default to arrow keys which will get a different action if we
690 * disable the buttons. So always leave them enabled so the action is consistent.
691 * https://gitlab.com/kicad/code/kicad/-/issues/14783
692 mgr->SetConditions( EE_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
693 mgr->SetConditions( EE_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
694 mgr->SetConditions( EE_ACTIONS::navigateBack, ENABLE( navHistoryHsBackward ) );
695 */
696
697 mgr->SetConditions( EE_ACTIONS::navigatePrevious, ENABLE( navSchematicHasPreviousSheet ) );
698 mgr->SetConditions( EE_ACTIONS::navigateNext, ENABLE( navSchematicHasNextSheet ) );
699 mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
700 mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
701 mgr->SetConditions( EE_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
702 mgr->SetConditions( EE_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
703 mgr->SetConditions( EE_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
704 mgr->SetConditions( EE_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
705 mgr->SetConditions( EE_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
706 mgr->SetConditions( EE_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
707 mgr->SetConditions( EE_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
708 mgr->SetConditions( EE_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
710
711#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
712
735
736#undef CURRENT_TOOL
737#undef CHECK
738#undef ENABLE
739}
740
741
743{
744 // we cannot store a pointer to an item in the display list here since
745 // that item may be deleted, such as part of a line concatenation or other.
746 // So simply always keep a copy of the object which is to be repeated.
747
748 if( aItem )
749 {
750 m_items_to_repeat.clear();
751
752 AddCopyForRepeatItem( aItem );
753 }
754}
755
756
758{
759 // we cannot store a pointer to an item in the display list here since
760 // that item may be deleted, such as part of a line concatenation or other.
761 // So simply always keep a copy of the object which is to be repeated.
762
763 if( aItem )
764 {
765 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate() ) );
766
767 // Clone() preserves the flags, we want 'em cleared.
768 repeatItem->ClearFlags();
769
770 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
771 }
772}
773
774
776{
777 return Schematic().GetSheets().GetItem( aId );
778}
779
780
782{
784}
785
786
788{
789 return GetCurrentSheet().LastScreen();
790}
791
792
794{
795 return *m_schematic;
796}
797
798
800{
801 return GetCurrentSheet().Last()->GetName();
802}
803
804
806{
808}
809
810
812{
815
816 SCH_SHEET* rootSheet = new SCH_SHEET( m_schematic );
817 m_schematic->SetRoot( rootSheet );
818
819 SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
820 const_cast<KIID&>( rootSheet->m_Uuid ) = rootScreen->GetUuid();
821 m_schematic->Root().SetScreen( rootScreen );
822 SetScreen( Schematic().RootScreen() );
823
824
825 m_schematic->RootScreen()->SetFileName( wxEmptyString );
826
827 // Don't leave root page number empty
828 SCH_SHEET_PATH rootSheetPath;
829
830 rootSheetPath.push_back( rootSheet );
831 m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
832 rootSheetPath.SetPageNumber( wxT( "1" ) );
833
834 if( GetScreen() == nullptr )
835 {
836 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
837 SetScreen( screen );
838 }
839}
840
841
843{
844 return m_schematic->CurrentSheet();
845}
846
847
849{
850 if( aSheet != GetCurrentSheet() )
851 {
852 FocusOnItem( nullptr );
853
854 Schematic().SetCurrentSheet( aSheet );
855 GetCanvas()->DisplaySheet( aSheet.LastScreen() );
856 }
857}
858
859
861{
863
864 for( SCH_ITEM* item : screen->Items() )
865 item->ClearCaches();
866
867 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
868 {
869 wxCHECK2( libSymbol.second, continue );
870 libSymbol.second->ClearCaches();
871 }
872
873 if( Schematic().Settings().m_IntersheetRefsShow )
875
876 FocusOnItem( nullptr );
877
878 GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
879
881 selectionTool->Reset( TOOL_BASE::REDRAW );
882
884}
885
886
887bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
888{
889 // Exit interactive editing
890 // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
891 // will cancel any drag currently in progress, but commit all changes from previous drags.
892 if( m_toolManager )
894
895 // Shutdown blocks must be determined and vetoed as early as possible
896 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
897 && Schematic().GetSheets().IsModified() )
898 {
899 return false;
900 }
901
902 if( Kiface().IsSingle() )
903 {
904 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
905
906 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
907 return false;
908
909 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
910
911 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
912 return false;
913
914 // SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
915 // sorry.
916 auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
917
918 if( chooser && !chooser->Close() ) // Can close symbol chooser?
919 return false;
920 }
921 else
922 {
923 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
924
925 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
926 {
927 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
928 return false;
929 }
930 }
931
932 if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
933 return false;
934
936 && !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
937 {
938 return false;
939 }
940
941 // We may have gotten multiple events; don't clean up twice
942 if( !Schematic().IsValid() )
943 return false;
944
945 SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
946
947 if( sheetlist.IsModified() )
948 {
949 wxFileName fileName = Schematic().RootScreen()->GetFileName();
950 wxString msg = _( "Save changes to '%s' before closing?" );
951
952 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
953 [&]() -> bool
954 {
955 return SaveProject();
956 } ) )
957 {
958 return false;
959 }
960 }
961
962 return true;
963}
964
965
967{
968 SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
969
970 // Shutdown all running tools
971 if( m_toolManager )
973
974 // Close modeless dialogs. They're trouble when they get destroyed after the frame.
975 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
976 Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
977 Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE,
979 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
980 this );
981 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection,
982 this );
983
984 // Close the find dialog and preserve its setting if it is displayed.
986 {
989
990 m_findReplaceDialog->Destroy();
991 m_findReplaceDialog = nullptr;
992 }
993
995 {
996 m_diffSymbolDialog->Destroy();
997 m_diffSymbolDialog = nullptr;
998 }
999
1000 if( m_ercDialog )
1001 {
1002 m_ercDialog->Destroy();
1003 m_ercDialog = nullptr;
1004 }
1005
1007 {
1008 m_symbolFieldsTableDialog->Destroy();
1009 m_symbolFieldsTableDialog = nullptr;
1010 }
1011
1012 // Shutdown all running tools
1013 if( m_toolManager )
1014 {
1016 // prevent the canvas from trying to dispatch events during close
1017 GetCanvas()->SetEventDispatcher( nullptr );
1018 delete m_toolManager;
1019 m_toolManager = nullptr;
1020 }
1021
1022 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
1023
1024 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
1025 {
1026 hierarchy_pane.Show( false );
1027 m_auimgr.Update();
1028 }
1029
1030 SCH_SCREENS screens( Schematic().Root() );
1031 wxFileName fn;
1032
1033 for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
1034 {
1035 fn = Prj().AbsolutePath( screen->GetFileName() );
1036
1037 // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
1038 fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
1039
1040 if( fn.IsFileWritable() )
1041 wxRemoveFile( fn.GetFullPath() );
1042 }
1043
1044 wxFileName tmpFn = Prj().GetProjectFullName();
1045 wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
1046
1047 if( autoSaveFileName.IsFileWritable() )
1048 wxRemoveFile( autoSaveFileName.GetFullPath() );
1049
1050 sheetlist.ClearModifyStatus();
1051
1052 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
1053
1054 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
1055 UpdateFileHistory( fileName );
1056
1057 // Make sure local settings are persisted
1059
1060 Schematic().RootScreen()->Clear();
1061
1062 // all sub sheets are deleted, only the main sheet is usable
1064
1065 // Clear view before destroying schematic as repaints depend on schematic being valid
1066 SetScreen( nullptr );
1067
1068 Schematic().Reset();
1069
1070 // Prevents any rogue events from continuing (i.e. search panel tries to redraw)
1071 Show( false );
1072
1073 Destroy();
1074}
1075
1076
1078{
1079 return Schematic().ErcSettings().GetSeverity( aErrorCode );
1080}
1081
1082
1084{
1086
1087 wxCHECK( GetScreen(), /* void */ );
1088
1090 m_autoSaveRequired = true;
1091
1092 GetCanvas()->Refresh();
1093
1094 if( !GetTitle().StartsWith( wxS( "*" ) ) )
1095 updateTitle();
1096}
1097
1098
1099void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
1100{
1101 if( Kiface().IsSingle() )
1102 {
1103 DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
1104 " in stand-alone mode. In order to create/update PCBs from"
1105 " schematics, launch the KiCad shell and create a project." ) );
1106 return;
1107 }
1108
1109 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1110
1111 if( !frame )
1112 {
1113 wxFileName fn = Prj().GetProjectFullName();
1114 fn.SetExt( FILEEXT::PcbFileExtension );
1115
1116 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1117
1118 // If Kiway() cannot create the Pcbnew frame, it shows a error message, and
1119 // frame is null
1120 if( !frame )
1121 return;
1122
1123 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1124 }
1125
1126 if( !frame->IsVisible() )
1127 frame->Show( true );
1128
1129 // On Windows, Raise() does not bring the window on screen, when iconized
1130 if( frame->IsIconized() )
1131 frame->Iconize( false );
1132
1133 frame->Raise();
1134
1135 std::string payload;
1137}
1138
1139
1141{
1142 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
1144}
1145
1146
1148{
1149 // Update only the hierarchy navigation tree labels.
1150 // The tree list is expectyed to be up to date
1152}
1153
1154
1156{
1158}
1159
1160
1162{
1163 wxString findString;
1164
1165 EE_SELECTION& selection = m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1166
1167 if( selection.Size() == 1 )
1168 {
1169 EDA_ITEM* front = selection.Front();
1170
1171 switch( front->Type() )
1172 {
1173 case SCH_SYMBOL_T:
1174 {
1175 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( front );
1176 findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() );
1177 break;
1178 }
1179
1180 case SCH_FIELD_T:
1181 findString = UnescapeString( static_cast<SCH_FIELD*>( front )->GetText() );
1182 break;
1183
1184 case SCH_LABEL_T:
1185 case SCH_GLOBAL_LABEL_T:
1186 case SCH_HIER_LABEL_T:
1187 case SCH_SHEET_PIN_T:
1188 findString = UnescapeString( static_cast<SCH_LABEL_BASE*>( front )->GetText() );
1189 break;
1190
1191 case SCH_TEXT_T:
1192 findString = UnescapeString( static_cast<SCH_TEXT*>( front )->GetText() );
1193
1194 if( findString.Contains( wxT( "\n" ) ) )
1195 findString = findString.Before( '\n' );
1196
1197 break;
1198
1199 default:
1200 break;
1201 }
1202 }
1203
1205 m_findReplaceDialog->Destroy();
1206
1208 static_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() ),
1209 wxDefaultPosition, wxDefaultSize,
1210 aReplace ? wxFR_REPLACEDIALOG : 0 );
1211
1214 m_findReplaceDialog->Show( true );
1215}
1216
1217
1218void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
1219{
1220 // Prepare the infobar, since we don't know its state
1223
1224 m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
1225}
1226
1227
1229{
1230 m_infoBar->Dismiss();
1231}
1232
1233
1235{
1238
1239 m_findReplaceDialog->Destroy();
1240 m_findReplaceDialog = nullptr;
1241
1243}
1244
1245
1246void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1247{
1248 wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1249
1250 if( fn.size() )
1251 OpenProjectFiles( std::vector<wxString>( 1, fn ) );
1252}
1253
1254
1255void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
1256{
1258}
1259
1260
1262{
1263 // Only standalone mode can directly load a new document
1264 if( !Kiface().IsSingle() )
1265 return;
1266
1267 wxString pro_dir = m_mruPath;
1268
1269 wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
1271
1272 if( dlg.ShowModal() != wxID_CANCEL )
1273 {
1274 // Enforce the extension, wxFileDialog is inept.
1275 wxFileName create_me =
1277
1278 if( create_me.FileExists() )
1279 {
1280 wxString msg;
1281 msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
1282 DisplayError( this, msg );
1283 return ;
1284 }
1285
1286 // OpenProjectFiles() requires absolute
1287 wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
1288
1289 OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1290 m_mruPath = create_me.GetPath();
1291 }
1292}
1293
1294
1296{
1297 // Only standalone mode can directly load a new document
1298 if( !Kiface().IsSingle() )
1299 return;
1300
1301 wxString pro_dir = m_mruPath;
1302 wxString wildcards = FILEEXT::AllSchematicFilesWildcard()
1304 + wxS( "|" ) + FILEEXT::LegacySchematicFileWildcard();
1305
1306 wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
1307 wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1308
1309 if( dlg.ShowModal() != wxID_CANCEL )
1310 {
1311 OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1313 }
1314}
1315
1316
1317void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
1318{
1319 wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
1320
1321 if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
1322 {
1323 kicad_board.SetExt( FILEEXT::PcbFileExtension );
1324 wxFileName legacy_board( kicad_board );
1325 legacy_board.SetExt( FILEEXT::LegacyPcbFileExtension );
1326 wxFileName& boardfn = legacy_board;
1327
1328 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1329 boardfn = kicad_board;
1330
1331 if( Kiface().IsSingle() )
1332 {
1333 ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
1334 }
1335 else
1336 {
1337 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1338
1339 if( !frame )
1340 {
1341 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1342
1343 // frame can be null if Cvpcb cannot be run. No need to show a warning
1344 // Kiway() generates the error messages
1345 if( !frame )
1346 return;
1347
1348 frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1349 }
1350
1351 if( !frame->IsVisible() )
1352 frame->Show( true );
1353
1354 // On Windows, Raise() does not bring the window on screen, when iconized
1355 if( frame->IsIconized() )
1356 frame->Iconize( false );
1357
1358 frame->Raise();
1359 }
1360 }
1361 else
1362 {
1363 // If we are running inside a project, it should be impossible for this case to happen
1364 wxASSERT( Kiface().IsSingle() );
1366 }
1367}
1368
1369
1370void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1371{
1372 wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1373 fn.SetExt( FILEEXT::NetlistFileExtension );
1374
1375 if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1376 return;
1377
1378 try
1379 {
1380 KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1381
1382 if( !player )
1383 {
1384 player = Kiway().Player( FRAME_CVPCB, true );
1385
1386 // player can be null if Cvpcb cannot be run. No need to show a warning
1387 // Kiway() generates the error messages
1388 if( !player )
1389 return;
1390
1391 player->Show( true );
1392 }
1393
1394 // Ensure the netlist (mainly info about symbols) is up to date
1397
1398 player->Raise();
1399 }
1400 catch( const IO_ERROR& )
1401 {
1402 DisplayError( this, _( "Could not open CvPcb" ) );
1403 }
1404}
1405
1406
1407void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1408{
1409 if( event.GetId() == wxID_EXIT )
1410 Kiway().OnKiCadExit();
1411
1412 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1413 Close( false );
1414}
1415
1416
1418{
1419 wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1420
1421 const wxBrush& brush =
1422 wxBrush( GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ).ToColour() );
1423 aSettings->GetPrintDC()->SetBackground( brush );
1424 aSettings->GetPrintDC()->Clear();
1425
1426 aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY );
1427 GetScreen()->Print( aSettings );
1428 PrintDrawingSheet( aSettings, GetScreen(), Schematic().GetProperties(), schIUScale.IU_PER_MILS,
1429 fileName );
1430}
1431
1432
1434{
1436 SIM_LIB_MGR simLibMgr( &Prj() );
1437 NULL_REPORTER devnull;
1438
1439 // Patch for bug early in V7.99 dev
1440 if( settings.m_OPO_VRange.EndsWith( 'A' ) )
1441 settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
1442
1443 // Update items which may have ${OP} text variables
1444 //
1446 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1447 {
1448 int flags = 0;
1449
1450 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1451 {
1452 item->RunOnChildren(
1453 [&flags]( SCH_ITEM* aChild )
1454 {
1455 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild );
1456
1457 if( text && text->HasTextVars() )
1458 {
1459 text->ClearRenderCache();
1460 text->ClearBoundingBoxCache();
1461 flags |= KIGFX::GEOMETRY | KIGFX::REPAINT;
1462 }
1463 } );
1464
1465 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
1466
1467 if( text && text->HasTextVars() )
1468 {
1469 text->ClearRenderCache();
1470 text->ClearBoundingBoxCache();
1472 }
1473 }
1474
1475 return flags;
1476 } );
1477
1478 // Update OP overlay items
1479 //
1480 for( SCH_ITEM* item : GetScreen()->Items() )
1481 {
1482 if( item->Type() == SCH_LINE_T )
1483 {
1484 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1485
1486 if( !line->GetOperatingPoint().IsEmpty() )
1487 GetCanvas()->GetView()->Update( line );
1488
1489 line->SetOperatingPoint( wxEmptyString );
1490 // update value from netlist, below
1491 }
1492 else if( item->Type() == SCH_SYMBOL_T )
1493 {
1494 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1495 wxString ref = symbol->GetRef( &GetCurrentSheet() );
1496 std::vector<SCH_PIN*> pins = symbol->GetPins( &GetCurrentSheet() );
1497
1498 // Power symbols and other symbols which have the reference starting with "#" are
1499 // not included in simulation
1500 if( ref.StartsWith( '#' ) || symbol->GetExcludedFromSim() )
1501 continue;
1502
1503 for( SCH_PIN* pin : pins )
1504 {
1505 if( !pin->GetOperatingPoint().IsEmpty() )
1506 GetCanvas()->GetView()->Update( pin );
1507
1508 pin->SetOperatingPoint( wxEmptyString );
1509 }
1510
1511 if( pins.size() == 2 )
1512 {
1513 wxString op = m_schematic->GetOperatingPoint( ref, settings.m_OPO_IPrecision,
1514 settings.m_OPO_IRange );
1515
1516 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1517 {
1518 pins[0]->SetOperatingPoint( op );
1519 GetCanvas()->GetView()->Update( symbol );
1520 }
1521 }
1522 else
1523 {
1524 SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol,
1525 devnull ).model;
1526
1527 SPICE_ITEM spiceItem;
1528 spiceItem.refName = ref;
1529 ref = model.SpiceGenerator().ItemName( spiceItem );
1530
1531 for( const auto& modelPin : model.GetPins() )
1532 {
1533 SCH_PIN* symbolPin = symbol->GetPin( modelPin.get().symbolPinNumber );
1534 wxString signalName = ref + wxS( ":" ) + modelPin.get().name;
1535 wxString op = m_schematic->GetOperatingPoint( signalName,
1536 settings.m_OPO_IPrecision,
1537 settings.m_OPO_IRange );
1538
1539 if( symbolPin && !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1540 {
1541 symbolPin->SetOperatingPoint( op );
1542 GetCanvas()->GetView()->Update( symbol );
1543 }
1544 }
1545 }
1546 }
1547 }
1548
1549 for( const auto& [ key, subgraphList ] : m_schematic->m_connectionGraph->GetNetMap() )
1550 {
1551 wxString op = m_schematic->GetOperatingPoint( key.Name, settings.m_OPO_VPrecision,
1552 settings.m_OPO_VRange );
1553
1554 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1555 {
1556 for( CONNECTION_SUBGRAPH* subgraph : subgraphList )
1557 {
1558 SCH_LINE* longestWire = nullptr;
1559 double length = 0.0;
1560
1561 for( SCH_ITEM* item : subgraph->GetItems() )
1562 {
1563 if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T } ) )
1564 {
1565 SCH_LINE* wire = static_cast<SCH_LINE*>( item );
1566
1567 if( wire->GetLength() > length )
1568 {
1569 longestWire = wire;
1570 length = wire->GetLength();
1571 }
1572 }
1573 }
1574
1575 if( longestWire )
1576 {
1577 longestWire->SetOperatingPoint( op );
1578 GetCanvas()->GetView()->Update( longestWire );
1579 }
1580 }
1581 }
1582 }
1583}
1584
1585
1587{
1588 if( aItem->IsType( { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) )
1589 {
1590 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
1591
1592 if( label->AutoRotateOnPlacement() )
1593 {
1594 SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
1595 label->GetSpinStyle(),
1596 &GetCurrentSheet() );
1597
1598 if( spin != label->GetSpinStyle() )
1599 {
1600 label->SetSpinStyle( spin );
1601
1602 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1603 {
1604 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1605
1606 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1607 otherLabel->AutoplaceFields( aScreen, false );
1608 }
1609 }
1610 }
1611 }
1612}
1613
1614
1616{
1617 SCH_SCREEN* screen = GetScreen();
1618
1619 wxCHECK( screen, /* void */ );
1620
1621 wxString title;
1622
1623 if( !screen->GetFileName().IsEmpty() )
1624 {
1625 wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1626 bool readOnly = false;
1627 bool unsaved = false;
1628
1629 if( fn.IsOk() && screen->FileExists() )
1630 readOnly = screen->IsReadOnly();
1631 else
1632 unsaved = true;
1633
1634 if( IsContentModified() )
1635 title = wxT( "*" );
1636
1637 title += fn.GetName();
1638
1639 wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
1640
1641 if( sheetPath != title )
1642 title += wxString::Format( wxT( " [%s]" ), sheetPath );
1643
1644 if( readOnly )
1645 title += wxS( " " ) + _( "[Read Only]" );
1646
1647 if( unsaved )
1648 title += wxS( " " ) + _( "[Unsaved]" );
1649 }
1650 else
1651 {
1652 title = _( "[no schematic loaded]" );
1653 }
1654
1655 title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1656
1657 SetTitle( title );
1658}
1659
1660
1662{
1664 GetScreen()->m_zoomInitialized = true;
1665}
1666
1667
1669{
1670 wxString highlightedConn = GetHighlightedConnection();
1671 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1673 SCH_COMMIT localCommit( m_toolManager );
1674
1675 if( !aCommit )
1676 aCommit = &localCommit;
1677
1678#ifdef PROFILE
1679 PROF_TIMER timer;
1680#endif
1681
1682 // Ensure schematic graph is accurate
1683 if( aCleanupFlags == LOCAL_CLEANUP )
1684 {
1685 SchematicCleanUp( aCommit, GetScreen() );
1686 }
1687 else if( aCleanupFlags == GLOBAL_CLEANUP )
1688 {
1689 for( const SCH_SHEET_PATH& sheet : list )
1690 SchematicCleanUp( aCommit, sheet.LastScreen() );
1691 }
1692
1693#ifdef PROFILE
1694 timer.Stop();
1695 wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1696#endif
1697
1698 if( settings.m_IntersheetRefsShow )
1700
1701 std::function<void( SCH_ITEM* )> changeHandler =
1702 [&]( SCH_ITEM* aChangedItem ) -> void
1703 {
1704 GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1705
1706 SCH_CONNECTION* connection = aChangedItem->Connection();
1707
1708 if( connection && ( connection->Name() == highlightedConn ) )
1710 };
1711
1712 if( !ADVANCED_CFG::GetCfg().m_IncrementalConnectivity || aCleanupFlags == GLOBAL_CLEANUP
1713 || m_undoList.m_CommandsList.empty() )
1714 {
1715 Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
1716 }
1717 else
1718 {
1719 PICKED_ITEMS_LIST* changed_list = m_undoList.m_CommandsList.back();
1720 std::set<SCH_ITEM*> changed_items;
1721 std::vector<VECTOR2I> pts;
1722 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> item_paths;
1723
1724 for( unsigned ii = 0; ii < changed_list->GetCount(); ++ii )
1725 {
1726 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItem( ii ) );
1727
1728 // Ignore objects that are not connectable.
1729 if( !item || !item->IsConnectable() )
1730 continue;
1731
1732 SCH_SCREEN* screen = static_cast<SCH_SCREEN*>( changed_list->GetScreenForItem( ii ) );
1733 SCH_SHEET_PATHS& paths = screen->GetClientSheetPaths();
1734
1735 std::vector<VECTOR2I> tmp_pts = item->GetConnectionPoints();
1736 pts.insert( pts.end(), tmp_pts.begin(), tmp_pts.end() );
1737 changed_items.insert( item );
1738
1739 for( SCH_SHEET_PATH& path : paths )
1740 item_paths.insert( std::make_pair( path, item ) );
1741 }
1742
1743 for( VECTOR2I& pt: pts )
1744 {
1745 for( SCH_ITEM* item : GetScreen()->Items().Overlapping( pt ) )
1746 {
1747 if( item->Type() == SCH_LINE_T )
1748 {
1749 if( item->HitTest( pt ) )
1750 changed_items.insert( item );
1751 }
1752 else if( item->Type() == SCH_SYMBOL_T )
1753 {
1754 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1755 std::vector<SCH_PIN*> pins = symbol->GetPins();
1756
1757 changed_items.insert( pins.begin(), pins.end() );
1758 }
1759 else if( item->Type() == SCH_SHEET_T )
1760 {
1761 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1762
1763 wxCHECK2( sheet, continue );
1764
1765 std::vector<SCH_SHEET_PIN*> sheetPins = sheet->GetPins();
1766 changed_items.insert( sheetPins.begin(), sheetPins.end() );
1767 }
1768 else
1769 {
1770 // Non-connectable objects have already been pruned.
1771 if( item->IsConnected( pt ) )
1772 changed_items.insert( item );
1773 }
1774 }
1775 }
1776
1777 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> all_items =
1778 Schematic().ConnectionGraph()->ExtractAffectedItems( changed_items );
1779
1780 all_items.insert( item_paths.begin(), item_paths.end() );
1781
1782 CONNECTION_GRAPH new_graph( &Schematic() );
1783
1784 new_graph.SetLastCodes( Schematic().ConnectionGraph() );
1785
1786 for( auto&[ path, item ] : all_items )
1787 {
1788 wxCHECK2( item, continue );
1789
1790 switch( item->Type() )
1791 {
1792 case SCH_FIELD_T:
1793 case SCH_PIN_T:
1794 {
1795 SCH_ITEM* parent = static_cast<SCH_ITEM*>( item->GetParent() );
1796 wxCHECK2( parent, continue );
1797 parent->SetConnectivityDirty();
1798 break;
1799 }
1800
1801 default:
1802 item->SetConnectivityDirty();
1803 }
1804 }
1805
1806 new_graph.Recalculate( list, false, &changeHandler );
1807 Schematic().ConnectionGraph()->Merge( new_graph );
1808 }
1809
1811 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1812 {
1813 int flags = 0;
1814 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
1815 SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
1816
1817 if( connection && connection->HasDriverChanged() )
1818 {
1819 connection->ClearDriverChanged();
1820 flags |= KIGFX::REPAINT;
1821 }
1822
1823 if( item )
1824 {
1825 item->RunOnChildren(
1826 [&flags]( SCH_ITEM* aChild )
1827 {
1828 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild );
1829
1830 if( text && text->HasTextVars() )
1831 {
1832 text->ClearRenderCache();
1833 text->ClearBoundingBoxCache();
1835 }
1836 } );
1837
1838 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
1839
1840 if( text && text->HasTextVars() )
1841 {
1842 text->ClearRenderCache();
1843 text->ClearBoundingBoxCache();
1845 }
1846
1847 if( flags & KIGFX::GEOMETRY )
1848 GetScreen()->Update( item, false ); // Refresh RTree
1849 }
1850
1851 return flags;
1852 } );
1853
1854 if( !highlightedConn.IsEmpty() )
1855 {
1857 || !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
1859
1861 }
1862
1863 if( !localCommit.Empty() )
1864 localCommit.Push( _( "Schematic Cleanup" ) );
1865}
1866
1867
1869{
1871 {
1872 for( SCH_FIELD& field : label->GetFields() )
1873 field.ClearBoundingBoxCache();
1874
1875 label->ClearBoundingBoxCache();
1876 GetCanvas()->GetView()->Update( label );
1877 } );
1878}
1879
1880
1882{
1884
1886}
1887
1888
1889void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1890{
1891 SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1892
1893 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1894
1896
1898
1899 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
1902
1903 KIGFX::VIEW* view = GetCanvas()->GetView();
1909
1911
1912 settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
1913
1914 if( !cfg->m_Drawing.field_names.IsEmpty() )
1916
1918
1919 for( SCH_ITEM* item : screen->Items() )
1920 item->ClearCaches();
1921
1922 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
1923 libSymbol->ClearCaches();
1924
1926
1928 Layout();
1929 SendSizeEvent();
1930}
1931
1932
1934{
1935 // Store the current zoom level into the current screen before calling
1936 // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
1938
1939 // Rebuild the sheet view (draw area and any other items):
1941}
1942
1943
1945{
1946 // call my base class
1948
1949 // tooltips in toolbars
1951
1952 m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
1953 m_auimgr.Update();
1955
1957
1958 // status bar
1960
1961 updateTitle();
1962
1963 // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1964 // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1965 // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1966 // toolbar to update correctly.
1967#if defined( __WXMSW__ )
1968 PostSizeEvent();
1969#endif
1970}
1971
1972
1974{
1975 if( !GetHighlightedConnection().IsEmpty() )
1976 {
1977 SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
1979 }
1980 else
1981 {
1982 SetStatusText( wxT( "" ) );
1983 }
1984}
1985
1986
1988{
1989 if( m_toolManager )
1991
1992 SCH_BASE_FRAME::SetScreen( aScreen );
1993 GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1994
1995 if( m_toolManager )
1997}
1998
1999
2000const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
2001{
2002 BOX2I bBoxDoc;
2003
2004 if( aIncludeAllVisible )
2005 {
2006 // Get the whole page size and return that
2009 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
2010 }
2011 else
2012 {
2013 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
2015 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
2016
2017 // Calc the bounding box of all items on screen except the page border
2018 for( EDA_ITEM* item : GetScreen()->Items() )
2019 {
2020 if( item != dsAsItem ) // Ignore the drawing-sheet itself
2021 bBoxDoc.Merge( item->GetBoundingBox() );
2022 }
2023 }
2024
2025 return bBoxDoc;
2026}
2027
2028
2030{
2031 return Schematic().GetSheets().IsModified();
2032}
2033
2034
2036{
2037 EESCHEMA_SETTINGS* cfg = eeconfig();
2038 return cfg && cfg->m_Appearance.show_hidden_pins;
2039}
2040
2041
2043{
2044 static KIID lastBrightenedItemID( niluuid );
2045
2046 SCH_SHEET_LIST sheetList = Schematic().GetSheets();
2048 SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
2049
2050 if( lastItem && lastItem != aItem )
2051 {
2052 lastItem->ClearBrightened();
2053
2054 UpdateItem( lastItem );
2055 lastBrightenedItemID = niluuid;
2056 }
2057
2058 if( aItem )
2059 {
2060 if( !aItem->IsBrightened() )
2061 {
2062 aItem->SetBrightened();
2063
2064 UpdateItem( aItem );
2065 lastBrightenedItemID = aItem->m_Uuid;
2066 }
2067
2069 }
2070}
2071
2072
2074{
2075 return Schematic().GetFileName();
2076}
2077
2078
2080{
2081 return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
2082}
2083
2084
2085void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2086{
2087 if( IsShown() )
2088 {
2089 // We only need this until the frame is done resizing and the final client size is
2090 // established.
2091 Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
2093 }
2094
2095 // Skip() is called in the base class.
2096 EDA_DRAW_FRAME::OnSize( aEvent );
2097}
2098
2099
2101 const KIID& aSchematicSymbolUUID )
2102{
2103 SCH_SHEET_PATH principalPath;
2104 SCH_ITEM* item = Schematic().GetSheets().GetItem( aSchematicSymbolUUID, &principalPath );
2105 SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
2106 SCH_COMMIT commit( m_toolManager );
2107
2108 if( !principalSymbol )
2109 return;
2110
2111 wxString principalRef;
2112
2113 if( principalSymbol->IsAnnotated( &principalPath ) )
2114 principalRef = principalSymbol->GetRef( &principalPath, false );
2115
2116 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
2117
2118 for( const SCH_SHEET_PATH& path : Schematic().GetSheets() )
2119 {
2120 for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2121 {
2122 SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
2123
2124 if( candidateSymbol == principalSymbol
2125 || ( candidateSymbol->IsAnnotated( &path )
2126 && candidateSymbol->GetRef( &path, false ) == principalRef ) )
2127 {
2128 allUnits.emplace_back( candidateSymbol, path );
2129 }
2130 }
2131 }
2132
2133 for( auto& [ unit, path ] : allUnits )
2134 {
2135 // This needs to be done before the LIB_SYMBOL is changed to prevent stale
2136 // library symbols in the schematic file.
2137 path.LastScreen()->Remove( unit );
2138
2139 if( !unit->IsNew() )
2140 commit.Modify( unit, path.LastScreen() );
2141
2142 unit->SetLibSymbol( aSymbol.Flatten().release() );
2143 unit->UpdateFields( &GetCurrentSheet(),
2144 true, /* update style */
2145 true, /* update ref */
2146 true, /* update other fields */
2147 false, /* reset ref */
2148 false /* reset other fields */ );
2149
2150 path.LastScreen()->Append( unit );
2151 GetCanvas()->GetView()->Update( unit );
2152 }
2153
2154 if( !commit.Empty() )
2155 commit.Push( _( "Save Symbol to Schematic" ) );
2156}
2157
2158
2159void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2160{
2161 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2162
2163 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
2164 sch_item->ClearCaches();
2165}
2166
2167
2169{
2170 wxCHECK( m_toolManager, /* void */ );
2171
2175
2176 wxCHECK( screen, /* void */ );
2177
2179
2180 SCH_BASE_FRAME::SetScreen( screen );
2181
2183
2184 // update the references, units, and intersheet-refs
2186
2187 // dangling state can also have changed if different units with different pin locations are
2188 // used
2192
2194
2195 wxCHECK( selectionTool, /* void */ );
2196
2197 auto visit =
2198 [&]( EDA_ITEM* item )
2199 {
2201 && !m_findReplaceData->findString.IsEmpty()
2202 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
2203 {
2204 item->SetForceVisible( true );
2205 selectionTool->BrightenItem( item );
2206 }
2207 else if( item->IsBrightened() )
2208 {
2209 item->SetForceVisible( false );
2210 selectionTool->UnbrightenItem( item );
2211 }
2212 };
2213
2214 for( SCH_ITEM* item : screen->Items() )
2215 {
2216 visit( item );
2217
2218 item->RunOnChildren(
2219 [&]( SCH_ITEM* aChild )
2220 {
2221 visit( aChild );
2222 } );
2223 }
2224
2225 if( !screen->m_zoomInitialized )
2226 {
2228 }
2229 else
2230 {
2231 // Set zoom to last used in this screen
2232 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
2233 GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
2234 }
2235
2236 updateTitle();
2237
2238 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
2239
2240 // Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
2242
2244
2245 wxCHECK( editTool, /* void */ );
2246
2248 editTool->UpdateNetHighlighting( dummy );
2249
2251
2253}
2254
2255
2257{
2258 if( !m_diffSymbolDialog )
2260 _( "Compare Symbol with Library" ) );
2261
2262 return m_diffSymbolDialog;
2263}
2264
2265
2266void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
2267{
2268 if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
2269 {
2270 m_diffSymbolDialog->Destroy();
2271 m_diffSymbolDialog = nullptr;
2272 }
2273}
2274
2275
2277{
2278 if( !m_ercDialog )
2279 m_ercDialog = new DIALOG_ERC( this );
2280
2281 return m_ercDialog;
2282}
2283
2284
2285void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
2286{
2287 if( m_ercDialog )
2288 {
2289 m_ercDialog->Destroy();
2290 m_ercDialog = nullptr;
2291 }
2292}
2293
2294
2296{
2299
2301}
2302
2303
2305{
2307 {
2308 m_symbolFieldsTableDialog->Destroy();
2309 m_symbolFieldsTableDialog = nullptr;
2310 }
2311}
2312
2313
2314void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
2315{
2316 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2317 aListener );
2318
2319 // Don't add duplicate listeners.
2320 if( it == m_schematicChangeListeners.end() )
2321 m_schematicChangeListeners.push_back( aListener );
2322}
2323
2324
2326{
2327 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2328 aListener );
2329
2330 // Don't add duplicate listeners.
2331 if( it != m_schematicChangeListeners.end() )
2332 m_schematicChangeListeners.erase( it );
2333}
2334
2335
2337{
2338 m_netNavigator = new wxTreeCtrl( this, wxID_ANY, wxPoint( 0, 0 ),
2339 FromDIP( wxSize( 160, 250 ) ),
2340 wxTR_DEFAULT_STYLE | wxNO_BORDER );
2341
2342 return m_netNavigator;
2343}
2344
2345
2346void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection,
2347 const NET_NAVIGATOR_ITEM_DATA* aSelection )
2348{
2349 bool refreshNetNavigator = aConnection != m_highlightedConn;
2350
2351 m_highlightedConn = aConnection;
2352
2353 if( refreshNetNavigator )
2354 RefreshNetNavigator( aSelection );
2355}
2356
2357
2359{
2360 if( m_netNavigator && !m_highlightedConn.IsEmpty() )
2361 {
2362 NET_NAVIGATOR_ITEM_DATA itemData;
2363 wxTreeItemId selection = m_netNavigator->GetSelection();
2364 bool refreshSelection = selection.IsOk() && ( selection != m_netNavigator->GetRootItem() );
2365
2366 if( refreshSelection )
2367 {
2369 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
2370
2371 wxCHECK( tmp, /* void */ );
2372 itemData = *tmp;
2373 }
2374
2375 m_netNavigator->DeleteAllItems();
2376 RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
2377 }
2378
2380}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
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
@ icon_eeschema_16
@ icon_eeschema_32
BOX2< VECTOR2I > BOX2I
Definition: box2.h:853
static TOOL_ACTION toggleGrid
Definition: actions.h:149
static TOOL_ACTION paste
Definition: actions.h:70
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
static TOOL_ACTION millimetersUnits
Definition: actions.h:157
static TOOL_ACTION unselectAll
Definition: actions.h:73
static TOOL_ACTION copy
Definition: actions.h:69
static TOOL_ACTION updateFind
Definition: actions.h:87
static TOOL_ACTION pasteSpecial
Definition: actions.h:71
static TOOL_ACTION milsUnits
Definition: actions.h:156
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:112
static TOOL_ACTION showSearch
Definition: actions.h:79
static TOOL_ACTION undo
Definition: actions.h:66
static TOOL_ACTION duplicate
Definition: actions.h:74
static TOOL_ACTION inchesUnits
Definition: actions.h:155
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:109
static TOOL_ACTION doDelete
Definition: actions.h:75
static TOOL_ACTION selectionTool
Definition: actions.h:164
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:101
static TOOL_ACTION redo
Definition: actions.h:67
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION zoomTool
Definition: actions.h:104
static TOOL_ACTION showProperties
Definition: actions.h:178
static TOOL_ACTION cut
Definition: actions.h:68
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:150
static TOOL_ACTION selectAll
Definition: actions.h:72
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...
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
WINDOW_SETTINGS m_Window
Definition: app_settings.h:170
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:589
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
bool Empty() const
Returns status of an item.
Definition: commit.h:144
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
Definition: common_tools.h:38
Calculate the connectivity of a schematic and generates netlists.
const NET_MAP & GetNetMap() const
CONNECTION_SUBGRAPH * FindFirstSubgraphByName(const wxString &aNetName)
Retrieve a subgraph for the given net name, if one exists.
std::set< std::pair< SCH_SHEET_PATH, SCH_ITEM * > > ExtractAffectedItems(const std::set< SCH_ITEM * > &aItems)
For a set of items, this will remove the connected items and their associated data including subgraph...
void SetLastCodes(const CONNECTION_GRAPH *aOther)
void Merge(CONNECTION_GRAPH &aGraph)
Combine the input graph contents into the current graph.
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr)
Update the connection graph for the given list of sheets.
A subgraph is a set of items that are electrically connected on a single sheet.
wxArrayString GetFindEntries() const
wxArrayString GetReplaceEntries() const
void SetReplaceEntries(const wxArrayString &aEntries)
void SetFindEntries(const wxArrayString &aEntries, const wxString &aFindString)
bool Show(bool show) override
virtual APP_SETTINGS_BASE * config() const
Returns 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.
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...
WX_INFOBAR * m_infoBar
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxAuiManager m_auimgr
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
virtual void OnSize(wxSizeEvent &aEvent)
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handles event fired when a file is dropped to the window.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches the file name from the file history list.
static wxString GetAutoSaveFilePrefix()
virtual int GetUndoCommandCount() const
wxString m_mruPath
wxArrayString m_replaceStringHistoryList
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
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.
static const wxString PropertiesPaneName()
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
virtual void SetScreen(BASE_SCREEN *aScreen)
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
virtual void UpdateMsgPanel()
Redraw the message panel.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
wxArrayString m_findStringHistoryList
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
PROPERTIES_PANEL * m_propertiesPanel
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:85
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:246
const KIID m_Uuid
Definition: eda_item.h:482
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
void ClearBrightened()
Definition: eda_item.h:119
void SetBrightened()
Definition: eda_item.h:116
bool IsBrightened() const
Definition: eda_item.h:108
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:95
virtual void ClearBoundingBoxCache()
Definition: eda_text.cpp:489
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 ScriptingConsoleVisible()
Create a functor testing if the python scripting console window is visible.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
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.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
PANEL_ANNOTATE m_AnnotatePanel
Gather all the actions that are shared by tools.
Definition: ee_actions.h:39
static TOOL_ACTION mirrorV
Definition: ee_actions.h:118
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:161
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
static TOOL_ACTION toggleAnnotateAuto
Definition: ee_actions.h:256
static TOOL_ACTION lineMode90
Definition: ee_actions.h:251
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:224
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:79
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION showPythonConsole
Definition: ee_actions.h:246
static TOOL_ACTION toggleERCWarnings
Definition: ee_actions.h:227
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:229
static TOOL_ACTION placeClassLabel
Definition: ee_actions.h:88
static TOOL_ACTION drawWire
Definition: ee_actions.h:81
static TOOL_ACTION drawCircle
Definition: ee_actions.h:96
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:117
static TOOL_ACTION lineModeFree
Definition: ee_actions.h:250
static TOOL_ACTION drawBus
Definition: ee_actions.h:82
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:228
static TOOL_ACTION placePower
Definition: ee_actions.h:80
static TOOL_ACTION drawLines
Definition: ee_actions.h:98
static TOOL_ACTION toggleOPCurrents
Definition: ee_actions.h:231
static TOOL_ACTION mirrorH
Definition: ee_actions.h:119
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:281
static TOOL_ACTION rotateCW
Definition: ee_actions.h:116
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:92
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:210
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:225
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:89
static TOOL_ACTION ddAppendFile
Definition: ee_actions.h:285
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:90
static TOOL_ACTION drawTextBox
Definition: ee_actions.h:94
static TOOL_ACTION showNetNavigator
Definition: ee_actions.h:282
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:95
static TOOL_ACTION placeImage
Definition: ee_actions.h:99
static TOOL_ACTION toggleDirectiveLabels
Definition: ee_actions.h:226
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:216
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:93
static TOOL_ACTION toggleOPVoltages
Definition: ee_actions.h:230
static TOOL_ACTION drawArc
Definition: ee_actions.h:97
static TOOL_ACTION lineMode45
Definition: ee_actions.h:252
static TOOL_ACTION drawSheet
Definition: ee_actions.h:91
static TOOL_ACTION navigateNext
Definition: ee_actions.h:215
static TOOL_ACTION placeLabel
Definition: ee_actions.h:87
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:86
static TOOL_ACTION placeJunction
Definition: ee_actions.h:85
static TOOL_ACTION navigatePrevious
Definition: ee_actions.h:214
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:84
Tool that displays edit points allowing to modify items by dragging the points.
bool empty() const
Definition: sch_rtree.h:176
EE_TYPE Overlapping(const BOX2I &aRect) const
Definition: sch_rtree.h:243
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
SEVERITY GetSeverity(int aErrorCode) const
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
void UpdateLabelsHierarchyTree()
Update the labels of the hierarchical tree of the schematic.
void UpdateHierarchySelection()
Updates the tree's selection to match current page.
void UpdateHierarchyTree()
Update the hierarchical tree of the schematic.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetDefaultFont(const wxString &aFont)
wxDC * GetPrintDC() const
Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:134
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: sch_view.h:103
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Set the scaling factor, zooming around a given anchor point.
Definition: sch_view.cpp:75
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
double GetScale() const
Definition: view.h:271
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1619
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:395
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:215
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:573
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:1511
Definition: kiid.h:49
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:67
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.
Definition: kiway_player.h:115
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:279
void OnKiCadExit()
Definition: kiway.cpp:737
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:432
virtual bool PlayerClose(FRAME_T aFrameType, bool doForce)
Call the KIWAY_PLAYER::Close( bool force ) function on the window and if not vetoed,...
Definition: kiway.cpp:496
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:553
Define a library symbol object.
Definition: lib_symbol.h:99
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:605
Tree view item data for the net navigator.
A singleton reporter that reports to nowhere.
Definition: reporter.h:223
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:162
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:153
A holder to handle information on schematic or board items.
unsigned GetCount() const
BASE_SCREEN * GetScreenForItem(unsigned int aIdx) const
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
A small class to help profiling.
Definition: profile.h:47
void Stop()
Save the time when this function was called, and set the counter stane to stop.
Definition: profile.h:86
double msecs(bool aSinceLast=false)
Definition: profile.h:147
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:129
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:135
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:320
virtual void LanguageChanged()
Parents will call this when the user changes the UI language.
Action handler for the Properties panel.
These settings were stored in SCH_BASE_FRAME previously.
Holds all the data relating to one schematic.
Definition: schematic.h:75
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:128
CONNECTION_GRAPH * m_connectionGraph
Holds and calculates connectivity information of this schematic.
Definition: schematic.h:329
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:136
void OnSchSheetChanged()
Notify the schematic and its listeners that the current sheet has been changed.
Definition: schematic.cpp:784
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
Definition: schematic.cpp:718
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:281
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:287
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:146
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:141
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:100
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:184
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:154
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:197
void RecomputeIntersheetRefs(const std::function< void(SCH_GLOBALLABEL *)> &aItemCallback)
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
Definition: schematic.cpp:656
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:121
void RemoveAllListeners()
Remove all listeners.
Definition: schematic.cpp:809
SCH_SHEET & Root() const
Definition: schematic.h:105
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:627
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:294
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
EESCHEMA_SETTINGS * eeconfig() const
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
virtual void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Definition: sch_commit.cpp:367
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
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.
SELECTION_CONDITION LineMode(LINE_MODE aMode)
Create a functor that tests if the frame is in the specified line drawing mode.
Handle actions specific to the schematic editor.
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
Schematic editor (Eeschema) main window.
bool IsContentModified() const override
Get if the current schematic has been modified but not saved.
void RefreshOperatingPointDisplay()
Refresh the display of any operaintg points.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
EDA_ITEM * GetItem(const KIID &aId) const override
Fetch an item by KIID.
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 onResizeNetNavigator(wxSizeEvent &aEvent)
bool m_highlightedConnChanged
void onNetNavigatorSelChanging(wxTreeEvent &aEvent)
void OnOpenCvpcb(wxCommandEvent &event)
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 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 ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
void UpdateHierarchySelection()
Update the hierarchy navigation tree selection (cross-probe from schematic to hierarchy pane).
void SetScreen(BASE_SCREEN *aScreen) override
void OnFindDialogClose()
Notification that the Find dialog has closed.
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
Update a schematic symbol from a LIB_SYMBOL.
void SchematicCleanUp(SCH_COMMIT *aCommit, SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
void onSize(wxSizeEvent &aEvent)
void ShowChangedLanguage() override
std::vector< wxEvtHandler * > m_schematicChangeListeners
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
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.
void OnAppendProject(wxCommandEvent &event)
SCHEMATIC * m_schematic
The currently loaded schematic.
void onCloseSymbolFieldsTableDialog(wxCommandEvent &aEvent)
void ClearFindReplaceStatus()
SCH_SHEET_PATH & GetCurrentSheet() const
void OnLoadFile(wxCommandEvent &event)
SCHEMATIC & Schematic() const
void updateTitle()
Set the main window title bar text.
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 OnUpdatePCB(wxCommandEvent &event)
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.
void OnOpenPcbnew(wxCommandEvent &event)
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void OnPageSettingsChange() override
Called when modifying the page settings.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
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)
static const wxString SchematicHierarchyPaneName()
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
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 ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
int GetSchematicJunctionSize()
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.
DIALOG_SCH_FIND * m_findReplaceDialog
void UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.
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 OnExit(wxCommandEvent &event)
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it)
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
SEVERITY GetSeverity(int aErrorCode) const override
void onNetNavigatorSelection(wxTreeEvent &aEvent)
void FocusOnItem(SCH_ITEM *aItem)
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:52
Handle actions specific to the schematic editor.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
virtual bool IsConnectable() const
Definition: sch_item.h:372
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:473
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:438
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:147
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:387
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:94
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_item.h:166
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:1377
SPIN_STYLE GetSpinStyle() const
Definition: sch_label.cpp:372
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_label.cpp:637
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:191
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Definition: sch_label.cpp:337
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:40
void SetOperatingPoint(const wxString &aText)
Definition: sch_line.h:303
double GetLength() const
Definition: sch_line.cpp:237
const wxString & GetOperatingPoint() const
Definition: sch_line.h:302
Handle actions specific to the schematic editor.
void SetOperatingPoint(const wxString &aText)
Definition: sch_pin.h:165
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:704
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:131
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:275
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Return the number of times this screen is used.
Definition: sch_screen.h:178
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:481
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:628
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
void Print(const RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
const wxString & GetFileName() const
Definition: sch_screen.h:144
const KIID & GetUuid() const
Definition: sch_screen.h:525
bool IsReadOnly() const
Definition: sch_screen.h:147
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:115
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:313
bool m_zoomInitialized
Definition: sch_screen.h:653
bool FileExists() const
Definition: sch_screen.h:150
SPIN_STYLE GetLabelOrientationForPoint(const VECTOR2I &aPosition, SPIN_STYLE aDefaultOrientation, const SCH_SHEET_PATH *aSheet) const
Definition: sch_screen.cpp:505
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) 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()
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
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.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
wxString GetName() const
Definition: sch_sheet.h:107
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:162
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:181
Schematic symbol object.
Definition: sch_symbol.h:109
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:748
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:950
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
bool GetExcludedFromSim() const override
Definition: sch_symbol.h:854
bool IsAnnotated(const SCH_SHEET_PATH *aSheet)
Check if the symbol has a valid annotation (reference) for the given sheet path.
Definition: sch_symbol.cpp:826
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
VECTOR2I GetPosition() const override
Definition: sch_text.h:134
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)
void UnbrightenItem(EDA_ITEM *aItem)
EDA_ITEM * Front() const
Definition: selection.h:208
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< LIB_PIN * > &aPins, REPORTER &aReporter)
std::vector< std::reference_wrapper< const PIN > > GetPins() const
Definition: sim_model.cpp:756
const SPICE_GENERATOR & SpiceGenerator() const
Definition: sim_model.h:439
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
Definition: tools_holder.h:167
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:169
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:168
@ 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:167
Master controller class:
Definition: tool_manager.h:57
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:145
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:289
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:230
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void InitTools()
Initializes all registered tools.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: wx_infobar.cpp:301
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: wx_infobar.cpp:140
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:187
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: wx_infobar.cpp:291
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:415
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
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:240
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#define _HKI(x)
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define SCH_EDIT_FRAME_NAME
@ ID_IMPORT_NON_KICAD_SCH
Definition: eeschema_id.h:57
const wxAuiPaneInfo & defaultPropertiesPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultNetNavigatorPaneInfo()
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)
Call the executable file aEditorName with the parameter aFileName.
Definition: gestfich.cpp:140
static const std::string NetlistFileExtension
static const std::string LegacyPcbFileExtension
static const std::string KiCadSchematicFileExtension
static wxString LegacySchematicFileWildcard()
static wxString AllSchematicFilesWildcard()
static wxString KiCadSchematicFileWildcard()
@ ID_FILE_LIST_CLEAR
Definition: id.h:87
@ ID_EDA_SOCKET_EVENT
Definition: id.h:163
@ ID_EDA_SOCKET_EVENT_SERV
Definition: id.h:162
@ ID_FILEMAX
Definition: id.h:85
@ ID_FILE1
Definition: id.h:84
@ ID_APPEND_PROJECT
Definition: id.h:74
PROJECT & Prj()
Definition: kicad.cpp:591
KIID niluuid(0)
KIWAY Kiway
#define KICTL_CREATE
caller thinks requested project files may not exist.
Definition: kiway_player.h:78
@ LAYER_ERC_WARN
Definition: layer_ids.h:381
@ LAYER_ERC_EXCLUSION
Definition: layer_ids.h:383
@ LAYER_ERC_ERR
Definition: layer_ids.h:382
@ LAYER_OP_CURRENTS
Definition: layer_ids.h:400
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:388
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:366
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:399
@ MAIL_PCB_UPDATE
Definition: mail_type.h:46
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:54
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:90
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:79
see class PGM_BASE
SEVERITY
#define DIFF_SYMBOLS_DIALOG_NAME
wxDEFINE_EVENT(EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent)
#define CURRENT_TOOL(action)
SCH_CLEANUP_FLAGS
@ LOCAL_CLEANUP
@ GLOBAL_CLEANUP
std::vector< SCH_SHEET_PATH > SCH_SHEET_PATHS
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:119
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
const double IU_PER_MILS
Definition: base_units.h:78
std::string refName
Definition for symbol library class.
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ SCH_LINE_T
Definition: typeinfo.h:146
@ SCH_SYMBOL_T
Definition: typeinfo.h:156
@ SCH_FIELD_T
Definition: typeinfo.h:155
@ SCH_LABEL_T
Definition: typeinfo.h:151
@ SCH_SHEET_T
Definition: typeinfo.h:158
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:153
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:157
@ SCH_TEXT_T
Definition: typeinfo.h:150
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152
@ SCH_PIN_T
Definition: typeinfo.h:159
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588
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.