diff --git a/octoprint/server.py b/octoprint/server.py index 4f01441..4aeeb3c 100644 --- a/octoprint/server.py +++ b/octoprint/server.py @@ -28,7 +28,8 @@ def index(): "index.html", webcamStream=settings().get("webcam", "stream"), enableTimelapse=(settings().get("webcam", "snapshot") is not None and settings().get("webcam", "ffmpeg") is not None), - enableEstimations=(settings().getBoolean("feature", "analyzeGcode")) + enableEstimations=(settings().getBoolean("feature", "analyzeGcode")), + gCodeVisualizer=settings().get("feature", "gCodeVisualizer") ) #~~ Printer state diff --git a/octoprint/settings.py b/octoprint/settings.py index 72af359..292300c 100644 --- a/octoprint/settings.py +++ b/octoprint/settings.py @@ -39,7 +39,8 @@ old_default_settings = { "timelapse_tmp": None }, "feature": { - "analyzeGcode": True + "analyzeGcode": True, + "gCodeVisualizer": True }, } diff --git a/octoprint/static/gcodeviewer/js/gCodeReader.js b/octoprint/static/gcodeviewer/js/gCodeReader.js index a5e8c02..190bc57 100644 --- a/octoprint/static/gcodeviewer/js/gCodeReader.js +++ b/octoprint/static/gcodeviewer/js/gCodeReader.js @@ -109,7 +109,7 @@ GCODE.gCodeReader = (function(){ lines = reader.target.result.split(/\n/); reader.target.result = null; prepareGCode(); - + worker.postMessage({ "cmd":"parseGCode", "msg":{ diff --git a/octoprint/static/js/ui.js b/octoprint/static/js/ui.js index ae8872b..c042090 100644 --- a/octoprint/static/js/ui.js +++ b/octoprint/static/js/ui.js @@ -812,6 +812,12 @@ function GcodeViewModel() { self.loadedFilename = undefined; self.status = 'idle'; + self.enabled = false; + + self.initialize = function(){ + self.enabled = true; + GCODE.ui.initHandlers(); + } self.loadFile = function(filename){ if(self.status == 'idle'){ @@ -849,6 +855,8 @@ function GcodeViewModel() { } self._processData = function(data) { + if(!self.enabled)return; + if(self.loadedFilename == data.job.filename){ var cmdIndex = GCODE.gCodeReader.getLinesCmdIndex(data.progress.progress); if(cmdIndex){ @@ -1056,8 +1064,10 @@ $(function() { if (webcamElement) { ko.applyBindings(webcamViewModel, document.getElementById("webcam")); } - - GCODE.ui.initHandlers(); + var gCodeVisualizerElement = document.getElementById("tab2d"); + if(gCodeVisualizerElement){ + gcodeViewModel.initialize(); + } //~~ startup commands connectionViewModel.requestData(); diff --git a/octoprint/templates/index.html b/octoprint/templates/index.html index 7a67621..334b87a 100644 --- a/octoprint/templates/index.html +++ b/octoprint/templates/index.html @@ -128,7 +128,7 @@