From 7297343ca00d1f392064741ef97e6b86f5409644 Mon Sep 17 00:00:00 2001 From: Teja Date: Sat, 23 May 2015 11:58:36 +0200 Subject: [PATCH] work in progress --- src/octoprint/plugins/svgtogcode/__init__.py | 2 +- src/octoprint/plugins/svgtogcode/static/js/working_area.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/octoprint/plugins/svgtogcode/__init__.py b/src/octoprint/plugins/svgtogcode/__init__.py index 6e38f37f..aabc01cd 100644 --- a/src/octoprint/plugins/svgtogcode/__init__.py +++ b/src/octoprint/plugins/svgtogcode/__init__.py @@ -143,7 +143,7 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin, def get_assets(self): return { - "js": [ "js/convert.js", "js/working_area.js", "js/gcode_parser.js", "js/lib/snap.svg-min.js"], + "js": [ "js/convert.js", "js/working_area.js", "js/gcode_parser.js", "js/lib/snap.svg-min.js", "js/bake_snap_plugin.js"], "less": ["less/svgtogcode.less"], "css": ["css/svgtogcode.css", "css/mrbeam.css"] } diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 2d8785b2..8db9f0c4 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -230,16 +230,20 @@ $(function(){ } } + // 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(); newSvgAttrs['transform'] = scaleMatrixStr; var newSvg = snap.group(f.selectAll("svg>*")); + newSvg.bake(); newSvg.attr(newSvgAttrs); var id = self.getEntryId(file); var previewId = self.generateUniqueId(id); // appends -# if multiple times the same design is placed. newSvg.attr({id: previewId}); snap.select("#userContent").append(newSvg); + //flatten(document.getElementById(previewId), false, true, false, 4) + //newSvg.attr({transform: scaleMatrixStr}); newSvg.drag();// TODO debug drag. should not be affected by scale matrix