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>
38#include <eeschema_id.h>
39#include <executable_names.h>
42#include <gestfich.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_marker.h>
60#include <sch_sheet_pin.h>
61#include <sch_commit.h>
62#include <sch_rule_area.h>
64#include <advanced_config.h>
65#include <sim/simulator_frame.h>
66#include <tool/action_manager.h>
67#include <tool/action_toolbar.h>
68#include <tool/common_control.h>
69#include <tool/common_tools.h>
70#include <tool/embed_tool.h>
71#include <tool/picker_tool.h>
73#include <tool/selection.h>
75#include <tool/tool_manager.h>
76#include <tool/zoom_tool.h>
77#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>
102#include <wx/debug.h>
104#include <widgets/wx_aui_utils.h>
106
107#ifdef KICAD_IPC_API
109#include <api/api_utils.h>
110#endif
111
112
113#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
114
115
116BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
119
120 EVT_SIZE( SCH_EDIT_FRAME::OnSize )
121
124
126
127 EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
128 EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
129
130 // Drop files event
131 EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
132END_EVENT_TABLE()
133
134
135wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
136wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
137
138
139SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
140 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
142 m_ercDialog( nullptr ),
143 m_diffSymbolDialog( nullptr ),
144 m_symbolFieldsTableDialog( nullptr ),
145 m_netNavigator( nullptr ),
146 m_highlightedConnChanged( false ),
147 m_designBlocksPane( nullptr )
148{
149 m_maximizeByDefault = true;
150 m_schematic = new SCHEMATIC( nullptr );
151
152 m_showBorderAndTitleBlock = true; // true to show sheet references
153 m_supportsAutoSave = true;
154 m_syncingPcbToSchSelection = false;
155 m_aboutTitle = _HKI( "KiCad Schematic Editor" );
156 m_show_search = false;
157
158 m_findReplaceDialog = nullptr;
159
160 m_findReplaceData = std::make_unique<SCH_SEARCH_DATA>();
161
162 // Give an icon
163 wxIcon icon;
164 wxIconBundle icon_bundle;
165
166 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 48 ) );
167 icon_bundle.AddIcon( icon );
168 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 128 ) );
169 icon_bundle.AddIcon( icon );
170 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 256 ) );
171 icon_bundle.AddIcon( icon );
172 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
173 icon_bundle.AddIcon( icon );
174 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
175 icon_bundle.AddIcon( icon );
176
177 SetIcons( icon_bundle );
178
179 LoadSettings( eeconfig() );
180
181 // NB: also links the schematic to the loaded project
182 CreateScreens();
183
184 SCH_SHEET_PATH root;
185 root.push_back( &Schematic().Root() );
186 SetCurrentSheet( root );
187
188 setupTools();
189 setupUIConditions();
190 ReCreateMenuBar();
191 ReCreateHToolbar();
192 ReCreateVToolbar();
193 ReCreateOptToolbar();
194
195#ifdef KICAD_IPC_API
197 &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
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 m_designBlocksPane = new DESIGN_BLOCK_PANE( this, nullptr, m_designBlockHistoryList );
215
216 m_auimgr.SetManagedWindow( this );
217
218 CreateInfoBar();
219
220 // Rows; layers 4 - 6
221 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxS( "MainToolbar" ) )
222 .Top().Layer( 6 ) );
223
224 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
225 .Bottom().Layer( 6 ) );
226
227 // Columns; layers 1 - 3
228 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
229 .Caption( _( "Schematic Hierarchy" ) )
230 .Left().Layer( 3 ).Position( 1 )
231 .TopDockable( false )
232 .BottomDockable( false )
233 .CloseButton( false )
234 .MinSize( FromDIP( wxSize( 120, 60 ) ) )
235 .BestSize( FromDIP( wxSize( 200, 200 ) ) )
236 .FloatingSize( FromDIP( wxSize( 200, 200 ) ) )
237 .FloatingPosition( FromDIP( wxPoint( 50, 50 ) ) )
238 .Show( false ) );
239
240 m_auimgr.AddPane( m_propertiesPanel, defaultPropertiesPaneInfo( this ) );
241 m_auimgr.AddPane( m_selectionFilterPanel, defaultSchSelectionFilterPaneInfo( this ) );
242
243 m_auimgr.AddPane( m_designBlocksPane, defaultDesignBlocksPaneInfo( this ) );
244
245 m_auimgr.AddPane( createHighlightedNetNavigator(), defaultNetNavigatorPaneInfo() );
246
247 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( wxS( "OptToolbar" ) )
248 .Left().Layer( 2 ) );
249
250 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( wxS( "ToolsToolbar" ) )
251 .Right().Layer( 2 ) );
252
253 // Center
254 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
255 .Center() );
256
257 m_auimgr.AddPane( m_searchPane, EDA_PANE()
258 .Name( SearchPaneName() )
259 .Bottom()
260 .Caption( _( "Search" ) )
261 .PaneBorder( false )
262 .MinSize( FromDIP( wxSize( 180, 60 ) ) )
263 .BestSize( FromDIP( wxSize( 180, 100 ) ) )
264 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
265 .CloseButton( false )
266 .DestroyOnClose( false )
267 .Show( m_show_search ) );
268
269 FinishAUIInitialization();
270
271 resolveCanvasType();
272 SwitchCanvas( m_canvasType );
273
274 GetCanvas()->GetGAL()->SetAxesEnabled( false );
275
276 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
277 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
278
279 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
280 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
281 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
282 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
283 wxAuiPaneInfo& designBlocksPane = m_auimgr.GetPane( DesignBlocksPaneName() );
284 EESCHEMA_SETTINGS* cfg = eeconfig();
285
286 hierarchy_pane.Show( cfg->m_AuiPanels.show_schematic_hierarchy );
287 netNavigatorPane.Show( cfg->m_AuiPanels.show_net_nav_panel );
288 propertiesPane.Show( cfg->m_AuiPanels.show_properties );
289 designBlocksPane.Show( cfg->m_AuiPanels.design_blocks_show );
290 updateSelectionFilterVisbility();
291
292 // The selection filter doesn't need to grow in the vertical direction when docked
293 selectionFilterPane.dock_proportion = 0;
294
297 {
298 // Show at end, after positioning
299 hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
301 }
302
303 if( cfg->m_AuiPanels.net_nav_panel_float_size.GetWidth() > 0
304 && cfg->m_AuiPanels.net_nav_panel_float_size.GetHeight() > 0 )
305 {
306 netNavigatorPane.FloatingSize( cfg->m_AuiPanels.net_nav_panel_float_size );
307 netNavigatorPane.FloatingPosition( cfg->m_AuiPanels.net_nav_panel_float_pos );
308 }
309
311 SetAuiPaneSize( m_auimgr, propertiesPane, cfg->m_AuiPanels.properties_panel_width, -1 );
312
314 hierarchy_pane.Float();
315
317 && ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
318 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
319 {
320 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
321 searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
322 SetAuiPaneSize( m_auimgr, searchPane, -1, cfg->m_AuiPanels.search_panel_height );
323 }
324
325 else if( cfg->m_AuiPanels.search_panel_width > 0
326 && ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
327 || cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
328 {
329 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
330 searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
331 SetAuiPaneSize( m_auimgr, searchPane, cfg->m_AuiPanels.search_panel_width, -1 );
332 }
333
335 netNavigatorPane.Float();
336
338 SetAuiPaneSize( m_auimgr, designBlocksPane,
340
342 {
343 // If the net navigator is not show, let the hierarchy navigator take all of the vertical
344 // space.
346 {
347 SetAuiPaneSize( m_auimgr, hierarchy_pane,
349 }
350 else
351 {
352 SetAuiPaneSize( m_auimgr, hierarchy_pane,
355
356 SetAuiPaneSize( m_auimgr, netNavigatorPane,
358 cfg->m_AuiPanels.net_nav_panel_docked_size.GetHeight() );
359 }
360
361 // wxAUI hack: force width by setting MinSize() and then Fixed()
362 // thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
363 hierarchy_pane.MinSize( cfg->m_AuiPanels.hierarchy_panel_docked_width, 60 );
364 hierarchy_pane.Fixed();
365 netNavigatorPane.MinSize( cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth(), 60 );
366 netNavigatorPane.Fixed();
367 m_auimgr.Update();
368
369 // now make it resizable again
370 hierarchy_pane.Resizable();
371 netNavigatorPane.Resizable();
372 m_auimgr.Update();
373
374 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
375 // back to minimum.
376 hierarchy_pane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
377 netNavigatorPane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
378 }
379 else
380 {
381 m_auimgr.Update();
382 }
383
384 LoadProjectSettings();
385 LoadDrawingSheet();
386
392
393 initScreenZoom();
394
395 m_hierarchy->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
396 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
397 this );
398 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
399 m_netNavigator->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onResizeNetNavigator, this );
400
401 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
402 // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
403 Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
404
405 setupUnits( eeconfig() );
406
407 // Net list generator
408 DefaultExecFlags();
409
410 updateTitle();
411 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
412
413#ifdef KICAD_IPC_API
414 m_apiHandler = std::make_unique<API_HANDLER_SCH>( this );
415 Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
416#endif
417
418 // Default shutdown reason until a file is loaded
419 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
420
421 // Init for dropping files
423 DragAcceptFiles( true );
424
425 // Ensure the window is on top
426 Raise();
427
428 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
429 // top-left corner of the canvas
430 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
431 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
432
433 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
434 Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
435 Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog,
436 this );
437}
438
439
441{
442#ifdef KICAD_IPC_API
443 Pgm().GetApiServer().DeregisterHandler( m_apiHandler.get() );
444 wxTheApp->Unbind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED,
445 &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
446#endif
447
448 m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
449
450 // Ensure m_canvasType is up to date, to save it in config
452
453 SetScreen( nullptr );
454
455 if( m_schematic )
457
458 // Delete all items not in draw list before deleting schematic
459 // to avoid dangling pointers stored in these items
462
463 delete m_schematic;
464 m_schematic = nullptr;
465
466 // Close the project if we are standalone, so it gets cleaned up properly
467 if( Kiface().IsSingle() )
468 {
469 try
470 {
471 GetSettingsManager()->UnloadProject( &Prj(), false );
472 }
473 catch( const nlohmann::detail::type_error& e )
474 {
475 wxFAIL_MSG( wxString::Format( wxT( "Settings exception occurred: %s" ), e.what() ) );
476 }
477 }
478
479 delete m_hierarchy;
481}
482
483
485{
486 aEvent.Skip();
487
488 // 1st Call: Handle the size update during the first resize event.
490
491 // Defer the second size capture
492 CallAfter([this]() {
494 });
495}
496
497
499{
500 // Called when resizing the Hierarchy Navigator panel
501 // Store the current pane size
502 // It allows to retrieve the last defined pane size when switching between
503 // docked and floating pane state
504 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
505
506 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
507 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
508
509 if( cfg && m_hierarchy->IsShownOnScreen() )
510 {
511 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
512 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
513
514 // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
515 // width is > 0 (i.e. if its size is already set and has meaning)
516 // if it is floating, its size is not initialized (only floating_size is initialized)
517 // initializing hierarchy_pane.best_size is useful when switching to float pane and
518 // after switching to the docked pane, to retrieve the last docked pane width
519 if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
520 {
521 cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
522 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
523 }
524 }
525}
526
527
529{
530 // Create the manager and dispatcher & route draw panel events to the dispatcher
533 GetCanvas()->GetViewControls(), config(), this );
534 m_actions = new EE_ACTIONS();
536
537 // Register tools
557
558 // Run the selection tool, it is supposed to be always active
560
562}
563
564
566{
568
570 SCH_EDITOR_CONDITIONS cond( this );
571
572 wxASSERT( mgr );
573
574 auto hasElements =
575 [ this ] ( const SELECTION& aSel )
576 {
577 return GetScreen() &&
578 ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
579 };
580
581 auto searchPaneCond =
582 [this] ( const SELECTION& )
583 {
584 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
585 };
586
587 auto propertiesCond =
588 [this] ( const SELECTION& )
589 {
590 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
591 };
592
593 auto hierarchyNavigatorCond =
594 [ this ] ( const SELECTION& aSel )
595 {
596 return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
597 };
598
599 auto netNavigatorCond =
600 [ this ] (const SELECTION& aSel )
601 {
602 return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
603 };
604
605 auto designBlockCond =
606 [ this ] (const SELECTION& aSel )
607 {
608 return m_auimgr.GetPane( DesignBlocksPaneName() ).IsShown();
609 };
610
611 auto undoCond =
612 [ this ] (const SELECTION& aSel )
613 {
615 return true;
616
617 return GetUndoCommandCount() > 0;
618 };
619
620#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
621#define CHECK( x ) ACTION_CONDITIONS().Check( x )
622
624 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
626
627 mgr->SetConditions( EE_ACTIONS::showSearch, CHECK( searchPaneCond ) );
628 mgr->SetConditions( EE_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
629 mgr->SetConditions( EE_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
630 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
631 mgr->SetConditions( EE_ACTIONS::showDesignBlockPanel, CHECK( designBlockCond ) );
636 CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
637 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
638 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
639
641 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_FREE ) ) );
643 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_90 ) ) );
645 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_45 ) ) );
646
647 mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
648 mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
649 mgr->SetConditions( ACTIONS::copyAsText, ENABLE( hasElements ) );
652 mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
653 mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
654 mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
655 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
656
657 mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( hasElements ) );
658 mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( hasElements ) );
659 mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( hasElements ) );
660 mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( hasElements ) );
661
666
667 if( SCRIPTING::IsWxAvailable() )
668 {
670 CHECK( cond.ScriptingConsoleVisible() ) );
671 }
672
673 auto showHiddenPinsCond =
674 [this]( const SELECTION& )
675 {
676 return GetShowAllPins();
677 };
678
679 auto showHiddenFieldsCond =
680 [this]( const SELECTION& )
681 {
683 return cfg && cfg->m_Appearance.show_hidden_fields;
684 };
685
686 auto showDirectiveLabelsCond =
687 [this]( const SELECTION& )
688 {
690 return cfg && cfg->m_Appearance.show_directive_labels;
691 };
692
693 auto showERCErrorsCond =
694 [this]( const SELECTION& )
695 {
697 return cfg && cfg->m_Appearance.show_erc_errors;
698 };
699
700 auto showERCWarningsCond =
701 [this]( const SELECTION& )
702 {
704 return cfg && cfg->m_Appearance.show_erc_warnings;
705 };
706
707 auto showERCExclusionsCond =
708 [this]( const SELECTION& )
709 {
711 return cfg && cfg->m_Appearance.show_erc_exclusions;
712 };
713
714 auto markSimExclusionsCond =
715 [this]( const SELECTION& )
716 {
718 return cfg && cfg->m_Appearance.mark_sim_exclusions;
719 };
720
721 auto showOPVoltagesCond =
722 [this]( const SELECTION& )
723 {
725 return cfg && cfg->m_Appearance.show_op_voltages;
726 };
727
728 auto showOPCurrentsCond =
729 [this]( const SELECTION& )
730 {
732 return cfg && cfg->m_Appearance.show_op_currents;
733 };
734
735 auto showPinAltModeIconsCond =
736 [this]( const SELECTION& )
737 {
739 return cfg && cfg->m_Appearance.show_pin_alt_icons;
740 };
741
742 auto showAnnotateAutomaticallyCond =
743 [this]( const SELECTION& )
744 {
746 return cfg && cfg->m_AnnotatePanel.automatic;
747 };
748
749 auto remapSymbolsCondition =
750 [&]( const SELECTION& aSel )
751 {
752 SCH_SCREENS schematic( Schematic().Root() );
753
754 // The remapping can only be performed on legacy projects.
755 return schematic.HasNoFullyDefinedLibIds();
756 };
757
758 auto belowRootSheetCondition =
759 [this]( const SELECTION& aSel )
760 {
762 return navigateTool && navigateTool->CanGoUp();
763 };
764
765 mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
766
767 /* Some of these are bound by default to arrow keys which will get a different action if we
768 * disable the buttons. So always leave them enabled so the action is consistent.
769 * https://gitlab.com/kicad/code/kicad/-/issues/14783
770 mgr->SetConditions( EE_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
771 mgr->SetConditions( EE_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
772 mgr->SetConditions( EE_ACTIONS::navigateBack, ENABLE( navHistoryHsBackward ) );
773 */
774
775 mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
776 mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
777 mgr->SetConditions( EE_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
778 mgr->SetConditions( EE_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
779 mgr->SetConditions( EE_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
780 mgr->SetConditions( EE_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
781 mgr->SetConditions( EE_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
782 mgr->SetConditions( EE_ACTIONS::markSimExclusions, CHECK( markSimExclusionsCond ) );
783 mgr->SetConditions( EE_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
784 mgr->SetConditions( EE_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
785 mgr->SetConditions( EE_ACTIONS::togglePinAltIcons, CHECK( showPinAltModeIconsCond ) );
786 mgr->SetConditions( EE_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
788
791
792#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
793
823
824#undef CURRENT_TOOL
825#undef CHECK
826#undef ENABLE
827}
828
829
831{
832 // we cannot store a pointer to an item in the display list here since
833 // that item may be deleted, such as part of a line concatenation or other.
834 // So simply always keep a copy of the object which is to be repeated.
835
836 if( aItem )
837 {
838 m_items_to_repeat.clear();
839
840 AddCopyForRepeatItem( aItem );
841 }
842}
843
844
846{
847 // we cannot store a pointer to an item in the display list here since
848 // that item may be deleted, such as part of a line concatenation or other.
849 // So simply always keep a copy of the object which is to be repeated.
850
851 if( aItem )
852 {
853 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate() ) );
854
855 // Clone() preserves the flags & parent, we want 'em cleared.
856 repeatItem->ClearFlags();
857 repeatItem->SetParent( nullptr );
858
859 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
860 }
861}
862
863
865{
866 return Schematic().GetItem( aId );
867}
868
869
871{
873}
874
875
877{
878 return GetCurrentSheet().LastScreen();
879}
880
881
883{
884 return *m_schematic;
885}
886
887
889{
890 return GetCurrentSheet().Last()->GetName();
891}
892
893
895{
897}
898
899
901{
904
905 SCH_SHEET* rootSheet = new SCH_SHEET( m_schematic );
906 m_schematic->SetRoot( rootSheet );
907
908 SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
909 const_cast<KIID&>( rootSheet->m_Uuid ) = rootScreen->GetUuid();
910 m_schematic->Root().SetScreen( rootScreen );
911 SetScreen( Schematic().RootScreen() );
912
913
914 m_schematic->RootScreen()->SetFileName( wxEmptyString );
915
916 // Don't leave root page number empty
917 SCH_SHEET_PATH rootSheetPath;
918
919 rootSheetPath.push_back( rootSheet );
920 m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
921 rootSheetPath.SetPageNumber( wxT( "1" ) );
922
923 if( GetScreen() == nullptr )
924 {
925 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
926 SetScreen( screen );
927 }
928}
929
930
932{
933 return m_schematic->CurrentSheet();
934}
935
936
938{
939 if( aSheet != GetCurrentSheet() )
940 {
941 FocusOnItem( nullptr );
942
943 Schematic().SetCurrentSheet( aSheet );
944 GetCanvas()->DisplaySheet( aSheet.LastScreen() );
945 }
946}
947
948
950{
952
953 for( SCH_ITEM* item : screen->Items() )
954 item->ClearCaches();
955
956 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
957 {
958 wxCHECK2( libSymbol.second, continue );
959 libSymbol.second->ClearCaches();
960 }
961
962 if( Schematic().Settings().m_IntersheetRefsShow )
964
965 FocusOnItem( nullptr );
966
967 GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
968
970 selectionTool->Reset( TOOL_BASE::REDRAW );
971
973}
974
975
976bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
977{
978 // Exit interactive editing
979 // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
980 // will cancel any drag currently in progress, but commit all changes from previous drags.
981 if( m_toolManager )
983
984 // Shutdown blocks must be determined and vetoed as early as possible
985 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
986 && IsContentModified() )
987 {
988 return false;
989 }
990
991 if( Kiface().IsSingle() )
992 {
993 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
994
995 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
996 return false;
997
998 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
999
1000 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
1001 return false;
1002
1003 // SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
1004 // sorry.
1005 auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
1006
1007 if( chooser && !chooser->Close() ) // Can close symbol chooser?
1008 return false;
1009 }
1010 else
1011 {
1012 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1013
1014 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
1015 {
1016 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
1017 return false;
1018 }
1019 }
1020
1021 if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
1022 return false;
1023
1025 && !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
1026 {
1027 return false;
1028 }
1029
1030 // We may have gotten multiple events; don't clean up twice
1031 if( !Schematic().IsValid() )
1032 return false;
1033
1034 if( IsContentModified() )
1035 {
1036 wxFileName fileName = Schematic().RootScreen()->GetFileName();
1037 wxString msg = _( "Save changes to '%s' before closing?" );
1038
1039 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1040 [&]() -> bool
1041 {
1042 return SaveProject();
1043 } ) )
1044 {
1045 return false;
1046 }
1047 }
1048
1049 return true;
1050}
1051
1052
1054{
1055 SCH_SHEET_LIST sheetlist = Schematic().Hierarchy();
1056
1057 // Shutdown all running tools
1058 if( m_toolManager )
1060
1061 // Close modeless dialogs. They're trouble when they get destroyed after the frame.
1062 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
1063 Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
1064 Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE,
1066 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
1067 this );
1068 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection,
1069 this );
1070
1071 // Close the find dialog and preserve its setting if it is displayed.
1073 {
1076
1077 m_findReplaceDialog->Destroy();
1078 m_findReplaceDialog = nullptr;
1079 }
1080
1081 if( m_diffSymbolDialog )
1082 {
1083 m_diffSymbolDialog->Destroy();
1084 m_diffSymbolDialog = nullptr;
1085 }
1086
1087 if( m_ercDialog )
1088 {
1089 m_ercDialog->Destroy();
1090 m_ercDialog = nullptr;
1091 }
1092
1094 {
1095 m_symbolFieldsTableDialog->Destroy();
1096 m_symbolFieldsTableDialog = nullptr;
1097 }
1098
1099 // Make sure local settings are persisted
1101
1102 // Shutdown all running tools
1103 if( m_toolManager )
1104 {
1106 // prevent the canvas from trying to dispatch events during close
1107 GetCanvas()->SetEventDispatcher( nullptr );
1108 delete m_toolManager;
1109 m_toolManager = nullptr;
1110 }
1111
1112 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
1113
1114 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
1115 {
1116 hierarchy_pane.Show( false );
1117 m_auimgr.Update();
1118 }
1119
1120 SCH_SCREENS screens( Schematic().Root() );
1121 wxFileName fn;
1122
1123 for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
1124 {
1125 fn = Prj().AbsolutePath( screen->GetFileName() );
1126
1127 // Auto save file name is the normal file name prepended with FILEEXT::AutoSaveFilePrefix.
1128 fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() );
1129
1130 if( fn.IsFileWritable() )
1131 wxRemoveFile( fn.GetFullPath() );
1132 }
1133
1134 wxFileName tmpFn = Prj().GetProjectFullName();
1135 wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
1136
1137 if( autoSaveFileName.IsFileWritable() )
1138 wxRemoveFile( autoSaveFileName.GetFullPath() );
1139
1140 sheetlist.ClearModifyStatus();
1141
1142 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
1143
1144 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
1145 UpdateFileHistory( fileName );
1146
1147 Schematic().RootScreen()->Clear( true );
1148
1149 // all sub sheets are deleted, only the main sheet is usable
1151
1152 // Clear view before destroying schematic as repaints depend on schematic being valid
1153 SetScreen( nullptr );
1154
1155 Schematic().Reset();
1156
1157 // Prevents any rogue events from continuing (i.e. search panel tries to redraw)
1158 Show( false );
1159
1160 Destroy();
1161}
1162
1163
1165{
1166 return Schematic().ErcSettings().GetSeverity( aErrorCode );
1167}
1168
1169
1171{
1173
1174 if( GetScreen() )
1176
1177 m_autoSaveRequired = true;
1178
1179 if( GetCanvas() )
1180 GetCanvas()->Refresh();
1181
1182 if( !GetTitle().StartsWith( wxS( "*" ) ) )
1183 updateTitle();
1184}
1185
1186
1188{
1189 if( Kiface().IsSingle() )
1190 {
1191 DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
1192 " in stand-alone mode. In order to create/update PCBs from"
1193 " schematics, launch the KiCad shell and create a project." ) );
1194 return;
1195 }
1196
1197 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1198 wxEventBlocker blocker( this );
1199
1200 if( !frame )
1201 {
1202 wxFileName fn = Prj().GetProjectFullName();
1203 fn.SetExt( FILEEXT::PcbFileExtension );
1204
1205 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1206
1207 // If Kiway() cannot create the Pcbnew frame, it shows a error message, and
1208 // frame is null
1209 if( !frame )
1210 return;
1211
1212 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1213 }
1214
1215 if( !frame->IsVisible() )
1216 frame->Show( true );
1217
1218 // On Windows, Raise() does not bring the window on screen, when iconized
1219 if( frame->IsIconized() )
1220 frame->Iconize( false );
1221
1222 frame->Raise();
1223
1224 std::string payload;
1226}
1227
1228
1229void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator )
1230{
1231 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
1233
1234 if( aRefreshNetNavigator )
1236}
1237
1238
1240{
1241 // Update only the hierarchy navigation tree labels.
1242 // The tree list is expectyed to be up to date
1244}
1245
1246
1248{
1250}
1251
1252
1254{
1255 wxString findString;
1256
1257 EE_SELECTION& selection = m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1258
1259 if( selection.Size() == 1 )
1260 {
1261 EDA_ITEM* front = selection.Front();
1262
1263 switch( front->Type() )
1264 {
1265 case SCH_SYMBOL_T:
1266 {
1267 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( front );
1268 findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() );
1269 break;
1270 }
1271
1272 case SCH_FIELD_T:
1273 findString = UnescapeString( static_cast<SCH_FIELD*>( front )->GetText() );
1274 break;
1275
1276 case SCH_LABEL_T:
1277 case SCH_GLOBAL_LABEL_T:
1278 case SCH_HIER_LABEL_T:
1279 case SCH_SHEET_PIN_T:
1280 findString = UnescapeString( static_cast<SCH_LABEL_BASE*>( front )->GetText() );
1281 break;
1282
1283 case SCH_TEXT_T:
1284 findString = UnescapeString( static_cast<SCH_TEXT*>( front )->GetText() );
1285
1286 if( findString.Contains( wxT( "\n" ) ) )
1287 findString = findString.Before( '\n' );
1288
1289 break;
1290
1291 default:
1292 break;
1293 }
1294 }
1295
1297 m_findReplaceDialog->Destroy();
1298
1300 static_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() ),
1301 wxDefaultPosition, wxDefaultSize,
1302 aReplace ? wxFR_REPLACEDIALOG : 0 );
1303
1306 m_findReplaceDialog->Show( true );
1307}
1308
1309
1310void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
1311{
1312 // Prepare the infobar, since we don't know its state
1315
1316 m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
1317}
1318
1319
1321{
1322 m_infoBar->Dismiss();
1323}
1324
1325
1327{
1330
1331 m_findReplaceDialog->Destroy();
1332 m_findReplaceDialog = nullptr;
1333
1335}
1336
1337
1338void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1339{
1340 wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1341
1342 if( fn.size() )
1343 OpenProjectFiles( std::vector<wxString>( 1, fn ) );
1344}
1345
1346
1347void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
1348{
1350}
1351
1352
1354{
1355 // Only standalone mode can directly load a new document
1356 if( !Kiface().IsSingle() )
1357 return;
1358
1359 wxString pro_dir = m_mruPath;
1360
1361 wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
1363
1364 if( dlg.ShowModal() != wxID_CANCEL )
1365 {
1366 // Enforce the extension, wxFileDialog is inept.
1367 wxFileName create_me =
1369
1370 if( create_me.FileExists() )
1371 {
1372 wxString msg;
1373 msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
1374 DisplayError( this, msg );
1375 return ;
1376 }
1377
1378 // OpenProjectFiles() requires absolute
1379 wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
1380
1381 OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1382 m_mruPath = create_me.GetPath();
1383 }
1384}
1385
1386
1388{
1389 // Only standalone mode can directly load a new document
1390 if( !Kiface().IsSingle() )
1391 return;
1392
1393 wxString pro_dir = m_mruPath;
1394 wxString wildcards = FILEEXT::AllSchematicFilesWildcard()
1396 + wxS( "|" ) + FILEEXT::LegacySchematicFileWildcard();
1397
1398 wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
1399 wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1400
1401 if( dlg.ShowModal() != wxID_CANCEL )
1402 {
1403 OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1405 }
1406}
1407
1408
1410{
1411 wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
1412
1413 if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
1414 {
1415 kicad_board.SetExt( FILEEXT::PcbFileExtension );
1416 wxFileName legacy_board( kicad_board );
1417 legacy_board.SetExt( FILEEXT::LegacyPcbFileExtension );
1418 wxFileName& boardfn = legacy_board;
1419
1420 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1421 boardfn = kicad_board;
1422
1423 if( Kiface().IsSingle() )
1424 {
1425 ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
1426 }
1427 else
1428 {
1429 wxEventBlocker blocker(this);
1430 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1431
1432 if( !frame )
1433 {
1434 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1435
1436 // frame can be null if Cvpcb cannot be run. No need to show a warning
1437 // Kiway() generates the error messages
1438 if( !frame )
1439 return;
1440
1441 frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1442 }
1443
1444 if( !frame->IsVisible() )
1445 frame->Show( true );
1446
1447 // On Windows, Raise() does not bring the window on screen, when iconized
1448 if( frame->IsIconized() )
1449 frame->Iconize( false );
1450
1451 frame->Raise();
1452 }
1453 }
1454 else
1455 {
1456 // If we are running inside a project, it should be impossible for this case to happen
1457 wxASSERT( Kiface().IsSingle() );
1459 }
1460}
1461
1462
1464{
1465 wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1466 fn.SetExt( FILEEXT::NetlistFileExtension );
1467
1468 if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1469 return;
1470
1471 try
1472 {
1473 KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1474
1475 if( !player )
1476 {
1477 player = Kiway().Player( FRAME_CVPCB, true );
1478
1479 // player can be null if Cvpcb cannot be run. No need to show a warning
1480 // Kiway() generates the error messages
1481 if( !player )
1482 return;
1483
1484 player->Show( true );
1485 }
1486
1487 // Ensure the netlist (mainly info about symbols) is up to date
1490
1491 player->Raise();
1492 }
1493 catch( const IO_ERROR& )
1494 {
1495 DisplayError( this, _( "Could not open CvPcb" ) );
1496 }
1497}
1498
1499
1500void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1501{
1502 if( event.GetId() == wxID_EXIT )
1503 Kiway().OnKiCadExit();
1504
1505 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1506 Close( false );
1507}
1508
1509
1511{
1512 wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1513 const SCH_RENDER_SETTINGS* cfg = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
1515
1516 cfg->GetPrintDC()->SetBackground( wxBrush( bg.ToColour() ) );
1517 cfg->GetPrintDC()->Clear();
1518
1519 cfg->GetPrintDC()->SetLogicalFunction( wxCOPY );
1520 GetScreen()->Print( cfg );
1521 PrintDrawingSheet( cfg, GetScreen(), Schematic().GetProperties(), schIUScale.IU_PER_MILS, fileName );
1522}
1523
1524
1526{
1528 SIM_LIB_MGR simLibMgr( &Prj() );
1529 NULL_REPORTER devnull;
1530
1531 // Patch for bug early in V7.99 dev
1532 if( settings.m_OPO_VRange.EndsWith( 'A' ) )
1533 settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
1534
1535 // Update items which may have ${OP} text variables
1536 //
1538 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1539 {
1540 int flags = 0;
1541
1542 auto invalidateTextVars =
1543 [&flags]( EDA_TEXT* text )
1544 {
1545 if( text->HasTextVars() )
1546 {
1547 text->ClearRenderCache();
1548 text->ClearBoundingBoxCache();
1550 }
1551 };
1552
1553 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1554 {
1555 item->RunOnChildren(
1556 [&invalidateTextVars]( SCH_ITEM* aChild )
1557 {
1558 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1559 invalidateTextVars( text );
1560 } );
1561 }
1562
1563 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1564 invalidateTextVars( text );
1565
1566 return flags;
1567 } );
1568
1569 // Update OP overlay items
1570 //
1571 for( SCH_ITEM* item : GetScreen()->Items() )
1572 {
1574 continue;
1575
1576 if( item->Type() == SCH_LINE_T )
1577 {
1578 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1579
1580 if( !line->GetOperatingPoint().IsEmpty() )
1581 GetCanvas()->GetView()->Update( line );
1582
1583 line->SetOperatingPoint( wxEmptyString );
1584 // update value from netlist, below
1585 }
1586 else if( item->Type() == SCH_SYMBOL_T )
1587 {
1588 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1589 wxString ref = symbol->GetRef( &GetCurrentSheet() );
1590 std::vector<SCH_PIN*> pins = symbol->GetPins( &GetCurrentSheet() );
1591
1592 // Power symbols and other symbols which have the reference starting with "#" are
1593 // not included in simulation
1594 if( ref.StartsWith( '#' ) || symbol->GetExcludedFromSim() )
1595 continue;
1596
1597 for( SCH_PIN* pin : pins )
1598 {
1599 if( !pin->GetOperatingPoint().IsEmpty() )
1600 GetCanvas()->GetView()->Update( pin );
1601
1602 pin->SetOperatingPoint( wxEmptyString );
1603 }
1604
1605 if( pins.size() == 2 )
1606 {
1607 wxString op = m_schematic->GetOperatingPoint( ref, settings.m_OPO_IPrecision,
1608 settings.m_OPO_IRange );
1609
1610 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1611 {
1612 pins[0]->SetOperatingPoint( op );
1613 GetCanvas()->GetView()->Update( symbol );
1614 }
1615 }
1616 else
1617 {
1618 SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol,
1619 devnull ).model;
1620
1621 SPICE_ITEM spiceItem;
1622 spiceItem.refName = ref;
1623 ref = model.SpiceGenerator().ItemName( spiceItem );
1624
1625 for( const auto& modelPin : model.GetPins() )
1626 {
1627 SCH_PIN* symbolPin = symbol->GetPin( modelPin.get().symbolPinNumber );
1628 wxString signalName = ref + wxS( ":" ) + modelPin.get().modelPinName;
1629 wxString op = m_schematic->GetOperatingPoint( signalName,
1630 settings.m_OPO_IPrecision,
1631 settings.m_OPO_IRange );
1632
1633 if( symbolPin && !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1634 {
1635 symbolPin->SetOperatingPoint( op );
1636 GetCanvas()->GetView()->Update( symbol );
1637 }
1638 }
1639 }
1640 }
1641 }
1642
1643 for( const auto& [ key, subgraphList ] : m_schematic->m_connectionGraph->GetNetMap() )
1644 {
1645 wxString op = m_schematic->GetOperatingPoint( key.Name, settings.m_OPO_VPrecision,
1646 settings.m_OPO_VRange );
1647
1648 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1649 {
1650 for( CONNECTION_SUBGRAPH* subgraph : subgraphList )
1651 {
1652 SCH_LINE* longestWire = nullptr;
1653 double length = 0.0;
1654
1655 if( subgraph->GetSheet().GetExcludedFromSim() )
1656 continue;
1657
1658 for( SCH_ITEM* item : subgraph->GetItems() )
1659 {
1660 if( item->Type() == SCH_LINE_T )
1661 {
1662 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1663
1664 if( line->IsWire() && line->GetLength() > length )
1665 {
1666 longestWire = line;
1667 length = line->GetLength();
1668 }
1669 }
1670 }
1671
1672 if( longestWire )
1673 {
1674 longestWire->SetOperatingPoint( op );
1675 GetCanvas()->GetView()->Update( longestWire );
1676 }
1677 }
1678 }
1679 }
1680}
1681
1682
1684{
1685 if( aItem->Type() == SCH_GLOBAL_LABEL_T || aItem->Type() == SCH_HIER_LABEL_T )
1686 {
1687 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
1688
1689 if( label->AutoRotateOnPlacement() )
1690 {
1691 SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
1692 label->GetSpinStyle(),
1693 &GetCurrentSheet() );
1694
1695 if( spin != label->GetSpinStyle() )
1696 {
1697 label->SetSpinStyle( spin );
1698
1699 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1700 {
1701 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1702
1703 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1704 otherLabel->AutoplaceFields( aScreen, false );
1705 }
1706 }
1707 }
1708 }
1709}
1710
1711
1713{
1714 SCH_SCREEN* screen = GetScreen();
1715
1716 wxCHECK( screen, /* void */ );
1717
1718 wxString title;
1719
1720 if( !screen->GetFileName().IsEmpty() )
1721 {
1722 wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1723 bool readOnly = false;
1724 bool unsaved = false;
1725
1726 if( fn.IsOk() && screen->FileExists() )
1727 readOnly = screen->IsReadOnly();
1728 else
1729 unsaved = true;
1730
1731 if( IsContentModified() )
1732 title = wxT( "*" );
1733
1734 title += fn.GetName();
1735
1736 wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
1737
1738 if( sheetPath != title )
1739 title += wxString::Format( wxT( " [%s]" ), sheetPath );
1740
1741 if( readOnly )
1742 title += wxS( " " ) + _( "[Read Only]" );
1743
1744 if( unsaved )
1745 title += wxS( " " ) + _( "[Unsaved]" );
1746 }
1747 else
1748 {
1749 title = _( "[no schematic loaded]" );
1750 }
1751
1752 title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1753
1754 SetTitle( title );
1755}
1756
1757
1759{
1761 GetScreen()->m_zoomInitialized = true;
1762}
1763
1764
1766{
1767 wxString highlightedConn = GetHighlightedConnection();
1768 bool hasHighlightedConn = !highlightedConn.IsEmpty();
1769 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1771 SCH_COMMIT localCommit( m_toolManager );
1772
1773 if( !aCommit )
1774 aCommit = &localCommit;
1775
1776 PROF_TIMER timer;
1777
1778 // Ensure schematic graph is accurate
1779 if( aCleanupFlags == LOCAL_CLEANUP )
1780 {
1781 SchematicCleanUp( aCommit, GetScreen() );
1782 }
1783 else if( aCleanupFlags == GLOBAL_CLEANUP )
1784 {
1785 for( const SCH_SHEET_PATH& sheet : list )
1786 SchematicCleanUp( aCommit, sheet.LastScreen() );
1787 }
1788
1789 timer.Stop();
1790 wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1791
1792 if( settings.m_IntersheetRefsShow )
1794
1795 std::function<void( SCH_ITEM* )> changeHandler =
1796 [&]( SCH_ITEM* aChangedItem ) -> void
1797 {
1798 GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1799
1800 SCH_CONNECTION* connection = aChangedItem->Connection();
1801
1803 return;
1804
1805 if( !hasHighlightedConn )
1806 {
1807 // No highlighted connection, but connectivity has changed, so refresh
1808 // the list of all nets
1810 }
1811 else if( connection
1812 && ( connection->Name() == highlightedConn
1813 || connection->HasDriverChanged() ) )
1814 {
1816 }
1817 };
1818
1819 if( !ADVANCED_CFG::GetCfg().m_IncrementalConnectivity || aCleanupFlags == GLOBAL_CLEANUP
1820 || m_undoList.m_CommandsList.empty()|| Schematic().ConnectionGraph()->IsMinor() )
1821 {
1822 // Clear all resolved netclass caches in case labels have changed
1823 Prj().GetProjectFile().NetSettings()->ClearAllCaches();
1824
1825 // Update all rule areas so we can cascade implied connectivity changes
1826 std::unordered_set<SCH_SCREEN*> all_screens;
1827
1828 for( const SCH_SHEET_PATH& path : list )
1829 all_screens.insert( path.LastScreen() );
1830
1831 SCH_RULE_AREA::UpdateRuleAreasInScreens( all_screens, GetCanvas()->GetView() );
1832
1833 // Recalculate all connectivity
1834 Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
1835 }
1836 else
1837 {
1838 struct CHANGED_ITEM
1839 {
1840 SCH_ITEM* item;
1841 SCH_ITEM* linked_item;
1842 SCH_SCREEN* screen;
1843 };
1844
1845 PICKED_ITEMS_LIST* changed_list = m_undoList.m_CommandsList.back();
1846
1847 // Final change sets
1848 std::set<SCH_ITEM*> changed_items;
1849 std::set<VECTOR2I> pts;
1850 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> item_paths;
1851
1852 // Working change sets
1853 std::unordered_set<SCH_SCREEN*> changed_screens;
1854 std::set<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> changed_rule_areas;
1855 std::vector<CHANGED_ITEM> changed_connectable_items;
1856
1857 // Lambda to add an item to the connectivity update sets
1858 auto addItemToChangeSet = [&changed_items, &pts, &item_paths]( CHANGED_ITEM itemData )
1859 {
1860 std::vector<SCH_SHEET_PATH>& paths = itemData.screen->GetClientSheetPaths();
1861
1862 std::vector<VECTOR2I> tmp_pts = itemData.item->GetConnectionPoints();
1863 pts.insert( tmp_pts.begin(), tmp_pts.end() );
1864 changed_items.insert( itemData.item );
1865
1866 for( SCH_SHEET_PATH& path : paths )
1867 item_paths.insert( std::make_pair( path, itemData.item ) );
1868
1869 if( !itemData.linked_item || !itemData.linked_item->IsConnectable() )
1870 return;
1871
1872 tmp_pts = itemData.linked_item->GetConnectionPoints();
1873 pts.insert( tmp_pts.begin(), tmp_pts.end() );
1874 changed_items.insert( itemData.linked_item );
1875
1876 // We have to directly add the pins here because the link may not exist on the schematic
1877 // anymore and so won't be picked up by GetScreen()->Items().Overlapping() below.
1878 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( itemData.linked_item ) )
1879 {
1880 std::vector<SCH_PIN*> pins = symbol->GetPins();
1881 changed_items.insert( pins.begin(), pins.end() );
1882 }
1883
1884 for( SCH_SHEET_PATH& path : paths )
1885 item_paths.insert( std::make_pair( path, itemData.linked_item ) );
1886 };
1887
1888 // Get all changed connectable items and determine all changed screens
1889 for( unsigned ii = 0; ii < changed_list->GetCount(); ++ii )
1890 {
1891 switch( changed_list->GetPickedItemStatus( ii ) )
1892 {
1893 // Only care about changed, new, and deleted items, the other
1894 // cases are not connectivity-related
1895 case UNDO_REDO::CHANGED:
1896 case UNDO_REDO::NEWITEM:
1897 case UNDO_REDO::DELETED:
1898 break;
1899
1900 default:
1901 continue;
1902 }
1903
1904 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItem( ii ) );
1905
1906 if( item )
1907 {
1908 SCH_SCREEN* screen =
1909 static_cast<SCH_SCREEN*>( changed_list->GetScreenForItem( ii ) );
1910 changed_screens.insert( screen );
1911
1912 if( item->Type() == SCH_RULE_AREA_T )
1913 {
1914 SCH_RULE_AREA* ruleArea = static_cast<SCH_RULE_AREA*>( item );
1915
1916 // Clear item and directive associations for this rule area
1917 ruleArea->ResetDirectivesAndItems( GetCanvas()->GetView() );
1918
1919 changed_rule_areas.insert( { ruleArea, screen } );
1920 }
1921 else if( item->IsConnectable() )
1922 {
1923 SCH_ITEM* linked_item =
1924 dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItemLink( ii ) );
1925 changed_connectable_items.push_back( { item, linked_item, screen } );
1926 }
1927 }
1928 }
1929
1930 // Update rule areas in changed screens to propagate any directive connectivity changes
1931 std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> forceUpdateRuleAreas =
1932 SCH_RULE_AREA::UpdateRuleAreasInScreens( changed_screens, GetCanvas()->GetView() );
1933
1934 std::for_each( forceUpdateRuleAreas.begin(), forceUpdateRuleAreas.end(),
1935 [&]( std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& updatedRuleArea )
1936 {
1937 changed_rule_areas.insert( updatedRuleArea );
1938 } );
1939
1940 // If a SCH_RULE_AREA was changed, we need to add all past and present contained items to
1941 // update their connectivity
1942 for( const std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& changedRuleArea : changed_rule_areas )
1943 {
1944 for( SCH_ITEM* containedItem :
1945 changedRuleArea.first->GetPastAndPresentContainedItems() )
1946 {
1947 addItemToChangeSet( { containedItem, nullptr, changedRuleArea.second } );
1948 }
1949 }
1950
1951 // Add all changed items, and associated items, to the change set
1952 for( CHANGED_ITEM& changed_item_data : changed_connectable_items )
1953 {
1954 addItemToChangeSet( changed_item_data );
1955
1956 // If a SCH_DIRECTIVE_LABEL was changed which is attached to a SCH_RULE_AREA, we need
1957 // to add the contained items to the change set to force update of their connectivity
1958 if( changed_item_data.item->Type() == SCH_DIRECTIVE_LABEL_T )
1959 {
1960 const std::vector<VECTOR2I> labelConnectionPoints =
1961 changed_item_data.item->GetConnectionPoints();
1962
1963 EE_RTREE::EE_TYPE candidateRuleAreas =
1964 changed_item_data.screen->Items().Overlapping(
1965 SCH_RULE_AREA_T, changed_item_data.item->GetBoundingBox() );
1966
1967 for( SCH_ITEM* candidateRuleArea : candidateRuleAreas )
1968 {
1969 SCH_RULE_AREA* ruleArea = static_cast<SCH_RULE_AREA*>( candidateRuleArea );
1970 std::vector<SHAPE*> borderShapes = ruleArea->MakeEffectiveShapes( true );
1971
1972 if( ruleArea->GetPolyShape().CollideEdge( labelConnectionPoints[0], nullptr,
1973 5 ) )
1974 {
1975 for( SCH_ITEM* containedItem : ruleArea->GetPastAndPresentContainedItems() )
1976 addItemToChangeSet(
1977 { containedItem, nullptr, changed_item_data.screen } );
1978 }
1979 }
1980 }
1981 }
1982
1983 for( const VECTOR2I& pt: pts )
1984 {
1985 for( SCH_ITEM* item : GetScreen()->Items().Overlapping( pt ) )
1986 {
1987 // Leave this check in place. Overlapping items are not necessarily connectable.
1988 if( !item->IsConnectable() )
1989 continue;
1990
1991 if( item->Type() == SCH_LINE_T )
1992 {
1993 if( item->HitTest( pt ) )
1994 changed_items.insert( item );
1995 }
1996 else if( item->Type() == SCH_SYMBOL_T && item->IsConnected( pt ) )
1997 {
1998 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1999 std::vector<SCH_PIN*> pins = symbol->GetPins();
2000
2001 changed_items.insert( pins.begin(), pins.end() );
2002 }
2003 else if( item->Type() == SCH_SHEET_T )
2004 {
2005 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
2006
2007 wxCHECK2( sheet, continue );
2008
2009 std::vector<SCH_SHEET_PIN*> sheetPins = sheet->GetPins();
2010 changed_items.insert( sheetPins.begin(), sheetPins.end() );
2011 }
2012 else
2013 {
2014 if( item->IsConnected( pt ) )
2015 changed_items.insert( item );
2016 }
2017 }
2018 }
2019
2020 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> all_items =
2021 Schematic().ConnectionGraph()->ExtractAffectedItems( changed_items );
2022
2023 all_items.insert( item_paths.begin(), item_paths.end() );
2024
2025 CONNECTION_GRAPH new_graph( &Schematic() );
2026
2027 new_graph.SetLastCodes( Schematic().ConnectionGraph() );
2028
2029 std::shared_ptr<NET_SETTINGS> netSettings = Prj().GetProjectFile().NetSettings();
2030
2031 std::set<wxString> affectedNets;
2032
2033 for( auto&[ path, item ] : all_items )
2034 {
2035 wxCHECK2( item, continue );
2036 item->SetConnectivityDirty();
2037 SCH_CONNECTION* conn = item->Connection();
2038
2039 if( conn )
2040 {
2041 affectedNets.insert( conn->Name() );
2042 }
2043 }
2044
2045 // Reset resolved netclass cache for this connection
2046 for( const wxString& netName : affectedNets )
2047 netSettings->ClearCacheForNet( netName );
2048
2049 new_graph.Recalculate( list, false, &changeHandler );
2050 Schematic().ConnectionGraph()->Merge( new_graph );
2051 }
2052
2054 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
2055 {
2056 int flags = 0;
2057 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
2058 SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
2059
2060 auto invalidateTextVars =
2061 [&flags]( EDA_TEXT* text )
2062 {
2063 if( text->HasTextVars() )
2064 {
2065 text->ClearRenderCache();
2066 text->ClearBoundingBoxCache();
2068 }
2069 };
2070
2071 if( connection && connection->HasDriverChanged() )
2072 {
2073 connection->ClearDriverChanged();
2074 flags |= KIGFX::REPAINT;
2075 }
2076
2077 if( item )
2078 {
2079 item->RunOnChildren(
2080 [&invalidateTextVars]( SCH_ITEM* aChild )
2081 {
2082 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
2083 invalidateTextVars( text );
2084 } );
2085
2086 if( flags & KIGFX::GEOMETRY )
2087 GetScreen()->Update( item, false ); // Refresh RTree
2088 }
2089
2090 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
2091 invalidateTextVars( text );
2092
2093 return flags;
2094 } );
2095
2097 || !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
2098 {
2102 }
2103
2104 if( !localCommit.Empty() )
2105 localCommit.Push( _( "Schematic Cleanup" ) );
2106}
2107
2108
2110{
2112 {
2113 for( SCH_FIELD& field : label->GetFields() )
2114 field.ClearBoundingBoxCache();
2115
2116 label->ClearBoundingBoxCache();
2117 GetCanvas()->GetView()->Update( label );
2118 } );
2119}
2120
2121
2123{
2125
2127}
2128
2129
2130std::unique_ptr<GRID_HELPER> SCH_EDIT_FRAME::MakeGridHelper()
2131{
2132 return std::make_unique<EE_GRID_HELPER>( m_toolManager );
2133}
2134
2135
2136void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
2137{
2138 SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
2139
2140 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
2141
2143
2145
2147 EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
2150
2151 KIGFX::VIEW* view = GetCanvas()->GetView();
2157
2159
2160 settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
2161
2162 if( !cfg->m_Drawing.field_names.IsEmpty() )
2164
2166
2167 for( SCH_ITEM* item : screen->Items() )
2168 item->ClearCaches();
2169
2170 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
2171 libSymbol->ClearCaches();
2172
2174
2176 Layout();
2177 SendSizeEvent();
2178}
2179
2180
2182{
2183 // Store the current zoom level into the current screen before calling
2184 // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
2186
2187 // Rebuild the sheet view (draw area and any other items):
2189}
2190
2191
2193{
2194 // call my base class
2196
2197 // tooltips in toolbars
2199
2200 m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
2201 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
2202 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
2203 m_auimgr.Update();
2205
2206 // status bar
2208
2209 updateTitle();
2210
2211 // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
2212 // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
2213 // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
2214 // toolbar to update correctly.
2215#if defined( __WXMSW__ )
2216 PostSizeEvent();
2217#endif
2218}
2219
2220
2222{
2223 if( !GetHighlightedConnection().IsEmpty() )
2224 {
2225 SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
2227 }
2228 else
2229 {
2230 SetStatusText( wxT( "" ) );
2231 }
2232}
2233
2234
2236{
2237 if( m_toolManager )
2239
2240 SCH_BASE_FRAME::SetScreen( aScreen );
2241 GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
2242
2243 if( m_toolManager )
2245}
2246
2247
2248const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
2249{
2250 BOX2I bBoxDoc;
2251
2252 if( aIncludeAllVisible )
2253 {
2254 // Get the whole page size and return that
2257 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
2258 }
2259 else
2260 {
2261 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
2263 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
2264
2265 // Calc the bounding box of all items on screen except the page border
2266 for( EDA_ITEM* item : GetScreen()->Items() )
2267 {
2268 if( item != dsAsItem ) // Ignore the drawing-sheet itself
2269 bBoxDoc.Merge( item->GetBoundingBox() );
2270 }
2271 }
2272
2273 return bBoxDoc;
2274}
2275
2276
2278{
2279 return Schematic().Hierarchy().IsModified();
2280}
2281
2282
2284{
2285 EESCHEMA_SETTINGS* cfg = eeconfig();
2286 return cfg && cfg->m_Appearance.show_hidden_pins;
2287}
2288
2289
2291{
2292 static KIID lastBrightenedItemID( niluuid );
2293
2295 SCH_ITEM* lastItem = Schematic().GetItem( lastBrightenedItemID, &dummy );
2296
2297 if( lastItem && lastItem != aItem )
2298 {
2299 lastItem->ClearBrightened();
2300
2301 UpdateItem( lastItem );
2302 lastBrightenedItemID = niluuid;
2303 }
2304
2305 if( aItem )
2306 {
2307 if( !aItem->IsBrightened() )
2308 {
2309 aItem->SetBrightened();
2310
2311 UpdateItem( aItem );
2312 lastBrightenedItemID = aItem->m_Uuid;
2313 }
2314
2316 }
2317}
2318
2319
2321{
2322 return Schematic().GetFileName();
2323}
2324
2325
2327{
2328 return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
2329}
2330
2331
2332void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2333{
2334 if( IsShown() )
2335 {
2336 // We only need this until the frame is done resizing and the final client size is
2337 // established.
2338 Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
2340 }
2341
2342 // Skip() is called in the base class.
2343 EDA_DRAW_FRAME::OnSize( aEvent );
2344}
2345
2346
2348 const KIID& aSchematicSymbolUUID )
2349{
2350 SCH_SHEET_PATH principalPath;
2351 SCH_SHEET_LIST sheets = Schematic().Hierarchy();
2352 SCH_ITEM* item = sheets.GetItem( aSchematicSymbolUUID, &principalPath );
2353 SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
2354 SCH_COMMIT commit( m_toolManager );
2355
2356 if( !principalSymbol )
2357 return;
2358
2359 wxString principalRef;
2360
2361 if( principalSymbol->IsAnnotated( &principalPath ) )
2362 principalRef = principalSymbol->GetRef( &principalPath, false );
2363
2364 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
2365
2366 for( const SCH_SHEET_PATH& path : sheets )
2367 {
2368 for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2369 {
2370 SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
2371
2372 if( candidateSymbol == principalSymbol
2373 || ( candidateSymbol->IsAnnotated( &path )
2374 && candidateSymbol->GetRef( &path, false ) == principalRef ) )
2375 {
2376 allUnits.emplace_back( candidateSymbol, path );
2377 }
2378 }
2379 }
2380
2381 for( auto& [ unit, path ] : allUnits )
2382 {
2383 // This needs to be done before the LIB_SYMBOL is changed to prevent stale
2384 // library symbols in the schematic file.
2385 path.LastScreen()->Remove( unit );
2386
2387 if( !unit->IsNew() )
2388 commit.Modify( unit, path.LastScreen() );
2389
2390 unit->SetLibSymbol( aSymbol.Flatten().release() );
2391 unit->UpdateFields( &GetCurrentSheet(),
2392 true, /* update style */
2393 true, /* update ref */
2394 true, /* update other fields */
2395 false, /* reset ref */
2396 false /* reset other fields */ );
2397
2398 path.LastScreen()->Append( unit );
2399 GetCanvas()->GetView()->Update( unit );
2400 }
2401
2402 if( !commit.Empty() )
2403 commit.Push( _( "Save Symbol to Schematic" ) );
2404}
2405
2406
2407void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2408{
2409 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2410
2411 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
2412 sch_item->ClearCaches();
2413}
2414
2415
2417{
2418 wxCHECK( m_toolManager, /* void */ );
2419
2423
2424 wxCHECK( screen, /* void */ );
2425
2427
2428 SCH_BASE_FRAME::SetScreen( screen );
2429
2430 SetSheetNumberAndCount(); // will also update CurrentScreen()'s sheet number info
2431
2433
2434 // update the references, units, and intersheet-refs
2436
2437 // dangling state can also have changed if different units with different pin locations are
2438 // used
2441
2443
2444 wxCHECK( selectionTool, /* void */ );
2445
2446 auto visit =
2447 [&]( EDA_ITEM* item )
2448 {
2450 && !m_findReplaceData->findString.IsEmpty()
2451 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
2452 {
2453 item->SetForceVisible( true );
2454 selectionTool->BrightenItem( item );
2455 }
2456 else if( item->IsBrightened() )
2457 {
2458 item->SetForceVisible( false );
2459 selectionTool->UnbrightenItem( item );
2460 }
2461 };
2462
2463 for( SCH_ITEM* item : screen->Items() )
2464 {
2465 visit( item );
2466
2467 item->RunOnChildren(
2468 [&]( SCH_ITEM* aChild )
2469 {
2470 visit( aChild );
2471 } );
2472 }
2473
2474 if( !screen->m_zoomInitialized )
2475 {
2477 }
2478 else
2479 {
2480 // Set zoom to last used in this screen
2481 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
2482 GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
2483 }
2484
2485 updateTitle();
2486
2487 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
2488
2489 // Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
2491
2493
2494 wxCHECK( editTool, /* void */ );
2495
2497 editTool->UpdateNetHighlighting( dummy );
2498
2500
2502}
2503
2504
2506{
2507 if( !m_diffSymbolDialog )
2509 _( "Compare Symbol with Library" ) );
2510
2511 return m_diffSymbolDialog;
2512}
2513
2514
2515void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
2516{
2517 if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
2518 {
2519 m_diffSymbolDialog->Destroy();
2520 m_diffSymbolDialog = nullptr;
2521 }
2522}
2523
2524
2526{
2527 if( !m_ercDialog )
2528 m_ercDialog = new DIALOG_ERC( this );
2529
2530 return m_ercDialog;
2531}
2532
2533
2534void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
2535{
2536 if( m_ercDialog )
2537 {
2538 m_ercDialog->Destroy();
2539 m_ercDialog = nullptr;
2540 }
2541}
2542
2543
2545{
2548
2550}
2551
2552
2554{
2556 {
2557 m_symbolFieldsTableDialog->Destroy();
2558 m_symbolFieldsTableDialog = nullptr;
2559 }
2560}
2561
2562
2563void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
2564{
2565 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2566 aListener );
2567
2568 // Don't add duplicate listeners.
2569 if( it == m_schematicChangeListeners.end() )
2570 m_schematicChangeListeners.push_back( aListener );
2571}
2572
2573
2575{
2576 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2577 aListener );
2578
2579 // Don't add duplicate listeners.
2580 if( it != m_schematicChangeListeners.end() )
2581 m_schematicChangeListeners.erase( it );
2582}
2583
2584
2586{
2587 m_netNavigator = new wxTreeCtrl( this, wxID_ANY, wxPoint( 0, 0 ),
2588 FromDIP( wxSize( 160, 250 ) ),
2589 wxTR_DEFAULT_STYLE | wxNO_BORDER );
2590
2591 return m_netNavigator;
2592}
2593
2594
2595void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection,
2596 const NET_NAVIGATOR_ITEM_DATA* aSelection )
2597{
2598 bool refreshNetNavigator = aConnection != m_highlightedConn;
2599
2600 m_highlightedConn = aConnection;
2601
2602 if( refreshNetNavigator )
2603 RefreshNetNavigator( aSelection );
2604}
2605
2606
2608{
2609 if( m_netNavigator )
2610 {
2611 NET_NAVIGATOR_ITEM_DATA itemData;
2612 wxTreeItemId selection = m_netNavigator->GetSelection();
2613 bool refreshSelection = selection.IsOk() && ( selection != m_netNavigator->GetRootItem() );
2614
2615 if( refreshSelection )
2616 {
2618 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
2619
2620 wxCHECK( tmp, /* void */ );
2621 itemData = *tmp;
2622 }
2623
2624 m_netNavigator->DeleteAllItems();
2625 RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
2626 }
2627
2629}
2630
2631
2633{
2634 wxAuiPaneInfo& hierarchyPane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2635 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
2636 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
2637 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
2638
2639 // Don't give the selection filter its own visibility controls; instead show it if
2640 // anything else is visible
2641 bool showFilter = ( hierarchyPane.IsShown() && hierarchyPane.IsDocked() )
2642 || ( netNavigatorPane.IsShown() && netNavigatorPane.IsDocked() )
2643 || ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
2644
2645 selectionFilterPane.Show( showFilter );
2646}
2647
2648#ifdef KICAD_IPC_API
2649void SCH_EDIT_FRAME::onPluginAvailabilityChanged( wxCommandEvent& aEvt )
2650{
2651 wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
2653 aEvt.Skip();
2654}
2655#endif
const KICOMMON_API wxEventTypeTag< wxCommandEvent > EDA_EVT_PLUGIN_AVAILABILITY_CHANGED
Notifies other parts of KiCad when plugin availability changes.
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
@ icon_eeschema
@ icon_eeschema_16
@ icon_eeschema_32
BOX2< VECTOR2I > BOX2I
Definition: box2.h:922
static TOOL_ACTION toggleGrid
Definition: actions.h:187
static TOOL_ACTION paste
Definition: actions.h:73
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION millimetersUnits
Definition: actions.h:195
static TOOL_ACTION unselectAll
Definition: actions.h:76
static TOOL_ACTION copy
Definition: actions.h:71
static TOOL_ACTION updateFind
Definition: actions.h:116
static TOOL_ACTION pasteSpecial
Definition: actions.h:74
static TOOL_ACTION milsUnits
Definition: actions.h:194
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:147
static TOOL_ACTION showSearch
Definition: actions.h:108
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION duplicate
Definition: actions.h:77
static TOOL_ACTION inchesUnits
Definition: actions.h:193
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:144
static TOOL_ACTION doDelete
Definition: actions.h:78
static TOOL_ACTION selectionTool
Definition: actions.h:202
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:134
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION deleteTool
Definition: actions.h:79
static TOOL_ACTION zoomTool
Definition: actions.h:138
static TOOL_ACTION showProperties
Definition: actions.h:216
static TOOL_ACTION cut
Definition: actions.h:70
static TOOL_ACTION copyAsText
Definition: actions.h:72
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:188
static TOOL_ACTION selectAll
Definition: actions.h:75
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:194
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
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:658
COLOR4D GetColor(int aLayer) const
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
bool Empty() const
Returns status of an item.
Definition: commit.h:144
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
Definition: common_tools.h:38
Calculate the connectivity of a schematic and generates netlists.
const NET_MAP & GetNetMap() const
CONNECTION_SUBGRAPH * FindFirstSubgraphByName(const wxString &aNetName)
Retrieve a subgraph for the given net name, if one exists.
std::set< std::pair< SCH_SHEET_PATH, SCH_ITEM * > > ExtractAffectedItems(const std::set< SCH_ITEM * > &aItems)
For a set of items, this will remove the connected items and their associated data including subgraph...
void SetLastCodes(const CONNECTION_GRAPH *aOther)
void Merge(CONNECTION_GRAPH &aGraph)
Combine the input graph contents into the current graph.
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr)
Update the connection graph for the given list of sheets.
A subgraph is a set of items that are electrically connected on a single sheet.
wxArrayString GetFindEntries() const
wxArrayString GetReplaceEntries() const
void SetReplaceEntries(const wxArrayString &aEntries)
void SetFindEntries(const wxArrayString &aEntries, const wxString &aFindString)
bool Show(bool show) override
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
UNDO_REDO_CONTAINER m_undoList
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
SETTINGS_MANAGER * GetSettingsManager() const
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
WX_INFOBAR * m_infoBar
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxAuiManager m_auimgr
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
virtual void OnSize(wxSizeEvent &aEvent)
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handles event fired when a file is dropped to the window.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches the file name from the file history list.
virtual int GetUndoCommandCount() const
wxString m_mruPath
wxArrayString m_replaceStringHistoryList
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
static const wxString PropertiesPaneName()
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
virtual void SetScreen(BASE_SCREEN *aScreen)
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
virtual void UpdateMsgPanel()
Redraw the message panel.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
wxArrayString m_findStringHistoryList
static const wxString DesignBlocksPaneName()
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
PROPERTIES_PANEL * m_propertiesPanel
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:250
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
void ClearBrightened()
Definition: eda_item.h:123
void SetBrightened()
Definition: eda_item.h:120
bool IsBrightened() const
Definition: eda_item.h:112
Specialization of the wxAuiPaneInfo class for KiCad panels.
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:286
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
virtual void ClearBoundingBoxCache()
Definition: eda_text.cpp:637
SELECTION_CONDITION NoActiveTool()
Create a functor testing if there are no tools active in the frame.
SELECTION_CONDITION BoundingBoxes()
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SELECTION_CONDITION 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 drawSheetFromFile
Definition: ee_actions.h:94
static TOOL_ACTION mirrorV
Definition: ee_actions.h:132
static TOOL_ACTION drawSheetFromDesignBlock
Definition: ee_actions.h:95
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:176
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
static TOOL_ACTION toggleAnnotateAuto
Definition: ee_actions.h:284
static TOOL_ACTION placeDesignBlock
Definition: ee_actions.h:82
static TOOL_ACTION lineMode90
Definition: ee_actions.h:279
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:247
static TOOL_ACTION drawTable
Definition: ee_actions.h:104
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:272
static TOOL_ACTION toggleERCWarnings
Definition: ee_actions.h:252
static TOOL_ACTION drawRuleArea
Definition: ee_actions.h:113
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:254
static TOOL_ACTION placeClassLabel
Definition: ee_actions.h:90
static TOOL_ACTION drawWire
Definition: ee_actions.h:83
static TOOL_ACTION drawCircle
Definition: ee_actions.h:106
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:131
static TOOL_ACTION lineModeFree
Definition: ee_actions.h:278
static TOOL_ACTION drawBus
Definition: ee_actions.h:84
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:253
static TOOL_ACTION placePower
Definition: ee_actions.h:81
static TOOL_ACTION placeSheetPin
Definition: ee_actions.h:96
static TOOL_ACTION drawLines
Definition: ee_actions.h:109
static TOOL_ACTION toggleOPCurrents
Definition: ee_actions.h:257
static TOOL_ACTION mirrorH
Definition: ee_actions.h:133
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:311
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:310
static TOOL_ACTION syncSheetPins
Definition: ee_actions.h:99
static TOOL_ACTION rotateCW
Definition: ee_actions.h:130
static TOOL_ACTION togglePinAltIcons
Definition: ee_actions.h:258
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:233
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:248
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:91
static TOOL_ACTION ddAppendFile
Definition: ee_actions.h:315
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:92
static TOOL_ACTION drawTextBox
Definition: ee_actions.h:103
static TOOL_ACTION showNetNavigator
Definition: ee_actions.h:312
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:105
static TOOL_ACTION placeImage
Definition: ee_actions.h:110
static TOOL_ACTION toggleDirectiveLabels
Definition: ee_actions.h:251
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:239
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:102
static TOOL_ACTION toggleOPVoltages
Definition: ee_actions.h:256
static TOOL_ACTION showDesignBlockPanel
Definition: ee_actions.h:206
static TOOL_ACTION drawArc
Definition: ee_actions.h:107
static TOOL_ACTION lineMode45
Definition: ee_actions.h:280
static TOOL_ACTION drawSheet
Definition: ee_actions.h:93
static TOOL_ACTION drawBezier
Definition: ee_actions.h:108
static TOOL_ACTION markSimExclusions
Definition: ee_actions.h:255
static TOOL_ACTION placeLabel
Definition: ee_actions.h:89
static TOOL_ACTION saveSheetAsDesignBlock
Definition: ee_actions.h:207
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:88
static TOOL_ACTION placeJunction
Definition: ee_actions.h:87
static TOOL_ACTION saveSelectionAsDesignBlock
Definition: ee_actions.h:208
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:86
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:273
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:1669
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:397
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:217
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:588
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:1555
Definition: kiid.h:49
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
Definition: kiway_player.h:113
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:99
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:69
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:284
void OnKiCadExit()
Definition: kiway.cpp:725
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:406
virtual bool PlayerClose(FRAME_T aFrameType, bool doForce)
Call the KIWAY_PLAYER::Close( bool force ) function on the window and if not vetoed,...
Definition: kiway.cpp:470
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:527
Define a library symbol object.
Definition: lib_symbol.h:78
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:304
Tree view item data for the net navigator.
A singleton reporter that reports to nowhere.
Definition: reporter.h:203
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
Definition: page_info.h:162
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
Definition: page_info.h:153
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
A holder to handle information on schematic or board items.
UNDO_REDO GetPickedItemStatus(unsigned int aIdx) const
EDA_ITEM * GetPickedItemLink(unsigned int aIdx) const
unsigned GetCount() const
BASE_SCREEN * GetScreenForItem(unsigned int aIdx) const
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
A small class to help profiling.
Definition: profile.h:49
void Stop()
Save the time when this function was called, and set the counter stane to stop.
Definition: profile.h:88
double msecs(bool aSinceLast=false)
Definition: profile.h:149
std::shared_ptr< NET_SETTINGS > & NetSettings()
Definition: project_file.h:103
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 PROJECT_FILE & GetProjectFile() const
Definition: project.h:200
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:359
Action handler for the Properties panel.
These are loaded from Eeschema settings but then overwritten by the project settings.
Holds all the data relating to one schematic.
Definition: schematic.h:77
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:138
CONNECTION_GRAPH * m_connectionGraph
Holds and calculates connectivity information of this schematic.
Definition: schematic.h:372
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:156
void OnSchSheetChanged()
Notify the schematic and its listeners that the current sheet has been changed.
Definition: schematic.cpp:784
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
Definition: schematic.cpp:718
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:306
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:312
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:166
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:161
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:214
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Definition: schematic.h:120
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:194
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:164
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:208
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:673
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:141
void RemoveAllListeners()
Remove all listeners.
Definition: schematic.cpp:809
SCH_SHEET & Root() const
Definition: schematic.h:125
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:644
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:319
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:432
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool HasDriverChanged() const
wxString Name(bool aIgnoreSheet=false) const
Handle schematic design block actions in the schematic editor.
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.).
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplaySheet(SCH_SCREEN *aScreen)
Group generic conditions for PCB editor states.
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 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.
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 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 SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void OnPageSettingsChange() override
Called when modifying the page settings.
void ClearRepeatItemsList()
Clear the list of items which are to be repeated with the insert key.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void CaptureHierarchyPaneSize()
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
std::unique_ptr< GRID_HELPER > MakeGridHelper() override
SEVERITY GetSeverity(int aErrorCode) const override
void onNetNavigatorSelection(wxTreeEvent &aEvent)
void ReCreateHToolbar() override
void FocusOnItem(SCH_ITEM *aItem)
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
Handle actions specific to the schematic editor.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
virtual bool IsConnectable() const
Definition: sch_item.h:449
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:568
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:218
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:131
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:1402
SPIN_STYLE GetSpinStyle() const
Definition: sch_label.cpp:332
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_label.cpp:563
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:201
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Definition: sch_label.cpp:297
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.)
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:41
void SetOperatingPoint(const wxString &aText)
Definition: sch_line.h:313
bool IsWire() const
Return true if the line is a wire.
Definition: sch_line.cpp:973
double GetLength() const
Definition: sch_line.cpp:239
const wxString & GetOperatingPoint() const
Definition: sch_line.h:312
Handle actions specific to the schematic editor.
void SetOperatingPoint(const wxString &aText)
Definition: sch_pin.h:289
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:712
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:130
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:278
void TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr, std::function< void(SCH_ITEM *)> *aChangedHandler=nullptr) const
Test all of the connectable objects in the schematic for unused connection points.
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:480
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:636
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:108
const wxString & GetFileName() const
Definition: sch_screen.h:143
const KIID & GetUuid() const
Definition: sch_screen.h:531
void Print(const SCH_RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
Definition: sch_screen.cpp:854
bool IsReadOnly() const
Definition: sch_screen.h:146
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:118
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:316
bool m_zoomInitialized
Definition: sch_screen.h:661
bool FileExists() const
Definition: sch_screen.h:149
SPIN_STYLE GetLabelOrientationForPoint(const VECTOR2I &aPosition, SPIN_STYLE aDefaultOrientation, const SCH_SHEET_PATH *aSheet) const
Definition: sch_screen.cpp:515
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
bool IsModified() const
Check the entire hierarchy for any modifications.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
bool GetExcludedFromSim() const
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void clear()
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
wxString GetName() const
Definition: sch_sheet.h:107
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:173
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:181
Schematic symbol object.
Definition: sch_symbol.h:104
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:815
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:939
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:737
VECTOR2I GetPosition() const override
Definition: sch_text.h:141
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void BrightenItem(EDA_ITEM *aItem)
void UnbrightenItem(EDA_ITEM *aItem)
EDA_ITEM * Front() const
Definition: selection.h:172
int Size() const
Returns the number of selected parts.
Definition: selection.h:116
T * GetAppSettings(const wxString &aFilename)
Returns a handle to the a given settings by type If the settings have already been loaded,...
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
bool CollideEdge(const VECTOR2I &aPoint, VERTEX_INDEX *aClosestVertex=nullptr, int aClearance=0) const
Check whether aPoint collides with any edge of any of the contours of the polygon.
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
const SPICE_GENERATOR & SpiceGenerator() const
Definition: sim_model.h:435
std::vector< std::reference_wrapper< const SIM_MODEL_PIN > > GetPins() const
Definition: sim_model.cpp:748
virtual std::string ItemName(const SPICE_ITEM &aItem) const
Symbol library viewer main window.
The symbol library editor main window.
Symbol library viewer main window.
bool GetExcludedFromSim() const override
Definition: symbol.h:136
void AddTemplateFieldNames(const wxString &aSerializedFieldNames)
Add a serialized list of template field names.
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:169
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:168
@ REDRAW
Full drawing refresh.
Definition: tool_base.h:83
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition: tool_base.h:80
Generic, UI-independent tool event.
Definition: tool_event.h:167
Master controller class:
Definition: tool_manager.h:62
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:302
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:235
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void InitTools()
Initializes all registered tools.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: wx_infobar.cpp:304
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: wx_infobar.cpp:140
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:190
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: wx_infobar.cpp:294
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
Definition: common.cpp:422
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:130
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#define _HKI(x)
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define SCH_EDIT_FRAME_NAME
@ ID_IMPORT_NON_KICAD_SCH
Definition: eeschema_id.h:57
const wxAuiPaneInfo & defaultSchSelectionFilterPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultPropertiesPaneInfo(wxWindow *aWindow)
const wxAuiPaneInfo & defaultNetNavigatorPaneInfo()
const wxAuiPaneInfo & defaultDesignBlocksPaneInfo(wxWindow *aWindow)
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
KiCad executable names.
const wxString PCBNEW_EXE
@ FRAME_PCB_EDITOR
Definition: frame_type.h:42
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SCH
Definition: frame_type.h:34
@ FRAME_SIMULATOR
Definition: frame_type.h:38
@ FRAME_CVPCB
Definition: frame_type.h:52
@ FRAME_SYMBOL_CHOOSER
Definition: frame_type.h:37
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition: gestfich.cpp:143
static const std::string NetlistFileExtension
static const std::string 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 IPC API and its plugin system.
Definition: api_utils.cpp:26
@ ID_FILE_LIST_CLEAR
Definition: id.h:86
@ ID_EDA_SOCKET_EVENT
Definition: id.h:163
@ ID_EDA_SOCKET_EVENT_SERV
Definition: id.h:162
@ ID_FILEMAX
Definition: id.h:84
@ ID_FILE1
Definition: id.h:83
PROJECT & Prj()
Definition: kicad.cpp:597
KIID niluuid(0)
#define KICTL_CREATE
caller thinks requested project files may not exist.
Definition: kiway_player.h:76
@ LAYER_ERC_WARN
Definition: layer_ids.h:383
@ LAYER_ERC_EXCLUSION
Definition: layer_ids.h:385
@ LAYER_ERC_ERR
Definition: layer_ids.h:384
@ LAYER_OP_CURRENTS
Definition: layer_ids.h:404
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:391
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:367
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:403
@ MAIL_PCB_UPDATE
Definition: mail_type.h:46
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:54
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: unix/app.cpp:90
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: unix/app.cpp:79
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
SEVERITY
#define DIFF_SYMBOLS_DIALOG_NAME
wxDEFINE_EVENT(EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent)
#define CURRENT_TOOL(action)
SCH_CLEANUP_FLAGS
@ LOCAL_CLEANUP
@ GLOBAL_CLEANUP
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
const double IU_PER_MILS
Definition: base_units.h:77
The EE_TYPE struct provides a type-specific auto-range iterator to the RTree.
Definition: sch_rtree.h:192
std::string refName
Definition for symbol library class.
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ SCH_LINE_T
Definition: typeinfo.h:163
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:171
@ SCH_LABEL_T
Definition: typeinfo.h:167
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_RULE_AREA_T
Definition: typeinfo.h:170
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:173
@ SCH_TEXT_T
Definition: typeinfo.h:151
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:168
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691
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.