2011-12-12 14:02:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-01-06 13:31:49 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-12 14:02:37 +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 gerbview_frame.cpp
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <build_version.h>
|
|
|
|
#include <macros.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <trigo.h>
|
2012-04-18 07:07:13 +00:00
|
|
|
#include <base_units.h>
|
2012-05-04 17:44:42 +00:00
|
|
|
#include <colors_selection.h>
|
|
|
|
#include <class_gbr_layer_box_selector.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
|
|
|
#include <class_gerber_draw_item.h>
|
|
|
|
#include <pcbplot.h>
|
|
|
|
#include <gerbview_id.h>
|
|
|
|
#include <hotkeys.h>
|
|
|
|
#include <class_GERBER.h>
|
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <class_DCodeSelectionbox.h>
|
|
|
|
#include <class_gerbview_layer_widget.h>
|
2012-04-25 19:33:24 +00:00
|
|
|
#include <class_gbr_screen.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
|
2013-01-21 20:02:07 +00:00
|
|
|
static const wxString cfgShowPageSizeOption( wxT( "PageSizeOpt" ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
static const wxString cfgShowDCodes( wxT( "ShowDCodesOpt" ) );
|
2013-01-06 13:31:49 +00:00
|
|
|
static const wxString cfgShowNegativeObjects( wxT( "ShowNegativeObjectsOpt" ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
static const wxString cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBlock" ) );
|
2011-03-12 09:50:21 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2011-12-12 14:02:37 +00:00
|
|
|
/*************************************/
|
|
|
|
/* class GERBVIEW_FRAME for GerbView */
|
|
|
|
/*************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
#define GERBVIEW_FRAME_NAME wxT( "GerberFrame" )
|
|
|
|
|
|
|
|
GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* aParent, const wxString& aTitle,
|
|
|
|
const wxPoint& aPosition, const wxSize& aSize,
|
|
|
|
long aStyle ) :
|
|
|
|
EDA_DRAW_FRAME( aParent, GERBER_FRAME_TYPE, aTitle, aPosition, aSize,
|
|
|
|
aStyle, GERBVIEW_FRAME_NAME )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
m_colorsSettings = &g_ColorsSettings;
|
|
|
|
m_Layout = NULL;
|
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
m_FrameName = GERBVIEW_FRAME_NAME;
|
2010-02-03 14:05:17 +00:00
|
|
|
m_show_layer_manager_tools = true;
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
m_showAxis = true; // true to show X and Y axis on screen
|
2012-05-04 17:44:42 +00:00
|
|
|
m_showBorderAndTitleBlock = false; // true for reference drawings.
|
|
|
|
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
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetEnableBlockCommands( 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
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
SetLayout( new GBR_LAYOUT() );
|
2009-11-09 14:00:22 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible.
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
SetScreen( new GBR_SCREEN( GetLayout()->GetPageSettings().GetSizeIU() ) );
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
// Create the PCB_LAYER_WIDGET *after* SetLayout():
|
|
|
|
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
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
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_LayersManager = new GERBER_LAYER_WIDGET( this, m_canvas, pointSize );
|
2010-02-03 14:05:17 +00:00
|
|
|
|
|
|
|
// 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 );
|
2012-05-06 16:55:51 +00:00
|
|
|
|
|
|
|
if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_1000 )
|
|
|
|
m_LastGridSizeId = m_LastGridSizeId;
|
|
|
|
if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_0_1MM )
|
2012-05-06 19:29:52 +00:00
|
|
|
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM;
|
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
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
EDA_PANEINFO horiz;
|
2011-09-15 18:25:44 +00:00
|
|
|
horiz.HorizontalToolbarPane();
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
EDA_PANEINFO vert;
|
2011-09-15 18:25:44 +00:00
|
|
|
vert.VerticalToolbarPane();
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
EDA_PANEINFO mesg;
|
2011-09-15 18:25:44 +00:00
|
|
|
mesg.MessageToolbarPane();
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
EDA_PANEINFO lyrs;
|
2011-09-15 18:25:44 +00:00
|
|
|
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
|
|
|
|
2011-12-16 13:32:23 +00:00
|
|
|
if( m_mainToolBar )
|
|
|
|
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
|
|
|
if( m_drawToolBar )
|
|
|
|
m_auimgr.AddPane( m_drawToolBar,
|
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).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
|
|
|
|
2011-12-14 20:03:15 +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
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas )
|
|
|
|
m_auimgr.AddPane( m_canvas,
|
2011-02-08 14:48:38 +00:00
|
|
|
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-12-12 14:02:37 +00:00
|
|
|
if( m_messagePanel )
|
|
|
|
m_auimgr.AddPane( m_messagePanel,
|
2012-05-04 17:44:42 +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()
|
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
GERBER_DRAW_ITEM* item = GetLayout()->m_Drawings;
|
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
// gives a minimal value to zoom, if no item in list
|
2012-05-04 17:44:42 +00:00
|
|
|
if( item == NULL )
|
|
|
|
return ZOOM_FACTOR( 350.0 );
|
2011-09-14 15:08:44 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
EDA_RECT bbox = GetLayout()->ComputeBoundingBox();
|
2011-09-14 15:08:44 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
wxSize size = m_canvas->GetClientSize();
|
2011-09-14 15:08:44 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
double x = (double) bbox.GetWidth() / (double) size.x;
|
|
|
|
double y = (double) bbox.GetHeight() / (double) size.y;
|
2011-09-14 15:08:44 +00:00
|
|
|
GetScreen()->SetScrollCenterPosition( bbox.Centre() );
|
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
double best_zoom = std::max( x, y );
|
2011-09-14 15:08:44 +00:00
|
|
|
return best_zoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::LoadSettings()
|
2009-11-22 20:55:05 +00:00
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
wxConfig* config = wxGetApp().GetSettings();
|
2009-11-22 20:55:05 +00:00
|
|
|
|
|
|
|
if( config == NULL )
|
|
|
|
return;
|
|
|
|
|
2012-04-25 19:33:24 +00:00
|
|
|
EDA_DRAW_FRAME::LoadSettings();
|
2011-03-12 09:50:21 +00:00
|
|
|
|
|
|
|
wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
PAGE_INFO pageInfo( wxT( "GERBER" ) );
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
config->Read( cfgShowBorderAndTitleBlock, &m_showBorderAndTitleBlock, false );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
if( m_showBorderAndTitleBlock )
|
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
wxString pageType;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
|
|
|
config->Read( cfgShowPageSizeOption, &pageType, wxT( "GERBER" ) );
|
|
|
|
|
|
|
|
pageInfo.SetType( pageType );
|
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
SetPageSettings( pageInfo );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
GetScreen()->InitDataPoints( pageInfo.GetSizeIU() );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2013-01-06 13:31:49 +00:00
|
|
|
bool tmp;
|
|
|
|
config->Read( cfgShowDCodes, &tmp, true );
|
2010-05-17 20:35:46 +00:00
|
|
|
SetElementVisibility( DCODES_VISIBLE, tmp );
|
2013-01-06 13:31:49 +00:00
|
|
|
config->Read( cfgShowNegativeObjects, &tmp, false );
|
|
|
|
SetElementVisibility( NEGATIVE_OBJECTS_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
|
2012-05-04 17:44:42 +00:00
|
|
|
config->SetPath( wxT( "drl_files" ) );
|
2011-03-17 19:14:45 +00:00
|
|
|
m_drillFileHistory.Load( *config );
|
2012-05-04 17:44:42 +00:00
|
|
|
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
|
2012-05-04 17:44:42 +00:00
|
|
|
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
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
wxConfig* config = wxGetApp().GetSettings();
|
2009-11-22 20:55:05 +00:00
|
|
|
|
|
|
|
if( config == NULL )
|
|
|
|
return;
|
|
|
|
|
2012-04-25 19:33:24 +00:00
|
|
|
EDA_DRAW_FRAME::SaveSettings();
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
config->Write( cfgShowPageSizeOption, GetPageSettings().GetType() );
|
|
|
|
config->Write( cfgShowBorderAndTitleBlock, m_showBorderAndTitleBlock );
|
|
|
|
config->Write( cfgShowDCodes, IsElementVisible( DCODES_VISIBLE ) );
|
2013-01-06 13:31:49 +00:00
|
|
|
config->Write( cfgShowNegativeObjects,
|
|
|
|
IsElementVisible( NEGATIVE_OBJECTS_VISIBLE ) );
|
2010-12-15 20:15:24 +00:00
|
|
|
|
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
|
2012-05-04 17:44:42 +00:00
|
|
|
config->SetPath( wxT( "drl_files" ) );
|
2011-03-17 19:14:45 +00:00
|
|
|
m_drillFileHistory.Save( *config );
|
2012-05-04 17:44:42 +00:00
|
|
|
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();
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
|
2010-02-03 14:05:17 +00:00
|
|
|
|
2012-05-04 17:44:42 +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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetElementVisibility
|
|
|
|
* changes the visibility of an element category
|
2012-09-12 17:28:55 +00:00
|
|
|
* @param aItemIdVisible is an item id from the enum GERBER_VISIBLE_ID
|
2010-02-03 14:05:17 +00:00
|
|
|
* @param aNewState = The new visibility state of the element category
|
|
|
|
*/
|
2012-09-12 17:28:55 +00:00
|
|
|
void GERBVIEW_FRAME::SetElementVisibility( GERBER_VISIBLE_ID aItemIdVisible,
|
|
|
|
bool aNewState )
|
2010-02-03 14:05:17 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
switch( aItemIdVisible )
|
|
|
|
{
|
|
|
|
case DCODES_VISIBLE:
|
|
|
|
m_DisplayOptions.m_DisplayDCodes = aNewState;
|
|
|
|
break;
|
|
|
|
|
2013-01-06 13:31:49 +00:00
|
|
|
case NEGATIVE_OBJECTS_VISIBLE:
|
|
|
|
m_DisplayOptions.m_DisplayNegativeObjects = aNewState;
|
|
|
|
break;
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
case GERBER_GRID_VISIBLE:
|
|
|
|
SetGridVisibility( aNewState );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aItemIdVisible );
|
|
|
|
}
|
|
|
|
m_LayersManager->SetRenderState( aItemIdVisible, aNewState );
|
2009-11-22 20:55:05 +00:00
|
|
|
}
|
2010-02-04 09:08:08 +00:00
|
|
|
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM GERBVIEW_FRAME::getNextAvailableLayer( LAYER_NUM aLayer ) const
|
2011-03-02 15:24:39 +00:00
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM layer = aLayer;
|
2011-03-02 15:24:39 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM i = FIRST_LAYER; i < NB_GERBER_LAYERS; ++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;
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
++layer;
|
2011-03-02 15:24:39 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
if( layer >= NB_GERBER_LAYERS )
|
|
|
|
layer = FIRST_LAYER;
|
2011-03-02 15:24:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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() );
|
2012-05-04 17:44:42 +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
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
int ii, jj;
|
|
|
|
D_CODE* pt_D_code;
|
|
|
|
wxString Line;
|
|
|
|
wxArrayString list;
|
|
|
|
double scale = IU_PER_MILS * 1000;
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM curr_layer = getActiveLayer();
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer )
|
2010-09-28 14:42:05 +00:00
|
|
|
{
|
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,
|
2013-05-07 17:31:52 +00:00
|
|
|
pt_D_code->m_Size.y / scale,
|
|
|
|
pt_D_code->m_Size.x / scale,
|
2010-09-28 14:42:05 +00:00
|
|
|
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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-26 19:57:48 +00:00
|
|
|
#if wxCHECK_VERSION( 2, 9, 4 )
|
2012-05-04 17:44:42 +00:00
|
|
|
wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL,
|
|
|
|
wxCHOICEDLG_STYLE & ~wxCANCEL );
|
2012-02-26 19:57:48 +00:00
|
|
|
#else
|
2012-05-04 17:44:42 +00:00
|
|
|
wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (char**) NULL,
|
|
|
|
wxCHOICEDLG_STYLE & ~wxCANCEL );
|
2012-02-26 19:57:48 +00:00
|
|
|
#endif
|
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
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
GERBER_IMAGE* gerber = g_GERBER_List[ getActiveLayer() ];
|
|
|
|
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 )
|
|
|
|
{
|
2012-05-10 06:25:27 +00:00
|
|
|
text.Printf( wxT( "GerbView %s" ), GetChars( 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):
|
2013-04-09 17:49:01 +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 );
|
|
|
|
}
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
/*
|
|
|
|
* Function IsElementVisible
|
2012-09-12 17:28:55 +00:00
|
|
|
* tests whether a given element category is visible
|
|
|
|
* aItemIdVisible is an item id from the enum GERBER_VISIBLE_ID
|
|
|
|
* return true if the element is visible.
|
2012-05-04 17:44:42 +00:00
|
|
|
*/
|
2013-01-06 13:31:49 +00:00
|
|
|
bool GERBVIEW_FRAME::IsElementVisible( GERBER_VISIBLE_ID aItemIdVisible ) const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
switch( aItemIdVisible )
|
|
|
|
{
|
|
|
|
case DCODES_VISIBLE:
|
|
|
|
return m_DisplayOptions.m_DisplayDCodes;
|
|
|
|
break;
|
|
|
|
|
2013-01-06 13:31:49 +00:00
|
|
|
case NEGATIVE_OBJECTS_VISIBLE:
|
|
|
|
return m_DisplayOptions.m_DisplayNegativeObjects;
|
|
|
|
break;
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
case GERBER_GRID_VISIBLE:
|
|
|
|
return IsGridVisible();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-09-12 17:28:55 +00:00
|
|
|
wxLogDebug( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aItemIdVisible );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetVisibleAlls
|
|
|
|
* Set the status of all layers to VISIBLE
|
|
|
|
*/
|
|
|
|
void GERBVIEW_FRAME::SetVisibleAlls()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetVisibleLayers
|
|
|
|
* is a proxy function that calls the correspondent function in m_BoardSettings
|
|
|
|
* Returns a bit-mask of all the layers that are visible
|
|
|
|
* @return int - the visible layers in bit-mapped form.
|
|
|
|
*/
|
2013-03-30 17:24:04 +00:00
|
|
|
LAYER_MSK GERBVIEW_FRAME::GetVisibleLayers() const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
return FULL_LAYERS; // TODO
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetVisibleLayers
|
|
|
|
* is a proxy function that calls the correspondent function in m_BoardSettings
|
|
|
|
* changes the bit-mask of visible layers
|
|
|
|
* @param aLayerMask = The new bit-mask of visible layers
|
|
|
|
*/
|
2013-03-30 17:24:04 +00:00
|
|
|
void GERBVIEW_FRAME::SetVisibleLayers( LAYER_MSK aLayerMask )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
GetLayout()->SetVisibleLayers( aLayerMask );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsLayerVisible
|
|
|
|
* tests whether a given layer is visible
|
2013-04-09 16:00:46 +00:00
|
|
|
* @param aLayer = The layer to be tested
|
2012-05-04 17:44:42 +00:00
|
|
|
* @return bool - true if the layer is visible.
|
|
|
|
*/
|
2013-04-09 16:00:46 +00:00
|
|
|
bool GERBVIEW_FRAME::IsLayerVisible( LAYER_NUM aLayer ) const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
if( ! m_DisplayOptions.m_IsPrinting )
|
2013-04-09 16:00:46 +00:00
|
|
|
return m_LayersManager->IsLayerVisible( aLayer );
|
2012-05-04 17:44:42 +00:00
|
|
|
else
|
2013-04-09 16:00:46 +00:00
|
|
|
return GetLayout()->IsLayerVisible( aLayer );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetVisibleElementColor
|
|
|
|
* returns the color of a pcb visible element.
|
|
|
|
* @see enum PCB_VISIBLE
|
|
|
|
*/
|
2013-01-06 13:31:49 +00:00
|
|
|
EDA_COLOR_T GERBVIEW_FRAME::GetVisibleElementColor( GERBER_VISIBLE_ID aItemIdVisible ) const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T color = UNSPECIFIED_COLOR;
|
2012-05-04 17:44:42 +00:00
|
|
|
|
|
|
|
switch( aItemIdVisible )
|
|
|
|
{
|
2013-01-06 13:31:49 +00:00
|
|
|
case NEGATIVE_OBJECTS_VISIBLE:
|
2012-05-04 17:44:42 +00:00
|
|
|
case DCODES_VISIBLE:
|
|
|
|
color = m_colorsSettings->GetItemColor( aItemIdVisible );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GERBER_GRID_VISIBLE:
|
|
|
|
color = GetGridColor();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-09-12 17:28:55 +00:00
|
|
|
wxLogDebug( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ),
|
|
|
|
(int)aItemIdVisible );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Virtual from EDA_DRAW_FRAME
|
|
|
|
*/
|
|
|
|
void GERBVIEW_FRAME::SetGridVisibility( bool aVisible )
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::SetGridVisibility( aVisible );
|
|
|
|
m_LayersManager->SetRenderState( GERBER_GRID_VISIBLE, aVisible );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-12 17:28:55 +00:00
|
|
|
void GERBVIEW_FRAME::SetVisibleElementColor( GERBER_VISIBLE_ID aItemIdVisible,
|
|
|
|
EDA_COLOR_T aColor )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
switch( aItemIdVisible )
|
|
|
|
{
|
2013-01-06 13:31:49 +00:00
|
|
|
case NEGATIVE_OBJECTS_VISIBLE:
|
2012-05-04 17:44:42 +00:00
|
|
|
case DCODES_VISIBLE:
|
|
|
|
m_colorsSettings->SetItemColor( aItemIdVisible, aColor );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GERBER_GRID_VISIBLE:
|
|
|
|
SetGridColor( aColor );
|
|
|
|
m_colorsSettings->SetItemColor( aItemIdVisible, aColor );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-09-12 17:28:55 +00:00
|
|
|
wxLogDebug( wxT( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d" ),
|
|
|
|
(int) aItemIdVisible );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-06 13:31:49 +00:00
|
|
|
/*
|
|
|
|
* Function GetNegativeItemsColor
|
|
|
|
* returns the color of negative items.
|
|
|
|
* This is usually the background color, but can be an other color
|
|
|
|
* in order to see negative objects
|
|
|
|
* therefore returns the background color if negative items not visible
|
|
|
|
* and the color selection of negative items if they are visible
|
|
|
|
*/
|
|
|
|
EDA_COLOR_T GERBVIEW_FRAME::GetNegativeItemsColor() const
|
|
|
|
{
|
|
|
|
if( IsElementVisible( NEGATIVE_OBJECTS_VISIBLE ) )
|
|
|
|
return GetVisibleElementColor( NEGATIVE_OBJECTS_VISIBLE );
|
|
|
|
else
|
|
|
|
return g_DrawBgColor;
|
|
|
|
}
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2013-01-06 13:31:49 +00:00
|
|
|
|
|
|
|
/*
|
2012-05-04 17:44:42 +00:00
|
|
|
* Function GetLayerColor
|
2013-01-06 13:31:49 +00:00
|
|
|
* gets a layer color for any valid layer.
|
2012-05-04 17:44:42 +00:00
|
|
|
*/
|
2013-03-31 13:27:46 +00:00
|
|
|
EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( LAYER_NUM aLayer ) const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
return m_colorsSettings->GetLayerColor( aLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetLayerColor
|
2013-01-06 13:31:49 +00:00
|
|
|
* changes a layer color for any valid layer.
|
2012-05-04 17:44:42 +00:00
|
|
|
*/
|
2013-03-31 13:27:46 +00:00
|
|
|
void GERBVIEW_FRAME::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
m_colorsSettings->SetLayerColor( aLayer, aColor );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function getActiveLayer
|
|
|
|
* returns the active layer
|
|
|
|
*/
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM GERBVIEW_FRAME::getActiveLayer()
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function setActiveLayer
|
|
|
|
* will change the currently active layer to \a aLayer and also
|
|
|
|
* update the PCB_LAYER_WIDGET.
|
|
|
|
*/
|
2013-03-31 13:27:46 +00:00
|
|
|
void GERBVIEW_FRAME::setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
|
|
|
|
|
|
|
|
if( doLayerWidgetUpdate )
|
|
|
|
m_LayersManager->SelectLayer( getActiveLayer() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
|
|
|
|
{
|
|
|
|
wxASSERT( m_Layout );
|
|
|
|
m_Layout->SetPageSettings( aPageSettings );
|
|
|
|
|
|
|
|
if( GetScreen() )
|
|
|
|
GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const PAGE_INFO& GERBVIEW_FRAME::GetPageSettings() const
|
|
|
|
{
|
|
|
|
wxASSERT( m_Layout );
|
|
|
|
return m_Layout->GetPageSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
|
|
|
|
{
|
|
|
|
wxASSERT( m_Layout );
|
|
|
|
|
|
|
|
// this function is only needed because EDA_DRAW_FRAME is not compiled
|
|
|
|
// with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
|
|
|
|
// into an application specific source file.
|
|
|
|
return m_Layout->GetPageSettings().GetSizeIU();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const TITLE_BLOCK& GERBVIEW_FRAME::GetTitleBlock() const
|
|
|
|
{
|
|
|
|
wxASSERT( m_Layout );
|
|
|
|
return m_Layout->GetTitleBlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
|
|
|
|
{
|
|
|
|
wxASSERT( m_Layout );
|
|
|
|
m_Layout->SetTitleBlock( aTitleBlock );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxPoint& GERBVIEW_FRAME::GetOriginAxisPosition() const
|
|
|
|
{
|
|
|
|
wxASSERT( m_Layout );
|
|
|
|
return m_Layout->GetOriginAxisPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_FRAME::SetOriginAxisPosition( const wxPoint& aPosition )
|
|
|
|
{
|
|
|
|
wxASSERT( m_Layout );
|
|
|
|
m_Layout->SetOriginAxisPosition( aPosition );
|
|
|
|
}
|
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
void GERBVIEW_FRAME::SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo )
|
|
|
|
{
|
|
|
|
GetScreen()->SetCurItem( aItem );
|
|
|
|
|
|
|
|
if( aItem )
|
|
|
|
{
|
|
|
|
if( aDisplayInfo )
|
2013-01-12 17:32:24 +00:00
|
|
|
{
|
|
|
|
MSG_PANEL_ITEMS items;
|
|
|
|
aItem->GetMsgPanelInfo( items );
|
|
|
|
SetMsgPanel( items );
|
|
|
|
}
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
else
|
2013-01-12 17:32:24 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
EraseMsgBox();
|
2013-01-12 17:32:24 +00:00
|
|
|
}
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
/*
|
|
|
|
* Function GetLayoutBoundingBox
|
|
|
|
* returns the bounding box containing all gerber items.
|
|
|
|
*/
|
|
|
|
EDA_RECT GERBVIEW_FRAME::GetLayoutBoundingBox()
|
|
|
|
{
|
|
|
|
GetLayout()->ComputeBoundingBox();
|
|
|
|
return GetLayout()->GetBoundingBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the status bar information.
|
|
|
|
*/
|
|
|
|
void GERBVIEW_FRAME::UpdateStatusBar()
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::UpdateStatusBar();
|
|
|
|
|
|
|
|
GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
|
|
|
|
|
|
|
|
if( !screen )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int dx;
|
|
|
|
int dy;
|
|
|
|
double dXpos;
|
|
|
|
double dYpos;
|
|
|
|
wxString line;
|
|
|
|
wxString locformatter;
|
|
|
|
|
|
|
|
if( m_DisplayOptions.m_DisplayPolarCood ) // display relative polar coordinates
|
|
|
|
{
|
|
|
|
double theta, ro;
|
|
|
|
|
|
|
|
dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
|
|
|
|
dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
|
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
// atan2 in the 0,0 case returns 0
|
|
|
|
theta = RAD2DEG( atan2( -dy, dx ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
ro = hypot( dx, dy );
|
2012-05-04 17:44:42 +00:00
|
|
|
wxString formatter;
|
|
|
|
switch( g_UserUnit )
|
|
|
|
{
|
|
|
|
case INCHES:
|
2013-02-24 17:31:18 +00:00
|
|
|
formatter = wxT( "Ro %.6f Th %.1f" );
|
2012-05-04 17:44:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MILLIMETRES:
|
2013-02-24 17:31:18 +00:00
|
|
|
formatter = wxT( "Ro %.5f Th %.1f" );
|
2012-05-04 17:44:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UNSCALED_UNITS:
|
|
|
|
formatter = wxT( "Ro %f Th %f" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
line.Printf( formatter, To_User_Unit( g_UserUnit, ro ), theta );
|
|
|
|
|
|
|
|
SetStatusText( line, 3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display absolute coordinates:
|
|
|
|
dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x );
|
|
|
|
dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y );
|
|
|
|
|
|
|
|
|
|
|
|
wxString absformatter;
|
|
|
|
|
|
|
|
switch( g_UserUnit )
|
|
|
|
{
|
|
|
|
case INCHES:
|
2013-02-24 17:31:18 +00:00
|
|
|
absformatter = wxT( "X %.6f Y %.6f" );
|
|
|
|
locformatter = wxT( "dx %.6f dy %.6f d %.6f" );
|
2012-05-04 17:44:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MILLIMETRES:
|
2013-02-24 17:31:18 +00:00
|
|
|
absformatter = wxT( "X %.5f Y %.5f" );
|
|
|
|
locformatter = wxT( "dx %.5f dy %.5f d %.5f" );
|
2012-05-04 17:44:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UNSCALED_UNITS:
|
|
|
|
absformatter = wxT( "X %f Y %f" );
|
|
|
|
locformatter = wxT( "dx %f dy %f d %f" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
line.Printf( absformatter, dXpos, dYpos );
|
|
|
|
SetStatusText( line, 2 );
|
|
|
|
|
|
|
|
if( !m_DisplayOptions.m_DisplayPolarCood ) // display relative cartesian coordinates
|
|
|
|
{
|
|
|
|
// Display relative coordinates:
|
|
|
|
dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
|
|
|
|
dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
|
|
|
|
dXpos = To_User_Unit( g_UserUnit, dx );
|
|
|
|
dYpos = To_User_Unit( g_UserUnit, dy );
|
|
|
|
|
|
|
|
// We already decided the formatter above
|
2013-05-01 17:32:36 +00:00
|
|
|
line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
SetStatusText( line, 3 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|