2009-11-09 14:00:22 +00:00
|
|
|
/*******************/
|
|
|
|
/* gerberframe.cpp */
|
|
|
|
/*******************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#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"
|
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "protos.h"
|
2010-01-24 13:46:01 +00:00
|
|
|
#include "gerbview_id.h"
|
2010-02-14 18:14:33 +00:00
|
|
|
#include "hotkeys.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 )
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_CLOSE( WinEDA_GerberFrame::OnCloseWindow )
|
|
|
|
EVT_SIZE( WinEDA_GerberFrame::OnSize )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_GerberFrame::OnZoom )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-02-04 11:03:31 +00:00
|
|
|
EVT_TOOL( wxID_FILE, WinEDA_GerberFrame::Files_io )
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_TOOL( ID_APPEND_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 )
|
|
|
|
EVT_TOOL( ID_SAVE_BOARD, WinEDA_GerberFrame::Files_io )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// Menu Files:
|
2010-02-04 11:03:31 +00:00
|
|
|
EVT_MENU( wxID_FILE, WinEDA_GerberFrame::Files_io )
|
2009-09-22 12:27:57 +00:00
|
|
|
EVT_MENU( ID_APPEND_FILE, WinEDA_GerberFrame::Files_io )
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
|
2009-09-22 12:27:57 +00:00
|
|
|
EVT_MENU( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
|
|
|
|
EVT_MENU( ID_SAVE_BOARD, WinEDA_GerberFrame::Files_io )
|
|
|
|
EVT_MENU( ID_SAVE_BOARD_AS, WinEDA_GerberFrame::Files_io )
|
2008-12-08 15:27:13 +00:00
|
|
|
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
|
|
|
|
2009-01-17 20:31:19 +00:00
|
|
|
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, WinEDA_GerberFrame::OnFileHistory )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-12-08 15:27:13 +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
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_MENU_RANGE( ID_CONFIG_AND_PREFERENCES_START,
|
|
|
|
ID_CONFIG_AND_PREFERENCES_END,
|
|
|
|
WinEDA_GerberFrame::Process_Config )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, WinEDA_GerberFrame::OnSelectOptionToolbar )
|
2009-11-22 20:55:05 +00:00
|
|
|
EVT_MENU( ID_OPTIONS_SETUP, WinEDA_GerberFrame::InstallGerberGeneralOptionsFrame )
|
2010-02-03 14:05:17 +00:00
|
|
|
EVT_MENU( ID_GERBVIEW_DISPLAY_OPTIONS_SETUP, WinEDA_GerberFrame::InstallGerberDisplayOptionsDialog )
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
|
|
|
|
WinEDA_DrawFrame::SetLanguage )
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// menu Postprocess
|
2008-12-08 15:27:13 +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-02-03 14:05:17 +00:00
|
|
|
EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE,
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// Menu Help
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
|
|
|
|
EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_TOOL( ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings )
|
|
|
|
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 )
|
2010-01-19 20:43:44 +00:00
|
|
|
EVT_TOOL( wxID_UNDO, WinEDA_GerberFrame::Process_Special_Functions )
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_TOOL( ID_GEN_PRINT, WinEDA_GerberFrame::ToPrinter )
|
|
|
|
EVT_TOOL( ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions )
|
2010-02-03 14:05:17 +00:00
|
|
|
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_LAYER,
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_KICAD_CHOICEBOX( 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:
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
|
2010-02-03 14:05:17 +00:00
|
|
|
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
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
|
2009-05-21 17:42:42 +00:00
|
|
|
WinEDA_GerberFrame::Process_Special_Functions )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// Pop up menu
|
2008-12-08 15:27:13 +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
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
|
|
|
|
WinEDA_GerberFrame::OnSelectOptionToolbar )
|
2010-02-03 14:05:17 +00:00
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
|
|
|
|
WinEDA_GerberFrame::OnSelectOptionToolbar )
|
2010-02-03 17:38:32 +00:00
|
|
|
EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES,
|
|
|
|
WinEDA_GerberFrame::OnSelectOptionToolbar )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
|
2008-04-17 16:25:29 +00:00
|
|
|
const wxString& title,
|
2008-12-08 15:27:13 +00:00
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style ) :
|
|
|
|
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
|
|
|
|
m_Draw_Sheet_Ref = FALSE; // TRUE for reference drawings.
|
2010-02-14 18:14:33 +00:00
|
|
|
m_HotkeysZoomAndGridList = s_Gerbview_Hokeys_Descr;
|
2008-04-17 16:25:29 +00:00
|
|
|
if( DrawPanel )
|
|
|
|
DrawPanel->m_Block_Enable = TRUE;
|
|
|
|
|
|
|
|
// 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 );
|
|
|
|
ActiveScreen = 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 );
|
|
|
|
int pointSize = font.GetPointSize();
|
|
|
|
int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
|
|
|
|
if( screenHeight <= 900 )
|
|
|
|
pointSize = (pointSize * 8) / 10;
|
|
|
|
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 );
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
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
|
|
|
|
wxAuiPaneInfo lyrs;
|
|
|
|
lyrs.MinSize( m_LayersManager->GetBestSize() ); // updated in ReFillLayerWidget
|
|
|
|
lyrs.BestSize( m_LayersManager->GetBestSize() );
|
|
|
|
lyrs.CloseButton( false );
|
|
|
|
lyrs.Caption( _( "Visibles" ) );
|
|
|
|
lyrs.IsFloatable();
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_HToolBar )
|
|
|
|
m_auimgr.AddPane( m_HToolBar,
|
|
|
|
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-02-03 14:05:17 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Row( 1 ) );
|
|
|
|
|
|
|
|
m_auimgr.AddPane( m_LayersManager, 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,
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
|
|
|
m_auimgr.Update();
|
2010-02-03 14:05:17 +00:00
|
|
|
|
|
|
|
ReFillLayerWidget(); // this is near end because contents establish size
|
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
|
|
|
|
2007-11-02 09:58:42 +00:00
|
|
|
/** Function SetToolbars()
|
2009-11-09 14:00:22 +00:00
|
|
|
* Set the tools state for the toolbars, according to display options
|
2007-11-02 09:58:42 +00:00
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
void WinEDA_GerberFrame::SetToolbars()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
int layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
|
|
|
|
GERBER* gerber = g_GERBER_List[layer];
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
if( m_HToolBar == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
|
|
|
m_HToolBar->EnableTool( wxID_CUT, TRUE );
|
|
|
|
m_HToolBar->EnableTool( wxID_COPY, TRUE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_HToolBar->EnableTool( wxID_CUT, FALSE );
|
|
|
|
m_HToolBar->EnableTool( wxID_COPY, FALSE );
|
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( m_SelLayerBox->GetSelection() !=
|
|
|
|
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
m_SelLayerBox->SetSelection(
|
2009-11-09 14:00:22 +00:00
|
|
|
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
if( gerber )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
|
|
|
int sel_index;
|
|
|
|
m_SelLayerTool->Enable( TRUE );
|
2008-11-08 06:44:07 +00:00
|
|
|
if( gerber->m_Selected_Tool < FIRST_DCODE ) // No tool selected
|
2008-04-17 16:25:29 +00:00
|
|
|
sel_index = 0;
|
|
|
|
else
|
2008-11-08 06:44:07 +00:00
|
|
|
sel_index = gerber->m_Selected_Tool - FIRST_DCODE + 1;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
if( sel_index != m_SelLayerTool->GetSelection() )
|
|
|
|
{
|
|
|
|
m_SelLayerTool->SetSelection( sel_index );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_SelLayerTool->SetSelection( 0 );
|
|
|
|
m_SelLayerTool->Enable( FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_OptionsToolBar )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
m_OptionsToolBar->ToggleTool(
|
|
|
|
ID_TB_OPTIONS_SELECT_UNIT_MM,
|
|
|
|
g_UnitMetric ==
|
|
|
|
MILLIMETRE ? TRUE : FALSE );
|
2008-04-17 16:25:29 +00:00
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
|
2008-12-08 15:27:13 +00:00
|
|
|
g_UnitMetric == INCHES ? TRUE : FALSE );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
|
2008-12-08 15:27:13 +00:00
|
|
|
DisplayOpt.DisplayPolarCood );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID,
|
2010-02-01 21:23:27 +00:00
|
|
|
IsGridVisible() );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
|
2009-04-05 20:49:15 +00:00
|
|
|
m_CursorShape );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
2008-12-08 15:27:13 +00:00
|
|
|
!m_DisplayPadFill );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
|
2008-12-08 15:27:13 +00:00
|
|
|
!m_DisplayPcbTrackFill );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH,
|
2008-12-08 15:27:13 +00:00
|
|
|
g_DisplayPolygonsModeSketch == 0 ? 0 : 1 );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_DCODES,
|
2010-02-03 14:05:17 +00:00
|
|
|
IsElementVisible( DCODES_VISIBLE) );
|
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
|
|
|
|
m_show_layer_manager_tools );
|
|
|
|
if( m_show_layer_manager_tools )
|
|
|
|
GetMenuBar()->SetLabel(ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
|
|
|
|
_("Hide &Layers Manager" ) );
|
|
|
|
else
|
|
|
|
GetMenuBar()->SetLabel(ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
|
|
|
|
_("Show &Layers Manager" ) );
|
|
|
|
|
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
DisplayUnitsMsg();
|
2009-11-09 14:00:22 +00:00
|
|
|
|
|
|
|
if( m_auimgr.GetManagedWindow() )
|
|
|
|
m_auimgr.Update();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
int WinEDA_GerberFrame::BestZoom()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
double x, y;
|
2008-04-17 16:25:29 +00:00
|
|
|
wxSize size;
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->ComputeBoundaryBox();
|
2009-04-05 20:49:15 +00:00
|
|
|
size = DrawPanel->GetClientSize();
|
|
|
|
x = ( (double) GetBoard()->m_BoundaryBox.GetWidth() +
|
2009-10-14 19:43:31 +00:00
|
|
|
GetScreen()->GetGridSize().x ) / (double) size.x;
|
2009-04-05 20:49:15 +00:00
|
|
|
y = ( (double) GetBoard()->m_BoundaryBox.GetHeight() +
|
2009-10-14 19:43:31 +00:00
|
|
|
GetScreen()->GetGridSize().y ) / (double) size.y;
|
2009-01-05 05:21:35 +00:00
|
|
|
GetScreen()->m_Curseur = GetBoard()->m_BoundaryBox.Centre();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
return wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar );
|
2007-05-06 16:03:28 +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();
|
|
|
|
long pageSize_opt;
|
|
|
|
config->Read( GerbviewShowPageSizeOption, &pageSize_opt, 0l );
|
|
|
|
int imax = 0;
|
|
|
|
for( ; g_GerberPageSizeList[imax] != NULL; imax++ );
|
|
|
|
if( pageSize_opt < 0 || pageSize_opt >= imax )
|
|
|
|
pageSize_opt = 0;
|
|
|
|
GetScreen()->m_CurrentSheetDesc = g_GerberPageSizeList[pageSize_opt];
|
|
|
|
if ( pageSize_opt > 0 )
|
|
|
|
{
|
|
|
|
m_Draw_Sheet_Ref = true;
|
|
|
|
}
|
2010-02-03 14:05:17 +00:00
|
|
|
|
|
|
|
long tmp;
|
|
|
|
config->Read( GerbviewShowDCodes, &tmp, 1);
|
|
|
|
SetElementVisibility( DCODES_VISIBLE, tmp);
|
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();
|
|
|
|
|
|
|
|
long pageSize_opt = 0;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
config->Write( GerbviewShowPageSizeOption, pageSize_opt );
|
2010-02-03 14:05:17 +00:00
|
|
|
config->Write( GerbviewShowDCodes, IsElementVisible( DCODES_VISIBLE) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_GerberFrame::ReFillLayerWidget()
|
|
|
|
{
|
|
|
|
m_LayersManager->ReFill();
|
|
|
|
|
|
|
|
wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
|
|
|
|
|
|
|
|
wxSize bestz = m_LayersManager->GetBestSize();
|
|
|
|
|
|
|
|
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-02-04 09:08:08 +00:00
|
|
|
syncLayerWidget( );
|
2010-02-03 14:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Function IsGridVisible() , virtual
|
|
|
|
* @return true if the grid must be shown
|
|
|
|
*/
|
|
|
|
bool WinEDA_GerberFrame::IsGridVisible()
|
|
|
|
{
|
|
|
|
return IsElementVisible(GERBER_GRID_VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Function SetGridVisibility() , virtual
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
void WinEDA_GerberFrame::SetGridVisibility(bool aVisible)
|
|
|
|
{
|
|
|
|
SetElementVisibility(GERBER_GRID_VISIBLE, aVisible);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Function GetGridColor() , virtual
|
|
|
|
* @return the color of the grid
|
|
|
|
*/
|
|
|
|
int WinEDA_GerberFrame::GetGridColor()
|
|
|
|
{
|
|
|
|
return GetBoard()->GetVisibleElementColor( GERBER_GRID_VISIBLE );
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Function SetGridColor() , virtual
|
|
|
|
* @param aColor = the new color of the grid
|
|
|
|
*/
|
|
|
|
void WinEDA_GerberFrame::SetGridColor(int aColor)
|
|
|
|
{
|
|
|
|
GetBoard()->SetVisibleElementColor( GERBER_GRID_VISIBLE, aColor );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_GerberFrame::syncLayerWidget( )
|
|
|
|
{
|
|
|
|
m_LayersManager->SelectLayer( getActiveLayer() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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() );
|
|
|
|
}
|
|
|
|
|