mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 17:27:57 +01:00
Merge branch 'develop' of github.com:Doodle3D/doodle3d-client into develop
This commit is contained in:
commit
92a28f54b8
@ -124,7 +124,7 @@ function rotateShape(radians) {
|
|||||||
|
|
||||||
function updateView() {
|
function updateView() {
|
||||||
setSketchModified(true);
|
setSketchModified(true);
|
||||||
redrawDoodle();
|
redrawDoodle(true);
|
||||||
adjustPreviewTransformation();
|
adjustPreviewTransformation();
|
||||||
renderToImageDataPreview();
|
renderToImageDataPreview();
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ var isModified = false;
|
|||||||
*
|
*
|
||||||
* * * * * * * * * */
|
* * * * * * * * * */
|
||||||
function initDoodleDrawing() {
|
function initDoodleDrawing() {
|
||||||
console.log("f:initDoodleDrawing()");
|
//console.log("f:initDoodleDrawing()");
|
||||||
|
|
||||||
$canvas = $("#mycanvas");
|
$canvas = $("#mycanvas");
|
||||||
canvas = $canvas[0];
|
canvas = $canvas[0];
|
||||||
@ -79,7 +79,7 @@ function initDoodleDrawing() {
|
|||||||
// drawCanvas = $(".drawareacontainer");
|
// drawCanvas = $(".drawareacontainer");
|
||||||
drawCanvas = $("#mycanvasContainer"); // $("#drawAreaContainer")
|
drawCanvas = $("#mycanvasContainer"); // $("#drawAreaContainer")
|
||||||
|
|
||||||
console.log("drawCanvasTopLeftCoords: " + drawCanvasTopLeftCoords);
|
//console.log("drawCanvasTopLeftCoords: " + drawCanvasTopLeftCoords);
|
||||||
// drawCanvasTopLeftCoords[0] = drawCanvas.css("left").match(/[0-9]/g).join("");
|
// drawCanvasTopLeftCoords[0] = drawCanvas.css("left").match(/[0-9]/g).join("");
|
||||||
// drawCanvasTopLeftCoords[1] = drawCanvas.css("top").match(/[0-9]/g).join("");
|
// drawCanvasTopLeftCoords[1] = drawCanvas.css("top").match(/[0-9]/g).join("");
|
||||||
drawCanvasTopLeftCoords[0] = drawCanvas.offset().left;
|
drawCanvasTopLeftCoords[0] = drawCanvas.offset().left;
|
||||||
@ -87,8 +87,8 @@ function initDoodleDrawing() {
|
|||||||
// drawCanvasTopLeftCoords[0] = drawCanvas[0].offsetParent.offsetLeft;
|
// drawCanvasTopLeftCoords[0] = drawCanvas[0].offsetParent.offsetLeft;
|
||||||
// drawCanvasTopLeftCoords[1] = drawCanvas[0].offsetParent.offsetTop;
|
// drawCanvasTopLeftCoords[1] = drawCanvas[0].offsetParent.offsetTop;
|
||||||
|
|
||||||
console.log("f:initDoodleDrawing() >> canvasWidth: " + canvasWidth);
|
//console.log("f:initDoodleDrawing() >> canvasWidth: " + canvasWidth);
|
||||||
console.log("f:initDoodleDrawing() >> canvasHeight: " + canvasHeight);
|
//console.log("f:initDoodleDrawing() >> canvasHeight: " + canvasHeight);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +98,7 @@ function initDoodleDrawing() {
|
|||||||
*
|
*
|
||||||
* * * * * * * * * */
|
* * * * * * * * * */
|
||||||
function draw(_x, _y, _width) {
|
function draw(_x, _y, _width) {
|
||||||
|
//console.log("canvasDrawing:draw");
|
||||||
// console.log("f:draw() >> _width: " + _width);
|
// console.log("f:draw() >> _width: " + _width);
|
||||||
|
|
||||||
if (prevX == 0 && prevY ==0) {
|
if (prevX == 0 && prevY ==0) {
|
||||||
@ -154,7 +155,7 @@ function draw(_x, _y, _width) {
|
|||||||
*
|
*
|
||||||
* * * * * * * * * */
|
* * * * * * * * * */
|
||||||
function clearDoodle() {
|
function clearDoodle() {
|
||||||
console.log("f:clearDoodle");
|
//console.log("f:clearDoodle");
|
||||||
|
|
||||||
updatePrevNextButtonStateOnClear();
|
updatePrevNextButtonStateOnClear();
|
||||||
|
|
||||||
@ -179,6 +180,7 @@ function clearDoodle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function redrawDoodle(recalcBoundsAndTransforms) {
|
function redrawDoodle(recalcBoundsAndTransforms) {
|
||||||
|
//console.log("canvasDrawing:redrawDoodle");
|
||||||
if (recalcBoundsAndTransforms == undefined) recalcBoundsAndTransforms = false;
|
if (recalcBoundsAndTransforms == undefined) recalcBoundsAndTransforms = false;
|
||||||
// console.log("f:redrawDoodle() >> recalcBoundsAndTransforms = " + recalcBoundsAndTransforms);
|
// console.log("f:redrawDoodle() >> recalcBoundsAndTransforms = " + recalcBoundsAndTransforms);
|
||||||
|
|
||||||
@ -205,8 +207,9 @@ function redrawDoodle(recalcBoundsAndTransforms) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// checks if x,y is outside doodleBounds, if so update
|
||||||
function adjustBounds(x, y) {
|
function adjustBounds(x, y) {
|
||||||
|
//console.log("canvasDrawing:adjustBounds");
|
||||||
var newPointsOutsideOfCurrentBounds = false;
|
var newPointsOutsideOfCurrentBounds = false;
|
||||||
// console.log("f:adjustBounds("+x+","+y+")");
|
// console.log("f:adjustBounds("+x+","+y+")");
|
||||||
|
|
||||||
@ -242,7 +245,7 @@ function redrawDoodle(recalcBoundsAndTransforms) {
|
|||||||
|
|
||||||
// does what exactly?
|
// does what exactly?
|
||||||
function adjustPreviewTransformation() {
|
function adjustPreviewTransformation() {
|
||||||
// console.log("f:adjustPreviewTransformation()");
|
//console.log("canvasDrawing:adjustPreviewTransformation");
|
||||||
|
|
||||||
doodleTransform[0] = doodleBounds[0];
|
doodleTransform[0] = doodleBounds[0];
|
||||||
doodleTransform[1] = doodleBounds[1];
|
doodleTransform[1] = doodleBounds[1];
|
||||||
@ -272,6 +275,7 @@ function adjustPreviewTransformation() {
|
|||||||
*
|
*
|
||||||
* * * * * * * * * */
|
* * * * * * * * * */
|
||||||
function onCanvasMouseDown(e) {
|
function onCanvasMouseDown(e) {
|
||||||
|
//console.log("canvasDrawing:onCanvasMouseDown");
|
||||||
setSketchModified(true);
|
setSketchModified(true);
|
||||||
|
|
||||||
// console.log("f:onCanvasMouseDown()");
|
// console.log("f:onCanvasMouseDown()");
|
||||||
@ -301,7 +305,7 @@ function onCanvasMouseDown(e) {
|
|||||||
|
|
||||||
var prevPoint = {x:-1, y:-1};
|
var prevPoint = {x:-1, y:-1};
|
||||||
function onCanvasMouseMove(e) {
|
function onCanvasMouseMove(e) {
|
||||||
|
//console.log("canvasDrawing:onCanvasMouseMove");
|
||||||
// console.log("f:onCanvasMouseMove()");
|
// console.log("f:onCanvasMouseMove()");
|
||||||
if (!dragging) return;
|
if (!dragging) return;
|
||||||
|
|
||||||
@ -363,11 +367,11 @@ function onCanvasMouseUp(e) {
|
|||||||
// console.log("f:onCanvasMouseUp()");
|
// console.log("f:onCanvasMouseUp()");
|
||||||
// console.log("onmouseup");
|
// console.log("onmouseup");
|
||||||
dragging = false;
|
dragging = false;
|
||||||
console.log("doodleBounds: " + doodleBounds);
|
//console.log("doodleBounds: " + doodleBounds);
|
||||||
console.log("doodleTransform: " + doodleTransform);
|
//console.log("doodleTransform: " + doodleTransform);
|
||||||
// ctx.stroke();
|
// ctx.stroke();
|
||||||
|
|
||||||
console.log("_points.length :" + _points.length);
|
//console.log("_points.length :" + _points.length);
|
||||||
// console.log(_points);
|
// console.log(_points);
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
@ -383,7 +387,7 @@ function onCanvasTouchDown(e) {
|
|||||||
setSketchModified(true);
|
setSketchModified(true);
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("f:onCanvasTouchDown >> e: " , e);
|
//console.log("f:onCanvasTouchDown >> e: " , e);
|
||||||
// var x = e.touches[0].pageX - e.touches[0].target.offsetLeft;
|
// var x = e.touches[0].pageX - e.touches[0].target.offsetLeft;
|
||||||
// var y = e.touches[0].pageY - e.touches[0].target.offsetTop;
|
// var y = e.touches[0].pageY - e.touches[0].target.offsetTop;
|
||||||
var x = e.touches[0].pageX - drawCanvasTopLeftCoords[0];
|
var x = e.touches[0].pageX - drawCanvasTopLeftCoords[0];
|
||||||
@ -404,6 +408,7 @@ function onCanvasTouchDown(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasTouchMove(e) {
|
function onCanvasTouchMove(e) {
|
||||||
|
//console.log("canvasDrawing:onCanvasTouchMove");
|
||||||
setSketchModified(true);
|
setSketchModified(true);
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -469,12 +474,12 @@ function onCanvasTouchMove(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasTouchEnd(e) {
|
function onCanvasTouchEnd(e) {
|
||||||
console.log("f:onCanvasTouchEnd()");
|
//console.log("f:onCanvasTouchEnd()");
|
||||||
console.log("doodleBounds: " + doodleBounds);
|
//console.log("doodleBounds: " + doodleBounds);
|
||||||
console.log("doodleTransform: " + doodleTransform);
|
//console.log("doodleTransform: " + doodleTransform);
|
||||||
// ctx.stroke();
|
// ctx.stroke();
|
||||||
|
|
||||||
console.log("_points.length :" + _points.length);
|
//console.log("_points.length :" + _points.length);
|
||||||
|
|
||||||
// redrawPreview();
|
// redrawPreview();
|
||||||
renderToImageDataPreview();
|
renderToImageDataPreview();
|
||||||
|
@ -26,7 +26,7 @@ var prevRedrawTime = new Date().getTime();
|
|||||||
var redrawInterval = 1000 / 30; // ms
|
var redrawInterval = 1000 / 30; // ms
|
||||||
|
|
||||||
function initPreviewRendering() {
|
function initPreviewRendering() {
|
||||||
console.log("f:initPreviewRendering()");
|
//console.log("f:initPreviewRendering()");
|
||||||
|
|
||||||
$preview = $("#preview");
|
$preview = $("#preview");
|
||||||
preview = $preview[0];
|
preview = $preview[0];
|
||||||
@ -89,6 +89,7 @@ var highlight = true; //highlight bottom, middle and top layers
|
|||||||
var linesRaw = "";
|
var linesRaw = "";
|
||||||
var debug_redrawSimplification = 6;
|
var debug_redrawSimplification = 6;
|
||||||
function redrawPreview(redrawLess) {
|
function redrawPreview(redrawLess) {
|
||||||
|
//console.log("PreviewRendering:redrawPreview");
|
||||||
if (redrawLess == undefined) redrawLess = false;
|
if (redrawLess == undefined) redrawLess = false;
|
||||||
|
|
||||||
if (_points.length < 2) {
|
if (_points.length < 2) {
|
||||||
@ -168,6 +169,7 @@ function redrawPreview(redrawLess) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderToImageDataPreview() {
|
function renderToImageDataPreview() {
|
||||||
|
//console.log("PreviewRendering:renderToImageDataPreview");
|
||||||
if (_points.length < 2) return;
|
if (_points.length < 2) return;
|
||||||
|
|
||||||
//*
|
//*
|
||||||
@ -236,9 +238,10 @@ function renderToImageDataPreview() {
|
|||||||
previewCtx.globalAlpha = globalAlpha;
|
previewCtx.globalAlpha = globalAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
// called by the move up/down or twist left/right buttons
|
// called by the move up/down, twist left/right or new buttons
|
||||||
// it is assumed that the preview has been rendered to an Image object, which will be used to draw the preview with (much better performance)
|
// it is assumed that the preview has been rendered to an Image object, which will be used to draw the preview with (much better performance)
|
||||||
function redrawRenderedPreview(redrawLess) {
|
function redrawRenderedPreview(redrawLess) {
|
||||||
|
//console.log("PreviewRendering:redrawRenderedPreview");
|
||||||
if (redrawLess == undefined) redrawLess = false;
|
if (redrawLess == undefined) redrawLess = false;
|
||||||
// console.log("f:redrawRenderedPreview()");
|
// console.log("f:redrawRenderedPreview()");
|
||||||
|
|
||||||
@ -249,6 +252,9 @@ function redrawRenderedPreview(redrawLess) {
|
|||||||
var y = 0;
|
var y = 0;
|
||||||
var r = 0;
|
var r = 0;
|
||||||
|
|
||||||
|
// check if there is preview image data that we can use for the layers
|
||||||
|
if(!doodleImageCapture.src || doodleImageCapture.src == "") return;
|
||||||
|
|
||||||
for(var i = 0; i < numLayers; i++) {
|
for(var i = 0; i < numLayers; i++) {
|
||||||
|
|
||||||
var verticalScaleFactor = scaleFunction(i / maxNumLayers);
|
var verticalScaleFactor = scaleFunction(i / maxNumLayers);
|
||||||
@ -297,6 +303,7 @@ function centeredAndScaledDoodlePoint(p) {
|
|||||||
var updatePrevX = -1;
|
var updatePrevX = -1;
|
||||||
var updatePrevY = -1;
|
var updatePrevY = -1;
|
||||||
function updatePreview(_x, _y, redrawLess) {
|
function updatePreview(_x, _y, redrawLess) {
|
||||||
|
//console.log("PreviewRendering:updatePreview");
|
||||||
if (redrawLess == undefined) redrawLess = false;
|
if (redrawLess == undefined) redrawLess = false;
|
||||||
redrawLess = false;
|
redrawLess = false;
|
||||||
|
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Doodle3D project (http://doodle3d.com).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013, Doodle3D
|
|
||||||
* This software is licensed under the terms of the GNU GPL v2 or later.
|
|
||||||
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var keyboardShortcutsEnabled = true;
|
|
||||||
|
|
||||||
function initKeyboard() {
|
|
||||||
|
|
||||||
$(document).keypress(function(event) {
|
|
||||||
|
|
||||||
if (!keyboardShortcutsEnabled) return;
|
|
||||||
|
|
||||||
var ch = String.fromCharCode(event.which);
|
|
||||||
|
|
||||||
switch (ch) {
|
|
||||||
case 'c': clearDoodle(); break;
|
|
||||||
case 'n': clearDoodle(); break;
|
|
||||||
case 'p': print(); break;
|
|
||||||
case 'u': oopsUndo(); break;
|
|
||||||
case 'e': settingsWindow.downloadGcode(); break;
|
|
||||||
case 'q': stopPrint(); break;
|
|
||||||
case ',': openSettingsWindow(); break;
|
|
||||||
case 'C': drawCircle(250,180,80,64); break; //x,y,r,res
|
|
||||||
case 'T': drawCircle(250,180,80,3); break; //triangle
|
|
||||||
case 'X': drawCircle(250,180,80,6); break; //hexagon
|
|
||||||
case 'h': previewUp(true); break;
|
|
||||||
case 'H': previewDown(true); break;
|
|
||||||
case 's': saveSketch(); break;
|
|
||||||
case 'L': nextDoodle(); break;
|
|
||||||
case 'l': prevDoodle(); break;
|
|
||||||
case '[': previewTwistLeft(); break;
|
|
||||||
case ']': previewTwistRight(); break;
|
|
||||||
case '\'': resetTwist(); break;
|
|
||||||
default: console.log("Key: '" + ch + "' (" + event.which + ")");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Doodle3D project (http://doodle3d.com).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013, Doodle3D
|
|
||||||
* This software is licensed under the terms of the GNU GPL v2 or later.
|
|
||||||
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function drawCircle(x0,y0,r,res) {
|
|
||||||
if (res==undefined) res = 50; //circle resolution
|
|
||||||
beginShape();
|
|
||||||
var step=Math.PI * 2.0 / res;
|
|
||||||
for (var a=0; a<=Math.PI*2; a+=step) {
|
|
||||||
var x = Math.sin(a) * r + x0;
|
|
||||||
var y = Math.cos(a) * r + y0;
|
|
||||||
if (a==0) shapeMoveTo(x,y);
|
|
||||||
else shapeLineTo(x,y);
|
|
||||||
}
|
|
||||||
endShape();
|
|
||||||
}
|
|
||||||
|
|
||||||
function beginShape(x,y) {
|
|
||||||
setSketchModified(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function shapeMoveTo(x,y) {
|
|
||||||
_points.push([x, y, true]);
|
|
||||||
adjustBounds(x, y)
|
|
||||||
adjustPreviewTransformation();
|
|
||||||
draw(x, y, .5);
|
|
||||||
}
|
|
||||||
|
|
||||||
function shapeLineTo(x,y) {
|
|
||||||
_points.push([x, y, false]);
|
|
||||||
adjustBounds(x, y)
|
|
||||||
adjustPreviewTransformation();
|
|
||||||
draw(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
function endShape() {
|
|
||||||
renderToImageDataPreview();
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Doodle3D project (http://doodle3d.com).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013, Doodle3D
|
|
||||||
* This software is licensed under the terms of the GNU GPL v2 or later.
|
|
||||||
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var VERTICALSHAPE;
|
|
||||||
var verticalShapes = {
|
|
||||||
"NONE": 'none',
|
|
||||||
"DIVERGING": 'diverging',
|
|
||||||
"CONVERGING": 'converging',
|
|
||||||
"SINUS": 'sinus'
|
|
||||||
};
|
|
||||||
|
|
||||||
function initVerticalShapes() {
|
|
||||||
// TODO give these vertical shapes a better spot
|
|
||||||
VERTICALSHAPE = verticalShapes.NONE;
|
|
||||||
$(".verticalShapes, .straight").on('mouseup touchend', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
console.log("diverging");
|
|
||||||
VERTICALSHAPE = verticalShapes.NONE;
|
|
||||||
redrawRenderedPreview();
|
|
||||||
})
|
|
||||||
$(".verticalShapes, .diverging").on('mouseup touchend', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
console.log("diverging");
|
|
||||||
VERTICALSHAPE = verticalShapes.DIVERGING;
|
|
||||||
redrawRenderedPreview();
|
|
||||||
})
|
|
||||||
$(".verticalShapes, .converging").on('mouseup touchend', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
console.log("converging");
|
|
||||||
VERTICALSHAPE = verticalShapes.CONVERGING;
|
|
||||||
redrawRenderedPreview();
|
|
||||||
})
|
|
||||||
$(".verticalShapes, .sinus").on('mouseup touchend', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
console.log("sinus");
|
|
||||||
VERTICALSHAPE = verticalShapes.SINUS;
|
|
||||||
redrawRenderedPreview();
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetVerticalShapes() {
|
|
||||||
VERTICALSHAPE = verticalShapes.NONE;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user