✨ Add support for skipping gcode in the gcode viewer

This commit is contained in:
LazeMSS authored and Gina Häußge committed 2021-02-23 17:06:12 +01:00
1 parent 96aead40dc
commit 0dc452e445
4 files changed
+32 -4

No files matched your search

@@ -48,8 +48,9 @@ class GcodeviewerPlugin(
def get_settings_defaults(self):
return {
"mobileSizeThreshold": 2 * 1024 * 1024, # 2MB
"sizeThreshold": 20 * 1024 * 1024,
} # 20MB
"sizeThreshold": 20 * 1024 * 1024, # 20MB
"skipUntilthis": None,
}
def get_settings_version(self):
return 1
@@ -475,6 +475,21 @@ $(function () {
};
self.showGCodeViewer = function (response, rstatus) {
// Slice of the gcode
if (self.settings.settings.plugins.gcodeviewer.skipUntilthis() != "") {
var findThis =
self.settings.settings.plugins.gcodeviewer.skipUntilthis() + "";
var indexPos = response.indexOf("\n" + findThis);
// Try windows newlines if not found
if (indexPos == -1) {
indexPos = response.indexOf("\r" + findThis);
}
if (indexPos != -1) {
// Slice and make sure we comment out any string left back after slicing - so if a user configures something like "G1" we dont end up with a snippet of gcode commands
// Yes it would be prettier to parse it line by line and remove the entire line, that is very slow and uses mem - this way we find the string, and remove it
response = ";" + response.slice(indexPos + findThis.length + 1);
}
}
var par = {
target: {
result: response
@@ -879,8 +894,8 @@ $(function () {
self.resetOptions();
var current = loadFromLocalStorage(optionsLocalStorageKey);
if (current["centerViewport"] !== undefined)
self.renderer_centerViewport(current["centerViewport"]);
if (current["centerViewPort"] !== undefined)
self.renderer_centerViewport(current["centerViewPort"]);
if (current["zoomOnModel"] !== undefined)
self.renderer_zoomOnModel(current["zoomOnModel"]);
if (current["showMoves"] !== undefined)
@@ -19,4 +19,15 @@
</span>
</div>
</div>
<div class="control-group" title="{{ _('Skip/Hide gcode until this string')}}">
<label class="control-label" for="settings-skipUntilthis">{{ _('Skip to this') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settings.settings.plugins.gcodeviewer.skipUntilthis" id="settings-skipUntilthis" placeholder="; layer 1">
</div>
<div class="controls">
<span class="help-inline">
{% trans %}If provided, the GCode Viewer will search for a line beginning with this string. If found, all GCode up to that point will be skipped. This can be used to skip "purge/nozzle wipe" GCode in the viewer. Note the search is case sensitive. Example: <code>; layer 1</code>{% endtrans %}
</span>
</div>
</div>
</form>