diff --git a/src/components/TheSettingsMenu.vue b/src/components/TheSettingsMenu.vue index ae4031e84..865c890a4 100644 --- a/src/components/TheSettingsMenu.vue +++ b/src/components/TheSettingsMenu.vue @@ -100,8 +100,11 @@ import { mdiWebcam, mdiDipSwitch, mdiMenu, + mdiGrid, } from '@mdi/js' import SettingsMiscellaneousTab from '@/components/settings/SettingsMiscellaneousTab.vue' +import SettingsHeightmapTab from '@/components/settings/SettingsHeightmapTab.vue' + @Component({ components: { Panel, @@ -119,6 +122,7 @@ import SettingsMiscellaneousTab from '@/components/settings/SettingsMiscellaneou SettingsTimelapseTab, SettingsMiscellaneousTab, SettingsNavigationTab, + SettingsHeightmapTab, }, }) export default class TheSettingsMenu extends Mixins(BaseMixin) { @@ -202,6 +206,11 @@ export default class TheSettingsMenu extends Mixins(BaseMixin) { name: 'navigation', title: this.$t('Settings.NavigationTab.Navigation'), }, + { + icon: mdiGrid, + name: 'heightmap', + title: this.$t('Settings.HeightmapTab.Heightmap'), + }, ] if (this.moonrakerComponents.includes('timelapse')) { diff --git a/src/components/settings/SettingsHeightmapTab.vue b/src/components/settings/SettingsHeightmapTab.vue new file mode 100644 index 000000000..e7b79c390 --- /dev/null +++ b/src/components/settings/SettingsHeightmapTab.vue @@ -0,0 +1,83 @@ + + + + + + {{ mdiGrid }} + + {{ $t('Settings.HeightmapTab.Heightmap') }} + + + + + + + + + + + + diff --git a/src/locales/en.json b/src/locales/en.json index 5124825d5..5f282c02d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -930,6 +930,18 @@ "RestoreDialog": "Please select all the sections you want to restore:", "TimeFormat": "Time Format" }, + "HeightmapTab": { + "ColorSchemes": "Color Schemes", + "Heightmap": "Heightmap", + "IsDefault": "(Default)", + "Schemes": { + "GrayScale": "Grayscale", + "Hot": "Hot", + "Hsv": "Hsv", + "Portland": "Portland", + "Spring": "Spring" + } + }, "InterfaceSettings": "Interface Settings", "MacrosTab": { "Add": "add", diff --git a/src/locales/nl.json b/src/locales/nl.json index 9a3312b76..7219ff20e 100644 --- a/src/locales/nl.json +++ b/src/locales/nl.json @@ -854,6 +854,18 @@ "RestoreDialog": "Kies alle secties die je wil herstellen:", "TimeFormat": "Tijdformaat" }, + "HeightmapTab": { + "ColorSchemes": "kleurenschema's", + "Heightmap": "Hoogtekaart", + "IsDefault": "(Standaard)", + "Schemes": { + "GrayScale": "Grijstinten", + "Hot": "Heet", + "Hsv": "Hsv", + "Portland": "Portland", + "Spring": "Lente" + } + }, "InterfaceSettings": "Interface Instellingen", "MacrosTab": { "Add": "voeg toe", diff --git a/src/pages/Heightmap.vue b/src/pages/Heightmap.vue index 660a93bf4..f193982fa 100644 --- a/src/pages/Heightmap.vue +++ b/src/pages/Heightmap.vue @@ -539,19 +539,7 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { calculable: true, dimension: 2, inRange: { - color: [ - '#313695', - '#4575b4', - '#74add1', - '#abd9e9', - '#e0f3f8', - '#ffffbf', - '#fee090', - '#fdae61', - '#f46d43', - '#d73027', - '#a50026', - ], + color: this.colorMap, }, seriesIndex: this.visualMapSeriesIndex, left: this.isMobile ? 10 : 30, @@ -1069,6 +1057,10 @@ export default class PageHeightmap extends Mixins(BaseMixin, ControlMixin) { } } + get colorMap(): string[] { + return this.$store.getters['gui/heightmap/getActiveColorSchemeList'] + } + tooltipFormatter(data: any): string { const outputArray: string[] = [] outputArray.push('' + data.seriesName + '') diff --git a/src/store/gui/heightmap/actions.ts b/src/store/gui/heightmap/actions.ts new file mode 100644 index 000000000..fcec2b163 --- /dev/null +++ b/src/store/gui/heightmap/actions.ts @@ -0,0 +1,20 @@ +import { ActionTree } from 'vuex' +import { RootState } from '../../types' +import { HeightmapState } from './types' + +export const actions: ActionTree = { + saveActiveColorScheme({ commit }, payload: string) { + commit('saveActiveColorScheme', payload) + }, + + saveSetting({ dispatch }, payload) { + dispatch( + 'gui/saveSetting', + { + name: 'heightmap.' + payload.name, + value: payload.value, + }, + { root: true } + ) + }, +} diff --git a/src/store/gui/heightmap/getters.ts b/src/store/gui/heightmap/getters.ts new file mode 100644 index 000000000..1ca2d05d3 --- /dev/null +++ b/src/store/gui/heightmap/getters.ts @@ -0,0 +1,32 @@ +import { GetterTree } from 'vuex' +import { HeightmapState } from './types' + +export const getters: GetterTree = { + getActiveColorSchemeList: (state): string[] => { + switch (state.activecolorscheme.toLowerCase()) { + case 'hsv': + return ['#0000ff', '#00ffff', '#00ff00', '#ffff00', '#ff0000'] + case 'spring': + return ['#ff00ff', '#ffff00'] + case 'hot': + return ['#000000', '#ff0000', '#ffff00', '#ffffff'] + case 'grayscale': + return ['#ffffff', '#000000'] + default: + // Portland colorscheme is being used as default. + return [ + '#313695', + '#4575b4', + '#74add1', + '#abd9e9', + '#e0f3f8', + '#ffffbf', + '#fee090', + '#fdae61', + '#f46d43', + '#d73027', + '#a50026', + ] + } + }, +} diff --git a/src/store/gui/heightmap/index.ts b/src/store/gui/heightmap/index.ts new file mode 100644 index 000000000..f47274bf0 --- /dev/null +++ b/src/store/gui/heightmap/index.ts @@ -0,0 +1,19 @@ +import { Module } from 'vuex' +import { HeightmapState } from './types' +import { getters } from './getters' +import { actions } from './actions' + +export const getDefaultState = (): HeightmapState => { + return { + activecolorscheme: 'portland', + } +} + +const state = getDefaultState() + +export const heightmap: Module = { + namespaced: true, + state, + getters, + actions, +} diff --git a/src/store/gui/heightmap/types.ts b/src/store/gui/heightmap/types.ts new file mode 100644 index 000000000..69c8de46c --- /dev/null +++ b/src/store/gui/heightmap/types.ts @@ -0,0 +1,3 @@ +export interface HeightmapState { + activecolorscheme: string +} diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index 47512562c..6f4722a81 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -15,6 +15,7 @@ import { notifications } from '@/store/gui/notifications' import { presets } from '@/store/gui/presets' import { remoteprinters } from '@/store/gui/remoteprinters' import { webcams } from '@/store/gui/webcams' +import { heightmap } from '@/store/gui/heightmap' export const getDefaultState = (): GuiState => { return { @@ -281,5 +282,6 @@ export const gui: Module = { presets, remoteprinters, webcams, + heightmap, }, }