0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-22 01:07:56 +01:00

Add checkbox for new setting 'printer.bottomEnableTraveling'.

Implement bottom layer traveling in GCode generation as well as sketch rendering.
This commit is contained in:
Wouter R 2016-01-06 19:26:07 +01:00
parent 46bcd54a1a
commit d48944e448
6 changed files with 64 additions and 46 deletions

View File

@ -25,7 +25,7 @@ function shapeMoveTo(x,y) {
_points.push([x, y, true]); _points.push([x, y, true]);
adjustBounds(x, y); adjustBounds(x, y);
adjustPreviewTransformation(); adjustPreviewTransformation();
draw(x, y, .5); draw(x, y, -1);
} }
function shapeLineTo(x,y) { function shapeLineTo(x,y) {

View File

@ -116,7 +116,7 @@ function loadFromSvg(svgData) {
adjustBounds(x, y); adjustBounds(x, y);
adjustPreviewTransformation(); adjustPreviewTransformation();
if (isMove) draw(x, y, .5); if (isMove) draw(x, y, -1);
else draw(x, y); else draw(x, y);
} }
p++; p++;

View File

@ -97,6 +97,9 @@ function initDoodleDrawing() {
* CANVAS DRAWING FUNCTION * CANVAS DRAWING FUNCTION
* *
* * * * * * * * * */ * * * * * * * * * */
//If _width is not specified, it is calculated from the distance between this and the previous point.
//If _width is negative, the path is 'floating', and only drawn if the setting printer.bottomEnableTraveling is true.
function draw(_x, _y, _width) { function draw(_x, _y, _width) {
//console.log("canvasDrawing:draw"); //console.log("canvasDrawing:draw");
//console.log("f:draw() >> _width: " + _width); //console.log("f:draw() >> _width: " + _width);
@ -108,6 +111,16 @@ function draw(_x, _y, _width) {
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(prevX, prevY); ctx.moveTo(prevX, prevY);
if (_width != undefined && _width < 0) {
if (settings['printer.bottomEnableTraveling']) {
ctx.moveTo(_x, _y);
} else {
ctx.lineTo(_x, _y);
ctx.lineWidth = 0.5;
ctx.stroke();
}
} else {
ctx.lineTo(_x, _y); ctx.lineTo(_x, _y);
if (_width != undefined) { if (_width != undefined) {
@ -142,7 +155,9 @@ function draw(_x, _y, _width) {
ctx.lineWidth = lineweight; ctx.lineWidth = lineweight;
} }
ctx.lineCap = 'round'; ctx.lineCap = 'round';
ctx.stroke(); ctx.stroke();
}
prevX = _x; prevX = _x;
prevY = _y; prevY = _y;
@ -202,7 +217,7 @@ function redrawDoodle(recalcBoundsAndTransforms) {
for (var i = 0; i < _points.length; i++) { for (var i = 0; i < _points.length; i++) {
// console.log(" drawing points " + _points[i]); // console.log(" drawing points " + _points[i]);
if (_points[i][2] == true) { if (_points[i][2] == true) {
draw(_points[i][0], _points[i][1], 0.5); draw(_points[i][0], _points[i][1], -1);
} else { } else {
draw(_points[i][0], _points[i][1]); draw(_points[i][0], _points[i][1]);
} }
@ -301,7 +316,7 @@ function onCanvasMouseDown(e) {
_points.push([x, y, true]); _points.push([x, y, true]);
adjustBounds(x, y); adjustBounds(x, y);
adjustPreviewTransformation(); adjustPreviewTransformation();
draw(x, y, 0.5); draw(x, y, -1);
} }
var prevPoint = {x:-1, y:-1}; var prevPoint = {x:-1, y:-1};
@ -401,7 +416,7 @@ function onCanvasTouchDown(e) {
_points.push([x, y, true]); _points.push([x, y, true]);
adjustBounds(x, y); adjustBounds(x, y);
adjustPreviewTransformation(); adjustPreviewTransformation();
draw(x, y, .5); draw(x, y, -1);
movementCounter = 0; movementCounter = 0;
@ -489,8 +504,3 @@ function onCanvasTouchEnd(e) {
function prevent(e) { function prevent(e) {
e.preventDefault(); e.preventDefault();
} }

View File

@ -20,6 +20,7 @@ function generate_gcode() {
var bottomSpeed = settings["printer.bottomLayerSpeed"]; var bottomSpeed = settings["printer.bottomLayerSpeed"];
var firstLayerSlow = settings["printer.firstLayerSlow"]; var firstLayerSlow = settings["printer.firstLayerSlow"];
var bottomFlowRate = settings["printer.bottomFlowRate"]; var bottomFlowRate = settings["printer.bottomFlowRate"];
var bottomEnableTraveling = settings["printer.bottomEnableTraveling"];
var travelSpeed = settings["printer.travelSpeed"] var travelSpeed = settings["printer.travelSpeed"]
var filamentThickness = settings["printer.filamentThickness"]; var filamentThickness = settings["printer.filamentThickness"];
var wallThickness = settings["printer.wallThickness"]; var wallThickness = settings["printer.wallThickness"];
@ -159,8 +160,10 @@ function generate_gcode() {
var isTraveling = !isLoop && i==0; var isTraveling = !isLoop && i==0;
var doRetract = retractionEnabled && prev.distance(to) > retractionminDistance; var doRetract = retractionEnabled && prev.distance(to) > retractionminDistance;
//Always travel to first point, then optionally disable traveling for first two layers and use settings for remainder of print.
var firstPointEver = (layer == 0 && i == 0 && j == 0); var firstPointEver = (layer == 0 && i == 0 && j == 0);
if (firstPointEver || layer > 2 && enableTraveling && isTraveling) { //always travel to first point, then disable traveling for first two layers and use settings for remainder of print var travelingAllowed = firstPointEver || bottomEnableTraveling || layer > 2;
if (travelingAllowed && enableTraveling && isTraveling) {
if (!firstPointEver && doRetract) gcode.push("G0 E" + (extruder - retractionamount).toFixed(3) + " F" + (retractionspeed * 60).toFixed(3)); //retract if (!firstPointEver && doRetract) gcode.push("G0 E" + (extruder - retractionamount).toFixed(3) + " F" + (retractionspeed * 60).toFixed(3)); //retract
gcode.push("G0 X" + to.x.toFixed(3) + " Y" + to.y.toFixed(3) + " Z" + z.toFixed(3) + " F" + (travelSpeed * 60).toFixed(3)); gcode.push("G0 X" + to.x.toFixed(3) + " Y" + to.y.toFixed(3) + " Z" + z.toFixed(3) + " F" + (travelSpeed * 60).toFixed(3));
if (!firstPointEver && doRetract) gcode.push("G0 E" + extruder.toFixed(3) + " F" + (retractionspeed * 60).toFixed(3)); // return to normal if (!firstPointEver && doRetract) gcode.push("G0 E" + extruder.toFixed(3) + " F" + (retractionspeed * 60).toFixed(3)); // return to normal

View File

@ -116,6 +116,10 @@ function SettingsWindow() {
settingsPopup.close(); settingsPopup.close();
self.signin(); self.signin();
} }
//FIXME: instead of this rather ugly call, implement events for changes to settings so we can keep code decoupled
redrawDoodle(false);
_btnOK.removeAttr("disabled"); _btnOK.removeAttr("disabled");
}); });
}; };

View File

@ -99,6 +99,7 @@
<label for="bottomLayerSpeed">Bottom layer speed:</label><input id="bottomLayerSpeed" type="number" name="printer.bottomLayerSpeed" class="small">mm/s<br> <label for="bottomLayerSpeed">Bottom layer speed:</label><input id="bottomLayerSpeed" type="number" name="printer.bottomLayerSpeed" class="small">mm/s<br>
<label for="travelSpeed">Travel speed:</label><input id="travelSpeed" type="number" name="printer.travelSpeed" class="small">mm/s<br> <label for="travelSpeed">Travel speed:</label><input id="travelSpeed" type="number" name="printer.travelSpeed" class="small">mm/s<br>
<label for="enableTraveling">Enable traveling:</label><input id="enableTraveling" type="checkbox" name="printer.enableTraveling" value="enableTraveling"><br> <label for="enableTraveling">Enable traveling:</label><input id="enableTraveling" type="checkbox" name="printer.enableTraveling" value="enableTraveling"><br>
<label for="bottomEnableTraveling">Bottom layers traveling:</label><input id="bottomEnableTraveling" type="checkbox" name="printer.bottomEnableTraveling" value="bottomEnableTraveling"><br>
<label for="firstLayerSlow">Bottom layers slow:</label><input id="firstLayerSlow" type="checkbox" name="printer.firstLayerSlow" value="firstLayerSlow"><br> <label for="firstLayerSlow">Bottom layers slow:</label><input id="firstLayerSlow" type="checkbox" name="printer.firstLayerSlow" value="firstLayerSlow"><br>
<label for="bottomFlowRate">Bottom layers flow rate*:</label><input id="bottomFlowRate" type="number" name="printer.bottomFlowRate" class="small"><br> <label for="bottomFlowRate">Bottom layers flow rate*:</label><input id="bottomFlowRate" type="number" name="printer.bottomFlowRate" class="small"><br>
<small>* Multiplier for extrusion rate in first few layers</small> <small>* Multiplier for extrusion rate in first few layers</small>