Skip to content

Commit

Permalink
feat: add support for cnc mode in g-code viewer (#1239)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
Sindarius authored and meteyou committed Jan 19, 2023
1 parent 15b58c8 commit eece48c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@codemirror/view": "^6.0.3",
"@jaames/iro": "^5.5.2",
"@lezer/highlight": "^1.0.0",
"@sindarius/gcodeviewer": "^3.1.14",
"@sindarius/gcodeviewer": "^3.2.0",
"@types/node": "^18.0.0",
"@types/overlayscrollbars": "^1.12.1",
"axios": "^0.27.0",
Expand Down
23 changes: 21 additions & 2 deletions src/components/gcodeviewer/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@
hide-details
:label="$t('GCodeViewer.SpecularLighting')"></v-checkbox>
</v-list-item>
<v-list-item class="minHeight36">
<v-checkbox
v-model="cncMode"
class="mt-0"
hide-details
:label="$t('GCodeViewer.CNCMode')"></v-checkbox>
</v-list-item>
</v-list>
</v-menu>
</v-col>
Expand Down Expand Up @@ -508,13 +515,14 @@ export default class Viewer extends Mixins(BaseMixin) {
}
viewer.gcodeProcessor.useHighQualityExtrusion(this.hdRendering)
viewer.gcodeProcessor.updateForceWireMode(this.forceLineRendering)
viewer.gcodeProcessor.updateForceWireMode(this.forceLineRendering || this.cncMode)
viewer.gcodeProcessor.setAlpha(this.transparency)
viewer.gcodeProcessor.setVoxelMode(this.voxelMode)
viewer.gcodeProcessor.voxelWidth = this.voxelWidth
viewer.gcodeProcessor.voxelHeight = this.voxelHeight
viewer.gcodeProcessor.useSpecularColor(this.specularLighting)
viewer.gcodeProcessor.setLiveTracking(false)
viewer.gcodeProcessor.g1AsExtrusion = this.cncMode
viewer.buildObjects.objectCallback = this.objectCallback
this.loadToolColors(this.extruderColors)
Expand Down Expand Up @@ -824,7 +832,7 @@ export default class Viewer extends Mixins(BaseMixin) {
@Watch('forceLineRendering')
async forceLineRenderingChanged(newVal: boolean) {
if (viewer) {
viewer.gcodeProcessor.updateForceWireMode(newVal)
viewer.gcodeProcessor.updateForceWireMode(newVal || this.cncMode)
await this.reloadViewer()
}
}
Expand Down Expand Up @@ -895,6 +903,17 @@ export default class Viewer extends Mixins(BaseMixin) {
}
}
get cncMode() {
return this.$store.state.gui.gcodeViewer.cncMode
}
set cncMode(newVal) {
this.$store.dispatch('gui/saveSetting', { name: 'gcodeViewer.cncMode', value: newVal })
viewer.gcodeProcessor.g1AsExtrusion = newVal
viewer.gcodeProcessor.updateForceWireMode(true)
this.reloadViewer()
}
get extruderColors() {
return this.$store.state.gui.gcodeViewer?.extruderColors ?? false
}
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@
"Transparency": "Transparency",
"Ultra": "Ultra",
"VoxelMode": "Voxel Mode (ASMBL)",
"ShowGCode": "Show G-Code"
"ShowGCode": "Show G-Code",
"CNCMode": "CNC Mode"
},
"Heightmap": {
"Abort": "abort",
Expand Down
1 change: 1 addition & 0 deletions src/store/gui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const getDefaultState = (): GuiState => {
axis_maximum: null,
},
showGCodePanel: false,
cncMode: false,
},
uiSettings: {
logo: defaultLogoColor,
Expand Down
1 change: 1 addition & 0 deletions src/store/gui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface GuiState {
axis_maximum: number[] | null
}
showGCodePanel: boolean
cncMode: boolean
}
macros?: GuiMacrosState
notifications?: GuiNotificationState
Expand Down

0 comments on commit eece48c

Please sign in to comment.