Merge branch 'mrbeam' into stable-1.2.2
This commit is contained in:
commit
2aa68e81ea
25 changed files with 1893 additions and 163 deletions
2
run
2
run
|
|
@ -19,7 +19,7 @@ I don't know anything about).
|
|||
sys.path.insert(0, os.path.join(basedir, "src"))
|
||||
|
||||
#import sys
|
||||
#sys.path.append('/home/teja/Downloads/pyvmmonitor/public_api')
|
||||
#sys.path.append('/home/teja/opt/pyvmmonitor/public_api')
|
||||
#import pyvmmonitor
|
||||
#pyvmmonitor.connect()
|
||||
|
||||
|
|
|
|||
|
|
@ -86,9 +86,10 @@ class Events(object):
|
|||
|
||||
# Settings
|
||||
SETTINGS_UPDATED = "SettingsUpdated"
|
||||
|
||||
|
||||
# GRBL
|
||||
LIMITS_HIT = "LimitsHit"
|
||||
SOFT_RESET = "Soft-Reset"
|
||||
RT_STATE = "RealTimeState"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -204,23 +204,7 @@ class FileManager(object):
|
|||
source_meta = self.get_metadata(source_location, source_path)
|
||||
hash = source_meta["hash"]
|
||||
|
||||
#<<<<<<< HEAD
|
||||
# class Wrapper(object):
|
||||
# def __init__(self, stl_name, temp_path, hash):
|
||||
# self.stl_name = stl_name
|
||||
# self.temp_path = temp_path
|
||||
# self.hash = hash
|
||||
#
|
||||
# def save(self, absolute_dest_path):
|
||||
# with open(absolute_dest_path, "w") as d:
|
||||
# d.write("; Generated from\n; {stl_name}\n; {hash}\r".format(**vars(self)))
|
||||
# with open(tmp_path, "r") as s:
|
||||
# import shutil
|
||||
# shutil.copyfileobj(s, d)
|
||||
#
|
||||
#=======
|
||||
import io
|
||||
#>>>>>>> upstream/maintenance
|
||||
links = [("model", dict(name=source_path))]
|
||||
_, stl_name = self.split_path(source_location, source_path)
|
||||
file_obj = StreamWrapper(os.path.basename(dest_path),
|
||||
|
|
|
|||
|
|
@ -204,15 +204,17 @@ class LaserCutterProfilesPlugin(octoprint.plugin.SettingsPlugin,
|
|||
if self._printer.is_locked() or self._printer.is_operational():
|
||||
if "volume" in new_profile:
|
||||
if "width" in new_profile["volume"]:
|
||||
width = int(new_profile['volume']['width'])
|
||||
width = float(new_profile['volume']['width'])
|
||||
if identifier == "_mrbeam_senior":
|
||||
width *= 2
|
||||
width += float(new_profile['volume']['origin_offset_x'])
|
||||
self._printer.commands('$130=' + str(width))
|
||||
time.sleep(0.1) ### TODO find better solution then sleep
|
||||
if "depth" in new_profile["volume"]:
|
||||
depth = int(new_profile['volume']['depth'])
|
||||
depth = float(new_profile['volume']['depth'])
|
||||
if identifier == "_mrbeam_senior":
|
||||
depth *= 2
|
||||
depth += float(new_profile['volume']['origin_offset_y'])
|
||||
self._printer.commands('$131=' + str(depth))
|
||||
|
||||
new_profile["id"] = identifier
|
||||
|
|
|
|||
|
|
@ -29,9 +29,11 @@ class LaserCutterProfileManager(object):
|
|||
name = "Mr Beam",
|
||||
model = "Junior",
|
||||
volume=dict(
|
||||
width = 216,
|
||||
depth = 297,
|
||||
width = 217,
|
||||
depth = 298,
|
||||
height = 0,
|
||||
origin_offset_x = 1,
|
||||
origin_offset_y = 1,
|
||||
),
|
||||
zAxis = False,
|
||||
axes=dict(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ $(function() {
|
|||
formFactor: "rectangular",
|
||||
width: 216,
|
||||
depth: 297,
|
||||
height: 0
|
||||
height: 0,
|
||||
origin_offset_x: 1,
|
||||
origin_offset_y: 1
|
||||
},
|
||||
zAxis: false,
|
||||
axes: {
|
||||
|
|
@ -108,8 +110,8 @@ $(function() {
|
|||
self.currentProfile(currentProfile);
|
||||
self.currentProfileData(currentProfileData);
|
||||
|
||||
self.workingarea.workingAreaWidthMM(self.currentProfileData().volume.width());
|
||||
self.workingarea.workingAreaHeightMM(self.currentProfileData().volume.depth());
|
||||
self.workingarea.workingAreaWidthMM(self.currentProfileData().volume.width() - self.currentProfileData().volume.origin_offset_x());
|
||||
self.workingarea.workingAreaHeightMM(self.currentProfileData().volume.depth() - self.currentProfileData().volume.origin_offset_y());
|
||||
var maxSpeed = Math.min(self.currentProfileData().axes.x.speed(), self.currentProfileData().axes.y.speed());
|
||||
self.conversion.maxSpeed(maxSpeed);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin,
|
|||
|
||||
def get_assets(self):
|
||||
return dict(
|
||||
js=[ "js/convert.js", "js/working_area.js", "js/gcode_parser.js", "js/lib/snap.svg-min.js", "js/matrix_oven.js", "js/drag_scale_rotate.js"],
|
||||
js=[ "js/convert.js", "js/working_area.js", "js/gcode_parser.js", "js/lib/snap.svg-min.js", "js/lib/photobooth_min.js", "js/matrix_oven.js", "js/render_fills.js", "js/drag_scale_rotate.js"],
|
||||
less=["less/svgtogcode.less"],
|
||||
css=["css/svgtogcode.css", "css/mrbeam.css"]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
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;
|
||||
margin-left: 1.5em;
|
||||
width: 2.5em;
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ table th.settings_plugin_svgtogcode_profiles_key,table td.settings_plugin_svgtog
|
|||
}
|
||||
|
||||
.svgtogcode_grayscale {
|
||||
background-image: linear-gradient(90deg, #FFFFFF, #000000);
|
||||
background-image: linear-gradient(90deg, #FFFFFF, #000000);
|
||||
width:220px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ svg text {
|
|||
-ms-user-select: none;
|
||||
cursor: default;
|
||||
pointer-events: none;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.img_slider{
|
||||
|
|
@ -60,8 +60,8 @@ svg text {
|
|||
left:0;
|
||||
}
|
||||
|
||||
.img_preprocessing_preview.after .contrast,
|
||||
.img_preprocessing_preview.after .sharpened,
|
||||
.img_preprocessing_preview.after .contrast,
|
||||
.img_preprocessing_preview.after .sharpened,
|
||||
.img_preprocessing_preview.after .sharpened_contrast {
|
||||
opacity: 0;
|
||||
}
|
||||
|
|
@ -85,3 +85,20 @@ svg text {
|
|||
font-size: large;
|
||||
padding-right: .5em;
|
||||
}
|
||||
|
||||
#photo_preview {
|
||||
width: 400px;
|
||||
height: 300px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.overrideSlider {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.overrideSlider input {
|
||||
width:45%;
|
||||
}
|
||||
.overrideSlider span {
|
||||
padding-left: .6em;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,10 +35,15 @@ $(function(){
|
|||
self.laserSpeed = ko.observable(undefined);
|
||||
self.maxSpeed = ko.observable(3000);
|
||||
self.minSpeed = ko.observable(20);
|
||||
self.fill_areas = ko.observable(false);
|
||||
self.show_fill_areas_checkbox = ko.observable(false);
|
||||
|
||||
// image engraving stuff
|
||||
// preset values are a good start for wood engraving
|
||||
self.show_image_parameters = ko.observable(false);
|
||||
self.images_placed = ko.observable(false);
|
||||
self.show_image_parameters = ko.computed(function(){
|
||||
return self.images_placed() || (self.fill_areas() && self.show_vector_parameters());
|
||||
});
|
||||
self.imgIntensityWhite = ko.observable(0);
|
||||
self.imgIntensityBlack = ko.observable(500);
|
||||
self.imgFeedrateWhite = ko.observable(1500);
|
||||
|
|
@ -76,12 +81,13 @@ $(function(){
|
|||
|
||||
// shows conversion dialog and extracts svg first
|
||||
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){
|
||||
self.show_fill_areas_checkbox(self.workingArea.hasFilledVectors())
|
||||
self.images_placed(self.workingArea.getPlacedImages().length > 0);
|
||||
//self.show_image_parameters(self.workingArea.getPlacedImages().length > 0);
|
||||
|
||||
if(self.show_vector_parameters() || self.show_image_parameters()){
|
||||
if(self.laserIntensity() === undefined){
|
||||
var intensity = self.settings.settings.plugins.svgtogcode.defaultIntensity();
|
||||
self.laserIntensity(intensity);
|
||||
|
|
@ -93,7 +99,7 @@ $(function(){
|
|||
|
||||
var gcodeFile = self.create_gcode_filename(self.workingArea.placedDesigns());
|
||||
self.gcodeFilename(gcodeFile);
|
||||
|
||||
|
||||
self.title(gettext("Converting"));
|
||||
$("#dialog_vector_graphics_conversion").modal("show"); // calls self.convert() afterwards
|
||||
} else {
|
||||
|
|
@ -101,6 +107,13 @@ $(function(){
|
|||
self.convert();
|
||||
}
|
||||
};
|
||||
|
||||
self.cancel_conversion = function(){
|
||||
if(self.slicing_in_progress()){
|
||||
console.log('cancel slicing', self.slicing_in_progress());
|
||||
// TODO cancel slicing properly
|
||||
}
|
||||
};
|
||||
|
||||
self.create_gcode_filename = function(placedDesigns){
|
||||
if(placedDesigns.length > 0){
|
||||
|
|
@ -233,43 +246,48 @@ $(function(){
|
|||
if(self.gcodeFilesToAppend.length === 1 && self.svg === undefined){
|
||||
self.files.startGcodeWithSafetyWarning(self.gcodeFilesToAppend[0]);
|
||||
} else {
|
||||
var filename = self.gcodeFilename() + self.settingsString() + '.gco';
|
||||
var gcodeFilename = self._sanitize(filename);
|
||||
self.slicing_in_progress(true);
|
||||
self.workingArea.getCompositionSVG(self.fill_areas(), function(composition){
|
||||
self.svg = composition;
|
||||
var filename = self.gcodeFilename() + self.settingsString() + '.gco';
|
||||
var gcodeFilename = self._sanitize(filename);
|
||||
|
||||
var data = {
|
||||
command: "convert",
|
||||
"profile.speed": self.laserSpeed(),
|
||||
"profile.intensity": self.laserIntensity(),
|
||||
"profile.pierce_time": self.pierceTime(),
|
||||
"profile.intensity_black" : self.imgIntensityBlack(),
|
||||
"profile.intensity_white" : self.imgIntensityWhite(),
|
||||
"profile.feedrate_black" : self.imgFeedrateBlack(),
|
||||
"profile.feedrate_white" : self.imgFeedrateWhite(),
|
||||
"profile.img_contrast" : self.imgContrast(),
|
||||
"profile.img_sharpening" : self.imgSharpening(),
|
||||
"profile.img_dithering" : self.imgDithering(),
|
||||
"profile.beam_diameter" : self.beamDiameter(),
|
||||
slicer: "svgtogcode",
|
||||
gcode: gcodeFilename
|
||||
};
|
||||
var data = {
|
||||
command: "convert",
|
||||
"profile.speed": self.laserSpeed(),
|
||||
"profile.intensity": self.laserIntensity(),
|
||||
"profile.fill_areas": self.fill_areas(),
|
||||
"profile.pierce_time": self.pierceTime(),
|
||||
"profile.intensity_black" : self.imgIntensityBlack(),
|
||||
"profile.intensity_white" : self.imgIntensityWhite(),
|
||||
"profile.feedrate_black" : self.imgFeedrateBlack(),
|
||||
"profile.feedrate_white" : self.imgFeedrateWhite(),
|
||||
"profile.img_contrast" : self.imgContrast(),
|
||||
"profile.img_sharpening" : self.imgSharpening(),
|
||||
"profile.img_dithering" : self.imgDithering(),
|
||||
"profile.beam_diameter" : self.beamDiameter(),
|
||||
slicer: "svgtogcode",
|
||||
gcode: gcodeFilename
|
||||
};
|
||||
|
||||
if(self.svg !== undefined){
|
||||
data.svg = self.svg;
|
||||
} else {
|
||||
data.svg = '<svg height="0" version="1.1" width="0" xmlns="http://www.w3.org/2000/svg"><defs/></svg>';
|
||||
}
|
||||
if(self.gcodeFilesToAppend !== undefined){
|
||||
data.gcodeFilesToAppend = self.gcodeFilesToAppend;
|
||||
}
|
||||
if(self.svg !== undefined){
|
||||
data.svg = self.svg;
|
||||
} else {
|
||||
data.svg = '<svg height="0" version="1.1" width="0" xmlns="http://www.w3.org/2000/svg"><defs/></svg>';
|
||||
}
|
||||
if(self.gcodeFilesToAppend !== undefined){
|
||||
data.gcodeFilesToAppend = self.gcodeFilesToAppend;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: API_BASEURL + "files/convert",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: API_BASEURL + "files/convert",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -291,29 +309,29 @@ $(function(){
|
|||
};
|
||||
self.onEventSlicingStarted = function(payload){
|
||||
self.slicing_in_progress(true);
|
||||
console.log("onSlicingDone" , payload);
|
||||
};
|
||||
self.onEventSlicingDone = function(payload){
|
||||
// payload
|
||||
// gcode: "angelina_20091211_0193_11more_i1000s300.gco"
|
||||
// gcode: "ex_11more_i1000s300.gco"
|
||||
// gcode_location: "local"
|
||||
// stl: "local/angelina_jolie_20091211_0193_11more_i1000s300.svg"
|
||||
// stl: "local/ex_11more_i1000s300.svg"
|
||||
// time: 30.612739086151123
|
||||
self.gcodeFilename(undefined);
|
||||
self.svg = undefined;
|
||||
$("#dialog_vector_graphics_conversion").modal("hide");
|
||||
self.slicing_in_progress(false);
|
||||
//console.log("onSlicingDone" , payload);
|
||||
};
|
||||
self.onEventSlicingCancelled = function(payload){
|
||||
self.gcodeFilename(undefined);
|
||||
self.svg = undefined;
|
||||
self.slicing_in_progress(false);
|
||||
$("#dialog_vector_graphics_conversion").modal("hide");
|
||||
console.log("onSlicingCancelled" , payload);
|
||||
//console.log("onSlicingCancelled" , payload);
|
||||
};
|
||||
self.onEventSlicingFailed = function(payload){
|
||||
self.slicing_in_progress(false);
|
||||
console.log("onSlicingFailed" , payload);
|
||||
//console.log("onSlicingFailed" , payload);
|
||||
};
|
||||
|
||||
self._configureIntensitySlider = function() {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
// Matrix Oven - a snapsvg.io plugin to apply & remove transformations from svg files.
|
||||
// Drag, Scale & Rotate - a snapsvg.io plugin to free transform objects in an svg.
|
||||
// Copyright (C) 2015 Teja Philipp <osd@tejaphilipp.de>
|
||||
//
|
||||
// based on work by https://gist.github.com/timo22345/9413158
|
||||
// and https://github.com/duopixel/Method-Draw/blob/master/editor/src/svgcanvas.js
|
||||
//
|
||||
// heavily inspired by http://svg.dabbles.info
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
|
|
@ -22,7 +21,7 @@
|
|||
Snap.plugin(function (Snap, Element, Paper, global) {
|
||||
|
||||
/**
|
||||
* bakes transformations of the element and all sub-elements into coordinates
|
||||
*
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -37,7 +37,8 @@ Snap.plugin(function (Snap, Element, Paper, global) {
|
|||
toCubics = false;
|
||||
if (typeof (dec) === 'undefined')
|
||||
dec = 5;
|
||||
var children = elem.selectAll('*')
|
||||
//var children = elem.selectAll('*')
|
||||
var children = elem.children();
|
||||
if (children.length > 0) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
|
|
|
|||
164
src/octoprint/plugins/svgtogcode/static/js/render_fills.js
Normal file
164
src/octoprint/plugins/svgtogcode/static/js/render_fills.js
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
// render_fills.js - a snapsvg.io plugin to render the infill of svg files into a bitmap.
|
||||
// Copyright (C) 2015 Teja Philipp <osd@tejaphilipp.de>
|
||||
//
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
Snap.plugin(function (Snap, Element, Paper, global) {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param {elem} elem start point
|
||||
*
|
||||
* @returns {path}
|
||||
*/
|
||||
|
||||
Element.prototype.removeUnfilled = function(fillPaths){
|
||||
var elem = this;
|
||||
var selection = [];
|
||||
var children = elem.children();
|
||||
|
||||
|
||||
if (children.length > 0) {
|
||||
var goRecursive = (elem.type !== "defs" && // ignore these tags
|
||||
elem.type !== "clipPath" &&
|
||||
elem.type !== "metadata" &&
|
||||
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];
|
||||
selection = selection.concat(child.removeUnfilled(fillPaths));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(elem.type === 'image'){
|
||||
selection.push(elem);
|
||||
} else {
|
||||
if(fillPaths && elem.is_filled()){
|
||||
selection.push(elem);
|
||||
} else {
|
||||
elem.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
return selection;
|
||||
};
|
||||
|
||||
Element.prototype.is_filled = function(){
|
||||
var elem = this;
|
||||
|
||||
// TODO text support
|
||||
// TODO opacity support
|
||||
if (elem.type !== "circle" &&
|
||||
elem.type !== "rect" &&
|
||||
elem.type !== "ellipse" &&
|
||||
elem.type !== "line" &&
|
||||
elem.type !== "polygon" &&
|
||||
elem.type !== "polyline" &&
|
||||
elem.type !== "path" ){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var fill = elem.attr('fill');
|
||||
var opacity = elem.attr('fill-opacity');
|
||||
|
||||
if(fill !== 'none'){
|
||||
if(opacity === null || opacity > 0){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Element.prototype.embedImage = function(callback){
|
||||
var elem = this;
|
||||
if(elem.type !== 'image') return;
|
||||
|
||||
var url = elem.attr('href');
|
||||
var image = new Image();
|
||||
|
||||
image.onload = function () {
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = this.naturalWidth; // or 'width' if you want a special/scaled size
|
||||
canvas.height = this.naturalHeight; // or 'height' if you want a special/scaled size
|
||||
|
||||
canvas.getContext('2d').drawImage(this, 0, 0);
|
||||
var dataUrl = canvas.toDataURL('image/png');
|
||||
elem.attr('href', dataUrl);
|
||||
canvas.remove();
|
||||
if(typeof callback === 'function'){
|
||||
callback(elem.attr('id'));
|
||||
console.log('embedded img');
|
||||
}
|
||||
};
|
||||
|
||||
image.src = url;
|
||||
|
||||
};
|
||||
|
||||
Element.prototype.renderPNG = function (wMM, hMM, pxPerMM, callback) {
|
||||
var elem = this;
|
||||
|
||||
// get svg as dataUrl
|
||||
var svgStr = elem.outerSVG();
|
||||
var svgDataUri = 'data:image/svg+xml;base64,' + window.btoa(svgStr);
|
||||
var source = new Image();
|
||||
source.src = svgDataUri;
|
||||
|
||||
// init render canvas and attach to page
|
||||
var renderCanvas = document.createElement('canvas');
|
||||
renderCanvas.id = "renderCanvas";
|
||||
renderCanvas.width = wMM * pxPerMM;
|
||||
renderCanvas.height = hMM * pxPerMM;
|
||||
document.getElementsByTagName('body')[0].appendChild(renderCanvas);
|
||||
var renderCanvasContext = renderCanvas.getContext('2d');
|
||||
|
||||
// render SVG image to the canvas once it loads.
|
||||
source.onload = function () {
|
||||
renderCanvasContext.drawImage(source, 0, 0, renderCanvas.width, renderCanvas.height);
|
||||
|
||||
// place fill bitmap into svg
|
||||
var fillBitmap = renderCanvas.toDataURL("image/png");
|
||||
if(typeof callback === 'function'){
|
||||
callback(fillBitmap);
|
||||
}
|
||||
renderCanvas.remove();
|
||||
};
|
||||
|
||||
// catch browsers without native svg support
|
||||
source.onerror = function() {
|
||||
console.error("Can't export! Maybe your browser doesn't support native SVG. Sorry.");
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -107,6 +107,8 @@ $(function(){
|
|||
if(self.state.isOperational() && !self.state.isPrinting()){
|
||||
var x = self.px2mm(event.offsetX);
|
||||
var y = self.px2mm(event.toElement.ownerSVGElement.offsetHeight - event.offsetY); // hopefully this works across browsers
|
||||
x = Math.min(x, self.workingAreaWidthMM());
|
||||
y = Math.min(y, self.workingAreaHeightMM());
|
||||
$.ajax({
|
||||
url: API_BASEURL + "printer/printhead",
|
||||
type: "POST",
|
||||
|
|
@ -310,13 +312,9 @@ $(function(){
|
|||
var bbox = svg.getBBox();
|
||||
var tx = self.px2mm(bbox.x * globalScale);
|
||||
var ty = self.workingAreaHeightMM() - self.px2mm(bbox.y2 * globalScale);
|
||||
// var tx = self.px2mm(svg.data('tx')*globalScale).toFixed(1);
|
||||
// var ty = -self.px2mm(svg.data('ty')*globalScale).toFixed(1);
|
||||
// var rot = svg.data('angle') || 0;
|
||||
var startIdx = transform.local.indexOf('r') + 1;
|
||||
var endIdx = transform.local.indexOf(',', startIdx);
|
||||
var rot = parseFloat(transform.local.substring(startIdx, endIdx)) || 0;
|
||||
// if(!rot) rot = 0; // avoid NaN
|
||||
var horizontal = self.px2mm((bbox.x2 - bbox.x) * globalScale);
|
||||
var vertical = self.px2mm((bbox.y2 - bbox.y) * globalScale);
|
||||
var id = svg.attr('id');
|
||||
|
|
@ -392,7 +390,7 @@ $(function(){
|
|||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
self.placeIMG = function (file) {
|
||||
var url = self._getIMGserveUrl(file);
|
||||
var img = new Image();
|
||||
|
|
@ -412,7 +410,7 @@ $(function(){
|
|||
newImg.attr({id: previewId, filter: 'url(#grayscale_filter)', 'data-serveurl': url});
|
||||
snap.select("#userContent").append(newImg);
|
||||
newImg.transformable();
|
||||
newImg.ftDisableRotate();
|
||||
//newImg.ftDisableRotate();
|
||||
newImg.ftRegisterCallback(self.svgTransformUpdate);
|
||||
file.id = id;
|
||||
file.previewId = previewId;
|
||||
|
|
@ -623,19 +621,36 @@ $(function(){
|
|||
self.check_sizes_and_placements();
|
||||
};
|
||||
|
||||
self.getCompositionSVG = function(){
|
||||
self.getCompositionSVG = function(fillAreas, callback){
|
||||
self.abortFreeTransforms();
|
||||
var tmpsvg = snap.select("#userContent").innerSVG(); // get working area
|
||||
if(tmpsvg !== ''){
|
||||
var wMM = self.workingAreaWidthMM();
|
||||
var hMM = self.workingAreaHeightMM();
|
||||
var wPT = wMM * 90 / 25.4;
|
||||
var hPT = hMM * 90 / 25.4;
|
||||
var compSvg = Snap(wPT, hPT);
|
||||
compSvg.attr('id', 'compSvg');
|
||||
|
||||
var userContent = snap.select("#userContent").clone();
|
||||
compSvg.append(userContent);
|
||||
|
||||
self.renderInfill(compSvg, fillAreas, wMM, hMM, 10, function(svgWithRenderedInfill){
|
||||
callback( self._wrapInSvgAndScale(svgWithRenderedInfill));
|
||||
$('#compSvg').remove();
|
||||
});
|
||||
};
|
||||
|
||||
self._wrapInSvgAndScale = function(content){
|
||||
var svgStr = content.innerSVG();
|
||||
if(svgStr !== ''){
|
||||
var dpiFactor = self.svgDPI()/25.4; // convert mm to pix 90dpi for inkscape, 72 for illustrator
|
||||
var w = dpiFactor * self.workingAreaWidthMM();
|
||||
var h = dpiFactor * self.workingAreaHeightMM();
|
||||
|
||||
// TODO: look for better solution to solve this Firefox bug problem
|
||||
tmpsvg = tmpsvg.replace("(\\\"","(");
|
||||
tmpsvg = tmpsvg.replace("\\\")",")");
|
||||
svgStr = svgStr.replace("(\\\"","(");
|
||||
svgStr = svgStr.replace("\\\")",")");
|
||||
|
||||
var svg = '<svg height="'+ h +'" version="1.1" width="'+ w +'" xmlns="http://www.w3.org/2000/svg"><defs/>'+ tmpsvg +'</svg>';
|
||||
var svg = '<svg height="'+ h +'" version="1.1" width="'+ w +'" xmlns="http://www.w3.org/2000/svg"><defs/>'+ svgStr +'</svg>';
|
||||
return svg;
|
||||
} else {
|
||||
return;
|
||||
|
|
@ -667,6 +682,19 @@ $(function(){
|
|||
return gcodeFiles;
|
||||
}, self);
|
||||
|
||||
self.hasFilledVectors = function(){
|
||||
var el = snap.selectAll('#userContent *');
|
||||
for (var i = 0; i < el.length; i++) {
|
||||
var e = el[i];
|
||||
var fill = e.attr('fill');
|
||||
var op = e.attr('fill-opacity');
|
||||
if(fill !== 'none' && op > 0){
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
self.draw_gcode = function(points, intensity, target){
|
||||
var stroke_color = intensity === 0 ? '#BBBBBB' : '#FF0000';
|
||||
|
|
@ -680,11 +708,6 @@ $(function(){
|
|||
};
|
||||
|
||||
self.draw_gcode_img_placeholder = function(x,y,w,h,url, target){
|
||||
var i = snap.rect(x,y,w,h).attr({
|
||||
stroke: '#AA0000',
|
||||
'stroke-width': 1
|
||||
});
|
||||
snap.select(target).append(i);
|
||||
if(url !== ""){
|
||||
var p = snap.image(url,x,y,w,h).attr({
|
||||
transform: 'matrix(1,0,0,-1,0,'+ String(h) +')',
|
||||
|
|
@ -698,7 +721,7 @@ $(function(){
|
|||
self.clear_gcode = function(){
|
||||
snap.select('#gCodePreview').clear();
|
||||
};
|
||||
|
||||
|
||||
self.onStartup = function(){
|
||||
self.state.workingArea = self;
|
||||
self.files.workingArea = self;
|
||||
|
|
@ -731,6 +754,79 @@ $(function(){
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
self._embedAllImages = function(svg, callback){
|
||||
|
||||
var allImages = svg.selectAll('image');
|
||||
var linkedImages = allImages.items.filter(function(i){ return !i.attr('href').startsWith('data:') });
|
||||
if(linkedImages.length > 0){
|
||||
var callbackCounter = linkedImages.length;
|
||||
for (var i = 0; i < linkedImages.length; i++) {
|
||||
var img = linkedImages[i];
|
||||
img.embedImage(function(){
|
||||
callbackCounter--;
|
||||
if(callbackCounter === 0 && typeof callback === 'function'){
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// callback if nothing to embed
|
||||
if(typeof callback === 'function'){
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// render the infill and inject it as an image into the svg
|
||||
self.renderInfill = function (svg, fillAreas, wMM, hMM, pxPerMM, callback) {
|
||||
var wPT = wMM * 90 / 25.4;
|
||||
var hPT = hMM * 90 / 25.4;
|
||||
var tmpSvg = Snap(wPT, hPT).attr('id', 'tmpSvg');
|
||||
// get only filled items and embed the images
|
||||
var userContent = svg.clone();
|
||||
tmpSvg.append(userContent);
|
||||
self._embedAllImages(tmpSvg, function(){
|
||||
var fillings = userContent.removeUnfilled(fillAreas);
|
||||
for (var i = 0; i < fillings.length; i++) {
|
||||
var item = fillings[i];
|
||||
|
||||
if (item.type === 'image') {
|
||||
// remove filter effects on images for proper rendering
|
||||
var style = item.attr('style');
|
||||
if (style !== null) {
|
||||
var strippedFilters = style.replace(/filter.+?;/, '');
|
||||
item.attr('style', strippedFilters);
|
||||
}
|
||||
} else {
|
||||
// remove stroke from other elements
|
||||
//item.attr('fill', '#ff0000');
|
||||
item.attr('stroke', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
var cb = function(result) {
|
||||
if(fillings.length > 0){
|
||||
// replace all images with the fill rendering
|
||||
svg.selectAll('image').remove();
|
||||
var waBB = snap.select('#coordGrid').getBBox();
|
||||
var fillImage = snap.image(result, 0, 0, waBB.w, waBB.h);
|
||||
fillImage.attr('id', 'fillRendering');
|
||||
svg.append(fillImage);
|
||||
}
|
||||
if (typeof callback === 'function') {
|
||||
callback(svg);
|
||||
}
|
||||
self._cleanup_render_mess();
|
||||
};
|
||||
|
||||
tmpSvg.renderPNG(wMM, hMM, pxPerMM, cb);
|
||||
});
|
||||
};
|
||||
|
||||
self._cleanup_render_mess = function(){
|
||||
$('#tmpSvg').remove();
|
||||
};
|
||||
|
||||
self.onBeforeBinding = function(){
|
||||
self.files.workingArea = self;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,12 @@
|
|||
The effect in general is dependent from the material and its color and surface.
|
||||
</div>
|
||||
</div>
|
||||
<label class="control-label">{{ _('Filled areas') }}</label>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: fill_areas">{{ _('Engrave Infills') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group" data-bind="visible: showExpertSettings ">
|
||||
|
|
@ -176,7 +182,7 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Cancel') }}</a>
|
||||
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true" data-bind="click: $root.cancel_conversion()">{{ _('Cancel') }}</a>
|
||||
<a href="#" class="btn btn-primary" data-bind="click: function() { if ($root.enableConvertButton()) { $root.convert() } }, enabled: enableConvertButton, css: {disabled: !$root.enableConvertButton()}">{{ _('Convert') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -23,7 +23,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
|||
|
||||
import re
|
||||
|
||||
import octoprint.util.comm_acc as comm
|
||||
import octoprint.util.comm_acc2 as comm
|
||||
import octoprint.util as util
|
||||
|
||||
from octoprint.settings import settings
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ from octoprint.plugin import plugin_manager, ProgressPlugin
|
|||
from octoprint.printer import PrinterInterface, PrinterCallback, UnknownScript
|
||||
from octoprint.printer.estimation import TimeEstimationHelper
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util import comm_acc as comm
|
||||
from octoprint.util import comm_acc2 as comm
|
||||
from octoprint.util import InvariantContainer
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -108,11 +108,11 @@ $(function() {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
self.rerenderControls = function () {
|
||||
var allControls = self.controlsFromServer.concat(self.additionalControls);
|
||||
self.controls(self._processControls(allControls))
|
||||
self.controls(self._processControls(allControls));
|
||||
};
|
||||
|
||||
self.requestData = function () {
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ $(function() {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
self.fromCurrentData = function(data) {
|
||||
self._processStateData(data.state);
|
||||
};
|
||||
|
|
@ -138,7 +138,7 @@ $(function() {
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
self.fromResponse = function(response, filenameToFocus, locationToFocus) {
|
||||
var files = response.files;
|
||||
_.each(files, function(element, index, list) {
|
||||
|
|
@ -267,7 +267,7 @@ $(function() {
|
|||
return "files_template_dummy";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
self.getEntryId = function(data) {
|
||||
return "gcode_file_" + md5(data["origin"] + ":" + data["name"]);
|
||||
};
|
||||
|
|
@ -344,7 +344,7 @@ $(function() {
|
|||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
|
||||
self.performSearch = function(e) {
|
||||
if (e !== undefined) {
|
||||
e.preventDefault();
|
||||
|
|
@ -375,7 +375,7 @@ $(function() {
|
|||
self.enableSVGConversion = function (data) {
|
||||
return self.loginState.isUser() && !(self.isPrinting() || self.isPaused());
|
||||
};
|
||||
|
||||
|
||||
self.onStartup = function() {
|
||||
$(".accordion-toggle[data-target='#files']").click(function() {
|
||||
var files = $("#files");
|
||||
|
|
@ -603,6 +603,90 @@ $(function() {
|
|||
}, 1000);
|
||||
});
|
||||
|
||||
$('#take_photo_dialog').on('hide', function () {
|
||||
$('#photo_preview').data("photobooth").destroy();
|
||||
});
|
||||
|
||||
|
||||
$('#take_photo_dialog').on('shown', function () {
|
||||
$('#photo_preview').photobooth();
|
||||
var w = $('#photo_preview').parent().width()*0.98;
|
||||
var h = w*3.0/4.0;
|
||||
$('#photo_preview').height(h);
|
||||
$('#photo_preview').width(w);
|
||||
$('#photo_preview').data('photobooth').resize(w, h);
|
||||
});
|
||||
|
||||
$('#photo_preview').on("image", function (event, dataUrl) {
|
||||
var photoBlob = self.dataUriToBlob(dataUrl);
|
||||
var t = new Date();
|
||||
var yyyy = t.getFullYear().toString();
|
||||
var mm = (t.getMonth()+1).toString(); // getMonth() is zero-based
|
||||
var dd = t.getDate().toString();
|
||||
var hh = t.getHours().toString();
|
||||
var m = t.getMinutes().toString();
|
||||
var date = yyyy + (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]) + '_' + (hh[1]?hh:"0"+hh[0])+(m[1]?m:"0"+m[0]); // padding
|
||||
|
||||
var filename = "Photo_" + date + ".png";
|
||||
var data = new FormData();
|
||||
data.append('file', photoBlob, filename);
|
||||
|
||||
jQuery.ajax({
|
||||
url: API_BASEURL + "files/local",
|
||||
data: data,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
type: 'POST',
|
||||
success: function(data, resp){
|
||||
gcode_upload_done(resp, {result: data});
|
||||
$('#take_photo_dialog').modal("hide");
|
||||
},
|
||||
fail: gcode_upload_fail,
|
||||
progressall: gcode_upload_progress
|
||||
});
|
||||
});
|
||||
|
||||
self.takePhoto = function () {
|
||||
$('#take_photo_dialog').modal("show");
|
||||
};
|
||||
|
||||
self.hasCamera = function () {
|
||||
var fGetUserMedia = (
|
||||
navigator.getUserMedia ||
|
||||
navigator.webkitGetUserMedia ||
|
||||
navigator.mozGetUserMedia ||
|
||||
navigator.oGetUserMedia ||
|
||||
navigator.msieGetUserMedia ||
|
||||
false
|
||||
);
|
||||
return !!fGetUserMedia;
|
||||
};
|
||||
|
||||
self.dataUriToBlob = function(dataURI) {
|
||||
// serialize the base64/URLEncoded data
|
||||
var byteString;
|
||||
if (dataURI.split(',')[0].indexOf('base64') >= 0) {
|
||||
byteString = atob(dataURI.split(',')[1]);
|
||||
}
|
||||
else {
|
||||
byteString = unescape(dataURI.split(',')[1]);
|
||||
}
|
||||
|
||||
// parse the mime type
|
||||
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
||||
|
||||
// construct a Blob of the image data
|
||||
var array = [];
|
||||
for (var i = 0; i < byteString.length; i++) {
|
||||
array.push(byteString.charCodeAt(i));
|
||||
}
|
||||
return new Blob(
|
||||
[new Uint8Array(array)],
|
||||
{type: mimeString}
|
||||
);
|
||||
};
|
||||
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ $(function() {
|
|||
|
||||
self.currentHeight = ko.observable(undefined);
|
||||
self.currentPos = ko.observable(undefined);
|
||||
self.intensityOverride = ko.observable(100);
|
||||
self.feedrateOverride = ko.observable(100);
|
||||
self.intensityOverride.extend({ rateLimit: 500 });
|
||||
self.feedrateOverride.extend({ rateLimit: 500 });
|
||||
|
||||
self.TITLE_PRINT_BUTTON_PAUSED = gettext("Restarts the print job from the beginning");
|
||||
self.TITLE_PRINT_BUTTON_UNPAUSED = gettext("Starts the print job");
|
||||
|
|
@ -281,6 +285,62 @@ $(function() {
|
|||
self.onEventRealTimeState = function(payload){
|
||||
self.currentPos({x: payload.wx, y: payload.wy});
|
||||
};
|
||||
|
||||
self.intensityOverride.subscribe(function(factor){
|
||||
self._overrideCommand("/intensity "+factor);
|
||||
});
|
||||
self.feedrateOverride.subscribe(function(factor){
|
||||
self._overrideCommand("/feedrate "+factor);
|
||||
});
|
||||
|
||||
self._overrideCommand = function(command, callback) {
|
||||
$.ajax({
|
||||
url: API_BASEURL + "printer/command",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({command: command}),
|
||||
success: function(response) {
|
||||
if (callback != undefined) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self._configureOverrideSliders = function() {
|
||||
self.intensityOverrideSlider = $("#intensity_override_slider").slider({
|
||||
step: 1,
|
||||
min: 10,
|
||||
max: 200,
|
||||
value: 100,
|
||||
// tooltip: 'hide'
|
||||
}).on("slideStop", function(ev){
|
||||
self.intensityOverride(ev.value);
|
||||
});
|
||||
|
||||
self.feedrateOverrideSlider = $("#feedrate_override_slider").slider({
|
||||
step: 1,
|
||||
min: 10,
|
||||
max: 200,
|
||||
value: 100,
|
||||
// tooltip: 'hide'
|
||||
}).on("slideStop", function(ev){
|
||||
self.feedrateOverride(ev.value);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
self.onEventPrintDone = function(){
|
||||
self.feedrateOverrideSlider.slider('setValue', 100);
|
||||
self.intensityOverrideSlider.slider('setValue', 100);
|
||||
self.intensityOverride(100);
|
||||
self.feedrateOverride(100);
|
||||
};
|
||||
|
||||
self.onStartup = function() {
|
||||
self._configureOverrideSliders();
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push([
|
||||
|
|
|
|||
12
src/octoprint/templates/dialogs/take_photo.jinja2
Normal file
12
src/octoprint/templates/dialogs/take_photo.jinja2
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<div id="take_photo_dialog" class="modal hide fade" >
|
||||
<div class="modal-header">
|
||||
<a href="#" class="close" data-dismiss="modal" aria-hidden="true">×</a>
|
||||
<h3>{{ _('Please smile') }}</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="photo_preview"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Cancel') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -15,27 +15,6 @@
|
|||
{% include 'initscript.jinja2' %}
|
||||
</head>
|
||||
<body>
|
||||
<!--<<<<<<< HEAD
|
||||
<div id="navbar" class="navbar navbar-static-top">
|
||||
<div class="navbar-inner" data-bind="css: appearance.color">
|
||||
<div class="container">
|
||||
<a class="brand" href="#"> <span xdata-bind="text: appearance.brand"></span></a>
|
||||
<div class="nav-collapse">
|
||||
Navbar
|
||||
<ul class="nav pull-right">
|
||||
{% for data in navbarEntries %}
|
||||
{% if "custom_bindings" not in data or data["custom_bindings"] %} ko allowBindings: false {% endif %}
|
||||
<li id="{{ data._div }}"
|
||||
{% if "data_bind" in data %}data-bind="{{ data.data_bind }}"{% endif %}
|
||||
{% if "classes" in data %}class="{{ data.classes|join(' ') }}"{% endif %}
|
||||
{% if "styles" in data %}style="{{ data.styles|join(', ') }}"{% endif %}
|
||||
>
|
||||
{% include data.template ignore missing %}
|
||||
</li>
|
||||
{% if "custom_bindings" not in data or data["custom_bindings"] %} /ko {% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
=======-->
|
||||
<div class="page-container">
|
||||
<div id="navbar" class="navbar navbar-static-top">
|
||||
<div class="navbar-inner" data-bind="css: appearanceClasses">
|
||||
|
|
@ -143,21 +122,6 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!--<<<<<<< HEAD
|
||||
<div class="footer">
|
||||
<ul class="pull-left muted">
|
||||
<li><small>{{ _('Version') }}: <span class="version">{{ display_version }}</span></small></li>
|
||||
</ul>
|
||||
<ul class="pull-right">
|
||||
<li><a href="http://www.mr-beam.org"><i class="icon-home"></i> {{ _('Homepage') }}</a></li>
|
||||
<li><a href="https://github.com/mrbeam/OctoPrint/"><i class="icon-download"></i> {{ _('Sourcecode') }}</a></li>
|
||||
<li><a href="https://wiki.mr-beam.org"><i class="icon-book"></i> {{ _('Documentation') }}</a></li>
|
||||
<li><a href="https://github.com/mrbeam/OctoPrint/issues"><i class="icon-flag"></i> {{ _('Bugs and Requests') }}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
=======
|
||||
>>>>>>> upstream/maintenance-->
|
||||
|
||||
<!-- Dialogs -->
|
||||
{% include 'dialogs/confirmation.jinja2' %}
|
||||
|
|
|
|||
|
|
@ -155,8 +155,20 @@
|
|||
{{ _('Timelapse') }}: <strong data-bind="text: timelapseString"></strong><br>
|
||||
-->
|
||||
{{ _('Approx. Total Job Time') }}: <strong data-bind="text: estimatedPrintTimeString"></strong><br>
|
||||
<div class="progress" data-bind="visible: isPrinting() || isPaused()">
|
||||
<div class="bar" id="job_progressBar" data-bind="style: { width: progressString() + '%' }"> {{ _('Processed') }} : <strong data-bind="text: byteString"></strong></div>
|
||||
<div data-bind="visible: isPrinting() || isPaused()">
|
||||
|
||||
<div class="progress">
|
||||
<div class="bar" id="job_progressBar" data-bind="style: { width: progressString() + '%' }"> {{ _('Processed') }} : <strong data-bind="text: byteString"></strong></div>
|
||||
</div>
|
||||
<div class="overrideSlider">
|
||||
<input id="intensity_override_slider" type="text" data-bind="sliderValue: intensityOverride">
|
||||
<span data-bind="text:intensityOverride()">100</span>% Intensity
|
||||
</div>
|
||||
<div class="overrideSlider">
|
||||
<input id="feedrate_override_slider" type="text" data-bind="sliderValue: feedrateOverride">
|
||||
<span data-bind="text:feedrateOverride()">100</span>% Feedrate
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- {{ _('Print Time') }}: <strong data-bind="text: printTimeString"></strong><br>
|
||||
{{ _('Print Time Left') }}: <strong data-bind="text: printTimeLeftString"></strong><br>-->
|
||||
|
|
@ -288,13 +300,11 @@
|
|||
</feComponentTransfer>
|
||||
</filter>
|
||||
<g id="scaleGroup" data-bind="attr: { transform: scaleMatrix() }">
|
||||
<rect data-bind="click: move_laser"
|
||||
id="coordGrid" x="0" y="0" width="0" height="0"
|
||||
stroke="none" fill="none"></rect>
|
||||
|
||||
<text
|
||||
xml:space="preserve"
|
||||
data-bind="visible: working_area_empty"
|
||||
style="font-size:64px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#DDDDDD;fill-opacity:1;stroke:none;font-family:DIN-BoldAlternate;-inkscape-font-specification:DIN-BoldAlternate Bold"
|
||||
style="font-size:64px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#DDDDDD;fill-opacity:1;stroke:none;font-family:DIN-BoldAlternate, Helvetica, Arial, Sans-serif;"
|
||||
x="396.81018"
|
||||
y="552.36218"
|
||||
id="add_designs_hint"
|
||||
|
|
@ -311,9 +321,12 @@
|
|||
<tspan
|
||||
x="368.571426" y="712.36218" id="tspan2991"
|
||||
style="text-anchor:middle;text-align:center" /></text>
|
||||
<g id="userContent" data-bind="visible: !state.isPrinting() && !state.isPaused()"></g>
|
||||
<g id="placedGcodes" data-bind="visible: !state.isPrinting() && !state.isPaused(), attr: { transform: scaleMatrixMMtoDisplay() }"></g>
|
||||
<g id="gCodePreview" data-bind="visible: state.isPrinting() || state.isPaused(), attr: { transform: scaleMatrixMMtoDisplay() }"></g>
|
||||
<rect data-bind="click: move_laser"
|
||||
id="coordGrid" x="0" y="0" width="0" height="0"
|
||||
stroke="none" fill="none"></rect>
|
||||
<g id="userContent" data-bind="visible: !state.isPrinting() && !state.isPaused()"></g>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
|
@ -494,11 +507,16 @@
|
|||
<div style="display: none;" data-bind="visible: loginState.isUser">
|
||||
<div class="row-fluid upload-buttons">
|
||||
|
||||
<span class="btn btn-primary fileinput-button span12" data-bind="css: {disabled: !$root.loginState.isUser()}" style="margin-bottom: 10px">
|
||||
<span class="btn btn-primary fileinput-button " data-bind="css: {disabled: !$root.loginState.isUser(), span12: !hasCamera(), span8: hasCamera()}" style="margin-bottom: 10px">
|
||||
<i class="icon-upload-alt icon-white"></i>
|
||||
<span>{{ _('Upload') }}</span>
|
||||
<input id="gcode_upload" type="file" name="file" class="fileinput-button" data-bind="enable: loginState.isUser()">
|
||||
</span>
|
||||
<a class="btn btn-primary span4" href="#" role="button" data-bind="visible:hasCamera(), css: {disabled: !$root.loginState.isUser()}, click: takePhoto" >
|
||||
<i class="icon-camera icon-white"></i>
|
||||
<span>{{ _('Photo') }}</span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
<div id="gcode_upload_progress" class="progress" style="width: 100%;">
|
||||
<div class="bar" style="width: 0%"></div>
|
||||
|
|
@ -715,6 +733,7 @@
|
|||
{#% include 'dialogs/settings.jinja2' %#}
|
||||
{% include 'dialogs/slicing.jinja2' %}
|
||||
{% include 'dialogs/usersettings.jinja2' %}
|
||||
{% include 'dialogs/take_photo.jinja2' %}
|
||||
<!-- End of dialogs -->
|
||||
|
||||
<!-- Overlays -->
|
||||
|
|
|
|||
|
|
@ -1888,22 +1888,34 @@ class MachineCom(object):
|
|||
self._doSendWithoutChecksum(commandToSend)
|
||||
|
||||
def _doSendWithoutChecksum(self, cmd):
|
||||
self._log("Send: %s" % cmd)
|
||||
self.acc_line_lengths.append(len(cmd)+1) # Track number of characters in grbl serial read buffer
|
||||
try:
|
||||
self._serial.write(cmd + '\n')
|
||||
except serial.SerialTimeoutException:
|
||||
self._log("Serial timeout while writing to serial port, trying again.")
|
||||
if cmd == "?":
|
||||
try:
|
||||
self._serial.write(cmd)
|
||||
except serial.SerialTimeoutException:
|
||||
self._log("Serial timeout while writing to serial port, trying again.")
|
||||
try:
|
||||
self._serial.write(cmd)
|
||||
except:
|
||||
self._log("Unexpected error while writing serial port: %s" % (get_exception_string()))
|
||||
self._errorValue = get_exception_string()
|
||||
self.close(True)
|
||||
else:
|
||||
self._log("Send: %s" % cmd)
|
||||
self.acc_line_lengths.append(len(cmd)+1) # Track number of characters in grbl serial read buffer
|
||||
try:
|
||||
self._serial.write(cmd + '\n')
|
||||
except serial.SerialTimeoutException:
|
||||
self._log("Serial timeout while writing to serial port, trying again.")
|
||||
try:
|
||||
self._serial.write(cmd + '\n')
|
||||
except:
|
||||
self._log("Unexpected error while writing serial port: %s" % (get_exception_string()))
|
||||
self._errorValue = get_exception_string()
|
||||
self.close(True)
|
||||
except:
|
||||
self._log("Unexpected error while writing serial port: %s" % (get_exception_string()))
|
||||
self._errorValue = get_exception_string()
|
||||
self.close(True)
|
||||
except:
|
||||
self._log("Unexpected error while writing serial port: %s" % (get_exception_string()))
|
||||
self._errorValue = get_exception_string()
|
||||
self.close(True)
|
||||
|
||||
##~~ command handlers
|
||||
def _gcode_H_sent(self, cmd, cmd_type=None):
|
||||
|
|
|
|||
1265
src/octoprint/util/comm_acc2.py
Normal file
1265
src/octoprint/util/comm_acc2.py
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue