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 The 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>
107
108#ifdef KICAD_IPC_API
110#include <api/api_utils.h>
111#endif
112
113
114#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
115
116
117BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
120
121 EVT_SIZE( SCH_EDIT_FRAME::OnSize )
122
125
127
128 EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
129 EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
130
131 // Drop files event
132 EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
133END_EVENT_TABLE()
134
135
136wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
137wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
138
139
140SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
141 SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
143 m_ercDialog( nullptr ),
144 m_diffSymbolDialog( nullptr ),
145 m_symbolFieldsTableDialog( nullptr ),
146 m_netNavigator( nullptr ),
147 m_highlightedConnChanged( false ),
148 m_designBlocksPane( nullptr )
149{
150 m_maximizeByDefault = true;
151 m_schematic = new SCHEMATIC( nullptr );
152
153 m_showBorderAndTitleBlock = true; // true to show sheet references
154 m_supportsAutoSave = true;
155 m_syncingPcbToSchSelection = false;
156 m_aboutTitle = _HKI( "KiCad Schematic Editor" );
157 m_show_search = false;
158
159 m_findReplaceDialog = nullptr;
160
161 m_findReplaceData = std::make_unique<SCH_SEARCH_DATA>();
162
163 // Give an icon
164 wxIcon icon;
165 wxIconBundle icon_bundle;
166
167 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 48 ) );
168 icon_bundle.AddIcon( icon );
169 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 128 ) );
170 icon_bundle.AddIcon( icon );
171 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 256 ) );
172 icon_bundle.AddIcon( icon );
173 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
174 icon_bundle.AddIcon( icon );
175 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
176 icon_bundle.AddIcon( icon );
177
178 SetIcons( icon_bundle );
179
180 LoadSettings( eeconfig() );
181
182 // NB: also links the schematic to the loaded project
183 CreateScreens();
184
185 SCH_SHEET_PATH root;
186 root.push_back( &Schematic().Root() );
187 SetCurrentSheet( root );
188
189 setupTools();
190 setupUIConditions();
191 ReCreateMenuBar();
192 ReCreateHToolbar();
193 ReCreateVToolbar();
194 ReCreateOptToolbar();
195
196#ifdef KICAD_IPC_API
198 &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
199#endif
200
201 m_hierarchy = new HIERARCHY_PANE( this );
202
203 // Initialize common print setup dialog settings.
204 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
205 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
206 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
207 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
208
209 m_searchPane = new SCH_SEARCH_PANE( this );
210 m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
211
212 m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
213
214 m_selectionFilterPanel = new PANEL_SCH_SELECTION_FILTER( this );
215 m_designBlocksPane = new DESIGN_BLOCK_PANE( this, nullptr, m_designBlockHistoryList );
216
217 m_auimgr.SetManagedWindow( this );
218
219 CreateInfoBar();
220
221 // Fetch COPY of config as a lot of these initializations are going to overwrite our data.
222 EESCHEMA_SETTINGS::AUI_PANELS aui_cfg = eeconfig()->m_AuiPanels;
223 EESCHEMA_SETTINGS::APPEARANCE appearance_cfg = eeconfig()->m_Appearance;
224
225 // Rows; layers 4 - 6
226 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxS( "MainToolbar" ) )
227 .Top().Layer( 6 ) );
228
229 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
230 .Bottom().Layer( 6 ) );
231
232 // Columns; layers 1 - 3
233 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
234 .Caption( _( "Schematic Hierarchy" ) )
235 .Left().Layer( 3 ).Position( 1 )
236 .TopDockable( false )
237 .BottomDockable( false )
238 .CloseButton( true )
239 .MinSize( FromDIP( wxSize( 120, 60 ) ) )
240 .BestSize( FromDIP( wxSize( 200, 200 ) ) )
241 .FloatingSize( FromDIP( wxSize( 200, 200 ) ) )
242 .FloatingPosition( FromDIP( wxPoint( 50, 50 ) ) )
243 .Show( false ) );
244
245 m_auimgr.AddPane( m_propertiesPanel, defaultPropertiesPaneInfo( this ) );
246 m_auimgr.AddPane( m_selectionFilterPanel, defaultSchSelectionFilterPaneInfo( this ) );
247
248 m_auimgr.AddPane( m_designBlocksPane, defaultDesignBlocksPaneInfo( this ) );
249
250 m_auimgr.AddPane( createHighlightedNetNavigator(), defaultNetNavigatorPaneInfo() );
251
252 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( wxS( "OptToolbar" ) )
253 .Left().Layer( 2 ) );
254
255 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( wxS( "ToolsToolbar" ) )
256 .Right().Layer( 2 ) );
257
258 // Center
259 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
260 .Center() );
261
262 m_auimgr.AddPane( m_searchPane, EDA_PANE()
263 .Name( SearchPaneName() )
264 .Bottom()
265 .Caption( _( "Search" ) )
266 .PaneBorder( false )
267 .MinSize( FromDIP( wxSize( 180, 60 ) ) )
268 .BestSize( FromDIP( wxSize( 180, 100 ) ) )
269 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
270 .CloseButton( true )
271 .DestroyOnClose( false )
272 .Show( m_show_search ) );
273
274 FinishAUIInitialization();
275
276 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
277 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
278 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
279 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
280 wxAuiPaneInfo& designBlocksPane = m_auimgr.GetPane( DesignBlocksPaneName() );
281
282 hierarchy_pane.Show( aui_cfg.show_schematic_hierarchy );
283 netNavigatorPane.Show( aui_cfg.show_net_nav_panel );
284 propertiesPane.Show( aui_cfg.show_properties );
285 designBlocksPane.Show( aui_cfg.design_blocks_show );
286 updateSelectionFilterVisbility();
287
288 // The selection filter doesn't need to grow in the vertical direction when docked
289 selectionFilterPane.dock_proportion = 0;
290
291 if( aui_cfg.hierarchy_panel_float_width > 0 && aui_cfg.hierarchy_panel_float_height > 0 )
292 {
293 // Show at end, after positioning
294 hierarchy_pane.FloatingSize( aui_cfg.hierarchy_panel_float_width,
296 }
297
298 if( aui_cfg.net_nav_panel_float_size.GetWidth() > 0
299 && aui_cfg.net_nav_panel_float_size.GetHeight() > 0 )
300 {
301 netNavigatorPane.FloatingSize( aui_cfg.net_nav_panel_float_size );
302 netNavigatorPane.FloatingPosition( aui_cfg.net_nav_panel_float_pos );
303 }
304
305 if( aui_cfg.properties_panel_width > 0 )
306 SetAuiPaneSize( m_auimgr, propertiesPane, aui_cfg.properties_panel_width, -1 );
307
308 if( aui_cfg.schematic_hierarchy_float )
309 hierarchy_pane.Float();
310
311 if( aui_cfg.search_panel_height > 0
312 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_TOP
313 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
314 {
315 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
316 searchPane.Direction( aui_cfg.search_panel_dock_direction );
317 SetAuiPaneSize( m_auimgr, searchPane, -1, aui_cfg.search_panel_height );
318 }
319
320 else if( aui_cfg.search_panel_width > 0
321 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_LEFT
322 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
323 {
324 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
325 searchPane.Direction( aui_cfg.search_panel_dock_direction );
326 SetAuiPaneSize( m_auimgr, searchPane, aui_cfg.search_panel_width, -1 );
327 }
328
329 if( aui_cfg.float_net_nav_panel )
330 netNavigatorPane.Float();
331
332 if( aui_cfg.design_blocks_show )
333 SetAuiPaneSize( m_auimgr, designBlocksPane, aui_cfg.design_blocks_panel_docked_width, -1 );
334
335 if( aui_cfg.hierarchy_panel_docked_width > 0 )
336 {
337 // If the net navigator is not show, let the hierarchy navigator take all of the vertical
338 // space.
339 if( !aui_cfg.show_net_nav_panel )
340 {
341 SetAuiPaneSize( m_auimgr, hierarchy_pane, aui_cfg.hierarchy_panel_docked_width, -1 );
342 }
343 else
344 {
345 SetAuiPaneSize( m_auimgr, hierarchy_pane,
348
349 SetAuiPaneSize( m_auimgr, netNavigatorPane,
350 aui_cfg.net_nav_panel_docked_size.GetWidth(),
351 aui_cfg.net_nav_panel_docked_size.GetHeight() );
352 }
353
354 // wxAUI hack: force width by setting MinSize() and then Fixed()
355 // thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
356 hierarchy_pane.MinSize( aui_cfg.hierarchy_panel_docked_width, 60 );
357 hierarchy_pane.Fixed();
358 netNavigatorPane.MinSize( aui_cfg.net_nav_panel_docked_size.GetWidth(), 60 );
359 netNavigatorPane.Fixed();
360 m_auimgr.Update();
361
362 // now make it resizable again
363 hierarchy_pane.Resizable();
364 netNavigatorPane.Resizable();
365 m_auimgr.Update();
366
367 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
368 // back to minimum.
369 hierarchy_pane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
370 netNavigatorPane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
371 }
372 else
373 {
374 m_auimgr.Update();
375 }
376
377 resolveCanvasType();
378 SwitchCanvas( m_canvasType );
379
380 GetCanvas()->GetGAL()->SetAxesEnabled( false );
381
382 KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
383 static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
384
385 LoadProjectSettings();
386 LoadDrawingSheet();
387
388 view->SetLayerVisible( LAYER_ERC_ERR, appearance_cfg.show_erc_errors );
389 view->SetLayerVisible( LAYER_ERC_WARN, appearance_cfg.show_erc_warnings );
391 view->SetLayerVisible( LAYER_OP_VOLTAGES, appearance_cfg.show_op_voltages );
392 view->SetLayerVisible( LAYER_OP_CURRENTS, appearance_cfg.show_op_currents );
393
394 initScreenZoom();
395
396 m_hierarchy->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
397 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
398 this );
399 m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
400 m_netNavigator->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onResizeNetNavigator, this );
401
402 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
403 // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
404 Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
405
406 setupUnits( eeconfig() );
407
408 // Net list generator
409 DefaultExecFlags();
410
411 updateTitle();
412 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
413
414#ifdef KICAD_IPC_API
415 m_apiHandler = std::make_unique<API_HANDLER_SCH>( this );
416 Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
417#endif
418
419 // Default shutdown reason until a file is loaded
420 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
421
422 // Init for dropping files
424 DragAcceptFiles( true );
425
426 // Ensure the window is on top
427 Raise();
428
429 // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
430 // top-left corner of the canvas
431 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
432 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
433
434 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
435 Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
436 Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog,
437 this );
438}
439
440
442{
443 m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
444
445 // Ensure m_canvasType is up to date, to save it in config
447
448 SetScreen( nullptr );
449
450 if( m_schematic )
452
453 // Delete all items not in draw list before deleting schematic
454 // to avoid dangling pointers stored in these items
457
458 delete m_schematic;
459 m_schematic = nullptr;
460
461 // Close the project if we are standalone, so it gets cleaned up properly
462 if( Kiface().IsSingle() )
463 {
464 try
465 {
466 GetSettingsManager()->UnloadProject( &Prj(), false );
467 }
468 catch( const nlohmann::detail::type_error& e )
469 {
470 wxFAIL_MSG( wxString::Format( wxT( "Settings exception occurred: %s" ), e.what() ) );
471 }
472 }
473
474 delete m_hierarchy;
476}
477
478
480{
481 aEvent.Skip();
482
483 // 1st Call: Handle the size update during the first resize event.
485
486 // Defer the second size capture
487 CallAfter( [this]() {
489 } );
490}
491
492
494{
495 // Called when resizing the Hierarchy Navigator panel
496 // Store the current pane size
497 // It allows to retrieve the last defined pane size when switching between
498 // docked and floating pane state
499 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
500
501 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
502 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
503
504 if( cfg && m_hierarchy->IsShownOnScreen() )
505 {
506 cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
507 cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
508
509 // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
510 // width is > 0 (i.e. if its size is already set and has meaning)
511 // if it is floating, its size is not initialized (only floating_size is initialized)
512 // initializing hierarchy_pane.best_size is useful when switching to float pane and
513 // after switching to the docked pane, to retrieve the last docked pane width
514 if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
515 {
516 cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
517 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
518 }
519 }
520}
521
522
524{
525 // Create the manager and dispatcher & route draw panel events to the dispatcher
528 GetCanvas()->GetViewControls(), config(), this );
529 m_actions = new EE_ACTIONS();
531
532 // Register tools
552
553 // Run the selection tool, it is supposed to be always active
555
557}
558
559
561{
563
565 SCH_EDITOR_CONDITIONS cond( this );
566
567 wxASSERT( mgr );
568
569 auto hasElements =
570 [ this ] ( const SELECTION& aSel )
571 {
572 return GetScreen() &&
573 ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
574 };
575
576 auto searchPaneCond =
577 [this] ( const SELECTION& )
578 {
579 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
580 };
581
582 auto propertiesCond =
583 [this] ( const SELECTION& )
584 {
585 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
586 };
587
588 auto hierarchyNavigatorCond =
589 [ this ] ( const SELECTION& aSel )
590 {
591 return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
592 };
593
594 auto netNavigatorCond =
595 [ this ] (const SELECTION& aSel )
596 {
597 return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
598 };
599
600 auto designBlockCond =
601 [ this ] (const SELECTION& aSel )
602 {
603 return m_auimgr.GetPane( DesignBlocksPaneName() ).IsShown();
604 };
605
606 auto undoCond =
607 [ this ] (const SELECTION& aSel )
608 {
610 return true;
611
612 return GetUndoCommandCount() > 0;
613 };
614
615#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
616#define CHECK( x ) ACTION_CONDITIONS().Check( x )
617
619 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
621
622 mgr->SetConditions( EE_ACTIONS::showSearch, CHECK( searchPaneCond ) );
623 mgr->SetConditions( EE_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
624 mgr->SetConditions( EE_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
625 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
626 mgr->SetConditions( EE_ACTIONS::showDesignBlockPanel, CHECK( designBlockCond ) );
631 CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
632 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
633 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
634
636 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_FREE ) ) );
638 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_90 ) ) );
640 CHECK( cond.LineMode( LINE_MODE::LINE_MODE_45 ) ) );
641
642 mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
643 mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
644 mgr->SetConditions( ACTIONS::copyAsText, ENABLE( hasElements ) );
649 mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
650 mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
651 mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
652 mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
653
654 mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( hasElements ) );
655 mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( hasElements ) );
656 mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( hasElements ) );
657 mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( hasElements ) );
658
663
664 auto showHiddenPinsCond =
665 [this]( const SELECTION& )
666 {
667 return GetShowAllPins();
668 };
669
670 auto showHiddenFieldsCond =
671 [this]( const SELECTION& )
672 {
674 return cfg && cfg->m_Appearance.show_hidden_fields;
675 };
676
677 auto showDirectiveLabelsCond =
678 [this]( const SELECTION& )
679 {
681 return cfg && cfg->m_Appearance.show_directive_labels;
682 };
683
684 auto showERCErrorsCond =
685 [this]( const SELECTION& )
686 {
688 return cfg && cfg->m_Appearance.show_erc_errors;
689 };
690
691 auto showERCWarningsCond =
692 [this]( const SELECTION& )
693 {
695 return cfg && cfg->m_Appearance.show_erc_warnings;
696 };
697
698 auto showERCExclusionsCond =
699 [this]( const SELECTION& )
700 {
702 return cfg && cfg->m_Appearance.show_erc_exclusions;
703 };
704
705 auto markSimExclusionsCond =
706 [this]( const SELECTION& )
707 {
709 return cfg && cfg->m_Appearance.mark_sim_exclusions;
710 };
711
712 auto showOPVoltagesCond =
713 [this]( const SELECTION& )
714 {
716 return cfg && cfg->m_Appearance.show_op_voltages;
717 };
718
719 auto showOPCurrentsCond =
720 [this]( const SELECTION& )
721 {
723 return cfg && cfg->m_Appearance.show_op_currents;
724 };
725
726 auto showPinAltModeIconsCond =
727 [this]( const SELECTION& )
728 {
730 return cfg && cfg->m_Appearance.show_pin_alt_icons;
731 };
732
733 auto showAnnotateAutomaticallyCond =
734 [this]( const SELECTION& )
735 {
737 return cfg && cfg->m_AnnotatePanel.automatic;
738 };
739
740 auto remapSymbolsCondition =
741 [&]( const SELECTION& aSel )
742 {
743 SCH_SCREENS schematic( Schematic().Root() );
744
745 // The remapping can only be performed on legacy projects.
746 return schematic.HasNoFullyDefinedLibIds();
747 };
748
749 auto belowRootSheetCondition =
750 [this]( const SELECTION& aSel )
751 {
753 return navigateTool && navigateTool->CanGoUp();
754 };
755
756 mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
757
758 /* Some of these are bound by default to arrow keys which will get a different action if we
759 * disable the buttons. So always leave them enabled so the action is consistent.
760 * https://gitlab.com/kicad/code/kicad/-/issues/14783
761 mgr->SetConditions( EE_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
762 mgr->SetConditions( EE_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
763 mgr->SetConditions( EE_ACTIONS::navigateBack, ENABLE( navHistoryHsBackward ) );
764 */
765
766 mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
767 mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
768 mgr->SetConditions( EE_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
769 mgr->SetConditions( EE_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
770 mgr->SetConditions( EE_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
771 mgr->SetConditions( EE_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
772 mgr->SetConditions( EE_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
773 mgr->SetConditions( EE_ACTIONS::markSimExclusions, CHECK( markSimExclusionsCond ) );
774 mgr->SetConditions( EE_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
775 mgr->SetConditions( EE_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
776 mgr->SetConditions( EE_ACTIONS::togglePinAltIcons, CHECK( showPinAltModeIconsCond ) );
777 mgr->SetConditions( EE_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
779
783
784#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
785
815
816#undef CURRENT_TOOL
817#undef CHECK
818#undef ENABLE
819}
820
821
823{
824 // we cannot store a pointer to an item in the display list here since
825 // that item may be deleted, such as part of a line concatenation or other.
826 // So simply always keep a copy of the object which is to be repeated.
827
828 if( aItem )
829 {
830 m_items_to_repeat.clear();
831
832 AddCopyForRepeatItem( aItem );
833 }
834}
835
836
838{
839 // we cannot store a pointer to an item in the display list here since
840 // that item may be deleted, such as part of a line concatenation or other.
841 // So simply always keep a copy of the object which is to be repeated.
842
843 if( aItem )
844 {
845 std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate() ) );
846
847 // Clone() preserves the flags & parent, we want 'em cleared.
848 repeatItem->ClearFlags();
849 repeatItem->SetParent( nullptr );
850
851 m_items_to_repeat.emplace_back( std::move( repeatItem ) );
852 }
853}
854
855
857{
858 return Schematic().GetItem( aId );
859}
860
861
863{
865}
866
867
869{
870 return GetCurrentSheet().LastScreen();
871}
872
873
875{
876 return *m_schematic;
877}
878
879
881{
882 return GetCurrentSheet().Last()->GetName();
883}
884
885
887{
889}
890
891
893{
896
897 SCH_SHEET* rootSheet = new SCH_SHEET( m_schematic );
898 m_schematic->SetRoot( rootSheet );
899
900 SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
901 const_cast<KIID&>( rootSheet->m_Uuid ) = rootScreen->GetUuid();
902 m_schematic->Root().SetScreen( rootScreen );
903 SetScreen( Schematic().RootScreen() );
904
905
906 m_schematic->RootScreen()->SetFileName( wxEmptyString );
907
908 // Don't leave root page number empty
909 SCH_SHEET_PATH rootSheetPath;
910
911 rootSheetPath.push_back( rootSheet );
912 m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
913 rootSheetPath.SetPageNumber( wxT( "1" ) );
914
915 // Rehash sheetpaths in hierarchy since we changed the uuid.
917
918 if( GetScreen() == nullptr )
919 {
920 SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
921 SetScreen( screen );
922 }
923}
924
925
927{
928 return m_schematic->CurrentSheet();
929}
930
931
933{
934 if( aSheet != GetCurrentSheet() )
935 {
936 FocusOnItem( nullptr );
937
938 Schematic().SetCurrentSheet( aSheet );
939 GetCanvas()->DisplaySheet( aSheet.LastScreen() );
940 }
941}
942
943
945{
947
948 for( SCH_ITEM* item : screen->Items() )
949 item->ClearCaches();
950
951 for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
952 {
953 wxCHECK2( libSymbol.second, continue );
954 libSymbol.second->ClearCaches();
955 }
956
957 if( Schematic().Settings().m_IntersheetRefsShow )
959
960 FocusOnItem( nullptr );
961
962 GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
963
965 selectionTool->Reset( TOOL_BASE::REDRAW );
966
968}
969
970
971bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
972{
973 // Exit interactive editing
974 // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
975 // will cancel any drag currently in progress, but commit all changes from previous drags.
976 if( m_toolManager )
978
979 // Shutdown blocks must be determined and vetoed as early as possible
980 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
981 && IsContentModified() )
982 {
983 return false;
984 }
985
986 if( Kiface().IsSingle() )
987 {
988 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
989
990 if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
991 return false;
992
993 auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
994
995 if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
996 return false;
997
998 // SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
999 // sorry.
1000 auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
1001
1002 if( chooser && !chooser->Close() ) // Can close symbol chooser?
1003 return false;
1004 }
1005 else
1006 {
1007 auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1008
1009 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
1010 {
1011 if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
1012 return false;
1013 }
1014 }
1015
1016 if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
1017 return false;
1018
1020 && !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
1021 {
1022 return false;
1023 }
1024
1025 // We may have gotten multiple events; don't clean up twice
1026 if( !Schematic().IsValid() )
1027 return false;
1028
1029 if( IsContentModified() )
1030 {
1031 wxFileName fileName = Schematic().RootScreen()->GetFileName();
1032 wxString msg = _( "Save changes to '%s' before closing?" );
1033
1034 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1035 [&]() -> bool
1036 {
1037 return SaveProject();
1038 } ) )
1039 {
1040 return false;
1041 }
1042 }
1043
1044 return true;
1045}
1046
1047
1049{
1050 SCH_SHEET_LIST sheetlist = Schematic().Hierarchy();
1051
1052#ifdef KICAD_IPC_API
1053 Pgm().GetApiServer().DeregisterHandler( m_apiHandler.get() );
1054 wxTheApp->Unbind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED,
1055 &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
1056#endif
1057
1058 // Shutdown all running tools
1059 if( m_toolManager )
1061
1062 // Close modeless dialogs. They're trouble when they get destroyed after the frame.
1063 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
1064 Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
1065 Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE,
1067 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
1068 this );
1069 m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection,
1070 this );
1071
1072 // Close the find dialog and preserve its setting if it is displayed.
1074 {
1077
1078 m_findReplaceDialog->Destroy();
1079 m_findReplaceDialog = nullptr;
1080 }
1081
1082 if( m_diffSymbolDialog )
1083 {
1084 m_diffSymbolDialog->Destroy();
1085 m_diffSymbolDialog = nullptr;
1086 }
1087
1088 if( m_ercDialog )
1089 {
1090 m_ercDialog->Destroy();
1091 m_ercDialog = nullptr;
1092 }
1093
1095 {
1096 m_symbolFieldsTableDialog->Destroy();
1097 m_symbolFieldsTableDialog = nullptr;
1098 }
1099
1100 // Make sure local settings are persisted
1101 if( Prj().GetLocalSettings().ShouldAutoSave() )
1103
1104 // Shutdown all running tools
1105 if( m_toolManager )
1106 {
1108
1109 // prevent the canvas from trying to dispatch events during close
1110 GetCanvas()->SetEventDispatcher( nullptr );
1111 delete m_toolManager;
1112 m_toolManager = nullptr;
1113 }
1114
1115 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
1116
1117 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
1118 {
1119 hierarchy_pane.Show( false );
1120 m_auimgr.Update();
1121 }
1122
1123 SCH_SCREENS screens( Schematic().Root() );
1124 wxFileName fn;
1125
1126 for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
1127 {
1128 fn = Prj().AbsolutePath( screen->GetFileName() );
1129
1130 // Auto save file name is the normal file name prepended with FILEEXT::AutoSaveFilePrefix.
1131 fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() );
1132
1133 if( fn.IsFileWritable() )
1134 wxRemoveFile( fn.GetFullPath() );
1135 }
1136
1137 wxFileName tmpFn = Prj().GetProjectFullName();
1138 wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
1139
1140 if( autoSaveFileName.IsFileWritable() )
1141 wxRemoveFile( autoSaveFileName.GetFullPath() );
1142
1143 sheetlist.ClearModifyStatus();
1144
1145 wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
1146
1147 if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
1148 UpdateFileHistory( fileName );
1149
1150 Schematic().RootScreen()->Clear( true );
1151
1152 // all sub sheets are deleted, only the main sheet is usable
1154
1155 // Clear view before destroying schematic as repaints depend on schematic being valid
1156 SetScreen( nullptr );
1157
1158 Schematic().Reset();
1159
1160 // Prevents any rogue events from continuing (i.e. search panel tries to redraw)
1161 Show( false );
1162
1163 Destroy();
1164}
1165
1166
1168{
1169 return Schematic().ErcSettings().GetSeverity( aErrorCode );
1170}
1171
1172
1174{
1176
1177 if( GetScreen() )
1179
1180 m_autoSaveRequired = true;
1181
1182 if( GetCanvas() )
1183 GetCanvas()->Refresh();
1184
1185 if( !GetTitle().StartsWith( wxS( "*" ) ) )
1186 updateTitle();
1187}
1188
1189
1191{
1192 if( Kiface().IsSingle() )
1193 {
1194 DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
1195 " in stand-alone mode. In order to create/update PCBs from"
1196 " schematics, launch the KiCad shell and create a project." ) );
1197 return;
1198 }
1199
1200 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1201 wxEventBlocker blocker( this );
1202
1203 if( !frame )
1204 {
1205 wxFileName fn = Prj().GetProjectFullName();
1206 fn.SetExt( FILEEXT::PcbFileExtension );
1207
1208 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1209
1210 // If Kiway() cannot create the Pcbnew frame, it shows a error message, and
1211 // frame is null
1212 if( !frame )
1213 return;
1214
1215 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1216 }
1217
1218 if( !frame->IsVisible() )
1219 frame->Show( true );
1220
1221 // On Windows, Raise() does not bring the window on screen, when iconized
1222 if( frame->IsIconized() )
1223 frame->Iconize( false );
1224
1225 frame->Raise();
1226
1227 std::string payload;
1229}
1230
1231
1232void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator, bool aClear )
1233{
1234 m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
1236
1237 if( aRefreshNetNavigator )
1239}
1240
1241
1243{
1244 // Update only the hierarchy navigation tree labels.
1245 // The tree list is expected to be up to date
1247}
1248
1249
1251{
1253}
1254
1255
1257{
1258 wxString findString;
1259
1260 EE_SELECTION& selection = m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1261
1262 if( selection.Size() == 1 )
1263 {
1264 EDA_ITEM* front = selection.Front();
1265
1266 switch( front->Type() )
1267 {
1268 case SCH_SYMBOL_T:
1269 {
1270 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( front );
1271 findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() );
1272 break;
1273 }
1274
1275 case SCH_FIELD_T:
1276 findString = UnescapeString( static_cast<SCH_FIELD*>( front )->GetText() );
1277 break;
1278
1279 case SCH_LABEL_T:
1280 case SCH_GLOBAL_LABEL_T:
1281 case SCH_HIER_LABEL_T:
1282 case SCH_SHEET_PIN_T:
1283 findString = UnescapeString( static_cast<SCH_LABEL_BASE*>( front )->GetText() );
1284 break;
1285
1286 case SCH_TEXT_T:
1287 findString = UnescapeString( static_cast<SCH_TEXT*>( front )->GetText() );
1288
1289 if( findString.Contains( wxT( "\n" ) ) )
1290 findString = findString.Before( '\n' );
1291
1292 break;
1293
1294 default:
1295 break;
1296 }
1297 }
1298
1300 m_findReplaceDialog->Destroy();
1301
1303 this, static_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() ), wxDefaultPosition,
1304 wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
1305
1308 m_findReplaceDialog->Show( true );
1309}
1310
1311
1312void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
1313{
1314 // Prepare the infobar, since we don't know its state
1317
1318 m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
1319}
1320
1321
1323{
1324 m_infoBar->Dismiss();
1325}
1326
1327
1329{
1332
1333 m_findReplaceDialog->Destroy();
1334 m_findReplaceDialog = nullptr;
1335
1337}
1338
1339
1340void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
1341{
1342 wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
1343
1344 if( fn.size() )
1345 OpenProjectFiles( std::vector<wxString>( 1, fn ) );
1346}
1347
1348
1349void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
1350{
1352}
1353
1354
1356{
1357 // Only standalone mode can directly load a new document
1358 if( !Kiface().IsSingle() )
1359 return;
1360
1361 wxString pro_dir = m_mruPath;
1362
1363 wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
1365
1366 if( dlg.ShowModal() != wxID_CANCEL )
1367 {
1368 // Enforce the extension, wxFileDialog is inept.
1369 wxFileName create_me =
1371
1372 if( create_me.FileExists() )
1373 {
1374 wxString msg;
1375 msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
1376 DisplayError( this, msg );
1377 return ;
1378 }
1379
1380 // OpenProjectFiles() requires absolute
1381 wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
1382
1383 OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
1384 m_mruPath = create_me.GetPath();
1385 }
1386}
1387
1388
1390{
1391 // Only standalone mode can directly load a new document
1392 if( !Kiface().IsSingle() )
1393 return;
1394
1395 wxString pro_dir = m_mruPath;
1396 wxString wildcards = FILEEXT::AllSchematicFilesWildcard()
1398 + wxS( "|" ) + FILEEXT::LegacySchematicFileWildcard();
1399
1400 wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
1401 wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1402
1403 if( dlg.ShowModal() != wxID_CANCEL )
1404 {
1405 OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
1407 }
1408}
1409
1410
1412{
1413 wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
1414
1415 if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
1416 {
1417 kicad_board.SetExt( FILEEXT::PcbFileExtension );
1418 wxFileName legacy_board( kicad_board );
1419 legacy_board.SetExt( FILEEXT::LegacyPcbFileExtension );
1420 wxFileName& boardfn = legacy_board;
1421
1422 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1423 boardfn = kicad_board;
1424
1425 if( Kiface().IsSingle() )
1426 {
1427 ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
1428 }
1429 else
1430 {
1431 wxEventBlocker blocker(this);
1432 KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1433
1434 if( !frame )
1435 {
1436 frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1437
1438 // frame can be null if Cvpcb cannot be run. No need to show a warning
1439 // Kiway() generates the error messages
1440 if( !frame )
1441 return;
1442
1443 frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1444 }
1445
1446 if( !frame->IsVisible() )
1447 frame->Show( true );
1448
1449 // On Windows, Raise() does not bring the window on screen, when iconized
1450 if( frame->IsIconized() )
1451 frame->Iconize( false );
1452
1453 frame->Raise();
1454 }
1455 }
1456 else
1457 {
1458 // If we are running inside a project, it should be impossible for this case to happen
1459 wxASSERT( Kiface().IsSingle() );
1461 }
1462}
1463
1464
1466{
1467 wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1468 fn.SetExt( FILEEXT::NetlistFileExtension );
1469
1470 if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1471 return;
1472
1473 try
1474 {
1475 KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1476
1477 if( !player )
1478 {
1479 player = Kiway().Player( FRAME_CVPCB, true );
1480
1481 // player can be null if Cvpcb cannot be run. No need to show a warning
1482 // Kiway() generates the error messages
1483 if( !player )
1484 return;
1485
1486 player->Show( true );
1487 }
1488
1489 // Ensure the netlist (mainly info about symbols) is up to date
1492
1493 player->Raise();
1494 }
1495 catch( const IO_ERROR& )
1496 {
1497 DisplayError( this, _( "Could not open CvPcb" ) );
1498 }
1499}
1500
1501
1502void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1503{
1504 if( event.GetId() == wxID_EXIT )
1505 Kiway().OnKiCadExit();
1506
1507 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1508 Close( false );
1509}
1510
1511
1513{
1514 wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1515 const SCH_RENDER_SETTINGS* cfg = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
1517
1518 cfg->GetPrintDC()->SetBackground( wxBrush( bg.ToColour() ) );
1519 cfg->GetPrintDC()->Clear();
1520
1521 cfg->GetPrintDC()->SetLogicalFunction( wxCOPY );
1522 GetScreen()->Print( cfg );
1523 PrintDrawingSheet( cfg, GetScreen(), Schematic().GetProperties(), schIUScale.IU_PER_MILS,
1524 fileName );
1525}
1526
1527
1529{
1531 SIM_LIB_MGR simLibMgr( &Prj() );
1532 NULL_REPORTER devnull;
1533
1534 // Patch for bug early in V7.99 dev
1535 if( settings.m_OPO_VRange.EndsWith( 'A' ) )
1536 settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
1537
1538 // Update items which may have ${OP} text variables
1539 //
1541 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1542 {
1543 int flags = 0;
1544
1545 auto invalidateTextVars =
1546 [&flags]( EDA_TEXT* text )
1547 {
1548 if( text->HasTextVars() )
1549 {
1550 text->ClearRenderCache();
1551 text->ClearBoundingBoxCache();
1553 }
1554 };
1555
1556 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1557 {
1558 item->RunOnChildren(
1559 [&invalidateTextVars]( SCH_ITEM* aChild )
1560 {
1561 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
1562 invalidateTextVars( text );
1563 } );
1564 }
1565
1566 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1567 invalidateTextVars( text );
1568
1569 return flags;
1570 } );
1571
1572 // Update OP overlay items
1573 //
1574 for( SCH_ITEM* item : GetScreen()->Items() )
1575 {
1577 continue;
1578
1579 if( item->Type() == SCH_LINE_T )
1580 {
1581 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1582
1583 if( !line->GetOperatingPoint().IsEmpty() )
1584 GetCanvas()->GetView()->Update( line );
1585
1586 line->SetOperatingPoint( wxEmptyString );
1587
1588 // update value from netlist, below
1589 }
1590 else if( item->Type() == SCH_SYMBOL_T )
1591 {
1592 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1593 wxString ref = symbol->GetRef( &GetCurrentSheet() );
1594 std::vector<SCH_PIN*> pins = symbol->GetPins( &GetCurrentSheet() );
1595
1596 // Power symbols and other symbols which have the reference starting with "#" are
1597 // not included in simulation
1598 if( ref.StartsWith( '#' ) || symbol->GetExcludedFromSim() )
1599 continue;
1600
1601 for( SCH_PIN* pin : pins )
1602 {
1603 if( !pin->GetOperatingPoint().IsEmpty() )
1604 GetCanvas()->GetView()->Update( pin );
1605
1606 pin->SetOperatingPoint( wxEmptyString );
1607 }
1608
1609 if( pins.size() == 2 )
1610 {
1611 wxString op = m_schematic->GetOperatingPoint( ref, settings.m_OPO_IPrecision,
1612 settings.m_OPO_IRange );
1613
1614 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1615 {
1616 pins[0]->SetOperatingPoint( op );
1617 GetCanvas()->GetView()->Update( symbol );
1618 }
1619 }
1620 else
1621 {
1622 SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol,
1623 devnull ).model;
1624
1625 SPICE_ITEM spiceItem;
1626 spiceItem.refName = ref;
1627 ref = model.SpiceGenerator().ItemName( spiceItem );
1628
1629 for( const auto& modelPin : model.GetPins() )
1630 {
1631 SCH_PIN* symbolPin = symbol->GetPin( modelPin.get().symbolPinNumber );
1632 wxString signalName = ref + wxS( ":" ) + modelPin.get().modelPinName;
1633 wxString op = m_schematic->GetOperatingPoint( signalName,
1634 settings.m_OPO_IPrecision,
1635 settings.m_OPO_IRange );
1636
1637 if( symbolPin && !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1638 {
1639 symbolPin->SetOperatingPoint( op );
1640 GetCanvas()->GetView()->Update( symbol );
1641 }
1642 }
1643 }
1644 }
1645 }
1646
1647 for( const auto& [ key, subgraphList ] : m_schematic->m_connectionGraph->GetNetMap() )
1648 {
1649 wxString op = m_schematic->GetOperatingPoint( key.Name, settings.m_OPO_VPrecision,
1650 settings.m_OPO_VRange );
1651
1652 if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
1653 {
1654 for( CONNECTION_SUBGRAPH* subgraph : subgraphList )
1655 {
1656 SCH_LINE* longestWire = nullptr;
1657 double length = 0.0;
1658
1659 if( subgraph->GetSheet().GetExcludedFromSim() )
1660 continue;
1661
1662 for( SCH_ITEM* item : subgraph->GetItems() )
1663 {
1664 if( item->Type() == SCH_LINE_T )
1665 {
1666 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1667
1668 if( line->IsWire() && line->GetLength() > length )
1669 {
1670 longestWire = line;
1671 length = line->GetLength();
1672 }
1673 }
1674 }
1675
1676 if( longestWire )
1677 {
1678 longestWire->SetOperatingPoint( op );
1679 GetCanvas()->GetView()->Update( longestWire );
1680 }
1681 }
1682 }
1683 }
1684}
1685
1686
1688{
1689 if( aItem->Type() == SCH_GLOBAL_LABEL_T || aItem->Type() == SCH_HIER_LABEL_T )
1690 {
1691 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
1692
1693 if( label->AutoRotateOnPlacement() )
1694 {
1695 SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
1696 label->GetSpinStyle(),
1697 &GetCurrentSheet() );
1698
1699 if( spin != label->GetSpinStyle() )
1700 {
1701 label->SetSpinStyle( spin );
1702
1703 for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1704 {
1705 SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
1706
1707 if( otherLabel != label && otherLabel->GetText() == label->GetText() )
1708 otherLabel->AutoplaceFields( aScreen, AUTOPLACE_AUTO );
1709 }
1710 }
1711 }
1712 }
1713}
1714
1715
1717{
1718 SCH_SCREEN* screen = GetScreen();
1719
1720 wxCHECK( screen, /* void */ );
1721
1722 wxString title;
1723
1724 if( !screen->GetFileName().IsEmpty() )
1725 {
1726 wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1727 bool readOnly = false;
1728 bool unsaved = false;
1729
1730 if( fn.IsOk() && screen->FileExists() )
1731 readOnly = screen->IsReadOnly();
1732 else
1733 unsaved = true;
1734
1735 if( IsContentModified() )
1736 title = wxT( "*" );
1737
1738 title += fn.GetName();
1739
1740 wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
1741
1742 if( sheetPath != title )
1743 title += wxString::Format( wxT( " [%s]" ), sheetPath );
1744
1745 if( readOnly )
1746 title += wxS( " " ) + _( "[Read Only]" );
1747
1748 if( unsaved )
1749 title += wxS( " " ) + _( "[Unsaved]" );
1750 }
1751 else
1752 {
1753 title = _( "[no schematic loaded]" );
1754 }
1755
1756 title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1757
1758 SetTitle( title );
1759}
1760
1761
1763{
1765 GetScreen()->m_zoomInitialized = true;
1766}
1767
1768
1770{
1771 wxString highlightedConn = GetHighlightedConnection();
1772 bool hasHighlightedConn = !highlightedConn.IsEmpty();
1773 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1775 SCH_COMMIT localCommit( m_toolManager );
1776
1777 if( !aCommit )
1778 aCommit = &localCommit;
1779
1780 PROF_TIMER timer;
1781
1782 // Ensure schematic graph is accurate
1783 if( aCleanupFlags == LOCAL_CLEANUP )
1784 {
1785 SchematicCleanUp( aCommit, GetScreen() );
1786 }
1787 else if( aCleanupFlags == GLOBAL_CLEANUP )
1788 {
1789 for( const SCH_SHEET_PATH& sheet : list )
1790 SchematicCleanUp( aCommit, sheet.LastScreen() );
1791 }
1792
1793 timer.Stop();
1794 wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1795
1796 if( settings.m_IntersheetRefsShow )
1798
1799 std::function<void( SCH_ITEM* )> changeHandler =
1800 [&]( SCH_ITEM* aChangedItem ) -> void
1801 {
1802 GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1803
1804 SCH_CONNECTION* connection = aChangedItem->Connection();
1805
1807 return;
1808
1809 if( !hasHighlightedConn )
1810 {
1811 // No highlighted connection, but connectivity has changed, so refresh
1812 // the list of all nets
1814 }
1815 else if( connection
1816 && ( connection->Name() == highlightedConn
1817 || connection->HasDriverChanged() ) )
1818 {
1820 }
1821 };
1822
1823 if( !ADVANCED_CFG::GetCfg().m_IncrementalConnectivity || aCleanupFlags == GLOBAL_CLEANUP
1824 || m_undoList.m_CommandsList.empty()|| Schematic().ConnectionGraph()->IsMinor() )
1825 {
1826 // Clear all resolved netclass caches in case labels have changed
1827 Prj().GetProjectFile().NetSettings()->ClearAllCaches();
1828
1829 // Update all rule areas so we can cascade implied connectivity changes
1830 std::unordered_set<SCH_SCREEN*> all_screens;
1831
1832 for( const SCH_SHEET_PATH& path : list )
1833 all_screens.insert( path.LastScreen() );
1834
1835 SCH_RULE_AREA::UpdateRuleAreasInScreens( all_screens, GetCanvas()->GetView() );
1836
1837 // Recalculate all connectivity
1838 Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
1839 }
1840 else
1841 {
1842 struct CHANGED_ITEM
1843 {
1844 SCH_ITEM* item;
1845 SCH_ITEM* linked_item;
1846 SCH_SCREEN* screen;
1847 };
1848
1849 PICKED_ITEMS_LIST* changed_list = m_undoList.m_CommandsList.back();
1850
1851 // Final change sets
1852 std::set<SCH_ITEM*> changed_items;
1853 std::set<VECTOR2I> pts;
1854 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> item_paths;
1855
1856 // Working change sets
1857 std::unordered_set<SCH_SCREEN*> changed_screens;
1858 std::set<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> changed_rule_areas;
1859 std::vector<CHANGED_ITEM> changed_connectable_items;
1860
1861 // Lambda to add an item to the connectivity update sets
1862 auto addItemToChangeSet = [&changed_items, &pts, &item_paths]( CHANGED_ITEM itemData )
1863 {
1864 std::vector<SCH_SHEET_PATH>& paths = itemData.screen->GetClientSheetPaths();
1865
1866 std::vector<VECTOR2I> tmp_pts = itemData.item->GetConnectionPoints();
1867 pts.insert( tmp_pts.begin(), tmp_pts.end() );
1868 changed_items.insert( itemData.item );
1869
1870 for( SCH_SHEET_PATH& path : paths )
1871 item_paths.insert( std::make_pair( path, itemData.item ) );
1872
1873 if( !itemData.linked_item || !itemData.linked_item->IsConnectable() )
1874 return;
1875
1876 tmp_pts = itemData.linked_item->GetConnectionPoints();
1877 pts.insert( tmp_pts.begin(), tmp_pts.end() );
1878 changed_items.insert( itemData.linked_item );
1879
1880 // We have to directly add the pins here because the link may not exist on the schematic
1881 // anymore and so won't be picked up by GetScreen()->Items().Overlapping() below.
1882 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( itemData.linked_item ) )
1883 {
1884 std::vector<SCH_PIN*> pins = symbol->GetPins();
1885 changed_items.insert( pins.begin(), pins.end() );
1886 }
1887
1888 for( SCH_SHEET_PATH& path : paths )
1889 item_paths.insert( std::make_pair( path, itemData.linked_item ) );
1890 };
1891
1892 // Get all changed connectable items and determine all changed screens
1893 for( unsigned ii = 0; ii < changed_list->GetCount(); ++ii )
1894 {
1895 switch( changed_list->GetPickedItemStatus( ii ) )
1896 {
1897 // Only care about changed, new, and deleted items, the other
1898 // cases are not connectivity-related
1899 case UNDO_REDO::CHANGED:
1900 case UNDO_REDO::NEWITEM:
1901 case UNDO_REDO::DELETED:
1902 break;
1903
1904 default:
1905 continue;
1906 }
1907
1908 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItem( ii ) );
1909
1910 if( item )
1911 {
1912 SCH_SCREEN* screen =
1913 static_cast<SCH_SCREEN*>( changed_list->GetScreenForItem( ii ) );
1914 changed_screens.insert( screen );
1915
1916 if( item->Type() == SCH_RULE_AREA_T )
1917 {
1918 SCH_RULE_AREA* ruleArea = static_cast<SCH_RULE_AREA*>( item );
1919
1920 // Clear item and directive associations for this rule area
1921 ruleArea->ResetDirectivesAndItems( GetCanvas()->GetView() );
1922
1923 changed_rule_areas.insert( { ruleArea, screen } );
1924 }
1925 else if( item->IsConnectable() )
1926 {
1927 SCH_ITEM* linked_item =
1928 dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItemLink( ii ) );
1929 changed_connectable_items.push_back( { item, linked_item, screen } );
1930 }
1931 }
1932 }
1933
1934 // Update rule areas in changed screens to propagate any directive connectivity changes
1935 std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> forceUpdateRuleAreas =
1936 SCH_RULE_AREA::UpdateRuleAreasInScreens( changed_screens, GetCanvas()->GetView() );
1937
1938 std::for_each( forceUpdateRuleAreas.begin(), forceUpdateRuleAreas.end(),
1939 [&]( std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& updatedRuleArea )
1940 {
1941 changed_rule_areas.insert( updatedRuleArea );
1942 } );
1943
1944 // If a SCH_RULE_AREA was changed, we need to add all past and present contained items to
1945 // update their connectivity
1946 for( const std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& changedRuleArea : changed_rule_areas )
1947 {
1948 for( SCH_ITEM* containedItem :
1949 changedRuleArea.first->GetPastAndPresentContainedItems() )
1950 {
1951 addItemToChangeSet( { containedItem, nullptr, changedRuleArea.second } );
1952 }
1953 }
1954
1955 // Add all changed items, and associated items, to the change set
1956 for( CHANGED_ITEM& changed_item_data : changed_connectable_items )
1957 {
1958 addItemToChangeSet( changed_item_data );
1959
1960 // If a SCH_DIRECTIVE_LABEL was changed which is attached to a SCH_RULE_AREA, we need
1961 // to add the contained items to the change set to force update of their connectivity
1962 if( changed_item_data.item->Type() == SCH_DIRECTIVE_LABEL_T )
1963 {
1964 const std::vector<VECTOR2I> labelConnectionPoints =
1965 changed_item_data.item->GetConnectionPoints();
1966
1967 EE_RTREE::EE_TYPE candidateRuleAreas =
1968 changed_item_data.screen->Items().Overlapping(
1969 SCH_RULE_AREA_T, changed_item_data.item->GetBoundingBox() );
1970
1971 for( SCH_ITEM* candidateRuleArea : candidateRuleAreas )
1972 {
1973 SCH_RULE_AREA* ruleArea = static_cast<SCH_RULE_AREA*>( candidateRuleArea );
1974 std::vector<SHAPE*> borderShapes = ruleArea->MakeEffectiveShapes( true );
1975
1976 if( ruleArea->GetPolyShape().CollideEdge( labelConnectionPoints[0], nullptr,
1977 5 ) )
1978 {
1979 for( SCH_ITEM* containedItem : ruleArea->GetPastAndPresentContainedItems() )
1980 addItemToChangeSet(
1981 { containedItem, nullptr, changed_item_data.screen } );
1982 }
1983 }
1984 }
1985 }
1986
1987 for( const VECTOR2I& pt: pts )
1988 {
1989 for( SCH_ITEM* item : GetScreen()->Items().Overlapping( pt ) )
1990 {
1991 // Leave this check in place. Overlapping items are not necessarily connectable.
1992 if( !item->IsConnectable() )
1993 continue;
1994
1995 if( item->Type() == SCH_LINE_T )
1996 {
1997 if( item->HitTest( pt ) )
1998 changed_items.insert( item );
1999 }
2000 else if( item->Type() == SCH_SYMBOL_T && item->IsConnected( pt ) )
2001 {
2002 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
2003 std::vector<SCH_PIN*> pins = symbol->GetPins();
2004
2005 changed_items.insert( pins.begin(), pins.end() );
2006 }
2007 else if( item->Type() == SCH_SHEET_T )
2008 {
2009 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
2010
2011 wxCHECK2( sheet, continue );
2012
2013 std::vector<SCH_SHEET_PIN*> sheetPins = sheet->GetPins();
2014 changed_items.insert( sheetPins.begin(), sheetPins.end() );
2015 }
2016 else
2017 {
2018 if( item->IsConnected( pt ) )
2019 changed_items.insert( item );
2020 }
2021 }
2022 }
2023
2024 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> all_items =
2025 Schematic().ConnectionGraph()->ExtractAffectedItems( changed_items );
2026
2027 all_items.insert( item_paths.begin(), item_paths.end() );
2028
2029 CONNECTION_GRAPH new_graph( &Schematic() );
2030
2031 new_graph.SetLastCodes( Schematic().ConnectionGraph() );
2032
2033 std::shared_ptr<NET_SETTINGS> netSettings = Prj().GetProjectFile().NetSettings();
2034
2035 std::set<wxString> affectedNets;
2036
2037 for( auto&[ path, item ] : all_items )
2038 {
2039 wxCHECK2( item, continue );
2040 item->SetConnectivityDirty();
2041 SCH_CONNECTION* conn = item->Connection();
2042
2043 if( conn )
2044 {
2045 affectedNets.insert( conn->Name() );
2046 }
2047 }
2048
2049 // Reset resolved netclass cache for this connection
2050 for( const wxString& netName : affectedNets )
2051 netSettings->ClearCacheForNet( netName );
2052
2053 new_graph.Recalculate( list, false, &changeHandler );
2054 Schematic().ConnectionGraph()->Merge( new_graph );
2055 }
2056
2058 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
2059 {
2060 int flags = 0;
2061 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
2062 SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
2063
2064 auto invalidateTextVars =
2065 [&flags]( EDA_TEXT* text )
2066 {
2067 if( text->HasTextVars() )
2068 {
2069 text->ClearRenderCache();
2070 text->ClearBoundingBoxCache();
2072 }
2073 };
2074
2075 if( connection && connection->HasDriverChanged() )
2076 {
2077 connection->ClearDriverChanged();
2078 flags |= KIGFX::REPAINT;
2079 }
2080
2081 if( item )
2082 {
2083 item->RunOnChildren(
2084 [&invalidateTextVars]( SCH_ITEM* aChild )
2085 {
2086 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
2087 invalidateTextVars( text );
2088 } );
2089
2090 if( flags & KIGFX::GEOMETRY )
2091 GetScreen()->Update( item, false ); // Refresh RTree
2092 }
2093
2094 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
2095 invalidateTextVars( text );
2096
2097 return flags;
2098 } );
2099
2101 || !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
2102 {
2106 }
2107
2108 if( !localCommit.Empty() )
2109 localCommit.Push( _( "Schematic Cleanup" ) );
2110}
2111
2112
2114{
2116 {
2117 for( SCH_FIELD& field : label->GetFields() )
2118 field.ClearBoundingBoxCache();
2119
2120 label->ClearBoundingBoxCache();
2121 GetCanvas()->GetView()->Update( label );
2122 } );
2123}
2124
2125
2127{
2129
2131}
2132
2133
2134std::unique_ptr<GRID_HELPER> SCH_EDIT_FRAME::MakeGridHelper()
2135{
2136 return std::make_unique<EE_GRID_HELPER>( m_toolManager );
2137}
2138
2139
2141{
2143
2144 SCHEMATIC_SETTINGS& settings = Schematic().Settings();
2145
2147
2149
2151 EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
2154
2155 KIGFX::VIEW* view = GetCanvas()->GetView();
2161
2163
2164 settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
2165
2166 if( !cfg->m_Drawing.field_names.IsEmpty() )
2168
2170
2171 for( SCH_ITEM* item : screen->Items() )
2172 item->ClearCaches();
2173
2174 for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
2175 libSymbol->ClearCaches();
2176
2178
2180 Layout();
2181 SendSizeEvent();
2182}
2183
2184
2186{
2187 // Store the current zoom level into the current screen before calling
2188 // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
2190
2191 // Rebuild the sheet view (draw area and any other items):
2193}
2194
2195
2197{
2198 // call my base class
2200
2201 // tooltips in toolbars
2203
2204 // For some obscure reason, the AUI manager hides the first modified pane.
2205 // So force show panes
2206 wxAuiPaneInfo& design_blocks_pane_info = m_auimgr.GetPane( m_designBlocksPane );
2207 bool panel_shown = design_blocks_pane_info.IsShown();
2208 design_blocks_pane_info.Caption( _( "Design Blocks" ) );
2209 design_blocks_pane_info.Show( panel_shown );
2210
2211 m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
2212 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
2213 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
2214 m_auimgr.GetPane( m_designBlocksPane ).Caption( _( "Design Blocks" ) );
2215 m_auimgr.Update();
2217
2218 // status bar
2220
2221 updateTitle();
2222
2223 // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
2224 // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
2225 // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
2226 // toolbar to update correctly.
2227#if defined( __WXMSW__ )
2228 PostSizeEvent();
2229#endif
2230}
2231
2232
2234{
2235 if( !GetHighlightedConnection().IsEmpty() )
2236 {
2237 SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
2239 }
2240 else
2241 {
2242 SetStatusText( wxT( "" ) );
2243 }
2244}
2245
2246
2248{
2249 if( m_toolManager )
2251
2252 SCH_BASE_FRAME::SetScreen( aScreen );
2253 GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
2254
2255 if( m_toolManager )
2257}
2258
2259
2260const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
2261{
2262 BOX2I bBoxDoc;
2263
2264 if( aIncludeAllVisible )
2265 {
2266 // Get the whole page size and return that
2269 bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
2270 }
2271 else
2272 {
2273 // Get current drawing-sheet in a form we can compare to an EDA_ITEM
2275 EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
2276
2277 // Calc the bounding box of all items on screen except the page border
2278 for( EDA_ITEM* item : GetScreen()->Items() )
2279 {
2280 if( item != dsAsItem ) // Ignore the drawing-sheet itself
2281 bBoxDoc.Merge( item->GetBoundingBox() );
2282 }
2283 }
2284
2285 return bBoxDoc;
2286}
2287
2288
2290{
2291 return Schematic().Hierarchy().IsModified();
2292}
2293
2294
2296{
2297 EESCHEMA_SETTINGS* cfg = eeconfig();
2298 return cfg && cfg->m_Appearance.show_hidden_pins;
2299}
2300
2301
2303{
2304 static KIID lastBrightenedItemID( niluuid );
2305
2307 SCH_ITEM* lastItem = Schematic().GetItem( lastBrightenedItemID, &dummy );
2308
2309 if( lastItem && lastItem != aItem )
2310 {
2311 lastItem->ClearBrightened();
2312
2313 UpdateItem( lastItem );
2314 lastBrightenedItemID = niluuid;
2315 }
2316
2317 if( aItem )
2318 {
2319 if( !aItem->IsBrightened() )
2320 {
2321 aItem->SetBrightened();
2322
2323 UpdateItem( aItem );
2324 lastBrightenedItemID = aItem->m_Uuid;
2325 }
2326
2328 }
2329}
2330
2331
2333{
2334 return Schematic().GetFileName();
2335}
2336
2337
2339{
2340 return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
2341}
2342
2343
2344void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2345{
2346 if( IsShown() )
2347 {
2348 // We only need this until the frame is done resizing and the final client size is
2349 // established.
2350 Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
2352 }
2353
2354 // Skip() is called in the base class.
2355 EDA_DRAW_FRAME::OnSize( aEvent );
2356}
2357
2358
2360 const KIID& aSchematicSymbolUUID )
2361{
2362 SCH_SHEET_PATH principalPath;
2363 SCH_SHEET_LIST sheets = Schematic().Hierarchy();
2364 SCH_ITEM* item = sheets.GetItem( aSchematicSymbolUUID, &principalPath );
2365 SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
2366 SCH_COMMIT commit( m_toolManager );
2367
2368 if( !principalSymbol )
2369 return;
2370
2371 wxString principalRef;
2372
2373 if( principalSymbol->IsAnnotated( &principalPath ) )
2374 principalRef = principalSymbol->GetRef( &principalPath, false );
2375
2376 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
2377
2378 for( const SCH_SHEET_PATH& path : sheets )
2379 {
2380 for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
2381 {
2382 SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
2383
2384 if( candidateSymbol == principalSymbol
2385 || ( candidateSymbol->IsAnnotated( &path )
2386 && candidateSymbol->GetRef( &path, false ) == principalRef ) )
2387 {
2388 allUnits.emplace_back( candidateSymbol, path );
2389 }
2390 }
2391 }
2392
2393 for( auto& [ unit, path ] : allUnits )
2394 {
2395 // This needs to be done before the LIB_SYMBOL is changed to prevent stale
2396 // library symbols in the schematic file.
2397 path.LastScreen()->Remove( unit );
2398
2399 if( !unit->IsNew() )
2400 commit.Modify( unit, path.LastScreen() );
2401
2402 unit->SetLibSymbol( aSymbol.Flatten().release() );
2403 unit->UpdateFields( &GetCurrentSheet(),
2404 true, /* update style */
2405 true, /* update ref */
2406 true, /* update other fields */
2407 false, /* reset ref */
2408 false /* reset other fields */ );
2409
2410 path.LastScreen()->Append( unit );
2411 GetCanvas()->GetView()->Update( unit );
2412 }
2413
2414 if( !commit.Empty() )
2415 commit.Push( _( "Save Symbol to Schematic" ) );
2416}
2417
2418
2419void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
2420{
2421 SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
2422
2423 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
2424 sch_item->ClearCaches();
2425}
2426
2427
2429{
2430 wxCHECK( m_toolManager, /* void */ );
2431
2435
2436 wxCHECK( screen, /* void */ );
2437
2439
2440 SCH_BASE_FRAME::SetScreen( screen );
2441
2442 SetSheetNumberAndCount(); // will also update CurrentScreen()'s sheet number info
2443
2445
2446 // update the references, units, and intersheet-refs
2448
2449 // dangling state can also have changed if different units with different pin locations are
2450 // used
2453
2455
2456 wxCHECK( selectionTool, /* void */ );
2457
2458 auto visit =
2459 [&]( EDA_ITEM* item )
2460 {
2462 && !m_findReplaceData->findString.IsEmpty()
2463 && item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
2464 {
2465 item->SetForceVisible( true );
2466 selectionTool->BrightenItem( item );
2467 }
2468 else if( item->IsBrightened() )
2469 {
2470 item->SetForceVisible( false );
2471 selectionTool->UnbrightenItem( item );
2472 }
2473 };
2474
2475 for( SCH_ITEM* item : screen->Items() )
2476 {
2477 visit( item );
2478
2479 item->RunOnChildren(
2480 [&]( SCH_ITEM* aChild )
2481 {
2482 visit( aChild );
2483 } );
2484 }
2485
2486 if( !screen->m_zoomInitialized )
2487 {
2489 }
2490 else
2491 {
2492 // Set zoom to last used in this screen
2493 GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
2494 GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
2495 }
2496
2497 updateTitle();
2498
2499 HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
2500
2501 // Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
2503
2505
2506 wxCHECK( editTool, /* void */ );
2507
2509 editTool->UpdateNetHighlighting( dummy );
2510
2512
2514}
2515
2516
2518{
2519 if( !m_diffSymbolDialog )
2521 _( "Compare Symbol with Library" ) );
2522
2523 return m_diffSymbolDialog;
2524}
2525
2526
2527void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
2528{
2529 if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
2530 {
2531 m_diffSymbolDialog->Destroy();
2532 m_diffSymbolDialog = nullptr;
2533 }
2534}
2535
2536
2538{
2539 if( !m_ercDialog )
2540 m_ercDialog = new DIALOG_ERC( this );
2541
2542 return m_ercDialog;
2543}
2544
2545
2546void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
2547{
2548 if( m_ercDialog )
2549 {
2550 m_ercDialog->Destroy();
2551 m_ercDialog = nullptr;
2552 }
2553}
2554
2555
2557{
2560
2562}
2563
2564
2566{
2568 {
2569 m_symbolFieldsTableDialog->Destroy();
2570 m_symbolFieldsTableDialog = nullptr;
2571 }
2572}
2573
2574
2575void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
2576{
2577 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2578 aListener );
2579
2580 // Don't add duplicate listeners.
2581 if( it == m_schematicChangeListeners.end() )
2582 m_schematicChangeListeners.push_back( aListener );
2583}
2584
2585
2587{
2588 auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
2589 aListener );
2590
2591 // Don't add duplicate listeners.
2592 if( it != m_schematicChangeListeners.end() )
2593 m_schematicChangeListeners.erase( it );
2594}
2595
2596
2598{
2599 m_netNavigator = new wxTreeCtrl( this, wxID_ANY, wxPoint( 0, 0 ),
2600 FromDIP( wxSize( 160, 250 ) ),
2601 wxTR_DEFAULT_STYLE | wxNO_BORDER );
2602
2603 return m_netNavigator;
2604}
2605
2606
2607void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection,
2608 const NET_NAVIGATOR_ITEM_DATA* aSelection )
2609{
2610 bool refreshNetNavigator = aConnection != m_highlightedConn;
2611
2612 m_highlightedConn = aConnection;
2613
2614 if( refreshNetNavigator )
2615 RefreshNetNavigator( aSelection );
2616}
2617
2618
2620{
2621 if( m_netNavigator )
2622 {
2623 NET_NAVIGATOR_ITEM_DATA itemData;
2624 wxTreeItemId selection = m_netNavigator->GetSelection();
2625 bool refreshSelection = selection.IsOk() && ( selection != m_netNavigator->GetRootItem() );
2626
2627 if( refreshSelection )
2628 {
2630 dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
2631
2632 wxCHECK( tmp, /* void */ );
2633 itemData = *tmp;
2634 }
2635
2636 m_netNavigator->DeleteAllItems();
2637 RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
2638 }
2639
2641}
2642
2643
2645{
2646 wxAuiPaneInfo& hierarchyPane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
2647 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
2648 wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
2649 wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
2650
2651 // Don't give the selection filter its own visibility controls; instead show it if
2652 // anything else is visible
2653 bool showFilter = ( hierarchyPane.IsShown() && hierarchyPane.IsDocked() )
2654 || ( netNavigatorPane.IsShown() && netNavigatorPane.IsDocked() )
2655 || ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
2656
2657 selectionFilterPane.Show( showFilter );
2658}
2659
2660#ifdef KICAD_IPC_API
2661void SCH_EDIT_FRAME::onPluginAvailabilityChanged( wxCommandEvent& aEvt )
2662{
2663 wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
2665 aEvt.Skip();
2666}
2667#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:196
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)
Modify a given item in the model.
Definition: commit.h:108
bool Empty() const
Definition: commit.h:150
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
Return 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)
Remove all files from the file history.
virtual void OnSize(wxSizeEvent &aEvent)
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handle event fired when a file is dropped to the window.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetch 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
The current canvas type.
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)
Print 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:249
const KIID m_Uuid
Definition: eda_item.h:488
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
void ClearBrightened()
Definition: eda_item.h:121
void SetBrightened()
Definition: eda_item.h:118
bool IsBrightened() const
Definition: eda_item.h:112
Specialization of the wxAuiPaneInfo class for KiCad panels.
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:291
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:657
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 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:276
static TOOL_ACTION placeDesignBlock
Definition: ee_actions.h:82
static TOOL_ACTION lineMode90
Definition: ee_actions.h:271
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:239
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 toggleERCWarnings
Definition: ee_actions.h:244
static TOOL_ACTION drawRuleArea
Definition: ee_actions.h:113
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:246
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:270
static TOOL_ACTION drawBus
Definition: ee_actions.h:84
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:245
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:249
static TOOL_ACTION mirrorH
Definition: ee_actions.h:133
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:303
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:302
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:250
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:225
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:240
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:91
static TOOL_ACTION ddAppendFile
Definition: ee_actions.h:307
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:304
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:243
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:231
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:102
static TOOL_ACTION toggleOPVoltages
Definition: ee_actions.h:248
static TOOL_ACTION showDesignBlockPanel
Definition: ee_actions.h:198
static TOOL_ACTION drawArc
Definition: ee_actions.h:107
static TOOL_ACTION lineMode45
Definition: ee_actions.h:272
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:247
static TOOL_ACTION placeLabel
Definition: ee_actions.h:89
static TOOL_ACTION saveSheetAsDesignBlock
Definition: ee_actions.h:199
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:200
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:179
EE_TYPE Overlapping(const BOX2I &aRect) const
Definition: sch_rtree.h:246
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:241
SEVERITY GetSeverity(int aErrorCode) const
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
void UpdateHierarchyTree(bool aClear=false)
Update the hierarchical tree of the schematic.
void UpdateLabelsHierarchyTree()
Update the labels of the hierarchical tree of the schematic.
void UpdateHierarchySelection()
Updates the tree's selection to match current page.
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:120
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:86
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
double GetScale() const
Definition: view.h:272
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:1673
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:396
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:216
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:586
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:1559
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:285
void OnKiCadExit()
Definition: kiway.cpp:727
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:84
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:338
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:125
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:140
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:146
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:370
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:83
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:148
CONNECTION_GRAPH * m_connectionGraph
Hold and calculate connectivity information of this schematic.
Definition: schematic.h:397
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:162
void OnSchSheetChanged()
Notify the schematic and its listeners that the current sheet has been changed.
Definition: schematic.cpp:813
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
Definition: schematic.cpp:747
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:316
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:322
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:172
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:167
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:224
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Definition: schematic.h:126
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:204
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:174
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:218
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:701
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:147
void RemoveAllListeners()
Remove all listeners.
Definition: schematic.cpp:838
SCH_SHEET & Root() const
Definition: schematic.h:131
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Definition: schematic.cpp:672
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:329
void RefreshHierarchy()
Definition: schematic.cpp:232
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(int aFlags) 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
Execute the changes.
Definition: sch_commit.cpp:433
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 operating 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 onSize(wxSizeEvent &aEvent)
void CommonSettingsChanged(int aFlags) override
Called after the preferences dialog is run.
void ShowChangedLanguage() override
std::vector< wxEvtHandler * > m_schematicChangeListeners
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 UpdateHierarchyNavigator(bool aRefreshNetNavigator=true, bool aClear=false)
Update the hierarchy navigation tree and history.
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
Return bounding box 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
DESIGN_BLOCK_PANE * m_designBlocksPane
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:53
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:167
virtual bool IsConnectable() const
Definition: sch_item.h:459
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:563
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:1410
SPIN_STYLE GetSpinStyle() const
Definition: sch_label.cpp:331
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
Definition: sch_label.cpp:560
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:213
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Definition: sch_label.cpp:296
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:321
bool IsWire() const
Return true if the line is a wire.
Definition: sch_line.cpp:964
double GetLength() const
Definition: sch_line.cpp:237
const wxString & GetOperatingPoint() const
Definition: sch_line.h:320
Handle actions specific to the schematic editor.
void SetOperatingPoint(const wxString &aText)
Definition: sch_pin.h:292
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)
Clear and resets items and directives attached to this rule area.
std::unordered_set< SCH_ITEM * > GetPastAndPresentContainedItems() const
Fetch 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)
Update 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:716
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:131
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:280
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:484
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:640
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition: sch_screen.h:109
const wxString & GetFileName() const
Definition: sch_screen.h:144
const KIID & GetUuid() const
Definition: sch_screen.h:535
void Print(const SCH_RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
Definition: sch_screen.cpp:859
bool IsReadOnly() const
Definition: sch_screen.h:147
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:120
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:318
bool m_zoomInitialized
Definition: sch_screen.h:665
bool FileExists() const
Definition: sch_screen.h:150
SPIN_STYLE GetLabelOrientationForPoint(const VECTOR2I &aPosition, SPIN_STYLE aDefaultOrientation, const SCH_SHEET_PATH *aSheet) const
Definition: sch_screen.cpp:517
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:59
wxString GetName() const
Definition: sch_sheet.h:110
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:171
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:184
Schematic symbol object.
Definition: sch_symbol.h:77
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:783
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:907
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) 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:705
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)
Return a handle to the a given settings by type.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Save, unload and unregister 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:752
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:173
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:171
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:173
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:172
@ 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:168
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()
Initialize 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:351
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:341
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:425
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:84
@ ID_EDA_SOCKET_EVENT
Definition: id.h:161
@ ID_EDA_SOCKET_EVENT_SERV
Definition: id.h:160
@ ID_FILEMAX
Definition: id.h:82
@ ID_FILE1
Definition: id.h:81
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:468
@ LAYER_ERC_EXCLUSION
Definition: layer_ids.h:470
@ LAYER_ERC_ERR
Definition: layer_ids.h:469
@ LAYER_OP_CURRENTS
Definition: layer_ids.h:490
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:477
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:452
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:489
@ MAIL_PCB_UPDATE
Definition: mail_type.h:46
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:58
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:55
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:1073
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
@ AUTOPLACE_AUTO
Definition: sch_item.h:70
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:195
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:695
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.