2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file pcbnew/pcbplot.cpp
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-06-09 09:38:58 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 1992-2012 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
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <plot_common.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <pcbplot.h>
|
|
|
|
#include <worksheet.h>
|
|
|
|
#include <pcbstruct.h>
|
|
|
|
#include <macros.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <protos.h>
|
|
|
|
#include <dialog_plot_base.h>
|
|
|
|
#include <pcb_plot_params.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
/* Keywords to r/w options in m_config */
|
2011-02-03 22:26:30 +00:00
|
|
|
#define CONFIG_XFINESCALE_ADJ wxT( "PlotXFineScaleAdj" )
|
|
|
|
#define CONFIG_YFINESCALE_ADJ wxT( "PlotYFineScaleAdj" )
|
2012-01-07 06:02:38 +00:00
|
|
|
#define CONFIG_PS_FINEWIDTH_ADJ wxT( "PSPlotFineWidthAdj" )
|
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
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
static bool setDouble( double* aDouble, double aValue, double aMin, double aMax )
|
|
|
|
{
|
|
|
|
if( aValue < aMin )
|
|
|
|
{
|
|
|
|
*aDouble = aMin;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if( aValue > aMax )
|
|
|
|
{
|
|
|
|
*aDouble = aMax;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aDouble = aValue;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
/**
|
|
|
|
* Class DIALOG_PLOT
|
|
|
|
*
|
|
|
|
*/
|
2010-01-01 13:30:39 +00:00
|
|
|
class DIALOG_PLOT : public DIALOG_PLOT_BASE
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-03-01 22:36:38 +00:00
|
|
|
public:
|
|
|
|
DIALOG_PLOT( PCB_EDIT_FRAME* parent );
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
private:
|
2012-04-05 18:27:56 +00:00
|
|
|
PCB_EDIT_FRAME* m_parent;
|
|
|
|
BOARD* m_board;
|
|
|
|
wxConfig* m_config;
|
|
|
|
std::vector<int> layerList; // List to hold CheckListBox layer numbers
|
|
|
|
double m_XScaleAdjust;
|
|
|
|
double m_YScaleAdjust;
|
|
|
|
double m_PSWidthAdjust; // Global width correction for exact width postscript output.
|
|
|
|
double m_WidthAdjustMinValue; // Global width correction
|
|
|
|
double m_WidthAdjustMaxValue; // margins.
|
|
|
|
|
|
|
|
PCB_PLOT_PARAMS m_plotOpts;
|
|
|
|
|
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 );
|
2011-02-15 22:54:23 +00:00
|
|
|
void applyPlotSettings();
|
2008-08-06 07:46:03 +00:00
|
|
|
void CreateDrillFile( wxCommandEvent& event );
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2012-06-27 20:07:37 +00:00
|
|
|
//const int UNITS_MILS = 1000;
|
2007-08-24 10:10:42 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
|
|
|
|
DIALOG_PLOT_BASE( aParent ),
|
|
|
|
m_parent( aParent ),
|
|
|
|
m_board( aParent->GetBoard() ),
|
|
|
|
m_plotOpts( aParent->GetPlotSettings() )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config = wxGetApp().GetSettings();
|
2010-01-01 13:30:39 +00:00
|
|
|
|
|
|
|
Init_Dialog();
|
|
|
|
|
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2008-10-30 10:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Read( CONFIG_XFINESCALE_ADJ, &m_XScaleAdjust );
|
|
|
|
m_config->Read( CONFIG_YFINESCALE_ADJ, &m_YScaleAdjust );
|
|
|
|
m_config->Read( CONFIG_PS_FINEWIDTH_ADJ, &m_PSWidthAdjust);
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2012-01-07 06:02:38 +00:00
|
|
|
// The reasonable width correction value must be in a range of
|
|
|
|
// [-(MinTrackWidth-1), +(MinClearanceValue-1)] decimils.
|
2012-04-05 18:27:56 +00:00
|
|
|
m_WidthAdjustMinValue = -(m_board->GetDesignSettings().m_TrackMinWidth - 1);
|
|
|
|
m_WidthAdjustMaxValue = m_board->GetSmallestClearanceValue() - 1;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotFormatOpt->SetSelection( m_plotOpts.GetPlotFormat() );
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2012-06-09 09:38:58 +00:00
|
|
|
// Set units and value for HPGL pen size (this param in in mils).
|
2010-07-12 14:07:09 +00:00
|
|
|
AddUnitSymbol( *m_textPenSize, g_UserUnit );
|
2012-06-09 09:38:58 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit,
|
|
|
|
m_plotOpts.GetHpglPenDiameter() * IU_PER_MILS );
|
2010-01-01 13:30:39 +00:00
|
|
|
m_HPGLPenSizeOpt->AppendText( msg );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2012-06-09 09:38:58 +00:00
|
|
|
// Units are *always* cm/s for HPGL pen speed, from 1 to 99.
|
|
|
|
msg = ReturnStringFromValue( UNSCALED_UNITS, m_plotOpts.GetHpglPenSpeed() );
|
2010-01-01 13:30:39 +00:00
|
|
|
m_HPGLPenSpeedOpt->AppendText( msg );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2012-06-09 09:38:58 +00:00
|
|
|
// Set units and value for HPGL pen overlay (this param in in mils).
|
2010-07-12 14:07:09 +00:00
|
|
|
AddUnitSymbol( *m_textPenOvr, g_UserUnit );
|
2012-06-09 09:38:58 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit,
|
|
|
|
m_plotOpts.GetHpglPenOverlay() * IU_PER_MILS );
|
2010-01-01 13:30:39 +00:00
|
|
|
m_HPGLPenOverlayOpt->AppendText( msg );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-01-30 18:55:56 +00:00
|
|
|
AddUnitSymbol( *m_textDefaultPenSize, g_UserUnit );
|
2012-04-13 18:51:24 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, m_plotOpts.GetPlotLineWidth() );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_linesWidth->AppendText( msg );
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2012-01-07 06:02:38 +00:00
|
|
|
// Set units for PS global width correction.
|
|
|
|
AddUnitSymbol( *m_textPSFineAdjustWidth, g_UserUnit );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_useAuxOriginCheckBox->SetValue( m_plotOpts.GetUseAuxOrigin() );
|
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 );
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2012-01-07 06:02:38 +00:00
|
|
|
// Test for a reasonable PS width correction value. Set to 0 if problem.
|
|
|
|
if( m_PSWidthAdjust < m_WidthAdjustMinValue || m_PSWidthAdjust > m_WidthAdjustMaxValue )
|
|
|
|
m_PSWidthAdjust = 0.;
|
|
|
|
|
2012-04-13 18:51:24 +00:00
|
|
|
msg.Printf( wxT( "%f" ), To_User_Unit( g_UserUnit, m_PSWidthAdjust ) );
|
2012-01-07 06:02:38 +00:00
|
|
|
m_PSFineAdjustWidthOpt->AppendText( msg );
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotPSNegativeOpt->SetValue( m_plotOpts.m_PlotPSNegative );
|
|
|
|
m_forcePSA4OutputOpt->SetValue( m_plotOpts.GetPsA4Output() );
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// 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 );
|
2011-02-15 22:54:23 +00:00
|
|
|
int layerIndex, checkIndex, layer;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2011-02-15 22:54:23 +00:00
|
|
|
for( layerIndex = 0; layerIndex < NB_LAYERS; layerIndex++ )
|
2008-03-21 19:27:11 +00:00
|
|
|
{
|
2011-02-15 22:54:23 +00:00
|
|
|
layer = layersOrder[layerIndex];
|
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
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
if( !m_board->IsLayerEnabled( layer ) )
|
2010-01-01 13:30:39 +00:00
|
|
|
continue;
|
2008-03-21 19:27:11 +00:00
|
|
|
|
2011-02-15 22:54:23 +00:00
|
|
|
layerList.push_back( layer );
|
2012-04-05 18:27:56 +00:00
|
|
|
checkIndex = m_layerCheckListBox->Append( m_board->GetLayerName( layer ) );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_plotOpts.GetLayerSelection() & ( 1 << layer ) )
|
2011-03-01 22:36:38 +00:00
|
|
|
m_layerCheckListBox->Check( checkIndex );
|
2009-12-30 18:06:12 +00:00
|
|
|
}
|
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Option for using proper Gerber extensions
|
2012-04-05 18:27:56 +00:00
|
|
|
m_useGerberExtensions->SetValue( m_plotOpts.GetUseGerberExtensions() );
|
2009-12-30 18:06:12 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
// Option for excluding contents of "Edges Pcb" layer
|
2012-04-05 18:27:56 +00:00
|
|
|
m_excludeEdgeLayerOpt->SetValue( m_plotOpts.m_ExcludeEdgeLayer );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_subtractMaskFromSilk->SetValue( m_plotOpts.GetSubtractMaskFromSilk() );
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2008-04-18 13:28:56 +00:00
|
|
|
// Option to plot page references:
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_parent->GetPrintBorderAndTitleBlock() )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotSheetRef->SetValue( m_plotOpts.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 );
|
2011-01-30 18:55:56 +00:00
|
|
|
m_plotSheetRef->SetValue( 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
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotPads_on_Silkscreen->SetValue( m_plotOpts.m_PlotPadsOnSilkLayer );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-01-07 07:58:45 +00:00
|
|
|
// Options to plot texts on footprints
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotModuleValueOpt->SetValue( m_plotOpts.m_PlotValue );
|
|
|
|
m_plotModuleRefOpt->SetValue( m_plotOpts.m_PlotReference );
|
|
|
|
m_plotTextOther->SetValue( m_plotOpts.m_PlotTextOther );
|
|
|
|
m_plotInvisibleText->SetValue( m_plotOpts.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
|
2012-04-05 18:27:56 +00:00
|
|
|
m_drillShapeOpt->SetSelection( m_plotOpts.m_DrillShapeOpt );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Scale option
|
2012-04-05 18:27:56 +00:00
|
|
|
m_scaleOpt->SetSelection( m_plotOpts.GetScaleSelection() );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Plot mode
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotModeOpt->SetSelection( m_plotOpts.m_PlotMode );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Plot mirror option
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotMirrorOpt->SetValue( m_plotOpts.m_PlotMirror );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Put vias on mask layer
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotNoViaOnMaskOpt->SetValue( m_plotOpts.m_PlotViaOnMaskLayer );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-11-21 15:12:37 +00:00
|
|
|
// Output directory
|
2012-04-05 18:27:56 +00:00
|
|
|
m_outputDirectoryName->SetValue( m_plotOpts.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 );
|
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
|
|
|
{
|
2011-02-15 22:54:23 +00:00
|
|
|
applyPlotSettings();
|
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
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
( (PCB_EDIT_FRAME*) 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 )
|
|
|
|
{
|
2011-02-01 18:37:32 +00:00
|
|
|
// Build the absolute path of current output plot directory
|
2011-03-22 17:58:58 +00:00
|
|
|
// to preselect it when opening the dialog.
|
2011-02-01 18:37:32 +00:00
|
|
|
wxFileName fn( m_outputDirectoryName->GetValue() );
|
|
|
|
wxString path;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2011-02-01 18:37:32 +00:00
|
|
|
if( fn.IsRelative() )
|
|
|
|
path = wxGetCwd() + fn.GetPathSeparator() + m_outputDirectoryName->GetValue();
|
|
|
|
else
|
|
|
|
path = m_outputDirectoryName->GetValue();
|
|
|
|
|
|
|
|
wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2010-11-21 15:12:37 +00:00
|
|
|
if( dirDialog.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
2011-01-30 18:55:56 +00:00
|
|
|
|
|
|
|
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
|
|
|
|
2012-01-17 15:02:17 +00:00
|
|
|
wxMessageDialog dialog( this, _( "Use a relative path? "),
|
|
|
|
_( "Plot Output Directory" ),
|
2011-01-30 18:55:56 +00:00
|
|
|
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
|
|
|
|
|
|
|
if( dialog.ShowModal() == wxID_YES ) {
|
2012-04-05 18:27:56 +00:00
|
|
|
wxString boardFilePath = ( (wxFileName) m_parent->GetScreen()->GetFileName()).GetPath();
|
2011-01-30 18:55:56 +00:00
|
|
|
|
|
|
|
if( !dirName.MakeRelativeTo( boardFilePath ) )
|
2012-01-17 15:02:17 +00:00
|
|
|
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ),
|
|
|
|
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
|
2011-01-30 18:55:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_outputDirectoryName->SetValue( dirName.GetFullPath() );
|
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
|
|
|
{
|
2011-02-16 22:54:44 +00:00
|
|
|
switch( m_plotFormatOpt->GetSelection() )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
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 );
|
2011-01-30 18:55:56 +00:00
|
|
|
m_useAuxOriginCheckBox->Enable( false );
|
2010-12-11 19:33:21 +00:00
|
|
|
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 );
|
2012-01-07 06:02:38 +00:00
|
|
|
m_PSFineAdjustWidthOpt->Enable( true );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_plotPSNegativeOpt->Enable( true );
|
2011-02-01 23:03:26 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Show( m_PSOptionsSizer );
|
|
|
|
Layout();
|
|
|
|
m_MainSizer->SetSizeHints( this );
|
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 );
|
2011-01-30 18:55:56 +00:00
|
|
|
m_useAuxOriginCheckBox->Enable( true );
|
2010-12-11 19:33:21 +00:00
|
|
|
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 );
|
2012-01-07 06:02:38 +00:00
|
|
|
m_PSFineAdjustWidthOpt->Enable( false );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_plotPSNegativeOpt->SetValue( false );
|
|
|
|
m_plotPSNegativeOpt->Enable( false );
|
2011-02-01 23:03:26 +00:00
|
|
|
m_PlotOptionsSizer->Show( m_GerberOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
|
|
|
|
Layout();
|
|
|
|
m_MainSizer->SetSizeHints( this );
|
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 );
|
2011-01-30 18:55:56 +00:00
|
|
|
m_useAuxOriginCheckBox->Enable( false );
|
2010-12-11 19:33:21 +00:00
|
|
|
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 );
|
2012-01-07 06:02:38 +00:00
|
|
|
m_PSFineAdjustWidthOpt->Enable( false );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_plotPSNegativeOpt->SetValue( false );
|
|
|
|
m_plotPSNegativeOpt->Enable( false );
|
2011-02-01 23:03:26 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Show( m_HPGLOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
|
|
|
|
Layout();
|
|
|
|
m_MainSizer->SetSizeHints( this );
|
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 );
|
2011-01-30 18:55:56 +00:00
|
|
|
m_useAuxOriginCheckBox->Enable( false );
|
2010-12-11 19:33:21 +00:00
|
|
|
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 );
|
2012-01-07 06:02:38 +00:00
|
|
|
m_PSFineAdjustWidthOpt->Enable( false );
|
2010-12-11 18:40:39 +00:00
|
|
|
m_plotPSNegativeOpt->SetValue( false );
|
|
|
|
m_plotPSNegativeOpt->Enable( false );
|
2011-02-01 23:03:26 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
|
|
|
|
Layout();
|
|
|
|
m_MainSizer->SetSizeHints( this );
|
2009-06-30 10:43:20 +00:00
|
|
|
break;
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 10:10:42 +00:00
|
|
|
|
2011-02-15 22:54:23 +00:00
|
|
|
void DIALOG_PLOT::applyPlotSettings()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-01-28 22:54:16 +00:00
|
|
|
PCB_PLOT_PARAMS tempOptions;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
tempOptions.m_ExcludeEdgeLayer = m_excludeEdgeLayerOpt->GetValue();
|
|
|
|
|
|
|
|
tempOptions.SetSubtractMaskFromSilk( m_subtractMaskFromSilk->GetValue() );
|
2010-12-06 22:05:12 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
if( m_plotSheetRef )
|
2011-01-28 22:54:16 +00:00
|
|
|
tempOptions.m_PlotFrameRef = m_plotSheetRef->GetValue();
|
|
|
|
|
|
|
|
tempOptions.m_PlotPadsOnSilkLayer = m_plotPads_on_Silkscreen->GetValue();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-01-30 18:55:56 +00:00
|
|
|
tempOptions.SetUseAuxOrigin( m_useAuxOriginCheckBox->GetValue() );
|
2010-01-31 20:01:46 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
tempOptions.m_PlotValue = m_plotModuleValueOpt->GetValue();
|
|
|
|
tempOptions.m_PlotReference = m_plotModuleRefOpt->GetValue();
|
|
|
|
tempOptions.m_PlotTextOther = m_plotTextOther->GetValue();
|
|
|
|
tempOptions.m_PlotInvisibleTexts = m_plotInvisibleText->GetValue();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
tempOptions.SetScaleSelection( m_scaleOpt->GetSelection() );
|
2010-12-11 18:40:39 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
tempOptions.m_DrillShapeOpt =
|
2010-12-11 19:33:21 +00:00
|
|
|
(PCB_PLOT_PARAMS::DrillShapeOptT) m_drillShapeOpt->GetSelection();
|
2011-01-28 22:54:16 +00:00
|
|
|
tempOptions.m_PlotMirror = m_plotMirrorOpt->GetValue();
|
2012-01-03 17:14:17 +00:00
|
|
|
tempOptions.m_PlotMode = (EDA_DRAW_MODE_T) m_plotModeOpt->GetSelection();
|
2011-01-28 22:54:16 +00:00
|
|
|
tempOptions.m_PlotViaOnMaskLayer = m_plotNoViaOnMaskOpt->GetValue();
|
2008-08-06 07:46:03 +00:00
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
// Update settings from text fields. Rewrite values back to the fields,
|
|
|
|
// since the values may have been constrained by the setters.
|
2012-06-09 09:38:58 +00:00
|
|
|
|
|
|
|
// read HPLG pen size (this param is stored in mils)
|
2010-01-01 13:30:39 +00:00
|
|
|
wxString msg = m_HPGLPenSizeOpt->GetValue();
|
2012-06-09 09:38:58 +00:00
|
|
|
int tmp = ReturnValueFromString( g_UserUnit, msg ) / IU_PER_MILS;
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
if( !tempOptions.SetHpglPenDiameter( tmp ) )
|
|
|
|
{
|
2012-06-09 09:38:58 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetHpglPenDiameter() * IU_PER_MILS );
|
2011-02-03 22:26:30 +00:00
|
|
|
m_HPGLPenSizeOpt->SetValue( msg );
|
2012-01-17 15:02:17 +00:00
|
|
|
msg.Printf( _( "HPGL pen size constrained!\n" ) );
|
2011-02-03 22:26:30 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
|
|
|
}
|
|
|
|
|
2012-06-09 09:38:58 +00:00
|
|
|
// read HPGL pen speed (this param is stored in cm/s)
|
2010-01-01 13:30:39 +00:00
|
|
|
msg = m_HPGLPenSpeedOpt->GetValue();
|
2012-04-16 17:39:32 +00:00
|
|
|
tmp = ReturnValueFromString( UNSCALED_UNITS, msg );
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
if( !tempOptions.SetHpglPenSpeed( tmp ) )
|
|
|
|
{
|
2012-06-09 09:38:58 +00:00
|
|
|
msg = ReturnStringFromValue( UNSCALED_UNITS, tempOptions.GetHpglPenSpeed() );
|
2011-02-03 22:26:30 +00:00
|
|
|
m_HPGLPenSpeedOpt->SetValue( msg );
|
2012-01-17 15:02:17 +00:00
|
|
|
msg.Printf( _( "HPGL pen speed constrained!\n" ) );
|
2011-02-03 22:26:30 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
|
|
|
}
|
|
|
|
|
2012-06-09 09:38:58 +00:00
|
|
|
// Read HPGL pen overlay (this param is stored in mils)
|
2010-01-01 13:30:39 +00:00
|
|
|
msg = m_HPGLPenOverlayOpt->GetValue();
|
2012-06-09 09:38:58 +00:00
|
|
|
tmp = ReturnValueFromString( g_UserUnit, msg ) / IU_PER_MILS;
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
if( !tempOptions.SetHpglPenOverlay( tmp ) )
|
|
|
|
{
|
2012-06-09 09:38:58 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit,
|
|
|
|
tempOptions.GetHpglPenOverlay() * IU_PER_MILS );
|
2011-02-03 22:26:30 +00:00
|
|
|
m_HPGLPenOverlayOpt->SetValue( msg );
|
2012-01-17 15:02:17 +00:00
|
|
|
msg.Printf( _( "HPGL pen overlay constrained!\n" ) );
|
2011-02-03 22:26:30 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Default linewidth
|
2010-12-11 19:33:21 +00:00
|
|
|
msg = m_linesWidth->GetValue();
|
2012-04-16 17:39:32 +00:00
|
|
|
tmp = ReturnValueFromString( g_UserUnit, msg );
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
if( !tempOptions.SetPlotLineWidth( tmp ) )
|
|
|
|
{
|
2012-04-13 18:51:24 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetPlotLineWidth() );
|
2011-02-03 22:26:30 +00:00
|
|
|
m_linesWidth->SetValue( msg );
|
2012-01-17 15:02:17 +00:00
|
|
|
msg.Printf( _( "Default linewidth constrained!\n" ) );
|
2011-02-03 22:26:30 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
// X scale
|
|
|
|
double tmpDouble;
|
2010-12-11 19:33:21 +00:00
|
|
|
msg = m_fineAdjustXscaleOpt->GetValue();
|
2011-02-03 22:26:30 +00:00
|
|
|
msg.ToDouble( &tmpDouble );
|
|
|
|
|
|
|
|
if( !setDouble( &m_XScaleAdjust, tmpDouble, MIN_SCALE, MAX_SCALE ) )
|
|
|
|
{
|
|
|
|
msg.Printf( wxT( "%f" ), m_XScaleAdjust );
|
|
|
|
m_fineAdjustXscaleOpt->SetValue( msg );
|
2012-01-17 15:02:17 +00:00
|
|
|
msg.Printf( _( "X scale constrained!\n" ) );
|
2011-02-03 22:26:30 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
|
|
|
}
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Write( CONFIG_XFINESCALE_ADJ, m_XScaleAdjust );
|
2011-02-03 22:26:30 +00:00
|
|
|
|
|
|
|
// Y scale
|
2010-12-11 19:33:21 +00:00
|
|
|
msg = m_fineAdjustYscaleOpt->GetValue();
|
2011-02-03 22:26:30 +00:00
|
|
|
msg.ToDouble( &tmpDouble );
|
|
|
|
|
|
|
|
if( !setDouble( &m_YScaleAdjust, tmpDouble, MIN_SCALE, MAX_SCALE ) )
|
|
|
|
{
|
|
|
|
msg.Printf( wxT( "%f" ), m_YScaleAdjust );
|
|
|
|
m_fineAdjustYscaleOpt->SetValue( msg );
|
2012-01-17 15:02:17 +00:00
|
|
|
msg.Printf( _( "Y scale constrained!\n" ) );
|
2011-02-03 22:26:30 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
|
|
|
}
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Write( CONFIG_YFINESCALE_ADJ, m_YScaleAdjust );
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2012-01-07 06:02:38 +00:00
|
|
|
// PS Width correction
|
|
|
|
msg = m_PSFineAdjustWidthOpt->GetValue();
|
2012-04-16 17:39:32 +00:00
|
|
|
tmpDouble = ReturnValueFromString( g_UserUnit, msg );
|
2012-01-07 06:02:38 +00:00
|
|
|
|
|
|
|
if( !setDouble( &m_PSWidthAdjust, tmpDouble, m_WidthAdjustMinValue, m_WidthAdjustMaxValue ) )
|
|
|
|
{
|
2012-04-13 18:51:24 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, m_PSWidthAdjust );
|
2012-01-07 06:02:38 +00:00
|
|
|
m_PSFineAdjustWidthOpt->SetValue( msg );
|
2012-02-05 13:02:46 +00:00
|
|
|
msg.Printf( _( "Width correction constrained!\n"
|
|
|
|
"The reasonable width correction value must be in a range of\n"
|
|
|
|
" [%+f; %+f] (%s) for current design rules!\n" ),
|
2012-04-13 18:51:24 +00:00
|
|
|
To_User_Unit( g_UserUnit, m_WidthAdjustMinValue ),
|
|
|
|
To_User_Unit( g_UserUnit, m_WidthAdjustMaxValue ),
|
2012-02-05 13:02:46 +00:00
|
|
|
( g_UserUnit == INCHES )? wxT("\"") : wxT("mm") );
|
2012-01-07 06:02:38 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
|
|
|
}
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Write( CONFIG_PS_FINEWIDTH_ADJ, m_PSWidthAdjust );
|
2009-12-30 18:06:12 +00:00
|
|
|
|
2011-01-30 18:55:56 +00:00
|
|
|
tempOptions.SetUseGerberExtensions( m_useGerberExtensions->GetValue() );
|
|
|
|
|
2011-02-16 22:54:44 +00:00
|
|
|
tempOptions.SetPlotFormat( m_plotFormatOpt->GetSelection() );
|
2009-12-30 18:06:12 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
long selectedLayers = 0;
|
2011-02-15 22:54:23 +00:00
|
|
|
unsigned int i;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2011-02-15 22:54:23 +00:00
|
|
|
for( i = 0; i < layerList.size(); i++ )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2011-03-01 22:36:38 +00:00
|
|
|
if( m_layerCheckListBox->IsChecked( i ) )
|
2011-02-15 22:54:23 +00:00
|
|
|
selectedLayers |= (1 << layerList[i]);
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
tempOptions.SetLayerSelection( selectedLayers );
|
2011-01-28 22:54:16 +00:00
|
|
|
tempOptions.m_PlotPSNegative = m_plotPSNegativeOpt->GetValue();
|
2011-02-17 17:11:20 +00:00
|
|
|
tempOptions.SetPsA4Output( m_forcePSA4OutputOpt->GetValue() );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-01-30 18:55:56 +00:00
|
|
|
// Set output directory and replace backslashes with forward ones
|
|
|
|
wxString dirStr;
|
|
|
|
dirStr = m_outputDirectoryName->GetValue();
|
|
|
|
dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
|
|
|
|
tempOptions.SetOutputDirectory( dirStr );
|
2010-11-21 15:12:37 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_plotOpts != tempOptions )
|
2011-01-28 22:54:16 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
m_parent->SetPlotSettings( tempOptions );
|
|
|
|
m_plotOpts = tempOptions;
|
|
|
|
m_parent->OnModify();
|
2011-01-28 22:54:16 +00:00
|
|
|
}
|
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
|
|
|
|
2011-02-15 22:54:23 +00:00
|
|
|
applyPlotSettings();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-11-21 15:12:37 +00:00
|
|
|
// Create output directory if it does not exist
|
2012-04-05 18:27:56 +00:00
|
|
|
wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() );
|
|
|
|
wxString boardFilePath = ( (wxFileName) m_parent->GetScreen()->GetFileName()).GetPath();
|
2011-01-30 18:55:56 +00:00
|
|
|
|
|
|
|
if( !outputDir.MakeAbsolute( boardFilePath ) )
|
|
|
|
{
|
|
|
|
wxString msg;
|
2012-01-17 15:02:17 +00:00
|
|
|
msg.Printf( _( " Cannot make %s absolute with respect to %s!" ),
|
2011-01-30 18:55:56 +00:00
|
|
|
GetChars( outputDir.GetPath() ),
|
|
|
|
GetChars( boardFilePath ) );
|
2012-01-17 15:02:17 +00:00
|
|
|
wxMessageBox( msg, _( "Plot" ), wxOK | wxICON_ERROR );
|
2011-01-30 18:55:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !wxFileName::DirExists( outputDir.GetPath() ) )
|
2010-11-21 15:12:37 +00:00
|
|
|
{
|
2011-01-30 18:55:56 +00:00
|
|
|
if( wxMkdir( outputDir.GetPath() ) )
|
2010-11-21 15:12:37 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2012-01-17 15:02:17 +00:00
|
|
|
msg.Printf( _( "Directory %s created.\n" ), GetChars( outputDir.GetPath() ) );
|
2010-12-11 19:33:21 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
2010-11-21 15:12:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-17 15:02:17 +00:00
|
|
|
wxMessageBox( _( "Cannot create output directory!" ),
|
2012-04-13 18:51:24 +00:00
|
|
|
_( "Plot" ), wxOK | wxICON_ERROR );
|
2010-11-21 15:12:37 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotOpts.m_AutoScale = false;
|
|
|
|
m_plotOpts.m_PlotScale = 1;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
switch( m_plotOpts.GetScaleSelection() )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
default:
|
2010-12-11 18:40:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotOpts.m_AutoScale = true;
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotOpts.m_PlotScale = 1.5;
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotOpts.m_PlotScale = 2;
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotOpts.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 )
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotOpts.m_FineScaleAdjustX = m_XScaleAdjust;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2010-12-11 19:33:21 +00:00
|
|
|
if( m_fineAdjustYscaleOpt->IsEnabled() && m_YScaleAdjust != 0.0 )
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotOpts.m_FineScaleAdjustY = m_YScaleAdjust;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2012-01-07 06:02:38 +00:00
|
|
|
if( m_PSFineAdjustWidthOpt->IsEnabled() )
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotOpts.m_FineWidthAdjust = m_PSWidthAdjust;
|
2012-01-07 06:02:38 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
switch( m_plotOpts.GetPlotFormat() )
|
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:
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotOpts.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:
|
2012-04-05 18:27:56 +00:00
|
|
|
m_plotOpts.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
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_plotOpts.m_PlotScale < MIN_SCALE )
|
2009-06-01 18:28:34 +00:00
|
|
|
DisplayInfoMessage( this,
|
2011-09-29 16:49:40 +00:00
|
|
|
_( "Warning: Scale option set to a very small value" ) );
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_plotOpts.m_PlotScale > MAX_SCALE )
|
2009-06-01 18:28:34 +00:00
|
|
|
DisplayInfoMessage( this,
|
2011-09-29 16:49:40 +00:00
|
|
|
_( "Warning: Scale option set to a very large value" ) );
|
2009-01-07 07:58:45 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
m_parent->SetPlotSettings( m_plotOpts );
|
|
|
|
|
2011-02-16 22:54:44 +00:00
|
|
|
long layerMask = 1;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2011-02-16 22:54:44 +00:00
|
|
|
for( layer = 0; layer < NB_LAYERS; layer++, layerMask <<= 1 )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
bool success = false;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_plotOpts.GetLayerSelection() & layerMask )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
fn = m_parent->GetScreen()->GetFileName();
|
2011-01-30 18:55:56 +00:00
|
|
|
fn.SetPath( outputDir.GetPath() );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-06-27 20:07:37 +00:00
|
|
|
// Create file name (from the English layer name for non copper layers).
|
|
|
|
wxString layername = m_board->GetLayerName( layer, false );
|
|
|
|
// remove leading and trailing spaces if any
|
|
|
|
layername.Trim( true ); layername.Trim( false );
|
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)
|
2012-04-05 18:27:56 +00:00
|
|
|
if( ( m_plotOpts.GetPlotFormat() == PLOT_FORMAT_GERBER )
|
2011-02-16 22:54:44 +00:00
|
|
|
&& 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
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
switch( m_plotOpts.GetPlotFormat() )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
case PLOT_FORMAT_POST:
|
2012-04-05 18:27:56 +00:00
|
|
|
success = m_parent->ExportToPostScriptFile( fn.GetFullPath(), layer,
|
|
|
|
m_plotOpts.GetPsA4Output(),
|
|
|
|
m_plotOpts.m_PlotMode );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_GERBER:
|
2012-04-05 18:27:56 +00:00
|
|
|
success = m_parent->ExportToGerberFile( fn.GetFullPath(), layer,
|
|
|
|
m_plotOpts.GetUseAuxOrigin(),
|
|
|
|
m_plotOpts.m_PlotMode );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_HPGL:
|
2012-04-05 18:27:56 +00:00
|
|
|
success = m_parent->ExportToHpglFile( fn.GetFullPath(), layer,
|
|
|
|
m_plotOpts.m_PlotMode );
|
2008-03-04 04:22:27 +00:00
|
|
|
break;
|
2009-06-30 10:43:20 +00:00
|
|
|
|
|
|
|
case PLOT_FORMAT_DXF:
|
2012-04-05 18:27:56 +00:00
|
|
|
success = m_parent->ExportToDxfFile( fn.GetFullPath(), layer,
|
|
|
|
m_plotOpts.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;
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
if( success )
|
|
|
|
msg.Printf( _( "Plot file <%s> created" ), GetChars( fn.GetFullPath() ) );
|
|
|
|
else
|
|
|
|
msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) );
|
2011-09-29 16:49:40 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
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.
|
2011-09-30 18:15:37 +00:00
|
|
|
// Prompt user if it happens because he could think there is a bug in Pcbnew.
|
2012-04-05 18:27:56 +00:00
|
|
|
if( !m_plotOpts.GetLayerSelection() )
|
2009-06-01 18:28:34 +00:00
|
|
|
DisplayError( this, _( "No layer selected" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::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
|
|
|
}
|