Commit a8212727 authored by jean-pierre charras's avatar jean-pierre charras

Gerbview: fix scaling error in x.6 file format. Minor cleaning code.

Better separation between Pcbnew code and Gerber code.
Update export to Pcb code (uses now the version 4  kicad_pcb file format).
parent c5e14ef1
......@@ -50,12 +50,13 @@ set( GERBVIEW_SRCS
gerbview_config.cpp
gerbview_frame.cpp
hotkeys.cpp
initpcb.cpp
init_gbr_drawlayers.cpp
locate.cpp
menubar.cpp
onleftclick.cpp
onrightclick.cpp
pcbplot.cpp
printout_control.cpp
readgerb.cpp
rs274_read_XY_and_IJ_coordinates.cpp
rs274d.cpp
......@@ -71,7 +72,6 @@ set( GERBVIEW_EXTRA_SRCS
../common/class_layer_box_selector.cpp
../common/class_page_info.cpp
../pcbnew/layer_widget.cpp
../pcbnew/printout_controler.cpp
)
if( MINGW )
......
......@@ -7,8 +7,12 @@
#include <gerbview_frame.h>
#include <select_layers_to_pcb.h>
#define NB_PCB_LAYERS LAYER_ID_COUNT
#define FIRST_COPPER_LAYER 0
#define LAST_COPPER_LAYER 31
// Exported function
const wxString GetPCBDefaultLayerName( int aLayerNumber );
const wxString GetPCBDefaultLayerName( int aLayerId );
enum layer_sel_id {
......@@ -21,9 +25,8 @@ enum layer_sel_id {
class SELECT_LAYER_DIALOG : public wxDialog
{
private:
GERBVIEW_FRAME* m_Parent;
wxRadioBox* m_LayerList;
int m_LayerId[int(GERBER_DRAWLAYERS_COUNT) + 1]; // One extra element for "(Deselect)" radiobutton
wxRadioBox* m_layerList;
std::vector <int> m_layerId;
public:
// Constructor and destructor
......@@ -64,12 +67,11 @@ END_EVENT_TABLE()
int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount,
bool aShowDeselectOption )
{
int layer;
SELECT_LAYER_DIALOG* frame = new SELECT_LAYER_DIALOG( this, aDefaultLayer,
aCopperLayerCount,
aShowDeselectOption );
layer = frame->ShowModal();
int layer = frame->ShowModal();
frame->Destroy();
return layer;
}
......@@ -88,85 +90,73 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent,
wxSize( 470, 250 ),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
#define NB_PCB_LAYERS 64
#define FIRST_COPPER_LAYER 0
#define LAST_COPPER_LAYER 31
wxButton* Button;
wxButton* button;
int ii;
wxString LayerList[NB_PCB_LAYERS + 1]; // One extra element for "(Deselect)"
// radiobutton
int LayerCount, LayerSelect = -1;
m_Parent = parent;
wxArrayString layerList;
int layerSelect = -1;
// Build the layer list; first build copper layers list
LayerCount = 0;
int layerCount = 0;
for( ii = FIRST_COPPER_LAYER; ii <= LAST_COPPER_LAYER; ++ii )
{
m_LayerId[ii] = 0;
if( ii == FIRST_COPPER_LAYER || ii == LAST_COPPER_LAYER || ii < aCopperLayerCount-1 )
{
LayerList[LayerCount] = GetPCBDefaultLayerName( ii );
layerList.Add( GetPCBDefaultLayerName( ii ) );
if( ii == aDefaultLayer )
LayerSelect = LayerCount;
layerSelect = layerCount;
m_LayerId[LayerCount] = ii;
LayerCount++;
m_layerId.push_back( ii );
layerCount++;
}
}
// Build the layer list; build non copper layers list
for( ; ii < NB_PCB_LAYERS; ++ii )
{
m_LayerId[ii] = 0;
LayerList[LayerCount] = GetPCBDefaultLayerName( ii );
layerList.Add( GetPCBDefaultLayerName( ii ) );
if( ii == aDefaultLayer )
LayerSelect = LayerCount;
layerSelect = layerCount;
m_LayerId[LayerCount] = ii;
LayerCount++;
m_layerId.push_back( ii );
layerCount++;
}
// When appropriate, also provide a "(Deselect)" radiobutton
if( aShowDeselectOption )
{
LayerList[LayerCount] = _( "(Deselect)" );
layerList.Add( _( "Do not export" ) );
if( NB_PCB_LAYERS == aDefaultLayer )
LayerSelect = LayerCount;
if( UNSELECTED_LAYER == aDefaultLayer )
layerSelect = layerCount;
m_LayerId[LayerCount] = NB_PCB_LAYERS;
LayerCount++;
m_layerId.push_back( UNSELECTED_LAYER );
layerCount++;
}
m_LayerList = new wxRadioBox( this, ID_LAYER_SELECT, _( "Layer" ),
m_layerList = new wxRadioBox( this, ID_LAYER_SELECT, _( "Layer" ),
wxPoint( -1, -1 ), wxSize( -1, -1 ),
LayerCount, LayerList,
(LayerCount < 8) ? LayerCount : 8,
layerList,
(layerCount < 8) ? layerCount : 8,
wxRA_SPECIFY_ROWS );
if( LayerSelect >= 0 )
m_LayerList->SetSelection( LayerSelect );
if( layerSelect >= 0 )
m_layerList->SetSelection( layerSelect );
wxBoxSizer* FrameBoxSizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer( FrameBoxSizer );
FrameBoxSizer->Add( m_LayerList, 0, wxALIGN_TOP | wxALL, 5 );
FrameBoxSizer->Add( m_layerList, 0, wxALIGN_TOP | wxALL, 5 );
wxBoxSizer* ButtonBoxSizer = new wxBoxSizer( wxVERTICAL );
FrameBoxSizer->Add( ButtonBoxSizer, 0, wxALIGN_BOTTOM | wxALL, 0 );
Button = new wxButton( this, wxID_OK, _( "OK" ) );
Button->SetDefault();
ButtonBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
ButtonBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
button = new wxButton( this, wxID_OK, _( "OK" ) );
button->SetDefault();
ButtonBoxSizer->Add( button, 0, wxGROW | wxALL, 5 );
SetFocus();
button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
ButtonBoxSizer->Add( button, 0, wxGROW | wxALL, 5 );
GetSizer()->SetSizeHints( this );
......@@ -176,7 +166,7 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent,
void SELECT_LAYER_DIALOG::OnLayerSelected( wxCommandEvent& event )
{
int ii = m_LayerId[m_LayerList->GetSelection()];
int ii = m_layerId[m_layerList->GetSelection()];
EndModal( ii );
}
......@@ -187,12 +177,15 @@ void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event )
EndModal( -1 );
}
const wxString GetPCBDefaultLayerName( int aLayerNumber )
// This function is a duplicate of
// const wxChar* LSET::Name( LAYER_ID aLayerId )
// However it avoids a dependency to Pcbnew code.
const wxString GetPCBDefaultLayerName( int aLayerId )
{
const wxChar* txt;
// Use a switch to explicitly show the mapping more clearly
switch( aLayerNumber )
// using a switch to explicitly show the mapping more clearly
switch( aLayerId )
{
case F_Cu: txt = wxT( "F.Cu" ); break;
case In1_Cu: txt = wxT( "In1.Cu" ); break;
......@@ -209,7 +202,25 @@ const wxString GetPCBDefaultLayerName( int aLayerNumber )
case In12_Cu: txt = wxT( "In12.Cu" ); break;
case In13_Cu: txt = wxT( "In13.Cu" ); break;
case In14_Cu: txt = wxT( "In14.Cu" ); break;
case In15_Cu: txt = wxT( "In15.Cu" ); break;
case In16_Cu: txt = wxT( "In16.Cu" ); break;
case In17_Cu: txt = wxT( "In17.Cu" ); break;
case In18_Cu: txt = wxT( "In18.Cu" ); break;
case In19_Cu: txt = wxT( "In19.Cu" ); break;
case In20_Cu: txt = wxT( "In20.Cu" ); break;
case In21_Cu: txt = wxT( "In21.Cu" ); break;
case In22_Cu: txt = wxT( "In22.Cu" ); break;
case In23_Cu: txt = wxT( "In23.Cu" ); break;
case In24_Cu: txt = wxT( "In24.Cu" ); break;
case In25_Cu: txt = wxT( "In25.Cu" ); break;
case In26_Cu: txt = wxT( "In26.Cu" ); break;
case In27_Cu: txt = wxT( "In27.Cu" ); break;
case In28_Cu: txt = wxT( "In28.Cu" ); break;
case In29_Cu: txt = wxT( "In29.Cu" ); break;
case In30_Cu: txt = wxT( "In30.Cu" ); break;
case B_Cu: txt = wxT( "B.Cu" ); break;
// Technicals
case B_Adhes: txt = wxT( "B.Adhes" ); break;
case F_Adhes: txt = wxT( "F.Adhes" ); break;
case B_Paste: txt = wxT( "B.Paste" ); break;
......@@ -218,12 +229,24 @@ const wxString GetPCBDefaultLayerName( int aLayerNumber )
case F_SilkS: txt = wxT( "F.SilkS" ); break;
case B_Mask: txt = wxT( "B.Mask" ); break;
case F_Mask: txt = wxT( "F.Mask" ); break;
// Users
case Dwgs_User: txt = wxT( "Dwgs.User" ); break;
case Cmts_User: txt = wxT( "Cmts.User" ); break;
case Eco1_User: txt = wxT( "Eco1.User" ); break;
case Eco2_User: txt = wxT( "Eco2.User" ); break;
case Edge_Cuts: txt = wxT( "Edge.Cuts" ); break;
default: txt = wxT( "BAD_INDEX" ); break;
case Margin: txt = wxT( "Margin" ); break;
// Footprint
case F_CrtYd: txt = wxT( "F.CrtYd" ); break;
case B_CrtYd: txt = wxT( "B.CrtYd" ); break;
case F_Fab: txt = wxT( "F.Fab" ); break;
case B_Fab: txt = wxT( "B.Fab" ); break;
default:
wxASSERT_MSG( 0, wxT( "aLayerId out of range" ) );
txt = wxT( "BAD INDEX!" ); break;
}
return wxString( txt );
......
......@@ -164,7 +164,7 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_GERBVIEW_GLOBAL_DELETE:
Erase_Current_Layer( true );
Erase_Current_DrawLayer( true );
ClearMsgPanel();
break;
......
This diff is collapsed.
......@@ -47,7 +47,7 @@ void GERBVIEW_FRAME::OnGbrFileHistory( wxCommandEvent& event )
if( !fn.IsEmpty() )
{
Erase_Current_Layer( false );
Erase_Current_DrawLayer( false );
LoadGerberFiles( fn );
}
}
......@@ -61,7 +61,7 @@ void GERBVIEW_FRAME::OnDrlFileHistory( wxCommandEvent& event )
if( !fn.IsEmpty() )
{
Erase_Current_Layer( false );
Erase_Current_DrawLayer( false );
LoadExcellonFiles( fn );
}
}
......@@ -75,12 +75,12 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event )
switch( id )
{
case wxID_FILE:
Erase_Current_Layer( false );
Erase_Current_DrawLayer( false );
LoadGerberFiles( wxEmptyString );
break;
case ID_GERBVIEW_ERASE_ALL:
Clear_Pcb( true );
Clear_DrawLayers( true );
Zoom_Automatique( false );
m_canvas->Refresh();
ClearMsgPanel();
......
......@@ -138,6 +138,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
lyrs.MinSize( m_LayersManager->GetBestSize() );
lyrs.BestSize( m_LayersManager->GetBestSize() );
lyrs.Caption( _( "Visibles" ) );
lyrs.TopDockable( false ).BottomDockable( false );
if( m_mainToolBar )
......
......@@ -630,8 +630,8 @@ public:
void Liste_D_Codes();
// PCB handling
bool Clear_Pcb( bool query );
void Erase_Current_Layer( bool query );
bool Clear_DrawLayers( bool query );
void Erase_Current_DrawLayer( bool query );
// Conversion function
void ExportDataInPcbnewFormat( wxCommandEvent& event );
......
......@@ -23,7 +23,7 @@
*/
/**
* @file gerbview/initpcb.cpp
* @file init_gbr_drawlayers.cpp
*/
#include <fctsys.h>
......@@ -38,7 +38,7 @@
#include <class_gerbview_layer_widget.h>
#include <class_gbr_layout.h>
bool GERBVIEW_FRAME::Clear_Pcb( bool query )
bool GERBVIEW_FRAME::Clear_DrawLayers( bool query )
{
int layer;
......@@ -73,7 +73,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
}
void GERBVIEW_FRAME::Erase_Current_Layer( bool query )
void GERBVIEW_FRAME::Erase_Current_DrawLayer( bool query )
{
int layer = getActiveLayer();
wxString msg;
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
*/
/**
* @file printout_controller.cpp
* @brief Board print handler implementation file.
*/
// Set this to 1 if you want to test PostScript printing under MSW.
#define wxTEST_POSTSCRIPT_IN_MSW 1
#include <fctsys.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <base_units.h>
#include <wxstruct.h>
#include <class_base_screen.h>
#include <layers_id_colors_and_visibility.h>
#include <gerbview_frame.h>
#include <printout_controler.h>
PRINT_PARAMETERS::PRINT_PARAMETERS()
{
m_PenDefaultSize = Millimeter2iu( 0.2 ); // A reasonable default value to draw items
// which do not have a specified line width
m_PrintScale = 1.0;
m_XScaleAdjust = 1.0;
m_YScaleAdjust = 1.0;
m_Print_Sheet_Ref = false;
m_PrintMaskLayer.set();
m_PrintMirror = false;
m_Print_Black_and_White = true;
m_OptionPrintPage = 1;
m_PageCount = 1;
m_ForceCentered = false;
m_Flags = 0;
m_DrillShapeOpt = PRINT_PARAMETERS::SMALL_DRILL_SHAPE;
m_PageSetupData = NULL;
}
BOARD_PRINTOUT_CONTROLLER::BOARD_PRINTOUT_CONTROLLER( const PRINT_PARAMETERS& aParams,
EDA_DRAW_FRAME* aParent,
const wxString& aTitle ) :
wxPrintout( aTitle )
{
m_PrintParams = aParams; // Make a local copy of the print parameters.
m_Parent = aParent;
}
bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
{
// in gerbview, draw layers are always printed on separate pages
// because handling negative objects when using only one page is tricky
m_PrintParams.m_Flags = aPage-1; // = gerber draw layer id
DrawPage();
return true;
}
void BOARD_PRINTOUT_CONTROLLER::GetPageInfo( int* minPage, int* maxPage,
int* selPageFrom, int* selPageTo )
{
*minPage = 1;
*selPageFrom = 1;
int icnt = 1;
if( m_PrintParams.m_OptionPrintPage == 0 )
icnt = m_PrintParams.m_PageCount;
*maxPage = icnt;
*selPageTo = icnt;
}
void BOARD_PRINTOUT_CONTROLLER::DrawPage()
{
wxPoint offset;
double userscale;
EDA_RECT boardBoundingBox;
EDA_RECT drawRect;
wxDC* dc = GetDC();
BASE_SCREEN* screen = m_Parent->GetScreen();
bool printMirror = m_PrintParams.m_PrintMirror;
wxSize pageSizeIU = m_Parent->GetPageSizeIU();
wxBusyCursor dummy;
boardBoundingBox = ((GERBVIEW_FRAME*) m_Parent)->GetGerberLayoutBoundingBox();
wxString titleblockFilename; // TODO see if we uses the gerber file name
// Use the page size as the drawing area when the board is shown or the user scale
// is less than 1.
if( m_PrintParams.PrintBorderAndTitleBlock() )
boardBoundingBox = EDA_RECT( wxPoint( 0, 0 ), pageSizeIU );
// Compute the PCB size in internal units
userscale = m_PrintParams.m_PrintScale;
if( m_PrintParams.m_PrintScale == 0 ) // fit in page option
{
if(boardBoundingBox.GetWidth() && boardBoundingBox.GetHeight())
{
int margin = Millimeter2iu( 10.0 ); // add a margin around the drawings
double scaleX = (double)(pageSizeIU.x - (2 * margin)) /
boardBoundingBox.GetWidth();
double scaleY = (double)(pageSizeIU.y - (2 * margin)) /
boardBoundingBox.GetHeight();
userscale = (scaleX < scaleY) ? scaleX : scaleY;
}
else
userscale = 1.0;
}
wxSize scaledPageSize = pageSizeIU;
drawRect.SetSize( scaledPageSize );
scaledPageSize.x = wxRound( scaledPageSize.x / userscale );
scaledPageSize.y = wxRound( scaledPageSize.y / userscale );
if( m_PrintParams.m_PageSetupData )
{
// Always scale to the size of the paper.
FitThisSizeToPageMargins( scaledPageSize, *m_PrintParams.m_PageSetupData );
}
// Compute Accurate scale 1
if( m_PrintParams.m_PrintScale == 1.0 )
{
// We want a 1:1 scale, regardless the page setup
// like page size, margin ...
MapScreenSizeToPaper(); // set best scale and offset (scale is not used)
int w, h;
GetPPIPrinter( &w, &h );
double accurate_Xscale = (double) w / (IU_PER_MILS*1000);
double accurate_Yscale = (double) h / (IU_PER_MILS*1000);
if( IsPreview() ) // Scale must take in account the DC size in Preview
{
// Get the size of the DC in pixels
wxSize PlotAreaSize;
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y );
GetPageSizePixels( &w, &h );
accurate_Xscale *= (double)PlotAreaSize.x / w;
accurate_Yscale *= (double)PlotAreaSize.y / h;
}
// Fine scale adjust
accurate_Xscale *= m_PrintParams.m_XScaleAdjust;
accurate_Yscale *= m_PrintParams.m_YScaleAdjust;
// Set print scale for 1:1 exact scale
dc->SetUserScale( accurate_Xscale, accurate_Yscale );
}
// Get the final size of the DC in pixels
wxSize PlotAreaSizeInPixels;
dc->GetSize( &PlotAreaSizeInPixels.x, &PlotAreaSizeInPixels.y );
double scalex, scaley;
dc->GetUserScale( &scalex, &scaley );
wxSize PlotAreaSizeInUserUnits;
PlotAreaSizeInUserUnits.x = KiROUND( PlotAreaSizeInPixels.x / scalex );
PlotAreaSizeInUserUnits.y = KiROUND( PlotAreaSizeInPixels.y / scaley );
// In some cases the plot origin is the centre of the board outline rather than the center
// of the selected paper size.
if( m_PrintParams.CenterOnBoardOutline() )
{
// Here we are only drawing the board and it's contents.
drawRect = boardBoundingBox;
offset.x += wxRound( (double) -scaledPageSize.x / 2.0 );
offset.y += wxRound( (double) -scaledPageSize.y / 2.0 );
wxPoint center = boardBoundingBox.Centre();
if( printMirror )
{
// Calculate the mirrored center of the board.
center.x = m_Parent->GetPageSizeIU().x - boardBoundingBox.Centre().x;
}
offset += center;
}
GRResetPenAndBrush( dc );
EDA_DRAW_PANEL* panel = m_Parent->GetCanvas();
EDA_RECT tmp = *panel->GetClipBox();
// Set clip box to the max size
#define MAX_VALUE (INT_MAX/2) // MAX_VALUE is the max we can use in an integer
// and that allows calculations without overflow
panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) );
screen->m_IsPrinting = true;
EDA_COLOR_T bg_color = m_Parent->GetDrawBgColor();
// Print frame reference, if requested, before printing draw layers
if( m_PrintParams.m_Print_Black_and_White )
GRForceBlackPen( true );
if( m_PrintParams.PrintBorderAndTitleBlock() )
m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
IU_PER_MILS, titleblockFilename );
if( printMirror )
{
// To plot mirror, we reverse the x axis, and modify the plot x origin
dc->SetAxisOrientation( false, false);
/* Plot offset x is moved by the x plot area size in order to have
* the old draw area in the new draw area, because the draw origin has not moved
* (this is the upper left corner) but the X axis is reversed, therefore the plotting area
* is the x coordinate values from - PlotAreaSize.x to 0 */
int x_dc_offset = PlotAreaSizeInPixels.x;
x_dc_offset = KiROUND( x_dc_offset * userscale );
dc->SetDeviceOrigin( x_dc_offset, 0 );
panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ),
panel->GetClipBox()->GetSize() ) );
}
// screen->m_DrawOrg = offset;
dc->SetLogicalOrigin( offset.x, offset.y );
m_Parent->SetDrawBgColor( WHITE );
// Never force black pen to print draw layers
// because negative objects need a white pen, not a black pen
// B&W mode is handled in print page function
GRForceBlackPen( false );
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror,
&m_PrintParams );
m_Parent->SetDrawBgColor( bg_color );
screen->m_IsPrinting = false;
panel->SetClipBox( tmp );
}
......@@ -19,7 +19,7 @@
// depending on the gerber file format
// this scale list assumes gerber units are imperial.
// for metric gerber units, the imperial to metric conversion is made in read functions
#define SCALE_LIST_SIZE 10
#define SCALE_LIST_SIZE 9
static double scale_list[SCALE_LIST_SIZE] =
{
1000.0 * IU_PER_MILS, // x.1 format (certainly useless)
......@@ -28,9 +28,9 @@ static double scale_list[SCALE_LIST_SIZE] =
1.0 * IU_PER_MILS, // x.4 format
0.1 * IU_PER_MILS, // x.5 format
0.01 * IU_PER_MILS, // x.6 format
0.0001 * IU_PER_MILS, // x.7 format
0.001 * IU_PER_MILS, // x.7 format (currently the max allowed precision)
0.0001 * IU_PER_MILS, // provided, but not used
0.00001 * IU_PER_MILS, // provided, but not used
0.000001 * IU_PER_MILS
};
/*
......
......@@ -359,17 +359,19 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
}
LAYER_NUM jj = m_layersLookUpTable[m_buttonTable[ii]];
if( !IsValidLayer( jj ) )
if( jj != UNSELECTED_LAYER && !IsValidLayer( jj ) )
jj = B_Cu; // (Defaults to "Copper" layer.)
jj = m_Parent->SelectPCBLayer( jj, m_exportBoardCopperLayersCount, true );
if( !IsValidLayer( jj ) )
if( jj != UNSELECTED_LAYER && !IsValidLayer( jj ) )
return;
if( jj != m_layersLookUpTable[m_buttonTable[ii]] )
{
m_layersLookUpTable[m_buttonTable[ii]] = jj;
if( jj == UNSELECTED_LAYER )
{
m_layersList[ii]->SetLabel( _( "Do not export" ) );
......
......@@ -37,16 +37,10 @@
#include <class_drawpanel.h>
#include <confirm.h>
#include <base_units.h>
#ifdef PCBNEW
#include <wxBasePcbFrame.h>
#include <class_board.h>
#include <pcbnew.h>
#else
#include <wxstruct.h>
#include <class_base_screen.h>
#include <layers_id_colors_and_visibility.h>
#include <gerbview_frame.h>
#endif
#include <wxBasePcbFrame.h>
#include <class_board.h>
#include <pcbnew.h>
#include <printout_controler.h>
......@@ -89,7 +83,6 @@ BOARD_PRINTOUT_CONTROLLER::BOARD_PRINTOUT_CONTROLLER( const PRINT_PARAMETERS& aP
bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
{
#ifdef PCBNEW
LSET lset = m_PrintParams.m_PrintMaskLayer;
// compute layer mask from page number if we want one page per layer
......@@ -115,11 +108,6 @@ bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
DrawPage();
m_PrintParams.m_PrintMaskLayer = lset;
#else // GERBVIEW
// in gerbview, draw layers are printed on separate pages
m_PrintParams.m_Flags = aPage-1; // = gerber draw layer id
DrawPage();
#endif
return true;
}
......@@ -154,16 +142,9 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
wxBusyCursor dummy;
#if defined (PCBNEW)
BOARD * brd = ((PCB_BASE_FRAME*) m_Parent)->GetBoard();
boardBoundingBox = brd->ComputeBoundingBox();
wxString titleblockFilename = brd->GetFileName();
#elif defined (GERBVIEW)
boardBoundingBox = ((GERBVIEW_FRAME*) m_Parent)->GetGerberLayoutBoundingBox();
wxString titleblockFilename; // TODO see if we uses the gerber file name
#else
#error BOARD_PRINTOUT_CONTROLLER::DrawPage() works only for PCBNEW or GERBVIEW
#endif
// Use the page size as the drawing area when the board is shown or the user scale
// is less than 1.
......@@ -362,12 +343,6 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
GRForceBlackPen( true );
#if defined (GERBVIEW)
// In B&W mode, do not force black pen for Gerbview
// because negative objects need a white pen, not a black pen
// B&W mode is handled in print page
GRForceBlackPen( false );
#endif
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror,
&m_PrintParams );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment