Permalink
Browse files

Fix stroke width in mapping selection for Corel X8 and others (#411)

* add more test SVG files

* get DPI from viewBox, so that stroke width mapping shows correct values for Corel X8 files
  • Loading branch information...
mgmax authored and t-oster committed Apr 24, 2017
1 parent 0b38e04 commit 1e226d994c49b99c941293b15c8007d06d4e9d0d
Showing with 936 additions and 25 deletions.
  1. +10 −0 src/com/t_oster/visicut/model/graphicelements/svgsupport/SVGImporter.java
  2. +1 −0 test/com/t_oster/visicut/model/graphicelements/svgsupport/scaling/README.txt
  3. +7 −0 test/com/t_oster/visicut/model/graphicelements/svgsupport/scaling/illustrator_15.svg
  4. +52 −0 ...sicut/model/graphicelements/svgsupport/scaling/illustrator_15_edited_in_inkscape_0.92_resized.svg
  5. +110 −0 test/com/t_oster/visicut/model/graphicelements/svgsupport/scaling/inkscape_0.48.svg
  6. +111 −0 ...ut/model/graphicelements/svgsupport/scaling/inkscape_0.48_updated_in_0.92_with_adjust_viewbox.svg
  7. +110 −0 ...t/model/graphicelements/svgsupport/scaling/inkscape_0.48_updated_in_0.92_with_resize_elements.svg
  8. +76 −0 test/com/t_oster/visicut/model/graphicelements/svgsupport/scaling/inkscape_0.92.svg
  9. +16 −0 .../t_oster/visicut/model/graphicelements/svgsupport/scaling/inkscape_0.92_edited_in_illustrator.svg
  10. +75 −0 ...om/t_oster/visicut/model/graphicelements/svgsupport/scaling/inkscape_0.92_without_version_tag.svg
  11. +2 −0 test/com/t_oster/visicut/model/graphicelements/svgsupport/stroke-width/README.txt
  12. +12 −0 test/com/t_oster/visicut/model/graphicelements/svgsupport/stroke-width/corel_18_10mm_stroke.svg
  13. +107 −0 test/com/t_oster/visicut/model/graphicelements/svgsupport/stroke-width/illustrator15.svg
  14. +75 −11 test/com/t_oster/visicut/model/graphicelements/svgsupport/stroke-width/inkscape_0.91_stroke.svg
  15. +94 −14 ...er/visicut/model/graphicelements/svgsupport/stroke-width/inkscape_0.91_stroke_transformations.svg
  16. +78 −0 test/com/t_oster/visicut/model/graphicelements/svgsupport/stroke-width/inkscape_0.92.svg
@@ -133,6 +133,16 @@ public void close() throws SecurityException{}
root = u.getDiagram(svg).getRoot();
GraphicSet result = new GraphicSet();
result.setBasicTransform(determineTransformation(root, svgResolution));
+
+ // The resulting transformation is the mapping of "SVG pixels" to real millimeters.
+ // If viewBox, width and height are set, this scaling can be different from
+ // the implicit svgResolution before, so we recalculate the svgResolution.
+ //
+ // Note: Modifying svgResolution at this point only affects the values
+ // of stroke-width shown in the mapping table, and nothing else, especially
+ // not the rendering or the laser engraving result.
+ double mmPerPx = (result.getBasicTransform().getScaleX() + result.getBasicTransform().getScaleY()) / 2;
+ svgResolution = 1/Util.mm2inch(mmPerPx);
importNode(root, result, svgResolution, warnings);
Logger.getLogger(SVGConst.SVG_LOGGER).removeHandler(svgImportLoggerHandler);
return result;
@@ -0,0 +1 @@
+All these files should import as 10x10cm bounding box (using the "engrave all" profile)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="595.28px" height="841.89px" viewBox="0 0 595.28 841.89" enable-background="new 0 0 595.28 841.89" xml:space="preserve">
+<rect x="183.44" y="85.992" fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" width="283.465" height="283.465"/>
+</svg>
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ id="Ebene_1"
+ x="0px"
+ y="0px"
+ width="595.28px"
+ height="841.89px"
+ viewBox="0 0 595.28 841.89"
+ enable-background="new 0 0 595.28 841.89"
+ xml:space="preserve"
+ sodipodi:docname="illustrator15_inkscape_0.92_resized.svg"
+ inkscape:version="0.92.1 r15371"><metadata
+ id="metadata3979"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs3977" /><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1920"
+ inkscape:window-height="1137"
+ id="namedview3975"
+ showgrid="false"
+ inkscape:zoom="0.79286936"
+ inkscape:cx="414.55733"
+ inkscape:cy="532.68843"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="Ebene_1" /><rect
+ x="183.60432"
+ y="84.739204"
+ stroke-miterlimit="10"
+ width="376.62411"
+ height="376.62411"
+ id="rect3972"
+ style="fill:#ffffff;stroke:#000000;stroke-width:1.32864428;stroke-miterlimit:10" /></svg>
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="210mm"
+ height="297mm"
+ id="svg3060"
+ version="1.1"
+ inkscape:version="0.48.5 r10040"
+ sodipodi:docname="Neues Dokument 5">
+ <defs
+ id="defs3062" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.35"
+ inkscape:cx="350"
+ inkscape:cy="518.57143"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="588"
+ inkscape:window-height="440"
+ inkscape:window-x="1920"
+ inkscape:window-y="733"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata3065">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Ebene 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <path
+ inkscape:connector-curvature="0"
+ style="fill:#008080;fill-opacity:1"
+ d="m 262.51295,323.76827 309.25982,0 c 12.48463,0 22.53543,10.05021 22.53543,22.53412 l 0,309.26245 c 0,12.48392 -10.0508,22.53412 -22.53543,22.53412 l -309.25982,0 c -12.48463,0 -22.53544,-10.0502 -22.53544,-22.53412 l 0,-309.26245 c 0,-12.48391 10.05081,-22.53412 22.53544,-22.53412 z"
+ id="rect3957" />
+ <g
+ transform="matrix(3.543307,0,0,3.543307,89.977522,93.727486)"
+ style="font-size:10.58333302px;font-style:normal;font-weight:normal;line-height:6.61458302px;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:sans-serif"
+ id="text3970">
+ <path
+ inkscape:connector-curvature="0"
+ d="m 59.520913,122.25245 1.705323,0 0,-5.88594 -1.855184,0.37207 0,-0.95085 1.844848,-0.37207 1.043864,0 0,6.83679 1.705322,0 0,0.8785 -4.444173,0 0,-0.8785"
+ style="fill:#ffffff"
+ id="path3020" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 68.311074,116.10296 c -0.537438,0 -0.942236,0.26528 -1.214396,0.79581 -0.268719,0.52711 -0.403078,1.3212 -0.403076,2.38229 -2e-6,1.05764 0.134357,1.85174 0.403076,2.38228 0.27216,0.5271 0.676958,0.79065 1.214396,0.79065 0.540876,0 0.945675,-0.26355 1.214396,-0.79065 0.272158,-0.53054 0.408239,-1.32464 0.408244,-2.38228 -5e-6,-1.06109 -0.136086,-1.85518 -0.408244,-2.38229 -0.268721,-0.53053 -0.67352,-0.79581 -1.214396,-0.79581 m 0,-0.82683 c 0.864715,1e-5 1.52445,0.3428 1.979207,1.02836 0.458192,0.68214 0.687291,1.67433 0.687297,2.97657 -6e-6,1.2988 -0.229105,2.29099 -0.687297,2.97656 -0.454757,0.68213 -1.114492,1.02319 -1.979207,1.02319 -0.864721,0 -1.526179,-0.34106 -1.984375,-1.02319 -0.454753,-0.68557 -0.682129,-1.67776 -0.682129,-2.97656 0,-1.30224 0.227376,-2.29443 0.682129,-2.97657 0.458196,-0.68556 1.119654,-1.02835 1.984375,-1.02836"
+ style="fill:#ffffff"
+ id="path3022" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 75.049681,116.10296 c -0.537438,0 -0.942236,0.26528 -1.214397,0.79581 -0.268719,0.52711 -0.403077,1.3212 -0.403076,2.38229 -10e-7,1.05764 0.134357,1.85174 0.403076,2.38228 0.272161,0.5271 0.676959,0.79065 1.214397,0.79065 0.540876,0 0.945674,-0.26355 1.214396,-0.79065 0.272157,-0.53054 0.408239,-1.32464 0.408244,-2.38228 -5e-6,-1.06109 -0.136087,-1.85518 -0.408244,-2.38229 -0.268722,-0.53053 -0.67352,-0.79581 -1.214396,-0.79581 m 0,-0.82683 c 0.864714,1e-5 1.524449,0.3428 1.979207,1.02836 0.458192,0.68214 0.68729,1.67433 0.687296,2.97657 -6e-6,1.2988 -0.229104,2.29099 -0.687296,2.97656 -0.454758,0.68213 -1.114493,1.02319 -1.979207,1.02319 -0.864722,0 -1.526179,-0.34106 -1.984375,-1.02319 -0.454754,-0.68557 -0.68213,-1.67776 -0.682129,-2.97656 -10e-7,-1.30224 0.227375,-2.29443 0.682129,-2.97657 0.458196,-0.68556 1.119653,-1.02835 1.984375,-1.02836"
+ style="fill:#ffffff"
+ id="path3024" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 84.232583,117.34319 -2.092895,2.81637 2.201416,2.97139 -1.121379,0 -1.684651,-2.27376 -1.684652,2.27376 -1.121379,0 2.247925,-3.02824 -2.056722,-2.75952 1.121379,0 1.53479,2.06189 1.53479,-2.06189 1.121378,0"
+ style="fill:#ffffff"
+ id="path3026" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 85.999917,122.25245 1.705323,0 0,-5.88594 -1.855184,0.37207 0,-0.95085 1.844848,-0.37207 1.043864,0 0,6.83679 1.705322,0 0,0.8785 -4.444173,0 0,-0.8785"
+ style="fill:#ffffff"
+ id="path3028" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 94.790077,116.10296 c -0.537438,0 -0.942236,0.26528 -1.214396,0.79581 -0.268719,0.52711 -0.403078,1.3212 -0.403076,2.38229 -2e-6,1.05764 0.134357,1.85174 0.403076,2.38228 0.27216,0.5271 0.676958,0.79065 1.214396,0.79065 0.540876,0 0.945674,-0.26355 1.214396,-0.79065 0.272158,-0.53054 0.408239,-1.32464 0.408244,-2.38228 -5e-6,-1.06109 -0.136086,-1.85518 -0.408244,-2.38229 -0.268722,-0.53053 -0.67352,-0.79581 -1.214396,-0.79581 m 0,-0.82683 c 0.864715,1e-5 1.52445,0.3428 1.979207,1.02836 0.458192,0.68214 0.687291,1.67433 0.687297,2.97657 -6e-6,1.2988 -0.229105,2.29099 -0.687297,2.97656 -0.454757,0.68213 -1.114492,1.02319 -1.979207,1.02319 -0.864721,0 -1.526179,-0.34106 -1.984375,-1.02319 -0.454753,-0.68557 -0.682129,-1.67776 -0.682129,-2.97656 0,-1.30224 0.227376,-2.29443 0.682129,-2.97657 0.458196,-0.68556 1.119654,-1.02835 1.984375,-1.02836"
+ style="fill:#ffffff"
+ id="path3030" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 101.52868,116.10296 c -0.53744,0 -0.94223,0.26528 -1.21439,0.79581 -0.26872,0.52711 -0.403081,1.3212 -0.40308,2.38229 -10e-7,1.05764 0.13436,1.85174 0.40308,2.38228 0.27216,0.5271 0.67695,0.79065 1.21439,0.79065 0.54088,0 0.94568,-0.26355 1.2144,-0.79065 0.27216,-0.53054 0.40824,-1.32464 0.40824,-2.38228 0,-1.06109 -0.13608,-1.85518 -0.40824,-2.38229 -0.26872,-0.53053 -0.67352,-0.79581 -1.2144,-0.79581 m 0,-0.82683 c 0.86472,1e-5 1.52445,0.3428 1.97921,1.02836 0.45819,0.68214 0.68729,1.67433 0.6873,2.97657 -1e-5,1.2988 -0.22911,2.29099 -0.6873,2.97656 -0.45476,0.68213 -1.11449,1.02319 -1.97921,1.02319 -0.86472,0 -1.52618,-0.34106 -1.984372,-1.02319 -0.454754,-0.68557 -0.68213,-1.67776 -0.682129,-2.97656 -10e-7,-1.30224 0.227375,-2.29443 0.682129,-2.97657 0.458192,-0.68556 1.119652,-1.02835 1.984372,-1.02836"
+ style="fill:#ffffff"
+ id="path3032" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 110.4067,118.45423 c 0.2377,-0.42718 0.52192,-0.74241 0.85266,-0.94567 0.33072,-0.20326 0.72002,-0.30489 1.16788,-0.3049 0.60289,1e-5 1.06798,0.21188 1.39527,0.63562 0.32727,0.42031 0.49091,1.01976 0.49092,1.79834 l 0,3.49333 -0.95601,0 0,-3.46232 c -1e-5,-0.55466 -0.0982,-0.96634 -0.29456,-1.23507 -0.19637,-0.26871 -0.4961,-0.40307 -0.89917,-0.40307 -0.49265,0 -0.88195,0.16364 -1.16788,0.49092 -0.28595,0.32729 -0.42892,0.77343 -0.42892,1.33842 l 0,3.27112 -0.95601,0 0,-3.46232 c -10e-6,-0.5581 -0.0982,-0.96979 -0.29456,-1.23507 -0.19637,-0.26871 -0.49954,-0.40307 -0.9095,-0.40307 -0.48576,0 -0.87161,0.16537 -1.15755,0.49609 -0.28595,0.32729 -0.42892,0.77171 -0.42892,1.33325 l 0,3.27112 -0.95601,0 0,-5.78776 0.95601,0 0,0.89917 c 0.21704,-0.35484 0.47715,-0.61667 0.78032,-0.78548 0.30316,-0.1688 0.66317,-0.25321 1.08003,-0.25322 0.4203,1e-5 0.77687,0.10681 1.06971,0.3204 0.29627,0.2136 0.51503,0.52366 0.65629,0.93017"
+ style="fill:#ffffff"
+ id="path3034" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 120.72131,118.45423 c 0.23771,-0.42718 0.52193,-0.74241 0.85266,-0.94567 0.33072,-0.20326 0.72002,-0.30489 1.16789,-0.3049 0.60288,1e-5 1.06797,0.21188 1.39526,0.63562 0.32728,0.42031 0.49092,1.01976 0.49093,1.79834 l 0,3.49333 -0.95602,0 0,-3.46232 c 0,-0.55466 -0.0982,-0.96634 -0.29455,-1.23507 -0.19638,-0.26871 -0.4961,-0.40307 -0.89917,-0.40307 -0.49266,0 -0.88195,0.16364 -1.16789,0.49092 -0.28595,0.32729 -0.42892,0.77343 -0.42891,1.33842 l 0,3.27112 -0.95602,0 0,-3.46232 c 0,-0.5581 -0.0982,-0.96979 -0.29455,-1.23507 -0.19638,-0.26871 -0.49955,-0.40307 -0.90951,-0.40307 -0.48576,0 -0.87161,0.16537 -1.15755,0.49609 -0.28595,0.32729 -0.42892,0.77171 -0.42891,1.33325 l 0,3.27112 -0.95602,0 0,-5.78776 0.95602,0 0,0.89917 c 0.21703,-0.35484 0.47714,-0.61667 0.78031,-0.78548 0.30316,-0.1688 0.66318,-0.25321 1.08004,-0.25322 0.42029,1e-5 0.77686,0.10681 1.0697,0.3204 0.29627,0.2136 0.51504,0.52366 0.65629,0.93017"
+ style="fill:#ffffff"
+ id="path3036" />
+ </g>
+ </g>
+</svg>
Oops, something went wrong.

0 comments on commit 1e226d9

Please sign in to comment.