2012-08-31 07:43:37 +00:00
|
|
|
/**
|
2012-09-12 17:28:55 +00:00
|
|
|
* @file pcbnew/dialogs/dialog_SVG_print.cpp
|
2012-08-31 07:43:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2012 KiCad Developers, see change_log.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
|
|
|
|
*/
|
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <wxBasePcbFrame.h>
|
|
|
|
#include <class_pcb_screen.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2012-09-20 18:58:41 +00:00
|
|
|
#include <convert_from_iu.h>
|
2012-11-16 14:13:31 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <macros.h>
|
2013-05-10 19:22:29 +00:00
|
|
|
#include <reporter.h>
|
|
|
|
#include <confirm.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbplot.h>
|
|
|
|
#include <printout_controler.h>
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <dialog_SVG_print.h>
|
2010-11-17 21:47:27 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
// Keys for configuration
|
2012-09-20 18:58:41 +00:00
|
|
|
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
|
|
|
|
#define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" )
|
|
|
|
#define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" )
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
// reasonable values for default pen width
|
2012-09-20 18:58:41 +00:00
|
|
|
#define WIDTH_MAX_VALUE (2 * IU_PER_MM)
|
|
|
|
#define WIDTH_MIN_VALUE (0.05 * IU_PER_MM)
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2009-01-13 19:18:54 +00:00
|
|
|
// Local variables:
|
2012-08-31 07:43:37 +00:00
|
|
|
static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT |
|
|
|
|
SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK;
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
/*
|
2009-01-11 19:12:18 +00:00
|
|
|
* DIALOG_SVG_PRINT functions
|
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ) :
|
2009-01-11 19:12:18 +00:00
|
|
|
DIALOG_SVG_PRINT_base( parent )
|
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
m_parent = (PCB_BASE_FRAME*) parent;
|
|
|
|
m_config = wxGetApp().GetSettings();
|
2011-12-16 20:12:49 +00:00
|
|
|
initDialog();
|
2010-03-26 17:18:59 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Centre();
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
2012-09-20 18:58:41 +00:00
|
|
|
bool DIALOG_SVG_PRINT::m_printMirror = false;
|
|
|
|
bool DIALOG_SVG_PRINT::m_oneFileOnly = false;
|
2009-01-11 19:12:18 +00:00
|
|
|
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
void DIALOG_SVG_PRINT::initDialog()
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
m_board = m_parent->GetBoard();
|
|
|
|
|
|
|
|
if( m_config )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
m_config->Read( PLOTSVGMODECOLOR_KEY, &m_printBW, false );
|
2012-08-31 07:43:37 +00:00
|
|
|
long ltmp;
|
2012-11-16 14:13:31 +00:00
|
|
|
m_config->Read( PLOTSVGPAGESIZEOPT_KEY, <mp, 0 );
|
2012-08-31 07:43:37 +00:00
|
|
|
m_rbSvgPageSizeOpt->SetSelection( ltmp );
|
2012-11-16 14:13:31 +00:00
|
|
|
m_config->Read( PLOTSVGPLOT_BRD_EDGE_KEY, <mp, 1 );
|
2012-09-20 18:58:41 +00:00
|
|
|
m_PrintBoardEdgesCtrl->SetValue( ltmp );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
m_outputDirectory = m_parent->GetPlotSettings().GetOutputDirectory();
|
|
|
|
m_outputDirectoryName->SetValue( m_outputDirectory );
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( m_printBW )
|
2012-08-31 07:43:37 +00:00
|
|
|
m_ModeColorOption->SetSelection( 1 );
|
|
|
|
else
|
|
|
|
m_ModeColorOption->SetSelection( 0 );
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
m_printMirrorOpt->SetValue( m_printMirror );
|
|
|
|
m_rbFileOpt->SetSelection( m_oneFileOnly ? 1 : 0 );
|
|
|
|
|
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
AddUnitSymbol( *m_TextPenWidth, g_UserUnit );
|
2012-08-31 07:43:37 +00:00
|
|
|
m_DialogDefaultPenSize->SetValue(
|
2012-09-20 18:58:41 +00:00
|
|
|
ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) );
|
2009-01-13 19:18:54 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
// Create layers list
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM layer;
|
|
|
|
for( layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
if( !m_board->IsLayerEnabled( layer ) )
|
|
|
|
m_boxSelectLayer[layer] = NULL;
|
2010-03-26 17:18:59 +00:00
|
|
|
else
|
2012-11-16 14:13:31 +00:00
|
|
|
m_boxSelectLayer[layer] =
|
|
|
|
new wxCheckBox( this, -1, m_board->GetLayerName( layer ) );
|
2010-03-26 17:18:59 +00:00
|
|
|
}
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2010-03-26 17:18:59 +00:00
|
|
|
// Add wxCheckBoxes in layers lists dialog
|
2012-09-20 18:58:41 +00:00
|
|
|
// List layers in same order than in setup layers dialog
|
2010-03-26 17:18:59 +00:00
|
|
|
// (Front or Top to Back or Bottom)
|
2012-09-20 18:58:41 +00:00
|
|
|
DECLARE_LAYERS_ORDER_LIST( layersOrder );
|
|
|
|
|
2013-04-25 07:05:33 +00:00
|
|
|
for( LAYER_NUM layer_idx = FIRST_LAYER; layer_idx < NB_PCB_LAYERS; ++layer_idx )
|
2010-03-26 17:18:59 +00:00
|
|
|
{
|
|
|
|
layer = layersOrder[layer_idx];
|
|
|
|
|
2013-04-25 07:05:33 +00:00
|
|
|
wxASSERT( layer < NB_PCB_LAYERS );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
if( m_boxSelectLayer[layer] == NULL )
|
2010-03-26 17:18:59 +00:00
|
|
|
continue;
|
|
|
|
|
2013-03-30 17:24:04 +00:00
|
|
|
LAYER_MSK mask = GetLayerMask( layer );
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
if( mask & s_SelectedLayers )
|
2012-11-16 14:13:31 +00:00
|
|
|
m_boxSelectLayer[layer]->SetValue( true );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
if( layer <= LAST_COPPER_LAYER )
|
2012-11-16 14:13:31 +00:00
|
|
|
m_CopperLayersBoxSizer->Add( m_boxSelectLayer[layer],
|
2009-11-14 22:15:22 +00:00
|
|
|
0,
|
|
|
|
wxGROW | wxALL,
|
|
|
|
1 );
|
2009-01-11 19:12:18 +00:00
|
|
|
else
|
2012-11-16 14:13:31 +00:00
|
|
|
m_TechnicalBoxSizer->Add( m_boxSelectLayer[layer],
|
2009-11-14 22:15:22 +00:00
|
|
|
0,
|
|
|
|
wxGROW | wxALL,
|
|
|
|
1 );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
if( m_config )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
|
|
|
wxString layerKey;
|
|
|
|
|
2013-04-25 07:05:33 +00:00
|
|
|
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
|
|
|
bool option;
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
if( m_boxSelectLayer[layer] == NULL )
|
2010-03-26 17:18:59 +00:00
|
|
|
continue;
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
if( m_config->Read( layerKey, &option ) )
|
|
|
|
m_boxSelectLayer[layer]->SetValue( option );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Build the absolute path of current output plot directory
|
|
|
|
// to preselect it when opening the dialog.
|
|
|
|
wxFileName fn( m_outputDirectoryName->GetValue() );
|
|
|
|
wxString path;
|
|
|
|
|
|
|
|
if( fn.IsRelative() )
|
|
|
|
path = wxGetCwd() + fn.GetPathSeparator() + m_outputDirectoryName->GetValue();
|
|
|
|
else
|
|
|
|
path = m_outputDirectoryName->GetValue();
|
|
|
|
|
|
|
|
wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
|
|
|
|
|
|
|
|
if( dirDialog.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
|
|
|
|
|
|
|
wxMessageDialog dialog( this, _( "Use a relative path? " ),
|
|
|
|
_( "Plot Output Directory" ),
|
|
|
|
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
|
|
|
|
|
|
|
if( dialog.ShowModal() == wxID_YES )
|
|
|
|
{
|
|
|
|
wxString boardFilePath = ( (wxFileName) m_board->GetFileName() ).GetPath();
|
|
|
|
|
|
|
|
if( !dirName.MakeRelativeTo( boardFilePath ) )
|
2013-05-10 19:22:29 +00:00
|
|
|
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ),
|
2012-11-16 14:13:31 +00:00
|
|
|
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_outputDirectoryName->SetValue( dirName.GetFullPath() );
|
|
|
|
m_outputDirectory = m_outputDirectoryName->GetValue();
|
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
void DIALOG_SVG_PRINT::SetPenWidth()
|
|
|
|
{
|
2012-09-20 18:58:41 +00:00
|
|
|
int pensize = ReturnValueFromTextCtrl( *m_DialogDefaultPenSize );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( pensize > WIDTH_MAX_VALUE )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-09-20 18:58:41 +00:00
|
|
|
pensize = WIDTH_MAX_VALUE;
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( pensize < WIDTH_MIN_VALUE )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-09-20 18:58:41 +00:00
|
|
|
pensize = WIDTH_MIN_VALUE;
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
g_DrawDefaultLineThickness = pensize;
|
|
|
|
m_DialogDefaultPenSize->SetValue( ReturnStringFromValue( g_UserUnit, pensize ) );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
m_outputDirectory = m_outputDirectoryName->GetValue();
|
|
|
|
|
|
|
|
// Create output directory if it does not exist (also transform it in
|
|
|
|
// absolute form). Bail if it fails
|
|
|
|
wxFileName outputDir = wxFileName::DirName( m_outputDirectory );
|
|
|
|
wxString boardFilename = m_board->GetFileName();
|
2013-05-10 19:22:29 +00:00
|
|
|
WX_TEXT_CTRL_REPORTER reporter( m_messagesBox );
|
2012-11-16 14:13:31 +00:00
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
if( !EnsureOutputDirectory( &outputDir, boardFilename, &reporter ) )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Could not write plot files to folder \"%s\"." ),
|
|
|
|
GetChars( outputDir.GetPath() ) );
|
|
|
|
DisplayError( this, msg );
|
2012-11-16 14:13:31 +00:00
|
|
|
return;
|
2013-05-10 19:22:29 +00:00
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
m_printMirror = m_printMirrorOpt->GetValue();
|
|
|
|
m_printBW = m_ModeColorOption->GetSelection();
|
2009-01-11 19:12:18 +00:00
|
|
|
SetPenWidth();
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
// Build layers mask
|
2013-03-30 17:24:04 +00:00
|
|
|
LAYER_MSK printMaskLayer = NO_LAYERS;
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2013-04-25 07:05:33 +00:00
|
|
|
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
if( m_boxSelectLayer[layer] && m_boxSelectLayer[layer]->GetValue() )
|
2013-03-31 13:27:46 +00:00
|
|
|
printMaskLayer |= GetLayerMask( layer );
|
2012-09-20 18:58:41 +00:00
|
|
|
}
|
2010-03-26 17:18:59 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
wxString msg;
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
|
2012-09-20 18:58:41 +00:00
|
|
|
{
|
2013-03-30 17:24:04 +00:00
|
|
|
LAYER_MSK currlayer_mask = GetLayerMask( layer );
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( (printMaskLayer & currlayer_mask ) == 0 )
|
2009-01-11 19:12:18 +00:00
|
|
|
continue;
|
|
|
|
|
2013-03-20 04:46:32 +00:00
|
|
|
wxString suffix = m_board->GetStandardLayerName( layer );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( aOnlyOneFile )
|
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
m_printMaskLayer = printMaskLayer;
|
|
|
|
suffix = wxT( "-brd" );
|
2013-05-10 19:22:29 +00:00
|
|
|
}
|
2009-01-13 19:18:54 +00:00
|
|
|
else
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
m_printMaskLayer = currlayer_mask;
|
2013-03-20 04:46:32 +00:00
|
|
|
suffix = m_board->GetStandardLayerName( layer );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
wxFileName fn(boardFilename);
|
|
|
|
BuildPlotFileName( &fn, outputDir.GetPath(), suffix, SVGFileExtension );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( m_PrintBoardEdgesCtrl->IsChecked() )
|
2012-11-16 14:13:31 +00:00
|
|
|
m_printMaskLayer |= EDGE_LAYER;
|
2012-09-20 18:58:41 +00:00
|
|
|
|
|
|
|
if( CreateSVGFile( fn.GetFullPath() ) )
|
|
|
|
msg.Printf( _( "Plot: %s OK\n" ), GetChars( fn.GetFullPath() ) );
|
|
|
|
else // Error
|
|
|
|
msg.Printf( _( "** Unable to create %s **\n" ), GetChars( fn.GetFullPath() ) );
|
2012-11-16 14:13:31 +00:00
|
|
|
m_messagesBox->AppendText( msg );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( aOnlyOneFile )
|
2009-01-11 19:12:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
// Actual SVG file export function.
|
2012-09-20 18:58:41 +00:00
|
|
|
bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-09-20 18:58:41 +00:00
|
|
|
PCB_PLOT_PARAMS m_plotOpts;
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
m_plotOpts.SetPlotFrameRef( PrintPageRef() );
|
2012-11-06 17:58:53 +00:00
|
|
|
|
|
|
|
// Adding drill marks, for copper layers
|
2012-11-16 14:13:31 +00:00
|
|
|
if( (m_printMaskLayer & ALL_CU_LAYERS) )
|
2012-11-06 17:58:53 +00:00
|
|
|
m_plotOpts.SetDrillMarksType( PCB_PLOT_PARAMS::FULL_DRILL_SHAPE );
|
|
|
|
else
|
|
|
|
m_plotOpts.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE );
|
2012-09-24 06:39:59 +00:00
|
|
|
|
|
|
|
m_plotOpts.SetSkipPlotNPTH_Pads( false );
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
m_plotOpts.SetMirror( m_printMirror );
|
|
|
|
m_plotOpts.SetFormat( PLOT_FORMAT_SVG );
|
2012-09-22 11:19:37 +00:00
|
|
|
EDA_COLOR_T color = UNSPECIFIED_COLOR; // Used layer color to plot ref and value
|
2012-09-20 18:58:41 +00:00
|
|
|
m_plotOpts.SetReferenceColor( color );
|
|
|
|
m_plotOpts.SetValueColor( color );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
PAGE_INFO pageInfo = m_board->GetPageSettings();
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint axisorigin = m_board->GetAuxOrigin();
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-08-31 07:43:37 +00:00
|
|
|
if( PageIsBoardBoundarySize() )
|
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
EDA_RECT bbox = m_board->ComputeBoundingBox();
|
|
|
|
PAGE_INFO currpageInfo = m_board->GetPageSettings();
|
2012-09-20 18:58:41 +00:00
|
|
|
currpageInfo.SetWidthMils( bbox.GetWidth() / IU_PER_MILS );
|
|
|
|
currpageInfo.SetHeightMils( bbox.GetHeight() / IU_PER_MILS );
|
2012-11-16 14:13:31 +00:00
|
|
|
m_board->SetPageSettings( currpageInfo );
|
2012-09-20 18:58:41 +00:00
|
|
|
m_plotOpts.SetUseAuxOrigin( true );
|
|
|
|
wxPoint origin = bbox.GetOrigin();
|
2013-08-03 05:15:23 +00:00
|
|
|
m_board->SetAuxOrigin( origin );
|
2012-08-31 07:43:37 +00:00
|
|
|
}
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
LOCALE_IO toggle;
|
2012-11-16 14:13:31 +00:00
|
|
|
SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( m_board,
|
2013-05-10 19:22:29 +00:00
|
|
|
&m_plotOpts, aFullFileName,
|
|
|
|
wxEmptyString );
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( plotter )
|
|
|
|
{
|
|
|
|
plotter->SetColorMode( m_ModeColorOption->GetSelection() == 0 );
|
2012-11-16 14:13:31 +00:00
|
|
|
PlotStandardLayer( m_board, plotter, m_printMaskLayer, m_plotOpts );
|
|
|
|
plotter->EndPlot();
|
2012-09-20 18:58:41 +00:00
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
delete plotter;
|
2013-08-03 05:15:23 +00:00
|
|
|
m_board->SetAuxOrigin( axisorigin );
|
2012-11-16 14:13:31 +00:00
|
|
|
m_board->SetPageSettings( pageInfo );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
return true;
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
void DIALOG_SVG_PRINT::OnButtonPlot( wxCommandEvent& event )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-09-20 18:58:41 +00:00
|
|
|
m_oneFileOnly = m_rbFileOpt->GetSelection() == 1;
|
|
|
|
ExportSVGFile( m_oneFileOnly );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_SVG_PRINT::OnButtonCancelClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
|
|
|
|
{
|
2009-01-17 17:32:20 +00:00
|
|
|
SetPenWidth();
|
2012-09-20 18:58:41 +00:00
|
|
|
m_printBW = m_ModeColorOption->GetSelection();
|
|
|
|
m_oneFileOnly = m_rbFileOpt->GetSelection() == 1;
|
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
if( m_config )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
m_config->Write( PLOTSVGMODECOLOR_KEY, m_printBW );
|
|
|
|
m_config->Write( PLOTSVGPAGESIZEOPT_KEY, m_rbSvgPageSizeOpt->GetSelection() );
|
|
|
|
m_config->Write( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() );
|
2012-08-31 07:43:37 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
wxString layerKey;
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2013-04-25 07:05:33 +00:00
|
|
|
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
if( m_boxSelectLayer[layer] == NULL )
|
2010-03-26 17:18:59 +00:00
|
|
|
continue;
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
2012-11-16 14:13:31 +00:00
|
|
|
m_config->Write( layerKey, m_boxSelectLayer[layer]->IsChecked() );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
// Set output directory and replace backslashes with forward ones
|
|
|
|
wxString dirStr;
|
|
|
|
dirStr = m_outputDirectoryName->GetValue();
|
|
|
|
dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
|
|
|
|
|
|
|
|
if( dirStr != m_parent->GetPlotSettings().GetOutputDirectory() )
|
|
|
|
{
|
|
|
|
PCB_PLOT_PARAMS tempOptions( m_parent->GetPlotSettings() );
|
|
|
|
tempOptions.SetOutputDirectory( dirStr );
|
|
|
|
m_parent->SetPlotSettings( tempOptions );
|
|
|
|
m_parent->OnModify();
|
|
|
|
}
|
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
EndModal( 0 );
|
|
|
|
}
|