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-2023 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 <schematic.h>
58#include <sch_commit.h>
60#include <advanced_config.h>
61#include <sim/simulator_frame.h>
62#include <tool/action_manager.h>
63#include <tool/action_toolbar.h>
64#include <tool/common_control.h>
65#include <tool/common_tools.h>
66#include <tool/picker_tool.h>
68#include <tool/selection.h>
70#include <tool/tool_manager.h>
71#include <tool/zoom_tool.h>
72#include <tools/ee_actions.h>
77#include <tools/sch_edit_tool.h>
81#include <tools/sch_move_tool.h>
84#include <view/view_controls.h>
85#include <widgets/wx_infobar.h>
90#include <wx/cmdline.h>
91#include <wx/app.h>
92#include <wx/filedlg.h>
93#include <wx/socket.h>
96
97
98#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
99
100
101BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
104
105 EVT_SIZE( SCH_EDIT_FRAME::OnSize )
106
109
112
113 EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
114 EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
115
116 // Drop files event
117 EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
118END_EVENT_TABLE()
119
120
121wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
122
123
124SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
125 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
127 m_ercDialog( nullptr ),
128 m_diffSymbolDialog( nullptr ),
129 m_symbolFieldsTableDialog( nullptr ),
130 m_netNavigator( nullptr ),
131 m_highlightedConnChanged( false )
132{
133 m_maximizeByDefault = true;
134 m_schematic = new SCHEMATIC( nullptr );
135
136 m_showBorderAndTitleBlock = true; // true to show sheet references
137 m_supportsAutoSave = true;
138 m_syncingPcbToSchSelection = false;
139 m_aboutTitle = _HKI( "KiCad Schematic Editor" );
140 m_show_search = false;
141
142 m_findReplaceDialog = nullptr;
143
144 m_findReplaceData = std::make_unique<SCH_SEARCH_DATA>();
145
146 // Give an icon
147 wxIcon icon;
148 wxIconBundle icon_bundle;
149
150 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema ) );
151 icon_bundle.AddIcon( icon );
152 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
153 icon_bundle.AddIcon( icon );
154 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
155 icon_bundle.AddIcon( icon );
156
157 SetIcons( icon_bundle );
158
159 LoadSettings( eeconfig() );
160
161 // NB: also links the schematic to the loaded project
162 CreateScreens();
163 SetCurrentSheet( Schematic().GetSheets()[0] );
164
165 setupTools();
166 setupUIConditions();
167 ReCreateMenuBar();
168 ReCreateHToolbar();
169 ReCreateVToolbar();
170 ReCreateOptToolbar();
171
172 m_hierarchy = new HIERARCHY_PANE( this );
173
174 // Initialize common print setup dialog settings.
175 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
176 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
177 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
178 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
179
180 m_searchPane = new SCH_SEARCH_PANE( this );
181 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
182
183 m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
184
185 m_auimgr.SetManagedWindow( this );
186
187 CreateInfoBar();
188
189 // Rows; layers 4 - 6
190 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxS( "MainToolbar" ) )
191 .Top().Layer( 6 ) );
192
193 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
194 .Bottom().Layer( 6 ) );
195
196 // Columns; layers 1 - 3
197 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
198 .Caption( _( "Schematic Hierarchy" ) )
199 .Left().Layer( 3 )
200 .TopDockable( false )
201 .BottomDockable( false )
202 .CloseButton( true )
203 .MinSize( 120, 60 )
204 .BestSize( 200, 200 )
205 .FloatingSize( 200, 200 )
206 .FloatingPosition( 50, 50 )
207 .Show( false ) );
208
209 m_auimgr.AddPane( m_propertiesPanel, defaultPropertiesPaneInfo() );
210
211 m_auimgr.AddPane( createHighlightedNetNavigator(), defaultNetNavigatorPaneInfo() );
212
213 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( wxS( "OptToolbar" ) )
214 .Left().Layer( 2 ) );
215
216 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( wxS( "ToolsToolbar" ) )
217 .Right().Layer( 2 ) );
218
219 // Center
220 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
221 .Center() );
222
223 m_auimgr.AddPane( m_searchPane, EDA_PANE()
224 .Name( SearchPaneName() )
225 .Bottom()
226 .Caption( _( "Search" ) )
227 .PaneBorder( false )
228 .MinSize( 180, -1 )
229 .BestSize( 180, -1 )
230 .FloatingSize( 480, 200 )
231 .CloseButton( true )
232 .DestroyOnClose( false )
233 .Show( m_show_search ) );
234
235 FinishAUIInitialization();
236
237 resolveCanvasType();
238 SwitchCanvas( m_canvasType );
239
240 GetCanvas()->GetGAL()->SetAxesEnabled( false );
241
242 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
243 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
244
245 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
246 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
247 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
248 EESCHEMA_SETTINGS* cfg = eeconfig();
249
250 hierarchy_pane.Show( cfg->m_AuiPanels.show_schematic_hierarchy );
251 netNavigatorPane.Show( cfg->m_AuiPanels.show_net_nav_panel );
252 propertiesPane.Show( cfg->m_AuiPanels.show_properties );
253
256 {
257 // Show at end, after positioning
258 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
260 }
261
262 if( cfg->m_AuiPanels.net_nav_panel_float_size.GetWidth() > 0
263 && cfg->m_AuiPanels.net_nav_panel_float_size.GetHeight() > 0 )
264 {
265 netNavigatorPane.FloatingSize( cfg->m_AuiPanels.net_nav_panel_float_size );
266 }
267
269 SetAuiPaneSize( m_auimgr, propertiesPane, cfg->m_AuiPanels.properties_panel_width, -1 );
270
272 hierarchy_pane.Float();
273
275 && ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
276 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
277 {
278 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
279 searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
280 SetAuiPaneSize( m_auimgr, searchPane, -1, cfg->m_AuiPanels.search_panel_height );
281 }
282
283 else if( cfg->m_AuiPanels.search_panel_width > 0
284 && ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
285 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
286 {
287 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
288 searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
289 SetAuiPaneSize( m_auimgr, searchPane, cfg->m_AuiPanels.search_panel_width, -1 );
290 }
291
293 netNavigatorPane.Float();
294
296 {
297 // If the net navigator is not show, let the heirarchy navigator take all of the vertical
298 // space.
300 {
301 SetAuiPaneSize( m_auimgr, hierarchy_pane,
303 }
304 else
305 {
306 SetAuiPaneSize( m_auimgr, hierarchy_pane,
309
310 SetAuiPaneSize( m_auimgr, netNavigatorPane,
312 cfg->m_AuiPanels.net_nav_panel_docked_size.GetHeight() );
313 }
314
315 // wxAUI hack: force width by setting MinSize() and then Fixed()
316 // thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
317 hierarchy_pane.MinSize( cfg->m_AuiPanels.hierarchy_panel_docked_width, 60 );
318 hierarchy_pane.Fixed();
319 netNavigatorPane.MinSize( cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth(), 60 );
320 netNavigatorPane.Fixed();
321 m_auimgr.Update();
322
323 // now make it resizable again
324 hierarchy_pane.Resizable();
325 netNavigatorPane.Resizable();
326 m_auimgr.Update();
327
328 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
329 // back to minimum.
330 hierarchy_pane.MinSize( 120, 60 );
331 netNavigatorPane.MinSize( 120, 60 );
332 }
333 else
334 {
335 m_auimgr.Update();
336 }
337
338 LoadProjectSettings();
339
345
346 initScreenZoom();
347
348 m_hierarchy->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
349 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
350 this );
351 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
352 m_netNavigator->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onResizeNetNavigator, this );
353
354 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
355 // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
356 Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
357
358 setupUnits( eeconfig() );
359
360 // Net list generator
361 DefaultExecFlags();
362
363 updateTitle();
364 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
365
366 // Default shutdown reason until a file is loaded
367 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
368
369 // Init for dropping files
370 m_acceptedExts.emplace( KiCadSchematicFileExtension, &EE_ACTIONS::ddAppendFile );
371 DragAcceptFiles( true );
372
373 // Ensure the window is on top
374 Raise();
375
376 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
377 // top-left corner of the canvas
378 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
379 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
380
381 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
382 Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
383 Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog,
384 this );
385}
386
387
389{
390 m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
391
392 // Ensure m_canvasType is up to date, to save it in config
394
395 SetScreen( nullptr );
396
397 if( m_schematic )
399
400 delete m_schematic;
401 m_schematic = nullptr;
402
403 // Close the project if we are standalone, so it gets cleaned up properly
404 if( Kiface().IsSingle() )
405 {
406 try
407 {
408 GetSettingsManager()->UnloadProject( &Prj(), false );
409 }
410 catch( const nlohmann::detail::type_error& exc )
411 {
412 // This may be overkill and could be an assertion but we are more likely to
413 // find any settings manager errors this way.
414 wxLogError( wxT( "Settings exception '%s' occurred." ), exc.what() );
415 }
416 }
417
418 delete m_hierarchy;
419}
420
421
423{
424 aEvent.Skip();
425
426 // Called when resizing the Hierarchy Navigator panel
427 // Store the current pane size
428 // It allows to retrieve the last defined pane size when switching between
429 // docked and floating pane state
430 // Note: *DO NOT* call m_auimgr.Update() here: it crashes Kicad at least on Windows
431
432 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
433 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
434
435 if( cfg && m_hierarchy->IsShown() )
436 {
437 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
438 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
439
440 // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
441 // width is > 0 (i.e. if its size is already set and has meaning)
442 // if it is floating, its size is not initialized (only floating_size is initialized)
443 // initializing hierarchy_pane.best_size is useful when switching to float pane and
444 // after switching to the docked pane, to retrieve the last docked pane width
445 if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
446 {
447 cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
448 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
449 }
450 }
451}
452
453
455{
456 // Create the manager and dispatcher & route draw panel events to the dispatcher
459 GetCanvas()->GetViewControls(), config(), this );
460 m_actions = new EE_ACTIONS();
462
463 // Register tools
480
481 // Run the selection tool, it is supposed to be always active
483
485}
486
487
489{
491
493 SCH_EDITOR_CONDITIONS cond( this );
494
495 wxASSERT( mgr );
496
497 auto hasElements =
498 [ this ] ( const SELECTION& aSel )
499 {
500 return GetScreen() &&
501 ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
502 };
503
504 auto searchPaneCond =
505 [this] ( const SELECTION& )
506 {
507 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
508 };
509
510 auto propertiesCond =
511 [this] ( const SELECTION& )
512 {
513 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
514 };
515
516 auto hierarchyNavigatorCond =
517 [ this ] ( const SELECTION& aSel )
518 {
519 return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
520 };
521
522 auto netNavigatorCond =
523 [ this ] (const SELECTION& aSel )
524 {
525 return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
526 };
527
528 auto undoCond =
529 [ this ] (const SELECTION& aSel )
530 {
532 return true;
533
534 return GetUndoCommandCount() > 0;
535 };
536
537#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
538#define CHECK( x ) ACTION_CONDITIONS().Check( x )
539
541 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
543
544 mgr->SetConditions( EE_ACTIONS::showSearch, CHECK( searchPaneCond ) );
545 mgr->SetConditions( EE_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
546 mgr->SetConditions( EE_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
547 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
552 CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
553 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
554 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
555
557 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_FREE ) ) );
559 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_90 ) ) );
561 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_45 ) ) );
562
563 mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
564 mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
567 mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
568 mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
569 mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
570 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
571
572 mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( hasElements ) );
573 mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( hasElements ) );
574 mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( hasElements ) );
575 mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( hasElements ) );
576
581
582 if( SCRIPTING::IsWxAvailable() )
583 {
585 CHECK( cond.ScriptingConsoleVisible() ) );
586 }
587
588 auto showHiddenPinsCond =
589 [this]( const SELECTION& )
590 {
591 return GetShowAllPins();
592 };
593
594 auto showHiddenFieldsCond =
595 [this]( const SELECTION& )
596 {
598 return cfg && cfg->m_Appearance.show_hidden_fields;
599 };
600
601 auto showDirectiveLabelsCond =
602 [this]( const SELECTION& )
603 {
605 return cfg && cfg->m_Appearance.show_directive_labels;
606 };
607
608 auto showERCErrorsCond =
609 [this]( const SELECTION& )
610 {
612 return cfg && cfg->m_Appearance.show_erc_errors;
613 };
614
615 auto showERCWarningsCond =
616 [this]( const SELECTION& )
617 {
619 return cfg && cfg->m_Appearance.show_erc_warnings;
620 };
621
622 auto showERCExclusionsCond =
623 [this]( const SELECTION& )
624 {
626 return cfg && cfg->m_Appearance.show_erc_exclusions;
627 };
628
629 auto showOPVoltagesCond =
630 [this]( const SELECTION& )
631 {
633 return cfg && cfg->m_Appearance.show_op_voltages;
634 };
635
636 auto showOPCurrentsCond =
637 [this]( const SELECTION& )
638 {
640 return cfg && cfg->m_Appearance.show_op_currents;
641 };
642
643 auto showAnnotateAutomaticallyCond =
644 [this]( const SELECTION& )
645 {
647 return cfg && cfg->m_AnnotatePanel.automatic;
648 };
649
650 auto remapSymbolsCondition =
651 [&]( const SELECTION& aSel )
652 {
653 SCH_SCREENS schematic( Schematic().Root() );
654
655 // The remapping can only be performed on legacy projects.
656 return schematic.HasNoFullyDefinedLibIds();
657 };
658
659 auto belowRootSheetCondition =
660 [this]( const SELECTION& aSel )
661 {
663 return navigateTool && navigateTool->CanGoUp();
664 };
665
666 auto navSchematicHasPreviousSheet =
667 [this]( const SELECTION& aSel )
668 {
670 return navigateTool && navigateTool->CanGoPrevious();
671 };
672
673 auto navSchematicHasNextSheet =
674 [this]( const SELECTION& aSel )
675 {
677 return navigateTool && navigateTool->CanGoNext();
678 };
679
680 mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
681
682 /* Some of these are bound by default to arrow keys which will get a different action if we
683 * disable the buttons. So always leave them enabled so the action is consistent.
684 * https://gitlab.com/kicad/code/kicad/-/issues/14783
685 mgr->SetConditions( EE_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
686 mgr->SetConditions( EE_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
687 mgr->SetConditions( EE_ACTIONS::navigateBack, ENABLE( navHistoryHsBackward ) );
688 */
689
690 mgr->SetConditions( EE_ACTIONS::navigatePrevious, ENABLE( navSchematicHasPreviousSheet ) );
691 mgr->SetConditions( EE_ACTIONS::navigateNext, ENABLE( navSchematicHasNextSheet ) );
692 mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
693 mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
694 mgr->SetConditions( EE_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
695 mgr->SetConditions( EE_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
696 mgr->SetConditions( EE_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
697 mgr->SetConditions( EE_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
698 mgr->SetConditions( EE_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
699 mgr->SetConditions( EE_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
700 mgr->SetConditions( EE_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
701 mgr->SetConditions( EE_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
703
704#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
705
728
729#undef CURRENT_TOOL
730#undef CHECK
731#undef ENABLE
732}
733
734
736{
737 // we cannot store a pointer to an item in the display list here since
738 // that item may be deleted, such as part of a line concatenation or other.
739 // So simply always keep a copy of the object which is to be repeated.
740
741 if( aItem )
742 {
743 m_items_to_repeat.clear();
744
745 AddCopyForRepeatItem( aItem );
746 }
747}
748
749
751{
752 // we cannot store a pointer to an item in the display list here since
753 // that item may be deleted, such as part of a line concatenation or other.
754 // So simply always keep a copy of the object which is to be repeated.
755
756 if( aItem )
757 {
758 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate() ) );
759
760 // Clone() preserves the flags, we want 'em cleared.
761 repeatItem->ClearFlags();
762
763 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
764 }
765}
766
767
769{
770 return Schematic().GetSheets().GetItem( aId );
771}
772
773
775{
777}
778
779
781{
782 return GetCurrentSheet().LastScreen();
783}
784
785
787{
788 return *m_schematic;
789}
790
791
793{
794 return GetCurrentSheet().Last()->GetName();
795}
796
797
799{
801}
802
803
805{
808
809 SCH_SHEET* rootSheet = new SCH_SHEET( m_schematic );
810 m_schematic->SetRoot( rootSheet );
811
812 SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
813 const_cast<KIID&>( rootSheet->m_Uuid ) = rootScreen->GetUuid();
814 m_schematic->Root().SetScreen( rootScreen );
815 SetScreen( Schematic().RootScreen() );
816
817
818 m_schematic->RootScreen()->SetFileName( wxEmptyString );
819
820 // Don't leave root page number empty
821 SCH_SHEET_PATH rootSheetPath;
822
823 rootSheetPath.push_back( rootSheet );
824 m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
825 rootSheetPath.SetPageNumber( wxT( "1" ) );
826
827 if( GetScreen() == nullptr )
828 {
829 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
830 SetScreen( screen );
831 }
832}
833
834
836{
837 return m_schematic->CurrentSheet();
838}
839
840
842{
843 if( aSheet != GetCurrentSheet() )
844 {
845 FocusOnItem( nullptr );
846
847 Schematic().SetCurrentSheet( aSheet );
848 GetCanvas()->DisplaySheet( aSheet.LastScreen() );
849 }
850}
851
852
854{
856
857 for( SCH_ITEM* item : screen->Items() )
858 item->ClearCaches();
859
860 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
861 {
862 wxCHECK2( libSymbol.second, continue );
863 libSymbol.second->ClearCaches();
864 }
865
866 if( Schematic().Settings().m_IntersheetRefsShow )
868
869 FocusOnItem( nullptr );
870
871 GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
872
874 selectionTool->Reset( TOOL_BASE::REDRAW );
875
877}
878
879
880bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
881{
882 // Exit interactive editing
883 // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
884 // will cancel any drag currently in progress, but commit all changes from previous drags.
885 if( m_toolManager )
887
888 // Shutdown blocks must be determined and vetoed as early as possible
889 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
890 && Schematic().GetSheets().IsModified() )
891 {
892 return false;
893 }
894
895 if( Kiface().IsSingle() )
896 {
897 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
898
899 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
900 return false;
901
902 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
903
904 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
905 return false;
906
907 // SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
908 // sorry.
909 auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
910
911 if( chooser && !chooser->Close() ) // Can close symbol chooser?
912 return false;
913 }
914 else
915 {
916 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
917
918 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
919 {
920 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
921 return false;
922 }
923 }
924
925 if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
926 return false;
927
929 && !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
930 {
931 return false;
932 }
933
934 // We may have gotten multiple events; don't clean up twice
935 if( !Schematic().IsValid() )
936 return false;
937
938 SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
939
940 if( sheetlist.IsModified() )
941 {
942 wxFileName fileName = Schematic().RootScreen()->GetFileName();
943 wxString msg = _( "Save changes to '%s' before closing?" );
944
945 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
946 [&]() -> bool
947 {
948 return SaveProject();
949 } ) )
950 {
951 return false;
952 }
953 }
954
955 return true;
956}
957
958
960{
961 SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
962
963 // Shutdown all running tools
964 if( m_toolManager )
966
967 // Close modeless dialogs. They're trouble when they get destroyed after the frame.
968 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
969 Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
970 Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE,
972 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
973 this );
974 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection,
975 this );
976
977 // Close the find dialog and preserve its setting if it is displayed.
979 {
982
983 m_findReplaceDialog->Destroy();
984 m_findReplaceDialog = nullptr;
985 }
986
988 {
989 m_diffSymbolDialog->Destroy();
990 m_diffSymbolDialog = nullptr;
991 }
992
993 if( m_ercDialog )
994 {
995 m_ercDialog->Destroy();
996 m_ercDialog = nullptr;
997 }
998
1000 {
1001 m_symbolFieldsTableDialog->Destroy();
1002 m_symbolFieldsTableDialog = nullptr;
1003 }
1004
1005 // Shutdown all running tools
1006 if( m_toolManager )
1007 {
1009 // prevent the canvas from trying to dispatch events during close
1010 GetCanvas()->SetEventDispatcher( nullptr );
1011 delete m_toolManager;
1012 m_toolManager = nullptr;
1013 }
1014
1015 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
1016
1017 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
1018 {
1019 hierarchy_pane.Show( false );
1020 m_auimgr.Update();
1021 }
1022
1023 SCH_SCREENS screens( Schematic().Root() );
1024 wxFileName fn;
1025
1026 for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
1027 {
1028 fn = Prj().AbsolutePath( screen->GetFileName() );
1029
1030 // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
1031 fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
1032
1033 if( fn.IsFileWritable() )
1034 wxRemoveFile( fn.GetFullPath() );
1035 }
1036
1037 wxFileName tmpFn = Prj().GetProjectFullName();
1038 wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
1039
1040 if( autoSaveFileName.IsFileWritable() )
1041 wxRemoveFile( autoSaveFileName.GetFullPath() );
1042
1043 sheetlist.ClearModifyStatus();
1044
1045 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
1046
1047 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
1048 UpdateFileHistory( fileName );
1049
1050 // Make sure local settings are persisted
1052
1053 Schematic().RootScreen()->Clear();
1054
1055 // all sub sheets are deleted, only the main sheet is usable
1057
1058 // Clear view before destroying schematic as repaints depend on schematic being valid
1059 SetScreen( nullptr );
1060
1061 Schematic().Reset();
1062
1063 // Prevents any rogue events from continuing (i.e. search panel tries to redraw)
1064 Show( false );
1065
1066 Destroy();
1067}
1068
1069
1071{
1072 return Schematic().ErcSettings().GetSeverity( aErrorCode );
1073}
1074
1075
1077{
1079
1080 wxCHECK( GetScreen(), /* void */ );
1081
1083 m_autoSaveRequired = true;
1084
1085 GetCanvas()->Refresh();
1087
1088 if( !GetTitle().StartsWith( wxS( "*" ) ) )
1089 updateTitle();
1090}
1091
1092
1093void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
1094{
1095 if( Kiface().IsSingle() )
1096 {
1097 DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
1098 " in stand-alone mode. In order to create/update PCBs from"
1099 " schematics, launch the KiCad shell and create a project." ) );
1100 return;
1101 }
1102
1103 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1104
1105 if( !frame )
1106 {
1107 wxFileName fn = Prj().GetProjectFullName();
1108 fn.SetExt( PcbFileExtension );
1109
1110 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1111
1112 // If Kiway() cannot create the Pcbnew frame, it shows a error message, and
1113 // frame is null
1114 if( !frame )
1115 return;
1116
1117 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1118 }
1119
1120 if( !frame->IsVisible() )
1121 frame->Show( true );
1122
1123 // On Windows, Raise() does not bring the window on screen, when iconized
1124 if( frame->IsIconized() )
1125 frame->Iconize( false );
1126
1127 frame->Raise();
1128
1129 std::string payload;
1131}
1132
1133
1135{
1136 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
1138}
1139
1140
1142{
1144}
1145
1146
1148{
1149 wxString findString;
1150
1151 EE_SELECTION& selection = m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1152
1153 if( selection.Size() == 1 )
1154 {
1155 EDA_ITEM* front = selection.Front();
1156
1157 switch( front->Type() )
1158 {
1159 case SCH_SYMBOL_T:
1160 {
1161 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( front );
1162 findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() );
1163 break;
1164 }
1165
1166 case SCH_FIELD_T:
1167 findString = UnescapeString( static_cast<SCH_FIELD*>( front )->GetText() );
1168 break;
1169
1170 case SCH_LABEL_T:
1171 case SCH_GLOBAL_LABEL_T:
1172 case SCH_HIER_LABEL_T:
1173 case SCH_SHEET_PIN_T:
1174 findString = UnescapeString( static_cast<SCH_LABEL_BASE*>( front )->GetText() );
1175 break;
1176
1177 case SCH_TEXT_T:
1178 findString = UnescapeString( static_cast<SCH_TEXT*>( front )->GetText() );
1179
1180 if( findString.Contains( wxT( "\n" ) ) )
1181 findString = findString.Before( '\n' );
1182
1183 break;
1184
1185 default:
1186 break;
1187 }
1188 }
1189
1191 m_findReplaceDialog->Destroy();
1192
1194 static_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() ),
1195 wxDefaultPosition, wxDefaultSize,
1196 aReplace ? wxFR_REPLACEDIALOG : 0 );
1197
1200 m_findReplaceDialog->Show( true );
1201}
1202
1203
1204void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
1205{
1206 // Prepare the infobar, since we don't know its state
1209
1210 m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
1211}
1212
1213
1215{
1216 m_infoBar->Dismiss();
1217}
1218
1219
1221{
1224
1225 m_findReplaceDialog->Destroy();
1226 m_findReplaceDialog = nullptr;
1227
1229}
1230
1231
1232void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1233{
1234 wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1235
1236 if( fn.size() )
1237 OpenProjectFiles( std::vector<wxString>( 1, fn ) );
1238}
1239
1240
1241void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
1242{
1244}
1245
1246
1248{
1249 wxString pro_dir = m_mruPath;
1250
1251 wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
1252 KiCadSchematicFileWildcard(), wxFD_SAVE );
1253
1254 if( dlg.ShowModal() != wxID_CANCEL )
1255 {
1256 // Enforce the extension, wxFileDialog is inept.
1257 wxFileName create_me = EnsureFileExtension( dlg.GetPath(), KiCadSchematicFileExtension );
1258
1259 if( create_me.FileExists() )
1260 {
1261 wxString msg;
1262 msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
1263 DisplayError( this, msg );
1264 return ;
1265 }
1266
1267 // OpenProjectFiles() requires absolute
1268 wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
1269
1270 OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1271 m_mruPath = create_me.GetPath();
1272 }
1273}
1274
1275
1277{
1278 wxString pro_dir = m_mruPath;
1279 wxString wildcards = AllSchematicFilesWildcard()
1280 + wxS( "|" ) + KiCadSchematicFileWildcard()
1281 + wxS( "|" ) + LegacySchematicFileWildcard();
1282
1283 wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
1284 wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1285
1286 if( dlg.ShowModal() != wxID_CANCEL )
1287 {
1288 OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1290 }
1291}
1292
1293
1294void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
1295{
1296 wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
1297
1298 if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
1299 {
1300 kicad_board.SetExt( PcbFileExtension );
1301 wxFileName legacy_board( kicad_board );
1302 legacy_board.SetExt( LegacyPcbFileExtension );
1303 wxFileName& boardfn = legacy_board;
1304
1305 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1306 boardfn = kicad_board;
1307
1308 if( Kiface().IsSingle() )
1309 {
1310 ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
1311 }
1312 else
1313 {
1314 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1315
1316 if( !frame )
1317 {
1318 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1319
1320 // frame can be null if Cvpcb cannot be run. No need to show a warning
1321 // Kiway() generates the error messages
1322 if( !frame )
1323 return;
1324
1325 frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1326 }
1327
1328 if( !frame->IsVisible() )
1329 frame->Show( true );
1330
1331 // On Windows, Raise() does not bring the window on screen, when iconized
1332 if( frame->IsIconized() )
1333 frame->Iconize( false );
1334
1335 frame->Raise();
1336 }
1337 }
1338 else
1339 {
1340 // If we are running inside a project, it should be impossible for this case to happen
1341 wxASSERT( Kiface().IsSingle() );
1343 }
1344}
1345
1346
1347void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1348{
1349 wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1350 fn.SetExt( NetlistFileExtension );
1351
1352 if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1353 return;
1354
1355 try
1356 {
1357 KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1358
1359 if( !player )
1360 {
1361 player = Kiway().Player( FRAME_CVPCB, true );
1362
1363 // player can be null if Cvpcb cannot be run. No need to show a warning
1364 // Kiway() generates the error messages
1365 if( !player )
1366 return;
1367
1368 player->Show( true );
1369 }
1370
1372
1373 player->Raise();
1374 }
1375 catch( const IO_ERROR& )
1376 {
1377 DisplayError( this, _( "Could not open CvPcb" ) );
1378 }
1379}
1380
1381
1382void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1383{
1384 if( event.GetId() == wxID_EXIT )
1385 Kiway().OnKiCadExit();
1386
1387 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1388 Close( false );
1389}
1390
1391
1393{
1394 wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1395
1396 const wxBrush& brush =
1397 wxBrush( GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ).ToColour() );
1398 aSettings->GetPrintDC()->SetBackground( brush );
1399 aSettings->GetPrintDC()->Clear();
1400
1401 aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY );
1402 GetScreen()->Print( aSettings );
1403 PrintDrawingSheet( aSettings, GetScreen(), Schematic().GetProperties(), schIUScale.IU_PER_MILS,
1404 fileName );
1405}
1406
1407
1409{
1411 SIM_LIB_MGR simLibMgr( &Prj() );
1412 NULL_REPORTER devnull;
1413
1414 // Patch for bug early in V7.99 dev
1415 if( settings.m_OPO_VRange.EndsWith( 'A' ) )
1416 settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
1417
1418 // Update items which may have ${OP} text variables
1419 //
1421 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1422 {
1423 int flags = 0;
1424
1425 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1426 {
1427 item->RunOnChildren(
1428 [&flags]( SCH_ITEM* aChild )
1429 {
1430 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild );
1431
1432 if( text && text->HasTextVars() )
1433 {
1434 text->ClearRenderCache();
1435 text->ClearBoundingBoxCache();
1436 flags |= KIGFX::GEOMETRY | KIGFX::REPAINT;
1437 }
1438 } );
1439
1440 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
1441
1442 if( text && text->HasTextVars() )
1443 {
1444 text->ClearRenderCache();
1445 text->ClearBoundingBoxCache();
1447 }
1448 }
1449
1450 return flags;
1451 } );
1452
1453 // Update OP overlay items
1454 //
1455 for( SCH_ITEM* item : GetScreen()->Items() )
1456 {
1457 if( item->Type() == SCH_LINE_T )
1458 {
1459 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1460
1461 if( !line->GetOperatingPoint().IsEmpty() )
1462 GetCanvas()->GetView()->Update( line );
1463
1464 line->SetOperatingPoint( wxEmptyString );
1465 // update value from netlist, below
1466 }
1467 else if( item->Type() == SCH_SYMBOL_T )
1468 {
1469 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1470 wxString ref = symbol->GetRef( &GetCurrentSheet() );
1471 std::vector<SCH_PIN*> pins = symbol->GetPins( &GetCurrentSheet() );
1472
1473 // Power symbols and other symbols which have the reference starting with "#" are
1474 // not included in simulation
1475 if( ref.StartsWith( '#' ) || symbol->GetExcludedFromSim() )
1476 continue;
1477
1478 for( SCH_PIN* pin : pins )
1479 {
1480 if( !pin->GetOperatingPoint().IsEmpty() )
1481 GetCanvas()->GetView()->Update( pin );
1482
1483 pin->SetOperatingPoint( wxEmptyString );
1484 }
1485
1486 if( pins.size() == 2 )
1487 {
1488 wxString op = m_schematic->GetOperatingPoint( ref, settings.m_OPO_IPrecision,
1489 settings.m_OPO_IRange );
1490
1491 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1492 {
1493 pins[0]->SetOperatingPoint( op );
1494 GetCanvas()->GetView()->Update( symbol );
1495 }
1496 }
1497 else
1498 {
1499 SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol, devnull ).model;
1500
1501 SPICE_ITEM spiceItem;
1502 spiceItem.refName = ref;
1503 ref = model.SpiceGenerator().ItemName( spiceItem );
1504
1505 for( const auto& modelPin : model.GetPins() )
1506 {
1507 SCH_PIN* symbolPin = symbol->GetPin( modelPin.get().symbolPinNumber );
1508 wxString signalName = ref + wxS( ":" ) + modelPin.get().name;
1509 wxString op = m_schematic->GetOperatingPoint( signalName,
1510 settings.m_OPO_IPrecision,
1511 settings.m_OPO_IRange );
1512
1513 if( symbolPin && !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1514 {
1515 symbolPin->SetOperatingPoint( op );
1516 GetCanvas()->GetView()->Update( symbol );
1517 }
1518 }
1519 }
1520 }
1521 }
1522
1523 for( const auto& [ key, subgraphList ] : m_schematic->m_connectionGraph->GetNetMap() )
1524 {
1525 wxString op = m_schematic->GetOperatingPoint( key.Name, settings.m_OPO_VPrecision,
1526 settings.m_OPO_VRange );
1527
1528 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1529 {
1530 for( CONNECTION_SUBGRAPH* subgraph : subgraphList )
1531 {
1532 SCH_LINE* longestWire = nullptr;
1533 double length = 0.0;
1534
1535 for( SCH_ITEM* item : subgraph->GetItems() )
1536 {
1537 if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T } ) )
1538 {
1539 SCH_LINE* wire = static_cast<SCH_LINE*>( item );
1540
1541 if( wire->GetLength() > length )
1542 {
1543 longestWire = wire;
1544 length = wire->GetLength();
1545 }
1546 }
1547 }
1548
1549 if( longestWire )
1550 {
1551 longestWire->SetOperatingPoint( op );
1552 GetCanvas()->GetView()->Update( longestWire );
1553 }
1554 }
1555 }
1556 }
1557}
1558
1559
1561{
1562 if( aItem->IsType( { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) )
1563 {
1564 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
1565
1566 if( label->AutoRotateOnPlacement() )
1567 {
1568 SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
1569 label->GetSpinStyle(),
1570 &GetCurrentSheet() );
1571
1572 if( spin != label->GetSpinStyle() )
1573 {
1574 label->SetSpinStyle( spin );
1575
1576 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1577 {
1578 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1579
1580 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1581 otherLabel->AutoplaceFields( aScreen, false );
1582 }
1583 }
1584 }
1585 }
1586}
1587
1588
1590{
1591 SCH_SCREEN* screen = GetScreen();
1592
1593 wxCHECK( screen, /* void */ );
1594
1595 wxString title;
1596
1597 if( !screen->GetFileName().IsEmpty() )
1598 {
1599 wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1600 bool readOnly = false;
1601 bool unsaved = false;
1602
1603 if( fn.IsOk() && screen->FileExists() )
1604 readOnly = screen->IsReadOnly();
1605 else
1606 unsaved = true;
1607
1608 if( IsContentModified() )
1609 title = wxT( "*" );
1610
1611 title += fn.GetName();
1612
1613 wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
1614
1615 if( sheetPath != title )
1616 title += wxString::Format( wxT( " [%s]" ), sheetPath );
1617
1618 if( readOnly )
1619 title += wxS( " " ) + _( "[Read Only]" );
1620
1621 if( unsaved )
1622 title += wxS( " " ) + _( "[Unsaved]" );
1623 }
1624 else
1625 {
1626 title = _( "[no schematic loaded]" );
1627 }
1628
1629 title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1630
1631 SetTitle( title );
1632}
1633
1634
1636{
1638 GetScreen()->m_zoomInitialized = true;
1639}
1640
1641
1643{
1644 wxString highlightedConn = GetHighlightedConnection();
1645 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1647 SCH_COMMIT localCommit( m_toolManager );
1648
1649 if( !aCommit )
1650 aCommit = &localCommit;
1651
1652#ifdef PROFILE
1653 PROF_TIMER timer;
1654#endif
1655
1656 // Ensure schematic graph is accurate
1657 if( aCleanupFlags == LOCAL_CLEANUP )
1658 {
1659 SchematicCleanUp( aCommit, GetScreen() );
1660 }
1661 else if( aCleanupFlags == GLOBAL_CLEANUP )
1662 {
1663 for( const SCH_SHEET_PATH& sheet : list )
1664 SchematicCleanUp( aCommit, sheet.LastScreen() );
1665 }
1666
1667#ifdef PROFILE
1668 timer.Stop();
1669 wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1670#endif
1671
1672 if( settings.m_IntersheetRefsShow )
1674
1675 std::function<void( SCH_ITEM* )> changeHandler =
1676 [&]( SCH_ITEM* aChangedItem ) -> void
1677 {
1678 GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1679
1680 SCH_CONNECTION* connection = aChangedItem->Connection();
1681
1682 if( connection && ( connection->Name() == highlightedConn ) )
1684 };
1685
1686 if( !ADVANCED_CFG::GetCfg().m_IncrementalConnectivity || aCleanupFlags == GLOBAL_CLEANUP
1687 || m_undoList.m_CommandsList.empty() )
1688 {
1689 Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
1690 }
1691 else
1692 {
1693 PICKED_ITEMS_LIST* changed_list = m_undoList.m_CommandsList.back();
1694 std::set<SCH_ITEM*> changed_items;
1695 std::vector<VECTOR2I> pts;
1696 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> item_paths;
1697
1698 for( unsigned ii = 0; ii < changed_list->GetCount(); ++ii )
1699 {
1700 EDA_ITEM* item = changed_list->GetPickedItem( ii );
1701
1702 if( !item || !IsEeschemaType( item->Type() ) )
1703 continue;
1704
1705 SCH_SCREEN* screen = static_cast<SCH_SCREEN*>( changed_list->GetScreenForItem( ii ) );
1706 SCH_ITEM* sch_item = static_cast<SCH_ITEM*>( item );
1707 SCH_SHEET_PATHS& paths = screen->GetClientSheetPaths();
1708
1709 std::vector<VECTOR2I> tmp_pts = sch_item->GetConnectionPoints();
1710 pts.insert( pts.end(), tmp_pts.begin(), tmp_pts.end() );
1711 changed_items.insert( sch_item );
1712
1713 for( SCH_SHEET_PATH& path : paths )
1714 item_paths.insert( std::make_pair( path, sch_item ) );
1715 }
1716
1717 for( VECTOR2I& pt: pts )
1718 {
1719 for( SCH_ITEM* item : GetScreen()->Items().Overlapping( pt ) )
1720 {
1721 if( item->Type() == SCH_LINE_T )
1722 {
1723 if( item->HitTest( pt ) )
1724 changed_items.insert( item );
1725 }
1726 else if( item->Type() == SCH_SYMBOL_T )
1727 {
1728 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1729 std::vector<SCH_PIN*> pins = symbol->GetPins();
1730
1731 changed_items.insert( pins.begin(), pins.end() );
1732 }
1733 else if( item->IsConnectable() )
1734 {
1735 if( item->IsConnected( pt ) )
1736 changed_items.insert( item );
1737 }
1738 }
1739 }
1740
1741 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> all_items =
1742 Schematic().ConnectionGraph()->ExtractAffectedItems( changed_items );
1743
1744 all_items.insert( item_paths.begin(), item_paths.end() );
1745
1746 CONNECTION_GRAPH new_graph( &Schematic() );
1747
1748 new_graph.SetLastCodes( Schematic().ConnectionGraph() );
1749
1750 for( auto&[ path, item ] : all_items )
1751 {
1752 switch( item->Type() )
1753 {
1754 case SCH_FIELD_T:
1755 case SCH_PIN_T:
1756 static_cast<SCH_ITEM*>( item->GetParent() )->SetConnectivityDirty();
1757 break;
1758
1759 default:
1760 item->SetConnectivityDirty();
1761 }
1762 }
1763
1764 new_graph.Recalculate( list, false, &changeHandler );
1765 Schematic().ConnectionGraph()->Merge( new_graph );
1766 }
1767
1769 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1770 {
1771 int flags = 0;
1772 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
1773 SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
1774
1775 if( connection && connection->HasDriverChanged() )
1776 {
1777 connection->ClearDriverChanged();
1778 flags |= KIGFX::REPAINT;
1779 }
1780
1781 if( item )
1782 {
1783 item->RunOnChildren(
1784 [&flags]( SCH_ITEM* aChild )
1785 {
1786 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild );
1787
1788 if( text && text->HasTextVars() )
1789 {
1790 text->ClearRenderCache();
1791 text->ClearBoundingBoxCache();
1793 }
1794 } );
1795
1796 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
1797
1798 if( text && text->HasTextVars() )
1799 {
1800 text->ClearRenderCache();
1801 text->ClearBoundingBoxCache();
1803 }
1804
1805 if( flags & KIGFX::GEOMETRY )
1806 GetScreen()->Update( item, false ); // Refresh RTree
1807 }
1808
1809 return flags;
1810 } );
1811
1812 if( !highlightedConn.IsEmpty() )
1813 {
1815 || !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
1817
1819 }
1820
1821 if( !localCommit.Empty() )
1822 localCommit.Push( _( "Schematic Cleanup" ) );
1823}
1824
1825
1827{
1829 {
1830 for( SCH_FIELD& field : label->GetFields() )
1831 field.ClearBoundingBoxCache();
1832
1833 label->ClearBoundingBoxCache();
1834 GetCanvas()->GetView()->Update( label );
1835 } );
1836}
1837
1838
1840{
1842
1844}
1845
1846
1847void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1848{
1849 SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1850
1851 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1852
1854
1856
1857 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
1860
1861 KIGFX::VIEW* view = GetCanvas()->GetView();
1867
1869
1870 settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
1871
1872 if( !cfg->m_Drawing.field_names.IsEmpty() )
1874
1876
1877 for( SCH_ITEM* item : screen->Items() )
1878 item->ClearCaches();
1879
1880 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
1881 libSymbol->ClearCaches();
1882
1884
1886 Layout();
1887 SendSizeEvent();
1888}
1889
1890
1892{
1893 // Store the current zoom level into the current screen before calling
1894 // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
1896 // Rebuild the sheet view (draw area and any other items):
1898}
1899
1900
1902{
1903 // call my base class
1905
1906 // tooltips in toolbars
1908
1909 m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
1910 m_auimgr.Update();
1912
1913 // status bar
1915
1916 updateTitle();
1917
1918 // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1919 // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1920 // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1921 // toolbar to update correctly.
1922#if defined( __WXMSW__ )
1923 PostSizeEvent();
1924#endif
1925}
1926
1927
1929{
1930 if( !GetHighlightedConnection().IsEmpty() )
1931 {
1932 SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
1934 }
1935 else
1936 {
1937 SetStatusText( wxT( "" ) );
1938 }
1939}
1940
1941
1943{
1944 if( m_toolManager )
1946
1947 SCH_BASE_FRAME::SetScreen( aScreen );
1948 GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1949
1950 if( m_toolManager )
1952}
1953
1954
1955const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1956{
1957 BOX2I bBoxDoc;
1958
1959 if( aIncludeAllVisible )
1960 {
1961 // Get the whole page size and return that
1964 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
1965 }
1966 else
1967 {
1968 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
1970 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
1971
1972 // Calc the bounding box of all items on screen except the page border
1973 for( EDA_ITEM* item : GetScreen()->Items() )
1974 {
1975 if( item != dsAsItem ) // Ignore the drawing-sheet itself
1976 bBoxDoc.Merge( item->GetBoundingBox() );
1977 }
1978 }
1979
1980 return bBoxDoc;
1981}
1982
1983
1985{
1986 return Schematic().GetSheets().IsModified();
1987}
1988
1989
1991{
1992 EESCHEMA_SETTINGS* cfg = eeconfig();
1993 return cfg && cfg->m_Appearance.show_hidden_pins;
1994}
1995
1996
1998{
1999 static KIID lastBrightenedItemID( niluuid );
2000
2001 SCH_SHEET_LIST sheetList = Schematic().GetSheets();
2003 SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
2004
2005 if( lastItem && lastItem != aItem )
2006 {
2007 lastItem->ClearBrightened();
2008
2009 UpdateItem( lastItem );
2010 lastBrightenedItemID = niluuid;
2011 }
2012
2013 if( aItem )
2014 {
2015 if( !aItem->IsBrightened() )
2016 {
2017 aItem->SetBrightened();
2018
2019 UpdateItem( aItem );
2020 lastBrightenedItemID = aItem->m_Uuid;
2021 }
2022
2024 }
2025}
2026
2027
2029{
2030 return Schematic().GetFileName();
2031}
2032
2033
2035{
2036 return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
2037}
2038
2039
2040void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2041{
2042 if( IsShown() )
2043 {
2044 // We only need this until the frame is done resizing and the final client size is
2045 // established.
2046 Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
2048 }
2049
2050 // Skip() is called in the base class.
2051 EDA_DRAW_FRAME::OnSize( aEvent );
2052}
2053
2054
2056 const KIID& aSchematicSymbolUUID )
2057{
2058 SCH_SHEET_PATH principalPath;
2059 SCH_ITEM* item = Schematic().GetSheets().GetItem( aSchematicSymbolUUID, &principalPath );
2060 SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
2061 SCH_COMMIT commit( m_toolManager );
2062
2063 if( !principalSymbol )
2064 return;
2065
2066 wxString principalRef;
2067
2068 if( principalSymbol->IsAnnotated( &principalPath ) )
2069 principalRef = principalSymbol->GetRef( &principalPath, false );
2070
2071 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
2072
2073 for( const SCH_SHEET_PATH& path : Schematic().GetSheets() )
2074 {
2075 for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2076 {
2077 SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
2078
2079 if( candidateSymbol == principalSymbol
2080 || ( candidateSymbol->IsAnnotated( &path )
2081 && candidateSymbol->GetRef( &path, false ) == principalRef ) )
2082 {
2083 allUnits.emplace_back( candidateSymbol, path );
2084 }
2085 }
2086 }
2087
2088 for( auto& [ unit, path ] : allUnits )
2089 {
2090 // This needs to be done before the LIB_SYMBOL is changed to prevent stale
2091 // library symbols in the schematic file.
2092 path.LastScreen()->Remove( unit );
2093
2094 if( !unit->IsNew() )
2095 commit.Modify( unit, path.LastScreen() );
2096
2097 unit->SetLibSymbol( aSymbol.Flatten().release() );
2098 unit->UpdateFields( &GetCurrentSheet(),
2099 true, /* update style */
2100 true, /* update ref */
2101 true, /* update other fields */
2102 false, /* reset ref */
2103 false /* reset other fields */ );
2104
2105 path.LastScreen()->Append( unit );
2106 GetCanvas()->GetView()->Update( unit );
2107 }
2108
2109 if( !commit.Empty() )
2110 commit.Push( _( "Save Symbol to Schematic" ) );
2111}
2112
2113
2114void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2115{
2116 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2117
2118 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
2119 sch_item->ClearCaches();
2120}
2121
2122
2124{
2125 wxCHECK( m_toolManager, /* void */ );
2126
2130
2131 wxCHECK( screen, /* void */ );
2132
2134
2135 SCH_BASE_FRAME::SetScreen( screen );
2136
2138
2139 // update the References
2143
2145
2146 wxCHECK( selectionTool, /* void */ );
2147
2148 auto visit =
2149 [&]( EDA_ITEM* item )
2150 {
2152 && !m_findReplaceData->findString.IsEmpty()
2153 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
2154 {
2155 item->SetForceVisible( true );
2156 selectionTool->BrightenItem( item );
2157 }
2158 else if( item->IsBrightened() )
2159 {
2160 item->SetForceVisible( false );
2161 selectionTool->UnbrightenItem( item );
2162 }
2163 };
2164
2165 for( SCH_ITEM* item : screen->Items() )
2166 {
2167 visit( item );
2168
2169 item->RunOnChildren(
2170 [&]( SCH_ITEM* aChild )
2171 {
2172 visit( aChild );
2173 } );
2174 }
2175
2176 if( !screen->m_zoomInitialized )
2177 {
2179 }
2180 else
2181 {
2182 // Set zoom to last used in this screen
2183 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
2184 GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
2185 }
2186
2187 updateTitle();
2188
2189 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
2190
2191 // Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
2193
2195
2196 wxCHECK( editTool, /* void */ );
2197
2199 editTool->UpdateNetHighlighting( dummy );
2200
2202
2204}
2205
2206
2208{
2209 if( !m_diffSymbolDialog )
2211 _( "Diff Symbol with Library" ) );
2212
2213 return m_diffSymbolDialog;
2214}
2215
2216
2217void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
2218{
2219 if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
2220 {
2221 m_diffSymbolDialog->Destroy();
2222 m_diffSymbolDialog = nullptr;
2223 }
2224}
2225
2226
2228{
2229 if( !m_ercDialog )
2230 m_ercDialog = new DIALOG_ERC( this );
2231
2232 return m_ercDialog;
2233}
2234
2235
2236void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
2237{
2238 if( m_ercDialog )
2239 {
2240 m_ercDialog->Destroy();
2241 m_ercDialog = nullptr;
2242 }
2243}
2244
2245
2247{
2250
2252}
2253
2254
2256{
2258 {
2259 m_symbolFieldsTableDialog->Destroy();
2260 m_symbolFieldsTableDialog = nullptr;
2261 }
2262}
2263
2264
2265void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
2266{
2267 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2268 aListener );
2269
2270 // Don't add duplicate listeners.
2271 if( it == m_schematicChangeListeners.end() )
2272 m_schematicChangeListeners.push_back( aListener );
2273}
2274
2275
2277{
2278 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2279 aListener );
2280
2281 // Don't add duplicate listeners.
2282 if( it != m_schematicChangeListeners.end() )
2283 m_schematicChangeListeners.erase( it );
2284}
2285
2286
2288{
2289 m_netNavigator = new wxTreeCtrl( this, wxID_ANY, wxPoint( 0, 0 ),
2290 FromDIP( wxSize( 160, 250 ) ),
2291 wxTR_DEFAULT_STYLE | wxNO_BORDER );
2292
2293 return m_netNavigator;
2294}
2295
2296
2297void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection,
2298 const NET_NAVIGATOR_ITEM_DATA* aSelection )
2299{
2300 bool refreshNetNavigator = aConnection != m_highlightedConn;
2301
2302 m_highlightedConn = aConnection;
2303
2304 if( refreshNetNavigator )
2305 RefreshNetNavigator( aSelection );
2306}
2307
2308
2310{
2311 if( m_netNavigator && !m_highlightedConn.IsEmpty() )
2312 {
2313 NET_NAVIGATOR_ITEM_DATA itemData;
2314 wxTreeItemId selection = m_netNavigator->GetSelection();
2315 bool refreshSelection = selection.IsOk() && ( selection != m_netNavigator->GetRootItem() );
2316
2317 if( refreshSelection )
2318 {
2320 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
2321
2322 wxCHECK( tmp, /* void */ );
2323 itemData = *tmp;
2324 }
2325
2326 m_netNavigator->DeleteAllItems();
2327 RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
2328 }
2329
2331}
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:106
@ icon_eeschema
@ icon_eeschema_16
@ icon_eeschema_32
BOX2< VECTOR2I > BOX2I
Definition: box2.h:853
static TOOL_ACTION toggleGrid
Definition: actions.h:148
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
static TOOL_ACTION millimetersUnits
Definition: actions.h:156
static TOOL_ACTION unselectAll
Definition: actions.h:72
static TOOL_ACTION copy
Definition: actions.h:68
static TOOL_ACTION updateFind
Definition: actions.h:86
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
static TOOL_ACTION milsUnits
Definition: actions.h:155
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:111
static TOOL_ACTION showSearch
Definition: actions.h:78
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION duplicate
Definition: actions.h:73
static TOOL_ACTION inchesUnits
Definition: actions.h:154
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:108
static TOOL_ACTION doDelete
Definition: actions.h:74
static TOOL_ACTION selectionTool
Definition: actions.h:163
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:100
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:75
static TOOL_ACTION zoomTool
Definition: actions.h:103
static TOOL_ACTION showProperties
Definition: actions.h:177
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:149
static TOOL_ACTION selectAll
Definition: actions.h:71
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:169
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:103
bool Empty() const
Returns status of an item.
Definition: commit.h:142
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
Definition: common_tools.h:38
Calculates the connectivity of a schematic and generates netlists.
const NET_MAP & GetNetMap() const
CONNECTION_SUBGRAPH * FindFirstSubgraphByName(const wxString &aNetName)
Retrieves 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)
Combines 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)
Updates 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
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:484
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:124
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:167
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
static TOOL_ACTION toggleAnnotateAuto
Definition: ee_actions.h:260
static TOOL_ACTION lineMode90
Definition: ee_actions.h:255
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:229
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:250
static TOOL_ACTION toggleERCWarnings
Definition: ee_actions.h:232
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:234
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:123
static TOOL_ACTION lineModeFree
Definition: ee_actions.h:254
static TOOL_ACTION drawBus
Definition: ee_actions.h:82
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:233
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:236
static TOOL_ACTION mirrorH
Definition: ee_actions.h:125
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:285
static TOOL_ACTION rotateCW
Definition: ee_actions.h:122
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:92
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:215
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:230
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:89
static TOOL_ACTION ddAppendFile
Definition: ee_actions.h:289
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:286
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:231
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:221
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:93
static TOOL_ACTION toggleOPVoltages
Definition: ee_actions.h:235
static TOOL_ACTION drawArc
Definition: ee_actions.h:97
static TOOL_ACTION lineMode45
Definition: ee_actions.h:256
static TOOL_ACTION drawSheet
Definition: ee_actions.h:91
static TOOL_ACTION navigateNext
Definition: ee_actions.h:220
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:219
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 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:76
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:82
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:268
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:1607
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:392
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:212
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:1510
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:66
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:113
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:615
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:152
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:143
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:137
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:143
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:328
Action handler for the Properties panel.
These settings were stored in SCH_BASE_FRAME previously.
TEMPLATES m_TemplateFieldNames
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:57
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:700
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
Definition: schematic.cpp:634
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:203
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:209
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:113
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:83
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:126
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:572
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:725
SCH_SHEET & Root() const
Definition: schematic.h:105
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:543
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:216
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:353
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 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:150
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:463
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:428
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:377
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:165
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:1316
SPIN_STYLE GetSpinStyle() const
Definition: sch_label.cpp:372
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_label.cpp:582
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:167
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:302
double GetLength() const
Definition: sch_line.cpp:237
const wxString & GetOperatingPoint() const
Definition: sch_line.h:301
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:673
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:277
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Return the number of times this screen is used.
Definition: sch_screen.h:178
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:597
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:117
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:315
bool m_zoomInitialized
Definition: sch_screen.h:622
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:507
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:161
Schematic symbol object.
Definition: sch_symbol.h:81
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:720
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:913
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:738
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:798
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
VECTOR2I GetPosition() const override
Definition: sch_text.h:126
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:745
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:165
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:167
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:166
@ 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:398
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()
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:40
@ 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:48
@ 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:118
const std::string LegacyPcbFileExtension
#define PcbFileExtension
const std::string NetlistFileExtension
const std::string KiCadSchematicFileExtension
wxString KiCadSchematicFileWildcard()
wxString LegacySchematicFileWildcard()
wxString AllSchematicFilesWildcard()
@ 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:571
KIID niluuid(0)
KIWAY Kiway
#define KICTL_CREATE
caller thinks requested project files may not exist.
Definition: kiway_player.h:77
@ LAYER_ERC_WARN
Definition: layer_ids.h:375
@ LAYER_ERC_EXCLUSION
Definition: layer_ids.h:377
@ LAYER_ERC_ERR
Definition: layer_ids.h:376
@ LAYER_OP_CURRENTS
Definition: layer_ids.h:394
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:382
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:360
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:393
@ 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
wxDEFINE_EVENT(EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent)
#define DIFF_SYMBOLS_DIALOG_NAME
#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:115
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:145
@ SCH_SYMBOL_T
Definition: typeinfo.h:155
@ SCH_FIELD_T
Definition: typeinfo.h:154
@ SCH_LABEL_T
Definition: typeinfo.h:150
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:152
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:156
@ SCH_TEXT_T
Definition: typeinfo.h:149
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:151
@ SCH_PIN_T
Definition: typeinfo.h:158
constexpr bool IsEeschemaType(const KICAD_T aType)
Definition: typeinfo.h:370
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.