Commit 84a985f8 authored by unknown's avatar unknown Committed by jean-pierre charras

Pcbnew: Commit patch (with very minor changes) about SVG file export with the...

Pcbnew: Commit patch (with very minor changes) about SVG file export with the layers ordered from bottom to top. ( bug 1286646 ), from Thiadmer Riemersma.
parent cd85ee62
...@@ -381,6 +381,66 @@ LSEQ LSET::Seq() const ...@@ -381,6 +381,66 @@ LSEQ LSET::Seq() const
} }
LSEQ LSET::SeqStackupBottom2Top() const
{
// bottom-to-top stack-up layers
static const LAYER_ID sequence[] = {
B_Fab,
B_CrtYd,
B_Adhes,
B_SilkS,
B_Paste,
B_Mask,
B_Cu,
In30_Cu,
In29_Cu,
In28_Cu,
In27_Cu,
In26_Cu,
In25_Cu,
In24_Cu,
In23_Cu,
In22_Cu,
In21_Cu,
In20_Cu,
In19_Cu,
In18_Cu,
In17_Cu,
In16_Cu,
In15_Cu,
In14_Cu,
In13_Cu,
In12_Cu,
In11_Cu,
In10_Cu,
In9_Cu,
In8_Cu,
In7_Cu,
In6_Cu,
In5_Cu,
In4_Cu,
In3_Cu,
In2_Cu,
In1_Cu,
F_Cu,
F_Mask,
F_Paste,
F_SilkS,
F_Adhes,
F_CrtYd,
F_Fab,
Dwgs_User,
Cmts_User,
Eco1_User,
Eco2_User,
Margin,
Edge_Cuts,
};
return Seq( sequence, DIM( sequence ) );
}
LAYER_ID FlipLayer( LAYER_ID aLayerId ) LAYER_ID FlipLayer( LAYER_ID aLayerId )
{ {
switch( aLayerId ) switch( aLayerId )
......
...@@ -367,11 +367,11 @@ public: ...@@ -367,11 +367,11 @@ public:
LSEQ Seq() const; LSEQ Seq() const;
/** /**
* Function SVG * Function SeqStackBottom2Top
* returns the sequence used to output an SVG plot. * returns the sequence that is typical for a bottom-to-top stack-up.
LSEQ SVG() const; * For instance, to plot multiple layers in a single image, the top layers output last.
put this in the needed source file using Seq() there.
*/ */
LSEQ SeqStackupBottom2Top() const;
/** /**
* Function FmtHex * Function FmtHex
......
...@@ -62,10 +62,8 @@ private: ...@@ -62,10 +62,8 @@ private:
wxCheckBox* m_boxSelectLayer[LAYER_ID_COUNT]; wxCheckBox* m_boxSelectLayer[LAYER_ID_COUNT];
bool m_printBW; bool m_printBW;
wxString m_outputDirectory; wxString m_outputDirectory;
bool m_printMirror;
// Static member to store options bool m_oneFileOnly;
static bool m_printMirror;
static bool m_oneFileOnly;
void initDialog(); void initDialog();
...@@ -88,7 +86,7 @@ private: ...@@ -88,7 +86,7 @@ private:
return m_rbSvgPageSizeOpt->GetSelection() == 0; return m_rbSvgPageSizeOpt->GetSelection() == 0;
} }
bool CreateSVGFile( const wxString& FullFileName ); bool CreateSVGFile( const wxString& FullFileName, bool aOnlyOneFile );
LSET getCheckBoxSelectedLayers() const; LSET getCheckBoxSelectedLayers() const;
}; };
...@@ -97,6 +95,8 @@ private: ...@@ -97,6 +95,8 @@ private:
// Keys for configuration // Keys for configuration
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" ) #define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
#define PLOTSVGMODEMIRROR_KEY wxT( "PlotSVGModeMirror" )
#define PLOTSVGMODEONEFILE_KEY wxT( "PlotSVGModeOneFile" )
#define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" ) #define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" )
#define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" ) #define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" )
...@@ -125,9 +125,6 @@ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( wxTopLevelWindow* aParent, BOARD* aBoard, PC ...@@ -125,9 +125,6 @@ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( wxTopLevelWindow* aParent, BOARD* aBoard, PC
Centre(); Centre();
} }
bool DIALOG_SVG_PRINT::m_printMirror = false;
bool DIALOG_SVG_PRINT::m_oneFileOnly = false;
void DIALOG_SVG_PRINT::initDialog() void DIALOG_SVG_PRINT::initDialog()
{ {
...@@ -136,6 +133,8 @@ void DIALOG_SVG_PRINT::initDialog() ...@@ -136,6 +133,8 @@ void DIALOG_SVG_PRINT::initDialog()
m_config->Read( PLOTSVGMODECOLOR_KEY, &m_printBW, false ); m_config->Read( PLOTSVGMODECOLOR_KEY, &m_printBW, false );
long ltmp; long ltmp;
m_config->Read( PLOTSVGPAGESIZEOPT_KEY, &ltmp, 0 ); m_config->Read( PLOTSVGPAGESIZEOPT_KEY, &ltmp, 0 );
m_config->Read( PLOTSVGMODEMIRROR_KEY, &m_printMirror, false );
m_config->Read( PLOTSVGMODEONEFILE_KEY, &m_oneFileOnly, false);
m_rbSvgPageSizeOpt->SetSelection( ltmp ); m_rbSvgPageSizeOpt->SetSelection( ltmp );
m_config->Read( PLOTSVGPLOT_BRD_EDGE_KEY, &ltmp, 1 ); m_config->Read( PLOTSVGPLOT_BRD_EDGE_KEY, &ltmp, 1 );
m_PrintBoardEdgesCtrl->SetValue( ltmp ); m_PrintBoardEdgesCtrl->SetValue( ltmp );
...@@ -144,11 +143,7 @@ void DIALOG_SVG_PRINT::initDialog() ...@@ -144,11 +143,7 @@ void DIALOG_SVG_PRINT::initDialog()
m_outputDirectory = m_callers_params->GetOutputDirectory(); m_outputDirectory = m_callers_params->GetOutputDirectory();
m_outputDirectoryName->SetValue( m_outputDirectory ); m_outputDirectoryName->SetValue( m_outputDirectory );
if( m_printBW ) m_ModeColorOption->SetSelection( m_printBW ? 1 : 0 );
m_ModeColorOption->SetSelection( 1 );
else
m_ModeColorOption->SetSelection( 0 );
m_printMirrorOpt->SetValue( m_printMirror ); m_printMirrorOpt->SetValue( m_printMirror );
m_rbFileOpt->SetSelection( m_oneFileOnly ? 1 : 0 ); m_rbFileOpt->SetSelection( m_oneFileOnly ? 1 : 0 );
...@@ -307,7 +302,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) ...@@ -307,7 +302,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
if( m_PrintBoardEdgesCtrl->IsChecked() ) if( m_PrintBoardEdgesCtrl->IsChecked() )
m_printMaskLayer.set( Edge_Cuts ); m_printMaskLayer.set( Edge_Cuts );
if( CreateSVGFile( fn.GetFullPath() ) ) if( CreateSVGFile( fn.GetFullPath(), aOnlyOneFile ) )
{ {
m_messagesBox->AppendText( m_messagesBox->AppendText(
wxString::Format( _( "Plot: '%s' OK\n" ), GetChars( fn.GetFullPath() ) ) wxString::Format( _( "Plot: '%s' OK\n" ), GetChars( fn.GetFullPath() ) )
...@@ -327,7 +322,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) ...@@ -327,7 +322,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
// Actual SVG file export function. // Actual SVG file export function.
bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName ) bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName, bool aOnlyOneFile )
{ {
PCB_PLOT_PARAMS plot_opts; PCB_PLOT_PARAMS plot_opts;
...@@ -372,15 +367,22 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName ) ...@@ -372,15 +367,22 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName )
if( plotter ) if( plotter )
{ {
plotter->SetColorMode( m_ModeColorOption->GetSelection() == 0 ); plotter->SetColorMode( !m_printBW );
if( aOnlyOneFile )
{
for( LSEQ seq = m_printMaskLayer.SeqStackupBottom2Top(); seq; ++seq )
PlotOneBoardLayer( m_board, plotter, *seq, plot_opts );
}
else
{
PlotStandardLayer( m_board, plotter, m_printMaskLayer, plot_opts ); PlotStandardLayer( m_board, plotter, m_printMaskLayer, plot_opts );
}
plotter->EndPlot(); plotter->EndPlot();
} }
delete plotter; delete plotter;
m_board->SetAuxOrigin( axisorigin ); // really, without a message saying so? m_board->SetAuxOrigin( axisorigin ); // reset to the values saved earlier
m_board->SetPageSettings( pageInfo ); m_board->SetPageSettings( pageInfo );
return true; return true;
...@@ -410,10 +412,9 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) ...@@ -410,10 +412,9 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
m_printBW = m_ModeColorOption->GetSelection(); m_printBW = m_ModeColorOption->GetSelection();
m_oneFileOnly = m_rbFileOpt->GetSelection() == 1; m_oneFileOnly = m_rbFileOpt->GetSelection() == 1;
// 1) Why is configuration data saved in two places: m_config and PCB_PLOT_OPTIONS? // Why are SVG layer choices co-mingled with other plot layer choices in the config file?
// 2) Why are SVG layer choices co-mingled with other plot layer choices in the config file?
// The string OPTKEY_LAYERBASE is used in multiple places. // The string OPTKEY_LAYERBASE is used in multiple places.
// fix these. // fix this.
wxString dirStr = m_outputDirectoryName->GetValue(); wxString dirStr = m_outputDirectoryName->GetValue();
dirStr.Replace( wxT( "\\" ), wxT( "/" ) ); dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
...@@ -423,6 +424,8 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) ...@@ -423,6 +424,8 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
if( m_config ) if( m_config )
{ {
m_config->Write( PLOTSVGMODECOLOR_KEY, m_printBW ); m_config->Write( PLOTSVGMODECOLOR_KEY, m_printBW );
m_config->Write( PLOTSVGMODEMIRROR_KEY, m_printMirror );
m_config->Write( PLOTSVGMODEONEFILE_KEY, m_oneFileOnly );
m_config->Write( PLOTSVGPAGESIZEOPT_KEY, m_rbSvgPageSizeOpt->GetSelection() ); m_config->Write( PLOTSVGPAGESIZEOPT_KEY, m_rbSvgPageSizeOpt->GetSelection() );
m_config->Write( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() ); m_config->Write( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() );
......
...@@ -89,6 +89,8 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c ...@@ -89,6 +89,8 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
sbOptionsSizer->Add( m_PrintBoardEdgesCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); sbOptionsSizer->Add( m_PrintBoardEdgesCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_printMirrorOpt = new wxCheckBox( this, wxID_ANY, _("Print mirrored"), wxDefaultPosition, wxDefaultSize, 0 ); m_printMirrorOpt = new wxCheckBox( this, wxID_ANY, _("Print mirrored"), wxDefaultPosition, wxDefaultSize, 0 );
m_printMirrorOpt->SetToolTip( _("Print the layer(s) horizontally mirrored") );
sbOptionsSizer->Add( m_printMirrorOpt, 0, wxRIGHT|wxLEFT, 5 ); sbOptionsSizer->Add( m_printMirrorOpt, 0, wxRIGHT|wxLEFT, 5 );
......
...@@ -925,7 +925,7 @@ ...@@ -925,7 +925,7 @@
<property name="style"></property> <property name="style"></property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip">Print the layer(s) horizontally mirrored</property>
<property name="validator_data_type"></property> <property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property> <property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property> <property name="validator_type">wxDefaultValidator</property>
......
...@@ -334,7 +334,7 @@ bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer ) ...@@ -334,7 +334,7 @@ bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer )
return false; return false;
// Fully delegated to the parent // Fully delegated to the parent
PlotOneBoardLayer( m_board, m_plotter, aLayer, m_plotOpts ); PlotOneBoardLayer( m_board, m_plotter, ToLAYER_ID( aLayer ), m_plotOpts );
return true; return true;
} }
......
...@@ -176,7 +176,7 @@ PLOTTER* StartPlotBoard( BOARD* aBoard, ...@@ -176,7 +176,7 @@ PLOTTER* StartPlotBoard( BOARD* aBoard,
* @param aLayer = the layer id to plot * @param aLayer = the layer id to plot
* @param aPlotOpt = the plot options (files, sketch). Has meaning for some formats only * @param aPlotOpt = the plot options (files, sketch). Has meaning for some formats only
*/ */
void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, LAYER_NUM aLayer, void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, LAYER_ID aLayer,
const PCB_PLOT_PARAMS& aPlotOpt ); const PCB_PLOT_PARAMS& aPlotOpt );
/** /**
......
...@@ -142,7 +142,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, ...@@ -142,7 +142,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
} }
} }
void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, LAYER_NUM aLayer, void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, LAYER_ID aLayer,
const PCB_PLOT_PARAMS& aPlotOpt ) const PCB_PLOT_PARAMS& aPlotOpt )
{ {
PCB_PLOT_PARAMS plotOpt = aPlotOpt; PCB_PLOT_PARAMS plotOpt = aPlotOpt;
...@@ -154,7 +154,7 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, LAYER_NUM aLayer, ...@@ -154,7 +154,7 @@ void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, LAYER_NUM aLayer,
// Specify that the contents of the "Edges Pcb" layer are to be plotted // Specify that the contents of the "Edges Pcb" layer are to be plotted
// in addition to the contents of the currently specified layer. // in addition to the contents of the currently specified layer.
LSET layer_mask( ToLAYER_ID( aLayer ) ); LSET layer_mask( aLayer );
if( !aPlotOpt.GetExcludeEdgeLayer() ) if( !aPlotOpt.GetExcludeEdgeLayer() )
layer_mask.set( Edge_Cuts ); layer_mask.set( Edge_Cuts );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment