Add check to negative values of mark length. Use GetCurrentLineWidth()
instead of currentPenWidth.
09.03.2015 19:06, jp charras пишет:
Le 09/03/2015 16:29, Eldar Khayrullin a écrit :
It is possible? May be you mean that need check this condition?
09.03.2015 18:19, jp charras пишет:
Le 09/03/2015 15:36, Eldar Khayrullin a écrit :
I deleted Magic numbers that set parameters of dash lines. Use constants
in mils. Then apply radius correction and scale to plot units when start
to plotting.
Make for PDF, PS, SVG plotters.
And some minor fixes.
Thanks.
But what happens when DASH_MARK_LENGTH <= currentPenWidth ?
Because the currentPenWidth can be > DASH_MARK_LENGTH, checking the dash
mark length always > 0 to avoid issues is certainly good.
(although this is an unusual pen width value, but who know!)
(and use the virtual GetCurrentLineWidth() instead of currentPenWidth is
better)
=== modified file 'common/class_plotter.cpp'
--- common/class_plotter.cpp 2015-03-04 19:45:18 +0000
+++ common/class_plotter.cpp 2015-03-09 16:20:48 +0000
@@ -126,12 +126,24 @@
}
-double PLOTTER::userToDeviceSize( double size )
+double PLOTTER::userToDeviceSize( double size ) const
{
return size * plotScale * iuPerDeviceUnit;
}
+double PLOTTER::GetDashMarkLenIU() const
+{
+ double mark = userToDeviceSize( DASH_MARK_LENGTH - GetCurrentLineWidth() );
+ return ( mark < 0.0 ) ? 0.0 : mark;
+}
+
+
+double PLOTTER::GetDashGapLenIU() const
+{
+ return userToDeviceSize( DASH_GAP_LENGTH + GetCurrentLineWidth() );
+}
+
void PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
FILL_T fill, int width )
{
=== modified file 'common/common_plotPDF_functions.cpp'
--- common/common_plotPDF_functions.cpp 2015-03-03 12:41:43 +0000
+++ common/common_plotPDF_functions.cpp 2015-03-09 14:22:59 +0000
@@ -132,7 +132,8 @@
{
wxASSERT( workFile );
if( dashed )
- fputs( "[200] 100 d\n", workFile );
+ fprintf( workFile, "[%d %d] 0 d\n",
+ (int) GetDashMarkLenIU(), (int) GetDashGapLenIU() );
else
fputs( "[] 0 d\n", workFile );
}
=== modified file 'common/common_plotPS_functions.cpp'
--- common/common_plotPS_functions.cpp 2014-10-19 20:20:16 +0000
+++ common/common_plotPS_functions.cpp 2015-03-09 14:22:59 +0000
@@ -228,7 +228,7 @@
/**
- * Write on a stream a string escaped for postscript/PDF
+ * Write on a stream a string escaped for postscript/PDF
*/
void PSLIKE_PLOTTER::fputsPostscriptString(FILE *fout, const wxString& txt)
{
@@ -469,7 +469,8 @@
{
wxASSERT( outputFile );
if( dashed )
- fputs( "dashedline\n", outputFile );
+ fprintf( outputFile, "[%d %d] 0 setdash\n",
+ (int) GetDashMarkLenIU(), (int) GetDashGapLenIU() );
else
fputs( "solidline\n", outputFile );
}
=== modified file 'common/common_plotSVG_functions.cpp'
--- common/common_plotSVG_functions.cpp 2015-03-06 17:46:04 +0000
+++ common/common_plotSVG_functions.cpp 2015-03-09 14:22:59 +0000
@@ -231,14 +231,8 @@
fputs( "stroke-linecap:round; stroke-linejoin:round;", outputFile );
if( m_dashed )
- {
- // Use a simple dash shape: a segment + a space
- #define DASH_SIZE 0.3 // length in mm of a dash
- double segm_len = DASH_SIZE * 10000/2.54 * m_IUsPerDecimil;
- // Use a space to the same len as segment, between segments
- double space_len = segm_len + pen_w;
- fprintf( outputFile, "stroke-dasharray:%g,%g;", segm_len, space_len );
- }
+ fprintf( outputFile, "stroke-dasharray:%g,%g;",
+ GetDashMarkLenIU(), GetDashGapLenIU() );
fputs( "\">\n", outputFile );
=== modified file 'include/plot_common.h'
--- include/plot_common.h 2015-03-06 17:46:04 +0000
+++ include/plot_common.h 2015-03-09 14:22:59 +0000
@@ -82,6 +82,11 @@
*/
class PLOTTER
{
+private:
+ /* Set dashed line parameters in mils */
+ static const int DASH_MARK_LENGTH = 80;
+ static const int DASH_GAP_LENGTH = 40;
+
public:
static const int DEFAULT_LINE_WIDTH = -1;
@@ -396,7 +401,11 @@
* Modifies size according to the plotter scale factors
* (simple double version)
*/
- virtual double userToDeviceSize( double size );
+ virtual double userToDeviceSize( double size ) const;
+
+ double GetDashMarkLenIU() const;
+
+ double GetDashGapLenIU() const;
/// Plot scale - chosen by the user (even implicitly with 'fit in a4')
double plotScale;
_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help : https://help.launchpad.net/ListHelp