Skip to content

Commit

Permalink
feat(Heightmap): add option to set the default orientation (#2006)
Browse files Browse the repository at this point in the history
Co-authored-by: rackrick <45207681+rackrick@users.noreply.github.com>
  • Loading branch information
meteyou and rackrick committed Sep 24, 2024
1 parent 5690b4a commit 795ca85
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 16 deletions.
32 changes: 24 additions & 8 deletions src/components/charts/HeightmapChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
style="height: 600px; width: 100%; overflow: hidden" />
</template>
<script lang="ts">
import { Component, Mixins, Prop } from 'vue-property-decorator'
import { Component, Mixins, Prop, Ref } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import BedmeshMixin from '@/components/mixins/bedmesh'
Expand Down Expand Up @@ -42,20 +42,17 @@ interface HeightmapSerie {
@Component
export default class HeightmapChart extends Mixins(BaseMixin, BedmeshMixin, ThemeMixin) {
declare $refs: {
// eslint-disable-next-line
heightmap: any
}
@Prop({ type: Boolean, default: false }) showProbed!: boolean
@Prop({ type: Boolean, default: false }) showMesh!: boolean
@Prop({ type: Boolean, default: false }) showFlat!: boolean
@Prop({ type: Boolean, default: false }) wireframe!: boolean
@Prop({ type: Boolean, default: false }) scaleGradient!: boolean
@Prop({ type: Number, default: 1 }) scaleZMax!: number
@Ref('heightmap') heightmap!: any
get chart(): ECharts | null {
return this.$refs.heightmap?.chart ?? null
return this.heightmap?.chart ?? null
}
get chartOptions() {
Expand Down Expand Up @@ -151,7 +148,10 @@ export default class HeightmapChart extends Mixins(BaseMixin, BedmeshMixin, Them
},
boxWidth: 100 * this.scaleX,
boxDepth: 100 * this.scaleY,
viewControl: { distance: 150 },
viewControl: {
distance: 200,
...this.defaultOrientation,
},
},
series: this.series,
}
Expand Down Expand Up @@ -388,6 +388,22 @@ export default class HeightmapChart extends Mixins(BaseMixin, BedmeshMixin, Them
return this.absRangeY / this.minRangeXY
}
get defaultOrientation() {
const orientation = this.$store.state.gui.heightmap.defaultOrientation ?? 'rightFront'
switch (orientation) {
case 'leftFront':
return { alpha: 25, beta: -40 }
case 'front':
return { alpha: 25, beta: 0 }
case 'top':
return { alpha: 90, beta: 0 }
default:
return { alpha: 25, beta: 40 }
}
}
tooltipFormatter(data: any): string {
const outputArray: string[] = []
outputArray.push(`<b>${data.seriesName}</b>`)
Expand Down
46 changes: 38 additions & 8 deletions src/components/settings/SettingsHeightmapTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<v-card-title class="mx-n2">
{{ $t('Settings.HeightmapTab.Heightmap') }}
</v-card-title>
<v-divider class="ml-3"></v-divider>
<v-divider class="ml-3" />
</div>
<settings-row
:title="$t('Settings.HeightmapTab.DefaultOrientation')"
:sub-title="$t('Settings.HeightmapTab.DefaultOrientationDescription')">
<v-select v-model="defaultOrientation" :items="availableOrientations" hide-details outlined dense />
</settings-row>
<v-divider class="my-2" />
<settings-row :title="$t('Settings.HeightmapTab.ColorSchemes')">
<v-select
v-model="colorScheme"
:items="availableColorSchemes"
hide-details
outlined
dense
attach></v-select>
<v-select v-model="colorScheme" :items="availableColorSchemes" hide-details outlined dense />
</settings-row>
</v-card-text>
</v-card>
Expand All @@ -39,6 +39,36 @@ import { mdiGrid } from '@mdi/js'
})
export default class SettingsHeightmapTab extends Mixins(BaseMixin) {
mdiGrid = mdiGrid
get availableOrientations() {
return [
{
text: this.$t('Settings.HeightmapTab.Orientations.RightFront'),
value: 'rightFront',
},
{
text: this.$t('Settings.HeightmapTab.Orientations.LeftFront'),
value: 'leftFront',
},
{
text: this.$t('Settings.HeightmapTab.Orientations.Front'),
value: 'front',
},
{
text: this.$t('Settings.HeightmapTab.Orientations.Top'),
value: 'top',
},
]
}
get defaultOrientation() {
return this.$store.state.gui.heightmap.defaultOrientation
}
set defaultOrientation(newVal) {
this.$store.dispatch('gui/heightmap/saveSetting', { name: 'defaultOrientation', value: newVal })
}
get availableColorSchemes() {
return [
{
Expand Down
8 changes: 8 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,16 @@
},
"HeightmapTab": {
"ColorSchemes": "Color Schemes",
"DefaultOrientation": "Default Orientation",
"DefaultOrientationDescription": "Select the default orientation for the bed mesh visualization.",
"Heightmap": "Heightmap",
"IsDefault": "(Default)",
"Orientations": {
"Front": "Front",
"LeftFront": "Left Front",
"RightFront": "Right Front",
"Top": "Top"
},
"Schemes": {
"GrayScale": "Grayscale",
"Hot": "Hot",
Expand Down
1 change: 1 addition & 0 deletions src/store/gui/heightmap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { actions } from './actions'
export const getDefaultState = (): HeightmapState => {
return {
activecolorscheme: 'portland',
defaultOrientation: 'rightFront',
}
}

Expand Down
1 change: 1 addition & 0 deletions src/store/gui/heightmap/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export interface HeightmapState {
activecolorscheme: string
defaultOrientation: 'rightFront' | 'leftFront' | 'front' | 'top'
}

0 comments on commit 795ca85

Please sign in to comment.