- Status Closed
- Percent Complete
- Task Type Bug Report
- Category QCAD (main)
-
Assigned To
Andrew - Operating System All
- Severity Low
- Priority Very Low
- Reported Version 3 Beta 2
- Due in Version Undecided
-
Due Date
Undecided
- Votes
- Private
Attached to Project: QCAD Bugtracker
Opened by Peter - 07.10.2011
Last edited by Andrew - 15.10.2011
Opened by Peter - 07.10.2011
Last edited by Andrew - 15.10.2011
FS#300 - Dashed lines in SVG PG export
Chat from FS#194 singled out, so that can be closed.
Dash patterns in BETA2 are very much out of proportion. BETA2 always PG exports 1:1 and only scales strokes so that in the final rendering they match what a technical drawing would show. As dash patterns depend on stroke, both current stroke and final scale have to be brought in accord.
The patch below also restores the alignment of dashes, so that dashed lines do not end in a gap, at least in most occasions.
--- SvgExporterPG-orig.js 2011-09-15 23:11:40.000000000 +0200 +++ SvgExporterPG.js 2011-10-07 13:28:04.085376719 +0200 @@ -384,32 +384,29 @@ continuous = true; } if (!continuous) { - //p.scale(this.getPatternFactor()); - p.scale(1/this.scale); + // dash and gap lengths are to be proportional to line weight + // beware: line weight unit is 100 times millimeters, convert to current unit + // beware: the viewer scales lengths differently from weight + p.scale(RUnit.convert(this.weight / 100.0, RS.Millimeter, this.svgUnit) / this.scale); var num = p.getNumDashes(); - var str = ""; + var str = []; for ( var i = 0; i < num; ++i) { var len = Math.abs(p.getDashLengthAt(i)); - // see FS#192: - //len = this.convert(len); - str += "" + len; - if (i < num - 1) { - str += ","; - } - } - additionalStyles += "stroke-dasharray:" + str; - - // does more harm than good -// if (isShape(this.shape)) { -// var length = this.shape.getLength(); -// if (isNaN(this.offset)) { -// this.offset = this.getPatternOffset(length, p); -// } else { -// var num = Math.ceil(this.offset / p.getPatternLength()); - // this.offset -= num * p.getPatternLength(); - // } - // additionalStyles += ";stroke-dashoffset:" + this.offset; - // } + str.push(len); + } + additionalStyles += "stroke-dasharray:" + str.join(","); + + // center dash-array + if (isShape(this.shape) && isFinite(this.shape.getLength())) { + var length = this.shape.getLength(); + if (isNaN(this.offset)) { + this.offset = -this.getPatternOffset(length, p); + } else { + var num = Math.ceil(this.offset / p.getPatternLength()); + this.offset -= num * p.getPatternLength(); + } + additionalStyles += ";stroke-dashoffset:" + this.offset; + } }
Things are still a bit fluid here for line patterns.
We have to ensure compatibility with other products, correct PDF export, correct printing and correct display in model space and paper space.
Beta 3 will be released shortly. Please check this release against your requirements again.
This should be correct in QCAD 3 Beta 3, can you please confirm / deny this, so we can close / update this report? Thanks.
Attached picture of several lines, all the same pattern, but different stroke width, rendered from PG-exported SVG. This looks like it should. Thank you Andrew.