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>
|
2020-05-22 14:12:44 +00:00
|
|
|
* Copyright (C) 2004-2020 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
|
|
|
|
*/
|
|
|
|
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <base_screen.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <class_library.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <eeschema_id.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <eeschema_settings.h>
|
|
|
|
#include <fctsys.h>
|
|
|
|
#include <general.h>
|
|
|
|
#include <kiface_i.h>
|
|
|
|
#include <kiway_express.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <lib_edit_frame.h>
|
2017-11-12 17:55:20 +00:00
|
|
|
#include <lib_manager.h>
|
2020-04-14 12:25:00 +00:00
|
|
|
#include <lib_text.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <libedit_settings.h>
|
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <sch_draw_panel.h>
|
|
|
|
#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>
|
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-01-13 01:44:19 +00:00
|
|
|
#include <tool/picker_tool.h>
|
|
|
|
#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>
|
|
|
|
#include <tools/lib_control.h>
|
|
|
|
#include <tools/lib_drawing_tools.h>
|
2019-05-08 18:56:03 +00:00
|
|
|
#include <tools/lib_edit_tool.h>
|
|
|
|
#include <tools/lib_move_tool.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tools/lib_pin_tool.h>
|
2020-05-20 01:31:47 +00:00
|
|
|
#include <widgets/infobar.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <widgets/lib_tree.h>
|
|
|
|
#include <widgets/symbol_tree_pane.h>
|
|
|
|
#include <wildcards_and_files_ext.h>
|
|
|
|
#include <wx/progdlg.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow )
|
|
|
|
EVT_SIZE( LIB_EDIT_FRAME::OnSize )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
EVT_COMBOBOX( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_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
|
|
|
// Right vertical toolbar.
|
2019-05-10 19:57:24 +00:00
|
|
|
EVT_TOOL( ID_LIBEDIT_IMPORT_BODY_BUTT, LIB_EDIT_FRAME::OnImportBody )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_EXPORT_BODY_BUTT, LIB_EDIT_FRAME::OnExportBody )
|
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
|
2019-06-25 04:44:34 +00:00
|
|
|
EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::OnExitKiCad )
|
|
|
|
EVT_MENU( wxID_CLOSE, LIB_EDIT_FRAME::CloseWindow )
|
2018-09-04 18:22:26 +00:00
|
|
|
EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings )
|
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.
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnUpdatePartNumber )
|
2016-11-04 12:59:45 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2014-05-05 15:15:54 +00:00
|
|
|
LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
2020-04-12 23:09:17 +00:00
|
|
|
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
|
|
|
|
LIB_EDIT_FRAME_NAME ),
|
|
|
|
m_unitSelectBox( nullptr )
|
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
|
|
|
|
2019-12-13 21:51:59 +00:00
|
|
|
m_my_part = 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;
|
|
|
|
m_convert = 1;
|
2019-05-13 18:33:30 +00:00
|
|
|
m_AboutTitle = "LibEdit";
|
2015-04-30 11:08:35 +00:00
|
|
|
|
2011-09-08 05:58:45 +00:00
|
|
|
wxIcon icon;
|
2016-09-20 11:22:42 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_libedit_xpm ) );
|
2011-09-08 05:58:45 +00:00
|
|
|
SetIcon( icon );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_settings = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
|
|
|
|
LoadSettings( m_settings );
|
2015-08-06 00:10:52 +00:00
|
|
|
|
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() );
|
2020-03-06 03:57:50 +00:00
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
setupTools();
|
2019-06-13 11:44:12 +00:00
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
m_libMgr = new LIB_MANAGER( *this );
|
2017-11-30 11:31:36 +00:00
|
|
|
SyncLibraries( true );
|
2018-07-27 20:47:51 +00:00
|
|
|
m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
|
2017-11-12 17:55:20 +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();
|
2019-06-25 04:44:34 +00:00
|
|
|
InitExitKey();
|
2018-08-13 17:00:08 +00:00
|
|
|
|
2018-10-05 12:55:34 +00:00
|
|
|
updateTitle();
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayCmpDoc();
|
2019-05-06 12:32:51 +00:00
|
|
|
RebuildSymbolUnitsList();
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2020-05-21 17:22:12 +00:00
|
|
|
// Create the infobar
|
|
|
|
m_infoBar = new WX_INFOBAR( this, &m_auimgr );
|
2020-05-20 01:31:47 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
|
|
|
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
|
2011-09-15 18:25:44 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
|
2020-05-21 17:22:12 +00:00
|
|
|
m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "ComponentTree" ).Left().Layer(2)
|
2019-02-05 15:06:36 +00:00
|
|
|
.Caption( _( "Libraries" ) ).MinSize( 250, -1 )
|
2020-04-12 23:09:17 +00:00
|
|
|
.BestSize( m_settings->m_LibWidth, -1 ).Resizable() );
|
2020-05-21 17:22:12 +00:00
|
|
|
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(2) );
|
|
|
|
m_auimgr.AddPane( m_infoBar,
|
|
|
|
EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
|
2011-09-15 18:25:44 +00:00
|
|
|
|
2020-05-21 17:22:12 +00:00
|
|
|
m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2020-05-21 17:22:12 +00:00
|
|
|
// Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
|
|
|
|
// hidding it.
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
// We don't want the infobar displayed right away
|
|
|
|
m_auimgr.GetPane( "InfoBar" ).Hide();
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2015-07-15 12:41:30 +00:00
|
|
|
Raise();
|
2011-04-12 12:41:13 +00:00
|
|
|
Show( true );
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
SyncView();
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetViewControls()->SetSnapping( true );
|
|
|
|
GetCanvas()->GetView()->UseDrawPriority( true );
|
|
|
|
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
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
|
|
|
|
double max_size_x = Millimeter2iu( 600 );
|
|
|
|
double max_size_y = Millimeter2iu( 600 );
|
|
|
|
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
|
|
|
|
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
2019-12-19 14:11:11 +00:00
|
|
|
|
|
|
|
SetShutdownBlockReason( _( "Library changes are unsaved" ) );
|
2020-04-17 23:32:29 +00:00
|
|
|
|
|
|
|
// Ensure the window is on top
|
|
|
|
Raise();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::~LIB_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();
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
// current screen is destroyed in EDA_DRAW_FRAME
|
|
|
|
SetScreen( m_dummyScreen );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
auto libedit = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
|
|
|
|
Pgm().GetSettingsManager().Save( libedit );
|
|
|
|
|
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-01-13 01:44:19 +00:00
|
|
|
void LIB_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|
|
|
{
|
2020-05-10 22:02:58 +00:00
|
|
|
wxCHECK_RET( m_settings, "Call to LIB_EDIT_FRAME::LoadSettings with null m_settings" );
|
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;
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
// Hidden elements must be editable
|
2020-04-12 23:09:17 +00:00
|
|
|
GetRenderSettings()->m_ShowHiddenText = true;
|
|
|
|
GetRenderSettings()->m_ShowHiddenPins = true;
|
|
|
|
GetRenderSettings()->m_ShowUmbilicals = false;
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-10 22:02:58 +00:00
|
|
|
void LIB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
2020-01-13 01:44:19 +00:00
|
|
|
{
|
2020-05-10 22:02:58 +00:00
|
|
|
wxCHECK_RET( m_settings, "Call to LIB_EDIT_FRAME::LoadSettings with null m_settings" );
|
|
|
|
|
|
|
|
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;
|
2020-04-12 23:09:17 +00:00
|
|
|
m_settings->m_LibWidth = m_treePane->GetSize().x;
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-06 03:57:50 +00:00
|
|
|
COLOR_SETTINGS* LIB_EDIT_FRAME::GetColorSettings()
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-04 11:23:04 +00:00
|
|
|
void LIB_EDIT_FRAME::setupTools()
|
|
|
|
{
|
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
|
|
|
m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
|
2020-06-12 10:58:56 +00:00
|
|
|
GetCanvas()->GetViewControls(), config(), this );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_actions = new EE_ACTIONS();
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
|
|
|
|
|
|
|
// 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 );
|
2019-05-07 18:49:53 +00:00
|
|
|
m_toolManager->RegisterTool( new LIB_PIN_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new LIB_DRAWING_TOOLS );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolManager->RegisterTool( new EE_POINT_EDITOR );
|
2019-05-08 18:56:03 +00:00
|
|
|
m_toolManager->RegisterTool( new LIB_MOVE_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new LIB_EDIT_TOOL );
|
2019-05-14 19:21:10 +00:00
|
|
|
m_toolManager->RegisterTool( new LIB_CONTROL );
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-19 14:11:11 +00:00
|
|
|
void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-12-19 14:11:11 +00:00
|
|
|
// Shutdown blocks must be determined and vetoed as early as possible
|
2019-12-19 15:34:01 +00:00
|
|
|
if( SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
|
|
|
|
&& IsContentModified() )
|
2019-12-19 14:11:11 +00:00
|
|
|
{
|
2019-12-19 15:34:01 +00:00
|
|
|
aEvent.Veto();
|
|
|
|
return;
|
2019-12-19 14:11:11 +00:00
|
|
|
}
|
|
|
|
|
2018-02-16 10:27:43 +00:00
|
|
|
if( saveAllLibraries( true ) )
|
2017-11-13 09:55:05 +00:00
|
|
|
Destroy();
|
|
|
|
else
|
2019-12-19 14:11:11 +00:00
|
|
|
aEvent.Veto();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-06 12:32:51 +00:00
|
|
|
void LIB_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
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
if( !m_my_part || m_my_part->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
|
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
for( int i = 0; i < m_my_part->GetUnitCount(); i++ )
|
2009-09-14 13:24:17 +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
|
|
|
wxString sub = LIB_PART::SubReference( i+1, false );
|
|
|
|
wxString unit = wxString::Format( _( "Unit %s" ), GetChars( sub ) );
|
2019-06-16 18:51:47 +00:00
|
|
|
m_unitSelectBox->Append( unit );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-02 20:09:23 +00:00
|
|
|
// Ensure the selected unit is compatible with the number of units of the current part:
|
2019-11-06 19:15:42 +00:00
|
|
|
if( m_my_part && m_my_part->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
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-31 11:13:20 +00:00
|
|
|
void LIB_EDIT_FRAME::OnToggleSearchTree( wxCommandEvent& event )
|
|
|
|
{
|
2017-11-12 17:55:20 +00:00
|
|
|
auto& treePane = m_auimgr.GetPane( m_treePane );
|
2017-10-31 11:13:20 +00:00
|
|
|
treePane.Show( !IsSearchTreeShown() );
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-02 23:17:27 +00:00
|
|
|
bool LIB_EDIT_FRAME::IsSearchTreeShown()
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2019-06-02 23:17:27 +00:00
|
|
|
return m_auimgr.GetPane( m_treePane ).IsShown();
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-02 23:17:27 +00:00
|
|
|
void LIB_EDIT_FRAME::FreezeSearchTree()
|
2017-10-31 11:13:20 +00:00
|
|
|
{
|
2019-06-02 23:17:27 +00:00
|
|
|
m_libMgr->GetAdapter()->Freeze();
|
2017-10-31 11:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-02 23:17:27 +00:00
|
|
|
void LIB_EDIT_FRAME::ThawSearchTree()
|
2018-01-20 17:15:46 +00:00
|
|
|
{
|
2019-06-02 23:17:27 +00:00
|
|
|
m_libMgr->GetAdapter()->Thaw();
|
2018-01-20 17:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-25 04:44:34 +00:00
|
|
|
void LIB_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
Kiway().OnKiCadExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
|
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;
|
|
|
|
|
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
|
|
|
// Using the typical event.Enable() call doesn't seem to work with wxGTK
|
|
|
|
// so use the pointer to alias combobox to directly enable or disable.
|
2019-11-06 19:15:42 +00:00
|
|
|
m_unitSelectBox->Enable( m_my_part && m_my_part->GetUnitCount() > 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-08 18:56:03 +00:00
|
|
|
void LIB_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
|
|
|
|
2019-05-10 22:24:02 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::cancelInteractive, true );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolManager->RunAction( EE_ACTIONS::clearSelection, true );
|
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();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
wxString LIB_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
|
|
|
{
|
2017-10-06 18:07:43 +00:00
|
|
|
if( !Prj().SchSymbolLibTable()->HasLibrary( 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
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
wxString LIB_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
|
|
|
|
2017-10-06 18:07:43 +00:00
|
|
|
if( aLibNickname.empty() || !Prj().SchSymbolLibTable()->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
|
|
|
|
2017-11-13 11:19:14 +00:00
|
|
|
m_libMgr->SetCurrentLib( aLibNickname );
|
|
|
|
|
2020-05-16 21:25:13 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
|
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
|
|
|
|
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
|
|
|
void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart )
|
2010-10-23 10:09:23 +00:00
|
|
|
{
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolManager->RunAction( EE_ACTIONS::clearSelection, true );
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2020-03-21 20:54:35 +00:00
|
|
|
delete m_my_part;
|
2019-12-13 21:51:59 +00:00
|
|
|
m_my_part = aPart;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2017-11-14 11:03:19 +00:00
|
|
|
// select the current component in the tree widget
|
2019-11-06 19:15:42 +00:00
|
|
|
if( m_my_part )
|
|
|
|
m_treePane->GetLibTree()->SelectLibId( m_my_part->GetLibId() );
|
2017-11-14 11:03:19 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
wxString partName = m_my_part ? m_my_part->GetName() : wxString();
|
2017-11-13 11:19:14 +00:00
|
|
|
m_libMgr->SetCurrentPart( partName );
|
|
|
|
|
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
|
2017-11-13 11:19:14 +00:00
|
|
|
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_PART, partName );
|
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
|
2019-11-06 19:15:42 +00:00
|
|
|
m_SyncPinEdit = aPart && aPart->IsRoot() && aPart->IsMulti() && !aPart->UnitsLocked();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-05-06 12:32:51 +00:00
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2018-08-03 12:18:26 +00:00
|
|
|
RebuildView();
|
2019-11-06 19:15:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LIB_MANAGER& LIB_EDIT_FRAME::GetLibManager()
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2019-05-10 19:57:24 +00:00
|
|
|
void LIB_EDIT_FRAME::OnImportBody( wxCommandEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2019-05-10 19:57:24 +00:00
|
|
|
m_toolManager->DeactivateTool();
|
|
|
|
LoadOneSymbol();
|
2019-06-15 00:29:42 +00:00
|
|
|
m_drawToolBar->ToggleTool( ID_LIBEDIT_IMPORT_BODY_BUTT, false );
|
2019-05-10 19:57:24 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
|
2019-05-10 19:57:24 +00:00
|
|
|
void LIB_EDIT_FRAME::OnExportBody( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_toolManager->DeactivateTool();
|
|
|
|
SaveOneSymbol();
|
2019-06-15 00:29:42 +00:00
|
|
|
m_drawToolBar->ToggleTool( ID_LIBEDIT_EXPORT_BODY_BUTT, false );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
2011-02-24 22:29:43 +00:00
|
|
|
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
void LIB_EDIT_FRAME::OnModify()
|
2017-10-31 11:13:20 +00:00
|
|
|
{
|
2017-11-12 17:55:20 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
storeCurrentPart();
|
2018-09-04 16:12:15 +00:00
|
|
|
|
2019-11-26 21:38:57 +00:00
|
|
|
m_treePane->GetLibTree()->RefreshLibTree();
|
2017-10-31 11:13:20 +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
|
|
|
bool LIB_EDIT_FRAME::SynchronizePins()
|
2011-10-28 13:43:37 +00:00
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
return m_SyncPinEdit && m_my_part && m_my_part->IsMulti() && !m_my_part->UnitsLocked();
|
2011-10-28 13:43:37 +00:00
|
|
|
}
|
2017-03-10 13:38:39 +00:00
|
|
|
|
|
|
|
|
2017-03-10 15:09:55 +00:00
|
|
|
void LIB_EDIT_FRAME::refreshSchematic()
|
2017-03-10 13:38:39 +00:00
|
|
|
{
|
|
|
|
// There may be no parent window so use KIWAY message to refresh the schematic editor
|
|
|
|
// in case any symbols have changed.
|
2019-03-27 22:37:26 +00:00
|
|
|
std::string dummyPayload;
|
|
|
|
Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_REFRESH, dummyPayload, this );
|
2017-03-10 13:38:39 +00:00
|
|
|
}
|
2017-11-12 17:55:20 +00:00
|
|
|
|
|
|
|
|
2019-06-02 18:58:09 +00:00
|
|
|
bool LIB_EDIT_FRAME::AddLibraryFile( bool aCreateNew )
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2018-07-27 20:47:51 +00:00
|
|
|
wxFileName fn = m_libMgr->GetUniqueLibraryName();
|
|
|
|
|
2020-05-07 15:25:48 +00:00
|
|
|
if( !LibraryFileBrowser( !aCreateNew, fn, KiCadSymbolLibFileWildcard(),
|
|
|
|
KiCadSymbolLibFileExtension, false ) )
|
2018-11-04 12:32:54 +00:00
|
|
|
{
|
2018-07-27 20:47:51 +00:00
|
|
|
return false;
|
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() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_libMgr->LibraryExists( libName ) )
|
|
|
|
{
|
2018-07-27 20:47:51 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Library \"%s\" already exists" ), libName ) );
|
2017-11-12 17:55:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-22 13:02:45 +00:00
|
|
|
// Select the target library table (global/project)
|
|
|
|
SYMBOL_LIB_TABLE* libTable = selectSymLibTable();
|
|
|
|
|
|
|
|
if( !libTable )
|
|
|
|
return false;
|
|
|
|
|
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"
|
|
|
|
"Check write permission." ),
|
|
|
|
fn.GetFullPath() ) );
|
2018-07-27 20:47:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
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." ) );
|
2018-07-27 20:47:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
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 );
|
|
|
|
|
2018-07-27 20:47:51 +00:00
|
|
|
return true;
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-05 22:29:59 +00:00
|
|
|
LIB_ID LIB_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
|
|
|
|
|
|
|
LIB_PART* LIB_EDIT_FRAME::getTargetPart() const
|
|
|
|
{
|
|
|
|
LIB_ID libId = GetTreeLIBID();
|
2019-06-13 11:44:12 +00:00
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
if( libId.IsValid() )
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
LIB_PART* alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
|
|
|
|
return alias;
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
2019-12-13 21:51:59 +00:00
|
|
|
return m_my_part;
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LIB_ID LIB_EDIT_FRAME::getTargetLibId() const
|
|
|
|
{
|
2019-06-05 19:15:57 +00:00
|
|
|
LIB_ID id = GetTreeLIBID();
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
if( id.GetLibNickname().empty() && m_my_part )
|
|
|
|
id = m_my_part->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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-07 17:06:24 +00:00
|
|
|
LIB_TREE_NODE* LIB_EDIT_FRAME::GetCurrentTreeNode() const
|
|
|
|
{
|
|
|
|
return m_treePane->GetLibTree()->GetCurrentTreeNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
wxString LIB_EDIT_FRAME::getTargetLib() const
|
|
|
|
{
|
2018-05-02 22:33:53 +00:00
|
|
|
return getTargetLibId().GetLibNickname();
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-25 12:21:09 +00:00
|
|
|
void LIB_EDIT_FRAME::SyncLibraries( bool aShowProgress )
|
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
|
|
|
{
|
2018-08-25 12:21:09 +00:00
|
|
|
wxProgressDialog progressDlg( _( "Loading Symbol Libraries" ), wxEmptyString,
|
|
|
|
m_libMgr->GetAdapter()->GetLibrariesCount(), this );
|
2017-11-22 13:02:45 +00:00
|
|
|
|
2018-08-25 12:21:09 +00:00
|
|
|
m_libMgr->Sync( true, [&]( int progress, int max, const wxString& libName )
|
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
progressDlg.Update( progress, wxString::Format( _( "Loading library \"%s\"" ),
|
|
|
|
libName ) );
|
2017-11-30 11:31:36 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_libMgr->Sync( true );
|
|
|
|
}
|
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
|
|
|
|
|
|
|
// Try to select the parent library, in case the part is not found
|
|
|
|
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
|
|
|
|
|
|
|
// If no selection, see if there's a current part to centre
|
2019-11-06 19:15:42 +00:00
|
|
|
if( !selected.IsValid() && m_my_part )
|
2019-02-27 15:34:51 +00:00
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
LIB_ID current( GetCurLib(), m_my_part->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-02-07 17:06:24 +00:00
|
|
|
void LIB_EDIT_FRAME::RegenerateLibraryTree()
|
|
|
|
{
|
|
|
|
LIB_ID target = getTargetLibId();
|
|
|
|
|
|
|
|
m_treePane->GetLibTree()->Regenerate( true );
|
|
|
|
|
|
|
|
if( target.IsValid() )
|
|
|
|
m_treePane->GetLibTree()->CenterLibId( target );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-23 11:48:14 +00:00
|
|
|
SYMBOL_LIB_TABLE* LIB_EDIT_FRAME::selectSymLibTable( bool aOptional )
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
|
|
|
wxArrayString libTableNames;
|
2017-11-14 12:57:58 +00:00
|
|
|
libTableNames.Add( _( "Global" ) );
|
|
|
|
libTableNames.Add( _( "Project" ) );
|
2017-11-12 17:55:20 +00:00
|
|
|
|
2018-08-23 11:48:14 +00:00
|
|
|
wxSingleChoiceDialog dlg( this, _( "Choose the Library Table to add the library to:" ),
|
|
|
|
_( "Add To Library Table" ), libTableNames );
|
|
|
|
|
|
|
|
if( aOptional )
|
|
|
|
{
|
|
|
|
dlg.FindWindow( wxID_CANCEL )->SetLabel( _( "Skip" ) );
|
|
|
|
dlg.FindWindow( wxID_OK )->SetLabel( _( "Add" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
switch( dlg.GetSelection() )
|
2017-11-12 17:55:20 +00:00
|
|
|
{
|
2018-07-29 15:33:58 +00:00
|
|
|
case 0: return &SYMBOL_LIB_TABLE::GetGlobalLibTable();
|
|
|
|
case 1: return Prj().SchSymbolLibTable();
|
|
|
|
default: return nullptr;
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-13 14:15:10 +00:00
|
|
|
bool LIB_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt )
|
|
|
|
{
|
|
|
|
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() ) )
|
|
|
|
{
|
2019-04-22 07:34:28 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Failed to save backup to \"%s\"" ),
|
|
|
|
backupFileName.GetFullPath() ) );
|
2017-11-13 14:15:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-12 17:55:20 +00:00
|
|
|
void LIB_EDIT_FRAME::storeCurrentPart()
|
|
|
|
{
|
|
|
|
if( m_my_part && !GetCurLib().IsEmpty() && GetScreen()->IsModify() )
|
2019-12-13 21:51:59 +00:00
|
|
|
m_libMgr->UpdatePart( m_my_part, GetCurLib() ); // UpdatePart() makes a copy
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool LIB_EDIT_FRAME::isCurrentPart( const LIB_ID& aLibId ) const
|
|
|
|
{
|
2018-01-19 18:56:01 +00:00
|
|
|
// This will return the root part of any alias
|
|
|
|
LIB_PART* part = m_libMgr->GetBufferedPart( aLibId.GetLibItemName(), aLibId.GetLibNickname() );
|
|
|
|
// Now we can compare the libId of the current part and the root part
|
2019-11-06 19:15:42 +00:00
|
|
|
return ( part && m_my_part && part->GetLibId() == m_my_part->GetLibId() );
|
2017-11-12 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::emptyScreen()
|
|
|
|
{
|
2019-06-13 11:44:12 +00:00
|
|
|
m_treePane->GetLibTree()->Unselect();
|
2017-11-12 17:55:20 +00:00
|
|
|
SetCurLib( wxEmptyString );
|
|
|
|
SetCurPart( nullptr );
|
|
|
|
SetScreen( m_dummyScreen );
|
2020-07-13 11:21:40 +00:00
|
|
|
ClearUndoRedoList();
|
2019-06-04 12:46:02 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
2017-11-12 17:55:20 +00:00
|
|
|
Refresh();
|
|
|
|
}
|
2018-01-08 04:05:03 +00:00
|
|
|
|
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void LIB_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
|
|
|
|
2020-03-22 00:03:59 +00:00
|
|
|
GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::ShowChangedLanguage()
|
|
|
|
{
|
|
|
|
// call my base class
|
|
|
|
SCH_BASE_FRAME::ShowChangedLanguage();
|
|
|
|
|
|
|
|
// tooltips in toolbars
|
2019-07-20 15:52:30 +00:00
|
|
|
RecreateToolbars();
|
2018-06-30 22:38:04 +00:00
|
|
|
|
|
|
|
// status bar
|
|
|
|
UpdateMsgPanel();
|
|
|
|
}
|
|
|
|
|
2018-10-17 11:14:09 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
void LIB_EDIT_FRAME::SetScreen( BASE_SCREEN* aScreen )
|
|
|
|
{
|
2019-04-17 19:09:48 +00:00
|
|
|
SCH_BASE_FRAME::SetScreen( aScreen );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-10-17 11:14:09 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
void LIB_EDIT_FRAME::RebuildView()
|
|
|
|
{
|
2018-09-02 20:19:22 +00:00
|
|
|
GetRenderSettings()->m_ShowUnit = m_unit;
|
|
|
|
GetRenderSettings()->m_ShowConvert = m_convert;
|
2019-11-06 19:15:42 +00:00
|
|
|
GetRenderSettings()->m_ShowDisabled = m_my_part && m_my_part->IsAlias();
|
2019-12-13 21:51:59 +00:00
|
|
|
GetCanvas()->DisplayComponent( m_my_part );
|
2018-10-21 12:50:31 +00:00
|
|
|
GetCanvas()->GetView()->HideWorksheet();
|
|
|
|
GetCanvas()->GetView()->ClearHiddenFlags();
|
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
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::HardRedraw()
|
|
|
|
{
|
2019-04-11 01:23:34 +00:00
|
|
|
SyncLibraries( true );
|
2020-03-21 20:54:35 +00:00
|
|
|
|
|
|
|
if( m_my_part )
|
|
|
|
{
|
|
|
|
EE_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
EE_SELECTION& selection = selectionTool->GetSelection();
|
|
|
|
|
|
|
|
for( LIB_ITEM& item : m_my_part->GetDrawItems() )
|
|
|
|
{
|
|
|
|
if( std::find( selection.begin(), selection.end(), &item ) == selection.end() )
|
|
|
|
item.ClearSelected();
|
|
|
|
else
|
|
|
|
item.SetSelected();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-17 11:14:09 +00:00
|
|
|
RebuildView();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
const BOX2I LIB_EDIT_FRAME::GetDocumentExtents() const
|
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
if( !m_my_part )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2019-12-30 20:43:10 +00:00
|
|
|
return BOX2I( VECTOR2I( Mils2iu( -100 ), Mils2iu( -100 ) ),
|
|
|
|
VECTOR2I( Mils2iu( 200 ), Mils2iu( 200 ) ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
EDA_RECT boundingBox = m_my_part->Flatten()->GetUnitBoundingBox( m_unit, m_convert );
|
|
|
|
return BOX2I( boundingBox.GetOrigin(), VECTOR2I( boundingBox.GetWidth(),
|
|
|
|
boundingBox.GetHeight() ) );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 16:53:01 +00:00
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|
|
|
{
|
|
|
|
const std::string& payload = mail.GetPayload();
|
|
|
|
|
|
|
|
switch( mail.Command() )
|
|
|
|
{
|
|
|
|
case MAIL_LIB_EDIT:
|
|
|
|
if( !payload.empty() )
|
|
|
|
{
|
|
|
|
wxString libFileName( payload );
|
|
|
|
wxString libNickname;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
|
|
|
|
const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( libFileName );
|
|
|
|
|
|
|
|
if( !libTableRow )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "The current configuration does not include the symbol library\n"
|
|
|
|
"\"%s\".\nUse Manage Symbol Libraries to edit the configuration." ),
|
|
|
|
libFileName );
|
|
|
|
DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
libNickname = libTableRow->GetNickName();
|
|
|
|
|
|
|
|
if( !libTable->HasLibrary( libNickname, true ) )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "The library with the nickname \"%s\" is not enabled\n"
|
|
|
|
"in the current configuration. Use Manage Symbol Libraries to\n"
|
|
|
|
"edit the configuration." ), libNickname );
|
|
|
|
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 );
|
|
|
|
m_treePane->GetLibTree()->ExpandLibId( id );
|
|
|
|
m_treePane->GetLibTree()->CenterLibId( id );
|
|
|
|
}
|
2018-08-19 16:53:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
2019-02-24 11:56:17 +00:00
|
|
|
|
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
void LIB_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
|
|
|
|
|
|
|
bool LIB_EDIT_FRAME::HasLibModifications() const
|
|
|
|
{
|
|
|
|
wxCHECK( m_libMgr, false );
|
|
|
|
|
|
|
|
return m_libMgr->HasModifications();
|
|
|
|
}
|
2019-12-19 15:34:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool LIB_EDIT_FRAME::IsContentModified()
|
|
|
|
{
|
|
|
|
wxCHECK( m_libMgr, false );
|
|
|
|
|
|
|
|
// Test if the currently edited part is modified
|
|
|
|
if( GetScreen() && GetScreen()->IsModify() && GetCurPart() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Test if any library has been modified
|
|
|
|
for( const auto& libNickname : m_libMgr->GetLibraryNames() )
|
|
|
|
{
|
2020-05-16 21:25:13 +00:00
|
|
|
if( m_libMgr->IsLibraryModified( libNickname )
|
|
|
|
&& !m_libMgr->IsLibraryReadOnly( libNickname ) )
|
2019-12-19 15:34:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-13 11:21:40 +00:00
|
|
|
|
|
|
|
|
2020-07-13 13:50:35 +00:00
|
|
|
void LIB_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
|
|
|
if( aItemCount == 0 )
|
|
|
|
return;
|
|
|
|
|
2020-07-13 13:50:35 +00:00
|
|
|
UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
|
|
|
|
|
|
|
|
for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
|
|
|
command->ClearListAndDeleteItems();
|
|
|
|
delete command;
|
|
|
|
}
|
|
|
|
|
2020-07-13 13:50:35 +00:00
|
|
|
list.m_CommandsList.clear();
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|