@@ -41,7 +41,7 @@ export type ProcessAlgorithm = (
4141 activeSegment : number
4242) => Promise < TypedArray | number [ ] > ;
4343
44- export const useProcessStore = defineStore ( 'process ' , ( ) => {
44+ export const usePaintProcessStore = defineStore ( 'paintProcess ' , ( ) => {
4545 const processState = ref < ProcessState > ( { step : 'start' } ) ;
4646 const activeProcessType = ref < ProcessType > ( ProcessType . FillBetween ) ;
4747
@@ -89,31 +89,26 @@ export const useProcessStore = defineStore('process', () => {
8989 activeProcessType . value = processType ;
9090 }
9191
92- async function computeProcess ( groupId : string , algorithm : ProcessAlgorithm ) {
92+ async function startProcess ( groupId : string , algorithm : ProcessAlgorithm ) {
93+ if ( ! paintStore . activeSegment ) {
94+ messageStore . addError ( 'No active segment selected' ) ;
95+ return ;
96+ }
97+
9398 const segImage = segmentGroupStore . dataIndex [ groupId ] ;
94- const state = processState . value ;
9599
96- const originalScalars =
97- state . step === 'previewing'
98- ? state . originalScalars
99- : segImage . getPointData ( ) . getScalars ( ) . getData ( ) . slice ( ) ;
100-
101- if ( state . step === 'previewing' ) {
102- rollbackPreview ( segImage , state . originalScalars ) ;
103- }
100+ const originalScalars = segImage
101+ . getPointData ( )
102+ . getScalars ( )
103+ . getData ( )
104+ . slice ( ) ;
104105
105106 processState . value = {
106107 step : 'computing' ,
107108 activeParentImageID : segmentGroupStore . metadataByID [ groupId ] . parentImage ,
108109 processType : activeProcessType . value ,
109110 } ;
110111
111- if ( ! paintStore . activeSegment ) {
112- messageStore . addError ( 'No active segment selected' ) ;
113- resetState ( ) ;
114- return ;
115- }
116-
117112 try {
118113 const outputScalars = await algorithm ( segImage , paintStore . activeSegment ) ;
119114
@@ -158,11 +153,9 @@ export const useProcessStore = defineStore('process', () => {
158153 ? state . originalScalars
159154 : state . processedScalars ;
160155
161- // Update the image display
162156 state . segImage . getPointData ( ) . getScalars ( ) . setData ( scalarsToShow ) ;
163157 state . segImage . modified ( ) ;
164158
165- // Update the state
166159 processState . value = {
167160 ...state ,
168161 showingOriginal : newShowingOriginal ,
@@ -200,7 +193,7 @@ export const useProcessStore = defineStore('process', () => {
200193 activeProcessType,
201194 showingOriginal,
202195 setActiveProcessType,
203- computeProcess ,
196+ startProcess ,
204197 confirmProcess,
205198 cancelProcess,
206199 togglePreview,
0 commit comments