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 <core/ignore.h>
44#include <invoke_sch_dialog.h>
45#include <string_utils.h>
46#include <kiface_base.h>
47#include <kiplatform/app.h>
48#include <kiway.h>
49#include <symbol_edit_frame.h>
50#include <symbol_viewer_frame.h>
51#include <pgm_base.h>
52#include <core/profile.h>
55#include <python_scripting.h>
56#include <sch_edit_frame.h>
58#include <sch_painter.h>
59#include <sch_sheet.h>
60#include <sch_marker.h>
61#include <sch_sheet_pin.h>
62#include <schematic.h>
63#include <sch_commit.h>
64#include <sch_rule_area.h>
66#include <advanced_config.h>
67#include <sim/simulator_frame.h>
68#include <tool/action_manager.h>
69#include <tool/action_toolbar.h>
70#include <tool/common_control.h>
71#include <tool/common_tools.h>
72#include <tool/picker_tool.h>
74#include <tool/selection.h>
76#include <tool/tool_manager.h>
77#include <tool/zoom_tool.h>
78#include <tools/ee_actions.h>
83#include <tools/sch_edit_tool.h>
88#include <tools/sch_move_tool.h>
91#include <unordered_set>
92#include <view/view_controls.h>
93#include <widgets/wx_infobar.h>
98#include <wx/cmdline.h>
99#include <wx/app.h>
100#include <wx/filedlg.h>
101#include <wx/socket.h>
103#include <widgets/wx_aui_utils.h>
105
106#ifdef KICAD_IPC_API
108#endif
109
110
111#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
112
113
114BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
117
118 EVT_SIZE( SCH_EDIT_FRAME::OnSize )
119
122
125
126 EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
127 EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
128
129 // Drop files event
130 EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
131END_EVENT_TABLE()
132
133
134wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
135wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
136
137
138SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
139 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
141 m_ercDialog( nullptr ),
142 m_diffSymbolDialog( nullptr ),
143 m_symbolFieldsTableDialog( nullptr ),
144 m_netNavigator( nullptr ),
145 m_highlightedConnChanged( false )
146{
147 m_maximizeByDefault = true;
148 m_schematic = new SCHEMATIC( nullptr );
149
150 m_showBorderAndTitleBlock = true; // true to show sheet references
151 m_supportsAutoSave = true;
152 m_syncingPcbToSchSelection = false;
153 m_aboutTitle = _HKI( "KiCad Schematic Editor" );
154 m_show_search = false;
155
156 m_findReplaceDialog = nullptr;
157
158 m_findReplaceData = std::make_unique<SCH_SEARCH_DATA>();
159
160 // Give an icon
161 wxIcon icon;
162 wxIconBundle icon_bundle;
163
164 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 48 ) );
165 icon_bundle.AddIcon( icon );
166 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 128 ) );
167 icon_bundle.AddIcon( icon );
168 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 256 ) );
169 icon_bundle.AddIcon( icon );
170 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
171 icon_bundle.AddIcon( icon );
172 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
173 icon_bundle.AddIcon( icon );
174
175 SetIcons( icon_bundle );
176
177 LoadSettings( eeconfig() );
178
179 // NB: also links the schematic to the loaded project
180 CreateScreens();
181 SetCurrentSheet( Schematic().GetSheets()[0] );
182
183 setupTools();
184 setupUIConditions();
185 ReCreateMenuBar();
186 ReCreateHToolbar();
187 ReCreateVToolbar();
188 ReCreateOptToolbar();
189
190#ifdef KICAD_IPC_API
192 [&]( wxCommandEvent& aEvt )
193 {
194 wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
195 ReCreateHToolbar();
196 aEvt.Skip();
197 } );
198#endif
199
200 m_hierarchy = new HIERARCHY_PANE( this );
201
202 // Initialize common print setup dialog settings.
203 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
204 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
205 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
206 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
207
208 m_searchPane = new SCH_SEARCH_PANE( this );
209 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
210
211 m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
212
213 m_selectionFilterPanel = new PANEL_SCH_SELECTION_FILTER( this );
214
215 m_auimgr.SetManagedWindow( this );
216
217 CreateInfoBar();
218
219 // Rows; layers 4 - 6
220 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxS( "MainToolbar" ) )
221 .Top().Layer( 6 ) );
222
223 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
224 .Bottom().Layer( 6 ) );
225
226 // Columns; layers 1 - 3
227 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
228 .Caption( _( "Schematic Hierarchy" ) )
229 .Left().Layer( 3 ).Position( 1 )
230 .TopDockable( false )
231 .BottomDockable( false )
232 .CloseButton( false )
233 .MinSize( FromDIP( wxSize( 120, 60 ) ) )
234 .BestSize( FromDIP( wxSize( 200, 200 ) ) )
235 .FloatingSize( FromDIP( wxSize( 200, 200 ) ) )
236 .FloatingPosition( FromDIP( wxPoint( 50, 50 ) ) )
237 .Show( false ) );
238
239 m_auimgr.AddPane( m_propertiesPanel, defaultPropertiesPaneInfo( this ) );
240 m_auimgr.AddPane( m_selectionFilterPanel, defaultSchSelectionFilterPaneInfo( this ) );
241
242 m_auimgr.AddPane( createHighlightedNetNavigator(), defaultNetNavigatorPaneInfo() );
243
244 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( wxS( "OptToolbar" ) )
245 .Left().Layer( 2 ) );
246
247 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( wxS( "ToolsToolbar" ) )
248 .Right().Layer( 2 ) );
249
250 // Center
251 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
252 .Center() );
253
254 m_auimgr.AddPane( m_searchPane, EDA_PANE()
255 .Name( SearchPaneName() )
256 .Bottom()
257 .Caption( _( "Search" ) )
258 .PaneBorder( false )
259 .MinSize( FromDIP( wxSize( 180, 60 ) ) )
260 .BestSize( FromDIP( wxSize( 180, 100 ) ) )
261 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
262 .CloseButton( false )
263 .DestroyOnClose( false )
264 .Show( m_show_search ) );
265
266 FinishAUIInitialization();
267
268 resolveCanvasType();
269 SwitchCanvas( m_canvasType );
270
271 GetCanvas()->GetGAL()->SetAxesEnabled( false );
272
273 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
274 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
275
276 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
277 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
278 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
279 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
280 EESCHEMA_SETTINGS* cfg = eeconfig();
281
282 hierarchy_pane.Show( cfg->m_AuiPanels.show_schematic_hierarchy );
283 netNavigatorPane.Show( cfg->m_AuiPanels.show_net_nav_panel );
284 propertiesPane.Show( cfg->m_AuiPanels.show_properties );
285 updateSelectionFilterVisbility();
286
287 // The selection filter doesn't need to grow in the vertical direction when docked
288 selectionFilterPane.dock_proportion = 0;
289
292 {
293 // Show at end, after positioning
294 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
296 }
297
298 if( cfg->m_AuiPanels.net_nav_panel_float_size.GetWidth() > 0
299 && cfg->m_AuiPanels.net_nav_panel_float_size.GetHeight() > 0 )
300 {
301 netNavigatorPane.FloatingSize( cfg->m_AuiPanels.net_nav_panel_float_size );
302 netNavigatorPane.FloatingPosition( cfg->m_AuiPanels.net_nav_panel_float_pos );
303 }
304
306 SetAuiPaneSize( m_auimgr, propertiesPane, cfg->m_AuiPanels.properties_panel_width, -1 );
307
309 hierarchy_pane.Float();
310
312 && ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
313 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
314 {
315 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
316 searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
317 SetAuiPaneSize( m_auimgr, searchPane, -1, cfg->m_AuiPanels.search_panel_height );
318 }
319
320 else if( cfg->m_AuiPanels.search_panel_width > 0
321 && ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
322 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
323 {
324 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
325 searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
326 SetAuiPaneSize( m_auimgr, searchPane, cfg->m_AuiPanels.search_panel_width, -1 );
327 }
328
330 netNavigatorPane.Float();
331
333 {
334 // If the net navigator is not show, let the hierarchy navigator take all of the vertical
335 // space.
337 {
338 SetAuiPaneSize( m_auimgr, hierarchy_pane,
340 }
341 else
342 {
343 SetAuiPaneSize( m_auimgr, hierarchy_pane,
346
347 SetAuiPaneSize( m_auimgr, netNavigatorPane,
349 cfg->m_AuiPanels.net_nav_panel_docked_size.GetHeight() );
350 }
351
352 // wxAUI hack: force width by setting MinSize() and then Fixed()
353 // thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
354 hierarchy_pane.MinSize( cfg->m_AuiPanels.hierarchy_panel_docked_width, 60 );
355 hierarchy_pane.Fixed();
356 netNavigatorPane.MinSize( cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth(), 60 );
357 netNavigatorPane.Fixed();
358 m_auimgr.Update();
359
360 // now make it resizable again
361 hierarchy_pane.Resizable();
362 netNavigatorPane.Resizable();
363 m_auimgr.Update();
364
365 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
366 // back to minimum.
367 hierarchy_pane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
368 netNavigatorPane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
369 }
370 else
371 {
372 m_auimgr.Update();
373 }
374
375 LoadProjectSettings();
376
382
383 initScreenZoom();
384
385 m_hierarchy->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
386 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
387 this );
388 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
389 m_netNavigator->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onResizeNetNavigator, this );
390
391 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
392 // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
393 Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
394
395 setupUnits( eeconfig() );
396
397 // Net list generator
398 DefaultExecFlags();
399
400 updateTitle();
401 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
402
403#ifdef KICAD_IPC_API
404 m_apiHandler = std::make_unique<API_HANDLER_SCH>( this );
405 Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
406#endif
407
408 // Default shutdown reason until a file is loaded
409 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
410
411 // Init for dropping files
413 DragAcceptFiles( true );
414
415 // Ensure the window is on top
416 Raise();
417
418 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
419 // top-left corner of the canvas
420 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
421 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
422
423 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
424 Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
425 Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog,
426 this );
427}
428
429
431{
432 m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
433
434 // Ensure m_canvasType is up to date, to save it in config
436
437 SetScreen( nullptr );
438
439 if( m_schematic )
441
442 delete m_schematic;
443 m_schematic = nullptr;
444
445 // Close the project if we are standalone, so it gets cleaned up properly
446 if( Kiface().IsSingle() )
447 {
448 try
449 {
450 GetSettingsManager()->UnloadProject( &Prj(), false );
451 }
452 catch( const nlohmann::detail::type_error& exc )
453 {
454 // This may be overkill and could be an assertion but we are more likely to
455 // find any settings manager errors this way.
456 wxLogError( wxT( "Settings exception '%s' occurred." ), exc.what() );
457 }
458 }
459
460 delete m_hierarchy;
462}
463
464
466{
467 aEvent.Skip();
468
469 // Called when resizing the Hierarchy Navigator panel
470 // Store the current pane size
471 // It allows to retrieve the last defined pane size when switching between
472 // docked and floating pane state
473 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
474
475 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
476 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
477
478 if( cfg && m_hierarchy->IsShownOnScreen() )
479 {
480 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
481 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
482
483 // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
484 // width is > 0 (i.e. if its size is already set and has meaning)
485 // if it is floating, its size is not initialized (only floating_size is initialized)
486 // initializing hierarchy_pane.best_size is useful when switching to float pane and
487 // after switching to the docked pane, to retrieve the last docked pane width
488 if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
489 {
490 cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
491 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
492 }
493 }
494}
495
496
498{
499 // Create the manager and dispatcher & route draw panel events to the dispatcher
502 GetCanvas()->GetViewControls(), config(), this );
503 m_actions = new EE_ACTIONS();
505
506 // Register tools
524
525 // Run the selection tool, it is supposed to be always active
527
529}
530
531
533{
535
537 SCH_EDITOR_CONDITIONS cond( this );
538
539 wxASSERT( mgr );
540
541 auto hasElements =
542 [ this ] ( const SELECTION& aSel )
543 {
544 return GetScreen() &&
545 ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
546 };
547
548 auto searchPaneCond =
549 [this] ( const SELECTION& )
550 {
551 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
552 };
553
554 auto propertiesCond =
555 [this] ( const SELECTION& )
556 {
557 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
558 };
559
560 auto hierarchyNavigatorCond =
561 [ this ] ( const SELECTION& aSel )
562 {
563 return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
564 };
565
566 auto netNavigatorCond =
567 [ this ] (const SELECTION& aSel )
568 {
569 return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
570 };
571
572 auto undoCond =
573 [ this ] (const SELECTION& aSel )
574 {
576 return true;
577
578 return GetUndoCommandCount() > 0;
579 };
580
581#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
582#define CHECK( x ) ACTION_CONDITIONS().Check( x )
583
585 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
587
588 mgr->SetConditions( EE_ACTIONS::showSearch, CHECK( searchPaneCond ) );
589 mgr->SetConditions( EE_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
590 mgr->SetConditions( EE_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
591 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
596 CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
597 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
598 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
599
601 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_FREE ) ) );
603 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_90 ) ) );
605 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_45 ) ) );
606
607 mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
608 mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
611 mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
612 mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
613 mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
614 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
615
616 mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( hasElements ) );
617 mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( hasElements ) );
618 mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( hasElements ) );
619 mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( hasElements ) );
620
625
626 if( SCRIPTING::IsWxAvailable() )
627 {
629 CHECK( cond.ScriptingConsoleVisible() ) );
630 }
631
632 auto showHiddenPinsCond =
633 [this]( const SELECTION& )
634 {
635 return GetShowAllPins();
636 };
637
638 auto showHiddenFieldsCond =
639 [this]( const SELECTION& )
640 {
642 return cfg && cfg->m_Appearance.show_hidden_fields;
643 };
644
645 auto showDirectiveLabelsCond =
646 [this]( const SELECTION& )
647 {
649 return cfg && cfg->m_Appearance.show_directive_labels;
650 };
651
652 auto showERCErrorsCond =
653 [this]( const SELECTION& )
654 {
656 return cfg && cfg->m_Appearance.show_erc_errors;
657 };
658
659 auto showERCWarningsCond =
660 [this]( const SELECTION& )
661 {
663 return cfg && cfg->m_Appearance.show_erc_warnings;
664 };
665
666 auto showERCExclusionsCond =
667 [this]( const SELECTION& )
668 {
670 return cfg && cfg->m_Appearance.show_erc_exclusions;
671 };
672
673 auto showOPVoltagesCond =
674 [this]( const SELECTION& )
675 {
677 return cfg && cfg->m_Appearance.show_op_voltages;
678 };
679
680 auto showOPCurrentsCond =
681 [this]( const SELECTION& )
682 {
684 return cfg && cfg->m_Appearance.show_op_currents;
685 };
686
687 auto showAnnotateAutomaticallyCond =
688 [this]( const SELECTION& )
689 {
691 return cfg && cfg->m_AnnotatePanel.automatic;
692 };
693
694 auto remapSymbolsCondition =
695 [&]( const SELECTION& aSel )
696 {
697 SCH_SCREENS schematic( Schematic().Root() );
698
699 // The remapping can only be performed on legacy projects.
700 return schematic.HasNoFullyDefinedLibIds();
701 };
702
703 auto belowRootSheetCondition =
704 [this]( const SELECTION& aSel )
705 {
707 return navigateTool && navigateTool->CanGoUp();
708 };
709
710 auto navSchematicHasPreviousSheet =
711 [this]( const SELECTION& aSel )
712 {
714 return navigateTool && navigateTool->CanGoPrevious();
715 };
716
717 auto navSchematicHasNextSheet =
718 [this]( const SELECTION& aSel )
719 {
721 return navigateTool && navigateTool->CanGoNext();
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::navigatePrevious, ENABLE( navSchematicHasPreviousSheet ) );
735 mgr->SetConditions( EE_ACTIONS::navigateNext, ENABLE( navSchematicHasNextSheet ) );
736 mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
737 mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
738 mgr->SetConditions( EE_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
739 mgr->SetConditions( EE_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
740 mgr->SetConditions( EE_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
741 mgr->SetConditions( EE_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
742 mgr->SetConditions( EE_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
743 mgr->SetConditions( EE_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
744 mgr->SetConditions( EE_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
745 mgr->SetConditions( EE_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
747
748#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
749
775
776#undef CURRENT_TOOL
777#undef CHECK
778#undef ENABLE
779}
780
781
783{
784 // we cannot store a pointer to an item in the display list here since
785 // that item may be deleted, such as part of a line concatenation or other.
786 // So simply always keep a copy of the object which is to be repeated.
787
788 if( aItem )
789 {
790 m_items_to_repeat.clear();
791
792 AddCopyForRepeatItem( aItem );
793 }
794}
795
796
798{
799 // we cannot store a pointer to an item in the display list here since
800 // that item may be deleted, such as part of a line concatenation or other.
801 // So simply always keep a copy of the object which is to be repeated.
802
803 if( aItem )
804 {
805 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate() ) );
806
807 // Clone() preserves the flags, we want 'em cleared.
808 repeatItem->ClearFlags();
809
810 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
811 }
812}
813
814
816{
817 return Schematic().GetSheets().GetItem( aId );
818}
819
820
822{
824}
825
826
828{
829 return GetCurrentSheet().LastScreen();
830}
831
832
834{
835 return *m_schematic;
836}
837
838
840{
841 return GetCurrentSheet().Last()->GetName();
842}
843
844
846{
848}
849
850
852{
855
856 SCH_SHEET* rootSheet = new SCH_SHEET( m_schematic );
857 m_schematic->SetRoot( rootSheet );
858
859 SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
860 const_cast<KIID&>( rootSheet->m_Uuid ) = rootScreen->GetUuid();
861 m_schematic->Root().SetScreen( rootScreen );
862 SetScreen( Schematic().RootScreen() );
863
864
865 m_schematic->RootScreen()->SetFileName( wxEmptyString );
866
867 // Don't leave root page number empty
868 SCH_SHEET_PATH rootSheetPath;
869
870 rootSheetPath.push_back( rootSheet );
871 m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
872 rootSheetPath.SetPageNumber( wxT( "1" ) );
873
874 if( GetScreen() == nullptr )
875 {
876 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
877 SetScreen( screen );
878 }
879}
880
881
883{
884 return m_schematic->CurrentSheet();
885}
886
887
889{
890 if( aSheet != GetCurrentSheet() )
891 {
892 FocusOnItem( nullptr );
893
894 Schematic().SetCurrentSheet( aSheet );
895 GetCanvas()->DisplaySheet( aSheet.LastScreen() );
896 }
897}
898
899
901{
903
904 for( SCH_ITEM* item : screen->Items() )
905 item->ClearCaches();
906
907 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
908 {
909 wxCHECK2( libSymbol.second, continue );
910 libSymbol.second->ClearCaches();
911 }
912
913 if( Schematic().Settings().m_IntersheetRefsShow )
915
916 FocusOnItem( nullptr );
917
918 GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
919
921 selectionTool->Reset( TOOL_BASE::REDRAW );
922
924}
925
926
927bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
928{
929 // Exit interactive editing
930 // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
931 // will cancel any drag currently in progress, but commit all changes from previous drags.
932 if( m_toolManager )
934
935 // Shutdown blocks must be determined and vetoed as early as possible
936 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
937 && Schematic().GetSheets().IsModified() )
938 {
939 return false;
940 }
941
942 if( Kiface().IsSingle() )
943 {
944 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
945
946 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
947 return false;
948
949 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
950
951 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
952 return false;
953
954 // SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
955 // sorry.
956 auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
957
958 if( chooser && !chooser->Close() ) // Can close symbol chooser?
959 return false;
960 }
961 else
962 {
963 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
964
965 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
966 {
967 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
968 return false;
969 }
970 }
971
972 if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
973 return false;
974
976 && !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
977 {
978 return false;
979 }
980
981 // We may have gotten multiple events; don't clean up twice
982 if( !Schematic().IsValid() )
983 return false;
984
985 SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
986
987 if( sheetlist.IsModified() )
988 {
989 wxFileName fileName = Schematic().RootScreen()->GetFileName();
990 wxString msg = _( "Save changes to '%s' before closing?" );
991
992 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
993 [&]() -> bool
994 {
995 return SaveProject();
996 } ) )
997 {
998 return false;
999 }
1000 }
1001
1002 return true;
1003}
1004
1005
1007{
1008 SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
1009
1010 // Shutdown all running tools
1011 if( m_toolManager )
1013
1014 // Close modeless dialogs. They're trouble when they get destroyed after the frame.
1015 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
1016 Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
1017 Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE,
1019 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
1020 this );
1021 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection,
1022 this );
1023
1024 // Close the find dialog and preserve its setting if it is displayed.
1026 {
1029
1030 m_findReplaceDialog->Destroy();
1031 m_findReplaceDialog = nullptr;
1032 }
1033
1034 if( m_diffSymbolDialog )
1035 {
1036 m_diffSymbolDialog->Destroy();
1037 m_diffSymbolDialog = nullptr;
1038 }
1039
1040 if( m_ercDialog )
1041 {
1042 m_ercDialog->Destroy();
1043 m_ercDialog = nullptr;
1044 }
1045
1047 {
1048 m_symbolFieldsTableDialog->Destroy();
1049 m_symbolFieldsTableDialog = nullptr;
1050 }
1051
1052 // Make sure local settings are persisted
1054
1055 // Shutdown all running tools
1056 if( m_toolManager )
1057 {
1059 // prevent the canvas from trying to dispatch events during close
1060 GetCanvas()->SetEventDispatcher( nullptr );
1061 delete m_toolManager;
1062 m_toolManager = nullptr;
1063 }
1064
1065 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
1066
1067 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
1068 {
1069 hierarchy_pane.Show( false );
1070 m_auimgr.Update();
1071 }
1072
1073 SCH_SCREENS screens( Schematic().Root() );
1074 wxFileName fn;
1075
1076 for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
1077 {
1078 fn = Prj().AbsolutePath( screen->GetFileName() );
1079
1080 // Auto save file name is the normal file name prepended with FILEEXT::AutoSaveFilePrefix.
1081 fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() );
1082
1083 if( fn.IsFileWritable() )
1084 wxRemoveFile( fn.GetFullPath() );
1085 }
1086
1087 wxFileName tmpFn = Prj().GetProjectFullName();
1088 wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
1089
1090 if( autoSaveFileName.IsFileWritable() )
1091 wxRemoveFile( autoSaveFileName.GetFullPath() );
1092
1093 sheetlist.ClearModifyStatus();
1094
1095 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
1096
1097 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
1098 UpdateFileHistory( fileName );
1099
1100 Schematic().RootScreen()->Clear();
1101
1102 // all sub sheets are deleted, only the main sheet is usable
1104
1105 // Clear view before destroying schematic as repaints depend on schematic being valid
1106 SetScreen( nullptr );
1107
1108 Schematic().Reset();
1109
1110 // Prevents any rogue events from continuing (i.e. search panel tries to redraw)
1111 Show( false );
1112
1113 Destroy();
1114}
1115
1116
1118{
1119 return Schematic().ErcSettings().GetSeverity( aErrorCode );
1120}
1121
1122
1124{
1126
1127 wxCHECK( GetScreen(), /* void */ );
1128
1130 m_autoSaveRequired = true;
1131
1132 GetCanvas()->Refresh();
1133
1134 if( !GetTitle().StartsWith( wxS( "*" ) ) )
1135 updateTitle();
1136}
1137
1138
1139void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
1140{
1141 if( Kiface().IsSingle() )
1142 {
1143 DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
1144 " in stand-alone mode. In order to create/update PCBs from"
1145 " schematics, launch the KiCad shell and create a project." ) );
1146 return;
1147 }
1148
1149 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1150
1151 if( !frame )
1152 {
1153 wxFileName fn = Prj().GetProjectFullName();
1154 fn.SetExt( FILEEXT::PcbFileExtension );
1155
1156 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1157
1158 // If Kiway() cannot create the Pcbnew frame, it shows a error message, and
1159 // frame is null
1160 if( !frame )
1161 return;
1162
1163 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1164 }
1165
1166 if( !frame->IsVisible() )
1167 frame->Show( true );
1168
1169 // On Windows, Raise() does not bring the window on screen, when iconized
1170 if( frame->IsIconized() )
1171 frame->Iconize( false );
1172
1173 frame->Raise();
1174
1175 std::string payload;
1177}
1178
1179
1180void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator )
1181{
1182 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
1184
1185 if( aRefreshNetNavigator )
1187}
1188
1189
1191{
1192 // Update only the hierarchy navigation tree labels.
1193 // The tree list is expectyed to be up to date
1195}
1196
1197
1199{
1201}
1202
1203
1205{
1206 wxString findString;
1207
1208 EE_SELECTION& selection = m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1209
1210 if( selection.Size() == 1 )
1211 {
1212 EDA_ITEM* front = selection.Front();
1213
1214 switch( front->Type() )
1215 {
1216 case SCH_SYMBOL_T:
1217 {
1218 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( front );
1219 findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() );
1220 break;
1221 }
1222
1223 case SCH_FIELD_T:
1224 findString = UnescapeString( static_cast<SCH_FIELD*>( front )->GetText() );
1225 break;
1226
1227 case SCH_LABEL_T:
1228 case SCH_GLOBAL_LABEL_T:
1229 case SCH_HIER_LABEL_T:
1230 case SCH_SHEET_PIN_T:
1231 findString = UnescapeString( static_cast<SCH_LABEL_BASE*>( front )->GetText() );
1232 break;
1233
1234 case SCH_TEXT_T:
1235 findString = UnescapeString( static_cast<SCH_TEXT*>( front )->GetText() );
1236
1237 if( findString.Contains( wxT( "\n" ) ) )
1238 findString = findString.Before( '\n' );
1239
1240 break;
1241
1242 default:
1243 break;
1244 }
1245 }
1246
1248 m_findReplaceDialog->Destroy();
1249
1251 static_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() ),
1252 wxDefaultPosition, wxDefaultSize,
1253 aReplace ? wxFR_REPLACEDIALOG : 0 );
1254
1257 m_findReplaceDialog->Show( true );
1258}
1259
1260
1261void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
1262{
1263 // Prepare the infobar, since we don't know its state
1266
1267 m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
1268}
1269
1270
1272{
1273 m_infoBar->Dismiss();
1274}
1275
1276
1278{
1281
1282 m_findReplaceDialog->Destroy();
1283 m_findReplaceDialog = nullptr;
1284
1286}
1287
1288
1289void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1290{
1291 wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1292
1293 if( fn.size() )
1294 OpenProjectFiles( std::vector<wxString>( 1, fn ) );
1295}
1296
1297
1298void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
1299{
1301}
1302
1303
1305{
1306 // Only standalone mode can directly load a new document
1307 if( !Kiface().IsSingle() )
1308 return;
1309
1310 wxString pro_dir = m_mruPath;
1311
1312 wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
1314
1315 if( dlg.ShowModal() != wxID_CANCEL )
1316 {
1317 // Enforce the extension, wxFileDialog is inept.
1318 wxFileName create_me =
1320
1321 if( create_me.FileExists() )
1322 {
1323 wxString msg;
1324 msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
1325 DisplayError( this, msg );
1326 return ;
1327 }
1328
1329 // OpenProjectFiles() requires absolute
1330 wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
1331
1332 OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1333 m_mruPath = create_me.GetPath();
1334 }
1335}
1336
1337
1339{
1340 // Only standalone mode can directly load a new document
1341 if( !Kiface().IsSingle() )
1342 return;
1343
1344 wxString pro_dir = m_mruPath;
1345 wxString wildcards = FILEEXT::AllSchematicFilesWildcard()
1347 + wxS( "|" ) + FILEEXT::LegacySchematicFileWildcard();
1348
1349 wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
1350 wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1351
1352 if( dlg.ShowModal() != wxID_CANCEL )
1353 {
1354 OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1356 }
1357}
1358
1359
1360void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
1361{
1362 wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
1363
1364 if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
1365 {
1366 kicad_board.SetExt( FILEEXT::PcbFileExtension );
1367 wxFileName legacy_board( kicad_board );
1368 legacy_board.SetExt( FILEEXT::LegacyPcbFileExtension );
1369 wxFileName& boardfn = legacy_board;
1370
1371 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1372 boardfn = kicad_board;
1373
1374 if( Kiface().IsSingle() )
1375 {
1376 ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
1377 }
1378 else
1379 {
1380 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1381
1382 if( !frame )
1383 {
1384 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1385
1386 // frame can be null if Cvpcb cannot be run. No need to show a warning
1387 // Kiway() generates the error messages
1388 if( !frame )
1389 return;
1390
1391 frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1392 }
1393
1394 if( !frame->IsVisible() )
1395 frame->Show( true );
1396
1397 // On Windows, Raise() does not bring the window on screen, when iconized
1398 if( frame->IsIconized() )
1399 frame->Iconize( false );
1400
1401 frame->Raise();
1402 }
1403 }
1404 else
1405 {
1406 // If we are running inside a project, it should be impossible for this case to happen
1407 wxASSERT( Kiface().IsSingle() );
1409 }
1410}
1411
1412
1413void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1414{
1415 wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1416 fn.SetExt( FILEEXT::NetlistFileExtension );
1417
1418 if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1419 return;
1420
1421 try
1422 {
1423 KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1424
1425 if( !player )
1426 {
1427 player = Kiway().Player( FRAME_CVPCB, true );
1428
1429 // player can be null if Cvpcb cannot be run. No need to show a warning
1430 // Kiway() generates the error messages
1431 if( !player )
1432 return;
1433
1434 player->Show( true );
1435 }
1436
1437 // Ensure the netlist (mainly info about symbols) is up to date
1440
1441 player->Raise();
1442 }
1443 catch( const IO_ERROR& )
1444 {
1445 DisplayError( this, _( "Could not open CvPcb" ) );
1446 }
1447}
1448
1449
1450void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1451{
1452 if( event.GetId() == wxID_EXIT )
1453 Kiway().OnKiCadExit();
1454
1455 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1456 Close( false );
1457}
1458
1459
1461{
1462 wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1463 const SCH_RENDER_SETTINGS* cfg = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
1465
1466 cfg->GetPrintDC()->SetBackground( wxBrush( bg.ToColour() ) );
1467 cfg->GetPrintDC()->Clear();
1468
1469 cfg->GetPrintDC()->SetLogicalFunction( wxCOPY );
1470 GetScreen()->Print( cfg );
1471 PrintDrawingSheet( cfg, GetScreen(), Schematic().GetProperties(), schIUScale.IU_PER_MILS, fileName );
1472}
1473
1474
1476{
1478 SIM_LIB_MGR simLibMgr( &Prj() );
1479 NULL_REPORTER devnull;
1480
1481 // Patch for bug early in V7.99 dev
1482 if( settings.m_OPO_VRange.EndsWith( 'A' ) )
1483 settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
1484
1485 // Update items which may have ${OP} text variables
1486 //
1488 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1489 {
1490 int flags = 0;
1491
1492 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1493 {
1494 item->RunOnChildren(
1495 [&flags]( SCH_ITEM* aChild )
1496 {
1497 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild );
1498
1499 if( text && text->HasTextVars() )
1500 {
1501 text->ClearRenderCache();
1502 text->ClearBoundingBoxCache();
1503 flags |= KIGFX::GEOMETRY | KIGFX::REPAINT;
1504 }
1505 } );
1506
1507 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
1508
1509 if( text && text->HasTextVars() )
1510 {
1511 text->ClearRenderCache();
1512 text->ClearBoundingBoxCache();
1514 }
1515 }
1516
1517 return flags;
1518 } );
1519
1520 // Update OP overlay items
1521 //
1522 for( SCH_ITEM* item : GetScreen()->Items() )
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().name;
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 for( SCH_ITEM* item : subgraph->GetItems() )
1604 {
1605 if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T } ) )
1606 {
1607 SCH_LINE* wire = static_cast<SCH_LINE*>( item );
1608
1609 if( wire->GetLength() > length )
1610 {
1611 longestWire = wire;
1612 length = wire->GetLength();
1613 }
1614 }
1615 }
1616
1617 if( longestWire )
1618 {
1619 longestWire->SetOperatingPoint( op );
1620 GetCanvas()->GetView()->Update( longestWire );
1621 }
1622 }
1623 }
1624 }
1625}
1626
1627
1629{
1630 if( aItem->IsType( { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) )
1631 {
1632 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
1633
1634 if( label->AutoRotateOnPlacement() )
1635 {
1636 SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
1637 label->GetSpinStyle(),
1638 &GetCurrentSheet() );
1639
1640 if( spin != label->GetSpinStyle() )
1641 {
1642 label->SetSpinStyle( spin );
1643
1644 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1645 {
1646 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1647
1648 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1649 otherLabel->AutoplaceFields( aScreen, false );
1650 }
1651 }
1652 }
1653 }
1654}
1655
1656
1658{
1659 SCH_SCREEN* screen = GetScreen();
1660
1661 wxCHECK( screen, /* void */ );
1662
1663 wxString title;
1664
1665 if( !screen->GetFileName().IsEmpty() )
1666 {
1667 wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1668 bool readOnly = false;
1669 bool unsaved = false;
1670
1671 if( fn.IsOk() && screen->FileExists() )
1672 readOnly = screen->IsReadOnly();
1673 else
1674 unsaved = true;
1675
1676 if( IsContentModified() )
1677 title = wxT( "*" );
1678
1679 title += fn.GetName();
1680
1681 wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
1682
1683 if( sheetPath != title )
1684 title += wxString::Format( wxT( " [%s]" ), sheetPath );
1685
1686 if( readOnly )
1687 title += wxS( " " ) + _( "[Read Only]" );
1688
1689 if( unsaved )
1690 title += wxS( " " ) + _( "[Unsaved]" );
1691 }
1692 else
1693 {
1694 title = _( "[no schematic loaded]" );
1695 }
1696
1697 title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1698
1699 SetTitle( title );
1700}
1701
1702
1704{
1706 GetScreen()->m_zoomInitialized = true;
1707}
1708
1709
1711{
1712 wxString highlightedConn = GetHighlightedConnection();
1713 bool hasHighlightedConn = !highlightedConn.IsEmpty();
1714 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1716 SCH_COMMIT localCommit( m_toolManager );
1717
1718 if( !aCommit )
1719 aCommit = &localCommit;
1720
1721#ifdef PROFILE
1722 PROF_TIMER timer;
1723#endif
1724
1725 // Ensure schematic graph is accurate
1726 if( aCleanupFlags == LOCAL_CLEANUP )
1727 {
1728 SchematicCleanUp( aCommit, GetScreen() );
1729 }
1730 else if( aCleanupFlags == GLOBAL_CLEANUP )
1731 {
1732 for( const SCH_SHEET_PATH& sheet : list )
1733 SchematicCleanUp( aCommit, sheet.LastScreen() );
1734 }
1735
1736#ifdef PROFILE
1737 timer.Stop();
1738 wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1739#endif
1740
1741 if( settings.m_IntersheetRefsShow )
1743
1744 std::function<void( SCH_ITEM* )> changeHandler =
1745 [&]( SCH_ITEM* aChangedItem ) -> void
1746 {
1747 GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1748
1749 SCH_CONNECTION* connection = aChangedItem->Connection();
1750
1752 return;
1753
1754 if( !hasHighlightedConn )
1755 {
1756 // No highlighted connection, but connectivity has changed, so refresh
1757 // the list of all nets
1759 }
1760 else if( connection
1761 && ( connection->Name() == highlightedConn
1762 || connection->HasDriverChanged() ) )
1763 {
1765 }
1766 };
1767
1768 if( !ADVANCED_CFG::GetCfg().m_IncrementalConnectivity || aCleanupFlags == GLOBAL_CLEANUP
1769 || m_undoList.m_CommandsList.empty() )
1770 {
1771 // Update all rule areas so we can cascade implied connectivity changes
1772 std::unordered_set<SCH_SCREEN*> all_screens;
1773
1774 for( const SCH_SHEET_PATH& path : list )
1775 all_screens.insert( path.LastScreen() );
1776
1777 SCH_RULE_AREA::UpdateRuleAreasInScreens( all_screens, GetCanvas()->GetView() );
1778
1779 // Recalculate all connectivity
1780 Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
1781 }
1782 else
1783 {
1784 struct CHANGED_ITEM
1785 {
1786 SCH_ITEM* item;
1787 SCH_ITEM* linked_item;
1788 SCH_SCREEN* screen;
1789 };
1790
1791 PICKED_ITEMS_LIST* changed_list = m_undoList.m_CommandsList.back();
1792
1793 // Final change sets
1794 std::set<SCH_ITEM*> changed_items;
1795 std::set<VECTOR2I> pts;
1796 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> item_paths;
1797
1798 // Working change sets
1799 std::unordered_set<SCH_SCREEN*> changed_screens;
1800 std::set<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> changed_rule_areas;
1801 std::vector<CHANGED_ITEM> changed_connectable_items;
1802
1803 // Lambda to add an item to the connectivity update sets
1804 auto addItemToChangeSet = [&changed_items, &pts, &item_paths]( CHANGED_ITEM itemData )
1805 {
1806 SCH_SHEET_PATHS& paths = itemData.screen->GetClientSheetPaths();
1807
1808 std::vector<VECTOR2I> tmp_pts = itemData.item->GetConnectionPoints();
1809 pts.insert( tmp_pts.begin(), tmp_pts.end() );
1810 changed_items.insert( itemData.item );
1811
1812 for( SCH_SHEET_PATH& path : paths )
1813 item_paths.insert( std::make_pair( path, itemData.item ) );
1814
1815 if( !itemData.linked_item || !itemData.linked_item->IsConnectable() )
1816 return;
1817
1818 tmp_pts = itemData.linked_item->GetConnectionPoints();
1819 pts.insert( tmp_pts.begin(), tmp_pts.end() );
1820 changed_items.insert( itemData.linked_item );
1821
1822 // We have to directly add the pins here because the link may not exist on the schematic
1823 // anymore and so won't be picked up by GetScreen()->Items().Overlapping() below.
1824 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( itemData.linked_item ) )
1825 {
1826 std::vector<SCH_PIN*> pins = symbol->GetPins();
1827 changed_items.insert( pins.begin(), pins.end() );
1828 }
1829
1830 for( SCH_SHEET_PATH& path : paths )
1831 item_paths.insert( std::make_pair( path, itemData.linked_item ) );
1832 };
1833
1834 // Get all changed connectable items and determine all changed screens
1835 for( unsigned ii = 0; ii < changed_list->GetCount(); ++ii )
1836 {
1837 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItem( ii ) );
1838
1839 if( item )
1840 {
1841 SCH_SCREEN* screen =
1842 static_cast<SCH_SCREEN*>( changed_list->GetScreenForItem( ii ) );
1843 changed_screens.insert( screen );
1844
1845 if( item->Type() == SCH_RULE_AREA_T )
1846 {
1847 SCH_RULE_AREA* ruleArea = static_cast<SCH_RULE_AREA*>( item );
1848
1849 // Clear item and directive associations for this rule area
1850 ruleArea->ResetDirectivesAndItems( GetCanvas()->GetView() );
1851
1852 changed_rule_areas.insert( { ruleArea, screen } );
1853 }
1854 else if( item->IsConnectable() )
1855 {
1856 SCH_ITEM* linked_item =
1857 dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItemLink( ii ) );
1858 changed_connectable_items.push_back( { item, linked_item, screen } );
1859 }
1860 }
1861 }
1862
1863 // Update rule areas in changed screens to propagate any directive connectivity changes
1864 std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> forceUpdateRuleAreas =
1865 SCH_RULE_AREA::UpdateRuleAreasInScreens( changed_screens, GetCanvas()->GetView() );
1866
1867 std::for_each( forceUpdateRuleAreas.begin(), forceUpdateRuleAreas.end(),
1868 [&]( std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& updatedRuleArea )
1869 {
1870 changed_rule_areas.insert( updatedRuleArea );
1871 } );
1872
1873 // If a SCH_RULE_AREA was changed, we need to add all past and present contained items to
1874 // update their connectivity
1875 for( const std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& changedRuleArea : changed_rule_areas )
1876 {
1877 for( SCH_ITEM* containedItem :
1878 changedRuleArea.first->GetPastAndPresentContainedItems() )
1879 {
1880 addItemToChangeSet( { containedItem, nullptr, changedRuleArea.second } );
1881 }
1882 }
1883
1884 // Add all changed items, and associated items, to the change set
1885 for( CHANGED_ITEM& changed_item_data : changed_connectable_items )
1886 {
1887 addItemToChangeSet( changed_item_data );
1888
1889 // If a SCH_DIRECTIVE_LABEL was changed which is attached to a SCH_RULE_AREA, we need
1890 // to add the contained items to the change set to force update of their connectivity
1891 if( changed_item_data.item->Type() == SCH_DIRECTIVE_LABEL_T )
1892 {
1893 const std::vector<VECTOR2I> labelConnectionPoints =
1894 changed_item_data.item->GetConnectionPoints();
1895
1896 EE_RTREE::EE_TYPE candidateRuleAreas =
1897 changed_item_data.screen->Items().Overlapping(
1898 SCH_RULE_AREA_T, changed_item_data.item->GetBoundingBox() );
1899
1900 for( SCH_ITEM* candidateRuleArea : candidateRuleAreas )
1901 {
1902 SCH_RULE_AREA* ruleArea = static_cast<SCH_RULE_AREA*>( candidateRuleArea );
1903 std::vector<SHAPE*> borderShapes = ruleArea->MakeEffectiveShapes( true );
1904
1905 if( ruleArea->GetPolyShape().CollideEdge( labelConnectionPoints[0], nullptr,
1906 5 ) )
1907 {
1908 for( SCH_ITEM* containedItem : ruleArea->GetPastAndPresentContainedItems() )
1909 addItemToChangeSet(
1910 { containedItem, nullptr, changed_item_data.screen } );
1911 }
1912 }
1913 }
1914 }
1915
1916 for( const VECTOR2I& pt: pts )
1917 {
1918 for( SCH_ITEM* item : GetScreen()->Items().Overlapping( pt ) )
1919 {
1920 // Leave this check in place. Overlapping items are not necessarily connectable.
1921 if( !item->IsConnectable() )
1922 continue;
1923
1924 if( item->Type() == SCH_LINE_T )
1925 {
1926 if( item->HitTest( pt ) )
1927 changed_items.insert( item );
1928 }
1929 else if( item->Type() == SCH_SYMBOL_T && item->IsConnected( pt ) )
1930 {
1931 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1932 std::vector<SCH_PIN*> pins = symbol->GetPins();
1933
1934 changed_items.insert( pins.begin(), pins.end() );
1935 }
1936 else if( item->Type() == SCH_SHEET_T )
1937 {
1938 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1939
1940 wxCHECK2( sheet, continue );
1941
1942 std::vector<SCH_SHEET_PIN*> sheetPins = sheet->GetPins();
1943 changed_items.insert( sheetPins.begin(), sheetPins.end() );
1944 }
1945 else
1946 {
1947 if( item->IsConnected( pt ) )
1948 changed_items.insert( item );
1949 }
1950 }
1951 }
1952
1953 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> all_items =
1954 Schematic().ConnectionGraph()->ExtractAffectedItems( changed_items );
1955
1956 all_items.insert( item_paths.begin(), item_paths.end() );
1957
1958 CONNECTION_GRAPH new_graph( &Schematic() );
1959
1960 new_graph.SetLastCodes( Schematic().ConnectionGraph() );
1961
1962 for( auto&[ path, item ] : all_items )
1963 {
1964 wxCHECK2( item, continue );
1965 item->SetConnectivityDirty();
1966 }
1967
1968 new_graph.Recalculate( list, false, &changeHandler );
1969 Schematic().ConnectionGraph()->Merge( new_graph );
1970 }
1971
1973 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1974 {
1975 int flags = 0;
1976 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
1977 SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
1978
1979 if( connection && connection->HasDriverChanged() )
1980 {
1981 connection->ClearDriverChanged();
1982 flags |= KIGFX::REPAINT;
1983 }
1984
1985 if( item )
1986 {
1987 item->RunOnChildren(
1988 [&flags]( SCH_ITEM* aChild )
1989 {
1990 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild );
1991
1992 if( text && text->HasTextVars() )
1993 {
1994 text->ClearRenderCache();
1995 text->ClearBoundingBoxCache();
1997 }
1998 } );
1999
2000 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
2001
2002 if( text && text->HasTextVars() )
2003 {
2004 text->ClearRenderCache();
2005 text->ClearBoundingBoxCache();
2007 }
2008
2009 if( flags & KIGFX::GEOMETRY )
2010 GetScreen()->Update( item, false ); // Refresh RTree
2011 }
2012
2013 return flags;
2014 } );
2015
2017 || !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
2018 {
2022 }
2023
2024 if( !localCommit.Empty() )
2025 localCommit.Push( _( "Schematic Cleanup" ) );
2026}
2027
2028
2030{
2032 {
2033 for( SCH_FIELD& field : label->GetFields() )
2034 field.ClearBoundingBoxCache();
2035
2036 label->ClearBoundingBoxCache();
2037 GetCanvas()->GetView()->Update( label );
2038 } );
2039}
2040
2041
2043{
2045
2047}
2048
2049
2050void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
2051{
2052 SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
2053
2054 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
2055
2057
2059
2063
2064 KIGFX::VIEW* view = GetCanvas()->GetView();
2070
2072
2073 settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
2074
2075 if( !cfg->m_Drawing.field_names.IsEmpty() )
2077
2079
2080 for( SCH_ITEM* item : screen->Items() )
2081 item->ClearCaches();
2082
2083 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
2084 libSymbol->ClearCaches();
2085
2087
2089 Layout();
2090 SendSizeEvent();
2091}
2092
2093
2095{
2096 // Store the current zoom level into the current screen before calling
2097 // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
2099
2100 // Rebuild the sheet view (draw area and any other items):
2102}
2103
2104
2106{
2107 // call my base class
2109
2110 // tooltips in toolbars
2112
2113 m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
2114 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
2115 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
2116 m_auimgr.Update();
2118
2119 // status bar
2121
2122 updateTitle();
2123
2124 // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
2125 // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
2126 // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
2127 // toolbar to update correctly.
2128#if defined( __WXMSW__ )
2129 PostSizeEvent();
2130#endif
2131}
2132
2133
2135{
2136 if( !GetHighlightedConnection().IsEmpty() )
2137 {
2138 SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
2140 }
2141 else
2142 {
2143 SetStatusText( wxT( "" ) );
2144 }
2145}
2146
2147
2149{
2150 if( m_toolManager )
2152
2153 SCH_BASE_FRAME::SetScreen( aScreen );
2154 GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
2155
2156 if( m_toolManager )
2158}
2159
2160
2161const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
2162{
2163 BOX2I bBoxDoc;
2164
2165 if( aIncludeAllVisible )
2166 {
2167 // Get the whole page size and return that
2170 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
2171 }
2172 else
2173 {
2174 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
2176 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
2177
2178 // Calc the bounding box of all items on screen except the page border
2179 for( EDA_ITEM* item : GetScreen()->Items() )
2180 {
2181 if( item != dsAsItem ) // Ignore the drawing-sheet itself
2182 bBoxDoc.Merge( item->GetBoundingBox() );
2183 }
2184 }
2185
2186 return bBoxDoc;
2187}
2188
2189
2191{
2192 return Schematic().GetSheets().IsModified();
2193}
2194
2195
2197{
2198 EESCHEMA_SETTINGS* cfg = eeconfig();
2199 return cfg && cfg->m_Appearance.show_hidden_pins;
2200}
2201
2202
2204{
2205 static KIID lastBrightenedItemID( niluuid );
2206
2207 SCH_SHEET_LIST sheetList = Schematic().GetSheets();
2209 SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
2210
2211 if( lastItem && lastItem != aItem )
2212 {
2213 lastItem->ClearBrightened();
2214
2215 UpdateItem( lastItem );
2216 lastBrightenedItemID = niluuid;
2217 }
2218
2219 if( aItem )
2220 {
2221 if( !aItem->IsBrightened() )
2222 {
2223 aItem->SetBrightened();
2224
2225 UpdateItem( aItem );
2226 lastBrightenedItemID = aItem->m_Uuid;
2227 }
2228
2230 }
2231}
2232
2233
2235{
2236 return Schematic().GetFileName();
2237}
2238
2239
2241{
2242 return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
2243}
2244
2245
2246void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2247{
2248 if( IsShown() )
2249 {
2250 // We only need this until the frame is done resizing and the final client size is
2251 // established.
2252 Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
2254 }
2255
2256 // Skip() is called in the base class.
2257 EDA_DRAW_FRAME::OnSize( aEvent );
2258}
2259
2260
2262 const KIID& aSchematicSymbolUUID )
2263{
2264 SCH_SHEET_PATH principalPath;
2265 SCH_ITEM* item = Schematic().GetSheets().GetItem( aSchematicSymbolUUID, &principalPath );
2266 SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
2267 SCH_COMMIT commit( m_toolManager );
2268
2269 if( !principalSymbol )
2270 return;
2271
2272 wxString principalRef;
2273
2274 if( principalSymbol->IsAnnotated( &principalPath ) )
2275 principalRef = principalSymbol->GetRef( &principalPath, false );
2276
2277 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
2278
2279 for( const SCH_SHEET_PATH& path : Schematic().GetSheets() )
2280 {
2281 for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2282 {
2283 SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
2284
2285 if( candidateSymbol == principalSymbol
2286 || ( candidateSymbol->IsAnnotated( &path )
2287 && candidateSymbol->GetRef( &path, false ) == principalRef ) )
2288 {
2289 allUnits.emplace_back( candidateSymbol, path );
2290 }
2291 }
2292 }
2293
2294 for( auto& [ unit, path ] : allUnits )
2295 {
2296 // This needs to be done before the LIB_SYMBOL is changed to prevent stale
2297 // library symbols in the schematic file.
2298 path.LastScreen()->Remove( unit );
2299
2300 if( !unit->IsNew() )
2301 commit.Modify( unit, path.LastScreen() );
2302
2303 unit->SetLibSymbol( aSymbol.Flatten().release() );
2304 unit->UpdateFields( &GetCurrentSheet(),
2305 true, /* update style */
2306 true, /* update ref */
2307 true, /* update other fields */
2308 false, /* reset ref */
2309 false /* reset other fields */ );
2310
2311 path.LastScreen()->Append( unit );
2312 GetCanvas()->GetView()->Update( unit );
2313 }
2314
2315 if( !commit.Empty() )
2316 commit.Push( _( "Save Symbol to Schematic" ) );
2317}
2318
2319
2320void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2321{
2322 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2323
2324 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
2325 sch_item->ClearCaches();
2326}
2327
2328
2330{
2331 wxCHECK( m_toolManager, /* void */ );
2332
2336
2337 wxCHECK( screen, /* void */ );
2338
2340
2341 SCH_BASE_FRAME::SetScreen( screen );
2342
2344
2345 // update the references, units, and intersheet-refs
2347
2348 // dangling state can also have changed if different units with different pin locations are
2349 // used
2353
2355
2356 wxCHECK( selectionTool, /* void */ );
2357
2358 auto visit =
2359 [&]( EDA_ITEM* item )
2360 {
2362 && !m_findReplaceData->findString.IsEmpty()
2363 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
2364 {
2365 item->SetForceVisible( true );
2366 selectionTool->BrightenItem( item );
2367 }
2368 else if( item->IsBrightened() )
2369 {
2370 item->SetForceVisible( false );
2371 selectionTool->UnbrightenItem( item );
2372 }
2373 };
2374
2375 for( SCH_ITEM* item : screen->Items() )
2376 {
2377 visit( item );
2378
2379 item->RunOnChildren(
2380 [&]( SCH_ITEM* aChild )
2381 {
2382 visit( aChild );
2383 } );
2384 }
2385
2386 if( !screen->m_zoomInitialized )
2387 {
2389 }
2390 else
2391 {
2392 // Set zoom to last used in this screen
2393 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
2394 GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
2395 }
2396
2397 updateTitle();
2398
2399 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
2400
2401 // Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
2403
2405
2406 wxCHECK( editTool, /* void */ );
2407
2409 editTool->UpdateNetHighlighting( dummy );
2410
2412
2414}
2415
2416
2418{
2419 if( !m_diffSymbolDialog )
2421 _( "Compare Symbol with Library" ) );
2422
2423 return m_diffSymbolDialog;
2424}
2425
2426
2427void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
2428{
2429 if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
2430 {
2431 m_diffSymbolDialog->Destroy();
2432 m_diffSymbolDialog = nullptr;
2433 }
2434}
2435
2436
2438{
2439 if( !m_ercDialog )
2440 m_ercDialog = new DIALOG_ERC( this );
2441
2442 return m_ercDialog;
2443}
2444
2445
2446void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
2447{
2448 if( m_ercDialog )
2449 {
2450 m_ercDialog->Destroy();
2451 m_ercDialog = nullptr;
2452 }
2453}
2454
2455
2457{
2460
2462}
2463
2464
2466{
2468 {
2469 m_symbolFieldsTableDialog->Destroy();
2470 m_symbolFieldsTableDialog = nullptr;
2471 }
2472}
2473
2474
2475void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
2476{
2477 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2478 aListener );
2479
2480 // Don't add duplicate listeners.
2481 if( it == m_schematicChangeListeners.end() )
2482 m_schematicChangeListeners.push_back( aListener );
2483}
2484
2485
2487{
2488 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2489 aListener );
2490
2491 // Don't add duplicate listeners.
2492 if( it != m_schematicChangeListeners.end() )
2493 m_schematicChangeListeners.erase( it );
2494}
2495
2496
2498{
2499 m_netNavigator = new wxTreeCtrl( this, wxID_ANY, wxPoint( 0, 0 ),
2500 FromDIP( wxSize( 160, 250 ) ),
2501 wxTR_DEFAULT_STYLE | wxNO_BORDER );
2502
2503 return m_netNavigator;
2504}
2505
2506
2507void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection,
2508 const NET_NAVIGATOR_ITEM_DATA* aSelection )
2509{
2510 bool refreshNetNavigator = aConnection != m_highlightedConn;
2511
2512 m_highlightedConn = aConnection;
2513
2514 if( refreshNetNavigator )
2515 RefreshNetNavigator( aSelection );
2516}
2517
2518
2520{
2521 if( m_netNavigator )
2522 {
2523 NET_NAVIGATOR_ITEM_DATA itemData;
2524 wxTreeItemId selection = m_netNavigator->GetSelection();
2525 bool refreshSelection = selection.IsOk() && ( selection != m_netNavigator->GetRootItem() );
2526
2527 if( refreshSelection )
2528 {
2530 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
2531
2532 wxCHECK( tmp, /* void */ );
2533 itemData = *tmp;
2534 }
2535
2536 m_netNavigator->DeleteAllItems();
2537 RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
2538 }
2539
2541}
2542
2543
2545{
2546 wxAuiPaneInfo& hierarchyPane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2547 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
2548 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
2549 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
2550
2551 // Don't give the selection filter its own visibility controls; instead show it if
2552 // anything else is visible
2553 bool showFilter = ( hierarchyPane.IsShown() && hierarchyPane.IsDocked() )
2554 || ( netNavigatorPane.IsShown() && netNavigatorPane.IsDocked() )
2555 || ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
2556
2557 selectionFilterPane.Show( showFilter );
2558}
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:887
static TOOL_ACTION toggleGrid
Definition: actions.h:172
static TOOL_ACTION paste
Definition: actions.h:70
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
static TOOL_ACTION millimetersUnits
Definition: actions.h:180
static TOOL_ACTION unselectAll
Definition: actions.h:73
static TOOL_ACTION copy
Definition: actions.h:69
static TOOL_ACTION updateFind
Definition: actions.h:106
static TOOL_ACTION pasteSpecial
Definition: actions.h:71
static TOOL_ACTION milsUnits
Definition: actions.h:179
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:135
static TOOL_ACTION showSearch
Definition: actions.h:98
static TOOL_ACTION undo
Definition: actions.h:66
static TOOL_ACTION duplicate
Definition: actions.h:74
static TOOL_ACTION inchesUnits
Definition: actions.h:178
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:132
static TOOL_ACTION doDelete
Definition: actions.h:75
static TOOL_ACTION selectionTool
Definition: actions.h:187
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:124
static TOOL_ACTION redo
Definition: actions.h:67
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION zoomTool
Definition: actions.h:127
static TOOL_ACTION showProperties
Definition: actions.h:201
static TOOL_ACTION cut
Definition: actions.h:68
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:173
static TOOL_ACTION selectAll
Definition: actions.h:72
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
WINDOW_SETTINGS m_Window
Definition: app_settings.h:170
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h: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.
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:88
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:249
const KIID m_Uuid
Definition: eda_item.h:485
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
void ClearBrightened()
Definition: eda_item.h:122
void SetBrightened()
Definition: eda_item.h:119
bool IsBrightened() const
Definition: eda_item.h:111
Specialization of the wxAuiPaneInfo class for KiCad panels.
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:262
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:83
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
virtual void ClearBoundingBoxCache()
Definition: eda_text.cpp:505
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:268
static TOOL_ACTION lineMode90
Definition: ee_actions.h:263
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:234
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:258
static TOOL_ACTION toggleERCWarnings
Definition: ee_actions.h:239
static TOOL_ACTION drawRuleArea
Definition: ee_actions.h:107
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:241
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:262
static TOOL_ACTION drawBus
Definition: ee_actions.h:82
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:240
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:295
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:294
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:220
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:235
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:89
static TOOL_ACTION ddAppendFile
Definition: ee_actions.h:299
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:296
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:238
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:226
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:264
static TOOL_ACTION drawSheet
Definition: ee_actions.h:91
static TOOL_ACTION navigateNext
Definition: ee_actions.h:225
static TOOL_ACTION placeLabel
Definition: ee_actions.h:87
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:86
static TOOL_ACTION placeJunction
Definition: ee_actions.h:85
static TOOL_ACTION navigatePrevious
Definition: ee_actions.h:224
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:271
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1631
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:395
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:215
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
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:1523
Definition: kiid.h:49
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:67
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
Definition: kiway_player.h:115
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:99
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:69
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
void OnKiCadExit()
Definition: kiway.cpp: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:77
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:579
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.
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 settings were stored in SCH_BASE_FRAME previously.
Holds all the data relating to one schematic.
Definition: schematic.h:75
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:128
CONNECTION_GRAPH * m_connectionGraph
Holds and calculates connectivity information of this schematic.
Definition: schematic.h:329
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:136
void OnSchSheetChanged()
Notify the schematic and its listeners that the current sheet has been changed.
Definition: schematic.cpp:767
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
Definition: schematic.cpp:701
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:281
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:287
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:146
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:141
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:100
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:184
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:154
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:197
void RecomputeIntersheetRefs(const std::function< void(SCH_GLOBALLABEL *)> &aItemCallback)
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
Definition: schematic.cpp:656
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:121
void RemoveAllListeners()
Remove all listeners.
Definition: schematic.cpp:792
SCH_SHEET & Root() const
Definition: schematic.h:105
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:627
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:294
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_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:405
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.
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 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:174
virtual bool IsConnectable() const
Definition: sch_item.h:457
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:576
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:210
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:120
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_item.h:189
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:1454
SPIN_STYLE GetSpinStyle() const
Definition: sch_label.cpp:373
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_label.cpp:639
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:196
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Definition: sch_label.cpp:338
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.)
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
void SetOperatingPoint(const wxString &aText)
Definition: sch_line.h:303
double GetLength() const
Definition: sch_line.cpp:243
const wxString & GetOperatingPoint() const
Definition: sch_line.h:302
Handle actions specific to the schematic editor.
void SetOperatingPoint(const wxString &aText)
Definition: sch_pin.h:274
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:704
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:131
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:275
void TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr, std::function< void(SCH_ITEM *)> *aChangedHandler=nullptr) const
Test all of the connectable objects in the schematic for unused connection points.
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:481
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:628
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
const wxString & GetFileName() const
Definition: sch_screen.h:144
const KIID & GetUuid() const
Definition: sch_screen.h:525
void Print(const SCH_RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
bool IsReadOnly() const
Definition: sch_screen.h:147
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:115
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:313
bool m_zoomInitialized
Definition: sch_screen.h:653
bool FileExists() const
Definition: sch_screen.h:150
SPIN_STYLE GetLabelOrientationForPoint(const VECTOR2I &aPosition, SPIN_STYLE aDefaultOrientation, const SCH_SHEET_PATH *aSheet) const
Definition: sch_screen.cpp:505
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
bool IsModified() const
Check the entire hierarchy for any modifications.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void clear()
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
wxString GetName() const
Definition: sch_sheet.h:107
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:162
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:181
Schematic symbol object.
Definition: sch_symbol.h:108
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:786
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:910
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:711
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:208
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
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)
std::vector< std::reference_wrapper< const PIN > > GetPins() const
Definition: sim_model.cpp:739
const SPICE_GENERATOR & SpiceGenerator() const
Definition: sim_model.h:436
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:57
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:145
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:297
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:230
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void InitTools()
Initializes all registered tools.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: wx_infobar.cpp:301
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: wx_infobar.cpp:140
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:187
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: wx_infobar.cpp:291
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
Definition: common.cpp:415
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:240
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#define _HKI(x)
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define SCH_EDIT_FRAME_NAME
@ ID_IMPORT_NON_KICAD_SCH
Definition: eeschema_id.h:57
const wxAuiPaneInfo & 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:78
@ LAYER_ERC_WARN
Definition: layer_ids.h:383
@ LAYER_ERC_EXCLUSION
Definition: layer_ids.h:385
@ LAYER_ERC_ERR
Definition: layer_ids.h:384
@ LAYER_OP_CURRENTS
Definition: layer_ids.h:402
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:390
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:367
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:401
@ MAIL_PCB_UPDATE
Definition: mail_type.h:46
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:54
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:90
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:79
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
std::vector< SCH_SHEET_PATH > SCH_SHEET_PATHS
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< int > VECTOR2I
Definition: vector2d.h:588
Definition of file extensions used in Kicad.
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.