{{ $t('Heightmap.NoProfile') }}
@@ -415,6 +441,7 @@ import { Grid3DComponent } from 'echarts-gl/components' // @ts-ignore import { SurfaceChart } from 'echarts-gl/charts' import type { ECharts } from 'echarts' +import { PrinterStateBedMesh } from '@/store/printer/types' use([CanvasRenderer, VisualMapComponent, Grid3DComponent, SurfaceChart]) @@ -607,6 +634,14 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { return this.$store.state.printer.bed_mesh ?? null } + get currentProfileName() { + return this.bed_mesh?.profile_name ?? '' + } + + get currentProfile() { + return this.profiles.find((profile: PrinterStateBedMesh) => profile.name === this.currentProfileName) + } + @Watch('bed_mesh', { deep: true }) bed_meshChanged() { this.chart?.setOption(this.chartOptions) @@ -698,12 +733,9 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { let min = 0 let max = 0 - if (this.bed_mesh) { - const points = [] - for (const row of this.bed_mesh.probed_matrix) for (const col of row) points.push(col) - - min = Math.min(min, ...points) - max = Math.max(max, ...points) + if (this.currentProfile) { + min = this.currentProfile.min + max = this.currentProfile.max } return [min, max] @@ -713,7 +745,7 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { const [min, max] = this.heightmapLimit const minRange = Math.round(Math.max(Math.abs(min), Math.abs(max)) * 10) / 10 - const maxRange = Math.max(minRange, 0.5) + const maxRange = Math.max(minRange, 1) return [minRange, maxRange] } @@ -934,7 +966,7 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { col, positionX, positionY, - value: Math.round(max * 1000) / 1000, + value: max, } } @@ -972,7 +1004,7 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { col, positionX, positionY, - value: Math.round(min * 1000) / 1000, + value: min, } } @@ -1004,12 +1036,10 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { } loadProfile(name: string): void { - this.$store.dispatch('server/addEvent', { message: 'BED_MESH_PROFILE LOAD=' + name, type: 'command' }) - this.$socket.emit( - 'printer.gcode.script', - { script: 'BED_MESH_PROFILE LOAD=' + name }, - { loading: 'bedMeshLoad_' + name } - ) + const gcode = 'BED_MESH_PROFILE LOAD="' + name + '"' + + this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' }) + this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'bedMeshLoad_' + name }) } openRenameProfile(): void { @@ -1024,20 +1054,20 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { renameProfile(): void { this.renameDialog = false + const gcodeNew = 'BED_MESH_PROFILE SAVE="' + this.newName + '"' + const gcodeOld = 'BED_MESH_PROFILE REMOVE="' + this.oldName + '"' - this.$store.dispatch('server/addEvent', { message: 'BED_MESH_PROFILE SAVE=' + this.newName, type: 'command' }) - this.$store.dispatch('server/addEvent', { message: 'BED_MESH_PROFILE REMOVE=' + this.oldName, type: 'command' }) + this.$store.dispatch('server/addEvent', { + message: gcodeNew, + type: 'command', + }) + this.$store.dispatch('server/addEvent', { + message: gcodeOld, + type: 'command', + }) - this.$socket.emit( - 'printer.gcode.script', - { script: 'BED_MESH_PROFILE SAVE=' + this.newName }, - { loading: 'bedMeshRename' } - ) - this.$socket.emit( - 'printer.gcode.script', - { script: 'BED_MESH_PROFILE REMOVE=' + this.oldName }, - { loading: 'bedMeshRename' } - ) + this.$socket.emit('printer.gcode.script', { script: gcodeNew }, { loading: 'bedMeshRename' }) + this.$socket.emit('printer.gcode.script', { script: gcodeOld }, { loading: 'bedMeshRename' }) this.newName = '' this.oldName = '' @@ -1050,13 +1080,15 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { removeProfile(): void { this.removeDialog = false + const gcode = 'BED_MESH_PROFILE REMOVE="' + this.removeDialogProfile + '"' + this.$store.dispatch('server/addEvent', { - message: 'BED_MESH_PROFILE REMOVE=' + this.removeDialogProfile, + message: gcode, type: 'command', }) this.$socket.emit( 'printer.gcode.script', - { script: 'BED_MESH_PROFILE REMOVE=' + this.removeDialogProfile }, + { script: gcode }, { action: 'printer/removeBedMeshProfile', actionPayload: { name: this.removeDialogProfile }, @@ -1069,13 +1101,17 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { } homePrinter(): void { - this.$store.dispatch('server/addEvent', { message: 'G28', type: 'command' }) - this.$socket.emit('printer.gcode.script', { script: 'G28' }, { loading: 'homeAll' }) + const gcode = 'G28' + + this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' }) + this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'homeAll' }) } clearBedMesh(): void { - this.$store.dispatch('server/addEvent', { message: 'BED_MESH_CLEAR', type: 'command' }) - this.$socket.emit('printer.gcode.script', { script: 'BED_MESH_CLEAR' }, { loading: 'bedMeshClear' }) + const gcode = 'BED_MESH_CLEAR' + + this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' }) + this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'bedMeshClear' }) } openCalibrateMesh() {