Skip to content

Commit

Permalink
Fixed an issue with a promise not resolving
Browse files Browse the repository at this point in the history
Fixed an issue with a promise not resolving which would block the ability to change render quality or load the current running job.
  • Loading branch information
Sindarius committed Nov 13, 2020
1 parent cf40d7b commit ddbdc0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
29 changes: 7 additions & 22 deletions GCodeViewer/GCodeViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<v-card>
<v-btn @click="reset" block>Reset View</v-btn>
<v-btn @click="reloadviewer" :disabled="loading" block>Reload View</v-btn>
<v-btn @click="loadRunningJob" :disabled="!isJobRunning || loading || visualizingCurrentJob" block>Load Current Job</v-btn>
<v-btn @click="loadRunningJob" :disabled="!isJobRunning || loading" block>Load Current Job</v-btn>
<v-btn @click="clearScene" v-show="debugVisible" :disabled="loading" block>Clear Scene</v-btn>
<v-checkbox v-model="showObjectSelection" :disabled="!canCancelObject" :label="jobSelectionLabel"></v-checkbox>
<v-checkbox v-model="showCursor" label="Show Cursor"></v-checkbox>
Expand Down Expand Up @@ -53,20 +53,6 @@
<h3>Background</h3>
<gcodeviewer-color-picker :editcolor="backgroundColor" @updatecolor="(value) => updateBackground(value)"></gcodeviewer-color-picker>
</v-card>
<v-card v-show="debugVisible">
<h3>Render Mode (Disabled)</h3>
<v-btn-toggle exclusive v-model="renderMode">
<v-btn :value="1">Line</v-btn>
<v-btn :value="2">3D</v-btn>
<v-btn :value="3">Point</v-btn>
</v-btn-toggle>
<h3>Render n-th row (Disabled)</h3>
<v-btn-toggle exclusive v-model="nthRow">
<v-btn :value="1">1</v-btn>
<v-btn :value="2">2</v-btn>
<v-btn :value="3">3</v-btn>
</v-btn-toggle>
</v-card>
</div>
<div class="viewer-box">
<canvas ref="viewerCanvas" class="babylon-canvas" />
Expand Down Expand Up @@ -113,7 +99,6 @@
showCursor: false,
showTravelLines: false,
selectedFile: '',
renderMode: 1,
nthRow: 1,
renderQuality: 0,
debugVisible: false,
Expand All @@ -134,7 +119,11 @@
...mapState('machine/model', ['job', 'move', 'state']),
isJobRunning: (state) => state.state.status === StatusType.simulating || state.state.status === StatusType.processing,
visualizingCurrentJob: function (state) {
return state.job.file.fileName === this.selectedFile;
try {
return state.job.file.fileName === this.selectedFile;
} catch {
return false;
}
},
filePosition: (state) => state.job.filePosition,
fileSize: (state) => state.job.file.size,
Expand Down Expand Up @@ -166,7 +155,6 @@
this.extruderColors = viewer.getExtruderColors();
this.backgroundColor = viewer.getBackgroundColor();
this.progressColor = viewer.getProgressColor();
this.viewModelEvent = async (path) => {
this.selectedFile = path;
this.loading = true;
Expand Down Expand Up @@ -305,14 +293,11 @@
let progressPercent = newValue / this.fileSize;
viewer.updatePrintProgress(progressPercent);
},
renderMode: function (newValue) {
viewer.gcodeProcessor.renderVersion = newValue;
this.reloadviewer();
},
nthRow: function (newValue) {
viewer.gcodeProcessor.everyNthRow = newValue;
},
renderQuality: function (newValue) {
console.log(newValue);
if (viewer.renderQuality !== newValue) {
viewer.updateRenderQuality(newValue);
this.reloadviewer();
Expand Down
5 changes: 4 additions & 1 deletion GCodeViewer/viewer/gcodeviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ export default class {
});
} else {
this.processFile(this.fileData);
resolve();
}
});
}
Expand Down Expand Up @@ -467,7 +468,9 @@ export default class {
}
updateRenderQuality(renderQuality) {
this.renderQuality = renderQuality;
localStorage.setItem('renderQuality', renderQuality);
if (localStorage) {
localStorage.setItem('renderQuality', renderQuality);
}
}
registerClipIgnore(mesh) {
let that = this;
Expand Down

0 comments on commit ddbdc0c

Please sign in to comment.