2009-11-09 14:00:22 +00:00
|
|
|
/*******************/
|
|
|
|
/* gerberframe.cpp */
|
|
|
|
/*******************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-03-28 20:02:34 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "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"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "gerbview.h"
|
2010-09-28 14:42:05 +00:00
|
|
|
#include "class_gerber_draw_item.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "bitmaps.h"
|
2010-01-24 13:46:01 +00:00
|
|
|
#include "gerbview_id.h"
|
2010-02-14 18:14:33 +00:00
|
|
|
#include "hotkeys.h"
|
2010-10-06 17:28:07 +00:00
|
|
|
#include "class_GERBER.h"
|
2010-11-18 21:16:28 +00:00
|
|
|
#include "dialog_helpers.h"
|
2010-12-17 20:34:29 +00:00
|
|
|
#include "class_DCodeSelectionbox.h"
|
2010-10-06 17:28:07 +00:00
|
|
|
|
|
|
|
#include "build_version.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
/****************************************/
|
|
|
|
/* class WinEDA_GerberFrame for GerbView*/
|
|
|
|
/****************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame )
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_CLOSE( WinEDA_GerberFrame::OnCloseWindow )
|
|
|
|
EVT_SIZE( WinEDA_GerberFrame::OnSize )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_GerberFrame::OnZoom )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_TOOL( wxID_FILE, WinEDA_GerberFrame::Files_io )
|
|
|
|
EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
|
|
|
|
EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, WinEDA_GerberFrame::Files_io )
|
|
|
|
EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, WinEDA_GerberFrame::Files_io )
|
|
|
|
EVT_TOOL( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// Menu Files:
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_MENU( wxID_FILE, WinEDA_GerberFrame::Files_io )
|
|
|
|
EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
|
|
|
|
EVT_MENU( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
|
|
|
|
EVT_MENU( ID_GEN_PLOT, WinEDA_GerberFrame::ToPlotter )
|
|
|
|
EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW,
|
|
|
|
WinEDA_GerberFrame::ExportDataInPcbnewFormat )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, WinEDA_GerberFrame::OnFileHistory )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_MENU( ID_EXIT, WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
// menu Preferences
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_MENU( ID_CONFIG_REQ,
|
|
|
|
WinEDA_GerberFrame::Process_Config )
|
|
|
|
EVT_MENU( ID_CONFIG_SAVE,
|
|
|
|
WinEDA_GerberFrame::Process_Config )
|
|
|
|
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START,
|
|
|
|
ID_PREFERENCES_HOTKEY_END,
|
|
|
|
WinEDA_GerberFrame::Process_Config )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
|
|
|
|
WinEDA_GerberFrame::OnSelectOptionToolbar )
|
|
|
|
EVT_MENU( ID_GERBVIEW_OPTIONS_SETUP, WinEDA_GerberFrame::InstallGerberOptionsDialog )
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::SetLanguage )
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// menu Postprocess
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES,
|
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
|
|
|
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS,
|
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
|
|
|
EVT_MENU( ID_GERBVIEW_SHOW_SOURCE,
|
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// menu Miscellaneous
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE,
|
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// Menu Help
|
2011-01-21 19:30:59 +00:00
|
|
|
EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp )
|
|
|
|
EVT_MENU( ID_KICAD_ABOUT, EDA_DRAW_FRAME::GetKicadAbout )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_TOOL( wxID_CUT, WinEDA_GerberFrame::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_COPY, WinEDA_GerberFrame::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_PASTE, WinEDA_GerberFrame::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_UNDO, WinEDA_GerberFrame::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_PRINT, WinEDA_GerberFrame::ToPrinter )
|
|
|
|
EVT_TOOL( ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions )
|
|
|
|
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_LAYER,
|
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_TOOL,
|
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// Vertical toolbar:
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_GERBVIEW_DELETE_ITEM_BUTT,
|
2009-11-09 14:00:22 +00:00
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
|
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// Pop up menu
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS,
|
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// Option toolbar
|
2010-12-17 20:34:29 +00:00
|
|
|
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
|
|
|
|
WinEDA_GerberFrame::OnSelectOptionToolbar )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH,
|
|
|
|
WinEDA_GerberFrame::OnSelectOptionToolbar )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH,
|
|
|
|
WinEDA_GerberFrame::OnSelectOptionToolbar )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
|
|
|
|
WinEDA_GerberFrame::OnSelectOptionToolbar )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES,
|
|
|
|
WinEDA_GerberFrame::OnSelectOptionToolbar )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_0,
|
|
|
|
WinEDA_GerberFrame::OnSelectDisplayMode )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_1,
|
|
|
|
WinEDA_GerberFrame::OnSelectDisplayMode )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_2,
|
|
|
|
WinEDA_GerberFrame::OnSelectDisplayMode )
|
|
|
|
|
|
|
|
END_EVENT_TABLE() WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
|
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style ) :
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_BasePcbFrame( father, GERBER_FRAME, title, pos, size, style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
m_FrameName = wxT( "GerberFrame" );
|
2010-02-03 14:05:17 +00:00
|
|
|
m_show_layer_manager_tools = true;
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
m_Draw_Axis = true; // true to show X and Y axis on screen
|
2010-07-27 12:47:08 +00:00
|
|
|
m_Draw_Sheet_Ref = false; // true for reference drawings.
|
2010-02-14 18:14:33 +00:00
|
|
|
m_HotkeysZoomAndGridList = s_Gerbview_Hokeys_Descr;
|
2010-12-17 20:34:29 +00:00
|
|
|
m_SelLayerBox = NULL;
|
|
|
|
m_DCodeSelector = NULL;
|
|
|
|
m_displayMode = 0;
|
2010-07-27 12:47:08 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
if( DrawPanel )
|
2010-07-27 12:47:08 +00:00
|
|
|
DrawPanel->m_Block_Enable = true;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
// Give an icon
|
2009-05-21 17:42:42 +00:00
|
|
|
#ifdef __WINDOWS__
|
2008-04-17 16:25:29 +00:00
|
|
|
SetIcon( wxICON( a_icon_gerbview ) );
|
2009-05-21 17:42:42 +00:00
|
|
|
#else
|
2008-04-17 16:25:29 +00:00
|
|
|
SetIcon( wxICON( icon_gerbview ) );
|
2009-05-21 17:42:42 +00:00
|
|
|
#endif
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
SetBaseScreen( ScreenPcb );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
SetBoard( new BOARD( NULL, this ) );
|
|
|
|
GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first.
|
2009-11-09 14:00:22 +00:00
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
// Create the PCB_LAYER_WIDGET *after* SetBoard():
|
|
|
|
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
2010-12-17 20:34:29 +00:00
|
|
|
int pointSize = font.GetPointSize();
|
|
|
|
int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
if( screenHeight <= 900 )
|
|
|
|
pointSize = (pointSize * 8) / 10;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
m_LayersManager = new GERBER_LAYER_WIDGET( this, DrawPanel, pointSize );
|
|
|
|
|
|
|
|
// LoadSettings() *after* creating m_LayersManager, because LoadSettings()
|
|
|
|
// initialize parameters in m_LayersManager
|
|
|
|
LoadSettings();
|
2008-04-17 16:25:29 +00:00
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
2009-11-07 14:45:14 +00:00
|
|
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
2010-12-17 20:34:29 +00:00
|
|
|
if( GetDisplayMode() == 1 || GetDisplayMode() == 2 )
|
|
|
|
DrawPanel->m_DisableEraseBG = true;
|
2009-11-07 14:45:14 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
2010-12-17 20:34:29 +00:00
|
|
|
|
2010-10-13 19:50:23 +00:00
|
|
|
// ReCreateVToolbar(); // Currently: no right vertical toolbar
|
2008-04-17 16:25:29 +00:00
|
|
|
ReCreateOptToolbar();
|
2009-11-09 14:00:22 +00:00
|
|
|
|
|
|
|
m_auimgr.SetManagedWindow( this );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
|
|
|
wxAuiPaneInfo horiz;
|
2009-11-09 14:00:22 +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-09 14:00:22 +00:00
|
|
|
wxAuiPaneInfo vert( horiz );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
vert.TopDockable( false ).BottomDockable( false );
|
|
|
|
horiz.LeftDockable( false ).RightDockable( false );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
// LAYER_WIDGET is floatable, but initially docked at far right
|
2010-12-17 20:34:29 +00:00
|
|
|
wxAuiPaneInfo lyrs;
|
2010-02-03 14:05:17 +00:00
|
|
|
lyrs.CloseButton( false );
|
|
|
|
lyrs.Caption( _( "Visibles" ) );
|
|
|
|
lyrs.IsFloatable();
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_HToolBar )
|
|
|
|
m_auimgr.AddPane( m_HToolBar,
|
2010-12-17 20:34:29 +00:00
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_VToolBar )
|
|
|
|
m_auimgr.AddPane( m_VToolBar,
|
2010-12-17 20:34:29 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Row( 1 ) );
|
2010-02-03 14:05:17 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
m_auimgr.AddPane( m_LayersManager,
|
2010-12-17 20:34:29 +00:00
|
|
|
lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Row( 0 ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_OptionsToolBar )
|
|
|
|
m_auimgr.AddPane( m_OptionsToolBar,
|
2010-12-17 20:34:29 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( DrawPanel )
|
|
|
|
m_auimgr.AddPane( DrawPanel,
|
2010-12-17 20:34:29 +00:00
|
|
|
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( MsgPanel )
|
|
|
|
m_auimgr.AddPane( MsgPanel,
|
2010-12-17 20:34:29 +00:00
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-02-26 15:39:10 +00:00
|
|
|
ReFillLayerWidget(); // this is near end because contents establish size
|
|
|
|
|
2010-11-05 08:14:00 +00:00
|
|
|
SetToolbars();
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
WinEDA_GerberFrame::~WinEDA_GerberFrame()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
SetBaseScreen( ScreenPcb );
|
2009-03-28 20:02:34 +00:00
|
|
|
extern PARAM_CFG_BASE* ParamCfgList[];
|
|
|
|
wxGetApp().SaveCurrentSetupValues( ParamCfgList );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
SaveSettings();
|
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
int WinEDA_GerberFrame::BestZoom()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-11-08 14:27:02 +00:00
|
|
|
// gives a minimal value to zoom, if no item in list
|
|
|
|
if( GetBoard()->m_Drawings == NULL )
|
2010-12-17 20:34:29 +00:00
|
|
|
return 16 * GetScreen()->m_ZoomScalar;
|
2010-11-08 14:27:02 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
double x, y;
|
|
|
|
EDA_Rect bbox;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
BOARD_ITEM* item = GetBoard()->m_Drawings;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
for( ; item; item = item->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2010-09-28 14:42:05 +00:00
|
|
|
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
|
|
|
|
bbox.Merge( gerb_item->GetBoundingBox() );
|
2010-05-17 20:35:46 +00:00
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
|
|
|
bbox.Inflate( wxRound( GetScreen()->GetGridSize().x * 2 ),
|
2010-12-17 20:34:29 +00:00
|
|
|
wxRound( GetScreen()->GetGridSize().y * 2 ) );
|
2010-09-28 14:42:05 +00:00
|
|
|
wxSize size = DrawPanel->GetClientSize();
|
2010-11-08 14:27:02 +00:00
|
|
|
x = bbox.GetWidth() / (double) size.x;
|
|
|
|
y = bbox.GetHeight() / (double) size.y;
|
2010-09-28 14:42:05 +00:00
|
|
|
GetScreen()->m_Curseur = bbox.Centre();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
int best_zoom = wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar );
|
|
|
|
return best_zoom;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
void WinEDA_GerberFrame::LoadSettings()
|
|
|
|
{
|
|
|
|
wxConfig* config = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
|
|
if( config == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
WinEDA_BasePcbFrame::LoadSettings();
|
2010-12-15 20:15:24 +00:00
|
|
|
config->Read( GerbviewDrawModeOption, &m_displayMode, 0l );
|
2009-11-22 20:55:05 +00:00
|
|
|
long pageSize_opt;
|
|
|
|
config->Read( GerbviewShowPageSizeOption, &pageSize_opt, 0l );
|
2010-12-17 20:34:29 +00:00
|
|
|
int imax = 0;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
for( ; g_GerberPageSizeList[imax] != NULL; imax++ )
|
|
|
|
;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
if( pageSize_opt < 0 || pageSize_opt >= imax )
|
|
|
|
pageSize_opt = 0;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
GetScreen()->m_CurrentSheetDesc = g_GerberPageSizeList[pageSize_opt];
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
if( pageSize_opt > 0 )
|
2009-11-22 20:55:05 +00:00
|
|
|
{
|
|
|
|
m_Draw_Sheet_Ref = true;
|
|
|
|
}
|
2010-02-03 14:05:17 +00:00
|
|
|
|
|
|
|
long tmp;
|
2010-05-17 20:35:46 +00:00
|
|
|
config->Read( GerbviewShowDCodes, &tmp, 1 );
|
|
|
|
SetElementVisibility( DCODES_VISIBLE, tmp );
|
2009-11-22 20:55:05 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
void WinEDA_GerberFrame::SaveSettings()
|
|
|
|
{
|
|
|
|
wxConfig* config = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
|
|
if( config == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
WinEDA_BasePcbFrame::SaveSettings();
|
|
|
|
|
|
|
|
wxRealPoint GridSize = GetScreen()->GetGridSize();
|
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
long pageSize_opt = 0;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
if( m_Draw_Sheet_Ref )
|
|
|
|
{
|
|
|
|
for( int ii = 1; g_GerberPageSizeList[ii] != NULL; ii++ )
|
|
|
|
{
|
|
|
|
if( GetScreen()->m_CurrentSheetDesc == g_GerberPageSizeList[ii] )
|
|
|
|
{
|
|
|
|
pageSize_opt = ii;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-15 20:15:24 +00:00
|
|
|
|
|
|
|
config->Write( GerbviewDrawModeOption, m_displayMode );
|
2009-11-22 20:55:05 +00:00
|
|
|
config->Write( GerbviewShowPageSizeOption, pageSize_opt );
|
2010-05-17 20:35:46 +00:00
|
|
|
config->Write( GerbviewShowDCodes, IsElementVisible( DCODES_VISIBLE ) );
|
2010-02-03 14:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_GerberFrame::ReFillLayerWidget()
|
|
|
|
{
|
|
|
|
m_LayersManager->ReFill();
|
|
|
|
|
|
|
|
wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
|
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
wxSize bestz = m_LayersManager->GetBestSize();
|
2010-02-03 14:05:17 +00:00
|
|
|
|
|
|
|
lyrs.MinSize( bestz );
|
|
|
|
lyrs.BestSize( bestz );
|
|
|
|
lyrs.FloatingSize( bestz );
|
|
|
|
|
|
|
|
if( lyrs.IsDocked() )
|
|
|
|
m_auimgr.Update();
|
|
|
|
else
|
|
|
|
m_LayersManager->SetSize( bestz );
|
2010-02-14 18:14:33 +00:00
|
|
|
|
2010-05-17 20:35:46 +00:00
|
|
|
syncLayerWidget();
|
2010-02-03 14:05:17 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function IsGridVisible() , virtual
|
2010-02-03 14:05:17 +00:00
|
|
|
* @return true if the grid must be shown
|
|
|
|
*/
|
|
|
|
bool WinEDA_GerberFrame::IsGridVisible()
|
|
|
|
{
|
2010-05-17 20:35:46 +00:00
|
|
|
return IsElementVisible( GERBER_GRID_VISIBLE );
|
2010-02-03 14:05:17 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function SetGridVisibility() , virtual
|
2010-02-03 14:05:17 +00:00
|
|
|
* It may be overloaded by derived classes
|
|
|
|
* if you want to store/retrieve the grid visiblity in configuration.
|
|
|
|
* @param aVisible = true if the grid must be shown
|
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void WinEDA_GerberFrame::SetGridVisibility( bool aVisible )
|
2010-02-03 14:05:17 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
SetElementVisibility( GERBER_GRID_VISIBLE, aVisible );
|
2010-02-03 14:05:17 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function GetGridColor() , virtual
|
2010-02-03 14:05:17 +00:00
|
|
|
* @return the color of the grid
|
|
|
|
*/
|
|
|
|
int WinEDA_GerberFrame::GetGridColor()
|
|
|
|
{
|
|
|
|
return GetBoard()->GetVisibleElementColor( GERBER_GRID_VISIBLE );
|
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function SetGridColor() , virtual
|
2010-02-03 14:05:17 +00:00
|
|
|
* @param aColor = the new color of the grid
|
|
|
|
*/
|
2010-12-17 20:34:29 +00:00
|
|
|
void WinEDA_GerberFrame::SetGridColor( int aColor )
|
2010-02-03 14:05:17 +00:00
|
|
|
{
|
|
|
|
GetBoard()->SetVisibleElementColor( GERBER_GRID_VISIBLE, aColor );
|
|
|
|
}
|
|
|
|
|
2010-10-06 17:28:07 +00:00
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
/**
|
|
|
|
* Function SetElementVisibility
|
|
|
|
* changes the visibility of an element category
|
|
|
|
* @param aGERBER_VISIBLE is from the enum by the same name
|
|
|
|
* @param aNewState = The new visibility state of the element category
|
|
|
|
* @see enum aGERBER_VISIBLE
|
|
|
|
*/
|
|
|
|
void WinEDA_GerberFrame::SetElementVisibility( int aGERBER_VISIBLE, bool aNewState )
|
|
|
|
{
|
|
|
|
GetBoard()->SetElementVisibility( aGERBER_VISIBLE, aNewState );
|
|
|
|
m_LayersManager->SetRenderState( aGERBER_VISIBLE, aNewState );
|
2009-11-22 20:55:05 +00:00
|
|
|
}
|
2010-02-04 09:08:08 +00:00
|
|
|
|
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
void WinEDA_GerberFrame::syncLayerWidget()
|
2010-02-04 09:08:08 +00:00
|
|
|
{
|
|
|
|
m_LayersManager->SelectLayer( getActiveLayer() );
|
2010-10-06 17:28:07 +00:00
|
|
|
UpdateTitleAndInfo();
|
2010-02-04 09:08:08 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
|
2010-02-04 09:08:08 +00:00
|
|
|
/**
|
|
|
|
* Function syncLayerBox
|
|
|
|
* updates the currently "selected" layer within m_SelLayerBox
|
|
|
|
* The currently active layer, as defined by the return value of
|
|
|
|
* getActiveLayer(). And updates the colored icon in the toolbar.
|
|
|
|
*/
|
|
|
|
void WinEDA_GerberFrame::syncLayerBox()
|
|
|
|
{
|
|
|
|
m_SelLayerBox->SetSelection( getActiveLayer() );
|
2010-12-17 20:34:29 +00:00
|
|
|
int dcodeSelected = -1;
|
|
|
|
GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer()];
|
|
|
|
if( gerber )
|
|
|
|
dcodeSelected = gerber->m_Selected_Tool;
|
|
|
|
if( m_DCodeSelector )
|
|
|
|
{
|
|
|
|
m_DCodeSelector->SetDCodeSelection( dcodeSelected );
|
|
|
|
m_DCodeSelector->Enable( gerber != NULL );
|
|
|
|
}
|
2010-10-06 17:28:07 +00:00
|
|
|
UpdateTitleAndInfo();
|
2010-02-04 09:08:08 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function SetLanguage
|
2010-02-26 15:39:10 +00:00
|
|
|
* called on a language menu selection
|
|
|
|
* Update Layer manager title and tabs texts
|
|
|
|
*/
|
|
|
|
void WinEDA_GerberFrame::SetLanguage( wxCommandEvent& event )
|
|
|
|
{
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::SetLanguage( event );
|
2010-05-17 20:35:46 +00:00
|
|
|
m_LayersManager->SetLayersManagerTabsText();
|
|
|
|
wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
|
2010-02-26 15:39:10 +00:00
|
|
|
pane_info.Caption( _( "Visibles" ) );
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
ReFillLayerWidget();
|
|
|
|
}
|
2010-09-28 14:42:05 +00:00
|
|
|
|
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
void WinEDA_GerberFrame::Liste_D_Codes()
|
2010-09-28 14:42:05 +00:00
|
|
|
{
|
2010-12-17 20:34:29 +00:00
|
|
|
int ii, jj;
|
2010-09-28 14:42:05 +00:00
|
|
|
D_CODE* pt_D_code;
|
|
|
|
wxString Line;
|
|
|
|
WinEDA_TextFrame* List;
|
|
|
|
int scale = 10000;
|
|
|
|
int curr_layer = GetScreen()->m_Active_Layer;
|
|
|
|
|
|
|
|
List = new WinEDA_TextFrame( this, _( "List D codes" ) );
|
|
|
|
|
|
|
|
for( int layer = 0; layer < 32; layer++ )
|
|
|
|
{
|
2010-10-16 14:51:22 +00:00
|
|
|
GERBER_IMAGE* gerber = g_GERBER_List[layer];
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
if( gerber == NULL )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( gerber->ReturnUsedDcodeNumber() == 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( layer == curr_layer )
|
|
|
|
Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
|
|
|
|
else
|
|
|
|
Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
List->Append( Line );
|
|
|
|
|
|
|
|
for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
|
|
|
|
{
|
|
|
|
pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
if( pt_D_code == NULL )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
|
|
|
|
continue;
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
Line.Printf( wxT( "tool %2.2d: D%2.2d V %2.4f H %2.4f %s" ),
|
2010-09-28 14:42:05 +00:00
|
|
|
jj,
|
|
|
|
pt_D_code->m_Num_Dcode,
|
|
|
|
(float) pt_D_code->m_Size.y / scale,
|
|
|
|
(float) pt_D_code->m_Size.x / scale,
|
|
|
|
D_CODE::ShowApertureType( pt_D_code->m_Shape )
|
|
|
|
);
|
|
|
|
|
|
|
|
if( !pt_D_code->m_Defined )
|
|
|
|
Line += wxT( " ?" );
|
|
|
|
|
|
|
|
if( !pt_D_code->m_InUse )
|
|
|
|
Line += wxT( " *" );
|
|
|
|
|
|
|
|
List->Append( Line );
|
|
|
|
jj++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ii = List->ShowModal();
|
|
|
|
List->Destroy();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
}
|
2010-10-06 17:28:07 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-12-18 18:47:58 +00:00
|
|
|
/*
|
2010-11-12 16:36:43 +00:00
|
|
|
* Function UpdateTitleAndInfo
|
2010-10-06 17:28:07 +00:00
|
|
|
* displays the short filename (if exists) of the selected layer
|
2010-10-08 14:02:49 +00:00
|
|
|
* on the caption of the main gerbview window
|
|
|
|
* displays image name and the last layer name (found in the gerber file: LN <name> command)
|
|
|
|
* in the status bar
|
|
|
|
* Note layer name can change when reading a gerber file, and the layer name is the last found.
|
|
|
|
* So, show the layer name is not very useful, and can be seen as a debug feature.
|
2010-10-06 17:28:07 +00:00
|
|
|
*/
|
|
|
|
void WinEDA_GerberFrame::UpdateTitleAndInfo()
|
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
GERBER_IMAGE* gerber = g_GERBER_List[ GetScreen()->m_Active_Layer ];
|
2010-12-17 20:34:29 +00:00
|
|
|
wxString text;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-10-06 17:28:07 +00:00
|
|
|
// Display the gerber filename
|
|
|
|
if( gerber == NULL )
|
|
|
|
{
|
|
|
|
text = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
|
2010-10-08 14:02:49 +00:00
|
|
|
SetTitle( text );
|
2010-10-06 17:28:07 +00:00
|
|
|
SetStatusText( wxEmptyString, 0 );
|
2010-12-17 20:34:29 +00:00
|
|
|
text.Printf( _( "Layer %d not in use" ), GetScreen()->m_Active_Layer + 1 );
|
2010-12-15 20:15:24 +00:00
|
|
|
m_TextInfo->SetValue( text );
|
2010-10-17 16:42:06 +00:00
|
|
|
ClearMsgPanel();
|
2010-10-06 17:28:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
text = _( "File:" );
|
|
|
|
text << wxT( " " ) << gerber->m_FileName;
|
2010-10-08 14:02:49 +00:00
|
|
|
SetTitle( text );
|
2010-10-09 11:03:03 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
gerber->DisplayImageInfo();
|
2010-10-08 14:02:49 +00:00
|
|
|
|
2010-10-06 17:28:07 +00:00
|
|
|
// Display Image Name and Layer Name (from the current gerber data):
|
2010-12-08 20:12:46 +00:00
|
|
|
text.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
|
2010-12-17 20:34:29 +00:00
|
|
|
GetChars( gerber->m_ImageName ),
|
|
|
|
GetChars( gerber->GetLayerParams().m_LayerName ) );
|
2010-10-06 17:28:07 +00:00
|
|
|
SetStatusText( text, 0 );
|
|
|
|
|
2010-10-08 14:02:49 +00:00
|
|
|
// Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
|
2010-12-17 20:34:29 +00:00
|
|
|
text.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
|
2010-12-08 20:12:46 +00:00
|
|
|
gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
|
|
|
|
gerber->m_FmtLen.x - gerber->m_FmtScale.x, gerber->m_FmtScale.x,
|
|
|
|
gerber->m_FmtLen.y - gerber->m_FmtScale.y, gerber->m_FmtScale.y,
|
|
|
|
gerber->m_NoTrailingZeros ? 'T' : 'L' );
|
2010-10-06 17:28:07 +00:00
|
|
|
|
|
|
|
m_TextInfo->SetValue( text );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-15 20:15:24 +00:00
|
|
|
/* Function OnSelectDisplayMode: called to select display mode
|
|
|
|
* (fast display, or exact mode with stacked images or with transparency
|
|
|
|
*/
|
|
|
|
void WinEDA_GerberFrame::OnSelectDisplayMode( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int oldMode = GetDisplayMode();
|
2010-12-17 20:34:29 +00:00
|
|
|
|
2010-12-15 20:15:24 +00:00
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
2010-12-17 20:34:29 +00:00
|
|
|
case ID_TB_OPTIONS_SHOW_GBR_MODE_0:
|
|
|
|
SetDisplayMode( 0 );
|
|
|
|
DrawPanel->m_DisableEraseBG = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TB_OPTIONS_SHOW_GBR_MODE_1:
|
|
|
|
SetDisplayMode( 1 );
|
|
|
|
DrawPanel->m_DisableEraseBG = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TB_OPTIONS_SHOW_GBR_MODE_2:
|
|
|
|
SetDisplayMode( 2 );
|
|
|
|
DrawPanel->m_DisableEraseBG = true;
|
|
|
|
break;
|
2010-12-15 20:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetToolbars();
|
|
|
|
if( GetDisplayMode() != oldMode )
|
2010-12-17 20:34:29 +00:00
|
|
|
DrawPanel->Refresh();
|
2010-12-15 20:15:24 +00:00
|
|
|
}
|