KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_edit_frame.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <algorithm>
26#include <api/api_handler_sch.h>
27#include <api/api_server.h>
28#include <base_units.h>
29#include <bitmaps.h>
30#include <symbol_library.h>
31#include <confirm.h>
32#include <connection_graph.h>
33#include <dialogs/dialog_erc.h>
37#include <eeschema_id.h>
38#include <executable_names.h>
41#include <gestfich.h>
43#include <invoke_sch_dialog.h>
44#include <string_utils.h>
45#include <kiface_base.h>
46#include <kiplatform/app.h>
47#include <kiway.h>
48#include <symbol_edit_frame.h>
49#include <symbol_viewer_frame.h>
50#include <pgm_base.h>
51#include <core/profile.h>
54#include <python_scripting.h>
55#include <sch_edit_frame.h>
57#include <sch_painter.h>
58#include <sch_marker.h>
59#include <sch_sheet_pin.h>
60#include <sch_commit.h>
61#include <sch_rule_area.h>
63#include <advanced_config.h>
64#include <sim/simulator_frame.h>
65#include <tool/action_manager.h>
66#include <tool/action_toolbar.h>
67#include <tool/common_control.h>
68#include <tool/common_tools.h>
69#include <tool/embed_tool.h>
70#include <tool/picker_tool.h>
72#include <tool/selection.h>
74#include <tool/tool_manager.h>
75#include <tool/zoom_tool.h>
76#include <tools/ee_actions.h>
80#include <tools/sch_edit_tool.h>
85#include <tools/sch_move_tool.h>
88#include <unordered_set>
89#include <view/view_controls.h>
90#include <widgets/wx_infobar.h>
95#include <wx/cmdline.h>
96#include <wx/app.h>
97#include <wx/filedlg.h>
98#include <wx/socket.h>
99#include <wx/debug.h>
101#include <widgets/wx_aui_utils.h>
103
104#ifdef KICAD_IPC_API
106#endif
107
108
109#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
110
111
112BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
115
116 EVT_SIZE( SCH_EDIT_FRAME::OnSize )
117
120
123
124 EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
125 EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
126
127 // Drop files event
128 EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
129END_EVENT_TABLE()
130
131
132wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
133wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
134
135
136SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
137 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
139 m_ercDialog( nullptr ),
140 m_diffSymbolDialog( nullptr ),
141 m_symbolFieldsTableDialog( nullptr ),
142 m_netNavigator( nullptr ),
143 m_highlightedConnChanged( false )
144{
145 m_maximizeByDefault = true;
146 m_schematic = new SCHEMATIC( nullptr );
147
148 m_showBorderAndTitleBlock = true; // true to show sheet references
149 m_supportsAutoSave = true;
150 m_syncingPcbToSchSelection = false;
151 m_aboutTitle = _HKI( "KiCad Schematic Editor" );
152 m_show_search = false;
153
154 m_findReplaceDialog = nullptr;
155
156 m_findReplaceData = std::make_unique<SCH_SEARCH_DATA>();
157
158 // Give an icon
159 wxIcon icon;
160 wxIconBundle icon_bundle;
161
162 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 48 ) );
163 icon_bundle.AddIcon( icon );
164 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 128 ) );
165 icon_bundle.AddIcon( icon );
166 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 256 ) );
167 icon_bundle.AddIcon( icon );
168 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
169 icon_bundle.AddIcon( icon );
170 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
171 icon_bundle.AddIcon( icon );
172
173 SetIcons( icon_bundle );
174
175 LoadSettings( eeconfig() );
176
177 // NB: also links the schematic to the loaded project
178 CreateScreens();
179
180 SCH_SHEET_PATH root;
181 root.push_back( &Schematic().Root() );
182 SetCurrentSheet( root );
183
184 setupTools();
185 setupUIConditions();
186 ReCreateMenuBar();
187 ReCreateHToolbar();
188 ReCreateVToolbar();
189 ReCreateOptToolbar();
190
191#ifdef KICAD_IPC_API
193 &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
194#endif
195
196 m_hierarchy = new HIERARCHY_PANE( this );
197
198 // Initialize common print setup dialog settings.
199 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
200 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
201 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
202 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
203
204 m_searchPane = new SCH_SEARCH_PANE( this );
205 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
206
207 m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
208
209 m_selectionFilterPanel = new PANEL_SCH_SELECTION_FILTER( this );
210
211 m_auimgr.SetManagedWindow( this );
212
213 CreateInfoBar();
214
215 // Rows; layers 4 - 6
216 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxS( "MainToolbar" ) )
217 .Top().Layer( 6 ) );
218
219 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
220 .Bottom().Layer( 6 ) );
221
222 // Columns; layers 1 - 3
223 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
224 .Caption( _( "Schematic Hierarchy" ) )
225 .Left().Layer( 3 ).Position( 1 )
226 .TopDockable( false )
227 .BottomDockable( false )
228 .CloseButton( false )
229 .MinSize( FromDIP( wxSize( 120, 60 ) ) )
230 .BestSize( FromDIP( wxSize( 200, 200 ) ) )
231 .FloatingSize( FromDIP( wxSize( 200, 200 ) ) )
232 .FloatingPosition( FromDIP( wxPoint( 50, 50 ) ) )
233 .Show( false ) );
234
235 m_auimgr.AddPane( m_propertiesPanel, defaultPropertiesPaneInfo( this ) );
236 m_auimgr.AddPane( m_selectionFilterPanel, defaultSchSelectionFilterPaneInfo( this ) );
237
238 m_auimgr.AddPane( createHighlightedNetNavigator(), defaultNetNavigatorPaneInfo() );
239
240 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( wxS( "OptToolbar" ) )
241 .Left().Layer( 2 ) );
242
243 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( wxS( "ToolsToolbar" ) )
244 .Right().Layer( 2 ) );
245
246 // Center
247 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
248 .Center() );
249
250 m_auimgr.AddPane( m_searchPane, EDA_PANE()
251 .Name( SearchPaneName() )
252 .Bottom()
253 .Caption( _( "Search" ) )
254 .PaneBorder( false )
255 .MinSize( FromDIP( wxSize( 180, 60 ) ) )
256 .BestSize( FromDIP( wxSize( 180, 100 ) ) )
257 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
258 .CloseButton( false )
259 .DestroyOnClose( false )
260 .Show( m_show_search ) );
261
262 FinishAUIInitialization();
263
264 resolveCanvasType();
265 SwitchCanvas( m_canvasType );
266
267 GetCanvas()->GetGAL()->SetAxesEnabled( false );
268
269 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
270 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
271
272 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
273 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
274 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
275 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
276 EESCHEMA_SETTINGS* cfg = eeconfig();
277
278 hierarchy_pane.Show( cfg->m_AuiPanels.show_schematic_hierarchy );
279 netNavigatorPane.Show( cfg->m_AuiPanels.show_net_nav_panel );
280 propertiesPane.Show( cfg->m_AuiPanels.show_properties );
281 updateSelectionFilterVisbility();
282
283 // The selection filter doesn't need to grow in the vertical direction when docked
284 selectionFilterPane.dock_proportion = 0;
285
288 {
289 // Show at end, after positioning
290 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
292 }
293
294 if( cfg->m_AuiPanels.net_nav_panel_float_size.GetWidth() > 0
295 && cfg->m_AuiPanels.net_nav_panel_float_size.GetHeight() > 0 )
296 {
297 netNavigatorPane.FloatingSize( cfg->m_AuiPanels.net_nav_panel_float_size );
298 netNavigatorPane.FloatingPosition( cfg->m_AuiPanels.net_nav_panel_float_pos );
299 }
300
302 SetAuiPaneSize( m_auimgr, propertiesPane, cfg->m_AuiPanels.properties_panel_width, -1 );
303
305 hierarchy_pane.Float();
306
308 && ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
309 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
310 {
311 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
312 searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
313 SetAuiPaneSize( m_auimgr, searchPane, -1, cfg->m_AuiPanels.search_panel_height );
314 }
315
316 else if( cfg->m_AuiPanels.search_panel_width > 0
317 && ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
318 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
319 {
320 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
321 searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
322 SetAuiPaneSize( m_auimgr, searchPane, cfg->m_AuiPanels.search_panel_width, -1 );
323 }
324
326 netNavigatorPane.Float();
327
329 {
330 // If the net navigator is not show, let the hierarchy navigator take all of the vertical
331 // space.
333 {
334 SetAuiPaneSize( m_auimgr, hierarchy_pane,
336 }
337 else
338 {
339 SetAuiPaneSize( m_auimgr, hierarchy_pane,
342
343 SetAuiPaneSize( m_auimgr, netNavigatorPane,
345 cfg->m_AuiPanels.net_nav_panel_docked_size.GetHeight() );
346 }
347
348 // wxAUI hack: force width by setting MinSize() and then Fixed()
349 // thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
350 hierarchy_pane.MinSize( cfg->m_AuiPanels.hierarchy_panel_docked_width, 60 );
351 hierarchy_pane.Fixed();
352 netNavigatorPane.MinSize( cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth(), 60 );
353 netNavigatorPane.Fixed();
354 m_auimgr.Update();
355
356 // now make it resizable again
357 hierarchy_pane.Resizable();
358 netNavigatorPane.Resizable();
359 m_auimgr.Update();
360
361 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
362 // back to minimum.
363 hierarchy_pane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
364 netNavigatorPane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
365 }
366 else
367 {
368 m_auimgr.Update();
369 }
370
371 LoadProjectSettings();
372 LoadDrawingSheet();
373
379
380 initScreenZoom();
381
382 m_hierarchy->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
383 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
384 this );
385 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
386 m_netNavigator->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onResizeNetNavigator, this );
387
388 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
389 // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
390 Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
391
392 setupUnits( eeconfig() );
393
394 // Net list generator
395 DefaultExecFlags();
396
397 updateTitle();
398 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
399
400#ifdef KICAD_IPC_API
401 m_apiHandler = std::make_unique<API_HANDLER_SCH>( this );
402 Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
403#endif
404
405 // Default shutdown reason until a file is loaded
406 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
407
408 // Init for dropping files
410 DragAcceptFiles( true );
411
412 // Ensure the window is on top
413 Raise();
414
415 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
416 // top-left corner of the canvas
417 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
418 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
419
420 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
421 Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
422 Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog,
423 this );
424}
425
426
428{
429#ifdef KICAD_IPC_API
430 Pgm().GetApiServer().DeregisterHandler( m_apiHandler.get() );
431 wxTheApp->Unbind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED,
432 &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
433#endif
434
435 m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
436
437 // Ensure m_canvasType is up to date, to save it in config
439
440 SetScreen( nullptr );
441
442 if( m_schematic )
444
445 // Delete all items not in draw list before deleting schematic
446 // to avoid dangling pointers stored in these items
449
450 delete m_schematic;
451 m_schematic = nullptr;
452
453 // Close the project if we are standalone, so it gets cleaned up properly
454 if( Kiface().IsSingle() )
455 {
456 try
457 {
458 GetSettingsManager()->UnloadProject( &Prj(), false );
459 }
460 catch( const nlohmann::detail::type_error& e )
461 {
462 wxFAIL_MSG( wxString::Format( wxT( "Settings exception occurred: %s" ), e.what() ) );
463 }
464 }
465
466 delete m_hierarchy;
468}
469
470
472{
473 aEvent.Skip();
474
475 // Called when resizing the Hierarchy Navigator panel
476 // Store the current pane size
477 // It allows to retrieve the last defined pane size when switching between
478 // docked and floating pane state
479 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
480
481 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
482 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
483
484 if( cfg && m_hierarchy->IsShownOnScreen() )
485 {
486 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
487 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
488
489 // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
490 // width is > 0 (i.e. if its size is already set and has meaning)
491 // if it is floating, its size is not initialized (only floating_size is initialized)
492 // initializing hierarchy_pane.best_size is useful when switching to float pane and
493 // after switching to the docked pane, to retrieve the last docked pane width
494 if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
495 {
496 cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
497 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
498 }
499 }
500}
501
502
504{
505 // Create the manager and dispatcher & route draw panel events to the dispatcher
508 GetCanvas()->GetViewControls(), config(), this );
509 m_actions = new EE_ACTIONS();
511
512 // Register tools
531
532 // Run the selection tool, it is supposed to be always active
534
536}
537
538
540{
542
544 SCH_EDITOR_CONDITIONS cond( this );
545
546 wxASSERT( mgr );
547
548 auto hasElements =
549 [ this ] ( const SELECTION& aSel )
550 {
551 return GetScreen() &&
552 ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
553 };
554
555 auto searchPaneCond =
556 [this] ( const SELECTION& )
557 {
558 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
559 };
560
561 auto propertiesCond =
562 [this] ( const SELECTION& )
563 {
564 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
565 };
566
567 auto hierarchyNavigatorCond =
568 [ this ] ( const SELECTION& aSel )
569 {
570 return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
571 };
572
573 auto netNavigatorCond =
574 [ this ] (const SELECTION& aSel )
575 {
576 return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
577 };
578
579 auto undoCond =
580 [ this ] (const SELECTION& aSel )
581 {
583 return true;
584
585 return GetUndoCommandCount() > 0;
586 };
587
588#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
589#define CHECK( x ) ACTION_CONDITIONS().Check( x )
590
592 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
594
595 mgr->SetConditions( EE_ACTIONS::showSearch, CHECK( searchPaneCond ) );
596 mgr->SetConditions( EE_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
597 mgr->SetConditions( EE_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
598 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
603 CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
604 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
605 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
606
608 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_FREE ) ) );
610 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_90 ) ) );
612 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_45 ) ) );
613
614 mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
615 mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
618 mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
619 mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
620 mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
621 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
622
623 mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( hasElements ) );
624 mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( hasElements ) );
625 mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( hasElements ) );
626 mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( hasElements ) );
627
632
633 if( SCRIPTING::IsWxAvailable() )
634 {
636 CHECK( cond.ScriptingConsoleVisible() ) );
637 }
638
639 auto showHiddenPinsCond =
640 [this]( const SELECTION& )
641 {
642 return GetShowAllPins();
643 };
644
645 auto showHiddenFieldsCond =
646 [this]( const SELECTION& )
647 {
649 return cfg && cfg->m_Appearance.show_hidden_fields;
650 };
651
652 auto showDirectiveLabelsCond =
653 [this]( const SELECTION& )
654 {
656 return cfg && cfg->m_Appearance.show_directive_labels;
657 };
658
659 auto showERCErrorsCond =
660 [this]( const SELECTION& )
661 {
663 return cfg && cfg->m_Appearance.show_erc_errors;
664 };
665
666 auto showERCWarningsCond =
667 [this]( const SELECTION& )
668 {
670 return cfg && cfg->m_Appearance.show_erc_warnings;
671 };
672
673 auto showERCExclusionsCond =
674 [this]( const SELECTION& )
675 {
677 return cfg && cfg->m_Appearance.show_erc_exclusions;
678 };
679
680 auto markSimExclusionsCond =
681 [this]( const SELECTION& )
682 {
684 return cfg && cfg->m_Appearance.mark_sim_exclusions;
685 };
686
687 auto showOPVoltagesCond =
688 [this]( const SELECTION& )
689 {
691 return cfg && cfg->m_Appearance.show_op_voltages;
692 };
693
694 auto showOPCurrentsCond =
695 [this]( const SELECTION& )
696 {
698 return cfg && cfg->m_Appearance.show_op_currents;
699 };
700
701 auto showAnnotateAutomaticallyCond =
702 [this]( const SELECTION& )
703 {
705 return cfg && cfg->m_AnnotatePanel.automatic;
706 };
707
708 auto remapSymbolsCondition =
709 [&]( const SELECTION& aSel )
710 {
711 SCH_SCREENS schematic( Schematic().Root() );
712
713 // The remapping can only be performed on legacy projects.
714 return schematic.HasNoFullyDefinedLibIds();
715 };
716
717 auto belowRootSheetCondition =
718 [this]( const SELECTION& aSel )
719 {
721 return navigateTool && navigateTool->CanGoUp();
722 };
723
724 mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
725
726 /* Some of these are bound by default to arrow keys which will get a different action if we
727 * disable the buttons. So always leave them enabled so the action is consistent.
728 * https://gitlab.com/kicad/code/kicad/-/issues/14783
729 mgr->SetConditions( EE_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
730 mgr->SetConditions( EE_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
731 mgr->SetConditions( EE_ACTIONS::navigateBack, ENABLE( navHistoryHsBackward ) );
732 */
733
734 mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
735 mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
736 mgr->SetConditions( EE_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
737 mgr->SetConditions( EE_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
738 mgr->SetConditions( EE_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
739 mgr->SetConditions( EE_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
740 mgr->SetConditions( EE_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
741 mgr->SetConditions( EE_ACTIONS::markSimExclusions, CHECK( markSimExclusionsCond ) );
742 mgr->SetConditions( EE_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
743 mgr->SetConditions( EE_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
744 mgr->SetConditions( EE_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
746
747#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
748
774
775#undef CURRENT_TOOL
776#undef CHECK
777#undef ENABLE
778}
779
780
782{
783 // we cannot store a pointer to an item in the display list here since
784 // that item may be deleted, such as part of a line concatenation or other.
785 // So simply always keep a copy of the object which is to be repeated.
786
787 if( aItem )
788 {
789 m_items_to_repeat.clear();
790
791 AddCopyForRepeatItem( aItem );
792 }
793}
794
795
797{
798 // we cannot store a pointer to an item in the display list here since
799 // that item may be deleted, such as part of a line concatenation or other.
800 // So simply always keep a copy of the object which is to be repeated.
801
802 if( aItem )
803 {
804 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate() ) );
805
806 // Clone() preserves the flags, we want 'em cleared.
807 repeatItem->ClearFlags();
808
809 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
810 }
811}
812
813
815{
816 return Schematic().GetItem( aId );
817}
818
819
821{
823}
824
825
827{
828 return GetCurrentSheet().LastScreen();
829}
830
831
833{
834 return *m_schematic;
835}
836
837
839{
840 return GetCurrentSheet().Last()->GetName();
841}
842
843
845{
847}
848
849
851{
854
855 SCH_SHEET* rootSheet = new SCH_SHEET( m_schematic );
856 m_schematic->SetRoot( rootSheet );
857
858 SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
859 const_cast<KIID&>( rootSheet->m_Uuid ) = rootScreen->GetUuid();
860 m_schematic->Root().SetScreen( rootScreen );
861 SetScreen( Schematic().RootScreen() );
862
863
864 m_schematic->RootScreen()->SetFileName( wxEmptyString );
865
866 // Don't leave root page number empty
867 SCH_SHEET_PATH rootSheetPath;
868
869 rootSheetPath.push_back( rootSheet );
870 m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
871 rootSheetPath.SetPageNumber( wxT( "1" ) );
872
873 if( GetScreen() == nullptr )
874 {
875 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
876 SetScreen( screen );
877 }
878}
879
880
882{
883 return m_schematic->CurrentSheet();
884}
885
886
888{
889 if( aSheet != GetCurrentSheet() )
890 {
891 FocusOnItem( nullptr );
892
893 Schematic().SetCurrentSheet( aSheet );
894 GetCanvas()->DisplaySheet( aSheet.LastScreen() );
895 }
896}
897
898
900{
902
903 for( SCH_ITEM* item : screen->Items() )
904 item->ClearCaches();
905
906 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
907 {
908 wxCHECK2( libSymbol.second, continue );
909 libSymbol.second->ClearCaches();
910 }
911
912 if( Schematic().Settings().m_IntersheetRefsShow )
914
915 FocusOnItem( nullptr );
916
917 GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
918
920 selectionTool->Reset( TOOL_BASE::REDRAW );
921
923}
924
925
926bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
927{
928 // Exit interactive editing
929 // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
930 // will cancel any drag currently in progress, but commit all changes from previous drags.
931 if( m_toolManager )
933
934 // Shutdown blocks must be determined and vetoed as early as possible
935 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
936 && IsContentModified() )
937 {
938 return false;
939 }
940
941 if( Kiface().IsSingle() )
942 {
943 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
944
945 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
946 return false;
947
948 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
949
950 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
951 return false;
952
953 // SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
954 // sorry.
955 auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
956
957 if( chooser && !chooser->Close() ) // Can close symbol chooser?
958 return false;
959 }
960 else
961 {
962 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
963
964 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
965 {
966 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
967 return false;
968 }
969 }
970
971 if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
972 return false;
973
975 && !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
976 {
977 return false;
978 }
979
980 // We may have gotten multiple events; don't clean up twice
981 if( !Schematic().IsValid() )
982 return false;
983
984 if( IsContentModified() )
985 {
986 wxFileName fileName = Schematic().RootScreen()->GetFileName();
987 wxString msg = _( "Save changes to '%s' before closing?" );
988
989 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
990 [&]() -> bool
991 {
992 return SaveProject();
993 } ) )
994 {
995 return false;
996 }
997 }
998
999 return true;
1000}
1001
1002
1004{
1006
1007 // Shutdown all running tools
1008 if( m_toolManager )
1010
1011 // Close modeless dialogs. They're trouble when they get destroyed after the frame.
1012 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
1013 Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
1014 Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE,
1016 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
1017 this );
1018 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection,
1019 this );
1020
1021 // Close the find dialog and preserve its setting if it is displayed.
1023 {
1026
1027 m_findReplaceDialog->Destroy();
1028 m_findReplaceDialog = nullptr;
1029 }
1030
1031 if( m_diffSymbolDialog )
1032 {
1033 m_diffSymbolDialog->Destroy();
1034 m_diffSymbolDialog = nullptr;
1035 }
1036
1037 if( m_ercDialog )
1038 {
1039 m_ercDialog->Destroy();
1040 m_ercDialog = nullptr;
1041 }
1042
1044 {
1045 m_symbolFieldsTableDialog->Destroy();
1046 m_symbolFieldsTableDialog = nullptr;
1047 }
1048
1049 // Make sure local settings are persisted
1051
1052 // Shutdown all running tools
1053 if( m_toolManager )
1054 {
1056 // prevent the canvas from trying to dispatch events during close
1057 GetCanvas()->SetEventDispatcher( nullptr );
1058 delete m_toolManager;
1059 m_toolManager = nullptr;
1060 }
1061
1062 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
1063
1064 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
1065 {
1066 hierarchy_pane.Show( false );
1067 m_auimgr.Update();
1068 }
1069
1070 SCH_SCREENS screens( Schematic().Root() );
1071 wxFileName fn;
1072
1073 for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
1074 {
1075 fn = Prj().AbsolutePath( screen->GetFileName() );
1076
1077 // Auto save file name is the normal file name prepended with FILEEXT::AutoSaveFilePrefix.
1078 fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() );
1079
1080 if( fn.IsFileWritable() )
1081 wxRemoveFile( fn.GetFullPath() );
1082 }
1083
1084 wxFileName tmpFn = Prj().GetProjectFullName();
1085 wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
1086
1087 if( autoSaveFileName.IsFileWritable() )
1088 wxRemoveFile( autoSaveFileName.GetFullPath() );
1089
1090 sheetlist.ClearModifyStatus();
1091
1092 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
1093
1094 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
1095 UpdateFileHistory( fileName );
1096
1097 Schematic().RootScreen()->Clear( true );
1098
1099 // all sub sheets are deleted, only the main sheet is usable
1101
1102 // Clear view before destroying schematic as repaints depend on schematic being valid
1103 SetScreen( nullptr );
1104
1105 Schematic().Reset();
1106
1107 // Prevents any rogue events from continuing (i.e. search panel tries to redraw)
1108 Show( false );
1109
1110 Destroy();
1111}
1112
1113
1115{
1116 return Schematic().ErcSettings().GetSeverity( aErrorCode );
1117}
1118
1119
1121{
1123
1124 if( GetScreen() )
1126
1127 m_autoSaveRequired = true;
1128
1129 if( GetCanvas() )
1130 GetCanvas()->Refresh();
1131
1132 if( !GetTitle().StartsWith( wxS( "*" ) ) )
1133 updateTitle();
1134}
1135
1136
1137void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
1138{
1139 if( Kiface().IsSingle() )
1140 {
1141 DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
1142 " in stand-alone mode. In order to create/update PCBs from"
1143 " schematics, launch the KiCad shell and create a project." ) );
1144 return;
1145 }
1146
1147 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1148
1149 if( !frame )
1150 {
1151 wxFileName fn = Prj().GetProjectFullName();
1152 fn.SetExt( FILEEXT::PcbFileExtension );
1153
1154 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1155
1156 // If Kiway() cannot create the Pcbnew frame, it shows a error message, and
1157 // frame is null
1158 if( !frame )
1159 return;
1160
1161 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1162 }
1163
1164 if( !frame->IsVisible() )
1165 frame->Show( true );
1166
1167 // On Windows, Raise() does not bring the window on screen, when iconized
1168 if( frame->IsIconized() )
1169 frame->Iconize( false );
1170
1171 frame->Raise();
1172
1173 std::string payload;
1175}
1176
1177
1178void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator )
1179{
1180 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
1182
1183 if( aRefreshNetNavigator )
1185}
1186
1187
1189{
1190 // Update only the hierarchy navigation tree labels.
1191 // The tree list is expectyed to be up to date
1193}
1194
1195
1197{
1199}
1200
1201
1203{
1204 wxString findString;
1205
1206 EE_SELECTION& selection = m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1207
1208 if( selection.Size() == 1 )
1209 {
1210 EDA_ITEM* front = selection.Front();
1211
1212 switch( front->Type() )
1213 {
1214 case SCH_SYMBOL_T:
1215 {
1216 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( front );
1217 findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() );
1218 break;
1219 }
1220
1221 case SCH_FIELD_T:
1222 findString = UnescapeString( static_cast<SCH_FIELD*>( front )->GetText() );
1223 break;
1224
1225 case SCH_LABEL_T:
1226 case SCH_GLOBAL_LABEL_T:
1227 case SCH_HIER_LABEL_T:
1228 case SCH_SHEET_PIN_T:
1229 findString = UnescapeString( static_cast<SCH_LABEL_BASE*>( front )->GetText() );
1230 break;
1231
1232 case SCH_TEXT_T:
1233 findString = UnescapeString( static_cast<SCH_TEXT*>( front )->GetText() );
1234
1235 if( findString.Contains( wxT( "\n" ) ) )
1236 findString = findString.Before( '\n' );
1237
1238 break;
1239
1240 default:
1241 break;
1242 }
1243 }
1244
1246 m_findReplaceDialog->Destroy();
1247
1249 static_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() ),
1250 wxDefaultPosition, wxDefaultSize,
1251 aReplace ? wxFR_REPLACEDIALOG : 0 );
1252
1255 m_findReplaceDialog->Show( true );
1256}
1257
1258
1259void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
1260{
1261 // Prepare the infobar, since we don't know its state
1264
1265 m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
1266}
1267
1268
1270{
1271 m_infoBar->Dismiss();
1272}
1273
1274
1276{
1279
1280 m_findReplaceDialog->Destroy();
1281 m_findReplaceDialog = nullptr;
1282
1284}
1285
1286
1287void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1288{
1289 wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1290
1291 if( fn.size() )
1292 OpenProjectFiles( std::vector<wxString>( 1, fn ) );
1293}
1294
1295
1296void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
1297{
1299}
1300
1301
1303{
1304 // Only standalone mode can directly load a new document
1305 if( !Kiface().IsSingle() )
1306 return;
1307
1308 wxString pro_dir = m_mruPath;
1309
1310 wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
1312
1313 if( dlg.ShowModal() != wxID_CANCEL )
1314 {
1315 // Enforce the extension, wxFileDialog is inept.
1316 wxFileName create_me =
1318
1319 if( create_me.FileExists() )
1320 {
1321 wxString msg;
1322 msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
1323 DisplayError( this, msg );
1324 return ;
1325 }
1326
1327 // OpenProjectFiles() requires absolute
1328 wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
1329
1330 OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1331 m_mruPath = create_me.GetPath();
1332 }
1333}
1334
1335
1337{
1338 // Only standalone mode can directly load a new document
1339 if( !Kiface().IsSingle() )
1340 return;
1341
1342 wxString pro_dir = m_mruPath;
1343 wxString wildcards = FILEEXT::AllSchematicFilesWildcard()
1345 + wxS( "|" ) + FILEEXT::LegacySchematicFileWildcard();
1346
1347 wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
1348 wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1349
1350 if( dlg.ShowModal() != wxID_CANCEL )
1351 {
1352 OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1354 }
1355}
1356
1357
1358void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
1359{
1360 wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
1361
1362 if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
1363 {
1364 kicad_board.SetExt( FILEEXT::PcbFileExtension );
1365 wxFileName legacy_board( kicad_board );
1366 legacy_board.SetExt( FILEEXT::LegacyPcbFileExtension );
1367 wxFileName& boardfn = legacy_board;
1368
1369 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1370 boardfn = kicad_board;
1371
1372 if( Kiface().IsSingle() )
1373 {
1374 ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
1375 }
1376 else
1377 {
1378 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1379
1380 if( !frame )
1381 {
1382 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1383
1384 // frame can be null if Cvpcb cannot be run. No need to show a warning
1385 // Kiway() generates the error messages
1386 if( !frame )
1387 return;
1388
1389 frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1390 }
1391
1392 if( !frame->IsVisible() )
1393 frame->Show( true );
1394
1395 // On Windows, Raise() does not bring the window on screen, when iconized
1396 if( frame->IsIconized() )
1397 frame->Iconize( false );
1398
1399 frame->Raise();
1400 }
1401 }
1402 else
1403 {
1404 // If we are running inside a project, it should be impossible for this case to happen
1405 wxASSERT( Kiface().IsSingle() );
1407 }
1408}
1409
1410
1411void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1412{
1413 wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1414 fn.SetExt( FILEEXT::NetlistFileExtension );
1415
1416 if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1417 return;
1418
1419 try
1420 {
1421 KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1422
1423 if( !player )
1424 {
1425 player = Kiway().Player( FRAME_CVPCB, true );
1426
1427 // player can be null if Cvpcb cannot be run. No need to show a warning
1428 // Kiway() generates the error messages
1429 if( !player )
1430 return;
1431
1432 player->Show( true );
1433 }
1434
1435 // Ensure the netlist (mainly info about symbols) is up to date
1438
1439 player->Raise();
1440 }
1441 catch( const IO_ERROR& )
1442 {
1443 DisplayError( this, _( "Could not open CvPcb" ) );
1444 }
1445}
1446
1447
1448void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1449{
1450 if( event.GetId() == wxID_EXIT )
1451 Kiway().OnKiCadExit();
1452
1453 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1454 Close( false );
1455}
1456
1457
1459{
1460 wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1461 const SCH_RENDER_SETTINGS* cfg = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
1463
1464 cfg->GetPrintDC()->SetBackground( wxBrush( bg.ToColour() ) );
1465 cfg->GetPrintDC()->Clear();
1466
1467 cfg->GetPrintDC()->SetLogicalFunction( wxCOPY );
1468 GetScreen()->Print( cfg );
1469 PrintDrawingSheet( cfg, GetScreen(), Schematic().GetProperties(), schIUScale.IU_PER_MILS, fileName );
1470}
1471
1472
1474{
1476 SIM_LIB_MGR simLibMgr( &Prj() );
1477 NULL_REPORTER devnull;
1478
1479 // Patch for bug early in V7.99 dev
1480 if( settings.m_OPO_VRange.EndsWith( 'A' ) )
1481 settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
1482
1483 // Update items which may have ${OP} text variables
1484 //
1486 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1487 {
1488 int flags = 0;
1489
1490 auto invalidateTextVars =
1491 [&flags]( EDA_TEXT* text )
1492 {
1493 if( text->HasTextVars() )
1494 {
1495 text->ClearRenderCache();
1496 text->ClearBoundingBoxCache();
1498 }
1499 };
1500
1501 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1502 {
1503 item->RunOnChildren(
1504 [&invalidateTextVars]( SCH_ITEM* aChild )
1505 {
1506 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1507 invalidateTextVars( text );
1508 } );
1509 }
1510
1511 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1512 invalidateTextVars( text );
1513
1514 return flags;
1515 } );
1516
1517 // Update OP overlay items
1518 //
1519 for( SCH_ITEM* item : GetScreen()->Items() )
1520 {
1522 continue;
1523
1524 if( item->Type() == SCH_LINE_T )
1525 {
1526 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1527
1528 if( !line->GetOperatingPoint().IsEmpty() )
1529 GetCanvas()->GetView()->Update( line );
1530
1531 line->SetOperatingPoint( wxEmptyString );
1532 // update value from netlist, below
1533 }
1534 else if( item->Type() == SCH_SYMBOL_T )
1535 {
1536 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1537 wxString ref = symbol->GetRef( &GetCurrentSheet() );
1538 std::vector<SCH_PIN*> pins = symbol->GetPins( &GetCurrentSheet() );
1539
1540 // Power symbols and other symbols which have the reference starting with "#" are
1541 // not included in simulation
1542 if( ref.StartsWith( '#' ) || symbol->GetExcludedFromSim() )
1543 continue;
1544
1545 for( SCH_PIN* pin : pins )
1546 {
1547 if( !pin->GetOperatingPoint().IsEmpty() )
1548 GetCanvas()->GetView()->Update( pin );
1549
1550 pin->SetOperatingPoint( wxEmptyString );
1551 }
1552
1553 if( pins.size() == 2 )
1554 {
1555 wxString op = m_schematic->GetOperatingPoint( ref, settings.m_OPO_IPrecision,
1556 settings.m_OPO_IRange );
1557
1558 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1559 {
1560 pins[0]->SetOperatingPoint( op );
1561 GetCanvas()->GetView()->Update( symbol );
1562 }
1563 }
1564 else
1565 {
1566 SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol,
1567 devnull ).model;
1568
1569 SPICE_ITEM spiceItem;
1570 spiceItem.refName = ref;
1571 ref = model.SpiceGenerator().ItemName( spiceItem );
1572
1573 for( const auto& modelPin : model.GetPins() )
1574 {
1575 SCH_PIN* symbolPin = symbol->GetPin( modelPin.get().symbolPinNumber );
1576 wxString signalName = ref + wxS( ":" ) + modelPin.get().modelPinName;
1577 wxString op = m_schematic->GetOperatingPoint( signalName,
1578 settings.m_OPO_IPrecision,
1579 settings.m_OPO_IRange );
1580
1581 if( symbolPin && !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1582 {
1583 symbolPin->SetOperatingPoint( op );
1584 GetCanvas()->GetView()->Update( symbol );
1585 }
1586 }
1587 }
1588 }
1589 }
1590
1591 for( const auto& [ key, subgraphList ] : m_schematic->m_connectionGraph->GetNetMap() )
1592 {
1593 wxString op = m_schematic->GetOperatingPoint( key.Name, settings.m_OPO_VPrecision,
1594 settings.m_OPO_VRange );
1595
1596 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1597 {
1598 for( CONNECTION_SUBGRAPH* subgraph : subgraphList )
1599 {
1600 SCH_LINE* longestWire = nullptr;
1601 double length = 0.0;
1602
1603 if( subgraph->GetSheet().GetExcludedFromSim() )
1604 continue;
1605
1606 for( SCH_ITEM* item : subgraph->GetItems() )
1607 {
1608 if( item->Type() == SCH_LINE_T )
1609 {
1610 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1611
1612 if( line->IsWire() && line->GetLength() > length )
1613 {
1614 longestWire = line;
1615 length = line->GetLength();
1616 }
1617 }
1618 }
1619
1620 if( longestWire )
1621 {
1622 longestWire->SetOperatingPoint( op );
1623 GetCanvas()->GetView()->Update( longestWire );
1624 }
1625 }
1626 }
1627 }
1628}
1629
1630
1632{
1633 if( aItem->Type() == SCH_GLOBAL_LABEL_T || aItem->Type() == SCH_HIER_LABEL_T )
1634 {
1635 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
1636
1637 if( label->AutoRotateOnPlacement() )
1638 {
1639 SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
1640 label->GetSpinStyle(),
1641 &GetCurrentSheet() );
1642
1643 if( spin != label->GetSpinStyle() )
1644 {
1645 label->SetSpinStyle( spin );
1646
1647 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1648 {
1649 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1650
1651 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1652 otherLabel->AutoplaceFields( aScreen, false );
1653 }
1654 }
1655 }
1656 }
1657}
1658
1659
1661{
1662 SCH_SCREEN* screen = GetScreen();
1663
1664 wxCHECK( screen, /* void */ );
1665
1666 wxString title;
1667
1668 if( !screen->GetFileName().IsEmpty() )
1669 {
1670 wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1671 bool readOnly = false;
1672 bool unsaved = false;
1673
1674 if( fn.IsOk() && screen->FileExists() )
1675 readOnly = screen->IsReadOnly();
1676 else
1677 unsaved = true;
1678
1679 if( IsContentModified() )
1680 title = wxT( "*" );
1681
1682 title += fn.GetName();
1683
1684 wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
1685
1686 if( sheetPath != title )
1687 title += wxString::Format( wxT( " [%s]" ), sheetPath );
1688
1689 if( readOnly )
1690 title += wxS( " " ) + _( "[Read Only]" );
1691
1692 if( unsaved )
1693 title += wxS( " " ) + _( "[Unsaved]" );
1694 }
1695 else
1696 {
1697 title = _( "[no schematic loaded]" );
1698 }
1699
1700 title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1701
1702 SetTitle( title );
1703}
1704
1705
1707{
1709 GetScreen()->m_zoomInitialized = true;
1710}
1711
1712
1714{
1715 wxString highlightedConn = GetHighlightedConnection();
1716 bool hasHighlightedConn = !highlightedConn.IsEmpty();
1717 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1719 SCH_COMMIT localCommit( m_toolManager );
1720
1721 if( !aCommit )
1722 aCommit = &localCommit;
1723
1724#ifdef PROFILE
1725 PROF_TIMER timer;
1726#endif
1727
1728 // Ensure schematic graph is accurate
1729 if( aCleanupFlags == LOCAL_CLEANUP )
1730 {
1731 SchematicCleanUp( aCommit, GetScreen() );
1732 }
1733 else if( aCleanupFlags == GLOBAL_CLEANUP )
1734 {
1735 for( const SCH_SHEET_PATH& sheet : list )
1736 SchematicCleanUp( aCommit, sheet.LastScreen() );
1737 }
1738
1739#ifdef PROFILE
1740 timer.Stop();
1741 wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1742#endif
1743
1744 if( settings.m_IntersheetRefsShow )
1746
1747 std::function<void( SCH_ITEM* )> changeHandler =
1748 [&]( SCH_ITEM* aChangedItem ) -> void
1749 {
1750 GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1751
1752 SCH_CONNECTION* connection = aChangedItem->Connection();
1753
1755 return;
1756
1757 if( !hasHighlightedConn )
1758 {
1759 // No highlighted connection, but connectivity has changed, so refresh
1760 // the list of all nets
1762 }
1763 else if( connection
1764 && ( connection->Name() == highlightedConn
1765 || connection->HasDriverChanged() ) )
1766 {
1768 }
1769 };
1770
1771 if( !ADVANCED_CFG::GetCfg().m_IncrementalConnectivity || aCleanupFlags == GLOBAL_CLEANUP
1772 || m_undoList.m_CommandsList.empty()|| Schematic().ConnectionGraph()->IsMinor() )
1773 {
1774 // Update all rule areas so we can cascade implied connectivity changes
1775 std::unordered_set<SCH_SCREEN*> all_screens;
1776
1777 for( const SCH_SHEET_PATH& path : list )
1778 all_screens.insert( path.LastScreen() );
1779
1780 SCH_RULE_AREA::UpdateRuleAreasInScreens( all_screens, GetCanvas()->GetView() );
1781
1782 // Recalculate all connectivity
1783 Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
1784 }
1785 else
1786 {
1787 struct CHANGED_ITEM
1788 {
1789 SCH_ITEM* item;
1790 SCH_ITEM* linked_item;
1791 SCH_SCREEN* screen;
1792 };
1793
1794 PICKED_ITEMS_LIST* changed_list = m_undoList.m_CommandsList.back();
1795
1796 // Final change sets
1797 std::set<SCH_ITEM*> changed_items;
1798 std::set<VECTOR2I> pts;
1799 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> item_paths;
1800
1801 // Working change sets
1802 std::unordered_set<SCH_SCREEN*> changed_screens;
1803 std::set<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> changed_rule_areas;
1804 std::vector<CHANGED_ITEM> changed_connectable_items;
1805
1806 // Lambda to add an item to the connectivity update sets
1807 auto addItemToChangeSet = [&changed_items, &pts, &item_paths]( CHANGED_ITEM itemData )
1808 {
1809 std::vector<SCH_SHEET_PATH>& paths = itemData.screen->GetClientSheetPaths();
1810
1811 std::vector<VECTOR2I> tmp_pts = itemData.item->GetConnectionPoints();
1812 pts.insert( tmp_pts.begin(), tmp_pts.end() );
1813 changed_items.insert( itemData.item );
1814
1815 for( SCH_SHEET_PATH& path : paths )
1816 item_paths.insert( std::make_pair( path, itemData.item ) );
1817
1818 if( !itemData.linked_item || !itemData.linked_item->IsConnectable() )
1819 return;
1820
1821 tmp_pts = itemData.linked_item->GetConnectionPoints();
1822 pts.insert( tmp_pts.begin(), tmp_pts.end() );
1823 changed_items.insert( itemData.linked_item );
1824
1825 // We have to directly add the pins here because the link may not exist on the schematic
1826 // anymore and so won't be picked up by GetScreen()->Items().Overlapping() below.
1827 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( itemData.linked_item ) )
1828 {
1829 std::vector<SCH_PIN*> pins = symbol->GetPins();
1830 changed_items.insert( pins.begin(), pins.end() );
1831 }
1832
1833 for( SCH_SHEET_PATH& path : paths )
1834 item_paths.insert( std::make_pair( path, itemData.linked_item ) );
1835 };
1836
1837 // Get all changed connectable items and determine all changed screens
1838 for( unsigned ii = 0; ii < changed_list->GetCount(); ++ii )
1839 {
1840 switch( changed_list->GetPickedItemStatus( ii ) )
1841 {
1842 // Only care about changed, new, and deleted items, the other
1843 // cases are not connectivity-related
1844 case UNDO_REDO::CHANGED:
1845 case UNDO_REDO::NEWITEM:
1846 case UNDO_REDO::DELETED:
1847 break;
1848
1849 default:
1850 continue;
1851 }
1852
1853 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItem( ii ) );
1854
1855 if( item )
1856 {
1857 SCH_SCREEN* screen =
1858 static_cast<SCH_SCREEN*>( changed_list->GetScreenForItem( ii ) );
1859 changed_screens.insert( screen );
1860
1861 if( item->Type() == SCH_RULE_AREA_T )
1862 {
1863 SCH_RULE_AREA* ruleArea = static_cast<SCH_RULE_AREA*>( item );
1864
1865 // Clear item and directive associations for this rule area
1866 ruleArea->ResetDirectivesAndItems( GetCanvas()->GetView() );
1867
1868 changed_rule_areas.insert( { ruleArea, screen } );
1869 }
1870 else if( item->IsConnectable() )
1871 {
1872 SCH_ITEM* linked_item =
1873 dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItemLink( ii ) );
1874 changed_connectable_items.push_back( { item, linked_item, screen } );
1875 }
1876 }
1877 }
1878
1879 // Update rule areas in changed screens to propagate any directive connectivity changes
1880 std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> forceUpdateRuleAreas =
1881 SCH_RULE_AREA::UpdateRuleAreasInScreens( changed_screens, GetCanvas()->GetView() );
1882
1883 std::for_each( forceUpdateRuleAreas.begin(), forceUpdateRuleAreas.end(),
1884 [&]( std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& updatedRuleArea )
1885 {
1886 changed_rule_areas.insert( updatedRuleArea );
1887 } );
1888
1889 // If a SCH_RULE_AREA was changed, we need to add all past and present contained items to
1890 // update their connectivity
1891 for( const std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& changedRuleArea : changed_rule_areas )
1892 {
1893 for( SCH_ITEM* containedItem :
1894 changedRuleArea.first->GetPastAndPresentContainedItems() )
1895 {
1896 addItemToChangeSet( { containedItem, nullptr, changedRuleArea.second } );
1897 }
1898 }
1899
1900 // Add all changed items, and associated items, to the change set
1901 for( CHANGED_ITEM& changed_item_data : changed_connectable_items )
1902 {
1903 addItemToChangeSet( changed_item_data );
1904
1905 // If a SCH_DIRECTIVE_LABEL was changed which is attached to a SCH_RULE_AREA, we need
1906 // to add the contained items to the change set to force update of their connectivity
1907 if( changed_item_data.item->Type() == SCH_DIRECTIVE_LABEL_T )
1908 {
1909 const std::vector<VECTOR2I> labelConnectionPoints =
1910 changed_item_data.item->GetConnectionPoints();
1911
1912 EE_RTREE::EE_TYPE candidateRuleAreas =
1913 changed_item_data.screen->Items().Overlapping(
1914 SCH_RULE_AREA_T, changed_item_data.item->GetBoundingBox() );
1915
1916 for( SCH_ITEM* candidateRuleArea : candidateRuleAreas )
1917 {
1918 SCH_RULE_AREA* ruleArea = static_cast<SCH_RULE_AREA*>( candidateRuleArea );
1919 std::vector<SHAPE*> borderShapes = ruleArea->MakeEffectiveShapes( true );
1920
1921 if( ruleArea->GetPolyShape().CollideEdge( labelConnectionPoints[0], nullptr,
1922 5 ) )
1923 {
1924 for( SCH_ITEM* containedItem : ruleArea->GetPastAndPresentContainedItems() )
1925 addItemToChangeSet(
1926 { containedItem, nullptr, changed_item_data.screen } );
1927 }
1928 }
1929 }
1930 }
1931
1932 for( const VECTOR2I& pt: pts )
1933 {
1934 for( SCH_ITEM* item : GetScreen()->Items().Overlapping( pt ) )
1935 {
1936 // Leave this check in place. Overlapping items are not necessarily connectable.
1937 if( !item->IsConnectable() )
1938 continue;
1939
1940 if( item->Type() == SCH_LINE_T )
1941 {
1942 if( item->HitTest( pt ) )
1943 changed_items.insert( item );
1944 }
1945 else if( item->Type() == SCH_SYMBOL_T && item->IsConnected( pt ) )
1946 {
1947 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1948 std::vector<SCH_PIN*> pins = symbol->GetPins();
1949
1950 changed_items.insert( pins.begin(), pins.end() );
1951 }
1952 else if( item->Type() == SCH_SHEET_T )
1953 {
1954 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1955
1956 wxCHECK2( sheet, continue );
1957
1958 std::vector<SCH_SHEET_PIN*> sheetPins = sheet->GetPins();
1959 changed_items.insert( sheetPins.begin(), sheetPins.end() );
1960 }
1961 else
1962 {
1963 if( item->IsConnected( pt ) )
1964 changed_items.insert( item );
1965 }
1966 }
1967 }
1968
1969 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> all_items =
1970 Schematic().ConnectionGraph()->ExtractAffectedItems( changed_items );
1971
1972 all_items.insert( item_paths.begin(), item_paths.end() );
1973
1974 CONNECTION_GRAPH new_graph( &Schematic() );
1975
1976 new_graph.SetLastCodes( Schematic().ConnectionGraph() );
1977
1978 for( auto&[ path, item ] : all_items )
1979 {
1980 wxCHECK2( item, continue );
1981 item->SetConnectivityDirty();
1982 }
1983
1984 new_graph.Recalculate( list, false, &changeHandler );
1985 Schematic().ConnectionGraph()->Merge( new_graph );
1986 }
1987
1989 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1990 {
1991 int flags = 0;
1992 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
1993 SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
1994
1995 auto invalidateTextVars =
1996 [&flags]( EDA_TEXT* text )
1997 {
1998 if( text->HasTextVars() )
1999 {
2000 text->ClearRenderCache();
2001 text->ClearBoundingBoxCache();
2003 }
2004 };
2005
2006 if( connection && connection->HasDriverChanged() )
2007 {
2008 connection->ClearDriverChanged();
2009 flags |= KIGFX::REPAINT;
2010 }
2011
2012 if( item )
2013 {
2014 item->RunOnChildren(
2015 [&invalidateTextVars]( SCH_ITEM* aChild )
2016 {
2017 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
2018 invalidateTextVars( text );
2019 } );
2020
2021 if( flags & KIGFX::GEOMETRY )
2022 GetScreen()->Update( item, false ); // Refresh RTree
2023 }
2024
2025 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
2026 invalidateTextVars( text );
2027
2028 return flags;
2029 } );
2030
2032 || !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
2033 {
2037 }
2038
2039 if( !localCommit.Empty() )
2040 localCommit.Push( _( "Schematic Cleanup" ) );
2041}
2042
2043
2045{
2047 {
2048 for( SCH_FIELD& field : label->GetFields() )
2049 field.ClearBoundingBoxCache();
2050
2051 label->ClearBoundingBoxCache();
2052 GetCanvas()->GetView()->Update( label );
2053 } );
2054}
2055
2056
2058{
2060
2062}
2063
2064
2065void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
2066{
2067 SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
2068
2069 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
2070
2072
2074
2078
2079 KIGFX::VIEW* view = GetCanvas()->GetView();
2085
2087
2088 settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
2089
2090 if( !cfg->m_Drawing.field_names.IsEmpty() )
2092
2094
2095 for( SCH_ITEM* item : screen->Items() )
2096 item->ClearCaches();
2097
2098 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
2099 libSymbol->ClearCaches();
2100
2102
2104 Layout();
2105 SendSizeEvent();
2106}
2107
2108
2110{
2111 // Store the current zoom level into the current screen before calling
2112 // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
2114
2115 // Rebuild the sheet view (draw area and any other items):
2117}
2118
2119
2121{
2122 // call my base class
2124
2125 // tooltips in toolbars
2127
2128 m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
2129 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
2130 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
2131 m_auimgr.Update();
2133
2134 // status bar
2136
2137 updateTitle();
2138
2139 // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
2140 // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
2141 // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
2142 // toolbar to update correctly.
2143#if defined( __WXMSW__ )
2144 PostSizeEvent();
2145#endif
2146}
2147
2148
2150{
2151 if( !GetHighlightedConnection().IsEmpty() )
2152 {
2153 SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
2155 }
2156 else
2157 {
2158 SetStatusText( wxT( "" ) );
2159 }
2160}
2161
2162
2164{
2165 if( m_toolManager )
2167
2168 SCH_BASE_FRAME::SetScreen( aScreen );
2169 GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
2170
2171 if( m_toolManager )
2173}
2174
2175
2176const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
2177{
2178 BOX2I bBoxDoc;
2179
2180 if( aIncludeAllVisible )
2181 {
2182 // Get the whole page size and return that
2185 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
2186 }
2187 else
2188 {
2189 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
2191 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
2192
2193 // Calc the bounding box of all items on screen except the page border
2194 for( EDA_ITEM* item : GetScreen()->Items() )
2195 {
2196 if( item != dsAsItem ) // Ignore the drawing-sheet itself
2197 bBoxDoc.Merge( item->GetBoundingBox() );
2198 }
2199 }
2200
2201 return bBoxDoc;
2202}
2203
2204
2206{
2208}
2209
2210
2212{
2213 EESCHEMA_SETTINGS* cfg = eeconfig();
2214 return cfg && cfg->m_Appearance.show_hidden_pins;
2215}
2216
2217
2219{
2220 static KIID lastBrightenedItemID( niluuid );
2221
2223 SCH_ITEM* lastItem = Schematic().GetItem( lastBrightenedItemID, &dummy );
2224
2225 if( lastItem && lastItem != aItem )
2226 {
2227 lastItem->ClearBrightened();
2228
2229 UpdateItem( lastItem );
2230 lastBrightenedItemID = niluuid;
2231 }
2232
2233 if( aItem )
2234 {
2235 if( !aItem->IsBrightened() )
2236 {
2237 aItem->SetBrightened();
2238
2239 UpdateItem( aItem );
2240 lastBrightenedItemID = aItem->m_Uuid;
2241 }
2242
2244 }
2245}
2246
2247
2249{
2250 return Schematic().GetFileName();
2251}
2252
2253
2255{
2256 return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
2257}
2258
2259
2260void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2261{
2262 if( IsShown() )
2263 {
2264 // We only need this until the frame is done resizing and the final client size is
2265 // established.
2266 Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
2268 }
2269
2270 // Skip() is called in the base class.
2271 EDA_DRAW_FRAME::OnSize( aEvent );
2272}
2273
2274
2276 const KIID& aSchematicSymbolUUID )
2277{
2278 SCH_SHEET_PATH principalPath;
2280 SCH_ITEM* item = sheets.GetItem( aSchematicSymbolUUID, &principalPath );
2281 SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
2282 SCH_COMMIT commit( m_toolManager );
2283
2284 if( !principalSymbol )
2285 return;
2286
2287 wxString principalRef;
2288
2289 if( principalSymbol->IsAnnotated( &principalPath ) )
2290 principalRef = principalSymbol->GetRef( &principalPath, false );
2291
2292 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
2293
2294 for( const SCH_SHEET_PATH& path : sheets )
2295 {
2296 for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2297 {
2298 SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
2299
2300 if( candidateSymbol == principalSymbol
2301 || ( candidateSymbol->IsAnnotated( &path )
2302 && candidateSymbol->GetRef( &path, false ) == principalRef ) )
2303 {
2304 allUnits.emplace_back( candidateSymbol, path );
2305 }
2306 }
2307 }
2308
2309 for( auto& [ unit, path ] : allUnits )
2310 {
2311 // This needs to be done before the LIB_SYMBOL is changed to prevent stale
2312 // library symbols in the schematic file.
2313 path.LastScreen()->Remove( unit );
2314
2315 if( !unit->IsNew() )
2316 commit.Modify( unit, path.LastScreen() );
2317
2318 unit->SetLibSymbol( aSymbol.Flatten().release() );
2319 unit->UpdateFields( &GetCurrentSheet(),
2320 true, /* update style */
2321 true, /* update ref */
2322 true, /* update other fields */
2323 false, /* reset ref */
2324 false /* reset other fields */ );
2325
2326 path.LastScreen()->Append( unit );
2327 GetCanvas()->GetView()->Update( unit );
2328 }
2329
2330 if( !commit.Empty() )
2331 commit.Push( _( "Save Symbol to Schematic" ) );
2332}
2333
2334
2335void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2336{
2337 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2338
2339 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
2340 sch_item->ClearCaches();
2341}
2342
2343
2345{
2346 wxCHECK( m_toolManager, /* void */ );
2347
2351
2352 wxCHECK( screen, /* void */ );
2353
2355
2356 SCH_BASE_FRAME::SetScreen( screen );
2357
2359
2360 // update the references, units, and intersheet-refs
2362
2363 // dangling state can also have changed if different units with different pin locations are
2364 // used
2368
2370
2371 wxCHECK( selectionTool, /* void */ );
2372
2373 auto visit =
2374 [&]( EDA_ITEM* item )
2375 {
2377 && !m_findReplaceData->findString.IsEmpty()
2378 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
2379 {
2380 item->SetForceVisible( true );
2381 selectionTool->BrightenItem( item );
2382 }
2383 else if( item->IsBrightened() )
2384 {
2385 item->SetForceVisible( false );
2386 selectionTool->UnbrightenItem( item );
2387 }
2388 };
2389
2390 for( SCH_ITEM* item : screen->Items() )
2391 {
2392 visit( item );
2393
2394 item->RunOnChildren(
2395 [&]( SCH_ITEM* aChild )
2396 {
2397 visit( aChild );
2398 } );
2399 }
2400
2401 if( !screen->m_zoomInitialized )
2402 {
2404 }
2405 else
2406 {
2407 // Set zoom to last used in this screen
2408 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
2409 GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
2410 }
2411
2412 updateTitle();
2413
2414 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
2415
2416 // Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
2418
2420
2421 wxCHECK( editTool, /* void */ );
2422
2424 editTool->UpdateNetHighlighting( dummy );
2425
2427
2429}
2430
2431
2433{
2434 if( !m_diffSymbolDialog )
2436 _( "Compare Symbol with Library" ) );
2437
2438 return m_diffSymbolDialog;
2439}
2440
2441
2442void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
2443{
2444 if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
2445 {
2446 m_diffSymbolDialog->Destroy();
2447 m_diffSymbolDialog = nullptr;
2448 }
2449}
2450
2451
2453{
2454 if( !m_ercDialog )
2455 m_ercDialog = new DIALOG_ERC( this );
2456
2457 return m_ercDialog;
2458}
2459
2460
2461void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
2462{
2463 if( m_ercDialog )
2464 {
2465 m_ercDialog->Destroy();
2466 m_ercDialog = nullptr;
2467 }
2468}
2469
2470
2472{
2475
2477}
2478
2479
2481{
2483 {
2484 m_symbolFieldsTableDialog->Destroy();
2485 m_symbolFieldsTableDialog = nullptr;
2486 }
2487}
2488
2489
2490void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
2491{
2492 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2493 aListener );
2494
2495 // Don't add duplicate listeners.
2496 if( it == m_schematicChangeListeners.end() )
2497 m_schematicChangeListeners.push_back( aListener );
2498}
2499
2500
2502{
2503 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2504 aListener );
2505
2506 // Don't add duplicate listeners.
2507 if( it != m_schematicChangeListeners.end() )
2508 m_schematicChangeListeners.erase( it );
2509}
2510
2511
2513{
2514 m_netNavigator = new wxTreeCtrl( this, wxID_ANY, wxPoint( 0, 0 ),
2515 FromDIP( wxSize( 160, 250 ) ),
2516 wxTR_DEFAULT_STYLE | wxNO_BORDER );
2517
2518 return m_netNavigator;
2519}
2520
2521
2522void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection,
2523 const NET_NAVIGATOR_ITEM_DATA* aSelection )
2524{
2525 bool refreshNetNavigator = aConnection != m_highlightedConn;
2526
2527 m_highlightedConn = aConnection;
2528
2529 if( refreshNetNavigator )
2530 RefreshNetNavigator( aSelection );
2531}
2532
2533
2535{
2536 if( m_netNavigator )
2537 {
2538 NET_NAVIGATOR_ITEM_DATA itemData;
2539 wxTreeItemId selection = m_netNavigator->GetSelection();
2540 bool refreshSelection = selection.IsOk() && ( selection != m_netNavigator->GetRootItem() );
2541
2542 if( refreshSelection )
2543 {
2545 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
2546
2547 wxCHECK( tmp, /* void */ );
2548 itemData = *tmp;
2549 }
2550
2551 m_netNavigator->DeleteAllItems();
2552 RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
2553 }
2554
2556}
2557
2558
2560{
2561 wxAuiPaneInfo& hierarchyPane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2562 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
2563 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
2564 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
2565
2566 // Don't give the selection filter its own visibility controls; instead show it if
2567 // anything else is visible
2568 bool showFilter = ( hierarchyPane.IsShown() && hierarchyPane.IsDocked() )
2569 || ( netNavigatorPane.IsShown() && netNavigatorPane.IsDocked() )
2570 || ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
2571
2572 selectionFilterPane.Show( showFilter );
2573}
2574
2575#ifdef KICAD_IPC_API
2576void SCH_EDIT_FRAME::onPluginAvailabilityChanged( wxCommandEvent& aEvt )
2577{
2578 wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
2580 aEvt.Skip();
2581}
2582#endif
const KICOMMON_API wxEventTypeTag< wxCommandEvent > EDA_EVT_PLUGIN_AVAILABILITY_CHANGED
Notifies other parts of KiCad when plugin availability changes.
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
@ icon_eeschema
@ icon_eeschema_16
@ icon_eeschema_32
BOX2< VECTOR2I > BOX2I
Definition: box2.h:877
static TOOL_ACTION toggleGrid
Definition: actions.h:177
static TOOL_ACTION paste
Definition: actions.h:72
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION millimetersUnits
Definition: actions.h:185
static TOOL_ACTION unselectAll
Definition: actions.h:75
static TOOL_ACTION copy
Definition: actions.h:71
static TOOL_ACTION updateFind
Definition: actions.h:108
static TOOL_ACTION pasteSpecial
Definition: actions.h:73
static TOOL_ACTION milsUnits
Definition: actions.h:184
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:137
static TOOL_ACTION showSearch
Definition: actions.h:100
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION duplicate
Definition: actions.h:76
static TOOL_ACTION inchesUnits
Definition: actions.h:183
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:134
static TOOL_ACTION doDelete
Definition: actions.h:77
static TOOL_ACTION selectionTool
Definition: actions.h:192
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:126
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION deleteTool
Definition: actions.h:78
static TOOL_ACTION zoomTool
Definition: actions.h:129
static TOOL_ACTION showProperties
Definition: actions.h:206
static TOOL_ACTION cut
Definition: actions.h:70
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:178
static TOOL_ACTION selectAll
Definition: actions.h:74
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:172
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:623
COLOR4D GetColor(int aLayer) const
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
bool Empty() const
Returns status of an item.
Definition: commit.h:144
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
Definition: common_tools.h:38
Calculate the connectivity of a schematic and generates netlists.
const NET_MAP & GetNetMap() const
CONNECTION_SUBGRAPH * FindFirstSubgraphByName(const wxString &aNetName)
Retrieve a subgraph for the given net name, if one exists.
std::set< std::pair< SCH_SHEET_PATH, SCH_ITEM * > > ExtractAffectedItems(const std::set< SCH_ITEM * > &aItems)
For a set of items, this will remove the connected items and their associated data including subgraph...
void SetLastCodes(const CONNECTION_GRAPH *aOther)
void Merge(CONNECTION_GRAPH &aGraph)
Combine the input graph contents into the current graph.
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr)
Update the connection graph for the given list of sheets.
A subgraph is a set of items that are electrically connected on a single sheet.
wxArrayString GetFindEntries() const
wxArrayString GetReplaceEntries() const
void SetReplaceEntries(const wxArrayString &aEntries)
void SetFindEntries(const wxArrayString &aEntries, const wxString &aFindString)
bool Show(bool show) override
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
UNDO_REDO_CONTAINER m_undoList
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
SETTINGS_MANAGER * GetSettingsManager() const
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
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.
virtual int GetUndoCommandCount() const
wxString m_mruPath
wxArrayString m_replaceStringHistoryList
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
static const wxString PropertiesPaneName()
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
virtual void SetScreen(BASE_SCREEN *aScreen)
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
virtual void UpdateMsgPanel()
Redraw the message panel.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
wxArrayString m_findStringHistoryList
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
PROPERTIES_PANEL * m_propertiesPanel
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:250
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
void ClearBrightened()
Definition: eda_item.h:123
void SetBrightened()
Definition: eda_item.h:120
bool IsBrightened() const
Definition: eda_item.h:112
Specialization of the wxAuiPaneInfo class for KiCad panels.
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:279
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:79
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
virtual void ClearBoundingBoxCache()
Definition: eda_text.cpp:504
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:126
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:170
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
static TOOL_ACTION toggleAnnotateAuto
Definition: ee_actions.h:267
static TOOL_ACTION lineMode90
Definition: ee_actions.h:262
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:233
static TOOL_ACTION drawTable
Definition: ee_actions.h:99
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:257
static TOOL_ACTION toggleERCWarnings
Definition: ee_actions.h:238
static TOOL_ACTION drawRuleArea
Definition: ee_actions.h:107
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:240
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:101
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:125
static TOOL_ACTION lineModeFree
Definition: ee_actions.h:261
static TOOL_ACTION drawBus
Definition: ee_actions.h:82
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:239
static TOOL_ACTION placePower
Definition: ee_actions.h:80
static TOOL_ACTION placeSheetPin
Definition: ee_actions.h:92
static TOOL_ACTION drawLines
Definition: ee_actions.h:103
static TOOL_ACTION toggleOPCurrents
Definition: ee_actions.h:243
static TOOL_ACTION mirrorH
Definition: ee_actions.h:127
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:294
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:293
static TOOL_ACTION syncSheetPins
Definition: ee_actions.h:94
static TOOL_ACTION rotateCW
Definition: ee_actions.h:124
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:219
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:234
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:89
static TOOL_ACTION ddAppendFile
Definition: ee_actions.h:298
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:90
static TOOL_ACTION drawTextBox
Definition: ee_actions.h:98
static TOOL_ACTION showNetNavigator
Definition: ee_actions.h:295
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:100
static TOOL_ACTION placeImage
Definition: ee_actions.h:104
static TOOL_ACTION toggleDirectiveLabels
Definition: ee_actions.h:237
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:225
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:97
static TOOL_ACTION toggleOPVoltages
Definition: ee_actions.h:242
static TOOL_ACTION drawArc
Definition: ee_actions.h:102
static TOOL_ACTION lineMode45
Definition: ee_actions.h:263
static TOOL_ACTION drawSheet
Definition: ee_actions.h:91
static TOOL_ACTION markSimExclusions
Definition: ee_actions.h:241
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 placeNoConnect
Definition: ee_actions.h:84
Tool that displays edit points allowing to modify items by dragging the points.
bool empty() const
Definition: sch_rtree.h:176
EE_TYPE Overlapping(const BOX2I &aRect) const
Definition: sch_rtree.h:243
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
SEVERITY GetSeverity(int aErrorCode) const
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
void UpdateLabelsHierarchyTree()
Update the labels of the hierarchical tree of the schematic.
void UpdateHierarchySelection()
Updates the tree's selection to match current page.
void UpdateHierarchyTree()
Update the hierarchical tree of the schematic.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
wxColour ToColour() const
Definition: color4d.cpp:220
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:68
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: sch_view.h:103
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Set the scaling factor, zooming around a given anchor point.
Definition: sch_view.cpp:75
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
double GetScale() const
Definition: view.h:277
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:1687
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:401
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:221
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:613
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:1573
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:65
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:717
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:406
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:470
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:527
Define a library symbol object.
Definition: lib_symbol.h:78
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:304
Tree view item data for the net navigator.
A singleton reporter that reports to nowhere.
Definition: reporter.h:223
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:162
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:153
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
A holder to handle information on schematic or board items.
UNDO_REDO GetPickedItemStatus(unsigned int aIdx) const
EDA_ITEM * GetPickedItemLink(unsigned int aIdx) const
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:49
void Stop()
Save the time when this function was called, and set the counter stane to stop.
Definition: profile.h:88
double msecs(bool aSinceLast=false)
Definition: profile.h:149
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:129
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:135
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
Definition: project.cpp:320
Action handler for the Properties panel.
These are loaded from Eeschema settings but then overwritten by the project settings.
Holds all the data relating to one schematic.
Definition: schematic.h:76
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:138
CONNECTION_GRAPH * m_connectionGraph
Holds and calculates connectivity information of this schematic.
Definition: schematic.h:350
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:144
void OnSchSheetChanged()
Notify the schematic and its listeners that the current sheet has been changed.
Definition: schematic.cpp:780
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
Definition: schematic.cpp:714
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:291
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:297
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:154
SCH_SHEET_LIST BuildUnorderedSheetList() const
Definition: schematic.h:101
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:149
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Definition: schematic.h:108
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:194
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:164
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:207
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:669
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:129
void RemoveAllListeners()
Remove all listeners.
Definition: schematic.cpp:805
SCH_SHEET & Root() const
Definition: schematic.h:113
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const override
Definition: schematic.h:96
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:640
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:304
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_RENDER_SETTINGS * GetRenderSettings()
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
PANEL_SCH_SELECTION_FILTER * m_selectionFilterPanel
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:406
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)
void updateSelectionFilterVisbility() override
Selection filter panel doesn't have a dedicated visibility control, so show it if any other AUI panel...
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 UpdateHierarchyNavigator(bool aRefreshNetNavigator=true)
Update the hierarchy navigation tree and history.
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.
void ClearRepeatItemsList()
Clear the list of items which are to be repeated with the insert key.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
void UpdateLabelsHierarchyNavigator()
Update the hierarchy navigation tree labels.
void OnImportProject(wxCommandEvent &event)
static const wxString SchematicHierarchyPaneName()
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void RemoveSchematicChangeListener(wxEvtHandler *aListener)
Remove aListener to from the schematic changed listener list.
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
int GetSchematicJunctionSize()
void DisplayCurrentSheet()
Draw the current sheet on the display.
~SCH_EDIT_FRAME() override
const wxString & GetHighlightedConnection() const
DIALOG_ERC * m_ercDialog
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
void UpdateNetHighlightStatus()
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
DIALOG_SCH_FIND * m_findReplaceDialog
void 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 ReCreateHToolbar() override
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:51
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:166
virtual bool IsConnectable() const
Definition: sch_item.h:449
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:568
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:221
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:131
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:1429
SPIN_STYLE GetSpinStyle() const
Definition: sch_label.cpp:383
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_label.cpp:614
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:201
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Definition: sch_label.cpp:348
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:41
void SetOperatingPoint(const wxString &aText)
Definition: sch_line.h:310
bool IsWire() const
Return true if the line is a wire.
Definition: sch_line.cpp:976
double GetLength() const
Definition: sch_line.cpp:242
const wxString & GetOperatingPoint() const
Definition: sch_line.h:309
Handle actions specific to the schematic editor.
void SetOperatingPoint(const wxString &aText)
Definition: sch_pin.h:284
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the EDA_SHAPE.
void ResetDirectivesAndItems(KIGFX::SCH_VIEW *view)
Clears and resets items and directives attached to this rule area.
std::unordered_set< SCH_ITEM * > GetPastAndPresentContainedItems() const
Fetches all items which were, or are, within the rule area.
static std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > UpdateRuleAreasInScreens(std::unordered_set< SCH_SCREEN * > &screens, KIGFX::SCH_VIEW *view)
Updates all rule area connectvity / caches in the given sheet paths.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:710
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:130
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:277
void TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr, std::function< void(SCH_ITEM *)> *aChangedHandler=nullptr) const
Test all of the connectable objects in the schematic for unused connection points.
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:480
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:634
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:108
const wxString & GetFileName() const
Definition: sch_screen.h:143
const KIID & GetUuid() const
Definition: sch_screen.h:531
void Print(const SCH_RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
Definition: sch_screen.cpp:965
bool IsReadOnly() const
Definition: sch_screen.h:146
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:659
bool FileExists() const
Definition: sch_screen.h:149
SPIN_STYLE GetLabelOrientationForPoint(const VECTOR2I &aPosition, SPIN_STYLE aDefaultOrientation, const SCH_SHEET_PATH *aSheet) const
Definition: sch_screen.cpp:514
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()
bool GetExcludedFromSim() const
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:172
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:181
Schematic symbol object.
Definition: sch_symbol.h:106
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
Definition: sch_symbol.cpp:810
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:934
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Definition: sch_symbol.cpp:735
VECTOR2I GetPosition() const override
Definition: sch_text.h:141
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:172
int Size() const
Returns the number of selected parts.
Definition: selection.h:116
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
bool CollideEdge(const VECTOR2I &aPoint, VERTEX_INDEX *aClosestVertex=nullptr, int aClearance=0) const
Check whether aPoint collides with any edge of any of the contours of the polygon.
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
const SPICE_GENERATOR & SpiceGenerator() const
Definition: sim_model.h:435
std::vector< std::reference_wrapper< const SIM_MODEL_PIN > > GetPins() const
Definition: sim_model.cpp:739
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.
bool GetExcludedFromSim() const override
Definition: symbol.h:136
void AddTemplateFieldNames(const wxString &aSerializedFieldNames)
Add a serialized list of template field names.
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:169
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:168
@ REDRAW
Full drawing refresh.
Definition: tool_base.h:83
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition: tool_base.h:80
Generic, UI-independent tool event.
Definition: tool_event.h:167
Master controller class:
Definition: tool_manager.h:62
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:150
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:302
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:235
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:304
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:190
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: wx_infobar.cpp:294
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:424
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
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:130
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 & defaultSchSelectionFilterPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultPropertiesPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultNetNavigatorPaneInfo()
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
KiCad executable names.
const wxString PCBNEW_EXE
@ FRAME_PCB_EDITOR
Definition: frame_type.h:42
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SCH
Definition: frame_type.h:34
@ FRAME_SIMULATOR
Definition: frame_type.h:38
@ FRAME_CVPCB
Definition: frame_type.h:52
@ FRAME_SYMBOL_CHOOSER
Definition: frame_type.h:37
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition: gestfich.cpp:139
static const std::string NetlistFileExtension
static const std::string LegacyPcbFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string AutoSaveFilePrefix
static wxString LegacySchematicFileWildcard()
static wxString AllSchematicFilesWildcard()
static wxString KiCadSchematicFileWildcard()
const wxChar *const traceApi
Flag to enable debug output related to the API plugin system.
@ 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:595
KIID niluuid(0)
#define KICTL_CREATE
caller thinks requested project files may not exist.
Definition: kiway_player.h:76
@ LAYER_ERC_WARN
Definition: layer_ids.h:384
@ LAYER_ERC_EXCLUSION
Definition: layer_ids.h:386
@ LAYER_ERC_ERR
Definition: layer_ids.h:385
@ LAYER_OP_CURRENTS
Definition: layer_ids.h:404
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:392
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:368
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:403
@ 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: unix/app.cpp:90
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: unix/app.cpp:79
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
SEVERITY
#define DIFF_SYMBOLS_DIALOG_NAME
wxDEFINE_EVENT(EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent)
#define CURRENT_TOOL(action)
SCH_CLEANUP_FLAGS
@ LOCAL_CLEANUP
@ GLOBAL_CLEANUP
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
const double IU_PER_MILS
Definition: base_units.h:77
The EE_TYPE struct provides a type-specific auto-range iterator to the RTree.
Definition: sch_rtree.h:192
std::string refName
Definition for symbol library class.
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ SCH_LINE_T
Definition: typeinfo.h:163
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:171
@ SCH_LABEL_T
Definition: typeinfo.h:167
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_RULE_AREA_T
Definition: typeinfo.h:170
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:173
@ SCH_TEXT_T
Definition: typeinfo.h:151
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:168
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:673
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.