QCAD

QCAD - 2D CAD System.

Click here for a documentation of the DokuWiki formatting syntax that can be used in reports

Please search for existing tasks (also closed ones) before opening a new task.

Please make sure that you are using the latest Version of QCAD before posting a bug (menu Help - Check for Updates)

Tasklist

FS#300 - Dashed lines in SVG PG export

Attached to Project: QCAD
Opened by Peter (hungerburg) - Friday, 07 October 2011, 13:35 GMT+2
Last edited by Andrew (andrew) - Saturday, 15 October 2011, 18:29 GMT+2
Task Type Bug Report
Category Main
Status Closed
Assigned To Andrew (andrew)
Operating System All
Severity Low
Priority Normal
Reported Version 3 Beta 2
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

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;
+        }
     }
This task depends upon

Closed by  Andrew (andrew)
Saturday, 15 October 2011, 18:29 GMT+2
Reason for closing:  Fixed
Comment by Andrew (andrew) - Friday, 07 October 2011, 14:36 GMT+2

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.

Comment by Andrew (andrew) - Saturday, 15 October 2011, 13:36 GMT+2

This should be correct in QCAD 3 Beta 3, can you please confirm / deny this, so we can close / update this report? Thanks.

Comment by Peter (hungerburg) - Saturday, 15 October 2011, 18:02 GMT+2

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.

Loading...