2009-11-18 12:52:19 +00:00
|
|
|
/***************/
|
|
|
|
/* pcbplot.cpp */
|
|
|
|
/***************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "plot_common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "gestfich.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "worksheet.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "protos.h"
|
2009-12-30 18:06:12 +00:00
|
|
|
#include "pcbstruct.h"
|
|
|
|
#include "class_board_design_settings.h"
|
2010-01-01 13:30:39 +00:00
|
|
|
#include "dialog_plot_base.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-21 19:27:11 +00:00
|
|
|
#define PLOT_DEFAULT_MARGE 300 // mils
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
/* Keywords to r/w options in m_Config */
|
2010-12-11 18:40:39 +00:00
|
|
|
#define OPTKEY_GERBER_EXTENSIONS wxT( "GerberOptUseLayersExt" )
|
|
|
|
#define OPTKEY_XFINESCALE_ADJ wxT( "PlotXFineScaleAdj" )
|
|
|
|
#define OPTKEY_YFINESCALE_ADJ wxT( "PlotYFineScaleAdj" )
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Define min and max reasonable values for print scale
|
2009-01-18 19:20:15 +00:00
|
|
|
#define MIN_SCALE 0.01
|
|
|
|
#define MAX_SCALE 100.0
|
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
// PCB_PLOT_PARAMS constructor: set the default values for plot options:
|
|
|
|
PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
|
2009-08-28 18:03:22 +00:00
|
|
|
{
|
2010-12-09 17:34:08 +00:00
|
|
|
m_SubtractMaskFromSilk = false;
|
2010-12-11 18:40:39 +00:00
|
|
|
m_PlotReference = true;
|
|
|
|
m_PlotValue = true;
|
|
|
|
m_PlotTextOther = true;
|
|
|
|
m_DrillShapeOpt = PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE;
|
2010-12-11 19:33:21 +00:00
|
|
|
m_PlotMode = FILLED;
|
2010-12-11 18:40:39 +00:00
|
|
|
m_PlotScale = 1.0;
|
|
|
|
m_AutoScale = false;
|
|
|
|
m_FineScaleAdjustX = 1.0;
|
|
|
|
m_FineScaleAdjustY = 1.0;
|
|
|
|
outputDirectory = wxT( "" );
|
2009-08-28 18:03:22 +00:00
|
|
|
}
|
2008-01-23 08:01:38 +00:00
|
|
|
|
2009-12-30 18:06:12 +00:00
|
|
|
|
2009-12-21 13:05:11 +00:00
|
|
|
static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT |
|
2009-12-21 18:51:37 +00:00
|
|
|
SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK;
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
static bool s_PlotOriginIsAuxAxis = FALSE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
/* The group of plot options - sadly global XXX */
|
2010-12-11 18:40:39 +00:00
|
|
|
PCB_PLOT_PARAMS g_PcbPlotOptions;
|
|
|
|
extern int g_DrawDefaultLineThickness;
|
2010-02-24 15:33:03 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
/*******************************/
|
|
|
|
/* Dialog box for plot control */
|
|
|
|
/*******************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
class DIALOG_PLOT : public DIALOG_PLOT_BASE
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-01-01 13:30:39 +00:00
|
|
|
WinEDA_PcbFrame* m_Parent;
|
|
|
|
wxConfig* m_Config;
|
|
|
|
wxCheckBox* m_BoxSelectLayer[LAYER_COUNT]; // wxCheckBox list to select/deselec layers to plot
|
|
|
|
double m_XScaleAdjust;
|
|
|
|
double m_YScaleAdjust;
|
2010-12-11 18:40:39 +00:00
|
|
|
static int m_dlgPlotScaleOpt; // Static to remember last selection
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2009-06-01 18:28:34 +00:00
|
|
|
bool useA4()
|
2008-03-22 05:55:06 +00:00
|
|
|
{
|
2010-12-11 19:33:21 +00:00
|
|
|
return m_plotFormatOpt->GetSelection() == 3;
|
2008-03-22 05:55:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function getFormat
|
2010-12-11 18:40:39 +00:00
|
|
|
* returns one of the values from the m_PlotFormat enum. If the 4th
|
2008-03-22 05:55:06 +00:00
|
|
|
* radio button is selected, map this back to postscript.
|
|
|
|
*/
|
|
|
|
PlotFormat getFormat()
|
|
|
|
{
|
2010-12-11 19:33:21 +00:00
|
|
|
int radioNdx = m_plotFormatOpt->GetSelection();
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2009-06-01 18:28:34 +00:00
|
|
|
// change the A4 to the simple postscript, according to the
|
2010-12-11 18:40:39 +00:00
|
|
|
// m_PlotFormat enum
|
2009-12-30 18:06:12 +00:00
|
|
|
switch( radioNdx )
|
|
|
|
{
|
|
|
|
case 3:
|
2008-08-06 07:46:03 +00:00
|
|
|
radioNdx = PLOT_FORMAT_POST;
|
2009-12-30 18:06:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
radioNdx = PLOT_FORMAT_DXF;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-22 05:55:06 +00:00
|
|
|
|
|
|
|
return PlotFormat( radioNdx );
|
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
public: DIALOG_PLOT( WinEDA_PcbFrame* parent );
|
2007-05-06 16:03:28 +00:00
|
|
|
private:
|
2010-01-01 13:30:39 +00:00
|
|
|
void Init_Dialog();
|
2008-08-06 07:46:03 +00:00
|
|
|
void Plot( wxCommandEvent& event );
|
|
|
|
void OnQuit( wxCommandEvent& event );
|
|
|
|
void OnClose( wxCloseEvent& event );
|
2010-11-21 15:12:37 +00:00
|
|
|
void OnOutputDirectoryBrowseClicked( wxCommandEvent& event );
|
2010-01-01 13:30:39 +00:00
|
|
|
void SetPlotFormat( wxCommandEvent& event );
|
2009-06-28 16:50:42 +00:00
|
|
|
void OnSetScaleOpt( wxCommandEvent& event );
|
2010-12-11 19:33:21 +00:00
|
|
|
void savePlotOptions( wxCommandEvent& event );
|
2008-08-06 07:46:03 +00:00
|
|
|
void CreateDrillFile( wxCommandEvent& event );
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
int DIALOG_PLOT::m_dlgPlotScaleOpt = 1;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-24 10:10:42 +00:00
|
|
|
const int UNITS_MILS = 1000;
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
DIALOG_PLOT::DIALOG_PLOT( WinEDA_PcbFrame* parent ) :
|
|
|
|
DIALOG_PLOT_BASE( parent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
m_Parent = parent;
|
2010-01-01 13:30:39 +00:00
|
|
|
m_Config = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
|
|
Init_Dialog();
|
|
|
|
|
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2008-10-30 10:55:46 +00:00
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
void DIALOG_PLOT::Init_Dialog()
|
2008-10-30 10:55:46 +00:00
|
|
|
{
|
2010-12-11 18:40:39 +00:00
|
|
|
wxString msg;
|
2010-11-21 15:12:37 +00:00
|
|
|
wxFileName fileName;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
BOARD* board = m_Parent->GetBoard();
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
m_Config->Read( OPTKEY_XFINESCALE_ADJ, &m_XScaleAdjust );
|
|
|
|
m_Config->Read( OPTKEY_YFINESCALE_ADJ, &m_YScaleAdjust );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotFormatOpt->SetSelection( g_PcbPlotOptions.m_PlotFormat );
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotLineWidth = g_DrawDefaultLineThickness;
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2008-08-06 07:46:03 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Set units and value for HPGL pen speed.
|
2010-07-12 14:07:09 +00:00
|
|
|
AddUnitSymbol( *m_textPenSize, g_UserUnit );
|
2010-12-11 18:40:39 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, g_PcbPlotOptions.m_HPGLPenDiam, UNITS_MILS );
|
2010-01-01 13:30:39 +00:00
|
|
|
m_HPGLPenSizeOpt->AppendText( msg );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Set units to cm for standard HPGL pen speed.
|
2010-12-11 18:40:39 +00:00
|
|
|
msg = ReturnStringFromValue( UNSCALED_UNITS, g_PcbPlotOptions.m_HPGLPenSpeed, 1 );
|
2010-01-01 13:30:39 +00:00
|
|
|
m_HPGLPenSpeedOpt->AppendText( msg );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Set units and value for HPGL pen overlay.
|
2010-07-12 14:07:09 +00:00
|
|
|
AddUnitSymbol( *m_textPenOvr, g_UserUnit );
|
|
|
|
msg = ReturnStringFromValue( g_UserUnit,
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_HPGLPenOvr,
|
2010-01-01 13:30:39 +00:00
|
|
|
UNITS_MILS );
|
|
|
|
m_HPGLPenOverlayOpt->AppendText( msg );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit,
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotLineWidth,
|
2010-01-01 13:30:39 +00:00
|
|
|
PCB_INTERNAL_UNIT );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_linesWidth->AppendText( msg );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
if( s_PlotOriginIsAuxAxis )
|
2010-12-11 19:33:21 +00:00
|
|
|
m_choicePlotOffset->SetSelection( 1 );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
// Create scale adjust option
|
|
|
|
m_XScaleAdjust = m_YScaleAdjust = 1.0;
|
2009-06-01 18:28:34 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Test for a reasonable scale value. Set to 1 if problem
|
2009-06-01 18:28:34 +00:00
|
|
|
if( m_XScaleAdjust < MIN_SCALE || m_YScaleAdjust < MIN_SCALE
|
|
|
|
|| m_XScaleAdjust > MAX_SCALE || m_YScaleAdjust > MAX_SCALE )
|
2009-01-18 19:20:15 +00:00
|
|
|
m_XScaleAdjust = m_YScaleAdjust = 1.0;
|
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
msg.Printf( wxT( "%f" ), m_XScaleAdjust );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_fineAdjustXscaleOpt->AppendText( msg );
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
msg.Printf( wxT( "%f" ), m_YScaleAdjust );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_fineAdjustYscaleOpt->AppendText( msg );
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
m_plotPSNegativeOpt->SetValue( g_PcbPlotOptions.m_PlotPSNegative );
|
2008-03-21 19:27:11 +00:00
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Create layer list.
|
2010-01-01 13:30:39 +00:00
|
|
|
int layer;
|
|
|
|
wxString layerKey;
|
|
|
|
for( layer = 0; layer < NB_LAYERS; ++layer )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2010-01-31 20:01:46 +00:00
|
|
|
if( !board->IsLayerEnabled( layer ) )
|
2010-01-01 13:30:39 +00:00
|
|
|
m_BoxSelectLayer[layer] = NULL;
|
|
|
|
else
|
2010-12-11 18:40:39 +00:00
|
|
|
m_BoxSelectLayer[layer] =
|
|
|
|
new wxCheckBox( this, -1, board->GetLayerName( layer ) );
|
2008-03-21 19:27:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Add wxCheckBoxes in layers lists dialog
|
|
|
|
// List layers in same order than in setup layers dialog
|
|
|
|
// (Front or Top to Back or Bottom)
|
2010-12-11 18:40:39 +00:00
|
|
|
DECLARE_LAYERS_ORDER_LIST( layersOrder );
|
2010-01-01 13:30:39 +00:00
|
|
|
for( int layer_idx = 0; layer_idx < NB_LAYERS; ++layer_idx )
|
2008-03-21 19:27:11 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
layer = layersOrder[layer_idx];
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
wxASSERT( layer < NB_LAYERS );
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
if( m_BoxSelectLayer[layer] == NULL )
|
|
|
|
continue;
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
if( layer < NB_COPPER_LAYERS )
|
|
|
|
m_CopperLayersBoxSizer->Add( m_BoxSelectLayer[layer],
|
2010-12-11 18:40:39 +00:00
|
|
|
0, wxGROW | wxALL, 1 );
|
2010-01-01 13:30:39 +00:00
|
|
|
else
|
|
|
|
m_TechnicalLayersBoxSizer->Add( m_BoxSelectLayer[layer],
|
2010-12-11 18:40:39 +00:00
|
|
|
0, wxGROW | wxALL, 1 );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
|
|
|
|
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
|
|
|
bool option;
|
|
|
|
if( m_Config->Read( layerKey, &option ) )
|
|
|
|
m_BoxSelectLayer[layer]->SetValue( option );
|
|
|
|
else
|
2009-12-30 18:06:12 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
long mask = 1 << layer;
|
|
|
|
if( mask & s_SelectedLayers )
|
|
|
|
m_BoxSelectLayer[layer]->SetValue( true );
|
2009-12-30 18:06:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Option for using proper Gerber extensions
|
2009-12-30 18:06:12 +00:00
|
|
|
long ltmp;
|
2010-01-01 13:30:39 +00:00
|
|
|
m_Config->Read( OPTKEY_GERBER_EXTENSIONS, <mp );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_useGerberExtensions->SetValue( ltmp );
|
2009-12-30 18:06:12 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
// Option for excluding contents of "Edges Pcb" layer
|
2010-12-11 18:40:39 +00:00
|
|
|
m_excludeEdgeLayerOpt->SetValue( g_PcbPlotOptions.m_ExcludeEdgeLayer );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
m_subtractMaskFromSilk->SetValue( g_PcbPlotOptions.GetSubtractMaskFromSilk() );
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2008-04-18 13:28:56 +00:00
|
|
|
// Option to plot page references:
|
2008-03-04 04:22:27 +00:00
|
|
|
if( m_Parent->m_Print_Sheet_Ref )
|
|
|
|
{
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotSheetRef->SetValue( g_PcbPlotOptions.m_PlotFrameRef );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
else
|
2010-01-01 13:30:39 +00:00
|
|
|
{
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotSheetRef->Enable( false );
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotFrameRef = false;
|
2010-01-01 13:30:39 +00:00
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-01-07 07:58:45 +00:00
|
|
|
// Option to plot pads on silkscreen layers or all layers
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotPads_on_Silkscreen->SetValue( g_PcbPlotOptions.m_PlotPadsOnSilkLayer );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-01-07 07:58:45 +00:00
|
|
|
// Options to plot texts on footprints
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotModuleValueOpt->SetValue( g_PcbPlotOptions.m_PlotValue );
|
|
|
|
m_plotModuleRefOpt->SetValue( g_PcbPlotOptions.m_PlotReference );
|
|
|
|
m_plotTextOther->SetValue( g_PcbPlotOptions.m_PlotTextOther );
|
|
|
|
m_plotInvisibleText->SetValue( g_PcbPlotOptions.m_PlotInvisibleTexts );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Options to plot pads and vias holes
|
2010-12-11 19:33:21 +00:00
|
|
|
m_drillShapeOpt->SetSelection( g_PcbPlotOptions.m_DrillShapeOpt );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Scale option
|
2010-12-11 19:33:21 +00:00
|
|
|
m_scaleOpt->SetSelection( m_dlgPlotScaleOpt );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Plot mode
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotModeOpt->SetSelection( g_PcbPlotOptions.m_PlotMode );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Plot mirror option
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotMirrorOpt->SetValue( g_PcbPlotOptions.m_PlotMirror );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Put vias on mask layer
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotNoViaOnMaskOpt->SetValue( g_PcbPlotOptions.m_PlotViaOnMaskLayer );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-11-21 15:12:37 +00:00
|
|
|
// Output directory
|
2010-12-11 18:40:39 +00:00
|
|
|
if( g_PcbPlotOptions.GetOutputDirectory().IsEmpty() )
|
2010-11-21 15:12:37 +00:00
|
|
|
{
|
|
|
|
fileName = m_Parent->GetScreen()->m_FileName;
|
2010-12-11 19:33:21 +00:00
|
|
|
m_outputDirectoryName->SetValue( fileName.GetPath() );
|
2010-11-21 15:12:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-11 19:33:21 +00:00
|
|
|
m_outputDirectoryName->SetValue( g_PcbPlotOptions.GetOutputDirectory() );
|
2010-11-21 15:12:37 +00:00
|
|
|
}
|
|
|
|
|
2009-01-07 07:58:45 +00:00
|
|
|
// Update options values:
|
2008-10-30 10:55:46 +00:00
|
|
|
wxCommandEvent cmd_event;
|
2010-01-01 13:30:39 +00:00
|
|
|
SetPlotFormat( cmd_event );
|
2009-06-28 16:50:42 +00:00
|
|
|
OnSetScaleOpt( cmd_event );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2008-03-21 19:27:11 +00:00
|
|
|
// without this line, the ESC key does not work
|
2008-10-30 10:55:46 +00:00
|
|
|
SetFocus();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 10:10:42 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
void DIALOG_PLOT::OnQuit( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
Close( true ); // true is to force the frame to close
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 10:10:42 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
void DIALOG_PLOT::OnClose( wxCloseEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
EndModal( 0 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
( (WinEDA_PcbFrame*) m_Parent )->InstallDrillFrame( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2009-12-30 18:06:12 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
|
|
|
/* Disable sheet reference for scale != 1:1 */
|
2010-12-11 19:33:21 +00:00
|
|
|
bool scale1 = ( m_scaleOpt->GetSelection() == 1 );
|
2009-12-30 18:06:12 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotSheetRef->Enable( scale1 );
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2009-12-30 18:06:12 +00:00
|
|
|
if( !scale1 )
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotSheetRef->SetValue( false );
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
2007-08-24 10:10:42 +00:00
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2010-11-21 15:12:37 +00:00
|
|
|
void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
|
|
|
{
|
2010-12-11 18:40:39 +00:00
|
|
|
wxString currentDir;
|
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
currentDir = m_outputDirectoryName->GetValue();
|
2010-11-21 15:12:37 +00:00
|
|
|
wxDirDialog dirDialog( this, _( "Select Output Directory" ), currentDir );
|
|
|
|
if( dirDialog.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
2010-12-11 19:33:21 +00:00
|
|
|
m_outputDirectoryName->SetValue( dirDialog.GetPath() );
|
2010-11-21 15:12:37 +00:00
|
|
|
}
|
2009-12-30 18:06:12 +00:00
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-22 05:55:06 +00:00
|
|
|
int format = getFormat();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
switch( format )
|
|
|
|
{
|
|
|
|
case PLOT_FORMAT_POST:
|
|
|
|
default:
|
2010-12-11 19:33:21 +00:00
|
|
|
m_drillShapeOpt->Enable( true );
|
|
|
|
m_plotModeOpt->Enable( true );
|
|
|
|
m_plotMirrorOpt->Enable( true );
|
|
|
|
m_choicePlotOffset->Enable( false );
|
|
|
|
m_linesWidth->Enable( true );
|
2008-03-04 04:22:27 +00:00
|
|
|
m_HPGLPenSizeOpt->Enable( false );
|
|
|
|
m_HPGLPenSpeedOpt->Enable( false );
|
|
|
|
m_HPGLPenOverlayOpt->Enable( false );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_excludeEdgeLayerOpt->SetValue( false );
|
|
|
|
m_excludeEdgeLayerOpt->Enable( false );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_subtractMaskFromSilk->Enable( false );
|
|
|
|
m_useGerberExtensions->Enable( false );
|
|
|
|
m_scaleOpt->Enable( true );
|
|
|
|
m_fineAdjustXscaleOpt->Enable( true );
|
|
|
|
m_fineAdjustYscaleOpt->Enable( true );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_plotPSNegativeOpt->Enable( true );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_GERBER:
|
2010-12-11 19:33:21 +00:00
|
|
|
m_drillShapeOpt->Enable( false );
|
|
|
|
m_plotModeOpt->SetSelection( 1 );
|
|
|
|
m_plotModeOpt->Enable( false );
|
|
|
|
m_plotMirrorOpt->SetValue( false );
|
|
|
|
m_plotMirrorOpt->Enable( false );
|
|
|
|
m_choicePlotOffset->Enable( true );
|
|
|
|
m_linesWidth->Enable( true );
|
2008-03-04 04:22:27 +00:00
|
|
|
m_HPGLPenSizeOpt->Enable( false );
|
|
|
|
m_HPGLPenSpeedOpt->Enable( false );
|
|
|
|
m_HPGLPenOverlayOpt->Enable( false );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_excludeEdgeLayerOpt->Enable( true );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_subtractMaskFromSilk->Enable( true );
|
|
|
|
m_useGerberExtensions->Enable( true );
|
|
|
|
m_scaleOpt->SetSelection( 1 );
|
|
|
|
m_scaleOpt->Enable( false );
|
|
|
|
m_fineAdjustXscaleOpt->Enable( false );
|
|
|
|
m_fineAdjustYscaleOpt->Enable( false );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_plotPSNegativeOpt->SetValue( false );
|
|
|
|
m_plotPSNegativeOpt->Enable( false );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_HPGL:
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotMirrorOpt->Enable( true );
|
|
|
|
m_drillShapeOpt->Enable( false );
|
|
|
|
m_plotModeOpt->Enable( true );
|
|
|
|
m_choicePlotOffset->Enable( false );
|
|
|
|
m_linesWidth->Enable( false );
|
2008-03-04 04:22:27 +00:00
|
|
|
m_HPGLPenSizeOpt->Enable( true );
|
|
|
|
m_HPGLPenSpeedOpt->Enable( true );
|
|
|
|
m_HPGLPenOverlayOpt->Enable( true );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_excludeEdgeLayerOpt->SetValue( false );
|
|
|
|
m_excludeEdgeLayerOpt->Enable( false );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_subtractMaskFromSilk->Enable( false );
|
|
|
|
m_useGerberExtensions->Enable( false );
|
|
|
|
m_scaleOpt->Enable( true );
|
|
|
|
m_fineAdjustXscaleOpt->Enable( false );
|
|
|
|
m_fineAdjustYscaleOpt->Enable( false );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_plotPSNegativeOpt->SetValue( false );
|
|
|
|
m_plotPSNegativeOpt->Enable( false );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
2009-06-30 10:43:20 +00:00
|
|
|
|
|
|
|
case PLOT_FORMAT_DXF:
|
2010-12-11 19:33:21 +00:00
|
|
|
m_plotMirrorOpt->Enable( false );
|
|
|
|
m_plotMirrorOpt->SetValue( false );
|
|
|
|
m_drillShapeOpt->Enable( false );
|
|
|
|
m_plotModeOpt->Enable( true );
|
|
|
|
m_choicePlotOffset->Enable( false );
|
|
|
|
m_linesWidth->Enable( false );
|
2009-06-30 10:43:20 +00:00
|
|
|
m_HPGLPenSizeOpt->Enable( false );
|
|
|
|
m_HPGLPenSpeedOpt->Enable( false );
|
|
|
|
m_HPGLPenOverlayOpt->Enable( false );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_excludeEdgeLayerOpt->SetValue( false );
|
|
|
|
m_excludeEdgeLayerOpt->Enable( false );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_subtractMaskFromSilk->Enable( false );
|
|
|
|
m_useGerberExtensions->Enable( false );
|
|
|
|
m_scaleOpt->Enable( false );
|
|
|
|
m_scaleOpt->SetSelection( 1 );
|
|
|
|
m_fineAdjustXscaleOpt->Enable( false );
|
|
|
|
m_fineAdjustYscaleOpt->Enable( false );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_plotPSNegativeOpt->SetValue( false );
|
|
|
|
m_plotPSNegativeOpt->Enable( false );
|
2009-06-30 10:43:20 +00:00
|
|
|
break;
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotFormat = format;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 10:10:42 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
void DIALOG_PLOT::savePlotOptions( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_ExcludeEdgeLayer = m_excludeEdgeLayerOpt->GetValue();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
g_PcbPlotOptions.SetSubtractMaskFromSilk( m_subtractMaskFromSilk->GetValue() );
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
if( m_plotSheetRef )
|
|
|
|
g_PcbPlotOptions.m_PlotFrameRef = m_plotSheetRef->GetValue();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
g_PcbPlotOptions.m_PlotPadsOnSilkLayer = m_plotPads_on_Silkscreen->GetValue();
|
2010-01-31 20:01:46 +00:00
|
|
|
|
2009-06-01 18:28:34 +00:00
|
|
|
s_PlotOriginIsAuxAxis =
|
2010-12-11 19:33:21 +00:00
|
|
|
(m_choicePlotOffset->GetSelection() == 0) ? FALSE : TRUE;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
g_PcbPlotOptions.m_PlotValue = m_plotModuleValueOpt->GetValue();
|
|
|
|
g_PcbPlotOptions.m_PlotReference = m_plotModuleRefOpt->GetValue();
|
|
|
|
g_PcbPlotOptions.m_PlotTextOther = m_plotTextOther->GetValue();
|
|
|
|
g_PcbPlotOptions.m_PlotInvisibleTexts = m_plotInvisibleText->GetValue();
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
m_dlgPlotScaleOpt = m_scaleOpt->GetSelection();
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_DrillShapeOpt =
|
2010-12-11 19:33:21 +00:00
|
|
|
(PCB_PLOT_PARAMS::DrillShapeOptT) m_drillShapeOpt->GetSelection();
|
|
|
|
g_PcbPlotOptions.m_PlotMirror = m_plotMirrorOpt->GetValue();
|
|
|
|
g_PcbPlotOptions.m_PlotMode = (GRTraceMode) m_plotModeOpt->GetSelection();
|
|
|
|
g_PcbPlotOptions.m_PlotViaOnMaskLayer = m_plotNoViaOnMaskOpt->GetValue();
|
2008-08-06 07:46:03 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
wxString msg = m_HPGLPenSizeOpt->GetValue();
|
2010-07-12 14:07:09 +00:00
|
|
|
int tmp = ReturnValueFromString( g_UserUnit, msg, UNITS_MILS );
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_HPGLPenDiam = tmp;
|
2010-01-01 13:30:39 +00:00
|
|
|
|
|
|
|
msg = m_HPGLPenSpeedOpt->GetValue();
|
2010-07-12 14:07:09 +00:00
|
|
|
tmp = ReturnValueFromString( MILLIMETRES, msg, 1 );
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_HPGLPenSpeed = tmp;
|
2010-01-01 13:30:39 +00:00
|
|
|
|
|
|
|
msg = m_HPGLPenOverlayOpt->GetValue();
|
2010-07-12 14:07:09 +00:00
|
|
|
tmp = ReturnValueFromString( g_UserUnit, msg, UNITS_MILS );
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_HPGLPenOvr = tmp;
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
msg = m_linesWidth->GetValue();
|
2010-07-12 14:07:09 +00:00
|
|
|
tmp = ReturnValueFromString( g_UserUnit, msg, PCB_INTERNAL_UNIT );
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotLineWidth = tmp;
|
|
|
|
g_DrawDefaultLineThickness = g_PcbPlotOptions.m_PlotLineWidth;
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
msg = m_fineAdjustXscaleOpt->GetValue();
|
2010-01-01 13:30:39 +00:00
|
|
|
msg.ToDouble( &m_XScaleAdjust );
|
2010-12-11 19:33:21 +00:00
|
|
|
msg = m_fineAdjustYscaleOpt->GetValue();
|
2010-01-01 13:30:39 +00:00
|
|
|
msg.ToDouble( &m_YScaleAdjust );
|
|
|
|
|
|
|
|
m_Config->Write( OPTKEY_GERBER_EXTENSIONS,
|
2010-12-11 19:33:21 +00:00
|
|
|
m_useGerberExtensions->GetValue() );
|
2010-01-01 13:30:39 +00:00
|
|
|
m_Config->Write( OPTKEY_XFINESCALE_ADJ, m_XScaleAdjust );
|
|
|
|
m_Config->Write( OPTKEY_YFINESCALE_ADJ, m_YScaleAdjust );
|
2009-12-30 18:06:12 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
g_PcbPlotOptions.m_PlotFormat = m_plotFormatOpt->GetSelection();
|
2009-12-30 18:06:12 +00:00
|
|
|
|
|
|
|
wxString layerKey;
|
2010-12-11 18:40:39 +00:00
|
|
|
for( int layer = 0; layer<NB_LAYERS; ++layer )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
if( m_BoxSelectLayer[layer] == NULL )
|
|
|
|
continue;
|
2009-12-30 18:06:12 +00:00
|
|
|
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
2010-01-01 13:30:39 +00:00
|
|
|
m_Config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotPSNegative = m_plotPSNegativeOpt->GetValue();
|
2010-11-21 15:12:37 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
g_PcbPlotOptions.SetOutputDirectory( m_outputDirectoryName->GetValue() );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 10:10:42 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
void DIALOG_PLOT::Plot( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
int layer;
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
|
|
|
wxString ext;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
BOARD* board = m_Parent->GetBoard();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
savePlotOptions( event );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-11-21 15:12:37 +00:00
|
|
|
// Create output directory if it does not exist
|
2010-12-11 19:33:21 +00:00
|
|
|
if( !wxFileName::DirExists( m_outputDirectoryName->GetValue() ) )
|
2010-11-21 15:12:37 +00:00
|
|
|
{
|
2010-12-11 19:33:21 +00:00
|
|
|
if( wxMkdir( m_outputDirectoryName->GetValue() ) )
|
2010-11-21 15:12:37 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2010-12-11 19:33:21 +00:00
|
|
|
msg.Printf( _( "Directory %s created.\n" ), GetChars( m_outputDirectoryName->GetValue() ) );
|
|
|
|
m_messagesBox->AppendText( msg );
|
2010-11-21 15:12:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "Cannot create output directory!" ), _( "Plot" ), wxICON_INFORMATION );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_AutoScale = false;
|
|
|
|
g_PcbPlotOptions.m_PlotScale = 1;
|
|
|
|
switch( m_dlgPlotScaleOpt )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
default:
|
2010-12-11 18:40:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
g_PcbPlotOptions.m_AutoScale = true;
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotScale = 1.5;
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotScale = 2;
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotScale = 3;
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-06-01 18:28:34 +00:00
|
|
|
/* If the scale factor edit controls are disabled or the scale value
|
|
|
|
* is 0, don't adjust the base scale factor. This fixes a bug when
|
|
|
|
* the default scale adjust is initialized to 0 and saved in program
|
|
|
|
* settings resulting in a divide by zero fault.
|
|
|
|
*/
|
2010-12-11 19:33:21 +00:00
|
|
|
if( m_fineAdjustXscaleOpt->IsEnabled() && m_XScaleAdjust != 0.0 )
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_FineScaleAdjustX = m_XScaleAdjust;
|
2010-12-11 19:33:21 +00:00
|
|
|
if( m_fineAdjustYscaleOpt->IsEnabled() && m_YScaleAdjust != 0.0 )
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_FineScaleAdjustY = m_YScaleAdjust;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-01-07 07:58:45 +00:00
|
|
|
int format = getFormat();
|
|
|
|
|
2008-03-22 05:55:06 +00:00
|
|
|
switch( format )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
case PLOT_FORMAT_POST:
|
2009-04-05 20:49:15 +00:00
|
|
|
ext = wxT( "ps" );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_GERBER:
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotScale = 1.0; // No scale option allowed in gerber format
|
2009-12-30 18:06:12 +00:00
|
|
|
ext = wxT( "pho" );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_HPGL:
|
2009-04-05 20:49:15 +00:00
|
|
|
ext = wxT( "plt" );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
2009-06-30 10:43:20 +00:00
|
|
|
|
|
|
|
case PLOT_FORMAT_DXF:
|
2010-12-11 18:40:39 +00:00
|
|
|
g_PcbPlotOptions.m_PlotScale = 1.0;
|
2009-06-30 10:43:20 +00:00
|
|
|
ext = wxT( "dxf" );
|
|
|
|
break;
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Test for a reasonable scale value
|
2010-12-11 18:40:39 +00:00
|
|
|
if( g_PcbPlotOptions.m_PlotScale < MIN_SCALE )
|
2009-06-01 18:28:34 +00:00
|
|
|
DisplayInfoMessage( this,
|
2009-12-30 18:06:12 +00:00
|
|
|
_( "Warning: Scale option set to a very small value" ) );
|
2010-12-11 18:40:39 +00:00
|
|
|
if( g_PcbPlotOptions.m_PlotScale > MAX_SCALE )
|
2009-06-01 18:28:34 +00:00
|
|
|
DisplayInfoMessage( this,
|
2009-12-30 18:06:12 +00:00
|
|
|
_( "Warning: Scale option set to a very large value" ) );
|
2009-01-07 07:58:45 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
int mask = 1;
|
|
|
|
s_SelectedLayers = 0;
|
2010-01-01 13:30:39 +00:00
|
|
|
for( layer = 0; layer < NB_LAYERS; layer++, mask <<= 1 )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
if( m_BoxSelectLayer[layer] == NULL )
|
|
|
|
continue;
|
|
|
|
bool success = false;
|
|
|
|
if( m_BoxSelectLayer[layer]->GetValue() )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
s_SelectedLayers |= mask;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = m_Parent->GetScreen()->m_FileName;
|
2010-12-11 19:33:21 +00:00
|
|
|
fn.SetPath( m_outputDirectoryName->GetValue() );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Create file name.
|
2010-01-01 13:30:39 +00:00
|
|
|
wxString layername = board->GetLayerName( layer );
|
|
|
|
layername.Trim( true ); layername.Trim( false ); // remove leading and trailing spaces if any
|
2009-12-30 18:06:12 +00:00
|
|
|
fn.SetName( fn.GetName() + wxT( "-" ) + layername );
|
|
|
|
|
|
|
|
// Use Gerber Extensions based on layer number
|
|
|
|
// (See http://en.wikipedia.org/wiki/Gerber_File)
|
2010-12-11 19:33:21 +00:00
|
|
|
if( (format == PLOT_FORMAT_GERBER) && m_useGerberExtensions->GetValue() )
|
2009-12-30 18:06:12 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
switch( layer )
|
2009-12-30 18:06:12 +00:00
|
|
|
{
|
|
|
|
case LAYER_N_FRONT:
|
|
|
|
fn.SetExt( wxT( "gtl" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAYER_N_2:
|
|
|
|
case LAYER_N_3:
|
|
|
|
case LAYER_N_4:
|
|
|
|
case LAYER_N_5:
|
|
|
|
case LAYER_N_6:
|
|
|
|
case LAYER_N_7:
|
|
|
|
case LAYER_N_8:
|
|
|
|
case LAYER_N_9:
|
|
|
|
case LAYER_N_10:
|
|
|
|
case LAYER_N_11:
|
|
|
|
case LAYER_N_12:
|
|
|
|
case LAYER_N_13:
|
|
|
|
case LAYER_N_14:
|
|
|
|
case LAYER_N_15:
|
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// TODO: see if we use .gbr or a layer identifier (gb1 .. gbnn ?)
|
|
|
|
// according to the new internal layers designation
|
2009-12-30 18:06:12 +00:00
|
|
|
// (1 is the first internal layer from the front layer)
|
|
|
|
fn.SetExt( wxT( "gbr" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAYER_N_BACK:
|
|
|
|
fn.SetExt( wxT( "gbl" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ADHESIVE_N_BACK:
|
|
|
|
fn.SetExt( wxT( "gba" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ADHESIVE_N_FRONT:
|
|
|
|
fn.SetExt( wxT( "gta" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SOLDERPASTE_N_BACK:
|
|
|
|
fn.SetExt( wxT( "gbp" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SOLDERPASTE_N_FRONT:
|
|
|
|
fn.SetExt( wxT( "gtp" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SILKSCREEN_N_BACK:
|
|
|
|
fn.SetExt( wxT( "gbo" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SILKSCREEN_N_FRONT:
|
|
|
|
fn.SetExt( wxT( "gto" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SOLDERMASK_N_BACK:
|
|
|
|
fn.SetExt( wxT( "gbs" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SOLDERMASK_N_FRONT:
|
|
|
|
fn.SetExt( wxT( "gts" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_N:
|
|
|
|
case COMMENT_N:
|
|
|
|
case ECO1_N:
|
|
|
|
case ECO2_N:
|
|
|
|
case EDGE_N:
|
2010-01-01 13:30:39 +00:00
|
|
|
default:
|
2009-12-30 18:06:12 +00:00
|
|
|
fn.SetExt( wxT( "gbr" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fn.SetExt( ext );
|
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2008-03-22 05:55:06 +00:00
|
|
|
switch( format )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
case PLOT_FORMAT_POST:
|
2010-01-01 13:30:39 +00:00
|
|
|
success = m_Parent->Genere_PS( fn.GetFullPath(), layer, useA4(),
|
2010-12-11 19:33:21 +00:00
|
|
|
g_PcbPlotOptions.m_PlotMode );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_GERBER:
|
2010-01-01 13:30:39 +00:00
|
|
|
success = m_Parent->Genere_GERBER( fn.GetFullPath(), layer,
|
|
|
|
s_PlotOriginIsAuxAxis,
|
2010-12-11 19:33:21 +00:00
|
|
|
g_PcbPlotOptions.m_PlotMode );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_HPGL:
|
2010-01-01 13:30:39 +00:00
|
|
|
success = m_Parent->Genere_HPGL( fn.GetFullPath(), layer,
|
2010-12-11 19:33:21 +00:00
|
|
|
g_PcbPlotOptions.m_PlotMode );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
2009-06-30 10:43:20 +00:00
|
|
|
|
|
|
|
case PLOT_FORMAT_DXF:
|
2010-01-01 13:30:39 +00:00
|
|
|
success = m_Parent->Genere_DXF( fn.GetFullPath(), layer,
|
2010-12-11 19:33:21 +00:00
|
|
|
g_PcbPlotOptions.m_PlotMode );
|
2009-06-30 10:43:20 +00:00
|
|
|
break;
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
2010-01-01 13:30:39 +00:00
|
|
|
|
|
|
|
// Print diags in messages box:
|
|
|
|
wxString msg;
|
|
|
|
if( success )
|
|
|
|
msg.Printf( _( "Plot file <%s> created" ), GetChars( fn.GetFullPath() ) );
|
|
|
|
else
|
|
|
|
msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) );
|
|
|
|
msg << wxT( "\n" );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// If no layer selected, we have nothing plotted.
|
|
|
|
// Prompt user if it happens
|
2009-03-10 08:26:52 +00:00
|
|
|
// because he could think there is a bug in pcbnew:
|
2009-06-01 18:28:34 +00:00
|
|
|
if( s_SelectedLayers == 0 )
|
|
|
|
DisplayError( this, _( "No layer selected" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
void WinEDA_PcbFrame::ToPlotter( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-12-11 18:40:39 +00:00
|
|
|
DIALOG_PLOT dlg( this );
|
|
|
|
dlg.ShowModal();
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|