2011-11-08 16:37:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2012 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>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <3d_viewer.h>
|
|
|
|
#include <pcbcommon.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 <protos.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <hotkeys.h>
|
|
|
|
#include <module_editor_frame.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2009-02-05 20:53:08 +00:00
|
|
|
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
static PCB_SCREEN* s_screenModule; // the PCB_SCREEN used by the footprint editor
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
BOARD* FOOTPRINT_EDIT_FRAME::s_Pcb;
|
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 )
|
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_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
|
|
|
|
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 )
|
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 )
|
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 )
|
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
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
#define FOOTPRINT_EDIT_FRAME_NAME wxT( "ModEditFrame" )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent, FP_LIB_TABLE* aTable ) :
|
2012-09-12 09:53:11 +00:00
|
|
|
PCB_BASE_FRAME( aParent, MODULE_EDITOR_FRAME_TYPE, wxEmptyString,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-09-12 09:53:11 +00:00
|
|
|
m_FrameName = GetFootprintEditorFrameName();
|
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;
|
2013-05-28 16:54:59 +00:00
|
|
|
m_footprintLibTable = aTable;
|
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
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( !s_Pcb )
|
2012-02-26 18:49:00 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
s_Pcb = new BOARD();
|
2012-11-19 16:19:38 +00:00
|
|
|
|
2012-02-26 18:49:00 +00:00
|
|
|
// Ensure all layers and items are visible:
|
|
|
|
s_Pcb->SetVisibleAlls();
|
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
SetBoard( s_Pcb );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
if( !s_screenModule )
|
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 );
|
2012-02-02 17:45:37 +00:00
|
|
|
|
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
|
|
|
|
2012-08-31 07:43:37 +00:00
|
|
|
GetBoard()->SetVisibleAlls();
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
SetPageSettings( PAGE_INFO::A4 );
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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() );
|
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
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
// When user reopens the Footprint editor, user would like to find the last edited item.
|
|
|
|
// Do not delete PCB_SCREEN (by the destructor of EDA_DRAW_FRAME)
|
|
|
|
SetScreen( NULL );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Do not allow PCB_BASE_FRAME::~PCB_BASE_FRAME()
|
|
|
|
// to delete our precious BOARD, which is also in static FOOTPRINT_EDIT_FRAME::s_Pcb.
|
|
|
|
// That function, PCB_BASE_FRAME::~PCB_BASE_FRAME(), runs immediately next
|
|
|
|
// as we return from here.
|
|
|
|
m_Pcb = 0;
|
|
|
|
}
|
|
|
|
|
2013-11-19 17:24:45 +00:00
|
|
|
|
|
|
|
const wxString& FOOTPRINT_EDIT_FRAME::getLibNickName() const
|
|
|
|
{
|
|
|
|
return wxGetApp().GetModuleLibraryNickname();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::setLibNickName( const wxString& aNickname )
|
|
|
|
{
|
|
|
|
wxGetApp().SetModuleLibraryNickname( aNickname );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-13 21:33:58 +00:00
|
|
|
wxString FOOTPRINT_EDIT_FRAME::getLibPath()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-11-19 17:24:45 +00:00
|
|
|
const wxString& nickname = getLibNickName();
|
|
|
|
|
|
|
|
const FP_LIB_TABLE::ROW* row = GetFootprintLibraryTable()->FindRow( nickname );
|
|
|
|
|
2013-10-13 21:33:58 +00:00
|
|
|
return row->GetFullURI( true );
|
|
|
|
}
|
|
|
|
catch( IO_ERROR ioe )
|
|
|
|
{
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
}
|
2013-12-12 16:01:03 +00:00
|
|
|
|
2013-05-28 16:54:59 +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-09-12 09:53:11 +00:00
|
|
|
/* return a reference to the current opened Footprint editor
|
|
|
|
* or NULL if no Footprint editor currently opened
|
|
|
|
*/
|
|
|
|
FOOTPRINT_EDIT_FRAME* FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor()
|
|
|
|
{
|
2013-05-28 16:54:59 +00:00
|
|
|
return (FOOTPRINT_EDIT_FRAME*) wxWindow::FindWindowByName( GetFootprintEditorFrameName() );
|
2012-09-12 09:53:11 +00:00
|
|
|
}
|
2012-02-02 17:45:37 +00:00
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& FOOTPRINT_EDIT_FRAME::GetDesignSettings() const
|
|
|
|
{
|
|
|
|
// get the BOARD_DESIGN_SETTINGS from the parent editor, not our BOARD.
|
|
|
|
|
|
|
|
PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) GetParent();
|
|
|
|
|
|
|
|
wxASSERT( parentFrame );
|
|
|
|
|
|
|
|
return parentFrame->GetDesignSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings )
|
|
|
|
{
|
2012-04-11 23:30:06 +00:00
|
|
|
// set the BOARD_DESIGN_SETTINGS into parent editor, not our BOARD.
|
2012-02-02 17:45:37 +00:00
|
|
|
|
|
|
|
PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) GetParent();
|
|
|
|
|
|
|
|
wxASSERT( parentFrame );
|
|
|
|
|
|
|
|
parentFrame->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.
|
|
|
|
|
|
|
|
PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) GetParent();
|
|
|
|
|
|
|
|
wxASSERT( parentFrame );
|
|
|
|
|
|
|
|
return parentFrame->GetPlotSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::SetPlotSettings( const PCB_PLOT_PARAMS& aSettings )
|
|
|
|
{
|
|
|
|
// set the settings into parent editor, not our BOARD.
|
|
|
|
|
|
|
|
PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) GetParent();
|
|
|
|
|
|
|
|
wxASSERT( parentFrame );
|
|
|
|
|
|
|
|
parentFrame->SetPlotSettings( aSettings );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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() )
|
|
|
|
{
|
2013-02-07 17:35:37 +00:00
|
|
|
int ii = DisplayExitDialog( this, _( "Save the changes in the module before closing?" ) );
|
|
|
|
|
|
|
|
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
|
2013-11-27 06:04:04 +00:00
|
|
|
if( GetBoard()->m_Modules && getLibNickName().size() )
|
|
|
|
{
|
|
|
|
if( Save_Module_In_Library( getLibNickName(), GetBoard()->m_Modules, true, true ) )
|
2013-02-07 17:35:37 +00:00
|
|
|
{
|
|
|
|
// save was correct
|
|
|
|
GetScreen()->ClrModify();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Library is not set, the module could not be saved." ) );
|
|
|
|
}
|
|
|
|
// 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
|
|
|
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
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
aEvent.Enable( getLibPath() != wxEmptyString );
|
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
|
|
|
{
|
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;
|
2013-03-13 18:53:58 +00:00
|
|
|
bool canInsert = ( 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.
|
2013-03-13 18:53:58 +00:00
|
|
|
if( 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
|
|
|
{
|
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;
|
2013-03-13 18:53:58 +00:00
|
|
|
bool canReplace = ( module_in_edit && module_in_edit->GetLink() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( module_in_edit && module_in_edit->GetLink() ) // 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
|
|
|
{
|
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 )
|
|
|
|
{
|
|
|
|
aEvent.Enable( m_footprintLibTable && !m_footprintLibTable->IsEmpty() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
|
|
|
if( snapToGrid )
|
2013-08-03 05:15:23 +00:00
|
|
|
pos = GetNearestGridPosition( pos );
|
2012-08-11 12:52:13 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
oldpos = 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:
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
pos.y -= KiROUND( 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:
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
pos.y += KiROUND( 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:
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
pos.x -= KiROUND( 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:
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
pos.x += KiROUND( 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;
|
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( pos, snapToGrid );
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
if( oldpos != GetCrossHairPosition() )
|
2009-02-05 20:53:08 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
pos = GetCrossHairPosition();
|
|
|
|
SetCrossHairPosition( oldpos, false );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( aDC );
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( pos, snapToGrid );
|
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
|
|
|
|
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::updateTitle()
|
2011-08-08 15:44:43 +00:00
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
wxString title = _( "Module Editor " );
|
2013-11-19 17:24:45 +00:00
|
|
|
|
|
|
|
wxString nickname = getLibNickName();
|
|
|
|
|
|
|
|
if( !nickname )
|
|
|
|
{
|
|
|
|
L_none:
|
|
|
|
title += _( "(no active library)" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
bool writable = m_footprintLibTable->IsFootprintLibWritable( nickname );
|
|
|
|
|
|
|
|
// no exception was thrown, this means libPath is valid, but it may be read only.
|
|
|
|
title = _( "Module Editor (active library: " ) + nickname + wxT( ")" );
|
|
|
|
|
|
|
|
if( !writable )
|
|
|
|
title += _( " [Read Only]" );
|
|
|
|
}
|
|
|
|
catch( IO_ERROR ioe )
|
|
|
|
{
|
|
|
|
// 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
|
|
|
}
|