Skip to content

Commit

Permalink
Hotfix for the visualizer plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishamm committed Oct 5, 2020
1 parent 3c1fc01 commit 5f4eda2
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/plugins/Visualizer/Visualizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ canvas {
'use strict'
import { mapState, mapActions } from 'vuex'
import { WebGLPreview } from 'gcode-preview'
import { Color } from 'three'
Expand All @@ -31,6 +30,7 @@ export default {
data() {
return {
active: true,
fileName: null,
fileContent: null,
lastFilePosition: 0,
preview: null
Expand All @@ -44,10 +44,20 @@ export default {
}
},
async loadFile(file) {
this.fileName = file;
this.fileContent = await this.download({ filename: file, type: 'text' });
this.preview.clear();
this.preview.processGCode((this.filePosition !== null) ? this.fileContent.substring(0, this.filePosition) : this.fileContent);
this.lastFilePosition = this.filePosition;
if (file === this.jobFile) {
if (this.filePosition) {
this.preview.processGCode(this.fileContent.substring(0, this.filePosition));
this.lastFilePosition = this.filePosition;
} else {
this.lastFilePosition = 0;
}
} else {
this.preview.processGCode(this.fileContent);
this.lastFilePosition = 0;
}
},
resize() {
if (this.preview) {
Expand Down Expand Up @@ -77,7 +87,7 @@ export default {
},
watch: {
filePosition(to) {
if (this.active && to > 0) {
if (this.active && this.jobFile === this.fileName && to > 0) {
if (this.fileContent) {
this.preview.processGCode(this.fileContent.substring(this.lastFilePosition, to));
}
Expand Down

0 comments on commit 5f4eda2

Please sign in to comment.