Compare commits

..

2 commits

Author SHA1 Message Date
make-ing
0dcaeb81d6 fixed problem with same id instead of previewId 2016-06-23 14:41:17 +02:00
make-ing
74e77f7492 added functionality to add multiple SVG's and IMG's. 2016-06-16 12:04:58 +02:00
13 changed files with 8245 additions and 1996 deletions

View file

@ -1,6 +1,5 @@
OctoPrint
=========
What I did was take the MrBeam fork of Octoprint (because I have a MrBeam, and I like it) - and modify it for pen plotting with an axidraw v3 clone.
[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=foosel&url=https://github.com/foosel/OctoPrint&title=OctoPrint&language=&tags=github&category=software)

File diff suppressed because it is too large Load diff

View file

@ -97,7 +97,7 @@ def update_source(git_executable, folder, target, force=False):
raise RuntimeError("Could not update, \"git reset --hard\" failed with returncode %d: %s" % (returncode, stdout))
print(">>> Running: git pull")
returncode, stdout = _git(["pull", "origin", "stable-1.2.2"], folder, git_executable=git_executable)
returncode, stdout = _git(["pull"], folder, git_executable=git_executable)
if returncode != 0:
raise RuntimeError("Could not update, \"git pull\" failed with returncode %d: %s" % (returncode, stdout))
print(stdout)

View file

@ -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_int(["svgDPI"], data["svgDPI"])
s.set(["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
@ -357,8 +357,6 @@ 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)

View file

@ -41,10 +41,8 @@ $(function(){
// 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.text_placed()
|| (self.fill_areas() && self.show_vector_parameters()));
return self.images_placed() || (self.fill_areas() && self.show_vector_parameters());
});
self.imgIntensityWhite = ko.observable(0);
self.imgIntensityBlack = ko.observable(500);
@ -87,7 +85,6 @@ $(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()){

View file

@ -30,15 +30,14 @@ Snap.plugin(function (Snap, Element, Paper, global) {
*/
Element.prototype.bake = function (toCubics, dec) {
var elem = this;
if (!elem || !elem.paper || elem.type !== "text" || elem.type !== "#text" || elem.type !== "tspan"){
if (!elem || !elem.paper) // don't handle unplaced elements. this causes double handling.
return;
} // don't handle unplaced elements. this causes double handling.
if (typeof (toCubics) === 'undefined')
toCubics = false;
if (typeof (dec) === 'undefined')
dec = 5;
//var children = elem.selectAll('*')
var children = elem.children();
if (children.length > 0) {
for (var i = 0; i < children.length; i++) {
@ -55,15 +54,14 @@ Snap.plugin(function (Snap, Element, Paper, global) {
elem.type !== "polygon" &&
elem.type !== "polyline" &&
elem.type !== "image" &&
elem.type !== "path" &&
elem.type !== "text" &&
elem.type !== "tspan" &&
elem.type !== "#text"){
elem.type !== "path"){
// if(elem.type !== 'g' && elem.type !== 'desc' && elem.type !== 'defs')
// console.log('skipping unsupported element ', elem.type);
return;
}
if (elem.type == 'image' || elem.type == "text" || elem.type == "#text"){
if (elem.type == 'image'){
// TODO ...
var x = parseFloat(elem.attr('x')),
y = parseFloat(elem.attr('y')),
@ -91,6 +89,7 @@ Snap.plugin(function (Snap, Element, Paper, global) {
return;
}
//if(elem.type !== 'path') console.log("bake: converting " + elem.type + " to path");
var path_elem = elem.convertToPath();
if (!path_elem || path_elem.attr('d') === '' || path_elem.attr('d') === null)
@ -439,19 +438,6 @@ Snap.plugin(function (Snap, Element, Paper, global) {
// Possibly the cubed root of 6, but 1.81 works best
var num = 1.81;
var tag = old_element.type;
var convertMMtoPixel = function (val) {
attrList = ['rx','ry','r','cx','cy','x1','x2','y1','y2','x','y','width','height'];
for(var attrIdx in attrList) {
if(val.attr(attrList[attrIdx]) != null && val.attr(attrList[attrIdx]).indexOf('mm') > -1) {
var tmp = parseFloat(val.attr(attrList[attrIdx])) * 3.5433;
val.attr(attrList[attrIdx], tmp);
}
}
}
convertMMtoPixel(old_element);
switch (tag) {
case 'ellipse':
case 'circle':

View file

@ -50,7 +50,7 @@ Snap.plugin(function (Snap, Element, Paper, global) {
}
}
} else {
if(elem.type === 'image' || elem.type === "text" || elem.type === "#text"){
if(elem.type === 'image'){
selection.push(elem);
} else {
if(fillPaths && elem.is_filled()){
@ -74,10 +74,7 @@ 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" ){
return false;
}
@ -124,7 +121,7 @@ Snap.plugin(function (Snap, Element, Paper, global) {
// get svg as dataUrl
var svgStr = elem.outerSVG();
var svgDataUri = 'data:image/svg+xml;base64,' + window.btoa(unescape(encodeURIComponent(svgStr))); //deprecated unescape needed!
var svgDataUri = 'data:image/svg+xml;base64,' + window.btoa(svgStr);
var source = new Image();
source.src = svgDataUri;

View file

@ -107,7 +107,6 @@ $(function(){
self.clear = function(){
snap.selectAll('#userContent>*').remove();
snap.selectAll('#placedGcodes>*').remove();
snap.selectAll('rect:not(#coordGrid)').remove();
self.placedDesigns([]);
};
@ -133,15 +132,9 @@ $(function(){
};
self.getXYCoord = function(evt){
if(/firefox/.test(navigator.userAgent.toLowerCase())) {
var scale = evt.target.parentElement.transform.baseVal[0].matrix.a;
var x = self.px2mm(evt.offsetX) * scale;
var y = self.px2mm(parseFloat(evt.target.attributes.height.value) - evt.offsetY) * scale;
} else
{
var x = self.px2mm(evt.offsetX);
var y = self.px2mm(parseFloat(evt.target.farthestViewportElement.clientHeight) - evt.offsetY);
}
x = Math.min(x, self.workingAreaWidthMM());
y = Math.min(y, self.workingAreaHeightMM());
return {x:x, y:y};
@ -243,11 +236,7 @@ $(function(){
var url = self._getSVGserveUrl(file);
callback = function (f) {
var newSvgAttrs = {};
if(f.select('svg') == null){
root_attrs = f.node.attributes;
} else {
var root_attrs = f.select('svg').node.attributes;
}
var doc_width = null;
var doc_height = null;
var doc_viewbox = null;
@ -256,13 +245,9 @@ $(function(){
var clipPathEl = f.selectAll('clipPath');
if(clipPathEl.length != 0){
console.warn("Warning: removed unsupported clipPath element in SVG");
self.svg_contains_clipPath_warning();
clipPathEl.remove()
}
// find all elements with "display=none" and remove them
f.selectAll("[display=none]").remove()
// iterate svg tag attributes
for(var i = 0; i < root_attrs.length; i++){
var attr = root_attrs[i];
@ -278,19 +263,9 @@ $(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: "Illustrator SVG detected! To preserve coorect scale, please go to the \'Settings\' menu and change the \'SVG dpi\' field under \'Plugins/Svg Conversion\' according to your file. And add it again.", type: "info", hide: false});
}
}
});
// scale matrix
var mat = self.getDocumentViewBoxMatrix(doc_width, doc_height, doc_viewbox);
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();
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>*"));
@ -309,12 +284,12 @@ $(function(){
newSvg.transformable();
newSvg.ftRegisterCallback(self.svgTransformUpdate);
file.id = id; // list entry id
file.previewId = previewId;
file.url = url;
file.misfit = "";
self.placedDesigns.push(file);
var fileCopy = $.extend(true,{},file);
fileCopy.id = id; // list entry id
fileCopy.previewId = previewId;
fileCopy.url = url;
fileCopy.misfit = "";
self.placedDesigns.push(fileCopy);
};
self.loadSVG(url, callback);
};
@ -327,15 +302,6 @@ $(function(){
self.abortFreeTransforms();
snap.selectAll('#'+file.previewId).remove();
self.placedDesigns.remove(file);
// TODO debug why remove always clears all items of this type.
// self.placedDesigns.remove(function(item){
// console.log("item", item.previewId );
// //return false;
// if(item.previewId === file.previewId){
// console.log("match", item.previewId );
// return true;
// } else return false;
// });
};
self.fitSVG = function(file){
self.abortFreeTransforms();
@ -370,10 +336,10 @@ $(function(){
var vertical = self.px2mm((bbox.y2 - bbox.y) * globalScale);
var id = svg.attr('id');
var label_id = id.substr(0, id.indexOf('-'));
$('#'+label_id+' .translation').text(tx.toFixed(1) + ',' + ty.toFixed(1));
$('#'+label_id+' .horizontal').text(horizontal.toFixed() + 'mm');
$('#'+label_id+' .vertical').text(vertical.toFixed() + 'mm');
$('#'+label_id+' .rotation').text(rot.toFixed(1) + '°');
$('#'+id+' .translation').text(tx.toFixed(1) + ',' + ty.toFixed(1));
$('#'+id+' .horizontal').text(horizontal.toFixed() + 'mm');
$('#'+id+' .vertical').text(vertical.toFixed() + 'mm');
$('#'+id+' .rotation').text(rot.toFixed(1) + '°');
};
@ -416,20 +382,8 @@ $(function(){
};
};
self.svg_contains_clipPath_warning = function(){
var error = "<p>" + gettext("The SVG file contains clipPath elements.<br/>clipPath is not supported yet and has been removed from file.") + "</p>";
//error += pnotifyAdditionalInfo("<pre>" + data.jqXHR.responseText + "</pre>");
new PNotify({
title: "clipPath elements removed",
text: error,
type: "warn",
hide: false
});
};
self.svg_contains_text_warning = function(svg){
var error = "<p>" + gettext("The SVG file contains text elements.<br/>If you want to laser just their outlines,<br/>please convert them to paths.<br/>Otherwise they will be engraved with infill.") + "</p>";
var error = "<p>" + gettext("The svg file contains text elements.<br/>Please convert them to paths.<br/>Otherwise they will be ignored.") + "</p>";
//error += pnotifyAdditionalInfo("<pre>" + data.jqXHR.responseText + "</pre>");
new PNotify({
title: "Text elements found",
@ -437,6 +391,7 @@ $(function(){
type: "warn",
hide: false
});
svg.selectAll('text,tspan').remove();
};
self.svg_misfitting_warning = function(svg, misfitting){
@ -474,11 +429,13 @@ $(function(){
newImg.transformable();
//newImg.ftDisableRotate();
newImg.ftRegisterCallback(self.svgTransformUpdate);
file.id = id;
file.previewId = previewId;
file.url = url;
file.subtype = "bitmap";
self.placedDesigns.push(file);
var fileCopy = $.extend(true,{},file);
fileCopy.id = id;
fileCopy.previewId = previewId;
fileCopy.url = url;
fileCopy.subtype = "bitmap";
self.placedDesigns.push(fileCopy);
};
img.src = url;
};
@ -742,16 +699,6 @@ $(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) {
@ -874,7 +821,7 @@ $(function(){
for (var i = 0; i < fillings.length; i++) {
var item = fillings[i];
if (item.type === 'image' || item.type === "text" || item.type === "#text") {
if (item.type === 'image') {
// remove filter effects on images for proper rendering
var style = item.attr('style');
if (style !== null) {

View file

@ -331,7 +331,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
def position(self, x, y):
printer_profile = self._printerProfileManager.get_current_or_default()
movement_speed = min(printer_profile["axes"]["x"]["speed"], printer_profile["axes"]["y"]["speed"])
self.commands(["G90", "G0 X%.3f Y%.3f F%d" % (x, y, movement_speed)])
self.commands(["G90", "G0 X%.3f Y%.3f F%d" % (x, y, movement_speed), "?"])
def _convert_rate_value(self, factor, min=0, max=200):
if not isinstance(factor, (int, float, long)):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title data-bind="text: title">Mr Draw</title>
<title data-bind="text: title">Mr Beam</title>
<link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}">
<link rel="apple-touch-icon" sizes="114x114" href="{{ url_for('static', filename='img/apple-touch-icon-114x114.png') }}">
@ -16,7 +16,7 @@
<div class="container">
<div class="navbar-header brand" style="min-width: 272px;">
<a class="navbar-brand" href="#">
<img alt="Mr Draw Logo" src="{{ url_for('static', filename='img/mr-draw-red_x120.png') }}">
<img alt="Mr Beam Logo" src="{{ url_for('static', filename='img/mr-typo-red_x120.png') }}">
</a>
</div>
<!-- Navbar -->
@ -58,7 +58,7 @@
<div id="control" class="accordion-inner" data-bind="visible: isReady() || isLocked() || isFlashing()">
<div data-bind="visible: isLocked ">
Mr Draw is in a locked state as it does not know its position.
Mr Beam is in a locked state as it does not know its position.
First remove any objects blocking the gantry's travel range.
Then do a homing cycle.
<div style='text-align: center; padding:.5em;'>
@ -221,7 +221,7 @@
<div class="accordion-body collapse in overflow_visible" id="wa_filelist">
<div class="accordion-inner">
<div class="gcode_files" data-bind="slimScrolledForeach: placedDesigns">
<div class="entry" data-bind="attr: { id: $data.id }, template: { name: $root.templateFor($data), data: $data }"></div>
<div class="entry" data-bind="attr: { id: $data.previewId }, template: { name: $root.templateFor($data), data: $data }"></div>
</div>
<script type="text/html" id="wa_template_machinecode">
@ -601,7 +601,7 @@
<div class="btn-group action-buttons">
<!-- <a class="btn btn-mini" data-bind="attr: {href: $root.downloadLink($data), css: {disabled: !$root.downloadLink($data)}}"><i class="icon-download-alt" title="{{ _('Download') }}"></i></a>
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableRemove($data)) { $root.removeFile($data); } else { return; } }, css: {disabled: !$root.enableRemove($data)}"><i class="icon-trash" title="{{ _('Remove') }}"></i></div>-->
<div class="btn" data-bind="click: function() { if(!$root.workingArea.isPlaced($data)){ $root.workingArea.placeSVG($data); } }, css: {disabled: $root.workingArea.isPlaced($data)}"><i class="icon-ok" title="{{ _('Use') }}">Add</i></div>
<div class="btn" data-bind="click: function() { $root.workingArea.placeSVG($data); }"><i class="icon-ok" title="{{ _('Use') }}">Add</i></div>
</div>
</div>
</script>
@ -628,7 +628,7 @@
<div class="btn-group action-buttons">
<!-- <a class="btn btn-mini" data-bind="attr: {href: $root.downloadLink($data), css: {disabled: !$root.downloadLink($data)}}"><i class="icon-download-alt" title="{{ _('Download') }}"></i></a>
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableRemove($data)) { $root.removeFile($data); } else { return; } }, css: {disabled: !$root.enableRemove($data)}"><i class="icon-trash" title="{{ _('Remove') }}"></i></div>-->
<div class="btn" data-bind="click: function() { if(!$root.workingArea.isPlaced($data)){ $root.workingArea.placeIMG($data); } }, css: {disabled: $root.workingArea.isPlaced($data)}"><i class="icon-ok" title="{{ _('Use') }}">Add</i></div>
<div class="btn" data-bind="click: function() { $root.workingArea.placeIMG($data);}"><i class="icon-ok" title="{{ _('Use') }}">Add</i></div>
</div>
</div>
</script>
@ -657,10 +657,12 @@
<div class="span4">
<ul class="focus_steps">
<li>1. Place your material on the working area</li>
<li>2. Move the pen over the material</li>
<li>&RightArrow; Now enable the pen calibration mode</li>
<li>5. Adjust the pen until it touches the paper</li>
<li>&RightArrow; Disable the pen calibration mode. </li>
<li>2. Move the laser over the material</li>
<li>3. Put on your safety glasses</li>
<li>4. Turn the laser safety switch to on</li>
<li>&RightArrow; Now enable the focus mode</li>
<li>5. Adjust the focus until the laser beam is as small as possible</li>
<li>&RightArrow; Disable the focus mode. </li>
</ul>
<div style="text-align:center">
<div class="btn-group" role="group" aria-label="focus mode control" style="">