2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file gerbview_frame.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"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "build_version.h"
|
|
|
|
#include "macros.h"
|
|
|
|
#include "class_layer_box_selector.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
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"
|
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"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "class_gerbview_layer_widget.h"
|
2010-10-06 17:28:07 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
// Config keywords
|
|
|
|
const wxString GerbviewShowPageSizeOption( wxT( "ShowPageSizeOpt" ) );
|
|
|
|
const wxString GerbviewShowDCodes( wxT( "ShowDCodesOpt" ) );
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
/****************************************/
|
2011-03-12 09:50:21 +00:00
|
|
|
/* class GERBVIEW_FRAME for GerbView*/
|
2008-04-17 16:25:29 +00:00
|
|
|
/****************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
|
2011-09-06 14:09:40 +00:00
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style ) :
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME( 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;
|
2011-09-24 18:33:28 +00:00
|
|
|
m_drillFileHistory.SetBaseId( ID_GERBVIEW_DRILL_FILE1 );
|
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
|
2011-09-09 19:30:59 +00:00
|
|
|
wxIcon icon;
|
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
|
|
|
|
SetIcon( icon );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-09-24 18:33:28 +00:00
|
|
|
SetScreen( new PCB_SCREEN() );
|
|
|
|
GetScreen()->m_CurrentSheetDesc = &g_Sheet_GERBER;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
SetBoard( new BOARD( NULL, this ) );
|
2010-02-03 14:05:17 +00:00
|
|
|
GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first.
|
2011-03-26 08:20:25 +00:00
|
|
|
GetBoard()->SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible.
|
2009-11-09 14:00:22 +00:00
|
|
|
|
2011-04-02 16:14:07 +00:00
|
|
|
// Create the PCB_LAYER_WIDGET *after* SetBoard():
|
2010-02-03 14:05:17 +00:00
|
|
|
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 );
|
2011-09-14 15:08:44 +00:00
|
|
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
2009-11-07 14:45:14 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateOptToolbar();
|
2009-11-09 14:00:22 +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();
|
|
|
|
|
|
|
|
EDA_PANEINFO vert;
|
|
|
|
vert.VerticalToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO mesg;
|
|
|
|
mesg.MessageToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO lyrs;
|
|
|
|
lyrs.LayersToolbarPane();
|
|
|
|
lyrs.MinSize( m_LayersManager->GetBestSize() );
|
|
|
|
lyrs.BestSize( m_LayersManager->GetBestSize() );
|
2010-02-03 14:05:17 +00:00
|
|
|
lyrs.Caption( _( "Visibles" ) );
|
2011-09-15 18:25:44 +00:00
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_HToolBar )
|
|
|
|
m_auimgr.AddPane( m_HToolBar,
|
2011-02-08 14:48:38 +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,
|
2011-02-08 14:48:38 +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,
|
2011-09-15 18:25:44 +00:00
|
|
|
lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 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,
|
2011-02-08 14:48:38 +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,
|
2011-02-08 14:48:38 +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,
|
2011-09-15 18:25:44 +00:00
|
|
|
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-04-07 19:17:51 +00:00
|
|
|
ReFillLayerWidget(); // this is near end because contents establish size
|
|
|
|
m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
GERBVIEW_FRAME::~GERBVIEW_FRAME()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-03-12 09:50:21 +00:00
|
|
|
wxGetApp().SaveCurrentSetupValues( m_configSettings );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::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
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
double GERBVIEW_FRAME::BestZoom()
|
|
|
|
{
|
|
|
|
// gives a minimal value to zoom, if no item in list
|
|
|
|
if( GetBoard()->m_Drawings == NULL )
|
|
|
|
return 160.0;
|
|
|
|
|
|
|
|
EDA_RECT bbox;
|
|
|
|
BOARD_ITEM* item = GetBoard()->m_Drawings;
|
|
|
|
|
|
|
|
bbox = ( (GERBER_DRAW_ITEM*) item )->GetBoundingBox();
|
|
|
|
|
|
|
|
for( ; item; item = item->Next() )
|
|
|
|
{
|
|
|
|
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
|
|
|
|
bbox.Merge( gerb_item->GetBoundingBox() );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxSize size = DrawPanel->GetClientSize();
|
|
|
|
|
|
|
|
double x = (double) bbox.GetWidth() / (double) size.x;
|
|
|
|
double y = (double) bbox.GetHeight() / (double) size.y;
|
|
|
|
GetScreen()->SetScrollCenterPosition( bbox.Centre() );
|
|
|
|
|
|
|
|
double best_zoom = MAX( x, y );
|
|
|
|
return best_zoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::LoadSettings()
|
2009-11-22 20:55:05 +00:00
|
|
|
{
|
|
|
|
wxConfig* config = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
|
|
if( config == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME::LoadSettings();
|
2011-03-12 09:50:21 +00:00
|
|
|
|
|
|
|
wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
|
|
|
|
|
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 );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
|
|
|
// because we have 2 file historues, we must read this one
|
|
|
|
// using a specific path
|
|
|
|
config->SetPath( wxT("drl_files") );
|
|
|
|
m_drillFileHistory.Load( *config );
|
|
|
|
config->SetPath( wxT("..") );
|
2011-04-02 16:14:07 +00:00
|
|
|
|
|
|
|
// WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
|
|
|
|
// when reading doubles in config,
|
|
|
|
// but forget to back to current locale. So we call SetLocaleTo_Default
|
|
|
|
SetLocaleTo_Default( );
|
2009-11-22 20:55:05 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::SaveSettings()
|
2009-11-22 20:55:05 +00:00
|
|
|
{
|
|
|
|
wxConfig* config = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
|
|
if( config == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME::SaveSettings();
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
|
|
|
|
|
2011-05-13 13:15:28 +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
|
|
|
|
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 ) );
|
2011-03-26 08:20:25 +00:00
|
|
|
// Save the drill file history list.
|
|
|
|
// Because we have 2 file histories, we must save this one
|
2011-03-17 19:14:45 +00:00
|
|
|
// in a specific path
|
|
|
|
config->SetPath(wxT("drl_files") );
|
|
|
|
m_drillFileHistory.Save( *config );
|
|
|
|
config->SetPath( wxT("..") );
|
2010-02-03 14:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::ReFillLayerWidget()
|
2010-02-03 14:05:17 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
*/
|
2011-03-12 09:50:21 +00:00
|
|
|
bool GERBVIEW_FRAME::IsGridVisible()
|
2010-02-03 14:05:17 +00:00
|
|
|
{
|
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
|
|
|
|
*/
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::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
|
|
|
|
*/
|
2011-03-12 09:50:21 +00:00
|
|
|
int GERBVIEW_FRAME::GetGridColor()
|
2010-02-03 14:05:17 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
*/
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::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
|
|
|
|
*/
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::SetElementVisibility( int aGERBER_VISIBLE, bool aNewState )
|
2010-02-03 14:05:17 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
int GERBVIEW_FRAME::getNextAvailableLayer( int aLayer ) const
|
2011-03-02 15:24:39 +00:00
|
|
|
{
|
|
|
|
int layer = aLayer;
|
|
|
|
|
2011-03-26 08:20:25 +00:00
|
|
|
for( int i = 0; i < LAYER_COUNT; i++ )
|
2011-03-02 15:24:39 +00:00
|
|
|
{
|
|
|
|
GERBER_IMAGE* gerber = g_GERBER_List[ layer ];
|
|
|
|
|
|
|
|
if( gerber == NULL || gerber->m_FileName.IsEmpty() )
|
|
|
|
return layer;
|
|
|
|
|
|
|
|
layer++;
|
|
|
|
|
2011-03-26 08:20:25 +00:00
|
|
|
if( layer >= LAYER_COUNT )
|
2011-03-02 15:24:39 +00:00
|
|
|
layer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NO_AVAILABLE_LAYERS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::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.
|
|
|
|
*/
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::syncLayerBox()
|
2010-02-04 09:08:08 +00:00
|
|
|
{
|
|
|
|
m_SelLayerBox->SetSelection( getActiveLayer() );
|
2010-12-17 20:34:29 +00:00
|
|
|
int dcodeSelected = -1;
|
|
|
|
GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer()];
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
if( gerber )
|
|
|
|
dcodeSelected = gerber->m_Selected_Tool;
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
if( m_DCodeSelector )
|
|
|
|
{
|
|
|
|
m_DCodeSelector->SetDCodeSelection( dcodeSelected );
|
|
|
|
m_DCodeSelector->Enable( gerber != NULL );
|
|
|
|
}
|
2011-02-08 14:48:38 +00:00
|
|
|
|
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
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::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;
|
2011-04-19 14:28:34 +00:00
|
|
|
wxArrayString list;
|
2010-09-28 14:42:05 +00:00
|
|
|
int scale = 10000;
|
2011-03-14 21:19:13 +00:00
|
|
|
int curr_layer = getActiveLayer();
|
2010-09-28 14:42:05 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2011-04-19 14:28:34 +00:00
|
|
|
list.Add( Line );
|
2010-09-28 14:42:05 +00:00
|
|
|
|
|
|
|
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( " *" );
|
|
|
|
|
2011-04-19 14:28:34 +00:00
|
|
|
list.Add( Line );
|
2010-09-28 14:42:05 +00:00
|
|
|
jj++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-19 14:28:34 +00:00
|
|
|
wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, NULL,
|
|
|
|
wxCHOICEDLG_STYLE & ~wxCANCEL );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-04-19 14:28:34 +00:00
|
|
|
dlg.ShowModal();
|
2010-09-28 14:42:05 +00:00
|
|
|
}
|
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
|
2011-09-30 18:15:37 +00:00
|
|
|
* on the caption of the main GerbView window
|
2010-10-08 14:02:49 +00:00
|
|
|
* 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
|
|
|
*/
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::UpdateTitleAndInfo()
|
2010-10-06 17:28:07 +00:00
|
|
|
{
|
2011-03-14 21:19:13 +00:00
|
|
|
GERBER_IMAGE* gerber = g_GERBER_List[ getActiveLayer() ];
|
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 );
|
2011-03-14 21:19:13 +00:00
|
|
|
text.Printf( _( "Layer %d not in use" ), getActiveLayer() + 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\"" ),
|
2011-02-08 14:48:38 +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 );
|
|
|
|
}
|
|
|
|
|