diff --git a/src/components/charts/HeightmapChart.vue b/src/components/charts/HeightmapChart.vue new file mode 100644 index 000000000..0d4e81907 --- /dev/null +++ b/src/components/charts/HeightmapChart.vue @@ -0,0 +1,411 @@ + + diff --git a/src/components/dialogs/HeightmapCalibrateMeshDialog.vue b/src/components/dialogs/HeightmapCalibrateMeshDialog.vue new file mode 100644 index 000000000..94d2faaf7 --- /dev/null +++ b/src/components/dialogs/HeightmapCalibrateMeshDialog.vue @@ -0,0 +1,88 @@ + + diff --git a/src/components/dialogs/HeightmapRemoveProfileDialog.vue b/src/components/dialogs/HeightmapRemoveProfileDialog.vue new file mode 100644 index 000000000..7b0c393a9 --- /dev/null +++ b/src/components/dialogs/HeightmapRemoveProfileDialog.vue @@ -0,0 +1,50 @@ + + diff --git a/src/components/dialogs/HeightmapRenameProfileDialog.vue b/src/components/dialogs/HeightmapRenameProfileDialog.vue new file mode 100644 index 000000000..969a4b15a --- /dev/null +++ b/src/components/dialogs/HeightmapRenameProfileDialog.vue @@ -0,0 +1,95 @@ + + diff --git a/src/components/mixins/bedmesh.ts b/src/components/mixins/bedmesh.ts new file mode 100644 index 000000000..36a4cbf12 --- /dev/null +++ b/src/components/mixins/bedmesh.ts @@ -0,0 +1,62 @@ +import Vue from 'vue' +import Component from 'vue-class-component' + +@Component +export default class BedmeshMixin extends Vue { + get bed_mesh() { + return this.$store.state.printer.bed_mesh ?? {} + } + + get profiles() { + return this.bed_mesh.profiles ?? {} + } + + get mesh_min() { + return this.bed_mesh.mesh_min ?? [0, 0] + } + + get mesh_max() { + return this.bed_mesh.mesh_max ?? [0, 0] + } + + get min() { + return Math.min(...this.points) + } + + get max() { + return Math.max(...this.points) + } + + get variance() { + return Math.abs(this.min - this.max).toFixed(3) + } + + get is_active() { + // if the current profile_mane is not empty, return true + if (this.bed_mesh.profile_name !== '') return true + + return this.mesh_min[0] !== 0 || this.mesh_min[1] !== 0 || this.mesh_max[0] !== 0 || this.mesh_max[1] !== 0 + } + + get name() { + if (this.bed_mesh.profile_name !== '') return this.bed_mesh.profile_name + + return 'Unknown' + } + + get probed_matrix() { + return this.bed_mesh.probed_matrix ?? [] + } + + get points() { + const points: number[] = [] + + for (let i = 0; i < this.probed_matrix.length; i++) { + for (let j = 0; j < this.probed_matrix[i].length; j++) { + points.push(this.probed_matrix[i][j]) + } + } + + return points + } +} diff --git a/src/components/panels/Heightmap/HeightmapChartPanel.vue b/src/components/panels/Heightmap/HeightmapChartPanel.vue new file mode 100644 index 000000000..a9dd9648c --- /dev/null +++ b/src/components/panels/Heightmap/HeightmapChartPanel.vue @@ -0,0 +1,220 @@ + + diff --git a/src/components/panels/Heightmap/HeightmapCurrentProfilePanel.vue b/src/components/panels/Heightmap/HeightmapCurrentProfilePanel.vue new file mode 100644 index 000000000..d60dfee69 --- /dev/null +++ b/src/components/panels/Heightmap/HeightmapCurrentProfilePanel.vue @@ -0,0 +1,142 @@ + + + + diff --git a/src/components/panels/Heightmap/HeightmapProfilesPanel.vue b/src/components/panels/Heightmap/HeightmapProfilesPanel.vue new file mode 100644 index 000000000..46e51cbb3 --- /dev/null +++ b/src/components/panels/Heightmap/HeightmapProfilesPanel.vue @@ -0,0 +1,35 @@ + + diff --git a/src/components/panels/Heightmap/HeightmapProfilesPanelRow.vue b/src/components/panels/Heightmap/HeightmapProfilesPanelRow.vue new file mode 100644 index 000000000..72aa67260 --- /dev/null +++ b/src/components/panels/Heightmap/HeightmapProfilesPanelRow.vue @@ -0,0 +1,148 @@ + + + + diff --git a/src/pages/Heightmap.vue b/src/pages/Heightmap.vue index c51019992..7885e740c 100644 --- a/src/pages/Heightmap.vue +++ b/src/pages/Heightmap.vue @@ -1,1234 +1,43 @@ - - diff --git a/src/store/printer/getters.ts b/src/store/printer/getters.ts index ae86074d9..24d5d71d8 100644 --- a/src/store/printer/getters.ts +++ b/src/store/printer/getters.ts @@ -2,7 +2,6 @@ import { checkKlipperConfigModules } from '@/store/variables' import { GetterTree } from 'vuex' import { PrinterState, - PrinterStateBedMesh, PrinterStateExtruder, PrinterStateExtruderStepper, PrinterStateFan, @@ -526,38 +525,6 @@ export const getters: GetterTree = { return output }, - getBedMeshProfiles: (state) => { - const profiles: PrinterStateBedMesh[] = [] - let currentProfile = '' - if (state.bed_mesh) currentProfile = state.bed_mesh.profile_name - - if (state.bed_mesh && 'profiles' in state.bed_mesh) { - Object.keys(state.bed_mesh?.profiles).forEach((key) => { - const value: any = state.bed_mesh.profiles[key] - - let points: number[] = [] - value.points.forEach((row: number[]) => { - points = points.concat(row) - }) - - const min = Math.min(...points) - const max = Math.max(...points) - - profiles.push({ - name: key, - data: { ...value.mesh_params, points: value.points }, - points: points, - min: min, - max: max, - variance: Math.abs(min - max), - is_active: currentProfile === key, - }) - }) - } - - return caseInsensitiveSort(profiles, 'name') - }, - getExtruders: (state) => { const extruders: PrinterStateExtruder[] = [] if (state.configfile?.settings) { diff --git a/src/store/printer/types.ts b/src/store/printer/types.ts index 5c2665e8a..e0ebe8275 100644 --- a/src/store/printer/types.ts +++ b/src/store/printer/types.ts @@ -157,26 +157,30 @@ export interface PrinterStateFilamentSensors { } export interface PrinterStateBedMesh { - name: string - data: { - algo: string + profile_name: string + mesh_min: [number, number] + mesh_max: [number, number] + probed_matrix: number[][] + mesh_matrix: number[][] + profiles: { + [key: string]: PrinterStateBedMeshProfile + } +} + +export interface PrinterStateBedMeshProfile { + points: number[][] + mesh_params: { + min_x: number max_x: number + min_y: number max_y: number + x_count: number + y_count: number mesh_x_pps: number mesh_y_pps: number - min_x: number - min_y: number - points: { [key: number]: number[] } + algo: 'bicubic' | 'lagrange' tension: number - version: number - x_count: number - y_count: number } - points: number[] - min: number - max: number - variance: number - is_active: boolean } export interface PrinterStateMacroParam {