From 572425b52b8d96815f90202fbc20bfd5ae463412 Mon Sep 17 00:00:00 2001 From: Teja Date: Fri, 7 Aug 2015 16:28:32 +0200 Subject: [PATCH] all parameters for image engraving are now in the ui. --- .../svgtogcode/static/css/svgtogcode.css | 16 ++- .../plugins/svgtogcode/static/js/convert.js | 40 ++++++- .../svgtogcode/static/js/working_area.js | 17 +++ .../svgtogcode/templates/svgtogcode.jinja2 | 100 ++++++++++++++---- 4 files changed, 152 insertions(+), 21 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/static/css/svgtogcode.css b/src/octoprint/plugins/svgtogcode/static/css/svgtogcode.css index e4edfa90..87169f55 100644 --- a/src/octoprint/plugins/svgtogcode/static/css/svgtogcode.css +++ b/src/octoprint/plugins/svgtogcode/static/css/svgtogcode.css @@ -1,5 +1,8 @@ table th.settings_plugin_svgtogcode_profiles_key,table td.settings_plugin_svgtogcode_profiles_key{text-overflow:ellipsis;text-align:left;width:200px}table th.settings_plugin_svgtogcode_profiles_name,table td.settings_plugin_svgtogcode_profiles_name{text-overflow:ellipsis;text-align:left}table th.settings_plugin_svgtogcode_profiles_actions,table td.settings_plugin_svgtogcode_profiles_actions{text-align:center;width:100px}table th.settings_plugin_svgtogcode_profiles_actions a,table td.settings_plugin_svgtogcode_profiles_actions a{text-decoration:none;color:#000}table th.settings_plugin_svgtogcode_profiles_actions a.disabled,table td.settings_plugin_svgtogcode_profiles_actions a.disabled{color:#ccc;cursor:default} -.slider_manual_input {margin-left: 1.5em; width: 2.5em;} +.slider_manual_input { + margin-left: 1.5em; + width: 2.5em; +} #gcode_reference .gcommand { font-weight: bold; @@ -16,4 +19,15 @@ table th.settings_plugin_svgtogcode_profiles_key,table td.settings_plugin_svgtog #gcode_reference ul li { list-style: none; margin-bottom: 1em; +} + +.svgtogcode_grayscale { + background-image: linear-gradient(90deg, #FFFFFF, #000000); + width:130px; + display: inline-block; +} + +.slider_manual_input.noleftspace{ + + margin-left: 0em; } \ No newline at end of file diff --git a/src/octoprint/plugins/svgtogcode/static/js/convert.js b/src/octoprint/plugins/svgtogcode/static/js/convert.js index bf61ecdf..c13aa916 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/convert.js +++ b/src/octoprint/plugins/svgtogcode/static/js/convert.js @@ -15,8 +15,14 @@ $(function(){ self.defaultSlicer = undefined; self.defaultProfile = undefined; - + + // expert settings + self.showExpertSettings = ko.observable(false); self.gcodeFilename = ko.observable(); + self.pierceTime = ko.observable(0); + + // vector settings + self.show_vector_parameters = ko.observable(true); self.laserIntensity = ko.observable(undefined); self.laserSpeed = ko.observable(undefined); self.maxSpeed = ko.observable(3000); @@ -26,6 +32,16 @@ $(function(){ self.slicers = ko.observableArray(); self.profile = ko.observable(); self.profiles = ko.observableArray(); + + // image engraving stuff + self.show_image_parameters = ko.observable(false); + self.imgIntensityWhite = ko.observable(0); + self.imgIntensityBlack = ko.observable(1000); + self.imgFeedrateWhite = ko.observable(3000); // TODO use machineprofile maximum + self.imgFeedrateBlack = ko.observable(500); + self.imgDithering = ko.observable(false); + self.imgSharpening = ko.observable(1); + self.imgContrast = ko.observable(1); self.maxSpeed.subscribe(function(val){ self._configureFeedrateSlider(); @@ -44,6 +60,8 @@ $(function(){ self.show_conversion_dialog = function() { self.svg = self.workingArea.getCompositionSVG(); self.gcodeFilesToAppend = self.workingArea.getPlacedGcodes(); + self.show_image_parameters(self.workingArea.getPlacedImages().length > 0); + self.show_vector_parameters(self.workingArea.getPlacedSvgs().length > 0); if(self.svg !== undefined){ if(self.laserIntensity() === undefined){ @@ -246,6 +264,7 @@ $(function(){ self.files.conversion = self; self._configureIntensitySlider(); self._configureFeedrateSlider(); +// self._configureImgSliders(); }; self._configureIntensitySlider = function() { @@ -303,6 +322,25 @@ $(function(){ self._calcRealSpeed = function(sliderVal){ return Math.round(self.minSpeed() + sliderVal/100 * (self.maxSpeed() - self.minSpeed())); }; + + self._configureImgSliders = function() { + self.intensitySlider = $("#svgtogcode_img_intensity_slider").slider({ + //id: "svgtogcode_img_intensity_slider_impl", + //reversed: false, + //selection: "after", +// orientation: "horizontal", +// min: 0, +// max: 1000, +// step: 1, + value: [200,500], +// enabled: true, + //formatter: function(value) { return "" ; } + }).on("slideStop", function(ev){ + //self.imgIntensity(ev.value); + //console.log(ev.value); + }); + + }; } diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 936f1d04..855fe25a 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -631,6 +631,23 @@ $(function(){ } }; + self.getPlacedSvgs = function() { + var svgFiles = []; + ko.utils.arrayForEach(self.placedDesigns(), function(design) { + if(design.type === 'model'){ + var extension = design.name.split('.').pop().toLowerCase(); + if (extension === "svg") { + svgFiles.push(design); + } + } + }); + return svgFiles; + }; + + self.getPlacedImages = function(){ + return snap.selectAll("#userContent image"); + }; + 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 5839b142..b1ae3073 100644 --- a/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 +++ b/src/octoprint/plugins/svgtogcode/templates/svgtogcode.jinja2 @@ -4,27 +4,83 @@