Skip to content

Commit 86daf10

Browse files
committed
refactor: removes parts module
Signed-off-by: Pedro Lamas <[email protected]>
1 parent d53e1d6 commit 86daf10

File tree

18 files changed

+103
-265
lines changed

18 files changed

+103
-265
lines changed

src/components/widgets/exclude-objects/ExcludeObjects.vue

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,74 @@
11
<template>
22
<g id="parts">
3-
<g
4-
v-for="name in parts"
5-
:key="name"
6-
:class="iconClasses(name)"
7-
class="layer"
8-
>
9-
<path
10-
class="partOutline"
11-
:d="partSVG(name)"
12-
:shape-rendering="shapeRendering"
13-
/>
14-
<svg
15-
width="7"
16-
height="7"
17-
viewBox="0 0 24 24"
18-
class="partIcon"
19-
:x="partPos(name).x - 7/2"
20-
:y="partPos(name).y - 7/2"
3+
<template v-for="part in parts">
4+
<g
5+
v-if="(
6+
part.polygon &&
7+
part.polygon.length > 0 &&
8+
part.center &&
9+
part.center.length >= 2
10+
)"
11+
:key="part.name"
12+
:class="iconClasses(part)"
13+
class="layer"
2114
>
22-
<path :d="iconCancelled" />
2315
<path
24-
v-if="!isPartExcluded(name)"
25-
v-touch:tap="() => $emit('cancel', name)"
26-
:d="iconCircle"
27-
class="hitarea"
16+
class="partOutline"
17+
:d="partSVG(part)"
18+
:shape-rendering="shapeRendering"
2819
/>
29-
</svg>
30-
</g>
20+
<svg
21+
width="7"
22+
height="7"
23+
viewBox="0 0 24 24"
24+
class="partIcon"
25+
:x="part.center[0] - 7/2"
26+
:y="part.center[1] - 7/2"
27+
>
28+
<path :d="iconCancelled" />
29+
<path
30+
v-if="!part.isExcluded"
31+
v-touch:tap="() => $emit('cancel', part.name)"
32+
:d="iconCircle"
33+
class="hitarea"
34+
/>
35+
</svg>
36+
</g>
37+
</template>
3138
</g>
3239
</template>
3340

