From aad5efff2d81367c1b085bff8e0f9e00118c8008 Mon Sep 17 00:00:00 2001 From: clemniem Date: Tue, 21 Jun 2016 15:13:36 +0200 Subject: [PATCH 1/8] WIP show text after upload in svg. missing: - add warning/dialogue about text in conversion dialogue - cleanup --- .../svgtogcode/static/js/matrix_oven.js | 2 +- .../svgtogcode/static/js/working_area.js | 26 +++++++------- .../svgtogcode/templates/svgtogcode.jinja2 | 36 ++++++++++--------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js b/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js index 95c50c6d..06b961dd 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js +++ b/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js @@ -44,7 +44,7 @@ Snap.plugin(function (Snap, Element, Paper, global) { var child = children[i]; child.bake(toCubics, dec); } - elem.attr({transform: ''}); + if(child.type !== "#text") elem.attr({transform: ''}); return; } if (elem.type !== "circle" && diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 3af0b1e4..5775633a 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -274,10 +274,10 @@ $(function(){ newSvgAttrs['transform'] = scaleMatrixStr; var newSvg = snap.group(f.selectAll("svg>*")); - var hasText = newSvg.selectAll('text,tspan'); - if(hasText !== null && hasText.length > 0){ - self.svg_contains_text_warning(newSvg); - } + // var hasText = newSvg.selectAll('text,tspan'); + // if(hasText !== null && hasText.length > 0){ + // self.svg_contains_text_warning(newSvg); + // } newSvg.bake(); // remove transforms newSvg.selectAll('path').attr({strokeWidth: '0.5'}); @@ -397,15 +397,15 @@ $(function(){ }; self.svg_contains_text_warning = function(svg){ - var error = "

" + gettext("The svg file contains text elements.
Please convert them to paths.
Otherwise they will be ignored.") + "

"; - //error += pnotifyAdditionalInfo("
" + data.jqXHR.responseText + "
"); - new PNotify({ - title: "Text elements found", - text: error, - type: "warn", - hide: false - }); - svg.selectAll('text,tspan').remove(); + // var error = "

" + gettext("The svg file contains text elements.
Please convert them to paths.
Otherwise they will be ignored.") + "

"; + // //error += pnotifyAdditionalInfo("
" + data.jqXHR.responseText + "
"); + // new PNotify({ + // title: "Text elements found", + // text: error, + // type: "warn", + // hide: false + // }); + // svg.selectAll('text,tspan').remove(); }; self.svg_misfitting_warning = function(svg, misfitting){ diff --git a/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 b/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 index 0eba6848..78d0636e 100644 --- a/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 +++ b/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 @@ -18,7 +18,7 @@
- Sets the intensity of the laser. The more intensity the deeper the effect on the material. + Sets the intensity of the laser. The more intensity the deeper the effect on the material. Cutting needs higher intensities than engraving. The effect in general is dependent from the material and its color and surface.
@@ -33,14 +33,16 @@
- Sets the velocity of the laser head. The slower the movement the deeper the effect on the material. - Cutting needs slower movement than engraving. + Sets the velocity of the laser head. The slower the movement the deeper the effect on the material. + Cutting needs slower movement than engraving. The effect in general is dependent from the material and its color and surface.
@@ -56,11 +58,11 @@
Some (especially bright) materials require the laser to dwell a little until the surface has absorbed enough energy to be affected. - This parameter sets the amount of time in milliseconds the movement is paused after the laser is switched on. + This parameter sets the amount of time in milliseconds the movement is paused after the laser is switched on. If the result shows gaps in lines for example increase this value carefully. The higher the value the higher the risk of material ignition.
- +

{{ _('Image engraving parameters:') }}

@@ -103,10 +105,10 @@
Pixel / raster engravings are done line by line. This sets the distance between the single lines. - Smaller values allow finer engravings but require a more precise focus and are slower. + Smaller values allow finer engravings but require a more precise focus and are slower.
- +

{{ _('Image Preprocessing') }}

before
@@ -114,22 +116,22 @@
- +
- +
-
+
- Increases the image contrast before converting to gcode. + Increases the image contrast before converting to gcode.
- +
@@ -137,10 +139,10 @@
- Sharpens the image before converting to gcode. + Sharpens the image before converting to gcode.
- +
- Converts the image to solely black and white pixels. - Use this if the laser effect on your material is not able to transfer grayscales. + Converts the image to solely black and white pixels. + Use this if the laser effect on your material is not able to transfer grayscales.
@@ -185,4 +187,4 @@ {{ _('Convert') }}
- \ No newline at end of file + From fffc0c4ecbdd494a0a6b99c1970328dea2f1f924 Mon Sep 17 00:00:00 2001 From: clemniem Date: Thu, 23 Jun 2016 11:04:22 +0200 Subject: [PATCH 2/8] excluded text from being jumped over, because it is not on the paper --- .../svgtogcode/static/js/matrix_oven.js | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js b/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js index 06b961dd..e14be63c 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js +++ b/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js @@ -30,8 +30,12 @@ Snap.plugin(function (Snap, Element, Paper, global) { */ Element.prototype.bake = function (toCubics, dec) { var elem = this; - if (!elem || !elem.paper) // don't handle unplaced elements. this causes double handling. + + console.log("ElemType: "+elem.type+" "+elem.id+" Children: "+elem.children().length); + if (!elem || !elem.paper || elem.type !== "text" || elem.type !== "#text" || elem.type !== "tspan"){ + console.log("Skip not on paper!"); return; + } // don't handle unplaced elements. this causes double handling. if (typeof (toCubics) === 'undefined') toCubics = false; @@ -42,9 +46,10 @@ Snap.plugin(function (Snap, Element, Paper, global) { if (children.length > 0) { for (var i = 0; i < children.length; i++) { var child = children[i]; + console.log("ChildType "+i+": "+child.type+" "+child.id+" Children: "+child.children().length); child.bake(toCubics, dec); } - if(child.type !== "#text") elem.attr({transform: ''}); + /*if(child.type !== "#text") */elem.attr({transform: ''}); return; } if (elem.type !== "circle" && @@ -54,14 +59,44 @@ Snap.plugin(function (Snap, Element, Paper, global) { elem.type !== "polygon" && elem.type !== "polyline" && elem.type !== "image" && - elem.type !== "path"){ + elem.type !== "path" && + elem.type !== "text" && + elem.type !== "tspan" && + elem.type !== "#text"){ // if(elem.type !== 'g' && elem.type !== 'desc' && elem.type !== 'defs') // console.log('skipping unsupported element ', elem.type); return; } - if (elem.type == 'image'){ + // if (elem.type == "text" || elem.type == "#text"){ + // var x = parseFloat(elem.attr('x')), + // y = parseFloat(elem.attr('y')), + // w = parseFloat(elem.attr('width')), + // h = parseFloat(elem.attr('height')); + // + // // Validity checks from http://www.w3.org/TR/SVG/shapes.html#RectElement: + // // If 'x' and 'y' are not specified, then set both to 0. // CorelDraw is creating that sometimes + // if (!isFinite(x)) { + // console.log('No attribute "x" in image tag. Assuming 0.') + // x = 0; + // } + // if (!isFinite(y)) { + // console.log('No attribute "y" in image tag. Assuming 0.') + // y = 0; + // } + // var transform = elem.transform(); + // var matrix = transform['totalMatrix']; + // var transformedX = matrix.x(x, y); + // var transformedY = matrix.y(x, y); + // var transformedW = matrix.x(x+w, y+h) - transformedX; + // var transformedH = matrix.y(x+w, y+h) - transformedY; + // + // elem.attr({x: transformedX, y: transformedY, width: transformedW, height: transformedH}); + // return; + // } + + if (elem.type == 'image' || elem.type == "text" || elem.type == "#text"){ // TODO ... var x = parseFloat(elem.attr('x')), y = parseFloat(elem.attr('y')), From 3ffdceb5af4865c68e42f16f0a819cb1abc29b8a Mon Sep 17 00:00:00 2001 From: clemniem Date: Thu, 23 Jun 2016 14:09:39 +0200 Subject: [PATCH 3/8] fixed conversion dialog, added second checkbox for text_fills, no real functionality added yet --- src/octoprint/plugins/svgtogcode/__init__.py | 4 +++- src/octoprint/plugins/svgtogcode/profile.py | 10 ++++++---- src/octoprint/plugins/svgtogcode/static/js/convert.js | 7 ++++++- .../plugins/svgtogcode/templates/svgtogcode.jinja2 | 6 +++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/__init__.py b/src/octoprint/plugins/svgtogcode/__init__.py index 123e8630..e8235eee 100644 --- a/src/octoprint/plugins/svgtogcode/__init__.py +++ b/src/octoprint/plugins/svgtogcode/__init__.py @@ -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 @@ -357,6 +357,8 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin, converter_path = '/home/teja/workspace/mrbeam-inkscape-ext' elif("denkbrett" in hostname): converter_path = '/home/flo/mrbeam/git/mrbeam-inkscape-ext' + elif ("clems-Air" in hostname): + converter_path = '/Users/clem/Dropbox/mrBeam/mrbeam-inkscape-ext' import sys sys.path.append(converter_path) diff --git a/src/octoprint/plugins/svgtogcode/profile.py b/src/octoprint/plugins/svgtogcode/profile.py index ce79e9af..9c5499d5 100644 --- a/src/octoprint/plugins/svgtogcode/profile.py +++ b/src/octoprint/plugins/svgtogcode/profile.py @@ -16,15 +16,16 @@ defaults = dict( # general settings svgDPI = 90, pierce_time = 0, - + # vector settings speed = 300, intensity = 500, fill_areas = False, + fill_text = False, cross_fill = False, fill_angle = 0, fill_spacing = 0.25, - + # pixel settings beam_diameter = 0.25, intensity_white = 0, @@ -251,8 +252,8 @@ class Profile(object): } return settings - - + + def convert_to_engine2(self): settings = { @@ -268,6 +269,7 @@ class Profile(object): "sharpening": self.get_float("img_sharpening"), "dithering": self.get_boolean("img_dithering"), "fill_areas": self.get_boolean("fill_areas"), + "fill_text": self.get_boolean("fill_text"), "cross_fill": self.get_boolean("cross_fill"), "fill_angle": self.get_float("fill_angle"), "fill_spacing": self.get_float("fill_spacing"), diff --git a/src/octoprint/plugins/svgtogcode/static/js/convert.js b/src/octoprint/plugins/svgtogcode/static/js/convert.js index fe37227f..70a769f5 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/convert.js +++ b/src/octoprint/plugins/svgtogcode/static/js/convert.js @@ -36,13 +36,17 @@ $(function(){ self.maxSpeed = ko.observable(3000); self.minSpeed = ko.observable(20); self.fill_areas = ko.observable(false); + self.fill_text = ko.observable(false); self.show_fill_areas_checkbox = ko.observable(false); + self.show_fill_text_checkbox = ko.observable(false); // image engraving stuff // preset values are a good start for wood engraving self.images_placed = ko.observable(false); self.show_image_parameters = ko.computed(function(){ - return self.images_placed() || (self.fill_areas() && self.show_vector_parameters()); + return self.images_placed() + || (self.fill_areas() && self.show_vector_parameters()) + || self.fill_text(); }); self.imgIntensityWhite = ko.observable(0); self.imgIntensityBlack = ko.observable(500); @@ -257,6 +261,7 @@ $(function(){ "profile.speed": self.laserSpeed(), "profile.intensity": self.laserIntensity(), "profile.fill_areas": self.fill_areas(), + "profile.fill_text": self.fill_text(), "profile.pierce_time": self.pierceTime(), "profile.intensity_black" : self.imgIntensityBlack(), "profile.intensity_white" : self.imgIntensityWhite(), diff --git a/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 b/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 index 78d0636e..8792dbee 100644 --- a/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 +++ b/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 @@ -41,9 +41,13 @@
+
+
+
From 4cb819fd7bc0739e5c081b98c7ea719636e3a4fa Mon Sep 17 00:00:00 2001 From: clemniem Date: Thu, 23 Jun 2016 14:43:04 +0200 Subject: [PATCH 4/8] added text to infill conversion --- .../plugins/svgtogcode/static/js/render_fills.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/render_fills.js b/src/octoprint/plugins/svgtogcode/static/js/render_fills.js index 60b55bd6..ee008cab 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/render_fills.js +++ b/src/octoprint/plugins/svgtogcode/static/js/render_fills.js @@ -66,7 +66,7 @@ Snap.plugin(function (Snap, Element, Paper, global) { Element.prototype.is_filled = function(){ var elem = this; - // TODO text support + // TODO text support --> check if working // TODO opacity support if (elem.type !== "circle" && elem.type !== "rect" && @@ -74,8 +74,10 @@ Snap.plugin(function (Snap, Element, Paper, global) { elem.type !== "line" && elem.type !== "polygon" && elem.type !== "polyline" && - elem.type !== "path" ){ - + elem.type !== "path" && + elem.type !== "text" && + elem.type !== "#text") + { return false; } From 8e02a97a61d18a71d98a5900195cc0333c423771 Mon Sep 17 00:00:00 2001 From: clemniem Date: Thu, 23 Jun 2016 14:53:04 +0200 Subject: [PATCH 5/8] added text to infill conversion, test 2 --- .../svgtogcode/static/js/render_fills.js | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/render_fills.js b/src/octoprint/plugins/svgtogcode/static/js/render_fills.js index ee008cab..3ee1b86e 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/render_fills.js +++ b/src/octoprint/plugins/svgtogcode/static/js/render_fills.js @@ -1,7 +1,7 @@ // render_fills.js - a snapsvg.io plugin to render the infill of svg files into a bitmap. // Copyright (C) 2015 Teja Philipp -// -// based on work by http://davidwalsh.name/convert-canvas-image +// +// based on work by http://davidwalsh.name/convert-canvas-image // and http://getcontext.net/read/svg-images-on-a-html5-canvas // // This program is free software: you can redistribute it and/or modify @@ -20,12 +20,12 @@ Snap.plugin(function (Snap, Element, Paper, global) { - - + + /** * @param {elem} elem start point - * + * * @returns {path} */ @@ -34,7 +34,7 @@ Snap.plugin(function (Snap, Element, Paper, global) { var selection = []; var children = elem.children(); - + if (children.length > 0) { var goRecursive = (elem.type !== "defs" && // ignore these tags elem.type !== "clipPath" && @@ -42,7 +42,7 @@ Snap.plugin(function (Snap, Element, Paper, global) { elem.type !== "rdf:rdf" && elem.type !== "cc:work" && elem.type !== "sodipodi:namedview"); - + if(goRecursive) { for (var i = 0; i < children.length; i++) { var child = children[i]; @@ -50,7 +50,7 @@ Snap.plugin(function (Snap, Element, Paper, global) { } } } else { - if(elem.type === 'image'){ + if(elem.type === 'image' || elem.type === "text" || elem.type === "#text"){ selection.push(elem); } else { if(fillPaths && elem.is_filled()){ @@ -65,8 +65,8 @@ Snap.plugin(function (Snap, Element, Paper, global) { Element.prototype.is_filled = function(){ var elem = this; - - // TODO text support --> check if working + + // TODO text support // TODO opacity support if (elem.type !== "circle" && elem.type !== "rect" && @@ -76,14 +76,15 @@ Snap.plugin(function (Snap, Element, Paper, global) { elem.type !== "polyline" && elem.type !== "path" && elem.type !== "text" && - elem.type !== "#text") - { + elem.type !== "#text" + ){ + return false; } - + var fill = elem.attr('fill'); var opacity = elem.attr('fill-opacity'); - + if(fill !== 'none'){ if(opacity === null || opacity > 0){ return true; @@ -91,7 +92,7 @@ Snap.plugin(function (Snap, Element, Paper, global) { } return false; }; - + Element.prototype.embedImage = function(callback){ var elem = this; if(elem.type !== 'image') return; @@ -115,9 +116,9 @@ Snap.plugin(function (Snap, Element, Paper, global) { }; image.src = url; - + }; - + Element.prototype.renderPNG = function (wMM, hMM, pxPerMM, callback) { var elem = this; @@ -131,7 +132,7 @@ Snap.plugin(function (Snap, Element, Paper, global) { var renderCanvas = document.createElement('canvas'); renderCanvas.id = "renderCanvas"; renderCanvas.width = wMM * pxPerMM; - renderCanvas.height = hMM * pxPerMM; + renderCanvas.height = hMM * pxPerMM; document.getElementsByTagName('body')[0].appendChild(renderCanvas); var renderCanvasContext = renderCanvas.getContext('2d'); From 6c44d8e24334fc170ffc951e582ee63be0787ea0 Mon Sep 17 00:00:00 2001 From: clemniem Date: Thu, 23 Jun 2016 16:51:50 +0200 Subject: [PATCH 6/8] added text to infill conversion, text will be treated like an image and always engraved. --- src/octoprint/plugins/svgtogcode/static/js/render_fills.js | 6 +++--- src/octoprint/plugins/svgtogcode/static/js/working_area.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/render_fills.js b/src/octoprint/plugins/svgtogcode/static/js/render_fills.js index 3ee1b86e..b21da1b3 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/render_fills.js +++ b/src/octoprint/plugins/svgtogcode/static/js/render_fills.js @@ -74,9 +74,9 @@ Snap.plugin(function (Snap, Element, Paper, global) { elem.type !== "line" && elem.type !== "polygon" && elem.type !== "polyline" && - elem.type !== "path" && - elem.type !== "text" && - elem.type !== "#text" + elem.type !== "path" //&& + // elem.type !== "text" && + // elem.type !== "#text" ){ return false; diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 5775633a..401fe9b4 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -833,7 +833,7 @@ $(function(){ for (var i = 0; i < fillings.length; i++) { var item = fillings[i]; - if (item.type === 'image') { + if (item.type === 'image' || item.type === "text" || item.type === "#text") { // remove filter effects on images for proper rendering var style = item.attr('style'); if (style !== null) { From e366b4c805e3189b19fa3c4d0cf9dfd9282cc162 Mon Sep 17 00:00:00 2001 From: clemniem Date: Thu, 30 Jun 2016 17:31:07 +0200 Subject: [PATCH 7/8] popup shows always laser infill if text is in userContent. --- src/octoprint/plugins/svgtogcode/profile.py | 2 -- src/octoprint/plugins/svgtogcode/static/js/convert.js | 10 ++++------ .../plugins/svgtogcode/static/js/working_area.js | 10 ++++++++++ .../plugins/svgtogcode/templates/svgtogcode.jinja2 | 6 ------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/profile.py b/src/octoprint/plugins/svgtogcode/profile.py index 9c5499d5..172e7a10 100644 --- a/src/octoprint/plugins/svgtogcode/profile.py +++ b/src/octoprint/plugins/svgtogcode/profile.py @@ -21,7 +21,6 @@ defaults = dict( speed = 300, intensity = 500, fill_areas = False, - fill_text = False, cross_fill = False, fill_angle = 0, fill_spacing = 0.25, @@ -269,7 +268,6 @@ class Profile(object): "sharpening": self.get_float("img_sharpening"), "dithering": self.get_boolean("img_dithering"), "fill_areas": self.get_boolean("fill_areas"), - "fill_text": self.get_boolean("fill_text"), "cross_fill": self.get_boolean("cross_fill"), "fill_angle": self.get_float("fill_angle"), "fill_spacing": self.get_float("fill_spacing"), diff --git a/src/octoprint/plugins/svgtogcode/static/js/convert.js b/src/octoprint/plugins/svgtogcode/static/js/convert.js index 70a769f5..b21fea96 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/convert.js +++ b/src/octoprint/plugins/svgtogcode/static/js/convert.js @@ -36,17 +36,15 @@ $(function(){ self.maxSpeed = ko.observable(3000); self.minSpeed = ko.observable(20); self.fill_areas = ko.observable(false); - self.fill_text = ko.observable(false); self.show_fill_areas_checkbox = ko.observable(false); - self.show_fill_text_checkbox = ko.observable(false); // image engraving stuff // preset values are a good start for wood engraving self.images_placed = ko.observable(false); + self.text_placed = ko.observable(false); self.show_image_parameters = ko.computed(function(){ - return self.images_placed() - || (self.fill_areas() && self.show_vector_parameters()) - || self.fill_text(); + return (self.images_placed() || self.text_placed() + || (self.fill_areas() && self.show_vector_parameters())); }); self.imgIntensityWhite = ko.observable(0); self.imgIntensityBlack = ko.observable(500); @@ -89,6 +87,7 @@ $(function(){ self.show_vector_parameters(self.workingArea.getPlacedSvgs().length > 0); self.show_fill_areas_checkbox(self.workingArea.hasFilledVectors()) self.images_placed(self.workingArea.getPlacedImages().length > 0); + self.text_placed(self.workingArea.hasTextItems()); //self.show_image_parameters(self.workingArea.getPlacedImages().length > 0); if(self.show_vector_parameters() || self.show_image_parameters()){ @@ -261,7 +260,6 @@ $(function(){ "profile.speed": self.laserSpeed(), "profile.intensity": self.laserIntensity(), "profile.fill_areas": self.fill_areas(), - "profile.fill_text": self.fill_text(), "profile.pierce_time": self.pierceTime(), "profile.intensity_black" : self.imgIntensityBlack(), "profile.intensity_white" : self.imgIntensityWhite(), diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 401fe9b4..2c469b49 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -711,6 +711,16 @@ $(function(){ return snap.selectAll("#userContent image"); }; + self.hasTextItems = function () { + if(snap.selectAll("#userContent tspan").length > 0 || + snap.selectAll("#userContent text").length > 0 || + snap.selectAll("userContent #text").length > 0) { + return true + }else{ + return false + } + }; + self.getPlacedGcodes = ko.computed(function() { var gcodeFiles = []; ko.utils.arrayForEach(self.placedDesigns(), function(design) { diff --git a/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 b/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 index 8792dbee..4f693105 100644 --- a/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 +++ b/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 @@ -44,12 +44,6 @@ {{ _('Engrave Infills') }} -
- -
From 793b009ab6deeb6430e486d3699449fd35fb892c Mon Sep 17 00:00:00 2001 From: clemniem Date: Thu, 30 Jun 2016 17:45:41 +0200 Subject: [PATCH 8/8] popup dialoge informing user about the handling of text elements in SVG that have been detected --- .../svgtogcode/static/js/working_area.js | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 2c469b49..664b2ce6 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -274,10 +274,10 @@ $(function(){ newSvgAttrs['transform'] = scaleMatrixStr; var newSvg = snap.group(f.selectAll("svg>*")); - // var hasText = newSvg.selectAll('text,tspan'); - // if(hasText !== null && hasText.length > 0){ - // self.svg_contains_text_warning(newSvg); - // } + var hasText = newSvg.selectAll('text,tspan'); + if(hasText !== null && hasText.length > 0){ + self.svg_contains_text_warning(newSvg); + } newSvg.bake(); // remove transforms newSvg.selectAll('path').attr({strokeWidth: '0.5'}); @@ -397,15 +397,14 @@ $(function(){ }; self.svg_contains_text_warning = function(svg){ - // var error = "

" + gettext("The svg file contains text elements.
Please convert them to paths.
Otherwise they will be ignored.") + "

"; - // //error += pnotifyAdditionalInfo("
" + data.jqXHR.responseText + "
"); - // new PNotify({ - // title: "Text elements found", - // text: error, - // type: "warn", - // hide: false - // }); - // svg.selectAll('text,tspan').remove(); + var error = "

" + gettext("The SVG file contains text elements.
If you want to laser just their outlines,
please convert them to paths.
Otherwise they will be engraved with infill.") + "

"; + //error += pnotifyAdditionalInfo("
" + data.jqXHR.responseText + "
"); + new PNotify({ + title: "Text elements found", + text: error, + type: "warn", + hide: false + }); }; self.svg_misfitting_warning = function(svg, misfitting){