2011-11-08 16:37:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-01-28 10:00:48 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2015-01-30 18:42:46 +00:00
|
|
|
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2016-10-28 13:11:23 +00:00
|
|
|
* Copyright (C) 2015-2016 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-01-30 10:52:52 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-11-08 16:37:25 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +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 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2011-11-08 16:37:25 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +00:00
|
|
|
* 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.
|
2011-11-08 16:37:25 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-11-08 16:37:25 +00:00
|
|
|
*/
|
|
|
|
|
2020-10-02 22:42:32 +00:00
|
|
|
#include "tools/convert_tool.h"
|
2020-01-13 01:44:19 +00:00
|
|
|
#include "tools/drawing_tool.h"
|
|
|
|
#include "tools/edit_tool.h"
|
2020-12-25 16:26:32 +00:00
|
|
|
#include "tools/footprint_editor_control.h"
|
2020-01-13 01:44:19 +00:00
|
|
|
#include "tools/pad_tool.h"
|
|
|
|
#include "tools/pcb_actions.h"
|
2020-12-16 13:31:32 +00:00
|
|
|
#include "tools/pcb_control.h"
|
|
|
|
#include "tools/pcb_picker_tool.h"
|
2020-01-13 01:44:19 +00:00
|
|
|
#include "tools/placement_tool.h"
|
2021-01-16 23:17:32 +00:00
|
|
|
#include "tools/pcb_point_editor.h"
|
2020-12-16 13:31:32 +00:00
|
|
|
#include "tools/pcb_selection_tool.h"
|
2021-03-19 23:38:11 +00:00
|
|
|
#include <python/scripting/pcb_scripting_tool.h>
|
2021-08-05 12:03:59 +00:00
|
|
|
#include <3d_viewer/eda_3d_viewer_frame.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <footprint.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <confirm.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <footprint_editor_settings.h>
|
|
|
|
#include <footprint_info_impl.h>
|
|
|
|
#include <footprint_tree_pane.h>
|
|
|
|
#include <fp_lib_table.h>
|
2021-11-25 12:22:40 +00:00
|
|
|
#include <plugins/kicad/pcb_plugin.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.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcb_draw_panel_gal.h>
|
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <project.h>
|
|
|
|
#include <settings/settings_manager.h>
|
|
|
|
#include <tool/action_toolbar.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/common_control.h>
|
2017-02-23 14:02:18 +00:00
|
|
|
#include <tool/common_tools.h>
|
2020-08-13 23:09:17 +00:00
|
|
|
#include <tool/selection.h>
|
2014-07-09 09:22:43 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2017-08-31 02:35:30 +00:00
|
|
|
#include <tool/zoom_tool.h>
|
2020-08-13 23:09:17 +00:00
|
|
|
#include <tools/pcb_editor_conditions.h>
|
2020-05-22 18:27:05 +00:00
|
|
|
#include <tools/pcb_viewer_tools.h>
|
2020-10-03 11:16:29 +00:00
|
|
|
#include <tools/group_tool.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tools/position_relative_tool.h>
|
2020-09-30 03:29:58 +00:00
|
|
|
#include <widgets/appearance_controls.h>
|
2018-07-29 15:33:58 +00:00
|
|
|
#include <widgets/lib_tree.h>
|
2020-08-15 20:42:11 +00:00
|
|
|
#include <widgets/panel_selection_filter.h>
|
2021-08-14 20:05:21 +00:00
|
|
|
#include <widgets/wx_progress_reporters.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2021-06-03 01:19:20 +00:00
|
|
|
#include <wx/filedlg.h>
|
2021-10-30 22:21:15 +00:00
|
|
|
#include <widgets/wx_aui_utils.h>
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
2020-11-10 20:31:52 +00:00
|
|
|
EVT_MENU( wxID_CLOSE, FOOTPRINT_EDIT_FRAME::CloseFootprintEditor )
|
2019-06-25 04:44:34 +00:00
|
|
|
EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::OnExitKiCad )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_SIZE( FOOTPRINT_EDIT_FRAME::OnSize )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2019-01-28 14:15:32 +00:00
|
|
|
EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom )
|
|
|
|
EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2020-11-10 20:11:53 +00:00
|
|
|
EVT_TOOL( ID_FPEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng )
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2022-01-10 14:03:30 +00:00
|
|
|
EVT_TOOL( ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnLoadFootprintFromBoard )
|
|
|
|
EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::OnSaveFootprintToBoard )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2019-11-03 17:14:21 +00:00
|
|
|
// Horizontal toolbar
|
2019-05-29 03:32:40 +00:00
|
|
|
EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings )
|
2020-11-10 20:11:53 +00:00
|
|
|
EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, FOOTPRINT_EDIT_FRAME::SelectLayer )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2015-09-13 14:23:01 +00:00
|
|
|
// UI update events.
|
2020-11-10 20:11:53 +00:00
|
|
|
EVT_UPDATE_UI( ID_LOAD_FOOTPRINT_FROM_BOARD,
|
2020-11-10 20:31:52 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard )
|
2019-04-15 21:09:14 +00:00
|
|
|
EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD,
|
2020-11-10 20:31:52 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateSaveFootprintToBoard )
|
2019-11-03 17:14:21 +00:00
|
|
|
EVT_UPDATE_UI( ID_TOOLBARH_PCB_SELECT_LAYER, FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox )
|
2009-11-18 12:52:19 +00:00
|
|
|
END_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2021-11-21 20:32:39 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
2019-09-05 22:00:47 +00:00
|
|
|
PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_FOOTPRINT_EDITOR, wxEmptyString,
|
2014-07-09 11:50:27 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2021-10-30 22:21:15 +00:00
|
|
|
KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() ),
|
|
|
|
m_show_layer_manager_tools( true )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-12-14 20:03:15 +00:00
|
|
|
m_showBorderAndTitleBlock = false; // true to show the frame references
|
2021-02-18 15:49:35 +00:00
|
|
|
m_aboutTitle = _( "KiCad Footprint Editor" );
|
2019-11-03 17:14:21 +00:00
|
|
|
m_selLayerBox = nullptr;
|
2021-07-29 15:02:25 +00:00
|
|
|
m_editorSettings = nullptr;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// Give an icon
|
2011-09-09 19:30:59 +00:00
|
|
|
wxIcon icon;
|
2020-12-22 19:41:32 +00:00
|
|
|
wxIconBundle icon_bundle;
|
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
|
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_modedit_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_modedit_16 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
|
|
|
|
SetIcons( icon_bundle );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
// Create GAL canvas
|
2021-11-21 20:32:39 +00:00
|
|
|
m_canvasType = loadCanvasTypeSetting();
|
2019-01-11 12:19:46 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
|
2019-01-11 12:19:46 +00:00
|
|
|
GetGalDisplayOptions(), m_canvasType );
|
2019-06-13 17:28:55 +00:00
|
|
|
SetCanvas( drawPanel );
|
2014-06-11 05:00:30 +00:00
|
|
|
SetBoard( new BOARD() );
|
2019-10-28 09:15:03 +00:00
|
|
|
|
2020-02-27 17:46:49 +00:00
|
|
|
// This board will only be used to hold a footprint for editing
|
|
|
|
GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER );
|
|
|
|
|
2020-11-16 00:45:43 +00:00
|
|
|
// In Footprint Editor, the default net clearance is not known (it depends on the actual
|
|
|
|
// board). So we do not show the default clearance, by setting it to 0. The footprint or
|
|
|
|
// pad specific clearance will be shown.
|
2017-01-17 14:05:17 +00:00
|
|
|
GetBoard()->GetDesignSettings().GetDefault()->SetClearance( 0 );
|
|
|
|
|
2021-08-22 22:05:47 +00:00
|
|
|
// Don't show the default board solder mask expansion in the footprint editor. Only the
|
|
|
|
// footprint or pad mask expansions settings should be shown.
|
|
|
|
GetBoard()->GetDesignSettings().m_SolderMaskExpansion = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2014-06-11 05:18:41 +00:00
|
|
|
// restore the last footprint from the project, if any
|
|
|
|
restoreLastFootprint();
|
|
|
|
|
2014-06-11 05:00:30 +00:00
|
|
|
// Ensure all layers and items are visible:
|
2020-05-08 18:10:47 +00:00
|
|
|
// In footprint editor, some layers have no meaning or cannot be used, but we show all of
|
|
|
|
// them, at least to be able to edit a bad layer
|
2014-06-11 05:00:30 +00:00
|
|
|
GetBoard()->SetVisibleAlls();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
// However the "no net" mark on pads is useless, because there are no nets in footprint
|
|
|
|
// editor: make it non visible.
|
2017-10-05 18:11:55 +00:00
|
|
|
GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false );
|
|
|
|
|
2018-02-19 00:04:03 +00:00
|
|
|
GetGalDisplayOptions().m_axesEnabled = true;
|
2017-09-10 14:21:56 +00:00
|
|
|
|
2020-11-16 00:45:43 +00:00
|
|
|
// In Footprint Editor, set the default paper size to A4 for plot/print
|
2014-06-11 05:00:30 +00:00
|
|
|
SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
|
2020-06-18 13:49:32 +00:00
|
|
|
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
|
2013-03-12 15:17:44 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
setupTools();
|
2020-08-13 23:09:17 +00:00
|
|
|
setupUIConditions();
|
2019-05-14 19:21:10 +00:00
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
initLibraryTree();
|
|
|
|
m_treePane = new FOOTPRINT_TREE_PANE( this );
|
|
|
|
|
2019-05-30 12:25:08 +00:00
|
|
|
ReCreateMenuBar();
|
2007-08-20 01:20:48 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
ReCreateOptToolbar();
|
|
|
|
|
2020-08-15 20:42:11 +00:00
|
|
|
m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
|
2020-09-30 03:29:58 +00:00
|
|
|
m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas(), true );
|
2020-08-15 20:42:11 +00:00
|
|
|
|
|
|
|
// LoadSettings() *after* creating m_LayersManager, because LoadSettings() initialize
|
|
|
|
// parameters in m_LayersManager
|
|
|
|
// NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew
|
|
|
|
LoadSettings( GetSettings() );
|
|
|
|
|
2020-09-07 20:00:28 +00:00
|
|
|
// Must be set after calling LoadSettings() to be sure these parameters are not dependent
|
|
|
|
// on what is read in stored settings. Enable one internal layer, because footprints
|
|
|
|
// support keepout areas that can be on internal layers only (therefore on the first internal
|
|
|
|
// layer). This is needed to handle these keepout in internal layers only.
|
|
|
|
GetBoard()->SetCopperLayerCount( 3 );
|
|
|
|
GetBoard()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) );
|
|
|
|
GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() );
|
|
|
|
GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
|
|
|
|
|
2020-09-30 03:29:58 +00:00
|
|
|
SetActiveLayer( F_SilkS );
|
2018-08-05 11:56:02 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2020-11-14 03:15:32 +00:00
|
|
|
|
2020-12-22 21:35:25 +00:00
|
|
|
CreateInfoBar();
|
|
|
|
|
2020-11-14 03:15:32 +00:00
|
|
|
unsigned int auiFlags = wxAUI_MGR_DEFAULT;
|
|
|
|
#if !defined( _WIN32 )
|
2020-12-11 12:09:37 +00:00
|
|
|
// Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
|
|
|
|
// of graphical glitches
|
2020-11-14 03:16:23 +00:00
|
|
|
auiFlags |= wxAUI_MGR_LIVE_RESIZE;
|
2020-11-14 03:15:32 +00:00
|
|
|
#endif
|
|
|
|
m_auimgr.SetFlags( auiFlags );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2020-12-11 12:09:37 +00:00
|
|
|
// Rows; layers 4 - 6
|
|
|
|
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 ) );
|
|
|
|
|
|
|
|
// Columns; layers 1 - 3
|
|
|
|
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
|
|
|
|
.Left().Layer( 3 ) );
|
|
|
|
m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" )
|
|
|
|
.Left().Layer(2)
|
|
|
|
.Caption( _( "Libraries" ) )
|
|
|
|
.MinSize( 250, 400 ).Resizable() );
|
|
|
|
|
|
|
|
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
|
|
|
|
.Right().Layer(2) );
|
|
|
|
|
|
|
|
m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
|
|
|
|
.Right().Layer( 3 )
|
2020-09-30 22:02:05 +00:00
|
|
|
.Caption( _( "Appearance" ) ).PaneBorder( false )
|
|
|
|
.MinSize( 180, -1 ).BestSize( 180, -1 ) );
|
2020-12-11 12:09:37 +00:00
|
|
|
m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Palette().Name( "SelectionFilter" )
|
|
|
|
.Right().Layer( 3 ).Position( 2 )
|
|
|
|
.Caption( _( "Selection Filter" ) ).PaneBorder( false )
|
2020-08-15 20:42:11 +00:00
|
|
|
.MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) );
|
|
|
|
|
2020-12-11 12:09:37 +00:00
|
|
|
// Center
|
|
|
|
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
|
|
|
|
.Center() );
|
|
|
|
|
2021-10-30 22:21:15 +00:00
|
|
|
m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
|
|
|
|
m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
|
|
|
|
|
2020-08-15 20:42:11 +00:00
|
|
|
// The selection filter doesn't need to grow in the vertical direction when docked
|
|
|
|
m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
|
|
|
|
|
2019-05-30 12:25:08 +00:00
|
|
|
ActivateGalCanvas();
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2020-12-22 21:35:25 +00:00
|
|
|
FinishAUIInitialization();
|
2020-05-21 17:22:12 +00:00
|
|
|
|
2021-07-29 15:02:25 +00:00
|
|
|
if( m_editorSettings->m_LibWidth > 0 )
|
2020-10-26 15:34:59 +00:00
|
|
|
{
|
|
|
|
wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
|
|
|
|
|
|
|
|
// wxAUI hack: force width by setting MinSize() and then Fixed()
|
|
|
|
// thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
|
2021-07-29 15:02:25 +00:00
|
|
|
treePane.MinSize( m_editorSettings->m_LibWidth, -1 );
|
2020-10-26 15:34:59 +00:00
|
|
|
treePane.Fixed();
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
// now make it resizable again
|
|
|
|
treePane.Resizable();
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
// Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
|
|
|
|
// back to minimum.
|
|
|
|
treePane.MinSize( 250, -1 );
|
|
|
|
}
|
|
|
|
|
2020-09-30 03:29:58 +00:00
|
|
|
// Apply saved visibility stuff at the end
|
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
|
|
|
|
m_appearancePanel->SetUserLayerPresets( cfg->m_LayerPresets );
|
|
|
|
m_appearancePanel->ApplyLayerPreset( cfg->m_ActiveLayerPreset );
|
|
|
|
|
2021-10-30 22:21:15 +00:00
|
|
|
if( cfg->m_AuiPanels.right_panel_width > 0 )
|
|
|
|
{
|
|
|
|
wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
|
|
|
|
SetAuiPaneSize( m_auimgr, layersManager, cfg->m_AuiPanels.right_panel_width, -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_appearancePanel->SetTabIndex( cfg->m_AuiPanels.appearance_panel_tab );
|
|
|
|
|
2019-06-04 12:46:02 +00:00
|
|
|
GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
|
2021-02-20 14:36:28 +00:00
|
|
|
UpdateTitle();
|
2020-10-05 19:26:33 +00:00
|
|
|
setupUnits( GetSettings() );
|
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
|
|
|
|
2021-12-03 00:33:13 +00:00
|
|
|
resolveCanvasType();
|
|
|
|
|
2019-12-19 14:11:11 +00:00
|
|
|
// Default shutdown reason until a file is loaded
|
2020-09-01 10:14:51 +00:00
|
|
|
KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Footprint changes are unsaved" ) );
|
2019-12-19 14:11:11 +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 );
|
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
// Ensure the window is on top
|
|
|
|
Raise();
|
2015-07-15 12:41:30 +00:00
|
|
|
Show( true );
|
2021-03-27 21:49:38 +00:00
|
|
|
|
|
|
|
// Register a call to update the toolbar sizes. It can't be done immediately because
|
|
|
|
// it seems to require some sizes calculated that aren't yet (at least on GTK).
|
|
|
|
CallAfter( [&]()
|
|
|
|
{
|
|
|
|
// Ensure the controls on the toolbars all are correctly sized
|
|
|
|
UpdateToolbarControlSizes();
|
|
|
|
} );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::~FOOTPRINT_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();
|
|
|
|
|
2014-06-11 05:18:41 +00:00
|
|
|
// save the footprint in the PROJECT
|
|
|
|
retainLastFootprint();
|
2014-07-09 09:59:23 +00:00
|
|
|
|
2020-08-15 20:42:11 +00:00
|
|
|
delete m_selectionFilterPanel;
|
2020-09-30 03:29:58 +00:00
|
|
|
delete m_appearancePanel;
|
2022-01-08 22:32:17 +00:00
|
|
|
delete m_treePane;
|
2012-02-02 17:45:37 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 17:24:45 +00:00
|
|
|
|
2021-05-27 23:07:48 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::IsContentModified() const
|
2019-12-19 15:34:01 +00:00
|
|
|
{
|
2021-05-28 19:07:04 +00:00
|
|
|
return GetScreen() && GetScreen()->IsContentModified() && GetBoard() && GetBoard()->GetFirstFootprint();
|
2019-12-19 15:34:01 +00:00
|
|
|
}
|
|
|
|
|
2018-08-11 11:16:41 +00:00
|
|
|
|
2020-08-13 23:09:17 +00:00
|
|
|
SELECTION& FOOTPRINT_EDIT_FRAME::GetCurrentSelection()
|
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
2020-08-13 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
|
2018-08-11 11:16:41 +00:00
|
|
|
{
|
2019-05-28 13:51:47 +00:00
|
|
|
// switches currently used canvas (Cairo / OpenGL).
|
|
|
|
PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
|
2019-06-01 00:48:11 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
2018-08-11 11:16:41 +00:00
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// The base class method *does not reinit* the layers manager. We must update the layer
|
2019-05-28 13:51:47 +00:00
|
|
|
// widget to match board visibility states, both layers and render columns, and and some
|
|
|
|
// settings dependent on the canvas.
|
2018-08-11 11:16:41 +00:00
|
|
|
UpdateUserInterface();
|
|
|
|
}
|
|
|
|
|
2018-11-04 00:58:28 +00:00
|
|
|
|
2019-04-11 01:23:34 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::HardRedraw()
|
|
|
|
{
|
|
|
|
SyncLibraryTree( true );
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->ForceRefresh();
|
2019-04-11 01:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-06 11:45:28 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::ToggleSearchTree()
|
2018-11-04 00:58:28 +00:00
|
|
|
{
|
2020-06-18 13:49:32 +00:00
|
|
|
wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
|
2018-11-04 00:58:28 +00:00
|
|
|
treePane.Show( !IsSearchTreeShown() );
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-30 22:21:15 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::ToggleLayersManager()
|
|
|
|
{
|
|
|
|
FOOTPRINT_EDITOR_SETTINGS* settings = GetSettings();
|
|
|
|
wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
|
|
|
|
wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
|
|
|
|
|
|
|
|
// show auxiliary Vertical layers and visibility manager toolbar
|
|
|
|
m_show_layer_manager_tools = !m_show_layer_manager_tools;
|
|
|
|
layersManager.Show( m_show_layer_manager_tools );
|
|
|
|
selectionFilter.Show( m_show_layer_manager_tools );
|
|
|
|
|
|
|
|
if( m_show_layer_manager_tools )
|
|
|
|
{
|
|
|
|
SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-10 00:27:03 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::IsSearchTreeShown() const
|
2018-11-04 00:58:28 +00:00
|
|
|
{
|
2021-12-10 00:27:03 +00:00
|
|
|
return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
|
2018-11-04 00:58:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-13 15:31:54 +00:00
|
|
|
BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const
|
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
return GetBoard()->GetFirstFootprint();
|
2016-05-13 15:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
LIB_ID FOOTPRINT_EDIT_FRAME::GetTreeFPID() const
|
|
|
|
{
|
|
|
|
return m_treePane->GetLibTree()->GetSelectedLibId();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-07 17:06:24 +00:00
|
|
|
LIB_TREE_NODE* FOOTPRINT_EDIT_FRAME::GetCurrentTreeNode() const
|
|
|
|
{
|
|
|
|
return m_treePane->GetLibTree()->GetCurrentTreeNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-03 23:50:44 +00:00
|
|
|
LIB_ID FOOTPRINT_EDIT_FRAME::GetTargetFPID() const
|
2013-11-19 17:24:45 +00:00
|
|
|
{
|
2021-12-10 00:27:03 +00:00
|
|
|
LIB_ID id;
|
|
|
|
|
|
|
|
if( IsSearchTreeShown() )
|
|
|
|
id = GetTreeFPID();
|
2014-06-11 05:18:41 +00:00
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
if( id.GetLibNickname().empty() )
|
2021-12-10 00:27:03 +00:00
|
|
|
id = GetLoadedFPID();
|
2014-06-11 05:18:41 +00:00
|
|
|
|
2018-07-29 15:33:58 +00:00
|
|
|
return id;
|
2013-11-19 17:24:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-13 23:39:40 +00:00
|
|
|
LIB_ID FOOTPRINT_EDIT_FRAME::GetLoadedFPID() const
|
2013-11-19 17:24:45 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
|
2018-07-29 15:33:58 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
if( footprint )
|
|
|
|
return LIB_ID( footprint->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
|
2018-07-29 15:33:58 +00:00
|
|
|
else
|
|
|
|
return LIB_ID();
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2013-11-19 17:24:45 +00:00
|
|
|
|
|
|
|
|
2020-11-10 20:11:53 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::ClearModify()
|
|
|
|
{
|
|
|
|
if( GetBoard()->GetFirstFootprint() )
|
|
|
|
m_footprintNameWhenLoaded = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
|
|
|
|
|
2021-05-28 19:07:04 +00:00
|
|
|
GetScreen()->SetContentModified( false );
|
2020-11-10 20:11:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-25 15:12:08 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::IsCurrentFPFromBoard() const
|
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
|
2018-08-25 15:12:08 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
return ( footprint && footprint->GetLink() != niluuid );
|
2018-08-25 15:12:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-11 05:18:41 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::retainLastFootprint()
|
2013-10-13 21:33:58 +00:00
|
|
|
{
|
2018-09-13 23:39:40 +00:00
|
|
|
LIB_ID id = GetLoadedFPID();
|
2014-06-11 05:18:41 +00:00
|
|
|
|
2018-07-29 15:33:58 +00:00
|
|
|
if( id.IsValid() )
|
2013-10-13 21:33:58 +00:00
|
|
|
{
|
2020-06-18 13:49:32 +00:00
|
|
|
Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME, id.GetLibNickname() );
|
|
|
|
Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME, id.GetLibItemName() );
|
2013-10-13 21:33:58 +00:00
|
|
|
}
|
2014-06-11 05:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::restoreLastFootprint()
|
|
|
|
{
|
2020-06-18 13:49:32 +00:00
|
|
|
const wxString& footprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME );
|
|
|
|
const wxString& libNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME );
|
2014-06-11 05:18:41 +00:00
|
|
|
|
2020-06-18 13:49:32 +00:00
|
|
|
if( libNickname.Length() && footprintName.Length() )
|
2013-10-13 21:33:58 +00:00
|
|
|
{
|
2018-03-09 01:31:30 +00:00
|
|
|
LIB_ID id;
|
2020-06-18 13:49:32 +00:00
|
|
|
id.SetLibNickname( libNickname );
|
|
|
|
id.SetLibItemName( footprintName );
|
2014-06-11 05:18:41 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = loadFootprint( id );
|
2014-06-11 05:57:26 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
if( footprint )
|
2020-11-10 20:31:52 +00:00
|
|
|
AddFootprintToBoard( footprint );
|
2013-10-13 21:33:58 +00:00
|
|
|
}
|
|
|
|
}
|
2013-12-12 16:01:03 +00:00
|
|
|
|
2014-06-11 05:57:26 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::AddFootprintToBoard( FOOTPRINT* aFootprint )
|
2018-09-25 14:23:38 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
m_revertModule.reset( (FOOTPRINT*) aFootprint->Clone() );
|
2018-10-03 21:44:17 +00:00
|
|
|
|
2018-09-25 14:23:38 +00:00
|
|
|
m_footprintNameWhenLoaded = aFootprint->GetFPID().GetLibItemName();
|
|
|
|
|
2020-11-10 20:31:52 +00:00
|
|
|
PCB_BASE_EDIT_FRAME::AddFootprintToBoard( aFootprint );
|
2021-08-04 10:37:52 +00:00
|
|
|
// Ensure item UUIDs are valide
|
|
|
|
// ("old" footprints can have null uuids that create issues in fp editor)
|
|
|
|
aFootprint->FixUuids();
|
2019-09-04 16:18:42 +00:00
|
|
|
|
2020-08-21 22:44:43 +00:00
|
|
|
if( IsCurrentFPFromBoard() )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
|
|
|
|
aFootprint->GetReference() );
|
|
|
|
|
|
|
|
GetInfoBar()->RemoveAllButtons();
|
2021-04-01 10:17:02 +00:00
|
|
|
GetInfoBar()->AddCloseButton();
|
2020-08-21 22:44:43 +00:00
|
|
|
GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
|
|
|
|
}
|
|
|
|
|
2019-09-04 16:18:42 +00:00
|
|
|
UpdateMsgPanel();
|
2018-09-25 14:23:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
const wxChar* FOOTPRINT_EDIT_FRAME::GetFootprintEditorFrameName()
|
|
|
|
{
|
|
|
|
return FOOTPRINT_EDIT_FRAME_NAME;
|
|
|
|
}
|
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& FOOTPRINT_EDIT_FRAME::GetDesignSettings() const
|
|
|
|
{
|
2015-01-30 18:42:46 +00:00
|
|
|
return GetBoard()->GetDesignSettings();
|
2012-02-02 17:45:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
const PCB_PLOT_PARAMS& FOOTPRINT_EDIT_FRAME::GetPlotSettings() const
|
|
|
|
{
|
2020-06-18 13:49:32 +00:00
|
|
|
wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2020-06-18 13:49:32 +00:00
|
|
|
return PCB_BASE_FRAME::GetPlotSettings();
|
2012-04-05 18:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::SetPlotSettings( const PCB_PLOT_PARAMS& aSettings )
|
|
|
|
{
|
2020-06-18 13:49:32 +00:00
|
|
|
wxFAIL_MSG( "Plotting not supported in Footprint Editor" );
|
2012-04-05 18:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
FOOTPRINT_EDITOR_SETTINGS* FOOTPRINT_EDIT_FRAME::GetSettings()
|
2015-01-30 18:42:46 +00:00
|
|
|
{
|
2021-07-29 15:02:25 +00:00
|
|
|
if( !m_editorSettings )
|
|
|
|
m_editorSettings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
2015-01-30 18:42:46 +00:00
|
|
|
|
2021-07-29 15:02:25 +00:00
|
|
|
return m_editorSettings;
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-17 03:07:35 +00:00
|
|
|
APP_SETTINGS_BASE* FOOTPRINT_EDIT_FRAME::config() const
|
|
|
|
{
|
2021-07-29 15:02:25 +00:00
|
|
|
return m_editorSettings ? m_editorSettings
|
|
|
|
: Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
2020-12-17 03:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|
|
|
{
|
|
|
|
// aCfg will be the PCBNEW_SETTINGS
|
2020-05-08 18:10:47 +00:00
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
PCB_BASE_FRAME::LoadSettings( cfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
GetDesignSettings() = cfg->m_DesignSettings;
|
2019-02-05 15:06:36 +00:00
|
|
|
|
2021-10-30 22:21:15 +00:00
|
|
|
m_displayOptions = cfg->m_Display;
|
|
|
|
m_show_layer_manager_tools = cfg->m_AuiPanels.show_layer_manager;
|
2020-12-06 12:12:48 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->GetFilter() = cfg->m_SelectionFilter;
|
2020-08-15 20:42:11 +00:00
|
|
|
m_selectionFilterPanel->SetCheckboxesFromFilter( cfg->m_SelectionFilter );
|
2015-01-30 18:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
2015-01-30 18:42:46 +00:00
|
|
|
{
|
2021-03-01 20:29:17 +00:00
|
|
|
GetGalDisplayOptions().m_axesEnabled = true;
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
// aCfg will be the PCBNEW_SETTINGS
|
2020-09-24 21:29:32 +00:00
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
PCB_BASE_FRAME::SaveSettings( cfg );
|
2017-09-10 14:21:56 +00:00
|
|
|
|
2020-09-30 03:29:58 +00:00
|
|
|
cfg->m_DesignSettings = GetDesignSettings();
|
2020-09-30 22:02:05 +00:00
|
|
|
cfg->m_Display = m_displayOptions;
|
2020-09-30 03:29:58 +00:00
|
|
|
cfg->m_LibWidth = m_treePane->GetSize().x;
|
2020-12-16 13:31:32 +00:00
|
|
|
cfg->m_SelectionFilter = GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->GetFilter();
|
2020-09-30 03:29:58 +00:00
|
|
|
cfg->m_LayerPresets = m_appearancePanel->GetUserLayerPresets();
|
|
|
|
cfg->m_ActiveLayerPreset = m_appearancePanel->GetActiveLayerPreset();
|
2020-09-24 21:29:32 +00:00
|
|
|
|
2021-10-30 22:21:15 +00:00
|
|
|
cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
|
|
|
|
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
|
|
|
|
cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
|
2020-05-06 01:45:48 +00:00
|
|
|
}
|
2019-02-05 15:06:36 +00:00
|
|
|
|
2020-05-06 01:45:48 +00:00
|
|
|
|
2022-01-20 09:43:40 +00:00
|
|
|
|
|
|
|
EDA_ANGLE FOOTPRINT_EDIT_FRAME::GetRotationAngle() const
|
|
|
|
{
|
2022-01-20 12:37:42 +00:00
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = const_cast<FOOTPRINT_EDIT_FRAME*>( this )->GetSettings();
|
2022-01-20 09:43:40 +00:00
|
|
|
|
|
|
|
return cfg ? cfg->m_RotationAngle : ANGLE_90;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
COLOR_SETTINGS* FOOTPRINT_EDIT_FRAME::GetColorSettings( bool aForceRefresh ) const
|
2020-05-06 01:45:48 +00:00
|
|
|
{
|
2020-12-19 00:19:47 +00:00
|
|
|
wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
|
|
|
|
return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
|
2015-01-30 18:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-22 18:27:05 +00:00
|
|
|
MAGNETIC_SETTINGS* FOOTPRINT_EDIT_FRAME::GetMagneticItemsSettings()
|
|
|
|
{
|
|
|
|
// Get the actual frame settings for magnetic items
|
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
|
|
|
|
wxCHECK( cfg, nullptr );
|
|
|
|
return &cfg->m_MagneticItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-25 07:31:56 +00:00
|
|
|
const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
|
2018-02-13 21:19:41 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
|
2018-02-13 21:19:41 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
if( footprint )
|
2020-05-10 23:15:01 +00:00
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
bool hasGraphicalItem = footprint->Pads().size() || footprint->Zones().size();
|
2020-05-10 23:15:01 +00:00
|
|
|
|
|
|
|
if( !hasGraphicalItem )
|
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
for( const BOARD_ITEM* item : footprint->GraphicalItems() )
|
2020-05-10 23:15:01 +00:00
|
|
|
{
|
2020-10-04 14:19:33 +00:00
|
|
|
if( item->Type() == PCB_FP_TEXT_T )
|
2020-05-10 23:15:01 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
hasGraphicalItem = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hasGraphicalItem )
|
|
|
|
{
|
2021-02-26 13:49:40 +00:00
|
|
|
return footprint->GetBoundingBox( false, false );
|
2020-05-10 23:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
|
|
|
|
newFootprintBB.Inflate( Millimeter2iu( 12 ) );
|
|
|
|
return newFootprintBB;
|
2020-05-10 23:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetBoardBoundingBox( false );
|
2018-02-13 21:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-22 14:27:38 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::CanCloseFPFromBoard( bool doClose )
|
|
|
|
{
|
|
|
|
if( IsContentModified() )
|
|
|
|
{
|
|
|
|
wxString footprintName = GetBoard()->GetFirstFootprint()->GetReference();
|
|
|
|
wxString msg = _( "Save changes to '%s' before closing?" );
|
|
|
|
|
|
|
|
if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
|
|
|
|
[&]() -> bool
|
|
|
|
{
|
|
|
|
return SaveFootprint( GetBoard()->GetFirstFootprint() );
|
|
|
|
} ) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( doClose )
|
|
|
|
{
|
|
|
|
GetInfoBar()->ShowMessageFor( wxEmptyString, 1 );
|
|
|
|
Clear_Pcb( false );
|
|
|
|
UpdateTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-12-19 15:34:01 +00:00
|
|
|
if( IsContentModified() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2019-12-19 14:11:11 +00:00
|
|
|
// Shutdown blocks must be determined and vetoed as early as possible
|
2021-07-19 23:56:05 +00:00
|
|
|
if( KIPLATFORM::APP::SupportsShutdownBlockReason() &&
|
|
|
|
aEvent.GetId() == wxEVT_QUERY_END_SESSION )
|
2019-12-19 14:11:11 +00:00
|
|
|
{
|
|
|
|
aEvent.Veto();
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2019-12-19 14:11:11 +00:00
|
|
|
}
|
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
|
2021-12-22 14:27:38 +00:00
|
|
|
|
|
|
|
if( IsCurrentFPFromBoard() )
|
|
|
|
footprintName = GetBoard()->GetFirstFootprint()->GetReference();
|
|
|
|
|
2021-06-27 13:24:02 +00:00
|
|
|
wxString msg = _( "Save changes to '%s' before closing?" );
|
2019-06-17 15:59:39 +00:00
|
|
|
|
|
|
|
if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
|
2020-08-09 11:28:59 +00:00
|
|
|
[&]() -> bool
|
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
return SaveFootprint( GetBoard()->GetFirstFootprint() );
|
2020-08-09 11:28:59 +00:00
|
|
|
} ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2019-12-19 14:11:11 +00:00
|
|
|
aEvent.Veto();
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-17 11:21:06 +00:00
|
|
|
return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
|
2020-08-24 02:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::doCloseWindow()
|
|
|
|
{
|
|
|
|
// No more vetos
|
2021-07-19 23:56:05 +00:00
|
|
|
GetCanvas()->SetEventDispatcher( nullptr );
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->StopDrawing();
|
2018-08-28 19:33:33 +00:00
|
|
|
|
2018-10-03 07:46:17 +00:00
|
|
|
// Do not show the layer manager during closing to avoid flicker
|
|
|
|
// on some platforms (Windows) that generate useless redraw of items in
|
2021-06-09 19:32:58 +00:00
|
|
|
// the Layer Manager
|
2018-10-03 07:46:17 +00:00
|
|
|
m_auimgr.GetPane( "LayersManager" ).Show( false );
|
2020-08-15 20:42:11 +00:00
|
|
|
m_auimgr.GetPane( "SelectionFilter" ).Show( false );
|
2018-10-03 07:46:17 +00:00
|
|
|
|
2018-08-28 19:33:33 +00:00
|
|
|
Clear_Pcb( false );
|
2020-12-17 03:07:35 +00:00
|
|
|
|
2020-12-19 03:56:01 +00:00
|
|
|
SETTINGS_MANAGER* mgr = GetSettingsManager();
|
|
|
|
|
|
|
|
if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
|
|
|
|
{
|
|
|
|
GFootprintList.WriteCacheToFile( Prj().GetProjectPath() + "fp-info-cache" );
|
|
|
|
}
|
|
|
|
|
|
|
|
mgr->FlushAndRelease( GetSettings() );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-25 04:44:34 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
Kiway().OnKiCadExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-10 20:31:52 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::CloseFootprintEditor( wxCommandEvent& Event )
|
2010-07-29 20:00:24 +00:00
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2020-11-10 20:31:52 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2019-09-05 22:00:47 +00:00
|
|
|
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != nullptr );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-10 20:31:52 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateSaveFootprintToBoard( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2019-09-05 22:00:47 +00:00
|
|
|
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
|
2010-07-29 20:00:24 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
|
|
|
|
bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
// If the source was deleted, the footprint can inserted but not updated in the board.
|
|
|
|
if( frame && editorFootprint && editorFootprint->GetLink() != niluuid )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-27 11:00:21 +00:00
|
|
|
BOARD* mainpcb = frame->GetBoard();
|
2019-05-31 00:15:57 +00:00
|
|
|
canInsert = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
// search if the source footprint was not deleted:
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* candidate : mainpcb->Footprints() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
if( editorFootprint->GetLink() == candidate->m_Uuid )
|
2019-05-31 00:15:57 +00:00
|
|
|
{
|
|
|
|
canInsert = false;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2019-05-31 00:15:57 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
aEvent.Enable( canInsert );
|
|
|
|
}
|
2010-07-29 20:00:24 +00:00
|
|
|
|
|
|
|
|
2018-08-04 11:59:04 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::ShowChangedLanguage()
|
|
|
|
{
|
|
|
|
// call my base class
|
|
|
|
PCB_BASE_EDIT_FRAME::ShowChangedLanguage();
|
|
|
|
|
2018-08-11 09:26:47 +00:00
|
|
|
// We have 2 panes to update.
|
|
|
|
// 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();
|
2018-08-11 16:04:46 +00:00
|
|
|
tree_pane_info.Caption( _( "Libraries" ) );
|
2018-08-11 09:26:47 +00:00
|
|
|
|
2020-09-30 03:29:58 +00:00
|
|
|
wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
|
2018-08-11 09:26:47 +00:00
|
|
|
bool lm_shown = lm_pane_info.IsShown();
|
2020-09-30 03:29:58 +00:00
|
|
|
lm_pane_info.Caption( _( "Appearance" ) );
|
2018-08-04 11:59:04 +00:00
|
|
|
|
2018-08-11 11:16:41 +00:00
|
|
|
// update the layer manager
|
2020-09-30 03:29:58 +00:00
|
|
|
m_appearancePanel->OnBoardChanged();
|
2018-08-11 11:16:41 +00:00
|
|
|
UpdateUserInterface();
|
2018-08-11 09:26:47 +00:00
|
|
|
|
|
|
|
// Now restore the visibility:
|
|
|
|
lm_pane_info.Show( lm_shown );
|
|
|
|
tree_pane_info.Show( tree_shown );
|
|
|
|
m_auimgr.Update();
|
2018-08-04 11:59:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnModify()
|
2010-05-01 12:46:33 +00:00
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME::OnModify();
|
2021-04-09 02:09:06 +00:00
|
|
|
Update3DView( true, true );
|
2019-11-26 21:38:57 +00:00
|
|
|
m_treePane->GetLibTree()->RefreshLibTree();
|
2021-02-19 21:58:22 +00:00
|
|
|
|
|
|
|
if( !GetTitle().StartsWith( "*" ) )
|
2021-02-20 14:36:28 +00:00
|
|
|
UpdateTitle();
|
2015-12-22 11:58:26 +00:00
|
|
|
}
|
2011-08-08 15:44:43 +00:00
|
|
|
|
|
|
|
|
2021-02-20 14:36:28 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::UpdateTitle()
|
2011-08-08 15:44:43 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
wxString title;
|
|
|
|
LIB_ID fpid = GetLoadedFPID();
|
|
|
|
FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
|
|
|
|
bool writable = true;
|
2013-11-19 17:24:45 +00:00
|
|
|
|
2018-10-05 12:55:34 +00:00
|
|
|
if( IsCurrentFPFromBoard() )
|
|
|
|
{
|
2021-06-20 21:46:41 +00:00
|
|
|
if( IsContentModified() )
|
|
|
|
title = wxT( "*" );
|
|
|
|
|
|
|
|
title += footprint->GetReference();
|
|
|
|
title += wxS( " " ) + wxString::Format( _( "[from %s]" ),
|
|
|
|
Prj().GetProjectName() + "." + PcbFileExtension );
|
2018-10-05 12:55:34 +00:00
|
|
|
}
|
|
|
|
else if( fpid.IsValid() )
|
2013-11-19 17:24:45 +00:00
|
|
|
{
|
2018-07-29 15:33:58 +00:00
|
|
|
try
|
2013-11-19 17:24:45 +00:00
|
|
|
{
|
2018-07-29 15:33:58 +00:00
|
|
|
writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& )
|
|
|
|
{
|
|
|
|
// best efforts...
|
2013-11-19 17:24:45 +00:00
|
|
|
}
|
2016-08-19 07:45:59 +00:00
|
|
|
|
2018-09-13 23:39:40 +00:00
|
|
|
// Note: don't used GetLoadedFPID(); footprint name may have been edited
|
2021-06-20 21:46:41 +00:00
|
|
|
if( IsContentModified() )
|
|
|
|
title = wxT( "*" );
|
|
|
|
|
|
|
|
title += FROM_UTF8( footprint->GetFPID().Format().c_str() );
|
|
|
|
|
|
|
|
if( !writable )
|
|
|
|
title += wxS( " " ) + _( "[Read Only]" );
|
2013-11-19 17:24:45 +00:00
|
|
|
}
|
2018-07-29 15:33:58 +00:00
|
|
|
else if( !fpid.GetLibItemName().empty() )
|
|
|
|
{
|
2018-09-13 23:39:40 +00:00
|
|
|
// Note: don't used GetLoadedFPID(); footprint name may have been edited
|
2021-06-20 21:46:41 +00:00
|
|
|
if( IsContentModified() )
|
|
|
|
title = wxT( "*" );
|
|
|
|
|
|
|
|
title += FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() );
|
|
|
|
title += wxS( " " ) + _( "[Unsaved]" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
title = _( "[no footprint loaded]" );
|
2018-07-29 15:33:58 +00:00
|
|
|
}
|
2013-11-19 17:24:45 +00:00
|
|
|
|
2021-06-20 21:46:41 +00:00
|
|
|
title += wxT( " \u2014 " ) + _( "Footprint Editor" );
|
2020-04-13 20:02:35 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
SetTitle( title );
|
2011-08-08 15:44:43 +00:00
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
|
2018-08-11 11:16:41 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::UpdateUserInterface()
|
|
|
|
{
|
2020-09-30 03:29:58 +00:00
|
|
|
m_appearancePanel->OnBoardChanged();
|
2018-08-11 11:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-10 20:11:53 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::UpdateView()
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
GetCanvas()->UpdateColors();
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->DisplayBoard( GetBoard() );
|
2014-07-09 11:50:27 +00:00
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2021-02-20 14:36:28 +00:00
|
|
|
UpdateTitle();
|
2014-07-09 11:50:27 +00:00
|
|
|
}
|
2015-01-07 19:07:15 +00:00
|
|
|
|
|
|
|
|
2018-07-29 15:33:58 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::initLibraryTree()
|
|
|
|
{
|
|
|
|
FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
|
|
|
|
|
|
|
|
WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
|
2021-05-14 21:23:40 +00:00
|
|
|
|
2020-12-19 02:56:36 +00:00
|
|
|
if( GFootprintList.GetCount() == 0 )
|
|
|
|
GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + "fp-info-cache" );
|
2021-05-14 21:23:40 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
|
2018-07-29 15:33:58 +00:00
|
|
|
progressReporter.Show( false );
|
|
|
|
|
|
|
|
if( GFootprintList.GetErrorCount() )
|
|
|
|
GFootprintList.DisplayErrors( this );
|
|
|
|
|
|
|
|
m_adapter = FP_TREE_SYNCHRONIZING_ADAPTER::Create( this, fpTable );
|
|
|
|
auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
|
|
|
|
|
|
|
|
adapter->AddLibraries();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-06 18:33:28 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::SyncLibraryTree( bool aProgress )
|
2018-07-29 15:33:58 +00:00
|
|
|
{
|
|
|
|
FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
|
|
|
|
auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
|
2019-06-03 23:50:44 +00:00
|
|
|
LIB_ID target = GetTargetFPID();
|
2018-07-29 15:33:58 +00:00
|
|
|
bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
|
|
|
|
|
|
|
|
// Sync FOOTPRINT_INFO list to the libraries on disk
|
|
|
|
if( aProgress )
|
|
|
|
{
|
|
|
|
WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
|
2021-07-19 23:56:05 +00:00
|
|
|
GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
|
2018-07-29 15:33:58 +00:00
|
|
|
progressReporter.Show( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
GFootprintList.ReadFootprintFiles( fpTable, nullptr, nullptr );
|
2018-07-29 15:33:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sync the LIB_TREE to the FOOTPRINT_INFO list
|
|
|
|
adapter->Sync();
|
|
|
|
|
|
|
|
m_treePane->GetLibTree()->Unselect();
|
2020-02-07 17:06:24 +00:00
|
|
|
m_treePane->GetLibTree()->Regenerate( true );
|
2018-07-29 15:33:58 +00:00
|
|
|
|
|
|
|
if( target.IsValid() )
|
|
|
|
{
|
|
|
|
if( adapter->FindItem( target ) )
|
|
|
|
{
|
|
|
|
if( targetSelected )
|
|
|
|
m_treePane->GetLibTree()->SelectLibId( target );
|
|
|
|
else
|
|
|
|
m_treePane->GetLibTree()->CenterLibId( target );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Try to focus on parent
|
|
|
|
target.SetLibItemName( wxEmptyString );
|
|
|
|
m_treePane->GetLibTree()->CenterLibId( target );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-07 17:06:24 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::RegenerateLibraryTree()
|
|
|
|
{
|
|
|
|
LIB_ID target = GetTargetFPID();
|
|
|
|
|
|
|
|
m_treePane->GetLibTree()->Regenerate( true );
|
|
|
|
|
|
|
|
if( target.IsValid() )
|
|
|
|
m_treePane->GetLibTree()->CenterLibId( target );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-10 20:11:53 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::RefreshLibraryTree()
|
|
|
|
{
|
|
|
|
m_treePane->GetLibTree()->RefreshLibTree();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-06 11:45:28 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::FocusOnLibID( const LIB_ID& aLibID )
|
2019-06-02 20:07:57 +00:00
|
|
|
{
|
2019-06-06 11:45:28 +00:00
|
|
|
m_treePane->GetLibTree()->SelectLibId( aLibID );
|
2019-06-02 20:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-19 19:45:50 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnDisplayOptionsChanged()
|
|
|
|
{
|
|
|
|
m_appearancePanel->UpdateDisplayOptions();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 16:39:05 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::setupTools()
|
|
|
|
{
|
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
2019-06-13 17:28:55 +00:00
|
|
|
m_toolManager->SetEnvironment( GetBoard(), GetCanvas()->GetView(),
|
2020-06-12 10:58:56 +00:00
|
|
|
GetCanvas()->GetViewControls(), config(), this );
|
2017-02-21 12:42:08 +00:00
|
|
|
m_actions = new PCB_ACTIONS();
|
2021-03-27 20:02:34 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
2015-05-19 16:39:05 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
|
2015-05-19 16:39:05 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
2017-02-23 14:02:18 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
2020-12-16 13:31:32 +00:00
|
|
|
m_toolManager->RegisterTool( new PCB_SELECTION_TOOL );
|
2016-06-08 11:19:53 +00:00
|
|
|
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
2015-05-19 16:39:05 +00:00
|
|
|
m_toolManager->RegisterTool( new EDIT_TOOL );
|
2017-01-21 21:06:18 +00:00
|
|
|
m_toolManager->RegisterTool( new PAD_TOOL );
|
2015-05-19 16:39:05 +00:00
|
|
|
m_toolManager->RegisterTool( new DRAWING_TOOL );
|
2021-01-16 23:17:32 +00:00
|
|
|
m_toolManager->RegisterTool( new PCB_POINT_EDITOR );
|
2020-12-16 13:31:32 +00:00
|
|
|
m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
|
2020-12-25 16:26:32 +00:00
|
|
|
m_toolManager->RegisterTool( new FOOTPRINT_EDITOR_CONTROL );
|
2017-04-18 15:32:05 +00:00
|
|
|
m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
|
2020-12-16 13:31:32 +00:00
|
|
|
m_toolManager->RegisterTool( new PCB_PICKER_TOOL );
|
2018-06-26 18:03:57 +00:00
|
|
|
m_toolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
|
2020-05-22 18:27:05 +00:00
|
|
|
m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
|
2020-10-03 11:16:29 +00:00
|
|
|
m_toolManager->RegisterTool( new GROUP_TOOL );
|
2020-10-02 22:42:32 +00:00
|
|
|
m_toolManager->RegisterTool( new CONVERT_TOOL );
|
2021-03-19 23:06:29 +00:00
|
|
|
m_toolManager->RegisterTool( new SCRIPTING_TOOL );
|
2015-05-19 16:39:05 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
m_toolManager->GetTool<PCB_SELECTION_TOOL>()->SetIsFootprintEditor( true );
|
2020-11-07 17:50:22 +00:00
|
|
|
m_toolManager->GetTool<EDIT_TOOL>()->SetIsFootprintEditor( true );
|
|
|
|
m_toolManager->GetTool<PAD_TOOL>()->SetIsFootprintEditor( true );
|
|
|
|
m_toolManager->GetTool<DRAWING_TOOL>()->SetIsFootprintEditor( true );
|
2021-01-16 23:17:32 +00:00
|
|
|
m_toolManager->GetTool<PCB_POINT_EDITOR>()->SetIsFootprintEditor( true );
|
2020-12-16 13:31:32 +00:00
|
|
|
m_toolManager->GetTool<PCB_CONTROL>()->SetIsFootprintEditor( true );
|
|
|
|
m_toolManager->GetTool<PCB_PICKER_TOOL>()->SetIsFootprintEditor( true );
|
2020-11-07 17:50:22 +00:00
|
|
|
m_toolManager->GetTool<POSITION_RELATIVE_TOOL>()->SetIsFootprintEditor( true );
|
|
|
|
m_toolManager->GetTool<GROUP_TOOL>()->SetIsFootprintEditor( true );
|
2021-03-19 23:06:29 +00:00
|
|
|
m_toolManager->GetTool<SCRIPTING_TOOL>()->SetIsFootprintEditor( true );
|
2015-05-19 16:39:05 +00:00
|
|
|
|
2020-05-22 18:27:05 +00:00
|
|
|
m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
|
2017-02-09 00:54:32 +00:00
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
2015-05-19 16:39:05 +00:00
|
|
|
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-13 23:09:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::setupUIConditions()
|
|
|
|
{
|
|
|
|
PCB_BASE_EDIT_FRAME::setupUIConditions();
|
|
|
|
|
|
|
|
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
|
|
|
PCB_EDITOR_CONDITIONS cond( this );
|
|
|
|
|
|
|
|
wxASSERT( mgr );
|
|
|
|
|
|
|
|
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
|
|
|
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
|
|
|
|
|
|
|
auto haveFootprintCond =
|
2020-11-08 21:29:04 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return GetBoard()->GetFirstFootprint() != nullptr;
|
|
|
|
};
|
2020-08-13 23:09:17 +00:00
|
|
|
|
|
|
|
auto footprintTargettedCond =
|
2021-10-30 22:21:15 +00:00
|
|
|
[this]( const SELECTION& )
|
2020-11-08 21:29:04 +00:00
|
|
|
{
|
|
|
|
return !GetTargetFPID().GetLibItemName().empty();
|
|
|
|
};
|
2020-08-13 23:09:17 +00:00
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
|
|
|
|
mgr->SetConditions( ACTIONS::revert, ENABLE( cond.ContentModified() ) );
|
2021-02-18 15:49:35 +00:00
|
|
|
mgr->SetConditions( ACTIONS::save, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
2020-08-13 23:09:17 +00:00
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
|
2020-10-03 23:34:23 +00:00
|
|
|
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 ) ) );
|
2020-08-13 23:09:17 +00:00
|
|
|
|
2021-02-18 00:07:28 +00:00
|
|
|
mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
|
2021-05-31 01:25:42 +00:00
|
|
|
mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle && cond.NoActiveTool() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::pasteSpecial, ENABLE( SELECTION_CONDITIONS::Idle && cond.NoActiveTool() ) );
|
2021-02-18 00:07:28 +00:00
|
|
|
mgr->SetConditions( ACTIONS::doDelete, ENABLE( cond.HasItems() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::duplicate, ENABLE( cond.HasItems() ) );
|
2020-08-27 00:19:32 +00:00
|
|
|
mgr->SetConditions( ACTIONS::selectAll, ENABLE( cond.HasItems() ) );
|
2021-02-18 00:07:28 +00:00
|
|
|
|
2021-09-17 21:21:05 +00:00
|
|
|
auto haveAtLeastOneGroupCond =
|
|
|
|
[]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
for( EDA_ITEM* item : aSel )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_GROUP_T )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2021-02-18 00:07:28 +00:00
|
|
|
mgr->SetConditions( PCB_ACTIONS::rotateCw, ENABLE( cond.HasItems() ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::rotateCcw, ENABLE( cond.HasItems() ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::mirror, ENABLE( cond.HasItems() ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::group, ENABLE( SELECTION_CONDITIONS::MoreThan( 1 ) ) );
|
2021-09-17 21:21:05 +00:00
|
|
|
mgr->SetConditions( PCB_ACTIONS::ungroup, ENABLE( haveAtLeastOneGroupCond ) );
|
2020-08-13 23:09:17 +00:00
|
|
|
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( !cond.TextFillDisplay() ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( !cond.GraphicsFillDisplay() ) );
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
|
|
|
|
|
|
|
auto highContrastCond =
|
2021-10-30 22:21:15 +00:00
|
|
|
[this]( const SELECTION& )
|
2020-11-08 21:29:04 +00:00
|
|
|
{
|
|
|
|
return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
|
|
|
|
};
|
2020-08-13 23:09:17 +00:00
|
|
|
|
2021-02-10 21:53:55 +00:00
|
|
|
auto boardFlippedCond =
|
2021-05-21 16:52:11 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return GetCanvas()->GetView()->IsMirroredX();
|
|
|
|
};
|
2021-02-10 21:53:55 +00:00
|
|
|
|
2020-08-13 23:09:17 +00:00
|
|
|
auto footprintTreeCond =
|
2021-10-30 22:21:15 +00:00
|
|
|
[this](const SELECTION& )
|
2020-11-08 21:29:04 +00:00
|
|
|
{
|
|
|
|
return IsSearchTreeShown();
|
|
|
|
};
|
2020-08-13 23:09:17 +00:00
|
|
|
|
2021-10-30 22:21:15 +00:00
|
|
|
auto layerManagerCond =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_auimgr.GetPane( "LayersManager" ).IsShown();
|
|
|
|
};
|
|
|
|
|
2021-03-27 19:04:16 +00:00
|
|
|
mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
|
2022-01-17 11:55:55 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) );
|
|
|
|
|
2021-03-29 11:01:03 +00:00
|
|
|
mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) );
|
2021-10-30 22:21:15 +00:00
|
|
|
mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
|
2020-08-13 23:09:17 +00:00
|
|
|
|
2021-03-27 19:04:16 +00:00
|
|
|
mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
|
2021-11-20 22:05:57 +00:00
|
|
|
mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) );
|
|
|
|
|
2021-03-27 19:04:16 +00:00
|
|
|
mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
|
2021-11-20 22:05:57 +00:00
|
|
|
mgr->SetConditions( PCB_ACTIONS::editTextAndGraphics, ENABLE( haveFootprintCond ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::checkFootprint, ENABLE( haveFootprintCond ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::repairFootprint, ENABLE( haveFootprintCond ) );
|
2021-03-27 19:04:16 +00:00
|
|
|
mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
|
2020-08-13 23:09:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Only enable a tool if the part is edtable
|
|
|
|
#define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
|
|
|
|
ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
|
|
|
|
|
|
|
|
CURRENT_EDIT_TOOL( ACTIONS::deleteTool );
|
|
|
|
CURRENT_EDIT_TOOL( ACTIONS::measureTool );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::placePad );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawLine );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawRectangle );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawCircle );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawArc );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawPolygon );
|
2020-09-21 23:32:07 +00:00
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawRuleArea );
|
2020-08-13 23:09:17 +00:00
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeText );
|
2022-01-30 10:52:52 +00:00
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawTextBox );
|
2021-12-04 23:52:00 +00:00
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawAlignedDimension );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawOrthogonalDimension );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawCenterDimension );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawRadialDimension );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawLeader );
|
2020-08-13 23:09:17 +00:00
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::setAnchor );
|
|
|
|
CURRENT_EDIT_TOOL( PCB_ACTIONS::gridSetOrigin );
|
|
|
|
|
|
|
|
#undef CURRENT_EDIT_TOOL
|
|
|
|
#undef ENABLE
|
|
|
|
#undef CHECK
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-30 12:25:08 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::ActivateGalCanvas()
|
2015-05-19 16:39:05 +00:00
|
|
|
{
|
2019-05-30 12:25:08 +00:00
|
|
|
PCB_BASE_EDIT_FRAME::ActivateGalCanvas();
|
2015-05-19 16:39:05 +00:00
|
|
|
|
2019-11-11 22:55:06 +00:00
|
|
|
// Be sure the axis are enabled
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
2019-11-11 22:55:06 +00:00
|
|
|
|
2020-11-10 20:11:53 +00:00
|
|
|
UpdateView();
|
2017-09-29 08:58:05 +00:00
|
|
|
|
2018-08-11 11:16:41 +00:00
|
|
|
// Ensure the m_Layers settings are using the canvas type:
|
|
|
|
UpdateUserInterface();
|
2015-05-19 16:39:05 +00:00
|
|
|
}
|
2018-01-08 04:05:03 +00:00
|
|
|
|
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2018-01-08 04:05:03 +00:00
|
|
|
{
|
2020-07-17 20:04:14 +00:00
|
|
|
PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2019-06-24 09:22:49 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
auto cfg = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
|
|
|
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
|
|
|
|
|
2020-09-20 23:11:44 +00:00
|
|
|
GetCanvas()->GetView()->UpdateAllLayersColor();
|
2021-08-29 23:33:08 +00:00
|
|
|
GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
2020-09-20 23:11:44 +00:00
|
|
|
GetCanvas()->ForceRefresh();
|
|
|
|
|
|
|
|
UpdateUserInterface();
|
|
|
|
|
2019-06-24 09:22:49 +00:00
|
|
|
if( aEnvVarsChanged )
|
|
|
|
SyncLibraryTree( true );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
Layout();
|
|
|
|
SendSizeEvent();
|
2018-01-08 04:05:03 +00:00
|
|
|
}
|
2018-02-19 19:26:02 +00:00
|
|
|
|
|
|
|
|
2018-11-09 13:32:13 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxString fullFileName;
|
|
|
|
|
|
|
|
LIB_ID id = GetLoadedFPID();
|
|
|
|
|
|
|
|
if( id.empty() )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "No footprint selected." ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxFileName fn( id.GetLibItemName() );
|
|
|
|
fn.SetExt( "png" );
|
|
|
|
|
|
|
|
wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
|
|
|
|
fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// calling wxYield is mandatory under Linux, after closing the file selector dialog
|
|
|
|
// to refresh the screen before creating the PNG or JPEG image from screen
|
|
|
|
wxYield();
|
2019-06-16 16:07:15 +00:00
|
|
|
SaveCanvasImageToFile( this, dlg.GetPath() );
|
2018-11-09 13:32:13 +00:00
|
|
|
}
|