2011-10-28 13:43:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-01-01 20:52:37 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-10-06 18:07:43 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2024-01-21 10:22:27 +00:00
|
|
|
* Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-28 13:43:37 +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
|
|
|
|
*/
|
|
|
|
|
2021-03-07 20:31:19 +00:00
|
|
|
#include <bitmaps.h>
|
2020-12-06 22:40:54 +00:00
|
|
|
#include <wx/hyperlink.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <base_screen.h>
|
2021-06-15 13:24:55 +00:00
|
|
|
#include <symbol_library.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2020-10-24 12:53:11 +00:00
|
|
|
#include <core/kicad_algo.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <eeschema_id.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <eeschema_settings.h>
|
2020-12-29 18:59:48 +00:00
|
|
|
#include <env_paths.h>
|
2023-09-18 23:52:27 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.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>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <kiway_express.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_edit_frame.h>
|
2022-09-16 03:06:23 +00:00
|
|
|
#include <lib_symbol_library_manager.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_editor_settings.h>
|
2021-01-28 12:30:59 +00:00
|
|
|
#include <paths.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pgm_base.h>
|
2023-09-28 03:04:53 +00:00
|
|
|
#include <project_sch.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <sch_painter.h>
|
|
|
|
#include <sch_view.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2017-10-06 18:07:43 +00:00
|
|
|
#include <symbol_lib_table.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>
|
2020-08-06 23:03:58 +00:00
|
|
|
#include <tool/editor_conditions.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tool/picker_tool.h>
|
2023-07-26 22:32:06 +00:00
|
|
|
#include <tool/properties_tool.h>
|
2020-08-06 23:03:58 +00:00
|
|
|
#include <tool/selection.h>
|
2020-01-13 01:44:19 +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>
|
|
|
|
#include <tools/ee_inspection_tool.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tools/ee_point_editor.h>
|
|
|
|
#include <tools/ee_selection_tool.h>
|
2020-12-12 03:13:52 +00:00
|
|
|
#include <tools/symbol_editor_control.h>
|
|
|
|
#include <tools/symbol_editor_drawing_tools.h>
|
|
|
|
#include <tools/symbol_editor_edit_tool.h>
|
|
|
|
#include <tools/symbol_editor_move_tool.h>
|
|
|
|
#include <tools/symbol_editor_pin_tool.h>
|
2024-04-27 19:57:24 +00:00
|
|
|
#include <view/view_controls.h>
|
2020-08-09 10:55:00 +00:00
|
|
|
#include <widgets/app_progress_dialog.h>
|
2022-12-28 22:03:03 +00:00
|
|
|
#include <widgets/wx_infobar.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <widgets/lib_tree.h>
|
2021-08-14 20:05:21 +00:00
|
|
|
#include <widgets/wx_progress_reporters.h>
|
2024-02-25 22:39:14 +00:00
|
|
|
#include <widgets/panel_sch_selection_filter.h>
|
2023-07-26 22:32:06 +00:00
|
|
|
#include <widgets/sch_properties_panel.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <widgets/symbol_tree_pane.h>
|
2023-06-17 11:44:36 +00:00
|
|
|
#include <widgets/wx_aui_utils.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2020-12-22 00:07:01 +00:00
|
|
|
#include <panel_sym_lib_table.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2024-04-27 19:57:24 +00:00
|
|
|
#include <wx/msgdlg.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
|
2021-01-08 23:24:12 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::m_showDeMorgan = false;
|
2010-11-19 16:28:46 +00:00
|
|
|
|
2020-08-31 15:06:23 +00:00
|
|
|
|
2023-01-28 19:08:38 +00:00
|
|
|
BEGIN_EVENT_TABLE( SYMBOL_EDIT_FRAME, SCH_BASE_FRAME )
|
2021-06-15 12:31:28 +00:00
|
|
|
EVT_COMBOBOX( ID_LIBEDIT_SELECT_UNIT_NUMBER, SYMBOL_EDIT_FRAME::OnSelectUnit )
|
2010-10-04 18:54:14 +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
|
|
|
// menubar commands
|
2020-10-31 01:27:16 +00:00
|
|
|
EVT_MENU( wxID_EXIT, SYMBOL_EDIT_FRAME::OnExitKiCad )
|
|
|
|
EVT_MENU( wxID_CLOSE, SYMBOL_EDIT_FRAME::CloseWindow )
|
2010-10-04 18:54:14 +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
|
|
|
// Update user interface elements.
|
2021-06-15 12:31:28 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_UNIT_NUMBER, SYMBOL_EDIT_FRAME::OnUpdateUnitNumber )
|
2016-11-04 12:59:45 +00:00
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
// Drop files event
|
|
|
|
EVT_DROP_FILES( SYMBOL_EDIT_FRAME::OnDropFiles )
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2020-08-31 15:06:23 +00:00
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|
|
|
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_SYMBOL_EDITOR, _( "Library Editor" ),
|
2020-04-12 23:09:17 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
|
|
|
|
LIB_EDIT_FRAME_NAME ),
|
2023-03-17 15:32:18 +00:00
|
|
|
m_unitSelectBox( nullptr ),
|
|
|
|
m_isSymbolFromSchematic( false )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-10 17:27:53 +00:00
|
|
|
SetShowDeMorgan( false );
|
2020-05-23 15:50:08 +00:00
|
|
|
m_SyncPinEdit = 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-06-15 12:31:28 +00:00
|
|
|
m_symbol = nullptr;
|
2017-11-12 17:55:20 +00:00
|
|
|
m_treePane = nullptr;
|
|
|
|
m_libMgr = nullptr;
|
2019-05-07 23:51:37 +00:00
|
|
|
m_unit = 1;
|
2024-01-26 16:16:13 +00:00
|
|
|
m_bodyStyle = 1;
|
2022-12-31 23:39:04 +00:00
|
|
|
m_aboutTitle = _HKI( "KiCad Symbol Editor" );
|
2015-04-30 11:08:35 +00:00
|
|
|
|
2011-09-08 05:58:45 +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_libedit, 48 ) );
|
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit, 256 ) );
|
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit, 128 ) );
|
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_libedit_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_libedit_16 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
|
|
|
|
SetIcons( icon_bundle );
|
2011-09-08 05:58:45 +00:00
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
m_settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
2020-01-13 01:44:19 +00:00
|
|
|
LoadSettings( m_settings );
|
2015-08-06 00:10:52 +00:00
|
|
|
|
2022-09-16 03:06:23 +00:00
|
|
|
m_libMgr = new LIB_SYMBOL_LIBRARY_MANAGER( *this );
|
2022-02-27 11:54:12 +00:00
|
|
|
bool loadingCancelled = false;
|
2021-11-21 20:32:39 +00:00
|
|
|
|
2022-02-27 11:54:12 +00:00
|
|
|
{
|
|
|
|
// Preload libraries before using SyncLibraries the first time, as the preload is
|
|
|
|
// multi-threaded
|
|
|
|
WX_PROGRESS_REPORTER reporter( this, _( "Loading Symbol Libraries" ),
|
|
|
|
m_libMgr->GetLibraryCount(), true );
|
|
|
|
m_libMgr->Preload( reporter );
|
|
|
|
|
|
|
|
loadingCancelled = reporter.IsCancelled();
|
|
|
|
wxSafeYield();
|
|
|
|
}
|
2021-11-21 20:32:39 +00:00
|
|
|
|
2022-02-27 11:54:12 +00:00
|
|
|
SyncLibraries( false, loadingCancelled );
|
2021-11-21 20:32:39 +00:00
|
|
|
m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
|
2023-05-01 20:26:29 +00:00
|
|
|
m_treePane->GetLibTree()->SetSortMode( (LIB_TREE_MODEL_ADAPTER::SORT_MODE) m_settings->m_LibrarySortMode );
|
2021-11-21 20:32:39 +00:00
|
|
|
|
|
|
|
resolveCanvasType();
|
|
|
|
SwitchCanvas( m_canvasType );
|
|
|
|
|
2019-05-22 08:04:34 +00:00
|
|
|
// Ensure axis are always drawn
|
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions();
|
|
|
|
gal_opts.m_axesEnabled = true;
|
|
|
|
|
2020-05-21 02:27:48 +00:00
|
|
|
m_dummyScreen = new SCH_SCREEN();
|
2017-11-12 17:55:20 +00:00
|
|
|
SetScreen( m_dummyScreen );
|
2009-09-04 18:57:37 +00:00
|
|
|
GetScreen()->m_Center = true;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
2012-05-06 16:55:51 +00:00
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
GetRenderSettings()->LoadColors( GetColorSettings() );
|
2021-09-30 14:44:35 +00:00
|
|
|
GetRenderSettings()->m_IsSymbolEditor = true;
|
2021-01-31 15:28:37 +00:00
|
|
|
GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
|
2020-03-06 03:57:50 +00:00
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
setupTools();
|
2020-08-06 23:03:58 +00:00
|
|
|
setupUIConditions();
|
2019-06-13 11:44:12 +00:00
|
|
|
|
2010-03-18 20:35:29 +00:00
|
|
|
ReCreateMenuBar();
|
2007-09-15 04:25:54 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
2018-01-08 04:05:03 +00:00
|
|
|
ReCreateOptToolbar();
|
2018-08-13 17:00:08 +00:00
|
|
|
|
2023-09-12 15:17:36 +00:00
|
|
|
UpdateTitle();
|
2021-08-20 19:45:57 +00:00
|
|
|
UpdateSymbolMsgPanelInfo();
|
2019-05-06 12:32:51 +00:00
|
|
|
RebuildSymbolUnitsList();
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2023-07-26 22:32:06 +00:00
|
|
|
m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
|
2023-09-25 11:35:31 +00:00
|
|
|
m_propertiesPanel->SetSplitterProportion( m_settings->m_AuiPanels.properties_splitter );
|
2023-07-26 22:32:06 +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 );
|
|
|
|
|
2020-12-22 21:35:25 +00:00
|
|
|
CreateInfoBar();
|
2022-07-26 11:13:16 +00:00
|
|
|
|
|
|
|
// Rows; layers 4 - 6
|
2020-12-11 12:09:37 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
|
|
|
|
.Top().Layer( 6 ) );
|
2022-07-26 11:13:16 +00:00
|
|
|
|
2020-12-11 12:09:37 +00:00
|
|
|
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
|
|
|
|
.Bottom().Layer( 6 ) );
|
2011-09-15 18:25:44 +00:00
|
|
|
|
2022-07-26 11:13:16 +00:00
|
|
|
// Columns; layers 1 - 3
|
2021-06-14 18:00:08 +00:00
|
|
|
m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "SymbolTree" )
|
2022-07-26 11:13:16 +00:00
|
|
|
.Left().Layer( 3 )
|
2023-07-30 10:45:03 +00:00
|
|
|
.TopDockable( false ).BottomDockable( false )
|
2020-12-11 12:09:37 +00:00
|
|
|
.Caption( _( "Libraries" ) )
|
2024-01-18 04:08:38 +00:00
|
|
|
.MinSize( FromDIP( 250 ), -1 ).BestSize( FromDIP( 250 ), -1 ) );
|
2023-07-26 22:32:06 +00:00
|
|
|
|
2024-01-18 04:08:38 +00:00
|
|
|
m_auimgr.AddPane( m_propertiesPanel, defaultPropertiesPaneInfo( this ) );
|
2023-07-30 09:04:49 +00:00
|
|
|
// Show or hide m_propertiesPanel depending on current settings:
|
|
|
|
wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
|
2024-02-25 22:39:14 +00:00
|
|
|
|
|
|
|
m_auimgr.AddPane( m_selectionFilterPanel, defaultSchSelectionFilterPaneInfo( this ) );
|
|
|
|
|
|
|
|
wxAuiPaneInfo& selectionFilterPane = m_auimgr.GetPane( wxS( "SelectionFilter" ) );
|
|
|
|
// The selection filter doesn't need to grow in the vertical direction when docked
|
|
|
|
selectionFilterPane.dock_proportion = 0;
|
|
|
|
|
2023-07-30 09:04:49 +00:00
|
|
|
propertiesPaneInfo.Show( m_settings->m_AuiPanels.show_properties );
|
2024-02-25 22:39:14 +00:00
|
|
|
updateSelectionFilterVisbility();
|
2023-07-26 22:32:06 +00:00
|
|
|
|
2022-07-26 11:13:16 +00:00
|
|
|
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
|
|
|
|
.Left().Layer( 2 ) );
|
|
|
|
|
2020-12-11 12:09:37 +00:00
|
|
|
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
|
|
|
|
.Right().Layer( 2 ) );
|
2011-09-15 18:25:44 +00:00
|
|
|
|
2022-07-26 11:13:16 +00:00
|
|
|
// Center
|
2020-12-11 12:09:37 +00:00
|
|
|
m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" )
|
|
|
|
.CentrePane() );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2020-12-22 21:35:25 +00:00
|
|
|
FinishAUIInitialization();
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2024-02-25 22:39:14 +00:00
|
|
|
// Can't put this in LoadSettings, because it has to be called before setupTools :/
|
|
|
|
EE_SELECTION_TOOL* selTool = GetToolManager()->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
selTool->GetFilter() = GetSettings()->m_SelectionFilter;
|
|
|
|
|
2020-10-26 15:34:59 +00:00
|
|
|
if( m_settings->m_LibWidth > 0 )
|
2023-06-17 11:44:36 +00:00
|
|
|
SetAuiPaneSize( m_auimgr, m_auimgr.GetPane( "SymbolTree" ), m_settings->m_LibWidth, -1 );
|
2020-10-26 15:34:59 +00:00
|
|
|
|
2023-03-17 15:32:18 +00:00
|
|
|
Raise();
|
|
|
|
Show( true );
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
SyncView();
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetView()->UseDrawPriority( true );
|
|
|
|
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
2018-11-20 14:11:22 +00:00
|
|
|
|
2020-10-05 19:26:33 +00:00
|
|
|
setupUnits( m_settings );
|
|
|
|
|
2018-11-20 14:11:22 +00:00
|
|
|
// Set the working/draw area size to display a symbol to a reasonable value:
|
|
|
|
// A 600mm x 600mm with a origin at the area center looks like a large working area
|
2022-09-16 11:33:56 +00:00
|
|
|
double max_size_x = schIUScale.mmToIU( 600 );
|
|
|
|
double max_size_y = schIUScale.mmToIU( 600 );
|
2018-11-20 14:11:22 +00:00
|
|
|
BOX2D bbox;
|
|
|
|
bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
|
|
|
|
bbox.SetSize( max_size_x, max_size_y );
|
|
|
|
GetCanvas()->GetView()->SetBoundary( bbox );
|
2019-07-20 15:52:30 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen );
|
2019-12-19 14:11:11 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
m_acceptedExts.emplace( FILEEXT::KiCadSymbolLibFileExtension, &ACTIONS::ddAddLibrary );
|
2022-09-14 22:28:09 +00:00
|
|
|
DragAcceptFiles( true );
|
|
|
|
|
2020-09-01 10:14:51 +00:00
|
|
|
KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Library changes are unsaved" ) );
|
2020-04-17 23:32:29 +00:00
|
|
|
|
2021-05-03 23:40:41 +00:00
|
|
|
// Catch unhandled accelerator command characters that were no handled by the library tree
|
|
|
|
// panel.
|
|
|
|
Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
|
|
|
|
Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
|
|
|
|
|
2023-03-17 15:32:18 +00:00
|
|
|
// Ensure the window is on top
|
|
|
|
Raise();
|
|
|
|
|
2022-02-27 11:54:12 +00:00
|
|
|
if( loadingCancelled )
|
|
|
|
ShowInfoBarWarning( _( "Symbol library loading was cancelled by user." ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
SYMBOL_EDIT_FRAME::~SYMBOL_EDIT_FRAME()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-02-03 14:00:48 +00:00
|
|
|
// Shutdown all running tools
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ShutdownAllTools();
|
|
|
|
|
2023-05-31 20:37:58 +00:00
|
|
|
setSymWatcher( nullptr );
|
|
|
|
|
2020-08-31 15:06:23 +00:00
|
|
|
if( IsSymbolFromSchematic() )
|
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
delete m_symbol;
|
|
|
|
m_symbol = nullptr;
|
2020-08-31 15:06:23 +00:00
|
|
|
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
delete screen;
|
|
|
|
m_isSymbolFromSchematic = false;
|
|
|
|
}
|
2022-07-27 11:27:58 +00:00
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
// current screen is destroyed in EDA_DRAW_FRAME
|
|
|
|
SetScreen( m_dummyScreen );
|
|
|
|
|
2023-10-16 21:04:01 +00:00
|
|
|
SYMBOL_EDITOR_SETTINGS* cfg = nullptr;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
cfg = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
|
|
|
}
|
|
|
|
catch( const std::runtime_error& e )
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( e.what() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( cfg )
|
|
|
|
{
|
|
|
|
Pgm().GetSettingsManager().Save( cfg );
|
|
|
|
}
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
delete m_libMgr;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
2020-01-13 01:44:19 +00:00
|
|
|
{
|
2021-07-04 12:19:40 +00:00
|
|
|
wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-10 22:02:58 +00:00
|
|
|
SCH_BASE_FRAME::LoadSettings( GetSettings() );
|
|
|
|
|
2020-05-22 23:11:04 +00:00
|
|
|
GetRenderSettings()->m_ShowPinsElectricalType = m_settings->m_ShowPinElectricalType;
|
2024-04-08 11:26:56 +00:00
|
|
|
GetRenderSettings()->m_ShowHiddenPins = m_settings->m_ShowHiddenPins;
|
|
|
|
GetRenderSettings()->m_ShowHiddenFields = m_settings->m_ShowHiddenFields;
|
2022-10-22 20:32:10 +00:00
|
|
|
GetRenderSettings()->SetDefaultFont( wxEmptyString );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
2020-01-13 01:44:19 +00:00
|
|
|
{
|
2021-07-04 12:19:40 +00:00
|
|
|
wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" );
|
2020-05-10 22:02:58 +00:00
|
|
|
|
2021-03-01 20:29:17 +00:00
|
|
|
GetGalDisplayOptions().m_axesEnabled = true;
|
|
|
|
|
2020-05-10 22:02:58 +00:00
|
|
|
SCH_BASE_FRAME::SaveSettings( GetSettings() );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-22 23:11:04 +00:00
|
|
|
m_settings->m_ShowPinElectricalType = GetRenderSettings()->m_ShowPinsElectricalType;
|
2024-04-08 11:26:56 +00:00
|
|
|
m_settings->m_ShowHiddenPins = GetRenderSettings()->m_ShowHiddenPins;
|
|
|
|
m_settings->m_ShowHiddenFields = GetRenderSettings()->m_ShowHiddenFields;
|
2024-01-21 10:22:27 +00:00
|
|
|
|
2024-04-08 11:26:56 +00:00
|
|
|
m_settings->m_LibWidth = m_treePane->GetSize().x;
|
2023-05-01 20:26:29 +00:00
|
|
|
|
|
|
|
m_settings->m_LibrarySortMode = m_treePane->GetLibTree()->GetSortMode();
|
2023-07-30 09:04:49 +00:00
|
|
|
|
2023-09-25 11:35:31 +00:00
|
|
|
m_settings->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
|
2023-07-30 09:04:49 +00:00
|
|
|
bool prop_shown = m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
|
|
|
|
m_settings->m_AuiPanels.show_properties = prop_shown;
|
2024-02-25 22:39:14 +00:00
|
|
|
|
|
|
|
EE_SELECTION_TOOL* selTool = GetToolManager()->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
m_settings->m_SelectionFilter = selTool->GetFilter();
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-13 02:03:25 +00:00
|
|
|
APP_SETTINGS_BASE* SYMBOL_EDIT_FRAME::config() const
|
|
|
|
{
|
|
|
|
return static_cast<APP_SETTINGS_BASE*>( GetSettings() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
COLOR_SETTINGS* SYMBOL_EDIT_FRAME::GetColorSettings( bool aForceRefresh ) const
|
2020-03-06 03:57:50 +00:00
|
|
|
{
|
2020-05-16 13:23:51 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
|
2020-05-10 22:02:58 +00:00
|
|
|
if( GetSettings()->m_UseEeschemaColorSettings )
|
2020-05-16 13:23:51 +00:00
|
|
|
return mgr.GetColorSettings( mgr.GetAppSettings<EESCHEMA_SETTINGS>()->m_ColorTheme );
|
2020-03-06 03:57:50 +00:00
|
|
|
else
|
2020-05-16 13:23:51 +00:00
|
|
|
return mgr.GetColorSettings( GetSettings()->m_ColorTheme );
|
2020-03-06 03:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::setupTools()
|
2019-05-04 11:23:04 +00:00
|
|
|
{
|
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
|
|
|
m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
|
2021-04-13 02:03:25 +00:00
|
|
|
GetCanvas()->GetViewControls(), GetSettings(), 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-10 17:19:48 +00:00
|
|
|
m_toolManager->RegisterTool( new EE_INSPECTION_TOOL );
|
2020-12-12 03:13:52 +00:00
|
|
|
m_toolManager->RegisterTool( new SYMBOL_EDITOR_PIN_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new SYMBOL_EDITOR_DRAWING_TOOLS );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolManager->RegisterTool( new EE_POINT_EDITOR );
|
2020-12-12 03:13:52 +00:00
|
|
|
m_toolManager->RegisterTool( new SYMBOL_EDITOR_MOVE_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new SYMBOL_EDITOR_EDIT_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL );
|
2023-07-26 22:32:06 +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
|
2019-05-08 18:56:03 +00:00
|
|
|
m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
|
2019-05-04 11:23:04 +00:00
|
|
|
|
|
|
|
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::setupUIConditions()
|
2020-08-06 23:03:58 +00:00
|
|
|
{
|
|
|
|
SCH_BASE_FRAME::setupUIConditions();
|
|
|
|
|
|
|
|
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
|
|
|
EDITOR_CONDITIONS cond( this );
|
|
|
|
|
|
|
|
wxASSERT( mgr );
|
|
|
|
|
|
|
|
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
|
|
|
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
|
|
|
|
|
|
|
auto haveSymbolCond =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_symbol;
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2020-12-22 02:29:27 +00:00
|
|
|
auto isEditableCond =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
// Only root symbols from the new s-expression libraries or the schematic
|
|
|
|
// are editable.
|
|
|
|
return IsSymbolEditable() && !IsSymbolAlias();
|
|
|
|
};
|
2020-11-04 20:00:09 +00:00
|
|
|
|
2022-03-28 20:41:36 +00:00
|
|
|
auto symbolModifiedCondition =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& sel )
|
|
|
|
{
|
2023-06-12 11:38:50 +00:00
|
|
|
return m_libMgr && m_libMgr->IsSymbolModified( GetTargetLibId().GetLibItemName(),
|
|
|
|
GetTargetLibId().GetLibNickname() );
|
2021-11-13 19:41:02 +00:00
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2020-12-27 16:28:52 +00:00
|
|
|
auto libSelectedCondition =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& sel )
|
|
|
|
{
|
|
|
|
return !GetTargetLibId().GetLibNickname().empty();
|
|
|
|
};
|
2020-12-27 16:28:52 +00:00
|
|
|
|
2021-02-06 13:28:06 +00:00
|
|
|
auto canEditProperties =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& sel )
|
|
|
|
{
|
|
|
|
return m_symbol && ( !IsSymbolFromLegacyLibrary() || IsSymbolFromSchematic() );
|
|
|
|
};
|
2021-02-07 23:21:38 +00:00
|
|
|
|
|
|
|
auto saveSymbolAsCondition =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
2021-11-24 19:42:43 +00:00
|
|
|
return getTargetSymbol() != nullptr;
|
2021-11-13 19:41:02 +00:00
|
|
|
};
|
2021-02-06 13:28:06 +00:00
|
|
|
|
2023-10-28 21:25:33 +00:00
|
|
|
mgr->SetConditions( ACTIONS::saveAll, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
|
|
|
mgr->SetConditions( ACTIONS::save, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::saveLibraryAs, ENABLE( libSelectedCondition ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::saveSymbolCopyAs, ENABLE( saveSymbolAsCondition ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::newSymbol, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::importSymbol, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::undo, ENABLE( haveSymbolCond && cond.UndoAvailable() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::redo, ENABLE( haveSymbolCond && cond.RedoAvailable() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::revert, ENABLE( symbolModifiedCondition ) );
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
|
2023-08-22 14:09:04 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleGridOverrides, CHECK( cond.GridOverrides() ) );
|
2023-10-28 21:25:33 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::cut, ENABLE( isEditableCond ) );
|
|
|
|
mgr->SetConditions( ACTIONS::copy, ENABLE( haveSymbolCond ) );
|
|
|
|
mgr->SetConditions( ACTIONS::paste, ENABLE( isEditableCond && SELECTION_CONDITIONS::Idle ) );
|
|
|
|
mgr->SetConditions( ACTIONS::doDelete, ENABLE( isEditableCond ) );
|
|
|
|
mgr->SetConditions( ACTIONS::duplicate, ENABLE( isEditableCond ) );
|
|
|
|
mgr->SetConditions( ACTIONS::selectAll, ENABLE( haveSymbolCond ) );
|
2023-09-06 23:44:39 +00:00
|
|
|
mgr->SetConditions( ACTIONS::unselectAll, ENABLE( haveSymbolCond ) );
|
2021-02-18 00:07:28 +00:00
|
|
|
|
2023-10-28 21:25:33 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( isEditableCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( isEditableCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( isEditableCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( isEditableCond ) );
|
2021-02-18 00:07:28 +00:00
|
|
|
|
2023-10-28 21:25:33 +00:00
|
|
|
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
2020-11-04 20:00:09 +00:00
|
|
|
|
2021-11-13 19:41:02 +00:00
|
|
|
auto pinTypeCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
2023-06-12 11:38:50 +00:00
|
|
|
return GetRenderSettings() && GetRenderSettings()->m_ShowPinsElectricalType;
|
2021-11-13 19:41:02 +00:00
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2024-01-21 10:22:27 +00:00
|
|
|
auto hiddenPinCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
2024-04-08 11:26:56 +00:00
|
|
|
return GetRenderSettings() && GetRenderSettings()->m_ShowHiddenPins;
|
2024-01-21 10:22:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto hiddenFieldCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
2024-04-08 11:26:56 +00:00
|
|
|
return GetRenderSettings() && GetRenderSettings()->m_ShowHiddenFields;
|
2024-01-21 10:22:27 +00:00
|
|
|
};
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
auto showCompTreeCond =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return IsSymbolTreeShown();
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2023-07-26 22:32:06 +00:00
|
|
|
auto propertiesCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
|
|
|
|
};
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( pinTypeCond ) );
|
2022-01-17 11:55:55 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::showSymbolTree, CHECK( showCompTreeCond ) );
|
2023-07-26 22:32:06 +00:00
|
|
|
mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
|
2024-04-08 11:26:56 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::showHiddenPins, CHECK( hiddenPinCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::showHiddenFields, CHECK( hiddenFieldCond ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
auto demorganCond =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return GetShowDeMorgan();
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
auto demorganStandardCond =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
2024-04-06 13:14:44 +00:00
|
|
|
return m_bodyStyle == BODY_STYLE::BASE;
|
2021-11-13 19:41:02 +00:00
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
auto demorganAlternateCond =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
2024-04-06 13:14:44 +00:00
|
|
|
return m_bodyStyle == BODY_STYLE::DEMORGAN;
|
2021-11-13 19:41:02 +00:00
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
auto multiUnitModeCond =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_symbol && m_symbol->IsMulti() && !m_symbol->UnitsLocked();
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2022-09-14 22:11:37 +00:00
|
|
|
auto hasMultipleUnitsCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_symbol && m_symbol->IsMulti();
|
|
|
|
};
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
auto syncedPinsModeCond =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_SyncPinEdit;
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
auto haveDatasheetCond =
|
2021-11-13 19:41:02 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_symbol && !m_symbol->GetDatasheetField().GetText().IsEmpty();
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
|
2021-02-18 00:07:28 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::symbolProperties, ENABLE( canEditProperties && haveSymbolCond ) );
|
2020-12-22 02:29:27 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::runERC, ENABLE( haveSymbolCond ) );
|
2021-01-08 23:24:12 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::pinTable, ENABLE( isEditableCond && haveSymbolCond ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
mgr->SetConditions( EE_ACTIONS::showDeMorganStandard,
|
|
|
|
ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::showDeMorganAlternate,
|
|
|
|
ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::toggleSyncedPinsMode,
|
|
|
|
ACTION_CONDITIONS().Enable( multiUnitModeCond ).Check( syncedPinsModeCond ) );
|
2022-09-14 22:11:37 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::setUnitDisplayName,
|
|
|
|
ACTION_CONDITIONS().Enable( isEditableCond && hasMultipleUnitsCond ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
// Only enable a tool if the symbol is edtable
|
2020-08-06 23:03:58 +00:00
|
|
|
#define EDIT_TOOL( tool ) ACTION_CONDITIONS().Enable( isEditableCond ).Check( cond.CurrentTool( tool ) )
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::deleteTool, EDIT_TOOL( ACTIONS::deleteTool ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::placeSymbolPin, EDIT_TOOL( EE_ACTIONS::placeSymbolPin ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::placeSymbolText, EDIT_TOOL( EE_ACTIONS::placeSymbolText ) );
|
2022-01-25 22:33:37 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::drawSymbolTextBox, EDIT_TOOL( EE_ACTIONS::drawSymbolTextBox ) );
|
2021-12-28 22:13:54 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::drawRectangle, EDIT_TOOL( EE_ACTIONS::drawRectangle ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::drawCircle, EDIT_TOOL( EE_ACTIONS::drawCircle ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::drawArc, EDIT_TOOL( EE_ACTIONS::drawArc ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::drawSymbolLines, EDIT_TOOL( EE_ACTIONS::drawSymbolLines ) );
|
2023-05-07 13:51:17 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::drawSymbolPolygon, EDIT_TOOL( EE_ACTIONS::drawSymbolPolygon ) );
|
2021-02-18 00:07:28 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::placeSymbolAnchor, EDIT_TOOL( EE_ACTIONS::placeSymbolAnchor ) );
|
2023-12-29 02:57:21 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::importGraphics, EDIT_TOOL( EE_ACTIONS::importGraphics ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
#undef CHECK
|
|
|
|
#undef ENABLE
|
|
|
|
#undef EDIT_TOOL
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-22 14:27:38 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::CanCloseSymbolFromSchematic( bool doClose )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2021-12-22 14:27:38 +00:00
|
|
|
if( IsContentModified() )
|
2020-10-23 15:56:15 +00:00
|
|
|
{
|
|
|
|
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
|
2021-12-22 14:27:38 +00:00
|
|
|
wxString msg = _( "Save changes to '%s' before closing?" );
|
2020-10-23 15:56:15 +00:00
|
|
|
|
2021-12-22 14:27:38 +00:00
|
|
|
switch( UnsavedChangesDialog( this, wxString::Format( msg, m_reference ), nullptr ) )
|
2020-10-23 15:56:15 +00:00
|
|
|
{
|
|
|
|
case wxID_YES:
|
2021-06-15 12:31:28 +00:00
|
|
|
if( schframe && GetCurSymbol() ) // Should be always the case
|
2021-11-11 16:42:25 +00:00
|
|
|
schframe->SaveSymbolToSchematic( *GetCurSymbol(), m_schematicSymbolUUID );
|
2020-10-23 15:56:15 +00:00
|
|
|
|
2021-12-22 14:27:38 +00:00
|
|
|
break;
|
2020-10-23 15:56:15 +00:00
|
|
|
|
2021-12-22 14:27:38 +00:00
|
|
|
case wxID_NO:
|
|
|
|
break;
|
2020-10-23 15:56:15 +00:00
|
|
|
|
|
|
|
default:
|
2021-12-22 14:27:38 +00:00
|
|
|
case wxID_CANCEL:
|
|
|
|
return false;
|
2020-10-23 15:56:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-22 14:27:38 +00:00
|
|
|
if( doClose )
|
|
|
|
{
|
|
|
|
SetCurSymbol( nullptr, false );
|
2023-09-12 15:17:36 +00:00
|
|
|
UpdateTitle();
|
2021-12-22 14:27:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SYMBOL_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
|
|
|
{
|
|
|
|
// Shutdown blocks must be determined and vetoed as early as possible
|
|
|
|
if( KIPLATFORM::APP::SupportsShutdownBlockReason()
|
|
|
|
&& aEvent.GetId() == wxEVT_QUERY_END_SESSION
|
|
|
|
&& IsContentModified() )
|
2020-08-24 02:01:14 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-22 14:27:38 +00:00
|
|
|
if( m_isSymbolFromSchematic && !CanCloseSymbolFromSchematic( false ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( !saveAllLibraries( true ) )
|
|
|
|
return false;
|
|
|
|
|
2022-11-14 19:59:33 +00:00
|
|
|
// Save symbol tree column widths
|
|
|
|
m_libMgr->GetAdapter()->SaveSettings();
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::doCloseWindow()
|
2020-08-24 02:01:14 +00:00
|
|
|
{
|
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::RebuildSymbolUnitsList()
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2019-06-16 18:51:47 +00:00
|
|
|
if( !m_unitSelectBox )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2019-06-16 18:51:47 +00:00
|
|
|
if( m_unitSelectBox->GetCount() != 0 )
|
|
|
|
m_unitSelectBox->Clear();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
if( !m_symbol || m_symbol->GetUnitCount() <= 1 )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2014-09-02 11:47:57 +00:00
|
|
|
m_unit = 1;
|
2019-06-16 18:51:47 +00:00
|
|
|
m_unitSelectBox->Append( wxEmptyString );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
for( int i = 0; i < m_symbol->GetUnitCount(); i++ )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2022-09-14 22:11:37 +00:00
|
|
|
wxString unitDisplayName = m_symbol->GetUnitDisplayName( i + 1 );
|
|
|
|
m_unitSelectBox->Append( unitDisplayName );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
// Ensure the selected unit is compatible with the number of units of the current symbol:
|
|
|
|
if( m_symbol && m_symbol->GetUnitCount() < m_unit )
|
2014-09-02 11:47:57 +00:00
|
|
|
m_unit = 1;
|
|
|
|
|
2019-06-16 18:51:47 +00:00
|
|
|
m_unitSelectBox->SetSelection(( m_unit > 0 ) ? m_unit - 1 : 0 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-18 11:46:07 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::OnToggleSymbolTree( wxCommandEvent& event )
|
2017-10-31 11:13:20 +00:00
|
|
|
{
|
2022-04-18 17:30:33 +00:00
|
|
|
wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
|
2021-03-18 11:46:07 +00:00
|
|
|
treePane.Show( !IsSymbolTreeShown() );
|
2024-02-25 22:39:14 +00:00
|
|
|
updateSelectionFilterVisbility();
|
2017-10-31 11:13:20 +00:00
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-10 00:27:03 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::IsSymbolTreeShown() const
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2021-12-10 00:27:03 +00:00
|
|
|
return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-17 14:53:27 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::FreezeLibraryTree()
|
2017-10-31 11:13:20 +00:00
|
|
|
{
|
2020-10-16 15:26:19 +00:00
|
|
|
m_treePane->Freeze();
|
2019-06-02 23:17:27 +00:00
|
|
|
m_libMgr->GetAdapter()->Freeze();
|
2017-10-31 11:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-17 14:53:27 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::ThawLibraryTree()
|
2018-01-20 17:15:46 +00:00
|
|
|
{
|
2019-06-02 23:17:27 +00:00
|
|
|
m_libMgr->GetAdapter()->Thaw();
|
2020-10-16 15:26:19 +00:00
|
|
|
m_treePane->Thaw();
|
2018-01-20 17:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
|
2019-06-25 04:44:34 +00:00
|
|
|
{
|
|
|
|
Kiway().OnKiCadExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::OnUpdateUnitNumber( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
event.Enable( m_symbol && m_symbol->GetUnitCount() > 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
int i = event.GetSelection();
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::cancelInteractive );
|
|
|
|
m_toolManager->RunAction( EE_ACTIONS::clearSelection );
|
2019-05-06 12:32:51 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_unit = i + 1;
|
2018-09-02 20:19:22 +00:00
|
|
|
|
2019-05-06 12:32:51 +00:00
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2018-09-04 16:12:15 +00:00
|
|
|
RebuildView();
|
2021-08-20 19:45:57 +00:00
|
|
|
UpdateSymbolMsgPanelInfo();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-22 00:07:01 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::IsSymbolFromLegacyLibrary() const
|
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
if( m_symbol )
|
2020-12-22 00:07:01 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
SYMBOL_LIB_TABLE_ROW* row = m_libMgr->GetLibrary( m_symbol->GetLibNickname() );
|
2020-12-22 00:07:01 +00:00
|
|
|
|
|
|
|
if( row && row->GetType() == SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_LEGACY ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
wxString SYMBOL_EDIT_FRAME::GetCurLib() const
|
2009-12-22 20:08:56 +00:00
|
|
|
{
|
2017-10-06 18:07:43 +00:00
|
|
|
wxString libNickname = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB );
|
2009-12-22 20:08:56 +00:00
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
if( !libNickname.empty() )
|
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-09-28 03:04:53 +00:00
|
|
|
if( !PROJECT_SCH::SchSymbolLibTable( &Prj() )->HasLibrary( libNickname ) )
|
2017-10-06 18:07:43 +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
|
|
|
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
|
2017-10-06 18:07:43 +00:00
|
|
|
libNickname = wxEmptyString;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
return libNickname;
|
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-10-31 01:27:16 +00:00
|
|
|
wxString SYMBOL_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
|
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
|
|
|
{
|
2017-10-06 18:07:43 +00:00
|
|
|
wxString old = GetCurLib();
|
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-09-28 03:04:53 +00:00
|
|
|
if( aLibNickname.empty() || !PROJECT_SCH::SchSymbolLibTable( &Prj() )->HasLibrary( aLibNickname ) )
|
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
|
|
|
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
|
2009-12-22 20:08:56 +00:00
|
|
|
else
|
2017-10-06 18:07:43 +00:00
|
|
|
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, aLibNickname );
|
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
|
|
|
|
|
|
|
return old;
|
2009-12-22 20:08:56 +00:00
|
|
|
}
|
2010-03-20 19:57:59 +00:00
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom )
|
2010-10-23 10:09:23 +00:00
|
|
|
{
|
2023-10-16 21:04:01 +00:00
|
|
|
wxCHECK( m_toolManager, /* void */ );
|
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( EE_ACTIONS::clearSelection );
|
2020-12-07 15:49:39 +00:00
|
|
|
GetCanvas()->GetView()->Clear();
|
2021-06-15 12:31:28 +00:00
|
|
|
delete m_symbol;
|
2020-12-07 15:49:39 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
m_symbol = aSymbol;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
// select the current symbol in the tree widget
|
2021-06-15 12:31:28 +00:00
|
|
|
if( !IsSymbolFromSchematic() && m_symbol )
|
|
|
|
m_treePane->GetLibTree()->SelectLibId( m_symbol->GetLibId() );
|
2020-08-31 15:06:23 +00:00
|
|
|
else
|
|
|
|
m_treePane->GetLibTree()->Unselect();
|
2017-11-14 11:03:19 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
wxString symbolName = m_symbol ? m_symbol->GetName() : wxString();
|
2017-11-13 11:19:14 +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
|
|
|
// retain in case this wxFrame is re-opened later on the same PROJECT
|
2021-06-15 12:31:28 +00:00
|
|
|
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_SYMBOL, symbolName );
|
2018-01-22 12:33:24 +00:00
|
|
|
|
2018-01-23 11:15:19 +00:00
|
|
|
// Ensure synchronized pin edit can be enabled only symbols with interchangeable units
|
2021-06-10 18:51:46 +00:00
|
|
|
m_SyncPinEdit = aSymbol && aSymbol->IsRoot() && aSymbol->IsMulti() && !aSymbol->UnitsLocked();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2020-12-08 15:05:35 +00:00
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2020-12-08 15:27:50 +00:00
|
|
|
|
|
|
|
GetRenderSettings()->m_ShowUnit = m_unit;
|
2024-01-26 16:16:13 +00:00
|
|
|
GetRenderSettings()->m_ShowBodyStyle = m_bodyStyle;
|
2021-02-10 22:56:26 +00:00
|
|
|
GetRenderSettings()->m_ShowDisabled = IsSymbolFromLegacyLibrary() && !IsSymbolFromSchematic();
|
|
|
|
GetRenderSettings()->m_ShowGraphicsDisabled = IsSymbolAlias() && !IsSymbolFromSchematic();
|
2021-06-15 12:31:28 +00:00
|
|
|
GetCanvas()->DisplaySymbol( m_symbol );
|
2021-02-22 16:37:43 +00:00
|
|
|
GetCanvas()->GetView()->HideDrawingSheet();
|
2020-12-08 15:27:50 +00:00
|
|
|
GetCanvas()->GetView()->ClearHiddenFlags();
|
|
|
|
|
|
|
|
if( aUpdateZoom )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen );
|
2020-12-08 15:27:50 +00:00
|
|
|
|
|
|
|
GetCanvas()->Refresh();
|
2020-12-08 15:05:35 +00:00
|
|
|
|
2020-12-06 22:40:54 +00:00
|
|
|
WX_INFOBAR* infobar = GetInfoBar();
|
|
|
|
|
2020-08-31 15:06:23 +00:00
|
|
|
if( IsSymbolFromSchematic() )
|
2020-08-21 22:44:43 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2020-08-31 15:06:23 +00:00
|
|
|
msg.Printf( _( "Editing symbol %s from schematic. Saving will update the schematic "
|
|
|
|
"only." ), m_reference );
|
2020-08-21 22:44:43 +00:00
|
|
|
|
2020-12-06 22:40:54 +00:00
|
|
|
infobar->RemoveAllButtons();
|
|
|
|
infobar->ShowMessage( msg, wxICON_INFORMATION );
|
|
|
|
}
|
2021-02-10 22:56:26 +00:00
|
|
|
else if( IsSymbolFromLegacyLibrary() )
|
2020-12-22 00:07:01 +00:00
|
|
|
{
|
|
|
|
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
|
|
|
|
_( "Manage symbol libraries" ),
|
|
|
|
wxEmptyString );
|
|
|
|
|
|
|
|
button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
|
2024-04-13 02:42:31 +00:00
|
|
|
[this]( wxHyperlinkEvent& aEvent )
|
2020-12-22 00:07:01 +00:00
|
|
|
{
|
|
|
|
InvokeSchEditSymbolLibTable( &Kiway(), this );
|
|
|
|
} ) );
|
|
|
|
|
|
|
|
infobar->RemoveAllButtons();
|
|
|
|
infobar->AddButton( button );
|
|
|
|
infobar->ShowMessage( _( "Symbols in legacy libraries are not editable. Use Manage "
|
|
|
|
"Symbol Libraries to migrate to current format." ),
|
|
|
|
wxICON_INFORMATION );
|
|
|
|
}
|
2021-02-10 22:56:26 +00:00
|
|
|
else if( IsSymbolAlias() )
|
2020-12-06 22:40:54 +00:00
|
|
|
{
|
2023-10-16 21:04:01 +00:00
|
|
|
wxString rootSymbolName;
|
2023-05-05 16:31:37 +00:00
|
|
|
|
|
|
|
// Don't assume the parent symbol shared pointer is still valid.
|
2023-10-28 17:15:45 +00:00
|
|
|
if( std::shared_ptr<LIB_SYMBOL> rootSymbol = m_symbol->GetRootSymbol() )
|
2023-10-16 21:04:01 +00:00
|
|
|
rootSymbolName = rootSymbol->GetName();
|
|
|
|
else
|
2023-10-25 07:41:08 +00:00
|
|
|
{
|
2023-10-16 21:04:01 +00:00
|
|
|
wxCHECK( false, /* void */ );
|
2023-10-25 07:41:08 +00:00
|
|
|
}
|
2023-05-05 16:31:37 +00:00
|
|
|
|
2023-05-04 10:29:13 +00:00
|
|
|
int unit = GetUnit();
|
2024-01-26 16:16:13 +00:00
|
|
|
int bodyStyle = GetBodyStyle();
|
2020-12-06 22:40:54 +00:00
|
|
|
wxString msg;
|
|
|
|
wxString link;
|
|
|
|
|
2023-08-20 16:05:31 +00:00
|
|
|
msg.Printf( _( "Symbol %s is a derived symbol. Symbol graphics will not be editable." ),
|
|
|
|
UnescapeString( symbolName ) );
|
2020-12-06 22:40:54 +00:00
|
|
|
|
2023-08-20 16:05:31 +00:00
|
|
|
link.Printf( _( "Open %s" ), UnescapeString( rootSymbolName ) );
|
2020-12-06 22:40:54 +00:00
|
|
|
|
|
|
|
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, link, wxEmptyString );
|
|
|
|
button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
|
2024-04-13 02:42:31 +00:00
|
|
|
[this, rootSymbolName, unit, bodyStyle]( wxHyperlinkEvent& aEvent )
|
2020-12-06 22:40:54 +00:00
|
|
|
{
|
2024-01-26 16:16:13 +00:00
|
|
|
LoadSymbolFromCurrentLib( rootSymbolName, unit, bodyStyle );
|
2020-12-06 22:40:54 +00:00
|
|
|
} ) );
|
|
|
|
|
|
|
|
infobar->RemoveAllButtons();
|
|
|
|
infobar->AddButton( button );
|
|
|
|
infobar->ShowMessage( msg, wxICON_INFORMATION );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
infobar->Dismiss();
|
2020-08-21 22:44:43 +00:00
|
|
|
}
|
2019-11-06 19:15:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-16 03:06:23 +00:00
|
|
|
LIB_SYMBOL_LIBRARY_MANAGER& SYMBOL_EDIT_FRAME::GetLibManager()
|
2019-11-06 19:15:42 +00:00
|
|
|
{
|
|
|
|
wxASSERT( m_libMgr );
|
|
|
|
return *m_libMgr;
|
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
|
|
|
}
|
2010-12-10 19:47:44 +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
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::OnModify()
|
2017-10-31 11:13:20 +00:00
|
|
|
{
|
2022-10-10 13:03:10 +00:00
|
|
|
EDA_BASE_FRAME::OnModify();
|
|
|
|
|
2021-05-28 19:07:04 +00:00
|
|
|
GetScreen()->SetContentModified();
|
2022-10-10 13:03:10 +00:00
|
|
|
m_autoSaveRequired = true;
|
2022-04-11 21:14:54 +00:00
|
|
|
|
|
|
|
if( !IsSymbolFromSchematic() )
|
|
|
|
storeCurrentSymbol();
|
2018-09-04 16:12:15 +00:00
|
|
|
|
2019-11-26 21:38:57 +00:00
|
|
|
m_treePane->GetLibTree()->RefreshLibTree();
|
2021-02-19 21:58:22 +00:00
|
|
|
|
|
|
|
if( !GetTitle().StartsWith( "*" ) )
|
2023-09-12 15:17:36 +00:00
|
|
|
UpdateTitle();
|
2017-10-31 11:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::SynchronizePins()
|
2011-10-28 13:43:37 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
return m_SyncPinEdit && m_symbol && m_symbol->IsMulti() && !m_symbol->UnitsLocked();
|
2011-10-28 13:43:37 +00:00
|
|
|
}
|
2017-03-10 13:38:39 +00:00
|
|
|
|
|
|
|
|
2022-04-19 18:09:19 +00:00
|
|
|
wxString SYMBOL_EDIT_FRAME::AddLibraryFile( bool aCreateNew )
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2021-01-28 05:36:41 +00:00
|
|
|
// Select the target library table (global/project)
|
2022-09-16 03:06:23 +00:00
|
|
|
SYMBOL_LIB_TABLE* libTable = SelectSymLibTable();
|
2021-01-28 05:36:41 +00:00
|
|
|
|
|
|
|
if( !libTable )
|
2022-04-19 18:09:19 +00:00
|
|
|
return wxEmptyString;
|
2021-01-28 05:36:41 +00:00
|
|
|
|
2018-07-27 20:47:51 +00:00
|
|
|
wxFileName fn = m_libMgr->GetUniqueLibraryName();
|
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
if( !LibraryFileBrowser( !aCreateNew, fn, FILEEXT::KiCadSymbolLibFileWildcard(),
|
|
|
|
FILEEXT::KiCadSymbolLibFileExtension, false,
|
2021-01-28 12:30:59 +00:00
|
|
|
( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() ),
|
|
|
|
PATHS::GetDefaultUserSymbolsPath() ) )
|
2018-11-04 12:32:54 +00:00
|
|
|
{
|
2022-04-19 18:09:19 +00:00
|
|
|
return wxEmptyString;
|
2018-11-04 12:32:54 +00:00
|
|
|
}
|
2018-07-27 20:47:51 +00:00
|
|
|
|
|
|
|
wxString libName = fn.GetName();
|
2017-11-12 17:55:20 +00:00
|
|
|
|
|
|
|
if( libName.IsEmpty() )
|
2022-04-19 18:09:19 +00:00
|
|
|
return wxEmptyString;
|
2017-11-12 17:55:20 +00:00
|
|
|
|
|
|
|
if( m_libMgr->LibraryExists( libName ) )
|
|
|
|
{
|
2021-06-27 13:24:02 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Library '%s' already exists." ), libName ) );
|
2022-04-19 18:09:19 +00:00
|
|
|
return wxEmptyString;
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( aCreateNew )
|
2017-11-22 12:20:26 +00:00
|
|
|
{
|
2018-07-27 20:47:51 +00:00
|
|
|
if( !m_libMgr->CreateLibrary( fn.GetFullPath(), libTable ) )
|
|
|
|
{
|
2019-05-10 19:57:24 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Could not create the library file '%s'.\n"
|
2022-04-19 18:09:19 +00:00
|
|
|
"Make sure you have write permissions and "
|
|
|
|
"try again." ),
|
2019-05-10 19:57:24 +00:00
|
|
|
fn.GetFullPath() ) );
|
2022-04-19 18:09:19 +00:00
|
|
|
return wxEmptyString;
|
2018-07-27 20:47:51 +00:00
|
|
|
}
|
2017-11-22 12:20:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-27 20:47:51 +00:00
|
|
|
if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
|
|
|
|
{
|
2017-11-22 12:20:26 +00:00
|
|
|
DisplayError( this, _( "Could not open the library file." ) );
|
2022-04-19 18:09:19 +00:00
|
|
|
return wxEmptyString;
|
2018-07-27 20:47:51 +00:00
|
|
|
}
|
2017-11-22 12:20:26 +00:00
|
|
|
}
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2018-01-31 09:46:01 +00:00
|
|
|
bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
|
|
|
|
saveSymbolLibTables( globalTable, !globalTable );
|
|
|
|
|
2021-07-15 18:51:20 +00:00
|
|
|
std::string packet = fn.GetFullPath().ToStdString();
|
|
|
|
this->Kiway().ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_LIB_EDIT, packet );
|
|
|
|
|
2022-04-19 18:09:19 +00:00
|
|
|
return fn.GetFullPath();
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::DdAddLibrary( wxString aLibFile )
|
|
|
|
{
|
|
|
|
// Select the target library table (global/project)
|
2022-09-16 03:06:23 +00:00
|
|
|
SYMBOL_LIB_TABLE* libTable = SelectSymLibTable();
|
2022-09-14 22:28:09 +00:00
|
|
|
|
|
|
|
if( !libTable )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxFileName fn = wxFileName( aLibFile );
|
|
|
|
|
|
|
|
wxString libName = fn.GetName();
|
|
|
|
|
|
|
|
if( libName.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( m_libMgr->LibraryExists( libName ) )
|
|
|
|
{
|
|
|
|
DisplayError( this, wxString::Format( _( "Library '%s' already exists." ), libName ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Could not open the library file." ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
|
|
|
|
saveSymbolLibTables( globalTable, !globalTable );
|
|
|
|
|
|
|
|
std::string packet = fn.GetFullPath().ToStdString();
|
|
|
|
this->Kiway().ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_LIB_EDIT, packet );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
LIB_ID SYMBOL_EDIT_FRAME::GetTreeLIBID( int* aUnit ) const
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2019-06-05 22:29:59 +00:00
|
|
|
return m_treePane->GetLibTree()->GetSelectedLibId( aUnit );
|
2019-06-05 19:15:57 +00:00
|
|
|
}
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
|
2022-09-09 02:15:44 +00:00
|
|
|
int SYMBOL_EDIT_FRAME::GetTreeSelectionCount() const
|
|
|
|
{
|
|
|
|
return m_treePane->GetLibTree()->GetSelectionCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
int SYMBOL_EDIT_FRAME::GetTreeLIBIDs( std::vector<LIB_ID>& aSelection ) const
|
|
|
|
{
|
|
|
|
return m_treePane->GetLibTree()->GetSelectedLibIds( aSelection );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_SYMBOL* SYMBOL_EDIT_FRAME::getTargetSymbol() const
|
2019-06-05 19:15:57 +00:00
|
|
|
{
|
2023-02-07 15:53:14 +00:00
|
|
|
if( IsSymbolTreeShown() )
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2023-02-07 15:53:14 +00:00
|
|
|
LIB_ID libId = GetTreeLIBID();
|
|
|
|
|
|
|
|
if( libId.IsValid() )
|
|
|
|
return m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
return m_symbol;
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-07 23:21:38 +00:00
|
|
|
LIB_ID SYMBOL_EDIT_FRAME::GetTargetLibId() const
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2021-12-10 00:27:03 +00:00
|
|
|
LIB_ID id;
|
|
|
|
|
|
|
|
if( IsSymbolTreeShown() )
|
|
|
|
id = GetTreeLIBID();
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
if( id.GetLibNickname().empty() && m_symbol )
|
|
|
|
id = m_symbol->GetLibId();
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2018-05-02 22:33:53 +00:00
|
|
|
return id;
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-09 02:15:44 +00:00
|
|
|
std::vector<LIB_ID> SYMBOL_EDIT_FRAME::GetSelectedLibIds() const
|
|
|
|
{
|
|
|
|
std::vector<LIB_ID> ids;
|
|
|
|
GetTreeLIBIDs( ids );
|
|
|
|
return ids;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
LIB_TREE_NODE* SYMBOL_EDIT_FRAME::GetCurrentTreeNode() const
|
2020-02-07 17:06:24 +00:00
|
|
|
{
|
|
|
|
return m_treePane->GetLibTree()->GetCurrentTreeNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
wxString SYMBOL_EDIT_FRAME::getTargetLib() const
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2021-02-07 23:21:38 +00:00
|
|
|
return GetTargetLibId().GetLibNickname();
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-27 11:54:12 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::SyncLibraries( bool aShowProgress, bool aPreloadCancelled,
|
|
|
|
const wxString& aForceRefresh )
|
2017-11-22 13:02:45 +00:00
|
|
|
{
|
2018-01-09 12:48:00 +00:00
|
|
|
LIB_ID selected;
|
|
|
|
|
|
|
|
if( m_treePane )
|
2018-07-27 20:47:51 +00:00
|
|
|
selected = m_treePane->GetLibTree()->GetSelectedLibId();
|
2018-01-09 12:48:00 +00:00
|
|
|
|
2018-08-25 12:21:09 +00:00
|
|
|
if( aShowProgress )
|
2017-11-30 11:31:36 +00:00
|
|
|
{
|
2020-08-09 10:55:00 +00:00
|
|
|
APP_PROGRESS_DIALOG progressDlg( _( "Loading Symbol Libraries" ), wxEmptyString,
|
|
|
|
m_libMgr->GetAdapter()->GetLibrariesCount(), this );
|
2017-11-22 13:02:45 +00:00
|
|
|
|
2021-01-31 22:58:34 +00:00
|
|
|
m_libMgr->Sync( aForceRefresh,
|
|
|
|
[&]( int progress, int max, const wxString& libName )
|
|
|
|
{
|
2021-06-26 11:33:37 +00:00
|
|
|
progressDlg.Update( progress, wxString::Format( _( "Loading library '%s'..." ),
|
|
|
|
libName ) );
|
2021-01-31 22:58:34 +00:00
|
|
|
} );
|
2017-11-30 11:31:36 +00:00
|
|
|
}
|
2022-02-27 11:54:12 +00:00
|
|
|
else if( !aPreloadCancelled )
|
2017-11-30 11:31:36 +00:00
|
|
|
{
|
2021-01-31 22:58:34 +00:00
|
|
|
m_libMgr->Sync( aForceRefresh,
|
|
|
|
[&]( int progress, int max, const wxString& libName )
|
|
|
|
{
|
|
|
|
} );
|
2017-11-30 11:31:36 +00:00
|
|
|
}
|
2017-11-22 13:15:51 +00:00
|
|
|
|
2017-11-30 11:31:36 +00:00
|
|
|
if( m_treePane )
|
2018-01-09 12:48:00 +00:00
|
|
|
{
|
|
|
|
wxDataViewItem found;
|
|
|
|
|
|
|
|
if( selected.IsValid() )
|
|
|
|
{
|
|
|
|
// Check if the previously selected item is still valid,
|
|
|
|
// if not - it has to be unselected to prevent crash
|
|
|
|
found = m_libMgr->GetAdapter()->FindItem( selected );
|
|
|
|
|
|
|
|
if( !found )
|
2018-07-27 20:47:51 +00:00
|
|
|
m_treePane->GetLibTree()->Unselect();
|
2018-01-09 12:48:00 +00:00
|
|
|
}
|
|
|
|
|
2020-02-07 17:06:24 +00:00
|
|
|
m_treePane->GetLibTree()->Regenerate( true );
|
2018-01-09 12:48:00 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
// Try to select the parent library, in case the symbol is not found
|
2018-01-09 12:48:00 +00:00
|
|
|
if( !found && selected.IsValid() )
|
|
|
|
{
|
|
|
|
selected.SetLibItemName( "" );
|
|
|
|
found = m_libMgr->GetAdapter()->FindItem( selected );
|
|
|
|
|
|
|
|
if( found )
|
2018-07-27 20:47:51 +00:00
|
|
|
m_treePane->GetLibTree()->SelectLibId( selected );
|
2018-01-09 12:48:00 +00:00
|
|
|
}
|
2019-02-27 15:34:51 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
// If no selection, see if there's a current symbol to centre
|
|
|
|
if( !selected.IsValid() && m_symbol )
|
2019-02-27 15:34:51 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
LIB_ID current( GetCurLib(), m_symbol->GetName() );
|
2019-02-27 15:34:51 +00:00
|
|
|
m_treePane->GetLibTree()->CenterLibId( current );
|
|
|
|
}
|
2018-01-09 12:48:00 +00:00
|
|
|
}
|
2017-11-22 13:02:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::RegenerateLibraryTree()
|
2020-02-07 17:06:24 +00:00
|
|
|
{
|
2021-02-07 23:21:38 +00:00
|
|
|
LIB_ID target = GetTargetLibId();
|
2020-02-07 17:06:24 +00:00
|
|
|
|
|
|
|
m_treePane->GetLibTree()->Regenerate( true );
|
|
|
|
|
|
|
|
if( target.IsValid() )
|
|
|
|
m_treePane->GetLibTree()->CenterLibId( target );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-17 14:53:27 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::RefreshLibraryTree()
|
|
|
|
{
|
|
|
|
m_treePane->GetLibTree()->RefreshLibTree();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-21 10:57:15 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::FocusOnLibId( const LIB_ID& aLibID )
|
|
|
|
{
|
|
|
|
m_treePane->GetLibTree()->SelectLibId( aLibID );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SYMBOL_EDIT_FRAME::UpdateLibraryTree( const wxDataViewItem& aTreeItem, LIB_SYMBOL* aSymbol )
|
|
|
|
{
|
|
|
|
if( aTreeItem.IsOk() ) // Can be not found in tree if the current footprint is imported
|
|
|
|
// from file therefore not yet in tree.
|
|
|
|
{
|
2023-11-17 18:17:50 +00:00
|
|
|
static_cast<LIB_TREE_NODE_ITEM*>( aTreeItem.GetID() )->Update( aSymbol );
|
2022-04-21 10:57:15 +00:00
|
|
|
m_treePane->GetLibTree()->RefreshLibTree();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt )
|
2017-11-13 14:15:10 +00:00
|
|
|
{
|
|
|
|
if( aOriginalFile.FileExists() )
|
|
|
|
{
|
|
|
|
wxFileName backupFileName( aOriginalFile );
|
2020-05-22 14:12:44 +00:00
|
|
|
backupFileName.SetExt( aBackupExt );
|
2017-11-13 14:15:10 +00:00
|
|
|
|
|
|
|
if( backupFileName.FileExists() )
|
|
|
|
wxRemoveFile( backupFileName.GetFullPath() );
|
|
|
|
|
|
|
|
if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
|
|
|
|
{
|
2021-06-27 13:24:02 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Failed to save backup to '%s'." ),
|
2019-04-22 07:34:28 +00:00
|
|
|
backupFileName.GetFullPath() ) );
|
2017-11-13 14:15:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::storeCurrentSymbol()
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
if( m_symbol && !GetCurLib().IsEmpty() && GetScreen()->IsContentModified() )
|
|
|
|
m_libMgr->UpdateSymbol( m_symbol, GetCurLib() ); // UpdateSymbol() makes a copy
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-21 10:57:15 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::IsCurrentSymbol( const LIB_ID& aLibId ) const
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
// This will return the root symbol of any alias
|
|
|
|
LIB_SYMBOL* symbol = m_libMgr->GetBufferedSymbol( aLibId.GetLibItemName(),
|
2022-04-21 10:57:15 +00:00
|
|
|
aLibId.GetLibNickname() );
|
2021-06-10 18:51:46 +00:00
|
|
|
|
|
|
|
// Now we can compare the libId of the current symbol and the root symbol
|
2021-06-15 12:31:28 +00:00
|
|
|
return ( symbol && m_symbol && symbol->GetLibId() == m_symbol->GetLibId() );
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::emptyScreen()
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2019-06-13 11:44:12 +00:00
|
|
|
m_treePane->GetLibTree()->Unselect();
|
2017-11-12 17:55:20 +00:00
|
|
|
SetCurLib( wxEmptyString );
|
2021-06-15 12:31:28 +00:00
|
|
|
SetCurSymbol( nullptr, false );
|
2017-11-12 17:55:20 +00:00
|
|
|
SetScreen( m_dummyScreen );
|
2020-07-13 11:21:40 +00:00
|
|
|
ClearUndoRedoList();
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen );
|
2017-11-12 17:55:20 +00:00
|
|
|
Refresh();
|
|
|
|
}
|
2018-01-08 04:05:03 +00:00
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2018-01-08 04:05:03 +00:00
|
|
|
{
|
2020-07-17 20:04:14 +00:00
|
|
|
SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2018-01-08 04:05:03 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
SETTINGS_MANAGER* mgr = GetSettingsManager();
|
|
|
|
SYMBOL_EDITOR_SETTINGS* cfg = mgr->GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
|
|
|
|
|
|
|
GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_ShowPinElectricalType;
|
2024-04-08 11:26:56 +00:00
|
|
|
GetRenderSettings()->m_ShowHiddenPins = cfg->m_ShowHiddenPins;
|
|
|
|
GetRenderSettings()->m_ShowHiddenFields = cfg->m_ShowHiddenFields;
|
2021-08-29 23:33:08 +00:00
|
|
|
|
|
|
|
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
|
|
|
|
|
2022-01-09 00:44:24 +00:00
|
|
|
if( m_symbol )
|
|
|
|
m_symbol->ClearCaches();
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
GetCanvas()->ForceRefresh();
|
2020-03-22 00:03:59 +00:00
|
|
|
|
2022-06-28 23:44:18 +00:00
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
|
|
|
GetCanvas()->Refresh();
|
|
|
|
|
2019-07-20 15:52:30 +00:00
|
|
|
RecreateToolbars();
|
2019-06-24 09:22:49 +00:00
|
|
|
|
|
|
|
if( aEnvVarsChanged )
|
|
|
|
SyncLibraries( true );
|
|
|
|
|
2018-01-08 04:05:03 +00:00
|
|
|
Layout();
|
|
|
|
SendSizeEvent();
|
|
|
|
}
|
2018-06-30 22:38:04 +00:00
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::ShowChangedLanguage()
|
2018-06-30 22:38:04 +00:00
|
|
|
{
|
|
|
|
// 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
|
|
|
|
2023-04-11 22:51:27 +00:00
|
|
|
// For some obscure reason, the AUI manager hides the first modified pane.
|
|
|
|
// So force show panes
|
|
|
|
wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
|
|
|
|
bool tree_shown = tree_pane_info.IsShown();
|
|
|
|
tree_pane_info.Caption( _( "Libraries" ) );
|
|
|
|
tree_pane_info.Show( tree_shown );
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
m_treePane->GetLibTree()->ShowChangedLanguage();
|
|
|
|
|
2018-06-30 22:38:04 +00:00
|
|
|
// status bar
|
|
|
|
UpdateMsgPanel();
|
2022-04-05 12:15:27 +00:00
|
|
|
|
|
|
|
if( GetRenderSettings()->m_ShowPinsElectricalType )
|
|
|
|
{
|
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
|
|
|
GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
2023-09-12 15:17:36 +00:00
|
|
|
UpdateTitle();
|
2018-06-30 22:38:04 +00:00
|
|
|
}
|
|
|
|
|
2018-10-17 11:14:09 +00:00
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::SetScreen( BASE_SCREEN* aScreen )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-04-17 19:09:48 +00:00
|
|
|
SCH_BASE_FRAME::SetScreen( aScreen );
|
2023-02-16 13:17:00 +00:00
|
|
|
|
|
|
|
// Let tools add things to the view if necessary
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-10-17 11:14:09 +00:00
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::RebuildView()
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-09-02 20:19:22 +00:00
|
|
|
GetRenderSettings()->m_ShowUnit = m_unit;
|
2024-01-26 16:16:13 +00:00
|
|
|
GetRenderSettings()->m_ShowBodyStyle = m_bodyStyle;
|
2021-02-10 22:56:26 +00:00
|
|
|
GetRenderSettings()->m_ShowDisabled = IsSymbolFromLegacyLibrary() && !IsSymbolFromSchematic();
|
|
|
|
GetRenderSettings()->m_ShowGraphicsDisabled = IsSymbolAlias() && !IsSymbolFromSchematic();
|
2021-06-15 12:31:28 +00:00
|
|
|
GetCanvas()->DisplaySymbol( m_symbol );
|
2021-02-22 16:37:43 +00:00
|
|
|
GetCanvas()->GetView()->HideDrawingSheet();
|
2018-10-21 12:50:31 +00:00
|
|
|
GetCanvas()->GetView()->ClearHiddenFlags();
|
2018-09-04 16:12:15 +00:00
|
|
|
|
2023-02-16 13:17:00 +00:00
|
|
|
// Let tools add things to the view if necessary
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
|
|
|
2022-06-28 23:44:18 +00:00
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
2018-09-04 16:12:15 +00:00
|
|
|
GetCanvas()->Refresh();
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-10-17 11:14:09 +00:00
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::HardRedraw()
|
2018-10-17 11:14:09 +00:00
|
|
|
{
|
2019-04-11 01:23:34 +00:00
|
|
|
SyncLibraries( true );
|
2020-03-21 20:54:35 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
if( m_symbol )
|
2020-03-21 20:54:35 +00:00
|
|
|
{
|
|
|
|
EE_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
EE_SELECTION& selection = selectionTool->GetSelection();
|
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
for( SCH_ITEM& item : m_symbol->GetDrawItems() )
|
2020-03-21 20:54:35 +00:00
|
|
|
{
|
2020-09-26 13:42:40 +00:00
|
|
|
if( !alg::contains( selection, &item ) )
|
2020-03-21 20:54:35 +00:00
|
|
|
item.ClearSelected();
|
|
|
|
else
|
|
|
|
item.SetSelected();
|
|
|
|
}
|
2022-01-07 17:42:43 +00:00
|
|
|
|
|
|
|
m_symbol->ClearCaches();
|
2020-03-21 20:54:35 +00:00
|
|
|
}
|
|
|
|
|
2018-10-17 11:14:09 +00:00
|
|
|
RebuildView();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
const BOX2I SYMBOL_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
if( !m_symbol )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2022-08-08 08:55:53 +00:00
|
|
|
// Gives a reasonable drawing area size
|
2022-09-16 11:33:56 +00:00
|
|
|
int width = schIUScale.mmToIU( 50 );
|
|
|
|
int height = schIUScale.mmToIU( 30 );
|
2022-08-08 08:55:53 +00:00
|
|
|
|
|
|
|
return BOX2I( VECTOR2I( -width/2, -height/2 ),
|
|
|
|
VECTOR2I( width, height ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-26 16:16:13 +00:00
|
|
|
return m_symbol->Flatten()->GetUnitBoundingBox( m_unit, m_bodyStyle );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 16:53:01 +00:00
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::FocusOnItem( SCH_ITEM* aItem )
|
2023-06-07 11:46:10 +00:00
|
|
|
{
|
|
|
|
static KIID lastBrightenedItemID( niluuid );
|
|
|
|
|
2024-04-06 13:14:44 +00:00
|
|
|
SCH_ITEM* lastItem = nullptr;
|
2023-06-07 11:46:10 +00:00
|
|
|
|
|
|
|
if( m_symbol )
|
|
|
|
{
|
2024-04-20 09:44:34 +00:00
|
|
|
for( SCH_PIN* pin : m_symbol->GetAllLibPins() )
|
2023-06-07 11:46:10 +00:00
|
|
|
{
|
|
|
|
if( pin->m_Uuid == lastBrightenedItemID )
|
|
|
|
lastItem = pin;
|
|
|
|
}
|
|
|
|
|
2024-04-12 21:00:41 +00:00
|
|
|
std::vector<SCH_FIELD*> fields;
|
2023-06-07 11:46:10 +00:00
|
|
|
m_symbol->GetFields( fields );
|
|
|
|
|
2024-04-12 21:00:41 +00:00
|
|
|
for( SCH_FIELD* field : fields )
|
2023-06-07 11:46:10 +00:00
|
|
|
{
|
|
|
|
if( field->m_Uuid == lastBrightenedItemID )
|
|
|
|
lastItem = field;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( lastItem && lastItem != aItem )
|
|
|
|
{
|
|
|
|
lastItem->ClearBrightened();
|
|
|
|
|
|
|
|
UpdateItem( lastItem );
|
|
|
|
lastBrightenedItemID = niluuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aItem )
|
|
|
|
{
|
|
|
|
if( !aItem->IsBrightened() )
|
|
|
|
{
|
|
|
|
aItem->SetBrightened();
|
|
|
|
|
|
|
|
UpdateItem( aItem );
|
|
|
|
lastBrightenedItemID = aItem->m_Uuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
FocusOnLocation( VECTOR2I( aItem->GetFocusPosition().x, -aItem->GetFocusPosition().y ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
2018-08-19 16:53:01 +00:00
|
|
|
{
|
|
|
|
const std::string& payload = mail.GetPayload();
|
|
|
|
|
|
|
|
switch( mail.Command() )
|
|
|
|
{
|
|
|
|
case MAIL_LIB_EDIT:
|
|
|
|
if( !payload.empty() )
|
|
|
|
{
|
|
|
|
wxString libFileName( payload );
|
|
|
|
wxString libNickname;
|
|
|
|
wxString msg;
|
|
|
|
|
2023-09-28 03:04:53 +00:00
|
|
|
SYMBOL_LIB_TABLE* libTable = PROJECT_SCH::SchSymbolLibTable( &Prj() );
|
2018-08-19 16:53:01 +00:00
|
|
|
const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( libFileName );
|
|
|
|
|
|
|
|
if( !libTableRow )
|
|
|
|
{
|
2024-02-01 17:29:16 +00:00
|
|
|
msg.Printf( _( "The current configuration does not include the symbol library '%s'." ),
|
2018-08-19 16:53:01 +00:00
|
|
|
libFileName );
|
2024-02-01 17:29:16 +00:00
|
|
|
msg += wxS( "\n" ) + _( "Use Manage Symbol Libraries to edit the configuration." );
|
2018-08-19 16:53:01 +00:00
|
|
|
DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
libNickname = libTableRow->GetNickName();
|
|
|
|
|
|
|
|
if( !libTable->HasLibrary( libNickname, true ) )
|
|
|
|
{
|
2024-02-01 17:29:16 +00:00
|
|
|
msg.Printf( _( "The symbol library '%s' is not enabled in the current configuration." ),
|
2021-07-28 17:36:13 +00:00
|
|
|
UnescapeString( libNickname ) );
|
2024-02-01 17:29:16 +00:00
|
|
|
msg += wxS( "\n" ) + _( "Use Manage Symbol Libraries to edit the configuration." );
|
2018-08-19 16:53:01 +00:00
|
|
|
DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetCurLib( libNickname );
|
|
|
|
|
|
|
|
if( m_treePane )
|
2018-09-24 14:45:51 +00:00
|
|
|
{
|
|
|
|
LIB_ID id( libNickname, wxEmptyString );
|
2021-07-15 18:51:20 +00:00
|
|
|
m_treePane->GetLibTree()->SelectLibId( id );
|
2018-09-24 14:45:51 +00:00
|
|
|
m_treePane->GetLibTree()->ExpandLibId( id );
|
|
|
|
m_treePane->GetLibTree()->CenterLibId( id );
|
|
|
|
}
|
2018-08-19 16:53:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2023-01-19 00:14:31 +00:00
|
|
|
case MAIL_RELOAD_LIB:
|
|
|
|
{
|
|
|
|
wxString currentLib = GetCurLib();
|
2023-09-28 03:04:53 +00:00
|
|
|
SYMBOL_LIB_TABLE* libTable = PROJECT_SCH::SchSymbolLibTable( &Prj() );
|
2023-01-19 00:14:31 +00:00
|
|
|
|
|
|
|
FreezeLibraryTree();
|
|
|
|
|
|
|
|
// Check if the currently selected symbol library been removed or disabled.
|
|
|
|
if( !currentLib.empty() && libTable && !libTable->HasLibrary( currentLib, true ) )
|
|
|
|
{
|
|
|
|
SetCurLib( wxEmptyString );
|
|
|
|
emptyScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
SyncLibraries( true );
|
|
|
|
ThawLibraryTree();
|
|
|
|
RefreshLibraryTree();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-05-31 20:37:58 +00:00
|
|
|
case MAIL_REFRESH_SYMBOL:
|
|
|
|
{
|
2023-09-28 03:04:53 +00:00
|
|
|
SYMBOL_LIB_TABLE* tbl = PROJECT_SCH::SchSymbolLibTable( &Prj() );
|
2023-05-31 20:37:58 +00:00
|
|
|
LIB_SYMBOL* symbol = GetCurSymbol();
|
|
|
|
|
|
|
|
wxLogTrace( "KICAD_LIB_WATCH", "Received refresh symbol request for %s",
|
|
|
|
payload );
|
|
|
|
|
|
|
|
if( !tbl || !symbol )
|
|
|
|
break;
|
|
|
|
|
|
|
|
wxString libName = symbol->GetLibId().GetLibNickname();
|
|
|
|
const SYMBOL_LIB_TABLE_ROW* row = tbl->FindRow( libName );
|
|
|
|
|
|
|
|
if( !row )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxFileName libfullname( row->GetFullURI( true ) );
|
|
|
|
|
|
|
|
wxFileName changedLib( mail.GetPayload() );
|
|
|
|
wxLogTrace( "KICAD_LIB_WATCH",
|
|
|
|
"Received refresh symbol request for %s, current symbols is %s",
|
|
|
|
changedLib.GetFullPath(), libfullname.GetFullPath() );
|
|
|
|
|
|
|
|
if( changedLib == libfullname )
|
|
|
|
{
|
|
|
|
wxLogTrace( "KICAD_LIB_WATCH", "Refreshing symbol %s", symbol->GetName() );
|
|
|
|
|
2024-03-06 03:53:51 +00:00
|
|
|
SetScreen( m_dummyScreen ); // UpdateLibraryBuffer will destroy the old screen
|
2023-05-31 20:37:58 +00:00
|
|
|
m_libMgr->UpdateLibraryBuffer( libName );
|
|
|
|
|
|
|
|
LIB_SYMBOL* lib_symbol = m_libMgr->GetBufferedSymbol( symbol->GetName(), libName );
|
|
|
|
wxCHECK2_MSG( lib_symbol, break, wxString::Format( "Symbol %s not found in library %s",
|
|
|
|
symbol->GetName(), libName ) );
|
|
|
|
|
|
|
|
// The buffered screen for the symbol
|
|
|
|
SCH_SCREEN* symbol_screen = m_libMgr->GetScreen( lib_symbol->GetName(), libName );
|
|
|
|
|
|
|
|
SetScreen( symbol_screen );
|
|
|
|
SetCurSymbol( new LIB_SYMBOL( *lib_symbol ), false );
|
|
|
|
RebuildSymbolUnitsList();
|
2024-01-26 16:16:13 +00:00
|
|
|
SetShowDeMorgan( GetCurSymbol()->HasAlternateBodyStyle() );
|
2023-07-02 09:34:32 +00:00
|
|
|
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2023-05-31 20:37:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-08-19 16:53:01 +00:00
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
2019-02-24 11:56:17 +00:00
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
|
2019-02-24 11:56:17 +00:00
|
|
|
{
|
|
|
|
// switches currently used canvas ( Cairo / OpenGL):
|
2019-05-28 13:51:47 +00:00
|
|
|
SCH_BASE_FRAME::SwitchCanvas( aCanvasType );
|
2019-02-24 11:56:17 +00:00
|
|
|
|
|
|
|
// Set options specific to symbol editor (axies are always enabled):
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
2020-03-22 00:03:59 +00:00
|
|
|
GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
|
2019-02-24 11:56:17 +00:00
|
|
|
}
|
2019-05-10 19:57:24 +00:00
|
|
|
|
2019-06-13 11:44:12 +00:00
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::HasLibModifications() const
|
2019-06-13 11:44:12 +00:00
|
|
|
{
|
|
|
|
wxCHECK( m_libMgr, false );
|
|
|
|
|
|
|
|
return m_libMgr->HasModifications();
|
|
|
|
}
|
2019-12-19 15:34:01 +00:00
|
|
|
|
|
|
|
|
2021-05-27 23:07:48 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::IsContentModified() const
|
2019-12-19 15:34:01 +00:00
|
|
|
{
|
|
|
|
wxCHECK( m_libMgr, false );
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
// Test if the currently edited symbol is modified
|
2021-06-15 12:31:28 +00:00
|
|
|
if( GetScreen() && GetScreen()->IsContentModified() && GetCurSymbol() )
|
2019-12-19 15:34:01 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
// Test if any library has been modified
|
2021-03-14 21:50:20 +00:00
|
|
|
for( const wxString& libName : m_libMgr->GetLibraryNames() )
|
2019-12-19 15:34:01 +00:00
|
|
|
{
|
2021-03-14 21:50:20 +00:00
|
|
|
if( m_libMgr->IsLibraryModified( libName ) && !m_libMgr->IsLibraryReadOnly( libName ) )
|
2019-12-19 15:34:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-13 11:21:40 +00:00
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
|
|
|
if( aItemCount == 0 )
|
|
|
|
return;
|
|
|
|
|
2024-02-07 14:49:50 +00:00
|
|
|
UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
|
2020-07-13 13:50:35 +00:00
|
|
|
|
2024-02-07 14:49:50 +00:00
|
|
|
if( aItemCount < 0 )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
2024-02-07 14:49:50 +00:00
|
|
|
list.ClearCommandList();
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
2024-02-07 14:49:50 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for( int ii = 0; ii < aItemCount; ii++ )
|
|
|
|
{
|
|
|
|
if( list.m_CommandsList.size() == 0 )
|
|
|
|
break;
|
2020-07-13 11:21:40 +00:00
|
|
|
|
2024-02-07 14:49:50 +00:00
|
|
|
PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
|
|
|
|
list.m_CommandsList.erase( list.m_CommandsList.begin() );
|
|
|
|
|
|
|
|
curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
delete aItem;
|
|
|
|
} );
|
|
|
|
delete curr_cmd; // Delete command
|
|
|
|
}
|
|
|
|
}
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
SELECTION& SYMBOL_EDIT_FRAME::GetCurrentSelection()
|
2020-08-06 23:03:58 +00:00
|
|
|
{
|
|
|
|
return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
|
|
|
|
}
|
2020-08-31 15:06:23 +00:00
|
|
|
|
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol )
|
2020-08-31 15:06:23 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
std::unique_ptr<LIB_SYMBOL> symbol = aSymbol->GetLibSymbolRef()->Flatten();
|
2021-06-10 18:51:46 +00:00
|
|
|
wxCHECK( symbol, /* void */ );
|
2021-02-14 18:29:27 +00:00
|
|
|
|
2023-03-15 16:55:18 +00:00
|
|
|
// Take in account the symbol orientation and mirroring. to calculate the field
|
|
|
|
// positions in symbol editor (i.e. no rotation, no mirroring)
|
|
|
|
int orientation = aSymbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
|
|
|
|
int mirror = aSymbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
|
|
|
|
|
2024-04-12 21:00:41 +00:00
|
|
|
std::vector<SCH_FIELD> fullSetOfFields;
|
2021-02-14 18:29:27 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < (int) aSymbol->GetFields().size(); ++i )
|
|
|
|
{
|
2021-02-28 13:28:23 +00:00
|
|
|
const SCH_FIELD& field = aSymbol->GetFields()[i];
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I pos = field.GetPosition() - aSymbol->GetPosition();
|
2024-04-12 21:00:41 +00:00
|
|
|
SCH_FIELD libField( symbol.get(), field.GetId() );
|
2021-02-14 18:29:27 +00:00
|
|
|
|
2021-02-28 13:28:23 +00:00
|
|
|
if( i >= MANDATORY_FIELDS && !field.GetName( false ).IsEmpty() )
|
|
|
|
libField.SetName( field.GetName( false ) );
|
2021-02-14 18:29:27 +00:00
|
|
|
|
2021-02-28 13:28:23 +00:00
|
|
|
libField.SetText( field.GetText() );
|
2021-12-28 22:13:54 +00:00
|
|
|
libField.SetAttributes( field );
|
2023-03-15 16:55:18 +00:00
|
|
|
|
|
|
|
// The inverse transform is mirroring before, rotate after
|
|
|
|
switch( mirror )
|
|
|
|
{
|
|
|
|
default:; break;
|
|
|
|
case SYM_MIRROR_X: pos.y = -pos.y; break;
|
|
|
|
case SYM_MIRROR_Y: pos.x = -pos.x; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( orientation )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case SYM_ORIENT_0: break;
|
|
|
|
case SYM_ORIENT_90:
|
|
|
|
std::swap( pos.x, pos.y );
|
|
|
|
pos.x = - pos.x;
|
|
|
|
break;
|
|
|
|
case SYM_ORIENT_270:
|
|
|
|
std::swap( pos.x, pos.y );
|
|
|
|
pos.y = - pos.y;
|
|
|
|
break;
|
|
|
|
case SYM_ORIENT_180:
|
|
|
|
pos.x = - pos.x;
|
|
|
|
pos.y = - pos.y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
libField.SetPosition( VECTOR2I( pos.x, -pos.y ) );
|
2021-02-14 18:29:27 +00:00
|
|
|
|
|
|
|
fullSetOfFields.emplace_back( std::move( libField ) );
|
|
|
|
}
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
symbol->SetFields( fullSetOfFields );
|
2020-08-31 15:06:23 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
if( m_symbol )
|
|
|
|
SetCurSymbol( nullptr, false );
|
2020-08-31 15:06:23 +00:00
|
|
|
|
|
|
|
m_isSymbolFromSchematic = true;
|
2021-11-11 16:42:25 +00:00
|
|
|
m_schematicSymbolUUID = aSymbol->m_Uuid;
|
2021-06-10 18:51:46 +00:00
|
|
|
m_reference = symbol->GetFieldById( REFERENCE_FIELD )->GetText();
|
2021-02-14 18:29:27 +00:00
|
|
|
m_unit = std::max( 1, aSymbol->GetUnit() );
|
2024-01-26 16:16:13 +00:00
|
|
|
m_bodyStyle = std::max( 1, aSymbol->GetBodyStyle() );
|
2020-08-31 15:06:23 +00:00
|
|
|
|
2023-01-06 00:32:25 +00:00
|
|
|
// Optimize default edit options for this symbol
|
|
|
|
// Usually if units are locked, graphic items are specific to each unit
|
|
|
|
// and if units are interchangeable, graphic items are common to units
|
|
|
|
SYMBOL_EDITOR_DRAWING_TOOLS* tools = GetToolManager()->GetTool<SYMBOL_EDITOR_DRAWING_TOOLS>();
|
|
|
|
tools->SetDrawSpecificUnit( symbol->UnitsLocked() );
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
// The buffered screen for the symbol
|
2020-08-31 15:06:23 +00:00
|
|
|
SCH_SCREEN* tmpScreen = new SCH_SCREEN();
|
|
|
|
|
|
|
|
SetScreen( tmpScreen );
|
2021-06-15 12:31:28 +00:00
|
|
|
SetCurSymbol( symbol.release(), true );
|
2023-05-31 20:37:58 +00:00
|
|
|
setSymWatcher( nullptr );
|
2020-08-31 15:06:23 +00:00
|
|
|
|
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
|
2021-03-18 11:46:07 +00:00
|
|
|
if( IsSymbolTreeShown() )
|
2020-08-31 15:06:23 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent evt;
|
2021-03-18 11:46:07 +00:00
|
|
|
OnToggleSymbolTree( evt );
|
2020-08-31 15:06:23 +00:00
|
|
|
}
|
|
|
|
|
2023-09-12 15:17:36 +00:00
|
|
|
UpdateTitle();
|
2020-08-31 15:06:23 +00:00
|
|
|
RebuildSymbolUnitsList();
|
2024-01-26 16:16:13 +00:00
|
|
|
SetShowDeMorgan( GetCurSymbol()->HasAlternateBodyStyle() );
|
2021-08-20 19:45:57 +00:00
|
|
|
UpdateSymbolMsgPanelInfo();
|
2023-03-23 17:36:20 +00:00
|
|
|
|
|
|
|
// Let tools add things to the view if necessary
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
|
|
|
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
|
|
|
GetCanvas()->Refresh();
|
2020-08-31 15:06:23 +00:00
|
|
|
}
|
2020-12-29 18:59:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool SYMBOL_EDIT_FRAME::addLibTableEntry( const wxString& aLibFile, TABLE_SCOPE aScope )
|
|
|
|
{
|
|
|
|
wxFileName fn = aLibFile;
|
|
|
|
wxFileName libTableFileName( Prj().GetProjectPath(),
|
|
|
|
SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
|
|
|
|
wxString libNickname = fn.GetName();
|
2023-09-28 03:04:53 +00:00
|
|
|
SYMBOL_LIB_TABLE* libTable = PROJECT_SCH::SchSymbolLibTable( &Prj() );
|
2020-12-29 18:59:48 +00:00
|
|
|
const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
|
|
|
|
|
|
|
|
if( libTable->HasLibrary( libNickname ) )
|
|
|
|
{
|
|
|
|
wxString tmp;
|
|
|
|
int suffix = 1;
|
|
|
|
|
|
|
|
while( libTable->HasLibrary( libNickname ) )
|
|
|
|
{
|
|
|
|
tmp.Printf( "%s%d", fn.GetName(), suffix );
|
|
|
|
libNickname = tmp;
|
|
|
|
suffix += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SYMBOL_LIB_TABLE_ROW* row = new SYMBOL_LIB_TABLE_ROW();
|
|
|
|
row->SetNickName( libNickname );
|
|
|
|
|
|
|
|
wxString normalizedPath = NormalizePath( aLibFile, &envVars, Prj().GetProjectPath() );
|
|
|
|
|
|
|
|
if( aScope == GLOBAL_LIB_TABLE )
|
|
|
|
{
|
|
|
|
libTable = &SYMBOL_LIB_TABLE::GetGlobalLibTable();
|
|
|
|
libTableFileName = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
|
|
|
|
|
|
|
|
// We cannot normalize against the current project path when saving to global table.
|
|
|
|
normalizedPath = NormalizePath( aLibFile, &envVars, wxEmptyString );
|
|
|
|
}
|
|
|
|
|
|
|
|
row->SetFullURI( normalizedPath );
|
|
|
|
|
|
|
|
wxCHECK( libTable->InsertRow( row ), false );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
libTable->Save( libTableFileName.GetFullPath() );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2021-01-31 22:58:34 +00:00
|
|
|
wxString msg = aScope == GLOBAL_LIB_TABLE ? _( "Error saving global library table." )
|
|
|
|
: _( "Error saving project library table." );
|
2020-12-29 18:59:48 +00:00
|
|
|
|
|
|
|
wxMessageDialog dlg( this, msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
|
|
|
|
dlg.SetExtendedMessage( ioe.What() );
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SYMBOL_EDIT_FRAME::replaceLibTableEntry( const wxString& aLibNickname,
|
|
|
|
const wxString& aLibFile )
|
|
|
|
{
|
|
|
|
// Check the global library table first because checking the project library table
|
|
|
|
// checks the global library table as well due to library chaining.
|
|
|
|
bool isGlobalTable = true;
|
|
|
|
wxFileName libTableFileName = SYMBOL_LIB_TABLE::GetGlobalTableFileName();;
|
|
|
|
const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
|
|
|
|
SYMBOL_LIB_TABLE* libTable = &SYMBOL_LIB_TABLE::GetGlobalLibTable();
|
|
|
|
SYMBOL_LIB_TABLE_ROW* row = libTable->FindRow( aLibNickname );
|
|
|
|
|
|
|
|
if( !row )
|
|
|
|
{
|
|
|
|
libTableFileName.SetPath( Prj().GetProjectPath() );
|
|
|
|
libTableFileName.SetName( SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
|
2023-09-28 03:04:53 +00:00
|
|
|
libTable = PROJECT_SCH::SchSymbolLibTable( &Prj() );
|
2020-12-29 18:59:48 +00:00
|
|
|
isGlobalTable = false;
|
|
|
|
row = libTable->FindRow( aLibNickname );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxCHECK( row, false );
|
|
|
|
|
|
|
|
wxString projectPath;
|
|
|
|
|
|
|
|
if( !isGlobalTable )
|
|
|
|
projectPath = Prj().GetProjectPath();
|
|
|
|
|
|
|
|
wxString normalizedPath = NormalizePath( aLibFile, &envVars, projectPath );
|
|
|
|
|
|
|
|
row->SetFullURI( normalizedPath );
|
|
|
|
row->SetType( "KiCad" );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
libTable->Save( libTableFileName.GetFullPath() );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2021-01-31 22:58:34 +00:00
|
|
|
wxString msg = isGlobalTable ? _( "Error saving global library table." )
|
|
|
|
: _( "Error saving project library table." );
|
2020-12-29 18:59:48 +00:00
|
|
|
|
|
|
|
wxMessageDialog dlg( this, msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
|
|
|
|
dlg.SetExtendedMessage( ioe.What() );
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2021-01-08 23:24:12 +00:00
|
|
|
|
|
|
|
|
2021-02-10 22:56:26 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::IsSymbolAlias() const
|
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
return m_symbol && !m_symbol->IsRoot();
|
2021-02-10 22:56:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-08 23:24:12 +00:00
|
|
|
bool SYMBOL_EDIT_FRAME::IsSymbolEditable() const
|
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
return m_symbol && ( !IsSymbolFromLegacyLibrary() || IsSymbolFromSchematic() );
|
2021-01-08 23:24:12 +00:00
|
|
|
}
|
2022-01-07 17:42:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SYMBOL_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpdateRtree )
|
|
|
|
{
|
|
|
|
SCH_BASE_FRAME::UpdateItem( aItem, isAddOrDelete, aUpdateRtree );
|
|
|
|
|
|
|
|
if( EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( aItem ) )
|
|
|
|
{
|
|
|
|
eda_text->ClearBoundingBoxCache();
|
|
|
|
eda_text->ClearRenderCache();
|
|
|
|
}
|
2022-09-14 22:11:37 +00:00
|
|
|
}
|
2024-02-25 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SYMBOL_EDIT_FRAME::updateSelectionFilterVisbility()
|
|
|
|
{
|
|
|
|
wxAuiPaneInfo& treePane = m_auimgr.GetPane( "SymbolTree" );
|
|
|
|
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 = ( treePane.IsShown() && treePane.IsDocked() )
|
|
|
|
|| ( propertiesPane.IsShown() && propertiesPane.IsDocked() );
|
|
|
|
|
|
|
|
selectionFilterPane.Show( showFilter );
|
|
|
|
}
|
2024-03-14 09:01:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool SYMBOL_EDIT_FRAME::GetShowInvisibleFields()
|
|
|
|
{
|
|
|
|
// Returns the current render option for invisible fields
|
2024-04-08 11:26:56 +00:00
|
|
|
return GetRenderSettings()->m_ShowHiddenFields;
|
2024-03-14 09:01:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SYMBOL_EDIT_FRAME::GetShowInvisiblePins()
|
|
|
|
{
|
|
|
|
// Returns the current render option for invisible pins
|
2024-04-08 11:26:56 +00:00
|
|
|
return GetRenderSettings()->m_ShowHiddenPins;
|
2024-03-14 09:01:58 +00:00
|
|
|
}
|