From 84a985f8afa3ce900f2543eedc6500524078d2d9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 10 Aug 2014 16:15:02 +0200 Subject: [PATCH] Pcbnew: Commit patch (with very minor changes) about SVG file export with the layers ordered from bottom to top. ( bug 1286646 ), from Thiadmer Riemersma. --- common/lset.cpp | 60 +++++++++++++++++++++++ include/layers_id_colors_and_visibility.h | 10 ++-- pcbnew/dialogs/dialog_SVG_print.cpp | 49 +++++++++--------- pcbnew/dialogs/dialog_SVG_print_base.cpp | 2 + pcbnew/dialogs/dialog_SVG_print_base.fbp | 2 +- pcbnew/pcbplot.cpp | 2 +- pcbnew/pcbplot.h | 2 +- pcbnew/plot_board_layers.cpp | 4 +- 8 files changed, 98 insertions(+), 33 deletions(-) diff --git a/common/lset.cpp b/common/lset.cpp index 02a2aae458..0e0964e36d 100644 --- a/common/lset.cpp +++ b/common/lset.cpp @@ -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 ) { switch( aLayerId ) diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 17a0e3384b..8586d39da5 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -367,11 +367,11 @@ public: LSEQ Seq() const; /** - * Function SVG - * returns the sequence used to output an SVG plot. - LSEQ SVG() const; - put this in the needed source file using Seq() there. - */ + * Function SeqStackBottom2Top + * returns the sequence that is typical for a bottom-to-top stack-up. + * For instance, to plot multiple layers in a single image, the top layers output last. + */ + LSEQ SeqStackupBottom2Top() const; /** * Function FmtHex diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index 5e90b3bfa3..6acf7c7299 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -62,10 +62,8 @@ private: wxCheckBox* m_boxSelectLayer[LAYER_ID_COUNT]; bool m_printBW; wxString m_outputDirectory; - - // Static member to store options - static bool m_printMirror; - static bool m_oneFileOnly; + bool m_printMirror; + bool m_oneFileOnly; void initDialog(); @@ -88,7 +86,7 @@ private: return m_rbSvgPageSizeOpt->GetSelection() == 0; } - bool CreateSVGFile( const wxString& FullFileName ); + bool CreateSVGFile( const wxString& FullFileName, bool aOnlyOneFile ); LSET getCheckBoxSelectedLayers() const; }; @@ -97,6 +95,8 @@ private: // Keys for configuration #define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" ) +#define PLOTSVGMODEMIRROR_KEY wxT( "PlotSVGModeMirror" ) +#define PLOTSVGMODEONEFILE_KEY wxT( "PlotSVGModeOneFile" ) #define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" ) #define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" ) @@ -125,9 +125,6 @@ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( wxTopLevelWindow* aParent, BOARD* aBoard, PC Centre(); } -bool DIALOG_SVG_PRINT::m_printMirror = false; -bool DIALOG_SVG_PRINT::m_oneFileOnly = false; - void DIALOG_SVG_PRINT::initDialog() { @@ -136,6 +133,8 @@ void DIALOG_SVG_PRINT::initDialog() m_config->Read( PLOTSVGMODECOLOR_KEY, &m_printBW, false ); long ltmp; m_config->Read( PLOTSVGPAGESIZEOPT_KEY, <mp, 0 ); + m_config->Read( PLOTSVGMODEMIRROR_KEY, &m_printMirror, false ); + m_config->Read( PLOTSVGMODEONEFILE_KEY, &m_oneFileOnly, false); m_rbSvgPageSizeOpt->SetSelection( ltmp ); m_config->Read( PLOTSVGPLOT_BRD_EDGE_KEY, <mp, 1 ); m_PrintBoardEdgesCtrl->SetValue( ltmp ); @@ -144,11 +143,7 @@ void DIALOG_SVG_PRINT::initDialog() m_outputDirectory = m_callers_params->GetOutputDirectory(); m_outputDirectoryName->SetValue( m_outputDirectory ); - if( m_printBW ) - m_ModeColorOption->SetSelection( 1 ); - else - m_ModeColorOption->SetSelection( 0 ); - + m_ModeColorOption->SetSelection( m_printBW ? 1 : 0 ); m_printMirrorOpt->SetValue( m_printMirror ); m_rbFileOpt->SetSelection( m_oneFileOnly ? 1 : 0 ); @@ -307,7 +302,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) if( m_PrintBoardEdgesCtrl->IsChecked() ) m_printMaskLayer.set( Edge_Cuts ); - if( CreateSVGFile( fn.GetFullPath() ) ) + if( CreateSVGFile( fn.GetFullPath(), aOnlyOneFile ) ) { m_messagesBox->AppendText( wxString::Format( _( "Plot: '%s' OK\n" ), GetChars( fn.GetFullPath() ) ) @@ -327,7 +322,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) // 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; @@ -372,15 +367,22 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName ) if( plotter ) { - plotter->SetColorMode( m_ModeColorOption->GetSelection() == 0 ); - PlotStandardLayer( m_board, plotter, m_printMaskLayer, plot_opts ); + 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 ); + } plotter->EndPlot(); } 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 ); return true; @@ -410,10 +412,9 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) m_printBW = m_ModeColorOption->GetSelection(); m_oneFileOnly = m_rbFileOpt->GetSelection() == 1; - // 1) Why is configuration data saved in two places: m_config and PCB_PLOT_OPTIONS? - // 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. - // fix these. + // 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. + // fix this. wxString dirStr = m_outputDirectoryName->GetValue(); dirStr.Replace( wxT( "\\" ), wxT( "/" ) ); @@ -423,6 +424,8 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) if( m_config ) { 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( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() ); diff --git a/pcbnew/dialogs/dialog_SVG_print_base.cpp b/pcbnew/dialogs/dialog_SVG_print_base.cpp index a1d4a10149..c467ff4cc0 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.cpp +++ b/pcbnew/dialogs/dialog_SVG_print_base.cpp @@ -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 ); 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 ); diff --git a/pcbnew/dialogs/dialog_SVG_print_base.fbp b/pcbnew/dialogs/dialog_SVG_print_base.fbp index fe98a01908..e51b7c4b27 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.fbp +++ b/pcbnew/dialogs/dialog_SVG_print_base.fbp @@ -925,7 +925,7 @@ 0 - + Print the layer(s) horizontally mirrored wxFILTER_NONE wxDefaultValidator diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index c5ad76183c..7913fab939 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -334,7 +334,7 @@ bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer ) return false; // 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; } diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h index 27fa8d897a..d74ca0cd60 100644 --- a/pcbnew/pcbplot.h +++ b/pcbnew/pcbplot.h @@ -176,7 +176,7 @@ PLOTTER* StartPlotBoard( BOARD* aBoard, * @param aLayer = the layer id to plot * @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 ); /** diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index e96dcb0702..36ac8b41bd 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -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 ) { PCB_PLOT_PARAMS plotOpt = aPlotOpt; @@ -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 // in addition to the contents of the currently specified layer. - LSET layer_mask( ToLAYER_ID( aLayer ) ); + LSET layer_mask( aLayer ); if( !aPlotOpt.GetExcludeEdgeLayer() ) layer_mask.set( Edge_Cuts );