From 4b0fdc1bc193b84ab71fee91ba3ec26125a83880 Mon Sep 17 00:00:00 2001 From: Rick Companje Date: Mon, 2 Feb 2015 17:19:19 +0100 Subject: [PATCH] added the 'l=1' switch which provides a limited user-interface --- js/Keyboard.js | 40 +++++++++++++++++++------------------- js/Printer.js | 3 ++- js/buttonbehaviors.js | 33 +++++++++++++++++++++++++++---- js/init_layout.js | 1 + js/main.js | 35 ++++++--------------------------- js/sketches.js | 4 +++- less/base_centerpanel.less | 7 ++++--- less/buttons.less | 11 ++++++++++- www/index.html | 2 +- 9 files changed, 76 insertions(+), 60 deletions(-) diff --git a/js/Keyboard.js b/js/Keyboard.js index 7559414..278978f 100644 --- a/js/Keyboard.js +++ b/js/Keyboard.js @@ -49,31 +49,31 @@ function initKeyboard() { var ch = String.fromCharCode(event.which); switch (ch) { - case 'c': newSketch(); break; - case 'n': newSketch(); break; - case 'p': print(); break; - case 'u': oopsUndo(); break; - case 'g': settingsWindow.downloadGcode(); break; - case 'q': stopPrint(); break; + case '+': case '=': zoomShape(1.05); break; case ',': openSettingsWindow(); break; - case 'h': previewUp(true); break; + case '-': zoomShape(.95); break; + case ';': moveShape(-5,0); break; + case '[': previewTwistLeft(); break; + case '\'': moveShape(5,0); break; + case ']': previewTwistRight(); break; + case 'c': newSketch(); break; + case 'f': showTravelLines=!showTravelLines; redrawDoodle(); break; + case 'g': settingsWindow.downloadGcode(); break; case 'H': previewDown(true); break; - case 's': saveSketch(); break; + case 'h': previewUp(true); break; + case 'i': showShapeDialog(); break; case 'L': nextSketch(); break; case 'l': prevSketch(); break; - case '[': previewTwistLeft(); break; - case ']': previewTwistRight(); break; - case '|': resetTwist(); break; - case 't': showWordArtDialog(); break; - case 'i': showShapeDialog(); break; - case 'T': showScanDialog(); break; - - case ';': moveShape(-5,0); break; - case '\'': moveShape(5,0); break; - case '-': zoomShape(.95); break; - case '+': zoomShape(1.05); break; - case 'r': rotateShape(.1); break; + case 'n': newSketch(); break; + case 'p': print(); break; + case 'q': stopPrint(); break; case 'R': rotateShape(-.1); break; + case 'r': rotateShape(.1); break; + case 's': saveSketch(); break; + case 'T': showScanDialog(); break; + case 't': showWordArtDialog(); break; + case 'u': oopsUndo(); break; + case '|': resetTwist(); break; //default: console.log("Key: '" + ch + "' (" + event.which + ")"); } diff --git a/js/Printer.js b/js/Printer.js index ca0f556..831bce5 100644 --- a/js/Printer.js +++ b/js/Printer.js @@ -184,7 +184,8 @@ function Printer() { if (completed) { console.log("Printer:sendPrintPart:gcode sending completed"); this.gcode = []; - btnStop.css("display","block"); // hack + //btnStop.css("display","block"); // hack + btnStop.enable(); //check me self.removeLeaveWarning(); message.set("Doodle has been sent to printer...",Message.INFO,true); //self.targetTemperature = settings["printer.temperature"]; // slight hack diff --git a/js/buttonbehaviors.js b/js/buttonbehaviors.js index ae3d642..64c8c8d 100644 --- a/js/buttonbehaviors.js +++ b/js/buttonbehaviors.js @@ -44,10 +44,10 @@ function initButtonBehavior() { buttonGroupAdd = $("#buttonGroupAdd"); btnShape = new Button("#btnShape"); btnWordArt = new Button("#btnWordArt"); - btnScan = new Button("#btnScan"); + btnScan = new Button("#btnScan"); popupWordArt = $("#popupWordArt"); popupShape = $("#popupShape"); - popupScan = $("#popupScan"); + popupScan = $("#popupScan"); popupMask = $("#popupMask"); logoPanel = $("#logopanel"); btnToggleEdit = new Button("#btnToggleEdit"); @@ -76,7 +76,7 @@ function initButtonBehavior() { btnPrint.on("onButtonClick", print); btnStop.on("onButtonClick", stopPrint); btnSave.on("onButtonClick", saveSketch); - btnPrevious.on("onButtonClick", previousSketch); + btnPrevious.on("onButtonClick", onPreviousButtonClick); btnNext.on("onButtonClick", nextSketch); btnOops.on("onButtonHold", onBtnOops); // vertical shape buttons @@ -98,6 +98,11 @@ function initButtonBehavior() { // setSketchModified(false); // updateSketchButtonStates(); + function onPreviousButtonClick() { + if (!sketchLoaded) loadSketch(curSketch); + else previousSketch(); + } + function onBtnToggleVerticalShapes() { var btnImg; if (buttonGroupVerticalShapes.is(":hidden")) { @@ -232,7 +237,8 @@ function print(e) { //setState(Printer.BUFFERING_STATE,printer.hasControl); printer.overruleState(Printer.BUFFERING_STATE); - btnStop.css("display","none"); // hack + // btnStop.css("display","none"); // hack + btnStop.disable(); //check me // we put the gcode generation in a little delay // so that for example the print button is disabled right away @@ -472,3 +478,22 @@ function setState(newState,newHasControl) { state = newState; hasControl = newHasControl; } + +function initLimitedInterface() { + btnSettings.hide(); + btnPrint.hide(); + btnStop.hide(); + btnInfo.hide(); + btnPrevious.hide(); + btnNext.hide(); + $("#thermometerContainer").hide(); + $("#progressbarCanvasContainerParent").hide(); + $("#btnSave").addClass("fake-print-button"); + $("#btnSave").attr("src","img/buttons/btnPrint.png"); + $("#btnSave").on("onButtonClick",function() { + setTimeout(function() { + alert('\nThank you!\n\nYour sketch has been saved on the Doodle3D WiFi-Box and is now ready for 3D-printing.\n\n'); + },1000); + + }) +} diff --git a/js/init_layout.js b/js/init_layout.js index 23b465b..7417851 100644 --- a/js/init_layout.js +++ b/js/init_layout.js @@ -67,3 +67,4 @@ function _startOrientationAndChangeEventListening() { // is it necessary to call these? Aren't they called by the above eventhandlers? doOnResize(); } + diff --git a/js/main.js b/js/main.js index b4d4dbc..9d31260 100644 --- a/js/main.js +++ b/js/main.js @@ -27,6 +27,7 @@ var $drawAreaContainer, $doodleCanvas, doodleCanvas, doodleCanvasContext, $previ var showhideInterval; var showOrHide = false; +var limitedFeatures = false; var clientInfo = {}; @@ -41,6 +42,7 @@ $(function() { if (getURLParameter("c") != "null") communicateWithWifibox = (getURLParameter("c") == "1"); if (getURLParameter("r") != "null") wifiboxIsRemote = (getURLParameter("r") == "1"); if (getURLParameter("u") != "null") autoUpdate = (getURLParameter("u") == "1"); + if (getURLParameter("l") != "null") limitedFeatures = (getURLParameter("l") == "1"); var hostname; if (wifiboxIsRemote) hostname = 'http://192.168.5.1'; @@ -107,37 +109,11 @@ $(function() { $("body").css("overflow", "auto"); $("#debug_textArea").css("display", "block"); //$("#preview_tmp").css("display", "block"); - $("#debug_display").css("display", "block"); + } - // show and hide the progressguage and thermometer - //showhideInterval = setInterval(showOrHideThermo, 2500); - -// $("#debugContainer").css("display", "block"); - - /* TEMP CODE!! -> artificially populates the startgcode and endgcode textareas in the settings window */ - // todo remove this temporary code... - /* - setTimeout(function() { - $("#startgcode").text(""); - $("#startgcode").append("G21 (mm) \n"); - $("#startgcode").append("G91 (relative) \n"); - $("#startgcode").append("G28 X0 Y0 Z0 (physical home) \n"); - $("#startgcode").append("M104 S230 (temperature) \n"); - $("#startgcode").append("G1 E10 F250 (flow) \n"); - $("#startgcode").append("G92 X-100 Y-100 Z0 E10 \n"); - $("#startgcode").append("G1 Z3 F5000 (prevent diagonal line) \n"); - $("#startgcode").append("G90 (absolute) \n"); - $("#startgcode").append("M106 (fan on)"); - console.log("$('#startgcode'): " + $("#startgcode").val()); - - $("#endgcode").text(""); - $("#endgcode").append("G1 X-100 Y-100 F15000 (fast homing) \n"); - $("#endgcode").append("M107 \n"); - $("#endgcode").append("M84 (disable axes) \n"); - console.log("$('#endgcode'): " + $("#endgcode").val()); - }, 1000); - //*/ + if (limitedFeatures) { + initLimitedInterface(); } }); @@ -182,4 +158,5 @@ function settingsLoaded() { function setDebugText(text) { $("#debug_display").text(text); + } diff --git a/js/sketches.js b/js/sketches.js index e1e9524..68c90cd 100644 --- a/js/sketches.js +++ b/js/sketches.js @@ -8,9 +8,10 @@ var curSketch = 0; var sketches = []; //contains fileIDs +var sketchLoaded = false; function previousSketch(e) { - loadSketch(curSketch-1); + loadSketch(curSketch-1); } function nextSketch(e) { @@ -80,6 +81,7 @@ function loadSketch(_curSketch) { var svgData = response.data.data; loadFromSvg(svgData); setSketchModified(false); + sketchLoaded = true; } else { console.log('error loading sketch: ',response); listSketches(); diff --git a/less/base_centerpanel.less b/less/base_centerpanel.less index 085c4c9..0828102 100644 --- a/less/base_centerpanel.less +++ b/less/base_centerpanel.less @@ -5,7 +5,7 @@ margin-left: -@center-panel-width/2; width: @center-panel-width; height: 100%; - padding-top: 1%; + padding-top: 3%; } #logopanel { @@ -32,12 +32,13 @@ #drawareacontainer { position: relative; width: 100%; - height: 79%; + // height: 79%; + height: 65%; background-color: #fff; border: 3px solid black; border-radius: 15px; box-sizing: border-box; - margin-top: 1%; + margin-top: 3%; } #canvasContainers { diff --git a/less/buttons.less b/less/buttons.less index 388186d..cff7a3b 100644 --- a/less/buttons.less +++ b/less/buttons.less @@ -29,6 +29,15 @@ float: right; } +#btnSave.fake-print-button { + position: absolute; + top: 10px; + left: 880px; + width: 125px; + max-width: 125px; + z-index: 100; +} + #btnStop { margin: 5% 5% 1% 5%; float: right; @@ -55,7 +64,7 @@ } #btnNew { - margin: 5% 0% 1% 5%; + margin: 25% 0% 1% 5%; width: 90%; max-width: 130px; height: auto; diff --git a/www/index.html b/www/index.html index 54a2400..86eee66 100644 --- a/www/index.html +++ b/www/index.html @@ -14,7 +14,7 @@ - +