feature: exclude object map (#369)

* feature: add 2D object map (testing)
* feature: 2D map for objects
* chore: update materialdesignicons
* feature: move exclude object map and list in a seperate dialog
* feature: add hover function to display hovered object in the map
* feature: colorize border of current object
* feature: click on object in map to cancel object
* feature: add mobile support for exclude object dialog

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej authored and GitHub committed 2021-10-05 22:52:17 +02:00
1 parent dd2c8c58ca
commit a81a486602
8 files changed
+449 -88

No files matched your search

+7 -7
View File
@@ -45,7 +45,7 @@
"vuex": "^3.6.2"
},
"devDependencies": {
"@mdi/font": "^5.9.55",
"@mdi/font": "^6.2.95",
"@types/semver": "^7.3.8",
"@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.29.3",
@@ -1894,9 +1894,9 @@
}
},
"node_modules/@mdi/font": {
"version": "5.9.55",
"resolved": "https://registry.npmjs.org/@mdi/font/-/font-5.9.55.tgz",
"integrity": "sha512-jswRF6q3eq8NWpWiqct6q+6Fg/I7nUhrxYJfiEM8JJpap0wVJLQdbKtyS65GdlK7S7Ytnx3TTi/bmw+tBhkGmg==",
"version": "6.2.95",
"resolved": "https://registry.npmjs.org/@mdi/font/-/font-6.2.95.tgz",
"integrity": "sha512-0RKkhabkFZP3ALwKqrjhdKdhydQpoydIjX6cvjIwLyjADCsE0pG68YkGY+S3qnfdErmhS4m8adwvgrAFXp2AYQ==",
"dev": true
},
"node_modules/@mrmlnc/readdir-enhanced": {
@@ -21722,9 +21722,9 @@
}
},
"@mdi/font": {
"version": "5.9.55",
"resolved": "https://registry.npmjs.org/@mdi/font/-/font-5.9.55.tgz",
"integrity": "sha512-jswRF6q3eq8NWpWiqct6q+6Fg/I7nUhrxYJfiEM8JJpap0wVJLQdbKtyS65GdlK7S7Ytnx3TTi/bmw+tBhkGmg==",
"version": "6.2.95",
"resolved": "https://registry.npmjs.org/@mdi/font/-/font-6.2.95.tgz",
"integrity": "sha512-0RKkhabkFZP3ALwKqrjhdKdhydQpoydIjX6cvjIwLyjADCsE0pG68YkGY+S3qnfdErmhS4m8adwvgrAFXp2AYQ==",
"dev": true
},
"@mrmlnc/readdir-enhanced": {
+1 -1
View File
@@ -51,7 +51,7 @@
"vuex": "^3.6.2"
},
"devDependencies": {
"@mdi/font": "^5.9.55",
"@mdi/font": "^6.2.95",
"@types/semver": "^7.3.8",
"@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.29.3",
+20 -74
View File
@@ -73,43 +73,10 @@
</v-card-title>
</v-img>
</template>
<template v-if="['printing', 'paused'].includes(printer_state) && printing_objects.length">
<v-container>
<v-row>
<v-col class="py-2">
<span class="subtitle-2 d-block px-0 text--disabled"><v-icon class="mr-2" small>mdi-printer-3d-nozzle</v-icon>{{ current_object !== null ? current_object : '--' }}</span>
</v-col>
<v-col class="col-auto py-2">
<v-icon class="text--disabled cursor-pointer" @click="openCancelObjectDialog(current_object)" small v-if="current_object !== null">mdi-close-circle</v-icon>
</v-col>
</v-row>
</v-container>
<v-divider class="mt-0 mb-0" ></v-divider>
<template v-if="boolShowObjects">
<div v-for="object in printing_objects" v-bind:key="object.name">
<v-container>
<v-row>
<v-col class="py-2">
<span class="subtitle-2 d-block px-0 text--disabled">{{ object.name }}</span>
</v-col>
<v-col class="col-auto py-2">
<v-chip pill small class="text--disabled" v-if="excluded_objects.includes(object.name)">{{ $t('Panels.StatusPanel.Canceled') }}</v-chip>
<v-icon class="text--disabled cursor-pointer" @click="openCancelObjectDialog(object.name)" small v-else>mdi-close-circle</v-icon>
</v-col>
</v-row>
</v-container>
<v-divider class="mt-0 mb-0" ></v-divider>
</div>
</template>
<v-container>
<v-row>
<v-col class="py-1 font-italic text-center">
<span @click="boolShowObjects = !boolShowObjects" class="text--disabled cursor-pointer"><v-icon class="mr-3 text--disabled" small>mdi-chevron-{{ boolShowObjects ? 'up' : 'down' }}</v-icon><small>{{ $t('Panels.StatusPanel.CountObjects', {count: printing_objects.length}) }}</small><v-icon class="ml-3 text--disabled" small>mdi-chevron-{{ boolShowObjects ? 'up' : 'down' }}</v-icon></span>
</v-col>
</v-row>
</v-container>
<v-divider class="mt-0 mb-0" ></v-divider>
</template>
<status-panel-exclude-object
:show-dialog.sync="boolShowObjects"
@update:showDialog="updateShowDialog"
></status-panel-exclude-object>
<template v-if="display_message || print_stats_message">
<v-container>
<v-row>
@@ -304,21 +271,6 @@
</template>
</v-card-text>
</v-card>
<v-dialog v-model="cancelObjectDialog.bool" max-width="290">
<v-card>
<v-toolbar flat dense >
<v-toolbar-title>
<span class="subheading"><v-icon class="mdi mdi-information" left></v-icon>{{ $t("Panels.StatusPanel.ExcludeObjectHeadline") }}</span>
</v-toolbar-title>
</v-toolbar>
<v-card-text class="mt-3">{{ $t("Panels.StatusPanel.ExcludeObjectText", {name: cancelObjectDialog.objectName}) }}</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text @click="cancelObjectDialog.bool = false">{{ $t("Panels.StatusPanel.Cancel") }}</v-btn>
<v-btn color="primary" text @click="cancelObject">{{ $t("Panels.StatusPanel.ExcludeObject") }}</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>
@@ -330,19 +282,16 @@ import MinSettingsPanel from '@/components/panels/MinSettingsPanel.vue'
import MoonrakerStatePanel from '@/components/panels/MoonrakerStatePanel.vue'
import KlippyStatePanel from '@/components/panels/KlippyStatePanel.vue'
import KlipperWarningsPanel from '@/components/panels/KlipperWarningsPanel.vue'
import StatusPanelExcludeObject from '@/components/panels/StatusPanelExcludeObject.vue'
@Component({
components: {KlipperWarningsPanel, KlippyStatePanel, MoonrakerStatePanel, MinSettingsPanel}
components: {
StatusPanelExcludeObject, KlipperWarningsPanel, KlippyStatePanel, MoonrakerStatePanel, MinSettingsPanel}
})
export default class StatusPanel extends Mixins(BaseMixin) {
maxFlow = 0
boolShowObjects = false
cancelObjectDialog = {
bool: false,
objectName: ''
}
$refs!: {
bigThumbnail: any
}
@@ -422,6 +371,13 @@ export default class StatusPanel extends Mixins(BaseMixin) {
loadingName: 'statusPrintResume',
status: ['paused'],
click: this.btnResumeJob
}, {
text: this.$t('Panels.StatusPanel.ExcludeObject.ExcludeObject'),
color: 'orange',
icon: 'mdi-selection-remove',
loadingName: '',
status: this.printing_objects.length ? ['paused', 'printing'] : [],
click: this.btnExcludeObject
}, {
text: this.$t('Panels.StatusPanel.CancelPrint'),
color: 'red',
@@ -621,12 +577,8 @@ export default class StatusPanel extends Mixins(BaseMixin) {
return this.$store.state.printer.exclude_object?.objects ?? []
}
get current_object() {
return this.$store.state.printer.exclude_object?.current_object ?? null
}
get excluded_objects() {
return this.$store.state.printer.exclude_object?.excluded_objects ?? []
updateShowDialog(newVal: boolean) {
this.boolShowObjects = newVal
}
btnPauseJob() {
@@ -637,6 +589,10 @@ export default class StatusPanel extends Mixins(BaseMixin) {
this.$socket.emit('printer.print.resume', { }, { loading: 'statusPrintResume' })
}
btnExcludeObject() {
this.boolShowObjects = true
}
btnCancelJob() {
this.$socket.emit('printer.print.cancel', { }, { loading: 'statusPrintCancel' })
}
@@ -692,16 +648,6 @@ export default class StatusPanel extends Mixins(BaseMixin) {
}
}
openCancelObjectDialog(objectName: string) {
this.cancelObjectDialog.objectName = objectName
this.cancelObjectDialog.bool = true
}
cancelObject() {
this.$socket.emit('printer.gcode.script', {script: 'EXCLUDE_OBJECT NAME='+this.cancelObjectDialog.objectName})
this.cancelObjectDialog.bool = false
}
onResize() {
const isFocused = (document.activeElement === this.$refs.bigThumbnail?.$el)
if (isFocused) this.focusBigThumbnail()
@@ -0,0 +1,95 @@
<style lang="scss" scoped>
</style>
<template>
<div v-if="['printing', 'paused'].includes(printer_state) && printing_objects.length">
<v-container>
<v-row>
<v-col class="py-2">
<span class="subtitle-2 d-block px-0 text--disabled"><v-icon class="mr-2" small>mdi-printer-3d-nozzle</v-icon>{{ current_object !== null ? current_object : '--' }}</span>
</v-col>
<v-col class="col-auto py-2">
<v-icon class="text--disabled cursor-pointer" @click="openCancelObjectDialog(current_object)" small v-if="current_object !== null">mdi-close-circle</v-icon>
</v-col>
</v-row>
</v-container>
<v-divider class="mt-0 mb-0" ></v-divider>
<v-dialog v-model="boolShowExcludeObjectDialog" max-width="400">
<v-card>
<v-toolbar flat dense >
<v-toolbar-title>
<span class="subheading"><v-icon left>mdi-selection-remove</v-icon>{{ $t("Panels.StatusPanel.ExcludeObject.ExcludeObjectHeadline") }}</span>
</v-toolbar-title>
</v-toolbar>
<v-card-text class="mt-3">{{ $t("Panels.StatusPanel.ExcludeObject.ExcludeObjectText", {name: excludeObjectDialogName}) }}</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text @click="boolShowExcludeObjectDialog = false">{{ $t("Panels.StatusPanel.ExcludeObject.Cancel") }}</v-btn>
<v-btn color="primary" text @click="cancelObject">{{ $t("Panels.StatusPanel.ExcludeObject.ExcludeObject") }}</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<status-panel-exclude-object-dialog
:show-dialog.sync="showDialogPass"
:exclude-object-dialog-name.sync="excludeObjectDialogName"
@update:name="updateExcludeObjectDialogName"
:exclude-object-dialog-bool.sync="boolShowExcludeObjectDialog"
@update:bool="updateExcludeObjectDialogBool"
></status-panel-exclude-object-dialog>
</div>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import {Mixins, Prop} from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import StatusPanelExcludeObjectDialog from '@/components/panels/StatusPanelExcludeObjectDialog.vue'
@Component({
components: {StatusPanelExcludeObjectDialog}
})
export default class StatusPanelExcludeObject extends Mixins(BaseMixin) {
boolShowExcludeObjectDialog = false
excludeObjectDialogName = ''
@Prop({ required: true }) readonly showDialog!: boolean
get showDialogPass() {
return this.showDialog
}
set showDialogPass(newVal) {
this.$emit('update:showDialog', newVal )
}
get printing_objects() {
return this.$store.state.printer.exclude_object?.objects ?? []
}
get current_object() {
return this.$store.state.printer.exclude_object?.current_object ?? null
}
get excluded_objects() {
return this.$store.state.printer.exclude_object?.excluded_objects ?? []
}
updateExcludeObjectDialogName(newVal: string) {
this.excludeObjectDialogName = newVal
}
updateExcludeObjectDialogBool(newVal: boolean) {
this.boolShowExcludeObjectDialog = newVal
}
openCancelObjectDialog(objectName: string) {
this.excludeObjectDialogName = objectName
this.boolShowExcludeObjectDialog = true
}
cancelObject() {
this.$socket.emit('printer.gcode.script', {script: 'EXCLUDE_OBJECT NAME='+this.excludeObjectDialogName})
this.boolShowExcludeObjectDialog = false
}
}
</script>
@@ -0,0 +1,81 @@
<style lang="scss" scoped>
</style>
<template>
<div>
<v-dialog v-model="showDialog" width="900" persistent :fullscreen="isMobile">
<v-card style="overflow: hidden;">
<v-toolbar flat dense>
<v-toolbar-title>
<span class="subheading"><v-icon left>mdi-selection-remove</v-icon>{{ $t('Panels.StatusPanel.ExcludeObject.ExcludeObject') }}</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn small class="minwidth-0 px-2" color="grey darken-2" @click="hideDialog"><v-icon small>mdi-close-thick</v-icon></v-btn>
</v-toolbar>
<v-container>
<v-row>
<v-col class="col-12 col-sm-6 pb-0 pb-sm-3">
<status-panel-exclude-object-dialog-map
:hover-name="hoverName"
@update:name="updateExcludeObjectDialogName"
@update:bool="updateExcludeObjectDialogBool"
></status-panel-exclude-object-dialog-map>
</v-col>
<v-col class="col-12 col-sm-6 pt-0 pt-sm-3">
<status-panel-exclude-object-dialog-list
:exclude-object-dialog-name.sync="excludeObjectDialogName"
@update:name="updateExcludeObjectDialogName"
@update:hoverName="updateHoverObjectDialogName"
:exclude-object-dialog-bool.sync="excludeObjectDialogBool"
@update:bool="updateExcludeObjectDialogBool"
></status-panel-exclude-object-dialog-list>
</v-col>
</v-row>
</v-container>
</v-card>
</v-dialog>
</div>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import {Mixins, Prop} from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import StatusPanelExcludeObjectDialogMap from '@/components/panels/StatusPanelExcludeObjectDialogMap.vue'
import StatusPanelExcludeObjectDialogList from '@/components/panels/StatusPanelExcludeObjectDialogList.vue'
@Component({
components: {StatusPanelExcludeObjectDialogList, StatusPanelExcludeObjectDialogMap}
})
export default class StatusPanelExcludeObjectDialog extends Mixins(BaseMixin) {
private hoverName = ''
@Prop({ required: true }) readonly showDialog!: boolean
@Prop({ required: true }) readonly excludeObjectDialogBool!: boolean
@Prop({ required: true }) readonly excludeObjectDialogName!: string
hideDialog() {
this.$emit('update:showDialog', false )
}
get passName() {
return this.excludeObjectDialogName
}
set passName(newVal: string) {
this.$emit('update:name', newVal )
}
updateExcludeObjectDialogBool(newVal: boolean) {
this.$emit('update:bool', newVal )
}
updateExcludeObjectDialogName(newVal: string) {
this.$emit('update:name', newVal )
}
updateHoverObjectDialogName(newVal: string) {
this.hoverName = newVal
}
}
</script>
@@ -0,0 +1,50 @@
<style lang="scss" scoped>
</style>
<template>
<div>
<template v-for="object in printing_objects">
<v-row v-bind:key="'div_'+object.name" class="py-3 d-flex" @mouseover="mouseOverObject(object.name)" @mouseleave="mouseOverObject('')">
<v-col class="py-2 subtitle-2 text--disabled text-truncate">
{{ object.name }}
</v-col>
<v-col class="col-auto py-2">
<v-chip pill small class="text--disabled" v-if="excluded_objects.includes(object.name)">{{ $t('Panels.StatusPanel.ExcludeObject.Excluded') }}</v-chip>
<v-icon class="text--disabled cursor-pointer" @click="openExcludeObjectDialog(object.name)" small v-else>mdi-close-circle</v-icon>
</v-col>
</v-row>
<v-divider v-bind:key="'divider_'+object.name" ></v-divider>
</template>
</div>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import {Mixins} from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
@Component
export default class StatusPanelObjectsDialogList extends Mixins(BaseMixin) {
get printing_objects() {
return this.$store.state.printer.exclude_object?.objects ?? []
}
get current_object() {
return this.$store.state.printer.exclude_object?.current_object ?? null
}
get excluded_objects() {
return this.$store.state.printer.exclude_object?.excluded_objects ?? []
}
openExcludeObjectDialog(name: string) {
this.$emit('update:name', name)
this.$emit('update:bool', true)
}
mouseOverObject(name: string) {
this.$emit('update:hoverName', name)
}
}
</script>
@@ -0,0 +1,188 @@
<style lang="scss" scoped>
svg {
//background: rgba(200, 200, 200);
border: 2px solid #888;
}
#tooltipObjectMap {
display: none;
position: absolute;
background: black;
border-radius: 3px;
color: white;
padding: 3px 7px;
z-index: 100;
&:before {
display: block;
content: ' ';
width: 0;
height: 0;
position: absolute;
bottom: -10px;
left: 10px;
border-top: 10px solid black;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
}
}
</style>
<template>
<div style="position: relative;">
<div id="tooltipObjectMap" ref="tooltipObjectMap"></div>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" :viewBox="viewBox" xml:space="preserve">
<defs>
<marker id="arrowhead" markerWidth="5" markerHeight="4" refX="2" refY="2" orient="auto">
<polygon points="0 0, 5 2, 0 4" :fill="coordinationCrossColor" />
</marker>
</defs>
<line :x1="convertX(0)" :y1="convertY(1)" :x2="convertX(stepperXmax / 4)" :y2="convertY(1)" :stroke="coordinationCrossColor" stroke-width="2" marker-end="url(#arrowhead)" />
<line :x1="convertX(1)" :y1="convertY(0)" :x2="convertX(1)" :y2="convertY(stepperYmax / 4)" :stroke="coordinationCrossColor" stroke-width="2" marker-end="url(#arrowhead)" />
<g>
<line v-for="x in xStripes" v-bind:key="'xLines'+x" :x1="convertX(x)" :x2="convertX(x)" :y1="convertY(stepperYmin)" :y2="convertY(stepperYmax)" :stroke="coordinationCrossColor" :stroke-opacity="0.25" stroke-width="1" />
<line v-for="y in yStripes" v-bind:key="'yLines'+y" :x1="convertX(stepperXmin)" :x2="convertX(stepperXmax)" :y1="convertY(y)" :y2="convertY(y)" :stroke="coordinationCrossColor" :stroke-opacity="0.25" stroke-width="1" />
</g>
<g v-for="(object, index) in printing_objects" v-bind:key="index">
<polygon
:points="object.polygon.map(point => convertX(point[0])+','+convertY(point[1])).join(' ')"
style="cursor: pointer;"
:stroke="current_object === object.name ? primaryColor : '#666'"
stroke-width="2"
fill-rule="evenodd"
:fill="hoverName === object.name ? primaryColor : (excluded_objects.includes(object.name) ? '#6668' : '#bbb')"
@mouseover="showObjectTooltip(object.name)"
@mouseout="hideObjectTooltip"
@click="openExcludeObjectDialog(object.name)"
/>
</g>
</svg>
</div>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import {Mixins, Prop} from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
@Component
export default class StatusPanelObjectsDialogMap extends Mixins(BaseMixin) {
private coordinationCrossColor = '#888'
private stripesOffset = 50
@Prop({ required: false, default: '' }) readonly hoverName!: string
$refs!: {
tooltipObjectMap: HTMLDivElement
}
get printing_objects() {
return this.$store.state.printer.exclude_object?.objects ?? []
}
get current_object() {
return this.$store.state.printer.exclude_object?.current_object ?? null
}
get excluded_objects() {
return this.$store.state.printer.exclude_object?.excluded_objects ?? []
}
get viewBox() {
return this.convertX(this.stepperXmin)+' '+this.convertY(this.stepperYmax)+' '+this.absoluteX+' '+this.absoluteY
}
get stepperXmin() {
return this.$store.state.printer.configfile?.settings?.stepper_x?.position_min ?? 0
}
get stepperXmax() {
return this.$store.state.printer.configfile?.settings?.stepper_x?.position_max ?? 0
}
get stepperYmin() {
return this.$store.state.printer.configfile?.settings?.stepper_y?.position_min ?? 200
}
get stepperYmax() {
return this.$store.state.printer.configfile?.settings?.stepper_y?.position_max ?? 200
}
get absoluteX() {
return Math.abs(this.stepperXmin) + Math.abs(this.stepperXmax)
}
get absoluteY() {
return Math.abs(this.stepperYmin) + Math.abs(this.stepperYmax)
}
get xStripes() {
const output = []
const minXstripe = Math.floor(this.stepperXmin / this.stripesOffset) * this.stripesOffset
const maxXstripe = Math.floor(this.stepperXmax / this.stripesOffset) * this.stripesOffset
for (let i = minXstripe; i <= maxXstripe; i = i + this.stripesOffset) {
output.push(i)
}
return output
}
get yStripes() {
const output = []
const minYstripe = Math.floor(this.stepperYmin / this.stripesOffset) * this.stripesOffset
const maxYstripe = Math.floor(this.stepperYmax / this.stripesOffset) * this.stripesOffset
for (let i = minYstripe; i <= maxYstripe; i = i + this.stripesOffset) {
output.push(i)
}
return output
}
get primaryColor() {
return this.$store.state.gui.theme.primary
}
convertX(x: number) {
return x
}
convertY(y: number) {
return y * -1
}
showObjectTooltip(text: string) {
if (this.$refs.tooltipObjectMap) {
this.$refs.tooltipObjectMap.innerHTML = text
this.$refs.tooltipObjectMap.style.display = 'block'
}
window.addEventListener('mousemove', this.moveTooltip)
}
hideObjectTooltip() {
if (this.$refs.tooltipObjectMap) {
this.$refs.tooltipObjectMap.style.display = 'none'
}
window.removeEventListener('mousemove', this.moveTooltip)
}
moveTooltip(event: any) {
if (this.$refs.tooltipObjectMap) {
this.$refs.tooltipObjectMap.style.left = (event.layerX - 20) + 'px'
this.$refs.tooltipObjectMap.style.top = (event.layerY - 45) + 'px'
}
}
openExcludeObjectDialog(name: string) {
this.$emit('update:name', name)
this.$emit('update:bool', true)
}
}
</script>
+7 -6
View File
@@ -337,12 +337,13 @@
"Slicer": "Slicer",
"ETA": "ETA",
"Unknown": "Unknown",
"ExcludeObjectHeadline": "Exclude Object",
"ExcludeObjectText": "Do you really want to exclude \"{name}\"?",
"Cancel": "cancel",
"ExcludeObject": "Exclude object",
"CountObjects": "{count} Objects",
"Canceled": "Canceled"
"ExcludeObject": {
"ExcludeObject": "Exclude Object",
"Excluded": "Excluded",
"ExcludeObjectHeadline": "Exclude Object",
"ExcludeObjectText": "Do you really want to exclude \"{name}\"?",
"Cancel": "cancel"
}
},
"ToolsPanel": {
"Headline": "Temperatures",