2011-11-08 16:37:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "dialog_helpers.h"
|
|
|
|
#include "3d_viewer.h"
|
|
|
|
#include "pcbcommon.h"
|
|
|
|
|
|
|
|
#include "class_board.h"
|
|
|
|
#include "class_module.h"
|
|
|
|
|
|
|
|
#include "pcbnew.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "protos.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h"
|
2010-02-14 18:14:33 +00:00
|
|
|
#include "hotkeys.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "module_editor_frame.h"
|
2009-02-05 20:53:08 +00:00
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
static PCB_SCREEN* s_screenModule = NULL; // the PCB_SCREEN used by the footprint editor
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
// Design setting for the module editor:
|
|
|
|
static BOARD_DESIGN_SETTINGS s_ModuleEditorDesignSetting;
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
wxString FOOTPRINT_EDIT_FRAME::m_CurrentLib = wxEmptyString;
|
2011-08-08 15:44:43 +00:00
|
|
|
|
2011-11-08 16:37:25 +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 )
|
|
|
|
EVT_TOOL( ID_MODEDIT_SAVE_LIBMODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_NEW_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_MODEDIT_LOAD_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
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 )
|
|
|
|
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 )
|
|
|
|
EVT_TOOL( wxID_UNDO, FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList )
|
|
|
|
EVT_TOOL( wxID_REDO, FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList )
|
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
|
|
|
|
|
|
|
// Options Toolbar
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_PADS_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar )
|
|
|
|
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 )
|
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
|
|
|
|
|
|
|
// 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 )
|
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
|
|
|
|
|
|
|
// 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
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected )
|
|
|
|
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 )
|
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 )
|
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
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( wxWindow* father,
|
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style ) :
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME( father, MODULE_EDITOR_FRAME, wxEmptyString, pos, size, style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-27 11:00:21 +00:00
|
|
|
m_FrameName = wxT( "ModEditFrame" );
|
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
|
2010-11-24 15:10:33 +00:00
|
|
|
m_HotkeysZoomAndGridList = 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
|
|
|
|
2011-08-08 15:44:43 +00:00
|
|
|
UpdateTitle();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( g_ModuleEditor_Pcb == NULL )
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
g_ModuleEditor_Pcb = new BOARD();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
SetBoard( g_ModuleEditor_Pcb );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
if( s_screenModule == NULL )
|
2011-12-31 05:44:00 +00:00
|
|
|
s_screenModule = new PCB_SCREEN( GetPageSettings().GetSizeIU() );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
SetScreen( s_screenModule );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
GetBoard()->SetDesignSettings( s_ModuleEditorDesignSetting );
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetCurItem( NULL );
|
2009-04-05 20:49:15 +00:00
|
|
|
LoadSettings();
|
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 );
|
2009-10-14 19:43:31 +00:00
|
|
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
2009-02-06 11:45:35 +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
|
|
|
|
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
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_auimgr.AddPane( m_drawToolBar,
|
2011-02-21 13:54:29 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_auimgr.AddPane( m_optionsToolBar,
|
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ). Left() );
|
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() );
|
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
|
|
|
|
|
|
|
m_auimgr.Update();
|
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
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
/* g_ModuleEditor_Pcb and its corresponding PCB_SCREEN are not deleted
|
|
|
|
* here, because if we reopen the Footprint editor, we expect to find
|
|
|
|
* the last edited item
|
2009-09-27 11:00:21 +00:00
|
|
|
*/
|
2011-02-05 02:21:11 +00:00
|
|
|
SetScreen( NULL ); /* Do not delete (by the destructor of EDA_DRAW_FRAME) the
|
|
|
|
* PCB_SCREEN handling g_ModuleEditor_Pcb
|
|
|
|
*/
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->m_ModuleEditFrame = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
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() )
|
|
|
|
{
|
2008-11-08 21:58:50 +00:00
|
|
|
if( !IsOK( this, _( "Module Editor: Module modified! Continue?" ) ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
Event.Veto(); return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveSettings();
|
|
|
|
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
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
aEvent.Enable( m_CurrentLib != wxEmptyString );
|
|
|
|
}
|
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
|
|
|
{
|
|
|
|
aEvent.Enable( ( m_CurrentLib != wxEmptyString ) && ( GetBoard()->m_Modules != NULL ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
aEvent.Enable( frame->GetBoard()->m_Modules != NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
|
2010-07-29 20:00:24 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
MODULE* module_in_edit = GetBoard()->m_Modules;
|
2011-02-21 13:54:29 +00:00
|
|
|
bool canInsert = ( module_in_edit && !module_in_edit->m_Link );
|
|
|
|
|
|
|
|
// If the source was deleted, the module can inserted but not updated in the board.
|
2009-11-18 12:52:19 +00:00
|
|
|
if( module_in_edit && module_in_edit->m_Link ) // 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
|
|
|
{
|
2011-12-12 08:37:05 +00:00
|
|
|
if( module_in_edit->m_Link == 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
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
|
2010-07-29 20:00:24 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
MODULE* module_in_edit = GetBoard()->m_Modules;
|
|
|
|
bool canReplace = ( module_in_edit && module_in_edit->m_Link );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
if( module_in_edit && module_in_edit->m_Link ) // this is not a new module
|
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
|
|
|
{
|
2011-12-12 08:37:05 +00:00
|
|
|
if( module_in_edit->m_Link == 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
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
m_Draw3DFrame = new EDA_3D_FRAME( 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
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2011-02-01 15:46:25 +00:00
|
|
|
wxRealPoint gridSize;
|
|
|
|
wxPoint oldpos;
|
|
|
|
wxPoint pos = aPosition;
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = GetScreen()->GetNearestGridPosition( aPosition );
|
|
|
|
oldpos = GetScreen()->GetCrossHairPosition();
|
2011-02-01 15:46:25 +00:00
|
|
|
gridSize = GetScreen()->GetGridSize();
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2011-02-22 16:43:03 +00:00
|
|
|
switch( aHotKey )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
case WXK_NUMPAD8:
|
2009-02-05 20:53:08 +00:00
|
|
|
case WXK_UP:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y -= wxRound( gridSize.y );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
2009-02-05 20:53:08 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
case WXK_NUMPAD2:
|
2009-02-05 20:53:08 +00:00
|
|
|
case WXK_DOWN:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y += wxRound( gridSize.y );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
2009-02-05 20:53:08 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
case WXK_NUMPAD4:
|
2009-02-05 20:53:08 +00:00
|
|
|
case WXK_LEFT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x -= wxRound( gridSize.x );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
2009-02-05 20:53:08 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
case WXK_NUMPAD6:
|
2009-02-05 20:53:08 +00:00
|
|
|
case WXK_RIGHT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x += wxRound( gridSize.x );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
2009-02-05 20:53:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( pos );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( oldpos != GetScreen()->GetCrossHairPosition() )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = GetScreen()->GetCrossHairPosition();
|
|
|
|
GetScreen()->SetCrossHairPosition( oldpos );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( aDC );
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( pos );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( aDC );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2011-05-20 18:25:11 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
2011-12-29 20:11:42 +00:00
|
|
|
wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC );
|
2011-05-20 18:25:11 +00:00
|
|
|
oDC.Clear();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( aDC, aPosition, false );
|
2011-05-20 18:25:11 +00:00
|
|
|
#else
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( aDC, aPosition, true );
|
2011-05-20 18:25:11 +00:00
|
|
|
#endif
|
2009-02-05 20:53:08 +00:00
|
|
|
}
|
2011-05-20 18:25:11 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
|
|
|
else
|
2011-12-22 13:28:11 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_overlay.Reset();
|
2011-12-22 13:28:11 +00:00
|
|
|
}
|
2011-05-20 18:25:11 +00:00
|
|
|
#endif
|
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
|
|
|
{
|
2011-02-22 16:43:03 +00:00
|
|
|
OnHotKey( aDC, aHotKey, aPosition );
|
2009-02-05 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
UpdateStatusBar();
|
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
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::UpdateTitle()
|
2011-08-08 15:44:43 +00:00
|
|
|
{
|
2011-08-26 17:01:17 +00:00
|
|
|
wxString title = _( "Module Editor " );
|
|
|
|
|
2011-08-08 15:44:43 +00:00
|
|
|
if( m_CurrentLib.IsEmpty() )
|
2011-08-26 17:01:17 +00:00
|
|
|
{
|
|
|
|
title += _( "(no active library)" );
|
|
|
|
}
|
2011-08-08 15:44:43 +00:00
|
|
|
else
|
2011-08-26 17:01:17 +00:00
|
|
|
{
|
|
|
|
wxFileName fileName = wxFileName( wxEmptyString, m_CurrentLib, ModuleFileExtension );
|
|
|
|
fileName = wxGetApp().FindLibraryPath( fileName );
|
|
|
|
|
|
|
|
if( !fileName.IsOk() || !fileName.FileExists() )
|
|
|
|
{
|
|
|
|
title += _( "(no active library)" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
title = _( "Module Editor (active library: " ) + fileName.GetFullPath() + wxT( ")" );
|
|
|
|
|
|
|
|
if( !fileName.IsFileWritable() )
|
|
|
|
title += _( " [Read Only]" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetTitle( title );
|
2011-08-08 15:44:43 +00:00
|
|
|
}
|