From f486a24914d9dece3a599e20fb510c1e6d54151c Mon Sep 17 00:00:00 2001 From: make-ing Date: Tue, 21 Jun 2016 13:44:19 +0200 Subject: [PATCH] fixed the DPI settings not working Problem, and added a PNotify messsage if an Illustrator comment is detected. --- src/octoprint/plugins/svgtogcode/__init__.py | 4 ++-- .../plugins/svgtogcode/static/js/working_area.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/__init__.py b/src/octoprint/plugins/svgtogcode/__init__.py index 123e8630..4b65fb0c 100644 --- a/src/octoprint/plugins/svgtogcode/__init__.py +++ b/src/octoprint/plugins/svgtogcode/__init__.py @@ -270,7 +270,7 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin, feedrate = max(1,data["defaultFeedrate"]) s.set(["defaultFeedrate"], feedrate) if "svgDPI" in data and data["svgDPI"]: - s.set(["svgDPI"], data["svgDPI"]) + s.set_int(["svgDPI"], data["svgDPI"]) if "debug_logging" in data: old_debug_logging = s.get_boolean(["debug_logging"]) new_debug_logging = data["debug_logging"] in octoprint.settings.valid_boolean_trues @@ -344,7 +344,7 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin, if not machinecode_path: path, _ = os.path.splitext(model_path) machinecode_path = path + ".gco" - + self._svgtogcode_logger.info("### Slicing %s to %s using profile stored at %s" % (model_path, machinecode_path, profile_path)) ## direct call diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 3af0b1e4..3aafd98a 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -268,9 +268,19 @@ $(function(){ } } + // find Illustrator comment and notify + f.node.childNodes.forEach(function(entry) { + if(entry.nodeType == 8) { // Nodetype 8 = comment + if(entry.textContent.indexOf('Illustrator') > -1) { + new PNotify({title: gettext("Illustrator SVG Detected"), text: "Looks like an Illustrator SVG! If the scale is not right, and you want to change the DPI, please go to the \'Settings\' menu and change the \'SVG dpi\' field under \'Plugins/Svg Conversion\' and add the file again.", type: "info", hide: false}); + } + } + }); + // scale matrix var mat = self.getDocumentViewBoxMatrix(doc_width, doc_height, doc_viewbox); - var scaleMatrixStr = new Snap.Matrix(mat[0][0],mat[0][1],mat[1][0],mat[1][1],mat[0][2],mat[1][2]).toTransformString(); + var dpiscale = 90 / self.settings.settings.plugins.svgtogcode.svgDPI(); + var scaleMatrixStr = new Snap.Matrix(mat[0][0],mat[0][1],mat[1][0],mat[1][1],mat[0][2],mat[1][2]).scale(dpiscale).toTransformString(); newSvgAttrs['transform'] = scaleMatrixStr; var newSvg = snap.group(f.selectAll("svg>*"));