2007-05-06 16:03:28 +00:00
|
|
|
|
/***************************************************************************/
|
|
|
|
|
/* moduleframe.cpp - fonctions de base de la classe WinEDA_ModuleEditFrame */
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#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"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#include "bitmaps.h"
|
|
|
|
|
#include "protos.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
|
#include "pcbnew_id.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-02-05 20:53:08 +00:00
|
|
|
|
#include "3d_viewer.h"
|
|
|
|
|
|
2009-02-07 08:33:25 +00:00
|
|
|
|
// Keys used in read/write config
|
2009-02-07 14:13:16 +00:00
|
|
|
|
#define MODEDIT_CURR_GRID wxT( "ModEditCurrGrid" )
|
2009-02-05 20:53:08 +00:00
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
|
// local variables:
|
|
|
|
|
static PCB_SCREEN* s_screenModule = NULL; // the PCB_SCREEN used by the footprint editor
|
|
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/********************************/
|
|
|
|
|
/* class WinEDA_ModuleEditFrame */
|
|
|
|
|
/********************************/
|
2009-01-07 15:59:49 +00:00
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_ModuleEditFrame, WinEDA_BasePcbFrame )
|
2009-09-27 11:00:21 +00:00
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START,
|
|
|
|
|
ID_POPUP_PCB_ITEM_SELECTION_END,
|
|
|
|
|
WinEDA_BasePcbFrame::ProcessItemSelection )
|
|
|
|
|
EVT_CLOSE( WinEDA_ModuleEditFrame::OnCloseWindow )
|
|
|
|
|
EVT_SIZE( WinEDA_ModuleEditFrame::OnSize )
|
|
|
|
|
|
|
|
|
|
EVT_KICAD_CHOICEBOX( ID_ON_ZOOM_SELECT, WinEDA_PcbFrame::OnSelectZoom )
|
|
|
|
|
EVT_KICAD_CHOICEBOX( ID_ON_GRID_SELECT, WinEDA_PcbFrame::OnSelectGrid )
|
|
|
|
|
|
|
|
|
|
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_ModuleEditFrame::OnZoom )
|
|
|
|
|
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_SELECT_CURRENT_LIB,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_SAVE_LIBMODULE,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_DELETE_PART,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_NEW_MODULE,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_LOAD_MODULE,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_IMPORT_PART,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_EXPORT_PART,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_SHEET_SET,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_GEN_PRINT, WinEDA_DrawFrame::ToPrinter )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_LOAD_MODULE,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_CHECK,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_PAD_SETTINGS,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
|
|
|
|
|
WinEDA_ModuleEditFrame::LoadModuleFromBoard )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_INSERT_MODULE_IN_BOARD,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_UPDATE_MODULE_IN_BOARD,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_EDIT_MODULE_PROPERTIES,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_UNDO,
|
|
|
|
|
WinEDA_ModuleEditFrame::GetComponentFromUndoList )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_REDO,
|
|
|
|
|
WinEDA_ModuleEditFrame::GetComponentFromRedoList )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
// Vertical toolbar (left click):
|
2009-09-27 11:00:21 +00:00
|
|
|
|
EVT_TOOL( ID_NO_SELECT_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_ADD_PAD,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_PCB_ARC_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_PCB_CIRCLE_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_PCB_ADD_TEXT_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_PCB_ADD_LINE_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_DELETE_ITEM_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_TOOL( ID_MODEDIT_PLACE_ANCHOR,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
// Vertical toolbar (right click):
|
2009-09-27 11:00:21 +00:00
|
|
|
|
EVT_TOOL_RCLICKED( ID_MODEDIT_ADD_PAD,
|
|
|
|
|
WinEDA_ModuleEditFrame::ToolOnRightClick )
|
|
|
|
|
EVT_TOOL_RCLICKED( ID_TRACK_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::ToolOnRightClick )
|
|
|
|
|
EVT_TOOL_RCLICKED( ID_PCB_CIRCLE_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::ToolOnRightClick )
|
|
|
|
|
EVT_TOOL_RCLICKED( ID_PCB_ARC_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::ToolOnRightClick )
|
|
|
|
|
EVT_TOOL_RCLICKED( ID_PCB_ADD_TEXT_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::ToolOnRightClick )
|
|
|
|
|
EVT_TOOL_RCLICKED( ID_PCB_ADD_LINE_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::ToolOnRightClick )
|
|
|
|
|
EVT_TOOL_RCLICKED( ID_PCB_COTATION_BUTT,
|
|
|
|
|
WinEDA_ModuleEditFrame::ToolOnRightClick )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
// Options Toolbar
|
2009-09-27 11:00:21 +00:00
|
|
|
|
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
|
|
|
|
|
WinEDA_ModuleEditFrame::OnSelectOptionToolbar )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
|
// popup commands
|
2009-09-27 11:00:21 +00:00
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
// Transformations du module
|
2009-09-27 11:00:21 +00:00
|
|
|
|
EVT_MENU( ID_MODEDIT_MODULE_ROTATE,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_MENU( ID_MODEDIT_MODULE_MIRROR,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
|
|
|
|
|
EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_MENU( ID_PCB_PAD_SETUP,
|
|
|
|
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
|
|
|
|
EVT_MENU( ID_PCB_USER_GRID_SETUP,
|
|
|
|
|
WinEDA_PcbFrame::Process_Special_Functions )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
// Menu 3D Frame
|
2009-09-27 11:00:21 +00:00
|
|
|
|
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, WinEDA_ModuleEditFrame::Show3D_Frame )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
// PopUp Menu Zoom trait<69>s dans drawpanel.cpp
|
2007-05-06 16:03:28 +00:00
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/****************/
|
|
|
|
|
/* Constructeur */
|
|
|
|
|
/****************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
|
WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
|
2007-08-20 01:20:48 +00:00
|
|
|
|
const wxString& title,
|
2009-09-27 11:00:21 +00:00
|
|
|
|
const wxPoint& pos,
|
|
|
|
|
const wxSize& size,
|
|
|
|
|
long style ) :
|
2008-12-08 15:27:13 +00:00
|
|
|
|
WinEDA_BasePcbFrame( father, MODULE_EDITOR_FRAME,
|
2008-12-05 16:03:05 +00:00
|
|
|
|
wxEmptyString, pos, size, style )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
|
wxConfig* config = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
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
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
// Give an icon
|
|
|
|
|
SetIcon( wxICON( icon_modedit ) );
|
|
|
|
|
|
|
|
|
|
SetTitle( wxT( "Module Editor (lib: " ) + m_CurrentLib + wxT( ")" ) );
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
SetBaseScreen( s_screenModule );
|
|
|
|
|
ActiveScreen = GetScreen();
|
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
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER );
|
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();
|
|
|
|
|
|
2009-02-07 14:13:16 +00:00
|
|
|
|
if( config )
|
|
|
|
|
{
|
|
|
|
|
long gridselection = 1;
|
|
|
|
|
config->Read( MODEDIT_CURR_GRID, &gridselection );
|
|
|
|
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + gridselection );
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( DrawPanel )
|
|
|
|
|
DrawPanel->m_Block_Enable = TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/****************************************************/
|
|
|
|
|
{
|
2009-09-27 11:00:21 +00:00
|
|
|
|
/* g_ModuleEditor_Pcb and its correspondinf PCB_SCREEN are not deleted here,
|
|
|
|
|
* because if we reopen the Footprint editor, we expect to find the last edited item
|
|
|
|
|
*/
|
|
|
|
|
SetBaseScreen( NULL ); /* Do not delete (by the destructor of WinEDA_DrawFrame)
|
|
|
|
|
* the PCB_SCREEN handling g_ModuleEditor_Pcb
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) GetParent();
|
2008-12-08 15:27:13 +00:00
|
|
|
|
frame->m_ModuleEditFrame = NULL;
|
2009-09-27 11:00:21 +00:00
|
|
|
|
ActiveScreen = frame->GetScreen();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**************************************************************/
|
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
|
wxConfig* config = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
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();
|
2008-12-08 15:27:13 +00:00
|
|
|
|
if( config )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
2009-02-07 14:13:16 +00:00
|
|
|
|
config->Write( MODEDIT_CURR_GRID, m_SelGridBox->GetSelection() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
void WinEDA_ModuleEditFrame::SetToolbars()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*********************************************/
|
|
|
|
|
{
|
2009-09-27 11:00:21 +00:00
|
|
|
|
size_t i;
|
|
|
|
|
bool active, islib = TRUE;
|
2008-12-08 15:27:13 +00:00
|
|
|
|
WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) wxGetApp().GetTopWindow();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
if( m_HToolBar == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if( m_CurrentLib == wxEmptyString )
|
2009-04-07 07:24:33 +00:00
|
|
|
|
islib = false;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_SAVE_LIBMODULE, islib );
|
2009-09-22 12:27:57 +00:00
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_DELETE_PART, islib );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
|
if( GetBoard()->m_Modules == NULL )
|
2009-04-07 07:24:33 +00:00
|
|
|
|
active = false;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
else
|
|
|
|
|
active = TRUE;
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_EXPORT_PART, active );
|
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
|
2008-12-05 16:03:05 +00:00
|
|
|
|
active );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_SAVE_LIBMODULE, active && islib );
|
2009-01-05 05:21:35 +00:00
|
|
|
|
MODULE* module_in_edit = GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( module_in_edit && module_in_edit->m_Link ) // this is not a new module ...
|
|
|
|
|
{
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( source_module )
|
|
|
|
|
{
|
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, false );
|
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, true );
|
|
|
|
|
}
|
|
|
|
|
else // The source was deleted, therefore we can insert but not update the module
|
|
|
|
|
{
|
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, true );
|
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, false );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, active );
|
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( GetScreen() )
|
|
|
|
|
{
|
2009-09-27 11:00:21 +00:00
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_UNDO, GetScreen()->GetUndoCommandCount()>0 && active );
|
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_REDO, GetScreen()->GetRedoCommandCount()>0 && active );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
|
if( frame->GetBoard()->m_Modules )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, TRUE );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-04-07 07:24:33 +00:00
|
|
|
|
m_HToolBar->EnableTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( m_VToolBar )
|
|
|
|
|
{
|
|
|
|
|
m_VToolBar->EnableTool( ID_MODEDIT_ADD_PAD, active );
|
2009-09-22 12:27:57 +00:00
|
|
|
|
m_VToolBar->EnableTool( ID_PCB_ADD_LINE_BUTT, active );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_VToolBar->EnableTool( ID_PCB_CIRCLE_BUTT, active );
|
|
|
|
|
m_VToolBar->EnableTool( ID_PCB_ARC_BUTT, active );
|
2009-09-22 12:27:57 +00:00
|
|
|
|
m_VToolBar->EnableTool( ID_PCB_ADD_TEXT_BUTT, active );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_VToolBar->EnableTool( ID_MODEDIT_PLACE_ANCHOR, active );
|
|
|
|
|
m_VToolBar->EnableTool( ID_PCB_DELETE_ITEM_BUTT, active );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( m_OptionsToolBar )
|
|
|
|
|
{
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM,
|
2009-04-07 07:24:33 +00:00
|
|
|
|
g_UnitMetric == MILLIMETRE ? TRUE : false );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
|
2009-04-07 07:24:33 +00:00
|
|
|
|
g_UnitMetric == INCHES ? TRUE : false );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
|
|
|
|
|
DisplayOpt.DisplayPolarCood );
|
2009-06-06 18:08:49 +00:00
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD,
|
2009-09-27 11:00:21 +00:00
|
|
|
|
DisplayOpt.DisplayPolarCood ?
|
|
|
|
|
_( "Polar Coords not show" ) :
|
|
|
|
|
_( "Display Polar Coords" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID,
|
|
|
|
|
m_Draw_Grid );
|
2009-06-06 18:08:49 +00:00
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID,
|
2009-09-27 11:00:21 +00:00
|
|
|
|
m_Draw_Grid ? _( "Grid not show" ) : _( "Show Grid" ) );
|
2009-06-06 18:08:49 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
|
2009-04-05 20:49:15 +00:00
|
|
|
|
m_CursorShape );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2009-09-29 04:44:35 +00:00
|
|
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
|
|
|
|
|
!m_DisplayViaFill );
|
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
|
|
|
|
|
m_DisplayViaFill ?
|
|
|
|
|
_( "Show Vias Sketch mode" ) :
|
|
|
|
|
_( "Show vias filled mode" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
|
|
|
|
!m_DisplayPadFill );
|
2009-06-06 18:08:49 +00:00
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
2009-09-27 11:00:21 +00:00
|
|
|
|
m_DisplayPadFill ?
|
|
|
|
|
_( "Show Pads Sketch mode" ) :
|
|
|
|
|
_( "Show pads filled mode" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( m_AuxiliaryToolBar )
|
|
|
|
|
{
|
2009-01-31 21:42:05 +00:00
|
|
|
|
unsigned jj;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( m_SelZoomBox )
|
|
|
|
|
{
|
2009-02-06 11:45:35 +00:00
|
|
|
|
bool not_found = true;
|
|
|
|
|
for( jj = 0; jj < GetScreen()->m_ZoomList.GetCount(); jj++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
2009-01-29 14:26:20 +00:00
|
|
|
|
if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[jj] )
|
|
|
|
|
{
|
|
|
|
|
m_SelZoomBox->SetSelection( jj + 1 );
|
2009-02-06 11:45:35 +00:00
|
|
|
|
not_found = false;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
break;
|
2009-01-29 14:26:20 +00:00
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
|
|
if( not_found )
|
2009-02-06 11:45:35 +00:00
|
|
|
|
m_SelZoomBox->SetSelection( -1 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( m_SelGridBox && GetScreen() )
|
|
|
|
|
{
|
|
|
|
|
int kk = m_SelGridBox->GetChoice();
|
2008-12-05 16:03:05 +00:00
|
|
|
|
for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
2008-12-05 16:03:05 +00:00
|
|
|
|
if( ( GetScreen()->GetGrid() == GetScreen()->m_GridList[i].m_Size ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
2009-09-27 11:00:21 +00:00
|
|
|
|
if( kk != (int) i )
|
|
|
|
|
m_SelGridBox->SetSelection( (int) i );
|
|
|
|
|
kk = (int) i;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DisplayUnitsMsg();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
2009-02-05 20:53:08 +00:00
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
2009-02-05 20:53:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* Display 3D frame of footprint (module) being edited.
|
|
|
|
|
*/
|
|
|
|
|
void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event )
|
|
|
|
|
{
|
|
|
|
|
if( m_Draw3DFrame )
|
|
|
|
|
{
|
2009-04-17 08:51:02 +00:00
|
|
|
|
DisplayInfoMessage( this, _( "3D Frame already opened" ) );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ) );
|
|
|
|
|
m_Draw3DFrame->Show( TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
2009-02-05 20:53:08 +00:00
|
|
|
|
void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
|
|
|
|
|
{
|
2009-09-27 11:00:21 +00:00
|
|
|
|
wxRealPoint delta;
|
|
|
|
|
wxPoint curpos, oldpos;
|
|
|
|
|
int hotkey = 0;
|
2009-02-05 20:53:08 +00:00
|
|
|
|
|
|
|
|
|
if( GetScreen()->IsRefreshReq() )
|
|
|
|
|
{
|
|
|
|
|
RedrawActiveWindow( DC, TRUE );
|
|
|
|
|
|
|
|
|
|
// We must return here, instead of proceeding.
|
|
|
|
|
// If we let the cursor move during a refresh request,
|
|
|
|
|
// the cursor be displayed in the wrong place
|
|
|
|
|
// during delayed repaint events that occur when
|
|
|
|
|
// you move the mouse when a message dialog is on
|
|
|
|
|
// the screen, and then you dismiss the dialog by
|
|
|
|
|
// typing the Enter key.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
curpos = DrawPanel->CursorRealPosition( Mouse );
|
|
|
|
|
oldpos = GetScreen()->m_Curseur;
|
|
|
|
|
|
|
|
|
|
delta = GetScreen()->GetGrid();
|
|
|
|
|
GetScreen()->Scale( delta );
|
|
|
|
|
|
|
|
|
|
if( delta.x == 0 )
|
|
|
|
|
delta.x = 1;
|
|
|
|
|
if( delta.y == 0 )
|
|
|
|
|
delta.y = 1;
|
|
|
|
|
|
|
|
|
|
switch( g_KeyPressed )
|
|
|
|
|
{
|
|
|
|
|
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
|
|
|
|
|
case WXK_UP:
|
2009-09-27 11:00:21 +00:00
|
|
|
|
Mouse.y -= wxRound( delta.y );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
DrawPanel->MouseTo( Mouse );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
|
|
|
|
|
case WXK_DOWN:
|
2009-09-27 11:00:21 +00:00
|
|
|
|
Mouse.y += wxRound( delta.y );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
DrawPanel->MouseTo( Mouse );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */
|
|
|
|
|
case WXK_LEFT:
|
2009-09-27 11:00:21 +00:00
|
|
|
|
Mouse.x -= wxRound( delta.x );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
DrawPanel->MouseTo( Mouse );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */
|
|
|
|
|
case WXK_RIGHT:
|
2009-09-27 11:00:21 +00:00
|
|
|
|
Mouse.x += wxRound( delta.x );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
DrawPanel->MouseTo( Mouse );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
hotkey = g_KeyPressed;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Recalcul de la position du curseur schema */
|
|
|
|
|
GetScreen()->m_Curseur = curpos;
|
|
|
|
|
|
|
|
|
|
/* Placement sur la grille generale */
|
|
|
|
|
PutOnGrid( &GetScreen()->m_Curseur );
|
|
|
|
|
|
|
|
|
|
if( oldpos != GetScreen()->m_Curseur )
|
|
|
|
|
{
|
|
|
|
|
curpos = GetScreen()->m_Curseur;
|
|
|
|
|
GetScreen()->m_Curseur = oldpos;
|
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
|
|
|
|
|
|
GetScreen()->m_Curseur = curpos;
|
|
|
|
|
DrawPanel->CursorOn( DC );
|
|
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
|
{
|
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( hotkey )
|
|
|
|
|
{
|
|
|
|
|
OnHotKey( DC, hotkey, NULL );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( GetScreen()->IsRefreshReq() )
|
|
|
|
|
{
|
|
|
|
|
RedrawActiveWindow( DC, TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetToolbars();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
UpdateStatusBar(); /* Affichage des coord curseur */
|
2009-02-05 20:53:08 +00:00
|
|
|
|
}
|
2009-02-06 11:45:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************/
|
|
|
|
|
void WinEDA_ModuleEditFrame::OnSelectGrid( wxCommandEvent& event )
|
|
|
|
|
/******************************************************************/
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
2009-02-06 11:45:35 +00:00
|
|
|
|
// Virtual function
|
|
|
|
|
{
|
|
|
|
|
if( m_SelGridBox == NULL )
|
|
|
|
|
return; // Should not occurs
|
2009-02-07 08:33:25 +00:00
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
|
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER );
|
2009-02-06 11:45:35 +00:00
|
|
|
|
|
|
|
|
|
WinEDA_DrawFrame::OnSelectGrid( event );
|
|
|
|
|
|
|
|
|
|
// If the user grid is the current selection , ensure grid size value = new user grid value
|
|
|
|
|
int ii = m_SelGridBox->GetSelection();
|
2009-09-27 11:00:21 +00:00
|
|
|
|
if( ii == (int) ( m_SelGridBox->GetCount() - 1 ) )
|
2009-02-06 11:45:35 +00:00
|
|
|
|
{
|
|
|
|
|
GetScreen()->SetGrid( ID_POPUP_GRID_USER );
|
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|