Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for CNC Mode in gcode viewer #1239

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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