From 7b843ecac8cb064d8b384a44e3d12a8f3b05a612 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 28 Apr 2014 18:13:18 +0200 Subject: [PATCH] Plots function: fix a bug about virtual PLOTTER::Text, which was not virtual for derived classes due to a missing parameter in ::Text in these classes. Noticeable only in SVG plot. SVG plot, fix a missing reinitialization in plot lines, which could define a filled polyline, instead of a simple polyline (these fixes solve Bug #1313084 ) --- common/common_plotDXF_functions.cpp | 17 +++++++++---- common/common_plotPDF_functions.cpp | 13 ++++++---- common/common_plotPS_functions.cpp | 37 ++++++++++++++++------------- common/common_plotSVG_functions.cpp | 14 +++++++++-- eeschema/sheet.cpp | 2 -- include/plot_common.h | 12 ++++++---- 6 files changed, 63 insertions(+), 32 deletions(-) diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp index 2368cb98f7..0164ca628b 100644 --- a/common/common_plotDXF_functions.cpp +++ b/common/common_plotDXF_functions.cpp @@ -570,12 +570,21 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, - bool aBold ) + bool aBold, + bool aMultilineAllowed ) { - if( textAsLines || containsNonAsciiChars( aText ) ) - /* output text as graphics */ + // Fix me: see how to use DXF text mode for multiline texts + if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) ) + aMultilineAllowed = false; // the text has only one line. + + if( textAsLines || containsNonAsciiChars( aText ) || aMultilineAllowed ) + { + // output text as graphics. + // Perhaps miltiline texts could be handled as DXF text entity + // but I do not want spend time about this (JPC) PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, - aWidth, aItalic, aBold ); + aWidth, aItalic, aBold, aMultilineAllowed ); + } else { /* Emit text as a text entity. This loses formatting and shape but it's diff --git a/common/common_plotPDF_functions.cpp b/common/common_plotPDF_functions.cpp index ec9cef66d3..7d75be97d4 100644 --- a/common/common_plotPDF_functions.cpp +++ b/common/common_plotPDF_functions.cpp @@ -741,10 +741,15 @@ void PDF_PLOTTER::Text( const wxPoint& aPos, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, - bool aBold ) + bool aBold, + bool aMultilineAllowed ) { + // Fix me: see how to use PDF text mode for multiline texts + if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) ) + aMultilineAllowed = false; // the text has only one line. + // Emit native PDF text (if requested) - if( m_textMode != PLOTTEXTMODE_STROKE ) + if( m_textMode != PLOTTEXTMODE_STROKE && !aMultilineAllowed ) { const char *fontname = aItalic ? (aBold ? "/KicadFontBI" : "/KicadFontI") : (aBold ? "/KicadFontB" : "/KicadFont"); @@ -800,10 +805,10 @@ void PDF_PLOTTER::Text( const wxPoint& aPos, } // Plot the stroked text (if requested) - if( m_textMode != PLOTTEXTMODE_NATIVE ) + if( m_textMode != PLOTTEXTMODE_NATIVE || aMultilineAllowed ) { PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, - aWidth, aItalic, aBold ); + aWidth, aItalic, aBold, aMultilineAllowed ); } } diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp index 9e1644485b..627f079088 100644 --- a/common/common_plotPS_functions.cpp +++ b/common/common_plotPS_functions.cpp @@ -812,27 +812,32 @@ bool PS_PLOTTER::EndPlot() -void PS_PLOTTER::Text( const wxPoint& aPos, - enum EDA_COLOR_T aColor, - const wxString& aText, - double aOrient, - const wxSize& aSize, - enum EDA_TEXT_HJUSTIFY_T aH_justify, - enum EDA_TEXT_VJUSTIFY_T aV_justify, - int aWidth, - bool aItalic, - bool aBold ) +void PS_PLOTTER::Text( const wxPoint& aPos, + enum EDA_COLOR_T aColor, + const wxString& aText, + double aOrient, + const wxSize& aSize, + enum EDA_TEXT_HJUSTIFY_T aH_justify, + enum EDA_TEXT_VJUSTIFY_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed ) { SetCurrentLineWidth( aWidth ); SetColor( aColor ); + // Fix me: see how to use PS text mode for multiline texts + if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) ) + aMultilineAllowed = false; // the text has only one line. + // Draw the native postscript text (if requested) - if( m_textMode == PLOTTEXTMODE_NATIVE ) + if( m_textMode == PLOTTEXTMODE_NATIVE && !aMultilineAllowed ) { const char *fontname = aItalic ? (aBold ? "/KicadFont-BoldOblique" : "/KicadFont-Oblique") - : (aBold ? "/KicadFont-Bold" - : "/KicadFont"); + : (aBold ? "/KicadFont-Bold" + : "/KicadFont"); // Compute the copious tranformation parameters double ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f; @@ -874,16 +879,16 @@ void PS_PLOTTER::Text( const wxPoint& aPos, if( m_textMode == PLOTTEXTMODE_PHANTOM ) { fputsPostscriptString( outputFile, aText ); - DPOINT pos_dev = userToDeviceCoordinates( aPos ); + DPOINT pos_dev = userToDeviceCoordinates( aPos ); fprintf( outputFile, " %g %g phantomshow\n", pos_dev.x, pos_dev.y ); } // Draw the stroked text (if requested) - if( m_textMode != PLOTTEXTMODE_NATIVE ) + if( m_textMode != PLOTTEXTMODE_NATIVE || aMultilineAllowed ) { PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, - aWidth, aItalic, aBold ); + aWidth, aItalic, aBold, aMultilineAllowed ); } } diff --git a/common/common_plotSVG_functions.cpp b/common/common_plotSVG_functions.cpp index b883107c84..e5d00a63e5 100644 --- a/common/common_plotSVG_functions.cpp +++ b/common/common_plotSVG_functions.cpp @@ -478,6 +478,15 @@ void SVG_PLOTTER::PenTo( const wxPoint& pos, char plume ) if( penState == 'Z' ) // here plume = 'D' or 'U' { DPOINT pos_dev = userToDeviceCoordinates( pos ); + + // Ensure we do not use a fill mode when moving tne pen, + // in SVG mode (i;e. we are plotting only basic lines, not a filled area + if( m_fillMode != NO_FILL ) + { + setFillMode( NO_FILL ); + setSVGPlotStyle(); + } + fprintf( outputFile, " -//#include #include #include #include #include -//#include #include #include diff --git a/include/plot_common.h b/include/plot_common.h index f59a2fbd82..3f0aee4e75 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -568,7 +568,8 @@ public: enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, - bool aBold ); + bool aBold, + bool aMultilineAllowed = false ); protected: virtual void emitSetRGBColor( double r, double g, double b ); }; @@ -633,7 +634,8 @@ public: enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, - bool aBold ); + bool aBold, + bool aMultilineAllowed = false ); virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos, double aScaleFactor ); @@ -702,7 +704,8 @@ public: enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, - bool aBold ); + bool aBold, + bool aMultilineAllowed = false ); protected: FILL_T m_fillMode; // true if the current contour @@ -904,7 +907,8 @@ public: enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, - bool aBold ); + bool aBold, + bool aMultilineAllowed = false ); protected: bool textAsLines;