From 816307e500e3790976803957a1b60378e1bb4fb7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 31 Jul 2017 14:28:35 +0200 Subject: [PATCH] Pcbnew plot: fix a few minor issues: - SVG export: fix color of PCB texts. - Avoid marking board as modified after plotting layers, when options not saved in board are modified. --- pcbnew/dialogs/dialog_SVG_print.cpp | 5 ---- pcbnew/dialogs/dialog_plot.cpp | 8 ++++-- pcbnew/pcb_plot_params.cpp | 31 ++++++++++----------- pcbnew/pcb_plot_params.h | 43 +++++++++++++++-------------- pcbnew/pcbframe.cpp | 14 ++++++---- pcbnew/plot_brditems_plotter.cpp | 23 ++++++--------- 6 files changed, 60 insertions(+), 64 deletions(-) diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index b936b79179..66d1668949 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -336,11 +336,6 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName, bool aOnlyO plot_opts.SetMirror( m_printMirror ); plot_opts.SetFormat( PLOT_FORMAT_SVG ); - COLOR4D color = COLOR4D::UNSPECIFIED; // Used layer color to plot ref and value - - plot_opts.SetReferenceColor( color ); - plot_opts.SetValueColor( color ); - PAGE_INFO pageInfo = m_board->GetPageSettings(); wxPoint axisorigin = m_board->GetAuxOrigin(); diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 0ed6f21190..8c89425215 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -706,11 +706,15 @@ void DIALOG_PLOT::applyPlotSettings() dirStr.Replace( wxT( "\\" ), wxT( "/" ) ); tempOptions.SetOutputDirectory( dirStr ); - if( m_plotOpts != tempOptions ) + if( !m_plotOpts.IsSameAs( tempOptions, false ) ) { + // First, mark board as modified only for parameters saved in file + if( !m_plotOpts.IsSameAs( tempOptions, true ) ) + m_parent->OnModify(); + + // Now, save any change, for the session m_parent->SetPlotSettings( tempOptions ); m_plotOpts = tempOptions; - m_parent->OnModify(); } } diff --git a/pcbnew/pcb_plot_params.cpp b/pcbnew/pcb_plot_params.cpp index 0e0e085608..5ae43b2e18 100644 --- a/pcbnew/pcb_plot_params.cpp +++ b/pcbnew/pcb_plot_params.cpp @@ -111,8 +111,6 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS() m_widthAdjust = 0.; m_outputDirectory.clear(); m_color = BLACK; - m_referenceColor = BLACK; - m_valueColor = BLACK; m_textMode = PLOTTEXTMODE_DEFAULT; m_layerSelection = LSET( 2, F_SilkS, B_SilkS) | LSET::AllCuMask(); @@ -220,7 +218,7 @@ void PCB_PLOT_PARAMS::Parse( PCB_PLOT_PARAMS_PARSER* aParser ) } -bool PCB_PLOT_PARAMS::operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const +bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCompareOnlySavedPrms ) const { if( m_layerSelection != aPcbPlotParams.m_layerSelection ) return false; @@ -242,8 +240,11 @@ bool PCB_PLOT_PARAMS::operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const return false; if( m_plotMode != aPcbPlotParams.m_plotMode ) return false; - if( m_DXFplotPolygonMode != aPcbPlotParams.m_DXFplotPolygonMode ) + if( !aCompareOnlySavedPrms ) + { + if( m_DXFplotPolygonMode != aPcbPlotParams.m_DXFplotPolygonMode ) return false; + } if( m_useAuxOrigin != aPcbPlotParams.m_useAuxOrigin ) return false; if( m_HPGLPenNum != aPcbPlotParams.m_HPGLPenNum ) @@ -284,12 +285,11 @@ bool PCB_PLOT_PARAMS::operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const return false; if( m_widthAdjust != aPcbPlotParams.m_widthAdjust ) return false; - if( m_color != aPcbPlotParams.m_color ) - return false; - if( m_referenceColor != aPcbPlotParams.m_referenceColor ) - return false; - if( m_valueColor != aPcbPlotParams.m_valueColor ) - return false; + if( !aCompareOnlySavedPrms ) + { + if( m_color != aPcbPlotParams.m_color ) + return false; + } if( m_textMode != aPcbPlotParams.m_textMode ) return false; if( !m_outputDirectory.IsSameAs( aPcbPlotParams.m_outputDirectory ) ) @@ -299,12 +299,6 @@ bool PCB_PLOT_PARAMS::operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const } -bool PCB_PLOT_PARAMS::operator!=( const PCB_PLOT_PARAMS &aPcbPlotParams ) const -{ - return !( *this == aPcbPlotParams ); -} - - bool PCB_PLOT_PARAMS::SetHPGLPenDiameter( int aValue ) { return setInt( &m_HPGLPenDiam, aValue, HPGL_PEN_DIAMETER_MIN, HPGL_PEN_DIAMETER_MAX ); @@ -442,18 +436,22 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) aPcbPlotParams->m_HPGLPenNum = parseInt( HPGL_PEN_NUMBER_MIN, HPGL_PEN_NUMBER_MAX ); break; + case T_hpglpenspeed: aPcbPlotParams->m_HPGLPenSpeed = parseInt( HPGL_PEN_SPEED_MIN, HPGL_PEN_SPEED_MAX ); break; + case T_hpglpendiameter: aPcbPlotParams->m_HPGLPenDiam = parseInt( HPGL_PEN_DIAMETER_MIN, HPGL_PEN_DIAMETER_MAX ); break; + case T_hpglpenoverlay: // No more used. juste here for compatibility with old versions parseInt( 0, HPGL_PEN_DIAMETER_MAX ); break; + case T_pscolor: NeedSYMBOL(); // This actually was never used... break; @@ -558,6 +556,7 @@ double PCB_PLOT_PARAMS_PARSER::parseDouble() return val; } + void PCB_PLOT_PARAMS_PARSER::skipCurrent() { int curr_level = 0; diff --git a/pcbnew/pcb_plot_params.h b/pcbnew/pcb_plot_params.h index a33b9375d6..6d0e2fca12 100644 --- a/pcbnew/pcb_plot_params.h +++ b/pcbnew/pcb_plot_params.h @@ -54,9 +54,10 @@ private: */ EDA_DRAW_MODE_T m_plotMode; - /// DXF format: Plot items in outline (polygon) mode - /// In polygon mode, each item to plot is converted to a polygon, and all - /// polygons are merged. + /** DXF format: Plot items in outline (polygon) mode + * In polygon mode, each item to plot is converted to a polygon, and all + * polygons are merged. + */ bool m_DXFplotPolygonMode; /// Plot format type (chooses the driver to be used) @@ -68,7 +69,7 @@ private: /// Choose how represent text with PS, PDF and DXF drivers PlotTextMode m_textMode; - /// The default line width (used for the frame and in LINE mode) + /// The default line width (used to draw items having no defined width) int m_lineWidth; /// When true set the scale to fit the board in the page @@ -95,8 +96,10 @@ private: /// Set of layers to plot LSET m_layerSelection; - /** When plotting gerbers use a conventional set of Protel extensions - * instead of appending a suffix to the board name */ + /** When plotting gerber files, use a conventional set of Protel extensions + * instead of .gbr, that is now the offical gerber file extension + * this is a deprecated feature + */ bool m_useGerberProtelExtensions; /// Include attributes from the Gerber X2 format (chapter 5 in revision J2) @@ -111,7 +114,7 @@ private: /// 5 is the minimal value for professional boards. int m_gerberPrecision; - /// Plot gerbers using auxiliary (drill) origin instead of page coordinates + /// Plot gerbers using auxiliary (drill) origin instead of absolue coordinates bool m_useAuxOrigin; /// On gerbers 'scrape' away the solder mask from silkscreen (trim silks) @@ -135,8 +138,7 @@ private: /// Force plotting of fields marked invisible bool m_plotInvisibleText; - /// Allows pads outlines on silkscreen layer - /// (when pads are also on silk screen) + /// Allows pads outlines on silkscreen layer (when pads are also on silk screen) bool m_plotPadsOnSilkLayer; /* These next two scale factors are intended to compensate plotters @@ -144,7 +146,8 @@ private: * near 1.0; only X and Y dimensions are adjusted: circles are plotted as * circles, even if X and Y fine scale differ; because of this it is mostly * useful for printers: postscript plots would be best adjusted using - * the prologue (that would change the whole output matrix */ + * the prologue (that would change the whole output matrix + */ double m_fineScaleAdjustX; ///< fine scale adjust X axis double m_fineScaleAdjustY; ///< fine scale adjust Y axis @@ -157,9 +160,7 @@ private: int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9) int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s) int m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas - COLOR4D m_color; ///< Color for plotting the current layer - COLOR4D m_referenceColor; ///< Color for plotting references - COLOR4D m_valueColor; ///< Color for plotting values + COLOR4D m_color; ///< Color for plotting the current layer. Provided, but not really used public: PCB_PLOT_PARAMS(); @@ -170,18 +171,18 @@ public: void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl=0 ) const; void Parse( PCB_PLOT_PARAMS_PARSER* aParser ); - bool operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const; - bool operator!=( const PCB_PLOT_PARAMS &aPcbPlotParams ) const; + /** + * Compare current settings to aPcbPlotParams, including not saved parameters in brd file + * @param aPcbPlotParams = the PCB_PLOT_PARAMS to compare + * @param aCompareOnlySavedPrms = true to compare only saved in file parameters, + * and false to compare the full set of parameters. + * @return true is parameters are same, false if one (or more) parameter does not match + */ + bool IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCompareOnlySavedPrms ) const; void SetColor( COLOR4D aVal ) { m_color = aVal; } COLOR4D GetColor() const { return m_color; } - void SetReferenceColor( COLOR4D aVal ) { m_referenceColor = aVal; } - COLOR4D GetReferenceColor() const { return m_referenceColor; } - - void SetValueColor( COLOR4D aVal ) { m_valueColor = aVal; } - COLOR4D GetValueColor() const { return m_valueColor; } - void SetTextMode( PlotTextMode aVal ) { m_textMode = aVal; } PlotTextMode GetTextMode() const { return m_textMode; } diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index e1f1fb737c..1f9fe85410 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -1004,16 +1004,20 @@ void PCB_EDIT_FRAME::OnModify( ) void PCB_EDIT_FRAME::SVG_Print( wxCommandEvent& event ) { - PCB_PLOT_PARAMS tmp = GetPlotSettings(); + PCB_PLOT_PARAMS plot_prms = GetPlotSettings(); // we don't want dialogs knowing about complex wxFrame functions so // pass everything the dialog needs without reference to *this frame's class. - if( InvokeSVGPrint( this, GetBoard(), &tmp ) ) + if( InvokeSVGPrint( this, GetBoard(), &plot_prms ) ) { - if( tmp != GetPlotSettings() ) + if( !plot_prms.IsSameAs( GetPlotSettings(), false ) ) { - SetPlotSettings( tmp ); - OnModify(); + // First, mark board as modified only for parameters saved in file + if( !plot_prms.IsSameAs( GetPlotSettings(), true ) ) + OnModify(); + + // Now, save any change, for the session + SetPlotSettings( plot_prms ); } } } diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 6f53c7b222..b4a924294c 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -224,18 +224,12 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule ) // Plot text fields, if allowed if( trace_ref ) { - if( GetReferenceColor() == COLOR4D::UNSPECIFIED ) - PlotTextModule( &aModule->Reference(), getColor( textLayer ) ); - else - PlotTextModule( &aModule->Reference(), GetReferenceColor() ); + PlotTextModule( &aModule->Reference(), getColor( textLayer ) ); } if( trace_val ) { - if( GetValueColor() == COLOR4D::UNSPECIFIED ) - PlotTextModule( &aModule->Value(), getColor( textLayer ) ); - else - PlotTextModule( &aModule->Value(), GetValueColor() ); + PlotTextModule( &aModule->Value(), getColor( textLayer ) ); } for( BOARD_ITEM* item = aModule->GraphicalItemsList().GetFirst(); item; item = item->Next() ) @@ -345,11 +339,9 @@ void BRDITEMS_PLOTTER::PlotDimension( DIMENSION* aDim ) draw.SetWidth( aDim->GetWidth() ); draw.SetLayer( aDim->GetLayer() ); - COLOR4D color = aDim->GetBoard()->GetLayerColor( aDim->GetLayer() ); + COLOR4D color = getColor( aDim->GetLayer() ); - // Set plot color (change WHITE to LIGHTGRAY because - // the white items are not seen on a white paper or screen - m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY); + m_plotter->SetColor( color ); PlotTextePcb( &aDim->Text() ); @@ -565,7 +557,8 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte ) gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR ); } - m_plotter->SetColor( getColor( pt_texte->GetLayer() ) ); + COLOR4D color = getColor( pt_texte->GetLayer() ); + m_plotter->SetColor( color ); size = pt_texte->GetTextSize(); pos = pt_texte->GetTextPos(); @@ -593,14 +586,14 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte ) for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) { wxString& txt = strings_list.Item( ii ); - m_plotter->Text( positions[ii], COLOR4D::UNSPECIFIED, txt, orient, size, + m_plotter->Text( positions[ii], color, txt, orient, size, pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(), thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata ); } } else { - m_plotter->Text( pos, COLOR4D::UNSPECIFIED, shownText, orient, size, + m_plotter->Text( pos, color, shownText, orient, size, pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(), thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata ); }