2011-10-15 13:25:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-07-26 10:03:24 +00:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2024-01-06 12:56:16 +00:00
|
|
|
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-15 13:25:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
#include <algorithm>
|
2024-01-20 23:35:29 +00:00
|
|
|
#include <api/api_handler_sch.h>
|
|
|
|
#include <api/api_server.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <base_units.h>
|
2021-03-07 20:31:19 +00:00
|
|
|
#include <bitmaps.h>
|
2021-06-15 13:24:55 +00:00
|
|
|
#include <symbol_library.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <confirm.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <connection_graph.h>
|
2023-03-13 16:03:48 +00:00
|
|
|
#include <dialogs/dialog_erc.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <dialogs/dialog_schematic_find.h>
|
2023-03-13 16:03:48 +00:00
|
|
|
#include <dialogs/dialog_book_reporter.h>
|
2023-08-14 14:41:28 +00:00
|
|
|
#include <dialogs/dialog_symbol_fields_table.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <eeschema_id.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <executable_names.h>
|
2023-09-18 23:52:27 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2024-04-25 14:24:46 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gestfich.h>
|
2021-09-14 18:26:03 +00:00
|
|
|
#include <dialogs/html_message_box.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <invoke_sch_dialog.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2020-09-01 10:14:51 +00:00
|
|
|
#include <kiplatform/app.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <kiway.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_edit_frame.h>
|
2020-12-25 23:37:01 +00:00
|
|
|
#include <symbol_viewer_frame.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <pgm_base.h>
|
2023-09-07 11:22:10 +00:00
|
|
|
#include <core/profile.h>
|
2020-06-20 14:36:16 +00:00
|
|
|
#include <project/project_file.h>
|
2020-10-07 14:40:12 +00:00
|
|
|
#include <project/net_settings.h>
|
2021-07-02 19:05:16 +00:00
|
|
|
#include <python_scripting.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2023-09-28 13:09:45 +00:00
|
|
|
#include <symbol_chooser_frame.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <sch_painter.h>
|
2020-11-18 22:55:38 +00:00
|
|
|
#include <sch_marker.h>
|
2024-01-21 16:53:05 +00:00
|
|
|
#include <sch_sheet_pin.h>
|
2023-06-09 21:41:33 +00:00
|
|
|
#include <sch_commit.h>
|
2024-04-25 14:24:46 +00:00
|
|
|
#include <sch_rule_area.h>
|
2020-06-20 14:36:16 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <advanced_config.h>
|
2023-03-03 22:36:07 +00:00
|
|
|
#include <sim/simulator_frame.h>
|
2020-08-06 23:03:58 +00:00
|
|
|
#include <tool/action_manager.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
|
|
|
#include <tool/common_control.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tool/common_tools.h>
|
2019-07-15 23:44:01 +00:00
|
|
|
#include <tool/picker_tool.h>
|
2023-06-21 01:57:20 +00:00
|
|
|
#include <tool/properties_tool.h>
|
2020-08-06 23:03:58 +00:00
|
|
|
#include <tool/selection.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
|
|
|
#include <tool/tool_manager.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tool/zoom_tool.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <tools/ee_actions.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <tools/ee_inspection_tool.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <tools/ee_point_editor.h>
|
2019-05-07 18:49:53 +00:00
|
|
|
#include <tools/sch_drawing_tools.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tools/sch_edit_tool.h>
|
2023-11-25 12:38:24 +00:00
|
|
|
#include <tools/sch_edit_table_tool.h>
|
2022-03-22 16:49:38 +00:00
|
|
|
#include <tools/sch_editor_conditions.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tools/sch_editor_control.h>
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <tools/sch_line_wire_bus_tool.h>
|
|
|
|
#include <tools/sch_move_tool.h>
|
2020-10-02 20:18:07 +00:00
|
|
|
#include <tools/sch_navigate_tool.h>
|
2023-01-11 14:17:36 +00:00
|
|
|
#include <tools/sch_find_replace_tool.h>
|
2024-04-25 14:24:46 +00:00
|
|
|
#include <unordered_set>
|
2020-09-25 07:31:56 +00:00
|
|
|
#include <view/view_controls.h>
|
2022-12-28 22:03:03 +00:00
|
|
|
#include <widgets/wx_infobar.h>
|
2022-12-12 11:46:20 +00:00
|
|
|
#include <widgets/hierarchy_pane.h>
|
2023-06-21 01:57:20 +00:00
|
|
|
#include <widgets/sch_properties_panel.h>
|
2023-05-15 01:35:39 +00:00
|
|
|
#include <widgets/sch_search_pane.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2020-04-19 18:28:36 +00:00
|
|
|
#include <wx/cmdline.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/app.h>
|
|
|
|
#include <wx/filedlg.h>
|
2021-06-03 21:57:41 +00:00
|
|
|
#include <wx/socket.h>
|
2024-06-24 16:07:33 +00:00
|
|
|
#include <wx/debug.h>
|
2024-02-25 22:39:14 +00:00
|
|
|
#include <widgets/panel_sch_selection_filter.h>
|
2022-06-02 21:56:17 +00:00
|
|
|
#include <widgets/wx_aui_utils.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_proxy_view_item.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
#ifdef KICAD_IPC_API
|
|
|
|
#include <api/api_plugin_manager.h>
|
|
|
|
#endif
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
#define DIFF_SYMBOLS_DIALOG_NAME wxT( "DiffSymbolsDialog" )
|
|
|
|
|
|
|
|
|
2023-01-28 19:08:38 +00:00
|
|
|
BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, SCH_BASE_FRAME )
|
2011-01-21 19:30:59 +00:00
|
|
|
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, EDA_DRAW_FRAME::OnSockRequestServer )
|
|
|
|
EVT_SOCKET( ID_EDA_SOCKET_EVENT, EDA_DRAW_FRAME::OnSockRequest )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_SIZE( SCH_EDIT_FRAME::OnSize )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2018-08-20 13:46:38 +00:00
|
|
|
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, SCH_EDIT_FRAME::OnLoadFile )
|
2020-02-25 15:46:56 +00:00
|
|
|
EVT_MENU( ID_FILE_LIST_CLEAR, SCH_EDIT_FRAME::OnClearFileHistory )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2013-01-24 17:46:37 +00:00
|
|
|
EVT_MENU( ID_APPEND_PROJECT, SCH_EDIT_FRAME::OnAppendProject )
|
2017-09-20 14:20:38 +00:00
|
|
|
EVT_MENU( ID_IMPORT_NON_KICAD_SCH, SCH_EDIT_FRAME::OnImportProject )
|
2013-01-24 17:46:37 +00:00
|
|
|
|
2019-05-26 22:22:03 +00:00
|
|
|
EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
|
2019-06-25 04:44:34 +00:00
|
|
|
EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
// Drop files event
|
|
|
|
EVT_DROP_FILES( SCH_EDIT_FRAME::OnDropFiles )
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2023-05-20 17:47:12 +00:00
|
|
|
|
2024-01-18 22:50:50 +00:00
|
|
|
wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGING, wxCommandEvent );
|
2023-05-15 01:35:39 +00:00
|
|
|
wxDEFINE_EVENT( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEvent );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2023-05-20 17:47:12 +00:00
|
|
|
|
2020-12-03 15:10:14 +00:00
|
|
|
SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|
|
|
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
|
2023-03-13 16:03:48 +00:00
|
|
|
m_ercDialog( nullptr ),
|
2023-05-20 17:47:12 +00:00
|
|
|
m_diffSymbolDialog( nullptr ),
|
2023-08-14 14:41:28 +00:00
|
|
|
m_symbolFieldsTableDialog( nullptr ),
|
2023-05-20 17:47:12 +00:00
|
|
|
m_netNavigator( nullptr ),
|
|
|
|
m_highlightedConnChanged( false )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-10-18 18:38:40 +00:00
|
|
|
m_maximizeByDefault = true;
|
2020-06-20 14:36:16 +00:00
|
|
|
m_schematic = new SCHEMATIC( nullptr );
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_showBorderAndTitleBlock = true; // true to show sheet references
|
2021-12-02 20:19:15 +00:00
|
|
|
m_supportsAutoSave = true;
|
2022-07-19 15:00:35 +00:00
|
|
|
m_syncingPcbToSchSelection = false;
|
2022-12-31 23:39:04 +00:00
|
|
|
m_aboutTitle = _HKI( "KiCad Schematic Editor" );
|
2023-05-15 01:35:39 +00:00
|
|
|
m_show_search = false;
|
2013-06-07 20:56:55 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
m_findReplaceDialog = nullptr;
|
|
|
|
|
2022-08-05 02:40:38 +00:00
|
|
|
m_findReplaceData = std::make_unique<SCH_SEARCH_DATA>();
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
// Give an icon
|
2011-09-09 19:30:59 +00:00
|
|
|
wxIcon icon;
|
2020-12-22 19:41:32 +00:00
|
|
|
wxIconBundle icon_bundle;
|
|
|
|
|
2024-01-16 22:21:01 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 48 ) );
|
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 128 ) );
|
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema, 256 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
|
|
|
|
SetIcons( icon_bundle );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2020-05-10 22:02:58 +00:00
|
|
|
LoadSettings( eeconfig() );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2021-09-02 11:40:45 +00:00
|
|
|
// NB: also links the schematic to the loaded project
|
2015-08-06 00:10:52 +00:00
|
|
|
CreateScreens();
|
2024-06-06 16:58:48 +00:00
|
|
|
|
|
|
|
SCH_SHEET_PATH root;
|
|
|
|
root.push_back( &Schematic().Root() );
|
|
|
|
SetCurrentSheet( root );
|
2015-08-06 00:10:52 +00:00
|
|
|
|
2019-05-13 20:42:40 +00:00
|
|
|
setupTools();
|
2020-08-06 23:03:58 +00:00
|
|
|
setupUIConditions();
|
2008-02-26 01:07:38 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
ReCreateOptToolbar();
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
#ifdef KICAD_IPC_API
|
|
|
|
wxTheApp->Bind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED,
|
|
|
|
[&]( wxCommandEvent& aEvt )
|
|
|
|
{
|
|
|
|
wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
|
|
|
|
ReCreateHToolbar();
|
|
|
|
aEvt.Skip();
|
|
|
|
} );
|
|
|
|
#endif
|
|
|
|
|
2022-12-12 11:46:20 +00:00
|
|
|
m_hierarchy = new HIERARCHY_PANE( this );
|
2022-06-02 21:56:17 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
// Initialize common print setup dialog settings.
|
|
|
|
m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
|
|
|
|
m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
|
|
|
|
m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
|
|
|
|
m_pageSetupData.GetPrintData().SetNoCopies( 1 );
|
2010-02-02 15:01:09 +00:00
|
|
|
|
2023-05-15 01:35:39 +00:00
|
|
|
m_searchPane = new SCH_SEARCH_PANE( this );
|
2023-06-21 01:57:20 +00:00
|
|
|
m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
|
|
|
|
|
2023-09-25 11:35:31 +00:00
|
|
|
m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
|
2023-05-15 01:35:39 +00:00
|
|
|
|
2024-02-25 22:39:14 +00:00
|
|
|
m_selectionFilterPanel = new PANEL_SCH_SELECTION_FILTER( this );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2020-12-22 21:35:25 +00:00
|
|
|
CreateInfoBar();
|
2022-07-26 11:13:16 +00:00
|
|
|
|
|
|
|
// Rows; layers 4 - 6
|
2023-01-17 04:14:38 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxS( "MainToolbar" ) )
|
2020-12-11 12:09:37 +00:00
|
|
|
.Top().Layer( 6 ) );
|
2022-07-26 11:13:16 +00:00
|
|
|
|
2023-01-17 04:14:38 +00:00
|
|
|
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
|
2022-07-26 11:13:16 +00:00
|
|
|
.Bottom().Layer( 6 ) );
|
|
|
|
|
|
|
|
// Columns; layers 1 - 3
|
2022-06-07 09:00:13 +00:00
|
|
|
m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
|
2022-07-26 11:13:16 +00:00
|
|
|
.Caption( _( "Schematic Hierarchy" ) )
|
2024-03-03 01:20:58 +00:00
|
|
|
.Left().Layer( 3 ).Position( 1 )
|
2022-06-08 16:09:25 +00:00
|
|
|
.TopDockable( false )
|
|
|
|
.BottomDockable( false )
|
2024-03-12 23:51:27 +00:00
|
|
|
.CloseButton( false )
|
2024-01-18 03:05:54 +00:00
|
|
|
.MinSize( FromDIP( wxSize( 120, 60 ) ) )
|
|
|
|
.BestSize( FromDIP( wxSize( 200, 200 ) ) )
|
|
|
|
.FloatingSize( FromDIP( wxSize( 200, 200 ) ) )
|
|
|
|
.FloatingPosition( FromDIP( wxPoint( 50, 50 ) ) )
|
2022-07-26 11:13:16 +00:00
|
|
|
.Show( false ) );
|
2023-05-20 17:47:12 +00:00
|
|
|
|
2024-01-18 04:08:38 +00:00
|
|
|
m_auimgr.AddPane( m_propertiesPanel, defaultPropertiesPaneInfo( this ) );
|
2024-02-25 22:39:14 +00:00
|
|
|
m_auimgr.AddPane( m_selectionFilterPanel, defaultSchSelectionFilterPaneInfo( this ) );
|
2023-06-21 01:57:20 +00:00
|
|
|
|
2023-05-20 17:47:12 +00:00
|
|
|
m_auimgr.AddPane( createHighlightedNetNavigator(), defaultNetNavigatorPaneInfo() );
|
|
|
|
|
2023-01-17 04:14:38 +00:00
|
|
|
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( wxS( "OptToolbar" ) )
|
2022-07-26 11:13:16 +00:00
|
|
|
.Left().Layer( 2 ) );
|
|
|
|
|
2023-01-17 04:14:38 +00:00
|
|
|
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( wxS( "ToolsToolbar" ) )
|
2020-12-11 12:09:37 +00:00
|
|
|
.Right().Layer( 2 ) );
|
2022-07-26 11:13:16 +00:00
|
|
|
|
|
|
|
// Center
|
2023-01-17 04:14:38 +00:00
|
|
|
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
|
2020-12-11 12:09:37 +00:00
|
|
|
.Center() );
|
|
|
|
|
2023-05-15 01:35:39 +00:00
|
|
|
m_auimgr.AddPane( m_searchPane, EDA_PANE()
|
2023-11-07 13:40:24 +00:00
|
|
|
.Name( SearchPaneName() )
|
|
|
|
.Bottom()
|
|
|
|
.Caption( _( "Search" ) )
|
|
|
|
.PaneBorder( false )
|
2024-01-18 03:05:54 +00:00
|
|
|
.MinSize( FromDIP( wxSize( 180, 60 ) ) )
|
|
|
|
.BestSize( FromDIP( wxSize( 180, 100 ) ) )
|
|
|
|
.FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
|
2024-03-12 23:51:27 +00:00
|
|
|
.CloseButton( false )
|
2023-11-07 13:40:24 +00:00
|
|
|
.DestroyOnClose( false )
|
|
|
|
.Show( m_show_search ) );
|
2023-05-15 01:35:39 +00:00
|
|
|
|
2022-07-26 11:13:16 +00:00
|
|
|
FinishAUIInitialization();
|
2022-06-08 16:09:25 +00:00
|
|
|
|
2022-07-26 11:13:16 +00:00
|
|
|
resolveCanvasType();
|
|
|
|
SwitchCanvas( m_canvasType );
|
2022-06-08 16:09:25 +00:00
|
|
|
|
2022-07-26 11:13:16 +00:00
|
|
|
GetCanvas()->GetGAL()->SetAxesEnabled( false );
|
|
|
|
|
|
|
|
KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
|
|
|
|
static_cast<KIGFX::SCH_PAINTER*>( view->GetPainter() )->SetSchematic( m_schematic );
|
|
|
|
|
2024-02-25 22:39:14 +00:00
|
|
|
wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
|
|
|
|
wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
|
|
|
|
wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
|
|
|
|
wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
|
2022-07-26 11:13:16 +00:00
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
|
|
|
|
hierarchy_pane.Show( cfg->m_AuiPanels.show_schematic_hierarchy );
|
2023-05-20 17:47:12 +00:00
|
|
|
netNavigatorPane.Show( cfg->m_AuiPanels.show_net_nav_panel );
|
2023-06-21 01:57:20 +00:00
|
|
|
propertiesPane.Show( cfg->m_AuiPanels.show_properties );
|
2024-02-25 22:39:14 +00:00
|
|
|
updateSelectionFilterVisbility();
|
|
|
|
|
|
|
|
// The selection filter doesn't need to grow in the vertical direction when docked
|
|
|
|
selectionFilterPane.dock_proportion = 0;
|
2022-07-26 11:13:16 +00:00
|
|
|
|
|
|
|
if( cfg->m_AuiPanels.hierarchy_panel_float_width > 0
|
|
|
|
&& cfg->m_AuiPanels.hierarchy_panel_float_height > 0 )
|
|
|
|
{
|
|
|
|
// Show at end, after positioning
|
|
|
|
hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width,
|
|
|
|
cfg->m_AuiPanels.hierarchy_panel_float_height );
|
2022-06-08 16:09:25 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 17:47:12 +00:00
|
|
|
if( cfg->m_AuiPanels.net_nav_panel_float_size.GetWidth() > 0
|
|
|
|
&& cfg->m_AuiPanels.net_nav_panel_float_size.GetHeight() > 0 )
|
|
|
|
{
|
|
|
|
netNavigatorPane.FloatingSize( cfg->m_AuiPanels.net_nav_panel_float_size );
|
2024-02-01 11:53:33 +00:00
|
|
|
netNavigatorPane.FloatingPosition( cfg->m_AuiPanels.net_nav_panel_float_pos );
|
2023-05-20 17:47:12 +00:00
|
|
|
}
|
|
|
|
|
2023-06-21 01:57:20 +00:00
|
|
|
if( cfg->m_AuiPanels.properties_panel_width > 0 )
|
|
|
|
SetAuiPaneSize( m_auimgr, propertiesPane, cfg->m_AuiPanels.properties_panel_width, -1 );
|
|
|
|
|
2022-07-26 11:13:16 +00:00
|
|
|
if( cfg->m_AuiPanels.schematic_hierarchy_float )
|
|
|
|
hierarchy_pane.Float();
|
2011-04-12 12:41:13 +00:00
|
|
|
|
2023-05-19 20:51:57 +00:00
|
|
|
if( cfg->m_AuiPanels.search_panel_height > 0
|
|
|
|
&& ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
|
|
|
|
|| cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
|
2023-05-15 01:35:39 +00:00
|
|
|
{
|
|
|
|
wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
|
2023-05-19 20:51:57 +00:00
|
|
|
searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
|
2023-05-15 01:35:39 +00:00
|
|
|
SetAuiPaneSize( m_auimgr, searchPane, -1, cfg->m_AuiPanels.search_panel_height );
|
|
|
|
}
|
|
|
|
|
2023-05-19 20:51:57 +00:00
|
|
|
else if( cfg->m_AuiPanels.search_panel_width > 0
|
|
|
|
&& ( cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
|
|
|
|
|| cfg->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
|
|
|
|
{
|
|
|
|
wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
|
|
|
|
searchPane.Direction( cfg->m_AuiPanels.search_panel_dock_direction );
|
|
|
|
SetAuiPaneSize( m_auimgr, searchPane, cfg->m_AuiPanels.search_panel_width, -1 );
|
|
|
|
}
|
|
|
|
|
2023-05-20 17:47:12 +00:00
|
|
|
if( cfg->m_AuiPanels.float_net_nav_panel )
|
|
|
|
netNavigatorPane.Float();
|
|
|
|
|
2022-07-26 11:13:16 +00:00
|
|
|
if( cfg->m_AuiPanels.hierarchy_panel_docked_width > 0 )
|
|
|
|
{
|
2023-10-12 13:36:28 +00:00
|
|
|
// If the net navigator is not show, let the hierarchy navigator take all of the vertical
|
2023-05-20 17:47:12 +00:00
|
|
|
// space.
|
|
|
|
if( !cfg->m_AuiPanels.show_net_nav_panel )
|
|
|
|
{
|
|
|
|
SetAuiPaneSize( m_auimgr, hierarchy_pane,
|
|
|
|
cfg->m_AuiPanels.hierarchy_panel_docked_width, -1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetAuiPaneSize( m_auimgr, hierarchy_pane,
|
|
|
|
cfg->m_AuiPanels.hierarchy_panel_docked_width,
|
|
|
|
cfg->m_AuiPanels.hierarchy_panel_docked_height );
|
|
|
|
|
|
|
|
SetAuiPaneSize( m_auimgr, netNavigatorPane,
|
|
|
|
cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth(),
|
|
|
|
cfg->m_AuiPanels.net_nav_panel_docked_size.GetHeight() );
|
|
|
|
}
|
2022-07-26 11:13:16 +00:00
|
|
|
|
|
|
|
// wxAUI hack: force width by setting MinSize() and then Fixed()
|
2023-05-20 17:47:12 +00:00
|
|
|
// thanks to ZenJu https://github.com/wxWidgets/wxWidgets/issues/13180
|
|
|
|
hierarchy_pane.MinSize( cfg->m_AuiPanels.hierarchy_panel_docked_width, 60 );
|
2022-07-26 11:13:16 +00:00
|
|
|
hierarchy_pane.Fixed();
|
2023-05-20 17:47:12 +00:00
|
|
|
netNavigatorPane.MinSize( cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth(), 60 );
|
|
|
|
netNavigatorPane.Fixed();
|
2022-07-26 11:13:16 +00:00
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
// now make it resizable again
|
|
|
|
hierarchy_pane.Resizable();
|
2023-05-20 17:47:12 +00:00
|
|
|
netNavigatorPane.Resizable();
|
2022-07-26 11:13:16 +00:00
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
// Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
|
|
|
|
// back to minimum.
|
2024-01-18 03:05:54 +00:00
|
|
|
hierarchy_pane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
|
|
|
|
netNavigatorPane.MinSize( FromDIP( wxSize( 120, 60 ) ) );
|
2022-07-26 11:13:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
2020-10-31 21:49:50 +00:00
|
|
|
|
2021-05-01 20:13:48 +00:00
|
|
|
LoadProjectSettings();
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
view->SetLayerVisible( LAYER_ERC_ERR, cfg->m_Appearance.show_erc_errors );
|
|
|
|
view->SetLayerVisible( LAYER_ERC_WARN, cfg->m_Appearance.show_erc_warnings );
|
|
|
|
view->SetLayerVisible( LAYER_ERC_EXCLUSION, cfg->m_Appearance.show_erc_exclusions );
|
|
|
|
view->SetLayerVisible( LAYER_OP_VOLTAGES, cfg->m_Appearance.show_op_voltages );
|
|
|
|
view->SetLayerVisible( LAYER_OP_CURRENTS, cfg->m_Appearance.show_op_currents );
|
|
|
|
|
Mark null project initial screen as zoom-initialized
The variable `m_Initialized` in `BASE_SCREEN` is used by
`SCH_EDIT_FRAME` to mark whether a screen had its zoom level initialized
by the "zoom to fit screen" action. When this variable is `false`, the
function `SCH_EDIT_FRAME::DisplayCurrentSheet()` performs "zoom to fit
screen", modifying the zoom level. This function is indirectly called in
the undo routines, so if `m_Initialized` is not set to `true`, a zoom
change will occur when the user undoes an operation, a behavior that is
undesired.
`m_Initialized` was not initialized to `true` for the null schematic
(the schematic that is loaded if no project is loaded), causing the
aforementioned undesired behavior.
To prevent this, I've changed the `SCH_EDIT_FRAME` constructor to set
`m_Initialized` to `true`, since it zooms to fit screen already. I've
moved `m_Initialized` from `BASE_SCREEN` to `SCH_SCREEN`, as it is used
only in Eeschema, and renamed it to `m_zoomInitialized`, a name I
believe that better describes what this variable does.
I've also introduced the function `SCH_EDIT_FRAME::initScreenZoom()` to
group the "zoom to fit screen" action with setting `m_Initialized` to
`true`, as they often should occur together.
I'd also like to say that I'm not confident whether
`SCH_EDIT_FRAME::DisplayCurrentSheet()` should perform the zoom level
initialization at this point, but I have decided to not change this
behavior for now, as the commit history suggests it's several years old.
Fixes https://gitlab.com/kicad/code/kicad/issues/7343
2021-01-30 22:47:39 +00:00
|
|
|
initScreenZoom();
|
2016-03-31 06:28:16 +00:00
|
|
|
|
2023-05-20 17:47:12 +00:00
|
|
|
m_hierarchy->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
|
|
|
|
m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
|
|
|
|
this );
|
|
|
|
m_netNavigator->Bind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this );
|
|
|
|
m_netNavigator->Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onResizeNetNavigator, this );
|
2022-06-09 17:39:35 +00:00
|
|
|
|
2020-08-20 14:33:12 +00:00
|
|
|
// This is used temporarily to fix a client size issue on GTK that causes zoom to fit
|
|
|
|
// to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
|
|
|
|
Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
|
|
|
|
|
2020-10-05 19:26:33 +00:00
|
|
|
setupUnits( eeconfig() );
|
2019-06-25 04:44:34 +00:00
|
|
|
|
2016-03-31 06:28:16 +00:00
|
|
|
// Net list generator
|
|
|
|
DefaultExecFlags();
|
2017-08-12 12:09:39 +00:00
|
|
|
|
2023-01-12 00:05:43 +00:00
|
|
|
updateTitle();
|
2022-06-02 21:56:17 +00:00
|
|
|
m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->ResetHistory();
|
2019-12-19 14:11:11 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
#ifdef KICAD_IPC_API
|
|
|
|
m_apiHandler = std::make_unique<API_HANDLER_SCH>( this );
|
|
|
|
Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
|
|
|
|
#endif
|
|
|
|
|
2019-12-19 14:11:11 +00:00
|
|
|
// Default shutdown reason until a file is loaded
|
2020-09-01 10:14:51 +00:00
|
|
|
KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
|
2020-04-17 23:32:29 +00:00
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
// Init for dropping files
|
2023-12-28 02:10:01 +00:00
|
|
|
m_acceptedExts.emplace( FILEEXT::KiCadSchematicFileExtension, &EE_ACTIONS::ddAppendFile );
|
2022-09-14 22:28:09 +00:00
|
|
|
DragAcceptFiles( true );
|
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
// Ensure the window is on top
|
|
|
|
Raise();
|
2022-06-08 16:09:25 +00:00
|
|
|
|
2022-07-26 11:13:16 +00:00
|
|
|
// Now that all sizes are fixed, set the initial hierarchy_pane floating position to the
|
|
|
|
// top-left corner of the canvas
|
2022-06-08 16:09:25 +00:00
|
|
|
wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
|
|
|
|
hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
|
2023-03-13 16:03:48 +00:00
|
|
|
|
|
|
|
Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
|
|
|
|
Bind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
|
2023-08-14 14:41:28 +00:00
|
|
|
Bind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, &SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog,
|
|
|
|
this );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2023-05-20 17:47:12 +00:00
|
|
|
m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
|
2023-03-13 16:03:48 +00:00
|
|
|
|
2021-05-17 09:44:17 +00:00
|
|
|
// Ensure m_canvasType is up to date, to save it in config
|
|
|
|
m_canvasType = GetCanvas()->GetBackend();
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
SetScreen( nullptr );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2023-05-11 02:53:10 +00:00
|
|
|
if( m_schematic )
|
|
|
|
m_schematic->RemoveAllListeners();
|
|
|
|
|
2024-06-14 14:57:57 +00:00
|
|
|
// Delete all items not in draw list before deleting schematic
|
|
|
|
// to avoid dangling pointers stored in these items
|
|
|
|
ClearUndoRedoList();
|
|
|
|
ClearRepeatItemsList();
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
delete m_schematic;
|
2020-12-29 17:29:24 +00:00
|
|
|
m_schematic = nullptr;
|
2020-08-08 20:52:57 +00:00
|
|
|
|
|
|
|
// Close the project if we are standalone, so it gets cleaned up properly
|
|
|
|
if( Kiface().IsSingle() )
|
2021-11-13 16:38:19 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
GetSettingsManager()->UnloadProject( &Prj(), false );
|
|
|
|
}
|
2024-06-24 16:07:33 +00:00
|
|
|
catch( const nlohmann::detail::type_error& e )
|
2021-11-13 16:38:19 +00:00
|
|
|
{
|
2024-06-24 16:07:33 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "Settings exception occurred: %s" ), e.what() ) );
|
2021-11-13 16:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-02 21:56:17 +00:00
|
|
|
|
|
|
|
delete m_hierarchy;
|
2024-02-25 22:39:14 +00:00
|
|
|
delete m_selectionFilterPanel;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2014-09-07 19:01:26 +00:00
|
|
|
|
2022-06-09 17:39:35 +00:00
|
|
|
void SCH_EDIT_FRAME::OnResizeHierarchyNavigator( wxSizeEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.Skip();
|
|
|
|
|
|
|
|
// Called when resizing the Hierarchy Navigator panel
|
|
|
|
// Store the current pane size
|
|
|
|
// It allows to retrieve the last defined pane size when switching between
|
|
|
|
// docked and floating pane state
|
2023-10-12 13:36:28 +00:00
|
|
|
// Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
|
2022-06-09 17:39:35 +00:00
|
|
|
|
|
|
|
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
|
|
|
wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
|
|
|
|
|
2021-08-19 21:28:54 +00:00
|
|
|
if( cfg && m_hierarchy->IsShownOnScreen() )
|
2022-06-09 17:39:35 +00:00
|
|
|
{
|
|
|
|
cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
|
|
|
|
cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
|
|
|
|
|
|
|
|
// initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
|
|
|
|
// width is > 0 (i.e. if its size is already set and has meaning)
|
|
|
|
// if it is floating, its size is not initialized (only floating_size is initialized)
|
|
|
|
// initializing hierarchy_pane.best_size is useful when switching to float pane and
|
|
|
|
// after switching to the docked pane, to retrieve the last docked pane width
|
|
|
|
if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
|
|
|
|
{
|
|
|
|
cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
|
|
|
|
hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-04 11:23:04 +00:00
|
|
|
void SCH_EDIT_FRAME::setupTools()
|
|
|
|
{
|
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
2020-05-23 15:50:08 +00:00
|
|
|
m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
|
2020-06-12 10:58:56 +00:00
|
|
|
GetCanvas()->GetViewControls(), config(), this );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_actions = new EE_ACTIONS();
|
2021-03-27 20:02:34 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
2019-05-04 11:23:04 +00:00
|
|
|
|
|
|
|
// Register tools
|
2019-06-09 21:57:23 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
|
|
|
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolManager->RegisterTool( new EE_SELECTION_TOOL );
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolManager->RegisterTool( new PICKER_TOOL );
|
2019-05-07 18:49:53 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_DRAWING_TOOLS );
|
2019-06-16 13:42:40 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_LINE_WIRE_BUS_TOOL );
|
2019-05-04 13:02:05 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_MOVE_TOOL );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_EDIT_TOOL );
|
2023-11-25 12:38:24 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_EDIT_TABLE_TOOL );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolManager->RegisterTool( new EE_INSPECTION_TOOL );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_EDITOR_CONTROL );
|
2023-01-11 14:17:36 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_FIND_REPLACE_TOOL );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolManager->RegisterTool( new EE_POINT_EDITOR );
|
2020-10-02 20:18:07 +00:00
|
|
|
m_toolManager->RegisterTool( new SCH_NAVIGATE_TOOL );
|
2023-06-21 01:57:20 +00:00
|
|
|
m_toolManager->RegisterTool( new PROPERTIES_TOOL );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
|
|
|
// Run the selection tool, it is supposed to be always active
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->PostAction( EE_ACTIONS::selectionActivate );
|
2019-05-04 11:23:04 +00:00
|
|
|
|
|
|
|
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
void SCH_EDIT_FRAME::setupUIConditions()
|
|
|
|
{
|
|
|
|
SCH_BASE_FRAME::setupUIConditions();
|
|
|
|
|
2023-06-16 20:44:16 +00:00
|
|
|
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
2022-03-22 16:49:38 +00:00
|
|
|
SCH_EDITOR_CONDITIONS cond( this );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
wxASSERT( mgr );
|
|
|
|
|
2020-08-20 23:05:21 +00:00
|
|
|
auto hasElements =
|
|
|
|
[ this ] ( const SELECTION& aSel )
|
|
|
|
{
|
2021-09-28 15:41:46 +00:00
|
|
|
return GetScreen() &&
|
|
|
|
( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
|
2020-08-20 23:05:21 +00:00
|
|
|
};
|
|
|
|
|
2023-06-04 14:01:06 +00:00
|
|
|
auto searchPaneCond =
|
2023-06-12 11:38:50 +00:00
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_auimgr.GetPane( SearchPaneName() ).IsShown();
|
|
|
|
};
|
2023-06-04 14:01:06 +00:00
|
|
|
|
2023-06-21 01:57:20 +00:00
|
|
|
auto propertiesCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
|
|
|
|
};
|
|
|
|
|
2022-06-02 21:56:17 +00:00
|
|
|
auto hierarchyNavigatorCond =
|
|
|
|
[ this ] ( const SELECTION& aSel )
|
|
|
|
{
|
2022-06-07 09:00:13 +00:00
|
|
|
return m_auimgr.GetPane( SchematicHierarchyPaneName() ).IsShown();
|
2022-06-02 21:56:17 +00:00
|
|
|
};
|
|
|
|
|
2023-05-20 17:47:12 +00:00
|
|
|
auto netNavigatorCond =
|
|
|
|
[ this ] (const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return m_auimgr.GetPane( NetNavigatorPaneName() ).IsShown();
|
|
|
|
};
|
2022-06-02 21:56:17 +00:00
|
|
|
|
2023-06-16 20:44:16 +00:00
|
|
|
auto undoCond =
|
|
|
|
[ this ] (const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
if( SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return GetUndoCommandCount() > 0;
|
|
|
|
};
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
|
|
|
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
|
|
|
|
2021-02-18 15:49:35 +00:00
|
|
|
mgr->SetConditions( ACTIONS::save, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
2023-06-16 20:44:16 +00:00
|
|
|
mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
|
|
|
|
|
2023-06-04 14:01:06 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::showSearch, CHECK( searchPaneCond ) );
|
2022-06-02 21:56:17 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::showHierarchy, CHECK( hierarchyNavigatorCond ) );
|
2023-05-20 17:47:12 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::showNetNavigator, CHECK( netNavigatorCond ) );
|
2023-06-21 01:57:20 +00:00
|
|
|
mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
|
2023-07-23 17:51:42 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleGridOverrides, CHECK( cond.GridOverrides() ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
|
2021-07-16 20:13:26 +00:00
|
|
|
mgr->SetConditions( ACTIONS::millimetersUnits,
|
|
|
|
CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
|
2020-10-03 23:34:23 +00:00
|
|
|
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::lineModeFree,
|
|
|
|
CHECK( cond.LineMode( LINE_MODE::LINE_MODE_FREE ) ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::lineMode90,
|
|
|
|
CHECK( cond.LineMode( LINE_MODE::LINE_MODE_90 ) ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::lineMode45,
|
|
|
|
CHECK( cond.LineMode( LINE_MODE::LINE_MODE_45 ) ) );
|
2022-03-22 16:49:38 +00:00
|
|
|
|
2021-01-31 22:43:46 +00:00
|
|
|
mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
|
|
|
|
mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
|
2021-05-31 01:25:42 +00:00
|
|
|
mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle ) );
|
|
|
|
mgr->SetConditions( ACTIONS::pasteSpecial, ENABLE( SELECTION_CONDITIONS::Idle ) );
|
2021-01-31 22:43:46 +00:00
|
|
|
mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
|
|
|
|
mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
|
2020-08-20 23:05:21 +00:00
|
|
|
mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
|
2023-09-06 23:44:39 +00:00
|
|
|
mgr->SetConditions( ACTIONS::unselectAll, ENABLE( hasElements ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2023-01-03 21:05:52 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( hasElements ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( hasElements ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( hasElements ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( hasElements ) );
|
2021-02-18 00:07:28 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
mgr->SetConditions( ACTIONS::zoomTool,
|
|
|
|
CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::selectionTool,
|
|
|
|
CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2021-07-02 19:05:16 +00:00
|
|
|
if( SCRIPTING::IsWxAvailable() )
|
2021-11-05 21:16:26 +00:00
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::showPythonConsole,
|
|
|
|
CHECK( cond.ScriptingConsoleVisible() ) );
|
2021-11-05 21:16:26 +00:00
|
|
|
}
|
2021-07-02 19:05:16 +00:00
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
auto showHiddenPinsCond =
|
2021-11-05 21:16:26 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return GetShowAllPins();
|
|
|
|
};
|
|
|
|
|
|
|
|
auto showHiddenFieldsCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
return cfg && cfg->m_Appearance.show_hidden_fields;
|
|
|
|
};
|
|
|
|
|
2023-04-27 16:59:53 +00:00
|
|
|
auto showDirectiveLabelsCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
return cfg && cfg->m_Appearance.show_directive_labels;
|
|
|
|
};
|
|
|
|
|
2021-11-05 21:16:26 +00:00
|
|
|
auto showERCErrorsCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
return cfg && cfg->m_Appearance.show_erc_errors;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto showERCWarningsCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
return cfg && cfg->m_Appearance.show_erc_warnings;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto showERCExclusionsCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
return cfg && cfg->m_Appearance.show_erc_exclusions;
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2024-06-03 12:59:40 +00:00
|
|
|
auto markSimExclusionsCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
return cfg && cfg->m_Appearance.mark_sim_exclusions;
|
|
|
|
};
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
auto showOPVoltagesCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
return cfg && cfg->m_Appearance.show_op_voltages;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto showOPCurrentsCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
return cfg && cfg->m_Appearance.show_op_currents;
|
|
|
|
};
|
|
|
|
|
2022-04-21 17:06:28 +00:00
|
|
|
auto showAnnotateAutomaticallyCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
|
|
|
return cfg && cfg->m_AnnotatePanel.automatic;
|
|
|
|
};
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
auto remapSymbolsCondition =
|
2021-11-05 21:16:26 +00:00
|
|
|
[&]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
SCH_SCREENS schematic( Schematic().Root() );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2021-11-05 21:16:26 +00:00
|
|
|
// The remapping can only be performed on legacy projects.
|
|
|
|
return schematic.HasNoFullyDefinedLibIds();
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
auto belowRootSheetCondition =
|
2021-11-05 21:16:26 +00:00
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
2023-06-12 11:38:50 +00:00
|
|
|
SCH_NAVIGATE_TOOL* navigateTool = m_toolManager->GetTool<SCH_NAVIGATE_TOOL>();
|
|
|
|
return navigateTool && navigateTool->CanGoUp();
|
2022-06-02 21:56:17 +00:00
|
|
|
};
|
|
|
|
|
2023-04-27 16:59:53 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
|
2023-05-31 09:21:49 +00:00
|
|
|
|
|
|
|
/* Some of these are bound by default to arrow keys which will get a different action if we
|
|
|
|
* disable the buttons. So always leave them enabled so the action is consistent.
|
|
|
|
* https://gitlab.com/kicad/code/kicad/-/issues/14783
|
2023-04-27 16:59:53 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::navigateUp, ENABLE( belowRootSheetCondition ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::navigateForward, ENABLE( navHistoryHasForward ) );
|
2023-05-31 09:21:49 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::navigateBack, ENABLE( navHistoryHsBackward ) );
|
|
|
|
*/
|
|
|
|
|
2023-04-27 16:59:53 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleHiddenFields, CHECK( showHiddenFieldsCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleDirectiveLabels, CHECK( showDirectiveLabelsCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleERCErrors, CHECK( showERCErrorsCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleERCWarnings, CHECK( showERCWarningsCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleERCExclusions, CHECK( showERCExclusionsCond ) );
|
2024-06-03 12:59:40 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::markSimExclusions, CHECK( markSimExclusionsCond ) );
|
2023-04-27 16:59:53 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleOPVoltages, CHECK( showOPVoltagesCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleOPCurrents, CHECK( showOPCurrentsCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleAnnotateAuto, CHECK( showAnnotateAutomaticallyCond ) );
|
|
|
|
mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
|
|
|
|
|
|
|
|
CURRENT_TOOL( ACTIONS::deleteTool );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::highlightNetTool );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeSymbol );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placePower );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawWire );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawBus );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeBusWireEntry );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeNoConnect );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeJunction );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeLabel );
|
2021-10-12 20:05:37 +00:00
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeClassLabel );
|
2020-08-06 23:03:58 +00:00
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeGlobalLabel );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeHierLabel );
|
2024-04-25 14:24:46 +00:00
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawRuleArea );
|
2020-08-06 23:03:58 +00:00
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawSheet );
|
2024-02-25 14:23:59 +00:00
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeSheetPin );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::syncSheetPins );
|
2022-01-25 22:33:37 +00:00
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawRectangle );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawCircle );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawArc );
|
2020-08-06 23:03:58 +00:00
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawLines );
|
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeSchematicText );
|
2022-01-25 22:33:37 +00:00
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawTextBox );
|
2023-11-25 12:38:24 +00:00
|
|
|
CURRENT_TOOL( EE_ACTIONS::drawTable );
|
2020-08-06 23:03:58 +00:00
|
|
|
CURRENT_TOOL( EE_ACTIONS::placeImage );
|
|
|
|
|
|
|
|
#undef CURRENT_TOOL
|
|
|
|
#undef CHECK
|
|
|
|
#undef ENABLE
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
void SCH_EDIT_FRAME::SaveCopyForRepeatItem( const SCH_ITEM* aItem )
|
2013-08-05 21:02:41 +00:00
|
|
|
{
|
|
|
|
// we cannot store a pointer to an item in the display list here since
|
2019-07-02 20:09:23 +00:00
|
|
|
// that item may be deleted, such as part of a line concatenation or other.
|
2013-08-05 21:02:41 +00:00
|
|
|
// So simply always keep a copy of the object which is to be repeated.
|
|
|
|
|
2019-07-11 17:23:11 +00:00
|
|
|
if( aItem )
|
|
|
|
{
|
2022-09-09 17:08:18 +00:00
|
|
|
m_items_to_repeat.clear();
|
|
|
|
|
|
|
|
AddCopyForRepeatItem( aItem );
|
|
|
|
}
|
|
|
|
}
|
2013-08-05 21:02:41 +00:00
|
|
|
|
2022-09-09 17:08:18 +00:00
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::AddCopyForRepeatItem( const SCH_ITEM* aItem )
|
|
|
|
{
|
|
|
|
// we cannot store a pointer to an item in the display list here since
|
|
|
|
// that item may be deleted, such as part of a line concatenation or other.
|
|
|
|
// So simply always keep a copy of the object which is to be repeated.
|
|
|
|
|
|
|
|
if( aItem )
|
|
|
|
{
|
2023-09-03 18:05:33 +00:00
|
|
|
std::unique_ptr<SCH_ITEM> repeatItem( static_cast<SCH_ITEM*>( aItem->Duplicate() ) );
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2019-07-11 17:23:11 +00:00
|
|
|
// Clone() preserves the flags, we want 'em cleared.
|
2022-09-09 17:08:18 +00:00
|
|
|
repeatItem->ClearFlags();
|
|
|
|
|
|
|
|
m_items_to_repeat.emplace_back( std::move( repeatItem ) );
|
2019-07-11 17:23:11 +00:00
|
|
|
}
|
2013-08-05 21:02:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
EDA_ITEM* SCH_EDIT_FRAME::GetItem( const KIID& aId ) const
|
2020-04-24 13:36:10 +00:00
|
|
|
{
|
2024-06-06 10:31:22 +00:00
|
|
|
return Schematic().GetItem( aId );
|
2020-04-24 13:36:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::SetSheetNumberAndCount()
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2022-11-03 03:38:02 +00:00
|
|
|
Schematic().SetSheetNumberAndCount();
|
2009-01-04 18:52:57 +00:00
|
|
|
}
|
2008-04-30 17:04:22 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
return GetCurrentSheet().LastScreen();
|
|
|
|
}
|
|
|
|
|
2019-05-20 18:54:44 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCHEMATIC& SCH_EDIT_FRAME::Schematic() const
|
|
|
|
{
|
|
|
|
return *m_schematic;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
|
2013-09-11 09:34:10 +00:00
|
|
|
wxString SCH_EDIT_FRAME::GetScreenDesc() const
|
2023-03-12 22:23:48 +00:00
|
|
|
{
|
2023-07-15 21:39:07 +00:00
|
|
|
return GetCurrentSheet().Last()->GetName();
|
2023-03-12 22:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString SCH_EDIT_FRAME::GetFullScreenDesc() const
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2023-07-15 21:39:07 +00:00
|
|
|
return GetCurrentSheet().PathHumanReadable();
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::CreateScreens()
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
m_schematic->Reset();
|
2020-06-08 02:19:46 +00:00
|
|
|
m_schematic->SetProject( &Prj() );
|
2020-07-03 03:42:36 +00:00
|
|
|
|
2022-10-15 18:15:51 +00:00
|
|
|
SCH_SHEET* rootSheet = new SCH_SHEET( m_schematic );
|
|
|
|
m_schematic->SetRoot( rootSheet );
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2020-05-21 02:27:48 +00:00
|
|
|
SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
|
2022-10-15 18:15:51 +00:00
|
|
|
const_cast<KIID&>( rootSheet->m_Uuid ) = rootScreen->GetUuid();
|
2020-05-13 02:00:37 +00:00
|
|
|
m_schematic->Root().SetScreen( rootScreen );
|
|
|
|
SetScreen( Schematic().RootScreen() );
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2022-10-15 18:15:51 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
m_schematic->RootScreen()->SetFileName( wxEmptyString );
|
2012-01-09 08:35:06 +00:00
|
|
|
|
2021-01-20 23:34:10 +00:00
|
|
|
// Don't leave root page number empty
|
|
|
|
SCH_SHEET_PATH rootSheetPath;
|
2022-11-22 19:35:27 +00:00
|
|
|
|
|
|
|
rootSheetPath.push_back( rootSheet );
|
2021-01-20 23:34:10 +00:00
|
|
|
m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
|
2022-11-22 19:35:27 +00:00
|
|
|
rootSheetPath.SetPageNumber( wxT( "1" ) );
|
2021-01-20 23:34:10 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
if( GetScreen() == nullptr )
|
2015-08-06 00:10:52 +00:00
|
|
|
{
|
2020-05-21 02:27:48 +00:00
|
|
|
SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
|
2015-08-06 00:10:52 +00:00
|
|
|
SetScreen( screen );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SHEET_PATH& SCH_EDIT_FRAME::GetCurrentSheet() const
|
2011-12-08 21:05:43 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
return m_schematic->CurrentSheet();
|
2011-12-08 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::SetCurrentSheet( const SCH_SHEET_PATH& aSheet )
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
if( aSheet != GetCurrentSheet() )
|
2018-10-17 01:03:50 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
FocusOnItem( nullptr );
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
Schematic().SetCurrentSheet( aSheet );
|
|
|
|
GetCanvas()->DisplaySheet( aSheet.LastScreen() );
|
2018-10-17 01:03:50 +00:00
|
|
|
}
|
2011-12-08 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-17 11:14:09 +00:00
|
|
|
void SCH_EDIT_FRAME::HardRedraw()
|
|
|
|
{
|
2022-01-07 17:42:43 +00:00
|
|
|
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
|
|
|
|
|
|
|
|
for( SCH_ITEM* item : screen->Items() )
|
|
|
|
item->ClearCaches();
|
|
|
|
|
2023-06-11 14:44:12 +00:00
|
|
|
for( const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->GetLibSymbols() )
|
2022-11-28 13:38:26 +00:00
|
|
|
{
|
2022-11-29 21:12:31 +00:00
|
|
|
wxCHECK2( libSymbol.second, continue );
|
|
|
|
libSymbol.second->ClearCaches();
|
2022-11-28 13:38:26 +00:00
|
|
|
}
|
2022-01-07 17:42:43 +00:00
|
|
|
|
2023-01-20 22:11:23 +00:00
|
|
|
if( Schematic().Settings().m_IntersheetRefsShow )
|
|
|
|
RecomputeIntersheetRefs();
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
FocusOnItem( nullptr );
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
|
2023-06-16 15:03:04 +00:00
|
|
|
|
|
|
|
if( EE_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<EE_SELECTION_TOOL>() )
|
|
|
|
selectionTool->Reset( TOOL_BASE::REDRAW );
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->ForceRefresh();
|
2018-10-17 11:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-10-31 11:49:52 +00:00
|
|
|
// Exit interactive editing
|
|
|
|
// Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
|
|
|
|
// will cancel any drag currently in progress, but commit all changes from previous drags.
|
|
|
|
if( m_toolManager )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::cancelInteractive );
|
2020-10-31 11:49:52 +00:00
|
|
|
|
2019-12-19 14:11:11 +00:00
|
|
|
// Shutdown blocks must be determined and vetoed as early as possible
|
2020-09-01 10:14:51 +00:00
|
|
|
if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
|
2024-06-06 10:31:22 +00:00
|
|
|
&& IsContentModified() )
|
2019-12-19 14:11:11 +00:00
|
|
|
{
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2019-12-19 14:11:11 +00:00
|
|
|
}
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
{
|
2020-10-31 01:27:16 +00:00
|
|
|
auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
|
|
|
|
|
2020-11-15 17:03:27 +00:00
|
|
|
if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
|
2020-10-31 01:27:16 +00:00
|
|
|
|
2020-11-15 17:03:27 +00:00
|
|
|
if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2023-09-28 13:09:45 +00:00
|
|
|
// SYMBOL_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
|
|
|
|
// sorry.
|
|
|
|
auto* chooser = (SYMBOL_CHOOSER_FRAME*) Kiway().Player( FRAME_SYMBOL_CHOOSER, false );
|
2018-10-24 14:18:19 +00:00
|
|
|
|
2023-09-28 13:09:45 +00:00
|
|
|
if( chooser && !chooser->Close() ) // Can close symbol chooser?
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
}
|
2021-12-22 14:27:38 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
|
|
|
|
|
|
|
|
if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
|
|
|
|
{
|
|
|
|
if( !symbolEditor->CanCloseSymbolFromSchematic( true ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-04-07 17:48:26 +00:00
|
|
|
|
2023-01-01 23:37:24 +00:00
|
|
|
if( !Kiway().PlayerClose( FRAME_SIMULATOR, false ) ) // Can close the simulator?
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2016-08-29 17:47:08 +00:00
|
|
|
|
2023-08-14 14:41:28 +00:00
|
|
|
if( m_symbolFieldsTableDialog
|
|
|
|
&& !m_symbolFieldsTableDialog->Close( false ) ) // Can close the symbol fields table?
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-08-11 22:56:47 +00:00
|
|
|
// We may have gotten multiple events; don't clean up twice
|
|
|
|
if( !Schematic().IsValid() )
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2020-08-11 22:56:47 +00:00
|
|
|
|
2024-06-06 10:31:22 +00:00
|
|
|
if( IsContentModified() )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxFileName fileName = Schematic().RootScreen()->GetFileName();
|
2021-06-28 23:44:07 +00:00
|
|
|
wxString msg = _( "Save changes to '%s' before closing?" );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2019-06-17 15:59:39 +00:00
|
|
|
if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
|
2021-10-01 20:49:14 +00:00
|
|
|
[&]() -> bool
|
|
|
|
{
|
|
|
|
return SaveProject();
|
|
|
|
} ) )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2008-02-26 01:07:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::doCloseWindow()
|
|
|
|
{
|
2024-06-06 16:58:48 +00:00
|
|
|
SCH_SHEET_LIST sheetlist = Schematic().BuildUnorderedSheetList();
|
2020-05-11 23:06:48 +00:00
|
|
|
|
2020-10-31 11:49:52 +00:00
|
|
|
// Shutdown all running tools
|
2020-05-11 23:06:48 +00:00
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ShutdownAllTools();
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
// Close modeless dialogs. They're trouble when they get destroyed after the frame.
|
|
|
|
Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &SCH_EDIT_FRAME::onCloseSymbolDiffDialog, this );
|
|
|
|
Unbind( EDA_EVT_CLOSE_ERC_DIALOG, &SCH_EDIT_FRAME::onCloseErcDialog, this );
|
2023-08-14 14:41:28 +00:00
|
|
|
Unbind( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE,
|
|
|
|
&SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog, this );
|
2023-05-20 17:47:12 +00:00
|
|
|
m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGING, &SCH_EDIT_FRAME::onNetNavigatorSelChanging,
|
|
|
|
this );
|
|
|
|
m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection,
|
|
|
|
this );
|
2023-03-13 16:03:48 +00:00
|
|
|
|
Fix source comment/doc typos (follow-up)
Found via `codespell -q 3 -S *.po,./thirdparty -L aactual,acount,aline,alocation,alog,anormal,anumber,aother,apoints,aparent,aray,dout,einstance,modul,ot,overide,serie,te,,tesselate,tesselator,tht`
2021-07-03 22:37:31 +00:00
|
|
|
// Close the find dialog and preserve its setting if it is displayed.
|
2019-05-19 21:04:04 +00:00
|
|
|
if( m_findReplaceDialog )
|
2011-11-10 17:01:33 +00:00
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_findStringHistoryList = m_findReplaceDialog->GetFindEntries();
|
|
|
|
m_replaceStringHistoryList = m_findReplaceDialog->GetReplaceEntries();
|
|
|
|
|
2019-05-23 17:31:10 +00:00
|
|
|
m_findReplaceDialog->Destroy();
|
|
|
|
m_findReplaceDialog = nullptr;
|
2011-11-10 17:01:33 +00:00
|
|
|
}
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
if( m_diffSymbolDialog )
|
|
|
|
{
|
|
|
|
m_diffSymbolDialog->Destroy();
|
|
|
|
m_diffSymbolDialog = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_ercDialog )
|
|
|
|
{
|
|
|
|
m_ercDialog->Destroy();
|
|
|
|
m_ercDialog = nullptr;
|
|
|
|
}
|
|
|
|
|
2023-08-14 14:41:28 +00:00
|
|
|
if( m_symbolFieldsTableDialog )
|
|
|
|
{
|
|
|
|
m_symbolFieldsTableDialog->Destroy();
|
|
|
|
m_symbolFieldsTableDialog = nullptr;
|
|
|
|
}
|
|
|
|
|
2024-02-25 22:39:14 +00:00
|
|
|
// Make sure local settings are persisted
|
|
|
|
SaveProjectLocalSettings();
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
// Shutdown all running tools
|
|
|
|
if( m_toolManager )
|
|
|
|
{
|
|
|
|
m_toolManager->ShutdownAllTools();
|
2023-04-09 00:30:42 +00:00
|
|
|
// prevent the canvas from trying to dispatch events during close
|
|
|
|
GetCanvas()->SetEventDispatcher( nullptr );
|
2023-03-13 16:03:48 +00:00
|
|
|
delete m_toolManager;
|
|
|
|
m_toolManager = nullptr;
|
|
|
|
}
|
|
|
|
|
2022-07-26 11:13:16 +00:00
|
|
|
wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
|
|
|
|
|
|
|
|
if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
|
|
|
|
{
|
|
|
|
hierarchy_pane.Show( false );
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREENS screens( Schematic().Root() );
|
2011-10-15 13:25:57 +00:00
|
|
|
wxFileName fn;
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
|
2011-10-15 13:25:57 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
fn = Prj().AbsolutePath( screen->GetFileName() );
|
2011-10-15 13:25:57 +00:00
|
|
|
|
2024-04-22 00:58:13 +00:00
|
|
|
// Auto save file name is the normal file name prepended with FILEEXT::AutoSaveFilePrefix.
|
|
|
|
fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() );
|
2011-10-15 13:25:57 +00:00
|
|
|
|
2021-10-13 18:48:28 +00:00
|
|
|
if( fn.IsFileWritable() )
|
2011-10-15 13:25:57 +00:00
|
|
|
wxRemoveFile( fn.GetFullPath() );
|
|
|
|
}
|
|
|
|
|
2021-10-13 18:48:28 +00:00
|
|
|
wxFileName tmpFn = Prj().GetProjectFullName();
|
|
|
|
wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
|
|
|
|
|
|
|
|
if( autoSaveFileName.IsFileWritable() )
|
|
|
|
wxRemoveFile( autoSaveFileName.GetFullPath() );
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
sheetlist.ClearModifyStatus();
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
UpdateFileHistory( fileName );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2024-05-16 16:57:20 +00:00
|
|
|
Schematic().RootScreen()->Clear( true );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2014-01-29 17:01:42 +00:00
|
|
|
// all sub sheets are deleted, only the main sheet is usable
|
2020-05-13 02:00:37 +00:00
|
|
|
GetCurrentSheet().clear();
|
2014-01-29 17:01:42 +00:00
|
|
|
|
2020-08-08 20:52:57 +00:00
|
|
|
// Clear view before destroying schematic as repaints depend on schematic being valid
|
|
|
|
SetScreen( nullptr );
|
|
|
|
|
2020-07-03 13:40:31 +00:00
|
|
|
Schematic().Reset();
|
|
|
|
|
2023-06-02 23:04:08 +00:00
|
|
|
// Prevents any rogue events from continuing (i.e. search panel tries to redraw)
|
2023-05-15 01:35:39 +00:00
|
|
|
Show( false );
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-29 13:41:02 +00:00
|
|
|
SEVERITY SCH_EDIT_FRAME::GetSeverity( int aErrorCode ) const
|
|
|
|
{
|
|
|
|
return Schematic().ErcSettings().GetSeverity( aErrorCode );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-28 20:30:50 +00:00
|
|
|
void SCH_EDIT_FRAME::OnModify()
|
2010-02-18 20:07:29 +00:00
|
|
|
{
|
2022-10-10 13:03:10 +00:00
|
|
|
EDA_BASE_FRAME::OnModify();
|
|
|
|
|
2023-07-15 21:39:07 +00:00
|
|
|
wxCHECK( GetScreen(), /* void */ );
|
2020-02-07 09:02:47 +00:00
|
|
|
|
2021-05-28 19:07:04 +00:00
|
|
|
GetScreen()->SetContentModified();
|
2022-10-10 13:03:10 +00:00
|
|
|
m_autoSaveRequired = true;
|
2010-02-18 20:07:29 +00:00
|
|
|
|
2019-05-31 17:37:07 +00:00
|
|
|
GetCanvas()->Refresh();
|
2021-02-19 21:58:22 +00:00
|
|
|
|
2023-01-17 04:14:38 +00:00
|
|
|
if( !GetTitle().StartsWith( wxS( "*" ) ) )
|
2023-01-12 00:05:43 +00:00
|
|
|
updateTitle();
|
2010-02-18 20:07:29 +00:00
|
|
|
}
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-12-21 20:21:15 +00:00
|
|
|
|
2016-01-29 10:24:39 +00:00
|
|
|
void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
|
2018-02-16 18:26:11 +00:00
|
|
|
{
|
2019-05-23 18:25:07 +00:00
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
{
|
2019-07-02 20:09:23 +00:00
|
|
|
DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
|
|
|
|
" in stand-alone mode. In order to create/update PCBs from"
|
2021-02-18 15:49:35 +00:00
|
|
|
" schematics, launch the KiCad shell and create a project." ) );
|
2019-05-23 18:25:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
|
2019-05-23 18:25:07 +00:00
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
if( !frame )
|
2019-05-24 19:41:29 +00:00
|
|
|
{
|
2020-07-10 16:59:06 +00:00
|
|
|
wxFileName fn = Prj().GetProjectFullName();
|
2023-12-28 02:10:01 +00:00
|
|
|
fn.SetExt( FILEEXT::PcbFileExtension );
|
2020-07-10 16:59:06 +00:00
|
|
|
|
|
|
|
frame = Kiway().Player( FRAME_PCB_EDITOR, true );
|
2022-07-24 17:42:50 +00:00
|
|
|
|
|
|
|
// If Kiway() cannot create the Pcbnew frame, it shows a error message, and
|
|
|
|
// frame is null
|
|
|
|
if( !frame )
|
|
|
|
return;
|
|
|
|
|
2019-05-24 19:41:29 +00:00
|
|
|
frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
|
|
|
|
}
|
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
if( !frame->IsVisible() )
|
|
|
|
frame->Show( true );
|
|
|
|
|
2019-05-23 18:25:07 +00:00
|
|
|
// On Windows, Raise() does not bring the window on screen, when iconized
|
|
|
|
if( frame->IsIconized() )
|
|
|
|
frame->Iconize( false );
|
|
|
|
|
|
|
|
frame->Raise();
|
|
|
|
|
2019-03-27 22:37:26 +00:00
|
|
|
std::string payload;
|
2019-09-05 22:00:47 +00:00
|
|
|
Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE, payload, this );
|
2016-01-29 10:24:39 +00:00
|
|
|
}
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
|
2024-04-17 18:31:50 +00:00
|
|
|
void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator )
|
2019-10-24 17:07:01 +00:00
|
|
|
{
|
2022-06-02 21:56:17 +00:00
|
|
|
m_toolManager->GetTool<SCH_NAVIGATE_TOOL>()->CleanHistory();
|
|
|
|
m_hierarchy->UpdateHierarchyTree();
|
2024-04-17 18:31:50 +00:00
|
|
|
|
|
|
|
if( aRefreshNetNavigator )
|
|
|
|
RefreshNetNavigator();
|
2019-10-24 17:07:01 +00:00
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2020-01-08 14:01:22 +00:00
|
|
|
|
2024-01-25 17:20:43 +00:00
|
|
|
void SCH_EDIT_FRAME::UpdateLabelsHierarchyNavigator()
|
|
|
|
{
|
|
|
|
// Update only the hierarchy navigation tree labels.
|
|
|
|
// The tree list is expectyed to be up to date
|
|
|
|
m_hierarchy->UpdateLabelsHierarchyTree();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-24 22:00:10 +00:00
|
|
|
void SCH_EDIT_FRAME::UpdateHierarchySelection()
|
|
|
|
{
|
|
|
|
m_hierarchy->UpdateHierarchySelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
|
|
|
|
{
|
2022-03-18 23:30:45 +00:00
|
|
|
wxString findString;
|
|
|
|
|
|
|
|
EE_SELECTION& selection = m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
|
|
|
|
|
|
|
|
if( selection.Size() == 1 )
|
|
|
|
{
|
|
|
|
EDA_ITEM* front = selection.Front();
|
|
|
|
|
|
|
|
switch( front->Type() )
|
|
|
|
{
|
|
|
|
case SCH_SYMBOL_T:
|
2023-05-05 13:21:56 +00:00
|
|
|
{
|
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( front );
|
|
|
|
findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() );
|
2022-03-18 23:30:45 +00:00
|
|
|
break;
|
2023-05-05 13:21:56 +00:00
|
|
|
}
|
2022-03-18 23:30:45 +00:00
|
|
|
|
|
|
|
case SCH_FIELD_T:
|
2023-05-05 13:21:56 +00:00
|
|
|
findString = UnescapeString( static_cast<SCH_FIELD*>( front )->GetText() );
|
2022-03-18 23:30:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
case SCH_SHEET_PIN_T:
|
2023-05-05 13:21:56 +00:00
|
|
|
findString = UnescapeString( static_cast<SCH_LABEL_BASE*>( front )->GetText() );
|
2022-03-18 23:30:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_TEXT_T:
|
2023-05-05 13:21:56 +00:00
|
|
|
findString = UnescapeString( static_cast<SCH_TEXT*>( front )->GetText() );
|
2022-03-18 23:30:45 +00:00
|
|
|
|
|
|
|
if( findString.Contains( wxT( "\n" ) ) )
|
|
|
|
findString = findString.Before( '\n' );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-23 17:31:10 +00:00
|
|
|
if( m_findReplaceDialog )
|
|
|
|
m_findReplaceDialog->Destroy();
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2023-05-05 13:21:56 +00:00
|
|
|
m_findReplaceDialog = new DIALOG_SCH_FIND( this,
|
|
|
|
static_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
aReplace ? wxFR_REPLACEDIALOG : 0 );
|
2011-11-10 17:01:33 +00:00
|
|
|
|
2022-03-18 23:30:45 +00:00
|
|
|
m_findReplaceDialog->SetFindEntries( m_findStringHistoryList, findString );
|
2019-05-19 21:04:04 +00:00
|
|
|
m_findReplaceDialog->SetReplaceEntries( m_replaceStringHistoryList );
|
|
|
|
m_findReplaceDialog->Show( true );
|
2010-03-16 18:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-20 01:31:47 +00:00
|
|
|
void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2020-05-20 01:31:47 +00:00
|
|
|
// Prepare the infobar, since we don't know its state
|
|
|
|
m_infoBar->RemoveAllButtons();
|
|
|
|
m_infoBar->AddCloseButton();
|
2011-02-03 21:57:02 +00:00
|
|
|
|
2020-05-20 01:31:47 +00:00
|
|
|
m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
|
2019-05-19 21:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::ClearFindReplaceStatus()
|
|
|
|
{
|
2020-05-20 01:31:47 +00:00
|
|
|
m_infoBar->Dismiss();
|
2019-05-19 21:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnFindDialogClose()
|
|
|
|
{
|
|
|
|
m_findStringHistoryList = m_findReplaceDialog->GetFindEntries();
|
|
|
|
m_replaceStringHistoryList = m_findReplaceDialog->GetReplaceEntries();
|
2019-05-23 17:31:10 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
m_findReplaceDialog->Destroy();
|
2019-05-23 17:31:10 +00:00
|
|
|
m_findReplaceDialog = nullptr;
|
2020-09-24 17:46:01 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::updateFind );
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
|
2008-02-27 19:38:16 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
if( fn.size() )
|
|
|
|
OpenProjectFiles( std::vector<wxString>( 1, fn ) );
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
2008-05-07 15:08:16 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2020-02-25 15:46:56 +00:00
|
|
|
void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
ClearFileHistory();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-24 23:36:31 +00:00
|
|
|
void SCH_EDIT_FRAME::NewProject()
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2024-02-11 14:36:17 +00:00
|
|
|
// Only standalone mode can directly load a new document
|
|
|
|
if( !Kiface().IsSingle() )
|
|
|
|
return;
|
|
|
|
|
2015-09-25 19:38:09 +00:00
|
|
|
wxString pro_dir = m_mruPath;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2020-03-16 13:04:50 +00:00
|
|
|
wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
|
2023-12-28 02:10:01 +00:00
|
|
|
FILEEXT::KiCadSchematicFileWildcard(), wxFD_SAVE );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_CANCEL )
|
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// Enforce the extension, wxFileDialog is inept.
|
2023-12-28 02:10:01 +00:00
|
|
|
wxFileName create_me =
|
|
|
|
EnsureFileExtension( dlg.GetPath(), FILEEXT::KiCadSchematicFileExtension );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
if( create_me.FileExists() )
|
|
|
|
{
|
2018-09-09 21:06:38 +00:00
|
|
|
wxString msg;
|
2021-06-16 22:35:00 +00:00
|
|
|
msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenProjectFiles() requires absolute
|
2023-01-17 04:14:38 +00:00
|
|
|
wxASSERT_MSG( create_me.IsAbsolute(), wxS( "wxFileDialog returned non-absolute path" ) );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
|
2015-09-25 19:38:09 +00:00
|
|
|
m_mruPath = create_me.GetPath();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2019-05-24 23:36:31 +00:00
|
|
|
void SCH_EDIT_FRAME::LoadProject()
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2024-02-11 14:36:17 +00:00
|
|
|
// Only standalone mode can directly load a new document
|
|
|
|
if( !Kiface().IsSingle() )
|
|
|
|
return;
|
|
|
|
|
2015-09-25 19:38:09 +00:00
|
|
|
wxString pro_dir = m_mruPath;
|
2023-12-28 02:10:01 +00:00
|
|
|
wxString wildcards = FILEEXT::AllSchematicFilesWildcard()
|
|
|
|
+ wxS( "|" ) + FILEEXT::KiCadSchematicFileWildcard()
|
|
|
|
+ wxS( "|" ) + FILEEXT::LegacySchematicFileWildcard();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2020-03-16 13:04:50 +00:00
|
|
|
wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
|
2020-03-25 15:27:15 +00:00
|
|
|
wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_CANCEL )
|
|
|
|
{
|
|
|
|
OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
|
2015-09-25 19:38:09 +00:00
|
|
|
m_mruPath = Prj().GetProjectPath();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2020-10-04 22:39:21 +00:00
|
|
|
if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2023-12-28 02:10:01 +00:00
|
|
|
kicad_board.SetExt( FILEEXT::PcbFileExtension );
|
2015-07-19 14:38:02 +00:00
|
|
|
wxFileName legacy_board( kicad_board );
|
2023-12-28 02:10:01 +00:00
|
|
|
legacy_board.SetExt( FILEEXT::LegacyPcbFileExtension );
|
2019-05-20 10:23:32 +00:00
|
|
|
wxFileName& boardfn = legacy_board;
|
|
|
|
|
|
|
|
if( !legacy_board.FileExists() || kicad_board.FileExists() )
|
|
|
|
boardfn = kicad_board;
|
2010-05-11 14:35:13 +00:00
|
|
|
|
2014-04-20 04:35:34 +00:00
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
{
|
2021-10-02 13:08:36 +00:00
|
|
|
ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
|
2014-04-20 04:35:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-10 16:59:06 +00:00
|
|
|
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
|
2014-04-20 04:35:34 +00:00
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
if( !frame )
|
2014-04-20 04:35:34 +00:00
|
|
|
{
|
2020-07-10 16:59:06 +00:00
|
|
|
frame = Kiway().Player( FRAME_PCB_EDITOR, true );
|
2022-07-24 17:42:50 +00:00
|
|
|
|
|
|
|
// frame can be null if Cvpcb cannot be run. No need to show a warning
|
|
|
|
// Kiway() generates the error messages
|
|
|
|
if( !frame )
|
|
|
|
return;
|
|
|
|
|
2015-07-19 14:38:02 +00:00
|
|
|
frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
|
2014-04-20 04:35:34 +00:00
|
|
|
}
|
2015-06-23 10:59:38 +00:00
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
if( !frame->IsVisible() )
|
|
|
|
frame->Show( true );
|
|
|
|
|
2015-06-23 10:59:38 +00:00
|
|
|
// On Windows, Raise() does not bring the window on screen, when iconized
|
|
|
|
if( frame->IsIconized() )
|
|
|
|
frame->Iconize( false );
|
|
|
|
|
|
|
|
frame->Raise();
|
2014-04-20 04:35:34 +00:00
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
else
|
2011-10-28 20:30:50 +00:00
|
|
|
{
|
2020-10-04 22:39:21 +00:00
|
|
|
// If we are running inside a project, it should be impossible for this case to happen
|
|
|
|
wxASSERT( Kiface().IsSingle() );
|
2021-09-19 13:45:27 +00:00
|
|
|
ExecuteFile( PCBNEW_EXE );
|
2011-10-28 20:30:50 +00:00
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
|
2023-12-28 02:10:01 +00:00
|
|
|
fn.SetExt( FILEEXT::NetlistFileExtension );
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2021-01-30 16:30:35 +00:00
|
|
|
if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
|
2017-11-27 16:11:12 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
try
|
2011-10-28 20:30:50 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
|
|
|
|
|
|
|
|
if( !player )
|
|
|
|
{
|
|
|
|
player = Kiway().Player( FRAME_CVPCB, true );
|
2022-07-24 17:42:50 +00:00
|
|
|
|
|
|
|
// player can be null if Cvpcb cannot be run. No need to show a warning
|
|
|
|
// Kiway() generates the error messages
|
|
|
|
if( !player )
|
|
|
|
return;
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
player->Show( true );
|
|
|
|
}
|
2015-04-08 12:50:36 +00:00
|
|
|
|
2024-01-26 08:24:38 +00:00
|
|
|
// Ensure the netlist (mainly info about symbols) is up to date
|
|
|
|
RecalculateConnections( nullptr, GLOBAL_CLEANUP );
|
2019-03-17 19:15:08 +00:00
|
|
|
sendNetlistToCvpcb();
|
2015-06-07 18:18:45 +00:00
|
|
|
|
2015-09-08 18:45:11 +00:00
|
|
|
player->Raise();
|
2011-10-28 20:30:50 +00:00
|
|
|
}
|
2018-04-18 07:10:29 +00:00
|
|
|
catch( const IO_ERROR& )
|
2017-11-27 16:11:12 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Could not open CvPcb" ) );
|
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2014-02-21 00:06:37 +00:00
|
|
|
|
2019-05-26 22:22:03 +00:00
|
|
|
void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
|
|
|
|
{
|
2019-06-25 04:44:34 +00:00
|
|
|
if( event.GetId() == wxID_EXIT )
|
|
|
|
Kiway().OnKiCadExit();
|
|
|
|
|
|
|
|
if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
|
|
|
|
Close( false );
|
2019-05-26 22:22:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void SCH_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings )
|
2011-03-28 19:26:31 +00:00
|
|
|
{
|
2024-04-02 17:28:17 +00:00
|
|
|
wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
|
|
|
|
const SCH_RENDER_SETTINGS* cfg = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
|
|
|
|
COLOR4D bg = GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2024-04-02 17:28:17 +00:00
|
|
|
cfg->GetPrintDC()->SetBackground( wxBrush( bg.ToColour() ) );
|
|
|
|
cfg->GetPrintDC()->Clear();
|
2021-04-12 13:38:10 +00:00
|
|
|
|
2024-04-02 17:28:17 +00:00
|
|
|
cfg->GetPrintDC()->SetLogicalFunction( wxCOPY );
|
|
|
|
GetScreen()->Print( cfg );
|
|
|
|
PrintDrawingSheet( cfg, GetScreen(), Schematic().GetProperties(), schIUScale.IU_PER_MILS, fileName );
|
2011-03-28 19:26:31 +00:00
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
|
2023-02-05 20:47:27 +00:00
|
|
|
void SCH_EDIT_FRAME::RefreshOperatingPointDisplay()
|
|
|
|
{
|
2023-02-09 17:18:56 +00:00
|
|
|
SCHEMATIC_SETTINGS& settings = m_schematic->Settings();
|
|
|
|
SIM_LIB_MGR simLibMgr( &Prj() );
|
2023-05-07 20:52:31 +00:00
|
|
|
NULL_REPORTER devnull;
|
|
|
|
|
2023-02-13 18:07:58 +00:00
|
|
|
// Patch for bug early in V7.99 dev
|
|
|
|
if( settings.m_OPO_VRange.EndsWith( 'A' ) )
|
|
|
|
settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V';
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
// Update items which may have ${OP} text variables
|
|
|
|
//
|
2023-02-05 20:47:27 +00:00
|
|
|
GetCanvas()->GetView()->UpdateAllItemsConditionally(
|
|
|
|
[&]( KIGFX::VIEW_ITEM* aItem ) -> int
|
|
|
|
{
|
|
|
|
int flags = 0;
|
|
|
|
|
2024-06-03 12:59:40 +00:00
|
|
|
auto invalidateTextVars =
|
|
|
|
[&flags]( EDA_TEXT* text )
|
|
|
|
{
|
|
|
|
if( text->HasTextVars() )
|
|
|
|
{
|
|
|
|
text->ClearRenderCache();
|
|
|
|
text->ClearBoundingBoxCache();
|
|
|
|
flags |= KIGFX::GEOMETRY | KIGFX::REPAINT;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-05 20:47:27 +00:00
|
|
|
if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
|
|
|
|
{
|
|
|
|
item->RunOnChildren(
|
2024-06-03 12:59:40 +00:00
|
|
|
[&invalidateTextVars]( SCH_ITEM* aChild )
|
2023-02-05 20:47:27 +00:00
|
|
|
{
|
2024-06-03 12:59:40 +00:00
|
|
|
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
|
|
|
|
invalidateTextVars( text );
|
2023-02-05 20:47:27 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2024-06-03 12:59:40 +00:00
|
|
|
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
|
|
|
|
invalidateTextVars( text );
|
|
|
|
|
2023-02-05 20:47:27 +00:00
|
|
|
return flags;
|
|
|
|
} );
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
// Update OP overlay items
|
|
|
|
//
|
|
|
|
for( SCH_ITEM* item : GetScreen()->Items() )
|
|
|
|
{
|
2024-06-02 21:26:49 +00:00
|
|
|
if( GetCurrentSheet().GetExcludedFromSim() )
|
|
|
|
continue;
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
if( item->Type() == SCH_LINE_T )
|
|
|
|
{
|
2023-02-22 13:52:52 +00:00
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( item );
|
|
|
|
|
|
|
|
if( !line->GetOperatingPoint().IsEmpty() )
|
|
|
|
GetCanvas()->GetView()->Update( line );
|
|
|
|
|
|
|
|
line->SetOperatingPoint( wxEmptyString );
|
2023-02-09 17:18:56 +00:00
|
|
|
// update value from netlist, below
|
|
|
|
}
|
|
|
|
else if( item->Type() == SCH_SYMBOL_T )
|
|
|
|
{
|
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
|
|
|
wxString ref = symbol->GetRef( &GetCurrentSheet() );
|
|
|
|
std::vector<SCH_PIN*> pins = symbol->GetPins( &GetCurrentSheet() );
|
|
|
|
|
2023-04-14 18:40:41 +00:00
|
|
|
// Power symbols and other symbols which have the reference starting with "#" are
|
|
|
|
// not included in simulation
|
2023-08-08 16:32:08 +00:00
|
|
|
if( ref.StartsWith( '#' ) || symbol->GetExcludedFromSim() )
|
2023-04-14 18:40:41 +00:00
|
|
|
continue;
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
for( SCH_PIN* pin : pins )
|
2023-02-22 13:52:52 +00:00
|
|
|
{
|
|
|
|
if( !pin->GetOperatingPoint().IsEmpty() )
|
|
|
|
GetCanvas()->GetView()->Update( pin );
|
|
|
|
|
2023-02-09 17:18:56 +00:00
|
|
|
pin->SetOperatingPoint( wxEmptyString );
|
2023-02-22 13:52:52 +00:00
|
|
|
}
|
2023-02-09 17:18:56 +00:00
|
|
|
|
|
|
|
if( pins.size() == 2 )
|
|
|
|
{
|
|
|
|
wxString op = m_schematic->GetOperatingPoint( ref, settings.m_OPO_IPrecision,
|
|
|
|
settings.m_OPO_IRange );
|
|
|
|
|
2023-02-13 18:07:58 +00:00
|
|
|
if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
|
2023-02-22 13:52:52 +00:00
|
|
|
{
|
2023-02-09 17:18:56 +00:00
|
|
|
pins[0]->SetOperatingPoint( op );
|
2023-02-22 13:52:52 +00:00
|
|
|
GetCanvas()->GetView()->Update( symbol );
|
|
|
|
}
|
2023-02-09 17:18:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-12 13:36:28 +00:00
|
|
|
SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol,
|
|
|
|
devnull ).model;
|
2023-02-13 18:38:43 +00:00
|
|
|
|
|
|
|
SPICE_ITEM spiceItem;
|
|
|
|
spiceItem.refName = ref;
|
|
|
|
ref = model.SpiceGenerator().ItemName( spiceItem );
|
2023-02-09 17:18:56 +00:00
|
|
|
|
|
|
|
for( const auto& modelPin : model.GetPins() )
|
|
|
|
{
|
|
|
|
SCH_PIN* symbolPin = symbol->GetPin( modelPin.get().symbolPinNumber );
|
2024-05-10 19:53:30 +00:00
|
|
|
wxString signalName = ref + wxS( ":" ) + modelPin.get().modelPinName;
|
2023-02-09 17:18:56 +00:00
|
|
|
wxString op = m_schematic->GetOperatingPoint( signalName,
|
|
|
|
settings.m_OPO_IPrecision,
|
|
|
|
settings.m_OPO_IRange );
|
|
|
|
|
2023-02-13 18:07:58 +00:00
|
|
|
if( symbolPin && !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
|
2023-02-09 17:18:56 +00:00
|
|
|
{
|
|
|
|
symbolPin->SetOperatingPoint( op );
|
|
|
|
GetCanvas()->GetView()->Update( symbol );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( const auto& [ key, subgraphList ] : m_schematic->m_connectionGraph->GetNetMap() )
|
|
|
|
{
|
|
|
|
wxString op = m_schematic->GetOperatingPoint( key.Name, settings.m_OPO_VPrecision,
|
|
|
|
settings.m_OPO_VRange );
|
|
|
|
|
2023-02-13 18:07:58 +00:00
|
|
|
if( !op.IsEmpty() && op != wxS( "--" ) && op != wxS( "?" ) )
|
2023-02-09 17:18:56 +00:00
|
|
|
{
|
|
|
|
for( CONNECTION_SUBGRAPH* subgraph : subgraphList )
|
|
|
|
{
|
|
|
|
SCH_LINE* longestWire = nullptr;
|
|
|
|
double length = 0.0;
|
|
|
|
|
2024-06-02 21:26:49 +00:00
|
|
|
if( subgraph->GetSheet().GetExcludedFromSim() )
|
|
|
|
continue;
|
|
|
|
|
2023-03-03 22:06:41 +00:00
|
|
|
for( SCH_ITEM* item : subgraph->GetItems() )
|
2023-02-09 17:18:56 +00:00
|
|
|
{
|
2024-06-21 18:07:42 +00:00
|
|
|
if( item->Type() == SCH_LINE_T )
|
2023-02-09 17:18:56 +00:00
|
|
|
{
|
2024-06-21 18:07:42 +00:00
|
|
|
SCH_LINE* line = static_cast<SCH_LINE*>( item );
|
2023-02-09 17:18:56 +00:00
|
|
|
|
2024-06-21 18:07:42 +00:00
|
|
|
if( line->IsWire() && line->GetLength() > length )
|
2023-02-09 17:18:56 +00:00
|
|
|
{
|
2024-06-21 18:07:42 +00:00
|
|
|
longestWire = line;
|
|
|
|
length = line->GetLength();
|
2023-02-09 17:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( longestWire )
|
|
|
|
{
|
|
|
|
longestWire->SetOperatingPoint( op );
|
|
|
|
GetCanvas()->GetView()->Update( longestWire );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-05 20:47:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-30 13:01:48 +00:00
|
|
|
void SCH_EDIT_FRAME::AutoRotateItem( SCH_SCREEN* aScreen, SCH_ITEM* aItem )
|
|
|
|
{
|
2024-06-21 18:07:42 +00:00
|
|
|
if( aItem->Type() == SCH_GLOBAL_LABEL_T || aItem->Type() == SCH_HIER_LABEL_T )
|
2022-08-30 13:01:48 +00:00
|
|
|
{
|
2023-07-15 21:39:07 +00:00
|
|
|
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
|
|
|
|
|
2022-08-30 13:01:48 +00:00
|
|
|
if( label->AutoRotateOnPlacement() )
|
|
|
|
{
|
2023-09-07 16:09:53 +00:00
|
|
|
SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
|
|
|
|
label->GetSpinStyle(),
|
|
|
|
&GetCurrentSheet() );
|
2023-07-15 21:39:07 +00:00
|
|
|
|
2023-09-07 16:09:53 +00:00
|
|
|
if( spin != label->GetSpinStyle() )
|
2022-08-30 13:01:48 +00:00
|
|
|
{
|
2023-09-07 16:09:53 +00:00
|
|
|
label->SetSpinStyle( spin );
|
2023-07-15 21:39:07 +00:00
|
|
|
|
2022-08-30 13:01:48 +00:00
|
|
|
for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
|
|
|
|
{
|
|
|
|
SCH_LABEL_BASE* otherLabel = static_cast<SCH_LABEL_BASE*>( item );
|
2023-07-15 21:39:07 +00:00
|
|
|
|
2022-08-30 13:01:48 +00:00
|
|
|
if( otherLabel != label && otherLabel->GetText() == label->GetText() )
|
|
|
|
otherLabel->AutoplaceFields( aScreen, false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-12 00:05:43 +00:00
|
|
|
void SCH_EDIT_FRAME::updateTitle()
|
2012-01-14 11:52:46 +00:00
|
|
|
{
|
2021-10-14 13:12:40 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
|
|
|
|
wxCHECK( screen, /* void */ );
|
|
|
|
|
2012-01-14 11:52:46 +00:00
|
|
|
wxString title;
|
|
|
|
|
2021-10-14 13:12:40 +00:00
|
|
|
if( !screen->GetFileName().IsEmpty() )
|
2012-01-14 11:52:46 +00:00
|
|
|
{
|
2021-10-14 13:12:40 +00:00
|
|
|
wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
|
2021-02-18 15:49:35 +00:00
|
|
|
bool readOnly = false;
|
|
|
|
bool unsaved = false;
|
2012-01-14 11:52:46 +00:00
|
|
|
|
2021-10-14 13:12:40 +00:00
|
|
|
if( fn.IsOk() && screen->FileExists() )
|
|
|
|
readOnly = screen->IsReadOnly();
|
2012-01-14 11:52:46 +00:00
|
|
|
else
|
2021-02-18 15:49:35 +00:00
|
|
|
unsaved = true;
|
2020-04-13 20:02:35 +00:00
|
|
|
|
2021-06-20 21:46:41 +00:00
|
|
|
if( IsContentModified() )
|
|
|
|
title = wxT( "*" );
|
|
|
|
|
|
|
|
title += fn.GetName();
|
2022-12-12 11:00:18 +00:00
|
|
|
|
|
|
|
wxString sheetPath = GetCurrentSheet().PathHumanReadable( false, true );
|
|
|
|
|
|
|
|
if( sheetPath != title )
|
|
|
|
title += wxString::Format( wxT( " [%s]" ), sheetPath );
|
2021-06-20 21:46:41 +00:00
|
|
|
|
|
|
|
if( readOnly )
|
|
|
|
title += wxS( " " ) + _( "[Read Only]" );
|
|
|
|
|
|
|
|
if( unsaved )
|
|
|
|
title += wxS( " " ) + _( "[Unsaved]" );
|
2012-01-14 11:52:46 +00:00
|
|
|
}
|
2021-06-20 21:46:41 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
title = _( "[no schematic loaded]" );
|
|
|
|
}
|
|
|
|
|
|
|
|
title += wxT( " \u2014 " ) + _( "Schematic Editor" );
|
2012-05-10 06:25:27 +00:00
|
|
|
|
|
|
|
SetTitle( title );
|
2012-01-14 11:52:46 +00:00
|
|
|
}
|
2017-12-24 17:57:57 +00:00
|
|
|
|
|
|
|
|
Mark null project initial screen as zoom-initialized
The variable `m_Initialized` in `BASE_SCREEN` is used by
`SCH_EDIT_FRAME` to mark whether a screen had its zoom level initialized
by the "zoom to fit screen" action. When this variable is `false`, the
function `SCH_EDIT_FRAME::DisplayCurrentSheet()` performs "zoom to fit
screen", modifying the zoom level. This function is indirectly called in
the undo routines, so if `m_Initialized` is not set to `true`, a zoom
change will occur when the user undoes an operation, a behavior that is
undesired.
`m_Initialized` was not initialized to `true` for the null schematic
(the schematic that is loaded if no project is loaded), causing the
aforementioned undesired behavior.
To prevent this, I've changed the `SCH_EDIT_FRAME` constructor to set
`m_Initialized` to `true`, since it zooms to fit screen already. I've
moved `m_Initialized` from `BASE_SCREEN` to `SCH_SCREEN`, as it is used
only in Eeschema, and renamed it to `m_zoomInitialized`, a name I
believe that better describes what this variable does.
I've also introduced the function `SCH_EDIT_FRAME::initScreenZoom()` to
group the "zoom to fit screen" action with setting `m_Initialized` to
`true`, as they often should occur together.
I'd also like to say that I'm not confident whether
`SCH_EDIT_FRAME::DisplayCurrentSheet()` should perform the zoom level
initialization at this point, but I have decided to not change this
behavior for now, as the commit history suggests it's several years old.
Fixes https://gitlab.com/kicad/code/kicad/issues/7343
2021-01-30 22:47:39 +00:00
|
|
|
void SCH_EDIT_FRAME::initScreenZoom()
|
|
|
|
{
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen );
|
Mark null project initial screen as zoom-initialized
The variable `m_Initialized` in `BASE_SCREEN` is used by
`SCH_EDIT_FRAME` to mark whether a screen had its zoom level initialized
by the "zoom to fit screen" action. When this variable is `false`, the
function `SCH_EDIT_FRAME::DisplayCurrentSheet()` performs "zoom to fit
screen", modifying the zoom level. This function is indirectly called in
the undo routines, so if `m_Initialized` is not set to `true`, a zoom
change will occur when the user undoes an operation, a behavior that is
undesired.
`m_Initialized` was not initialized to `true` for the null schematic
(the schematic that is loaded if no project is loaded), causing the
aforementioned undesired behavior.
To prevent this, I've changed the `SCH_EDIT_FRAME` constructor to set
`m_Initialized` to `true`, since it zooms to fit screen already. I've
moved `m_Initialized` from `BASE_SCREEN` to `SCH_SCREEN`, as it is used
only in Eeschema, and renamed it to `m_zoomInitialized`, a name I
believe that better describes what this variable does.
I've also introduced the function `SCH_EDIT_FRAME::initScreenZoom()` to
group the "zoom to fit screen" action with setting `m_Initialized` to
`true`, as they often should occur together.
I'd also like to say that I'm not confident whether
`SCH_EDIT_FRAME::DisplayCurrentSheet()` should perform the zoom level
initialization at this point, but I have decided to not change this
behavior for now, as the commit history suggests it's several years old.
Fixes https://gitlab.com/kicad/code/kicad/issues/7343
2021-01-30 22:47:39 +00:00
|
|
|
GetScreen()->m_zoomInitialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags )
|
2019-03-11 21:32:05 +00:00
|
|
|
{
|
2023-05-17 00:06:21 +00:00
|
|
|
wxString highlightedConn = GetHighlightedConnection();
|
2024-04-03 18:44:40 +00:00
|
|
|
bool hasHighlightedConn = !highlightedConn.IsEmpty();
|
2020-08-31 14:11:54 +00:00
|
|
|
SCHEMATIC_SETTINGS& settings = Schematic().Settings();
|
2024-06-06 16:58:48 +00:00
|
|
|
SCH_SHEET_LIST list = Schematic().BuildSheetListSortedByPageNumbers();
|
2023-06-09 21:41:33 +00:00
|
|
|
SCH_COMMIT localCommit( m_toolManager );
|
2023-06-09 16:24:49 +00:00
|
|
|
|
|
|
|
if( !aCommit )
|
2023-06-09 21:41:33 +00:00
|
|
|
aCommit = &localCommit;
|
2023-05-17 00:06:21 +00:00
|
|
|
|
2021-05-01 14:08:21 +00:00
|
|
|
#ifdef PROFILE
|
2022-09-17 18:43:46 +00:00
|
|
|
PROF_TIMER timer;
|
2021-05-01 14:08:21 +00:00
|
|
|
#endif
|
2019-04-11 03:29:17 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
// Ensure schematic graph is accurate
|
2019-11-10 23:24:27 +00:00
|
|
|
if( aCleanupFlags == LOCAL_CLEANUP )
|
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
SchematicCleanUp( aCommit, GetScreen() );
|
2019-11-10 23:24:27 +00:00
|
|
|
}
|
|
|
|
else if( aCleanupFlags == GLOBAL_CLEANUP )
|
2019-04-13 02:46:12 +00:00
|
|
|
{
|
2021-03-09 21:24:03 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheet : list )
|
2023-06-09 16:24:49 +00:00
|
|
|
SchematicCleanUp( aCommit, sheet.LastScreen() );
|
2019-04-13 02:46:12 +00:00
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2021-05-01 14:08:21 +00:00
|
|
|
#ifdef PROFILE
|
2019-04-11 03:29:17 +00:00
|
|
|
timer.Stop();
|
|
|
|
wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
|
2021-05-01 14:08:21 +00:00
|
|
|
#endif
|
2019-04-11 03:29:17 +00:00
|
|
|
|
2020-12-20 17:48:15 +00:00
|
|
|
if( settings.m_IntersheetRefsShow )
|
2020-11-29 16:31:43 +00:00
|
|
|
RecomputeIntersheetRefs();
|
2020-08-31 14:11:54 +00:00
|
|
|
|
2020-12-06 21:23:16 +00:00
|
|
|
std::function<void( SCH_ITEM* )> changeHandler =
|
|
|
|
[&]( SCH_ITEM* aChangedItem ) -> void
|
|
|
|
{
|
|
|
|
GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
|
2023-05-17 00:06:21 +00:00
|
|
|
|
|
|
|
SCH_CONNECTION* connection = aChangedItem->Connection();
|
|
|
|
|
2024-04-03 18:44:40 +00:00
|
|
|
if( m_highlightedConnChanged )
|
|
|
|
return;
|
2024-04-17 18:31:50 +00:00
|
|
|
|
|
|
|
if( !hasHighlightedConn )
|
|
|
|
{
|
|
|
|
// No highlighted connection, but connectivity has changed, so refresh
|
|
|
|
// the list of all nets
|
2024-04-03 18:44:40 +00:00
|
|
|
m_highlightedConnChanged = true;
|
2024-04-17 18:31:50 +00:00
|
|
|
}
|
2024-04-03 18:44:40 +00:00
|
|
|
else if( connection
|
|
|
|
&& ( connection->Name() == highlightedConn
|
|
|
|
|| connection->HasDriverChanged() ) )
|
|
|
|
{
|
2023-05-20 17:47:12 +00:00
|
|
|
m_highlightedConnChanged = true;
|
2024-04-03 18:44:40 +00:00
|
|
|
}
|
2020-12-06 21:23:16 +00:00
|
|
|
};
|
|
|
|
|
2023-04-08 15:22:34 +00:00
|
|
|
if( !ADVANCED_CFG::GetCfg().m_IncrementalConnectivity || aCleanupFlags == GLOBAL_CLEANUP
|
2024-06-03 18:33:29 +00:00
|
|
|
|| m_undoList.m_CommandsList.empty()|| Schematic().ConnectionGraph()->IsMinor() )
|
2023-04-08 15:22:34 +00:00
|
|
|
{
|
2024-04-25 14:24:46 +00:00
|
|
|
// Update all rule areas so we can cascade implied connectivity changes
|
|
|
|
std::unordered_set<SCH_SCREEN*> all_screens;
|
|
|
|
|
|
|
|
for( const SCH_SHEET_PATH& path : list )
|
|
|
|
all_screens.insert( path.LastScreen() );
|
|
|
|
|
|
|
|
SCH_RULE_AREA::UpdateRuleAreasInScreens( all_screens, GetCanvas()->GetView() );
|
|
|
|
|
|
|
|
// Recalculate all connectivity
|
2023-04-08 15:22:34 +00:00
|
|
|
Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-04-25 14:24:46 +00:00
|
|
|
struct CHANGED_ITEM
|
|
|
|
{
|
|
|
|
SCH_ITEM* item;
|
|
|
|
SCH_ITEM* linked_item;
|
|
|
|
SCH_SCREEN* screen;
|
|
|
|
};
|
|
|
|
|
2023-09-16 19:42:48 +00:00
|
|
|
PICKED_ITEMS_LIST* changed_list = m_undoList.m_CommandsList.back();
|
2023-04-08 15:22:34 +00:00
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
// Final change sets
|
|
|
|
std::set<SCH_ITEM*> changed_items;
|
|
|
|
std::set<VECTOR2I> pts;
|
|
|
|
std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> item_paths;
|
2024-01-21 16:53:05 +00:00
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
// Working change sets
|
|
|
|
std::unordered_set<SCH_SCREEN*> changed_screens;
|
|
|
|
std::set<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> changed_rule_areas;
|
|
|
|
std::vector<CHANGED_ITEM> changed_connectable_items;
|
2023-05-10 18:25:53 +00:00
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
// Lambda to add an item to the connectivity update sets
|
2024-04-26 11:56:37 +00:00
|
|
|
auto addItemToChangeSet = [&changed_items, &pts, &item_paths]( CHANGED_ITEM itemData )
|
2024-04-25 14:24:46 +00:00
|
|
|
{
|
2024-06-03 10:11:04 +00:00
|
|
|
std::vector<SCH_SHEET_PATH>& paths = itemData.screen->GetClientSheetPaths();
|
2023-05-10 18:25:53 +00:00
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
std::vector<VECTOR2I> tmp_pts = itemData.item->GetConnectionPoints();
|
2024-04-24 19:44:32 +00:00
|
|
|
pts.insert( tmp_pts.begin(), tmp_pts.end() );
|
2024-04-25 14:24:46 +00:00
|
|
|
changed_items.insert( itemData.item );
|
2023-09-16 19:42:48 +00:00
|
|
|
|
2024-04-24 02:35:29 +00:00
|
|
|
for( SCH_SHEET_PATH& path : paths )
|
2024-04-25 14:24:46 +00:00
|
|
|
item_paths.insert( std::make_pair( path, itemData.item ) );
|
2024-04-24 02:35:29 +00:00
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
if( !itemData.linked_item || !itemData.linked_item->IsConnectable() )
|
|
|
|
return;
|
2024-04-24 02:35:29 +00:00
|
|
|
|
2024-04-25 14:24:46 +00:00
|
|
|
tmp_pts = itemData.linked_item->GetConnectionPoints();
|
2024-04-24 19:44:32 +00:00
|
|
|
pts.insert( tmp_pts.begin(), tmp_pts.end() );
|
2024-04-25 14:24:46 +00:00
|
|
|
changed_items.insert( itemData.linked_item );
|
2024-04-24 02:35:29 +00:00
|
|
|
|
|
|
|
// We have to directly add the pins here because the link may not exist on the schematic
|
|
|
|
// anymore and so won't be picked up by GetScreen()->Items().Overlapping() below.
|
2024-04-25 14:24:46 +00:00
|
|
|
if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( itemData.linked_item ) )
|
2024-04-24 02:35:29 +00:00
|
|
|
{
|
|
|
|
std::vector<SCH_PIN*> pins = symbol->GetPins();
|
|
|
|
changed_items.insert( pins.begin(), pins.end() );
|
|
|
|
}
|
|
|
|
|
2023-09-16 19:42:48 +00:00
|
|
|
for( SCH_SHEET_PATH& path : paths )
|
2024-04-25 14:24:46 +00:00
|
|
|
item_paths.insert( std::make_pair( path, itemData.linked_item ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
// Get all changed connectable items and determine all changed screens
|
|
|
|
for( unsigned ii = 0; ii < changed_list->GetCount(); ++ii )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItem( ii ) );
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* screen =
|
|
|
|
static_cast<SCH_SCREEN*>( changed_list->GetScreenForItem( ii ) );
|
|
|
|
changed_screens.insert( screen );
|
|
|
|
|
|
|
|
if( item->Type() == SCH_RULE_AREA_T )
|
|
|
|
{
|
|
|
|
SCH_RULE_AREA* ruleArea = static_cast<SCH_RULE_AREA*>( item );
|
|
|
|
|
|
|
|
// Clear item and directive associations for this rule area
|
|
|
|
ruleArea->ResetDirectivesAndItems( GetCanvas()->GetView() );
|
|
|
|
|
|
|
|
changed_rule_areas.insert( { ruleArea, screen } );
|
|
|
|
}
|
|
|
|
else if( item->IsConnectable() )
|
|
|
|
{
|
|
|
|
SCH_ITEM* linked_item =
|
|
|
|
dynamic_cast<SCH_ITEM*>( changed_list->GetPickedItemLink( ii ) );
|
|
|
|
changed_connectable_items.push_back( { item, linked_item, screen } );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update rule areas in changed screens to propagate any directive connectivity changes
|
|
|
|
std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> forceUpdateRuleAreas =
|
|
|
|
SCH_RULE_AREA::UpdateRuleAreasInScreens( changed_screens, GetCanvas()->GetView() );
|
|
|
|
|
|
|
|
std::for_each( forceUpdateRuleAreas.begin(), forceUpdateRuleAreas.end(),
|
|
|
|
[&]( std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& updatedRuleArea )
|
|
|
|
{
|
|
|
|
changed_rule_areas.insert( updatedRuleArea );
|
|
|
|
} );
|
|
|
|
|
|
|
|
// If a SCH_RULE_AREA was changed, we need to add all past and present contained items to
|
|
|
|
// update their connectivity
|
|
|
|
for( const std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& changedRuleArea : changed_rule_areas )
|
|
|
|
{
|
|
|
|
for( SCH_ITEM* containedItem :
|
|
|
|
changedRuleArea.first->GetPastAndPresentContainedItems() )
|
|
|
|
{
|
|
|
|
addItemToChangeSet( { containedItem, nullptr, changedRuleArea.second } );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add all changed items, and associated items, to the change set
|
|
|
|
for( CHANGED_ITEM& changed_item_data : changed_connectable_items )
|
|
|
|
{
|
|
|
|
addItemToChangeSet( changed_item_data );
|
|
|
|
|
|
|
|
// If a SCH_DIRECTIVE_LABEL was changed which is attached to a SCH_RULE_AREA, we need
|
|
|
|
// to add the contained items to the change set to force update of their connectivity
|
|
|
|
if( changed_item_data.item->Type() == SCH_DIRECTIVE_LABEL_T )
|
|
|
|
{
|
|
|
|
const std::vector<VECTOR2I> labelConnectionPoints =
|
|
|
|
changed_item_data.item->GetConnectionPoints();
|
|
|
|
|
|
|
|
EE_RTREE::EE_TYPE candidateRuleAreas =
|
|
|
|
changed_item_data.screen->Items().Overlapping(
|
|
|
|
SCH_RULE_AREA_T, changed_item_data.item->GetBoundingBox() );
|
|
|
|
|
|
|
|
for( SCH_ITEM* candidateRuleArea : candidateRuleAreas )
|
|
|
|
{
|
|
|
|
SCH_RULE_AREA* ruleArea = static_cast<SCH_RULE_AREA*>( candidateRuleArea );
|
|
|
|
std::vector<SHAPE*> borderShapes = ruleArea->MakeEffectiveShapes( true );
|
|
|
|
|
|
|
|
if( ruleArea->GetPolyShape().CollideEdge( labelConnectionPoints[0], nullptr,
|
|
|
|
5 ) )
|
|
|
|
{
|
|
|
|
for( SCH_ITEM* containedItem : ruleArea->GetPastAndPresentContainedItems() )
|
|
|
|
addItemToChangeSet(
|
|
|
|
{ containedItem, nullptr, changed_item_data.screen } );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-08 15:22:34 +00:00
|
|
|
}
|
|
|
|
|
2024-04-24 19:44:32 +00:00
|
|
|
for( const VECTOR2I& pt: pts )
|
2023-04-08 15:22:34 +00:00
|
|
|
{
|
2023-06-24 17:19:44 +00:00
|
|
|
for( SCH_ITEM* item : GetScreen()->Items().Overlapping( pt ) )
|
2023-04-08 15:22:34 +00:00
|
|
|
{
|
2024-04-10 23:40:43 +00:00
|
|
|
// Leave this check in place. Overlapping items are not necessarily connectable.
|
|
|
|
if( !item->IsConnectable() )
|
|
|
|
continue;
|
|
|
|
|
2023-06-24 17:19:44 +00:00
|
|
|
if( item->Type() == SCH_LINE_T )
|
2023-04-08 15:22:34 +00:00
|
|
|
{
|
2023-06-24 17:19:44 +00:00
|
|
|
if( item->HitTest( pt ) )
|
2023-04-08 15:22:34 +00:00
|
|
|
changed_items.insert( item );
|
|
|
|
}
|
2024-04-10 23:40:43 +00:00
|
|
|
else if( item->Type() == SCH_SYMBOL_T && item->IsConnected( pt ) )
|
2023-04-21 20:25:01 +00:00
|
|
|
{
|
2023-06-24 17:19:44 +00:00
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
|
|
|
std::vector<SCH_PIN*> pins = symbol->GetPins();
|
|
|
|
|
2023-04-21 20:25:01 +00:00
|
|
|
changed_items.insert( pins.begin(), pins.end() );
|
|
|
|
}
|
2024-01-21 16:53:05 +00:00
|
|
|
else if( item->Type() == SCH_SHEET_T )
|
|
|
|
{
|
|
|
|
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
|
|
|
|
|
|
|
|
wxCHECK2( sheet, continue );
|
|
|
|
|
|
|
|
std::vector<SCH_SHEET_PIN*> sheetPins = sheet->GetPins();
|
|
|
|
changed_items.insert( sheetPins.begin(), sheetPins.end() );
|
|
|
|
}
|
|
|
|
else
|
2023-06-24 17:19:44 +00:00
|
|
|
{
|
|
|
|
if( item->IsConnected( pt ) )
|
|
|
|
changed_items.insert( item );
|
|
|
|
}
|
2023-04-08 15:22:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> all_items =
|
2023-06-12 18:33:52 +00:00
|
|
|
Schematic().ConnectionGraph()->ExtractAffectedItems( changed_items );
|
2023-04-08 15:22:34 +00:00
|
|
|
|
2023-09-16 19:42:48 +00:00
|
|
|
all_items.insert( item_paths.begin(), item_paths.end() );
|
|
|
|
|
2023-04-08 15:22:34 +00:00
|
|
|
CONNECTION_GRAPH new_graph( &Schematic() );
|
|
|
|
|
|
|
|
new_graph.SetLastCodes( Schematic().ConnectionGraph() );
|
|
|
|
|
|
|
|
for( auto&[ path, item ] : all_items )
|
|
|
|
{
|
2024-02-10 20:41:10 +00:00
|
|
|
wxCHECK2( item, continue );
|
2024-04-10 23:40:43 +00:00
|
|
|
item->SetConnectivityDirty();
|
2023-04-08 15:22:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
new_graph.Recalculate( list, false, &changeHandler );
|
|
|
|
Schematic().ConnectionGraph()->Merge( new_graph );
|
|
|
|
}
|
2021-07-03 20:42:14 +00:00
|
|
|
|
2022-12-03 13:25:20 +00:00
|
|
|
GetCanvas()->GetView()->UpdateAllItemsConditionally(
|
2023-02-07 15:09:24 +00:00
|
|
|
[&]( KIGFX::VIEW_ITEM* aItem ) -> int
|
2021-07-23 15:44:15 +00:00
|
|
|
{
|
2023-02-05 20:50:24 +00:00
|
|
|
int flags = 0;
|
|
|
|
SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
|
2021-07-23 15:44:15 +00:00
|
|
|
SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
|
|
|
|
|
2024-06-03 12:59:40 +00:00
|
|
|
auto invalidateTextVars =
|
|
|
|
[&flags]( EDA_TEXT* text )
|
|
|
|
{
|
|
|
|
if( text->HasTextVars() )
|
|
|
|
{
|
|
|
|
text->ClearRenderCache();
|
|
|
|
text->ClearBoundingBoxCache();
|
|
|
|
flags |= KIGFX::GEOMETRY | KIGFX::REPAINT;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-23 15:44:15 +00:00
|
|
|
if( connection && connection->HasDriverChanged() )
|
|
|
|
{
|
|
|
|
connection->ClearDriverChanged();
|
2023-02-05 20:50:24 +00:00
|
|
|
flags |= KIGFX::REPAINT;
|
2021-07-23 15:44:15 +00:00
|
|
|
}
|
|
|
|
|
2023-02-05 20:50:24 +00:00
|
|
|
if( item )
|
2022-12-03 13:25:20 +00:00
|
|
|
{
|
2023-02-05 20:50:24 +00:00
|
|
|
item->RunOnChildren(
|
2024-06-03 12:59:40 +00:00
|
|
|
[&invalidateTextVars]( SCH_ITEM* aChild )
|
2023-02-05 20:50:24 +00:00
|
|
|
{
|
2024-06-03 12:59:40 +00:00
|
|
|
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aChild ) )
|
|
|
|
invalidateTextVars( text );
|
2023-02-05 20:50:24 +00:00
|
|
|
} );
|
|
|
|
|
2023-02-07 15:09:24 +00:00
|
|
|
if( flags & KIGFX::GEOMETRY )
|
|
|
|
GetScreen()->Update( item, false ); // Refresh RTree
|
2022-12-03 13:25:20 +00:00
|
|
|
}
|
2021-07-23 15:44:15 +00:00
|
|
|
|
2024-06-03 12:59:40 +00:00
|
|
|
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
|
|
|
|
invalidateTextVars( text );
|
|
|
|
|
2023-02-05 20:50:24 +00:00
|
|
|
return flags;
|
2021-07-23 15:44:15 +00:00
|
|
|
} );
|
|
|
|
|
2024-04-03 18:44:40 +00:00
|
|
|
if( m_highlightedConnChanged
|
|
|
|
|| !Schematic().ConnectionGraph()->FindFirstSubgraphByName( highlightedConn ) )
|
2023-05-17 00:06:21 +00:00
|
|
|
{
|
2024-04-03 18:44:40 +00:00
|
|
|
GetToolManager()->RunAction( EE_ACTIONS::updateNetHighlighting );
|
|
|
|
RefreshNetNavigator();
|
2023-05-20 17:47:12 +00:00
|
|
|
m_highlightedConnChanged = false;
|
2023-05-17 00:06:21 +00:00
|
|
|
}
|
2023-06-09 16:24:49 +00:00
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
if( !localCommit.Empty() )
|
|
|
|
localCommit.Push( _( "Schematic Cleanup" ) );
|
2019-03-11 21:32:05 +00:00
|
|
|
}
|
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
|
2022-12-03 13:25:20 +00:00
|
|
|
void SCH_EDIT_FRAME::RecomputeIntersheetRefs()
|
2020-08-31 14:11:54 +00:00
|
|
|
{
|
2022-12-03 13:25:20 +00:00
|
|
|
Schematic().RecomputeIntersheetRefs( [&]( SCH_GLOBALLABEL* label )
|
2022-11-03 04:12:53 +00:00
|
|
|
{
|
2022-12-03 13:25:20 +00:00
|
|
|
for( SCH_FIELD& field : label->GetFields() )
|
|
|
|
field.ClearBoundingBoxCache();
|
|
|
|
|
|
|
|
label->ClearBoundingBoxCache();
|
2022-11-03 04:12:53 +00:00
|
|
|
GetCanvas()->GetView()->Update( label );
|
2022-12-03 13:25:20 +00:00
|
|
|
} );
|
2020-08-31 14:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
void SCH_EDIT_FRAME::ShowAllIntersheetRefs( bool aShow )
|
|
|
|
{
|
2022-12-03 13:25:20 +00:00
|
|
|
RecomputeIntersheetRefs();
|
2020-11-29 16:31:43 +00:00
|
|
|
|
2021-10-12 20:05:37 +00:00
|
|
|
GetCanvas()->GetView()->SetLayerVisible( LAYER_INTERSHEET_REFS, aShow );
|
2020-08-31 14:11:54 +00:00
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2018-01-08 04:05:03 +00:00
|
|
|
{
|
2023-01-23 23:40:58 +00:00
|
|
|
SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
|
|
|
|
2020-08-31 14:11:54 +00:00
|
|
|
SCHEMATIC_SETTINGS& settings = Schematic().Settings();
|
2021-11-07 13:48:51 +00:00
|
|
|
|
|
|
|
settings.m_JunctionSize = GetSchematicJunctionSize();
|
2020-07-17 20:04:14 +00:00
|
|
|
|
2020-11-17 16:02:47 +00:00
|
|
|
ShowAllIntersheetRefs( settings.m_IntersheetRefsShow );
|
2020-08-31 14:11:54 +00:00
|
|
|
|
2021-11-05 21:16:26 +00:00
|
|
|
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
2021-08-29 23:33:08 +00:00
|
|
|
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
|
2022-10-22 20:32:10 +00:00
|
|
|
GetRenderSettings()->SetDefaultFont( cfg->m_Appearance.default_font );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2021-11-05 21:16:26 +00:00
|
|
|
KIGFX::VIEW* view = GetCanvas()->GetView();
|
|
|
|
view->SetLayerVisible( LAYER_ERC_ERR, cfg->m_Appearance.show_erc_errors );
|
|
|
|
view->SetLayerVisible( LAYER_ERC_WARN, cfg->m_Appearance.show_erc_warnings );
|
|
|
|
view->SetLayerVisible( LAYER_ERC_EXCLUSION, cfg->m_Appearance.show_erc_exclusions );
|
2023-02-09 17:18:56 +00:00
|
|
|
view->SetLayerVisible( LAYER_OP_VOLTAGES, cfg->m_Appearance.show_op_voltages );
|
|
|
|
view->SetLayerVisible( LAYER_OP_CURRENTS, cfg->m_Appearance.show_op_currents );
|
|
|
|
|
|
|
|
RefreshOperatingPointDisplay();
|
2021-11-05 21:16:26 +00:00
|
|
|
|
2023-01-23 23:40:58 +00:00
|
|
|
settings.m_TemplateFieldNames.DeleteAllFieldNameTemplates( true /* global */ );
|
|
|
|
|
|
|
|
if( !cfg->m_Drawing.field_names.IsEmpty() )
|
|
|
|
settings.m_TemplateFieldNames.AddTemplateFieldNames( cfg->m_Drawing.field_names );
|
|
|
|
|
2022-01-09 00:44:24 +00:00
|
|
|
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
|
|
|
|
|
|
|
|
for( SCH_ITEM* item : screen->Items() )
|
|
|
|
item->ClearCaches();
|
|
|
|
|
2023-06-11 14:44:12 +00:00
|
|
|
for( const auto& [ libItemName, libSymbol ] : screen->GetLibSymbols() )
|
|
|
|
libSymbol->ClearCaches();
|
2022-01-09 00:44:24 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
GetCanvas()->ForceRefresh();
|
|
|
|
|
2019-07-20 15:52:30 +00:00
|
|
|
RecreateToolbars();
|
2018-01-08 04:05:03 +00:00
|
|
|
Layout();
|
|
|
|
SendSizeEvent();
|
|
|
|
}
|
2018-06-30 22:38:04 +00:00
|
|
|
|
|
|
|
|
2018-11-20 14:11:22 +00:00
|
|
|
void SCH_EDIT_FRAME::OnPageSettingsChange()
|
|
|
|
{
|
2021-01-18 15:07:09 +00:00
|
|
|
// Store the current zoom level into the current screen before calling
|
|
|
|
// DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
|
|
|
|
GetScreen()->m_LastZoomLevel = GetCanvas()->GetView()->GetScale();
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2018-11-20 14:11:22 +00:00
|
|
|
// Rebuild the sheet view (draw area and any other items):
|
|
|
|
DisplayCurrentSheet();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-30 22:38:04 +00:00
|
|
|
void SCH_EDIT_FRAME::ShowChangedLanguage()
|
|
|
|
{
|
|
|
|
// call my base class
|
|
|
|
SCH_BASE_FRAME::ShowChangedLanguage();
|
|
|
|
|
|
|
|
// tooltips in toolbars
|
2019-07-20 15:52:30 +00:00
|
|
|
RecreateToolbars();
|
2018-06-30 22:38:04 +00:00
|
|
|
|
2022-12-28 00:11:05 +00:00
|
|
|
m_auimgr.GetPane( m_hierarchy ).Caption( _( "Schematic Hierarchy" ) );
|
2024-02-25 22:39:14 +00:00
|
|
|
m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
|
|
|
|
m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
|
2022-12-28 00:11:05 +00:00
|
|
|
m_auimgr.Update();
|
|
|
|
m_hierarchy->UpdateHierarchyTree();
|
|
|
|
|
2018-06-30 22:38:04 +00:00
|
|
|
// status bar
|
|
|
|
UpdateMsgPanel();
|
2019-02-25 18:26:14 +00:00
|
|
|
|
2023-01-12 00:05:43 +00:00
|
|
|
updateTitle();
|
2022-04-05 12:15:27 +00:00
|
|
|
|
2019-02-25 18:26:14 +00:00
|
|
|
// This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
|
|
|
|
// windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
|
|
|
|
// wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
|
|
|
|
// toolbar to update correctly.
|
|
|
|
#if defined( __WXMSW__ )
|
|
|
|
PostSizeEvent();
|
|
|
|
#endif
|
2018-06-30 22:38:04 +00:00
|
|
|
}
|
|
|
|
|
2018-11-04 16:37:29 +00:00
|
|
|
|
2020-08-13 21:30:30 +00:00
|
|
|
void SCH_EDIT_FRAME::UpdateNetHighlightStatus()
|
|
|
|
{
|
2023-05-17 00:06:21 +00:00
|
|
|
if( !GetHighlightedConnection().IsEmpty() )
|
2020-08-13 21:30:30 +00:00
|
|
|
{
|
|
|
|
SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
|
2023-05-17 00:06:21 +00:00
|
|
|
UnescapeString( GetHighlightedConnection() ) ) );
|
2020-08-13 21:30:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetStatusText( wxT( "" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
void SCH_EDIT_FRAME::SetScreen( BASE_SCREEN* aScreen )
|
|
|
|
{
|
2020-10-28 02:04:43 +00:00
|
|
|
if( m_toolManager )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( EE_ACTIONS::clearSelection );
|
2020-10-28 02:04:43 +00:00
|
|
|
|
2019-04-17 19:09:48 +00:00
|
|
|
SCH_BASE_FRAME::SetScreen( aScreen );
|
2019-05-31 17:37:07 +00:00
|
|
|
GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
|
2023-02-15 04:46:35 +00:00
|
|
|
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-11-04 16:37:29 +00:00
|
|
|
|
2020-09-25 07:31:56 +00:00
|
|
|
const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2020-09-25 07:31:56 +00:00
|
|
|
BOX2I bBoxDoc;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2020-09-25 07:31:56 +00:00
|
|
|
if( aIncludeAllVisible )
|
|
|
|
{
|
|
|
|
// Get the whole page size and return that
|
2022-09-16 23:25:07 +00:00
|
|
|
int sizeX = GetScreen()->GetPageSettings().GetWidthIU( schIUScale.IU_PER_MILS );
|
|
|
|
int sizeY = GetScreen()->GetPageSettings().GetHeightIU( schIUScale.IU_PER_MILS );
|
2020-09-25 07:31:56 +00:00
|
|
|
bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
// Get current drawing-sheet in a form we can compare to an EDA_ITEM
|
|
|
|
DS_PROXY_VIEW_ITEM* ds = SCH_BASE_FRAME::GetCanvas()->GetView()->GetDrawingSheet();
|
|
|
|
EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
|
2020-09-25 07:31:56 +00:00
|
|
|
|
|
|
|
// Calc the bounding box of all items on screen except the page border
|
|
|
|
for( EDA_ITEM* item : GetScreen()->Items() )
|
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
if( item != dsAsItem ) // Ignore the drawing-sheet itself
|
2022-08-30 23:28:18 +00:00
|
|
|
bBoxDoc.Merge( item->GetBoundingBox() );
|
2020-09-25 07:31:56 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-30 23:28:18 +00:00
|
|
|
|
2020-09-25 07:31:56 +00:00
|
|
|
return bBoxDoc;
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
2019-06-23 15:12:25 +00:00
|
|
|
|
2020-08-31 15:06:23 +00:00
|
|
|
|
2021-05-27 23:07:48 +00:00
|
|
|
bool SCH_EDIT_FRAME::IsContentModified() const
|
2019-12-19 15:34:01 +00:00
|
|
|
{
|
2024-06-06 16:58:48 +00:00
|
|
|
return Schematic().BuildUnorderedSheetList().IsModified();
|
2019-12-19 15:34:01 +00:00
|
|
|
}
|
2020-04-18 07:57:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool SCH_EDIT_FRAME::GetShowAllPins() const
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS* cfg = eeconfig();
|
2021-09-28 15:41:46 +00:00
|
|
|
return cfg && cfg->m_Appearance.show_hidden_pins;
|
2020-04-18 07:57:04 +00:00
|
|
|
}
|
2020-05-07 13:26:43 +00:00
|
|
|
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
void SCH_EDIT_FRAME::FocusOnItem( SCH_ITEM* aItem )
|
|
|
|
{
|
|
|
|
static KIID lastBrightenedItemID( niluuid );
|
|
|
|
|
|
|
|
SCH_SHEET_PATH dummy;
|
2024-06-06 10:31:22 +00:00
|
|
|
SCH_ITEM* lastItem = Schematic().GetItem( lastBrightenedItemID, &dummy );
|
2020-05-13 02:00:37 +00:00
|
|
|
|
|
|
|
if( lastItem && lastItem != aItem )
|
|
|
|
{
|
|
|
|
lastItem->ClearBrightened();
|
|
|
|
|
2020-08-10 11:40:58 +00:00
|
|
|
UpdateItem( lastItem );
|
2020-05-13 02:00:37 +00:00
|
|
|
lastBrightenedItemID = niluuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aItem )
|
|
|
|
{
|
2022-07-19 15:00:35 +00:00
|
|
|
if( !aItem->IsBrightened() )
|
|
|
|
{
|
|
|
|
aItem->SetBrightened();
|
2020-05-13 02:00:37 +00:00
|
|
|
|
2022-07-19 15:00:35 +00:00
|
|
|
UpdateItem( aItem );
|
|
|
|
lastBrightenedItemID = aItem->m_Uuid;
|
|
|
|
}
|
2020-05-13 02:00:37 +00:00
|
|
|
|
|
|
|
FocusOnLocation( aItem->GetFocusPosition() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-16 23:08:01 +00:00
|
|
|
wxString SCH_EDIT_FRAME::GetCurrentFileName() const
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
return Schematic().GetFileName();
|
2020-05-16 23:08:01 +00:00
|
|
|
}
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
SELECTION& SCH_EDIT_FRAME::GetCurrentSelection()
|
|
|
|
{
|
|
|
|
return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
|
|
|
|
}
|
2020-08-20 14:33:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( IsShown() )
|
|
|
|
{
|
|
|
|
// We only need this until the frame is done resizing and the final client size is
|
|
|
|
// established.
|
|
|
|
Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
|
2023-06-26 22:16:51 +00:00
|
|
|
GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
|
2020-08-20 14:33:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Skip() is called in the base class.
|
|
|
|
EDA_DRAW_FRAME::OnSize( aEvent );
|
|
|
|
}
|
2020-08-31 15:06:23 +00:00
|
|
|
|
|
|
|
|
2021-11-11 16:42:25 +00:00
|
|
|
void SCH_EDIT_FRAME::SaveSymbolToSchematic( const LIB_SYMBOL& aSymbol,
|
|
|
|
const KIID& aSchematicSymbolUUID )
|
2020-08-31 15:06:23 +00:00
|
|
|
{
|
2023-06-09 21:41:33 +00:00
|
|
|
SCH_SHEET_PATH principalPath;
|
2024-06-06 16:58:48 +00:00
|
|
|
SCH_SHEET_LIST sheets = Schematic().BuildUnorderedSheetList();
|
|
|
|
SCH_ITEM* item = sheets.GetItem( aSchematicSymbolUUID, &principalPath );
|
2023-06-09 21:41:33 +00:00
|
|
|
SCH_SYMBOL* principalSymbol = dynamic_cast<SCH_SYMBOL*>( item );
|
|
|
|
SCH_COMMIT commit( m_toolManager );
|
2020-08-31 15:06:23 +00:00
|
|
|
|
2022-12-19 21:05:56 +00:00
|
|
|
if( !principalSymbol )
|
|
|
|
return;
|
2020-08-31 15:06:23 +00:00
|
|
|
|
2022-12-19 21:05:56 +00:00
|
|
|
wxString principalRef;
|
2020-08-31 15:06:23 +00:00
|
|
|
|
2022-12-19 21:05:56 +00:00
|
|
|
if( principalSymbol->IsAnnotated( &principalPath ) )
|
|
|
|
principalRef = principalSymbol->GetRef( &principalPath, false );
|
2020-08-31 15:06:23 +00:00
|
|
|
|
2023-06-07 14:30:56 +00:00
|
|
|
std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > allUnits;
|
2023-01-02 11:36:26 +00:00
|
|
|
|
2024-06-06 16:58:48 +00:00
|
|
|
for( const SCH_SHEET_PATH& path : sheets )
|
2022-12-19 21:05:56 +00:00
|
|
|
{
|
|
|
|
for( SCH_ITEM* candidate : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
|
2020-08-31 15:06:23 +00:00
|
|
|
{
|
2022-12-19 21:05:56 +00:00
|
|
|
SCH_SYMBOL* candidateSymbol = static_cast<SCH_SYMBOL*>( candidate );
|
2020-08-31 15:06:23 +00:00
|
|
|
|
2022-12-19 21:05:56 +00:00
|
|
|
if( candidateSymbol == principalSymbol
|
|
|
|
|| ( candidateSymbol->IsAnnotated( &path )
|
|
|
|
&& candidateSymbol->GetRef( &path, false ) == principalRef ) )
|
|
|
|
{
|
2023-06-07 14:30:56 +00:00
|
|
|
allUnits.emplace_back( candidateSymbol, path );
|
2023-01-02 11:36:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-19 21:05:56 +00:00
|
|
|
|
2023-06-07 14:30:56 +00:00
|
|
|
for( auto& [ unit, path ] : allUnits )
|
2023-01-02 11:36:26 +00:00
|
|
|
{
|
|
|
|
// This needs to be done before the LIB_SYMBOL is changed to prevent stale
|
|
|
|
// library symbols in the schematic file.
|
2023-06-07 14:30:56 +00:00
|
|
|
path.LastScreen()->Remove( unit );
|
2022-12-19 21:05:56 +00:00
|
|
|
|
2023-06-07 14:30:56 +00:00
|
|
|
if( !unit->IsNew() )
|
|
|
|
commit.Modify( unit, path.LastScreen() );
|
2023-01-02 11:36:26 +00:00
|
|
|
|
2024-06-12 17:27:17 +00:00
|
|
|
unit->SetLibSymbol( aSymbol.Flatten().release() );
|
2023-06-07 14:30:56 +00:00
|
|
|
unit->UpdateFields( &GetCurrentSheet(),
|
2023-10-12 13:36:28 +00:00
|
|
|
true, /* update style */
|
|
|
|
true, /* update ref */
|
|
|
|
true, /* update other fields */
|
|
|
|
false, /* reset ref */
|
|
|
|
false /* reset other fields */ );
|
2023-01-02 11:36:26 +00:00
|
|
|
|
2023-06-07 14:30:56 +00:00
|
|
|
path.LastScreen()->Append( unit );
|
|
|
|
GetCanvas()->GetView()->Update( unit );
|
2020-08-31 15:06:23 +00:00
|
|
|
}
|
|
|
|
|
2023-06-07 14:30:56 +00:00
|
|
|
if( !commit.Empty() )
|
|
|
|
commit.Push( _( "Save Symbol to Schematic" ) );
|
2020-08-31 15:06:23 +00:00
|
|
|
}
|
2022-01-07 17:42:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
|
|
|
|
{
|
|
|
|
SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
|
|
|
|
|
|
|
|
if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
|
|
|
|
sch_item->ClearCaches();
|
2022-03-22 16:49:38 +00:00
|
|
|
}
|
2022-06-02 21:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
|
|
|
{
|
2023-03-06 12:12:11 +00:00
|
|
|
wxCHECK( m_toolManager, /* void */ );
|
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::cancelInteractive );
|
|
|
|
m_toolManager->RunAction( EE_ACTIONS::clearSelection );
|
2022-06-02 21:56:17 +00:00
|
|
|
SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
|
|
|
|
|
2023-03-06 12:12:11 +00:00
|
|
|
wxCHECK( screen, /* void */ );
|
2022-06-02 21:56:17 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( EE_ACTIONS::clearSelection );
|
2023-03-05 01:33:07 +00:00
|
|
|
|
|
|
|
SCH_BASE_FRAME::SetScreen( screen );
|
|
|
|
|
2023-03-06 12:12:11 +00:00
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2022-06-02 21:56:17 +00:00
|
|
|
|
2023-10-26 12:06:59 +00:00
|
|
|
// update the references, units, and intersheet-refs
|
2022-06-02 21:56:17 +00:00
|
|
|
GetCurrentSheet().UpdateAllScreenReferences();
|
2023-10-26 12:06:59 +00:00
|
|
|
|
|
|
|
// dangling state can also have changed if different units with different pin locations are
|
|
|
|
// used
|
|
|
|
GetCurrentSheet().LastScreen()->TestDanglingEnds();
|
2022-06-02 21:56:17 +00:00
|
|
|
SetSheetNumberAndCount();
|
2023-02-09 17:18:56 +00:00
|
|
|
RefreshOperatingPointDisplay();
|
2022-06-02 21:56:17 +00:00
|
|
|
|
2023-01-02 18:43:35 +00:00
|
|
|
EE_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
|
2023-03-06 12:12:11 +00:00
|
|
|
wxCHECK( selectionTool, /* void */ );
|
|
|
|
|
2023-01-02 18:43:35 +00:00
|
|
|
auto visit =
|
|
|
|
[&]( EDA_ITEM* item )
|
|
|
|
{
|
|
|
|
if( m_findReplaceDialog
|
|
|
|
&& !m_findReplaceData->findString.IsEmpty()
|
|
|
|
&& item->Matches( *m_findReplaceData, &GetCurrentSheet() ) )
|
|
|
|
{
|
|
|
|
item->SetForceVisible( true );
|
|
|
|
selectionTool->BrightenItem( item );
|
|
|
|
}
|
|
|
|
else if( item->IsBrightened() )
|
|
|
|
{
|
|
|
|
item->SetForceVisible( false );
|
|
|
|
selectionTool->UnbrightenItem( item );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
for( SCH_ITEM* item : screen->Items() )
|
|
|
|
{
|
|
|
|
visit( item );
|
|
|
|
|
|
|
|
item->RunOnChildren(
|
|
|
|
[&]( SCH_ITEM* aChild )
|
|
|
|
{
|
|
|
|
visit( aChild );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2022-06-02 21:56:17 +00:00
|
|
|
if( !screen->m_zoomInitialized )
|
|
|
|
{
|
|
|
|
initScreenZoom();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Set zoom to last used in this screen
|
|
|
|
GetCanvas()->GetView()->SetScale( GetScreen()->m_LastZoomLevel );
|
2023-03-05 01:33:07 +00:00
|
|
|
GetCanvas()->GetView()->SetCenter( GetScreen()->m_ScrollCenter );
|
2022-06-02 21:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-01-12 00:05:43 +00:00
|
|
|
updateTitle();
|
2022-06-02 21:56:17 +00:00
|
|
|
|
|
|
|
HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
|
|
|
|
|
2023-02-16 22:14:08 +00:00
|
|
|
// Allow tools to re-add their VIEW_ITEMs after the last call to Clear in HardRedraw
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
|
|
|
2022-06-02 21:56:17 +00:00
|
|
|
SCH_EDITOR_CONTROL* editTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
|
2023-03-06 12:12:11 +00:00
|
|
|
|
|
|
|
wxCHECK( editTool, /* void */ );
|
|
|
|
|
2022-06-02 21:56:17 +00:00
|
|
|
TOOL_EVENT dummy;
|
|
|
|
editTool->UpdateNetHighlighting( dummy );
|
|
|
|
|
|
|
|
m_hierarchy->UpdateHierarchySelection();
|
2023-08-20 20:13:07 +00:00
|
|
|
|
|
|
|
m_schematic->OnSchSheetChanged();
|
2022-06-02 21:56:17 +00:00
|
|
|
}
|
2023-03-13 16:03:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
DIALOG_BOOK_REPORTER* SCH_EDIT_FRAME::GetSymbolDiffDialog()
|
|
|
|
{
|
|
|
|
if( !m_diffSymbolDialog )
|
|
|
|
m_diffSymbolDialog = new DIALOG_BOOK_REPORTER( this, DIFF_SYMBOLS_DIALOG_NAME,
|
2023-12-13 16:07:09 +00:00
|
|
|
_( "Compare Symbol with Library" ) );
|
2023-03-13 16:03:48 +00:00
|
|
|
|
|
|
|
return m_diffSymbolDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::onCloseSymbolDiffDialog( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_diffSymbolDialog && aEvent.GetString() == DIFF_SYMBOLS_DIALOG_NAME )
|
|
|
|
{
|
|
|
|
m_diffSymbolDialog->Destroy();
|
|
|
|
m_diffSymbolDialog = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_ERC* SCH_EDIT_FRAME::GetErcDialog()
|
|
|
|
{
|
|
|
|
if( !m_ercDialog )
|
|
|
|
m_ercDialog = new DIALOG_ERC( this );
|
|
|
|
|
|
|
|
return m_ercDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::onCloseErcDialog( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_ercDialog )
|
|
|
|
{
|
|
|
|
m_ercDialog->Destroy();
|
|
|
|
m_ercDialog = nullptr;
|
|
|
|
}
|
|
|
|
}
|
2023-05-15 01:35:39 +00:00
|
|
|
|
|
|
|
|
2023-08-14 14:41:28 +00:00
|
|
|
DIALOG_SYMBOL_FIELDS_TABLE* SCH_EDIT_FRAME::GetSymbolFieldsTableDialog()
|
|
|
|
{
|
|
|
|
if( !m_symbolFieldsTableDialog )
|
|
|
|
m_symbolFieldsTableDialog = new DIALOG_SYMBOL_FIELDS_TABLE( this );
|
|
|
|
|
|
|
|
return m_symbolFieldsTableDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::onCloseSymbolFieldsTableDialog( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_symbolFieldsTableDialog )
|
|
|
|
{
|
|
|
|
m_symbolFieldsTableDialog->Destroy();
|
|
|
|
m_symbolFieldsTableDialog = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-15 01:35:39 +00:00
|
|
|
void SCH_EDIT_FRAME::AddSchematicChangeListener( wxEvtHandler* aListener )
|
|
|
|
{
|
|
|
|
auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
|
|
|
|
aListener );
|
|
|
|
|
|
|
|
// Don't add duplicate listeners.
|
|
|
|
if( it == m_schematicChangeListeners.end() )
|
|
|
|
m_schematicChangeListeners.push_back( aListener );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::RemoveSchematicChangeListener( wxEvtHandler* aListener )
|
|
|
|
{
|
|
|
|
auto it = std::find( m_schematicChangeListeners.begin(), m_schematicChangeListeners.end(),
|
|
|
|
aListener );
|
|
|
|
|
|
|
|
// Don't add duplicate listeners.
|
|
|
|
if( it != m_schematicChangeListeners.end() )
|
|
|
|
m_schematicChangeListeners.erase( it );
|
2023-05-17 00:06:21 +00:00
|
|
|
}
|
2023-05-20 17:47:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxTreeCtrl* SCH_EDIT_FRAME::createHighlightedNetNavigator()
|
|
|
|
{
|
|
|
|
m_netNavigator = new wxTreeCtrl( this, wxID_ANY, wxPoint( 0, 0 ),
|
|
|
|
FromDIP( wxSize( 160, 250 ) ),
|
|
|
|
wxTR_DEFAULT_STYLE | wxNO_BORDER );
|
|
|
|
|
|
|
|
return m_netNavigator;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-09 18:34:40 +00:00
|
|
|
void SCH_EDIT_FRAME::SetHighlightedConnection( const wxString& aConnection,
|
|
|
|
const NET_NAVIGATOR_ITEM_DATA* aSelection )
|
2023-05-20 17:47:12 +00:00
|
|
|
{
|
|
|
|
bool refreshNetNavigator = aConnection != m_highlightedConn;
|
|
|
|
|
|
|
|
m_highlightedConn = aConnection;
|
|
|
|
|
|
|
|
if( refreshNetNavigator )
|
2023-06-09 18:34:40 +00:00
|
|
|
RefreshNetNavigator( aSelection );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::unitsChangeRefresh()
|
|
|
|
{
|
2024-04-19 01:20:43 +00:00
|
|
|
if( m_netNavigator )
|
2023-06-09 18:34:40 +00:00
|
|
|
{
|
|
|
|
NET_NAVIGATOR_ITEM_DATA itemData;
|
|
|
|
wxTreeItemId selection = m_netNavigator->GetSelection();
|
|
|
|
bool refreshSelection = selection.IsOk() && ( selection != m_netNavigator->GetRootItem() );
|
|
|
|
|
|
|
|
if( refreshSelection )
|
|
|
|
{
|
|
|
|
NET_NAVIGATOR_ITEM_DATA* tmp =
|
|
|
|
dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
|
|
|
|
|
|
|
|
wxCHECK( tmp, /* void */ );
|
|
|
|
itemData = *tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_netNavigator->DeleteAllItems();
|
|
|
|
RefreshNetNavigator( refreshSelection ? &itemData : nullptr );
|
|
|
|
}
|
2023-06-21 01:57:20 +00:00
|
|
|
|
|
|
|
UpdateProperties();
|
2023-05-20 17:47:12 +00:00
|
|
|
}
|
2024-02-25 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::updateSelectionFilterVisbility()
|
|
|
|
{
|
|
|
|
wxAuiPaneInfo& hierarchyPane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
|
|
|
|
wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
|
|
|
|
wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
|
|
|
|
wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
|
|
|
|
|
|
|
|
// Don't give the selection filter its own visibility controls; instead show it if
|
|
|
|
// anything else is visible
|
|
|
|
bool showFilter = ( hierarchyPane.IsShown() && hierarchyPane.IsDocked() )
|
|
|
|
|| ( netNavigatorPane.IsShown() && netNavigatorPane.IsDocked() )
|
|
|
|
|| ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
|
|
|
|
|
|
|
|
selectionFilterPane.Show( showFilter );
|
|
|
|
}
|