Skip to content

Commit

Permalink
feat(GcodePreview): add option to hide part bounding box when printin…
Browse files Browse the repository at this point in the history
…g a single part (#1310)

Signed-off-by: Mathis Mensing <github@matmen.dev>
  • Loading branch information
matmen committed Jan 13, 2024
1 parent b51025e commit 8726577
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/components/settings/GcodePreviewSettings.vue
Expand Up @@ -174,6 +174,17 @@

<v-divider />

<app-setting :title="$t('app.setting.label.hide_single_part_bounding_box')">
<v-switch
v-model="hideSinglePartBoundingBox"
hide-details
class="mb-5"
@click.native.stop
/>
</app-setting>

<v-divider />

<app-setting :title="$t('app.setting.label.reset')">
<app-btn
outlined
Expand Down Expand Up @@ -344,6 +355,18 @@ export default class GcodePreviewSettings extends Vue {
})
}
get hideSinglePartBoundingBox () {
return this.$store.state.config.uiSettings.gcodePreview.hideSinglePartBoundingBox
}
set hideSinglePartBoundingBox (value: boolean) {
this.$store.dispatch('config/saveByPath', {
path: 'uiSettings.gcodePreview.hideSinglePartBoundingBox',
value,
server: true
})
}
handleReset () {
this.$store.dispatch('config/saveByPath', {
path: 'uiSettings.gcodePreview',
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.yaml
Expand Up @@ -556,6 +556,7 @@ app:
fps_idle_target: FPS Ziel im Ruhezustand
gcode_coords: GCode-Koordinaten verwenden
height: Höhe
hide_single_part_bounding_box: Bauteilrahmen bei Druck eines einzelnen Teils verstecken
invert_x_control: X-Steuerung invertieren
invert_y_control: Y-Steuerung invertieren
invert_z_control: Z-Steuerung invertieren
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.yaml
Expand Up @@ -558,6 +558,7 @@ app:
fps_target: FPS Target
fps_idle_target: FPS Target when not in focus
height: Height
hide_single_part_bounding_box: Hide part bounding box when printing a single part
gcode_coords: Use GCode Coordinates
icon: Icon
invert_x_control: Invert X control
Expand Down
1 change: 1 addition & 0 deletions src/store/config/state.ts
Expand Up @@ -129,6 +129,7 @@ export const defaultState = (): ConfigState => {
autoLoadOnPrintStart: false,
autoLoadMobileOnPrintStart: false,
autoFollowOnFileLoad: true,
hideSinglePartBoundingBox: false,
autoZoom: false,
flip: {
horizontal: false,
Expand Down
1 change: 1 addition & 0 deletions src/store/config/types.ts
Expand Up @@ -205,6 +205,7 @@ export interface GcodePreviewConfig {
autoLoadOnPrintStart: boolean;
autoLoadMobileOnPrintStart: boolean;
autoFollowOnFileLoad: boolean;
hideSinglePartBoundingBox: boolean;
autoZoom: boolean;
flip: {
horizontal: boolean;
Expand Down
6 changes: 5 additions & 1 deletion src/store/gcodePreview/actions.ts
Expand Up @@ -26,7 +26,7 @@ export const actions: ActionTree<GcodePreviewState, RootState> = {
}
},

async loadGcode ({ commit, getters, state }, payload: { file: AppFile; gcode: string }) {
async loadGcode ({ commit, getters, state, rootState }, payload: { file: AppFile; gcode: string }) {
const worker = new ParseGcodeWorker()

commit('setParserWorker', worker)
Expand All @@ -46,6 +46,10 @@ export const actions: ActionTree<GcodePreviewState, RootState> = {
commit('setLayers', data.layers)
commit('setParts', data.parts)
commit('setParserProgress', payload.file.size ?? payload.gcode.length)

if (rootState.config.uiSettings.gcodePreview.hideSinglePartBoundingBox && data.parts.length <= 1) {
commit('setViewerState', { showParts: false })
}
} catch (error) {
consola.error('Parser worker error', error)
}
Expand Down

0 comments on commit 8726577

Please sign in to comment.