Skip to content

Commit cd4c69f

Browse files
committed
refactor(PaintControls): factor out FillBetweenControls
1 parent 9cdf4f7 commit cd4c69f

2 files changed

Lines changed: 77 additions & 69 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<template>
2+
<v-col>
3+
<div class="mb-2 d-flex align-center">
4+
<mini-expansion-panel>
5+
<template #title> Interpolate segmentation between slices. </template>
6+
<ul>
7+
<li>
8+
Will only fill between segmented slices where none of their direct
9+
neighbors are segmented.
10+
</li>
11+
<li>Only the selected segment will be filled between.</li>
12+
<li>
13+
Uses
14+
<a
15+
href="https://insight-journal.org/browse/publication/977"
16+
target="_blank"
17+
>
18+
morphological contour interpolation
19+
</a>
20+
method.
21+
</li>
22+
</ul>
23+
</mini-expansion-panel>
24+
</div>
25+
<v-row justify="space-between" no-gutters>
26+
<v-btn
27+
variant="tonal"
28+
:prepend-icon="fillStep === 'computing' ? '' : 'mdi-cogs'"
29+
@click="startCompute"
30+
:disabled="fillStep !== 'start'"
31+
:loading="fillStep === 'computing'"
32+
>
33+
Preview
34+
</v-btn>
35+
<v-btn
36+
variant="tonal"
37+
prepend-icon="mdi-check"
38+
:disabled="fillStep !== 'previewing'"
39+
@click="confirmFill"
40+
>
41+
Confirm
42+
</v-btn>
43+
<v-btn
44+
variant="tonal"
45+
prepend-icon="mdi-cancel"
46+
:disabled="fillStep !== 'previewing'"
47+
@click="cancelFill"
48+
>
49+
Cancel
50+
</v-btn>
51+
</v-row>
52+
</v-col>
53+
</template>
54+
55+
<script setup lang="ts">
56+
import { computed } from 'vue';
57+
import MiniExpansionPanel from './MiniExpansionPanel.vue';
58+
import { useFillBetweenStore } from '../store/tools/fillBetween';
59+
import { usePaintToolStore } from '../store/tools/paint';
60+
61+
const fillBetweenStore = useFillBetweenStore();
62+
const paintStore = usePaintToolStore();
63+
64+
const fillStep = computed(() => fillBetweenStore.fillStep);
65+
66+
function startCompute() {
67+
const id = paintStore.activeSegmentGroupID;
68+
if (!id) return;
69+
fillBetweenStore.computeFillBetween(id);
70+
}
71+
72+
const confirmFill = () => fillBetweenStore.confirmFill();
73+
const cancelFill = () => fillBetweenStore.cancelFill();
74+
</script>

src/components/PaintControls.vue

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -78,59 +78,7 @@
7878
</template>
7979
</v-slider>
8080

81-
<v-col v-if="mode === PaintMode.FillBetween">
82-
<div class="mb-2 d-flex align-center">
83-
<mini-expansion-panel>
84-
<template #title>
85-
Interpolate segmentation between slices.
86-
</template>
87-
<ul>
88-
<li>
89-
Will only fill between segmented slices where none of their
90-
direct neighbors are segmented.
91-
</li>
92-
<li>Only the selected segment will be filled between.</li>
93-
<li>
94-
Uses
95-
<a
96-
href="https://insight-journal.org/browse/publication/977"
97-
target="_blank"
98-
>
99-
morphological contour interpolation
100-
</a>
101-
method.
102-
</li>
103-
</ul>
104-
</mini-expansion-panel>
105-
</div>
106-
<v-row justify="space-between" no-gutters>
107-
<v-btn
108-
variant="tonal"
109-
:prepend-icon="fillStep === 'computing' ? '' : 'mdi-cogs'"
110-
@click="startCompute"
111-
:disabled="fillStep !== 'start'"
112-
:loading="fillStep === 'computing'"
113-
>
114-
Preview
115-
</v-btn>
116-
<v-btn
117-
variant="tonal"
118-
prepend-icon="mdi-check"
119-
:disabled="fillStep !== 'previewing'"
120-
@click="confirmFill"
121-
>
122-
Confirm
123-
</v-btn>
124-
<v-btn
125-
variant="tonal"
126-
prepend-icon="mdi-cancel"
127-
:disabled="fillStep !== 'previewing'"
128-
@click="cancelFill"
129-
>
130-
Cancel
131-
</v-btn>
132-
</v-row>
133-
</v-col>
81+
<FillBetweenControls v-if="mode === PaintMode.FillBetween" />
13482
</v-row>
13583
</v-container>
13684
</template>
@@ -140,14 +88,13 @@ import { defineComponent, computed } from 'vue';
14088
import { storeToRefs } from 'pinia';
14189
import { PaintMode } from '@/src/core/tools/paint';
14290
import { usePaintToolStore } from '../store/tools/paint';
143-
import { useFillBetweenStore } from '../store/tools/fillBetween';
144-
import MiniExpansionPanel from './MiniExpansionPanel.vue';
91+
import FillBetweenControls from './FillBetweenControls.vue';
14592
14693
export default defineComponent({
14794
name: 'PaintControls',
14895
14996
components: {
150-
MiniExpansionPanel,
97+
FillBetweenControls,
15198
},
15299
153100
setup() {
@@ -165,24 +112,11 @@ export default defineComponent({
165112
},
166113
});
167114
168-
const fillBetweenStore = useFillBetweenStore();
169-
const fillStep = computed(() => fillBetweenStore.fillStep);
170-
171-
const startCompute = () => {
172-
const id = paintStore.activeSegmentGroupID;
173-
if (!id) return;
174-
fillBetweenStore.computeFillBetween(id);
175-
};
176-
177115
return {
178116
brushSize,
179117
setBrushSize,
180118
mode,
181119
PaintMode,
182-
fillStep,
183-
startCompute,
184-
confirmFill: fillBetweenStore.confirmFill,
185-
cancelFill: fillBetweenStore.cancelFill,
186120
};
187121
},
188122
});

0 commit comments

Comments
 (0)