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>
|
2015-01-28 10:00:48 +00:00
|
|
|
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-11-08 16:37:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
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>
|
* 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 <pgm_base.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>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <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>
|
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>
|
2015-01-30 18:42:46 +00:00
|
|
|
#include <dialog_hotkeys_editor.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <module_editor_frame.h>
|
2015-01-30 18:42:46 +00:00
|
|
|
#include <modview_frame.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2014-07-09 09:59:23 +00:00
|
|
|
#include <class_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>
|
|
|
|
#include <tool/tool_dispatcher.h>
|
|
|
|
#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"
|
2014-07-09 13:02:56 +00:00
|
|
|
#include "tools/module_tools.h"
|
2014-07-09 12:23:13 +00:00
|
|
|
#include "tools/placement_tool.h"
|
2014-07-09 09:22:43 +00:00
|
|
|
#include "tools/common_actions.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 )
|
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
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_COMBOBOX( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom )
|
|
|
|
EVT_COMBOBOX( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_SELECT_CURRENT_LIB, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
2012-10-07 15:37:25 +00:00
|
|
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_SAVE_LIBRARY_AS, FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs )
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_SAVE_LIBMODULE, 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 )
|
|
|
|
|
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 )
|
2011-02-21 13:54:29 +00:00
|
|
|
EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
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 )
|
|
|
|
EVT_TOOL( ID_MODEDIT_LOAD_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
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_UPDATE_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 )
|
2011-02-24 20:22:12 +00:00
|
|
|
EVT_TOOL_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_PLACE_GRID_COORD,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2015-02-01 07:19:31 +00:00
|
|
|
// Options Toolbar (ID_TB_OPTIONS_SHOW_PADS_SKETCH id is managed in PCB_BASE_FRAME)
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar )
|
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_EXPORT_CONFIG,
|
|
|
|
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
|
|
|
EVT_MENU( ID_PREFERENCES_HOTKEY_IMPORT_CONFIG,
|
|
|
|
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
|
|
|
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_EDITOR,
|
|
|
|
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
|
|
|
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
|
|
|
|
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
2015-03-30 16:42:39 +00:00
|
|
|
EVT_MENU( ID_PCB_LIB_WIZARD,
|
|
|
|
FOOTPRINT_EDIT_FRAME::ProcessPreferences )
|
2015-01-30 18:42:46 +00:00
|
|
|
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
|
|
|
EVT_MENU( ID_POPUP_MODEDIT_ENTER_EDGE_WIDTH, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
|
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-08-26 17:01:17 +00:00
|
|
|
EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_MENU( ID_PCB_PAD_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
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 )
|
|
|
|
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
|
|
|
|
EVT_MENU( ID_MENU_CANVAS_DEFAULT, FOOTPRINT_EDIT_FRAME::SwitchCanvas )
|
|
|
|
EVT_MENU( ID_MENU_CANVAS_CAIRO, FOOTPRINT_EDIT_FRAME::SwitchCanvas )
|
|
|
|
EVT_MENU( ID_MENU_CANVAS_OPENGL, FOOTPRINT_EDIT_FRAME::SwitchCanvas )
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected )
|
2013-10-13 16:29:20 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_SELECT_CURRENT_LIB, FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib )
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
|
2011-02-21 13:54:29 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
|
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_SAVE_LIBMODULE, FOOTPRINT_EDIT_FRAME::OnUpdateLibAndModuleSelected )
|
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 )
|
2011-02-21 13:54:29 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_UPDATE_MODULE_IN_BOARD,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard )
|
|
|
|
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar )
|
2015-01-30 18:42:46 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
EVT_UPDATE_UI_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_PLACE_GRID_COORD,
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar )
|
2015-01-30 18:42:46 +00:00
|
|
|
|
|
|
|
// Option toolbar:
|
|
|
|
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
|
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar )
|
|
|
|
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
|
|
|
|
FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar )
|
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 )
|
|
|
|
|
2014-10-24 09:19:54 +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
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
#define FOOTPRINT_EDIT_FRAME_NAME wxT( "ModEditFrame" )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2015-05-19 16:39:05 +00:00
|
|
|
// Store the canvas mode during a session:
|
|
|
|
static enum PCB_DRAW_PANEL_GAL::GalType galmode = PCB_DRAW_PANEL_GAL::GAL_TYPE_NONE;
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
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
|
2015-05-19 16:39:05 +00:00
|
|
|
m_hotkeysDescrList = g_Module_Editor_Hokeys_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
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
// Show a title (frame title + footprint name):
|
2012-11-19 16:19:38 +00:00
|
|
|
updateTitle();
|
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,
|
2015-05-19 16:39:05 +00:00
|
|
|
galmode != PCB_DRAW_PANEL_GAL::GAL_TYPE_NONE ?
|
|
|
|
galmode : PCB_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
|
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
|
|
|
|
GetBoard()->GetDesignSettings().GetDefault()->SetClearance(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
|
|
|
|
2014-07-09 09:59:23 +00:00
|
|
|
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
2015-01-07 19:07:15 +00:00
|
|
|
m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), font.GetPointSize(), true );
|
2014-07-09 09:59:23 +00:00
|
|
|
|
2014-06-11 05:00:30 +00:00
|
|
|
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
|
2012-02-02 17:45:37 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetCurItem( NULL );
|
* 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
|
|
|
LoadSettings( config() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, 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 );
|
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateAuxiliaryToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
ReCreateOptToolbar();
|
|
|
|
|
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 );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-09-15 18:25:44 +00:00
|
|
|
EDA_PANEINFO horiz;
|
|
|
|
horiz.HorizontalToolbarPane();
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-09-15 18:25:44 +00:00
|
|
|
EDA_PANEINFO vert;
|
|
|
|
vert.VerticalToolbarPane();
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-09-15 18:25:44 +00:00
|
|
|
EDA_PANEINFO mesg_pane;
|
|
|
|
mesg_pane.MessageToolbarPane();
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2014-07-09 09:59:23 +00:00
|
|
|
// Create a wxAuiPaneInfo for the Layers Manager, not derived from the template.
|
|
|
|
// LAYER_WIDGET is floatable, but initially docked at far right
|
|
|
|
EDA_PANEINFO lyrs;
|
|
|
|
lyrs.LayersToolbarPane();
|
|
|
|
lyrs.MinSize( m_Layers->GetBestSize() ); // updated in ReFillLayerWidget
|
|
|
|
lyrs.BestSize( m_Layers->GetBestSize() );
|
|
|
|
lyrs.Caption( _( "Visibles" ) );
|
|
|
|
|
2011-12-16 13:32:23 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar,
|
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top(). Row( 0 ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_auimgr.AddPane( m_auxiliaryToolBar,
|
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_auxiliaryToolBar" ) ).Top().Row( 1 ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2013-11-01 12:56:20 +00:00
|
|
|
// The main right vertical toolbar
|
2011-12-14 20:03:15 +00:00
|
|
|
m_auimgr.AddPane( m_drawToolBar,
|
2013-11-01 12:56:20 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Layer(1) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2014-07-09 09:59:23 +00:00
|
|
|
// Add the layer manager ( most right side of pcbframe )
|
|
|
|
m_auimgr.AddPane( m_Layers, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 2 ) );
|
2015-05-19 16:39:05 +00:00
|
|
|
// Layers manager is visible
|
|
|
|
m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( true );
|
2014-07-09 09:59:23 +00:00
|
|
|
|
2013-11-01 12:56:20 +00:00
|
|
|
// The left vertical toolbar (fast acces to display options)
|
2011-12-14 20:03:15 +00:00
|
|
|
m_auimgr.AddPane( m_optionsToolBar,
|
2013-11-01 12:56:20 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ). Left().Layer(1) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_auimgr.AddPane( m_canvas,
|
2011-02-21 13:54:29 +00:00
|
|
|
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
|
2014-07-09 09:22:43 +00:00
|
|
|
m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
|
|
|
|
wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-12-12 14:02:37 +00:00
|
|
|
m_auimgr.AddPane( m_messagePanel,
|
2011-09-15 18:25:44 +00:00
|
|
|
wxAuiPaneInfo( mesg_pane ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
|
2009-11-02 22:24:55 +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();
|
|
|
|
UseGalCanvas( galmode != PCB_DRAW_PANEL_GAL::GAL_TYPE_NONE );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2015-01-07 19:07:15 +00:00
|
|
|
if( m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).IsShown() )
|
|
|
|
{
|
2014-09-01 11:48:10 +00:00
|
|
|
m_Layers->ReFill();
|
|
|
|
m_Layers->ReFillRender();
|
|
|
|
|
|
|
|
GetScreen()->m_Active_Layer = F_SilkS;
|
|
|
|
m_Layers->SelectLayer( F_SilkS );
|
|
|
|
m_Layers->OnLayerSelected();
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2014-07-09 09:59:23 +00:00
|
|
|
|
|
|
|
m_auimgr.Update();
|
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-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
|
|
|
|
2014-06-11 05:18:41 +00:00
|
|
|
const wxString FOOTPRINT_EDIT_FRAME::getLibPath()
|
2013-11-19 17:24:45 +00:00
|
|
|
{
|
2014-06-11 05:18:41 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
const wxString& nickname = GetCurrentLib();
|
|
|
|
|
|
|
|
const FP_LIB_TABLE::ROW* row = Prj().PcbFootprintLibs()->FindRow( nickname );
|
|
|
|
|
|
|
|
return row->GetFullURI( true );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
2013-11-19 17:24:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-11 05:18:41 +00:00
|
|
|
const wxString FOOTPRINT_EDIT_FRAME::GetCurrentLib() const
|
2013-11-19 17:24:45 +00:00
|
|
|
{
|
2014-06-11 05:18:41 +00:00
|
|
|
return Prj().GetRString( PROJECT::PCB_LIB_NICKNAME );
|
|
|
|
};
|
2013-11-19 17:24:45 +00:00
|
|
|
|
|
|
|
|
2014-06-11 05:18:41 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::retainLastFootprint()
|
2013-10-13 21:33:58 +00:00
|
|
|
{
|
2014-06-11 05:18:41 +00:00
|
|
|
PCB_IO pcb_io;
|
|
|
|
MODULE* module = GetBoard()->m_Modules;
|
|
|
|
|
|
|
|
if( module )
|
2013-10-13 21:33:58 +00:00
|
|
|
{
|
2014-06-11 05:57:26 +00:00
|
|
|
pcb_io.Format( module );
|
2013-11-19 17:24:45 +00:00
|
|
|
|
2014-06-11 05:18:41 +00:00
|
|
|
wxString pretty = FROM_UTF8( pcb_io.GetStringOutput( true ).c_str() );
|
2013-11-19 17:24:45 +00:00
|
|
|
|
2014-06-11 05:57:26 +00:00
|
|
|
// save the footprint in the RSTRING facility.
|
2014-06-11 05:18:41 +00:00
|
|
|
Prj().SetRString( PROJECT::PCB_FOOTPRINT, pretty );
|
2013-10-13 21:33:58 +00:00
|
|
|
}
|
2014-06-11 05:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::restoreLastFootprint()
|
|
|
|
{
|
|
|
|
wxString pretty = Prj().GetRString( PROJECT::PCB_FOOTPRINT );
|
|
|
|
|
|
|
|
if( !!pretty )
|
2013-10-13 21:33:58 +00:00
|
|
|
{
|
2014-06-11 05:18:41 +00:00
|
|
|
PCB_IO pcb_io;
|
|
|
|
MODULE* module = NULL;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
module = (MODULE*) pcb_io.Parse( pretty );
|
|
|
|
}
|
|
|
|
catch( const PARSE_ERROR& pe )
|
|
|
|
{
|
|
|
|
// unlikely to be a problem, since we produced the pretty string.
|
|
|
|
wxLogError( wxT( "PARSE_ERROR" ) );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
// unlikely to be a problem, since we produced the pretty string.
|
|
|
|
wxLogError( wxT( "IO_ERROR" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( module )
|
2014-06-11 05:57:26 +00:00
|
|
|
{
|
|
|
|
// assumes BOARD is empty.
|
|
|
|
wxASSERT( GetBoard()->m_Modules == NULL );
|
|
|
|
|
|
|
|
// no idea, its monkey see monkey do. I would encapsulate this into
|
|
|
|
// a member function if its actually necessary.
|
|
|
|
module->SetParent( GetBoard() );
|
|
|
|
module->SetLink( 0 );
|
|
|
|
|
|
|
|
GetBoard()->Add( 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
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::LoadSettings( aCfg );
|
|
|
|
wxConfigLoadSetups( aCfg, GetConfigurationSettings() );
|
|
|
|
|
|
|
|
// Ensure some params are valid
|
|
|
|
BOARD_DESIGN_SETTINGS& settings = GetDesignSettings();
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::SaveSettings( aCfg );
|
|
|
|
wxConfigSaveSetups( aCfg, GetConfigurationSettings() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( GetScreen()->IsModify() )
|
|
|
|
{
|
2014-10-08 05:50:56 +00:00
|
|
|
int ii = DisplayExitDialog( this, _( "Save the changes to the footprint before closing?" ) );
|
2013-02-07 17:35:37 +00:00
|
|
|
|
|
|
|
switch( ii )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-02-07 17:35:37 +00:00
|
|
|
case wxID_NO:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_YES:
|
|
|
|
// code from FOOTPRINT_EDIT_FRAME::Process_Special_Functions,
|
|
|
|
// at case ID_MODEDIT_SAVE_LIBMODULE
|
2014-06-11 05:18:41 +00:00
|
|
|
if( GetBoard()->m_Modules && GetCurrentLib().size() )
|
2013-11-27 06:04:04 +00:00
|
|
|
{
|
2015-01-28 10:00:48 +00:00
|
|
|
if( SaveFootprintInLibrary( GetCurrentLib(), GetBoard()->m_Modules, true, true ) )
|
2013-02-07 17:35:37 +00:00
|
|
|
{
|
|
|
|
// save was correct
|
|
|
|
GetScreen()->ClrModify();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-08 05:50:56 +00:00
|
|
|
DisplayError( this, _( "Library is not set, the footprint could not be saved." ) );
|
2013-02-07 17:35:37 +00:00
|
|
|
}
|
|
|
|
// fall through: cancel the close because of an error
|
|
|
|
|
|
|
|
case wxID_CANCEL:
|
|
|
|
Event.Veto();
|
|
|
|
return;
|
2007-08-20 01:20:48 +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
|
|
|
|
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
|
|
|
|
2015-01-30 18:42:46 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
int id = aEvent.GetId();
|
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions();
|
|
|
|
|
|
|
|
bool state = false;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH:
|
2015-02-02 08:06:39 +00:00
|
|
|
state = displ_opts->m_DisplayModTextFill == SKETCH;
|
2015-01-30 18:42:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH:
|
2015-02-02 08:06:39 +00:00
|
|
|
state = displ_opts->m_DisplayModEdgeFill == SKETCH;
|
2015-01-30 18:42:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
|
|
|
|
state = displ_opts->m_ContrastModeDisplay;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxMessageBox( wxT( "FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar error" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aEvent.Check( state );
|
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2014-04-04 18:28:35 +00:00
|
|
|
bool enable = getLibPath() != wxEmptyString;
|
|
|
|
aEvent.Enable( enable );
|
|
|
|
GetMenuBar()->Enable( ID_MODEDIT_SAVE_LIBRARY_AS, enable );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-07-29 20:00:24 +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
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateLibAndModuleSelected( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
aEvent.Enable( getLibPath() != wxEmptyString && GetBoard()->m_Modules != NULL );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard( 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
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
MODULE* module_in_edit = GetBoard()->m_Modules;
|
2014-05-05 07:46:07 +00:00
|
|
|
bool canReplace = frame && module_in_edit && module_in_edit->GetLink();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2014-05-05 07:46:07 +00:00
|
|
|
if( canReplace ) // this is not a new module, but verify if the source is still on board
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
BOARD* mainpcb = frame->GetBoard();
|
|
|
|
MODULE* source_module = mainpcb->m_Modules;
|
|
|
|
|
|
|
|
// search if the source module was not deleted:
|
|
|
|
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() )
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
canReplace = ( source_module != NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
aEvent.Enable( canReplace );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2013-10-13 16:29:20 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
2014-05-09 18:35:48 +00:00
|
|
|
FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
|
* 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
|
|
|
|
|
|
|
aEvent.Enable( fptbl && !fptbl->IsEmpty() );
|
2013-10-13 16:29:20 +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
|
|
|
{
|
|
|
|
if( m_Draw3DFrame )
|
|
|
|
{
|
2011-08-04 11:23:19 +00:00
|
|
|
// Raising the window does not show the window on Windows if iconized.
|
|
|
|
// This should work on any platform.
|
|
|
|
if( m_Draw3DFrame->IsIconized() )
|
|
|
|
m_Draw3DFrame->Iconize( false );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
m_Draw3DFrame->Raise();
|
|
|
|
|
|
|
|
// Raising the window does not set the focus on Linux. This should work on any platform.
|
|
|
|
if( wxWindow::FindFocus() != m_Draw3DFrame )
|
|
|
|
m_Draw3DFrame->SetFocus();
|
|
|
|
|
2009-02-05 20:53:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
* 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
|
|
|
m_Draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, _( "3D Viewer" ) );
|
2010-07-29 20:00:24 +00:00
|
|
|
m_Draw3DFrame->Show( true );
|
2009-02-05 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2014-08-29 20:23:40 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2014-08-29 20:23:40 +00:00
|
|
|
bool eventHandled = true;
|
|
|
|
|
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;
|
|
|
|
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
|
|
|
|
2011-02-22 16:43:03 +00:00
|
|
|
if( aHotKey )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2014-08-29 20:23:40 +00:00
|
|
|
eventHandled = OnHotKey( aDC, aHotKey, aPosition );
|
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
|
|
|
|
|
|
|
return eventHandled;
|
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();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-05-01 12:46:33 +00:00
|
|
|
if( m_Draw3DFrame )
|
2010-07-29 20:00:24 +00:00
|
|
|
m_Draw3DFrame->ReloadRequest();
|
2010-05-01 12:46:33 +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
|
|
|
{
|
2014-10-08 05:50:56 +00:00
|
|
|
wxString title = _( "Footprint Editor " );
|
2013-11-19 17:24:45 +00:00
|
|
|
|
2014-06-11 05:18:41 +00:00
|
|
|
wxString nickname = GetCurrentLib();
|
2013-11-19 17:24:45 +00:00
|
|
|
|
|
|
|
if( !nickname )
|
|
|
|
{
|
|
|
|
L_none:
|
|
|
|
title += _( "(no active library)" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2014-05-09 18:35:48 +00:00
|
|
|
bool writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname );
|
2013-11-19 17:24:45 +00:00
|
|
|
|
|
|
|
// no exception was thrown, this means libPath is valid, but it may be read only.
|
2014-10-08 05:50:56 +00:00
|
|
|
title = _( "Footprint Editor (active library: " ) + nickname + wxT( ")" );
|
2013-11-19 17:24:45 +00:00
|
|
|
|
|
|
|
if( !writable )
|
|
|
|
title += _( " [Read Only]" );
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-11-19 17:24:45 +00:00
|
|
|
{
|
|
|
|
// user may be bewildered as to why after selecting a library it is not showing up
|
|
|
|
// in the title, we could show an error message, but that should have been done at time
|
|
|
|
// of libary selection UI.
|
|
|
|
goto L_none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::updateView()
|
|
|
|
{
|
|
|
|
static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->DisplayBoard( GetBoard() );
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2014-07-23 10:06:24 +00:00
|
|
|
m_toolManager->RunAction( COMMON_ACTIONS::zoomFitScreen, true );
|
2014-07-09 11:50:27 +00:00
|
|
|
}
|
2015-01-07 19:07:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool FOOTPRINT_EDIT_FRAME::IsGridVisible() const
|
|
|
|
{
|
|
|
|
return IsElementVisible( GRID_VISIBLE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::SetGridVisibility(bool aVisible)
|
|
|
|
{
|
|
|
|
SetElementVisibility( GRID_VISIBLE, aVisible );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool FOOTPRINT_EDIT_FRAME::IsElementVisible( int aElement ) const
|
|
|
|
{
|
|
|
|
return GetBoard()->IsElementVisible( aElement );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::SetElementVisibility( int aElement, bool aNewState )
|
|
|
|
{
|
|
|
|
GetGalCanvas()->GetView()->SetLayerVisible( ITEM_GAL_LAYER( aElement ), aNewState );
|
|
|
|
GetBoard()->SetElementVisibility( aElement, aNewState );
|
|
|
|
m_Layers->SetRenderState( aElement, aNewState );
|
|
|
|
}
|
|
|
|
|
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_EXPORT_CONFIG:
|
2015-03-02 17:29:18 +00:00
|
|
|
ExportHotkeyConfigToFile( g_Module_Editor_Hokeys_Descr, wxT( "pcbnew" ) );
|
2015-01-30 18:42:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
|
2015-03-02 17:29:18 +00:00
|
|
|
ImportHotkeyConfigFromFile( g_Module_Editor_Hokeys_Descr, wxT( "pcbnew" ) );
|
2015-01-30 18:42:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
|
|
|
|
InstallHotkeyFrame( this, g_Module_Editor_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
|
|
|
|
// Display current hotkey list for the footprint editor.
|
|
|
|
DisplayHotkeyList( this, g_Module_Editor_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
2015-03-30 16:42:39 +00:00
|
|
|
case ID_PCB_LIB_WIZARD:
|
2015-01-30 18:42:46 +00:00
|
|
|
case ID_PCB_LIB_TABLE_EDIT:
|
|
|
|
{
|
|
|
|
bool tableChanged = false;
|
2015-03-30 16:42:39 +00:00
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
if( id == ID_PCB_LIB_TABLE_EDIT )
|
|
|
|
r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() );
|
|
|
|
else
|
|
|
|
r = InvokeFootprintWizard( this, &GFootprintTable, Prj().PcbFootprintLibs() );
|
2015-01-30 18:42:46 +00:00
|
|
|
|
|
|
|
if( r & 1 )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() );
|
|
|
|
|
|
|
|
GFootprintTable.Format( &sf, 0 );
|
|
|
|
tableChanged = true;
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( _(
|
|
|
|
"Error occurred saving the global footprint library "
|
|
|
|
"table:\n\n%s" ),
|
|
|
|
GetChars( ioe.errorText.GetData() )
|
|
|
|
);
|
|
|
|
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( r & 2 )
|
|
|
|
{
|
|
|
|
wxString tblName = Prj().FootprintLibTblName();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Prj().PcbFootprintLibs()->Save( tblName );
|
|
|
|
tableChanged = true;
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( _(
|
|
|
|
"Error occurred saving project specific footprint library "
|
|
|
|
"table:\n\n%s" ),
|
|
|
|
GetChars( ioe.errorText )
|
|
|
|
);
|
|
|
|
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FOOTPRINT_VIEWER_FRAME* viewer;
|
|
|
|
viewer = (FOOTPRINT_VIEWER_FRAME*)Kiway().Player( FRAME_PCB_MODULE_VIEWER, false );
|
|
|
|
|
|
|
|
if( tableChanged && viewer != NULL )
|
|
|
|
viewer->ReCreateLibraryList();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_PREFERENCES:
|
|
|
|
InvokeFPEditorPrefsDlg( this );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "FOOTPRINT_EDIT_FRAME::ProcessPreferences error" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-29 21:22:53 +00:00
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
Pgm().ConfigurePaths( this );
|
|
|
|
}
|
2015-05-19 16:39:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
int id = aEvent.GetId();
|
|
|
|
bool use_gal = false;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_MENU_CANVAS_DEFAULT:
|
|
|
|
galmode = PCB_DRAW_PANEL_GAL::GAL_TYPE_NONE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MENU_CANVAS_CAIRO:
|
|
|
|
galmode = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
|
|
|
|
use_gal = GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MENU_CANVAS_OPENGL:
|
|
|
|
galmode = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
|
|
|
|
use_gal = GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
UseGalCanvas( use_gal );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
|
|
|
|
|
|
|
drawPanel->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
|
|
|
|
m_toolManager->RegisterTool( new SELECTION_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new EDIT_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new DRAWING_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new POINT_EDITOR );
|
|
|
|
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
|
|
|
|
m_toolManager->RegisterTool( new MODULE_TOOLS );
|
|
|
|
m_toolManager->RegisterTool( new PLACEMENT_TOOL );
|
|
|
|
|
|
|
|
m_toolManager->GetTool<SELECTION_TOOL>()->EditModules( true );
|
|
|
|
m_toolManager->GetTool<EDIT_TOOL>()->EditModules( true );
|
|
|
|
m_toolManager->GetTool<DRAWING_TOOL>()->EditModules( true );
|
|
|
|
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::RUN );
|
|
|
|
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable )
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::UseGalCanvas( aEnable );
|
|
|
|
|
|
|
|
if( aEnable )
|
|
|
|
{
|
|
|
|
SetBoard( m_Pcb );
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
|
|
|
|
updateView();
|
|
|
|
GetGalCanvas()->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
GetGalCanvas()->StartDrawing();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
|
|
|
|
|
|
|
|
// Redirect all events to the legacy canvas
|
|
|
|
GetGalCanvas()->SetEventDispatcher( NULL );
|
|
|
|
}
|
|
|
|
}
|