From 0e302d440ff390311350c93d437f3d83803068b4 Mon Sep 17 00:00:00 2001 From: AndyQ Date: Mon, 18 Feb 2019 11:28:41 +0100 Subject: [PATCH 1/4] Added ability to preview the current layer to be drawn If selected, the current layer is drawn at 30% opacity and then the progress is drawn over the top at 100% Added additional checkbox on GCodeView page to include current layer as preview --- AUTHORS.md | 1 + src/octoprint/static/gcodeviewer/js/renderer.js | 7 ++++++- src/octoprint/static/js/app/viewmodels/gcode.js | 6 ++++++ src/octoprint/templates/tabs/gcodeviewer.jinja2 | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index aa13f4baa..3428b6b41 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -97,6 +97,7 @@ date of first contribution): * [Henning Groß](https://github.com/hgross) * [Jubaleth](https://github.com/jubaleth) * [Daniel Joyce](https://github.com/DanielJoyce) + * [Andy Qua](https://github.com/AndyQ) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by [Daid Braam](https://github.com/daid). Parts of its communication layer and diff --git a/src/octoprint/static/gcodeviewer/js/renderer.js b/src/octoprint/static/gcodeviewer/js/renderer.js index f63412b42..87455cffb 100644 --- a/src/octoprint/static/gcodeviewer/js/renderer.js +++ b/src/octoprint/static/gcodeviewer/js/renderer.js @@ -46,6 +46,7 @@ GCODE.renderer = (function(){ modelCenter: {x: 0, y: 0}, differentiateColors: true, showNextLayer: false, + showCurrentLayer: false, showPreviousLayer: false, showBoundingBox: false, showFullSize: false, @@ -98,6 +99,9 @@ GCODE.renderer = (function(){ if (renderOptions['showNextLayer'] && layerNumStore < model.length - 1) { drawLayer(layerNumStore + 1, 0, GCODE.renderer.getLayerNumSegments(layerNumStore + 1), true); } + if (renderOptions['showCurrentLayer'] && layerNumStore < model.length) { + drawLayer(layerNumStore, 0, GCODE.renderer.getLayerNumSegments(layerNumStore), true); + } if (renderOptions['showPreviousLayer'] && layerNumStore > 0) { drawLayer(layerNumStore - 1, 0, GCODE.renderer.getLayerNumSegments(layerNumStore - 1), true); } @@ -567,7 +571,8 @@ GCODE.renderer = (function(){ var sizeRetractSpot = renderOptions["sizeRetractSpot"] * lineWidthFactor * 2; // alpha value (100% if current layer is being rendered, 30% otherwise) - var alpha = (renderOptions['showNextLayer'] || renderOptions['showPreviousLayer']) && isNotCurrentLayer ? 0.3 : 1.0; + // Note - If showing currently layer as preview - also render it at 30% and draw the progress over the top at 100% + var alpha = (renderOptions['showNextLayer'] || renderOptions['showCurrentLayer'] || renderOptions['showPreviousLayer']) && isNotCurrentLayer ? 0.3 : 1.0; var colorLine = {}; var colorMove = {}; diff --git a/src/octoprint/static/js/app/viewmodels/gcode.js b/src/octoprint/static/js/app/viewmodels/gcode.js index 5f9581f33..a553b08f7 100644 --- a/src/octoprint/static/js/app/viewmodels/gcode.js +++ b/src/octoprint/static/js/app/viewmodels/gcode.js @@ -52,6 +52,7 @@ $(function() { self.renderer_extrusionWidthEnabled = ko.observable(false); self.renderer_extrusionWidth = ko.observable(2); self.renderer_showNext = ko.observable(false); + self.renderer_showCurrent = ko.observable(false); self.renderer_showPrevious = ko.observable(false); self.renderer_syncProgress = ko.observable(true); @@ -79,6 +80,7 @@ $(function() { showFullSize: self.renderer_showFullSize(), extrusionWidth: self.renderer_extrusionWidthEnabled() ? self.renderer_extrusionWidth() : 1, showNextLayer: self.renderer_showNext(), + showCurrentLayer: self.renderer_showCurrent(), showPreviousLayer: self.renderer_showPrevious(), zoomInOnModel: self.renderer_zoomOnModel(), onInternalOptionChange: self._onInternalRendererOptionChange @@ -124,6 +126,7 @@ $(function() { self.renderer_extrusionWidthEnabled.subscribe(self.rendererOptionUpdated); self.renderer_extrusionWidth.subscribe(self.rendererOptionUpdated); self.renderer_showNext.subscribe(self.rendererOptionUpdated); + self.renderer_showCurrent.subscribe(self.rendererOptionUpdated); self.renderer_showPrevious.subscribe(self.rendererOptionUpdated); self.reader_sortLayers.subscribe(self.readerOptionUpdated); @@ -341,6 +344,7 @@ $(function() { self.renderer_extrusionWidthEnabled(false); self.renderer_extrusionWidth(2); self.renderer_showNext(false); + self.renderer_showCurrent(false); self.renderer_showPrevious(false); self.renderer_syncProgress(true); @@ -711,6 +715,7 @@ $(function() { current["showRetracts"] = self.renderer_showRetracts(); current["showPrinthead"] = self.renderer_showPrinthead(); current["showPrevious"] = self.renderer_showPrevious(); + current["showCurrent"] = self.renderer_showCurrent(); current["showNext"] = self.renderer_showNext(); current["showFullsize"] = self.renderer_showFullSize(); current["showBoundingBox"] = self.renderer_showBoundingBox(); @@ -743,6 +748,7 @@ $(function() { if (current["showRetracts"] !== undefined) self.renderer_showRetracts(current["showRetracts"]) ; if (current["showPrinthead"] !== undefined) self.renderer_showPrinthead(current["showPrinthead"]); if (current["showPrevious"] !== undefined) self.renderer_showPrevious(current["showPrevious"]) ; + if (current["showCurrent"] !== undefined) self.renderer_showCurrent(current["showCurrent"]) ; if (current["showNext"] !== undefined) self.renderer_showNext(current["showNext"]) ; if (current["showFullsize"] !== undefined) self.renderer_showFullSize(current["showFullsize"]) ; if (current["showBoundingBox"] !== undefined) self.renderer_showBoundingBox(current["showBoundingBox"]) ; diff --git a/src/octoprint/templates/tabs/gcodeviewer.jinja2 b/src/octoprint/templates/tabs/gcodeviewer.jinja2 index b9c098e07..304ec69ad 100644 --- a/src/octoprint/templates/tabs/gcodeviewer.jinja2 +++ b/src/octoprint/templates/tabs/gcodeviewer.jinja2 @@ -64,6 +64,9 @@ + From c652bed87138c6ebb874178dba6c7f87a5967f59 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 28 Feb 2019 11:31:52 +0100 Subject: [PATCH 2/4] Add missing documentation about state in `jobs` endpoint --- docs/api/datamodel.rst | 19 +++++++++++++++++++ docs/api/job.rst | 8 ++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/api/datamodel.rst b/docs/api/datamodel.rst index a55554e9e..abf0ba2b9 100644 --- a/docs/api/datamodel.rst +++ b/docs/api/datamodel.rst @@ -219,6 +219,25 @@ Progress information - Integer - Estimate of time left to print, in seconds +.. _sec-api-datamodel-jobs-state: + +State information +----------------- + +.. list-table:: + :widths: 15 5 10 30 + :header-rows: 1 + + * - Name + - Multiplicity + - Type + - Description + * - body + - 1 + - String + - A textual representation of the current state of the job, i.e. "Operational", "Printing", "Pausing", "Paused", + "Cancelling", "Error" or "Offline". + .. _sec-api-datamodel-files: File related diff --git a/docs/api/job.rst b/docs/api/job.rst index 338a10ea7..bc9d67a1e 100644 --- a/docs/api/job.rst +++ b/docs/api/job.rst @@ -212,7 +212,8 @@ Retrieve information about the current job "filepos": 337942, "printTime": 276, "printTimeLeft": 912 - } + }, + "state": "Printing" } :statuscode 200: No error @@ -243,4 +244,7 @@ Job information response - 1 - :ref:`sec-api-datamodel-jobs-progress` - Information regarding the progress of the current print job - + * - ``state`` + - 1 + - :ref:`sec-api-datamodel-jobs-state` + - Information regarding the state of the current print job From a15e2de251a2502bb285cc4f0bb0dd2cb664222b Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 28 Feb 2019 12:17:35 +0100 Subject: [PATCH 3/4] Fix datamodel structure --- docs/api/datamodel.rst | 33 ++++++++++++++------------------- docs/api/job.rst | 2 +- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/docs/api/datamodel.rst b/docs/api/datamodel.rst index abf0ba2b9..62f530066 100644 --- a/docs/api/datamodel.rst +++ b/docs/api/datamodel.rst @@ -151,6 +151,20 @@ Temperature offset Job related =========== +.. list-table:: + :widths: 15 5 10 30 + :header-rows: 1 + + * - Name + - Multiplicity + - Type + - Description + * - ``state`` + - 1 + - String + - A textual representation of the current state of the job, i.e. "Operational", "Printing", "Pausing", "Paused", + "Cancelling", "Error" or "Offline". + .. _sec-api-datamodel-jobs-job: Job information @@ -219,25 +233,6 @@ Progress information - Integer - Estimate of time left to print, in seconds -.. _sec-api-datamodel-jobs-state: - -State information ------------------ - -.. list-table:: - :widths: 15 5 10 30 - :header-rows: 1 - - * - Name - - Multiplicity - - Type - - Description - * - body - - 1 - - String - - A textual representation of the current state of the job, i.e. "Operational", "Printing", "Pausing", "Paused", - "Cancelling", "Error" or "Offline". - .. _sec-api-datamodel-files: File related diff --git a/docs/api/job.rst b/docs/api/job.rst index bc9d67a1e..a38dda0cd 100644 --- a/docs/api/job.rst +++ b/docs/api/job.rst @@ -246,5 +246,5 @@ Job information response - Information regarding the progress of the current print job * - ``state`` - 1 - - :ref:`sec-api-datamodel-jobs-state` + - :ref:`sec-api-datamodel-jobs` - Information regarding the state of the current print job From 4dbb24ecd759d703b7af2bb61f3864235ecb5e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 28 Feb 2019 12:26:25 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=93=9D=20`state`=20is=20not=20a=20sub?= =?UTF-8?q?=20data=20model=20but=20a=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api/datamodel.rst | 14 -------------- docs/api/job.rst | 5 +++-- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/docs/api/datamodel.rst b/docs/api/datamodel.rst index 62f530066..a55554e9e 100644 --- a/docs/api/datamodel.rst +++ b/docs/api/datamodel.rst @@ -151,20 +151,6 @@ Temperature offset Job related =========== -.. list-table:: - :widths: 15 5 10 30 - :header-rows: 1 - - * - Name - - Multiplicity - - Type - - Description - * - ``state`` - - 1 - - String - - A textual representation of the current state of the job, i.e. "Operational", "Printing", "Pausing", "Paused", - "Cancelling", "Error" or "Offline". - .. _sec-api-datamodel-jobs-job: Job information diff --git a/docs/api/job.rst b/docs/api/job.rst index a38dda0cd..0c43e2b3b 100644 --- a/docs/api/job.rst +++ b/docs/api/job.rst @@ -246,5 +246,6 @@ Job information response - Information regarding the progress of the current print job * - ``state`` - 1 - - :ref:`sec-api-datamodel-jobs` - - Information regarding the state of the current print job + - String + - A textual representation of the current state of the job, i.e. "Operational", "Printing", "Pausing", "Paused", + "Cancelling", "Error" or "Offline".