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>
|
2018-01-08 04:05:03 +00:00
|
|
|
* Copyright (C) 1992-2018 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
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file moduleframe.cpp
|
|
|
|
* @brief Footprint (module) editor main window.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2018-01-08 04:05:03 +00:00
|
|
|
#include <kiface_i.h>
|
2014-05-06 04:58:33 +00:00
|
|
|
#include <kiway.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <project.h>
|
2014-06-11 05:18:41 +00:00
|
|
|
#include <kicad_plugin.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
2014-07-09 09:22:43 +00:00
|
|
|
#include <pcb_draw_panel_gal.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_helpers.h>
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <3d_viewer/eda_3d_viewer.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2013-10-13 16:29:20 +00:00
|
|
|
#include <fp_lib_table.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2017-03-08 09:35:51 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2018-08-11 16:04:46 +00:00
|
|
|
#include <eda_dockart.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <hotkeys.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2018-01-31 12:37:36 +00:00
|
|
|
#include <footprint_viewer_frame.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2018-01-31 08:23:20 +00:00
|
|
|
#include <pcb_layer_widget.h>
|
2015-01-30 18:42:46 +00:00
|
|
|
#include <invoke_pcb_dialog.h>
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2017-02-23 14:02:18 +00:00
|
|
|
#include <tool/common_tools.h>
|
2014-07-09 09:22:43 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
2017-08-31 02:35:30 +00:00
|
|
|
#include <tool/zoom_tool.h>
|
2017-02-23 14:02:18 +00:00
|
|
|
|
2018-07-29 15:33:58 +00:00
|
|
|
#include <footprint_tree_pane.h>
|
|
|
|
#include <widgets/lib_tree.h>
|
|
|
|
#include <fp_lib_table.h>
|
|
|
|
#include <footprint_info_impl.h>
|
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
#include <widgets/paged_dialog.h>
|
|
|
|
#include <dialogs/panel_modedit_settings.h>
|
|
|
|
#include <dialogs/panel_modedit_defaults.h>
|
|
|
|
#include <dialogs/panel_modedit_display_options.h>
|
|
|
|
#include <dialog_configure_paths.h>
|
|
|
|
|
2018-06-22 13:05:11 +00:00
|
|
|
#include <tools/position_relative_tool.h>
|
2018-07-29 15:33:58 +00:00
|
|
|
#include <widgets/progress_reporter.h>
|
2014-07-09 09:22:43 +00:00
|
|
|
#include "tools/selection_tool.h"
|
|
|
|
#include "tools/edit_tool.h"
|
|
|
|
#include "tools/drawing_tool.h"
|
|
|
|
#include "tools/point_editor.h"
|
|
|
|
#include "tools/pcbnew_control.h"
|
2018-02-16 19:26:55 +00:00
|
|
|
#include "tools/footprint_editor_tools.h"
|
2014-07-09 12:23:13 +00:00
|
|
|
#include "tools/placement_tool.h"
|
2015-06-18 15:51:51 +00:00
|
|
|
#include "tools/picker_tool.h"
|
2017-01-21 21:06:18 +00:00
|
|
|
#include "tools/pad_tool.h"
|
2017-02-21 12:42:08 +00:00
|
|
|
#include "tools/pcb_actions.h"
|
2014-07-09 09:22:43 +00:00
|
|
|
|
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 )
|
2011-02-21 13:54:29 +00:00
|
|
|
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END,
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME::ProcessItemSelection )
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_CLOSE( FOOTPRINT_EDIT_FRAME::OnCloseWindow )
|
|
|
|
EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::CloseModuleEditor )
|
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
|
|
|
|
2015-07-02 09:50:38 +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
|
|
|
|
2018-07-29 15:33:58 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_SAVE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_SAVE_AS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2018-10-03 21:44:17 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_REVERT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2012-02-09 20:33:38 +00:00
|
|
|
EVT_TOOL( ID_OPEN_MODULE_VIEWER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
|
2018-10-03 21:44:17 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_CUT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_COPY_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_PASTE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_NEW_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2012-05-09 17:37:25 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2018-07-26 20:19:46 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2018-10-03 21:44:17 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_ADD_LIBRARY, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2014-07-09 13:02:56 +00:00
|
|
|
EVT_TOOL( ID_GEN_IMPORT_DXF_FILE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_TOOL( wxID_PRINT, FOOTPRINT_EDIT_FRAME::ToPrinter )
|
2018-07-29 15:33:58 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_EDIT_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_PAD_SETTINGS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard )
|
|
|
|
EVT_TOOL( ID_MODEDIT_INSERT_MODULE_IN_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_EDIT_MODULE_PROPERTIES, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2014-07-09 11:50:27 +00:00
|
|
|
EVT_TOOL( wxID_UNDO, FOOTPRINT_EDIT_FRAME::RestoreCopyFromUndoList )
|
|
|
|
EVT_TOOL( wxID_REDO, FOOTPRINT_EDIT_FRAME::RestoreCopyFromRedoList )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
// Vertical tool bar button click event handler.
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_TOOL( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
|
2016-06-08 11:19:53 +00:00
|
|
|
EVT_TOOL( ID_ZOOM_SELECTION, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
|
2017-03-09 09:09:13 +00:00
|
|
|
EVT_TOOL_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2018-02-18 14:21:23 +00:00
|
|
|
// Options Toolbar
|
|
|
|
// ID_TB_OPTIONS_SHOW_PADS_SKETCH id is managed in PCB_BASE_FRAME
|
|
|
|
// ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH id is managed in PCB_BASE_FRAME
|
|
|
|
// ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH id is managed in PCB_BASE_FRAME
|
2015-01-10 10:27:49 +00:00
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2015-03-30 16:42:39 +00:00
|
|
|
// Preferences and option menus
|
2015-01-30 18:42:46 +00:00
|
|
|
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
|
|
|
|
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
|
|
|
EVT_MENU( ID_PCB_LIB_TABLE_EDIT,
|
|
|
|
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
|
|
|
EVT_MENU( wxID_PREFERENCES,
|
|
|
|
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
2015-03-29 21:22:53 +00:00
|
|
|
EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, FOOTPRINT_EDIT_FRAME::OnConfigurePaths )
|
2015-01-30 18:42:46 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
// popup commands
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2013-01-19 12:58:54 +00:00
|
|
|
EVT_MENU( ID_POPUP_MODEDIT_EDIT_BODY_ITEM,
|
|
|
|
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2012-10-07 15:37:25 +00:00
|
|
|
EVT_MENU( ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE,
|
|
|
|
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_MENU( ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE,
|
|
|
|
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2012-02-12 19:39:37 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
// Module transformations
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_MENU( ID_MODEDIT_MODULE_ROTATE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_MENU( ID_MODEDIT_MODULE_MIRROR, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2015-02-12 03:22:24 +00:00
|
|
|
EVT_MENU( ID_MODEDIT_MODULE_MOVE_EXACT, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2011-11-08 16:37:25 +00:00
|
|
|
EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2014-09-09 16:46:12 +00:00
|
|
|
// Menu Help
|
|
|
|
EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
|
|
|
|
EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
|
2016-09-24 00:44:52 +00:00
|
|
|
EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
|
2014-09-09 16:46:12 +00:00
|
|
|
EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
// Menu 3D Frame
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, FOOTPRINT_EDIT_FRAME::Show3D_Frame )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2015-05-19 16:39:05 +00:00
|
|
|
// Switching canvases
|
2018-08-11 11:16:41 +00:00
|
|
|
EVT_MENU( ID_MENU_CANVAS_LEGACY, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas )
|
|
|
|
EVT_MENU( ID_MENU_CANVAS_CAIRO, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas )
|
|
|
|
EVT_MENU( ID_MENU_CANVAS_OPENGL, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas )
|
2015-05-19 16:39:05 +00:00
|
|
|
|
2015-09-13 14:23:01 +00:00
|
|
|
// UI update events.
|
2018-08-27 23:24:31 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs )
|
2018-07-29 15:33:58 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_SAVE, FOOTPRINT_EDIT_FRAME::OnUpdateSave )
|
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_SAVE_AS, FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs )
|
2018-10-03 21:44:17 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_REVERT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateSave )
|
2018-07-29 15:33:58 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted )
|
2011-02-21 13:54:29 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard )
|
2011-02-21 13:54:29 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_INSERT_MODULE_IN_BOARD,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard )
|
2017-06-12 13:10:43 +00:00
|
|
|
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool )
|
|
|
|
EVT_UPDATE_UI( ID_ZOOM_SELECTION, FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool )
|
2015-01-30 18:42:46 +00:00
|
|
|
|
2017-03-09 09:09:13 +00:00
|
|
|
EVT_UPDATE_UI_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar )
|
2015-01-30 18:42:46 +00:00
|
|
|
|
2018-07-29 15:33:58 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_EDIT_MODULE_PROPERTIES, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
|
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_PAD_SETTINGS, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
|
|
|
|
|
2015-01-30 18:42:46 +00:00
|
|
|
// Option toolbar:
|
2015-01-10 10:27:49 +00:00
|
|
|
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
|
2015-01-30 18:42:46 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar )
|
|
|
|
|
2018-07-29 15:33:58 +00:00
|
|
|
EVT_UPDATE_UI( ID_GEN_IMPORT_DXF_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
END_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2018-08-03 19:41:57 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend ) :
|
2014-07-09 11:50:27 +00:00
|
|
|
PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
|
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
|
|
|
|
m_showAxis = true; // true to show X and Y axis on screen
|
|
|
|
m_showGridAxis = true; // show the grid origin axis
|
2018-02-14 22:07:59 +00:00
|
|
|
m_hotkeysDescrList = g_Module_Editor_Hotkeys_Descr;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// Give an icon
|
2011-09-09 19:30:59 +00:00
|
|
|
wxIcon icon;
|
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
|
|
|
|
SetIcon( icon );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
// Create GAL canvas
|
|
|
|
PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
|
2018-08-03 19:41:57 +00:00
|
|
|
GetGalDisplayOptions(), aBackend );
|
2014-07-09 09:22:43 +00:00
|
|
|
SetGalCanvas( drawPanel );
|
|
|
|
|
2014-06-11 05:00:30 +00:00
|
|
|
SetBoard( new BOARD() );
|
2015-01-10 10:27:49 +00:00
|
|
|
// In modedit, 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 );
|
|
|
|
|
|
|
|
// Don't show the default board solder mask clearance in the footprint editor. Only the
|
|
|
|
// footprint or pad clearance setting should be shown if it is not 0.
|
|
|
|
GetBoard()->GetDesignSettings().m_SolderMaskMargin = 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:
|
2015-01-07 19:07:15 +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
|
|
|
|
2017-10-05 18:11:55 +00:00
|
|
|
// However the "no net" mark on pads is useless, because there is
|
|
|
|
// no net in footprint editor: make it non visible
|
|
|
|
GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false );
|
|
|
|
|
2018-05-02 14:46:09 +00:00
|
|
|
m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), true );
|
2014-07-09 09:59:23 +00:00
|
|
|
|
2017-09-10 14:21:56 +00:00
|
|
|
// LoadSettings() *after* creating m_LayersManager, because LoadSettings()
|
|
|
|
// initialize parameters in m_LayersManager
|
2015-08-06 00:10:52 +00:00
|
|
|
LoadSettings( config() );
|
2018-02-19 00:04:03 +00:00
|
|
|
GetGalDisplayOptions().m_axesEnabled = true;
|
2017-09-10 14:21:56 +00:00
|
|
|
|
2014-06-11 05:00:30 +00:00
|
|
|
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
|
2015-08-06 00:10:52 +00:00
|
|
|
GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2018-02-24 11:24:00 +00:00
|
|
|
GetScreen()->AddGrid( m_UserGridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER );
|
2014-06-11 05:18:41 +00:00
|
|
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
2009-02-06 11:45:35 +00:00
|
|
|
|
2013-03-12 15:17:44 +00:00
|
|
|
// In modedit, set the default paper size to A4:
|
|
|
|
// this should be OK for all footprint to plot/print
|
2014-06-11 05:00:30 +00:00
|
|
|
SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
|
2013-03-12 15:17:44 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
2018-07-29 15:33:58 +00:00
|
|
|
|
|
|
|
initLibraryTree();
|
|
|
|
m_treePane = new FOOTPRINT_TREE_PANE( this );
|
|
|
|
|
2018-08-05 11:56:02 +00:00
|
|
|
// ReCreateMenuBar(); // UseGalCanvas() will do this for us.
|
2007-08-20 01:20:48 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
ReCreateOptToolbar();
|
|
|
|
|
2018-08-05 11:56:02 +00:00
|
|
|
m_Layers->ReFill();
|
|
|
|
m_Layers->ReFillRender();
|
|
|
|
|
|
|
|
GetScreen()->m_Active_Layer = F_SilkS;
|
|
|
|
m_Layers->SelectLayer( F_SilkS );
|
|
|
|
m_Layers->OnLayerSelected();
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetEnableBlockCommands( true );
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
// Horizontal items; 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) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
// Vertical items; 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(1)
|
|
|
|
.Caption( _( "Libraries" ) ).MinSize( 250, 400 ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
|
|
|
|
m_auimgr.AddPane( m_Layers, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
|
|
|
|
.Caption( _( "Layers Manager" ) ).PaneBorder( false )
|
|
|
|
.MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2018-08-11 20:47:18 +00:00
|
|
|
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
|
|
|
m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
|
2018-07-29 15:33:58 +00:00
|
|
|
|
2014-07-09 09:59:24 +00:00
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
2015-05-19 16:39:05 +00:00
|
|
|
setupTools();
|
2017-03-08 09:35:51 +00:00
|
|
|
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
|
2018-08-03 19:41:57 +00:00
|
|
|
UseGalCanvas( aBackend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2014-07-09 09:59:23 +00:00
|
|
|
m_auimgr.Update();
|
2018-07-26 20:19:46 +00:00
|
|
|
updateTitle();
|
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
|
|
|
|
2015-07-15 12:41:30 +00:00
|
|
|
Raise(); // On some window managers, this is needed
|
|
|
|
Show( true );
|
|
|
|
|
2015-03-06 17:46:04 +00:00
|
|
|
Zoom_Automatique( false );
|
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
|
|
|
{
|
2014-06-11 05:18:41 +00:00
|
|
|
// save the footprint in the PROJECT
|
|
|
|
retainLastFootprint();
|
2014-07-09 09:59:23 +00:00
|
|
|
|
|
|
|
delete m_Layers;
|
2012-02-02 17:45:37 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 17:24:45 +00:00
|
|
|
|
2018-08-11 11:16:41 +00:00
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
// switches currently used canvas (default / Cairo / OpenGL).
|
|
|
|
PCB_BASE_FRAME::OnSwitchCanvas( aEvent );
|
|
|
|
|
|
|
|
// The base class method *does not reinit* the layers manager.
|
|
|
|
// We must upate the layer widget to match board visibility states,
|
|
|
|
// both layers and render columns, and and some settings dependent on the canvas.
|
|
|
|
UpdateUserInterface();
|
|
|
|
}
|
|
|
|
|
2016-05-13 15:31:54 +00:00
|
|
|
BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const
|
|
|
|
{
|
|
|
|
return GetBoard()->m_Modules;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-13 23:39:40 +00:00
|
|
|
LIB_ID FOOTPRINT_EDIT_FRAME::getTargetFPID() const
|
2013-11-19 17:24:45 +00:00
|
|
|
{
|
2018-07-29 15:33:58 +00:00
|
|
|
LIB_ID id = m_treePane->GetLibTree()->GetSelectedLibId();
|
|
|
|
wxString nickname = id.GetLibNickname();
|
2014-06-11 05:18:41 +00:00
|
|
|
|
2018-07-29 15:33:58 +00:00
|
|
|
if( nickname.IsEmpty() )
|
2018-09-13 23:39:40 +00:00
|
|
|
return 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
|
|
|
{
|
2018-07-29 15:33:58 +00:00
|
|
|
MODULE* module = GetBoard()->m_Modules;
|
|
|
|
|
|
|
|
if( module )
|
2018-09-13 23:39:40 +00:00
|
|
|
return LIB_ID( module->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
|
|
|
|
|
|
|
|
2018-08-25 15:12:08 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::IsCurrentFPFromBoard() const
|
|
|
|
{
|
|
|
|
MODULE* module = GetBoard()->m_Modules;
|
|
|
|
|
|
|
|
return ( module && module->GetLink() > 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2018-03-09 01:31:30 +00:00
|
|
|
Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_NICKNAME, id.GetLibNickname() );
|
|
|
|
Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FPNAME, id.GetLibItemName() );
|
2013-10-13 21:33:58 +00:00
|
|
|
}
|
2014-06-11 05:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::restoreLastFootprint()
|
|
|
|
{
|
2018-03-09 01:31:30 +00:00
|
|
|
const wxString& curFootprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FPNAME );
|
|
|
|
const wxString& curNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_NICKNAME );
|
2014-06-11 05:18:41 +00:00
|
|
|
|
2018-03-09 01:31:30 +00:00
|
|
|
if( curNickname.Length() && curFootprintName.Length() )
|
2013-10-13 21:33:58 +00:00
|
|
|
{
|
2018-03-09 01:31:30 +00:00
|
|
|
LIB_ID id;
|
|
|
|
id.SetLibNickname( curNickname );
|
|
|
|
id.SetLibItemName( curFootprintName );
|
2014-06-11 05:18:41 +00:00
|
|
|
|
2018-03-09 01:31:30 +00:00
|
|
|
MODULE* module = loadFootprint( id );
|
2014-06-11 05:57:26 +00:00
|
|
|
|
2018-03-09 01:31:30 +00:00
|
|
|
if( module )
|
2018-09-25 14:23:38 +00:00
|
|
|
AddModuleToBoard( module );
|
2013-10-13 21:33:58 +00:00
|
|
|
}
|
|
|
|
}
|
2013-12-12 16:01:03 +00:00
|
|
|
|
2014-06-11 05:57:26 +00:00
|
|
|
|
2018-09-25 14:23:38 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::AddModuleToBoard( MODULE* aFootprint )
|
|
|
|
{
|
2018-10-03 21:44:17 +00:00
|
|
|
m_revertModule.reset( (MODULE*) aFootprint->Clone() );
|
|
|
|
|
2018-09-25 14:23:38 +00:00
|
|
|
m_footprintNameWhenLoaded = aFootprint->GetFPID().GetLibItemName();
|
|
|
|
|
|
|
|
// Pads are always editable in Footprint Editor
|
|
|
|
aFootprint->SetPadsLocked( false );
|
|
|
|
|
|
|
|
PCB_BASE_EDIT_FRAME::AddModuleToBoard( aFootprint );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings )
|
|
|
|
{
|
2015-01-30 18:42:46 +00:00
|
|
|
GetBoard()->SetDesignSettings( aSettings );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
const PCB_PLOT_PARAMS& FOOTPRINT_EDIT_FRAME::GetPlotSettings() const
|
|
|
|
{
|
|
|
|
// get the settings from the parent editor, not our BOARD.
|
|
|
|
|
2014-05-06 04:58:33 +00:00
|
|
|
// @todo(DICK) change the routing to some default or the board directly, parent may not exist
|
|
|
|
PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) Kiway().Player( FRAME_PCB, true );
|
2012-04-05 18:27:56 +00:00
|
|
|
wxASSERT( parentFrame );
|
|
|
|
|
|
|
|
return parentFrame->GetPlotSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::SetPlotSettings( const PCB_PLOT_PARAMS& aSettings )
|
|
|
|
{
|
|
|
|
// set the settings into parent editor, not our BOARD.
|
|
|
|
|
2014-05-06 04:58:33 +00:00
|
|
|
// @todo(DICK) change the routing to some default or the board directly, parent may not exist
|
|
|
|
PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) Kiway().Player( FRAME_PCB, true );
|
2012-04-05 18:27:56 +00:00
|
|
|
wxASSERT( parentFrame );
|
|
|
|
|
|
|
|
parentFrame->SetPlotSettings( aSettings );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-30 18:42:46 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|
|
|
{
|
2015-07-03 08:15:37 +00:00
|
|
|
PCB_BASE_FRAME::LoadSettings( aCfg );
|
2015-01-30 18:42:46 +00:00
|
|
|
wxConfigLoadSetups( aCfg, GetConfigurationSettings() );
|
|
|
|
|
2017-09-10 14:21:56 +00:00
|
|
|
m_configSettings.Load( aCfg ); // mainly, load the color config
|
|
|
|
|
2015-01-30 18:42:46 +00:00
|
|
|
// Ensure some params are valid
|
|
|
|
BOARD_DESIGN_SETTINGS& settings = GetDesignSettings();
|
|
|
|
|
2015-07-03 08:15:37 +00:00
|
|
|
// Usually, graphic items are drawn on F_SilkS or F_Fab layer
|
|
|
|
// Force these layers if not default
|
2015-01-30 18:42:46 +00:00
|
|
|
if( ( settings.m_RefDefaultlayer != F_SilkS ) && ( settings.m_RefDefaultlayer != F_Fab ) )
|
|
|
|
settings.m_RefDefaultlayer = F_SilkS;
|
|
|
|
|
|
|
|
if( ( settings.m_ValueDefaultlayer != F_SilkS ) && ( settings.m_ValueDefaultlayer != F_Fab ) )
|
|
|
|
settings.m_ValueDefaultlayer = F_Fab;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
|
|
|
|
{
|
2017-09-10 14:21:56 +00:00
|
|
|
m_configSettings.Save( aCfg );
|
|
|
|
|
2015-07-03 08:15:37 +00:00
|
|
|
PCB_BASE_FRAME::SaveSettings( aCfg );
|
2015-01-30 18:42:46 +00:00
|
|
|
wxConfigSaveSetups( aCfg, GetConfigurationSettings() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-13 21:19:41 +00:00
|
|
|
double FOOTPRINT_EDIT_FRAME::BestZoom()
|
|
|
|
{
|
|
|
|
EDA_RECT ibbbox = GetBoardBoundingBox();
|
|
|
|
|
|
|
|
double sizeX = (double) ibbbox.GetWidth();
|
|
|
|
double sizeY = (double) ibbbox.GetHeight();
|
|
|
|
|
|
|
|
wxPoint centre = ibbbox.Centre();
|
|
|
|
|
|
|
|
// Reserve a 20% margin around "board" bounding box.
|
|
|
|
double margin_scale_factor = 1.2;
|
|
|
|
return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2018-05-03 14:03:26 +00:00
|
|
|
if( GetScreen()->IsModify() && GetBoard()->m_Modules )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2018-08-11 20:46:03 +00:00
|
|
|
if( !HandleUnsavedChanges( this, _( "Save changes to footprint before closing?" ),
|
|
|
|
[&]()->bool { return SaveFootprint( GetBoard()->m_Modules ); } ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-02-07 17:35:37 +00:00
|
|
|
Event.Veto();
|
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-26 09:50:16 +00:00
|
|
|
if( IsGalCanvasActive() )
|
2018-08-28 19:33:33 +00:00
|
|
|
{
|
|
|
|
GetGalCanvas()->SetEventDispatcher( NULL );
|
2015-08-26 09:50:16 +00:00
|
|
|
GetGalCanvas()->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
|
|
|
|
// the Layer Manger
|
|
|
|
m_auimgr.GetPane( "LayersManager" ).Show( false );
|
|
|
|
|
2018-08-28 19:33:33 +00:00
|
|
|
Clear_Pcb( false );
|
2015-08-26 09:50:16 +00:00
|
|
|
|
2013-02-07 17:35:37 +00:00
|
|
|
//close the editor
|
2007-08-20 01:20:48 +00:00
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::CloseModuleEditor( wxCommandEvent& Event )
|
2010-07-29 20:00:24 +00:00
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2017-06-12 13:10:43 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
2018-04-14 15:44:17 +00:00
|
|
|
if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
|
2018-04-13 20:41:36 +00:00
|
|
|
aEvent.Check( GetToolId() == aEvent.GetId() );
|
2017-06-12 13:10:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
aEvent.Enable( GetBoard()->m_Modules != NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
if( aEvent.GetEventObject() == m_drawToolBar )
|
2011-02-24 20:22:12 +00:00
|
|
|
aEvent.Check( GetToolId() == aEvent.GetId() );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2017-01-17 14:05:17 +00:00
|
|
|
|
2015-01-30 18:42:46 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
int id = aEvent.GetId();
|
2017-10-30 17:21:07 +00:00
|
|
|
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
|
2015-01-30 18:42:46 +00:00
|
|
|
|
|
|
|
bool state = false;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
|
|
|
|
state = displ_opts->m_ContrastModeDisplay;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-10-28 13:11:23 +00:00
|
|
|
wxMessageBox( "FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar error" );
|
2015-01-30 18:42:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aEvent.Check( state );
|
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
aEvent.Enable( GetBoard()->m_Modules != NULL );
|
|
|
|
}
|
2010-07-29 20:00:24 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2018-07-29 15:33:58 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
2018-09-13 23:39:40 +00:00
|
|
|
aEvent.Enable( getTargetFPID().IsValid() );
|
2018-07-29 15:33:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.Enable( GetBoard()->m_Modules && GetScreen()->IsModify() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
2018-09-13 23:39:40 +00:00
|
|
|
LIB_ID libId = getTargetFPID();
|
2018-07-29 15:33:58 +00:00
|
|
|
const wxString& libName = libId.GetLibNickname();
|
|
|
|
const wxString& partName = libId.GetLibItemName();
|
|
|
|
|
|
|
|
aEvent.Enable( !libName.IsEmpty() || !partName.IsEmpty() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2014-05-05 07:46:07 +00:00
|
|
|
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2014-05-05 07:46:07 +00:00
|
|
|
aEvent.Enable( frame && frame->GetBoard()->m_Modules != NULL );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2014-05-05 07:46:07 +00:00
|
|
|
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
|
2010-07-29 20:00:24 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
MODULE* module_in_edit = GetBoard()->m_Modules;
|
2014-05-05 07:46:07 +00:00
|
|
|
bool canInsert = frame && module_in_edit && !module_in_edit->GetLink();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
// If the source was deleted, the module can inserted but not updated in the board.
|
2014-05-05 07:46:07 +00:00
|
|
|
if( frame && module_in_edit && module_in_edit->GetLink() ) // this is not a new module
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-27 11:00:21 +00:00
|
|
|
BOARD* mainpcb = frame->GetBoard();
|
|
|
|
MODULE* source_module = mainpcb->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// search if the source module was not deleted:
|
2009-09-27 11:00:21 +00:00
|
|
|
for( ; source_module != NULL; source_module = source_module->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-03-13 18:53:58 +00:00
|
|
|
if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
canInsert = ( source_module == NULL );
|
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::ReFillLayerWidget()
|
|
|
|
{
|
2018-08-11 11:16:41 +00:00
|
|
|
|
|
|
|
m_Layers->Freeze();
|
2018-08-04 11:59:04 +00:00
|
|
|
m_Layers->ReFill();
|
2018-08-11 11:16:41 +00:00
|
|
|
m_Layers->Thaw();
|
2018-08-04 11:59:04 +00:00
|
|
|
|
|
|
|
wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_Layers );
|
|
|
|
|
|
|
|
wxSize bestz = m_Layers->GetBestSize();
|
|
|
|
|
|
|
|
lyrs.MinSize( bestz );
|
|
|
|
lyrs.BestSize( bestz );
|
|
|
|
lyrs.FloatingSize( bestz );
|
|
|
|
|
|
|
|
if( lyrs.IsDocked() )
|
|
|
|
m_auimgr.Update();
|
|
|
|
else
|
|
|
|
m_Layers->SetSize( bestz );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_Layers );
|
|
|
|
bool lm_shown = lm_pane_info.IsShown();
|
2018-08-11 16:04:46 +00:00
|
|
|
lm_pane_info.Caption( _( "Layers Manager" ) );
|
2018-08-04 11:59:04 +00:00
|
|
|
|
2018-08-11 11:16:41 +00:00
|
|
|
// update the layer manager
|
2018-08-04 11:59:04 +00:00
|
|
|
m_Layers->SetLayersManagerTabsText();
|
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::Show3D_Frame( wxCommandEvent& event )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2018-05-10 10:49:20 +00:00
|
|
|
bool forceRecreateIfNotOwner = true;
|
|
|
|
CreateAndShow3D_Frame( forceRecreateIfNotOwner );
|
2009-02-05 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2016-01-20 12:11:17 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2014-06-12 16:12:14 +00:00
|
|
|
// Filter out the 'fake' mouse motion after a keyboard movement
|
|
|
|
if( !aHotKey && m_movingCursorWithKeyboard )
|
|
|
|
{
|
|
|
|
m_movingCursorWithKeyboard = false;
|
2014-08-29 20:23:40 +00:00
|
|
|
return false;
|
2014-06-12 16:12:14 +00:00
|
|
|
}
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2012-08-11 12:52:13 +00:00
|
|
|
// when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
|
|
|
|
// for next cursor position
|
|
|
|
// ( shift or ctrl key down are PAN command with mouse wheel)
|
|
|
|
bool snapToGrid = true;
|
2013-05-28 16:54:59 +00:00
|
|
|
|
2012-08-11 12:52:13 +00:00
|
|
|
if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
|
|
|
|
snapToGrid = false;
|
|
|
|
|
2014-06-12 16:12:14 +00:00
|
|
|
wxPoint oldpos = GetCrossHairPosition();
|
|
|
|
wxPoint pos = aPosition;
|
2017-10-06 07:23:13 +00:00
|
|
|
bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, snapToGrid );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( pos, snapToGrid );
|
2014-06-12 16:12:14 +00:00
|
|
|
RefreshCrossHair( oldpos, aPosition, aDC );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2017-10-06 07:23:13 +00:00
|
|
|
if( aHotKey && OnHotKey( aDC, aHotKey, aPosition ) )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2017-10-06 07:23:13 +00:00
|
|
|
keyHandled = true;
|
2009-02-05 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
UpdateStatusBar();
|
2014-08-29 20:23:40 +00:00
|
|
|
|
2017-10-06 07:23:13 +00:00
|
|
|
return keyHandled;
|
2009-02-05 20:53:08 +00:00
|
|
|
}
|
2010-05-01 12:46:33 +00:00
|
|
|
|
2010-07-29 20:00:24 +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();
|
2018-05-10 10:49:20 +00:00
|
|
|
Update3DView();
|
2018-07-29 15:33:58 +00:00
|
|
|
m_treePane->GetLibTree()->Refresh();
|
2015-12-22 11:58:26 +00:00
|
|
|
}
|
2011-08-08 15:44:43 +00:00
|
|
|
|
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::updateTitle()
|
2011-08-08 15:44:43 +00:00
|
|
|
{
|
2018-10-05 12:55:34 +00:00
|
|
|
wxString title = _( "Footprint Editor" );
|
2018-09-13 23:39:40 +00:00
|
|
|
LIB_ID fpid = GetLoadedFPID();
|
2018-07-29 15:33:58 +00:00
|
|
|
bool writable = true;
|
2013-11-19 17:24:45 +00:00
|
|
|
|
2018-10-05 12:55:34 +00:00
|
|
|
if( IsCurrentFPFromBoard() )
|
|
|
|
{
|
|
|
|
title += wxString::Format( wxT( " \u2014 %s [from %s.%s]" ),
|
|
|
|
GetBoard()->m_Modules->GetReference(),
|
|
|
|
Prj().GetProjectName(), PcbFileExtension );
|
|
|
|
}
|
|
|
|
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
|
2018-07-26 20:19:46 +00:00
|
|
|
title += wxString::Format( wxT( " \u2014 %s %s" ),
|
2018-09-13 23:39:40 +00:00
|
|
|
FROM_UTF8( GetBoard()->m_Modules->GetFPID().Format().c_str() ),
|
2018-07-26 20:19:46 +00:00
|
|
|
writable ? wxString( wxEmptyString ) : _( "[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
|
2018-07-29 15:33:58 +00:00
|
|
|
title += wxString::Format( wxT( " \u2014 %s %s" ),
|
2018-09-13 23:39:40 +00:00
|
|
|
FROM_UTF8( GetBoard()->m_Modules->GetFPID().GetLibItemName().c_str() ),
|
2018-07-29 15:33:58 +00:00
|
|
|
_( "[Unsaved]" ) );
|
|
|
|
}
|
2013-11-19 17:24:45 +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()
|
|
|
|
{
|
|
|
|
// Update the layer manager and other widgets from the board setup
|
|
|
|
// (layer and items visibility, colors ...)
|
|
|
|
|
|
|
|
// Update the layer manager
|
|
|
|
m_Layers->Freeze();
|
|
|
|
ReFillLayerWidget();
|
|
|
|
m_Layers->ReFillRender();
|
|
|
|
|
|
|
|
// update the layer widget to match board visibility states.
|
|
|
|
m_Layers->SyncLayerVisibilities();
|
|
|
|
static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb );
|
|
|
|
m_Layers->SelectLayer( GetActiveLayer() );
|
|
|
|
m_Layers->OnLayerSelected();
|
|
|
|
|
|
|
|
m_Layers->Thaw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::updateView()
|
|
|
|
{
|
2017-08-04 12:43:02 +00:00
|
|
|
auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
|
|
|
|
dp->UseColorScheme( &Settings().Colors() );
|
|
|
|
dp->DisplayBoard( GetBoard() );
|
2014-07-09 11:50:27 +00:00
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2017-02-20 18:10:20 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
2018-07-26 20:19:46 +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 );
|
|
|
|
GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
|
|
|
|
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() );
|
2018-09-13 23:39:40 +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 );
|
|
|
|
GFootprintList.ReadFootprintFiles( fpTable, NULL, &progressReporter );
|
|
|
|
progressReporter.Show( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GFootprintList.ReadFootprintFiles( fpTable, NULL, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sync the LIB_TREE to the FOOTPRINT_INFO list
|
|
|
|
adapter->Sync();
|
|
|
|
|
|
|
|
m_treePane->GetLibTree()->Unselect();
|
|
|
|
m_treePane->Regenerate();
|
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-07 19:07:15 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::IsGridVisible() const
|
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
return IsElementVisible( LAYER_GRID );
|
2015-01-07 19:07:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::SetGridVisibility(bool aVisible)
|
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
SetElementVisibility( LAYER_GRID, aVisible );
|
2015-01-07 19:07:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::IsElementVisible( GAL_LAYER_ID aElement ) const
|
2015-01-07 19:07:15 +00:00
|
|
|
{
|
|
|
|
return GetBoard()->IsElementVisible( aElement );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState )
|
2015-01-07 19:07:15 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
GetGalCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
|
2015-01-07 19:07:15 +00:00
|
|
|
GetBoard()->SetElementVisibility( aElement, aNewState );
|
|
|
|
m_Layers->SetRenderState( aElement, aNewState );
|
|
|
|
}
|
|
|
|
|
2015-01-30 18:42:46 +00:00
|
|
|
|
2018-02-21 16:29:24 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateLayerAlpha( wxUpdateUIEvent & )
|
|
|
|
{
|
|
|
|
m_Layers->SyncLayerAlphaIndicators();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-30 18:42:46 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int id = event.GetId();
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
// Hotkey IDs
|
|
|
|
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
|
|
|
|
// Display current hotkey list for the footprint editor.
|
2018-02-14 22:07:59 +00:00
|
|
|
DisplayHotkeyList( this, g_Module_Editor_Hotkeys_Descr );
|
2015-01-30 18:42:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PCB_LIB_TABLE_EDIT:
|
2018-08-06 18:33:28 +00:00
|
|
|
InvokePcbLibTableEditor( &Kiway(), this );
|
2015-01-30 18:42:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_PREFERENCES:
|
2018-05-14 17:34:18 +00:00
|
|
|
ShowPreferences( g_Pcbnew_Editor_Hotkeys_Descr, g_Module_Editor_Hotkeys_Descr, wxT( "pcbnew" ) );
|
2017-03-13 15:18:30 +00:00
|
|
|
break;
|
|
|
|
|
2015-01-30 18:42:46 +00:00
|
|
|
default:
|
2016-10-28 13:11:23 +00:00
|
|
|
DisplayError( this, "FOOTPRINT_EDIT_FRAME::ProcessPreferences error" );
|
2015-01-30 18:42:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-29 21:22:53 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent )
|
|
|
|
{
|
2018-07-15 23:15:48 +00:00
|
|
|
wxTreebook* book = aParent->GetTreebook();
|
|
|
|
|
|
|
|
book->AddPage( new PANEL_MODEDIT_SETTINGS( this, aParent ), _( "Footprint Editor" ) );
|
|
|
|
book->AddSubPage( new PANEL_MODEDIT_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
|
|
|
|
book->AddSubPage( new PANEL_MODEDIT_DEFAULTS( this, aParent ), _( "Default Values" ) );
|
2018-05-14 17:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-29 21:22:53 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
|
|
|
{
|
2018-05-14 17:34:18 +00:00
|
|
|
DIALOG_CONFIGURE_PATHS dlg( this, Prj().Get3DCacheManager()->GetResolver() );
|
|
|
|
dlg.ShowModal();
|
2015-03-29 21:22:53 +00:00
|
|
|
}
|
2015-05-19 16:39:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::setupTools()
|
|
|
|
{
|
|
|
|
PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
|
|
|
|
|
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
|
|
|
m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
|
|
|
|
drawPanel->GetViewControls(), this );
|
2017-02-21 12:42:08 +00:00
|
|
|
m_actions = new PCB_ACTIONS();
|
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
2015-05-19 16:39:05 +00:00
|
|
|
|
|
|
|
drawPanel->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
|
2017-02-23 14:02:18 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
2015-05-19 16:39:05 +00:00
|
|
|
m_toolManager->RegisterTool( new 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 );
|
|
|
|
m_toolManager->RegisterTool( new POINT_EDITOR );
|
|
|
|
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
|
2017-01-27 11:07:29 +00:00
|
|
|
m_toolManager->RegisterTool( new MODULE_EDITOR_TOOLS );
|
2017-04-18 15:32:05 +00:00
|
|
|
m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
|
2015-06-18 15:51:51 +00:00
|
|
|
m_toolManager->RegisterTool( new PICKER_TOOL );
|
2018-06-26 18:03:57 +00:00
|
|
|
m_toolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
|
2015-05-19 16:39:05 +00:00
|
|
|
|
2017-02-09 00:54:32 +00:00
|
|
|
m_toolManager->GetTool<PAD_TOOL>()->SetEditModules( true );
|
2016-05-10 16:09:39 +00:00
|
|
|
m_toolManager->GetTool<SELECTION_TOOL>()->SetEditModules( true );
|
|
|
|
m_toolManager->GetTool<EDIT_TOOL>()->SetEditModules( true );
|
|
|
|
m_toolManager->GetTool<DRAWING_TOOL>()->SetEditModules( true );
|
2015-05-19 16:39:05 +00:00
|
|
|
|
2017-02-09 00:54:32 +00:00
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
2015-05-19 16:39:05 +00:00
|
|
|
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable )
|
|
|
|
{
|
2015-08-07 17:15:36 +00:00
|
|
|
PCB_BASE_EDIT_FRAME::UseGalCanvas( aEnable );
|
2015-05-19 16:39:05 +00:00
|
|
|
|
|
|
|
if( aEnable )
|
2017-04-29 09:43:02 +00:00
|
|
|
{
|
|
|
|
// Be sure the axis are enabled:
|
|
|
|
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
|
2015-05-19 16:39:05 +00:00
|
|
|
updateView();
|
2017-04-29 09:43:02 +00:00
|
|
|
}
|
2017-09-29 08:58:05 +00:00
|
|
|
|
|
|
|
ReCreateMenuBar();
|
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
|
|
|
|
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged()
|
2018-01-08 04:05:03 +00:00
|
|
|
{
|
2018-05-14 17:34:18 +00:00
|
|
|
PCB_BASE_EDIT_FRAME::CommonSettingsChanged();
|
|
|
|
|
|
|
|
Layout();
|
|
|
|
SendSizeEvent();
|
2018-01-08 04:05:03 +00:00
|
|
|
}
|
2018-02-19 19:26:02 +00:00
|
|
|
|
|
|
|
|
2018-05-12 08:44:31 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::UpdateMsgPanel()
|
|
|
|
{
|
|
|
|
// If a item is currently selected, displays the item info.
|
|
|
|
// If nothing selected, display the current footprint info
|
|
|
|
BOARD_ITEM* item = GetScreen()->GetCurItem();
|
|
|
|
|
|
|
|
if( !item )
|
|
|
|
item = GetBoard()->m_Modules;
|
|
|
|
|
|
|
|
MSG_PANEL_ITEMS items;
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
2018-04-10 10:52:12 +00:00
|
|
|
item->GetMsgPanelInfo( m_UserUnits, items );
|
2018-05-12 08:44:31 +00:00
|
|
|
SetMsgPanel( items );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ClearMsgPanel();
|
|
|
|
}
|
|
|
|
|