@@ -124,11 +124,12 @@ const contourToolsNames = [
124
124
let selectedToolName = contourToolsNames [ 0 ] ;
125
125
126
126
const segmentIndices = [ 1 , 2 , 3 , 4 , 5 ] ;
127
- let sourceSegmentIndex = segmentIndices [ 0 ] ;
128
- let targetSegmentIndex = segmentIndices [ 1 ] ;
127
+ let firstSegmentIndex = segmentIndices [ 0 ] ;
128
+ let secondSegmentIndex = segmentIndices [ 1 ] ;
129
+ let outputSegmentIndex = segmentIndices [ 0 ] ;
129
130
130
131
addDropdownToToolbar ( {
131
- labelText : 'Active segment' ,
132
+ labelText : 'Drawing segment' ,
132
133
options : { values : segmentIndices , defaultValue : segmentIndices [ 0 ] } ,
133
134
onSelectedValueChange : ( nameAsStringOrNumber ) => {
134
135
const segmentIndex = Number ( nameAsStringOrNumber ) ;
@@ -158,10 +159,10 @@ addDropdownToToolbar({
158
159
} ) ;
159
160
160
161
addDropdownToToolbar ( {
161
- labelText : 'Source segment' ,
162
+ labelText : 'First segment' ,
162
163
options : { values : segmentIndices , defaultValue : segmentIndices [ 0 ] } ,
163
164
onSelectedValueChange : ( nameAsStringOrNumber ) => {
164
- sourceSegmentIndex = Number ( nameAsStringOrNumber ) ;
165
+ firstSegmentIndex = Number ( nameAsStringOrNumber ) ;
165
166
} ,
166
167
} ) ;
167
168
@@ -189,55 +190,57 @@ addDropdownToToolbar({
189
190
selectedOperation = LogicalOperation . Delete ;
190
191
break ;
191
192
}
192
- // Enable/disable the target segment dropdown based on operation
193
- const targetDropdown = document . getElementById (
194
- 'targetSegmentIndex '
193
+ // Enable/disable the second segment dropdown based on operation
194
+ const secondDropdown = document . getElementById (
195
+ 'secondSegmentIndex '
195
196
) as HTMLSelectElement | null ;
196
- if ( targetDropdown ) {
197
+ if ( secondDropdown ) {
197
198
if (
198
199
selectedOperation === LogicalOperation . Copy ||
199
200
selectedOperation === LogicalOperation . Delete
200
201
) {
201
- targetDropdown . disabled = true ;
202
+ secondDropdown . disabled = true ;
202
203
} else {
203
- targetDropdown . disabled = false ;
204
+ secondDropdown . disabled = false ;
204
205
}
205
206
}
206
- // Enable/disable the "Apply operation and create new segment" button for Copy/Delete
207
- const applyAndCreateNewSegmentBtn = document . getElementById (
208
- 'applyAndCreateNewSegment'
209
- ) as HTMLButtonElement | null ;
210
- if ( applyAndCreateNewSegmentBtn ) {
207
+
208
+ // Enable/disable the output segment dropdown based on operation
209
+ const outputDropDown = document . getElementById (
210
+ 'outputSegmentIndex'
211
+ ) as HTMLSelectElement | null ;
212
+ if ( outputDropDown ) {
211
213
if ( selectedOperation === LogicalOperation . Delete ) {
212
- applyAndCreateNewSegmentBtn . disabled = true ;
214
+ outputDropDown . disabled = true ;
213
215
} else {
214
- applyAndCreateNewSegmentBtn . disabled = false ;
216
+ outputDropDown . disabled = false ;
215
217
}
216
218
}
217
219
} ,
218
220
} ) ;
219
221
220
222
addDropdownToToolbar ( {
221
- id : 'targetSegmentIndex ' ,
222
- labelText : 'Target segment' ,
223
+ id : 'secondSegmentIndex ' ,
224
+ labelText : 'Second segment' ,
223
225
options : { values : segmentIndices , defaultValue : segmentIndices [ 1 ] } ,
224
226
onSelectedValueChange : ( nameAsStringOrNumber ) => {
225
- targetSegmentIndex = Number ( nameAsStringOrNumber ) ;
227
+ secondSegmentIndex = Number ( nameAsStringOrNumber ) ;
226
228
} ,
227
229
} ) ;
228
230
229
- addButtonToToolbar ( {
230
- title : 'Apply operation' ,
231
- onClick : function ( ) {
232
- performLogicalOperation ( selectedOperation , false ) ;
231
+ addDropdownToToolbar ( {
232
+ id : 'outputSegmentIndex' ,
233
+ labelText : '= Output segment' ,
234
+ options : { values : segmentIndices , defaultValue : segmentIndices [ 0 ] } ,
235
+ onSelectedValueChange : ( nameAsStringOrNumber ) => {
236
+ outputSegmentIndex = Number ( nameAsStringOrNumber ) ;
233
237
} ,
234
238
} ) ;
235
239
236
240
addButtonToToolbar ( {
237
- id : 'applyAndCreateNewSegment' ,
238
- title : 'Apply operation and create new segment' ,
241
+ title : 'Apply operation' ,
239
242
onClick : function ( ) {
240
- performLogicalOperation ( selectedOperation , true ) ;
243
+ performLogicalOperation ( selectedOperation , false ) ;
241
244
} ,
242
245
} ) ;
243
246
@@ -262,16 +265,9 @@ function performLogicalOperation(
262
265
263
266
if ( annotationUIDsMap ) {
264
267
const segmentIndexes = Array . from ( annotationUIDsMap . keys ( ) ) ;
265
- let newIndex = 0 ;
266
- if ( createNew ) {
267
- newIndex = Math . max ( ...segmentIndexes ) + 1 ;
268
- } else {
269
- newIndex = targetSegmentIndex ;
270
- }
271
268
const operatorOptions = {
272
269
segmentationId : activeSeg . segmentationId ,
273
- label : 'Combined Addition' ,
274
- segmentIndex : newIndex ,
270
+ segmentIndex : outputSegmentIndex ,
275
271
color : 'rgb(50, 130, 162)' ,
276
272
} ;
277
273
@@ -280,14 +276,14 @@ function performLogicalOperation(
280
276
copy (
281
277
{
282
278
segmentationId : activeSeg . segmentationId ,
283
- segmentIndex : sourceSegmentIndex ,
279
+ segmentIndex : firstSegmentIndex ,
284
280
} ,
285
281
operatorOptions
286
282
) ;
287
283
} else if ( operation === LogicalOperation . Delete ) {
288
284
deleteOperation ( {
289
285
segmentationId : activeSeg . segmentationId ,
290
- segmentIndex : sourceSegmentIndex ,
286
+ segmentIndex : firstSegmentIndex ,
291
287
} ) ;
292
288
}
293
289
}
@@ -296,47 +292,47 @@ function performLogicalOperation(
296
292
add (
297
293
{
298
294
segmentationId : activeSeg . segmentationId ,
299
- segmentIndex : sourceSegmentIndex ,
295
+ segmentIndex : firstSegmentIndex ,
300
296
} ,
301
297
{
302
298
segmentationId : activeSeg . segmentationId ,
303
- segmentIndex : targetSegmentIndex ,
299
+ segmentIndex : secondSegmentIndex ,
304
300
} ,
305
301
operatorOptions
306
302
) ;
307
303
} else if ( operation === LogicalOperation . Subtract ) {
308
304
subtract (
309
305
{
310
306
segmentationId : activeSeg . segmentationId ,
311
- segmentIndex : sourceSegmentIndex ,
307
+ segmentIndex : firstSegmentIndex ,
312
308
} ,
313
309
{
314
310
segmentationId : activeSeg . segmentationId ,
315
- segmentIndex : targetSegmentIndex ,
311
+ segmentIndex : secondSegmentIndex ,
316
312
} ,
317
313
operatorOptions
318
314
) ;
319
315
} else if ( operation === LogicalOperation . Intersect ) {
320
316
intersect (
321
317
{
322
318
segmentationId : activeSeg . segmentationId ,
323
- segmentIndex : sourceSegmentIndex ,
319
+ segmentIndex : firstSegmentIndex ,
324
320
} ,
325
321
{
326
322
segmentationId : activeSeg . segmentationId ,
327
- segmentIndex : targetSegmentIndex ,
323
+ segmentIndex : secondSegmentIndex ,
328
324
} ,
329
325
operatorOptions
330
326
) ;
331
327
} else if ( operation === LogicalOperation . XOR ) {
332
328
xor (
333
329
{
334
330
segmentationId : activeSeg . segmentationId ,
335
- segmentIndex : sourceSegmentIndex ,
331
+ segmentIndex : firstSegmentIndex ,
336
332
} ,
337
333
{
338
334
segmentationId : activeSeg . segmentationId ,
339
- segmentIndex : targetSegmentIndex ,
335
+ segmentIndex : secondSegmentIndex ,
340
336
} ,
341
337
operatorOptions
342
338
) ;
0 commit comments