2009-11-18 12:52:19 +00:00
|
|
|
/************************************************************/
|
|
|
|
/* moduleframe.cpp - 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"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2010-08-10 18:34:26 +00:00
|
|
|
#include "module_editor_frame.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"
|
2010-11-18 21:16:28 +00:00
|
|
|
#include "dialog_helpers.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-02-05 20:53:08 +00:00
|
|
|
#include "3d_viewer.h"
|
|
|
|
|
|
|
|
|
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-08-26 17:01:17 +00:00
|
|
|
/******************************/
|
|
|
|
/* class FOOTPRINT_EDIT_FRAME */
|
|
|
|
/******************************/
|
|
|
|
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-03-01 19:26:17 +00:00
|
|
|
EVT_MENU( ID_PCB_USER_GRID_SETUP, PCB_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" );
|
2009-04-07 07:24:33 +00:00
|
|
|
m_Draw_Sheet_Ref = false; // true to show the frame references
|
2009-09-27 11:00:21 +00:00
|
|
|
m_Draw_Axis = true; // true to show X and Y axis on screen
|
2010-07-13 10:42:32 +00:00
|
|
|
m_Draw_Grid_Axis = 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
|
|
|
|
SetIcon( wxICON( icon_modedit ) );
|
|
|
|
|
2011-08-08 15:44:43 +00:00
|
|
|
UpdateTitle();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( g_ModuleEditor_Pcb == NULL )
|
|
|
|
g_ModuleEditor_Pcb = new BOARD( NULL, this );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
SetBoard( g_ModuleEditor_Pcb );
|
|
|
|
GetBoard()->m_PcbFrame = this;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
if( s_screenModule == NULL )
|
|
|
|
s_screenModule = new PCB_SCREEN();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
SetScreen( s_screenModule );
|
2010-01-31 20:01:46 +00:00
|
|
|
GetBoard()->SetBoardDesignSettings( &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();
|
|
|
|
|
|
|
|
if( DrawPanel )
|
2010-07-29 20:00:24 +00:00
|
|
|
DrawPanel->m_Block_Enable = 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
|
|
|
|
|
|
|
wxAuiPaneInfo horiz;
|
2009-11-18 12:52:19 +00:00
|
|
|
horiz.Gripper( false );
|
|
|
|
horiz.DockFixed( true );
|
|
|
|
horiz.Movable( false );
|
|
|
|
horiz.Floatable( false );
|
|
|
|
horiz.CloseButton( false );
|
|
|
|
horiz.CaptionVisible( false );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
wxAuiPaneInfo vert( horiz );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
vert.TopDockable( false ).BottomDockable( false );
|
|
|
|
horiz.LeftDockable( false ).RightDockable( false );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_auimgr.AddPane( m_HToolBar,
|
2011-02-21 13:54:29 +00:00
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top(). Row( 0 ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_auimgr.AddPane( m_AuxiliaryToolBar,
|
2011-02-21 13:54:29 +00:00
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_AuxiliaryToolBar" ) ).Top().Row( 1 ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_auimgr.AddPane( m_VToolBar,
|
2011-02-21 13:54:29 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_auimgr.AddPane( m_OptionsToolBar,
|
2011-02-21 13:54:29 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ). Left() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_auimgr.AddPane( DrawPanel,
|
2011-02-21 13:54:29 +00:00
|
|
|
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
m_auimgr.AddPane( MsgPanel,
|
2011-02-21 13:54:29 +00:00
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
|
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-02-21 13:54:29 +00:00
|
|
|
if( aEvent.GetEventObject() == m_VToolBar )
|
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
|
|
|
{
|
|
|
|
if( module_in_edit->m_Link == source_module->m_TimeStamp )
|
|
|
|
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-02-21 13:54:29 +00:00
|
|
|
if( module_in_edit->m_Link == source_module->m_TimeStamp )
|
|
|
|
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 );
|
|
|
|
DrawPanel->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 );
|
|
|
|
DrawPanel->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 );
|
|
|
|
DrawPanel->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 );
|
|
|
|
DrawPanel->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 );
|
|
|
|
DrawPanel->CrossHairOff( aDC );
|
|
|
|
GetScreen()->SetCrossHairPosition( pos );
|
|
|
|
DrawPanel->CrossHairOn( aDC );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( DrawPanel->IsMouseCaptured() )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2011-05-20 18:25:11 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
|
|
|
wxDCOverlay oDC( DrawPanel->m_overlay, (wxWindowDC*)aDC );
|
|
|
|
oDC.Clear();
|
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, false );
|
|
|
|
#else
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, 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
|
|
|
|
DrawPanel->m_overlay.Reset();
|
|
|
|
#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
|
|
|
}
|