3441
<script lang="ts">
3542
import { Component, Mixins, Prop } from 'vue-property-decorator'
3643
import StateMixin from '@/mixins/state'
3744
import { Icons } from '@/globals'
45+
import type { ExcludeObjectPart } from '@/store/printer/types'
3846
3947
@Component({})
4048
export default class ExcludeObjects extends Mixins(StateMixin) {
4149
@Prop({ type: String })
4250
readonly shapeRendering?: string
4351
4452
get parts () {
45-
const parts = this.$store.getters['parts/getParts']
46-
return Object.keys(parts)
53+
return this.$store.getters['printer/getExcludeObjectParts'] as ExcludeObjectPart[]
4754
}
4855
49-
iconClasses (name: string) {
50-
return this.isPartExcluded(name) ? 'partExcluded' : this.isPartCurrent(name) ? 'partCurrent' : 'partIncluded'
56+
iconClasses (part: ExcludeObjectPart) {
57+
if (part.isExcluded) {
58+
return 'partExcluded'
59+
} else if (part.isCurrent) {
60+
return 'partCurrent'
61+
} else {
62+
return 'partIncluded'
63+
}
5164
}
5265
53-
partSVG (name: string) {
54-
return this.$store.getters['parts/getPartSVG'](name)
66+
partSVG (part: ExcludeObjectPart) {
67+
const polygonAsString = part.polygon!
68+
.map(point => `${point[0]},${point[1]}`)
69+
.join('L')
70+
71+
return `M${polygonAsString}z`
5572
}
5673
5774
get iconCancelled () {
@@ -61,18 +78,6 @@ export default class ExcludeObjects extends Mixins(StateMixin) {
6178
get iconCircle () {
6279
return Icons.circle
6380
}
64-
65-
partPos (name: string) {
66-
return this.$store.getters['parts/getPartPos'](name)
67-
}
68-
69-
isPartCurrent (name: string) {
70-
return this.$store.getters['parts/getIsPartCurrent'](name)
71-
}
72-
73-
isPartExcluded (name: string) {
74-
return this.$store.getters['parts/getIsPartExcluded'](name)
75-
}
7681
}
7782
</script>
7883

src/components/widgets/exclude-objects/ExcludeObjectsDialog.vue

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
<v-simple-table>
1010
<tbody>
1111
<tr
12-
v-for="name in parts"
13-
:key="name"
12+
v-for="part in parts"
13+
:key="part.name"
1414
>
1515
<td
1616
:class="{
17-
'text--disabled': isPartExcluded(name),
18-
'info--text': isPartCurrent(name)
17+
'text--disabled': part.isExcluded,
18+
'info--text': part.isCurrent
1919
}"
2020
class="partName"
2121
>
22-
{{ name }}
22+
{{ part.name }}
2323
</td>
2424
<td class="actions">
2525
<app-btn
2626
icon
27-
:disabled="isPartExcluded(name)"
28-
@click="cancelObject(name)"
27+
:disabled="part.isExcluded"
28+
@click="cancelObject(part.name)"
2929
>
3030
<v-icon
3131
dense
@@ -46,23 +46,15 @@
4646
import { Component, Mixins, VModel } from 'vue-property-decorator'
4747
import StateMixin from '@/mixins/state'
4848
import { encodeGcodeParamValue } from '@/util/gcode-helpers'
49+
import type { ExcludeObjectPart } from '@/store/printer/types'
4950
5051
@Component({})
5152
export default class ExcludeObjectDialog extends Mixins(StateMixin) {
5253
@VModel({ type: Boolean })
5354
open?: boolean
5455
55-
get parts () {
56-
const parts = this.$store.getters['parts/getParts']
57-
return Object.keys(parts)
58-
}
59-
60-
isPartExcluded (name: string) {
61-
return this.$store.getters['parts/getIsPartExcluded'](name)
62-
}
63-
64-
isPartCurrent (name: string) {
65-
return this.$store.getters['parts/getIsPartCurrent'](name)
56+
get parts (): ExcludeObjectPart[] {
57+
return this.$store.getters['printer/getExcludeObjectParts'] as ExcludeObjectPart[]
6658
}
6759
6860
async cancelObject (name: string) {

src/components/widgets/gcode-preview/GcodePreview.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,12 @@ export default class GcodePreview extends Mixins(StateMixin, BrowserMixin) {
503503
return this.panning ? 'optimizeSpeed' : 'geometricPrecision'
504504
}
505505
506-
get hasParts (): boolean {
507-
return this.$store.getters['parts/getHasParts'] as boolean
506+
get hasExcludeObjectParts (): boolean {
507+
return this.$store.getters['printer/getHasExcludeObjectParts'] as boolean
508508
}
509509
510510
get showExcludeObjects (): boolean {
511-
if (!this.hasParts) {
511+
if (!this.klippyReady || !this.hasExcludeObjectParts) {
512512
return false
513513
}
514514

src/components/widgets/gcode-preview/GcodePreviewCard.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,6 @@ export default class GcodePreviewCard extends Mixins(StateMixin, FilesMixin, Bro
404404
}
405405
}
406406
407-
get parts () {
408-
return Object.values(this.$store.getters['parts/getParts'])
409-
}
410-
411407
handleDragOver (event: DragEvent) {
412408
if (
413409
event.dataTransfer &&

src/components/widgets/status/StatusControls.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<template #activator="{ on, attrs }">
6464
<app-btn
6565
v-bind="attrs"
66-
:disabled="!hasParts"
66+
:disabled="!hasExcludeObjectParts"
6767
icon
6868
v-on="on"
6969
@click="showExcludeObjectDialog = true"
@@ -116,8 +116,8 @@ export default class StatusControls extends Mixins(StateMixin) {
116116
return this.$store.getters['server/componentSupport']('history') as boolean
117117
}
118118
119-
get hasParts (): boolean {
120-
return this.$store.getters['parts/getHasParts'] as boolean
119+
get hasExcludeObjectParts (): boolean {
120+
return this.$store.getters['printer/getHasExcludeObjectParts'] as boolean
121121
}
122122
123123
resetFile () {

src/store/helpers.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,6 @@ export const handleTrinamicDriversChange = (payload: any, state: RootState, disp
3535
}
3636
}
3737

38-
export const handleExcludeObjectChange = (payload: any, state: RootState, dispatch: Dispatch) => {
39-
// For every notify - if print_stats.state changes from standby -> printing,
40-
// then record an entry in our print history.
41-
// If the state changes from printing -> complete, then record the finish time.
42-
if ('exclude_object' in payload) {
43-
dispatch('parts/onPartUpdate', payload.exclude_object, { root: true })
44-
}
45-
46-
if (
47-
'print_stats' in payload &&
48-
('state' in payload.print_stats || 'filename' in payload.print_stats)
49-
) {
50-
dispatch('parts/onPrintStatsUpdate', payload.print_stats, { root: true })
51-
}
52-
}
53-
5438
export const handlePrintStateChange = (payload: any, state: RootState, dispatch: Dispatch) => {
5539
// For every notify - if print_stats.state changes from standby -> printing,
5640
// then record an entry in our print history.

src/store/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { announcements } from './announcements'
2424
import { wait } from './wait'
2525
import { gcodePreview } from './gcodePreview'
2626
import { timelapse } from './timelapse'
27-
import { parts } from './parts'
2827
import { webcams } from './webcams'
2928
import { jobQueue } from './jobQueue'
3029
import { spoolman } from './spoolman'
@@ -54,7 +53,6 @@ export default new Vuex.Store<RootState>({
5453
wait,
5554
gcodePreview,
5655
timelapse,
57-
parts,
5856
webcams,
5957
jobQueue,
6058
spoolman,

src/store/parts/actions.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/store/parts/getters.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/store/parts/index.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)