chore(gcodeviewr): convert to TS
Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
1 parent
cc85e2a441
commit
2f88def03a
4 files changed
+1387
-212
No files matched your search
Generated
+1216
-14
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -22,7 +22,7 @@
|
||||
"@codemirror/state": "^0.19.1",
|
||||
"@codemirror/stream-parser": "^0.19.1",
|
||||
"@codemirror/view": "^0.19.1",
|
||||
"@sindarius/gcodeviewer": "^2.0.6",
|
||||
"@sindarius/gcodeviewer": "^2.1.0",
|
||||
"axios": "^0.21.1",
|
||||
"core-js": "^3.16.0",
|
||||
"echarts": "^5.1.2",
|
||||
|
||||
@@ -1,28 +1,50 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<v-icon>mdi-video-3d</v-icon>
|
||||
{{ $t('GCodeViewer.Title') }}
|
||||
<v-toolbar flat dense>
|
||||
<v-toolbar-title>
|
||||
<span class="subheading"><v-icon left>mdi-video-3d</v-icon>{{ $t('GCodeViewer.Title') }}</span>
|
||||
</v-toolbar-title>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn @click="tracking=true" v-show="showTrackingButton">{{ $t("GCodeViewer.TrackPrint")}}</v-btn>
|
||||
<v-btn @click="reloadViewer()" color="info" v-show="reloadRequired">{{$t("GCodeViewer.ReloadRequired")}}</v-btn>
|
||||
</v-card-title>
|
||||
</v-toolbar>
|
||||
<v-card-text>
|
||||
<v-row>
|
||||
<v-col cols="2">
|
||||
<v-btn @click="chooseFile" block>{{ $t("GCodeViewer.LoadLocal") }}</v-btn>
|
||||
<v-btn @click="resetCamera" block class="mt-1">{{ $t("GCodeViewer.ResetCamera")}}</v-btn>
|
||||
<v-select :items="renderQualities" :label="$t('GCodeViewer.RenderQuality')" attach class="mt-2" item-text="label" v-model="renderQuality"></v-select>
|
||||
<v-switch :label="$t('GCodeViewer.ForceLineRendering')" class="ma-0 pa-0" dense v-model="forceLineRendering"></v-switch>
|
||||
<v-subheader class="ma-0">{{ $t("GCodeViewer.ZClip") }}</v-subheader>
|
||||
<v-slider :disabled="tracking" :max="maxZSlider" min="-1" v-model="zSlider"></v-slider>
|
||||
<v-row v-if="loading">
|
||||
<v-col>
|
||||
<v-progress-linear :value="loadingPercent" :height="25" rounded>
|
||||
<span class="progress-text">{{loadingPercent}}%</span>
|
||||
</v-progress-linear>
|
||||
</v-col>
|
||||
<v-col cols="10" ref="viewerCanvasContainer">
|
||||
<div class="progress-container">
|
||||
<v-progress-linear :value="loadingPercent" class="disable-transition" color="#d41216" height="15" rounded v-show="loading">
|
||||
<span class="progress-text">{{loadingPercent}}%</span>
|
||||
</v-progress-linear>
|
||||
</div>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<div ref="viewerCanvasContainer"></div>
|
||||
</v-col>
|
||||
<v-col class="col-auto pr-6">
|
||||
<v-slider
|
||||
vertical
|
||||
:disabled="tracking"
|
||||
:max="maxZSlider"
|
||||
min="-1"
|
||||
:value="zSlider"
|
||||
:height="sliderHeight"
|
||||
class="slider-autoheight"
|
||||
@change="updateZSlider"
|
||||
></v-slider>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-btn @click="chooseFile">{{ $t("GCodeViewer.LoadLocal") }}</v-btn>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn @click="resetCamera">{{ $t("GCodeViewer.ResetCamera")}}</v-btn>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-switch :label="$t('GCodeViewer.ForceLineRendering')" class="mt-0" v-model="forceLineRendering" hide-details dense></v-switch>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-select :items="renderQualities" :label="$t('GCodeViewer.RenderQuality')" item-text="label" dense v-model="renderQuality" hide-details></v-select>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<input :accept="'.g,.gcode,.gc,.gco,.nc,.ngc,.tap'" @change="fileSelected" hidden multiple ref="fileInput" type="file" />
|
||||
@@ -37,6 +59,10 @@
|
||||
height: 100%;
|
||||
border: 1px solid #3f3f3f;
|
||||
}
|
||||
|
||||
.slider-autoheight .v-slider {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
@@ -52,50 +78,54 @@
|
||||
.disable-transition {
|
||||
transition: none !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
/* Can remove this when converted to typescript proper */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
|
||||
<script lang="ts">
|
||||
import {Component, Mixins, Prop, Ref, Watch} from 'vue-property-decorator'
|
||||
import BaseMixin from '../mixins/base'
|
||||
// @ts-ignore
|
||||
import GCodeViewer from '@sindarius/gcodeviewer'
|
||||
let viewer
|
||||
let canvasBackup = null
|
||||
let loadedFileBackup = ''
|
||||
import {Debounce} from 'vue-debounce-decorator'
|
||||
|
||||
let viewer: any = null
|
||||
let trackingBackup = false
|
||||
let loadedFileBackup = ''
|
||||
|
||||
@Component
|
||||
export default class Viewer extends Mixins(BaseMixin) {
|
||||
isBusy = false;
|
||||
loading = false;
|
||||
loadingPercent = 0;
|
||||
tracking = trackingBackup;
|
||||
loadedFile = loadedFileBackup; //This needs to be set in order for vue tracking and computed values to work properly.
|
||||
reloadRequired = false;
|
||||
fileSize = 0;
|
||||
maxZSlider = 100000;
|
||||
zSlider = this.maxZSlider;
|
||||
private canvasBackup: HTMLCanvasElement | null = null
|
||||
private isBusy = false
|
||||
private loading = false
|
||||
private loadingPercent = 0
|
||||
|
||||
renderQualities = [
|
||||
{label: this.$t('GCodeViewer.Low'), value: 2},
|
||||
{label: this.$t('GCodeViewer.Medium'), value: 3},
|
||||
{label: this.$t('GCodeViewer.High'), value: 4},
|
||||
{label: this.$t('GCodeViewer.Ultra'), value: 5},
|
||||
{label: this.$t('GCodeViewer.Max'), value: 6},
|
||||
];
|
||||
renderQuality = this.renderQualities[2];
|
||||
private tracking = trackingBackup
|
||||
private loadedFile = loadedFileBackup
|
||||
|
||||
@Prop({type: String, default: '', required: false}) filename;
|
||||
private reloadRequired = false
|
||||
private fileSize = 0
|
||||
private maxZSlider = 100000
|
||||
private zSlider = this.maxZSlider
|
||||
private renderQuality = this.renderQualities[2]
|
||||
|
||||
@Ref('fileInput') fileInput;
|
||||
@Prop({type: String, default: '', required: false}) filename!: string
|
||||
@Ref('fileInput') fileInput!: HTMLInputElement
|
||||
@Ref('viewerCanvasContainer') viewerCanvasContainer!: HTMLCanvasElement
|
||||
|
||||
@Ref('viewerCanvasContainer') viewerCanvasContainer;
|
||||
get renderQualities() {
|
||||
return [
|
||||
{ label: this.$t('GCodeViewer.Low'), value: 2 },
|
||||
{ label: this.$t('GCodeViewer.Medium'), value: 3 },
|
||||
{ label: this.$t('GCodeViewer.High'), value: 4 },
|
||||
{ label: this.$t('GCodeViewer.Ultra'), value: 5 },
|
||||
{ label: this.$t('GCodeViewer.Max'), value: 6 },
|
||||
]
|
||||
}
|
||||
|
||||
async mounted() {
|
||||
this.init()
|
||||
await this.init()
|
||||
}
|
||||
|
||||
get filePosition() {
|
||||
return this.printerIsPrinting ? this.$store.state.printer.virtual_sdcard.file_position : 0
|
||||
}
|
||||
@@ -105,40 +135,40 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
get currentPosition() {
|
||||
try {
|
||||
return this.$store.state.printer.motion_report.live_position
|
||||
} catch {
|
||||
return [0, 0, 0, 0]
|
||||
}
|
||||
return this.$store.state.printer.motion_report?.live_position ?? [0, 0, 0, 0]
|
||||
}
|
||||
|
||||
get showTrackingButton() {
|
||||
return this.printerIsPrinting && this.sdCardFilePath !== this.loadedFile
|
||||
}
|
||||
|
||||
get sliderHeight() {
|
||||
return this.canvasBackup?.height ?? 100
|
||||
}
|
||||
|
||||
async init() {
|
||||
if (canvasBackup === null) {
|
||||
if (this.canvasBackup === null) {
|
||||
let canvasElement = document.createElement('canvas')
|
||||
canvasElement.className = 'viewer'
|
||||
this.viewerCanvasContainer.appendChild(canvasElement)
|
||||
canvasBackup = canvasElement
|
||||
this.canvasBackup = canvasElement
|
||||
this.viewerInit(canvasElement)
|
||||
if (this.$route.query.filename) {
|
||||
await this.sleep(2000) //Give the store a chance to initializ before loading the file.
|
||||
this.loadFile(this.apiUrl + '/server/files/' + encodeURI(this.$route.query.filename))
|
||||
await this.loadFile(this.apiUrl + '/server/files/' + encodeURI(this.$route.query.filename.toString()))
|
||||
}
|
||||
} else {
|
||||
if (![this.loadedFile, '', null, undefined].includes(this.$route.query.filename)) {
|
||||
this.loadedFile = this.$route.query.filename
|
||||
this.loadFile(this.apiUrl + '/server/files/' + encodeURI(this.$route.query.filename))
|
||||
if (![this.loadedFile, '', null, undefined].includes(this.$route.query.filename.toString())) {
|
||||
this.loadedFile = this.$route.query.filename.toString()
|
||||
await this.loadFile(this.apiUrl + '/server/files/' + encodeURI(this.$route.query.filename.toString()))
|
||||
}
|
||||
|
||||
this.viewerCanvasContainer.appendChild(canvasBackup)
|
||||
this.viewerCanvasContainer.appendChild(this.canvasBackup)
|
||||
}
|
||||
this.registerProgressCallback()
|
||||
}
|
||||
|
||||
viewerInit(element) {
|
||||
viewerInit(element: HTMLCanvasElement) {
|
||||
viewer = new GCodeViewer(element)
|
||||
viewer.init()
|
||||
viewer.setBackgroundColor('#121212')
|
||||
@@ -177,18 +207,16 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
registerProgressCallback() {
|
||||
viewer.gcodeProcessor.loadingProgressCallback = (progress) => {
|
||||
viewer.gcodeProcessor.loadingProgressCallback = (progress: number) => {
|
||||
this.loadingPercent = Math.ceil(progress * 100)
|
||||
if (this.loadingPercent > 99) {
|
||||
this.loading = false
|
||||
} else {
|
||||
this.loading = true
|
||||
}
|
||||
this.loading = this.loadingPercent <= 99
|
||||
}
|
||||
}
|
||||
|
||||
beforeDestroy() {
|
||||
viewer.gcodeProcessor.loadingProgressCallback = null
|
||||
if (viewer) {
|
||||
viewer.gcodeProcessor.loadingProgressCallback = null
|
||||
}
|
||||
}
|
||||
|
||||
chooseFile() {
|
||||
@@ -204,23 +232,27 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
viewer.setCursorVisiblity(this.showCursor)
|
||||
}
|
||||
|
||||
async fileSelected(e) {
|
||||
async fileSelected(e: any) {
|
||||
const reader = new FileReader()
|
||||
reader.addEventListener('load', async (event) => {
|
||||
if (!event || !event.target) return
|
||||
const blob = event.target.result
|
||||
this.fileSize = blob.length
|
||||
// Do something with result
|
||||
await viewer.processFile(blob)
|
||||
if (typeof blob === 'string') {
|
||||
this.fileSize = blob.length
|
||||
// Do something with result
|
||||
await viewer.processFile(blob)
|
||||
}
|
||||
this.finishLoad()
|
||||
})
|
||||
this.tracking = false
|
||||
this.loadedFile = e.target.files[0].name
|
||||
reader.readAsText(e.target.files[0])
|
||||
if (e.target.files?.length) {
|
||||
this.loadedFile = e?.target?.files[0].name
|
||||
reader.readAsText(e.target.files[0])
|
||||
}
|
||||
e.target.value = ''
|
||||
}
|
||||
|
||||
async loadFile(filename) {
|
||||
async loadFile(filename: string) {
|
||||
let response = await fetch(filename)
|
||||
let text = await response.text()
|
||||
viewer.updateRenderQuality(this.renderQuality.value)
|
||||
@@ -229,7 +261,7 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
this.finishLoad()
|
||||
}
|
||||
|
||||
async sleep(ms) {
|
||||
async sleep(ms: number) {
|
||||
await new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
@@ -265,7 +297,7 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
@Watch('renderQuality')
|
||||
async renderQualityChanged(newVal) {
|
||||
async renderQualityChanged(newVal: number) {
|
||||
if (viewer && viewer.renderQuality !== newVal) {
|
||||
viewer.updateRenderQuality(newVal)
|
||||
await this.reloadViewer()
|
||||
@@ -273,7 +305,7 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
@Watch('forceLineRendering')
|
||||
async forceLineRenderingChanged(newVal) {
|
||||
async forceLineRenderingChanged(newVal: boolean) {
|
||||
if (viewer) {
|
||||
viewer.gcodeProcessor.updateForceWireMode(newVal)
|
||||
await this.reloadViewer()
|
||||
@@ -281,19 +313,20 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
@Watch('currentPosition')
|
||||
currentPositionChanged(newVal) {
|
||||
let position = [
|
||||
{axes: 'X', position: newVal[0]},
|
||||
{axes: 'Y', position: newVal[1]},
|
||||
{axes: 'Z', position: newVal[2]},
|
||||
]
|
||||
currentPositionChanged(newVal: number[]) {
|
||||
if (viewer) {
|
||||
const position = [
|
||||
{axes: 'X', position: newVal[0]},
|
||||
{axes: 'Y', position: newVal[1]},
|
||||
{axes: 'Z', position: newVal[2]},
|
||||
]
|
||||
|
||||
viewer.updateToolPosition(position)
|
||||
}
|
||||
}
|
||||
|
||||
@Watch('filePosition')
|
||||
filePositionChanged(newVal) {
|
||||
filePositionChanged(newVal: number) {
|
||||
if (!viewer) return
|
||||
if (newVal > 0 && this.printerIsPrinting && this.tracking) {
|
||||
viewer.gcodeProcessor.updateFilePosition(newVal)
|
||||
@@ -304,12 +337,12 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
|
||||
@Watch('loadedFile')
|
||||
loadedFileChanged(newVal) {
|
||||
loadedFileBackup = newVal //We need to keep the backup in sync for when component comes out of scope.
|
||||
this.loadedFileBackup = newVal //We need to keep the backup in sync for when component comes out of scope.
|
||||
}
|
||||
|
||||
@Watch('tracking')
|
||||
async trackingChanged(newVal) {
|
||||
trackingBackup = newVal
|
||||
this.trackingBackup = newVal
|
||||
if (!viewer) return
|
||||
if (newVal) {
|
||||
this.loadedFile = this.sdCardFilePath
|
||||
@@ -337,49 +370,42 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
@Watch('showCursor')
|
||||
showCursorChanged(newVal) {
|
||||
if (viewer) {
|
||||
viewer.setCursorVisiblity(newVal)
|
||||
}
|
||||
showCursorChanged(newVal: boolean) {
|
||||
viewer?.setCursorVisiblity(newVal)
|
||||
}
|
||||
|
||||
get extruderColors() {
|
||||
try {
|
||||
return this.$store.state.gui.gcodeViewer.extruderColors
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
return this.$store.state.gui.gcodeViewer?.extruderColors ?? false
|
||||
}
|
||||
|
||||
loadToolColors(colors) {
|
||||
viewer.gcodeProcessor.resetTools()
|
||||
for (var idx = 0; idx < colors.length; idx++) {
|
||||
viewer.gcodeProcessor.addTool(colors[idx], 0.4) //Default the nozzle to 0.4 for now.
|
||||
loadToolColors(colors: string[]) {
|
||||
if (viewer && colors.length) {
|
||||
viewer.gcodeProcessor.resetTools()
|
||||
colors.forEach((color: string) => {
|
||||
//Todo get nozzle size
|
||||
viewer.gcodeProcessor.addTool(color, 0.4) //Default the nozzle to 0.4 for now.
|
||||
})
|
||||
this.setReloadRequiredFlag()
|
||||
}
|
||||
this.setReloadRequiredFlag()
|
||||
}
|
||||
|
||||
@Watch('extruderColors')
|
||||
extruderColorsChanged(newVal) {
|
||||
if (viewer && newVal) {
|
||||
extruderColorsChanged(newVal: string[]) {
|
||||
if (viewer && newVal && newVal.length) {
|
||||
this.loadToolColors(newVal)
|
||||
this.setReloadRequiredFlag()
|
||||
}
|
||||
}
|
||||
|
||||
get colorMode() {
|
||||
try {
|
||||
return this.$store.state.gui.gcodeViewer.colorMode
|
||||
} catch {
|
||||
return 'extruder'
|
||||
}
|
||||
return this.$store.state.gui.gcodeViewer?.colorMode ?? 'extruder'
|
||||
}
|
||||
|
||||
@Watch('colorMode')
|
||||
colorModeChanged(newVal) {
|
||||
colorModeChanged(newVal: string) {
|
||||
if (!viewer) return
|
||||
if (newVal) {
|
||||
let mode = newVal === 'extruder' ? 0 : 1 //Magic number until I export the enum 0 = Color 1 = Feed Rate
|
||||
const mode = newVal === 'extruder' ? 0 : 1 //Magic number until I export the enum 0 = Color 1 = Feed Rate
|
||||
if (viewer.gcodeProcessor.colorMode !== mode) {
|
||||
this.setReloadRequiredFlag()
|
||||
viewer.gcodeProcessor.setColorMode(mode)
|
||||
@@ -388,130 +414,94 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
get backgroundColor() {
|
||||
try {
|
||||
return this.$store.state.gui.gcodeViewer.backgroundColor
|
||||
} catch {
|
||||
return '#000000'
|
||||
}
|
||||
return this.$store.state.gui.gcodeViewer?.backgroundColor ?? '#000000'
|
||||
}
|
||||
|
||||
@Watch('backgroundColor')
|
||||
backgroundColorChanged(newVal) {
|
||||
backgroundColorChanged(newVal: string) {
|
||||
if (!viewer) return
|
||||
viewer.setBackgroundColor(newVal)
|
||||
}
|
||||
|
||||
get gridColor() {
|
||||
try {
|
||||
return this.$store.state.gui.gcodeViewer.gridColor
|
||||
} catch {
|
||||
return '#000000'
|
||||
}
|
||||
return this.$store.state.gui.gcodeViewer?.gridColor ?? '#000000'
|
||||
}
|
||||
|
||||
@Watch('gridColor')
|
||||
gridColorChanged(newVal) {
|
||||
gridColorChanged(newVal: string) {
|
||||
if (!viewer) return
|
||||
viewer.bed.setBedColor(newVal)
|
||||
}
|
||||
|
||||
get showAxes() {
|
||||
try {
|
||||
return this.$store.state.gui.gcodeViewer.showAxes
|
||||
} catch {
|
||||
return true
|
||||
}
|
||||
return this.$store.state.gui.gcodeViewer?.showAxes ?? true
|
||||
}
|
||||
|
||||
@Watch('showAxes')
|
||||
showAxesChanged(newVal) {
|
||||
showAxesChanged(newVal: boolean) {
|
||||
if (!viewer) return
|
||||
viewer.axes.show(newVal)
|
||||
}
|
||||
|
||||
get minFeed() {
|
||||
try {
|
||||
return this.$store.state.gui.gcodeViewer.minFeed
|
||||
} catch {
|
||||
return 20
|
||||
}
|
||||
return this.$store.state.gui.gcodeViewer?.minFeed ?? 20
|
||||
}
|
||||
|
||||
@Watch('minFeed')
|
||||
minFeedChanged(newVal) {
|
||||
minFeedChanged(newVal: number) {
|
||||
if (!viewer) return
|
||||
viewer.gcodeProcessor.updateColorRate(newVal * 60, this.maxFeed * 60)
|
||||
}
|
||||
|
||||
get maxFeed() {
|
||||
try {
|
||||
return this.$store.state.gui.gcodeViewer.maxFeed
|
||||
} catch {
|
||||
return 100
|
||||
}
|
||||
return this.$store.state.gui.gcodeViewer?.maxFeed ?? 100
|
||||
}
|
||||
|
||||
@Watch('maxFeed')
|
||||
maxFeedChanged(newVal) {
|
||||
maxFeedChanged(newVal: number) {
|
||||
if (!viewer) return
|
||||
viewer.gcodeProcessor.updateColorRate(this.minFeed * 60, newVal * 60)
|
||||
}
|
||||
|
||||
get minFeedColor() {
|
||||
try {
|
||||
return this.$store.state.gui.gcodeViewer.minFeedColor
|
||||
} catch {
|
||||
return '#0000FF'
|
||||
}
|
||||
return this.$store.state.gui.gcodeViewer?.minFeedColor ?? '#0000FF'
|
||||
}
|
||||
|
||||
@Watch('minFeedColor')
|
||||
minFeedColorUpdated(newVal) {
|
||||
minFeedColorUpdated(newVal: string) {
|
||||
if (!viewer) return
|
||||
viewer.gcodeProcessor.updateMinFeedColor(newVal)
|
||||
this.setReloadRequiredFlag()
|
||||
}
|
||||
|
||||
get maxFeedColor() {
|
||||
try {
|
||||
return this.$store.state.gui.gcodeViewer.maxFeedColor
|
||||
} catch {
|
||||
return '#FF0000'
|
||||
}
|
||||
return this.$store.state.gui.gcodeViewer?.maxFeedColor ?? '#FF0000'
|
||||
}
|
||||
|
||||
@Watch('maxFeedColor')
|
||||
maxFeedColorUpdated(newVal) {
|
||||
maxFeedColorUpdated(newVal: string) {
|
||||
if (!viewer) return
|
||||
viewer.gcodeProcessor.updateMaxFeedColor(newVal)
|
||||
this.setReloadRequiredFlag()
|
||||
}
|
||||
|
||||
get kinematics() {
|
||||
try {
|
||||
return this.$store.state.printer.configfile.settings.printer.kinematics
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
return this.$store.state.printer.configfile?.settings?.printer?.kinematics ?? ''
|
||||
}
|
||||
|
||||
@Watch('kinematics')
|
||||
kinematicsChanged(newVal) {
|
||||
kinematicsChanged(newVal: string) {
|
||||
if (viewer && newVal) {
|
||||
viewer.bed.setDelta(newVal.includes('delta'))
|
||||
}
|
||||
}
|
||||
|
||||
get bedMinSize() {
|
||||
try {
|
||||
return this.$store.state.printer.toolhead.axis_minimum
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
return this.$store.state.printer.toolhead?.axis_minimum ?? null
|
||||
}
|
||||
|
||||
@Watch('bedMinSize', {deep: true})
|
||||
bedMinSizeChanged(newVal) {
|
||||
bedMinSizeChanged(newVal: number[] | null) {
|
||||
if (viewer && newVal) {
|
||||
viewer.bed.buildVolume['x'].min = newVal[0]
|
||||
viewer.bed.buildVolume['y'].min = newVal[1]
|
||||
@@ -520,15 +510,11 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
get bedMaxSize() {
|
||||
try {
|
||||
return this.$store.state.printer.toolhead.axis_maximum
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
return this.$store.state.printer.toolhead?.axis_maximum ?? null
|
||||
}
|
||||
|
||||
@Watch('bedMaxSize', {deep: true})
|
||||
bedMaxSizeChanged(newVal) {
|
||||
bedMaxSizeChanged(newVal: number[] | null) {
|
||||
if (newVal && viewer) {
|
||||
viewer.bed.buildVolume['x'].max = newVal[0]
|
||||
viewer.bed.buildVolume['y'].max = newVal[1]
|
||||
@@ -545,23 +531,22 @@ export default class Viewer extends Mixins(BaseMixin) {
|
||||
}
|
||||
|
||||
@Watch('zSlider')
|
||||
zSliderChanged(newVal) {
|
||||
viewer.setZClipPlane(newVal, -1)
|
||||
zSliderChanged(newVal: number) {
|
||||
viewer?.setZClipPlane(newVal, -1)
|
||||
}
|
||||
|
||||
get progressColor() {
|
||||
try {
|
||||
return this.$store.state.gui.gcodeViewer.progressColor
|
||||
} catch {
|
||||
return '#FFFFFF'
|
||||
}
|
||||
return this.$store.state.gui.gcodeViewer?.progressColor ?? '#FFFFFF'
|
||||
}
|
||||
|
||||
@Watch('progressColor')
|
||||
progressColorChanged(newVal) {
|
||||
if (viewer) {
|
||||
viewer.setProgressColor(newVal)
|
||||
}
|
||||
progressColorChanged(newVal: string) {
|
||||
viewer?.setProgressColor(newVal)
|
||||
}
|
||||
|
||||
@Debounce(250)
|
||||
updateZSlider(newVal: any) {
|
||||
this.zSlider = newVal
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
<div>
|
||||
<v-card flat>
|
||||
<v-card-text>
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.ShowCursor')" class="my-2">
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.ShowCursor')">
|
||||
<v-switch class="mt-0" hide-details v-model="showCursor"></v-switch>
|
||||
</settings-row>
|
||||
<v-divider class="my-2"></v-divider>
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.ShowAxes')" class="my-2">
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.ShowAxes')">
|
||||
<v-switch class="mt-0" hide-details v-model="showAxes"></v-switch>
|
||||
</settings-row>
|
||||
<v-divider class="my-2"></v-divider>
|
||||
@@ -14,16 +14,7 @@
|
||||
<v-select :items="colorModes" dense hide-details outlined selected v-model="colorMode"></v-select>
|
||||
</settings-row>
|
||||
<v-divider class="my-2"></v-divider>
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.ProgressColor')" class="my-2">
|
||||
<v-menu :close-on-content-click="false" bottom left offset-y>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-btn :color="progressColor" class="minwidth-0 px-5" small v-bind="attrs" v-on="on"></v-btn>
|
||||
</template>
|
||||
<v-color-picker :value="progressColor" @update:color="updateColorValue('progressColor', $event)" hide-mode-switch mode="rgba"></v-color-picker>
|
||||
</v-menu>
|
||||
</settings-row>
|
||||
<v-divider class="my-2"></v-divider>
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.BackgroundColor')" class="my-2">
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.BackgroundColor')">
|
||||
<v-menu :close-on-content-click="false" bottom left offset-y>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-btn :color="backgroundColor" class="minwidth-0 px-5" small v-bind="attrs" v-on="on"></v-btn>
|
||||
@@ -32,7 +23,7 @@
|
||||
</v-menu>
|
||||
</settings-row>
|
||||
<v-divider class="my-2"></v-divider>
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.GridColor')" class="my-2">
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.GridColor')">
|
||||
<v-menu :close-on-content-click="false" bottom left offset-y>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-btn :color="gridColor" class="minwidth-0 px-5" small v-bind="attrs" v-on="on"></v-btn>
|
||||
@@ -41,7 +32,7 @@
|
||||
</v-menu>
|
||||
</settings-row>
|
||||
<v-divider class="my-2"></v-divider>
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.ExtruderColor')" class="my-2">
|
||||
<settings-row :title="$t('Settings.GCodeViewerTab.ExtruderColor')">
|
||||
<v-row no-gutters>
|
||||
<v-menu :close-on-content-click="false" :key="index" bottom left offset-y v-for="(extruderColor, index) in extruderColors">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
@@ -208,7 +199,4 @@ export default class SettingsGCodeViewerTab extends Mixins(BaseMixin) {
|
||||
this.$store.dispatch('gui/saveSetting', {name: 'gcodeViewer.progressColor', value: newVal})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
</script>
|
||||
Reference in new issue
Block a user